Esempio n. 1
0
	/**
	 * Returns singleton instance of self.
	 * @todo This can be inherited once late static binding is available.  For now
	 * it has to be redefined in the child classes
	 *
	 * @return vBCms_Types						- Reference to singleton instance of the type handler
	 */
	public static function instance()
	{
		if (!isset(self::$instance))
		{
			$class = __CLASS__;
			self::$instance = new $class();
		}

		return self::$instance;
	}
Esempio n. 2
0
			FROM " . TABLE_PREFIX . "cms_widget AS widget
			WHERE widget.varname = '" . $vbulletin->db->escape_string($vbulletin->GPC['varname']) . "'
		");

		if ($duplicate_varname)
		{
			print_stop_message('widget_varname_x_already_in_use', htmlspecialchars($vbulletin->GPC['varname']));
		}
	}
	*/
}

// Add #########################################################################
if ($_POST['do'] == 'addwidget')
{
	$widgettypes = vBCms_Types::instance()->enumerateWidgetTypes();

	print_form_header('cms_admin', 'newwidget');
	print_table_header($vbphrase['create_widget']);
	print_select_row($vbphrase['widget_type'], 'widgettype', $widgettypes);
	print_input_row($vbphrase['title'], 'title');
	//print_input_row($vbphrase['varname'], 'varname', $widgetinfo['varname'], false);
	print_textarea_row($vbphrase['description'], 'description');
	print_submit_row($vbphrase['save'], '');
}

// New #########################################################################
if ($_REQUEST['do'] == 'newwidget')
{
	$vbulletin->input->clean_array_gpc('p', array(
		'widgettype'	=> TYPE_UINT,
Esempio n. 3
0
	/**
	 * Adds item id info to a view for submitting via post.
	 *
	 * @param vB_View $view
	 */
	protected function addPostId(vB_View $view)
	{
		$view->item_type = 'content';
		$view->item_class = vBCms_Types::instance()->getTypeKey($this->content->getPackage(), $this->content->getClass());
		$view->item_id = $this->content->getContentId();
		$view->nodeid = $this->content->getNodeId();
	}
Esempio n. 4
0
	/**
	 * Adds item id info to a view for submitting via post.
	 *
	 * @param vB_View $view
	 */
	protected function addPostId(vB_View $view)
	{
		$view->item_type = 'widget';
		$view->item_class = vBCms_Types::instance()->getTypeKey($this->widget->getPackage(), $this->widget->getClass());
		$view->item_id = $this->widget->getId();

		require_once(DIR . '/includes/adminfunctions.php');
		$view->adminhash = ADMINHASH;
	}
Esempio n. 5
0
	/**
	 * Adds a new content node of the posted contenttype.
	 * Default content is created with a default title and url segment.  Everything
	 * else inherits from the new node's parent until changes with actionEditNode().
	 *
	 * @return string
	 */
	public function actionAddNode()
	{
			vB::$vbulletin->input->clean_array_gpc('r', array(
			'contenttypeid' => vB_Input::TYPE_UINT,
			'parentnode'    => vB_Input::TYPE_UINT,
			'item_type' => vB_Input::TYPE_STR
		));

		// Validate the content id
		if (!($contenttypeid = vBCms_Types::instance()->getContentTypeID(vB::$vbulletin->GPC['contenttypeid'])))
		{
				throw (new vB_Exception_User(new vB_Phrase('error', 'no_contenttype_selected')));
		}

		if (! vB::$vbulletin->GPC_exists['parentnode'])
		{
			vB::$vbulletin->GPC_exists['parentnode'] = true;
			vB::$vbulletin->GPC['parentnode'] = $this->node->getNodeId() ;
		}

		//Check the privileges.
		if (!$this->node->canCreate())
		{
			throw (new vB_Exception_User(new vB_Phrase('error', 'no_create_permissions')));
		}

		// Validate the postid
		if ((!vB::$vbulletin->GPC['item_type'] == 'content') AND !$contenttypeid)
		{
			throw (new vB_Exception_User());
		}

		try
		{
			// create the nodedm
			$class  = vB_Types::instance()->getContentClassFromId($contenttypeid);
			$classname = $class['package']. "_DM_" . $class['class'];

			if (class_exists($classname))
			{
				$nodedm = new $classname;
			}
			else
			{
				$nodedm = new vBCms_DM_Node();
			}

			// create content handler
			$content = vBCms_Content::create(vB_Types::instance()->getContentTypePackage($contenttypeid), vBCms_Types::instance()->getContentTypeClass($contenttypeid));
			// insert default content for the contenttype and get the new contentid
			$nodeid = $content->createDefaultContent($nodedm);
		}
		catch (vB_Exception $e)
		{
			throw (new vB_Exception_DM('Could not create default content.  Exception thrown with message: \'' . htmlspecialchars($e->getMessage()) . '\''));
		}

		// Create route to redirect the user to
		$route = new vBCms_Route_Content();
		$route->node = $nodeid;
		$route->setSegments(array('action' => 'edit'));
		throw (new vB_Exception_Reroute($route));
	}
Esempio n. 6
0
	/**
	 * Creates a content item to add to the collection.
	 *
	 * @param array mixed $iteminfo				- The known properties of the new item
	 * @return vB_Item							- The created item
	 */
	protected function createItem($iteminfo, $load_flags = false)
	{
		$class = vBCms_Types::instance()->getContentTypeClass($iteminfo['contenttypeid']);
		$package = vBCms_Types::instance()->getContentTypePackage($iteminfo['contenttypeid']);

		$item = vB_Item_Content::create($package, $class, $iteminfo[$this->primary_key]);
		$item->setInfo($iteminfo, $load_flags);

		return $item;
	}
Esempio n. 7
0
	/**
	 * Validate the set widgettype.
	 *
	 * @param mixed $value						- The value to validate
	 * @param mixed $error						- The var to assign an error to
	 * @return mixed | bool						- The filtered value or boolean false
	 */
	protected function validateWidgetTypeID($value, &$error)
	{
		if (vBCms_Types::instance()->widgetTypeEnabled($value))
		{
			return $value;
		}

		return false;
	}
Esempio n. 8
0
	public static function updateSections()
	{
		// There are several possibilities. First, if the user edits a title, published,
		//layout, or style, we save immediately.
		vB::$vbulletin->input->clean_array_gpc('p', array(
			'sectionid' => TYPE_INT,
			'nodeid' => TYPE_INT,
			'nodeid2' => TYPE_INT,
			'ids' => TYPE_ARRAY,
			'new_contenttype' => TYPE_INT,
			'title' => TYPE_NOHTML,
			'section_title' => TYPE_NOHTML,
			'sentfrom' => TYPE_NOHTML
			));

		$msg = '';
		//let's see if we need a list of ID's
		if (vB::$vbulletin->GPC['do'] == 'publish_section'
			OR vB::$vbulletin->GPC['do'] == 'unpublish_section'
			OR vB::$vbulletin->GPC['do'] == 'publish_nodes'
			OR vB::$vbulletin->GPC['do'] == 'unpublish_nodes'
			OR vB::$vbulletin->GPC['do'] == 'delete_section'
			OR vB::$vbulletin->GPC['do'] == 'move_section'
			OR vB::$vbulletin->GPC['do'] == 'delete_nodes'
			OR vB::$vbulletin->GPC['do'] == 'move_node'
			OR vB::$vbulletin->GPC['do'] == 'save_nodes')
		{
			$ids = array();
			foreach (vB::$vbulletin->GPC['ids'] as $id)
			{
				if ($_POST["cb_$id"] == 'on')
				{
					$ids[] = $id;
				}
			}
		}

		switch(vB::$vbulletin->GPC['do'])
		{
			case 'saveonetitle':

					if (vB::$vbulletin->GPC_exists['sectionid'])
				{
					$this_id = vB::$vbulletin->GPC['sectionid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'title_' . $this_id => TYPE_STR));

					if (vB::$vbulletin->GPC_exists['title_' . $this_id])
					{
						self::saveRecords('cms_node', 'nodeid',
							array($this_id => array('title' =>vB::$vbulletin->GPC['title_' . $this_id])));
						vB_Cache::instance()->purge('section_nav_' . $this_id);
						//we need to purge the data cache record for this id
						$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
						vB_Cache::instance()->event($content->getCacheEvents());
						unset($content);
						vB_Cache::instance()->event('sections_updated');
						vB_Cache::instance()->cleanNow();
					}
				}
				;
				break;

			case 'set_order':
			//First, we validate that we have an id, and an order
				vB::$vbulletin->input->clean_array_gpc('p', array(
					'id' => TYPE_INT,
					'displayorder' => TYPE_INT,
					'sectionid' => TYPE_INT
					));
				if (vB::$vbulletin->GPC_exists['id'] AND vB::$vbulletin->GPC_exists['sectionid'])
				{
					self::setDisplayOrder(vB::$vbulletin->GPC['sectionid'], vB::$vbulletin->GPC['id'], vB::$vbulletin->GPC['displayorder']);
					vB_Cache::instance()->event('sections_updated');
					
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', vB::$vbulletin->GPC['sectionid']);
					vB_Cache::instance()->event($content->getCacheEvents());
					vB_Cache::instance()->cleanNow();
					unset($content);
				}
				;
			break;

			case 'saveonesectionstate':
			case 'saveonenodestate':

				// We need a sectionid and state. 1 is published, 2 is unpublished,
				// and 3 means it's currently published in the future and we should leave it
				// that way.
				if (vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'state_' . $this_id => TYPE_INT));

					if (vB::$vbulletin->GPC['state_' . $this_id])
					{
						if (vB::$vbulletin->GPC['state_' . $this_id] == 2)
						{
							self::saveRecords('cms_node', 'nodeid', array($this_id => array('setpublish' =>1,
							'publishdate' => TIMENOW - 1)));
						}
						elseif (vB::$vbulletin->GPC['state_' . $this_id] == 1)
						{
							self::saveRecords('cms_node', 'nodeid', array($this_id => array('setpublish' =>0)));
						}
						vB_Cache::instance()->event('section_nav_' . $this_id);
						vB_Cache::instance()->event('articles_updated');
						vB_Cache::instance()->event('sections_updated');
						//we need to purge the data cache record for this id
						$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
						vB_Cache::instance()->event($content->getCacheEvents());
						vB_Cache::instance()->cleanNow();
						unset($content);
					}
				}
				break;

			case 'delete_section':
				//first check to see if there is content under this section
				vB::$vbulletin->input->clean_array_gpc('p', array(
					'delete_sectionid' => TYPE_INT));
				if (vB::$vbulletin->GPC_exists['delete_sectionid'])

					//If this is id 1, don't allow deletion.
					if ((intval(vB::$vbulletin->GPC['delete_sectionid']) == 1) OR $record = vB::$vbulletin->db->query_first('SELECT COUNT(*) AS qty FROM ' .
					TABLE_PREFIX . "cms_node WHERE new != 1 AND parentnode = " . vB::$vbulletin->GPC['delete_sectionid'])
						and intval($record['qty']))
					{
						return false;
					}
				vB::$vbulletin->db->query_write($sql = "DELETE FROM ".
					TABLE_PREFIX . "cms_nodeconfig WHERE nodeid = " . vB::$vbulletin->GPC['delete_sectionid']);
				vB::$vbulletin->db->query_write($sql = "DELETE FROM ".
					TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . vB::$vbulletin->GPC['delete_sectionid']);
				vB::$vbulletin->db->query_write($sql = "DELETE FROM ".
					TABLE_PREFIX . "cms_node WHERE nodeid = " . vB::$vbulletin->GPC['delete_sectionid']);
				vB::$vbulletin->db->query_write("DELETE FROM " .
					TABLE_PREFIX .	"cms_category WHERE parentnode = " . vB::$vbulletin->GPC['delete_sectionid']);
				vB_Cache::instance()->event('sections_updated');
				vB_Cache::instance()->cleanNow();
				break;

			case 'delete_nodes':
				foreach(vB::$vbulletin->GPC['ids'] as $this_id)
				{
					if (isset($_POST["cb_$this_id"]))
					{
						vB::$vbulletin->db->query_write($sql = "DELETE FROM ".
						TABLE_PREFIX . "cms_nodeconfig WHERE nodeid = $this_id" );
						vB::$vbulletin->db->query_write($sql = "DELETE FROM ".
						TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = $this_id" );
						vB::$vbulletin->db->query_write($sql = "DELETE FROM ".
						TABLE_PREFIX . "cms_node WHERE nodeid = $this_id");
						vB::$vbulletin->db->query_write("DELETE FROM " .
						TABLE_PREFIX .	"cms_category WHERE parentnode = $this_id");
					}
				}
				vB_Cache::instance()->event('sections_updated');
				vB_Cache::instance()->event('articles_updated');
				vB_Cache::instance()->cleanNow();
				break;


			case 'saveonelayout':

				// We need a nodeid and a layoutid.
				if (vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'layout_' . $this_id => TYPE_INT));

					if (vB::$vbulletin->GPC['layout_' . $this_id])
					{
						self::saveRecords('cms_node', 'nodeid',
							array($this_id => array('layoutid' =>vB::$vbulletin->GPC['layout_' . $this_id]	)));
					}
					else
					{
						self::saveRecords('cms_node', 'nodeid',
							array($this_id => array('layoutid' => null)));

					}
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
					vB_Cache::instance()->event($content->getCacheEvents());
					unset($content);
				}
				break;

			case 'saveonecl':
				// We need a nodeid and a clid.
				if (vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'cl_' . $this_id => TYPE_INT));

					if (vB::$vbulletin->GPC_exists['cl_' . $this_id] AND intval(vB::$vbulletin->GPC['cl_' . $this_id]))
					{
						self::saveConfig ($this_id, 'content_layout', vB::$vbulletin->GPC['cl_' . $this_id], false);
					}
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
					vB_Cache::instance()->event($content->getCacheEvents());
					unset($content);
				}
				break;
			case 'sectionpriority':
				// We need a nodeid and a sect_pr_XX value
				if (vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'sect_pr_' . $this_id => TYPE_INT));

					if (vB::$vbulletin->GPC_exists['sect_pr_' . $this_id] )
					{
						if (intval(vB::$vbulletin->GPC['sect_pr_' . $this_id]))
						{
							self::saveConfig ($this_id, 'section_priority', vB::$vbulletin->GPC['sect_pr_' . $this_id], false);
						}
						else
						{
							//The we go back to default.
							self::saveConfig ($this_id, 'section_priority', 0, false);
						}
					}
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
					vB_Cache::instance()->event($content->getCacheEvents());
					unset($content);
				}
				break;

			case 'sectionpp':
				// We need a nodeid and a sect_pp_XX value
				if (vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'section_pp_' . $this_id => TYPE_INT));

					if (vB::$vbulletin->GPC_exists['section_pp_' . $this_id] AND intval(vB::$vbulletin->GPC['section_pp_' . $this_id]))
					{
						self::saveConfig ($this_id, 'items_perhomepage', vB::$vbulletin->GPC['section_pp_' . $this_id], false);
					}
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
					vB_Cache::instance()->event($content->getCacheEvents());
					unset($content);
				}
				break;

			case 'saveonestyle':

				// We need a sectionid and state. 1 is published, 2 is unpublished,
				// and 3 means it's currently published in the future and we should leave it
				// that way.
				if (vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
					//We still need a title
					vB::$vbulletin->input->clean_array_gpc('p', array(
						'style_' . $this_id => TYPE_INT));

					if (vB::$vbulletin->GPC['style_' . $this_id])
					{
						self::saveRecords('cms_node', 'nodeid',
							array($this_id => array('styleid' =>vB::$vbulletin->GPC['style_' . $this_id])));
					}
					else
					{
						self::saveRecords('cms_node', 'nodeid',
							array($this_id => array('styleid' => null)));
					}
					vB_Cache::instance()->event('section_nav_' . $this_id);
					vB_Cache::instance()->event('sections_updated');				}
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
					vB_Cache::instance()->event($content->getCacheEvents());
					vB_Cache::instance()->cleanNow();
					unset($content);
				break;

			case 'publish_section':
			case 'publish_nodes':
				self::savePreview();
				foreach(vB::$vbulletin->GPC['ids'] as $id)
				{
					vB::$vbulletin->input->clean_array_gpc('r', array('cb_' . $id => TYPE_STR ));

					if (vB::$vbulletin->GPC_exists['cb_' . $id])
					{
						$checked[] = $id;
					}

				}

				if (count($checked))
				{
					self::saveRecords('cms_node', 'nodeid', array('setpublish'=> 1),
						$checked);
					foreach($checked as $id)
					{
						vB_Cache::instance()->event('section_nav_' . $id);
					//we need to purge the data cache record for this id
					$content = vBCms_Item_Content::create('vBCms', 'Section', $id);
					vB_Cache::instance()->event($content->getCacheEvents());
					unset($content);
					}
					break;
					vB_Cache::instance()->event('sections_updated');
					vB_Cache::instance()->event('articles_updated');
					vB_Cache::instance()->cleanNow();
				}
				break;

			case 'unpublish_nodes':
			case 'unpublish_section':
				self::savePreview();
				foreach(vB::$vbulletin->GPC['ids'] as $id)
				{
					vB::$vbulletin->input->clean_array_gpc('r', array('cb_' . $id => TYPE_STR ));

					if (vB::$vbulletin->GPC_exists['cb_' . $id])
					{
						$checked[] = $id;
					}

				}

				if (count($checked))
				{
					self::saveRecords('cms_node', 'nodeid', array('setpublish'=> 0),
						$checked);
					foreach($checked as $id)
					{
						vB_Cache::instance()->event('section_nav_' . $id);
						//we need to purge the data cache record for this id
						$content = vBCms_Item_Content::create('vBCms', 'Section', $id);
						vB_Cache::instance()->event($content->getCacheEvents());
						unset($content);
					}
					vB_Cache::instance()->event('sections_updated');
					vB_Cache::instance()->event('sections_updated');
					vB_Cache::instance()->event('articles_updated');
					vB_Cache::instance()->cleanNow();
				}
				break;

			case 'move_node':
			case 'move_section':

				//sectionid is where we're moving the records.
				if (vB::$vbulletin->GPC_exists['sectionid'] and
					$nodelist = self::getNodeList($ids))
				{
					$msg = self::moveSection($nodelist, vB::$vbulletin->GPC['sectionid']);
				}
				foreach ($nodelist as $sectionid)
				{

					vB_Cache::instance()->event('section_nav_' . $sectionid);
				}
				vB_Cache::instance()->event('sections_updated');
				vB_Cache::instance()->event('articles_updated');
				vB_Cache::instance()->cleanNow();
				break;

			case 'save_section':
				//We should have a title, a sectionid, and a target_sectionid
				vB::$vbulletin->input->clean_array_gpc('p',
					array('title' => TYPE_STR ,
					'nodeid' => TYPE_INT,
					'target_sectionid' => TYPE_INT));

				if (vB::$vbulletin->GPC_exists['title'] AND vB::$vbulletin->GPC_exists['nodeid'])
				{
					$this_id = vB::$vbulletin->GPC['nodeid'];
						//First we save the title. Then try a move.
					//The move subroutine will check to see if it's necessary.
					self::saveRecords('cms_nodeinfo', 'nodeid',
						array($this_id => array('title' =>vB::$vbulletin->GPC['title'], 'html_title' =>vB::$vbulletin->GPC['title'])));
				}

				if (vB::$vbulletin->GPC_exists['target_sectionid']
					and vB::$vbulletin->GPC['target_sectionid'])
				{
					$msg .= self::moveSection(array($this_id), vB::$vbulletin->GPC['target_sectionid']);
				}
				vB_Cache::instance()->event('section_nav_' . $this_id);
				vB_Cache::instance()->event('sections_updated');
				vB_Cache::instance()->event('articles_updated');
				//we need to purge the data cache record for this id
				$content = vBCms_Item_Content::create('vBCms', 'Section', $this_id);
				vB_Cache::instance()->event($content->getCacheEvents());
				vB_Cache::instance()->cleanNow();
				unset($content);

				break;

			case 'swap_sections':
				if (vB::$vbulletin->GPC_exists['nodeid'] AND vB::$vbulletin->GPC_exists['nodeid2'])
				{
					$node1 = vB::$vbulletin->GPC['nodeid'];
					$node2 = vB::$vbulletin->GPC['nodeid2'];

					self::swapNodes($node1, $node2);

					vB_Cache::instance()->event('section_nav_' . $node1);
					vB_Cache::instance()->event('section_nav_' . $node2);
					vB_Cache::instance()->event('sections_updated');
					vB_Cache::instance()->event('articles_updated');
					//we need to purge the data cache record for these ids
					$content = vBCms_Item_Content::create('vBCms', 'Section', $node1);
					vB_Cache::instance()->event($content->getCacheEvents());
					$content = vBCms_Item_Content::create('vBCms', 'Section', $node2);
					vB_Cache::instance()->event($content->getCacheEvents());
					vB_Cache::instance()->cleanNow();
					unset($content);
				}
				break;

			case 'new_section':
				global $vbulletin;
				vB::$vbulletin->input->clean_array_gpc('p',
					array('title' => TYPE_STR ,
					'sectionid' => TYPE_INT,
					'target_sectionid' => TYPE_INT,
					'section_title' => TYPE_STR
					));
				if (!vB::$vbulletin->GPC_exists['parentnode'] AND vB::$vbulletin->GPC_exists['target_sectionid'])
				{
					$vbulletin->GPC_exists['parentnode'] = 1;
					$vbulletin->GPC['parentnode'] = $vbulletin->GPC['target_sectionid'];
				}
				elseif (!vB::$vbulletin->GPC_exists['parentnode'] AND vB::$vbulletin->GPC_exists['sectionid'])
				{
					$vbulletin->GPC_exists['parentnode'] = 1;
					vB::$vbulletin->GPC['parentnode'] = vB::$vbulletin->GPC['sectionid'];
				}
				
				if (vB::$vbulletin->GPC_exists['title'] AND vB::$vbulletin->GPC_exists['parentnode']
					and vB::$vbulletin->GPC['parentnode'])
				{
					{

						if ($content = vBCms_Content::create('vBCms', 'Section'))
						{
							$nodedm = new vBCms_DM_Section();
							$nodedm->set('parentnode', $vbulletin->GPC['parentnode']);
							if (! $nodeid = $content->createDefaultContent($nodedm))
							{
								throw (new vB_Exception_DM('Could not create new node for content: ' . print_r($nodedm->getErrors())));
							}
						}
						vB_Cache::instance()->event('sections_updated');
						vB_Cache::instance()->cleanNow();
						//now let's display the new section.
						vB::$vbulletin->GPC_exists['sectionid'] = 1;
						vB::$vbulletin->GPC['sectionid'] = $nodeid;
					}
				}
				break;

			case 'new':

				//
				if (vB::$vbulletin->GPC_exists['sectionid'] AND vB::$vbulletin->GPC_exists['new_contenttype'])
				{
					$contenttypeid = vB::$vbulletin->GPC['new_contenttype'];
					try
					{
						// create the nodedm
						$class  =vB_Types::instance()->getContentClassFromId($contenttypeid);
						$classname = "vBCms_DM_" . $class['class'];

						if (class_exists($classname))
						{
							$nodedm = new $classname;
						}
						else
						{
							$nodedm = new vBCms_DM_Node();
						}

						// create content handler
						$content = vBCms_Content::create(vB_Types::instance()->getContentTypePackage($contenttypeid), vBCms_Types::instance()->getContentTypeClass($contenttypeid));


						// insert default content for the contenttype and get the new contentid
						$content->setParentNode(vB::$vbulletin->GPC['sectionid']);

						$contentid = $content->createDefaultContent($nodedm);
					}
					catch (vB_Exception $e)
					{
						throw (new vB_Exception_DM('Could not create default content.  Exception thrown with message: \'' . htmlspecialchars_uni($e->getMessage()) . '\''));
					}

					// Create new content node
					$nodedm->set('contenttypeid', $contenttypeid);
					$nodedm->set('contentid', $contentid);

					$nodedm->set('parentnode', vB::$vbulletin->GPC['sectionid']);
					$nodedm->set('title', (vB::$vbulletin->GPC_exists['section_title']?
						vB::$vbulletin->GPC['section_title'] : vB::$vbulletin->GPC['section_title']) );


					//allow child nodes to set the author. This is necessary when we
					//promote a post
					if (! $nodedm->getSet('userid'))
					{
						$nodedm->set('userid', vB::$vbulletin->userinfo['userid']);
					}

					if (!($nodeid = $nodedm->save()))
					{
						throw (new vB_Exception_DM('Could not create new node for content: ' . print_r($nodedm->getErrors())));
					}
					vB_Cache::instance()->event('section_nav_' . vB::$vbulletin->GPC['sectionid']);
					vB_Cache::instance()->event('sections_updated');
					vB_Cache::instance()->event('articles_updated');
					vB_Cache::instance()->cleanNow();
				}
				break;

			case 'save_nodes':
				//The only thing we're updating is the publicpreview flag

				self::savePreview();
				vB_Cache::instance()->event('articles_updated');
			default:
				;
		} // switch
		return $msg;
	}
Esempio n. 9
0
	/**
	 * Return the widgettype title.
	 */
	public function getTypeTitle()
	{
		return vBCms_Types::instance()->getWidgetTypeTitle(array('package' => $this->getPackage(), 'class' => $this->getClass()));
	}
Esempio n. 10
0
	/**
	 * Fetches the package class identifier of the contenttype.
	 * Note: This is only a segment of the class name.  It should be combined with
	 * the content class identifier and the required class type.
	 *
	 * Usually class names can be resolved with the vB_Content for a specific
	 * content type.
	 *
	 * @return string
	 */
	public function getPackage()
	{
		$this->Load();

		if ($this->contenttypeid)
		{
			return vBCms_Types::instance()->getContentTypePackage($this->contenttypeid);
		}

		return $this->package;
	}
Esempio n. 11
0
	/**
	 * Creates a widget to add to the collection.
	 *
	 * @param array mixed $iteminfo				- The known properties of the new item
	 * @return vB_Item							- The created item
	 */
	protected function createItem($iteminfo, $load_flags = false)
	{
		$class = vBCms_Types::instance()->getWidgetTypeClass($iteminfo['widgettypeid']);
		$package = vBCms_Types::instance()->getWidgetTypePackage($iteminfo['widgettypeid']);

		$item_class = $package . '_Item_Widget_' . $class;
		$item = new $item_class($iteminfo[$this->primary_key]);

		$item->setInfo($iteminfo, $load_flags);

		if ($this->nodeid)
		{
			$item->setNodeId($this->nodeid);
		}

		return $item;
	}