Exemplo n.º 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;
     }
 }
Exemplo n.º 2
0
 public static function xml($text, $lang = "")
 {
     if (!$lang) {
         $lang = status::lang();
     }
     if ($text) {
         // multilingual text found
         if ($text->text) {
             $textNode = $text->XPath("../.");
             $xpath = "text[@lang='{$lang}']";
             $default_xpath = "text[@lang='" . system::OLIV_DEFAULT_LANG() . "']";
             $tempText = $text->XPath($xpath);
             $defaultTempText = $text->XPath($default_xpath);
             // return language test
             if (count($tempText) > 0) {
                 return (string) $tempText[0];
             } else {
                 if (count($defaultTempText)) {
                     return (string) $defaultTempText[0];
                 }
             }
         } else {
             return (string) $text;
         }
     }
     return FALSE;
 }
Exemplo n.º 3
0
 public function get($table, $filter)
 {
     $this->query(status::lang(), "SELECT", $table, "", $filter);
     /*		while ($entry = $this->fetch())
     		{
     echoall($entry);
     		}*/
     return $this->fetch();
 }
Exemplo n.º 4
0
 public function page($page, $template)
 {
     if ($page->structure()) {
         // set parameters for stylesheet display
         $template->stylesheet->setParameter("", "lang", status::lang());
         $template->stylesheet->setParameter("", "user", status::OLIV_USER());
         // start stylesheet processor
         return $template->stylesheet->transformToXML($page->structure());
     }
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 public function process($page)
 {
     $content = $page->structure();
     if ($content) {
         $lang = status::lang();
         $default_lang = system::OLIV_DEFAULT_LANG();
         $texts = $content->XPath("//*/*[text]");
         // translate all texts
         for ($i = 0; $i < count($texts); $i++) {
             $text = OLIVText::xml($texts[$i]);
             // set correct language in node
             if (is_array($texts)) {
                 if (array_key_exists($i, $texts)) {
                     if ($texts[$i]->text) {
                         unset($texts[$i]->text);
                         $texts[$i]->text = $text;
                     }
                 }
             }
         }
     }
     //echoall($content);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
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");
 }
Exemplo n.º 11
0
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']);
}
// set val from friendly url
if (array_key_exists('val', $pathInfo)) {
    status::set('val', $pathInfo['val']);
}
//------------------------------------------------------------------------------
// update clipboard
//------------------------------------------------------------------------------
// language definition => loaded from argv
//TODO
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
 public static function makeUrl($lang, $url)
 {
     $valArray = array();
     if ($url) {
         $routeArray = array(system::OLIV_PROTOCOL() . system::OLIV_HOST() . system::OLIV_BASE() . system::OLIV_SCRIPT_NAME());
         if ($lang) {
             array_push($routeArray, $lang);
         } else {
             $lang = status::lang();
         }
         // use friendly name for url
         $path = OLIVRoute::makePath($url);
         // tranlsate and combine path
         foreach ($path as $entry) {
             array_push($valArray, OLIVRoute::translateFriendlyName($lang, $entry));
         }
         $val = implode("/", $valArray);
         if ($val) {
             array_push($routeArray, $val);
         }
         return implode("/", $routeArray);
     }
 }