/** * Get array of contacts data by Email * * @param string $data * @return array of CMS_profile_user * @access public */ static function getByEmail($data) { if (!SensitiveIO::isValidEmail($data)) { CMS_grandFather::raiseError('$data must be a valid email : ' . $data); return array(); } $aUsers = array(); //create the request to look for the data $sql = 'select `id_cd` from `contactDatas` where `email_cd` = "' . sensitiveIO::sanitizeSQLString($data) . '"'; //launching the request $q = new CMS_query($sql); //checking if ok and looping on results if (!$q->hasError()) { while (($oTmpUserId = $q->getValue("id_cd")) !== false) { //creating the user and filling the data $oTmpUser = CMS_profile_usersCatalog::getByID($oTmpUserId); if (!$oTmpUser->hasError()) { $oTmpUser->getContactData(); if (!$oTmpUser->hasError()) { $aUsers[] = $oTmpUser; } } } unset($oTmpUser, $oTmpUserId); } return $aUsers; }
/** * Set the script informations. * * @return boolean true on success, false on failure * @access public */ function setParameters($module, $parameters) { if (!$this->_scriptName) { return false; } $sql = "\n\t\t\tupdate\n\t\t\t\tscriptsStatuses\n\t\t\tset\n\t\t\t\tmodule_ss='" . sensitiveIO::sanitizeSQLString($module) . "',\n\t\t\t\tparameters_ss='" . sensitiveIO::sanitizeSQLString($parameters) . "'\n\t\t\twhere\n\t\t\t\tscriptName_ss='" . $this->_scriptName . "'"; $q = new CMS_query($sql); return true; }
/** * get HTML admin (used to enter object values in admin) * * @param integer $fieldID, the current field id (only for poly object compatibility) * @param CMS_language $language, the current admin language * @param string prefixname : the prefix to use for post names * @return string : the html admin * @access public */ function getHTMLAdmin($fieldID, $language, $prefixName) { //get module codename $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //is this field mandatory ? $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : ''; $desc = $this->getFieldDescription($language); if (POLYMOD_DEBUG) { $values = array(); foreach (array_keys($this->_subfieldValues) as $subFieldID) { if (is_object($this->_subfieldValues[$subFieldID])) { $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50); } } $desc .= $desc ? '<br />' : ''; $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>'; foreach ($values as $subFieldID => $value) { $desc .= '<li>' . $subFieldID . ' : ' . $value . '</li>'; } $desc .= '</ul></span>'; } $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language); $ids = 'oembed-' . md5(mt_rand() . microtime()); $oembedURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/oembed.php'; $loadingURL = PATH_ADMIN_IMAGES_WR . '/loading-old.gif'; $params = $this->getParamsValues(); $fields = array(); $fields[] = array('fieldLabel' => '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($language->getMessage(self::MESSAGE_OBJECT_OEMBED_MEDIA_URL_DESC, false, MOD_POLYMOD_CODENAME)) . '">' . $language->getMessage(self::MESSAGE_OBJECT_OEMBED_MEDIA_URL, false, MOD_POLYMOD_CODENAME) . '</span>', 'xtype' => 'textfield', 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_0]', 'value' => $this->_subfieldValues[0]->getValue() ? sensitiveIO::decodeEntities($this->_subfieldValues[0]->getValue()) : '', 'enableKeyEvents' => true, 'listeners' => array('blur' => array('fn' => sensitiveIO::sanitizeJSString('function(el){ /*call server for oembed HTML content*/ Ext.get(\'' . $ids . '-view\').update(\'<img src="' . $loadingURL . '" />\'); Automne.server.call({ url: \'' . $oembedURL . '\', scope: this, fcnCallback: function(response, options, htmlResponse){ Ext.get(\'' . $ids . '-view\').update(htmlResponse); }, params: { module: \'' . $moduleCodename . '\', url: el.getValue(), width: 600, height: 250, key: \'' . $params['embedlyKey'] . '\' } }); }', false, false), 'buffer' => 600))); $fields[] = array('xtype' => 'panel', 'border' => false, 'html' => '<div id="' . $ids . '-view" style="overflow:auto;text-align:center;">' . ($this->getValue('hasValue') ? $this->getValue('html', '600,250') : '') . '</div>'); $return = array(); $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'defaultType' => 'textfield', 'defaults' => array('anchor' => '97%', 'allowBlank' => !$this->_field->getValue('required')), 'items' => $fields); return $return; }
/** * Move the data of a resource from one data location to another. * May be used by every module, provided it respects the naming rules described in the modules HOWTO * * @param string $module, The module codename * @param integer $resourceID The DB ID of the resource whose data we want to move * @param string $locationFrom The starting location, among the available RESOURCE_DATA_LOCATION * @param string $locationTo The ending location, among the available RESOURCE_DATA_LOCATION * @param boolean $copyOnly If set to true, the deletion from the originating tables and dirs won't occur * @return boolean true on success, false on failure * @access public * @static */ function moveResourceData($module, $resourceID, $locationFrom, $locationTo, $copyOnly = false) { //get all datas locations $locations = CMS_resource::getAllDataLocations(); if (!in_array($locationFrom, $locations)) { CMS_grandFather::raiseError("LocationFrom is not a valid location : " . $locationFrom); return false; } if (!in_array($locationTo, $locations)) { CMS_grandFather::raiseError("LocationTo is not a valid location : " . $locationTo); return false; } if (!sensitiveIO::IsPositiveInteger($resourceID)) { CMS_grandFather::raiseError("ResourceID must be a positive integer : " . $resourceID); return false; } //first move DB datas $tables_prefixes = array('mod_subobject_date_', 'mod_subobject_integer_', 'mod_subobject_string_', 'mod_subobject_text_'); foreach ($tables_prefixes as $table_prefix) { //delete all in the destination table and insert new ones if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) { $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID='" . $resourceID . "'\n\t\t\t\t"; $q = new CMS_query($sql); $sql = "\n\t\t\t\t\treplace into\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tobjectID='" . $resourceID . "'\n\t\t\t\t"; $q = new CMS_query($sql); } if (!$copyOnly) { //delete from the starting table $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID='" . $resourceID . "'\n\t\t\t\t"; $q = new CMS_query($sql); } } //second, move the files $locationFromDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY); //cut here if the locationFromDir doesn't exists. That means the module doesn't have files if (!$locationFromDir->exists()) { return true; } if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) { $locationToDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY); //cut here if the locationToDir doesn't exists. if (!$locationToDir->exists()) { CMS_grandFather::raiseError("LocationToDir does not exists : " . PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo); return false; } //delete all files of the locationToDir $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo . '/r' . $resourceID . '_*', GLOB_NOSORT); if (is_array($files)) { foreach ($files as $file) { if (!CMS_file::deleteFile($file)) { $this->raiseError("Can't delete file " . $file); return false; } } } //then copy or move them to the locationToDir $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT); if (is_array($files)) { foreach ($files as $file) { $to = str_replace('/' . $locationFrom . '/', '/' . $locationTo . '/', $file); if ($copyOnly) { if (!CMS_file::copyTo($file, $to)) { $this->raiseError("Can't copy file " . $file . " to " . $to); return false; } } else { if (!CMS_file::moveTo($file, $to)) { $this->raiseError("Can't move file " . $file . " to " . $to); return false; } } //then chmod new file CMS_file::chmodFile(FILES_CHMOD, $to); } } } else { //then get all files of the locationFromDir $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT); if (is_array($files)) { foreach ($files as $file) { if (!CMS_file::deleteFile($file)) { $this->raiseError("Can't delete file " . $file); return false; } } } } return true; }
$view->setContent($datas); $edited = true; } else { CMS_grandFather::raiseError('Can\'t get row type ' . $rowId . ' from clientspace ' . $cs . ' of page ' . $cms_page->getID() . ' with row id ' . $rowTag); $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT)); } } else { CMS_grandFather::raiseError('Can\'t get block class type ' . $blockClass . ' to update content'); $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT)); } break; default: CMS_grandFather::raiseError('Unknown action ' . $action . ' to do for page ' . $currentPage); $view->show(); break; } //set user message if any if (isset($cms_message) && $cms_message) { $view->setActionMessage($cms_message); } //Eval PHP content if any $content = $view->getContent(); if (io::strpos($content, '<?php') !== false) { ob_start(); $content = sensitiveIO::evalPHPCode($content); $return = ob_get_clean(); $content = $return . $content; //set datas as returned content $view->setContent($content); } $view->show();
/** * Sort and limit found ids by orders and limit clauses * This method limit results to existant objects too * * @access private * @return array of object ids sorted */ protected function _sortIds() { $statusSuffix = $this->_public ? "_public" : "_edited"; $ids = array(); if ($this->_orderConditions) { //reverse order conditions (needed to get natural order) $orderConditions = array_reverse($this->_orderConditions, true); //loop on each order conditions foreach ($orderConditions as $type => $value) { $sql = ''; if (!isset($value['direction']) || !$value['direction']) { $value['direction'] = 'asc'; } if (!isset($value['operator']) || !$value['operator']) { $value['operator'] = ''; } $direction = $value['direction']; $operator = $value['operator']; //add previously found ids to where clause if (is_array($this->_resultsIds) && $this->_resultsIds) { //update tmp table with found ids $this->_updateTmpList($this->_resultsIds); $where = ' and objectID in (' . $this->_getSQLTmpList() . ')'; } else { $where = ''; } switch ($type) { case "publication date after": // Date start // Date start case "publication date before": // Date start // Date start case "publication date start": // Date start $sql = "\n\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . ",\n\t\t\t\t\t\t\t\t\tresources,\n\t\t\t\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\tobjectFieldID = '0'\n\t\t\t\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\torder by publicationDateStart_rs " . $direction; break; case "publication date end": // Date end $sql = "\n\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . ",\n\t\t\t\t\t\t\t\t\tresources,\n\t\t\t\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\tobjectFieldID = '0'\n\t\t\t\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\torder by publicationDateEnd_rs " . $direction; break; case 'objectID': $ids = $ids ? $ids : $this->_resultsIds; ksort($ids, SORT_NUMERIC); $ids = $direction == 'asc' ? $ids : array_reverse($ids, true); break; case 'itemsOrdered': $orderedIds = $direction == 'asc' ? $this->_orderConditions['itemsOrdered']['order'] : array_reverse($this->_orderConditions['itemsOrdered']['order'], true); $ids = array_intersect($orderedIds, $ids ? $ids : $this->_resultsIds); unset($orderedIds); break; case 'random': $tmpIds = $ids ? $ids : $this->_resultsIds; shuffle($tmpIds); $ids = array(); foreach ($tmpIds as $id) { $ids[$id] = $id; } break; case "relevance": //this order condition is replaced by an itemsOrdered order at the end of _getIds method break; default: if (sensitiveIO::isPositiveInteger($type)) { if (!isset($this->_fieldsDefinitions[$type]) || !is_object($this->_fieldsDefinitions[$type])) { //get object fields definition $this->_fieldsDefinitions = CMS_poly_object_catalog::getFieldsDefinition($this->_object->getID()); } if (isset($this->_fieldsDefinitions[$type])) { //get type object for field $objectField = $this->_fieldsDefinitions[$type]->getTypeObject(); $operator = isset($operator) ? $operator : ''; $sql = $objectField->getFieldOrderSQL($type, $direction, $operator, $where, $this->_public); } else { $this->raiseError('Unknown field ' . $type . ' to use as order with value ' . print_r($value, true)); } } break; } if ($sql) { if (isset($ids) && $ids) { $sql .= " , field(objectID, " . implode(',', array_reverse($ids)) . ") desc "; } $q = new CMS_query($sql); $orderedIds = array(); if (!$q->hasError()) { //save ordered ids while ($id = $q->getValue('objectID')) { $orderedIds[$id] = $id; } } $ids = $orderedIds; } } } else { $ids = $this->_resultsIds; } //check for results existance in objects datas tables if ($ids) { //update tmp table with found ids $this->_updateTmpList($ids); $where = ' objectID in (' . $this->_getSQLTmpList() . ')'; $sql = "\n\t\t\t\tselect\n\t\t\t\t\tdistinct objectID\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_text" . $statusSuffix . "\n\t\t\t\twhere\n\t\t\t\t\t{$where}\n\t\t\t\tunion distinct\n\t\t\t\tselect\n\t\t\t\t\tdistinct objectID\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_integer" . $statusSuffix . "\n\t\t\t\twhere\n\t\t\t\t\t{$where}\n\t\t\t\tunion distinct\n\t\t\t\tselect\n\t\t\t\t\tdistinct objectID\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_string" . $statusSuffix . "\n\t\t\t\twhere\n\t\t\t\t\t{$where}\n\t\t\t\tunion distinct\n\t\t\t\tselect\n\t\t\t\t\tdistinct objectID\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_date" . $statusSuffix . "\n\t\t\t\twhere\n\t\t\t\t\t{$where}\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows() != count($ids)) { $foundIds = $q->getAll(PDO::FETCH_COLUMN, 0); if ($foundIds) { $ids = array_intersect($ids, $foundIds); //update count of results $this->_numRows = sizeof($ids); } else { $ids = array(); $this->_numRows = 0; } } } //Limit results if needed if ($ids && $this->_numRows > 0 && $this->_itemsPerPage > 0) { $ids = array_slice($ids, $this->_page * $this->_itemsPerPage, $this->_itemsPerPage, true); } return $ids; }
/** * Get : a full XHTML a tag * * @param string $module If false, only returns the filename * @param string $dataLocation Where does the data lies ? @see CMS_resource constants * @param string $attrs, any attributes to append into A tag * @return string, the XHTML Tag * @access public */ function getHTML($label = false, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $attrs = false, $hrefOnly = false) { if ($label) { $this->_label = $label; } // Building href $s = ''; $href = ''; $onClick = ''; switch ($this->_linkType) { case RESOURCE_LINK_TYPE_INTERNAL: // Get internal page URL switch ($dataLocation) { case RESOURCE_DATA_LOCATION_PUBLIC: case RESOURCE_DATA_LOCATION_EDITED: default: if (sensitiveIO::isPositiveInteger($this->_internalLink) && ($href = CMS_tree::getPageValue($this->_internalLink, 'url'))) { $href = PATH_PAGES_WR && strpos($href, PATH_PAGES_WR) !== false || stripos($href, 'http') !== false ? $href : PATH_PAGES_WR . $href; } break; } // Set a popup link, not a trivial link if (isset($this->_popup['width']) && isset($this->_popup['height']) && $this->_popup['width'] > 0 && $this->_popup['height'] > 0) { $onClick = "javascript:CMS_openPopUpPage('" . $href . "', 'popup_page', " . $this->_popup['width'] . ", " . $this->_popup['height'] . ");return false;"; } break; case RESOURCE_LINK_TYPE_EXTERNAL: $href = io::htmlspecialchars($this->_externalLink); $href = str_replace('&', '&', $href); if (strtolower(substr($href, 0, 4)) != 'http') { $href = 'http://' . $href; } // Set a popup link, not a trivial link if (isset($this->_popup['width']) && $this->_popup['width'] > 0 && isset($this->_popup['height']) && $this->_popup['height'] > 0) { $onClick = "javascript:CMS_openPopUpPage('" . $href . "', 'external', " . $this->_popup['width'] . ", " . $this->_popup['height'] . ");return false;"; } break; case RESOURCE_LINK_TYPE_FILE: if (is_file($this->getFileLink(true, $module, $dataLocation, PATH_RELATIVETO_FILESYSTEM))) { $href = $this->getFileLink(true, $module, $dataLocation, PATH_RELATIVETO_WEBROOT); // Set a popup link, not a trivial link if (isset($this->_popup['width']) && $this->_popup['width'] > 0 && isset($this->_popup['height']) && $this->_popup['height'] > 0) { $onClick = "javascript:CMS_openPopUpPage('" . $href . "', 'file', " . $this->_popup['width'] . ", " . $this->_popup['height'] . ");return false;"; } } break; } if ($hrefOnly) { return $href; } if ($this->_target) { $target = ' target="' . $this->_target . '"'; } // Get onClick if ($onClick != '') { $onClick = ' onClick="' . $onClick . '"'; } // Return Link if (trim($href) != '') { if (!$attrs) { $attrs = $this->getAttributesString(); } $attrs = ' ' . trim($attrs); $s = '<a href="' . $href . '"' . $onClick . $target . $attrs . '>' . $this->_label . '</a>'; } return $s; }
function getJSonDescription($user, $cms_language, $withDefinition = false) { //get websites $websites = CMS_websitesCatalog::getAll(); $hasPages = $this->hasPages(); $websitesList = ''; $websitesDenied = $this->getWebsitesDenied(); foreach ($websites as $id => $website) { if (!isset($websitesDenied[$id])) { $websitesList .= $websitesList ? ', ' : ''; $websitesList .= $website->getLabel(); } } /*$shortdesc = sensitiveIO::ellipsis($this->getDescription(), 60); if ($shortdesc != nl2br($this->getDescription())) { $shortdesc = '<span class="atm-help" ext:qtip="'.nl2br(io::htmlspecialchars($this->getDescription())).'">'.$shortdesc.'</span>'; } $shortdesc = $shortdesc ? $shortdesc.'<br />' : '';*/ $mediumdesc = sensitiveIO::ellipsis($this->getDescription(), 200); if ($mediumdesc != $this->getDescription()) { $mediumdesc = '<span class="atm-help" ext:qtip="' . nl2br(io::htmlspecialchars(strip_tags($this->getDescription()))) . '">' . nl2br(io::htmlspecialchars($mediumdesc)) . '</span>'; } else { $mediumdesc = io::htmlspecialchars($mediumdesc); } $mediumdesc = $mediumdesc ? $mediumdesc . '<br />' : ''; //append template definition if needed $definitionDatas = $withDefinition ? $this->getDefinition() : ''; if ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) { $edit = array('url' => 'template.php', 'params' => array('template' => $this->getID())); } else { $edit = false; } return array('id' => $this->getID(), 'label' => $this->getLabel(), 'type' => $cms_language->getMessage(self::MESSAGE_DESC_TEMPLATE), 'image' => PATH_TEMPLATES_IMAGES_WR . '/' . ($this->getImage() ? $this->getImage() : 'nopicto.gif'), 'groups' => implode(', ', $this->getGroups()), 'websites' => $websitesList, 'desc' => io::htmlspecialchars($this->getDescription()), 'filter' => $this->getLabel() . ' ' . implode(', ', $this->getGroups()), 'description' => '<div' . (!$this->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . (PATH_TEMPLATES_IMAGES_WR . '/' . ($this->getImage() ? $this->getImage() : 'nopicto.gif')) . '" style="float:left;margin-right:3px;width:80px;" />' . $mediumdesc . $cms_language->getMessage(self::MESSAGE_DESC_WEBSITES) . ' <strong>' . $websitesList . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_GROUPS) . ' <strong>' . ($this->getGroups() ? implode(', ', $this->getGroups()) : $cms_language->getMessage(self::MESSAGE_DESC_NONE)) . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_ACTIVE) . ' <strong>' . ($this->isUseable() ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_USED) . ' <strong>' . ($hasPages ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong>' . ($hasPages ? ' - <a href="#" onclick="Automne.view.search(\'template:' . $this->getID() . '\');return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_SEE) . '</a>' . ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) ? ' / <a href="#" onclick="Automne.server.call(\'templates-controler.php\', \'\', {templateId:' . $this->getID() . ', action:\'regenerate\'});return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_REGENERATE) . '</a>' : '') . ' ' . $cms_language->getMessage(self::MESSAGE_DESC_PAGES) : '') . '<br />' . $cms_language->getMessage(self::MESSAGE_DESC_XML_FILE) . ': <strong>' . ($this->getDefinitionFile() ? $this->getDefinitionFile() : $cms_language->getMessage(self::MESSAGE_DESC_NONE)) . '</strong>' . '<br class="x-form-clear" />' . '</div>', 'activated' => $this->isUseable() ? true : false, 'used' => $hasPages, 'definition' => $definitionDatas, 'edit' => $edit); }
/** * Get the recursive HTML display for a recursivelinks, if it passes the condition of course. * * @param CMS_page $parsedPage The page in which the linx tag is * @param integer $level The current level of recursivity * @param multidimentionnal array $recursiveTree The tree to display * @param array $pages array of pages objects (indexed by id) * @param boolean $public Is the page data to show the public or edited one ? * @param array $lineage The lineage of the pages (used to see wich recursions need to be done in closed link display mode) * @return string The html of the recursive link * @access public */ function getRecursiveOutput(&$parsedPage, $level = 0, $recursiveTree, &$pages, $public, $lineage = array()) { $html = ''; if (is_array($recursiveTree) && $recursiveTree) { $rank = 1; $levelhtml = ''; foreach ($recursiveTree as $pageID => $subPages) { //get Page Object $page = $pages[$pageID]; //instanciate page if not exists as object if (!is_object($page) && sensitiveIO::isPositiveInteger($page)) { $page = CMS_tree::getPageByID($page); } $pagehtml = ''; //check if page pass the condition if (is_object($page) && (!$this->hasCondition() || $this->pagePassesConditions($parsedPage, $page, $public, $rank)) && (!$public || $public && $page->isUseable() && $page->getPublication() == RESOURCE_PUBLICATION_PUBLIC)) { //get pages infos $linkTitle = $page->getLinkTitle($public); $title = $page->getTitle($public); //set pages infos in html template $replace = array("{{title}}" => io::sanitizeHTMLString($linkTitle), "{{jstitle}}" => io::sanitizeHTMLString($linkTitle), "{{pagetitle}}" => io::sanitizeHTMLString($title), "{{jspagetitle}}" => io::sanitizeHTMLString($title), "{{desc}}" => io::sanitizeHTMLString($page->getDescription($public)), "{{href}}" => $page->getURL(), "{{id}}" => $page->getID(), "{{codename}}" => $page->getCodename($public), "{{number}}" => $rank - 1, "{{modulo}}" => ($rank - 1) % 2, "{{lvlClass}}" => "CMS_lvl" . ($level + 1), "{{currentClass}}" => $parsedPage->getID() == $page->getID() ? "CMS_current" : "", 'id="{{currentID}}"' => $parsedPage->getID() == $page->getID() ? 'id="CMS_current"' : ""); if (io::strpos($this->_htmlTemplate, '{{isParent}}') !== false) { //only if needed because getLineage require a lot of query $pagelineage = CMS_tree::getLineage($page->getID(), $parsedPage->getID(), false); $replace['class="{{isParent}}"'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'class="CMS_parent"' : ""; $replace['{{isParent}}'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'CMS_parent' : ""; $replace['id="{{isParent}}"'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'id="CMS_parent"' : ""; } if (io::strpos($this->_htmlTemplate, '{{website') !== false) { //only if needed because getWebsite require a lot of query $website = $page->getWebsite(); $replace['{{websitetitle}}'] = $website->getLabel(); $replace['{{websitecodename}}'] = $website->getCodename($public); } $pagehtml = str_replace(array_keys($replace), $replace, $this->_htmlTemplate); if ($level == 0 && ($this->_root === 'false' || !$this->_root)) { $pagehtml = str_replace(array_keys($replace), $replace, $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public, $lineage)); } else { //check if link is in open or closed mode if ($this->_mode == "open") { //if it is open mode recurse indefinitely (until end of tree) //then mark info of sublevels or not $replace = array("{{typeClass}}" => $subPages ? "CMS_sub" : "CMS_nosub", "{{sublevel}}" => $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public)); $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml); } else { //if it is 'close' mode recurse only for pages in current lineage $recurse = false; if (is_array($lineage)) { $recurse = in_array($page->getID(), $lineage) ? true : false; } //then mark info of sublevels or not and if level is open or not $sub = $recurse ? "CMS_open" : "CMS_sub"; $replace = array("{{typeClass}}" => $subPages ? $sub : "CMS_nosub", "{{sublevel}}" => $recurse ? $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public, $lineage) : ""); if (!$recurse) { //needed to update link targets which is used after to register watched links $it = new RecursiveArrayIterator($subPages); foreach ($it as $pageID => $element) { unset($pages[$pageID]); } } $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml); } } //add APPLICATION_ENFORCES_ACCESS_CONTROL php access checking if (APPLICATION_ENFORCES_ACCESS_CONTROL && $public) { $pagehtml = $this->_addSlashAroundPHPContent($pagehtml); $replace = array("<?php" => "';", "?>" => "echo '"); $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml); $pagehtml = '<?php if ($cms_user->hasPageClearance(' . $page->getID() . ', CLEARANCE_PAGE_VIEW)) {' . "\n" . 'echo \'' . $pagehtml . '\';' . "\n" . '}' . "\n" . '?>'; } $rank++; } else { //needed to update link targets which is used after to register watched links unset($pages[$pageID]); } $levelhtml .= $pagehtml; } if ($level == 0 && ($this->_root === 'false' || !$this->_root)) { $html = $levelhtml; } else { if ($levelhtml && io::strpos($this->_subleveltemplate, "{{sublevel}}") !== false) { $replace = array("{{sublevel}}" => $levelhtml, "{{lvlClass}}" => "CMS_lvl" . ($level + 1)); $html = str_replace(array_keys($replace), $replace, $this->_subleveltemplate); } else { $html = $levelhtml; } } } return $html; }
function checkCatId($catId) { return io::strpos($catId, 'cat') === 0 && sensitiveIO::isPositiveInteger(io::substr($catId, 3)); }
* * @package Automne * @subpackage admin * @author Sébastien Pauchet <*****@*****.**> */ define("ENABLE_HTML_COMPRESSION", false); require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; define('MESSAGE_PAGE_NO_LOGS', 1608); define("MESSAGE_PAGE_NO_SERVER_RIGHTS", 748); //CHECKS user has admin clearance if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { CMS_grandFather::raiseError('User has no administration rights'); echo $cms_language->getMessage(MESSAGE_PAGE_NO_SERVER_RIGHTS); exit; } $date = sensitiveIO::request('date'); $errorFile = ''; $gzip = false; $now = new CMS_date(); $now->setNow(true); $requestedDate = new CMS_date(); $requestedDate->setFormat($cms_language->getDateFormat()); $requestedDate->setLocalizedDate($date); if (!$requestedDate->hasError()) { if (CMS_date::compare($requestedDate, $now, '==')) { $errorFile = PATH_MAIN_FS . '/' . CMS_grandFather::ERROR_LOG; } else { $gzip = true; $requestedDate->moveDate('+1 day'); $errorFile = PATH_LOGS_FS . '/' . CMS_grandFather::ERROR_LOG . '-' . $requestedDate->getLocalizedDate('Y-m-d') . '.gz'; }
* * @package Automne * @subpackage admin * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; //load interface instance $view = CMS_view::getInstance(); //set default display mode for this page $view->setDisplayMode(CMS_view::SHOW_JSON); //This file is an admin file. Interface must be secure $view->setSecure(); $keyword = sensitiveIO::request('keyword'); $elements = sensitiveIO::request('elements', 'is_array', array()); $start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0); $limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', 0); $results = $scores = array(); //Users search if (in_array('users', $elements)) { $usersResults = CMS_profile_usersCatalog::search($keyword, '', '', 'score', 'desc', 0, 0, false, false, $usersScore); if ($usersResults) { foreach ($usersResults as $resultId) { if (isset($usersScore[$resultId])) { $scores[$usersScore[$resultId]][] = array('users', $resultId); } else { $scores[0][] = array('users', $resultId); } } //pr('Users :'); //pr($usersResults); //pr($rowsScore);
// +----------------------------------------------------------------------+ // // $Id: server-scripts-controler.php,v 1.6 2010/03/08 16:41:21 sebastien Exp $ /** * PHP controler : Receive actions on server * Used accross an Ajax request to process one server action * * @package Automne * @subpackage admin * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; //Controler vars $action = sensitiveIO::request('action', array('regenerate-all', 'regenerate-tree', 'regenerate-pages', 'restart-scripts', 'stop-scripts', 'clear-scripts')); $page = sensitiveIO::request('page', 'sensitiveIO::isPositiveInteger'); $pages = sensitiveIO::request('pages'); define("MESSAGE_PAGE_NO_SCRIPTS_RIGHTS", 794); define("MESSAGE_ACTION_ALL_PAGES_SUBMITED", 795); define("MESSAGE_ACTION_N_PAGES_SUBMITED", 796); define("MESSAGE_ACTION_N_PAGES_REGENERATED", 797); define("MESSAGE_ERROR_NO_PAGES_FOUND", 798); define("MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR", 1602); //load interface instance $view = CMS_view::getInstance(); //set default display mode for this page $view->setDisplayMode(CMS_view::SHOW_RAW); //This file is an admin file. Interface must be secure $view->setSecure(); //CHECKS user has scripts admin clearance if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES)) { CMS_grandFather::raiseError('User has no regeneration rights');
/** * Set soap values * * @param integer $fieldID The field ID * @param $domdocument XML values to set * @param $itemId the ID of the polyobject item, if any (necessary for some fields (image, file, etc...) * @return boolean true or false * @access public */ function setSoapValues($fieldID, $domdocument, $itemId = '') { $view = CMS_view::getInstance(); $fieldValues = array(); // subfield foreach ($domdocument->childNodes as $childNode) { if ($childNode->nodeType == XML_ELEMENT_NODE) { switch ($childNode->tagName) { case 'subfield': //<subfield id="{int}" [name="{string}"] type="int|string|date|text|object|binary|category|user|group"> $subFieldId = $childNode->getAttribute('id'); if (!sensitiveIO::isPositiveInteger($subFieldId) && $subFieldId != 0) { $view->addError('Missing or invalid attribute id for subfield tag'); return false; } if (!isset($this->_subfields[$subFieldId])) { $view->addError('Unknown field id ' . $fieldId . ' for object ' . $this->_objectID); return false; } $fieldValues[$fieldID . '_' . $subFieldId] = trim(io::strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8' ? utf8_decode($childNode->nodeValue) : $childNode->nodeValue); break; case 'object': //TODO break; default: $view->addError('Unknown xml tag ' . $childNode->tagName . ' to process.'); return false; break; } } else { if ($childNode->nodeType == XML_TEXT_NODE && trim($childNode->nodeValue)) { $view->addError('Unknown xml content tag ' . $childNode->nodeValue . ' to process.'); return false; } } } if (!$this->checkMandatory($fieldValues, '')) { $view->addError('Error of mandatory values for field ' . $fieldID); return false; } elseif (!$this->setValues($fieldValues, '', false, $itemId)) { return false; } return true; }
require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; //load interface instance $view = CMS_view::getInstance(); //set default display mode for this page $view->setDisplayMode(CMS_view::SHOW_JSON); //This file is an admin file. Interface must be secure $view->setSecure(); //get search vars $search = sensitiveIO::request('search'); $letter = sensitiveIO::request('letter'); $sort = sensitiveIO::request('sort'); $dir = sensitiveIO::request('dir'); $start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0); $limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', CMS_session::getRecordsPerPage()); $userId = sensitiveIO::request('userId', 'sensitiveIO::isPositiveInteger'); $filter = sensitiveIO::request('filter') ? true : false; $groupsDatas = array(); $groupsDatas['groups'] = array(); if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITUSERS)) { CMS_grandFather::raiseError('User has no users management rights ...'); $view->setContent($groupsDatas); $view->show(); } //load user's groups if any if ($userId) { $userGroups = CMS_profile_usersGroupsCatalog::getGroupsOfUser($userId, true); } else { $userGroups = array(); } if ($userId && $filter) { //search users
/** * Get form field by it's name * * @param string $fieldName : the form field name to get * @param boolean $outputobjects : return array of CMS_forms_field instead of array of ids (default : false) * @param boolean $withDesactivedFields : add desactived fields to returned list (default : false) * @access public * @return array of CMS_forms_field */ function getFieldByName($fieldName, $outputobjects = false, $withDesactivedFields = false) { $sql = "\n\t\t\tselect\n\t\t\t\tid_fld as id\n\t\t\tfrom\n\t\t\t\tmod_cms_forms_fields\n\t\t\twhere\n\t\t\t\tform_fld='" . $this->getID() . "'\n\t\t\t\tand name_fld='" . sensitiveIO::sanitizeSQLString($fieldName) . "'\n\t\t"; if (!$withDesactivedFields) { $sql .= " and active_fld = '1'"; } $q = new CMS_query($sql); if ($q->getNumRows()) { if ($outputobjects) { return new CMS_forms_field($q->getValue('id')); } else { return $q->getValue('id'); } } }
/** * Get the page content for the specified visualization mode and language. * * @return string The content of the page. * @access public */ function getContent(&$language, $visualizationMode = false) { if (!$language instanceof CMS_language || !SensitiveIO::isInSet($visualizationMode, CMS_page::getAllVisualizationModes())) { $this->raiseError("Language must be a valid language and visualization mode in the set of possibles"); return false; } $this->_checkTemplate(); if ($this->_template) { //get parsed content definition from template (including CS block contents) $definition = $this->_template->getContent($language, $this, $visualizationMode); //instanciate modules treatments for page content tags $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGECONTENT_TAGS, $visualizationMode, $this); $modulesTreatment->setTreatmentParameters(array("language" => $language)); $modulesTreatment->setDefinition($definition); $content = $modulesTreatment->treatContent(true); //instanciate modules treatments for page header tags $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGEHEADER_TAGS, $visualizationMode, $this); $modulesTreatment->setTreatmentParameters(array("language" => $language, 'replaceVars' => true)); $modulesTreatment->setDefinition($content); $content = $modulesTreatment->treatContent(true); /*if ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE) { //eval() the PHP code $content = sensitiveIO::evalPHPCode($content); return $content; }*/ //include modules header codes on top of output file $modulesCodes = new CMS_modulesCodes(); $headerInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_PAGECONTENT_HEADER_CODE, $visualizationMode, $this); if (is_array($headerInclude) && $headerInclude) { $content = implode("\n", $headerInclude) . $content; } //include modules footers codes on bottom of output file $footerInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_PAGECONTENT_FOOTER_CODE, $visualizationMode, $this); if (is_array($footerInclude) && $footerInclude) { $content .= implode("\n", $footerInclude); } //replace {{pageID}} tag in all page content. $content = str_replace('{{pageID}}', $this->getID(), $content); if ($visualizationMode != PAGE_VISUALMODE_HTML_PUBLIC && $visualizationMode != PAGE_VISUALMODE_PRINT) { //eval() the PHP code $content = sensitiveIO::evalPHPCode($content); } return $content; } else { return false; } }
$file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file']); $fileDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension()); } else { $fileDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => ''); } $filePath = $fileDatas['filepath']; $fileDatas = sensitiveIO::jsonEncode($fileDatas); if ($rawDatas['enlargedFile'] && file_exists(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['enlargedFile'])) { $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['enlargedFile']); $zoomDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension()); } else { $zoomDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => ''); } $zoomDatas = sensitiveIO::jsonEncode($zoomDatas); $linkDatas = sensitiveIO::sanitizeJSString($rawDatas['externalLink']); $imageLabel = sensitiveIO::sanitizeJSString($rawDatas["label"]); $jscontent = <<<END \tvar blockWindow = Ext.getCmp('{$winId}'); \t//set window title \t \tblockWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_EDIT_IMG)}'); \t//set help button on top of page \tblockWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t blockWindow.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_WINDOW_IMG_INFO)}', \t\tdismissDelay:\t0 \t}); \t
if ($field->getValue('searchable')) { $objectType = $field->getTypeObject(); if (!method_exists($objectType, 'getListOfNamesForObject')) { $possibleTargets[] = $fieldID; } } } //get all search datas from requests $keywords = sensitiveIO::request('items_' . $object->getID() . '_kwrds', '', ''); $keywordsOptions = sensitiveIO::request('items_' . $object->getID() . '_kwrds_options', array('any', 'all', 'phrase', 'beginswith'), 'any'); $keywordsTarget = sensitiveIO::request('kwrds_target_' . $object->getID(), $possibleTargets, -1); $dateFrom = sensitiveIO::request('items_dtfrm', '', ''); $dateEnd = sensitiveIO::request('items_dtnd', '', ''); $sort = sensitiveIO::request('sort_' . $object->getID(), '', ''); $status = sensitiveIO::request('status_' . $object->getID(), '', ''); $direction = sensitiveIO::request('direction_' . $object->getID(), '', ''); // Set default session search options CMS_session::setSessionVar('items_' . $object->getID() . '_kwrds', $keywords); //CMS_session::setSessionVar('items_'.$object->getID().'_kwrds_options', $keywordsOptions); CMS_session::setSessionVar('kwrds_target_' . $object->getID(), $keywordsTarget); CMS_session::setSessionVar("items_dtfrm", $dateFrom); CMS_session::setSessionVar("items_dtnd", $dateEnd); CMS_session::setSessionVar('sort_' . $object->getID(), $sort); CMS_session::setSessionVar('status_' . $object->getID(), $status); CMS_session::setSessionVar('direction_' . $object->getID(), $direction); //Add all subobjects to search if any foreach ($objectFields as $fieldID => $field) { if (isset($fields[$fieldID])) { CMS_session::setSessionVar('items_' . $object->getID() . '_' . $fieldID, $fields[$fieldID]); } }
} else { CMS_grandFather::raiseError('Error, can\'t get block class : ' . $blockClass); $view->show(); } $maxFileSize = CMS_file::getMaxUploadFileSize('K'); if ($rawDatas['file'] && file_exists(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file'])) { $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file']); $fileDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension()); } else { $fileDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => ''); } $filePath = $fileDatas['filepath']; $fileDatas = sensitiveIO::jsonEncode($fileDatas); $flashvars = sensitiveIO::sanitizeJSString($rawDatas["flashvars"]); $params = sensitiveIO::sanitizeJSString($rawDatas["params"]); $attributes = sensitiveIO::sanitizeJSString($rawDatas["attributes"]); $jscontent = <<<END \tvar blockWindow = Ext.getCmp('{$winId}'); \t//set window title \tblockWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_EDIT_FLASH)}'); \t//set help button on top of page \tblockWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t blockWindow.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_WINDOW_INFO)}', \t\tdismissDelay:\t0 \t}); \t \t//create center panel
break; case 'order': if (sizeof($paramValue)) { foreach ($paramValue as $orderName => $orderValue) { // Order direction $orderName = trim($orderName, '()'); if ($paramValue && !$value['search'][$searchName][$paramType][$orderName]) { //mandatory ? $formok = false; } } } break; default: $paramType = trim($paramType, '()'); if (sensitiveIO::isPositiveInteger($paramType)) { if ($paramValue && !$value['search'][$searchName][$paramType]) { //mandatory ? $formok = false; } } break; } } } } } if (!$formok) { $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MANDATORY_FIELDS); } else { if (!$cms_block->writeToPersistence($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false, array("value" => $value))) {
foreach ($modules as $module) { if (!$module->isPolymod() && $module->getCodename() != MOD_STANDARD_CODENAME) { $modulesInfo .= '<li>' . $module->getLabel($cms_language); if (file_exists(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION')) { $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION'); } if ($module->getCodename() == 'mail' && file_exists(PATH_MODULES_FS . '/mailing/VERSION')) { $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/mailing/VERSION'); } $modulesInfo .= '</li>'; } } $modulesInfo .= '</ul>'; //Scripts content $content = $cms_language->getMessage(MESSAGE_PAGE_ABOUT_MESSAGE, array(AUTOMNE_VERSION, $lastUpdate, APPLICATION_DEFAULT_ENCODING, LIBXML_DOTTED_VERSION, $modulesInfo)); $content = sensitiveIO::sanitizeJSString($content); $jscontent = <<<END \tvar serverWindow = Ext.getCmp('{$winId}'); \t//set window title \tserverWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE)}'); \t//set help button on top of page \tserverWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t serverWindow.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_MESSAGE)}', \t\tdismissDelay:\t0 \t}); \t \t//create center panel
/** * Get the filename and optionnaly path of a file given its original name * Cleans the name and add the directory where files should reside (when page is un USERSPACE location) * * @param string $originalName The original name of the file * @param CMS_page &$page The page which contains the block * @param string &$clientspace The clientspace which contains the block * @param string &$row The row which contains the block * @param string &$block The block * @param boolean $withPath If false, only the filename will be returned * @param boolean $isEnlarged Is it the enlarged image we want the path of ? * @return string The full pathname * @access private */ function getFilePath($originalName, &$page, &$clientspace, &$row, &$block, $withPath = true, $isEnlarged = false) { $name = md5(mt_rand() . microtime()); $name .= SensitiveIO::sanitizeAsciiString($originalName); $name = "p" . $page->getID() . "_" . $name; if (io::strlen($name) > 255) { $name = sensitiveIO::ellipsis($name, 255, '-', true); } if ($withPath) { return PATH_MODULES_FILES_STANDARD_FS . "/edition/" . $name; } else { return $name; } }
/** * Get all form fields * * @param integer $formID : the form id for wanted fields * @param boolean $outputobjects : return array of CMS_forms_field instead of array of ids (default : false) * @param boolean $withDesactivedFields : add desactived fields to returned list (default : false) * @access public * @return array of CMS_forms_field */ function getAll($formID, $outputobjects = false, $withDesactivedFields = false) { if (!sensitiveIO::isPositiveInteger($formID)) { $this->raiseError("FormID must be a positive integer : " . $formID); return false; } $sql = "\n\t\t\tselect\n\t\t\t\tid_fld as id\n\t\t\tfrom\n\t\t\t\tmod_cms_forms_fields\n\t\t\twhere\n\t\t\t\tform_fld='" . $formID . "'\n\t\t"; if (!$withDesactivedFields) { $sql .= " and active_fld = '1'"; } $sql .= " order by order_fld asc"; $q = new CMS_query($sql); $return = array(); while ($id = $q->getValue('id')) { if ($outputobjects) { $return[$id] = new CMS_forms_field($id); } else { $return[$id] = $id; } } return $return; }
/** * set object Values * * @param array $values : the POST result values * @param string $prefixname : the prefix used for post names * @param boolean newFormat : new automne v4 format (default false for compatibility) * @param integer $objectID : the current object id. Must be set, but default is blank for compatibility with other objects * @return boolean true on success, false on failure * @access public */ function setValues($values, $prefixName, $newFormat = false, $objectID = '') { if (!sensitiveIO::isPositiveInteger($objectID)) { $this->raiseError('ObjectID must be a positive integer : ' . $objectID); return false; } //get module codename $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //create a sub prefix for CMS_dialog_href object $subPrefixName = 'href' . $prefixName . $this->_field->getID() . '_0'; //create object CMS_href & CMS_dialog_href $hrefDialog = new CMS_dialog_href(new CMS_href($this->_subfieldValues[0]->getValue()), $subPrefixName); if ($newFormat) { $hrefDialog->create($values[$subPrefixName], $moduleCodename, $objectID, $this->_field->getID()); if ($hrefDialog->hasError()) { return false; } $href = $hrefDialog->getHREF(); if (!$this->_subfieldValues[0]->setValue($href->getTextDefinition())) { return false; } $content = array('datas' => array('polymodFieldsValue[' . $subPrefixName . ']' => sensitiveIO::decodeEntities($this->_subfieldValues[0]->getValue()))); $view = CMS_view::getInstance(); $view->addContent($content); } else { //check for http:// if ($values[$subPrefixName . 'link_external'] && io::strpos($values[$subPrefixName . 'link_external'], 'http://') !== 0) { $values[$subPrefixName . 'link_external'] = 'http://' . $values[$subPrefixName . 'link_external']; } $hrefDialog->doPost($moduleCodename, $objectID, $this->_field->getID()); if ($hrefDialog->hasError()) { return false; } $href = $hrefDialog->getHREF(); if (!$this->_subfieldValues[0]->setValue($href->getTextDefinition())) { return false; } } return true; }
CMS_grandFather::raiseError('Error, user has no rights item ' . $itemId); $jscontent = "\n\t\tvar window = Ext.getCmp('{$winId}');\n\t\tif (window) {\n\t\t\twindow.close();\n\t\t}\n\t\tAutomne.message.popup({\n\t\t\tmsg: \t\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_ELEMENT_EDIT_RIGHTS_ERROR, array($itemLabel), MOD_POLYMOD_CODENAME)}',\n\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\tclosable: \t\t\tfalse,\n\t\t\ticon: \t\t\t\tExt.MessageBox.ERROR\n\t\t});"; $view->addJavascript($jscontent); $view->show(); } } else { //instanciate clean object (creation) $item = new CMS_poly_object($object->getID(), ''); } $winLabel = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_TITLE_MODULE, array($cms_module->getLabel($cms_language))) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE, array($object->getLabel($cms_language)), MOD_POLYMOD_CODENAME)); $fieldsObjects = $item->getFieldsObjects(); $itemFields = ''; foreach ($fieldsObjects as $fieldID => $aFieldObject) { $fieldAdmin = $item->getHTMLAdmin($fieldID, $cms_language, ''); if (is_array($fieldAdmin)) { $itemFields .= sensitiveIO::jsonEncode($fieldAdmin) . ','; } } //do some search and replace to allow use of js functions in returned code $itemFields = str_replace('"scope":"this"', '"scope":this', $itemFields); function replaceCallBack($parts) { return 'function(' . str_replace(array('\\"', '\\/'), array('"', '/'), $parts[1]) . '}'; } $itemFields = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $itemFields); //Append pub dates if object is a primary resource $saveAndValidate = ''; $saveIconCls = $saveTooltip = ''; if ($object->isPrimaryResource()) { if (!$item->getID()) { $dt = new CMS_date();
// // $Id: page-previsualization.php,v 1.5 2010/03/08 16:41:19 sebastien Exp $ /** * PHP page : page previsualization * Used to view the page edited data. * * @package Automne * @subpackage admin * @author Antoine Pouch <*****@*****.**> & * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; $currentPage = sensitiveIO::request('currentPage', 'sensitiveIO::isPositiveInteger', CMS_session::getPageID()); $draft = sensitiveIO::request('draft') ? true : false; //unset request to avoid it to have interaction with page code sensitiveIO::unsetRequest(array('draft', 'currentPage')); //CHECKS if (!SensitiveIO::isPositiveInteger($currentPage)) { die("Invalid page"); } //view edited or edition mode ? $cms_visual_mode = $draft ? PAGE_VISUALMODE_HTML_EDITION : PAGE_VISUALMODE_HTML_EDITED; $cms_page = CMS_tree::getPageByID($currentPage); if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) { die('No rigths on page ...'); exit; } //unset vars to avoid interraction with page unset($currentPage); unset($draft); echo $cms_page->getContent($cms_language, $cms_visual_mode);
/** * Returns XHTML formatted form fields for this Href * * @param CMS_language $cms_language, the language to build the form with * @param string $module, the module codename (default : MOD_STANDARD_CODENAME) * @param constant $dataLocation, the current data location (RESOURCE_DATA_LOCATION_EDITED (default), RESOURCE_DATA_LOCATION_PUBLIC, etc.) * @param array $options, array of possible link options (default false : all options actived) * Example : * Array ( * 'label' => true|false, // Link has label ? * 'internal' => true|false, // Link can target an Automne page ? * 'external' => true|false, // Link can target an external resource ? * 'file' => true|false, // Link can target a file ? * 'destination'=> true|false, // Can select a destination for the link ? * 'no_admin' => true|false, // Deprecated : Remove all admin class reference (default = false) * 'admin' => true|false, // Use admin JS and classes instead of direct actions (default = true) * 'currentPage'=> int|false, // Current page to open tree panel (default : CMS_tree::getRoot()) * ) * @return string HTML formated expected * @access public */ function getHTMLFields($cms_language, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $options = false) { global $cms_user; if (!is_a($this->_href, 'CMS_href')) { $this->raiseError("\$this->_href isn't a CMS_href"); return ''; } $tdClass = $tdClassLight = $tdClassDark = $inputClass = ''; if (!isset($options['no_admin']) || $options['no_admin'] === false) { $tdClass = ' class="admin"'; $tdClassLight = ' class="admin_lightgreybg"'; $tdClassDark = ' class="admin_darkgreybg"'; $inputClass = ' class="admin_input_text"'; } $s = ''; if (!isset($options['destination']) || $options['destination'] == true) { $s .= ' <script type="text/javascript"> if (typeof CMS_openPopUpPage != "function") { function CMS_openPopUpPage(href, id, width, height) { if (href != "") { pagePopupWin = window.open(href, \'CMS_page_\'+id, \'width=\'+width+\',height=\'+height+\',resizable=yes,menubar=no,toolbar=no,scrollbars=yes,status=no,left=0,top=0\'); } } } </script>'; } $s .= ' <table>'; if (!isset($options['label']) || $options['label'] == true) { $s .= ' <!-- link label --> <tr> <th' . $tdClass . '><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_LABEL) . '</th> <td' . $tdClassLight . ' colspan="2"><input style="width:100%;" type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_label" value="' . io::htmlspecialchars($this->_href->getLabel()) . '" /></td> </tr>'; } $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_NONE ? ' checked="checked"' : ''; $rowspan = 4; if (isset($options['internal']) && $options['internal'] == false) { $rowspan--; } if (isset($options['external']) && $options['external'] == false) { $rowspan--; } if (isset($options['file']) && $options['file'] == false) { $rowspan--; } $s .= ' <tr> <th' . $tdClass . ' rowspan="' . $rowspan . '"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_DESTINATION) . '</th> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_0" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_NONE . '"' . $checked . ' /></td> <td' . $tdClassDark . '><label for="' . $this->_prefix . 'link_type_0">' . $cms_language->getMessage(self::MESSAGE_PAGE_NOLINK) . '</label></td> </tr> '; if (!isset($options['internal']) || $options['internal'] == true) { $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL ? ' checked="checked"' : ''; // Build tree link $grand_root = isset($options['currentPage']) && sensitiveIO::isPositiveInteger($options['currentPage']) ? CMS_tree::getPageByID($options['currentPage']) : CMS_tree::getRoot(); $grand_rootID = $grand_root->getID(); if ($cms_user && is_a($cms_user, 'CMS_profile_user')) { if (!$cms_user->hasPageClearance($grand_rootID, CLEARANCE_PAGE_VIEW)) { // If user don't have any clearance view for page root : search a "first root" and viewable page sections $sections_roots = array(); $sections_roots = $cms_user->getViewablePageClearanceRoots(); if ($sections_roots) { CMS_session::setSessionVar('sectionsRoots', $sections_roots); $sections_roots = array_reverse($sections_roots); foreach ($sections_roots as $pageID) { $lineages[count(CMS_tree::getLineage($grand_rootID, $pageID, false))] = $pageID; } } ksort($lineages); $grand_rootID = array_shift($lineages); } } if (!isset($options['admin']) || $options['admin'] == false) { //build tree link $href = '/automne/admin-v3/tree.php'; $href .= '?root=' . $grand_rootID; $href .= '&heading=' . $cms_language->getMessage(self::MESSAGE_PAGE_TREEH1); $href .= '&encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $this->_prefix . "link_internal').value = '%s';self.close();"); $href .= '&encodedPageLink=' . base64_encode('false'); $treeLink = '<a href="' . $href . '"' . $tdClass . ' target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>'; } else { $treeLink = '<a href="#" onclick="Automne.view.tree(\'' . $this->_prefix . 'link_internal\', \'' . sensitiveIO::sanitizeJSString($cms_language->getMessage(self::MESSAGE_PAGE_TREEH1)) . '\', \'' . $grand_rootID . '\')"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>'; } $s .= '<tr> <td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_1" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_INTERNAL . '"' . $checked . ' /></td> <td' . $tdClassLight . '> <label for="' . $this->_prefix . 'link_type_1">' . $cms_language->getMessage(self::MESSAGE_PAGE_INTERNALLINK) . '</label> <input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_internal" name="' . $this->_prefix . 'link_internal" value="' . $this->_href->getInternalLink() . '" size="6" /> ' . $treeLink . ' </td> </tr>'; } if (!isset($options['external']) || $options['external'] == true) { $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_EXTERNAL ? ' checked="checked"' : ''; $s .= ' <tr> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_2" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_EXTERNAL . '"' . $checked . ' /></td> <td' . $tdClassDark . '> <label for="' . $this->_prefix . 'link_type_2">' . $cms_language->getMessage(self::MESSAGE_PAGE_EXTERNALLINK) . '</label> <input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_external" name="' . $this->_prefix . 'link_external" value="' . io::htmlspecialchars($this->_href->getExternalLink()) . '" size="30" /> </td> </tr> '; } if (!isset($options['file']) || $options['file'] == true) { $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_FILE ? ' checked="checked"' : ''; $s .= ' <tr> <td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_3" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_FILE . '"' . $checked . ' /></td> <td' . $tdClassLight . '> <label for="' . $this->_prefix . 'link_type_3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINKFILE) . '</label> <input type="file"' . $inputClass . ' name="' . $this->_prefix . 'link_file" /><br /> <label for="' . $this->_prefix . 'link_edit_linkfile"><input type="checkbox" id="' . $this->_prefix . 'link_edit_linkfile" name="' . $this->_prefix . 'link_edit_linkfile" value="1" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_FIELD_EDITFILE) . '</label>'; if ($this->_href->getFileLink(false, $module, $dataLocation)) { $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : <a href="' . $this->_href->getFileLink(true, $module, $dataLocation) . '" target="_blank">' . $this->_href->getFileLink(false, $module, $dataLocation) . '</a>'; } else { $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : ' . $cms_language->getMessage(self::MESSAGE_PAGE_NO_FILE); } $s .= ' </td> </tr>'; } if (!isset($options['destination']) || $options['destination'] == true) { $popup = $this->_href->getPopup(); $checked_pop = isset($popup['width']) && $popup['width'] > 0 ? ' checked="checked"' : ''; $checked_top = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_top' ? ' checked="checked"' : ''; $checked_bl = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_blank' ? ' checked="checked"' : ''; if (!$checked_pop && !$checked_top && !$checked_bl) { $checked_top = ' checked="checked"'; } $width = isset($popup['width']) ? $popup['width'] : 0; $height = isset($popup['height']) ? $popup['height'] : 0; $s .= ' <!-- Link target --> <tr> <th' . $tdClass . ' rowspan="3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_SHOW) . '</th> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_top" name="' . $this->_prefix . 'link_target" value="top"' . $checked_top . ' /></td> <td' . $tdClassDark . '> <label for="' . $this->_prefix . 'link_target_top"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_TOP) . '</label> </td> </tr> <tr> <td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_target_blank" name="' . $this->_prefix . 'link_target" value="blank"' . $checked_bl . ' /></td> <td' . $tdClassLight . '> <label for="' . $this->_prefix . 'link_target_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_blank.gif" alt="" border="0" align="absmiddle" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_BLANK) . '</label> </td> </tr> <tr> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_popup" name="' . $this->_prefix . 'link_target" value="popup"' . $checked_pop . ' /></td> <td' . $tdClassDark . '> <label for="' . $this->_prefix . 'link_target_popup"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_POPUP) . ' : </label> ' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_WIDTH) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_width" value="' . $width . '" size="3" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_HEIGHT) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_height" value="' . $height . '" size="3" /> </td> </tr>'; } $s .= '</table>'; return $s; }
/** * Get the HTML form given the block HTML example data. * * @param CMS_language &$language The language of the administration frontend * @param CMS_page &$page The page which contains the client space * @param CMS_clientSpace &$clientSpace The client space which contains the row * @param CMS_row &$row The row which contains the block * @param integer $blockID The tag ID of the block * @param string $data The data to show as example * @return string The HTML form which can send to the page that will modify the block * @access private */ protected function _getHTMLForm($language, &$page, &$clientSpace, &$row, $blockID, $data) { global $cms_user; //append atm-block class and block-id to all first level tags found in block datas $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<block>' . $data . '</block>'); } catch (DOMException $e) { $this->raiseError('Parse error for ' . get_class($this) . ' : Page ' . $page->getID() . ' - Row "' . $row->getTagID() . '" - Block "' . $blockID . '" : ' . $e->getMessage()); $data = '<div class="atm-error-block atm-block-helper">' . $language->getMessage(self::MESSAGE_BLOCK_CONTENT_ERROR) . '</div>'; $domdocument = new CMS_DOMDocument(); $domdocument->loadXML('<block>' . $data . '</block>'); } $blockNodes = $domdocument->getElementsByTagName('block'); if ($blockNodes->length == 1) { $blockXML = $blockNodes->item(0); } //check for valid tags nodes inside current block tag $hasNode = false; foreach ($blockXML->childNodes as $blockChildNode) { //scripts tags and p tags are not correctly handled by javascript if (is_a($blockChildNode, 'DOMElement') && $blockChildNode->tagName != 'script') { $hasNode = true; } } foreach ($blockXML->childNodes as $blockChildNode) { //scripts tags and p tags are not correctly handled by javascript if (is_a($blockChildNode, 'DOMElement') && ($blockChildNode->tagName != 'p' || io::substr($blockChildNode->tagName, 0, 4) != 'atm-')) { $hasNode = false; } } if (!$hasNode) { //append div with atm-empty-block class around datas $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<block><div class="atm-empty-block atm-block-helper">' . $data . '</div></block>'); } catch (DOMException $e) { $this->raiseError('Parse error for block : ' . $e->getMessage() . " :\n" . $data, true); return ''; } $blockNodes = $domdocument->getElementsByTagName('block'); if ($blockNodes->length == 1) { $blockXML = $blockNodes->item(0); } } $elements = array(); $uniqueId = 'block-' . md5(mt_rand() . microtime()); foreach ($blockXML->childNodes as $blockChildNode) { if (is_a($blockChildNode, 'DOMElement') && $blockChildNode->tagName != 'script' && $blockChildNode->tagName != 'p' && io::substr($blockChildNode->tagName, 0, 4) != 'atm-') { if ($blockChildNode->hasAttribute('class')) { $blockChildNode->setAttribute('class', $blockChildNode->getAttribute('class') . ' atm-block ' . $uniqueId); } else { $blockChildNode->setAttribute('class', 'atm-block ' . $uniqueId); } $elementId = 'el-' . md5(mt_rand() . microtime()); $blockChildNode->setAttribute('id', $elementId); $elements[] = $elementId; } } $data = CMS_DOMDocument::DOMElementToString($blockXML, true); //add block JS specification $data = ' <script type="text/javascript"> atmBlocksDatas[\'' . $uniqueId . '\'] = { page: \'' . $page->getID() . '\', document: document, clientSpaceTagID: \'' . $clientSpace->getTagID() . '\', row: \'' . $row->getTagID() . '\', id: \'' . $blockID . '\', jsBlockClass: \'' . $this->_jsBlockClass . '\', hasContent: \'' . $this->_hasContent . '\', editable: \'' . $this->_editable . '\', administrable: \'' . $this->_administrable . '\', options: ' . io::jsonEncode($this->_options) . ', value: ' . (is_array($this->_value) ? sensitiveIO::jsonEncode($this->_value) : '\'' . sensitiveIO::sanitizeJSString($this->_value) . '\'') . ', elements: [' . ($elements ? '\'' . implode('\',\'', $elements) . '\'' : '') . '] }; </script> ' . $data; return $data; }
/** * Compute an atm-blockvar tag * * @param array $tag : the reference tag to compute * @return string the PHP / HTML content computed * @access private */ protected function _blockVarTag(&$tag) { //check tags requirements if (!$this->checkTagRequirements($tag, array('id' => true, 'varname' => 'alphanum', 'vartype' => true, 'label' => true, 'mandatory' => '(true)|(false)'))) { return; } switch ($tag['attributes']['vartype']) { case 'string': if (!$this->checkTagValues($tag, array('maxLength' => array('value' => '([-+]?[0-9]+)', 'mandatory' => false), 'default' => array('value' => 'alphanum', 'mandatory' => false)))) { return; } break; case 'integer': if (!$this->checkTagValues($tag, array('maxValue' => array('value' => '([-+]?[0-9]+)', 'mandatory' => false), 'minValue' => array('value' => '([-+]?[0-9]+)', 'mandatory' => false), 'default' => array('value' => '([-+]?[0-9]+)', 'mandatory' => false)))) { return; } break; case 'boolean': if (!$this->checkTagValues($tag, array('default' => array('value' => '[0-1]', 'mandatory' => false)))) { return; } break; case 'date': // do nothing break; case 'float': $pattern = '[-+]?[0-9]*\\.?[0-9]+'; if (isset($tag['attributes']['separator'])) { if ($tag['attributes']['separator'] != '.') { $pattern = '[-+]?[0-9]*' . $tag['attributes']['separator'] . '?[0-9]+'; } } if (!$this->checkTagValues($tag, array('separator' => array('value' => '\\.|,', 'mandatory' => false), 'default' => array('value' => $pattern, 'mandatory' => false)))) { return; } break; case 'page': if (!$this->checkTagValues($tag, array('root' => array('value' => 'page', 'mandatory' => false), 'default' => array('value' => 'page', 'mandatory' => false)))) { return; } break; default: // handle polymod stuff if (strpos($tag['attributes']['vartype'], 'fields') !== false) { if (!$this->checkTagValues($tag, array('vartype' => array('value' => 'field', 'mandatory' => true)))) { return; } } else { // Assume it's an object if (!$this->checkTagValues($tag, array('vartype' => array('value' => 'object', 'mandatory' => true)))) { return; } } break; } if ($this->_mode == self::BLOCK_PARAM_MODE) { // handle i18n on label and description $tag['attributes']['label'] = eval(sensitiveIO::sanitizeExecCommand('return "' . CMS_polymod_definition_parsing::preReplaceVars($tag['attributes']['label']) . '";')); if (isset($tag['attributes']['description'])) { $tag['attributes']['description'] = eval(sensitiveIO::sanitizeExecCommand('return "' . CMS_polymod_definition_parsing::preReplaceVars($tag['attributes']['description']) . '";')); } if (isset($tag['attributes']['possibleValues'])) { $tag['attributes']['possibleValues'] = eval(sensitiveIO::sanitizeExecCommand('return "' . CMS_polymod_definition_parsing::preReplaceVars($tag['attributes']['possibleValues']) . '";')); } $this->_blockParams['var'][$tag['attributes']['id']][$tag['attributes']['varname']] = $tag['attributes']; } $tag['attributes']['value'] = '".@$blockAttributes[\'var\'][\'' . $tag['attributes']['id'] . '\'][\'' . $tag['attributes']['varname'] . '\']."'; return ' $varname_' . $tag['attributes']['id'] . ' = "' . $this->replaceVars($tag['attributes']['varname'], null) . '"; ${$varname_' . $tag['attributes']['id'] . '} = CMS_polymod_definition_parsing::replaceVars("' . $this->replaceVars($tag['attributes']['value'], null) . '", @$replace); unset($varname_' . $tag['attributes']['id'] . ');' . "\n"; }