Пример #1
0
 protected static function processParams($params, $parser)
 {
     if (isset($params['title'])) {
         self::$title = $parser->recursiveTagParse($params['title']);
     }
     //check for both metakeywords and metak params
     if (isset($params['metakeywords']) || isset($params['keywords'])) {
         $keywords = isset($params['metakeywords']) ? $params['metakeywords'] : $params['keywords'];
         self::$meta_keywords = $parser->recursiveTagParse($keywords);
     }
     //check for both metadescription and metad params
     if (isset($params['metadescription']) || isset($params['description'])) {
         $description = isset($params['metadescription']) ? $params['metadescription'] : $params['description'];
         self::$meta_description = $parser->recursiveTagParse($description);
     }
     if (isset($params['titlemode']) && in_array($params['titlemode'], array('append', 'prepend', 'replace'))) {
         self::$title_mode = $params['titlemode'];
     }
 }
Пример #2
0
 /**
  * Processes params (assumed valid) and sets them as class properties
  * @param Array $params Array of pre-validated params
  * @param Parser $parser If passed, the parser will be used to recursively parse all params
  * @return Array An array of processed params
  */
 protected static function processParams($params, $parser = null)
 {
     //correct params for compatibility with "HTML Meta and Title" extension
     foreach (self::$convert_params as $from => $to) {
         if (isset($params[$from])) {
             $params[$to] = $params[$from];
             unset($params[$from]);
         }
     }
     $processed = array();
     //ensure only valid parameter names are processed
     foreach (self::$valid_params as $p) {
         if (isset($params[$p])) {
             //if the parser has been passed and the param is parsable parse it, else simply assign it
             $processed[$p] = $parser && in_array($p, self::$parse_params) ? $parser->recursiveTagParse($params[$p]) : $params[$p];
         }
     }
     //set the processed values as class properties
     foreach ($processed as $k => $v) {
         if ($k === 'title') {
             self::$title = $v;
         } else {
             if ($k === 'title_mode' && in_array($v, self::$valid_title_modes)) {
                 self::$title_mode = $v;
             } else {
                 if ($k === 'title_separator') {
                     self::$title_separator = ' ' . $v . ' ';
                 } else {
                     if (isset(self::$tag_types[$k]) && self::$tag_types[$k] === 'meta') {
                         self::$meta[$k] = $v;
                     } else {
                         if (isset(self::$tag_types[$k]) && self::$tag_types[$k] === 'property') {
                             self::$property[$k] = $v;
                         }
                     }
                 }
             }
         }
     }
     return $processed;
 }