From 8d39a02d523b7977ae239b0e6d1071e4757779ac Mon Sep 17 00:00:00 2001 From: Drew Heath Date: Fri, 9 Aug 2013 20:35:56 +0800 Subject: [PATCH 1/3] control monthly archive order direction added option for user to control list order of monthly archives --- plugins/coreblocks/coreblocks.plugin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/coreblocks/coreblocks.plugin.php b/plugins/coreblocks/coreblocks.plugin.php index 690813dae..a33fa752d 100644 --- a/plugins/coreblocks/coreblocks.plugin.php +++ b/plugins/coreblocks/coreblocks.plugin.php @@ -188,7 +188,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 +216,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 ) { From f367497fdf38c6cc0e97636e91027db47a64d9d0 Mon Sep 17 00:00:00 2001 From: Drew Heath Date: Wed, 14 Aug 2013 17:41:03 +0800 Subject: [PATCH 2/3] new tag archives style: cloud -= adds new core tag archives style of cloud =- features: * sizing driven by post counts * user can set minimum size (em) * user can set maximum size (em) --- .../coreblocks/block.cloud.tag_archives.php | 28 +++++++++++++++++++ plugins/coreblocks/coreblocks.plugin.php | 19 +++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 plugins/coreblocks/block.cloud.tag_archives.php diff --git a/plugins/coreblocks/block.cloud.tag_archives.php b/plugins/coreblocks/block.cloud.tag_archives.php new file mode 100644 index 000000000..5d28ae0de --- /dev/null +++ b/plugins/coreblocks/block.cloud.tag_archives.php @@ -0,0 +1,28 @@ + +tags; +if ($content->cloud_max != '') { $maxSize = $content->cloud_max; } else { $maxSize = 4; } +if ($content->cloud_min != '') { $minSize = $content->cloud_min; } else { $minSize = 0.6; } +$minPosts = 1000; +$maxPosts = 1; +foreach ($tags as $tag) { + if ($tag['count'] > $maxPosts) { $maxPosts = $tag['count']; } + if ($tag['count'] < $minPosts) { $minPosts = $tag['count']; } +} +$sizeIncrement = round(($maxSize - $minSize) / ($maxPosts - $minPosts),1); +?> +
+ tags; foreach( $tags as $tag ): ?> + + + + show_counts) { ?>() + + + +
\ No newline at end of file diff --git a/plugins/coreblocks/coreblocks.plugin.php b/plugins/coreblocks/coreblocks.plugin.php index a33fa752d..ecc841311 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"); } /** @@ -275,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) + )); } /** @@ -295,9 +304,13 @@ public function action_block_content_tag_archives( $block, $theme ) foreach( $results as $result ) { $count = ''; - if ( $block->show_counts ) { + if ( $block->show_counts && $block->style != 'cloud') { $count = " (" . Posts::count_by_tag( $result->term_display, "published") . ")"; - } + } else if ($block->show_counts) { + /* we don't want text parens for the cloud because the post count is used + to derive the span em sizes */ + $count = Posts::count_by_tag( $result->term_display, "published"); + } $url = URL::get( 'display_entries_by_tag', array( 'tag' => $result->term ) ); $tags[] = array( From d66c0edeff75281766a3b854c57ca78018413b53 Mon Sep 17 00:00:00 2001 From: Drew Heath Date: Wed, 14 Aug 2013 22:34:59 +0800 Subject: [PATCH 3/3] tag archive enhancement complete 1) moved post count parentheses out of plugin and into template where it belongs 2) moved all of tag cloud code out of template and into plugin where it belongs --- .../coreblocks/block.cloud.tag_archives.php | 19 ++----------------- .../block.dropdown.tag_archives.php | 2 +- plugins/coreblocks/block.tag_archives.php | 2 +- plugins/coreblocks/coreblocks.plugin.php | 18 +++++++++++++----- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/plugins/coreblocks/block.cloud.tag_archives.php b/plugins/coreblocks/block.cloud.tag_archives.php index 5d28ae0de..7fe60af4f 100644 --- a/plugins/coreblocks/block.cloud.tag_archives.php +++ b/plugins/coreblocks/block.cloud.tag_archives.php @@ -1,23 +1,8 @@ -tags; -if ($content->cloud_max != '') { $maxSize = $content->cloud_max; } else { $maxSize = 4; } -if ($content->cloud_min != '') { $minSize = $content->cloud_min; } else { $minSize = 0.6; } -$minPosts = 1000; -$maxPosts = 1; -foreach ($tags as $tag) { - if ($tag['count'] > $maxPosts) { $maxPosts = $tag['count']; } - if ($tag['count'] < $minPosts) { $minPosts = $tag['count']; } -} -$sizeIncrement = round(($maxSize - $minSize) / ($maxPosts - $minPosts),1); -?> +tags; ?>
tags; foreach( $tags as $tag ): ?> - + 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 ecc841311..d296d0ae7 100644 --- a/plugins/coreblocks/coreblocks.plugin.php +++ b/plugins/coreblocks/coreblocks.plugin.php @@ -300,15 +300,16 @@ 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 && $block->style != 'cloud') { - $count = " (" . Posts::count_by_tag( $result->term_display, "published") . ")"; - } else if ($block->show_counts) { - /* we don't want text parens for the cloud because the post count is used - to derive the span em sizes */ + if ( $block->show_counts) { $count = Posts::count_by_tag( $result->term_display, "published"); } @@ -318,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; }