| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080 |
- Index: af-extended-live-archive-include.php
- --- af-extended-live-archive-include.php.orig 2006-06-17 19:04:56 +0200
- +++ af-extended-live-archive-include.php 2007-10-01 19:16:47 +0200
- @@ -43,7 +43,6 @@
- class af_ela_classGenerator {
-
- var $cache;
- - var $utwCore;
- var $yearTable = array();
- var $monthTable = array();
- var $catsTable = array();
- @@ -56,9 +55,7 @@
- * Helper Function : class constructor
- * ***********************************/
- function af_ela_classGenerator() {
- - global $utw_is_present;
- $this->cache = new af_ela_classCacheFile('');
- - if($utw_is_present) $this->utwCore = new UltimateTagWarriorCore;
- return true;
- }
- /* ***********************************
- @@ -66,13 +63,13 @@
- * updated post.
- * ***********************************/
- function buildPostToGenerateTable($exclude, $id, $commentId = false) {
- - global $wpdb, $tabletags, $tablepost2tag, $utw_is_present;
- + global $wpdb;
-
- if (!empty($exclude)) {
- $excats = preg_split('/[\s,]+/',$exclude);
- if (count($excats)) {
- foreach ($excats as $excat) {
- - $exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
- + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- }
- @@ -82,40 +79,39 @@
- $dojustid = ' AND ID = ' . intval($id) . ' ' ;
- }
-
- - $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, category_id
- - FROM $wpdb->posts
- - INNER JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)
- + $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, tr.term_taxonomy_id AS `term_taxonomy_id`
- + FROM $wpdb->posts p
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
- + INNER JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
- WHERE post_date > 0
- + AND taxonomy = 'category'
- $exclusions $dojustid
- ORDER By post_date DESC";
- logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- $results = $wpdb->get_results($query);
- if ($results) {
- foreach($results as $result) {
- - $this->postToGenerate['category_id'][] = $result->category_id;
- + $this->postToGenerate['term_taxonomy_id'][] = $result->term_taxonomy_id;
- }
- }
- $this->postToGenerate['new_year']= $results[0]->year;
- $this->postToGenerate['new_month']= $results[0]->month;
-
- - // For UTW
- - if($utw_is_present) {
- - $query = "SELECT tag_id
- - FROM $wpdb->posts
- - INNER JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)
- - INNER JOIN $tablepost2tag ON ($wpdb->posts.ID = $tablepost2tag.post_id)
- - WHERE post_date > 0
- - $exclusions $dojustid
- - ORDER By post_date DESC";
- - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- - $results = $wpdb->get_results($query);
- - if ($results) {
- - foreach($results as $result) {
- - $this->postToGenerate['tag_id'][] = $result->tag_id;
- - }
- + $query = "SELECT tr.term_taxonomy_id
- + FROM $wpdb->posts p
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
- + INNER JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
- + WHERE post_date > 0
- + AND tt.taxonomy = 'post_tag'
- + $exclusions $dojustid
- + ORDER By post_date DESC";
- + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- + $results = $wpdb->get_results($query);
- + if ($results) {
- + foreach($results as $result) {
- + $this->postToGenerate['term_taxonomy_id'][] = $result->term_taxonomy_id;
- }
- }
- - // End of stuff for UTW
-
- return true;
- } else {
- @@ -130,9 +126,9 @@
- $dojustid = ' AND ID = ' . intval($id) . ' ' ;
- }
-
- - $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, category_id
- - FROM $wpdb->posts
- - INNER JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)
- + $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, tr.term_taxonomy_id AS `term_taxonomy_id`
- + FROM $wpdb->posts p
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
- WHERE post_date > 0
- $exclusions $dojustid
- ORDER By post_date DESC";
- @@ -140,14 +136,14 @@
- $results = $wpdb->get_results($query);
- if($results) {
- foreach($results as $result) {
- - $this->postToGenerate['category_id'][]=$result->category_id;
- + $this->postToGenerate['term_taxonomy_id'][]=$result->term_taxonomy_id;
- }
- $this->postToGenerate['post_id'] = $id;
- $this->postToGenerate['new_year']= $results[0]->year;
- $this->postToGenerate['new_month'] = $results[0]->month;
- $this->yearTable = array($this->postToGenerate['new_year'] => 0);
- $this->monthTable[$this->postToGenerate['new_year']] = array($this->postToGenerate['new_month'] => 0);
- - $this->catsTable = $this->postToGenerate['category_id'];
- + $this->catsTable = $this->postToGenerate['term_taxonomy_id'];
- return true;
- }
- }
- @@ -164,7 +160,7 @@
- $excats = preg_split('/[\s,]+/',$exclude);
- if (count($excats)) {
- foreach ($excats as $excat) {
- - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
- + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- }
- @@ -172,7 +168,7 @@
-
- $query = "SELECT DISTINCT YEAR(p.post_date) AS `year`
- FROM $wpdb->posts p
- - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id)
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
- WHERE p.post_date > 0
- $exclusions
- ORDER By p.post_date DESC";
- @@ -182,9 +178,10 @@
- foreach( $year_results as $year_result ) {
- $query = "SELECT p.ID
- FROM $wpdb->posts p
- - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id)
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
- WHERE YEAR(p.post_date) = $year_result->year
- $exclusions
- + AND p.post_type = 'post'
- AND p.post_status = 'publish'
- AND p.post_date_gmt < '$now'
- GROUP BY p.ID";
- @@ -219,7 +216,7 @@
- $excats = preg_split('/[\s,]+/',$exclude);
- if (count($excats)) {
- foreach ($excats as $excat) {
- - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
- + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- }
- @@ -228,7 +225,7 @@
- foreach( $this->yearTable as $year => $y ) {
- $query = "SELECT DISTINCT MONTH(p.post_date) AS `month`
- FROM $wpdb->posts p
- - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id )
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id )
- WHERE YEAR(p.post_date) = $year
- $exclusions
- AND p.post_date_gmt < '$now'
- @@ -239,10 +236,11 @@
- foreach( $month_results as $month_result ) {
- $query = "SELECT p.ID
- FROM $wpdb->posts p
- - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id)
- + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
- WHERE YEAR(p.post_date) = $year
- $exclusions
- AND MONTH(p.post_date) = $month_result->month
- + AND p.post_type = 'post'
- AND p.post_status = 'publish'
- AND p.post_date_gmt < '$now'
- GROUP BY p.ID";
- @@ -282,7 +280,7 @@
- $excats = preg_split('/[\s,]+/',$exclude);
- if (count($excats)) {
- foreach ($excats as $excat) {
- - $exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
- + $exclusions .= ' AND term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- }
- @@ -297,6 +295,7 @@
- FROM $wpdb->posts
- WHERE YEAR(post_date) = $year
- AND MONTH(post_date) = $month
- + AND post_type = 'post'
- AND post_status = 'publish'
- AND post_date_gmt < '$now'
- ORDER By post_date DESC";
- @@ -304,9 +303,9 @@
- $post_results = $wpdb->get_results($query);
- if( $post_results ) {
- foreach( $post_results as $post_result ) {
- - $query = "SELECT category_id
- - FROM $wpdb->post2cat
- - WHERE post_id = $post_result->ID
- + $query = "SELECT term_taxonomy_id
- + FROM $wpdb->term_relationships
- + WHERE object_id = $post_result->ID
- $exclusions";
- logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- $posts_in_cat_results = $wpdb->get_results($query);
- @@ -364,7 +363,7 @@
- if (!empty($diffcats)) {
- $this->catsTable = $diffcats;
- } else {
- - $this->catsTable = $this->postToGenerate['category_id'];
- + $this->catsTable = $this->postToGenerate['term_taxonomy_id'];
- }
- }
- }
- @@ -378,17 +377,20 @@
- $excats = preg_split('/[\s,]+/',$exclude);
- if (count($excats)) {
- foreach ($excats as $excat) {
- - $exclusions .= ' AND c.cat_ID <> ' . intval($excat) . ' ';
- + $exclusions .= ' AND tt.term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- }
-
- if (intval($categories)==0){
- - $sort_column = 'c.cat_'.$sort_column;
- + $sort_column = 'tt.term_taxonomy_'.$sort_column;
-
- - $query = "SELECT cat_ID, cat_name, category_nicename, category_parent
- - FROM $wpdb->categories c
- - WHERE c.cat_ID > 0 $exclusions $dojustid
- + $query = "SELECT tt.term_taxonomy_id, t.name, t.slug, tt.parent
- + FROM $wpdb->terms t
- + INNER JOIN $wpdb->term_taxonomy tt ON (t.term_id = tt.term_id)
- + WHERE t.term_id > 0
- + AND tt.taxonomy = 'category'
- + $exclusions $dojustid
- ORDER BY $sort_column $sort_order";
- logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- $categories = $wpdb->get_results($query);
- @@ -396,39 +398,41 @@
-
- if (!count($category_posts)) {
- $now = current_time('mysql', 1);
- - $query = "SELECT c.cat_ID,
- - COUNT(distinct p2c.post_id) AS cat_count
- - FROM $wpdb->categories c
- - INNER JOIN $wpdb->post2cat p2c ON (c.cat_ID = p2c.category_id)
- - INNER JOIN $wpdb->posts p ON (p.ID = p2c.post_id)
- + $query = "SELECT tr.term_taxonomy_id,
- + COUNT(tr.object_id) AS cat_count
- + FROM $wpdb->term_taxonomy tt
- + INNER JOIN $wpdb->term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id)
- + INNER JOIN $wpdb->posts p ON (p.ID = tr.object_id)
- WHERE p.post_status = 'publish'
- + AND p.post_type = 'post'
- AND p.post_date_gmt < '$now'
- + AND tt.taxonomy = 'category'
- $exclusions
- - GROUP BY p2c.category_id";
- + GROUP BY tr.term_taxonomy_id";
- logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- $cat_counts = $wpdb->get_results($query);
-
- if (! empty($cat_counts)) {
- foreach ($cat_counts as $cat_count) {
- if (1 != intval($hide_empty) || $cat_count > 0) {
- - $category_posts[$cat_count->cat_ID] = $cat_count->cat_count;
- + $category_posts[$cat_count->term_taxonomy_id] = $cat_count->cat_count;
- }
- }
- }
- }
- foreach ($categories as $category) {
- - if ((intval($hide_empty) == 0 || isset($category_posts[$category->cat_ID])) && (!$hierarchical || $category->category_parent == $child_of) ) {
- - $this->catsTable[$category->cat_ID] = array( $category->cat_ID,
- - $category->cat_name,
- - $category->category_nicename,
- - $category_posts["$category->cat_ID"],
- - $category->category_parent);
- + if ((intval($hide_empty) == 0 || isset($category_posts[$category->term_taxonomy_id])) && (!$hierarchical || $category->parent == $child_of) ) {
- + $this->catsTable[$category->term_taxonomy_id] = array( $category->term_taxonomy_id,
- + $category->name,
- + $category->slug,
- + $category_posts["$category->term_taxonomy_id"],
- + $category->parent);
- if ($hierarchical && $children) {
- $this->buildCatsList( $sort_column,
- $sort_order,
- $hide_empty,
- $children,
- - $category->cat_ID,
- + $category->term_taxonomy_id,
- $categories,
- $exclude,
- $hierarchical);
- @@ -452,7 +456,7 @@
- $excats = preg_split('/[\s,]+/',$exclude);
- if (count($excats)) {
- foreach ($excats as $excat) {
- - $exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
- + $exclusions .= ' AND term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- }
- @@ -460,23 +464,26 @@
- logthis($this->catsTable);
- foreach( $this->catsTable as $category ) {
- $posts_in_cat[$category[0]] = array();
- - $query = "SELECT post_id
- - FROM $wpdb->post2cat
- - WHERE category_id = $category[0]
- - $exclusions";
- + $query = "SELECT object_id AS post_id
- + FROM $wpdb->term_relationships tr
- + INNER JOIN $wpdb->posts p
- + ON tr.object_id = p.ID
- + WHERE tr.term_taxonomy_id = $category[0]
- + AND p.post_type = 'post'
- + AND p.post_status = 'publish'
- + AND p.post_date_gmt <= '$now'
- + $exclusions
- + ORDER BY p.post_date DESC";
- logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- $posts_in_cat_results = $wpdb->get_results($query);
-
- if( $posts_in_cat_results ) {
- - $posts_in_cat_results = array_reverse($posts_in_cat_results);
- + //$posts_in_cat_results = array_reverse($posts_in_cat_results);
- foreach( $posts_in_cat_results as $post_in_cat_result ) {
-
- $query = "SELECT ID, post_title, post_date as `day`, comment_status
- FROM $wpdb->posts
- - WHERE ID = $post_in_cat_result->post_id
- - AND post_status = 'publish'
- - AND post_date_gmt <= '$now'
- - ORDER By post_date";
- + WHERE ID = $post_in_cat_result->post_id ";
- logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- $post_results = $wpdb->get_results($query);
- if( $post_results ) {
- @@ -503,73 +510,72 @@
- * Helper Function : build Tags.
- * ***********************************/
- function buildTagsTable($exclude='', $id = false, $order = false, $orderparam = 0) {
- - global $utw_is_present;
- - if($utw_is_present) {
- - global $wpdb, $tabletags, $tablepost2tag;
- -
- - if (!empty($exclude)) {
- - $excats = preg_split('/[\s,]+/',$exclude);
- - if (count($excats)) {
- - foreach ($excats as $excat) {
- - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
- - }
- + global $wpdb;
- +
- + if (!empty($exclude)) {
- + $excats = preg_split('/[\s,]+/',$exclude);
- + if (count($excats)) {
- + foreach ($excats as $excat) {
- + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- -
- - switch($order) {
- - case 2: // X is the min number of post per tag
- - $ordering = "HAVING tag_count >= ". $orderparam . " ORDER BY tag_count DESC";
- - break;
- - case 1: // X is the number of tag to show
- - $ordering = "ORDER BY tag_count DESC LIMIT ". $orderparam;
- - break;
- - case 0:
- - default:
- - $ordering = "";
- - break;
- - }
- -
- - $now = current_time('mysql', 1);
- + }
- +
- + switch($order) {
- + case 2: // X is the min number of post per tag
- + $ordering = "HAVING tag_count >= ". $orderparam . " ORDER BY tag_count DESC";
- + break;
- + case 1: // X is the number of tag to show
- + $ordering = "ORDER BY tag_count DESC LIMIT ". $orderparam;
- + break;
- + case 0:
- + default:
- + $ordering = "";
- + break;
- + }
- +
- + $now = current_time('mysql', 1);
-
- - $query = "SELECT t.tag_id, t.tag, count(distinct p2t.post_id) as tag_count
- - FROM $tabletags t
- - INNER JOIN $tablepost2tag p2t ON t.tag_id = p2t.tag_id
- - INNER JOIN $wpdb->posts p ON p2t.post_id = p.ID
- - INNER JOIN $wpdb->post2cat p2c ON p2t.post_id = p2c.post_ID
- - WHERE p.post_date_gmt < '$now'
- - AND p.post_status = 'publish'
- - $exclusions
- - GROUP BY t.tag
- - $ordering";
- - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- - $tagsSet = $wpdb->get_results($query);
- - $tagged_posts = 0;
- - $posted_tags = 0;
- - if( !empty($tagsSet) ) {
- - foreach($tagsSet as $tag) {
- - if ($tag->tag_count) {
- - $this->tagsTable[$tag->tag_id] = array($tag->tag_id, $tag->tag, $tag->tag_count );
- - $tagged_posts++;
- - if (intval($posted_tags) < intval($tag->tag_count)) $posted_tags = $tag->tag_count;
- - }
- - }
- - if ($order!= false ) {
- - $this->tagsTable = $this->arraySort($this->tagsTable, 1);
- + $query = "SELECT tt.term_taxonomy_id, t.name, count(distinct tr.object_id) as tag_count
- + FROM $wpdb->terms t
- + INNER JOIN $wpdb->term_taxonomy tt ON t.term_id = tt.term_id
- + INNER JOIN $wpdb->term_relationships tr ON tt.term_taxonomy_id = tr.term_taxonomy_id
- + INNER JOIN $wpdb->posts p ON tr.object_id = p.ID
- + WHERE p.post_date_gmt < '$now'
- + AND tt.taxonomy = 'post_tag'
- + AND p.post_type = 'post'
- + AND p.post_status = 'publish'
- + $exclusions
- + GROUP BY t.name
- + $ordering";
- + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- + $tagsSet = $wpdb->get_results($query);
- + $tagged_posts = 0;
- + $posted_tags = 0;
- + if( !empty($tagsSet) ) {
- + foreach($tagsSet as $tag) {
- + if ($tag->tag_count) {
- + $this->tagsTable[$tag->term_taxonomy_id] = array($tag->term_taxonomy_id, $tag->name, $tag->tag_count );
- + $tagged_posts++;
- + if (intval($posted_tags) < intval($tag->tag_count)) $posted_tags = $tag->tag_count;
- }
- -
- - $this->tagsTable[0] = array($tagged_posts, $posted_tags);
- -
- - $this->cache->contentIs($this->tagsTable);
- - $this->cache->writeFile('tags.dat');
- -
- - if($id) {
- - $this->cache->readFile('tags.dat');
- - $difftags = array_diff_assoc($this->cache->readFileContent, $this->tagsTable);
- - if (!empty($difftags)) {
- - $this->tagsTable = $difftags;
- - } else {
- - $this->tagsTable = $this->postToGenerate['tag_id'];
- - }
- + }
- + if ($order!= false ) {
- + $this->tagsTable = $this->arraySort($this->tagsTable, 1);
- + }
- +
- + $this->tagsTable[0] = array($tagged_posts, $posted_tags);
- +
- + $this->cache->contentIs($this->tagsTable);
- + $this->cache->writeFile('tags.dat');
- +
- + if($id) {
- + $this->cache->readFile('tags.dat');
- + $difftags = array_diff_assoc($this->cache->readFileContent, $this->tagsTable);
- + if (!empty($difftags)) {
- + $this->tagsTable = $difftags;
- + } else {
- + $this->tagsTable = $this->postToGenerate['term_taxonomy_id'];
- }
- }
- }
- @@ -581,65 +587,65 @@
- * Tags
- * ***********************************/
- function buildPostsInTagsTable($exclude='',$hide_ping_and_track) {
- - global $utw_is_present;
- - if($utw_is_present) {
- - global $wpdb, $tabletags, $tablepost2tag;
- -
- - if( 1 == $hide_ping_and_track ) {
- - $ping = "AND comment_type NOT LIKE '%pingback%' AND comment_type NOT LIKE '%trackback%'";
- - } else {
- - $ping = '';
- - }
- -
- - if (!empty($exclude)) {
- - $excats = preg_split('/[\s,]+/',$exclude);
- - if (count($excats)) {
- - foreach ($excats as $excat) {
- - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
- - }
- + global $wpdb;
- +
- + if( 1 == $hide_ping_and_track ) {
- + $ping = "AND comment_type NOT LIKE '%pingback%' AND comment_type NOT LIKE '%trackback%'";
- + } else {
- + $ping = '';
- + }
- +
- + if (!empty($exclude)) {
- + $excats = preg_split('/[\s,]+/',$exclude);
- + if (count($excats)) {
- + foreach ($excats as $excat) {
- + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
- }
- }
- -
- - $now = current_time('mysql', 1);
- - foreach( $this->tagsTable as $tag) {
- - $posts_in_tags[$tags[0]] = array();
- - $query = "SELECT p2t.post_id
- - FROM $tablepost2tag p2t
- - INNER JOIN $wpdb->post2cat p2c ON p2t.post_id = p2c.post_ID
- - WHERE p2t.tag_id = $tag[0]
- - $exclusions";
- - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- - $posts_in_tag_results = $wpdb->get_results($query);
- + }
-
- - if( $posts_in_tag_results ) {
- - $posts_in_tag_results = array_reverse($posts_in_tag_results);
- - foreach( $posts_in_tag_results as $posts_in_tag_result ) {
- -
- - $query = "SELECT ID, post_title, post_date as `day`, comment_status
- - FROM $wpdb->posts
- - WHERE ID = $posts_in_tag_result->post_id
- - AND post_status = 'publish'
- - AND post_date_gmt <= '$now'
- - ORDER By post_date";
- - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- - $post_results = $wpdb->get_results($query);
- - if( $post_results ) {
- - foreach( $post_results as $post_result ) {
- - $query = "SELECT COUNT(comment_ID)
- - FROM $wpdb->comments
- - WHERE comment_post_ID = $post_result->ID
- - AND comment_approved = '1'
- - $ping";
- - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- - $num_comments = $wpdb->get_var($query);
- - $this->postsInTagsTable[$tag[0]][$post_result->ID] = array($post_result->day, $post_result->post_title, get_permalink($post_result->ID), $num_comments, $post_result->comment_status);
- - }
- + $now = current_time('mysql', 1);
- + foreach( $this->tagsTable as $tag) {
- + $posts_in_tags[$tags[0]] = array();
- + $query = "SELECT p.ID AS post_id
- + FROM $wpdb->posts p
- + INNER JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id
- + INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
- + WHERE tr.term_taxonomy_id = $tag[0]
- + AND tt.taxonomy = 'post_tag'
- + $exclusions";
- + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- + $posts_in_tag_results = $wpdb->get_results($query);
- +
- + if( $posts_in_tag_results ) {
- + $posts_in_tag_results = array_reverse($posts_in_tag_results);
- + foreach( $posts_in_tag_results as $posts_in_tag_result ) {
- +
- + $query = "SELECT ID, post_title, post_date as `day`, comment_status
- + FROM $wpdb->posts
- + WHERE ID = $posts_in_tag_result->post_id
- + AND post_type = 'post'
- + AND post_status = 'publish'
- + AND post_date_gmt <= '$now'
- + ORDER By post_date";
- + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- + $post_results = $wpdb->get_results($query);
- + if( $post_results ) {
- + foreach( $post_results as $post_result ) {
- + $query = "SELECT COUNT(comment_ID)
- + FROM $wpdb->comments
- + WHERE comment_post_ID = $post_result->ID
- + AND comment_approved = '1'
- + $ping";
- + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
- + $num_comments = $wpdb->get_var($query);
- + $this->postsInTagsTable[$tag[0]][$post_result->ID] = array($post_result->day, $post_result->post_title, get_permalink($post_result->ID), $num_comments, $post_result->comment_status);
- }
- }
- - if ($this->postsInTagsTable[$tag[0]]) {
- - $this->cache->contentIs($this->postsInTagsTable[$tag[0]]);
- - $this->cache->writeFile('tag-' . $tag[0] . '.dat');
- - }
- + }
- + if ($this->postsInTagsTable[$tag[0]]) {
- + $this->cache->contentIs($this->postsInTagsTable[$tag[0]]);
- + $this->cache->writeFile('tag-' . $tag[0] . '.dat');
- }
- }
- }
- Index: af-extended-live-archive-options.php
- --- af-extended-live-archive-options.php.orig 2006-06-22 07:56:38 +0200
- +++ af-extended-live-archive-options.php 2007-10-01 19:16:44 +0200
- @@ -93,6 +93,12 @@
- 'paged_post_next' => 'next posts >>',
- 'paged_post_prev' => '<< previous posts',
-
- + // tags related stuff
- + 'most_popular_color' => '#444444',
- + 'most_popular_font_size' => 250,
- + 'least_popular_color' => '#cccccc',
- + 'least_popular_font_size' => 70,
- + 'font_size_unit' => '%',
-
- // default text for the tab buttons
- 'menu_order' => 'chrono,cats',
- @@ -185,6 +191,13 @@
- if( isset($_POST['paged_post_next']) ) $settings['paged_post_next'] = urldecode($_POST['paged_post_next']);
- if( isset($_POST['paged_post_prev']) ) $settings['paged_post_prev'] = urldecode($_POST['paged_post_prev']);
-
- + // tags related stuff
- + if( isset($_POST['most_popular_color']) ) $settings['most_popular_color'] = urldecode($_POST['most_popular_color']);
- + if( isset($_POST['most_popular_font_size']) ) $settings['most_popular_font_size'] = urldecode($_POST['most_popular_font_size']);
- + if( isset($_POST['least_popular_color']) ) $settings['least_popular_color'] = urldecode($_POST['least_popular_color']);
- + if( isset($_POST['least_popular_font_size']) ) $settings['least_popular_font_size'] = urldecode($_POST['least_popular_font_size']);
- + if( isset($_POST['font_size_unit']) ) $settings['font_size_unit'] = urldecode($_POST['font_size_unit']);
- +
- // default text for the tab buttons
- if( isset($_POST['menu_order']) ) {
- $comma ='';
- @@ -203,7 +216,7 @@
- if( isset($_POST['idle_content']) ) $settings['idle_content'] = urldecode($_POST['idle_content']);
-
- $current_mode = get_option('af_ela_option_mode');
- - $asides_cats = $wpdb->get_results("SELECT * from $wpdb->categories");
- + $asides_cats = $wpdb->get_results("SELECT tt.term_taxonomy_id, t.name, t.slug from $wpdb->terms t, $wpdb->term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy = 'category'");
- $comma ='';
- if (!isset($_POST['excluded_categories'])) {?>
- <div class="updated"><p><strong>What's the point of not showing up any categories at all ?</strong></p></div> <?php
- @@ -213,9 +226,9 @@
- } else {
- $settings['excluded_categories'] = '';
- foreach ($asides_cats as $cat) {
- - if(!in_array($cat->cat_ID, $_POST['excluded_categories'])) {
- + if(!in_array($cat->term_taxonomy_id, $_POST['excluded_categories'])) {
- $settings['excluded_categories'] .= $comma ;
- - $settings['excluded_categories'] .= $cat->cat_ID;
- + $settings['excluded_categories'] .= $cat->term_taxonomy_id;
- $comma = ',';
- }
- }
- @@ -310,6 +323,7 @@
- af_ela_echo_fieldset_whataboutthemenus($settings,$advancedState);
- af_ela_echo_fieldset_whatcategoriestoshow($settings,$advancedState);
- af_ela_echo_fieldset_whataboutthepagedposts($settings,$advancedState);
- + af_ela_echo_fieldset_whataboutthetags($settings,$advancedState);
- ?> <hr style="clear: both; border: none;" />
- <div class="submit">
- <input type="submit" name="update_generic" value="<?php _e('Update Options Now') ?>" />
- @@ -330,7 +344,6 @@
- }
-
- function af_ela_echo_scripts() {
- - global $utw_is_present;
- ?> <script language="javascript" type="text/javascript">
- //<![CDATA[
- function disableTabs(first, disabler) {
- @@ -386,12 +399,12 @@
-
- function initUnavailableOptions(){
- disableDOM('number_text', 'num_entries');
- - <?php if($utw_is_present) { ?>disableDOM('number_text_tagged', 'num_entries_tagged');<?php }?>;
- + disableDOM('number_text_tagged', 'num_entries_tagged');
- disableDOM('comment_text', 'num_comments');
- disableDOM('closed_comment_text', 'num_comments');
- disableDOM('hide_pingbacks_and_trackbacks', 'num_comments');
- hideDOM('fieldsetpagedposts', 'paged_posts');
- - <?php if($utw_is_present) { ?>disableDOMinv('tag_soup_X', 'tag_soup_cut0');<?php }?>;
- + disableDOMinv('tag_soup_X', 'tag_soup_cut0');
- disableTabs(1, 0);
- }
-
- @@ -449,7 +462,6 @@
- }
-
- function af_ela_echo_fieldset_whattoshow($settings,$basicState, $current_mode) {
- - global $utw_is_present;
- ?>
- <fieldset class="options"><legend>What to show ? </legend>
- <table width="100%" cellspacing="2" cellpadding="5" class="editform">
- @@ -466,13 +478,13 @@
- <input onchange="Javascript:disableDOM('number_text', 'num_entries');" name="num_entries" id="num_entries" type="checkbox" value="<?php echo $settings['num_entries']; ?>" <?php checked('1', $settings['num_entries']); ?> />
- </td>
- <td><small>Sets whether the number of entries for each year, month, category should be shown.</small></td>
- - </tr><?php if($utw_is_present) { ?>
- + </tr>
- <tr>
- <th width="30%" valign="top" scope="row"><label for="num_entries_tagged">Show Number of Entries Per Tag:</label></th>
- <td width="5%">
- <input onchange="Javascript:disableDOM('number_text_tagged', 'num_entries_tagged');" name="num_entries_tagged" id="num_entries_tagged" type="checkbox" value="<?php echo $settings['num_entries_tagged']; ?>" <?php checked('1', $settings['num_entries_tagged']); ?> /></td>
- <td><small>Sets whether the number of entries for each tags should be shown</small></td>
- - </tr><?php } ?>
- + </tr>
- <tr>
- <th width="30%" valign="top" scope="row"><label for="num_comments">Show Number of Comments:</label></th>
- <td width="5%">
- @@ -509,11 +521,11 @@
- $asides_table = explode(',', $settings['excluded_categories']);
- if ($asides_table[0] != 0) {
- $id = $asides_table[0];
- - $asides_title = $wpdb->get_var("SELECT cat_name from $wpdb->categories WHERE cat_ID = ${asides_table[0]}");
- + $asides_title = $wpdb->get_var("SELECT t.name from $wpdb->terms t, $wpdb->term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy = 'category' AND tt.term_taxonomy_id = ${asides_table[0]}");
- } else {
- $asides_title='No Asides';
- }
- - $asides_cats = $wpdb->get_results("SELECT * from $wpdb->categories");
- + $asides_cats = $wpdb->get_results("SELECT tt.term_taxonomy_id, t.name, t.slug from $wpdb->terms t, $wpdb->term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy = 'category'");
- if ($current_mode == 0) {
- ?> <select name="excluded_categories[]" id="cat_asides" style="width: 10em;" >
- <option value="<?php echo $asides_table[0]; ?>"><?php echo $asides_title; ?></option>
- @@ -521,7 +533,7 @@
- <option value="0">No Asides</option>
- <option value="-----">----</option><?php
- foreach ($asides_cats as $cat) {
- - echo '<option value="' . $cat->cat_ID . '">' . $cat->cat_name . '</option>';
- + echo '<option value="' . $cat->term_taxonomy_id . '">' . $cat->name . '</option>';
- }?>
- </select><small> The category you are using for your asides.</small></td><?php } ?>
- </tr>
- @@ -530,7 +542,6 @@
- }
-
- function af_ela_echo_fieldset_howtoshow($settings,$advancedState) {
- - global $utw_is_present;
- ?> <fieldset class="options" style="display: <?php echo $advancedState; ?>; float: left; width: 52%;" ><legend>How to show it ? </legend>
- <table width="100%" cellspacing="2" cellpadding="5" class="editform" >
- <tr valign="top">
- @@ -547,12 +558,12 @@
- <th scope="row"><label for="number_text"># of Entries Text:</label></th>
- <td><input name="number_text" id="number_text" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['number_text'])); ?>" size="30" /><br/>
- <small>The string to show for number of entries per year, month or category. Can contain HTML. % is replaced with number of entries.</small></td>
- - </tr><?php if($utw_is_present) { ?>
- + </tr>
- <tr valign="top">
- <th scope="row"><label for="number_text_tagged"># of Tagged-Entries Text:</label></th>
- <td><input name="number_text_tagged" id="number_text_tagged" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['number_text_tagged'])); ?>" size="30" /><br/>
- <small>The string to show for number of entries per tag. Can contain HTML. % is replaced with number of entries.</small></td>
- - </tr><?php } ?>
- + </tr>
- <tr valign="top">
- <th scope="row"><label for="comment_text"># of Comments Text:</label></th>
- <td><input name="comment_text" id="comment_text" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['comment_text'])); ?>" size="30" /><br/>
- @@ -578,7 +589,6 @@
- }
-
- function af_ela_echo_fieldset_howtocut($settings,$advancedState) {
- - global $utw_is_present;
- ?>
- <fieldset class="options" style="display: <?php echo $advancedState; ?>;float: right; width: 40%;" ><legend>What to cut out ? </legend>
- <table width="100%" cellspacing="2" cellpadding="5" class="editform">
- @@ -606,7 +616,7 @@
- <th scope="row"><label for="abbreviated_month">Abbreviate month names:</label></th>
- <td><input name="abbreviated_month" id="abbreviated_month" type="checkbox" value="<?php echo $settings['abbreviated_month']; ?>" <?php checked('1', $settings['abbreviated_month']); ?> /><br/>
- <small>Sets whether the month names will be abbreviated to three letters.</small></td>
- - </tr><?php if ($utw_is_present) { ?>
- + </tr>
- <tr valign="top">
- <th scope="row"><label for="tag_soup_cut">Displayed tags:</label></th>
- <td><input name="tag_soup_cut" id="tag_soup_cut0" type="radio" value="0" onchange="Javascript:disableDOMinv('tag_soup_X', 'tag_soup_cut0');" <?php checked('0', $settings['tag_soup_cut']); ?> /><small>Show all tags.</small>
- @@ -618,7 +628,7 @@
- <th scope="row"><label for="tag_soup_X">The X in the selected above description:</label></th>
- <td><input name="tag_soup_X" id="tag_soup_X" type="text" value="<?php echo $settings['tag_soup_X']; ?>" /><br/>
- <small>Sets depending on the selection made above the number of post per tag needed to display the tag or the number of most-used tags to display.</small></td>
- - </tr><?php }?>
- + </tr>
- </table>
- </fieldset><?php
- }
- @@ -627,7 +637,6 @@
- if (!empty($settings['menu_order'])) {
- $menu_table = preg_split('/[\s,]+/',$settings['menu_order']);
- }
- - global $utw_is_present;
- ?> <fieldset class="options" style="display: <?php echo $advancedState; ?>; float: left; width: 52%" ><legend>What about the menus ? </legend>
- <table width="100%" cellspacing="2" cellpadding="5" class="editform">
- <tr valign="top">
- @@ -636,21 +645,20 @@
- <select name="menu_order[]" id="menu_order_tab0" onchange="Javascript:disableTabs(1,0);" style="width: 10em;" >
- <option value="none" <?php echo ($menu_table[0] == 'none') ? 'selected' : '' ?>>None</option>
- <option value="chrono" <?php echo ($menu_table[0] == 'chrono') ? 'selected' : '' ?>>By date</option>
- - <option value="cats" <?php echo ($menu_table[0] == 'cats') ? 'selected' : '' ?>>By category</option><?php if($utw_is_present) { ?>
- - <option value="tags" <?php echo ($menu_table[0] == 'tags') ? 'selected' : '' ?>>By tag</option><?php } ?></select>
- + <option value="cats" <?php echo ($menu_table[0] == 'cats') ? 'selected' : '' ?>>By category</option>
- + <option value="tags" <?php echo ($menu_table[0] == 'tags') ? 'selected' : '' ?>>By tag</option></select>
-
- <select name="menu_order[]" id="menu_order_tab1" onchange="Javascript:disableTabs(2,1);" style="width: 10em;" >
- <option id="none1" value="none" <?php echo ($menu_table[1] == 'none') ? 'selected' : '' ?>>None</option>
- <option id="chrono1" value="chrono" <?php echo ($menu_table[1] == 'chrono') ? 'selected' : '' ?>>By date</option>
- - <option id="cats1" value="cats" <?php echo ($menu_table[1] == 'cats') ? 'selected' : '' ?>>By category</option><?php if($utw_is_present) { ?>
- - <option id="tags1" value="tags" <?php echo ($menu_table[1] == 'tags') ? 'selected' : '' ?>>By tag</option><?php } ?></select>
- -<?php if($utw_is_present) { ?>
- + <option id="cats1" value="cats" <?php echo ($menu_table[1] == 'cats') ? 'selected' : '' ?>>By category</option>
- + <option id="tags1" value="tags" <?php echo ($menu_table[1] == 'tags') ? 'selected' : '' ?>>By tag</option></select>
- <select name="menu_order[]" id="menu_order_tab2" style="width: 10em;" >
- <option id="none2" value="none" <?php echo ($menu_table[2] == 'none') ? 'selected' : '' ?>>None</option>
- <option id="chrono2" value="chrono" <?php echo ($menu_table[2] == 'chrono') ? 'selected' : '' ?>>By date</option>
- <option id="cats2" value="cats" <?php echo ($menu_table[2] == 'cats') ? 'selected' : '' ?>>By category</option>
- <option id="tags2" value="tags" <?php echo ($menu_table[2] == 'tags') ? 'selected' : '' ?>>By tag</option>
- - </select><?php } ?>
- + </select>
- <br/><small>The order of the tab to display.</small></td>
- </tr>
- <tr valign="top">
- @@ -662,12 +670,12 @@
- <th scope="row"><label for="menu_cat">By Category Tab Text:</label></th>
- <td><input name="menu_cat" id="menu_cat" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['menu_cat'])); ?>" size="30" /><br/>
- <small>The text written in the categories tab.</small></td>
- - </tr><?php if($utw_is_present) { ?>
- + </tr>
- <tr valign="top">
- <th scope="row"><label for="menu_tag">By Tag Tab Text:</label></th>
- <td><input name="menu_tag" id="menu_tag" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['menu_tag'])); ?>" size="30" /><br/>
- <small>The text written in the tags tab.</small></td>
- - </tr><?php } ?>
- + </tr>
-
- <tr valign="top">
- <th scope="row"><label for="before_child">Before Child Text:</label></th>
- @@ -699,16 +707,16 @@
- global $wpdb;
- $asides_table = array();
- $asides_table = explode(',', $settings['excluded_categories']);
- - $asides_cats = $wpdb->get_results("SELECT * from $wpdb->categories");
- + $asides_cats = $wpdb->get_results("SELECT tt.term_taxonomy_id, t.name, t.slug from $wpdb->terms t, $wpdb->term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy = 'category'");
- $asides_content = '<table width="100%" cellspacing="2" cellpadding="5" class="editform">';
- $asides_select = '';
- foreach ($asides_cats as $cat) {
- - $checked = in_array($cat->cat_ID, $asides_table) ? '' : 'checked ';
- - $asides_select .= $cat->cat_ID.',';
- + $checked = in_array($cat->term_taxonomy_id, $asides_table) ? '' : 'checked ';
- + $asides_select .= $cat->term_taxonomy_id.',';
- $asides_content .= '
- <tr valign="top">
- - <th scope="row"><label for="category-'.$cat->cat_ID.'">'.$cat->cat_name.'</label></th>
- - <td width="5%"><input value="'.$cat->cat_ID.'" type="checkbox" name="excluded_categories[]" id="category-'.$cat->cat_ID.'" '. $checked . '/></td>
- + <th scope="row"><label for="category-'.$cat->term_taxonomy_id.'">'.$cat->name.'</label></th>
- + <td width="5%"><input value="'.$cat->term_taxonomy_id.'" type="checkbox" name="excluded_categories[]" id="category-'.$cat->term_taxonomy_id.'" '. $checked . '/></td>
- </tr>';
- }
- $asides_content .= '</table>';
- @@ -738,9 +746,51 @@
- <small>The text written as the link to the previous page.</small></td>
- </tr>
- </table>
- + </fieldset><?php
- +}
- +
- +function af_ela_echo_fieldset_whataboutthetags($settings,$advancedState) {
- +?>
- + <fieldset id="fieldsetthetags" class="options" style="display: <?php echo $advancedState; ?>; float: left; width: 52%" ><legend>What about the tags ?</legend><label for="cat_asides">Tag color and size for showing tag cloud.</label>
- + <table width="100%" cellspacing="2" cellpadding="5" class="editform">
- + <tr valign="top">
- + <th scope="row"><label for="most_popular_color">Most Popular Color:</label></th>
- + <td><input name="most_popular_color" id="most_popular_color" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['most_popular_color'])); ?>" size="30" /><br/>
- + <small>Hexadecimal color of most popular tag in tag cloud.</small></td>
- + </tr>
- + <tr valign="top">
- + <th scope="row"><label for="most_popular_font_size">Most Popular Font Size:</label></th>
- + <td><input name="most_popular_font_size" id="most_popular_font_size" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['most_popular_font_size'])); ?>" size="30" /><br/>
- + <small>Font size of most popular tag in tag cloud.</small></td>
- + </tr>
- + <tr valign="top">
- + <th scope="row"><label for="least_popular_color">Least Popular Color:</label></th>
- + <td><input name="least_popular_color" id="least_popular_color" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['least_popular_color'])); ?>" size="30" /><br/>
- + <small>Hexadecimal color of least popular tag in tag cloud.</small></td>
- + </tr>
- + <tr valign="top">
- + <th scope="row"><label for="least_popular_font_size">Least Popular Font Size:</label></th>
- + <td><input name="least_popular_font_size" id="least_popular_font_size" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['least_popular_font_size'])); ?>" size="30" /><br/>
- + <small>Font size of least popular tag in tag cloud.</small></td>
- + </tr>
- + <?php $font_units = array('%','pt','px','em'); ?>
- + <tr valign="top">
- + <th scope="row"><label for="font_size_unit">Font Size Unit:</label></th>
- + <td><select name="font_size_unit">
- + <?php foreach ($font_units as $font_unit) {
- + echo "<option value=\"$font_unit\"";
- + if ($settings['font_size_unit'] == $font_unit) {
- + echo " selected";
- + }
- + echo ">$font_unit</option>";
- + } ?>
- + </select><br/>
- + <small>Unit of font size.</small></td>
- + </tr>
- + </table>
- </fieldset>
- <?php
- }
-
- af_ela_admin_page();
- -?>
- \ No newline at end of file
- +?>
- Index: af-extended-live-archive.php
- --- af-extended-live-archive.php.orig 2006-06-22 07:56:34 +0200
- +++ af-extended-live-archive.php 2007-10-01 19:16:50 +0200
- @@ -16,12 +16,6 @@
-
- $af_ela_cache_root = dirname(__FILE__) . '/cache/';
- $debug = false;
- -$utw_is_present = false;
- -
- -if (file_exists(ABSPATH . 'wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-core.php') && in_array('UltimateTagWarrior/ultimate-tag-warrior.php', get_option('active_plugins'))) {
- - @require_once(ABSPATH . 'wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-core.php');
- - $utw_is_present=true;
- -}
-
- require_once(dirname(__FILE__)."/af-extended-live-archive-include.php");
-
- @@ -57,12 +51,14 @@
- $num_posts = $wpdb->get_var("
- SELECT COUNT(ID)
- FROM $wpdb->posts
- - WHERE post_status = 'publish'");
- + WHERE post_status = 'publish'
- + AND post_type = 'post'");
-
- $last_post_id = $wpdb->get_var("
- SELECT ID
- FROM $wpdb->posts
- WHERE post_status = 'publish'
- + AND post_type = 'post'
- ORDER BY post_date DESC LIMIT 1");
-
-
- @@ -145,7 +141,7 @@
- * actions when a post changes.
- **************************************/
- function af_ela_post_change($id) {
- - global $wpdb,$utw_is_present;
- + global $wpdb;
- $generator = new af_ela_classGenerator;
-
- $settings = get_option('af_ela_options');
- @@ -173,9 +169,9 @@
-
- $generator->buildPostsInCatsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
-
- - if($utw_is_present) $ret = $generator->buildTagsTable($settings['excluded_categories'], $idTags, $order, $orderparam);
- + $ret = $generator->buildTagsTable($settings['excluded_categories'], $idTags, $order, $orderparam);
-
- - if($ret && $utw_is_present) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
- + if($ret) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
-
- return $id;
- }
- @@ -184,7 +180,7 @@
- * creation of the cache
- **************************************/
- function af_ela_create_cache($settings) {
- - global $wpdb, $af_ela_cache_root, $utw_is_present;
- + global $wpdb, $af_ela_cache_root;
-
- if( !is_dir($af_ela_cache_root) ) {
- if(!af_ela_create_cache_dir()) return false;
- @@ -209,9 +205,9 @@
-
- $generator->buildPostsInCatsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
-
- - if($utw_is_present) $ret = $generator->buildTagsTable($settings['excluded_categories'], false, $order, $orderparam);
- + $ret = $generator->buildTagsTable($settings['excluded_categories'], false, $order, $orderparam);
-
- - if($ret && $utw_is_present) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
- + if($ret) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
-
- return true;
- }
- @@ -222,7 +218,7 @@
- * TODO need to do some more checks
- **************************************/
- function af_ela_set_config($config, $reset=false) {
- - global $wpdb, $af_ela_cache_root, $utw_is_present;
- + global $wpdb, $af_ela_cache_root;
-
- $settings = get_option('af_ela_options');
-
- @@ -286,4 +282,4 @@
- add_action('delete_comment', 'af_ela_comment_change');
- add_action('admin_menu', 'af_ela_admin_pages');
-
- -?>
- \ No newline at end of file
- +?>
- Index: includes/af-ela.php
- --- includes/af-ela.php.orig 2006-06-22 07:52:50 +0200
- +++ includes/af-ela.php 2007-10-01 19:16:55 +0200
- @@ -41,6 +41,51 @@
- return $title;
- }
-
- +function af_ela_get_color_for_weight($weight) {
- + global $settings;
- + $maxtagcolour = $settings['most_popular_color'];
- + $mintagcolour = $settings['least_popular_color'];
- + if ($weight) {
- + $weight = $weight/100;
- +
- + $minr = hexdec(substr($mintagcolour, 1, 2));
- + $ming = hexdec(substr($mintagcolour, 3, 2));
- + $minb = hexdec(substr($mintagcolour, 5, 2));
- +
- + $maxr = hexdec(substr($maxtagcolour, 1, 2));
- + $maxg = hexdec(substr($maxtagcolour, 3, 2));
- + $maxb = hexdec(substr($maxtagcolour, 5, 2));
- +
- + $r = dechex(intval((($maxr - $minr) * $weight) + $minr));
- + $g = dechex(intval((($maxg - $ming) * $weight) + $ming));
- + $b = dechex(intval((($maxb - $minb) * $weight) + $minb));
- +
- + if (strlen($r) == 1) $r = "0" . $r;
- + if (strlen($g) == 1) $g = "0" . $g;
- + if (strlen($b) == 1) $b = "0" . $b;
- +
- + return "#$r$g$b";
- + }
- +}
- +
- +
- +function af_ela_get_font_size_for_weight($weight) {
- + global $settings;
- + $maxtagsize = $settings['most_popular_font_size'];
- + $mintagsize = $settings['least_popular_font_size'];
- + $fontunits = $settings['font_size_unit'];
- +
- + if ($units == "") $units = '%';
- +
- + if ($maxtagsize > $mintagsize) {
- + $fontsize = (($weight/100) * ($maxtagsize - $mintagsize)) + $mintagsize;
- + } else {
- + $fontsize = (((100-$weight)/100) * ($maxtagsize - $mintagsize)) + $maxtagsize;
- + }
- +
- + return intval($fontsize) . $fontunits;
- +}
- +
- function af_ela_read_years() {
- global $year, $years, $path, $settings;
- $year_contents = @file_get_contents($path . 'years.dat');
- @@ -280,9 +325,9 @@
- $num = ' ' . str_replace('%', $p[2], $settings['number_text_tagged']);
- }
- $tag_weight = $p[2] / $posted_tags * 100;
- - $utwClass = new UltimateTagWarriorCore;
- - $tag_weightcolor = $utwClass->GetColorForWeight($tag_weight);
- - $tag_weightfontsize = $utwClass->GetFontSizeForWeight($tag_weight);
- + //$utwClass = new UltimateTagWarriorCore;
- + $tag_weightcolor = af_ela_get_color_for_weight($tag_weight);
- + $tag_weightfontsize = af_ela_get_font_size_for_weight($tag_weight);
- $tag_display = str_replace('_',' ', $p[1]);
- $tag_display = str_replace('-',' ',$tag_display);
- $tag_display = str_replace('+',' ',$tag_display);
- @@ -602,4 +647,4 @@
- header("Content-Type: text/html; charset=${settings['charset']}");
- echo $layer;
- echo $text;
- -?>
- \ No newline at end of file
- +?>
|