public function make() { if (!$this->query || !$this->url) { return false; } // get the current page if (!isset($this->current_page)) { if (isset($_GET[$this->GET_param])) { $this->current_page = $_GET[$this->GET_param]; } else { $this->current_page = 1; } } // get count of all items if (!preg_match('#^SELECT(.*?)FROM(.*?)$#is', $this->query)) { return false; } $query = preg_replace('#SELECT(.*?)FROM#is', 'SELECT COUNT(*) as count FROM', $this->query); $sql = new MySQLObject(); if (!$sql->query($query)) { return false; } $count = $sql->fetch_one(); $this->count = $count->count; // get count of all pages $this->pages_count = ceil($this->count / $this->per_page); $this->made = true; return true; }
public function edit_item() { $sql = new MySQLObject(); if ($sql->query("\r\nSELECT `header`,`link`,`show`\r\nFROM " . $sql->table('menu') . "\r\nWHERE (`iid` = " . intval($_GET['iid']) . ")") && $sql->num() > 0) { $item = $sql->fetch_one(); global $tpl, $cfg; $tpl->assign(array('ITEM.HEADER' => $item->header, 'ITEM.LINK' => $item->link, 'ITEM.SHOW_TRUE' => $item->show == 1 ? $cfg['tpl']['checked'] : '', 'ITEM.SHOW_FALSE' => $item->show == 0 ? $cfg['tpl']['checked'] : '')); } }
public function editpage() { global $q, $tpl; $sql = new MySQLObject(); if ($sql->query("\r\nSELECT\r\n\t" . $q->table('pages') . ".`pid`,\r\n\t" . $q->table('pages') . ".`header`,\r\n\t" . $q->table('pages') . ".`slug`,\r\n\t" . $q->table('pages') . ".`path`,\r\n\t" . $q->table('pages') . ".`content`,\r\n\t" . $q->table('pages') . ".`parent`\r\nFROM " . $q->table('pages') . "\r\nWHERE (" . $q->table('pages') . ".`pid` = " . intval($_GET['pid']) . ")\r\n")) { $page = $sql->fetch_one(); $fck = new FCKeditor('page[content]'); $fck->BasePath = './app/lib/js/fckeditor/'; $fck->Value = $page->content; $fck->Height = 512; ob_start(); $fck->Create(); $content = ob_get_contents(); ob_end_clean(); $tpl->assign(array('PAGE.ID' => $page->pid, 'PAGE.HEADER' => $page->header, 'PAGE.SLUG' => $page->slug, 'PAGE.PATH' => $page->path, 'PAGE.CONTENT' => isset($content) ? $content : $page->content, 'PAGE.CONTENT_GEEEDIT' => str_replace("\r\n", "'+\r'", $page->content), 'PAGE.PARENT' => $page->parent)); } }
function mainmenu_getorder() { $sql = new MySQLObject(); if ($sql->query("SELECT `order` FROM " . $sql->table('menu') . " ORDER BY `order` DESC LIMIT 0,1")) { if ($sql->num() > 0) { $order = $sql->fetch_one(); return $order->order; } else { return 0; } } else { return false; } }
public function group() { global $q, $tpl; $sql = new MySQLObject(); if ($sql->query("SELECT `name`,`description` FROM " . $q->table('users_groups') . " WHERE (`gid` = " . intval($_GET['gid']) . ")")) { $group = $sql->fetch_one(); $tpl->assign(array('GROUP.HEADER' => $group->name, 'GROUP.DESCRIPTION' => $group->description)); } }
public function menu_add_items_categories() { $items = array(); $sql = new MySQLObject(); if ($sql->query("SELECT `header` FROM " . $sql->table('blog_categories') . " WHERE (`cid` = -1)")) { $category = $sql->fetch_one(); $items[] = array('ADD_TEXT' => $category->header, 'ADD_LINK' => './action.php?c=menu&mode=add&module=blog&cid=-1'); if ($sql->query("SELECT `cid`,`header` FROM " . $sql->table('blog_categories') . " WHERE (`cid` != -1) ORDER BY `slug` ASC")) { foreach ($sql->fetch() as $category) { $items[] = array('ADD_TEXT' => $category->header, 'ADD_LINK' => './action.php?c=menu&mode=add&module=blog&cid=' . $category->cid); } } } return $items; }