Deutschland United States United Kingdom
ContentLion - Open Source CMS

Blame page.php

Rev 2 | Details | Compare with Previous | Last modification | View Log

Rev Author Line
2 user_9
<?php
user_9
 
user_9
class Plugin_PHPPage_Page extends Editor {
user_9
 
user_9
    /*
user_9
     *
user_9
     * @param Page $page
user_9
     */
user_9
    public function __construct(Page $page){
user_9
        $this->page = $page;
user_9
    }
user_9
 
user_9
    public function getHeader () {
user_9
        return "";
user_9
    }
user_9
 
user_9
    public function display () {
user_9
        $content = $this->page->getEditorContent($this);
user_9
 
3 user_9
        require(dirname(__FILE__) . "/../config.php");
user_9
 
user_9
        if (isset($config['executeOnlyFromScriptsPath']) && $config['executeOnlyFromScriptsPath']) {
user_9
            $content = "content/scripts/" . trim(str_replace("/", "", str_replace("content/scripts/", "", $content)));
user_9
        }
user_9
 
2 user_9
        if ($content == "" || $content == null || !file_exists(trim(Settings::getInstance()->get("root") . $content))) {
user_9
            echo Language::DirectTranslate("plugin_phppage_not-found");
user_9
        } else {
user_9
            $args = array('is_included' => true);
user_9
 
user_9
            EventManager::raiseEvent("plugin_phppage_execute", array('script' => $content, 'path' => Settings::getInstance()->get("root") . $content, 'page' => $this->page, 'instance' => $this, 'args' => &$args));
user_9
            include(trim(Settings::getInstance()->get("root") . $content));
user_9
        }        
user_9
    }
user_9
 
user_9
    /**
user_9
     *
user_9
     * @return string
user_9
     */
user_9
    public function getEditableCode() {
user_9
        $template = new Template();
user_9
        $template->load("plugin_phppage_edit");
user_9
        $template->assign_var("CONTENT",$this->page->getEditorContent($this));
user_9
        $template->assign_var("HOST",Settings::getInstance()->get("host"));
user_9
        $template->assign_var("ROOT",Settings::getInstance()->get("root"));
user_9
        $template->assign_var("ALIAS",$this->page->alias);
user_9
        $template->assign_var("URL",  UrlRewriting::GetUrlByAlias("admin/pageedit","site=".$this->page->alias));
user_9
        $template->assign_var("LANG",strtolower(Settings::getInstance()->get("language")));
user_9
        $template->assign_var("PREVIEWURL",$this->page->GetUrl());
user_9
        return $template->getCode();    
user_9
    }
user_9
 
user_9
    /**
user_9
     *
user_9
     * @param Page $newPage
user_9
     * @param Page $oldPage
user_9
     */
user_9
    public function save(Page $newPage,Page $oldPage){
user_9
        $this->page = $newPage;
user_9
        $this->page->setEditorContent(trim(str_replace("\\\"","\"",$_POST['content'])));
user_9
        $this->page->save();
user_9
    }
user_9
 
user_9
}
user_9
 
user_9
?>