Example #1
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['visualization']) || !isset($this->_computeParams['object']) || !$this->_computeParams['object'] instanceof CMS_page) {
             return '';
         }
         $public = $this->_computeParams['visualization'] == PAGE_VISUALMODE_PRINT || $this->_computeParams['visualization'] == PAGE_VISUALMODE_HTML_PUBLIC;
         return CMS_tree::getPageValue($this->_computeParams['object']->getID(), $this->_attributes['name'], $public);
     } else {
         return '$content .= CMS_tree::getPageValue($parameters[\'pageID\'], \'' . $this->_attributes['name'] . '\', (isset($public_search) ? $public_search : false));';
     }
 }
Example #2
0
		</tr>
		</table>
	</li>
	';
}
$content .= '
</ul>
<div id="validateDrag" class="hideit">
	<form name="change_order" onsubmit="return getNewOrder();" action="' . $_SERVER['SCRIPT_NAME'] . '" method="post">
		<input type="hidden" name="cms_action" value="change_order" />
		<input type="hidden" name="new_order" value="" />
		<input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_SAVE_NEWORDER) . '" />
	</form>
</div>';
//new website : send to tree to select the root page (hope the user has the PAGE clearance for the root)
$grand_root = CMS_tree::getRoot();
$href = PATH_ADMIN_SPECIAL_TREE_WR;
$href .= '?root=' . $grand_root->getID();
//$href .= '&amp;pageLink=website.php'.chr(167).chr(167).'website_root=%s'.chr(167).'cms_action=set_root';
$href .= '&amp;encodedPageLink=' . base64_encode('website.php' . chr(167) . chr(167) . 'website_root=%s' . chr(167) . 'cms_action=set_root');
$href .= '&amp;backLink=websites.php';
$href .= '&amp;title=' . urlencode($cms_language->getMessage(MESSAGE_PAGE_TREE_TITLE));
$href .= '&amp;heading=' . urlencode($cms_language->getMessage(MESSAGE_PAGE_TREE_HEADING));
$content .= '
	<br />
	<form method="post" action="' . $href . '">
		<input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_NEW) . '" />
	</form>
	<br />
';
$dialog->setContent($content);
Example #3
0
/**
 * Builds a link from a linktype and a link template which may contain the special string {{href}}
 *
 * @param integer $type The type of the link
 * @param array(string) $parameters The links parameters in this order : internalLink page ID, external URL, file URL
 * @param string $template The link template
 * @param array $popup The popup parameter $popupInfo[0] : boolean is popup active ?, $popupInfo[1] : integer popup size X, $popupInfo[2] : integer popup size Y
 * @return string The link built.
 * @access public
 */
function buildLink($type, $parameters, $template, $popupInfo = false)
{
    switch ($type) {
        case RESOURCE_LINK_TYPE_INTERNAL:
            $href = CMS_tree::getPageValue($parameters[0], 'url');
            $target = "_top";
            break;
        case RESOURCE_LINK_TYPE_EXTERNAL:
            $href = $parameters[1];
            if (substr($href, 0, 4) != 'http') {
                $href = 'http://' . $href;
            }
            $target = "_blank";
            break;
        case RESOURCE_LINK_TYPE_FILE:
            $href = $parameters[2];
            if (substr($href, 0, 4) != 'http') {
                $href = 'http://' . $href;
            }
            $target = "_blank";
            break;
        default:
            return '';
            break;
    }
    if ($popupInfo != false && is_array($popupInfo) && $popupInfo[0] != 0 && $href) {
        $href = "javascript:openWindow('" . $href . "', 'popup', " . $popupInfo[1] . ", " . $popupInfo[2] . ", 'yes', 'yes', 'no', 40, 40);";
        $target = "";
    }
    if ($href) {
        $template = str_replace("{{target}}", $target, $template);
        return str_replace("{{href}}", $href, $template);
    }
}
Example #4
0
 /**
  * Get : a full XHTML a tag
  *
  * @param string $module If false, only returns the filename
  * @param string $dataLocation Where does the data lies ? @see CMS_resource constants
  * @param string $attrs, any attributes to append into A tag 
  * @return string, the XHTML Tag
  * @access public
  */
 function getHTML($label = false, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $attrs = false, $hrefOnly = false)
 {
     if ($label) {
         $this->_label = $label;
     }
     // Building href
     $s = '';
     $href = '';
     $onClick = '';
     switch ($this->_linkType) {
         case RESOURCE_LINK_TYPE_INTERNAL:
             // Get internal page URL
             switch ($dataLocation) {
                 case RESOURCE_DATA_LOCATION_PUBLIC:
                 case RESOURCE_DATA_LOCATION_EDITED:
                 default:
                     if (sensitiveIO::isPositiveInteger($this->_internalLink) && ($href = CMS_tree::getPageValue($this->_internalLink, 'url'))) {
                         $href = PATH_PAGES_WR && strpos($href, PATH_PAGES_WR) !== false || stripos($href, 'http') !== false ? $href : PATH_PAGES_WR . $href;
                     }
                     break;
             }
             // Set a popup link, not a trivial link
             if (isset($this->_popup['width']) && isset($this->_popup['height']) && $this->_popup['width'] > 0 && $this->_popup['height'] > 0) {
                 $onClick = "javascript:CMS_openPopUpPage('" . $href . "', 'popup_page', " . $this->_popup['width'] . ", " . $this->_popup['height'] . ");return false;";
             }
             break;
         case RESOURCE_LINK_TYPE_EXTERNAL:
             $href = io::htmlspecialchars($this->_externalLink);
             $href = str_replace('&amp;', '&', $href);
             if (strtolower(substr($href, 0, 4)) != 'http') {
                 $href = 'http://' . $href;
             }
             // Set a popup link, not a trivial link
             if (isset($this->_popup['width']) && $this->_popup['width'] > 0 && isset($this->_popup['height']) && $this->_popup['height'] > 0) {
                 $onClick = "javascript:CMS_openPopUpPage('" . $href . "', 'external', " . $this->_popup['width'] . ", " . $this->_popup['height'] . ");return false;";
             }
             break;
         case RESOURCE_LINK_TYPE_FILE:
             if (is_file($this->getFileLink(true, $module, $dataLocation, PATH_RELATIVETO_FILESYSTEM))) {
                 $href = $this->getFileLink(true, $module, $dataLocation, PATH_RELATIVETO_WEBROOT);
                 // Set a popup link, not a trivial link
                 if (isset($this->_popup['width']) && $this->_popup['width'] > 0 && isset($this->_popup['height']) && $this->_popup['height'] > 0) {
                     $onClick = "javascript:CMS_openPopUpPage('" . $href . "', 'file', " . $this->_popup['width'] . ", " . $this->_popup['height'] . ");return false;";
                 }
             }
             break;
     }
     if ($hrefOnly) {
         return $href;
     }
     if ($this->_target) {
         $target = ' target="' . $this->_target . '"';
     }
     // Get onClick
     if ($onClick != '') {
         $onClick = ' onClick="' . $onClick . '"';
     }
     // Return Link
     if (trim($href) != '') {
         if (!$attrs) {
             $attrs = $this->getAttributesString();
         }
         $attrs = ' ' . trim($attrs);
         $s = '<a href="' . $href . '"' . $onClick . $target . $attrs . '>' . $this->_label . '</a>';
     }
     return $s;
 }
Example #5
0
 /**
  * Check that the website is instanciated.
  *
  * @return void
  * @access private
  */
 protected function _checkWebsite()
 {
     if (!is_object($this->_website)) {
         $this->_website = CMS_tree::getPageWebsite($this->_pageID);
     }
     if (!is_object($this->_website)) {
         $this->raiseError('No website found for page : ' . $this->_pageID);
         return false;
     }
     return true;
 }
Example #6
0
    /**
     * Returns XHTML formatted form fields for this Href
     * 
     * @param CMS_language $cms_language, the language to build the form with
     * @param string $module, the module codename (default : MOD_STANDARD_CODENAME)
     * @param constant $dataLocation, the current data location (RESOURCE_DATA_LOCATION_EDITED (default), RESOURCE_DATA_LOCATION_PUBLIC, etc.)
     * @param array $options, array of possible link options (default false : all options actived)
     *	Example :
     * Array (
     *     'label' 		=> true|false,				// Link has label ?
     *     'internal' 	=> true|false,				// Link can target an Automne page ?
     *     'external' 	=> true|false,				// Link can target an external resource ?
     *     'file' 		=> true|false,				// Link can target a file ?
     *     'destination'=> true|false,				// Can select a destination for the link ?
     *     'no_admin' 	=> true|false,				// Deprecated : Remove all admin class reference (default = false)
     *     'admin' 		=> true|false,				// Use admin JS and classes instead of direct actions (default = true)
     *     'currentPage'=> int|false,				// Current page to open tree panel (default : CMS_tree::getRoot())
     * )
     * @return string HTML formated expected
     * @access public
     */
    function getHTMLFields($cms_language, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $options = false)
    {
        global $cms_user;
        if (!is_a($this->_href, 'CMS_href')) {
            $this->raiseError("\$this->_href isn't a CMS_href");
            return '';
        }
        $tdClass = $tdClassLight = $tdClassDark = $inputClass = '';
        if (!isset($options['no_admin']) || $options['no_admin'] === false) {
            $tdClass = ' class="admin"';
            $tdClassLight = ' class="admin_lightgreybg"';
            $tdClassDark = ' class="admin_darkgreybg"';
            $inputClass = ' class="admin_input_text"';
        }
        $s = '';
        if (!isset($options['destination']) || $options['destination'] == true) {
            $s .= '
			<script type="text/javascript">
				if (typeof CMS_openPopUpPage != "function") {
					function CMS_openPopUpPage(href, id, width, height) {
						if (href != "") {
							pagePopupWin = window.open(href, \'CMS_page_\'+id, \'width=\'+width+\',height=\'+height+\',resizable=yes,menubar=no,toolbar=no,scrollbars=yes,status=no,left=0,top=0\');
						}
					}
				}
			</script>';
        }
        $s .= '
		<table>';
        if (!isset($options['label']) || $options['label'] == true) {
            $s .= '
				<!-- link label -->
				<tr>
					<th' . $tdClass . '><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_LABEL) . '</th>
					<td' . $tdClassLight . ' colspan="2"><input style="width:100%;" type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_label" value="' . io::htmlspecialchars($this->_href->getLabel()) . '" /></td>
				</tr>';
        }
        $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_NONE ? ' checked="checked"' : '';
        $rowspan = 4;
        if (isset($options['internal']) && $options['internal'] == false) {
            $rowspan--;
        }
        if (isset($options['external']) && $options['external'] == false) {
            $rowspan--;
        }
        if (isset($options['file']) && $options['file'] == false) {
            $rowspan--;
        }
        $s .= '
					<tr>
						<th' . $tdClass . ' rowspan="' . $rowspan . '"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_DESTINATION) . '</th>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_0" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_NONE . '"' . $checked . ' /></td>
						<td' . $tdClassDark . '><label for="' . $this->_prefix . 'link_type_0">' . $cms_language->getMessage(self::MESSAGE_PAGE_NOLINK) . '</label></td>
					</tr>
			';
        if (!isset($options['internal']) || $options['internal'] == true) {
            $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL ? ' checked="checked"' : '';
            // Build tree link
            $grand_root = isset($options['currentPage']) && sensitiveIO::isPositiveInteger($options['currentPage']) ? CMS_tree::getPageByID($options['currentPage']) : CMS_tree::getRoot();
            $grand_rootID = $grand_root->getID();
            if ($cms_user && is_a($cms_user, 'CMS_profile_user')) {
                if (!$cms_user->hasPageClearance($grand_rootID, CLEARANCE_PAGE_VIEW)) {
                    // If user don't have any clearance view for page root : search a "first root" and viewable page sections
                    $sections_roots = array();
                    $sections_roots = $cms_user->getViewablePageClearanceRoots();
                    if ($sections_roots) {
                        CMS_session::setSessionVar('sectionsRoots', $sections_roots);
                        $sections_roots = array_reverse($sections_roots);
                        foreach ($sections_roots as $pageID) {
                            $lineages[count(CMS_tree::getLineage($grand_rootID, $pageID, false))] = $pageID;
                        }
                    }
                    ksort($lineages);
                    $grand_rootID = array_shift($lineages);
                }
            }
            if (!isset($options['admin']) || $options['admin'] == false) {
                //build tree link
                $href = '/automne/admin-v3/tree.php';
                $href .= '?root=' . $grand_rootID;
                $href .= '&amp;heading=' . $cms_language->getMessage(self::MESSAGE_PAGE_TREEH1);
                $href .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $this->_prefix . "link_internal').value = '%s';self.close();");
                $href .= '&encodedPageLink=' . base64_encode('false');
                $treeLink = '<a href="' . $href . '"' . $tdClass . ' target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>';
            } else {
                $treeLink = '<a href="#" onclick="Automne.view.tree(\'' . $this->_prefix . 'link_internal\', \'' . sensitiveIO::sanitizeJSString($cms_language->getMessage(self::MESSAGE_PAGE_TREEH1)) . '\', \'' . $grand_rootID . '\')"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>';
            }
            $s .= '<tr>
						<td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_1" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_INTERNAL . '"' . $checked . ' /></td>
						<td' . $tdClassLight . '>
							<label for="' . $this->_prefix . 'link_type_1">' . $cms_language->getMessage(self::MESSAGE_PAGE_INTERNALLINK) . '</label>
							<input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_internal" name="' . $this->_prefix . 'link_internal" value="' . $this->_href->getInternalLink() . '" size="6" />
							' . $treeLink . '
						</td>
					</tr>';
        }
        if (!isset($options['external']) || $options['external'] == true) {
            $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_EXTERNAL ? ' checked="checked"' : '';
            $s .= '
					<tr>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_2" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_EXTERNAL . '"' . $checked . ' /></td>
						<td' . $tdClassDark . '>
							<label for="' . $this->_prefix . 'link_type_2">' . $cms_language->getMessage(self::MESSAGE_PAGE_EXTERNALLINK) . '</label>
							<input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_external" name="' . $this->_prefix . 'link_external" value="' . io::htmlspecialchars($this->_href->getExternalLink()) . '" size="30" />
						</td>
					</tr>
				';
        }
        if (!isset($options['file']) || $options['file'] == true) {
            $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_FILE ? ' checked="checked"' : '';
            $s .= '
					<tr>
						<td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_3" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_FILE . '"' . $checked . ' /></td>
						<td' . $tdClassLight . '>
							<label for="' . $this->_prefix . 'link_type_3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINKFILE) . '</label>
							<input type="file"' . $inputClass . ' name="' . $this->_prefix . 'link_file" /><br />
							<label for="' . $this->_prefix . 'link_edit_linkfile"><input type="checkbox" id="' . $this->_prefix . 'link_edit_linkfile" name="' . $this->_prefix . 'link_edit_linkfile" value="1" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_FIELD_EDITFILE) . '</label>';
            if ($this->_href->getFileLink(false, $module, $dataLocation)) {
                $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : <a href="' . $this->_href->getFileLink(true, $module, $dataLocation) . '" target="_blank">' . $this->_href->getFileLink(false, $module, $dataLocation) . '</a>';
            } else {
                $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : ' . $cms_language->getMessage(self::MESSAGE_PAGE_NO_FILE);
            }
            $s .= '	</td>
					</tr>';
        }
        if (!isset($options['destination']) || $options['destination'] == true) {
            $popup = $this->_href->getPopup();
            $checked_pop = isset($popup['width']) && $popup['width'] > 0 ? ' checked="checked"' : '';
            $checked_top = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_top' ? ' checked="checked"' : '';
            $checked_bl = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_blank' ? ' checked="checked"' : '';
            if (!$checked_pop && !$checked_top && !$checked_bl) {
                $checked_top = ' checked="checked"';
            }
            $width = isset($popup['width']) ? $popup['width'] : 0;
            $height = isset($popup['height']) ? $popup['height'] : 0;
            $s .= '
					<!-- Link target -->
					<tr>
						<th' . $tdClass . ' rowspan="3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_SHOW) . '</th>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_top" name="' . $this->_prefix . 'link_target" value="top"' . $checked_top . ' /></td>
						<td' . $tdClassDark . '>
							<label for="' . $this->_prefix . 'link_target_top"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_TOP) . '</label>
						</td>
					</tr>
					<tr>
						<td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_target_blank" name="' . $this->_prefix . 'link_target" value="blank"' . $checked_bl . ' /></td>
						<td' . $tdClassLight . '>
							<label for="' . $this->_prefix . 'link_target_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_blank.gif" alt="" border="0" align="absmiddle" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_BLANK) . '</label>
						</td>
					</tr>
					<tr>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_popup" name="' . $this->_prefix . 'link_target" value="popup"' . $checked_pop . ' /></td>
						<td' . $tdClassDark . '>
							<label for="' . $this->_prefix . 'link_target_popup"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_POPUP) . ' : </label>
							' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_WIDTH) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_width" value="' . $width . '" size="3" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_HEIGHT) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_height" value="' . $height . '" size="3" />
						</td>
					</tr>';
        }
        $s .= '</table>';
        return $s;
    }
Example #7
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);
 }
 }
 $pages = array_unique($pages);
 sort($pages);
 if (sizeof($pages)) {
     $validPages = CMS_tree::pagesExistsInUserSpace($pages);
     if (sizeof($validPages)) {
         if (sizeof($validPages) > 3) {
             //submit pages to regenerator
             CMS_tree::submitToRegenerator($validPages, true);
             $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE) . ' : ' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_SUBMITED, array(sizeof($validPages)));
         } else {
             //regenerate pages
             @set_time_limit(1000);
             $regenok = $regenerror = 0;
             foreach ($validPages as $pageID) {
                 $pg = CMS_tree::getPageByID($pageID);
                 if (is_a($pg, 'CMS_page') && !$pg->hasError()) {
                     if ($pg->regenerate(true)) {
                         $regenok++;
                     } else {
                         $regenerror++;
                     }
                 }
             }
             if ($regenok) {
                 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE) . ' : ' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATED, array($regenok));
             }
             if ($regenerror) {
                 $cms_message .= $cms_message ? '<br />' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror)) : $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror));
             }
         }
Example #9
0
 public static function getNewsletterContent($pageId)
 {
     $page = CMS_tree::getPageByID($pageId);
     if ($page->hasError()) {
         return;
     }
     $website = $page->getWebsite();
     $websiteUrl = $website->getURL();
     $language = CMS_languagesCatalog::getByCode($page->getLanguage());
     $content = $page->getContent($language, PAGE_VISUALMODE_HTML_PUBLIC);
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $page);
     $modulesTreatment->setDefinition($content);
     $content = $modulesTreatment->treatContent(true);
     //eval all php code in page
     $php_evalued_content = io::evalPHPCode($content);
     //change all relative URL in page
     $parsed_content = self::prepareHTML($php_evalued_content, $websiteUrl);
     return $parsed_content;
 }
Example #10
0
 /**
  * Get the page clearance root for a given page (this function must be as fast as possible
  * because it is often used with APPLICATION_ENFORCES_ACCESS_CONTROL)
  *
  * @param integer $pageId The DB ID of the page we test
  * @return The root page (CMS_page if $outputCMS_page is true, else pageID)
  * @access public
  * @static
  */
 function getPageClearanceRoot($pageId, $outputCMS_page = true)
 {
     static $clearances;
     $hash = md5($this->getId() . '-' . serialize(func_get_args()));
     if (isset($clearances[$hash])) {
         return $clearances[$hash];
     }
     if (!$this->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
         $clearances = $this->_pageClearances->getElements();
         $nearestRoot = false;
         //get the full lineage of queried page
         $lineage = CMS_tree::getLineage(APPLICATION_ROOT_PAGE_ID, $pageId, false);
         if (!$lineage) {
             CMS_grandFather::raiseError('Lineage error for page : ' . $pageId);
             $clearances[$hash] = false;
             return $clearances[$hash];
         } else {
             $lineage = array_reverse($lineage);
             foreach ($lineage as $ancestor) {
                 foreach ($clearances as $clearance) {
                     if ($ancestor == $clearance[0]) {
                         $nearestRoot = $ancestor;
                         break 2;
                     }
                 }
             }
         }
     } else {
         $nearestRoot = APPLICATION_ROOT_PAGE_ID;
     }
     if ($outputCMS_page) {
         $clearances[$hash] = CMS_tree::getPageByID($nearestRoot);
     } else {
         $clearances[$hash] = $nearestRoot;
     }
     return $clearances[$hash];
 }
Example #11
0
		</select>
		</td>
	</tr>
	<tr>
		<td class="admin" align="right">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_FAVICON) . '</td>
		<td class="admin"><input type="text" size="30" maxlength="255" class="admin_input_long_text" name="favicon" value="' . htmlspecialchars($website->getMeta('favicon')) . '" />&nbsp; <span class="admin_comment">(' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_FAVICON_COMMENT) . ')</span></td>
	</tr>
	<tr>
		<td colspan="2" class="admin"><br /><input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_BUTTON_VALIDATE) . '" /></td>
	</tr>
</table>
</fieldset>
</form>
<br />
' . $cms_language->getMessage(MESSAGE_FORM_MANDATORY_FIELDS) . '
<br /><br />';
$codenames = $website->getAllPagesCodenames();
if ($codenames) {
    $content .= '
	<fieldset class="admin">
	<legend class="admin"><strong>' . $cms_language->getMessage(MESSAGE_PAGE_CODENAMES) . '</strong></legend><ul>';
    foreach ($codenames as $codename => $pageId) {
        $page = CMS_tree::getPageById($pageId);
        $content .= '<li>' . $codename . ' : <a href="#" onclick="Automne.utils.getPageById(' . $page->getID() . ');Ext.WindowMgr.getActive().close();" class="admin">' . $page->getTitle() . ' (' . $page->getID() . ')</a></li>';
    }
    $content .= '
	</ul></fieldset>
	';
}
$dialog->setContent($content);
$dialog->show();
Example #12
0
 /**
  * Returns The URL of the current website, according to parameter or constant CURRENT_PAGE or the main domain URL if constant does not exists
  * Static function.
  *
  * @param mixed $currentPage : The current page id or CMS_page
  * @return string The current website URL
  * @access public
  */
 static function getCurrentDomain($currentPage = '')
 {
     static $domain;
     if (!isset($domain)) {
         $domain = '';
         if (io::isPositiveInteger($currentPage)) {
             $page = CMS_tree::getPageByID($currentPage);
         } elseif (is_object($currentPage)) {
             $page = $currentPage;
         } elseif (defined('CURRENT_PAGE') && io::isPositiveInteger(CURRENT_PAGE)) {
             $page = CMS_tree::getPageByID(CURRENT_PAGE);
         }
         if (isset($page) && is_object($page) && !$page->hasError()) {
             $domain = $page->getWebsite()->getURL();
             //check for HTTPS
             if ($page->isHTTPS() || defined('PAGE_SSL_MODE') && PAGE_SSL_MODE) {
                 $domain = str_ireplace('http://', 'https://', $domain);
             }
         }
         if (!$domain) {
             $domain = CMS_websitesCatalog::getMainURL();
         }
     }
     return $domain;
 }
Example #13
0
         $lockUser = CMS_profile_usersCatalog::getById($hasLock);
         $panelContent .= "\n\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNLOCK_LOCKED_PAGE, array(io::htmlspecialchars($lockUser->getFullName()))) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNLOCK_PAGE) . "</span>',\n\t\t\t\t\t\t\t\ticonCls: 'atm-pic-unlock',\n\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNLOCK_CONFIRM, array(io::htmlspecialchars($lockUser->getFullName()))) . "',\n\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'resource-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresource:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodule:\t\t\t'standard',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t'unlock'\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));";
     } elseif ($fromtab == 'edit' && $cms_user->getUserID() == $hasLock) {
         $panelContent .= $pageDraft;
     }
 } else {
     if ($cms_page->getProposedLocation() == RESOURCE_LOCATION_DELETED) {
         //undelete
         $panelContent .= "\n\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_DELETION_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_DELETION) . "</span>',\n\t\t\t\t\t\t\t\ticonCls: 'atm-pic-undelete',\n\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'undelete'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));";
     } elseif ($cms_page->getProposedLocation() == RESOURCE_LOCATION_ARCHIVED) {
         //unarchive
         $panelContent .= "\n\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_ARCHIVING_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_ARCHIVING) . "</span>',\n\t\t\t\t\t\t\t\ticonCls: 'atm-pic-unarchive',\n\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'unarchive'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}));";
     } else {
         if (!$cms_page->isProtected()) {
             //move page
             $father = CMS_tree::getAncestor($cms_page, 1);
             $draggable = is_object($father) && $cms_user->hasPageClearance($father->getID(), CLEARANCE_PAGE_EDIT) && (!$hasSiblings || $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) && $cms_page->getID() != APPLICATION_ROOT_PAGE_ID);
             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}));";
Example #14
0
 /**
  * get object previzualisation URL if set
  *
  * @param boolean $addPrevizParameter : add the previz=previz parameter at end of address (default : true)
  * @return string : the object previzualisation URL or false if none set
  * @access public
  */
 function getPrevizPageURL($addPrevizParameter = true)
 {
     //get Object definition
     $objectDef = $this->getObjectDefinition();
     if (!$objectDef->getValue("previewURL")) {
         //no previz set
         return false;
     }
     $previzInfos = explode('||', $objectDef->getValue("previewURL"));
     if (!sensitiveIO::isPositiveInteger($previzInfos[0])) {
         //no valid previz page set
         return false;
     }
     $page = CMS_tree::getPageByID($previzInfos[0]);
     if (!$page || $page->hasError()) {
         //no valid previz page set
         return false;
     }
     $previewPageURL = $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, false, $addPrevizParameter);
     if (!$previewPageURL) {
         //no valid previz page set
         return false;
     }
     //convert URL parameters
     $parameters['item'] =& $this;
     $parameters['public'] = $this->_public;
     $polymodParsing = new CMS_polymod_definition_parsing($previzInfos[1], false);
     $previewPageParams = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
     //overwrite website host with admin current host (to avoid session lost)
     if ($addPrevizParameter) {
         //check for website host
         $pageHost = @parse_url($previewPageURL, PHP_URL_HOST);
         $httpHost = @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST'];
         if ($pageHost && $_SERVER['HTTP_HOST'] && io::strtolower($httpHost) != io::strtolower($pageHost)) {
             //page host is not the same of current host so change it to avoid JS restriction
             $previewPageURL = str_replace($pageHost, $httpHost, $previewPageURL);
         }
         //check for website protocol
         $pageScheme = @parse_url($previewPageURL, PHP_URL_SCHEME);
         $currentScheme = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] && strtolower($_SERVER["HTTPS"]) != 'off' ? 'https' : 'http';
         if ($pageScheme && $currentScheme != io::strtolower($pageScheme)) {
             $previewPageURL = str_replace($pageScheme . '://', $currentScheme . '://', $panelURL);
         }
     }
     return $previewPageURL . '?' . $previewPageParams . ($addPrevizParameter ? '&atm-previz=previz' : '');
 }
Example #15
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);
         }
     }
 }
         $view->setContent($content);
     } else {
         $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_TEMPLATE);
     }
     break;
 case 'regenerate':
     //submit all pages of this template to the regenerator
     $pages = $template->getPages(true);
     $pagesIds = array();
     foreach ($pages as $page) {
         if ($page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
             $pagesIds[] = $page->getID();
         }
     }
     if ($pagesIds) {
         CMS_tree::submitToRegenerator($pagesIds, true);
         $cms_message = $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGEN, array(sizeof($pagesIds)));
     } else {
         $cms_message = $cms_language->getMessage(MESSAGE_ERROR_NO_PUBLIC_PAGE);
     }
     break;
 case 'copy':
     if (is_a($template, "CMS_pageTemplate") && !$template->hasError()) {
         //Dupplicate selected template with given label
         $label = $cms_language->getMessage(MESSAGE_PAGE_COPY_OF) . ' ' . $template->getLabel();
         $template = CMS_pageTemplatesCatalog::getCloneFromID($templateId, $label);
         $log = new CMS_log();
         $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Template : " . $label . " (create template)");
         $content = array('success' => array('templateId' => $template->getID()));
         $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label));
         $view->setContent($content);
Example #17
0
 /**
  * Get the page property specified
  *
  * @param CMS_page $page The page we want the property of
  * @param string $property The property we want
  * @param boolean $public Do we want the public or edited property ?
  * @return mixed The property value
  * @access private
  */
 protected function _getPageProperty(&$page, $property, $public)
 {
     if (!is_a($page, "CMS_page")) {
         $this->raiseError("Page parameter must be an object");
         return;
     }
     switch ($property) {
         case "title":
             return $page->getTitle($public);
             break;
         case "father":
             return CMS_tree::getFather($page, false, $public);
             break;
         case "id":
             return $page->getID();
             break;
         case "website":
             return $page->getWebsite()->getCodename();
             break;
         case "codename":
             return $page->getCodename($public);
             break;
     }
 }
            $label = $redirectlink->getExternalLink();
            $redirectlink->setTarget('_blank');
            $redirect = $redirectlink->getHTML(io::ellipsis($label, '80'), MOD_STANDARD_CODENAME, RESOURCE_DATA_LOCATION_EDITED);
        }
    } else {
        $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $page->getTitle() . '" (' . $page->getID() . ')';
        $redirect = '<a href="' . $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>';
    }
    $content = '
	<div id="atm-center">
		<div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array($redirect)) . '</div>
	</div>';
} else {
    if (isset($_GET['url'])) {
        $url = urldecode($_GET['url']);
        if ($page = CMS_tree::analyseURL($url)) {
            $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $page->getTitle() . '" (' . $page->getID() . ')';
            $redirect = '<a href="' . $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>';
        } else {
            $redirect = '<a href="' . $url . '" target="_blank">' . io::htmlspecialchars($url) . '</a>';
        }
        $content = '
	<div id="atm-center">
		<div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array($redirect)) . '</div>
	</div>';
    } else {
        $content = '
	<div id="atm-center">
		<div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_PAGE_REDIRECT_ERROR) . '</div>
	</div>';
    }
 public function getPageTitle()
 {
     $pageId = $this->getValue('page');
     return CMS_tree::getPageValue($pageId, 'title');
 }
Example #20
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 #21
0
 /**
  * Get the recursive HTML display for a recursivelinks, if it passes the condition of course.
  *
  * @param CMS_page $parsedPage The page in which the linx tag is
  * @param integer $level The current level of recursivity
  * @param multidimentionnal array $recursiveTree The tree to display
  * @param array $pages array of pages objects (indexed by id)
  * @param boolean $public Is the page data to show the public or edited one ?
  * @param array $lineage The lineage of the pages (used to see wich recursions need to be done in closed link display mode)
  * @return string The html of the recursive link
  * @access public
  */
 function getRecursiveOutput(&$parsedPage, $level = 0, $recursiveTree, &$pages, $public, $lineage = array())
 {
     $html = '';
     if (is_array($recursiveTree) && $recursiveTree) {
         $rank = 1;
         $levelhtml = '';
         foreach ($recursiveTree as $pageID => $subPages) {
             //get Page Object
             $page = $pages[$pageID];
             //instanciate page if not exists as object
             if (!is_object($page) && sensitiveIO::isPositiveInteger($page)) {
                 $page = CMS_tree::getPageByID($page);
             }
             $pagehtml = '';
             //check if page pass the condition
             if (is_object($page) && (!$this->hasCondition() || $this->pagePassesConditions($parsedPage, $page, $public, $rank)) && (!$public || $public && $page->isUseable() && $page->getPublication() == RESOURCE_PUBLICATION_PUBLIC)) {
                 //get pages infos
                 $linkTitle = $page->getLinkTitle($public);
                 $title = $page->getTitle($public);
                 //set pages infos in html template
                 $replace = array("{{title}}" => io::sanitizeHTMLString($linkTitle), "{{jstitle}}" => io::sanitizeHTMLString($linkTitle), "{{pagetitle}}" => io::sanitizeHTMLString($title), "{{jspagetitle}}" => io::sanitizeHTMLString($title), "{{desc}}" => io::sanitizeHTMLString($page->getDescription($public)), "{{href}}" => $page->getURL(), "{{id}}" => $page->getID(), "{{codename}}" => $page->getCodename($public), "{{number}}" => $rank - 1, "{{modulo}}" => ($rank - 1) % 2, "{{lvlClass}}" => "CMS_lvl" . ($level + 1), "{{currentClass}}" => $parsedPage->getID() == $page->getID() ? "CMS_current" : "", 'id="{{currentID}}"' => $parsedPage->getID() == $page->getID() ? 'id="CMS_current"' : "");
                 if (io::strpos($this->_htmlTemplate, '{{isParent}}') !== false) {
                     //only if needed because getLineage require a lot of query
                     $pagelineage = CMS_tree::getLineage($page->getID(), $parsedPage->getID(), false);
                     $replace['class="{{isParent}}"'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'class="CMS_parent"' : "";
                     $replace['{{isParent}}'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'CMS_parent' : "";
                     $replace['id="{{isParent}}"'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'id="CMS_parent"' : "";
                 }
                 if (io::strpos($this->_htmlTemplate, '{{website') !== false) {
                     //only if needed because getWebsite require a lot of query
                     $website = $page->getWebsite();
                     $replace['{{websitetitle}}'] = $website->getLabel();
                     $replace['{{websitecodename}}'] = $website->getCodename($public);
                 }
                 $pagehtml = str_replace(array_keys($replace), $replace, $this->_htmlTemplate);
                 if ($level == 0 && ($this->_root === 'false' || !$this->_root)) {
                     $pagehtml = str_replace(array_keys($replace), $replace, $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public, $lineage));
                 } else {
                     //check if link is in open or closed mode
                     if ($this->_mode == "open") {
                         //if it is open mode recurse indefinitely (until end of tree)
                         //then mark info of sublevels or not
                         $replace = array("{{typeClass}}" => $subPages ? "CMS_sub" : "CMS_nosub", "{{sublevel}}" => $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public));
                         $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml);
                     } else {
                         //if it is 'close' mode recurse only for pages in current lineage
                         $recurse = false;
                         if (is_array($lineage)) {
                             $recurse = in_array($page->getID(), $lineage) ? true : false;
                         }
                         //then mark info of sublevels or not and if level is open or not
                         $sub = $recurse ? "CMS_open" : "CMS_sub";
                         $replace = array("{{typeClass}}" => $subPages ? $sub : "CMS_nosub", "{{sublevel}}" => $recurse ? $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public, $lineage) : "");
                         if (!$recurse) {
                             //needed to update link targets which is used after to register watched links
                             $it = new RecursiveArrayIterator($subPages);
                             foreach ($it as $pageID => $element) {
                                 unset($pages[$pageID]);
                             }
                         }
                         $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml);
                     }
                 }
                 //add APPLICATION_ENFORCES_ACCESS_CONTROL php access checking
                 if (APPLICATION_ENFORCES_ACCESS_CONTROL && $public) {
                     $pagehtml = $this->_addSlashAroundPHPContent($pagehtml);
                     $replace = array("<?php" => "';", "?>" => "echo '");
                     $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml);
                     $pagehtml = '<?php if ($cms_user->hasPageClearance(' . $page->getID() . ', CLEARANCE_PAGE_VIEW)) {' . "\n" . 'echo \'' . $pagehtml . '\';' . "\n" . '}' . "\n" . '?>';
                 }
                 $rank++;
             } else {
                 //needed to update link targets which is used after to register watched links
                 unset($pages[$pageID]);
             }
             $levelhtml .= $pagehtml;
         }
         if ($level == 0 && ($this->_root === 'false' || !$this->_root)) {
             $html = $levelhtml;
         } else {
             if ($levelhtml && io::strpos($this->_subleveltemplate, "{{sublevel}}") !== false) {
                 $replace = array("{{sublevel}}" => $levelhtml, "{{lvlClass}}" => "CMS_lvl" . ($level + 1));
                 $html = str_replace(array_keys($replace), $replace, $this->_subleveltemplate);
             } else {
                 $html = $levelhtml;
             }
         }
     }
     return $html;
 }
Example #22
0
// | The license text is bundled with this package in the file			  |
// | LICENSE-GPL, and is available through the world-wide-web at		  |
// | http://www.gnu.org/copyleft/gpl.html.								  |
// +----------------------------------------------------------------------+
// | Author: Sébastien Pauchet <*****@*****.**>      |
// +----------------------------------------------------------------------+
//
// $Id: tree-lineage.php,v 1.3 2010/03/08 16:41:22 sebastien Exp $
/**
 * PHP page : Load tree window infos
 * Used accross an Ajax request render page tree in the tree window
 *
 * @package Automne
 * @subpackage admin
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_JSON);
//This file is an admin file. Interface must be secure
$view->setSecure();
$rootId = (int) sensitiveIO::request('root', 'sensitiveIO::isPositiveInteger', APPLICATION_ROOT_PAGE_ID);
$nodeId = (int) sensitiveIO::request('node', 'sensitiveIO::isPositiveInteger', APPLICATION_ROOT_PAGE_ID);
$lineage = CMS_tree::getLineage($rootId, $nodeId, false);
if (!$lineage) {
    $lineage = array();
}
$view->setContent($lineage);
$view->show();
 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;
 }
Example #24
0
 /**
  * Module script task
  * @param array $parameters the task parameters
  *		task : string task to execute
  *		object : string module codename for the task
  *		field : string module uid
  *		...	: optional field relative parameters
  * @return Boolean true/false
  * @access public
  */
 function scriptTask($parameters)
 {
     switch ($parameters['task']) {
         case 'emailNotification':
             @set_time_limit(300);
             $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
             //create a new script for all recipients
             $allUsers = $this->_getRecipients($parameters['object']);
             foreach ($allUsers as $userId) {
                 //add script to send email for user if needed
                 CMS_scriptsManager::addScript($module, array('task' => 'emailSend', 'user' => $userId, 'field' => $parameters['field'], 'object' => $parameters['object']));
             }
             //then set sending date to current date
             $sendingDate = new CMS_date();
             $sendingDate->setNow();
             $this->_subfieldValues[1]->setValue($sendingDate->getDBValue());
             $this->writeToPersistence();
             break;
         case 'emailSend':
             @set_time_limit(300);
             $params = $this->getParamsValues();
             if (!sensitiveIO::isPositiveInteger($parameters['user'])) {
                 return false;
             }
             //instanciate script related item
             $item = CMS_poly_object_catalog::getObjectByID($parameters['object'], false, true);
             if (!is_object($item) || $item->hasError()) {
                 return false;
             }
             //instanciate user
             $cms_user = new CMS_profile_user($parameters['user']);
             //check user
             if (!$cms_user || $cms_user->hasError() || !$cms_user->isActive() || $cms_user->isDeleted() || !sensitiveIO::isValidEmail($cms_user->getEmail())) {
                 return false;
             }
             $cms_language = $cms_user->getLanguage();
             //globalise cms_user and cms_language
             $GLOBALS['cms_language'] = $cms_user->getLanguage();
             $GLOBALS['cms_user'] = $cms_user;
             //check user clearance on object
             if (!$item->userHasClearance($cms_user, CLEARANCE_MODULE_VIEW)) {
                 return false;
             }
             //create email subject
             $parameters['item'] = $item;
             $parameters['public'] = true;
             $polymodParsing = new CMS_polymod_definition_parsing($params['emailSubject'], false);
             $subject = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
             $body = '';
             //create email body
             if ($params['emailBody']['type'] == 1) {
                 //send body
                 $parameters['module'] = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
                 $polymodParsing = new CMS_polymod_definition_parsing($params['emailBody']['html'], true, CMS_polymod_definition_parsing::PARSE_MODE, $parameters['module']);
                 $body = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
             } elseif ($params['emailBody']['type'] == 2) {
                 //send a page
                 $page = CMS_tree::getPageById($params['emailBody']['pageID']);
                 if (!$page || $page->hasError()) {
                     $this->raiseError('Page ID is not a valid page : ' . $params['emailBody']['pageID']);
                     return false;
                 }
                 $pageHTMLFile = new CMS_file($page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM));
                 if (!$pageHTMLFile->exists()) {
                     $this->raiseError('Page HTML file does not exists : ' . $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM));
                     return false;
                 }
                 $body = $pageHTMLFile->readContent();
                 //create page URL call
                 $polymodParsing = new CMS_polymod_definition_parsing($params['emailBody']['pageURL'], false);
                 $pageURL = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
                 parse_str($pageURL, $GLOBALS['_REQUEST']);
                 //$GLOBALS['_REQUEST']
                 //parse and eval HTML page
                 $cms_page_included = true;
                 $GLOBALS['cms_page_included'] = $cms_page_included;
                 //eval() the PHP code
                 $body = sensitiveIO::evalPHPCode($body);
                 $website = $page->getWebsite();
                 $webroot = $website->getURL();
                 //replace URLs values
                 $replace = array('="/' => '="' . $webroot . '/', "='/" => "='" . $webroot . "/", "url(/" => "url(" . $webroot . "/");
                 $body = str_replace(array_keys($replace), $replace, $body);
             } else {
                 $this->raiseError('No valid email type to send : ' . $params['emailBody']['type']);
                 return false;
             }
             if (isset($sendmail)) {
                 //$body .= print_r($sendmail,true);
             }
             //drop email sending
             if (isset($sendmail) && $sendmail === false) {
                 return false;
             }
             //if no body for email or if sendmail var is set to false, quit
             if (!$body) {
                 $this->raiseError('No email body to send ... Email parameters : user : '******'user'] . ' - object ' . $parameters['object']);
                 return false;
             }
             //This code is for debug purpose only.
             //$testFile = new CMS_file('/test/test_'.$cms_user->getUserId().'.php', CMS_file::WEBROOT);
             //$testFile->setContent($body);
             //$testFile->writeToPersistence();
             // Set email
             $email = new CMS_email();
             $email->setSubject($subject);
             $email->setEmailHTML($body);
             $email->setEmailTo($cms_user->getEmail());
             if ($params['includeFiles']) {
                 //check for file fields attached to object
                 $files = array();
                 $this->_getFieldsFiles($item, $files);
                 if (sizeof($files)) {
                     foreach ($files as $file) {
                         $email->setFile($file);
                     }
                 }
             }
             //set email From
             if (!$params['emailFrom']) {
                 $email->setFromName(APPLICATION_LABEL);
                 $email->setEmailFrom(APPLICATION_POSTMASTER_EMAIL);
             } else {
                 $email->setFromName($params['emailFrom']);
                 $email->setEmailFrom($params['emailFrom']);
             }
             //Send
             if ($email->sendEmail()) {
                 //store email sent number
                 $this->_subfieldValues[2]->setValue($this->_subfieldValues[2]->getValue() + 1);
                 $this->writeToPersistence();
                 return true;
             } else {
                 return false;
             }
             break;
         default:
             $this->raiseError('No valid task given : ' . $parameters['task']);
             return false;
             break;
     }
 }
Example #25
0
 /**
  * Get the pages based on this template or templates clones
  *
  * @param boolean $withClones : get also all pages based on the clones (default : false)
  * @return array(CMS_page) The pages
  * @access private
  */
 function getPages($withClones = false)
 {
     if (!$this->_id || !$this->_definitionFile) {
         return array();
     }
     if ($withClones) {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tpageTemplates\n\t\t\t\twhere\n\t\t\t\t\ttemplate_pag=id_pt\n\t\t\t\t\tand definitionFile_pt = '" . $this->_definitionFile . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages\n\t\t\t\twhere\n\t\t\t\t\ttemplate_pag='" . $this->_id . "'\n\t\t\t";
     }
     $q = new CMS_query($sql);
     $pages = array();
     while ($id = $q->getValue("id_pag")) {
         $pg = CMS_tree::getPageByID($id);
         if (!$pg->hasError()) {
             $pages[] = $pg;
         }
     }
     return $pages;
 }
Example #26
0
     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:
     if (strpos($varAttributes['vartype'], 'fields') !== false) {
         // Assume it's a polymod object field
         $fieldId = io::substr($varAttributes['vartype'], strrpos($varAttributes['vartype'], 'fields') + 9, -2);
         $objectId = CMS_poly_object_catalog::getObjectIDForField($fieldId);
         if (io::isPositiveInteger($objectId)) {
             $objectFields = CMS_poly_object_catalog::getFieldsDefinition($objectId);
             if (sensitiveIO::isPositiveInteger($fieldId)) {
                 //subobjects
                 $field = $objectFields[$fieldId];
//
// $Id: page-previsualization.php,v 1.5 2010/03/08 16:41:19 sebastien Exp $
/**
 * PHP page : page previsualization
 * Used to view the page edited data.
 *
 * @package Automne
 * @subpackage admin
 * @author Antoine Pouch <*****@*****.**> &
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
$currentPage = sensitiveIO::request('currentPage', 'sensitiveIO::isPositiveInteger', CMS_session::getPageID());
$draft = sensitiveIO::request('draft') ? true : false;
//unset request to avoid it to have interaction with page code
sensitiveIO::unsetRequest(array('draft', 'currentPage'));
//CHECKS
if (!SensitiveIO::isPositiveInteger($currentPage)) {
    die("Invalid page");
}
//view edited or edition mode ?
$cms_visual_mode = $draft ? PAGE_VISUALMODE_HTML_EDITION : PAGE_VISUALMODE_HTML_EDITED;
$cms_page = CMS_tree::getPageByID($currentPage);
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) {
    die('No rigths on page ...');
    exit;
}
//unset vars to avoid interraction with page
unset($currentPage);
unset($draft);
echo $cms_page->getContent($cms_language, $cms_visual_mode);
Example #28
0
 /**
  * Return the module CSS files
  *
  * @return array : the module css file in /css/modules/codename
  * @access public
  */
 function getCSSFiles($pageId = '', $allFiles = false)
 {
     $files = array();
     $medias = array('all', 'aural', 'braille', 'embossed', 'handheld', 'print', 'projection', 'screen', 'tty', 'tv');
     //get generic files
     foreach ($medias as $media) {
         if ($media == 'all') {
             if (file_exists(PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename . '.css')) {
                 $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', PATH_CSS_FS . '/modules/' . $this->_codename . '.css'));
             }
         }
         if (file_exists(PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename . '-' . $media . '.css')) {
             $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', PATH_CSS_FS . '/modules/' . $this->_codename . '-' . $media . '.css'));
         }
     }
     //get subdir files if any
     $dirname = PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename;
     if (@is_dir($dirname)) {
         try {
             //all subdirs or only this dir
             $dir = $allFiles ? new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST) : new DirectoryIterator($dirname);
             foreach ($dir as $file) {
                 if ($file->isFile() && io::substr($file->getFilename(), -4) == ".css") {
                     $found = false;
                     foreach ($medias as $media) {
                         if (io::substr($file->getFilename(), -5 - strlen($media)) == '-' . $media . '.css') {
                             $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                             $found = true;
                         }
                     }
                     if (!$found) {
                         $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                     }
                 }
             }
         } catch (Exception $e) {
         }
     }
     //get website files if any
     if (!$allFiles && io::isPositiveInteger($pageId)) {
         $page = CMS_tree::getPageById($pageId);
         if ($page) {
             $website = $page->getWebsite();
             if ($website) {
                 if (@is_dir($dirname . DIRECTORY_SEPARATOR . $website->getCodename())) {
                     try {
                         foreach (new DirectoryIterator($dirname . DIRECTORY_SEPARATOR . $website->getCodename()) as $file) {
                             if ($file->isFile() && io::substr($file->getFilename(), -4) == ".css") {
                                 $found = false;
                                 foreach ($medias as $media) {
                                     if (io::substr($file->getFilename(), -5 - strlen($media)) == '-' . $media . '.css') {
                                         $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                                         $found = true;
                                     }
                                 }
                                 if (!$found) {
                                     $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname()));
                                 }
                             }
                         }
                     } catch (Exception $e) {
                     }
                 }
             }
         }
     }
     return $files;
 }
Example #29
0
#!/usr/bin/env php
<?php 
// +----------------------------------------------------------------------+
// | Automne (TM)														  |
// +----------------------------------------------------------------------+
// | Copyright (c) 2000-2010 WS Interactive								  |
// +----------------------------------------------------------------------+
// | Automne is subject to version 2.0 or above of the GPL license.		  |
// | The license text is bundled with this package in the file			  |
// | LICENSE-GPL, and is available through the world-wide-web at		  |
// | http://www.gnu.org/copyleft/gpl.html.								  |
// +----------------------------------------------------------------------+
// | Author: Antoine Pouch <*****@*****.**>              |
// +----------------------------------------------------------------------+
/**
 * background script : regenerateall
 *
 * Regenerates All the pages : call the function in CMS_tree and lauch regenerator
 *
 * @package Automne
 * @subpackage scripts
 * @author Antoine Pouch <*****@*****.**>
 */
//must calculate the document root first (for compatibility with old scripts)
$_SERVER["DOCUMENT_ROOT"] = realpath(substr(dirname(__FILE__), 0, strlen(dirname(__FILE__)) - strpos(strrev(dirname(__FILE__)), "enmotua") - strlen("automne") - 1));
//include required file
require_once dirname(__FILE__) . '/../../../cms_rc_admin.php';
CMS_tree::regenerateAllPages(true);
Example #30
0
function getBigTree(&$user, &$lines, $page, $offset, $link, $pageProperty = false, $father)
{
    global $cms_language;
    global $hideMenu;
    global $pageProperty;
    global $title;
    global $backLink;
    global $pageLink;
    global $onClick;
    global $heading;
    global $frame;
    global $lineage;
    global $startRoot;
    global $linkTarget;
    global $cms_user;
    static $haveRootInDisplay;
    if (!$father) {
        $father = $page;
    }
    $stop = '1';
    $sign = 'plus';
    //get siblings
    $sibs = CMS_tree::getSiblings($page, false, false);
    //si pas de fils :
    // => on affiche aucun signe
    // => on sort
    if (!$sibs || !sizeof($sibs)) {
        $sign = '';
    } elseif (in_array($page->getID(), $lineage)) {
        $stop = '0';
        $sign = 'minus';
    }
    $status = $page->getStatus();
    if ($link && strpos($link, "%s") !== false) {
        $link_final = sprintf($link, $page->getID());
    } elseif ($link == 'false' && $onClick) {
        $link_final = "#";
        $link_onClick = ' onClick="' . sprintf($onClick, $page->getID()) . 'return false;"';
        $linkTarget = "_self";
    } else {
        $link_final = $link;
    }
    $pageTitle = PAGE_LINK_NAME_IN_TREE ? $page->getLinkTitle() : $page->getTitle();
    if ($link_final) {
        $link_final = '<a href="' . $link_final . '"' . $link_onClick . ' name="n' . $page->getID() . '" target="' . $linkTarget . '" class="admin_tree_page">' . htmlspecialchars($pageTitle) . '</a>';
    } else {
        $link_final = htmlspecialchars($pageTitle);
    }
    //page cell display
    $cell_display = '<a name="page_' . $page->getID() . '"></a>
		<table border="0" cellpadding="2" cellspacing="0">
		<tr>';
    $size = "0";
    for ($i = 0; $i < $offset; $i++) {
        $size = $size + 20;
    }
    if ($page->getID() == APPLICATION_ROOT_PAGE_ID || $haveRootInDisplay) {
        $size = $size - 20;
        $haveRootInDisplay = true;
    }
    if ($size > 0) {
        $cell_display .= '<td width="1"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="' . $size . '" height="2" border="0" /></td>';
    }
    switch ($sign) {
        case '':
            $cell_display .= '<td width="20"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="20" height="2" border="0" /></td>';
            break;
        case 'minus':
            if ($page->getID() != APPLICATION_ROOT_PAGE_ID) {
                $cell_display .= '<td width="20" align="center"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="20" height="1" border="0" /><br /><a href="' . $_SERVER["SCRIPT_NAME"] . '?root=' . $father->getID() . '&pageProperty=' . $pageProperty . '&hideMenu=' . $hideMenu . '&title=' . $title . '&backLink=' . $backLink . '&frame=' . $frame . '&heading=' . $heading . '&encodedPageLink=' . base64_encode($pageLink) . '&encodedOnClick=' . base64_encode($onClick) . '&linkTarget=' . $linkTarget . '#page_' . $page->getID() . '" class="admin_tree_sign">-</a></td>';
            }
            break;
        case 'plus':
            $cell_display .= '<td width="20" align="center"><img src="' . PATH_ADMIN_IMAGES_WR . '/../v3/img/pix_trans.gif" width="20" height="1" border="0" /><br /><a href="' . $_SERVER["SCRIPT_NAME"] . '?root=' . $page->getID() . '&pageProperty=' . $pageProperty . '&hideMenu=' . $hideMenu . '&title=' . $title . '&backLink=' . $backLink . '&frame=' . $frame . '&heading=' . $heading . '&encodedPageLink=' . base64_encode($pageLink) . '&encodedOnClick=' . base64_encode($onClick) . '&linkTarget=' . $linkTarget . '#page_' . $page->getID() . '" class="admin_tree_sign">+</a></td>';
            break;
    }
    //property display
    if ($pageProperty) {
        switch ($pageProperty) {
            case "last_creation_date":
                $lng = $user->getLanguage();
                $date = $page->getLastFileCreationDate();
                if (is_a($date, "CMS_date")) {
                    $date->setFormat($lng->getDateFormat());
                    $property_display = $date->getLocalizedDate();
                }
                break;
            case "template":
                $tmp = $page->getTemplate();
                $property_display = is_a($tmp, "CMS_pageTemplate") ? $tmp->getLabel() : '???';
                break;
        }
    } else {
        $property_display = $page->getID();
    }
    $cell_display .= '
			<td class="admin">' . $status->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $page->getID()) . '</td>
			<td class="admin_tree_page" nowrap="nowrap">' . $link_final . ' (' . $property_display . ')</td>
		</tr>
		</table>
	';
    $bgcolor = $page->getID() == $startRoot ? ' bgcolor="#DDDAD9"' : '';
    //add the line
    $lines .= '<tr onMouseOver="changeColor(this,\'DDDAD9\');" onMouseOut="changeColor(this,\'\');">
			<td' . $bgcolor . ' nowrap="nowrap">
				' . $cell_display . '
			</td>
		</tr>' . "\n";
    if ($stop) {
        return $lines;
    }
    //on traite les fils
    $sibs = CMS_tree::getSiblings($page);
    foreach ($sibs as $sib) {
        if ($user->hasPageClearance($sib->getID(), CLEARANCE_PAGE_VIEW)) {
            getBigTree($user, $lines, $sib, $offset + 1, $link, $pageProperty, $page);
        }
    }
}