function Show() { if (!empty($GLOBALS['_POST'])) { $actions = get('actions', '', 'p'); if ($actions) { return $this->{$actions}(); } } // проверим есть ли pid и если есть то относится ли к нужному root_id $filter = get('filter', array()); if ($filter['all_pids']) { $page_root_id = sql_getValue("SELECT root_id FROM `tree` WHERE id='" . (int) $filter['all_pids'] . "'"); if ($page_root_id != domainRootID()) { $_GET['filter']['all_pids'] = 0; } } $tree = array(); $root_id = domainRootId(); if ($root_id > 0 && allowDomainForUser($root_id)) { $tree = $tree + $this->getPages((int) $root_id); $temp = $tree; $tree = array(); foreach ($temp as $val) { $tree[$val['id']] = $val['name']; } } $filter_pid_value = array('' => 'все') + $tree; // строим таблицу require_once core('list_table'); $data['table'] = list_table(array('columns' => array(array('select' => 'p.id', 'display' => 'id', 'type' => 'checkbox'), array('select' => 'p.name', 'display' => 'name', 'flags' => FLAG_SORT | FLAG_SEARCH), array('select' => 'UNIX_TIMESTAMP(p.date)', 'as' => 'date', 'display' => 'date', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'date', 'filter_value' => 'date', 'type' => 'date'), array('select' => 'p.pid', 'display' => 'pid', 'type' => 'dir'), $root_id > 0 ? array('select' => 'CAST(CONCAT(p.pid,\',\',p.pids) AS CHAR)', 'as' => 'all_pids', 'flags' => FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => $filter_pid_value, 'filter_display' => 'pid', 'filter_rule' => 'find_in_set') : array('select' => 'CAST(CONCAT(p.pid,\',\',p.pids) AS CHAR)', 'as' => 'all_pids'), array('select' => 'p.visible', 'display' => 'visible', 'type' => 'visible', 'flags' => FLAG_SORT | FLAG_FILTER, 'filter_type' => 'array', 'filter_value' => array('') + array('1' => 'Да', '2' => 'Нет'), 'filter_field' => 'IF(p.visible=0,2,1)'), array('select' => 'p.id', 'display' => 'showInSite', 'type' => 'show'), array('select' => 't.dir'), array('select' => 't.root_id'), array('select' => 't.name', 'as' => 't_name', 'flags' => FLAG_SEARCH), array('select' => 'p.notice', 'flags' => FLAG_SEARCH), array('select' => 'p.text', 'flags' => FLAG_SEARCH)), 'from' => $this->table . " as p\n\t\t\tLEFT JOIN `tree` as t ON t . id = p . pid\n\t\t\t", 'where' => (domainRootId() > 0 ? ' (t.root_id=' . domainRootId() . ' OR t.root_id IS NULL OR FIND_IN_SET(' . domainRootId() . ', (SELECT GROUP_CONCAT( DISTINCT CAST(root_id AS CHAR)) FROM tree WHERE FIND_IN_SET(id, CONCAT(p.pid, ",", p.pids)))) )' : '') . $this->where_extra, 'orderby' => 'p.date DESC', 'params' => array('page' => $this->name, 'do' => 'show'), 'dblclick' => 'editItem(p.id)', 'click' => 'ID=cb.value'), $this); $data['table'] .= "<script type='text/javascript'>\n \$('ul.navPanel').find('a:first').attr('onclick','').click(function(){\n \$('.createbox').show().find('input[type=text]').focus();\n });\n </script>\n <style type='text/css'>\n .createbox {\n width:307px;\n height:100px;\n background-color:#fff;\n border:2px solid #FAAE3E;\n position:fixed;\n left:550px;\n top:400px;\n display:none;\n padding:10px;\n box-shadow:5px 5px 5px rgba(0,0,0,0.5);\n }\n .createbox .close {\n text-decoration:none;\n position:relative;\n top:-7px;\n left:304px;\n font-size:16px;\n color:#f00;\n }\n </style>\n <div class='createbox'>\n <a href='javascript:void(0);' onclick='\$(\".createbox\").hide();' class='close'>X</a>\n <form action='' method='post'>\n <input type='hidden' name='page' value='{$this->name}' />\n <input type='hidden' name='do' value='editCreate' />\n <!--input type='hidden' name='ref' value='/admin/editor.php?page={$this->name}' /-->\n <label>Введите название новой публикации:</label>\n <input type='text' class='text' name='fld[name]' id='fld_name' value='' />\n <a href='javascript:void(0);' onclick='if(\$(this).parent().find(\"#fld_name\").val()) \$(this).parent().submit(); else alert(\"Вы не ввели название публикации\");' class='button' style='position:relative;left:90px;top:5px;'><span>Создать</span></a>\n </form>\n </div>"; $this->AddStrings($data); return $this->Parse($data, LIST_TEMPLATE); }
function ElemInit() { // есть ли привязку к сайту $is_root_id = sql_getValue("SHOW COLUMNS FROM " . $this->elem_table . " LIKE 'root_id'"); if (!$is_root_id) { unset($this->elem_fields['columns']['root_id']); } else { global $site_domains; $count = 0; $root_id = 0; foreach ($site_domains as $site) { foreach ($site['langs'] as $lang) { if (!allowDomainForUser($lang['root_id'])) { continue; } $root_id = $lang['root_id']; $count++; } } if ($count == 1) { $this->elem_fields['columns']['root_id']['value'] = $root_id; } } TElems::ElemInit(); }
function getRoots() { global $site_domains; $ret = array(); foreach ($site_domains as $site) { foreach ($site['langs'] as $lang) { if (!allowDomainForUser($lang['root_id'])) { continue; } $ret[$lang['root_id']] = $site['name'] . ' (' . $lang['descr'] . ')'; } } return $ret; }