CMS Tree Page View - Version 0.7.2

Version Description

  • pages that the user is not allowed to edit now get "dimmed". they will still be visible becuase a page a user is not allowed to edit, may have a child-page that they are allowed to edit, so the sub-pages must still be accessible
  • some problems with Ozh' Admin Drop Down Menu fixed (tree showed posts instead of pages)
Download this release

Release Info

Developer eskapism
Plugin Icon wp plugin CMS Tree Page View
Version 0.7.2
Comparing to
See all releases

Code changes from version 0.7.1 to 0.7.2

Files changed (5) hide show
  1. functions.php +39 -16
  2. index.php +2 -2
  3. readme.txt +8 -4
  4. scripts/cms_tree_page_view.js +11 -0
  5. styles/styles.css +5 -0
functions.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
  // for debug, remember to comment out (yes.. i *know* i will forget this later on...)
4
- #require("FirePHPCore/FirePHP.class.php");
5
- #$firephp = FirePHP::getInstance(true);
6
 
7
  function cms_tpv_admin_head() {
8
 
@@ -35,9 +35,6 @@ function cms_tpv_admin_head() {
35
 
36
  function cms_tpv_admin_init() {
37
 
38
- // this no longer works since we can have multiple menu items
39
- #define( "CMS_TPV_PAGE_FILE", menu_page_url("cms-tpv-pages-page", false));
40
-
41
  wp_enqueue_style( "cms_tpv_styles", CMS_TPV_URL . "styles/styles.css", false, CMS_TPV_VERSION );
42
  wp_enqueue_style( "jquery-alerts", CMS_TPV_URL . "styles/jquery.alerts.css", false, CMS_TPV_VERSION );
43
  wp_enqueue_script( "jquery-cookie", CMS_TPV_URL . "scripts/jquery.biscuit.js", array("jquery")); // renamed from cookie to fix problems with mod_security
@@ -80,7 +77,7 @@ function cms_tpv_save_settings() {
80
  $options["dashboard"] = (array) $_POST["post-type-dashboard"];
81
  $options["menu"] = (array) $_POST["post-type-menu"];
82
  update_option('cms_tpv_options', $options); // enable this to show box
83
- #bonny_d($options);
84
  }
85
  /*
86
  [post-type-dashboard] => Array
@@ -229,7 +226,18 @@ function cms_tpv_get_options() {
229
  }
230
 
231
  function cms_tpv_get_selected_post_type() {
 
 
 
 
 
232
  $post_type = $_GET["post_type"];
 
 
 
 
 
 
233
  if (!$post_type) { $post_type = "post"; }
234
  return $post_type;
235
  }
@@ -242,6 +250,7 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
242
  if (!$post_type) {
243
  $post_type = cms_tpv_get_selected_post_type();
244
  }
 
245
  $post_type_object = get_post_type_object($post_type);
246
  $get_pages_args = array("post_type" => $post_type);
247
 
@@ -339,7 +348,7 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
339
  <a href="#" title='<?php _e("Edit page", "cms-tree-page-view")?>' class='cms_tpv_action_edit'><?php _e("Edit", "cms-tree-page-view")?></a> |
340
  <a href="#" title='<?php _e("View page", "cms-tree-page-view")?>' class='cms_tpv_action_view'><?php _e("View", "cms-tree-page-view")?></a>
341
  </p>
342
- <p>
343
  <span class='cms_tpv_action_add_page'><?php echo $post_type_object->labels->add_new_item ?></span>
344
  <a href="#" title='<?php _e("Add new page after", "cms-tree-page-view")?>' class='cms_tpv_action_add_page_after'><?php _e("after", "cms-tree-page-view")?></a>
345
  <?php
@@ -374,6 +383,7 @@ function cms_tpv_print_common_tree_stuff($post_type = "") {
374
  * A page with the tree. Good stuff.
375
  */
376
  function cms_tpv_pages_page() {
 
377
  $post_type = cms_tpv_get_selected_post_type();
378
  $post_type_object = get_post_type_object($post_type);
379
 
@@ -383,7 +393,7 @@ function cms_tpv_pages_page() {
383
 
384
  <?php
385
  cms_tpv_show_annoying_box();
386
- cms_tpv_print_common_tree_stuff();
387
  ?>
388
  </div>
389
  <?php
@@ -423,7 +433,7 @@ function cms_tpv_get_pages($args = null) {
423
  $get_posts_args["post_status"] = "publish";
424
  }
425
 
426
- // does not work with plugin role scoper. don't know why, but this shold fix it
427
  remove_action("get_pages", array('ScoperHardway', 'flt_get_pages'), 1, 2);
428
 
429
  #do_action_ref_array('parse_query', array(&$this));
@@ -462,7 +472,7 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
462
  unset($posts_columns["cb"], $posts_columns["title"], $posts_columns["author"], $posts_columns["categories"], $posts_columns["tags"], $posts_columns["date"]);
463
 
464
  global $post;
465
- #$tmpPost = $post;
466
  #cms_tpv_firedebug(timer_stop());
467
 
468
  ?>[<?php
@@ -470,6 +480,8 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
470
 
471
  #cms_tpv_firedebug(timer_stop());
472
  $onePage = $arrPages[$i];
 
 
473
  $page_id = $onePage->ID;
474
 
475
  $editLink = get_edit_post_link($onePage->ID, 'notDisplay');
@@ -498,7 +510,6 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
498
  $post_modified_time = date_i18n(get_option('date_format'), $post_modified_time, false);
499
 
500
  // last edited by
501
- $post = $onePage;
502
  setup_postdata($post);
503
  $post_author = get_the_modified_author();
504
  if (empty($post_author)) {
@@ -513,6 +524,15 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
513
  #$title = html_entity_decode($title, ENT_COMPAT, "UTF-8");
514
  #$title = html_entity_decode($title, ENT_COMPAT);
515
 
 
 
 
 
 
 
 
 
 
516
  // fetch columns
517
  $str_columns = "";
518
  foreach ( $posts_columns as $column_name => $column_display_name ) {
@@ -552,9 +572,7 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
552
  if ($str_columns) {
553
  $str_columns = "<dl>$str_columns</dl>";
554
  }
555
- // @todo: lägg till col comments, data
556
 
557
- #$post = $tmpPost; // @todo: should do this at the end instead?
558
  ?>
559
  {
560
  "data": {
@@ -568,7 +586,8 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
568
  "attr": {
569
  "xhref": "<?php echo $editLink ?>",
570
  "id": "cms-tpv-<?php echo $onePage->ID ?>",
571
- "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>"
 
572
  },
573
  <?php echo $strState ?>
574
  "metadata": {
@@ -582,7 +601,8 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
582
  "editlink": "<?php echo htmlspecialchars_decode($editLink) ?>",
583
  "modified_time": "<?php echo $post_modified_time ?>",
584
  "modified_author": "<?php echo $post_author ?>",
585
- "columns": "<?php echo rawurlencode($str_columns) ?>"
 
586
  }
587
  <?php
588
  // if id is in $arrOpenChilds then also output children on this one
@@ -599,6 +619,10 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
599
  if ($i < $pagesCount-1) {
600
  ?>,<?php
601
  }
 
 
 
 
602
  }
603
  ?>]<?php
604
  }
@@ -607,7 +631,6 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $po
607
  // Act on AJAX-call
608
  function cms_tpv_get_childs() {
609
 
610
- // @todo: activate again!
611
  header("Content-type: application/json");
612
 
613
  $action = $_GET["action"];
1
  <?php
2
 
3
  // for debug, remember to comment out (yes.. i *know* i will forget this later on...)
4
+ // require("FirePHPCore/FirePHP.class.php");
5
+ // $firephp = FirePHP::getInstance(true);
6
 
7
  function cms_tpv_admin_head() {
8
 
35
 
36
  function cms_tpv_admin_init() {
37
 
 
 
 
38
  wp_enqueue_style( "cms_tpv_styles", CMS_TPV_URL . "styles/styles.css", false, CMS_TPV_VERSION );
39
  wp_enqueue_style( "jquery-alerts", CMS_TPV_URL . "styles/jquery.alerts.css", false, CMS_TPV_VERSION );
40
  wp_enqueue_script( "jquery-cookie", CMS_TPV_URL . "scripts/jquery.biscuit.js", array("jquery")); // renamed from cookie to fix problems with mod_security
77
  $options["dashboard"] = (array) $_POST["post-type-dashboard"];
78
  $options["menu"] = (array) $_POST["post-type-menu"];
79
  update_option('cms_tpv_options', $options); // enable this to show box
80
+ // bonny_d($options);
81
  }
82
  /*
83
  [post-type-dashboard] => Array
226
  }
227
 
228
  function cms_tpv_get_selected_post_type() {
229
+ // fix for Ozh' Admin Drop Down Menu that does something with the urls
230
+ // movies funkar:
231
+ // http://localhost/wp-admin/edit.php?post_type=movies&page=cms-tpv-page-xmovies
232
+ // movies funkar inte:
233
+ // http://localhost/wp-admin/admin.php?page=cms-tpv-page-movies
234
  $post_type = $_GET["post_type"];
235
+ if (!$post_type) {
236
+ // no post type, happens with ozh admin drop down, so get it via page instead
237
+ $page = $_GET["page"];
238
+ $post_type = str_replace("cms-tpv-page-", "", $page);
239
+ }
240
+
241
  if (!$post_type) { $post_type = "post"; }
242
  return $post_type;
243
  }
250
  if (!$post_type) {
251
  $post_type = cms_tpv_get_selected_post_type();
252
  }
253
+ #echo "post_type: $post_type";
254
  $post_type_object = get_post_type_object($post_type);
255
  $get_pages_args = array("post_type" => $post_type);
256
 
348
  <a href="#" title='<?php _e("Edit page", "cms-tree-page-view")?>' class='cms_tpv_action_edit'><?php _e("Edit", "cms-tree-page-view")?></a> |
349
  <a href="#" title='<?php _e("View page", "cms-tree-page-view")?>' class='cms_tpv_action_view'><?php _e("View", "cms-tree-page-view")?></a>
350
  </p>
351
+ <p class="cms_tpv_action_add_and_edit_page">
352
  <span class='cms_tpv_action_add_page'><?php echo $post_type_object->labels->add_new_item ?></span>
353
  <a href="#" title='<?php _e("Add new page after", "cms-tree-page-view")?>' class='cms_tpv_action_add_page_after'><?php _e("after", "cms-tree-page-view")?></a>
354
  <?php
383
  * A page with the tree. Good stuff.
384
  */
385
  function cms_tpv_pages_page() {
386
+
387
  $post_type = cms_tpv_get_selected_post_type();
388
  $post_type_object = get_post_type_object($post_type);
389
 
393
 
394
  <?php
395
  cms_tpv_show_annoying_box();
396
+ cms_tpv_print_common_tree_stuff($post_type);
397
  ?>
398
  </div>
399
  <?php
433
  $get_posts_args["post_status"] = "publish";
434
  }
435
 
436
+ // does not work with plugin role scoper. don't know why, but this should fix it
437
  remove_action("get_pages", array('ScoperHardway', 'flt_get_pages'), 1, 2);
438
 
439
  #do_action_ref_array('parse_query', array(&$this));
472
  unset($posts_columns["cb"], $posts_columns["title"], $posts_columns["author"], $posts_columns["categories"], $posts_columns["tags"], $posts_columns["date"]);
473
 
474
  global $post;
475
+
476
  #cms_tpv_firedebug(timer_stop());
477
 
478
  ?>[<?php
480
 
481
  #cms_tpv_firedebug(timer_stop());
482
  $onePage = $arrPages[$i];
483
+ $tmpPost = $post;
484
+ $post = $onePage;
485
  $page_id = $onePage->ID;
486
 
487
  $editLink = get_edit_post_link($onePage->ID, 'notDisplay');
510
  $post_modified_time = date_i18n(get_option('date_format'), $post_modified_time, false);
511
 
512
  // last edited by
 
513
  setup_postdata($post);
514
  $post_author = get_the_modified_author();
515
  if (empty($post_author)) {
524
  #$title = html_entity_decode($title, ENT_COMPAT, "UTF-8");
525
  #$title = html_entity_decode($title, ENT_COMPAT);
526
 
527
+ // can edit?
528
+ if ( current_user_can( 'edit_page', $page_id ) ) {
529
+ $user_can_edit_page = true;
530
+ $user_can_edit_page_css = "cms_tpv_user_can_edit_page_yes";
531
+ } else {
532
+ $user_can_edit_page = false;
533
+ $user_can_edit_page_css = "cms_tpv_user_can_edit_page_no";
534
+ }
535
+
536
  // fetch columns
537
  $str_columns = "";
538
  foreach ( $posts_columns as $column_name => $column_display_name ) {
572
  if ($str_columns) {
573
  $str_columns = "<dl>$str_columns</dl>";
574
  }
 
575
 
 
576
  ?>
577
  {
578
  "data": {
586
  "attr": {
587
  "xhref": "<?php echo $editLink ?>",
588
  "id": "cms-tpv-<?php echo $onePage->ID ?>",
589
+ "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>",
590
+ "class": "<?php echo $user_can_edit_page_css ?>"
591
  },
592
  <?php echo $strState ?>
593
  "metadata": {
601
  "editlink": "<?php echo htmlspecialchars_decode($editLink) ?>",
602
  "modified_time": "<?php echo $post_modified_time ?>",
603
  "modified_author": "<?php echo $post_author ?>",
604
+ "columns": "<?php echo rawurlencode($str_columns) ?>",
605
+ "user_can_edit_page": "<?php echo (int) $user_can_edit_page ?>"
606
  }
607
  <?php
608
  // if id is in $arrOpenChilds then also output children on this one
619
  if ($i < $pagesCount-1) {
620
  ?>,<?php
621
  }
622
+
623
+ // return orgiginal post
624
+ $post = $tmpPost;
625
+
626
  }
627
  ?>]<?php
628
  }
631
  // Act on AJAX-call
632
  function cms_tpv_get_childs() {
633
 
 
634
  header("Content-type: application/json");
635
 
636
  $action = $_GET["action"];
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: CMS Tree Page View
4
  Plugin URI: http://eskapism.se/code-playground/cms-tree-page-view/
5
  Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. By using the tree you can edit, view, add pages and even search pages (useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this!
6
- Version: 0.7.1
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
@@ -27,7 +27,7 @@ License: GPL2
27
 
28
  require("functions.php");
29
 
30
- define( "CMS_TPV_VERSION", "0.7.1");
31
  define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
32
  define( "CMS_TPV_NAME", "CMS Tree Page View");
33
 
3
  Plugin Name: CMS Tree Page View
4
  Plugin URI: http://eskapism.se/code-playground/cms-tree-page-view/
5
  Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. By using the tree you can edit, view, add pages and even search pages (useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this!
6
+ Version: 0.7.2
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
27
 
28
  require("functions.php");
29
 
30
+ define( "CMS_TPV_VERSION", "0.7.2");
31
  define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
32
  define( "CMS_TPV_NAME", "CMS Tree Page View");
33
 
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === Plugin Name ===
2
  Contributors: eskapism
3
  Donate link: http://eskapism.se/sida/donate/
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
@@ -20,14 +20,14 @@ Page management won't get any easier than this!
20
 
21
  #### Features and highlights:
22
 
23
- * drag and drop to rearrange your pages
24
  * add pages after or inside a page
25
  * edit pages
26
  * view pages
27
  * search pages
28
  * available for both regular pages and custom posts
29
- * easy view your site hierarchy directly from the WordPress dashboard
30
- * supports WPML, so you can manage all the languages of your site
31
 
32
  #### Screencast
33
 
@@ -72,6 +72,10 @@ Now the tree with the pages will be visible both on the dashboard and in the men
72
 
73
  == Changelog ==
74
 
 
 
 
 
75
  = 0.7.1 =
76
  - quick fix: capability edit_pages required to view the tree menu, instead of editor (which led to administrators not being able to view the tree...)
77
 
1
+ === CMS Tree Page View ===
2
  Contributors: eskapism
3
  Donate link: http://eskapism.se/sida/donate/
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
20
 
21
  #### Features and highlights:
22
 
23
+ * drag and drop to rearrange/order your pages
24
  * add pages after or inside a page
25
  * edit pages
26
  * view pages
27
  * search pages
28
  * available for both regular pages and custom posts
29
+ * view your site hierarchy directly from the WordPress dashboard
30
+ * support for translation plugin [WPML](http://wordpress.org/extend/plugins/sitepress-multilingual-cms/), so you can manage all the languages of your site
31
 
32
  #### Screencast
33
 
72
 
73
  == Changelog ==
74
 
75
+ = 0.7.2 =
76
+ - pages that the user is not allowed to edit now get "dimmed". they will still be visible becuase a page a user is not allowed to edit, may have a child-page that they are allowed to edit, so the sub-pages must still be accessible
77
+ - some problems with Ozh' Admin Drop Down Menu fixed (tree showed posts instead of pages)
78
+
79
  = 0.7.1 =
80
  - quick fix: capability edit_pages required to view the tree menu, instead of editor (which led to administrators not being able to view the tree...)
81
 
scripts/cms_tree_page_view.js CHANGED
@@ -179,6 +179,17 @@ jQuery(".jstree li").live("mouseover", function(e) {
179
  var editlink = $li.data("jstree").editlink;
180
  $edit.attr("href", editlink);
181
 
 
 
 
 
 
 
 
 
 
 
 
182
  // ..and some extras
183
  div_actions_for_post_type.find(".cms_tpv_page_actions_modified_time").text($li.data("jstree").modified_time);
184
  div_actions_for_post_type.find(".cms_tpv_page_actions_modified_by").text($li.data("jstree").modified_author);
179
  var editlink = $li.data("jstree").editlink;
180
  $edit.attr("href", editlink);
181
 
182
+ // check if user is allowed to edit page
183
+ var $cms_tpv_action_add_and_edit_page = div_actions_for_post_type.find(".cms_tpv_action_add_and_edit_page");
184
+ if ($li.data("jstree").user_can_edit_page == 0) {
185
+ // nooope
186
+ $edit.hide();
187
+ $cms_tpv_action_add_and_edit_page.hide();
188
+ } else {
189
+ $edit.show();
190
+ $cms_tpv_action_add_and_edit_page.show();
191
+ }
192
+
193
  // ..and some extras
194
  div_actions_for_post_type.find(".cms_tpv_page_actions_modified_time").text($li.data("jstree").modified_time);
195
  div_actions_for_post_type.find(".cms_tpv_page_actions_modified_by").text($li.data("jstree").modified_author);
styles/styles.css CHANGED
@@ -294,3 +294,8 @@ p.cms_tpv_annoying_little_box_close {
294
  }
295
  .cms_tpv_wrapper .cms_tpv_page_actions_columns a.post-com-count {
296
  }
 
 
 
 
 
294
  }
295
  .cms_tpv_wrapper .cms_tpv_page_actions_columns a.post-com-count {
296
  }
297
+
298
+ li.cms_tpv_user_can_edit_page_no a {
299
+ opacity: .6; /* Standard: FF gt 1.5, Opera, Safari */
300
+ -ms-filter: "alpha(opacity=60)"; /* IE 8 */
301
+ }