예제 #1
0
 public function process($page)
 {
     global $_PLUGIN;
     //echoall($page);
     // call plugins
     //		$pageXml = olivxml_create($page,"page");
     if ($page) {
         $pageXml = OLIVPlugin::call(new simpleXmlElement($page), "render");
         //------------------------------------------------------------------------------
         // convert page xml to html
         if (sessionfile_exists(system::OLIV_TEMPLATE_PATH() . "post.xslt")) {
             $postStylesheet = sessionxml_load_file(system::OLIV_TEMPLATE_PATH() . "post.xslt");
         } else {
             OLIVError::fire("postprocessor.php::process - post.xslt file not found");
             die;
         }
         $htmlProcessor = new XSLTProcessor();
         $htmlProcessor->importStylesheet($postStylesheet);
         $pageString = $htmlProcessor->transformToXML($pageXml);
         //echoall($pageXml->asXML());
         //------------------------------------------------------------------------------
         // run markup parser
         $pageString = $this->markup($pageString);
         return $pageString;
     }
 }
예제 #2
0
 public static function link_css($name)
 {
     $path = pathinfo($name);
     $cssPath = $path['dirname'] . "/";
     $cssName = $path['filename'] . ".css";
     if (!sessionfile_exists($cssPath . $cssName)) {
         $cssName = "default.css";
         // default.css class
     }
     // css file found
     if (sessionfile_exists($cssPath)) {
         echo "<link href='" . session_path($cssPath . $cssName) . "' rel='stylesheet' type='text/css'>";
         // link css to site
     } else {
         OLIVError::warning("template::link_css.php - no stylesheet found");
     }
 }
예제 #3
0
파일: module.php 프로젝트: nibble-arts/oliv
 private function scan($path)
 {
     $modules = array();
     $cnt = 0;
     if ($modDir = olivopendir($path)) {
         while ($file = readdir($modDir)) {
             if (olivis_dir($path . $file) and $file != "." and $file != "..") {
                 $filePath = "{$file}/";
                 // get modules define.xml
                 if (olivfile_exists($path . $filePath)) {
                     // load module information
                     $xml = olivxml_load_file($path . $filePath . "define.xml");
                     //------------------------------------------------------------------------------
                     // check for session directory
                     $sessionDir = system::oliv_module_path() . $filePath;
                     if (sessionfile_exists($sessionDir)) {
                         $contentPath = $xml->content;
                         $templatePath = $xml->template;
                         // write directory permissions to module header
                         $xml->content['permission'] = get_permission(session_path($sessionDir) . $contentPath);
                         $xml->template['permission'] = get_permission(session_path($sessionDir) . $templatePath);
                     } else {
                         // session directory don't exist
                         $xml->status = "NO_SESSION_DIR";
                         $xml->permission = 0;
                     }
                     //------------------------------------------------------------------------------
                     // save module metadata
                     $modules[(string) $xml->name] = $xml;
                     $cnt++;
                 }
             }
         }
         closedir($modDir);
         system::set("modules", $modules);
         return $cnt;
     } else {
         OLIVError::fire("module::scan - directory {$path} not found");
     }
     return FALSE;
 }
예제 #4
0
 public function process($page, $stylesheet, $templatePath)
 {
     $i = 0;
     $templates = array();
     $xmlString = "";
     $templArray = array();
     $linkArray = array();
     //------------------------------------------------------------------------------
     // parse site
     if (count($page->structure())) {
         $areas = $page->structure()->children();
         if (count($areas)) {
             foreach ($areas as $entry) {
                 // check for read access rights
                 // if not, clear node to hide from rendering
                 if (OLIVRight::r($entry)) {
                     if ($mod = $entry->attributes()->mod) {
                         $script = OLIVModule::getModuleByName($mod);
                         $originScript = $script;
                         //------------------------------------------------------------------------------
                         // script found
                         if (isset($script->script)) {
                             // insert parameters
                             olivxml_insert($script, OLIVPreprocessor::parse_param((string) $entry), "ALL");
                             // create paths for module, content, template, image
                             $script->path = system::OLIV_MODULE_PATH() . (string) $script->name . "/";
                             // insert script access rights
                             $script->access->r = OLIVRight::r($entry);
                             $script->access->w = OLIVRight::w($entry);
                             $script->access->x = OLIVRight::x($entry);
                             //------------------------------------------------------------------------------
                             // load module script
                             $this->loadScript($script->script->main, system::OLIV_MODULE_PATH() . $script->name . "/");
                             //------------------------------------------------------------------------------
                             // call module class and merge template and content
                             if ($script->script->main) {
                                 $tempArray = explode(".", $script->script->main);
                                 $class = $tempArray[0];
                                 if (class_exists($class)) {
                                     //------------------------------------------------------------------------------
                                     //------------------------------------------------------------------------------
                                     // create and execute module class
                                     $module = new $class($script);
                                     //------------------------------------------------------------------------------
                                     //------------------------------------------------------------------------------
                                     if (is_object($module)) {
                                         if (!method_exists($module, "template")) {
                                             OLIVError::fire("preprocessor.php::process - module '" . $script->name . "' don't extend OLIVModule");
                                         } else {
                                             $tempTemplate = $module->template();
                                             // set path to insert module-template-link stylesheet
                                             // link only if template and content found
                                             if ($module->template() and $module->content()) {
                                                 if (is_object($module->content())) {
                                                     //TODO register template
                                                     // load template array
                                                     array_push($linkArray, array("module" => (string) $mod, "area" => $entry->getName(), "content" => $module->content()->getName(), "templatePath" => $tempTemplate));
                                                     $templates[$entry->getName() . "::" . $module->content()->getName()] = $tempTemplate;
                                                 }
                                             }
                                             //------------------------------------------------------------------------------
                                             // module didn't return content and template
                                             // clear content entry
                                             if (!$module->content() and !$module->template()) {
                                                 $page->clear($entry->getName());
                                             }
                                             // insert module content in page content
                                             $page->insert($module->content(), $entry->getName());
                                         }
                                     } else {
                                         $page->clear($entry->getName());
                                     }
                                     // destroy module object
                                     //									unset($module);
                                 }
                             } else {
                                 OLIVError::fire("render::callModule - no main script declared");
                             }
                         } else {
                             OLIVError::warning("processor::process - required module '" . $mod . "' not found");
                         }
                     }
                     //------------------------------------------------------------------------------
                 } else {
                     $page->clear($entry->getName());
                 }
             }
             //echoall($page->structure());
         } else {
             OLIVError::fire("processor::process - page is empty");
         }
     }
     //------------------------------------------------------------------------------
     // include module templates in page template
     // create temporary xslt for include process
     $tempXsl = new XSLTProcessor();
     $tempXsl->registerPHPFunctions();
     // include page template
     if (sessionfile_exists($templatePath . ".xslt")) {
         $xmlString = "<xsl:include href='" . session_path($templatePath) . ".xslt'/>";
         OLIVTemplate::link_css($templatePath);
     } else {
         OLIVError::fire("preprocessor.php::process - no page template found");
     }
     //		status::set("debug",$linkArray);
     //------------------------------------------------------------------------------
     // create module link templates
     foreach ($linkArray as $entry) {
         // create stylesheet to link module template to page area
         $tempString = "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>";
         $tempString .= "<xsl:template match='" . $entry['area'] . "'>";
         $tempString .= "<xsl:apply-templates select='" . $entry['content'] . "'/>";
         $tempString .= "</xsl:template>";
         $tempString .= "</xsl:stylesheet>";
         $tempXsl = new simpleXmlElement($tempString);
         $fileName = explode("/", $entry['templatePath']);
         array_pop($fileName);
         $fileName = implode("/", $fileName);
         $filePath = session_path($fileName) . "/link_" . $entry['area'] . "_to_" . $entry['content'] . ".xslt";
         // write link file to disk
         $fileHandle = fopen($filePath, "w");
         if ($fileHandle) {
             fputs($fileHandle, $tempXsl->asXML());
             fclose($fileHandle);
         }
         //------------------------------------------------------------------------------
         // insert link template
         $xmlString .= "<xsl:include href='" . $filePath . "'/>";
         //------------------------------------------------------------------------------
         // insert module template only once
         if (!array_key_exists($entry['templatePath'], $templArray)) {
             $templArray[$entry['templatePath']] = $filePath;
             if (sessionfile_exists($entry['templatePath'] . ".xslt")) {
                 // insert module template
                 $xmlString .= "<xsl:include href='" . session_path($entry['templatePath']) . ".xslt'/>";
                 // link css file
                 OLIVTemplate::link_css($entry['templatePath']);
             }
         }
     }
     //------------------------------------------------------------------------------
     // create temporary include template
     $xmlString = "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" . $xmlString . "</xsl:stylesheet>";
     $tempXml = new simpleXmlElement($xmlString);
     $stylesheet->importStylesheet($tempXml);
     //echoall($tempXml->children('http://www.w3.org/1999/XSL/Transform')->asXML());
     //status::set("debug",$page->structure());
 }
예제 #5
0
파일: init.php 프로젝트: nibble-arts/oliv
if ($sessionXml) {
    if ($sessionXml->system->children()) {
        foreach ($sessionXml->system->children() as $key => $value) {
            system::set($key, (string) $value);
        }
    } else {
        die("init.php - no session constant definitions found");
    }
} else {
    die("init.php - session.xml not found");
}
//------------------------------------------------------------------------------
// load session user rights
global $_access;
if (system::OLIV_ACCESS_FILE() == "local") {
    if (sessionfile_exists("access.xml")) {
        $_access = sessionxml_load_file("access.xml");
    } else {
        die("init.php - session access.xml not found");
    }
} else {
    if (olivfile_exists("access.xml")) {
        $_access = olivxml_load_file("access.xml");
    } else {
        die("init.php - session access.xml not found");
    }
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// set page arguments
// insert GET POST messages in argv
예제 #6
0
파일: page.php 프로젝트: nibble-arts/oliv
 public static function _load($pageName)
 {
     $xml = "";
     if (!$pageName) {
         $url = status::url();
         // if no url defined, user OLIV_INDEX_PAGE
         if (!$url) {
             $url = system::OLIV_INDEX_PAGE();
         }
         $pageName = strtolower($url);
         // set to lowercase
     }
     // create content path
     $path = system::OLIV_PAGE_PATH() . $pageName . "/" . $pageName . ".xml";
     if (sessionfile_exists($path)) {
         // load content xml
         $xml = sessionxml_load_file($path);
         //------------------------------------------------------------------------------
         // search for plugins and call methods
         if ($xml->content->include) {
             OLIVPlugin::call($xml->content, "page");
         }
         //------------------------------------------------------------------------------
         return $xml;
     } else {
         OLIVError::fire("page::load - page not found");
     }
     return FALSE;
 }
예제 #7
0
파일: image.php 프로젝트: nibble-arts/oliv
function img_lang_exists($path, $image, $lang)
{
    $o = $path . $image;
    // check for language code
    if (!$lang) {
        $lang = status::lang();
    }
    //look directory with image name exist -> language versions
    // language code subdirectory found
    if (sessionis_dir($path . $image)) {
        // create path and filename for language version
        $langPath = $path . $image . "/";
        $ext = pathinfo($image, PATHINFO_EXTENSION);
        $langImage = strtolower($lang) . "." . $ext;
        // language version found
        if (sessionfile_exists($langPath . $langImage)) {
            $o = $langPath . $langImage;
        } else {
            $o = "";
        }
    }
    // no language subdirektory
    // return unchanged parameters
    return $o;
}
예제 #8
0
파일: route.php 프로젝트: nibble-arts/oliv
 public function scan($lang)
 {
     $path = system::OLIV_PAGE_PATH() . "page.xml";
     if (sessionfile_exists($path)) {
         $pageXml = sessionxml_load_file($path);
         status::set("pages", $pageXml->define);
         status::set("pagestructure", $pageXml->structure);
         OLIVText::writeSource(status::pages(), $path);
     } else {
         OLIVError::fire("page::scan - page.xml not found -> rescan");
     }
 }