本文整理汇总了PHP中eZTemplateDesignResource类的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateDesignResource类的具体用法?PHP eZTemplateDesignResource怎么用?PHP eZTemplateDesignResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZTemplateDesignResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendConfirmation
function sendConfirmation()
{
if ($this->attribute('status') != eZSubscription::StatusPending) {
return;
}
$res = eZTemplateDesignResource::instance();
$ini = eZINI::instance();
$hostname = eZSys::hostname();
$template = 'design:eznewsletter/sendout/registration.tpl';
$tpl = eZNewsletterTemplateWrapper::templateInit();
$tpl->setVariable('userData', eZUserSubscriptionData::fetch($this->attribute('email')));
$tpl->setVariable('hostname', $hostname);
$tpl->setVariable('subscription', $this);
$tpl->setVariable('subscriptionList', $this->attribute('subscription_list'));
$templateResult = $tpl->fetch($template);
if ($tpl->hasVariable('subject')) {
$subject = $tpl->variable('subject');
}
$mail = new eZMail();
$mail->setSender($ini->variable('MailSettings', 'EmailSender'), $ini->variable('SiteSettings', 'SiteName'));
$mail->setReceiver($this->attribute('email'));
$mail->setBody($templateResult);
$mail->setSubject($subject);
eZMailTransport::send($mail);
}
示例2: displayAttribute
/**
* 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');
}
示例3: getLessFilePath
/**
* @return mixed
*/
public function getLessFilePath()
{
if ( is_null($this->_lessFilePath) )
{
$bases = eZTemplateDesignResource::allDesignBases();
$triedFiles = array();
$match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $this->getLessFileName(), $triedFiles);
if ( !$match )
{
eZDebug::writeError(sprintf('File %s not found in %s', $this->getLessFileName(), implode(', ', $triedFiles)), __METHOD__);
return false;
}
$this->_lessFilePath = $match['path'];
}
return $this->_lessFilePath;
}
示例4: fetchOverrideTemplateList
function fetchOverrideTemplateList($classID)
{
$class = eZContentClass::fetch($classID);
$classIdentifier = $class->attribute('identifier');
$result = array();
$ini = eZINI::instance();
$siteAccessArray = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList');
foreach ($siteAccessArray as $siteAccess) {
$overrides = eZTemplateDesignResource::overrideArray($siteAccess);
foreach ($overrides as $override) {
if (isset($override['custom_match'])) {
foreach ($override['custom_match'] as $customMatch) {
if (isset($customMatch['conditions']['class_identifier']) && $customMatch['conditions']['class_identifier'] == $classIdentifier) {
$result[] = array('siteaccess' => $siteAccess, 'block' => $customMatch['override_name'], 'source' => $override['template'], 'target' => $customMatch['match_file']);
}
if (isset($customMatch['conditions']['class']) && $customMatch['conditions']['class'] == $classID) {
$result[] = array('siteaccess' => $siteAccess, 'block' => $customMatch['override_name'], 'source' => $override['template'], 'target' => $customMatch['match_file']);
}
}
}
}
}
return array('result' => $result);
}
示例5: handlePublishEvent
function handlePublishEvent($event, &$parameters)
{
$versionObject = $event->attribute('content');
if (!$versionObject) {
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$contentObject = $versionObject->attribute('contentobject');
if (!$contentObject) {
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$contentNode = $contentObject->attribute('main_node');
if (!$contentNode) {
return eZNotificationEventHandler::EVENT_SKIPPED;
}
// Notification should only be sent out when the object is published (is visible)
if ($contentNode->attribute('is_invisible') == 1) {
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$contentClass = $contentObject->attribute('content_class');
if (!$contentClass) {
return eZNotificationEventHandler::EVENT_SKIPPED;
}
if ($versionObject->attribute('version') != $contentObject->attribute('current_version')) {
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$tpl = eZTemplate::factory();
$tpl->resetVariables();
$parentNode = $contentNode->attribute('parent');
if (!$parentNode instanceof eZContentObjectTreeNode) {
eZDebug::writeError('DB corruption: Node id ' . $contentNode->attribute('node_id') . ' is missing parent node.', __METHOD__);
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$parentContentObject = $parentNode->attribute('object');
if (!$parentContentObject instanceof eZContentObject) {
eZDebug::writeError('DB corruption: Node id ' . $parentNode->attribute('node_id') . ' is missing object.', __METHOD__);
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$parentContentClass = $parentContentObject->attribute('content_class');
if (!$parentContentClass instanceof eZContentClass) {
eZDebug::writeError('DB corruption: Object id ' . $parentContentObject->attribute('id') . ' is missing class object.', __METHOD__);
return eZNotificationEventHandler::EVENT_SKIPPED;
}
$res = eZTemplateDesignResource::instance();
$res->setKeys(array(array('object', $contentObject->attribute('id')), array('node', $contentNode->attribute('node_id')), array('class', $contentObject->attribute('contentclass_id')), array('class_identifier', $contentClass->attribute('identifier')), array('parent_node', $contentNode->attribute('parent_node_id')), array('parent_class', $parentContentObject->attribute('contentclass_id')), array('parent_class_identifier', $parentContentClass != null ? $parentContentClass->attribute('identifier') : 0), array('depth', $contentNode->attribute('depth')), array('url_alias', $contentNode->attribute('url_alias'))));
$tpl->setVariable('object', $contentObject);
$notificationINI = eZINI::instance('notification.ini');
$emailSender = $notificationINI->variable('MailSettings', 'EmailSender');
$ini = eZINI::instance();
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
}
if (!$emailSender) {
$emailSender = $ini->variable("MailSettings", "AdminEmail");
}
$tpl->setVariable('sender', $emailSender);
$result = $tpl->fetch('design:notification/handler/ezsubtree/view/plain.tpl');
$subject = $tpl->variable('subject');
if ($tpl->hasVariable('message_id')) {
$parameters['message_id'] = $tpl->variable('message_id');
}
if ($tpl->hasVariable('references')) {
$parameters['references'] = $tpl->variable('references');
}
if ($tpl->hasVariable('reply_to')) {
$parameters['reply_to'] = $tpl->variable('reply_to');
}
if ($tpl->hasVariable('from')) {
$parameters['from'] = $tpl->variable('from');
}
if ($tpl->hasVariable('content_type')) {
$parameters['content_type'] = $tpl->variable('content_type');
}
$collection = eZNotificationCollection::create($event->attribute('id'), self::NOTIFICATION_HANDLER_ID, self::TRANSPORT);
$collection->setAttribute('data_subject', $subject);
$collection->setAttribute('data_text', $result);
$collection->store();
$assignedNodes = $contentObject->parentNodes(true);
$nodeIDList = array();
foreach ($assignedNodes as $node) {
if ($node) {
$pathString = $node->attribute('path_string');
$pathString = ltrim(rtrim($pathString, '/'), '/');
$nodeIDListPart = explode('/', $pathString);
$nodeIDList = array_merge($nodeIDList, $nodeIDListPart);
}
}
$nodeIDList[] = $contentNode->attribute('node_id');
$nodeIDList = array_unique($nodeIDList);
$userList = eZSubtreeNotificationRule::fetchUserList($nodeIDList, $contentObject);
$locale = eZLocale::instance();
$weekDayNames = $locale->attribute('weekday_name_list');
$weekDaysByName = array_flip($weekDayNames);
foreach ($userList as $subscriber) {
$item = $collection->addItem($subscriber['address']);
if ($subscriber['use_digest'] == 0) {
$settings = eZGeneralDigestUserSettings::fetchByUserId($subscriber['user_id']);
if ($settings !== null && $settings->attribute('receive_digest') == 1) {
$time = $settings->attribute('time');
$timeArray = explode(':', $time);
$hour = $timeArray[0];
//.........这里部分代码省略.........
示例6: contentPDFGenerate
function contentPDFGenerate($cacheFile, $node, $object = false, $viewCacheEnabled = true, $languageCode = false, $viewParameters = array())
{
if ($languageCode) {
$node->setCurrentLanguage($languageCode);
}
if ($object == false) {
$object = $node->attribute('object');
}
$res = eZTemplateDesignResource::instance();
$res->setKeys(array(array('object', $node->attribute('contentobject_id')), array('remote_id', $object->attribute('remote_id')), array('node_remote_id', $node->attribute('remote_id')), array('section', $object->attribute('section_id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias')), array('class_group', $object->attribute('match_ingroup_id_list')), array('class_identifier', $object->attribute('class_identifier'))));
$tpl = eZTemplate::factory();
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('node', $node);
$tpl->setVariable('generate_toc', 0);
$tpl->setVariable('tree_traverse', 0);
$tpl->setVariable('class_array', 0);
$tpl->setVariable('show_frontpage', 0);
if ($viewCacheEnabled) {
$tpl->setVariable('generate_file', 1);
$tpl->setVariable('filename', $cacheFile);
} else {
$tpl->setVariable('generate_file', 0);
$tpl->setVariable('generate_stream', 1);
}
$textElements = array();
$uri = 'design:node/view/pdf.tpl';
$tpl->setVariable('pdf_root_template', 1);
eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
$pdf_definition = implode('', $textElements);
$pdf_definition = str_replace(array(' ', "\r\n", "\t", "\n"), '', $pdf_definition);
$tpl->setVariable('pdf_definition', $pdf_definition);
$uri = 'design:node/view/execute_pdf.tpl';
$textElements = '';
eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
}
示例7: load
/**
* Reloads extensions and changes siteaccess globally
* If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
*
* - clears all in-memory caches used by the INI system
* - re-builds the list of paths where INI files are searched for
* - runs {@link eZSiteAccess::change()}
* - re-searches module paths {@link eZModule::setGlobalPathList()}
*
* @since 4.4
* @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
* See {@link eZSiteAccess::match()} for array structure definition
* @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
* If set, then global siteacceess will not be changed as well.
* @return array The $access parameter
*/
static function load( array $access, eZINI $siteINI = null )
{
$currentSiteAccess = $GLOBALS['eZCurrentAccess'];
unset( $GLOBALS['eZCurrentAccess'] );
// Clear all ini override dirs
if ( $siteINI instanceof eZINI )
{
$siteINI->resetOverrideDirs();
}
else
{
eZINI::resetAllInstances();
eZExtension::clearActiveExtensionsMemoryCache();
eZTemplateDesignResource::clearInMemoryCache();
}
// Reload extensions, siteaccess and access extensions
eZExtension::activateExtensions( 'default', $siteINI );
$access = self::change( $access, $siteINI );
eZExtension::activateExtensions( 'access', $siteINI );
// Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
if ( $siteINI instanceof eZINI )
{
$GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
}
else
{
$moduleRepositories = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList( $moduleRepositories );
}
return $access;
}
示例8: eZStepData
include_once "kernel/setup/ezsetuptests.php";
include_once 'kernel/setup/ezsetup_summary.php';
// Initialize template
$tpl = eZTemplate::instance();
//$tpl->registerFunction( "section", new eZTemplateSectionFunction( "section" ) );
//$tpl->registerFunction( "include", new eZTemplateIncludeFunction() );
$ini = eZINI::instance();
if ($ini->variable('TemplateSettings', 'Debug') == 'enabled') {
eZTemplate::setIsDebugEnabled(true);
}
//eZDebug::setLogOnly( true );
//$ini->setVariable( 'RegionalSettings', 'TextTranslation', 'disabled' );
$Module = $Params['Module'];
$tpl->setAutoloadPathList($ini->variable('TemplateSettings', 'AutoloadPathList'));
$tpl->autoload();
$tpl->registerResource(eZTemplateDesignResource::instance());
// Initialize HTTP variables
$http = eZHTTPTool::instance();
$baseDir = 'kernel/setup/';
// Load step list data. See this file for install step references.
$stepDataFile = $baseDir . "steps/ezstep_data.php";
$stepData = null;
if (file_exists($stepDataFile)) {
include_once $stepDataFile;
$stepData = new eZStepData();
}
if ($stepData == null) {
print "<h1>Setup step data file not found. Setup is exiting...</h1>";
//TODO : i18n translate
eZDisplayResult($templateResult);
eZExecution::cleanExit();
示例9: load
/**
* Reloads extensions and changes siteaccess globally
* If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
*
* - clears all in-memory caches used by the INI system
* - re-builds the list of paths where INI files are searched for
* - runs {@link eZSiteAccess::change()}
* - re-searches module paths {@link eZModule::setGlobalPathList()}
*
* @since 4.4
* @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
* See {@link eZSiteAccess::match()} for array structure definition
* @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
* If set, then global siteacceess will not be changed as well.
* @return array The $access parameter
*/
static function load( array $access, eZINI $siteINI = null )
{
$currentSiteAccess = $GLOBALS['eZCurrentAccess'];
unset( $GLOBALS['eZCurrentAccess'] );
// Clear all ini override dirs
if ( $siteINI instanceof eZINI )
{
$siteINI->resetOverrideDirs();
}
else
{
eZINI::resetAllInstances();
eZExtension::clearActiveExtensionsMemoryCache();
eZTemplateDesignResource::clearInMemoryCache();
}
// Reload extensions, siteaccess and access extensions
eZExtension::activateExtensions( 'default', $siteINI );
$access = self::change( $access, $siteINI );
eZExtension::activateExtensions( 'access', $siteINI );
// Reload Extenion ordering to reorder eZINI Global Override Dirs.
// @TODO : Améliorer la gestion globale (éviter des appels multiples !!!)
if ( $siteINI instanceof eZINI && $siteINI->variable( 'ExtensionSettings', 'ExtensionOrdering' ) === 'enabled' )
{
eZINI::removeGlobalOverrideDirsByScope( 'sa-extension' );
eZINI::removeGlobalOverrideDirsByScope( 'extension' );
eZExtension::activateExtensions( false );
}
// Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
if ( $siteINI instanceof eZINI )
{
$GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
}
else
{
$moduleRepositories = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList( $moduleRepositories );
}
return $access;
}
示例10: DOMDocument
function &outputText()
{
if (!$this->XMLData) {
$output = '';
return $output;
}
$this->Tpl = eZTemplate::factory();
$this->Res = eZTemplateDesignResource::instance();
if ($this->ContentObjectAttribute) {
$this->Res->setKeys(array(array('attribute_identifier', $this->ContentObjectAttribute->attribute('contentclass_attribute_identifier'))));
}
$this->Document = new DOMDocument('1.0', 'utf-8');
$success = $this->Document->loadXML($this->XMLData);
if (!$success) {
$this->Output = '';
return $this->Output;
}
$this->prefetch();
$this->XMLSchema = eZXMLSchema::instance();
// Add missing elements to the OutputTags array
foreach ($this->XMLSchema->availableElements() as $element) {
if (!isset($this->OutputTags[$element])) {
$this->OutputTags[$element] = array();
}
}
$this->NestingLevel = 0;
$params = array();
$output = $this->outputTag($this->Document->documentElement, $params);
$this->Output = $output[1];
unset($this->Document);
$this->Res->removeKey('attribute_identifier');
return $this->Output;
}
示例11: foreach
$i = 0;
foreach ( $parameters as $param )
{
if ( $i > 0 )
$template .= "/";
$template .= "$param";
$i++;
}
$siteAccess = $Params['SiteAccess'];
if( $siteAccess )
$http->setSessionVariable( 'eZTemplateAdminCurrentSiteAccess', $siteAccess );
else
$siteAccess = $http->sessionVariable( 'eZTemplateAdminCurrentSiteAccess' );
$overrideArray = eZTemplateDesignResource::overrideArray( $siteAccess );
// Check if template already exists
$isExistingTemplate = false;
foreach ( $overrideArray as $overrideSetting )
{
if ( $overrideSetting['base_dir'] . $overrideSetting['template'] == $template )
{
$isExistingTemplate = true;
break;
}
elseif ( isset( $overrideSetting['custom_match'] ) )
{
foreach ( $overrideSetting['custom_match'] as $customMatch )
{
if ( $customMatch['match_file'] == $template )
示例12: generateStatistics
static function generateStatistics($as_html = true)
{
$stats = '';
if (!eZTemplate::isTemplatesUsageStatisticsEnabled()) {
return $stats;
}
if ($as_html) {
$stats .= "<h3>Templates used to render the page:</h3>";
$stats .= "<table id='templateusage' class='debug_resource_usage' title='List of used templates'>" . "<tr><th title='Usage count of this particular template'>Usage</th>" . "<th>Requested template</th>" . "<th>Template</th>" . "<th>Template loaded</th>" . "<th>Edit</th>" . "<th>Override</th></tr>";
} else {
$formatString = "%-40s%-40s%-40s\n";
$stats .= "Templates usage statistics\n";
$stats .= sprintf($formatString, 'Templates', 'Requested template', 'Template loaded');
}
if ($as_html) {
$iconSizeX = 16;
$iconSizeY = 16;
$templateViewFunction = 'visual/templateview';
eZURI::transformURI($templateViewFunction);
$templateEditFunction = 'visual/templateedit';
eZURI::transformURI($templateEditFunction);
$templateOverrideFunction = 'visual/templatecreate';
eZURI::transformURI($templateOverrideFunction);
$std_base = eZTemplateDesignResource::designSetting('standard');
$wwwDir = htmlspecialchars(eZSys::wwwDir(), ENT_COMPAT, 'UTF-8');
$editIconFile = "{$wwwDir}/design/{$std_base}/images/edit.gif";
$overrideIconFile = "{$wwwDir}/design/{$std_base}/images/override-template.gif";
$tdClass = 'used_templates_stats1';
$j = 0;
$currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
}
$templatesUsageStatistics = eZTemplate::templatesUsageStatistics();
$alreadyListedTemplate = $templateCounts = array();
//Generate usage count for each unique template first.
foreach ($templatesUsageStatistics as $templateInfo) {
$actualTemplateName = $templateInfo['actual-template-name'];
if (!array_key_exists($actualTemplateName, $templateCounts)) {
$templateCounts[$actualTemplateName] = 1;
} else {
++$templateCounts[$actualTemplateName];
}
}
//Then create the actual listing
foreach ($templatesUsageStatistics as $templateInfo) {
$actualTemplateName = $templateInfo['actual-template-name'];
$requestedTemplateName = $templateInfo['requested-template-name'];
$templateFileName = $templateInfo['template-filename'];
if (!in_array($actualTemplateName, $alreadyListedTemplate)) {
$alreadyListedTemplate[] = $actualTemplateName;
if ($as_html) {
$requestedTemplateViewURI = $templateViewFunction . '/' . $requestedTemplateName;
$actualTemplateViewURI = $templateViewFunction . '/' . $actualTemplateName;
$templateEditURI = $templateEditFunction . '/' . $templateFileName;
$templateOverrideURI = $templateOverrideFunction . '/' . $actualTemplateName;
$actualTemplateNameOutput = $actualTemplateName == $requestedTemplateName ? "<em><No override></em>" : $actualTemplateName;
$stats .= "<tr class='data'><td>{$templateCounts[$actualTemplateName]}</td>" . "<td><a href=\"{$requestedTemplateViewURI}\">{$requestedTemplateName}</a></td>" . "<td>{$actualTemplateNameOutput}</td>" . "<td>{$templateFileName}</td>" . "<td><a href=\"{$templateEditURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$editIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Edit template\" title=\"Edit template\" /></a></td>" . "<td><a href=\"{$templateOverrideURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$overrideIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Override template\" title=\"Override template\" /></a></td></tr>";
$j++;
} else {
$stats .= sprintf($formatString, $requestedTemplateName, $actualTemplateName, $templateFileName);
}
}
}
$totalTemplatesCount = count($templatesUsageStatistics);
$totalUniqueTemplatesCopunt = count(array_keys($alreadyListedTemplate));
if ($as_html) {
$stats .= "<tr><td colspan=\"6\"><b> Number of times templates used: {$totalTemplatesCount}<br /> Number of unique templates used: {$totalUniqueTemplatesCopunt}</b></td></tr>";
$stats .= "</table>";
} else {
$stats .= "\nTotal templates count: " . $totalTemplatesCount . "\n" . "Total unique templates count: " . $totalUniqueTemplatesCopunt . "\n";
}
return $stats;
}
示例13: packFiles
/**
* Merges a collection of files togheter and returns array of paths to the files.
* js /css content is returned as string if packlevel is 0 and you use a js/ css generator.
* $fileArray can also be array of array of files, like array( 'file.js', 'file2.js', array( 'file5.js' ) )
* The name of the cached file is a md5 hash consistant of the file paths
* of the valid files in $file_array and the packlevel.
* The whole argument is used instead of file path on js/ css generators in the cache hash.
*
* @param array|string $fileArray Either array of file paths, or string with file path
* @param string $subPath In witch sub path of design folder to look for files.
* @param string $fileExtension File extension name (for use on cache file)
* @param int $packLevel Level of packing, values: 0-3
* @param bool $indexDirInCacheHash To add index path in cache hash or not
* @param string $filePostName Extra file name part, example "_screen" in case of medai use for css
*
* @return array List of css files
*/
static function packFiles($fileArray, $subPath = '', $fileExtension = '.js', $packLevel = 2, $indexDirInCacheHash = false, $filePostName = '')
{
if (!$fileArray) {
return array();
} else {
if (!is_array($fileArray)) {
$fileArray = array($fileArray);
}
}
$ezjscINI = eZINI::instance('ezjscore.ini');
$bases = eZTemplateDesignResource::allDesignBases();
$customHosts = $ezjscINI->variable('Packer', 'CustomHosts');
$data = array('http' => array(), 'www' => array(), 'locale' => array(), 'cache_name' => '', 'cache_hash' => '', 'cache_path' => '', 'last_modified' => 0, 'file_extension' => $fileExtension, 'file_post_name' => $filePostName, 'pack_level' => $packLevel, 'sub_path' => $subPath, 'cache_dir' => self::getCacheDir(), 'www_dir' => htmlspecialchars(self::getWwwDir(), ENT_COMPAT, 'UTF-8'), 'index_dir' => self::getIndexDir(), 'custom_host' => isset($customHosts[$fileExtension]) ? $customHosts[$fileExtension] : '');
// Only pack files if Packer is enabled and if not set DevelopmentMode is disabled
if ($ezjscINI->hasVariable('eZJSCore', 'Packer')) {
$packerIniValue = $ezjscINI->variable('eZJSCore', 'Packer');
if ($packerIniValue === 'disabled') {
$data['pack_level'] = 0;
} else {
if (is_numeric($packerIniValue)) {
$data['pack_level'] = (int) $packerIniValue;
}
}
} else {
if (eZINI::instance()->variable('TemplateSettings', 'DevelopmentMode') === 'enabled') {
$data['pack_level'] = 0;
}
}
// Needed for image includes to work on ezp installs with mixed access methods (virtualhost + url based setup)
if ($indexDirInCacheHash) {
$data['cache_name'] = $data['index_dir'];
}
$originalFileArray = $fileArray;
while (!empty($fileArray)) {
$file = array_shift($fileArray);
// if $file is array, concat it to the file array and continue
if ($file && is_array($file)) {
$fileArray = array_merge($file, $fileArray);
continue;
} else {
if (!$file) {
continue;
} else {
if (strpos($file, '::') !== false) {
$server = self::serverCallHelper(explode('::', $file));
if (!$server instanceof ezjscServerRouter) {
continue;
}
$fileTime = $server->getCacheTime($data);
// Generate content straight away if packing is disabled
if ($data['pack_level'] === 0) {
$data['www'][] = $server->call($fileArray);
} else {
if ($fileTime === -1) {
$data['http'][] = $server->call($fileArray);
} else {
$data['locale'][] = $server;
$data['cache_name'] .= $file . '_';
}
}
$data['last_modified'] = max($data['last_modified'], $fileTime);
continue;
} else {
if (strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) {
$data['http'][] = $file;
continue;
} else {
if (strpos($file, '://') === 0) {
if (!isset($protocol)) {
$protocol = eZSys::serverProtocol();
}
$data['http'][] = $protocol . $file;
continue;
} else {
if (strpos($file, 'var/') === 0) {
if (substr($file, 0, 2) === '//' || preg_match("#^[a-zA-Z0-9]+:#", $file)) {
$file = '/';
} else {
if (strlen($file) > 0 && $file[0] !== '/') {
$file = '/' . $file;
}
}
eZURI::transformURI($file, true, 'relative');
//.........这里部分代码省略.........
示例14: packFiles
/**
* Merges a collection of files togheter and returns array of paths to the files.
* js /css content is returned as string if packlevel is 0 and you use a js/ css generator.
* $fileArray can also be array of array of files, like array( 'file.js', 'file2.js', array( 'file5.js' ) )
* The name of the cached file is a md5 hash consistant of the file paths
* of the valid files in $file_array and the packlevel.
* The whole argument is used instead of file path on js/ css generators in the cache hash.
*
* @param array|string $fileArray Either array of file paths, or string with file path
* @param string $subPath In witch sub path of design folder to look for files.
* @param string $fileExtension File extension name (for use on cache file)
* @param int $packLevel Level of packing, values: 0-3
* @param bool $wwwInCacheHash To add www path in cahce hash or not
* @return array List of css files
*/
static function packFiles($fileArray, $subPath = '', $fileExtension = '.js', $packLevel = 2, $wwwInCacheHash = false)
{
if (!$fileArray) {
return array();
} else {
if (!is_array($fileArray)) {
$fileArray = array($fileArray);
}
}
$cacheName = '';
$lastmodified = 0;
$httpFiles = array();
$validFiles = array();
$validWWWFiles = array();
$bases = eZTemplateDesignResource::allDesignBases();
// Only pack files if Packer is enabled and if not set DevelopmentMode is disabled
$ezjscINI = eZINI::instance('ezjscore.ini');
if ($ezjscINI->hasVariable('eZJSCore', 'Packer')) {
$packerIniValue = $ezjscINI->variable('eZJSCore', 'Packer');
if ($packerIniValue === 'disabled') {
$packLevel = 0;
} else {
if (is_numeric($packerIniValue)) {
$packLevel = (int) $packerIniValue;
}
}
} else {
$ini = eZINI::instance();
if ($ini->variable('TemplateSettings', 'DevelopmentMode') === 'enabled') {
$packLevel = 0;
}
}
$packerInfo = array('file_extension' => $fileExtension, 'pack_level' => $packLevel, 'sub_path' => $subPath, 'cache_dir' => self::getCacheDir(), 'www_dir' => self::getWwwDir());
// needed for image includes to work on ezp installs with mixed access methods (virtualhost + url based setup)
if ($wwwInCacheHash) {
$cacheName = $packerInfo['www_dir'];
}
while (count($fileArray) > 0) {
$file = array_shift($fileArray);
// if $file is array, concat it to the file array and continue
if ($file && is_array($file)) {
$fileArray = array_merge($file, $fileArray);
continue;
} else {
if (!$file) {
continue;
} else {
if (strpos($file, '::') !== false) {
$server = self::serverCallHelper(explode('::', $file));
$fileTime = $server->getCacheTime($packerInfo);
// generate content straight away if packing is disabled
if ($packLevel === 0) {
$validWWWFiles[] = $server->call($fileArray);
} else {
if ($fileTime === -1) {
$validFiles[] = $server->call($fileArray);
} else {
$validFiles[] = $server;
$cacheName .= $file . '_';
}
}
$lastmodified = max($lastmodified, $fileTime);
continue;
} else {
if (strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) {
$httpFiles[] = $file;
continue;
} else {
if (strpos($file, 'var/') === 0) {
if (substr($file, 0, 2) === '//' || preg_match("#^[a-zA-Z0-9]+:#", $file)) {
$file = '/';
} else {
if (strlen($file) > 0 && $file[0] !== '/') {
$file = '/' . $file;
}
}
eZURI::transformURI($file, true, 'relative');
// get file time and continue if it return false
$file = str_replace('//' . $packerInfo['www_dir'], '', '//' . $file);
$fileTime = file_exists($file) ? filemtime($file) : false;
$wwwFile = $packerInfo['www_dir'] . $file;
} else {
// allow path to be outside subpath if it starts with '/'
if ($file[0] === '/') {
$file = ltrim($file, '/');
//.........这里部分代码省略.........
示例15: filter
public static function filter($module, $node, $tpl, $viewMode)
{
//Make it compatable with patches before 5.2 and 5.2(no patch) because a patch reverse
//Ref.https://github.com/ezsystems/ezpublish-legacy/commit/85ab7fb8374f31c5cba00450e71d27e456552878
if (!$module instanceof eZModule) {
$viewMode = $tpl;
$tpl = $node;
$node = $module;
$module = null;
}
//End of compatability fix
$ini = eZINI::instance('override.ini');
$conditions = $ini->groups();
$nodeID = $node->attribute('node_id');
$object = $node->attribute('object');
$classIdentifier = $object->attribute('class_identifier');
$overrideClass = null;
foreach ($conditions as $condition) {
if (isset($condition['Match'])) {
$matches = $condition['Match'];
// node condition
$matchNode = null;
if (isset($matches['node'])) {
if ($matches['node'] == $nodeID) {
$matchNode = true;
} else {
$matchNode = false;
}
}
// class_identifier condition
$matchClass = null;
if (isset($matches['class_identifier'])) {
if ($matches['class_identifier'] == $classIdentifier) {
$matchClass = true;
} else {
$matchClass = false;
}
}
// view mode condition
$matchViewmode = null;
if (isset($matches['viewmode'])) {
if ($matches['viewmode'] == $viewMode) {
$matchViewmode = true;
} else {
$matchViewmode = false;
}
}
$useIt = false;
// When viewmode is not set or viewmode matches
if (!isset($matchViewmode) || $matchViewmode === true) {
// When class_identifier is not set or class_identifier matches
if (!isset($matchClass) || $matchClass === true) {
// When node(id) is not set or node(id) matches
if (!isset($matchNode) || $matchNode === true) {
if (isset($condition['Class'])) {
$overrideClass = $condition['Class'];
break;
}
}
}
}
}
}
//Support Match[attribute_<attribute_identifier>]=<value> in override.ini
$object = $node->attribute('object');
$dataMap = $object->dataMap();
$ini = eZINI::instance('xoverride.ini');
$siteAccessesMatch = false;
if (!$ini->hasVariable('TemplateOverride', 'AvailableSiteAccess')) {
$siteAccessesMatch = true;
} else {
$siteAccesses = $ini->variable('TemplateOverride', 'AvailableSiteAccess');
$currentSiteAccessArray = eZSiteAccess::current();
$currentSiteAccess = $currentSiteAccessArray['name'];
if (is_array($siteAccesses) && (in_array($currentSiteAccess, $siteAccesses) or in_array('*', $siteAccesses))) {
$siteAccessesMatch = true;
}
}
if ($siteAccessesMatch) {
$supportedDatatype = $ini->variable('General', 'SupportedDatatype');
$keys = array();
foreach ($dataMap as $attributeId => $attribute) {
$dataType = $attribute->attribute('data_type_string');
if (in_array($dataType, $supportedDatatype)) {
$value = $attribute->attribute('content');
$keys[] = array('attribute_' . $attributeId, $value);
}
}
$res = eZTemplateDesignResource::instance();
$res->setKeys($keys);
if (!empty($overrideClass)) {
$overrideView = new $overrideClass();
$http = eZHTTPTool::instance();
eZDebug::writeNotice("Loading nodeview render {$overrideClass}, node id: {$nodeID}", __METHOD__);
$overrideView->initNodeview($module, $node, $tpl, $viewMode);
}
}
}