wordpress.patch.ela 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  1. Index: af-extended-live-archive-include.php
  2. --- af-extended-live-archive-include.php.orig 2006-06-17 19:04:56 +0200
  3. +++ af-extended-live-archive-include.php 2007-10-01 19:16:47 +0200
  4. @@ -43,7 +43,6 @@
  5. class af_ela_classGenerator {
  6. var $cache;
  7. - var $utwCore;
  8. var $yearTable = array();
  9. var $monthTable = array();
  10. var $catsTable = array();
  11. @@ -56,9 +55,7 @@
  12. * Helper Function : class constructor
  13. * ***********************************/
  14. function af_ela_classGenerator() {
  15. - global $utw_is_present;
  16. $this->cache = new af_ela_classCacheFile('');
  17. - if($utw_is_present) $this->utwCore = new UltimateTagWarriorCore;
  18. return true;
  19. }
  20. /* ***********************************
  21. @@ -66,13 +63,13 @@
  22. * updated post.
  23. * ***********************************/
  24. function buildPostToGenerateTable($exclude, $id, $commentId = false) {
  25. - global $wpdb, $tabletags, $tablepost2tag, $utw_is_present;
  26. + global $wpdb;
  27. if (!empty($exclude)) {
  28. $excats = preg_split('/[\s,]+/',$exclude);
  29. if (count($excats)) {
  30. foreach ($excats as $excat) {
  31. - $exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
  32. + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
  33. }
  34. }
  35. }
  36. @@ -82,40 +79,39 @@
  37. $dojustid = ' AND ID = ' . intval($id) . ' ' ;
  38. }
  39. - $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, category_id
  40. - FROM $wpdb->posts
  41. - INNER JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)
  42. + $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, tr.term_taxonomy_id AS `term_taxonomy_id`
  43. + FROM $wpdb->posts p
  44. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
  45. + INNER JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
  46. WHERE post_date > 0
  47. + AND taxonomy = 'category'
  48. $exclusions $dojustid
  49. ORDER By post_date DESC";
  50. logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  51. $results = $wpdb->get_results($query);
  52. if ($results) {
  53. foreach($results as $result) {
  54. - $this->postToGenerate['category_id'][] = $result->category_id;
  55. + $this->postToGenerate['term_taxonomy_id'][] = $result->term_taxonomy_id;
  56. }
  57. }
  58. $this->postToGenerate['new_year']= $results[0]->year;
  59. $this->postToGenerate['new_month']= $results[0]->month;
  60. - // For UTW
  61. - if($utw_is_present) {
  62. - $query = "SELECT tag_id
  63. - FROM $wpdb->posts
  64. - INNER JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)
  65. - INNER JOIN $tablepost2tag ON ($wpdb->posts.ID = $tablepost2tag.post_id)
  66. - WHERE post_date > 0
  67. - $exclusions $dojustid
  68. - ORDER By post_date DESC";
  69. - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  70. - $results = $wpdb->get_results($query);
  71. - if ($results) {
  72. - foreach($results as $result) {
  73. - $this->postToGenerate['tag_id'][] = $result->tag_id;
  74. - }
  75. + $query = "SELECT tr.term_taxonomy_id
  76. + FROM $wpdb->posts p
  77. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
  78. + INNER JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
  79. + WHERE post_date > 0
  80. + AND tt.taxonomy = 'post_tag'
  81. + $exclusions $dojustid
  82. + ORDER By post_date DESC";
  83. + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  84. + $results = $wpdb->get_results($query);
  85. + if ($results) {
  86. + foreach($results as $result) {
  87. + $this->postToGenerate['term_taxonomy_id'][] = $result->term_taxonomy_id;
  88. }
  89. }
  90. - // End of stuff for UTW
  91. return true;
  92. } else {
  93. @@ -130,9 +126,9 @@
  94. $dojustid = ' AND ID = ' . intval($id) . ' ' ;
  95. }
  96. - $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, category_id
  97. - FROM $wpdb->posts
  98. - INNER JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id)
  99. + $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, tr.term_taxonomy_id AS `term_taxonomy_id`
  100. + FROM $wpdb->posts p
  101. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
  102. WHERE post_date > 0
  103. $exclusions $dojustid
  104. ORDER By post_date DESC";
  105. @@ -140,14 +136,14 @@
  106. $results = $wpdb->get_results($query);
  107. if($results) {
  108. foreach($results as $result) {
  109. - $this->postToGenerate['category_id'][]=$result->category_id;
  110. + $this->postToGenerate['term_taxonomy_id'][]=$result->term_taxonomy_id;
  111. }
  112. $this->postToGenerate['post_id'] = $id;
  113. $this->postToGenerate['new_year']= $results[0]->year;
  114. $this->postToGenerate['new_month'] = $results[0]->month;
  115. $this->yearTable = array($this->postToGenerate['new_year'] => 0);
  116. $this->monthTable[$this->postToGenerate['new_year']] = array($this->postToGenerate['new_month'] => 0);
  117. - $this->catsTable = $this->postToGenerate['category_id'];
  118. + $this->catsTable = $this->postToGenerate['term_taxonomy_id'];
  119. return true;
  120. }
  121. }
  122. @@ -164,7 +160,7 @@
  123. $excats = preg_split('/[\s,]+/',$exclude);
  124. if (count($excats)) {
  125. foreach ($excats as $excat) {
  126. - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
  127. + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
  128. }
  129. }
  130. }
  131. @@ -172,7 +168,7 @@
  132. $query = "SELECT DISTINCT YEAR(p.post_date) AS `year`
  133. FROM $wpdb->posts p
  134. - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id)
  135. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
  136. WHERE p.post_date > 0
  137. $exclusions
  138. ORDER By p.post_date DESC";
  139. @@ -182,9 +178,10 @@
  140. foreach( $year_results as $year_result ) {
  141. $query = "SELECT p.ID
  142. FROM $wpdb->posts p
  143. - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id)
  144. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
  145. WHERE YEAR(p.post_date) = $year_result->year
  146. $exclusions
  147. + AND p.post_type = 'post'
  148. AND p.post_status = 'publish'
  149. AND p.post_date_gmt < '$now'
  150. GROUP BY p.ID";
  151. @@ -219,7 +216,7 @@
  152. $excats = preg_split('/[\s,]+/',$exclude);
  153. if (count($excats)) {
  154. foreach ($excats as $excat) {
  155. - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
  156. + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
  157. }
  158. }
  159. }
  160. @@ -228,7 +225,7 @@
  161. foreach( $this->yearTable as $year => $y ) {
  162. $query = "SELECT DISTINCT MONTH(p.post_date) AS `month`
  163. FROM $wpdb->posts p
  164. - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id )
  165. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id )
  166. WHERE YEAR(p.post_date) = $year
  167. $exclusions
  168. AND p.post_date_gmt < '$now'
  169. @@ -239,10 +236,11 @@
  170. foreach( $month_results as $month_result ) {
  171. $query = "SELECT p.ID
  172. FROM $wpdb->posts p
  173. - INNER JOIN $wpdb->post2cat p2c ON (p.ID = p2c.post_id)
  174. + INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
  175. WHERE YEAR(p.post_date) = $year
  176. $exclusions
  177. AND MONTH(p.post_date) = $month_result->month
  178. + AND p.post_type = 'post'
  179. AND p.post_status = 'publish'
  180. AND p.post_date_gmt < '$now'
  181. GROUP BY p.ID";
  182. @@ -282,7 +280,7 @@
  183. $excats = preg_split('/[\s,]+/',$exclude);
  184. if (count($excats)) {
  185. foreach ($excats as $excat) {
  186. - $exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
  187. + $exclusions .= ' AND term_taxonomy_id <> ' . intval($excat) . ' ';
  188. }
  189. }
  190. }
  191. @@ -297,6 +295,7 @@
  192. FROM $wpdb->posts
  193. WHERE YEAR(post_date) = $year
  194. AND MONTH(post_date) = $month
  195. + AND post_type = 'post'
  196. AND post_status = 'publish'
  197. AND post_date_gmt < '$now'
  198. ORDER By post_date DESC";
  199. @@ -304,9 +303,9 @@
  200. $post_results = $wpdb->get_results($query);
  201. if( $post_results ) {
  202. foreach( $post_results as $post_result ) {
  203. - $query = "SELECT category_id
  204. - FROM $wpdb->post2cat
  205. - WHERE post_id = $post_result->ID
  206. + $query = "SELECT term_taxonomy_id
  207. + FROM $wpdb->term_relationships
  208. + WHERE object_id = $post_result->ID
  209. $exclusions";
  210. logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  211. $posts_in_cat_results = $wpdb->get_results($query);
  212. @@ -364,7 +363,7 @@
  213. if (!empty($diffcats)) {
  214. $this->catsTable = $diffcats;
  215. } else {
  216. - $this->catsTable = $this->postToGenerate['category_id'];
  217. + $this->catsTable = $this->postToGenerate['term_taxonomy_id'];
  218. }
  219. }
  220. }
  221. @@ -378,17 +377,20 @@
  222. $excats = preg_split('/[\s,]+/',$exclude);
  223. if (count($excats)) {
  224. foreach ($excats as $excat) {
  225. - $exclusions .= ' AND c.cat_ID <> ' . intval($excat) . ' ';
  226. + $exclusions .= ' AND tt.term_taxonomy_id <> ' . intval($excat) . ' ';
  227. }
  228. }
  229. }
  230. if (intval($categories)==0){
  231. - $sort_column = 'c.cat_'.$sort_column;
  232. + $sort_column = 'tt.term_taxonomy_'.$sort_column;
  233. - $query = "SELECT cat_ID, cat_name, category_nicename, category_parent
  234. - FROM $wpdb->categories c
  235. - WHERE c.cat_ID > 0 $exclusions $dojustid
  236. + $query = "SELECT tt.term_taxonomy_id, t.name, t.slug, tt.parent
  237. + FROM $wpdb->terms t
  238. + INNER JOIN $wpdb->term_taxonomy tt ON (t.term_id = tt.term_id)
  239. + WHERE t.term_id > 0
  240. + AND tt.taxonomy = 'category'
  241. + $exclusions $dojustid
  242. ORDER BY $sort_column $sort_order";
  243. logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  244. $categories = $wpdb->get_results($query);
  245. @@ -396,39 +398,41 @@
  246. if (!count($category_posts)) {
  247. $now = current_time('mysql', 1);
  248. - $query = "SELECT c.cat_ID,
  249. - COUNT(distinct p2c.post_id) AS cat_count
  250. - FROM $wpdb->categories c
  251. - INNER JOIN $wpdb->post2cat p2c ON (c.cat_ID = p2c.category_id)
  252. - INNER JOIN $wpdb->posts p ON (p.ID = p2c.post_id)
  253. + $query = "SELECT tr.term_taxonomy_id,
  254. + COUNT(tr.object_id) AS cat_count
  255. + FROM $wpdb->term_taxonomy tt
  256. + INNER JOIN $wpdb->term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id)
  257. + INNER JOIN $wpdb->posts p ON (p.ID = tr.object_id)
  258. WHERE p.post_status = 'publish'
  259. + AND p.post_type = 'post'
  260. AND p.post_date_gmt < '$now'
  261. + AND tt.taxonomy = 'category'
  262. $exclusions
  263. - GROUP BY p2c.category_id";
  264. + GROUP BY tr.term_taxonomy_id";
  265. logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  266. $cat_counts = $wpdb->get_results($query);
  267. if (! empty($cat_counts)) {
  268. foreach ($cat_counts as $cat_count) {
  269. if (1 != intval($hide_empty) || $cat_count > 0) {
  270. - $category_posts[$cat_count->cat_ID] = $cat_count->cat_count;
  271. + $category_posts[$cat_count->term_taxonomy_id] = $cat_count->cat_count;
  272. }
  273. }
  274. }
  275. }
  276. foreach ($categories as $category) {
  277. - if ((intval($hide_empty) == 0 || isset($category_posts[$category->cat_ID])) && (!$hierarchical || $category->category_parent == $child_of) ) {
  278. - $this->catsTable[$category->cat_ID] = array( $category->cat_ID,
  279. - $category->cat_name,
  280. - $category->category_nicename,
  281. - $category_posts["$category->cat_ID"],
  282. - $category->category_parent);
  283. + if ((intval($hide_empty) == 0 || isset($category_posts[$category->term_taxonomy_id])) && (!$hierarchical || $category->parent == $child_of) ) {
  284. + $this->catsTable[$category->term_taxonomy_id] = array( $category->term_taxonomy_id,
  285. + $category->name,
  286. + $category->slug,
  287. + $category_posts["$category->term_taxonomy_id"],
  288. + $category->parent);
  289. if ($hierarchical && $children) {
  290. $this->buildCatsList( $sort_column,
  291. $sort_order,
  292. $hide_empty,
  293. $children,
  294. - $category->cat_ID,
  295. + $category->term_taxonomy_id,
  296. $categories,
  297. $exclude,
  298. $hierarchical);
  299. @@ -452,7 +456,7 @@
  300. $excats = preg_split('/[\s,]+/',$exclude);
  301. if (count($excats)) {
  302. foreach ($excats as $excat) {
  303. - $exclusions .= ' AND category_id <> ' . intval($excat) . ' ';
  304. + $exclusions .= ' AND term_taxonomy_id <> ' . intval($excat) . ' ';
  305. }
  306. }
  307. }
  308. @@ -460,23 +464,26 @@
  309. logthis($this->catsTable);
  310. foreach( $this->catsTable as $category ) {
  311. $posts_in_cat[$category[0]] = array();
  312. - $query = "SELECT post_id
  313. - FROM $wpdb->post2cat
  314. - WHERE category_id = $category[0]
  315. - $exclusions";
  316. + $query = "SELECT object_id AS post_id
  317. + FROM $wpdb->term_relationships tr
  318. + INNER JOIN $wpdb->posts p
  319. + ON tr.object_id = p.ID
  320. + WHERE tr.term_taxonomy_id = $category[0]
  321. + AND p.post_type = 'post'
  322. + AND p.post_status = 'publish'
  323. + AND p.post_date_gmt <= '$now'
  324. + $exclusions
  325. + ORDER BY p.post_date DESC";
  326. logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  327. $posts_in_cat_results = $wpdb->get_results($query);
  328. if( $posts_in_cat_results ) {
  329. - $posts_in_cat_results = array_reverse($posts_in_cat_results);
  330. + //$posts_in_cat_results = array_reverse($posts_in_cat_results);
  331. foreach( $posts_in_cat_results as $post_in_cat_result ) {
  332. $query = "SELECT ID, post_title, post_date as `day`, comment_status
  333. FROM $wpdb->posts
  334. - WHERE ID = $post_in_cat_result->post_id
  335. - AND post_status = 'publish'
  336. - AND post_date_gmt <= '$now'
  337. - ORDER By post_date";
  338. + WHERE ID = $post_in_cat_result->post_id ";
  339. logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  340. $post_results = $wpdb->get_results($query);
  341. if( $post_results ) {
  342. @@ -503,73 +510,72 @@
  343. * Helper Function : build Tags.
  344. * ***********************************/
  345. function buildTagsTable($exclude='', $id = false, $order = false, $orderparam = 0) {
  346. - global $utw_is_present;
  347. - if($utw_is_present) {
  348. - global $wpdb, $tabletags, $tablepost2tag;
  349. -
  350. - if (!empty($exclude)) {
  351. - $excats = preg_split('/[\s,]+/',$exclude);
  352. - if (count($excats)) {
  353. - foreach ($excats as $excat) {
  354. - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
  355. - }
  356. + global $wpdb;
  357. +
  358. + if (!empty($exclude)) {
  359. + $excats = preg_split('/[\s,]+/',$exclude);
  360. + if (count($excats)) {
  361. + foreach ($excats as $excat) {
  362. + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
  363. }
  364. }
  365. -
  366. - switch($order) {
  367. - case 2: // X is the min number of post per tag
  368. - $ordering = "HAVING tag_count >= ". $orderparam . " ORDER BY tag_count DESC";
  369. - break;
  370. - case 1: // X is the number of tag to show
  371. - $ordering = "ORDER BY tag_count DESC LIMIT ". $orderparam;
  372. - break;
  373. - case 0:
  374. - default:
  375. - $ordering = "";
  376. - break;
  377. - }
  378. -
  379. - $now = current_time('mysql', 1);
  380. + }
  381. +
  382. + switch($order) {
  383. + case 2: // X is the min number of post per tag
  384. + $ordering = "HAVING tag_count >= ". $orderparam . " ORDER BY tag_count DESC";
  385. + break;
  386. + case 1: // X is the number of tag to show
  387. + $ordering = "ORDER BY tag_count DESC LIMIT ". $orderparam;
  388. + break;
  389. + case 0:
  390. + default:
  391. + $ordering = "";
  392. + break;
  393. + }
  394. +
  395. + $now = current_time('mysql', 1);
  396. - $query = "SELECT t.tag_id, t.tag, count(distinct p2t.post_id) as tag_count
  397. - FROM $tabletags t
  398. - INNER JOIN $tablepost2tag p2t ON t.tag_id = p2t.tag_id
  399. - INNER JOIN $wpdb->posts p ON p2t.post_id = p.ID
  400. - INNER JOIN $wpdb->post2cat p2c ON p2t.post_id = p2c.post_ID
  401. - WHERE p.post_date_gmt < '$now'
  402. - AND p.post_status = 'publish'
  403. - $exclusions
  404. - GROUP BY t.tag
  405. - $ordering";
  406. - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  407. - $tagsSet = $wpdb->get_results($query);
  408. - $tagged_posts = 0;
  409. - $posted_tags = 0;
  410. - if( !empty($tagsSet) ) {
  411. - foreach($tagsSet as $tag) {
  412. - if ($tag->tag_count) {
  413. - $this->tagsTable[$tag->tag_id] = array($tag->tag_id, $tag->tag, $tag->tag_count );
  414. - $tagged_posts++;
  415. - if (intval($posted_tags) < intval($tag->tag_count)) $posted_tags = $tag->tag_count;
  416. - }
  417. - }
  418. - if ($order!= false ) {
  419. - $this->tagsTable = $this->arraySort($this->tagsTable, 1);
  420. + $query = "SELECT tt.term_taxonomy_id, t.name, count(distinct tr.object_id) as tag_count
  421. + FROM $wpdb->terms t
  422. + INNER JOIN $wpdb->term_taxonomy tt ON t.term_id = tt.term_id
  423. + INNER JOIN $wpdb->term_relationships tr ON tt.term_taxonomy_id = tr.term_taxonomy_id
  424. + INNER JOIN $wpdb->posts p ON tr.object_id = p.ID
  425. + WHERE p.post_date_gmt < '$now'
  426. + AND tt.taxonomy = 'post_tag'
  427. + AND p.post_type = 'post'
  428. + AND p.post_status = 'publish'
  429. + $exclusions
  430. + GROUP BY t.name
  431. + $ordering";
  432. + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  433. + $tagsSet = $wpdb->get_results($query);
  434. + $tagged_posts = 0;
  435. + $posted_tags = 0;
  436. + if( !empty($tagsSet) ) {
  437. + foreach($tagsSet as $tag) {
  438. + if ($tag->tag_count) {
  439. + $this->tagsTable[$tag->term_taxonomy_id] = array($tag->term_taxonomy_id, $tag->name, $tag->tag_count );
  440. + $tagged_posts++;
  441. + if (intval($posted_tags) < intval($tag->tag_count)) $posted_tags = $tag->tag_count;
  442. }
  443. -
  444. - $this->tagsTable[0] = array($tagged_posts, $posted_tags);
  445. -
  446. - $this->cache->contentIs($this->tagsTable);
  447. - $this->cache->writeFile('tags.dat');
  448. -
  449. - if($id) {
  450. - $this->cache->readFile('tags.dat');
  451. - $difftags = array_diff_assoc($this->cache->readFileContent, $this->tagsTable);
  452. - if (!empty($difftags)) {
  453. - $this->tagsTable = $difftags;
  454. - } else {
  455. - $this->tagsTable = $this->postToGenerate['tag_id'];
  456. - }
  457. + }
  458. + if ($order!= false ) {
  459. + $this->tagsTable = $this->arraySort($this->tagsTable, 1);
  460. + }
  461. +
  462. + $this->tagsTable[0] = array($tagged_posts, $posted_tags);
  463. +
  464. + $this->cache->contentIs($this->tagsTable);
  465. + $this->cache->writeFile('tags.dat');
  466. +
  467. + if($id) {
  468. + $this->cache->readFile('tags.dat');
  469. + $difftags = array_diff_assoc($this->cache->readFileContent, $this->tagsTable);
  470. + if (!empty($difftags)) {
  471. + $this->tagsTable = $difftags;
  472. + } else {
  473. + $this->tagsTable = $this->postToGenerate['term_taxonomy_id'];
  474. }
  475. }
  476. }
  477. @@ -581,65 +587,65 @@
  478. * Tags
  479. * ***********************************/
  480. function buildPostsInTagsTable($exclude='',$hide_ping_and_track) {
  481. - global $utw_is_present;
  482. - if($utw_is_present) {
  483. - global $wpdb, $tabletags, $tablepost2tag;
  484. -
  485. - if( 1 == $hide_ping_and_track ) {
  486. - $ping = "AND comment_type NOT LIKE '%pingback%' AND comment_type NOT LIKE '%trackback%'";
  487. - } else {
  488. - $ping = '';
  489. - }
  490. -
  491. - if (!empty($exclude)) {
  492. - $excats = preg_split('/[\s,]+/',$exclude);
  493. - if (count($excats)) {
  494. - foreach ($excats as $excat) {
  495. - $exclusions .= ' AND p2c.category_id <> ' . intval($excat) . ' ';
  496. - }
  497. + global $wpdb;
  498. +
  499. + if( 1 == $hide_ping_and_track ) {
  500. + $ping = "AND comment_type NOT LIKE '%pingback%' AND comment_type NOT LIKE '%trackback%'";
  501. + } else {
  502. + $ping = '';
  503. + }
  504. +
  505. + if (!empty($exclude)) {
  506. + $excats = preg_split('/[\s,]+/',$exclude);
  507. + if (count($excats)) {
  508. + foreach ($excats as $excat) {
  509. + $exclusions .= ' AND tr.term_taxonomy_id <> ' . intval($excat) . ' ';
  510. }
  511. }
  512. -
  513. - $now = current_time('mysql', 1);
  514. - foreach( $this->tagsTable as $tag) {
  515. - $posts_in_tags[$tags[0]] = array();
  516. - $query = "SELECT p2t.post_id
  517. - FROM $tablepost2tag p2t
  518. - INNER JOIN $wpdb->post2cat p2c ON p2t.post_id = p2c.post_ID
  519. - WHERE p2t.tag_id = $tag[0]
  520. - $exclusions";
  521. - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  522. - $posts_in_tag_results = $wpdb->get_results($query);
  523. + }
  524. - if( $posts_in_tag_results ) {
  525. - $posts_in_tag_results = array_reverse($posts_in_tag_results);
  526. - foreach( $posts_in_tag_results as $posts_in_tag_result ) {
  527. -
  528. - $query = "SELECT ID, post_title, post_date as `day`, comment_status
  529. - FROM $wpdb->posts
  530. - WHERE ID = $posts_in_tag_result->post_id
  531. - AND post_status = 'publish'
  532. - AND post_date_gmt <= '$now'
  533. - ORDER By post_date";
  534. - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  535. - $post_results = $wpdb->get_results($query);
  536. - if( $post_results ) {
  537. - foreach( $post_results as $post_result ) {
  538. - $query = "SELECT COUNT(comment_ID)
  539. - FROM $wpdb->comments
  540. - WHERE comment_post_ID = $post_result->ID
  541. - AND comment_approved = '1'
  542. - $ping";
  543. - logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  544. - $num_comments = $wpdb->get_var($query);
  545. - $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);
  546. - }
  547. + $now = current_time('mysql', 1);
  548. + foreach( $this->tagsTable as $tag) {
  549. + $posts_in_tags[$tags[0]] = array();
  550. + $query = "SELECT p.ID AS post_id
  551. + FROM $wpdb->posts p
  552. + INNER JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id
  553. + INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
  554. + WHERE tr.term_taxonomy_id = $tag[0]
  555. + AND tt.taxonomy = 'post_tag'
  556. + $exclusions";
  557. + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  558. + $posts_in_tag_results = $wpdb->get_results($query);
  559. +
  560. + if( $posts_in_tag_results ) {
  561. + $posts_in_tag_results = array_reverse($posts_in_tag_results);
  562. + foreach( $posts_in_tag_results as $posts_in_tag_result ) {
  563. +
  564. + $query = "SELECT ID, post_title, post_date as `day`, comment_status
  565. + FROM $wpdb->posts
  566. + WHERE ID = $posts_in_tag_result->post_id
  567. + AND post_type = 'post'
  568. + AND post_status = 'publish'
  569. + AND post_date_gmt <= '$now'
  570. + ORDER By post_date";
  571. + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  572. + $post_results = $wpdb->get_results($query);
  573. + if( $post_results ) {
  574. + foreach( $post_results as $post_result ) {
  575. + $query = "SELECT COUNT(comment_ID)
  576. + FROM $wpdb->comments
  577. + WHERE comment_post_ID = $post_result->ID
  578. + AND comment_approved = '1'
  579. + $ping";
  580. + logthis("SQL Query :".$query, __FUNCTION__, __LINE__);
  581. + $num_comments = $wpdb->get_var($query);
  582. + $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);
  583. }
  584. }
  585. - if ($this->postsInTagsTable[$tag[0]]) {
  586. - $this->cache->contentIs($this->postsInTagsTable[$tag[0]]);
  587. - $this->cache->writeFile('tag-' . $tag[0] . '.dat');
  588. - }
  589. + }
  590. + if ($this->postsInTagsTable[$tag[0]]) {
  591. + $this->cache->contentIs($this->postsInTagsTable[$tag[0]]);
  592. + $this->cache->writeFile('tag-' . $tag[0] . '.dat');
  593. }
  594. }
  595. }
  596. Index: af-extended-live-archive-options.php
  597. --- af-extended-live-archive-options.php.orig 2006-06-22 07:56:38 +0200
  598. +++ af-extended-live-archive-options.php 2007-10-01 19:16:44 +0200
  599. @@ -93,6 +93,12 @@
  600. 'paged_post_next' => 'next posts >>',
  601. 'paged_post_prev' => '<< previous posts',
  602. + // tags related stuff
  603. + 'most_popular_color' => '#444444',
  604. + 'most_popular_font_size' => 250,
  605. + 'least_popular_color' => '#cccccc',
  606. + 'least_popular_font_size' => 70,
  607. + 'font_size_unit' => '%',
  608. // default text for the tab buttons
  609. 'menu_order' => 'chrono,cats',
  610. @@ -185,6 +191,13 @@
  611. if( isset($_POST['paged_post_next']) ) $settings['paged_post_next'] = urldecode($_POST['paged_post_next']);
  612. if( isset($_POST['paged_post_prev']) ) $settings['paged_post_prev'] = urldecode($_POST['paged_post_prev']);
  613. + // tags related stuff
  614. + if( isset($_POST['most_popular_color']) ) $settings['most_popular_color'] = urldecode($_POST['most_popular_color']);
  615. + if( isset($_POST['most_popular_font_size']) ) $settings['most_popular_font_size'] = urldecode($_POST['most_popular_font_size']);
  616. + if( isset($_POST['least_popular_color']) ) $settings['least_popular_color'] = urldecode($_POST['least_popular_color']);
  617. + if( isset($_POST['least_popular_font_size']) ) $settings['least_popular_font_size'] = urldecode($_POST['least_popular_font_size']);
  618. + if( isset($_POST['font_size_unit']) ) $settings['font_size_unit'] = urldecode($_POST['font_size_unit']);
  619. +
  620. // default text for the tab buttons
  621. if( isset($_POST['menu_order']) ) {
  622. $comma ='';
  623. @@ -203,7 +216,7 @@
  624. if( isset($_POST['idle_content']) ) $settings['idle_content'] = urldecode($_POST['idle_content']);
  625. $current_mode = get_option('af_ela_option_mode');
  626. - $asides_cats = $wpdb->get_results("SELECT * from $wpdb->categories");
  627. + $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'");
  628. $comma ='';
  629. if (!isset($_POST['excluded_categories'])) {?>
  630. <div class="updated"><p><strong>What's the point of not showing up any categories at all ?</strong></p></div> <?php
  631. @@ -213,9 +226,9 @@
  632. } else {
  633. $settings['excluded_categories'] = '';
  634. foreach ($asides_cats as $cat) {
  635. - if(!in_array($cat->cat_ID, $_POST['excluded_categories'])) {
  636. + if(!in_array($cat->term_taxonomy_id, $_POST['excluded_categories'])) {
  637. $settings['excluded_categories'] .= $comma ;
  638. - $settings['excluded_categories'] .= $cat->cat_ID;
  639. + $settings['excluded_categories'] .= $cat->term_taxonomy_id;
  640. $comma = ',';
  641. }
  642. }
  643. @@ -310,6 +323,7 @@
  644. af_ela_echo_fieldset_whataboutthemenus($settings,$advancedState);
  645. af_ela_echo_fieldset_whatcategoriestoshow($settings,$advancedState);
  646. af_ela_echo_fieldset_whataboutthepagedposts($settings,$advancedState);
  647. + af_ela_echo_fieldset_whataboutthetags($settings,$advancedState);
  648. ?> <hr style="clear: both; border: none;" />
  649. <div class="submit">
  650. <input type="submit" name="update_generic" value="<?php _e('Update Options Now') ?>" />
  651. @@ -330,7 +344,6 @@
  652. }
  653. function af_ela_echo_scripts() {
  654. - global $utw_is_present;
  655. ?> <script language="javascript" type="text/javascript">
  656. //<![CDATA[
  657. function disableTabs(first, disabler) {
  658. @@ -386,12 +399,12 @@
  659. function initUnavailableOptions(){
  660. disableDOM('number_text', 'num_entries');
  661. - <?php if($utw_is_present) { ?>disableDOM('number_text_tagged', 'num_entries_tagged');<?php }?>;
  662. + disableDOM('number_text_tagged', 'num_entries_tagged');
  663. disableDOM('comment_text', 'num_comments');
  664. disableDOM('closed_comment_text', 'num_comments');
  665. disableDOM('hide_pingbacks_and_trackbacks', 'num_comments');
  666. hideDOM('fieldsetpagedposts', 'paged_posts');
  667. - <?php if($utw_is_present) { ?>disableDOMinv('tag_soup_X', 'tag_soup_cut0');<?php }?>;
  668. + disableDOMinv('tag_soup_X', 'tag_soup_cut0');
  669. disableTabs(1, 0);
  670. }
  671. @@ -449,7 +462,6 @@
  672. }
  673. function af_ela_echo_fieldset_whattoshow($settings,$basicState, $current_mode) {
  674. - global $utw_is_present;
  675. ?>
  676. <fieldset class="options"><legend>What to show ? </legend>
  677. <table width="100%" cellspacing="2" cellpadding="5" class="editform">
  678. @@ -466,13 +478,13 @@
  679. <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']); ?> />
  680. </td>
  681. <td><small>Sets whether the number of entries for each year, month, category should be shown.</small></td>
  682. - </tr><?php if($utw_is_present) { ?>
  683. + </tr>
  684. <tr>
  685. <th width="30%" valign="top" scope="row"><label for="num_entries_tagged">Show Number of Entries Per Tag:</label></th>
  686. <td width="5%">
  687. <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>
  688. <td><small>Sets whether the number of entries for each tags should be shown</small></td>
  689. - </tr><?php } ?>
  690. + </tr>
  691. <tr>
  692. <th width="30%" valign="top" scope="row"><label for="num_comments">Show Number of Comments:</label></th>
  693. <td width="5%">
  694. @@ -509,11 +521,11 @@
  695. $asides_table = explode(',', $settings['excluded_categories']);
  696. if ($asides_table[0] != 0) {
  697. $id = $asides_table[0];
  698. - $asides_title = $wpdb->get_var("SELECT cat_name from $wpdb->categories WHERE cat_ID = ${asides_table[0]}");
  699. + $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]}");
  700. } else {
  701. $asides_title='No Asides';
  702. }
  703. - $asides_cats = $wpdb->get_results("SELECT * from $wpdb->categories");
  704. + $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'");
  705. if ($current_mode == 0) {
  706. ?> <select name="excluded_categories[]" id="cat_asides" style="width: 10em;" >
  707. <option value="<?php echo $asides_table[0]; ?>"><?php echo $asides_title; ?></option>
  708. @@ -521,7 +533,7 @@
  709. <option value="0">No Asides</option>
  710. <option value="-----">----</option><?php
  711. foreach ($asides_cats as $cat) {
  712. - echo '<option value="' . $cat->cat_ID . '">' . $cat->cat_name . '</option>';
  713. + echo '<option value="' . $cat->term_taxonomy_id . '">' . $cat->name . '</option>';
  714. }?>
  715. </select><small>&nbsp;&nbsp;&nbsp;The category you are using for your asides.</small></td><?php } ?>
  716. </tr>
  717. @@ -530,7 +542,6 @@
  718. }
  719. function af_ela_echo_fieldset_howtoshow($settings,$advancedState) {
  720. - global $utw_is_present;
  721. ?> <fieldset class="options" style="display: <?php echo $advancedState; ?>; float: left; width: 52%;" ><legend>How to show it ? </legend>
  722. <table width="100%" cellspacing="2" cellpadding="5" class="editform" >
  723. <tr valign="top">
  724. @@ -547,12 +558,12 @@
  725. <th scope="row"><label for="number_text"># of Entries Text:</label></th>
  726. <td><input name="number_text" id="number_text" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['number_text'])); ?>" size="30" /><br/>
  727. <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>
  728. - </tr><?php if($utw_is_present) { ?>
  729. + </tr>
  730. <tr valign="top">
  731. <th scope="row"><label for="number_text_tagged"># of Tagged-Entries Text:</label></th>
  732. <td><input name="number_text_tagged" id="number_text_tagged" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['number_text_tagged'])); ?>" size="30" /><br/>
  733. <small>The string to show for number of entries per tag. Can contain HTML. % is replaced with number of entries.</small></td>
  734. - </tr><?php } ?>
  735. + </tr>
  736. <tr valign="top">
  737. <th scope="row"><label for="comment_text"># of Comments Text:</label></th>
  738. <td><input name="comment_text" id="comment_text" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['comment_text'])); ?>" size="30" /><br/>
  739. @@ -578,7 +589,6 @@
  740. }
  741. function af_ela_echo_fieldset_howtocut($settings,$advancedState) {
  742. - global $utw_is_present;
  743. ?>
  744. <fieldset class="options" style="display: <?php echo $advancedState; ?>;float: right; width: 40%;" ><legend>What to cut out ? </legend>
  745. <table width="100%" cellspacing="2" cellpadding="5" class="editform">
  746. @@ -606,7 +616,7 @@
  747. <th scope="row"><label for="abbreviated_month">Abbreviate month names:</label></th>
  748. <td><input name="abbreviated_month" id="abbreviated_month" type="checkbox" value="<?php echo $settings['abbreviated_month']; ?>" <?php checked('1', $settings['abbreviated_month']); ?> /><br/>
  749. <small>Sets whether the month names will be abbreviated to three letters.</small></td>
  750. - </tr><?php if ($utw_is_present) { ?>
  751. + </tr>
  752. <tr valign="top">
  753. <th scope="row"><label for="tag_soup_cut">Displayed tags:</label></th>
  754. <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>
  755. @@ -618,7 +628,7 @@
  756. <th scope="row"><label for="tag_soup_X">The X in the selected above description:</label></th>
  757. <td><input name="tag_soup_X" id="tag_soup_X" type="text" value="<?php echo $settings['tag_soup_X']; ?>" /><br/>
  758. <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>
  759. - </tr><?php }?>
  760. + </tr>
  761. </table>
  762. </fieldset><?php
  763. }
  764. @@ -627,7 +637,6 @@
  765. if (!empty($settings['menu_order'])) {
  766. $menu_table = preg_split('/[\s,]+/',$settings['menu_order']);
  767. }
  768. - global $utw_is_present;
  769. ?> <fieldset class="options" style="display: <?php echo $advancedState; ?>; float: left; width: 52%" ><legend>What about the menus ? </legend>
  770. <table width="100%" cellspacing="2" cellpadding="5" class="editform">
  771. <tr valign="top">
  772. @@ -636,21 +645,20 @@
  773. <select name="menu_order[]" id="menu_order_tab0" onchange="Javascript:disableTabs(1,0);" style="width: 10em;" >
  774. <option value="none" <?php echo ($menu_table[0] == 'none') ? 'selected' : '' ?>>None</option>
  775. <option value="chrono" <?php echo ($menu_table[0] == 'chrono') ? 'selected' : '' ?>>By date</option>
  776. - <option value="cats" <?php echo ($menu_table[0] == 'cats') ? 'selected' : '' ?>>By category</option><?php if($utw_is_present) { ?>
  777. - <option value="tags" <?php echo ($menu_table[0] == 'tags') ? 'selected' : '' ?>>By tag</option><?php } ?></select>
  778. + <option value="cats" <?php echo ($menu_table[0] == 'cats') ? 'selected' : '' ?>>By category</option>
  779. + <option value="tags" <?php echo ($menu_table[0] == 'tags') ? 'selected' : '' ?>>By tag</option></select>
  780. <select name="menu_order[]" id="menu_order_tab1" onchange="Javascript:disableTabs(2,1);" style="width: 10em;" >
  781. <option id="none1" value="none" <?php echo ($menu_table[1] == 'none') ? 'selected' : '' ?>>None</option>
  782. <option id="chrono1" value="chrono" <?php echo ($menu_table[1] == 'chrono') ? 'selected' : '' ?>>By date</option>
  783. - <option id="cats1" value="cats" <?php echo ($menu_table[1] == 'cats') ? 'selected' : '' ?>>By category</option><?php if($utw_is_present) { ?>
  784. - <option id="tags1" value="tags" <?php echo ($menu_table[1] == 'tags') ? 'selected' : '' ?>>By tag</option><?php } ?></select>
  785. -<?php if($utw_is_present) { ?>
  786. + <option id="cats1" value="cats" <?php echo ($menu_table[1] == 'cats') ? 'selected' : '' ?>>By category</option>
  787. + <option id="tags1" value="tags" <?php echo ($menu_table[1] == 'tags') ? 'selected' : '' ?>>By tag</option></select>
  788. <select name="menu_order[]" id="menu_order_tab2" style="width: 10em;" >
  789. <option id="none2" value="none" <?php echo ($menu_table[2] == 'none') ? 'selected' : '' ?>>None</option>
  790. <option id="chrono2" value="chrono" <?php echo ($menu_table[2] == 'chrono') ? 'selected' : '' ?>>By date</option>
  791. <option id="cats2" value="cats" <?php echo ($menu_table[2] == 'cats') ? 'selected' : '' ?>>By category</option>
  792. <option id="tags2" value="tags" <?php echo ($menu_table[2] == 'tags') ? 'selected' : '' ?>>By tag</option>
  793. - </select><?php } ?>
  794. + </select>
  795. <br/><small>The order of the tab to display.</small></td>
  796. </tr>
  797. <tr valign="top">
  798. @@ -662,12 +670,12 @@
  799. <th scope="row"><label for="menu_cat">By Category Tab Text:</label></th>
  800. <td><input name="menu_cat" id="menu_cat" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['menu_cat'])); ?>" size="30" /><br/>
  801. <small>The text written in the categories tab.</small></td>
  802. - </tr><?php if($utw_is_present) { ?>
  803. + </tr>
  804. <tr valign="top">
  805. <th scope="row"><label for="menu_tag">By Tag Tab Text:</label></th>
  806. <td><input name="menu_tag" id="menu_tag" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['menu_tag'])); ?>" size="30" /><br/>
  807. <small>The text written in the tags tab.</small></td>
  808. - </tr><?php } ?>
  809. + </tr>
  810. <tr valign="top">
  811. <th scope="row"><label for="before_child">Before Child Text:</label></th>
  812. @@ -699,16 +707,16 @@
  813. global $wpdb;
  814. $asides_table = array();
  815. $asides_table = explode(',', $settings['excluded_categories']);
  816. - $asides_cats = $wpdb->get_results("SELECT * from $wpdb->categories");
  817. + $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'");
  818. $asides_content = '<table width="100%" cellspacing="2" cellpadding="5" class="editform">';
  819. $asides_select = '';
  820. foreach ($asides_cats as $cat) {
  821. - $checked = in_array($cat->cat_ID, $asides_table) ? '' : 'checked ';
  822. - $asides_select .= $cat->cat_ID.',';
  823. + $checked = in_array($cat->term_taxonomy_id, $asides_table) ? '' : 'checked ';
  824. + $asides_select .= $cat->term_taxonomy_id.',';
  825. $asides_content .= '
  826. <tr valign="top">
  827. - <th scope="row"><label for="category-'.$cat->cat_ID.'">'.$cat->cat_name.'</label></th>
  828. - <td width="5%"><input value="'.$cat->cat_ID.'" type="checkbox" name="excluded_categories[]" id="category-'.$cat->cat_ID.'" '. $checked . '/></td>
  829. + <th scope="row"><label for="category-'.$cat->term_taxonomy_id.'">'.$cat->name.'</label></th>
  830. + <td width="5%"><input value="'.$cat->term_taxonomy_id.'" type="checkbox" name="excluded_categories[]" id="category-'.$cat->term_taxonomy_id.'" '. $checked . '/></td>
  831. </tr>';
  832. }
  833. $asides_content .= '</table>';
  834. @@ -738,9 +746,51 @@
  835. <small>The text written as the link to the previous page.</small></td>
  836. </tr>
  837. </table>
  838. + </fieldset><?php
  839. +}
  840. +
  841. +function af_ela_echo_fieldset_whataboutthetags($settings,$advancedState) {
  842. +?>
  843. + <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>
  844. + <table width="100%" cellspacing="2" cellpadding="5" class="editform">
  845. + <tr valign="top">
  846. + <th scope="row"><label for="most_popular_color">Most Popular Color:</label></th>
  847. + <td><input name="most_popular_color" id="most_popular_color" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['most_popular_color'])); ?>" size="30" /><br/>
  848. + <small>Hexadecimal color of most popular tag in tag cloud.</small></td>
  849. + </tr>
  850. + <tr valign="top">
  851. + <th scope="row"><label for="most_popular_font_size">Most Popular Font Size:</label></th>
  852. + <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/>
  853. + <small>Font size of most popular tag in tag cloud.</small></td>
  854. + </tr>
  855. + <tr valign="top">
  856. + <th scope="row"><label for="least_popular_color">Least Popular Color:</label></th>
  857. + <td><input name="least_popular_color" id="least_popular_color" type="text" value="<?php echo htmlspecialchars(stripslashes($settings['least_popular_color'])); ?>" size="30" /><br/>
  858. + <small>Hexadecimal color of least popular tag in tag cloud.</small></td>
  859. + </tr>
  860. + <tr valign="top">
  861. + <th scope="row"><label for="least_popular_font_size">Least Popular Font Size:</label></th>
  862. + <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/>
  863. + <small>Font size of least popular tag in tag cloud.</small></td>
  864. + </tr>
  865. + <?php $font_units = array('%','pt','px','em'); ?>
  866. + <tr valign="top">
  867. + <th scope="row"><label for="font_size_unit">Font Size Unit:</label></th>
  868. + <td><select name="font_size_unit">
  869. + <?php foreach ($font_units as $font_unit) {
  870. + echo "<option value=\"$font_unit\"";
  871. + if ($settings['font_size_unit'] == $font_unit) {
  872. + echo " selected";
  873. + }
  874. + echo ">$font_unit</option>";
  875. + } ?>
  876. + </select><br/>
  877. + <small>Unit of font size.</small></td>
  878. + </tr>
  879. + </table>
  880. </fieldset>
  881. <?php
  882. }
  883. af_ela_admin_page();
  884. -?>
  885. \ No newline at end of file
  886. +?>
  887. Index: af-extended-live-archive.php
  888. --- af-extended-live-archive.php.orig 2006-06-22 07:56:34 +0200
  889. +++ af-extended-live-archive.php 2007-10-01 19:16:50 +0200
  890. @@ -16,12 +16,6 @@
  891. $af_ela_cache_root = dirname(__FILE__) . '/cache/';
  892. $debug = false;
  893. -$utw_is_present = false;
  894. -
  895. -if (file_exists(ABSPATH . 'wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-core.php') && in_array('UltimateTagWarrior/ultimate-tag-warrior.php', get_option('active_plugins'))) {
  896. - @require_once(ABSPATH . 'wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-core.php');
  897. - $utw_is_present=true;
  898. -}
  899. require_once(dirname(__FILE__)."/af-extended-live-archive-include.php");
  900. @@ -57,12 +51,14 @@
  901. $num_posts = $wpdb->get_var("
  902. SELECT COUNT(ID)
  903. FROM $wpdb->posts
  904. - WHERE post_status = 'publish'");
  905. + WHERE post_status = 'publish'
  906. + AND post_type = 'post'");
  907. $last_post_id = $wpdb->get_var("
  908. SELECT ID
  909. FROM $wpdb->posts
  910. WHERE post_status = 'publish'
  911. + AND post_type = 'post'
  912. ORDER BY post_date DESC LIMIT 1");
  913. @@ -145,7 +141,7 @@
  914. * actions when a post changes.
  915. **************************************/
  916. function af_ela_post_change($id) {
  917. - global $wpdb,$utw_is_present;
  918. + global $wpdb;
  919. $generator = new af_ela_classGenerator;
  920. $settings = get_option('af_ela_options');
  921. @@ -173,9 +169,9 @@
  922. $generator->buildPostsInCatsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
  923. - if($utw_is_present) $ret = $generator->buildTagsTable($settings['excluded_categories'], $idTags, $order, $orderparam);
  924. + $ret = $generator->buildTagsTable($settings['excluded_categories'], $idTags, $order, $orderparam);
  925. - if($ret && $utw_is_present) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
  926. + if($ret) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
  927. return $id;
  928. }
  929. @@ -184,7 +180,7 @@
  930. * creation of the cache
  931. **************************************/
  932. function af_ela_create_cache($settings) {
  933. - global $wpdb, $af_ela_cache_root, $utw_is_present;
  934. + global $wpdb, $af_ela_cache_root;
  935. if( !is_dir($af_ela_cache_root) ) {
  936. if(!af_ela_create_cache_dir()) return false;
  937. @@ -209,9 +205,9 @@
  938. $generator->buildPostsInCatsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
  939. - if($utw_is_present) $ret = $generator->buildTagsTable($settings['excluded_categories'], false, $order, $orderparam);
  940. + $ret = $generator->buildTagsTable($settings['excluded_categories'], false, $order, $orderparam);
  941. - if($ret && $utw_is_present) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
  942. + if($ret) $generator->buildPostsInTagsTable($settings['excluded_categories'], $settings['hide_pingbacks_and_trackbacks']);
  943. return true;
  944. }
  945. @@ -222,7 +218,7 @@
  946. * TODO need to do some more checks
  947. **************************************/
  948. function af_ela_set_config($config, $reset=false) {
  949. - global $wpdb, $af_ela_cache_root, $utw_is_present;
  950. + global $wpdb, $af_ela_cache_root;
  951. $settings = get_option('af_ela_options');
  952. @@ -286,4 +282,4 @@
  953. add_action('delete_comment', 'af_ela_comment_change');
  954. add_action('admin_menu', 'af_ela_admin_pages');
  955. -?>
  956. \ No newline at end of file
  957. +?>
  958. Index: includes/af-ela.php
  959. --- includes/af-ela.php.orig 2006-06-22 07:52:50 +0200
  960. +++ includes/af-ela.php 2007-10-01 19:16:55 +0200
  961. @@ -41,6 +41,51 @@
  962. return $title;
  963. }
  964. +function af_ela_get_color_for_weight($weight) {
  965. + global $settings;
  966. + $maxtagcolour = $settings['most_popular_color'];
  967. + $mintagcolour = $settings['least_popular_color'];
  968. + if ($weight) {
  969. + $weight = $weight/100;
  970. +
  971. + $minr = hexdec(substr($mintagcolour, 1, 2));
  972. + $ming = hexdec(substr($mintagcolour, 3, 2));
  973. + $minb = hexdec(substr($mintagcolour, 5, 2));
  974. +
  975. + $maxr = hexdec(substr($maxtagcolour, 1, 2));
  976. + $maxg = hexdec(substr($maxtagcolour, 3, 2));
  977. + $maxb = hexdec(substr($maxtagcolour, 5, 2));
  978. +
  979. + $r = dechex(intval((($maxr - $minr) * $weight) + $minr));
  980. + $g = dechex(intval((($maxg - $ming) * $weight) + $ming));
  981. + $b = dechex(intval((($maxb - $minb) * $weight) + $minb));
  982. +
  983. + if (strlen($r) == 1) $r = "0" . $r;
  984. + if (strlen($g) == 1) $g = "0" . $g;
  985. + if (strlen($b) == 1) $b = "0" . $b;
  986. +
  987. + return "#$r$g$b";
  988. + }
  989. +}
  990. +
  991. +
  992. +function af_ela_get_font_size_for_weight($weight) {
  993. + global $settings;
  994. + $maxtagsize = $settings['most_popular_font_size'];
  995. + $mintagsize = $settings['least_popular_font_size'];
  996. + $fontunits = $settings['font_size_unit'];
  997. +
  998. + if ($units == "") $units = '%';
  999. +
  1000. + if ($maxtagsize > $mintagsize) {
  1001. + $fontsize = (($weight/100) * ($maxtagsize - $mintagsize)) + $mintagsize;
  1002. + } else {
  1003. + $fontsize = (((100-$weight)/100) * ($maxtagsize - $mintagsize)) + $maxtagsize;
  1004. + }
  1005. +
  1006. + return intval($fontsize) . $fontunits;
  1007. +}
  1008. +
  1009. function af_ela_read_years() {
  1010. global $year, $years, $path, $settings;
  1011. $year_contents = @file_get_contents($path . 'years.dat');
  1012. @@ -280,9 +325,9 @@
  1013. $num = ' ' . str_replace('%', $p[2], $settings['number_text_tagged']);
  1014. }
  1015. $tag_weight = $p[2] / $posted_tags * 100;
  1016. - $utwClass = new UltimateTagWarriorCore;
  1017. - $tag_weightcolor = $utwClass->GetColorForWeight($tag_weight);
  1018. - $tag_weightfontsize = $utwClass->GetFontSizeForWeight($tag_weight);
  1019. + //$utwClass = new UltimateTagWarriorCore;
  1020. + $tag_weightcolor = af_ela_get_color_for_weight($tag_weight);
  1021. + $tag_weightfontsize = af_ela_get_font_size_for_weight($tag_weight);
  1022. $tag_display = str_replace('_',' ', $p[1]);
  1023. $tag_display = str_replace('-',' ',$tag_display);
  1024. $tag_display = str_replace('+',' ',$tag_display);
  1025. @@ -602,4 +647,4 @@
  1026. header("Content-Type: text/html; charset=${settings['charset']}");
  1027. echo $layer;
  1028. echo $text;
  1029. -?>
  1030. \ No newline at end of file
  1031. +?>