Example #1
0
 /**
  * @param array(CMS_users) $users users to send message to
  * @param array(CMS_profile_user) $users
  * @param array($language=>$subject) $messages indexed by languages code
  * @param array($language=>$subject) $subjects indexed by languages code
  * @param integer $alertLevel
  * @return void
  * @access public
  */
 function setUserMessages($users, $messages, $subjects, $alertLevel = ALERT_LEVEL_VALIDATION, $module = MOD_STANDARD_CODENAME)
 {
     $mainURL = CMS_websitesCatalog::getMainURL();
     $template = is_file(PATH_MAIL_TEMPLATES_FS) ? PATH_MAIL_TEMPLATES_FS : '';
     foreach ($users as $user) {
         //if is integer create user object
         if (!is_a($user, "CMS_user_profile") && SensitiveIO::isPositiveInteger($user)) {
             $user = CMS_profile_usersCatalog::getByID($user);
         }
         //if user hasn't alert level for this module or user is not active anymore, skip it
         if (!$user->hasAlertLevel($alertLevel, $module) || $user->isDeleted() || !$user->isActive()) {
             //CMS_grandFather::raiseError('user '.$user->getFullName().' has no alerts for level '.$alertLevel.' for module '.$module);
             continue;
         }
         $userLang = $user->getLanguage();
         $email = new CMS_email();
         if ($user->getEmail()) {
             if ($email->setEmailTo($user->getEmail())) {
                 $email->setSubject($subjects[$userLang->getCode()], true);
                 $email->setBody($messages[$userLang->getCode()]);
                 $email->setFooter($userLang->getMessage(self::MESSAGE_EMAIL_BODY_URLS, array(APPLICATION_LABEL, $mainURL . "/", $mainURL . PATH_ADMIN_WR . "/")));
                 $email->setTemplate($template);
                 $this->_messages[] = $email;
             } else {
                 $this->raiseError("Email Catalog: email invalid (" . $user->getEmail() . ") for user : " . $user->getFullName());
             }
         }
     }
 }
Example #2
0
 /**
  * Compute the tag
  *
  * @return string the PHP / HTML content computed
  * @access private
  */
 protected function _compute()
 {
     if ($this->_parameters['context'] == CMS_XMLTag::HTML_CONTEXT) {
         if (!isset($this->_computeParams['object']) || !$this->_computeParams['object'] instanceof CMS_page) {
             return '';
         }
         return CMS_websitesCatalog::getWebsiteValue($this->_computeParams['object']->getWebsite()->getID(), $this->_attributes['name']);
     } else {
         return '$content .= CMS_websitesCatalog::getWebsiteValue(CMS_tree::getPageValue($parameters[\'pageID\'], \'website\'), \'' . $this->_attributes['name'] . '\');';
     }
 }
Example #3
0
     //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);
     if ($draggable) {
         $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVE_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVE_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-move',\n\t\t\t\t\t\t\t\t\t\thandler: function() {\n\t\t\t\t\t\t\t\t\t\t\t//create window element\n\t\t\t\t\t\t\t\t\t\t\tvar win = new Automne.Window({\n\t\t\t\t\t\t\t\t\t\t\t\tid:\t\t\t\t'pageMoveWindow',\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t" . $cms_page->getID() . ",\n\t\t\t\t\t\t\t\t\t\t\t\tautoLoad:\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t'tree.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\tparams:\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twinId:\t\t'pageMoveWindow',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:" . $cms_page->getID() . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenableDD:\ttrue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\theading:\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVE_PAGE_USING_ICONS) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle:\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVING_PAGE) . "'\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\tnocache:\ttrue,\n\t\t\t\t\t\t\t\t\t\t\t\t\tscope:\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\twin.show(this.getEl());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));";
     }
 }
 //page copy
 $panelContent .= $pageCopy;
 if (!$cms_page->isProtected()) {
     //archiving
     if (!$hasSiblings) {
         $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_ARCHIVING_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_ARCHIVING_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-archiving',\n\t\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_ARCHIVING_PAGE_CONFIRM) . "',\n\t\t\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\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\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\t\t\tif (button == 'ok') {\n\t\t\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\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\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\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'archive'\n\t\t\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\t\t});\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}\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}));";
     }
     //deletion
     if (!$hasSiblings && !CMS_websitesCatalog::isWebsiteRoot($cms_page->getID())) {
         $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETING_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETING_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-deletion',\n\t\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETING_PAGE_CONFIRM) . "',\n\t\t\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\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\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\t\t\tif (button == 'ok') {\n\t\t\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\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\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\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'delete'\n\t\t\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\t\t});\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}\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}));";
     }
 }
 //page editions cancelling
 $editions = $cms_page->getStatus()->getEditions();
 if ($cms_page->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && $editions & RESOURCE_EDITION_CONTENT) {
     $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-editions-cancelling',\n\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_CONFIRM) . "',\n\t\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\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\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\t\tfn: \t\t\t\tfunction (button) {\n\t\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\t\ttabs.setActiveTab('public');\n\t\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\t\turl:\t\t\t\t'page-controler.php',\n\t\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\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'cancel_editions'\n\t\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\t\tfcnCallback: \t\tfunction() {\n\t\t\t\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\t\t\t\ttabs.getPageInfos({\n\t\t\t\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\t\t\t\tnoreload:\ttrue\n\t\t\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\t\t},\n\t\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\t});\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}));";
 }
 if ($editions & RESOURCE_EDITION_CONTENT && $cms_user->hasValidationClearance(MOD_STANDARD_CODENAME)) {
     //validate
     $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION_MODIFICATIONS) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-validate',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call('validations-controler.php', function(response, options, jsonResponse){\n\t\t\t\t\t\t\t\t\t\t\tif (!jsonResponse.success) {\n\t\t\t\t\t\t\t\t\t\t\t\t//get validation message\n\t\t\t\t\t\t\t\t\t\t\t\tif (response.responseXML && response.responseXML.getElementsByTagName('message').length) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar message = response.responseXML.getElementsByTagName('message').item(0).firstChild.nodeValue;\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\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\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\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\t\taction:\t\t\t\t'validateById',\n\t\t\t\t\t\t\t\t\t\t\tresource:\t\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\tmodule:\t\t\t\t'" . MOD_STANDARD_CODENAME . "',\n\t\t\t\t\t\t\t\t\t\t\tevalMessage:\t\tfalse\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}));";
 }
 $endPublication = $cms_page->getPublicationDateEnd(false);
 $now = new CMS_date();
 $now->setNow();
 /**
  * public static getCloneFromID
  *
  * Clones a Template, changes some attributes
  * and writes it to persistence (MySQL for now)
  *
  * @param anyTemplateID as the ID of Template to be cloned
  * @param String label receive a new label for this Template
  * @param boolean $setPrivate Should the template be set as a private one ?  ALSO determines if the new template should point to the same file
  * @param boolean $dontCopyClientSpaces Should the clientspaces be copied ?
  * @param integer $tplFrom the original template ID to get good rows
  * @return a valid new CMS_pageTemplate
  */
 static function getCloneFromID($templateID = 0, $label = false, $setPrivate = false, $dontCopyClientSpaces = false, $tplFrom = false)
 {
     $ret = false;
     $model = new CMS_pageTemplate($templateID);
     if ($model->getID() > 0) {
         //New blank one
         $tpl = new CMS_pageTemplate();
         //First write a new object to get it's ID
         $tpl->writeToPersistence();
         //Setting label
         $label = $label ? $label : $model->getLabel();
         $tpl->setLabel($label);
         //Copying template definition file (if not private template)
         if ($setPrivate) {
             $filename = $model->getDefinitionFile();
         } else {
             $filename = "pt" . $tpl->getID() . "_" . SensitiveIO::sanitizeAsciiString($tpl->getLabel()) . ".xml";
         }
         if ($setPrivate || CMS_file::copyTo(PATH_TEMPLATES_FS . "/" . $model->getDefinitionFile(), PATH_TEMPLATES_FS . "/" . $filename)) {
             $tpl->setDefinitionFile($filename);
             //Copying groupsStack from database
             foreach ($model->getGroups() as $grp) {
                 $tpl->addGroup($grp);
             }
             //Copying image file from model to a new one
             if ($setPrivate) {
                 $tpl->setImage($model->getImage());
             } else {
                 if ($model->getImage()) {
                     $ext = io::substr($model->getImage(), strrpos($model->getImage(), "."));
                     $imagefilename = "pt" . $tpl->getID() . "_" . SensitiveIO::sanitizeAsciiString($tpl->getLabel()) . $ext;
                     if (CMS_file::copyTo(PATH_TEMPLATES_IMAGES_FS . "/" . $model->getImage(), PATH_TEMPLATES_IMAGES_FS . "/" . $imagefilename)) {
                         $tpl->setImage($imagefilename);
                     }
                 } else {
                     $tpl->setImage();
                 }
             }
             //set private if asked to.
             if ($setPrivate) {
                 $tpl->setPrivate(true);
             }
             //copy description
             $tpl->setDescription($model->getDescription());
             //websites denied
             $websitesDenied = $model->getWebsitesDenied();
             foreach ($websitesDenied as $websiteId) {
                 if (CMS_websitesCatalog::exists($websiteId)) {
                     //to check if website still exists
                     $tpl->denyWebsite($websiteId);
                 }
             }
             //Copy printing definition
             $tpl->setPrintingClientSpaces($model->getPrintingClientSpaces());
             //Partial update for groups and image
             $tpl->writeToPersistence();
             //Copying template clientspaces rows definitions
             if (!$dontCopyClientSpaces) {
                 $suffixes = array('archived', 'deleted', 'edited', 'edition', 'public');
                 foreach ($suffixes as $suffix) {
                     if ($tplFrom) {
                         $sql = "\n\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t`mod_standard_clientSpaces_" . $suffix . "`\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t`template_cs`='" . $tplFrom . "'\n\t\t\t\t\t\t\t";
                     } else {
                         $sql = "\n\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t`mod_standard_clientSpaces_" . $suffix . "`\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t`template_cs`='" . $model->getID() . "'\n\t\t\t\t\t\t\t";
                     }
                     $q = new CMS_query($sql);
                     while ($arr = $q->getArray()) {
                         $sql1 = "\n\t\t\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\t\t\t`mod_standard_clientSpaces_" . $suffix . "`\n\t\t\t\t\t\t\t\tset\n\t\t\t\t\t\t\t\t\t`template_cs`='" . $tpl->getID() . "',\n\t\t\t\t\t\t\t\t\t`tagID_cs`='" . SensitiveIO::sanitizeSQLString($arr["tagID_cs"]) . "',\n\t\t\t\t\t\t\t\t\t`rowsDefinition_cs`='" . SensitiveIO::sanitizeSQLString($arr["rowsDefinition_cs"]) . "',\n\t\t\t\t\t\t\t\t\t`type_cs`='" . $arr["type_cs"] . "',\n\t\t\t\t\t\t\t\t\t`order_cs`='" . $arr["order_cs"] . "'\n\t\t\t\t\t\t\t";
                         $q1 = new CMS_query($sql1);
                         unset($q1);
                     }
                     unset($q);
                 }
             }
             //CMS_Template to return
             $ret = $tpl;
         }
         unset($model);
     }
     if ($tpl) {
         //Clean if any error when out
         if (!$ret) {
             $tpl->destroy();
         }
         unset($tpl);
     }
     return $ret;
 }
Example #5
0
            $orders = explode(',', $_POST['new_order']);
            if (CMS_websitesCatalog::setOrders($orders)) {
                $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
            } else {
                $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_ORDERING_ERROR);
            }
        }
        break;
}
if ($_GET["records_per_page"]) {
    CMS_session::setRecordsPerPage($_GET["records_per_page"]);
}
if ($_GET["bookmark"]) {
    CMS_session::setBookmark($_GET["bookmark"]);
}
$websites = CMS_websitesCatalog::getAll('order');
$records_per_page = CMS_session::getRecordsPerPage();
$bookmark = CMS_session::getBookmark();
$pages = ceil(sizeof($websites) / $records_per_page);
$first_record = ($bookmark - 1) * $records_per_page;
$dialog = new CMS_dialog();
$content = '';
$dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE));
if ($cms_message) {
    $dialog->setActionMessage($cms_message);
} elseif (io::request('cms_message_id', 'io::isPositiveInteger')) {
    $dialog->setActionMessage($cms_language->getMessage(io::request('cms_message_id')));
}
$content .= '
<script language="JavaScript" type="text/javascript" src="' . PATH_ADMIN_WR . '/v3/js/coordinates.js"></script>
<script language="JavaScript" type="text/javascript" src="' . PATH_ADMIN_WR . '/v3/js/drag.js"></script>
Example #6
0
 /**
  * Recursive function to Build the targets tree (recursivelinks) 
  * then apply the selection to the builded targets
  * Uses the websites catalog to exclude (for desclinks and sublinks) pages that are not part of the current website
  *
  * @return multidimensionnal array : array("recursiveTree" => tree of page id, "targets" => cms_page objects);
  * @access private
  */
 protected function _buildRecursiveTargets($pageID, $level = 0)
 {
     $targets = array();
     $recursiveTargets = array();
     $targets_temp = CMS_tree::getSiblings($pageID, $this->_publicTree, false);
     if ($targets_temp && is_array($targets_temp)) {
         foreach ($targets_temp as $aTarget_temp) {
             if ($this->_crosswebsite || !CMS_websitesCatalog::isWebsiteRoot($aTarget_temp)) {
                 //construct targets array
                 $targets[$aTarget_temp] = $aTarget_temp;
                 if ($this->_selectionCondition === false || $this->_selectionCondition->levelPasses($level + 1)) {
                     //construct recursive targets array and array of cms_pages objects
                     $returnedDatas = $this->_buildRecursiveTargets($aTarget_temp, $level + 1);
                     $targets = $targets + $returnedDatas["targets"];
                     //add this page to father watches
                     if (sizeof($returnedDatas["targets"])) {
                         $this->_fatherWatches[] = $aTarget_temp;
                     }
                     $recursiveTargets[$aTarget_temp] = $returnedDatas["recursiveTree"];
                 }
             }
         }
     }
     return array("recursiveTree" => $recursiveTargets, "targets" => $targets);
 }
Example #7
0
 /**
  * Regenerate the page file, either from scratch or from the linx file.
  * If linx file doesn't exists, the file is regenerated from scratch (obviously).
  *
  * @param boolean $fromScratch If false, regenerate from the linx file, otherwise regenerate linx file first.
  * @return boolean true on success, false on failure
  * @access public
  */
 function regenerate($fromScratch = false)
 {
     //regenerate don't work on pages that are not public or which not have website
     if ($this->getPublication() != RESOURCE_PUBLICATION_PUBLIC || !$this->_checkWebsite()) {
         return true;
     }
     //need pageTemplate for regeneration
     $this->_checkTemplate();
     //get linx file path
     $linxFile = new CMS_file($this->getLinxFilePath());
     //should we regenerate the linx file ?
     if ($fromScratch || !$linxFile->exists()) {
         if (!$this->_template) {
             $this->raiseError('Can\'t find page template for page ' . $this->getID());
             return false;
         }
         if (!$this->writeLinxFile()) {
             return false;
         }
         //reload linx file
         $linxFile = new CMS_file($this->getLinxFilePath());
     }
     //unregister all linxes
     CMS_linxesCatalog::deleteLinxes($this);
     //instanciate modules treatments for page linx tags
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $this);
     $modulesTreatment->setDefinition($linxFile->getContent());
     if ($content = $modulesTreatment->treatContent(true)) {
         $pageHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getHTMLFilename();
         $pageFile = new CMS_file($pageHTMLPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         $pageFile->setContent($content);
         $pageFile->writeToPersistence();
         $this->_lastFileCreation->setNow();
         $this->writeToPersistence();
         //if the page is a website root, create the index page redirecting to this one
         if ($fromScratch && CMS_websitesCatalog::isWebsiteRoot($this->getID())) {
             CMS_websitesCatalog::writeRootRedirection();
         }
     } else {
         $this->raiseError('Malformed linx file');
         return false;
     }
     //write significant url page
     $pagePath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getFilename();
     $redirectionFile = new CMS_file($pagePath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
     $redirectionFile->setContent($this->redirectionCode($pageHTMLPath));
     $redirectionFile->writeToPersistence(true, true);
     //write website index
     if (CMS_websitesCatalog::isWebsiteRoot($this->getID())) {
         $ws = $this->getWebsite();
         if ($ws && !$ws->isMain()) {
             $wsPath = $ws->getPagesPath(PATH_RELATIVETO_FILESYSTEM) . '/index.php';
             $redirectionFile = new CMS_file($wsPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
             $redirectionFile->setContent($this->redirectionCode($pageHTMLPath));
             $redirectionFile->writeToPersistence(true, true);
         }
     }
     //write print page if any
     if (USE_PRINT_PAGES && $this->_template->getPrintingClientSpaces()) {
         //reload linx file
         $printLinxFile = new CMS_file($this->getLinxFilePath() . '.print', CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         if ($printLinxFile->exists()) {
             $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_PRINT, $this);
             $modulesTreatment->setDefinition($printLinxFile->getContent());
             if ($content = $modulesTreatment->treatContent(true)) {
                 $printHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getHTMLFilename();
                 $printFile = new CMS_file($printHTMLPath);
                 $printFile->setContent($content);
                 $printFile->writeToPersistence();
             } else {
                 $this->raiseError('Malformed print linx file');
                 return false;
             }
             //write significant url print page
             $printPath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getFilename();
             $redirectionFile = new CMS_file($printPath);
             $redirectionFile->setContent($this->redirectionCode($printHTMLPath));
             $redirectionFile->writeToPersistence();
         } else {
             $this->raiseError('Malformed print linx file');
             return false;
         }
     }
     return true;
 }
Example #8
0
 /**
  * Computes the target of the tag.
  *
  * @param CMS_page $page The page where the linx tag is.
  * @param string $publicTree Is the calculus made in the public or edited tree ?
  * @return CMS_page The target page, of false if no target.
  * @access public
  */
 function getTarget(&$page, $publicTree)
 {
     $pg = false;
     switch ($this->_type) {
         case "node":
             $pg = CMS_tree::getPageByID($this->_value);
             if ($pg && !$pg->hasError()) {
                 return $pg;
             } else {
                 return false;
             }
             break;
         case "codename":
             if ($this->_website) {
                 $website = CMS_websitesCatalog::getByCodename($this->_website);
                 if ($website) {
                     $pg = CMS_tree::getPageByCodename($this->_value, $website, $publicTree, true);
                 }
             } else {
                 if ($this->_crosswebsite) {
                     return CMS_tree::getPagesByCodename($this->_value, $publicTree, true);
                 } else {
                     $pg = CMS_tree::getPageByCodename($this->_value, $page->getWebsite(), $publicTree, true);
                 }
             }
             if ($pg && !$pg->hasError()) {
                 return $pg;
             } else {
                 return false;
             }
             break;
         case "relative":
             switch ($this->_value) {
                 case "root":
                     if ($this->_website) {
                         $website = CMS_websitesCatalog::getByCodename($this->_website);
                         if ($website) {
                             $pg = $website->getRoot();
                         }
                     } else {
                         $offset = abs($this->_relativeOffset) * -1;
                         $pg = CMS_tree::getAncestor($page, $offset, !$this->_crosswebsite, false);
                         //here we do not want to use public tree because, in public tree, some page may be unpublished or in this case, it break the lineage and root page cannot be found
                     }
                     break;
                 case "father":
                     $offset = abs($this->_relativeOffset);
                     $pg = CMS_tree::getAncestor($page, $offset, !$this->_crosswebsite, $publicTree);
                     break;
                 case "self":
                     $pg = $page;
                     break;
                 case "brother":
                     $pg = CMS_tree::getBrother($page, $this->_relativeOffset, $publicTree);
                     break;
             }
             if ($this->_website && is_a($pg, 'CMS_page') && !$pg->hasError()) {
                 if ($pg->getCodename()) {
                     $website = CMS_websitesCatalog::getByCodename($this->_website);
                     $pg = $website ? CMS_tree::getPageByCodename($pg->getCodename(), $website, $publicTree, true) : false;
                 } else {
                     $pg = false;
                 }
             }
             if (is_a($pg, 'CMS_page') && !$pg->hasError()) {
                 return $pg;
             } else {
                 return false;
             }
             break;
     }
 }
Example #9
0
         $item['format'] = $varAttributes['format'];
     } else {
         $item['format'] = $cms_language->getDateFormat();
     }
     break;
 case 'page':
     $item['xtype'] = 'atmPageField';
     $item['mandatory'] = false;
     $item['anchor'] = '97%';
     if (isset($varAttributes['root'])) {
         if (!io::isPositiveInteger($varAttributes['root'])) {
             // Assuming the structure {websitecodename:pagecodename}
             $page = trim($varAttributes['root'], "{}");
             if (strpos($page, ":") !== false) {
                 list($websiteCodename, $pageCodename) = explode(':', $page);
                 $website = CMS_websitesCatalog::getByCodename($websiteCodename);
                 if ($website) {
                     $pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
                     if ($pageID) {
                         $item['root'] = $pageID;
                     }
                 }
             }
         } else {
             if (CMS_tree::getPageByID($tag['attributes'][$name])) {
                 $item['root'] = $varAttributes['root'];
             }
         }
     }
     break;
 default:
Example #10
0
 /**
  * Get iframe code for current html embed code
  *
  * @param string $style the html style code to add
  * @param string $attr the html attributes code to add
  * @return string the html code
  * @access protected
  */
 protected function _getIframe($style, $attr)
 {
     //load datas
     if (!($datas = $this->getDatas())) {
         return '';
     }
     //already iframe embeded, no need to redo an iframe arround
     if (strtolower(substr(trim($datas['html']), 0, 8)) == '<iframe ') {
         return '<div' . $style . $attr . '>' . $datas['html'] . '</div>';
     }
     //frame param
     $frameParam = base64_encode(serialize(array('url' => $this->_url, 'maxwidth' => io::isPositiveInteger($this->_maxwidth) ? $this->_maxwidth : '', 'maxheight' => io::isPositiveInteger($this->_maxheight) ? $this->_maxheight : '')));
     //frame domain
     if (defined('APPLICATION_EMBED_DOMAIN') && APPLICATION_EMBED_DOMAIN) {
         $domain = strtolower(substr(APPLICATION_EMBED_DOMAIN, 0, 4)) == 'http' ? APPLICATION_EMBED_DOMAIN : 'http://' . APPLICATION_EMBED_DOMAIN;
     } else {
         $domain = CMS_websitesCatalog::getCurrentDomain();
     }
     //iframe width/height
     $width = $height = '';
     if (isset($datas['width']) && io::isPositiveInteger($datas['width'])) {
         $width = io::htmlspecialchars($datas['width']);
     } else {
         //try to guess width for iframe ...
         $matches = array();
         if (preg_match('/^<[^>]* width="([0-9]+)"/i', trim($datas['html']), $matches) && isset($matches[1])) {
             $width = $matches[1];
         } elseif (io::isPositiveInteger($this->_maxwidth)) {
             $width = $this->_maxwidth;
         }
     }
     if (isset($datas['height']) && io::isPositiveInteger($datas['height'])) {
         $height = io::htmlspecialchars($datas['height']);
     } else {
         //try to guess width for iframe ...
         $matches = array();
         if (preg_match('/^<[^>]* height="([0-9]+)"/i', trim($datas['html']), $matches) && isset($matches[1])) {
             $height = $matches[1];
         } elseif (io::isPositiveInteger($this->_maxheight)) {
             $height = $this->_maxheight;
         }
     }
     return '<iframe scrolling="no" frameBorder="0"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . $domain . PATH_MAIN_WR . '/oembed/frame' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?params=' . $frameParam . '">' . '	<a href="' . $domain . PATH_MAIN_WR . '/oembed/frame' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?params=' . $frameParam . '" target="_blank">Click to view media</a>' . '</iframe>';
 }
Example #11
0
 * @author Sébastien Pauchet <*****@*****.**>
 */
// *************************************************************************
// ** REDIRECTION HANDLER. KEEP ALL THIS PHP CODE IN 403 ERROR DOCUMENT ! **
// **     YOU CAN DEFINE YOUR OWN ERROR PAGE WITH THE FILE /403.html      **
// *************************************************************************
//disactive HTML compression
define("ENABLE_HTML_COMPRESSION", false);
require_once dirname(__FILE__) . '/cms_rc_frontend.php';
//send 403 error code
header('HTTP/1.x 403 Forbidden', true, 403);
//try to get website by domain to serve specific 403 page
$domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']);
$path = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if ($domain && strpos($path, 'htaccess.txt') === false) {
    $website = CMS_websitesCatalog::getWebsiteFromDomain($domain);
    if ($website && !$website->hasError()) {
        //check if website has a 403 page defined
        $page403 = $website->get403();
        if ($page403) {
            $pPath = $page403->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
            if ($pPath) {
                if (file_exists($pPath)) {
                    $cms_page_included = true;
                    require $pPath;
                    exit;
                } elseif ($page403->regenerate(true)) {
                    clearstatcache();
                    if (file_exists($pPath)) {
                        $cms_page_included = true;
                        require $pPath;
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 = '')
 {
     switch ($name) {
         case 'file':
         case 'thumb':
             if ($name == 'file') {
                 $fieldIndex = 4;
                 $fielfPrefix = 'image';
             } else {
                 $fieldIndex = 1;
                 $fielfPrefix = 'thumb';
             }
             // If we have a value and there are additionnal cropping parameters
             if ($this->_subfieldValues[$fieldIndex]->getValue() && $parameters && in_array($this->getValue($name . 'Extension'), array('jpg', 'jpeg', 'png', 'gif'))) {
                 @(list($x, $y) = explode(',', str_replace(';', ',', $parameters)));
                 if (io::isPositiveInteger($x) && $x < $this->getValue($fielfPrefix . 'Width') || io::isPositiveInteger($y) && $y < $this->getValue($fielfPrefix . 'Height')) {
                     $crop = $x && $y ? 1 : 0;
                     //get module codename
                     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                     //set location
                     $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
                     //resized image path
                     $pathInfo = pathinfo($this->_subfieldValues[$fieldIndex]->getValue());
                     $resizedImage = $pathInfo['filename'] . '-' . $x . '-' . $y . ($crop ? '-c' : '') . '.' . $pathInfo['extension'];
                     //resized image path
                     $resizedImagepathFS = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location . '/' . $resizedImage;
                     //if file already exists, no need to resize file send it
                     if (file_exists($resizedImagepathFS)) {
                         return $this->getValue('filePath') . '/' . $resizedImage;
                     } else {
                         return CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . '/image-file' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?image=' . $this->_subfieldValues[$fieldIndex]->getValue() . '&amp;module=' . $moduleCodename . '&amp;x=' . $x . '&amp;y=' . $y . '&amp;crop=' . $crop . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? '&amp;location=' . $location : '');
                     }
                 }
             }
             if ($this->_subfieldValues[$fieldIndex]->getValue()) {
                 // If we have a value but no cropping params
                 return $this->getValue('filePath') . '/' . $this->_subfieldValues[$fieldIndex]->getValue();
             }
             return '';
             break;
         case 'fileHTML':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $filepath = $this->_subfieldValues[3]->getValue() == self::OBJECT_FILE_TYPE_INTERNAL ? PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location . '/' . $this->_subfieldValues[4]->getValue() : $this->_subfieldValues[4]->getValue();
             //append website url if missing
             if (io::substr($filepath, 0, 1) == '/') {
                 $filepath = CMS_websitesCatalog::getCurrentDomain() . $filepath;
             }
             //link content
             $linkContent = $parameters ? $parameters : $this->_subfieldValues[0]->getValue();
             $file = '<a href="' . $filepath . '" target="_blank" title="' . $this->_subfieldValues[0]->getValue() . '">' . $linkContent . '</a>';
             return $file;
             break;
         case 'fileLabel':
             return $this->_subfieldValues[0]->getValue();
             break;
         case 'filename':
             return $this->_subfieldValues[4]->getValue();
             break;
         case 'thumbnail':
         case 'thumbname':
             return $this->_subfieldValues[1]->getValue();
             break;
         case 'filePath':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $altDomain = $this->getAlternativeDomain();
             // If we are serving a public file and there is an alternative domain set up, change the url
             if ($this->isPublic() && $altDomain) {
                 return $altDomain . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             } else {
                 return CMS_websitesCatalog::getCurrentDomain() . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             }
             break;
         case 'thumbMaxWidth':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['thumbMaxWidth'] ? $params['thumbMaxWidth'] : '';
             break;
         case 'thumbMaxHeight':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['thumbMaxHeight'] ? $params['thumbMaxHeight'] : '';
             break;
         case 'thumbWidth':
         case 'thumbHeight':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $imgPath = $path . "/" . $this->_subfieldValues[1]->getValue();
             $sizeX = $sizeY = 0;
             if (file_exists($imgPath)) {
                 list($sizeX, $sizeY) = @getimagesize($imgPath);
             }
             if ($name == 'thumbWidth') {
                 return (string) $sizeX;
             } else {
                 return (string) $sizeY;
             }
             break;
         case 'imageWidth':
         case 'imageHeight':
             if ($this->_subfieldValues[4]->getValue() && in_array($this->getValue('fileExtension'), array('jpg', 'jpeg', 'png', 'gif'))) {
                 //get module codename
                 $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                 //set location
                 $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
                 $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
                 $imgPath = $path . "/" . $this->_subfieldValues[4]->getValue();
                 $sizeX = $sizeY = 0;
                 if (file_exists($imgPath)) {
                     list($sizeX, $sizeY) = @getimagesize($imgPath);
                 }
                 if ($name == 'imageWidth') {
                     return (string) $sizeX;
                 } else {
                     return (string) $sizeY;
                 }
             }
             return 0;
             break;
         case 'fileSize':
             return $this->_subfieldValues[2]->getValue();
             break;
         case 'fileIcon':
             return $this->_getFileIcon();
             break;
         case 'fileExtension':
             return $this->_getFileExtension();
             break;
         case 'thumbExtension':
             return $this->_getThumbExtension();
             break;
         case 'alternativeDomain':
             return $this->getAlternativeDomain();
         default:
             return parent::getValue($name, $parameters);
             break;
     }
 }
Example #13
0
 /**
  * Send the mail
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function sendEmail()
 {
     if ($this->hasError()) {
         $this->raiseError('Cannot send email, error appened');
         return false;
     }
     $emailSent = true;
     if (!$this->_emailTo) {
         $this->raiseError('emailTo can not be null');
         return false;
     }
     $OB = "----=_OuterBoundary_000";
     $IB = "----=_InnerBoundery_001";
     $encoding = $this->_emailEncoding ? $this->_emailEncoding : APPLICATION_DEFAULT_ENCODING;
     if ($this->_template) {
         //if template is provided for email HTML, use it
         $template = new CMS_file($this->_template);
         $templateContent = $template->getContent();
         $replace = array('{{subject}}' => $this->_subject, '{{body}}' => $this->_emailHTML ? $this->_emailHTML : $this->convertTextToHTML($this->_body), '{{footer}}' => $this->convertTextToHTML($this->_footer), '{{href}}' => CMS_websitesCatalog::getMainURL(), '{{charset}}' => strtoupper($encoding));
         $Html = str_replace(array_keys($replace), $replace, $templateContent);
     } elseif ($this->_emailHTML) {
         //if HTML content is provided for email, use it
         //if this mail contain relative link, append default website address
         if (io::strpos($this->_emailHTML, 'href="/') !== false || io::strpos($this->_emailHTML, 'src="/') !== false) {
             $url = CMS_websitesCatalog::getMainURL();
             $this->_emailHTML = str_replace(array('href="/', 'src="/'), array('href="' . $url . '/', 'src="' . $url . '/'), $this->_emailHTML);
         }
         $Html = $this->_emailHTML;
     } else {
         //else use text content converted to HTML
         $Html = $this->convertTextToHTML($this->_body . ($this->_footer ? "\n\n" . $this->_footer : ''));
     }
     $Text = $this->_body ? $this->_body . ($this->_footer ? "\n\n" . $this->_footer : '') : "Sorry, but you need an HTML compatible mailer to read this mail...";
     $From = $this->_emailFrom ? $this->_emailFrom : APPLICATION_POSTMASTER_EMAIL;
     $FromName = $this->_fromName ? $this->_fromName : '';
     $toUsers = is_array($this->_emailTo) && $this->_emailTo ? $this->_emailTo : array($this->_emailTo);
     $cc = is_array($this->_cc) && $this->_cc ? $this->_cc : ($this->_cc ? array($this->_cc) : '');
     $bcc = is_array($this->_bcc) && $this->_bcc ? $this->_bcc : ($this->_bcc ? array($this->_bcc) : '');
     $toNames = is_array($this->_toName) && $this->_toName ? $this->_toName : array($this->_toName);
     $Error = $this->_error ? $this->_error : '';
     $Subject = $this->_subject;
     $AttmFiles = $this->_files;
     //Messages start with text/html alternatives in OB
     $Msg = "This is a multi-part message in MIME format.\n";
     $Msg .= "\n--" . $OB . "\n";
     $Msg .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $IB . "\"\n\n";
     //plaintext section
     $Msg .= "\n--" . $IB . "\n";
     $Msg .= "Content-Type: text/plain;\n\tcharset=\"" . $encoding . "\"\n";
     $Msg .= "Content-Transfer-Encoding: 8bit\n\n";
     // plaintext goes here
     $Msg .= $Text . "\n\n";
     // html section
     $Msg .= "\n--" . $IB . "\n";
     $Msg .= "Content-Type: text/html;\n\tcharset=\"" . $encoding . "\"\n";
     $Msg .= "Content-Transfer-Encoding: base64\n\n";
     // html goes here
     $Msg .= chunk_split(base64_encode($Html), 76, "\n") . "\n\n";
     // end of IB
     $Msg .= "\n--" . $IB . "--\n";
     // attachments
     if (is_array($AttmFiles) && $AttmFiles) {
         foreach ($AttmFiles as $AttmFile) {
             $patharray = explode("/", $AttmFile);
             $FileName = $patharray[count($patharray) - 1];
             $Msg .= "\n--" . $OB . "\n";
             $Msg .= "Content-Type: application/octet-stream;\n\tname=\"" . $FileName . "\"\n";
             $Msg .= "Content-Transfer-Encoding: base64\n";
             $Msg .= "Content-Disposition: attachment;\n\tfilename=\"" . $FileName . "\"\n\n";
             //file goes here
             $fd = fopen($AttmFile, "r");
             $FileContent = fread($fd, filesize($AttmFile));
             fclose($fd);
             $FileContent = chunk_split(base64_encode($FileContent), 76, "\n");
             $Msg .= $FileContent;
             $Msg .= "\n\n";
         }
     }
     if (LOG_SENDING_MAIL) {
         global $cms_user;
         $user = $cms_user ? $cms_user : CMS_profile_usersCatalog::getById(ROOT_PROFILEUSER_ID);
     }
     //message ends
     $Msg .= "\n--" . $OB . "--\n";
     foreach ($toUsers as $key => $to) {
         if (sensitiveIO::isValidEmail($to)) {
             $headers = "MIME-Version: 1.0\n";
             if ($FromName) {
                 $headers .= "From: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
                 $headers .= "Reply-To: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
                 $headers .= "Return-Path: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
                 $headers .= "X-Sender: " . $this->EncodeHeader($FromName) . " <" . $From . ">\n";
             } else {
                 $headers .= "From: " . $From . "\n";
                 $headers .= "Reply-To: " . $From . "\n";
                 $headers .= "Return-Path: " . $From . "\n";
                 $headers .= "X-Sender: " . $From . "\n";
             }
             if (isset($toNames[$key]) && $toNames[$key]) {
                 $to = $this->EncodeHeader($toNames[$key]) . " <" . $to . ">";
             }
             if ($Error) {
                 $headers .= "Errors-To: " . $Error . "\n";
             }
             if ($cc) {
                 $headers .= "Cc: " . implode(',', $cc) . "\n";
             }
             if ($bcc) {
                 $headers .= "Bcc: " . implode(',', $bcc) . "\n";
             }
             /*$headers.="User-Agent: Automne (TM)\n";*/
             //Cause email to be reported as spam
             $headers .= "X-Mailer: Automne (TM)\n";
             $headers .= "X-Priority: 3\n";
             $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"" . $OB . "\"\n";
             //Check drop emails list (Automne default emails)
             if (!in_array($to, $this->_drop) && !in_array($From, $this->_drop)) {
                 //log in the cms_error_log the complete email
                 if (LOG_APPLICATION_MAIL) {
                     $this->log($to . "\n" . $this->EncodeHeader($Subject) . "\n\n" . $Msg);
                 }
                 //if mail deactivated always return true
                 if (NO_APPLICATION_MAIL) {
                     return $emailSent;
                 } else {
                     //send emails
                     $sent = @mail($to, $this->EncodeHeader($Subject), $Msg, $headers);
                 }
                 $emailSent = $emailSent && $sent;
                 if (LOG_SENDING_MAIL) {
                     $log = new CMS_log();
                     $log->logMiscAction(CMS_log::LOG_ACTION_SEND_EMAIL, $user, 'Email To ' . $to . ', From : ' . $From . ', Subject : ' . $Subject . ', Sent : ' . ($sent ? 'Yes' : 'Error'));
                 }
             } else {
                 if (LOG_SENDING_MAIL) {
                     $log = new CMS_log();
                     $log->logMiscAction(CMS_log::LOG_ACTION_SEND_EMAIL, $user, 'Email To ' . $to . ', From : ' . $From . ', Subject : ' . $Subject . ', Sent : No, Dropped because sender or receiver address is under Automne drop address list');
                 } else {
                     $this->raiseError('Email to ' . $to . ', from : ' . $From . ' (subject : ' . $Subject . '), Dropped because sender or receiver address is under Automne drop address list');
                 }
             }
         } else {
             if (LOG_SENDING_MAIL) {
                 $log = new CMS_log();
                 $log->logMiscAction(CMS_log::LOG_ACTION_SEND_EMAIL, $user, 'Email To ' . $to . ', From : ' . $From . ', Subject : ' . $Subject . ', Sent : No, Dropped because receiver address is not valid');
             } else {
                 $this->raiseError('Email to ' . $to . ', from : ' . $From . ' (subject : ' . $Subject . '), Dropped because receiver address is not valid');
             }
         }
     }
     if (!$emailSent) {
         $this->raiseError('Email was not sent, please check your sendmail configuration or SMTP connection in php.ini');
     }
     return $emailSent;
 }
 public static function getServiceUrl()
 {
     return CMS_websitesCatalog::getCurrentDomain() . '/embed/oembed' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?url=' . rawurlencode(CMS_websitesCatalog::getCurrentDomain() . $_SERVER['REQUEST_URI']);
 }
Example #15
0
        $archives[] = 'install.php';
        if ($archiveFound) {
            $archives[] = $archiveFile;
        }
        if (file_exists(dirname(__FILE__) . '/' . $demoFr)) {
            $archives[] = $demoFr;
        }
        if (file_exists(dirname(__FILE__) . '/' . $demoEn)) {
            $archives[] = $demoEn;
        }
        $archivesNames = '<ul>';
        foreach ($archives as $archive) {
            $archivesNames .= '<li>' . $archive . '</li>';
        }
        $archivesNames .= '</ul>';
        $mainURL = CMS_websitesCatalog::getMainURL() . PATH_REALROOT_WR;
        $content .= sprintf($step9_alldone, $mainURL, $mainURL, $mainURL, $mainURL, $archivesNames, $uname);
    }
    // +----------------------------------------------------------------------+
    // | RENDERING                                                            |
    // +----------------------------------------------------------------------+
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Automne :: Installation</title>
	<style type="text/css">
		body{
			background-color:	#e9f1da;
			font-family:		arial,verdana,helvetica,sans-serif;
Example #16
0
    if (!$error) {
        $content .= $data . "\n";
    } else {
        $content .= '<item>' . "\n" . '    <title>RSS Feed Error ..</title>' . "\n" . '    <guid isPermaLink="false">Error' . time() . '</guid>' . "\n" . '    <description><![CDATA[';
        switch ($error) {
            case 1:
                $content .= 'Error : RSS ID not found or not a valid integer ... Please contact the webmaster here : ' . APPLICATION_MAINTAINER_EMAIL;
                break;
            case 2:
                $content .= 'Error : Invalid RSS ID found ... Please contact the webmaster here : ' . APPLICATION_MAINTAINER_EMAIL;
                break;
            case 3:
                $content .= 'Error : RSS Content generation error or no valid content for this RSS feed ... Please contact the webmaster here : ' . APPLICATION_MAINTAINER_EMAIL;
                break;
        }
        $content .= ']]></description>' . "\n" . '    <link>' . CMS_websitesCatalog::getMainURL() . '</link>' . "\n" . '</item>';
    }
    $content .= '	</channel>' . "\n" . '</rss>';
    if ('utf-8' != strtolower(APPLICATION_DEFAULT_ENCODING)) {
        $content = io::utf8Encode($content);
    }
    //output content to record it into cache
    echo $content;
    $content = $cache->endSave();
}
unset($cache);
//send RSS content
if (!isset($_REQUEST['atm-previz'])) {
    header('Content-type: text/xml; charset=UTF-8');
    echo $content;
} else {
Example #17
0
 /**
  * get websites for a given domain or false if none found
  *
  * @param string $domain : the domain to found website of
  * @return array(CMS_website)
  * @access public
  */
 static function getWebsitesFromDomain($domain, &$isAlt = false)
 {
     //get all websites
     $websites = CMS_websitesCatalog::getAll('order');
     $matchWebsites = array();
     foreach ($websites as $website) {
         if (io::strtolower($domain) == io::strtolower(@parse_url($website->getURL(), PHP_URL_HOST))) {
             $matchWebsites[$website->getID()] = $website;
         } else {
             $altDomains = $website->getAltDomains();
             foreach ($altDomains as $altDomain) {
                 if (io::strtolower($domain) == io::strtolower(@parse_url($altDomain, PHP_URL_HOST))) {
                     $isAlt = true;
                     $matchWebsites[$website->getID()] = $website;
                 }
             }
         }
     }
     return $matchWebsites;
 }
Example #18
0
 /**
  * Sets the Codename.
  *
  * @param string $codename The Codename to set
  * @return boolean true on success, false on failure.
  * @access public
  */
 function setCodename($codename)
 {
     //codename should'nt be changed once set
     if ($this->_id) {
         $this->raiseError("Trying to change the codename of a website already existing");
         return false;
     }
     if ($codename) {
         $old_codename = $this->_codename;
         $this->_codename = $codename;
         //now test to see if a directory already exists with that name (Because codename must _not_ be moveable once set)
         if (!$this->_isMain && CMS_websitesCatalog::getByCodename($this->_codename)) {
             $this->_codename = $old_codename;
             $this->raiseError("Codename to set has same directory for pages than a previously set one.");
             return false;
         } else {
             return true;
         }
     } else {
         $this->raiseError("Codename can't be empty");
         return false;
     }
 }
Example #19
0
        $header[0] = '"Date"';
    }
    foreach ($fields as $field) {
        if ($field->getAttribute('type') != 'submit') {
            //remove submit field
            $header[$field->getID()] = '"' . cleanvalue($field->getAttribute('label')) . '"';
        }
        //check for file field in form
        if ($field->getAttribute('type') == 'file') {
            $fileFields[$field->getID()] = true;
        }
    }
}
//prepare files path if needed
if (sizeof($fileFields)) {
    $filesPath = CMS_websitesCatalog::getMainURL() . PATH_MODULES_FILES_WR . '/' . MOD_CMS_FORMS_CODENAME . '/';
}
//then create CVS file
//CSV header
$csv = implode(';', $header) . "\n";
//CSV content
if (sizeof($formDatas)) {
    foreach ($formDatas as $formData) {
        $count = 0;
        foreach ($header as $fieldID => $head) {
            $csv .= $count ? ';' : '';
            if (!$fileFields[$fieldID]) {
                $csv .= '"' . cleanvalue($formData[$fieldID]) . '"';
            } else {
                if ($formData[$fieldID]) {
                    $csv .= '"' . $filesPath . cleanvalue($formData[$fieldID]) . '"';
Example #20
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
  */
 protected function _replaceBlockVars($data, $html_attributes, $location, $public)
 {
     //get folder for files
     $folder = $this->_getFolderName($location, $public);
     //must put the main website URL before
     if ($public && ALTERNATIVE_DOMAIN) {
         $mainurl = ALTERNATIVE_DOMAIN;
     } else {
         $mainurl = CMS_websitesCatalog::getCurrentDomain(@$this->_pageID);
     }
     $html = '<a href="' . $mainurl . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["file"] . '"' . $html_attributes . ' title="' . io::htmlspecialchars($data["label"]) . '">' . $data["label"] . '</a>';
     $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data["file"]);
     $filesize = $file->getFileSize();
     $filesize = $filesize === false ? '0 M' : $filesize;
     $filesdatas = explode('_', $data["file"]);
     unset($filesdatas[0]);
     $originalFilename = io::substr(implode('_', $filesdatas), 32);
     $replace = array('{{data}}' => '<a href="' . $mainurl . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["file"] . '"' . $html_attributes . ' title="' . io::htmlspecialchars($data["label"]) . '" class="atm-file atm-filetype-' . $file->getExtension() . '">' . io::htmlspecialchars($data["label"]) . '</a>', '{{href}}' => $mainurl . PATH_MODULES_FILES_STANDARD_WR . '/' . $folder . '/' . $data["file"], '{{filename}}' => $data["file"], '{{originalfilename}}' => $originalFilename, '{{label}}' => io::htmlspecialchars($data["label"]), '{{jslabel}}' => io::htmlspecialchars($data["label"]), '{{size}}' => $filesize, '{{type}}' => $file->getExtension(), '{{icon}}' => $file->getFileIcon(CMS_file::WEBROOT) ? '<img src="' . $file->getFileIcon(CMS_file::WEBROOT) . '" title="' . $file->getExtension() . '" alt="' . $file->getExtension() . '" />' : '');
     return str_replace(array_keys($replace), $replace, $this->_definition);
 }
Example #21
0
    $redirHidden = "{\n\t\txtype:\t\t\t'hidden',\n\t\tname:\t\t\t'page',\n\t\tvalue:\t\t\t'{$pageId}'\n\t},";
} else {
    if (io::isPositiveInteger($item->getPageID())) {
        $href->setLinkType(RESOURCE_LINK_TYPE_INTERNAL);
        $href->setInternalLink($item->getPageID());
    } elseif ($item->getURL()) {
        $href->setLinkType(RESOURCE_LINK_TYPE_EXTERNAL);
        $href->setExternalLink($item->getURL());
    }
    $redirDisabled = $redirHidden = '';
}
$redirectValue = io::sanitizeJSString($href->getTextDefinition());
$visualmode = RESOURCE_DATA_LOCATION_EDITED;
//Websites
$currentWebsites = $item->getWebsites();
$websites = CMS_websitesCatalog::getAll();
$availableWebsites = $selectedWebsites = array();
foreach ($websites as $id => $website) {
    if (in_array($website->getId(), $currentWebsites)) {
        $exists = false;
        foreach ($selectedWebsites as $data) {
            if ($data[1] == $website->getURL()) {
                $exists = true;
            }
        }
        if (!$exists) {
            $selectedWebsites[] = array($id, $website->getURL());
        }
    } else {
        $exists = false;
        foreach ($availableWebsites as $data) {
Example #22
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return multidimentionnal array : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     switch ($name) {
         case 'label':
             return $this->getLabel();
             break;
         case 'image':
         case 'imageZoom':
             if ($name == 'image') {
                 $fieldIndex = 0;
             } else {
                 $fieldIndex = 2;
             }
             if ($this->_subfieldValues[$fieldIndex]->getValue() && $parameters) {
                 @(list($x, $y) = explode(',', str_replace(';', ',', $parameters)));
                 if (io::isPositiveInteger($x) && $x < $this->getValue($name . 'Width') || io::isPositiveInteger($y) && $y < $this->getValue($name . 'Height')) {
                     //get module codename
                     $crop = $x && $y ? 1 : 0;
                     //get module codename
                     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                     //set location
                     $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
                     //resized image path
                     $pathInfo = pathinfo($this->_subfieldValues[$fieldIndex]->getValue());
                     $resizedImage = $pathInfo['filename'] . '-' . $x . '-' . $y . ($crop ? '-c' : '') . '.' . $pathInfo['extension'];
                     //resized image path
                     $resizedImagepathFS = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location . '/' . $resizedImage;
                     //if file already exists, no need to resize file send it
                     if (file_exists($resizedImagepathFS)) {
                         return $this->getValue('imagePath') . '/' . $resizedImage;
                     } else {
                         return CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . '/image-file' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?image=' . $this->_subfieldValues[$fieldIndex]->getValue() . '&amp;module=' . $moduleCodename . '&amp;x=' . $x . '&amp;y=' . $y . '&amp;crop=' . $crop . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? '&amp;location=' . $location : '');
                     }
                 }
             }
             if ($this->_subfieldValues[$fieldIndex]->getValue()) {
                 return $this->getValue('imagePath') . '/' . $this->_subfieldValues[$fieldIndex]->getValue();
             }
             return '';
             break;
         case 'imageHTML':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             //link content
             $img = '';
             if ($parameters) {
                 $img = $parameters;
             } elseif ($this->_subfieldValues[0]->getValue()) {
                 //bug 1380
                 $img = '<img src="' . $this->getValue('image') . '" alt="' . $this->_subfieldValues[1]->getValue() . '" />';
             }
             //add link to zoom if any
             if ($img && $this->_subfieldValues[2]->getValue()) {
                 $href = CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . "/" . self::OBJECT_IMAGE_POPUP_FILE . '?' . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? 'location=' . RESOURCE_DATA_LOCATION_EDITED . '&amp;' : '') . 'file=' . $this->_subfieldValues[2]->getValue() . '&amp;label=' . urlencode($this->_subfieldValues[1]->getValue()) . '&amp;module=' . $moduleCodename;
                 // file informations
                 $popup = OPEN_ZOOMIMAGE_IN_POPUP ? ' onclick="javascript:CMS_openPopUpImage(\'' . addslashes($href) . '\');return false;"' : '';
                 $img = '<a target="_blank" rel="atm-enlarge" href="' . $href . '"' . $popup . ' title="' . $this->_subfieldValues[1]->getValue() . '">' . $img . '</a>';
             }
             return $img;
             break;
         case 'imageLabel':
             return $this->_subfieldValues[1]->getValue();
             break;
         case 'imageName':
             return $this->_subfieldValues[0]->getValue();
             break;
         case 'imageZoomName':
             return $this->_subfieldValues[2]->getValue();
             break;
         case 'imagePath':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $altDomain = $this->getAlternativeDomain();
             // If we are serving a public file and there is an alternative domain set up, change the url
             if ($this->isPublic() && $altDomain) {
                 return $altDomain . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             } else {
                 return CMS_websitesCatalog::getCurrentDomain() . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
             }
             break;
         case 'imageMaxWidth':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['maxWidth'] ? $params['maxWidth'] : '';
             break;
         case 'imageMaxHeight':
             //get field parameters
             $params = $this->getParamsValues();
             return $params['maxHeight'] ? $params['maxHeight'] : '';
             break;
         case 'imageWidth':
         case 'imageHeight':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $imgPath = $path . "/" . $this->_subfieldValues[0]->getValue();
             $sizeX = $sizeY = 0;
             if (file_exists($imgPath)) {
                 list($sizeX, $sizeY) = @getimagesize($imgPath);
             }
             if ($name == 'imageWidth') {
                 return (string) $sizeX;
             } else {
                 return (string) $sizeY;
             }
             break;
         case 'imageZoomWidth':
         case 'imageZoomHeight':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $imgPath = $path . "/" . $this->_subfieldValues[2]->getValue();
             $sizeX = $sizeY = 0;
             if (file_exists($imgPath)) {
                 list($sizeX, $sizeY) = @getimagesize($imgPath);
             }
             if ($name == 'imageZoomWidth') {
                 return (string) $sizeX;
             } else {
                 return (string) $sizeY;
             }
             break;
         case 'imageSize':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $filesize = @filesize($path . "/" . $this->_subfieldValues[0]->getValue());
             if ($filesize !== false && $filesize > 0) {
                 //convert in MB
                 $filesize = round($filesize / 1048576, 2) . ' M';
             } else {
                 $filesize = '0 M';
             }
             return $filesize;
             break;
         case 'imageZoomSize':
             //get module codename
             $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //set location
             $location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location;
             $filesize = @filesize($path . "/" . $this->_subfieldValues[2]->getValue());
             if ($filesize !== false && $filesize > 0) {
                 //convert in MB
                 $filesize = round($filesize / 1048576, 2) . ' M';
             } else {
                 $filesize = '0 M';
             }
             return $filesize;
             break;
         case 'alternativeDomain':
             return $this->getAlternativeDomain();
         default:
             return parent::getValue($name, $parameters);
             break;
     }
 }
Example #23
0
 /**
  * Create the redirection of an alias
  *
  * @return boolean true on success, false on failure
  * @access public
  * @static
  */
 function redirect()
 {
     //get aliases for current folder
     $dirname = array_pop(explode(DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_NAME'])));
     $aliases = CMS_module_cms_aliases::getByName($dirname);
     if (!$aliases) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']));
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //check each aliases returned to get the one which respond to current alias
     $matchAlias = false;
     $domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']);
     $websites = array();
     if ($domain) {
         $websites = CMS_websitesCatalog::getWebsitesFromDomain($domain);
     }
     foreach ($aliases as $alias) {
         if (!$matchAlias && dirname($_SERVER['SCRIPT_NAME']) == substr($alias->getPath(), 0, -1)) {
             if ($websites) {
                 foreach ($websites as $website) {
                     //alias match path, check for website
                     if (!$alias->getWebsites() || !$website || in_array($website->getId(), $alias->getWebsites())) {
                         //alias match website, use it
                         $matchAlias = $alias;
                     }
                 }
             } else {
                 //alias match path, check for website
                 if (!$alias->getWebsites()) {
                     //alias match website, use it
                     $matchAlias = $alias;
                 }
             }
         }
     }
     if (!$matchAlias) {
         //no alias found, go to 404
         CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']) . ' and domain ' . $domain);
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     }
     //if alias is used as a page url, return page
     if ($matchAlias->urlReplaced()) {
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             $page = CMS_tree::getPageById($matchAlias->getPageID());
         } else {
             //no valid page set, go to 404
             $matchAlias->raiseError('No page set for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         if (!$page || $page->hasError()) {
             //no valid page found, go to 404
             $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
         //return page path
         $pPath = $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
         if ($pPath) {
             if (file_exists($pPath)) {
                 return $pPath;
             } elseif ($page->regenerate(true)) {
                 clearstatcache();
                 if (file_exists($pPath)) {
                     return $pPath;
                 }
             }
         }
         //no valid url page found, go to 404
         $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
         CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
     } else {
         //this is a redirection
         $params = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
         if (isset($_SERVER['HTTP_REFERER'])) {
             header("Referer: " . $_SERVER['HTTP_REFERER']);
         }
         if (io::isPositiveInteger($matchAlias->getPageID())) {
             //it's a redirection to an Automne Page
             $page = CMS_tree::getPageById($matchAlias->getPageID());
             if ($page && !$page->hasError()) {
                 $pageURL = CMS_tree::getPageValue($matchAlias->getPageID(), 'url');
                 if ($pageURL) {
                     CMS_view::redirect($pageURL . $params, true, $matchAlias->isPermanent() ? 301 : 302);
                 } else {
                     //no valid url page found, go to 404
                     $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                     CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
                 }
             } else {
                 //no valid page found, go to 404
                 $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
                 CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
             }
         } elseif ($matchAlias->getURL()) {
             //it's a redirection to an URL
             CMS_view::redirect($matchAlias->getURL(), true, $matchAlias->isPermanent() ? 301 : 302);
         } else {
             //no valid redirection found, go to 404
             $matchAlias->raiseError('Invalid redirection for alias ' . $matchAlias->getID());
             CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
         }
     }
 }
Example #24
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);
 }
 protected function checkTagValues(&$tag, $requirements)
 {
     if (!is_array($requirements)) {
         $this->raiseError('Tag requirements must be an array');
         return false;
     }
     foreach ($requirements as $name => $requirementType) {
         //check parameter existence
         if ($requirementType['mandatory'] && !isset($tag['attributes'][$name])) {
             if ($this->_mode == self::CHECK_PARSING_MODE) {
                 $this->_parsingError .= "\n" . 'Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute';
                 return false;
             } else {
                 $this->raiseError('Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute');
                 return false;
             }
         } elseif (isset($tag['attributes'][$name])) {
             //if any, check value requirement
             $message = false;
             switch ($requirementType['value']) {
                 case 'alphanum':
                     if ($tag['attributes'][$name] != sensitiveIO::sanitizeAsciiString($tag['attributes'][$name], '', '_')) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be composed with alphanumeric caracters (0-9a-z_) : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'language':
                     if (isset($this->_parameters['module'])) {
                         $languages = CMS_languagesCatalog::getAllLanguages($this->_parameters['module']);
                     } else {
                         $languages = CMS_languagesCatalog::getAllLanguages();
                     }
                     if (!isset($languages[$tag['attributes'][$name]])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be a valid language code : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'object':
                     if (!sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], 9, -3))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object';
                     }
                     break;
                 case 'field':
                     if (strrpos($tag['attributes'][$name], 'fields') === false || !sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], strrpos($tag['attributes'][$name], 'fields') + 9, -2))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object field';
                     }
                     break;
                 case 'page':
                     if (!io::isPositiveInteger($tag['attributes'][$name])) {
                         // Assuming the structure {websitecodename:pagecodename}
                         $page = trim($tag['attributes'][$name], "{}");
                         if (strpos($page, ":") !== false) {
                             list($websiteCodename, $pageCodename) = explode(':', $page);
                             $website = CMS_websitesCatalog::getByCodename($websiteCodename);
                             if (!$website) {
                                 $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow Website codename : ' . $websiteCodename . '';
                             } else {
                                 $pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
                                 if (!$pageID) {
                                     $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow page codename ' . $pageCodename . ' in website : ' . $websiteCodename . '';
                                 }
                             }
                         } else {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must be an integer or use the format websitecodename:pagecodename';
                         }
                     } else {
                         if (!CMS_tree::getPageByID($tag['attributes'][$name])) {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow pageID : ' . $tag['attributes'][$name];
                         }
                     }
                     break;
                 default:
                     //check
                     if (!preg_match('#^' . $requirementType['value'] . '$#i', $tag['attributes'][$name])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must match expression \'' . $requirementType['value'] . '\' : ' . $tag['attributes'][$name];
                     }
                     break;
             }
             if ($message) {
                 if ($this->_mode == self::CHECK_PARSING_MODE) {
                     $this->_parsingError .= "\n<br />" . $message;
                     return false;
                 } else {
                     $this->raiseError($message);
                     return false;
                 }
             }
         }
     }
     return true;
 }
	<form name="frm" action="' . $_SERVER["SCRIPT_NAME"] . '" method="post">
	<input type="hidden" id="cms_action" name="cms_action" value="validate" />
	<input type="hidden" name="moduleCodename" value="' . $moduleCodename . '" />
	<input type="hidden" name="object" value="' . $object->getID() . '" />
	<input type="hidden" name="RSSDefinition" value="' . $RSSDefinition->getID() . '" />
		<tr>
			<td class="admin" align="right" valign="top"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_TITLE) . '</td>
			<td class="admin" width="80%">' . $label->getHTMLAdmin('label') . '</td>
		</tr>
		<tr>
			<td class="admin" align="right" valign="top" nowrap="nowrap"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_DESCRIPTION) . '</td>
			<td class="admin" width="80%">' . $description->getHTMLAdmin('description', true) . '</td>
		</tr>
		<tr>
			<td class="admin" align="right" valign="top">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LINK, false, MOD_POLYMOD_CODENAME) . '</td>
			<td class="admin" width="80%"><input type="text" class="admin_input_long_text" name="link" value="' . $RSSDefinition->getValue('link') . '" /><br /><small>(' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LINK_EXPLANATION, array(CMS_websitesCatalog::getMainURL()), MOD_POLYMOD_CODENAME) . ')</small></td>
		</tr>
		<tr>
			<td class="admin" align="right" valign="top">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_AUTHOR, false, MOD_POLYMOD_CODENAME) . '</td>
			<td class="admin" width="80%"><input type="text" class="admin_input_long_text" name="author" value="' . $RSSDefinition->getValue('author') . '" /></td>
		</tr>
		<tr>
			<td class="admin" align="right" valign="top">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_EMAIL, false, MOD_POLYMOD_CODENAME) . '</td>
			<td class="admin" width="80%"><input type="text" class="admin_input_long_text" name="email" value="' . $RSSDefinition->getValue('email') . '" /></td>
		</tr>
		<tr>
			<td class="admin" align="right" valign="top">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_COPYRIGHT, false, MOD_POLYMOD_CODENAME) . '</td>
			<td class="admin" width="80%"><input type="text" class="admin_input_long_text" name="copyright" value="' . $RSSDefinition->getValue('copyright') . '" /></td>
		</tr>
		<tr>
			<td class="admin" align="right" valign="top">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_CATEGORIES, false, MOD_POLYMOD_CODENAME) . '</td>
Example #27
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 #28
0
    /**
     * Shows body of html page
     *
     * @return void
     * @access private
     */
    protected function _showBody()
    {
        switch ($this->_displayMode) {
            case 'menu':
                echo '
					<body marginheight="0" background="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond_menu.gif" marginwidth="0" leftmargin="0" topmargin="0" class="admin">
						' . $this->_writeMenu() . '
					</body>
					';
                break;
            case 'frames':
                echo '
					<body>
					' . $this->_parseContent($this->_content) . '
					</body>
					';
                break;
            case 'frameChecker':
                echo '
					<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="frame" onLoad="initJavascript();">
					' . $this->_parseContent($this->_content) . '
					</body>
					';
                break;
            case 'arbo':
                echo '
					<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="frame">
						
					' . $this->_getTitleDesign($this->_title, "admin_frame", "picto_pages.gif") . '
					
					' . $this->_showMessage() . '
					' . $this->_parseContent($this->_content) . '
					</body>
				';
                break;
            case 'modules':
                echo '
					<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="frame">
						
					' . $this->_getTitleDesign($this->_title, "admin_frame", "picto_modules.gif") . '
					
					' . $this->_showMessage() . '
					' . $this->_parseContent($this->_content) . '
					</body>
				';
                break;
            default:
                $user = $this->_context->getUser();
                $language = $user->getLanguage();
                echo '<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" class="admin" onLoad="initJavascript();">';
                //content is out of frames, so add Automne content header and do not display menu
                if ($this->_displayMode == 'out') {
                    echo '
					<table width="100%" height="72" border="0" cellpadding="0" cellspacing="0" style="background:url(' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond.gif) repeat-x bottom left;">
						<tr>
							<td width="562" height="72" valign="top" class="admin">
								<table width="562" height="30" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td width="472" height="30" class="admin_date">
											<!--&nbsp;&nbsp;<span class="admin_site_label">' . APPLICATION_LABEL . '</span> - <b>' . date($language->getDateFormat(), time()) . '</b>--></td>
										<td width="90" height="30" class="admin"><a href="http://www.automne-cms.org" target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/powered.gif" border="0" /></a></td>
									</tr>
								</table>
								<table width="562" height="42" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td width="562" height="42" background="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond.gif" valign="center"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="562" height="1" border="0" /><br />
											' . $this->_getSubMenu() . '
										</td>
									</tr>
								</table>
							</td>
							<td width="138" height="72"><a href="' . CMS_websitesCatalog::getMainURL() . '" target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/logo.png" class="png" width="138" height="72" border="0" /></a></td>
							<td width="100%" height="72" valign="top" class="admin">
								<table width="100%" height="72" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td width="100%" height="30"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="1" height="1" border="0" /></td>
									</tr>
									<tr>
										<td width="100%" height="42" background="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/fond.gif"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="1" height="1" border="0" /></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>';
                } else {
                    echo $this->_getSubMenu();
                }
                //display content
                echo '
					<table width="100%" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td width="15"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" border="0" width="15" height="1" /></td>
							<td class="admin">';
                if ($this->_title) {
                    echo $this->_getTitleDesign($this->_title, "admin_h1", $this->_picto);
                }
                echo '<br />' . $this->_showMessage();
                $replace = array(PATH_ADMIN_WR => '', 'modules/' => '', '/' => '_', '.php' => '');
                if (io::strpos($_SERVER["SCRIPT_NAME"], '/polymod/') !== false && isset($_REQUEST['polymod'])) {
                    $replace['polymod'] = $_REQUEST['polymod'];
                }
                $filename = sensitiveIO::sanitizeAsciiString(str_replace(array_keys($replace), $replace, $_SERVER["SCRIPT_NAME"]));
                if (file_exists(PATH_ADMIN_FS . '/inc/' . $filename . "_" . $language->getCode() . ".inc.php")) {
                    include_once PATH_ADMIN_FS . '/inc/' . $filename . "_" . $language->getCode() . ".inc.php";
                }
                echo '
								' . $this->_parseContent($this->_content) . '
								<br />
							</td>
						</tr>
					</table>
					' . $this->_beforeBody;
                if ($this->_displayMode != "loading") {
                    echo '</body>';
                } else {
                    //add loading class
                    require_once "loadingDialog.php";
                    //start loading mode
                    CMS_LoadingDialog::startLoadingMode();
                }
                break;
        }
    }
Example #29
0
 protected function _createCategoriesTree($categories, $itemPattern, $templatePattern, $selectedPattern, $maxlevel = 0, $selectedIDs = array())
 {
     global $cms_language;
     static $level;
     $level++;
     $return = "";
     //get all level categories object
     $categoriesObjects = array();
     $subCats = array();
     foreach ($categories as $catID => $subCategories) {
         $category = CMS_moduleCategories_catalog::getByID($catID);
         $categoriesObjects[$category->getAttribute('order')] = $category;
         $subCats[$catID] = $subCategories;
     }
     //sort categories by order
     ksort($categoriesObjects);
     ///then display it
     foreach ($categoriesObjects as $category) {
         $catID = $category->getID();
         $subCategories = $subCats[$catID];
         $subcats = '';
         if (is_array($subCategories) && $subCategories && (!$maxlevel || $level < $maxlevel)) {
             //recurse on subcategories
             $subcats = $this->_createCategoriesTree($subCategories, $itemPattern, $templatePattern, $selectedPattern, $maxlevel, $selectedIDs);
         }
         $iconPathFS = $category->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true);
         if ($iconPathFS && file_exists($iconPathFS)) {
             $iconPathWR = CMS_websitesCatalog::getCurrentDomain() . $category->getIconPath(true, PATH_RELATIVETO_WEBROOT, true);
             $icon = '<img src="' . $iconPathWR . '" alt="" title="' . SensitiveIO::sanitizeHTMLString($category->getLabel($cms_language)) . '" />';
         } else {
             $icon = '';
         }
         $replace = array('{id}' => $catID, '{label}' => $category->getLabel($cms_language), '{description}' => $category->getDescription($cms_language), '{sublevel}' => $subcats, '{lvl}' => $level, '{icon}' => $icon);
         if ($selectedIDs && in_array($catID, $selectedIDs)) {
             $return .= str_replace(array_keys($replace), $replace, $selectedPattern);
         } else {
             $return .= str_replace(array_keys($replace), $replace, $itemPattern);
         }
     }
     $return = str_replace('{sublevel}', $return, $templatePattern);
     $level--;
     return $return;
 }
Example #30
0
 * @subpackage frontend
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/cms_rc_frontend.php';
$httpHost = null;
if (isset($_SERVER['HTTP_HOST'])) {
    $httpHost = @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST'];
}
//search page id by domain address
$website = CMS_websitesCatalog::getWebsiteFromDomain($httpHost, '', $isAlt);
//redirect to website main domain if current domain is an altdomain and need redirection
if ($website && $isAlt && $website->redirectAltDomain()) {
    CMS_view::redirect($website->getURL(), true, 301);
}
if (!$website) {
    $website = CMS_websitesCatalog::getMainWebsite();
}
$rootPage = $website->getRoot();
if ($rootPage->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
    //redirect to subpage if any
    $redirectlink = $rootPage->getRedirectLink(true);
    while ($redirectlink && $redirectlink->hasValidHREF() && sensitiveIO::IsPositiveInteger($redirectlink->getInternalLink())) {
        $rootPage = new CMS_page($redirectlink->getInternalLink());
        if ($rootPage->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
            $redirectlink = $rootPage->getRedirectLink(true);
        } else {
            $redirectlink = '';
        }
    }
}
$pPath = $rootPage->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);