Esempio 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'];
	}