本文整理汇总了PHP中Cms\Classes\Theme类的典型用法代码示例。如果您正苦于以下问题:PHP Theme类的具体用法?PHP Theme怎么用?PHP Theme使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Theme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testCmsExceptionPhp
public function testCmsExceptionPhp()
{
$theme = new Theme();
$theme->load('test');
$router = new Router($theme);
$page = $router->findByUrl('/throw-php');
$foreignException = new \Symfony\Component\Debug\Exception\FatalErrorException('This is a general error');
$this->setProtectedProperty($foreignException, 'file', "/modules/cms/classes/CodeParser.php(165) : eval()'d code line 7");
$exception = new CmsException($page, 300);
$exception->setMask($foreignException);
$this->assertEquals($page->getFullPath(), $exception->getFile());
$this->assertEquals('PHP Content', $exception->getErrorType());
$this->assertEquals('This is a general error', $exception->getMessage());
}
示例3: boot
public function boot()
{
$this->manager = PluginManager::instance();
// Get paths we need
$theme = Theme::getActiveTheme();
$themePath = $theme->getPath();
$pluginPath = dirname(__FILE__);
$providerPath = $themePath . '/Plugin.php';
// Load your theme's Theme.php file as a service provider
if (File::exists($providerPath)) {
// Use reflection to find out info about Plugin.php
$info = new Classes\ClassInfo($providerPath);
if (ltrim($info->extends, '\\') == "NSRosenqvist\\ThemesPlus\\Classes\\ThemesPlusBase") {
// Activate the theme plugin
$plugin = $this->manager->loadPlugin($info->namespace, $themePath);
$identifier = $this->manager->getIdentifier($plugin);
$definitionsFile = $pluginPath . '/composer/definitions.php';
$this->manager->registerPlugin($plugin);
$this->manager->bootPlugin($plugin);
// See if we need to generate a new composer psr-4 definitions file
if (Settings::get('definitions_generated_for') != $identifier || !File::exists($definitionsFile)) {
File::put($definitionsFile, $this->makeDefinitionFile($info->namespace, $themePath));
Settings::set('definitions_generated_for', $identifier);
}
// Add theme to autoload through our definitions file
ComposerManager::instance()->autoload($pluginPath);
}
}
// dd(\Composer\Autoload\ClassLoader::findFile('MyCompany\\MyTheme\\Classes\\Radical'));
// dd(ComposerManager::instance());
}
示例4: onRun
public function onRun()
{
$theme = Theme::getActiveTheme();
$page = Page::load($theme, $this->page->baseFileName);
$this->page["hasBlog"] = false;
if (!$page->hasComponent("blogPost")) {
$this->seo_title = $this->page["seo_title"] = empty($this->page->meta_title) ? $this->page->title : $this->page->meta_title;
$this->seo_description = $this->page["seo_description"] = $this->page->meta_description;
$this->seo_keywords = $this->page["seo_keywords"] = $this->page->seo_keywords;
$this->canonical_url = $this->page["canonical_url"] = $this->page->canonical_url;
$this->redirect_url = $this->page["redirect_url"] = $this->page->redirect_url;
$this->robot_follow = $this->page["robot_follow"] = $this->page->robot_follow;
$this->robot_index = $this->page["robot_index"] = $this->page->robot_index;
$settings = Settings::instance();
if ($settings->enable_og_tags) {
$this->ogTitle = empty($this->page->meta_title) ? $this->page->title : $this->page->meta_title;
$this->ogDescription = $this->page->meta_description;
$this->ogUrl = empty($this->page->canonical_url) ? Request::url() : $this->page->canonical_url;
$this->ogSiteName = $settings->og_sitename;
$this->ogFbAppId = $settings->og_fb_appid;
}
} else {
$this->hasBlog = $this->page["hasBlog"] = true;
}
}
示例5: getThemeDir
protected function getThemeDir()
{
if (is_null(self::$theme)) {
self::$theme = Theme::getActiveTheme();
}
return ltrim(Config::get('cms.themesPath'), '/') . '/' . self::$theme->getDirName();
}
示例6: getFormFields
/**
* Returns all fields defined for this model, based on form field definitions.
*/
public function getFormFields()
{
if (!($theme = CmsTheme::load($this->theme))) {
throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
}
return $theme->getConfigValue('form.fields', []) + $theme->getConfigValue('form.tabs.fields', []) + $theme->getConfigValue('form.secondaryTabs.fields', []);
}
示例7: fire
/**
* Execute the console command.
* @return void
*/
public function fire()
{
$this->info('Initializing npm, bower and some boilerplates');
// copiar templates
$path_source = plugins_path('genius/elixir/assets/template/');
$path_destination = base_path('/');
$vars = ['{{theme}}' => Theme::getActiveTheme()->getDirName(), '{{project}}' => str_slug(BrandSettings::get('app_name'))];
$fileSystem = new Filesystem();
foreach ($fileSystem->allFiles($path_source) as $file) {
if (!$fileSystem->isDirectory($path_destination . $file->getRelativePath())) {
$fileSystem->makeDirectory($path_destination . $file->getRelativePath(), 0777, true);
}
$fileSystem->put($path_destination . $file->getRelativePathname(), str_replace(array_keys($vars), array_values($vars), $fileSystem->get($path_source . $file->getRelativePathname())));
}
$this->info('... initial setup is ok!');
$this->info('Installing npm... this can take several minutes!');
// instalar NPM
system("cd '{$path_destination}' && npm install");
$this->info('... node components is ok!');
$this->info('Installing bower... this will no longer take as!');
// instalar NPM
system("cd '{$path_destination}' && bower install");
$this->info('... bower components is ok!');
$this->info('Now... edit the /gulpfile.js as you wish and edit your assets at/ resources directory... that\'s is!');
}
示例8: onRun
public function onRun()
{
$url = $this->getRouter()->getUrl();
if (!strlen($url)) {
$url = '/';
}
$theme = Theme::getActiveTheme();
$router = new Router($theme);
$page = $router->findByUrl($url);
if ($page) {
$tree = StaticPageClass::buildMenuTree($theme);
$code = $startCode = $page->getBaseFileName();
$breadcrumbs = [];
while ($code) {
if (!isset($tree[$code])) {
continue;
}
$pageInfo = $tree[$code];
if ($pageInfo['navigation_hidden']) {
$code = $pageInfo['parent'];
continue;
}
$reference = new MenuItemReference();
$reference->title = $pageInfo['title'];
$reference->url = URL::to($pageInfo['url']);
$reference->isActive = $code == $startCode;
$breadcrumbs[] = $reference;
$code = $pageInfo['parent'];
}
$breadcrumbs = array_reverse($breadcrumbs);
$this->breadcrumbs = $this->page['breadcrumbs'] = $breadcrumbs;
}
}
示例9: onRun
public function onRun()
{
$url = Request::path();
if (!strlen($url)) {
$url = '/';
}
$router = new Router(Theme::getActiveTheme());
$this->page = $this->page['page'] = $router->findByUrl($url);
if ($this->page) {
$this->seo_title = $this->page['seo_title'] = $this->page->getViewBag()->property('seo_title');
$this->title = $this->page['title'] = $this->page->getViewBag()->property('title');
$this->seo_description = $this->page['seo_description'] = $this->page->getViewBag()->property('seo_description');
$this->seo_keywords = $this->page['seo_keywords'] = $this->page->getViewBag()->property('seo_keywords');
$this->canonical_url = $this->page['canonical_url'] = $this->page->getViewBag()->property('canonical_url');
$this->redirect_url = $this->page['redirect_url'] = $this->page->getViewBag()->property('redirect_url');
$this->robot_index = $this->page['robot_index'] = $this->page->getViewBag()->property('robot_index');
$this->robot_follow = $this->page['robot_follow'] = $this->page->getViewBag()->property('robot_follow');
$settings = Settings::instance();
if ($settings->enable_og_tags) {
$this->ogTitle = empty($this->page->meta_title) ? $this->page->title : $this->page->meta_title;
$this->ogDescription = $this->page->meta_description;
$this->ogUrl = empty($this->page->canonical_url) ? Request::url() : $this->page->canonical_url;
$this->ogSiteName = $settings->og_sitename;
$this->ogFbAppId = $settings->og_fb_appid;
}
}
}
示例10: init
/**
* Initialize this singleton.
*/
protected function init()
{
$this->theme = Theme::getActiveTheme();
if (!$this->theme) {
throw new CmsException(Lang::get('cms::lang.theme.active.not_found'));
}
}
示例11: __construct
/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
BackendMenu::setContext('October.Cms', 'cms', true);
try {
if (!($theme = Theme::getEditTheme())) {
throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
}
$this->theme = $theme;
new TemplateList($this, 'pageList', function () use($theme) {
return Page::listInTheme($theme, true);
});
new TemplateList($this, 'partialList', function () use($theme) {
return Partial::listInTheme($theme, true);
});
new TemplateList($this, 'layoutList', function () use($theme) {
return Layout::listInTheme($theme, true);
});
new TemplateList($this, 'contentList', function () use($theme) {
return Content::listInTheme($theme, true);
});
new ComponentList($this, 'componentList');
new AssetList($this, 'assetList');
} catch (Exception $ex) {
$this->handleError($ex);
}
}
示例12: init
/**
* Initialize.
*
* @return void
* @throws \Krisawzm\DemoManager\Classes\DemoManagerException
*/
protected function init()
{
$backendUser = BackendAuth::getUser();
$baseTheme = $this->theme = Config::get('krisawzm.demomanager::base_theme', null);
if ($backendUser) {
if ($backendUser->login == Config::get('krisawzm.demomanager::admin.login', 'admin')) {
$this->theme = $baseTheme;
} else {
$this->theme = $backendUser->login;
}
} else {
if (UserCounter::instance()->limit()) {
$action = Config::get('krisawzm.demomanager::limit_action', 'reset');
if ($action == 'reset') {
DemoManager::instance()->resetEverything();
// @todo queue/async?
$this->theme = $this->newDemoUser()->login;
} elseif ($action == 'maintenance') {
$theme = Theme::load($baseTheme);
Event::listen('cms.page.beforeDisplay', function ($controller, $url, $page) use($theme) {
return Page::loadCached($theme, 'maintenance');
});
} elseif ($action == 'nothing') {
$this->theme = $baseTheme;
} else {
throw new DemoManagerException('User limit is reached, but an invalid action is defined.');
}
} else {
$this->theme = $this->newDemoUser()->login;
// @todo Remember the username after signing out.
// Could prove useful as some plugins may
// have some different offline views.
}
}
}
示例13: __construct
/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
BackendMenu::setContext('RainLab.Pages', 'pages', 'pages');
try {
if (!($this->theme = Theme::getEditTheme())) {
throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
}
new PageList($this, 'pageList');
new MenuList($this, 'menuList');
new SnippetList($this, 'snippetList');
$theme = $this->theme;
new TemplateList($this, 'contentList', function () use($theme) {
return Content::listInTheme($theme, true);
});
} catch (Exception $ex) {
$this->handleError($ex);
}
$this->addJs('/modules/backend/assets/js/october.treeview.js', 'core');
$this->addJs('/plugins/rainlab/pages/assets/js/pages-page.js');
$this->addJs('/plugins/rainlab/pages/assets/js/pages-snippets.js');
$this->addCss('/plugins/rainlab/pages/assets/css/pages.css');
// Preload the code editor class as it could be needed
// before it loads dynamically.
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js', 'core');
$this->bodyClass = 'compact-container side-panel-not-fixed';
$this->pageTitle = 'rainlab.pages::lang.plugin.name';
$this->pageTitleTemplate = '%s Pages';
}
示例14: getMenuTypeInfo
/**
* Handler for the pages.menuitem.getTypeInfo event.
* Returns a menu item type information. The type information is returned as array
* with the following elements:
* - references - a list of the item type reference options. The options are returned in the
* ["key"] => "title" format for options that don't have sub-options, and in the format
* ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional,
* required only if the menu item type requires references.
* - nesting - Boolean value indicating whether the item type supports nested items. Optional,
* false if omitted.
* - dynamicItems - Boolean value indicating whether the item type could generate new menu items.
* Optional, false if omitted.
* - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to
* resolve the item URL.
* @param string $type Specifies the menu item type
* @return array Returns an array
*/
public static function getMenuTypeInfo($type)
{
$result = [];
if ($type == 'blog-category') {
$references = [];
$categories = self::orderBy('name')->get();
foreach ($categories as $category) {
$references[$category->id] = $category->name;
}
$result = ['references' => $references, 'nesting' => false, 'dynamicItems' => false];
}
if ($type == 'all-blog-categories') {
$result = ['dynamicItems' => true];
}
if ($result) {
$theme = Theme::getActiveTheme();
$pages = CmsPage::listInTheme($theme, true);
$cmsPages = [];
foreach ($pages as $page) {
if (!$page->hasComponent('blogPosts')) {
continue;
}
$properties = $page->getComponentProperties('blogPosts');
if (!isset($properties['categoryFilter']) || substr($properties['categoryFilter'], 0, 1) !== ':') {
continue;
}
$cmsPages[] = $page;
}
$result['cmsPages'] = $cmsPages;
}
return $result;
}
示例15: getMenuTypeInfo
/**
* Handler for the pages.menuitem.getTypeInfo event.
* Returns a menu item type information. The type information is returned as array
* with the following elements:
* - references - a list of the item type reference options. The options are returned in the
* ["key"] => "title" format for options that don't have sub-options, and in the format
* ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional,
* required only if the menu item type requires references.
* - nesting - Boolean value indicating whether the item type supports nested items. Optional,
* false if omitted.
* - dynamicItems - Boolean value indicating whether the item type could generate new menu items.
* Optional, false if omitted.
* - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to
* resolve the item URL.
* @param string $type Specifies the menu item type
* @return array Returns an array
*/
public static function getMenuTypeInfo($type)
{
$result = [];
if ($type == 'blog-category') {
$result = ['references' => self::listSubCategoryOptions(), 'nesting' => true, 'dynamicItems' => true];
}
if ($type == 'all-blog-categories') {
$result = ['dynamicItems' => true];
}
if ($result) {
$theme = Theme::getActiveTheme();
$pages = CmsPage::listInTheme($theme, true);
$cmsPages = [];
foreach ($pages as $page) {
if (!$page->hasComponent('blogPosts')) {
continue;
}
/*
* Component must use a category filter with a routing parameter
* eg: categoryFilter = "{{ :somevalue }}"
*/
$properties = $page->getComponentProperties('blogPosts');
if (!isset($properties['categoryFilter']) || !preg_match('/{{\\s*:/', $properties['categoryFilter'])) {
continue;
}
$cmsPages[] = $page;
}
$result['cmsPages'] = $cmsPages;
}
return $result;
}