PageRenderTime 259ms CodeModel.GetById 18ms RepoModel.GetById 2ms app.codeStats 0ms

/modules/structure/index.php

https://bitbucket.org/ssimpledecision/simpledecision
PHP | 138 lines | 132 code | 6 blank | 0 comment | 24 complexity | e586c1d552ed1e6e88e9b3988f4f1a87 MD5 | raw file
  1. <? include "../../inc/header_m.php";?>
  2. <?
  3. if (!empty($structure_home))
  4. $home_parent=" and parent='$structure_home' ";
  5. $searchinmodul=$_POST['searchinmodul'];
  6. if (!empty($searchinmodul)){
  7. $searchinmodul=explode(' ', $searchinmodul);
  8. foreach ($searchinmodul as $key => $value) {
  9. $searchinmodules.="or UPPER(alias) LIKE '%".strtoupper($value)."%' ";
  10. $searchinmodules.="or UPPER(name) LIKE '%".strtoupper($value)."%' ";
  11. $searchinmodules.="or UPPER(menu_name) LIKE '%".strtoupper($value)."%' ";
  12. $searchinmodules.="or UPPER(anons) LIKE '%".strtoupper($value)."%' ";
  13. $searchinmodules.="or UPPER(text) LIKE '%".strtoupper($value)."%' ";
  14. $searchinmodules.="or UPPER(href) LIKE '%".strtoupper($value)."%' ";
  15. $searchinmodules.="or UPPER(title) LIKE '%".strtoupper($value)."%' ";
  16. $searchinmodules.="or UPPER(description) LIKE '%".strtoupper($value)."%' ";
  17. }
  18. $searchinmodules=' and ('.substr($searchinmodules, 2).')';
  19. }
  20. $del = $_POST['list'];
  21. $sor = $_POST['sor'];
  22. if (isset($del))
  23. foreach ($del as &$delv)
  24. {
  25. if ($delv>1) {
  26. if (!empty($structure_home) && $structure_home==$delv) die();
  27. if (mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where id={$delv} $home_parent limit 1"))>0) {
  28. $sql1="select * from {$pref}db_pic where id_type={$id_modules} and id_el={$delv} ";
  29. $query1=mysql_query($sql1);
  30. if ($query1 && mysql_num_rows($query1)>0)
  31. while ($res1=mysql_fetch_array($query1)) {
  32. $pic=$res1['pic'];
  33. unlink("{$_SERVER['DOCUMENT_ROOT']}/files/images/{$id_modules}/{$pic}");
  34. unlink("{$_SERVER['DOCUMENT_ROOT']}/files/images/{$id_modules}/mcith/mcith_{$pic}");
  35. }
  36. mysql_query("delete from {$pref}db_pic where id_type={$id_modules} and id_el={$delv}");
  37. mysql_query("delete from {$pref}db_{$modul} where id={$delv} $home_parent");
  38. mysql_query("delete from {$pref}db_structure_alias where id_page=$delv");
  39. }
  40. }}
  41. if (isset($sor))
  42. foreach ($sor as $sork=>$sorv)
  43. {
  44. if (mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where id={$sork} $home_parent limit 1"))>0) {
  45. mysql_query("update {$pref}db_{$modul} set sort={$sorv} where id={$sork}");
  46. }}
  47. if (isset($_GET['sort'])) $_SESSION['sort'] = $_GET['sort'];
  48. if (isset($_SESSION['sort'])) $sort = $_SESSION['sort'];
  49. if (strpos($mod_ver,substr($sort,0,2))===false)
  50. $sort = 'sort,id';
  51. mysql_query("delete from {$pref}db_{$modul} where status=-1");
  52. $lim=30;
  53. if (isset($_GET['p'])) $p=$_GET['p']; else {$p=1;$_GET['p']=1;}
  54. $o=$p*$lim-$lim;
  55. $query=mysql_query("select * from {$pref}db_{$modul} where 1=1 {$home_parent} {$searchinmodules} order by {$sort} limit $o,$lim");
  56. $total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where 1=1 {$home_parent} {$searchinmodules}"));
  57. $m_title="Структура";
  58. $body="
  59. <table class='tablesorter' cellspacing='0'>
  60. <thead>
  61. <tr>
  62. <th>ID</th>
  63. <th>Название</th>
  64. <th>Шаблон</th>
  65. <th>Ссылка</th>
  66. <th>Сортировка</th>
  67. <th>Статус</th>
  68. <td>Удалить<input type='checkbox' class='selectdelete'></td>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. ";
  73. while ($res=mysql_fetch_array($query))
  74. {
  75. if (empty($res['tpl'])) $res['tpl']='По умолчанию';
  76. $body.="
  77. <tr>
  78. <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['id']}</td>
  79. <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['name']}</td>
  80. <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['tpl']}</td>";
  81. if (empty($home_root))
  82. $body.="
  83. <td><a href='{$res['href']}' target='_blank'>".substr($res['href'],0,50)."...</td>";
  84. else
  85. $body.="
  86. <td><a href='".str_replace($home_root, '/', str_replace($home_root.'/', '/', $res['href']))."' target='_blank'>".substr(str_replace($home_root, '/', str_replace($home_root.'/', '/', $res['href'])),0,50)."...</td>";
  87. $body.="
  88. <td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor[{$res['id']}]' value='{$res['sort']}' /></td>
  89. <td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}-{$res['id']}-{$res['status']}' >
  90. <img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
  91. <td>";
  92. if (!(!empty($structure_home) && $structure_home==$res['id']))
  93. $body.="<input type='checkbox' onclick='check();' name='list[]' class='listdelete' value='{$res['id']}' />";
  94. $body.="</td>
  95. </tr>";
  96. }
  97. $body.="
  98. </tbody>
  99. </table>
  100. ";
  101. ?>
  102. <script>
  103. $(document).ready(function(){
  104. $('.modulForm').submit(function(){
  105. if (!confirm("Уверены, что хотите внести изменения?"))
  106. return false;
  107. })
  108. });
  109. </script>
  110. <form method='POST' acction='' class='modulForm' >
  111. <? if (isset($_POST['sf'])){?><h4 class="alert_success">Сохранено</h4><?}?>
  112. <article class="module width_full">
  113. <header><h3 class="tabs_involved"><?=$m_title?></h3>
  114. <!-- <ul class="tabs">
  115. <li><a href="#tab1">Список</a></li>
  116. </ul> -->
  117. </header>
  118. <div class="tab_container">
  119. <div id="tab1" class="tab_content">
  120. <?=$body?>
  121. </div></div>
  122. <footer>
  123. <div class="submit_link fl">
  124. <? paging_m($total,$lim,$p);?>
  125. </div>
  126. <div class="submit_link">
  127. <input type='submit' value='Сохранить' name='sf' />
  128. </div>
  129. </footer>
  130. </article>
  131. </form>
  132. <? include "../../inc/footer_m.php"; ?>