Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cCodeGeneratorAbstract
  • cCodeGeneratorFactory
  • cCodeGeneratorStandard
  • cContentTypeAbstract
  • cContentTypeAbstractTabbed
  • cContentTypeDate
  • cContentTypeFilelist
  • cContentTypeHead
  • cContentTypeHtml
  • cContentTypeHtmlhead
  • cContentTypeImg
  • cContentTypeImgdescr
  • cContentTypeImgeditor
  • cContentTypeLink
  • cContentTypeLinkdescr
  • cContentTypeLinkeditor
  • cContentTypeLinktarget
  • cContentTypeRaw
  • cContentTypeTeaser
  • cContentTypeText
  • cTypeGenerator
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * CONTENIDO standard code generator
  5:  *
  6:  * @package Core
  7:  * @subpackage ContentType
  8:  * @version SVN Revision $Rev:$
  9:  *
 10:  * @author Murat Purc <murat@purc.de>
 11:  * @copyright four for business AG <www.4fb.de>
 12:  * @license http://www.contenido.org/license/LIZENZ.txt
 13:  * @link http://www.4fb.de
 14:  * @link http://www.contenido.org
 15:  */
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * CONTENIDO standard code generator.
 20:  *
 21:  * @package Core
 22:  * @subpackage ContentType
 23:  */
 24: class cCodeGeneratorStandard extends cCodeGeneratorAbstract {
 25: 
 26:     /**
 27:      * {@inheritdoc}
 28:      */
 29:     public function _generate($contype = true) {
 30:         global $cfg, $code;
 31: 
 32:         $this->_cssData = '';
 33:         $this->_jsData = '';
 34:         $this->_tplName = '';
 35: 
 36:         cDebug::out("conGenerateCode($this->_idcat, $this->_idart, $this->_lang, $this->_client, $this->_layout);<br>");
 37: 
 38:         // Set category article id
 39:         $idcatart = conGetCategoryArticleId($this->_idcat, $this->_idart);
 40: 
 41:         // Set configuration for article
 42:         $this->_idtplcfg = $this->_getTemplateConfigurationId();
 43:         if (NULL === $this->_idtplcfg) {
 44:             $this->_processNoConfigurationError($idcatart);
 45:             return '0601';
 46:         }
 47: 
 48:         // List of configured container
 49:         $containerConfigurations = conGetContainerConfiguration($this->_idtplcfg);
 50: 
 51:         // Set idlay and idmod array
 52:         $data = $this->_getTemplateData();
 53:         $idlay = $data['idlay'];
 54:         $idtpl = $data['idtpl'];
 55:         $this->_tplName = cApiStrCleanURLCharacters($data['name']);
 56: 
 57:         // List of used modules
 58:         $containerModules = conGetUsedModules($idtpl);
 59: 
 60:         // Load layout code from file
 61:         $layoutInFile = new cLayoutHandler($idlay, '', $cfg, $this->_lang);
 62:         $this->_layoutCode = $layoutInFile->getLayoutCode();
 63:         $this->_layoutCode = cApiStrNormalizeLineEndings($this->_layoutCode, "\n");
 64: 
 65:         $moduleHandler = new cModuleHandler();
 66: 
 67:         // Create code for all containers
 68:         if ($idlay) {
 69:             cInclude('includes', 'functions.tpl.php');
 70:             $containerNumbers = tplGetContainerNumbersInLayout($idlay);
 71: 
 72:             foreach ($containerNumbers as $containerNr) {
 73:                 if (!isset($containerModules[$containerNr]) || !is_numeric($containerModules[$containerNr])) {
 74:                     // No configured module in this container
 75:                     // reset current module state and process empty container
 76:                     $this->_resetModule();
 77:                     $this->_processCmsContainer($containerNr);
 78:                     continue;
 79:                 }
 80: 
 81:                 $containerModuleId = $containerModules[$containerNr];
 82:                 $oModule = new cApiModule($containerModuleId);
 83:                 $module = $oModule->toArray();
 84:                 if (false === $module) {
 85:                     $module = array();
 86:                 }
 87: 
 88:                 $this->_resetModule();
 89: 
 90:                 $this->_modulePrefix[] = '$cCurrentModule = ' . $containerModuleId . ';';
 91:                 $this->_modulePrefix[] = '$cCurrentContainer = ' . $containerNr . ';';
 92: 
 93:                 $moduleHandler = new cModuleHandler($containerModuleId);
 94:                 $input = '';
 95: 
 96:                 // Get the contents of input and output from files and not from
 97:                 // db-table
 98:                 if ($moduleHandler->modulePathExists() == true) {
 99:                     $this->_moduleCode = $moduleHandler->readOutput();
100:                     // Load css and js content of the js/css files
101:                     if ($moduleHandler->getFilesContent('css', 'css') !== false) {
102:                         $this->_cssData .= $moduleHandler->getFilesContent('css', 'css');
103:                     }
104: 
105:                     if ($moduleHandler->getFilesContent('js', 'js') !== false) {
106:                         $this->_jsData .= $moduleHandler->getFilesContent('js', 'js');
107:                     }
108: 
109:                     $input = $moduleHandler->readInput();
110:                 }
111: 
112:                 $this->_moduleCode = $this->_moduleCode . "\n";
113: 
114:                 // Process CMS value tags
115:                 $containerCmsValues = $this->_processCmsValueTags($containerNr, $containerConfigurations[$containerNr]);
116: 
117:                 // Add CMS value code to module prefix code
118:                 if ($containerCmsValues) {
119:                     $this->_modulePrefix[] = $containerCmsValues;
120:                 }
121: 
122:                 // Process frontend debug
123:                 $this->_processFrontendDebug($containerNr, $module);
124: 
125:                 // Replace new containers
126:                 $this->_processCmsContainer($containerNr);
127:             }
128:         }
129: 
130:         // Find out what kind of CMS_... Vars are in use
131:         $a_content = $this->_getUsedCmsTypesData();
132: 
133:         // Replace all CMS_TAGS[]
134:         if ($contype) {
135:             $this->_processCmsTags($a_content, true);
136:         }
137: 
138:         // Add/replace title tag
139:         $this->_processCodeTitleTag();
140: 
141:         // Add/replace meta tags
142:         $this->_processCodeMetaTags();
143: 
144:         // Save the collected css/js data and save it under the template name
145:         // ([templatename].css , [templatename].js in cache dir
146:         $cssFile = '';
147:         if (strlen($this->_cssData) > 0) {
148:             if (($myFileCss = $moduleHandler->saveContentToFile($this->_tplName, 'css', $this->_cssData)) !== false) {
149:                 $oHTML = new cHTML(array(
150:                     'rel' => 'stylesheet',
151:                     'type' => 'text/css',
152:                     'href' => $myFileCss
153:                 ));
154:                 $oHTML->setTag('link');
155:                 $cssFile = $oHTML->render();
156:             }
157:         }
158: 
159:         $jsFile = '';
160:         if (strlen($this->_jsData) > 0) {
161:             if (($myFileJs = $moduleHandler->saveContentToFile($this->_tplName, 'js', $this->_jsData)) !== false) {
162:                 $jsFile = '<script src="' . $myFileJs . '" type="text/javascript"></script>';
163:             }
164:         }
165: 
166:         // // show toolbar with revisions of article This toolbar is only shown
167:         // in
168:         // // backend in edit mode if revision control is enabled
169:         // $revionsToolBar = $this->_revisionControl->getToolbar();
170:         // if (NULL !== $revionsToolBar) {
171:         // if (false !== strpos($this->_layoutCode, '<body>')) {
172:         // $this->_layoutCode = str_ireplace_once('<body>', '<body>' .
173:         // $revionsToolBar, $this->_layoutCode);
174:         // } else {
175:         // // TODO wo füg ich die dann ein?
176:         // // $this->_layoutCode .= $revionsToolBar;
177:         // }
178:         // }
179: 
180:         // add module CSS at {CSS} position, after title or after opening head
181:         // tag
182:         if (strpos($this->_layoutCode, '{CSS}') !== false) {
183:             $this->_layoutCode = cString::iReplaceOnce('{CSS}', $cssFile, $this->_layoutCode);
184:         } else if (!empty($cssFile)) {
185:             if (strpos($this->_layoutCode, '</title>') !== false) {
186:                 $matches = array();
187:                 preg_match_all("#(<head>.*?</title>)(.*?</head>)#si", $this->_layoutCode, $matches);
188:                 $this->_layoutCode = cString::iReplaceOnce($matches[1][0], $matches[1][0] . $cssFile . $matches[1][1], $this->_layoutCode);
189:             } else {
190:                 $this->_layoutCode = cString::iReplaceOnce('<head>', '<head>' . $cssFile, $this->_layoutCode);
191:             }
192:         }
193: 
194:         if (strpos($this->_layoutCode, '{REV}') !== false) {
195:             $this->_layoutCode = cString::iReplaceOnce('{REV}', ((int) getEffectiveSetting("ressource", "revision", 0)), $this->_layoutCode);
196:         }
197: 
198:         // add module JS at {JS} position or before closing body tag if there is
199:         // no {JS}
200:         if (strpos($this->_layoutCode, '{JS}') !== false) {
201:             $this->_layoutCode = cString::iReplaceOnce('{JS}', $jsFile, $this->_layoutCode);
202:         } else if (!empty($jsFile)) {
203:             $this->_layoutCode = cString::iReplaceOnce('</body>', $jsFile . '</body>', $this->_layoutCode);
204:         }
205: 
206:         if (strpos($this->_layoutCode, '{META}') !== false) {
207:             $this->_layoutCode = cString::iReplaceOnce('{META}', $this->_processCodeMetaTags(), $this->_layoutCode);
208:         } else {
209:             $this->_layoutCode = cString::iReplaceOnce('</head>', $this->_processCodeMetaTags() . '</head>', $this->_layoutCode);
210:         }
211: 
212:         if ($this->_feDebugOptions['general_information']) {
213:             $debugPrefix = '';
214: 
215:             $debugPrefix .= "<?php\nif (\$frontend_debug['general_information']) {\n";
216:             $debugPrefix .= "\techo(\"<!-- \\n\\n\");\n";
217: 
218:             $layout = new cApiLayout($idlay);
219:             $layouName = $layout->get('name');
220:             $debugPrefix .= "\techo(\"Layout: " . $layouName . " (" . $idlay . ")\\n\");\n";
221: 
222:             $debugPrefix .= "\techo(\"Template: " . $this->_tplName . " (" . $idtpl . ")\\n\");\n";
223: 
224:             $article = new cApiArticleLanguage($this->_idartlang);
225:             $catart = new cApiCategoryArticle();
226:             $cat = new cApiCategoryLanguage();
227:             $cat->loadByCategoryIdAndLanguageId($this->_idcat, $article->get('idlang'));
228:             $catart->loadByMany(array(
229:                 'idcat' => $cat->get('idcat'),
230:                 'idart' => $article->get('idart')
231:             ));
232:             $lang = new cApiLanguage($article->get('idlang'));
233:             $debugPrefix .= "\techo(\"Language: " . $lang->get('idlang') . " (" . $lang->get('name') . ")\\n\");\n";
234: 
235:             $debugPrefix .= "\techo(\"Category: " . $cat->get('idcat') . " (" . $cat->get('name') . ")\\n\");\n";
236: 
237:             $articleName = $article->get('title');
238:             $debugPrefix .= "\techo(\"Article: " . $articleName . " (catart = " . $catart->get('idcatart') . ", artlang = " . $this->_idartlang . ", art = " . $article->get('idart') . ")\\n\");\n";
239: 
240:             $debugPrefix .= "\techo(\"\\n--> \\n\");\n";
241:             $debugPrefix .= "}\n?>";
242: 
243:             $this->_layoutCode = $debugPrefix . $this->_layoutCode;
244:         }
245: 
246:         // Save the generated code
247:         $this->_saveGeneratedCode($idcatart);
248: 
249:         return $this->_layoutCode;
250:     }
251: 
252:     /**
253:      * Will be invoked, if code generation wasn't able to find a configured
254:      * article
255:      * or category.
256:      *
257:      * Creates a error message and writes this into the code cache.
258:      *
259:      * @param int $idcatart Category article id
260:      */
261:     protected function _processNoConfigurationError($idcatart) {
262:         cDebug::out('Neither CAT or ART are configured!<br><br>');
263: 
264:         $code = '<html><body>No code was created for this article in this category.</body><html>';
265:         $this->_saveGeneratedCode($idcatart, $code, false);
266:     }
267: 
268:     /**
269:      * Processes and adds or replaces title tag for an article.
270:      * Calls also the CEC 'Contenido.Content.CreateTitletag' for user defined
271:      * title creation.
272:      *
273:      * @see cCodeGeneratorAbstract::_processCodeTitleTag()
274:      * @return string
275:      */
276:     protected function _processCodeTitleTag() {
277:         if ($this->_pageTitle == '') {
278:             cApiCecHook::setDefaultReturnValue($this->_pageTitle);
279:             $this->_pageTitle = cApiCecHook::executeAndReturn('Contenido.Content.CreateTitletag');
280:         }
281: 
282:         // Add or replace title
283:         if ($this->_pageTitle != '') {
284:             $replaceTag = '{__TITLE__' . md5(rand().time()) . '}';
285:             $this->_layoutCode = preg_replace('/<title>.*?<\/title>/is', $replaceTag, $this->_layoutCode, 1);
286:             if (strstr($this->_layoutCode, $replaceTag)) {
287:                 $this->_layoutCode = str_ireplace($replaceTag, '<title>' . $this->_pageTitle . '</title>', $this->_layoutCode);
288:             } else {
289:                 $this->_layoutCode = cString::iReplaceOnce('</head>', '<title>' . $this->_pageTitle . "</title>\n</head>", $this->_layoutCode);
290:             }
291:         } else {
292:             $this->_layoutCode = str_replace('<title></title>', '', $this->_layoutCode);
293:         }
294: 
295:         return $this->_layoutCode;
296:     }
297: 
298:     /**
299:      * Processes and adds or replaces all meta tags for an article.
300:      *
301:      * Calls also the CEC 'Contenido.Content.CreateMetatags' for user defined
302:      * meta tags creation.
303:      *
304:      * @global array $encoding
305:      */
306:     protected function _processCodeMetaTags() {
307:         global $encoding;
308: 
309:         // get basic meta tags (from article & system)
310:         $metaTags = $this->_getBasicMetaTags();
311: 
312:         // process chain Contenido.Content.CreateMetatags to update meta tags
313:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Content.CreateMetatags');
314:         if ($_cecIterator->count() > 0) {
315:             while (false !== $chainEntry = $_cecIterator->next()) {
316:                 $metaTags = $chainEntry->execute($metaTags);
317:             }
318:         }
319: 
320:         $sMetatags = '';
321: 
322:         foreach ($metaTags as $value) {
323: 
324:             // get meta tag keys
325:             $valueKeys = array_keys($value);
326:             $nameKey = 'name';
327:             foreach ($valueKeys as $key) {
328: 
329:                 if ($key != 'content')
330:                     $nameKey = $key;
331:             }
332: 
333:             // decode entities and htmlspecialchars, content will be converted
334:             // later using conHtmlSpecialChars() by render() function
335:             if (isset($value['content'])) {
336:                 $value['content'] = str_replace('"', '\"', (conHtmlEntityDecode(stripslashes($value['content']))));
337:             }
338: 
339:             // build up metatag string
340:             $oMetaTagGen = new cHTML();
341:             $oMetaTagGen->setTag('meta');
342:             $oMetaTagGen->updateAttributes($value);
343: 
344:             // HTML does not allow ID for meta tags
345:             $oMetaTagGen->removeAttribute('id');
346: 
347:             // check if metatag already exists
348:             $sPattern = '/(<meta(?:\s+)' . $nameKey . '(?:\s*)=(?:\s*)(?:\\"|\\\')(?:\s*)' . $value[$nameKey] . '(?:\s*)(?:\\"|\\\')(?:[^>]+)>\n?)/i';
349:             if (preg_match($sPattern, $this->_layoutCode, $aMatch)) {
350:                 // the meta tag is already specified in the layout
351:                 // replace it only if its attributes are not empty
352:                 $replace = true;
353:                 foreach ($value as $test) {
354:                     if ($test == '') {
355:                         $replace = false;
356:                         break;
357:                     }
358:                 }
359:                 if ($replace) {
360:                     $this->_layoutCode = str_replace($aMatch[1], $oMetaTagGen->render() . "\n", $this->_layoutCode);
361:                 }
362:             } else {
363:                 $sMetatags .= $oMetaTagGen->render() . "\n";
364:             }
365:         }
366: 
367:         return $sMetatags;
368:     }
369: 
370:     /**
371:      * Saves the generated code (if layout flag is false and save flag is true)
372:      *
373:      * @global array $cfgClient
374:      * @param int $idcatart Category article id
375:      * @param string $code parameter for setting code manually instead of using
376:      *        the generated layout code
377:      * @param bool $flagCreateCode whether the create code flag in cat_art
378:      *        should be set or not (optional)
379:      */
380:     protected function _saveGeneratedCode($idcatart, $code = '', $flagCreateCode = true) {
381:         global $cfgClient;
382: 
383:         // Write code in the cache of the client. If the folder does not exist
384:         // create one.
385:         if ($this->_layout == false && $this->_save == true) {
386:             if (!is_dir($cfgClient[$this->_client]['code']['path'])) {
387:                 mkdir($cfgClient[$this->_client]['code']['path']);
388:                 @chmod($cfgClient[$this->_client]['code']['path'], 0777);
389:                 cFileHandler::write($cfgClient[$this->_client]['code']['path'] . '.htaccess', "Order Deny,Allow\nDeny from all\n");
390:             }
391: 
392:             $fileCode = ($code == '')? $this->_layoutCode : $code;
393: 
394:             $code = "<?php\ndefined('CON_FRAMEWORK') or die('Illegal call');\n\n?>\n" . $fileCode;
395:             cFileHandler::write($cfgClient[$this->_client]['code']['path'] . $this->_client . '.' . $this->_lang . '.' . $idcatart . '.php', $code, false);
396: 
397:             // Update create code flag
398:             if ($flagCreateCode == true) {
399:                 $oCatArtColl = new cApiCategoryArticleCollection();
400:                 $oCatArtColl->setCreateCodeFlag($idcatart, 0);
401:             }
402:         }
403:     }
404: 
405:     /**
406:      * Collects and return basic meta tags/elements.
407:      *
408:      * @global array $encoding
409:      * @return array List of assozative meta tag values
410:      */
411:     protected function _getBasicMetaTags() {
412: 
413:         // collect all available meta tag entries with non empty values
414:         $metaTags = array();
415:         foreach (conGetAvailableMetaTagTypes() as $key => $value) {
416:             $metaValue = conGetMetaValue($this->_idartlang, $key);
417:             if (0 < strlen($metaValue)) {
418:                 $metaTags[] = array(
419:                     $value['fieldname'] => $value['metatype'],
420:                     'content' => $metaValue
421:                 );
422:             }
423:         }
424: 
425:         // add generator meta tag
426:         // if the version is appended should be configurable due to security
427:         // reasons
428:         $generator = 'CMS CONTENIDO';
429:         $addVersion = true;
430:         if ($addVersion) {
431:             $cfg = cRegistry::getConfig();
432:             $aVersion = explode('.', CON_VERSION);
433:             $generator .= ' ' . $aVersion[0] . '.' . $aVersion[1];
434:         }
435:         $metaTags[] = array(
436:             'name' => 'generator',
437:             'content' => $generator
438:         );
439: 
440:         // add charset or content type meta tag
441:         global $encoding;
442:         if (getEffectiveSetting('generator', 'html5', 'false') == 'true') {
443:             $metaTags[] = array(
444:                 'charset' => $encoding[$this->_lang]
445:             );
446:         } elseif (getEffectiveSetting('generator', 'xhtml', 'false') == 'true') {
447:             $metaTags[] = array(
448:                 'http-equiv' => 'Content-Type',
449:                 'content' => 'application/xhtml+xml; charset=' . $encoding[$this->_lang]
450:             );
451:         } else {
452:             $metaTags[] = array(
453:                 'http-equiv' => 'Content-Type',
454:                 'content' => 'text/html; charset=' . $encoding[$this->_lang]
455:             );
456:         }
457: 
458:         // update (!) index setting of robots meta tag
459:         // the follow value will not be changed
460:         // $index = (bool) $this->getArtLangObject()->get('searchable');
461:         // $metaTags = $this->_updateMetaRobots($metaTags, $index, NULL);
462: 
463:         return $metaTags;
464:     }
465: 
466:     /**
467:      * This method allows to set new values for the robots meta element.
468:      *
469:      * If NULL is given for $index or $follow, existing settings are *not*
470:      * overwritten. If article should be indexed and followed, 'all' will be
471:      * set.
472:      *
473:      * @param array $metaTags array of meta elements to amend
474:      * @param bool|NULL $index if article should be indexed
475:      * @param bool|NULL $follow if links in article should be followed
476:      * @return array
477:      */
478:     protected function _updateMetaRobots(array $metaTags, $index, $follow) {
479: 
480:         // extract robots setting from current meta elements
481:         list($metaTags, $metaRobots) = $this->_extractMetaElement($metaTags, 'name', 'robots');
482: 
483:         if (is_null($metaRobots)) {
484:             // build new meta element if none could be found
485:             $metaRobots = array(
486:                 'name' => 'robots',
487:                 'content' => ''
488:             );
489:         } else {
490:             $content = array_map('trim', explode(',', $metaRobots['content']));
491:             // determine index from extracted element if given value is NULL
492:             if (is_null($index)) {
493:                 $index = (bool) (in_array('all', $content) || in_array('index', $content));
494:                 if (in_array('index', $content) || in_array('all', $content)) {
495:                     $index = true;
496:                 } else if (in_array('noindex', $content)) {
497:                     $index = true;
498:                 } else {
499:                     $index = NULL;
500:                 }
501:             }
502:             // determine follow from extracted element if given value is NULL
503:             if (is_null($follow)) {
504:                 if (in_array('follow', $content) || in_array('all', $content)) {
505:                     $follow = true;
506:                 } else if (in_array('nofollow', $content)) {
507:                     $follow = true;
508:                 } else {
509:                     $follow = NULL;
510:                 }
511:             }
512:         }
513: 
514:         // build and set new content for robots element
515:         $content = array();
516:         if (true === $index && true === $follow) {
517:             $content[] = 'all';
518:         } else {
519:             if (!is_null($index)) {
520:                 $content[] = $index? 'index' : 'noindex';
521:             }
522:             if (!is_null($follow)) {
523:                 $content[] = $follow? 'follow' : 'nofollow';
524:             }
525:         }
526:         $metaRobots['content'] = implode(',', $content);
527: 
528:         // add robots meta element
529:         $metaTags[] = $metaRobots;
530: 
531:         // what do you expect?
532:         return $metaTags;
533:     }
534: 
535:     /**
536:      * Extracts a meta element of type $type (either 'name' or 'http-equiv') and
537:      * name or HTTP header equivalent $nameOrEquiv from the given array of meta
538:      * elements.
539:      *
540:      * Both, the reduced array of meta elements and the meta element to be
541:      * extracted are returned as an array. If the meta element to be extracted
542:      * could not be found, NULL will be returned in its place.
543:      *
544:      * @param array $metaTags
545:      * @param string $type either 'name' or 'http-equiv'
546:      * @param string $nameOrEquiv
547:      * @return array
548:      */
549:     protected function _extractMetaElement(array $metaTags, $type, $nameOrEquiv) {
550: 
551:         // prepare result structure
552:         $result = array(
553:             array(),
554:             NULL
555:         );
556: 
557:         // loop all given meta elements
558:         foreach ($metaTags as $metaTag) {
559:             if (!is_array($metaTag)) {
560:                 // skip $metaTag if it's no array
561:                 continue;
562:             } else if (!array_key_exists($type, $metaTag)) {
563:                 // add element to reduced array if it's of different type
564:                 array_push($result[0], $metaTag);
565:             } else if ($metaTag[$type] !== $nameOrEquiv) {
566:                 // add element to reduced array if it has different name
567:                 array_push($result[0], $metaTag);
568:             } else {
569:                 // set element as extracted element
570:                 $result[1] = $metaTag;
571:             }
572:         }
573: 
574:         // what do you expect?
575:         return $result;
576:     }
577: 
578: }
579: 
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0