コード例 #1
0
ファイル: attach.php プロジェクト: 0hyeah/yurivn
 /**
  * Select library
  *
  * @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  * @param	integer			Unique id of this contenttype (forum post, blog entry, etc)
  * @param	boolean			Display thumbnail
  * @param	integer			Unique id of this item attachment.attachmentid
  *
  * @return	object
  */
 public static function &fetch_library(&$registry, $contenttypeid, $thumbnail, $attachmentid)
 {
     if (self::$instance) {
         return self::$instance;
     }
     $types = vB_Types::instance();
     $attachmentinfo = array();
     if (!$contenttypeid) {
         // Send the contenttypeid into fetch_library to avoid this query!
         $contentinfo = $registry->db->query_first_slave("\n\t\t\t\tSELECT a.contenttypeid\n\t\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\t\tWHERE a.attachmentid = {$attachmentid}\n\t\t\t");
         $contenttypeid = $contentinfo['contenttypeid'];
     }
     if (!($contenttypeid = $types->getContentTypeID($contenttypeid))) {
         return false;
     }
     $package = $types->getContentTypePackage($contenttypeid);
     $class = $types->getContentTypeClass($contenttypeid);
     $selectclass = "vB_Attachment_Display_Single_{$package}_{$class}";
     $path = DIR . '/packages/' . strtolower($package) . '/attach/' . strtolower($class) . '.php';
     if (file_exists($path)) {
         include_once DIR . '/packages/' . strtolower($package) . '/attach/' . strtolower($class) . '.php';
         if (class_exists($selectclass)) {
             self::$instance = new $selectclass($registry, $attachmentid, $thumbnail);
             return self::$instance;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: attach.php プロジェクト: hungnv0789/vhtm
	/**
	* Select library
	*
	* @param	vB_Registry	Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
	* @param	integer			Unique id of this contenttype (forum post, blog entry, etc)
	* @param	boolean			Display thumbnail
	* @param	integer			Unique id of this item attachment.attachmentid
	*
	* @return	object
	*/
	public static function &fetch_library(&$registry, $contenttypeid, $thumbnail, $attachmentid)
	{
		if (self::$instance)
		{
			return self::$instance;
		}

		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/vb/types.php');
		vB_Bootstrap_Framework::init();
		$types = vB_Types::instance();

		$attachmentinfo = array();
		if (!$contenttypeid)
		{
			// Send the contenttypeid into fetch_library to avoid this query!
			$contentinfo = $registry->db->query_first_slave("
				SELECT a.contenttypeid
				FROM " . TABLE_PREFIX . "attachment AS a
				WHERE a.attachmentid = $attachmentid
			");
			$contenttypeid = $contentinfo['contenttypeid'];
		}

		if (!($contenttypeid = $types->getContentTypeID($contenttypeid)))
		{
			return false;
		}

		$package = $types->getContentTypePackage($contenttypeid);
		$class = $types->getContentTypeClass($contenttypeid);

		$selectclass = "vB_Attachment_Display_Single_{$package}_{$class}";
		include_once(DIR . '/packages/' . strtolower($package) . '/attach/' . strtolower($class) . '.php');
		if (class_exists($selectclass))
		{
			self::$instance = new $selectclass($registry, $attachmentid, $thumbnail);
		}
		else
		{
			return false;
		}

		return self::$instance;
	}