Exemplo n.º 1
0
	protected function saveData()
	{
		// collect error messages
		$errors = array();
		vB::$vbulletin->input->clean_array_gpc('p', array(
			'do' => vB_Input::TYPE_STR,
			'html' => vB_Input::TYPE_STR,
			'title' => vB_Input::TYPE_STR,
			'new_parentid' => TYPE_INT,
			'html_title' => vB_Input::TYPE_STR,
			'publicpreview' => TYPE_INT,
			'item_id' => vB_Input::TYPE_INT

		));

		if (vB::$vbulletin->GPC['do'] == 'movenode'
			and vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid']))
		{
			vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']);
			$new_sectionid = vB::$vbulletin->GPC['new_parentid'];
		}

		$new_values = array();
		// create DM and save
		$dm = $this->content->getDM();
		$dm->set('contentid', $this->content->getId());
		$dm->set('item_id', $this->content->getId());

		if (vB::$vbulletin->GPC_exists['html_title'])
		{
			$new_values['html_title'] = vB::$vbulletin->GPC['html_title'];
			$dm->set('html_title', vB::$vbulletin->GPC['html_title']);
		}

		if (vB::$vbulletin->GPC_exists['html'])
		{
			$new_values['html'] = vB::$vbulletin->GPC['html'];
			$dm->set('html', vB::$vbulletin->GPC['html']);
		}

		if (vB::$vbulletin->GPC_exists['comments_enabled'])
		{
			$new_values['comments_enabled'] = vB::$vbulletin->GPC['comments_enabled'];
			$dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']);
		}

		if (vB::$vbulletin->GPC_exists['title'])
		{
			$new_values['title'] = vB::$vbulletin->GPC['title'];
			$dm->set('title', vB::$vbulletin->GPC['title']);
		}

		if (vB::$vbulletin->GPC_exists['publicpreview'])
		{
			$new_values['publicpreview'] = vB::$vbulletin->GPC['publicpreview'];
			$dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']);
		}

		// add node info
		$dm->setNodeTitle($title);

		// set the node segment if it's empty
		if (!$this->content->getUrlTitle())
		{
			$dm->setNodeURLSegment($title);
		}

		$success = $dm->saveFromForm($this->content->getNodeId());

		//invalidate the navigation cache.

		vB_Cache::instance()->event(array('sections_updated' ));
		vBCms_Content::cleanContentCache();

		if ($dm->hasErrors())
		{
			$fieldnames = array(
				'html' => new vB_Phrase('vbcms', 'html')
			);

			$view->errors = $dm->getErrors(array_keys($fieldnames));
			$view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames);
			$view->status = $view->error_view->title;
		}
		else
		{
			$view->status = new vB_Phrase('vbcms', 'content_saved');
			$this->cleanContentCache();
		}

		// postback content
		$view->html_title = $new_values['html_title'];
		$view->title = $new_values['title'];
	}
Exemplo n.º 2
0
	protected function saveData($view)
	{

		//confirm that the user has edit rights
		if (!(($this->content->canEdit() OR ($this->getUserId() == vB::$vbulletin->userinfo['userid']))
				AND $this->content->canUseHtml(vB::$vbulletin->userinfo['userid']))
			AND !$this->content->canPublish())
		{
			return new vB_Phrase('global', 'no_edit_permissions');
		}

		$this->config = $this->content->getConfig();
		require_once DIR . '/includes/functions.php';
		// collect error messages
		$errors = array();
		//We don't need to change the cache lifetime for static page, our descendants will
		vB::$vbulletin->input->clean_array_gpc('p', array(
			'do'               => vB_Input::TYPE_STR,
			'message'          => vB_Input::TYPE_STR,
			'url'              => vB_Input::TYPE_NOHTML,
			'title'            => vB_Input::TYPE_NOHTML,
			'cms_node_title'            => vB_Input::TYPE_NOHTML,
			'setpublish'       => vB_Input::TYPE_UINT,
			'html_title'       => vB_Input::TYPE_NOHTML,
			'publicpreview'    => vB_Input::TYPE_UINT,
			'new_parentid'     => vB_Input::TYPE_UINT,
			'cache_ttl'		    => vB_Input::TYPE_UINT,
			'comments_enabled' => vB_Input::TYPE_UINT,
			'parseurl'         => vB_Input::TYPE_BOOL,
			'posthash'         => vB_Input::TYPE_NOHTML,
			'htmlstate'        => vB_Input::TYPE_NOHTML,
			'pagetext' 		    => vB_Input::TYPE_STR,
			'previewtext' 	    => vB_Input::TYPE_STR,
			'previewtemplate'  => vB_Input::TYPE_STR,
			'template'         => vB_Input::TYPE_STR,
			'preview_image' 	 => vB_Input::TYPE_STR,
		));
		($hook = vBulletinHook::fetch_hook($this->savestarthook)) ? eval($hook) : false;
		$dm = $this->content->getDM();

		if ($this->content->canEdit() AND $this->content->canUseHtml(vB::$vbulletin->userinfo['userid']))
		{

			$html_title = vB::$vbulletin->GPC['html_title'];

			if (vB::$vbulletin->GPC_exists['pagetext'])
			{
				$this->config['pagetext'] = vB::$vbulletin->GPC['pagetext'];
			}

			if (vB::$vbulletin->GPC_exists['preview_image'])
			{
				$this->config['preview_image'] = vB::$vbulletin->GPC['preview_image'];

			}

			if (vB::$vbulletin->GPC_exists['previewtext'])
			{
				$this->config['previewtext'] = vB::$vbulletin->GPC['previewtext'];
			}

			//make sure we have preview text.
			if (empty($this->config['previewtext']) AND !empty($this->config['pagetext']))
			{
				$this->config['previewtext'] =
				 htmlspecialchars_uni(fetch_censored_text(
					trim(fetch_trimmed_title(strip_bbcode($this->config['pagetext'],
					true, false, false), vB::$vbulletin->options['default_cms_previewlength']))));
			}

			if (vB::$vbulletin->GPC_exists['previewtemplate'])
			{
				$this->config['previewtemplate'] = vB::$vbulletin->GPC['previewtemplate'];

			}

			if (vB::$vbulletin->GPC_exists['template'])
			{
				$this->config['template'] = vB::$vbulletin->GPC['template'];

			}

			//For the descendants, at least phpeval
			if (vB::$vbulletin->GPC_exists['cache_ttl'])
			{
				$this->config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl'];

			}

			if (count($this->config))
			{
				$dm->set('config', $this->config);
				$this->content->setConfig($this->config);
			}

			if (vB::$vbulletin->GPC_exists['cms_node_title'])
			{
				$title = vB::$vbulletin->GPC['cms_node_title'];
				$dm->set('title', $title);
			}
		}


		if ($this->content->canPublish())
		{
			$old_sectionid = $this->content->getParentId();

			//set the values, for the dm and update the content.
			if ( vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid']))
			{
				vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']);
				$new_sectionid = vB::$vbulletin->GPC['new_parentid'];
			}

			if (vB::$vbulletin->GPC_exists['publicpreview'])
			{
				$dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']);
			}

			if (vB::$vbulletin->GPC_exists['comments_enabled'])
			{
				$dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']);
			}

			if (vB::$vbulletin->GPC_exists['setpublish'])
			{
				$dm->set('setpublish', vB::$vbulletin->GPC['setpublish']);
			}
		}

		if (vB::$vbulletin->GPC_exists['html_title'])
		{
			$dm->set('html_title', vB::$vbulletin->GPC['html_title']);
		}

		if (vB::$vbulletin->GPC_exists['url'])
		{
			$dm->set('url', vB::$vbulletin->GPC['url']);
		}

		//We may have some processing to do for public preview. Let's see if comments
		// are enabled. We never enable them for sections, and they might be turned off globally.
		vB::$vbulletin->input->clean_array_gpc('r', array(
			'publicpreview' => TYPE_UINT));

		$dm->set('contentid', $this->content->getNodeId());
		$success = $dm->saveFromForm($this->content->getNodeId());
		//Make sure that items we render don't decide to save random data.
		$_POST['do'] = '';
		$_REQUEST['do'] = '';
		vB::$vbulletin->GPC['do'] = '';
		vB::$vbulletin->GPC_exists['do'] = false;

		if ($dm->hasErrors())
		{
			$fieldnames = array(
				'html_title' => new vB_Phrase('vbcms', 'html_title'),
				'title' => new vB_Phrase('global', 'title')
			);

			$view->errors = $dm->getErrors(array_keys($fieldnames));
			$view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames);
			$view->status = $view->error_view->title;
		}
		else
		{
			$view->status = new vB_Phrase('vbcms', 'content_saved');
			$this->cleanContentCache();
		}
		($hook = vBulletinHook::fetch_hook($this->saveendhook)) ? eval($hook) : false;

		//invalidate the appropriate cache entries.
		vB_Cache::instance()->event(array_merge($this->content->getCacheEvents(),array('sections_updated','articles_updated',
			$this->content->getContentCacheEvent())));

		vB_Cache::instance()->cleanNow();
		$view->html_title = $html_title;
		$view->title = $title;
		$this->content->reset();
		$this->changed = true;

	}
Exemplo n.º 3
0
	protected function saveData($view)
	{
		if ($this->data_saved)
		{
			return true;
		}
		$this->data_saved = true;

		if (!$this->content->canEdit() AND !$this->content->canPublish() )
		{
			return $vb_phrase['no_edit_permissions'];
		}

		require_once DIR . '/includes/functions.php';
		// collect error messages
		$errors = array();
		vB::$vbulletin->input->clean_array_gpc('p', array(
			'do'               => vB_Input::TYPE_STR,
			'cms_node_title'   => vB_Input::TYPE_STR,
			'cms_node_url'     => vB_Input::TYPE_STR,
			'message'          => vB_Input::TYPE_STR,
			'url'              => vB_Input::TYPE_NOHTML,
			'title'            => vB_Input::TYPE_NOHTML,
			'setpublish'       => vB_Input::TYPE_UINT,
			'publishdate'      => vB_Input::TYPE_UINT,
			'html_title'       => vB_Input::TYPE_NOHTML,
			'publicpreview'    => vB_Input::TYPE_UINT,
			'new_parentid'     => vB_Input::TYPE_UINT,
			'comments_enabled' => vB_Input::TYPE_UINT,
			'wysiwyg'          => vB_Input::TYPE_BOOL,
			'parseurl'         => vB_Input::TYPE_BOOL,
			'posthash'         => vB_Input::TYPE_NOHTML,
			'poststarttime'    => vB_Input::TYPE_UINT,
			'htmlstate'        => vB_Input::TYPE_NOHTML,
		));

		($hook = vBulletinHook::fetch_hook('vbcms_article_save_start')) ? eval($hook) : false;
		$dm = $this->content->getDM();
		$dm->set('contentid', $this->content->getId());

		if ($this->content->canEdit())
		{
			// get pagetext
			$pagetext = vB::$vbulletin->GPC['message'];
			$html_title = vB::$vbulletin->GPC['html_title'];
			$title = vB::$vbulletin->GPC['title'];

			// unwysiwygify the incoming data
			if (vB::$vbulletin->GPC['wysiwyg'])
			{
				$html_parser = new vBCms_WysiwygHtmlParser(vB::$vbulletin);
				$pagetext = $html_parser->parse($pagetext);
			}

			$dm->info['parseurl'] = true;
			$dm->set('pagetext', $pagetext);

			if ($title)
			{
				$dm->set('title', $pagetext);
			}

			$bbcodesearch = array();

			$video_location = stripos($pagetext, '[video');

			$found_image = false;
			// populate the preview image field with [img] if we can find one
			if (($i = stripos($pagetext, '[IMG]')) !== false and ($j = stripos($pagetext, '[/IMG]')) AND $j > $i)
			{
				$previewimage = htmlspecialchars_uni(substr($pagetext, $i+5, $j - $i - 5));
				$image_location = $i;
				if ($size = @getimagesize($previewimage))
				{
					$dm->set('previewimage', $previewimage);
					$dm->set('imagewidth', $size[0]);
					$dm->set('imageheight', $size[1]);
					$bbcodesearch[] = substr($pagetext, $i, $j + 6);
					$found_image = true;
				}
			}
			// or populate the preview image field with [attachment] if we can find one
			if (!$found_image)
			{
				$i = stripos($pagetext, "[ATTACH=CONFIG]");
				$j = stripos($pagetext, '[/ATTACH]');

				if ($j !== false)
				{
					if ($i === false)
					{
						$i = stripos($pagetext, "[ATTACH]");

						if ($i !== false AND ($i > $j))
						{
							$attachmentid = substr($pagetext, $i + 15, $j - $i - 15);
							$found_image = $this->getAttachData($attachmentid, $dm, $bbcodesearch);
						}
					}
					else if ($i > $j)
					{
						$attachmentid = substr($pagetext, $i + 15, $j - $i - 15);
						$found_image = $this->getAttachData($attachmentid, $dm, $bbcodesearch);
					}

				}
			}

			if (!$found_image AND $this->content->canDownload())
			{
				require_once(DIR . '/packages/vbattach/attach.php');
				$attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article');
				$attachments = $attach->fetch_postattach(0, $this->content->getNodeId(), $this->content->getUserId());

				if (!empty($attachments))
				{
					foreach($attachments as $attachment)
					{
						if ($attachment['hasthumbnail'])
						{
							$found_image = $this->getAttachData($attachment['attachmentid'], $dm, $bbcodesearch);
							if ($found_image)
							{
								break;
							}
						}
					}
				}
			}

			// if there are no images in the article body, make sure we unset the preview in the db
			if (!$found_image )
			{
				$dm->set('previewimage', '');
				$dm->set('imagewidth', 0);
				$dm->set('imageheight', 0);
				$image_location = intval($video_location) + 1;
			}
			$parseurl = false;
			$providers = $search = $replace = $previewvideo = array();
			($hook = vBulletinHook::fetch_hook('data_preparse_bbcode_video_start')) ? eval($hook) : false;

			// Convert video bbcode with no option
			if ((($video_location !== false) AND (intval($video_location) < intval($image_location))) OR $parseurl)
			{
				if (!$providers)
				{
					$bbcodes = vB::$db->query_read_slave("
						SELECT
						provider, url, regex_url, regex_scrape, tagoption
					FROM " . TABLE_PREFIX . "bbcode_video
					ORDER BY priority
				");
					while ($bbcode = vB::$db->fetch_array($bbcodes))
					{
						$providers["$bbcode[tagoption]"] = $bbcode;
					}
				}

				$scraped = 0;
				if (!empty($providers) AND preg_match_all('#\[video[^\]]*\](.*?)\[/video\]#si', $pagetext, $matches))
				{
					foreach ($matches[1] AS $key => $url)
					{
						$match = false;
						foreach ($providers AS $provider)
						{
							$addcaret = ($provider['regex_url'][0] != '^') ? '^' : '';
							if (preg_match('#' . $addcaret . $provider['regex_url'] . '#si', $url, $match))
							{
								break;
							}
						}
						if ($match)
						{
							if (!$provider['regex_scrape'] AND $match[1])
							{
								$previewvideo['provider'] = $provider['tagoption'];
								$previewvideo['code'] = $match[1];
								$previewvideo['url'] = $url;
								$bbcodesearch[] = $matches[0][$key];
								break;
							}
							else if ($provider['regex_scrape'] AND vB::$vbulletin->options['bbcode_video_scrape'] > 0 AND $scraped < vB::$vbulletin->options['bbcode_video_scrape'])
							{
								require_once(DIR . '/includes/functions_file.php');
								$result = fetch_body_request($url);
								if (preg_match('#' . $provider['regex_scrape'] . '#si', $result, $scrapematch))
								{
									$previewvideo['provider'] = $provider['tagoption'];
									$previewvideo['code'] = $scrapematch[1];
									$previewvideo['url'] = $url;
									$bbcodesearch[] = $matches[0][$key];
									break;
								}
								$scraped++;
							}
						}
					}
				}
			}

			$htmlstate = vB::$vbulletin->GPC_exists['htmlstate'] ? vB::$vbulletin->GPC['htmlstate']
				: $this->content->getHtmlState();

			// Try to populate previewvideo html
			if ($previewvideo)
			{
				$templater = vB_Template::create('bbcode_video');
				$templater->register('url', $previewvideo['url']);
				$templater->register('provider', $previewvideo['provider']);
				$templater->register('code', $previewvideo['code']);
				$dm->set('previewvideo', $templater->render());
				$dm->set('previewimage', '');
				$dm->set('imagewidth', 0);
				$dm->set('imageheight', 0);
				$image_location = -1;
			}
			else
			{
				$dm->set('previewvideo', '');
			}

				}

		if ($this->content->canPublish())
		{
			$old_sectionid = $this->content->getParentId();

			//set the values, for the dm and update the content.
			if ( vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid']))
			{
				vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']);
				$new_sectionid = vB::$vbulletin->GPC['new_parentid'];
			}

			if (vB::$vbulletin->GPC_exists['publicpreview'])
			{
				$dm->set('publicpreview', vB::$vbulletin->GPC['publicpreview']);
			}

			if (vB::$vbulletin->GPC_exists['comments_enabled'])
			{
				$dm->set('comments_enabled', vB::$vbulletin->GPC['comments_enabled']);
			}

			if (vB::$vbulletin->GPC_exists['setpublish'])
			{
				$dm->set('setpublish', vB::$vbulletin->GPC['setpublish']);
			}
		}

		if (vB::$vbulletin->GPC_exists['html_title'])
		{
			$dm->set('html_title', vB::$vbulletin->GPC['html_title']);
		}

		if (vB::$vbulletin->GPC_exists['url'])
		{
			$dm->set('url', vB::$vbulletin->GPC['url']);
		}

		if (vB::$vbulletin->GPC_exists['htmlstate'])
		{
			$dm->set('htmlstate', vB::$vbulletin->GPC['htmlstate']);
		}

		//We may have some processing to do for public preview. Let's see if comments
		// are enabled. We never enable them for sections, and they might be turned off globally.
		vB::$vbulletin->input->clean_array_gpc('r', array(
			'publicpreview' => TYPE_UINT));

		$success = $dm->saveFromForm($this->content->getNodeId());
		$this->changed = true;

		if ($dm->hasErrors())
		{
			$fieldnames = array(
				'html_title' => new vB_Phrase('vbcms', 'html_title'),
				'title' => new vB_Phrase('global', 'title')
			);

			$view->errors = $dm->getErrors(array_keys($fieldnames));
			$view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames);
			$view->status = $view->error_view->title;
		}
		else
		{
			$view->status = new vB_Phrase('vbcms', 'content_saved');
			$this->cleanContentCache();

			// Make sure the posthash is valid
			if (md5(vB::$vbulletin->GPC['poststarttime'] . vB::$vbulletin->userinfo['userid'] . vB::$vbulletin->userinfo['salt']) == vB::$vbulletin->GPC['posthash'])
			{
				vB::$vbulletin->db->query_write("
					UPDATE " . TABLE_PREFIX . "attachment
					SET
						posthash = '',
						contentid = " . intval($this->content->getNodeId()) . "
					WHERE
						posthash = '" . vB::$vbulletin->db->escape_string(vB::$vbulletin->GPC['posthash']) . "'
							AND
						contenttypeid = " . intval(vB_Types::instance()->getContentTypeID("vBCms_Article")) . "
				");
			}

			// only publish to Facebook if we are going from not-published to published, and the date is in the past
			if (is_facebookenabled() AND $this->content->isPublished())
			{
				$message =  new vB_Phrase('posting', 'fbpublish_message_newarticle', vB::$vbulletin->options['bbtitle']);
				$fblink =  vBCms_Route_Content::getURL(array(
					'node' => $this->content->getUrlSegment(),
					'action' =>'view'
				));
				$fblink = str_ireplace('&amp;', '&', $fblink);
				publishtofacebook_newarticle($message, $this->content->getTitle(), $this->content->getPageText(), create_full_url($fblink));
			}
		}
		($hook = vBulletinHook::fetch_hook('vbcms_article_save_end')) ? eval($hook) : false;

		//invalidate the navigation cache.
		vB_Cache::instance()->event('sections_updated');
		vB_Cache::instance()->event('articles_updated');
		vB_Cache::instance()->event(array_merge($this->content->getCacheEvents(),
			array($this->content->getContentCacheEvent())));

		//Make sure comment count will be updated when a comment is posted
		if ($threadid = $this->content->getAssociatedThreadId())
		{
			vB_Cache::instance()->event("cms_comments_thread_$threadid");
		}
		vB_Cache::instance()->cleanNow();
		$this->content->reset();
		//reset the required information
		$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
		$this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT);
		$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
		$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
		$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);
	}
Exemplo n.º 4
0
	public function checkSaveData($view)
	{
		require_once DIR . '/includes/functions_databuild.php';
		require_once DIR . '/includes/functions.php';
		fetch_phrase_group('cpcms');
		($hook = vBulletinHook::fetch_hook('vbcms_section_save_start')) ? eval($hook) : false;

		// Check if inline form was submitted
		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do' => vB_Input::TYPE_STR
		));

		//let's make sure we use the Post value of do
		vB::$vbulletin->input->clean_array_gpc('p', array(
			'do' => vB_Input::TYPE_STR,
			'per_page' => TYPE_INT,
			'new_parentid' => TYPE_INT,
			'html_title' => TYPE_STR,
			'title' => TYPE_STR,
			'displayorder' => TYPE_INT,
			'content_layout' => TYPE_INT,
			'pagination_links' => TYPE_INT,
			'contentfrom' => TYPE_INT,
			'new_parentid' => TYPE_INT,
			'simple_paging' => TYPE_INT,
			'perpage' => TYPE_INT,
		));

		if (vB::$vbulletin->GPC_exists['new_parentid'] AND intval(vB::$vbulletin->GPC['new_parentid'])
			AND (intval(vB::$vbulletin->GPC['new_parentid'] != $this->content->getParentId())) )
		{
			vBCms_ContentManager::moveSection(array($this->content->getNodeId()), vB::$vbulletin->GPC['new_parentid']);
		}

		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' )
		{
			// collect error messages
			$errors = array();

			// create dm
			$dm = $this->content->getDM();
			$this->config = array();

			if (vB::$vbulletin->GPC_exists['perpage']) //This is the number displayed on the edit page
			{
				$current_user = new vB_Legacy_CurrentUser();
				if (!$stored_prefs = $current_user->getSearchPrefs())
				{
					$stored_prefs = array();
				}

				if (vB::$vbulletin->GPC_exists['perpage'] AND intval(vB::$vbulletin->GPC['perpage']))
				{
					$stored_prefs['cmsadmin_showperpage'] = intval(vB::$vbulletin->GPC['perpage']);
					$current_user->saveSearchPrefs($stored_prefs);
				}
			}

			if (vB::$vbulletin->GPC_exists['per_page']) //This is the number of items displayed to the end user in the view
			{
				$this->config['items_perhomepage'] = vB::$vbulletin->GPC['per_page'];
			}

			if (vB::$vbulletin->GPC_exists['displayorder'])
			{
				$this->config['section_priority'] = vB::$vbulletin->GPC['displayorder'];
			}

			if (vB::$vbulletin->GPC_exists['content_layout'])
			{
				$this->config['content_layout'] = vB::$vbulletin->GPC['content_layout'];
			}

			if (vB::$vbulletin->GPC_exists['title'])
			{
				$this->config['title'] = vB::$vbulletin->GPC['title'];
			}

			if (vB::$vbulletin->GPC_exists['pagination_links'])
			{
				$this->config['pagination_links'] = vB::$vbulletin->GPC['pagination_links'];
			}


			if (vB::$vbulletin->GPC_exists['simple_paging'])
			{
				$this->config['simple_paging'] = 1;
			}

			$this->config['contentfrom'] = (vB::$vbulletin->GPC_exists['contentfrom']
				AND (vB::$vbulletin->GPC['contentfrom'] == 1)) ? 1 : 2;

			if (count($this->config))
			{
				$dm->set('config', $this->config);
				$this->content->setConfig($this->config);
			}
			$dm->saveFromForm($this->content->getNodeId());

			if ($dm->hasErrors())
			{
				$fieldnames = array(
					'title' => new vB_Phrase('global', 'title')
				);

				$view->errors = $dm->getErrors(array_keys($fieldnames));
				$view->error_summary = self::getErrorSummary($dm->getErrors(array_keys($fieldnames)), $fieldnames);
				$view->status = $view->error_view->title;
			}
			else
			{
				$view->status = new vB_Phrase('vbcms', 'content_saved');

				// reroute to the section
				$route = new vBCms_Route_Content();
				$route->node = $this->content->getUrlSegment();
				$url = $route->getCurrentUrl();

				($hook = vBulletinHook::fetch_hook('vbcms_section_save_end')) ? eval($hook) : false;
			}

		}
		$this->changed = true;
		($hook = vBulletinHook::fetch_hook('vbcms_section_save_end')) ? eval($hook) : false;
		//invalidate the navigation cache.
		vB_Cache::instance()->event('sections_updated');
		vB_Cache::instance()->event('articles_updated');
		vB_Cache::instance()->event($this->content->getCacheEvents());
		vB_Cache::instance()->event($this->getCleanCacheEvents());
		vB_Cache::instance()->cleanNow();
		$this->content->reset();
	}