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


PHP Picture::model方法代码示例

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


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

示例1: loadModel

 public function loadModel($id)
 {
     if (($model = Picture::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:7,代码来源:PictureBackendController.php

示例2: run

 public function run()
 {
     $models = Picture::model()->published()->onMainPage()->with('category')->findAll(array('order' => 'category.sort ASC, t.sort ASC', 'limit' => (int) $this->limit));
     if (empty($models)) {
         return;
     }
     $this->render($this->view, array('models' => $models));
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:8,代码来源:PortfolioWidget.php

示例3: actionIndex

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = array();
     $model['publishers'] = count(Publishing::model()->findAll());
     $model['authors'] = count(Author::model()->findAll());
     $model['books'] = count(Book::model()->findAll());
     $model['pictures'] = count(Picture::model()->findAll());
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index', ['model' => $model]);
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:15,代码来源:SiteController.php

示例4: actionResize

    public function actionResize($id1,$id2,$width,$height,$type) {
        $id = $id1*1000+$id2;
        /** @var Picture $picture */
        $picture = Picture::model()->findByPk($id);
        if (!$picture)
            throw new CHttpException(404,'The requested page does not exist.');

        if ($picture->resize($width,$height) !== null) {
            header("Content-type: ".$picture->getType()->getMime());
            echo file_get_contents($picture->getResizePath($width,$height));
            exit();
        }

        throw new CHttpException(404,'The requested page does not exist.');
    }
开发者ID:schyzoo,项目名称:giiy,代码行数:15,代码来源:GiiyPictureController.php

示例5: getBookAll

 public static function getBookAll($id)
 {
     $book = array();
     $modelBook = Book::model()->findByPk($id);
     $book['name'] = $modelBook->name;
     $book['date'] = $modelBook->date;
     $modelAuthor = Author::model()->findByPk($modelBook->author_id);
     $book['author'] = $modelAuthor->name;
     $modelPublisher = Publishing::model()->findByPk($modelAuthor->publishing_id);
     $book['publisher'] = $modelPublisher->name;
     $modelCategory = Category::model()->findByPk($modelBook->category_id);
     $book['category'] = $modelCategory->name;
     $criteria = new CDbCriteria();
     $criteria->compare('book_id', $modelBook->id);
     $bookPicture = Picture::model()->findAll($criteria);
     $book['pictures'] = array();
     foreach ($bookPicture as $pic) {
         $book['pictures'][] = $pic->image;
     }
     return $book;
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:21,代码来源:Front.php

示例6: actionShow

 public function actionShow($alias)
 {
     $model = Picture::model()->published()->with(array('category', 'author', 'color', 'images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->findByAlias($alias);
     if (!$model) {
         throw new CHttpException(404);
     }
     // Учитываем фильтр в каталоге
     $filter = Yii::app()->user->getState('galleryFilter');
     // Определяем следующую картину
     $nextItem = $model->getNextItem($filter);
     // Определяем предыдущую картину
     $prevItem = $model->getPrevItem($filter);
     // Увеличиваем значение счетчика просмотров картины
     if (!Yii::app()->request->cookies['hits']) {
         $cookie = new CHttpCookie('hits', true);
         $cookie->expire = time() + 3600;
         $cookie->path = $this->createUrl("/catalog/catalog/show", array("alias" => $alias));
         Yii::app()->request->cookies['hits'] = $cookie;
         $model->saveCounters(array('hits' => 1));
     }
     $this->render('picture', array('model' => $model, 'nextItem' => $nextItem, 'prevItem' => $prevItem, 'returnUrl' => Yii::app()->user->getState('galleryReturnUrl')));
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:22,代码来源:CatalogController.php

示例7: actionLoadVersionVehicle

 public function actionLoadVersionVehicle()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'reference';
     $criteria->condition = 'id != 32 AND id != 33 AND id != 34  AND id != 36 AND id != 37 AND id != 38 AND id != 39 AND id != 40 AND id != 41 AND id != 42';
     $vehicle_version = VehicleVersion::model()->findAllByAttributes(array("vehicle_id" => $_POST['vehicle_id'], "status" => "ACTIVE"), $criteria);
     $vehicle_image = Picture::model()->findByAttributes(array("vehicle_id" => $_POST['vehicle_id']));
     $vehicle_s = Vehicle::model()->findByPk($_POST['vehicle_id']);
     $return = array();
     foreach ($vehicle_version as $z => $vehicle) {
         $return[$z]['id'] = $vehicle->id;
         $return[$z]['reference'] = $vehicle->reference;
         $return[$z]['motor'] = $vehicle->motor;
         $return[$z]['type'] = $vehicle->type;
         $return[$z]['transmission'] = $vehicle->transmission;
         $return[$z]['combustion'] = $vehicle->combustion;
         $return[$z]['ac'] = $vehicle->ac;
         $return[$z]['abs'] = $vehicle->abs;
     }
     $return['image'] = $vehicle_image->description;
     $return['name'] = $vehicle_s->name;
     echo json_encode($return);
 }
开发者ID:frankpaul142,项目名称:nissan-modulos,代码行数:23,代码来源:DefaultController.php

示例8: loadModel

 /**
  * 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 $id the ID of the model to be loaded
  * @return Picture the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Picture::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:15,代码来源:PictureController.php

示例9: ActionDelPicture

 /**
  * 根据图片ID,对图片进行假删除
  */
 public function ActionDelPicture()
 {
     $picture_ID = $_POST['pic_id'];
     if (is_numeric($picture_ID)) {
         $picture_ID = intval($picture_ID);
         $picture_model = Picture::model()->findByPk($picture_ID);
         if (!empty($picture_model)) {
             //更新有效性状态为无效
             $count = Picture::model()->updateByPk($picture_ID, array('Valid' => 1));
             if ($count > 0) {
                 echo true;
             } else {
                 echo false;
             }
         } else {
             echo '数据不存在';
         }
     } else {
         echo '参数无效';
     }
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:24,代码来源:PictureController.php

示例10: ActionDelPictureCategory

 /**
  * 根据图片类型id,删除图片类型
  * @param $picture_category_id
  */
 public function ActionDelPictureCategory($picture_category_id)
 {
     $picture_category_model = PictureCategory::model();
     $picture_category_info = $picture_category_model->findByPk($picture_category_id);
     $pictures = Picture::model()->findAllByAttributes(array('CategoryId' => $picture_category_id));
     //判断图片类型是否有图片管理
     if (empty($pictures)) {
         if ($picture_category_info->delete()) {
             Yii::app()->user->setFlash('delete_pic', '删除成功');
             $this->redirect(Yii::app()->createUrl('PictureCategory/ListPictureCategory'));
         } else {
             Yii::app()->user->setFlash('delete_pic', '删除失败');
         }
     } else {
         Yii::app()->user->setFlash('delete_pic', '该图片类型不可删除,已有图片关联。');
         $this->redirect(Yii::app()->createUrl('PictureCategory/ListPictureCategory'));
     }
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:22,代码来源:PictureCategoryController.php

示例11: getPrevItem

 public function getPrevItem($filter = array())
 {
     $criteria = $this->_constructCriteriaByFilter($filter);
     $criteria->order = 'category.sort DESC, t.sort DESC';
     // Условие выборки по порядку
     $fullCriteria = clone $criteria;
     if ($this->category_id !== null) {
         $fullCriteria->addCondition('((t.category_id = :category_id AND t.sort <= :sort) OR category.sort < :category_sort) AND t.id <> :id');
         $fullCriteria->params = array_merge($fullCriteria->params, array(':category_id' => $this->category_id, ':sort' => $this->sort, ':category_sort' => $this->category->sort, ':id' => $this->id));
     } else {
         $fullCriteria->addCondition('t.sort <= :sort AND t.id <> :id');
         $fullCriteria->params = array_merge($fullCriteria->params, array(':sort' => $this->sort, ':id' => $this->id));
     }
     $prevItem = Picture::model()->published()->find($fullCriteria);
     if ($prevItem === null) {
         $prevItem = Picture::model()->published()->find($criteria);
     }
     return $prevItem;
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:19,代码来源:Picture_1.php

示例12: getIsCreateUser

 public function getIsCreateUser($pk, $model)
 {
     if ($model == "diary" && Diary::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
         return true;
     } else {
         if ($model == "photo" && Photo::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
             return true;
         } else {
             if ($model == "recent" && Recent::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
                 return true;
             } else {
                 if ($model == "timeline" && Timeline::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
                     return true;
                 } else {
                     if ($model == "pictue" && Picture::model()->findByPk($pk)->create_user == Yii::app()->user->id) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:ruzuojun,项目名称:shiqu,代码行数:23,代码来源:Comment.php

示例13: ActionPicture

 /**
  * @uses 根据参数查询图片信息。
  * 1:如果国家信息不为空,无城市参数,获取国家全部城市列表。
  * 2:如果国家信息为空,则以城市信息为准获取图片数据。
  * @link http://brs.baicheng.com/index.php?r=Api/Picture/picture
  * $json_params包含如下参数
  * country_id 国家id 【可选】 默认为:0 。
  * city_ids 城市id串 【可选】默认为空 例如:123,234,122。
  * cate_id 图片类型id 【可选】 默认为:0
  * page_size 分页大小 【可选】 默认为:20
  * page 页码 【可选】默认为:1
  * @return bool 返回数据,如果参数错误返回false,如果参数正确并获取到数据,则返回对应的json数据
  */
 public function ActionPicture()
 {
     $json_params = Yii::app()->request->getParam('json_params');
     if (!empty($json_params)) {
         $params_arr = json_decode($json_params, true);
         //大洲
         if (isset($params_arr['country_id']) && !empty($params_arr['country_id'])) {
             $country_id = $params_arr['country_id'];
         } else {
             $country_id = 0;
         }
         //城市
         if (isset($params_arr['city_ids']) && !empty($params_arr['city_ids'])) {
             $city_ids = $params_arr['city_ids'];
         } else {
             $city_ids = "";
         }
         //类型
         if (isset($params_arr['cate_id']) && !empty($params_arr['cate_id'])) {
             $cate_id = $params_arr['cate_id'];
         } else {
             $cate_id = 0;
         }
         //分页大小
         if (isset($params_arr['page_size']) && !empty($params_arr['page_size'])) {
             $page_size = $params_arr['page_size'];
         } else {
             $page_size = 20;
         }
         //页码
         if (isset($params_arr['page']) && !empty($params_arr['page'])) {
             $page = $params_arr['page'];
         } else {
             $page = 1;
         }
         if (empty($country_id) && empty($city_ids) || $page < 1 || $page_size < 1) {
             //参数错误
             return false;
         } else {
             if (!empty($country_id) && empty($city_ids)) {
                 //如果有国家id,无城市ids,将获取国家下的所有城市。
                 $country_cities = City::model()->findAllByAttributes(array('CountryID' => $country_id));
                 $country_cities_arr = array();
                 foreach ($country_cities as $cc) {
                     $country_cities_arr[] = $cc['ID'];
                 }
                 array_unique($country_cities_arr);
                 $city_ids = implode(",", $country_cities_arr);
                 //该国家所有的城市id串
             }
             $cities_arr = explode(",", $city_ids);
             //城市id串
             $pictures_arr = array();
             //返回的数组
             //分页获取图片信息
             $pic_condition = new CDbCriteria();
             $pic_condition->addInCondition('CityId', $cities_arr);
             $pic_condition->addColumnCondition(array('Valid' => 0));
             if (!empty($cate_id)) {
                 $pic_condition->addColumnCondition(array('CategoryId' => $cate_id));
             }
             $pic_condition->order = 'ID ASC';
             $count = Picture::model()->count($pic_condition);
             $pager = new CPagination($count);
             $pager->pageSize = $page_size;
             $pager->setCurrentPage($page - 1);
             $pager->applyLimit($pic_condition);
             $picture_list = Picture::model()->findAll($pic_condition);
             //返回数组中分页信息
             $pictures_arr['PageCount'] = $count;
             $pictures_arr['PageSize'] = $page_size;
             $pictures_arr['Page'] = $page;
             //封装返回数据
             foreach ($picture_list as $key => $val) {
                 $pictures_arr['PictureList'][$key]['ID'] = $val['ID'];
                 $pictures_arr['PictureList'][$key]['CityId'] = $val['CityId'];
                 $pictures_arr['PictureList'][$key]['CategoryId'] = $val['CategoryId'];
                 $pictures_arr['PictureList'][$key]['PictureCategoryName'] = $val->picture_category['PictureCategoryName'];
                 $pictures_arr['PictureList'][$key]['Name'] = $val['Name'];
                 $pictures_arr['PictureList'][$key]['Title'] = $val['Title'];
                 $pictures_arr['PictureList'][$key]['Description'] = $val['Description'];
                 foreach ($val->picture_source as $v) {
                     if ($v['SizeType'] == 0) {
                         $pictures_arr['PictureList'][$key]['PicSrcBig'] = str_replace("uploads/", "", $v['PicSrc']);
                     } elseif ($v['SizeType'] == 1) {
                         $pictures_arr['PictureList'][$key]['PicSrcMiddle'] = str_replace("uploads/", "", $v['PicSrc']);
                     } elseif ($v['SizeType'] == 2) {
//.........这里部分代码省略.........
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:101,代码来源:PictureController.php


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