當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::model方法代碼示例

本文整理匯總了PHP中Image::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::model方法的具體用法?PHP Image::model怎麽用?PHP Image::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Image的用法示例。


在下文中一共展示了Image::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:30,代碼來源:ResetAction.php

示例2: run

 public function run()
 {
     //SEO
     $this->controller->_seoTitle = $this->controller->_setting['seo_title'];
     $this->controller->_seoKeywords = $this->controller->_setting['seo_keywords'];
     $this->controller->_seoDescription = $this->controller->_setting['seo_description'];
     //頭部banner
     $index_top_banner = Ad::model()->getAdOne(4);
     //中部banner
     $index_mid_banner = Ad::model()->getAdOne(3);
     //底部banner
     $index_bottom_banner = Ad::model()->getAdOne(5);
     //最新資訊
     $news_new = Post::model()->getList(array('limit' => 20));
     //熱門資訊
     $news_hot = Post::model()->getList(array('order' => 't.view_count DESC, t.id DESC', 'limit' => 20));
     //最新圖集
     $image_new = Image::model()->getList(array('limit' => 10));
     //熱門圖集
     $image_hot = Image::model()->getList(array('limit' => 10, 'order' => 'view_count DESC, t.id DESC'));
     //最新軟件
     $soft_new = Soft::model()->getList(array('limit' => 20));
     //熱門軟件
     $soft_hot = Soft::model()->getList(array('limit' => 10, 'order' => 'down_count DESC, t.id DESC'));
     //最新視頻
     $video_new = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY id DESC Limit 20", array(':status' => 'Y'));
     //熱門視頻
     $video_hot = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY view_count DESC, video_score DESC, id DESC Limit 20", array(':status' => 'Y'));
     //友情鏈接
     $link_logos = Link::model()->findAll("logo !='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->controller->render('index', array('index_top_banner' => $index_top_banner, 'index_mid_banner' => $index_mid_banner, 'index_bottom_banner' => $index_bottom_banner, 'link_logos' => $link_logos, 'link_texts' => $link_texts, 'news_new' => $news_new, 'news_hot' => $news_hot, 'image_new' => $image_new, 'image_hot' => $image_hot, 'soft_new' => $soft_new, 'soft_hot' => $soft_hot, 'video_new' => $video_new, 'video_hot' => $video_hot));
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:33,代碼來源:IndexAction.php

示例3: actionFoto

 public function actionFoto($id)
 {
     $model = Image::model()->findByPk((int) $id);
     if (is_null($model)) {
         throw new CHttpException(404, Yii::t('gallery', 'Страница не найдена!'));
     }
     $this->render('foto', array('model' => $model));
 }
開發者ID:RSol,項目名稱:yupe,代碼行數:8,代碼來源:ContestController.php

示例4: selectByRow

 public function selectByRow($table, $row_id)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'path';
     $criteria->condition = 'row_id=:row_id AND `table`=:table';
     $criteria->params = array(':row_id' => $row_id, ':table' => $table);
     $result = Image::model()->find($criteria);
     //error_log(var_dump($data,1));
     return $result;
 }
開發者ID:vasia-ostapchuk,項目名稱:source,代碼行數:10,代碼來源:image.php

示例5: 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Image::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
開發者ID:rinodung,項目名稱:yii-shop,代碼行數:16,代碼來源:ImageController.php

示例6: actionImageDelete

 public function actionImageDelete($id)
 {
     $model = Image::model()->findByPk((int) $id);
     if ($model) {
         $model->delete();
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
         }
     } else {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
 }
開發者ID:resoul,項目名稱:resoul,代碼行數:12,代碼來源:GoodsController.php

示例7: run

 public function run()
 {
     $catalog_id = trim(Yii::app()->request->getParam('catalog_id'));
     $order = trim(Yii::app()->request->getParam('order'));
     if (!$order) {
         $order = 'id';
     }
     switch ($order) {
         case 'id':
             $order_by = 't.id DESC';
             break;
         case 'view_count':
             $order_by = 'view_count DESC';
             break;
         default:
             $order = 'id';
             $order_by = 't.id DESC';
             break;
     }
     //SEO
     $navs = array();
     $search_cats = '所有';
     if ($catalog_id) {
         $condition = ' AND catalog_id = ' . $catalog_id;
         $catalog = Catalog::model()->findByPk($catalog_id);
         if ($catalog) {
             $this->controller->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->controller->_setting['site_name'];
             $this->controller->_seoKeywords = $catalog->seo_keywords;
             $this->controller->_seoDescription = $catalog->seo_description;
             $navs[] = array('url' => $this->controller->createUrl('image/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
             //已搜索的分類
             $cat_parents = Catalog::getParantsCatalog($catalog_id);
             $search_cats = $cat_parents ? implode('>', $cat_parents) . '>' . $catalog->catalog_name : $catalog->catalog_name;
         }
     }
     if (!$navs) {
         $condition = '';
         $catalog = array();
         $seo = ModelType::getSEO('image');
         $this->controller->_seoTitle = $seo['seo_title'] . ' - ' . $this->controller->_setting['site_name'];
         $this->controller->_seoKeywords = $seo['seo_keywords'];
         $this->controller->_seoDescription = $seo['seo_description'];
         $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $this->controller->_seoTitle);
     }
     //獲取所有符合條件的圖集
     $pages = array();
     $datalist = Image::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
     //該欄目下最新的圖集
     $last_images = Image::model()->getList(array('condition' => $condition, 'limit' => 10));
     $this->controller->render('index', array('navs' => $navs, 'catalog' => $catalog, 'datalist' => $datalist, 'pagebar' => $pages, 'last_images' => $last_images, 'order' => $order, 'search_cats' => $search_cats));
 }
開發者ID:manjingzi,項目名稱:yiifcms,代碼行數:51,代碼來源:IndexAction.php

示例8: actionReset

 /**
  * 
  * 重新統計標簽,刪除不匹配的標簽
  * 
  */
 public function actionReset()
 {
     $tags = Tag::model()->findAll();
     foreach ((array) $tags as $tag) {
         $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
         $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
         $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
         if (!$post && !$image && !$soft) {
             $tag->delete();
         } else {
             $tag->data_count = count($post) + count($image) + count($soft);
             $tag->save();
         }
     }
     $this->message('success', Yii::t('admin', 'Reset Tags Success'), $this->createUrl('index'));
 }
開發者ID:github-zjh,項目名稱:task,代碼行數:21,代碼來源:TagController.php

示例9: actionIndex

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     //首頁banner幻燈片
     $banner = Ad::model()->findAll('position_id=:pid', array(':pid' => 1));
     //SEO
     $this->_seoTitle = $this->_setting['seo_title'];
     $this->_seoKeywords = $this->_setting['seo_keywords'];
     $this->_seoDescription = $this->_setting['seo_description'];
     //加載css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/index.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.easytabs.min.js");
     //頭部banner
     $index_top_banner = Ad::model()->getAdOne(4);
     //中部banner
     $index_mid_banner = Ad::model()->getAdOne(3);
     //底部banner
     $index_bottom_banner = Ad::model()->getAdOne(5);
     //最新資訊
     Yii::app()->cache && ($news_new = Yii::app()->cache->get('news_new'));
     if ($news_new == false) {
         $news_new = Post::model()->getList(array('limit' => 20));
         Yii::app()->cache && Yii::app()->cache->set('news_new', $news_new);
     }
     //熱門資訊
     Yii::app()->cache && ($news_hot = Yii::app()->cache->get('news_host'));
     if ($news_hot == false) {
         $news_hot = Post::model()->getList(array('order' => 't.view_count DESC, t.id DESC', 'limit' => 20));
         Yii::app()->cache && Yii::app()->cache->set('news_hot', $news_hot);
     }
     //最新圖集
     $image_new = Image::model()->getList(array('limit' => 10));
     //熱門圖集
     $image_hot = Image::model()->getList(array('limit' => 10, 'order' => 'view_count DESC, t.id DESC'));
     //最新軟件
     $soft_new = Soft::model()->getList(array('limit' => 20));
     //熱門軟件
     $soft_hot = Soft::model()->getList(array('limit' => 10, 'order' => 'down_count DESC, t.id DESC'));
     //最新視頻
     //$video_new = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY id DESC Limit 20", array(':status'=>'Y'));
     //熱門視頻
     //$video_hot = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY view_count DESC, video_score DESC, id DESC Limit 20", array(':status'=>'Y'));
     //友情鏈接
     $link_logos = Link::model()->findAll("logo !='' AND status_is='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' or logo is null AND status_is='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->render('index', compact(array('index_top_banner', 'index_mid_banner', 'index_bottom_banner', 'link_logos', 'link_texts', 'news_new', 'news_hot', 'image_new', 'image_hot', 'soft_new', 'soft_hot', 'video_new', 'video_hot')));
 }
開發者ID:jzxyouok,項目名稱:yiifcms,代碼行數:51,代碼來源:SiteController.php

示例10: run

 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //刪除
             foreach ((array) $ids as $id) {
                 //刪除關聯的標簽
                 TagData::model()->deleteAll('content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->controller->_type_ids['post']));
             }
             Image::model()->deleteAll($criteria);
             break;
         case 'show':
             //顯示
             Image::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隱藏
             Image::model()->updateAll(['status' => 'N'], $criteria);
             break;
         case 'commend':
             //圖集推薦
             $content_id = implode(',', $ids);
             $type_key = 'image';
             $this->controller->redirect($this->controller->createUrl('recommend/create', array('content_id' => $content_id, 'type_key' => $type_key)));
             break;
         case 'stick':
             //圖集置頂
             Image::model()->updateAll(['top_line' => 'Y'], $criteria);
             break;
         case 'cancelStick':
             //圖集取消置頂
             Image::model()->updateAll(['top_line' => 'N'], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:46,代碼來源:BatchAction.php

示例11: selectBySingerId

 public function selectBySingerId($singer_id)
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->condition = 'id=:singer_id';
     $criteria->params = array(':singer_id' => $singer_id);
     $result = Singer::model()->find($criteria);
     $image = Image::model()->selectByRow('singer', $singer_id);
     $style = Style::model()->selectBySingerId($singer_id);
     $result = $result['attributes'];
     if ($image) {
         $result['path'] = $image->path;
     }
     if ($style) {
         $result['style'] = $style;
     }
     return $result;
 }
開發者ID:vasia-ostapchuk,項目名稱:source,代碼行數:18,代碼來源:singer.php

示例12: run

 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $post = Image::model()->findByPk(intval($id));
     if (false == $post || $post->status == 'N') {
         throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
     }
     //更新瀏覽次數
     $post->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $id));
     //seo信息
     $this->controller->_seoTitle = empty($post->seo_title) ? $post->title . ' - ' . $this->controller->_setting['site_name'] : $post->seo_title;
     $this->controller->_seoKeywords = empty($post->seo_keywords) ? $post->tags : $post->seo_keywords;
     $this->controller->_seoDescription = empty($post->seo_description) ? $this->controller->_seoDescription : $post->seo_description;
     //最近的圖集
     $last_images = Image::model()->findAll(array('condition' => 'catalog_id = ' . $post->catalog_id, 'order' => 'id DESC', 'limit' => 10));
     //nav
     $navs = array();
     $navs[] = array('url' => $this->controller->createUrl('image/view', array('id' => $id)), 'name' => $post->title);
     $tplVar = array('post' => $post, 'navs' => $navs, 'last_images' => $last_images);
     $this->controller->render('view', $tplVar);
 }
開發者ID:jerrylsxu,項目名稱:yiifcms,代碼行數:21,代碼來源:ViewAction.php

示例13: actionEditImage

 /**
  * Ajax/Get-обёртка для редактирования изображения:
  *
  * @param int $id - id-изображения
  *
  * @return void
  **/
 public function actionEditImage($id = null)
 {
     if (($image = Image::model()->findByPk($id)) === null || $image->canChange() === false) {
         throw new CHttpException(404, Yii::t('GalleryModule.gallery', 'Page was not found!'));
     }
     if ((Yii::app()->getRequest()->getIsPostRequest() || Yii::app()->getRequest()->getIsAjaxRequest()) && Yii::app()->getRequest()->getPost('Image') !== null) {
         $image->setAttributes(Yii::app()->getRequest()->getPost('Image'));
         if ($image->validate() && $image->save()) {
             $message = Yii::t('GalleryModule.gallery', 'Image #{id} edited', ['{id}' => $id]);
             if (Yii::app()->getRequest()->getIsPostRequest() && Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->ajax->success(['message' => $message, 'type' => 'saved']);
             }
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, $message);
             $this->redirect(['/gallery/gallery/show', 'id' => $image->gallery->id]);
         }
     }
     if (Yii::app()->getRequest()->getIsPostRequest() && Yii::app()->getRequest()->getIsAjaxRequest()) {
         Yii::app()->ajax->success(['form' => $this->renderPartial('_form', ['model' => $image], true)]);
     }
     $this->render('edit-image', ['model' => $image]);
 }
開發者ID:RonLab1987,項目名稱:43berega,代碼行數:28,代碼來源:GalleryController.php

示例14: actionUpdate

 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $photo = Image::model()->findAllByAttributes(array('imageid' => $id));
     if (isset($_POST['News'])) {
         $photos = CUploadedFile::getInstancesByName('images');
         $url = array();
         foreach ($photos as $files) {
             $fn = $files->getTempName();
             $client_id = "c633cc927c486e6";
             $handle = fopen($fn, "r");
             $data = fread($handle, filesize($fn));
             $pvars = array('image' => base64_encode($data));
             $timeout = 30;
             $curl = curl_init();
             curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
             curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
             curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
             curl_setopt($curl, CURLOPT_POST, 1);
             curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
             $out = curl_exec($curl);
             curl_close($curl);
             $pms = json_decode($out, true);
             array_push($url, $pms['data']['link']);
         }
         $model->attributes = $_POST['News'];
         if ($model->save()) {
             foreach ($url as $path) {
                 $model_image = new Image();
                 $model_image->imageid = $model->id;
                 $model_image->path = $path;
                 $model_image->save();
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'photo' => $photo));
 }
開發者ID:kjunangle,項目名稱:Web-App-engineer,代碼行數:40,代碼來源:NewsController.php

示例15: actionRepair

 public function actionRepair()
 {
     $images = Image::model()->findAll();
     foreach ($images as $image) {
         $c = new Comment();
         $c->img_id = $image->img_id;
         $c->create_time = time();
         $c->save();
     }
 }
開發者ID:sr71k,項目名稱:pet,代碼行數:10,代碼來源:SiteController.php


注:本文中的Image::model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。