本文整理汇总了PHP中Cms\Classes\Theme::getActiveTheme方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme::getActiveTheme方法的具体用法?PHP Theme::getActiveTheme怎么用?PHP Theme::getActiveTheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cms\Classes\Theme
的用法示例。
在下文中一共展示了Theme::getActiveTheme方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: getThemeDir
protected function getThemeDir()
{
if (is_null(self::$theme)) {
self::$theme = Theme::getActiveTheme();
}
return ltrim(Config::get('cms.themesPath'), '/') . '/' . self::$theme->getDirName();
}
示例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: 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;
}
示例5: 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;
}
}
}
示例6: 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!');
}
示例7: 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;
}
示例8: 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'));
}
}
示例9: 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;
}
}
示例10: loadData
protected function loadData()
{
if (!($theme = Theme::getActiveTheme())) {
throw new ApplicationException(Lang::get('cms::lang.theme.not_found_name', ['name' => Theme::getActiveThemeCode()]));
}
$this->vars['theme'] = $theme;
$this->vars['inMaintenance'] = MaintenanceSetting::get('is_enabled');
}
示例11: testApiTheme
public function testApiTheme()
{
Event::flush('cms.activeTheme');
Event::listen('cms.activeTheme', function () {
return 'apitest';
});
$activeTheme = Theme::getActiveTheme();
$this->assertNotNull($activeTheme);
$this->assertEquals('apitest', $activeTheme->getDirName());
}
示例12: getMenuTypeInfo
/**
*
* Returns an array of info about menu item type
*
* @param string $type item name
* @return array
*/
public static function getMenuTypeInfo($type)
{
$result = [];
if ($type != 'all-archive-years') {
return $result;
}
$result['dynamicItems'] = true;
$theme = Theme::getActiveTheme();
$result['cmsPages'] = CmsPage::listInTheme($theme, true);
return $result;
}
示例13: processLinks
/**
* Checks for broken links in selected database fields and/or all CMS files
* @return void
*/
public static function processLinks()
{
# Let's start by truncating the BrokenLinks table
BrokenLink::truncate();
$brokenLinks = [];
$settings = Settings::instance();
foreach ($settings->modelators as $el) {
list($modelName, $field) = explode('::', $el['modelator']);
$models = $modelName::whereNotNull($field)->get();
foreach ($models as $model) {
$urls = Helper::scanForUrls($model->{$field});
$modelParts = explode('\\', $modelName);
foreach ($urls as $url) {
$status = BrokenLink::isBrokenLink($url);
if ($status) {
$brokenLinks[] = ['status' => $status, 'plugin' => $modelParts[1] . '.' . $modelParts[2], 'model' => array_pop($modelParts), 'model_id' => $model->id, 'field' => $field, 'url' => $model->{$field}];
}
}
}
}
/**
* Go process the current theme
*/
$theme = Theme::getActiveTheme();
$theme->getPath();
/**
* Should we process theme pages?
*/
if ($settings['checkCMS'] == '1') {
foreach (File::directories($theme->getPath()) as $themeSubDir) {
# Skip the assets folder
if (basename($themeSubDir) == 'assets') {
continue;
}
foreach (File::allFiles($themeSubDir) as $filePath) {
$urls = Helper::scanForUrls(file_get_contents($filePath));
foreach ($urls as $url) {
$status = BrokenLink::isBrokenLink($url);
if ($status) {
$brokenLinks[] = ['status' => $status, 'plugin' => 'CMS', 'model' => str_replace($theme->getPath() . DIRECTORY_SEPARATOR, '', $filePath), 'url' => $url];
}
}
}
}
}
/**
* Lets seed the BrokenLink table with any and all found links.
*/
foreach ($brokenLinks as $brokenLink) {
BrokenLink::create($brokenLink);
}
return count($brokenLinks);
}
示例14: onRun
public function onRun()
{
$url = Request::path();
if (!strlen($url)) {
$url = '/';
}
$router = new Router(Theme::getActiveTheme());
$this->pageObject = $this->page['page'] = $router->findByUrl($url);
if ($this->pageObject) {
$this->title = $this->page['title'] = $this->pageObject->getViewBag()->property('title');
$this->extraData = $this->page['extraData'] = $this->defineExtraData();
}
}
示例15: onRun
public function onRun()
{
$url = $this->getRouter()->getUrl();
if (!strlen($url)) {
$url = '/';
}
$router = new Router(Theme::getActiveTheme());
$this->pageObject = $this->page['page'] = $router->findByUrl($url);
if ($this->pageObject) {
$this->title = $this->page['title'] = array_get($this->pageObject->viewBag, 'title');
$this->extraData = $this->page['extraData'] = $this->defineExtraData();
}
}