/** * Renders the block (returns HTML) * * @return string HTML **/ public function render() { $tpl = eZTemplate::factory(); $tpl->setVariable( 'localized_apps', $this->fetchApplications() ); return $tpl->fetch( 'design:presenters/block/carousel.tpl' ); }
/** * Returns block item XHTML * * @param mixed $args * @return array */ public static function getNextItems($args) { $http = eZHTTPTool::instance(); $tpl = eZTemplate::factory(); $result = array(); $galleryID = $http->postVariable('gallery_id'); $offset = $http->postVariable('offset'); $limit = $http->postVariable('limit'); $galleryNode = eZContentObjectTreeNode::fetch($galleryID); if ($galleryNode instanceof eZContentObjectTreeNode) { $params = array('Depth' => 1, 'Offset' => $offset, 'Limit' => $limit); $pictureNodes = $galleryNode->subtree($params); foreach ($pictureNodes as $validNode) { $tpl->setVariable('node', $validNode); $tpl->setVariable('view', 'block_item'); $tpl->setVariable('image_class', 'blockgallery1'); $content = $tpl->fetch('design:node/view/view.tpl'); $result[] = $content; if ($counter === $limit) { break; } } } return $result; }
function sendOrderEmail($params) { $ini = eZINI::instance(); if (isset($params['order']) and isset($params['email'])) { $order = $params['order']; $email = $params['email']; $tpl = eZTemplate::factory(); $tpl->setVariable('order', $order); $templateResult = $tpl->fetch('design:shop/orderemail.tpl'); $subject = $tpl->variable('subject'); $mail = new eZMail(); $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable("MailSettings", "AdminEmail"); } if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $mail->setReceiver($email); $mail->setSender($emailSender); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); $email = $ini->variable('MailSettings', 'AdminEmail'); $mail = new eZMail(); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $mail->setReceiver($email); $mail->setSender($emailSender); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); } }
/** * Returns block item XHTML * * @param mixed $args * @return array */ public static function getValidItems($args) { $http = eZHTTPTool::instance(); $tpl = eZTemplate::factory(); $result = array(); $blockID = $http->postVariable('block_id'); $offset = $http->postVariable('offset'); $limit = $http->postVariable('limit'); $validNodes = eZFlowPool::validNodes($blockID); $counter = 0; foreach ($validNodes as $validNode) { if (!$validNode->attribute('can_read')) { continue; } $counter++; if ($counter <= $offset) { continue; } $tpl->setVariable('node', $validNode); $tpl->setVariable('view', 'block_item'); $tpl->setVariable('image_class', 'blockgallery1'); $content = $tpl->fetch('design:node/view/view.tpl'); $result[] = $content; if ($counter === $limit) { break; } } return $result; }
function prime( &$tr ) { $tpl = eZTemplate::factory(); $tpl->setIsCachingAllowed( true ); eZTemplateCompiler::setSettings( array( 'compile' => true, 'comments' => false, 'accumulators' => false, 'timingpoints' => false, 'fallbackresource' => false, 'nodeplacement' => false, 'execution' => true, 'generate' => true, 'compilation-directory' => 'benchmarks/eztemplate/compilation' ) ); $expected = $tpl->fetch( 'benchmarks/eztemplate/mark.tpl' ); eZTemplateCompiler::setSettings( array( 'compile' => true, 'comments' => false, 'accumulators' => false, 'timingpoints' => false, 'fallbackresource' => false, 'nodeplacement' => false, 'execution' => true, 'generate' => false, 'compilation-directory' => 'benchmarks/eztemplate/compilation' ) ); $tpl->reset(); $this->TPL = $tpl; }
protected static function run() { self::checkIfLoggedIn(); $ini = eZINI::instance('cookielaw.ini'); if (self::$isActive) { $message = ezpI18n::tr('extension/occookielaw', "I cookie ci aiutano ad erogare servizi di qualità. Utilizzando i nostri servizi, l'utente accetta le nostre modalità d'uso dei cookie."); if ($ini->hasVariable('AlertSettings', 'MessageText')) { $message = $ini->variable('AlertSettings', 'MessageText'); } $dismiss = ezpI18n::tr('extension/occookielaw', "OK"); if ($ini->hasVariable('AlertSettings', 'DismissButtonText')) { $dismiss = $ini->variable('AlertSettings', 'DismissButtonText'); } $info = ezpI18n::tr('extension/occookielaw', "Maggiori informazioni"); if ($ini->hasVariable('AlertSettings', 'InfoButtonText')) { $info = $ini->variable('AlertSettings', 'InfoButtonText'); } $tpl = eZTemplate::factory(); $tpl->setVariable('message', $message); $tpl->setVariable('dismiss_button', $dismiss); $tpl->setVariable('info_button', $info); return $tpl->fetch('design:inject_in_page_layout.tpl'); } return ''; }
/** * Renders the block (returns HTML) * * @return string HTML **/ public function render() { $tpl = eZTemplate::factory(); $tpl->setVariable( 'name', $this->name ); $tpl->setVariable( 'banners', $this->fetchBanners() ); $tpl->setVariable( 'cluster_identifier', ClusterTool::clusterIdentifier() ); return $tpl->fetch( 'design:presenters/block/channel.tpl' ); }
/** * Renders the block (returns HTML) * * @return string HTML **/ public function render() { $tpl = eZTemplate::factory(); $tpl->setVariable( 'articles', $this->getSolrArticles() ); $blockResult = $tpl->fetch( 'design:presenters/block/congressreport.tpl' ); eZTemplate::resetInstance(); return $blockResult; }
function displayForm($Result, $errors = null) { $tpl = eZTemplate::factory(); $tpl->setVariable('errors', $errors); $Result['path'] = array(array('url' => '/', 'text' => ezpI18n::tr('mailchimp/subscribe', 'Home')), array('url' => false, 'text' => ezpI18n::tr('mailchimp/subscribe', 'Subscribe'))); $Result['title'] = 'Subscribe'; $Result['content'] = $tpl->fetch("design:mailchimp/subscribe.tpl"); return $Result; }
/** * Returns string with rendered content * * @return string */ public function render() { $tpl = eZTemplate::factory(); $ini = eZINI::instance('rest.ini'); $nodeViewData = eZNodeviewfunctions::generateNodeViewData($tpl, $this->content->main_node, $this->content->main_node->attribute('object'), $this->content->activeLanguage, 'rest', 0); $tpl->setVariable('module_result', $nodeViewData); $routingInfos = $this->controller->getRouter()->getRoutingInformation(); $templateName = $ini->variable($routingInfos->controllerClass . '_' . $routingInfos->action . '_OutputSettings', 'Template'); return $tpl->fetch('design:' . $templateName); }
/** * Renders the block (returns HTML) * * @return string HTML **/ public function render() { $tpl = eZTemplate::factory(); $page = $this->fetchStaticPage(); $tpl->setVariable( 'core_content', str_replace( '/bundles/static-data/', '/esibuild/static/', $page->attribute('core_content') ) ); $renderResult = $tpl->fetch( 'design:presenters/block/content.tpl' ); eZTemplate::resetInstance(); return $renderResult; }
/** * Invoca il template per il form di attributo * * @see SearchFormOperator::modify * @param OCClassSearchFormHelper $instance * @param OCClassSearchFormAttributeField $field * * @return array|null|string */ public static function displayAttribute(OCClassSearchFormHelper $instance, OCClassSearchFormAttributeField $field) { $keyArray = array(array('class', $instance->getContentClass()->attribute('id')), array('class_identifier', $instance->getContentClass()->attribute('identifier')), array('class_group', $instance->getContentClass()->attribute('match_ingroup_id_list')), array('attribute', $field->contentClassAttribute->attribute('id')), array('attribute_identifier', $field->contentClassAttribute->attribute('identifier'))); $tpl = eZTemplate::factory(); $tpl->setVariable('class', $instance->getContentClass()); $tpl->setVariable('attribute', $field->contentClassAttribute); $res = eZTemplateDesignResource::instance(); $res->setKeys($keyArray); $templateName = $field->contentClassAttribute->attribute('data_type_string'); return $tpl->fetch('design:class_search_form/datatypes/' . $templateName . '.tpl'); }
/** * Abstract method to initialize a template and eventually takes advantage of new 4.3 TPL API * @return eZTemplate */ public static function templateInit() { $tpl = null; if (eZPublishSDK::majorVersion() >= 4 && eZPublishSDK::minorVersion() < 3) { include_once 'kernel/common/template.php'; $tpl = templateInit(); } else { $tpl = eZTemplate::factory(); } return $tpl; }
public function doGetAll() { $result = new ezpRestMvcResult(); // Header $tpl = eZTemplate::factory(); $tpl->setVariable('current_user', eZUser::currentUser()); $result->variables['menu'] = $tpl->fetch('design:page_topmenu.tpl'); $result->variables['news'] = $tpl->fetch('design:parts/news_header.tpl'); $result->variables['styles_ie'] = $tpl->fetch('design:page_head_style_ie.tpl'); $result->variables['footer'] = $tpl->fetch('design:page_footer.tpl'); return $result; }
/** * Regression test for issue #15852 * * indent() operator throws a warning when count parameter is negative */ public function testIssue15852() { set_error_handler( 'testErrorHandler' ); $tpl = eZTemplate::factory(); $templateDirectory = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; // Static variable test $templateFile = "file:$templateDirectory/eztemplatetextoperator_regression_testIssue15852_static.tpl"; $tpl->compileTemplateFile( $templateFile ); try { $result = $tpl->fetch( $templateFile ); } catch( Exception $e ) { restore_error_handler(); if ( strstr( $e->getMessage(), "str_repeat" ) !== false ) { $this->fail( 'Static variable, warning thrown: ' . $e->getMessage() ); } else { throw $e; } } $this->assertEquals( "This is a string", $result, "The original, unindented string should have been returned" ); // Dynamic variable test $templateFile = "file:$templateDirectory/eztemplatetextoperator_regression_testIssue15852_dynamic.tpl"; $tpl->compileTemplateFile( $templateFile ); $tpl->setVariable( 'indent', -1 ); try { $result = $tpl->fetch( $templateFile ); } catch ( Exception $e ) { restore_error_handler(); if ( strstr( $e->getMessage(), "str_repeat" ) !== false ) { $this->fail( 'Dynamic variable, warning thrown: ' . $e->getMessage() ); } else { throw $e; } } $this->assertEquals( "This is a string", $result, "The original, unindented string should have been returned" ); restore_error_handler(); }
public function __construct() { parent::__construct(); $this->setName("eZSIBlockFunctionTest"); $this->templateResource = eZTemplate::factory(); $this->rootNamespace = ''; $this->currentNamespace = ''; $this->textElements = array(); $this->functionChildren = array(); $this->functionParameters = array(); $this->functionPlacement = $this->initFunctionPlacement(); }
/** * send notification with all comment in one notification * Exception if error happens * @param $subscriber * @param $contentObject * @param $commentList comment list to the subscriber, which can be null. * @param $tpl * @return void */ public function sendNotificationInOne($subscriber, $contentObject, $commentList = null, $tpl = null) { if (is_null($tpl)) { $tpl = eZTemplate::factory(); } $tpl->setVariable('subscriber', $subscriber); $tpl->setVariable('contentobject', $contentObject); if (!is_null($commentList)) { $tpl->setVariable('comment_list', $commentList); } $subject = $tpl->fetch($this->multiSubjectTemplatePath); $body = $tpl->fetch($this->multiBodyTemplatePath); $this->executeSending($subject, $body, $subscriber); }
/** * * Renders a template. * * @param $content * @param array $options * * @return array * */ protected function renderTpl($content, array $options = array()) { if (isset($options['template'])) { $tpl = \eZTemplate::factory(); if (is_array($content)) { foreach ($content as $key => $val) { $tpl->setVariable($key, $val); } } return $tpl->fetch($options['template']); unset($options['template']); } return compact('content') + $options; }
/** * Executes the PHP function for the operator cleanup and modifies $operatorValue. * * @param eZTemplate $tpl * @param string $operatorName * @param array $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters */ public function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters) { switch ($operatorName) { case 'eztagscloud': $searchEngine = eZINI::instance()->variable('SearchSettings', 'SearchEngine'); if (class_exists('eZSolr') && $searchEngine == 'ezsolr' && eZINI::instance('eztags.ini')->variable('GeneralSettings', 'TagCloudOverSolr') === 'enabled') { $tagCloud = $this->solrTagCloud($namedParameters['params']); } else { $tagCloud = $this->tagCloud($namedParameters['params']); } $tpl = eZTemplate::factory(); $tpl->setVariable('tag_cloud', $tagCloud); $operatorValue = $tpl->fetch('design:tagcloud.tpl'); break; } }
function lookupIcon($ini, $tag) { $iconMap = $ini->variable('Icons', 'IconMap'); $returnValue = $ini->variable('Icons', 'Default'); if (array_key_exists($tag->attribute('id'), $iconMap) && !empty($iconMap[$tag->attribute('id')])) { $returnValue = $iconMap[$tag->attribute('id')]; } else { $tempTag = $tag; while ($tempTag->attribute('parent_id') > 0) { $tempTag = $tempTag->getParent(); if (array_key_exists($tempTag->attribute('id'), $iconMap) && !empty($iconMap[$tempTag->attribute('id')])) { $returnValue = $iconMap[$tempTag->attribute('id')]; break; } } } return eZURLOperator::eZImage(eZTemplate::factory(), 'tag_icons/small/' . $returnValue, ''); }
function execute( $xml ) { $template = $xml->getAttribute( 'template' ); $receiverID = $xml->getAttribute( 'receiver' ); $nodeID = $xml->getAttribute( 'node' ); $ini = eZINI::instance(); $mail = new eZMail(); $tpl = eZTemplate::factory(); $node = eZContentObjectTreeNode::fetch( $nodeID ); if ( !$node ) { $node = eZContentObjectTreeNode::fetch( 2 ); } $emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); if ( !$emailSender ) $emailSender = $ini->variable( "MailSettings", "AdminEmail" ); $receiver = eZUser::fetch( $receiverID ); if ( !$receiver ) { $emailReceiver = $emailSender; } else { $emailReceiver = $receiver->attribute( 'email' ); } $tpl->setVariable( 'node', $node ); $tpl->setVariable( 'receiver', $receiver ); $body = $tpl->fetch( 'design:' . $template ); $subject = $tpl->variable( 'subject' ); $mail->setReceiver( $emailReceiver ); $mail->setSender( $emailSender ); $mail->setSubject( $subject ); $mail->setBody( $body ); $mailResult = eZMailTransport::send( $mail ); return $mailResult; }
public function testActivateSubscription() { $subscriber = ezcomSubscriber::create(); $subscriber->setAttribute('email', '*****@*****.**'); $subscriber->setAttribute('user_id', 10); $subscriber->store(); $subscription = ezcomSubscription::create(); $subscription->setAttribute('subscriber_id', $subscriber->attribute('id')); $subscription->setAttribute('subscriber_type', 'ezcomcomment'); $subscription->setAttribute('enabled', 0); $subscription->setAttribute('content_id', '10_2'); $hashString = ezcomUtility::instance()->generateSubscriptionHashString($subscription); $subscription->setAttribute('hash_string', $hashString); $subscription->store(); $id = $subscription->attribute('id'); $tpl = eZTemplate::factory(); $subscriptionManager = ezcomSubscriptionManager::instance($tpl, null, null, 'ezcomSubscriptionManager'); $subscriptionManager->activateSubscription($hashString); $subscriptionActivated = ezcomSubscription::fetch($id); $this->assertEquals(1, $subscriptionActivated->attribute('enabled')); }
/** * @deprecated Since 5.0 * @return null */ function eZDisplayDebug() { $ini = eZINI::instance(); if ($ini->variable('DebugSettings', 'DebugOutput') != 'enabled') { return null; } $scriptStopTime = microtime(true); $type = $ini->variable("DebugSettings", "Debug"); //eZDebug::setHandleType( eZDebug::HANDLE_NONE ); if ($type == "inline" or $type == "popup") { $asHtml = true; if ($ini->variable("DebugSettings", "DebugToolbar") == 'enabled' && $ini->variable("SiteAccessSettings", "CheckValidity") !== 'true' && $asHtml == true && !$GLOBALS['eZRedirection']) { $tpl = eZTemplate::factory(); $result = "<tr><td colspan='2'>" . $tpl->fetch('design:setup/debug_toolbar.tpl') . "</td></tr>"; eZDebug::appendTopReport("Debug toolbar", $result); } eZDebug::appendBottomReport('Template Usage Statistics', eZTemplatesStatisticsReporter::generateStatistics($asHtml)); eZDebug::setScriptStop($scriptStopTime); return eZDebug::printReport($type == "popup", $asHtml, true, false, true, true, $ini->variable("DebugSettings", "DisplayIncludedFiles") == 'enabled'); } return null; }
/** * Renders the block (returns HTML) * * @return string HTML **/ public function render() { $tpl = eZTemplate::factory(); $tpl->setVariable( 'articles', $this->getSolrArticles() ); $tpl->setVariable( 'additional_classes', $this->additionalClasses() ); $tpl->setVariable( 'app', $this->applicationObject ); $tpl->setVariable( 'app_localized', $this->applicationLocalized ); $tpl->setVariable( 'app_url_alias', $this->appUrlAlias() ); $tpl->setVariable( 'cluster_identifier', ClusterTool::clusterIdentifier() ); $tpl->setVariable( 'include_app_name', SolrSafeOperatorHelper::clusterIni( 'HomePageSettings', 'ShowApplicationInMoreLink', 'merck.ini' ) ); $tpl->setVariable( 'nb_articles', $this->nbArticles ); $tpl->setVariable( 'publisher_logo', $this->publisherLogo() ); $tpl->setVariable( 'view_mode', $this->viewMode() ); $tpl->setVariable( 'application_url', SolrSafeOperatorHelper::getApplicationUrl($this->applicationObject->attribute('identifier')) ); $tpl->setVariable( 'with_feed', $this->_application->resultHandler->withFeed ); $blockResult = $tpl->fetch( 'design:presenters/block/applist.tpl' ); eZTemplate::resetInstance(); return $blockResult; }
function prepareXMLFromTemplate( $templateName, $cli = false ) { $template = 'design:' . $templateName . '.tpl'; $tpl = eZTemplate::factory(); $tpl->setVariable( 'tpl_info', false ); $content = $tpl->fetch( $template ); $tplInfo = false; if ( $tpl->variable( "tpl_info" ) !== false ) { $tplInfo = $tpl->variable( "tpl_info" ); } if ( is_array( $tplInfo ) ) { foreach ( $tplInfo as $var => $info ) { if ( isset( $info['info'] ) ) { $query = $info['info']; } else { $query = 'Info for ' . $var; } $default = ''; if ( isset( $info['default'] ) ) { $default = $info['default']; } $value = eZPrepareXML::getUserInput( "Please enter \"" . $query . "\" (" . $default . "): ", $default ); $tpl->setVariable( $var, $value ); } } $content = $tpl->fetch( $template ); $xml = $tpl->variable( "xml_data" ); return $xml; }
function handle($event) { eZDebugSetting::writeDebug('kernel-notification', $event, "trying to handle event"); if ($event->attribute('event_type_string') == 'ezcurrenttime') { $date = $event->content(); $timestamp = $date->attribute('timestamp'); $addressArray = $this->fetchUsersForDigest($timestamp); $tpl = eZTemplate::factory(); $prevTplUsageStats = $tpl->setIsTemplatesUsageStatisticsEnabled(false); $transport = eZNotificationTransport::instance('ezmail'); foreach ($addressArray as $address) { $tpl->setVariable('date', $date); $tpl->setVariable('address', $address['address']); $result = $tpl->fetch('design:notification/handler/ezgeneraldigest/view/plain.tpl'); $subject = $tpl->variable('subject'); $parameters = array(); if ($tpl->hasVariable('content_type')) { $parameters['content_type'] = $tpl->variable('content_type'); } $transport->send($address, $subject, $result, null, $parameters); eZDebugSetting::writeDebug('kernel-notification', $result, "digest result"); } $collectionItemIDList = $tpl->variable('collection_item_id_list'); eZDebugSetting::writeDebug('kernel-notification', $collectionItemIDList, "handled items"); $tpl->setIsTemplatesUsageStatisticsEnabled($prevTplUsageStats); if (is_array($collectionItemIDList) && count($collectionItemIDList) > 0) { $ini = eZINI::instance('notification.ini'); $countElements = $ini->variable('RuleSettings', 'LimitDeleteElements'); if (!$countElements) { $countElements = 50; } $splited = array_chunk($collectionItemIDList, $countElements); foreach ($splited as $key => $value) { eZPersistentObject::removeObject(eZNotificationCollectionItem::definition(), array('id' => array($value, ''))); } } } return true; }
/** Get the text content to make the edge include the given template. * @see nxcESI::getIncludeForTemplate() */ public function getIncludeForTemplate($template, $keys) { // Save the current EAS instance to restore it afterwards, so that the // {es-cache} settings of the included template doesn't affect the // header for the current response, which is for the full page. $easInstance = nxcESIEAS::restoreInstance(null); $tpl = eZTemplate::factory(); do { $namespace = uniqid('nxcESI-', true); } while (isset($tpl->Variables[$namespace])); $oldValues = array(); foreach ($keys as $key => $value) { if ($tpl->hasVariable($key, $namespace)) { $oldValues[$key] = $tpl->variable($key, $namespace); } $tpl->setVariable($key, $value, $namespace); } $content = array(); $tpl->processURI($template, true, $extraParameters, $content, $namespace, $namespace); if (is_array($content)) { $content = implode('', $content); } if (!is_string($content)) { $content = ''; } foreach ($keys as $key => $value) { if (array_key_exists($key, $oldValues)) { $tpl->setVariable($key, $oldValues[$key], $namespace); } else { $tpl->unsetVariable($key, $namespace); } } unset($tpl->Variables[$namespace]); nxcESIEAS::restoreInstance($easInstance); return $content; }
<?php /** * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version 2012.8 * @package kernel */ $settingTypeArray = array('array' => 'Array', 'true/false' => 'True/False', 'enable/disable' => 'Enabled/Disabled', 'string' => 'String', 'numeric' => 'Numeric'); $tpl = eZTemplate::factory(); $http = eZHTTPTool::instance(); //$ini = eZINI::instance(); if ($Params['INIFile']) { $iniFile = $Params['INIFile']; } if ($Params['SiteAccess']) { $siteAccess = $Params['SiteAccess']; } if ($Params['Block']) { $block = $Params['Block']; } if ($Params['Setting']) { $settingName = $Params['Setting']; } if ($Params['Placement']) { $settingPlacement = $Params['Placement']; } if ($http->hasPostVariable('INIFile')) { $iniFile = $http->variable("INIFile"); } if ($http->hasPostVariable('SiteAccess')) {
function showNotificationAfterCopying($http, $Module, &$Result, &$Notifications, $srcNode) { $tpl = eZTemplate::factory(); if ($http->hasSessionVariable("LastAccessesURI", false)) { $tpl->setVariable('redirect_url', $http->sessionVariable("LastAccessesURI")); } else { $parentRootNodeID = $srcNode->attribute('parent_node_id'); if ($Module->hasActionParameter('LanguageCode')) { $languageCode = $Module->actionParameter('LanguageCode'); } else { $languageCode = false; } if ($Module->hasActionParameter('ViewMode')) { $viewMode = $Module->actionParameter('ViewMode'); } else { $viewMode = 'full'; } $redirectURI = $Module->redirectionURIForModule($Module, 'view', array($viewMode, $parentRootNodeID, $languageCode)); $tpl->setVariable('redirect_url', $redirectURI); } $tpl->setVariable('source_node', $srcNode); //$tpl->setVariable( 'subtree_nodes_count', $srcSubtreeNodesCount ); $tpl->setVariable('notifications', $Notifications); $Result['content'] = $tpl->fetch('design:content/copy_subtree_notification.tpl'); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/content', 'Content')), array('url' => false, 'text' => ezpI18n::tr('kernel/content', 'Copy subtree'))); }
function checkContentActions( $module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage, $FromLanguage, &$Result ) { if ( $module->isCurrentAction( 'Preview' ) ) { $module->redirectToView( 'versionview', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'Translate' ) ) { $module->redirectToView( 'translate', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'VersionEdit' ) ) { if ( isset( $GLOBALS['eZRequestedURI'] ) and is_object( $GLOBALS['eZRequestedURI'] ) ) { $uri = $GLOBALS['eZRequestedURI']; $uri = $uri->originalURIString(); $http = eZHTTPTool::instance(); $http->setSessionVariable( 'LastAccessesVersionURI', $uri ); } $module->redirectToView( 'history', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'EditLanguage' ) ) { if ( $module->hasActionParameter( 'SelectedLanguage' ) ) { $EditLanguage = $module->actionParameter( 'SelectedLanguage' ); // We reset the from language to disable the translation look $FromLanguage = false; $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } } if ( $module->isCurrentAction( 'TranslateLanguage' ) ) { if ( $module->hasActionParameter( 'SelectedLanguage' ) ) { $FromLanguage = $EditLanguage; $EditLanguage = $module->actionParameter( 'SelectedLanguage' ); $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } } if ( $module->isCurrentAction( 'FromLanguage' ) ) { $FromLanguage = $module->actionParameter( 'FromLanguage' ); $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'Discard' ) ) { $http = eZHTTPTool::instance(); $objectID = $object->attribute( 'id' ); $discardConfirm = true; if ( $http->hasPostVariable( 'DiscardConfirm' ) ) $discardConfirm = $http->postVariable( 'DiscardConfirm' ); $http->setSessionVariable( 'DiscardObjectID', $objectID ); $http->setSessionVariable( 'DiscardObjectVersion', $EditVersion ); $http->setSessionVariable( 'DiscardObjectLanguage', $EditLanguage ); $http->setSessionVariable( 'DiscardConfirm', $discardConfirm ); $module->redirectTo( $module->functionURI( 'removeeditversion' ) . '/' ); return eZModule::HOOK_STATUS_CANCEL_RUN; } // helper function which computes the redirect after // publishing and final store of a draft. function computeRedirect( $module, $object, $version, $EditLanguage = false ) { $http = eZHTTPTool::instance(); $node = $object->mainNode(); if ( $http->hasSessionVariable( 'RedirectIfDiscarded' ) ) { $http->removeSessionVariable( 'RedirectIfDiscarded' ); } $hasRedirected = false; if ( $http->hasSessionVariable( 'ParentObject' ) && $http->sessionVariable( 'NewObjectID' ) == $object->attribute( 'id' ) ) { $parentArray = $http->sessionVariable( 'ParentObject' ); $parentURL = $module->redirectionURI( 'content', 'edit', $parentArray ); $parentObject = eZContentObject::fetch( $parentArray[0] ); $db = eZDB::instance(); $db->begin(); $parentObject->addContentObjectRelation( $object->attribute( 'id' ), $parentArray[1] ); $db->commit(); $http->removeSessionVariable( 'ParentObject' ); $http->removeSessionVariable( 'NewObjectID' ); $module->redirectTo( $parentURL ); $hasRedirected = true; } if ( $http->hasSessionVariable( 'RedirectURIAfterPublish' ) && !$hasRedirected ) { $uri = $http->sessionVariable( 'RedirectURIAfterPublish' ); $http->removeSessionVariable( 'RedirectURIAfterPublish' ); $module->redirectTo( $uri ); $hasRedirected = true; } if ( $http->hasPostVariable( 'RedirectURIAfterPublish' ) && !$hasRedirected ) { $uri = $http->postVariable( 'RedirectURIAfterPublish' ); $module->redirectTo( $uri ); $hasRedirected = true; } if ( $http->hasPostVariable( "BackToEdit" ) && $http->postVariable( "BackToEdit" ) ) { $uri = $module->redirectionURI( 'content', 'edit', array( $object->attribute( 'id'), 'f', $EditLanguage ) ); $module->redirectTo( $uri ); eZDebug::writeDebug( $uri, "uri " . $object->attribute( 'id') ); $hasRedirected = true; } if ( !$hasRedirected ) { if ( $http->hasPostVariable( 'RedirectURI' ) ) { $uri = $http->postVariable( 'RedirectURI' ); $module->redirectTo( $uri ); } else if ( $node !== null ) { $parentNode = $node->attribute( 'parent_node_id' ); if ( $parentNode == 1 ) { $parentNode = $node->attribute( 'node_id' ); } $module->redirectToView( 'view', array( 'full', $parentNode ) ); } else { $module->redirectToView( 'view', array( 'full', $version->attribute( 'main_parent_node_id' ) ) ); } } } if( $module->isCurrentAction( 'StoreExit' ) ) { computeRedirect( $module, $object, $version, $EditLanguage ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'Publish' ) ) { // Checking the source and destination language from the url, // if they are the same no confirmation is needed. if ( $EditLanguage != $FromLanguage ) { $conflictingVersions = $version->hasConflicts( $EditLanguage ); if ( $conflictingVersions ) { $tpl = eZTemplate::factory(); $res = eZTemplateDesignResource::instance(); $res->setKeys( array( array( 'object', $object->attribute( 'id' ) ), array( 'remote_id', $object->attribute( 'remote_id' ) ), array( 'class', $class->attribute( 'id' ) ), array( 'class_identifier', $class->attribute( 'identifier' ) ), array( 'class_group', $class->attribute( 'match_ingroup_id_list' ) ) ) ); $tpl->setVariable( 'edit_language', $EditLanguage ); $tpl->setVariable( 'current_version', $version->attribute( 'version' ) ); $tpl->setVariable( 'object', $object ); $tpl->setVariable( 'draft_versions', $conflictingVersions ); $Result = array(); $Result['content'] = $tpl->fetch( 'design:content/edit_conflict.tpl' ); return eZModule::HOOK_STATUS_CANCEL_RUN; } } eZDebug::accumulatorStart( 'publish', '', 'publish' ); $oldObjectName = $object->name(); $behaviour = new ezpContentPublishingBehaviour(); $behaviour->isTemporary = true; $behaviour->disableAsynchronousPublishing = false; ezpContentPublishingBehaviour::setBehaviour( $behaviour ); $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ), 'version' => $version->attribute( 'version' ) ) ); eZDebug::accumulatorStop( 'publish' ); if ( ( array_key_exists( 'status', $operationResult ) && $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE ) ) { eZDebug::writeDebug( $operationResult, __FILE__ ); switch( $operationResult['status'] ) { case eZModuleOperationInfo::STATUS_REPEAT: { eZContentOperationCollection::setVersionStatus( $object->attribute( 'id' ), $version->attribute( 'version' ), eZContentObjectVersion::STATUS_REPEAT ); } case eZModuleOperationInfo::STATUS_HALTED: { if ( isset( $operationResult['redirect_url'] ) ) { $module->redirectTo( $operationResult['redirect_url'] ); return; } else if ( isset( $operationResult['result'] ) ) { $result = $operationResult['result']; $resultContent = false; if ( is_array( $result ) ) { if ( isset( $result['content'] ) ) { $resultContent = $result['content']; } if ( isset( $result['path'] ) ) { $Result['path'] = $result['path']; } } else { $resultContent = $result; } // Temporary fix to make approval workflow work with edit. if ( strpos( $resultContent, 'Deffered to cron' ) === 0 ) { $Result = null; } else { $Result['content'] = $resultContent; } } }break; case eZModuleOperationInfo::STATUS_CANCELLED: { $Result = array(); $Result['content'] = "Content publish cancelled<br/>"; } } /* If we already have a correct module result * we don't need to continue module execution. */ if ( is_array( $Result ) ) return eZModule::HOOK_STATUS_CANCEL_RUN; } // update content object attributes array by refetching them from database $object = eZContentObject::fetch( $object->attribute( 'id' ) ); $contentObjectAttributes = $object->attribute( 'contentobject_attributes' ); // set chosen hidden/invisible attributes for object nodes $http = eZHTTPTool::instance(); $assignedNodes = $object->assignedNodes( true ); foreach ( $assignedNodes as $node ) { $nodeID = $node->attribute( 'node_id' ); $parentNodeID = $node->attribute( 'parent_node_id' ); $updateNodeVisibility = false; $postVarName = "FutureNodeHiddenState_$parentNodeID"; if ( !$http->hasPostVariable( $postVarName ) ) $updateNodeVisibility = true; else { $futureNodeHiddenState = $http->postVariable( $postVarName ); $db = eZDB::instance(); $db->begin(); if ( $futureNodeHiddenState == 'hidden' ) eZContentObjectTreeNode::hideSubTree( $node ); else if ( $futureNodeHiddenState == 'visible' ) eZContentObjectTreeNode::unhideSubTree( $node ); else if ( $futureNodeHiddenState == 'unchanged' ) $updateNodeVisibility = true; else eZDebug::writeWarning( "Unknown value for the future node hidden state: '$futureNodeHiddenState'" ); $db->commit(); } if ( $updateNodeVisibility ) { // this might be redundant $db = eZDB::instance(); $db->begin(); $parentNode = eZContentObjectTreeNode::fetch( $parentNodeID ); eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false ); $db->commit(); unset( $node, $parentNode ); } } unset( $assignedNodes ); $object = eZContentObject::fetch( $object->attribute( 'id' ) ); $newObjectName = $object->name(); $http = eZHTTPTool::instance(); computeRedirect( $module, $object, $version, $EditLanguage ); // we have set redirection URI for module so we don't need to continue module execution return eZModule::HOOK_STATUS_CANCEL_RUN; } }