Beispiel #1
0
 /**
  *
  * @return string 
  */
 public function getCode()
 {
     $res = "";
     if ($this->cacheName != "" && Cache::contains("tables", $this->cacheName)) {
         $res = Cache::getData("tables", $this->cacheName);
     } else {
         $res = "<table class='datatable'>";
         $this->columns->actions = $this->actions;
         $res .= $this->columns->getHeaderCode();
         $res .= "<tbody>";
         $rows_found = false;
         if ($rows = DataBase::Current()->ReadRows($this->getSelect())) {
             foreach ($rows as $row) {
                 $rows_found = true;
                 $res .= $this->columns->getBodyCode($row);
             }
         }
         if (!$rows_found) {
             $text = Language::GetGlobal()->Translate($this->noDataText);
             $res .= "<tr><td colspan='" . $this->columns->count() . "'>" . htmlentities($text) . "</td></tr>";
         }
         $res .= "</tbody>";
         $res .= "</table>";
         if ($this->cacheName) {
             Cache::setData("tables", $this->cacheName, $res);
         }
     }
     return $res;
 }
Beispiel #2
0
 public function load()
 {
     $this->headline = Language::DirectTranslate("plugin_menulistwidget_menus");
     if (Cache::contains("menu", "widget_" . $_GET['dir'])) {
         $this->content = Cache::getData("menu", "widget_" . $_GET['dir']);
     } else {
         if (!isset($_GET['dir']) || substr($_GET['dir'], 0, 1) == '.') {
             $_GET['dir'] = "";
         }
         $template = new Template();
         $template->load("plugin_menulistwidget_menulist");
         $newmenuurl = UrlRewriting::GetUrlByAlias("admin/newmenu");
         $template->assign_var("NEWMENUURL", $newmenuurl);
         $menus = sys::getMenues($_GET['dir']);
         foreach ($menus as $menu) {
             $index = $template->add_loop_item("MENUS");
             $template->assign_loop_var("MENUS", $index, "ID", $menu->id);
             $template->assign_loop_var("MENUS", $index, "TITLE", $menu->name);
             $template->assign_loop_var("MENUS", $index, "PAGES", $menu->count);
             $editurl = UrlRewriting::GetUrlByAlias("admin/editmenu", "menu=" . $menu->id);
             $template->assign_loop_var("MENUS", $index, "EDITURL", $editurl);
             $deleteurl = UrlRewriting::GetUrlByAlias("admin/deletemenu", "menu=" . $menu->id);
             $template->assign_loop_var("MENUS", $index, "DELETEURL", $deleteurl);
         }
         if (!$menus) {
             $template->assign_var("NOMENUS", Language::DirectTranslate("plugin_menulistwidget_no_menus"));
         } else {
             $template->assign_var("NOMENUS", "");
         }
         $this->content = $template->getCode();
         Cache::setData("menu", "widget_" . $_GET['dir'], $this->content);
     }
 }
Beispiel #3
0
 /**
  *
  * @param string $token 
  */
 public function __construct($token = null)
 {
     if ($token == null) {
         $token = Settings::getInstance()->get("language");
     }
     $this->language = $token;
     $alias = Page::Current()->alias;
     if (Cache::Contains("language", $token . "/" . $alias)) {
         $this->cache = Cache::getData("language", $token . "/" . $alias);
     }
 }
Beispiel #4
0
 public function load()
 {
     $dir = '';
     if (isset($_GET['dir']) && substr($_GET['dir'], 0, 1) != '.') {
         $dir = $_GET['dir'];
     }
     $this->headline = Language::DirectTranslate("plugin_pagelistwidget_pages");
     if (Cache::contains("page", "widget_" . $dir)) {
         $this->content = Cache::getData("page", "widget_" . $dir);
     } else {
         $template = new Template();
         $template->load("plugin_pagelistwidget_pagelist");
         $pages = Page::getPagesByDir($dir);
         if (substr($dir, 0, 1) == "/") {
             $shortdir = substr($dir, 1);
         } else {
             $shortdir = $dir;
         }
         if ($pages) {
             foreach ($pages as $page) {
                 $shortalias = substr($page->alias, strlen($shortdir));
                 if (substr($shortalias, 0, 1) == "/") {
                     $shortalias = substr($shortalias, 1);
                 } else {
                     $shortalias = $shortalias;
                 }
                 if (!strpos($shortalias, "/")) {
                     $host = Settings::getInstance()->get("host");
                     $index = $template->add_loop_item("PAGES");
                     $template->assign_loop_var("PAGES", $index, "TITLE", $page->title);
                     $template->assign_loop_var("PAGES", $index, "ALIAS", $shortalias);
                     $editurl = UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $page->alias);
                     $template->assign_loop_var("PAGES", $index, "EDITURL", $editurl);
                     $deleteurl = UrlRewriting::GetUrlByAlias("admin/pagedelete", "site=" . $page->alias);
                     $template->assign_loop_var("PAGES", $index, "DELETEURL", $deleteurl);
                     $showurl = UrlRewriting::GetUrlByAlias($page->alias);
                     $template->assign_loop_var("PAGES", $index, "SHOWURL", $showurl);
                 }
             }
             $template->assign_var("NOPAGES", "");
         } else {
             $template->assign_var("NOPAGES", Language::DirectTranslate("plugin_pagelistwidget_no_pages"));
         }
         $this->content = $template->getCode();
         if (isset($_GET['dir'])) {
             Cache::setData("page", "widget_" . $_GET['dir'], $this->content);
         }
     }
 }
Beispiel #5
0
 /**
  *
  * @return Role 
  */
 public static function getAllRoles()
 {
     if (Cache::contains("roles", "all")) {
         $res = Cache::getData("roles", "all");
     } else {
         $roles = DataBase::Current()->ReadRows("SELECT id FROM {'dbprefix'}roles ORDER BY name, id");
         foreach ($roles as $role) {
             $newRole = new Role();
             $newRole->load($role->id);
             $res[] = $newRole;
         }
         Cache::setData("roles", "all", $res);
     }
     return $res;
 }
Beispiel #6
0
 static function includeHeader()
 {
     echo "<title>" . htmlentities(Page::Current()->title) . Settings::getValue("title_extention") . "</title>";
     if (Cache::contains("htmlmeta", Page::Current()->id)) {
         echo Cache::getData("htmlmeta", Page::Current()->id);
     } else {
         $cache = "";
         $rows = DataBase::Current()->ReadRows("SELECT name, content\n                            FROM {'dbprefix'}meta_global\n                            UNION SELECT name, content\n                            FROM {'dbprefix'}meta_local\n                            WHERE page = '" . Page::Current()->id . "'");
         if ($rows) {
             foreach ($rows as $row) {
                 echo "<meta name=\"" . htmlentities($row->name) . "\" content=\"" . htmlentities($row->content) . "\" />";
                 $cache .= "<meta name=\"" . htmlentities($row->name) . "\" content=\"" . htmlentities($row->content) . "\" />";
             }
         }
         Cache::setData("htmlmeta", Page::Current()->id, $cache);
     }
     echo Page::Current()->getHeader();
     EventManager::RaiseEvent("header_included", null);
 }
Beispiel #7
0
 /**
  * 
  * @return array;
  */
 public static function GetAllHandler()
 {
     $res = self::$handler;
     if ($res == null) {
         if (Cache::contains("eventmanager", "handler")) {
             $res = Cache::getData("eventmanager", "handler");
         } else {
             $rows = DataBase::Current()->ReadRows("SELECT * FROM {'dbprefix'}events");
             foreach ($rows as $handler) {
                 if (!isset($item[$handler->event])) {
                     $res[$handler->event] = array();
                 }
                 $res[$handler->event][] = $handler->file;
             }
             Cache::setData("eventmanager", "handler", $res);
             self::$handler = $res;
         }
     }
     return $res;
 }
Beispiel #8
0
 public function load()
 {
     $this->headline = "Updater";
     include_once 'interfaces/iupdateimporter.php';
     include_once 'interfaces/iupdatecommand.php';
     if (Cache::contains("packages", "all")) {
         $installedPackages = $this->content = Cache::getData("packages", "all");
     } else {
         $installedPackages = Plugin_Updater_Package::readFromDB();
         Cache::setData("packages", "all", $installedPackages);
     }
     $path = "http://connect.contentlion.org/update.php?format=xml";
     $i = 0;
     if (is_array($installedPackages)) {
         foreach ($installedPackages as $package) {
             $path .= "&" . $package->getUpdateToken($i);
             $i++;
         }
     }
     $importer = new Plugin_Updater_UpdateXmlImporter();
     $importer->importPath($path);
     if ($importer->areUpdatesAvailible()) {
         $host = Settings::getInstance()->get("host");
         foreach ($importer->getUpdates() as $update) {
             if (isset($_GET['update']) && $_GET['update'] == $update->getName()) {
                 $this->content .= "<br />" . Language::DirectTranslate("install_it") . " " . $update->getName() . "...";
                 $update->runUpdate();
                 Cache::clear();
                 $this->content .= "<br />" . htmlentities(Language::DirectTranslate("plugin_updater_install_complete"));
             } else {
                 $this->content .= "<br />" . $update->getName() . " - <a href='" . $host . "admin/home.html?update=" . $update->getName() . "'>" . Language::DirectTranslate("plugin_updater_install") . "</a>";
             }
         }
     } else {
         $this->content = Language::DirectTranslate("plugin_updater_no_updates");
     }
 }
Beispiel #9
0
 /**
  *
  * @return string
  */
 function getBreadcrumb()
 {
     if (Cache::contains("breadcrumb", $this->id)) {
         $res = Cache::getData("breadcrumb", $this->id);
     } else {
         if (!$this->owner) {
             $this->getOwner(true);
         }
         if ($this->owner) {
             $res = $this->owner->getBreadcrumb();
         }
         $res[] = array($this->alias, $this->title);
         Cache::setData("breadcrumb", $this->id, $res);
     }
     return $res;
 }
Beispiel #10
0
 /**
  *
  * @param string $area
  * @param string $areatype
  * @param string $dir
  * @return Settings 
  */
 protected static function getCached($area, $areatype, $dir)
 {
     $res = null;
     $role = self::getRoleID();
     $res = new Settings();
     $res->setAreaType($areatype);
     $res->setArea($area);
     $res->setDir($dir);
     if (Cache::contains("settings", $area . "|" . $areatype . "|" . $dir . "|" . $role)) {
         $res->properties = Cache::getData("settings", $area . "|" . $areatype . "|" . $dir . "|" . $role);
     }
     return $res;
 }