diff -r c7c0fbc09788 -r 5e8dcbe22c24 web/wp-content/plugins/bbpress/includes/common/classes.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/bbpress/includes/common/classes.php Tue Dec 04 18:43:10 2012 -0800 @@ -0,0 +1,389 @@ +setup_globals( $args ); + $this->includes(); + $this->setup_actions(); + } + + /** + * Component global variables + * + * @since bbPress (r2700) + * @access private + * + * @uses apply_filters() Calls 'bbp_{@link BBP_Component::name}_id' + * @uses apply_filters() Calls 'bbp_{@link BBP_Component::name}_slug' + */ + private function setup_globals( $args = '' ) { + $this->name = $args['name']; + $this->id = apply_filters( 'bbp_' . $this->name . '_id', $args['id'] ); + $this->slug = apply_filters( 'bbp_' . $this->name . '_slug', $args['slug'] ); + } + + /** + * Include required files + * + * @since bbPress (r2700) + * @access private + * + * @uses do_action() Calls 'bbp_{@link BBP_Component::name}includes' + */ + private function includes() { + do_action( 'bbp_' . $this->name . 'includes' ); + } + + /** + * Setup the actions + * + * @since bbPress (r2700) + * @access private + * + * @uses add_action() To add various actions + * @uses do_action() Calls + * 'bbp_{@link BBP_Component::name}setup_actions' + */ + private function setup_actions() { + add_action( 'bbp_register_post_types', array( $this, 'register_post_types' ), 10, 2 ); // Register post types + add_action( 'bbp_register_taxonomies', array( $this, 'register_taxonomies' ), 10, 2 ); // Register taxonomies + add_action( 'bbp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10, 2 ); // Add the rewrite tags + add_action( 'bbp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10, 2 ); // Generate rewrite rules + + // Additional actions can be attached here + do_action( 'bbp_' . $this->name . 'setup_actions' ); + } + + /** + * Setup the component post types + * + * @since bbPress (r2700) + * + * @uses do_action() Calls 'bbp_{@link BBP_Component::name}_register_post_types' + */ + public function register_post_types() { + do_action( 'bbp_' . $this->name . '_register_post_types' ); + } + + /** + * Register component specific taxonomies + * + * @since bbPress (r2700) + * + * @uses do_action() Calls 'bbp_{@link BBP_Component::name}_register_taxonomies' + */ + public function register_taxonomies() { + do_action( 'bbp_' . $this->name . '_register_taxonomies' ); + } + + /** + * Add any additional rewrite tags + * + * @since bbPress (r2700) + * + * @uses do_action() Calls 'bbp_{@link BBP_Component::name}_add_rewrite_tags' + */ + public function add_rewrite_tags() { + do_action( 'bbp_' . $this->name . '_add_rewrite_tags' ); + } + + /** + * Generate any additional rewrite rules + * + * @since bbPress (r2700) + * + * @uses do_action() Calls 'bbp_{@link BBP_Component::name}_generate_rewrite_rules' + */ + public function generate_rewrite_rules( $wp_rewrite ) { + do_action_ref_array( 'bbp_' . $this->name . '_generate_rewrite_rules', $wp_rewrite ); + } +} +endif; // BBP_Component + +if ( class_exists( 'Walker' ) ) : +/** + * Create HTML list of forums. + * + * @package bbPress + * @subpackage Classes + * + * @since bbPress (r2514) + * + * @uses Walker + */ +class BBP_Walker_Forum extends Walker { + + /** + * @see Walker::$tree_type + * + * @since bbPress (r2514) + * + * @var string + */ + var $tree_type; + + /** + * @see Walker::$db_fields + * + * @since bbPress (r2514) + * + * @var array + */ + var $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + + /** Methods ***************************************************************/ + + /** + * Set the tree_type + * + * @since bbPress (r2514) + */ + public function __construct() { + $this->tree_type = bbp_get_forum_post_type(); + } + + /** + * @see Walker::start_lvl() + * + * @since bbPress (r2514) + * + * @param string $output Passed by reference. Used to append additional + * content. + * @param int $depth Depth of page. Used for padding. + */ + public function start_lvl( &$output, $depth ) { + $indent = str_repeat( "\t", $depth ); + $output .= "\n$indent\n"; + } + + /** + * @see Walker::start_el() + * + * @since bbPress (r2514) + * + * @param string $output Passed by reference. Used to append additional + * content. + * @param object $forum Page data object. + * @param int $depth Depth of page. Used for padding. + * @param int $current_forum Page ID. + * @param array $args + */ + public function start_el( &$output, $forum, $depth, $args, $current_forum ) { + + $indent = $depth ? str_repeat( "\t", $depth ) : ''; + + extract( $args, EXTR_SKIP ); + $css_class = array( 'bbp-forum-item', 'bbp-forum-item-' . $forum->ID ); + + if ( !empty( $current_forum ) ) { + $_current_page = bbp_get_forum( $current_forum ); + + if ( isset( $_current_page->ancestors ) && in_array( $forum->ID, (array) $_current_page->ancestors ) ) + $css_class[] = 'bbp-current-forum-ancestor'; + + if ( $forum->ID == $current_forum ) + $css_class[] = 'bbp_current_forum_item'; + elseif ( $_current_page && $forum->ID == $_current_page->post_parent ) + $css_class[] = 'bbp-current-forum-parent'; + + } elseif ( $forum->ID == get_option( 'page_for_posts' ) ) { + $css_class[] = 'bbp-current-forum-parent'; + } + + $css_class = implode( ' ', apply_filters( 'bbp_forum_css_class', $css_class, $forum ) ); + $output .= $indent . '
  • ' . $link_before . apply_filters( 'the_title', $forum->post_title, $forum->ID ) . $link_after . ''; + + if ( !empty( $show_date ) ) { + $time = ( 'modified' == $show_date ) ? $forum->post_modified : $time = $forum->post_date; + $output .= " " . mysql2date( $date_format, $time ); + } + } + + /** + * @see Walker::end_el() + * + * @since bbPress (r2514) + * + * @param string $output Passed by reference. Used to append additional + * content. + * @param object $forum Page data object. Not used. + * @param int $depth Depth of page. Not Used. + */ + public function end_el( &$output, $forum, $depth ) { + $output .= "
  • \n"; + } +} + +/** + * Create HTML dropdown list of bbPress forums/topics. + * + * @package bbPress + * @subpackage Classes + * + * @since bbPress (r2746) + * @uses Walker + */ +class BBP_Walker_Dropdown extends Walker { + + /** + * @see Walker::$tree_type + * + * @since bbPress (r2746) + * + * @var string + */ + var $tree_type; + + /** + * @see Walker::$db_fields + * + * @since bbPress (r2746) + * + * @var array + */ + var $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + + /** Methods ***************************************************************/ + + /** + * Set the tree_type + * + * @since bbPress (r2746) + */ + public function __construct() { + $this->tree_type = bbp_get_forum_post_type(); + } + + /** + * @see Walker::start_el() + * + * @since bbPress (r2746) + * + * @param string $output Passed by reference. Used to append additional + * content. + * @param object $_post Post data object. + * @param int $depth Depth of post in reference to parent posts. Used + * for padding. + * @param array $args Uses 'selected' argument for selected post to set + * selected HTML attribute for option element. + * @uses bbp_is_forum_category() To check if the forum is a category + * @uses current_user_can() To check if the current user can post in + * closed forums + * @uses bbp_is_forum_closed() To check if the forum is closed + * @uses apply_filters() Calls 'bbp_walker_dropdown_post_title' with the + * title, output, post, depth and args + */ + public function start_el( &$output, $_post, $depth, $args ) { + $pad = str_repeat( ' ', $depth * 3 ); + $output .= '\n"; + } +} + +endif; // class_exists check