'custom date format', 'limit_to'=>'Run the plugin only for this file', 'post_separator'=>'character(s) to use when joining post titles' ); var $date_format = '%e %B %y'; var $limit_to = 'list_categories.php'; var $post_separator = '‖'; var $default_context = LP_CONTEXT_INDEX; var $description = 'Display a list of active categories and their posts titles'; var $active = true; var $hooks = array('pre_render'); function CategoriesListExtended(&$frontend, $args, $dummy_run=false) { $this->LightPressPlugin($frontend, $args, $dummy_run); if (!$dummy_run && !empty($this->limit_to) && basename($_SERVER['PHP_SELF']) != $this->limit_to) $this->active = false; } function run($hook, &$hook_data) { $f =& $this->_frontend; $tpl =& $f->tpl; $db =& $f->db; $sep = $this->post_separator; $tpl->setFile('plugin_categorieslistextended', 'plugins/categories_list_extended.xml'); $tpl->setBlock('plugin_categorieslistextended', 'plugin_categorieslistextended_catgroup', 'PLUGIN_CATEGORIESLISTEXTENDED_CATGROUP'); $tpl->setBlock('plugin_categorieslistextended_catgroup', 'plugin_categorieslistextended_category', 'PLUGIN_CATEGORIESLISTEXTENDED_CATEGORY'); $categories =& $this->_frontend->getCategories(); $q = "select p.id, p.post_name, p.post_title, UNIX_TIMESTAMP(p.post_date) as tstamp, " . "p.post_category as category_id, p2c.category_id as post_category " . "from " . $f->tables['post2cat'] . " p2c " . "inner join " . $f->tables['posts'] . " p on p.id = p2c.post_id " . "where p.post_status='publish' and p.post_date_gmt <= '" . $f->where_date . "' " . "order by p2c.category_id, p.post_date desc"; $db->query($q); $opt_url = $f->options['url']; $category = null; foreach ($db->all() as $post) { if ($category != $post['post_category']) { if (!is_null($category)) $categories[$category]['posts'] = '
  • ' . implode("
  • $sep
  • ", $posts) . '
  • '; $posts = array(); $category = $post['post_category']; } $posts[] = sprintf('%s', $opt_url, $f->getPermalink($post['id'], $post['post_name'], $post['tstamp'], $post['category_id']), htmlspecialchars($post['post_title'], ENT_QUOTES)); } $categories[$category]['posts'] = '
  • ' . implode("
  • $sep
  • ", $posts) . '
  • '; $config_messages =& $f->messages; $date_format = (empty($this->date_format) ? $f->options['short_date_format'] : $this->date_format); $catgroup = null; $append = true; foreach ($categories as $category) { if ($category['catgroup'] != $catgroup) { if ($catgroup != null) { $tpl->parse('PLUGIN_CATEGORIESLISTEXTENDED_CATGROUP', 'plugin_categorieslistextended_catgroup', true); $append = false; } $catgroup = $category['catgroup']; } $tpl->setVar($category); if (is_null($catgroup)) { $tpl->parse('PLUGIN_CATEGORIESLISTEXTENDED_CATGROUP', 'plugin_categorieslistextended_category', true); } else { $tpl->parse('PLUGIN_CATEGORIESLISTEXTENDED_CATEGORY', 'plugin_categorieslistextended_category', $append); $append = true; } } if ($catgroup != null) $tpl->parse('PLUGIN_CATEGORIESLISTEXTENDED_CATGROUP', 'plugin_categorieslistextended_catgroup', true); $tpl->parse('PLUGIN_CATEGORIESLISTEXTENDED', 'plugin_categorieslistextended', true); } } ?>