/** * Add / replace a script to process to the queue. * * @param string $module : the module codename in charge of the script process * @param array $parameters : The script parameters * @param integer $id : The script id to replace (default : false, add a new script) * @return void * @access public * @static */ static function addScript($module, $parameters, $id = false) { if ($module && is_array($parameters) && $parameters) { $sqlFields = "\n\t\t\t\tmodule_reg='" . sensitiveIO::sanitizeSQLString($module) . "',\n\t\t\t\tparameters_reg='" . sensitiveIO::sanitizeSQLString(serialize($parameters)) . "'"; if (sensitiveIO::isPositiveInteger($id)) { $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tregenerator\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sqlFields . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_reg='" . $id . "'"; } else { $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tregenerator\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sqlFields; } $q = new CMS_query($sql); //$q->executePreparedQuery($sql, $sqlParameters); return true; } return false; }
/** * Module script info : get infos for a given script parameters * * @param array $parameters the task parameters * task : string task to execute * module : string module codename for the task * uid : string module uid * @return string : HTML scripts infos * @access public */ function scriptInfo($parameters) { if (isset($parameters['field']) && sensitiveIO::isPositiveInteger($parameters['field'])) { if (!is_object($this->_objectValues[$parameters['field']]) || !method_exists($this->_objectValues[$parameters['field']], 'scriptInfo')) { return false; } //then pass query to field return $this->_objectValues[$parameters['field']]->scriptInfo($parameters); } else { //this is an object related script switch ($parameters['task']) { case 'emailNotification': global $cms_language; if ($parameters['type'] == 'validate') { return $cms_language->getMessage(self::MESSAGE_OBJECT_VALIDATION_AWAIT_NOTIFICATION, false, MOD_POLYMOD_CODENAME); } elseif ($parameters['type'] == 'delete') { return $cms_language->getMessage(self::MESSAGE_OBJECT_DELETION_AWAIT_NOTIFICATION, false, MOD_POLYMOD_CODENAME); } break; default: $this->raiseError('Unknown script task to do : ' . print_r($parameters, true)); return false; break; } } return false; }
/** * 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; }
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))) {
/** * is this template content in draft ? * * @return boolean * @access public */ function isDraft() { if (!sensitiveIO::isPositiveInteger($this->getID())) { return false; } $sql = "select \n\t\t\t\t\t1\n\t\t\t\tfrom \n\t\t\t\t\tmod_standard_clientSpaces_edition \n\t\t\t\twhere \n\t\t\t\t\ttemplate_cs='" . $this->getID() . "'"; $q = new CMS_query($sql); return $q->getNumRows(true) ? true : false; }
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; }
/** * 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; }
function checkCatId($catId) { return io::strpos($catId, 'cat') === 0 && sensitiveIO::isPositiveInteger(io::substr($catId, 3)); }
/** * Is user belongs to given group ? * * @return boolean * @access public * @static */ static function userBelongsToGroup($userID, $groupID) { if (!sensitiveIO::isPositiveInteger($userID) || !sensitiveIO::isPositiveInteger($groupID)) { CMS_grandFather::raiseError('User id and group id must be positive integers'); return false; } $sql = "\n\t\t\tselect\n\t\t\t\t1\n\t\t\tfrom\n\t\t\t\tprofileUsersByGroup\n\t\t\twhere\n\t\t\t\tuserId_gu = '" . SensitiveIO::sanitizeSQLString($userID) . "'\n\t\t\t\tand groupId_gu = '" . SensitiveIO::sanitizeSQLString($groupID) . "'\n\t\t"; $q = new CMS_query($sql); return $q->getNumRows() ? true : false; }
$printableCS = sensitiveIO::request('printableCS') ? explode(',', sensitiveIO::request('printableCS')) : array(); //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(); //CHECKS user has templates clearance if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) { //templates CMS_grandFather::raiseError('User has no rights template editions'); $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_NO_RIGHTS_FOR_TEMPLATES)); $view->show(); } //load template if any if (sensitiveIO::isPositiveInteger($templateId)) { $template = CMS_pageTemplatesCatalog::getByID($templateId); if (!$template || $template->hasError()) { CMS_grandFather::raiseError('Unknown template for given Id : ' . $templateId); $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_TEMPLATE)); $view->show(); } } elseif ($templateId == 'print') { $templateFile = new CMS_file(PATH_TEMPLATES_FS . "/print.xml"); } else { $template = false; } $cms_message = ''; switch ($action) { case 'properties': //Edition
/** * Return the needed form field tag for current object field * * @param array $values : parameters values array(parameterName => parameterValue) in : * id : the form field id to set * @param multidimentionnal array $tags : xml2Array content of atm-function tag * @return string : the form field HTML tag * @access public */ function getInput($fieldID, $language, $inputParams) { //hidden field : use parent method if (isset($inputParams['hidden']) && ($inputParams['hidden'] == 'true' || $inputParams['hidden'] == 1)) { return parent::getInput($fieldID, $language, $inputParams); } global $cms_user; $params = $this->getParamsValues(); if (isset($inputParams['prefix'])) { $prefixName = $inputParams['prefix']; } else { $prefixName = ''; } //serialize all htmlparameters //$htmlParameters = $this->serializeHTMLParameters($inputParams); $html = ''; //create fieldname $fieldName = $prefixName . $this->_field->getID() . '_0'; //create field value $value = $this->_subfieldValues[0]->getValue(); if ($params['html']) { // Insert prefered text editor for textarea field $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); $toolbarset = !$params['toolbar'] ? $module : $params['toolbar']; if (class_exists('CMS_wysiwyg_toolbar')) { $toolbar = CMS_wysiwyg_toolbar::getByCode($toolbarset, $cms_user); $value = $toolbar->hasModulePlugins() ? CMS_textEditor::parseInnerContent($value, $module) : $value; } $CKEditor = new CKEditor(PATH_MAIN_WR . '/ckeditor/'); $CKEditor->returnOutput = true; $html .= $CKEditor->editor($fieldName, $value, array('language' => $language->getCode(), 'width' => $params['toolbarWidth'] ? $params['toolbarWidth'] : '100%', 'height' => sensitiveIO::isPositiveInteger($params['toolbarHeight']) ? $params['toolbarHeight'] : 200, 'customConfig' => PATH_MAIN_WR . '/ckeditor/config.php?toolbar=' . $toolbarset)); } else { //serialize all htmlparameters $htmlParameters = $this->serializeHTMLParameters($inputParams); //append field id to html field parameters (if not already exists) $htmlParameters .= !isset($inputParams['id']) ? ' id="' . $prefixName . $this->_field->getID() . '_0"' : ''; $width = '100%'; if ($params['toolbarWidth']) { $width = io::substr($params['toolbarWidth'], -1, 1) == '%' ? $params['toolbarWidth'] : $params['toolbarWidth'] . 'px'; } $html .= '<textarea type="text" name="' . $fieldName . '"' . $htmlParameters . ' style="width:' . $width . ';height:' . (sensitiveIO::isPositiveInteger($params['toolbarHeight']) ? $params['toolbarHeight'] : 200) . 'px">' . str_replace('<br />', "\n", str_replace(array("\n", "\r"), "", $value)) . '</textarea>' . "\n"; } if (POLYMOD_DEBUG) { $html .= ' <span class="admin_text_alert">(Field : ' . $this->_field->getID() . ' - SubField : 0)</span>'; } //append html hidden field which store field name if ($html) { $html .= '<input type="hidden" name="polymodFields[' . $this->_field->getID() . ']" value="' . $this->_field->getID() . '" />'; } return $html; }
/** * Writes the cmsprofile into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $sql_fields = "\n\t\t\tadministrationClearance_pr='" . SensitiveIO::sanitizeSQLString($this->_adminClearance) . "',\n\t\t\tpageClearancesStack_pr='" . SensitiveIO::sanitizeSQLString($this->_pageClearances->getTextDefinition()) . "',\n\t\t\tvalidationClearancesStack_pr='" . SensitiveIO::sanitizeSQLString($this->_validationClearances->getTextDefinition()) . "',\n\t\t\tmoduleClearancesStack_pr='" . SensitiveIO::sanitizeSQLString($this->_moduleClearances->getTextDefinition()) . "',\n\t\t\ttemplateGroupsDeniedStack_pr='" . SensitiveIO::sanitizeSQLString($this->_templateGroupsDenied->getTextDefinition()) . "',\n\t\t\trowGroupsDeniedStack_pr='" . SensitiveIO::sanitizeSQLString($this->_rowGroupsDenied->getTextDefinition()) . "'\n\t\t"; if ($this->_id) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tprofiles\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_pr='" . $this->_id . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tprofiles\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } //pr($sql); $q = new CMS_query($sql); if ($q->hasError()) { return false; } elseif (!$this->_id) { $this->_id = $q->getLastInsertedID(); } if (!sensitiveIO::isPositiveInteger($this->_moduleCategoriesClearances->getProfileID())) { $this->_moduleCategoriesClearances->setProfileID($this->_id); } // Write moduleCategories clearances to persistence also return $this->_moduleCategoriesClearances->writeToPersistence(); }
/** * Reset websites order * * @param array $websitesIDsOrdered : the websites IDs ordered * @return boolean true on success, false on failure * @access public */ static function setOrders($websitesIDsOrdered) { $count = 1; foreach ($websitesIDsOrdered as $websiteID) { if (!sensitiveIO::isPositiveInteger($websiteID)) { CMS_grandFather::raiseError('Website id must be a positive integer : ' . $websiteID); return false; } $sql = "\n\t\t\t\tupdate \n\t\t\t\t\twebsites \n\t\t\t\tset \n\t\t\t\t\torder_web='" . $count . "'\n\t\t\t\twhere\n\t\t\t\t\tid_web='" . $websiteID . "'\n\t\t\t"; $q = new CMS_query($sql); if ($q->hasError()) { CMS_grandFather::raiseError('Saving order error for website : ' . $websiteID); return false; } $count++; } return true; }
/** * Get the search. * * @param integer $searchType : the type of the search (see constants) * @return array of CMS_page the result pages * @access public */ function getSearch($keywords, $user, $public = false, $withPageContent = false) { if (is_a($user, 'CMS_profile_user')) { $cms_language = $user->getLanguage(); } else { $cms_language = new CMS_language('fr'); } $results = array(); $count = 0; /*$messages = array(); $message = '';*/ $where = $order = ''; $foundLinkToIDs = $foundLinkFromIDs = $foundPagesFromTemplate = $foundPagesFromRow = $matches = array(); // Clean keywords $keywords = SensitiveIO::sanitizeSQLString($keywords); $keywords = strtr($keywords, ",;", " "); $blocks = array(); $blocks = array_map("trim", array_unique(explode(" ", $keywords))); $cleanedBlocks = array(); foreach ($blocks as $block) { if ($block !== '' || sensitiveIO::isPositiveInteger($block)) { $block = str_replace(array('%', '_'), array('\\%', '\\_'), $block); $cleanedBlocks[] = $block; } } // Separate block codes if ($cleanedBlocks) { $allDatas = array(); $allCodes = CMS_search::getAllCodes(); foreach ($allCodes as $code) { $datas = array(); foreach (array_keys($cleanedBlocks) as $key) { if (strstr($cleanedBlocks[$key], $code . ':')) { $datas[] = $cleanedBlocks[$key]; unset($cleanedBlocks[$key]); } } if ($datas) { $allDatas[$code] = $datas; } } $allDatas[self::SEARCH_TYPE_DEFAULT] = $cleanedBlocks; // Get IDs from all specific codes $foundIDs = array(); $allLinksNumber = 0; foreach ($allCodes as $code) { switch ($code) { case self::SEARCH_TYPE_LINKTO: if (isset($allDatas[self::SEARCH_TYPE_LINKTO])) { $foundLinkToIDs = array(); $where = ''; $count = 0; foreach ($allDatas[self::SEARCH_TYPE_LINKTO] as $block) { $tabValues = explode(':', $block); if (SensitiveIO::isPositiveInteger($tabValues[1])) { $where .= $count ? ' or ' : ''; $count++; $where .= " start_lre = '" . $tabValues[1] . "' "; } } if ($where) { $select = ' stop_lre '; $from = 'linx_real_public'; $sql = "\n\t\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t\t" . $select . "\n\t\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t\t" . $from . "\n\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\t" . $where; $q = new CMS_query($sql); $arr = array(); while ($arr = $q->getArray()) { $foundLinkToIDs[] = $arr["stop_lre"]; } // Count links number $allLinksNumber += count($foundLinkToIDs); $where = $select = ''; } } break; case self::SEARCH_TYPE_LINKFROM: if (isset($allDatas[self::SEARCH_TYPE_LINKFROM])) { $foundLinkFromIDs = array(); $where = ''; $count = 0; /*$messagesIDs = array();*/ foreach ($allDatas[self::SEARCH_TYPE_LINKFROM] as $block) { $tabValues = explode(':', $block); if (SensitiveIO::isPositiveInteger($tabValues[1])) { $where .= $count ? ' or ' : ''; $count++; $where .= " stop_lre = '" . $tabValues[1] . "' "; } } if ($where) { $select = ' start_lre '; $from = 'linx_real_public'; $sql = "\n\t\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t\t" . $select . "\n\t\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t\t" . $from . "\n\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\t" . $where; $q = new CMS_query($sql); $arr = array(); while ($arr = $q->getArray()) { $foundLinkFromIDs[] = $arr["start_lre"]; } // Count links number $allLinksNumber += count($foundLinkFromIDs); $where = $select = ''; } } break; case self::SEARCH_TYPE_TEMPLATE: if (isset($allDatas[self::SEARCH_TYPE_TEMPLATE])) { $foundPagesFromTemplate = array(); foreach ($allDatas[self::SEARCH_TYPE_TEMPLATE] as $block) { $tabValues = explode(':', $block); if (SensitiveIO::isPositiveInteger($tabValues[1])) { $foundPagesFromTemplate = array_unique(array_merge(CMS_pageTemplatesCatalog::getPagesByTemplate($tabValues[1]), $foundPagesFromTemplate)); } } $allLinksNumber += count($foundPagesFromTemplate); } break; case self::SEARCH_TYPE_ROW: if (isset($allDatas[self::SEARCH_TYPE_ROW])) { $foundPagesFromRow = array(); foreach ($allDatas[self::SEARCH_TYPE_ROW] as $block) { $tabValues = explode(':', $block); if (SensitiveIO::isPositiveInteger($tabValues[1])) { $foundPagesFromRow = array_unique(array_merge(CMS_rowsCatalog::getPagesByRow($tabValues[1]), CMS_rowsCatalog::getPagesByRow($tabValues[1], false, true), $foundPagesFromRow)); } } $allLinksNumber += count($foundPagesFromRow); } break; } } $foundIDs = array_unique(array_merge($foundLinkToIDs, $foundLinkFromIDs, $foundPagesFromTemplate, $foundPagesFromRow)); // Main sql requests (for pageId, pages codenames and keywords) if ($allDatas[self::SEARCH_TYPE_DEFAULT]) { $count = 0; $where = ''; foreach ($allDatas[self::SEARCH_TYPE_DEFAULT] as $key => $block) { if (SensitiveIO::isPositiveInteger($block)) { $where .= $count ? ' or ' : ''; $count++; $where .= " (page_pbd like '%" . $block . "%')"; unset($allDatas[self::SEARCH_TYPE_DEFAULT][$key]); } } $order = ''; if ($allDatas[self::SEARCH_TYPE_DEFAULT]) { $suffix = $public ? '_public' : '_edited'; if (!$withPageContent) { //Search in page metadatas //$count = 0; foreach ($allDatas[self::SEARCH_TYPE_DEFAULT] as $block) { $where .= $count ? ' or ' : ''; $count++; $where .= " (\n\t\t\t\t\t\t\t\ttitle_pbd like '%" . $block . "%'\n\t\t\t\t\t\t\t\tor linkTitle_pbd like '%" . $block . "%'\n\t\t\t\t\t\t\t\tor keywords_pbd like '%" . $block . "%'\n\t\t\t\t\t\t\t\tor description_pbd like '%" . $block . "%'\n\t\t\t\t\t\t\t\tor category_pbd like '%" . $block . "%'\n\t\t\t\t\t\t\t\tor codename_pbd = '" . $block . "'\n\t\t\t\t\t\t\t)"; } if ($foundIDs) { $where .= " and page_pbd in (" . implode($foundIDs, ',') . ") "; } // Set SQL $sql = "\n\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\tpage_pbd\n\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\tpagesBaseData" . $suffix . "\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t" . $where . "\n\t\t\t\t\t\t"; $q = new CMS_query($sql); //pr($sql); $results = array(); $count = 0; $foundIDs = array(); while ($id = $q->getValue('page_pbd')) { $foundIDs[] = $id; } $order = "\n\t\t\t\t\t \t\torder by title_pbd asc\n\t\t\t\t\t\t"; } else { //Search in page content (fulltext search) $keywords = implode(' ', $allDatas[self::SEARCH_TYPE_DEFAULT]); $selects = array('pagesBaseData' . $suffix => array('page' => 'page_pbd', 'match' => 'title_pbd,linkTitle_pbd,keywords_pbd,description_pbd,codename_pbd'), 'blocksVarchars' . $suffix => array('page' => 'page', 'match' => 'value'), 'blocksTexts' . $suffix => array('page' => 'page', 'match' => 'value', 'entities' => true), 'blocksImages' . $suffix => array('page' => 'page', 'match' => 'label'), 'blocksFiles' . $suffix => array('page' => 'page', 'match' => 'label')); $matches = array(); foreach ($selects as $table => $select) { // Set SQL $sql = "\n\t\t\t\t\t\t\t\tselect \n\t\t\t\t\t\t\t\t\t" . $select['page'] . " as pageId, MATCH (" . $select['match'] . ") AGAINST ('" . sensitiveIO::sanitizeSQLString($keywords) . "') as m1\n\t\t\t\t\t\t\t\t\t" . (isset($select['entities']) && $keywords != htmlentities($keywords) ? " , MATCH (" . $select['match'] . ") AGAINST ('" . sensitiveIO::sanitizeSQLString(htmlentities($keywords)) . "') as m2 " : '') . "\n\t\t\t\t\t\t\t\tfrom \n\t\t\t\t\t\t\t\t\t" . $table . "\n\t\t\t\t\t\t\t\twhere \n\t\t\t\t\t\t\t\t\tMATCH (" . $select['match'] . ") AGAINST ('" . sensitiveIO::sanitizeSQLString($keywords) . "')\n\t\t\t\t\t\t\t\t\t" . (isset($select['entities']) && $keywords != htmlentities($keywords) ? " or MATCH (" . $select['match'] . ") AGAINST ('" . sensitiveIO::sanitizeSQLString(htmlentities($keywords)) . "') " : '') . "\n\t\t\t\t\t\t\t\t"; //pr($sql); $q = new CMS_query($sql); while ($r = $q->getArray()) { if (!isset($matches[$r['pageId']]) || isset($matches[$r['pageId']]) && $r['m1'] > $matches[$r['pageId']]) { $matches[$r['pageId']] = $r['m1']; } if (isset($r['m2']) && (!isset($matches[$r['pageId']]) || isset($matches[$r['pageId']]) && $r['m2'] > $matches[$r['pageId']])) { $matches[$r['pageId']] = $r['m2']; } } } //sort page Ids by relevance arsort($matches, SORT_NUMERIC); //$matches = array_keys($matches); $order = "\n\t\t\t\t\t \t\torder by field(page_pbd, " . implode(',', array_reverse(array_keys($matches))) . ") desc\n\t\t\t\t\t\t"; $foundIDs = $foundIDs ? array_intersect(array_keys($matches), $foundIDs) : array_keys($matches); } } else { $order = " order by page_pbd "; } } if ($foundIDs) { $select = ' page_pbd '; $from = $public ? 'pagesBaseData_public' : 'pagesBaseData_edited'; $where .= $where && $foundIDs ? " and " : ''; $where .= $foundIDs ? " page_pbd in (" . implode($foundIDs, ',') . ") " : ''; if ($where) { // Set SQL $sql = "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t" . $select . "\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t" . $from . "\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t" . $where . "\n\t\t\t\t\t\t" . $order . "\n\t\t\t\t\t"; $q = new CMS_query($sql); //pr($sql); $results = array(); $count = 0; while ($arr = $q->getArray()) { $id = $arr["page_pbd"]; if ($user->hasPageClearance($id, CLEARANCE_PAGE_VIEW)) { $count++; $results[$id] = $id; } } } } } else { // No results $count = 0; } return array('nbresult' => $count, 'nblinksresult' => $allLinksNumber, 'results' => $results, 'score' => $matches); }
}); tabs.insert(' . $index . ', panel); } '; } break; case 'edit': $panelTitle = $cms_language->getMessage(MESSAGE_PAGE_EDIT_CONTENT); $panelDisabled = $isEditable && !$hasRedirect ? 'false' : 'true'; $panelTipTitle = $cms_language->getMessage(MESSAGE_PAGE_EDIT_CONTENT_TIP_TITLE); $panelTip = $cms_language->getMessage(MESSAGE_PAGE_EDIT_CONTENT_TIP_DESC); $panelPicto = 'atm-pic-big-edit'; if ($hasDraft) { $panelTip .= '<br /><br /><strong>' . $cms_language->getMessage(MESSAGE_PAGE_EDIT_NOT_VALIDATED) . '</strong>'; } if ($hasLock && sensitiveIO::isPositiveInteger($hasLock)) { $lockUser = CMS_profile_usersCatalog::getById($hasLock); $lockDate = $cms_page->getLockDate(); $panelTip .= '<br /><br /><strong>' . $cms_language->getMessage(MESSAGE_PAGE_LOCKEDBY) . ' </strong>' . $lockUser->getFullName() . ' ' . $cms_language->getMessage(MESSAGE_PAGE_LOCKED_ON_AT, array($lockDate->getLocalizedDate($cms_language->getDateFormat()), $lockDate->getLocalizedDate('H:i:s'))); } elseif (!$isEditable) { $panelTip .= '<br /><br />' . $cms_language->getMessage(MESSAGE_PAGE_EDIT_CONTENT_TIP_DISABLED_DESC); } $panelURL = PATH_ADMIN_WR . '/page-content.php?page=' . $cms_page->getID() . ($querystring ? '&' . $querystring : ''); $panelEditable = 'true'; break; case 'edited': $panelTitle = $cms_language->getMessage(MESSAGE_PAGE_PREVIZ); $panelPicto = 'atm-pic-big-edited'; $panelDisabled = $hasPreviz && !$hasRedirect ? 'false' : 'true'; $panelTipTitle = $cms_language->getMessage(MESSAGE_PAGE_PREVIZ_TIP_TITLE); $panelTip = $cms_language->getMessage(MESSAGE_PAGE_PREVIZ_TIP_DESC);
/** * Writes object into persistence (MySQL for now), along with base data. * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { //get Order if needed if (!$this->_objectFieldValues["order"] && sensitiveIO::isPositiveInteger($this->_objectFieldValues["objectID"])) { $this->_objectFieldValues["order"] = $this->getFieldsNextOrder(); } if (!$this->_objectFieldValues["uuid"]) { $this->_objectFieldValues["uuid"] = io::uuid(); } $sql_fields = "\n\t\t\tobject_id_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["objectID"]) . "',\n\t\t\tlabel_id_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["labelID"]) . "',\n\t\t\tdesc_id_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["descriptionID"]) . "',\n\t\t\ttype_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["type"]) . "',\n\t\t\torder_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["order"]) . "',\n\t\t\tsystem_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["system"]) . "',\n\t\t\trequired_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["required"]) . "',\n\t\t\tindexable_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["indexable"]) . "',\n\t\t\tsearchlist_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["searchlist"]) . "',\n\t\t\tsearchable_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["searchable"]) . "',\n\t\t\tparams_mof='" . SensitiveIO::sanitizeSQLString(serialize($this->_objectFieldValues["params"])) . "',\n\t\t\tuuid_mof='" . SensitiveIO::sanitizeSQLString($this->_objectFieldValues["uuid"]) . "'\n\t\t"; //save data if ($this->_fieldID) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmod_object_field\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_mof='" . $this->_fieldID . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmod_object_field\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { $this->raiseError("Can't save object"); return false; } elseif (!$this->_fieldID) { $this->_fieldID = $q->getLastInsertedID(); } //unset fields catalog in cache CMS_cache::clearTypeCache('atm-polymod-structure'); //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => CMS_poly_object_catalog::getModuleCodenameForField($this->_fieldID))); CMS_cache::clearTypeCache('polymod'); return true; }
/** * 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; }
* PHP page : module cms_forms frontend * Export form datas to CSV file * * @package Automne * @subpackage cms_forms * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../../../cms_rc_admin.php'; require_once PATH_ADMIN_SPECIAL_SESSION_CHECK_FS; //CHECKS $cms_module = CMS_modulesCatalog::getByCodename(MOD_CMS_FORMS_CODENAME); if (!$cms_user->hasModuleClearance(MOD_CMS_FORMS_CODENAME, CLEARANCE_MODULE_EDIT)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_name()); exit; } if (!$_GET["form"] || !sensitiveIO::isPositiveInteger($_GET["form"])) { CMS_grandFather::raiseError("Formular export : Missing form ID parameter"); exit; } $replace = array('"' => '""', '\\r\\n' => '\\n'); function cleanvalue($value) { global $replace; return str_replace(array_keys($replace), $replace, $value); } $form = new CMS_forms_formular($_GET["form"]); //get array of form datas $formDatas = $form->getAllRecordDatas(false, $_GET["withDate"] ? true : false); //create array of fields names (for CSV header) $fields = $form->getFields(true); $fileFields = array();
/** * 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; }
*/ //This page must be accessible by all users to avoid infinite loop if a website home page is redirected to an external website require_once dirname(__FILE__) . '/../../cms_rc_frontend.php'; define("MESSAGE_PAGE_REDIRECT", 320); define("MESSAGE_PAGE_PAGE", 1303); define("MESSAGE_PAGE_PAGE_REDIRECT_ERROR", 703); //load interface instance $view = CMS_view::getInstance(); $view->addCSSFile('main'); $view->addCSSFile('info'); //force language if none exists if (!isset($cms_language) || !is_object($cms_language)) { $cms_language = new CMS_language(ADMINISTRATION_DEFAULT_LANGUAGE); } //get page if (isset($_GET['pageId']) && sensitiveIO::isPositiveInteger($_GET['pageId'])) { $page = CMS_tree::getPageById($_GET['pageId']); } if (isset($page) && !$page->hasError()) { $redirect = ''; $redirectlink = $page->getRedirectLink(true); if ($redirectlink->hasValidHREF()) { if ($redirectlink->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL) { $redirectPage = new CMS_page($redirectlink->getInternalLink()); if (!$redirectPage->hasError()) { $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $redirectPage->getTitle() . '" (' . $redirectPage->getID() . ')'; } $redirect = '<a href="' . $redirectPage->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>'; } else { $label = $redirectlink->getExternalLink(); $redirectlink->setTarget('_blank');
/** * 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 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; $params = $this->getParamsValues(); $name = $name !== 0 ? $name : "0"; switch ($name) { case 'ids': $ids = array(); foreach (array_keys($this->_subfieldValues) as $subFieldID) { if (is_object($this->_subfieldValues[$subFieldID])) { $ids[] = $this->_subfieldValues[$subFieldID]->getValue(); } } return $ids; break; case 'values': return $this->_subfieldValues; break; case 'count': return sizeof($this->_subfieldValues); break; default: if (sensitiveIO::isPositiveInteger($name) || $name === "0") { if (!is_object($this->_subfieldValues[$name])) { return ''; } switch ($parameters) { case 'id': return $this->_subfieldValues[$name]->getValue(); break; case 'label': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[$name]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[$name]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? io::htmlspecialchars($userGroup->getLabel()) : io::htmlspecialchars($userGroup->getFirstName() . ' ' . $userGroup->getLastName()); } return ''; break; case 'email': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[$name]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[$name]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? '' : io::htmlspecialchars($userGroup->getEmail()); } return ''; break; } } else { if (!isset($this->_subfieldValues[0]) || !is_object($this->_subfieldValues[0])) { return ''; } switch ($name) { case 'label': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[0]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[0]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? io::htmlspecialchars($userGroup->getLabel()) : io::htmlspecialchars($userGroup->getFirstName() . ' ' . $userGroup->getLastName()); } return ''; break; case 'email': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[0]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[0]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? '' : io::htmlspecialchars($userGroup->getEmail()); } return ''; break; case 'id': return $this->_subfieldValues[0]->getValue(); break; default: return parent::getValue($name, $parameters); break; } } break; } }
/** * Recursive method to replace input tags in XHTML source * * @param multidimentionnal array &definition : the XML definition to treat (by reference) * @param CMS_forms_field $field, the field to replace * @access private * @return void */ protected function _replaceField(&$definition, &$field) { if (is_array($definition) && is_array($definition[0])) { //loop on subtags foreach (array_keys($definition) as $key) { if (in_array($definition[$key]['nodename'], array('input', 'textarea', 'select')) && isset($definition[$key]['attributes']['id'])) { $fieldId = CMS_forms_field::extractEncodedID($definition[$key]['attributes']['id']); if (sensitiveIO::isPositiveInteger($fieldId) && $field->getID() == $fieldId) { //recreate XHTML code for field list($label, $input) = $field->getFieldXHTML($this->_language); $replace = array('&' => '&'); //transform XHTML code to XML definition $xmlArray = new CMS_xml2Array($input, CMS_xml2Array::XML_ENCLOSE | CMS_xml2Array::XML_PROTECT_ENTITIES); //then replace field definition into current definition tag $fieldDefinition = $xmlArray->getParsedArray(); // Default : add the first tag $definition[$key] = $fieldDefinition[0]; // Check other tags if ($fieldDefinition) { foreach ($fieldDefinition as $subFieldTagKey => $subFieldTag) { if (isset($subFieldTag['attributes']['class']) && $subFieldTag['attributes']['class'] == 'inputHelp') { $definition[] = $subFieldTag; } } } } } elseif ($definition[$key]['nodename'] == 'label' && isset($definition[$key]['attributes']['for'])) { $fieldId = CMS_forms_field::extractEncodedID($definition[$key]['attributes']['for']); if (sensitiveIO::isPositiveInteger($fieldId) && $field->getID() == $fieldId) { //recreate encoded id $definition[$key]['attributes']['for'] = $field->generateFieldIdDatas(); //remove old text node unset($definition[$key]['childrens']); //set new text node $definition[$key]['childrens'][0]['textnode'] = $field->getAttribute('label'); } } if (is_array($definition[$key]) && sizeof($definition[$key]['childrens'])) { $this->_replaceField($definition[$key]['childrens'], $field); } } } else { $this->raiseError("Malformed definition to compute : " . print_r($definition, true)); return false; } }
protected function _getFieldsFiles($item, &$files) { //get object fields definitions $objectFields = CMS_poly_object_catalog::getFieldsDefinition($item->getObjectID()); $itemFieldsObjects =& $item->getFieldsObjects(); foreach ($itemFieldsObjects as $fieldID => $itemField) { //check field type $fieldType = $objectFields[$fieldID]->getValue('type'); if (sensitiveIO::isPositiveInteger($fieldType)) { //this field is a poly_object so recurse on his values $this->_getFieldsFiles($itemField, $files); } elseif (io::strpos($fieldType, "multi|") !== false) { //this field is a multi_poly_object so recurse on all poly_objects it contain $params = $itemField->getParamsValues(); if ($itemField->getValue('count')) { $items = $itemField->getValue('fields'); foreach ($items as $anItem) { $this->_getFieldsFiles($anItem, $files); } } } else { //if this field is a file, check for file if ($fieldType == 'CMS_object_file') { if ($itemField->getValue('filename')) { $files[] = PATH_REALROOT_FS . $itemField->getValue('filePath') . '/' . $itemField->getValue('filename'); } } } } return; }
/** * 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; }
<input type="hidden" name="block" value="' . $blockId . '" /> <td class="admin"><input type="submit" class="admin_input_' . $td_class . '" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_UNSELECT, false, MOD_CMS_FORMS_CODENAME) . '" /></td> </form>'; } $content .= ' </tr> </table> </td> </tr> '; } $content .= ' </table>'; } //previsualization of a form if (sensitiveIO::isPositiveInteger($previz)) { $previzform = new CMS_forms_formular($previz); $content .= ' <br /><br /> <dialog-title type="admin_h2">' . $cms_language->getMessage(MESSAGE_PAGE_PREVIEW) . '</dialog-title><br /><br /> <table border="1" cellpadding="3" cellspacing="0"> <tr> <td class="admin"> ' . $previzform->getContent(CMS_forms_formular::REMOVE_FORM_SUBMIT) . ' </td> </tr> </table> '; } $dialog->setContent($content); $dialog->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; }
/** * 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) * @return boolean true on success, false on failure * @access public */ function setValues($values, $prefixName, $newFormat = false) { if (isset($values['list' . $prefixName . $this->_field->getID() . '_0'])) { $values['list' . $prefixName . $this->_field->getID() . '_0'] = str_replace(',', ';', $values['list' . $prefixName . $this->_field->getID() . '_0']); $valuesArray = explode(';', $values['list' . $prefixName . $this->_field->getID() . '_0']); foreach (array_keys($this->_subfieldValues) as $subFieldID) { $value = isset($valuesArray[$subFieldID]) ? $valuesArray[$subFieldID] : false; if (is_object($this->_subfieldValues[$subFieldID]) && $value !== false && sensitiveIO::isPositiveInteger($value)) { //replace value $this->_subfieldValues[$subFieldID]->setValue($value); } else { if (is_object($this->_subfieldValues[$subFieldID]) && ($value === false || !sensitiveIO::isPositiveInteger($value))) { //remove unused $this->_subfieldValues $this->_subfieldValues[$subFieldID]->destroy(); unset($this->_subfieldValues[$subFieldID]); } } } foreach ($valuesArray as $subFieldID => $aValue) { if (!isset($this->_subfieldValues[$subFieldID]) && sensitiveIO::isPositiveInteger($aValue)) { $this->_subfieldValues[$subFieldID] = new CMS_subobject_integer(); $this->_subfieldValues[$subFieldID]->setValue($aValue); } } //and reload all subObject values $this->_loadSubObjectsValues(); } return true; }
/** * Pseudo-constructor, initializes the tag with its definition from tag and row id * * @param string $blockID, the block id to initialise * @param integer $rowID, the row id which contain the block to load * @return boolean true on success, false on failure. * @access public */ function initializeFromID($blockID, $rowID) { if (!sensitiveIO::isPositiveInteger($rowID)) { $this->raiseError("rowID must be a positive integer : " . $rowID); return false; } //instanciate row to get block definition $row = new CMS_row($rowID); $blockTag = $row->getBlockTagById($blockID); if (!is_object($blockTag)) { $this->raiseError('Can\'t get block ' . $blockID . ' from row id : ' . $rowID); return false; } $this->initializeFromTag($blockTag->getAttributes(), $blockTag->getInnerContent()); return true; }
$def = CMS_polymod_oembed_definition_catalog::getById($_POST['oembedId']); $def->destroy(); $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); break; case "change_order": if (is_object($object)) { $fields = CMS_poly_object_catalog::getFieldsDefinition($object->getID()); $count = 0; //construct array of new fields orders $newPagesOrder = array(); $tmpPagesOrder = explode(',', $_POST["new_order"]); if (sizeof($tmpPagesOrder)) { foreach ($tmpPagesOrder as $tmpPage) { $fieldID = substr($tmpPage, 1); $count++; if (sensitiveIO::isPositiveInteger($fieldID) && is_object($fields[$fieldID])) { $fields[$fieldID]->setValue('order', $count); $fields[$fieldID]->writeToPersistence(); } } } $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); } break; } $objects = $module->getObjects(); $content .= ' <dialog-title type="admin_h2">' . $cms_language->getMessage(MESSAGE_PAGE_APPLICATION) . ' :: ' . $module->getLabel($cms_language) . ' :</dialog-title> <br /> <dialog-title type="admin_h3">' . $cms_language->getMessage(MESSAGE_PAGE_OBJECTS) . ' :</dialog-title>'; if (!sizeof($objects)) {