Example #1
0
 public static function selector($langXml)
 {
     // create lang selector
     $langSelector = new simpleXmlElement("<lang_selector/>");
     if ($langXml) {
         foreach ($langXml as $entry) {
             $langCode = $entry->getName();
             //echoall($langCode);
             $countryCode = OLIVLang::defaultCountry($langCode);
             // make current language bigger
             $id = "oliv_lang_flag";
             if ($langCode == status::lang()) {
                 $id = "oliv_lang_flag_selected";
             }
             //get string for url title language name
             $title = OLIVText::_("change_language", $langCode);
             $title .= " - " . OLIVText::_($langCode, $langCode);
             // full language name
             // create flag image
             //				$img = new simpleXmlElement("<img url='" . status::url() . "' urllang='" . $langCode . "' urltitle='{$title}' src='oliv_flag' id='{$id}' lang='" . $countryCode . "' />");
             $img = new simpleXmlElement("<selector><a href='current()' title='{$title}' lang='" . $langCode . "'/><img id='{$id}' lang='" . $countryCode . "'>oliv_flag</img></selector>");
             // insert image
             olivxml_insert($langSelector, $img, "ALL");
         }
         //echoall($langSelector->asXML());
         return $langSelector;
     }
 }
Example #2
0
 public static function __callStatic($method, $options)
 {
     $content = $options[0];
     $tag = $options[1];
     // get include information
     $nodes = $content->XPath("//include");
     // include all page informations
     if (count($nodes)) {
         foreach ($nodes as $node) {
             $page = OLIVPage::_load((string) $node);
             olivxml_insert($content, $page->content);
         }
     }
     return $content;
 }
Example #3
0
 public function __construct($header)
 {
     // create temporary content xml
     // name different if used with different templates
     $templateName = (string) $header->param->template;
     if ($templateName) {
         $this->content = new simpleXmlElement("<search_{$templateName}/>");
     } else {
         $this->content = new simpleXmlElement("<search/>");
     }
     $tempContent = OLIVModule::load_content($header);
     $this->template = OLIVModule::load_template($header);
     olivxml_insert($this->content, $tempContent);
     olivxml_insert($this->content->search_result, status::search_result());
     // add search result target page
     $this->content->target = $header->param->target;
 }
Example #4
0
 public static function __callStatic($method, $options)
 {
     $content = $options[0];
     $tag = $options[1];
     $type = $options[2];
     switch ($type) {
         // call text search
         case 'search':
             // merge result with status::set()
             $searchString = argv::search();
             $result = textPlugin::search();
             if ($result) {
                 // get translation of pages
                 $pages = $result->XPath("./result");
                 // insert text snippets with highlighted searchString
                 foreach ($pages as $page) {
                     $moduleName = (string) $page->type;
                     $name = (string) $page->name;
                     $value = (string) $page->value;
                     $article = OLIVModule::load_xml("", $moduleName . "/" . "content/", $name . ".xml");
                     if ($article) {
                         $texts = $article->XPath("//text");
                         foreach ($texts as $text) {
                             // highlight seachstring
                             if ($highlighted = OLIVText::highlight((string) $text, $searchString, "highlight", 25)) {
                                 $page->summary = $highlighted;
                                 // add language
                                 $page->lang = (string) $text['lang'];
                             }
                         }
                         // insert page name
                         olivxml_insert($page->pagename, OLIVRoute::getName((string) $page->page));
                     }
                 }
                 olivxml_insert($content, $result);
             }
             break;
             // call renderer
         // call renderer
         case 'render':
             textPlugin::render($content);
             break;
     }
 }
Example #5
0
 public static function search($string)
 {
     global $_INDEX;
     $search = new simpleXmlElement("<search/>");
     // prepare string for search
     $string = strtolower(OLIVText::remove_accents($string));
     // search index
     $result = OLIVIndex::_search($_INDEX->root, $string);
     if (count($result)) {
         // create search xml
         foreach ($result as $entry) {
             $resArray = explode(":", (string) $entry);
             $page = $resArray[0];
             $type = $resArray[1];
             $name = $resArray[2];
             $lang = $resArray[3];
             $value = $resArray[4];
             $newResult = new simpleXmlElement("<result><page>{$page}</page><type>{$type}</type><name>{$name}</name><lang>{$lang}</lang><value>{$value}</value></result>");
             olivxml_insert($search, $newResult, "ALL");
         }
         return $search;
     }
 }
Example #6
0
 public function text($node, $name)
 {
     olivxml_insert($this->content->{$node}, $this->content->{$name});
 }
Example #7
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());
 }
Example #8
0
 private static function scan($path)
 {
     global $_PLUGIN;
     //    $_PLUGIN = new simpleXmlElement("<plugin></plugin>");
     $_PLUGIN = new simpleXmlElement("<plugins></plugins>");
     if ($pluginDir = olivopendir($path)) {
         $cnt = 0;
         while ($file = readdir($pluginDir)) {
             if (olivis_dir($path . $file) and $file != "." and $file != "..") {
                 $file .= "/";
                 // get define.xml
                 if (olivfile_exists($path . $file . "define.xml")) {
                     $xml = olivxml_load_file($path . $file . "define.xml");
                     //TODO include plugin script
                     // get type of plugin
                     olivxml_insert($_PLUGIN, $xml, "ALL");
                 }
             }
         }
         closedir($pluginDir);
         return $cnt;
     } else {
         OLIVError::fire("plugin::scan - directory {$path} not found");
     }
     return FALSE;
 }
Example #9
0
 public static function getGroup($user)
 {
     global $_access;
     if ($user) {
         $groupArray = array();
         $groupXml = new simpleXmlElement("<group></group>");
         $groups = $_access->group->XPath("*/users[{$user}]");
         foreach ($groups as $entry) {
             $group = $entry->XPath("..");
             olivxml_insert($groupXml, $group[0], "ALL");
         }
         return $groupXml;
     }
     return FALSE;
 }
Example #10
0
function olivxml_changeNode($node, $xml)
{
    $temp = new simpleXmlElement("<{$node}>" . (string) $xml . "</{$node}>");
    foreach ($xml->attributes() as $key => $value) {
        $temp->addAttribute($key, $value);
    }
    if (count($xml)) {
        foreach ($xml->children() as $entry) {
            olivxml_insert($temp, $entry);
        }
    }
    return $temp;
}
Example #11
0
 private function parse($menus, $menuName, $templateName, $access, $url, $level = 0)
 {
     $menu = $menus->{$menuName};
     $active = FALSE;
     if ($menu) {
         // get name of menu
         $menuName = $menu->getName();
         $menuXml = new simpleXmlElement("<menu></menu>");
         // open path to actice menu
         $this->openPath($menus, $url);
         //------------------------------------------------------------------------------
         // loop over menu entries
         foreach ($menu->children() as $entry) {
             $visible = FALSE;
             $subMenuVisible = $entry['visible'];
             if ($subMenuVisible) {
                 $entry->visible = "visible";
             }
             //------------------------------------------------------------------------------
             // display item if read permission
             if (OLIVRight::r($entry) and OLIVRight::r($menu)) {
                 $internUrl = "";
                 $menuItemName = $entry->getName();
                 //------------------------------------------------------------------------------
                 // is intern link
                 if (!$entry->url) {
                     // look for module link
                     $mod = (string) $entry["mod"];
                     $page = (string) $entry["page"];
                     $name = $entry->getName();
                     if ($mod and $page) {
                         olivxml_insert($entry, OLIVModule::getContentFriendlyName($mod, $name), "ALL");
                         olivxml_insert($entry, OLIVModule::getContentName($mod, $name), "ALL");
                         olivxml_insert($entry, OLIVModule::getContentTitle($mod, $name), "ALL");
                         $internUrl = "href():" . $page;
                         $entry->url = $internUrl;
                         //							echoall($internUrl);
                     } else {
                         // create correct url
                         $internUrl = $name;
                         $entry->url = $internUrl;
                         $urlName = OLIVText::xml(OLIVRoute::getPageName(status::lang(), $internUrl));
                         // expand url with val
                         if ($val = (string) $entry['val']) {
                             $valArray = OLIVModule::parse_param_string($val);
                             /*							if (array_key_exists("mod",$valArray) and array_key_exists("content",$valArray))
                             								{
                             									$contentName = OLIVModule::getContentName($valArray['mod'],$valArray['content']);
                             									olivxml_insert($entry->val,OLIVModule::getContentFriendlyName($valArray['mod'],$valArray['content']));
                             									$contentTitle = OLIVModule::getContentTitle($valArray['mod'],$valArray['content']);
                             
                             									olivxml_insert($entry->title,$contentTitle);
                             									olivxml_insert($entry->name,$contentName);
                             								}*/
                         } else {
                             olivxml_insert($entry, OLIVRoute::getTitle($internUrl), "ALL");
                             olivxml_insert($entry, OLIVRoute::getPageName(status::lang(), $internUrl), "ALL");
                         }
                     }
                 }
                 //------------------------------------------------------------------------------
                 // set display class
                 //------------------------------------------------------------------------------
                 // aktive / inactive
                 if ($internUrl == $url) {
                     $visible = $url;
                     $entry->status = "active";
                     $entry->class = "{$templateName} menu_{$templateName}_active";
                 } else {
                     $entry->class = "{$templateName} menu_{$templateName}_inactive";
                 }
                 // submenu level
                 if ($level) {
                     $entry->class = "menu{$level}_" . $entry->class;
                 } else {
                     $entry->class = "menu_" . $entry->class;
                 }
                 //------------------------------------------------------------------------------
                 // remove link if no x permission
                 // check for menu_item, menu and page permissions
                 // set display class to disabled
                 $pageXAccess = (string) $access->x;
                 $menuXAccess = OLIVRight::x($menu);
                 if (!(OLIVRight::x($entry) and $menuXAccess and $pageXAccess)) {
                     $entry->url = "";
                     $entry->class = "menu_{$templateName}_disabled";
                 }
                 // get submenu name
                 $subName = (string) $entry['submenu'];
                 if ($subName) {
                     $entry->submenu = $subName;
                 }
                 // create menu_item xml
                 $menu_item = new simpleXmlElement("<menu_item_{$templateName}></menu_item_{$templateName}>");
                 olivxml_insert($menu_item, $entry);
                 // insert menu_item into new menu structure
                 olivxml_insert($menuXml, $menu_item, "ALL");
                 //------------------------------------------------------------------------------
                 // look if aktive menu is in submenu
                 // display sub menus
                 if ($subName and $visible or $subMenuVisible) {
                     // call menu recursive
                     $subMenu = $this->parse($menus, $subName, $templateName, $access, $url, $level + 1);
                     olivxml_insert($menuXml, $subMenu);
                 }
             }
         }
         //echoall($menuXml);
         return $menuXml;
     }
     //    else
     //      OLIVError::fire("menu::parse - no menu defined");
 }
Example #12
0
 public function insert($xml, $root)
 {
     if ($xml) {
         $insertName = $xml->getName();
         // insert content only once
         if (!$this->structure->{$root}->{$insertName}) {
             $tempXml = new simpleXmlElement("<{$root}/>");
             olivxml_insert($tempXml, $xml, "ALL");
             olivxml_insert($this->structure, $tempXml, "ALL");
         }
     }
 }
Example #13
0
 private static function updatePageXml($url)
 {
     // get page information xml
     $pageInfo = OLIVPage::getPageInfo($url);
     // page exists => write pageInfo in page.xml
     if ($pageInfo) {
         $pageXml = sessionxml_load_file(system::OLIV_PAGE_PATH() . "page.xml");
         // insert if url don't exist
         if (!$pageXml->define->{$url}) {
             olivxml_insert($pageXml->define->{$url}, $pageInfo->define);
             // write file back to disk
             $pageXml->asXML(session_path(system::OLIV_PAGE_PATH() . "page.xml"));
         }
         return $pageInfo;
     }
 }
Example #14
0
 private function create()
 {
     $structure = $this->content->structure;
     $content = $this->content->content;
     if ($content) {
         foreach ($content->children() as $entry) {
             $name = $entry->getName();
             // insert translated text in attibutes
             // text tag with leading $
             $tempName = "\$" . $name;
             $nodes = $structure->XPath("//*[@* = '{$tempName}']");
             foreach ($nodes as $node) {
                 $text = OLIVText::xml($entry);
                 foreach ($node->attributes() as $key => $value) {
                     if ((string) $value == $tempName) {
                         $node[$key] = $text;
                     }
                 }
             }
             // insert content at name attribute
             $nodes = $structure->XPath("//*[@name = '{$name}']");
             foreach ($nodes as $node) {
                 // insert text into node
                 olivxml_insert($node, $entry);
             }
         }
     }
     //echoall($this->content->structure);
 }