EOF;
return $code;
} // end createHeader();
/**
* Creates a common footer for each page.
*
* @return String
*/
public function createFooter()
{
$translate = tfTranslate::get();
if(strlen($this->project->config['copyrightLink']) > 0)
{
$copyright = '
'.$this->project->config['copyright'].'';
}
else
{
$copyright = $this->project->config['copyright'];
}
if(strlen($this->project->config['licenseLink']) > 0)
{
$license = '
'.$this->project->config['license'].'';
}
else
{
$license = $this->project->config['license'];
}
$textLicense = $translate->_('general','doc_license',$license);
$version = tfMain::VERSION;
$code = <<
EOF;
return $code;
} // end createFooter();
/**
* Creates the navigation above the page contents.
*
* @param Array &$page The page meta-info.
* @return String
*/
public function createTopNavigator(&$page)
{
$n =& $this->project->config['showNumbers'];
$translate = tfTranslate::get();
$parent = $this->project->getMetaInfo($page['_Parent'], false);
$prev = $this->project->getMetaInfo($page['_Previous'], false);
$next = $this->project->getMetaInfo($page['_Next'], false);
$code = '
';
if(!is_null($parent))
{
$code .= '- '.($n ? $parent['FullNumber'].'. ' : '').$parent['Tags']['Title'].'
'.($n ? $page['FullNumber'].'. ' : '').$page['Tags']['Title'].' ';
}
else
{
$code .= '- '.$translate->_('general','table_of_contents').'
'.($n ? $page['FullNumber'].'. ' : '').$page['Tags']['Title'].' ';
}
if(!is_null($prev))
{
$code .= '- '.($n ? $prev['FullNumber'].'. ' : '').$prev['Tags']['Title'].'
« '.$translate->_('navigation','prev').' ';
}
if(!is_null($next))
{
$code .= '- '.($n ? $next['FullNumber'].'. ' : '').$next['Tags']['Title'].'
'.$translate->_('navigation','next').' » ';
}
$code .= '
';
return $code;
} // end createTopNavigator();
/**
* Creates the navigation below the page contents.
*
* @param Array &$page The page meta-info.
* @return String
*/
public function createBottomNavigator(&$page)
{
$n =& $this->project->config['showNumbers'];
$translate = tfTranslate::get();
$parent = $this->project->getMetaInfo($page['_Parent'], false);
$prev = $this->project->getMetaInfo($page['_Previous'], false);
$next = $this->project->getMetaInfo($page['_Next'], false);
$code = '
';
if(!is_null($parent))
{
$code .= '- '.($n ? $page['FullNumber'].'. ' : '').$page['Tags']['Title'].'
'.($n ? $parent['FullNumber'].'. ' : '').$parent['Tags']['Title'].' ';
}
else
{
$code .= '- '.($n ? $page['FullNumber'].'. ' : '').$page['Tags']['Title'].'
'.$translate->_('general','table_of_contents').' ';
}
if(!is_null($prev))
{
$code .= '- « '.$translate->_('navigation','prev').'
'.($n ? $prev['FullNumber'].'. ' : '').$prev['Tags']['Title'].' ';
}
if(!is_null($next))
{
$code .= '- '.$translate->_('navigation','next').' »
'.($n ? $next['FullNumber'].'. ' : '').$next['Tags']['Title'].' ';
}
$code .= '
';
return $code;
} // end createBottomNavigator();
/**
* Generates a menu.
*
* @param String $what The root page.
* @param Boolean $recursive Do we need a recursive tree?
* @param Boolean $start Do we include the "Table of contents" text?
* @return String
*/
public function menuGen($what, $recursive = true, $start = false)
{
$n =& $this->project->config['showNumbers'];
$translate = tfTranslate::get();
$code = '';
if($start)
{
$code .= '
'.$translate->_('general','table_of_contents').'
';
}
if(isset($this->project->tree[$what]) && count($this->project->tree[$what]) > 0)
{
$code .= '
';
return $code;
}
return '';
} // end menuGen();
/**
* Converts the page identifier to the URL.
*
* @param String $page The page identifier.
* @return String
*/
public function toAddress($page)
{
return $page.'.html';
} // end toAddress();
/**
* Creates "See also" links below the page content.
*
* @param Array $standard The links within the documentation
* @param Array $external The external SeeAlso links
* @return String
*/
public function _tagSeeAlso($standard, $external)
{
$n =& $this->project->config['showNumbers'];
$translate = tfTranslate::get();
$prog = tfProgram::get();
$i = 0;
$code = '
'.$this->translate->_('navigation','see_also').':
';
if(!is_null($standard))
{
foreach($standard as $value)
{
$meta = $this->project->getMetaInfo($value, false);
if(is_null($meta))
{
$prog->console->stderr->writeln('The page "'.$value.'" linked in See Also of "'.$this->_currentPage['Id'].'" does not exist.');
}
else
{
$code .= '- '.($n ? $meta['FullNumber'].'. ' : '').$meta['Tags']['ShortTitle'].'
';
$i++;
}
}
}
if(!is_null($external))
{
foreach($external as $value)
{
if(($sep = strpos($value, ' ')) !== false)
{
$code .= '- '.substr($value, $sep).'
';
$i++;
}
else
{
$code .= '- '.$value.'
';
$i++;
}
}
}
$code .= '
';
if($i == 0)
{
return '';
}
return $code;
} // end _tagSeeAlso();
/**
* Handles "Author" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagAuthor($value)
{
return '
'.$this->translate->_('tags','author').' | '.$value.' |
---|
';
} // end _tagAuthor();
/**
* Handles "Status" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagStatus($value)
{
return '
'.$this->translate->_('tags','status').' | '.$value.' |
---|
';
} // end _tagStatus();
/**
* Handles "VCSKeywords" tag.
*
* @param String $val The value to be displayed.
* @return String
*/
public function _tagVCSKeywords($val)
{
if($this->project->config['versionControlInfo'])
{
return '
'.$this->translate->_('tags','version_control_info').' | '.$val.' |
---|
';
}
return '';
} // end _tagVCSKeywords();
/**
* Handles "VersionSince" tag.
*
* @param String $val The value to be displayed.
* @return String
*/
public function _tagVersionSince($val)
{
$this->_tagVersion['since'] = $val;
return '';
} // end _tagVersionSince();
/**
* Handles "VersionTo" tag.
*
* @param String $val The value to be displayed.
* @return String
*/
public function _tagVersionTo($val)
{
$this->_tagVersion['to'] = $val;
return '';
} // end _tagVersionTo();
/**
* Handles "FeatureInformation" tag.
*
* @param String $val The parsed value to be displayed.
* @return String
*/
public function _tagFeatureInformationFrame($val)
{
return $val;
} // end _tagImplements();
/**
* Handles "Construct" tag.
*
* @param String $val The value to be displayed.
* @return String
*/
public function _tagConstruct($val)
{
return '
'.$this->translate->_('tags','construct').' | '.$val.' |
---|
';
} // end _tagConstruct();
/**
* Handles "Visibility" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagVisibility($value)
{
return '
'.$this->translate->_('tags','visibility').' | '.$value.' |
---|
';
} // end _tagVisibility();
/**
* Handles "Namespace" and "ENamespace" tags.
*
* @param String $value The tag value
* @return String
*/
public function _tagNamespace($namespace, $enamespace)
{
if($namespace === null)
{
return '
'.$this->translate->_('tags','namespace').' | '.$enamespace.' |
---|
';
}
else
{
$pp = $this->project->getMetaInfo($namespace, false);
if($pp !== null)
{
return '
'.$this->translate->_('tags','namespace').' | '.$pp['Tags']['ShortTitle'].' |
---|
';
}
else
{
return 'dupa';
}
}
} // end _tagNamespace();
/**
* Handles "File" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagFile($value)
{
return '
'.$this->translate->_('tags','file').' | '.$value.' |
---|
';
} // end _tagFile();
/**
* Handles "Reference" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagReference($value)
{
return '
'.$this->translate->_('tags','reference').' | '.$value.' |
---|
';
} // end _tagReference();
/**
* Handles "Files" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagFiles($value)
{
$code = '
'.$this->translate->_('tags','files').' | ';
foreach($value as $file)
{
$code .= ''.$file.' ';
}
return $code.' |
---|
';
} // end _tagFiles();
/**
* Handles "Returns" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagReturns($value)
{
return '
'.$this->translate->_('tags','returns').' | '.$value.' |
---|
';
} // end _tagVisibility();
/**
* Handles "Type" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagType($value)
{
return '
'.$this->translate->_('tags','type').' | '.$value.' |
---|
';
} // end _tagType();
/**
* Handles "Extends" and "EExtends" tags.
*
* @param String $extends The "Extends" list of values
* @param String $eextends The "EExtends" list of values
* @return String
*/
public function _tagExtends($extends, $eextends)
{
$extends = (is_null($extends) ? $eextends : $extends);
$pp = $this->project->getMetaInfo($extends, false);
if(!is_null($pp))
{
return '
'.$this->translate->_('tags','obj_extends').' | '.$pp['Tags']['ShortTitle'].' |
---|
';
}
} // end _tagExtends();
/**
* Handles "PartOf" and "EPartOf" tags.
*
* @param String $partOf The "PartOf" list of values
* @param String $ePartOf The "EPartOf" list of values
* @return String
*/
public function _tagPartOf($partOf, $ePartOf)
{
$partOf = (is_null($partOf) ? $ePartOf : $partOf);
$pp = $this->project->getMetaInfo($partOf, false);
if(!is_null($pp))
{
return '
'.$this->translate->_('tags','part_of').' | '.$pp['Tags']['ShortTitle'].' |
---|
';
}
} // end _tagPartOf();
/**
* Handles "ExtendedBy" and "EExtendedBy" tags.
*
* @param Array $val1 The "ExtendedBy" list of values
* @param Array $val2 The "EExtendedBy" list of values
* @return String
*/
public function _tagExtendedBy($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_extended');
} // end _tagExtendedBy();
/**
* Handles "ImplementedBy" and "EImplementedBy" tags.
*
* @param Array $val1 The "ImplementedBy" list of values
* @param Array $val2 The "EImplementedBy" list of values
* @return String
*/
public function _tagImplementedBy($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_implemented');
} // end _tagExtendedBy();
/**
* Handles "Implements" and "EImplements" tags.
*
* @param Array $val1 The "Implements" list of values
* @param Array $val2 The "EImplements" list of values
* @return String
*/
public function _tagImplements($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_implements');
} // end _tagImplements();
/**
* Handles "Throws" and "EThrows" tags.
*
* @param Array $val1 The "Implements" list of values
* @param Array $val2 The "EImplements" list of values
* @return String
*/
public function _tagThrows($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_throws');
} // end _tagImplements();
/**
* Handles "MultiExtends" and "EMultiExtends" tags.
*
* @param Array $val1 The "Implements" list of values
* @param Array $val2 The "EImplements" list of values
* @return String
*/
public function _tagMultiExtends($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_extends');
} // end _tagMultiExtends();
/**
* Handles "Mixins" and "EMixins" tags.
*
* @param Array $val1 The "Mixins" list of values
* @param Array $val2 The "EMixins" list of values
* @return String
*/
public function _tagMixins($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_mixins');
} // end _tagMixins();
/**
* Handles "Traits" and "ETraits" tags.
*
* @param Array $val1 The "Traits" list of values
* @param Array $val2 The "ETraits" list of values
* @return String
*/
public function _tagTraits($val1, $val2)
{
return $this->_showLinks($val1, $val2, 'obj_traits');
} // end _tagTraits();
/**
* Handles "Arguments" tag.
*
* @param Array $list The argument list
* @return String
*/
public function _tagArguments($list)
{
$output = tfProgram::get()->console->stderr;
$typeOk = true;
foreach($list as $item)
{
if(!isset($item['Type']) && !isset($item['EType']))
{
$typeOk = false;
}
// Do some validation here.
if(!isset($item['Desc']))
{
$output->writeln('Missing Arguments:Desc tag in '.$this->_currentPage['Id']);
return;
}
if(!isset($item['Name']))
{
$output->writeln('Missing Arguments:Name tag in '.$this->_currentPage['Id']);
return;
}
}
$code = '
'.$this->translate->_('tags', 'arg_list').' | ';//.$this->translate->_('tags', 'arg_name').'';
$code .= '';
foreach($list as $item)
{
$code .= ''.$item['Name'].' ';
if($typeOk)
{
$code .= ' - ';
if(isset($item['Type']))
{
$pp = $this->project->getMetaInfo($item['Type'], false);
if(!is_null($pp))
{
$code .= ''.$pp['Tags']['ShortTitle'].'';
}
}
elseif(isset($item['EType']))
{
$code .= ''.$item['EType'].'';
}
$code .= '';
}
$code .= '- '.$item['Desc'].'
';
}
return $code.' |
---|
';
} // end _tagParameters();
/**
* Handles "Package" tag.
*
* @param String $value The tag value
* @return String
*/
public function _tagPackage($package, $epackage)
{
if($package === null)
{
return '
'.$this->translate->_('tags','package').' | '.$epackage.' |
---|
';
}
else
{
$pp = $this->project->getMetaInfo($extends, false);
if($pp !== null)
{
return '
'.$this->translate->_('tags','package').' | '.$pageDef['ShortTitle'].' |
---|
';
}
}
} // end _tagPackage();
/**
* Handles "TimeComplexity" tag.
*
* @param String $val The value to be displayed.
* @return String
*/
public function _tagTimeComplexity($val)
{
return '
'.$this->translate->_('tags','time_complexity').' | '.$val.' |
---|
';
} // end _tagTimeComplexity();
/**
* Handles "MemoryComplexity" tag.
*
* @param String $val The value to be displayed.
* @return String
*/
public function _tagMemoryComplexity($val)
{
return '
'.$this->translate->_('tags','memory_complexity').' | '.$val.' |
---|
';
} // end _tagMemoryComplexity();
/**
* Handles "StartConditions" tag.
*
* @param Array $conditions The values to be displayed.
* @return String
*/
public function _tagStartConditions($conditions)
{
return $this->_showList($conditions, 'start_conditions');
} // end _tagStartConditions();
/**
* Handles "EndConditions" tag.
*
* @param Array $conditions The values to be displayed.
* @return String
*/
public function _tagEndConditions($conditions)
{
return $this->_showList($conditions, 'end_conditions');
} // end _tagEndConditions();
/**
* Handles "SideEffects" tag.
*
* @param Array $conditions The values to be displayed.
* @return String
*/
public function _tagSideEffects($conditions)
{
return $this->_showList($conditions, 'side_effects');
} // end _tagSideEffects();
/**
* Handles "Limitations" tag.
*
* @param Array $conditions The values to be displayed.
* @return String
*/
public function _tagLimitations($conditions)
{
return $this->_showList($conditions, 'limitations');
} // end _tagLimitations();
/**
* Handles "DataSources" tag.
*
* @param Array $conditions The values to be displayed.
* @return String
*/
public function _tagDataSources($val1, $val2)
{
$code = '
'.$this->translate->_('tags', 'datasources').' | ';
if($val1 !== null)
{
foreach($val1 as $item)
{
$pp = $this->project->getMetaInfo($item, false);
if(!is_null($pp))
{
$code .= '- '.$pp['Tags']['ShortTitle'].'
';
}
}
}
if($val2 !== null)
{
foreach($val2 as $item)
{
$code .= '- '.$item.'
';
}
}
return $code.' |
---|
';
} // end _tagDataSources();
/**
* A helper method for tags like "SideEffects".
*
* @param Array $val1
* @param Array $val2
* @param String $message
*/
protected function _showList(array $val1, $message)
{
$code = '
'.$this->translate->_('tags',$message).' | ';
$items = array();
if(sizeof($val1) == 1)
{
$code .= $val1[0];
}
else
{
$code .= '';
foreach($val1 as $item)
{
$code .= '- '.$item.'
';
}
$code .= ' ';
}
return $code.' |
---|
';
} // end _showList();
/**
* A helper method for tags like "Implements".
*
* @param Array $val1
* @param Array $val2
* @param String $message
*/
protected function _showLinks($val1, $val2, $message)
{
$code = '
'.$this->translate->_('tags',$message).' | ';
$items = array();
if($val1 !== null)
{
foreach($val1 as $item)
{
$pp = $this->project->getMetaInfo($item, false);
if(!is_null($pp))
{
$items[] = ''.$pp['Tags']['ShortTitle'].' ';
}
}
}
if($val2 !== null)
{
foreach($val2 as $item)
{
$items[] = ''.$item.' ';
}
}
return $code.implode(', ', $items).' |
---|
';
} // end _showLinks();
} // end xhtml;