コード例 #1
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;
 }
コード例 #2
0
ファイル: formPlugin.php プロジェクト: nibble-arts/oliv
 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;
 }
コード例 #3
0
ファイル: textPlugin.php プロジェクト: nibble-arts/oliv
 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;
     }
 }
コード例 #4
0
ファイル: breadcrumb.php プロジェクト: nibble-arts/oliv
 function __construct($header)
 {
     $this->content = OLIVModule::load_content($header);
     $pathActive = count(status::path());
     // get path
     if (array_key_exists("path", $_SESSION)) {
         $path = $_SESSION['path'];
     } else {
         $path = array();
     }
     // insert start page link if not active
     if ($path[0] != system::OLIV_INDEX_PAGE()) {
         $homePage = OLIVRoute::translateName(status::lang(), system::OLIV_INDEX_PAGE());
         $newNode = $this->content->addChild("path_point", $homePage);
         $newNode->addAttribute("href", system::OLIV_INDEX_PAGE());
         if ($pathActive == 0) {
             $newNode->addAttribute("class", "breadcrumb_active");
         } else {
             $newNode->addAttribute("class", "breadcrumb");
         }
     }
     // insert all links in hyrarchy
     $x = 1;
     foreach ($path as $page) {
         $pageName = OLIVRoute::translateName(status::lang(), $page);
         $newNode = $this->content->addChild("path_point", $pageName);
         $newNode->addAttribute("href", $page);
         if ($pathActive == $x) {
             $newNode->addAttribute("class", "breadcrumb_active");
         } else {
             $newNode->addAttribute("class", "breadcrumb");
         }
         $x++;
     }
     //echoall($this->content);
     $this->template = OLIVModule::load_template($header);
 }
コード例 #5
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;
 }
コード例 #6
0
ファイル: menu.php プロジェクト: nibble-arts/oliv
 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");
 }
コード例 #7
0
ファイル: init.php プロジェクト: nibble-arts/oliv
argv::remove('url');
//TODO create command and cmd-val
if (argv::val()) {
    $valArray = explode("/", argv::val());
    status::set('command', $valArray[0]);
    array_shift($valArray);
    status::set('cmdval', implode("/", $valArray));
}
//TODO val created by router
status::set('val', argv::val());
argv::remove('val');
//------------------------------------------------------------------------------
// decode friendly url to parameters without mod_rewrite
//TODO look if .htaccess exist
if (isset($_SERVER['PATH_INFO'])) {
    $pathInfo = OLIVRoute::decode($_SERVER['PATH_INFO'], array("lang", "url"));
} else {
    $pathInfo = array();
}
// set language from friendly url
if (array_key_exists('lang', $pathInfo)) {
    status::set('lang', $pathInfo['lang']);
}
// if no language set -> use default
if (!status::lang()) {
    status::set('lang', system::OLIV_DEFAULT_LANG());
}
// set url from friendly url
if (array_key_exists('url', $pathInfo)) {
    status::set('url', $pathInfo['url']);
}
コード例 #8
0
ファイル: route.php プロジェクト: nibble-arts/oliv
 public static function getPage($urlArray)
 {
     $urlPart = array_pop($urlArray);
     $urlId = (string) OLIVRoute::getUrl($urlPart);
     // url found => return ID
     if ($urlId) {
         return $urlId;
     } else {
         if (count($urlArray)) {
             return OLIVRoute::getPage($urlArray);
         } else {
             return FALSE;
         }
     }
 }