/modules/materials/edit.categorie.php
PHP | 116 lines | 101 code | 15 blank | 0 comment | 9 complexity | cee20cb15ba707500bcdf9d66803df01 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}_cat where id={$id} $home_parent limit 1"))==0) {die();}
- $name=$_POST['name'];
- $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}_cat set name='{$name}',text='{$text}',status='{$status}',pid='{$pid}',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}_cat where id={$id} $home_parent limit 1");
- $res=mysql_fetch_array($query);
- $m_title="Изменить категорию";
- }
-
-
-
- else
- {
- mysql_query("insert into {$pref}db_{$modul}_cat 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>
- <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' />
- Поля, отмеченные * являются обязательными для заполнения
- ";
- ?>
- <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?>
- <?tree2(0,1,$res['pid'],$modul.'_cat','name');?>
- <?=$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"; ?>