本文整理汇总了PHP中Gallery::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Gallery::model方法的具体用法?PHP Gallery::model怎么用?PHP Gallery::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gallery
的用法示例。
在下文中一共展示了Gallery::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGallery
/** @return Gallery Returns gallery associated with model */
public function getGallery()
{
if (empty($this->_gallery)) {
$this->_gallery = Gallery::model()->findByPk($this->getOwner()->{$this->idAttribute});
}
return $this->_gallery;
}
示例2: actionShow
public function actionShow($id)
{
$model = Gallery::model()->findByPk((int) $id);
if (is_null($model)) {
throw new CHttpException(404, Yii::t('gallery', 'Страница не найдена!'));
}
$image = new Image();
if (Yii::app()->request->isPostRequest && isset($_POST['Image'])) {
$transaction = Yii::app()->db->beginTransaction();
try {
$image = $image->create($_POST['Image']);
if (!$image->hasErrors()) {
if ($model->addImage($image)) {
Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('gallery', 'Фотография добавлена!'));
}
$transaction->commit();
$this->redirect(array('/gallery/gallery/show/', 'id' => $model->id));
}
throw new CDbException(Yii::t('gallery', 'При добавлении изображения произошла ошибка!'));
} catch (Exception $e) {
$transaction->rollback();
Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('gallery', $e->getMessage()));
}
}
$dataProvider = new CActiveDataProvider('ImageToGallery', array('criteria' => array('condition' => 'galleryId = :galleryId', 'params' => array(':galleryId' => $model->id), 'limit' => self::GALLERY_PER_PAGE, 'order' => 't.creation_date DESC', 'with' => 'image'), 'pagination' => array('pageSize' => self::GALLERY_PER_PAGE)));
$this->render('show', array('image' => $image, 'model' => $model, 'dataProvider' => $dataProvider));
}
示例3: actionView
/**
* @param $id
* @throws CDbException
* @throws CHttpException
*/
public function actionView($id)
{
if (($gallery = Gallery::model()->published()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('GalleryModule.gallery', 'Page was not found!'));
}
$image = new Image();
if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['Image'])) {
try {
$transaction = Yii::app()->db->beginTransaction();
$image->attributes = $_POST['Image'];
if ($image->save() && $gallery->addImage($image)) {
$transaction->commit();
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('GalleryModule.gallery', 'Photo was created!'));
$this->redirect(['/gallery/gallery/view', 'id' => $gallery->id]);
}
} catch (Exception $e) {
$transaction->rollback();
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, $e->getMessage());
}
}
if ($gallery->status == Gallery::STATUS_PRIVATE && $gallery->owner != Yii::app()->user->id) {
throw new CHttpException(404);
}
$this->render('view', ['image' => $image, 'model' => $gallery]);
}
示例4: actionIndex
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->condition = "status = 1";
$criteria->order = "sort_order asc,gallery_id asc";
$model = Gallery::model()->findAll($criteria);
$this->render('index', array('gallery' => $model));
}
示例5: actionView
/**
* Index Page, for now just render all static content.
*/
public function actionView($id)
{
$gallery = Gallery::model()->with('galleryImages')->findByPk($id);
if (empty($gallery)) {
$gallery = new Gallery();
}
$this->render('view', array('gallery' => $gallery));
}
示例6: loadModel
public function loadModel($id)
{
$model = Gallery::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例7: actionIndex
public function actionIndex()
{
$dependency = new CDbCacheDependency('SELECT MAX(UNIX_TIMESTAMP(updated_at)), COUNT(0) FROM {{gallery}} WHERE status = :status');
$dependency->params = array('status' => ActiveRecord::STATUS_ON);
$model = Gallery::model()->cache(3600 * 24, $dependency, 2)->opened();
$dataProvider = new CActiveDataProvider($model, array('criteria' => array('order' => 'sort'), 'pagination' => array('pageSize' => (int) config('gallery.limit'), 'pageVar' => 'page')));
$this->render('//gallery', array('dataProvider' => $dataProvider));
}
示例8: LoadGallery
public static function LoadGallery($id)
{
$id = _xls_number_only($id);
if ($id > 1000) {
$id = 1000;
}
$gallery = Gallery::model()->findByPk($id);
if (!$gallery) {
$gallery = new Gallery();
$gallery->id = $id;
$gallery->name = true;
$gallery->description = true;
$gallery->versions = array('small' => array('resize' => array(200, null)), 'medium' => array('resize' => array(800, null)));
$gallery->save();
}
return $gallery;
}
示例9: run
public function run()
{
if (Yii::app()->request->isAjaxRequest && isset($_GET['q'])) {
$title = Yii::app()->request->getParam('q', '');
$limit = Yii::app()->request->getParam('limit', 50);
$limit = min($limit, 50);
$criteria = new CDbCriteria();
$criteria->condition = "title LIKE :sterm";
$criteria->params = array(":sterm" => "%{$title}%");
$criteria->limit = $limit;
$array = Gallery::model()->findAll($criteria);
$result = '';
foreach ($array as $val) {
$result .= $val->getAttribute('title') . '|' . $val->getAttribute('id') . "\n";
}
echo $result;
}
}
示例10: foreach
echo $getTranslateWorld['gallery'];
?>
</h1>
<div id="slider_container" style="position:relative;margin:0 auto;top:0px;left:0px;width:800px;height:456px;background:#191919;">
<div u="loading" style="position:absolute;top:0px;left:0px;">
<div style="filter:alpha(opacity=70);opacity:0.7;position:absolute;display:block;background-color:#000000;top:0px;left:0px;width:100%;height:100%;">
</div>
<div style="position:absolute;display:block;background:url(<?php
echo Yii::app()->request->baseUrl;
?>
/css/xeon/img/loading.gif) no-repeat center center;top:0px;left:0px;width:100%;height:100%;">
</div>
</div>
<div u="slides" style="cursor:move;position:absolute;left:0px;top:0px;width:800px;height:356px;overflow:hidden;">
<?php
$gallery = Gallery::model()->findAll();
if (!empty($gallery)) {
foreach ($gallery as $key => $value) {
?>
<div>
<a href=''><img u = "image" src = "<?php
echo Yii::app()->request->baseUrl . '/css/xeon/images/gallery/' . $value->image_big;
?>
"></a>
<img u = "thumb" src = "<?php
echo Yii::app()->request->baseUrl . '/css/xeon/images/gallery/' . $value->image_small;
?>
">
</div>
<?php
}
示例11: loadModel
/**
* Возвращает модель по указанному идентификатору
* Если модель не будет найдена - возникнет HTTP-исключение.
*
* @param integer идентификатор нужной модели
*
* @return Gallery $model
*
* @throws CHttpException
*/
public function loadModel($id)
{
if (($model = Gallery::model()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('GalleryModule.gallery', 'Requested page was not found.'));
}
return $model;
}
示例12: getSelectedGallery
public static function getSelectedGallery($id)
{
return Gallery::model()->findByPk($id);
}
示例13: getGalleryList
public function getGalleryList()
{
$result = array();
if ($galleries = Gallery::model()->findAll()) {
foreach ($galleries as $gallery) {
$result[$gallery->id] = $gallery->title;
}
}
return $result;
}
示例14: getGallery
public static function getGallery($id)
{
return !empty($id) ? Gallery::model()->with('photos')->findByPk($id) : new Gallery();
}
示例15: loadGallery
/**
* Load model for our gallery.
* Sets @var $this->gmodel.
* Sets order of pictures
* Sets @var $this->imgsOrder.
*/
public function loadGallery()
{
$this->gmodel = Gallery::model()->find(array('condition' => "pid='{$this->pid}'"));
$this->imgsOrder = unserialize($this->gmodel->imgsOrder);
}