Пример #1
0
 private function route()
 {
     // separate url and values
     // look for url in page.xml
     $tempArray = $this->parseUrl(status::url());
     status::set('url', $tempArray['url']);
     status::set('val', $tempArray['val']);
     // add values to val-parameter
     status::set('path', $tempArray['path']);
     // add values to val-parameter
     //echoall($tempArray);
     // routable url found
     if (status::url()) {
         if ($newVal = OLIVRoute::getUrl(status::url())) {
             status::set('url', $newVal);
         } else {
             OLIVError::fire("route.php::route - rescan route information");
         }
     } else {
         // use 404 page or if not defined use index page
         if (system::OLIV_404_PAGE()) {
             status::set('url', system::OLIV_404_PAGE());
         } else {
             status::set('url', system::OLIV_INDEX_PAGE());
         }
     }
     // set page name in correct language
     status::set('OLIV_PAGE', system::OLIV_SITE_NAME() . " " . OLIVText::xml($this->getPageName(status::lang(), status::url())));
 }
Пример #2
0
 public static function __callStatic($method, $options)
 {
     $content = $options[0];
     $tag = $options[1];
     //------------------------------------------------------------------------------
     // look for href expressions
     $nodes = $content->XPath("//*[@href]");
     // loop through all nodes
     for ($i = 0; $i < count($nodes); $i++) {
         // if not extern link
         // route
         if (!link_is_extern($href = (string) $nodes[$i]['href'])) {
             // set lang for link call
             if (!($lang = (string) $nodes[$i]['lang'])) {
                 $lang = status::lang();
             }
             $href = str_replace(array(";"), array("&"), $href);
             $hrefArray = explode(":", $href);
             // parse special route functions:
             // referer() ... insert referer address
             // current() ... insert current url and val
             // javascript(): ... convert to javascript call
             // urlName:valName ... convert to correct friendly_url/val
             switch ($hrefArray[0]) {
                 case 'href()':
                     $nodes[$i]['href'] = OLIVRoute::url($lang, $hrefArray[1], (string) $nodes[$i]["val"]);
                     break;
                 case 'referer()':
                     $nodes[$i]['href'] = status::oliv_referer();
                     break;
                 case 'current()':
                     $nodes[$i]['href'] = OLIVRoute::url($lang, status::url(), status::val());
                     // insert additional parameters
                     if (count($hrefArray) > 1) {
                         $nodes[$i]['href'] = substr($nodes[$i]['href'], 0, -1) . "?" . $hrefArray[1];
                     }
                     break;
                 case 'javascript()':
                     $nodes[$i]['href'] = "javascript:toolbox('" . (string) $hrefArray[1] . "')";
                     break;
                 default:
                     $nodes[$i]['href'] = OLIVRoute::url($lang, $hrefArray[0], status::val());
                     // add value
                     if (count($hrefArray) > 1) {
                         $nodes[$i]['href'] .= $hrefArray[1] . "/";
                     }
                     break;
             }
         }
     }
     return $content;
 }
Пример #3
0
 public static function __callStatic($method, $options)
 {
     $content = $options[0];
     $tag = $options[1];
     switch ($tag) {
         case 'form':
             // get form information
             $nodes = $content->XPath("//form");
             // loop through all nodes
             for ($i = 0; $i < count($nodes); $i++) {
                 $formMethod = $nodes[$i]["action"];
                 $nodes[$i]["method"] = "post";
                 $nodes[$i]["accept-charset"] = "utf-8";
                 // if no action -> insert correct url
                 if (!$formMethod) {
                     $nodes[$i]["action"] = OLIVRoute::makeUrl(status::lang(), status::url());
                 } else {
                     $nodes[$i]["action"] = OLIVRoute::makeUrl(status::lang(), (string) $formMethod);
                 }
             }
             break;
         case 'input':
             // if $xxx in value of input tag
             // replace by argv::xxx() value
             $nodes = $content->XPath("//input[contains(@value,'\$')]");
             foreach ($nodes as $entry) {
                 if ($entry) {
                     $val = substr((string) $entry['value'], 1);
                     $entry['value'] = argv::$val();
                 }
             }
             // set checked value for radio and checkbox
             $nodes = $content->XPath("//input[@type = 'radio' or @type = 'checkbox']");
             foreach ($nodes as $entry) {
                 $name = (string) $entry['name'];
                 $value = (string) $entry['value'];
                 $arg = argv::$name();
                 if ($arg == $value) {
                     $entry['checked'] = "checked";
                 }
             }
             break;
     }
     return $content;
 }
Пример #4
0
 function __construct($header)
 {
     $menuName = "";
     $templateName = "";
     // load menu items
     $access = $header->access;
     $menuName = (string) $header->param->menu;
     $templateName = (string) $header->param->template;
     if ($templateName and $menuName) {
         $menu = status::pagestructure();
         // permission to display menu
         if (OLIVRight::r($menu->{$menuName})) {
             // load menu template
             $template = OLIVModule::load_template($header);
             // call menu parser
             $menuXml = $this->parse($menu, $menuName, $templateName, $access, status::url());
             $this->template = $template;
             $this->content = $menuXml;
             //echoall($menuXml);
         }
     }
 }
Пример #5
0
 public function draw()
 {
     $display = "";
     $o = "<ul id='" . $this->context->attributes()->name . "' class='contextMenu'>";
     // create ouput string from xml
     foreach ($this->context as $entry) {
         // disable entry
         if ($display = (string) $entry->attributes()->display) {
             $display = " " . $display;
         }
         // set entry to url or status::url
         if (($url = (string) $entry->attributes()->url) == "#CURRENT") {
             $url = status::url();
         }
         // set val
         if ($val = (string) $this->context->attributes()->value) {
         } else {
             $val = (string) $this->context->attributes()->name;
         }
         // set parameters
         $class = (string) $entry->attributes()->class;
         $cmd = (string) $entry->attributes()->cmd;
         $command = OLIVText::_($cmd);
         $text = OLIVText::_($entry->getName());
         $o .= "<li class='{$class}{$display}'>";
         $o .= "<a href='#{$cmd};{$command};" . OLIVRoute::url("", array("url" => $url)) . ";{$val}'>{$text}</a>";
         $o .= "</li>";
     }
     $o .= "</ul>";
     // output to display
     echo $o;
 }
Пример #6
0
 public static function tagEditString($tag, $value, $options)
 {
     $content = $options['template'];
     $source = $content->attributes()->source;
     //echoall($options);
     $retArray = imgRender::tagString($tag, $value, $options);
     // set link if permission granted && source found
     if (OLIVRight::x($content) and $source) {
         $retArray['link']['url'] = status::url();
         $retArray['link']['val'] = OLIVText::_("edit");
         $retArray['link']['lang'] = status::lang();
         $retArray['value'] = "edit";
     }
     return $retArray;
 }
Пример #7
0
 public function insertText($text, $url = "", $lang = "")
 {
     // remove punctuation marks in text
     $text = preg_replace("![\\.\\,\\;\\:\\(\\)\\[\\]\\{\\}\\-\\_\\/]!", " ", strtolower($text));
     // extract words
     $wordArray = explode(" ", $text);
     $wordArray = array_unique($wordArray);
     foreach ($wordArray as $word) {
         //	 		$word = strtolower(Normalizer::normalize($word,Normalizer::FORM_C));
         $word = strtolower($word);
         //TODO replace all special characters with root
         $specialChar = array("ä", "ö");
         $replaceChar = array();
         $word = OLIVText::remove_accents($word);
         //			$this->insertWord($word,$word);
         $suffArray = $this->makeSuffArray($word);
         foreach ($suffArray as $suffix) {
             $this->insertWord($suffix, status::url() . ":" . $url . ":{$lang}:{$word}", $lang);
         }
     }
     global $_INDEX;
     //echoall($_INDEX);
     // write index to disk
     $path = session_path("");
     $name = "index.idx";
     if (file_exists($path)) {
         $fh = fopen($path . $name, "w");
         if ($fh) {
             fwrite($fh, $_INDEX->asXML());
             fclose($fh);
         } else {
             OLIVError::fire("index.php - no write permission");
         }
     } else {
         OLIVError::fire("index.php - directory {$path} don't exist");
     }
 }
Пример #8
0
 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;
 }