public function __construct($id, $module = null) { //$this->initAPI(); parent::__construct($id, $module); $this->initMenu(); $this->initAssets(); $this->url_referrer = Yii::app()->request->urlReferrer; $this->requests = SearchRequests::model()->getUserRequests(WebUser::Id(true)); $this->listings = ListingNames::model()->getUserLists(WebUser::Id()); if (!WebUser::isGuest()) { $user = WebUser::getModel(); $user->date_last_visit = time(); $user->save(); } }
/** * @param $user_id * @return SearchRequests[] */ public function getUserRequests($user_id) { $criteria = new CDbCriteria(); $criteria->compare('user_id', $user_id); $criteria->order = 'date_update DESC'; return SearchRequests::model()->findAll($criteria); }
<?php echo CHtml::activeLabelEx($model, 'auction_type_id'); ?> <?php $listing_types = array('All', 'Auction', 'BuyItNow', 'Classified', 'FixedPrice', 'StoreInventory'); //$listing_types = array_combine(array_keys($model->getAuctionTypes()), $listing_types); $listing_types = $model->getAuctionTypes(); echo CHtml::activeDropDownList($model, 'auction_type_id', $listing_types); ?> </div> <div class="span3"> <?php echo CHtml::activeLabelEx($model, 'condition'); ?> <?php $conditions = SearchRequests::model()->getItemsConditions(); echo CHtml::activeDropDownList($model, 'condition', $conditions); ?> </div> </td> </tr> <tr> <td> <table> <tbody> <tr> <td> <?php echo Yii::t('sniper_ebay', 'Min Price');
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded * @return SearchRequests */ public function loadModel($id) { $model = SearchRequests::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Process and render search results. * * @param array $data The raw request data submitted by user * @param SearchForm $form The form instance that was submitted * @param SS_HTTPRequest $request Request generated for this action */ public function getSearchResults($request) { $list = new ArrayList(); $v = $request->getVars(); $q = $v["Search"]; $input = DB::getConn()->addslashes($q); $data = DB::query("SELECT * FROM SearchableDataObjects WHERE MATCH (Title, Content) AGAINST ('{$input}' IN NATURAL LANGUAGE MODE)"); foreach ($data as $row) { $do = DataObject::get_by_id($row['ClassName'], $row['ID']); /* * Check that we have been returned a valid DataObject, using the * ClassName and ID stored in the SortableDataObject DB table, to * prevent PHP notice: * * [Strict Notice] Creating default object from empty value * * caused when DataObject::get_by_id() returns false */ if (is_object($do) && $do->exists()) { $do->Title = $row['Title']; $do->Content = $row['Content']; $list->push($do); } } $pageLength = Config::inst()->get('CustomSearch', 'items_per_page'); $ret = new PaginatedList($list, $request); $ret->setPageLength($pageLength); $input = strtolower($input); $result = DataObject::get('SearchRequests')->where(sprintf('Phrase = \'%s\'', $input))->limit(1); if ($result->first()) { $request = $result->first(); $request->Count = $request->Count + 1; } else { $request = new SearchRequests(); $request->Phrase = $input; $request->Results = count($list); } $request->write(); return $ret; }