/** * 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 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); } }
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( '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; }
/** * Generate G+ comments feed for an activity * @param eZTemplate $tpl * @param array $namedParameters * @return string */ private function getGooglePlusComments($tpl, $namedParameters) { //get config $nlGooglePlusIni = eZINI::instance('nlgoogleplus.ini'); //initilize G+ Service $plus = $this->initializeGooglePlusService(); if (!isset($namedParameters['activityid'])) { eZLog::write('Activity id is required', 'error.log'); return false; } //parameters needed $activityId = $namedParameters['activityid']; $title = $namedParameters['title']; //find all related comments $optParams = array('maxResults' => $nlGooglePlusIni->variable('Feed', 'MaxResults')); try { $comments = $plus->comments->listComments($activityId, $optParams); } catch (Exception $e) { eZLog::write('Google Plus get comments problem : ' . $e->getMessage(), 'error.log'); } //use template $tpl->setVariable('comments', $comments); $tpl->setVariable('title', $title); return $tpl->fetch('design:nlgoogleplus/googleplusboxcomments.tpl'); }
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; }
private function runModify( $operatorName, $method ) { $operator = new eZURLOperator(); $tpl = eZTemplate::instance(); $operatorValue = null; $argument = 'zeargument'; $expectedResult = 'zevalue'; switch( $method ) { case 'get' : $_GET[$argument] = $expectedResult; break; case 'post' : $_POST[$argument] = $expectedResult; break; case 'cookie' : $_COOKIE[$argument] = $expectedResult; break; case 'session': $_SESSION[$argument] = $expectedResult; break; } $operatorParameters = array( array( array( 1, $argument, false, ), ), array( array( 1, $method, false, ), ), ); $namedParameters = array( 'quote_val' => $argument, 'server_url' => $method ); $operator->modify( $tpl, $operatorName, $operatorParameters, '', '', $operatorValue, $namedParameters, false ); $this->assertEquals( $expectedResult, $operatorValue ); }
/** * 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; }
/** * 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; }
/** * 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); }
/** * Executes the template operator * * @param eZTemplate $tpl * @param string $operatorName * @param mixed $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters * @param mixed $placement */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement) { if (!is_string($namedParameters['name']) && empty($namedParameters['name'])) { $tpl->error($operatorName, "{$operatorName} parameter 'name' must be a non empty string.", $placement); return; } $templateName = $namedParameters['name']; if ($namedParameters['parameters'] !== null && !is_array($namedParameters['parameters'])) { $tpl->error($operatorName, "{$operatorName} parameter 'parameters' must be a hash array.", $placement); return; } $templateParameters = $namedParameters['parameters'] !== null ? $namedParameters['parameters'] : array(); $apiContentConverter = NgSymfonyToolsApiContentConverter::instance(); foreach ($templateParameters as $parameterName => $parameterValue) { $templateParameters[$parameterName] = $apiContentConverter->convert($parameterValue); } $serviceContainer = ezpKernel::instance()->getServiceContainer(); $templatingEngine = $serviceContainer->get('templating'); $operatorValue = $templatingEngine->render($templateName, $templateParameters); }
/** * 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; }
/** * 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'); }
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(); }
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(); }
/** * Executes the template operator * * @param eZTemplate $tpl * @param string $operatorName * @param mixed $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters * @param mixed $placement */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement) { if (!$namedParameters['uri'] instanceof ControllerReference && !(is_string($namedParameters['uri']) && !empty($namedParameters['uri']))) { $tpl->error($operatorName, "{$operatorName} parameter 'uri' must be a non empty string or a controller reference.", $placement); return; } $uri = $namedParameters['uri']; if ($namedParameters['options'] !== null && !is_array($namedParameters['options'])) { $tpl->error($operatorName, "{$operatorName} parameter 'options' must be a hash array.", $placement); return; } $options = $namedParameters['options'] !== null ? $namedParameters['options'] : array(); if ($operatorName === 'symfony_render_esi') { $options['strategy'] = 'esi'; } else { if ($operatorName === 'symfony_render_hinclude') { $options['strategy'] = 'hinclude'; } } $operatorValue = self::renderUri($uri, $options); }
/** * Executes the template operator * * @param eZTemplate $tpl * @param string $operatorName * @param mixed $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters * @param mixed $placement */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement) { if (!is_string($namedParameters['name']) && empty($namedParameters['name'])) { $tpl->error($operatorName, "{$operatorName} parameter 'name' must be a non empty string.", $placement); return; } $name = $namedParameters['name']; if ($namedParameters['parameters'] !== null && !is_array($namedParameters['parameters'])) { $tpl->error($operatorName, "{$operatorName} parameter 'parameters' must be a hash array.", $placement); return; } $parameters = $namedParameters['parameters'] !== null ? $namedParameters['parameters'] : array(); if ($operatorName === 'symfony_path') { $relative = isset($namedParameters['relative']) && $namedParameters['relative'] === true; $operatorValue = self::getPath($name, $parameters, $relative); } else { if ($operatorName === 'symfony_url') { $schemeRelative = isset($namedParameters['scheme_relative']) && $namedParameters['scheme_relative'] === true; $operatorValue = self::getUrl($name, $parameters, $schemeRelative); } } }
/** * * 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 template operator * * @param eZTemplate $tpl * @param string $operatorName * @param mixed $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters * @param mixed $placement */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement) { if (!is_string($namedParameters['controller']) || empty($namedParameters['controller'])) { $tpl->error($operatorName, "{$operatorName} parameter 'controller' must be a non empty string.", $placement); return; } $controller = $namedParameters['controller']; if ($namedParameters['attributes'] !== null && !is_array($namedParameters['attributes'])) { $tpl->error($operatorName, "{$operatorName} parameter 'attributes' must be a hash array.", $placement); return; } $attributes = $namedParameters['attributes'] !== null ? $namedParameters['attributes'] : array(); if ($namedParameters['query'] !== null && !is_array($namedParameters['query'])) { $tpl->error($operatorName, "{$operatorName} parameter 'query' must be a hash array.", $placement); return; } $query = $namedParameters['query'] !== null ? $namedParameters['query'] : array(); $apiContentConverter = NgSymfonyToolsApiContentConverter::instance(); foreach ($attributes as $attributeName => $attributeValue) { $attributes[$attributeName] = $apiContentConverter->convert($attributeValue); } $operatorValue = self::getController($controller, $attributes, $query); }
/** * 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); }
/** * Test for issue #12285 * Variables set by functions handled by eZObjectForwarder (like attribute_view_gui) are not scope safe. * The patch for this issue ensures that, if requested, a template variable can be backed up in a safe namespace * (same var name but different namespace), so that it can't be overridden * @param string $varName * @param string $val * @param string $namespace * @link http://issues.ez.no/12285 * @group issue12285 */ public function testSetScopeSafeVariable() { $namespace = "myNamespace"; $varName = "foo"; $aVal = array( "bar", "baz", "biz" ); // Simulate 3 level of nesting $previousVal = null; $nestingLevel = 0; // Try to set different values to a tpl variable to emulate a nested set like described in the issue foreach ( $aVal as $val ) { $this->tpl->setVariable( $varName, $val, $namespace, true ); self::assertEquals( $val, $this->tpl->variable( $varName, $namespace ), "Template variable has not been correctly set" ); if ( !empty( $previousVal ) ) { $safeNamespace = $namespace . str_repeat( ":safe", $nestingLevel ); self::assertEquals( $previousVal, $this->tpl->variable( $varName, $safeNamespace ), "Template variable has not been backed up in a safe namespace" ); } $previousVal = $val; $nestingLevel++; } // Now unset the tpl variables and check that they are well restored $aUnsetVal = array_reverse( $aVal ); // Nesting level must decrease to 0, so decrease it first $nestingLevel -= 1; foreach ( $aUnsetVal as $val ) { $safeNamespace = $namespace . str_repeat( ":safe", $nestingLevel ); $this->tpl->unsetVariable( $varName, $namespace ); self::assertNull( $this->tpl->variable( $varName, $safeNamespace ), "Backed up tpl variable has not been deleted" ); $nestingLevel--; // Check that backed up value is correctly restored if ( $nestingLevel >= 0 ) { self::assertEquals( $aVal[$nestingLevel], $this->tpl->variable( $varName, $namespace ), "Backed up tpl variable has not been properly restored from safe namespace" ); } else { self::assertNull( $this->tpl->variable( $varName, $namespace ), "Template variable has not been unset" ); } } }
/** * 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; } }
/** * @return eZTemplate */ public function tpl() { if(is_null($this->_tpl)) { eZTemplate::resetInstance(); $this->_tpl = eZTemplate::factory(); if (SolrSafeOperatorHelper::featureIsActive('showMedicalNewsDemo') && SolrSafeOperatorHelper::feature('ShowMedicalNewsDemo', 'showDemo')){ $showMedicalNewsDemo = true; }else { $showMedicalNewsDemo = false; } $this->_tpl->setVariable('showMedicalNewsDemo',$showMedicalNewsDemo); $this->_tpl->setVariable('language' , LocaleTool::languageISO639Code()); $this->_tpl->setVariable('application_class' , get_class($this) ); $this->_tpl->setVariable('view_parameters' , $this->_params['UserParameters']); $this->_tpl->setVariable('cluster_identifier', ClusterTool::clusterIdentifier()); $this->_tpl->setVariable('application_url' , $this->applicationName()); $this->_tpl->setVariable('consult' , $this->isConsult); $this->_tpl->setVariable('httpcontext' , array( 'host' => ContextTool::instance()->domain(), )); $environment = new MMEnvironment(); $this->_tpl->setVariable('environment' , $environment->env); $applicationLocalized = CacheApplicationTool::buildLocalizedApplication($this->applicationName()); if (empty($applicationLocalized)) $this->_tpl->setVariable('application_name' , $this->applicationName()); else { $applicationIdentifier = $applicationLocalized->applicationObject->attribute('identifier'); $this->_tpl->setVariable('application_name' , $applicationIdentifier ); $this->_tpl->setVariable('current_localized' , $applicationLocalized ); $this->_tpl->setVariable('current_application' , $applicationLocalized->applicationObject ); } } return $this->_tpl; }
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')); }