Вход Регистрация
Файл: InstantSocial/uploud/admin/applets/tree.php
Строк: 625
<?php
/******************************************************************************/
//                                                                            //
//                             InstantCMS v1.9                                //
//                        http://www.instantcms.ru/                           //
//                                                                            //
//                   written by InstantCMS Team, 2007-2011                    //
//                produced by InstantSoft, (www.instantsoft.ru)               //
//                                                                            //
//                        LICENSED BY GNU/GPL v2                              //
//                                                                            //
/******************************************************************************/

if(!defined('VALID_CMS_ADMIN')) { die('ACCESS DENIED'); }

function 
applet_tree(){

    
$inCore cmsCore::getInstance();
    
$inUser cmsUser::getInstance();
    
$inDB     cmsDatabase::getInstance();
    
$inPage cmsPage::getInstance();

    
//check access
    
global $adminAccess;
    if (!
$inCore->isAdminCan('admin/content'$adminAccess)) { cpAccessDenied(); }

    
$cfg $inCore->loadComponentConfig('content');
    if(!isset(
$cfg['img_small_w'])) { $cfg['img_small_w'] = 100; }
    if(!isset(
$cfg['img_big_w'])) { $cfg['img_big_w'] = 200; }
    if(!isset(
$cfg['img_sqr'])) { $cfg['img_sqr'] = 1; }

    
$inCore->loadModel('content');
    
$model = new cms_model_content();

    
$GLOBALS['cp_page_title'] = 'Контент сайта';
    
cpAddPathway('Контент сайта''index.php?view=tree');
    
    
$GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/content.js"></script>';

    
$do $inCore->request('do''str''tree');

//============================================================================//    
//============================================================================//    
    
    
if ($do == 'tree'){
        
$toolmenu = array();

        
$toolmenu[8]['icon'] = 'config.gif';
        
$toolmenu[8]['title'] = 'Настроить каталог статей';
        
$toolmenu[8]['link'] = "?view=components&do=config&link=content";

        
$toolmenu[9]['icon'] = 'help.gif';
        
$toolmenu[9]['title'] = 'Помощь';
        
$toolmenu[9]['link'] = "?view=help&topic=content";

        
cpToolMenu($toolmenu);

        
$category_id    $inCore->request('cat_id''int'0);
        
$base_uri       'index.php?view=tree';

        
$title_part     $inCore->request('title''str''');

        
$def_order  $category_id 'con.ordering' 'pubdate';
        
$orderby    $inCore->request('orderby''str'$def_order);
        
$orderto    $inCore->request('orderto''str''asc');
        
$page       $inCore->request('page''int'1);
        
$perpage    20;

        
$hide_cats  $inCore->request('hide_cats''int'0);

        
$cats       $model->getCatsTree();

        if (
$category_id) {
            
$model->whereCatIs($category_id);
        }

        if (
$title_part){
            
$model->where('LOWER(con.title) LIKE '%'.strtolower($title_part).'%'');
        }

        
$model->orderBy($orderby$orderto);

        
$model->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);

    }

//============================================================================//    
//============================================================================//    
        
    
if ($do == 'arhive_on'){
        if(isset(
$_REQUEST['id'])) { 
            
$id = (int)$_REQUEST['id'];
            
$sql "UPDATE cms_content SET is_arhive = 1 WHERE id = $id";
            
dbQuery($sql) ;
            
header('location:?view=content');
        }
    }

    if (
$do == 'move'){

        
$item_id $inCore->request('id''int'0);
        
$cat_id  $inCore->request('cat_id''int'0);
        
$dir     $_REQUEST['dir'];
        
$step    1;
        
$model->moveItem($item_id$cat_id$dir$step);
        echo 
'1'; exit;

    }

    if (
$do == 'show'){
        if (!isset(
$_REQUEST['item'])){
            if (
$id >= 0){ dbShow('cms_content'$id);  }
            echo 
'1'; exit;
        } else {
            
dbShowList('cms_content'$_REQUEST['item']);    
            
$inCore->redirectBack();            
        }
        
    }

    if (
$do == 'hide'){
        if (!isset(
$_REQUEST['item'])){
            if (
$id >= 0){ dbHide('cms_content'$id);  }
            echo 
'1'; exit;
        } else {
            
dbHideList('cms_content'$_REQUEST['item']);                
            
$inCore->redirectBack();
        }        
    }
    
    if (
$do == 'delete'){
        if (
$cfg['af_delete']){ include_once(PATH.'/components/forum/includes/forumcore.php'); }
        if (!isset(
$_REQUEST['item'])){
            if (
$id >= 0){ 
                
$model->deleteArticle($id$cfg['af_delete']);
            }
        } else {
            
$model->deleteArticles($_REQUEST['item'], $cfg['af_delete']);
        }
        
header('location:?view=content');
    }
    
    if (
$do == 'update'){
        if(isset(
$_REQUEST['id'])) {

            
$id                        $inCore->request('id''int'0);
            
$article['category_id']    = $inCore->request('category_id''int'1);
            
$article['title']          = $inCore->request('title''str''');
            
$article['url']            = $inCore->request('url''str''');
            
$article['showtitle']      = $inCore->request('showtitle''int'0);
            
$article['description']    = $inCore->request('description''html''');
            
$article['description']    = $inDB->escape_string($article['description']); 
            
$article['content']        = $inCore->request('content''html''');
            
$article['content']           = $inDB->escape_string($article['content']); 
            
$article['published']      = $inCore->request('published''int'0);
            
            
$article['showdate']       = $inCore->request('showdate''int'0);
            
$article['showlatest']     = $inCore->request('showlatest''int'0);
            
$article['showpath']       = $inCore->request('showpath''int'0);
            
$article['comments']       = $inCore->request('comments''int'0);
            
$article['canrate']        = $inCore->request('canrate''int'0);
            
            
$article['enddate']        = $inCore->request('enddate''str''');
            
$article['is_end']         = $inCore->request('is_end''int'0);
            
$article['pagetitle']      = $inCore->request('pagetitle''str''');
            
            
$article['tags']           = $inCore->request('tags''str''');

            
$olddate                   $inCore->request('olddate''str''');
            
$pubdate                   $inCore->request('pubdate''str''');

            
$article['user_id']         = $inCore->request('user_id''int'$inUser->id);

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

            
$autokeys                   $inCore->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'] = $inCore->request('meta_desc''str');
                        
$article['meta_keys'] = $inCore->request('meta_keys''str');
                        break;
            }

            
$model->updateArticle($id$article);

            if (!
$inCore->request('is_public''int'0)){
                
$showfor $_REQUEST['showfor'];                
                
$model->setArticleAccess($id$showfor);
            } else {
                
$model->clearArticleAccess($id);
            }


            
$file       'article'.$id.'.jpg';

            if (
$inCore->request('delete_image''int'0)){
                @
unlink(PATH."/images/photos/small/$file");
                @
unlink(PATH."/images/photos/medium/$file");
            } else {

                if (isset(
$_FILES["picture"]["name"]) && @$_FILES["picture"]["name"]!=''){
                    
//generate image file
                    
$tmp_name   $_FILES["picture"]["tmp_name"];                   
                    
//upload image and insert record in db
                    
if (@move_uploaded_file($tmp_namePATH."/images/photos/$file")){
                        
$inCore->includeGraphics();
                        if (
$cfg['watermark'] && !$cfg['watermark_only_big']) { @img_add_watermark(PATH."/images/photos/$file"); }
                        @
img_resize(PATH."/images/photos/$file"PATH."/images/photos/small/$file"$cfg['img_small_w'], $cfg['img_small_w'], $cfg['img_sqr']);
                        @
img_resize(PATH."/images/photos/$file"PATH."/images/photos/medium/$file"$cfg['img_big_w'], $cfg['img_big_w'], $cfg['img_sqr']);
                        if (
$cfg['watermark'] && $cfg['watermark_only_big']) { @img_add_watermark(PATH."/images/photos/medium/$file"); }
                        @
unlink(PATH."/images/photos/$file");
                        @
chmod(PATH."/images/photos/small/$file"0777);
                        @
chmod(PATH."/images/photos/medium/$file"0777);
                    }
                }

            }

            if (!isset(
$_SESSION['editlist']) || @sizeof($_SESSION['editlist'])==0){
                
header('location:?view=content');        
            } else {
                
header('location:?view=content&do=edit');        
            }    
        }
    }
    
    if (
$do == 'submit'){
        
$article['category_id']     = $inCore->request('category_id''int'1);
        
$article['title']           = $inCore->request('title''str');
        
$article['url']             = $inCore->request('url''str');
        
$article['showtitle']       = $inCore->request('showtitle''int'0);
        
$article['description']     = $inCore->request('description''html''');
        
$article['description']     = $inDB->escape_string($article['description']); 
        
$article['content']         = $inCore->request('content''html''');
        
$article['content']            = $inDB->escape_string($article['content']); 

        
$article['published']       = $inCore->request('published''int'0);

        
$article['showdate']        = $inCore->request('showdate''int'0);
        
$article['showlatest']      = $inCore->request('showlatest''int'0);
        
$article['showpath']        = $inCore->request('showpath''int'0);
        
$article['comments']        = $inCore->request('comments''int'0);
        
$article['canrate']         = $inCore->request('canrate''int'0);

        
$article['enddate']         = $_REQUEST['enddate'];
        
$article['is_end']          = $inCore->request('is_end''int'0);
        
$article['pagetitle']       = $inCore->request('pagetitle''str''');

        
$article['tags']            = $inCore->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']         = $inCore->request('user_id''int'$inUser->id);

        
$autokeys                   $inCore->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'] = $inCore->request('meta_desc''str');
                    
$article['meta_keys'] = $inCore->request('meta_keys''str');
                    break;
        }

        
$article['id']              = $model->addArticle($article);
        
        if (!
$inCore->request('is_public''int'0)){
            
$showfor $_REQUEST['showfor'];
            if (
sizeof($showfor)>0  && !$inCore->request('is_public''int'0)){
                
$model->setArticleAccess($article['id'], $showfor);
            }
        }

        
$inmenu $inCore->request('createmenu''str''');

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

        if (
$cfg['af_on'] && $category_id != $cfg['af_hidecat_id'] && !$inCore->inRequest('noforum')){
            
cmsAutoCreateThread($article$cfg);
        }

        if (isset(
$_FILES["picture"]["name"]) && @$_FILES["picture"]["name"]!=''){
            
//generate image file
            
$tmp_name   $_FILES["picture"]["tmp_name"];
            
$file       'article'.$article['id'].'.jpg';
            
//upload image and insert record in db
            
if (@move_uploaded_file($tmp_namePATH."/images/photos/$file")){
                
$inCore->includeGraphics();
                if (
$cfg['watermark'] && !$cfg['watermark_only_big']) { @img_add_watermark(PATH."/images/photos/$file"); }
                @
img_resize(PATH."/images/photos/$file"PATH."/images/photos/small/$file"$cfg['img_small_w'], $cfg['img_small_w'], $cfg['img_sqr']);
                @
img_resize(PATH."/images/photos/$file"PATH."/images/photos/medium/$file"$cfg['img_big_w'], $cfg['img_big_w'], $cfg['img_sqr']);
                if (
$cfg['watermark'] && $cfg['watermark_only_big']) { @img_add_watermark(PATH."/images/photos/medium/$file"); }
                @
unlink(PATH."/images/photos/$file");
                @
chmod(PATH."/images/photos/small/$file"0755);
                @
chmod(PATH."/images/photos/medium/$file"0755);
            }
        }

        
header('location:?view=content');
    }      

   if (
$do == 'add' || $do == 'edit'){
   
           require(
'../includes/jwtabs.php');
        
$GLOBALS['cp_page_head'][] = jwHeader();
 
         
$toolmenu = array();
        
$toolmenu[0]['icon'] = 'save.gif';
        
$toolmenu[0]['title'] = 'Сохранить';
        
$toolmenu[0]['link'] = 'javascript:document.addform.submit();';

        
$toolmenu[1]['icon'] = 'cancel.gif';
        
$toolmenu[1]['title'] = 'Отмена';
        
$toolmenu[1]['link'] = 'javascript:history.go(-1);';

        
cpToolMenu($toolmenu);
   
        if (
$do=='add'){
             echo 
'<h3>Добавить статью</h3>';
               
cpAddPathway('Добавить статью''index.php?view=content&do=add');
             
$mod['category_id'] = $_REQUEST['to'];
        } else {
                     if(isset(
$_REQUEST['multiple'])){                 
                        if (isset(
$_REQUEST['item'])){                    
                            
$_SESSION['editlist'] = $_REQUEST['item'];
                        } else {
                            echo 
'<p class="error">Нет выбранных объектов!</p>';
                            return;
                        }                 
                     }
                        
                     
$ostatok '';
                    
                     if (isset(
$_SESSION['editlist'])){
                        
$id array_shift($_SESSION['editlist']);
                        if (
sizeof($_SESSION['editlist'])==0) { unset($_SESSION['editlist']); } else 
                        { 
$ostatok '(На очереди: '.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
                              FROM cms_content 
                             WHERE id = 
$id LIMIT 1";
                     
$result dbQuery($sql) ;
                     if (
mysql_num_rows($result)){
                        
$mod mysql_fetch_assoc($result);
                     }
                    
                     echo 
'<h3>Редактировать статью '.$ostatok.'</h3>';
                      
cpAddPathway($mod['title'], 'index.php?view=menu&do=edit&id='.$mod['id']);
            }   
    
?>
    <form id="addform" name="addform" method="post" action="index.php" enctype="multipart/form-data">
        <input type="hidden" name="view" value="content" />

        <table class="proptable" width="100%" cellpadding="15" cellspacing="2">
            <tr>
            
                <!-- главная ячейка -->
                <td valign="top">

                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td valign="top">
                                <div><strong>Название статьи</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="Показывать заголовок" 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>Дата публикации</strong></div>
                                <div>
                                    <input name="pubdate" type="text" id="pubdate" style="width:100px" <?php if(@!$mod['pubdate']) { echo 'value="'.date('Y-m-d').'"'; } else { echo 'value="'.$mod['pubdate'].'"'; } ?>/>
                                    <?php
                                        
//include javascript
                                        
$GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="/includes/jquery/jquery.js"></script>';
                                        
$GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="/includes/jquery/datepicker/date_ru_win1251.js"></script>';
                                        
$GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="/includes/jquery/datepicker/datepicker.js"></script>';
                                        
$GLOBALS['cp_page_head'][] = '<link href="/includes/jquery/datepicker/datepicker.css" rel="stylesheet" type="text/css" />';
                                        if (@!
$mod['pubdate']){
                                            
$GLOBALS['cp_page_head'][] = '<script type="text/javascript">$(document).ready(function(){$('#pubdate').datePicker({startDate:'01/01/1996'}).val(new Date().asString()).trigger('change');});</script>';
                                        
} else {
                                            
$GLOBALS['cp_page_head'][] = '<script type="text/javascript">$(document).ready(function(){$('#pubdate').datePicker({startDate:'01/01/1996'}).val(''.$mod['pubdate'].'').trigger('change');});</script>';
                                        
}
                                    
?>
                                    <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="Показывать дату и автора" value="1" <?php if ($mod['showdate'] || $do=='add') { echo 'checked="checked"'; } ?>/>
                            </td>
                        </tr>
                    </table>

                    <div><strong>Анонс статьи (не обязательно)</strong></div>
                    <div><?php $inCore->insertEditor('description'$mod['description'], '200''100%'); ?></div>

                    <div><strong>Полный текст статьи</strong></div>
                    <?php insertPanel(); ?>
                    <div><?php $inCore->insertEditor('content'$mod['content'], '400''100%'); ?></div>

                    <div><strong>Теги статьи</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>Автоматически сгенерировать ключевые слова и описание</strong></label>
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                                <input type="radio" name="autokeys" id="autokeys2" value="2"/>
                            </td>
                            <td>
                                <label for="autokeys2"><strong>Использовать теги и анонс как ключевые слова и описание</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>Заполнить ключевые слова и описание вручную</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>Не создавать тему на форуме для обсуждения статьи</strong></label></td>
                        </tr>
                        <?php ?>
                    </table>

                </td>

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

                    <?php ob_start(); ?>

                    {tab=Публикация}

                    <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>Публиковать статью</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']==|| !isset($mod['category_id'])) { echo 'selected'; }?>>-- Корневой раздел --</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'; } ?>>Глубиномер: Только название</option>
                            <option value="1" <?php if (@$mod['showpath']) { echo 'selected'; } ?>>Глубиномер: Полный путь</option>
                        </select>
                    </div>

                    <div style="margin-top:15px">
                        <strong>URL страницы</strong><br/>
                        <div style="color:gray">Если не указан, генерируется из заголовка</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>Автор статьи</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>Фотография</strong></div>
                    <div style="margin-bottom:10px">
                        <?php
                            
if ($do=='edit'){
                                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">
                            <img src="/images/photos/small/article<?php echo $id?>.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">Удалить фотографию</label></td>
                            </tr>
                        </table>
                        <?php
                                
}
                            }
                        
?>
                        <input type="file" name="picture" style="width:100%" />
                    </div>
                    
                    <div style="margin-top:25px"><strong>Параметры публикации</strong></div>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist">
                        <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">Показывать в "новых статьях"</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">Разрешить комментарии</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">Разрешить рейтинг</label></td>
                        </tr>
                    </table>

                    <?php if ($do=='add'){ ?>
                        <div style="margin-top:25px">
                            <strong>Создать ссылку в меню</strong>
                        </div>
                        <div>
                            <select name="createmenu" id="createmenu" style="width:99%">
                                <option value="0" selected="selected">-- не создавать --</option>
                                <option value="mainmenu">Главное меню</option>
                                <?php for($m=1;$m<=15;$m++){ ?>
                                    <option value="menu<?php echo $m?>">Дополнительное меню <?php echo $m?></option>
                                <?php ?>
                            </select>
                        </div>
                    <?php ?>

                    {tab=Сроки}

                    <div style="margin-top:5px">
                        <strong>Срок показа статьи</strong>
                    </div>
                    <div>
                        <select name="is_end" id="is_end" style="width:99%">
                            <option value="0" <?php if (@!$mod['is_end']) { echo 'selected'; } ?>>Не ограничен</option>
                            <option value="1" <?php if (@$mod['is_end']) { echo 'selected'; } ?>>По дату окончания</option>
                        </select>
                    </div>

                    <div style="margin-top:20px">
                        <strong>Дата окончания:</strong><br/>
                        <span class="hinttext">В формате ГГГГ-ММ-ДД</span>
                    </div>
                    <div><input name="enddate" type="text" style="width:99%" <?php if(@!$mod['is_end']) { echo 'value="'.date('Y-m-d').'"'; } else { echo 'value="'.$mod['enddate'].'"'; } ?>id="enddate" /></div>
                    
                    
                    {tab=SEO}

                    <div style="margin-top:5px">
                        <strong>Заголовок страницы</strong><br/>
                        <span class="hinttext">Если не указан, будет совпадать с названием</span>
                    </div>
                    <div>
                        <input name="pagetitle" type="text" id="pagetitle" style="width:99%" value="<?php if (isset($mod['pagetitle'])) { echo $mod['pagetitle']; } ?>" />
                    </div>

                    <div style="margin-top:20px">
                        <strong>Ключевые слова</strong><br/>
                        <span class="hinttext">Через запятую, 10-15 слов</span>
                    </div>
                    <div>
                         <textarea name="meta_keys" style="width:97%" rows="2" id="meta_keys"><?php echo @$mod['meta_keys'];?></textarea>
                    </div>

                    <div style="margin-top:20px">
                        <strong>Описание</strong><br/>
                        <span class="hinttext">Не более 250 символов</span>
                    </div>
                    <div>
                         <textarea name="meta_desc" style="width:97%" rows="4" id="meta_desc"><?php echo @$mod['meta_desc'];?></textarea>
                    </div>

                    {tab=Доступ}

                    <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 dbQuery($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 dbQuery($sql2);
                                        
$ord = array();

                                        if (
mysql_num_rows($result2)){
                                            
$public '';
                                            
$style '';
                                            while (
$r mysql_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>Общий доступ</strong></label></td>
                        </tr>
                    </table>
                    <div style="padding:5px">
                        <span class="hinttext">
                            Если отмечено, материал виден всем посетителям. Снимите галочку, чтобы вручную выбрать разрешенные группы пользователей.
                        </span>
                    </div>

                    <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp">
                        <div>
                            <strong>Показывать группам:</strong><br />
                            <span class="hinttext">
                                Можно выбрать несколько, удерживая CTRL.
                            </span>
                        </div>
                        <div>
                            <?php
                                
echo '<select style="width: 99%" name="showfor[]" id="showin" size="6" multiple="multiple" '.$style.'>';

                                if (
mysql_num_rows($result)){
                                    while (
$item=mysql_fetch_assoc($result)){
                                        echo 
'<option value="'.$item['id'].'"';
                                        if (
$do=='edit'){
                                            if (
inArray($ord$item['id'])){
                                                echo 
'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="Создать материал"'; } else { echo 'value="Сохранить материал"'; } ?> />
            <input name="back" type="button" id="back" value="Отмена" 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
    
}

?>
Онлайн: 0
Реклама