Esempio n. 1
0
 /** ====================================================================================================================================================
  * Same as the render function but avoid printing the javascript
  * 
  * @access private
  * @param array $array list to display, each item of the list is an array : array('title', null) if the node is the last one in the tree or array(title, array(...)) if there is other son nodes. 
  * @param boolean $reduce_develop to enable the reduction and the expansion of the tree with javascript
  * @return void
  */
 static function render_sub($array, $reduce_develop = false, $hide = false, $rand = "")
 {
     $hidden = "";
     if ($hide) {
         $hidden = " style='display: none;' ";
     }
     echo "<ul class='tree'" . $hidden . ">";
     foreach ($array as $item) {
         $id = "";
         $next_hide = false;
         $children = null;
         $plus_minus = "class='minus_folder'";
         if (isset($item[1])) {
             $id = " id='" . $item[1] . "' ";
         }
         if (isset($item[2])) {
             $children = $item[2];
         }
         if (isset($item[3])) {
             if (!$item[3]) {
                 $next_hide = true;
                 $plus_minus = "class='plus_folder'";
             }
         }
         $toggle = "";
         if ($reduce_develop && $children != null) {
             $toggle = " onclick='folderToggle" . $rand . "(event, jQuery(this).find(\"ul:first\"));' " . $plus_minus . " ";
         } else {
             if ($reduce_develop) {
                 $toggle = " onclick='stopPropag" . $rand . "(event);' ";
             }
         }
         // We replace the link in the text by a stopPropag to avoid closing the hierarchy when clicking on links
         if ($children != null) {
             $item[0] = str_replace("<a ", "<a onclick='stopPropag" . $rand . "(event);' ", $item[0]);
         }
         echo "<li" . $id . "" . $toggle . ">" . "<div>" . $item[0] . "</div>";
         if ($children != null) {
             SLFramework_Treelist::render_sub($children, $reduce_develop, $next_hide, $rand);
         } else {
             echo "<ul></ul>";
         }
         echo "</li>";
     }
     echo "</ul>";
 }
Esempio n. 2
0
 /** ====================================================================================================================================================
  * Call when meet the shortcode "[page_tree]" in an post/page
  * 
  * @return string the replacement string
  */
 function page_tree($attribs)
 {
     global $post;
     // We check that we are in a page and not in a post
     if (!is_page()) {
         return "";
     }
     ob_start();
     $args = array('sort_order' => 'ASC', 'sort_column' => 'menu_order,post_title', 'parent' => $this->get_root($post->ID), 'child_of' => $this->get_root($post->ID), 'offset' => 0, 'post_type' => 'page');
     // Check if the user may edit page
     if (current_user_can('edit_published_pages')) {
         $args['post_status'] = 'publish,draft,pending,future';
     } else {
         $args['post_status'] = 'publish';
     }
     $children = $this->create_hierarchy_pages(get_pages($args), $post->ID);
     $id_to_show = $post->ID;
     $a = get_post($this->get_root($post->ID));
     if ($a->ID == $id_to_show) {
         $text = $this->get_text_standard($a, $this->get_param('current_style'));
     } else {
         if ($this->is_child(get_post($a->ID), $id_to_show)) {
             $text = $this->get_text_standard($a, $this->get_param('parent_style'));
         } else {
             if ($this->is_parent(get_post($a->ID), $id_to_show)) {
                 $text = $this->get_text_standard($a, $this->get_param('child_style'));
             } else {
                 $text = $this->get_text_standard($a, $this->get_param('other_style'));
             }
         }
     }
     $to_show = array(array($text, 'page_' . $post->ID, $children, true));
     SLFramework_Treelist::render($to_show, true, null, 'page_hiera');
     $out = ob_get_clean();
     return "<div style='margin:10px;padding:10px;'>" . $out . "</div>";
 }