Example #1
0
 /**
  * Get the HTML output
  *
  * @return string The HTML
  * @access public
  */
 function getOutput($register = false)
 {
     if ($this->hasError()) {
         return '';
     }
     //computes the targets (from selection)
     $this->_targets = $this->_buildTargets();
     //set output
     $output = '';
     if ($this->_type == 'recursivelinks') {
         $root = CMS_tree::getRoot();
         $lineage = CMS_tree::getLineage($root->getID(), $this->_page->getID(), false, $this->_publicTree);
         if (is_array($this->_displays)) {
             foreach ($this->_displays as $display) {
                 $html = $display->getRecursiveOutput($this->_page, 0, $this->_recursiveTargets, $this->_targets, $this->_publicTree, $lineage);
                 if ($html) {
                     $output .= $html;
                     break;
                 }
             }
         }
     } else {
         if (is_array($this->_displays)) {
             foreach ($this->_displays as $display) {
                 $displayOutput = '';
                 if (is_array($this->_targets) && $this->_targets) {
                     $sizeofTargets = sizeof($this->_targets);
                     for ($i = 0; $i < $sizeofTargets; $i++) {
                         $target = $this->_targets[$i];
                         $displayOutput .= $display->getOutput($this->_page, $target, $this->_publicTree, $i + 1, $this->_noerror, $this->_noselection);
                     }
                     $output .= $display->getSubLevelOutput($displayOutput);
                 } elseif (is_object($this->_noselection)) {
                     $output .= CMS_DOMDocument::DOMElementToString($this->_noselection, true);
                 }
             }
         }
     }
     if ($register) {
         $this->_register();
     }
     //append args to generated linx code
     if ($this->_args) {
         //append atm-row class and row-id to all first level tags found in row datas
         $domdocument = new CMS_DOMDocument();
         try {
             $domdocument->loadXML('<linx>' . $output . '</linx>');
         } catch (DOMException $e) {
             $this->raiseError('Parse error for linx : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($output));
             return '';
         }
         $rowNodes = $domdocument->getElementsByTagName('linx');
         if ($rowNodes->length == 1) {
             $rowXML = $rowNodes->item(0);
         }
         $elements = array();
         if (isset($rowXML)) {
             foreach ($rowXML->childNodes as $rowChildNode) {
                 if (is_a($rowChildNode, 'DOMElement') && $rowChildNode->tagName != 'script') {
                     if ($this->_args['class'] !== false) {
                         if ($rowChildNode->hasAttribute('class')) {
                             $rowChildNode->setAttribute('class', $rowChildNode->getAttribute('class') . ' ' . $this->_args['class']);
                         } else {
                             $rowChildNode->setAttribute('class', $this->_args['class']);
                         }
                     }
                     if ($this->_args['id'] !== false) {
                         $rowChildNode->setAttribute('id', $this->_args['id']);
                     }
                 }
             }
             $output = CMS_DOMDocument::DOMElementToString($rowXML, true);
         } else {
             $output = '';
         }
     }
     return $output;
 }
Example #2
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 #3
0
	<tr>
		<td class="admin" align="right"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_URL) . '</td>
		<td class="admin"><input type="text" size="30" class="admin_input_text" name="url" value="' . htmlspecialchars($website->getURL()) . '" /></td>
	</tr>
	<tr>
		<td class="admin" align="right">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_ROOT) . '</td>
		<td class="admin">' . htmlspecialchars($website_root->getTitle()) . ' (' . $website_root->getID() . ')<input type="hidden" name="root" value="' . $website_root->getID() . '" />
';
//users can modify the website root, unless it's the main root
if ($website_root->getID() != $grand_root->getID()) {
    $content .= '
		<input type="Button" onClick="location.replace(\'' . $tree_href . '&' . session_name() . '=' . session_id() . '\');" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_BUTTON_CHANGE) . '" />
	';
}
//build tree link
$grand_root = CMS_tree::getRoot();
$href404 = PATH_ADMIN_SPECIAL_TREE_WR;
$href404 .= '?root=' . $grand_root->getID();
$href404 .= '&amp;heading=' . $cms_language->getMessage(MESSAGE_PAGE_TREEH1);
$href404 .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('page404').value = '%s';self.close();");
$href404 .= '&encodedPageLink=' . base64_encode('false');
$href403 = PATH_ADMIN_SPECIAL_TREE_WR;
$href403 .= '?root=' . $grand_root->getID();
$href403 .= '&amp;heading=' . $cms_language->getMessage(MESSAGE_PAGE_TREEH1);
$href403 .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('page403').value = '%s';self.close();");
$href403 .= '&encodedPageLink=' . base64_encode('false');
$redirAltChecked = $website->redirectAltDomain() ? ' checked="checked"' : '';
$content .= '
		</td>
	</tr>
	<tr>
Example #4
0
    function getHTMLSubFieldsParametersEmailBody($language, $prefixName)
    {
        global $cms_language, $moduleCodename, $object;
        $module = CMS_modulesCatalog::getByCodename($moduleCodename);
        $params = $this->getParamsValues();
        $values = $this->_parameterValues;
        $parameters = $this->getSubFieldParameters();
        $htmlSelected = !isset($params['emailBody']['type']) || $params['emailBody']['type'] == 1 ? ' checked="checked"' : '';
        $input = '
		<fieldset>
			<legend><label for="' . $prefixName . 'message_body_html"><input' . $htmlSelected . ' id="' . $prefixName . 'message_body_html" type="radio" name="' . $prefixName . 'emailBody" value="1" />' . $cms_language->getMessage(self::MESSAGE_OBJECT_EMAIL_PARAMETER_BODY_HTML, false, MOD_POLYMOD_CODENAME) . '</label></legend>';
        foreach ($parameters as $parameterID => $parameter) {
            $paramValue = $values[$parameterID];
            if ($parameter["type"] == "emailbody") {
                $html = isset($params['emailBody']['html']) ? $params['emailBody']['html'] : '';
                $input .= '<textarea class="admin_textarea" cols="100" rows="15" name="' . $prefixName . 'emailBody_html">' . $module->convertDefinitionString($html, true) . '</textarea>';
            }
        }
        $pageSelected = isset($params['emailBody']['type']) && $params['emailBody']['type'] == 2 ? ' checked="checked"' : '';
        $pageID = isset($params['emailBody']['pageID']) ? $params['emailBody']['pageID'] : '';
        $pageURL = isset($params['emailBody']['pageURL']) ? $params['emailBody']['pageURL'] : '';
        $input .= '
		</fieldset>
		<fieldset>
			<legend><label for="' . $prefixName . 'message_body_page"><input' . $pageSelected . ' id="' . $prefixName . 'message_body_page" type="radio" name="' . $prefixName . 'emailBody" value="2" />' . $cms_language->getMessage(self::MESSAGE_OBJECT_EMAIL_PARAMETER_BODY_PAGE, false, MOD_POLYMOD_CODENAME) . '</label></legend>
			<input type="text" class="admin_input_text" id="' . $prefixName . 'emailBody_pageID" name="' . $prefixName . 'emailBody_pageID" value="' . io::htmlspecialchars($pageID) . '" size="6" />';
        //build tree link
        $grand_root = CMS_tree::getRoot();
        $href = PATH_ADMIN_SPECIAL_TREE_WR;
        $href .= '?root=' . $grand_root->getID();
        $href .= '&amp;heading=' . $cms_language->getMessage(MESSAGE_PAGE_TREEH1);
        $href .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $prefixName . "emailBody_pageID').value = '%s';self.close();");
        $href .= '&encodedPageLink=' . base64_encode('false');
        $input .= '&nbsp;<a href="' . $href . '" class="admin" target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/picto-arbo.gif" border="0" align="absmiddle" /></a>
			&nbsp;?<input type="text" size="80" name="' . $prefixName . 'emailBody_pageURL" value="' . io::htmlspecialchars($module->convertDefinitionString($pageURL, true)) . '" class="admin_input_text" />
		</fieldset>';
        //object Explanation
        $input .= '
			<fieldset>
				<legend>' . $cms_language->getMessage(self::MESSAGE_OBJECT_EMAIL_PARAMETER_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '</legend>
				<br />';
        if (!isset($_POST['objectexplanation'])) {
            $_POST['objectexplanation'] = '';
        }
        //selected value
        $selected['working'] = $_POST['objectexplanation'] == 'working' ? ' selected="selected"' : '';
        $selected['working-polymod'] = $_POST['objectexplanation'] == 'working-polymod' ? ' selected="selected"' : '';
        $selected['vars'] = $_POST['objectexplanation'] == 'vars' ? ' selected="selected"' : '';
        $selected['search'] = $_POST['objectexplanation'] == 'search' ? ' selected="selected"' : '';
        $input .= '
			<select name="objectexplanation" class="admin_input_text" onchange="document.getElementById(\'cms_action\').value=\'switchexplanation\';document.frm.submit();">
				<option value="">' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_CHOOSE) . '</option>
				<optgroup label="' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_ROW_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">
					<option value="search"' . $selected['search'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_SEARCH_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
					<option value="working"' . $selected['working'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_TAGS) . '</option>
					<option value="working-polymod"' . $selected['working-polymod'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_POLYMOD_TAGS, false, MOD_POLYMOD_CODENAME) . '</option>
					<option value="vars"' . $selected['vars'] . '>' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_BLOCK_GENERAL_VARS) . '</option>
					</optgroup>
				<optgroup label="' . $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_ROW_OBJECTS_VARS_EXPLANATION, false, MOD_POLYMOD_CODENAME) . '">';
        $input .= CMS_poly_module_structure::viewObjectInfosList($moduleCodename, $cms_language, $_POST['objectexplanation'], $object->getID());
        $input .= '
				</optgroup>';
        $input .= '
			</select><br /><br />';
        //then display chosen object infos
        if ($_POST['objectexplanation']) {
            switch ($_POST['objectexplanation']) {
                case 'search':
                    $input .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_SEARCH_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                    break;
                case 'working':
                    $content .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_TAGS_EXPLANATION);
                    break;
                case 'working-polymod':
                    $content .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_WORKING_POLYMOD_TAGS_EXPLANATION, false, MOD_POLYMOD_CODENAME);
                    break;
                case 'vars':
                    $content .= $cms_language->getMessage(CMS_polymod::MESSAGE_PAGE_BLOCK_GENERAL_VARS_EXPLANATION);
                    break;
                default:
                    //object info
                    $input .= CMS_poly_module_structure::viewObjectRowInfos($moduleCodename, $cms_language, $_POST['objectexplanation']);
                    break;
            }
        }
        $input .= '</fieldset>';
        return $input;
    }
Example #5
0
$dialog->changeColor();
//add message if any
if ($cms_message) {
    $dialog->setActionMessage($cms_message);
}
//add back link
if ($backLink) {
    //links are coded in query string and so ? are replaced by §§ and ampersands are replaced with § to avoid confusion
    $bl = str_replace(chr(167) . chr(167), "?", $backLink);
    $bl = str_replace(chr(167), "&", $bl);
    $dialog->setBackLink(SensitiveIO::sanitizeHTMLString($bl));
}
//first make a diff beetween current queried Root and all user sections to see wich sections missing.
$getRoot = array($startRoot);
$displayed = array();
$cms_root = CMS_tree::getRoot();
$sectionsRoots = CMS_session::getSessionVar('sectionsRoots');
foreach ($getRoot as $aRootID) {
    if ($pages[$aRootID]) {
        $treeRoot = $pages[$aRootID];
    } else {
        $treeRoot = CMS_tree::getPageByID($aRootID);
        $pages[$aRootID] = $treeRoot;
    }
    if (!$treeRoot || $treeRoot->hasError()) {
        die("Unknown tree root to display ...");
    }
    $lineages[$aRootID] = CMS_tree::getLineage($cms_root->getID(), $treeRoot->getID(), false);
    if (is_array($sectionsRoots)) {
        foreach ($lineages[$aRootID] as $aLineagePage) {
            if (in_array($aLineagePage, $sectionsRoots)) {
Example #6
0
    } else {
        $jscontent = "\n\t\t\t//disable all tabs except search and tree\n\t\t\tAutomne.tabPanels.items.each(function(panel) {\n\t\t\t\tif (panel.id != 'search' && panel.id != 'tree') {\n\t\t\t\t\tpanel.disable();\n\t\t\t\t} else {\n\t\t\t\t\tpanel.enable();\n\t\t\t\t}\n\t\t\t});\n\t\t\tAutomne.message.popup({\n\t\t\t\ttitle: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_ERROR) . "', \n\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_PAGE_NOT_VIEWVABLE, array($pageId)) . "',\n\t\t\t\tbuttons:\tExt.MessageBox.OK,\n\t\t\t\ticon: \t\tExt.MessageBox.ERROR\n\t\t\t});\n\t\t";
        $view->addJavascript($jscontent);
        CMS_grandFather::raiseError('Error on page : ' . $pageId);
        $view->show();
    }
}
if (!isset($cms_page) || !is_object($cms_page)) {
    CMS_grandFather::raiseError('Error, can\'t get a valid page to work with.');
    $view->show();
}
//check if page is useable (public or edited at least)
if (!$cms_page->isUseable() || $followRedirect) {
    if (!$cms_page->isUseable()) {
        //page is deleted, go to root
        $cms_page = CMS_tree::getRoot();
    }
    //redirect to subpage if any redirection exists
    $redirectlink = $cms_page->getRedirectLink(true);
    while ($redirectlink->hasValidHREF() && sensitiveIO::IsPositiveInteger($redirectlink->getInternalLink())) {
        $cms_page = new CMS_page($redirectlink->getInternalLink());
        $redirectlink = $cms_page->getRedirectLink(true);
    }
    $pageId = $cms_page->getID();
}
pr('View page : ' . $cms_page->getID() . ($reload ? ' (Force reload queried by interface)' : ''));
//set page into user context
CMS_session::setPage($cms_page);
//for the page, create all javascript informations needed
$hasPreviz = $hasPublic = $hasDraft = $isEditable = $hasLock = $hasRedirect = false;
//which panels can be seen by user (according to his rights)
Example #7
0
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
define("MESSAGE_PAGE_TITLE", 852);
$view = CMS_view::getInstance();
$templateId = sensitiveIO::request('template', 'sensitiveIO::isPositiveInteger');
//unset request to avoid it to have interaction with page code
sensitiveIO::unsetRequest(array('template'));
//CHECKS
if (!SensitiveIO::isPositiveInteger($templateId)) {
    die("Invalid template");
}
$template = CMS_pageTemplatesCatalog::getByID($templateId);
if (!is_object($template) || $template->hasError()) {
    die("Invalid template or template error");
}
//RIGHTS CHECK
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) {
    //templates
    die("User has no rights on template edition");
}
$dummy_page = CMS_tree::getRoot();
$dummy_page->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE, array($template->getLabel())), $cms_user);
//add ext and edit JS files
$view->addJSFile('ext');
$view->addJSFile('edit');
//get page content
$dummy_page->setTemplate($template->getID());
//get page content
$content = $dummy_page->getContent($cms_language, PAGE_VISUALMODE_CLIENTSPACES_FORM);
echo $content;
Example #8
0
    /**
     * Return the needed form field tag for current object field
     *
     * @param array $values : parameters values array(parameterName => parameterValue) in :
     *     id : the form field id to set
     * @param multidimentionnal array $tags : xml2Array content of atm-function tag
     * @return string : the form field HTML tag
     * @access public
     */
    function getInput($fieldID, $language, $inputParams)
    {
        //hidden field : use parent method
        if (isset($inputParams['hidden']) && ($inputParams['hidden'] == 'true' || $inputParams['hidden'] == 1)) {
            return parent::getInput($fieldID, $language, $inputParams);
        }
        if (isset($inputParams['prefix'])) {
            $prefixName = $inputParams['prefix'];
            unset($inputParams['prefix']);
        } else {
            $prefixName = '';
        }
        $params = $this->getParamsValues();
        //serialize all htmlparameters
        $htmlParameters = $this->serializeHTMLParameters($inputParams);
        $html = '';
        //create fieldname
        $fieldName = $prefixName . $this->_field->getID() . '_0';
        //append field id to html field parameters (if not already exists)
        $htmlParameters .= !isset($inputParams['id']) ? ' id="' . $prefixName . $this->_field->getID() . '_0"' : '';
        //create field value
        $value = $this->_subfieldValues[0]->getValue() ? $this->_subfieldValues[0]->getValue() : '';
        //then create field HTML
        $html .= $html ? '<br />' : '';
        $html .= '<input ' . $htmlParameters . ' type="text" name="' . $fieldName . '" value="' . $value . '" />' . "\n";
        //build tree link
        $grand_root = CMS_tree::getRoot();
        $href = PATH_ADMIN_SPECIAL_TREE_WR;
        $href .= '?root=' . $grand_root->getID();
        $windowTitle = SensitiveIO::sanitizeHTMLString($language->getMessage(self::MESSAGE_PAGE_TREEH1));
        $href .= '&amp;heading=' . $windowTitle;
        $href .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $fieldName . "').value = '%s';self.close();");
        $href .= '&encodedPageLink=' . base64_encode('false');
        $html .= '&nbsp;<a href="' . $href . '" class="admin" target="_blank"><img title="' . $windowTitle . '" alt="' . $windowTitle . '" src="' . PATH_ADMIN_IMAGES_WR . '/picto-arbo.gif" border="0" align="absmiddle" /></a>
			';
        if (POLYMOD_DEBUG) {
            $html .= ' <span class="admin_text_alert">(Field : ' . $this->_field->getID() . ' - SubField : 0)</span>';
        }
        //append html hidden field which store field name
        if ($html) {
            $html .= '<input type="hidden" name="polymodFields[' . $this->_field->getID() . ']" value="' . $this->_field->getID() . '" />';
        }
        return $html;
    }
}
// Current usersgroup clearances
if ($moduleCodename != MOD_STANDARD_CODENAME) {
    $stack_clearances = $profile->getModuleCategoriesClearancesStack();
    $modules_clearances = CMS_Profile::getAllModuleCategoriesClearances();
} else {
    $stack_clearances = $profile->getPageClearances();
    $modules_clearances = CMS_Profile::getAllPageClearances();
}
if (!$item) {
    // Get root
    if ($moduleCodename != MOD_STANDARD_CODENAME) {
        $categories_search_attrs = array("module" => $moduleCodename, "language" => $cms_language, "level" => 0, "root" => 0, "attrs" => false, "cms_user" => &$cms_user);
        $root_items = CMS_module::getModuleCategories($categories_search_attrs);
    } else {
        $root_items = array(CMS_tree::getRoot());
    }
    $content = '';
    if (!$root_items || !sizeof($root_items)) {
        $content .= "<br />" . $cms_language->getMessage(MESSAGE_PAGE_EMPTY_SET) . "<br /><br />";
    } else {
        $content .= '
		<div style="width:100%;" id="cats-' . $hash . '">
			<table border="0" cellpadding="2" cellspacing="0" style="margin-bottom:2px;">
				<tr>
					<th width="100%" style="text-align:left;"><label for="maxDepth-' . $moduleCodename . '-' . $profileId . '">' . $cms_language->getMessage(MESSAGE_PAGE_DEPTH) . ' : </label><input id="maxDepth-' . $moduleCodename . '-' . $profileId . '" type="text" style="width:18px;" name="" value="' . $maxDepth . '" />&nbsp; ' . $cms_language->getMessage(MESSAGE_PAGE_LEVELS) . '</th>
					<th width="120" align="right">
						<table width="120" border="0" cellpadding="2" cellspacing="0">
							<tr>';
        reset($modules_clearances);
        $pictos = array(CLEARANCE_MODULE_NONE => 'right-none', CLEARANCE_MODULE_VIEW => 'right-view', CLEARANCE_MODULE_EDIT => 'right-edit', CLEARANCE_MODULE_MANAGE => 'right-manage');
Example #10
0
 /**
  * Process the module validations : here, calls the parent function but before :
  * - Pass all the editors to remindedEditors
  * - computes all the pages that got to be regenerated.
  *
  * @param CMS_resourceValidation $resourceValidation The resource validation to process
  * @param integer $result The result of the validation process. See VALIDATION_OPTION constants
  * @param boolean $lastValidation Is this the last validation done in a load of multiple validations (or the only one) ?
  *        if true, launch the regeneration script.
  * @return boolean true on success, false on failure to process
  * @access public
  */
 function processValidation($resourceValidation, $result, $lastValidation = true)
 {
     if (!$resourceValidation instanceof CMS_resourceValidation) {
         $this->raiseError("ResourceValidation is not a valid CMS_resourceValidation object");
         return false;
     }
     $editions = $resourceValidation->getEditions();
     $page = $resourceValidation->getResource();
     $publication_before = $page->getPublication();
     $location_before = $page->getLocation();
     //Clear polymod cache
     //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => MOD_STANDARD_CODENAME));
     CMS_cache::clearTypeCache('polymod');
     //Get the linked pages (it will be too late after parent processing if pages move outside USERSPACE
     //first add the page to regen
     $regen_pages = array();
     if ($result == VALIDATION_OPTION_ACCEPT) {
         //2.1. If editions contains SIBLINGSORDER, all pages monitoring this one for father changes should regen
         if ($editions & RESOURCE_EDITION_SIBLINGSORDER || $editions & RESOURCE_EDITION_MOVE) {
             $temp_regen = CMS_linxesCatalog::getWatchers($page);
             if ($temp_regen) {
                 $regen_pages = array_merge($regen_pages, $temp_regen);
             }
         }
         //2.2. If editions contains BASEDATA, all pages linked with this one should regen, and all monitoring its father
         if ($editions & RESOURCE_EDITION_BASEDATA || $editions & RESOURCE_EDITION_LOCATION) {
             $temp_regen = CMS_linxesCatalog::getLinkers($page);
             if ($temp_regen) {
                 $regen_pages = array_merge($regen_pages, $temp_regen);
             }
             $father = CMS_tree::getFather($page);
             if ($father) {
                 $temp_regen = CMS_linxesCatalog::getWatchers($father);
                 if ($temp_regen) {
                     $regen_pages = array_merge($regen_pages, $temp_regen);
                 }
             }
         }
         //2.3. If editions contains CONTENT, only the page should be regen
         if ($editions & RESOURCE_EDITION_CONTENT) {
             //do nothing, the page is already in the array
         }
         $regen_pages = array_unique($regen_pages);
     }
     //call the parent function, but empty the reminded editors stack before
     if ($result == VALIDATION_OPTION_ACCEPT) {
         $stack = $page->getRemindedEditorsStack();
         $stack->emptyStack();
         $page->setRemindedEditorsStack($stack);
         $page->writeToPersistence();
     }
     if (!parent::processValidation($resourceValidation, $result)) {
         return false;
     }
     if ($result == VALIDATION_OPTION_REFUSE && ($editions & RESOURCE_EDITION_SIBLINGSORDER || $editions & RESOURCE_EDITION_MOVE)) {
         //validation was refused, move the page to it's original position
         if ($editions & RESOURCE_EDITION_SIBLINGSORDER) {
             //revert page order to the old one
             CMS_tree::revertSiblingsOrder($page);
         } elseif ($editions & RESOURCE_EDITION_MOVE) {
             //revert page move to the old position
             CMS_tree::revertPageMove($page);
         }
     }
     //if validation was not accepted, nothing more to do
     if ($result != VALIDATION_OPTION_ACCEPT) {
         return true;
     }
     //re-instanciate the page object that have changed
     $page = CMS_tree::getPageByID($resourceValidation->getResourceID());
     //page was moved out of userspace
     if ($editions & RESOURCE_EDITION_LOCATION) {
         if ($page->getLocation() != RESOURCE_LOCATION_USERSPACE && $location_before == RESOURCE_LOCATION_USERSPACE) {
             $page->deleteFiles();
             CMS_linxesCatalog::deleteLinxes($page, true);
             if ($publication_before != RESOURCE_PUBLICATION_NEVERVALIDATED) {
                 CMS_tree::detachPageFromTree($page, true);
             }
             CMS_tree::detachPageFromTree($page, false);
             //can't regenerate the page now
             if ($key = array_search($page->getID(), $regen_pages)) {
                 unset($regen_pages[$key]);
             }
         }
     } elseif ($editions & RESOURCE_EDITION_BASEDATA && $publication_before != RESOURCE_PUBLICATION_NEVERVALIDATED && $page->getPublication() != RESOURCE_PUBLICATION_PUBLIC && CMS_tree::isInPublicTree($page)) {
         //detach page if publication dates changed and page no longer published
         $page->deleteFiles();
         CMS_linxesCatalog::deleteLinxes($page, true);
         CMS_tree::detachPageFromTree($page, true);
         //can't regenerate the page now
         if ($key = array_search($page->getID(), $regen_pages)) {
             unset($regen_pages[$key]);
         }
     } else {
         //LINX_TREE RECORDS GENERATION
         //1. If the page has never been validated
         if ($publication_before == RESOURCE_PUBLICATION_NEVERVALIDATED) {
             //test the father's editions. If SIBLINGSORDER, only attach the page, else validate all of siblings orders
             $father = CMS_tree::getFather($page, true);
             $father_status = $father->getStatus();
             if ($father_status->getEditions() & RESOURCE_EDITION_SIBLINGSORDER || $editions & RESOURCE_EDITION_MOVE) {
                 CMS_tree::attachPageToTree($page, $father, true);
             } else {
                 CMS_tree::publishSiblingsOrder($father);
             }
         }
         //2. If the page has been validated, attach it to the public tree
         $grand_root = CMS_tree::getRoot();
         if ($page->getPublication() == RESOURCE_PUBLICATION_PUBLIC && $page->getID() != $grand_root->getID()) {
             $father = CMS_tree::getFather($page);
             if ($editions & RESOURCE_EDITION_MOVE) {
                 //publish page move
                 CMS_tree::publishPageMove($page);
                 //regenerate all pages which link moved page
                 $temp_regen = CMS_linxesCatalog::getLinkers($page);
                 if ($temp_regen) {
                     $regen_pages = array_merge($regen_pages, $temp_regen);
                 }
                 //and regenerate all page who watch new father page
                 $temp_regen = CMS_linxesCatalog::getWatchers($father);
                 if ($temp_regen) {
                     $regen_pages = array_merge($regen_pages, $temp_regen);
                 }
             } else {
                 CMS_tree::attachPageToTree($page, $father, true);
             }
         }
         //PAGE REGENERATION
         //3. the page itself (fromscratch needed).
         $launchRegnerator = $lastValidation && !$regen_pages ? true : false;
         CMS_tree::submitToRegenerator($page->getID(), true, $launchRegnerator);
     }
     $regen_pages = array_unique($regen_pages);
     //2. the linked pages
     CMS_tree::submitToRegenerator($regen_pages, false, !$lastValidation);
     return true;
 }
Example #11
0
 /**
  * Get the tree string needed by the text edition applet
  * format is :
  * 	pageID/roottitle/subroottitle/pagetitle:::[SAME AS BEFORE...]
  * where ::: is the separator passed as argument
  * Static function.
  * Recursive function
  *
  * @param string $separator The pages separator.
  * @return string the tree string
  * @access public
  */
 static function getTreeString(&$user, $pageID, $separator, &$treeString)
 {
     static $treeStringInfos;
     $root = CMS_tree::getRoot();
     $lineage = CMS_tree::getLineage($root->getID(), $pageID, false);
     $treeString .= $pageID;
     //add ancestors
     if (is_array($lineage) && $lineage) {
         foreach ($lineage as $ancestor) {
             //to reduce the total time of the function (really long on big websites).
             if (!$treeStringInfos[$ancestor]) {
                 $ancestor = CMS_tree::getPageByID($ancestor);
                 $ancestorTitle = $treeStringInfos[$ancestor->getID()] = $ancestor->getTitle();
             } else {
                 $ancestorTitle = $treeStringInfos[$ancestor];
             }
             //test the presence of the separator in the sibling title
             if (io::strpos($ancestorTitle, $separator) !== false) {
                 CMS_grandFather::raiseError("Page has the separator in its title (transformed) : " . $ancestorTitle);
                 $title = str_replace($separator, "[SEPARATOR]", $ancestorTitle);
             } else {
                 $title = $ancestorTitle;
             }
             $treeString .= "/" . addslashes($title);
         }
     }
     $treeString .= $separator;
     //get siblings and recursively show them
     $sibs = CMS_tree::getSiblings($pageID, false, false);
     if (!$sibs) {
         return $treeString;
     }
     foreach ($sibs as $sib) {
         CMS_tree::getTreeString($user, $sib, $separator, $treeString);
     }
 }