예제 #1
0
 function getSInsert()
 {
     global $PRJ_DIR, $THEME_REF, $smarty;
     if (file_exists($PRJ_DIR . '/templates/admin/components/' . CUtils::_getVar('unit') . '.' . CUtils::_getVar('table') . '.tpl')) {
         return $smarty->fetch('admin/components/' . CUtils::_getVar('unit') . '.' . CUtils::_getVar('table') . '.tpl');
     } else {
         reset($this->t->fields);
         $ret = '';
         $fields = '';
         foreach ($this->t->fields as $k => $v) {
             if (empty($v['readonly'])) {
                 $vis = '';
                 if ($this->t->getDBTableName() == 'table_attributes' && ($v['name'] == 'select_values' || $v['name'] == 'params')) {
                     $vis = ' style="display:none;"';
                 }
                 $fields .= '<tr' . $vis . ' id="add_' . $v['name'] . '" bgcolor="#fafafa"><td class="left" width="180" align="left"><b>' . $v['title'] . '</b>' . $this->getHelpLink($k, $v) . $this->getTemplateName($v) . '</td><td class="right">';
                 $ft = $this->t->createFieldType($v);
                 $fields .= $ft->getInput() . '</td></tr>' . "\n";
             }
         }
         $ret .= '<form enctype="multipart/form-data" method="post" name="frmInsert" id="frmInsert" action="' . $this->fullRef . '&action=insert">';
         $ret .= '<input type="hidden" id="utype" name="utype" value="0">';
         $ret .= $this->getTableHeader();
         $ret .= '<tr">' . "\n";
         $ret .= '<td><b>Добавить</b><a name=add></a><br><img src="' . $THEME_REF . '/img/0.gif" width="150" height="1"></td>' . "\n";
         $ret .= '<td><div class="empty"></div></td></tr>' . "\n";
         $ret .= $fields;
         $ret .= '</table><div class="ctlbtns"><input type="button" class="adm-btn" onClick="preSubmit(\'frmInsert\', 1)" value="Применить"><input type="button" class="adm-btn" onClick="preSubmit(\'frmInsert\', 0)" value="Сохранить"><input type="button" class="adm-btn" onClick="window.location = \'' . (!empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->fullRef) . '\'" value="Отменить"></div></form>' . "\n";
         return $ret;
     }
 }
예제 #2
0
 function getBody()
 {
     $ret = $this->smarty->fetch('service/' . $this->props['lang'] . '/search.form.tpl');
     $max_per_page = 20;
     $this->page = CUtils::_getVar('page', true, 1);
     if (CUtils::_getVar('text')) {
         $search_array = array();
         $simple_search_array = explode(' ', CUtils::_getVar('text'));
         foreach ($simple_search_array as $ssa) {
             inc_lib('tools/stemming/stemming.php');
             $ssa = PorterStem::stemming($ssa);
             $search_array[] = $ssa;
         }
         if (count($search_array)) {
             $results = $this->getResults($search_array);
         } else {
             $results = $this->getResults(addslashes($this->text));
         }
         $this->smarty->assign('search_text', addslashes(CUtils::_getVar('text')));
         if (sizeof($results) > 0) {
             $pages_cnt = ceil(sizeof($results) / $max_per_page);
             if ($pages_cnt > 1) {
                 $pages = '<div>';
                 if ($this->page > 1) {
                     $ref = '?text=' . urlencode(CUtils::_getVar('text')) . '&page=' . ($this->page - 1);
                     $pages .= '<a title="назад" href="' . $ref . '">&larr;</a>';
                 }
                 for ($i = 1; $i <= $pages_cnt; $i++) {
                     $pages .= $i == $this->page ? ' ' . $i . ' ' : ' <a href="?text=' . urlencode(CUtils::_getVar('text')) . '&page=' . $i . '">' . $i . '</a> ';
                 }
                 if ($this->page < $pages_cnt) {
                     $ref = '?text=' . urlencode(CUtils::_getVar('text')) . '&page=' . ($this->page + 1);
                     $pages .= '<a title="вперед" href="' . $ref . '">&rarr;</a>';
                 }
                 $pages .= '</div>';
                 $this->smarty->assign('ptext', $pages);
             }
             if ($this->page == $pages_cnt && sizeof($results) % $max_per_page > 0) {
                 $max_per_page_cur = count($results) % $max_per_page;
             } else {
                 $max_per_page_cur = $max_per_page;
             }
             $items = array();
             for ($i = 1; $i <= $max_per_page_cur; $i++) {
                 $j = $i + ($this->page - 1) * $max_per_page;
                 $results[$j - 1]['num'] = $j;
                 $items[] = $results[$j - 1];
             }
             $this->smarty->assign('items', $items);
             $ret .= $this->smarty->fetch('service/' . $this->props['lang'] . '/search.list.tpl');
         } else {
             $ret .= $this->smarty->fetch('service/' . $this->props['lang'] . '/search.no.tpl');
         }
     }
     return $ret;
 }
예제 #3
0
 public function getInput($value = '', $name = '')
 {
     $name = $name ? $name : $this->getName();
     $value = $value ? $value : $this->dbValue;
     $input_id = strtr($name, '[]', '__');
     $ret = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="100%"><input type="text" readonly style="width:100%;" value="' . $this->getStatic() . '" size="62" id="' . $input_id . '_title">';
     $ret .= '<input type="hidden" name="' . $name . '" value="' . $value . '" id="' . $input_id . '">';
     $ret .= '</td><td><input class="butt" type="button" value="&hellip;" onClick="show_list_popup(\'' . $input_id . '\',\'' . CUtils::_getVar('unit') . '_' . CUtils::_getVar('table') . '\',\'' . $this->getName() . '\', \'' . CUtils::_getVar('id', true, 0) . '\',\'' . $value . '\');"></td></tr></table>';
     return $ret;
 }
예제 #4
0
 protected function setOptions()
 {
     $this->unit = CUtils::_getVar('unit');
     $this->state = CUtils::_getVar('state', false, 'content');
     $this->smarty = $GLOBALS['smarty'];
     $this->smarty->assign('user', CUtils::_sessionVar('user'));
     $this->smarty->assign('state', $this->state);
     $this->smarty->assign('lang', CUtils::_sessionVar('lang', false, 'ru'));
     $this->smarty->assign('unit', $this->unit);
 }
예제 #5
0
 public function __construct(&$unitAdminInterface)
 {
     $this->uai = $unitAdminInterface;
     $this->baseRef = $unitAdminInterface->getBaseTableRef();
     if (is_object($this->t = $this->uai->getBaseTable())) {
         $this->search_url = $this->t->getSeachURL();
         $this->search_sql = $this->t->getSeachSQL();
         $this->searchRef0 = $this->baseRef . ($this->search_url ? '&' . $this->search_url : '');
         $this->searchRef = $this->searchRef0 . (CUtils::_getVar('rpp') ? '&rpp=' . CUtils::_getVar('rpp') : '');
         $this->fullRef0 = $this->searchRef0 . (CUtils::_getVar('page') ? '&page=' . CUtils::_getVar('page') : '');
         $this->fullRef = $this->searchRef . (CUtils::_getVar('page') ? '&page=' . CUtils::_getVar('page') : '');
     }
 }
예제 #6
0
 protected function select_tree_getInput($value, $name, $zeroTitle = 'Корень')
 {
     $name = $name ? $name : $this->getName();
     $value = empty($value) ? intval($this->dbValue) : $value;
     $unit = CUtils::_getVar('unit');
     $table = CUtils::_getVar('table');
     $id = empty($this->dbId) ? '-1' : $this->dbId;
     $input_id = strtr($name, '[]', '__');
     // узнаем имя категории, для текстового поля
     $ret = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="100%"><input type="text" readonly style="width:100%;" value="' . $this->getStatic() . '" size="62" id="' . $input_id . '_title">';
     $ret .= '<input type="hidden" name="' . $name . '" value="' . $value . '" id="' . $input_id . '"></td>';
     $ret .= '</td><td><input class="butt" type="button" value="&hellip;" onClick="show_tree_popup(\'' . $input_id . '\',\'' . $unit . '_' . $table . '\',\'' . $name . '\', \'' . $id . '\', \'' . $zeroTitle . '\',\'' . $value . '\');"></td></tr></table>';
     return $ret;
 }
예제 #7
0
 private function _getEntityList()
 {
     global $db;
     $this->_aEntities = null;
     if (is_null($this->_aEntities)) {
         $where = '';
         if (!empty($this->props['query'])) {
             $where .= $where ? ' AND (' . $this->props['query'] . ')' : $this->props['query'];
         }
         if (isset($this->props['dir'])) {
             $module = $GLOBALS['rtti']->getComponent(CUtils::_getVar('unit'));
             $where .= ($where ? ' AND ' : '') . ' module_id = ' . $module['id'];
         }
         $this->_aEntities = $GLOBALS['db']->getItems('select_items', "SELECT id," . $this->props['l_field'] . " FROM " . $this->props['l_table'] . ($where ? " WHERE " . $where : '') . ' ORDER BY ' . $this->props['l_sort']);
     }
     return $this->_aEntities;
 }
예제 #8
0
 public function getStatic($value, $name)
 {
     $ret = '';
     $unit = CUtils::_getVar('unit');
     $table = CUtils::_getVar('table');
     $value = empty($value) ? '' : $value;
     $input_id = $this->dbId ? strtr($name, '[]', '__') . $this->dbId : strtr($name, '[]', '__');
     $text = '';
     // узнаем имя категории, для текстового поля
     if ($id && ($items = $GLOBALS['rtti']->getItems($this->props['l_table'], $this->props['l_link'] . "=" . $id))) {
         foreach ($items as $item) {
             $text .= ($text ? ', ' : '') . $a[$this->props['l_field']];
         }
         return $ret . '<span id="' . $input_id . '">' . $text . '</span>&nbsp;<input class="butt" type="button" onClick="show_listbox(\'' . $input_id . '\',\'' . $unit . '\',\'' . $table . '\',\'' . $input_id . '\', \'' . $this->dbId . '\');" value="Просмотр">';
     } else {
         return '-';
     }
 }
예제 #9
0
 function getTableUpdate()
 {
     global $smarty;
     $unit = CUtils::_getVar('unit');
     $table = CUtils::_getVar('table');
     $ret = '';
     $fields = '';
     $types = array();
     $svalues = explode(';', 'HTML|html;Булево|checkbox;Вещественное число|float;Выбор|select;Выбор из дерева|select_tree;Выбор множества|select_list;Дата|date;Дата и время|datetime;Мемо|text;Пароль|password;Перечисление|enum;Рисунок|image;Строка|string;Файл|file;Целое число|number;Шаблон|template');
     foreach ($svalues as $a) {
         $types[] = explode('|', $a);
     }
     $smarty->assign('types', $types);
     $smarty->assign('fields', $this->t->fields);
     $smarty->assign('groups', $GLOBALS['rtti']->getItems('users_groups'));
     $smarty->assign('rights', array('' => 'По-умолчанию (чтение)', 'D' => 'Закрыт', 'R' => 'Чтение', 'W' => 'Чтение и запись', 'X' => 'Полный доступ'));
     $smarty->assign('a', $GLOBALS['rtti']->getClass($unit . '_' . $table));
     return $smarty->fetch('admin/table.edit.tpl');
 }
예제 #10
0
 function getText()
 {
     global $db, $THEME_REF;
     $ret = '';
     $ret .= '<form enctype="multipart/form-data" method="post" name="frmInsert" id="frmInsert" action="' . $this->fullRef . '&action=methods">';
     $ret .= $this->getTableHeader();
     $ret .= '<tr>';
     $ret .= '<th>Макет</th>';
     $ret .= '<th>Шаблон</th>';
     $ret .= '<th>Обработчик</th>';
     $ret .= '<th align=center><img alt="Действия" src="' . $THEME_REF . '/img/action_head.gif" border=0></td></tr>' . "\n";
     $component = $GLOBALS['rtti']->getComponent(CUtils::_getVar('unit'));
     $methods = $GLOBALS['db']->getItems('config_methods', 'SELECT cm.*,tt.name as maket_name FROM config_methods cm LEFT JOIN templates_templates tt ON cm.maket=tt.id WHERE cm.seniorid=' . $component['id']);
     foreach ($methods as $method) {
         $ret .= '<tr><td class=left align=left width=250>' . $method['maket_name'] . '</td>';
         $ret .= '<td>' . ($method['code'] ? $method['code'] : 'нет') . '</td>';
         $ret .= '<td class="right">' . ($method['template'] ? $method['template'] : 'нет') . '</td>';
         $ret .= $this->getUpdateDelete($method['id']) . '</tr>' . "\n";
     }
     $ret .= '</table></form>';
     return $ret;
 }
예제 #11
0
 function getText()
 {
     set_time_limit(0);
     $this->messageAction($GLOBALS['rtti']->dublicateItem($this->t->getDBTableName(), CUtils::_getVar('id'), CUtils::_getVar('quantity', true, 5)) ? 'Скопировано' : 'Ошибка копирования');
 }
예제 #12
0
 function getText()
 {
     $file = CUtils::_getVar('file');
     @unlink($GLOBALS['PRJ_DIR'] . $file);
     header('location: ' . $this->fullRef . '&action=s_backup');
 }
예제 #13
0
 function showAuthForm()
 {
     global $smarty;
     if (CUtils::_getVar('error')) {
         $this->message['type'] = 'error';
         $this->message['text'] = CUtils::_getVar('error');
     }
     if (CUtils::_getVar('ok')) {
         $this->message['type'] = 'ok';
         $this->message['text'] = CUtils::_getVar('ok');
     }
     $smarty->assign('message', CUtils::showMsg($this->message));
     $smarty->display('admin/form.auth.tpl');
     exit;
 }
예제 #14
0
 function getText()
 {
     $q = 'id=' . CUtils::_getVar('id', true, 0);
     $this->messageAction($GLOBALS['rtti']->deleteItem($this->t->getDBTableName(), $q) ? 'Удалено' : 'Ошибка удаления');
 }
예제 #15
0
    protected function getTableOperations()
    {
        $ret = '<table align="center" cellpadding="0" cellspacing="0" border="0" class="contextmenu2">
	<tr class="top">
<td class="left"><div class="empty"></div></td>
<td><div class="empty"></div></td>
<td class="right"><div class="empty"></div></td>
</tr>
<tr>
<td class="left"><div class="empty"></div></td>
<td class="content">
<table cellpadding="2" cellspacing="0" border="0">
<tr>';
        if (!$this->p['noinsert']) {
            $ret .= '<td><div class="section-separator first"></div></td>
<td align="center"><a href="' . $this->fullRef . '&amp;action=s_insert' . (CUtils::_getVar('p_id') ? '&p_id=' . CUtils::_getVar('p_id') : '') . '" class="context-button">Добавить запись</a></td>';
        }
        $ret .= '<td><div class="section-separator"></div></td>
<td align="center"><a href="' . $this->fullRef . '&amp;action=create" class="context-button">Создать таблицу</a></td>';
        $ret .= '<td><div class="section-separator"></div></td>
<td align="center"><a href="' . $this->fullRef . '&amp;action=alter" class="context-button">Обновить таблицу</a></td>';
        $ret .= '</tr>
</table>
</td>
<td class="right"><div class="empty"></div></td>
</tr>
<tr class="bottom">
<td class="left"><div class="empty"></div></td>
<td><div class="empty"></div></td>
<td class="right"><div class="empty"></div></td>
</tr>

<tr class="bottom-all">
<td class="left"><div class="empty"></div></td>
<td><div class="empty"></div></td>
<td class="right"><div class="empty"></div></td>
</tr>
</table><br>';
        return $ret;
    }
예제 #16
0
 public function getURLProps($url = '')
 {
     global $PRJ_REF;
     $uri = empty($url) ? $this->url : $url;
     $this->props['url'] = $uri;
     if (!stristr($uri, '/admin')) {
         $langs = $GLOBALS['db']->getItems('config_languages', 'SELECT * FROM config_languages');
         $findlang = false;
         foreach ($langs as $l) {
             if (stristr($uri, '/' . $l['name'] . '/') || CUtils::_getVar('lang') == $l['name']) {
                 $_SESSION['lang'] = $l['name'];
                 $uri = str_replace('/' . $l['name'] . '/', '/', $uri);
                 $findlang = true;
                 if (empty($uri)) {
                     $uri = '/';
                 }
             }
         }
         if (!$findlang) {
             $_SESSION['lang'] = 'ru';
         }
     }
     $this->parseVariables();
     $this->props['lang'] = CUtils::_sessionVar('lang', false, 'ru');
     $uri = str_replace(stristr($uri, '#'), '', $uri);
     $uri = str_replace('?' . $_SERVER['QUERY_STRING'], '', $uri);
     $clear_uri = $uri = str_replace($PRJ_REF . '/', '/', $uri);
     if ($this->checkURL($clear_uri)) {
         $url_parts = $GLOBALS['rtti']->parseURL($clear_uri);
         if (!$url_parts) {
             $this->props['error'] = '404';
         }
         $this->props['component'] = $url_parts['cname'];
         $this->props['method'] = $url_parts['mname'];
         $this->props['params'] = $url_parts['params'];
         $url_error = false;
         if ($clear_uri == '/') {
             //echo '1';
             $dir = $GLOBALS['rtti']->getItem('tree_tree', "name='/'");
             if (isset($dir['module_id_name'])) {
                 $this->props['component'] = $dir['module_id_name'];
             }
         } elseif ($clear_uri == '/' . $this->props['method'] . '.htm' && ($dir = $GLOBALS['rtti']->getItem('tree_tree', "name='" . $this->props['method'] . "'"))) {
             //echo '2';
             $this->props['params'] = array($this->props['method']);
             $this->props['method'] = 'index';
         } elseif (sizeof(explode('/', $clear_uri)) == 2) {
             //echo '2.2';
             $dir = $GLOBALS['rtti']->getItem('tree_tree', "name='/'");
             if (!isset($dir['module_id_name'])) {
                 $url_error = true;
             } else {
                 $this->props['component'] = $dir['module_id_name'];
             }
         } else {
             //echo '3';
             $dir = $GLOBALS['rtti']->getItem('tree_tree', "name='" . $this->props['component'] . "'");
             if (!isset($dir['module_id_name'])) {
                 $url_error = true;
             } else {
                 $this->props['component'] = $dir['module_id_name'];
             }
         }
         if (is_array($dir) && !$url_error) {
             $this->props['node'] = $dir;
             $this->props['dir_id'] = $dir['id'];
             $this->props['dir_uri'] = $this->props['uri'] = $dir['name'];
         } else {
             $this->props['error'] = '404';
         }
     } else {
         $this->props['uri'] = $clear_uri;
     }
     return $this->props;
 }
예제 #17
0
 function getIndex()
 {
     global $smarty;
     $title = str_replace(' ', '&nbsp;', $this->title);
     $message = CUtils::_getVar('message');
     if (sizeof($menu = $this->getMenuItems()) > 0) {
         foreach ($menu as $m) {
             if ($this->getBaseTableRef() == $m['ref']) {
                 $title .= ':&nbsp;' . $m['name'];
             }
         }
         if (CUtils::_getVar('action')) {
             switch (CUtils::_getVar('action')) {
                 case 's_table':
                     $title .= ':&nbsp;Настройка таблицы';
                     break;
                 case 's_insert':
                     $title .= ':&nbsp;Добавление';
                     break;
                 case 's_update':
                     $title .= ':&nbsp;Редактирование';
                     break;
             }
         }
     }
     $title .= !empty($message) ? ':&nbsp;' . $message : '';
     $smarty->assign('title', $title);
     $smarty->assign('body', $this->getContent());
     return $smarty->fetch('admin/mainbody.tpl');
 }
예제 #18
0
 function getText()
 {
     global $PRJ_DIR, $THEME_REF, $smarty;
     $links = array(array('ref' => $this->fullRef, 'name' => 'Список элементов'));
     $ret = $this->getOperationsBar($links);
     if (file_exists($PRJ_DIR . '/templates/admin/' . CUtils::_getVar('unit') . '.' . CUtils::_getVar('table') . '.edit.tpl')) {
         $smarty->assign('update_form', $this->getUpdateForm());
         $smarty->assign('sizes_form', $this->getSizesForm());
         $smarty->assign('files_form', $this->getFilesForm());
         $ret .= $smarty->fetch('admin/' . CUtils::_getVar('unit') . '.' . CUtils::_getVar('table') . '.edit.tpl');
     } else {
         $ret .= $this->getUpdateForm();
     }
     return $ret;
 }
예제 #19
0
<?php

include_once '../config.php';
inc_lib('common.php');
$item_table = CUtils::_getVar('table');
$item_field = CUtils::_getVar('field');
$item_id = CUtils::_getVar('id');