コード例 #1
0
ファイル: section.php プロジェクト: hungnv0789/vhtm
	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();
	}