Beispiel #1
0
	/**
	 * Prepares properties for rendering.
	 */
	protected function prepareProperties()
	{
		parent::prepareProperties();

		// vB_View_Content has already htmlspecialchars_uni($this->title) so we should not htmlspecialchars_uni again here. Fixed bug #29663
		// $this->title = htmlspecialchars_uni($this->title);
		$this->css = new vB_View('vbcms_article_css');
		$this->author_phrase = new vB_Phrase('vbcms', 'author');

		if ($this->pagelist AND sizeof($this->pagelist) > 1)
		{
			// create a route
			$route = new vBCms_Route_Content();
			$route->setSegments(array('node' => $this->nodesegment, 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')));

			$pagelist = $this->pagelist;
			$pagelist[1] = $this->title;
			$this->pagelist = $pagelist;

			$pages = array();
			foreach ($this->pagelist AS $pagenum => $title)
			{
				$route->setParameter(0, $pagenum);
				$title = $title ? $title : new vB_Phrase('vbcms', 'page_x', $pagenum);

				// undo the 'stop_parse' from the [page] bbcode and strip bbcode and html
				$title = vbchop(strip_tags(strip_bbcode(str_replace(array('[', ']'), array('[', ']'), $title))), 75);

				$pages[$pagenum] = array(
					'url'      => $route->getCurrentURL(null, array($pagenum)),
					'title'    => htmlspecialchars_uni($title),
					'selected' => ($pagenum == $this->current_page) ? 1 : 0
				);
			}

			if ($this->current_page > 1)
			{
				$this->prev_page_url = $pages[$this->current_page - 1]['url'];
				$this->prev_page_phrase = new vB_Phrase('vbcms', 'previous');
			}

			if ($this->current_page < sizeof($pages))
			{
				$this->next_page_url = $pages[$this->current_page + 1]['url'];
				$this->next_page_phrase = new vB_Phrase('vbcms', 'next');
			}

			$this->pagelist = $pages;
		}
		else
		{
			$this->pagelist = false;
		}
	}
Beispiel #2
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));
	}