Ejemplo n.º 1
0
function applet_arhive()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES_ARCHIVE']);
    $cfg = $inCore->loadComponentConfig('content');
    $cfg_arhive = $inCore->loadComponentConfig('arhive');
    cpAddPathway($_LANG['AD_ARTICLE_SITE'], 'index.php?view=tree');
    cpAddPathway($_LANG['AD_ARTICLES_ARCHIVE'], 'index.php?view=arhive');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'saveconfig') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $cfg['source'] = cmsCore::request('source', 'str', '');
        $inCore->saveComponentConfig('arhive', $cfg);
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('?view=arhive&do=config');
    }
    if ($do == 'config') {
        $toolmenu = array(array('icon' => 'folders.gif', 'title' => $_LANG['AD_LIST_OF_ARTICLES'], 'link' => '?view=arhive'));
        cpToolMenu($toolmenu);
        cpAddPathway($_LANG['AD_SETTINGS'], 'index.php?view=arhive&do=config');
        cmsCore::c('page')->initTemplate('applets', 'arhive')->assign('cfg_arhive', $cfg_arhive)->display();
    }
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'config.gif', 'title' => $_LANG['AD_SETTINGS'], 'link' => '?view=arhive&do=config'), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=arhive&do=delete&multiple=1');"));
        cpToolMenu($toolmenu);
        //TABLE COLUMNS
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_CREATE'], 'field' => 'pubdate', 'width' => '80', 'filter' => 15, 'fdate' => '%d/%m/%Y'), array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=content&do=edit&id=%id%', 'filter' => 15), array('title' => $_LANG['AD_PARTITION'], 'field' => 'category_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpCatById', 'filterlist' => cpGetList('cms_category')));
        //ACTIONS
        $actions = array(array('title' => $_LANG['AD_TO_ARTICLES_CATALOG'], 'icon' => 'arhive_off.gif', 'link' => '?view=arhive&do=arhive_off&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=content&do=delete&id=%id%', 'confirm' => $_LANG['AD_DELETE_MATERIALS']));
        //Print table
        cpListTable('cms_content', $fields, $actions, 'is_arhive=1');
    }
    if ($do == 'arhive_off') {
        if (cmsCore::inRequest('id')) {
            cmsCore::c('db')->setFlag('cms_content', $id, 'is_arhive', '0');
            cmsCore::redirect('?view=arhive');
        }
    }
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                cmsCore::m('content')->deleteArticle($id, $cfg['af_delete']);
            }
        } else {
            cmsCore::m('content')->deleteArticles(cmsCore::request('item', 'array_int'), $cfg['af_delete']);
        }
        cmsCore::redirect('?view=arhive');
    }
}
Ejemplo n.º 2
0
function applet_tree()
{
    $inCore = cmsCore::getInstance();
    cmsCore::loadLib('tags');
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES']);
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    cmsCore::c('page')->addHeadJS('admin/js/content.js');
    echo '<script>';
    echo cmsPage::getLangJS('AD_NO_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_DELETE_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_PIECES');
    echo cmsPage::getLangJS('AD_CATEGORY_DELETE');
    echo cmsPage::getLangJS('AD_AND_SUB_CATS');
    echo cmsPage::getLangJS('AD_DELETE_SUB_ARTICLES');
    echo '</script>';
    $do = cmsCore::request('do', 'str', 'tree');
    if ($do == 'tree') {
        $toolmenu = array(array('icon' => 'config.gif', 'title' => $_LANG['AD_SETUP_CATEGORY'], 'link' => '?view=components&do=config&link=content'), array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=components&do=config&link=content'));
        cpToolMenu($toolmenu);
        $only_hidden = cmsCore::request('only_hidden', 'int', 0);
        $category_id = cmsCore::request('cat_id', 'int', 0);
        $base_uri = 'index.php?view=tree';
        $title_part = cmsCore::request('title', 'str', '');
        $def_order = $category_id ? 'con.ordering' : 'pubdate';
        $orderby = cmsCore::request('orderby', 'str', $def_order);
        $orderto = cmsCore::request('orderto', 'str', 'asc');
        $page = cmsCore::request('page', 'int', 1);
        $perpage = 20;
        if ($category_id) {
            cmsCore::m('content')->whereCatIs($category_id);
        }
        if ($title_part) {
            cmsCore::c('db')->where('LOWER(con.title) LIKE \'%' . mb_strtolower($title_part) . '%\'');
        }
        if ($only_hidden) {
            cmsCore::c('db')->where('con.published = 0');
        }
        cmsCore::c('db')->orderBy($orderby, $orderto);
        cmsCore::c('db')->limitPage($page, $perpage);
        $total = cmsCore::m('content')->getArticlesCount(false);
        cmsCore::c('page')->initTemplate('applets', 'tree')->assign('hide_cats', cmsCore::request('hide_cats', 'int', 0))->assign('only_hidden', $only_hidden)->assign('base_uri', $base_uri)->assign('category_id', $category_id)->assign('cats', cmsCore::m('content')->getCatsTree())->assign('orderto', $orderto)->assign('orderby', $orderby)->assign('title_part', $title_part)->assign('category_opt', $inCore->getListItemsNS('cms_category', $category_id))->assign('page', $page)->assign('total', $total)->assign('perpage', $perpage)->assign('pages', ceil($total / $perpage))->assign('items', cmsCore::m('content')->getArticlesList(false))->display();
    }
}
Ejemplo n.º 3
0
function applet_content()
{
    $inCore = cmsCore::getInstance();
    $inUser = cmsUser::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    //check access
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    $cfg = $inCore->loadComponentConfig('content');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'arhive_on') {
        $inDB->query("UPDATE cms_content SET is_arhive = 1 WHERE id = '{$id}'");
        cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO_ARHIVE'], 'success');
        cmsCore::redirectBack();
    }
    if ($do == 'move') {
        $item_id = cmsCore::request('id', 'int', 0);
        $cat_id = cmsCore::request('cat_id', 'int', 0);
        $dir = $_REQUEST['dir'];
        $step = 1;
        $model->moveItem($item_id, $cat_id, $dir, $step);
        echo '1';
        exit;
    }
    if ($do == 'move_to_cat') {
        $items = cmsCore::request('item', 'array_int');
        $to_cat_id = cmsCore::request('obj_id', 'int', 0);
        if ($items && $to_cat_id) {
            $last_ordering = (int) $inDB->get_field('cms_content', "category_id = '{$to_cat_id}' ORDER BY ordering DESC", 'ordering');
            foreach ($items as $item_id) {
                $article = $model->getArticle($item_id);
                if (!$article) {
                    continue;
                }
                $last_ordering++;
                $model->updateArticle($article['id'], array('category_id' => $to_cat_id, 'ordering' => $last_ordering, 'url' => $article['url'], 'title' => $inDB->escape_string($article['title']), 'id' => $article['id'], 'user_id' => $article['user_id']));
            }
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO'], 'success');
        }
        cmsCore::redirect('?view=tree&cat_id=' . $to_cat_id);
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_content', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_content', cmsCore::request('item', 'array_int'));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_content', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_content', cmsCore::request('item', 'array_int'));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $model->deleteArticle($id);
                cmsCore::addSessionMessage($_LANG['AD_ARTICLE_REMOVE'], 'success');
            }
        } else {
            $model->deleteArticles(cmsCore::request('item', 'array_int'));
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_REMOVE'], 'success');
        }
        cmsCore::redirectBack();
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        if (isset($_REQUEST['id'])) {
            $id = cmsCore::request('id', 'int', 0);
            $article['category_id'] = cmsCore::request('category_id', 'int', 1);
            $article['title'] = cmsCore::request('title', 'str');
            $article['url'] = cmsCore::request('url', 'str');
            $article['showtitle'] = cmsCore::request('showtitle', 'int', 0);
            $article['description'] = cmsCore::request('description', 'html', '');
            $article['description'] = $inDB->escape_string($article['description']);
            $article['content'] = cmsCore::request('content', 'html', '');
            $article['content'] = $inDB->escape_string($article['content']);
            $article['for_img'] = cmsCore::request('for_img', 'html', '');
            $article['for_img'] = $inDB->escape_string($article['for_img']);
            $article['published'] = cmsCore::request('published', 'int', 0);
            $article['showdate'] = cmsCore::request('showdate', 'int', 0);
            $article['showlatest'] = cmsCore::request('showlatest', 'int', 0);
            $article['show_in_new'] = cmsCore::request('show_in_new', 'int', 0);
            //new
            $article['show_in_footer'] = cmsCore::request('show_in_footer', 'int', 0);
            //new
            $article['showpath'] = cmsCore::request('showpath', 'int', 0);
            $article['comments'] = cmsCore::request('comments', 'int', 0);
            $article['canrate'] = cmsCore::request('canrate', 'int', 0);
            $article['add_text'] = cmsCore::request('add_text', 'str');
            $enddate = explode('.', cmsCore::request('enddate', 'str'));
            $article['enddate'] = $enddate[2] . '-' . $enddate[1] . '-' . $enddate[0];
            $article['is_end'] = cmsCore::request('is_end', 'int', 0);
            $article['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
            $article['tags'] = cmsCore::request('tags', 'str');
            $olddate = cmsCore::request('olddate', 'str', '');
            $pubdate = cmsCore::request('pubdate', 'str', '');
            $article['user_id'] = cmsCore::request('user_id', 'int', $inUser->id);
            $article['tpl'] = cmsCore::request('tpl', 'str', 'com_content_read.tpl');
            $date = explode('.', $pubdate);
            $article['pubdate'] = $date[2] . '-' . $date[1] . '-' . $date[0] . ' ' . date('H:i');
            $autokeys = cmsCore::request('autokeys', 'int');
            switch ($autokeys) {
                case 1:
                    $article['meta_keys'] = $inCore->getKeywords($article['content']);
                    $article['meta_desc'] = $article['title'];
                    break;
                case 2:
                    $article['meta_desc'] = strip_tags($article['description']);
                    $article['meta_keys'] = $article['tags'];
                    break;
                case 3:
                    $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                    $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                    break;
            }
            $model->updateArticle($id, $article);
            if (!cmsCore::request('is_public', 'int', 0)) {
                $showfor = $_REQUEST['showfor'];
                cmsCore::setAccess($id, $showfor, 'material');
            } else {
                cmsCore::clearAccess($id, 'material');
            }
            if (isset($_SESSION['lang']) && $_SESSION['lang'] != 'ru') {
                $file = 'article' . $id . '_' . $_SESSION['lang'] . '.jpg';
            } else {
                $file = 'article' . $id . '.jpg';
            }
            //$file = 'article'.$id.'.jpg';
            if (cmsCore::request('delete_image', 'int', 0)) {
                @unlink(PATH . "/images/photos/small/{$file}");
                @unlink(PATH . "/images/photos/medium/{$file}");
            } else {
                // Загружаем класс загрузки фото
                cmsCore::loadClass('upload_photo');
                $inUploadPhoto = cmsUploadPhoto::getInstance();
                // Выставляем конфигурационные параметры
                $inUploadPhoto->upload_dir = PATH . '/images/photos/';
                $inUploadPhoto->small_size_w = $model->config['img_small_w'];
                $inUploadPhoto->medium_size_w = $model->config['img_big_w'];
                $inUploadPhoto->thumbsqr = $model->config['img_sqr'];
                $inUploadPhoto->is_watermark = $model->config['watermark'];
                $inUploadPhoto->input_name = 'picture';
                $inUploadPhoto->filename = $file;
                // Процесс загрузки фото
                $inUploadPhoto->uploadPhoto();
            }
            cmsCore::addSessionMessage($_LANG['AD_ARTICLE_SAVE'], 'success');
            if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
                cmsCore::redirect('?view=tree&cat_id=' . $article['category_id']);
            } else {
                cmsCore::redirect('?view=content&do=edit');
            }
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $article['category_id'] = cmsCore::request('category_id', 'int', 1);
        $article['title'] = cmsCore::request('title', 'str');
        $article['url'] = cmsCore::request('url', 'str');
        $article['showtitle'] = cmsCore::request('showtitle', 'int', 0);
        $article['description'] = cmsCore::request('description', 'html', '');
        $article['description'] = $inDB->escape_string($article['description']);
        $article['content'] = cmsCore::request('content', 'html', '');
        $article['content'] = $inDB->escape_string($article['content']);
        $article['for_img'] = cmsCore::request('for_img', 'html', '');
        $article['for_img'] = $inDB->escape_string($article['for_img']);
        $article['published'] = cmsCore::request('published', 'int', 0);
        $article['showdate'] = cmsCore::request('showdate', 'int', 0);
        $article['showlatest'] = cmsCore::request('showlatest', 'int', 0);
        $article['show_in_new'] = cmsCore::request('show_in_new', 'int', 0);
        //new
        $article['show_in_footer'] = cmsCore::request('show_in_footer', 'int', 0);
        //new
        $article['showpath'] = cmsCore::request('showpath', 'int', 0);
        $article['comments'] = cmsCore::request('comments', 'int', 0);
        $article['canrate'] = cmsCore::request('canrate', 'int', 0);
        $article['add_text'] = cmsCore::request('add_text', 'str');
        $enddate = explode('.', cmsCore::request('enddate', 'str'));
        $article['enddate'] = $enddate[2] . '-' . $enddate[1] . '-' . $enddate[0];
        $article['is_end'] = cmsCore::request('is_end', 'int', 0);
        $article['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $article['tags'] = cmsCore::request('tags', 'str');
        $article['pubdate'] = $_REQUEST['pubdate'];
        $date = explode('.', $article['pubdate']);
        $article['pubdate'] = $date[2] . '-' . $date[1] . '-' . $date[0] . ' ' . date('H:i');
        $article['user_id'] = cmsCore::request('user_id', 'int', $inUser->id);
        $article['tpl'] = cmsCore::request('tpl', 'str', 'com_content_read.tpl');
        $autokeys = cmsCore::request('autokeys', 'int');
        switch ($autokeys) {
            case 1:
                $article['meta_keys'] = $inCore->getKeywords($article['content']);
                $article['meta_desc'] = $article['title'];
                break;
            case 2:
                $article['meta_desc'] = strip_tags($article['description']);
                $article['meta_keys'] = $article['tags'];
                break;
            case 3:
                $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                break;
        }
        $article['id'] = $model->addArticle($article);
        if (!cmsCore::request('is_public', 'int', 0)) {
            $showfor = $_REQUEST['showfor'];
            if (sizeof($showfor) > 0 && !cmsCore::request('is_public', 'int', 0)) {
                cmsCore::setAccess($article['id'], $showfor, 'material');
            }
        }
        $inmenu = cmsCore::request('createmenu', 'str', '');
        if ($inmenu) {
            createMenuItem($inmenu, $article['id'], $article['title']);
        }
        // Загружаем класс загрузки фото
        cmsCore::loadClass('upload_photo');
        $inUploadPhoto = cmsUploadPhoto::getInstance();
        // Выставляем конфигурационные параметры
        $inUploadPhoto->upload_dir = PATH . '/images/photos/';
        $inUploadPhoto->small_size_w = $model->config['img_small_w'];
        $inUploadPhoto->medium_size_w = $model->config['img_big_w'];
        $inUploadPhoto->thumbsqr = $model->config['img_sqr'];
        $inUploadPhoto->is_watermark = $model->config['watermark'];
        $inUploadPhoto->input_name = 'picture';
        $inUploadPhoto->filename = 'article' . $article['id'] . '.jpg';
        // Процесс загрузки фото
        $inUploadPhoto->uploadPhoto();
        cmsCore::addSessionMessage($_LANG['AD_ARTICLE_ADD'], 'success');
        cmsCore::redirect('?view=tree&cat_id=' . $article['category_id']);
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'save.gif';
        $toolmenu[0]['title'] = $_LANG['SAVE'];
        $toolmenu[0]['link'] = 'javascript:document.addform.submit();';
        $toolmenu[1]['icon'] = 'cancel.gif';
        $toolmenu[1]['title'] = $_LANG['CANCEL'];
        $toolmenu[1]['link'] = 'javascript:history.go(-1);';
        cpToolMenu($toolmenu);
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_CREATE_ARTICLE'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_ARTICLE'], 'index.php?view=content&do=add');
            $mod['category_id'] = (int) $_REQUEST['to'];
            $mod['showpath'] = 1;
            $mod['tpl'] = 'com_content_read.tpl';
        } else {
            if (isset($_REQUEST['item'])) {
                $_SESSION['editlist'] = $_REQUEST['item'];
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $id = (int) $_REQUEST['id'];
            }
            $sql = "SELECT *, (TO_DAYS(enddate) - TO_DAYS(CURDATE())) as daysleft, DATE_FORMAT(pubdate, '%d.%m.%Y') as pubdate, DATE_FORMAT(enddate, '%d.%m.%Y') as enddate\n\t\t\t\t\t FROM cms_content\n\t\t\t\t\t WHERE id = {$id} LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $mod = $inDB->fetch_assoc($result);
            }
            echo '<h3>' . $_LANG['AD_EDIT_ARTICLE'] . $ostatok . '</h3>';
            cpAddPathway($mod['title'], 'index.php?view=content&do=edit&id=' . $mod['id']);
        }
        ?>
    <form id="addform" name="addform" method="post" action="index.php" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="content" />

        <table class="proptable" width="100%" cellpadding="5" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">

                    <table width="100%" cellpadding="0" cellspacing="4" border="0">
                        <tr>
                            <td valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_ARTICLE_NAME'];
        ?>
</strong></div>
                                <div>
                                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                            <td><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></td>
                                            <td style="width:15px;padding-left:10px;padding-right:10px;">
                                                <input type="checkbox" title="<?php 
        echo $_LANG['AD_VIEW_TITLE'];
        ?>
" name="showtitle" <?php 
        if ($mod['showtitle'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
 value="1">
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                            <td width="130" valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_PUBLIC_DATE'];
        ?>
</strong></div>
                                <div>
                                    <input name="pubdate" type="text" id="pubdate" style="width:100px" <?php 
        if (@(!$mod['pubdate'])) {
            echo 'value="' . date('d.m.Y') . '"';
        } else {
            echo 'value="' . $mod['pubdate'] . '"';
        }
        ?>
/>

                                    <input type="hidden" name="olddate" value="<?php 
        echo @$mod['pubdate'];
        ?>
" />
                                </div>
                            </td>
                            <td width="16" valign="bottom" style="padding-bottom:10px">
                                <input type="checkbox" name="showdate" id="showdate" title="<?php 
        echo $_LANG['AD_VIEW_DATE_AND_AUTHOR'];
        ?>
" value="1" <?php 
        if ($mod['showdate'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/>
                            </td>
<!--                             <td width="160" valign="top">
                                <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TEMPLATE'];
        ?>
</strong></div>
                                <div><input name="tpl" type="text" style="width:160px" value="<?php 
        echo @$mod['tpl'];
        ?>
"></div>
                            </td> -->
							  <td width="160" valign="top">
                                <div><strong>Шаблон статьи</strong></div>
								<?php 
        $inConf = cmsConfig::getInstance();
        //задаём имя директории
        $directory = PATH . "/templates/" . $inConf->template . "/components";
        $scan_dir = scandir($directory);
        if (is_dir($directory)) {
            //проверяем наличие директории
            //директория существует
            echo '<select name="tpl">';
            $scan_dir = scandir($directory);
            //сканируем (получаем массив файлов)
            array_shift($scan_dir);
            // удаляем из массива '.'
            array_shift($scan_dir);
            // удаляем из массива '..'
            for ($i = 0; $i < sizeof($scan_dir); $i++) {
                $tpl = explode("_", $scan_dir[$i]);
                if ($_GET['view'] == $tpl['1']) {
                    if ($_GET['view']) {
                        //выводим все файлы
                        if (@$mod["tpl"] == $scan_dir[$i]) {
                            echo '<option selected>' . $scan_dir[$i] . '</option>';
                        } else {
                            echo '<option>' . $scan_dir[$i] . '</option>';
                        }
                    }
                }
            }
            echo '</select>';
        } else {
            echo '<input name="tpl" type="text" style="width:160px" value="' . @$mod["tpl"] . '">';
        }
        ?>
                            </td>

                        </tr>
                    </table>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_NOTICE'];
        ?>
</strong></div>
                    <div><?php 
        $inCore->insertEditor('description', $mod['description'], '200', '100%');
        ?>
</div>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TEXT'];
        ?>
</strong></div>
                    <?php 
        insertPanel();
        ?>
                    <div><?php 
        $inCore->insertEditor('content', $mod['content'], '400', '100%');
        ?>
</div><!--Editor text in articles-->

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_IMG'];
        ?>
</strong></div>
                    <div><?php 
        $inCore->insertEditor('for_img', $mod['for_img'], '200', '100%');
        ?>
</div>

                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_ADD_TEXT'];
        ?>
</strong></div>
                    <div><input name="add_text" type="text" id="add_text" style="width:99%" value="<?php 
        echo htmlspecialchars($mod['add_text']);
        ?>
" /></div>


                    <div><strong><?php 
        echo $_LANG['AD_ARTICLE_TAGS'];
        ?>
</strong></div>
                    <div><input name="tags" type="text" id="tags" style="width:99%" value="<?php 
        if (isset($mod['id'])) {
            echo cmsTagLine('content', $mod['id'], false);
        }
        ?>
" /></div>

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys1" <?php 
        if ($do == 'add' && $cfg['autokeys']) {
            ?>
checked="checked"<?php 
        }
        ?>
 value="1"/>
                            </td>
                            <td>
                                <label for="autokeys1"><strong><?php 
        echo $_LANG['AD_AUTO_GEN_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys2" value="2"/>
                            </td>
                            <td>
                                <label for="autokeys2"><strong><?php 
        echo $_LANG['AD_TAGS_AS_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys3" value="3" <?php 
        if ($do == 'edit' || !$cfg['autokeys']) {
            ?>
checked="checked"<?php 
        }
        ?>
/>
                            </td>
                            <td>
                                <label for="autokeys3"><strong><?php 
        echo $_LANG['AD_MANUAL_KEY'];
        ?>
</strong></label>
                            </td>
                        </tr>

                        <?php 
        if ($cfg['af_on'] && $do == 'add') {
            ?>
                        <tr>
                            <td width="20"><input type="checkbox" name="noforum" id="noforum" value="1" /> </td>
                            <td><label for="noforum"><strong><?php 
            echo $_LANG['AD_NO_CREATE_THEME'];
            ?>
</strong></label></td>
                        </tr>
                        <?php 
        }
        ?>
                    </table>

                </td>

                <!-- боковая ячейка -->
                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_PUBLIC_ARTICLE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

                    <div style="margin-top:7px">
                        <select name="category_id" size="10" id="category_id" style="width:99%;height:200px">
                            <option value="1" <?php 
        if (@$mod['category_id'] == 1 || !isset($mod['category_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_ROOT_CATEGORY'];
        ?>
</option>
                            <?php 
        if (isset($mod['category_id'])) {
            echo $inCore->getListItemsNS('cms_category', $mod['category_id']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                        </select>
                    </div>

                    <div style="margin-bottom:10px">
                        <select name="showpath" id="showpath" style="width:99%">
                            <option value="0" <?php 
        if (@(!$mod['showpath'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_PATHWAY_NAME_ONLY'];
        ?>
</option>
                            <option value="1" <?php 
        if (@$mod['showpath']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_PATHWAY_FULL'];
        ?>
</option>
                        </select>
                    </div>

                    <div style="margin-top:15px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_URL'];
        ?>
</strong><br/>
                        <div style="color:gray"><?php 
        echo $_LANG['AD_IF_UNKNOWN'];
        ?>
</div>
                    </div>
                    <div>
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td><input type="text" name="url" value="<?php 
        echo $mod['url'];
        ?>
" style="width:100%"/></td>
                                <td width="40" align="center">.html</td>
                            </tr>
                        </table>
                    </div>

                    <div style="margin-top:10px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_AUTHOR'];
        ?>
</strong>
                    </div>
                    <div>
                        <select name="user_id" id="user_id" style="width:99%">
                          <?php 
        if (isset($mod['user_id'])) {
            echo $inCore->getListItems('cms_users', $mod['user_id'], 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        } else {
            echo $inCore->getListItems('cms_users', $inUser->id, 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        }
        ?>
                        </select>
                    </div>

                    <div style="margin-top:12px"><strong><?php 
        echo $_LANG['AD_PHOTO'];
        ?>
</strong></div>
                    <div style="margin-bottom:10px">
                        <?php 
        if ($do == 'edit') {
            if (isset($_SESSION['lang']) && $_SESSION['lang'] != 'ru') {
                $mod_id = $mod['id'] . '_' . $_SESSION['lang'];
                $id_art = $mod['id'] . '_' . $_SESSION['lang'];
            } else {
                $mod_id = $mod['id'];
                $id_art = $id;
            }
            //if (file_exists(PATH.'/images/photos/small/article'.$mod['id'].'.jpg')){
            if (file_exists(PATH . '/images/photos/small/article' . $mod_id . '.jpg')) {
                ?>
                        <div style="margin-top:3px;margin-bottom:3px;padding:10px;border:solid 1px gray;text-align:center">
                            <?/*php<img src="/images/photos/small/article<?php 
                echo $id;
                ?>
.jpg" border="0" />*/?>
                            <img src="/images/photos/small/article<?php 
                echo $id_art;
                ?>
.jpg" border="0" />
                        </div>
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td width="16"><input type="checkbox" id="delete_image" name="delete_image" value="1" /></td>
                                <td><label for="delete_image"><?php 
                echo $_LANG['AD_PHOTO_REMOVE'];
                ?>
</label></td>
                            </tr>
                        </table>
                        <?php 
            }
        }
        ?>
                        <input type="file" name="picture" style="width:100%" />
                    </div>

                    <div style="margin-top:25px"><strong><?php 
        echo $_LANG['AD_PUBLIC_PARAMETRS'];
        ?>
</strong></div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="show_in_new" id="show_in_new" value="1" <?php 
        if ($mod['show_in_new'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="show_in_new"><?php 
        echo $_LANG['AD_VIEW_NEW_CATS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="show_in_footer" id="show_in_footer" value="1" <?php 
        if ($mod['show_in_footer'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="show_in_footer"><?php 
        echo $_LANG['AD_VIEW_FOOTER'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showlatest" id="showlatest" value="1" <?php 
        if ($mod['showlatest'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showlatest"><?php 
        echo $_LANG['AD_VIEW_NEW_ARTICLES'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="comments" id="comments" value="1" <?php 
        if ($mod['comments'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="comments"><?php 
        echo $_LANG['AD_ENABLE_COMMENTS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="canrate" id="canrate" value="1" <?php 
        if ($mod['canrate']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="canrate"><?php 
        echo $_LANG['AD_ENABLE_RATING'];
        ?>
</label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'add') {
            ?>
                        <div style="margin-top:25px">
                            <strong><?php 
            echo $_LANG['AD_CREATE_LINK'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="createmenu" id="createmenu" style="width:99%">
                                <option value="0" selected="selected"><?php 
            echo $_LANG['AD_DONT_CREATE_LINK'];
            ?>
</option>
                            <?php 
            foreach ($menu_list as $menu) {
                ?>
                                <option value="<?php 
                echo $menu['id'];
                ?>
">
                                    <?php 
                echo $menu['title'];
                ?>
                                </option>
                            <?php 
            }
            ?>
                            </select>
                        </div>
                    <?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_DATE'];
        ?>
}

                    <div style="margin-top:5px">
                        <strong><?php 
        echo $_LANG['AD_ARTICLE_TIME'];
        ?>
</strong>
                    </div>
                    <div>
                        <select name="is_end" id="is_end" style="width:99%" onchange="if($(this).val() == 1){ $('#final_time').show(); }else {$('#final_time').hide();}">
                            <option value="0" <?php 
        if (@(!$mod['is_end'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_UNLIMITED'];
        ?>
</option>
                            <option value="1" <?php 
        if (@$mod['is_end']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_TO_FINAL_TIME'];
        ?>
</option>
                        </select>
                    </div>

                    <div id="final_time" <?php 
        if (@(!$mod['is_end'])) {
            echo 'style="display: none"';
        }
        ?>
>
                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['AD_FINAL_TIME'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_CALENDAR_FORMAT'];
        ?>
</span>
                    </div>
                    <div><input name="enddate" type="text" style="width:80%" <?php 
        if (@(!$mod['is_end'])) {
            echo 'value="' . date('d.m.Y') . '"';
        } else {
            echo 'value="' . $mod['enddate'] . '"';
        }
        ?>
id="enddate" /></div></div>


                    {tab=SEO}

                    <div style="margin-top:5px">
                        <strong><?php 
        echo $_LANG['AD_PAGE_TITLE'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_IF_UNKNOWN_PAGETITLE'];
        ?>
</span>
                    </div>
                    <div>
                        <input name="pagetitle" type="text" id="pagetitle" style="width:99%" value="<?php 
        if (isset($mod['pagetitle'])) {
            echo htmlspecialchars($mod['pagetitle']);
        }
        ?>
" />
                    </div>

                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['KEYWORDS'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_FROM_COMMA'];
        ?>
</span>
                    </div>
                    <div>
                         <textarea name="meta_keys" style="width:97%" rows="4" id="meta_keys"><?php 
        echo htmlspecialchars($mod['meta_keys']);
        ?>
</textarea>
                    </div>

                    <div style="margin-top:20px">
                        <strong><?php 
        echo $_LANG['DESCRIPTION'];
        ?>
</strong><br/>
                        <span class="hinttext"><?php 
        echo $_LANG['AD_LESS_THAN'];
        ?>
</span>
                    </div>
                    <div>
                         <textarea name="meta_desc" style="width:97%" rows="6" id="meta_desc"><?php 
        echo htmlspecialchars($mod['meta_desc']);
        ?>
</textarea>
                    </div>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $sql = "SELECT * FROM cms_user_groups";
        $result = $inDB->query($sql);
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            $sql2 = "SELECT * FROM cms_content_access WHERE content_id = " . $mod['id'] . " AND content_type = 'material'";
            $result2 = $inDB->query($sql2);
            $ord = array();
            if ($inDB->num_rows($result2)) {
                $public = '';
                $style = '';
                while ($r = $inDB->fetch_assoc($result2)) {
                    $ord[] = $r['group_id'];
                }
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkGroupList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_IF_NOTED'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" ' . $style . '>';
        if ($inDB->num_rows($result)) {
            while ($item = $inDB->fetch_assoc($result)) {
                echo '<option value="' . $item['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($ord, $item['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $item['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>

        <p>
            <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_CREATE_CONTENT'] . '"';
        } else {
            echo 'value="' . $_LANG['AD_SAVE_CONTENT'] . '"';
        }
        ?>
 />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
    </form>
    <?php 
    }
}
Ejemplo n.º 4
0
function applet_plugins()
{
    global $_LANG;
    $inCore = cmsCore::getInstance();
    $GLOBALS['cp_page_title'] = $_LANG['AD_PLUGINS'];
    cpAddPathway($_LANG['AD_PLUGINS'], 'index.php?view=plugins');
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
        cpAccessDenied();
    }
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    // ===================================================================================== //
    if ($do == 'hide') {
        dbHide('cms_plugins', $id);
        echo '1';
        exit;
    }
    // ===================================================================================== //
    if ($do == 'show') {
        dbShow('cms_plugins', $id);
        echo '1';
        exit;
    }
    // ===================================================================================== //
    if ($do == 'list') {
        $toolmenu = array();
        $toolmenu[1]['icon'] = 'install.gif';
        $toolmenu[1]['title'] = $_LANG['AD_INSTALL_PLUGINS'];
        $toolmenu[1]['link'] = '?view=install&do=plugin';
        cpToolMenu($toolmenu);
        $plugin_id = cmsCore::request('installed', 'str', '');
        if ($plugin_id) {
            $task = cmsCore::request('task', 'str', 'install');
            if ($task == 'install' || $task == 'upgrade') {
                $plugin = $inCore->loadPlugin($plugin_id);
                $task_str = $task == 'install' ? $_LANG['AD_IS_INSTALL'] : $_LANG['AD_IS_UPDATE'];
                echo '<div style="color:green;margin-top:12px;margin-bottom:5px;">' . $_LANG['AD_PLUGIN'] . ' <strong>"' . $plugin->info['title'] . '"</strong> ' . $task_str . '. ' . $_LANG['AD_ENABLE_PLUGIN'] . '.</div>';
            }
            if ($task == 'remove') {
                echo '<div style="color:green;margin-top:12px;margin-bottom:5px;">' . $_LANG['AD_REMOVE_PLUGIN_OK'] . '.</div>';
            }
        }
        $fields = array();
        $fields[0]['title'] = 'id';
        $fields[0]['field'] = 'id';
        $fields[0]['width'] = '20';
        $fields[1]['title'] = $_LANG['TITLE'];
        $fields[1]['field'] = 'title';
        $fields[1]['width'] = '250';
        $fields[2]['title'] = $_LANG['DESCRIPTION'];
        $fields[2]['field'] = 'description';
        $fields[2]['width'] = '';
        $fields[3]['title'] = $_LANG['AD_AUTHOR'];
        $fields[3]['field'] = 'author';
        $fields[3]['width'] = '160';
        $fields[4]['title'] = $_LANG['AD_VERSION'];
        $fields[4]['field'] = 'version';
        $fields[4]['width'] = '50';
        $fields[5]['title'] = $_LANG['AD_FOLDER'];
        $fields[5]['field'] = 'plugin';
        $fields[5]['width'] = '100';
        $fields[6]['title'] = $_LANG['AD_ENABLE'];
        $fields[6]['field'] = 'published';
        $fields[6]['width'] = '60';
        $actions = array();
        $actions[0]['title'] = $_LANG['AD_CONFIG'];
        $actions[0]['icon'] = 'config.gif';
        $actions[0]['link'] = '?view=plugins&do=config&id=%id%';
        $actions[1]['title'] = $_LANG['DELETE'];
        $actions[1]['icon'] = 'delete.gif';
        $actions[1]['confirm'] = $_LANG['AD_REMOVE_PLUGIN_FROM'];
        $actions[1]['link'] = '?view=install&do=remove_plugin&id=%id%';
        cpListTable('cms_plugins', $fields, $actions);
    }
    // ===================================================================================== //
    if ($do == 'save_config') {
        if (!cmsCore::validateForm()) {
            cmsCore::error404();
        }
        $plugin_name = cmsCore::request('plugin', 'str', 0);
        $config = cmsCore::request('config', 'array_str');
        if (!$config || !$plugin_name) {
            cmsCore::redirectBack();
        }
        $inCore->savePluginConfig($plugin_name, $config);
        cmsUser::clearCsrfToken();
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=plugins');
    }
    // ===================================================================================== //
    if ($do == 'config') {
        $plugin_name = $inCore->getPluginById($id);
        if (!$plugin_name) {
            cmsCore::error404();
        }
        $plugin = $inCore->loadPlugin($plugin_name);
        $config = $inCore->loadPluginConfig($plugin_name);
        $GLOBALS['cp_page_title'] = $plugin->info['title'];
        cpAddPathway($plugin->info['title'], 'index.php?view=plugins&do=config&id=' . $id);
        echo '<h3>' . $plugin->info['title'] . '</h3>';
        if (!$config) {
            echo '<p>' . $_LANG['AD_PLUGIN_DISABLE'] . '.</p>';
            echo '<p><a href="javascript:window.history.go(-1);">' . $_LANG['BACK'] . '</a></p>';
            return;
        }
        echo '<form action="index.php?view=plugins&do=save_config&plugin=' . $plugin_name . '" method="POST">';
        echo '<input type="hidden" name="csrf_token" value="' . cmsUser::getCsrfToken() . '" />';
        echo '<table class="proptable" width="605" cellpadding="8" cellspacing="0" border="0">';
        foreach ($config as $field => $value) {
            echo '<tr>';
            echo '<td width="150"><strong>' . (isset($_LANG[mb_strtoupper($field)]) ? $_LANG[mb_strtoupper($field)] : $field) . ':</strong></td>';
            echo '<td><input type="text" style="width:90%" name="config[' . $field . ']" value="' . htmlspecialchars($value) . '" /></td>';
            echo '</tr>';
        }
        echo '</table>';
        echo '<div style="margin-top:6px;">';
        echo '<input type="submit" name="save" value="' . $_LANG['SAVE'] . '" /> ';
        echo '<input type="button" name="back" value="' . $_LANG['CANCEL'] . '" onclick="window.history.go(-1)" />';
        echo '</div>';
        echo '</form>';
    }
    // ===================================================================================== //
}
Ejemplo n.º 5
0
function applet_usergroups()
{
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_USERS_GROUP'];
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_USERS_GROUP'], 'index.php?view=usergroups');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    cmsCore::loadModel('users');
    $model = new cms_model_users();
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'usergroupadd.gif', 'title' => $_LANG['AD_CREATE_GROUP'], 'link' => '?view=usergroups&do=add');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=usergroups&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('{$_LANG['AD_REMOVE_GROUP']}')) { checkSel('?view=users&do=delete&multiple=1'); }");
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=usergroups&do=edit&id=%id%', 'filter' => '12');
        $fields[] = array('title' => $_LANG['AD_FROM_USERS'], 'field' => 'id', 'width' => '100', 'prc' => 'getCountUsers');
        $fields[] = array('title' => $_LANG['AD_IF_ADMIN'], 'field' => 'is_admin', 'width' => '110', 'prc' => 'cpYesNo');
        $fields[] = array('title' => $_LANG['AD_ALIAS'], 'field' => 'alias', 'width' => '75', 'filter' => '12');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=usergroups&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_GROUP'], 'link' => '?view=usergroups&do=delete&id=%id%');
        cpListTable('cms_user_groups', $fields, $actions);
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $model->deleteGroup($id);
            }
        } else {
            $model->deleteGroups(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=usergroups');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('title' => array('title', 'str', ''), 'alias' => array('alias', 'str', ''), 'is_admin' => array('is_admin', 'int', 0), 'access' => array('access', 'array_str', array(), create_function('$a_list', 'return implode(\',\', $a_list);')));
        $items = cmsCore::getArrayFromRequest($types);
        if ($do == 'submit') {
            $inDB->insert('cms_user_groups', $items);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('index.php?view=usergroups');
        } else {
            $inDB->update('cms_user_groups', $items, $id);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=usergroups');
            } else {
                cmsCore::redirect('index.php?view=usergroups&do=edit');
            }
        }
    }
    if ($do == 'add' || $do == 'edit') {
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_CREATE_GROUP']);
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_user_groups', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_GROUP'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_GROUP'] . ' ' . $mod['title']);
        }
        if (isset($mod['access'])) {
            $mod['access'] = str_replace(', ', ',', $mod['access']);
            $mod['access'] = explode(',', $mod['access']);
        }
        ?>
	<form id="addform" name="addform" method="post" action="index.php?view=usergroups">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
		<table width="660" border="0" cellspacing="5" class="proptable">
			<tr>
				<td width="198" valign="top"><div><strong><?php 
        echo $_LANG['AD_GROUP_NAME'];
        ?>
: </strong></div><span class="hinttext"><?php 
        echo $_LANG['AD_VIEW_SITE'];
        ?>
</span></td>
				<td width="475" valign="top"><input name="title" type="text" id="title" size="30" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
"/></td>
			</tr>
			<tr>
				<td valign="top"><div><strong><?php 
        echo $_LANG['AD_ALIAS'];
        ?>
:</strong></div><?php 
        if ($do == 'edit') {
            ?>
<span class="hinttext"><?php 
            echo $_LANG['AD_DONT_CHANGE'];
            ?>
</span><?php 
        }
        ?>
</td>
    <td valign="top"><input name="alias" type="text" id="title3" <?php 
        if (@$mod['alias'] == 'guest') {
            ?>
readonly="readonly"<?php 
        }
        ?>
 size="30" value="<?php 
        echo @$mod['alias'];
        ?>
"/></td>
			</tr>
			<tr>
				<td><strong><?php 
        echo $_LANG['AD_IF_ADMIN'];
        ?>
</strong></td>
				<td>
					<label><input name="is_admin" type="radio" value="1" <?php 
        if (@$mod['is_admin']) {
            echo 'checked="checked"';
        }
        ?>
 onclick="$('#accesstable').hide();$('#admin_accesstable').show();"/> <?php 
        echo $_LANG['YES'];
        ?>
 </label>
					<label><input name="is_admin" type="radio" value="0"  <?php 
        if (@(!$mod['is_admin'])) {
            echo 'checked="checked"';
        }
        ?>
 onclick="$('#accesstable').show();$('#admin_accesstable').hide();"/> <?php 
        echo $_LANG['NO'];
        ?>
</label>
				</td>
			</tr>
		</table>

		<!--------------------------------------------------------------------------------------------------------------------------------------------->

		<table width="660" border="0" cellspacing="5" class="proptable" id="admin_accesstable" style="<?php 
        if (@(!$mod['is_admin'])) {
            echo 'display:none;';
        }
        ?>
">
			<tr>
				<td width="191" valign="top">
					<div><strong><?php 
        echo $_LANG['AD_AVAILABLE_SECTIONS'];
        ?>
 </strong></div>
					<span class="hinttext"><?php 
        echo $_LANG['AD_ALL_SECTIONS'];
        ?>
</span>
				</td>
				<td width="475" valign="top">
					<table width="100%" border="0" cellspacing="2" cellpadding="0">
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_menu" value="admin/menu" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/menu', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_menu"><?php 
        echo $_LANG['AD_MENU_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_modules" value="admin/modules" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/modules', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_modules"><?php 
        echo $_LANG['AD_MODULES_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_content" value="admin/content" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/content', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_content"><?php 
        echo $_LANG['AD_CONTENTS_CONTROL'];
        ?>
</label></td>
						</tr>
                        <tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_plugins" value="admin/plugins" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/filters', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_plugins"><?php 
        echo $_LANG['AD_PLUGINS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_filters" value="admin/filters" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/filters', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_filters"><?php 
        echo $_LANG['AD_FILTERS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_components" value="admin/components" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/components', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_components"><?php 
        echo $_LANG['AD_COMPONENTS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_users" value="admin/users" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/users', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_users"><?php 
        echo $_LANG['AD_USERS_CONTROL'];
        ?>
</label></td>
						</tr>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_config" value="admin/config" <?php 
        if (isset($mod['access'])) {
            if (in_array('admin/config', $mod['access'])) {
                echo 'checked="checked"';
            }
        }
        ?>
></td>
							<td><label for="admin_config"><?php 
        echo $_LANG['AD_SETTINGS_CONTROL'];
        ?>
</label></td>
						</tr>
					</table>
                </td>
			</tr>
			<tr>
			  <td valign="top">
			  	<div><strong><?php 
        echo $_LANG['AD_COMPONENTS_SETTINGS_FREE'];
        ?>
 </strong></div>
				<span class="hinttext"><?php 
        echo $_LANG['AD_COMPONENTS_SETTINGS_ON'];
        ?>
</span>
			  </td>
			  <td valign="top">
				  <table width="100%" border="0" cellspacing="2" cellpadding="0">

						<?php 
        $coms = cmsCore::getInstance()->getAllComponents();
        foreach ($coms as $com) {
            if (!file_exists(PATH . '/admin/components/' . $com['link'] . '/backend.php')) {
                continue;
            }
            ?>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="admin_com_<?php 
            echo $com['link'];
            ?>
" value="admin/com_<?php 
            echo $com['link'];
            ?>
" <?php 
            if (isset($mod['access'])) {
                if (in_array('admin/com_' . $com['link'], $mod['access'])) {
                    echo 'checked="checked"';
                }
            }
            ?>
 /></td>
							<td><label for="admin_com_<?php 
            echo $com['link'];
            ?>
"><?php 
            echo $com['title'];
            ?>
</label></td>
						</tr>
						<?php 
        }
        ?>

				  </table>
			  </td>
		  </tr>
		</table>

		<!--------------------------------------------------------------------------------------------------------------------------------------------->

		<table width="660" border="0" cellspacing="5" class="proptable" id="accesstable" style="<?php 
        if (@$mod['is_admin']) {
            echo 'display:none;';
        }
        ?>
">
			<tr>
				<td width="191" valign="top"><strong><?php 
        echo $_LANG['AD_GROUP_RULE'];
        ?>
 </strong></td>
				<td width="475" valign="top">
					<table width="100%" border="0" cellspacing="2" cellpadding="0">

					<?php 
        $sql = "SELECT * FROM cms_user_groups_access ORDER BY access_type";
        $res = $inDB->query($sql);
        while ($ga = $inDB->fetch_assoc($res)) {
            if ($mod['alias'] == 'guest' && $ga['hide_for_guest']) {
                continue;
            }
            ?>
						<tr>
							<td width="16"><input type="checkbox" name="access[]" id="<?php 
            echo str_replace('/', '_', $ga['access_type']);
            ?>
" value="<?php 
            echo $ga['access_type'];
            ?>
" <?php 
            if (isset($mod['access'])) {
                if (in_array($ga['access_type'], $mod['access'])) {
                    echo 'checked="checked"';
                }
            }
            ?>
></td>
							<td><label for="<?php 
            echo str_replace('/', '_', $ga['access_type']);
            ?>
"><?php 
            echo $ga['access_name'];
            ?>
</label></td>
						</tr>
                    <?php 
        }
        ?>
					</table>
				</td>
			</tr>
		</table>

		<!--------------------------------------------------------------------------------------------------------------------------------------------->

		<p>
			<input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_CREATE_GROUP'] . '"';
        } else {
            echo 'value="' . $_LANG['SAVE'] . '"';
        }
        ?>
 />
			<span style="margin-top:15px"><input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/></span>
			<input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
			<?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
		</p>
	</form>
	<?php 
    }
}
Ejemplo n.º 6
0
Archivo: tree.php Proyecto: r2git/icms1
function applet_tree()
{
    $inCore = cmsCore::getInstance();
    $inUser = cmsUser::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inPage = cmsPage::getInstance();
    cmsCore::loadLib('tags');
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) {
        cpAccessDenied();
    }
    $cfg = $inCore->loadComponentConfig('content');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/content.js"></script>';
    echo '<script>';
    echo cmsPage::getLangJS('AD_NO_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_DELETE_SELECTED_ARTICLES');
    echo cmsPage::getLangJS('AD_PIECES');
    echo cmsPage::getLangJS('AD_CATEGORY_DELETE');
    echo cmsPage::getLangJS('AD_AND_SUB_CATS');
    echo cmsPage::getLangJS('AD_DELETE_SUB_ARTICLES');
    echo '</script>';
    $do = cmsCore::request('do', 'str', 'tree');
    //============================================================================//
    //============================================================================//
    if ($do == 'tree') {
        $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['AD_SETUP_CATEGORY'], 'link' => '?view=components&do=config&link=content');
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=components&do=config&link=content');
        cpToolMenu($toolmenu);
        $only_hidden = cmsCore::request('only_hidden', 'int', 0);
        $category_id = cmsCore::request('cat_id', 'int', 0);
        $base_uri = 'index.php?view=tree';
        $title_part = cmsCore::request('title', 'str', '');
        $def_order = $category_id ? 'con.ordering' : 'pubdate';
        $orderby = cmsCore::request('orderby', 'str', $def_order);
        $orderto = cmsCore::request('orderto', 'str', 'asc');
        $page = cmsCore::request('page', 'int', 1);
        $perpage = 20;
        $hide_cats = cmsCore::request('hide_cats', 'int', 0);
        $cats = $model->getCatsTree();
        if ($category_id) {
            $model->whereCatIs($category_id);
        }
        if ($title_part) {
            $inDB->where('LOWER(con.title) LIKE \'%' . mb_strtolower($title_part) . '%\'');
        }
        if ($only_hidden) {
            $inDB->where('con.published = 0');
        }
        $inDB->orderBy($orderby, $orderto);
        $inDB->limitPage($page, $perpage);
        $total = $model->getArticlesCount(false);
        $items = $model->getArticlesList(false);
        $pages = ceil($total / $perpage);
        $tpl_file = 'admin/content.php';
        $tpl_dir = file_exists(TEMPLATE_DIR . $tpl_file) ? TEMPLATE_DIR : DEFAULT_TEMPLATE_DIR;
        include $tpl_dir . $tpl_file;
    }
}
Ejemplo n.º 7
0
function applet_tickets()
{
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/tickets', $adminAccess)) {
        cpAccessDenied();
    }
    global $_LANG;
    cmsUser::sessionDel('ticket_cat');
    $do = cmsCore::request('do', 'str', 'list');
    $super_user = cmsCore::c('user')->id == 1;
    $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_TICKET_CREATE'], 'link' => '?view=tickets&do=add'), array('icon' => 'liststuff.gif', 'title' => $_LANG['AD_TICKET_LIST'], 'link' => '?view=tickets&do=list'));
    cpToolMenu($toolmenu, 'list', 'do');
    cmsCore::c('page')->setTitle($_LANG['AD_TICKETS']);
    cpAddPathway($_LANG['AD_TICKETS'], 'index.php?view=tickets');
    if ($do == 'list') {
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_TICKET_STATUS'], 'field' => 'status', 'width' => '100', 'filter' => 1, 'prc' => 'cpTicketStatus', 'filterlist' => cpGetTicketStatusList()), array('title' => $_LANG['AD_TICKET_DATE'], 'field' => 'pubdate', 'width' => '80'), array('title' => $_LANG['AD_TICKET_TITLE'], 'field' => 'title', 'width' => '', 'filter' => 32, 'link' => 'index.php?view=tickets&do=view&id=%id%'), array('title' => $_LANG['AD_TICKET_LAST_MSG_DATE'], 'field' => 'last_msg_date', 'width' => '80'), array('title' => $_LANG['AD_TICKET_CAT'], 'field' => 'cat_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpTicketCategory', 'filter' => 1, 'filterlist' => cpGetTicketCats()), array('title' => $_LANG['AD_TICKET_PRIORITY'], 'field' => 'priority', 'width' => '100', 'filter' => 1, 'prc' => 'cpTicketPriority', 'filterlist' => cpGetTicketPriorityList()));
        if ($super_user) {
            $fields[] = array('title' => $_LANG['AD_TICKET_USER'], 'field' => 'user_id', 'width' => '110', 'prc' => 'cpTicketAuthor');
        }
        $actions = array(array('title' => $_LANG['AD_TICKET_CLOSE'], 'icon' => 'off.gif', 'link' => '?view=tickets&do=close_ticket&id=%id%', 'condition' => 'cpCheckTicketClose'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=tickets&do=delete&id=%id%', 'confirm' => $_LANG['AD_TICKET_DELETE']));
        cpListTable('cms_ticket', $fields, $actions, $super_user ? '' : 'user_id=' . cmsCore::c('user')->id, 'last_msg_date DESC', 30);
    }
    if ($do == 'delete') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (!empty($item)) {
            $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id=' . $item['cat_id'], 'server');
            if (empty($server)) {
                $server = 'http://ds-soft.ru/tickets.api.php';
            }
            //Удаляем сам тиккет
            cmsCore::c('db')->delete('cms_ticket', 'id=' . $item['id']);
            //Удаляем все сообщения тиккета
            cmsCore::c('db')->delete('cms_ticket_msg', 'ticket_id=' . $item['id']);
            //Удаляем все прикрепленные изображения тиккета
            cmsCore::deleteUploadImages($item['id'], 'ticket');
            if ($item['status'] != '3') {
                //Отправляем сообщение на сервер техподдержки что тикет удален
                cmsCore::c('curl')->ajax()->request('post', $server . '?do=ticket_deleted', array('ticket_id' => $item['id'], 'ticket_secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host));
            }
            cmsCore::addSessionMessage($_LANG['AD_TICKET_DELETE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=tickets');
    }
    if ($do == 'close_ticket') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (!empty($item)) {
            cmsCore::c('db')->setFlag('cms_ticket', $item['id'], 'status', '3');
            $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id=' . $item['cat_id'], 'server');
            if (empty($server)) {
                $server = 'http://ds-soft.ru/tickets.api.php';
            }
            //Отправляем сообщение на сервер техподдержки что тикет закрыт
            cmsCore::c('curl')->ajax()->request('post', $server . '?do=ticket_closed', array('ticket_id' => $item['id'], 'ticket_secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host));
            cmsCore::addSessionMessage($_LANG['AD_TICKET_CLOSE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=tickets');
    }
    if ($do == 'add') {
        cpAddPathway($_LANG['AD_TICKET_CREATE'], 'index.php?view=tickets&do=add');
        cmsCore::c('page')->initTemplate('applets', 'tickets_add')->assign('cats', cpGetTicketCats())->display();
    }
    if ($do == 'submit') {
        $cats = cpGetTicketCats();
        $item = array('cat_id' => cmsCore::request('cat_id', 'int', 0), 'priority' => cmsCore::request('priority', array(0, 1, 2, 3), 0), 'title' => cmsCore::request('title', 'str', ''), 'msg' => cmsCore::request('msg', 'str', ''));
        if (!isset($cats[$item['cat_id']])) {
            $item['cat_id'] = 0;
        }
        if (!empty($item['title']) && !empty($item['msg'])) {
            $item['msg'] = cmsCore::c('db')->escape_string($item['msg']);
            $item['msg_count'] = 1;
            $item['pubdate'] = date('Y-m-d H:i:s');
            $item['last_msg_date'] = $item['pubdate'];
            $item['user_id'] = cmsCore::c('user')->id;
            $item['id'] = cmsCore::c('db')->insert('cms_ticket', $item);
            cmsCore::addSessionMessage($_LANG['AD_TICKET_CREATED'], 'success');
            $do = 'send';
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR_2'], 'error');
            cmsCore::redirect('index.php?view=tickets&do=add');
        }
    }
    if ($do == 'send') {
        if (empty($item)) {
            $id = cmsCore::request('id', 'int', 0);
            $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        }
        if (!empty($item)) {
            $cat = cmsCore::c('db')->get_fields('cms_ticket_cat', 'id=' . $item['cat_id'], '*');
            $server = !empty($cat['server']) ? $cat['server'] : 'http://ds-soft.ru/tickets.api.php';
            $ticket = array('ticket_id' => $item['id'], 'cat_id' => $item['cat_id'], 'priority' => $item['priority'], 'title' => $item['title'], 'msg' => $item['msg'], 'host' => cmsCore::c('config')->host, 'module' => $cat['module']);
            if ($ticket['cat_id'] > 0 && !empty($cat['module'])) {
                $ticket['module'] = $cat['module'];
            }
            //Отправляем тикет на сервер техподдержки
            $result = cmsCore::c('curl')->ajax()->request('post', $server . '?do=add_ticket', $ticket)->json();
            if (!empty($result['error'])) {
                cmsCore::clearSessionMessages();
                cmsCore::addSessionMessage($result['error'], 'error');
                cmsCore::c('db')->delete('cms_ticket', 'id=' . $item['id']);
            } else {
                if (isset($result['secret_key'])) {
                    cmsCore::c('db')->update('cms_ticket', array('status' => 1, 'secret_key' => $result['secret_key']), $item['id']);
                    cmsCore::addSessionMessage($_LANG['AD_TICKET_SENDED'], 'success');
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_TICKET_UNKNOWN_ERROR'], 'error');
                    cmsCore::c('db')->delete('cms_ticket', 'id=' . $item['id']);
                }
            }
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=tickets');
    }
    if ($do == 'view') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (empty($item) || $item['user_id'] != cmsCore::c('user')->id && !$super_user) {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
            cmsCore::redirect('index.php?view=tickets');
        }
        cpAddPathway($item['title'], 'index.php?view=tickets&do=view&id=' . $item['id']);
        if ($item['msg_count'] > 1) {
            $item['msgs'] = array();
            $results = cmsCore::c('db')->query("SELECT * FROM cms_ticket_msg WHERE ticket_id=" . $item['id'] . " ORDER BY pubdate ASC");
            if (cmsCore::c('db')->num_rows($results)) {
                while ($msg = cmsCore::c('db')->fetch_assoc($results)) {
                    $msg['pubdate'] = cmsCore::dateFormat($msg['pubdate']);
                    $item['msgs'][] = $msg;
                }
            }
        }
        if ($item['status'] != 3) {
            switch ($item['priority']) {
                case 0:
                    $class = 'info';
                    break;
                case 1:
                    $class = 'success';
                    break;
                case 2:
                    $class = 'primary';
                    break;
                case 3:
                    $class = 'danger';
                    break;
            }
        } else {
            $class = 'default';
        }
        cmsCore::c('page')->initTemplate('applets', 'tickets_view')->assign('item', $item)->display();
    }
    if ($do == 'submit_msg') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id=' . $id, '*');
        if (empty($item) || $item['user_id'] != cmsCore::c('user')->id && !$super_user) {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
            cmsCore::redirect('index.php?view=tickets');
        }
        $msg = cmsCore::request('msg', 'str', '');
        $date = date('Y-m-d H:i:s');
        cmsCore::c('db')->insert('cms_ticket_msg', array('msg' => cmsCore::c('db')->escape_string($msg), 'ticket_id' => $item['id'], 'pubdate' => $date));
        cmsCore::c('db')->query("UPDATE `cms_tickets` SET `last_msg_date` = '" . $date . "', `msg_count` = `msg_count`+1 WHERE `id` = '" . $item['id'] . "'");
        $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id=' . $item['cat_id'], 'server');
        if (empty($server)) {
            $server = 'http://ds-soft.ru/tickets.api.php';
        }
        //Отправляем тикет на сервер техподдержки
        $result = cmsCore::c('curl')->ajax()->request('post', $server . '?do=add_ticket_msg', array('msg' => $msg, 'ticket_id' => $item['id'], 'secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host))->json();
        if (!empty($result['error'])) {
            cmsCore::addSessionMessage($result['error'], 'error');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_MSG_SENDED'], 'success');
        }
        cmsCore::redirect('index.php?view=tickets&do=view&id=' . $item['id']);
    }
}
Ejemplo n.º 8
0
function applet_userbanlist()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_BANLIST']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_BANLIST'], 'index.php?view=userbanlist');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $to = cmsCore::request('to', 'int', 0);
    // для редиректа обратно в профиль на сайт
    if ($to) {
        cmsUser::sessionPut('back_url', cmsCore::getBackURL());
    }
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'useradd.gif', 'title' => $_LANG['AD_TO_BANLIST_ADD'], 'link' => '?view=userbanlist&do=add'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=edit&multiple=1');"), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=delete&multiple=1');"));
        cpToolMenu($toolmenu);
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_IS_ACTIVE'], 'field' => 'status', 'width' => '65', 'prc' => 'cpYesNo'), array('title' => $_LANG['AD_BANLIST_USER'], 'field' => 'user_id', 'width' => '120', 'filter' => '12', 'prc' => 'cpUserNick'), array('title' => $_LANG['AD_BANLIST_IP'], 'field' => 'ip', 'width' => '100', 'link' => '?view=userbanlist&do=edit&id=%id%', 'filter' => '12'), array('title' => $_LANG['DATE'], 'field' => 'bandate', 'width' => '', 'fdate' => '%d/%m/%Y %H:%i:%s', 'filter' => '12'), array('title' => $_LANG['AD_BANLIST_TIME'], 'field' => 'int_num', 'width' => '55'), array('title' => '', 'field' => 'int_period', 'width' => '70'), array('title' => $_LANG['AD_AUTOREMOVE'], 'field' => 'autodelete', 'width' => '100', 'prc' => 'cpYesNo'));
        $actions = array(array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=userbanlist&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_RULE'], 'link' => '?view=userbanlist&do=delete&id=%id%'));
        cpListTable('cms_banlist', $fields, $actions, '1=1', 'ip DESC');
    }
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                dbDelete('cms_banlist', $id);
            }
        } else {
            dbDeleteList('cms_banlist', cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::redirect('?view=userbanlist');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('user_id' => array('user_id', 'int', 0), 'ip' => array('ip', 'str', ''), 'cause' => array('cause', 'str', ''), 'autodelete' => array('autodelete', 'int', 0), 'int_num' => array('int_num', 'int', 0), 'int_period' => array('int_period', 'str', '', create_function('$p', 'if(!in_array($p, array("MONTH","DAY","HOUR","MINUTE"))){ $p = "MINUTE"; } return $p;')));
        $items = cmsCore::getArrayFromRequest($types);
        $error = false;
        if (!$items['ip']) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_NEED_IP'], 'error');
        }
        if ($items['ip'] == $_SERVER['REMOTE_ADDR'] || $items['user_id'] == cmsCore::c('user')->id) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_YOUR_IP'], 'error');
        }
        if (cmsUser::userIsAdmin($items['user_id'])) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_ADMIN'], 'error');
        }
        if ($error) {
            cmsCore::redirectBack();
        }
        if ($do == 'update') {
            cmsCore::c('db')->update('cms_banlist', $items, $id);
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('?view=userbanlist');
            } else {
                cmsCore::redirect('?view=userbanlist&do=edit');
            }
        }
        cmsCore::c('db')->insert('cms_banlist', $items);
        $back_url = cmsUser::sessionGet('back_url');
        cmsUser::sessionDel('back_url');
        cmsCore::redirect($back_url ? $back_url : '?view=userbanlist');
    }
    if ($do == 'add' || $do == 'edit') {
        cmsCore::c('page')->addHeadJS('admin/js/banlist.js');
        $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'));
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_TO_BANLIST_ADD'] . '</h3>';
            cpAddPathway($_LANG['AD_TO_BANLIST_ADD']);
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = cmsCore::c('db')->get_fields('cms_banlist', "id = '" . $item_id . "'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_RULE'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_RULE']);
        }
        if ($do == 'add' && $to) {
            $mod['user_id'] = $to;
            $mod['ip'] = cmsCore::c('db')->get_field('cms_users', 'id=' . $to, 'last_ip');
        }
        cmsCore::c('page')->initTemplate('applets', 'userbanlist_add')->assign('do', $do)->assign('mod', $mod)->assign('users_opt', $inCore->getListItems('cms_users', cmsCore::getArrVal($mod, 'user_id', 0), 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname'))->display();
    }
}
Ejemplo n.º 9
0
function applet_cats() {
    $inCore = cmsCore::getInstance();

    global $_LANG;

    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES']);
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');

    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);

    define('IS_BILLING', $inCore->isComponentInstalled('billing'));
    if (IS_BILLING) { cmsCore::loadClass('billing'); }

    if ($do == 'delete') {
        $is_with_content = cmsCore::inRequest('content');
        cmsCore::m('content')->deleteCategory($id, $is_with_content);
        
        cmsCore::addSessionMessage(($is_with_content ? $_LANG['AD_CATEGORY_REMOVED'] : $_LANG['AD_CATEGORY_REMOVED_NOT_ARTICLE']), 'success');
        cmsCore::redirect('?view=tree');
    }

    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        if (cmsCore::inRequest('id')) {
            $category['id']          = cmsCore::request('id', 'int', 0);
            $category['title']       = cmsCore::request('title', 'str', $_LANG['AD_SECTION_UNTITLED']);
            $category['parent_id']   = cmsCore::request('parent_id', 'int');
            $category['description'] = cmsCore::request('description', 'html', '');
            $category['description'] = cmsCore::c('db')->escape_string($category['description']);
            $category['published']   = cmsCore::request('published', 'int', 0);
            $category['showdate']    = cmsCore::request('showdate', 'int', 0);
            $category['showcomm']    = cmsCore::request('showcomm', 'int', 0);
            $category['orderby']     = cmsCore::request('orderby', 'str', '');
            $category['orderto']     = cmsCore::request('orderto', 'str', '');
            $category['modgrp_id']   = cmsCore::request('modgrp_id', 'int', 0);
            $category['maxcols']     = cmsCore::request('maxcols', 'int', 0);
            $category['showtags']    = cmsCore::request('showtags', 'int', 0);
            $category['showrss']     = cmsCore::request('showrss', 'int', 0);
            $category['showdesc']    = cmsCore::request('showdesc', 'int', 0);
            $category['is_public']   = cmsCore::request('is_public', 'int', 0);
            $category['url']         = cmsCore::request('url', 'str', '');
            $category['pagetitle']   = cmsCore::request('pagetitle', 'str', '');
            $category['meta_desc']   = cmsCore::request('meta_desc', 'str', '');
            $category['meta_keys']   = cmsCore::request('meta_keys', 'str', '');
            
            if (!empty($category['url'])) {
                $category['url'] = cmsCore::strToURL($category['url'], cmsCore::m('content')->config['is_url_cyrillic']);
            }
            $category['tpl']         = cmsCore::request('tpl', 'str', 'com_content_view');
            
            $category['cost']        = cmsCore::request('cost', 'str', '');
            if (!is_numeric($category['cost'])) { $category['cost'] = ''; }

            $album = array();
            $album['id']      = cmsCore::request('album_id', 'int', 0);
            $album['header']  = cmsCore::request('album_header', 'str', '');
            $album['orderby'] = cmsCore::request('album_orderby', 'str', '');
            $album['orderto'] = cmsCore::request('album_orderto', 'str', '');
            $album['maxcols'] = cmsCore::request('album_maxcols', 'int', 0);
            $album['max']     = cmsCore::request('album_max', 'int', 0);

            if ($album['id']) {
                $category['photoalbum'] = serialize($album);
            } else {
                $category['photoalbum'] = '';
            }

            // получаем старую категорию
            $old = cmsCore::c('db')->get_fields('cms_category', "id='". $category['id'] ."'", '*');
            if (!$old) { cmsCore::error404(); } 
            
            // если сменили категорию
            if ($old['parent_id'] != $category['parent_id']) {
                // перемещаем ее в дереве
                $inCore->nestedSetsInit('cms_category')->MoveNode($category['id'], $category['parent_id']);
                // обновляем сеолинки категорий
                cmsCore::c('db')->updateNsCategorySeoLink('cms_category', $category['id'], cmsCore::m('content')->config['is_url_cyrillic']);
                // Обновляем ссылки меню на категории
                cmsCore::m('content')->updateCatMenu();
                // обновляем сеолинки всех вложенных статей
                cmsCore::m('content')->updateArticlesSeoLink($category['id']);
                cmsCore::addSessionMessage($_LANG['AD_CATEGORY_NEW_URL'], 'info');
            }

            cmsCore::c('db')->update('cms_category', $category, $category['id']);

            // если пришел запрос на обновление ссылок
            // и категория не менялась - если менялась, мы выше все обновили
            if (cmsCore::inRequest('update_seolink') && ($old['parent_id'] == $category['parent_id'])) {
                // обновляем сеолинки категорий
                cmsCore::c('db')->updateNsCategorySeoLink('cms_category', $category['id'], cmsCore::m('content')->config['is_url_cyrillic']);
                // Обновляем ссылки меню на категории
                cmsCore::m('content')->updateCatMenu();
                // обновляем сеолинки всех вложенных статей
                cmsCore::m('content')->updateArticlesSeoLink($category['id']);
                cmsCore::addSessionMessage($_LANG['AD_SECTION_AND_ARTICLES_NEW_URL'], 'info');
            }

            if (!cmsCore::request('is_access', 'int', 0)) {
                $showfor = cmsCore::request('showfor', 'array_int');
                cmsCore::setAccess($category['id'], $showfor, 'category');
            } else {
                cmsCore::clearAccess($category['id'], 'category');
            }

            cmsCore::addSessionMessage($_LANG['AD_CATEGORY_SAVED'], 'success');

            if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
                cmsCore::redirect('?view=tree&cat_id='. $category['id']);
            } else {
                cmsCore::redirect('?view=tree');
            }
        }
    }

    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $category['title']       = cmsCore::request('title', 'str', $_LANG['AD_CATEGORY_UNTITLED']);
        $category['url']         = cmsCore::request('url', 'str', '');
        if (!empty($category['url'])) {
            $category['url'] = cmsCore::strToURL($category['url']);
        }
        $category['parent_id']   = cmsCore::request('parent_id', 'int');
        $category['description'] = cmsCore::request('description', 'html', '');
        $category['description'] = cmsCore::c('db')->escape_string($category['description']);
        $category['published']   = cmsCore::request('published', 'int', 0);
        $category['showdate']    = cmsCore::request('showdate', 'int', 0);
        $category['showcomm']    = cmsCore::request('showcomm', 'int', 0);
        $category['orderby']     = cmsCore::request('orderby', 'str', '');
        $category['orderto']     = cmsCore::request('orderto', 'str', '');
        $category['modgrp_id']   = cmsCore::request('modgrp_id', 'int', 0);
        $category['maxcols']     = cmsCore::request('maxcols', 'int', 0);
        $category['showtags']    = cmsCore::request('showtags', 'int', 0);
        $category['showrss']     = cmsCore::request('showrss', 'int', 0);
        $category['showdesc']    = cmsCore::request('showdesc', 'int', 0);
        $category['is_public']   = cmsCore::request('is_public', 'int', 0);
        $category['tpl']         = cmsCore::request('tpl', 'str', 'com_content_view');
        $category['pagetitle']   = cmsCore::request('pagetitle', 'str', '');
        $category['meta_desc']   = cmsCore::request('meta_desc', 'str', '');
        $category['meta_keys']   = cmsCore::request('meta_keys', 'str', '');

        $category['cost']        = cmsCore::request('cost', 'str', 0);
        if (!is_numeric($category['cost'])) { $category['cost'] = ''; }

        $album = array();
        $album['id']      = cmsCore::request('album_id', 'int', 0);
        $album['header']  = cmsCore::request('album_header', 'str', '');
        $album['orderby'] = cmsCore::request('album_orderby', 'str', '');
        $album['orderto'] = cmsCore::request('album_orderto', 'str', '');
        $album['maxcols'] = cmsCore::request('album_maxcols', 'int', 0);
        $album['max']     = cmsCore::request('album_max', 'int', 0);

        if ($album['id']) {
            $category['photoalbum'] = serialize($album);
        } else {
            $category['photoalbum'] = '';
        }

        $ns = $inCore->nestedSetsInit('cms_category');
        $category['id'] = $ns->AddNode($category['parent_id']);

        $category['seolink'] = cmsCore::generateCatSeoLink($category, 'cms_category', cmsCore::m('content')->config['is_url_cyrillic']);

        if ($category['id']) {
            cmsCore::c('db')->update('cms_category', $category, $category['id']);

            if (!cmsCore::request('is_access', 'int', 0)) {
                $showfor = cmsCore::request('showfor', 'array_int');
                cmsCore::setAccess($category['id'], $showfor, 'category');
            } else {
                cmsCore::clearAccess($category['id'], 'category');
            }
        }

        $inmenu = cmsCore::request('createmenu', 'str', '');

        if ($inmenu) {
            createMenuItem($inmenu, $category['id'], $category['title']);
        }

        cmsCore::addSessionMessage($_LANG['AD_CATEGORY_ADD'], 'success');

        cmsCore::redirect('?view=tree');
    }

    if ($do == 'add' || $do == 'edit') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' ),
        );
        
        cpToolMenu($toolmenu);
        
        $menu_list = cpGetList('menu');
        
        if ($do == 'add') {
            echo '<h3>'. $_LANG['AD_CREATE_SECTION'] .'</h3>';
            
            cpAddPathway($_LANG['AD_CREATE_SECTION'], 'index.php?view=cats&do=add');
            
            $mod = array();
            $mod['tpl'] = 'com_content_view';
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int');
                } else {
                    echo '<p class="error">'. $_LANG['AD_NO_SELECT_OBJECTS'] .'</p>';
                    return;
                }
            }
            
            $ostatok = '';
            
            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) .')';
                }
            } else {
                $id = cmsCore::request('id', 'int', 0);
            }
            
            $mod = cmsCore::c('db')->get_fields('cms_category', 'id='.$id, '*');
            if (!empty($mod['photoalbum'])) {
                $mod['photoalbum'] = unserialize($mod['photoalbum']);
            }
            
            echo '<h3>'. $_LANG['AD_EDIT_SECTION'] . $ostatok .'</h3>';
            cpAddPathway($mod['title'], 'index.php?view=cats&do=edit&id='. $mod['id']);
        }
?>
<form id="addform" name="addform" method="post" action="index.php">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    <input type="hidden" name="view" value="cats" />

    <table class="table">
        <tr>
            <!-- главная ячейка -->
            <td valign="top">
                <div class="form-group">
                    <label><?php echo $_LANG['AD_TITLE_PARTITION'];?></label>
                    <input type="text" id="title" class="form-control" name="title" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'title', ''));?>" />
                </div>
                    
                <div class="form-group">
                    <label><?php echo $_LANG['AD_TEMPLATE_PARTITION'];?></label>
                    <input type="text" class="form-control" name="tpl" value="<?php echo cmsCore::getArrVal($mod, 'tpl', '');?>" />
                </div>
                    
                <div class="form-group">
                    <label><?php echo $_LANG['AD_PARENT_PARTITION'];?></label>
                    <div class="parent_notice" style="color:red;margin:4px 0px;display:none"><?php echo $_LANG['AD_ANOTHER_PARENT'];?></div>

                    <select name="parent_id" size="12" id="parent_id" class="form-control" onchange="if($('option:selected',this).data('nsleft')>='<?php echo cmsCore::getArrVal($mod, 'NSLeft', 0); ?>' && $('option:selected',this).data('nsright')<='<?php echo cmsCore::getArrVal($mod, 'NSRight', 0); ?>'){ $('.parent_notice').show();$('#add_mod').prop('disabled', true); } else { $('.parent_notice').hide();$('#add_mod').prop('disabled', false); }">
                        <?php $rootid = cmsCore::c('db')->getNsRootCatId('cms_category'); ?>
                        <option value="<?php echo $rootid; ?>" <?php if (!isset($mod['parent_id']) || cmsCore::getArrVal($mod, 'parent_id', '') == $rootid) { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_SECTION'];?></option>
                        <?php echo $inCore->getListItemsNS('cms_category', cmsCore::getArrVal($mod, 'parent_id', $rootid)); ?>
                    </select>
                </div>
                    
                <div class="form-group">
                    <label><?php echo $_LANG['AD_SECTION_DESCRIPT'];?></label>
                    <?php $inCore->insertEditor('description', cmsCore::getArrVal($mod, 'description', ''), '250', '100%'); ?>
                </div>
            </td>
                
            <!-- боковая -->
            <td valign="top" style="width:500px;">
                <div class="uitabs">
                    <ul id="tabs">
                        <li><a href="#upr_publish"><span><?php echo $_LANG['AD_TAB_PUBLISH']; ?></span></a></li>
                        <li><a href="#upr_seo"><span>SEO</span></a></li>
                        <li><a href="#upr_editors"><span><?php echo $_LANG['AD_EDITORS']; ?></span></a></li>
                        <li><a href="#upr_foto"><span><?php echo $_LANG['AD_FOTO']; ?></span></a></li>
                        <li><a href="#upr_access"><span><?php echo $_LANG['AD_TAB_ACCESS']; ?></span></a></li>
                    </ul>
                        
                    <div id="upr_publish">
                        <div class="form-group">
                            <label>
                                <input type="checkbox" name="published" id="published" value="1" <?php if (cmsCore::getArrVal($mod, 'published', 0) || $do=='add') { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_PUBLIC_SECTION'];?>
                            </label>
                        </div>
                            
                        <div class="form-group url_cat" style=" <?php if ($do == 'edit'){  ?>display:none;<?php } ?>">
                            <label><?php echo $_LANG['AD_SECTION_URL'];?></label>
                            <input type="text" class="form-control" name="url" value="<?php echo cmsCore::getArrVal($mod, 'url', ''); ?>" />
                            <div class="help-block"><?php echo $_LANG['AD_FROM_TITLE'];?></div>
                        </div>
                            
                        <?php if ($do == 'edit') {  ?>
                        <div class="form-group">
                            <label>
                                <input type="checkbox" name="update_seolink" value="1" onclick="$('.url_cat').slideToggle('fast');" />
                                    <?php echo $_LANG['AD_NEW_LINK'];?>
                            </label>
                            <div class="help-block url_cat" style="display:none;"><b style="color:#F00;"><?php echo $_LANG['ATTENTION'];?>:</b> <?php echo $_LANG['AD_NO_LINKS'];?></div>
                        </div>
                        <?php } ?>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_SORT_ARTICLES'];?></label>
                            <select id="orderby" class="form-control" name="orderby">
                                <?php $mod['orderby'] = cmsCore::getArrVal($mod, 'orderby', ''); ?>
                                <option value="pubdate" <?php if ($mod['orderby'] == 'pubdate') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_CALENDAR'];?></option>
                                <option value="title" <?php if ($mod['orderby'] == 'title') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_TITLE'];?></option>
                                <option value="ordering" <?php if ($mod['orderby'] == 'ordering') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_ORDER'];?></option>
                                <option value="hits" <?php if ($mod['orderby'] == 'hits') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_VIEWS'];?></option>
                            </select>
                            <select id="orderto" class="form-control" name="orderto">
                                <?php $mod['orderto'] = cmsCore::getArrVal($mod, 'orderto', ''); ?>
                                <option value="ASC" <?php if ($mod['orderto'] == 'ASC') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_INCREMENT'];?></option>
                                <option value="DESC" <?php if ($mod['orderto'] == 'DESC') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_DECREMENT'];?></option>
                            </select>
                        </div>

                        <table width="100%">
                            <tr>
                                <td>
                                    <strong><?php echo $_LANG['AD_HOW_MANY_COLUMNS'];?></strong>
                                </td>
                                <td>
                                    <input class="form-control uispin" name="maxcols" type="text" style="width:50px" value="<?php echo cmsCore::getArrVal($mod, 'maxcols', 1); ?>" />
                                </td>
                            </tr>
                        </table>
                            
                        <div class="form-group">
                            <h4><?php echo $_LANG['AD_HOW_PUBLISH_SET'];?></h4>
                            <table class="table">
                                <tr>
                                    <td>
                                        <?php echo $_LANG['AD_PREVIEW'];?>
                                    </td>
                                    <td>
                                        <div class="btn-group" data-toggle="buttons">
                                            <?php
                                                $act1=$act2=$chk1=$chk2='';
                                                if (cmsCore::getArrVal($mod, 'showdesc') || $do == 'add') {
                                                    $act1 = 'active';
                                                    $chk1 = 'checked="checked"';
                                                } else {
                                                    $act2 = 'active';
                                                    $chk2 = 'checked="checked"';
                                                }
                                            ?>
                                            <label class="btn btn-default <?php echo $act1; ?>">
                                                <input type="radio" name="showdesc" <?php echo $chk1; ?> value="1" /> <?php echo $_LANG['YES'];?>
                                            </label>
                                            <label class="btn btn-default <?php echo $act2; ?>">
                                                <input type="radio" name="showdesc" <?php echo $chk2; ?> value="0" /> <?php echo $_LANG['NO'];?>
                                            </label>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <?php echo $_LANG['AD_CALENDAR_VIEW'];?>
                                    </td>
                                    <td>
                                        <div class="btn-group" data-toggle="buttons">
                                            <?php
                                                $act1=$act2=$chk1=$chk2='';
                                                if (cmsCore::getArrVal($mod, 'showdate') || $do == 'add') {
                                                    $act1 = 'active';
                                                    $chk1 = 'checked="checked"';
                                                } else {
                                                    $act2 = 'active';
                                                    $chk2 = 'checked="checked"';
                                                }
                                            ?>
                                            <label class="btn btn-default <?php echo $act1; ?>">
                                                <input type="radio" name="showdate" <?php echo $chk1; ?> value="1" /> <?php echo $_LANG['YES'];?>
                                            </label>
                                            <label class="btn btn-default <?php echo $act2; ?>">
                                                <input type="radio" name="showdate" <?php echo $chk2; ?> value="0" /> <?php echo $_LANG['NO'];?>
                                            </label>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <?php echo $_LANG['AD_HOW_MANY_COMENTS'];?>
                                    </td>
                                    <td>
                                        <div class="btn-group" data-toggle="buttons">
                                            <?php
                                                $act1=$act2=$chk1=$chk2='';
                                                if (cmsCore::getArrVal($mod, 'showcomm') || $do == 'add') {
                                                    $act1 = 'active';
                                                    $chk1 = 'checked="checked"';
                                                } else {
                                                    $act2 = 'active';
                                                    $chk2 = 'checked="checked"';
                                                }
                                            ?>
                                            <label class="btn btn-default <?php echo $act1; ?>">
                                                <input type="radio" name="showcomm" <?php echo $chk1; ?> value="1" /> <?php echo $_LANG['YES'];?>
                                            </label>
                                            <label class="btn btn-default <?php echo $act2; ?>">
                                                <input type="radio" name="showcomm" <?php echo $chk2; ?> value="0" /> <?php echo $_LANG['NO'];?>
                                            </label>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <?php echo $_LANG['AD_HOW_MANY_TAGS'];?>
                                    </td>
                                    <td>
                                        <div class="btn-group" data-toggle="buttons">
                                            <?php
                                                $act1=$act2=$chk1=$chk2='';
                                                if (cmsCore::getArrVal($mod, 'showtags') || $do == 'add') {
                                                    $act1 = 'active';
                                                    $chk1 = 'checked="checked"';
                                                } else {
                                                    $act2 = 'active';
                                                    $chk2 = 'checked="checked"';
                                                }
                                            ?>
                                            <label class="btn btn-default <?php echo $act1; ?>">
                                                <input type="radio" name="showtags" <?php echo $chk1; ?> value="1" /> <?php echo $_LANG['YES'];?>
                                            </label>
                                            <label class="btn btn-default <?php echo $act2; ?>">
                                                <input type="radio" name="showtags" <?php echo $chk2; ?> value="0" /> <?php echo $_LANG['NO'];?>
                                            </label>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <?php echo $_LANG['AD_RSS_VIEW'];?>
                                    </td>
                                    <td>
                                        <div class="btn-group" data-toggle="buttons">
                                            <?php
                                                $act1=$act2=$chk1=$chk2='';
                                                if (cmsCore::getArrVal($mod, 'showrss') || $do == 'add') {
                                                    $act1 = 'active';
                                                    $chk1 = 'checked="checked"';
                                                } else {
                                                    $act2 = 'active';
                                                    $chk2 = 'checked="checked"';
                                                }
                                            ?>
                                            <label class="btn btn-default <?php echo $act1; ?>">
                                                <input type="radio" name="showrss" <?php echo $chk1; ?> value="1" /> <?php echo $_LANG['YES'];?>
                                            </label>
                                            <label class="btn btn-default <?php echo $act2; ?>">
                                                <input type="radio" name="showrss" <?php echo $chk2; ?> value="0" /> <?php echo $_LANG['NO'];?>
                                            </label>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                            
                        <?php if ($do == 'add'){ ?>
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_CREATE_LINK'];?></label>
                            <select class="form-control" style="width:99%" name="createmenu">
                                <option value="0" selected="selected"><?php echo $_LANG['AD_DONT_CREATE'];?></option>
                                <?php foreach ($menu_list as $menu) { ?>
                                <option value="<?php echo $menu['id']; ?>">
                                    <?php echo $menu['title']; ?>
                                </option>
                                <?php } ?>
                            </select>
                        </div>
                        <?php } ?>
                    </div>
                        
                    <div id="upr_seo">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_PAGE_TITLE']; ?></label>
                            <input type="text" id="pagetitle" class="form-control" name="pagetitle" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'pagetitle', '')); ?>" />
                            <div class="help-block"><?php echo $_LANG['AD_IF_UNKNOWN_PAGETITLE']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['KEYWORDS']; ?></label>
                            <textarea class="form-control" name="meta_keys" rows="4"><?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'meta_keys', ''));?></textarea>
                            <div class="help-block"><?php echo $_LANG['AD_FROM_COMMA']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['DESCRIPTION']; ?></label>
                            <textarea class="form-control" name="meta_desc" rows="6"><?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'meta_desc', ''));?></textarea>
                            <div class="help-block"><?php echo $_LANG['AD_LESS_THAN']; ?></div>
                        </div>
                    </div>
                        
                    <div id="upr_editors">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_USERS_ARTICLES'];?></label>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default <?php echo $act1; ?>">
                                    <input type="radio" name="is_public" <?php if (cmsCore::getArrVal($mod, 'is_public')) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES'];?>
                                </label>
                                <label class="btn btn-default <?php echo $act2; ?>">
                                    <input type="radio" name="is_public" <?php if (!cmsCore::getArrVal($mod, 'is_public')) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO'];?>
                                </label>
                            </div>
                            <div class="help-block"><?php echo $_LANG['AD_IF_SWITCH'];?></div>
                        </div>

                        <?php if (IS_BILLING){ ?>
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_COST_ARTICLES_ADD'];?></label>
                            <input type="text" class="form-control" style="width:50px" name="cost" value="<?php echo cmsCore::getArrVal($mod, 'cost', ''); ?>" /><?php echo $_LANG['BILLING_POINT10'];?>
                            <div class="help-block"><?php echo $_LANG['AD_COST_ARTICLES_BY_DEFAULT'];?></div>
                        </div>
                        <?php } ?>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_EDITORS_SECTION'];?></label>
                            <select class="form-control" name="modgrp_id">
                                <option value="0" <?php if (!isset($mod['modgrp_id']) || cmsCore::getArrVal($mod, 'modgrp_id', '') == 0) { echo 'selected'; }?>><?php echo $_LANG['AD_ONLY_ADMINS'];?></option>
                                <?php
                                    echo $inCore->getListItems('cms_user_groups', cmsCore::getArrVal($mod, 'modgrp_id', 0), 'id', 'ASC', 'is_admin = 0');
                                ?>
                            </select>
                            <div class="help-block"><?php echo $_LANG['AD_USERS_CAN_ADMIN'];?></div>
                        </div>
                    </div>
                        
                    <div id="upr_foto">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_PHOTOALBUM_CONNECT'];?></label>
                            <select id="album_id" class="form-control" name="album_id" onchange="choosePhotoAlbum()">
                                <option value="0" <?php if (empty($mod['photoalbum']['id'])) { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_DONT_CONNECT'];?></option>
                                <?php  //FIND ROOT
                                    echo $inCore->getListItemsNS('cms_photo_albums', cmsCore::getArrVal(cmsCore::getArrVal($mod, 'photoalbum'), 'id', 0));
                                ?>
                            </select>
                            <div class="help-block"><?php echo $_LANG['AD_PHOTO_BY_ARTICLES'];?></div>
                        </div>
                            
                        <div id="con_photoalbum" <?php if (empty($mod['photoalbum']['id'])) { echo 'style="display:none;"'; }?>>
                            <div class="form-group">
                                <label><?php echo $_LANG['AD_TITLE'];?></label>
                                <input type="text" id="album_header" class="form-control" name="album_header" value="<?php echo cmsCore::getArrVal(cmsCore::getArrVal($mod, 'photoalbum'), 'header', 0); ?>" />
                                <div class="help-block"><?php echo $_LANG['AD_OVER_PHOTOS'];?></div>
                            </div>
                                
                            <div class="form-group">
                                <label><?php echo $_LANG['AD_PHOTOS_SORT'];?></label>
                                <select class="form-control" name="album_orderby">
                                    <?php $mod['photoalbum']['orderby'] = cmsCore::getArrVal(cmsCore::getArrVal($mod, 'photoalbum'), 'orderby', 0); ?>
                                    <option value="title" <?php if ($mod['photoalbum']['orderby'] == 'title') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_ALPHABET'];?></option>
                                    <option value="pubdate" <?php if ($mod['photoalbum']['orderby'] == 'pubdate') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_CALENDAR'];?></option>
                                    <option value="rating" <?php if ($mod['photoalbum']['orderby'] == 'rating') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_RATING'];?></option>
                                    <option value="hits" <?php if ($mod['photoalbum']['orderby'] == 'hits') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_VIEWS'];?></option>
                                </select>
                                <select class="form-control" name="album_orderto">
                                    <?php $mod['photoalbum']['orderto'] = cmsCore::getArrVal(cmsCore::getArrVal($mod, 'photoalbum'), 'orderto', 0); ?>
                                    <option value="desc" <?php if ($mod['photoalbum']['orderto'] == 'desc') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_DECREMENT'];?></option>
                                    <option value="asc" <?php if ($mod['photoalbum']['orderto'] == 'asc') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_INCREMENT'];?></option>
                                </select>
                            </div>
                                
                            <div class="form-group">
                                <label><?php echo $_LANG['AD_HOW_MANY_COLUMNS'];?></label>
                                <input type="text" class="form-control" name="album_maxcols" value="<?php echo cmsCore::getArrVal(cmsCore::getArrVal($mod, 'photoalbum'), 'maxcols', 2); ?>"/>
                            </div>
                                
                            <div class="form-group">
                                <label><?php echo $_LANG['AD_HOW_MANY_PHOTO'];?></label>
                                <input type="text" class="form-control" name="album_max" value="<?php echo cmsCore::getArrVal(cmsCore::getArrVal($mod, 'photoalbum'), 'max', 8); ?>"/>
                            </div>
                        </div>
                    </div>
                        
                    <div id="upr_access">
                        <div class="form-group">
                            <?php
                                $sql    = "SELECT * FROM cms_user_groups";
                                $result = cmsCore::c('db')->query($sql) ;

                                $style  = 'disabled="disabled"';
                                $public = 'checked="checked"';

                                if ($do == 'edit'){
                                    $sql2 = "SELECT * FROM cms_content_access WHERE content_id = ". $mod['id'] ." AND content_type = 'category'";
                                    $result2 = cmsCore::c('db')->query($sql2);
                                    $ord = array();

                                    if (cmsCore::c('db')->num_rows($result2)){
                                        $public = '';
                                        $style = '';
                                        while ($r = cmsCore::c('db')->fetch_assoc($result2)){
                                            $ord[] = $r['group_id'];
                                        }
                                    }
                                }
                            ?>
                            <label>
                                <input type="checkbox" id="is_public" name="is_access" onclick="checkGroupList()" value="1" <?php echo $public; ?> />
                                <?php echo $_LANG['AD_SHARE'];?>
                            </label>
                            <div class="help-block"><?php echo $_LANG['AD_IF_NOTED'];?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_GROUPS_VIEW'];?></label>
                            <?php
                                echo '<select id="showin" class="form-control" name="showfor[]" size="6" multiple="multiple" '. $style .'>';
                                if (cmsCore::c('db')->num_rows($result)) {
                                    while ($item = cmsCore::c('db')->fetch_assoc($result)) {
                                        echo '<option value="'. $item['id'] .'"';
                                        if ($do == 'edit' && in_array($item['id'], $ord)) {
                                            echo 'selected="selected"';
                                        }
                                        echo '>';
                                        echo $item['title'] .'</option>';
                                    }
                                }
                                echo '</select>';
                            ?>
                            <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];?></div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <div>
        <input type="submit" class="btn btn-primary" name="add_mod" <?php if ($do == 'add') { echo 'value="'.$_LANG['AD_SAVE_SECTION'].'"'; } else { echo 'value="'.$_LANG['AD_SAVE_SECTION'].'"'; } ?> />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />
        <input type="hidden" name="do" <?php if ($do == 'add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> />
        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
<script type="text/javascript">
    function choosePhotoAlbum(){
        id = $('select[name=album_id]').val();
        if(id != 0){
            $('#con_photoalbum').fadeIn();
        }else{
            $('#con_photoalbum').hide();
        }
    }
</script>
<?php
    }
}
Ejemplo n.º 10
0
function applet_arhive()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES_ARCHIVE'];
    $cfg = $inCore->loadComponentConfig('content');
    $cfg_arhive = $inCore->loadComponentConfig('arhive');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    cpAddPathway($_LANG['AD_ARTICLE_SITE'], 'index.php?view=tree');
    cpAddPathway($_LANG['AD_ARTICLES_ARCHIVE'], 'index.php?view=arhive');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'saveconfig') {
        if (!cmsCore::validateForm()) {
            cmsCore::error404();
        }
        $cfg['source'] = cmsCore::request('source', 'str', '');
        $inCore->saveComponentConfig('arhive', $cfg);
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('?view=arhive&do=config');
    }
    if ($do == 'config') {
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'folders.gif';
        $toolmenu[0]['title'] = $_LANG['AD_LIST_OF_ARTICLES'];
        $toolmenu[0]['link'] = '?view=arhive';
        cpToolMenu($toolmenu);
        cpAddPathway($_LANG['AD_SETTINGS'], 'index.php?view=arhive&do=config');
        ?>
<form action="index.php?view=arhive&do=saveconfig" method="post" name="optform" target="_self" id="form1">
    <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
    <table width="609" border="0" cellpadding="10" cellspacing="0" class="proptable">
        <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_SOURCE_MATERIALS'];
        ?>
</strong></td>
            <td width="100" valign="top">
                <select name="source" id="source" style="width:285px">
                    <option value="content" <?php 
        if ($cfg_arhive['source'] == 'content') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_ARTICLE_SITE'];
        ?>
</option>
                    <option value="arhive" <?php 
        if ($cfg_arhive['source'] == 'arhive') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_ARTICLES_ARCHIVE'];
        ?>
</option>
                    <option value="both" <?php 
        if ($cfg_arhive['source'] == 'both') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_CATALOG_AND_ARCHIVE'];
        ?>
</option>
                </select>
            </td>
        </tr>
    </table>
    <p>
        <input name="opt" type="hidden" value="saveconfig" />
        <input name="save" type="submit" id="save" value="<?php 
        echo $_LANG['SAVE'];
        ?>
" />
        <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=arhive';" />
    </p>
</form>
<?php 
    }
    if ($do == 'list') {
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'config.gif';
        $toolmenu[0]['title'] = $_LANG['AD_SETTINGS'];
        $toolmenu[0]['link'] = '?view=arhive&do=config';
        $toolmenu[1]['icon'] = 'delete.gif';
        $toolmenu[1]['title'] = $_LANG['AD_DELETE_SELECTED'];
        $toolmenu[1]['link'] = "javascript:checkSel('?view=arhive&do=delete&multiple=1');";
        cpToolMenu($toolmenu);
        //TABLE COLUMNS
        $fields = array();
        $fields[0]['title'] = 'id';
        $fields[0]['field'] = 'id';
        $fields[0]['width'] = '30';
        $fields[1]['title'] = $_LANG['AD_CREATE'];
        $fields[1]['field'] = 'pubdate';
        $fields[1]['width'] = '80';
        $fields[1]['filter'] = 15;
        $fields[1]['fdate'] = '%d/%m/%Y';
        $fields[2]['title'] = $_LANG['TITLE'];
        $fields[2]['field'] = 'title';
        $fields[2]['width'] = '';
        $fields[2]['link'] = '?view=content&do=edit&id=%id%';
        $fields[2]['filter'] = 15;
        $fields[3]['title'] = $_LANG['AD_PARTITION'];
        $fields[3]['field'] = 'category_id';
        $fields[3]['width'] = '100';
        $fields[3]['filter'] = 1;
        $fields[3]['prc'] = 'cpCatById';
        $fields[3]['filterlist'] = cpGetList('cms_category');
        //ACTIONS
        $actions = array();
        $actions[0]['title'] = $_LANG['AD_TO_ARTICLES_CATALOG'];
        $actions[0]['icon'] = 'arhive_off.gif';
        $actions[0]['link'] = '?view=arhive&do=arhive_off&id=%id%';
        $actions[2]['title'] = $_LANG['DELETE'];
        $actions[2]['icon'] = 'delete.gif';
        $actions[2]['confirm'] = $_LANG['AD_DELETE_MATERIALS'];
        $actions[2]['link'] = '?view=content&do=delete&id=%id%';
        //Print table
        cpListTable('cms_content', $fields, $actions, 'is_arhive=1');
    }
    if ($do == 'arhive_off') {
        if (isset($_REQUEST['id'])) {
            $sql = "UPDATE cms_content SET is_arhive = 0 WHERE id = '{$id}'";
            $inDB->query($sql);
            cmsCore::redirect('?view=arhive');
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $model->deleteArticle($id, $cfg['af_delete']);
            }
        } else {
            $model->deleteArticles($_REQUEST['item'], $cfg['af_delete']);
        }
        cmsCore::redirect('?view=arhive');
    }
}
Ejemplo n.º 11
0
function applet_menu() {
    $inCore = cmsCore::getInstance();

    global $_LANG;
    global $adminAccess;

    if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_MENU']);
    cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add' ),
            array( 'icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu' ),
            array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link'=> "javascript:checkSel('?view=menu&do=edit&multiple=1');" ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');" ),
            array( 'icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');" ),
            array( 'icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');" ),
            array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu' )
        );

        cpToolMenu($toolmenu);

        $fields = array(
            array( 'title' => 'Lt', 'field' => 'NSLeft', 'width' => '40' ),
            array(
                'title' => $_LANG['TITLE'],
                'field' => array('title', 'titles'), 'width'=>'',
                'link'  => '?view=menu&do=edit&id=%id%',
                'prc'   => function ($i) {
                    $i['titles'] = cmsCore::yamlToArray($i['titles']);
                    
                    // переопределяем название пункта меню в зависимости от языка
                    if (!empty($i['titles'][cmsConfig::getConfig('lang')])) {
                        $i['title'] = $i['titles'][cmsConfig::getConfig('lang')];
                    }
                    
                    return $i['title'];
                }
            ),
            array( 'title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80' ),
            array( 'title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100' ),
            array( 'title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById' ),
            array( 'title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu' ),
            array( 'title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '90', 'prc' => 'cpTemplateById' )
        );
        
        $actions = array(
            array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%' )
        );

        cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering');

    } else {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu' )
        );

        cpToolMenu($toolmenu);
    }

    if ($do == 'move_up') {
        cmsCore::c('db')->moveNsCategory('cms_menu', $id, 'up');
        cmsCore::redirectBack();
    }

    if ($do == 'move_down') {
        cmsCore::c('db')->moveNsCategory('cms_menu', $id, 'down');
        cmsCore::redirectBack();
    }

    if ($do == 'show') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) { cmsCore::c('db')->setFlag('cms_menu', $id, 'published', '1'); }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_menu', $_REQUEST['item'], 'published', '1');
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');
            cmsCore::redirectBack();
        }
    }

    if ($do == 'hide') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) { cmsCore::c('db')->setFlag('cms_menu', $id, 'published', '0'); }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_menu', cmsCore::request('item', 'array_int', array()), 'published', '0');
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');
            cmsCore::redirectBack();
        }
    }

    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) { cmsCore::c('db')->deleteNS('cms_menu', (int)$id); }
        } else {
            cmsCore::c('db')->deleteListNS('cms_menu', cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');
        cmsCore::redirectBack();
    }

    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $id = cmsCore::request('id', 'int', 0);
        if(!$id){ cmsCore::redirectBack(); }

        $title     = cmsCore::request('title', 'str', '');
        $titles    = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $menu      = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype  = cmsCore::request('mode', 'str', '');
        $linkid    = cmsCore::request($linktype, 'str', '');
        $link      = $inCore->getMenuLink($linktype, $linkid);
        $target    = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template  = cmsCore::request('template', 'str', '');
        $iconurl   = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $oldparent = cmsCore::request('oldparent', 'int', 0);
        $is_lax    = cmsCore::request('is_lax', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');

        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }

        $ns = $inCore->nestedSetsInit('cms_menu');

        if ($oldparent != $parent_id) {
            $ns->MoveNode($id, $parent_id);
        }

        $sql = "UPDATE cms_menu
                SET title='". $title ."',
                    titles='". $titles ."',
                    css_class='". $css_class ."',
                    menu='". $menu ."',
                    link='". $link ."',
                    linktype='". $linktype ."',
                    linkid='". $linkid ."',
                    target='". $target ."',
                    published='". $published ."',
                    template='". $template ."',
                    access_list='". $access_list ."',
                    is_lax='". $is_lax ."',
                    iconurl='". $iconurl ."'
                WHERE id = '". $id ."'
                LIMIT 1";
        cmsCore::c('db')->query($sql) ;

        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');

        if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) {
            cmsCore::redirect('?view=menu');
        } else {
            cmsCore::redirect('?view=menu&do=edit');
        }

    }

    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $title     = cmsCore::request('title', 'str', '');
        $titles    = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $menu      = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype  = cmsCore::request('mode', 'str', '');
        $linkid    = cmsCore::request($linktype, 'str', '');
        $link      = $inCore->getMenuLink($linktype, $linkid);
        $target    = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template  = cmsCore::request('template', 'str', '');
        $iconurl   = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');

        $is_public = cmsCore::request('is_public', 'int', '');
        $is_lax    = cmsCore::request('is_lax', 'int', 0);
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }

        $ns = $inCore->nestedSetsInit('cms_menu');
        $myid = $ns->AddNode($parent_id);

        $sql = "UPDATE cms_menu
                        SET menu='". $menu ."',
                                title='". $title ."',
                                titles='". $titles ."',
                                css_class='". $css_class ."',
                                link='". $link ."',
                                linktype='". $linktype ."',
                                linkid='". $linkid ."',
                                target='". $target ."',
                                published='". $published ."',
                                template='". $template ."',
                                access_list='". $access_list ."',
                                is_lax='". $is_lax ."',
                                iconurl='". $iconurl ."'
                        WHERE id = '". $myid ."'";

        cmsCore::c('db')->query($sql);

        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');
        cmsCore::redirect('?view=menu');
    }

    if ($do == 'submitmenu') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1";
        $result = cmsCore::c('db')->query($sql) ;
        $row = cmsCore::c('db')->fetch_assoc($result);
        $maxorder = $row['max_o'] + 1;

        $menu       = cmsCore::request('menu', 'str', '');
        $title      = cmsCore::request('title', 'str', '');
        $position   = cmsCore::request('position', 'str', '');
        $published  = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public  = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }

        $cfg['menu'] = $menu;
        $cfg_str = cmsCore::arrayToYaml($cfg);

        $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list)
                VALUES ('". $position ."', '". $_LANG['AD_MENU'] ."', '". $title ."', 1, 'mod_menu', ". $maxorder .", 1, ". $published .", 0, '". $cfg_str ."', '". $css_prefix ."', '". $access_list ."')";

        cmsCore::c('db')->query($sql) ;

        $newid = cmsCore::c('db')->get_last_id('cms_modules');

        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');

        cmsCore::redirect('?view=modules&do=edit&id='.$newid);

    }

    if ($do == 'addmenu' || $do == 'add' || $do == 'edit') {
        cmsCore::c('page')->addHeadJS('admin/js/menu.js');
        echo '<script>';
        echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU');
        echo '</script>';
    }

    if ($do == 'addmenu') {
        cmsCore::c('page')->setTitle($_LANG['AD_MENU_ADD']);
        cpAddPathway($_LANG['AD_MENU_ADD']);

        $menu_list = cpGetList('menu');

?>
<form id="addform" name="addform" action="index.php?view=menu&do=submitmenu" method="post">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
            
    <div class="panel panel-default" style="width:650px;">
        <div class="panel-body">
            <div class="form-group">
                <label><?php echo $_LANG['AD_MODULE_MENU_TITLE']; ?></label>
                <input type="text" id="title2" class="form-control" name="title" style="width:99%" value="" />
            </div>

            <div class="form-group">
                <label><?php echo $_LANG['AD_MENU_TO_VIEW']; ?></label>
                <select id="menu" class="form-control" name="menu" style="width:99%">
                    <?php foreach ($menu_list as $menu) { ?>
                        <option value="<?php echo $menu['id']; ?>">
                            <?php echo $menu['title']; ?>
                        </option>
                    <?php } ?>
                </select>
                <div class="help-block"><?php echo $_LANG['AD_TO_CREATE_NEW_POINT']; ?></div>
            </div>
                    
            <div class="form-group">
                <label><?php echo $_LANG['AD_POSITION_TO_VIEW']; ?></label>
                <?php
                    $pos = cpModulePositions(cmsConfig::getConfig('template'));
                ?>
                <select id="position" class="form-control" name="position" style="width:99%">
                    <?php
                        if ($pos){
                            foreach($pos as $key=>$position) {
                                if (cmsCore::getArrVal($mod, 'position') == $position){
                                    echo '<option value="'. $position .'" selected>'. $position .'</option>';
                                } else {
                                    echo '<option value="'. $position .'">'. $position .'</option>';
                                }
                            }
                        }
                    ?>
                </select>
                <input name="is_external" type="hidden" id="is_external" value="0" />
                <div class="help-block"><?php echo $_LANG['AD_POSITION_MUST_BE']; ?></div>
            </div>
                    
            <div class="form-group">
                <label><?php echo $_LANG['AD_MENU_PUBLIC']; ?></label>
                <label>
                    <input name="published" type="radio" value="1" checked="checked" <?php if (cmsCore::getArrVal($mod, 'published')) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['YES']; ?>
                </label>
                <label>
                    <input name="published" type="radio" value="0"  <?php if (!cmsCore::getArrVal($mod, 'published')) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['NO']; ?>
                </label>
            </div>
                    
            <div class="form-group">
                <label><?php echo $_LANG['AD_PREFIX_CSS']; ?></label>
                <input type="text" id="css_prefix" class="form-control" name="css_prefix" value="<?php echo cmsCore::getArrVal($mod, 'css_prefix'); ?>" style="width:99%" />
            </div>
                    
            <div class="form-group">
                <label><?php echo $_LANG['AD_TAB_ACCESS']; ?>:</label>
                <div class="help-block"><?php echo $_LANG['AD_GROUP_ACCESS'] ; ?></div>
                <?php
                    $groups = cmsUser::getGroups();
                    $style  = 'disabled="disabled"';
                    $public = 'checked="checked"';

                    if ($do == 'edit') {
                        if ($mod['access_list']) {
                            $public = '';
                            $style  = '';
                            $access_list = $inCore->yamlToArray($mod['access_list']);
                        }
                    }
                ?>
                <label><input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public?> /> <?php echo $_LANG['AD_SHARE']; ?></label>
                <div class="help-block"><?php echo $_LANG['AD_VIEW_IF_CHECK']; ?></div>
            </div>
                    
            <div class="form-group">
                <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label>
                <?php
                    echo '<select class="form-control" style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" '. $style .'>';
                    if ($groups) {
                        foreach ($groups as $group) {
                            echo '<option value="'. $group['id'] .'"';
                            if ($do == 'edit') {
                                if (in_array($group['id'], $access_list)) {
                                    echo 'selected="selected"';
                                }
                            }
                            echo '>';
                            echo $group['title'].'</option>';
                        }
                    }
                            
                    echo '</select>';
                ?>
                <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?></div>
            </div>
                    
            <div class="alert alert-info" role="alert"><?php echo $_LANG['AD_NEW_MENU_NEW_MODULE']; ?></div>
        </div>
    </div>

    <div style="margin-top:5px">
        <input class="btn btn-primary" name="save" type="submit" id="save" value="<?php echo $_LANG['AD_MENU_ADD']; ?>" />
        <input class="btn btn-default" name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.location.href='index.php?view=menu';" />
    </div>
</form>
<?php
    }

    if ($do == 'add' || $do == 'edit') {
        $menu_list = cpGetList('menu');
        
        $langs = cmsCore::getDirsList('/languages');
        
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MENU_POINT_ADD']);
            $mod['menu'] = array('mainmenu');
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('.$_LANG['AD_NEXT_IN'].sizeof($_SESSION['editlist']).')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_menu', "id = '$item_id'", '*');
            if (!$mod) { cmsCore::error404(); }

            $mod['menu']   = cmsCore::yamlToArray($mod['menu']);
            $mod['titles'] = cmsCore::yamlToArray($mod['titles']);

            cpAddPathway($_LANG['AD_MENU_POINT_EDIT'].$ostatok.' "'.$mod['title'].'"');

        }
?>
<form id="addform" name="addform" method="post" action="index.php">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    <input type="hidden" name="view" value="menu" />

    <table class="table">
        <tr>
            <td valign="top">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MENU_POINT_TITLE']; ?></label>
                            <input type="text" id="title" class="form-control" style="width:100%" name="title" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'title', ''));?>" />
                            <div class="help-block"><?php echo $_LANG['AD_VIEW_IN_SITE']; ?></div>
                        </div>
                        
                        <?php if (count($langs) > 1) { ?>
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_LANG_TITLES']; ?></label>
                            <?php foreach ($langs as $lang) { ?>
                                <div>
                                    <strong><?php echo $lang; ?>:</strong>
                                    <input name="titles[<?php echo $lang; ?>]" type="text" style="width:97%" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod['titles'], $lang, '')); ?>" placeholder="<?php echo $_LANG['AD_HINT_DEFAULT']; ?>" />
                                </div>
                            <?php } ?>
                            <div class="help-block"><?php echo $_LANG['AD_LANG_TITLES_HINT']; ?></div>
                        </div>
                        <?php } ?>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_PARENT_POINT']; ?></label>
                            <?php
                                $rootid = cmsCore::c('db')->get_field('cms_menu', 'parent_id=0', 'id');
                            ?>
                            <select id="parent_id" class="form-control" style="width:100%" name="parent_id" size="10">
                                <option value="<?php echo $rootid; ?>" <?php if (cmsCore::getArrVal($mod, 'parent_id', $rootid) == $rootid) { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_MENU_ROOT']; ?></option>
                                <?php
                                    echo $inCore->getListItemsNS('cms_menu', cmsCore::getArrVal($mod, 'parent_id', 0));
                                ?>
                            </select>
                            <input type="hidden" name="oldparent" value="<?php echo cmsCore::getArrVal($mod, 'parent_id', '');?>" />
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MENU_POINT_ACTION']; ?></label>
                            <select id="linktype" class="form-control" style="width:100%" name="mode" onchange="showMenuTarget()">
                                <?php $link_type = cmsCore::getArrVal($mod, 'linktype', 'link') ?>
                                <option value="link" <?php if ($link_type == 'link') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_LINK']; ?></option>
                                <option value="content" <?php if ($link_type == 'content') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_ARTICLE']; ?></option>
                                <?php if($inCore->isComponentInstalled('video')){ ?> 
                                    <option value="video_cat" <?php if ($link_type == 'video_cat') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_VIDEO_PARTITION']; ?></option> 
                                <?php } ?>
                                <option value="category" <?php if ($link_type == 'category') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_PARTITION']; ?></option>
                                <option value="component" <?php if ($link_type == 'component') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_COMPONENT']; ?></option>
                                <option value="blog" <?php if ($link_type == 'blog') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_BLOG']; ?></option>
                                <option value="uccat" <?php if ($link_type == 'uccat') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_CATEGORY']; ?></option>
                                <option value="photoalbum" <?php if ($link_type == 'photoalbum') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_ALBUM']; ?></option>
                            </select>
                        </div>
                            
                        <div id="t_link" class="form-group menu_target" style="display:<?php if ($link_type == 'link' || $link_type == 'ext') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_LINK']; ?></label>
                            <input type="text" id="link" class="form-control" style="width:100%" name="link" size="50" value="<?php if ($link_type == 'link' || $link_type == 'ext') { echo cmsCore::getArrVal($mod, 'link', ''); } ?>" />
                            <div class="help-block"><?php echo $_LANG['AD_LINK_HINT']; ?> <b>http://</b></div>
                        </div>
                            
                        <div id="t_content" class="form-group menu_target" style="display:<?php if ($link_type == 'content') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_ARTICLE'] ; ?></label>
                            <select id="content" class="form-control" style="width:100%" name="content">
                                <?php
                                    echo $inCore->getListItems('cms_content', (($link_type == 'content') ? $mod['linkid'] : 0));
                                ?>
                            </select>
                        </div>
                            
                        <?php if($inCore->isComponentInstalled('video')){ ?> 
                        <div id="t_video_cat" class="form-group menu_target" style="display:<?php if ($link_type == 'video_cat') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_PARTITION']; ?></label>
                            <select id="video_cat" class="form-control" style="width:100%" name="video_cat"> 
                                <?php
                                    echo $inCore->getListItemsNS('cms_video_category', (($link_type == 'video_cat') ? $mod['linkid'] : 0));
                                ?> 
                            </select>
                        </div>
                        <?php } ?>
                            
                        <div id="t_category" class="form-group menu_target" style="display:<?php if ($link_type == 'category') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_PARTITION']; ?></label>
                            <select id="category" class="form-control" style="width:100%" name="category"> 
                                <?php
                                    echo $inCore->getListItemsNS('cms_category', (($link_type == 'category') ? $mod['linkid'] : 0));
                                ?> 
                            </select>
                        </div>
                            
                        <div id="t_component" class="form-group menu_target" style="display:<?php if ($link_type == 'component') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_COMPONENT']; ?></label>
                            <select id="component" class="form-control" style="width:100%" name="component"> 
                                <?php
                                    echo $inCore->getListItems('cms_components', (($link_type == 'component') ? $mod['linkid'] : 0), 'title', 'asc', 'internal=0', 'link');
                                ?> 
                            </select>
                        </div>
                            
                        <div id="t_blog" class="form-group menu_target" style="display:<?php if ($link_type == 'blog') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_BLOG']; ?></label>
                            <select id="blog" class="form-control" style="width:100%" name="blog"> 
                                <?php
                                    echo $inCore->getListItems('cms_blogs', (($link_type == 'blog') ? $mod['linkid'] : 0), 'title', 'asc', "owner='user'");
                                ?> 
                            </select>
                        </div>
                            
                        <div id="t_uccat" class="form-group menu_target" style="display:<?php if ($link_type == 'uccat') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_CATEGORY']; ?></label>
                            <select id="blog" class="form-control" style="width:100%" name="blog"> 
                                <?php
                                    echo $inCore->getListItems('cms_uc_cats', (($link_type == 'uccat') ? $mod['linkid'] : 0));
                                ?> 
                            </select>
                        </div>
                            
                        <div id="t_photoalbum" class="form-group menu_target" style="display:<?php if ($link_type == 'photoalbum') { echo 'block'; } else { echo 'none'; } ?>">
                            <label><?php echo $_LANG['AD_CHECK_ALBUM']; ?></label>
                            <select id="blog" class="form-control" style="width:100%" name="blog"> 
                                <?php
                                    echo $inCore->getListItems('cms_photo_albums', (($link_type == 'photoalbum') ? $mod['linkid'] : 0), 'id', 'ASC', 'NSDiffer = ""');
                                ?> 
                            </select>
                        </div>
                    </div>
                </div>
            </td>

            <td width="400" valign="top">
                <div class="uitabs">
                    <ul id="tabs">
                        <li><a href="#upr_publish"><span><?php echo $_LANG['AD_TAB_PUBLISH']; ?></span></a></li>
                        <li><a href="#upr_access"><span><?php echo $_LANG['AD_TAB_ACCESS']; ?></span></a></li>
                        <li><a href="#upr_menu"><span><?php echo $_LANG['AD_MENU']; ?></span></a></li>
                    </ul>
                        
                    <div id="upr_publish">
                        <div class="form-group">
                            <label>
                                <input type="checkbox" name="published" value="1" <?php if (cmsCore::getArrVal($mod, 'published') || $do == 'add') { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_MENU_POINT_PUBLIC']; ?>
                            </label>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_OPEN_POINT']; ?></label>
                            <select id="target" class="form-control" style="width:100%" name="target">
                                <option value="_self" <?php if (@$mod['target']=='_self') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_SELF']; ?></option>
                                <option value="_parent"><?php echo $_LANG['AD_PARENT'];?></option>
                                <option value="_blank" <?php if (@$mod['target']=='_blank') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_BLANK']; ?></option>
                                <option value="_top" <?php if (@$mod['target']=='_top') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_TOP']; ?></option>
                            </select>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['TEMPLATE']; ?></label>
                            <select id="template" class="form-control" style="width:100%" name="template"  >
                                <option value="0" <?php if (!cmsCore::getArrVal($mod, 'template')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_DEFAULT'];?></option>
                                <?php
                                $templates = cmsCore::getDirsList('/templates');
                                foreach ($templates as $template) {
                                    if ($template == 'admin') { continue; }
                                    echo '<option value="'. $template .'" '.(cmsCore::getArrVal($mod, 'template') ? 'selected="selected"': '').'>'.$template.'</option>';
                                }
                                ?>
                            </select>
                            <div class="help-block"><?php echo $_LANG['AD_DESIGN_CHANGE'] ;?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_ICON_PICTURE']; ?></label>
                            <input type="text" id="iconurl" class="form-control" style="width:100%" name="iconurl" size="30" value="<?php echo cmsCore::getArrVal($mod, 'iconurl', ''); ?>" />
                                
                            <a id="iconlink" style="display:block;" href="javascript:showIcons()"><?php echo $_LANG['AD_CHECK_ICON'];?></a>
                            <div id="icondiv" style="display:none; padding:6px;border:solid 1px gray;background:#FFF">
                                <div><?php iconList(); ?></div>
                            </div>
                                
                            <div class="help-block"><?php echo $_LANG['AD_ICON_FILENAME'] ;?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_CSS_CLASS']; ?></label>
                            <input type="text" class="form-control" style="width:100%" name="css_class" size="30" value="<?php echo cmsCore::getArrVal($mod, 'css_class', ''); ?>" />
                        </div>
                    </div>
                        
                    <div id="upr_access">
                        <div class="form-group">
                            <?php
                                $groups = cmsUser::getGroups();
                                $style  = 'disabled="disabled"';
                                $public = 'checked="checked"';

                                if ($do == 'edit') {
                                    if ($mod['access_list']) {
                                        $public = '';
                                        $style  = '';
                                        $access_list = $inCore->yamlToArray($mod['access_list']);
                                    }
                                }
                            ?>
                                
                            <label>
                                <input type="checkbox" name="is_public" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> />
                                <?php echo $_LANG['AD_SHARE']; ?>
                            </label>
                            <div class="help-block"><?php echo $_LANG['AD_VIEW_IF_CHECK'];?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label>
                            <?php
                                echo '<select id="allow_group" class="form-control" style="width: 99%" name="allow_group[]"  size="6" multiple="multiple" '.$style.'>';
                                if ($groups) {
                                    foreach($groups as $group) {
                                        echo '<option value="'. $group['id'] .'"';
                                        if ($do == 'edit' && cmsCore::getArrVal($mod, 'access_list')) {
                                            if (in_array($group['id'], $access_list)){
                                                echo 'selected="selected"';
                                            }
                                        }
                                        echo '>';
                                        echo $group['title'] .'</option>';
                                    }
                                }

                                echo '</select>';
                            ?>
                            <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];?></div>
                        </div>
                            
                        <div class="form-group">
                            <label>
                                <input type="checkbox" id="is_lax" name="is_lax" value="1" <?php if(cmsCore::getArrVal($mod, 'is_lax')) {?>checked="checked"<?php } ?> />
                                <?php echo $_LANG['AD_ONLY_CHILD_ITEM']; ?>
                            </label>
                        </div>
                    </div>
                        
                    <div id="upr_menu">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MENU_TO_VIEW'];?></label>
                            <select class="form-control" style="width: 99%" name="menu[]" size="9" multiple="multiple">
                                <?php foreach ($menu_list as $menu) { ?>
                                <option value="<?php echo $menu['id']; ?>" <?php if (in_array($menu['id'], cmsCore::getArrVal($mod, 'menu', array()))) { echo 'selected="selected"'; }?>>
                                        <?php echo $menu['title']; ?>
                                    </option>
                                <?php } ?>
                            </select>
                            <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];?></div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>

    <div>
        <input type="button" class="btn btn-primary" name="add_mod" onclick="submitItem()" value="<?php echo $_LANG['SAVE']; ?> " />
        <input type="button" class="btn btn-default" name="back"  value="<?php echo $_LANG['CANCEL'];?>" onclick="window.location.href='index.php?view=menu';" />
        <input type="hidden" name="do" <?php if ($do=='add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> />
        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'.$mod['id'].'" />';
            }
        ?>
    </div>
</form>
<?php
   }
}
Ejemplo n.º 12
0
function applet_usergroups() {
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_USERS_GROUP']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_USERS_GROUP'], 'index.php?view=usergroups');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);

    cmsCore::loadModel('users');
    $model = new cms_model_users();

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'usergroupadd.gif', 'title' => $_LANG['AD_CREATE_GROUP'], 'link' => '?view=usergroups&do=add' ),
            array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=usergroups&do=edit&multiple=1');" ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('". $_LANG['AD_REMOVE_GROUP'] ."')) { checkSel('?view=users&do=delete&multiple=1'); }" )
        );
        
        cpToolMenu($toolmenu);
        
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=usergroups&do=edit&id=%id%', 'filter' => '12' ),
            array( 'title' => $_LANG['AD_FROM_USERS'], 'field' => 'id', 'width' => '110', 'prc' => 'getCountUsers' ),
            array( 'title' => $_LANG['AD_IF_ADMIN'], 'field' => 'is_admin', 'width' => '120', 'prc' => 'cpYesNo' ),
            array( 'title' => $_LANG['AD_ALIAS'], 'field' => 'alias', 'width' => '85', 'filter' => '12' )
        );
        
        $actions = array(
            array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=usergroups&do=edit&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_GROUP'], 'link' => '?view=usergroups&do=delete&id=%id%' )
        );
        
        cpListTable('cms_user_groups', $fields, $actions);
    }
    
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')){
            if ($id >= 0){
                $model->deleteGroup($id);
            }
        } else {
            $model->deleteGroups(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=usergroups');
    }

    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $types = array(
            'title' => array( 'title', 'str', '' ),
            'alias' => array( 'alias', 'str', '' ),
            'is_admin' => array( 'is_admin', 'int', 0 ),
            'access' => array( 'access', 'array_str', array(), create_function('$a_list', 'return implode(\',\', $a_list);') )
        );

        $items = cmsCore::getArrayFromRequest($types);

        if ($do == 'submit') {
            cmsCore::c('db')->insert('cms_user_groups', $items);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('index.php?view=usergroups');
        } else {
            cmsCore::c('db')->update('cms_user_groups', $items, $id);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=usergroups');
            } else {
                cmsCore::redirect('index.php?view=usergroups&do=edit');
            }
        }
    }

    if ($do == 'add' || $do == 'edit') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );
        
        cpToolMenu($toolmenu);

        if ($do == 'add') {
            cpAddPathway($_LANG['AD_CREATE_GROUP']);
            $mod = array();
        } else {
            if(cmsCore::inRequest('multiple')){
                if (cmsCore::inRequest('item')){
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_user_groups', "id = '". $item_id ."'", '*');
            if (!$mod){ cmsCore::error404(); }

            echo '<h3>'. $_LANG['AD_EDIT_GROUP'] .' '. $ostatok .'</h3>';

            cpAddPathway($_LANG['AD_EDIT_GROUP'] .' '. $mod['title']);
        }

        if (isset($mod['access'])) {
            $mod['access'] = str_replace(', ', ',', $mod['access']);
            $mod['access'] = explode(',', $mod['access']);
        }
?>
<form id="addform" name="addform" method="post" action="index.php?view=usergroups">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:650px;">
        <div class="form-group">
            <label><?php echo $_LANG['AD_GROUP_NAME'];?>:</label>
            <input type="text" class="form-control" name="title" size="30" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'title', '')); ?>" />
            <div class="help-block"><?php echo $_LANG['AD_VIEW_SITE']; ?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_ALIAS'];?>:</label>
            <input type="text" class="form-control" name="alias" size="30" <?php if (cmsCore::getArrVal($mod, 'alias', '') == 'guest') { echo 'readonly="readonly"'; } ?> value="<?php echo cmsCore::getArrVal($mod, 'alias', ''); ?>" />
            <?php if ($do == 'edit') { ?>
                <div class="help-block"><?php echo $_LANG['AD_DONT_CHANGE']; ?></div>
            <?php } ?>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_IF_ADMIN'];?>:</label>
            <div class="btn-group" data-toggle="buttons" style="float:right;">
                <label class="btn btn-default <?php if (cmsCore::getArrVal($mod, 'is_admin')) { echo 'active'; } ?>" onclick="$('#accesstable').hide();$('#admin_accesstable').show();">
                    <input type="radio" name="is_admin" <?php if (cmsCore::getArrVal($mod, 'is_admin')) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                </label>
                <label class="btn btn-default <?php if (!cmsCore::getArrVal($mod, 'is_admin')) { echo 'active'; } ?>" onclick="$('#accesstable').show();$('#admin_accesstable').hide();">
                    <input type="radio" name="is_admin" <?php if (!cmsCore::getArrVal($mod, 'is_admin')) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                </label>
            </div>
        </div>
        
        <hr>
        
        <div id="admin_accesstable" <?php if (!cmsCore::getArrVal($mod, 'is_admin')) { echo 'style="display:none;"'; } ?>>
            <div class="form-group">
                <label><?php echo $_LANG['AD_AVAILABLE_SECTIONS']; ?></label>
                
                <div style="margin-left:50px;">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_menu" name="access[]" value="admin/menu" <?php if (isset($mod['access'])) { if (in_array('admin/menu', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_MENU_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_modules" name="access[]" value="admin/modules" <?php if (isset($mod['access'])) { if (in_array('admin/modules', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_MODULES_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_content" name="access[]" value="admin/content" <?php if (isset($mod['access'])) { if (in_array('admin/content', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_CONTENTS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_plugins" name="access[]" value="admin/plugins" <?php if (isset($mod['access'])) { if (in_array('admin/filters', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_CONTENTS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_filters" name="access[]" value="admin/filters" <?php if (isset($mod['access'])) { if (in_array('admin/filters', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_FILTERS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_components" name="access[]" value="admin/components" <?php if (isset($mod['access'])) { if (in_array('admin/components', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_COMPONENTS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_users" name="access[]" value="admin/users" <?php if (isset($mod['access'])) { if (in_array('admin/users', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_USERS_CONTROL']; ?>
                        </label>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_config" name="access[]" value="admin/config" <?php if (isset($mod['access'])) { if (in_array('admin/config', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_SETTINGS_CONTROL']; ?>
                        </label>
                    </div>
                    
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_config" name="access[]" value="admin/tickets" <?php if (isset($mod['access'])) { if (in_array('admin/tickets', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_TICKETS_CONTROL']; ?>
                        </label>
                    </div>
                    
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" id="admin_config" name="access[]" value="admin/checksystem" <?php if (isset($mod['access'])) { if (in_array('admin/checksystem', $mod['access'])) { echo 'checked="checked"'; } } ?> />
                            <?php echo $_LANG['AD_CHECKSYSTEM_CONTROL']; ?>
                        </label>
                    </div>
                </div>
                
                <div class="help-block"><?php echo $_LANG['AD_ALL_SECTIONS']; ?></div>
            </div>
            
            <div class="form-group">
                <label><?php echo $_LANG['AD_COMPONENTS_SETTINGS_FREE']; ?></label>
                
                <div style="margin-left:50px;">
                    <?php
                        $coms = cmsCore::getInstance()->getAllComponents();
                        foreach ($coms as $com) {
                            if (!file_exists(PATH.'/admin/components/'. $com['link'] .'/backend.php')) { continue; }
                    ?>

                        <div class="checkbox">
                            <label>
                                <input type="checkbox" id="admin_com_<?php echo $com['link']; ?>" name="access[]" value="admin/com_<?php echo $com['link']; ?>" <?php if (isset($mod['access'])) { if (in_array('admin/com_'. $com['link'], $mod['access'])) { echo 'checked="checked"'; } } ?> />
                                <?php echo $com['title']; ?>
                            </label>
                        </div>
                    <?php } ?>
                </div>
                
                <div class="help-block"><?php echo $_LANG['AD_COMPONENTS_SETTINGS_ON']; ?></div>
            </div>
        </div>
        
        <div id="accesstable" <?php if (cmsCore::getArrVal($mod, 'is_admin')) { echo 'style="display:none;"'; } ?>>
            <div class="form-group">
                <label><?php echo $_LANG['AD_GROUP_RULE'];?></label>
                
                <div style="margin-left:50px;">
                    <?php
                        $sql = "SELECT * FROM cms_user_groups_access ORDER BY access_type";
                        $res = cmsCore::c('db')->query($sql);

                        while ($ga = cmsCore::c('db')->fetch_assoc($res)) {
                            if ($mod['alias'] == 'guest' && $ga['hide_for_guest']) { continue; }
                    ?>
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" id="<?php echo str_replace('/', '_', $ga['access_type']); ?>" name="access[]" value="<?php echo $ga['access_type']; ?>" <?php if (isset($mod['access'])) { if (in_array($ga['access_type'], $mod['access'])) { echo 'checked="checked"'; } } ?> />
                                <?php echo $ga['access_name']; ?>
                            </label>
                        </div>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>
    
    <div>
        <input type="submit" class="btn btn-primary" name="add_mod" value="<?php if ($do == 'add') { echo $_LANG['AD_CREATE_GROUP']; } else { echo $_LANG['SAVE']; } ?>" />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL'];?>" onclick="window.history.back();"/>
        
        <input type="hidden" name="do" value="<?php if ($do == 'add') { echo 'submit'; } else { echo 'update'; } ?>" />
        <?php
            if ($do == 'edit') {
                echo '<input name="id" type="hidden" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
<?php
   }
}
Ejemplo n.º 13
0
function applet_components()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/components', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_COMPONENTS'];
    cpAddPathway($_LANG['AD_COMPONENTS'], 'index.php?view=components');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', 0);
    $link = cmsCore::request('link', 'str', '');
    if ($link) {
        $_REQUEST['id'] = $id = $inCore->getComponentId($link);
    }
    if ($do != 'list') {
        $com = $inCore->getComponent($id);
        if (!$com) {
            cmsCore::error404();
        }
        if (!cmsUser::isAdminCan('admin/com_' . $com['link'], $adminAccess)) {
            cpAccessDenied();
        }
    }
    if ($do == 'show') {
        dbShow('cms_components', $id);
        echo '1';
        exit;
    }
    if ($do == 'hide') {
        dbHide('cms_components', $id);
        echo '1';
        exit;
    }
    if ($do == 'config') {
        $file = PATH . '/admin/components/' . $com['link'] . '/backend.php';
        if (file_exists($file)) {
            cpAddPathway($com['title'] . ' v' . $com['version'], '?view=components&do=config&id=' . $com['id']);
            cmsCore::loadLanguage('components/' . $com['link']);
            cmsCore::loadLanguage('admin/components/' . $com['link']);
            include $file;
            return;
        } else {
            cmsCore::redirect('index.php?view=components');
        }
    }
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'install.gif', 'title' => $_LANG['AD_INSTALL_COMPONENTS'], 'link' => '?view=install&do=component');
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=components');
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'link' => '?view=components&do=config&id=%id%', 'width' => '');
        $fields[] = array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '60');
        $fields[] = array('title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '65');
        $fields[] = array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '200');
        $fields[] = array('title' => $_LANG['AD_LINK'], 'field' => 'link', 'width' => '100');
        $actions[] = array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=components&do=config&id=%id%', 'condition' => 'cpComponentHasConfig');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=install&do=remove_component&id=%id%', 'condition' => 'cpComponentCanRemove', 'confirm' => $_LANG['AD_DELETED_COMPONENT_FROM']);
        $where = '';
        if ($inUser->id > 1) {
            foreach ($adminAccess as $key => $value) {
                if (mb_strstr($value, 'admin/com_')) {
                    if ($where) {
                        $where .= ' OR ';
                    }
                    $value = str_replace('admin/com_', '', $value);
                    $where .= "link='{$value}'";
                }
            }
        }
        if (!$where) {
            $where = 'id>0';
        }
        cpListTable('cms_components', $fields, $actions, $where);
    }
}
Ejemplo n.º 14
0
Archivo: cats.php Proyecto: r2git/icms1
function applet_cats()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    $GLOBALS['cp_page_title'] = $_LANG['AD_ARTICLES'];
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');
    cmsCore::loadModel('content');
    $model = new cms_model_content();
    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);
    define('IS_BILLING', $inCore->isComponentInstalled('billing'));
    if (IS_BILLING) {
        cmsCore::loadClass('billing');
    }
    if ($do == 'delete') {
        $is_with_content = cmsCore::inRequest('content');
        $model->deleteCategory($id, $is_with_content);
        cmsCore::addSessionMessage($is_with_content ? $_LANG['AD_CATEGORY_REMOVED'] : $_LANG['AD_CATEGORY_REMOVED_NOT_ARTICLE'], 'success');
        cmsCore::redirect('?view=tree');
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $category['id'] = cmsCore::request('id', 'int', 0);
        $category['title'] = cmsCore::request('title', 'str', $_LANG['AD_SECTION_UNTITLED']);
        $category['parent_id'] = cmsCore::request('parent_id', 'int');
        $category['description'] = cmsCore::request('description', 'html');
        $category['description'] = $inDB->escape_string($category['description']);
        $category['published'] = cmsCore::request('published', 'int', 0);
        $category['showdate'] = cmsCore::request('showdate', 'int', 0);
        $category['showcomm'] = cmsCore::request('showcomm', 'int', 0);
        $category['orderby'] = cmsCore::request('orderby', 'str');
        $category['orderto'] = cmsCore::request('orderto', 'str');
        $category['modgrp_id'] = cmsCore::request('modgrp_id', 'int', 0);
        $category['maxcols'] = cmsCore::request('maxcols', 'int', 0);
        $category['showtags'] = cmsCore::request('showtags', 'int', 0);
        $category['showrss'] = cmsCore::request('showrss', 'int', 0);
        $category['showdesc'] = cmsCore::request('showdesc', 'int', 0);
        $category['is_public'] = cmsCore::request('is_public', 'int', 0);
        $category['url'] = cmsCore::request('url', 'str');
        $category['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $category['meta_desc'] = cmsCore::request('meta_desc', 'str');
        $category['meta_keys'] = cmsCore::request('meta_keys', 'str');
        if ($category['url']) {
            $category['url'] = cmsCore::strToURL($category['url'], $model->config['is_url_cyrillic']);
        }
        $category['tpl'] = cmsCore::request('tpl', 'str', 'com_content_view.tpl');
        $category['cost'] = cmsCore::request('cost', 'str', '');
        if (!is_numeric($category['cost'])) {
            $category['cost'] = '';
        }
        $album = array();
        $album['id'] = cmsCore::request('album_id', 'int', 0);
        $album['header'] = cmsCore::request('album_header', 'str', '');
        $album['orderby'] = cmsCore::request('album_orderby', 'str', '');
        $album['orderto'] = cmsCore::request('album_orderto', 'str', '');
        $album['maxcols'] = cmsCore::request('album_maxcols', 'int', 0);
        $album['max'] = cmsCore::request('album_max', 'int', 0);
        if ($album['id']) {
            $category['photoalbum'] = serialize($album);
        } else {
            $category['photoalbum'] = '';
        }
        // получаем старую категорию
        $old = $inDB->get_fields('cms_category', "id='{$category['id']}'", '*');
        if (!$old) {
            cmsCore::error404();
        }
        // если сменили категорию
        if ($old['parent_id'] != $category['parent_id']) {
            // перемещаем ее в дереве
            $inCore->nestedSetsInit('cms_category')->MoveNode($category['id'], $category['parent_id']);
            // обновляем сеолинки категорий
            $inDB->updateNsCategorySeoLink('cms_category', $category['id'], $model->config['is_url_cyrillic']);
            // Обновляем ссылки меню на категории
            $model->updateCatMenu();
            // обновляем сеолинки всех вложенных статей
            $model->updateArticlesSeoLink($category['id']);
            cmsCore::addSessionMessage($_LANG['AD_CATEGORY_NEW_URL'], 'info');
        }
        $inDB->update('cms_category', $category, $category['id']);
        // если пришел запрос на обновление ссылок
        // и категория не менялась - если менялась, мы выше все обновили
        if (cmsCore::inRequest('update_seolink') && $old['parent_id'] == $category['parent_id']) {
            // обновляем сеолинки категорий
            $inDB->updateNsCategorySeoLink('cms_category', $category['id'], $model->config['is_url_cyrillic']);
            // Обновляем ссылки меню на категории
            $model->updateCatMenu();
            // обновляем сеолинки всех вложенных статей
            $model->updateArticlesSeoLink($category['id']);
            cmsCore::addSessionMessage($_LANG['AD_SECTION_AND_ARTICLES_NEW_URL'], 'info');
        }
        if (!cmsCore::request('is_access', 'int', 0)) {
            $showfor = $_REQUEST['showfor'];
            cmsCore::setAccess($category['id'], $showfor, 'category');
        } else {
            cmsCore::clearAccess($category['id'], 'category');
        }
        cmsCore::addSessionMessage($_LANG['AD_CATEGORY_SAVED'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('?view=tree&cat_id=' . $category['id']);
        } else {
            cmsCore::redirect('?view=tree');
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $category['title'] = cmsCore::request('title', 'str', $_LANG['AD_CATEGORY_UNTITLED']);
        $category['url'] = cmsCore::request('url', 'str');
        if ($category['url']) {
            $category['url'] = cmsCore::strToURL($category['url']);
        }
        $category['parent_id'] = cmsCore::request('parent_id', 'int');
        $category['description'] = cmsCore::request('description', 'html');
        $category['description'] = $inDB->escape_string($category['description']);
        $category['published'] = cmsCore::request('published', 'int', 0);
        $category['showdate'] = cmsCore::request('showdate', 'int', 0);
        $category['showcomm'] = cmsCore::request('showcomm', 'int', 0);
        $category['orderby'] = cmsCore::request('orderby', 'str');
        $category['orderto'] = cmsCore::request('orderto', 'str');
        $category['modgrp_id'] = cmsCore::request('modgrp_id', 'int', 0);
        $category['maxcols'] = cmsCore::request('maxcols', 'int', 0);
        $category['showtags'] = cmsCore::request('showtags', 'int', 0);
        $category['showrss'] = cmsCore::request('showrss', 'int', 0);
        $category['showdesc'] = cmsCore::request('showdesc', 'int', 0);
        $category['is_public'] = cmsCore::request('is_public', 'int', 0);
        $category['tpl'] = cmsCore::request('tpl', 'str', 'com_content_view.tpl');
        $category['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
        $category['meta_desc'] = cmsCore::request('meta_desc', 'str');
        $category['meta_keys'] = cmsCore::request('meta_keys', 'str');
        $category['cost'] = cmsCore::request('cost', 'str', 0);
        if (!is_numeric($category['cost'])) {
            $category['cost'] = '';
        }
        $album = array();
        $album['id'] = cmsCore::request('album_id', 'int', 0);
        $album['header'] = cmsCore::request('album_header', 'str', '');
        $album['orderby'] = cmsCore::request('album_orderby', 'str', '');
        $album['orderto'] = cmsCore::request('album_orderto', 'str', '');
        $album['maxcols'] = cmsCore::request('album_maxcols', 'int', 0);
        $album['max'] = cmsCore::request('album_max', 'int', 0);
        if ($album['id']) {
            $category['photoalbum'] = serialize($album);
        } else {
            $category['photoalbum'] = '';
        }
        $ns = $inCore->nestedSetsInit('cms_category');
        $category['id'] = $ns->AddNode($category['parent_id']);
        $category['seolink'] = cmsCore::generateCatSeoLink($category, 'cms_category', $model->config['is_url_cyrillic']);
        if ($category['id']) {
            $inDB->update('cms_category', $category, $category['id']);
            if (!cmsCore::request('is_access', 'int', 0)) {
                $showfor = $_REQUEST['showfor'];
                cmsCore::setAccess($category['id'], $showfor, 'category');
            } else {
                cmsCore::clearAccess($category['id'], 'category');
            }
        }
        $inmenu = cmsCore::request('createmenu', 'str', '');
        if ($inmenu) {
            createMenuItem($inmenu, $category['id'], $category['title']);
        }
        cmsCore::addSessionMessage($_LANG['AD_CATEGORY_ADD'], 'success');
        cmsCore::redirect('?view=tree');
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $toolmenu = array();
        $toolmenu[0]['icon'] = 'save.gif';
        $toolmenu[0]['title'] = $_LANG['SAVE'];
        $toolmenu[0]['link'] = 'javascript:document.addform.submit();';
        $toolmenu[1]['icon'] = 'cancel.gif';
        $toolmenu[1]['title'] = $_LANG['CANCEL'];
        $toolmenu[1]['link'] = 'javascript:history.go(-1);';
        cpToolMenu($toolmenu);
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_CREATE_SECTION'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_SECTION'], 'index.php?view=cats&do=add');
            $mod['tpl'] = 'com_content_view.tpl';
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = $_REQUEST['item'];
                } else {
                    echo '<p class="error">' . $_LANG['AD_NO_SELECT_OBJECTS'] . '</p>';
                    return;
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $id = (int) $_REQUEST['id'];
            }
            $sql = "SELECT * FROM cms_category WHERE id = {$id} LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $mod = $inDB->fetch_assoc($result);
                if (@$mod['photoalbum']) {
                    $mod['photoalbum'] = unserialize($mod['photoalbum']);
                }
            }
            echo '<h3>' . $_LANG['AD_EDIT_SECTION'] . $ostatok . '</h3>';
            cpAddPathway($mod['title'], 'index.php?view=cats&do=edit&id=' . $mod['id']);
        }
        ?>

    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="cats" />
        <table class="proptable" width="100%" cellpadding="5" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">
                    <table border="0" cellpadding="0" cellspacing="5" width="100%">
                      <tbody>
                        <tr>
                          <td>
                            <strong><?php 
        echo $_LANG['AD_TITLE_PARTITION'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'title');
        ?>
                          </td>
                          <td width="190" style="padding-left:6px">
                            <strong><?php 
        echo $_LANG['AD_TEMPLATE_PARTITION'];
        ?>
</strong>
                          </td>
                        </tr>
                        <tr>
                          <td>
                        <input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" />
                          </td>
                          <td style="padding-left:6px">
                            <input name="tpl" type="text" style="width:98%" value="<?php 
        echo @$mod['tpl'];
        ?>
" />
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <div><strong><?php 
        echo $_LANG['AD_PARENT_PARTITION'];
        ?>
</strong></div>
                    <div>
                        <div class="parent_notice" style="color:red;margin:4px 0px;display:none"><?php 
        echo $_LANG['AD_ANOTHER_PARENT'];
        ?>
</div>
                        <select name="parent_id" size="12" id="parent_id" style="width:100%" onchange="if($('option:selected',this).data('nsleft')>='<?php 
        echo $mod['NSLeft'];
        ?>
' && $('option:selected',this).data('nsright')<='<?php 
        echo $mod['NSRight'];
        ?>
'){ $('.parent_notice').show();$('#add_mod').prop('disabled', true); } else { $('.parent_notice').hide();$('#add_mod').prop('disabled', false); }">
                            <?php 
        $rootid = $inDB->getNsRootCatId('cms_category');
        ?>
                            <option value="<?php 
        echo $rootid;
        ?>
" <?php 
        if (@$mod['parent_id'] == $rootid || !isset($mod['parent_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_SECTION'];
        ?>
</option>
                            <?php 
        if (isset($mod['parent_id'])) {
            echo $inCore->getListItemsNS('cms_category', $mod['parent_id']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                        </select>
                    </div>

                    <div><strong><?php 
        echo $_LANG['AD_SECTION_DESCRIPT'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'description');
        ?>
</div>
                    <div>
                        <?php 
        $inCore->insertEditor('description', $mod['description'], '250', '100%');
        ?>
                    </div>

                </td>

                <!-- боковая -->
                <td valign="top" width="350" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_PUBLIC_SECTION'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

					<div style=" <?php 
        if ($do == 'edit') {
            ?>
display:none;<?php 
        }
        ?>
" class="url_cat">
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_SECTION_URL'];
        ?>
</strong><br/>
                            <div style="color:gray"><?php 
        echo $_LANG['AD_FROM_TITLE'];
        ?>
</div>
                        </div>
                        <div>
                            <input type="text" name="url" value="<?php 
        echo $mod['url'];
        ?>
" style="width:99%"/>
                        </div>
                    </div>

					<?php 
        if ($do == 'edit') {
            ?>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:15px">
                            <tr>
                                <td width="20"><input type="checkbox" name="update_seolink" id="update_seolink" value="1" onclick="$('.url_cat').slideToggle('fast');" /></td>
                                <td><label for="update_seolink"><strong><?php 
            echo $_LANG['AD_NEW_LINK'];
            ?>
</strong></label></td>
                            </tr>
                        </table>
                        <div class="url_cat" style="display:none;"><strong style="color:#F00;"><?php 
            echo $_LANG['ATTENTION'];
            ?>
:</strong> <?php 
            echo $_LANG['AD_NO_LINKS'];
            ?>
</div>
                    <?php 
        }
        ?>

                    <div style="margin-top:20px"><strong><?php 
        echo $_LANG['AD_SORT_ARTICLES'];
        ?>
</strong></div>
                    <div>
                        <select name="orderby" id="orderby" style="width:100%">
                            <option value="pubdate" <?php 
        if (@$mod['orderby'] == 'pubdate') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_CALENDAR'];
        ?>
</option>
                            <option value="title" <?php 
        if (@$mod['orderby'] == 'title') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_TITLE'];
        ?>
</option>
                            <option value="ordering" <?php 
        if (@$mod['orderby'] == 'ordering') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_ORDER'];
        ?>
</option>
                            <option value="hits" <?php 
        if (@$mod['orderby'] == 'hits') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_VIEWS'];
        ?>
</option>
                        </select>
                        <select name="orderto" id="orderto" style="width:100%">
                            <option value="ASC" <?php 
        if (@$mod['orderto'] == 'ASC') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_INCREMENT'];
        ?>
</option>
                            <option value="DESC" <?php 
        if (@$mod['orderto'] == 'DESC') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DECREMENT'];
        ?>
</option>
                        </select>
                    </div>

                    <div style="margin-top:20px"><strong><?php 
        echo $_LANG['AD_HOW_MANY_COLUMNS'];
        ?>
</strong></div>
                    <div>
                        <?php 
        if (!isset($mod['maxcols'])) {
            $mod['maxcols'] = 1;
        }
        ?>
                        <input class="uispin" name="maxcols" type="text" id="maxcols" style="width:99%" value="<?php 
        echo @$mod['maxcols'];
        ?>
" />
                    </div>

                    <div style="margin-top:20px"><strong><?php 
        echo $_LANG['AD_HOW_PUBLISH_SET'];
        ?>
</strong></div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="showdesc" id="showdesc" value="1" <?php 
        if ($mod['showdesc'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showdesc"><?php 
        echo $_LANG['AD_PREVIEW'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showdate" id="showdate" value="1" <?php 
        if ($mod['showdate'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showdate"><?php 
        echo $_LANG['AD_CALENDAR_VIEW'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showcomm" id="showcomm" value="1" <?php 
        if ($mod['showcomm'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showcomm"><?php 
        echo $_LANG['AD_HOW_MANY_COMENTS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showtags" id="showtags" value="1" <?php 
        if ($mod['showtags'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showtags"><?php 
        echo $_LANG['AD_HOW_MANY_TAGS'];
        ?>
</label></td>
                        </tr>
                        <tr>
                            <td width="20"><input type="checkbox" name="showrss" id="showrss" value="1" <?php 
        if ($mod['showrss'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="showrss"><?php 
        echo $_LANG['AD_RSS_VIEW'];
        ?>
</label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'add') {
            ?>
                        <div style="margin-top:25px">
                            <strong><?php 
            echo $_LANG['AD_CREATE_LINK'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="createmenu" id="createmenu" style="width:99%">
                                <option value="0" selected="selected"><?php 
            echo $_LANG['AD_DONT_CREATE'];
            ?>
</option>
                            <?php 
            foreach ($menu_list as $menu) {
                ?>
                                <option value="<?php 
                echo $menu['id'];
                ?>
">
                                    <?php 
                echo $menu['title'];
                ?>
                                </option>
                            <?php 
            }
            ?>
                            </select>
                        </div>
                    <?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_EDITORS'];
        ?>
}

                        <div style="margin-top:10px">
                            <strong><?php 
        echo $_LANG['AD_USERS_ARTICLES'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_IF_SWITCH'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="is_public" style="width:100%">
                                <option value="0" <?php 
        if (!$mod['is_public']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['NO'];
        ?>
</option>
                                <option value="1" <?php 
        if ($mod['is_public']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['YES'];
        ?>
</option>
                            </select>
                        </div>
                        <?php 
        if (IS_BILLING) {
            ?>
                            <div style="margin-top:15px">
                                <strong><?php 
            echo $_LANG['AD_COST_ARTICLES_ADD'];
            ?>
</strong><br/>
                                <div style="color:gray"><?php 
            echo $_LANG['AD_COST_ARTICLES_BY_DEFAULT'];
            ?>
</div>
                            </div>
                            <div>
                                <input type="text" name="cost" value="<?php 
            echo $mod['cost'];
            ?>
" style="width:50px"/><?php 
            echo $_LANG['BILLING_POINT10'];
            ?>
                            </div>
                        <?php 
        }
        ?>
                        <div style="margin-top:20px">
                            <strong><?php 
        echo $_LANG['AD_EDITORS_SECTION'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_USERS_CAN_ADMIN'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="modgrp_id" id="modgrp_id" style="width:100%">
                                <option value="0" <?php 
        if (!isset($mod['modgrp_id']) || @$mod['modgrp_id'] == 0) {
            echo 'selected';
        }
        ?>
><?php 
        echo $_LANG['AD_ONLY_ADMINS'];
        ?>
</option>
                                <?php 
        if (@$mod['modgrp_id']) {
            echo $inCore->getListItems('cms_user_groups', $mod['modgrp_id'], 'id', 'ASC', 'is_admin = 0');
        } else {
            echo $inCore->getListItems('cms_user_groups', 0, 'id', 'ASC', 'is_admin = 0');
        }
        ?>
                            </select>
                        </div>

                    {tab=<?php 
        echo $_LANG['AD_FOTO'];
        ?>
}

                        <div style="margin-top:10px">
                            <strong><?php 
        echo $_LANG['AD_PHOTOALBUM_CONNECT'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_PHOTO_BY_ARTICLES'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="album_id" id="album_id" style="width:100%" onchange="choosePhotoAlbum()">
                                <option value="0" <?php 
        if (!isset($mod['photoalbum']['id']) || !@$mod['photoalbum']['id']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_DONT_CONNECT'];
        ?>
</option>
                                <?php 
        //FIND ROOT
        if (isset($mod['photoalbum']['id'])) {
            echo $inCore->getListItemsNS('cms_photo_albums', $mod['photoalbum']['id']);
        } else {
            echo $inCore->getListItemsNS('cms_photo_albums');
        }
        ?>
                            </select>
                        </div>
						<div id="con_photoalbum" <?php 
        if (!isset($mod['photoalbum']['id']) || !$mod['photoalbum']['id']) {
            echo 'style="display:none;"';
        }
        ?>
>
                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_TITLE'];
        ?>
</strong><br/>
                                <span class="hinttext"><?php 
        echo $_LANG['AD_OVER_PHOTOS'];
        ?>
</span>
                            </div>
                            <div>
                                <input name="album_header" type="text" id="album_header" style="width:99%" value="<?php 
        echo @$mod['photoalbum']['header'];
        ?>
" />
                            </div>

                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_PHOTOS_SORT'];
        ?>
</strong>
                            </div>
                            <div>
                                <select name="album_orderby" id="album_orderby" style="width:100%">
                                    <option value="title" <?php 
        if (@$mod['photoalbum']['orderby'] == 'title') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_ALPHABET'];
        ?>
</option>
                                    <option value="pubdate" <?php 
        if (@$mod['photoalbum']['orderby'] == 'pubdate') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_CALENDAR'];
        ?>
</option>
                                    <option value="rating" <?php 
        if (@$mod['photoalbum']['orderby'] == 'rating') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_RATING'];
        ?>
</option>
                                    <option value="hits" <?php 
        if (@$mod['photoalbum']['orderby'] == 'hits') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_VIEWS'];
        ?>
</option>
                                </select>
                                <select name="album_orderto" id="album_orderto" style="width:100%">
                                    <option value="desc" <?php 
        if (@$mod['photoalbum']['orderto'] == 'desc') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DECREMENT'];
        ?>
</option>
                                    <option value="asc" <?php 
        if (@$mod['photoalbum']['orderto'] == 'asc') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_INCREMENT'];
        ?>
</option>
                                </select>
                            </div>

                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_HOW_MANY_COLUMNS'];
        ?>
</strong>
                            </div>
                            <div>
                                <?php 
        if (!isset($mod['photoalbum']['maxcols'])) {
            $mod['photoalbum']['maxcols'] = 2;
        }
        ?>
                                <input name="album_maxcols" type="text" id="album_maxcols" style="width:99%" value="<?php 
        echo @$mod['photoalbum']['maxcols'];
        ?>
"/>
                            </div>

                            <div style="margin-top:20px">
                                <strong><?php 
        echo $_LANG['AD_HOW_MANY_PHOTO'];
        ?>
</strong>
                            </div>
                            <div>
                                <?php 
        if (!isset($mod['photoalbum']['max'])) {
            $mod['photoalbum']['max'] = 8;
        }
        ?>
                                <input name="album_max" type="text" id="album_max" style="width:99%" value="<?php 
        echo @$mod['photoalbum']['max'];
        ?>
"/>
                            </div>
                       </div>
                        {tab=SEO}

                        <div style="margin-top:5px">
                            <strong><?php 
        echo $_LANG['AD_PAGE_TITLE'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'pagetitle');
        ?>
<br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_IF_UNKNOWN_PAGETITLE'];
        ?>
</span>
                        </div>
                        <div>
                            <input name="pagetitle" type="text" id="pagetitle" style="width:99%" value="<?php 
        if (isset($mod['pagetitle'])) {
            echo htmlspecialchars($mod['pagetitle']);
        }
        ?>
" />
                        </div>

                        <div style="margin-top:20px">
                            <strong><?php 
        echo $_LANG['KEYWORDS'];
        ?>
</strong> <?php 
        printLangPanel('content_category', @$mod['id'], 'meta_keys');
        ?>
<br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_FROM_COMMA'];
        ?>
</span>
                        </div>
                        <div>
                             <textarea name="meta_keys" style="width:97%" rows="4" id="meta_keys"><?php 
        echo htmlspecialchars($mod['meta_keys']);
        ?>
</textarea>
                        </div>

                        <div style="margin-top:20px">
                            <strong><?php 
        echo $_LANG['DESCRIPTION'];
        ?>
</strong>  <?php 
        printLangPanel('content_category', @$mod['id'], 'meta_desc');
        ?>
<br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_LESS_THAN'];
        ?>
</span>
                        </div>
                        <div>
                             <textarea name="meta_desc" style="width:97%" rows="6" id="meta_desc"><?php 
        echo htmlspecialchars($mod['meta_desc']);
        ?>
</textarea>
                        </div>
                      {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}

                      <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                          <tr>
                              <td width="20">
                                  <?php 
        $sql = "SELECT * FROM cms_user_groups";
        $result = $inDB->query($sql);
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            $sql2 = "SELECT * FROM cms_content_access WHERE content_id = " . $mod['id'] . " AND content_type = 'category'";
            $result2 = $inDB->query($sql2);
            $ord = array();
            if ($inDB->num_rows($result2)) {
                $public = '';
                $style = '';
                while ($r = $inDB->fetch_assoc($result2)) {
                    $ord[] = $r['group_id'];
                }
            }
        }
        ?>
                                  <input name="is_access" type="checkbox" id="is_public" onclick="checkGroupList()" value="1" <?php 
        echo $public;
        ?>
 />
                              </td>
                              <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                          </tr>
                      </table>
                      <div style="padding:5px">
                          <span class="hinttext">
                              <?php 
        echo $_LANG['AD_IF_NOTED'];
        ?>
                          </span>
                      </div>

                      <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                          <div>
                              <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                              <span class="hinttext">
                                  <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                              </span>
                          </div>
                          <div>
                              <?php 
        echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" ' . $style . '>';
        if ($inDB->num_rows($result)) {
            while ($item = $inDB->fetch_assoc($result)) {
                echo '<option value="' . $item['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($ord, $item['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $item['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                          </div>
                      </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>
        <p>
            <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_SAVE_SECTION'] . '"';
        } else {
            echo 'value="' . $_LANG['AD_SAVE_SECTION'] . '"';
        }
        ?>
 />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>

    </form>
<script type="text/javascript">
function choosePhotoAlbum(){
	id = $('select[name=album_id]').val();
	if(id != 0){
		$('#con_photoalbum').fadeIn();
	} else {
		$('#con_photoalbum').hide();
	}
}
</script>
<?php 
    }
}
Ejemplo n.º 15
0
function applet_modules()
{
    $inCore = cmsCore::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_MODULES']);
    cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules');
    cmsCore::c('page')->addHeadJS('admin/js/modules.js');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $co = cmsCore::request('co', 'int', -1);
    if ($do == 'config') {
        $module_name = cpModuleById($id);
        $module_title = cpModuleTitleById($id);
        if (!$module_name) {
            cmsCore::redirect('index.php?view=modules&do=edit&id=' . $id);
        }
        $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml';
        $php_file = 'modules/' . $module_name . '/backend.php';
        if (file_exists($php_file)) {
            include $php_file;
            return;
        }
        $cfg = $inCore->loadModuleConfig($id);
        cpAddPathway($module_title, '?view=modules&do=edit&id=' . $id);
        cpAddPathway($_LANG['AD_SETTINGS']);
        $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id=' . $id));
        cpToolMenu($toolmenu);
        $tpl = cmsCore::c('page')->initTemplate('applets', 'modules_config')->assign('module_title', $module_title)->assign('id', $id);
        if (file_exists($xml_file)) {
            cmsCore::loadClass('formgen');
            $formGen = new cmsFormGen($xml_file, $cfg);
            $tpl->assign('formGenHtml', $formGen->getHTML());
        } else {
            $tpl->assign('cfg', $cfg);
        }
        $tpl->display();
    }
    if ($do == 'save_auto_config') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $module_name = cpModuleById($id);
        $is_ajax = cmsCore::inRequest('ajax');
        if ($is_ajax) {
            $title = cmsCore::request('title', 'str', '');
            $published = cmsCore::request('published', 'int', 0);
            cmsCore::c('db')->query("UPDATE cms_modules SET title='" . $title . "', published='" . $published . "' WHERE id=" . $id);
            if (cmsCore::inRequest('content')) {
                $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html'));
                cmsCore::c('db')->query("UPDATE cms_modules SET content='" . $content . "' WHERE id=" . $id);
            }
        }
        if (cmsCore::inRequest('title_only')) {
            cmsCore::redirectBack();
        }
        $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml';
        if (file_exists($xml_file)) {
            $cfg = array();
            $backend = simplexml_load_file($xml_file);
            foreach ($backend->params->param as $param) {
                $name = (string) $param['name'];
                $type = (string) $param['type'];
                $default = (string) $param['default'];
                switch ($param['type']) {
                    case 'number':
                        $value = cmsCore::request($name, 'int', $default);
                        break;
                    case 'string':
                        $value = cmsCore::request($name, 'str', $default);
                        break;
                    case 'html':
                        $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default));
                        break;
                    case 'flag':
                        $value = cmsCore::request($name, 'int', 0);
                        break;
                    case 'list':
                        $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                        break;
                    case 'list_function':
                        $value = cmsCore::request($name, 'str', $default);
                        break;
                    case 'list_db':
                        $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                        break;
                }
                $cfg[$name] = $value;
            }
        }
        $cfg['tpl'] = cmsCore::request('tpl', 'str', $module_name);
        $inCore->saveModuleConfig($id, $cfg);
        if (!$is_ajax) {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        }
        cmsCore::redirectBack();
    }
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add'), array('icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');"), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');"), array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');"), array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');"), array('icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder'), array('icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');"), array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules'));
        cpToolMenu($toolmenu);
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_TITLE'], 'field' => array('title', 'titles'), 'width' => '', 'link' => '?view=modules&do=edit&id=%id%', 'prc' => function ($i) {
            $i['titles'] = cmsCore::yamlToArray($i['titles']);
            // переопределяем название пункта меню в зависимости от языка
            if (!empty($i['titles'][cmsConfig::getConfig('lang')])) {
                $i['title'] = $i['titles'][cmsConfig::getConfig('lang')];
            }
            return $i['title'];
        }), array('title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15'), array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '70'), array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110'), array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80'), array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100'), array('title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('positions')));
        $actions = array(array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig'), array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%'));
        cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC');
    }
    if ($do == 'autoorder') {
        $rs = cmsCore::c('db')->query("SELECT id, position FROM cms_modules ORDER BY position");
        if (cmsCore::c('db')->num_rows($rs)) {
            $ord = 1;
            while ($item = cmsCore::c('db')->fetch_assoc($rs)) {
                if (isset($latest_pos)) {
                    if ($latest_pos != $item['position']) {
                        $ord = 1;
                    }
                }
                cmsCore::c('db')->query("UPDATE cms_modules SET ordering = " . $ord . " WHERE id=" . $item['id']);
                $ord += 1;
                $latest_pos = $item['position'];
            }
        }
        cmsCore::redirect('index.php?view=modules');
    }
    if ($do == 'move_up') {
        if ($id >= 0) {
            dbMoveUp('cms_modules', $id, $co);
        }
        cmsCore::redirectBack();
    }
    if ($do == 'move_down') {
        if ($id >= 0) {
            dbMoveDown('cms_modules', $id, $co);
        }
        cmsCore::redirectBack();
    }
    if ($do == 'saveorder') {
        if (isset($_REQUEST['ordering'])) {
            $ord = $_REQUEST['ordering'];
            $ids = $_REQUEST['ids'];
            foreach ($ord as $id => $ordering) {
                cmsCore::c('db')->query("UPDATE cms_modules SET ordering = " . (int) $ordering . " WHERE id = " . (int) $ids[$id]);
            }
            cmsCore::redirect('index.php?view=modules');
        }
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '1');
            }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '1');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '0');
            }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '0');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            $inCore->removeModule($id);
        } else {
            $inCore->removeModule(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $id = cmsCore::request('id', 'int', 0);
        $mod = cmsCore::c('db')->get_fields('cms_modules', "id = " . $id . "", '*');
        $module = array('name' => cmsCore::request('name', 'str', ''), 'title' => cmsCore::request('title', 'str', ''), 'titles' => cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())), 'position' => cmsCore::request('position', 'str', ''), 'showtitle' => cmsCore::request('showtitle', 'int', 0), 'published' => cmsCore::request('published', 'int', 0), 'css_prefix' => cmsCore::request('css_prefix', 'str', ''), 'is_strict_bind' => cmsCore::request('is_strict_bind', 'int', 0), 'is_strict_bind_hidden' => cmsCore::request('is_strict_bind_hidden', 'int', 0), 'template' => cmsCore::request('template', 'str', ''), 'cache' => cmsCore::request('cache', 'int', 0), 'cachetime' => cmsCore::request('cachetime', 'int', 0), 'cacheint' => cmsCore::request('cacheint', 'str', ''), 'access_list' => '', 'hidden_menu_ids' => '');
        if (!$mod['is_external']) {
            $module['content'] = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', ''));
        }
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $module['access_list'] = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        cmsCore::c('db')->update('cms_modules', $module, $id);
        cmsCore::c('db')->delete('cms_modules_bind', "module_id=" . $id . " AND tpl='" . cmsCore::c('config')->template . "'");
        if (cmsCore::request('show_all', 'int', 0)) {
            cmsCore::c('db')->insert('cms_modules_bind', array('module_id' => $id, 'menu_id' => 0, 'position' => $module['position'], 'tpl' => cmsCore::c('config')->template));
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if (!empty($hidden_menu_ids)) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='" . $hidden_menu_ids . "' WHERE id = '" . $id . "' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array_int', array());
            $showpos = cmsCore::request('showpos', 'array_str', array());
            if (count($showin) > 0) {
                foreach ($showin as $key => $value) {
                    cmsCore::c('db')->insert('cms_modules_bind', array('module_id' => $id, 'menu_id' => $value, 'position' => $showpos[$value], 'tpl' => cmsCore::c('config')->template));
                }
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) {
            cmsCore::redirect('index.php?view=modules');
        } else {
            cmsCore::redirect('index.php?view=modules&do=edit');
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $maxorder = cmsCore::c('db')->get_field('cms_menu', '1=1 ORDER BY ordering DESC', 'ordering') + 1;
        $name = cmsCore::request('name', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $position = cmsCore::request('position', 'str', '');
        $showtitle = cmsCore::request('showtitle', 'int', 0);
        $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', ''));
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        $template = cmsCore::request('template', 'str', '');
        $cache = cmsCore::request('cache', 'int', 0);
        $cachetime = cmsCore::request('cachetime', 'int', 0);
        $cacheint = cmsCore::request('cacheint', 'str', '');
        $operate = cmsCore::request('operate', array('user', 'clone'), '');
        $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
        $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);
        if ($operate == 'user') {
            //USER MODULE
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden)\r\n                            VALUES ('" . $position . "', '" . $name . "', '" . $title . "', '" . $titles . "', 0, '" . $content . "', '" . $maxorder . "', '" . $showtitle . "', '" . $published . "', 1, 1, '" . $css_prefix . "', '" . $access_list . "', '" . $template . "', '" . $is_strict_bind . "', '" . $is_strict_bind_hidden . "')";
            cmsCore::c('db')->query($sql);
        }
        if ($operate == 'clone') {
            //DUPLICATE MODULE
            $mod_id = cmsCore::request('clone_id', 'int', 0);
            $sql = "SELECT * FROM cms_modules WHERE id = " . $mod_id . " LIMIT 1";
            $result = cmsCore::c('db')->query($sql);
            $original = cmsCore::c('db')->escape_string(cmsCore::c('db')->fetch_assoc($result));
            $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0;
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, original, user, config, css_prefix, template, access_list, is_strict_bind, is_strict_bind_hidden, cache, cachetime, cacheint, version)\r\n                        VALUES (\r\n                            '" . $position . "',\r\n                            '" . $original['name'] . "',\r\n                            '" . $title . "',\r\n                            '" . $titles . "',\r\n                            '" . $original['is_external'] . "',\r\n                            '" . $original['content'] . "',\r\n                            '" . $maxorder . "',\r\n                            '" . $showtitle . "',\r\n                            '" . $published . "',\r\n                            '" . $is_original . "',\r\n                            '" . $original['user'] . "',\r\n                            '" . $original['config'] . "',\r\n                            '" . $css_prefix . "',\r\n                            '" . $template . "',\r\n                            '" . $access_list . "',\r\n                            '" . $is_strict_bind . "',\r\n                            '" . $is_strict_bind_hidden . "',\r\n                            '" . $cache . "', \r\n                            '" . $cachetime . "',\r\n                            '" . $cacheint . "',\r\n                            '" . $original['version'] . "'\r\n                )";
            cmsCore::c('db')->query($sql);
            if (cmsCore::request('del_orig', 'int', 0)) {
                $sql = "DELETE FROM cms_modules WHERE id = " . $mod_id;
                cmsCore::c('db')->query($sql);
            }
        }
        $lastid = cmsCore::c('db')->get_last_id('cms_modules');
        if (cmsCore::request('show_all', 'int', 0)) {
            $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl)\r\n                            VALUES (" . $lastid . ", 0, '" . $position . "', '" . cmsCore::c('config')->template . "')";
            cmsCore::c('db')->query($sql);
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if ($hidden_menu_ids) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='" . $hidden_menu_ids . "' WHERE id = '" . $lastid . "' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array', array());
            $showpos = cmsCore::request('showpos', 'array', array());
            if (count($showin) > 0) {
                foreach ($showin as $key => $value) {
                    $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl)\r\n                                    VALUES (" . $lastid . ", " . $value . ", '" . $showpos[$value] . "', '" . cmsCore::c('config')->template . "')";
                    cmsCore::c('db')->query($sql);
                }
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }
    if ($do == 'add' || $do == 'edit') {
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MODULE_ADD']);
            echo '<h3>' . $_LANG['AD_MODULE_ADD'] . '</h3>';
            $show_all = false;
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = cmsCore::c('db')->get_fields('cms_modules', "id = '" . $item_id . "'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']);
            $mod['titles'] = cmsCore::yamlToArray($mod['titles']);
            $show_all = false;
            $default_position = cmsCore::c('db')->get_field('cms_modules_bind', "module_id='" . $mod['id'] . "' AND menu_id=0 AND tpl='" . cmsCore::c('config')->template . "'", 'position');
            if (!empty($default_position)) {
                $show_all = true;
                $mod['position'] = $default_position;
            }
            echo '<h3>' . $_LANG['AD_EDIT_MODULE'] . $ostatok . '</h3>';
            cpAddPathway($mod['name']);
        }
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        if (cmsCore::getArrVal($mod, 'is_external')) {
            $php_file = 'modules/' . $mod['content'] . '/backend.php';
            $xml_file = 'modules/' . $mod['content'] . '/backend.xml';
            if (file_exists($php_file) || file_exists($xml_file)) {
                $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id=' . $mod['id']);
            }
        }
        cpToolMenu($toolmenu);
        $bind = array();
        $bind_pos = array();
        $cache = 0;
        if ($do == 'edit') {
            $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = " . $mod['id'] . " AND tpl = '" . cmsCore::c('config')->template . "'";
            $bind_res = cmsCore::c('db')->query($bind_sql);
            while ($r = cmsCore::c('db')->fetch_assoc($bind_res)) {
                $bind[] = $r['menu_id'];
                $bind_pos[$r['menu_id']] = $r['position'];
            }
            $cache = cmsCore::c('cache')->get('modules', $mod['id'], $mod['content'], array(cmsCore::getArrVal($mod, 'cachetime', 1), cmsCore::getArrVal($mod, 'cacheint', 'MINUTES')));
        }
        $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering";
        $menu_res = cmsCore::c('db')->query($menu_sql);
        $menu_items = array();
        if (cmsCore::c('db')->num_rows($menu_res)) {
            while ($item = cmsCore::c('db')->fetch_assoc($menu_res)) {
                if ($do == 'edit') {
                    if (in_array($item['id'], $bind)) {
                        $item['selected'] = true;
                        $item['position'] = $bind_pos[$item['id']];
                    }
                }
                $item['titles'] = cmsCore::yamlToArray($item['titles']);
                // переопределяем название пункта меню в зависимости от языка
                if (!empty($item['titles'][cmsCore::c('config')->lang])) {
                    $item['title'] = $item['titles'][cmsCore::c('config')->lang];
                }
                $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']);
                $menu_items[] = $item;
            }
        }
        cmsCore::c('page')->initTemplate('applets', 'modules_add')->assign('do', $do)->assign('langs', cmsCore::getDirsList('/languages'))->assign('pos', cpModulePositions(cmsCore::c('config')->template))->assign('positions_img_exist', file_exists(PATH . '/templates/' . cmsCore::c('config')->template . '/positions.jpg'))->assign('tpls', cmsAdmin::getModuleTemplates())->assign('modules_opt', $inCore->getListItems('cms_modules'))->assign('show_all', $show_all)->assign('groups', cmsUser::getGroups())->assign('kb_cache', !empty($cache) ? round(mb_strlen($cache) / 1024, 2) : false)->assign('menu_items', $menu_items)->assign('access_list', !empty($mod['access_list']) ? $inCore->yamlToArray($mod['access_list']) : array())->assign('mod', $mod)->display();
    }
}
Ejemplo n.º 16
0
function applet_cron()
{
    cmsCore::loadClass('cron');
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_CRON_MISSION'];
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    cpAddPathway($_LANG['AD_CRON_MISSION'], 'index.php?view=cron');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', '0');
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_CREATE_CRON_MISSION'], 'link' => '?view=cron&do=add'));
        cpToolMenu($toolmenu);
        $items = cmsCron::getJobs(false);
        $tpl_file = 'admin/cron.php';
        $tpl_dir = file_exists(TEMPLATE_DIR . $tpl_file) ? TEMPLATE_DIR : DEFAULT_TEMPLATE_DIR;
        include $tpl_dir . $tpl_file;
    }
    if ($do == 'show') {
        if ($id) {
            cmsCron::jobEnabled($id, true);
        }
        echo '1';
        exit;
    }
    if ($do == 'hide') {
        if ($id) {
            cmsCron::jobEnabled($id, false);
        }
        echo '1';
        exit;
    }
    if ($do == 'delete') {
        if ($id) {
            cmsCron::removeJobById($id);
        }
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'execute') {
        if ($id) {
            $job_result = cmsCron::executeJobById($id);
        }
        if ($job_result) {
            cmsCore::addSessionMessage($_LANG['AD_MISSION_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_MISSION_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $job_name = cmsCore::request('job_name', 'str');
        $comment = cmsCore::request('comment', 'str');
        $job_interval = cmsCore::request('job_interval', 'int');
        $enabled = cmsCore::request('enabled', 'int');
        $component = cmsCore::request('component', 'str');
        $model_method = cmsCore::request('model_method', 'str');
        $custom_file = cmsCore::request('custom_file', 'str');
        $custom_file = mb_stripos($custom_file, 'image/') || mb_stripos($custom_file, 'upload/') || mb_stripos($custom_file, 'cache/') ? '' : $custom_file;
        $custom_file = preg_replace('/\\.+\\//', '', $custom_file);
        $class_name = cmsCore::request('class_name', 'str');
        $class_method = cmsCore::request('class_method', 'str');
        cmsCron::registerJob($job_name, array('interval' => $job_interval, 'component' => $component, 'model_method' => $model_method, 'comment' => $comment, 'custom_file' => $custom_file, 'enabled' => $enabled, 'class_name' => $class_name, 'class_method' => $class_method));
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        if (!$id) {
            cmsCore::halt();
        }
        $job_name = cmsCore::request('job_name', 'str');
        $comment = cmsCore::request('comment', 'str');
        $job_interval = cmsCore::request('job_interval', 'int');
        $enabled = cmsCore::request('enabled', 'int');
        $component = cmsCore::request('component', 'str');
        $model_method = cmsCore::request('model_method', 'str');
        $custom_file = cmsCore::request('custom_file', 'str');
        $custom_file = mb_stripos($custom_file, 'image/') || mb_stripos($custom_file, 'upload/') || mb_stripos($custom_file, 'cache/') ? '' : $custom_file;
        $custom_file = preg_replace('/\\.+\\//', '', $custom_file);
        $class_name = cmsCore::request('class_name', 'str');
        $class_method = cmsCore::request('class_method', 'str');
        cmsCron::updateJob($id, array('job_name' => $job_name, 'job_interval' => $job_interval, 'component' => $component, 'model_method' => $model_method, 'comment' => $comment, 'custom_file' => $custom_file, 'is_enabled' => $enabled, 'class_name' => $class_name, 'class_method' => $class_method));
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'edit' || $do == 'add') {
        $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'));
        cpToolMenu($toolmenu);
        if ($do == 'edit') {
            $mod = cmsCron::getJobById($id);
            echo '<h3>' . $_LANG['AD_EDIT_MISSION'] . '</h3>';
            cpAddPathway($mod['job_name'], 'index.php?view=cron&do=edit&id=' . $mod['id']);
        } else {
            echo '<h3>' . $_LANG['AD_CREATE_CRON_MISSION'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_CRON_MISSION'], 'index.php?view=cron&do=add');
        }
        ?>

    <form action="index.php?view=cron" method="post" enctype="multipart/form-data" name="addform" id="addform">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <table width="750" border="0" cellpadding="0" cellspacing="10" class="proptable">
            <tr>
                <td width="300" valign="middle">
                    <strong><?php 
        echo $_LANG['TITLE'];
        ?>
:</strong><br/>
                    <span class="hinttext"><?php 
        echo $_LANG['AD_ONLY_LATIN'];
        ?>
</span>
                </td>
                <td width="" valign="middle">
                    <input name="job_name" type="text" style="width:220px" value="<?php 
        echo @$mod['job_name'];
        ?>
" />
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['DESCRIPTION'];
        ?>
: </strong><br/>
                    <span class="hinttext"><?php 
        echo $_LANG['AD_ONLY_200_SIMBOLS'];
        ?>
</span>
                </td>
                <td valign="middle">
                    <input name="comment" type="text" maxlength="200" style="width:400px" value="<?php 
        echo htmlspecialchars($mod['comment']);
        ?>
" />
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['AD_MISSION_ON'];
        ?>
 </strong><br/>
                    <span class="hinttext"><?php 
        echo $_LANG['AD_MISSION_OFF'];
        ?>
</span>
                </td>
                <td valign="middle">
                    <label>
                        <input name="enabled" type="radio" value="1" <?php 
        if ($mod['is_enabled']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['YES'];
        ?>
                    </label>
                    <label>
                        <input name="enabled" type="radio" value="0"  <?php 
        if (!$mod['is_enabled']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['NO'];
        ?>
                    </label>
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['AD_MISSION_INTERVAL'];
        ?>
:</strong><br/>
                    <span class="hinttext"><?php 
        echo $_LANG['AD_MISSION_PERIOD'];
        ?>
</span>
                </td>
                <td valign="middle">
                    <input name="job_interval" type="text" maxlength="4" style="width:50px" value="<?php 
        echo @$mod['job_interval'];
        ?>
" /> <?php 
        echo $_LANG['HOUR1'] . '.';
        ?>
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['AD_PHP_FILE'];
        ?>
 </strong><br/>
                    <span class="hinttext"><?php 
        echo $_LANG['AD_EXAMPLE'];
        ?>
: <strong>includes/myphp/test.php</strong></span><br/>
                </td>
                <td valign="middle">
                    <input name="custom_file" type="text" maxlength="250" style="width:220px" value="<?php 
        echo @$mod['custom_file'];
        ?>
" />
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['AD_COMPONENT'];
        ?>
: </strong><br/>
                </td>
                <td valign="middle">
                    <input name="component" type="text" maxlength="250" style="width:220px" value="<?php 
        echo @$mod['component'];
        ?>
" />
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['AD_METHOD'];
        ?>
 </strong><br/>
                </td>
                <td valign="middle">
                    <input name="model_method" type="text" maxlength="250" style="width:220px" value="<?php 
        echo @$mod['model_method'];
        ?>
" />
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo icms_ucfirst($_LANG['AD_CLASS']);
        ?>
</strong><br/>
                    <span class="hinttext">
                        <span style="color:#666;font-family: mono"><?php 
        echo $_LANG['AD_FILE_CLASS'];
        ?>
</span>, <?php 
        echo $_LANG['AD_EXAMPLE'];
        ?>
 <strong>actions|cmsActions</strong>&nbsp;<?php 
        echo $_LANG['OR'];
        ?>
<br/>
                        <span style="color:#666;font-family: mono"><?php 
        echo $_LANG['AD_CLASS'];
        ?>
</span>, <?php 
        echo $_LANG['AD_EXAMPLE'];
        ?>
 <strong>cmsDatabase</strong>
                    </span>
                </td>
                <td valign="top">
                    <input name="class_name" type="text" maxlength="50" style="width:220px" value="<?php 
        echo @$mod['class_name'];
        ?>
" />
                </td>
            </tr>
            <tr>
                <td width="" valign="middle">
                    <strong><?php 
        echo $_LANG['AD_CLASS_METHOD'];
        ?>
 </strong><br/>
                </td>
                <td valign="middle">
                    <input name="class_method" type="text" maxlength="50" style="width:220px" value="<?php 
        echo @$mod['class_method'];
        ?>
" />
                </td>
            </tr>
        </table>
        <p>
		  <?php 
        if ($do == 'edit') {
            ?>
	          <input name="do" type="hidden" id="do" value="update" />
	          <input name="add_mod" type="submit" id="add_mod" value="<?php 
            echo $_LANG['AD_SAVE_CRON_MISSION'];
            ?>
" />
		  <?php 
        } else {
            ?>
	          <input name="do" type="hidden" id="do" value="submit" />
	          <input name="add_mod" type="submit" id="add_mod" value="<?php 
            echo $_LANG['AD_CREATE_CRON_MISSION'];
            ?>
" />
		  <?php 
        }
        ?>
          <span style="margin-top:15px">
          <input name="back2" type="button" id="back2" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();" />
          </span>
        <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
      </form>
	<?php 
    }
}
Ejemplo n.º 17
0
function applet_modules()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_MODULES'];
    cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules');
    $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/modules.js"></script>';
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $co = cmsCore::request('co', 'int', -1);
    //============================================================================//
    //============================================================================//
    if ($do == 'config') {
        $module_name = cpModuleById($id);
        $module_title = cpModuleTitleById($id);
        if (!$module_name) {
            cmsCore::redirect('index.php?view=modules&do=edit&id=' . $id);
        }
        $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml';
        $php_file = 'modules/' . $module_name . '/backend.php';
        if (!file_exists($xml_file)) {
            if (file_exists($php_file)) {
                include $php_file;
                return;
            }
            cmsCore::halt();
        }
        $cfg = $inCore->loadModuleConfig($id);
        cmsCore::loadClass('formgen');
        $formGen = new cmsFormGen($xml_file, $cfg);
        cpAddPathway($module_title, '?view=modules&do=edit&id=' . $id);
        cpAddPathway($_LANG['AD_SETTINGS']);
        echo '<h3>' . $module_title . '</h3>';
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id=' . $id);
        cpToolMenu($toolmenu);
        echo '<form action="index.php?view=modules&do=save_auto_config&id=' . $id . '" method="post" name="optform" target="_self" id="optform">';
        echo $formGen->getHTML();
        echo '</form>';
        return;
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'save_auto_config') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $module_name = cpModuleById($id);
        $is_ajax = cmsCore::inRequest('ajax');
        if ($is_ajax) {
            $title = cmsCore::request('title', 'str', '');
            $published = cmsCore::request('published', 'int', 0);
            $inDB->query("UPDATE cms_modules SET title='{$title}', published='{$published}' WHERE id={$id}");
            if (cmsCore::inRequest('content')) {
                $content = $inDB->escape_string(cmsCore::request('content', 'html'));
                $inDB->query("UPDATE cms_modules SET content='{$content}' WHERE id={$id}");
            }
            // Добавим возможность изменять css_префикс с фронта
            if (cmsCore::inRequest('css_prefix')) {
                // На шаблонах не не отдающих параметра затирать класс не будем
                $css_prefix = cmsCore::request('css_prefix', 'str', '');
                $inDB->query("UPDATE cms_modules SET css_prefix='{$css_prefix}' WHERE id='{$id}'");
            }
        }
        if (cmsCore::inRequest('title_only')) {
            cmsCore::redirectBack();
        }
        $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml';
        if (!file_exists($xml_file)) {
            cmsCore::halt();
        }
        $cfg = array();
        $backend = simplexml_load_file($xml_file);
        foreach ($backend->params->param as $param) {
            $name = (string) $param['name'];
            $type = (string) $param['type'];
            $default = (string) $param['default'];
            switch ($param['type']) {
                case 'number':
                    $value = cmsCore::request($name, 'int', $default);
                    break;
                case 'string':
                    $value = cmsCore::request($name, 'str', $default);
                    break;
                case 'html':
                    $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default));
                    break;
                case 'flag':
                    $value = cmsCore::request($name, 'int', 0);
                    break;
                case 'list':
                    $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                    break;
                case 'list_function':
                    $value = cmsCore::request($name, 'str', $default);
                    break;
                case 'list_db':
                    $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                    break;
            }
            $cfg[$name] = $value;
        }
        $inCore->saveModuleConfig($id, $cfg);
        if (!$is_ajax) {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        }
        cmsCore::redirectBack();
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add');
        $toolmenu[] = array('icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');");
        $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');");
        $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');");
        $toolmenu[] = array('icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder');
        $toolmenu[] = array('icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');");
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules');
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['AD_TITLE'], 'field' => array('title', 'titles'), 'width' => '', 'link' => '?view=modules&do=edit&id=%id%', 'prc' => function ($i) {
            $i['titles'] = cmsCore::yamlToArray($i['titles']);
            // переопределяем название пункта меню в зависимости от языка
            if (!empty($i['titles'][cmsConfig::getConfig('lang')])) {
                $i['title'] = $i['titles'][cmsConfig::getConfig('lang')];
            }
            return $i['title'];
        });
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15');
        $fields[] = array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '55');
        $fields[] = array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110');
        $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '65');
        $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '75');
        $fields[] = array('title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('positions'));
        $actions[] = array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%');
        cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'autoorder') {
        $rs = $inDB->query("SELECT id, position FROM cms_modules ORDER BY position");
        if ($inDB->num_rows($rs)) {
            $ord = 1;
            while ($item = $inDB->fetch_assoc($rs)) {
                if (isset($latest_pos)) {
                    if ($latest_pos != $item['position']) {
                        $ord = 1;
                    }
                }
                $inDB->query("UPDATE cms_modules SET ordering = {$ord} WHERE id='{$item['id']}'");
                $ord += 1;
                $latest_pos = $item['position'];
            }
        }
        cmsCore::redirect('index.php?view=modules');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'move_up') {
        if ($id >= 0) {
            dbMoveUp('cms_modules', $id, $co);
        }
        cmsCore::redirectBack();
    }
    if ($do == 'move_down') {
        if ($id >= 0) {
            dbMoveDown('cms_modules', $id, $co);
        }
        cmsCore::redirectBack();
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'saveorder') {
        if (isset($_REQUEST['ordering'])) {
            $ord = $_REQUEST['ordering'];
            $ids = $_REQUEST['ids'];
            foreach ($ord as $id => $ordering) {
                $inDB->query("UPDATE cms_modules SET ordering = '" . (int) $ordering . "' WHERE id = '" . (int) $ids[$id] . "'");
            }
            cmsCore::redirect('index.php?view=modules');
        }
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_modules', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_modules', cmsCore::request('item', 'array_int', array()));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_modules', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_modules', cmsCore::request('item', 'array_int', array()));
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            $inCore->removeModule($id);
        } else {
            $inCore->removeModule(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $id = cmsCore::request('id', 'int', 0);
        $name = cmsCore::request('name', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $position = cmsCore::request('position', 'str', '');
        $showtitle = cmsCore::request('showtitle', 'int', 0);
        $content = $inDB->escape_string(cmsCore::request('content', 'html', ''));
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
        $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        $template = cmsCore::request('template', 'str', '');
        $cache = cmsCore::request('cache', 'int', 0);
        $cachetime = cmsCore::request('cachetime', 'int', 0);
        $cacheint = cmsCore::request('cacheint', 'str', '');
        $sql = "UPDATE cms_modules\r\n                SET name='{$name}',\r\n                    title='{$title}',\r\n                    titles='{$titles}',\r\n                    position='{$position}',\r\n                    template='{$template}',\r\n                    showtitle={$showtitle},";
        if ($content) {
            $sql .= "content='{$content}',";
        }
        $sql .= "\r\n                    published={$published},\r\n                    css_prefix='{$css_prefix}',\r\n                    access_list='{$access_list}',\r\n                    hidden_menu_ids='',\r\n                    cachetime = '{$cachetime}',\r\n                    cacheint = '{$cacheint}',\r\n                    cache = '{$cache}',\r\n                    is_strict_bind = '{$is_strict_bind}',\r\n                    is_strict_bind_hidden = '{$is_strict_bind_hidden}'\r\n                WHERE id = '{$id}'\r\n                LIMIT 1";
        $inDB->query($sql);
        $sql = "DELETE FROM cms_modules_bind WHERE module_id = {$id}";
        $inDB->query($sql);
        if (cmsCore::request('show_all', 'int', 0)) {
            $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n                    VALUES ({$id}, 0, '{$position}')";
            $inDB->query($sql);
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if ($hidden_menu_ids) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                $inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$id}' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array_int', array());
            $showpos = cmsCore::request('showpos', 'array_str', array());
            if ($showin) {
                foreach ($showin as $key => $value) {
                    $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n                            VALUES ({$id}, {$value}, '{$showpos[$value]}')";
                    $inDB->query($sql);
                }
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('index.php?view=modules');
        } else {
            cmsCore::redirect('index.php?view=modules&do=edit');
        }
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $sql = "SELECT ordering as max_o FROM cms_menu ORDER BY ordering DESC LIMIT 1";
        $result = $inDB->query($sql);
        $row = $inDB->fetch_assoc($result);
        $maxorder = $row['max_o'] + 1;
        $name = cmsCore::request('name', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $position = cmsCore::request('position', 'str', '');
        $showtitle = cmsCore::request('showtitle', 'int', 0);
        $content = $inDB->escape_string(cmsCore::request('content', 'html', ''));
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        $template = cmsCore::request('template', 'str', '');
        $cache = cmsCore::request('cache', 'int', 0);
        $cachetime = cmsCore::request('cachetime', 'int', 0);
        $cacheint = cmsCore::request('cacheint', 'str', '');
        $operate = cmsCore::request('operate', 'str', '');
        $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
        $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);
        if ($operate == 'user') {
            //USER MODULE
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden)\r\n\t\t\t\t\tVALUES ('{$position}', '{$name}', '{$title}', '{$titles}', 0, '{$content}', '{$maxorder}', '{$showtitle}', '{$published}', 1, 1, '{$css_prefix}', '{$access_list}', '{$template}', '{$is_strict_bind}', '{$is_strict_bind_hidden}')";
            $inDB->query($sql);
        }
        if ($operate == 'clone') {
            //DUPLICATE MODULE
            $mod_id = cmsCore::request('clone_id', 'int', 0);
            $sql = "SELECT * FROM cms_modules WHERE id = {$mod_id} LIMIT 1";
            $result = $inDB->query($sql);
            $original = $inDB->escape_string($inDB->fetch_assoc($result));
            $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0;
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external,\r\n                                             content, ordering, showtitle, published,\r\n                                             original, user, config, css_prefix, template,\r\n                                             access_list, is_strict_bind, is_strict_bind_hidden,\r\n                                             cache, cachetime, cacheint, version)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t\t'{$position}',\r\n\t\t\t\t\t\t\t'{$original['name']}',\r\n\t\t\t\t\t\t\t'{$title}',\r\n\t\t\t\t\t\t\t'{$titles}',\r\n\t\t\t\t\t\t\t'{$original['is_external']}',\r\n\t\t\t\t\t\t\t'{$original['content']}',\r\n\t\t\t\t\t\t\t'{$maxorder}',\r\n\t\t\t\t\t\t\t'{$showtitle}',\r\n\t\t\t\t\t\t\t'{$published}',\r\n\t\t\t\t\t\t\t'{$is_original}',\r\n\t\t\t\t\t\t\t'{$original['user']}',\r\n\t\t\t\t\t\t\t'{$original['config']}',\r\n\t\t\t\t\t\t\t'{$css_prefix}',\r\n                            '{$template}',\r\n                            '{$access_list}',\r\n                            '{$is_strict_bind}',\r\n                            '{$is_strict_bind_hidden}',\r\n                            '{$cache}', '{$cachetime}', '{$cacheint}', '{$original['version']}'\r\n                            )";
            $inDB->query($sql);
            if ($is_original) {
                $sql = "DELETE FROM cms_modules WHERE id = {$mod_id}";
                $inDB->query($sql);
            }
        }
        $lastid = $inDB->get_last_id('cms_modules');
        if (cmsCore::request('show_all', 'int', 0)) {
            $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n\t\t\t\t\tVALUES ({$lastid}, 0, '{$position}')";
            $inDB->query($sql);
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if ($hidden_menu_ids) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                $inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$lastid}' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array_int', array());
            $showpos = cmsCore::request('showpos', 'array_str', array());
            if ($showin) {
                foreach ($showin as $key => $value) {
                    $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n\t\t\t\t\t\t\tVALUES ({$lastid}, {$value}, '{$showpos[$value]}')";
                    $inDB->query($sql);
                }
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }
    //============================================================================//
    //============================================================================//
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $langs = cmsCore::getDirsList('/languages');
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MODULE_ADD']);
            echo '<h3>' . $_LANG['AD_MODULE_ADD'] . '</h3>';
            $show_all = false;
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_modules', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']);
            $mod['titles'] = cmsCore::yamlToArray($mod['titles']);
            $sql = "SELECT id FROM cms_modules_bind WHERE module_id = {$id} AND menu_id = 0 LIMIT 1";
            $result = $inDB->query($sql);
            if ($inDB->num_rows($result)) {
                $show_all = true;
            } else {
                $show_all = false;
            }
            echo '<h3>' . $_LANG['AD_EDIT_MODULE'] . $ostatok . '</h3>';
            cpAddPathway($mod['name']);
        }
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        if (@$mod['is_external']) {
            $php_file = 'modules/' . $mod['content'] . '/backend.php';
            $xml_file = 'modules/' . $mod['content'] . '/backend.xml';
            if (file_exists($php_file) || file_exists($xml_file)) {
                $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id=' . $mod['id']);
            }
        }
        cpToolMenu($toolmenu);
        ?>
    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="modules" />

        <table class="proptable" width="100%" cellpadding="15" cellspacing="2">
            <tr>

                <!-- главная ячейка -->
                <td valign="top">

                    <div><strong><?php 
        echo $_LANG['AD_MODULE_TITLE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_VIEW_IN_SITE'];
        ?>
</span></div>
                    <div>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></td>
                                <td style="width:15px;padding-left:10px;padding-right:0px;">
                                    <input type="checkbox" title="<?php 
        echo $_LANG['AD_VIEW_TITLE'];
        ?>
" name="showtitle" <?php 
        if ($mod['showtitle'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
 value="1">
                                </td>
                            </tr>
                        </table>
                    </div>
                    <?php 
        if (count($langs) > 1) {
            ?>
                    <div><strong><?php 
            echo $_LANG['AD_LANG_TITLES'];
            ?>
</strong> <span class="hinttext">&mdash; <?php 
            echo $_LANG['AD_LANG_TITLES_HINT'];
            ?>
</span></div>
                    <?php 
            foreach ($langs as $lang) {
                ?>

                    <div><strong><?php 
                echo $lang;
                ?>
:</strong> <input name="titles[<?php 
                echo $lang;
                ?>
]" type="text" style="width:97%" value="<?php 
                echo htmlspecialchars(@$mod['titles'][$lang]);
                ?>
" placeholder="<?php 
                echo $_LANG['AD_HINT_DEFAULT'];
                ?>
" /></div>
                    <?php 
            }
            ?>
                    <?php 
        }
        ?>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:10px;">
                        <tr>
                            <td valign="top">
                                <div>
                                    <strong><?php 
        echo $_LANG['AD_MODULE_NAME'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_SHOW_ADMIN'];
        ?>
</span>
                                </div>
                                <div>
                                    <?php 
        if (!isset($mod['user']) || @$mod['user'] == 1) {
            ?>
                                        <input name="name" type="text" id="name" style="width:99%" value="<?php 
            echo htmlspecialchars($mod['name']);
            ?>
" />
                                    <?php 
        } else {
            ?>
                                        <input name="" type="text" id="name" style="width:99%" value="<?php 
            echo @$mod['name'];
            ?>
" disabled="disabled" />
                                        <input name="name" type="hidden" value="<?php 
            echo htmlspecialchars($mod['name']);
            ?>
" />
                                    <?php 
        }
        ?>
                                </div>
                            </td>
                            <td valign="top" width="160" style="padding-left:10px;">
                                <div>
                                    <strong><?php 
        echo $_LANG['AD_PREFIX_CSS'];
        ?>
</strong>
                                </div>
                                <div>
                                    <input name="css_prefix" type="text" id="css_prefix" value="<?php 
        echo @$mod['css_prefix'];
        ?>
" style="width:154px" />
                                </div>
                            </td>
                        </tr>
                    </table>

                    <div style="margin-top:8px">
                        <strong><?php 
        echo $_LANG['AD_DEFOLT_VIEW'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_POSITION_MUST_BE'];
        ?>
</span>
                    </div>
                    <div>
                        <?php 
        $pos = cpModulePositions(cmsConfig::getConfig('template'));
        ?>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;">
                            <tr>
                                <td valign="top">
                                    <select name="position" id="position" style="width:100%">
                                        <?php 
        if ($pos) {
            foreach ($pos as $key => $position) {
                if (@$mod['position'] == $position) {
                    echo '<option value="' . $position . '" selected>' . $position . '</option>';
                } else {
                    echo '<option value="' . $position . '">' . $position . '</option>';
                }
            }
        }
        ?>
                                    </select>
                                </td>
                                <?php 
        if (file_exists(PATH . '/templates/' . TEMPLATE . '/positions.jpg')) {
            ?>
                                <td valign="top" width="160" style="padding-left:10px;">
                                    <script>
                                    $(function() {
                                        $('#pos').dialog({modal: true, autoOpen: false, closeText: LANG_CLOSE, width: 'auto'});
                                    });
                                    </script>
                                    <a onclick="$('#pos').dialog('open');return false;" href="#" class="ajaxlink"><?php 
            echo $_LANG['AD_SEE_VISUALLY'];
            ?>
</a>
                                    <div id="pos" title="<?php 
            echo $_LANG['AD_TPL_POS'];
            ?>
"><img src="/templates/<?php 
            echo TEMPLATE;
            ?>
/positions.jpg" alt="<?php 
            echo $_LANG['AD_TPL_POS'];
            ?>
" /></div>
                                </td>
                                <?php 
        }
        ?>
                            </tr>
                        </table>
                    </div>

                    <div style="margin-top:15px">
                        <strong><?php 
        echo $_LANG['AD_MODULE_TEMPLATE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_FOLDER_MODULES'];
        ?>
</span>
                    </div>
                    <div>
                        <?php 
        $tpls = cmsAdmin::getModuleTemplates();
        ?>
                        <select name="template" id="template" style="width:100%">
                            <?php 
        foreach ($tpls as $tpl) {
            $selected = $mod['template'] == $tpl || !$mod['template'] && $tpl == 'module.tpl' ? 'selected="selected"' : '';
            echo '<option value="' . $tpl . '" ' . $selected . '>' . $tpl . '</option>';
        }
        ?>
                        </select>
                    </div>

                    <?php 
        if ($do == 'add') {
            ?>
                    <div style="margin-top:15px">
                        <strong><?php 
            echo $_LANG['AD_MODULE_TYPE'];
            ?>
</strong>
                    </div>
                    <div>
                        <select name="operate" id="operate" onchange="checkDiv()" style="width:100%">
                            <option value="user" selected="selected"><?php 
            echo $_LANG['AD_MODULE_TYPE_NEW'];
            ?>
</option>
                            <option value="clone"><?php 
            echo $_LANG['AD_MODULE_TYPE_COPY'];
            ?>
</option>
                        </select>
                    </div>
                    <?php 
        }
        ?>

                    <?php 
        if (!isset($mod['user']) || $mod['user'] == 1 || $do == 'add') {
            ?>
                        <div id="user_div">
                            <div style="margin-top:15px">
                                <strong><?php 
            echo $_LANG['AD_MODULE_CONTENT'];
            ?>
</strong>
                            </div>
                            <div><?php 
            insertPanel();
            ?>
</div>
                            <div>
                                <?php 
            $inCore->insertEditor('content', $mod['content'], '250', '100%');
            ?>
                            </div>
                        </div>
                    <?php 
        }
        ?>

                <div id="clone_div" style="display:none;">
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_MODULE_COPY'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="clone_id" id="clone_id" style="width:100%">
                                <?php 
        echo $inCore->getListItems('cms_modules');
        ?>
                            </select>
                            <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:6px">
                                <tr>
                                    <td width="20"><input type="checkbox" name="del_orig" id="del_orig" value="1" /></td>
                                    <td><label for="del_orig"><?php 
        echo $_LANG['AD_ORIGINAL_MODULE_DELETE'];
        ?>
</label></td>
                                </tr>
                            </table>
                        </div>
                </div>

                </td>

                <!-- боковая ячейка -->
                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <tr>
                            <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                            <td><label for="published"><strong><?php 
        echo $_LANG['AD_MODULE_PUBLIC'];
        ?>
</strong></label></td>
                        </tr>
                        <tr>
                            <td width="20"><input name="show_all" id="show_all" type="checkbox" value="1" onclick="checkGroupList()" <?php 
        if ($show_all) {
            echo 'checked';
        }
        ?>
 /></td>
                            <td><label for="show_all"><strong><?php 
        echo $_LANG['AD_VIEW_ALL_PAGES'];
        ?>
</strong></label></td>
                        </tr>
                    </table>

                    <?php 
        if ($do == 'edit') {
            $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = " . $mod['id'];
            $bind_res = $inDB->query($bind_sql);
            $bind = array();
            $bind_pos = array();
            while ($r = $inDB->fetch_assoc($bind_res)) {
                $bind[] = $r['menu_id'];
                $bind_pos[$r['menu_id']] = $r['position'];
            }
        }
        $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering";
        $menu_res = $inDB->query($menu_sql);
        $menu_items = array();
        if ($inDB->num_rows($menu_res)) {
            while ($item = $inDB->fetch_assoc($menu_res)) {
                if ($do == 'edit') {
                    if (in_array($item['id'], $bind)) {
                        $item['selected'] = true;
                        $item['position'] = $bind_pos[$item['id']];
                    }
                }
                $item['titles'] = cmsCore::yamlToArray($item['titles']);
                // переопределяем название пункта меню в зависимости от языка
                if (!empty($item['titles'][cmsConfig::getConfig('lang')])) {
                    $item['title'] = $item['titles'][cmsConfig::getConfig('lang')];
                }
                $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']);
                $menu_items[] = $item;
            }
        }
        ?>

                    <div id="grp">

                        <div style="margin-top:13px">
                            <strong class="show_list"><?php 
        echo $_LANG['AD_WHERE_MODULE_VIEW'];
        ?>
</strong>
                            <strong class="hide_list"><?php 
        echo $_LANG['AD_WHERE_MODULE_NOT_VIEW'];
        ?>
</strong>
                        </div>

                        <div style="height:300px;overflow: auto;border: solid 1px #999; padding:5px 10px; background: #FFF;">
                        <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
                            <tr>
                                <td colspan="2" height="25"><strong><?php 
        echo $_LANG['AD_MENU'];
        ?>
</strong></td>
                                <td class="show_list" align="center" width="50"><strong><?php 
        echo $_LANG['AD_POSITION'];
        ?>
</strong></td>
                            </tr>
                            <?php 
        foreach ($menu_items as $i) {
            ?>
                            <tr class="show_list">
                                <td width="20" height="25">
                                    <input type="checkbox" name="showin[]" id="mid<?php 
            echo $i['id'];
            ?>
" value="<?php 
            echo $i['id'];
            ?>
" <?php 
            if ($i['selected']) {
                ?>
checked="checked"<?php 
            }
            ?>
 onclick="$('#p<?php 
            echo $i['id'];
            ?>
').toggle()"/>
                                </td>
                                <td style="padding-left:<?php 
            echo $i['NSLevel'] * 6 - 6;
            ?>
px"><label for="mid<?php 
            echo $i['id'];
            ?>
"><?php 
            echo $i['title'];
            ?>
</label></td>
                                <td align="center">
                                    <select id="p<?php 
            echo $i['id'];
            ?>
" name="showpos[<?php 
            echo $i['id'];
            ?>
]" style="<?php 
            if (!$i['selected']) {
                ?>
display:none<?php 
            }
            ?>
">
                                        <?php 
            foreach ($pos as $position) {
                ?>
                                            <option value="<?php 
                echo $position;
                ?>
" <?php 
                if ($i['position'] == $position) {
                    ?>
selected="selected"<?php 
                }
                ?>
><?php 
                echo $position;
                ?>
</option>
                                        <?php 
            }
            ?>
                                    </select>
                                </td>
                            </tr>
                            <?php 
        }
        ?>
                            <?php 
        foreach ($menu_items as $it) {
            ?>
                            <tr class="hide_list">
                                <td width="20" height="25">
                                    <input type="checkbox" name="hidden_menu_ids[]" id="hmid<?php 
            echo $it['id'];
            ?>
" value="<?php 
            echo $it['id'];
            ?>
" <?php 
            if (in_array($it['id'], $mod['hidden_menu_ids'])) {
                ?>
checked="checked"<?php 
            }
            ?>
 />
                                </td>
                                <td style="padding-left:<?php 
            echo $it['NSLevel'] * 6 - 6;
            ?>
px"><label for="hmid<?php 
            echo $it['id'];
            ?>
"><?php 
            echo $it['title'];
            ?>
</label></td>
                            </tr>
                            <?php 
        }
        ?>
                        </table>
                        </div>

                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist show_list">
                            <tr>
                                <td width="20"><input type="checkbox" name="is_strict_bind" id="is_strict_bind" value="1" <?php 
        if ($mod['is_strict_bind']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="is_strict_bind"><strong><?php 
        echo $_LANG['AD_DONT_VIEW'];
        ?>
</strong></label></td>
                            </tr>
                        </table>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist hide_list">
                            <tr>
                                <td width="20"><input type="checkbox" name="is_strict_bind_hidden" id="is_strict_bind_hidden" value="1" <?php 
        if ($mod['is_strict_bind_hidden']) {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="is_strict_bind_hidden"><strong><?php 
        echo $_LANG['AD_EXCEPT_NESTED'];
        ?>
</strong></label></td>
                            </tr>
                        </table>

                    </div>

					<?php 
        if ($mod['is_external'] && $do == 'edit' || $do == 'add') {
            ?>

                    {tab=<?php 
            echo $_LANG['AD_MODULE_CACHE'];
            ?>
}

                        <div style="margin-top:4px">
                            <strong><?php 
            echo $_LANG['AD_DO_MODULE_CACHE'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="cache" id="cache" style="width:100%">
                                <option value="0" <?php 
            if (@(!$mod['cache'])) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['NO'];
            ?>
</option>
                                <option value="1" <?php 
            if (@$mod['cache']) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['YES'];
            ?>
</option>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
            echo $_LANG['AD_MODULE_CACHE_PERIOD'];
            ?>
</strong>
                        </div>
                        <div>
                            <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;">
                                <tr>
                                    <td valign="top"  width="100">
                                        <input name="cachetime" type="text" id="int_1" style="width:99%" value="<?php 
            echo @(int) $mod['cachetime'];
            ?>
"/>
                                    </td>
                                    <td valign="top" style="padding-left:5px">
                                        <select name="cacheint" id="int_2" style="width:100%">
                                            <option value="MINUTE"  <?php 
            if (@mb_strstr($mod['cacheint'], 'MINUTE')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false);
            ?>
</option>
                                            <option value="HOUR"  <?php 
            if (@mb_strstr($mod['cacheint'], 'HOUR')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false);
            ?>
</option>
                                            <option value="DAY" <?php 
            if (@mb_strstr($mod['cacheint'], 'DAY')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false);
            ?>
</option>
                                            <option value="MONTH" <?php 
            if (@mb_strstr($mod['cacheint'], 'MONTH')) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false);
            ?>
</option>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                        </div>

                        <div style="margin-top:15px">
                            <?php 
            if ($do == 'edit') {
                if ($inCore->isCached('module', $mod['id'], $mod['cachetime'], $mod['cacheint'])) {
                    $t = 'module' . $mod['id'];
                    $cfile = PATH . '/cache/' . md5($t) . '.html';
                    if (file_exists($cfile)) {
                        $kb = round(filesize($cfile) / 1024, 2);
                        echo '<a href="index.php?view=cache&do=delcache&target=module&id=' . $mod['id'] . '">' . $_LANG['AD_MODULE_CACHE_DELETE'] . '</a> (' . $kb . $_LANG['SIZE_KB'] . ')';
                    }
                } else {
                    echo '<span style="color:gray">' . $_LANG['AD_NO_CACHE'] . '</span>';
                }
            }
            ?>
                        </div>
					<?php 
        }
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_IF_CHECKED'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit' && $mod['access_list']) {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>

                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>
        <p>
            <input name="add_mod" type="submit" id="add_mod" value="<?php 
        echo $_LANG['SAVE'];
        ?>
" />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();" />
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
    </form>
<?php 
    }
    //============================================================================//
    //============================================================================//
}
Ejemplo n.º 18
0
function applet_modules() {
    $inCore = cmsCore::getInstance();

    global $_LANG;

    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_MODULES']);
    cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules');
    cmsCore::c('page')->addHeadJS('admin/js/modules.js');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $co = cmsCore::request('co', 'int', -1);

    if ($do == 'config') {
        $module_name  = cpModuleById($id);
        $module_title = cpModuleTitleById($id);

        if (!$module_name) { cmsCore::redirect('index.php?view=modules&do=edit&id='. $id); }

        $xml_file = PATH .'/admin/modules/'. $module_name .'/backend.xml';
        $php_file = 'modules/'. $module_name .'/backend.php';
        
        if (file_exists($php_file)) {
            include $php_file;
            return;
        }
        
        $cfg = $inCore->loadModuleConfig($id);
        
        cpAddPathway($module_title, '?view=modules&do=edit&id='. $id);
        cpAddPathway($_LANG['AD_SETTINGS']);

        echo '<h3>'. $module_title .'</h3>';
        
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules' ),
            array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id='. $id )
        );

        cpToolMenu($toolmenu);
?>
        <form action="index.php?view=modules&do=save_auto_config&id=<?php echo $id; ?>" method="post" name="optform" target="_self" id="optform">
            <div class="panel panel-default" style="width:650px;">
                <div class="panel-body">
<?php
        if (file_exists($xml_file)) {
            cmsCore::loadClass('formgen');
            $formGen = new cmsFormGen($xml_file, $cfg);
            echo $formGen->getHTML();
        } else {
?>
                    <div class="form-group">
                        <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MODULE_TEMPLATE']; ?></label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" value="<?php echo $cfg['tpl']; ?>" />
                        </div>
                    </div>
<?php
        }
?>
                </div>
                <div class="panel-footer">
                    <input type="submit" name="save" class="btn btn-primary" value="<?php echo $_LANG['SAVE']; ?>" />
                </div>
            </div>
        <script type="text/javascript">
            function submitModuleConfig(){
                $('#optform').submit();
            }
        </script>
        </form>
<?php

        return;
    }

    if ($do == 'save_auto_config') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $module_name = cpModuleById($id);

        $is_ajax = cmsCore::inRequest('ajax');

        if ($is_ajax) {
            $title      = cmsCore::request('title', 'str', '');
            $published  = cmsCore::request('published', 'int', 0);
            cmsCore::c('db')->query("UPDATE cms_modules SET title='". $title ."', published='". $published ."' WHERE id=". $id);
            if (cmsCore::inRequest('content')) {
                $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html'));
                cmsCore::c('db')->query("UPDATE cms_modules SET content='". $content ."' WHERE id=". $id);
            }
        }

        if (cmsCore::inRequest('title_only')) { cmsCore::redirectBack(); }

        $xml_file = PATH .'/admin/modules/'. $module_name .'/backend.xml';
        if (file_exists($xml_file)) {
            $cfg = array();

            $backend = simplexml_load_file($xml_file);

            foreach ($backend->params->param as $param) {
                $name    = (string)$param['name'];
                $type    = (string)$param['type'];
                $default = (string)$param['default'];

                switch($param['type']) {
                    case 'number': $value = cmsCore::request($name, 'int', $default); break;
                    case 'string': $value = cmsCore::request($name, 'str', $default); break;
                    case 'html':   $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default)); break;
                    case 'flag': $value = cmsCore::request($name, 'int', 0); break;
                    case 'list': $value = (is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default)); break;
                    case 'list_function': $value = cmsCore::request($name, 'str', $default); break;
                    case 'list_db': $value = (is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default)); break;
                }

                $cfg[$name] = $value;
            }
        }
        
        $cfg['tpl'] = cmsCore::request('tpl', 'str', $module_name);

        $inCore->saveModuleConfig($id, $cfg);

        if (!$is_ajax) {
            cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        }

        cmsCore::redirectBack();
    }

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add' ),
            array( 'icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module' ),
            array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');" ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');" ),
            array( 'icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');" ),
            array( 'icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');" ),
            array( 'icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder' ),
            array( 'icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');" ),
            array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules' )
        );

        cpToolMenu($toolmenu);
        
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array(
                'title' => $_LANG['AD_TITLE'],
                'field' => array('title','titles'), 'width'=>'',
                'link'  => '?view=modules&do=edit&id=%id%',
                'prc'   => function ($i) {
                    $i['titles'] = cmsCore::yamlToArray($i['titles']);
                    // переопределяем название пункта меню в зависимости от языка
                    if (!empty($i['titles'][cmsConfig::getConfig('lang')])) {
                        $i['title'] = $i['titles'][cmsConfig::getConfig('lang')];
                    }
                    
                    return $i['title'];
                }
            ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15' ),
            array( 'title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '70' ),
            array( 'title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110' ),
            array( 'title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80' ),
            array( 'title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100' ),
            array( 'title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('positions') )
        );
        
        $actions = array(
            array( 'title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig' ),
            array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%' )
        );
        
        cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC');
    }

    if ($do == 'autoorder'){
        $rs = cmsCore::c('db')->query("SELECT id, position FROM cms_modules ORDER BY position") ;

        if (cmsCore::c('db')->num_rows($rs)) {
            $ord = 1;
            while ($item = cmsCore::c('db')->fetch_assoc($rs)) {
                if (isset($latest_pos)) {
                    if ($latest_pos != $item['position']) {
                        $ord = 1;
                    }
                }
                cmsCore::c('db')->query("UPDATE cms_modules SET ordering = ". $ord ." WHERE id=". $item['id']) ;
                $ord += 1;
                $latest_pos = $item['position'];
            }
        }

        cmsCore::redirect('index.php?view=modules');
    }

    if ($do == 'move_up') {
        if ($id >= 0) { dbMoveUp('cms_modules', $id, $co); }
        cmsCore::redirectBack();
    }

    if ($do == 'move_down') {
        if ($id >= 0) { dbMoveDown('cms_modules', $id, $co); }
        cmsCore::redirectBack();
    }

    if ($do == 'saveorder') {
        if (isset($_REQUEST['ordering'])) {
            $ord = $_REQUEST['ordering'];
            $ids = $_REQUEST['ids'];

            foreach ($ord as $id=>$ordering) {
                cmsCore::c('db')->query("UPDATE cms_modules SET ordering = ". (int)$ordering ." WHERE id = ". (int)$ids[$id]);
            }
            cmsCore::redirect('index.php?view=modules');
        }
    }

    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '1'); }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '1');
            cmsCore::redirectBack();
        }

    }

    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '0'); }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '0');
            cmsCore::redirectBack();
        }
    }

    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            $inCore->removeModule($id);
        } else {
            $inCore->removeModule(cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=modules');
    }

    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $id = cmsCore::request('id', 'int', 0);
        $mod = cmsCore::c('db')->get_fields('cms_modules', "id = ". $id ."", '*');
        
        $module = array(
            'name'       => cmsCore::request('name', 'str', ''),
            'title'      => cmsCore::request('title', 'str', ''),
            'titles'     => cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())),
            'position'   => cmsCore::request('position', 'str', ''),
            'showtitle'  => cmsCore::request('showtitle', 'int', 0),
            'published'  => cmsCore::request('published', 'int', 0),
            'css_prefix' => cmsCore::request('css_prefix', 'str', ''),
            'is_strict_bind' => cmsCore::request('is_strict_bind', 'int', 0),
            'is_strict_bind_hidden' => cmsCore::request('is_strict_bind_hidden', 'int', 0),
            'template'   => cmsCore::request('template', 'str', ''),
            'cache'      => cmsCore::request('cache', 'int', 0),
            'cachetime'  => cmsCore::request('cachetime', 'int', 0),
            'cacheint'   => cmsCore::request('cacheint', 'str', ''),
            'access_list' => '',
            'hidden_menu_ids' => ''
        );
        
        if (!$mod['is_external']) {
            $module['content'] = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', ''));
        }

        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $module['access_list'] = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }
        
        cmsCore::c('db')->update('cms_modules', $module, $id);
        cmsCore::c('db')->delete('cms_modules_bind', "module_id=". $id ." AND tpl='". cmsCore::c('config')->template ."'");

        if (cmsCore::request('show_all', 'int', 0)) {
            cmsCore::c('db')->insert(
                'cms_modules_bind',
                array(
                    'module_id' => $id,
                    'menu_id'   => 0,
                    'position'  => $module['position'],
                    'tpl'       => cmsCore::c('config')->template
                )
            );
            
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if (!empty($hidden_menu_ids)) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='". $hidden_menu_ids ."' WHERE id = '". $id ."' LIMIT 1");
            }
        } else {
            $showin  = cmsCore::request('showin', 'array_int', array());
            $showpos = cmsCore::request('showpos', 'array_str', array());
            if (count($showin) > 0) {
                foreach ($showin as $key => $value) {
                    cmsCore::c('db')->insert(
                        'cms_modules_bind',
                        array(
                            'module_id' => $id,
                            'menu_id'   => $value,
                            'position'  => $showpos[$value],
                            'tpl'       => cmsCore::c('config')->template
                        )
                    );
                }
            }
        }

        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success');

        if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) {
            cmsCore::redirect('index.php?view=modules');
        } else {
            cmsCore::redirect('index.php?view=modules&do=edit');
        }
    }

    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $maxorder = cmsCore::c('db')->get_field('cms_menu', '1=1 ORDER BY ordering DESC', 'ordering') + 1;

        $name           = cmsCore::request('name', 'str', '');
        $title          = cmsCore::request('title', 'str', '');
        $titles         = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
        $position       = cmsCore::request('position', 'str', '');
        $showtitle      = cmsCore::request('showtitle', 'int', 0);
        $content    	= cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', ''));
        $published      = cmsCore::request('published', 'int', 0);
        $css_prefix     = cmsCore::request('css_prefix', 'str', '');

        $is_public      = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
        }

        $template       = cmsCore::request('template', 'str', '');
        $cache          = cmsCore::request('cache', 'int', 0);
        $cachetime      = cmsCore::request('cachetime', 'int', 0);
        $cacheint       = cmsCore::request('cacheint', 'str', '');
        $operate        = cmsCore::request('operate', array('user', 'clone'), '');

        $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
        $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);

        if ($operate == 'user') { //USER MODULE
            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden)
                            VALUES ('". $position ."', '". $name ."', '". $title ."', '". $titles ."', 0, '". $content ."', '". $maxorder ."', '". $showtitle ."', '". $published ."', 1, 1, '". $css_prefix ."', '". $access_list ."', '". $template ."', '". $is_strict_bind ."', '". $is_strict_bind_hidden ."')";
            cmsCore::c('db')->query($sql) ;
        }

        if ($operate == 'clone') { //DUPLICATE MODULE
            $mod_id     = cmsCore::request('clone_id', 'int', 0);

            $sql         = "SELECT * FROM cms_modules WHERE id = ". $mod_id ." LIMIT 1";
            $result      = cmsCore::c('db')->query($sql) ;
            $original    = cmsCore::c('db')->escape_string(cmsCore::c('db')->fetch_assoc($result));
            $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0;

            $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, original, user, config, css_prefix, template, access_list, is_strict_bind, is_strict_bind_hidden, cache, cachetime, cacheint, version)
                        VALUES (
                            '". $position ."',
                            '". $original['name'] ."',
                            '". $title ."',
                            '". $titles ."',
                            '". $original['is_external'] ."',
                            '". $original['content'] ."',
                            '". $maxorder ."',
                            '". $showtitle ."',
                            '". $published ."',
                            '". $is_original ."',
                            '". $original['user'] ."',
                            '". $original['config'] ."',
                            '". $css_prefix ."',
                            '". $template ."',
                            '". $access_list ."',
                            '". $is_strict_bind ."',
                            '". $is_strict_bind_hidden ."',
                            '". $cache ."', 
                            '". $cachetime ."',
                            '". $cacheint ."',
                            '". $original['version'] ."'
                )";
            cmsCore::c('db')->query($sql);

            if (cmsCore::request('del_orig', 'int', 0)) {
                $sql = "DELETE FROM cms_modules WHERE id = ". $mod_id;
                cmsCore::c('db')->query($sql) ;
            }
        }

        $lastid = cmsCore::c('db')->get_last_id('cms_modules');

        if (cmsCore::request('show_all', 'int', 0)) {
            $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl)
                            VALUES (". $lastid .", 0, '". $position ."', '". cmsCore::c('config')->template ."')";
            cmsCore::c('db')->query($sql) ;
            
            $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
            if ($hidden_menu_ids) {
                $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
                cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='". $hidden_menu_ids ."' WHERE id = '". $lastid ."' LIMIT 1");
            }
        } else {
            $showin = cmsCore::request('showin', 'array', array());
            $showpos = cmsCore::request('showpos', 'array', array());
            if (count($showin) > 0) {
                foreach ($showin as $key=>$value) {
                    $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl)
                                    VALUES (". $lastid .", ". $value .", '". $showpos[$value] ."', '". cmsCore::c('config')->template ."')";
                    cmsCore::c('db')->query($sql) ;
                }
            }
        }

        cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'] , 'success');
        cmsCore::redirect('index.php?view=modules');
    }

    if ($do == 'add' || $do == 'edit') {
        $langs = cmsCore::getDirsList('/languages');
        
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MODULE_ADD']);
            echo '<h3>'. $_LANG['AD_MODULE_ADD'] .'</h3>';
            $show_all = false;
        } else {
            if (cmsCore::inRequest('multiple')) {
                if (cmsCore::inRequest('item')) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist'])==0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_modules', "id = '". $item_id ."'", '*');
            if (!$mod) { cmsCore::error404(); }
            
            $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']);
            $mod['titles'] = cmsCore::yamlToArray($mod['titles']);
            
            $show_all = false;
            
            $default_position = cmsCore::c('db')->get_field('cms_modules_bind', "module_id='". $mod['id'] ."' AND menu_id=0 AND tpl='". cmsCore::c('config')->template ."'", 'position');
            
            if (!empty($default_position)) {
                $show_all = true;
                $mod['position'] = $default_position;
            }

            echo '<h3>'. $_LANG['AD_EDIT_MODULE'] . $ostatok .'</h3>';
            cpAddPathway($mod['name']);
        }

        $toolmenu[] = array( 'icon' => 'save.gif',   'title' => $_LANG['SAVE'],   'link' => 'javascript:document.addform.submit();' );
        $toolmenu[] = array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' );

        if (cmsCore::getArrVal($mod, 'is_external')) {
            $php_file = 'modules/'. $mod['content'] .'/backend.php';
            $xml_file = 'modules/'. $mod['content'] .'/backend.xml';
            if (file_exists($php_file) || file_exists($xml_file)) {
                $toolmenu[] = array( 'icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id='. $mod['id'] );
            }
        }

        cpToolMenu($toolmenu);
?>
    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
        <input type="hidden" name="view" value="modules" />

        <table class="table">
            <tr><td>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MODULE_TITLE']; ?> (<input type="checkbox" class="uittip" title="<?php echo $_LANG['AD_VIEW_TITLE'];?>" name="showtitle" <?php if ($mod['showtitle'] || $do == 'add') { echo 'checked="checked"'; } ?> value="1" />)</label>
                            <input type="text" id="title" class="form-control" style="width:100%" name="title" value="<?php echo htmlspecialchars($mod['title']);?>" />
                            <div class="help-block"><?php echo $_LANG['AD_VIEW_IN_SITE']; ?></div>
                        </div>
                        
                        <?php if (count($langs) > 1) { ?>
                            <label><?php echo $_LANG['AD_LANG_TITLES']; ?></label>
                            <?php foreach ($langs as $lang) { ?>
                                <div>
                                    <strong><?php echo $lang; ?>:</strong>
                                    <input name="titles[<?php echo $lang; ?>]" type="text" style="width:97%" value="<?php echo htmlspecialchars($mod['titles'][$lang]); ?>" placeholder="<?php echo $_LANG['AD_HINT_DEFAULT']; ?>" />
                                </div>
                            <?php } ?>
                            <div class="help-block"><?php echo $_LANG['AD_LANG_TITLES_HINT']; ?></div>
                        <?php } ?> 
                        
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MODULE_NAME']; ?></label>
                            <?php if (!isset($mod['user']) || @$mod['user'] == 1) { ?>
                                <input type="text" id="name" class="form-control" style="width:99%" name="name" value="<?php echo htmlspecialchars($mod['name']);?>" />
                            <?php } else { ?>
                                <input type="text" id="name" class="form-control" style="width:99%" name="" value="<?php echo @$mod['name'];?>" disabled="disabled" />
                                <input type="hidden" name="name" value="<?php echo htmlspecialchars($mod['name']);?>" />
                            <?php } ?>
                            <div class="help-block"><?php echo $_LANG['AD_SHOW_ADMIN']; ?></div>
                        </div>
                        
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_PREFIX_CSS']; ?></label>
                            <input type="text" id="css_prefix" class="form-control" style="width:154px" name="css_prefix" value="<?php echo @$mod['css_prefix'];?>" />
                        </div>
                        
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_DEFOLT_VIEW']; ?></label>
                            <?php
                                $pos = cpModulePositions(cmsConfig::getConfig('template'));
                            ?>
                            
                            <select id="position" class="form-control" style="width:100%" name="position">
                                <?php
                                    if ($pos){
                                        foreach($pos as $key=>$position) {
                                            if (@$mod['position']==$position) {
                                                echo '<option value="'.$position.'" selected>'.$position.'</option>';
                                            } else {
                                                echo '<option value="'.$position.'">'.$position.'</option>';
                                            }
                                        }
                                    }
                                ?>
                            </select>
                            
                            <div class="help-block">
                                <?php echo $_LANG['AD_POSITION_MUST_BE']; ?>
                                <?php if (file_exists(PATH .'/templates/'. cmsCore::c('config')->template .'/positions.jpg')) { ?>
                                    <a href="#myModal" role="button" class="btn btn-sm btn-default" data-toggle="modal"><?php echo $_LANG['AD_SEE_VISUALLY']; ?></a>
                                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                    <h4 class="modal-title" id="myModalLabel"><?php echo $_LANG['AD_TPL_POS']; ?></h4>
                                                </div>
                                                <div class="modal-body">
                                                    <img src="/templates/<?php echo cmsCore::c('config')->template; ?>/positions.jpg" alt="<?php echo $_LANG['AD_TPL_POS']; ?>" style="width:100%;height:auto;" />
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                <?php } ?>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MODULE_TEMPLATE']; ?></label>
                            <?php
                                $tpls = cmsAdmin::getModuleTemplates();
                            ?>
                            <select id="template" class="form-control" style="width:100%" name="template">
                                <?php
                                    foreach ($tpls as $tpl) {
                                        $selected = ($mod['template'] == $tpl || (!$mod['template'] && $tpl == 'module' )) ? 'selected="selected"' : '';
                                        echo '<option value="'. $tpl .'" '. $selected .'>'. $tpl .'</option>';
                                    }
                                ?>
                            </select>
                            <div class="help-block"><?php echo $_LANG['AD_FOLDER_MODULES'];?></div>
                        </div>
                        
                        <?php if ($do == 'add') { ?>
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MODULE_TYPE']; ?></label>
                            <select id="operate" class="form-control" style="width:100%" name="operate" onchange="checkDiv()" >
                                <option value="user" selected="selected"><?php echo $_LANG['AD_MODULE_TYPE_NEW'];?></option>
                                <option value="clone"><?php echo $_LANG['AD_MODULE_TYPE_COPY'];?></option>
                            </select>
                        </div>
                        <?php } ?>
                        
                        <?php if (!isset($mod['user']) || $mod['user'] == 1 || $do == 'add') { ?>
                        <div id="user_div" class="form-group">
                            <label><?php echo $_LANG['AD_MODULE_CONTENT']; ?></label>
                            <div><?php insertPanel(); ?></div>
                            <div><?php $inCore->insertEditor('content', $mod['content'], '250', '100%'); ?></div>
                        </div>
                        <?php } ?>
                        
                        <div id="clone_div" class="form-group" style="display:none;">
                            <label><?php echo $_LANG['AD_MODULE_COPY']; ?></label>
                            <select id="clone_id" class="form-control" style="width:100%" name="clone_id">
                                <?php
                                    echo $inCore->getListItems('cms_modules');
                                ?>
                            </select>
                            <label>
                                <input type="checkbox" name="del_orig" value="1" />
                                <?php echo $_LANG['AD_ORIGINAL_MODULE_DELETE'];?>
                            </label>
                        </div>
                    </div>
                </div>
            </td>

            <!-- боковая ячейка -->
            <td width="400" valign="top">
                <div class="uitabs">
                    <ul id="tabs">
                        <li><a href="#upr_publish"><span><?php echo $_LANG['AD_TAB_PUBLISH']; ?></span></a></li>
                        
                        <?php if ((($mod['is_external'] && $do == 'edit') || $do == 'add') && cmsCore::c('config')->cache) { ?>
                        <li><a href="#upr_cache"><span><?php echo $_LANG['AD_MODULE_CACHE']; ?></span></a></li>
                        <?php } ?>
                        
                        <li><a href="#upr_access"><span><?php echo $_LANG['AD_TAB_ACCESS']; ?></span></a></li>
                    </ul>
                    
                    <div id="upr_publish">
                        <div class="form-group">
                            <label>
                                <input type="checkbox" name="published" id="published" value="1" <?php if ($mod['published'] || $do=='add') { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_MODULE_PUBLIC'];?>
                            </label>
                        </div>
                        <div class="form-group">
                            <label>
                                <input name="show_all" id="show_all" type="checkbox" value="1"  onclick="checkGroupList()" <?php if ($show_all) { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_VIEW_ALL_PAGES'];?>
                            </label>
                        </div>
                        
                        <?php
                            if ($do == 'edit') {
                                $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = ". $mod['id'] ." AND tpl = '". cmsConfig::getConfig('template') ."'";
                                $bind_res = cmsCore::c('db')->query($bind_sql);
                                $bind     = array();
                                $bind_pos = array();
                                while ($r = cmsCore::c('db')->fetch_assoc($bind_res)) {
                                    $bind[] = $r['menu_id'];
                                    $bind_pos[$r['menu_id']] = $r['position'];
                                }
                            }

                            $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering";
                            $menu_res = cmsCore::c('db')->query($menu_sql) ;

                            $menu_items = array();

                            if (cmsCore::c('db')->num_rows($menu_res)) {
                                while ($item = cmsCore::c('db')->fetch_assoc($menu_res)) {
                                    if ($do == 'edit') {
                                        if (in_array($item['id'], $bind)) {
                                            $item['selected'] = true;
                                            $item['position'] = $bind_pos[$item['id']];
                                        }
                                    }
                                    
                                    $item['titles'] = cmsCore::yamlToArray($item['titles']);
                                    // переопределяем название пункта меню в зависимости от языка
                                    if (!empty($item['titles'][cmsCore::c('config')->lang])) {
                                        $item['title'] = $item['titles'][cmsCore::c('config')->lang];
                                    }
                                    
                                    $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']);
                                    $menu_items[] = $item;
                                }
                            }
                        ?>
                        
                        <div id="grp" class="form-group">
                            <label>
                                <span class="show_list"><?php echo $_LANG['AD_WHERE_MODULE_VIEW'];?></span>
                                <span class="hide_list"><?php echo $_LANG['AD_WHERE_MODULE_NOT_VIEW'];?></span>
                            </label>
                            <div style="height:400px;overflow: auto;border: solid 1px #999; padding:5px 10px; background: #FFF;">
                                <table class="table">
                                    <tr>
                                        <td colspan="2" height="25"><strong><?php echo $_LANG['AD_MENU'];?></strong></td>
                                        <td class="show_list" align="center" width="50"><strong><?php echo $_LANG['AD_POSITION'];?></strong></td>
                                    </tr>
                                    <?php foreach($menu_items as $i) { ?>
                                    <tr class="show_list">
                                        <td width="20" height="25">
                                            <input type="checkbox" name="showin[]" id="mid<?php echo $i['id']; ?>" value="<?php echo $i['id']; ?>" <?php if ($i['selected']){ ?>checked="checked"<?php } ?> onclick="$('#p<?php echo $i['id']; ?>').toggle()"/>
                                        </td>
                                        <td style="padding-left:<?php echo ($i['NSLevel'])*6-6; ?>px"><label for="mid<?php echo $i['id']; ?>"><?php echo $i['title']; ?></label></td>
                                        <td align="center">
                                            <select id="p<?php echo $i['id']; ?>" name="showpos[<?php echo $i['id']; ?>]" style="<?php if (!$i['selected']) { ?>display:none<?php } ?>">
                                                <?php foreach($pos as $position){ ?>
                                                    <option value="<?php echo $position; ?>" <?php if ($i['position']==$position){ ?>selected="selected"<?php } ?>><?php echo $position; ?></option>
                                                <?php } ?>
                                            </select>
                                        </td>
                                    </tr>
                                    <?php } ?>
                                    <?php foreach($menu_items as $it) { ?>
                                    <tr class="hide_list">
                                        <td width="20" height="25">
                                            <input type="checkbox" name="hidden_menu_ids[]" id="hmid<?php echo $it['id']; ?>" value="<?php echo $it['id']; ?>" <?php if (in_array($it['id'], $mod['hidden_menu_ids'])){ ?>checked="checked"<?php } ?> />
                                        </td>
                                        <td style="padding-left:<?php echo ($it['NSLevel'])*6-6; ?>px"><label for="hmid<?php echo $it['id']; ?>"><?php echo $it['title']; ?></label></td>
                                    </tr>
                                    <?php } ?>
                                </table>
                            </div>
                            <label class="show_list">
                                <input type="checkbox" name="is_strict_bind" id="is_strict_bind" value="1" <?php if ($mod['is_strict_bind']) { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_DONT_VIEW']; ?>
                            </label>
                            <label class="hide_list">
                                <input type="checkbox" name="is_strict_bind_hidden" id="is_strict_bind_hidden" value="1" <?php if ($mod['is_strict_bind_hidden']) { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_EXCEPT_NESTED']; ?>
                            </label>
                        </div>
                    </div>
                    
                    <?php if ((($mod['is_external'] && $do == 'edit') || $do == 'add') && cmsCore::c('config')->cache) { ?>
                    <div id="upr_cache">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_DO_MODULE_CACHE']; ?></label>
                            <select id="cache" class="form-control" style="width:100%" name="cache">
                                <option value="0" <?php if (!cmsCore::getArrVal($mod, 'cache')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['NO']; ?></option>
                                <option value="1" <?php if (cmsCore::getArrVal($mod, 'cache')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['YES']; ?></option>
                            </select>
                        </div>
                        
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_MODULE_CACHE_PERIOD']; ?></label>
                            <table class="table">
                                <tr>
                                    <td valign="top"  width="100">
                                        <input id="int_1" class="form-control" style="width:99%" name="cachetime" type="text" value="<?php echo cmsCore::getArrVal($mod, 'cachetime', 0); ?>"/>
                                    </td>
                                    <td valign="top" style="padding-left:5px">
                                        <select id="int_2" class="form-control" style="width:100%" name="cacheint">
                                            <option value="MINUTE"  <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MINUTE')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false); ?></option>
                                            <option value="HOUR"  <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'HOUR')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false); ?></option>
                                            <option value="DAY" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'DAY')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false); ?></option>
                                            <option value="MONTH" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MONTH')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false); ?></option>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                            <div style="margin-top:15px">
                                <?php
                                    if ($do == 'edit') {
                                        $cache = cmsCore::c('cache')->get('modules', $mod['id'], $mod['content'], array(cmsCore::getArrVal($mod, 'cachetime', 1), cmsCore::getArrVal($mod, 'cacheint', 'MINUTES')));
                                        
                                        if (!empty($cache)){
                                            $kb = round(mb_strlen($cache)/1024, 2);
                                            unset($cache);
                                            echo '<a href="index.php?view=cache&component=modules&target='. $mod['content'] .'&target_id='. $mod['id'] .'">'. $_LANG['AD_MODULE_CACHE_DELETE'] .'</a> ('. $kb . $_LANG['SIZE_KB'] .')';
                                        } else {
                                            echo '<span style="color:gray">'. $_LANG['AD_NO_CACHE'] .'</span>';
                                        }
                                    }
                                ?>
                            </div>
                        </div>
                    </div>
                    <?php } ?>
                    
                    <div id="upr_access">
                        <div class="form-group">
                            <?php
                                $groups = cmsUser::getGroups();
                                $style  = 'disabled="disabled"';
                                $public = 'checked="checked"';

                                if ($do == 'edit') {
                                    if ($mod['access_list']) {
                                        $public = '';
                                        $style  = '';
                                        $access_list = $inCore->yamlToArray($mod['access_list']);
                                    }
                                }
                            ?>
                            <label>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> />
                                <?php echo $_LANG['AD_SHARE']; ?>
                            </label>
                            <div class="help-block"><?php echo $_LANG['AD_IF_CHECKED']; ?></div>
                        </div>
                        
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label>
                            <?php
                                echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" '.$style.'>';

                                if ($groups) {
                                    foreach($groups as $group) {
                                        echo '<option value="'.$group['id'].'"';
                                        if ($do == 'edit' && $mod['access_list']) {
                                            if (in_array($group['id'], $access_list)) {
                                                echo 'selected="selected"';
                                            }
                                        }

                                        echo '>';
                                        echo $group['title'].'</option>';
                                    }
                                }

                                echo '</select>';
                            ?>
                            <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?></div>
                        </div>
                    </div>
                </div>
            </td></tr>
        </table>
        <p>
            <input type="submit" id="add_mod" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['SAVE']; ?>" />
            <input type="button" id="back" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />
            <input type="hidden" id="do" name="do" <?php if ($do == 'add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> />
            <?php
                if ($do == 'edit') {
                    echo '<input name="id" type="hidden" value="'. $mod['id'] .'" />';
                }
            ?>
        </p>
    </form>
<?php
   }
}
Ejemplo n.º 19
0
function applet_arhive() {
    $inCore = cmsCore::getInstance();
    
    global $_LANG;
    
    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES_ARCHIVE']);
    
    $cfg = $inCore->loadComponentConfig('content');
    $cfg_arhive = $inCore->loadComponentConfig('arhive');

    cpAddPathway($_LANG['AD_ARTICLE_SITE'], 'index.php?view=tree');
    cpAddPathway($_LANG['AD_ARTICLES_ARCHIVE'], 'index.php?view=arhive');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);

    if ($do == 'saveconfig') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $cfg['source'] = cmsCore::request('source', 'str', '');
        $inCore->saveComponentConfig('arhive', $cfg);
        
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'] , 'success');
        cmsCore::redirect('?view=arhive&do=config');
    }
    
    if ($do == 'config') {
        $toolmenu = array(
            array( 'icon' => 'folders.gif', 'title' => $_LANG['AD_LIST_OF_ARTICLES'], 'link' => '?view=arhive' )
        );
        
        cpToolMenu($toolmenu);
        cpAddPathway($_LANG['AD_SETTINGS'], 'index.php?view=arhive&do=config');
?>
<form action="index.php?view=arhive&do=saveconfig" method="post" name="optform" target="_self" id="form1">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:550px">
        <div class="form-group">
            <label><?php echo $_LANG['AD_SOURCE_MATERIALS']; ?></label>
            <select class="form-control" name="source">
                <option value="content" <?php if ($cfg_arhive['source'] == 'content') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_ARTICLE_SITE']; ?></option>
                <option value="arhive" <?php if ($cfg_arhive['source'] == 'arhive') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_ARTICLES_ARCHIVE']; ?></option>
                <option value="both" <?php if ($cfg_arhive['source'] == 'both') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_CATALOG_AND_ARCHIVE']; ?></option>
            </select>
        </div>
    </div>
    
    <div>
        <input type="hidden" name="opt" value="saveconfig" />
        <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['SAVE']; ?>" />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.location.href='index.php?view=arhive';" />
    </div>
</form>
<?php
    }

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'config.gif', 'title' => $_LANG['AD_SETTINGS'], 'link' => '?view=arhive&do=config' ),
            array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=arhive&do=delete&multiple=1');" )
        );

        cpToolMenu($toolmenu);

        //TABLE COLUMNS
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['AD_CREATE'], 'field' => 'pubdate', 'width' => '80', 'filter' => 15, 'fdate' => '%d/%m/%Y' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=content&do=edit&id=%id%', 'filter' => 15 ),
            array( 'title' => $_LANG['AD_PARTITION'], 'field' => 'category_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpCatById', 'filterlist' => cpGetList('cms_category') )
        );

        //ACTIONS
        $actions = array(
            array( 'title' => $_LANG['AD_TO_ARTICLES_CATALOG'], 'icon' => 'arhive_off.gif', 'link' => '?view=arhive&do=arhive_off&id=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=content&do=delete&id=%id%', 'confirm' => $_LANG['AD_DELETE_MATERIALS'] )
        );

        //Print table
        cpListTable('cms_content', $fields, $actions, 'is_arhive=1');
    }
    
    if ($do == 'arhive_off') {
        if (cmsCore::inRequest('id')) {
            cmsCore::c('db')->setFlag('cms_content', $id, 'is_arhive', '0');
            cmsCore::redirect('?view=arhive');
        }
    }

    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                cmsCore::m('content')->deleteArticle($id, $cfg['af_delete']);
            }
        } else {
            cmsCore::m('content')->deleteArticles(cmsCore::request('item', 'array_int'), $cfg['af_delete']);
        }
        cmsCore::redirect('?view=arhive');
    }
}
Ejemplo n.º 20
0
function applet_tickets() {
    global $adminAccess;

    if (!cmsUser::isAdminCan('admin/tickets', $adminAccess)) { cpAccessDenied(); }
    
    global $_LANG;
    
    cmsUser::sessionDel('ticket_cat');

    $do = cmsCore::request('do', 'str', 'list');
    $super_user = cmsCore::c('user')->id == 1;
    
    $toolmenu = array(
        array( 'icon' => 'new.gif', 'title' => $_LANG['AD_TICKET_CREATE'], 'link' => '?view=tickets&do=add' ),
        array( 'icon' => 'liststuff.gif', 'title' => $_LANG['AD_TICKET_LIST'], 'link' => '?view=tickets&do=list' )
    );

    cpToolMenu($toolmenu, 'list', 'do');
    
    cmsCore::c('page')->setTitle($_LANG['AD_TICKETS']);
    cpAddPathway($_LANG['AD_TICKETS'], 'index.php?view=tickets');
    
    if ($do == 'list') {
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['AD_TICKET_STATUS'], 'field' => 'status', 'width' => '100', 'filter' => 1, 'prc' => 'cpTicketStatus', 'filterlist' => cpGetTicketStatusList() ),
            array( 'title' => $_LANG['AD_TICKET_DATE'], 'field' => 'pubdate', 'width' => '80' ),
            array( 'title' => $_LANG['AD_TICKET_TITLE'], 'field' => 'title', 'width' => '', 'filter' => 32, 'link' => 'index.php?view=tickets&do=view&id=%id%' ),
            array( 'title' => $_LANG['AD_TICKET_LAST_MSG_DATE'], 'field' => 'last_msg_date', 'width' => '80' ),
            array( 'title' => $_LANG['AD_TICKET_CAT'], 'field' => 'cat_id', 'width' => '150', 'filter' => 1, 'prc' => 'cpTicketCategory', 'filter' => 1, 'filterlist' => cpGetTicketCats() ),
            array( 'title' => $_LANG['AD_TICKET_PRIORITY'], 'field' => 'priority', 'width' => '100', 'filter' => 1, 'prc' => 'cpTicketPriority', 'filterlist' => cpGetTicketPriorityList() )
        );
        
        if ($super_user) {
            $fields[] = array( 'title' => $_LANG['AD_TICKET_USER'], 'field' => 'user_id', 'width' => '110', 'prc' => 'cpTicketAuthor' );
        }

        $actions = array(
            array( 'title' => $_LANG['AD_TICKET_CLOSE'], 'icon' => 'off.gif', 'link' => '?view=tickets&do=close_ticket&id=%id%', 'condition' => 'cpCheckTicketClose' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=tickets&do=delete&id=%id%', 'confirm' => $_LANG['AD_TICKET_DELETE'] )
        );

        cpListTable('cms_ticket', $fields, $actions, $super_user ? '' : 'user_id='. cmsCore::c('user')->id, 'last_msg_date DESC', 30);
    }
    
    if ($do == 'delete') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id='. $id, '*');
        
        if (!empty($item)) {
            $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id='. $item['cat_id'], 'server');
            if (empty($server)) { $server = 'http://ds-soft.ru/tickets.api.php'; }
            
            //Удаляем сам тиккет
            cmsCore::c('db')->delete('cms_ticket', 'id='. $item['id']);
            
            //Удаляем все сообщения тиккета
            cmsCore::c('db')->delete('cms_ticket_msg', 'ticket_id='. $item['id']);
            
            //Удаляем все прикрепленные изображения тиккета
            cmsCore::deleteUploadImages($item['id'], 'ticket');
            
            if ($item['status'] != '3') {
                //Отправляем сообщение на сервер техподдержки что тикет удален
                cmsCore::c('curl')->ajax()->request('post', $server .'?do=ticket_deleted', array( 'ticket_id' => $item['id'], 'ticket_secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host ));
            }
            
            cmsCore::addSessionMessage($_LANG['AD_TICKET_DELETE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        
        cmsCore::redirect('index.php?view=tickets');
    }
    
    if ($do == 'close_ticket') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id='. $id, '*');
        
        if (!empty($item)) {
            cmsCore::c('db')->setFlag('cms_ticket', $item['id'], 'status', '3');
            
            $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id='. $item['cat_id'], 'server');
            if (empty($server)) { $server = 'http://ds-soft.ru/tickets.api.php'; }
            
            //Отправляем сообщение на сервер техподдержки что тикет закрыт
            cmsCore::c('curl')->ajax()->request('post', $server .'?do=ticket_closed', array( 'ticket_id' => $item['id'], 'ticket_secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host ));
            
            cmsCore::addSessionMessage($_LANG['AD_TICKET_CLOSE_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        
        cmsCore::redirect('index.php?view=tickets');
    }
    
    if ($do == 'add') {
        cpAddPathway($_LANG['AD_TICKET_CREATE'], 'index.php?view=tickets&do=add');
        $cats = cpGetTicketCats();
?>
<form action="index.php?view=tickets&do=submit" method="post">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div class="panel panel-default" style="width:650px;">
        <div class="panel-body">
            <div class="form-group">
                <label><?php echo $_LANG['AD_TICKET_CAT']; ?></label>
                <select class="form-control" name="cat_id">
                    <?php foreach ($cats as $cat) { ?>
                    <option value="<?php echo $cat['id']; ?>"><?php echo $cat['title']; ?></option>
                    <?php } ?>
                </select>
            </div>
            
            <div class="form-group">
                <label><?php echo $_LANG['AD_TICKET_PRIORITY']; ?></label>
                <select class="form-control" name="priority">
                    <option value="0"><?php echo $_LANG['AD_TICKET_PRIORITY_0']; ?></option>
                    <option value="1"><?php echo $_LANG['AD_TICKET_PRIORITY_1']; ?></option>
                    <option value="2"><?php echo $_LANG['AD_TICKET_PRIORITY_2']; ?></option>
                    <option value="3"><?php echo $_LANG['AD_TICKET_PRIORITY_3']; ?></option>
                </select>
            </div>
            
            <div class="form-group">
                <label><?php echo $_LANG['AD_TICKET_TITLE']; ?></label>
                <input type="text" class="form-control" name="title" value="" required="true" maxlength="256" />
            </div>
            
            <div class="form-group">
                <label><?php echo $_LANG['AD_TICKET_MSG']; ?></label>
                <textarea class="form-control" name="msg" style="height: 200px;"></textarea>
            </div>
        </div>
    </div>
    
    <div style="margin-top:5px">
        <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['AD_TICKET_SUBMIT']; ?>" />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.location.href='index.php?view=tickets';" />
    </div>
</form>
<?php
    }
    
    if ($do == 'submit') {
        $cats = cpGetTicketCats();
        
        $item = array(
            'cat_id' => cmsCore::request('cat_id', 'int', 0),
            'priority' => cmsCore::request('priority', array(0,1,2,3), 0),
            'title' => cmsCore::request('title', 'str', ''),
            'msg' => cmsCore::request('msg', 'str', '')
        );
        
        if (!isset($cats[$item['cat_id']])) { $item['cat_id'] = 0; }
        
        if (!empty($item['title']) && !empty($item['msg'])) {
            $item['msg'] = cmsCore::c('db')->escape_string($item['msg']);
            $item['msg_count'] = 1;
            $item['pubdate'] = date('Y-m-d H:i:s');
            $item['last_msg_date'] = $item['pubdate'];
            $item['user_id'] = cmsCore::c('user')->id;
            
            $item['id'] = cmsCore::c('db')->insert('cms_ticket', $item);

            cmsCore::addSessionMessage($_LANG['AD_TICKET_CREATED'], 'success');
            
            $do = 'send';
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR_2'], 'error');
            cmsCore::redirect('index.php?view=tickets&do=add');
        }
    }
    
    if ($do == 'send') {
        if (empty($item)) {
            $id = cmsCore::request('id', 'int', 0);
            $item = cmsCore::c('db')->get_fields('cms_ticket', 'id='. $id, '*');
        }
        
        if (!empty($item)) {
            $cat = cmsCore::c('db')->get_fields('cms_ticket_cat', 'id='. $item['cat_id'], '*');
            $server = !empty($cat['server']) ? $cat['server'] : 'http://ds-soft.ru/tickets.api.php';

            $ticket = array(
                'ticket_id' => $item['id'],
                'cat_id' => $item['cat_id'],
                'priority' => $item['priority'],
                'title' => $item['title'],
                'msg' => $item['msg'],
                'host' => cmsCore::c('config')->host,
                'module' => $cat['module']
            );
            
            if ($ticket['cat_id'] > 0 && !empty($cat['module'])) {
                $ticket['module'] = $cat['module'];
            }

            //Отправляем тикет на сервер техподдержки
            $result = cmsCore::c('curl')->ajax()->request('post', $server .'?do=add_ticket', $ticket)->json();
            
            if (!empty($result['error'])) {
                cmsCore::clearSessionMessages();
                cmsCore::addSessionMessage($result['error'], 'error');
                cmsCore::c('db')->delete('cms_ticket', 'id='. $item['id']);
            } else if (isset($result['secret_key'])) {
                cmsCore::c('db')->update(
                    'cms_ticket',
                    array('status' => 1, 'secret_key' => $result['secret_key']),
                    $item['id']
                );

                cmsCore::addSessionMessage($_LANG['AD_TICKET_SENDED'], 'success');
            } else {
                cmsCore::addSessionMessage($_LANG['AD_TICKET_UNKNOWN_ERROR'], 'error');
                cmsCore::c('db')->delete('cms_ticket', 'id='. $item['id']);
            }
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
        }
        
        cmsCore::redirect('index.php?view=tickets');
    }
    
    if ($do == 'view') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id='. $id, '*');
        
        if (empty($item) || ($item['user_id'] != cmsCore::c('user')->id && !$super_user)) {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
            cmsCore::redirect('index.php?view=tickets');
        }
        
        cpAddPathway($item['title'], 'index.php?view=tickets&do=view&id='. $item['id']);
        
        if ($item['msg_count'] > 1) {
            $item['msgs'] = array();
            $results = cmsCore::c('db')->query("SELECT * FROM cms_ticket_msg WHERE ticket_id=". $item['id'] ." ORDER BY pubdate ASC");
            if (cmsCore::c('db')->num_rows($results)) {
                while($msg = cmsCore::c('db')->fetch_assoc($results)) {
                    $msg['pubdate'] = cmsCore::dateFormat($msg['pubdate']);
                    $item['msgs'][] = $msg;
                }
            }
        }
        
        if ($item['status'] != 3) {
            switch($item['priority']) {
                case 0: $class = 'info'; break;
                case 1: $class = 'success'; break;
                case 2: $class = 'primary'; break;
                case 3: $class = 'danger'; break;
            }
        }else {
            $class = 'default';
        }
?>
<div class="panel panel-<?php echo $class; ?>" style="width:650px;">
    <div class="panel-heading">
        <h4>Тема: <?php echo $item['title']; ?></h4>
        <div><?php echo $item['msg']; ?></div>
    </div>
    
    <div class="panel-body">
        <?php if (!empty($item['msgs'])) {
            foreach ($item['msgs'] as $msg) {
        ?>
            <div style="text-align: <?php if (!empty($msg['support'])) { echo 'right'; } else { echo 'left'; } ?>;">
                <span>
                    <i class="fa fa-calendar-o"></i>
                    <?php echo $msg['pubdate']; ?>
                </span>
                <?php if (!empty($msg['support'])) { ?>
                    <span>
                        <i class="fa fa-user"></i>
                        <?php echo $msg['support']; ?>
                    </span>
                <?php } ?>
            </div>
            <div class="alert alert-warning" style="margin-<?php if (!empty($msg['support'])) { echo 'left'; } else { echo 'right'; } ?>: 50px;">
                <?php echo $msg['msg']; ?>
            </div>
        <?php } } ?>
    </div>
    
    <div class="panel-footer">
        <?php if ($item['msg_count'] > 1 && $item['status'] != 3) { ?>
            <form id="ticket_msg_add" action="index.php?view=tickets&do=submit_msg" method="post">
                <div class="form-group">
                    <label><?php echo $_LANG['AD_TICKET_MSG']; ?></label>
                    <textarea class="form-control" name="msg" style="height: 200px;"></textarea>
                </div>

                <div style="margin-top:5px">
                    <input type="hidden" name="id" value="<?php echo $item['id']; ?>" />
                    <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['SEND']; ?>" />
                    <input type="button" class="btn btn-warning" value="<?php echo $_LANG['AD_TICKET_CLOSE']; ?>" onclick="window.location.href='index.php?view=tickets&do=close_ticket&id=<?php echo $item['id']; ?>';return false;" />
                    <input type="button" class="btn btn-danger" value="<?php echo $_LANG['DELETE']; ?>" onclick="jsmsg('<?php echo $_LANG['AD_TICKET_DELETE']; ?>', '?view=tickets&do=delete&id=<?php echo $item['id']; ?>');" />
                    <input type="button" class="btn btn-default" value="<?php echo $_LANG['BACK']; ?>" onclick="window.location.href='index.php?view=tickets';return false;" />
                </div>
            </form>
        <?php } else { ?>
            <div>
                <?php if ($item['status'] != 3) { ?>
                    <input type="button" class="btn btn-warning" value="<?php echo $_LANG['AD_TICKET_CLOSE']; ?>" onclick="window.location.href='index.php?view=tickets&do=close_ticket&id=<?php echo $item['id']; ?>';return false;" />
                <?php } ?>
                <input type="button" class="btn btn-danger" value="<?php echo $_LANG['DELETE']; ?>" onclick="jsmsg('<?php echo $_LANG['AD_TICKET_DELETE']; ?>', '?view=tickets&do=delete&id=<?php echo $item['id']; ?>');" />
                <input type="button" class="btn btn-default" value="<?php echo $_LANG['BACK']; ?>" onclick="window.location.href='index.php?view=tickets';return false;" />
            </div>
        <?php } ?>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $('body').animate({ scrollTop: $('#ticket_msg_add').offset().top }, 1100);
    });
</script>
<?php
    }
    
    if ($do == 'submit_msg') {
        $id = cmsCore::request('id', 'int', 0);
        $item = cmsCore::c('db')->get_fields('cms_ticket', 'id='. $id, '*');
        
        if (empty($item) || ($item['user_id'] != cmsCore::c('user')->id && !$super_user)) {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_ERROR'], 'error');
            cmsCore::redirect('index.php?view=tickets');
        }
        
        $msg = cmsCore::request('msg', 'str', '');
        $date = date('Y-m-d H:i:s');
        
        cmsCore::c('db')->insert('cms_ticket_msg', array('msg' => cmsCore::c('db')->escape_string($msg), 'ticket_id' => $item['id'], 'pubdate' => $date));
        
        cmsCore::c('db')->query("UPDATE `cms_tickets` SET `last_msg_date` = '". $date ."', `msg_count` = `msg_count`+1 WHERE `id` = '". $item['id'] ."'");
        
        $server = cmsCore::c('db')->get_field('cms_ticket_cat', 'id='. $item['cat_id'], 'server');
        if (empty($server)) { $server = 'http://ds-soft.ru/tickets.api.php'; }
        
        //Отправляем тикет на сервер техподдержки
        $result = cmsCore::c('curl')->ajax()->request('post', $server .'?do=add_ticket_msg', array( 'msg' => $msg, 'ticket_id' => $item['id'], 'secret_key' => $item['secret_key'], 'host' => cmsCore::c('config')->host ))->json();

        if (!empty($result['error'])) {
            cmsCore::addSessionMessage($result['error'], 'error');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_TICKET_MSG_SENDED'], 'success');
        }
        
        cmsCore::redirect('index.php?view=tickets&do=view&id='. $item['id']);
    }
}
Ejemplo n.º 21
0
function applet_menu()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_MENU'];
    cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add');
        $toolmenu[] = array('icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');");
        $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');");
        $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');");
        $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu');
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'Lt', 'field' => 'NSLeft', 'width' => '30');
        $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=menu&do=edit&id=%id%');
        $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '60');
        $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100');
        $fields[] = array('title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById');
        $fields[] = array('title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu');
        $fields[] = array('title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '70', 'prc' => 'cpTemplateById');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%');
        cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering');
    } else {
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu');
        cpToolMenu($toolmenu);
    }
    if ($do == 'move_up') {
        $inDB->moveNsCategory('cms_menu', $id, 'up');
        cmsCore::redirectBack();
    }
    if ($do == 'move_down') {
        $inDB->moveNsCategory('cms_menu', $id, 'down');
        cmsCore::redirectBack();
    }
    if ($do == 'show') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbShow('cms_menu', $id);
            }
            echo '1';
            exit;
        } else {
            dbShowList('cms_menu', $_REQUEST['item']);
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'hide') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbHide('cms_menu', $id);
            }
            echo '1';
            exit;
        } else {
            dbHideList('cms_menu', cmsCore::request('item', 'array_int', array()));
            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirectBack();
        }
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                $inDB->deleteNS('cms_menu', (int) $id);
            }
        } else {
            $items = cmsCore::request('item', 'array_int', array());
            foreach ($items as $item_id) {
                $inDB->deleteNS('cms_menu', $item_id);
            }
        }
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirectBack();
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $id = cmsCore::request('id', 'int', 0);
        if (!$id) {
            cmsCore::redirectBack();
        }
        $title = cmsCore::request('title', 'str', '');
        $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype = cmsCore::request('mode', 'str', '');
        $linkid = cmsCore::request($linktype, 'str', '');
        $link = $inCore->getMenuLink($linktype, $linkid);
        $target = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template = cmsCore::request('template', 'str', '');
        $iconurl = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $oldparent = cmsCore::request('oldparent', 'int', 0);
        $is_lax = cmsCore::request('is_lax', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $ns = $inCore->nestedSetsInit('cms_menu');
        if ($oldparent != $parent_id) {
            $ns->MoveNode($id, $parent_id);
        }
        $sql = "UPDATE cms_menu\n                SET title='{$title}',\n                    css_class='{$css_class}',\n                    menu='{$menu}',\n                    link='{$link}',\n                    linktype='{$linktype}',\n                    linkid='{$linkid}',\n                    target='{$target}',\n                    published='{$published}',\n                    template='{$template}',\n                    access_list='{$access_list}',\n                    is_lax='{$is_lax}',\n                    iconurl='{$iconurl}'\n                WHERE id = '{$id}'\n                LIMIT 1";
        $inDB->query($sql);
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
            cmsCore::redirect('?view=menu');
        } else {
            cmsCore::redirect('?view=menu&do=edit');
        }
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $title = cmsCore::request('title', 'str', '');
        $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
        $linktype = cmsCore::request('mode', 'str', '');
        $linkid = cmsCore::request($linktype, 'str', '');
        $link = $inCore->getMenuLink($linktype, $linkid);
        $target = cmsCore::request('target', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $template = cmsCore::request('template', 'str', '');
        $iconurl = cmsCore::request('iconurl', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        $css_class = cmsCore::request('css_class', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        $is_lax = cmsCore::request('is_lax', 'int', 0);
        if (!$is_public) {
            $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $ns = $inCore->nestedSetsInit('cms_menu');
        $myid = $ns->AddNode($parent_id);
        $sql = "UPDATE cms_menu\n\t\t\t\tSET menu='{$menu}',\n\t\t\t\t\ttitle='{$title}',\n                    css_class='{$css_class}',\n\t\t\t\t\tlink='{$link}',\n\t\t\t\t\tlinktype='{$linktype}',\n\t\t\t\t\tlinkid='{$linkid}',\n\t\t\t\t\ttarget='{$target}',\n\t\t\t\t\tpublished='{$published}',\n\t\t\t\t\ttemplate='{$template}',\n\t\t\t\t\taccess_list='{$access_list}',\n\t\t\t\t\tis_lax='{$is_lax}',\n\t\t\t\t\ticonurl='{$iconurl}'\n\t\t\t\tWHERE id = '{$myid}'";
        $inDB->query($sql);
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('?view=menu');
    }
    if ($do == 'submitmenu') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1";
        $result = $inDB->query($sql);
        $row = $inDB->fetch_assoc($result);
        $maxorder = $row['max_o'] + 1;
        $menu = cmsCore::request('menu', 'str', '');
        $title = cmsCore::request('title', 'str', '');
        $position = cmsCore::request('position', 'str', '');
        $published = cmsCore::request('published', 'int', 0);
        $css_prefix = cmsCore::request('css_prefix', 'str', '');
        $is_public = cmsCore::request('is_public', 'int', '');
        if (!$is_public) {
            $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int'));
        }
        $cfg['menu'] = $menu;
        $cfg_str = cmsCore::arrayToYaml($cfg);
        $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list)\n                VALUES ('{$position}', '{$_LANG['AD_MENU']}', '{$title}', 1, 'mod_menu', {$maxorder}, 1, {$published}, 0, '{$cfg_str}', '{$css_prefix}', '{$access_list}')";
        $inDB->query($sql);
        $newid = $inDB->get_last_id('cms_modules');
        cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
        cmsCore::redirect('?view=modules&do=edit&id=' . $newid);
    }
    if ($do == 'addmenu' || $do == 'add' || $do == 'edit') {
        $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>';
        echo '<script>';
        echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU');
        echo '</script>';
    }
    if ($do == 'addmenu') {
        $GLOBALS['cp_page_title'] = $_LANG['AD_MENU_ADD'];
        cpAddPathway($_LANG['AD_MENU_ADD']);
        $menu_list = cpGetList('menu');
        ?>
         <form id="addform" name="addform" action="index.php?view=menu&do=submitmenu" method="post">
             <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
             <table class="proptable" width="650" cellspacing="10" cellpadding="10">
                 <tr>
                     <td width="300" valign="top">
                         <strong><?php 
        echo $_LANG['AD_MODULE_MENU_TITLE'];
        ?>
</strong>
                     </td>
                     <td valign="top">
                         <input name="title" type="text" id="title2" style="width:99%" value=""/>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_MENU_TO_VIEW'];
        ?>
</strong><br/>
                         <span class="hinttext"><?php 
        echo $_LANG['AD_TO_CREATE_NEW_POINT'];
        ?>
</span>
                     </td>
                     <td valign="top">
                         <select name="menu" id="menu" style="width:99%">
                             <?php 
        foreach ($menu_list as $menu) {
            ?>
                                 <option value="<?php 
            echo $menu['id'];
            ?>
">
                                     <?php 
            echo $menu['title'];
            ?>
                                 </option>
                             <?php 
        }
        ?>
                         </select>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_POSITION_TO_VIEW'];
        ?>
</strong><br />
                         <span class="hinttext"><?php 
        echo $_LANG['AD_POSITION_MUST_BE'];
        ?>
</span>
                     </td>
                     <td valign="top">
                         <?php 
        $pos = cpModulePositions(cmsConfig::getConfig('template'));
        ?>
                         <select name="position" id="position" style="width:99%">
                             <?php 
        if ($pos) {
            foreach ($pos as $key => $position) {
                if (@$mod['position'] == $position) {
                    echo '<option value="' . $position . '" selected>' . $position . '</option>';
                } else {
                    echo '<option value="' . $position . '">' . $position . '</option>';
                }
            }
        }
        ?>
                         </select>
                         <input name="is_external" type="hidden" id="is_external" value="0" />
                     </td>
                 </tr>
                 <tr>
                     <td valign="top"><strong><?php 
        echo $_LANG['AD_MENU_PUBLIC'];
        ?>
</strong></td>
                     <td valign="top">
                         <label><input name="published" type="radio" value="1" checked="checked" <?php 
        if (@$mod['published']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['YES'];
        ?>
</label>
                         <label><input name="published" type="radio" value="0"  <?php 
        if (@(!$mod['published'])) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['NO'];
        ?>
</label>
                     </td>
                 </tr>
                 <tr>
                     <td valign="top"><strong><?php 
        echo $_LANG['AD_PREFIX_CSS'];
        ?>
</strong></td>
                     <td valign="top">
                         <input name="css_prefix" type="text" id="css_prefix" value="<?php 
        echo @$mod['css_prefix'];
        ?>
" style="width:99%" />
                     </td>
                 </tr>
                 <tr>
                     <td valign="top">
                         <strong><?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
:</strong><br />
                         <span class="hinttext"><?php 
        echo $_LANG['AD_GROUP_ACCESS'];
        ?>
</span>
                     </td>
                     <td valign="top">
                     <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                         <tr>
                             <td width="20">
                                 <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                 <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                             </td>
                             <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                         </tr>
                     </table>
                     <div style="padding:5px">
                         <span class="hinttext">
                             <?php 
        echo $_LANG['AD_VIEW_IF_CHECK'];
        ?>
                         </span>
                     </div>

                     <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                         <div>
                             <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                             <span class="hinttext">
                                  <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                             </span>
                         </div>
                         <div>
                             <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit') {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                         </div>
                     </div>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="2" valign="top">
                         <div style="padding:10px;margin:4px;background-color:#EBEBEB;border:solid 1px gray">
                             <?php 
        echo $_LANG['AD_NEW_MENU_NEW_MODULE'];
        ?>
                         </div>
                     </td>
                 </tr>
             </table>
             <div style="margin-top:5px">
                 <input name="save" type="submit" id="save" value="<?php 
        echo $_LANG['AD_MENU_ADD'];
        ?>
" />
                 <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=menu';" />
             </div>
         </form>
         <?php 
    }
    if ($do == 'add' || $do == 'edit') {
        require '../includes/jwtabs.php';
        $GLOBALS['cp_page_head'][] = jwHeader();
        $menu_list = cpGetList('menu');
        if ($do == 'add') {
            cpAddPathway($_LANG['AD_MENU_POINT_ADD']);
            $mod['menu'] = array('mainmenu');
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_menu', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            $mod['menu'] = cmsCore::yamlToArray($mod['menu']);
            cpAddPathway($_LANG['AD_MENU_POINT_EDIT'] . $ostatok . ' "' . $mod['title'] . '"');
        }
        ?>
    <form id="addform" name="addform" method="post" action="index.php">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <input type="hidden" name="view" value="menu" />

        <table class="proptable" width="100%" cellpadding="15" cellspacing="2">
            <tr>

                <td valign="top">

                    <div><strong><?php 
        echo $_LANG['AD_MENU_POINT_TITLE'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_VIEW_IN_SITE'];
        ?>
</span></div>
                    <div><input name="title" type="text" id="title" style="width:100%" value="<?php 
        echo htmlspecialchars($mod['title']);
        ?>
" /></div>
                    <div><strong><?php 
        echo $_LANG['AD_PARENT_POINT'];
        ?>
</strong></div>
                    <div>
                        <?php 
        $rootid = $inDB->get_field('cms_menu', 'parent_id=0', 'id');
        ?>
                        <select name="parent_id" size="10" id="parent_id" style="width:100%">
                            <option value="<?php 
        echo $rootid;
        ?>
" <?php 
        if (@$mod['parent_id'] == $rootid || !isset($mod['parent_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_MENU_ROOT'];
        ?>
</option>
                            <?php 
        if (isset($mod['parent_id'])) {
            echo $inCore->getListItemsNS('cms_menu', $mod['parent_id']);
        } else {
            echo $inCore->getListItemsNS('cms_menu');
        }
        ?>
                        </select>
                        <input type="hidden" name="oldparent" value="<?php 
        echo @$mod['parent_id'];
        ?>
" />
                    </div>

                    <div><strong><?php 
        echo $_LANG['AD_MENU_POINT_ACTION'];
        ?>
</strong></div>
                    <div>
                        <select name="mode" id="linktype" style="width:100%" onchange="showMenuTarget()">
                            <option value="link" <?php 
        if (@$mod['linktype'] == 'link' || !isset($mod['mode'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_LINK'];
        ?>
</option>
                            <option value="content" <?php 
        if (@$mod['linktype'] == 'content') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_ARTICLE'];
        ?>
</option>
                            <option value="category" <?php 
        if (@$mod['linktype'] == 'category') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_PARTITION'];
        ?>
</option>
                            <?php 
        if ($inCore->isComponentInstalled('video')) {
            ?>
                            <option value="video_cat" <?php 
            if (@$mod['linktype'] == 'video_cat') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $_LANG['AD_OPEN_VIDEO_PARTITION'];
            ?>
</option>
                            <?php 
        }
        ?>
                            <option value="component" <?php 
        if (@$mod['linktype'] == 'component') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_COMPONENT'];
        ?>
</option>
                            <option value="blog" <?php 
        if (@$mod['linktype'] == 'blog') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_BLOG'];
        ?>
</option>
                            <option value="uccat" <?php 
        if (@$mod['linktype'] == 'uccat') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_CATEGORY'];
        ?>
</option>
                            <option value="photoalbum" <?php 
        if (@$mod['linktype'] == 'photoalbum') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_OPEN_ALBUM'];
        ?>
</option>
                        </select>
                    </div>

                    <div id="t_link" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'link' || $mod['linktype'] == 'ext' || !$mod['linktype']) {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_LINK'];
        ?>
</strong> <span class="hinttext">&mdash; <?php 
        echo $_LANG['AD_LINK_HINT'];
        ?>
 <b>http://</b></span>
                        </div>
                        <div>
                            <input name="link" type="text" id="link" size="50" style="width:100%" <?php 
        if (@$mod['linktype'] == 'link' || @$mod['linktype'] == 'ext') {
            echo 'value="' . $mod['link'] . '"';
        }
        ?>
/>
                        </div>
                    </div>

                    <div id="t_content" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'content') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_ARTICLE'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="content" id="content" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'content') {
            echo $inCore->getListItems('cms_content', $mod['linkid']);
        } else {
            echo $inCore->getListItems('cms_content');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <?php 
        if ($inCore->isComponentInstalled('video')) {
            ?>
                    <div id="t_video_cat" class="menu_target" style="display:<?php 
            if ($mod['linktype'] == 'video_cat') {
                echo 'block';
            } else {
                echo 'none';
            }
            ?>
">
                        <div>
                            <strong><?php 
            echo $_LANG['AD_CHECK_PARTITION'];
            ?>
</strong>
                        </div>
                        <div>
                            <select name="video_cat" id="video_cat" style="width:100%">
                                    <?php 
            if (@$mod['linktype'] == 'video_cat') {
                echo $inCore->getListItemsNS('cms_video_category', $mod['linkid']);
            } else {
                echo $inCore->getListItemsNS('cms_video_category');
            }
            ?>
                            </select>
                        </div>
                    </div>
                    <?php 
        }
        ?>

                    <div id="t_category" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'category') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_PARTITION'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="category" id="category" style="width:100%">
                                    <?php 
        if (@$mod['linktype'] == 'category') {
            echo $inCore->getListItemsNS('cms_category', $mod['linkid']);
        } else {
            echo $inCore->getListItemsNS('cms_category');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_component" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'component') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_COMPONENT'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="component" id="component" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'component') {
            echo $inCore->getListItems('cms_components', $mod['linkid'], 'title', 'asc', 'internal=0', 'link');
        } else {
            echo $inCore->getListItems('cms_components', 0, 'title', 'asc', 'internal=0', 'link');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_blog" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'blog') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_BLOG'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="blog" id="blog" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'blog') {
            echo $inCore->getListItems('cms_blogs', $mod['linkid'], 'title', 'asc', "owner='user'");
        } else {
            echo $inCore->getListItems('cms_blogs', 0, 'title', 'asc', "owner='user'");
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_uccat" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'uccat') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_CATEGORY'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="uccat" id="uccat" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'uccat') {
            echo $inCore->getListItems('cms_uc_cats', $mod['linkid']);
        } else {
            echo $inCore->getListItems('cms_uc_cats');
        }
        ?>
                            </select>
                        </div>
                    </div>

                    <div id="t_photoalbum" class="menu_target" style="display:<?php 
        if ($mod['linktype'] == 'photoalbum') {
            echo 'block';
        } else {
            echo 'none';
        }
        ?>
">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_CHECK_ALBUM'];
        ?>
</strong>
                        </div>
                        <div>
                           <select name="photoalbum" id="photoalbum" style="width:100%">
                                <?php 
        if (@$mod['linktype'] == 'photoalbum') {
            echo $inCore->getListItems('cms_photo_albums', $mod['linkid'], 'id', 'ASC', 'NSDiffer = ""');
        } else {
            echo $inCore->getListItems('cms_photo_albums', 0, 'id', 'ASC', 'NSDiffer = ""');
        }
        ?>
                            </select>
                        </div>
                    </div>

                </td>

                <td width="300" valign="top" style="background:#ECECEC;">

                    <?php 
        ob_start();
        ?>

                    {tab=<?php 
        echo $_LANG['AD_TAB_PUBLISH'];
        ?>
}

                        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                            <tr>
                                <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php 
        if ($mod['published'] || $do == 'add') {
            echo 'checked="checked"';
        }
        ?>
/></td>
                                <td><label for="published"><strong><?php 
        echo $_LANG['AD_MENU_POINT_PUBLIC'];
        ?>
</strong></label></td>
                            </tr>
                        </table>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_OPEN_POINT'];
        ?>
</strong>
                        </div>
                        <div>
                            <select name="target" id="target" style="width:100%">
                                <option value="_self" <?php 
        if (@$mod['target'] == '_self') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_SELF'];
        ?>
</option>
                                <option value="_parent"><?php 
        echo $_LANG['AD_PARENT'];
        ?>
</option>
                                <option value="_blank" <?php 
        if (@$mod['target'] == '_blank') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BLANK'];
        ?>
</option>
                                <option value="_top" <?php 
        if (@$mod['target'] == '_top') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_TOP'];
        ?>
</option>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['TEMPLATE'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_DESIGN_CHANGE'];
        ?>
</span>
                        </div>
                        <div>
                            <select name="template" id="template" style="width:100%">
                                <option value="0" <?php 
        if (@$mod['template'] == 0 || !$mod['template']) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_BY_DEFAULT'];
        ?>
</option>
                                <?php 
        $templates = cmsCore::getDirsList('/templates');
        foreach ($templates as $template) {
            echo '<option value="' . $template . '" ' . (@$mod['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>';
        }
        ?>
                            </select>
                        </div>

                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_ICON_PICTURE'];
        ?>
</strong><br/>
                            <span class="hinttext"><?php 
        echo $_LANG['AD_ICON_FILENAME'];
        ?>
</span>
                        </div>
                        <div>
                            <input name="iconurl" type="text" id="iconurl" size="30" value="<?php 
        echo @$mod['iconurl'];
        ?>
" style="width:100%"/>
                            <div>
                                <a id="iconlink" style="display:block;" href="javascript:showIcons()"><?php 
        echo $_LANG['AD_CHECK_ICON'];
        ?>
</a>
                                <div id="icondiv" style="display:none; padding:6px;border:solid 1px gray;background:#FFF">
                                    <div><?php 
        iconList();
        ?>
</div>
                                </div>
                            </div>
                        </div>
                        <div style="margin-top:15px">
                            <strong><?php 
        echo $_LANG['AD_CSS_CLASS'];
        ?>
</strong>
                        </div>
                        <div>
                            <input name="css_class" type="text" size="30" value="<?php 
        echo @$mod['css_class'];
        ?>
" style="width:100%"/>
                        </div>

                    {tab=<?php 
        echo $_LANG['AD_TAB_ACCESS'];
        ?>
}
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <?php 
        $groups = cmsUser::getGroups();
        $style = 'disabled="disabled"';
        $public = 'checked="checked"';
        if ($do == 'edit') {
            if ($mod['access_list']) {
                $public = '';
                $style = '';
                $access_list = $inCore->yamlToArray($mod['access_list']);
            }
        }
        ?>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php 
        echo $public;
        ?>
 />
                            </td>
                            <td><label for="is_public"><strong><?php 
        echo $_LANG['AD_SHARE'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            <?php 
        echo $_LANG['AD_VIEW_IF_CHECK'];
        ?>
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_GROUPS_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                            <?php 
        echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>';
        if ($groups) {
            foreach ($groups as $group) {
                echo '<option value="' . $group['id'] . '"';
                if ($do == 'edit' && $mod['access_list']) {
                    if (inArray($access_list, $group['id'])) {
                        echo 'selected="selected"';
                    }
                }
                echo '>';
                echo $group['title'] . '</option>';
            }
        }
        echo '</select>';
        ?>
                        </div>
                    </div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px">
                        <tr>
                            <td width="20">
                                <input name="is_lax" type="checkbox" id="is_lax" value="1" <?php 
        if (@$mod['is_lax']) {
            ?>
checked="checked"<?php 
        }
        ?>
 />
                            </td>
                            <td><label for="is_lax"><strong><?php 
        echo $_LANG['AD_ONLY_CHILD_ITEM'];
        ?>
</strong></label></td>
                        </tr>
                    </table>
                    {tab=<?php 
        echo $_LANG['AD_MENU'];
        ?>
}
                    <div style="padding:5px;padding-right:0px;">
                        <div>
                            <strong><?php 
        echo $_LANG['AD_MENU_TO_VIEW'];
        ?>
</strong><br />
                            <span class="hinttext">
                                <?php 
        echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];
        ?>
                            </span>
                        </div>
                        <div>
                        <select style="width: 99%" name="menu[]" size="9" multiple="multiple">
                            <?php 
        foreach ($menu_list as $menu) {
            ?>
                                <option value="<?php 
            echo $menu['id'];
            ?>
" <?php 
            if (@in_array($menu['id'], @$mod['menu'])) {
                echo 'selected="selected"';
            }
            ?>
>
                                    <?php 
            echo $menu['title'];
            ?>
                                </option>
                            <?php 
        }
        ?>
                        </select>
                        </div>
                    </div>
                    {/tabs}

                    <?php 
        echo jwTabs(ob_get_clean());
        ?>

                </td>

            </tr>
        </table>

        <p>
            <input name="add_mod" type="button" onclick="submitItem()" id="add_mod" value="<?php 
        echo $_LANG['SAVE'];
        ?>
 " />
            <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.location.href='index.php?view=menu';" />
            <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
            <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
    </form>
    <?php 
    }
}
Ejemplo n.º 22
0
function applet_components() {
    $inCore = cmsCore::getInstance();
    $inDB   = cmsCore::c('db');
    $inUser = cmsCore::c('user');

    global $_LANG;

    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/components', $adminAccess)) { cpAccessDenied(); }
    
    cmsCore::c('page')->setTitle($_LANG['AD_COMPONENTS']);
    cpAddPathway($_LANG['AD_COMPONENTS'], 'index.php?view=components');
    
    $do = cmsCore::request('do', 'str', 'list');
    
    $id   = cmsCore::request('id', 'int', 0);
    $link = cmsCore::request('link', 'str', '');
    
    if (!empty($link)) { $_REQUEST['id'] = $id = $inCore->getComponentId($link); }

    if ($do != 'list') {
        $com = $inCore->getComponent($id);
        if (!$com) { cmsCore::error404(); }
        if (!cmsUser::isAdminCan('admin/com_'. $com['link'], $adminAccess)) { cpAccessDenied(); }
    }

    if ($do == 'show') {
        cmsCore::c('db')->setFlag('cms_components', $id, 'published', '1');
        cmsCore::halt('1');
    }
    
    if ($do == 'hide') {
        cmsCore::c('db')->setFlag('cms_components', $id, 'published', '0');
        cmsCore::halt('1');
    }
    
    if ($do == 'config') {
        $file      = PATH .'/admin/components/'. $com['link'] .'/backend.php';
        $file_cfg  = PATH .'/admin/components/'. $com['link'] .'/backend_cfg.php';
        $file_json = PATH .'/admin/components/'. $com['link'] .'/backend_cfg.json';
        
        cmsCore::loadLanguage('components/'. $com['link']);
        cmsCore::loadLanguage('admin/components/'. $com['link']);
        
        cpAddPathway($com['title'] .' v'. $com['version'], '?view=components&do=config&id='. $com['id']);

        if (file_exists($file)) {
            include($file);
            return;
        } else if (file_exists($file_cfg) || file_exists($file_json)) {
            echo '<h3>'. $_LANG['AD_SETTINGS'] .': '. $com['title'] .'</h3>';
            
            if (file_exists($file_cfg)) {
                include($file_cfg);
            } else {
                $com_cfg = json_decode(file_get_contents($file_json));
            }
            
            if (!empty($com_cfg)) {
                echo '<form action="index.php?view=components&do=save_config&id='. $com['id'] .'" method="POST">';
                    echo '<div style="width:650px;">'. cmsCore::c('form_gen')->generateForm($com_cfg, $inCore->loadComponentConfig($com['link'])) .'</div>';
                    echo '<div style="margin-top:6px;">';
                        echo '<input type="submit" class="btn btn-primary" name="save" value="'. $_LANG['SAVE'] .'" /> ';
                        echo '<input type="button" class="btn btn-default" name="back" value="'. $_LANG['CANCEL'] .'" onclick="window.history.go(-1)" />';
                    echo '</div>';
                echo '</form>';
            }
            
            return;
        }
        
        cmsCore::redirect('index.php?view=components');
    }

    if ($do == 'save_config') {
        if (cmsUser::checkCsrfToken()) {
            $file_cfg  = PATH .'/admin/components/'. $com['link'] .'/backend_cfg.php';
            $file_json = PATH .'/admin/components/'. $com['link'] .'/backend_cfg.json';

            if (file_exists($file_cfg) || file_exists($file_json)) {
                if (file_exists($file_cfg)) {
                    include($file_cfg);
                } else {
                    $com_cfg = json_decode(file_get_contents($file_json), true);
                }
                
                if (!empty($com_cfg)) {
                    $config = cmsCore::c('form_gen')->requestForm($com_cfg);
                    
                    $inCore->saveComponentConfig($com['link'], $config);

                    cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');

                    cmsCore::redirect('?view=components&do=config&id='. $id);
                }
            }
        }
        
        cmsCore::error404();
    }
    
    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'install.gif', 'title' => $_LANG['AD_INSTALL_COMPONENTS'], 'link' => '?view=install&do=component' ),
            array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=components' )
        );
        
        cpToolMenu($toolmenu);

        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
            array( 'title' => $_LANG['TITLE'], 'field' => 'title','link' => '?view=components&do=config&id=%id%', 'width' => '' ),
            array( 'title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '80' ),
            array( 'title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '80' ),
            array( 'title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '200' ),
            array( 'title' => $_LANG['AD_LINK'], 'field' => 'link', 'width' => '100' )
        );

        $actions = array(
            array( 'title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=components&do=config&id=%id%', 'condition' => 'cpComponentHasConfig'),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=install&do=remove_component&id=%id%', 'condition' => 'cpComponentCanRemove', 'confirm' => $_LANG['AD_DELETED_COMPONENT_FROM'])
        );
        
        $where = '';

        if (cmsCore::c('user')->id > 1) {
            foreach($adminAccess as $key => $value){
                if (mb_strstr($value, 'admin/com_')) {
                    if ($where) { $where .= ' OR '; }
                    $value = str_replace('admin/com_', '', $value);
                    $where .= "link='". $value ."'";
                }
            }
        }
        
        if (!$where) { $where = 'id>0'; }
        
        cpListTable('cms_components', $fields, $actions, $where);
    }
}
Ejemplo n.º 23
0
function applet_cron() {
    cmsCore::loadClass('cron');
    
    global $_LANG;
    
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_CRON_MISSION']);
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    cpAddPathway($_LANG['AD_CRON_MISSION'], 'index.php?view=cron');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', '0');
    
    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'new.gif', 'title' => $_LANG['AD_CREATE_CRON_MISSION'], 'link' => '?view=cron&do=add' )
        );

        cpToolMenu($toolmenu);

        $items = cmsCron::getJobs(false);

        $tpl_file   = 'admin/cron.php';
        $tpl_dir    = file_exists(TEMPLATE_DIR . $tpl_file) ? TEMPLATE_DIR : DEFAULT_TEMPLATE_DIR;

        include($tpl_dir . $tpl_file);
    }

    if ($do == 'show') {
        if ($id) { cmsCron::jobEnabled($id, true);  }
        cmsCore::halt('1');
    }
    
    if ($do == 'hide') {
        if ($id) { cmsCron::jobEnabled($id, false);  }
        cmsCore::halt('1');
    }
    
    if ($do == 'delete') {
        if ($id) { cmsCron::removeJobById($id); }
        cmsCore::redirect('index.php?view=cron');
    }
    
    if ($do == 'execute') {
        if ($id) { $job_result = cmsCron::executeJobById($id); }

        if ($job_result) {
            cmsCore::addSessionMessage($_LANG['AD_MISSION_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_MISSION_ERROR'], 'error');
        }

        cmsCore::redirect('index.php?view=cron');
    }
    
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $job_name     = cmsCore::request('job_name', 'str');
        $comment      = cmsCore::request('comment', 'str');
        $job_interval = cmsCore::request('job_interval', 'int');
        $enabled      = cmsCore::request('enabled', 'int');
        $component    = cmsCore::request('component', 'str');
        $model_method = cmsCore::request('model_method', 'str');
        $custom_file  = cmsCore::request('custom_file', 'str');
        $custom_file  = (mb_stripos($custom_file, 'image') || mb_stripos($custom_file, 'upload') || mb_stripos($custom_file, 'cache')) ? '' : $custom_file;
        $custom_file  = preg_replace('/\.+\//', '', $custom_file);
        $class_name   = cmsCore::request('class_name', 'str');
        $class_method = cmsCore::request('class_method', 'str');

        cmsCron::registerJob(
            $job_name,
            array(
                'interval' => $job_interval,
                'component' => $component,
                'model_method' => $model_method,
                'comment' => $comment,
                'custom_file' => $custom_file,
                'enabled' => $enabled,
                'class_name' => $class_name,
                'class_method' => $class_method
            )
        );

        cmsCore::redirect('index.php?view=cron');
    }
    
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        if (!$id) { cmsCore::halt(); }

        $job_name     = cmsCore::request('job_name', 'str');
        $comment      = cmsCore::request('comment', 'str');
        $job_interval = cmsCore::request('job_interval', 'int');
        $enabled      = cmsCore::request('enabled', 'int');
        $component    = cmsCore::request('component', 'str');
        $model_method = cmsCore::request('model_method', 'str');
        $custom_file  = cmsCore::request('custom_file', 'str');
        $custom_file  = (mb_stripos($custom_file, 'image') || mb_stripos($custom_file, 'upload') || mb_stripos($custom_file, 'cache')) ? '' : $custom_file;
        $custom_file  = preg_replace('/\.+\//', '', $custom_file);
        $class_name   = cmsCore::request('class_name', 'str');
        $class_method = cmsCore::request('class_method', 'str');

        cmsCron::updateJob(
            $id,
            array(
                'job_name' => $job_name,
                'job_interval' => $job_interval,
                'component' => $component,
                'model_method' => $model_method,
                'comment' => $comment,
                'custom_file' => $custom_file,
                'is_enabled' => $enabled,
                'class_name' => $class_name,
                'class_method' => $class_method
            )
        );

        cmsCore::redirect('index.php?view=cron');
    }
    
    if ($do == 'edit' || $do == 'add') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );

        cpToolMenu($toolmenu);
        
        if ($do == 'edit') {
            $mod = cmsCron::getJobById($id);
            if (!$mod) { cmsCore::error404(); }
            
            echo '<h3>'. $_LANG['AD_EDIT_MISSION'] .'</h3>';
            cpAddPathway($mod['job_name'], 'index.php?view=cron&do=edit&id='. $mod['id']);
        } else {
            echo '<h3>'. $_LANG['AD_CREATE_CRON_MISSION'] .'</h3>';
            cpAddPathway($_LANG['AD_CREATE_CRON_MISSION'], 'index.php?view=cron&do=add');
            $mod = array();
	}
?>
<form action="index.php?view=cron" method="post" enctype="multipart/form-data" name="addform" id="addform">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:650px;">
        <div class="form-group">
            <label><?php echo $_LANG['TITLE']; ?>:</label>
            <input type="text" class="form-control" name="job_name" value="<?php echo cmsCore::getArrVal($mod, 'job_name', ''); ?>" />
            <div class="help-block"><?php echo $_LANG['AD_ONLY_LATIN']; ?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['DESCRIPTION']; ?>:</label>
            <input type="text" class="form-control" name="comment" maxlength="200" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'comment', '')); ?>" />
            <div class="help-block"><?php echo $_LANG['AD_ONLY_200_SIMBOLS']; ?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_MISSION_ON']; ?>:</label>
            <div class="btn-group" data-toggle="buttons" style="float:right;">
                <label class="btn btn-default <?php if (cmsCore::getArrVal($mod, 'is_enabled')) { echo 'active'; } ?>">
                    <input type="radio" name="enabled" <?php if ($mod['is_enabled']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                </label>
                <label class="btn btn-default <?php if (!cmsCore::getArrVal($mod, 'is_enabled')) { echo 'active'; } ?>">
                    <input type="radio" name="enabled" <?php if (!$mod['is_enabled']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                </label>
            </div>
            <div class="help-block"><?php echo $_LANG['AD_MISSION_OFF']; ?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_MISSION_INTERVAL']; ?> (<?php echo $_LANG['HOUR1']; ?>):</label>
            <input type="number" class="form-control" name="job_interval" min="0" value="<?php echo cmsCore::getArrVal($mod, 'job_interval', ''); ?>" /> 
            <div class="help-block"><?php echo $_LANG['AD_MISSION_PERIOD']; ?></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_PHP_FILE']; ?>:</label>
            <input type="text" class="form-control" name="custom_file" maxlength="250" value="<?php echo cmsCore::getArrVal($mod, 'custom_file', ''); ?>" /> 
            <div class="help-block"><?php echo $_LANG['AD_EXAMPLE'] ; ?>: <b>includes/myphp/test.php</b></div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_COMPONENT']; ?>:</label>
            <input type="text" class="form-control" name="component" maxlength="250" value="<?php echo cmsCore::getArrVal($mod, 'component', ''); ?>" /> 
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_METHOD']; ?>:</label>
            <input type="text" class="form-control" name="model_method" maxlength="250" value="<?php echo cmsCore::getArrVal($mod, 'model_method', ''); ?>" /> 
        </div>
        
        <div class="form-group">
            <label><?php echo icms_ucfirst($_LANG['AD_CLASS']); ?></label>
            <input type="text" class="form-control" name="class_name" maxlength="50" value="<?php echo cmsCore::getArrVal($mod, 'class_name', ''); ?>" />
            <div class="help-block">
                <span style="color:#666;font-family: mono"><?php echo $_LANG['AD_FILE_CLASS']; ?></span>, <?php echo $_LANG['AD_EXAMPLE']; ?> <b>actions|cmsActions</b>&nbsp;<?php echo $_LANG['OR']; ?><br/>
                <span style="color:#666;font-family: mono"><?php echo $_LANG['AD_CLASS']; ?></span>, <?php echo $_LANG['AD_EXAMPLE']; ?> <b>cmsDatabase</b>
            </div>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_CLASS_METHOD']; ?>:</label>
            <input type="text" class="form-control" name="class_method" maxlength="50" value="<?php echo cmsCore::getArrVal($mod, 'class_method', ''); ?>" /> 
        </div>
    </div>
    
    <div>
        <?php if ($do == 'edit') { ?>
            <input type="hidden" name="do" value="update" />
            <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['AD_SAVE_CRON_MISSION']; ?>" />
        <?php } else { ?>
            <input type="hidden" name="do" value="submit" />
            <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['AD_CREATE_CRON_MISSION'] ; ?>" />
        <?php } ?>
        
        <input type="button" class="btn btn-default" name="back2" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />
          
        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'. $mod['id'] .'" />';
            }
        ?>
        </div>
</form>
<?php
   }
}
Ejemplo n.º 24
0
function applet_checksystem() {
    global $_LANG;
    
    global $adminAccess;
    
    if (!cmsUser::isAdminCan('admin/checksystem', $adminAccess)) { cpAccessDenied(); }
    
    cmsCore::c('page')->setTitle($_LANG['AD_CHECK_SYSTEM']);

    cpAddPathway($_LANG['AD_CHECK_SYSTEM'], 'index.php?view=checksystem');

    $do = cmsCore::request('do', array('last_check', 'save', 'start', 'start_scan'), 'last_check');
    
    $toolmenu = array(
        array( 'icon' => 'liststuff.gif', 'title' => $_LANG['AD_LAST_CHECK_RESULT'], 'link' => 'index.php?view=checksystem&do=last_check' ),
        array( 'icon' => 'start.png', 'title' => $_LANG['AD_START_NEW_CHECK'], 'link' => 'index.php?view=checksystem&do=start' ),
        array( 'icon' => 'save.png', 'title' => $_LANG['AD_CREATE_NEW_IMG'], 'link' => 'index.php?view=checksystem&do=save' )
    );

    cpToolMenu($toolmenu, 'last_check', 'do');
    
    if ($do == 'last_check') {
        cpAddPathway($_LANG['AD_LAST_CHECK_RESULT'], 'index.php?view=checksystem&do=last_check');
        
        $data = false;
        if (file_exists(PATH .'/cache/last_check_result.serialize')) {
            $data = unserialize(file_get_contents(PATH .'/cache/last_check_result.serialize'));
        }
        
        echo '<p>'. $_LANG['AD_TIME_LAST_CHECK'] .' <b>'. (isset($data['date']) ? $data['date'] : $_LANG['AD_NEVER']) .'</b>, '. $_LANG['AD_IMG'] .': <b>'. (isset($data['img']) ? $data['img'] : '') .'</b></p>';
        
        if (!empty($data)) {
            echo '<div class="uitabs"><ul id="tabs"><li><a href="#tab1"><span>'. $_LANG['AD_MODIFY_FILES'] .'</span></a></li><li><a href="#tab2"><span>'. $_LANG['AD_NEW_FILES'] .'</span></a></li><li><a href="#tab3"><span>'. $_LANG['AD_DELETED_FILES'] .'</span></a></li></ul>';
            
                echo '<div id="tab1">';
                    if (!empty($data['modified_files'])) {
                        foreach ($data['modified_files'] as $path) {
                            echo '<div>'. $path .'</div>';
                        }
                    } else {
                        echo '<p>'. $_LANG['AD_MODIFY_FILES_NOT_FOUND'] .'</p>';
                    }
                echo '</div>';

                echo '<div id="tab2">';
                    if (!empty($data['new_files'])) {
                        foreach ($data['new_files'] as $path) {
                            echo '<div>'. $path .'</div>';
                        }
                    } else {
                        echo '<p>'. $_LANG['AD_NEW_FILES_NOT_FOUND'] .'</p>';
                    }
                echo '</div>';
                
                echo '<div id="tab3">';
                    if (!empty($data['old_files'])) {
                        foreach ($data['old_files'] as $path) {
                            echo '<div>'. $path .'</div>';
                        }
                    } else {
                        echo '<p>'. $_LANG['AD_DELETED_FILES_NOT_FOUND'] .'</p>';
                    }
                echo '</div>';
            
            echo '</div>';
        } else {
            echo '<p>'. $_LANG['AD_LAST_CHECK_RESULT_NOT_FOUND'] .'</p>';
        }
    }
    
    if ($do == 'start') {
        cpAddPathway($_LANG['AD_START_NEW_CHECK']);
        
        $imageFiles = getSystemImageFiles();
?>
<form class="form-horizontal" role="form" action="/admin/index.php?view=checksystem&do=start_scan" method="post" name="CFGform" target="_self" style="margin-bottom:30px">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:750px;">
        <div class="form-group">
            <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SELECT_IMG']; ?></label>
            <div class="col-sm-7">
                <select id="image" class="form-control" name="image">
                    <?php foreach ($imageFiles as $if) { ?>
                        <option value="<?php echo $if; ?>"><?php echo $if; ?></option>
                    <?php } ?>
                </select>
            </div>
        </div>
        
        <div>
            <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['AD_START']; ?>" />
            <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />
        </div>
    </div>
</form>
<?php
    }
    
    if ($do == 'start_scan') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $image = cmsCore::request('image', 'str', '');
        
        if (empty($image) || !file_exists(PATH .'/cache/system/'. $image)) {
            cmsCore::error404();
        }
        
        genSystemImage(PATH);
        
        $old_files = unserialize(file_get_contents(PATH .'/cache/system/'. $image));
        
        $data = array(
            'modified_files' => array(),
            'new_files'      => array(),
            'old_files'      => array()
        );
        
        foreach ($GLOBALS['SYSTEM_IMAGE'] as $k=>$v) {
            if (isset($old_files[$k])) {
                if ($old_files[$k] != $v) {
                    $data['modified_files'][] = $k;
                }
                unset($old_files[$k]);
            } else {
                $data['new_files'][] = $k;
            }
            unset($GLOBALS['SYSTEM_IMAGE'][$k]);
        }
        
        foreach ($old_files as $k => $v) {
            $data['old_files'][] = $k;
        }
        
        $data['date'] = date('Y-m-d H:i:s');
        $data['img']  = $image;
        
        file_put_contents(PATH .'/cache/last_check_result.serialize', serialize($data));
        
        cmsCore::addSessionMessage($_LANG['AD_CHECK_SYSTEM_SUCCES'], 'success');
        cmsCore::redirect('index.php?view=checksystem');
    }
    
    if ($do == 'save') {
        $GLOBALS['SYSTEM_IMAGE'] = array();
        
        genSystemImage(PATH);
        
        $d = date('Y-m-d_H-i-s');
        
        file_put_contents(PATH . '/cache/system/systemImage_'. $d .'.serialize', serialize($GLOBALS['SYSTEM_IMAGE']));
        
        unset($GLOBALS['SYSTEM_IMAGE']);
        
        cmsCore::addSessionMessage($_LANG['AD_NEW_IMG_GENERATED'] .': /cache/system/systemImage_'. $d .'.serialize', 'success');
        cmsCore::redirectBack();
    }
}
Ejemplo n.º 25
0
function applet_users() {
    $inCore = cmsCore::getInstance();
    cmsCore::loadClass('actions');
    cmsCore::loadModel('users');
    $model = new cms_model_users();

    // подключаем язык компонента регистрации
    cmsCore::loadLanguage('components/registration');

    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) { cpAccessDenied(); }

    cmsCore::c('page')->setTitle($_LANG['AD_USERS']);
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');

    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', 0);

    if ($do == 'list') {
        $toolmenu = array(
            array( 'icon' => 'useradd.gif', 'title' => $_LANG['AD_USER_ADD'], 'link' => '?view=users&do=add' ),
            array( 'icon' => 'useredit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=users&do=edit&multiple=1');" ),
            array( 'icon' => 'userdelete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:if(confirm('". $_LANG['AD_IF_USERS_SELECT_REMOVE'] ."')) { checkSel('?view=users&do=delete&multiple=1'); }" ),
            array( 'icon' => 'usergroup.gif', 'title' => $_LANG['AD_USERS_GROUP'], 'link' => '?view=usergroups' ),
            array( 'icon' => 'userbanlist.gif', 'title' => $_LANG['AD_BANLIST'], 'link' => '?view=userbanlist' ),
            array( 'icon' => 'user_go.png', 'title' => $_LANG['AD_USERS_SELECT_ACTIVATE'], 'link' => "javascript:if(confirm('". $_LANG['AD_IF_USERS_SELECT_ACTIVATE'] ."')) { checkSel('?view=users&do=activate&multiple=1'); }" ),
            array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=users' )
        );
        
        cpToolMenu($toolmenu);
        
        $fields = array(
            array( 'title' => 'id', 'field' => 'id', 'width' => '40'  ),
            array( 'title' => $_LANG['LOGIN'], 'field' => 'login', 'width' => '100', 'link' => '?view=users&do=edit&id=%id%', 'filter' => 12 ),
            array( 'title' => $_LANG['NICKNAME'], 'field' => 'nickname', 'width' => '', 'link' => '?view=users&do=edit&id=%id%', 'filter' => 12 ),
            array( 'title' => $_LANG['AD_RATING'], 'field' => array( 'rating', 'id' ), 'width' => '70', 'prc' => 'setRating' ),
            array( 'title' => $_LANG['AD_GROUP'], 'field' => 'group_id', 'width' => '110', 'prc' => 'cpGroupById', 'filter' => 1, 'filterlist' => cpGetList('cms_user_groups') ),
            array( 'title' => $_LANG['EMAIL'], 'field' => 'email', 'width' => '120' ),
            array( 'title' => $_LANG['AD_REGISTRATION_DATE'], 'field' => 'regdate', 'width' => '100' ),
            array( 'title' => $_LANG['AD_LAST_LOGIN'], 'field' => 'logdate', 'width' => '100' ),
            array( 'title' => $_LANG['AD_LAST_IP'], 'field' => 'last_ip', 'width' => '90', 'prc' => 'getIpLink' ),
            array( 'title' => $_LANG['AD_IS_LOCKED'], 'field' => 'is_locked', 'width' => '110', 'prc' => 'viewAct' ),
            array( 'title' => $_LANG['AD_IS_DELETED'], 'field' => 'is_deleted', 'width' => '80', 'prc' => 'viewDel' )
        );
        
        $actions = array(
            array( 'title' => $_LANG['AD_PROFILE'], 'icon' => 'profile.gif', 'link' => '/users/%login%' ),
            array( 'title' => $_LANG['AD_BANNED'], 'icon' => 'ban.gif', 'link' => '?view=userbanlist&do=add&to=%id%' ),
            array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_IS_USER_DELETE'], 'link' => '?view=users&do=delete&id=%id%' ),
            array( 'title' => $_LANG['AD_FOREVER_USER_DELETE'], 'icon' => 'off.gif', 'confirm' => $_LANG['AD_IF_FOREVER_USER_DELETE'], 'link' => '?view=users&do=delete_full&id=%id%' )
        );
        
        cpListTable('cms_users', $fields, $actions, '1=1', 'regdate DESC');
    }
    
    if ($do == 'rerating') {
        $user_id = cmsCore::request('user_id', 'int');
        if (!$user_id) { cmsCore::redirectBack(); }
        
        $rating = cmsUser::getRating($user_id);

        $user_sql = "UPDATE cms_users
                     SET rating = ". $rating ."
                     WHERE id = '". $user_id ."'";

        cmsCore::c('db')->query($user_sql);
        
        cmsCore::redirectBack();
    }
    
    if ($do == 'activate') {
        $user_ids = cmsCore::request('item', 'array_int');
        if (!$user_ids) { cmsCore::redirectBack(); }

        foreach ($user_ids as $user_id) {
            $code = cmsCore::c('db')->get_field('cms_users_activate', "user_id = '". $user_id ."'", 'code');

            $sql = "UPDATE cms_users SET is_locked = 0 WHERE id = '". $user_id ."'";
            cmsCore::c('db')->query($sql);

            $sql = "DELETE FROM cms_users_activate WHERE code = '". $code ."'";
            cmsCore::c('db')->query($sql);

            cmsCore::callEvent('USER_ACTIVATED', $user_id);

            // Регистрируем событие
            cmsActions::log(
                'add_user',
                array(
                    'object' => '',
                    'user_id' => $user_id,
                    'object_url' => '',
                    'object_id' => $user_id,
                    'target' => '',
                    'target_url' => '',
                    'target_id' => 0,
                    'description' => ''
                )
            );
        }
        
        cmsCore::redirectBack();
    }
    
    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                $model->deleteUser($id);
            }
        } else {
            $model->deleteUsers(cmsCore::request('item', 'array_int', array()));
        }
        
        cmsCore::redirectBack();
    }

    if ($do == 'delete_full') {
        $model->deleteUser($id, true);
        cmsCore::redirectBack();
    }

    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }

        $types = array(
            'login' => array( 'login', 'str', '' ),
            'nickname' => array( 'nickname', 'str', '', 'htmlspecialchars' ),
            'email' => array( 'email', 'email', '' ),
            'group_id' => array( 'group_id', 'int', 1 ),
            'is_locked' => array( 'is_locked', 'int', 0 ),
            'password' => array( 'pass', 'str', '', 'stripslashes' ),
            'pass2' => array( 'pass2', 'str', '', 'stripslashes' )
        );

        $items = cmsCore::getArrayFromRequest($types);

        $errors = false;

        // проверяем логин
        if (mb_strlen($items['login']) < 2 ||
                mb_strlen($items['login']) > 15 ||
                is_numeric($items['login']) ||
                !preg_match("/^([a-zA-Z0-9])+$/ui", $items['login'])) {
            cmsCore::addSessionMessage($_LANG['ERR_LOGIN'], 'error');
            $errors = true;
        }

        // проверяем пароль
        if ($do == 'submit') {
            if (!$items['password']) {
                cmsCore::addSessionMessage($_LANG['TYPE_PASS'], 'error');
                $errors = true;
            }
        }
        
        if ($items['password'] && !$items['pass2']) {
            cmsCore::addSessionMessage($_LANG['TYPE_PASS_TWICE'], 'error');
            $errors = true;
        }
        
        if ($items['password'] && $items['pass2'] && mb_strlen($items['password']) < 6) {
            cmsCore::addSessionMessage($_LANG['PASS_SHORT'], 'error');
            $errors = true;
        }
        
        if ($items['password'] && $items['pass2'] && $items['password'] != $items['pass2']) {
            cmsCore::addSessionMessage($_LANG['WRONG_PASS'], 'error');
            $errors = true;
        }

        // никнейм
        if (mb_strlen($items['nickname']) < 2) {
            cmsCore::addSessionMessage($_LANG['SHORT_NICKNAME'], 'error');
            $errors = true;
        }
        
        // Проверяем email
        if (!$items['email']) {
            cmsCore::addSessionMessage($_LANG['ERR_EMAIL'], 'error');
            $errors = true;
        }

        // проверяем есть ли такой пользователь
        if ($do == 'submit') {
            $user_exist = cmsCore::c('db')->get_fields('cms_users', "(login LIKE '". $items['login'] ."' OR email LIKE '". $items['email'] ."') AND is_deleted = 0", 'login');
            if ($user_exist) {
                if ($user_exist['login'] == $items['login']) {
                    cmsCore::addSessionMessage($_LANG['LOGIN'] .' "'. $items['login'] .'" '. $_LANG['IS_BUSY'], 'error');
                    $errors = true;
                } else {
                    cmsCore::addSessionMessage($_LANG['EMAIL_IS_BUSY'], 'error');
                    $errors = true;
                }
            }
        }

        if ($errors) {
            if ($do == 'submit') {
                cmsUser::sessionPut('items', $items);
            }
            cmsCore::redirectBack();
        }

        if ($do == 'submit') {
            $items['regdate']  = date('Y-m-d H:i:s');
            $items['logdate']  = date('Y-m-d H:i:s');
            $items['password'] = md5($items['password']);

            $items['user_id'] = cmsCore::c('db')->insert('cms_users', $items);
            if (!$items['user_id']) { cmsCore::error404(); }

            cmsCore::c('db')->insert('cms_user_profiles', $items);

            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            cmsCore::redirect('?view=users');
        } else {
            // главного админа может редактировать только он сам
            if ($id == 1 && cmsCore::c('user')->id != $id) {
                cmsCore::error404();
            }
            
            if ($id == 1) {
                unset($items['group_id']);
                unset($items['is_locked']);
            }

            if (!$items['password']) {
                unset($items['password']);
            } else {
                $items['password'] = md5($items['password']);
            }

            cmsCore::c('db')->update('cms_users', $items, $id);

            cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('index.php?view=users');
            } else {
                cmsCore::redirect('index.php?view=users&do=edit');
            }
        }
    }

    if ($do == 'edit' || $do == 'add') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );

        cpToolMenu($toolmenu);

        if ($do == 'edit') {
            if (cmsCore::inRequest('multiple')){
                if (cmsCore::inRequest('item')){
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist']) == 0) {
                   unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }

            $mod = cmsCore::c('db')->get_fields('cms_users', "id = '". $item_id ."'", '*');
            if (!$mod) { cmsCore::error404(); }

            echo '<h3>'. $_LANG['AD_USER_EDIT'] .' '. $ostatok .'</h3>';
            cpAddPathway($mod['nickname']);

        } else {
            $mod = cmsUser::sessionGet('items');
            if ($mod) { cmsUser::sessionDel('items'); }
            cpAddPathway($_LANG['AD_USER_ADD']);
        }
        
        cmsCore::c('page')->addHeadJS('components/registration/js/check.js');
?>
<form action="index.php?view=users" method="post" enctype="multipart/form-data" name="addform" id="addform">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    
    <div style="width:500px;">
        <div class="form-group">
            <label><?php echo $_LANG['LOGIN']; ?>:</label>
            <input type="text" id="logininput" class="form-control" name="login" value="<?php echo cmsCore::getArrVal($mod, 'login', ''); ?>" onchange="checkLogin()" />
            <?php if ($do == 'edit') { echo '<div class="help-block" style="text-align:right;"><a target="_blank" href="/users/'. $mod['login'] .'" title="'. $_LANG['AD_USER_PROFILE'] .'">'. $_LANG['AD_USER_PROFILE'] .'</a></div>'; } ?>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['NICKNAME']; ?>:</label>
            <input type="text" id="login" class="form-control" name="nickname" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'nickname', '')); ?>" />
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['EMAIL']; ?>:</label>
            <input type="text" id="nickname" class="form-control" name="email" value="<?php echo cmsCore::getArrVal($mod, 'email', ''); ?>" />
        </div>
        
        <div class="form-group">
            <label><?php if ($do == 'edit') { echo $_LANG['AD_NEW_PASS']; } else { echo $_LANG['PASS']; } ?></label>
            <input type="password" id="pass" class="form-control" name="pass" />
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['REPEAT_PASS']; ?>:</label>
            <input type="password" id="pass2" class="form-control" name="pass2" />
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_GROUP']; ?>:</label>
            <select id="group_id" class="form-control" name="group_id">
                <?php
                    echo $inCore->getListItems('cms_user_groups', cmsCore::getArrVal($mod, 'group_id', 0));
                ?>
            </select>
            <?php if ($do == 'edit') { echo '<div class="help-block" style="text-align:right;"><a target="_blank" href="?view=usergroups&do=edit&id='. $mod['group_id'] .'">'. $_LANG['EDIT'] .'</a></div>'; } ?>
        </div>
        
        <div class="form-group">
            <label><?php echo $_LANG['AD_IF_ACCAUNT_LOCK']; ?></label>
            <div class="btn-group" data-toggle="buttons" style="float:right;">
                <label class="btn btn-default <?php if ($mod['is_locked']) { echo 'active'; } ?>">
                    <input type="radio" name="is_locked" <?php if ($mod['is_locked']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?>
                </label>
                <label class="btn btn-default <?php if (!$mod['is_locked']) { echo 'active'; } ?>">
                    <input type="radio" name="is_locked" <?php if (!$mod['is_locked']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?>
                </label>
            </div>
        </div>
    </div>

    <div>
        <?php if ($do == 'edit') { ?>
            <input type="hidden" name="do" value="update" />
            <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['SAVE']; ?>" />
        <?php } else { ?>
            <input type="hidden" name="do" value="submit" />
            <input type="submit" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['AD_USER_ADD']; ?>" />
        <?php } ?>
        <input type="button" class="btn btn-default" name="back2" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" />

        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
<?php
   }
}
Ejemplo n.º 26
0
function applet_plugins()
{
    global $_LANG;
    $inCore = cmsCore::getInstance();
    cmsCore::c('page')->setTitle($_LANG['AD_PLUGINS']);
    cpAddPathway($_LANG['AD_PLUGINS'], 'index.php?view=plugins');
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
        cpAccessDenied();
    }
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    if ($do == 'hide') {
        cmsCore::c('db')->setFlag('cms_plugins', $id, 'published', '0');
        cmsCore::halt('1');
    }
    if ($do == 'show') {
        cmsCore::c('db')->setFlag('cms_plugins', $id, 'published', '1');
        cmsCore::halt('1');
    }
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'install.gif', 'title' => $_LANG['AD_INSTALL_PLUGINS'], 'link' => '?view=install&do=plugin'), array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=plugins'));
        cpToolMenu($toolmenu);
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['TITLE'], 'field' => 'title', 'link' => '?view=plugins&do=config&id=%id%', 'width' => '250'), array('title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => ''), array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '160'), array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '80'), array('title' => $_LANG['AD_FOLDER'], 'field' => 'plugin', 'width' => '100'), array('title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '80'));
        $actions = array(array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=plugins&do=config&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'link' => '?view=install&do=remove_plugin&id=%id%', 'confirm' => $_LANG['AD_REMOVE_PLUGIN_FROM']));
        cpListTable('cms_plugins', $fields, $actions);
    }
    if ($do == 'save_config') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $plugin_name = cmsCore::request('plugin', 'str', 0);
        $plugin = $inCore->loadPlugin($plugin_name);
        $plugin_cfg_fields = $plugin->getConfigFields();
        if (empty($plugin_cfg_fields)) {
            $config = cmsCore::request('config', 'array_str');
        } else {
            $config = cmsCore::c('form_gen')->requestForm($plugin->getConfigFields());
        }
        if (!$config || !$plugin_name) {
            cmsCore::redirectBack();
        }
        $inCore->savePluginConfig($plugin_name, $config);
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=plugins');
    }
    if ($do == 'save_auto_config') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $plugin_name = cmsCore::request('plugin', 'str', '');
        $xml_file = PATH . '/plugins/' . $plugin_name . '/backend.xml';
        if (!file_exists($xml_file)) {
            cmsCore::error404();
        }
        $cfg = array();
        $backend = simplexml_load_file($xml_file);
        foreach ($backend->params->param as $param) {
            $name = (string) $param['name'];
            $type = (string) $param['type'];
            $default = (string) $param['default'];
            switch ($param['type']) {
                case 'number':
                    $value = cmsCore::request($name, 'int', $default);
                    break;
                case 'string':
                    $value = cmsCore::request($name, 'str', $default);
                    break;
                case 'html':
                    $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default));
                    break;
                case 'flag':
                    $value = cmsCore::request($name, 'int', 0);
                    break;
                case 'list':
                    $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                    break;
                case 'list_function':
                    $value = cmsCore::request($name, 'str', $default);
                    break;
                case 'list_db':
                    $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default);
                    break;
            }
            $cfg[$name] = $value;
        }
        if (!$cfg || !$plugin_name) {
            cmsCore::redirectBack();
        }
        $inCore->savePluginConfig($plugin_name, $cfg);
        cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success');
        cmsCore::redirect('index.php?view=plugins');
    }
    if ($do == 'config') {
        $plugin_name = $inCore->getPluginById($id);
        if (!$plugin_name) {
            cmsCore::error404();
        }
        $plugin = $inCore->loadPlugin($plugin_name);
        $config = $inCore->loadPluginConfig($plugin_name);
        $plugin_cfg_fields = $plugin->getConfigFields();
        cmsCore::c('page')->setTitle($plugin->info['title']);
        cpAddPathway($plugin->info['title'], 'index.php?view=plugins&do=config&id=' . $id);
        $xml_file = PATH . '/plugins/' . $plugin_name . '/backend.xml';
        $tpl = cmsCore::c('page')->initTemplate('applets', 'plugins_config')->assign('plugin_title', $plugin->info['title'])->assign('config', $config)->assign('plugin_cfg_fields', $plugin_cfg_fields)->assign('xml_file_exist', file_exists($xml_file))->assign('plugin_name', $plugin_name);
        if (!empty($plugin_cfg_fields)) {
            $tpl->assign('form_gen_form', cmsCore::c('form_gen')->generateForm($plugin->getConfigFields(), $config));
        } else {
            if (file_exists($xml_file)) {
                $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
                $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules');
                cpToolMenu($toolmenu);
                cmsCore::loadClass('formgen');
                $formGen = new cmsFormGen($xml_file, $config);
                $tpl->assign('form_gen_form', $formGen->getHTML());
            }
        }
        $tpl->display();
    }
}
Ejemplo n.º 27
0
function applet_userbanlist()
{
    $inCore = cmsCore::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/users', $adminAccess)) {
        cpAccessDenied();
    }
    $GLOBALS['cp_page_title'] = $_LANG['AD_BANLIST'];
    cpAddPathway($_LANG['AD_USERS'], 'index.php?view=users');
    cpAddPathway($_LANG['AD_BANLIST'], 'index.php?view=userbanlist');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', -1);
    $to = cmsCore::request('to', 'int', 0);
    // для редиректа обратно в профиль на сайт
    if ($to) {
        cmsUser::sessionPut('back_url', cmsCore::getBackURL());
    }
    if ($do == 'list') {
        $toolmenu[] = array('icon' => 'useradd.gif', 'title' => $_LANG['AD_TO_BANLIST_ADD'], 'link' => '?view=userbanlist&do=add');
        $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=edit&multiple=1');");
        $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=userbanlist&do=delete&multiple=1');");
        cpToolMenu($toolmenu);
        $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
        $fields[] = array('title' => $_LANG['AD_IS_ACTIVE'], 'field' => 'status', 'width' => '55', 'prc' => 'cpYesNo');
        $fields[] = array('title' => $_LANG['AD_BANLIST_USER'], 'field' => 'user_id', 'width' => '120', 'filter' => '12', 'prc' => 'cpUserNick');
        $fields[] = array('title' => $_LANG['AD_BANLIST_IP'], 'field' => 'ip', 'width' => '100', 'link' => '?view=userbanlist&do=edit&id=%id%', 'filter' => '12');
        $fields[] = array('title' => $_LANG['DATE'], 'field' => 'bandate', 'width' => '', 'fdate' => '%d/%m/%Y %H:%i:%s', 'filter' => '12');
        $fields[] = array('title' => $_LANG['AD_BANLIST_TIME'], 'field' => 'int_num', 'width' => '55');
        $fields[] = array('title' => '', 'field' => 'int_period', 'width' => '70');
        $fields[] = array('title' => $_LANG['AD_AUTOREMOVE'], 'field' => 'autodelete', 'width' => '90', 'prc' => 'cpYesNo');
        $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=userbanlist&do=edit&id=%id%');
        $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_REMOVE_RULE'], 'link' => '?view=userbanlist&do=delete&id=%id%');
        cpListTable('cms_banlist', $fields, $actions, '1=1', 'ip DESC');
    }
    if ($do == 'delete') {
        if (!isset($_REQUEST['item'])) {
            if ($id >= 0) {
                dbDelete('cms_banlist', $id);
            }
        } else {
            dbDeleteList('cms_banlist', cmsCore::request('item', 'array_int', array()));
        }
        cmsCore::redirect('?view=userbanlist');
    }
    if ($do == 'submit' || $do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $types = array('user_id' => array('user_id', 'int', 0), 'ip' => array('ip', 'str', ''), 'cause' => array('cause', 'str', ''), 'autodelete' => array('autodelete', 'int', 0), 'int_num' => array('int_num', 'int', 0), 'int_period' => array('int_period', 'str', '', create_function('$p', 'if(!in_array($p, array("MONTH","DAY","HOUR","MINUTE"))){ $p = "MINUTE"; } return $p;')));
        $items = cmsCore::getArrayFromRequest($types);
        $error = false;
        if (!$items['ip']) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_NEED_IP'], 'error');
        }
        if ($items['ip'] == $_SERVER['REMOTE_ADDR'] || $items['user_id'] == $inUser->id) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_YOUR_IP'], 'error');
        }
        if (cmsUser::userIsAdmin($items['user_id'])) {
            $error = true;
            cmsCore::addSessionMessage($_LANG['AD_ITS_ADMIN'], 'error');
        }
        if ($error) {
            cmsCore::redirectBack();
        }
        if ($do == 'update') {
            $inDB->update('cms_banlist', $items, $id);
            if (empty($_SESSION['editlist'])) {
                cmsCore::redirect('?view=userbanlist');
            } else {
                cmsCore::redirect('?view=userbanlist&do=edit');
            }
        }
        $inDB->insert('cms_banlist', $items);
        $back_url = cmsUser::sessionGet('back_url');
        cmsUser::sessionDel('back_url');
        cmsCore::redirect($back_url ? $back_url : '?view=userbanlist');
    }
    if ($do == 'add' || $do == 'edit') {
        $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="/admin/js/banlist.js"></script>';
        $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
        $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);');
        cpToolMenu($toolmenu);
        if ($do == 'add') {
            echo '<h3>' . $_LANG['AD_TO_BANLIST_ADD'] . '</h3>';
            cpAddPathway($_LANG['AD_TO_BANLIST_ADD']);
        } else {
            if (isset($_REQUEST['multiple'])) {
                if (isset($_REQUEST['item'])) {
                    $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array());
                } else {
                    cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error');
                    cmsCore::redirectBack();
                }
            }
            $ostatok = '';
            if (isset($_SESSION['editlist'])) {
                $item_id = array_shift($_SESSION['editlist']);
                if (sizeof($_SESSION['editlist']) == 0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')';
                }
            } else {
                $item_id = cmsCore::request('id', 'int', 0);
            }
            $mod = $inDB->get_fields('cms_banlist', "id = '{$item_id}'", '*');
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_RULE'] . ' ' . $ostatok . '</h3>';
            cpAddPathway($_LANG['AD_EDIT_RULE']);
        }
        ?>
	  <div style="margin-top:2px;padding:10px;border:dotted 1px silver; width:508px;background:#FFFFCC">
	  	<div style="font-weight:bold"><?php 
        echo $_LANG['ATTENTION'];
        ?>
!</div>
		<div><?php 
        echo $_LANG['AD_CAUTION_INFO_0'];
        ?>
</div>
		<div><?php 
        echo $_LANG['AD_CAUTION_INFO_1'];
        ?>
</div>
	  </div>
      <form id="addform" name="addform" method="post" action="index.php?view=userbanlist">
        <input type="hidden" name="csrf_token" value="<?php 
        echo cmsUser::getCsrfToken();
        ?>
" />
        <table width="530" border="0" cellspacing="5" class="proptable">
          <tr>
            <td width="150" valign="top"><div><strong><?php 
        echo $_LANG['AD_BANLIST_USER'];
        ?>
: </strong></div></td>
			<?php 
        if ($do == 'add' && $to) {
            $mod['user_id'] = $to;
            $mod['ip'] = $inDB->get_field('cms_users', 'id=' . $to, 'last_ip');
        }
        ?>
            <td valign="top">
				<select name="user_id" id="user_id" onchange="loadUserIp()" style="width: 250px;">
                    <option value="0" <?php 
        if (@(!$mod['user_id'])) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['AD_WHITHOUT_USER'];
        ?>
</option>
                    <?php 
        if (isset($mod['user_id'])) {
            echo $inCore->getListItems('cms_users', $mod['user_id'], 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        } else {
            echo $inCore->getListItems('cms_users', 0, 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
        }
        ?>
				</select>
            </td>
          </tr>
          <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BANLIST_IP'];
        ?>
:</strong></td>
            <td valign="top"><input name="ip" type="text" id="ip" style="width: 244px;" value="<?php 
        echo @$mod['ip'];
        ?>
"/></td>
          </tr>
          <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BANLIST_CAUSE'];
        ?>
:</strong></td>
            <td valign="top">
                <textarea name="cause" style="width:240px" rows="5"><?php 
        echo @$mod['cause'];
        ?>
</textarea>
            </td>
          </tr>
		  <?php 
        $forever = false;
        if (!@$mod['int_num']) {
            $forever = true;
        }
        ?>
          <tr>
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BAN_FOREVER'];
        ?>
</strong></td>
            <td valign="top"><input type="checkbox" name="forever" value="1" <?php 
        if ($forever) {
            echo 'checked="checked"';
        }
        ?>
 onclick="$('tr.bantime').toggle();"/></td>
          </tr>
          <tr class="bantime">
            <td valign="top"><strong><?php 
        echo $_LANG['AD_BAN_FOR_TIME'];
        ?>
</strong> </td>

            <td valign="top"><p>
            <input name="int_num" type="text" id="int_num" size="5" value="<?php 
        echo @(int) $mod['int_num'];
        ?>
"/>
              <select name="int_period" id="int_period">
                <option value="MINUTE"  <?php 
        if (@mb_strstr($mod['int_period'], 'MINUTE')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['MINUTE10'];
        ?>
</option>]
                <option value="HOUR"  <?php 
        if (@mb_strstr($mod['int_period'], 'HOUR')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['HOUR10'];
        ?>
</option>
                <option value="DAY" <?php 
        if (@mb_strstr($mod['int_period'], 'DAY')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['DAY10'];
        ?>
</option>
                <option value="MONTH" <?php 
        if (@mb_strstr($mod['int_period'], 'MONTH')) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $_LANG['MONTH10'];
        ?>
</option>
              </select>
            </p>
            <p><label><input name="autodelete" type="checkbox" id="autodelete" value="1" <?php 
        if ($mod['autodelete']) {
            echo 'checked="checked"';
        }
        ?>
 /> <?php 
        echo $_LANG['AD_REMOVE_BAN'];
        ?>
</label></p>
            </td>
          </tr>
		  <?php 
        if ($forever) {
            ?>
<script type="text/javascript">$('tr.bantime').hide();</script><?php 
        }
        ?>
        </table>
        <p>
          <label>
          <input name="add_mod" type="submit" id="add_mod" <?php 
        if ($do == 'add') {
            echo 'value="' . $_LANG['AD_TO_BANLIST_ADD'] . '"';
        } else {
            echo 'value="' . $_LANG['SAVE'] . '"';
        }
        ?>
 />
          </label>
          <label><span style="margin-top:15px">
          <input name="back" type="button" id="back" value="<?php 
        echo $_LANG['CANCEL'];
        ?>
" onclick="window.history.back();"/>
          </span></label>
          <input name="do" type="hidden" id="do" <?php 
        if ($do == 'add') {
            echo 'value="submit"';
        } else {
            echo 'value="update"';
        }
        ?>
 />
          <?php 
        if ($do == 'edit') {
            echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />';
        }
        ?>
        </p>
      </form>
	<?php 
    }
}
Ejemplo n.º 28
0
function applet_content() {
    $inCore = cmsCore::getInstance();
    cmsCore::m('content');
    
    global $_LANG;

    //check access
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/content', $adminAccess)) { cpAccessDenied(); }

    $cfg = $inCore->loadComponentConfig('content');

    cmsCore::c('page')->setTitle($_LANG['AD_ARTICLES']);
    cpAddPathway($_LANG['AD_ARTICLES'], 'index.php?view=tree');

    $do = cmsCore::request('do', 'str', 'add');
    $id = cmsCore::request('id', 'int', -1);

    if ($do == 'arhive_on') {
        cmsCore::c('db')->setFlag('cms_content', $id, 'is_arhive', '1');
        cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO_ARHIVE'], 'success');
        cmsCore::redirectBack();
    }

    if ($do == 'move') {
        $item_id = cmsCore::request('id', 'int', 0);
        $cat_id  = cmsCore::request('cat_id', 'int', 0);

        $dir     = cmsCore::request('dir', 'str');
        $step    = 1;

        cmsCore::m('content')->moveItem($item_id, $cat_id, $dir, $step);
        cmsCore::halt(1);
    }

    if ($do == 'move_to_cat') {
        $items     = cmsCore::request('item', 'array_int');
        $to_cat_id = cmsCore::request('obj_id', 'int', 0);

        if ($items && $to_cat_id) {
            $last_ordering = (int)cmsCore::c('db')->get_field('cms_content', "category_id = '". $to_cat_id ."' ORDER BY ordering DESC", 'ordering');
            foreach ($items as $item_id) {
                $article = cmsCore::m('content')->getArticle($item_id);
                if (!$article) { continue; }
                $last_ordering++;
                
                cmsCore::m('content')->updateArticle(
                    $article['id'],
                    array(
                        'category_id' => $to_cat_id,
                        'ordering' => $last_ordering,
                        'url' => $article['url'],
                        'title' => cmsCore::c('db')->escape_string($article['title']),
                        'id' => $article['id'],
                        'user_id' => $article['user_id']
                    )
                );
            }
            
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_TO'], 'success');
        }

        cmsCore::redirect('?view=tree&cat_id='. $to_cat_id);
    }

    if ($do == 'show') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) { cmsCore::c('db')->setFlag('cms_content', $id, 'published', '1'); }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_content', cmsCore::request('item', 'array_int'), 'published', '1');
            cmsCore::redirectBack();
        }
    }

    if ($do == 'hide') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) { cmsCore::c('db')->setFlag('cms_content', $id, 'published', '0'); }
            cmsCore::halt('1');
        } else {
            cmsCore::c('db')->setFlags('cms_content', cmsCore::request('item', 'array_int'), 'published', '0');
            cmsCore::redirectBack();
        }
    }

    if ($do == 'delete') {
        if (!cmsCore::inRequest('item')) {
            if ($id >= 0) {
                cmsCore::m('content')->deleteArticle($id);
                cmsCore::addSessionMessage($_LANG['AD_ARTICLE_REMOVE'], 'success');
            }
        } else {
            cmsCore::m('content')->deleteArticles(cmsCore::request('item', 'array_int'));
            cmsCore::addSessionMessage($_LANG['AD_ARTICLES_REMOVE'], 'success');
        }
        cmsCore::redirectBack();
    }

    if ($do == 'update'){
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        if (cmsCore::inRequest('id')) {
            $id                     = cmsCore::request('id', 'int', 0);
            $article['category_id'] = cmsCore::request('category_id', 'int', 1);
            $article['title']       = cmsCore::request('title', 'str');
            $article['url']         = cmsCore::request('url', 'str');
            $article['showtitle']   = cmsCore::request('showtitle', 'int', 0);
            $article['description'] = cmsCore::request('description', 'html', '');
            $article['description'] = cmsCore::c('db')->escape_string($article['description']);
            $article['content']     = cmsCore::request('content', 'html', '');
            $article['content']     = cmsCore::c('db')->escape_string($article['content']);
            $article['published']   = cmsCore::request('published', 'int', 0);

            $article['showdate']    = cmsCore::request('showdate', 'int', 0);
            $article['showlatest']  = cmsCore::request('showlatest', 'int', 0);
            $article['showpath']    = cmsCore::request('showpath', 'int', 0);
            $article['comments']    = cmsCore::request('comments', 'int', 0);
            $article['canrate']     = cmsCore::request('canrate', 'int', 0);

            $enddate                = explode('.', cmsCore::request('enddate', 'str'));
            $article['enddate']     = $enddate[2] .'-'. $enddate[1] .'-'. $enddate[0];

            $article['is_end']      = cmsCore::request('is_end', 'int', 0);
            $article['pagetitle']   = cmsCore::request('pagetitle', 'str', '');

            $article['tags']        = cmsCore::request('tags', 'str');

            $olddate                = cmsCore::request('olddate', 'str', '');
            $pubdate                = cmsCore::request('pubdate', 'str', '');

            $article['user_id']     = cmsCore::request('user_id', 'int', cmsCore::c('user')->id);

            $article['tpl']         = cmsCore::request('tpl', 'str', 'com_content_read');

            if ($olddate != $pubdate) {
                $date = explode('.', $pubdate);
                $article['pubdate'] = $date[2] .'-'. $date[1] .'-'. $date[0] .' '.  date('H:i');
            }

            $autokeys               = cmsCore::request('autokeys', 'int');

            switch($autokeys){
                case 1: $article['meta_keys'] = $inCore->getKeywords($article['content']);
                        $article['meta_desc'] = $article['title'];
                        break;

                case 2: $article['meta_desc'] = strip_tags($article['description']);
                        $article['meta_keys'] = $article['tags'];
                        break;

                case 3: $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                        $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                        break;
            }

            cmsCore::m('content')->updateArticle($id, $article);

            if (!cmsCore::request('is_public', 'int', 0)) {
                $showfor = cmsCore::request('showfor', 'array_int', array());
                cmsCore::setAccess($id, $showfor, 'material');
            } else {
                cmsCore::clearAccess($id, 'material');
            }

            cmsCore::m('content')->uploadArticeImage($id, cmsCore::request('delete_image', 'int', 0));

            cmsCore::addSessionMessage($_LANG['AD_ARTICLE_SAVE'], 'success');

            if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) {
                cmsCore::redirect('?view=tree&cat_id='.$article['category_id']);
            } else {
                cmsCore::redirect('?view=content&do=edit');
            }
        }
    }

    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
        
        $article['category_id'] = cmsCore::request('category_id', 'int', 1);
        $article['title']       = cmsCore::request('title', 'str');
        $article['url']         = cmsCore::request('url', 'str');
        $article['showtitle']   = cmsCore::request('showtitle', 'int', 0);
        $article['description'] = cmsCore::request('description', 'html', '');
        $article['description'] = cmsCore::c('db')->escape_string($article['description']);
        $article['content']     = cmsCore::request('content', 'html', '');
        $article['content']    	= cmsCore::c('db')->escape_string($article['content']);

        $article['published']   = cmsCore::request('published', 'int', 0);

        $article['showdate']    = cmsCore::request('showdate', 'int', 0);
        $article['showlatest']  = cmsCore::request('showlatest', 'int', 0);
        $article['showpath']    = cmsCore::request('showpath', 'int', 0);
        $article['comments']    = cmsCore::request('comments', 'int', 0);
        $article['canrate']     = cmsCore::request('canrate', 'int', 0);

        $enddate                = explode('.', cmsCore::request('enddate', 'str'));
        $article['enddate']     = $enddate[2] .'-'. $enddate[1] .'-'. $enddate[0];
        $article['is_end']      = cmsCore::request('is_end', 'int', 0);
        $article['pagetitle']   = cmsCore::request('pagetitle', 'str', '');

        $article['tags']        = cmsCore::request('tags', 'str');

        $article['pubdate']     = cmsCore::request('pubdate', 'str');
        $date                   = explode('.', $article['pubdate']);
        $article['pubdate']     = $date[2] .'-'. $date[1] .'-'. $date[0] .' '. date('H:i');

        $article['user_id']     = cmsCore::request('user_id', 'int', cmsCore::c('user')->id);

        $article['tpl']         = cmsCore::request('tpl', 'str', 'com_content_read');

        $autokeys               = cmsCore::request('autokeys', 'int');

        switch ($autokeys) {
            case 1: $article['meta_keys'] = $inCore->getKeywords($article['content']);
                    $article['meta_desc'] = $article['title'];
                    break;

            case 2: $article['meta_desc'] = strip_tags($article['description']);
                    $article['meta_keys'] = $article['tags'];
                    break;

            case 3: $article['meta_desc'] = cmsCore::request('meta_desc', 'str');
                    $article['meta_keys'] = cmsCore::request('meta_keys', 'str');
                    break;
        }

        $article['id'] = cmsCore::m('content')->addArticle($article);

        if (!cmsCore::request('is_public', 'int', 0)) {
            $showfor = cmsCore::request('showfor', 'array_int', array());
            cmsCore::setAccess($article['id'], $showfor, 'material');
        }

        $inmenu = cmsCore::request('createmenu', 'str', '');

        if ($inmenu) {
            createMenuItem($inmenu, $article['id'], $article['title']);
        }

        cmsCore::m('content')->uploadArticeImage($article['id']);

        cmsCore::addSessionMessage($_LANG['AD_ARTICLE_ADD'], 'success');

        cmsCore::redirect('?view=tree&cat_id='. $article['category_id']);
    }

    if ($do == 'add' || $do == 'edit') {
        $toolmenu = array(
            array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ),
            array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' )
        );

        cpToolMenu($toolmenu);
        $menu_list = cpGetList('menu');

        if ($do == 'add') {
            echo '<h3>'. $_LANG['AD_CREATE_ARTICLE'] .'</h3>';
            cpAddPathway($_LANG['AD_CREATE_ARTICLE'], 'index.php?view=content&do=add');
            
            $mod = array(
                'category_id' => cmsCore::request('to', 'int'),
                'showpath' => 1,
                'tpl' => 'com_content_read'
            );
        } else {
            if (isset($_REQUEST['item'])){
                $_SESSION['editlist'] = $_REQUEST['item'];
            }

            $ostatok = '';

            if (isset($_SESSION['editlist'])) {
                $id = array_shift($_SESSION['editlist']);
                if (count($_SESSION['editlist'])==0) {
                    unset($_SESSION['editlist']);
                } else {
                    $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')';
                }
            } else {
                $id = (int)$_REQUEST['id'];
            }

            $sql = "SELECT *, (TO_DAYS(enddate) - TO_DAYS(CURDATE())) as daysleft, DATE_FORMAT(pubdate, '%d.%m.%Y') as pubdate, DATE_FORMAT(enddate, '%d.%m.%Y') as enddate
                     FROM cms_content
                     WHERE id = ". $id ." LIMIT 1";
            $result = cmsCore::c('db')->query($sql) ;
            if (cmsCore::c('db')->num_rows($result)) {
                $mod = cmsCore::c('db')->fetch_assoc($result);
                if (!empty($mod['images'])) {
                    $mod['images'] = json_decode($mod['images'], true);
                }
            }

            echo '<h3>'. $_LANG['AD_EDIT_ARTICLE'] . $ostatok .'</h3>';
            cpAddPathway($mod['title'], 'index.php?view=content&do=edit&id='. $mod['id']);
        }
        
        $ajaxUploader = cmsCore::c('page')->initAjaxUpload(
            'plupload',
            array(
                'component' => 'content',
                'target_id' => cmsCore::getArrVal($mod, 'id', 0),
                'insertEditor' => 'content'
            ),
            cmsCore::getArrVal($mod, 'images', false)
        );
        
        $tab_plugins = cmsCore::callTabEventPlugins('ADMIN_CONTENT_TABS', !empty($mod['id']) ? $mod : array());
?>
<form id="addform" name="addform" method="post" action="index.php" enctype="multipart/form-data">
    <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" />
    <input type="hidden" name="view" value="content" />

    <table class="table">
        <tr>
            <!-- главная ячейка -->
            <td valign="top">
                <table width="100%" cellpadding="0" cellspacing="4" border="0">
                    <tr>
                        <td valign="top">
                            <label><?php echo $_LANG['AD_ARTICLE_NAME']; ?></label>
                            <div>
                                <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                        <td><input type="text" class="form-control" name="title" value="<?php echo htmlspecialchars($mod['title']);?>" /></td>
                                        <td style="width:15px;padding-left:10px;padding-right:10px;">
                                            <input type="checkbox" class="uittip" title="<?php echo $_LANG['AD_VIEW_TITLE']; ?>" name="showtitle" <?php if ($mod['showtitle'] || $do=='add') { echo 'checked="checked"'; } ?> value="1">
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                        <td width="130" valign="top">
                            <label><?php echo $_LANG['AD_PUBLIC_DATE']; ?></label>
                            <div>
                                <input type="text" id="pubdate" class="form-control" name="pubdate" style="width:100px;display: inline-block" <?php if(@!$mod['pubdate']) { echo 'value="'.date('d.m.Y').'"'; } else { echo 'value="'.$mod['pubdate'].'"'; } ?>/>

                                <input type="hidden" name="olddate" value="<?php echo @$mod['pubdate']?>" />
                            </div>
                        </td>
                        <td width="16" valign="bottom" style="padding-bottom:10px">
                            <input type="checkbox" id="showdate" class="uittip" name="showdate" title="<?php echo $_LANG['AD_VIEW_DATE_AND_AUTHOR']; ?>" value="1" <?php if ($mod['showdate'] || $do=='add') { echo 'checked="checked"'; } ?>/>
                        </td>
                        <td width="160" valign="top">
                            <label><?php echo $_LANG['AD_ARTICLE_TEMPLATE']; ?></label>
                            <div><input type="text" class="form-control" style="width:160px" name="tpl" value="<?php echo @$mod['tpl'];?>"></div>
                        </td>
                    </tr>
                </table>
                    
                <div class="form-group">
                    <label><?php echo $_LANG['AD_ARTICLE_NOTICE']; ?></label>
                    <div><?php $inCore->insertEditor('description', $mod['description'], '200', '100%'); ?></div>
                </div>

                <div class="form-group">
                    <label><?php echo $_LANG['AD_ARTICLE_TEXT']; ?></label>
                    <?php insertPanel(); ?>
                    <div><?php $inCore->insertEditor('content', $mod['content'], '400', '100%'); ?></div>
                </div>
                    
                <div class="form-group">
                    <label><?php echo $_LANG['AD_ARTICLE_TAGS']; ?></label>
                    <input type="text" id="tags" class="form-control" name="tags" value="<?php if (isset($mod['id'])) { echo cmsTagLine('content', $mod['id'], false); } ?>" />
                </div>

                <div>
                    <label>
                        <input type="radio" name="autokeys" <?php if ($do == 'add' && $cfg['autokeys']) { ?>checked="checked"<?php } ?> value="1"/>
                        <?php echo $_LANG['AD_AUTO_GEN_KEY']; ?>
                    </label>
                </div>
                <div>
                    <label>
                        <input type="radio" name="autokeys" value="2" />
                        <?php echo $_LANG['AD_TAGS_AS_KEY']; ?>
                    </label>
                </div>
                <div>
                    <label>
                        <input type="radio" name="autokeys" id="autokeys3" value="3" <?php if ($do == 'edit' || !$cfg['autokeys']) { ?>checked="checked"<?php } ?>/>
                        <?php echo $_LANG['AD_MANUAL_KEY']; ?>
                    </label>
                </div>
                    
                <?php if ($cfg['af_on'] && $do=='add') { ?>
                <div>
                    <label>
                        <input type="checkbox" name="noforum" id="noforum" value="1" />
                        <?php echo $_LANG['AD_NO_CREATE_THEME']; ?>
                    </label>
                </div>
                <?php } ?>
            </td>

            <!-- боковая ячейка -->
            <td valign="top" style="width:450px">
                <div class="uitabs">
                    <ul id="tabs">
                        <li><a href="#upr_publish"><span><?php echo $_LANG['AD_TAB_PUBLISH']; ?></span></a></li>
                        <li><a href="#upr_restrictions"><span><?php echo $_LANG['AD_RESTRICTIONS']; ?></span></a></li>
                        <li><a href="#upr_photos"><span><?php echo $_LANG['AD_PHOTOS']; ?></span></a></li>
                        <?php if (!empty($tab_plugins)){ foreach ($tab_plugins as $tab_plugin){ ?>
                            <li><a href="<?php if ($tab_plugin['ajax_link']){ echo $tab_plugin['ajax_link']; }else{ echo '#upr_'. $tab_plugin['name']; } ?>" title="<?php echo $tab_plugin['name']; ?>"><span><?php echo $tab_plugin['title']; ?></span></a></li>
                        <?php }} ?>
                    </ul>
                        
                    <div id="upr_publish">
                        <div class="form-group">
                            <label>
                                <input type="checkbox" name="published" id="published" value="1" <?php if ($mod['published'] || $do=='add') { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_PUBLIC_ARTICLE']; ?>
                            </label>
                        </div>
                            
                        <div class="form-group">
                            <select id="category_id" class="form-control" style="height:200px" name="category_id" size="10">
                                <option value="1" <?php if (@$mod['category_id']==1 || !isset($mod['category_id'])) { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_ROOT_CATEGORY'] ; ?></option>
                                <?php
                                    if (isset($mod['category_id'])){
                                        echo $inCore->getListItemsNS('cms_category', $mod['category_id']);
                                    } else {
                                        echo $inCore->getListItemsNS('cms_category');
                                    }
                                ?>
                            </select>
                            <select id="showpath" name="showpath" class="form-control">
                                <option value="0" <?php if (@!$mod['showpath']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_PATHWAY_NAME_ONLY']; ?></option>
                                <option value="1" <?php if (@$mod['showpath']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_PATHWAY_FULL']; ?></option>
                            </select>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_ARTICLE_URL']; ?></label>
                            <input type="text" class="form-control" name="url" value="<?php echo $mod['url']; ?>" />
                            <div class="help-block"><?php echo $_LANG['AD_IF_UNKNOWN_PAGETITLE']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_ARTICLE_AUTHOR']; ?></label>
                            <select id="user_id" class="form-control" name="user_id">
                            <?php
                                if (isset($mod['user_id'])) {
                                    echo $inCore->getListItems('cms_users', $mod['user_id'], 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
                                } else {
                                    echo $inCore->getListItems('cms_users', cmsCore::c('user')->id, 'nickname', 'ASC', 'is_deleted=0 AND is_locked=0', 'id', 'nickname');
                                }
                            ?>
                            </select>
                        </div>
                            
                        <h4><?php echo $_LANG['AD_PUBLIC_PARAMETRS']; ?></h4>
                        <div class="form-group">
                            <label>
                                <input type="checkbox" name="showlatest" value="1" <?php if ($mod['showlatest'] || $do=='add') { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_VIEW_NEW_ARTICLES']; ?>
                            </label>
                            <label>
                                <input type="checkbox" name="comments" value="1" <?php if ($mod['comments'] || $do=='add') { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_ENABLE_COMMENTS']; ?>
                            </label>
                            <label>
                                <input type="checkbox" name="canrate" value="1" <?php if ($mod['canrate']) { echo 'checked="checked"'; } ?> />
                                <?php echo $_LANG['AD_ENABLE_RATING']; ?>
                            </label>
                        </div>
                            
                        <h4>SEO</h4>
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_PAGE_TITLE']; ?></label>
                            <input type="text" class="form-control" name="pagetitle" value="<?php if (isset($mod['pagetitle'])) { echo htmlspecialchars($mod['pagetitle']); } ?>" />
                            <div class="help-block"><?php echo $_LANG['AD_IF_UNKNOWN']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['KEYWORDS']; ?></label>
                            <textarea class="form-control" name="meta_keys" rows="4"><?php echo htmlspecialchars($mod['meta_keys']);?></textarea>
                            <div class="help-block"><?php echo $_LANG['AD_FROM_COMMA']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['DESCRIPTION']; ?></label>
                            <textarea class="form-control" name="meta_desc" rows="6"><?php echo htmlspecialchars($mod['meta_desc']);?></textarea>
                            <div class="help-block"><?php echo $_LANG['AD_LESS_THAN']; ?></div>
                        </div>
                            
                        <?php if ($do=='add'){ ?>
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_CREATE_LINK']; ?></label>
                            <select class="form-control" name="createmenu">
                                <option value="0" selected="selected"><?php echo $_LANG['AD_DONT_CREATE_LINK']; ?></option>
                            <?php foreach ($menu_list as $menu) { ?>
                                <option value="<?php echo $menu['id']; ?>">
                                    <?php echo $menu['title']; ?>
                                </option>
                            <?php } ?>
                            </select>
                        </div>
                        <?php } ?>
                    </div>
                        
                    <div id="upr_restrictions">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_ARTICLE_TIME']; ?></label>
                            <select class="form-control" name="is_end" onchange="if($(this).val() == 1){ $('#final_time').show(); }else {$('#final_time').hide();}">
                                <option value="0" <?php if (@!$mod['is_end']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_UNLIMITED']; ?></option>
                                <option value="1" <?php if (@$mod['is_end']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_TO_FINAL_TIME']; ?></option>
                            </select>
                        </div>
                            
                        <div id="final_time" class="form-group" <?php if (@!$mod['is_end']) { echo 'style="display: none"'; } ?>>
                            <label><?php echo $_LANG['AD_FINAL_TIME']; ?></label>
                            <input type="text" id="enddate" class="form-control" name="enddate" <?php if(@!$mod['is_end']) { echo 'value="'.date('d.m.Y').'"'; } else { echo 'value="'. $mod['enddate'] .'"'; } ?> />
                            <div class="help-block"><?php echo $_LANG['AD_CALENDAR_FORMAT']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <?php
                                $sql    = "SELECT * FROM cms_user_groups";
                                $result = cmsCore::c('db')->query($sql) ;

                                $style  = 'disabled="disabled"';
                                $public = 'checked="checked"';

                                if ($do == 'edit') {
                                    $sql2 = "SELECT * FROM cms_content_access WHERE content_id = ".$mod['id']." AND content_type = 'material'";
                                    $result2 = cmsCore::c('db')->query($sql2);
                                    $ord = array();

                                    if (cmsCore::c('db')->num_rows($result2)){
                                        $public = '';
                                        $style = '';
                                        while ($r = cmsCore::c('db')->fetch_assoc($result2)){
                                            $ord[] = $r['group_id'];
                                        }
                                    }
                                }
                            ?>
                            <label>
                                <input name="is_public" type="checkbox" id="is_public" onclick="checkGroupList()" value="1" <?php echo $public?> />
                                <?php echo $_LANG['AD_SHARE']; ?>
                            </label>
                            <div class="help-block"><?php echo $_LANG['AD_IF_NOTED']; ?></div>
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label>
                            <?php
                                echo '<select id="showin" class="form-control" name="showfor[]" size="6" multiple="multiple" '.$style.'>';

                                if (cmsCore::c('db')->num_rows($result)){
                                    while ($item = cmsCore::c('db')->fetch_assoc($result)){
                                        echo '<option value="'.$item['id'].'"';
                                        if ($do=='edit'){
                                            if (in_array($item['id'], $ord)){
                                                echo 'selected="selected"';
                                            }
                                        }

                                        echo '>';
                                        echo $item['title'].'</option>';
                                    }
                                }

                                echo '</select>';
                            ?>
                            <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?></div>
                        </div>
                    </div>
                        
                    <div id="upr_photos">
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_PHOTO']; ?></label>
                                
                            <?php
                                if ($do == 'edit' && file_exists(PATH.'/images/photos/small/article'. $mod['id'] .'.jpg')){
                            ?>
                            <div style="margin-top:3px;margin-bottom:3px;padding:10px;border:solid 1px gray;text-align:center">
                                <img src="/images/photos/small/article<?php echo $id; ?>.jpg" border="0" />
                            </div>
                            <label>
                                <input type="checkbox" name="delete_image" value="1" />
                                <?php echo $_LANG['AD_PHOTO_REMOVE']; ?>
                            </label>
                            <?php
                                }
                            ?>

                            <input type="file" class="form-control" name="picture" />
                        </div>
                            
                        <div class="form-group">
                            <label><?php echo $_LANG['AD_INSERTED_IMAGES']; ?></label>
                            <?php echo $ajaxUploader; ?>
                        </div>
                    </div>
                        
                    <?php foreach ($tab_plugins as $tab_plugin) { ?>
                        <div id="upr_<?php echo $tab_plugin['name']; ?>"><?php echo $tab_plugin['html']; ?></div>
                    <?php } ?>
                </div>
            </td>
        </tr>
    </table>

    <div>
        <input type="submit" class="btn btn-primary" name="add_mod" <?php if ($do == 'add') { echo 'value="'. $_LANG['AD_CREATE_CONTENT'] .'"'; } else { echo 'value="'. $_LANG['AD_SAVE_CONTENT'] .'"'; } ?> />
        <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();"/>
        <input type="hidden" name="do" <?php if ($do == 'add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> />
        <?php
            if ($do == 'edit') {
                echo '<input type="hidden" name="id" value="'. $mod['id'] .'" />';
            }
        ?>
    </div>
</form>
    <?php
    }
}
Ejemplo n.º 29
0
    }
}
/******************************************************************************/
$opt = cmsCore::request('opt', 'str', 'list');
cmsCore::loadModel('banners');
$toolmenu = array();
if ($opt == 'list') {
    $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_ADD_BANNER'], 'link' => '?view=components&do=config&id=' . $id . '&opt=add');
    $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=components&do=config&id=" . $id . "&opt=edit&multiple=1');");
    $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=components&do=config&id=" . $id . "&opt=show_banner&multiple=1');");
    $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=components&do=config&id=" . $id . "&opt=hide_banner&multiple=1');");
} else {
    $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
    $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => '?view=components&do=config&id=' . $id);
}
cpToolMenu($toolmenu);
if ($opt == 'show_banner') {
    if (!isset($_REQUEST['item'])) {
        if (isset($_REQUEST['item_id'])) {
            dbShow('cms_banners', $_REQUEST['item_id']);
        }
        echo '1';
        exit;
    } else {
        dbShowList('cms_banners', $_REQUEST['item']);
        cmsCore::redirectBack();
    }
}
if ($opt == 'hide_banner') {
    if (!isset($_REQUEST['item'])) {
        if (isset($_REQUEST['item_id'])) {
Ejemplo n.º 30
0
function applet_cron()
{
    cmsCore::loadClass('cron');
    global $_LANG;
    global $adminAccess;
    if (!cmsUser::isAdminCan('admin/config', $adminAccess)) {
        cpAccessDenied();
    }
    cmsCore::c('page')->setTitle($_LANG['AD_CRON_MISSION']);
    cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config');
    cpAddPathway($_LANG['AD_CRON_MISSION'], 'index.php?view=cron');
    $do = cmsCore::request('do', 'str', 'list');
    $id = cmsCore::request('id', 'int', '0');
    if ($do == 'list') {
        $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_CREATE_CRON_MISSION'], 'link' => '?view=cron&do=add'));
        cpToolMenu($toolmenu);
        $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['TITLE'], 'field' => 'job_name', 'width' => '80', 'link' => '?view=cron&do=edit&id=%id%'), array('title' => $_LANG['DESCRIPTION'], 'field' => 'comment', 'width' => ''), array('title' => $_LANG['AD_MISSION_INTERVAL'], 'field' => 'job_interval', 'width' => '30', 'prc' => function ($interval) {
            global $_LANG;
            return $interval . ' ' . $_LANG['HOUR'];
        }), array('title' => $_LANG['AD_LAST_START'], 'field' => 'job_run_date', 'width' => '150'), array('title' => $_LANG['AD_IS_ACTIVE'], 'field' => 'is_enabled', 'width' => '50', 'published' => true));
        $actions = array(array('title' => $_LANG['AD_PERFORM_TASK'], 'icon' => 'play.gif', 'confirm' => $_LANG['AD_PERFORM_TASK'] . ' %job_name%?', 'link' => '?view=cron&do=execute&id=%id%'), array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=cron&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_IF_COMENT_DELETE'], 'link' => '?view=cron&do=delete&id=%id%'));
        cpListTable('cms_cron_jobs', $fields, $actions, '1=1', 'job_run_date ASC');
    }
    if ($do == 'show') {
        if ($id) {
            cmsCron::jobEnabled($id, true);
        }
        cmsCore::halt('1');
    }
    if ($do == 'hide') {
        if ($id) {
            cmsCron::jobEnabled($id, false);
        }
        cmsCore::halt('1');
    }
    if ($do == 'delete') {
        if ($id) {
            cmsCron::removeJobById($id);
        }
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'execute') {
        if ($id) {
            $job_result = cmsCron::executeJobById($id);
        }
        if ($job_result) {
            cmsCore::addSessionMessage($_LANG['AD_MISSION_SUCCESS'], 'success');
        } else {
            cmsCore::addSessionMessage($_LANG['AD_MISSION_ERROR'], 'error');
        }
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'submit') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        $job_name = cmsCore::request('job_name', 'str');
        $comment = cmsCore::request('comment', 'str');
        $job_interval = cmsCore::request('job_interval', 'int');
        $enabled = cmsCore::request('enabled', 'int');
        $component = cmsCore::request('component', 'str');
        $model_method = cmsCore::request('model_method', 'str');
        $custom_file = cmsCore::request('custom_file', 'str');
        $custom_file = mb_stripos($custom_file, 'image') || mb_stripos($custom_file, 'upload') || mb_stripos($custom_file, 'cache') ? '' : $custom_file;
        $custom_file = preg_replace('/\\.+\\//', '', $custom_file);
        $class_name = cmsCore::request('class_name', 'str');
        $class_method = cmsCore::request('class_method', 'str');
        cmsCron::registerJob($job_name, array('interval' => $job_interval, 'component' => $component, 'model_method' => $model_method, 'comment' => $comment, 'custom_file' => $custom_file, 'enabled' => $enabled, 'class_name' => $class_name, 'class_method' => $class_method));
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'update') {
        if (!cmsUser::checkCsrfToken()) {
            cmsCore::error404();
        }
        if (!$id) {
            cmsCore::halt();
        }
        $job_name = cmsCore::request('job_name', 'str');
        $comment = cmsCore::request('comment', 'str');
        $job_interval = cmsCore::request('job_interval', 'int');
        $enabled = cmsCore::request('enabled', 'int');
        $component = cmsCore::request('component', 'str');
        $model_method = cmsCore::request('model_method', 'str');
        $custom_file = cmsCore::request('custom_file', 'str');
        $custom_file = mb_stripos($custom_file, 'image') || mb_stripos($custom_file, 'upload') || mb_stripos($custom_file, 'cache') ? '' : $custom_file;
        $custom_file = preg_replace('/\\.+\\//', '', $custom_file);
        $class_name = cmsCore::request('class_name', 'str');
        $class_method = cmsCore::request('class_method', 'str');
        cmsCron::updateJob($id, array('job_name' => $job_name, 'job_interval' => $job_interval, 'component' => $component, 'model_method' => $model_method, 'comment' => $comment, 'custom_file' => $custom_file, 'is_enabled' => $enabled, 'class_name' => $class_name, 'class_method' => $class_method));
        cmsCore::redirect('index.php?view=cron');
    }
    if ($do == 'edit' || $do == 'add') {
        $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'));
        cpToolMenu($toolmenu);
        if ($do == 'edit') {
            $mod = cmsCron::getJobById($id);
            if (!$mod) {
                cmsCore::error404();
            }
            echo '<h3>' . $_LANG['AD_EDIT_MISSION'] . '</h3>';
            cpAddPathway($mod['job_name'], 'index.php?view=cron&do=edit&id=' . $mod['id']);
        } else {
            echo '<h3>' . $_LANG['AD_CREATE_CRON_MISSION'] . '</h3>';
            cpAddPathway($_LANG['AD_CREATE_CRON_MISSION'], 'index.php?view=cron&do=add');
            $mod = array();
        }
        cmsCore::c('page')->initTemplate('applets', 'cron_edit')->assign('do', $do)->assign('mod', $mod)->display();
    }
}