コード例 #1
0
ファイル: route.php プロジェクト: nibble-arts/oliv
 public function __construct()
 {
     $this->scan(status::lang());
     // set referer
     // complete url to get back
     if (array_key_exists('HTTP_REFERER', $_SERVER)) {
         status::set("OLIV_REFERER", $_SERVER['HTTP_REFERER']);
     } else {
         status::set("OLIV_REFERER", OLIVRoute::url(system::lang(), system::oliv_index_page(), status::val()));
     }
     $this->route();
 }
コード例 #2
0
ファイル: routePlugin.php プロジェクト: nibble-arts/oliv
 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
ファイル: context.php プロジェクト: nibble-arts/oliv
 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;
 }