当前位置: 首页>>代码示例>>PHP>>正文


PHP VmModel::getTable方法代码示例

本文整理汇总了PHP中VmModel::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP VmModel::getTable方法的具体用法?PHP VmModel::getTable怎么用?PHP VmModel::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VmModel的用法示例。


在下文中一共展示了VmModel::getTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderGuiList

	/**
	 * Builds an enlist for information (not chooseable)
	 *
	 * @author Max Milbers
	 *
	 * @param array $idList ids
	 * @param string $table vmTable to use
	 * @param string $name fieldname for the name
	 * @param string $view view for the links
	 * @param bool $tableXref the xref table
	 * @param bool $tableSecondaryKey the fieldname of the xref table
	 * @param int $quantity
	 * @param bool $translate
	 * @return string
	 */
	static public function renderGuiList ($idList, $table, $name, $view, $tableXref = false, $tableSecondaryKey = false, $quantity = 3, $translate = true ) {

		$list = '';
		$ttip = '';
		$link = '';

		if ($view != 'user' and $view != 'shoppergroup') {
			$cid = 'cid';
		} else if ($view == 'user'){
			$cid = 'virtuemart_user_id';
		} else {
			$cid = 'virtuemart_shoppergroup_id';
		}

		$model = new VmModel();
		$table = $model->getTable($table);

		if(!is_array($idList)){
			$db = JFactory::getDBO ();
			$q = 'SELECT `' . $table->getPKey() . '` FROM `#__virtuemart_' . $db->escape ($tableXref) . '` WHERE ' . $db->escape ($tableSecondaryKey) . ' = "' . (int)$idList . '"';
			$db->setQuery ($q);
			$idList = $db->loadColumn ();
		}

		$i = 0;

		foreach($idList as $id ){

			$item = $table->load ((int)$id);
			if($translate) $item->$name = vmText::_($item->$name);
			$link = ', '.JHtml::_('link', JRoute::_('index.php?option=com_virtuemart&view='.$view.'&task=edit&'.$cid.'[]='.$id,false), $item->$name);
			if($i<$quantity and $i<=count($idList)){
				$list .= $link;
			} else if ($i==$quantity and $i<count($idList)){
				$list .= ',...';
			}
			$ttip .= ', '.$item->$name;
			if($i>($quantity + 6)) {
				$ttip .= ',...';
				break;
			}
			$i++;
		}

		$list = substr ($list, 2);
		$ttip = substr ($ttip, 2);

		return '<span class="hasTip" title="'.$ttip.'" >' . $list . '</span>';
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:64,代码来源:shopfunctions.php

示例2: saveRating

 /**
  * Save a rating
  * @author  Max Milbers
  */
 public function saveRating($data = 0)
 {
     //Check user_rating
     $maxrating = VmConfig::get('vm_maximum_rating_scale', 5);
     $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', 0);
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $user = JFactory::getUser();
         $userId = $user->id;
         $allowReview = $this->allowReview($virtuemart_product_id);
         $allowRating = $this->allowRating($virtuemart_product_id);
     } else {
         $userId = $data['created_by'];
         $allowReview = true;
         $allowRating = true;
     }
     if (!empty($virtuemart_product_id)) {
         //if ( !empty($data['virtuemart_product_id']) && !empty($userId)){
         if (empty($data)) {
             $data = vRequest::getPost();
         }
         if ($allowRating) {
             //normalize the rating
             if ($data['vote'] < 0) {
                 $data['vote'] = 0;
             }
             if ($data['vote'] > $maxrating + 1) {
                 $data['vote'] = $maxrating;
             }
             $data['lastip'] = $_SERVER['REMOTE_ADDR'];
             $data['vote'] = (int) $data['vote'];
             $rating = $this->getRatingByProduct($data['virtuemart_product_id']);
             vmdebug('$rating', $rating);
             $vote = $this->getVoteByProduct($data['virtuemart_product_id'], $userId);
             vmdebug('$vote', $vote);
             $data['virtuemart_rating_vote_id'] = empty($vote->virtuemart_rating_vote_id) ? 0 : $vote->virtuemart_rating_vote_id;
             if (isset($data['vote'])) {
                 $votesTable = $this->getTable('rating_votes');
                 $votesTable->bindChecknStore($data, TRUE);
                 $errors = $votesTable->getErrors();
                 foreach ($errors as $error) {
                     vmError(get_class($this) . '::Error store votes ' . $error);
                 }
             }
             if (!empty($rating->rates) && empty($vote)) {
                 $data['rates'] = $rating->rates + $data['vote'];
                 $data['ratingcount'] = $rating->ratingcount + 1;
             } else {
                 if (!empty($rating->rates) && !empty($vote->vote)) {
                     $data['rates'] = $rating->rates - $vote->vote + $data['vote'];
                     $data['ratingcount'] = $rating->ratingcount;
                 } else {
                     $data['rates'] = $data['vote'];
                     $data['ratingcount'] = 1;
                 }
             }
             if (empty($data['rates']) || empty($data['ratingcount'])) {
                 $data['rating'] = 0;
             } else {
                 $data['rating'] = $data['rates'] / $data['ratingcount'];
             }
             $data['virtuemart_rating_id'] = empty($rating->virtuemart_rating_id) ? 0 : $rating->virtuemart_rating_id;
             vmdebug('saveRating $data', $data);
             $rating = $this->getTable('ratings');
             $rating->bindChecknStore($data, TRUE);
             $errors = $rating->getErrors();
             foreach ($errors as $error) {
                 vmError(get_class($this) . '::Error store rating ' . $error);
             }
         }
         if ($allowReview and !empty($data['comment'])) {
             //if(!empty($data['comment'])){
             $data['comment'] = substr($data['comment'], 0, VmConfig::get('vm_reviews_maximum_comment_length', 2000));
             // no HTML TAGS but permit all alphabet
             $value = preg_replace('@<[\\/\\!]*?[^<>]*?>@si', '', $data['comment']);
             //remove all html tags
             $value = (string) preg_replace('#on[a-z](.+?)\\)#si', '', $value);
             //replace start of script onclick() onload()...
             $value = trim(str_replace('"', ' ', $value), "'");
             $data['comment'] = (string) preg_replace('#^\'#si', '', $value);
             //replace ' at start
             $data['comment'] = nl2br($data['comment']);
             // keep returns
             //set to defaut value not used (prevent hack)
             $data['review_ok'] = 0;
             $data['review_rating'] = 0;
             $data['review_editable'] = 0;
             // Check if ratings are auto-published (set to 0 prevent injected by user)
             //
             $app = JFactory::getApplication();
             if ($app->isSite()) {
                 if (VmConfig::get('reviews_autopublish', 1)) {
                     $data['published'] = 1;
                 } else {
                     $model = new VmModel();
                     $product = $model->getTable('products');
//.........这里部分代码省略.........
开发者ID:lenard112,项目名称:cms,代码行数:101,代码来源:ratings.php

示例3: deleteCart

 public function deleteCart()
 {
     $model = new VmModel();
     $carts = $model->getTable('carts');
     if (!empty($this->virtuemart_cart_id)) {
         $carts->delete($this->virtuemart_cart_id, 'virtuemart_cart_id');
     } else {
         $currentUser = JFactory::getUser();
         if (!empty($currentUser->id)) {
             $carts->delete($currentUser->id);
         }
     }
 }
开发者ID:chaudhary4k4,项目名称:modernstore,代码行数:13,代码来源:cart.php

示例4: deleteCart

 public function deleteCart()
 {
     $currentUser = JFactory::getUser();
     if (!$currentUser->guest) {
         $model = new VmModel();
         $carts = $model->getTable('carts');
         $carts->delete($currentUser->id);
     }
 }
开发者ID:lenard112,项目名称:cms,代码行数:9,代码来源:cart.php


注:本文中的VmModel::getTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。