Example #1
0
 /**
  * Parses the user request.
  * @param CHttpRequest $request The request application component.
  * @return string The route (controllerID/actionID) and perhaps GET parameters in path format.
  */
 public function parseUrl($request)
 {
     $route = $request->getQuery('r');
     if (is_null($route)) {
         $route = $request->getPathInfo();
     }
     $app = Yii::app()->getModule('herbie')->application;
     try {
         $path = $app['urlMatcher']->match($route);
     } catch (Exception $ex) {
         // Don't catch exception
     }
     if (!empty($path)) {
         return 'herbie/page';
     }
     return parent::parseUrl($request);
 }
Example #2
0
 /**
  * @param CHttpRequest $request
  * @return array
  */
 public function getTypeAttributesForSearchFromQuery(CHttpRequest $request)
 {
     $attributes = Yii::app()->getCache()->get('Store::filter::attributes');
     if (false === $attributes) {
         $attributes = [];
         $models = Attribute::model()->findAll(['select' => ['name', 'id', 'type']]);
         foreach ($models as $model) {
             $attributes[$model->name] = $model;
         }
         Yii::app()->getCache()->set('Store::filter::attributes', $attributes);
     }
     $result = [];
     $attributeValue = new AttributeValue();
     foreach ($attributes as $name => $attribute) {
         $searchParams = $request->getQuery($attribute->name);
         //пропускаем пустые значения
         if (null === $searchParams) {
             continue;
         }
         if (is_array($searchParams)) {
             if (isset($searchParams['from']) && null == $searchParams['from']) {
                 unset($searchParams['from']);
             }
             if (isset($searchParams['to']) && null == $searchParams['to']) {
                 unset($searchParams['to']);
             }
             if (empty($searchParams)) {
                 continue;
             }
         }
         $result[$attribute->name] = ['value' => $searchParams, 'attribute_id' => (int) $attribute->id, 'column' => $attributeValue->column($attribute->type)];
     }
     return $result;
 }
Example #3
0
 /**
  * @param CHttpRequest $request
  * @return array
  */
 public function getEavAttributesForSearchFromQuery(CHttpRequest $request)
 {
     $result = $params = [];
     $attributes = Attribute::model()->cache(Yii::app()->getModule('yupe')->coreCacheTime)->findAll(['select' => ['name']]);
     foreach ($attributes as $attribute) {
         if ($request->getQuery($attribute->name)) {
             $searchParams = $request->getQuery($attribute->name);
             if (!is_array($searchParams)) {
                 $result[$attribute->name] = $searchParams;
                 continue;
             }
             $isFrom = array_key_exists('from', $searchParams);
             $isTo = array_key_exists('to', $searchParams);
             if (false === $isFrom && false === $isTo) {
                 $result[$attribute->name] = $searchParams;
                 continue;
             }
             if (true === $isFrom && !empty($searchParams['from'])) {
                 $result[] = ['>=', $attribute->name, (double) $searchParams['from']];
             }
             if (true === $isTo && !empty($searchParams['to'])) {
                 $result[] = ['<=', $attribute->name, (double) $searchParams['to']];
             }
         }
     }
     return $result;
 }
Example #4
0
 public function actionIndex()
 {
     $this->render('index', array('callback' => SearchController::search(CHttpRequest::getQuery('text'))));
 }
Example #5
0
<div class="filter pager">
  <ul class="yiiPager">
    <?php 
foreach (range('A', 'Z') as $filter) {
    ?>
      <li class="page <?php 
    if ($filter === CHttpRequest::getQuery('filter')) {
        echo 'selected';
    }
    ?>
">
        <?php 
    echo CHtml::link($filter, $this->createUrl('', array_merge($_GET, array('filter' => $filter))));
    ?>
      </li>
    <?php 
}
?>
  </ul>
</div>
Example #6
0
 public function actionWishlist()
 {
     $criteria = new CDbCriteria();
     $criteria->alias = 'm';
     $criteria->select = 'm.*';
     $criteria->join = 'JOIN user2movie um ON m.id=um.movie_id';
     $criteria->join .= ' JOIN user u ON um.user_id=u.id';
     $username = CHttpRequest::getQuery('username', Yii::app()->user->name);
     $criteria->condition = 'u.username=:username';
     $criteria->params[':username'] = $username;
     $criteria->condition .= ' AND um.on_wishlist=1';
     $criteria->order = 'm.url_key ASC';
     $criteria->with = array('attributes', 'images');
     if ($filter = CHttpRequest::getQuery('filter')) {
         $criteria->condition .= ' AND url_key LIKE :filter';
         $criteria->params[':filter'] = "{$filter}%";
     }
     $dataProvider = new CActiveDataProvider('Movie', array('criteria' => $criteria, 'pagination' => array('pageSize' => 9)));
     $this->render('index', array('dataProvider' => $dataProvider));
 }
Example #7
0
<?php

$this->pageTitle = Yii::app()->name . ' - Movies';
$this->breadcrumbs = array('Movies');
$this->menu = array();
?>

<img src="/images/uploads/avatar/<?php 
echo CHttpRequest::getQuery('username', Yii::app()->user->name);
?>
.jpg" class="avatar"/>
<?php 
if ($username = CHttpRequest::getQuery('username')) {
    ?>
  <h1>Movie-Library of <?php 
    echo $username;
    ?>
</h1>
<?php 
} else {
    ?>
  <h1>Your Movie-Library</h1>
<?php 
}
?>

<?php 
$this->renderPartial('_filter');
?>

<br class="clear"/>