<?php

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
	exit();
}

class setup_articles
{
	/**
	 * Execute selected method
	 *
	 * @access	public
	 * @param	object		Registry object
	 * @return	void
	 */
	public function doExecute( ipsRegistry $registry ) 
	{
		/* Make object */
		$this->registry =  $registry;
		$this->DB       =  $this->registry->DB();
		$this->settings =& $this->registry->fetchSettings();
		$this->request  =& $this->registry->fetchRequest();
		$this->cache    =  $this->registry->cache();
		$this->caches   =& $this->registry->cache()->fetchCaches();
		
		$this->createDatabases();
	}
	
	/**
	 * We need to create the article database
	 *
	 * @access	public
	 * @return	array
	 */
	public function createDatabases()
	{
		/* Get Data */
		$data			= $this->getDatabaseData();
		$_fieldIds		= array();
		$_catIds		= array();
		$_databaseId	= 0;

		//-----------------------------------------
		// Articles
		//-----------------------------------------
		
		/* Insert DB, need to fix: database_database, database_field_title, database_field_content */
		$this->DB->insert( "ccs_databases", $data['databases']['articles'] );

		$_databaseId	= $this->DB->getInsertId();
		$driver         = $this->registry->dbFunctions()->getDriverType();
		
		/* Now the fields */
		foreach( $data['fields']['articles'] as $field )
		{
			$field['field_database_id']	= $_databaseId;
			
			$this->DB->insert( "ccs_database_fields", $field );
			
			$_fieldId	= $this->DB->getInsertId();
			$_fieldIds[ $field['field_key'] ]	= 'field_' . $_fieldId;
		}

		/* Update database */
		$_dbUpdate	= array(
							'database_database'			=> "ccs_custom_database_" . $_databaseId,
							'database_field_title'		=> $_fieldIds['article_title'],
							'database_field_content'	=> $_fieldIds['article_body'],
							);

		$this->DB->update( "ccs_databases", $_dbUpdate, "database_id=" . $_databaseId );
		
		$data['databases']['articles']['database_id']				= $_databaseId;
		$data['databases']['articles']['database_database']			= "ccs_custom_database_" . $_databaseId;
		$data['databases']['articles']['database_field_title']		= $_fieldIds['article_title'];
		$data['databases']['articles']['database_field_content']	= $_fieldIds['article_body'];
		
		/* Permission index */
		$_permissions	= array(
								'app'				=> 'ccs',
								'perm_type'			=> 'database',
								'perm_type_id'		=> $_databaseId,
								'perm_view'			=> '*',
								'perm_2'			=> '*',
								'perm_3'			=> '*',
								'perm_4'			=> '*',
								'perm_5'			=> '*',
								'perm_6'			=> '*',
								);

		$this->DB->insert( "permission_index", $_permissions );
		
		/* Now the categories */
		foreach( $data['categories']['articles'] as $category )
		{
			$category['category_database_id']	= $_databaseId;
			
			/* Fix parent id */
			if( $category['category_parent_id'] )
			{
				$category['category_parent_id']	= $_catIds[ $category['category_parent_id'] ];
			}
			
			$this->DB->insert( "ccs_database_categories", $category );
			
			/* Store parent id */
			$_catId	= $this->DB->getInsertId();
			$_catIds[ '__' . $category['category_furl_name'] . '__' ]	= $_catId;
		}
		
		/* Get driver-specific create table file */
		require_once( IPS_ROOT_PATH . '/applications_addon/ips/ccs/setup/articles_' . $driver . '.php' );
		$_className	= "articleTables_" . $driver;
		
		$_tableCreator	= new $_className( $this->registry );
		$_tableCreator->createTable( $_databaseId, $_fieldIds );
		
		/* Populate the table */
		foreach( $data['records']['articles'] as $record )
		{
			$record['category_id']	= $_catIds[ $record['category_id'] ];
			$newRecord				= array();
			
			foreach( $record as $k => $v )
			{
				$k	= str_replace( "_field_title", $_fieldIds['article_title'], $k );
				$k	= str_replace( "_field_body", $_fieldIds['article_body'], $k );
				$k	= str_replace( "_field_date", $_fieldIds['article_date'], $k );
				$k	= str_replace( "_field_homepage", $_fieldIds['article_homepage'], $k );
				$k	= str_replace( "_field_comments", $_fieldIds['article_comments'], $k );
				$k	= str_replace( "_field_image", $_fieldIds['article_image'], $k );
				$k	= str_replace( "_field_expiry", $_fieldIds['article_expiry'], $k );
				
				$newRecord[ $k ]	= $v;
			}

			$this->DB->insert( "ccs_custom_database_{$_databaseId}", $newRecord );
		}

		//-----------------------------------------
		// Media
		//-----------------------------------------
		
		/* Do media database if this is new install */
		if( !defined('CCS_UPGRADE') OR !CCS_UPGRADE )
		{
			$_fieldIds	= array();
			
			/* Insert DB, need to fix: database_database, database_field_title, database_field_content */
			$this->DB->insert( "ccs_databases", $data['databases']['media'] );
			
			$_databaseId	= $this->DB->getInsertId();
			
			/* Now the fields */
			foreach( $data['fields']['media'] as $field )
			{
				$field['field_database_id']	= $_databaseId;
				
				$this->DB->insert( "ccs_database_fields", $field );
				
				$_fieldId	= $this->DB->getInsertId();
				$_fieldIds[ $field['field_key'] ]	= 'field_' . $_fieldId;
			}
			
			/* Update database */
			$_dbUpdate	= array(
								'database_database'			=> "ccs_custom_database_" . $_databaseId,
								'database_field_title'		=> $_fieldIds['1b38adf8e5f6baeb9b340e40c22c41ec'],
								'database_field_content'	=> $_fieldIds['21f0f3093b5b6068740d7d8ba4250471'],
								);
	
			$this->DB->update( "ccs_databases", $_dbUpdate, "database_id=" . $_databaseId );
			
			$data['databases']['media']['database_id']				= $_databaseId;
			$data['databases']['media']['database_database']		= "ccs_custom_database_" . $_databaseId;
			$data['databases']['media']['database_field_title']		= $_fieldIds['1b38adf8e5f6baeb9b340e40c22c41ec'];
			$data['databases']['media']['database_field_content']	= $_fieldIds['21f0f3093b5b6068740d7d8ba4250471'];
			
			/* Permission index */
			$_permissions	= array(
									'app'				=> 'ccs',
									'perm_type'			=> 'database',
									'perm_type_id'		=> $_databaseId,
									'perm_view'			=> '*',
									'perm_2'			=> '*',
									'perm_3'			=> '*',
									'perm_4'			=> '*',
									'perm_5'			=> '*',
									'perm_6'			=> '*',
									);
	
			$this->DB->insert( "permission_index", $_permissions );
			
			/* Now the categories */
			foreach( $data['categories']['media'] as $category )
			{
				$category['category_database_id']	= $_databaseId;
				
				/* Fix parent id */
				if( $category['category_parent_id'] )
				{
					$category['category_parent_id']	= $_catIds[ $category['category_parent_id'] ];
				}
				
				$this->DB->insert( "ccs_database_categories", $category );
				
				/* Store parent id */
				$_catId	= $this->DB->getInsertId();
				$_catIds[ '__' . $category['category_furl_name'] . '__' ]	= $_catId;
			}
			
			/* Create table */
			$_tableCreator->createTable( $_databaseId, $_fieldIds );
			
			/* Populate the table */
			foreach( $data['records']['media'] as $record )
			{
				$record['category_id']	= $_catIds[ $record['category_id'] ];
				$newRecord				= array();
				
				foreach( $record as $k => $v )
				{
					$k	= str_replace( "_field_title", $_fieldIds['1b38adf8e5f6baeb9b340e40c22c41ec'], $k );
					$k	= str_replace( "_field_ytid", $_fieldIds['1b0a9280fdf9d2054e7867818e09c51b'], $k );
					$k	= str_replace( "_field_description", $_fieldIds['21f0f3093b5b6068740d7d8ba4250471'], $k );
					$k	= str_replace( "_field_image", $_fieldIds['851d0d5e09912f9a24686facb33a55f1'], $k );
					$k	= str_replace( "_field_length", $_fieldIds['cd7a8a9520fb437e3802261ed1534f61'], $k );
					
					$newRecord[ $k ]	= $v;
				}
				
				$this->DB->insert( "ccs_custom_database_{$_databaseId}", $newRecord );
			}
		}
		
		//-----------------------------------------
		// Caches
		//-----------------------------------------
		
		/* Rebuild category data */
		require_once( IPSLib::getAppDir('ccs') . "/sources/databases/categories.php" );
		$catsLib	= new ccs_categories( $this->registry );
		$catsLib->init( $data['databases']['articles'] );
		$catsLib->recache( 0 );
		
		/* Do media database if this is new install */
		if( !defined('CCS_UPGRADE') OR !CCS_UPGRADE )
		{
			$catsLib->init( $data['databases']['media'] );
			$catsLib->recache( 0 );
		}
		
		/* And rebuild caches */
		/* Caches already automatically rebuilt later in upgrade routine */
		//$this->cache->rebuildCache( 'ccs_databases' );
		//$this->cache->rebuildCache( 'ccs_fields' );

		/* Create or update front page cache */
		$templates	= $this->getTemplates();
		
		$cache		= array(
							'categories'		=> '*',
							'limit'				=> 10,
							'sort'				=> 'record_updated',
							'order'				=> 'desc',
							'pinned'			=> 0,
							'template'			=> $templates['frontpage'],
							);

		$this->cache->setCache( 'ccs_frontpage', $cache, array( 'array' => 1 ) );
	}
	
	/**
	 * Define the data for the databases to be inserted
	 *
	 * @access	public
	 * @return	array
	 */
	public function getDatabaseData()
	{
		/* Get templates */
		$templates	= $this->getTemplates();
		$member		= $this->getMember();
		
		/**
		 * Define fields
		 */
		$fields			= array(
								/* Articles */
								'articles' => array(
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Title",
										'field_description'			=> '',
										'field_key'					=> 'article_title',
										'field_type'				=> "input",
										'field_required'			=> 1,
										'field_user_editable'		=> 1,
										'field_position'			=> 1,
										'field_max_length'			=> 500,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 50,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Body",
										'field_description'			=> '',
										'field_key'					=> 'article_body',
										'field_type'				=> "editor",
										'field_required'			=> 1,
										'field_user_editable'		=> 1,
										'field_position'			=> 2,
										'field_max_length'			=> 0,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Publish Date",
										'field_description'			=> '',
										'field_key'					=> 'article_date',
										'field_type'				=> "date",
										'field_required'			=> 1,
										'field_user_editable'		=> 1,
										'field_position'			=> 3,
										'field_max_length'			=> 0,
										'field_extra'				=> 'short',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> 'Today',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Expiry Date",
										'field_description'			=> 'After this date, the article will only display in the archives',
										'field_key'					=> 'article_expiry',
										'field_type'				=> "date",
										'field_required'			=> 0,
										'field_user_editable'		=> 1,
										'field_position'			=> 4,
										'field_max_length'			=> 0,
										'field_extra'				=> 'short',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 0,
										'field_display_display'		=> 0,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Comment Cutoff",
										'field_description'			=> 'After this date, comments will no longer be allowed',
										'field_key'					=> 'article_cutoff',
										'field_type'				=> "date",
										'field_required'			=> 0,
										'field_user_editable'		=> 1,
										'field_position'			=> 5,
										'field_max_length'			=> 0,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 0,
										'field_display_display'		=> 0,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Show on front page",
										'field_description'			=> '',
										'field_key'					=> 'article_homepage',
										'field_type'				=> "checkbox",
										'field_required'			=> 0,
										'field_user_editable'		=> 1,
										'field_position'			=> 6,
										'field_max_length'			=> 0,
										'field_extra'				=> '1=Yes',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '1',
										'field_display_listing'		=> 0,
										'field_display_display'		=> 0,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Allow Comments?",
										'field_description'			=> '',
										'field_key'					=> 'article_comments',
										'field_type'				=> "radio",
										'field_required'			=> 0,
										'field_user_editable'		=> 1,
										'field_position'			=> 7,
										'field_max_length'			=> 0,
										'field_extra'				=> '1=Yes
0=No',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '1',
										'field_display_listing'		=> 0,
										'field_display_display'		=> 0,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Article Image",
										'field_description'			=> '',
										'field_key'					=> 'article_image',
										'field_type'				=> "upload",
										'field_required'			=> 0,
										'field_user_editable'		=> 1,
										'field_position'			=> 8,
										'field_max_length'			=> 0,
										'field_extra'				=> 'gif,jpg,jpeg,png',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									),

								/* Media */
								'media' => array(
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Video Title",
										'field_description'			=> 'The main title of this video',
										'field_key'					=> '1b38adf8e5f6baeb9b340e40c22c41ec',
										'field_type'				=> "input",
										'field_required'			=> 1,
										'field_user_editable'		=> 0,
										'field_position'			=> 1,
										'field_max_length'			=> 80,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "YouTube ID",
										'field_description'			=> 'YouTube video ID',
										'field_key'					=> '1b0a9280fdf9d2054e7867818e09c51b',
										'field_type'				=> "input",
										'field_required'			=> 1,
										'field_user_editable'		=> 0,
										'field_position'			=> 2,
										'field_max_length'			=> 0,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Description",
										'field_description'			=> 'Short description of this video',
										'field_key'					=> '21f0f3093b5b6068740d7d8ba4250471',
										'field_type'				=> "textarea",
										'field_required'			=> 0,
										'field_user_editable'		=> 0,
										'field_position'			=> 3,
										'field_max_length'			=> 0,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Thumbnail",
										'field_description'			=> 'Image to represent this video in the system',
										'field_key'					=> '851d0d5e09912f9a24686facb33a55f1',
										'field_type'				=> "upload",
										'field_required'			=> 0,
										'field_user_editable'		=> 0,
										'field_position'			=> 4,
										'field_max_length'			=> 0,
										'field_extra'				=> 'gif,jpg,jpeg,png',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									array(
										'field_database_id'			=> 0,				// Fix this
										'field_name'				=> "Length",
										'field_description'			=> 'Length of this video',
										'field_key'					=> 'cd7a8a9520fb437e3802261ed1534f61',
										'field_type'				=> "input",
										'field_required'			=> 0,
										'field_user_editable'		=> 0,
										'field_position'			=> 5,
										'field_max_length'			=> 0,
										'field_extra'				=> '',
										'field_html'				=> 0,
										'field_is_numeric'			=> 0,
										'field_truncate'			=> 0,
										'field_default_value'		=> '',
										'field_display_listing'		=> 1,
										'field_display_display'		=> 1,
										'field_format_opts'			=> '',
										'field_validator'			=> '',
										),
									),
								);

		/**
		 * Define databases
		 */
		$databases		= array(
								/* Articles */
								'articles' => array(
									'database_name'					=> "Articles",
									'database_key'					=> "articles9283759273592",	// Random to prevent conflict
									'database_database'				=> "",						// Fix this
									'database_description'			=> "Manage articles",
									'database_field_count'			=> count($fields['articles']),
									'database_record_count'			=> 8,
									'database_template_categories'	=> $templates['article_categories'],
									'database_template_listing'		=> $templates['article_archives'],
									'database_template_display'		=> $templates['article_view'],
									'database_user_editable'		=> 1,
									'database_all_editable'			=> 0,
									'database_open'					=> 1,
									'database_comments'				=> 1,
									'database_rate'					=> 1,
									'database_revisions'			=> 1,
									'database_field_title'			=> "field_",				// Fix this
									'database_field_sort'			=> "record_updated",
									'database_field_direction'		=> "desc",
									'database_field_perpage'		=> 25,
									'database_comment_approve'		=> 0,
									'database_record_approve'		=> 1,
									'database_rss'					=> 0,
									'database_rss_cache'			=> null,
									'database_field_content'		=> "field_",				// Fix this
									'database_lang_sl'				=> "article",
									'database_lang_pl'				=> "articles",
									'database_lang_su'				=> "Article",
									'database_lang_pu'				=> "Articles",
									'database_comment_bump'			=> 0,
									'database_meta_keywords'		=> null,
									'database_meta_description'		=> null,
									'database_is_articles'			=> 1,
									'database_featured_article'		=> 0,
									'database_forum_record'			=> 0,
									'database_forum_comments'		=> 0,
									'database_forum_delete'			=> 0,
									'database_forum_forum'			=> 0,
									'database_forum_prefix'			=> '',
									'database_forum_suffix'			=> '',
									),

									
								/* Media */
								'media' => array(
									'database_name'					=> "Media Demo",
									'database_key'					=> "media_demo",
									'database_database'				=> "",						// Fix this
									'database_description'			=> "A media section, displaying videos. A demonstration of what is possible using the IP.Content database system.",
									'database_field_count'			=> count($fields['media']),
									'database_record_count'			=> 3,
									'database_template_categories'	=> $templates['media_categories'],
									'database_template_listing'		=> $templates['media_listing'],
									'database_template_display'		=> $templates['media_display'],
									'database_user_editable'		=> 0,
									'database_all_editable'			=> 0,
									'database_open'					=> 1,
									'database_comments'				=> 1,
									'database_rate'					=> 1,
									'database_revisions'			=> 0,
									'database_field_title'			=> "field_",				// Fix this
									'database_field_sort'			=> "record_updated",
									'database_field_direction'		=> "desc",
									'database_field_perpage'		=> 25,
									'database_comment_approve'		=> 1,
									'database_record_approve'		=> 0,
									'database_rss'					=> 0,
									'database_rss_cache'			=> null,
									'database_field_content'		=> "field_",				// Fix this
									'database_lang_sl'				=> "video",
									'database_lang_pl'				=> "videos",
									'database_lang_su'				=> "Video",
									'database_lang_pu'				=> "Videos",
									'database_comment_bump'			=> 0,
									'database_meta_keywords'		=> null,
									'database_meta_description'		=> null,
									'database_is_articles'			=> 0,
									'database_featured_article'		=> 0,
									'database_forum_record'			=> 0,
									'database_forum_comments'		=> 0,
									'database_forum_delete'			=> 0,
									'database_forum_forum'			=> 0,
									'database_forum_prefix'			=> '',
									'database_forum_suffix'			=> '',
									),
								);

		/**
		 * Define the categories
		 */
		$categories		= array(
								/* Articles */
								'articles'	=> array(
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Articles",
										'category_parent_id'			=> 0,
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Articles describing how to use the new Articles module of IP.Content",
										'category_position'				=> 1,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "articles",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Forum Integration",
										'category_parent_id'			=> '__articles__',
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Learn how to use the new forum integration features",
										'category_position'				=> 2,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "forum",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Frontpage",
										'category_parent_id'			=> '__articles__',
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Learn how to leverage the frontpage setup in IP.Content",
										'category_position'				=> 3,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "frontpage",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Pages",
										'category_parent_id'			=> 0,
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Page management articles",
										'category_position'				=> 4,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "pages",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Miscellaneous",
										'category_parent_id'			=> 0,
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Articles describing how to use various other sections of IP.Content",
										'category_position'				=> 5,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "misc",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Databases",
										'category_parent_id'			=> '__misc__',
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Database related articles for IP.Content",
										'category_position'				=> 6,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "databases",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Templates",
										'category_parent_id'			=> '__misc__',
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Configure your templates to get the most out of IP.Content",
										'category_position'				=> 7,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "templates",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Media",
										'category_parent_id'			=> '__misc__',
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Manage your multimedia with IP.Content",
										'category_position'				=> 8,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "media",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> $templates['frontpage'],
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									),
									
								/* Media */
								'media'	=> array(
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "New Features",
										'category_parent_id'			=> 0,
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Check out how to use some of the latest features of IP.Content",
										'category_position'				=> 1,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "new",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> 0,
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									array(
										'category_database_id'			=> 0,				// Fix this
										'category_name'					=> "Other",
										'category_parent_id'			=> 0,
										'category_last_record_id'		=> 0,
										'category_last_record_date'		=> 0,
										'category_last_record_member'	=> 0,
										'category_last_record_name'		=> '',
										'category_last_record_seo_name'	=> '',
										'category_description'			=> "Other videos you may be interested in",
										'category_position'				=> 2,
										'category_records'				=> 0,
										'category_show_records'			=> 1,
										'category_has_perms'			=> 0,
										'category_rss'					=> '1;12;20;0',
										'category_rss_cache'			=> null,
										'category_furl_name'			=> "other",
										'category_meta_keywords'		=> '',
										'category_meta_description'		=> '',
										'category_template'				=> 0,
										'category_forum_override'		=> 0,
										'category_forum_record'			=> 0,
										'category_forum_comments'		=> 0,
										'category_forum_delete'			=> 0,
										'category_forum_forum'			=> 0,
										'category_forum_prefix'			=> '',
										'category_forum_suffix'			=> '',
										),
									),
								);

		/* Records */
		$records		= array(
								/* Articles */
								'articles'	=> array(
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> '259487fad808714985558fe5d59a51e3',
										'category_id'			=> '__forum__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'promoting-posts-to-articles',
										'_field_title'			=> "Promoting Posts to Articles",
										'_field_body'			=> "Beginning with IP.Content 2.0, you can now promote forum posts to your articles section in IP.Content.  <br />
<br />
The administrator can configure the specifics of this feature in the ACP under My Apps -&gt; IP.Content -&gt; Promote Article Settings.  You can turn the system on and off, control which groups can copy and move posts to the articles section, and specify a few other details for the feature.  A new hook is included with IP.Content which adds a button to each post labeled &quot;Promote to Article&quot;.  This button only shows up if you have permission to use the feature based on the ACP configuration.<br />
<br />
When clicked, the button will take you to a new form where you can formalize the details of the new article.  You can tweak the text and title, upload an image, and specify other pertinent details.  If you are able to both move and copy posts to the articles section, you will also be asked which type of promotion you wish to use.  Upon submitting the form, IP.Content handles the rest.<br />
<br />
This new feature can be used to showcase important content otherwise hidden in your forums by pushing this content to your frontpage.  It is then up to you whether you want a copy made in the articles section (leaving the original post in tact), whether you want to actually move the post to the articles section, and whether you want any cross-linking left in place.  With such powerful options, we are sure you will find many uses for this new promotion tool in IP.Content 2.0.",
										'_field_date'			=> '1268694000',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "2d39a5ac26bb53702ae33132e7ae5b4e.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> 'c9be451b983a9595b775a1db471fb7e3',
										'category_id'			=> '__frontpage__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'what-is-a-frontpage',
										'_field_title'			=> "What Is A Frontpage?",
										'_field_body'			=> "IP.Content 2.0 uses the term &quot;frontpage&quot; to refer to both the homepage of the Articles module, and the landing page of each individual category.  We have introduced this new navigational structure to better allow you to showcase content, while presenting it in a standardized format that your users will be able to understand and jump into without assistance.<br />
<br />
Firstly, you will now be able to define &quot;frontpage&quot; templates in the ACP for the Articles module.  IP.Content 2.0 will ship with 3 defaults:<br />
<br />
[list][*][b]1x2x2 Layout[/b]<br />
This layout will display articles in a traditional &quot;news&quot; style layout.<br />
[*][b]Blog format[/b]<br />
This format will display articles in a blog-style format.<br />
[*][b]Single column[/b]<br />
This layout will force articles to display in a single column, one per row.[/list]<br />
<br />
You can use one or more of these frontpage layouts, or you can create your own.  Experiment with displaying articles in different formats on your homepage to determine which layout your users like best.<br />
<br />
Articles must be set to &quot;Show on front page&quot; in order for them to display on the homepage frontpage.<br />
<br />
In addition to the homepage frontpage, each category has it&#39;s own frontpage.  The category frontpage functions identically to the homepage frontpage, except for two important factors:<br />
<br />
[list][*]Only records from within that category (and it&#39;s subcategories) will be displayed<br />
[*]The &quot;Show on front page&quot; setting is not honored for the category frontpage[/list]<br />
<br />
You will be able to easily review and manage the articles set to display on the frontpage from a new section of the ACP labeled &quot;Frontpage Manager&quot;.  We feel that this new area of the articles section will help showcase important articles and increase user interaction with your articles section.",
										'_field_date'			=> '1268780400',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "9a9fa3438b80e405b838b7c7227785c8.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> 'fdba36f3e898e8149622704f4c7ee6ce',
										'category_id'			=> '__media__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'media-management',
										'_field_title'			=> "Media Management",
										'_field_body'			=> "The media module in the IP.Content 2.0 ACP section allows you to quickly and easily manage multimedia files you may need to use with IP.Content.  While you can certainly upload your files through FTP, or link to offsite files, you may find it easier to upload the files using the media section of the ACP, and then copy the links for use within pages, templates, and blocks.<br />
<br />
From within the media module, you can create folders, upload files, move files and folders, rename files and folders, and delete files and folders.  Files can be listed and you can click on a file to view it (or right click on the file to copy the link).<br />
<br />
This simple tool can be a timesaver when you simply need to upload an image quickly for use within a page template.  The media folder is defined in the media_path.php file in your forum root directory, giving you the freedom to move and organize your paths as needed.",
										'_field_date'			=> '1268780400',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "4453d2bd25df7d318936bb300ef94203.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> 'd367083d21baf5bac9eeffff0b703843',
										'category_id'			=> '__pages__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'page-management',
										'_field_title'			=> "Page Management",
										'_field_body'			=> "The page management module interface has been overhauled for IP.Content 2.0 to make it easier to manage your pages in the ACP.<br />
<br />
Firstly, the folder navigation utilizes AJAX to load the folder contents inline without requiring you to visit a new page to view the contents of the folder.  We found that folder navigation was a slow process, especially when working with many files and folders, so we wanted to speed up the interaction with the software in this particular area.<br />
<br />
We have also updated some common management features to utilize AJAX to help facilitate management of your pages.  Actions like clearing folders and deleting folders, for instance, will now occur without page refreshes, making your managerial activities flow smoother and quicker.<br />
<br />
Additionally, the interface as a whole has been updated to provide a nicer, smoother feel for the page management areas.  In practice, we found that many administrators spend the majority of their time setting up and utilizing IP.Content in the page management areas, so we wanted to update the user interface to make this experience as easy and enjoyable as possible.  Minor details like confirmation dialogs have been updated to bring everything together for a more consistent feel.<br />
<br />
A new filter bar, utilizing AJAX to retrieve the results without the need for a page refresh, has also been added to the page management area.  You can begin typing in the name of a page and a live-search action will occur in the background, showing you the results of your search as you type.  If you have many pages and many folders (and many pages within those many folders), you will find that using the filter bar to locate your pages can dramatically speed up your navigation of IP.Content within the page management areas of the ACP.<br />
<br />
Overall, we&#39;ve modernized the IP.Content page management area of the ACP, polishing up the little details, in an effort to make your experience all the more pleasant.",
										'_field_date'			=> '1268694000',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "01f350478adfbe32287d8e1bbbaa78d1.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> '169cbc593b8a742bebe36fd26ffdedd4',
										'category_id'			=> '__templates__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'template-management',
										'_field_title'			=> "Template Management",
										'_field_body'			=> "In IP.Content 2.0, you will notice that there are 3 separate template sections of the ACP:<br />
<br />
[list][*][b]Page Templates[/b]<br />
[*][b]Database Templates[/b]<br />
[*][b]Article Templates[/b][/list]<br />
<br />
In IP.Content 1.x, database and page templates were combined into a single &quot;Templates&quot; section, which worked fine for our original intentions.  However, with the introduction of a separate Articles module, and additional template types related to the articles module, we decided to separate the templates so that each template type is displayed separately.  This should help finding and editing your templates easier in practice, as you will be able to filter the template types and work with fewer at a time.<br />
<br />
Within each templates section, you can create containers to group your templates into logical groupings.  For instance, you may wish to create a grouping for each database you create, and then place the database templates appropriately into the container representing the database itself.  Or you may wish to create multiple front page templates, and group them all together in the article templates area.  You can use containers for whatever purposes you may have, or not at all: it&#39;s up to you&#33;<br />
<br />
Templates can be reordered by dragging and dropping the rows up and down, and they can be moved from one container to another via drag n drop as well.  <br />
<br />
Certain meta data about the templates are stored when you create new database or article templates, allowing IP.Content to tailor other areas of the ACP to help you out.  For example, in IP.Content 1.x the software did not &quot;remember&quot; what kind of database template you were creating, so all database templates were presented in each of the dropdowns when creating or editing a database.  Beginning with IP.Content 2.x, the software stores the template type when you create a new template.  This allows us to show only &quot;category listing&quot; templates in the &quot;category listing template&quot; selection dropdowns.  Similarly, the template tag help popup can automatically know which template type you are editing without you having to specify.<br />
<br />
Properly making use of templates can help you push out pages on your site in a uniform manner quickly and easily, and without having to &quot;reinvent the wheel&quot; each time a new page is ready to be published.",
										'_field_date'			=> '1268694000',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "18283c56b6a7e9de70581ed1c5554381.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> '8b277b0e2c676c18ffe5810aacae92fa',
										'category_id'			=> '__forum__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'store-comments-in-forum',
										'_field_title'			=> "Store Comments In Forum",
										'_field_body'			=> "With IP.Content 2.0, articles and custom databases can now mirror a topic to the forums when a new article or database record is submitted.  In doing so, IP.Content can also utilize that automatically-generated topic as the comment &quot;storage&quot; for the article or record.  When a comment is submitted to the article, the comment is actually stored as a reply to the topic.  Similarly, replies made directly to the topic in the forum also show up as comments for the record.<br />
<br />
This new functionality can be enabled at a per-database and per-category level.  You can specify separate forums for each category in your article section, for instance, or you can turn off forum commenting for a specific category, while enabling it for all others.<br />
<br />
A few additional configuration options, such as allowing you to automatically remove the topic when the record is removed, and specifying a prefix and/or suffix for the topic title so that your users can more easily identify that such topics were stemmed from the articles section help round out the feature, giving you better control over how these automatically posted topics are handled.<br />
<br />
These new forum cross-posting capabilities allow the administrator to better tie in articles with the forums, giving you better opportunities to expose your content to a wider audience.  Additionally, forum management of comments provides for easier maintenance and stronger managerial options of the comments, utilizing IP.Board&#39;s powerful, proven feature set.",
										'_field_date'			=> '1268780400',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "024a5a7b7d7495bd655e688c9b8ed57c.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> 'f990eb16268cb7b4d305fe2960ce96ca',
										'category_id'			=> '__databases__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'sharing-links',
										'_field_title'			=> "Sharing links",
										'_field_body'			=> "IP.Board 3.1 introduces a new feature that is available for any application to make use of: sharing links.  IP.Content 2.0 makes use of this new feature in the custom databases (and articles) modules to allow you to more easily expose your content to a wider audience.<br />
<br />
Along with supporting sharing of your content with third party services such as Facebook and Twitter, you can now also send an article via email, print the article, and download the article easily by clicking the appropriate icon under the article body.  The additional printing and downloading features allow the content to be shared, online as well as offline. <br />
<br />
Within the articles module specifically, the article image that you upload when posting the article (optionally) will automatically be flagged for use with Facebook when someone uses Facebook to share the link.  This ensures that the correct image is the one Facebook displays to other users.  Similarly, we pull out an appropriate extract of textual content for Facebook to use as well.  If the user is logged in to Twitter or Facebook, sharing the content becomes even easier, not requiring you to even leave the site.<br />
<br />
We hope that by providing tools to make it easier to share content on your site, your content will be exposed to a wider audience, bringing you more traffic and making your content more easily and readily available to the world.",
										'_field_date'			=> '1268780400',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "3eacb41863f20759407ea5587ea8c3bc.png",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> '33910ca4a412925080cd64dc61734be6',
										'category_id'			=> '__templates__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'template-variables-help',
										'_field_title'			=> "Template Variables Help",
										'_field_body'			=> "All templates are capable of using template tags, and as such when you edit any type of template, there will be a &quot;template tag help&quot; link.  Clicking this produces a sidebar (there is then a link in the sidebar to open a separate popup) that details all of the template tags you can insert to include IP.Content data within your template.<br />
<br />
However, with database and article templates, there are additional variables that are passed into the template to allow it to manipulate and display the HTML that represents the content.  For instance, different data is retrieved and available when you are looking at a list of articles compared to when you are viewing a single article.  You need to know what these variables are in order to be able to properly modify the template to display data in the manner you want, and as such, a template variable help popup is available that will detail the variables available for each template type.<br />
<br />
When you are editing a template, click on &quot;template variable help&quot; and a new window opens displaying the variables you can expect to be available to the template with a short description of each variable.  If you get stuck, this help window can help shed some light on the variables that are available, what values they should contain, and how you can use these variables to your advantage to build a more dynamic and useful interface for your database.",
										'_field_date'			=> '1268784000',
										'_field_homepage'		=> ',1,',
										'_field_comments'		=> 1,
										'_field_expiry'			=> 0,
										'_field_image'			=> "ccf9e6113c134dafd5ebe33b58a1479e.png",
										),
									),
									
								/* Media */
								'media'		=> array(
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> '6bdf2e08d61f80097f6380746d13d904',
										'category_id'			=> '__new__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'promote-to-article',
										'record_static_furl'	=> 'promote-article',
										'_field_title'			=> "Promote to Article",
										'_field_ytid'			=> "uzxNFpG7ems",
										'_field_description'	=> "Learn how to use the new &quot;Promote to Article&quot; feature to copy a post to the articles section.",
										'_field_image'			=> "90000532aa1cc479ab9039f6fb3e168f.png",
										'_field_length'			=> "1:14",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> '58dcd38dcf6393e2bf47a9ebccded85a',
										'category_id'			=> '__new__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'article-management',
										'record_static_furl'	=> 'articles',
										'_field_title'			=> "Article Management",
										'_field_ytid'			=> "AznH-MXILXg",
										'_field_description'	=> "This video shows off some of the user interface you can expect to see in the article management area of the ACP.",
										'_field_image'			=> "fc04831cf5b06052b2c04930feecaed9.png",
										'_field_length'			=> "0:54",
										),
									array(
										'member_id'				=> $member['member_id'],
										'record_saved'			=> time(),
										'record_updated'		=> time(),
										'post_key'				=> 'dad19507a140862322082fdc46df1835',
										'category_id'			=> '__other__',
										'record_approved'		=> 1,
										'record_dynamic_furl'	=> 'latest-topics',
										'record_static_furl'	=> 'latest-topics',
										'_field_title'			=> "Latest Topics",
										'_field_ytid'			=> "YXTPDMDHz4I",
										'_field_description'	=> "This video shows how to create a latest topics block, showing the full post, and then adding that block to a new page.",
										'_field_image'			=> "5de8a6e992ef6124306ea1c5d480bb39.png",
										'_field_length'			=> "1:53",
										),
									),
								);

		return array( 'databases' => $databases, 'categories' => $categories, 'fields' => $fields, 'records' => $records );
	}	
	
	/**
	 * Get the templates
	 *
	 * @access	public
	 * @return	array
	 */
	public function getTemplates()
	{
		static $templates	= array();
		
		if( count($templates) )
		{
			return $templates;
		}
		
		$this->DB->build( array( 'select' => 'template_id,template_key', 'from' => 'ccs_page_templates' ) );
		$this->DB->execute();
		
		while( $r = $this->DB->fetch() )
		{
			$templates[ $r['template_key'] ]	= $r['template_id'];
		}
		
		return $templates;
	}
	
	/**
	 * Get member data for the first root admin we can find
	 *
	 * @access	public
	 * @return	array
	 */
	public function getMember()
	{
		$member	= $this->DB->buildAndFetch( array( 'select' => 'member_id,members_display_name', 'from' => 'members', 'where' => 'member_group_id=' . $this->settings['admin_group'], 'limit' => array( 0, 1 ) ) );
		
		return $member;
	}
}
