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


PHP eZTemplateDesignResource::fileMatch方法代码示例

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


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

示例1: 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;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:22,代码来源:KLessFile.php

示例2: overrideArray

 /**
  * Get an array of all the current templates and overrides for them.
  * The current siteaccess is used if none is specified.
  *
  * @static
  * @return array
  */
 static function overrideArray($siteAccess = false)
 {
     if ($siteAccess === false and self::$overrideArrayCache !== null) {
         return self::$overrideArrayCache;
     }
     $bases = eZTemplateDesignResource::allDesignBases($siteAccess);
     // fetch the override array from a specific siteacces
     if ($siteAccess) {
         $overrideINI = eZSiteAccess::getIni($siteAccess, 'override.ini');
     } else {
         $overrideINI = eZINI::instance('override.ini');
     }
     $designStartPath = eZTemplateDesignResource::designStartPath();
     // Generate match cache for all templates
     // Build arrays of available files, start with standard design and end with most prefered design
     $matchFileArray = array();
     $reverseBases = array_reverse($bases);
     foreach ($reverseBases as $base) {
         $templateResource = $base . '/templates';
         $sourceFileArray = eZDir::recursiveFindRelative($templateResource, "", "tpl");
         foreach ($sourceFileArray as $source) {
             $matchFileArray[$source]['base_dir'] = $templateResource;
             $matchFileArray[$source]['template'] = $source;
         }
     }
     // Load override templates
     $overrideSettingGroups = $overrideINI->groups();
     if (isset($GLOBALS['eZDesignOverrides'])) {
         $overrideSettingGroups = array_merge($overrideSettingGroups, $GLOBALS['eZDesignOverrides']);
     }
     foreach ($overrideSettingGroups as $overrideName => $overrideSetting) {
         if (!isset($overrideSetting['Source'])) {
             continue;
         }
         $overrideSource = "/" . $overrideSetting['Source'];
         $overrideMatchFile = $overrideSetting['MatchFile'];
         // Find the matching file in the available resources
         $triedFiles = array();
         $fileInfo = eZTemplateDesignResource::fileMatch($bases, 'override/templates', $overrideMatchFile, $triedFiles);
         $resourceInUse = is_array($fileInfo) ? $fileInfo['resource'] : false;
         $overrideMatchFilePath = is_array($fileInfo) ? $fileInfo['path'] : false;
         // if the override template is not found
         // then we probably shouldn't use it
         // there should be added a check around the following code
         // if ( $overrideMatchFilePath )
         // {
         $customMatchArray = array();
         $customMatchArray['conditions'] = isset($overrideSetting['Match']) ? $overrideSetting['Match'] : null;
         $customMatchArray['match_file'] = $overrideMatchFilePath;
         $customMatchArray['override_name'] = $overrideName;
         $matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray;
         // }
         // if overriding a non-existing template
         // then we use the override template as main template
         // this code should probably be removed
         // because we should not allow an override if the main template is missing
         if ($resourceInUse && !isset($matchFileArray[$overrideSource]['base_dir'])) {
             $matchFileArray[$overrideSource]['base_dir'] = $resourceInUse;
             $matchFileArray[$overrideSource]['template'] = $overrideSource;
         }
         if (!$overrideMatchFilePath) {
             eZDebug::writeError("Custom match file: path '{$overrideMatchFile}' not found in any resource. Check the template settings in settings/override.ini", __METHOD__);
             eZDebug::writeError(implode(', ', $triedFiles), __METHOD__ . ' tried files');
         }
     }
     if ($siteAccess === false) {
         self::$overrideArrayCache = $matchFileArray;
     }
     return $matchFileArray;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:77,代码来源:eztemplatedesignresource.php

示例3: getDesignFile

    public static function getDesignFile( $file, $triedFiles = array() )
    {
        if ( self::$designBases === null )
        {
            self::$designBases = eZTemplateDesignResource::allDesignBases();
        }

        $match = eZTemplateDesignResource::fileMatch( self::$designBases, '', $file, $triedFiles );

        if ( $match === false )
        {
            eZDebug::writeWarning( "Could not find: $file", __METHOD__ );
            return $file;
        }
        return htmlspecialchars( self::getServerURL() . '/' . $match['path'] );
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:16,代码来源:ezoexmlinput.php

示例4: eZImage

 static function eZImage($tpl, $operatorValue, $operatorName, $skipSlash = false)
 {
     $sys = eZSys::instance();
     if ($skipSlash && strlen($sys->wwwDir()) != 0) {
         $skipSlash = false;
     }
     $bases = eZTemplateDesignResource::allDesignBases();
     $triedFiles = array();
     $fileInfo = eZTemplateDesignResource::fileMatch($bases, 'images', $operatorValue, $triedFiles);
     if (!$fileInfo) {
         $tpl->warning($operatorName, "Image '{$operatorValue}' does not exist in any design");
         $tpl->warning($operatorName, "Tried files: " . implode(', ', $triedFiles));
         $siteDesign = eZTemplateDesignResource::designSetting('site');
         $imgPath = "design/{$siteDesign}/images/{$operatorValue}";
     } else {
         $imgPath = $fileInfo['path'];
     }
     $operatorValue = $skipSlash ? $imgPath : $sys->wwwDir() . '/' . $imgPath;
     $operatorValue = htmlspecialchars($operatorValue);
     return $operatorValue;
 }
开发者ID:stevoland,项目名称:ez_patch,代码行数:21,代码来源:ezurloperator.php

示例5: getDesignFile

 /**
  * Internal function to get current index dir
  *
  * @return string
  */
 protected static function getDesignFile($file)
 {
     static $bases = null;
     static $wwwDir = null;
     if ($bases === null) {
         $bases = eZTemplateDesignResource::allDesignBases();
     }
     if ($wwwDir === null) {
         $wwwDir = eZSys::wwwDir() . '/';
     }
     $triedFiles = array();
     $match = eZTemplateDesignResource::fileMatch($bases, '', $file, $triedFiles);
     if ($match === false) {
         eZDebug::writeWarning("Could not find: {$file}", __METHOD__);
         return false;
     }
     return $wwwDir . htmlspecialchars($match['path']);
 }
开发者ID:legende91,项目名称:ez,代码行数:23,代码来源:ezjscserverfunctionsjs.php

示例6: packFiles


//.........这里部分代码省略.........
                 } 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');
                                 // Get file time and continue if it return false
                                 $file = str_replace('//' . $data['www_dir'], '', '//' . $file);
                                 $fileTime = file_exists($file) ? filemtime($file) : false;
                                 $wwwFile = $data['www_dir'] . $file;
                             } else {
                                 // Allow path to be outside subpath if it starts with '/'
                                 if ($file[0] === '/') {
                                     $file = ltrim($file, '/');
                                 } else {
                                     $file = $subPath . $file;
                                 }
                                 $triedFiles = array();
                                 $match = eZTemplateDesignResource::fileMatch($bases, '', $file, $triedFiles);
                                 if ($match === false) {
                                     eZDebug::writeWarning("Could not find: {$file}", __METHOD__);
                                     continue;
                                 }
                                 $file = htmlspecialchars($match['path']);
                                 $fileTime = file_exists($file) ? filemtime($file) : false;
                                 $wwwFile = $data['www_dir'] . $file;
                             }
                         }
                     }
                 }
             }
         }
         if ($fileTime === false) {
             eZDebug::writeWarning("Could not get modified time of file: {$file}", __METHOD__);
             continue;
         }
         // Calculate last modified time and store in arrays
         $data['last_modified'] = max($data['last_modified'], $fileTime);
         $data['locale'][] = $file;
         $data['www'][] = $wwwFile;
         $data['cache_name'] .= $file . '_';
     }
     if ($data['pack_level'] === 0) {
         self::$log[] = $data;
         // if packing is disabled, return the valid paths / content we have generated
         return array_merge($data['http'], $data['www']);
     } else {
         if (empty($data['locale']) && !empty($data['http'])) {
             self::$log[] = $data;
             // return if there are only external scripts and no local files to cache
             return array_merge($data['http'], $data['www']);
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:67,代码来源:ezjscpacker.php

示例7: packFiles


//.........这里部分代码省略.........
                         } 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, '/');
                             } else {
                                 $file = $subPath . $file;
                             }
                             $triedFiles = array();
                             $match = eZTemplateDesignResource::fileMatch($bases, '', $file, $triedFiles);
                             if ($match === false) {
                                 eZDebug::writeWarning("Could not find: {$file}", __METHOD__);
                                 continue;
                             }
                             $file = htmlspecialchars($match['path']);
                             $fileTime = file_exists($file) ? filemtime($file) : false;
                             $wwwFile = $packerInfo['www_dir'] . $file;
                         }
                     }
                 }
             }
         }
         if ($fileTime === false) {
             eZDebug::writeWarning("Could not get modified time of file: {$file}", __METHOD__);
             continue;
         }
         // calculate last modified time and store in arrays
         $lastmodified = max($lastmodified, $fileTime);
         $validFiles[] = $file;
         $validWWWFiles[] = $wwwFile;
         // STEVO
         $cacheName .= $file . '_' . $fileTime . '_';
     }
     // if packing is disabled, return the valid paths / content we have generated
     if ($packLevel === 0) {
         return array_merge($httpFiles, $validWWWFiles);
     }
     if (!$validFiles) {
         eZDebug::writeWarning("Could not find any files: " . var_export($fileArray, true), __METHOD__);
         return array();
     }
     // generate cache file name and path
开发者ID:stevoland,项目名称:ez_patch,代码行数:67,代码来源:ezjscpacker.php

示例8: generateTag

 /**
  * generateTag
  * @param array $files
  * @return string $html
  */
 private function generateTag($files)
 {
     eZDebug::writeDebug($files, 'ezLessOperator::generateTag');
     $html = $cssContent = '';
     $ini = eZINI::instance('ezless.ini');
     $compileMethod = trim($ini->variable('ezlessconfig', 'CompileMethod'));
     $useOneFile = $ini->variable('ezlessconfig', 'useOneFile');
     // ToDo: siteaccess as parameter
     $bases = eZTemplateDesignResource::allDesignBases();
     $triedFiles = array();
     $importsTried = array();
     if ($compileMethod === 'javascript') {
         foreach ($files as $file) {
             $match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $file, $triedFiles);
             if ($match) {
                 $path = "/{$match['path']}";
                 $html .= "<link rel=\"stylesheet/less\" type=\"text/css\" href=\"{$path}\">" . PHP_EOL;
             }
         }
         $lessJSFilename = $ini->variable('ezlessconfig', 'LessJSFile');
         $lookForLessJS = eZTemplateDesignResource::fileMatch($bases, '', 'javascript/' . $lessJSFilename, $triedFiles);
         if (!$lookForLessJS) {
             eZDebug::writeDebug("Using LessJS mode but unable to find less.js (LessJSFile={$lessJSFilename}).\nTried files : " . implode("\n", $triedFiles), __CLASS__ . "::" . __FUNCTION__);
         } else {
             $path = "/{$lookForLessJS['path']}";
             $html .= "<script src=\"{$path}\" type=\"text/javascript\" ></script>" . PHP_EOL;
         }
         return $html;
     } elseif ($compileMethod === 'lessphp') {
         $sys = eZSys::instance();
         $path = $sys->cacheDirectory() . '/public/stylesheets';
         require_once dirname(__FILE__) . '/../lib/lessphp/lessc.inc.php';
         $packerLevel = $this->getPackerLevel();
         $less = new lessc();
         foreach ($bases as $base) {
             $less->importDir[] = $base . DIRECTORY_SEPARATOR . 'stylesheets';
         }
         $importContent = "";
         $importCss = "";
         if (count(self::$imports) > 0) {
             foreach (self::$imports as $import) {
                 $match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $import, $importsTried);
                 $importCss = file_get_contents($match['path']);
                 $importContent .= $importCss;
             }
         }
         foreach ($files as $file) {
             $match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $file, $triedFiles);
             $content = file_get_contents($match['path']);
             $content = ezjscPacker::fixImgPaths($content, $match['path']);
             if ($useOneFile == "true") {
                 $cssContent .= $content;
             } else {
                 try {
                     $parsedContent = $less->parse($importContent . $content);
                     if ($packerLevel > 1) {
                         $parsedContent = $this->optimizeCSS($parsedContent, $packerLevel);
                     }
                     // $file = md5(uniqid(mt_rand(), true)) . ".css";
                     $file = substr($file, 0, -4) . 'css';
                     // we wan't to know what's the name of the less file on the browser
                     $file = $path . '/' . $file;
                     $clusterFile = eZClusterFileHandler::instance($file);
                     $clusterFile->storeContents($parsedContent, 'ezless', 'text/css');
                     eZURI::transformURI($file, true);
                     $html .= '<link rel="stylesheet" type="text/css" href="' . $file . '" />' . PHP_EOL;
                 } catch (Exception $e) {
                     eZDebug::writeError($e->getMessage(), 'ezLessOperator for ' . $match['path']);
                 }
             }
         }
         if ($useOneFile == "true") {
             $file = md5(uniqid(mt_rand(), true)) . ".css";
             try {
                 $parsedContent = $less->parse($cssContent);
                 if ($packerLevel > 1) {
                     $parsedContent = $this->optimizeCSS($parsedContent, $packerLevel);
                 }
                 $file = $path . '/' . $file;
                 $clusterFile = eZClusterFileHandler::instance($file);
                 $clusterFile->storeContents($parsedContent, 'ezless', 'text/css');
                 eZURI::transformURI($file, true);
                 $html = '<link rel="stylesheet" type="text/css" href="' . $file . '" />' . PHP_EOL;
             } catch (Exception $e) {
                 eZDebug::writeError($e->getMessage(), 'ezLessOperator parsing error');
             }
         }
         return $html;
     } else {
         eZDebug::writeError("Unknown compile method : '{$compileMethod}'", __CLASS__ . "::" . __FUNCTION__);
     }
 }
开发者ID:heliopsis,项目名称:ezless,代码行数:97,代码来源:ezless.php

示例9: eZImage

    static function eZImage( $tpl, $operatorValue, $operatorName, $skipSlash = false )
    {
        $sys = eZSys::instance();
        if ( $skipSlash && strlen( $sys->wwwDir() ) != 0 )
        {
            $skipSlash = false;
        }

        $bases = eZTemplateDesignResource::allDesignBases();
        $triedFiles = array();
        $fileInfo = eZTemplateDesignResource::fileMatch( $bases, 'images', $operatorValue, $triedFiles );

        if ( !$fileInfo )
        {
            $tpl->warning( $operatorName, "Image '$operatorValue' does not exist in any design" );
            $tpl->warning( $operatorName, "Tried files: " . implode( ', ', $triedFiles ) );
            $siteDesign = eZTemplateDesignResource::designSetting( 'site' );
            $imgPath = "design/$siteDesign/images/$operatorValue";
        }
        else
        {
            $imgPath = $fileInfo['path'];
        }

        $ini = eZINI::instance();
        if ( $ini->variable( 'DesignSettings', 'DynamicImageSuffix' ) == 'enabled' )
        {
            $imgHash = sha1_file( $imgPath );
            $imgDecHash = hexdec( substr( $imgHash, 0, 7 ) );
            $imgPath =  preg_replace( '/^(.*)\.([^.]+)$/i', '$1.'.$imgDecHash.'.$2', $imgPath );
        }

        $operatorValue = $skipSlash ? $imgPath : $sys->wwwDir() . '/' . $imgPath;
        $operatorValue = htmlspecialchars( $operatorValue );
        if ( ! $skipSlash )
        {
            $serverURL = eZURI::serverShardingURL( $operatorValue );
            $operatorValue = $serverURL.$operatorValue;
        }

        return $operatorValue;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:42,代码来源:ezurloperator.php


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