PageRenderTime 61ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/dynamic-widgets/dynwid_admin_edit.php

https://bitbucket.org/Thane2376/death-edge.ru
PHP | 514 lines | 389 code | 96 blank | 29 comment | 78 complexity | 51312b2f3041c7670accb9477cdacc96 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-3.0, AGPL-1.0
  1. <?php
  2. /**
  3. * dynwid_admin_edit.php - Options settings
  4. *
  5. * @version $Id: dynwid_admin_edit.php 939272 2014-06-26 19:44:38Z qurl $
  6. * @copyright 2011 Jacco Drabbe
  7. */
  8. // Plugins support
  9. DW_BP::detect();
  10. DW_QT::detect();
  11. DW_WPSC::detect();
  12. DW_WPML::detect();
  13. // Sanitizing some stuff
  14. $widget_id = ( isset($_GET['id']) && ! empty($_GET['id']) ) ? esc_attr($_GET['id']) : '';
  15. $return_url = ( isset($_GET['returnurl']) && ! empty($_GET['returnurl']) ) ? esc_url($_GET['returnurl']) : '';
  16. // In some cases $widget_id appears not to be global (anymore)
  17. $GLOBALS['widget_id'] = $widget_id;
  18. if (! array_key_exists($widget_id, $DW->registered_widgets) ) {
  19. wp_die('WidgetID is not valid');
  20. }
  21. ?>
  22. <style type="text/css">
  23. label {
  24. cursor : default;
  25. }
  26. .condition-select {
  27. width : 450px;
  28. -moz-border-radius-topleft : 6px;
  29. -moz-border-radius-topright : 6px;
  30. -moz-border-radius-bottomleft : 6px;
  31. -moz-border-radius-bottomright : 6px;
  32. border-style : solid;
  33. border-width : 1px;
  34. border-color : #E3E3E3;
  35. padding : 5px;
  36. padding-right: 15px; /* for RTL? */
  37. }
  38. .infotext {
  39. width : 98%;
  40. display : none;
  41. color : #666666;
  42. font-style : italic;
  43. }
  44. #dynwid h3 {
  45. text-indent : 30px;
  46. cursor: pointer;
  47. }
  48. h4 {
  49. text-indent : 30px;
  50. cursor: pointer;
  51. }
  52. .hasoptions {
  53. color : #ff0000;
  54. }
  55. #dynwid {
  56. font-family : 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif;
  57. font-size : 13px;
  58. }
  59. .dynwid_conf {
  60. display: none;
  61. padding: 15px;
  62. padding-left: 30px;
  63. }
  64. .ui-datepicker {
  65. font-size : 10px;
  66. }
  67. div.settingbox {
  68. border-color: #E3E3E3;
  69. border-radius: 6px 6px 6px 6px;
  70. border-style: solid;
  71. border-width: 1px;
  72. padding: 5px;
  73. }
  74. </style>
  75. <script type="text/javascript">
  76. /* <![CDATA[ */
  77. function chkChild(prefix, pid) {
  78. var add = true;
  79. var child = false;
  80. if ( jQuery( '#' + prefix + '_act_' + pid).is( ':checked' ) == false ) {
  81. if ( jQuery( '#' + prefix + '_childs_act_' + pid ).length > 0 ) {
  82. jQuery( '#' + prefix + '_childs_act_' + pid ).attr( 'checked', false );
  83. child = true;
  84. }
  85. add = false;
  86. }
  87. var value = jQuery( 'input[name^="' + prefix + '_act"]' ).val();
  88. console.log( 'prefix: ' + prefix + ', value: ' + value );
  89. var a = value.split(',');
  90. if ( child ) {
  91. var value_child = jQuery( 'input[name^="' + prefix + '_childs_act"]' ).val();
  92. var a_child = value_child.split(',');
  93. }
  94. if ( add ) {
  95. if ( jQuery.inArray(pid, a) == -1 ) {
  96. a.push( pid );
  97. }
  98. } else {
  99. a = jQuery.grep( a, function(v) {
  100. return v != pid;
  101. });
  102. if ( child ) {
  103. a_child = jQuery.grep( a_child, function(v) {
  104. return v != pid;
  105. });
  106. }
  107. }
  108. value = a.join();
  109. jQuery( '#' + prefix + '_act' ).val( value );
  110. if ( child ) {
  111. value_child = a_child.join();
  112. jQuery( '#' + prefix + '_childs_act' ).val( value_child );
  113. }
  114. }
  115. function chkParent(prefix, pid) {
  116. var add = false;
  117. if ( jQuery( '#' + prefix + '_childs_act_' + pid ).is( ':checked' ) == true ) {
  118. jQuery( '#' + prefix + '_act_' + pid ).attr('checked', true);
  119. add = true;
  120. }
  121. // var value = jQuery( '#' + prefix + '_act' ).val();
  122. var value = jQuery( 'input[name^="' + prefix + '_act"]' ).val();
  123. // var value_child = jQuery( '#' + prefix + '_childs_act' ).val();
  124. var value_child = jQuery( 'input[name^="' + prefix + '_childs_act"]' ).val();
  125. var a = value.split(',');
  126. var a_child = value_child.split(',');
  127. if ( add ) {
  128. if ( jQuery.inArray(pid, a) == -1 ) {
  129. a.push( pid );
  130. }
  131. if ( jQuery.inArray(pid, a_child) == -1 ) {
  132. a_child.push( pid );
  133. }
  134. } else {
  135. a_child = jQuery.grep( a_child, function(v) {
  136. return v != pid;
  137. });
  138. }
  139. value = a.join();
  140. value_child = a_child.join();
  141. jQuery( '#' + prefix + '_act' ).val( value );
  142. jQuery( '#' + prefix + '_childs_act' ).val( value_child );
  143. }
  144. /* function chkCPChild(type, pid) {
  145. if ( jQuery('#'+type+'_act_'+pid).is(':checked') == false ) {
  146. jQuery('#'+type+'_childs_act_'+pid).attr('checked', false);
  147. }
  148. }
  149. function chkCPParent(type, pid) {
  150. if ( jQuery('#'+type+'_childs_act_'+pid).is(':checked') == true ) {
  151. jQuery('#'+type+'_act_'+pid).attr('checked', true);
  152. }
  153. } */
  154. function divToggle(div) {
  155. var div = '#'+div;
  156. jQuery(div).slideToggle(400);
  157. }
  158. function swChb(c, s) {
  159. for ( i = 0; i < c.length; i++ ) {
  160. if ( s == true ) {
  161. jQuery('#'+c[i]).attr('checked', false);
  162. }
  163. jQuery('#'+c[i]).attr('disabled', s);
  164. }
  165. }
  166. function saveandreturn() {
  167. var returnurl = '<?php echo trailingslashit(admin_url()) . 'themes.php?page=dynwid-config'; ?>';
  168. jQuery('#returnurl').val(returnurl);
  169. jQuery('#dwsave').submit();
  170. }
  171. function swTxt(c, s) {
  172. for ( i = 0; i < c.length; i++ ) {
  173. if ( s == true ) {
  174. jQuery('#'+c[i]).val('');
  175. }
  176. jQuery('#'+c[i]).attr('disabled', s);
  177. }
  178. }
  179. function setOff() {
  180. jQuery(':radio').each( function() {
  181. if ( jQuery(this).val() == 'no' && jQuery.inArray(jQuery(this).attr('name'), exclOff) == -1 ) {
  182. jQuery(this).attr('checked', true);
  183. };
  184. });
  185. alert('All options set to \'No\'.\nDon\'t forget to make changes, otherwise you\'ll receive an error when saving.');
  186. }
  187. function toggleAll() {
  188. jQuery( 'h4, #dynwid h3' ).each( function() {
  189. var id = this.id;
  190. if ( closed_state ) {
  191. jQuery( '#' + id + '_conf' ).slideDown('slow');
  192. } else {
  193. jQuery( '#' + id + '_conf' ).slideUp('slow');
  194. }
  195. });
  196. if ( closed_state ) {
  197. closed_state = false;
  198. } else {
  199. closed_state = true;
  200. }
  201. }
  202. function term_tree(widget_id, name, id, prefix) {
  203. var display = jQuery( '#child_' + prefix + id ).css( 'display' );
  204. if ( display == 'none' ) {
  205. jQuery.post( ajaxurl, { action: 'term_tree', id: id, name: name, widget_id: widget_id, prefix: prefix }, function(data) {
  206. jQuery( '#tree_' + prefix + id ).html( data );
  207. jQuery( '#child_' + prefix + id ).slideDown('slow');
  208. });
  209. } else {
  210. jQuery( '#child_' + prefix + id ).slideUp('slow');
  211. }
  212. }
  213. jQuery(document).ready( function() {
  214. jQuery( 'h4, #dynwid h3' ).click( function() {
  215. var id = this.id;
  216. jQuery( '#' + id + '_conf' ).slideToggle('slow');
  217. });
  218. jQuery( 'h4, #dynwid h3' ).mouseover( function() {
  219. jQuery(this).addClass('ui-state-hover');
  220. });
  221. jQuery( 'h4, #dynwid h3' ).mouseleave( function() {
  222. jQuery(this).removeClass('ui-state-hover');
  223. });
  224. });
  225. var closed_state = true;
  226. /* ]]> */
  227. </script>
  228. <?php
  229. if ( isset($_POST['dynwid_save']) && $_POST['dynwid_save'] == 'yes' ) {
  230. $lead = __('Widget options saved.', DW_L10N_DOMAIN);
  231. $msg = '<a href="themes.php?page=dynwid-config">' . __('Return', DW_L10N_DOMAIN) . '</a> ' . __('to Dynamic Widgets overview', DW_L10N_DOMAIN);
  232. DWMessageBox::create($lead, $msg);
  233. } else if ( isset($_GET['work']) && $_GET['work'] == 'none' ) {
  234. DWMessageBox::setTypeMsg('error');
  235. $text = __('Dynamic does not mean static hiding of a widget.', DW_L10N_DOMAIN) . ' ' . __('Hint', DW_L10N_DOMAIN) . ': <a href="widgets.php">' . __('Remove', DW_L10N_DOMAIN) . '</a>' . ' ' . __('the widget from the sidebar', DW_L10N_DOMAIN) . '.';
  236. DWMessageBox::setMessage($text);
  237. DWMessageBox::output();
  238. } else if ( isset($_GET['work']) && $_GET['work'] == 'nonedate' ) {
  239. DWMessageBox::setTypeMsg('error');
  240. $text = __('The From date can\'t be later than the To date.', DW_L10N_DOMAIN);
  241. DWMessageBox::setMessage($text);
  242. DWMessageBox::output();
  243. }
  244. ?>
  245. <h3><?php _e('Edit options for the widget', DW_L10N_DOMAIN); ?>: <em><?php echo $DW->getName($widget_id); ?></em></h3>
  246. <?php echo ( DW_DEBUG ) ? '<pre>ID = ' . $widget_id . '</pre><br />' : ''; ?>
  247. <div class="settingbox">
  248. <b><?php _e('Quick settings', DW_L10N_DOMAIN); ?></b>
  249. <p>
  250. <a href="#" onclick="setOff(); return false;"><?php _e('Set all options to \'No\'', DW_L10N_DOMAIN); ?></a> (<?php _e('Except overriding options like Role, Date, etc.', DW_L10N_DOMAIN); ?>)
  251. </p>
  252. </div><br />
  253. <form id="dwsave" action="<?php echo trailingslashit(admin_url()) . 'themes.php?page=dynwid-config&action=edit&id=' . $widget_id; ?>" method="post">
  254. <?php wp_nonce_field('plugin-name-action_edit_' . $widget_id); ?>
  255. <input type="hidden" name="dynwid_save" value="yes" />
  256. <input type="hidden" name="widget_id" value="<?php echo $widget_id; ?>" />
  257. <input type="hidden" id="returnurl" name="returnurl" value="<?php echo ( (! empty($return_url)) ? trailingslashit(admin_url()) . $return_url : '' ); ?>" />
  258. <div class="settingbox">
  259. <b><?php _e('Individual Posts, Custom Post Types and Tags', DW_L10N_DOMAIN); ?></b>
  260. <p>
  261. <?php
  262. $opt_individual = $DW->getDWOpt($widget_id, 'individual');
  263. $individual = ( $opt_individual->count > 0 ) ? TRUE : FALSE;
  264. $DW->dumpOpt($opt_individual);
  265. echo '<input type="checkbox" id="individual" name="individual" value="1" ' . ( ($individual) ? 'checked="checked"' : '' ) . ' onclick="chkInPosts()" />';
  266. echo ' <label for="individual">' . __('Make exception rule available to individual posts and tags.', DW_L10N_DOMAIN) . '</label>';
  267. echo '<img src="' . $DW->plugin_url . 'img/info.gif" alt="info" title="' . __('Click to toggle info', DW_L10N_DOMAIN) . '" onclick="divToggle(\'individual_post_tag\')" />';
  268. echo '<div>';
  269. echo '<div id="individual_post_tag" class="infotext">';
  270. _e('When you enable this option, you have the ability to apply an exception rule to tags and individual posts (Posts and Custom Post Types).
  271. You can set the exception rule for tags in the single Edit Tag Panel (go to <a href="edit-tags.php?taxonomy=post_tag">Post Tags</a>,
  272. click a tag), For individual posts in the <em>New</em> or <em>Edit</em> Posts panel.
  273. Exception rules for tags and individual posts in any combination work independantly, but will always be counted as one exception.<br />
  274. Please note when this is enabled, exception rules which are set within Posts for Author and/or Category will be disabled.
  275. ', DW_L10N_DOMAIN);
  276. echo '</div></div>';
  277. ?>
  278. </p>
  279. </div><br />
  280. <input type="button" value="Toggle sections" onclick="toggleAll();" /><br />
  281. <br />
  282. <div id="dynwid">
  283. <?php
  284. $DW->getModuleName();
  285. $DW->dwoptions = apply_filters('dynwid_admin_modules', $DW->dwoptions);
  286. if ( array_key_exists('role', $DW->dwoptions) ) {
  287. $DW_Role = new DW_Role();
  288. $DW_Role->admin();
  289. }
  290. if ( array_key_exists('date', $DW->dwoptions) ) {
  291. $DW_Date = new DW_Date();
  292. $DW_Date->admin();
  293. }
  294. if ( array_key_exists('day', $DW->dwoptions) ) {
  295. $DW_Day = new DW_Day();
  296. $DW_Day->admin();
  297. }
  298. if ( array_key_exists('week', $DW->dwoptions) ) {
  299. $DW_Week = new DW_Week();
  300. $DW_Week->admin();
  301. }
  302. if ( array_key_exists('wpml', $DW->dwoptions) ) {
  303. $DW_WPML = new DW_WPML();
  304. $DW_WPML->admin();
  305. }
  306. if ( array_key_exists('qt', $DW->dwoptions) ) {
  307. $DW_QT = new DW_QT();
  308. $DW_QT->admin();
  309. }
  310. if ( array_key_exists('browser', $DW->dwoptions) ) {
  311. $DW_Browser = new DW_Browser();
  312. $DW_Browser->admin();
  313. }
  314. if ( array_key_exists('ip', $DW->dwoptions) ) {
  315. $DW_IP = new DW_IP();
  316. $DW_IP->admin();
  317. }
  318. if ( array_key_exists('device', $DW->dwoptions) ) {
  319. $DW_Device = new DW_Device();
  320. $DW_Device->admin();
  321. }
  322. if ( array_key_exists('tpl', $DW->dwoptions) ) {
  323. $DW_Tpl = new DW_Tpl();
  324. $DW_Tpl->admin();
  325. }
  326. if ( array_key_exists('url', $DW->dwoptions) ) {
  327. $DW_URL = new DW_URL();
  328. $DW_URL->admin();
  329. }
  330. if ( array_key_exists('front-page', $DW->dwoptions) ) {
  331. $DW_Front_page = new DW_Front_page();
  332. $DW_Front_page->admin();
  333. }
  334. if ( array_key_exists('single', $DW->dwoptions) ) {
  335. $DW_Single = new DW_Single();
  336. $DW_Single->admin();
  337. }
  338. if ( array_key_exists('attachment', $DW->dwoptions) ) {
  339. $DW_Attachment = new DW_Attachment();
  340. $DW_Attachment->admin();
  341. }
  342. if ( array_key_exists('page', $DW->dwoptions) ) {
  343. $DW_Page = new DW_Page();
  344. $DW_Page->admin();
  345. }
  346. if ( array_key_exists('author', $DW->dwoptions) ) {
  347. $DW_Author = new DW_Author();
  348. $DW_Author->admin();
  349. }
  350. if ( array_key_exists('category', $DW->dwoptions) ) {
  351. $DW_Category = new DW_Category();
  352. $DW_Category->admin();
  353. }
  354. if ( array_key_exists('tag', $DW->dwoptions) ) {
  355. $DW_Tag = new DW_Tag();
  356. $DW_Tag->admin();
  357. }
  358. if ( array_key_exists('archive', $DW->dwoptions) ) {
  359. $DW_Archive = new DW_Archive();
  360. $DW_Archive->admin();
  361. }
  362. if ( array_key_exists('e404', $DW->dwoptions) ) {
  363. $DW_E404 = new DW_E404();
  364. $DW_E404->admin();
  365. }
  366. if ( array_key_exists('search', $DW->dwoptions) ) {
  367. $DW_Search = new DW_Search();
  368. $DW_Search->admin();
  369. }
  370. $DW_CustomPost = new DW_CustomPost();
  371. $DW_CustomPost->admin();
  372. if ( array_key_exists('wpsc', $DW->dwoptions) ) {
  373. $DW_WPSC = new DW_WPSC();
  374. $DW_WPSC->admin();
  375. }
  376. if ( array_key_exists('bp', $DW->dwoptions) ) {
  377. $DW_BP = new DW_BP();
  378. $DW_BP->admin();
  379. }
  380. if ( array_key_exists('bbp_profile', $DW->dwoptions) ) {
  381. $DW_bbPress = new DW_bbPress();
  382. $DW_bbPress->admin();
  383. }
  384. if ( array_key_exists('pods', $DW->dwoptions) ) {
  385. $DW_Pods = new DW_Pods();
  386. $DW_Pods->admin();
  387. }
  388. // For JS exclOff
  389. $excl = array();
  390. foreach ( $DW->overrule_maintype as $m ) {
  391. $excl[ ] = "'" . $m . "'";
  392. }
  393. ?>
  394. </div><!-- end dynwid -->
  395. <br /><br />
  396. <!-- <div>
  397. Save as a quick setting <input type="text" name="qsetting" value="" />
  398. </div> //-->
  399. <br />
  400. <div style="float:left">
  401. <input class="button-primary" type="submit" value="<?php _e('Save'); ?>" /> &nbsp;&nbsp;
  402. </div>
  403. <?php $url = (! empty($return_url) ) ? trailingslashit(admin_url()) . $return_url : trailingslashit(admin_url()) . 'themes.php?page=dynwid-config'; ?>
  404. <?php if ( empty($return_url) ) { ?>
  405. <div style="float:left">
  406. <input class="button-primary" type="button" value="<?php _e('Save'); ?> & <?php _e('Return', DW_L10N_DOMAIN); ?>" onclick="saveandreturn()" /> &nbsp;&nbsp;
  407. </div>
  408. <?php } ?>
  409. <div style="float:left">
  410. <input class="button-secondary" type="button" value="<?php _e('Return', DW_L10N_DOMAIN); ?>" onclick="location.href='<?php echo $url; ?>'" />
  411. </div>
  412. </form>
  413. <script type="text/javascript">
  414. /* <![CDATA[ */
  415. var exclOff = new Array(<?php echo implode(', ', $excl); ?>);
  416. /* ]]> */
  417. </script>