diff --git a/plugins/coreblocks/block.cloud.tag_archives.php b/plugins/coreblocks/block.cloud.tag_archives.php new file mode 100644 index 000000000..7fe60af4f --- /dev/null +++ b/plugins/coreblocks/block.cloud.tag_archives.php @@ -0,0 +1,13 @@ + +tags; ?> +
+ tags; foreach( $tags as $tag ): ?> + + + + show_counts) { ?>() + + + +
\ No newline at end of file diff --git a/plugins/coreblocks/block.dropdown.tag_archives.php b/plugins/coreblocks/block.dropdown.tag_archives.php index d200d7193..1ab8537e1 100644 --- a/plugins/coreblocks/block.dropdown.tag_archives.php +++ b/plugins/coreblocks/block.dropdown.tag_archives.php @@ -7,7 +7,7 @@ tags; foreach( $tags as $tag ): ?> - diff --git a/plugins/coreblocks/block.tag_archives.php b/plugins/coreblocks/block.tag_archives.php index e569172b7..935577810 100644 --- a/plugins/coreblocks/block.tag_archives.php +++ b/plugins/coreblocks/block.tag_archives.php @@ -5,7 +5,7 @@ diff --git a/plugins/coreblocks/coreblocks.plugin.php b/plugins/coreblocks/coreblocks.plugin.php index 690813dae..d296d0ae7 100644 --- a/plugins/coreblocks/coreblocks.plugin.php +++ b/plugins/coreblocks/coreblocks.plugin.php @@ -33,6 +33,7 @@ function action_init() } $this->add_template( "block.dropdown.tag_archives", dirname( __FILE__ ) . "/block.dropdown.tag_archives.php" ); $this->add_template( "block.dropdown.monthly_archives", dirname( __FILE__ ) . "/block.dropdown.monthly_archives.php" ); + $this->add_template( "block.cloud.tag_archives", dirname( __FILE__ ) . "/block.cloud.tag_archives.php"); } /** @@ -188,7 +189,10 @@ public function action_block_content_recent_posts( $block, $theme ) */ public function action_block_form_monthly_archives( $form, $block ) { - $form->append( FormControlLabel::wrap( _t( 'Display full month names:' ), + $form->append( FormControlLabel::wrap( _t( 'Archive ordering:' ), + FormControlSelect::create( 'order', $block )->set_options( array('ASC' => _t( 'Oldest to Newest' ), 'DESC' => _t( 'Newest to Oldest' ) ) ) + )); + $form->append( FormControlLabel::wrap( _t( 'Display full month names:' ), FormControlCheckbox::create( 'full_names', $block ) )); $form->append( FormControlLabel::wrap( _t( 'Append post count:' ), @@ -213,7 +217,8 @@ public function action_block_content_monthly_archives( $block, $theme ) $results = Posts::get( array( 'content_type' => 'entry', 'status' => 'published', - 'month_cts' => 1 ) + 'month_cts' => 1, + 'orderby' => 'pubdate '.$block->order) ); foreach ( $results as $result ) { @@ -271,8 +276,16 @@ public function action_block_form_tag_archives( $form, $block ) FormControlCheckbox::create( 'show_counts', $block ) )); $form->append( FormControlLabel::wrap( _t( 'Preferred Output Style:' ), - FormControlSelect::create( 'style', $block )->set_options( array('dropdown' => _t( 'Dropdown' ), 'list' => _t( 'List' ) ) ) + FormControlSelect::create( 'style', $block )->set_options( array( 'dropdown' => _t( 'Dropdown' ), + 'list' => _t( 'List' ), + 'cloud' => _t( 'Cloud' )) ) )); + $form->append( FormControlLabel::wrap( _t( 'Cloud tag max font size (em):' ), + FormControlText::create('cloud_max',$block) + )); + $form->append( FormControlLabel::wrap( _t( 'Cloud tag min font size (em):' ), + FormControlText::create('cloud_min',$block) + )); } /** @@ -287,13 +300,18 @@ public function action_block_content_tag_archives( $block, $theme ) { $tags = array(); $results = Tags::vocabulary()->get_tree(); + $minCount = 1000000; + $maxCount = 1; + if ($block->cloud_max == '') { $block->cloud_max = 3; } + if ($block->cloud_min == '') { $block->cloud_min = 0.8; } + $sizeIncrement = 0; foreach( $results as $result ) { $count = ''; - if ( $block->show_counts ) { - $count = " (" . Posts::count_by_tag( $result->term_display, "published") . ")"; - } + if ( $block->show_counts) { + $count = Posts::count_by_tag( $result->term_display, "published"); + } $url = URL::get( 'display_entries_by_tag', array( 'tag' => $result->term ) ); $tags[] = array( @@ -301,8 +319,15 @@ public function action_block_content_tag_archives( $block, $theme ) 'count' => $count, 'url' => $url, ); + + if ($count > $maxCount) { $maxCount = $count; } + if ($count < $minCount) { $minCount = $count; } } + $sizeIncrement = round(($block->cloud_max - $block->cloud_min) / ($maxCount - $minCount),1); + $block->size_increment = $sizeIncrement; + $block->min_post_count = $minCount; + $block->tags = $tags; }