protected function renderHeadForOutput() { //set final page title $sTitleBefore = self::g_("local_title_before"); if ($sTitleBefore) { $sTitleBefore .= ' '; } $sTitleAfter = self::g_("local_title_after"); if ($sTitleAfter) { $sTitleAfter = ' ' . $sTitleAfter; } $this->title = $sTitleBefore . $this->title . $sTitleAfter; //set some global JS $this->headJs('var g_actionurl="' . str_replace('&', '&', AnwUtils::escapeQuote(AnwUtils::aLink($this->getName()))) . '";'); //render CSS & Javascript if ($this->headCss) { $this->headCss = $this->tpl()->headCss($this->headCss); } if ($this->headJsOnload) { $this->headJs .= $this->tpl()->headJsOnload($this->headJsOnload); } //append to headJs if ($this->headJs) { $this->headJs = $this->tpl()->headJs($this->headJs); } //render head $this->head = $this->tpl()->globalHead($this->head, $this->headCss, $this->headJs); }
function hiddentags($id, $defaultcontent, $originalcontent, $translated) { $defaultcontent = AnwUtils::escapeQuote($defaultcontent); $originalcontent = AnwUtils::escapeQuote($originalcontent); $sTranslated = $translated ? 'true' : 'false'; $HTML = <<<EOF \toTranslator.addItem( new TranslateItem("{$this->xQuote($id)}", "{$defaultcontent}", "{$originalcontent}", {$sTranslated}) ); EOF; return $HTML; }
/** * Overloaded function to display a toolbar with page actions. */ public function output($bEmergencyError = false) { if (!$bEmergencyError) { if ($this->pageExists()) { //action links $aoAllowedActions = self::getPageNavEntriesAllowed($this->getoPage()); $nCountAllowedActions = count($aoAllowedActions); if ($nCountAllowedActions > 1 || $nCountAllowedActions == 1 && $aoAllowedActions[0]->getActionName() != 'view') { $this->out = $this->tpl()->pageNav($aoAllowedActions) . $this->out; } } $this->headJs('var g_pagename="' . str_replace('&', '&', AnwUtils::escapeQuote($this->getoPage()->getName())) . '";'); $this->headJs('var g_actionpageurl="' . str_replace('&', '&', AnwUtils::escapeQuote(AnwUtils::link($this->getoPage(), $this->getName()))) . '";'); } parent::output($bEmergencyError); }
function renderEditHtmlForm($bFromPost, $sFormUrl = "", $sSuffix = "", $oContentOriginal = null) { $sHtmlEditForm = ""; //special process for the first call if ($oContentOriginal == null) { $oContentOriginal = $this; $oContentOriginal->bHtmlEditFormHasErroneousFields = false; $oContentOriginal->bHtmlEditFormHasPhpCode = false; $oContentOriginal->bHtmlEditFormHasJsCode = false; $oContentOriginal->nHtmlEditFormCountErroneousChild = 0; $sFormUrl = str_replace('&', '&', $sFormUrl); AnwAction::headJs('var g_editcontentform_url="' . AnwUtils::escapeQuote($sFormUrl) . '";'); AnwAction::headEditContent(); //render tabs if any $aoFieldsTabs = $this->getContentFieldsTabs(); if (count($aoFieldsTabs) > 0) { $sHtmlTabs = ""; foreach ($aoFieldsTabs as $oFieldTab) { $sHtmlTabs .= $oFieldTab->renderEditTab($sSuffix); } $sHtmlEditForm .= <<<EOF <div class="contentfield_tabs"> \t{$sHtmlTabs} \t<div class="break;"></div> </div> EOF; } } $aoContentFields = $this->getContentFieldsContainer()->getContentFields(); foreach ($aoContentFields as $oContentField) { $nPreviousCountErroneousChild = $oContentOriginal->nHtmlEditFormCountErroneousChild; $sFieldName = $oContentField->getName(); $asValuesForRender = array(); $asFieldValues = array(); $aoSubContents = array(); $bHasOverridingValues = null; //do not load from post when contentfield is hidden if ($bFromPost && !$oContentField->isDisplayed()) { $bReallyFromPost = false; } else { $bReallyFromPost = $bFromPost; } /***************************************************************************** * CONTENTFIELD CONTAINER : recursively get value from it's subcontentfields *****************************************************************************/ if ($oContentField instanceof AnwStructuredContentField_composed) { if (!$bReallyFromPost) { // shared code for multiplicity single or multiple try { $aoSubContents = $this->getSubContents($sFieldName); } catch (AnwUnexpectedException $e) { //contentfield_container don't exist already. create it. $aoSubContents = array($this->newContent($oContentField)); } } else { $aoSubContents = array(); if ($oContentField->isMultiple()) { //create as many empty subcontents as instances edited from post $asFieldsIdsFromPost = AnwEnv::_POST($oContentField->getInputName($sSuffix), array()); foreach ($asFieldsIdsFromPost as $sFieldIdFromPost) { $aoSubContents[$sFieldIdFromPost] = $this->newContent($oContentField); } } else { //only 1 empty instance $aoSubContents[] = $this->newContent($oContentField); } } foreach ($aoSubContents as $sIndice => $oSubContent) { //update suffix if (!$bReallyFromPost) { $sSuffixId = AnwUtils::genUniqueIdNumeric(); } else { $sSuffixId = $sIndice; } $sNewSuffix = $oContentField->updateSuffix($sSuffix, $sSuffixId); $sSubRender = $oSubContent->renderEditHtmlForm($bReallyFromPost, $sFormUrl, $sNewSuffix, $oContentOriginal); //recursive call //$asValuesForRender[$sSuffixId] = $sSubRender; $asValuesForRender[$sSuffixId] = array(self::IDX_SUBCONTENT => $oSubContent, self::IDX_RENDERED => $sSubRender); if ($oContentField->isCollapsed() || $oContentField->isCollapsedChild()) { $bWasCollapsingEnabled = AnwStructuredContentField::getDoCollapsing(); AnwStructuredContentField::setDoCollapsing(false); $sSubRenderUncollapsed = $oSubContent->renderEditHtmlForm($bReallyFromPost, $sFormUrl, $sNewSuffix, $oContentOriginal); //recursive call $asValuesForRender[$sSuffixId]['UNCOLLAPSED'] = $sSubRenderUncollapsed; AnwStructuredContentField::setDoCollapsing($bWasCollapsingEnabled); } //only after calling render on subContent! //$asFieldValues[] = $oSubContent->toXmlString(); } $bHasOverridingValues = self::hasOverridingValues($oContentField, $aoSubContents); if ($oContentField->isMultiple()) { if (!$oContentField->hasDefaultSubContents()) { $bHasOverridingValues = false; //special case } } else { if (!$oContentField->hasSetDefaultValues()) { $bHasOverridingValues = false; //special case } } } else { if (!$bReallyFromPost) { $asFieldValues = $this->getContentFieldValues($sFieldName); } else { $asFieldValues = $oContentField->getValuesFromPost($sSuffix); } $asValuesForRender = $asFieldValues; $bHasOverridingValues = self::hasOverridingValues($oContentField, $asFieldValues); if (!$oContentField->hasSetDefaultValues()) { $bHasOverridingValues = false; //special case } } $sFieldError = false; // - run the test for any _atomic field. // - only run the test for _composed fields which dont't have erroneous childs (important for security reasons, to not trigger test() procedure of these composed fields on unsafe values) if ($oContentOriginal->nHtmlEditFormCountErroneousChild == $nPreviousCountErroneousChild) { //test values and multiplicity (even for composed fields) try { if ($oContentField instanceof AnwStructuredContentField_atomic) { $oContentField->testContentFieldValues($asFieldValues, $this); } else { $oContentField->testContentFieldValues($aoSubContents, $this); } } catch (AnwException $e) { //here we can get errors from php edition //display error $sInputName = $oContentField->getInputName($sSuffix); $sFieldError = str_replace('#CONTENTFIELDINPUTID#', $sInputName, $e->getMessage()); $oContentOriginal->bHtmlEditFormHasErroneousFields = true; $oContentOriginal->nHtmlEditFormCountErroneousChild++; //quick hack to solve the following problem: //if user enters invalid XML code, in a contentfield such as _xml //the system would fail on setContentFieldValues() or later, //when trying to load invalid XML from the content. // //so we replace erroneous values by a valid-xml string. //these erroneous values should never be read later : // - test for this contentfield was done before // - render is done on $asValuesForRender, so that user views erroneous in edit inputs // - if this contentfield is child of a container, the container won't do the test as it contains already erroneous values if ($e instanceof AnwInvalidContentFieldValueException && $oContentField instanceof AnwStructuredContentField_atomic) { $sErroneousValue = '#ERRONEOUSVALUE#'; foreach ($asFieldValues as $nValueIndice => $null) { $asFieldValues[$nValueIndice] = $sErroneousValue; } } } /* catch(AnwException $e){ //should never go here print 'ERROR 62'; print_r($e); exit; }*/ } /*else { $sFieldError = "(test skipped)"; }*/ //render it now if ($oContentField->isDisplayed()) { $sHtmlEditForm .= $oContentField->renderEditInputs($asValuesForRender, $sSuffix, $bHasOverridingValues, $sFieldError); } if ($bReallyFromPost) { //update content for preview/save if ($oContentField instanceof AnwStructuredContentField_atomic) { $this->setContentFieldValues($sFieldName, $asFieldValues); } else { $this->setSubContents($sFieldName, $aoSubContents); } } if ($oContentField instanceof AnwStructuredContentField_atomic) { //check acls - are these checks still needed, as test was integrated in class_contentfield? foreach ($asFieldValues as $mContentFieldValue) { //check PHP permission $bHasPhpCode = AnwUtils::contentHasPhpCode($mContentFieldValue); if ($bHasPhpCode) { $oContentOriginal->bHtmlEditFormHasPhpCode = true; AnwCurrentSession::getUser()->checkPhpEditionAllowed(); } //check JS permission $bHasJsCode = AnwUtils::contentHasJsCode($mContentFieldValue); if ($bHasJsCode) { $oContentOriginal->bHtmlEditFormHasJsCode = true; AnwCurrentSession::getUser()->checkJsEditionAllowed(); } } } } return $sHtmlEditForm; }
function getJsInitMap($oMap) { $sContentSafe = AnwUtils::escapeQuote($this->sContent); $sMapJsVar = $oMap->getMapJsVar(); $nCenterLat = $this->nCenterLat ? $this->nCenterLat : $oMap->getCenterLat(); $nCenterLng = $this->nCenterLng ? $this->nCenterLng : $oMap->getCenterLng(); $HTML = <<<EOF \t\tvar markerOptions = {map: {$sMapJsVar}, position: new google.maps.LatLng({$nCenterLat}, {$nCenterLng})}; \t\tvar marker = new google.maps.Marker(markerOptions); \t\t \t\tvar myWindowOptions = { \t\t\tcontent: "{$sContentSafe}" \t\t}; \t\tvar myInfoWindow = new google.maps.InfoWindow(myWindowOptions); \t\tgoogle.maps.event.addListener(marker, 'click', function() { \t\t\tmyInfoWindow.open({$sMapJsVar}, marker); \t\t}); EOF; if ($this->bOpenOnStartup) { $HTML .= <<<EOF \t\tgoogle.maps.event.trigger(marker, "click"); EOF; } return $HTML; }