Example #1
0
 /**
  * Output the anchor start tag
  *
  * @return string the HTML content
  * @access private
  */
 function anchorStart($tagName, $anchor, $attributes)
 {
     if (strpos($_SERVER['SCRIPT_NAME'], PATH_ADMIN_WR) !== false && strpos($_SERVER['SCRIPT_NAME'], 'page-previsualization.php') === false) {
         return '<' . $tagName . ' href="' . $anchor . '"' . $attributes . '>';
     }
     return '<' . $tagName . ' href="' . (pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_BASENAME) != 'index.php' ? $_SERVER['SCRIPT_NAME'] : pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME) . (pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME) == '/' ? '' : '/')) . (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] ? '?' . io::htmlspecialchars($_SERVER["QUERY_STRING"]) : '') . $anchor . '"' . $attributes . '>';
 }
Example #2
0
 } else {
     $pageCopy = '';
 }
 //draft
 if ($fromtab == 'edit' && $cms_user->getUserID() == $hasLock) {
     //cancel draft and submit draft to validation
     $pageDraft = "\n\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETE_DRAFT_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETE_DRAFT) . "</span>',\n\t\t\t\t\t\ticonCls: 'atm-pic-draft-deletion',\n\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETE_DRAFT_CONFIRM) . "',\n\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t//send to public or edited tab\n\t\t\t\t\t\t\t\t\t\tvar pubTab = tabs.getItem('public');\n\t\t\t\t\t\t\t\t\t\tif (!pubTab.disabled) {\n\t\t\t\t\t\t\t\t\t\t\ttabs.setActiveTab('public');\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\ttabs.setActiveTab('edited');\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'cancel_draft'\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_DRAFT_TO_VALIDATION_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_DRAFT_TO_VALIDATION) . "</span>',\n\t\t\t\t\t\ticonCls: 'atm-pic-draft-validation',\n\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t//submit page to validation\n\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\taction:\t\t\t\t'submit_for_validation'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}));";
 } else {
     $pageDraft = '';
 }
 if ($cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) {
     if ($hasLock) {
         //unlock
         if ($fromtab != 'edit' && ($cms_user->getUserID() == $hasLock || $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL))) {
             $lockUser = CMS_profile_usersCatalog::getById($hasLock);
             $panelContent .= "\n\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNLOCK_LOCKED_PAGE, array(io::htmlspecialchars($lockUser->getFullName()))) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNLOCK_PAGE) . "</span>',\n\t\t\t\t\t\t\t\ticonCls: 'atm-pic-unlock',\n\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNLOCK_CONFIRM, array(io::htmlspecialchars($lockUser->getFullName()))) . "',\n\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'resource-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresource:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodule:\t\t\t'standard',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t'unlock'\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));";
         } elseif ($fromtab == 'edit' && $cms_user->getUserID() == $hasLock) {
             $panelContent .= $pageDraft;
         }
     } else {
         if ($cms_page->getProposedLocation() == RESOURCE_LOCATION_DELETED) {
             //undelete
             $panelContent .= "\n\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_DELETION_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_DELETION) . "</span>',\n\t\t\t\t\t\t\t\ticonCls: 'atm-pic-undelete',\n\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'undelete'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));";
         } elseif ($cms_page->getProposedLocation() == RESOURCE_LOCATION_ARCHIVED) {
             //unarchive
             $panelContent .= "\n\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_ARCHIVING_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_ARCHIVING) . "</span>',\n\t\t\t\t\t\t\t\ticonCls: 'atm-pic-unarchive',\n\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'unarchive'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));";
         } else {
             if (!$cms_page->isProtected()) {
                 //move page
                 $father = CMS_tree::getAncestor($cms_page, 1);
                 $draggable = is_object($father) && $cms_user->hasPageClearance($father->getID(), CLEARANCE_PAGE_EDIT) && (!$hasSiblings || $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) && $cms_page->getID() != APPLICATION_ROOT_PAGE_ID);
Example #3
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     $href = new CMS_href($this->_subfieldValues[0]->getValue());
     switch ($name) {
         case 'validhref':
             return $href->hasValidHREF();
             break;
         case 'hrefvalue':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             return $href->getHTML(false, $moduleCodename, $location, false, true);
             break;
         case 'hreflabel':
             return io::htmlspecialchars($href->getLabel());
             break;
         case 'hreftarget':
             return $href->getTarget();
             break;
         case 'hreftype':
             return $href->getLinkType();
             break;
         case 'popupWidth':
             $popup = $href->getPopup();
             return $popup['width'];
             break;
         case 'popupHeight':
             $popup = $href->getPopup();
             return $popup['height'];
             break;
         case 'hrefHTML':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             //add link title (if any)
             if ($parameters) {
                 $title = $parameters;
                 //add title attribute to link
                 $href->setAttributes(array('title' => io::htmlspecialchars($href->getLabel() . ' (' . $title . ')')));
             } else {
                 $title = false;
                 //add title attribute to link
                 $href->setAttributes(array('title' => io::htmlspecialchars($href->getLabel())));
             }
             return $href->getHTML($title, $moduleCodename, $location);
             break;
         default:
             return parent::getValue($name, $parameters);
             break;
     }
 }
Example #4
0
 /**
  * Get all searched objects ids
  * 
  * @access private
  * @return array of object ids unsorted
  */
 protected function _getIds()
 {
     $IDs = array();
     $statusSuffix = $this->_public ? "_public" : "_edited";
     //loop on each conditions
     foreach ($this->_whereConditions as $type => $typeWhereConditions) {
         foreach ($typeWhereConditions as $whereConditionsValues) {
             $value = $whereConditionsValues['value'];
             $operator = $whereConditionsValues['operator'];
             $sql = '';
             switch ($type) {
                 case "object":
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and id_moo in (' . $this->_getSQLTmpList() . ')' : '';
                     //to remove deleted objects from results
                     $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tid_moo as objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_object_polyobjects\n\t\t\t\t\twhere\n\t\t\t\t\t\tobject_type_id_moo = '" . $this->_object->getID() . "'\n\t\t\t\t\t\tand deleted_moo = '0'\n\t\t\t\t\t\t{$where}\n\t\t\t\t\t";
                     break;
                 case "item":
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     //check operator
                     $supportedOperator = array('=', '!=', '>=', '>', '<=', '<');
                     if ($operator && !in_array($operator, $supportedOperator)) {
                         $this->raiseError("Unknown search operator : " . $operator . ", use default search instead");
                         $operator = false;
                     }
                     if (!$operator) {
                         $operator = '=';
                     }
                     $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_text" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " '" . $value . "'\n\t\t\t\t\t\t{$where}\n\t\t\t\t\tunion distinct\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " '" . $value . "'\n\t\t\t\t\t\t{$where}\n\t\t\t\t\tunion distinct\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_string" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " '" . $value . "'\n\t\t\t\t\t\t{$where}\n\t\t\t\t\tunion distinct\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_date" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " '" . $value . "'\n\t\t\t\t\t\t{$where}\n\t\t\t\t\t";
                     break;
                 case "items":
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     //check operator
                     $supportedOperator = array('in', 'not in');
                     if ($operator && !in_array($operator, $supportedOperator)) {
                         $this->raiseError("Unknown search operator : " . $operator . ", use default search instead");
                         $operator = false;
                     }
                     if (!$operator) {
                         $operator = 'in';
                     }
                     //no values to found so break search
                     if ((!is_array($value) || !$value) && $operator == 'in') {
                         $IDs = array();
                         break;
                     }
                     //no filter to do so break search
                     if ((!is_array($value) || !$value) && $operator == 'not in') {
                         break;
                     }
                     $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_text" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " (" . implode(',', $value) . ")\n\t\t\t\t\t\t{$where}\n\t\t\t\t\tunion distinct\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " (" . implode(',', $value) . ")\n\t\t\t\t\t\t{$where}\n\t\t\t\t\tunion distinct\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_string" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " (" . implode(',', $value) . ")\n\t\t\t\t\t\t{$where}\n\t\t\t\t\tunion distinct\n\t\t\t\t\tselect\n\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_date" . $statusSuffix . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID " . $operator . " (" . implode(',', $value) . ")\n\t\t\t\t\t\t{$where}\n\t\t\t\t\t";
                     break;
                 case "profile":
                     //if user has no right on module, he cannot search object on it
                     if (!$value->hasModuleClearance($this->_object->getValue('module'), CLEARANCE_MODULE_VIEW)) {
                         break;
                     }
                     //if object has categories, check rights on it
                     if ($this->_object->hasCategories()) {
                         //get field of categories for searched object type (assume it uses categories)
                         $categoriesFields = CMS_poly_object_catalog::objectHasCategories($this->_object->getId());
                         //BUG : in websites without APPLICATION_ENFORCES_ACCESS_CONTROL, backend rights on categories are checked on visibility instead of edition
                         if (!$this->_public) {
                             $clearance = CLEARANCE_MODULE_EDIT;
                             $strict = true;
                         } else {
                             $clearance = CLEARANCE_MODULE_VIEW;
                             $strict = false;
                         }
                         //get a list of all viewvable categories for current user
                         $cats = array_keys(CMS_moduleCategories_catalog::getViewvableCategoriesForProfile($value, $this->_object->getValue('module'), true, $clearance, $strict));
                         foreach ($categoriesFields as $categoriesField) {
                             //load category field if not exists
                             if (!isset($this->_fieldsDefinitions[$categoriesField]) || !is_object($this->_fieldsDefinitions[$categoriesField])) {
                                 //get object fields definition
                                 $this->_fieldsDefinitions = CMS_poly_object_catalog::getFieldsDefinition($this->_object->getID());
                             }
                             if (!isset($this->_fieldsDefinitions[$categoriesField])) {
                                 break;
                             }
                             //we can see objects without categories only if is not public or field is not required and user has admin right on module
                             if ($this->_public && !$this->_fieldsDefinitions[$categoriesField]->getValue('required') || !$this->_public && $value->hasModuleClearance($this->_object->getValue('module'), CLEARANCE_MODULE_EDIT)) {
                                 //add deleted cats to searchs
                                 $viewvableCats = array_merge(CMS_moduleCategories_catalog::getDeletedCategories($this->_object->getValue('module')), $cats);
                                 //add zero value for objects without categories
                                 $viewvableCats[] = 0;
                             } else {
                                 $viewvableCats = $cats;
                                 //add zero value for objects without categories
                                 $viewvableCats[] = 0;
                             }
                             //if no viewvable categories, user has no rights to view anything
                             if (!$viewvableCats) {
                                 break;
                             }
                             $removedIDs = array();
                             //add previously found IDs to where clause
                             $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                             $sqlTmp = "\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\twhere\n\t\t\t\t\t\t\t\t\tobjectFieldID = '" . $categoriesField . "'\n\t\t\t\t\t\t\t\t\tand value not in (" . @implode(',', $viewvableCats) . ")\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t";
                             $qTmp = new CMS_query($sqlTmp);
                             while ($r = $qTmp->getArray()) {
                                 if ($r['objectID'] && isset($IDs[$r['objectID']])) {
                                     $removedIDs[$r['objectID']] = $r['objectID'];
                                 }
                             }
                             //add (again) ids which has a category visible and a category not visible
                             if ($removedIDs) {
                                 $sqlTmp = "\n\t\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . "\n\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\tobjectFieldID = '" . $categoriesField . "'\n\t\t\t\t\t\t\t\t\t\tand value in (" . @implode(',', $viewvableCats) . ")\n\t\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\t";
                                 $qTmp = new CMS_query($sqlTmp);
                                 while ($r = $qTmp->getArray()) {
                                     if ($r['objectID'] && isset($removedIDs[$r['objectID']])) {
                                         unset($removedIDs[$r['objectID']]);
                                     }
                                 }
                                 //then finally remove ids
                                 foreach ($removedIDs as $idToRemove) {
                                     unset($IDs[$idToRemove]);
                                 }
                             }
                             //if no IDs break
                             if (!$IDs) {
                                 break;
                             }
                             //if field is required and if it is a public search, object must have this category in DB
                             if ($this->_fieldsDefinitions[$categoriesField]->getValue('required') && $this->_public) {
                                 //update tmp table with found ids
                                 $this->_updateTmpList($IDs);
                                 $sqlTmp = "\n\t\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . "\n\t\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t\tobjectFieldID = '" . $categoriesField . "'\n\t\t\t\t\t\t\t\t\t\tand objectID in (" . $this->_getSQLTmpList() . ")\n\t\t\t\t\t\t\t\t";
                                 $qTmp = new CMS_query($sqlTmp);
                                 $IDs = array();
                                 while ($r = $qTmp->getArray()) {
                                     $IDs[$r['objectID']] = $r['objectID'];
                                 }
                             }
                             //if no IDs break
                             if (!$IDs) {
                                 break;
                             }
                         }
                         //if no IDs break
                         if (!$IDs) {
                             break;
                         }
                     } elseif (!$this->_public && !$value->hasModuleClearance($this->_object->getValue('module'), CLEARANCE_MODULE_EDIT)) {
                         break;
                     } elseif ($this->_public && !$value->hasModuleClearance($this->_object->getValue('module'), CLEARANCE_MODULE_VIEW)) {
                         break;
                     }
                     //update tmp table with found ids
                     $this->_updateTmpList($IDs);
                     //add previously found IDs to where clause
                     $where = $IDs ? ' id_moo in (' . $this->_getSQLTmpList() . ')' : '';
                     $sql = "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\tdistinct id_moo as objectID\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\tmod_object_polyobjects\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t";
                     break;
                 case "keywords":
                     if ($value) {
                         //check operators
                         $supportedOperator = array('any', 'all', 'phrase', 'beginswith');
                         if ($operator && !in_array($operator, $supportedOperator)) {
                             $this->raiseError("Unkown search operator : " . $operator . ", use default search instead");
                             $operator = 'any';
                         } elseif (!$operator) {
                             $operator = 'any';
                         }
                         //if ASE module exists (and is active) and object is indexed, and search is public, use it to do this search
                         if ($operator == 'any' && class_exists('CMS_module_ase') && CMS_module_ase::isActive() && $this->_object->getValue('indexable') && $this->_public) {
                             //get language code for stemming
                             $languageCode = '';
                             if ($languageFieldIDs = CMS_poly_object_catalog::objectHasLanguageField($this->_object->getID())) {
                                 $languageFieldID = array_shift($languageFieldIDs);
                                 //if any query use this field, use the queried value for stemming strategy
                                 if (isset($this->_whereConditions[$languageFieldID]) && $this->_whereConditions[$languageFieldID]) {
                                     $languageCode = $this->_whereConditions[$languageFieldID][0]['value'];
                                 }
                             }
                             //otherwise, we use current language
                             if (!$languageCode) {
                                 global $cms_language;
                                 $languageCode = $cms_language->getCode();
                             }
                             if (!$languageCode) {
                                 $languageCode = io::strtolower(APPLICATION_DEFAULT_LANGUAGE);
                             }
                             $module = $this->_object->getValue('module');
                             //create Xapian search object
                             $search = new CMS_XapianQuery(trim($value), array($module), $languageCode, true);
                             //load module interface
                             if (!($moduleInterface = CMS_ase_interface_catalog::getModuleInterface($module))) {
                                 $this->raiseError('No active Xapian interface for module : ' . $module);
                                 return false;
                             }
                             //add previously found IDs to search filters
                             $moduleInterface->addFilter('items', $IDs);
                             //set module interface to search engine
                             $search->setModuleInterface($module, $moduleInterface);
                             //set page number and max results for xapian query
                             //we must do a complete search all the time so we start from page 0
                             $page = 0;
                             //we limit to a maximum of 1000 results
                             $maxResults = 1000;
                             //then search
                             if (!$search->query($page, $maxResults)) {
                                 $this->raiseError('Error in Xapian query for search : ' . io::htmlspecialchars($value));
                                 return false;
                             }
                             //pr($search->getQueryDesc(true));
                             //if no results : break
                             if (!$search->getMatchesNumbers()) {
                                 break;
                             }
                             $xapianResults = $search->getMatches();
                         } else {
                             //get fields
                             if (!isset($this->_fieldsDefinitions[$type]) || !is_object($this->_fieldsDefinitions[$type])) {
                                 //get object fields definition
                                 $this->_fieldsDefinitions = CMS_poly_object_catalog::getFieldsDefinition($this->_object->getID());
                             }
                             //search only in "searchable" fields
                             $fields = array();
                             $aseExists = class_exists('CMS_module_ase') && CMS_module_ase::isActive() && $this->_object->getValue('indexable') ? true : false;
                             foreach ($this->_fieldsDefinitions as $fieldDefinition) {
                                 if ($fieldDefinition->getValue($aseExists ? 'indexable' : 'searchable')) {
                                     $fields[] = $fieldDefinition->getID();
                                 }
                             }
                             if (!$fields) {
                                 //if no fields after cleaning, return
                                 break;
                             }
                             //add previously found IDs to where clause
                             $where = $IDs ? ' objectID in (' . $this->_getSQLTmpList() . ') and ' : '';
                             //filter on specified fields
                             $where .= $fields ? ' objectFieldID  in (' . implode(',', $fields) . ') and ' : '';
                             //clean user keywords (never trust user input, user is evil)
                             $value = strtr($value, ",;", "  ");
                             $words = array();
                             $words = array_map("trim", array_unique(explode(" ", $value)));
                             $cleanedWords = array();
                             foreach ($words as $aWord) {
                                 if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) {
                                     $aWord = str_replace(array('%', '_'), array('\\%', '\\_'), $aWord);
                                     $cleanedWords[] = $aWord;
                                 }
                             }
                             if (!$cleanedWords) {
                                 //if no words after cleaning, return
                                 break;
                             }
                             switch ($operator) {
                                 case 'any':
                                     $where .= '(';
                                     //then add keywords
                                     $count = '0';
                                     foreach ($cleanedWords as $aWord) {
                                         $where .= $count ? ' or ' : '';
                                         $count++;
                                         $where .= "value like '%" . $aWord . "%'";
                                         if (htmlentities($aWord) != $aWord) {
                                             $where .= " or value like '%" . htmlentities($aWord) . "%'";
                                         }
                                     }
                                     $where .= ')';
                                     break;
                                 case 'all':
                                     $where .= '(';
                                     //then add keywords
                                     $count = '0';
                                     foreach ($cleanedWords as $aWord) {
                                         $where .= $count ? ' and ' : '';
                                         $count++;
                                         if (htmlentities($aWord) != $aWord) {
                                             $where .= "(value like '%" . $aWord . "%' or value like '%" . htmlentities($aWord) . "%')";
                                         } else {
                                             $where .= "value like '%" . $aWord . "%'";
                                         }
                                     }
                                     $where .= ')';
                                     break;
                                 case 'phrase':
                                     $value = str_replace(array('%', '_'), array('\\%', '\\_'), trim($value));
                                     if (htmlentities($value) != $value) {
                                         $where .= "(value like '%" . $value . "%' or value like '%" . htmlentities($value) . "%')";
                                     } else {
                                         $where .= "value like '%" . $value . "%'";
                                     }
                                     break;
                                 case 'beginswith':
                                     $value = str_replace(array('%', '_'), array('\\%', '\\_'), trim($value));
                                     if (htmlentities($value) != $value) {
                                         $where .= "(value like '" . $value . "%' or value like '" . htmlentities($value) . "%')";
                                     } else {
                                         $where .= "value like '" . $value . "%'";
                                     }
                                     break;
                             }
                             $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_text" . $statusSuffix . "\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\tunion distinct\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\twhere\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\tunion distinct\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_string" . $statusSuffix . "\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\tunion distinct\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_date" . $statusSuffix . "\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t";
                         }
                     }
                     break;
                 case "publication date after":
                     // Date start
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     $sql = "\n\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . ",\n\t\t\t\t\t\t\t\tresources,\n\t\t\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tobjectFieldID = '0'\n\t\t\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t\t\t\t\tand publicationDateStart_rs >= '" . $value->getDBValue(true) . "'\n\t\t\t\t\t\t\t\tand publicationDateStart_rs != '0000-00-00'\n\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t";
                     break;
                 case "publication date before":
                     // Date End
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     $sql = "\n\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . ",\n\t\t\t\t\t\t\t\tresources,\n\t\t\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tobjectFieldID = '0'\n\t\t\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t\t\t\t\tand publicationDateStart_rs <= '" . $value->getDBValue(true) . "'\n\t\t\t\t\t\t\t\tand publicationDateStart_rs != '0000-00-00'\n\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t";
                     break;
                 case "publication date end":
                     // End Date of publication
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     $sql = "\n\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\tdistinct objectID\n\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\tmod_subobject_integer" . $statusSuffix . ",\n\t\t\t\t\t\t\t\tresources,\n\t\t\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tobjectFieldID = '0'\n\t\t\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t\t\t\t\tand (publicationDateEnd_rs >= '" . $value->getDBValue(true) . "'\n\t\t\t\t\t\t\t\tor publicationDateEnd_rs = '0000-00-00')\n\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t";
                     break;
                 case "status":
                     // Publication status
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     switch ($value) {
                         case 'online':
                             $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\tand location_rs='" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\t\t\t\t\tand publication_rs='" . RESOURCE_PUBLICATION_PUBLIC . "'\n\t\t\t\t\t\t\t\t\tand publicationDateStart_rs <= '" . date('Y-m-d') . "'\n\t\t\t\t\t\t\t\t\tand publicationDateStart_rs != '0000-00-00'\n\t\t\t\t\t\t\t\t\tand (publicationDateEnd_rs >= '" . date('Y-m-d') . "'\n\t\t\t\t\t\t\t\t\tor publicationDateEnd_rs = '0000-00-00')\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\t";
                             break;
                         case 'offline':
                             $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\tand (publication_rs='" . RESOURCE_PUBLICATION_NEVERVALIDATED . "' or publication_rs='" . RESOURCE_PUBLICATION_VALIDATED . "')\n\t\t\t\t\t\t\t\t\tand (publicationDateStart_rs > '" . date('Y-m-d') . "' or publicationDateEnd_rs < '" . date('Y-m-d') . "')\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\t";
                             break;
                         case 'validated':
                             $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\tand editions_rs=0\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\t";
                             break;
                         case 'awaiting':
                             $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\tand editions_rs!=0\n\t\t\t\t\t\t\t\t\t{$where}\n\t\t\t\t\t\t\t\t";
                             break;
                     }
                     break;
                 default:
                     //add previously found IDs to where clause
                     $where = $IDs ? ' and objectID in (' . $this->_getSQLTmpList() . ')' : '';
                     if (!isset($this->_fieldsDefinitions[$type]) || !is_object($this->_fieldsDefinitions[$type])) {
                         //get object fields definition
                         $this->_fieldsDefinitions = CMS_poly_object_catalog::getFieldsDefinition($this->_object->getID());
                     }
                     //get type object for field
                     if (isset($this->_fieldsDefinitions[$type])) {
                         $objectField = $this->_fieldsDefinitions[$type]->getTypeObject();
                         $sql = $objectField->getFieldSearchSQL($type, $value, $operator, $where, $this->_public);
                     } else {
                         $this->raiseError('Unknown field ' . $type . ' to filter with value ' . print_r($value, true));
                     }
                     break;
             }
             if ($sql || isset($xapianResults) || isset($fullTextResults)) {
                 if ($sql) {
                     //pr($sql);
                     //$this->raiseError($sql);
                     $q = new CMS_query($sql);
                     $IDs = array();
                     if (!$q->hasError()) {
                         while ($id = $q->getValue('objectID')) {
                             $IDs[$id] = $id;
                         }
                     }
                 } elseif (isset($xapianResults)) {
                     $IDs = array();
                     foreach ($xapianResults as $id) {
                         $IDs[$id] = $id;
                     }
                     //if we only have objectID as orderCondition or if order by relevance is queried, use order provided by Xapian
                     if (isset($this->_orderConditions['objectID']) && $this->_orderConditions['objectID'] && sizeof($this->_orderConditions) <= 1 || isset($this->_orderConditions['relevance']) && $this->_orderConditions['relevance']) {
                         if ($this->_orderConditions['relevance'] == 'desc') {
                             $this->_orderConditions = array('itemsOrdered' => array('order' => array_reverse($IDs, true)));
                         } else {
                             $this->_orderConditions = array('itemsOrdered' => array('order' => $IDs));
                         }
                         if (isset($this->_orderConditions['relevance']) && $this->_orderConditions['relevance']) {
                             unset($this->_orderConditions['relevance']);
                         }
                     }
                 } else {
                     //if we only have objectID as orderCondition or if order by relevance is queried, use order provided by MySQL Fulltext
                     if (isset($this->_orderConditions['relevance']) && $this->_orderConditions['relevance']) {
                         if ($this->_orderConditions['relevance'] == 'desc') {
                             $this->_orderConditions = array('itemsOrdered' => array('order' => array_reverse($fullTextResults, true)));
                         } else {
                             $this->_orderConditions = array('itemsOrdered' => array('order' => $fullTextResults));
                         }
                         unset($this->_orderConditions['relevance']);
                     }
                 }
                 //if no results, no need to continue
                 if (!$IDs) {
                     $IDs = array();
                     $this->_numRows = 0;
                     return $IDs;
                 }
                 //update tmp table with found ids
                 $this->_updateTmpList($IDs);
             } else {
                 //if no sql request, then no results (can be used by 'profile'), no need to continue
                 $IDs = array();
                 $this->_numRows = sizeof($IDs);
                 return $IDs;
             }
         }
     }
     $this->_numRows = sizeof($IDs);
     return $IDs;
 }
Example #5
0
 /**
  * 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('&amp;', '&', $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;
 }
Example #6
0
 /**
  * Get HTML meta tags for a given page
  *
  * @param boolean $public Do we want the edited or public value ? (default : false => edited).
  * @param array $tags the tags names to activate/desactivate (by default all tags are present if they have content)
  *		array('description' => false)
  * @return string : HTML meta tags infos infos
  * @access public
  */
 function getMetaTags($public = false, $tags = array())
 {
     $website = $this->getWebsite();
     $favicon = '';
     $metaDatas = '';
     if (!is_object($website)) {
         return '';
     }
     if (!isset($tags['icon']) || $tags['icon']) {
         if ($website->getMeta('favicon')) {
             $infos = pathinfo($website->getMeta('favicon'));
             if ($infos['extension']) {
                 switch ($infos['extension']) {
                     case 'ico':
                         $type = 'image/x-icon';
                         break;
                     case 'jpg':
                         $type = 'image/jpeg';
                         break;
                     case 'gif':
                         $type = 'image/gif';
                         break;
                     case 'png':
                         $type = 'image/png';
                         break;
                     default:
                         $type = 'application/octet-stream';
                         break;
                 }
             } else {
                 $type = 'application/octet-stream';
             }
             $metaDatas .= '<?php echo \'<link rel="icon" type="' . $type . '" href="\'.CMS_websitesCatalog::getCurrentDomain().\'' . PATH_REALROOT_WR . $website->getMeta('favicon') . '" />\'."\\n"; ?>' . "\n";
         } elseif (file_exists(PATH_REALROOT_FS . '/favicon.ico')) {
             $metaDatas .= '<?php echo \'<link rel="icon" type="image/x-icon" href="\'.CMS_websitesCatalog::getCurrentDomain().\'' . PATH_REALROOT_WR . '/favicon.ico" />\'."\\n"; ?>' . "\n";
         } elseif (file_exists(PATH_REALROOT_FS . '/img/favicon.png')) {
             $metaDatas .= '<?php echo \'<link rel="icon" type="image/png" href="\'.CMS_websitesCatalog::getCurrentDomain().\'' . PATH_REALROOT_WR . '/img/favicon.png" />\'."\\n"; ?>' . "\n";
         }
     }
     if ((!isset($tags['description']) || $tags['description']) && $this->getDescription($public)) {
         $metaDatas .= '	<meta name="description" content="' . io::htmlspecialchars($this->getDescription($public), ENT_COMPAT) . '" />' . "\n";
     }
     if ((!isset($tags['keywords']) || $tags['keywords']) && $this->getKeywords($public)) {
         $metaDatas .= '	<meta name="keywords" content="' . io::htmlspecialchars($this->getKeywords($public), ENT_COMPAT) . '" />' . "\n";
     }
     if (io::strtolower(APPLICATION_XHTML_DTD) != io::strtolower('<!DOCTYPE html>')) {
         if ((!isset($tags['category']) || $tags['category']) && $this->getCategory($public)) {
             $metaDatas .= '	<meta name="category" content="' . io::htmlspecialchars($this->getCategory($public), ENT_COMPAT) . '" />' . "\n";
         }
         if ((!isset($tags['robots']) || $tags['robots']) && $this->getRobots($public)) {
             $metaDatas .= '	<meta name="robots" content="' . io::htmlspecialchars($this->getRobots($public), ENT_COMPAT) . '" />' . "\n";
         }
         if ((!isset($tags['language']) || $tags['language']) && $this->getLanguage($public)) {
             $metaDatas .= '	<meta name="language" content="' . io::htmlspecialchars($this->getLanguage($public), ENT_COMPAT) . '" />' . "\n";
         }
         if (!isset($tags['identifier-url']) || $tags['identifier-url']) {
             $metaDatas .= '	<?php echo \'<meta name="identifier-url" content="\'.CMS_websitesCatalog::getCurrentDomain().\'' . PATH_REALROOT_WR . '" />\'."\\n"; ?>' . "\n";
         }
         if ((!isset($tags['revisit-after']) || $tags['revisit-after']) && $this->getReminderPeriodicity($public) && $this->getReminderPeriodicity($public) > 0) {
             $metaDatas .= '	<meta name="revisit-after" content="' . $this->getReminderPeriodicity($public) . ' days" />' . "\n";
         }
         if ((!isset($tags['pragma']) || $tags['pragma']) && $this->getPragma($public)) {
             $metaDatas .= '	<meta http-equiv="pragma" content="no-cache" />' . "\n";
         }
         if ((!isset($tags['refresh']) || $tags['refresh']) && $this->getRefresh($public)) {
             $metaDatas .= '	<meta http-equiv="refresh" content="' . io::htmlspecialchars($this->getRefresh($public), ENT_COMPAT) . '" />' . "\n";
         }
     }
     if (!NO_PAGES_EXTENDED_META_TAGS) {
         if ((!isset($tags['author']) || $tags['author']) && $this->getAuthor($public)) {
             $metaDatas .= '	<meta name="author" content="' . io::htmlspecialchars($this->getAuthor($public), ENT_COMPAT) . '" />' . "\n";
         }
         if (io::strtolower(APPLICATION_XHTML_DTD) != io::strtolower('<!DOCTYPE html>')) {
             if ((!isset($tags['reply-to']) || $tags['reply-to']) && $this->getReplyto($public)) {
                 $metaDatas .= '	<meta name="reply-to" content="' . io::htmlspecialchars($this->getReplyto($public), ENT_COMPAT) . '" />' . "\n";
             }
             if ((!isset($tags['copyright']) || $tags['copyright']) && $this->getCopyright($public)) {
                 $metaDatas .= '	<meta name="copyright" content="' . io::htmlspecialchars($this->getCopyright($public), ENT_COMPAT) . '" />' . "\n";
             }
         }
     }
     if (!isset($tags['generator']) || $tags['generator']) {
         $metaDatas .= '	<meta name="generator" content="' . CMS_grandFather::SYSTEM_LABEL . '" />' . "\n";
     }
     if ($this->getMetas($public)) {
         $metaDatas .= $this->getMetas($public) . "\n";
     }
     return $metaDatas;
 }
Example #7
0
 /**
  * Get field XHTML
  * 
  * @param CMS_language $formLanguage : the language for messages
  * @return array array(label, input)
  */
 function getFieldXHTML($formLanguage = '')
 {
     // Language
     global $cms_language;
     if (!$formLanguage) {
         $formLanguage = $cms_language;
     }
     //generate field id datas
     $fieldIDDatas = $this->generateFieldIdDatas();
     $input = $label = '';
     switch ($this->getAttribute("type")) {
         case 'hidden':
             $input = '<input type="hidden" value="' . io::htmlspecialchars($this->getAttribute("value")) . '" id="' . $fieldIDDatas . '" name="' . $this->getAttribute("name") . '" />';
             break;
         case 'select':
             $label = '<label for="' . $fieldIDDatas . '">' . $this->getAttribute("label") . '</label>';
             $input = '<select name="' . $this->getAttribute("name") . '" id="' . $fieldIDDatas . '">';
             $options = $this->getAttribute("options");
             if (sizeof($options)) {
                 foreach ($options as $aValue => $anOption) {
                     $selected = $this->getAttribute("value") == $aValue ? ' selected="selected"' : '';
                     $input .= '<option value="' . $aValue . '"' . $selected . '>' . $anOption . '</option>';
                 }
             }
             $input .= '</select>';
             break;
         case 'text':
         case 'email':
         case 'url':
         case 'integer':
         case 'file':
         case 'pass':
         case 'checkbox':
             $label = '<label for="' . $fieldIDDatas . '">' . $this->getAttribute("label") . '</label>';
             $input = '<input';
             $fileHelp = '';
             switch ($this->getAttribute("type")) {
                 case 'file':
                     $input .= ' type="file"';
                     $fileParams = $this->getAttribute("params");
                     $fileHelpTab = array();
                     if ($fileParams) {
                         foreach ($fileParams as $fileParamName => $fileParamValue) {
                             switch ($fileParamName) {
                                 case 'extensions':
                                     $fileHelpTab['extensions'] = $formLanguage->getMessage(self::MESSAGE_CMS_FORMS_FILE_PARAMS_ALLOWED_EXTENSIONS, false, MOD_CMS_FORMS_CODENAME) . ' ' . $fileParamValue;
                                     break;
                                 case 'weight':
                                     $fileHelpTab['weight'] = $formLanguage->getMessage(self::MESSAGE_CMS_FORMS_FILE_PARAMS_MAX_FILESIZE, false, MOD_CMS_FORMS_CODENAME) . ' ' . $fileParamValue . 'Ko';
                                     break;
                             }
                         }
                     }
                     if (!isset($fileHelpTab['weight'])) {
                         $fileHelpTab['weight'] = $formLanguage->getMessage(self::MESSAGE_CMS_FORMS_FILE_PARAMS_MAX_FILESIZE, false, MOD_CMS_FORMS_CODENAME) . ' ' . CMS_file::getMaxUploadFileSize('K') . 'Ko';
                     }
                     if ($fileHelpTab) {
                         $fileHelp = '<br/>(' . implode(' ; ', $fileHelpTab) . ')';
                     }
                     break;
                 case 'pass':
                     $input .= ' type="password" value=""';
                     break;
                 case 'checkbox':
                     $input .= ' type="checkbox" value="1" class="checkbox" ' . ($this->getAttribute("value") ? ' checked="checked"' : '');
                     break;
                 case 'text':
                 case 'email':
                 case 'url':
                 case 'integer':
                 default:
                     $input .= ' type="text" value="' . io::htmlspecialchars($this->getAttribute("value")) . '"';
                     break;
             }
             $fileHelp = $fileHelp ? ' <span class="inputHelp">' . $fileHelp . '</span>' : '';
             $input .= ' id="' . $fieldIDDatas . '" name="' . $this->getAttribute("name") . '" />' . $fileHelp;
             break;
         case 'submit':
             $input = '<input id="' . $fieldIDDatas . '" type="submit" class="button" name="' . $this->getAttribute("name") . '" value="' . $this->getAttribute("label") . '" />';
             break;
         case 'textarea':
             $label = '<label for="' . $fieldIDDatas . '">' . $this->getAttribute("label") . '</label>';
             $input = '<textarea cols="40" rows="6" id="' . $fieldIDDatas . '" name="' . $this->getAttribute("name") . '">' . io::htmlspecialchars($this->getAttribute("value")) . '</textarea>';
             break;
     }
     return array($label, $input);
 }
Example #8
0
 function getContent($type = 'menu')
 {
     //create a random name (useful for onSubmit purposes among other)
     $form_name = md5(mt_rand());
     $onSubmit = '0';
     $method = isset($this->_formAttributes["method"]) ? $this->_formAttributes["method"] : "post";
     if ($method != 'post') {
         $onSubmit = '1';
     }
     if ($type == 'DHTML' || $type == 'popup') {
         $content = '<tr><td width="100%" height="34" valign="top" nowrap="nowrap">';
     } else {
         $content = '<td width="34" height="35" onMouseOver="changeColor(this,\'A69C9A\');" onMouseOut="changeColor(this,\'\');" valign="center" align="center">';
     }
     $content .= '<form name="' . $form_name . '" method="' . $method . '" action="' . $this->_formAction . '" ';
     foreach ($this->_formAttributes as $name => $value) {
         if ($name != "method" && $name != "onSubmit" && $name != "onsubmit" && $name != "target") {
             $content .= $name . '="' . io::htmlspecialchars($value) . '" ';
         }
         if ($name == "onSubmit" || $name == "onsubmit") {
             $content .= $name . '="' . io::htmlspecialchars($value) . '" ';
             $onSubmit = '1';
         }
         if ($name == "target") {
             if ($value == "_blank") {
                 $onSubmit = '1';
             }
             $content .= $name . '="' . io::htmlspecialchars($value) . '" ';
         }
     }
     if (!$onSubmit && $type != 'popup') {
         $content .= ' onSubmit="check();" ';
     }
     $content .= '>';
     foreach ($this->_formHiddens as $name => $value) {
         $value = str_replace("\n", "", $value);
         $value = str_replace("\r", "", $value);
         $value = io::htmlspecialchars($value);
         $content .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
     }
     foreach ($this->_formTexts as $name => $textArray) {
         $value = $textArray["value"];
         $size = $textArray["size"];
         $code = $textArray["code"];
         $replace = array("\n" => '', "\r" => '');
         $value = str_replace(array_keys($replace), $replace, $value);
         $value = htmlspecialchars($value);
         $content .= SensitiveIO::arraySprintf($code, array('<input type="text" class="admin_input_text" name="' . $name . '" value="' . $value . '" size="' . $size . '" />'));
     }
     if ($type == 'DHTML' || $type == 'popup') {
         if ($this->_picto) {
             $content .= '<input align="absmiddle" type="image" src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/' . $this->_picto . '" alt="' . $this->_label . '" title="' . $this->_label . '" value="' . $this->_label . '" /><input type="submit" onMouseOver="this.style.backgroundColor=\'#D0CBCA\';" onMouseOut="this.style.backgroundColor=\'#FFFFFF\';" class="CMS_dhtml_input_submit" value="' . $this->_label . '" />';
         } else {
             $content .= '<input type="submit" class="admin_input_submit" value="' . $this->_label . '" style="width:130px" />';
         }
     } else {
         if ($this->_picto) {
             $content .= '<input type="image" src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/' . $this->_picto . '" alt="' . $this->_label . '" title="' . $this->_label . '" value="' . $this->_label . '" />';
         } else {
             $content .= '<input type="submit" class="admin_input_submit" value="' . $this->_label . '" style="width:130px" />';
         }
     }
     if ($type == 'DHTML' || $type == 'popup') {
         $content .= '</form></td></tr>';
     } else {
         $content .= '</form></td>';
     }
     return $content;
 }
Example #9
0
 /**
  * For a given category, return options tag list (for a select tag) of all sub categories
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  * 	selected : the category id which is selected (optional)
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag (nothing for this one)
  * @return string : options tag list
  * @access public
  */
 function selectOptions($values, $tags)
 {
     $usersGroups = $this->getListOfNamesForObject();
     $return = "";
     if (is_array($usersGroups) && $usersGroups) {
         foreach ($usersGroups as $userGroupID => $userGroupLabel) {
             $selected = $userGroupID == $values['selected'] ? ' selected="selected"' : '';
             $return .= '<option title="' . io::htmlspecialchars($userGroupLabel) . '" value="' . $userGroupID . '"' . $selected . '>' . $userGroupLabel . '</option>';
         }
     }
     return $return;
 }
        }
    } else {
        $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $page->getTitle() . '" (' . $page->getID() . ')';
        $redirect = '<a href="' . $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>';
    }
    $content = '
	<div id="atm-center">
		<div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array($redirect)) . '</div>
	</div>';
} else {
    if (isset($_GET['url'])) {
        $url = urldecode($_GET['url']);
        if ($page = CMS_tree::analyseURL($url)) {
            $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $page->getTitle() . '" (' . $page->getID() . ')';
            $redirect = '<a href="' . $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>';
        } else {
            $redirect = '<a href="' . $url . '" target="_blank">' . io::htmlspecialchars($url) . '</a>';
        }
        $content = '
	<div id="atm-center">
		<div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array($redirect)) . '</div>
	</div>';
    } else {
        $content = '
	<div id="atm-center">
		<div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_PAGE_REDIRECT_ERROR) . '</div>
	</div>';
    }
}
$view->setContent($content);
$view->show(CMS_view::SHOW_HTML);
Example #11
0
 /**
  * Look if this block can have or must have parameters to been set ? (search parameters for now)
  *
  * @return boolean true
  * @access private
  */
 private function _lookForBlockParameters()
 {
     if ($this->_canhasParameters !== null && $this->_musthaveParameters !== null) {
         return true;
     }
     $this->_canhasParameters = false;
     $this->_musthaveParameters = false;
     $domdocument = new CMS_DOMDocument();
     try {
         $domdocument->loadXML('<dummy>' . $this->_definition . '</dummy>');
     } catch (DOMException $e) {
         $this->raiseError('Parse error during search for blocks parameters : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($this->_definition));
         return true;
     }
     $searchTags = $domdocument->getElementsByTagName('atm-search');
     if ($searchTags->length) {
         foreach ($searchTags as $searchTag) {
             $paramTags = array();
             $paramTags[] = $searchTag->getElementsByTagName('atm-search-param');
             $paramTags[] = $searchTag->getElementsByTagName('atm-search-limit');
             $paramTags[] = $searchTag->getElementsByTagName('atm-search-page');
             $paramTags[] = $searchTag->getElementsByTagName('atm-search-order');
             foreach ($paramTags as $paramTagType) {
                 foreach ($paramTagType as $paramTag) {
                     if ($paramTag->hasAttribute('value') && $paramTag->getAttribute('value') == 'block') {
                         $this->_canhasParameters = true;
                         //check for mandatory block parameter value (all are mandatory except for atm-search-param which is explicitely defined)
                         if ($paramTag->getAttribute('mandatory') == 'true' && $paramTag->tagName == 'atm-search-param' || $paramTag->tagName != 'atm-search-param') {
                             $this->_musthaveParameters = true;
                             return true;
                         }
                     }
                 }
             }
         }
     }
     // if we are here it means that no search mandatory atm-search-param was found
     // Let's check for atm-blockvar elements
     $blockVarsTags = $domdocument->getElementsByTagName('atm-blockvar');
     if ($blockVarsTags->length) {
         // at least one atm-blockvar was found, so the tag can have parameters
         $this->_canhasParameters = true;
         foreach ($blockVarsTags as $blockVarTag) {
             if ($blockVarTag->getAttribute('mandatory') == 'true') {
                 // a mandatory value was found, no need to continue the loop
                 $this->_musthaveParameters = true;
                 return true;
             }
         }
     }
     return true;
 }
Example #12
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     $params = $this->getParamsValues();
     switch ($name) {
         case 'label':
             return isset($params['html']) && $params['html'] ? $this->getLabel() : io::htmlspecialchars($this->getLabel());
             break;
         case 'txtvalue':
             if (isset($params['html']) && $params['html']) {
                 return strip_tags(str_replace('<br />', "\n", str_replace(array("\n", "\r"), "", $this->_evalPHPContent($this->_subfieldValues[0]->getValue()))));
             } else {
                 return $this->_subfieldValues[0]->getValue();
             }
             break;
         case 'htmlvalue':
         case 'value':
             //do not put an htmlspecialchars on text only value because line-breaks are auto converted to <br /> tags
             if (isset($params['html']) && $params['html']) {
                 return $this->_evalPHPContent($this->_subfieldValues[0]->getValue());
             } else {
                 return $name == 'value' ? str_replace('<br />', "\n", str_replace(array("\n", "\r"), "", $this->_subfieldValues[0]->getValue())) : sensitiveIO::convertTextToHTML($this->_subfieldValues[0]->getValue(), false);
             }
             break;
         case 'hasvalue':
             return $this->_subfieldValues[0]->getValue() ? true : false;
             break;
         case 'rawvalue':
             return $this->_subfieldValues[0]->getValue();
             break;
         default:
             return parent::getValue($name, $parameters);
             break;
     }
 }
    CMS_grandFather::raiseError('Unknown window Id ...');
    $view->show();
}
//load module
$module = CMS_modulesCatalog::getByCodename($codename);
if (!$module) {
    CMS_grandFather::raiseError('Unknown module or module for codename : ' . $codename);
    $view->show();
}
//CHECKS user has module clearance
if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
    CMS_grandFather::raiseError('User has no rights on module : ' . $codename);
    $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($cms_language))));
    $view->show();
}
$moduleLabel = sensitiveIO::sanitizeJSString(io::htmlspecialchars($module->getLabel($cms_language)));
$jscontent = <<<END
\tvar moduleCategoriesWindow = Ext.getCmp('{$winId}');
\tvar fatherWindow = Ext.getCmp('{$fatherId}');
\t//do not allow change of maxDepth before layout is completely done
\tvar allowChangeMaxdepth = false;
\t
\tvar categoryWindows = [];
\t
\tvar tree = new Ext.tree.TreePanel({
\t\ttitle:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_DRAG_DROP)}',
\t\tautoScroll:\t\ttrue,
        animate:\t\ttrue,
        region:\t\t\t'center',
\t\tborder:\t\t\tfalse,
\t\tenableDD:\t\ttrue,
Example #14
0
 /**
  * Parse the content of a template for module parameters and returns the content.
  * Usually used by the getData() function to handle template files and feed them with module parameters
  *
  * @param string $filename The filename of the template, located in the templates directory
  * @return string the data from the rows.
  * @access private
  */
 protected function _parseTemplateForParameters($filename)
 {
     $module = CMS_modulesCatalog::getByCodename($this->_attributes["module"]);
     if (!$module instanceof CMS_module) {
         $this->raiseError("No module defined for the clientspace");
         return false;
     }
     $parameters = $module->getParameters();
     $templateFile = new CMS_file(PATH_TEMPLATES_FS . "/" . $filename);
     if ($templateFile->exists()) {
         $cdata = $templateFile->getContent();
         //no need to be complicated if no parameters
         if (!$parameters) {
             return $cdata;
         }
         //"parse" template for parameters. No XML parsing (PHP code produces strange results)
         //MUST wipe out the linefeeds, because pcre's stop at them !!!
         $cdata_pcre = str_replace("\n", "§§", $cdata);
         while (true) {
             unset($regs);
             preg_match('/(.*)(<module-param [^>]*\\/>)(.*)/', $cdata_pcre, $regs);
             if (isset($regs[2])) {
                 $param_value = '';
                 $domdocument = new CMS_DOMDocument();
                 try {
                     $domdocument->loadXML('<dummy>' . $regs[2] . '</dummy>');
                 } catch (DOMException $e) {
                     $this->raiseError('Parse error during search for module-param parameters : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($regs[2]));
                     return false;
                 }
                 $paramsTags = $domdocument->getElementsByTagName('module-param');
                 foreach ($paramsTags as $paramTag) {
                     $param_value = str_replace("\n", "§§", $parameters[$paramTag->getAttribute("name")]);
                 }
                 $cdata_pcre = $regs[1] . $param_value . $regs[3];
             } else {
                 break;
             }
         }
         $cdata = str_replace("§§", "\n", $cdata_pcre);
         return $cdata;
     } else {
         $this->raiseError("Template " . $filename . " isn't readable");
         return false;
     }
 }
Example #15
0
		//load interface
		Automne.load(' . sensitiveIO::jsonEncode($userSessionsInfos) . ');
		//display welcome message
		Automne.message.show(\'' . sensitiveIO::sanitizeJSString($welcome) . '\', \'' . sensitiveIO::sanitizeJSString($welcomeMsg) . '\', \'\', 6);
		';
            //add all JS locales
            $jscontent .= CMS_session::getJSLocales();
            $view->addJavascript($jscontent);
            $view->show(CMS_view::SHOW_RAW);
        } else {
            unset($cms_user);
        }
        break;
}
//Send Login form window
$applicationLabel = io::htmlspecialchars(APPLICATION_LABEL);
$loginURL = PATH_ADMIN_WR . '/login-form.php?_ts=' . time();
$rootPath = PATH_REALROOT_WR;
$jscontent = <<<END
\tvar loginWindow = new Automne.frameWindow({
\t\ttitle: \t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE, array($applicationLabel))}',
\t\tid:\t\t\t\t'loginWindow',
\t\tframeURL:\t\t'{$loginURL}',
\t\tallowFrameNav:\ttrue,
\t\twidth: \t\t\t400,
\t\theight:\t\t\t218,
\t\tresizable:\t\tfalse,
\t\tmaximizable:\tfalse,
\t\tautoScroll:\t\tfalse,
\t\tbodyStyle:\t\t'padding:5px;overflow:hidden;'
\t});
Example #16
0
    function getHTMLSubFieldsParametersEmailBody($language, $prefixName)
    {
        global $cms_language, $moduleCodename, $object;
        $module = CMS_modulesCatalog::getByCodename($moduleCodename);
        $params = $this->getParamsValues();
        $values = $this->_parameterValues;
        $parameters = $this->getSubFieldParameters();
        $htmlSelected = !isset($params['emailBody']['type']) || $params['emailBody']['type'] == 1 ? ' checked="checked"' : '';
        $input = '
		<fieldset>
			<legend><label for="' . $prefixName . 'message_body_html"><input' . $htmlSelected . ' id="' . $prefixName . 'message_body_html" type="radio" name="' . $prefixName . 'emailBody" value="1" />' . $cms_language->getMessage(self::MESSAGE_OBJECT_EMAIL_PARAMETER_BODY_HTML, false, MOD_POLYMOD_CODENAME) . '</label></legend>';
        foreach ($parameters as $parameterID => $parameter) {
            $paramValue = $values[$parameterID];
            if ($parameter["type"] == "emailbody") {
                $html = isset($params['emailBody']['html']) ? $params['emailBody']['html'] : '';
                $input .= '<textarea class="admin_textarea" cols="100" rows="15" name="' . $prefixName . 'emailBody_html">' . $module->convertDefinitionString($html, true) . '</textarea>';
            }
        }
        $pageSelected = isset($params['emailBody']['type']) && $params['emailBody']['type'] == 2 ? ' checked="checked"' : '';
        $pageID = isset($params['emailBody']['pageID']) ? $params['emailBody']['pageID'] : '';
        $pageURL = isset($params['emailBody']['pageURL']) ? $params['emailBody']['pageURL'] : '';
        $input .= '
		</fieldset>
		<fieldset>
			<legend><label for="' . $prefixName . 'message_body_page"><input' . $pageSelected . ' id="' . $prefixName . 'message_body_page" type="radio" name="' . $prefixName . 'emailBody" value="2" />' . $cms_language->getMessage(self::MESSAGE_OBJECT_EMAIL_PARAMETER_BODY_PAGE, false, MOD_POLYMOD_CODENAME) . '</label></legend>
			<input type="text" class="admin_input_text" id="' . $prefixName . 'emailBody_pageID" name="' . $prefixName . 'emailBody_pageID" value="' . io::htmlspecialchars($pageID) . '" size="6" />';
        //build tree link
        $grand_root = CMS_tree::getRoot();
        $href = PATH_ADMIN_SPECIAL_TREE_WR;
        $href .= '?root=' . $grand_root->getID();
        $href .= '&amp;heading=' . $cms_language->getMessage(MESSAGE_PAGE_TREEH1);
        $href .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $prefixName . "emailBody_pageID').value = '%s';self.close();");
        $href .= '&encodedPageLink=' . base64_encode('false');
        $input .= '&nbsp;<a href="' . $href . '" class="admin" target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/picto-arbo.gif" border="0" align="absmiddle" /></a>
			&nbsp;?<input type="text" size="80" name="' . $prefixName . 'emailBody_pageURL" value="' . io::htmlspecialchars($module->convertDefinitionString($pageURL, true)) . '" class="admin_input_text" />
		</fieldset>';
        //object Explanation
        $input .= '
			<fieldset>
				<legend>' . $cms_language->getMessage(self::MESSAGE_OBJECT_EMAIL_PARAMETER_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '</legend>
				<br />';
        if (!isset($_POST['objectexplanation'])) {
            $_POST['objectexplanation'] = '';
        }
        //selected value
        $selected['working'] = $_POST['objectexplanation'] == 'working' ? ' selected="selected"' : '';
        $selected['working-polymod'] = $_POST['objectexplanation'] == 'working-polymod' ? ' selected="selected"' : '';
        $selected['vars'] = $_POST['objectexplanation'] == 'vars' ? ' selected="selected"' : '';
        $selected['search'] = $_POST['objectexplanation'] == 'search' ? ' selected="selected"' : '';
        $input .= '
			<select name="objectexplanation" class="admin_input_text" onchange="document.getElementById(\'cms_action\').value=\'switchexplanation\';document.frm.submit();">
				<option value="">' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_CHOOSE) . '</option>
				<optgroup label="' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_ROW_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">
					<option value="search"' . $selected['search'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_SEARCH_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
					<option value="working"' . $selected['working'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_TAGS) . '</option>
					<option value="working-polymod"' . $selected['working-polymod'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_POLYMOD_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
					<option value="vars"' . $selected['vars'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_BLOCK_GENERAL_VARS) . '</option>
					</optgroup>
				<optgroup label="' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_ROW_OBJECTS_VARS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">';
        $input .= CMS_poly_module_structure::viewObjectInfosList($moduleCodename, $cms_language, $_POST['objectexplanation'], $object->getID());
        $input .= '
				</optgroup>';
        $input .= '
			</select><br /><br />';
        //then display chosen object infos
        if ($_POST['objectexplanation']) {
            switch ($_POST['objectexplanation']) {
                case 'search':
                    $input .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_SEARCH_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                    break;
                case 'working':
                    $content .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_TAGS_EXPLANATION);
                    break;
                case 'working-polymod':
                    $content .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_POLYMOD_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                    break;
                case 'vars':
                    $content .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_BLOCK_GENERAL_VARS_EXPLANATION);
                    break;
                default:
                    //object info
                    $input .= CMS_poly_module_structure::viewObjectRowInfos($moduleCodename, $cms_language, $_POST['objectexplanation']);
                    break;
            }
        }
        $input .= '</fieldset>';
        return $input;
    }
Example #17
0
 /**
  * Get the HTML output
  *
  * @return string The HTML
  * @access public
  */
 function getOutput($register = false)
 {
     if ($this->hasError()) {
         return '';
     }
     //computes the targets (from selection)
     $this->_targets = $this->_buildTargets();
     //set output
     $output = '';
     if ($this->_type == 'recursivelinks') {
         $root = CMS_tree::getRoot();
         $lineage = CMS_tree::getLineage($root->getID(), $this->_page->getID(), false, $this->_publicTree);
         if (is_array($this->_displays)) {
             foreach ($this->_displays as $display) {
                 $html = $display->getRecursiveOutput($this->_page, 0, $this->_recursiveTargets, $this->_targets, $this->_publicTree, $lineage);
                 if ($html) {
                     $output .= $html;
                     break;
                 }
             }
         }
     } else {
         if (is_array($this->_displays)) {
             foreach ($this->_displays as $display) {
                 $displayOutput = '';
                 if (is_array($this->_targets) && $this->_targets) {
                     $sizeofTargets = sizeof($this->_targets);
                     for ($i = 0; $i < $sizeofTargets; $i++) {
                         $target = $this->_targets[$i];
                         $displayOutput .= $display->getOutput($this->_page, $target, $this->_publicTree, $i + 1, $this->_noerror, $this->_noselection);
                     }
                     $output .= $display->getSubLevelOutput($displayOutput);
                 } elseif (is_object($this->_noselection)) {
                     $output .= CMS_DOMDocument::DOMElementToString($this->_noselection, true);
                 }
             }
         }
     }
     if ($register) {
         $this->_register();
     }
     //append args to generated linx code
     if ($this->_args) {
         //append atm-row class and row-id to all first level tags found in row datas
         $domdocument = new CMS_DOMDocument();
         try {
             $domdocument->loadXML('<linx>' . $output . '</linx>');
         } catch (DOMException $e) {
             $this->raiseError('Parse error for linx : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($output));
             return '';
         }
         $rowNodes = $domdocument->getElementsByTagName('linx');
         if ($rowNodes->length == 1) {
             $rowXML = $rowNodes->item(0);
         }
         $elements = array();
         if (isset($rowXML)) {
             foreach ($rowXML->childNodes as $rowChildNode) {
                 if (is_a($rowChildNode, 'DOMElement') && $rowChildNode->tagName != 'script') {
                     if ($this->_args['class'] !== false) {
                         if ($rowChildNode->hasAttribute('class')) {
                             $rowChildNode->setAttribute('class', $rowChildNode->getAttribute('class') . ' ' . $this->_args['class']);
                         } else {
                             $rowChildNode->setAttribute('class', $this->_args['class']);
                         }
                     }
                     if ($this->_args['id'] !== false) {
                         $rowChildNode->setAttribute('id', $this->_args['id']);
                     }
                 }
             }
             $output = CMS_DOMDocument::DOMElementToString($rowXML, true);
         } else {
             $output = '';
         }
     }
     return $output;
 }
Example #18
0
// $Id: backtrace.php,v 1.3 2010/03/08 16:41:17 sebastien Exp $
/**
 * PHP page : Backtrace debug page
 *
 * @package Automne
 * @subpackage admin
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
$dialog = new CMS_dialog();
$dialog->setTitle('Automne :: Debug :: BackTrace', 'pic_meta.gif');
$backTraceName = $_GET['bt'];
if (!$backTraceName) {
    $content = 'Cannot backtrace, datas missing ...';
} else {
    //get backtrace from cache object
    $cache = new CMS_cache($backTraceName, 'atm-backtrace', 600, false);
    //load cache content
    if (!$cache->exist() || !($datas = $cache->load())) {
        $content = 'Cannot backtrace, datas missing ...';
    } else {
        $content = '
		<h3>Backtrace:</h3>
		' . $datas['summary'] . '<br />
		<h3>Backtrace Detail:</h3>
		<pre>' . io::htmlspecialchars($datas['backtrace']) . '</pre>
		';
    }
}
$dialog->setContent($content);
$dialog->show();
}
//load module
$module = CMS_modulesCatalog::getByCodename($codename);
if (!$module) {
    CMS_grandFather::raiseError('Unknown module or module for codename : ' . $codename);
    $view->show();
}
//CHECKS user has module clearance
if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
    CMS_grandFather::raiseError('User has no rights on module : ' . $codename);
    $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($cms_language))));
    $view->show();
}
//get queried module categories
$attrs = array("module" => $codename, "language" => $cms_language, "level" => $rootId, "root" => $rootId ? false : 0, "attrs" => false, "cms_user" => $cms_user);
$categories = CMS_module::getModuleCategories($attrs);
$nodes = array();
foreach ($categories as $category) {
    $parentRight = sensitiveIO::isPositiveInteger($category->getAttribute('parentID')) ? $cms_user->hasModuleCategoryClearance($category->getAttribute('parentID'), CLEARANCE_MODULE_MANAGE) : $cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT);
    $categoryRight = $cms_user->hasModuleCategoryClearance($category->getID(), CLEARANCE_MODULE_MANAGE);
    $hasSiblings = $category->hasSiblings();
    $qtip = $category->getIconPath(false, PATH_RELATIVETO_WEBROOT, true) ? '<img style="max-width:280px;" src="' . $category->getIconPath(true) . '" /><br />' : '';
    $qtip .= $category->getDescription() ? $category->getDescription() . '<br />' : '';
    if ($category->isProtected()) {
        $qtip .= '<strong>' . $cms_language->getMessage(MESSAGE_CATEGORY_PROTECTED) . ' : </strong>' . $cms_language->getMessage(MESSAGE_CATEGORY_PROTECTED_DESC) . '<br />';
    }
    $qtip .= 'ID : ' . $category->getID();
    $nodes[] = array('id' => 'cat' . $category->getID(), 'catId' => $category->getID(), 'text' => ($category->isProtected() ? '<span style="color:grey;"' . ($qtip ? ' ext:qtip="' . io::htmlspecialchars($qtip) . '"' : '') . '>' : '') . $category->getLabel() . ($category->isProtected() ? '</span>' : ''), 'leaf' => !$hasSiblings, 'qtip' => $qtip ? $qtip : false, 'draggable' => $parentRight && !$category->isProtected(), 'allowDrop' => $categoryRight, 'allowChildren' => true, 'disabled' => !$categoryRight, 'deletable' => $categoryRight && !$hasSiblings && !$category->isProtected() && !$module->isCategoryUsed($category), 'manageable' => $categoryRight, 'expanded' => sizeof($category->getLineageStack()) < $maxDepth, 'protected' => $category->isProtected() && !$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL));
}
$view->setContent($nodes);
$view->show();
Example #20
0
 /**
  * get labels for object structure and functions
  *
  * @return array : the labels of object structure and functions
  * @access public
  */
 function getLabelsStructure(&$language, $objectName)
 {
     $labels = array();
     $object = new CMS_poly_object($this->_objectID);
     $labels['structure']['label'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_LABEL_DESCRIPTION, false, MOD_POLYMOD_CODENAME);
     $labels['structure']['fieldname'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_FIELDNAME_DESCRIPTION, array($this->getFieldLabel($language)), MOD_POLYMOD_CODENAME);
     $labels['structure']['fieldID'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_FIELDID_DESCRIPTION, array($this->_field->getID()), MOD_POLYMOD_CODENAME);
     $labels['structure']['required'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_REQUIRED_DESCRIPTION, false, MOD_POLYMOD_CODENAME);
     $labels['structure']['objectname'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_OBJECTNAME_DESCRIPTION, array($object->getFieldLabel($language)), MOD_POLYMOD_CODENAME);
     $labels['structure']['objectdescription'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_OBJECTDESC_DESCRIPTION, array($object->getFieldDesc($language)), MOD_POLYMOD_CODENAME);
     $labels['structure']['objecttype'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_OBJECTTYPE_DESCRIPTION, array($this->_objectID), MOD_POLYMOD_CODENAME);
     $labels['structure']['ids'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_IDS_DESCRIPTION, array($object->getFieldLabel($language)), MOD_POLYMOD_CODENAME);
     $labels['structure']['fields'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_FIELDS_DESCRIPTION, array($object->getFieldLabel($language)), MOD_POLYMOD_CODENAME);
     $labels['structure']['count'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_COUNT_DESCRIPTION, array($object->getFieldLabel($language)), MOD_POLYMOD_CODENAME);
     $labels['structure']['description'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_FIELD_DESC_DESCRIPTION, array(io::htmlspecialchars($this->getFieldDescription($language))), MOD_POLYMOD_CODENAME);
     $labels['function']['selectOptions'] = $language->getMessage(self::MESSAGE_MULTI_OBJECT_FUNCTION_SELECTOPTIONS_DESCRIPTION, array('{' . $objectName . '}'), MOD_POLYMOD_CODENAME);
     return $labels;
 }
Example #21
0
    /**
     * 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 .= '&amp;heading=' . $cms_language->getMessage(self::MESSAGE_PAGE_TREEH1);
                $href .= '&amp;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;
    }
Example #22
0
 /**
  * Raises an error. Shows it to the screen
  * Deprecated, use raiseError instead
  * @param string $errorMessage the error message.
  * @param boolean $encodeOutput, does the screen output should be encoded (default : false)
  * @return void
  * @access public
  */
 public function _raiseError($errorMessage, $encodeOutput = false, $error = true)
 {
     static $errorNumber;
     $systemDebug = !defined('SYSTEM_DEBUG') ? true : SYSTEM_DEBUG;
     if (isset($this) && isset($this->_debug) && $this->_debug === NULL) {
         $this->_debug = $systemDebug;
     }
     if ($errorMessage) {
         //second condition are for static calls (made by static methods)
         if (!defined('APPLICATION_EXEC_TYPE') || APPLICATION_EXEC_TYPE == 'http' && (!isset($this) && $systemDebug || isset($this) && isset($this->_debug) && $this->_debug)) {
             $backTrace = $backTraceLink = '';
             if (version_compare(phpversion(), "5.2.5", "<")) {
                 $bt = @array_reverse(debug_backtrace());
             } else {
                 $bt = @array_reverse(debug_backtrace(false));
             }
             $backtrace = array('summary' => sensitiveIO::printBackTrace($bt), 'backtrace' => @print_r($bt, true));
             $backtraceName = 'bt_' . md5(rand());
             $backTraceLink = PATH_ADMIN_WR . '/backtrace.php?bt=' . $backtraceName;
             //save backtrace to cache (for 10 min)
             $cache = new CMS_cache($backtraceName, 'atm-backtrace', 600, false);
             if ($cache) {
                 $cache->save($backtrace);
             }
             unset($backtrace, $cache, $bt);
             //append error to current view
             $view = CMS_view::getInstance();
             $outputMessage = $encodeOutput ? io::htmlspecialchars($errorMessage) : $errorMessage;
             $view->addError(array('error' => $outputMessage, 'backtrace' => $backTraceLink));
         }
         //second condition are for static calls (made by static methods)
         if (!isset($this) || !isset($this->_log) || $this->_log) {
             if (@file_put_contents(PATH_MAIN_FS . '/' . self::ERROR_LOG, date("Y-m-d H:i:s", time()) . '|' . APPLICATION_EXEC_TYPE . '|' . $errorMessage . "\n", FILE_APPEND) !== false) {
                 CMS_file::chmodFile(FILES_CHMOD, PATH_MAIN_FS . '/' . self::ERROR_LOG);
             } else {
                 die('<pre><b>' . CMS_view::SYSTEM_LABEL . ' ' . AUTOMNE_VERSION . ' error : /automne dir is not writable' . "</b></pre>\n");
             }
         }
     }
     //must be at the end because it interferes with the static calls conditions above
     if ($error && isset($this)) {
         $this->_errRaised = true;
     }
 }
Example #23
0
 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);
 }
Example #24
0
 function getJSonDescription($user, $cms_language, $withDefinition = false)
 {
     $hasClientSpaces = $this->hasClientSpaces();
     $shortdesc = sensitiveIO::ellipsis($this->getDescription(), 60);
     if ($shortdesc != nl2br($this->getDescription())) {
         $shortdesc = '<span class="atm-help" ext:qtip="' . nl2br(io::htmlspecialchars(strip_tags($this->getDescription()))) . '">' . io::htmlspecialchars($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() : '';
     //templates filters
     $filteredTemplates = '';
     if ($this->getFilteredTemplates()) {
         foreach ($this->getFilteredTemplates() as $tplId) {
             $template = CMS_pageTemplatesCatalog::getByID($tplId);
             if (is_object($template) && !$template->hasError()) {
                 $filteredTemplates .= $filteredTemplates ? ', ' : '';
                 $filteredTemplates .= $template->getLabel();
             }
         }
     }
     $filtersInfos = '';
     $filtersInfos .= $filteredTemplates ? $cms_language->getMessage(self::MESSAGE_DESC_TEMPLATES) . ' ' . $filteredTemplates : '';
     $filtersInfos = $filtersInfos ? '<br />' . $cms_language->getMessage(self::MESSAGE_DESC_USAGE_RESTRICTION) . ' <strong>' . $filtersInfos . '</strong>' : '';
     if ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_TEMPLATES)) {
         $edit = array('url' => 'row.php', 'params' => array('row' => $this->getID()));
     } else {
         $edit = false;
     }
     return array('id' => $this->getID(), 'label' => $this->getLabel(), 'type' => $cms_language->getMessage(self::MESSAGE_DESC_ROW_TEMPLATE), 'image' => $this->getImage(), 'groups' => implode(', ', $this->getGroups()), 'filter' => $this->getLabel() . ' ' . implode(', ', $this->getGroups()), 'tplfilter' => implode(',', $this->getFilteredTemplates()), 'description' => '<div' . (!$this->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . $this->getImage() . '" style="float:left;margin-right:3px;width:70px;" />' . $mediumdesc . $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>' . ($hasClientSpaces ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong>' . ($hasClientSpaces ? ' - <a href="#" onclick="Automne.view.search(\'row:' . $this->getID() . '\');return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_SEE) . '</a>' . ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) ? ' / <a href="#" onclick="Automne.server.call(\'rows-controler.php\', \'\', {rowId:' . $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_FILE) . ' <strong>' . $this->getDefinitionFileName() . '</strong>' . $filtersInfos . '<br class="x-form-clear" />' . '</div>', 'activated' => $this->isUseable() ? true : false, 'used' => $hasClientSpaces, 'definition' => $definitionDatas, 'edit' => $edit, 'shortdesc' => $shortdesc);
 }
Example #25
0
         $cms_page = CMS_session::getPage();
         if (is_object($cms_page) && !$cms_page->hasError()) {
             $parameters['pageID'] = $cms_page->getID();
         }
         $parameters['selection'] = io::decodeEntities($selectedContent);
         $parameters['public'] = false;
         $parameters['plugin-view'] = true;
         $definitionParsing = new CMS_polymod_definition_parsing($definition, true, CMS_polymod_definition_parsing::PARSE_MODE);
         $codeTopaste = $definitionParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
         //add some attributes to images to prevent resizing into editor
         $codeTopaste = str_replace('<img ', '<img contenteditable="false" unselectable="on" ', $codeTopaste);
         //encode all ampersand without reencode already encoded ampersand
         $codeTopaste = sensitiveIO::reencodeAmpersand($codeTopaste);
         if ($codeTopaste) {
             //add identification span tag arround code to paste
             $codeTopaste = '<span id="polymod-' . $pluginId . '-' . $itemId . '" class="polymod" title="' . io::htmlspecialchars($selectedPlugin->getLabel($cms_language) . ' : ' . trim($item->getLabel($cms_language))) . '">' . $codeTopaste . '</span>';
         }
         $content = $codeTopaste;
     } elseif (sensitiveIO::isPositiveInteger($itemId) && $selectedPlugin->needSelection()) {
         $codeTopaste = '<span id="polymod-' . $pluginId . '-' . $itemId . '" class="polymod">' . $selectedContent . '</span>';
         $content = $codeTopaste;
     } else {
         $selectedContent = $selectedContent ? $selectedContent : ' ';
         $content = $selectedContent;
     }
     break;
 case 'setRowParameters':
     $tpl = sensitiveIO::request('template', 'sensitiveIO::isPositiveInteger');
     $rowId = sensitiveIO::request('rowType', 'sensitiveIO::isPositiveInteger');
     $rowTag = sensitiveIO::request('rowTag');
     $cs = sensitiveIO::request('cs');
Example #26
0
 /**
  * Return options tag list (for a select tag) of all float values for this field
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  *     selected : the float value which is selected (optional)
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag (nothing for this one)
  * @return string : options tag list
  * @access public
  */
 function selectOptions($values, $tags)
 {
     $return = "";
     $fieldID = $this->_field->getID();
     $allValues = array();
     $status = $this->_public ? 'public' : 'edited';
     // Search all values for this field
     $sql = "select\n                   distinct value\n               from\n                   mod_subobject_string_" . $status . "\n               where\n                   objectFieldID='" . $fieldID . "'\n\t\t";
     $q = new CMS_query($sql);
     while (($value = $q->getValue('value')) !== false) {
         if ($value) {
             $allValues[$value] = $value;
         }
     }
     if (is_array($allValues) && $allValues) {
         natsort($allValues);
         foreach ($allValues as $id => $label) {
             $selected = $id == $values['selected'] ? ' selected="selected"' : '';
             $return .= '<option title="' . io::htmlspecialchars($label) . '" value="' . $id . '"' . $selected . '>' . $label . '</option>';
         }
     }
     return $return;
 }
Example #27
0
 /**
  * Replace block definition vars.
  *
  * @param array data : the block datas
  * @param string html_attributes : html attributes
  * @param integer $location The location of the page
  * @param boolean $public The needed precision for USERSPACE location
  * @return string the HTML data
  * @access public
  */
 function _replaceBlockVars($data, $html_attributes, $location, $public)
 {
     switch ($location) {
         case RESOURCE_DATA_LOCATION_PUBLIC:
             $folder = $public ? "public" : "edited";
             break;
         case RESOURCE_DATA_LOCATION_ARCHIVED:
             $folder = "archived";
             break;
         case RESOURCE_DATA_LOCATION_DELETED:
             $folder = "deleted";
             break;
         case RESOURCE_DATA_LOCATION_EDITION:
             $folder = "edition";
             break;
     }
     $currentLink = new CMS_href($data["externalLink"]);
     //must put the main website URL before
     $html_imgZoomHtml = '';
     $html_imgZoomName = '';
     $html_imageZoomHref = '';
     $html_imageZoomPop = '';
     if ($public && ALTERNATIVE_DOMAIN) {
         $domain = ALTERNATIVE_DOMAIN;
     } else {
         $domain = CMS_websitesCatalog::getCurrentDomain(@$this->_pageID);
     }
     if ($data["file"]) {
         $html_img = '<img src="' . $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["file"] . '" alt="' . io::htmlspecialchars($data["label"]) . '" ' . $html_attributes . ' />';
     }
     if ($data["enlargedFile"]) {
         $html_imgZoomName = $data["enlargedFile"];
         $html_imgZoomHtml = '<img src="' . $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["enlargedFile"] . '" alt="' . io::htmlspecialchars($data["label"]) . '" ' . $html_attributes . ' />';
     }
     if ($data["enlargedFile"]) {
         $href = OPEN_ZOOMIMAGE_IN_POPUP ? CMS_websitesCatalog::getCurrentDomain(@$this->_pageID) . PATH_REALROOT_WR . "/" . CMS_block_image::BLOCK_IMAGE_POPUP . '?location=' . $folder . '&amp;file=' . $data["enlargedFile"] . '&amp;label=' . urlencode($data["label"]) : $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["enlargedFile"];
         $popup = OPEN_ZOOMIMAGE_IN_POPUP ? ' onclick="javascript:CMS_openPopUpImage(\'' . addslashes($href) . '\');return false;"' : '';
         if ($html_img) {
             $html = '<a target="_blank" rel="atm-enlarge" href="' . $href . '"' . $popup . ' title="' . io::htmlspecialchars($data["label"]) . '">' . $html_img . '</a>';
         }
         $html_imageZoomHref = $href;
         $linkLabel = '<a class="imagezoomlink" target="_blank" href="' . $href . '"' . $popup . ' title="' . io::htmlspecialchars($data["label"]) . '">' . io::htmlspecialchars($data["label"]) . '</a>';
     } else {
         if ($currentLink->getHTML(false, MOD_STANDARD_CODENAME, $location)) {
             $html = $currentLink->getHTML($html_img, MOD_STANDARD_CODENAME, $location);
             $currentLink->setLabel('');
             $linkLabel = $currentLink->getHTML($data['label'], MOD_STANDARD_CODENAME, $location);
         } else {
             $html = $html_img;
             $linkLabel = io::htmlspecialchars($data["label"]);
         }
     }
     $replace = array('{{data}}' => $html, '{{label}}' => io::htmlspecialchars($data["label"]), '{{jslabel}}' => io::htmlspecialchars($data["label"]), '{{linkLabel}}' => $linkLabel, '{{imageZoomHtml}}' => $html_imgZoomHtml, '{{imagePath}}' => $domain . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder, '{{imageName}}' => $data["file"], '{{imageZoomHref}}' => $html_imageZoomHref, '{{imageZoomName}}' => $html_imgZoomName);
     if (io::strpos($this->_definition, 'Width}}') !== false || io::strpos($this->_definition, 'Height}}') !== false) {
         list($sizeX, $sizeY) = @getimagesize(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data["file"]);
         if (isset($data["enlargedFile"])) {
             list($sizeZoomX, $sizeZoomY) = @getimagesize(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data["enlargedFile"]);
         }
         $replace['{{imageWidth}}'] = isset($sizeX) ? $sizeX : "0";
         $replace['{{imageHeight}}'] = isset($sizeY) ? $sizeY : "0";
         $replace['{{imageZoomWidth}}'] = isset($sizeZoomX) ? $sizeZoomX : "0";
         $replace['{{imageZoomHeight}}'] = isset($sizeZoomY) ? $sizeZoomY : "0";
     }
     return str_replace(array_keys($replace), $replace, $this->_definition);
 }
Example #28
0
 /**
  * get labels for object structure and functions
  *
  * @return array : the labels of object structure and functions
  * @access public
  */
 function getLabelsStructure(&$language, $objectName = '')
 {
     $labels = array();
     $labels['structure']['label'] = $language->getMessage(self::MESSAGE_OBJECT_COMMON_LABEL_DESCRIPTION, false, MOD_POLYMOD_CODENAME);
     $labels['structure']['fieldname'] = $language->getMessage(self::MESSAGE_OBJECT_COMMON_FIELDNAME_DESCRIPTION, array(io::htmlspecialchars($this->getFieldLabel($language))), MOD_POLYMOD_CODENAME);
     $labels['structure']['fieldID'] = $language->getMessage(self::MESSAGE_OBJECT_COMMON_FIELDID_DESCRIPTION, array($this->_field->getID()), MOD_POLYMOD_CODENAME);
     $labels['structure']['value'] = $language->getMessage(self::MESSAGE_OBJECT_COMMON_VALUE_DESCRIPTION, false, MOD_POLYMOD_CODENAME);
     $labels['structure']['required'] = $language->getMessage(self::MESSAGE_OBJECT_COMMON_REQUIRED_DESCRIPTION, false, MOD_POLYMOD_CODENAME);
     $labels['structure']['description'] = $language->getMessage(self::MESSAGE_OBJECT_COMMON_FIELD_DESC_DESCRIPTION, array(io::htmlspecialchars($this->getFieldDescription($language))), MOD_POLYMOD_CODENAME);
     return $labels;
 }
Example #29
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     if (in_array($name, array('fieldname', 'required', 'fieldID', 'value'))) {
         return parent::getValue($name, $parameters);
     }
     $params = $this->getParamsValues();
     if ($name == 'hasValue') {
         return $this->_subfieldValues[0]->getValue() ? true : false;
     }
     //oembed values : first, get size parameters
     @(list($width, $height) = explode(',', str_replace(';', ',', $parameters)));
     if (!io::isPositiveInteger($width)) {
         $width = '';
     }
     if (!io::isPositiveInteger($height)) {
         $height = '';
     }
     //load oembed object
     if (in_array($name, array('html', 'width', 'height'))) {
         //size specific values : get oembed object at queried size
         if (!isset($this->_oembedObjects[$width . '-' . $height])) {
             $this->_oembedObjects[$width . '-' . $height] = new CMS_oembed($this->_subfieldValues[0]->getValue(), $width, $height, $params['embedlyKey']);
         }
         $oembed = $this->_oembedObjects[$width . '-' . $height];
     } else {
         if ($this->_oembedObjects) {
             //load current oembed object
             $oembed = current($this->_oembedObjects);
         } else {
             $this->_oembedObjects[$width . '-' . $height] = new CMS_oembed($this->_subfieldValues[0]->getValue(), $width, $height, $params['embedlyKey']);
             $oembed = $this->_oembedObjects[$width . '-' . $height];
         }
     }
     if (!$oembed->hasProvider()) {
         return '';
     }
     if ($name == 'authorName') {
         $name = 'author_name';
     }
     if ($name == 'authorUrl') {
         $name = 'author_url';
     }
     if ($name == 'authorName') {
         $name = 'author_name';
     }
     if ($name == 'providerUrl') {
         $name = 'provider_url';
     }
     switch ($name) {
         case 'html':
             return $oembed->getHTML(array('class' => 'atm-embed'));
             break;
         case 'thumb':
             return $oembed->getThumbnail(array('class' => 'atm-thumb-embed'));
             break;
         case 'providerName':
             return io::htmlspecialchars($oembed->getProviderName());
             break;
         case 'url':
             return $this->_subfieldValues[0]->getValue();
             break;
         case 'datas':
             return $oembed->getDatas();
             break;
         default:
             return io::htmlspecialchars($oembed->getData($name));
             break;
     }
 }
Example #30
0
 /**
  * Return given RSS feed informations
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  * 	selected : the selected rss ID
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag
  * 	... {url} ... {label} ... {description} ...
  * @return string : the RSS feed informations
  * @access public
  */
 function rss($values, $tags)
 {
     global $cms_language;
     if (!sensitiveIO::isPositiveInteger($values['selected'])) {
         $this->raiseError("Selected value parameter must be a valid RSS Feed ID : " . $values['selected']);
         return false;
     }
     $RSSDefinition = new CMS_poly_rss_definitions($values['selected']);
     if ($RSSDefinition->hasError()) {
         $this->raiseError("Selected value parameter must be a valid RSS Feed ID : " . $values['selected']);
         return false;
     }
     $linkParameters = '';
     if (sizeof($values) > 1) {
         foreach ($values as $key => $value) {
             if ($key != 'selected') {
                 $linkParameters .= '&amp;' . $key . '=' . io::htmlspecialchars($value);
             }
         }
     }
     $replace = array('{url}' => PATH_REALROOT_WR . '/rss/rss' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?id=' . $RSSDefinition->getID() . $linkParameters, '{label}' => $RSSDefinition->getLabel($cms_language), '{description}' => $RSSDefinition->getDescription($cms_language));
     $xml2Array = new CMS_xml2Array($tags);
     $return = $xml2Array->toXML($tags);
     $return = str_replace(array_keys($replace), $replace, $return);
     return $return;
 }