本文整理汇总了PHP中eZTemplate类的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplate类的具体用法?PHP eZTemplate怎么用?PHP eZTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValidItems
/**
* 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;
}
示例2: sendOrderEmail
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);
}
}
示例3: run
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 '';
}
示例4: render
/**
* 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' );
}
示例5: getNextItems
/**
* 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;
}
示例6: getGooglePlusComments
/**
* 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');
}
示例7: prime
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;
}
示例8: runModify
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 );
}
示例9: render
/**
* 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' );
}
示例10: render
/**
* 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;
}
示例11: displayForm
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;
}
示例12: render
/**
* 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;
}
示例13: render
/**
* 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);
}
示例14: modify
/**
* 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);
}
示例15: templateInit
/**
* 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;
}