$ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max()); $ItemList->set_filters(array('cat_array' => array($Chapter->ID), 'cat_modifier' => NULL, 'unit' => 'all')); $ItemList->query(); if ($ItemList->result_num_rows > 0) { $no_content_to_display = false; ?> <div class="posts_list"> <div class="category_title clear"><h2><a href="<?php echo $Chapter->get_permanent_url(); ?> "><?php echo $Chapter->get('name'); ?> </a></h2></div> <?php while ($Item =& $ItemList->get_item()) { // For each blog post, do everything below up to the closing curly brace "}" // Temporarily switch to post locale (useful for multilingual blogs) $Item->locale_temp_switch(); ?> <div id="<?php $Item->anchor_id(); ?> " class="<?php $Item->div_classes($params); ?> " lang="<?php $Item->lang(); ?> "> <?php
echo sprintf(T_('Blog #%d doesn\'t seem to exist.'), 3); } else { ?> <h3>#3: <a href="<?php $Blog_roll->disp('blogurl', 'raw'); ?> "><?php echo $Blog_roll->disp('name', 'htmlbody'); ?> </a></h3> <?php $LinkblogList = new ItemList2($Blog_roll, $Blog_roll->get_timestamp_min(), $Blog_roll->get_timestamp_max(), $posts); $LinkblogList->set_filters(array('authors' => $author, 'ymdhms' => $m, 'week' => $w, 'order' => $order, 'orderby' => $orderby, 'unit' => $unit)); // Run the query: $LinkblogList->query(); while ($Item =& $LinkblogList->get_item()) { ?> <div id="<?php $Item->anchor_id(); ?> " class="bPostSide bPostSide<?php $Item->status_raw(); ?> " lang="<?php $Item->lang(); ?> "> <h4 class="bTitle"> <?php $Item->permanent_link(array('text' => '#icon#')); ?>
/** * blogger.getRecentPosts retieves X most recent posts. * * This API call is not documented on * {@link http://www.blogger.com/developers/api/1_docs/} * @see http://www.sixapart.com/developers/xmlrpc/blogger_api/bloggergetrecentposts.html * * @param xmlrpcmsg XML-RPC Message * 0 appkey (string): Unique identifier/passcode of the application sending the post. * (See access info {@link http://www.blogger.com/developers/api/1_docs/#access} .) * 1 blogid (string): Unique identifier of the blog the post will be added to. * Currently ignored in b2evo, in favor of the category. * 2 username (string): Login for a Blogger user who has permission to edit the given * post (either the user who originally created it or an admin of the blog). * 3 password (string): Password for said username. * 4 numposts (integer): number of posts to retrieve. * @return xmlrpcresp XML-RPC Response */ function blogger_getrecentposts($m) { global $xmlrpcerruser, $DB; // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 2, 3))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET BLOG: /** * @var Blog */ if (!($Blog =& xmlrpcs_get_Blog($m, 1))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } $numposts = $m->getParam(4); $numposts = $numposts->scalarval(); // Get the posts to display: load_class('items/model/_itemlist.class.php', 'ItemList'); $MainList = new ItemList2($Blog, NULL, NULL, $numposts); // Protected and private get checked by statuses_where_clause(). $statuses = array('published', 'redirected', 'protected', 'private'); if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) { // These statuses require member status: $statuses = array_merge($statuses, array('draft', 'deprecated')); } logIO('Statuses: ' . implode(', ', $statuses)); $MainList->set_filters(array('visibility_array' => $statuses, 'order' => 'DESC', 'unit' => 'posts')); // Run the query: $MainList->query(); logIO('Items:' . $MainList->result_num_rows); $data = array(); while ($Item =& $MainList->get_item()) { logIO('Item:' . $Item->title . ' - Issued: ' . $Item->issue_date . ' - Modified: ' . $Item->datemodified); $post_date = mysql2date('U', $Item->issue_date); $post_date = gmdate('Ymd', $post_date) . 'T' . gmdate('H:i:s', $post_date); $content = '<title>' . $Item->title . '</title>'; $content .= '<category>' . $Item->main_cat_ID . '</category>'; $content .= $Item->content; // Load Item's creator User: $Item->get_creator_User(); $authorname = $Item->creator_User->get('preferredname'); $data[] = new xmlrpcval(array('authorName' => new xmlrpcval($authorname), 'userid' => new xmlrpcval($Item->creator_user_ID), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'content' => new xmlrpcval($content), 'postid' => new xmlrpcval($Item->ID)), 'struct'); } $resp = new xmlrpcval($data, 'array'); logIO('OK.'); return new xmlrpcresp($resp); }
/** * Get array of latest items * * @param array of params * - limit (int) the number of items to return * - post_ID (int) return specified item or NULL to return all available * @return xmlrpcmsg */ function xmlrpc_get_items($params, &$Blog) { global $current_User; $params = array_merge(array('limit' => 0, 'item_ID' => 0, 'types' => ''), $params); // Protected and private get checked by statuses_where_clause(). $statuses = array('published', 'redirected', 'protected', 'private'); if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) { // These statuses require member status: $statuses = array_merge($statuses, array('draft', 'deprecated')); } logIO('Statuses: ' . implode(', ', $statuses)); if (!empty($params['item_ID'])) { logIO('Getting item #' . $params['item_ID']); $filters = array('visibility_array' => $statuses, 'types' => NULL, 'post_ID' => $params['item_ID']); } else { logIO(sprintf('Trying to get latest items (%s)', $params['limit'] ? $params['limit'] : 'all')); $filters = array('visibility_array' => $statuses, 'types' => $params['types'], 'order' => 'DESC', 'unit' => 'posts'); } // Get the pages to display: load_class('items/model/_itemlist.class.php', 'ItemList2'); $ItemList = new ItemList2($Blog, NULL, NULL, $params['limit']); $ItemList->set_filters($filters, false); // Run the query: $ItemList->query(); logIO('Items found: ' . $ItemList->result_num_rows); $data = array(); while ($Item =& $ItemList->get_item()) { $data[] = _wp_mw_get_item_struct($Item); } return $data; }
/** * Display a list of the posts for current chapter * * @param array params * @return string List with posts */ function manual_display_posts($params = array(), $level = 0) { $params = array_merge(array('chapter_ID' => 0, 'chapters_items_mode' => 'std'), $params); global $DB, $Blog, $blog; if (empty($Blog) && !empty($blog)) { // Set Blog if it still doesn't exist $BlogCache =& get_BlogCache(); $Blog =& $BlogCache->get_by_ID($blog, false); } if (empty($params['chapter_ID']) || empty($Blog)) { // No chapter ID, Exit here return; } if ($params['chapters_items_mode'] == 'order') { // Get all subchapters in this mode to following insertion into posts list below $sub_chapters = manual_get_chapters($params['chapter_ID']); } // Get the posts of current category $ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page')); $ItemList->load_from_Request(); $ItemList->set_filters(array('cat_array' => array($params['chapter_ID']), 'unit' => 'all')); $ItemList->query(); // Split items in two arrays to know what items are from main category and what items are from extra category $items_main = array(); $items_extra = array(); while ($cur_Item = $ItemList->get_item()) { if ($cur_Item->main_cat_ID == $params['chapter_ID']) { // Item is from main category $items_main[] = $cur_Item; } else { // Item is from extra catogry $items_extra[] = $cur_Item; } } // ---- Display Items from MAIN category ---- // $prev_item_order = 0; foreach ($items_main as $cur_Item) { if ($params['chapters_items_mode'] == 'order') { // In this mode we display the chapters inside a posts list foreach ($sub_chapters as $s => $sub_Chapter) { // Loop through categories to find for current order if ($sub_Chapter->get('order') <= $cur_Item->get('order') && $sub_Chapter->get('order') > $prev_item_order || $cur_Item->get('order') == 0 && $sub_Chapter->get('order') >= $cur_Item->get('order')) { // Display chapter manual_display_chapter(array_merge($params, array('Chapter' => $sub_Chapter)), $level); // Remove this chapter from array to avoid the duplicates unset($sub_chapters[$s]); } } // Save current post order for next iteration $prev_item_order = $cur_Item->get('order'); } manual_display_post_row($cur_Item, $level, array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'title_field' => 'urltitle')); } if ($params['chapters_items_mode'] == 'order') { foreach ($sub_chapters as $s => $sub_Chapter) { // Loop through rest categories that have order more than last item manual_display_chapter(array_merge($params, array('Chapter' => $sub_Chapter)), $level); // Remove this chapter from array to avoid the duplicates unset($sub_chapters[$s]); } } // ---- Display Items from EXTRA category ---- // foreach ($items_extra as $cur_Item) { manual_display_post_row($cur_Item, $level, array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'title_field' => 'urltitle', 'title_before' => '<i>', 'title_after' => '</i>')); } }
/** * Display a list of the posts for current chapter * * @param array params * @return string List with posts */ function display_chapter_posts($params = array()) { $params = array_merge(array('chapter_ID' => 0, 'item_start' => '<li>', 'item_end' => '</li>', 'class_selected' => 'selected', 'class_post' => 'post', 'chapters_items_mode' => 'std', 'display_children' => false, 'display_posts' => false), $params); global $DB, $Item, $Blog, $blog; if (empty($Blog) && !empty($blog)) { // Set Blog if it still doesn't exist $BlogCache =& get_BlogCache(); $Blog =& $BlogCache->get_by_ID($blog, false); } if (empty($params['chapter_ID']) || empty($Blog)) { // No chapter ID, Exit here return; } if ($params['chapters_items_mode'] == 'order') { // Get all subchapters in this mode to following insertion into posts list below $sub_chapters = $this->get_chapters($params['chapter_ID']); } // Get the posts of current category $ItemList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), $Blog->get_setting('posts_per_page')); $ItemList->load_from_Request(); $ItemList->set_filters(array('cat_array' => array($params['chapter_ID']), 'unit' => 'all')); $ItemList->query(); $selected_item_ID = !empty($Item) && !empty($Item->ID) ? $Item->ID : 0; // Split items in two arrays to know what items are from main category and what items are from extra category $items_main = array(); $items_extra = array(); while ($cur_Item = $ItemList->get_item()) { if ($cur_Item->main_cat_ID == $params['chapter_ID']) { // Item is from main category $items_main[] = $cur_Item; } else { // Item is from extra catogry $items_extra[] = $cur_Item; } } // ---- Display Items from MAIN category ---- // $prev_item_order = 0; foreach ($items_main as $cur_Item) { if ($params['chapters_items_mode'] == 'order') { // In this mode we display the chapters inside a posts list foreach ($sub_chapters as $s => $sub_Chapter) { // Loop through categories to find for current order if ($sub_Chapter->get('order') <= $cur_Item->get('order') && $sub_Chapter->get('order') > $prev_item_order || $cur_Item->get('order') == 0 && $sub_Chapter->get('order') >= $cur_Item->get('order')) { // Display chapter $this->display_chapter_item(array_merge($params, array('Chapter' => $sub_Chapter))); // Remove this chapter from array to avoid the duplicates unset($sub_chapters[$s]); } } // Save current post order for next iteration $prev_item_order = $cur_Item->get('order'); } $classes = array('post'); if ($selected_item_ID == $cur_Item->ID) { // This post is selected $classes[] = $params['class_selected']; } // Display a post if (empty($classes)) { echo $params['item_start']; } else { // Add attr "class" for item start tag echo str_replace('>', ' class="' . implode(' ', $classes) . '">', $params['item_start']); } // Display a permanent link to post $cur_Item->title(array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'link_class' => 'link')); //echo ' <span class="red">'.( $cur_Item->get('order') > 0 ? $cur_Item->get('order') : 'NULL').'</span>'.$params['item_end']; echo $params['item_end']; } if ($params['chapters_items_mode'] == 'order') { foreach ($sub_chapters as $s => $sub_Chapter) { // Loop through rest categories that have order more than last item $this->display_chapter_item(array_merge($params, array('Chapter' => $sub_Chapter))); // Remove this chapter from array to avoid the duplicates unset($sub_chapters[$s]); } } // ---- Display Items from EXTRA category ---- // foreach ($items_extra as $cur_Item) { $classes = array('post'); if ($selected_item_ID == $cur_Item->ID) { // This post is selected $classes[] = $params['class_selected']; } // Display a post if (empty($classes)) { echo $params['item_start']; } else { // Add attr "class" for item start tag echo str_replace('>', ' class="' . implode(' ', $classes) . '">', $params['item_start']); } // Display a permanent link to post $cur_Item->title(array('post_navigation' => 'same_category', 'nav_target' => $params['chapter_ID'], 'link_type' => 'permalink', 'link_class' => 'link', 'before' => '<i>', 'after' => '</i>')); //echo ' <span class="red">'.( $cur_Item->get('order') > 0 ? $cur_Item->get('order') : 'NULL').'</span>'.$params['item_end']; echo $params['item_end']; } }
/** * If an Intro Post is available, return it. If not, see if a Featured Post is available and return it. * * Note: this will set the global $FeaturedList which may be used to obtain several featured Items. * * @param string Name of $disp where we should display it * @param string Collection IDs: * NULL: depend on blog setting "Collections to aggregate" * empty: current blog only * "*": all blogs * "1,2,3":blog IDs separated by comma * "-": current blog only and exclude the aggregated blogs * @return Item */ function &get_featured_Item($restrict_disp = 'posts', $coll_IDs = NULL) { global $Blog, $cat; global $disp, $disp_detail, $MainList, $FeaturedList; global $featured_displayed_item_IDs; if ($disp != $restrict_disp || !isset($MainList)) { // If we're not currently displaying posts, no need to try & display a featured/intro post on top! $Item = NULL; return $Item; } if (!isset($FeaturedList)) { // Don't repeat if we've done this already -- Initialize the featured list only first time this function is called in a skin: // Get ready to obtain 1 post only: $FeaturedList = new ItemList2($Blog, $Blog->get_timestamp_min(), $Blog->get_timestamp_max(), 1); $featured_list_filters = $MainList->filters; if (!empty($cat)) { // Get a featured post only of the selected category and don't touch the posts of the child categories: $featured_list_filters['cat_array'] = array($cat); } // Set default filters for the current page: $FeaturedList->set_default_filters($featured_list_filters); // FIRST: Try to find an Intro post: if (!$MainList->is_filtered()) { // This is not a filtered page, so we are on the home page. if ($restrict_disp == 'front') { // Special Front page: // Use Intro-Front posts $restrict_to_types = '1400'; } else { // Default front page displaying posts: // The competing intro-* types are: 'main' and 'all': // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first! $restrict_to_types = '1500,1600'; } } else { // We are on a filtered... it means a category page or sth like this... // echo $disp_detail; switch ($disp_detail) { case 'posts-cat': case 'posts-subcat': // The competing intro-* types are: 'cat' and 'all': // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first! $restrict_to_types = '1520,1600'; break; case 'posts-tag': // The competing intro-* types are: 'tag' and 'all': // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first! $restrict_to_types = '1530,1600'; break; default: // The competing intro-* types are: 'sub' and 'all': // fplanque> IMPORTANT> nobody changes this without consulting the manual and talking to me first! $restrict_to_types = '1570,1600'; } } $FeaturedList->set_filters(array('coll_IDs' => $coll_IDs, 'types' => $restrict_to_types), false); // pre_dump( $FeaturedList->filters ); // Run the query: $FeaturedList->query(); // SECOND: If no Intro, try to find an Featured post: if ($FeaturedList->result_num_rows == 0 && $restrict_disp != 'front') { // No Intro page was found, try to find a featured post instead: $FeaturedList->reset(); $FeaturedList->set_filters(array('coll_IDs' => $coll_IDs, 'featured' => 1), false); // Run the query: $FeaturedList->query(); } } // Get first Item in the result set. $Item = $FeaturedList->get_item(); if ($Item) { // Memorize that ID so that it can later be filtered out of normal display: $featured_displayed_item_IDs[] = $Item->ID; } return $Item; }
?> " title="<?php $l_Blog->disp('shortdesc', 'htmlattr'); ?> "><?php $l_Blog->disp('name', 'htmlattr'); ?> </a></h3> <ul> <?php // Get the 3 last posts for each blog: $BlogBList = new ItemList2($l_Blog, $l_Blog->get_timestamp_min(), $l_Blog->get_timestamp_max(), 3); $BlogBList->set_filters(array('order' => 'DESC', 'unit' => 'posts')); // Run the query: $BlogBList->query(); while ($Item =& $BlogBList->get_item()) { ?> <li lang="<?php $Item->lang(); ?> "> <?php $Item->issue_date(array('before' => ' ', 'after' => ' ', 'date_format' => '#')); $Item->title(array('link_type' => 'permalink')); ?> <span class="small">[<?php $Item->lang(); ?> ]</span> </li> <?php
/** * Dispaly posts awaiting moderation with the given status * * @param string visibility status * @param object block_item_Widget * @return boolean true if items were displayed, false otherwise */ function display_posts_awaiting_moderation($status, &$block_item_Widget) { global $Blog, $current_User; // Create empty List: $ItemList = new ItemList2($Blog, NULL, NULL); // Filter list: $ItemList->set_filters(array('visibility_array' => array($status), 'orderby' => 'datemodified', 'order' => 'DESC', 'posts' => 5)); // Get ready for display (runs the query): $ItemList->display_init(); if (!$ItemList->result_num_rows) { // We don't have posts awaiting moderation with the given status return false; } switch ($status) { case 'draft': $block_title = T_('Recent drafts'); break; case 'review': $block_title = T_('Recent posts to review'); break; case 'protected': $block_title = T_('Recent member posts awaiting moderation'); break; case 'community': $block_title = T_('Recent community posts awaiting moderation'); break; default: $block_title = T_('Recent posts awaiting moderation'); break; } $block_item_Widget->title = $block_title; $block_item_Widget->disp_template_replaced('block_start'); while ($Item =& $ItemList->get_item()) { echo '<div class="dashboard_post dashboard_post_' . ($ItemList->current_idx % 2 ? 'even' : 'odd') . '" lang="' . $Item->get('locale') . '">'; // We don't switch locales in the backoffice, since we use the user pref anyway // Load item's creator user: $Item->get_creator_User(); $Item->status(array('before' => '<div class="floatright"><span class="note status_' . $Item->status . '"><span>', 'after' => '</span></span></div>')); echo '<div class="dashboard_float_actions">'; $Item->edit_link(array('before' => ' ', 'after' => ' ', 'class' => 'ActionButton btn')); $Item->publish_link('', '', '#', '#', 'PublishButton'); echo get_icon('pixel'); echo '</div>'; if ($Item->status !== 'draft' || $Item->creator_user_ID == $current_User->ID) { // Display Item permalink icon echo '<span style="float: left; padding-right: 5px; margin-top: 4px">' . $Item->get_permanent_link('#icon#') . '</span>'; } echo '<h3 class="dashboard_post_title">'; $item_title = $Item->dget('title'); if (!strlen($item_title)) { $item_title = '[' . format_to_output(T_('No title')) . ']'; } echo '<a href="?ctrl=items&blog=' . $Blog->ID . '&p=' . $Item->ID . '">' . $item_title . '</a>'; echo ' <span class="dashboard_post_details">'; echo '</span>'; echo '</h3>'; echo '</div>'; } $block_item_Widget->disp_template_raw('block_end'); return true; }