page.php
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
<?php
class Plugin_PHPPage_Page
extends Editor
{
/*
*
* @param Page $page
*/
public function __construct
(Page
$page){
$this->page = $page;
}
public function getHeader
() {
return "";
}
public function display
() {
$content = $this->page->getEditorContent($this);
if ($content == "" || $content == null || !file_exists(trim(Settings
::getInstance()->get("root") . $content))) {
echo Language
::DirectTranslate("plugin_phppage_not-found");
} else {
$args = array('is_included' => true);
EventManager
::raiseEvent("plugin_phppage_execute", array('script' => $content, 'path' => Settings
::getInstance()->get("root") . $content, 'page' => $this->page, 'instance' => $this, 'args' => &$args));
include(trim(Settings
::getInstance()->get("root") . $content));
}
}
/**
*
* @return string
*/
public function getEditableCode
() {
$template = new Template
();
$template->load("plugin_phppage_edit");
$template->assign_var("CONTENT",$this->page->getEditorContent($this));
$template->assign_var("HOST",Settings
::getInstance()->get("host"));
$template->assign_var("ROOT",Settings
::getInstance()->get("root"));
$template->assign_var("ALIAS",$this->page->alias);
$template->assign_var("URL", UrlRewriting
::GetUrlByAlias("admin/pageedit","site=".$this->page->alias));
$template->assign_var("LANG",strtolower(Settings
::getInstance()->get("language")));
$template->assign_var("PREVIEWURL",$this->page->GetUrl());
return $template->getCode();
}
/**
*
* @param Page $newPage
* @param Page $oldPage
*/
public function save
(Page
$newPage,Page
$oldPage){
$this->page = $newPage;
$this->page->setEditorContent(trim(str_replace("\\\"","\"",$_POST['content'])));
$this->page->save();
}
}
?>