예제 #1
0
 /**
  * Initializes the generation.
  * 
  * @param tfProject $project The project
  * @param String $path Output path
  */
 public function init($project, $path)
 {
     $this->translate = tfTranslate::get();
     $this->date = date('d.m.Y');
     $this->project = $project;
     $this->path = $path;
 }
예제 #2
0
 public static function get()
 {
     if (is_null(tfTranslate::$instance)) {
         tfTranslate::$instance = new tfTranslate();
     }
     return tfTranslate::$instance;
 }
예제 #3
0
 /**
  * Sets the new project language.
  * @param String $language The new language abbreviation, i.e. "pl" or "en".
  */
 public function setLanguage($language)
 {
     if (!in_array($language, $this->langs)) {
         throw new SystemException('The used language "' . $language . '" is not supported in this project.');
     }
     $translate = tfTranslate::get();
     $translate->setLanguage($language);
     $this->language = $language;
 }
예제 #4
0
 /**
  * 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 = '<h4>' . $this->translate->_('navigation', 'see_also') . ':</h4><ul>';
     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 .= '<li><a href="' . $this->toAddress($meta['Id']) . '">' . ($n ? $meta['FullNumber'] . '. ' : '') . $meta['Tags']['ShortTitle'] . '</a></li>';
                 $i++;
             }
         }
     }
     if (!is_null($external)) {
         foreach ($external as $value) {
             if (($sep = strpos($value, ' ')) !== false) {
                 $code .= '<li><a href="' . substr($value, 0, $sep) . '">' . substr($value, $sep) . '</a></li>';
                 $i++;
             } else {
                 $code .= '<li><a href="' . $value . '">' . $value . '</a></li>';
                 $i++;
             }
         }
     }
     $code .= '</ul>';
     if ($i == 0) {
         return '';
     }
     return $code;
 }
예제 #5
0
 /**
  * Validates the tag list and returns the result.
  *
  * @param Array &$tags The list of tags
  * @return Boolean
  */
 public static function validateTags(array &$tags)
 {
     // Process the "FeatureInformation" tag.
     // This tag has to be reparsed every time the method is invoked (because of parsing markdown)
     if (isset($tags['FeatureInformation'])) {
         $parser = tfParsers::get();
         try {
             $tags['FeatureInformationFrame'] = $parser->parse(self::$_project->getTemplate($tags['FeatureInformation']));
         } catch (SystemException $exception) {
             self::$_error = 'The feature information identifier: "' . $tags['FeatureInformation'] . '" is not defined.';
             return false;
         }
     }
     if (isset($tags['%%Validated'])) {
         return true;
     }
     self::_buildTagList();
     if (!isset($tags['Title'])) {
         self::$_error = 'The required tag "Title" is not defined.';
         return false;
     }
     if (!isset($tags['ShortTitle'])) {
         $tags['ShortTitle'] = $tags['Title'];
     }
     // Validate the tags.
     foreach ($tags as $tag => &$value) {
         if (!isset(self::$_tags[$tag])) {
             if (!self::$_allowUnknown) {
                 self::$_error = 'The tag "' . $tag . '" cannot be recognized as a valid TypeFriendly tag.';
                 return false;
             }
         }
         if (!self::_validate($value, self::$_tags[$tag])) {
             self::$_error = '"' . $tag . '": invalid value.';
             return false;
         }
     }
     if (isset($tags['Extends']) && isset($tags['EExtends'])) {
         self::$_error = 'Tags "Extends" and "EExtends" cannot be used together.';
         return false;
     }
     if ((isset($tags['Extends']) || isset($tags['EExtends'])) && (isset($tags['MultiExtends']) || isset($tags['EMultiExtends']))) {
         self::$_error = 'Tags "Extends" and "MultiExtends" cannot be used together.';
         return false;
     }
     // Process the "Construct" tag
     if (isset($tags['Construct'])) {
         $translate = tfTranslate::get();
         $construct = strtolower(trim($tags['Construct']));
         if (!in_array($construct, self::$_constructs)) {
             $tags['ConstructType'] = 'unknown';
         } else {
             $tags['ConstructType'] = str_replace(' ', '_', $construct);
             $tags['Construct'] = $translate->_('constructs', $tags['ConstructType']);
         }
         // Using the information from "Construct", we can perform some extra checks.
         $extends = false;
         $reference = false;
         $throws = false;
         $implementedBy = false;
         $mixins = false;
         $traits = false;
         switch ($tags['ConstructType']) {
             case 'function':
             case 'method':
             case 'static_method':
             case 'abstract_method':
             case 'accessor_method':
             case 'final_method':
             case 'final_static method':
             case 'final_accessor_method':
             case 'optional_method':
             case 'magic_method':
             case 'constructor':
             case 'destructor':
             case 'macro':
             case 'operator':
                 $reference = true;
                 $throws = true;
                 break;
             case 'mixin':
             case 'trait':
                 $implementedBy = true;
                 break;
             case 'class':
             case 'abstract_class':
             case 'exception_class':
             case 'internal_class':
             case 'structure':
                 $extends = true;
             case 'final_class':
                 $mixins = true;
                 $traits = true;
                 break;
             case 'interface':
                 $extends = true;
                 $implementedBy = true;
                 break;
         }
         if (!$reference && isset($tags['Reference'])) {
             self::$_error = 'Tag "Reference" is not allowed with the specified construct.';
             return false;
         }
         if (!$throws && (isset($tags['Throws']) || isset($tags['EThrows']))) {
             self::$_error = 'Tags "Throws" and "EThrows" are not allowed with the specified construct.';
             return false;
         }
         if (!$implementedBy && (isset($tags['ImplementedBy']) || isset($tags['EImplementedBy']))) {
             self::$_error = 'Tags "ImplementedBy" and "EImplementedBy" are not allowed with the specified construct.';
             return false;
         }
         if (!$mixins && (isset($tags['Mixins']) || isset($tags['EMixins']))) {
             self::$_error = 'Tags "Mixins" and "EMixins" are not allowed with the specified construct.';
             return false;
         }
         if (!$traits && (isset($tags['Traits']) || isset($tags['ETraits']))) {
             self::$_error = 'Tags "Traits" and "ETraits" are not allowed with the specified construct.';
             return false;
         }
         if ($tags['ConstructType'] != 'internal_class' && (isset($tags['PartOf']) || isset($tags['EPartOf']))) {
             self::$_error = 'Tags "PartOf" and "EPartOf" are not allowed with the specified construct.';
             return false;
         }
         if (!$extends && (isset($tags['Extends']) || isset($tags['EExtends']) || isset($tags['Implements']) || isset($tags['Implements']) || isset($tags['ExtendedBy']) || isset($tags['EExtendedBy']) || isset($tags['MultiExtends']) || isset($tags['EMultiExtends']))) {
             self::$_error = 'The tags that describe the OOP inheritance are not allowed with the specified construct.';
             return false;
         }
     }
     $tags['%%Validated'] = true;
     return true;
 }