本文整理汇总了PHP中Cms\Classes\Theme::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme::load方法的具体用法?PHP Theme::load怎么用?PHP Theme::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cms\Classes\Theme
的用法示例。
在下文中一共展示了Theme::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteTheme
/**
* Completely delete a theme from the system.
* @param string $id Theme code/namespace
* @return void
*/
public function deleteTheme($theme)
{
if (!$theme) {
return false;
}
if (is_string($theme)) {
$theme = CmsTheme::load($theme);
}
if ($theme->isActiveTheme()) {
throw new ApplicationException(trans('cms::lang.theme.delete_active_theme_failed'));
}
/*
* Delete from file system
*/
$themePath = $theme->getPath();
if (File::isDirectory($themePath)) {
File::deleteDirectory($themePath);
}
/*
* Set uninstalled
*/
if ($themeCode = $this->findByDirName($theme->getDirName())) {
$this->setUninstalled($themeCode);
}
}
示例2: 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', []);
}
示例3: 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.
}
}
}
示例4: testHtmlContent
public function testHtmlContent()
{
$theme = Theme::load('test');
$content = Content::load($theme, 'html-content.htm');
$this->assertEquals('<a href="#">Stephen Saucier</a> changed his profile picture — <small>7 hrs ago</small></div>', $content->markup);
$this->assertEquals('<a href="#">Stephen Saucier</a> changed his profile picture — <small>7 hrs ago</small></div>', $content->parsedMarkup);
}
示例5: inTheme
/**
* Set the theme to a specific one.
* @return self
*/
public function inTheme($theme)
{
if (is_string($theme)) {
$theme = Theme::load($theme);
}
$this->theme = $theme;
return $this;
}
示例6: generateSitemap
public function generateSitemap()
{
if (!$this->items) {
return;
}
$currentUrl = Request::path();
$theme = Theme::load($this->theme);
/*
* Cycle each page and add its URL
*/
foreach ($this->items as $item) {
/*
* Explicit URL
*/
if ($item->type == 'url') {
$this->addItemToSet($item, URL::to($item->url));
} else {
$apiResult = Event::fire('pages.menuitem.resolveItem', [$item->type, $item, $currentUrl, $theme]);
if (!is_array($apiResult)) {
continue;
}
foreach ($apiResult as $itemInfo) {
if (!is_array($itemInfo)) {
continue;
}
/*
* Single item
*/
if (isset($itemInfo['url'])) {
$this->addItemToSet($item, $itemInfo['url'], array_get($itemInfo, 'mtime'));
}
/*
* Multiple items
*/
if (isset($itemInfo['items'])) {
$parentItem = $item;
$itemIterator = function ($items) use(&$itemIterator, $parentItem) {
foreach ($items as $item) {
if (isset($item['url'])) {
$this->addItemToSet($parentItem, $item['url'], array_get($item, 'mtime'));
}
if (isset($item['items'])) {
$itemIterator($item['items']);
}
}
};
$itemIterator($itemInfo['items']);
}
}
}
}
$urlSet = $this->makeUrlSet();
$xml = $this->makeXmlObject();
$xml->appendChild($urlSet);
return $xml->saveXML();
}
示例7: spoofPageCode
private function spoofPageCode()
{
// Spoof all the objects we need to make a page object
$theme = Theme::load('test');
$page = Page::load($theme, 'index.htm');
$layout = Layout::load($theme, 'content.htm');
$controller = new Controller($theme);
$parser = new CodeParser($page);
$pageObj = $parser->source($page, $layout, $controller);
return $pageObj;
}
示例8: testListPages
public function testListPages()
{
$theme = Theme::load('test');
$pages = $theme->listPages();
$this->assertInternalType('array', $pages);
$expectedPageNum = $this->countThemePages(base_path() . '/tests/fixtures/themes/test/pages');
$this->assertEquals($expectedPageNum, count($pages));
$this->assertInstanceOf('\\Cms\\Classes\\Page', $pages[0]);
$this->assertNotEmpty($pages[0]->url);
$this->assertInstanceOf('\\Cms\\Classes\\Page', $pages[1]);
$this->assertNotEmpty($pages[1]->url);
}
示例9: testCmsExceptionPhp
public function testCmsExceptionPhp()
{
$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', 100, 1, 'test.php', 20);
$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->getFilePath(), $exception->getFile());
$this->assertEquals('PHP Content', $exception->getErrorType());
$this->assertEquals('This is a general error', $exception->getMessage());
}
示例10: formExtendFields
/**
* Add form fields defined in theme.yaml
*/
protected function formExtendFields($form)
{
$model = $form->model;
if (!($theme = CmsTheme::load($model->theme))) {
throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
}
if ($fields = $theme->getConfigValue('form.fields')) {
$form->addFields($fields);
}
if ($fields = $theme->getConfigValue('form.tabs.fields')) {
$form->addTabFields($fields);
}
if ($fields = $theme->getConfigValue('form.secondaryTabs.fields')) {
$form->addSecondaryTabFields($fields);
}
}
示例11: fire
/**
* Execute the console command.
* @return void
*/
public function fire()
{
if (!$this->confirmToProceed('Do you really want to change the active theme?')) {
return;
}
$newThemeName = $this->argument('name');
$newTheme = Theme::load($newThemeName);
if (!$newTheme->exists($newThemeName)) {
return $this->error(sprintf('The theme %s does not exist.', $newThemeName));
}
if ($newTheme->isActiveTheme()) {
return $this->error(sprintf('%s is already the active theme.', $newTheme->getId()));
}
$activeTheme = Theme::getActiveTheme();
$from = $activeTheme ? $activeTheme->getId() : 'nothing';
$this->info(sprintf('Switching theme from %s to %s', $from, $newTheme->getId()));
Theme::setActiveTheme($newThemeName);
}
示例12: update
/**
* Update action. Add the theme object to the page vars.
*/
public function update($recordId = null, $context = null)
{
$this->bodyClass = 'compact-container';
try {
if (!($editTheme = Theme::getEditTheme())) {
throw new ApplicationException('Unable to find the active theme.');
}
$result = $this->asExtension('FormController')->update($recordId, $context);
$model = $this->formGetModel();
$theme = Theme::load($model->theme);
/*
* Not editing the active sitemap definition
*/
if ($editTheme->getDirName() != $theme->getDirName()) {
return $this->redirectToThemeSitemap($editTheme);
}
$this->vars['theme'] = $theme;
$this->vars['themeName'] = $theme->getConfigValue('name', $theme->getDirName());
$this->vars['sitemapUrl'] = URL::to('/sitemap.xml');
return $result;
} catch (Exception $ex) {
$this->handleError($ex);
}
}
示例13: testGetViewBagEmpty
public function testGetViewBagEmpty()
{
$theme = Theme::load('test');
$obj = TestParsedCmsCompoundObject::load($theme, 'compound.htm');
$viewBag = $obj->getViewBag();
$this->assertInstanceOf('Cms\\Classes\\ViewBag', $viewBag);
$properties = $viewBag->getProperties();
$this->assertEmpty($properties);
$this->assertEquals($obj->viewBag, $properties);
}
示例14: testSaveNewDir
public function testSaveNewDir()
{
$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));
}
示例15: getFormFields
/**
* Returns all fields defined for this model, based on form field definitions.
* @return array
*/
public function getFormFields()
{
if (!($theme = CmsTheme::load($this->theme))) {
throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
}
$config = $theme->getConfigArray('form');
return array_get($config, 'fields', []) + array_get($config, 'tabs.fields', []) + array_get($config, 'secondaryTabs.fields', []);
}