本文整理汇总了PHP中Cms\Classes\Page::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::load方法的具体用法?PHP Page::load怎么用?PHP Page::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cms\Classes\Page
的用法示例。
在下文中一共展示了Page::load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: getContent
/**
* @return bool|string
* @throws \SystemException
*/
public function getContent()
{
switch ($this->popup->content_type) {
case 'imageUrl':
return "<img src='{$this->popup->content_image_url}'>";
break;
case 'imageUpload':
return '<img src="' . MediaLibrary::instance()->getPathUrl($this->popup->content_image_upload) . '">';
break;
case 'page':
/** @var Page $page */
$page = Page::load(Theme::getActiveTheme(), $this->popup->content_page);
$cms = new CmsController();
return $cms->run($page->url)->getContent();
break;
case 'markdown':
return \Markdown::parse($this->popup->content_markdown);
break;
}
}
示例4: testTargetCmsPageRedirect
public function testTargetCmsPageRedirect()
{
$page = Page::load(Theme::getActiveTheme(), 'adrenth-redirect-testpage');
if ($page === null) {
$page = new Page();
$page->title = 'Testpage';
$page->url = '/adrenth/redirect/testpage';
$page->setFileNameAttribute('adrenth-redirect-testpage');
$page->save();
}
$redirect = new Redirect(['match_type' => Redirect::TYPE_EXACT, 'target_type' => Redirect::TARGET_TYPE_CMS_PAGE, 'from_url' => '/this-should-be-source', 'cms_page' => 'adrenth-redirect-testpage', 'requirements' => null, 'status_code' => 302, 'from_date' => Carbon::now(), 'to_date' => Carbon::now()->addWeek()]);
self::assertTrue($redirect->save());
$rule = RedirectRule::createWithModel($redirect);
self::assertInstanceOf(RedirectRule::class, $rule);
$manager = RedirectManager::createWithRule($rule);
self::assertInstanceOf(RedirectManager::class, $manager);
$result = $manager->match('/this-should-be-source');
self::assertInstanceOf(RedirectRule::class, $result);
self::assertEquals('http://localhost/adrenth/redirect/testpage', $manager->getLocation($result));
self::assertTrue($page->delete());
}
示例5: render
/**
* Renders a page in its entirety, including component initialization.
* AJAX will be disabled for this process.
* @param string $pageFile Specifies the CMS page file name to run.
* @param array $parameters Routing parameters.
* @param \Cms\Classes\Theme $theme Theme object
*/
public static function render($pageFile, $parameters = [], $theme = null)
{
if (!$theme && !($theme = Theme::getActiveTheme())) {
throw new CmsException(Lang::get('cms::lang.theme.active.not_found'));
}
$controller = new static($theme);
$controller->getRouter()->setParameters($parameters);
if (($page = Page::load($theme, $pageFile)) === null) {
throw new CmsException(Lang::get('cms::lang.page.not_found_name', ['name' => $pageFile]));
}
return $controller->runPage($page, false);
}
示例6: testNamespaces
public function testNamespaces()
{
$theme = Theme::load('test');
$page = Page::load($theme, 'code-namespaces.htm');
$this->assertNotEmpty($page);
$parser = new CodeParser($page);
$info = $parser->parse();
$this->assertInternalType('array', $info);
$this->assertArrayHasKey('filePath', $info);
$this->assertArrayHasKey('className', $info);
$this->assertArrayHasKey('source', $info);
$this->assertFileExists($info['filePath']);
$controller = new Controller($theme);
$obj = $parser->source($page, null, $controller);
$this->assertInstanceOf('\\Cms\\Classes\\PageCode', $obj);
$referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces.php';
$this->assertFileExists($referenceFilePath);
$referenceContents = $this->getContents($referenceFilePath);
$referenceContents = str_replace('{className}', $info['className'], $referenceContents);
$this->assertEquals($referenceContents, $this->getContents($info['filePath']));
}