public static function create($campaignId, $data = array())
 {
     if (!io::isPositiveInteger($campaignId)) {
         return false;
     }
     $sql = 'INSERT INTO mod_mailjet VALUES (' . $campaignId . ',"' . json_encode($data) . '");';
     $query = new CMS_query($sql);
     return !$query->hasError();
 }
 public static function getById($id = 0)
 {
     if (!io::isPositiveInteger($id)) {
         return null;
     }
     $sql = 'SELECT * from mod_object_oembed_definition where id_mood = ' . io::sanitizeSQLString($id);
     $query = new CMS_query($sql);
     $data = array_pop($query->getAll());
     if ($data === null) {
         return null;
     }
     return self::getObj($data);
 }
Пример #3
0
 /**
  * Constructor.
  * initialize object.
  *
  * @param string $hash the cache hash to use
  * @param string $type : the type of the cache to use
  * @param mixed $lifetime : the cache lifetime
  * @return void
  * @access public
  */
 function __construct($hash, $type, $lifetime = null, $contextAware = false)
 {
     if ($contextAware) {
         $this->_parameters['hash'] = $hash . '_' . CMS_session::getContextHash();
         $this->_context = true;
     } else {
         $this->_parameters['hash'] = $hash;
     }
     //normalize cache lifetime
     if ($lifetime == 'false' || $lifetime == '0' || $lifetime === false || $lifetime === 0) {
         $lifetime = false;
     }
     if ($lifetime == 'true' || $lifetime == 'auto' || $lifetime == '1' || $lifetime === true || $lifetime === 1) {
         //this definition do not use PHP so use default cache lifetime
         $lifetime = CACHE_MODULES_DEFAULT_LIFETIME;
         //set this cache as auto lifetime
         $this->_auto = true;
     }
     if (io::isPositiveInteger($lifetime)) {
         $lifetime = (int) $lifetime;
     }
     $this->_parameters['type'] = io::sanitizeAsciiString($type);
     $this->_parameters['lifetime'] = $lifetime ? $lifetime : null;
     //check cache dir
     $cachedir = new CMS_file(PATH_CACHE_FS . '/' . $this->_parameters['type'], CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
     if (!$cachedir->exists()) {
         $cachedir->writeTopersistence();
     }
     //Cache options
     $frontendOptions = array('lifetime' => $this->_parameters['lifetime'], 'caching' => $this->_parameters['lifetime'] === null ? false : CACHE_MODULES_DATAS, 'automatic_cleaning_factor' => 50, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => PATH_CACHE_FS . '/' . $this->_parameters['type'], 'cache_file_umask' => octdec(FILES_CHMOD), 'hashed_directory_umask' => octdec(DIRS_CHMOD), 'hashed_directory_level' => 2);
     // getting a Zend_Cache_Core object
     if (!class_exists('Zend_Cache')) {
         die('not found ....');
     }
     try {
         $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     } catch (Zend_Cache_Exception $e) {
         $this->raiseError($e->getMessage());
         return false;
     }
     if (!isset($this->_cache) || !is_object($this->_cache)) {
         $this->raiseError('Error : Zend cache object does not exists');
         return false;
     }
 }
Пример #4
0
                    } elseif (method_exists($resource, 'getTitle')) {
                        $method = 'getTitle';
                    }
                    if ($method) {
                        $element = $resource->{$method}();
                    }
                    if (!$element) {
                        $element = $resource->getID();
                    } else {
                        $element .= ' (' . $resource->getID() . ')';
                    }
                    //get resource type label
                    if (method_exists($module, 'getRessourceTypeLabelMethod') && $module->getRessourceTypeLabelMethod()) {
                        $element = $resource->{$module->getRessourceTypeLabelMethod()}($cms_language) . ' : ' . $element;
                    } else {
                        $element .= ' (' . $module->getLabel($cms_language) . ')';
                    }
                }
            } else {
                $element = $status = '';
            }
            $actionKey = array_search($log->getLogAction(), $actions);
            $actionLabel = io::isPositiveInteger($actionKey) ? $cms_language->getMessage($actionKey) : $actionKey;
            $feeds['items'][] = array('id' => $log->getID(), 'datetime' => $dt->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'), 'element' => $element, 'action' => $actionLabel, 'status' => $status, 'comment' => $log->getTextData());
        }
        $feeds['total_count'] = CMS_log_catalog::search('', 0, $userId, array(), false, false, $start, $limit, $order, $direction, true);
        $feeds['version'] = 1;
        $view->setContent($feeds);
        break;
}
$view->show();
Пример #5
0
 /**
  * Constructor
  * 
  * @access public
  * @param $objectDefinition CMS_poly_object_definition the current search object definition or the ID of the CMS_poly_object_definition
  * @param boolean $public
  */
 function __construct($objectDefinition, $public = false)
 {
     global $cms_user;
     if (io::isPositiveInteger($objectDefinition)) {
         $objectDefinition = CMS_poly_object_catalog::getObjectDefinition($objectDefinition);
     }
     if (!is_a($objectDefinition, 'CMS_poly_object_definition')) {
         $this->raiseError('ObjectDefinition must be a valid CMS_poly_object_definition.');
         return false;
     }
     $this->_object = $objectDefinition;
     // Set public status
     $this->_public = $public;
     //add search object type condition
     $this->addWhereCondition("object", $this->_object);
     //if cms_user exists, check user rights
     if (is_object($cms_user)) {
         $this->addWhereCondition("profile", $cms_user);
     }
     //add resource condition if any
     if ($this->_object->isPrimaryResource()) {
         //if this is a public search, add limitation to resource publications dates
         if ($this->_public) {
             $limitDate = new CMS_date();
             $limitDate->setNow();
             $this->addWhereCondition("publication date before", $limitDate);
             $this->addWhereCondition("publication date end", $limitDate);
         }
     }
 }
Пример #6
0
if (empty($limitToOrderedItems) && empty($limitToItems)) {
    //Add all subobjects to search if any
    foreach ($objectFields as $fieldID => $field) {
        //if field is a poly object
        if (CMS_session::getSessionVar('items_' . $object->getID() . '_' . $fieldID) != '') {
            $search->addWhereCondition($fieldID, CMS_session::getSessionVar('items_' . $object->getID() . '_' . $fieldID));
        }
    }
}
// Param : With keywords (this is best if it is done at last)
if (CMS_session::getSessionVar('items_' . $object->getID() . '_kwrds') != '') {
    $kwrd = CMS_session::getSessionVar('items_' . $object->getID() . '_kwrds');
    if (io::isPositiveInteger($kwrd) && !io::isPositiveInteger($keywordsTarget)) {
        $search->addWhereCondition("item", $kwrd);
    } else {
        if (io::isPositiveInteger($keywordsTarget)) {
            // a specific field target was specified
            $search->addWhereCondition($keywordsTarget, $kwrd, $keywordsOptions);
        } else {
            $search->addWhereCondition("keywords", $kwrd, $keywordsOptions);
        }
    }
}
//If we must limit to some specific items (usually used during refresh of some listing elements)
if ($limitToItems) {
    $search->addWhereCondition("items", $limitToItems);
} elseif ($limitToOrderedItems) {
    //If we must limit to some specific items ordered (usually used for polymod multi_poly_object field)
    $search->addWhereCondition("itemsOrdered", $limitToOrderedItems);
} else {
    // Params : paginate limit
Пример #7
0
 /**
  * Create the redirection of an alias
  *
  * @return boolean true on success, false on failure
  * @access public
  * @static
  */
 function redirect()
 {
     //get aliases for current folder
     $dirname = array_pop(explode(DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_NAME'])));
     $aliases = CMS_module_cms_aliases::getByName($dirname);
     if (!$aliases) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']));
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //check each aliases returned to get the one which respond to current alias
     $matchAlias = false;
     $domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']);
     $websites = array();
     if ($domain) {
         $websites = CMS_websitesCatalog::getWebsitesFromDomain($domain);
     }
     foreach ($aliases as $alias) {
         if (!$matchAlias && dirname($_SERVER['SCRIPT_NAME']) == substr($alias->getPath(), 0, -1)) {
             if ($websites) {
                 foreach ($websites as $website) {
                     //alias match path, check for website
                     if (!$alias->getWebsites() || !$website || in_array($website->getId(), $alias->getWebsites())) {
                         //alias match website, use it
                         $matchAlias = $alias;
                     }
                 }
             } else {
                 //alias match path, check for website
                 if (!$alias->getWebsites()) {
                     //alias match website, use it
                     $matchAlias = $alias;
                 }
             }
         }
     }
     if (!$matchAlias) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']) . ' and domain ' . $domain);
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //if alias is used as a page url, return page
     if ($matchAlias->urlReplaced()) {
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             $page = CMS_tree::getPageById($matchAlias->getPageID());
         } else {
             //no valid page set, go to 404
             $matchAlias->raiseError('No page set for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         if (!$page || $page->hasError()) {
             //no valid page found, go to 404
             $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         //return page path
         $pPath = $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
         if ($pPath) {
             if (file_exists($pPath)) {
                 return $pPath;
             } elseif ($page->regenerate(true)) {
                 clearstatcache();
                 if (file_exists($pPath)) {
                     return $pPath;
                 }
             }
         }
         //no valid url page found, go to 404
         $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     } else {
         //this is a redirection
         $params = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
         if (isset($_SERVER['HTTP_REFERER'])) {
             header("Referer: " . $_SERVER['HTTP_REFERER']);
         }
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             //it's a redirection to an Automne Page
             $page = CMS_tree::getPageById($matchAlias->getPageID());
             if ($page && !$page->hasError()) {
                 $pageURL = CMS_tree::getPageValue($matchAlias->getPageID(), 'url');
                 if ($pageURL) {
                     CMS_view::redirect($pageURL . $params, true, $matchAlias->isPermanent() ? 301 : 302);
                 } else {
                     //no valid url page found, go to 404
                     $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                     CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
                 }
             } else {
                 //no valid page found, go to 404
                 $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                 CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
             }
         } elseif ($matchAlias->getURL()) {
             //it's a redirection to an URL
             CMS_view::redirect($matchAlias->getURL(), true, $matchAlias->isPermanent() ? 301 : 302);
         } else {
             //no valid redirection found, go to 404
             $matchAlias->raiseError('Invalid redirection for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
     }
 }
Пример #8
0
     // Limit
     $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
     $value = isset($data["value"]['search'][$searchName][$paramType]) ? $data["value"]['search'][$searchName][$paramType] : '';
     $searchParamContent[] = array('fieldLabel' => $mandatory . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LIMIT, false, MOD_POLYMOD_CODENAME), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'anchor' => '99%', 'allowNegative' => false, 'allowDecimals' => false, 'xtype' => 'numberfield', 'allowBlank' => !$mandatory, 'value' => $value);
     break;
 case 'order':
     if (sizeof($paramValue)) {
         $orderNameList = array('objectID' => MESSAGE_PAGE_FIELD_ORDER_OBJECTID, 'random' => MESSAGE_PAGE_FIELD_ORDER_RANDOM, 'publication date after' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_START, 'publication date before' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_END);
         $searchOrderContent = array();
         foreach ($paramValue as $orderName => $orderValue) {
             $fieldLabel = '';
             if (in_array($orderName, CMS_object_search::getStaticOrderConditionTypes())) {
                 $fieldLabel = $cms_language->getMessage($orderNameList[$orderName], false, MOD_POLYMOD_CODENAME);
             } else {
                 $orderName = trim($orderName, '()');
                 if (io::isPositiveInteger($orderName)) {
                     $field = new CMS_poly_object_field($orderName);
                     if ($field && !$field->hasError()) {
                         $label = new CMS_object_i18nm($field->getValue('labelID'));
                         $fieldLabel = $label->getValue($cms_language->getCode());
                     }
                 }
             }
             if ($fieldLabel) {
                 // Order direction
                 $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
                 $value = isset($data["value"]['search'][$searchName][$paramType][$orderName]) ? $data["value"]['search'][$searchName][$paramType][$orderName] : '';
                 $searchOrderContent[] = array('xtype' => 'atmCombo', 'fieldLabel' => $mandatory . $fieldLabel, 'name' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'hiddenName' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'forceSelection' => true, 'mode' => 'local', 'valueField' => 'id', 'displayField' => 'name', 'triggerAction' => 'all', 'allowBlank' => !$mandatory, 'selectOnFocus' => true, 'editable' => false, 'value' => $value, 'store' => array('xtype' => 'arraystore', 'fields' => array('id', 'name'), 'data' => array(array('', '-'), array('asc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_ASC, false, MOD_POLYMOD_CODENAME)), array('desc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_DESC, false, MOD_POLYMOD_CODENAME)))));
             } else {
                 $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_SEARCH_ORDERTYPE_ERROR, array($searchName, $row->getLabel(), $orderName), MOD_POLYMOD_CODENAME) . "\n";
             }
Пример #9
0
 /**
  * Return well indented php code
  *
  * @param string $phpcode : php code to indent
  * @return string indented php code
  * @access public
  * @static
  */
 function indentPHP($phpcode)
 {
     $phparray = array_map('trim', explode("\n", $phpcode));
     $level = 0;
     foreach ($phparray as $linenb => $phpline) {
         //remove blank lines
         if ($phpline == '') {
             unset($phparray[$linenb]);
             continue;
         }
         //check for indent level down
         $firstChar = $phpline[0];
         if ($firstChar == '}' || $firstChar == ')' || substr($phpline, 0, 5) == 'endif') {
             $level--;
         }
         //indent code
         $indent = io::isPositiveInteger($level) ? str_repeat("\t", $level) : '';
         $phparray[$linenb] = $indent . $phpline;
         //check for indent level up
         $lastChar = substr($phpline, -1);
         if ($lastChar == '{' || $lastChar == ':' || substr($phpline, -7) == 'array (') {
             $level++;
         }
     }
     return implode("\n", $phparray);
 }
Пример #10
0
 /**
  * Sets the 403 page Id for the website
  *
  * @param integer $pageId The 403 page Id to set
  * @return boolean true on success, false on failure.
  * @access public
  */
 function set403($pageId)
 {
     if ($pageId && !io::isPositiveInteger($pageId)) {
         return false;
     }
     $this->_403 = $pageId;
     return true;
 }
Пример #11
0
 /**
  * Factory, instanciate a sender from current context
  * 
  * @return CMS_forms_sender 
  */
 function getSenderForContext()
 {
     //sender does not exists in DB so create a new one*/
     $obj = new CMS_forms_sender();
     $obj->setAttribute('sessionID', Zend_Session::getId());
     if (io::isPositiveInteger(CMS_session::getUserID())) {
         $obj->setAttribute('userID', CMS_session::getUserID());
     }
     $obj->setAttribute('clientIP', @$_SERVER["REMOTE_ADDR"]);
     if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
         $obj->setAttribute('languages', @$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
     }
     $obj->setAttribute('userAgent', @$_SERVER["HTTP_USER_AGENT"]);
     return $obj;
 }
Пример #12
0
 $replaceURL = sensitiveIO::request('replaceURL') ? true : false;
 $permanent = sensitiveIO::request('permanent') ? true : false;
 // Current alias object to manipulate
 if ($aliasId) {
     $item = CMS_module_cms_aliases::getByID($aliasId);
 } else {
     $item = new CMS_resource_cms_aliases();
 }
 //check protected status
 $protected = sensitiveIO::request('protected') ? true : false;
 if (!$item->isProtected() || !$protected && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
     //set alias websites (needed to know if alias is correct in case of name conflict)
     $item->setWebsites(explode(',', $websites));
     //set parent only if alias has no subaliases
     if (!$item->hasSubAliases()) {
         if (io::isPositiveInteger($newFatherId)) {
             $parent = CMS_module_cms_aliases::getByID($newFatherId);
             $item->setParent($parent);
         } else {
             $item->setParent(false);
         }
         //then set alias name
         if (!$item->setAlias($name)) {
             $cms_message .= $cms_language->getMessage(MESSAGE_ERROR_DIRECTORY_EXISTS, false, 'cms_aliases');
             break;
         }
     }
     $item->setReplaceURL($replaceURL);
     $item->setPermanent($permanent);
     $item->setProtected($protected);
     if ($pageId) {
Пример #13
0
 /**
  * Get iframe code for current html embed code
  *
  * @param string $style the html style code to add
  * @param string $attr the html attributes code to add
  * @return string the html code
  * @access protected
  */
 protected function _getIframe($style, $attr)
 {
     //load datas
     if (!($datas = $this->getDatas())) {
         return '';
     }
     //already iframe embeded, no need to redo an iframe arround
     if (strtolower(substr(trim($datas['html']), 0, 8)) == '<iframe ') {
         return '<div' . $style . $attr . '>' . $datas['html'] . '</div>';
     }
     //frame param
     $frameParam = base64_encode(serialize(array('url' => $this->_url, 'maxwidth' => io::isPositiveInteger($this->_maxwidth) ? $this->_maxwidth : '', 'maxheight' => io::isPositiveInteger($this->_maxheight) ? $this->_maxheight : '')));
     //frame domain
     if (defined('APPLICATION_EMBED_DOMAIN') && APPLICATION_EMBED_DOMAIN) {
         $domain = strtolower(substr(APPLICATION_EMBED_DOMAIN, 0, 4)) == 'http' ? APPLICATION_EMBED_DOMAIN : 'http://' . APPLICATION_EMBED_DOMAIN;
     } else {
         $domain = CMS_websitesCatalog::getCurrentDomain();
     }
     //iframe width/height
     $width = $height = '';
     if (isset($datas['width']) && io::isPositiveInteger($datas['width'])) {
         $width = io::htmlspecialchars($datas['width']);
     } else {
         //try to guess width for iframe ...
         $matches = array();
         if (preg_match('/^<[^>]* width="([0-9]+)"/i', trim($datas['html']), $matches) && isset($matches[1])) {
             $width = $matches[1];
         } elseif (io::isPositiveInteger($this->_maxwidth)) {
             $width = $this->_maxwidth;
         }
     }
     if (isset($datas['height']) && io::isPositiveInteger($datas['height'])) {
         $height = io::htmlspecialchars($datas['height']);
     } else {
         //try to guess width for iframe ...
         $matches = array();
         if (preg_match('/^<[^>]* height="([0-9]+)"/i', trim($datas['html']), $matches) && isset($matches[1])) {
             $height = $matches[1];
         } elseif (io::isPositiveInteger($this->_maxheight)) {
             $height = $this->_maxheight;
         }
     }
     return '<iframe scrolling="no" frameBorder="0"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . $domain . PATH_MAIN_WR . '/oembed/frame' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?params=' . $frameParam . '">' . '	<a href="' . $domain . PATH_MAIN_WR . '/oembed/frame' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?params=' . $frameParam . '" target="_blank">Click to view media</a>' . '</iframe>';
 }
Пример #14
0
if ($_SERVER['REQUEST_URI'] && $_SERVER['REQUEST_URI'] != $_SERVER['SCRIPT_NAME']) {
    $pathinfo = pathinfo($_SERVER['REQUEST_URI']);
    $basename = isset($pathinfo['filename']) ? $pathinfo['filename'] : $pathinfo['basename'];
    //first try to get redirection rules from CSV file if exists
    if (file_exists(PATH_MAIN_FS . '/redirect/redirectRules.csv')) {
        $csvFile = new CMS_file(PATH_MAIN_FS . '/redirect/redirectRules.csv');
        $csvDatas = $csvFile->readContent('csv', 'trim', array('delimiter' => ';', 'enclosure' => '"', 'strict' => true));
        $rules = array();
        foreach ($csvDatas as $line => $csvData) {
            if (isset($csvData[0]) && $csvData[0] && isset($csvData[1]) && $csvData[1]) {
                $rules[$csvData[0]] = $csvData[1];
            }
        }
        if (isset($rules[$_SERVER['REQUEST_URI']]) && io::isPositiveInteger($rules[$_SERVER['REQUEST_URI']])) {
            $page = CMS_tree::getPageById($rules[$_SERVER['REQUEST_URI']]);
        } elseif (isset($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)]) && io::isPositiveInteger($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)])) {
            $page = CMS_tree::getPageById($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)]);
        }
    }
    if (!isset($page)) {
        //get page from requested url
        $page = CMS_tree::analyseURL($_SERVER['REQUEST_URI'], false);
    }
    //get redirection URL for page
    if (isset($page) && is_object($page) && !$page->hasError() && $page->getStatus()->getLocation() != RESOURCE_LOCATION_DELETED) {
        //get page file
        $pageURL = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false, false, PATH_RELATIVETO_FILESYSTEM);
        if (file_exists($pageURL)) {
            $redirectTo = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false);
        } else {
            //try to regenerate page
Пример #15
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     switch ($name) {
         case 'file':
         case 'thumb':
             if ($name == 'file') {
                 $fieldIndex = 4;
                 $fielfPrefix = 'image';
             } else {
                 $fieldIndex = 1;
                 $fielfPrefix = 'thumb';
             }
             // If we have a value and there are additionnal cropping parameters
             if ($this->_subfieldValues[$fieldIndex]->getValue() && $parameters && in_array($this->getValue($name . 'Extension'), array('jpg', 'jpeg', 'png', 'gif'))) {
                 @(list($x, $y) = explode(',', str_replace(';', ',', $parameters)));
                 if (io::isPositiveInteger($x) && $x < $this->getValue($fielfPrefix . 'Width') || io::isPositiveInteger($y) && $y < $this->getValue($fielfPrefix . 'Height')) {
                     $crop = $x && $y ? 1 : 0;
                     //get module codename
                     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                     //set location
                     $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
                     //resized image path
                     $pathInfo = pathinfo($this->_subfieldValues[$fieldIndex]->getValue());
                     $resizedImage = $pathInfo['filename'] . '-' . $x . '-' . $y . ($crop ? '-c' : '') . '.' . $pathInfo['extension'];
                     //resized image path
                     $resizedImagepathFS = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location . '/' . $resizedImage;
                     //if file already exists, no need to resize file send it
                     if (file_exists($resizedImagepathFS)) {
                         return $this->getValue('filePath') . '/' . $resizedImage;
                     } else {
                         return CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . '/image-file' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?image=' . $this->_subfieldValues[$fieldIndex]->getValue() . '&amp;module=' . $moduleCodename . '&amp;x=' . $x . '&amp;y=' . $y . '&amp;crop=' . $crop . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? '&amp;location=' . $location : '');
                     }
                 }
             }
             if ($this->_subfieldValues[$fieldIndex]->getValue()) {
                 // If we have a value but no cropping params
                 return $this->getValue('filePath') . '/' . $this->_subfieldValues[$fieldIndex]->getValue();
             }
             return '';
             break;
         case 'fileHTML':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $filepath = $this->_subfieldValues[3]->getValue() == self::OBJECT_FILE_TYPE_INTERNAL ? PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location . '/' . $this->_subfieldValues[4]->getValue() : $this->_subfieldValues[4]->getValue();
             //append website url if missing
             if (io::substr($filepath, 0, 1) == '/') {
                 $filepath = CMS_websitesCatalog::getCurrentDomain() . $filepath;
             }
             //link content
             $linkContent = $parameters ? $parameters : $this->_subfieldValues[0]->getValue();
             $file = '<a href="' . $filepath . '" target="_blank" title="' . $this->_subfieldValues[0]->getValue() . '">' . $linkContent . '</a>';
             return $file;
             break;
         case 'fileLabel':
             return $this->_subfieldValues[0]->getValue();
             break;
         case 'filename':
             return $this->_subfieldValues[4]->getValue();
             break;
         case 'thumbnail':
         case 'thumbname':
             return $this->_subfieldValues[1]->getValue();
             break;
         case 'filePath':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $altDomain = $this->getAlternativeDomain();
             // If we are serving a public file and there is an alternative domain set up, change the url
             if ($this->isPublic() && $altDomain) {
                 return $altDomain . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             } else {
                 return CMS_websitesCatalog::getCurrentDomain() . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             }
             break;
         case 'thumbMaxWidth':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['thumbMaxWidth'] ? $params['thumbMaxWidth'] : '';
             break;
         case 'thumbMaxHeight':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['thumbMaxHeight'] ? $params['thumbMaxHeight'] : '';
             break;
         case 'thumbWidth':
         case 'thumbHeight':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $imgPath = $path . "/" . $this->_subfieldValues[1]->getValue();
             $sizeX = $sizeY = 0;
             if (file_exists($imgPath)) {
                 list($sizeX, $sizeY) = @getimagesize($imgPath);
             }
             if ($name == 'thumbWidth') {
                 return (string) $sizeX;
             } else {
                 return (string) $sizeY;
             }
             break;
         case 'imageWidth':
         case 'imageHeight':
             if ($this->_subfieldValues[4]->getValue() && in_array($this->getValue('fileExtension'), array('jpg', 'jpeg', 'png', 'gif'))) {
                 //get module codename
                 $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                 //set location
                 $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
                 $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
                 $imgPath = $path . "/" . $this->_subfieldValues[4]->getValue();
                 $sizeX = $sizeY = 0;
                 if (file_exists($imgPath)) {
                     list($sizeX, $sizeY) = @getimagesize($imgPath);
                 }
                 if ($name == 'imageWidth') {
                     return (string) $sizeX;
                 } else {
                     return (string) $sizeY;
                 }
             }
             return 0;
             break;
         case 'fileSize':
             return $this->_subfieldValues[2]->getValue();
             break;
         case 'fileIcon':
             return $this->_getFileIcon();
             break;
         case 'fileExtension':
             return $this->_getFileExtension();
             break;
         case 'thumbExtension':
             return $this->_getThumbExtension();
             break;
         case 'alternativeDomain':
             return $this->getAlternativeDomain();
         default:
             return parent::getValue($name, $parameters);
             break;
     }
 }
Пример #16
0
 /**
  * Import module objects from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create categories (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 static function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for objects importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for objects importation : ' . $params['module'] . "\n";
         return false;
     }
     $return = true;
     //first create missing objects to get relation ids
     foreach ($data as $objectDatas) {
         if (!isset($objectDatas['uuid']) || !CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid'])) {
             //create new object if we can
             if (!isset($params['create']) || $params['create'] == true) {
                 //create object
                 $object = new CMS_poly_object_definition();
                 //set module
                 $object->setValue('module', $params['module']);
                 //set uuid
                 $object->setUuid($objectDatas['uuid']);
                 //write object to persistence to get relations ids
                 $object->writeToPersistence();
                 //set id translation
                 if (isset($objectDatas['id']) && $objectDatas['id']) {
                     // && $object->getID() != $objectDatas['id']) {
                     // Fix for bug #3157 : in some cases the imported object will have the same id has the newly created,
                     // we still need the relation table otherwise it will fail to link to the new object
                     $idsRelation['objects'][$objectDatas['id']] = $object->getID();
                 }
                 //set uuid translation
                 if (isset($objectDatas['uuid']) && $objectDatas['uuid'] && $object->getValue('uuid') != $objectDatas['uuid']) {
                     $idsRelation['objects-uuid'][$objectDatas['uuid']] = $object->getValue('uuid');
                 }
             }
         } elseif (isset($objectDatas['uuid']) && isset($objectDatas['id'])) {
             //get relation between imported object id and local id
             $id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid']);
             if (io::isPositiveInteger($id)) {
                 $idsRelation['objects'][$objectDatas['id']] = $id;
             }
         }
     }
     //then import objects datas
     foreach ($data as $objectDatas) {
         $importType = '';
         if (isset($objectDatas['uuid']) && ($id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid']))) {
             //object already exist : load it if we can update it
             if (!isset($params['update']) || $params['update'] == true) {
                 $object = CMS_poly_object_catalog::getObjectDefinition($id);
                 $importType = ' (Update)';
                 //set id translation
                 $idsRelation['objects'][$objectDatas['id']] = $id;
             }
         } else {
             //check for translated id
             if (isset($objectDatas['id']) && isset($idsRelation['objects'][$objectDatas['id']])) {
                 //object exists with a translated id
                 $objectDatas['id'] = $idsRelation['objects'][$objectDatas['id']];
                 //load translated object
                 $object = CMS_poly_object_catalog::getObjectDefinition($objectDatas['id']);
                 $importType = ' (Creation)';
             }
             //check for translated uuid
             if (isset($objectDatas['uuid']) && isset($idsRelation['objects-uuid'][$objectDatas['uuid']])) {
                 //object exists with a translated uuid
                 $objectDatas['uuid'] = $idsRelation['objects-uuid'][$objectDatas['uuid']];
                 //load translated object
                 if ($id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid'])) {
                     $object = CMS_poly_object_catalog::getObjectDefinition($id);
                     $importType = ' (Creation)';
                 }
             }
         }
         if (isset($object)) {
             if ($object->fromArray($objectDatas, $params, $cms_language, $idsRelation, $infos)) {
                 $return &= true;
                 $infos .= 'Object "' . $object->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
             } else {
                 $return = false;
                 $infos .= 'Error during import of object ' . $objectDatas['id'] . $importType . "\n";
             }
         }
     }
     return $return;
 }
Пример #17
0
ksort($selectContent);
array_unshift($selectContent, array(0, '/'));
$selectContent = sensitiveIO::jsonEncode(array_values($selectContent));
$controlerURL = PATH_ADMIN_MODULES_WR . '/' . $codename . '/controler.php';
$parentId = isset($parentAlias) && is_object($parentAlias) ? $parentAlias->getId() : 0;
//mandatory
$mandatory = '<span class="atm-red">*</span> ';
//create pseudo href for redirection infos
$href = new CMS_href();
if ($pageId) {
    $href->setLinkType(RESOURCE_LINK_TYPE_INTERNAL);
    $href->setInternalLink($pageId);
    $redirDisabled = 'disabled:true,';
    $redirHidden = "{\n\t\txtype:\t\t\t'hidden',\n\t\tname:\t\t\t'page',\n\t\tvalue:\t\t\t'{$pageId}'\n\t},";
} else {
    if (io::isPositiveInteger($item->getPageID())) {
        $href->setLinkType(RESOURCE_LINK_TYPE_INTERNAL);
        $href->setInternalLink($item->getPageID());
    } elseif ($item->getURL()) {
        $href->setLinkType(RESOURCE_LINK_TYPE_EXTERNAL);
        $href->setExternalLink($item->getURL());
    }
    $redirDisabled = $redirHidden = '';
}
$redirectValue = io::sanitizeJSString($href->getTextDefinition());
$visualmode = RESOURCE_DATA_LOCATION_EDITED;
//Websites
$currentWebsites = $item->getWebsites();
$websites = CMS_websitesCatalog::getAll();
$availableWebsites = $selectedWebsites = array();
foreach ($websites as $id => $website) {
Пример #18
0
    /**
     * Return the module code for the specified treatment mode, visualization mode and object.
     *
     * @param mixed $modulesCode the previous modules codes (usually string)
     * @param integer $treatmentMode The current treatment mode (see constants on top of this file for accepted values).
     * @param integer $visualizationMode The current visualization mode (see constants on top of cms_page class for accepted values).
     * @param object $treatedObject The reference object to treat.
     * @param array $treatmentParameters : optionnal parameters used for the treatment. Usually an array of objects.
     *
     * @return string : the module code to add
     * @access public
     */
    function getModuleCode($modulesCode, $treatmentMode, $visualizationMode, &$treatedObject, $treatmentParameters)
    {
        switch ($treatmentMode) {
            case MODULE_TREATMENT_PAGECONTENT_HEADER_CODE:
                //if this page use a row of this module then add the header code to the page
                if ($usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename)) {
                    if (isset($usage['headCallback'])) {
                        $modulesCode[$this->_codename] = '';
                        foreach ($usage['headCallback'] as $headCallback) {
                            //add header codes
                            if (isset($headCallback['tagsCallback'])) {
                                foreach ($headCallback['tagsCallback'] as $key => $headcode) {
                                    if (isset($headcode['code'])) {
                                        $modulesCode[$this->_codename] .= '<?php' . "\n" . $headCallback['headcode'] . "\n" . $headcode['code'] . "\n" . '?>';
                                    }
                                }
                            }
                            //add forms header if needed
                            if (isset($headCallback['form']) && $headCallback['form']) {
                                $modulesCode[$this->_codename] .= '<?php CMS_poly_definition_functions::formActions(' . var_export($headCallback['form'], true) . ', \'' . $treatedObject->getID() . '\', \'' . $headCallback['language'] . '\', ' . ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC || $visualizationMode == PAGE_VISUALMODE_PRINT || $visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE ? 'true' : 'false') . ', $polymodFormsError, $polymodFormsItems); ?>';
                            }
                            //add forms callback if needed
                            if (isset($headCallback['formsCallback']) && is_array($headCallback['formsCallback']) && isset($headCallback['headcode'])) {
                                foreach ($headCallback['formsCallback'] as $formName => $formCallback) {
                                    foreach ($formCallback as $formFieldID => $callback) {
                                        if (io::isPositiveInteger($formFieldID)) {
                                            $modulesCode[$this->_codename] .= '<?php' . "\n" . '//callback function to check field ' . $formFieldID . ' for atm-form ' . $formName . "\n" . 'function form_' . $formName . '_' . $formFieldID . '($formName, $fieldID, &$item_' . $formName . '_' . $formFieldID . ') {' . "\n" . '		global $cms_user;' . "\n" . '		global $public_search;' . "\n" . '		global $cms_language;' . "\n" . '       $object[$item_' . $formName . '_' . $formFieldID . '->getObjectID()] = $item_' . $formName . '_' . $formFieldID . ';' . "\n" . '       ' . $headCallback['headcode'] . "\n" . '       ' . $callback . "\n" . '       return false;' . "\n" . '}' . "\n" . '?>';
                                        } elseif ($formFieldID == 'form') {
                                            $modulesCode[$this->_codename] .= '<?php' . "\n" . '//callback function for atm-form ' . $formName . "\n" . 'function form_' . $formName . '($formName, &$item_' . $formName . ') {' . "\n" . '		global $cms_user;' . "\n" . '		global $public_search;' . "\n" . '		global $cms_language;' . "\n" . '       $object[$item_' . $formName . '->getObjectID()] = $item_' . $formName . ';' . "\n" . '       ' . $headCallback['headcode'] . "\n" . '       ' . $callback . "\n" . '       return true;' . "\n" . '}' . "\n" . '?>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return $modulesCode;
                break;
            case MODULE_TREATMENT_ROWS_EDITION_LABELS:
                $modulesCode[$this->_codename] = '';
                //if user has rights on module
                if ($treatmentParameters["user"]->hasModuleClearance($this->_codename, CLEARANCE_MODULE_EDIT)) {
                    if (!isset($treatmentParameters['request'])) {
                        //add form to choose object to display
                        $modulesCode[$this->_codename] = '
							<h1>' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_ROW_TAGS_CHOOSE, false, MOD_POLYMOD_CODENAME) . '<select onchange="Ext.get(\'help' . $this->_codename . '\').getUpdater().update({url: \'' . PATH_ADMIN_WR . '/help-detail.php\',params: {module: \'' . $this->_codename . '\',object: this.value, mode:' . MODULE_TREATMENT_ROWS_EDITION_LABELS . '}});">
								<option value="">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_CHOOSE) . '</option>
								<optgroup label="' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_ROW_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">
									<option value="block">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
									<option value="search">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_SEARCH_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
									<option value="working">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_TAGS) . '</option>
									<option value="working-polymod">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_POLYMOD_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
									<option value="vars">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_GENERAL_VARS) . '</option>
									<option value="forms">' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_FORMS, false, MOD_POLYMOD_CODENAME) . '</option>
								</optgroup>
								<optgroup label="' . $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_ROW_OBJECTS_VARS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">';
                        $modulesCode[$this->_codename] .= CMS_poly_module_structure::viewObjectInfosList($this->_codename, $treatmentParameters["language"], @$treatmentParameters['request'][$this->_codename . 'object']);
                        $modulesCode[$this->_codename] .= '
								</optgroup>';
                        $modulesCode[$this->_codename] .= '
							</select></h1>
							<div id="help' . $this->_codename . '"></div>
						';
                    }
                    //then display chosen object infos
                    if (isset($treatmentParameters['request'][$this->_codename]) && isset($treatmentParameters['request'][$this->_codename . 'object'])) {
                        switch ($treatmentParameters['request'][$this->_codename . 'object']) {
                            case 'block':
                                $moduleLanguages = CMS_languagesCatalog::getAllLanguages($this->_codename);
                                foreach ($moduleLanguages as $moduleLanguage) {
                                    $moduleLanguagesCodes[] = $moduleLanguage->getCode();
                                }
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_TAGS_EXPLANATION, array($this->_codename, implode(', ', $moduleLanguagesCodes)), MOD_POLYMOD_CODENAME);
                                break;
                            case 'search':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_SEARCH_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                                break;
                            case 'working':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_TAGS_EXPLANATION);
                                break;
                            case 'working-polymod':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_WORKING_POLYMOD_TAGS_EXPLANATION, array(implode(', ', CMS_modulesCatalog::getAllCodenames())), MOD_POLYMOD_CODENAME);
                                break;
                            case 'vars':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_GENERAL_VARS_EXPLANATION, array($treatmentParameters["language"]->getDateFormatMask(), $treatmentParameters["language"]->getDateFormatMask(), $treatmentParameters["language"]->getDateFormatMask()));
                                break;
                            case 'forms':
                                $modulesCode[$this->_codename] .= $treatmentParameters["language"]->getMessage(self::MESSAGE_PAGE_BLOCK_FORMS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                                break;
                            default:
                                //object info
                                $modulesCode[$this->_codename] .= CMS_poly_module_structure::viewObjectRowInfos($this->_codename, $treatmentParameters["language"], $treatmentParameters['request'][$this->_codename . 'object']);
                                break;
                        }
                    }
                }
                return $modulesCode;
                break;
            case MODULE_TREATMENT_EDITOR_CODE:
                if ($treatmentParameters["editor"] == "fckeditor" && $treatmentParameters["user"]->hasModuleClearance($this->_codename, CLEARANCE_MODULE_EDIT)) {
                    if (!isset($modulesCode["Default"]['polymod'])) {
                        $pluginDefinitions = CMS_poly_object_catalog::getAllPluginDefinitionsForObject();
                        if (is_array($pluginDefinitions) && $pluginDefinitions) {
                            $languages = implode(',', array_keys(CMS_languagesCatalog::getAllLanguages()));
                            //This is an exception of the method, because here we return an array, see admin/fckeditor/fckconfig.php for the detail
                            $modulesCode["Default"]['polymod'] = "'polymod'";
                            $modulesCode["modulesDeclaration"]['polymod'] = "FCKConfig.Plugins.Add( 'polymod', '" . $languages . "' );";
                        }
                    }
                    $plugins = array();
                    //get all objects for module
                    $moduleObjects = CMS_poly_object_catalog::getObjectsForModule($this->_codename);
                    foreach ($moduleObjects as $object) {
                        $fields = CMS_poly_object_catalog::getFieldsDefinition($object->getID());
                        foreach ($fields as $field) {
                            $fieldObject = $field->getTypeObject(true);
                            if (method_exists($fieldObject, 'getUsedPlugins')) {
                                $plugins = array_merge($plugins, $fieldObject->getUsedPlugins());
                            }
                        }
                    }
                    $plugins = array_unique($plugins);
                    // create specific polymod toolbar
                    $modulesCode["ToolbarSets"][] = "FCKConfig.ToolbarSets[\"" . $this->_codename . "\"] = [\n\t\t\t\t\t\t\t\t['Source','Undo','Redo'],\n\t\t\t\t\t\t\t\t['Cut','Copy','Paste','PasteText','PasteWord'],\n\t\t\t\t\t\t\t\t['OrderedList','UnorderedList','-','Outdent','Indent'],\n\t\t\t\t\t\t\t\t['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],\n\t\t\t\t\t\t\t\t['Link','Unlink','Anchor'" . ($plugins ? ',' . implode(",", $plugins) : '') . "],\n\t\t\t\t\t\t\t\t['Table','Rule','SpecialChar']\n\t\t\t\t\t\t\t];";
                }
                return $modulesCode;
                break;
            case MODULE_TREATMENT_EDITOR_PLUGINS:
                if ($treatmentParameters["editor"] == "fckeditor" && $treatmentParameters["user"]->hasModuleClearance($this->_codename, CLEARANCE_MODULE_EDIT)) {
                    if (!isset($modulesCode['polymod'])) {
                        $modulesCode['polymod'] = '';
                        $pluginDefinitions = CMS_poly_object_catalog::getAllPluginDefinitionsForObject();
                        if (is_array($pluginDefinitions) && $pluginDefinitions) {
                            foreach ($pluginDefinitions as $pluginDefinition) {
                                $modulesCode['polymod'] .= $modulesCode['polymod'] ? ', ' : '';
                                $modulesCode['polymod'] .= $pluginDefinition->getLabel($treatmentParameters["user"]->getLanguage());
                            }
                        }
                    }
                }
                break;
            case MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT:
                //if object is a polyobject and module is the current object's module
                if ($treatedObject instanceof CMS_poly_object && $this->_codename == CMS_poly_object_catalog::getModuleCodenameForObject($treatedObject->getID())) {
                    //send notification of the validation result to polyobject
                    $treatedObject->afterValidation($treatmentParameters['result']);
                }
                break;
            case MODULE_TREATMENT_ALERTS:
                //only if user has validation clearances
                if ($treatmentParameters['user']->hasValidationClearance($this->_codename)) {
                    $modulesCode[$this->_codename] = array(ALERT_LEVEL_VALIDATION => array('label' => self::MESSAGE_ALERT_LEVEL_VALIDATION, 'description' => self::MESSAGE_ALERT_LEVEL_VALIDATION_DESCRIPTION));
                }
                return $modulesCode;
                break;
        }
        return $modulesCode;
    }
Пример #19
0
 /**
  * Return the module CSS files
  *
  * @return array : the module css file in /css/modules/codename
  * @access public
  */
 function getCSSFiles($pageId = '', $allFiles = false)
 {
     $files = array();
     $medias = array('all', 'aural', 'braille', 'embossed', 'handheld', 'print', 'projection', 'screen', 'tty', 'tv');
     //get generic files
     foreach ($medias as $media) {
         if ($media == 'all') {
             if (file_exists(PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename . '.css')) {
                 $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', PATH_CSS_FS . '/modules/' . $this->_codename . '.css'));
             }
         }
         if (file_exists(PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename . '-' . $media . '.css')) {
             $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', PATH_CSS_FS . '/modules/' . $this->_codename . '-' . $media . '.css'));
         }
     }
     //get subdir files if any
     $dirname = PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename;
     if (@is_dir($dirname)) {
         try {
             //all subdirs or only this dir
             $dir = $allFiles ? new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST) : new DirectoryIterator($dirname);
             foreach ($dir as $file) {
                 if ($file->isFile() && io::substr($file->getFilename(), -4) == ".css") {
                     $found = false;
                     foreach ($medias as $media) {
                         if (io::substr($file->getFilename(), -5 - strlen($media)) == '-' . $media . '.css') {
                             $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                             $found = true;
                         }
                     }
                     if (!$found) {
                         $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                     }
                 }
             }
         } catch (Exception $e) {
         }
     }
     //get website files if any
     if (!$allFiles && io::isPositiveInteger($pageId)) {
         $page = CMS_tree::getPageById($pageId);
         if ($page) {
             $website = $page->getWebsite();
             if ($website) {
                 if (@is_dir($dirname . DIRECTORY_SEPARATOR . $website->getCodename())) {
                     try {
                         foreach (new DirectoryIterator($dirname . DIRECTORY_SEPARATOR . $website->getCodename()) as $file) {
                             if ($file->isFile() && io::substr($file->getFilename(), -4) == ".css") {
                                 $found = false;
                                 foreach ($medias as $media) {
                                     if (io::substr($file->getFilename(), -5 - strlen($media)) == '-' . $media . '.css') {
                                         $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                                         $found = true;
                                     }
                                 }
                                 if (!$found) {
                                     $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                                 }
                             }
                         }
                     } catch (Exception $e) {
                     }
                 }
             }
         }
     }
     return $files;
 }
Пример #20
0
 /**
  * Get Page
  *
  * @return CMS_page The page currently registered, false if none
  * @access public
  */
 public static function getPage()
 {
     $sessionNS = new Zend_Session_Namespace('atm-page');
     if (isset($sessionNS->pageId) && io::isPositiveInteger($sessionNS->pageId)) {
         return CMS_tree::getPageByID($sessionNS->pageId);
     } else {
         return false;
     }
 }
Пример #21
0
 /**
  * Import field from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     if (isset($data['type']) && $data['type']) {
         $type = !io::isPositiveInteger($data['type']) ? $data['type'] : (isset($data['multi']) && $data['multi'] ? 'multi|' . $data['type'] : $data['type']);
         if (!io::isPositiveInteger($data['type'])) {
             $type = $data['type'];
         } else {
             if (isset($idsRelation['objects'][$data['type']])) {
                 $objectId = $idsRelation['objects'][$data['type']];
                 $type = isset($data['multi']) && $data['multi'] ? 'multi|' . $objectId : $objectId;
             } else {
                 // Use UUID to look for the linked object
                 if (isset($data['params']['linkedObjectUuid'])) {
                     //$this->setValue("order", $data['params']['order']);
                     $linkedObjectDef = CMS_poly_object_catalog::getDefinitionFromUuid($data['params']['linkedObjectUuid']);
                     if ($linkedObjectDef) {
                         $objectId = $linkedObjectDef->getID();
                         $type = isset($data['multi']) && $data['multi'] ? 'multi|' . $objectId : $objectId;
                     } else {
                         $type = 'Unknown imported type ' . $data['type'];
                     }
                 } else {
                     $type = 'Unknown imported type ' . $data['type'];
                 }
             }
         }
         $this->setValue("type", $type);
     } else {
         $infos .= 'Error : missing or invalid type for field importation ...' . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::fieldUuidExists($data['uuid'])) {
         //check imported uuid. If objects does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['fields-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectFieldValues["uuid"]) {
         $this->_objectFieldValues["uuid"] = $data['uuid'];
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     if (isset($data['params']['order'])) {
         $this->setValue("order", $data['params']['order']);
     }
     if (isset($data['params']['required'])) {
         $this->setValue("required", $data['params']['required']);
     }
     if (isset($data['params']['indexable'])) {
         $this->setValue("indexable", $data['params']['indexable']);
     }
     if (isset($data['params']['searchlist'])) {
         $this->setValue("searchlist", $data['params']['searchlist']);
     }
     if (isset($data['params']['searchable'])) {
         $this->setValue("searchable", $data['params']['searchable']);
     }
     //parameters
     if (!io::isPositiveInteger($data['type']) || isset($data['multi']) && $data['multi']) {
         $fieldObject = $this->getTypeObject();
         $GLOBALS['moduleCodename'] = $params['module'];
         if ($fieldObject && isset($data['params']['params']) && $data['params']['params']) {
             if (method_exists($fieldObject, 'treatParams')) {
                 $params = $fieldObject->treatParams($data['params']['params'], '');
                 if ($params) {
                     $this->setValue("params", $params);
                     //set this object into definition to convert array so it can be converted again at end of import process
                     $idsRelation['definitionToConvert'][] = $this;
                     //store field to convert params at end of import
                     if (method_exists($fieldObject, 'importParams')) {
                         $idsRelation['paramsFieldsToConvert'][] = $this;
                     }
                 } else {
                     $infos .= 'Error : missing or invalid parameters for field importation ...' . "\n";
                     return false;
                 }
             }
         }
     }
     //write field
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object field ...' . "\n";
         return false;
     }
     //if current field id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['fields'][$data['id']] = $this->getID();
         if (isset($data['uuid']) && $data['uuid']) {
             $idsRelation['fields'][$data['uuid']] = $this->getID();
         }
     }
     return true;
 }
Пример #22
0
 /**
  * Checks if current session exists in session table
  *
  * @return void
  * @access private
  */
 function _checkSession($userId)
 {
     if (io::isPositiveInteger($userId)) {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tsessions\n\t\t\t\twhere\n\t\t\t\t\tphpid_ses='" . io::sanitizeSQLString(Zend_Session::getId()) . "'\n\t\t\t\t\tand user_ses='" . io::sanitizeSQLString($userId) . "'\n\t\t\t\t\tand UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(lastTouch_ses) <= " . io::sanitizeSQLString(APPLICATION_SESSION_TIMEOUT) . "\n\t\t\t";
         if (CHECK_REMOTE_IP_MASK && isset($_SERVER['REMOTE_ADDR'])) {
             //Check for a range in IPv4 or for the exact address in IPv6
             if (filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
                 $a_ip_seq = explode(".", $_SERVER['REMOTE_ADDR']);
                 $sql .= " and remote_addr_ses like '" . io::sanitizeSQLString($a_ip_seq[0] . "." . $a_ip_seq[1] . ".") . "%'\n\t\t\t\t\t";
             } else {
                 $sql .= " and remote_addr_ses = '" . io::sanitizeSQLString($_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\t\t";
             }
         }
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             return true;
         }
     }
     return false;
 }
Пример #23
0
 /**
  * Get Resource Id
  *
  * @return integer
  * @access public
  */
 function getResource()
 {
     $mod = $this->getModule();
     if (is_a($mod, "CMS_module") && io::isPositiveInteger($this->_resource)) {
         return $mod->getResourceByID($this->_resource);
     } else {
         return false;
     }
 }
Пример #24
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     switch ($name) {
         case 'label':
             return $this->getLabel();
             break;
         case 'image':
         case 'imageZoom':
             if ($name == 'image') {
                 $fieldIndex = 0;
             } else {
                 $fieldIndex = 2;
             }
             if ($this->_subfieldValues[$fieldIndex]->getValue() && $parameters) {
                 @(list($x, $y) = explode(',', str_replace(';', ',', $parameters)));
                 if (io::isPositiveInteger($x) && $x < $this->getValue($name . 'Width') || io::isPositiveInteger($y) && $y < $this->getValue($name . 'Height')) {
                     //get module codename
                     $crop = $x && $y ? 1 : 0;
                     //get module codename
                     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                     //set location
                     $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
                     //resized image path
                     $pathInfo = pathinfo($this->_subfieldValues[$fieldIndex]->getValue());
                     $resizedImage = $pathInfo['filename'] . '-' . $x . '-' . $y . ($crop ? '-c' : '') . '.' . $pathInfo['extension'];
                     //resized image path
                     $resizedImagepathFS = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location . '/' . $resizedImage;
                     //if file already exists, no need to resize file send it
                     if (file_exists($resizedImagepathFS)) {
                         return $this->getValue('imagePath') . '/' . $resizedImage;
                     } else {
                         return CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . '/image-file' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?image=' . $this->_subfieldValues[$fieldIndex]->getValue() . '&amp;module=' . $moduleCodename . '&amp;x=' . $x . '&amp;y=' . $y . '&amp;crop=' . $crop . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? '&amp;location=' . $location : '');
                     }
                 }
             }
             if ($this->_subfieldValues[$fieldIndex]->getValue()) {
                 return $this->getValue('imagePath') . '/' . $this->_subfieldValues[$fieldIndex]->getValue();
             }
             return '';
             break;
         case 'imageHTML':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             //link content
             $img = '';
             if ($parameters) {
                 $img = $parameters;
             } elseif ($this->_subfieldValues[0]->getValue()) {
                 //bug 1380
                 $img = '<img src="' . $this->getValue('image') . '" alt="' . $this->_subfieldValues[1]->getValue() . '" />';
             }
             //add link to zoom if any
             if ($img && $this->_subfieldValues[2]->getValue()) {
                 $href = CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . "/" . self::OBJECT_IMAGE_POPUP_FILE . '?' . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? 'location=' . RESOURCE_DATA_LOCATION_EDITED . '&amp;' : '') . 'file=' . $this->_subfieldValues[2]->getValue() . '&amp;label=' . urlencode($this->_subfieldValues[1]->getValue()) . '&amp;module=' . $moduleCodename;
                 // file informations
                 $popup = OPEN_ZOOMIMAGE_IN_POPUP ? ' onclick="javascript:CMS_openPopUpImage(\'' . addslashes($href) . '\');return false;"' : '';
                 $img = '<a target="_blank" rel="atm-enlarge" href="' . $href . '"' . $popup . ' title="' . $this->_subfieldValues[1]->getValue() . '">' . $img . '</a>';
             }
             return $img;
             break;
         case 'imageLabel':
             return $this->_subfieldValues[1]->getValue();
             break;
         case 'imageName':
             return $this->_subfieldValues[0]->getValue();
             break;
         case 'imageZoomName':
             return $this->_subfieldValues[2]->getValue();
             break;
         case 'imagePath':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $altDomain = $this->getAlternativeDomain();
             // If we are serving a public file and there is an alternative domain set up, change the url
             if ($this->isPublic() && $altDomain) {
                 return $altDomain . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             } else {
                 return CMS_websitesCatalog::getCurrentDomain() . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             }
             break;
         case 'imageMaxWidth':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['maxWidth'] ? $params['maxWidth'] : '';
             break;
         case 'imageMaxHeight':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['maxHeight'] ? $params['maxHeight'] : '';
             break;
         case 'imageWidth':
         case 'imageHeight':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $imgPath = $path . "/" . $this->_subfieldValues[0]->getValue();
             $sizeX = $sizeY = 0;
             if (file_exists($imgPath)) {
                 list($sizeX, $sizeY) = @getimagesize($imgPath);
             }
             if ($name == 'imageWidth') {
                 return (string) $sizeX;
             } else {
                 return (string) $sizeY;
             }
             break;
         case 'imageZoomWidth':
         case 'imageZoomHeight':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $imgPath = $path . "/" . $this->_subfieldValues[2]->getValue();
             $sizeX = $sizeY = 0;
             if (file_exists($imgPath)) {
                 list($sizeX, $sizeY) = @getimagesize($imgPath);
             }
             if ($name == 'imageZoomWidth') {
                 return (string) $sizeX;
             } else {
                 return (string) $sizeY;
             }
             break;
         case 'imageSize':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $filesize = @filesize($path . "/" . $this->_subfieldValues[0]->getValue());
             if ($filesize !== false && $filesize > 0) {
                 //convert in MB
                 $filesize = round($filesize / 1048576, 2) . ' M';
             } else {
                 $filesize = '0 M';
             }
             return $filesize;
             break;
         case 'imageZoomSize':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $filesize = @filesize($path . "/" . $this->_subfieldValues[2]->getValue());
             if ($filesize !== false && $filesize > 0) {
                 //convert in MB
                 $filesize = round($filesize / 1048576, 2) . ' M';
             } else {
                 $filesize = '0 M';
             }
             return $filesize;
             break;
         case 'alternativeDomain':
             return $this->getAlternativeDomain();
         default:
             return parent::getValue($name, $parameters);
             break;
     }
 }
 protected function checkTagValues(&$tag, $requirements)
 {
     if (!is_array($requirements)) {
         $this->raiseError('Tag requirements must be an array');
         return false;
     }
     foreach ($requirements as $name => $requirementType) {
         //check parameter existence
         if ($requirementType['mandatory'] && !isset($tag['attributes'][$name])) {
             if ($this->_mode == self::CHECK_PARSING_MODE) {
                 $this->_parsingError .= "\n" . 'Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute';
                 return false;
             } else {
                 $this->raiseError('Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute');
                 return false;
             }
         } elseif (isset($tag['attributes'][$name])) {
             //if any, check value requirement
             $message = false;
             switch ($requirementType['value']) {
                 case 'alphanum':
                     if ($tag['attributes'][$name] != sensitiveIO::sanitizeAsciiString($tag['attributes'][$name], '', '_')) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be composed with alphanumeric caracters (0-9a-z_) : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'language':
                     if (isset($this->_parameters['module'])) {
                         $languages = CMS_languagesCatalog::getAllLanguages($this->_parameters['module']);
                     } else {
                         $languages = CMS_languagesCatalog::getAllLanguages();
                     }
                     if (!isset($languages[$tag['attributes'][$name]])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be a valid language code : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'object':
                     if (!sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], 9, -3))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object';
                     }
                     break;
                 case 'field':
                     if (strrpos($tag['attributes'][$name], 'fields') === false || !sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], strrpos($tag['attributes'][$name], 'fields') + 9, -2))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object field';
                     }
                     break;
                 case 'page':
                     if (!io::isPositiveInteger($tag['attributes'][$name])) {
                         // Assuming the structure {websitecodename:pagecodename}
                         $page = trim($tag['attributes'][$name], "{}");
                         if (strpos($page, ":") !== false) {
                             list($websiteCodename, $pageCodename) = explode(':', $page);
                             $website = CMS_websitesCatalog::getByCodename($websiteCodename);
                             if (!$website) {
                                 $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow Website codename : ' . $websiteCodename . '';
                             } else {
                                 $pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
                                 if (!$pageID) {
                                     $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow page codename ' . $pageCodename . ' in website : ' . $websiteCodename . '';
                                 }
                             }
                         } else {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must be an integer or use the format websitecodename:pagecodename';
                         }
                     } else {
                         if (!CMS_tree::getPageByID($tag['attributes'][$name])) {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow pageID : ' . $tag['attributes'][$name];
                         }
                     }
                     break;
                 default:
                     //check
                     if (!preg_match('#^' . $requirementType['value'] . '$#i', $tag['attributes'][$name])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must match expression \'' . $requirementType['value'] . '\' : ' . $tag['attributes'][$name];
                     }
                     break;
             }
             if ($message) {
                 if ($this->_mode == self::CHECK_PARSING_MODE) {
                     $this->_parsingError .= "\n<br />" . $message;
                     return false;
                 } else {
                     $this->raiseError($message);
                     return false;
                 }
             }
         }
     }
     return true;
 }
Пример #26
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     global $cms_language, $cms_user;
     $name = $name !== 0 ? $name : "0";
     switch ($name) {
         case 'ids':
             $ids = array();
             foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                 if (is_object($this->_subfieldValues[$subFieldID]) && io::isPositiveInteger($this->_subfieldValues[$subFieldID]->getValue())) {
                     $ids[] = $this->_subfieldValues[$subFieldID]->getValue();
                 }
             }
             return $ids;
             break;
         case 'labels':
             $labels = array();
             if (!$parameters) {
                 $parameters = ', ';
             }
             foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                 $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[$subFieldID]->getValue());
                 if (!$category->hasError()) {
                     $labels[] = io::htmlspecialchars($category->getLabel($cms_language));
                 }
             }
             return implode($labels, $parameters);
             break;
         case 'values':
             if ($parameters && is_object($cms_user)) {
                 $values = array();
                 $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                 foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                     if (is_object($this->_subfieldValues[$subFieldID]) && io::isPositiveInteger($this->_subfieldValues[$subFieldID]->getValue())) {
                         switch ($parameters) {
                             case 'none':
                                 if ($cms_user->hasModuleCategoryClearance($this->_subfieldValues[$subFieldID]->getValue(), CLEARANCE_MODULE_NONE, $moduleCodename)) {
                                     $values[$subFieldID] = $this->_subfieldValues[$subFieldID];
                                 }
                                 break;
                             case 'view':
                                 if ($cms_user->hasModuleCategoryClearance($this->_subfieldValues[$subFieldID]->getValue(), CLEARANCE_MODULE_VIEW, $moduleCodename)) {
                                     $values[$subFieldID] = $this->_subfieldValues[$subFieldID];
                                 }
                                 break;
                             case 'edit':
                                 if ($cms_user->hasModuleCategoryClearance($this->_subfieldValues[$subFieldID]->getValue(), CLEARANCE_MODULE_EDIT, $moduleCodename)) {
                                     $values[$subFieldID] = $this->_subfieldValues[$subFieldID];
                                 }
                                 break;
                             case 'manage':
                                 if ($cms_user->hasModuleCategoryClearance($this->_subfieldValues[$subFieldID]->getValue(), CLEARANCE_MODULE_MANAGE, $moduleCodename)) {
                                     $values[$subFieldID] = $this->_subfieldValues[$subFieldID];
                                 }
                                 break;
                             default:
                                 $values[$subFieldID] = $this->_subfieldValues[$subFieldID];
                                 break;
                         }
                     }
                 }
                 return $values;
             }
             return $this->_subfieldValues;
             break;
         case 'count':
             return sizeof($this->getValue('ids'));
             break;
         case 'start':
             $params = $this->getParamsValues();
             return $params['rootCategory'];
             break;
         default:
             if (sensitiveIO::isPositiveInteger($name) || $name === "0") {
                 switch ($parameters) {
                     case 'id':
                         return $this->_subfieldValues[$name]->getValue();
                         break;
                     case 'file':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[$name]->getValue());
                         if (!$category->hasError()) {
                             $file = $category->getFile($cms_language);
                             if ($file) {
                                 //get module codename
                                 $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                                 return PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_PUBLIC . '/' . $file;
                             }
                         }
                         return '';
                         break;
                     case 'categorydesc':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[$name]->getValue());
                         if (!$category->hasError()) {
                             return $category->getDescription($cms_language);
                         }
                         return '';
                         break;
                     case 'categorytxtdesc':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[$name]->getValue());
                         if (!$category->hasError()) {
                             return io::htmlspecialchars(strip_tags($category->getDescription($cms_language)));
                         }
                         return '';
                         break;
                     case 'label':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[$name]->getValue());
                         if (!$category->hasError()) {
                             return io::htmlspecialchars($category->getLabel($cms_language));
                         }
                         return '';
                         break;
                     case 'iconPath':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[$name]->getValue());
                         if (!$category->hasError()) {
                             $iconPathFS = $category->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true);
                             $iconPathWR = CMS_websitesCatalog::getCurrentDomain() . $category->getIconPath(true, PATH_RELATIVETO_WEBROOT, true);
                             if ($iconPathFS && file_exists($iconPathFS) && is_file($iconPathFS) && $iconPathWR) {
                                 return $iconPathWR;
                             }
                         }
                         return '';
                         break;
                     case 'iconHTML':
                         $iconPath = $this->getValue($name, 'iconPath');
                         if ($iconPath) {
                             $iconLabel = $this->getValue($name, 'label');
                             return '<img src="' . $iconPath . '" alt="" title="' . SensitiveIO::sanitizeHTMLString($iconLabel) . '" />';
                         }
                         return '';
                         break;
                 }
             } else {
                 switch ($name) {
                     case 'label':
                         $category = isset($this->_subfieldValues[0]) ? CMS_moduleCategories_catalog::getByID($this->_subfieldValues[0]->getValue()) : '';
                         if (is_object($category) && !$category->hasError()) {
                             return io::htmlspecialchars($category->getLabel($cms_language));
                         }
                         return '';
                         break;
                     case 'id':
                         return $this->_subfieldValues[0]->getValue();
                         break;
                     case 'file':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[0]->getValue());
                         if (!$category->hasError()) {
                             $file = $category->getFile($cms_language);
                             if ($file) {
                                 //get module codename
                                 $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                                 return PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_PUBLIC . '/' . $file;
                             }
                         }
                         return '';
                         break;
                     case 'categorydesc':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[0]->getValue());
                         if (!$category->hasError()) {
                             return $category->getDescription($cms_language);
                         }
                         return '';
                         break;
                     case 'categorytxtdesc':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[0]->getValue());
                         if (!$category->hasError()) {
                             return io::htmlspecialchars(strip_tags($category->getDescription($cms_language)));
                         }
                         return '';
                         break;
                     case 'iconPath':
                         $category = CMS_moduleCategories_catalog::getByID($this->_subfieldValues[0]->getValue());
                         if (!$category->hasError()) {
                             $iconPathFS = $category->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true);
                             $iconPathWR = CMS_websitesCatalog::getCurrentDomain() . $category->getIconPath(true, PATH_RELATIVETO_WEBROOT, true);
                             if ($iconPathFS && file_exists($iconPathFS) && is_file($iconPathFS) && $iconPathWR) {
                                 return $iconPathWR;
                             }
                         }
                         return '';
                         break;
                     case 'iconHTML':
                         $iconPath = $this->getValue('iconPath');
                         if ($iconPath) {
                             $iconLabel = $this->getValue('label');
                             return '<img src="' . $iconPath . '" alt="" title="' . SensitiveIO::sanitizeHTMLString($iconLabel) . '" />';
                         }
                         return '';
                         break;
                     default:
                         return parent::getValue($name, $parameters);
                         break;
                 }
             }
             break;
     }
 }
Пример #27
0
 /**
  * Gets the internal link (a page or false if no link)
  *
  * @return CMS_page
  * @access public
  */
 function getInternalLinkPage()
 {
     if (io::isPositiveInteger($this->_internalLink)) {
         return CMS_tree::getPageByID($this->_internalLink);
     } else {
         return false;
     }
 }
Пример #28
0
 /**
  * Returns The URL of the current website, according to parameter or constant CURRENT_PAGE or the main domain URL if constant does not exists
  * Static function.
  *
  * @param mixed $currentPage : The current page id or CMS_page
  * @return string The current website URL
  * @access public
  */
 static function getCurrentDomain($currentPage = '')
 {
     static $domain;
     if (!isset($domain)) {
         $domain = '';
         if (io::isPositiveInteger($currentPage)) {
             $page = CMS_tree::getPageByID($currentPage);
         } elseif (is_object($currentPage)) {
             $page = $currentPage;
         } elseif (defined('CURRENT_PAGE') && io::isPositiveInteger(CURRENT_PAGE)) {
             $page = CMS_tree::getPageByID(CURRENT_PAGE);
         }
         if (isset($page) && is_object($page) && !$page->hasError()) {
             $domain = $page->getWebsite()->getURL();
             //check for HTTPS
             if ($page->isHTTPS() || defined('PAGE_SSL_MODE') && PAGE_SSL_MODE) {
                 $domain = str_ireplace('http://', 'https://', $domain);
             }
         }
         if (!$domain) {
             $domain = CMS_websitesCatalog::getMainURL();
         }
     }
     return $domain;
 }
Пример #29
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     if (in_array($name, array('fieldname', 'required', 'fieldID', 'value'))) {
         return parent::getValue($name, $parameters);
     }
     $params = $this->getParamsValues();
     if ($name == 'hasValue') {
         return $this->_subfieldValues[0]->getValue() ? true : false;
     }
     //oembed values : first, get size parameters
     @(list($width, $height) = explode(',', str_replace(';', ',', $parameters)));
     if (!io::isPositiveInteger($width)) {
         $width = '';
     }
     if (!io::isPositiveInteger($height)) {
         $height = '';
     }
     //load oembed object
     if (in_array($name, array('html', 'width', 'height'))) {
         //size specific values : get oembed object at queried size
         if (!isset($this->_oembedObjects[$width . '-' . $height])) {
             $this->_oembedObjects[$width . '-' . $height] = new CMS_oembed($this->_subfieldValues[0]->getValue(), $width, $height, $params['embedlyKey']);
         }
         $oembed = $this->_oembedObjects[$width . '-' . $height];
     } else {
         if ($this->_oembedObjects) {
             //load current oembed object
             $oembed = current($this->_oembedObjects);
         } else {
             $this->_oembedObjects[$width . '-' . $height] = new CMS_oembed($this->_subfieldValues[0]->getValue(), $width, $height, $params['embedlyKey']);
             $oembed = $this->_oembedObjects[$width . '-' . $height];
         }
     }
     if (!$oembed->hasProvider()) {
         return '';
     }
     if ($name == 'authorName') {
         $name = 'author_name';
     }
     if ($name == 'authorUrl') {
         $name = 'author_url';
     }
     if ($name == 'authorName') {
         $name = 'author_name';
     }
     if ($name == 'providerUrl') {
         $name = 'provider_url';
     }
     switch ($name) {
         case 'html':
             return $oembed->getHTML(array('class' => 'atm-embed'));
             break;
         case 'thumb':
             return $oembed->getThumbnail(array('class' => 'atm-thumb-embed'));
             break;
         case 'providerName':
             return io::htmlspecialchars($oembed->getProviderName());
             break;
         case 'url':
             return $this->_subfieldValues[0]->getValue();
             break;
         case 'datas':
             return $oembed->getDatas();
             break;
         default:
             return io::htmlspecialchars($oembed->getData($name));
             break;
     }
 }
Пример #30
0
if (!$cms_user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_EDIT)) {
    CMS_grandFather::raiseError('User has no edit management rights on standard module ...');
    $view->setContent($rowsDatas);
    $view->show();
}
$skipSearch = false;
if (!$items) {
    $rowIds = array();
    if ($pageId) {
        //filter by page if needed
        $rowIds = CMS_rowsCatalog::getRowsByPage($pageId);
        if (!$rowIds) {
            $skipSearch = true;
        }
    }
    if (io::isPositiveInteger($keyword)) {
        //filter by id
        $rowIds = array($keyword);
        $keyword = '';
    }
    if ($module) {
        //filter by module
        $ids = CMS_rowsCatalog::getByModules(array($module), false, false);
        $rowIds = $rowIds ? array_intersect($rowIds, $ids) : $ids;
        if (!$rowIds) {
            $skipSearch = true;
        }
    }
} else {
    $rowIds = $items;
}