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


PHP E::ModuleViewerAsset方法代码示例

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


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

示例1: smarty_function_asset

/**
 * Plugin for Smarty
 * Returns URL for skin asset file
 *
 * @param   array $aParams
 * @param   Smarty_Internal_Template $oSmartyTemplate
 *
 * @return  string
 */
function smarty_function_asset($aParams, $oSmartyTemplate)
{
    if (empty($aParams['skin']) && empty($aParams['file'])) {
        trigger_error('Asset: missing "file" parameter', E_USER_WARNING);
        return '';
    }
    if (isset($aParams['file'])) {
        if (stripos($aParams['file'], 'http://') === 0 || stripos($aParams['file'], 'https://') === 0 || stripos($aParams['file'], 'http://') === 0) {
            $sUrl = $aParams['file'];
        } else {
            $sSkin = !empty($aParams['skin']) ? $aParams['skin'] : E::ModuleViewer()->GetConfigSkin();
            // File name has full local path
            if (F::File_LocalDir($aParams['file'])) {
                $sFile = $aParams['file'];
            } else {
                // Need URL to asset file
                if (isset($aParams['theme'])) {
                    if (is_bool($aParams['theme'])) {
                        $sTheme = E::ModuleViewer()->GetConfigTheme();
                    } else {
                        $sTheme = $aParams['theme'];
                    }
                } else {
                    $sTheme = '';
                }
                if ($sTheme) {
                    $sTheme = 'themes/' . $sTheme . '/';
                }
                if (isset($aParams['plugin'])) {
                    $sFile = Plugin::GetTemplateFile($aParams['plugin'], $aParams['file']);
                } else {
                    $sFile = Config::Get('path.skins.dir') . '/' . $sSkin . '/' . $sTheme . $aParams['file'];
                }
            }
            if (isset($aParams['prepare'])) {
                $sAssetName = empty($aParams['asset']) ? $sFile : $aParams['asset'];
                // Грязноватый хак, но иначе нам не получить ссылку
                $aFileData = array($sFile => array('name' => md5($sFile), 'prepare' => true));
                /** @var ModuleViewerAsset $oLocalViewerAsset */
                $oLocalViewerAsset = new ModuleViewerAsset();
                $oLocalViewerAsset->AddFiles(F::File_GetExtension($sFile, true), $aFileData, $sAssetName);
                $oLocalViewerAsset->Prepare();
                //$sUrl = $oLocalViewerAsset->AssetFileUrl(F::File_NormPath($sFile));
                $aLinks = $oLocalViewerAsset->GetPreparedAssetLinks();
                $sUrl = reset($aLinks);
            } else {
                $sUrl = E::ModuleViewerAsset()->File2Link($sFile, 'skin/' . $sSkin . '/');
            }
        }
    } else {
        // Need URL to asset dir
        $sUrl = E::ModuleViewer()->GetAssetUrl() . 'skin/' . $aParams['skin'] . '/';
    }
    return $sUrl;
}
开发者ID:anp135,项目名称:altocms,代码行数:64,代码来源:function.asset.php

示例2: smarty_function_asset

/**
 * Plugin for Smarty
 * Returns URL for skin asset file
 *
 * @param   array $aParams
 * @param   Smarty_Internal_Template $oSmartyTemplate
 *
 * @return  string
 */
function smarty_function_asset($aParams, $oSmartyTemplate)
{
    if (empty($aParams['skin']) && empty($aParams['file'])) {
        trigger_error('Asset: missing "file" parametr', E_USER_WARNING);
        return '';
    }
    if (isset($aParams['file'])) {
        if (stripos($aParams['file'], 'http://') === 0 || stripos($aParams['file'], 'https://') === 0 || stripos($aParams['file'], 'http://') === 0) {
            $sUrl = $aParams['file'];
        } else {
            if (F::File_LocalDir($aParams['file'])) {
                $sFile = $aParams['file'];
            } else {
                // Need URL to asset file
                if (empty($aParams['skin'])) {
                    $sSkin = E::ModuleViewer()->GetConfigSkin();
                } else {
                    $sSkin = $aParams['skin'];
                }
                if (isset($aParams['theme'])) {
                    if (is_bool($aParams['theme'])) {
                        $sTheme = E::ModuleViewer()->GetConfigTheme();
                    } else {
                        $sTheme = $aParams['theme'];
                    }
                } else {
                    $sTheme = '';
                }
                if ($sTheme) {
                    $sTheme = 'themes/' . $sTheme . '/';
                }
                if (isset($aParams['plugin'])) {
                    $sFile = Plugin::GetTemplateFile($aParams['plugin'], $aParams['file']);
                } else {
                    $sFile = Config::Get('path.skins.dir') . '/' . $sSkin . '/' . $sTheme . $aParams['file'];
                }
            }
            if (isset($aParams['prepare'])) {
                /** @var ModuleViewerAsset $oLocalViewerAsset */
                $oLocalViewerAsset = new ModuleViewerAsset();
                $oLocalViewerAsset->AddFiles(F::File_GetExtension($sFile, true), array($sFile));
                $oLocalViewerAsset->Prepare();
                $sUrl = $oLocalViewerAsset->AssetFileUrl(F::File_NormPath($sFile));
            } else {
                $sUrl = E::ModuleViewerAsset()->File2Link($sFile, 'skin/' . $sSkin . '/');
            }
        }
    } else {
        // Need URL to asset dir
        $sUrl = E::ModuleViewer()->GetAssetUrl() . 'skin/' . $aParams['skin'] . '/';
    }
    return $sUrl;
}
开发者ID:AntiqS,项目名称:altocms,代码行数:62,代码来源:function.asset.php

示例3: CompileFile

 /**
  * Компилирует файл less и возвращает текст css-файла
  *
  * @param $aFile
  * @param $sCacheDir
  * @param $sMapPath
  * @param $aParams
  * @param $bCompress
  * @return string
  */
 public function CompileFile($aFile, $sCacheDir, $sMapPath, $aParams, $bCompress)
 {
     if (!($sMapPath && $sCacheDir && $aFile)) {
         return '';
     }
     try {
         $options = array('sourceMap' => TRUE, 'sourceMapWriteTo' => $sMapPath, 'sourceMapURL' => E::ModuleViewerAsset()->AssetFileUrl($sMapPath), 'cache_dir' => $sCacheDir);
         if ($bCompress) {
             $options = array_merge($options, array('compress' => TRUE));
         }
         $sCssFileName = Less_Cache::Get($aFile, $options, $aParams);
         return file_get_contents($sCacheDir . $sCssFileName);
     } catch (Exception $e) {
         E::ModuleMessage()->AddErrorSingle($e->getMessage());
     }
     return '';
 }
开发者ID:AntiqS,项目名称:altocms,代码行数:27,代码来源:Less.class.php

示例4: ClearAssetsFiles

 public function ClearAssetsFiles()
 {
     $sDir = F::File_GetAssetDir();
     F::File_RemoveDir($sDir);
     E::ModuleViewerAsset()->ClearAssetsCache();
 }
开发者ID:anp135,项目名称:altocms,代码行数:6,代码来源:Viewer.class.php

示例5: _convertUrlsInCss

 protected function _convertUrlsInCss($sContent, $sSourceDir)
 {
     // Есть ли в файле URLs
     if (!preg_match_all('/(?P<src>src:)?url\\((?P<url>.*?)\\)/is', $sContent, $aMatchedUrl, PREG_OFFSET_CAPTURE)) {
         return $sContent;
     }
     // * Обрабатываем список URLs
     $aUrls = array();
     foreach ($aMatchedUrl['url'] as $nIdx => $aPart) {
         $sPath = $aPart[0];
         //$nPos = $aPart[1];
         // * Don't touch data URIs
         if (strstr($sPath, 'data:')) {
             continue;
         }
         $sPath = str_replace(array('\'', '"'), '', $sPath);
         // * Если путь является абсолютным, то не обрабатываем
         if (substr($sPath, 0, 1) == "/" || substr($sPath, 0, 5) == 'http:' || substr($sPath, 0, 6) == 'https:') {
             continue;
         }
         if (($n = strpos($sPath, '?')) || ($n = strpos($sPath, '#'))) {
             $sPath = substr($sPath, 0, $n);
             $sFileParam = substr($sPath, $n);
         } else {
             $sFileParam = '';
         }
         if (!isset($aUrls[$sPath])) {
             // if url didn't prepare...
             $sRealPath = realpath($sSourceDir . $sPath);
             if ($sRealPath) {
                 $sDestination = F::File_GetAssetDir() . F::Crc32(dirname($sRealPath), true) . '/' . basename($sRealPath);
                 $aUrls[$sPath] = array('source' => $sRealPath, 'destination' => $sDestination, 'url' => E::ModuleViewerAsset()->AssetFileDir2Url($sDestination) . $sFileParam);
                 F::File_Copy($sRealPath, $sDestination);
             }
         }
     }
     if ($aUrls) {
         $sContent = str_replace(array_keys($aUrls), F::Array_Column($aUrls, 'url'), $sContent);
     }
     return $sContent;
 }
开发者ID:hard990,项目名称:altocms,代码行数:41,代码来源:PackageCss.entity.class.php

示例6: MakeMerge

 /**
  * Создание ресурса из множества файлов
  *
  * @param string $sAsset
  * @param array  $aFiles
  *
  * @return bool
  */
 public function MakeMerge($sAsset, $aFiles)
 {
     $sDestination = F::File_GetAssetDir() . md5($sAsset . serialize($aFiles)) . '.' . $this->sOutType;
     if (!$this->CheckDestination($sDestination)) {
         $sContents = '';
         $bCompress = $this->bCompress;
         $bPrepare = null;
         foreach ($aFiles as $aFileParams) {
             $sFileContents = trim(F::File_GetContents($aFileParams['file']));
             $sContents .= $this->PrepareContents($sFileContents, $aFileParams['file']) . PHP_EOL;
             if (isset($aFileParams['compress'])) {
                 $bCompress = $bCompress && (bool) $aFileParams['compress'];
             }
             // Если хотя бы один файл из набора нужно выводить, то весь набор выводится
             if ((is_null($bPrepare) || $bPrepare === true) && isset($aFileParams['prepare']) && !$aFileParams['prepare']) {
                 $bPrepare = false;
             }
         }
         if (F::File_PutContents($sDestination, $sContents)) {
             $aParams = array('file' => $sDestination, 'asset' => $sAsset, 'asset_file' => $sDestination, 'compress' => $bCompress, 'prepare' => is_null($bPrepare) ? false : $bPrepare);
             $this->AddLink($this->sOutType, E::ModuleViewerAsset()->AssetFileDir2Url($sDestination), $aParams);
         } else {
             F::SysWarning('Can not write asset file "' . $sDestination . '"');
             return false;
         }
     } else {
         $aParams = array('file' => $sDestination, 'asset' => $sAsset, 'asset_file' => $sDestination, 'compress' => $this->bCompress, 'prepare' => false);
         $this->AddLink($this->sOutType, E::ModuleViewerAsset()->AssetFileDir2Url($sDestination), $aParams);
     }
     return true;
 }
开发者ID:hard990,项目名称:altocms,代码行数:39,代码来源:Package.entity.class.php


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