/**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     /**
      * @var ItemList2
      */
     global $MainList;
     global $BlogCache, $Blog;
     global $Item, $Settings;
     $this->init_display($params);
     $blog_ID = intval($this->disp_params['blog_ID']);
     $listBlog = $blog_ID ? $BlogCache->get_by_ID($blog_ID, false) : $Blog;
     if (empty($listBlog)) {
         echo $this->disp_params['block_start'];
         echo $this->disp_params['block_body_start'];
         echo T_('The requested Blog doesn\'t exist any more!');
         echo $this->disp_params['block_body_end'];
         echo $this->disp_params['block_end'];
         return;
     }
     // Define default template params that can be rewritten by skin
     $this->disp_params = array_merge(array('item_first_image_before' => '<div class="item_first_image">', 'item_first_image_after' => '</div>', 'item_first_image_placeholder' => '<div class="item_first_image_placeholder"><a href="$item_permaurl$"></a></div>', 'item_title_before' => '<div class="item_title">', 'item_title_after' => '</div>', 'item_title_single_before' => '', 'item_title_single_after' => '', 'item_excerpt_before' => '<div class="item_excerpt">', 'item_excerpt_after' => '</div>', 'item_content_before' => '<div class="item_content">', 'item_content_after' => '</div>', 'item_images_before' => '<div class="item_images">', 'item_images_after' => '</div>'), $this->disp_params);
     // Create ItemList
     // Note: we pass a widget specific prefix in order to make sure to never interfere with the mainlist
     $limit = intval($this->disp_params['limit']);
     if ($this->disp_params['disp_teaser']) {
         // We want to show some of the post content, we need to load more info: use ItemList2
         $ItemList = new ItemList2($listBlog, $listBlog->get_timestamp_min(), $listBlog->get_timestamp_max(), $limit, 'ItemCache', $this->code . '_');
     } else {
         // no excerpts, use ItemListLight
         load_class('items/model/_itemlistlight.class.php', 'ItemListLight');
         $ItemList = new ItemListLight($listBlog, $listBlog->get_timestamp_min(), $listBlog->get_timestamp_max(), $limit, 'ItemCacheLight', $this->code . '_');
     }
     $cat_array = sanitize_id_list($this->disp_params['cat_IDs'], true);
     // Filter list:
     $filters = array('cat_array' => $cat_array, 'orderby' => $this->disp_params['order_by'], 'order' => $this->disp_params['order_dir'], 'unit' => 'posts', 'coll_IDs' => $this->disp_params['blog_ID']);
     if ($this->disp_params['item_visibility'] == 'public') {
         // Get only the public items
         $filters['visibility_array'] = array('published');
     }
     if (isset($this->disp_params['page'])) {
         $filters['page'] = $this->disp_params['page'];
     }
     if ($this->disp_params['item_type'] != '#') {
         // Not "default", restrict to a specific type (or '' for all)
         $filters['types'] = $this->disp_params['item_type'];
     }
     if ($this->disp_params['follow_mainlist'] == 'tags') {
         // Restrict to Item tagged with some tag used in the Mainlist:
         if (!isset($MainList)) {
             // Nothing to follow, don't display anything
             return false;
         }
         $all_tags = $MainList->get_all_tags();
         if (empty($all_tags)) {
             // Nothing to follow, don't display anything
             return false;
         }
         $filters['tags'] = implode(',', $all_tags);
         if (!empty($Item)) {
             // Exclude current Item
             $filters['post_ID'] = '-' . $Item->ID;
         }
         // fp> TODO: in addition to just filtering, offer ordering in a way where the posts with the most matching tags come first
     }
     $chapter_mode = false;
     if ($this->disp_params['item_group_by'] == 'chapter') {
         // Group by chapter:
         $chapter_mode = true;
         # This is the list of categories to restrict the linkblog to (cats will be displayed recursively)
         # Example: $linkblog_cat = '4,6,7';
         $linkblog_cat = '';
         # This is the array if categories to restrict the linkblog to (non recursive)
         # Example: $linkblog_catsel = array( 4, 6, 7 );
         $linkblog_catsel = array();
         // $cat_array;
         // Compile cat array stuff:
         $linkblog_cat_array = array();
         $linkblog_cat_modifier = '';
         compile_cat_array($linkblog_cat, $linkblog_catsel, $linkblog_cat_array, $linkblog_cat_modifier, $listBlog->ID);
         $filters['cat_array'] = $linkblog_cat_array;
         $filters['cat_modifier'] = $linkblog_cat_modifier;
     }
     $ItemList->set_filters($filters, false);
     // we don't want to memorize these params
     // Run the query:
     $ItemList->query();
     if (!$ItemList->result_num_rows) {
         // Nothing to display:
         return;
     }
     // Check if the widget displays only single title
     $this->disp_params['disp_only_title'] = !($this->disp_params['attached_pics'] != 'none' || $this->disp_params['disp_excerpt'] || $this->disp_params['disp_teaser']);
     // Start to capture display content here in order to solve the issue to don't display empty widget
     ob_start();
     // This variable used to display widget. Will be set to true when content is displayed
     $content_is_displayed = false;
     // Get extra classes depending on widget settings:
     $block_css_class = $this->get_widget_extra_class();
     if (empty($block_css_class)) {
         // No extra class, Display default wrapper:
         echo $this->disp_params['block_start'];
     } else {
         // Append extra classes for widget block:
         echo preg_replace('/ class="([^"]+)"/', ' class="$1' . $block_css_class . '"', $this->disp_params['block_start']);
     }
     $title = sprintf($this->disp_params['title_link'] ? '<a href="' . $listBlog->gen_blogurl() . '" rel="nofollow">%s</a>' : '%s', $this->disp_params['title']);
     $this->disp_title($title);
     echo $this->disp_params['block_body_start'];
     if ($chapter_mode) {
         // List grouped by chapter/category:
         $items_map_by_chapter = array();
         $chapters_of_loaded_items = array();
         $group_by_blogs = false;
         $prev_chapter_blog_ID = NULL;
         while ($iterator_Item =& $ItemList->get_item()) {
             // Display contents of the Item depending on widget params:
             $Chapter =& $iterator_Item->get_main_Chapter();
             if (!isset($items_map_by_chapter[$Chapter->ID])) {
                 $items_map_by_chapter[$Chapter->ID] = array();
                 $chapters_of_loaded_items[] = $Chapter;
             }
             $items_map_by_chapter[$Chapter->ID][] = $iterator_Item;
             // Group by blogs if there are chapters from multiple blogs
             if (!$group_by_blogs && $Chapter->blog_ID != $prev_chapter_blog_ID) {
                 // group by blogs is not decided yet
                 $group_by_blogs = $prev_chapter_blog_ID != NULL;
                 $prev_chapter_blog_ID = $Chapter->blog_ID;
             }
         }
         usort($chapters_of_loaded_items, 'Chapter::compare_chapters');
         $displayed_blog_ID = NULL;
         if ($group_by_blogs && isset($this->disp_params['collist_start'])) {
             // Start list of blogs
             echo $this->disp_params['collist_start'];
         } else {
             // Display list start, all chapters are in the same group ( not grouped by blogs )
             echo $this->disp_params['list_start'];
         }
         foreach ($chapters_of_loaded_items as $Chapter) {
             if ($group_by_blogs && $displayed_blog_ID != $Chapter->blog_ID) {
                 $Chapter->get_Blog();
                 if ($displayed_blog_ID != NULL) {
                     // Display the end of the previous blog's chapter list
                     echo $this->disp_params['list_end'];
                 }
                 echo $this->disp_params['coll_start'] . $Chapter->Blog->get('shortname') . $this->disp_params['coll_end'];
                 // Display start of blog's chapter list
                 echo $this->disp_params['list_start'];
                 $displayed_blog_ID = $Chapter->blog_ID;
             }
             $content_is_displayed = $this->disp_chapter($Chapter, $items_map_by_chapter) || $content_is_displayed;
         }
         if ($content_is_displayed) {
             // End of a chapter list - if some content was displayed this is always required
             echo $this->disp_params['list_end'];
         }
         if ($group_by_blogs && isset($this->disp_params['collist_end'])) {
             // End of blog list
             echo $this->disp_params['collist_end'];
         }
     } else {
         // Plain list:
         echo $this->disp_params['list_start'];
         /**
          * @var ItemLight (or Item)
          */
         while ($Item =& $ItemList->get_item()) {
             // Display contents of the Item depending on widget params:
             $content_is_displayed = $this->disp_contents($Item) || $content_is_displayed;
         }
         if (isset($this->disp_params['page'])) {
             if (empty($this->disp_params['pagination'])) {
                 $this->disp_params['pagination'] = array();
             }
             $ItemList->page_links($this->disp_params['pagination']);
         }
         echo $this->disp_params['list_end'];
     }
     echo $this->disp_params['block_body_end'];
     echo $this->disp_params['block_end'];
     if ($content_is_displayed) {
         // Some content is displayed, Print out widget
         ob_end_flush();
     } else {
         // No content, Don't display widget
         ob_end_clean();
     }
 }
Example #2
0
    /**
     * Load data from Request form fields.
     *
     * @param array groups of params to load
     * @return boolean true if loaded data seems valid.
     */
    function load_from_Request($groups = array())
    {
        global $Messages, $default_locale, $DB;
        /**
         * @var User
         */
        global $current_User;
        // Load collection settings and clear update cascade array
        $this->load_CollectionSettings();
        $this->CollectionSettings->clear_update_cascade();
        if (param('blog_name', 'string', NULL) !== NULL) {
            // General params:
            $this->set_from_Request('name');
            $this->set('shortname', param('blog_shortname', 'string', true));
            $this->set('locale', param('blog_locale', 'string', $default_locale));
        }
        if (param('archive_links', 'string', NULL) !== NULL) {
            // Archive link type:
            $this->set_setting('archive_links', get_param('archive_links'));
            $this->set_setting('archive_posts_per_page', param('archive_posts_per_page', 'integer', NULL), true);
        }
        if (param('chapter_links', 'string', NULL) !== NULL) {
            // Chapter link type:
            $this->set_setting('chapter_links', get_param('chapter_links'));
        }
        if (param('category_prefix', 'string', NULL) !== NULL) {
            $category_prefix = get_param('category_prefix');
            if (!preg_match('|^([A-Za-z0-9\\-_]+(/[A-Za-z0-9\\-_]+)*)?$|', $category_prefix)) {
                param_error('category_prefix', T_('Invalid category prefix.'));
            }
            $this->set_setting('category_prefix', $category_prefix);
        }
        if (param('atom_redirect', 'string', NULL) !== NULL) {
            param_check_url('atom_redirect', 'commenting');
            $this->set_setting('atom_redirect', get_param('atom_redirect'));
            param('rss2_redirect', 'string', NULL);
            param_check_url('rss2_redirect', 'commenting');
            $this->set_setting('rss2_redirect', get_param('rss2_redirect'));
        }
        if (param('image_size', 'string', NULL) !== NULL) {
            $this->set_setting('image_size', get_param('image_size'));
        }
        if (param('tag_links', 'string', NULL) !== NULL) {
            // Tag page link type:
            $this->set_setting('tag_links', get_param('tag_links'));
        }
        if (param('tag_prefix', 'string', NULL) !== NULL) {
            $tag_prefix = get_param('tag_prefix');
            if (!preg_match('|^([A-Za-z0-9\\-_]+(/[A-Za-z0-9\\-_]+)*)?$|', $tag_prefix)) {
                param_error('tag_prefix', T_('Invalid tag prefix.'));
            }
            $this->set_setting('tag_prefix', $tag_prefix);
        }
        // Default to "tag", if "prefix-only" is used, but no tag_prefix was provided.
        if (get_param('tag_links') == 'prefix-only' && !strlen(param('tag_prefix', 'string', NULL))) {
            $this->set_setting('tag_prefix', 'tag');
        }
        // Use rel="tag" attribute? (checkbox)
        $this->set_setting('tag_rel_attib', param('tag_rel_attib', 'integer', 0));
        if (param('chapter_content', 'string', NULL) !== NULL) {
            // What kind of content on chapter pages?
            $this->set_setting('chapter_content', get_param('chapter_content'));
        }
        if (param('tag_content', 'string', NULL) !== NULL) {
            // What kind of content on tags pages?
            $this->set_setting('tag_content', get_param('tag_content'));
        }
        if (param('archive_content', 'string', NULL) !== NULL) {
            // What kind of content on archive pages?
            $this->set_setting('archive_content', get_param('archive_content'));
        }
        if (param('filtered_content', 'string', NULL) !== NULL) {
            // What kind of content on filtered pages?
            $this->set_setting('filtered_content', get_param('filtered_content'));
        }
        if (param('main_content', 'string', NULL) !== NULL) {
            // What kind of content on main pages?
            $this->set_setting('main_content', get_param('main_content'));
        }
        // Chapter posts per page:
        $this->set_setting('chapter_posts_per_page', param('chapter_posts_per_page', 'integer', NULL), true);
        // Tag posts per page:
        $this->set_setting('tag_posts_per_page', param('tag_posts_per_page', 'integer', NULL), true);
        if (param('single_links', 'string', NULL) !== NULL) {
            // Single post link type:
            $this->set_setting('single_links', get_param('single_links'));
        }
        if (param('slug_limit', 'integer', NULL) !== NULL) {
            // Limit slug length:
            $this->set_setting('slug_limit', get_param('slug_limit'));
        }
        if (param('normal_skin_ID', 'integer', NULL) !== NULL) {
            // Default blog:
            $this->set_setting('normal_skin_ID', get_param('normal_skin_ID'));
        }
        if (param('mobile_skin_ID', 'integer', NULL) !== NULL) {
            // Default blog:
            $this->set_setting('mobile_skin_ID', get_param('mobile_skin_ID'));
        }
        if (param('tablet_skin_ID', 'integer', NULL) !== NULL) {
            // Default blog:
            $this->set_setting('tablet_skin_ID', get_param('tablet_skin_ID'));
        }
        if (param('archives_sort_order', 'string', NULL) !== NULL) {
            $this->set_setting('archives_sort_order', param('archives_sort_order', 'string', false));
        }
        if (param('feed_content', 'string', NULL) !== NULL) {
            // How much content in feeds?
            $this->set_setting('feed_content', get_param('feed_content'));
            param_integer_range('posts_per_feed', 1, 9999, T_('Items per feed must be between %d and %d.'));
            $this->set_setting('posts_per_feed', get_param('posts_per_feed'));
        }
        if (param('comment_feed_content', 'string', NULL) !== NULL) {
            // How much content in comment feeds?
            $this->set_setting('comment_feed_content', get_param('comment_feed_content'));
            param_integer_range('comments_per_feed', 1, 9999, T_('Comments per feed must be between %d and %d.'));
            $this->set_setting('comments_per_feed', get_param('comments_per_feed'));
        }
        if (param('require_title', 'string', NULL) !== NULL) {
            // Title for items required?
            $this->set_setting('require_title', get_param('require_title'));
        }
        if (param('blog_description', 'string', NULL) !== NULL) {
            // Description:
            $this->set_from_Request('shortdesc', 'blog_description');
        }
        if (param('blog_keywords', 'string', NULL) !== NULL) {
            // Keywords:
            $this->set_from_Request('keywords');
        }
        if (param('blog_tagline', 'html', NULL) !== NULL) {
            // HTML tagline:
            param_check_html('blog_tagline', T_('Invalid tagline'));
            $this->set('tagline', get_param('blog_tagline'));
        }
        if (param('blog_longdesc', 'html', NULL) !== NULL) {
            // HTML long description:
            param_check_html('blog_longdesc', T_('Invalid long description'));
            $this->set('longdesc', get_param('blog_longdesc'));
        }
        if (param('blog_footer_text', 'html', NULL) !== NULL) {
            // Blog footer:
            param_check_html('blog_footer_text', T_('Invalid blog footer'));
            $this->set_setting('blog_footer_text', get_param('blog_footer_text'));
        }
        if (param('single_item_footer_text', 'html', NULL) !== NULL) {
            // Blog footer:
            param_check_html('single_item_footer_text', T_('Invalid single post footer'));
            $this->set_setting('single_item_footer_text', get_param('single_item_footer_text'));
        }
        if (param('xml_item_footer_text', 'html', NULL) !== NULL) {
            // Blog footer:
            param_check_html('xml_item_footer_text', T_('Invalid RSS footer'));
            $this->set_setting('xml_item_footer_text', get_param('xml_item_footer_text'));
        }
        if (param('blog_notes', 'html', NULL) !== NULL) {
            // HTML notes:
            param_check_html('blog_notes', T_('Invalid Blog Notes'));
            $this->set('notes', get_param('blog_notes'));
            param_integer_range('max_footer_credits', 0, 3, T_('Max credits must be between %d and %d.'));
            $this->set_setting('max_footer_credits', get_param('max_footer_credits'));
        }
        if (in_array('pings', $groups)) {
            // we want to load the ping checkboxes:
            $blog_ping_plugins = param('blog_ping_plugins', 'array/string', array());
            $blog_ping_plugins = array_unique($blog_ping_plugins);
            $this->set_setting('ping_plugins', implode(',', $blog_ping_plugins));
        }
        if (in_array('authors', $groups)) {
            // we want to load the multiple authors params
            $this->set('advanced_perms', param('advanced_perms', 'integer', 0));
            $this->set_setting('use_workflow', param('blog_use_workflow', 'integer', 0));
        }
        if (in_array('features', $groups)) {
            // we want to load the workflow checkboxes:
            $this->set_setting('allow_html_post', param('allow_html_post', 'integer', 0));
            $this->set_setting('enable_goto_blog', param('enable_goto_blog', 'string', NULL));
            $this->set_setting('editing_goto_blog', param('editing_goto_blog', 'string', NULL));
            $this->set_setting('default_post_status', param('default_post_status', 'string', NULL));
            $this->set_setting('post_categories', param('post_categories', 'string', NULL));
            $this->set_setting('post_navigation', param('post_navigation', 'string', NULL));
            // Show x days or x posts?:
            $this->set_setting('what_to_show', param('what_to_show', 'string', ''));
            param_integer_range('posts_per_page', 1, 9999, T_('Items/days per page must be between %d and %d.'));
            $this->set_setting('posts_per_page', get_param('posts_per_page'));
            $this->set_setting('orderby', param('orderby', 'string', true));
            $this->set_setting('orderdir', param('orderdir', 'string', true));
            // Time frame
            $this->set_setting('timestamp_min', param('timestamp_min', 'string', ''));
            $this->set_setting('timestamp_min_duration', param_duration('timestamp_min_duration'));
            $this->set_setting('timestamp_max', param('timestamp_max', 'string', ''));
            $this->set_setting('timestamp_max_duration', param_duration('timestamp_max_duration'));
            // Location
            $location_country = param('location_country', 'string', 'hidden');
            $location_region = param('location_region', 'string', 'hidden');
            $location_subregion = param('location_subregion', 'string', 'hidden');
            $location_city = param('location_city', 'string', 'hidden');
            if ($location_city == 'required') {
                // If city is required - all location fields also are required
                $location_country = $location_region = $location_subregion = 'required';
            } else {
                if ($location_subregion == 'required') {
                    // If subregion is required - country & region fields also are required
                    $location_country = $location_region = 'required';
                } else {
                    if ($location_region == 'required') {
                        // If region is required - country field also is required
                        $location_country = 'required';
                    }
                }
            }
            $this->set_setting('location_country', $location_country);
            $this->set_setting('location_region', $location_region);
            $this->set_setting('location_subregion', $location_subregion);
            $this->set_setting('location_city', $location_city);
            // Set to show Latitude & Longitude params for this blog items
            $this->set_setting('show_location_coordinates', param('show_location_coordinates', 'integer', 0));
            // Load custom double & varchar fields
            $custom_field_names = array();
            $this->load_custom_fields('double', $update_cascade_query, $custom_field_names);
            $this->load_custom_fields('varchar', $update_cascade_query, $custom_field_names);
            if (!empty($update_cascade_query)) {
                // Some custom fields were deleted and these fields must be deleted from the item settings table also. Add required query.
                $this->CollectionSettings->add_update_cascade($update_cascade_query);
            }
            // call modules update_collection_features on this blog
            modules_call_method('update_collection_features', array('edited_Blog' => &$this));
        }
        if (in_array('comments', $groups)) {
            // we want to load the workflow checkboxes:
            // load moderation statuses
            $moderation_statuses = get_visibility_statuses('moderation');
            $blog_moderation_statuses = array();
            foreach ($moderation_statuses as $status) {
                if (param('notif_' . $status, 'integer', 0)) {
                    $blog_moderation_statuses[] = $status;
                }
            }
            $this->set_setting('moderation_statuses', implode(',', $blog_moderation_statuses));
            $this->set_setting('comment_quick_moderation', param('comment_quick_moderation', 'string', 'expire'));
            $this->set_setting('allow_item_subscriptions', param('allow_item_subscriptions', 'integer', 0));
            $this->set_setting('comments_detect_email', param('comments_detect_email', 'integer', 0));
            $this->set_setting('comments_register', param('comments_register', 'integer', 0));
        }
        if (in_array('other', $groups)) {
            // we want to load the workflow checkboxes:
            $this->set_setting('enable_sitemaps', param('enable_sitemaps', 'integer', 0));
            $this->set_setting('allow_subscriptions', param('allow_subscriptions', 'integer', 0));
            $this->set_setting('allow_item_subscriptions', param('allow_item_subscriptions', 'integer', 0));
            // Public blog list
            $this->set('in_bloglist', param('blog_in_bloglist', 'integer', 0));
            $this->set_setting('image_size_user_list', param('image_size_user_list', 'string'));
            $this->set_setting('image_size_messaging', param('image_size_messaging', 'string'));
            $this->set_setting('archive_mode', param('archive_mode', 'string', true));
        }
        if (param('allow_comments', 'string', NULL) !== NULL) {
            // Feedback options:
            $this->set_setting('allow_comments', param('allow_comments', 'string', 'any'));
            $this->set_setting('allow_view_comments', param('allow_view_comments', 'string', 'any'));
            $new_feedback_status = param('new_feedback_status', 'string', 'draft');
            if ($new_feedback_status != $this->get_setting('new_feedback_status') && ($new_feedback_status != 'published' || $current_User->check_perm('blog_admin', 'edit', false, $this->ID))) {
                // Only admin can set this setting to 'Public'
                $this->set_setting('new_feedback_status', $new_feedback_status);
            }
            $this->set_setting('disable_comments_bypost', param('disable_comments_bypost', 'string', '0'));
            $this->set_setting('allow_anon_url', param('allow_anon_url', 'string', '0'));
            $this->set_setting('allow_html_comment', param('allow_html_comment', 'string', '0'));
            $this->set_setting('allow_attachments', param('allow_attachments', 'string', 'registered'));
            $this->set_setting('max_attachments', param('max_attachments', 'integer', ''));
            $this->set_setting('allow_rating_items', param('allow_rating_items', 'string', 'never'));
            $this->set_setting('rating_question', param('rating_question', 'text'));
            $this->set_setting('allow_rating_comment_helpfulness', param('allow_rating_comment_helpfulness', 'string', '0'));
            $blog_allowtrackbacks = param('blog_allowtrackbacks', 'integer', 0);
            if ($blog_allowtrackbacks != $this->get('allowtrackbacks') && ($blog_allowtrackbacks == 0 || $current_User->check_perm('blog_admin', 'edit', false, $this->ID))) {
                // Only admin can turn ON this setting
                $this->set('allowtrackbacks', $blog_allowtrackbacks);
            }
            $this->set_setting('comments_orderdir', param('comments_orderdir', '/^(?:ASC|DESC)$/', 'ASC'));
            // call modules update_collection_comments on this blog
            modules_call_method('update_collection_comments', array('edited_Blog' => &$this));
            $threaded_comments = param('threaded_comments', 'integer', 0);
            $this->set_setting('threaded_comments', $threaded_comments);
            $this->set_setting('paged_comments', $threaded_comments ? 0 : param('paged_comments', 'integer', 0));
            param_integer_range('comments_per_page', 1, 9999, T_('Comments per page must be between %d and %d.'));
            $this->set_setting('comments_per_page', get_param('comments_per_page'));
            $this->set_setting('comments_avatars', param('comments_avatars', 'integer', 0));
            $this->set_setting('comments_latest', param('comments_latest', 'integer', 0));
        }
        if (in_array('seo', $groups)) {
            // we want to load the workflow checkboxes:
            $this->set_setting('canonical_homepage', param('canonical_homepage', 'integer', 0));
            $this->set_setting('relcanonical_homepage', param('relcanonical_homepage', 'integer', 0));
            $this->set_setting('canonical_item_urls', param('canonical_item_urls', 'integer', 0));
            $this->set_setting('relcanonical_item_urls', param('relcanonical_item_urls', 'integer', 0));
            $this->set_setting('canonical_archive_urls', param('canonical_archive_urls', 'integer', 0));
            $this->set_setting('relcanonical_archive_urls', param('relcanonical_archive_urls', 'integer', 0));
            $this->set_setting('canonical_cat_urls', param('canonical_cat_urls', 'integer', 0));
            $this->set_setting('relcanonical_cat_urls', param('relcanonical_cat_urls', 'integer', 0));
            $this->set_setting('canonical_tag_urls', param('canonical_tag_urls', 'integer', 0));
            $this->set_setting('relcanonical_tag_urls', param('relcanonical_tag_urls', 'integer', 0));
            $this->set_setting('default_noindex', param('default_noindex', 'integer', 0));
            $this->set_setting('paged_noindex', param('paged_noindex', 'integer', 0));
            $this->set_setting('paged_nofollowto', param('paged_nofollowto', 'integer', 0));
            $this->set_setting('archive_noindex', param('archive_noindex', 'integer', 0));
            $this->set_setting('archive_nofollowto', param('archive_nofollowto', 'integer', 0));
            $this->set_setting('chapter_noindex', param('chapter_noindex', 'integer', 0));
            $this->set_setting('tag_noindex', param('tag_noindex', 'integer', 0));
            $this->set_setting('filtered_noindex', param('filtered_noindex', 'integer', 0));
            $this->set_setting('arcdir_noindex', param('arcdir_noindex', 'integer', 0));
            $this->set_setting('catdir_noindex', param('catdir_noindex', 'integer', 0));
            $this->set_setting('feedback-popup_noindex', param('feedback-popup_noindex', 'integer', 0));
            $this->set_setting('msgform_noindex', param('msgform_noindex', 'integer', 0));
            $this->set_setting('special_noindex', param('special_noindex', 'integer', 0));
            $this->set_setting('title_link_type', param('title_link_type', 'string', ''));
            $this->set_setting('permalinks', param('permalinks', 'string', ''));
            $this->set_setting('404_response', param('404_response', 'string', ''));
            $this->set_setting('help_link', param('help_link', 'string', ''));
            $this->set_setting('excerpts_meta_description', param('excerpts_meta_description', 'integer', 0));
            $this->set_setting('categories_meta_description', param('categories_meta_description', 'integer', 0));
            $this->set_setting('tags_meta_keywords', param('tags_meta_keywords', 'integer', 0));
        }
        /*
         * ADVANCED ADMIN SETTINGS
         */
        if ($current_User->check_perm('blog_admin', 'edit', false, $this->ID)) {
            // We have permission to edit advanced admin settings:
            if (in_array('cache', $groups)) {
                // we want to load the cache params:
                $this->set_setting('ajax_form_enabled', param('ajax_form_enabled', 'integer', 0));
                $this->set_setting('ajax_form_loggedin_enabled', param('ajax_form_loggedin_enabled', 'integer', 0));
                $this->set_setting('cache_enabled_widgets', param('cache_enabled_widgets', 'integer', 0));
            }
            if (in_array('styles', $groups)) {
                // we want to load the styles params:
                $this->set('allowblogcss', param('blog_allowblogcss', 'integer', 0));
                $this->set('allowusercss', param('blog_allowusercss', 'integer', 0));
            }
            if (in_array('login', $groups)) {
                // we want to load the login params:
                $this->set_setting('in_skin_login', param('in_skin_login', 'integer', 0));
                $this->set_setting('in_skin_editing', param('in_skin_editing', 'integer', 0));
            }
            if (param('blog_head_includes', 'html', NULL) !== NULL) {
                // HTML header includes:
                param_check_html('blog_head_includes', T_('Invalid Custom meta section'));
                $this->set_setting('head_includes', get_param('blog_head_includes'));
            }
            if (param('blog_footer_includes', 'html', NULL) !== NULL) {
                // HTML header includes:
                param_check_html('blog_footer_includes', T_('Invalid Custom javascript section'));
                $this->set_setting('footer_includes', get_param('blog_footer_includes'));
            }
            if (param('owner_login', 'string', NULL) !== NULL) {
                // Permissions:
                $UserCache =& get_UserCache();
                $owner_User =& $UserCache->get_by_login(get_param('owner_login'));
                if (empty($owner_User)) {
                    param_error('owner_login', sprintf(T_('User &laquo;%s&raquo; does not exist!'), get_param('owner_login')));
                } else {
                    $this->set('owner_user_ID', $owner_User->ID);
                    $this->owner_User =& $owner_User;
                }
            }
            if (($blog_urlname = param('blog_urlname', 'string', NULL)) !== NULL) {
                // check urlname
                if (param_check_not_empty('blog_urlname', T_('You must provide an URL blog name!'))) {
                    if (!preg_match('|^[A-Za-z0-9\\-]+$|', $blog_urlname)) {
                        param_error('blog_urlname', sprintf(T_('The url name %s is invalid.'), "&laquo;{$blog_urlname}&raquo;"));
                        $blog_urlname = NULL;
                    }
                    if (isset($blog_urlname) && $DB->get_var('SELECT COUNT(*)
															FROM T_blogs
															WHERE blog_urlname = ' . $DB->quote($blog_urlname) . '
															AND blog_ID <> ' . $this->ID)) {
                        // urlname is already in use
                        param_error('blog_urlname', sprintf(T_('The URL name %s is already in use by another blog. Please choose another name.'), "&laquo;{$blog_urlname}&raquo;"));
                        $blog_urlname = NULL;
                    }
                    if (isset($blog_urlname)) {
                        $this->set_from_Request('urlname');
                    }
                }
            }
            if (($access_type = param('blog_access_type', 'string', NULL)) !== NULL) {
                // Blog URL parameters:
                $this->set('access_type', $access_type);
                if ($access_type == 'absolute') {
                    $blog_siteurl = param('blog_siteurl_absolute', 'string', true);
                    if (preg_match('#^https?://[^/]+/.*#', $blog_siteurl, $matches)) {
                        // It looks like valid absolute URL, so we may update the blog siteurl
                        $this->set('siteurl', $blog_siteurl);
                    } else {
                        // It is not valid absolute URL, don't update the blog 'siteurl' to avoid errors
                        $Messages->add(T_('Blog Folder URL') . ': ' . sprintf(T_('%s is an invalid absolute URL'), '&laquo;' . htmlspecialchars($blog_siteurl) . '&raquo;') . ' ' . T_('You must provide an absolute URL (starting with <code>http://</code> or <code>https://</code>) and it must contain at least one \'/\' sign after the domain name!'), 'error');
                    }
                } elseif ($access_type == 'relative') {
                    // relative siteurl
                    $blog_siteurl = param('blog_siteurl_relative', 'string', true);
                    if (preg_match('#^https?://#', $blog_siteurl)) {
                        $Messages->add(T_('Blog Folder URL') . ': ' . T_('You must provide a relative URL (without <code>http://</code> or <code>https://</code>)!'), 'error');
                    }
                    $this->set('siteurl', $blog_siteurl);
                } else {
                    $this->set('siteurl', '');
                }
            }
            if (param('aggregate_coll_IDs', 'string', NULL) !== NULL) {
                // Aggregate list: (can be '*')
                $aggregate_coll_IDs = get_param('aggregate_coll_IDs');
                if ($aggregate_coll_IDs != '*') {
                    // Sanitize the string
                    $aggregate_coll_IDs = sanitize_id_list($aggregate_coll_IDs);
                }
                // fp> TODO: check perms on each aggregated blog (if changed)
                // fp> TODO: better interface
                if ($aggregate_coll_IDs != '*' && !preg_match('#^([0-9]+(,[0-9]+)*)?$#', $aggregate_coll_IDs)) {
                    param_error('aggregate_coll_IDs', T_('Invalid aggregate blog ID list!'));
                }
                $this->set_setting('aggregate_coll_IDs', $aggregate_coll_IDs);
            }
            if (param('blog_media_location', 'string', NULL) !== NULL) {
                // Media files location:
                $this->set_from_Request('media_location');
                $this->set_media_subdir(param('blog_media_subdir', 'string', ''));
                $this->set_media_fullpath(param('blog_media_fullpath', 'string', ''));
                $this->set_media_url(param('blog_media_url', 'string', ''));
                // check params
                switch ($this->get('media_location')) {
                    case 'custom':
                        // custom path and URL
                        global $demo_mode, $media_path;
                        if ($this->get('media_fullpath') == '') {
                            param_error('blog_media_fullpath', T_('Media dir location') . ': ' . T_('You must provide the full path of the media directory.'));
                        }
                        if (!preg_match('#^https?://#', $this->get('media_url'))) {
                            param_error('blog_media_url', T_('Media dir location') . ': ' . T_('You must provide an absolute URL (starting with <code>http://</code> or <code>https://</code>)!'));
                        }
                        if ($demo_mode) {
                            $canonical_fullpath = get_canonical_path($this->get('media_fullpath'));
                            if (!$canonical_fullpath || strpos($canonical_fullpath, $media_path) !== 0) {
                                param_error('blog_media_fullpath', T_('Media dir location') . ': in demo mode the path must be inside of $media_path.');
                            }
                        }
                        break;
                    case 'subdir':
                        global $media_path;
                        if ($this->get('media_subdir') == '') {
                            param_error('blog_media_subdir', T_('Media dir location') . ': ' . T_('You must provide the media subdirectory.'));
                        } else {
                            // Test if it's below $media_path (subdir!)
                            $canonical_path = get_canonical_path($media_path . $this->get('media_subdir'));
                            if (!$canonical_path || strpos($canonical_path, $media_path) !== 0) {
                                param_error('blog_media_subdir', T_('Media dir location') . ': ' . sprintf(T_('Invalid subdirectory &laquo;%s&raquo;.'), format_to_output($this->get('media_subdir'))));
                            } else {
                                // Validate if it's a valid directory name:
                                $subdir = no_trailing_slash(substr($canonical_path, strlen($media_path)));
                                if ($error = validate_dirname($subdir)) {
                                    param_error('blog_media_subdir', T_('Media dir location') . ': ' . $error);
                                }
                            }
                        }
                        break;
                }
            }
        }
        return !param_errors_detected();
    }
Example #3
0
 /**
  * Event handler: SkinTag (widget)
  *
  * @param array Associative array of parameters. Valid keys are:
  *      - 'block_start' : (Default: '<div class="bSideItem">')
  *      - 'block_end' : (Default: '</div>')
  *      - 'title' : (Default: T_('Calendar'))
  *      - 'displaycaption'
  *      - 'monthformat'
  *      - 'linktomontharchive'
  *      - 'tablestart'
  *      - 'tableend'
  *      - 'monthstart'
  *      - 'monthend'
  *      - 'rowstart'
  *      - 'rowend'
  *      - 'headerdisplay'
  *      - 'headerrowstart'
  *      - 'headerrowend'
  *      - 'headercellstart'
  *      - 'headercellend'
  *      - 'cellstart'
  *      - 'cellend'
  *      - 'linkpostcellstart'
  *      - 'linkposttodaycellstart'
  *      - 'todaycellstart'
  *      - 'todaycellstartpost'
  *      - 'navigation' : Where do we want to have the navigation arrows? (Default: 'tfoot')
  *      - 'browseyears' : boolean  Do we want arrows to move one year at a time?
  *      - 'min_timestamp' : Minimum unix timestamp the user can browse too or 'query' (Default: 2000-01-01)
  *      - 'max_timestamp' : Maximum unix timestamp the user can browse too or 'query' (Default: now + 1 year )
  *      - 'postcount_month_atitle'
  *      - 'postcount_month_atitle_one'
  *      - 'postcount_year_atitle'
  *      - 'postcount_year_atitle_one'
  *      - 'link_type' : 'canonic'|'context' (default: canonic)
  * @return boolean did we display?
  */
 function SkinTag($params)
 {
     // Prefix of the ItemList object
     $itemlist_prefix = isset($params['itemlist_prefix']) ? $params['itemlist_prefix'] : '';
     global $month;
     global $Blog, $cat_array, $cat_modifier;
     global $show_statuses;
     global $author, $assgn, $status, $types;
     global ${$itemlist_prefix . 'm'}, $w, $dstart;
     global $s, $sentence, $exact;
     global $posttypes_specialtypes;
     /**
      * Default params:
      */
     $params = array_merge(array('block_start' => '<div class="bSideItem">', 'block_end' => "</div>\n", 'block_title_start' => '<h3>', 'block_title_end' => '</h3>', 'block_body_start' => '', 'block_body_end' => ''), $params);
     $Calendar = new Calendar(${$itemlist_prefix . 'm'}, $params);
     // TODO: automate with a table inside of Calendatr object. Table should also contain descriptions and default values to display in help screen.
     // Note: minbrowse and maxbrowe already work this way.
     if (isset($params['displaycaption'])) {
         $Calendar->set('displaycaption', $params['displaycaption']);
     }
     if (isset($params['monthformat'])) {
         $Calendar->set('monthformat', $params['monthformat']);
     }
     if (isset($params['linktomontharchive'])) {
         $Calendar->set('linktomontharchive', $params['linktomontharchive']);
     }
     if (isset($params['tablestart'])) {
         $Calendar->set('tablestart', $params['tablestart']);
     }
     if (isset($params['tableend'])) {
         $Calendar->set('tableend', $params['tableend']);
     }
     if (isset($params['monthstart'])) {
         $Calendar->set('monthstart', $params['monthstart']);
     }
     if (isset($params['monthend'])) {
         $Calendar->set('monthend', $params['monthend']);
     }
     if (isset($params['rowstart'])) {
         $Calendar->set('rowstart', $params['rowstart']);
     }
     if (isset($params['rowend'])) {
         $Calendar->set('rowend', $params['rowend']);
     }
     if (isset($params['headerdisplay'])) {
         $Calendar->set('headerdisplay', $params['headerdisplay']);
     }
     if (isset($params['headerrowstart'])) {
         $Calendar->set('headerrowstart', $params['headerrowstart']);
     }
     if (isset($params['headerrowend'])) {
         $Calendar->set('headerrowend', $params['headerrowend']);
     }
     if (isset($params['headercellstart'])) {
         $Calendar->set('headercellstart', $params['headercellstart']);
     }
     if (isset($params['headercellend'])) {
         $Calendar->set('headercellend', $params['headercellend']);
     }
     if (isset($params['cellstart'])) {
         $Calendar->set('cellstart', $params['cellstart']);
     }
     if (isset($params['cellend'])) {
         $Calendar->set('cellend', $params['cellend']);
     }
     if (isset($params['emptycellstart'])) {
         $Calendar->set('emptycellstart', $params['emptycellstart']);
     }
     if (isset($params['emptycellend'])) {
         $Calendar->set('emptycellend', $params['emptycellend']);
     }
     if (isset($params['emptycellcontent'])) {
         $Calendar->set('emptycellcontent', $params['emptycellcontent']);
     }
     if (isset($params['linkpostcellstart'])) {
         $Calendar->set('linkpostcellstart', $params['linkpostcellstart']);
     }
     if (isset($params['linkposttodaycellstart'])) {
         $Calendar->set('linkposttodaycellstart', $params['linkposttodaycellstart']);
     }
     if (isset($params['todaycellstart'])) {
         $Calendar->set('todaycellstart', $params['todaycellstart']);
     }
     if (isset($params['todaycellstartpost'])) {
         $Calendar->set('todaycellstartpost', $params['todaycellstartpost']);
     }
     if (isset($params['navigation'])) {
         $Calendar->set('navigation', $params['navigation']);
     }
     if (isset($params['browseyears'])) {
         $Calendar->set('browseyears', $params['browseyears']);
     }
     if (isset($params['postcount_month_atitle'])) {
         $Calendar->set('postcount_month_atitle', $params['postcount_month_atitle']);
     }
     if (isset($params['postcount_month_atitle_one'])) {
         $Calendar->set('postcount_month_atitle_one', $params['postcount_month_atitle_one']);
     }
     if (isset($params['postcount_year_atitle'])) {
         $Calendar->set('postcount_year_atitle', $params['postcount_year_atitle']);
     }
     if (isset($params['postcount_year_atitle_one'])) {
         $Calendar->set('postcount_year_atitle_one', $params['postcount_year_atitle_one']);
     }
     // Link type:
     if (isset($params['link_type'])) {
         $Calendar->set('link_type', $params['link_type']);
     }
     if (isset($params['context_isolation'])) {
         $Calendar->set('context_isolation', $params['context_isolation']);
     }
     echo $params['block_start'];
     if (!empty($params['title'])) {
         // We want to display a title for the widget block:
         echo $params['block_title_start'];
         if ($params['title_link']) {
             // Set block title as link to current collection:
             echo '<a href="' . $Blog->gen_blogurl() . '" rel="nofollow">' . $params['title'] . '</a>';
         } else {
             // Display a block title as simple text:
             echo $params['title'];
         }
         echo $params['block_title_end'];
     }
     echo $params['block_body_start'];
     // CONSTRUCT THE WHERE CLAUSE:
     // - - Select a specific Item:
     // $this->ItemQuery->where_ID( $p, $title );
     // Set filter by collection:
     $blog_ID = empty($params['blog_ID']) ? NULL : $params['blog_ID'];
     if (empty($params['cat_IDs'])) {
         // Use default categories filter:
         $filter_cat_array = $Calendar->link_type == 'context' ? $cat_array : array();
     } else {
         // Get categories filter from widget settings:
         $filter_cat_array = sanitize_id_list($params['cat_IDs'], true);
     }
     if ($Calendar->link_type == 'context') {
         // We want to preserve the current context:
         // * - - Restrict to selected blog/categories:
         $Calendar->ItemQuery->where_chapter2($Blog, $filter_cat_array, $cat_modifier, 'wide', $blog_ID);
         // Restrict to selected authors:
         $Calendar->ItemQuery->where_author($author);
         // Restrict to selected assignees:
         $Calendar->ItemQuery->where_assignees($assgn);
         // Restrict to selected satuses:
         $Calendar->ItemQuery->where_statuses($status);
         // - - - + * * if a month is specified in the querystring, load that month:
         $Calendar->ItemQuery->where_datestart('', '', $dstart, '', $Blog->get_timestamp_min(), $Blog->get_timestamp_max());
         // Keyword search stuff:
         $Calendar->ItemQuery->where_keywords($s, $sentence, $exact);
     } else {
         // We want to preserve only the minimal context:
         // * - - Restrict to selected blog/categories:
         $Calendar->ItemQuery->where_chapter2($Blog, $filter_cat_array, '', 'wide', $blog_ID);
         // - - - + * * if a month is specified in the querystring, load that month:
         $Calendar->ItemQuery->where_datestart('', '', '', '', $Blog->get_timestamp_min(), $Blog->get_timestamp_max());
     }
     if (isset($params['item_visibility']) && $params['item_visibility'] == 'public') {
         // Get only the public items:
         $visibility_array = array('published');
     } else {
         // Get the current selected status items:
         $visibility_array = $show_statuses;
     }
     // * Restrict to the statuses we want to show:
     $Calendar->ItemQuery->where_visibility($visibility_array);
     $item_types = $types;
     if (isset($params['item_type'])) {
         if ($params['item_type'] == '#') {
             // Exclude pages and intros and sidebar stuff by default:
             $item_types = '-' . implode(',', $posttypes_specialtypes);
         } elseif ($params['item_type'] != 'all') {
             // Filter by one selected item type:
             $item_types = $params['item_type'];
         }
     }
     // Filter by item types:
     $Calendar->ItemQuery->where_types($item_types);
     // DISPLAY:
     $Calendar->display();
     echo $params['block_body_end'];
     echo $params['block_end'];
     return true;
 }
 /**
  * Callback: Generate category line when it has children
  *
  * @param object Chapter we want to display
  * @param integer Level of the category in the recursive tree
  * @return string HTML
  */
 function cat_line($Chapter, $level)
 {
     global $cat_array;
     if (!isset($cat_array)) {
         $cat_array = array();
     }
     $exclude_cats = sanitize_id_list($this->disp_params['exclude_cats'], true);
     if (in_array($Chapter->ID, $exclude_cats)) {
         // Cat ID is excluded, skip it
         return;
     }
     // ID of the current selected category
     $first_selected_cat_ID = isset($cat_array[0]) ? $cat_array[0] : 0;
     if (!isset($this->disp_params['current_parents'])) {
         // Try to find the parent categories in order to select it because of widget setting is enabled
         $this->disp_params['current_all_cats'] = array();
         // All children of the root parent of the selcted category
         $this->disp_params['current_parents'] = array();
         // All parents of the selected category
         $this->disp_params['current_selected_level'] = 0;
         // Level of the selected category
         if ($first_selected_cat_ID > 0) {
             $this->disp_params['current_selected_level'] = $this->disp_params['current_selected_level'] + 1;
             $ChapterCache =& get_ChapterCache();
             $parent_Chapter =& $ChapterCache->get_by_ID($first_selected_cat_ID, false, false);
             while ($parent_Chapter !== NULL) {
                 // Go up to the first/root category
                 $root_parent_ID = $parent_Chapter->ID;
                 if ($parent_Chapter =& $parent_Chapter->get_parent_Chapter()) {
                     $this->disp_params['current_parents'][] = $parent_Chapter->ID;
                     $this->disp_params['current_all_cats'][] = $parent_Chapter->ID;
                     $this->disp_params['current_selected_level'] = $this->disp_params['current_selected_level'] + 1;
                 }
             }
             // Load all categories of the current selected path (these categories should be visible on page)
             $this->disp_params['current_all_cats'] = $cat_array;
             $this->load_category_children($root_parent_ID, $this->disp_params['current_all_cats'], $this->disp_params['current_parents']);
         }
     }
     $parent_cat_is_visible = isset($this->disp_params['parent_cat_is_visible']) ? $this->disp_params['parent_cat_is_visible'] : false;
     $start_level = intval($this->disp_params['start_level']);
     if ($start_level > 1 && ($start_level > $level + 1 || !in_array($Chapter->ID, $this->disp_params['current_all_cats']) && !$this->disp_params['parent_cat_is_visible'] || $this->disp_params['current_selected_level'] < $level && !$this->disp_params['parent_cat_is_visible'])) {
         // Don't show this item because of level restriction
         $this->disp_params['parent_cat_is_visible'] = false;
         //return '<span style="font-size:10px">hidden: ('.$level.'|'.$this->disp_params['current_selected_level'].')</span>';
         return '';
     } elseif (!isset($this->disp_params['current_cat_level'])) {
         // Save level of the current selected category
         $this->disp_params['current_cat_level'] = $level;
         $this->disp_params['parent_cat_is_visible'] = true;
     }
     if ($this->disp_params['mark_first_selected'] && $Chapter->ID == $first_selected_cat_ID || $this->disp_params['mark_children'] && $Chapter->ID != $first_selected_cat_ID && in_array($Chapter->ID, $cat_array) || $this->disp_params['mark_parents'] && $Chapter->ID != $first_selected_cat_ID && in_array($Chapter->ID, $this->disp_params['current_parents'])) {
         // This category should be selected
         $start_tag = $this->disp_params['item_selected_start'];
     } else {
         if (empty($Chapter->children)) {
             // This category has no children
             $start_tag = $this->disp_params['item_last_start'];
         } else {
             $start_tag = $this->disp_params['item_start'];
         }
     }
     if ($Chapter->meta) {
         // Add class name "meta" for meta categories
         $start_tag = $this->add_cat_class_attr($start_tag, 'meta');
     }
     $r = $start_tag;
     if ($this->disp_params['use_form'] || $this->disp_params['display_checkboxes']) {
         // We want to add form fields:
         $cat_checkbox_params = '';
         if ($Chapter->meta) {
             // Disable the checkbox of meta category ( and hide it by css )
             $cat_checkbox_params = ' disabled="disabled"';
         }
         $r .= '<label><input type="checkbox" name="catsel[]" value="' . $Chapter->ID . '" class="checkbox middle"';
         if (in_array($Chapter->ID, $cat_array)) {
             // This category is in the current selection
             $r .= ' checked="checked"';
         }
         $r .= $cat_checkbox_params . ' /> ';
     }
     $cat_name = $Chapter->dget('name');
     if ($Chapter->lock && isset($this->disp_params['show_locked']) && $this->disp_params['show_locked']) {
         $cat_name .= '<span style="padding:0 5px;" >' . get_icon('file_not_allowed', 'imgtag', array('title' => T_('Locked'))) . '</span>';
     }
     // Make a link from category name
     $r .= '<a href="';
     if ($this->disp_params['link_type'] == 'context') {
         // We want to preserve current browsing context:
         $r .= regenerate_url('cats,catsel', 'cat=' . $Chapter->ID);
     } else {
         $r .= $Chapter->get_permanent_url();
     }
     $r .= '">' . $cat_name . '</a>';
     if ($this->disp_params['use_form'] || $this->disp_params['display_checkboxes']) {
         // We want to add form fields:
         $r .= '</label>';
     }
     // End the line even if it has children, since this is the end of one single item
     // To close the whole group of categories with all of it's children see @cat_before_level and @cat_after_level
     // Note: If this solution will not work, and we can't add the 'item_end' here, then create new after_line callback,
     // which then must be called from a the ChapterCache recurse method
     $r .= $this->disp_params['item_end'];
     return $r;
 }
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     $this->init_display($params);
     global $blog;
     $BlogCache =& get_BlogCache();
     // Source collections:
     // Get a list of quoted blog IDs
     $blog_ids = sanitize_id_list($this->disp_params['blog_ids'], true);
     if (empty($blog) && empty($blog_ids)) {
         // Nothing to display
         return;
     } elseif (empty($blog_ids)) {
         // Use current Blog
         $blog_ids = $blog;
     }
     // Destination:
     if ($destination_coll_ID = $this->disp_params['destination_coll_ID']) {
         // Get destination Colelction, but allow error, in that case we'll get NULL
         $destination_Blog = $BlogCache->get_by_ID($destination_coll_ID, false);
     } else {
         // Auto destination:
         $destination_Blog = NULL;
     }
     $results = get_tags($blog_ids, $this->disp_params['max_tags'], NULL, false);
     if (empty($results)) {
         // No tags!
         return;
     }
     $max_count = $results[0]->tag_count;
     $min_count = $results[count($results) - 1]->tag_count;
     $count_span = max(1, $max_count - $min_count);
     $max_size = $this->disp_params['tag_max_size'];
     $min_size = $this->disp_params['tag_min_size'];
     $size_span = $max_size - $min_size;
     if ($this->disp_params['tag_ordering'] == 'ASC') {
         usort($results, array($this, 'tag_cloud_cmp'));
     } elseif ($this->disp_params['tag_ordering'] == 'RAND') {
         shuffle($results);
     }
     echo $this->disp_params['block_start'];
     $this->disp_title();
     echo $this->disp_params['block_body_start'];
     echo $this->disp_params['tag_cloud_start'];
     $count = 0;
     foreach ($results as $row) {
         if ($count > 0) {
             echo $this->disp_params['tag_separator'];
         }
         // If there's a space in the tag name, quote it:
         $tag_name_disp = strpos($row->tag_name, ' ') ? '&laquo;' . format_to_output($row->tag_name, 'htmlbody') . '&raquo;' : format_to_output($row->tag_name, 'htmlbody');
         $font_size = floor($row->tag_count * $size_span / $count_span + $min_size);
         if (!is_null($destination_Blog)) {
             $l_Blog = $destination_Blog;
         } else {
             // Automatic destination decision. Note: this may not be be best decision.
             $l_Blog = $BlogCache->get_by_ID($row->cat_blog_ID);
         }
         echo $l_Blog->get_tag_link($row->tag_name, $tag_name_disp, array('style' => 'font-size:' . $font_size . 'pt;', 'title' => sprintf(T_('Display posts tagged with "%s"'), $row->tag_name)));
         $count++;
     }
     echo $this->disp_params['tag_cloud_end'];
     echo $this->disp_params['block_body_end'];
     echo $this->disp_params['block_end'];
     return true;
 }
 /**
  * Callback: Generate category line when it has children
  *
  * @param Chapter generic category we want to display
  * @param int level of the category in the recursive tree
  * @return string HTML
  */
 function cat_line($Chapter, $level)
 {
     global $cat_array;
     if (!isset($cat_array)) {
         $cat_array = array();
     }
     $exclude_cats = sanitize_id_list($this->disp_params['exclude_cats'], true);
     if (in_array($Chapter->ID, $exclude_cats)) {
         // Cat ID is excluded, skip it
         return;
     }
     if (in_array($Chapter->ID, $cat_array)) {
         // This category is in the current selection
         $r = $this->disp_params['item_selected_start'];
     } else {
         if (empty($Chapter->children)) {
             // This category has no children
             $r = $this->disp_params['item_last_start'];
         } else {
             $r = $this->disp_params['item_start'];
         }
     }
     if ($this->disp_params['use_form'] || $this->disp_params['display_checkboxes']) {
         // We want to add form fields:
         $cat_checkbox_params = '';
         if ($Chapter->meta) {
             // Hide and disable the checkbox of meta category
             $cat_checkbox_params = ' style="visibility:hidden" disabled="disabled"';
         }
         $r .= '<label><input type="checkbox" name="catsel[]" value="' . $Chapter->ID . '" class="checkbox middle"';
         if (in_array($Chapter->ID, $cat_array)) {
             // This category is in the current selection
             $r .= ' checked="checked"';
         }
         $r .= $cat_checkbox_params . ' /> ';
     }
     $cat_name_params = '';
     if ($Chapter->meta) {
         // Mark the meta category with bold style
         $cat_name_params = ' style="font-weight:bold"';
     }
     $r .= '<a href="';
     if ($this->disp_params['link_type'] == 'context') {
         // We want to preserve current browsing context:
         $r .= regenerate_url('cats,catsel', 'cat=' . $Chapter->ID);
     } else {
         $r .= $Chapter->get_permanent_url();
     }
     $cat_name = $Chapter->dget('name');
     if ($Chapter->lock && isset($this->disp_params['show_locked']) && $this->disp_params['show_locked']) {
         $cat_name .= '<span style="padding:0 5px;" >' . get_icon('file_not_allowed', 'imgtag', array('title' => T_('Locked'))) . '</span>';
     }
     $r .= '"' . $cat_name_params . '>' . $cat_name . '</a>';
     if ($this->disp_params['use_form'] || $this->disp_params['display_checkboxes']) {
         // We want to add form fields:
         $r .= '</label>';
     }
     // Do not end line here because we need to include children first!
     // $r .= $this->disp_params['item_end'];
     return $r;
 }
Example #7
0
    /**
     * Load data from Request form fields.
     *
     * @param array groups of params to load
     * @return boolean true if loaded data seems valid.
     */
    function load_from_Request($groups = array())
    {
        global $Messages, $default_locale, $DB;
        /**
         * @var User
         */
        global $current_User;
        // Load collection settings and clear update cascade array
        $this->load_CollectionSettings();
        if (param('blog_name', 'string', NULL) !== NULL) {
            // General params:
            $this->set_from_Request('name');
            $this->set('shortname', param('blog_shortname', 'string', true));
            // Language / locale:
            if (param('blog_locale', 'string', NULL) !== NULL) {
                // These settings can be hidden when only one locale is enaled in the system
                $this->set_from_Request('locale');
                $this->set_setting('locale_source', param('blog_locale_source', 'string', 'blog'));
                $this->set_setting('post_locale_source', param('blog_post_locale_source', 'string', 'post'));
            }
            // Collection permissions:
            $this->set('advanced_perms', param('advanced_perms', 'integer', 0));
            $this->set_setting('allow_access', param('blog_allow_access', 'string', ''));
            if ($this->get_setting('allow_access') == 'users' || $this->get_setting('allow_access') == 'members') {
                // Disable site maps, feeds and ping plugins when access is restricted on this blog
                $this->set_setting('enable_sitemaps', 0);
                $this->set_setting('feed_content', 'none');
                $this->set_setting('ping_plugins', '');
            }
            // Lists of collections:
            $this->set('order', param('blog_order', 'integer'));
            $this->set('in_bloglist', param('blog_in_bloglist', 'string', 'public'));
            $this->set('favorite', param('favorite', 'integer', 0));
        }
        if (param('archive_links', 'string', NULL) !== NULL) {
            // Archive link type:
            $this->set_setting('archive_links', get_param('archive_links'));
            $this->set_setting('archive_posts_per_page', param('archive_posts_per_page', 'integer', NULL), true);
        }
        if (param('chapter_links', 'string', NULL) !== NULL) {
            // Chapter link type:
            $this->set_setting('chapter_links', get_param('chapter_links'));
        }
        if (param('category_prefix', 'string', NULL) !== NULL) {
            $category_prefix = get_param('category_prefix');
            if (!preg_match('|^([A-Za-z0-9\\-_]+(/[A-Za-z0-9\\-_]+)*)?$|', $category_prefix)) {
                param_error('category_prefix', T_('Invalid category prefix.'));
            }
            $this->set_setting('category_prefix', $category_prefix);
        }
        if (param('atom_redirect', 'string', NULL) !== NULL) {
            param_check_url('atom_redirect', 'commenting');
            $this->set_setting('atom_redirect', get_param('atom_redirect'));
            param('rss2_redirect', 'string', NULL);
            param_check_url('rss2_redirect', 'commenting');
            $this->set_setting('rss2_redirect', get_param('rss2_redirect'));
        }
        if (param('image_size', 'string', NULL) !== NULL) {
            $this->set_setting('image_size', get_param('image_size'));
        }
        if (param('tag_links', 'string', NULL) !== NULL) {
            // Tag page link type:
            $this->set_setting('tag_links', get_param('tag_links'));
        }
        if (param('tag_prefix', 'string', NULL) !== NULL) {
            $tag_prefix = get_param('tag_prefix');
            if (!preg_match('|^([A-Za-z0-9\\-_]+(/[A-Za-z0-9\\-_]+)*)?$|', $tag_prefix)) {
                param_error('tag_prefix', T_('Invalid tag prefix.'));
            }
            $this->set_setting('tag_prefix', $tag_prefix);
        }
        // Default to "tag", if "prefix-only" is used, but no tag_prefix was provided.
        if (get_param('tag_links') == 'prefix-only' && !strlen(param('tag_prefix', 'string', NULL))) {
            $this->set_setting('tag_prefix', 'tag');
        }
        // Use rel="tag" attribute? (checkbox)
        $this->set_setting('tag_rel_attib', param('tag_rel_attib', 'integer', 0));
        if (param('chapter_content', 'string', NULL) !== NULL) {
            // What kind of content on chapter pages?
            $this->set_setting('chapter_content', get_param('chapter_content'));
        }
        if (param('tag_content', 'string', NULL) !== NULL) {
            // What kind of content on tags pages?
            $this->set_setting('tag_content', get_param('tag_content'));
        }
        if (param('archive_content', 'string', NULL) !== NULL) {
            // What kind of content on archive pages?
            $this->set_setting('archive_content', get_param('archive_content'));
        }
        if (param('filtered_content', 'string', NULL) !== NULL) {
            // What kind of content on filtered pages?
            $this->set_setting('filtered_content', get_param('filtered_content'));
        }
        if (param('main_content', 'string', NULL) !== NULL) {
            // What kind of content on main pages?
            $this->set_setting('main_content', get_param('main_content'));
        }
        // Chapter posts per page:
        $this->set_setting('chapter_posts_per_page', param('chapter_posts_per_page', 'integer', NULL), true);
        // Tag posts per page:
        $this->set_setting('tag_posts_per_page', param('tag_posts_per_page', 'integer', NULL), true);
        if (param('single_links', 'string', NULL) !== NULL) {
            // Single post link type:
            $this->set_setting('single_links', get_param('single_links'));
        }
        if (param('slug_limit', 'integer', NULL) !== NULL) {
            // Limit slug length:
            $this->set_setting('slug_limit', get_param('slug_limit'));
        }
        if (param('normal_skin_ID', 'integer', NULL) !== NULL) {
            // Normal skin ID:
            $this->set_setting('normal_skin_ID', get_param('normal_skin_ID'));
        }
        if (param('mobile_skin_ID', 'integer', NULL) !== NULL) {
            // Mobile skin ID:
            if (get_param('mobile_skin_ID') == 0) {
                // Don't store this empty setting in DB
                $this->delete_setting('mobile_skin_ID');
            } else {
                // Set mobile skin
                $this->set_setting('mobile_skin_ID', get_param('mobile_skin_ID'));
            }
        }
        if (param('tablet_skin_ID', 'integer', NULL) !== NULL) {
            // Tablet skin ID:
            if (get_param('tablet_skin_ID') == 0) {
                // Don't store this empty setting in DB
                $this->delete_setting('tablet_skin_ID');
            } else {
                // Set tablet skin
                $this->set_setting('tablet_skin_ID', get_param('tablet_skin_ID'));
            }
        }
        if (param('archives_sort_order', 'string', NULL) !== NULL) {
            // Archive sorting
            $this->set_setting('archives_sort_order', param('archives_sort_order', 'string', false));
        }
        if (param('download_delay', 'integer', NULL) !== NULL) {
            // Download delay
            param_check_range('download_delay', 0, 10, T_('Download delay must be numeric (0-10).'));
            $this->set_setting('download_delay', get_param('download_delay'));
        }
        if (param('feed_content', 'string', NULL) !== NULL) {
            // How much content in feeds?
            $this->set_setting('feed_content', get_param('feed_content'));
            param_integer_range('posts_per_feed', 1, 9999, T_('Items per feed must be between %d and %d.'));
            $this->set_setting('posts_per_feed', get_param('posts_per_feed'));
        }
        if (param('comment_feed_content', 'string', NULL) !== NULL) {
            // How much content in comment feeds?
            $this->set_setting('comment_feed_content', get_param('comment_feed_content'));
            param_integer_range('comments_per_feed', 1, 9999, T_('Comments per feed must be between %d and %d.'));
            $this->set_setting('comments_per_feed', get_param('comments_per_feed'));
        }
        if (param('blog_shortdesc', 'string', NULL) !== NULL) {
            // Description:
            $this->set_from_Request('shortdesc');
        }
        if (param('blog_keywords', 'string', NULL) !== NULL) {
            // Keywords:
            $this->set_from_Request('keywords');
        }
        if (param('blog_tagline', 'html', NULL) !== NULL) {
            // HTML tagline:
            param_check_html('blog_tagline', T_('Invalid tagline'));
            $this->set('tagline', get_param('blog_tagline'));
        }
        if (param('blog_longdesc', 'html', NULL) !== NULL) {
            // HTML long description:
            param_check_html('blog_longdesc', T_('Invalid long description'));
            $this->set('longdesc', get_param('blog_longdesc'));
        }
        if (param('blog_footer_text', 'html', NULL) !== NULL) {
            // Blog footer:
            param_check_html('blog_footer_text', T_('Invalid blog footer'));
            $this->set_setting('blog_footer_text', get_param('blog_footer_text'));
        }
        if (param('single_item_footer_text', 'html', NULL) !== NULL) {
            // Blog footer:
            param_check_html('single_item_footer_text', T_('Invalid single post footer'));
            $this->set_setting('single_item_footer_text', get_param('single_item_footer_text'));
        }
        if (param('xml_item_footer_text', 'html', NULL) !== NULL) {
            // Blog footer:
            param_check_html('xml_item_footer_text', T_('Invalid RSS footer'));
            $this->set_setting('xml_item_footer_text', get_param('xml_item_footer_text'));
        }
        if (param('blog_notes', 'html', NULL) !== NULL) {
            // HTML notes:
            param_check_html('blog_notes', T_('Invalid Blog Notes'));
            $this->set('notes', get_param('blog_notes'));
            param_integer_range('max_footer_credits', 0, 3, T_('Max credits must be between %d and %d.'));
            $this->set_setting('max_footer_credits', get_param('max_footer_credits'));
        }
        if (in_array('pings', $groups)) {
            // we want to load the ping checkboxes:
            $blog_ping_plugins = param('blog_ping_plugins', 'array:string', array());
            $blog_ping_plugins = array_unique($blog_ping_plugins);
            $this->set_setting('ping_plugins', implode(',', $blog_ping_plugins));
        }
        if (in_array('authors', $groups)) {
            // we want to load the workflow & permissions params
            $this->set_setting('use_workflow', param('blog_use_workflow', 'integer', 0));
        }
        if (in_array('home', $groups)) {
            // we want to load the front page params:
            $front_disp = param('front_disp', 'string', '');
            $this->set_setting('front_disp', $front_disp);
            $front_post_ID = param('front_post_ID', 'integer', 0);
            if ($front_disp == 'page') {
                // Post ID must be required
                param_check_not_empty('front_post_ID', T_('Please enter a specific post ID'));
            }
            $this->set_setting('front_post_ID', $front_post_ID);
        }
        if (in_array('features', $groups)) {
            // we want to load the workflow checkboxes:
            $this->set_setting('enable_goto_blog', param('enable_goto_blog', 'string', NULL));
            $this->set_setting('editing_goto_blog', param('editing_goto_blog', 'string', NULL));
            $this->set_setting('default_post_status', param('default_post_status', 'string', NULL));
            $this->set_setting('post_categories', param('post_categories', 'string', NULL));
            $this->set_setting('post_navigation', param('post_navigation', 'string', NULL));
            // Show x days or x posts?:
            $this->set_setting('what_to_show', param('what_to_show', 'string', ''));
            param_integer_range('posts_per_page', 1, 9999, T_('Items/days per page must be between %d and %d.'));
            $this->set_setting('posts_per_page', get_param('posts_per_page'));
            $this->set_setting('orderby', param('orderby', 'string', true));
            $this->set_setting('orderdir', param('orderdir', 'string', true));
            // Front office statuses
            $this->load_inskin_statuses('post');
            // Time frame
            $this->set_setting('timestamp_min', param('timestamp_min', 'string', ''));
            $this->set_setting('timestamp_min_duration', param_duration('timestamp_min_duration'));
            $this->set_setting('timestamp_max', param('timestamp_max', 'string', ''));
            $this->set_setting('timestamp_max_duration', param_duration('timestamp_max_duration'));
            // call modules update_collection_features on this blog
            modules_call_method('update_collection_features', array('edited_Blog' => &$this));
            // load post moderation statuses
            $moderation_statuses = get_visibility_statuses('moderation');
            $post_moderation_statuses = array();
            foreach ($moderation_statuses as $status) {
                if (param('post_notif_' . $status, 'integer', 0)) {
                    $post_moderation_statuses[] = $status;
                }
            }
            $this->set_setting('post_moderation_statuses', implode(',', $post_moderation_statuses));
        }
        if (in_array('comments', $groups)) {
            // we want to load the comments settings:
            // load moderation statuses
            $moderation_statuses = get_visibility_statuses('moderation');
            $blog_moderation_statuses = array();
            foreach ($moderation_statuses as $status) {
                if (param('notif_' . $status, 'integer', 0)) {
                    $blog_moderation_statuses[] = $status;
                }
            }
            $this->set_setting('moderation_statuses', implode(',', $blog_moderation_statuses));
            $this->set_setting('comment_quick_moderation', param('comment_quick_moderation', 'string', 'expire'));
            $this->set_setting('allow_item_subscriptions', param('allow_item_subscriptions', 'integer', 0));
            $this->set_setting('comments_detect_email', param('comments_detect_email', 'integer', 0));
            $this->set_setting('comments_register', param('comments_register', 'integer', 0));
        }
        if (in_array('other', $groups)) {
            // we want to load the other settings:
            // Search results:
            param_integer_range('search_per_page', 1, 9999, T_('Number of search results per page must be between %d and %d.'));
            $this->set_setting('search_per_page', get_param('search_per_page'));
            // Latest comments :
            param_integer_range('latest_comments_num', 1, 9999, T_('Number of shown comments must be between %d and %d.'));
            $this->set_setting('latest_comments_num', get_param('latest_comments_num'));
            // User directory:
            $this->set_setting('image_size_user_list', param('image_size_user_list', 'string'));
            // Messaging pages:
            $this->set_setting('image_size_messaging', param('image_size_messaging', 'string'));
            // Archive pages:
            $this->set_setting('archive_mode', param('archive_mode', 'string', true));
        }
        if (in_array('more', $groups)) {
            // we want to load more settings:
            // Tracking:
            $this->set_setting('track_unread_content', param('track_unread_content', 'integer', 0));
            // Subscriptions:
            $this->set_setting('allow_subscriptions', param('allow_subscriptions', 'integer', 0));
            $this->set_setting('allow_item_subscriptions', param('allow_item_subscriptions', 'integer', 0));
            // Sitemaps:
            $this->set_setting('enable_sitemaps', param('enable_sitemaps', 'integer', 0));
        }
        if (param('allow_comments', 'string', NULL) !== NULL) {
            // Feedback options:
            $this->set_setting('allow_comments', param('allow_comments', 'string', 'any'));
            $this->set_setting('allow_view_comments', param('allow_view_comments', 'string', 'any'));
            $new_feedback_status = param('new_feedback_status', 'string', 'draft');
            if ($new_feedback_status != $this->get_setting('new_feedback_status') && ($new_feedback_status != 'published' || $current_User->check_perm('blog_admin', 'edit', false, $this->ID))) {
                // Only admin can set this setting to 'Public'
                $this->set_setting('new_feedback_status', $new_feedback_status);
            }
            $this->set_setting('allow_anon_url', param('allow_anon_url', 'string', '0'));
            $this->set_setting('allow_html_comment', param('allow_html_comment', 'string', '0'));
            $this->set_setting('allow_attachments', param('allow_attachments', 'string', 'registered'));
            $this->set_setting('max_attachments', param('max_attachments', 'integer', ''));
            $this->set_setting('autocomplete_usernames', param('autocomplete_usernames', 'integer', ''));
            $this->set_setting('display_rating_summary', param('display_rating_summary', 'string', '0'));
            $this->set_setting('allow_rating_items', param('allow_rating_items', 'string', 'never'));
            $this->set_setting('rating_question', param('rating_question', 'text'));
            $this->set_setting('allow_rating_comment_helpfulness', param('allow_rating_comment_helpfulness', 'string', '0'));
            $blog_allowtrackbacks = param('blog_allowtrackbacks', 'integer', 0);
            if ($blog_allowtrackbacks != $this->get('allowtrackbacks') && ($blog_allowtrackbacks == 0 || $current_User->check_perm('blog_admin', 'edit', false, $this->ID))) {
                // Only admin can turn ON this setting
                $this->set('allowtrackbacks', $blog_allowtrackbacks);
            }
            $this->set_setting('comments_orderdir', param('comments_orderdir', '/^(?:ASC|DESC)$/', 'ASC'));
            // call modules update_collection_comments on this blog
            modules_call_method('update_collection_comments', array('edited_Blog' => &$this));
            $threaded_comments = param('threaded_comments', 'integer', 0);
            $this->set_setting('threaded_comments', $threaded_comments);
            $this->set_setting('paged_comments', $threaded_comments ? 0 : param('paged_comments', 'integer', 0));
            param_integer_range('comments_per_page', 1, 9999, T_('Comments per page must be between %d and %d.'));
            $this->set_setting('comments_per_page', get_param('comments_per_page'));
            $this->set_setting('comments_avatars', param('comments_avatars', 'integer', 0));
            $this->set_setting('comments_latest', param('comments_latest', 'integer', 0));
            // load blog front office comment statuses
            $this->load_inskin_statuses('comment');
        }
        if (in_array('seo', $groups)) {
            // we want to load the workflow checkboxes:
            $this->set_setting('canonical_homepage', param('canonical_homepage', 'integer', 0));
            $this->set_setting('relcanonical_homepage', param('relcanonical_homepage', 'integer', 0));
            $this->set_setting('canonical_item_urls', param('canonical_item_urls', 'integer', 0));
            $this->set_setting('relcanonical_item_urls', param('relcanonical_item_urls', 'integer', 0));
            $this->set_setting('canonical_archive_urls', param('canonical_archive_urls', 'integer', 0));
            $this->set_setting('relcanonical_archive_urls', param('relcanonical_archive_urls', 'integer', 0));
            $this->set_setting('canonical_cat_urls', param('canonical_cat_urls', 'integer', 0));
            $this->set_setting('relcanonical_cat_urls', param('relcanonical_cat_urls', 'integer', 0));
            $this->set_setting('canonical_tag_urls', param('canonical_tag_urls', 'integer', 0));
            $this->set_setting('relcanonical_tag_urls', param('relcanonical_tag_urls', 'integer', 0));
            $this->set_setting('default_noindex', param('default_noindex', 'integer', 0));
            $this->set_setting('paged_noindex', param('paged_noindex', 'integer', 0));
            $this->set_setting('paged_nofollowto', param('paged_nofollowto', 'integer', 0));
            $this->set_setting('archive_noindex', param('archive_noindex', 'integer', 0));
            $this->set_setting('archive_nofollowto', param('archive_nofollowto', 'integer', 0));
            $this->set_setting('chapter_noindex', param('chapter_noindex', 'integer', 0));
            $this->set_setting('tag_noindex', param('tag_noindex', 'integer', 0));
            $this->set_setting('filtered_noindex', param('filtered_noindex', 'integer', 0));
            $this->set_setting('arcdir_noindex', param('arcdir_noindex', 'integer', 0));
            $this->set_setting('catdir_noindex', param('catdir_noindex', 'integer', 0));
            $this->set_setting('feedback-popup_noindex', param('feedback-popup_noindex', 'integer', 0));
            $this->set_setting('msgform_noindex', param('msgform_noindex', 'integer', 0));
            $this->set_setting('special_noindex', param('special_noindex', 'integer', 0));
            $this->set_setting('title_link_type', param('title_link_type', 'string', ''));
            $this->set_setting('permalinks', param('permalinks', 'string', ''));
            $this->set_setting('404_response', param('404_response', 'string', ''));
            $this->set_setting('help_link', param('help_link', 'string', ''));
            $this->set_setting('excerpts_meta_description', param('excerpts_meta_description', 'integer', 0));
            $this->set_setting('categories_meta_description', param('categories_meta_description', 'integer', 0));
            $this->set_setting('tags_meta_keywords', param('tags_meta_keywords', 'integer', 0));
            $this->set_setting('tags_open_graph', param('tags_open_graph', 'integer', 0));
            $this->set_setting('download_noindex', param('download_noindex', 'integer', 0));
            $this->set_setting('download_nofollowto', param('download_nofollowto', 'integer', 0));
        }
        /*
         * ADVANCED ADMIN SETTINGS
         */
        if ($current_User->check_perm('blog_admin', 'edit', false, $this->ID)) {
            // We have permission to edit advanced admin settings:
            if (in_array('cache', $groups)) {
                // we want to load the cache params:
                $this->set_setting('ajax_form_enabled', param('ajax_form_enabled', 'integer', 0));
                $this->set_setting('ajax_form_loggedin_enabled', param('ajax_form_loggedin_enabled', 'integer', 0));
                $this->set_setting('cache_enabled_widgets', param('cache_enabled_widgets', 'integer', 0));
            }
            if (in_array('styles', $groups)) {
                // we want to load the styles params:
                $this->set('allowblogcss', param('blog_allowblogcss', 'integer', 0));
                $this->set('allowusercss', param('blog_allowusercss', 'integer', 0));
            }
            if (in_array('login', $groups)) {
                // we want to load the login params:
                if (!get_setting_Blog('login_blog_ID')) {
                    // Update this only when no blog is defined for login/registration
                    $this->set_setting('in_skin_login', param('in_skin_login', 'integer', 0));
                }
                $this->set_setting('in_skin_editing', param('in_skin_editing', 'integer', 0));
            }
            if (param('blog_head_includes', 'html', NULL) !== NULL) {
                // HTML header includes:
                param_check_html('blog_head_includes', T_('Invalid Custom meta tag/css section.'), '#', 'head_extension');
                $this->set_setting('head_includes', get_param('blog_head_includes'));
            }
            if (param('blog_footer_includes', 'html', NULL) !== NULL) {
                // HTML header includes:
                param_check_html('blog_footer_includes', T_('Invalid Custom javascript section'));
                $this->set_setting('footer_includes', get_param('blog_footer_includes'));
            }
            if (param('owner_login', 'string', NULL) !== NULL) {
                // Permissions:
                $UserCache =& get_UserCache();
                $owner_User =& $UserCache->get_by_login(get_param('owner_login'));
                if (empty($owner_User)) {
                    param_error('owner_login', sprintf(T_('User &laquo;%s&raquo; does not exist!'), get_param('owner_login')));
                } else {
                    $this->set('owner_user_ID', $owner_User->ID);
                    $this->owner_User =& $owner_User;
                }
            }
            if (($blog_urlname = param('blog_urlname', 'string', NULL)) !== NULL) {
                // check urlname
                if (param_check_not_empty('blog_urlname', T_('You must provide an URL collection name!'))) {
                    if (!preg_match('|^[A-Za-z0-9\\-]+$|', $blog_urlname)) {
                        param_error('blog_urlname', sprintf(T_('The url name %s is invalid.'), "&laquo;{$blog_urlname}&raquo;"));
                        $blog_urlname = NULL;
                    }
                    if (isset($blog_urlname) && $DB->get_var('SELECT COUNT(*)
															FROM T_blogs
															WHERE blog_urlname = ' . $DB->quote($blog_urlname) . '
															AND blog_ID <> ' . $this->ID)) {
                        // urlname is already in use
                        param_error('blog_urlname', sprintf(T_('The URL name %s is already in use by another collection. Please choose another name.'), "&laquo;{$blog_urlname}&raquo;"));
                        $blog_urlname = NULL;
                    }
                    if (isset($blog_urlname)) {
                        // Set new urlname and save old media dir in order to rename folder to new
                        $old_media_dir = $this->get_media_dir(false);
                        $this->set_from_Request('urlname');
                    }
                }
            }
            if (($access_type = param('blog_access_type', 'string', NULL)) !== NULL) {
                // Blog URL parameters:
                // Note: We must avoid to set an invalid url, because the new blog url will be displayed in the evobar even if it was not saved
                $allow_new_access_type = true;
                if ($access_type == 'absolute') {
                    $blog_siteurl = param('blog_siteurl_absolute', 'string', true);
                    if (preg_match('#^https?://[^/]+/.*#', $blog_siteurl, $matches)) {
                        // It looks like valid absolute URL, so we may update the blog siteurl
                        $this->set('siteurl', $blog_siteurl);
                    } else {
                        // It is not valid absolute URL, don't update the blog 'siteurl' to avoid errors
                        $allow_new_access_type = false;
                        // If site url is not updated do not allow access_type update either
                        $Messages->add(T_('Collection Folder URL') . ': ' . sprintf(T_('%s is an invalid absolute URL'), '&laquo;' . htmlspecialchars($blog_siteurl) . '&raquo;') . '. ' . T_('You must provide an absolute URL (starting with <code>http://</code> or <code>https://</code>) and it must contain at least one \'/\' sign after the domain name!'), 'error');
                    }
                } elseif ($access_type == 'relative') {
                    // relative siteurl
                    $blog_siteurl = param('blog_siteurl_relative', 'string', true);
                    if (preg_match('#^https?://#', $blog_siteurl)) {
                        $Messages->add(T_('Blog Folder URL') . ': ' . T_('You must provide a relative URL (without <code>http://</code> or <code>https://</code>)!'), 'error');
                    }
                    $this->set('siteurl', $blog_siteurl);
                } else {
                    $this->set('siteurl', '');
                }
                if ($allow_new_access_type) {
                    // The received siteurl value was correct, may update the access_type value
                    $this->set('access_type', $access_type);
                }
            }
            if (param('aggregate_coll_IDs', 'string', NULL) !== NULL) {
                // Aggregate list: (can be '*')
                $aggregate_coll_IDs = get_param('aggregate_coll_IDs');
                if ($aggregate_coll_IDs != '*') {
                    // Sanitize the string
                    $aggregate_coll_IDs = sanitize_id_list($aggregate_coll_IDs);
                }
                // fp> TODO: check perms on each aggregated blog (if changed)
                // fp> TODO: better interface
                if ($aggregate_coll_IDs != '*' && !preg_match('#^([0-9]+(,[0-9]+)*)?$#', $aggregate_coll_IDs)) {
                    param_error('aggregate_coll_IDs', T_('Invalid aggregate collection ID list!'));
                }
                $this->set_setting('aggregate_coll_IDs', $aggregate_coll_IDs);
            }
            $media_location = param('blog_media_location', 'string', NULL);
            if ($media_location !== NULL) {
                // Media files location:
                $old_media_dir = $this->get_media_dir(false);
                $old_media_location = $this->get('media_location');
                $this->set_from_Request('media_location');
                $this->set_media_subdir(param('blog_media_subdir', 'string', ''));
                $this->set_media_fullpath(param('blog_media_fullpath', 'string', ''));
                $this->set_media_url(param('blog_media_url', 'string', ''));
                // check params
                switch ($this->get('media_location')) {
                    case 'custom':
                        // custom path and URL
                        global $demo_mode, $media_path;
                        if ($this->get('media_fullpath') == '') {
                            param_error('blog_media_fullpath', T_('Media dir location') . ': ' . T_('You must provide the full path of the media directory.'));
                        }
                        if (!preg_match('#^https?://#', $this->get('media_url'))) {
                            param_error('blog_media_url', T_('Media dir location') . ': ' . T_('You must provide an absolute URL (starting with <code>http://</code> or <code>https://</code>)!'));
                        }
                        if ($demo_mode) {
                            $canonical_fullpath = get_canonical_path($this->get('media_fullpath'));
                            if (!$canonical_fullpath || strpos($canonical_fullpath, $media_path) !== 0) {
                                param_error('blog_media_fullpath', T_('Media dir location') . ': in demo mode the path must be inside of $media_path.');
                            }
                        }
                        break;
                    case 'subdir':
                        global $media_path;
                        if ($this->get('media_subdir') == '') {
                            param_error('blog_media_subdir', T_('Media dir location') . ': ' . T_('You must provide the media subdirectory.'));
                        } else {
                            // Test if it's below $media_path (subdir!)
                            $canonical_path = get_canonical_path($media_path . $this->get('media_subdir'));
                            if (!$canonical_path || strpos($canonical_path, $media_path) !== 0) {
                                param_error('blog_media_subdir', T_('Media dir location') . ': ' . sprintf(T_('Invalid subdirectory &laquo;%s&raquo;.'), format_to_output($this->get('media_subdir'))));
                            } else {
                                // Validate if it's a valid directory name:
                                $subdir = no_trailing_slash(substr($canonical_path, strlen($media_path)));
                                if ($error = validate_dirname($subdir)) {
                                    param_error('blog_media_subdir', T_('Media dir location') . ': ' . $error);
                                    syslog_insert(sprintf('Invalid name is detected for folder %s', '<b>' . $subdir . '</b>'), 'warning', 'file');
                                }
                            }
                        }
                        break;
                }
            }
            if (!param_errors_detected() && !empty($old_media_dir)) {
                // No error were detected before and possibly the media directory path was updated, check if it can be managed
                $this->check_media_dir_change($old_media_dir, isset($old_media_location) ? $old_media_location : NULL);
            }
        }
        return !param_errors_detected();
    }
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     $this->init_display($params);
     global $blog;
     // Get a list of quoted blog IDs
     $blog_ids = sanitize_id_list($this->disp_params['blog_ids'], true);
     if (empty($blog) && empty($blog_ids)) {
         // Nothing to display
         return;
     } elseif (empty($blog_ids)) {
         // Use current Blog
         $blog_ids = $blog;
     }
     $results = get_tags($blog_ids, $this->disp_params['max_tags'], $this->disp_params['filter_list'], true);
     if (empty($results)) {
         // No tags!
         return;
     }
     $BlogCache =& get_BlogCache();
     $max_count = $results[0]->tag_count;
     $min_count = $results[count($results) - 1]->tag_count;
     $count_span = max(1, $max_count - $min_count);
     $max_size = $this->disp_params['tag_max_size'];
     $min_size = $this->disp_params['tag_min_size'];
     $size_span = $max_size - $min_size;
     if ($this->disp_params['tag_ordering'] == 'ASC') {
         usort($results, array($this, 'tag_cloud_cmp'));
     } else {
         if ($this->disp_params['tag_ordering'] == 'RAND') {
             shuffle($results);
         }
     }
     echo $this->disp_params['block_start'];
     $this->disp_title();
     echo $this->disp_params['tag_cloud_start'];
     $count = 0;
     foreach ($results as $row) {
         if ($count > 0) {
             echo $this->disp_params['tag_separator'];
         }
         // If there's a space in the tag name, quote it:
         $tag_name_disp = strpos($row->tag_name, ' ') ? '&laquo;' . format_to_output($row->tag_name, 'htmlbody') . '&raquo;' : format_to_output($row->tag_name, 'htmlbody');
         $size = floor($row->tag_count * $size_span / $count_span + $min_size);
         $l_Blog = $BlogCache->get_by_id($row->cat_blog_ID);
         echo $l_Blog->get_tag_link($row->tag_name, $tag_name_disp, array('style' => 'font-size:' . $size . 'pt;', 'title' => sprintf(T_('Display posts tagged with &laquo;%s&raquo;'), $row->tag_name)));
         $count++;
     }
     echo $this->disp_params['tag_cloud_end'];
     echo $this->disp_params['block_end'];
     return true;
 }