/modules/menu/edit.categorie.php
PHP | 151 lines | 136 code | 15 blank | 0 comment | 10 complexity | 6470e8d7255f444618ca4f63d134dbc9 MD5 | raw file
- <? include "../../inc/header_m.php";?>
- <?
- if (!empty($parent_home))
- $home_parent=" and parentid='$parent_home' ";
- if (isset($_GET['id_material'])||isset($_POST['id_material']))
- {
- if (count($_POST)>0)
- {
- $id=$_POST['id_material'];
- if (mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where id={$id} $home_parent and pid=0 limit 1"))==0) {die();}
- $name=$_POST['name'];
- $tmpl=$_POST['tmpl'];
- $position=$_POST['position'];
- $text=addslashes($_POST['text']);
- $status=$_POST['status'];
- $pid=$_POST['pid'];
- $parent=$pid;
- if ($parent<=0)
- $parent=$id;
- else $parent=getdb('db_catalog_cat',$pid,'parent');
- function editcatparent($id,$lev,$g_id,$db,$parent) //Дерево
- {
- global $pref;
- $sql01 = "select * from {$pref}db_{$db} where pid=$id ";
- $result01 = mysql_query($sql01);
- while ($rowo01 = mysql_fetch_array($result01)) {
- $id = $rowo01['id'];
- $pid=$rowo01['pid'];
- mysql_query("update {$pref}db_{$db} set parent='{$parent}' where id='{$id}'");
- editcatparent($id,$lev,$g_id,$db,$parent);
- }
- }
- editcatparent($id,1,0,'catalog_cat',$parent) ;
- $mes="<font color='green'><b class='saveinfo'>Сохранено</b></font>";
- mysql_query("update {$pref}db_{$modul} set name='{$name}',tmpl='{$tmpl}',position='{$position}',text='{$text}',status='{$status}',pid='0',parent='{$parent}' where id='{$id}' $home_parent");
- if (isset($_POST['sf1'])) header("Location: index.php");
- }
- else
- {
- unset($mes);
- $id=$_GET['id_material'];
- }
- $query=mysql_query("select * from {$pref}db_{$modul} where id={$id} $home_parent and pid=0 limit 1");
- $res=mysql_fetch_array($query);
- $m_title="Изменить категорию";
- }
-
-
-
- else
- {
- mysql_query("insert into {$pref}db_{$modul} set sort=0, parentid='$parent_home'");
- $id=mysql_insert_id();
- $m_title="Добавить категорию";
- }
- $body="";
- $body1="";
-
- $body.="
- <fieldset>
- <label>Название меню*</label>
- <input type='text' class='validate[required]' name='name' id='name' value='{$res['name']}' />
- </fieldset>
- <fieldset>
- <label>Текст</label>
- <textarea name='text' id='elm1'>{$res['text']}</textarea>
- </fieldset>";
- $body.="
- <fieldset class='left'>
- <label>Шаблон</label>
- <select name='tmpl' class='tmpl'>";
- $tpl=opendir($pt.'templates/tpl/');
- while(($tpla=readdir($tpl))!==false)
- {
- if (strlen($tpla)>5) $body.="
- <option value='$tpla' ";if ($tpla==$res['tmpl'])$body.="selected";$body.=">$tpla</option>";
- };
- $body.="
- </select><input type='hidden' value='".$id."'/></fieldset>
- <fieldset class='right'>
- <label>Позиция</label>
- <select name='position' class='position'>";
- $body.="
- </select></fieldset><div class='clear'></div>
- <fieldset class='left'>
- <label>Добавить в</label>
- <select class='' name='pid' id='pid'><option value='0'>--</option>
- ";
- $body1.="
- </select><br>
- </fieldset>
- <fieldset class='right'>
- <label>Статус*</label>
- <select class='validate[required]' name='status' id='status' >
- <option value='1' ";if ($res['status']==1) $body1.="selected";$body1.=">Опубликовано</option>
- <option value='2' ";if ($res['status']==2) $body1.="selected";$body1.=">Не опубликованно</option>
- </select></fieldset><div class='clear'></div>
- <input type='hidden' value='{$id}' name='id_material' />
- Поля, отмеченные * являются обязательными для заполнения
- ";
- ?>
- <script>
- function getPosition(val,id)
- {
- $.post('/<?=$cmspatch?>/templates/getPositionTmpl2.php',
- {"tmpl":""+val+"","id":""+id+""},
- function(result){
- $('.position').html(result.bod);
- },"json"
- );
- }
- $(document).ready(function(){
- getPosition($('.tmpl').val(),$('.tmpl').next().val());
- $('.tmpl').change(function(){
- getPosition($(this).val(),$(this).next().val())
- });
- });
- </script>
- <form action='' class='userInform' method='post' enctype='multipart/form-data'>
- <? if (count($_POST)>0){?><h4 class="alert_success"><?=$mes?></h4><?}?>
- <article class="module width_full">
- <header><h3 class="tabs_involved"><?=$m_title?></h3>
- <!-- <ul class="tabs">
- <li><a href="#tab1">Список</a></li>
- </ul> -->
- </header>
- <div class="module_content">
- <div id="tab1" class="tab_content">
- <?=$body?>
- <?=$body1?>
- </div></div>
- <footer>
- <div class="submit_link">
- <input type='submit' value='Сохранить' name='sf' />
- <input type='submit' value='Сохранить и закрыть' name='sf1' />
- </div>
- </footer>
- </article>
- </form>
- <? include "../../inc/footer_m.php"; ?>