public function actionBlogs() { $data = Yii::app()->ls->createCommand('SELECT * FROM prefix_blog')->queryAll(); $transaction = Yii::app()->db->beginTransaction(); try { Blog::model()->deleteAll(); foreach ($data as $blog) { echo "Import blog '{$blog['blog_title']}' !\n"; $slug = $blog['blog_url'] ? $blog['blog_url'] : yupe\helpers\YText::translit($blog['blog_title']); $updateDate = $blog['blog_date_edit'] ? $blog['blog_date_edit'] : $blog['blog_date_add']; $icon = ''; if ($blog['blog_avatar']) { $url = parse_url($blog['blog_avatar']); if (!empty($url['path'])) { $icon = str_replace('/uploads/', '', $url['path']); } } $type = $blog['blog_type'] == 'personal' ? Blog::TYPE_PRIVATE : Blog::TYPE_PUBLIC; Yii::app()->db->createCommand(' INSERT INTO {{blog_blog}} (id, name, slug, description, create_user_id, update_user_id, create_date, update_date, icon, type) VALUES (:id, :name, :slug, :description, :create_user_id, :update_user_id, :create_date, :update_date, :icon, :type) ')->bindValue(':id', $blog['blog_id'])->bindValue(':name', $blog['blog_title'])->bindValue(':slug', $slug)->bindValue(':description', strip_tags($blog['blog_description']))->bindValue(':create_user_id', $blog['user_owner_id'])->bindValue(':update_user_id', $blog['user_owner_id'])->bindValue(':create_date', strtotime($blog['blog_date_add']))->bindValue(':update_date', strtotime($updateDate))->bindValue(':icon', $icon)->bindValue(':type', $type)->execute(); } $transaction->commit(); } catch (Exception $e) { CVarDumper::dump($e); $transaction->rollback(); die; } }
public function actionWrite() { $post = new Post(); if ($postId = (int) Yii::app()->getRequest()->getQuery('id')) { $post = Post::model()->findUserPost($postId, Yii::app()->getUser()->getId()); if (null === $post) { throw new CHttpException(404); } } if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['Post'])) { $data = Yii::app()->getRequest()->getPost('Post'); $data['user_id'] = Yii::app()->user->getId(); if ($post->createPublicPost($data, Yii::app()->getRequest()->getPost('tags'))) { $message = Yii::t('BlogModule.blog', 'Post sent for moderation!'); $redirect = array('/blog/publisher/my'); if ($post->status === Post::STATUS_DRAFT) { $message = Yii::t('BlogModule.blog', 'Post saved!'); } if ($post->status === Post::STATUS_PUBLISHED) { $message = Yii::t('BlogModule.blog', 'Post published!'); $redirect = array('/blog/post/show', 'slug' => $post->slug); } Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, $message); $this->redirect($redirect); } } $blogs = Blog::model()->getListForUser(Yii::app()->getUser()->getId()); $this->render('write', array('post' => $post, 'blogs' => $blogs)); }
/** * @throws CException */ public function run() { if (!$this->blog) { $this->blog = Blog::model()->with('members')->findByPk($this->blogId); } $this->render($this->view, ['model' => $this->blog]); }
public function actionBlog($slug) { $blog = Blog::model()->getByUrl($slug)->find(); if (null === $blog) { throw new CHttpException(404); } $this->render('blog-post', array('target' => $blog, 'posts' => $blog->getPosts())); }
/** * @param Event $event */ public static function onGenerate(Event $event) { $generator = $event->getGenerator(); $blogsProvider = new CActiveDataProvider(Blog::model()->published()->public()); foreach (new CDataProviderIterator($blogsProvider) as $blog) { $generator->addItem(Yii::app()->createAbsoluteUrl('/blog/blog/show', ['slug' => $blog->slug]), $blog->update_time, SitemapHelper::FREQUENCY_DAILY, 0.5); } $postProvider = new CActiveDataProvider(Post::model()->published()->public()); foreach (new CDataProviderIterator($postProvider) as $post) { $generator->addItem(Yii::app()->createAbsoluteUrl('/blog/post/show', ['slug' => $post->slug]), $post->update_time, SitemapHelper::FREQUENCY_YEARLY, 0.5); } }
public function actionView($id) { $model = Blog::model(); if (Yii::app()->user->isGuest) { $model->published(); } $model = Blog::model()->findByPk($id); if (!$model) { throw new CHttpException(404, 'Blog post [id: ' . $id . '] not found'); } $this->render('view', compact('model')); }
public function actionDeleteImg() { $blogId = Yii::app()->request->getParam('id'); $imageId = Yii::app()->request->getParam('imId'); if ($blogId && $imageId) { $blogModel = Blog::model()->findByPk($blogId); if ($blogModel->image_id != $imageId) { throw404(); } $blogModel->image_id = 0; $blogModel->update('image_id'); $imageModel = BlogImage::model()->findByPk($imageId); $imageModel->delete(); $this->redirect(array('/blog/backend/main/update', 'id' => $blogId)); } throw404(); }
/** * Удаляет модель блога из базы. * Если удаление прошло успешно - возвращется в index * * @param integer $id - идентификатор блога, который нужно удалить * * @return nothing **/ public function actionDelete($id) { if (Yii::app()->getRequest()->getIsPostRequest()) { // поддерживаем удаление только из POST-запроса if (($model = Blog::model()->loadModel($id)) === null) { throw new CHttpException(404, Yii::t('BlogModule.blog', 'Page was not found!')); } $model->delete(); Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BlogModule.blog', 'Blog was deleted!')); // если это AJAX запрос ( кликнули удаление в админском grid view), мы не должны никуда редиректить if (!Yii::app()->getRequest()->getIsAjaxRequest()) { $this->redirect(Yii::app()->getRequest()->getPost('returnUrl', array('index'))); } } else { throw new CHttpException(400, Yii::t('BlogModule.blog', 'Wrong request. Please don\'t repeate requests like this anymore!')); } }
public function actionView($id) { $id = intval($id); $blog = Blog::model()->find('id=:id', array('id' => $id)); $blog->views += 1; $blog->save(); $catelist = Category::getDropList(1); $model = new Blog(); $criteria = new CDbCriteria(); //查询条件 $criteria->addCondition("is_show=1"); //排序 $criteria->order = 'id DESC'; $criteria->limit = 5; $recent = $model->findAll($criteria); $this->render('view2', array('blog' => $blog, 'catelist' => $catelist, 'recent' => $recent)); }
public function run() { if (Yii::app()->request->isAjaxRequest && isset($_GET['q'])) { $tag = 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" => "%{$tag}%"); $criteria->limit = $limit; $tagArray = Blog::model()->findAll($criteria); $returnVal = ''; foreach ($tagArray as $tagValue) { $returnVal .= $tagValue->getAttribute('title') . '|' . $tagValue->getAttribute('id') . "\n"; } echo $returnVal; } }
public function actions() { if (!($limit = (int) $this->module->rssCount)) { throw new CHttpException(404); } $criteria = new CDbCriteria(); $criteria->order = 'publish_date DESC'; $criteria->params = array(); $criteria->limit = $limit; $yupe = Yii::app()->getModule('yupe'); $title = $yupe->siteName; $description = $yupe->siteDescription; $blogId = (int) Yii::app()->getRequest()->getQuery('blog'); if (!empty($blogId)) { $blog = Blog::model()->cache($yupe->coreCacheTime)->published()->findByPk($blogId); if (null === $blog) { throw new CHttpException(404); } $title = $blog->name; $description = $blog->description; $criteria->addCondition('blog_id = :blog_id'); $criteria->params[':blog_id'] = $blogId; } $categoryId = (int) Yii::app()->getRequest()->getQuery('category'); if (!empty($categoryId)) { $category = Category::model()->cache($yupe->coreCacheTime)->published()->findByPk($categoryId); if (null === $category) { throw new CHttpException(404); } $title = $category->name; $description = $category->description; $criteria->addCondition('category_id = :category_id'); $criteria->params[':category_id'] = $categoryId; } $tag = Yii::app()->getRequest()->getQuery('tag'); if (!empty($tag)) { $data = Post::model()->with('createUser')->published()->public()->taggedWith($tag)->findAll(); } else { $data = Post::model()->cache($yupe->coreCacheTime)->with('createUser')->published()->public()->findAll($criteria); } return array('feed' => array('class' => 'yupe\\components\\actions\\YFeedAction', 'data' => $data, 'title' => $title, 'description' => $description, 'itemFields' => array('author_object' => 'createUser', 'author_nickname' => 'nick_name', 'content' => 'content', 'datetime' => 'create_date', 'link' => '/blog/post/show', 'linkParams' => array('slug' => 'slug'), 'title' => 'title', 'updated' => 'update_date'))); }
public function loadData() { if (!($limit = (int) $this->module->rssCount)) { throw new CHttpException(404); } $criteria = new CDbCriteria(); $criteria->order = 'publish_time DESC'; $criteria->params = []; $criteria->limit = $limit; $yupe = Yii::app()->getModule('yupe'); $this->title = $yupe->siteName; $this->description = $yupe->siteDescription; $blogId = (int) Yii::app()->getRequest()->getQuery('blog'); if (!empty($blogId)) { $blog = Blog::model()->cache($yupe->coreCacheTime)->published()->findByPk($blogId); if (null === $blog) { throw new CHttpException(404); } $this->title = $blog->name; $this->description = $blog->description; $criteria->addCondition('blog_id = :blog_id'); $criteria->params[':blog_id'] = $blogId; } $categoryId = (int) Yii::app()->getRequest()->getQuery('category'); if (!empty($categoryId)) { $category = Category::model()->cache($yupe->coreCacheTime)->published()->findByPk($categoryId); if (null === $category) { throw new CHttpException(404); } $this->title = $category->name; $this->description = $category->description; $criteria->addCondition('category_id = :category_id'); $criteria->params[':category_id'] = $categoryId; } $tag = Yii::app()->getRequest()->getQuery('tag'); if (!empty($tag)) { $this->data = Post::model()->with('createUser')->published()->public()->taggedWith($tag)->findAll(); } else { $this->data = Post::model()->cache($yupe->coreCacheTime)->with('createUser')->published()->public()->findAll($criteria); } }
$("a[name='"+myUrlTab+"']").attr("id","current"); // Activate url tab $(myUrlTab).fadeIn(); // Show url tab content } } }); </script> <div id="blog" class="box"> <h2 class="h2-white">Lastest Blog</h2> <div class="container-box" id="news"> <ul class="container" > <?php foreach (Blog::model()->findAll() as $key) { ?> <li > <a href="<?php echo Yii::app()->createUrl("blog/index"); ?> " style=""><?php echo substr($key->title, 0, 40) . ".. - " . date('d M Y, H:i:s', strtotime($key->datetime)); ?> </a> <br> <a></a> </li> <?php
<div class="page-header"> <h1> <small><?php echo Yii::t('BlogModule.blog', 'My posts'); ?> </small> <a class="btn btn-warning pull-right" href="<?php echo Yii::app()->createUrl('/blog/publisher/write'); ?> "><?php echo Yii::t('BlogModule.blog', 'Write post!'); ?> </a> </h1> </div> <?php $this->widget('bootstrap.widgets.TbExtendedGridView', ['id' => 'my-post-grid', 'type' => 'condensed', 'dataProvider' => $posts->search(), 'columns' => [['name' => 'blog_id', 'type' => 'raw', 'value' => 'CHtml::link($data->blog->name, array("/blog/blog/view", "slug" => $data->blog->slug))', 'filter' => CHtml::listData(Blog::model()->getList(), 'id', 'name')], ['name' => 'title', 'value' => 'CHtml::link($data->title, $data->getLink())', 'type' => 'html'], ['name' => 'publish_time'], ['name' => 'status', 'type' => 'raw', 'value' => '$data->getStatus()', 'filter' => Post::model()->getStatusList()], ['header' => Yii::t('BlogModule.blog', 'Tags'), 'value' => 'implode(", ", $data->getTags())'], ['header' => "<i class=\"glyphicon glyphicon-comment\"></i>", 'value' => 'CHtml::link(($data->commentsCount>0) ? $data->commentsCount-1 : 0,array("/comment/commentBackend/index/","Comment[model]" => "Post","Comment[model_id]" => $data->id))', 'type' => 'raw'], ['class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{delete}{update}', 'deleteButtonUrl' => 'array("/blog/publisher/delete/", "id" => "$data->id")', 'updateButtonUrl' => 'array("/blog/publisher/write/", "id" => "$data->id")', 'buttons' => ['delete' => ['visible' => '$data->status == Post::STATUS_DRAFT'], 'update' => ['visible' => '$data->status == Post::STATUS_DRAFT']]]]]);
<div class="alert alert-info"> Вы можете писать только в блоги, подписчиком которых являетесь... </div> <?php echo $form->errorSummary($model); ?> <div class="row-fluid control-group"> <div class="span2 pull-left"> <?php echo $form->labelEx($model, 'blog_id'); ?> <?php $this->widget('bootstrap.widgets.TbSelect2', array('asDropDownList' => true, 'model' => $model, 'attribute' => 'blog_id', 'data' => CHtml::listData(Blog::model()->getListForUser(Yii::app()->getUser()->getId()), 'id', 'name'), 'value' => null)); ?> </div> </div> <div class="row-fluid control-group <?php echo $model->hasErrors('title') ? 'error' : ''; ?> "> <?php echo $form->textFieldRow($model, 'title', array('class' => 'span12 popover-help', 'maxlength' => 250, 'size' => 60, 'data-original-title' => $model->getAttributeLabel('title'), 'data-content' => $model->getAttributeDescription('title'))); ?> </div> <div class="row-fluid control-group <?php echo $model->hasErrors('slug') ? 'error' : '';
<div class="row"> <div class="col-sm-3"> <?php echo $form->textFieldGroup($model, 'title', ['widgetOptions' => ['htmlOptions' => ['empty' => '---', 'class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('title'), 'data-content' => $model->getAttributeDescription('title')]]]); ?> </div> <div class="col-sm-3"> <?php echo $form->textFieldGroup($model, 'slug', ['widgetOptions' => ['htmlOptions' => ['empty' => '---', 'class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('slug'), 'data-content' => $model->getAttributeDescription('slug')]]]); ?> </div> </div> <div class="row"> <div class="col-sm-3"> <?php echo $form->dropDownListGroup($model, 'blog_id', ['widgetOptions' => ['data' => CHtml::listData(Blog::model()->findAll(), 'id', 'name'), 'htmlOptions' => ['empty' => '---', 'class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('blog_id'), 'data-content' => $model->getAttributeDescription('blog_id')]]]); ?> </div> <div class="col-sm-3"> <?php echo $form->datePickerGroup($model, 'publish_time', ['widgetOptions' => ['options' => ['format' => 'yy-mm-dd', 'weekStart' => 1, 'autoclose' => true], 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('publish_time'), 'data-content' => $model->getAttributeDescription('publish_time')], 'events' => ['show' => 'js:function(e){ var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); $(this).val(year + "-" + month + "-" + day); }']], 'prepend' => '<i class="fa fa-calendar"></i>']); ?> </div> </div> <div class="row">
.img-founder{ width: 50px; float: left; margin-right:10px; } .desc-founder{ color: white; margin-top: -5px; } </style> <div id="wrapper-right-side"> <div class="box"> <?php $blog = Blog::model()->findAll("t.id != {$_REQUEST['id']}"); ?> <h2>RECENT POST</h2> <?php foreach ($blog as $key) { ?> <?php $id = $key->id; $gambar = $key->image; ?> <div class="recent-post"> <img class="img-recent" src="<?php echo Yii::app()->request->baseurl; ?>
<?php $options = array(); if (Yii::app()->user->checkAccess('op_blog_addposts')) { $options[Yii::t('blog', 'Add Post')] = array('blog/addpost'); } if (Yii::app()->user->checkAccess('op_blog_manage')) { $pending = Blog::model()->count('status=0'); $options[Yii::t('blog', '{count} Pending Posts', array('{count}' => $pending))] = array('blog/showpending'); } if (Yii::app()->user->id) { $options[Yii::t('blog', 'My Posts')] = array('blog/showmyposts'); } ?> <div id="nav"> <div class="boxnavnoborder"> <ul class='menunav'> <h4><?php echo Yii::t('blog', 'Categories'); ?> </h4> <?php foreach (BlogCats::model()->getCatsForMember(Yii::app()->language) as $category) { ?> <li><?php echo CHtml::link($category->title, array('/blog/category/' . $category->alias, 'lang' => false)); ?> - ( <?php echo $category->count;
echo Yii::t('BlogModule.blog', 'administration'); ?> </small> </h1> </div> <button class="btn btn-small dropdown-toggle" data-toggle="collapse" data-target="#search-toggle"> <i class="icon-search"> </i> <?php echo CHtml::link(Yii::t('BlogModule.blog', 'Find members'), '#', array('class' => 'search-button')); ?> <span class="caret"> </span> </button> <div id="search-toggle" class="collapse out search-form"> <?php Yii::app()->clientScript->registerScript('search', "\n \$('.search-form form').submit(function() {\n \$.fn.yiiGridView.update('user-to-blog-grid', {\n data: \$(this).serialize()\n });\n return false;\n });"); $this->renderPartial('_search', array('model' => $model)); ?> </div> <br/> <p><?php echo Yii::t('BlogModule.blog', 'In this category located member administration functions'); ?> </p> <?php $this->widget('yupe\\widgets\\CustomGridView', array('id' => 'user-to-blog-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'type' => 'raw', 'value' => 'CHtml::link($data->id, array("/blog/userToBlogBackend/update", "id" => $data->id))', 'htmlOptions' => array('style' => 'width:10px;')), array('name' => 'user_id', 'type' => 'raw', 'value' => 'CHtml::link($data->user->getFullName(), array("/user/userBackend/view", "id" => $data->user->id))', 'filter' => CHtml::listData(User::model()->cache($this->yupe->coreCacheTime)->findAll(), 'id', 'nick_name')), array('name' => 'blog_id', 'type' => 'raw', 'value' => 'CHtml::link($data->blog->name, array("/blog/blogBackend/view", "id" => $data->blog->id))', 'filter' => CHtml::listData(Blog::model()->cache($this->yupe->coreCacheTime)->findAll(), 'id', 'name')), array('class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => array('url' => $this->createUrl('/blog/userToBlogBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'title' => Yii::t('BlogModule.blog', 'Select {field}', array('{field}' => mb_strtolower($model->getAttributeLabel('role')))), 'source' => $model->getRoleList(), 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)), 'name' => 'role', 'type' => 'raw', 'value' => '$data->getRole()', 'filter' => $model->getRoleList()), array('class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => array('url' => $this->createUrl('/blog/userToBlogBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'title' => Yii::t('BlogModule.blog', 'Select {field}', array('{field}' => mb_strtolower($model->getAttributeLabel('status')))), 'source' => $model->getStatusList(), 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)), 'name' => 'status', 'type' => 'raw', 'value' => '$data->getStatus()', 'filter' => $model->getStatusList()), array('class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => array('url' => $this->createUrl('/blog/userToBlogBackend/inline'), 'mode' => 'inline', 'title' => Yii::t('BlogModule.blog', 'Select {field}', array('{field}' => mb_strtolower($model->getAttributeLabel('note')))), 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)), 'name' => 'note', 'type' => 'raw'), array('name' => 'create_date', 'value' => 'Yii::app()->getDateFormatter()->formatDateTime($data->create_date, "medium", "short")'), array('name' => 'update_date', 'value' => 'Yii::app()->getDateFormatter()->formatDateTime($data->update_date, "short", "short")'), array('class' => 'bootstrap.widgets.TbButtonColumn'))));
/** * @param array $post * @param $tags * @return bool */ public function createPublicPost(array $post) { if (empty($post['blog_id']) || empty($post['user_id'])) { $this->addError('blog_id', Yii::t('BlogModule.blog', "Blog is empty!")); return false; } $blog = Blog::model()->get((int) $post['blog_id'], []); if (null === $blog) { $this->addError('blog_id', Yii::t('BlogModule.blog', "You can't write in this blog!")); return false; } if ($blog->isPrivate() && !$blog->isOwner($post['user_id'])) { $this->addError('blog_id', Yii::t('BlogModule.blog', "You can't write in this blog!")); return false; } if (!$blog->isPrivate() && !$blog->userIn($post['user_id'])) { $this->addError('blog_id', Yii::t('BlogModule.blog', "You can't write in this blog!")); return false; } $this->setAttributes($post); $this->setTags($post['tags']); $this->publish_time = date('d-m-Y h:i'); $this->status = $post['status'] == self::STATUS_DRAFT ? self::STATUS_DRAFT : $blog->post_status; return $this->save(); }
<table class="table-project" border="0" cellpadding="30"> <thead> <tr class="head"> <td align="left" class="row" value="project_name" >no</td> <td style="display:none" align="left" class="row" value="project_name" >overview</td> <td align="left" class="row" value="project_name" >title</td> <td align="left" class="row" value="due_date">category</td> <td align="left" class="row" value="username">datetime</td> <td align="left" class="row" value="progres">author</td> <td align="center" class="row" value="progres">tags</td> <td align="center" class="row" value="progres">Image Main</td> <td align="left" class="row" value="progres">Action</td> </tr> </thead> <?php $blog = Blog::model()->findAll(); ?> <tbody id="baris-blog"> <?php $data = Yii::app()->db->createCommand()->select("*")->from('blog')->queryAll(); $no = 1; foreach ($data as $d) { ?> <tr style="border-bottom:1px solid black"> <td><?php echo $no; ?> </td> <td style="display:none"><img style="width:120px" src="images/<?php echo $d['image']; ?>
<style type="text/css"> body{ background-color: white!important; } </style> <?php $blog = Blog::model()->findByPk($_REQUEST['id']); ?> <?php $filename = Yii::app()->basePath . "/../img/blog/{$blog->image}"; // echo $filename; if (file_exists($filename)) { $image = Yii::app()->baseUrl . '/img/blog/' . $blog->image; } else { //$image=Yii::app()->baseUrl.'/img/blog/notfound.jpg'; } ?> <div id="cover-blog" style="background-image:url('<?php echo $image; ?> ')" > <div id="headline"> <div class="inner-headline"> <div class="satu"> <?php echo $blog->category; ?> </div> <div class="dua"> <?php
echo Yii::t('BlogModule.blog', 'administration'); ?> </small> </h1> </div> <button class="btn btn-small dropdown-toggle" data-toggle="collapse" data-target="#search-toggle"> <i class="icon-search"> </i> <?php echo CHtml::link(Yii::t('BlogModule.blog', 'Find posts'), '#', array('class' => 'search-button')); ?> <span class="caret"> </span> </button> <div id="search-toggle" class="collapse out search-form"> <?php Yii::app()->clientScript->registerScript('search', "\n \$('.search-form form').submit(function() {\n \$.fn.yiiGridView.update('post-grid', {\n data: \$(this).serialize()\n });\n return false;\n });"); $this->renderPartial('_search', array('model' => $model)); ?> </div> <br/> <p><?php echo Yii::t('BlogModule.blog', 'In this category located post administration functions'); ?> </p> <?php $this->widget('yupe\\widgets\\CustomGridView', array('id' => 'post-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'bulkActions' => array('actionButtons' => array(array('id' => 'delete-comment', 'buttonType' => 'button', 'type' => 'danger', 'size' => 'small', 'label' => Yii::t('BlogModule.blog', 'Remove'), 'click' => 'js:function(values){ if(!confirm("' . Yii::t('BlogModule.blog', 'Do you really want to delete selected items?') . '")) return false; multiaction("delete", values); }')), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('name' => 'id', 'value' => 'CHtml::link($data->id, array("/blog/postBackend/update","id" => $data->id))', 'type' => 'html', 'htmlOptions' => array('style' => 'width:10px;')), array('name' => 'blog_id', 'type' => 'raw', 'value' => 'CHtml::link($data->blog->name, array("/blog/blogBackend/view", "id" => $data->blog->id))', 'filter' => CHtml::listData(Blog::model()->findAll(), 'id', 'name')), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'title', 'editable' => array('url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'inline', 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken))), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'slug', 'editable' => array('url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'inline', 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken))), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'publish_date', 'editable' => array('url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'inline', 'type' => 'datetime', 'options' => array('datetimepicker' => array('format' => 'dd-mm-yyyy hh:ii'), 'datepicker' => array('format' => 'dd-mm-yyyy hh:ii')), 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken))), array('name' => 'category_id', 'value' => 'empty($data->category) ? "---" : $data->category->name', 'filter' => Category::model()->getFormattedList((int) Yii::app()->getModule('blog')->mainPostCategory)), array('name' => 'create_user_id', 'type' => 'raw', 'value' => 'CHtml::link($data->createUser->getFullName(), array("/user/userBackend/view", "id" => $data->createUser->id))', 'filter' => CHtml::listData(User::model()->cache($this->yupe->coreCacheTime)->findAll(), 'id', 'nick_name')), array('class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => array('url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'source' => $model->getStatusList(), 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)), 'name' => 'status', 'type' => 'raw', 'value' => '$data->getStatus()', 'filter' => Post::model()->getStatusList()), array('class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => array('url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'source' => $model->getCommentStatusList(), 'params' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)), 'name' => 'comment_status', 'type' => 'raw', 'value' => '$data->getCommentStatus()', 'filter' => $model->getCommentStatusList()), array('header' => Yii::t('BlogModule.blog', 'Tags'), 'value' => 'implode(", ", $data->getTags())'), array('header' => "<i class=\"icon-comment\"></i>", 'value' => 'CHtml::link(($data->commentsCount>0) ? $data->commentsCount-1 : 0,array("/comment/commentBackend/index/","Comment[model]" => "Post","Comment[model_id]" => $data->id))', 'type' => 'raw'), array('class' => 'bootstrap.widgets.TbButtonColumn'))));
echo Yii::t('BlogModule.blog', 'Fields marked with'); ?> <span class="required">*</span> <?php echo Yii::t('BlogModule.blog', 'are required.'); ?> </div> <?php echo $form->errorSummary($model); ?> <div class="row"> <div class="col-sm-3"> <?php echo $form->select2Group($model, 'blog_id', ['widgetOptions' => ['data' => ['' => '---'] + CHtml::listData(Blog::model()->getList(), 'id', 'name')]]); ?> </div> <div class="col-sm-3"> <?php echo $form->dropDownListGroup($model, 'status', ['widgetOptions' => ['data' => $model->getStatusList(), 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('status'), 'data-content' => $model->getAttributeDescription('status')]]]); ?> </div> <div class="col-sm-3"> <?php echo $form->dateTimePickerGroup($model, 'publish_time', ['widgetOptions' => ['options' => ['format' => 'dd-mm-yyyy hh:ii', 'weekStart' => 1, 'autoclose' => true], 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('publish_time'), 'data-content' => $model->getAttributeDescription('publish_time')]], 'prepend' => '<i class="fa fa-calendar"></i>']); ?> </div> </div> <div class="row">
<a class="btn btn-default btn-sm dropdown-toggle" data-toggle="collapse" data-target="#search-toggle"> <i class="fa fa-search"> </i> <?php echo Yii::t('BlogModule.blog', 'Find posts'); ?> <span class="caret"> </span> </a> <div id="search-toggle" class="collapse out search-form"> <?php Yii::app()->getClientScript()->registerScript('search', "\n \$('.search-form form').submit(function () {\n \$.fn.yiiGridView.update('post-grid', {\n data: \$(this).serialize()\n });\n\n return false;\n });"); $this->renderPartial('_search', ['model' => $model]); ?> </div> <?php $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'post-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => ['url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'title' => Yii::t('BlogModule.blog', 'Select {field}', ['{field}' => mb_strtolower($model->getAttributeLabel('blog_id'))]), 'source' => CHtml::listData(Blog::model()->findAll(), 'id', 'name'), 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'name' => 'blog_id', 'type' => 'raw', 'filter' => CHtml::activeDropDownList($model, 'blog_id', CHtml::listData(Blog::model()->findAll(), 'id', 'name'), ['class' => 'form-control', 'empty' => ''])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'title', 'editable' => ['url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'title', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'slug', 'editable' => ['url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'slug', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'publish_time', 'editable' => ['url' => $this->createUrl('/blog/postBackend/inline'), 'type' => 'datetime', 'options' => ['datetimepicker' => ['format' => 'dd-mm-yyyy hh:ii', 'language' => Yii::app()->language], 'datepicker' => ['format' => 'dd-mm-yyyy']], 'viewformat' => 'dd-mm-yyyy hh:ii', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'value' => function ($data) { return $data->publish_time; }, 'filter' => CHtml::activeTextField($model, 'publish_time', ['class' => 'form-control'])], ['name' => 'create_user_id', 'type' => 'raw', 'value' => function ($data) { return CHtml::link($data->createUser->getFullName(), array("/user/userBackend/view", "id" => $data->createUser->id)); }, 'filter' => CHtml::activeDropDownList($model, 'create_user_id', User::getFullNameList(), ['class' => 'form-control', 'empty' => ''])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'editable' => ['url' => $this->createUrl('/blog/postBackend/inline'), 'mode' => 'popup', 'type' => 'select', 'title' => Yii::t('BlogModule.blog', 'Select {field}', ['{field}' => mb_strtolower($model->getAttributeLabel('comment_status'))]), 'source' => array_merge(['' => '---'], $model->getCommentStatusList()), 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken]], 'name' => 'comment_status', 'type' => 'raw', 'value' => function ($data) { return $data->getCommentStatus(); }, 'filter' => CHtml::activeDropDownList($model, 'comment_status', $model->getCommentStatusList(), ['class' => 'form-control', 'empty' => ''])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'status', 'url' => $this->createUrl('/blog/postBackend/inline'), 'source' => $model->getStatusList(), 'options' => [Post::STATUS_PUBLISHED => ['class' => 'label-success'], Post::STATUS_SCHEDULED => ['class' => 'label-info'], Post::STATUS_DRAFT => ['class' => 'label-default'], Post::STATUS_MODERATED => ['class' => 'label-warning']]], ['name' => 'tags', 'value' => function ($data) { return implode(", ", $data->getTags()); }, 'filter' => false], ['header' => "<i class=\"fa fa-comment\"></i>", 'value' => function ($data) { return CHtml::link($data->commentsCount > 0 ? $data->commentsCount - 1 : 0, array("/comment/commentBackend/index/", "Comment[model]" => "Post", "Comment[model_id]" => $data->id)); }, 'type' => 'raw'], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'frontViewButtonUrl' => function ($data) { return Yii::app()->createUrl('/blog/post/view', ['slug' => $data->slug]); }, 'buttons' => ['front_view' => ['visible' => function ($row, $data) { return $data->status == Post::STATUS_PUBLISHED; }]]]]]);
/** * @param $slug * @throws CHttpException */ public function actionMembers($slug) { $blog = Blog::model()->getBySlug($slug); if (null === $blog) { throw new CHttpException(404); } $this->render('members', ['blog' => $blog, 'members' => $blog->getMembersList()]); }
<div class="wide row-fluid control-group"> <div class="span3"> <?php echo $form->textFieldRow($model, 'title', array('class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('title'), 'data-content' => $model->getAttributeDescription('title'))); ?> </div> <div class="span3"> <?php echo $form->textFieldRow($model, 'slug', array('class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('slug'), 'data-content' => $model->getAttributeDescription('slug'))); ?> </div> </div> <div class="wide row-fluid control-group"> <div class="span3"> <?php echo $form->dropDownListRow($model, 'blog_id', CHtml::listData(Blog::model()->findAll(), 'id', 'name'), array('empty' => '----', 'class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('blog_id'), 'data-content' => $model->getAttributeDescription('blog_id'))); ?> </div> <div class="span3"> <div class="popover-help" data-original-title='<?php echo $model->getAttributeLabel('publish_date'); ?> ' data-content='<?php echo $model->getAttributeDescription('publish_date'); ?> '> <?php echo $form->labelEx($model, 'publish_date'); ?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'publish_date', 'options' => array('dateFormat' => 'yy-mm-dd')));
</div> <div class="panel-body"> <?php $criteria = new CDbCriteria(); $criteria->order = " DATE_FORMAT(time,'%Y') DESC "; $criteria->group = " DATE_FORMAT(time,'%Y') "; $bl = Blog::model()->findAll($criteria); foreach ($bl as $blog) { echo CHtml::link(date("Y", strtotime($blog->time)), '#', array(' data-toggle' => 'collapse', 'data-target' => '#' . $blog->id)) . '<br>'; echo '<div id="' . $blog->id . '" class="collapse">'; $criteria = new CDbCriteria(); $criteria->order = " DATE_FORMAT(time,'%m') ASC "; $criteria->group = " DATE_FORMAT(time,'%Y-%m') "; $criteria->condition = " DATE_FORMAT(time,'%Y') = '" . date("Y", strtotime($blog->time)) . "' "; $bl2 = Blog::model()->findAll($criteria); foreach ($bl2 as $blog) { echo ' ' . CHtml::link($months[date("m", strtotime($blog->time))], Yii::app()->request->baseUrl . '/index.php/blog/index?pvm=' . date("Y-m", strtotime($blog->time)), array('class' => 'search-button')) . '<br>'; } echo '</div>'; } ?> </div> </div> </div> </div> </div>
public function run() { $models = Blog::model()->public()->published()->cache($this->cacheTime)->with('membersCount', 'postsCount')->cache($this->cacheTime)->findAll(array('join' => 'JOIN {{blog_user_to_blog}} utb ON utb.blog_id = t.id', 'select' => 't.name, t.slug', 'order' => 'count(utb.id) DESC', 'group' => 't.slug, t.name, t.id', 'limit' => $this->limit)); $this->render($this->view, array('models' => $models)); }
</a> <?php $this->widget('CStarRating', array('htmlOptions' => array('class' => 'linkcomment', 'style' => 'padding-left: 4px; text-align:left; direction:ltr;'), 'name' => 'rating', 'value' => $model->getRating(), 'readOnly' => Yii::app()->user->isGuest, 'allowEmpty' => false, 'starCount' => 5, 'ratingStepSize' => 1, 'maxRating' => 10, 'minRating' => 1, 'callback' => ' function(){ $.ajax({ type: "POST", url: "' . $this->createUrl('blog/rating') . '", data: "' . Yii::app()->request->csrfTokenName . '=' . Yii::app()->request->csrfToken . '&id=' . $model->id . '&rate=" + $(this).val(), success: function(msg){ alert("' . Yii::t('global', 'Rating Added.') . '"); }})}')); ?> <?php if (Blog::model()->canEditPost($model)) { ?> <?php echo CHtml::link(CHtml::image(Yii::app()->themeManager->baseUrl . '/images/icons/pencil.png'), array('blog/editpost', 'id' => $model->id), array('class' => 'linkcomment')); ?> <?php } ?> <?php if (Yii::app()->user->checkAccess('op_blog_manage')) { ?> <?php if ($model->status) {