当前位置: 首页>>代码示例>>PHP>>正文


PHP eZTemplateDesignResource::overrideArray方法代码示例

本文整理汇总了PHP中eZTemplateDesignResource::overrideArray方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateDesignResource::overrideArray方法的具体用法?PHP eZTemplateDesignResource::overrideArray怎么用?PHP eZTemplateDesignResource::overrideArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZTemplateDesignResource的用法示例。


在下文中一共展示了eZTemplateDesignResource::overrideArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:24,代码来源:ezclassfunctioncollection.php

示例2: createOverrideCache

 function createOverrideCache()
 {
     if (isset($GLOBALS['eZSiteBasics'])) {
         if (isset($GLOBALS['eZSiteBasics']['no-cache-adviced']) and $GLOBALS['eZSiteBasics']['no-cache-adviced']) {
             return false;
         }
     }
     global $eZTemplateOverrideCacheNoPermission;
     if ($eZTemplateOverrideCacheNoPermission == "nocache") {
         return false;
     }
     $ini = eZINI::instance('site.ini');
     $useOverrideCache = true;
     if ($ini->hasVariable('OverrideSettings', 'Cache')) {
         $useOverrideCache = $ini->variable('OverrideSettings', 'Cache') == 'enabled';
     }
     $standardBase = eZTemplateDesignResource::designSetting('standard');
     $siteBase = eZTemplateDesignResource::designSetting('site');
     $overrideKeys = $this->overrideKeys();
     $overrideKey = md5(implode(',', $overrideKeys) . $siteBase . $standardBase);
     $cacheDir = eZSys::cacheDirectory();
     $overrideCacheFile = $cacheDir . '/override/override_' . $overrideKey . '.php';
     // Build matching cache only of it does not already exists,
     // or override file has been updated
     if (!$useOverrideCache or !file_exists($overrideCacheFile)) {
         $matchFileArray = eZTemplateDesignResource::overrideArray($this->OverrideSiteAccess);
         // Generate PHP compiled cache file.
         $phpCache = new eZPHPCreator("{$cacheDir}/override", "override_{$overrideKey}.php");
         $phpCode = "\$GLOBALS['eZOverrideTemplateCacheMap'] = array (\n";
         $numMatchFiles = count($matchFileArray);
         $countMatchFiles = 0;
         //            $phpCode .= "switch ( \$matchFile )\n{\n    ";
         foreach (array_keys($matchFileArray) as $matchKey) {
             $countMatchFiles++;
             $phpCode .= '\'' . md5($matchKey) . '\' => ';
             if (isset($matchFileArray[$matchKey]['custom_match'])) {
                 $baseDir = isset($matchFileArray[$matchKey]['base_dir']) ? $matchFileArray[$matchKey]['base_dir'] : '';
                 $defaultMatchFile = $baseDir . $matchKey;
                 // Custom override matching
                 //                    $phpCode .= "    case  \"$matchKey\":\n    {\n";
                 $matchConditionArray = array();
                 foreach ($matchFileArray[$matchKey]['custom_match'] as $customMatch) {
                     $matchCondition = "";
                     $condCount = 0;
                     if (is_array($customMatch['conditions'])) {
                         foreach (array_keys($customMatch['conditions']) as $conditionKey) {
                             if ($condCount > 0) {
                                 $matchCondition .= " and ";
                             }
                             // Have a special substring match for subtree matching
                             $matchCondition .= "( isset( \$matchKeys[\\'{$conditionKey}\\'] ) and ";
                             if ($conditionKey == 'url_alias') {
                                 $matchCondition .= "( strpos( \$matchKeys[\\'url_alias\\'],  \\'" . $customMatch['conditions']['url_alias'] . "\\' ) === 0 ) )";
                             } else {
                                 $matchCondition .= "( is_array( \$matchKeys[\\'{$conditionKey}\\'] ) ? " . "in_array( \\'" . $customMatch['conditions'][$conditionKey] . "\\', \$matchKeys[\\'{$conditionKey}\\'] ) : " . "\$matchKeys[\\'{$conditionKey}\\'] == \\'" . $customMatch['conditions'][$conditionKey] . "\\') )";
                             }
                             $condCount++;
                         }
                     }
                     // Only create custom match if conditions are defined
                     if ($matchCondition != "") {
                         //                            $phpCode .= "        if ( $matchCondition )\n        {\n";
                         //                            $phpCode .= "            return '" . $customMatch['match_file'] . "';\n        }\n";
                         if ($condCount > 1) {
                             $matchConditionArray[] = array('condition' => '(' . $matchCondition . ')', 'matchFile' => $customMatch['match_file']);
                         } else {
                             $matchConditionArray[] = array('condition' => $matchCondition, 'matchFile' => $customMatch['match_file']);
                         }
                     } else {
                         // No override conditions defined. Override default match file
                         $defaultMatchFile = $customMatch['match_file'];
                     }
                 }
                 $phpCode .= "array ( 'eval' => 1, 'code' => ";
                 $phpCode .= "'";
                 foreach (array_keys($matchConditionArray) as $key) {
                     $phpCode .= '(' . $matchConditionArray[$key]['condition'] . ' ? ' . "\\'" . $matchConditionArray[$key]['matchFile'] . "\\'" . ' : ';
                 }
                 $phpCode .= "\\'" . $defaultMatchFile . "\\'";
                 for ($condCount = 0; $condCount < count($matchConditionArray); $condCount++) {
                     $phpCode .= ')';
                 }
                 $phpCode .= "' )";
             } else {
                 $phpCode .= "'" . $matchFileArray[$matchKey]['base_dir'] . $matchKey . "'";
             }
             if ($countMatchFiles < $numMatchFiles) {
                 $phpCode .= ",\n";
             } else {
                 $phpCode .= ");\n";
             }
         }
         $phpCache->addCodePiece($phpCode);
         if ($useOverrideCache and $phpCache->store()) {
         } else {
             if ($useOverrideCache) {
                 eZDebug::writeError("Could not write template override cache file, check permissions in {$cacheDir}/override/.\nRunning eZ Publish without this cache will have a performance impact.", __METHOD__);
             }
             $eZTemplateOverrideCacheNoPermission = 'nocache';
             $overrideCacheFile = false;
//.........这里部分代码省略.........
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:101,代码来源:eztemplatedesignresource.php

示例3: templateNodeTransformation

    function templateNodeTransformation( $functionName, &$node,
                                         $tpl, $parameters, $privateData )
    {
        if ( !isset( $this->Rules[$functionName] ) )
            return false;
        $rule = $this->Rules[$functionName];
        $resourceData = $privateData['resource-data'];

        $parameters = eZTemplateNodeTool::extractFunctionNodeParameters( $node );
        $inputName = $rule['input_name'];
        if ( !isset( $parameters[$inputName] ) )
        {
            return false;
        }
        $inputData = $parameters[$inputName];
        $outputName = $rule['output_name'];

        $newNodes = array();

        $viewDir = '';
        $renderMode = false;
        if ( isset( $rule["render_mode"] ) )
        {
            $renderMode = $rule["render_mode"];
        }
        if ( isset( $parameters['render-mode'] ) )
        {
            $renderData = $parameters['render-mode'];
            if ( !eZTemplateNodeTool::isConstantElement( $renderData ) )
            {
                return false;
            }
            $renderMode = eZTemplateNodeTool::elementConstantValue( $renderData );
        }
        if ( $renderMode )
            $view_dir .= "/render-$renderMode";

        $viewValue = false;
        $viewName = false;
        if ( $rule['use_views'] )
        {
            $viewName = $rule['use_views'];
            if ( isset( $parameters[$viewName] ) )
            {
                $viewData = $parameters[$viewName];
                if ( !eZTemplateNodeTool::isConstantElement( $viewData ) )
                {
                    return false;
                }
                $viewValue = eZTemplateNodeTool::elementConstantValue( $viewData );
                $viewDir .= '/' . $viewValue;
            }
            else
            {
                if ( !( isset( $rule['optional_views'] ) && $rule['optional_views'] ) )
                {
                    return false;
                }
            }
        }

        $namespaceValue = false;
        if ( isset( $rule['namespace'] ) )
        {
            $namespaceValue = $rule['namespace'];
        }

        $variableList = array();

        $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $inputData, false, array(),
                                                              array( $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $outputName ) );
        $variableList[] = $outputName;

        foreach ( array_keys( $parameters ) as $parameterName )
        {
            if ( $parameterName == $inputName or
                 $parameterName == $outputName or
                 $parameterName == $viewName )
                continue;

            $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameters[$parameterName], false, array(),
                                                                  array( $namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName ) );
            $variableList[] = $parameterName;
        }

        $templateRoot = $rule["template_root"];
        $matchFileArray = eZTemplateDesignResource::overrideArray();

        if ( is_string( $templateRoot ) )
        {
            $resourceNodes = $this->resourceAcquisitionTransformation( $functionName, $node, $rule, $inputData,
                                                                       $outputName, $namespaceValue,
                                                                       $templateRoot, $viewDir, $viewValue,
                                                                       $matchFileArray, 0, $resourceData );
            // If the transformation failed we return false to invoke interpreted mode
            if ( $resourceNodes === false )
                return false;
            $newNodes = array_merge( $newNodes, $resourceNodes );
        }
        else
//.........这里部分代码省略.........
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:101,代码来源:ezobjectforwarder.php

示例4: DOMDocument

    function &generateTemplateFilenameArray()
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );

        $templateListDOMNode = $dom->createElement( 'template-list' );
        $dom->appendChild( $templateListDOMNode );

        foreach( array_keys( $this->OverrideSettingsArray ) as $siteAccess )
        {
            $this->TemplateFileArray[$siteAccess] = array();
            $overrideArray = eZTemplateDesignResource::overrideArray( $siteAccess );

            foreach( $this->OverrideSettingsArray[$siteAccess] as $override )
            {
                $customMatchArray = $overrideArray['/' . $override['Source']]['custom_match'];

                foreach( $customMatchArray as $customMatch )
                {
                    if ( $customMatch['conditions'] == null )
                    {
                        //$templateListDOMNode->appendChild( $this->createDOMNodeFromFile( $customMatch['match_file'], $siteAccess, 'design' ) );
                        //$this->TemplateFileArray[$siteAccess][] = $customMatch['match_file'];
                    }
                    else if ( count( array_diff( $customMatch['conditions'], $override['Match'] ) ) == 0 &&
                              count( array_diff( $override['Match'], $customMatch['conditions'] ) ) == 0 )
                    {
                        unset( $node );
                        $node = $this->createDOMNodeFromFile( $customMatch['match_file'], $siteAccess, 'design' );
                        $importedNode = $dom->importNode( $node, true );
                        $templateListDOMNode->appendChild( $importedNode );
                        $this->TemplateFileArray[$siteAccess][] = $customMatch['match_file'];
                    }
                }
            }
        }
        return $templateListDOMNode;

        //TODO : add templates included in templates here.
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:39,代码来源:ezcontentobjectpackagehandler.php

示例5: 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 )
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:31,代码来源:templateedit.php

示例6: generateDefaultTemplate

function generateDefaultTemplate( $http, $template, $fileName )
{
    $templateCode = "";
    // Check what kind of contents we should create in the template
    switch ( $http->postVariable( 'TemplateContent' ) )
    {
        case 'DefaultCopy' :
        {
            $siteAccess = $http->sessionVariable( 'eZTemplateAdminCurrentSiteAccess' );
            $overrideArray = eZTemplateDesignResource::overrideArray( $siteAccess );
            $fileName = $overrideArray[$template]['base_dir'] . $overrideArray[$template]['template'];
            $fp = fopen( $fileName, 'rb' );
            if ( $fp )
            {
                $codeFromFile = fread( $fp, filesize( $fileName ) );

                // Remove the "{* DO NOT EDIT... *}" first line (if exists).
                $templateCode = preg_replace('@^{\*\s*DO\sNOT\sEDIT.*?\*}\n(.*)@s', '$1', $codeFromFile);
            }
            else
            {
                eZDebug::writeError( "Could not open file $fileName, check read permissions" );
            }
            fclose( $fp );
        }break;

        default:
        case 'EmptyFile' :
        {
            $templateCode = '{*?template charset=latin1?*}' .
                 '<!DOCTYPE html>' . "\n" .
                 '<html lang="en">' .
                 '<head>' . "\n" .
                 '    <link rel="stylesheet" type="text/css" href={"stylesheets/core.css"|ezdesign} />' . "\n" .
                 '    <link rel="stylesheet" type="text/css" href={"stylesheets/debug.css"|ezdesign} />' . "\n" .
                 '    {include uri="design:page_head.tpl"}' . "\n" .
                 '</head>' . "\n" .
                 '<body>' . "\n" .
                 '{$module_result.content}' . "\n" .
                 '<!--DEBUG_REPORT-->' . "\n" .
                 '</body>' . "\n" .
                 '</html>' . "\n";
        }break;
    }
    return $templateCode;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:46,代码来源:templatecreate.php


注:本文中的eZTemplateDesignResource::overrideArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。