Skip to content

Commit

Permalink
Merge branch 'dev' of git://github.com/yupe/yupe into fix-1888
Browse files Browse the repository at this point in the history
Conflicts:
	protected/modules/blog/models/Post.php
	protected/modules/gallery/views/gallery/_form.php
  • Loading branch information
chemezov committed Mar 20, 2015
2 parents 34e38c4 + 1e82c51 commit 66a3952
Show file tree
Hide file tree
Showing 29 changed files with 347 additions and 473 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- #1881: Исправлена ошибка массового удаления записей (@sabian)
- #1894: Увеличен объем сохраняемых данных в поле "Текст" модуля "Страницы" (@sabian)
- #1896: Исправлено массовое удаление действий в rbac (@sabian)
- #1906: Изменён алгоритм ресайза изображений в Thumbnailer. Отрефакторены ImageUploadBehavior и FileUploadBehavior (@chemezov)

Версия 0.9.3 10 февраля 2015
-------------------------------------
Expand Down
10 changes: 0 additions & 10 deletions protected/modules/blog/models/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,11 @@ public function behaviors()
return [
'imageUpload' => [
'class' => 'yupe\components\behaviors\ImageUploadBehavior',
'scenarios' => ['insert', 'update'],
'attributeName' => 'icon',
'minSize' => $module->minSize,
'maxSize' => $module->maxSize,
'types' => $module->allowedExtensions,
'uploadPath' => $module->uploadPath,
'fileName' => [$this, 'generateFileName'],
'defaultImage' => Yii::app()->getTheme()->getAssetsUrl() . '/images/blog-default.jpg',
],
'CTimestampBehavior' => [
Expand All @@ -357,14 +355,6 @@ public function behaviors()
];
}

/**
* @return string
*/
public function generateFileName()
{
return md5($this->name . microtime(true) . uniqid());
}

/**
* @return bool
*/
Expand Down
116 changes: 53 additions & 63 deletions protected/modules/blog/models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,31 @@ public function relations()
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return [
'createUser' => [self::BELONGS_TO, 'User', 'create_user_id'],
'updateUser' => [self::BELONGS_TO, 'User', 'update_user_id'],
'blog' => [self::BELONGS_TO, 'Blog', 'blog_id'],
'comments' => [
'createUser' => [self::BELONGS_TO, 'User', 'create_user_id'],
'updateUser' => [self::BELONGS_TO, 'User', 'update_user_id'],
'blog' => [self::BELONGS_TO, 'Blog', 'blog_id'],
'comments' => [
self::HAS_MANY,
'Comment',
'model_id',
'on' => 'model = :model AND comments.status = :status and level > 1',
'on' => 'model = :model AND comments.status = :status and level > 1',
'params' => [
':model' => 'Post',
':model' => 'Post',
':status' => Comment::STATUS_APPROVED
],
'order' => 'comments.id'
'order' => 'comments.id'
],
'commentsCount' => [
self::STAT,
'Comment',
'model_id',
'condition' => 'model = :model AND status = :status AND level > 1',
'params' => [
':model' => 'Post',
'params' => [
':model' => 'Post',
':status' => Comment::STATUS_APPROVED
]
],
'category' => [self::BELONGS_TO, 'Category', 'category_id']
'category' => [self::BELONGS_TO, 'Category', 'category_id']
];
}

Expand All @@ -215,17 +215,17 @@ public function scopes()
return [
'published' => [
'condition' => 't.status = :status',
'params' => [':status' => self::STATUS_PUBLISHED],
'params' => [':status' => self::STATUS_PUBLISHED],
],
'public' => [
'public' => [
'condition' => 't.access_type = :access_type',
'params' => [':access_type' => self::ACCESS_PUBLIC],
'params' => [':access_type' => self::ACCESS_PUBLIC],
],
'moderated' => [
'condition' => 't.status = :status',
'params' => [':status' => self::STATUS_MODERATED]
'params' => [':status' => self::STATUS_MODERATED]
],
'recent' => [
'recent' => [
'order' => 'publish_date DESC'
]
];
Expand Down Expand Up @@ -273,26 +273,26 @@ public function sortByPubDate($typeSort = 'ASC')
public function attributeLabels()
{
return [
'id' => Yii::t('BlogModule.blog', 'id'),
'blog_id' => Yii::t('BlogModule.blog', 'Blog'),
'id' => Yii::t('BlogModule.blog', 'id'),
'blog_id' => Yii::t('BlogModule.blog', 'Blog'),
'create_user_id' => Yii::t('BlogModule.blog', 'Created'),
'update_user_id' => Yii::t('BlogModule.blog', 'Update user'),
'create_date' => Yii::t('BlogModule.blog', 'Created at'),
'update_date' => Yii::t('BlogModule.blog', 'Updated at'),
'publish_date' => Yii::t('BlogModule.blog', 'Date'),
'slug' => Yii::t('BlogModule.blog', 'Url'),
'title' => Yii::t('BlogModule.blog', 'Title'),
'quote' => Yii::t('BlogModule.blog', 'Quote'),
'content' => Yii::t('BlogModule.blog', 'Content'),
'link' => Yii::t('BlogModule.blog', 'Link'),
'status' => Yii::t('BlogModule.blog', 'Status'),
'create_date' => Yii::t('BlogModule.blog', 'Created at'),
'update_date' => Yii::t('BlogModule.blog', 'Updated at'),
'publish_date' => Yii::t('BlogModule.blog', 'Date'),
'slug' => Yii::t('BlogModule.blog', 'Url'),
'title' => Yii::t('BlogModule.blog', 'Title'),
'quote' => Yii::t('BlogModule.blog', 'Quote'),
'content' => Yii::t('BlogModule.blog', 'Content'),
'link' => Yii::t('BlogModule.blog', 'Link'),
'status' => Yii::t('BlogModule.blog', 'Status'),
'comment_status' => Yii::t('BlogModule.blog', 'Comments'),
'access_type' => Yii::t('BlogModule.blog', 'Access'),
'keywords' => Yii::t('BlogModule.blog', 'Keywords'),
'description' => Yii::t('BlogModule.blog', 'description'),
'tags' => Yii::t('BlogModule.blog', 'Tags'),
'image' => Yii::t('BlogModule.blog', 'Image'),
'category_id' => Yii::t('BlogModule.blog', 'Category')
'access_type' => Yii::t('BlogModule.blog', 'Access'),
'keywords' => Yii::t('BlogModule.blog', 'Keywords'),
'description' => Yii::t('BlogModule.blog', 'description'),
'tags' => Yii::t('BlogModule.blog', 'Tags'),
'image' => Yii::t('BlogModule.blog', 'Image'),
'category_id' => Yii::t('BlogModule.blog', 'Category')
];
}

Expand Down Expand Up @@ -331,7 +331,7 @@ public function search()
return new CActiveDataProvider(
'Post', [
'criteria' => $criteria,
'sort' => [
'sort' => [
'defaultOrder' => 'publish_date DESC',
]
]
Expand All @@ -347,7 +347,7 @@ public function allPosts()
$criteria->addCondition('t.status = :status');
$criteria->addCondition('t.access_type = :access_type');
$criteria->params = [
':status' => self::STATUS_PUBLISHED,
':status' => self::STATUS_PUBLISHED,
':access_type' => self::ACCESS_PUBLIC
];
$criteria->with = ['blog', 'createUser', 'commentsCount'];
Expand Down Expand Up @@ -381,15 +381,13 @@ public function behaviors()
'tagBindingTableTagId' => 'tag_id',
'cacheID' => 'cache',
],
'imageUpload' => [
'class' => 'yupe\components\behaviors\ImageUploadBehavior',
'scenarios' => ['insert', 'update'],
'imageUpload' => [
'class' => 'yupe\components\behaviors\ImageUploadBehavior',
'attributeName' => 'image',
'minSize' => $module->minSize,
'maxSize' => $module->maxSize,
'types' => $module->allowedExtensions,
'uploadPath' => $module->uploadPath,
'fileName' => [$this, 'generateFileName'],
'minSize' => $module->minSize,
'maxSize' => $module->maxSize,
'types' => $module->allowedExtensions,
'uploadPath' => $module->uploadPath,
],
'seo' => [
'class' => 'vendor.chemezov.yii-seo.behaviors.SeoActiveRecordBehavior',
Expand All @@ -399,14 +397,6 @@ public function behaviors()
];
}

/**
* @return string
*/
public function generateFileName()
{
return md5($this->slug . microtime(true) . uniqid());
}

/**
* @return bool
*/
Expand Down Expand Up @@ -438,7 +428,7 @@ public function afterDelete()
Comment::model()->deleteAll(
'model = :model AND model_id = :model_id',
[
':model' => 'Post',
':model' => 'Post',
':model_id' => $this->id
]
);
Expand All @@ -464,11 +454,11 @@ public function beforeValidate()
public function getStatusList()
{
return [
self::STATUS_DRAFT => Yii::t('BlogModule.blog', 'Draft'),
self::STATUS_DRAFT => Yii::t('BlogModule.blog', 'Draft'),
self::STATUS_PUBLISHED => Yii::t('BlogModule.blog', 'Published'),
self::STATUS_SCHEDULED => Yii::t('BlogModule.blog', 'Scheduled'),
self::STATUS_MODERATED => Yii::t('BlogModule.blog', 'Moderated'),
self::STATUS_DELETED => Yii::t('BlogModule.blog', 'Deleted')
self::STATUS_DELETED => Yii::t('BlogModule.blog', 'Deleted')
];
}

Expand All @@ -489,7 +479,7 @@ public function getAccessTypeList()
{
return [
self::ACCESS_PRIVATE => Yii::t('BlogModule.blog', 'Private'),
self::ACCESS_PUBLIC => Yii::t('BlogModule.blog', 'Public'),
self::ACCESS_PUBLIC => Yii::t('BlogModule.blog', 'Public'),
];
}

Expand Down Expand Up @@ -522,7 +512,7 @@ public function getCommentStatus()
public function getCommentStatusList()
{
return [
self::COMMENT_NO => Yii::t('BlogModule.blog', 'Forbidden'),
self::COMMENT_NO => Yii::t('BlogModule.blog', 'Forbidden'),
self::COMMENT_YES => Yii::t('BlogModule.blog', 'Allowed'),
];
}
Expand All @@ -546,7 +536,7 @@ public function afterFind()
public function getQuote($limit = 500)
{
return $this->quote
?: yupe\helpers\YText::characterLimiter(
? : yupe\helpers\YText::characterLimiter(
$this->content,
(int)$limit
);
Expand Down Expand Up @@ -581,10 +571,10 @@ public function getArchive($blogId = null, $cache = 3600)
list($day, $month, $year) = explode('-', date('d-m-Y', strtotime($model->publish_date)));

$data[$year][$month][] = [
'title' => $model->title,
'slug' => $model->slug,
'title' => $model->title,
'slug' => $model->slug,
'publish_date' => $model->publish_date,
'quote' => $model->getQuote()
'quote' => $model->getQuote()
];
}
} else {
Expand Down Expand Up @@ -614,8 +604,8 @@ public function getStream($limit = 10, $cacheTime)
->where(
'c.model = :model AND p.status = :status AND c.status = :commentstatus AND c.id <> c.root',
[
':model' => 'Post',
':status' => Post::STATUS_PUBLISHED,
':model' => 'Post',
':status' => Post::STATUS_PUBLISHED,
':commentstatus' => Comment::STATUS_APPROVED
]
)
Expand Down Expand Up @@ -784,7 +774,7 @@ public function deleteUserPost($postId, $userId)
'create_user_id = :userId AND id = :id AND status != :status',
[
':userId' => (int)$userId,
':id' => (int)$postId,
':id' => (int)$postId,
':status' => self::STATUS_PUBLISHED
]
);
Expand All @@ -801,7 +791,7 @@ public function findUserPost($postId, $userId)
'id = :id AND create_user_id = :userId AND status != :status',
[
':userId' => (int)$userId,
':id' => (int)$postId,
':id' => (int)$postId,
':status' => self::STATUS_PUBLISHED
]
);
Expand Down
7 changes: 0 additions & 7 deletions protected/modules/catalog/models/Good.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,11 @@ public function behaviors()
],
'imageUpload' => [
'class' => 'yupe\components\behaviors\ImageUploadBehavior',
'scenarios' => ['insert', 'update'],
'attributeName' => 'image',
'minSize' => $module->minSize,
'maxSize' => $module->maxSize,
'types' => $module->allowedExtensions,
'uploadPath' => $module->uploadPath,
'fileName' => [$this, 'generateFileName'],
],
'seo' => [
'class' => 'vendor.chemezov.yii-seo.behaviors.SeoActiveRecordBehavior',
Expand All @@ -238,11 +236,6 @@ public function behaviors()
];
}

public function generateFileName()
{
return md5($this->name . microtime(true) . uniqid());
}

public function beforeValidate()
{
$this->change_user_id = Yii::app()->user->getId();
Expand Down
7 changes: 0 additions & 7 deletions protected/modules/category/models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,12 @@ public function behaviors()
return [
'imageUpload' => [
'class' => 'yupe\components\behaviors\ImageUploadBehavior',
'scenarios' => ['insert', 'update'],
'attributeName' => 'image',
'uploadPath' => $module->uploadPath,
'fileName' => [$this, 'generateFileName'],
],
];
}

public function generateFileName()
{
return md5($this->name . microtime(true) . uniqid());
}

public function relations()
{
return [
Expand Down
4 changes: 2 additions & 2 deletions protected/modules/category/views/categoryBackend/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
'name' => 'image',
'type' => 'raw',
'value' => $model->image
? CHtml::image($model->getImageUrl(), $model->name, ['width' => 300, 'height' => 300])
: '---',
? CHtml::image($model->getImageUrl(300, 300), $model->name)
: '---',
],
[
'name' => 'description',
Expand Down
22 changes: 11 additions & 11 deletions protected/modules/gallery/controllers/GalleryBackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public function actionImages($id)
'image' => $image,
'model' => $gallery,
'tab' => !($errors = $image->getErrors())
? '_images_show'
: '_image_add'
? '_images_show'
: '_image_add'
]
);
}
Expand Down Expand Up @@ -274,8 +274,8 @@ public function actionDeleteImage($id = null, $method = null)
[
'{id}' => $id,
'{result}' => ($result = $image->delete())
? Yii::t('GalleryModule.gallery', 'success')
: Yii::t('GalleryModule.gallery', 'not')
? Yii::t('GalleryModule.gallery', 'success')
: Yii::t('GalleryModule.gallery', 'not')
]
);

Expand Down Expand Up @@ -328,14 +328,14 @@ public function actionAddimages($id)
'type' => $_FILES['Image']['type']['file'],
'size' => $_FILES['Image']['size']['file'],
'url' => $image->getImageUrl(),
'thumbnail_url' => $image->getImageUrl(80),
'thumbnail_url' => $image->getImageUrl(80, 80),
'delete_url' => $this->createUrl(
'/gallery/galleryBackend/deleteImage',
[
'id' => $image->id,
'method' => 'uploader'
]
),
'/gallery/galleryBackend/deleteImage',
[
'id' => $image->id,
'method' => 'uploader'
]
),
'delete_type' => 'GET'
];
}
Expand Down
Loading

0 comments on commit 66a3952

Please sign in to comment.