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); }
public static function getGroupName($user) { $groups = OLIVUser::getGroup($user); $groupArray = array(); foreach ($groups as $entry) { $groupId = $entry->getName(); array_push($groupArray, OLIVText::xml($entry->name)); } return implode(", ", $groupArray); }
public static function _($text, $lang = "") { $systemText = system::systemtext(); $textXml = $systemText->XPath("//{$text}"); return OLIVText::xml($textXml[0], $lang); }
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"); }
public static function translateFriendlyName($lang, $url) { $pages = status::pages(); // return friendly name if ($name = OLIVText::xml($pages->{$url}->friendly_name, $lang)) { // get page path from status::pages() // $name = OLIVRoute::getRootPath($url); return $name; } else { $pageInfo = OLIVRoute::updatePageXml($url); if ($pageInfo) { return OLIVText::xml($pageInfo->friendly_name); } else { return FALSE; } } }
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); }