예제 #1
0
파일: class.menu.php 프로젝트: klimjr/cms
 /**
  * Получение пунктов меню
  * @param $parent
  * @param $group_id
  * @return array
  */
 public function getMenuElements($parent, $group_id)
 {
     $query = 'CALL get_menu_elements(:parent_id, :group_id)';
     $params = array(':parent_id' => $parent, ':group_id' => $group_id);
     $data = PdoWrap::select($query, $params);
     return $data;
 }
예제 #2
0
 /**
  * Получение массива дочерних элементов для панели администрирования
  * @param $table
  * @param $parent
  * @param int $page_num
  * @param string $sort
  * @param string $sort_type
  * @return array
  */
 public function getAdminChildren($table, $parent = 0, $page_num = 1, $sort = '', $sort_type = 'ASC')
 {
     $count = '';
     $query = 'CALL get_tree_table_children_rows_group_names(:current_table, :group_table, :parent_id, :group_id, :sort, :sort_type, :limit_field, :page_num, :active_field)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':group_table' => $this->__getPrefixTableName($this->getTableGroupName()), ':parent_id' => (int) $parent, ':group_id' => (int) $this->getGroup(), ':sort' => $sort, ':sort_type' => $sort_type, ':limit_field' => $this->getLimit(), ':page_num' => $page_num, ':active_field' => 2);
     // Получение массива данных
     $data = PdoWrap::select($query, $params);
     // Получение общего количества записей
     $count = PdoWrap::selectCell('SELECT @count AS `count`');
     $this->setCount($count);
     return $data;
 }
예제 #3
0
파일: .component.php 프로젝트: klimjr/cms
 public function start()
 {
     $this->setObject();
     $group_id = isset($this->params['gid']) && (int) $this->params['gid'] > 0 ? (int) $this->params['gid'] : 0;
     $parent = isset($this->params['parent']) && (int) $this->params['parent'] > 0 ? (int) $this->params['parent'] : 0;
     $query = 'CALL get_menu_elements(:parent_id, :group_id)';
     $params = array(':parent_id' => $parent, ':group_id' => $group_id);
     $data = PdoWrap::select($query, $params);
     $this->smarty->assign('__lang', $this->getLocalization());
     $this->smarty->assign('current_link', $this->getUrl());
     $this->smarty->assign('data', $data);
     $this->smarty->assign('page', $this->page_info);
 }
예제 #4
0
 /**
  * Получение массива дочерних элементов для панели администрирования
  * @param string $table
  * @param int $parent
  * @param int $page_num
  * @param string $sort
  * @param int $sort_type
  * @return array
  */
 public function getAdminChildren($table, $parent = 0, $page_num = 1, $sort = '', $sort_type = 0)
 {
     $count = '';
     if ((int) $parent == 0) {
         $query = 'CALL get_table_all_rows_with_group(:current_table, :group_table, :sort, :sort_type, :table_limit, :page_num, :active_field)';
         $params = array(':current_table' => $this->__getPrefixTableName($table), ':group_table' => $this->__getPrefixTableName($this->getTableGroupName()), ':sort' => $sort, ':sort_type' => $sort_type, ':table_limit' => $this->getLimit(), ':page_num' => $page_num, ':active_field' => 2);
         // Получение массива данных
         $data = PdoWrap::select($query, $params);
         // Получение общего количества записей
         $count = PdoWrap::selectCell('SELECT @count AS `count`');
         $this->setCount($count);
         return $data;
     } else {
         return $this->getRows($table, 'group_id', $parent, $sort, $sort_type, $page_num, $this->getLimit(), 2);
     }
 }
예제 #5
0
파일: clsss.Search.php 프로젝트: klimjr/cms
    public function search_data($search_query)
    {
        $data = array();
        if ($search_query != '') {
            $tmp = preg_split('/\\s/', $search_query);
            $count = count($tmp);
            $query = '
				(
				SELECT
					`p`.`name`,
					`p`.`link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`h1`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'pages` `p`
				WHERE
					`p`.`type` != 3
				HAVING
					`search_string` LIKE "%' . mysql_real_escape_string($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . mysql_real_escape_string($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $data = PdoWrap::select($query);
        }
        return $data;
    }
예제 #6
0
파일: .component.php 프로젝트: klimjr/cms
 private function showList()
 {
     //	Лимит записей на страницу.
     $limit = isset($this->params['limit']) && (int) $this->params['limit'] > 0 ? (int) $this->params['limit'] : System_Settings::getLimit();
     //	Группа новостей.
     $group_id = isset($this->params['gid']) && (int) $this->params['gid'] > 0 ? (int) $this->params['gid'] : 0;
     //	Выводить на главной.
     $main_page = isset($this->params['main_page']) && (int) $this->params['main_page'] > 0 ? (int) $this->params['main_page'] : 0;
     // Получение номера страницы
     $page_num = $this->getPageNum();
     $data = $this->getList($group_id, $page_num, $limit);
     if ($main_page == 1) {
         $query = '
             SELECT
                 `i`.*,
                 CONCAT(`c`.`link`, `i`.`alias`, ".html") AS `link`,
                 `c`.`link` AS `group_link`,
                 `c`.`name` AS `group_name`,
                 (SELECT `image` FROM `cms_catalog_images` `im` WHERE `im`.`item_id` = `i`.`id` ORDER BY `im`.`position` DESC LIMIT 1) AS `image`
             FROM
                 `' . PREF . 'catalog_items` `i`
             INNER JOIN
                 `' . PREF . 'catalog_groups` `c` ON `c`.`id` = `i`.`group_id`
             INNER JOIN
                 `' . PREF . 'catalog_groups` `p` ON `c`.`tree_left` >= `p`.`tree_left` AND `c`.`tree_right` <= `p`.`tree_right`
             WHERE
                 `p`.`id` = ?
             AND
                 `i`.`active` = "1"
             AND
                 `i`.`main_page` = "1"
             ORDER BY `i`.`position` ASC
             LIMIT ' . (int) $limit . '
         ';
         $data = PdoWrap::select($query, array($group_id));
     }
     // Вывод информации о постраничной навигации
     $this->smarty->assign('pagination', $this->object->getPagination($page_num));
     $this->smarty->assign('current_link', $this->getUrl());
     // Вывод информации в шаблон
     $this->smarty->assign('data', $data);
     $this->smarty->assign('page', $this->page_info);
 }
예제 #7
0
파일: rights.php 프로젝트: klimjr/cms
if (realpath($_SERVER['SCRIPT_FILENAME']) == realpath(__FILE__)) {
    header('Location: /');
    exit;
}
/**
 * Проверка прав доступа на просмотр для текущего действия.
 */
if (!isset($rights[$action]['edit']) || (int) $rights[$action]['edit'] == 0) {
    $access_denied = true;
} else {
    //	Идентификатор модуля.
    $id = (int) Text::get_get('id');
    //	Получение списка групп пользователей.
    $query = 'CALL modules_get_user_groups(:module_id)';
    $params = array(':module_id' => (int) $id);
    $groups = PdoWrap::select($query, $params);
    /**
     * Обновление данных.
     */
    if (Text::get_post('save') != '') {
        //	Подсчет количества групп.
        $count = count($groups);
        //	Удаление прав для модуля.
        $query = 'CALL delete_table_row_by_field(:table_name, :table_cell, :cell_value)';
        $params = array(':table_name' => PREF . 'users_groups_rights', ':table_cell' => 'module_id', ':cell_value' => (int) $id);
        PdoWrap::execute($query, $params);
        //	Массив прав для чтения.
        $reads = Text::get_post('read');
        //	Массив прав для изменения.
        $edits = Text::get_post('edit');
        //	Массив прав для удаления.
예제 #8
0
파일: list.php 프로젝트: klimjr/cms
<?php

//	Запрет на обращение к файлу.
if (realpath($_SERVER['SCRIPT_FILENAME']) == realpath(__FILE__)) {
    header('Location: /');
    exit;
}
/**
 * Получение установленных модулей.
 */
//	Получение записей.
$tmp = PdoWrap::select('CALL get_installed_modules()');
//	Подсчет полученных записей.
$count = count($tmp);
$data = array();
$data['notinstalled'] = array();
for ($i = 0; $i < $count; $i++) {
    if (is_file(DOC . 'admin/~' . $tmp[$i]['folder'] . '/.desc.php')) {
        $name = '';
        //	Подключение файлов локализации.
        if (is_file(DOC . 'admin/~' . $tmp[$i]['folder'] . '/langs/' . $current_lang . '.lang.php')) {
            require DOC . 'admin/~' . $tmp[$i]['folder'] . '/langs/' . $current_lang . '.lang.php';
        }
        //	Подключение настроек модуля
        require DOC . 'admin/~' . $tmp[$i]['folder'] . '/.desc.php';
        //	Заполнение массива.
        $data['installed'][$tmp[$i]['folder']] = $tmp[$i];
        $data['installed'][$tmp[$i]['folder']]['name'] = $name;
    } elseif (is_file(DOC . 'modules/' . $tmp[$i]['folder'] . '/admin/.desc.php')) {
        $name = '';
        //	Подключение файлов локализации.
예제 #9
0
파일: class.Base.php 프로젝트: klimjr/cms
 /**
  * Поиск по любым таблицам
  * @param $table
  * @param $search
  * @param $parent
  * @param int $page_num
  * @param string $sort
  * @param string $sort_type
  * @param int $active
  * @return array
  */
 public function searchAllTables($table, $search, $parent, $page_num = 1, $sort = '', $sort_type = '', $active = 2)
 {
     // Название процедуры для поиска
     $proc_name = 'search_by_' . $table;
     // Проверяем существование процедуры поиска по таблице
     if (!$this->__storedProcedureCheck($proc_name)) {
         // Генерация процедуры для поиска
         $this->__generateSearchStoredProc($table);
     }
     $query = 'CALL `' . $proc_name . '`(:group_id,:sort,:sort_type,:table_limit,:page_num,:search_query,:active_field);';
     $params = array(':group_id' => (int) $parent, ':sort' => $sort, ':sort_type' => $sort_type, ':table_limit' => $this->getLimit(), ':page_num' => $page_num, ':search_query' => '%' . $search . '%', ':active_field' => $active);
     $data = PdoWrap::select($query, $params);
     $count = PdoWrap::selectCell('SELECT @count');
     $this->setCount($count);
     return $data;
 }
예제 #10
0
 /**
  *  Проверка одинаковых псевдонимов
  * @param string $table
  * @param int $id
  * @param string $alias
  * @param int $parent
  * @param int $type
  * @return int
  */
 public function checkAlias($table, $id, $alias, $parent = 0, $type = 0)
 {
     switch ($type) {
         case 0:
         case 1:
             $re = "/^[a-z0-9\\-_]+\$/i";
             break;
         case 2:
             $re = "/^[a-z0-9\\-\\_\\/]+\$/i";
             break;
         case 3:
             $re = "/^(.*)\$/i";
             break;
         default:
             $re = "/^[a-z0-9\\-_]+\$/i";
             break;
     }
     // Проверяем введенный алиас
     if (!preg_match($re, $alias)) {
         return 1;
     }
     $query = 'CALL check_tree_alias(:current_table, :field_id, :field_alias, :field_pid)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':field_id' => (int) $id, ':field_alias' => $alias, ':field_pid' => (int) $parent);
     $resource = PdoWrap::select($query, $params);
     if (count($resource) > 0) {
         return 2;
     }
     return 0;
 }
예제 #11
0
파일: class.pages.php 프로젝트: klimjr/cms
 /**
  * Получение списка страниц, являющихся разделами
  * @param int $table - название таблицы
  * @param int $parent - Идентификатор родителя
  * @param int $last_child - Идентификатор последнено дочернего элемента (дочерние эементы last_child не выводятся)
  * @return array
  */
 public function getGroupsList($table = 'pages', $parent, $last_child = 0)
 {
     $query = 'CALL `pages_get_groups_list`(:parent, :last_child)';
     $params = array(':parent' => (int) $parent, ':last_child' => (int) $last_child);
     $result = PdoWrap::select($query, $params);
     return $result;
 }
예제 #12
0
파일: index.php 프로젝트: klimjr/cms
     foreach ($rights as $key => $value) {
         if ($value['read'] == 1) {
             $available_actions[] = $key;
         }
     }
     if (!in_array($action, $available_actions)) {
         $action = $available_actions[0];
     }
 }
 /**
  * Формирование верхнего меню.
  */
 //	Массив меню.
 $top_menu = array();
 //	Получение данных о модулях.
 $tmp = PdoWrap::select('CALL get_modules_data()');
 //	Подсчет количества записей.
 $count = count($tmp);
 // Иконка для меню по умолчанию
 $menu_pic = 'text.png';
 $name = '';
 $title = '';
 $bread_crumbs = array(array('link' => '/admin/', 'name' => $__lang['main']));
 //	Заполнение массива.
 if ($action != 'ajax') {
     for ($i = 0; $i < $count; $i++) {
         if (!isset($rights[$tmp[$i]['folder']]) || $rights[$tmp[$i]['folder']]['read'] == 0) {
             continue;
         }
         //	Проверка наличия файла описания.
         if (is_file(DOC . 'admin/~' . $tmp[$i]['folder'] . '/.desc.php')) {
예제 #13
0
 /**
  * Поиск позиций каталога
  * @param $word
  * @return array
  */
 public function findItem($word)
 {
     $data = array();
     if ($word == '') {
         return $data;
     }
     $query = 'CALL catalog_item_find(:word)';
     $params = array(':word' => $word);
     $tmp_data = PdoWrap::select($query, $params);
     if (is_array($tmp_data) && !empty($tmp_data)) {
         foreach ($tmp_data as $key => $value) {
             $data[] = array('label' => $value['name'], 'value' => $value['name'], 'id' => $value['id']);
         }
     }
     return $data;
 }
예제 #14
0
 function __construct(&$smarty, $preload_m = null, $conf = array(), $rights = array(), $localize = array())
 {
     self::setCurrentLang($conf['curlang']);
     self::setDefaultLang($conf['deflang']);
     self::setAString($conf['aStrings']);
     self::setLocalize($localize);
     if (is_array($conf) && count($conf) > 0) {
         foreach ($conf as $var => $value) {
             $this->setConf($var, $value);
         }
     }
     self::setFinalPath($this->getConf('final_path'));
     self::setLimit($this->getConf('limit'));
     //	Подключение данных для ремаппинга.
     $__remap = array();
     if (is_file(System_Settings::getPathRoot() . '/remap.php')) {
         require System_Settings::getPathRoot() . '/remap.php';
     }
     $show_page_text = 1;
     $current_lang = self::getCurrentLang();
     // Подключение файлов основного модуля
     include System_Settings::getPathRoot() . '/modules/pages/class.pages.php';
     include System_Settings::getPathRoot() . '/modules/pages/controller.php';
     // Выгрузка файла локализации
     $__lang = self::getLocalize();
     // Получаем информацию об корневой странице модуля
     $page = array();
     $bread_crumbs = array();
     $page_title = '';
     $tpl = 'index';
     self::setModuleAString(self::$aString);
     if (class_exists('Pages')) {
         // Объекст класса для работы с деревьями
         $base = new TreeTable(DOC, $current_lang, PREF);
         $pages = new Pages($base, $__lang);
         // Для показа статических страниц нужно разобрать URL
         $aStrings = self::getModuleAString();
         // Получение информации о корневой странице
         $page = $pages->showBasePage($aStrings);
         if (isset($page['type']) && $page['type'] == 1 && $page['tree_level'] > 0 && !preg_match('/\\.html$/i', $_SERVER['REDIRECT_URL'])) {
             $page = array();
         } elseif (isset($page['tree_level']) && $page['tree_level'] == 0 && count($aStrings) > 1) {
             $page = array();
         }
         if (isset($page['id'])) {
             // Получение хлебных крошек
             $bread_crumbs = $pages->getBreadCrumbsByID($page['id']);
             /*		Шаблон страницы.	*/
             $tpl = !isset($page['template']) || empty($page['template']) ? 'index' : is_file(System_Settings::getSmarty_template() . $page['template'] . '.tpl') ? $page['template'] : 'index2';
         }
     }
     if (count(self::$aString) > 1) {
         if (isset($__remap[self::$aString[1]])) {
             // Если Страница является модулем, то отьрасывыем остальную часть УРЛ
             // Разбор остальной части будет производиться в модуле
             $root_aString = array();
             $module_aString = array();
             $count_aString = count(self::$aString);
             for ($i = 0; $i < $count_aString; $i++) {
                 if ($i <= 1) {
                     $root_aString[] = self::$aString[$i];
                 } else {
                     $module_aString[] = self::$aString[$i];
                 }
             }
             if ($count_aString != count($root_aString)) {
                 $show_page_text = 0;
             }
             self::setAString($root_aString);
             self::setModuleAString($module_aString);
             $module_name = $__remap[self::$aString[1]]['module'];
         } elseif (isset($page['type']) && $page['type'] == 2) {
             $module_name = $page['alias'];
             // TODO: Проверить работу модулей
             // Проверяем является ли страница модулем
             if ($this->checkModule($module_name)) {
                 // Если Страница является модулем, то отьрасывыем остальную часть УРЛ
                 // Разбор остальной части будет производиться в модуле
                 $root_aString = array();
                 $module_aString = array();
                 $count_aString = count(self::$aString);
                 for ($i = 0; $i < $count_aString; $i++) {
                     if ($i <= 1) {
                         $root_aString[] = self::$aString[$i];
                     } else {
                         $module_aString[] = self::$aString[$i];
                     }
                 }
                 if ($count_aString != count($root_aString)) {
                     $show_page_text = 0;
                 }
                 self::setAString($root_aString);
                 self::setModuleAString($module_aString);
                 $module_name = self::$aString[1];
             } else {
                 $module_name = 'pages';
             }
         }
     }
     // Имя запрашиваемого пользователем модуля
     $modules = !empty($module_name) ? $module_name : 'pages';
     // Модули загружаемые до загрузки основного модуля
     if ($preload_m != null) {
         foreach ($preload_m as $key => $value) {
             $this->setRequestModule($key);
             $this->AddModule($key, $value);
         }
     }
     if ($modules != 'pages') {
         // Проверить существует ли запрошенный модуль
         if ($this->checkModule($modules)) {
             // Получение прав пользователей
             $query = 'CALL get_user_rights(:user_level)';
             $params = array(':user_level' => isset($_SESSION['siteuser']['group_id']) ? (int) $_SESSION['siteuser']['group_id'] : 0);
             $rights = PdoWrap::select($query, $params);
             $access = 1;
             foreach ($rights as $values) {
                 if ($modules == $values['folder'] && $values['read'] == 1) {
                     $access++;
                 }
             }
             $action = 'index';
             if ($access > 0) {
                 // Установить имя запрошенного модуля
                 $this->setRequestModule($modules);
                 // Проверить вызываемые дейтсвия для модуля
                 if ($this->checkAction($action)) {
                     // Установить имя запрошенного модуля
                     $this->setRequestAction($action);
                     if (isset($__remap[$this->getRequestModule()])) {
                         // Все параметры для вызова основного модуля готовы, вызываем модуль
                         $module = $__remap[$this->getRequestModule()]['module'];
                         if ($this->checkLang()) {
                             include System_Settings::getPathRoot() . '/modules/' . $module . '/langs/' . self::getCurrentLang() . '.lang.php';
                         }
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/class.' . $module . '.php';
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/controller.php';
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/index.action.php';
                     } else {
                         // Все параметры для вызова основного модуля готовы, вызываем модуль
                         if ($this->checkLang()) {
                             $__lang = '';
                             require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/langs/' . self::getCurrentLang() . '.lang.php';
                             self::setLocalize($__lang);
                         }
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/class.' . $this->getRequestModule() . '.php';
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/controller.php';
                         // и действие для данного модуля
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/' . self::getRequestAction() . '.action.php';
                         // Проверяем существование модульного шаблона
                         if (file_exists(System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/templates/' . $tpl . '.tpl')) {
                             $tpl = System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/templates/' . $tpl;
                         }
                     }
                     // В случае ошибки - вывести сообщение и остановить работу скрипта
                 } else {
                     require_once DOC . '/error404.php';
                 }
             } else {
                 echo 'access denied';
                 exit;
             }
         } else {
             require_once DOC . '/error404.php';
             exit;
         }
     } else {
         // Подключение управляющего файла модуля
         include System_Settings::getPathRoot() . '/modules/pages/index.action.php';
     }
     // Установка шаблона
     self::setTpl($tpl);
     // Получение заголовка
     $page_title = $pages->getPageTitle($page['head_title'], self::getPageNum(), $page['show_navigation']);
     // Выгрузка переменных в шаблон
     $smarty->assign(array('page' => $page, 'breadcrumbs' => $bread_crumbs, 'page_title' => $page_title, 'show_page_text' => $show_page_text));
 }
예제 #15
0
/**
 * Получение собственных заметок пользователя
 * @param $param
 * @param $smarty
 */
function smarty_function_getUserNotes($param, &$smarty)
{
    $data = array();
    //	Переменная, в которую все вернется.
    $assign = 'data';
    if (isset($param['assign']) && preg_match('/^[a-z0-9_]+?$/', $param['assign'])) {
        $assign = $param['assign'];
    }
    if (isset($_SESSION['siteuser']['id'])) {
        $query = 'CALL get_user_notes(:user_id,:status,:table_limit,:table_page,:sort_field,:sort_type)';
        $params = array('user_id' => $_SESSION['siteuser']['id'], 'status' => 1, 'table_limit' => 5, 'table_page' => 1, 'sort_field' => '', 'sort_type' => '');
        $data = PdoWrap::select($query, $params);
    }
    // Выгрузка в шпблон
    $smarty->assign($assign, $data);
}
예제 #16
0
 /**
  * Получение сообщений
  * @param int $from_user
  * @param int $to_user
  * @param int $page_num
  * @param string $sort_field
  * @param int $sort_type
  * @return array
  */
 public function getMessages($from_user = 0, $to_user = 0, $page_num = 1, $sort_field = 'date', $sort_type = 0)
 {
     $query = 'CALL get_user_messages(:from_user,:to_user,:table_limit,:table_page,:sort_field,:sort_type)';
     $params = array('from_user' => (int) $from_user, 'to_user' => (int) $to_user, 'table_limit' => (int) $this->getLimit(), 'table_page' => (int) $page_num, 'sort_field' => $sort_field, 'sort_type' => (int) $sort_type);
     $data = PdoWrap::select($query, $params);
     // Получение общего количества записей
     $count = PdoWrap::selectCell('SELECT @count AS `count`');
     $this->setCountRows($count);
     return $data;
 }
예제 #17
0
 /**
  * Получение массива дочерних альбомов
  * @param $parent
  * @param int $page_num
  * @param string $sort
  * @param string $sort_type
  * @return array
  */
 public function getChildrenAlbums($parent, $page_num = 1, $sort = '', $sort_type = 'ASC')
 {
     $count = '';
     $query = 'CALL get_gallery_children_albums(:parent_id, :sort, :sort_type, :limit_field, :page_num)';
     $params = array(':parent_id' => (int) $parent, ':sort' => $sort, ':sort_type' => $sort_type, ':limit_field' => $this->base->getLimit(), ':page_num' => $page_num);
     // Получение массива данных
     $data = PdoWrap::select($query, $params);
     // Получение общего количества записей
     $count = PdoWrap::selectCell('SELECT @count AS `count`');
     $this->base->setCount($count);
     return $data;
 }
예제 #18
0
 /**
  * Получение связаннх данных
  * @param string $table - таблица со связями
  * @param string $relation_table - таблица из которой получают данные
  * @param string $col1 - столбец 1 таблицы со связями
  * @param string $col2 - столбец 2 таблицы со связями
  * @param int $value - значение столбца 1
  * @return array
  */
 public function getRelationList($table, $relation_table, $col1, $col2, $value)
 {
     $query = 'CALL get_relations(:table_name,:relation_table,:col1,:col2,:value)';
     $params = array(':table_name' => $table, ':relation_table' => $relation_table, ':col1' => $col1, ':col2' => $col2, ':value' => (int) $value);
     $data = PdoWrap::select($query, $params);
     return $data;
 }
예제 #19
0
function clearCacheFiles(Smarty $smarty, $cache_id = 0, $table = '', $table_id = 0, $link = '')
{
    $cache_data = array();
    // Удаление файлов кэша по ID
    if ((int) $cache_id > 0) {
        $query = 'CALL get_table_row_by_id(:current_table, :id_value)';
        $params = array(':current_table' => PREF . 'cached_files', ':id_value' => $cache_id);
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'CALL delete_table_row_by_field(:current_table, :table_cell, :cell_value)';
        $params = array(':current_table' => PREF . 'cached_files', ':table_cell' => 'id', ':cell_value' => $cache_id);
        PdoWrap::execute($query, $params);
    }
    // Удаление файлов кэша по ID таблицы
    if (!empty($table) && (int) $table_id > 0) {
        $query = 'SELECT * FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name AND `table_id` = :table_id';
        $params = array(':table_name' => $table, ':table_id' => $table_id);
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'DELETE FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name AND `table_id` = :table_id';
        $params = array(':table_name' => $table, ':table_id' => $table_id);
        PdoWrap::execute($query, $params);
    }
    // Удаление файлов кэша по всей таблице
    if (!empty($table) && (int) $table_id == 0) {
        $query = 'SELECT * FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name';
        $params = array(':table_name' => $table);
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'DELETE FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name';
        $params = array(':table_name' => $table);
        PdoWrap::execute($query, $params);
    }
    // Удаление файлов кэша по ссылке
    if (!empty($link)) {
        $query = 'SELECT * FROM `' . PREF . 'cached_files` WHERE `link` LIKE :link';
        $params = array(':link' => '%' . $link . '%');
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'DELETE FROM `' . PREF . 'cached_files` WHERE `link` LIKE :link';
        $params = array(':link' => '%' . $link . '%');
        PdoWrap::execute($query, $params);
    }
    for ($i = 0; $i < count($cache_data); $i++) {
        $smarty->clearCache($cache_data[$i]['template'], $cache_data[$i]['id']);
    }
}
예제 #20
0
파일: edit.php 프로젝트: klimjr/cms
 $id = (int) Text::get_get('id');
 // Идентификатор родителя
 $group_id = (int) Text::get_get('group_id');
 if ($group_id > 0) {
     $object->setGroup($table, $group_id);
 }
 // Идентификатор родителя
 $parent = (int) Text::get_get('parent');
 $parent = $parent > 0 ? $parent : $object->getRootId();
 // Основная переменная
 $data = array();
 // Массив ошибок
 $errors = array('all' => false);
 if (!isset($_REQUEST['send'])) {
     // Получение списка таблиц
     $tables_tmp = PdoWrap::select('SHOW TABLES');
     // Получение информации о записи
     $data = $object->getAdminEditedRow($table, $id, $parent);
     // Получение родительской таблицы
     $foreign_keys = $object->getForeignTableKeys($table, 'group_id');
     if (isset($foreign_keys["REFERENCED_TABLE_NAME"])) {
         $group_table = $foreign_keys["REFERENCED_TABLE_NAME"];
     }
     $menu = array();
     $options_level = $object->getTableOption($table, 'tree_level');
     // Получение доступных ветвей дерева
     if ($object->getBase() instanceof TreeTable && $options_level['edit_list'] == 1) {
         // Получение списка разделов
         $menu = $object->getGroupsList($table, $object->getRootId(), $id);
     }
     $groups = array();
예제 #21
0
파일: class.search.php 프로젝트: klimjr/cms
    public function search_data($search_query)
    {
        $data = array();
        if ($search_query != '') {
            $tmp = preg_split('/\\s/', $search_query);
            $count = count($tmp);
            $query = '
				(
				SELECT
					`p`.`name`,
					`p`.`image`,
					`p`.`link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`alias`, `p`.`h1`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'pages` `p`
				WHERE
					`p`.`type` != 3
				HAVING
					`search_string` LIKE "%' . htmlspecialchars($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . htmlspecialchars($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $query .= '
				UNION (
				SELECT
					`p`.`name`,
					(SELECT `i`.`image` FROM `' . PREF . 'catalog_images` `i` WHERE `i`.`item_id` = `p`.`id` ORDER BY `position` DESC LIMIT 1) AS `image`,
					CONCAT(`g`.`link`, `p`.`alias`, ".html") AS `link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`alias`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'catalog_items` `p`
				LEFT JOIN
					`' . PREF . 'catalog_groups` `g`
				ON
                    `p`.`group_id` = `g`.`id`
				WHERE
					`p`.`active` = "1"
				HAVING
					`search_string` LIKE "%' . htmlspecialchars($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . htmlspecialchars($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $query .= '
				UNION (
				SELECT
					`p`.`name`,
					`p`.`icon` AS `image`,
					`p`.`link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`alias`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'catalog_groups` `p`
				WHERE
					`p`.`active` = "1"
				HAVING
					`search_string` LIKE "%' . htmlspecialchars($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . htmlspecialchars($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $data = PdoWrap::select($query);
        }
        return $data;
    }
예제 #22
0
파일: __list.php 프로젝트: klimjr/cms
    $sort_type = $sort_type == 0 ? 'ASC' : 'DESC';
}
// Идентификатор родителя
$parent = (int) Text::get_get('parent');
$parent = $parent > 0 ? $parent : 0;
$groups_list = array();
// Установка группововй таблицы
if (isset($group_table) && $group_table != '' && ($object->getBase() instanceof TreeTableGroup || $object->getBase() instanceof SimpleTableGroup)) {
    $base->setTableGroupName($group_table);
    $groups_list = $object->getAllRows($group_table, 'tree_left', 'ASC');
}
$count_rows = 0;
if (Text::get_get('search') != '') {
    $query = 'CALL search_catalog_items(:sort, :sort_type, :table_limit, :page_num, :search_query)';
    $params = array(':sort' => 'name', ':sort_type' => 'ASC', ':table_limit' => 9999, ':page_num' => $page_num, ':search_query' => Text::get_get('search'));
    $data = PdoWrap::select($query, $params);
} else {
    $data = $object->getAdminList($table, $parent, $page_num, $sort, $sort_type);
    $count_rows = $object->getCount();
}
// определение постраничной навигации
$pagination = $object->getPagination($page_num);
// Обработка данных
$data = $object->getAdminListData($table, $data);
// Получение заголовков таблицы
$table_head = $object->getTableColumns($table);
//  Получение информации о родителях для хлебных крошек
$breadcrumbs = $object->getAdminBreadCrumbs($table, $parent, $action);
$smarty->assign('table_head', $table_head);
$smarty->assign('table', $table);
$smarty->assign('data', $data);