PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/admin-dashboard/modules/menu_link/update.php

https://gitlab.com/diva-lab/essam-labs
PHP | 266 lines | 257 code | 2 blank | 7 comment | 42 complexity | 14a762d4c6bc023e3ae168d7fc903cc1 MD5 | raw file
  1. <?php
  2. require_once("../layout/initialize.php");
  3. //check id access
  4. if(isset($_GET['id']) && is_numeric($_GET['id'])){
  5. $record_id = $_GET['id'];
  6. $define_class = new MenuLink();
  7. $define_class->enable_relation();
  8. //Menu Group Info
  9. $record_info = $define_class->find_by_id($record_id);
  10. //check id access
  11. if(empty($record_info->id)){
  12. redirect_to("view.php");
  13. }else{
  14. $group_data = MenuGroup::find_by_id($record_info->group_id);
  15. if($record_info->path_type == 'category'){
  16. //get all category
  17. $define_cat_class = new Taxonomies();
  18. $define_cat_class->enable_relation();
  19. $records = $define_cat_class->taxonomies_data('category',null,null,'inserted_date','DESC',null,null,$general_setting_info->translate_lang_id,'yes');
  20. }else{
  21. ///get all nodes
  22. $define_path_class = new Nodes;
  23. $define_path_class->enable_relation();
  24. $records = $define_path_class->node_data($record_info->path_type,null,null,null,null,null,$general_setting_info->translate_lang_id,null,null,null);
  25. }
  26. }
  27. }else{
  28. redirect_to("../MenuGroup/view.php");
  29. }
  30. require_once("../layout/header.php");
  31. require_once("../../assets/texteditor4/head.php");
  32. ?>
  33. <script type="text/javascript" src="../../js-crud/menu_links.js"></script>
  34. <!--header end-->
  35. <!--sidebar start-->
  36. <?php require_once("../layout/navigation.php");?>
  37. <!--sidebar end-->
  38. <!--main content start-->
  39. <section id="main-content">
  40. <section class="wrapper site-min-height">
  41. <h4>Menu link Module </h4>
  42. <!-- page start-->
  43. <div class="row">
  44. <aside class="profile-info col-lg-8">
  45. <section>
  46. <div class="panel">
  47. <div class="panel-heading"> Edit Menu link in <?php echo '"'.$group_data->title.'"' ?> </div>
  48. <div class="panel-body">
  49. <form class="form-horizontal tasi-form" role="form" id="form_crud" action="data_model/update.php">
  50. <input type="hidden" id="process_type" value="update">
  51. <input type="hidden" id="group_id" value="<?php echo $record_info->group_id; ?>">
  52. <input type="hidden" id="record" value="<?php echo $record_id; ?>">
  53. <section class="panel">
  54. <header class="panel-heading tab-bg-dark-navy-blue">
  55. <ul class="nav nav-tabs">
  56. <li class=" center-block active" > <a data-toggle="tab" href="#main_info" class="text-center"><strong>Main Info</strong></a></li>
  57. <li class=" center-block"> <a data-toggle="tab" href="#link_option" class="text-center"><strong>Link Option</strong></a></li>
  58. </ul>
  59. </header>
  60. <div class="panel-body">
  61. <div class="tab-content">
  62. <div id="main_info" class="tab-pane active ">
  63. <section class="panel col-lg-9">
  64. <header class="panel-heading tab-bg-dark-navy-blue ">
  65. <ul class="nav nav-tabs">
  66. <?php
  67. //create tabs for all available languages
  68. $languages = Localization::find_all('id','desc');
  69. $serial_tabs = 1;
  70. foreach($languages as $language){
  71. $lang_tab_header = ucfirst($language->name);
  72. echo "<li class='";if($serial_tabs == 1){ echo " active ";} echo"'> <a data-toggle='tab' href='#$language->name'>
  73. <strong>$lang_tab_header</strong></a></li>";
  74. $serial_tabs++;
  75. }
  76. ?>
  77. </ul>
  78. </header>
  79. <div class="panel-body">
  80. <div class="tab-content">
  81. <?php
  82. $serial_tabs_content = 1;
  83. foreach($languages as $language):
  84. //get data by language
  85. $main_content = MenuLinkContent::get_link_content($record_id, $language->id);
  86. echo "<div id='$language->name' class='tab-pane"; if($serial_tabs_content == 1){ echo " active ";} echo"'>";
  87. ?>
  88. <input class='main_content' type='hidden' id='<?php echo "content_id_$language->label"; ?>'
  89. value='<?php if(!empty($main_content )){echo $main_content->id;}else{ echo "0";} ?>'>
  90. <div class='form-group'>
  91. <label class='col-lg-2'>Title:</label>
  92. <div class='col-lg-9'>
  93. <input type='text' class='form-control main_content' id='<?php echo "title_$language->label";?>' autocomplete='off'
  94. value='<?php if(!empty($main_content ))echo $main_content->title; ?>' >
  95. </div>
  96. </div>
  97. <div class='form-group'>
  98. <label class='col-lg-2'>Description:</label>
  99. <div class='col-lg-9'>
  100. <textarea class=' form-control main_content' id='<?php echo "description_$language->label";?>'>
  101. <?php if(!empty($main_content ))echo $main_content->description; ?></textarea>
  102. </div>
  103. </div>
  104. </div>
  105. <?php
  106. $serial_tabs_content++;
  107. endforeach;
  108. ?>
  109. </div>
  110. </section>
  111. </div>
  112. <div id="link_option" class="tab-pane ">
  113. <div class="form-group">
  114. <label class="col-lg-2">Sorting:</label>
  115. <div class="col-lg-8">
  116. <input type="text" class="form-control" id="sorting" autocomplete="off" value=" <?php echo $record_info->sorting; ?>"
  117. style="width:50px;"/>
  118. </div>
  119. </div>
  120. <div class="form-group">
  121. <label class="col-lg-2">Parent:</label>
  122. <div class="col-lg-8">
  123. <select class="form-control" id="sid">
  124. <option value="0">Root</option>
  125. <?php echo $define_class->getMenu(0,$record_info->parent_id,$record_info->group_id,$general_setting_info->translate_lang_id);?>
  126. </select>
  127. </div>
  128. </div>
  129. <div class="form-group" >
  130. <label class="col-lg-2 "> Path Type:</label>
  131. <div class="col-lg-8">
  132. <select class="form-control" id="path_type">
  133. <option value="page" <?php if($record_info->path_type == "page") echo "selected";?>>Page</option>
  134. <option value="post" <?php if($record_info->path_type == "post") echo "selected";?>>Post</option>
  135. <option value="event" <?php if($record_info->path_type == "event") echo "selected";?>>Event</option>
  136. <option value="external" <?php if($record_info->path_type == "external") echo "selected";?>>External</option>
  137. <option value="category" <?php if($record_info->path_type == "category") echo "selected";?>>Category</option>
  138. </select>
  139. </div>
  140. </div>
  141. <div class="form-group" >
  142. <label class="col-lg-2 "> Path:</label>
  143. <div class="col-lg-8" id="select_div">
  144. <input type='text' class='form-control <?php if($record_info->path_type != 'external'){echo " hide";}?>' id='external_path'
  145. value='<?php echo $record_info->external_path?>'/>
  146. <select class="form-control <?php if($record_info->path_type== 'external'){ echo " hide";}?>" id="path">
  147. <option value=""> Select <?php if($record_info->path_type == 'category'){ echo 'category'; }else{echo"Nodes"; }?> </option>
  148. <?php foreach($records as $record){
  149. echo "<option value='$record->id'";
  150. if($record->id == $record_info->path){
  151. echo "selected";
  152. }
  153. echo ">";
  154. if($record_info->path_type == 'category'){ echo "$record->name"; }else{echo"$record->title"; }
  155. echo"</option>";
  156. }?>
  157. </select>
  158. </div>
  159. <div id="node_loading_data"></div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </section>
  165. <div class="form-group">
  166. <div class="col-lg-offset-2 col-lg-10">
  167. <button type="submit" class="btn btn-info" id="submit">Save</button>
  168. <button type="submit" class="btn btn-default">Cancel</button>
  169. <button type="button" class="btn btn-info"
  170. onClick="window.location.href = 'view.php?group_id='+<?php echo $group_data->id?>" >View Links </button>
  171. <div id="loading_data"></div>
  172. </div>
  173. </div>
  174. </form>
  175. </div>
  176. </div>
  177. </section>
  178. </aside>
  179. <div class="col-lg-4">
  180. <section class="panel panel-primary">
  181. <header class="panel-heading"> Publish Options: </header>
  182. <div class="panel-body">
  183. <form class="form-horizontal tasi-form" role="form">
  184. <div class="form-group ">
  185. <label class="col-lg-5">Status:</label>
  186. <div class="col-lg-6">
  187. <label class="checkbox-inline">
  188. <input type="radio" name="shadow" class="radio" value="draft" <?php if($record_info->status=="draft") echo 'checked'?>>
  189. Draft</label>
  190. <label class="checkbox-inline">
  191. <input type="radio" name="shadow" class="radio" value="publish" <?php if($record_info->status=="publish") echo 'checked'?>>
  192. Publish</label>
  193. </div>
  194. </div>
  195. <div class="form-group <?php if($record_info->path_type != 'category'){echo " hide";} ?>" id="drop_down">
  196. <label class="col-lg-5">Drop Down:</label>
  197. <div class="col-lg-6">
  198. <label class="checkbox-inline">
  199. <input type="radio" name="drop_down" class="radio" value="yes" <?php if($record_info->drop_down == "yes") echo 'checked'?>>
  200. Yes</label>
  201. <label class="checkbox-inline">
  202. <input type="radio" name="drop_down" class="radio" value="no" <?php if($record_info->drop_down == "no") echo 'checked'?>>
  203. No</label>
  204. </div>
  205. </div>
  206. <div class="form-group <?php if($record_info->path_type != 'category'){echo " hide";} ?>" id="op_div">
  207. <label class="col-lg-4">Drop Down Style:</label>
  208. <div class="col-lg-8">
  209. <label class="checkbox-inline">
  210. <input type="radio" name="drop_dwon_style" class="radio" value="0" <?php if($record_info->drop_down_style == "") echo 'checked'?>>
  211. No </label>
  212. <label class="checkbox-inline">
  213. <input type="radio" name="drop_dwon_style" class="radio" value="op1" <?php if($record_info->drop_down_style == "op1") echo 'checked'?>>
  214. Op1</label>
  215. <label class="checkbox-inline">
  216. <input type="radio" name="drop_dwon_style" class="radio" value="op2" <?php if($record_info->drop_down_style == "op2") echo 'checked'?>>
  217. Op 2</label>
  218. <label class="checkbox-inline">
  219. <input type="radio" name="drop_dwon_style" class="radio" value="op3" <?php if($record_info->drop_down_style == "op3") echo 'checked'?>>
  220. Op 3</label>
  221. </div>
  222. </div>
  223. </form>
  224. </div>
  225. </section>
  226. </div>
  227. <div class="col-lg-4">
  228. <section class="panel panel-primary">
  229. <header class="panel-heading"> Included Images & Icons :</header>
  230. <div class="panel-body">
  231. <form class="form-horizontal tasi-form" role="form" id="form_image">
  232. <div class="form-group">
  233. <label class="col-lg-2 ">Icon:</label>
  234. <div class="col-lg-8">
  235. <input type="text" class="form-control" id="icon" placeholder=" "
  236. value="<?php echo $record_info->icon;?>"autocomplete="off">
  237. </div>
  238. </div>
  239. <div class="form-group">
  240. <label class="col-lg-4 ">Image Cover:</label>
  241. <div class="col-lg-6"> <a href="../file_mangers/media_filemanager/view_media_directories.php" id="image_cover">Select Image</a> <br />
  242. <br />
  243. <input type="hidden" class="form-control" id="imageVal" autocomplete="off" value="../../../media-library/<?php echo $record_info->image?>">
  244. <div id="imageShow" <?php if(empty($record_info->image)) {echo "style='display:none'";} ?>>
  245. <?php
  246. $image_url = $record_info->image ;
  247. $explode = explode('/' , $image_url) ;
  248. $image_title = $explode[1] ;
  249. ?>
  250. <img src="../../../media-library/main_menu/<?php echo $image_title ; ?>" id="imageSrc" style="width:80px; height:80px;"></div>
  251. </div>
  252. </div>
  253. </form>
  254. </div>
  255. </section>
  256. </div>
  257. </div>
  258. <!-- page end-->
  259. </section>
  260. </section>
  261. <!--main content end-->
  262. <!--footer start-->
  263. <?php require_once("../layout/footer.php");?>
  264. <script src="../../js-crud/load_nodes.js"></script>