本文整理汇总了PHP中Cms\Classes\Theme::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme::getPath方法的具体用法?PHP Theme::getPath怎么用?PHP Theme::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cms\Classes\Theme
的用法示例。
在下文中一共展示了Theme::getPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listInTheme
/**
* Returns the list of objects in the specified theme.
* This method is used internally by the system.
* @param \Cms\Classes\Theme $theme Specifies a parent theme.
* @param boolean $skipCache Indicates if objects should be reloaded from the disk bypassing the cache.
* @return array Returns an array of CMS objects.
*/
public static function listInTheme($theme, $skipCache = false)
{
if (!$theme) {
throw new ApplicationException(Lang::get('cms::lang.theme.active.not_set'));
}
$dirPath = $theme->getPath() . '/' . static::getObjectTypeDirName();
$result = [];
if (!File::isDirectory($dirPath)) {
return $result;
}
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath));
$it->setMaxDepth(1);
// Support only a single level of subdirectories
$it->rewind();
while ($it->valid()) {
if ($it->isFile() && in_array($it->getExtension(), static::$allowedExtensions)) {
$filePath = $it->getBasename();
if ($it->getDepth() > 0) {
$filePath = basename($it->getPath()) . '/' . $filePath;
}
$page = $skipCache ? static::load($theme, $filePath) : static::loadCached($theme, $filePath);
$result[] = $page;
}
$it->next();
}
return $result;
}
示例2: testRoot
public function testRoot()
{
/*
* Test the / route and the fallback layout
*/
$theme = new Theme();
$theme->load('test');
$controller = new Controller($theme);
$response = $controller->run('/');
$this->assertInternalType('string', $response);
$content = file_get_contents($theme->getPath() . '/pages/index.htm');
$this->assertEquals('<h1>My Webpage</h1>', trim($response));
}
示例3: buildMenuTree
/**
* Builds and caches a menu item tree.
* This method is used internally for menu items and breadcrumbs.
* @param \Cms\Classes\Theme $theme Specifies the current theme.
* @return array Returns an array containing the page information
*/
public static function buildMenuTree($theme)
{
if (self::$menuTreeCache !== null) {
return self::$menuTreeCache;
}
$key = crc32($theme->getPath()) . 'static-page-menu-tree';
$cached = Cache::get($key, false);
$unserialized = $cached ? @unserialize($cached) : false;
if ($unserialized !== false) {
return self::$menuTreeCache = $unserialized;
}
$menuTree = ['--root-pages--' => []];
$iterator = function ($items, $parent, $level) use(&$menuTree, &$iterator) {
$result = [];
foreach ($items as $item) {
$viewBag = $item->page->getViewBag();
$pageCode = $item->page->getBaseFileName();
$itemData = ['url' => Str::lower(RouterHelper::normalizeUrl($viewBag->property('url'))), 'title' => $viewBag->property('title'), 'mtime' => $item->page->mtime, 'items' => $iterator($item->subpages, $pageCode, $level + 1), 'parent' => $parent, 'navigation_hidden' => $viewBag->property('navigation_hidden')];
if ($level == 0) {
$menuTree['--root-pages--'][] = $pageCode;
}
$result[] = $pageCode;
$menuTree[$pageCode] = $itemData;
}
return $result;
};
$pageList = new PageList($theme);
$iterator($pageList->getPageTree(), null, 0);
self::$menuTreeCache = $menuTree;
Cache::put($key, serialize($menuTree), Config::get('cms.parsedPageCacheTTL', 10));
return self::$menuTreeCache;
}
示例4: testGetPath
public function testGetPath()
{
$theme = new Theme();
$theme->load('test');
$this->assertEquals(base_path() . '/tests/fixtures/cms/themes/test', $theme->getPath());
}
示例5: getFilePath
/**
* Returns the absolute file path.
* @param \Cms\Classes\Theme $theme Specifies a theme the file belongs to.
* @param string$fileName Specifies the file name to return the path to.
* @return string
*/
protected static function getFilePath($theme, $fileName)
{
return $theme->getPath() . '/' . static::getObjectTypeDirName() . '/' . $fileName;
}
示例6: getPartialSnippetMap
/**
* Returns a list of partial-based snippets and corresponding partial names.
* @param \Cms\Classes\Theme $theme Specifies a parent theme.
* @return Returns an associative array with the snippet code in keys and partial file names in values.
*/
public function getPartialSnippetMap($theme)
{
$result = [];
$key = crc32($theme->getPath()) . self::CACHE_KEY_PARTIAL_MAP;
$cached = Cache::get($key, false);
if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
return $cached;
}
$partials = Partial::listInTheme($theme);
foreach ($partials as $partial) {
$viewBag = $partial->getViewBag();
$snippetCode = $viewBag->property('snippetCode');
if (!strlen($snippetCode)) {
continue;
}
$result[$snippetCode] = $partial->getFileName();
}
Cache::put($key, serialize($result), Config::get('cms.parsedPageCacheTTL', 10));
return $result;
}
示例7: testSaveFull
public function testSaveFull()
{
$theme = new Theme();
$theme->load('apitest');
$destFilePath = $theme->getPath() . '/testobjects/compound.htm';
if (file_exists($destFilePath)) {
unlink($destFilePath);
}
$this->assertFileNotExists($destFilePath);
$obj = new TestCmsCompoundObject($theme);
$obj->fill(['fileName' => 'compound', 'settings' => ['var' => 'value'], 'code' => 'function a() {return true;}', 'markup' => '<p>Hello, world!</p>']);
$obj->save();
$referenceFilePath = base_path() . '/tests/fixtures/cms/reference/compound-full.htm';
$this->assertFileExists($referenceFilePath);
$this->assertFileExists($destFilePath);
$this->assertFileEquals($referenceFilePath, $destFilePath);
}
示例8: testSaveNewDir
public function testSaveNewDir()
{
$theme = new Theme();
$theme->load('apitest');
$destFilePath = $theme->getPath() . '/testobjects/testsubdir/mytestobj.htm';
if (file_exists($destFilePath)) {
unlink($destFilePath);
}
$destDirPath = dirname($destFilePath);
if (file_exists($destDirPath) && is_dir($destDirPath)) {
rmdir($destDirPath);
}
$this->assertFileNotExists($destFilePath);
$this->assertFileNotExists($destDirPath);
$testContents = 'mytestcontent';
$obj = new TestCmsObject($theme);
$obj->fill(['fileName' => 'testsubdir/mytestobj.htm', 'content' => $testContents]);
$obj->save();
$this->assertFileExists($destFilePath);
$this->assertEquals($testContents, file_get_contents($destFilePath));
}
示例9: clearCache
/**
* Clears the object cache.
* @param \Cms\Classes\Theme $theme Specifies a parent theme.
* @return void
*/
public static function clearCache($theme)
{
$key = crc32($theme->getPath()) . 'component-properties';
Cache::forget($key);
}