config = $config; // get browser's device require_once "system/libs/mobile_detect.php"; $deviceDetector = new Mobile_Detect(); if($_GET["version"] == "desktop" ) { $this->browser_device = 0; } elseif($_GET["version"] == "mobile") { $this->browser_device = 2; } elseif($deviceDetector->isAndroidtablet() || $deviceDetector->isIpad()) { $this->browser_device = 1; } elseif($deviceDetector->isMobile()) { $this->browser_device = 2; } // get URI and remove any trailing slash $this->uri = $_GET["u"]; if ($this->uri[strlen($this->uri) - 1] == "/") $this->uri = substr($this->uri, 0, strlen($this->uri) - 1); $this->url = $this->config["site_url"] . "/" . $this->uri; $this->uri_segments = array(); $this->uri_segments = explode("/", $this->uri); $this->DB = new DB(); $this->DB->connect($this->config["db_host"], $this->config["db_user"], $this->config["db_password"], $this->config["db_database"], $this->config["db_prefix"]); $iplogs = new Channel_IPLogs($this); if (strstr($this->uri, "filter-keywords")) die(); if (strstr($this->uri, "filter-category")) die(); if (strstr($this->uri, "filter-tag")) die(); if (strstr($this->uri, "recommend")) die(); if (in_array($_SERVER["REMOTE_ADDR"], array("95.2", "94.2", "5.39.", "37.5", "112.", "114.", "118.", "116."))) die(); /* if (!in_array($_SERVER["REMOTE_ADDR"], array("194.212.248.9"))) { die(); } */ /* $iplog["created"] = date("Y-m-d H:i:s"); $iplog["ip"] = $_SERVER["REMOTE_ADDR"]; $iplog["url"] = $this->uri; $iplogs->insert($iplog); */ // caching $caching_active = false; $caching_exclusions = array("cms", "processor", "feed"); if (!$this->isDeveloper() && $this->config["cache_enabled"] && $this->uri_segments[0] != "" && !in_array($this->uri_segments[1], $caching_exclusions)) { $caching_active = true; if($this->browser_device == 2) { $mobile = "_mobile"; } else { $mobile = ""; } $cache_file = $this->config["site_abs_path"] . "/cache/pages/" . str_replace("/", "--", $_GET["u"]) . $mobile; if (file_exists($cache_file) && (time() - filemtime($cache_file)) / 60 < $this->config["cache_refresh_interval"]) { $content = file_get_contents($cache_file); $content .= ""; //$t = (time() - filemtime($cache_file)) / 60; //$content .= ""; echo $content; die; } else { ob_start(); } } // instantiate core classes $this->Session = new Session($this); $this->Auxiliary = new Auxiliary($this); $this->Validation = new Validation($this); $this->Notification = new Notification($this); $this->Debug = new Debug($this); if ($this->config["debug_enabled"] && $this->isDeveloper()) $this->Debug->enable(); $this->Upload = new Upload($this); $this->Mail = new Mail($this); $this->CMS = new CMS($this); $this->Captcha = new PhpCaptcha(array('assets/fonts/VeraBd.ttf', 'assets/fonts/VeraIt.ttf', 'assets/fonts/Vera.ttf'), 200, 60); $this->Nodes = $this->loadModule("Nodes"); // test if installed /* $probe = $this->DB->selectSingle("SELECT table_name FROM information_schema.tables WHERE table_name = 'languages'"); if (empty($probe) && $this->uri_segments[0] != "install") { $this->lang_code = 'en'; $this->loadLang("langs/" . $this->lang_code . ".php"); $this->loadLang("system/langs/lang_" . $this->lang_code . ".php"); $this->loadTemplate("cms/install.php"); die; } */ // run installer if needed if ($this->uri_segments[0] == "install") { die; $this->DB->query(" CREATE TABLE IF NOT EXISTS languages ( id int(11) unsigned NOT NULL auto_increment, value_cs varchar(255), value_en varchar(255), code varchar(2), active tinyint(4), is_default tinyint(4), PRIMARY KEY (id), KEY code (code) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" INSERT IGNORE INTO languages (id, value_cs, value_en, code, active, is_default) VALUES (2, 'čeština', 'Czech', 'cs', 1, 0), (1, 'angličtina', 'English', 'en', 1, 1); "); // problém s instalátorem: doplnit table varchar(255) NOT NULL, $this->DB->query(" CREATE TABLE IF NOT EXISTS channels ( id tinyint(3) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL, channel varchar(255) NOT NULL, module varchar(255) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" CREATE TABLE IF NOT EXISTS templates ( id smallint(5) unsigned NOT NULL auto_increment, type_id smallint(5) unsigned NOT NULL, name varchar(255) NOT NULL, file varchar(255) NOT NULL, channel_id int(11) NOT NULL, group_id smallint(5) NOT NULL, PRIMARY KEY (id), KEY channel_id (channel_id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" CREATE TABLE IF NOT EXISTS modules ( id int(10) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL, version varchar(12) NOT NULL, state_id smallint(6) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" CREATE TABLE IF NOT EXISTS module_states ( id smallint(5) unsigned NOT NULL auto_increment, value_en varchar(128) NOT NULL default '', value_cs varchar(128) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" CREATE TABLE IF NOT EXISTS module_actions ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `module_id` int(10) unsigned NOT NULL, `action` varchar(255) NOT NULL, `value_cs` varchar(255) NOT NULL, `value_en` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" INSERT IGNORE INTO module_states (id, value_en, value_cs) VALUES (1, 'inactive', 'neaktivní'), (2, 'active', 'aktivní'), (3, 'missing', 'chybí'); "); $this->DB->query(" CREATE TABLE IF NOT EXISTS nodes ( id int(10) unsigned NOT NULL auto_increment, parent_id int(10) unsigned default NULL, template_id smallint(6) default NULL, weight int(11) default NULL, hook varchar(128) NOT NULL, PRIMARY KEY (id), KEY parent_id (parent_id), KEY template_id (template_id), KEY hook (hook) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->DB->query(" CREATE TABLE IF NOT EXISTS node_versions ( id int(10) unsigned NOT NULL auto_increment, node_id int(11) NOT NULL, lang_id int(11) NOT NULL, title varchar(255) NOT NULL, navigation_enabled tinyint(4) NOT NULL, navigation varchar(255) NOT NULL default '', uri varchar(255) NOT NULL, meta_title varchar(255) NOT NULL, description varchar(255) NOT NULL, keywords varchar(255) NOT NULL, created datetime NOT NULL, published tinyint(2) NOT NULL, body text NOT NULL, excerpt text NOT NULL, params varchar(255) NOT NULL, filter varchar(255) NOT NULL, PRIMARY KEY (id), KEY node_id (node_id), KEY lang_id (lang_id), KEY uri (uri) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; "); $this->installNode(1, "templates/home.php", "", "cs", "Domů", 0, "ROOT"); $this->installNode(1, "templates/home.php", "", "en", "Home", 0, "ROOT"); $this->installNode(1, "cms/dashboard.php", "ROOT", "cs", "CMS", 0, "CMS"); $this->installNode(1, "cms/dashboard.php", "ROOT", "en", "CMS", 0, "CMS"); $this->installNode(1, "cms/installed.php", "CMS", "cs", "Instalace dokončena", 0, "INSTALLED"); $this->installNode(1, "cms/installed.php", "CMS", "en", "Installation Completed", 0, "INSTALLED"); $this->installNode(1, "cms/dashboard.php", "CMS", "cs", "Přehled", 1, "DASHBOARD"); $this->installNode(1, "cms/dashboard.php", "CMS", "en", "Dashboard", 1, "DASHBOARD"); $this->installNode(1, "cms/content.php", "CMS", "cs", "Obsah", 1, "CONTENT"); $this->installNode(1, "cms/content.php", "CMS", "en", "Content", 1, "CONTENT"); $this->installNode(1, "cms/settings.php", "CMS", "cs", "Nastavení", 1, "SETTINGS"); $this->installNode(1, "cms/settings.php", "CMS", "en", "Settings", 1, "SETTINGS"); $this->installNode(1, "cms/crm.php", "CMS", "cs", "CRM", 1, "CRM"); $this->installNode(1, "cms/crm.php", "CMS", "en", "CRM", 1, "CRM"); $this->installNode(1, "templates/sitemap.php", "ROOT", "cs", "Mapa stránek", 0, "SITEMAP"); $this->installNode(1, "templates/sitemap.php", "ROOT", "en", "Sitemap", 0, "SITEMAP"); $Modules = $this->loadModule("Modules"); // insert PHP injection protection here && is this call placed correctly? $Modules->activate("Nodes"); $Modules->activate("Files"); $Modules->activate("Users"); $Modules->activate("Modules"); //$this->loadTemplate("cms/installed.php"); header("location:" . $this->config["site_url"] . "/en/cms/installation-completed"); die; } else if ($this->uri_segments[0] == "sitemap.xml") { $this->loadTemplate("feeds/sitemap.php"); die; } // process language $lang = $this->DB->selectSingle("SELECT * FROM languages WHERE active = 1 AND code = '" . $this->uri_segments[0] . "'"); $lang_default = $this->DB->selectSingle("SELECT * FROM languages WHERE is_default = '1'"); if ($lang) { $this->Debug->trace("lang found in uri", "true"); $this->uri_segments[0] = ""; } else { $var = "HTTP_ACCEPT_LANGUAGE"; if (!empty($GLOBALS['_SERVER'][$var])) $http_lang = $GLOBALS['_SERVER'][$var]; else $http_lang = $GLOBALS['HTTP_SERVER_VARS'][$var]; $lang = substr($http_lang, 0, 2); if ($this->DB->selectCount("SELECT * FROM languages WHERE active = 1 AND code = '" . $lang . "'") <= 0) $lang = $lang_default["code"]; header("location:" . $this->config["site_url"] . "/" . $lang); die; $lang = $this->DB->selectSingle("SELECT * FROM languages WHERE code = '" . substr($http_lang, 0, 2) . "'"); } $this->lang_code = $lang["code"]; $this->lang_id = $lang["id"]; $this->Debug->trace("lang", $this->lang_code); $this->loadLang("langs/" . $this->lang_code . ".php"); $this->loadLang("system/langs/lang_" . $this->lang_code . ".php"); // parse request $this->parseRequest(); // instantiate core modules $this->Nodes = $this->loadModule("Nodes"); $this->Files = $this->loadModule("Files"); $this->Users = $this->loadModule("Users"); $this->languages = new Channel_Languages($this); $this->countries = new Channel_Countries($this); $this->channels = new Channel_Channels($this); // parse URI if ($this->uri_segments[1] == "processor") { if ($this->uri_segments[2] && $this->uri_segments[3]) { $target = $this->uri_segments[2]; $operation = $this->uri_segments[3]; } else { // deprecated, left for compatibility reasons only if (!isset($_REQUEST["target"])) $_REQUEST["target"] = $_REQUEST["source"]; $target = $_REQUEST["target"]; $operation = $_REQUEST["operation"]; } if ($target && $operation) { $Module = $this->loadModule(ucfirst($target)); // insert PHP injection protection here if (method_exists($Module, "operation_" . $operation)) { $Module->preprocessOperation(); if ($this->Validation->isOK()) { eval('$result = $Module->operation_' . $operation . '();'); } $Module->postprocessOperation(); } else if (method_exists($Module, "extop_" . $operation)) { $Module->preprocessOperation(); if ($this->Validation->isOK()) { eval('$result = $Module->extop_' . $operation . '();'); } $Module->postprocessOperation(); } else if (method_exists($Module, "intop_" . $operation)) { if ($this->Session->isLoggedIn()) { $Module->preprocessOperation(); if ($this->Validation->isOK()) { eval('$result = $Module->intop_' . $operation . '();'); } $Module->postprocessOperation(); } else { echo "Error: Operation " . $operation . " is for internal use only."; die; } } else { echo "Error: Operation " . $operation . " does not exists."; die; } /* if (method_exists($Module, "operation_" . $operation)) eval('$result = $Module->operation_' . $operation . '();'); else { echo "Error: Operation " . $operation . " does not exists."; die; } */ } else { echo "Error: Incomplete processor request."; die; } } else if ($this->uri_segments[1] == "feed") { if (isset($_REQUEST["page"])) $this->page = $_REQUEST["page"] - 1; // temporary, filtering and sorting will need to be added if ($this->uri_segments[2] == "pdf") { require_once("system/third-party/dompdf/dompdf_config.inc.php"); $dompdf = new DOMPDF(); $dompdf->load_html_file($this->config["site_url"] . "/" . $this->lang_code . "/feed/" . $this->uri_segments[3] . "&uri=" . $_GET["uri"]); $dompdf->render(); $dompdf->stream("export.pdf"); } else { if (isset($_REQUEST["template"])) { $this->loadTemplate($_REQUEST["template"]); } else { $this->loadTemplate("feeds/" . $this->uri_segments[2] . ".php"); } } die; } else { // test if we were in window mode last time; if ture, add window more param and redirect if ((strpos($this->uri, "param-win") === false) && ( !(strpos($_SERVER['HTTP_REFERER'], "param-win") === false) || !(strpos($_SERVER['HTTP_REFERER'], "tiny_mce") === false) )) { header("location:" . $this->config["site_url"] . "/" . $this->uri . "/param-win"); } $this->filter = array(); $this->sorter = array(); $this->page = 0; // was -1 $this->uri_nodes = array(); $i = 0; $terminate = false; $page_not_found = false; $uri_node_last["id"] = 0; while ($i < count($this->uri_segments) && !$terminate && !$page_not_found) { $uri_segment = $this->uri_segments[$i]; $this->Debug->trace("uri segment", $uri_segment); $uri_node = $this->Nodes->nodes->selectSingle("published = 1 AND lang_id = " . $this->lang_id . " AND parent_id = " . $uri_node_last["id"] . " AND uri = '$uri_segment'"); if (empty($uri_node)) { // first check if filter, paging, sorter or param if (strpos($uri_segment, "filter-") === 0) { $this->uri_filter .= $this->uri_segments[$i] . "/" . $this->uri_segments[$i + 1] . "/"; $name = str_replace("filter-", "", $this->uri_segments[$i]); $this->filter[$name] = $this->uri_segments[$i + 1]; //$this->Debug->trace("found filter $name", $this->uri_segments[$i + 1]); $i++; } else if (strpos($uri_segment, "sorter-") === 0) { $name = str_replace("sorter-", "", $this->uri_segments[$i]); $this->sorter[$name] = $this->uri_segments[$i + 1]; $i++; } else if (strpos($uri_segment, "page") === 0) { $this->page = $this->uri_segments[$i + 1] - 1; $i++; } else if (strpos($uri_segment, "param-") === 0) { // other parameters - to be sorted out $name = str_replace("param-", "", $this->uri_segments[$i]); if ($this->uri_segments[$i + 1] != "") $this->get[$name] = $this->uri_segments[$i + 1]; else $this->get[$name] = true; $i++; } else if ($uri_node_last["type_id"] == 2) { // then if not filter, paging or sorter, use default node $uri_node = $this->Nodes->nodes->selectSingle("templates.type_id = 3 AND lang_id = '" . $this->lang_id . "' AND parent_id = '" . $uri_node_last["id"] . "'"); if (!$uri_node) { $page_not_found = true; } else { $this->Debug->trace("found subst node", $uri_node["id"]); if ($uri_node_last["channel_id"] != 0) { $channel = $this->DB->selectSingle("SELECT * FROM channels WHERE id = '" . $uri_node_last["channel_id"] . "'"); $Module = $this->loadModule($channel["module"]); //echo 'eval ' . '$linked_channel = $Module->' . $channel["channel"] . ';'; eval('$linked_channel = $Module->' . $channel["channel"] . ';'); if (is_numeric($uri_segment)) { $uri_node["data"] = $linked_channel->selectSingle($channel["name"] . ".id = '$uri_segment'"); } else { //echo $channel["channel"]; $uri_node["data"] = $linked_channel->selectSingle("uri = '$uri_segment'"); /* // commented out for now as it needs to be implemented better if ($channel["versioned"] == 1) { $versions_table = substr($channel["name"], 0, -1) . "_versions"; $uri_node["data2"] = $linked_channel->selectSingle("lang_id = 2 AND " . $channel["name"] . ".id = '" . $uri_node["data"]["id"] . "' AND $versions_table.published = 1"); $uri_node["data1"] = $linked_channel->selectSingle("lang_id = 1 AND " . $channel["name"] . ".id = '" . $uri_node["data"]["id"] . "' AND $versions_table.published = 1"); } else { $uri_node["data2"] = $uri_node["data"]; $uri_node["data1"] = $uri_node["data"]; } */ } } $uri_node["param_id"] = $uri_segment; $this->uri_real .= $uri_segment . "/"; $this->uri_rest = $uri_segment; // for compatibility reasons $this->uri_nodes[] = $uri_node; $uri_node_last = $uri_node; } } else { $page_not_found = true; } } else { if ($uri_node["excerpt"] == "") $uri_node["excerpt"] = $uri_node_last["excerpt"]; // to be optimized $attachment = $this->Files->selectMainAttachment($uri_node["version_id"], "node_versions"); if ($attachment["full_name"] != ".") { $uri_node["image"] = $attachment; } else { $uri_node["image"] = $uri_node_last["image"]; } $this->uri_real .= $uri_segment . "/"; $this->uri_nodes[] = $uri_node; $uri_node_last = $uri_node; } $i++; } if ($page_not_found) { $this->loadTemplate("templates/404.php"); } else { $this->current_node = $this->uri_nodes[count($this->uri_nodes) - 1]; $this->url_real = $this->config["site_url"] . "/" . $this->lang_code . $this->uri_real; $this->Debug->trace("url_real", $this->url_real); // Apply default filter if ($this->current_node["filter"]) { $this->current_node["filter"] = str_replace("'", '"', $this->current_node["filter"]); $filter_doceded = json_decode($this->current_node["filter"], true); if ($filter_doceded) $this->filter = array_merge($filter_doceded, $this->filter); } // load template $Users = $this->loadModule("Users"); if ($this->current_node["group_id"] == 2 || $Users->canAccess($this->current_node["id"])) { $this->Debug->trace("template id", $this->current_node["template_id"]); $template = $this->DB->selectSingle("SELECT * FROM templates WHERE id = " . $this->current_node["template_id"]); $this->loadTemplate($template["file"]); } else { echo "Access forbidden."; die; } } } // Caching if ($caching_active) { $cached_output = ob_get_clean(); file_put_contents($cache_file, $cached_output); echo $cached_output; } } private function parseRequest() { if (!empty($_REQUEST)) { foreach($_REQUEST as $key => $value) { $request_segment = array(); $key_segments = explode("~", $key); if (count($key_segments) > 1) { $key = $key_segments[0]; $type = $key_segments[1]; if ($key_segments[2] == REQUEST_MANDATORY) $mandatory = true; else $mandatory = false; } else { $mandatory = 0; $type = REQUEST_DEFAULT; } //$request_segment["key"] = $key; $request_segment["mandatory"] = $mandatory; $request_segment["type"] = $type; if ($type == REQUEST_BOOLEAN) { //$this->Notification->addMessage("boolean"); //echo ""; if ($value == "on") $request_segment["value"] = 1; else $request_segment["value"] = 0; } elseif ($type == REQUEST_NUMBER) { $request_segment["value"] = $this->Auxiliary->unformatNumber($value); } elseif ($type == REQUEST_TIME) { $request_segment["value"] = $value; } elseif ($type == REQUEST_DATE) { $request_segment["value"] = $this->Auxiliary->unformatDate($value); if (isset($_REQUEST["$key~12~$key_segments[2]"])) { $request_segment["value"] .= " " . $_REQUEST["$key~12~$key_segments[2]"]; } } elseif ($type == REQUEST_ARRAY) { $request_segment["value"] = $value; } elseif ($type == REQUEST_HTML) { $request_segment["value"] = $value; } else { $this->Notification->addMessage("$value"); $request_segment["value"] = $value; /*$request_segment["value"] = htmlentities($value);*/ } if ($this->request[$key] == "") $this->request[$key] = $request_segment; //var_dump($_REQUEST["categories~13~opt"]); } } //var_dump($this->request["email"]); } public function getRequest($_key) { return $this->request[$_key]["value"]; } public function encodeRequest($_key, $_type, $_mandatory = 0) { return "$_key~$_type~$_mandatory"; } function getLastNode() { return $this->uri_nodes[count($this->uri_nodes) - 1]; } function loadTemplate($_template_file) { $templateFilePath = explode("/",$_template_file); $templateFileName = array_pop($templateFilePath); $mobileFile = $this->config["site_abs_path"]."/".implode("/", $templateFilePath)."/mobile/".$templateFileName; $file = $this->config["site_abs_path"] . "/" . $_template_file; if(file_exists($mobileFile) && $this->browser_device == 2) { require_once($mobileFile); } elseif (file_exists($file)) { //$file = $this->config["site_abs_path"] . $this->config["template_dir"] . "/" . $_template_file; require_once($file); } else { echo 'Error: Cannot locate the template "' . $_template_file . '".'; } } function loadLang($_lang_file) { $file = $this->config["site_abs_path"] . "/" . $_lang_file; if (file_exists($file)) { require_once($file); } else { echo 'Error: Cannot locate the language file "' . $_lang_file . '".'; } } function loadModule($_module_name) { $_module_dir = $this->config["site_abs_path"] . $this->config["module_dir"] . "/" . strtolower($_module_name); $_module_file = strtolower($_module_name) . ".php"; $_module_lang_file = $_module_dir . "/langs/" . $this->lang_code . ".php"; if (file_exists($_module_lang_file)) require_once($_module_lang_file); if (file_exists($_module_dir . "/" . $_module_file)) { require_once($_module_dir . "/" . $_module_file); eval('$module = new ' . $_module_name . '($this);'); return $module; } else { echo "CMS Error: Module $_module_name not found."; return false; } } public function placeBreadcrumb($_rest = "") { echo $this->Nodes->getBreadcrumb($this->uri_nodes); /* $i = 0; $uri = $this->config["site_url"] . "/" . $this->lang_code . "/"; if ($this->uri_nodes) foreach ($this->uri_nodes as $node) { $uri .= $node["uri"]; if ($i == 0) { echo '' . $this->config["site_title"] . ' » '; } else if ($node["uri"] == $this->current_node["uri"]) { echo $node["title"]; } else { echo '' . $node["title"] . ' » '; } $uri .= "/"; $i++; } if ($_rest) { echo " " . $_rest; } */ } function getURL($_uri) { $url = $this->config["site_url"] . "/" . $this->lang_code; if ($url[strlen($url) - 1] != "/" && $_uri[0] != "/") $url .= "/"; return $url . $_uri; } // most of the below will be deprecated function placeURL($_node_id) { $node = $this->Nodes->nodes->selectSingle("nodes.id = $_node_id AND lang_id = $this->lang_id AND published = 1"); if ($node) { $uri = $this->getURI($_node_id, $this->lang_id); echo $this->config["site_url"] . "/" . $this->lang_code . "/" . $uri; } } public function getLocalizedURI($_lang_id) { $uri_segments = array(); $incomplete = false; $i = 0; while ($i < count($this->uri_nodes) && !$incomplete) { $node = $this->uri_nodes[$i]; if ($node["type_id"] == 3) { $uri_segments[] = $node["data"]["uri"]; //$uri_segments[] = $node["data$_lang_id"]["uri"]; } else { $version = $this->Nodes->selectVersion($node["id"], $_lang_id, "published = 1"); if ($version) $uri_segments[] = $version["uri"]; else $incomplete = true; } $i++; } return implode("/", $uri_segments); } function placeRelativeURL($_uri) { $url = $this->url_real; if ($url[strlen($url) - 1] != "/" && $_uri[0] != "/") $url .= "/"; return $url . $_uri; } public function placeLang() { $langs = $this->languages->selectList("active = 1"); $i = 0; if (count($langs) > 1) { foreach ($langs as $lang) { if ($i == count($langs) - 1) $class = "last"; else $class = ""; if ($lang["id"] == $this->lang_id) $class .= " current"; echo 'getLocalizedURI($lang["id"]) . '">' . $lang["code"] . ''; $i++; } } } // needs to be optimized and made consistent with classes public function getFilterURI() { if ($this->filter) { $filter_segments = array(); foreach ($this->filter as $key => $value) { $filter_segments[] = "filter-" . $key . "/" . $value; } return implode("/", $filter_segments) . "/"; } } public function getSorterURI() { if ($this->sorter) { $sorter_segments = array(); foreach ($this->sorter as $key => $value) { $sorter_segments[] = "sorter-" . $key . "/" . $value; } return implode("/", $sorter_segments) . "/"; } } // deprecated public function placeNav($_parent_id = 1) { $parent_node = $this->Nodes->nodes->selectSingle("published = 1 AND nodes.id = '$_parent_id'"); $nodes = $this->Nodes->nodes->selectList("lang_id = $this->lang_id AND navigation_enabled = '$_parent_id' AND published = 1 AND parent_id = 1", FILTERING_OFF, SORTING_OFF, PAGING_OFF, "weight ASC"); // ORDER BY weight $i = 0; if ($nodes) { echo ''; } elseif ($parent_node["type_id"] == 2 && $parent_node["channel_id"] != 0) { //if ($this->isDeveloper()) { /* $object = $this->DB->selectSingle("SELECT * FROM channels WHERE id = '" . $parent_node["channel_id"] . "'"); $Module = $this->loadModule($object["name"]); $nodes = $Module->selectNav(); echo ''; */ //} } } public function setDefaultSorter($_name, $_dir) { if (empty($this->sorter)) $this->sorter["$_name"] = $_dir; } public function placeTitle() { if ($this->current_node["meta_title"] != "") { $title = $this->current_node["meta_title"]; $title .= " | "; } else { if ($this->current_node["parent_id"] != 0) { if ($this->current_node["data"]) $title = $this->current_node["data"]["name"]; else $title = $this->current_node["title"]; $title .= " | "; } } $title .= $this->config["site_title"]; if ($this->current_node["description"] != "") $description = $this->current_node["description"]; else $description = STR_META_DESCRIPTION; if ($this->current_node["data"]["meta_description"]) $keywords = $this->current_node["data"]["meta_description"]; else if ($this->current_node["description"] != "") $keywords = $this->current_node["keywords"]; else $keywords = STR_META_KEYWORDS ?>