Пример #1
0
 protected function _evalPHPContent($content)
 {
     //eval() the PHP code
     if ($content != '' && !function_exists((string) $content)) {
         //first, try to get all items ids to search
         $count = preg_match_all("#(<\\?php|<\\?).*'([0-9]*?)', '([0-9]*?)',.*\\?>#Usi", $content, $matches);
         //if more than one item is found in text, it is faster to search them by one search
         if ($count > 1) {
             $ids = $GLOBALS['polymod']['preparedItems'] = array();
             //then sort all items ids by plugin ID
             foreach ($matches[2] as $key => $match) {
                 $ids[$match][] = $matches[3][$key];
             }
             //then search all items
             foreach ($ids as $pluginID => $itemsIds) {
                 //get plugin
                 $plugin = new CMS_poly_plugin_definitions($pluginID);
                 if ($plugin && is_object($plugin) && !$plugin->hasError()) {
                     //then search all objects and put results in a global var usable in CMS_poly_definition_functions::pluginCode method (ugly i know)
                     $GLOBALS['polymod']['preparedItems'][$plugin->getValue('objectID')] = CMS_poly_object_catalog::getAllObjects($plugin->getValue('objectID'), $this->_public, array('items' => $itemsIds), true);
                 }
             }
         }
         //then eval all php codes if any
         if (strpos($content, '<?php') !== false) {
             $content = io::evalPHPCode($content);
         }
         if (isset($GLOBALS['polymod']['preparedItems'])) {
             unset($GLOBALS['polymod']['preparedItems']);
         }
     }
     return $content;
 }
Пример #2
0
 /**
  * Parse content which go to the WYSIWYG editor to handle all plugins tags
  *
  * @param string $text The inputed text of fckeditor
  * @param string $module The module codename which made the request
  * @return string the text with plugins tags adapted for fckeditor
  * @access public
  */
 function parseInnerContent($value, $module = MOD_STANDARD_CODENAME)
 {
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_WYSIWYG_INNER_TAGS, RESOURCE_DATA_LOCATION_EDITION, $this);
     $wantedTags = $modulesTreatment->getWantedTags();
     //create regular expression on wanted tags
     $exp = '';
     foreach ($wantedTags as $aWantedTag) {
         $exp .= $exp ? '|<' . $aWantedTag["tagName"] : '<' . $aWantedTag["tagName"];
     }
     //is parsing needed (value contain some of these wanted tags)
     if ($value && is_array($wantedTags) && $wantedTags && preg_match('#(' . $exp . ')+#', $value) !== false) {
         $modulesTreatment->setTreatmentParameters(array('module' => $module));
         $modulesTreatment->setDefinition($value);
         $value = $modulesTreatment->treatContent(true);
     }
     //eval PHP content if any
     if (strpos($value, '<?php') !== false) {
         $value = io::evalPHPCode($value);
     }
     return $value;
 }
Пример #3
0
 public static function getNewsletterContent($pageId)
 {
     $page = CMS_tree::getPageByID($pageId);
     if ($page->hasError()) {
         return;
     }
     $website = $page->getWebsite();
     $websiteUrl = $website->getURL();
     $language = CMS_languagesCatalog::getByCode($page->getLanguage());
     $content = $page->getContent($language, PAGE_VISUALMODE_HTML_PUBLIC);
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $page);
     $modulesTreatment->setDefinition($content);
     $content = $modulesTreatment->treatContent(true);
     //eval all php code in page
     $php_evalued_content = io::evalPHPCode($content);
     //change all relative URL in page
     $parsed_content = self::prepareHTML($php_evalued_content, $websiteUrl);
     return $parsed_content;
 }