// +---------------------------------------------------------------------- // | Demila [ Beautiful Digital Content Trading System ] // +---------------------------------------------------------------------- // | Copyright (c) 2015 http://demila.org All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- _setView(__FILE__); _setTitle($langArray['add']); $cms = new categories(); if (!isset($_GET['sub_of']) || !is_numeric($_GET['sub_of'])) { $_GET['sub_of'] = 0; } if (isset($_POST['add'])) { $status = $cms->add(); if ($status !== true) { abr('error', $status); } else { refresh("?m=" . $_GET['m'] . "&c=list&sub_of=" . $_GET['sub_of'], $langArray['add_complete']); } } else { $_POST['visible'] = 'true'; } if ($_GET['sub_of'] != 0) { $pdata = $cms->get($_GET['sub_of']); abr('pdata', $pdata); } require_once ROOT_PATH . '/apps/lists/leftlist_admin.php';
// +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- _setView(ROOT_PATH . "/apps/" . $_GET['m'] . "/admin/add.php"); _setTitle($langArray['edit']); if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { refresh('?m=' . $_GET['m'] . '&c=list', 'INVALID ID', 'error'); } if (!isset($_GET['p'])) { $_GET['p'] = ''; } $cms = new categories(); if (isset($_POST['edit'])) { $status = $cms->edit($_GET['id']); if ($status !== true) { abr('error', $status); } else { refresh("?m=" . $_GET['m'] . "&c=list&p=" . $_GET['p'], $langArray['edit_complete']); } } else { $_POST = $cms->get($_GET['id']); } #加载主类别 $mysql->query("\n\t\tSELECT *\n\t\tFROM `categories`\n\t\tWHERE `sub_of` = '0'\n\t\tORDER BY `order_index` ASC\n\t", __FUNCTION__); if ($mysql->num_rows() > 0) { while ($d = $mysql->fetch_array()) { $categories[$d['id']] = $d; } abr('categories', $categories); } require_once ROOT_PATH . '/apps/lists/leftlist_admin.php';
/** * Сохранение порядка категорий * @return null * @throws EngineException */ public function save_order($sort) { if (!$sort) { throw new EngineException(); } $i = 0; foreach ($sort as $id => $parent) { $id = (int) $id; if (!$parent || !$this->cats->get($parent)) { $parent = 0; } db::o()->p($id)->update(array('sort' => $i, 'parent_id' => (int) $parent), 'categories', 'WHERE id=? LIMIT 1'); $i++; } db::o()->query('ALTER TABLE `categories` ORDER BY `sort`'); }
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- _setView(ROOT_PATH . "/apps/" . $_GET['m'] . "/admin/add.php"); _setTitle($langArray['edit']); if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { refresh('?m=' . $_GET['m'] . '&c=list', 'INVALID ID', 'error'); } if (!isset($_GET['p'])) { $_GET['p'] = ''; } $cms = new categories(); if (isset($_POST['edit'])) { $status = $cms->edit($_GET['id']); if ($status !== true) { abr('error', $status); } else { refresh("?m=" . $_GET['m'] . "&c=list&sub_of=" . $_GET['sub_of'] . "&p=" . $_GET['p'], $langArray['edit_complete']); } } else { $_POST = $cms->get($_GET['id']); } $pagesArr = $cms->getAllWithChilds($_GET['id']); $select = $cms->generateSelect($pagesArr, $_POST['sub_of']); abr('select', $select); if ($_GET['sub_of'] != 0) { $pdata = $cms->get($_GET['sub_of']); abr('pdata', $pdata); } require_once ROOT_PATH . '/apps/lists/leftlist_admin.php';
// +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- _setView(__FILE__); header('Content-type: application/xml; charset="utf-8"', true); mb_internal_encoding("UTF-8"); $name = ''; $link = ''; $whereQuery = ''; if (isset($_GET['category'])) { $whereQuery .= " AND `categories` LIKE '%," . intval($_GET['category']) . ",%' "; require_once ROOT_PATH . '/apps/categories/models/categories.class.php'; $categoriesClass = new categories(); $category = $categoriesClass->get($_GET['category']); $name = $category['name']; $link = '?category=' . $_GET['category']; } if (isset($_GET['user'])) { $whereQuery .= " AND `user_id` = '" . intval($_GET['user']) . "' "; require_once ROOT_PATH . '/apps/users/models/users.class.php'; $usersClass = new users(); $user = $usersClass->get($_GET['user']); $name = $user['username']; if ($link == '') { $link = '?user='******'user']; } else { $link .= '&user='******'user']; } }
// +---------------------------------------------------------------------- // | Copyright (c) 2015 http://demila.org All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- _setView(__FILE__); _setTitle($langArray['attributes']); if (!isset($_GET['id']) && !is_numeric($_GET['id'])) { refresh("/" . $languageURL . adminURL . "/?m=" . $_GET['m'] . "&c=list"); } $cms = new attributes(); if (isset($_GET['up']) || isset($_GET['down'])) { $cms->tableName = 'attributes'; $cms->idColumn = 'id'; $cms->orderWhere = " AND `category_id` = '" . intval($_GET['id']) . "' "; if (isset($_GET['up']) && is_numeric($_GET['up'])) { $cms->moveUp($_GET['up']); } elseif (isset($_GET['down']) && is_numeric($_GET['down'])) { $cms->moveDown($_GET['down']); } } $data = $cms->getAll(START, LIMIT, " `category_id` = '" . intval($_GET['id']) . "' "); abr('data', $data); $p = paging("?m=" . $_GET['m'] . "&c=attr&id=" . $_GET['id'] . "&p=", "", PAGE, LIMIT, $cms->foundRows); abr('paging', $p); $categoriesClass = new categories(); $pdata = $categoriesClass->get($_GET['id']); abr('pdata', $pdata); require_once ROOT_PATH . '/apps/lists/leftlist_admin.php';
/** * list keywords * * This function is used to list all keywords starting with provided letters. * * @param string prefix to consider * @paral string or int nickname or ID of category keywords have to be child to * @return an array of matching $keyword => $introduction * * @see categories/complete.php */ public static function &list_keywords($prefix, $mothercat = NULL) { global $context; // we return an array $output = array(); // ensure proper unicode encoding $prefix = utf8::encode($prefix); // look for mothercat if ($mothercat = categories::get($mothercat)) { $more = ' AND categories.anchor = "category:' . $mothercat['id'] . '"'; } else { $more = ''; } // select among available items $query = "SELECT keywords, introduction FROM " . SQL::table_name('categories') . " AS categories" . " WHERE categories.keywords LIKE '" . SQL::escape($prefix) . "%'" . $more . " ORDER BY keywords LIMIT 100"; $result = SQL::query($query); // populate the returned array while ($row = SQL::fetch($result)) { $output[$row['keywords']] = $row['introduction']; } // return by reference return $output; }
<?php if (!isset($_SESSION['admin'])) { header('location: Login'); die; } require 'classes/class_categories.php'; $categories = new categories(); // If there are a request to save the categories if (isset($_POST['save_categories_submit'])) { // Saving the categories if (isset($_POST['categories'])) { $categories->save($_POST['categories']); } // Adding new category, if admin fill one $checked = isset($_POST['checked']) ? 1 : 0; if (isset($_POST['name']) && isset($_POST['order']) && !empty($_POST['name']) && !empty($_POST['order'])) { $categories->add($_POST['name'], $_POST['order'], $checked); } } // If there are a request to delete category if (isset($_GET['d'])) { $categories->delete($_GET['d']); } // Gets all the categories in array $categories->get(); require 'design/design_categories.php';