public function getContent() { global $sql; $pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users')); $pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc'); $query = $sql->query(' SELECT id, name, inline, members FROM ' . DB_PREFIX . 'groups ORDER BY display_order'); while ($row = $query->fetch()) { if ($row['inline']) { $row['name'] = sprintf($row['inline'], $row['name']); } $groups[] = $row; } $query = $sql->query(' SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name FROM ' . DB_PREFIX . 'users u LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id ORDER BY ' . $pager->orderBy . ' LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); while ($row = $query->fetch()) { $row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']); switch ($row['gender']) { case 1: $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />'; break; case 2: $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />'; break; default: $row['gender'] = ''; } $users[] = $row; } try { $tpl = new PHPTAL('modules/users/users.tpl.html'); $tpl->sort = $pager->sorters; $tpl->users = $users; $tpl->groups = $groups; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } }
public function getContent() { global $sql; $this->err = new Error(); $pager = new Pager('guestbook', Kio::getStat('entries', 'guestbook'), Kio::getConfig('limit', 'guestbook')); if (Kio::getConfig('order_by', 'guestbook') == 'DESC') { $x = $pager->items + 1 - $pager->offset; $y = '$x--;'; } else { $x = $pager->offset; $y = '$x++;'; } // $entries = $sql->getCache('guestbook_'.$pager->current); if (!$entries) { $stmt = $sql->query(' SELECT gb.id, gb.added, gb.author, gb.email, gb.website, gb.message, gb.author_id, gb.author_ip, u.nickname, u.group_id, u.avatar, u.signature FROM ' . DB_PREFIX . 'guestbook gb LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = gb.author_id ORDER BY gb.id ' . Kio::getConfig('order_by', 'guestbook') . ' LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); if ($stmt->rowCount()) { while ($row = $stmt->fetch()) { eval($y); $row['number'] = $x; if ($row['author_id']) { $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']); } $row['message'] = parse($row['message'], Kio::getConfig('parsers', 'guestbook')); $row['signature'] = $row['signature'] ? parse($row['signature'], Kio::getConfig('parsers', 'guestbook')) : ''; $entries[] = $row; } $sql->putCacheContent('guestbook_' . $pager->current, $entries); } else { $this->note->info('Jeszcze nikt nie dodał żadnego wpisu.'); } } // Editing entry if (ctype_digit(u2)) { // guestbook/edit/u2 $edited_id = u1 == 'edit' ? u2 : ''; if (!User::hasPermit('guestbook edit')) { $this->note->error(t('You do not have access to edit entries.')); } else { if ($edited_id) { $row = $sql->query(' SELECT id, added, author, author_id, author_ip, email, website, message FROM ' . DB_PREFIX . 'guestbook WHERE id = ' . $edited_id)->fetch(); // Entry exists if ($row) { $form = $row; $form['edit_mode'] = true; if (!$row['author']) { $form['author'] = User::getNickname(BY_ID, $row['author_id']); } } else { $this->note->error(t('Selected entry doesn't exist.')); } } } } if (!$form['edit_mode']) { $form['author'] = User::$nickname; } // Form action $add = $_POST['add'] ? true : false; $edit = $_POST['edit'] ? true : false; // On form submit if ($add || $edit) { $this->formSumbit(); } else { if (ctype_digit($_POST['delete_id']) && $_POST['auth'] == AUTH && User::hasPermit('guestbook delete')) { $sql->exec(' UPDATE ' . DB_PREFIX . 'stats SET content = content - 1 WHERE name = "guestbook_entries"; DELETE FROM ' . DB_PREFIX . 'guestbook WHERE id = ' . $_POST['delete_id']); $sql->clearCacheGroup('guestbook_*'); } } try { $tpl = new PHPTAL('modules/guestbook/guestbook.tpl.html'); $tpl->message_limit = Kio::getConfig('message_max', 'guestbook'); $tpl->form = $form; $tpl->entries = $entries; $tpl->err = $this->err->toArray(); $tpl->note = $this->note; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } }
private function getEntries() { global $sql; $pager_url = 'news'; $category_id = 0; if (u1 == 'category') { $category_id = (int) u2; } $total = Kio::getStat('entries', 'news'); if ($category_id) { $category = $sql->setCache('news_categories_' . $category_id)->query(' SELECT id, name, description, entries FROM ' . DB_PREFIX . 'news_categories WHERE id = ' . $category_id)->fetch(PDO::FETCH_ASSOC); if ($category) { $total = $category['entries']; if ($category['description']) { Kio::setDescription($category['name'] . ' - ' . $category['description']); } Kio::addTitle($category['name']); Kio::addBreadcrumb($category['name'], 'news/category/' . $category_id . '/' . clean_url($category['name'])); $pager_url = 'news/category/' . $category_id . '/' . clean_url($category['name']); } else { return not_found(t('Selected category does not exists.'), array(t('Category was moved or deleted.'), t('Entered URL is invalid.'))); } } if (!empty($category) || empty($category)) { $this->subcodename = 'entries'; $pager = new Pager($pager_url, $total, Kio::getConfig('limit', 'news')); $stmt = $sql->setCache('news_' . $category_id . '_' . $pager->current)->query(' SELECT u.nickname, u.group_id, c.id c_id, c.name c_name, c.description c_description, n.* FROM ' . DB_PREFIX . 'news n LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = n.author_id LEFT JOIN ' . DB_PREFIX . 'news_categories c ON c.id = n.category_id WHERE ' . ($category_id ? 'c.id = ' . $category_id . ' AND ' : '') . (LOGGED ? 'n.publication > 0' : 'n.publication = 1') . ' AND n.added < ' . TIMESTAMP . ' ORDER BY ' . Kio::getConfig('order_by', 'news') . ' LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); while ($row = $stmt->fetch()) { if ($row['author_id']) { $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']); } $row['url_title'] = ($row['c_name'] ? clean_url($row['c_name']) . '/' : '') . clean_url($row['title']); $row['content'] = parse($row['content'], Kio::getConfig('parsers', 'news')); $entries[] = $row; } try { $tpl = new PHPTAL('modules/news/news.tpl.html'); $tpl->entries = $entries; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } }
$kio->addPath(t('Newest'), 'gallery/newest'); } else { $order_by = 'views'; $kio->addPath(t('Popular'), 'gallery/popular'); } $module->name = t('Gallery'); $pager = new Pager('gallery/' . u1, $kio->stats['gallery_images'], $cfg->gallery['limit']); //$query = $sql->setCache('gallery_'.u1.'_'.$pager->current)->query(' $query = $sql->query(' SELECT id, name, description, added, views, rating, comments, file_extension FROM ' . DB_PREFIX . 'gallery_images ORDER BY ' . $order_by . ' DESC LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); while ($row = $query->fetch()) { if ($row['author_id']) { $row['author'] = User::format($row['author_id'], $row['nickname'], $row['name']); } $images[] = $row; } try { $tpl = new PHPTAL('modules/gallery/thumbnails.html'); $tpl->cfg = $cfg; $tpl->note = $note; $tpl->images = $images; $tpl->album = $album; $tpl->pagination = $pager->getLinks(); echo $tpl->execute(); } catch (Exception $e) { echo template_error($e); }
private function getCategory() { global $sql, $plug; if (u1 == 'newest') { $order_by = 'added'; Kio::addTitle(t('Newest')); Kio::addBreadcrumb(t('Newest'), 'gallery/newest'); } else { $order_by = 'views'; Kio::addTitle(t('Popular')); Kio::addBreadcrumb(t('Popular'), 'gallery/popular'); } $this->name = t('Gallery'); $pager = new Pager('gallery/' . u1, Kio::getStat('images', 'gallery'), Kio::getConfig('limit', 'gallery')); //$query = $sql->setCache('gallery_'.u1.'_'.$pager->current)->query(' $query = $sql->query(' SELECT id, name, description, added, views, rating, comments, file_extension FROM ' . DB_PREFIX . 'gallery_images ORDER BY ' . $order_by . ' DESC LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); while ($row = $query->fetch()) { if ($row['author_id']) { $row['author'] = User::format($row['author_id'], $row['nickname'], $row['name']); } $images[] = $row; } try { $tpl = new PHPTAL('modules/gallery/thumbnails.tpl.html'); $tpl->note = $note; $tpl->images = $images; $tpl->album = $album; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } }
private function getFolder($folder_id) { global $sql; Kio::addTitle(t(ucfirst(u1))); Kio::addBreadcrumb(t(ucfirst(u1)), 'pm/' . u1); $note = new Notifier(); $this->subcodename = 'box'; $pager = new Pager('pm/' . u1, User::${'pm' . ucfirst(u1)}, Kio::getConfig('limit', 'pm')); $pager->sort(array(t('Subject') => 'subject', t('Message') => 'message', u1 == 'outbox' ? t('To') : t('From') => 'nickname', t('Sent') => 'sent'), 'sent', 'asc'); // Reset new messages counter if (User::$pmNew) { $sql->exec('UPDATE ' . DB_PREFIX . 'users SET pm_new = 0 WHERE id = ' . UID); } if (isset($_POST['action']) && !empty($_POST['messages'])) { $action_messages = implode(', ', array_map('intval', $_POST['messages'])); switch ($_POST['action']) { // Mark messages as read case 'read': $sql->exec(' UPDATE ' . DB_PREFIX . 'pm SET is_read = 1 WHERE id IN(' . $action_messages . ') AND folder = ' . $folder_id . ' AND owner_id = ' . UID); break; // Mark messages as unread // Mark messages as unread case 'unread': $sql->exec(' UPDATE ' . DB_PREFIX . 'pm SET is_read = 0 WHERE id IN(' . $action_messages . ') AND folder = ' . $folder_id . ' AND owner_id = ' . UID); break; // Delete messages // Delete messages case 'delete': $sql->exec(' DELETE FROM ' . DB_PREFIX . 'pm WHERE id IN(' . $action_messages . ') AND folder = ' . $folder_id . ' AND owner_id = ' . UID); } redirect(HREF . PATH); } $stmt = $sql->query(' SELECT pm.*, u.nickname, u.group_id FROM ' . DB_PREFIX . 'pm pm LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = pm.connector_id WHERE pm.owner_id = ' . UID . ' AND pm.folder = ' . $folder_id . ' ORDER BY ' . $pager->orderBy . ' LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); if ($stmt->rowCount()) { $messages = array(); while ($row = $stmt->fetch()) { if ($row['connector_id']) { $row['nickname'] = User::format($row['connector_id'], $row['nickname'], $row['group_id']); } $messages[] = $row; } try { $tpl = new PHPTAL('modules/pm/pm.tpl.html'); $tpl->messages = $messages; $tpl->sort = $pager->sorters; $tpl->total = User::${'pm' . ucfirst(u1)}; $tpl->max = Kio::getConfig(u1 . '_max', 'pm'); $tpl->note = $note; $tpl->pager = $pager; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } else { return $note->info(t('There is no messages in the box.')); } }