b2evolution PHP Cross Reference Blogging Systems

Source: /inc/collections/model/_collsettings.class.php - 305 lines - 11807 bytes - Summary - Text - Print

Description: This file implements the CollectionSettings class which handles coll_ID/name/value triplets for collections/blogs. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the CollectionSettings class which handles
   4   * coll_ID/name/value triplets for collections/blogs.
   5   *
   6   * This file is part of the evoCore framework - {@link http://evocore.net/}
   7   * See also {@link http://sourceforge.net/projects/evocms/}.
   8   *
   9   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * }}
  22   *
  23   * @package evocore
  24   *
  25   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  26   * @author fplanque: Francois PLANQUE
  27   *
  28   * @version $Id: _collsettings.class.php 6136 2014-03-08 07:59:48Z manuel $
  29   *
  30   */
  31  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  32  
  33  load_class( 'settings/model/_abstractsettings.class.php', 'AbstractSettings' );
  34  
  35  /**
  36   * Class to handle the settings for collections/blogs
  37   *
  38   * @package evocore
  39   */
  40  class CollectionSettings extends AbstractSettings
  41  {
  42      /**
  43       * The default settings to use, when a setting is not defined in the database.
  44       *
  45       * @access protected
  46       */
  47      var $_defaults = array(
  48          // Home page settings:
  49              'what_to_show'           => 'posts',        // posts, days
  50              'main_content'           => 'normal',
  51              'posts_per_page'         => '5',
  52              'canonical_homepage'     => 1,                // Redirect homepage to its canonical Url?
  53              'relcanonical_homepage'  => 1,                // If no 301, fall back to rel="canoncial" ?
  54              'default_noindex'        => '0',            // META NOINDEX on Default blog page
  55              // the following are actually general params but are probably best understood if being presented with the home page params
  56              'orderby'         => 'datestart',
  57              'orderdir'        => 'DESC',
  58              'title_link_type' => 'permalink',
  59              'permalinks'      => 'single',                // single, archive, subchap
  60  
  61          // Page 2,3,4..; settings:
  62              'paged_noindex' => '1',                        // META NOINDEX on following blog pages
  63              'paged_nofollowto' => '0',                    // NOFOLLOW on links to following blog pages
  64  
  65          // Single post settings:
  66              'canonical_item_urls' => 1,                    // Redirect posts to their canonical Url?
  67              'relcanonical_item_urls' => 1,                // If no 301, fall back to rel="canoncial" ?
  68              'single_links'   => 'short',
  69              'single_item_footer_text' => '',
  70              'count_custom_double' => 0,
  71              'count_custom_varchar' => 0,
  72              'show_location_coordinates' => 0,
  73              'tags_meta_keywords' => 1,
  74              'slug_limit' => 5,
  75  
  76          // Comment settings:
  77              // 'new_feedback_status' => 'review',        // Default status for new anonymous comments: 'published', 'community', 'protected', 'private', 'review', 'draft' or 'deprecated'. We don't specify a general default because it depends from the blog type ( see @Blog::get_setting() )
  78              // 'moderation_statuses' => NULL,            // Possible values are a list of statuses from: 'community', 'protected', 'review', 'draft', but we don't specify a general default because it depends from the blog type ( see @Blog::get_setting() )
  79              'allow_comments' => 'any',
  80              'allow_view_comments' => 'any',                // 'any', 'registered', 'member', 'moderator'
  81              'disable_comments_bypost' => '1',
  82              'allow_anon_url' => '0',
  83              'allow_attachments' => 'registered',
  84              'max_attachments' => '',
  85              'allow_rating_items' => 'never',
  86              'allow_rating_comment_helpfulness' => '0',
  87              'comments_orderdir' => 'ASC',
  88              'threaded_comments' => '0',
  89              'paged_comments' => '0',
  90              'comments_per_page' => 1000,
  91              'comments_avatars' => '1',
  92              'comments_latest' => '1',
  93              'comments_detect_email' => 1,
  94              'comments_register' => 1,
  95              'comment_quick_moderation' => 'expire',        // Comment quick moderation can be 'never', 'expire' - Links expire on first edit action, and 'always'
  96  
  97          // Archive settings:
  98              'arcdir_noindex' => '1',                    // META NOINDEX on Archive directory
  99              'archive_mode'   => 'monthly',                // monthly, weekly, daily, postbypost
 100              'archive_links'  => 'extrapath',            // param, extrapath
 101              'canonical_archive_urls' => 1,                // Redirect archives to their canonical URL?
 102              'relcanonical_archive_urls' => 1,            // If no 301, fall back to rel="canoncial" ?
 103              'archive_content'   => 'excerpt',
 104              'archive_posts_per_page' => '100',
 105              'archive_noindex' => '1',                    // META NOINDEX on Archive pages
 106              'archive_nofollowto' => '0',                // NOFOLLOW on links to archive pages
 107              'archives_sort_order' => 'date',
 108  
 109          // Chapter/Category settings:
 110              'catdir_noindex' => '1',                    // META NOINDEX on Category directory
 111              'chapter_links'  => 'chapters',                // 'param_num', 'subchap', 'chapters'
 112              'canonical_cat_urls' => 1,                    // Redirect categories to their canonical URL?
 113              'relcanonical_cat_urls' => 1,                // If no 301, fall back to rel="canoncial" ?
 114              'chapter_content'   => 'excerpt',
 115              'chapter_posts_per_page' => 100,
 116              'chapter_noindex'   => '1',                    // META NOINDEX on Category pages
 117              'category_prefix'   => '',
 118              'categories_meta_description' => 1,
 119  
 120          // Tag page settings:
 121              'tag_links'  => 'colon',                    // 'param', 'semicolon' -- fp> we want this changed to prefix only for new blogs only
 122              'canonical_tag_urls' => 1,                    // Redirect tag pages to their canonical Url?
 123              'relcanonical_tag_urls' => 1,                // If no 301, fall back to rel="canoncial" ?
 124              'tag_content'       => 'excerpt',
 125              'tag_posts_per_page' => 100,
 126              'tag_noindex' => '1',                          // META NOINDEX on Tag pages
 127              'tag_prefix' => '',                            // fp> fp> we want this changed to prefix only for new blogs only
 128              'tag_rel_attrib' => 1,                        // rel="tag" attribute for tag links (http://microformats.org/wiki/rel-tag) -- valid only in prefix-only mode
 129  
 130          // Other filtered pages:
 131              'filtered_noindex' => '1',                    // META NOINDEX on other filtered pages
 132              'filtered_content'  => 'excerpt',
 133  
 134          // Other pages:
 135              'feedback-popup_noindex' => '1',            // META NOINDEX on Feedback popups
 136              'msgform_noindex' => '1',                    // META NOINDEX on Message forms
 137              'special_noindex' => '1',                    // META NOINDEX on other special pages
 138              '404_response' => '404',
 139              'help_link' => 'slug',
 140  
 141          // Feed settings: (should probably be duplicated for comment feed, category feeds, etc...)
 142              'atom_redirect' => '',
 143              'rss2_redirect' => '',
 144              'feed_content'   => 'normal',
 145              'posts_per_feed' => '8',
 146              'xml_item_footer_text' => '<p><small><a href="$perm_url$">Original post</a> blogged on <a href="http://b2evolution.net/">b2evolution</a>.</small></p>',
 147              'image_size'    => 'fit-320x320',
 148  
 149          // Comment feed settings:
 150              'comment_feed_content' => 'normal',
 151              'comments_per_feed' => '8',
 152  
 153          // Sitemaps settings:
 154              'enable_sitemaps' => 1,
 155  
 156          // General settings:
 157              'ajax_form_enabled' => 0,                    // Comment and contacts forms will be fetched by javascript
 158              'ajax_form_loggedin_enabled' => 0,            // Also use JS forms for logged in users
 159              'cache_enabled' => 0,
 160              'cache_enabled_widgets' => 0,
 161              'in_skin_login' => 0,                        // Use in skin login form every time it's possible
 162              'in_skin_editing' => 0,
 163              'default_cat_ID' => NULL,                    // Default Cat for new posts
 164              'require_title' => 'required',                // Is a title for items required ("required", "optional", "none")
 165              'ping_plugins'   => 'ping_pingomatic,ping_b2evonet,evo_twitter', // ping plugin codes, separated by comma
 166              'allow_subscriptions' => 0,                    // Don't allow email subscriptions by default
 167              'allow_item_subscriptions' => 0,            // Don't allow email subscriptions for a specific post by default
 168              'use_workflow' => 0,                        // Don't use workflow by default
 169              'aggregate_coll_IDs' => '',
 170              'blog_footer_text' => '&copy;$year$ by $owner$',
 171              'max_footer_credits' => 3,
 172              'enable_goto_blog' => 'blog',  // 'no' - No redirect, 'blog' - Go to blog after publishing post, 'post' - Redirect to permanent post url
 173              'editing_goto_blog' => 'post', // 'no' - No redirect, 'blog' - Go to blog after editing post, 'post' - Redirect to permanent post url
 174              // 'default_post_status' => 'draft',        // Default status for new posts ("published", "community", "protected", "private", "review", "draft", "deprecated", "redirected"). We don't specify a general default because it depends from the blog type ( see @Blog::get_setting() )
 175              'post_categories' => 'main_extra_cat_post', // Post category setting
 176              'post_navigation' => 'same_blog',           // Default post by post navigation should stay in the same blog, category or author
 177              'blog_head_includes' => '',
 178              'blog_footer_includes' => '',
 179              'allow_html_post' => 1, // Allow HTML in posts
 180              'allow_html_comment' => 1, // Allow HTML in comments
 181  
 182          // Other settings:
 183              'image_size_user_list' => 'crop-top-32x32', // Used in disp = users
 184              'image_size_messaging' => 'crop-top-32x32', // Used in disp = threads
 185  
 186          // Time frame settings:
 187              'timestamp_min' => 'yes',
 188              'timestamp_max' => 'no',
 189  
 190          // Back-end settings, these can't be modified by the users, it will be modified from code:
 191              'last_invalidation_timestamp' => 0,
 192  
 193          // Location
 194              'location_country'   => 'hidden', // Editing mode of country for item:   "optional" | "required" | "hidden"
 195              'location_region'    => 'hidden', // Editing mode of region for item:    "optional" | "required" | "hidden"
 196              'location_subregion' => 'hidden', // Editing mode of subregion for item: "optional" | "required" | "hidden"
 197              'location_city'      => 'hidden', // Editing mode of city for item:      "optional" | "required" | "hidden"
 198          );
 199  
 200      /**
 201       *  Configurable default settings
 202       *
 203       *  These settings default is defined in general settings
 204       *
 205       *  Skin settings:
 206       *  'normal_skin_ID' => NULL,
 207       *  'mobile_skin_ID' => NULL,
 208       *  'tablet_skin_ID' => NULL,
 209       */
 210  
 211  
 212      /**
 213       * When custom fields are changed it may require other updates on different tables.
 214       * These changes must be processed only if the collection settings were also saved.
 215       *
 216       * @access private
 217       *
 218       * @var array which contains update/delete queries
 219       */
 220      var $update_cascade = array();
 221  
 222  
 223      /**
 224       * Constructor
 225       */
 226  	function CollectionSettings()
 227      {
 228          parent::AbstractSettings( 'T_coll_settings', array( 'cset_coll_ID', 'cset_name' ), 'cset_value', 1 );
 229      }
 230  
 231      /**
 232       * Loads the settings. Not meant to be called directly, but gets called
 233       * when needed.
 234       *
 235       * @access protected
 236       * @param string First column key
 237       * @param string Second column key
 238       * @return boolean
 239       */
 240  	function _load( $coll_ID, $arg )
 241      {
 242          if( empty( $coll_ID ) )
 243          {
 244              return false;
 245          }
 246  
 247          return parent::_load( $coll_ID, $arg );
 248      }
 249  
 250  
 251      /**
 252       * Commit changed settings to DB.
 253       *
 254       * @return boolean true, if settings have been updated; false otherwise
 255       */
 256  	function dbupdate()
 257      {
 258          global $DB;
 259  
 260          if( !parent::dbupdate() )
 261          { // Collection settings couldn't been updated successful
 262              return false;
 263          }
 264  
 265          if( !empty( $this->update_cascade ) )
 266          { // process update cascade commands
 267              foreach( $this->update_cascade as $query )
 268              {
 269                  if( $DB->query( $query ) === false )
 270                  { // error occured
 271                      return false;
 272                  }
 273              }
 274              $this->update_cascade = array();
 275          }
 276  
 277          return true;
 278      }
 279  
 280  
 281      /**
 282       * Add an update/delete query which must be processed if collection settings will be updated
 283       *
 284       * @param string query
 285       */
 286  	function add_update_cascade( $query )
 287      {
 288          if( empty( $query ) )
 289          {
 290              return;
 291          }
 292          $this->update_cascade[] = $query;
 293      }
 294  
 295  
 296      /**
 297       * Remove all registered update query
 298       */
 299  	function clear_update_cascade()
 300      {
 301          $this->update_cascade = array();
 302      }
 303  }
 304  
 305  ?>

title

Description

title

Description

title

Description

title

title

Body