├── .gitignore ├── Bootstrap.php ├── Module.php ├── README.md ├── assets ├── AdminAsset.php ├── AppAsset.php ├── DynamicFrontendAsset.php ├── FeatherlightAsset.php ├── FontAwesomeAsset.php ├── ModmoreRedactorPluginsAsset.php ├── StickySidebarAsset.php ├── TinymceFileManagerAsset.php └── default │ ├── css │ ├── bootstrap_custom.css │ ├── common.css │ └── style.css │ └── js │ └── fixRedactor.js ├── behaviors └── DataOptionsBehavior │ ├── Behavior.php │ └── DataModel.php ├── components ├── JsonLDHelper.php ├── OpenGraph.php ├── TwitterCard.php └── ViewPatternHelper.php ├── composer.json ├── controllers ├── backend │ ├── BaseAdminController.php │ ├── BlogCategoryController.php │ ├── BlogCommentController.php │ ├── BlogPostController.php │ ├── BlogTagController.php │ ├── DefaultController.php │ ├── ImperaviController.php │ ├── ImporterController.php │ ├── PostTypeController.php │ ├── TinymceController.php │ ├── UploadController.php │ └── WidgetTypeController.php └── frontend │ ├── DefaultController.php │ └── FixerController.php ├── messages ├── config.php ├── hy │ └── blog.php └── ru-RU │ └── blog.php ├── migrations ├── m000001_000001_blog_post_type.php ├── m000002_000001_blog_category.php ├── m000002_000004_blog_category_data.php ├── m000003_000001_blog_post.php ├── m000003_000002_blog_post_book.php ├── m000003_000003_blog_post_book_chapter.php ├── m000003_000004_blog_category_map.php ├── m000003_000005_blog_post_data.php ├── m000007_000001_blog_comment.php ├── m000008_000001_blog_tag.php ├── m000009_000001_blog_widget_type.php ├── m000009_000002_blog_widget_type_DATA_INSERT.php └── m100000_000001_blog_rules.php ├── models ├── BlogCategory.php ├── BlogCategoryData.php ├── BlogCategorySearch.php ├── BlogComment.php ├── BlogCommentSearch.php ├── BlogPost.php ├── BlogPostBook.php ├── BlogPostBookChapter.php ├── BlogPostBookChapterSearch.php ├── BlogPostData.php ├── BlogPostSearch.php ├── BlogPostType.php ├── BlogTag.php ├── BlogTagSearch.php ├── BlogWidgetType.php └── importer │ ├── Csv.php │ └── Wordpress.php ├── rbac └── BlogAuthorRule.php ├── traits ├── ConfigTrait.php ├── ModuleTrait.php └── StatusTrait.php ├── views ├── backend │ ├── blog-category │ │ ├── _form.php │ │ ├── _search.php │ │ ├── create.php │ │ ├── index.php │ │ ├── update.php │ │ └── view.php │ ├── blog-comment │ │ ├── _form.php │ │ ├── _search.php │ │ ├── create.php │ │ ├── index.php │ │ ├── update.php │ │ └── view.php │ ├── blog-post │ │ ├── _book_chapter_form.php │ │ ├── _book_form.php │ │ ├── _form.php │ │ ├── _search.php │ │ ├── create.php │ │ ├── createBook.php │ │ ├── createBookChapter.php │ │ ├── index.php │ │ ├── update.php │ │ ├── updateBook.php │ │ ├── updateBookChapter.php │ │ └── view.php │ ├── blog-tag │ │ ├── _form.php │ │ ├── _search.php │ │ ├── create.php │ │ ├── index.php │ │ ├── update.php │ │ └── view.php │ ├── default │ │ ├── index.php │ │ └── thumbnails.php │ ├── importer │ │ ├── csv.php │ │ ├── index.php │ │ └── wordpress.php │ ├── post-type │ │ ├── _form.php │ │ ├── create.php │ │ ├── index.php │ │ └── update.php │ └── widget-type │ │ ├── _form.php │ │ ├── create.php │ │ ├── index.php │ │ ├── update.php │ │ └── view.php └── frontend │ ├── default │ ├── _article.php │ ├── _book.php │ ├── _book_chapter_search_form.php │ ├── _books.php │ ├── _chapter.php │ ├── _comment.php │ ├── _post.php │ ├── archive.php │ ├── dynamic.php │ ├── index.php │ ├── navbar.php │ ├── searchBookChapter.php │ ├── view.php │ ├── viewBook.php │ └── viewChapter.php │ └── layouts │ ├── dynamic.php │ └── navigation.php └── widgets ├── Article.php ├── Carousel.php ├── Comments.php ├── Feed.php ├── Navigation.php ├── RecentComments.php ├── Search.php ├── Slider.php ├── Slider2.php ├── SocialMedia.php ├── social ├── AddThis.php └── FacebookComments.php └── views ├── _feed_item.php ├── _post_item.php ├── _search.php └── recentComments.php /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ -------------------------------------------------------------------------------- /Bootstrap.php: -------------------------------------------------------------------------------- 1 | db->getTableSchema(BlogPostType::tableName(), true) === null) { 18 | return; 19 | } 20 | 21 | $post_types = BlogPostType::find()->all(); 22 | $rules = [ 23 | /* 24 | * Category rage rule 25 | * Each category has custom page 26 | * F.e. https://yoursite.com/category/my_category_slug 27 | * */ 28 | '/category/' => '/blog/default/archive', 29 | 30 | /* 31 | * Archive page shows all posts 32 | * With pagination 33 | * */ 34 | '/archive/' => '/blog/default/archive', 35 | '/archive' => '/blog/default/archive', 36 | 37 | /* 38 | * Site map XML rule 39 | * F.e. http://yoursite.com/sitemap 40 | * */ 41 | '/sitemap' => '/blog/sitemap', 42 | 43 | /* 44 | * Fixing old posts issue 45 | * */ 46 | // '/archives/' => '/blog/fixer/id', 47 | // [ 48 | // 'pattern' => '///', 49 | // 'route' => '/blog/fixer/slug', 50 | // 'suffix' => '/' 51 | // ], 52 | 53 | 54 | ]; 55 | 56 | foreach ($post_types as $type) { 57 | if ($type->url_pattern != null) { 58 | $rules[] = [ 59 | 'pattern' => $type->url_pattern, 60 | 'route' => '/blog/default/view', 61 | 'suffix' => '/' 62 | ]; 63 | $rules[] = [ 64 | 'pattern' => $type->url_pattern, 65 | 'route' => '/blog/default/view', 66 | ]; 67 | 68 | } 69 | } 70 | 71 | /* 72 | * Adding module URL rules. 73 | * */ 74 | $app->getUrlManager()->addRules( 75 | $rules 76 | ); 77 | 78 | 79 | // Add module I18N category. 80 | if (!isset($app->i18n->translations['diazoxide/blog'])) { 81 | $app->i18n->translations['diazoxide/blog'] = [ 82 | 'class' => PhpMessageSource::class, 83 | 'basePath' => __DIR__ . '/messages', 84 | 'forceTranslation' => true, 85 | 'fileMap' => [ 86 | 'diazoxide/blog' => 'blog.php', 87 | ] 88 | // 'class' => \yii\i18n\DbMessageSource::class, 89 | // 'sourceMessageTable'=>'{{%source_message}}', 90 | // 'messageTable'=>'{{%message}}', 91 | // 'enableCaching' => true, 92 | // 'cachingDuration' => 10, 93 | // 'forceTranslation'=>true, 94 | 95 | ]; 96 | } 97 | 98 | \Yii::setAlias('@diazoxide', \Yii::getAlias('@vendor') . '/diazoxide'); 99 | } 100 | } -------------------------------------------------------------------------------- /assets/AdminAsset.php: -------------------------------------------------------------------------------- 1 | 'module', 15 | 'crossorigin'=>"anonymous" 16 | ], 17 | ]; 18 | } 19 | -------------------------------------------------------------------------------- /assets/TinymceFileManagerAsset.php: -------------------------------------------------------------------------------- 1 | getView(); 33 | $assetManager = $view->getAssetManager(); 34 | $bundle = $assetManager->getBundle(self::class); 35 | return $assetManager->getAssetUrl($bundle, $asset); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /assets/default/css/common.css: -------------------------------------------------------------------------------- 1 | .diazoxide_infinite_scroll_pager_status { 2 | display: none; 3 | width: 100%; 4 | position: absolute; 5 | bottom: 0; 6 | border-top: 1px solid #DDD; 7 | text-align: center; 8 | color: #fff; 9 | background: #444; 10 | } -------------------------------------------------------------------------------- /assets/default/js/fixRedactor.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $.fn.size = function() { 3 | return this.length; 4 | } 5 | }); -------------------------------------------------------------------------------- /behaviors/DataOptionsBehavior/Behavior.php: -------------------------------------------------------------------------------- 1 | 'afterSave', 36 | ActiveRecord::EVENT_AFTER_INSERT => 'afterSave', 37 | /*ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeSave', 38 | ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete', 39 | ActiveRecord::EVENT_BEFORE_DELETE => 'beforeDelete', 40 | ActiveRecord::EVENT_BEFORE_INSERT => 'beforeSave',*/ 41 | ]; 42 | } 43 | 44 | /** 45 | * After save 46 | * @throws Exception 47 | */ 48 | public function afterSave() 49 | { 50 | foreach ($this->_data as $data) { 51 | $this->setDataValue($data[0], $data[1], $data[2]); 52 | } 53 | } 54 | 55 | /** 56 | * @return \yii\db\ActiveQuery 57 | * @throws Exception 58 | */ 59 | public function getData() 60 | { 61 | return $this->owner->hasMany($this->data_model, [$this->owner_attribute => $this->getPrimaryKey()]); 62 | } 63 | 64 | /** 65 | * @return mixed 66 | * @throws Exception 67 | */ 68 | protected function getPrimaryKey() 69 | { 70 | $primaryKey = $this->owner->primaryKey(); 71 | if (!isset($primaryKey[0])) { 72 | throw new Exception('"' . $this->owner->className() . '" must have a primary key.'); 73 | } 74 | return $primaryKey[0]; 75 | } 76 | 77 | 78 | /** 79 | * @param $name 80 | * @param null $default 81 | * @return array|null|\yii\db\ActiveRecord|\yii\db\ActiveRecord[] 82 | * @throws Exception 83 | */ 84 | public function getDataValue($name, $default = null) 85 | { 86 | $query = $this->getData()->andWhere([$this->name_attribute => $name]); 87 | 88 | if ($query->count() == 1) { 89 | return $query->one(); 90 | } elseif ($query->count() > 1) { 91 | return $query->all(); 92 | } 93 | 94 | return $default; 95 | } 96 | 97 | /** 98 | * Saving Dynamic data to db 99 | * @param $name 100 | * @param $value 101 | * @param bool $overwrite 102 | * @return array|bool 103 | * @throws Exception 104 | */ 105 | public function setDataValue($name, $value, $overwrite = true) 106 | { 107 | if ($this->owner->isNewRecord) { 108 | $this->_data[] = [$name, $value, $overwrite]; 109 | return true; 110 | } 111 | 112 | $errors = []; 113 | $data = $this->getDataValue($name); 114 | 115 | if (!is_array($value)) { 116 | $value = [$value]; 117 | } 118 | 119 | if (!$data || !$overwrite) { 120 | 121 | foreach ($value as $item) { 122 | /** @var ActiveRecord $model */ 123 | $model = new $this->data_model; 124 | $model->{$this->owner_attribute} = $this->owner->id; 125 | $model->{$this->name_attribute} = $name; 126 | $model->{$this->value_attribute} = (string)$item; 127 | if (!$model->save()) { 128 | $errors[] = $model->errors; 129 | } 130 | } 131 | 132 | } elseif ($overwrite) { 133 | 134 | if (!is_array($data)) { 135 | $data = [$data]; 136 | } 137 | 138 | foreach ($value as $key => $item) { 139 | $model = isset($data[$key]) ? $data[$key] : new $this->data_model; 140 | $model->{$this->owner_attribute} = $this->owner->id; 141 | $model->{$this->name_attribute} = $name; 142 | $model->{$this->value_attribute} = (string)$item; 143 | if (!$model->save()) { 144 | $errors[] = $model->errors; 145 | } 146 | } 147 | } 148 | 149 | if (!empty($errors)) { 150 | return $errors; 151 | } 152 | 153 | return true; 154 | } 155 | 156 | 157 | /** 158 | * @param $name 159 | * @param $value 160 | * @return \yii\db\ActiveQuery 161 | */ 162 | public function findByData($name, $value) 163 | { 164 | return $this->owner::find() 165 | ->joinWith(['data data']) 166 | ->andWhere( 167 | [ 168 | "data.{$this->name_attribute}" => $name, 169 | "data.{$this->value_attribute}" => $value 170 | ] 171 | ); 172 | } 173 | } -------------------------------------------------------------------------------- /behaviors/DataOptionsBehavior/DataModel.php: -------------------------------------------------------------------------------- 1 | 255], 23 | [['value'], 'string'] 24 | ]; 25 | } 26 | 27 | 28 | } -------------------------------------------------------------------------------- /components/JsonLDHelper.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class JsonLDHelper extends Component 15 | { 16 | public $publisher; 17 | 18 | public function init(){ 19 | $this->addBreadcrumbList(); 20 | $this->add($this->publisher); 21 | } 22 | /** 23 | * Adds BreadcrumbList schema.org markup based on the application view `breadcrumbs` parameter 24 | */ 25 | public function addBreadcrumbList() 26 | { 27 | $view = Yii::$app->getView(); 28 | $breadcrumbList = []; 29 | if (isset($view->params['breadcrumbs'])) { 30 | $position = 1; 31 | foreach ($view->params['breadcrumbs'] as $breadcrumb) { 32 | if (is_array($breadcrumb)) { 33 | $breadcrumbList[] = (object)[ 34 | "@type" => "http://schema.org/ListItem", 35 | "http://schema.org/position" => $position, 36 | "http://schema.org/item" => (object)[ 37 | "@id" => Url::to($breadcrumb['url'], true), 38 | "http://schema.org/name" => $breadcrumb['label'], 39 | ] 40 | ]; 41 | } else { 42 | // Is it ok to omit URL here or not? Google is not clear on that: 43 | // http://stackoverflow.com/questions/33688608/how-to-markup-the-last-non-linking-item-in-breadcrumbs-list-using-json-ld 44 | $breadcrumbList[] = (object)[ 45 | "@type" => "http://schema.org/ListItem", 46 | "http://schema.org/position" => $position, 47 | "http://schema.org/item" => (object)[ 48 | "http://schema.org/name" => $breadcrumb, 49 | "@id"=>'' 50 | ] 51 | ]; 52 | } 53 | $position++; 54 | } 55 | } 56 | $doc = (object)[ 57 | "@type" => "http://schema.org/BreadcrumbList", 58 | "http://schema.org/itemListElement" => $breadcrumbList 59 | ]; 60 | JsonLDHelper::add($doc); 61 | } 62 | /** 63 | * Compacts JSON-LD document, encodes and adds to the application view `jsonld` parameter, 64 | * so it can later be registered using JsonLDHelper::registerScripts(). 65 | * @param array|object $doc The JSON-LD document 66 | * @param array|null|object|string $context optional context. If not specified, schema.org vocabulary will be used. 67 | */ 68 | public function add($doc, $context = null) 69 | { 70 | if (is_null($context)) { 71 | // Using a simple context from the following comment would end up replacing `@type` keyword with `type` alias, 72 | // which is not recognized by Google's SDTT. So using a workaround instead 73 | // http://stackoverflow.com/questions/35879351/google-structured-data-testing-tool-fails-to-validate-type-as-an-alias-of-type 74 | //$context = (object)["@context" => "http://schema.org"]; 75 | $context = (object)[ 76 | "@context" => (object)["@vocab" => "http://schema.org/"] 77 | ]; 78 | } 79 | $compacted = JsonLD::compact((object)$doc, $context); 80 | // We need to register it with "application/ld+json" script type, which is not possible with registerJs(), 81 | // so passing to layout where it can be registered via JsonLDHelper::registerScripts() using Html::script 82 | $view = Yii::$app->getView(); 83 | $view->params['jsonld'][] = json_encode($compacted, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); 84 | } 85 | /** 86 | * Registers JSON-LD scripts stored in the application view `jsonld` parameter. 87 | * This should be invoked in the section of your layout. 88 | */ 89 | public function registerScripts() 90 | { 91 | $view = Yii::$app->getView(); 92 | if (isset($view->params['jsonld'])) { 93 | foreach ($view->params['jsonld'] as $jsonld) { 94 | echo Html::script($jsonld, ['type' => 'application/ld+json']); 95 | } 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /components/OpenGraph.php: -------------------------------------------------------------------------------- 1 | title = Yii::$app->name; 20 | $this->site_name = Yii::$app->name; 21 | $this->url = Yii::$app->request->absoluteUrl; 22 | $this->description = null; 23 | $this->type = 'article'; 24 | $this->locale = str_replace('-','_',Yii::$app->language); 25 | $this->image = null; 26 | 27 | // Twitter Card 28 | $this->twitter = new TwitterCard; 29 | 30 | // Listed to Begin Page View event to start adding meta 31 | Yii::$app->view->on(View::EVENT_BEGIN_PAGE, function(){ 32 | // Register required and easily determined open graph data 33 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:title', 'content'=>$this->title], 'og:title'); 34 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:site_name', 'content'=>$this->site_name], 'og:site_name'); 35 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:url', 'content'=>$this->url], 'og:url'); 36 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:type', 'content'=>$this->type], 'og:type'); 37 | 38 | // Locale issafe to be specifued since it has default value on Yii applications 39 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:locale', 'content'=>$this->locale], 'og:locale'); 40 | 41 | // Only add a description meta if specified 42 | if($this->description!==null){ 43 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:description', 'content'=>$this->description], 'og:description'); 44 | } 45 | 46 | // Only add an image meta if specified 47 | if($this->image!==null){ 48 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:image', 'content'=>$this->image], 'og:image'); 49 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:image:width', 'content'=>$this->imageWidth], 'og:image:width'); 50 | Yii::$app->controller->view->registerMetaTag(['property'=>'og:image:height', 'content'=>$this->imageHeight], 'og:image:height'); 51 | } 52 | 53 | $this->twitter->registerTags(); 54 | }); 55 | } 56 | 57 | 58 | public function set($metas=[]){ 59 | // Massive assignment by array 60 | foreach($metas as $property=>$content){ 61 | if($property=='twitter'){ 62 | $this->twitter->set($content); 63 | }else if(property_exists($this, $property)){ 64 | $this->$property = $content; 65 | } 66 | } 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /components/TwitterCard.php: -------------------------------------------------------------------------------- 1 | card = null; 28 | $this->site = null; 29 | $this->site_id = null; 30 | $this->creator = null; 31 | $this->creator_id = null; 32 | } 33 | 34 | public function set($metas=[]){ 35 | // Massive assignment by array 36 | foreach($metas as $property=>$content){ 37 | if(property_exists($this, $property)){ 38 | $this->$property = $content; 39 | } 40 | } 41 | } 42 | 43 | public function registerTags(){ 44 | $this->checkTag('card'); 45 | $this->checkTag('site'); 46 | $this->checkTag('site_id'); 47 | $this->checkTag('creator'); 48 | $this->checkTag('creator_id'); 49 | } 50 | 51 | private function checkTag($property){ 52 | if($this->$property!==null){ 53 | $property = str_replace('_', ':', $property); 54 | Yii::$app->controller->view->registerMetaTag([ 55 | 'property' => 'twitter:'.$property, 56 | 'content' => $this->$property, 57 | ], 'twitter:'.$property); 58 | } 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /components/ViewPatternHelper.php: -------------------------------------------------------------------------------- 1 | (?.*?)\:\:(?>(?\w+)))'; 15 | public static $viewPattern = '(?(?>[\w+@\/\-\_])+)'; 16 | public static $varPattern = '(?>\$(?(?>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?>(?>\-\>[\w\s]+)+)?))'; 17 | public static $configPattern = '(?>\`(?.*)\`)'; 18 | public static $codePattern = '(?>\`\`\`(?.*)\`\`\`)'; 19 | 20 | /** 21 | * Building final pattern 22 | * @return string 23 | */ 24 | public static function pattern(){ 25 | 26 | $class = self::$classPattern; 27 | $view = self::$viewPattern; 28 | $var = self::$varPattern; 29 | $config = self::$configPattern; 30 | $code = self::$codePattern; 31 | 32 | /* 33 | * Constructing instances pattern 34 | * */ 35 | $instance = "(?>$class|$view|$var)"; 36 | 37 | /* 38 | * Building final pattern 39 | * */ 40 | $pattern = "/\[(?>$code|(?>$instance(?>\s*)$config?))\]/"; 41 | return $pattern; 42 | } 43 | 44 | private static function initConfig($config, $dependencies) 45 | { 46 | foreach ($config as $key => $option) { 47 | if (is_string($option)) { 48 | preg_match('/^(?>\$(?(?>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?>(?>\-\>[\w\s]+)+)?))$/', 49 | $option, $option_matches); 50 | if (isset($option_matches['var'])) { 51 | $config[$key] = $dependencies[$option_matches['var']]; 52 | } 53 | } elseif (is_array($option)) { 54 | $config[$key] = self::initConfig($option, $dependencies); 55 | } 56 | } 57 | 58 | return $config; 59 | } 60 | 61 | public static function extract($pattern, $dependencies) 62 | { 63 | return preg_replace_callback(self::pattern(), 64 | function ($matches) use ($dependencies) { 65 | 66 | $code = isset($matches['code']) ? $matches['code'] : null; 67 | 68 | if($code){ 69 | return eval($code); 70 | } 71 | 72 | $view = isset($matches['view']) ? $matches['view'] : null; 73 | 74 | $var = isset($matches['var']) ? $matches['var'] : null; 75 | 76 | $config = isset($matches['config']) ? $matches['config'] : null; 77 | 78 | 79 | if ($config) { 80 | $config = self::initConfig(json_decode($config, true), $dependencies); 81 | } else { 82 | $config = []; 83 | } 84 | 85 | if ($view) { 86 | $result = Yii::$app->view->render($view, $config); 87 | 88 | return $result === false ? $matches[0] : $result; 89 | } elseif ($var) { 90 | $path = explode('->', $var); 91 | $elem = null; 92 | foreach ($path as $key => $prop) { 93 | if ($key == 0) { 94 | $elem = $dependencies[$prop]; 95 | } else { 96 | if (is_array($elem)) { 97 | $elem = $elem[$prop]; 98 | } elseif (is_object($elem)) { 99 | $elem = $elem->{$prop}; 100 | } else { 101 | $elem = Module::t('', 'Wrong Variable.'); 102 | } 103 | } 104 | } 105 | 106 | return $elem; 107 | } 108 | 109 | $class = isset($matches['class']) ? $matches['class'] : null; 110 | if ($class) { 111 | 112 | $method = isset($matches['method']) ? $matches['method'] : null; 113 | 114 | $MethodChecker = new ReflectionMethod($class, $method); 115 | if ($MethodChecker->isStatic()) { 116 | return $MethodChecker->invokeArgs(new $class, $config); 117 | /*return call_user_func($class . '::' . $method, $config);*/ 118 | } else { 119 | $obj = new $class($config); 120 | 121 | return $obj->{$method}; 122 | } 123 | } 124 | 125 | /* 126 | * Return Full match as string 127 | * */ 128 | return $matches[0]; 129 | 130 | }, $pattern); 131 | 132 | } 133 | 134 | } -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "diazoxide/yii2-blog", 3 | "description": "Advanced Yii2 blog module, posts, categories, tags, comments, books, SEO, social plugins, Slider Revolution e.t.c.", 4 | "type": "yii2-extension", 5 | "keywords": [ 6 | "yii2", 7 | "extension", 8 | "blog", 9 | "post", 10 | "category", 11 | "tag", 12 | "comments", 13 | "module", 14 | "yii2-blog", 15 | "seo" 16 | ], 17 | "license": "MIT", 18 | "authors": [ 19 | { 20 | "name": "Diazoxide", 21 | "email": "diazoxide@gmail.com" 22 | } 23 | ], 24 | "require": { 25 | "ext-json": "*", 26 | "ext-fileinfo":"*", 27 | "yiisoft/yii2": "*", 28 | "yiisoft/yii2-bootstrap4": "~1.0.0", 29 | "diazoxide/yii2-revslider": "*", 30 | "diazoxide/yii2-infinite-scroll": "dev-master", 31 | "2amigos/yii2-ckeditor-widget": "dev-master", 32 | "trntv/yii2-aceeditor": "^2.0.0", 33 | "2amigos/yii2-tinymce-widget": "~1.1", 34 | "yiidoc/yii2-redactor": "*", 35 | "bower-asset/modmore-redactor-plugins": "v1.1.3", 36 | "bower-asset/font-awesome": "^5.7", 37 | "bower-asset/featherlight": "^1.7.6", 38 | "bower-asset/sticky-sidebar": "*", 39 | "paulzi/yii2-adjacency-list": "^2.2", 40 | "yii-dream-team/yii2-upload-behavior": "dev-master", 41 | "voskobovich/yii2-many-many-behavior": "^3.0", 42 | "kartik-v/yii2-widget-select2": "@dev", 43 | "kartik-v/yii2-widget-datetimepicker": "dev-master", 44 | "dektrium/yii2-user": "^0.9.14", 45 | "dektrium/yii2-rbac": "^1.0", 46 | "yiisoft/yii2-imagine": "*", 47 | "lesha724/yii2-math-captcha": "*", 48 | "chriskonnertz/bbcode": "dev-master", 49 | "paulzi/yii2-json-behavior": "~1.0.0", 50 | "himiklab/yii2-sitemap-module" : "*", 51 | "ml/json-ld": "1.*", 52 | "zelenin/yii2-i18n-module": "dev-master", 53 | "parsecsv/php-parsecsv":"^1.1.1" 54 | }, 55 | "repositories": [ 56 | { 57 | "type": "package", 58 | "package": { 59 | "name": "yii-dream-team/yii2-upload-behavior", 60 | "type": "yii2-extension", 61 | "description": "Yii2 file/image upload behavior for ActiveRecord", 62 | "keywords": [ 63 | "file", 64 | "image", 65 | "upload", 66 | "behavior", 67 | "resize", 68 | "thumb" 69 | ], 70 | "license": "MIT", 71 | "homepage": "http://yiidreamteam.com/yii2/upload-behavior", 72 | "authors": [ 73 | { 74 | "name": "Alexey Samoylov", 75 | "email": "alexey.samoylov@gmail.com", 76 | "homepage": "http://yiidreamteam.com/team/alexey", 77 | "role": "Developer" 78 | } 79 | ], 80 | "minimum-stability": "dev", 81 | "require": { 82 | "php": ">=7.1.0", 83 | "yiisoft/yii2": "*", 84 | "masterexploder/phpthumb": "*" 85 | }, 86 | "repositories": [ 87 | { 88 | "type": "git", 89 | "url": "https://github.com/yii-dream-team/PHPThumb" 90 | } 91 | ], 92 | "autoload": { 93 | "psr-4": { 94 | "yiidreamteam\\upload\\": "./src" 95 | } 96 | }, 97 | "version": "1.0.0", 98 | "source": { 99 | "type": "git", 100 | "url": "https://github.com/akiraz2/yii2-upload-behavior", 101 | "reference": "master" 102 | } 103 | } 104 | } 105 | ], 106 | "autoload": { 107 | "psr-4": { 108 | "diazoxide\\blog\\": "" 109 | } 110 | }, 111 | "extra": { 112 | "bootstrap": "diazoxide\\blog\\Bootstrap" 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /controllers/backend/BaseAdminController.php: -------------------------------------------------------------------------------- 1 | [ 28 | 'class' => VerbFilter::class, 29 | 'actions' => [ 30 | 'delete' => ['POST'], 31 | ], 32 | ] 33 | ]; 34 | } 35 | 36 | public function init() 37 | { 38 | if ($this->module->adminAccessControl) { 39 | $this->attachBehavior('access', [ 40 | 'class' => $this->module->adminAccessControl, 41 | ]); 42 | } 43 | 44 | parent::init(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /controllers/backend/DefaultController.php: -------------------------------------------------------------------------------- 1 | [ 26 | 'class' => VerbFilter::class, 27 | 'actions' => [ 28 | 'regenerate-thumbnails' => ['POST'], 29 | ], 30 | ], 31 | 32 | 'access' => [ 33 | 'class' => AccessControl::class, 34 | 'only' => ['index', 'thumbnails', 'regenerate-thumbnails'], 35 | 'rules' => [ 36 | [ 37 | 'actions' => ['index'], 38 | 'allow' => true, 39 | 'roles' => ['@'] 40 | ], 41 | [ 42 | 'actions' => ['thumbnails', 'regenerate-thumbnails'], 43 | 'allow' => true, 44 | 'roles' => ['BLOG_REGENERATE_THUMBNAILS'] 45 | ], 46 | ] 47 | ] 48 | 49 | ]; 50 | } 51 | 52 | /** 53 | * @return string 54 | */ 55 | public function actionIndex() 56 | { 57 | return $this->render('index'); 58 | } 59 | 60 | public function actionThumbnails() 61 | { 62 | $post_count = BlogPost::find()->count(); 63 | return $this->render('thumbnails', [ 64 | 'count' => $post_count 65 | ]); 66 | } 67 | 68 | public function actionRegenerateThumbnails($offset, $limit) 69 | { 70 | 71 | $posts = BlogPost::find()->orderBy(['id' => SORT_DESC])->limit($limit)->offset($offset)->all(); 72 | foreach ($posts as $key => $post) { 73 | $post->createThumbs(); 74 | } 75 | 76 | echo Module::t(null, 'Thumbnails Generation Done: ' . $offset . ' - ' . ($limit + $offset)) . PHP_EOL; 77 | 78 | } 79 | 80 | public function actionTest(){ 81 | echo BlogCategory::find()->where(['type_id'=>1])->findByData('wordpress_origin_id',140)->one()->title; 82 | // echo (new BlogCategory())->findByData('wordpress_origin_id',140)->andWhere(['type_id' =>1])->one()->title; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /controllers/backend/ImperaviController.php: -------------------------------------------------------------------------------- 1 | [ 22 | 'class' => 'vova07\imperavi\actions\GetImagesAction', 23 | 'url' => $this->module->imgFileUrl, // Directory URL address, where files are stored. 24 | 'path' => $this->module->imgFilePath, 25 | ], 26 | 'image-upload' => [ 27 | 'class' => 'vova07\imperavi\actions\UploadFileAction', 28 | 'url' => $this->module->imgFileUrl, // Directory URL address, where files are stored. 29 | 'path' => $this->module->imgFilePath, 30 | ], 31 | 'file-delete' => [ 32 | 'class' => 'vova07\imperavi\actions\DeleteFileAction', 33 | 'url' => $this->module->imgFileUrl, // Directory URL address, where files are stored. 34 | 'path' => $this->module->imgFilePath, 35 | ], 36 | 'files-get' => [ 37 | 'class' => 'vova07\imperavi\actions\GetFilesAction', 38 | 'url' => $this->module->imgFileUrl, // Directory URL address, where files are stored. 39 | 'path' => $this->module->imgFilePath, 40 | ], 41 | 'file-upload' => [ 42 | 'class' => 'vova07\imperavi\actions\UploadFileAction', 43 | 'url' => $this->module->imgFileUrl, // Directory URL address, where files are stored. 44 | 'path' => $this->module->imgFilePath, 45 | 'uploadOnlyImage' => false, // For any kind of files uploading. 46 | ], 47 | ]; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /controllers/backend/TinymceController.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'class' => VerbFilter::class, 25 | 'actions' => [ 26 | 'upload' => ['POST'], 27 | ], 28 | ], 29 | 30 | ]; 31 | } 32 | 33 | /** 34 | * @throws BadRequestHttpException 35 | * @throws \yii\base\InvalidConfigException 36 | */ 37 | public function actionUpload() 38 | { 39 | $imageFolder = Yii::getAlias($this->module->imgFilePath . '/' . $this->module->postContentImagesDirectory); 40 | $imageUrl = Yii::getAlias($this->module->imgFileUrl . '/' . $this->module->postContentImagesDirectory); 41 | $temp = UploadedFile::getInstanceByName('file'); 42 | 43 | if ($temp) { 44 | 45 | $name = Yii::$app->formatter->asDatetime(time(), 'php:Y-m-d-H-i-s') . '_' . $temp->baseName . '.' . $temp->extension; 46 | 47 | $temp->saveAs($imageFolder . '/' . $name); 48 | 49 | $fileurl = $imageUrl . '/' . $name; 50 | 51 | return json_encode(['location' => $fileurl]); 52 | 53 | } else { 54 | 55 | throw new BadRequestHttpException("Invalid upload."); 56 | 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /controllers/backend/UploadController.php: -------------------------------------------------------------------------------- 1 | module = \Yii::$app->getModule(\Yii::$app->getModule('blog')->redactorModule); 17 | $this->attachBehavior('content', [ 18 | 'class' => 'yii\filters\ContentNegotiator', 19 | 'formats' => [ 20 | 'application/json' => Response::FORMAT_JSON 21 | ], 22 | ]); 23 | } 24 | 25 | public function actions() 26 | { 27 | return [ 28 | 'file' => 'yii\redactor\actions\FileUploadAction', 29 | 'image' => 'yii\redactor\actions\ImageUploadAction', 30 | 'image-json' => 'yii\redactor\actions\ImageManagerJsonAction', 31 | 'file-json' => 'yii\redactor\actions\FileManagerJsonAction', 32 | ]; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /controllers/backend/WidgetTypeController.php: -------------------------------------------------------------------------------- 1 | [ 27 | 'class' => VerbFilter::className(), 28 | 'actions' => [ 29 | 'delete' => ['POST'], 30 | ], 31 | ], 32 | 'access' => [ 33 | 'class' => AccessControl::className(), 34 | 'only' => ['index', 'delete', 'create', 'update'], 35 | 'rules' => [ 36 | [ 37 | 'actions' => ['index'], 38 | 'allow' => true, 39 | 'roles' => ['BLOG_VIEW_WIDGET_TYPES'] 40 | ], 41 | [ 42 | 'actions' => ['delete'], 43 | 'allow' => true, 44 | 'roles' => ['BLOG_DELETE_WIDGET_TYPE'] 45 | ], 46 | [ 47 | 'actions' => ['create'], 48 | 'allow' => true, 49 | 'roles' => ['BLOG_CREATE_WIDGET_TYPE'] 50 | ], 51 | [ 52 | 'actions' => ['update'], 53 | 'allow' => true, 54 | 'roles' => ['BLOG_UPDATE_WIDGET_TYPE'] 55 | ], 56 | ], 57 | ], 58 | ]; 59 | } 60 | 61 | /** 62 | * @return mixed 63 | */ 64 | public function actionIndex() 65 | { 66 | $query = BlogWidgetType::find(); 67 | 68 | $dataProvider = new ActiveDataProvider([ 69 | 'query' => $query, 70 | ]); 71 | 72 | return $this->render('index', [ 73 | 'dataProvider' => $dataProvider, 74 | ]); 75 | } 76 | 77 | /** 78 | * @param integer $id 79 | * @return mixed 80 | * @throws NotFoundHttpException 81 | */ 82 | public function actionView($id) 83 | { 84 | return $this->render('view', [ 85 | 'model' => $this->findModel($id), 86 | ]); 87 | } 88 | 89 | /** 90 | * @param integer $id 91 | * @return BlogWidgetType 92 | * @throws NotFoundHttpException if the model cannot be found 93 | */ 94 | protected function findModel($id) 95 | { 96 | if (($model = BlogWidgetType::findOne($id)) !== null) { 97 | return $model; 98 | } else { 99 | throw new NotFoundHttpException('The requested page does not exist.'); 100 | } 101 | } 102 | 103 | /** 104 | * @return string|\yii\web\Response 105 | */ 106 | public function actionCreate() 107 | { 108 | $model = new BlogWidgetType(); 109 | 110 | if ($model->load(Yii::$app->request->post()) && $model->save()) { 111 | return $this->redirect(['update', 'id' => $model->id]); 112 | } 113 | 114 | return $this->render('create', [ 115 | 'model' => $model, 116 | ]); 117 | } 118 | 119 | /** 120 | * @param integer $id 121 | * @return mixed 122 | * @throws NotFoundHttpException 123 | */ 124 | public function actionUpdate($id) 125 | { 126 | $model = $this->findModel($id); 127 | if ($model->load(Yii::$app->request->post()) && $model->save()) { 128 | return $this->redirect(['update', 'id' => $model->id]); 129 | } 130 | return $this->render('update', [ 131 | 'model' => $model, 132 | ]); 133 | } 134 | 135 | /** 136 | * @param integer $id 137 | * @return mixed 138 | * @throws NotFoundHttpException 139 | * @throws \Throwable 140 | * @throws \yii\db\StaleObjectException 141 | */ 142 | public function actionDelete($id) 143 | { 144 | //$this->findModel($id)->delete(); 145 | $model = $this->findModel($id); 146 | $model->delete(); 147 | 148 | return $this->redirect(['index']); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /controllers/frontend/FixerController.php: -------------------------------------------------------------------------------- 1 | $slug]); 38 | return $this->redirect($post->url); 39 | } 40 | 41 | /** 42 | * @param $id 43 | * @return \yii\web\Response 44 | */ 45 | public function actionId($id) 46 | { 47 | $post = BlogPost::findOne($id); 48 | return $this->redirect($post->url); 49 | } 50 | 51 | 52 | public function actionWordpress($id){ 53 | $opt = BlogPostData::findOne(['name'=>"wp_" . md5("https://armday.org")."_origin_id",'value'=>$id]); 54 | $post = BlogPost::findOne($opt->owner_id); 55 | return $this->redirect($post->url); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /messages/config.php: -------------------------------------------------------------------------------- 1 | null, 14 | 'interactive' => true, 15 | 'help' => null, 16 | 'sourcePath' => '@vendor/diazoxide/yii2-blog/', 17 | 'messagePath' => '@vendor/diazoxide/yii2-blog/messages', 18 | 'languages' => [ 19 | 'en-US', 20 | 'ru-RU', 21 | 'hy', 22 | ], 23 | 'translator' => 'Module::t', 24 | 'sort' => false, 25 | 'overwrite' => true, 26 | 'removeUnused' => false, 27 | 'markUnused' => true, 28 | 'except' => [ 29 | '.svn', 30 | '.git', 31 | '.gitignore', 32 | '.gitkeep', 33 | '.hgignore', 34 | '.hgkeep', 35 | '/vendor', 36 | '/BaseYii.php', 37 | '/node_modules', 38 | '/vagrant', 39 | '*test*', 40 | '*fixture*', 41 | 'environments' 42 | ], 43 | 'only' => [ 44 | '*.php', 45 | ], 46 | 'format' => 'db', 47 | 'db' => 'db', 48 | 'sourceMessageTable' => '{{%source_message}}', 49 | 'messageTable' => '{{%message}}', 50 | 'catalog' => 'messages', 51 | 'ignoreCategories' => [], 52 | 'phpFileHeader' => '', 53 | 'phpDocBlock' => null, 54 | ]; 55 | -------------------------------------------------------------------------------- /messages/hy/blog.php: -------------------------------------------------------------------------------- 1 | 'Թեգեր', 21 | 'A comment has been added and is awaiting validation' => 'Մեկնաբանությունը ավելացվել է և գտնվում է հաստատման փուլում։', 22 | 'Action not found' => 'Գործողություն չի հայտնաբերվել', 23 | 'Actions' => 'Գործողություն', 24 | 'Add Sub Category' => 'Ավելացնել ենթաբաժին', 25 | 'Add comments' => 'Ավելացնել մեկնաբանություն', 26 | 'Are you sure you want to delete this item?' => 'Վստա՞հ եք, որ ցանկանում եք ջնջել այս։', 27 | 'Author' => 'Հեղինակ', 28 | 'Banner' => 'Գլխավոր նկար', 29 | 'Blog' => 'Լրատվական', 30 | 'Blog Categories' => 'Բաժիններ', 31 | 'Blog Category' => 'Բաժին', 32 | 'Blog Comment' => 'Մեկնաբանություն', 33 | 'Blog Comments' => 'Մեկնաբանություններ', 34 | 'Blog Post' => 'Գրառում', 35 | 'Blog Posts' => 'Գրառումներ', 36 | 'Blog Tag' => 'Թեգ', 37 | 'Blog Tags' => 'Թեգեր', 38 | 'Brief' => 'Կարճ նկարագրություն', 39 | 'CONSTANT_NO' => 'ՈՉ', 40 | 'CONSTANT_YES' => 'ԱՅՈ', 41 | 'Categories' => 'Բաժիններ', 42 | 'Category' => 'Բաժին', 43 | 'Category ID' => 'Բաժնի Հ/Հ', 44 | 'Click' => 'Դիտումներ', 45 | 'Comment' => 'Մեկնաբանություն', 46 | 'Comments' => 'Մեկնաբանություններ', 47 | 'Comments Count' => 'Մեկնաբանութ․ քանակը', 48 | 'Confirm' => 'Հաստատել', 49 | 'Content' => 'Տեքստ', 50 | 'Create' => 'Ստեղծել', 51 | 'Create ' => 'Ստեղծել ', 52 | 'Create Time' => 'Ստեղծման ժամանակը', 53 | 'Created' => 'Ստեղծված', 54 | 'Created At' => 'Ստեղծված', 55 | 'Delete' => 'Ջնջել', 56 | 'Email' => 'Էլ․ Փոստ', 57 | 'Feed' => 'Լրահոս', 58 | 'Frequency' => 'Հաճախականություն', 59 | 'General' => 'Գլխավոր', 60 | 'ID' => 'Հ/Հ', 61 | 'Icon Class' => 'Մանրապատկերի Կլասը', 62 | 'Insert banner code' => 'Ավելացրեք բանների կոդը', 63 | 'Is Featured' => 'Կարևորված', 64 | 'Is Nav' => 'Նավիգացիա', 65 | 'Is Slide' => 'Սլայդ', 66 | 'Math, for example, 45-12 = 33' => 'Գրեք լուծումը, օրինակ՝ 45-12 = 33', 67 | 'NO' => 'Ոչ', 68 | 'Name' => 'Անուն', 69 | 'No' => 'Ոչ', 70 | 'PAGE_TYPE_LIST' => 'Լիստ', 71 | 'PAGE_TYPE_PAGE' => 'Հասարակ Էջ', 72 | 'PROMPT_STATUS' => 'Կարգավիճակը', 73 | 'Page Size' => 'Էջի չափերը', 74 | 'Parent' => 'Ծնող', 75 | 'Parent ID' => 'Ծնողական Հ/Հ', 76 | 'Play video' => 'Դիտել տեսանյութը', 77 | 'Please Filter' => 'Ֆիլտր', 78 | 'Popular posts' => 'Շատ ընթերցվողներ', 79 | 'Post' => 'Գրառում', 80 | 'Post ID' => 'Գրառման Հ/Հ', 81 | 'Posts' => 'Գրառումներ', 82 | 'Published' => 'Հրապարակված', 83 | 'Published At' => 'Հրապարակված', 84 | 'Read Icon Class' => 'Կարդալու Մանրապատկերի Կլասը', 85 | 'Read more' => 'Կարդալ ավելին', 86 | 'Redirect Url' => 'Վերահղման URL', 87 | 'Reset' => 'Վերագործարկել', 88 | 'Root Category' => 'Արմատային բաժին', 89 | 'STATUS_ACTIVE' => 'Ակտիվ', 90 | 'STATUS_ARCHIVE' => 'Արխիվ', 91 | 'STATUS_INACTIVE' => 'Ապաակտիվացված', 92 | 'Search' => 'Փնտրել', 93 | 'Select Categories' => 'Ընտրեք Բաժիններ', 94 | 'Select Category' => 'Ընտրեք Բաժինը', 95 | 'Select Main Category' => 'Ընտրեք Հիմնական Բաժինը', 96 | 'Select Publish Datetime' => 'Ընտրեք Հրապարակման ամիս/ամսաթիվը', 97 | 'Select value' => 'Ընտրեք արժեքը', 98 | 'Send' => 'Ուղարկել', 99 | 'Show Comments' => 'Ցուցադրել Մեկնաբանությունները', 100 | 'Show In Slider' => 'Ցուցադրել սլայդերում', 101 | 'Slug' => 'Սղանուն', 102 | 'Sort Order' => 'Դասավորություն', 103 | 'Status' => 'Կարգավիճակ', 104 | 'Successfully confirm' => 'Հաջողությամբ Հաստատվեց', 105 | 'Successfully delete' => 'Հաջողությամբ ջնջվեց', 106 | 'Template' => 'Շաբլոն', 107 | 'Title' => 'Վերնագիր', 108 | 'Update' => 'Թարմացնել', 109 | 'Update ' => 'Թարմացնել ', 110 | 'Updated' => 'Թարմացված', 111 | 'Updated At' => 'Թարմացված', 112 | 'Url' => 'Url', 113 | 'User ID' => 'Օգտատիրոջ Հ/Հ', 114 | 'Verify code' => 'Ստուգման կոդ', 115 | 'Videos' => 'Տեսանյութեր', 116 | 'View' => 'Դիտել', 117 | 'Welcome to Blog Module' => 'Բարի գալուստ', 118 | 'Widget Types' => 'Վիջեթների Տեսակները', 119 | 'Write comments' => 'Գրել մեկնաբանություն', 120 | 'YES' => 'Այո', 121 | 'Yes' => 'Այո', 122 | ]; 123 | -------------------------------------------------------------------------------- /messages/ru-RU/blog.php: -------------------------------------------------------------------------------- 1 | 'Добро пожаловать в модуль Блог', 21 | 'A comment has been added and is awaiting validation' => 'Комментарий добавлен и ожидает проверки', 22 | 'Action not found' => 'Действие не найдено', 23 | 'Actions' => 'Действия', 24 | 'Add Sub Catelog' => 'Добавить подкатегорию', 25 | 'Add comments' => 'Добавить комментарий', 26 | 'Are you sure you want to delete this item?' => 'Точно удалить?', 27 | 'Author' => 'Автор', 28 | 'Banner' => 'Баннер', 29 | 'Blog' => 'Статьи', 30 | 'Blog Category' => 'Категория блога', 31 | 'Blog Categories' => 'Категории блога', 32 | 'Blog Comment' => 'Комментарий блога', 33 | 'Blog Comments' => 'Комментарии блога', 34 | 'Blog Post' => 'Запись блога', 35 | 'Blog Posts' => 'Записи блога', 36 | 'Blog Tag' => 'Тег блога', 37 | 'Blog Tags' => 'Теги блога', 38 | 'Brief' => 'Краткий Анонс', 39 | 'CONSTANT_NO' => 'НЕТ', 40 | 'CONSTANT_YES' => 'ДА', 41 | 'Category' => 'Категория', 42 | 'Category ID' => 'ID Категории', 43 | 'Click' => 'Просмотры', 44 | 'Comments' => 'Комментарии', 45 | 'Comments Count' => 'Кол-во комментариев', 46 | 'Confirm' => 'Подтвердить', 47 | 'Content' => 'Текст', 48 | 'Create' => 'Создать', 49 | 'Create ' => 'Создать ', 50 | 'Create Time' => 'Время создания', 51 | 'Created At' => 'Создано', 52 | 'Delete' => 'Удалить', 53 | 'Email' => 'Email', 54 | 'Frequency' => 'Частота', 55 | 'ID' => 'ID', 56 | 'Is Nav' => 'Навигация', 57 | 'Math, for example, 45-12 = 33' => 'Напишите решение, например, 45-12 = 33', 58 | 'NO' => 'Нет', 59 | 'Name' => 'Имя', 60 | 'PAGE_TYPE_LIST' => 'PAGE_TYPE_LIST', 61 | 'PAGE_TYPE_PAGE' => 'PAGE_TYPE_PAGE', 62 | 'PROMPT_STATUS' => 'Все', 63 | 'Page Size' => 'Размер страницы', 64 | 'Parent ID' => 'ID родителя', 65 | 'Please Filter' => 'Фильтр', 66 | 'Post ID' => 'ID Записи', 67 | 'Redirect Url' => 'URL перенаправления', 68 | 'Reset' => 'Сбросить', 69 | 'Root Category' => 'Корневая категория', 70 | 'STATUS_ACTIVE' => 'Актив', 71 | 'STATUS_DELETED' => 'Удалено', 72 | 'STATUS_INACTIVE' => 'Неактив', 73 | 'Search' => 'Поиск', 74 | 'Send' => 'Отправить', 75 | 'Slug' => 'Транслит', 76 | 'Sort Order' => 'Сортировка', 77 | 'Status' => 'Статус', 78 | 'Successfully confirm' => 'Успешно подтверждено', 79 | 'Successfully delete' => 'Успешно удалено', 80 | 'Tags' => 'Теги', 81 | 'Template' => 'Шаблон', 82 | 'Title' => 'Название', 83 | 'Update' => 'Изменить', 84 | 'Update ' => 'Изменить ', 85 | 'Updated At' => 'Обновлено', 86 | 'Url' => 'Url', 87 | 'User ID' => 'User ID', 88 | 'Verify code' => 'Проверочный код', 89 | 'View' => 'Просмотреть', 90 | 'Write comments' => 'Написать комментарий', 91 | 'YES' => 'Да', 92 | ]; 93 | -------------------------------------------------------------------------------- /migrations/m000002_000001_blog_category.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_category}}', 21 | [ 22 | 'id' => $this->primaryKey(11), 23 | 'parent_id' => $this->integer(11)->notNull()->defaultValue(0), 24 | 'title' => $this->string(191)->notNull(), 25 | 'slug' => $this->string(191)->notNull(), 26 | 'banner' => $this->string(191)->null()->defaultValue(null), 27 | 'icon_class' => $this->string(60)->null()->defaultValue(null), 28 | 'is_nav' => $this->integer(11)->notNull()->defaultValue(1), 29 | 'is_featured' => $this->tinyInteger(1)->defaultValue(0), 30 | 'widget_type_id' => $this->integer(11)->null()->defaultValue(null), 31 | 'read_icon_class' => $this->string(60)->null(), 32 | 'read_more_text' => $this->string(60)->null(), 33 | 'sort_order' => $this->integer(11)->notNull()->defaultValue(50), 34 | 'sort' => $this->integer(11)->notNull()->defaultValue(0), 35 | 'page_size' => $this->integer(11)->notNull()->defaultValue(10), 36 | 'template' => $this->string(191)->notNull()->defaultValue('post'), 37 | 'redirect_url' => $this->string(191)->null()->defaultValue(null), 38 | 'status' => $this->integer(11)->notNull()->defaultValue(1), 39 | 'created_at' => $this->integer(11)->notNull()->defaultValue(0), 40 | 'updated_at' => $this->integer(11)->notNull()->defaultValue(0), 41 | 'type_id' => $this->integer(11)->null()->defaultValue(1), 42 | ], $tableOptions 43 | ); 44 | $this->createIndex('is_nav', '{{%blog_category}}', ['is_nav'], false); 45 | $this->createIndex('sort_order', '{{%blog_category}}', ['sort_order'], false); 46 | $this->createIndex('status', '{{%blog_category}}', ['status'], false); 47 | $this->createIndex('created_at', '{{%blog_category}}', ['created_at'], false); 48 | 49 | $this->addForeignKey('fk_blog_category_type_id', 50 | '{{%blog_category}}', 'type_id', 51 | '{{%blog_post_type}}', 'id', 52 | 'CASCADE', 'CASCADE' 53 | ); 54 | 55 | $this->insertDefaultContent(); 56 | } 57 | 58 | public function safeDown() 59 | { 60 | $this->dropForeignKey('fk_blog_category_type_id', '{{%blog_category}}'); 61 | 62 | $this->dropIndex('is_nav', '{{%blog_category}}'); 63 | $this->dropIndex('sort_order', '{{%blog_category}}'); 64 | $this->dropIndex('status', '{{%blog_category}}'); 65 | $this->dropIndex('created_at', '{{%blog_category}}'); 66 | $this->dropTable('{{%blog_category}}'); 67 | } 68 | 69 | public function insertDefaultContent() 70 | { 71 | $this->batchInsert('{{%blog_category}}', 72 | ["id", "type_id", "parent_id", "title", "slug"], 73 | [ 74 | [ 75 | 'id' => '1', 76 | 'type_id'=>null, 77 | 'parent_id' => '0', 78 | 'title' => 'Main', 79 | 'slug' => 'main', 80 | ], 81 | [ 82 | 'id' => '2', 83 | 'type_id'=>'1', 84 | 'parent_id' => '1', 85 | 'title' => 'My Articles', 86 | 'slug' => 'my-articles', 87 | ] 88 | ] 89 | ); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /migrations/m000002_000004_blog_category_data.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_category_data}}', 21 | [ 22 | 'id' => $this->primaryKey(11), 23 | 'owner_id' => $this->integer(11)->notNull()->defaultValue(0), 24 | 'name' => $this->string(191)->notNull(), 25 | 'value' => $this->text(), 26 | ], $tableOptions 27 | ); 28 | 29 | $this->createIndex('owner_id', '{{%blog_category_data}}', ['owner_id'], false); 30 | 31 | $this->addForeignKey('fk_blog_category_data_owner_id', 32 | '{{%blog_category_data}}', 'owner_id', 33 | '{{%blog_category}}', 'id', 34 | 'CASCADE', 'CASCADE' 35 | ); 36 | 37 | } 38 | 39 | public function safeDown() 40 | { 41 | $this->dropForeignKey('fk_blog_category_data_owner_id', '{{%blog_category_data}}'); 42 | $this->dropIndex('owner_id', '{{%blog_category_data}}'); 43 | $this->dropTable('{{%blog_category_data}}'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /migrations/m000003_000001_blog_post.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_post}}', 21 | [ 22 | 'id' => $this->primaryKey(11), 23 | 'title' => $this->string(191)->notNull(), 24 | 'content' => $this->getDb()->getSchema()->createColumnSchemaBuilder('longtext')->null()->defaultValue(null), 25 | // 'content' => $this->text()->null()->defaultValue(null), 26 | 'brief' => $this->text()->null()->defaultValue(null), 27 | 'created_at' => $this->integer(11)->defaultValue(0), 28 | 'published_at' => $this->integer(11)->defaultValue(0), 29 | 'banner' => $this->string(191)->null()->defaultValue(null), 30 | 'user_id' => $this->integer(11)->null()->defaultValue(null), 31 | 'slug' => $this->string(191)->unique(), 32 | 'tags' => $this->string(191)->null()->defaultValue(null), 33 | 'click' => $this->integer(11)->defaultValue(0), 34 | 'show_comments' => $this->tinyInteger(1)->null()->defaultValue(null), 35 | 'status' => $this->integer(11)->notNull()->defaultValue(1), 36 | 'updated_at' => $this->integer(11)->defaultValue(0), 37 | 'category_id' => $this->integer(11)->null()->defaultValue(0), 38 | 'is_slide' => $this->boolean(), 39 | 'type_id' => $this->integer(11)->notNull(), 40 | ], $tableOptions 41 | ); 42 | 43 | $this->createIndex('category_id', '{{%blog_post}}', ['category_id'], false); 44 | $this->createIndex('type_id', '{{%blog_post}}', ['type_id'], false); 45 | $this->createIndex('status', '{{%blog_post}}', ['status'], false); 46 | $this->createIndex('created_at', '{{%blog_post}}', ['created_at'], false); 47 | $this->createIndex('updated_at', '{{%blog_post}}', ['updated_at'], false); 48 | $this->createIndex('published_at', '{{%blog_post}}', ['published_at'], false); 49 | 50 | $this->addForeignKey('fk_blog_post_type_id', 51 | '{{%blog_post}}', 'type_id', 52 | '{{%blog_post_type}}', 'id', 53 | 'CASCADE', 'CASCADE' 54 | ); 55 | 56 | } 57 | 58 | public function safeDown() 59 | { 60 | $this->dropForeignKey('fk_blog_post_type_id', '{{%blog_post}}'); 61 | $this->dropIndex('slug', '{{%blog_post}}'); 62 | $this->dropIndex('category_id', '{{%blog_post}}'); 63 | $this->dropIndex('status', '{{%blog_post}}'); 64 | $this->dropIndex('created_at', '{{%blog_post}}'); 65 | $this->dropIndex('updated_at', '{{%blog_post}}'); 66 | $this->dropIndex('published_at', '{{%blog_post}}'); 67 | $this->dropTable('{{%blog_post}}'); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /migrations/m000003_000002_blog_post_book.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_post_book}}', 21 | [ 22 | 'id'=> $this->primaryKey(11), 23 | 'post_id'=> $this->integer(11)->notNull(), 24 | 'title'=> $this->string(191)->notNull(), 25 | 'brief'=> $this->string(191)->notNull(), 26 | 'banner'=> $this->string(191)->notNull(), 27 | 'slug'=> $this->string(128)->notNull(), 28 | 'bbcode'=> $this->tinyInteger(1)->null()->defaultValue(null), 29 | 'created_at'=> $this->integer(11)->notNull(), 30 | 'updated_at'=> $this->integer(11)->notNull(), 31 | 'status'=> $this->tinyInteger(1)->notNull(), 32 | ],$tableOptions 33 | ); 34 | $this->createIndex('post_id','{{%blog_post_book}}',['post_id'],false); 35 | 36 | $this->addForeignKey('fk_blog_post_book_post_id', 37 | '{{%blog_post_book}}', 'post_id', 38 | '{{%blog_post}}', 'id', 39 | 'CASCADE', 'CASCADE' 40 | ); 41 | 42 | } 43 | 44 | public function safeDown() 45 | { 46 | $this->dropForeignKey('fk_blog_post_book_post_id', '{{%blog_post_book}}'); 47 | $this->dropIndex('post_id', '{{%blog_post_book}}'); 48 | $this->dropTable('{{%blog_post_book}}'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /migrations/m000003_000003_blog_post_book_chapter.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 11 | parent::init(); 12 | } 13 | 14 | public function safeUp() 15 | { 16 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 17 | 18 | $this->createTable( 19 | '{{%blog_post_book_chapter}}', 20 | [ 21 | 'id' => $this->primaryKey(11), 22 | 'book_id' => $this->integer(11)->notNull(), 23 | 'title' => $this->string(191)->notNull(), 24 | 'content' => $this->text()->notNull(), 25 | 'bbcode' => $this->tinyInteger(1)->null()->defaultValue(null), 26 | 'brief' => $this->string(191)->notNull(), 27 | 'keywords' => $this->string(191)->notNull(), 28 | 'banner' => $this->string(191)->notNull(), 29 | 'parent_id' => $this->integer(11)->null()->defaultValue(null), 30 | 'sort_order' => $this->integer(11)->notNull(), 31 | ], $tableOptions 32 | ); 33 | $this->createIndex('book_id', '{{%blog_post_book_chapter}}', ['book_id'], false); 34 | $this->createIndex('parent_id', '{{%blog_post_book_chapter}}', ['book_id'], false); 35 | 36 | 37 | $this->addForeignKey('fk_blog_post_book_chapter_book_id', 38 | '{{%blog_post_book_chapter}}', 'book_id', 39 | '{{%blog_post_book}}', 'id', 40 | 'CASCADE', 'CASCADE' 41 | ); 42 | 43 | $this->addForeignKey('fk_blog_post_book_chapter_parent_id', 44 | '{{%blog_post_book_chapter}}', 'parent_id', 45 | '{{%blog_post_book_chapter}}', 'id', 46 | 'CASCADE', 'CASCADE' 47 | ); 48 | 49 | } 50 | 51 | public function safeDown() 52 | { 53 | $this->dropForeignKey('fk_blog_post_book_chapter_book_id', '{{%blog_post_book_chapter}}'); 54 | 55 | $this->dropForeignKey('fk_blog_post_book_chapter_parent_id', '{{%blog_post_book_chapter}}'); 56 | 57 | $this->dropIndex('book_id', '{{%blog_post_book}}'); 58 | 59 | $this->dropIndex('parent_id', '{{%blog_post_book}}'); 60 | 61 | 62 | $this->dropTable('{{%blog_post_book_chapter}}'); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /migrations/m000003_000004_blog_category_map.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_category_map}}', 21 | [ 22 | 'post_id'=> $this->integer(11)->notNull(), 23 | 'category_id'=> $this->integer(11)->notNull(), 24 | ],$tableOptions 25 | ); 26 | 27 | $this->addForeignKey('fk_blog_category_map_category_id', 28 | '{{%blog_category_map}}', 'category_id', 29 | '{{%blog_category}}', 'id', 30 | 'CASCADE', 'CASCADE' 31 | ); 32 | 33 | $this->addForeignKey('fk_blog_category_map_post_id', 34 | '{{%blog_category_map}}', 'post_id', 35 | '{{%blog_post}}', 'id', 36 | 'CASCADE', 'CASCADE' 37 | ); 38 | 39 | } 40 | 41 | public function safeDown() 42 | { 43 | $this->dropForeignKey('fk_blog_category_map_category_id', '{{%blog_category_map}}'); 44 | 45 | $this->dropForeignKey('fk_blog_category_map_post_id', '{{%blog_category_map}}'); 46 | 47 | $this->dropTable('{{%blog_category_map}}'); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /migrations/m000003_000005_blog_post_data.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_post_data}}', 21 | [ 22 | 'id' => $this->primaryKey(11), 23 | 'owner_id' => $this->integer(11)->notNull()->defaultValue(0), 24 | 'name' => $this->string(191)->notNull(), 25 | 'value' => $this->text(), 26 | ], $tableOptions 27 | ); 28 | 29 | $this->createIndex('owner_id', '{{%blog_post_data}}', ['owner_id'], false); 30 | 31 | $this->addForeignKey('fk_blog_post_data_owner_id', 32 | '{{%blog_post_data}}', 'owner_id', 33 | '{{%blog_post}}', 'id', 34 | 'CASCADE', 'CASCADE' 35 | ); 36 | 37 | } 38 | 39 | public function safeDown() 40 | { 41 | $this->dropForeignKey('fk_blog_post_data_owner_id', '{{%blog_post_data}}'); 42 | $this->dropIndex('owner_id', '{{%blog_post_data}}'); 43 | $this->dropTable('{{%blog_post_data}}'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /migrations/m000007_000001_blog_comment.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_comment}}', 21 | [ 22 | 'id'=> $this->primaryKey(11), 23 | 'post_id'=> $this->integer(11)->notNull(), 24 | 'content'=> $this->text()->notNull(), 25 | 'author'=> $this->string(128)->notNull(), 26 | 'email'=> $this->string(128)->notNull(), 27 | 'url'=> $this->string(128)->null()->defaultValue(null), 28 | 'status'=> $this->integer(11)->notNull()->defaultValue(1), 29 | 'created_at'=> $this->integer(11)->notNull(), 30 | 'updated_at'=> $this->integer(11)->notNull(), 31 | ],$tableOptions 32 | ); 33 | $this->createIndex('post_id','{{%blog_comment}}',['post_id'],false); 34 | $this->createIndex('status','{{%blog_comment}}',['status'],false); 35 | $this->createIndex('created_at','{{%blog_comment}}',['created_at'],false); 36 | 37 | $this->addForeignKey('fk_blog_comment_post_id', 38 | '{{%blog_comment}}','post_id', 39 | '{{%blog_post}}','id', 40 | 'CASCADE','CASCADE' 41 | ); 42 | } 43 | 44 | public function safeDown() 45 | { 46 | $this->dropForeignKey('fk_blog_comment_post_id', '{{%blog_comment}}'); 47 | 48 | $this->dropIndex('post_id', '{{%blog_comment}}'); 49 | $this->dropIndex('status', '{{%blog_comment}}'); 50 | $this->dropIndex('created_at', '{{%blog_comment}}'); 51 | $this->dropTable('{{%blog_comment}}'); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /migrations/m000008_000001_blog_tag.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_tag}}', 21 | [ 22 | 'id'=> $this->primaryKey(11), 23 | 'name'=> $this->string(128)->notNull(), 24 | 'frequency'=> $this->integer(11)->notNull()->defaultValue(1), 25 | ],$tableOptions 26 | ); 27 | $this->createIndex('frequency','{{%blog_tag}}',['frequency'],false); 28 | 29 | } 30 | 31 | public function safeDown() 32 | { 33 | $this->dropIndex('frequency', '{{%blog_tag}}'); 34 | $this->dropTable('{{%blog_tag}}'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /migrations/m000009_000001_blog_widget_type.php: -------------------------------------------------------------------------------- 1 | db = 'db'; 12 | parent::init(); 13 | } 14 | 15 | public function safeUp() 16 | { 17 | $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; 18 | 19 | $this->createTable( 20 | '{{%blog_widget_type}}', 21 | [ 22 | 'id'=> $this->primaryKey(11), 23 | 'title'=> $this->string(191)->notNull(), 24 | 'config'=> $this->text()->notNull(), 25 | ],$tableOptions 26 | ); 27 | 28 | } 29 | 30 | public function safeDown() 31 | { 32 | $this->dropTable('{{%blog_widget_type}}'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /models/BlogCategoryData.php: -------------------------------------------------------------------------------- 1 | orderBy(['sort_order' => SORT_ASC, 'create_time' => SORT_DESC]); 50 | 51 | $dataProvider = new ActiveDataProvider([ 52 | 'query' => $query, 53 | ]); 54 | 55 | if (!($this->load($params) && $this->validate())) { 56 | return $dataProvider; 57 | } 58 | 59 | $query->andFilterWhere([ 60 | 'id' => $this->id, 61 | 'parent_id' => $this->parent_id, 62 | 'is_nav' => $this->is_nav, 63 | 'sort_order' => $this->sort_order, 64 | 'page_size' => $this->page_size, 65 | 'status' => $this->status, 66 | 'create_time' => $this->create_time, 67 | 'update_time' => $this->update_time, 68 | ]); 69 | 70 | $query->andFilterWhere(['like', 'title', $this->title]) 71 | ->andFilterWhere(['like', 'slug', $this->slug]) 72 | ->andFilterWhere(['like', 'banner', $this->banner]) 73 | ->andFilterWhere(['like', 'template', $this->template]) 74 | ->andFilterWhere(['like', 'redirect_url', $this->redirect_url]); 75 | 76 | return $dataProvider; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /models/BlogCommentSearch.php: -------------------------------------------------------------------------------- 1 | orderBy(['created_at' => SORT_DESC]); 51 | 52 | if ($this->scenario == self::SCENARIO_USER) { 53 | $query->andWhere(['post_id' => $post_id, 'status' => [IActiveStatus::STATUS_INACTIVE, IActiveStatus::STATUS_ACTIVE]]); 54 | } 55 | $dataProvider = new ActiveDataProvider([ 56 | 'query' => $query, 57 | 'pagination' => [ 58 | 'pageSize' => $this->module->blogCommentPageCount, 59 | ] 60 | ]); 61 | 62 | if (!($this->load($params) && $this->validate())) { 63 | return $dataProvider; 64 | } 65 | 66 | $query->andFilterWhere([ 67 | 'id' => $this->id, 68 | 'post_id' => $post_id ? $post_id : $this->post_id, 69 | 'status' => ($this->scenario == self::SCENARIO_USER) ? IActiveStatus::STATUS_ACTIVE : $this->status, 70 | 'created_at' => $this->created_at, 71 | 'updated_at' => $this->updated_at, 72 | ]); 73 | 74 | $query->andFilterWhere(['like', 'content', $this->content]) 75 | ->andFilterWhere(['like', 'author', $this->author]) 76 | ->andFilterWhere(['like', 'email', $this->email]) 77 | ->andFilterWhere(['like', 'url', $this->url]); 78 | 79 | return $dataProvider; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /models/BlogPostData.php: -------------------------------------------------------------------------------- 1 | scenario == self::SCENARIO_USER) { 40 | return ''; 41 | } else return parent::formName(); 42 | } 43 | 44 | /** 45 | * @inheritdoc 46 | */ 47 | public function scenarios() 48 | { 49 | $scenarios = parent::scenarios(); 50 | $scenarios[self::SCENARIO_ADMIN] = ['id', 'category_id', 'type_id', 'click', 'user_id', 'status', 'title']; 51 | $scenarios[self::SCENARIO_USER] = ['category_id', 'type_id', 'q']; 52 | return $scenarios; 53 | } 54 | 55 | /** 56 | * Creates data provider instance with search query applied 57 | * 58 | * @param array $params 59 | * 60 | * @return ActiveDataProvider 61 | */ 62 | public function search($params) 63 | { 64 | $query = BlogPost::find(); 65 | 66 | $query->andFilterWhere([$this::tableName() . '.type_id' => $this->type_id]); 67 | 68 | if ($this->scenario == self::SCENARIO_ADMIN) { 69 | $query->orderBy(['created_at' => SORT_DESC]); 70 | 71 | } 72 | if ($this->scenario == self::SCENARIO_USER) { 73 | $query->orderBy(['published_at' => SORT_DESC]); 74 | 75 | $query->andWhere([BlogPost::tableName() . '.status' => IActiveStatus::STATUS_ACTIVE]) 76 | ->innerJoinWith('category') 77 | ->andWhere([BlogCategory::tableName() . '.status' => IActiveStatus::STATUS_ACTIVE]); 78 | 79 | $query->andWhere('FROM_UNIXTIME(' . BlogPost::tableName() . '.published_at) <= NOW()'); 80 | } 81 | 82 | $dataProvider = new ActiveDataProvider([ 83 | 'query' => $query, 84 | 'pagination' => [ 85 | 'pageSize' => $this->module->blogPostPageCount, 86 | ] 87 | ]); 88 | 89 | if (!($this->load($params) && $this->validate())) { 90 | return $dataProvider; 91 | } 92 | 93 | if ($this->scenario == self::SCENARIO_USER) { 94 | $query 95 | ->andFilterWhere(['like', $this::tableName() . '.title', $this->q]) 96 | ->orFilterWhere(['like', $this::tableName() . '.content', $this->q]); 97 | } 98 | 99 | 100 | if ($this->scenario == self::SCENARIO_ADMIN) { 101 | 102 | $query->andFilterWhere([ 103 | $this::tableName() . '.id' => $this->id, 104 | $this::tableName() . '.status' => $this->status, 105 | $this::tableName() . '.click' => $this->click, 106 | $this::tableName() . '.user_id' => $this->user_id, 107 | $this::tableName() . '.created_at' => $this->created_at, 108 | $this::tableName() . '.updated_at' => $this->updated_at, 109 | $this::tableName() . '.published_at' => $this->published_at, 110 | ]); 111 | 112 | $query 113 | ->andFilterWhere(['like', $this::tableName() . '.title', $this->title]) 114 | ->andFilterWhere(['like', $this::tableName() . '.tags', $this->tags]) 115 | ->andFilterWhere(['like', $this::tableName() . '.content', $this->content]) 116 | ->andFilterWhere(['like', $this::tableName() . '.slug', $this->slug]); 117 | } 118 | if ($this->category_id) { 119 | $catIds = ArrayHelper::map(BlogCategory::findOne($this->category_id)->getDescendants()->all(), 'id', 'id'); 120 | $catIds[] = $this->category_id; 121 | $query->andFilterWhere(['in', $this::tableName() . '.category_id', $catIds]); 122 | } 123 | 124 | return $dataProvider; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /models/BlogPostType.php: -------------------------------------------------------------------------------- 1 | 191], 72 | [['name'], 'string', 'max' => 64], 73 | [['single_pattern', 'archive_pattern', 'default_pattern'], 'string'], 74 | [['has_comment', 'has_banner', 'has_category', 'has_tag', 'has_book', 'has_content', 'has_brief', 'has_title'], 'boolean'], 75 | ]; 76 | } 77 | 78 | /** 79 | * @inheritdoc 80 | */ 81 | public function attributeLabels() 82 | { 83 | return [ 84 | 'id' => Module::t('', 'ID'), 85 | 'title' => Module::t('', 'Title'), 86 | 'has_comment' => Module::t('', 'Has Comment'), 87 | 'has_banner' => Module::t('', 'Has Banner'), 88 | 'has_category' => Module::t('', 'Has Category'), 89 | 'has_tag' => Module::t('', 'Has Tag'), 90 | 'has_book' => Module::t('', 'Has Book'), 91 | 92 | ]; 93 | } 94 | 95 | /** 96 | * @return \yii\db\ActiveQuery 97 | */ 98 | public function getPosts() 99 | { 100 | return $this->hasMany(BlogPost::class, ['type_id' => 'id']); 101 | } 102 | 103 | public function getUrl() 104 | { 105 | /* 106 | * If backend detected 107 | * Than return post type edit url 108 | * */ 109 | if ($this->getModule()->getIsBackend()) { 110 | return Yii::$app->getUrlManager()->createUrl(['blog/blog-post', 'type' => $this->name]); 111 | } 112 | 113 | return Yii::$app->getUrlManager()->createUrl(['/']); 114 | } 115 | 116 | // /** 117 | // * Creating image upload directory 118 | // * @param bool $insert 119 | // * @param array $changedAttributes 120 | // * @throws \yii\base\Exception 121 | // */ 122 | // public function afterSave($insert, $changedAttributes) 123 | // { 124 | // parent::afterSave($insert, $changedAttributes); 125 | // 126 | // $path = Yii::getAlias($this->module->imgFilePath . '/post/' . $this->id); 127 | // 128 | // if (!is_dir($path)) { 129 | // FileHelper::createDirectory($path, $mode = 0775, $recursive = true); 130 | // } 131 | // 132 | // } 133 | } 134 | -------------------------------------------------------------------------------- /models/BlogTag.php: -------------------------------------------------------------------------------- 1 | 128] 44 | ]; 45 | } 46 | 47 | /** 48 | * @inheritdoc 49 | */ 50 | public function attributeLabels() 51 | { 52 | return [ 53 | 'id' => Module::t('', 'ID'), 54 | 'name' => Module::t('', 'Name'), 55 | 'frequency' => Module::t('', 'Frequency'), 56 | ]; 57 | } 58 | 59 | public static function string2array($tags) 60 | { 61 | return preg_split('/\s*,\s*/', trim($tags), -1, PREG_SPLIT_NO_EMPTY); 62 | } 63 | 64 | public static function array2string($tags) 65 | { 66 | return implode(',', $tags); 67 | } 68 | 69 | public static function updateFrequency($oldTags, $newTags) 70 | { 71 | $oldTags = self::string2array($oldTags); 72 | $newTags = self::string2array($newTags); 73 | self::addTags(array_values(array_diff($newTags, $oldTags))); 74 | self::removeTags(array_values(array_diff($oldTags, $newTags))); 75 | } 76 | 77 | public static function updateFrequencyOnDelete($oldTags) 78 | { 79 | $oldTags = self::string2array($oldTags); 80 | self::removeTags($oldTags); 81 | } 82 | 83 | public static function addTags($tags) 84 | { 85 | 86 | BlogTag::updateAllCounters(['frequency' => 1], 'name in ("' . implode('"," ', $tags) . '")'); 87 | 88 | foreach ($tags as $name) { 89 | if (!BlogTag::findOne(['name' => $name,])) { 90 | $tag = new BlogTag; 91 | $tag->name = $name; 92 | $tag->frequency = 1; 93 | $tag->save(); 94 | } 95 | } 96 | } 97 | 98 | public static function removeTags($tags) 99 | { 100 | if (empty($tags)) { 101 | return; 102 | } 103 | 104 | BlogTag::updateAllCounters(['frequency' => 1], 'name in ("' . implode('"," ', $tags) . '")'); 105 | BlogTag::deleteAll('frequency <= 0'); 106 | } 107 | 108 | public static function findTagWeights($limit = 20) 109 | { 110 | $models = BlogTag::find()->orderBy(['frequency' => SORT_DESC])->all(); 111 | 112 | $total = 0; 113 | foreach ($models as $model) { 114 | $total += $model->frequency; 115 | } 116 | 117 | $tags = []; 118 | if ($total > 0) { 119 | foreach ($models as $model) { 120 | $tags[$model->name] = 8 + (int)(16 * $model->frequency / ($total + 10)); 121 | } 122 | ksort($tags); 123 | } 124 | return $tags; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /models/BlogTagSearch.php: -------------------------------------------------------------------------------- 1 | orderBy(['frequency' => SORT_DESC]); 50 | 51 | $dataProvider = new ActiveDataProvider([ 52 | 'query' => $query, 53 | ]); 54 | 55 | if (!($this->load($params) && $this->validate())) { 56 | return $dataProvider; 57 | } 58 | 59 | $query->andFilterWhere([ 60 | 'id' => $this->id, 61 | 'frequency' => $this->frequency, 62 | ]); 63 | 64 | $query->andFilterWhere(['like', 'name', $this->name]); 65 | 66 | return $dataProvider; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /models/BlogWidgetType.php: -------------------------------------------------------------------------------- 1 | getModule()->breadcrumbs; 34 | $result[] = [ 'label' => Module::t( '', 'Widget Types' ), 'url' => [ 'index' ] ]; 35 | 36 | return $result; 37 | } 38 | 39 | /** 40 | * Before Save change $config variable 41 | * From array to json string 42 | * 43 | * @param bool $insert 44 | * 45 | * @return bool 46 | */ 47 | public function beforeSave( $insert ) { 48 | $this->config = Json::encode( $this->config ); 49 | 50 | return parent::beforeSave( $insert ); 51 | } 52 | 53 | 54 | /** 55 | * After object initialize change 56 | * $config variable to decoded array 57 | */ 58 | public function afterFind() { 59 | $this->config = Json::decode( $this->config ); 60 | parent::afterFind(); 61 | } 62 | 63 | /** 64 | * @inheritdoc 65 | */ 66 | public function rules() { 67 | return [ 68 | [ [ 'title' ], 'required' ], 69 | [ [ 'title' ], 'string', 'max' => 191 ], 70 | [ [ 'config' ], 'safe' ], 71 | ]; 72 | } 73 | 74 | /** 75 | * @inheritdoc 76 | */ 77 | public function attributeLabels() { 78 | return [ 79 | 'id' => Module::t( '', 'ID' ), 80 | 'config' => Module::t( '', 'Config' ), 81 | 'title' => Module::t( '', 'Title' ), 82 | ]; 83 | } 84 | 85 | /** 86 | * @param $type_id 87 | * @param array $config 88 | * 89 | * @return string 90 | * @throws NotFoundHttpException 91 | */ 92 | public static function widget( $type_id, $config = [] ) { 93 | $type = self::findOne( $type_id ); 94 | 95 | if ( $type == null ) { 96 | throw new NotFoundHttpException( 'Widget Type not found' ); 97 | } 98 | 99 | $config = array_merge( $type->config, $config); 100 | 101 | return Feed::widget( $config ); 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /rbac/BlogAuthorRule.php: -------------------------------------------------------------------------------- 1 | user_id == $user : false; 24 | } 25 | } -------------------------------------------------------------------------------- /traits/ConfigTrait.php: -------------------------------------------------------------------------------- 1 | 'index', 25 | 'blog/default/view' => 'view', 26 | 'blog/default/archive' => 'archive', 27 | 'blog/default/book' => 'viewBook', 28 | 'blog/default/chapter' => 'viewChapter', 29 | 'blog/default/chapter-search' => 'searchBookChapter', 30 | ]; 31 | 32 | public $urlManager = 'urlManager'; 33 | 34 | public $imgFilePath = '@frontend/web/img/blog'; 35 | 36 | public $imgFileUrl = '/img/blog'; 37 | 38 | public $adminAccessControl = null; 39 | 40 | public $blogPostPageCount = 10; 41 | 42 | public $blogCommentPageCount = 20; 43 | 44 | public $enableComments = false; 45 | 46 | public $enableBooks = true; 47 | 48 | public $enableLocalComments = false; 49 | 50 | public $enableFacebookComments = true; 51 | 52 | public $showBannerInPost = false; 53 | 54 | public $showClicksInPost = true; 55 | 56 | public $showClicksInArchive = false; 57 | 58 | public $showDateInPost = true; 59 | 60 | public $dateTypeInPost = 'dateTime'; 61 | 62 | public $blogViewLayout = null; 63 | 64 | public $schemaOrg = []; 65 | 66 | public $addthisId = null; 67 | 68 | public $enableShareButtons = false; 69 | 70 | public $redactorModule = 'redactorBlog'; 71 | 72 | public $userModel;// = \common\models\User::class; 73 | 74 | public $userPK = 'id'; 75 | 76 | public $userName = 'username'; 77 | 78 | public $blogTheme; 79 | 80 | protected $_isBackend; 81 | 82 | public $homeTitle = 'Blog'; 83 | 84 | public $banners = []; 85 | 86 | public $htmlClass = "diazoxide_blog"; 87 | */ 88 | ]; 89 | 90 | public static function getConfigFormSchema(){ 91 | 92 | return [ 93 | 'controllerNamespace'=>[ 94 | 'title'=>Module::t('', 'Controller Namespace'), 95 | 'type'=>'string', 96 | ], 97 | 'backendViewPath'=>[ 98 | 'title'=>Module::t('', 'Backend View Path'), 99 | 'type'=>'string', 100 | ], 101 | 102 | ]; 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /traits/ModuleTrait.php: -------------------------------------------------------------------------------- 1 | getModule('blog'); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /traits/StatusTrait.php: -------------------------------------------------------------------------------- 1 | Module::t('', 'STATUS_INACTIVE'), 26 | IActiveStatus::STATUS_ACTIVE => Module::t('', 'STATUS_ACTIVE'), 27 | IActiveStatus::STATUS_ARCHIVE => Module::t('', 'STATUS_ARCHIVE') 28 | ]; 29 | } 30 | 31 | public function getStatusList2() 32 | { 33 | return self::getStatusList(); 34 | } 35 | 36 | public function getStatus($nullLabel = '') 37 | { 38 | $statuses = static::getStatusList(); 39 | return (isset($this->status) && isset($statuses[$this->status])) ? $statuses[$this->status] : $nullLabel; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /views/backend/blog-category/_form.php: -------------------------------------------------------------------------------- 1 | 20 | 21 |
22 | 23 | ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 25 | 'fieldConfig' => [ 26 | 'template' => "{label}\n
{input}{error}
", 27 | 'labelOptions' => ['class' => 'col-lg-2 control-label'], 28 | ], 29 | ]); ?> 30 | 31 | field($model, 'parent_id')->dropDownList(ArrayHelper::map(BlogCategory::find()->andWhere(['type_id'=>$model->type->id])->orWhere(['type_id'=>null])->all(),'id','title')) ?> 32 | 33 | field($model, 'title')->textInput(['maxlength' => 255]) ?> 34 | 35 | field($model, 'slug')->textInput(['maxlength' => 128]) ?> 36 | 37 | field($model, 'banner')->fileInput() ?> 38 | 39 | field($model, 'icon_class')->textInput(['maxlength' => 60]) ?> 40 | 41 | field($model, 'read_icon_class')->textInput(['maxlength' => 60]) ?> 42 | 43 | field($model, 'read_more_text')->textInput(['maxlength' => 60]) ?> 44 | 45 | field($model, 'is_nav')->dropDownList(BlogCategory::getArrayIsNav()) ?> 46 | 47 | field($model, 'is_featured')->dropDownList(BlogCategory::getArrayIsFeatured()) ?> 48 | 49 | field($model, 'widget_type_id')->dropDownList(ArrayHelper::map(\diazoxide\blog\models\BlogWidgetType::find()->all(), 'id', 'title'),['prompt'=>Module::t('', 'Select value')]) ?> 50 | 51 | field($model, 'page_size')->textInput() ?> 52 | 53 | field($model, 'template')->textInput(['maxlength' => 255]) ?> 54 | 55 | field($model, 'redirect_url')->textInput(['maxlength' => 255]) ?> 56 | 57 | field($model, 'status')->dropDownList(BlogCategory::getStatusList()) ?> 58 | 59 |
60 | 61 | isNewRecord ? Module::t('', 'Create') : Module::t('', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 62 |
63 | 64 | 65 | 66 |
67 | -------------------------------------------------------------------------------- /views/backend/blog-category/_search.php: -------------------------------------------------------------------------------- 1 | 16 | 17 | 58 | -------------------------------------------------------------------------------- /views/backend/blog-category/create.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Blog Category'); 14 | $this->params['breadcrumbs'] = $model->breadcrumbs; 15 | $this->params['breadcrumbs'][] = $this->title; 16 | ?> 17 | 18 |
19 | 20 | render('_form', [ 21 | 'model' => $model, 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/blog-category/index.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Blog Categories'); 11 | /** @var array $breadcrumbs */ 12 | $this->params['breadcrumbs'] = $breadcrumbs; 13 | $this->params['breadcrumbs'][] = $this->title; 14 | 15 | function renderItem($model) 16 | { 17 | foreach ($model as $key => $item) { 18 | 19 | echo Html::beginTag('li'); 20 | echo Html::a($item->title, $item->url) . ' '; 21 | 22 | echo Html::beginTag('span', ['class' => 'btn-group']); 23 | 24 | $menu = Html::beginTag('span', ['class' => 'btn-group-vertical']); 25 | $menu .= Html::a(' ' . Module::t('', 'View'), ['blog-category/view', 'id' => $item->id], ['class' => 'btn btn-default btn-xs', 'title' => Module::t('', 'View Category')]); 26 | $menu .= Html::a(' ' . Module::t('', 'Create subcategory'), ['blog-category/create', 'parent_id' => $item->id, 'type' => $item->type->name], ['class' => 'btn btn-success btn-xs', 'title' => Module::t('', 'Add Sub Category')]); 27 | $menu .= Html::a(' ' . Module::t('', 'Update'), ['blog-category/update', 'id' => $item->id], ['class' => 'btn btn-warning btn-xs', 'title' => Module::t('', 'Update Category')]); 28 | $menu .= Html::endTag('span'); 29 | 30 | echo Html::a('', null, [ 31 | 'title' => Module::t('', 'Options'), 32 | 'class' => 'btn btn-default btn-xs', 33 | 'tabindex' => $key, 34 | 'data' => [ 35 | 'html' => "true", 36 | 'toggle' => "popover", 37 | 'trigger' => "focus", 38 | 'content' => $menu, 39 | 'placement' => "bottom" 40 | ] 41 | ]); 42 | 43 | 44 | $menu = Html::beginTag('span', ['class' => 'btn-group-vertical']); 45 | $menu .= Html::a(' ' . Module::t('', 'Move up'), ['blog-category/reorder', 'id' => $item->id, 'action' => 'up'], ['class' => 'btn btn-default btn-xs', 'title' => Module::t('', 'Move up')]); 46 | $menu .= Html::a(' ' . Module::t('', 'Move down'), ['blog-category/reorder', 'id' => $item->id, 'action' => 'down'], ['class' => 'btn btn-default btn-xs', 'title' => Module::t('', 'Move up')]); 47 | $menu .= Html::a(' ' . Module::t('', 'Make first'), ['blog-category/reorder', 'id' => $item->id, 'action' => 'first'], ['class' => 'btn btn-default btn-xs', 'title' => Module::t('', 'Move up')]); 48 | $menu .= Html::a(' ' . Module::t('', 'Make last'), ['blog-category/reorder', 'id' => $item->id, 'action' => 'last'], ['class' => 'btn btn-default btn-xs', 'title' => Module::t('', 'Move up')]); 49 | $menu .= Html::endTag('span'); 50 | 51 | echo Html::a('', null, [ 52 | 'title' => Module::t('', 'Sorting'), 53 | 'class' => 'btn btn-default btn-xs', 54 | 'tabindex' => $key, 55 | 'data' => [ 56 | 'html' => "true", 57 | 'toggle' => "popover", 58 | 'trigger' => "focus", 59 | 'content' => $menu, 60 | 'placement' => "bottom" 61 | ] 62 | ]); 63 | 64 | echo Html::a(' ' . Module::t('', 'Delete'), ['blog-category/delete', 'id' => $item->id], ['class' => 'btn btn-danger btn-xs', 'title' => Module::t('', 'Delete Category'), 'data-confirm' => Module::t('', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => 0]); 65 | 66 | 67 | echo Html::endTag('span'); 68 | 69 | 70 | if ($item->children) { 71 | echo Html::beginTag('ul'); 72 | renderItem($item->children); 73 | echo Html::endTag('ul'); 74 | echo Html::endTag('li'); 75 | } 76 | 77 | echo Html::endTag('li'); 78 | 79 | 80 | } 81 | } 82 | 83 | ?> 84 |
85 | 86 |

87 | $type->name], ['class' => 'btn btn-success']) ?> 89 |

90 | 91 |
    92 | 95 |
96 | 97 |
98 | 99 | registerJs(<< 107 | -------------------------------------------------------------------------------- /views/backend/blog-category/update.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Blog Category') . ' ' . $model->title; 14 | $this->params['breadcrumbs'] = $model->breadcrumbs; 15 | $this->params['breadcrumbs'][] = $model->title; 16 | ?> 17 |
18 | 19 | render('_form', [ 20 | 'model' => $model, 21 | ]) ?> 22 | 23 |
24 | -------------------------------------------------------------------------------- /views/backend/blog-category/view.php: -------------------------------------------------------------------------------- 1 | title = $model->title; 16 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Categorys'), 'url' => ['index']]; 17 | $this->params['breadcrumbs'][] = $this->title; 18 | ?> 19 |
20 | 21 |

22 | $model->id], ['class' => 'btn btn-primary']) ?> 23 | $model->id], [ 24 | 'class' => 'btn btn-danger', 25 | 'data' => [ 26 | 'confirm' => Module::t('', 'Are you sure you want to delete this item?'), 27 | 'method' => 'post', 28 | ], 29 | ]) ?> 30 |

31 | 32 | $model, 34 | 'attributes' => [ 35 | 'id', 36 | [ 37 | 'attribute' => 'parent_id', 38 | 'value' => $model->parent_id ? $model->parent->title : Module::t('', 'Root Category'), 39 | ], 40 | 'title', 41 | 'slug', 42 | 'banner', 43 | [ 44 | 'attribute' => 'is_nav', 45 | 'value' => $model->isNavLabel, 46 | ], 47 | 'sort_order', 48 | 'page_size', 49 | 'template', 50 | 'redirect_url:url', 51 | [ 52 | 'attribute' => 'status', 53 | 'value' => $model->getStatus(), 54 | ], 55 | 'created_at:datetime', 56 | 'updated_at:datetime', 57 | ], 58 | ]) ?> 59 | 60 |
61 | -------------------------------------------------------------------------------- /views/backend/blog-comment/_form.php: -------------------------------------------------------------------------------- 1 | 18 | 19 |
20 | 21 | 22 | 23 | field($model, 'post_id')->dropDownList(ArrayHelper::map(BlogPost::find()->all(), 'id', 'title')) ?> 24 | 25 | field($model, 'content')->textarea(['rows' => 6]) ?> 26 | 27 | field($model, 'author')->textInput(['maxlength' => 128]) ?> 28 | 29 | field($model, 'email')->textInput(['maxlength' => 128]) ?> 30 | 31 | field($model, 'url')->textInput(['maxlength' => 128]) ?> 32 | 33 | field($model, 'status')->dropDownList(BlogPost::getStatusList()) ?> 34 | 35 |
36 | isNewRecord ? Module::t('', 'Create') : Module::t('', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 37 |
38 | 39 | 40 | 41 |
42 | -------------------------------------------------------------------------------- /views/backend/blog-comment/_search.php: -------------------------------------------------------------------------------- 1 | 16 | 17 | 50 | -------------------------------------------------------------------------------- /views/backend/blog-comment/create.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Blog Comment'); 15 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Comments'), 'url' => ['index']]; 16 | $this->params['breadcrumbs'][] = $this->title; 17 | ?> 18 |
19 | 20 | render('_form', [ 21 | 'model' => $model, 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/blog-comment/index.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Blog Comments'); 18 | $this->params['breadcrumbs'][] = $this->title; 19 | ?> 20 |
21 | 22 | render('_search', ['model' => $searchModel]); ?> 23 | 24 |

25 | 'btn btn-success']) ?> 26 |

27 | 28 | $dataProvider, 30 | 'filterModel' => $searchModel, 31 | 'columns' => [ 32 | ['class' => 'yii\grid\CheckboxColumn'], 33 | 34 | [ 35 | 'attribute' => 'post_id', 36 | 'value' => function ($model) { 37 | return mb_substr($model->post->title, 0, 15, 'utf-8') . '...'; 38 | }, 39 | /*'filter' => Html::activeDropDownList( 40 | $searchModel, 41 | 'post_id', 42 | \diazoxide\blog\models\BlogPost::getArrayCategory(), 43 | ['class' => 'form-control', 'prompt' => Module::t('blog', 'Please Filter')] 44 | )*/ 45 | ], 46 | [ 47 | 'attribute' => 'content', 48 | 'value' => function ($model) { 49 | return mb_substr(Yii::$app->formatter->asText($model->content), 0, 30, 'utf-8') . '...'; 50 | }, 51 | ], 52 | 'author', 53 | 'email:email', 54 | // 'url:url', 55 | [ 56 | 'attribute' => 'status', 57 | 'format' => 'html', 58 | 'value' => function ($model) { 59 | if ($model->status === \diazoxide\blog\traits\IActiveStatus::STATUS_ACTIVE) { 60 | $class = 'label-success'; 61 | } elseif ($model->status === \diazoxide\blog\traits\IActiveStatus::STATUS_INACTIVE) { 62 | $class = 'label-warning'; 63 | } else { 64 | $class = 'label-danger'; 65 | } 66 | 67 | return '' . $model->getStatus() . ''; 68 | }, 69 | 'filter' => Html::activeDropDownList( 70 | $searchModel, 71 | 'status', 72 | \diazoxide\blog\models\BlogPost::getStatusList(), 73 | ['class' => 'form-control', 'prompt' => Module::t('', 'PROMPT_STATUS')] 74 | ) 75 | ], 76 | 77 | 'created_at:date', 78 | // 'update_time', 79 | 80 | ['class' => 'yii\grid\ActionColumn'], 81 | ], 82 | ]); ?> 83 |
84 |
85 |
86 | 'Choose', 89 | 'c' => Module::t('', 'Confirm'), 90 | 'd' => Module::t('', 'Delete') 91 | ], ['class' => 'form-control dropdown',]) ?> 92 |
93 |
94 | 'btn btn-info',]); ?> 95 |
96 |
97 | 98 | 99 |
100 | -------------------------------------------------------------------------------- /views/backend/blog-comment/update.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Blog Comment') . ' ' . $model->id; 14 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Comments'), 'url' => ['index']]; 15 | $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; 16 | $this->params['breadcrumbs'][] = Module::t('', 'Update'); 17 | ?> 18 |
19 | 20 | render('_form', [ 21 | 'model' => $model, 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/blog-comment/view.php: -------------------------------------------------------------------------------- 1 | title = $model->id; 16 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Comments'), 'url' => ['index']]; 17 | $this->params['breadcrumbs'][] = $this->title; 18 | ?> 19 |
20 | 21 |

22 | $model->id], ['class' => 'btn btn-primary']) ?> 23 | $model->id], [ 24 | 'class' => 'btn btn-danger', 25 | 'data' => [ 26 | 'confirm' => Module::t('', 'Are you sure you want to delete this item?'), 27 | 'method' => 'post', 28 | ], 29 | ]) ?> 30 |

31 | 32 | $model, 34 | 'attributes' => [ 35 | 'id', 36 | [ 37 | 'attribute' => 'post_id', 38 | 'value' => $model->post->title, 39 | ], 40 | 'content:ntext', 41 | 'author', 42 | 'email:email', 43 | 'url:url', 44 | [ 45 | 'attribute' => 'status', 46 | 'value' => $model->getStatus(), 47 | ], 48 | 'created_at:datetime', 49 | 'updated_at:datetime', 50 | ], 51 | ]) ?> 52 | 53 |
54 | -------------------------------------------------------------------------------- /views/backend/blog-post/_book_chapter_form.php: -------------------------------------------------------------------------------- 1 | 19 | 20 |
21 | 22 | 23 | ['enctype' => 'multipart/form-data'], 25 | ]); ?> 26 | 27 | errorSummary($model); ?> 28 | 29 |
30 |
31 | isNewRecord ? Module::t('', 'Create') : Module::t('', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-warning']) ?> 32 |
33 |
34 | 35 | 36 |
37 |
38 | 39 | field($model, 'title')->textInput(['maxlength' => 128]) ?> 40 | 41 | field($model, 'keywords')->textInput(['maxlength' => 255]) ?> 42 | 43 | field($model, 'brief')->textarea(['rows' => 4]) ?> 44 | 45 | isBBcode()) { 48 | echo $form->field($model, 'content')->textarea(['rows' => 10]); 49 | 50 | } else { 51 | echo $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::class, [ 52 | 'moduleId' => $model->module->redactorModule, 53 | 'clientOptions' => [ 54 | 'plugins' => ['clips', 'fontcolor', 'imagemanager'] 55 | ] 56 | ]); 57 | } ?> 58 | 59 |
60 | 61 |
62 | 63 | field($model, 'bbcode')->dropDownList([0 => 'Disabled', 1 => 'Enabled'], ['prompt' => "Select"]) ?> 64 | 65 | 66 |
67 |
68 | getThumbFileUrl('banner', 'sthumb'), ['class' => 'img-responsive']) ?> 69 |
70 |
71 | field($model, 'banner')->fileInput() ?> 72 |
73 |
74 | 75 |
76 |
77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /views/backend/blog-post/_book_form.php: -------------------------------------------------------------------------------- 1 | 19 | 20 |
21 | 22 | 23 | [ 25 | 'enctype' => 'multipart/form-data'], 26 | ]); ?> 27 | 28 | errorSummary($model); ?> 29 | 30 |
31 |
32 | isNewRecord ? Module::t('', 'Create') : Module::t('', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-warning']) ?> 33 |
34 |
35 | 36 | 37 |
38 |
39 | 40 | field($model, 'title')->textInput(['maxlength' => 128]) ?> 41 | 42 | field($model, 'slug')->textInput(['maxlength' => 128, 'class' => 'form-control input-sm', 'readonly' => true, 'onclick' => "this.removeAttribute('readonly')"]) ?> 43 | 44 | field($model, 'brief')->textarea(['rows' => 4]) ?> 45 | 46 |
47 | 48 |
49 | 50 | field($model, 'bbcode')->dropDownList([0 => 'Disabled', 1 => 'Enabled'], ['prompt' => "Select"]) ?> 51 | 52 |
53 |
54 | getThumbFileUrl('banner', 'sthumb'), ['class' => 'img-responsive']) ?> 55 |
56 |
57 | field($model, 'banner')->fileInput() ?> 58 |
59 |
60 | 61 | field($model, 'status')->dropDownList(\diazoxide\blog\models\BlogPost::getStatusList()) ?> 62 | 63 |
64 |
65 | 66 | 67 | 68 | 69 |
70 | -------------------------------------------------------------------------------- /views/backend/blog-post/_search.php: -------------------------------------------------------------------------------- 1 | 16 | 17 |
18 | 19 | ['index'], 21 | 'method' => 'get', 22 | ]); ?> 23 | 24 | field($model, 'id') ?> 25 | 26 | field($model, 'category_id') ?> 27 | 28 | field($model, 'title') ?> 29 | 30 | field($model, 'content') ?> 31 | 32 | field($model, 'tags') ?> 33 | 34 | field($model, 'slug') ?> 35 | 36 | field($model, 'click') ?> 37 | 38 | field($model, 'user_id') ?> 39 | 40 | field($model, 'status') ?> 41 | 42 | field($model, 'create_time') ?> 43 | 44 | field($model, 'update_time') ?> 45 | 46 |
47 | 'btn btn-primary']) ?> 48 | 'btn btn-default']) ?> 49 |
50 | 51 | 52 | 53 |
54 | -------------------------------------------------------------------------------- /views/backend/blog-post/create.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Blog Post'); 15 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Posts'), 'url' => ['index']]; 16 | $this->params['breadcrumbs'][] = $this->title; 17 | ?> 18 |
19 | 20 | render('_form', [ 22 | 'model' => $model, 23 | 'type'=>$type 24 | ]) ?> 25 | 26 |
27 | -------------------------------------------------------------------------------- /views/backend/blog-post/createBook.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create '); 13 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Posts'), 'url' => ['index']]; 14 | $this->params['breadcrumbs'][] = ['label' => $model->post->title, 'url' => ['update', 'id' => $model->post_id]]; 15 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Books')]; 16 | $this->params['breadcrumbs'][] = $this->title; 17 | ?> 18 |
19 | 20 | render('_book_form', [ 21 | 'model' => $model, 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/blog-post/createBookChapter.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Chapter'); 13 | $this->params['breadcrumbs'] = $model->breadcrumbs; 14 | $this->params['breadcrumbs'][] = $this->title; 15 | ?> 16 |
17 | 18 | render('_book_chapter_form', [ 19 | 'model' => $model, 20 | ]) ?> 21 | 22 |
23 | -------------------------------------------------------------------------------- /views/backend/blog-post/index.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Blog Posts'); 19 | /** @var array $breadcrumbs */ 20 | $this->params['breadcrumbs'] = $breadcrumbs; 21 | $this->params['breadcrumbs'][] = $this->title; 22 | ?> 23 |
24 | 25 | render('_search', ['model' => $searchModel]); ?> 26 | 27 |

28 | $type->name], ['class' => 'btn btn-success']) ?> 30 |

31 | 32 | 33 | 'yii\grid\CheckboxColumn'], 37 | ]; 38 | if ($type->has_banner) { 39 | $columns[] = [ 40 | 'attribute' => 'banner', 41 | 'value' => function ($model) { 42 | return Html::img($model->getThumbFileUrl('banner', 'xsthumb')); 43 | }, 44 | 'format' => 'raw', 45 | 'filter' => false 46 | ]; 47 | } 48 | $columns[] = [ 49 | 'format' => 'raw', 50 | 'attribute' => 'title', 51 | 'value' => function ($model) { 52 | return Html::a(\yii\helpers\StringHelper::truncate(Html::encode($model->title), 100, "..."), $model->url); 53 | } 54 | ]; 55 | 56 | if ($type->has_category) { 57 | $columns[] = [ 58 | 'format' => 'raw', 59 | 'attribute' => 'category_id', 60 | 'value' => function ($model) use ($searchModel) { 61 | return Html::a(\yii\helpers\StringHelper::truncate(Html::encode($model->category->title), 50, "..."), 62 | ['', $searchModel->formName() => ['category_id' => $model->category->id]] 63 | ); 64 | }, 65 | 'filter' => Html::activeDropDownList( 66 | $searchModel, 67 | 'category_id', 68 | BlogPost::getArrayCategory(), 69 | ['class' => 'form-control', 'prompt' => Module::t('', 'Please Filter')] 70 | ) 71 | ]; 72 | } 73 | $columns[] = 'click'; 74 | 75 | if ($type->has_comment) { 76 | $columns[] = 'commentsCount'; 77 | } 78 | $columns[] = [ 79 | 'attribute' => 'status', 80 | 'format' => 'html', 81 | 'value' => function ($model) { 82 | if ($model->status === IActiveStatus::STATUS_ACTIVE) { 83 | $class = 'label-success'; 84 | } elseif ($model->status === IActiveStatus::STATUS_INACTIVE) { 85 | $class = 'label-warning'; 86 | } else { 87 | $class = 'label-danger'; 88 | } 89 | 90 | return '' . $model->getStatus() . ''; 91 | }, 92 | 'filter' => Html::activeDropDownList( 93 | $searchModel, 94 | 'status', 95 | BlogPost::getStatusList(), 96 | ['class' => 'form-control', 'prompt' => Module::t('', 'PROMPT_STATUS')] 97 | ) 98 | ]; 99 | 100 | $columns[] = 'published_at:relativeTime'; 101 | $columns[] = 'created_at:dateTime'; 102 | $columns[] = 'updated_at:dateTime'; 103 | $columns[] = ['class' => 'yii\grid\ActionColumn']; 104 | echo GridView::widget([ 105 | 'dataProvider' => $dataProvider, 106 | 'filterModel' => $searchModel, 107 | 'columns' => $columns, 108 | ]); ?> 109 | 110 | 111 |
112 | -------------------------------------------------------------------------------- /views/backend/blog-post/update.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Blog Post') . ' ' . $model->title; 18 | $this->params['breadcrumbs'] = $model->breadcrumbs; 19 | $this->params['breadcrumbs'][] = ['label' => $model->title]; 20 | ?> 21 |
22 | 23 | render('_form', [ 24 | 'model' => $model, 25 | 'type' => $model->type 26 | ]) ?> 27 | 28 | type->has_book) : ?> 29 | 30 |
31 |

32 |
33 | $model->id], ['class' => 'btn btn-default']) ?> 34 |
35 | $bookDataProvider, 39 | 'columns' => [ 40 | ['class' => 'yii\grid\SerialColumn'], 41 | [ 42 | 'attribute' => "banner", 43 | 'format' => 'raw', 44 | 'value' => function ($model) { 45 | /** @var \diazoxide\blog\models\BlogPostBook $model */ 46 | return Html::img($model->getThumbFileUrl('banner', "xsthumb")); 47 | } 48 | ], 49 | 'title', 50 | 'brief', 51 | [ 52 | 'attribute' => 'status', 53 | 'format' => 'html', 54 | 'value' => 55 | function ($model) { 56 | /** @var \diazoxide\blog\models\BlogPost $model */ 57 | if ($model->status === IActiveStatus::STATUS_ACTIVE) { 58 | $class = 'label-success'; 59 | } elseif ($model->status === IActiveStatus::STATUS_INACTIVE) { 60 | $class = 'label-warning'; 61 | } else { 62 | $class = 'label-danger'; 63 | } 64 | 65 | return '' . $model->getStatus() . ''; 66 | }, 67 | ], 68 | [ 69 | 'class' => 'yii\grid\ActionColumn', 70 | 'header' => 'Actions', 71 | 'headerOptions' => ['style' => 'color:#337ab7'], 72 | 'template' => '{update} {delete}', 73 | 'urlCreator' => function ($action, $model, $key, $index) { 74 | if ($action === 'update') { 75 | return Url::toRoute(['update-book', 'id' => $model->id]); 76 | 77 | } 78 | if ($action === 'delete') { 79 | return Url::toRoute(['delete-book', 'id' => $model->id]); 80 | 81 | } 82 | return true; 83 | } 84 | ], 85 | 86 | ], 87 | ]); 88 | ?> 89 |
90 | 91 | 92 | 93 |
94 | 95 | 96 | -------------------------------------------------------------------------------- /views/backend/blog-post/updateBook.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Blog Post Book') . ' ' . $model->title; 18 | $this->params['breadcrumbs'] = $model->breadcrumbs; 19 | ?> 20 |
21 | 22 | render('_book_form', [ 24 | 'model' => $model, 25 | ]) ?> 26 | 27 |
28 | 29 |

30 | 31 |
32 | $model->id], ['class' => 'btn btn-default']) ?> 33 |
34 | 35 | $model->getChapters()->andWhere(['parent_id' => null]), 38 | 'pagination' => [ 39 | 'pageSize' => 20, 40 | 'pageParam' => 'chapter_page', 41 | 'pageSizeParam' => 'chapter_page_size', 42 | ], 43 | 'sort' => [ 44 | 'sortParam' => 'chapter_sort' 45 | ] 46 | ]); 47 | 48 | /** @var \yii\debug\models\timeline\DataProvider $bookDataProvider */ 49 | echo GridView::widget([ 50 | 'dataProvider' => $chaptersDataProvider, 51 | 'columns' => [ 52 | ['class' => 'yii\grid\SerialColumn'], 53 | [ 54 | 'attribute' => "banner", 55 | 'format' => 'raw', 56 | 'value' => function ($model) { 57 | /** @var \diazoxide\blog\models\BlogPostBook $model */ 58 | return Html::img($model->getThumbFileUrl('banner', "xsthumb")); 59 | } 60 | ], 61 | 'title', 62 | 'brief', 63 | [ 64 | 'class' => 'yii\grid\ActionColumn', 65 | 'header' => 'Actions', 66 | 'headerOptions' => ['style' => 'color:#337ab7'], 67 | 'template' => '{update}{delete}', 68 | 'urlCreator' => function ($action, $model, $key, $index) { 69 | if ($action === 'update') { 70 | return Url::toRoute(['update-book-chapter', 'id' => $model->id]); 71 | 72 | } 73 | if ($action === 'delete') { 74 | return Url::toRoute(['delete-book-chapter', 'id' => $model->id]); 75 | 76 | } 77 | } 78 | ], 79 | 80 | ], 81 | ]); 82 | ?> 83 |
84 | 85 |
86 | -------------------------------------------------------------------------------- /views/backend/blog-post/updateBookChapter.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Chapter') . ' ' . $model->title; 17 | $this->params['breadcrumbs'] = $model->breadcrumbs; 18 | $this->params['breadcrumbs'][] = ['label' => $model->title]; 19 | ?> 20 |
21 | 22 | render('_book_chapter_form', [ 23 | 'model' => $model, 24 | ]) ?> 25 | 26 |
27 |
28 | $model->book_id, 'parent_id' => $model->id], ['class' => 'btn btn-default']) ?> 29 |
30 | $model->getChapters(), 33 | 'pagination' => [ 34 | 'pageSize' => 20, 35 | 'pageParam' => 'chapter_page', 36 | 'pageSizeParam' => 'chapter_page_size', 37 | ], 38 | 'sort' => [ 39 | 'sortParam' => 'chapter_sort' 40 | ] 41 | ]); 42 | 43 | /** @var \yii\debug\models\timeline\DataProvider $bookDataProvider */ 44 | echo GridView::widget([ 45 | 'dataProvider' => $chaptersDataProvider, 46 | 'columns' => [ 47 | ['class' => 'yii\grid\SerialColumn'], 48 | [ 49 | 'attribute' => "banner", 50 | 'format' => 'raw', 51 | 'value' => function ($model) { 52 | /** @var \diazoxide\blog\models\BlogPostBook $model */ 53 | return Html::img($model->getThumbFileUrl('banner', "xsthumb")); 54 | } 55 | ], 56 | 'title', 57 | 'brief', 58 | [ 59 | 'class' => 'yii\grid\ActionColumn', 60 | 'header' => 'Actions', 61 | 'headerOptions' => ['style' => 'color:#337ab7'], 62 | 'template' => '{update}{delete}', 63 | 'urlCreator' => function ($action, $model, $key, $index) { 64 | if ($action === 'update') { 65 | return Url::toRoute(['update-book-chapter', 'id' => $model->id]); 66 | 67 | } 68 | if ($action === 'delete') { 69 | return Url::toRoute(['delete-book-chapter', 'id' => $model->id]); 70 | 71 | } 72 | } 73 | ], 74 | 75 | ], 76 | ]); 77 | ?> 78 |
79 | 80 |
81 | -------------------------------------------------------------------------------- /views/backend/blog-post/view.php: -------------------------------------------------------------------------------- 1 | title = $model->title; 16 | $this->params['breadcrumbs'] = $model->breadcrumbs; 17 | $this->params['breadcrumbs'][] = $this->title; 18 | ?> 19 |
20 | 21 |

22 | $model->id], ['class' => 'btn btn-primary']) ?> 23 | $model->id], [ 24 | 'class' => 'btn btn-danger', 25 | 'data' => [ 26 | 'confirm' => Module::t('', 'Are you sure you want to delete this item?'), 27 | 'method' => 'post', 28 | ], 29 | ]) ?> 30 |

31 | 32 | $model, 34 | 'attributes' => [ 35 | 'id', 36 | [ 37 | 'attribute' => 'category_id', 38 | 'value' => $model->category->title, 39 | ], 40 | 'title', 41 | 'brief:ntext', 42 | 'content:html', 43 | 'tags', 44 | 'slug', 45 | [ 46 | 'attribute' => 'banner', 47 | 'value' => $model->getThumbFileUrl('banner', 'thumb'), 48 | ], 49 | 'click', 50 | [ 51 | 'attribute' => 'user', 52 | 'value' => ($model->user) ? $model->user->{Module::getInstance()->userName} : 'Отсутствует', 53 | ], 54 | [ 55 | 'attribute' => 'status', 56 | 'value' => $model->getStatus(), 57 | ], 58 | 'created_at:datetime', 59 | 'updated_at:datetime', 60 | ], 61 | ]) ?> 62 | 63 |
64 | -------------------------------------------------------------------------------- /views/backend/blog-tag/_form.php: -------------------------------------------------------------------------------- 1 | 16 | 17 |
18 | 19 | 20 | 21 | field($model, 'name')->textInput(['maxlength' => 128]) ?> 22 | 23 | field($model, 'frequency')->textInput(['maxlength' => 10]) ?> 24 | 25 |
26 | isNewRecord ? Module::t('', 'Create') : Module::t('', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 27 |
28 | 29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /views/backend/blog-tag/_search.php: -------------------------------------------------------------------------------- 1 | 16 | 17 | 38 | -------------------------------------------------------------------------------- /views/backend/blog-tag/create.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Blog Tag'); 15 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Tags'), 'url' => ['index']]; 16 | $this->params['breadcrumbs'][] = $this->title; 17 | ?> 18 |
19 | 20 | render('_form', [ 21 | 'model' => $model, 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/blog-tag/index.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Blog Tags'); 17 | $this->params['breadcrumbs'][] = $this->title; 18 | ?> 19 |
20 | 21 | render('_search', ['model' => $searchModel]); ?> 22 | 23 |

24 | 'btn btn-success']) ?> 25 |

26 | 27 | $dataProvider, 29 | 'filterModel' => $searchModel, 30 | 'columns' => [ 31 | ['class' => 'yii\grid\CheckboxColumn'], 32 | 33 | 'id', 34 | 'name', 35 | 'frequency', 36 | 37 | ['class' => 'yii\grid\ActionColumn'], 38 | ], 39 | ]); ?> 40 | 41 |
42 | -------------------------------------------------------------------------------- /views/backend/blog-tag/update.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Blog Tag') . ' ' . $model->name; 14 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Tags'), 'url' => ['index']]; 15 | $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; 16 | $this->params['breadcrumbs'][] = Module::t('', 'Update'); 17 | ?> 18 |
19 | 20 | render('_form', [ 21 | 'model' => $model, 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/blog-tag/view.php: -------------------------------------------------------------------------------- 1 | title = $model->name; 16 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Tags'), 'url' => ['index']]; 17 | $this->params['breadcrumbs'][] = $this->title; 18 | ?> 19 |
20 | 21 |

22 | $model->id], ['class' => 'btn btn-primary']) ?> 23 | $model->id], [ 24 | 'class' => 'btn btn-danger', 25 | 'data' => [ 26 | 'confirm' => Module::t('', 'Are you sure you want to delete this item?'), 27 | 'method' => 'post', 28 | ], 29 | ]) ?> 30 |

31 | 32 | $model, 34 | 'attributes' => [ 35 | 'id', 36 | 'name', 37 | 'frequency', 38 | ], 39 | ]) ?> 40 | 41 |
42 | -------------------------------------------------------------------------------- /views/backend/default/index.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', "Blog"); 6 | $this->params['breadcrumbs'][] = $this->title; 7 | ?> 8 |
9 | limit(10)->orderBy(['id' => SORT_DESC]); 11 | echo Html::a(' ' . Module::t('', 'Blog Posts') . ' (' . $model->count() . ')', ['/blog/blog-post']); 12 | ?> 13 |
14 | 20, 16 | 'show_item_brief' => false, 17 | 'show_title' => false, 18 | 'item_brief_length' => 50, 19 | 'infinite_scroll' => true, 20 | 'id' => 'home_feed_widget', 21 | 'item_image_type' => 'xsthumb', 22 | 'item_title_length' => 70, 23 | 'list_options' => ['style' => 'height:50vh; overflow:auto;'], 24 | 'title_options' => ['class' => 'widget_title'], 25 | 'show_item_category'=>true, 26 | 'item_title_options' => ['class' => 'top-buffer-10-xs'], 27 | 'item_info_container_options' => ['class' => 'text-right text-warning small'], 28 | 'item_image_container_options' => ['class' => 'col-xs-2 left-padding-0-xs right-padding-10-xs'], 29 | 'item_content_container_options' => ['class' => 'col-xs-10 nospaces-xs'], 30 | 'item_options' => ['tag' => 'article', 'class' => 'item col-xs-12 top-buffer-10-xs left-padding-0-xs right-padding-10-xs'], 31 | ]); 32 | ?> 33 |
34 |
35 | 'btn btn-warning']); ?> 36 |
37 |
38 | 39 |
40 | limit(10)->orderBy(['sort_order' => SORT_DESC]); 42 | echo Html::a(' ' . Module::t('', 'Blog Categories') . ' (' . $model->count() . ')', ['/blog/blog-post']); 43 | ?> 44 |
    45 | all() as $item) { 48 | echo Html::tag( 49 | 'li', Html::a($item->titleWithIcon, $item->url), 50 | ['class' => ''] 51 | ); 52 | } 53 | ?> 54 |
55 | 'btn btn-warning']); ?> 56 | 57 |
58 |
59 | 60 | 61 |
62 |
63 | 64 | 65 |
66 | -------------------------------------------------------------------------------- /views/backend/default/thumbnails.php: -------------------------------------------------------------------------------- 1 | title = \diazoxide\blog\Module::t(null, 'Regenerate Thumbnails'); 13 | ?> 14 |
15 |

16 |

17 | 18 |
19 | 'btn btn-danger', 'id' => 'start-regeneration']) ?> 20 |
21 | 22 | 23 | 24 | 25 | registerJs($js); 59 | ?> 60 |
61 | 62 | -------------------------------------------------------------------------------- /views/backend/importer/csv.php: -------------------------------------------------------------------------------- 1 | 19 | 20 |
21 | 22 |

23 | 24 |
25 | 27 | 'get', 29 | 'options' => ['enctype' => 'multipart/form-data'], 30 | ]); ?> 31 | errorSummary($csv); ?> 33 |
34 |
35 | field($csv, 'unique_key')->textInput(['maxlength' => 16])->hint(Module::t('', 'Required field, for next overwrite.')) ?> 36 | field($csv, 'url')->textInput(['maxlength' => 255]) ?> 37 | field($csv, 'enclosure')->textInput(['maxLength'=>16]) ?> 38 | field($csv, 'delimiter')->textInput(['maxLength'=>16]) ?> 39 | field($csv, 'fields')->textarea(['rows' => 3])->hint(Module::t('', 'Comma separated fields name in order.')) ?> 40 | field($csv, 'per_page')->textInput(['type' => 'number']) ?> 41 | field($csv, 'page')->textInput(['type' => 'number']) ?> 42 | field($csv, 'import_categories')->checkbox() ?> 43 | field($csv, 'overwrite')->checkbox() ?> 44 | field($csv, 'localize_content')->checkbox() ?> 45 | field($csv, 'post_type_id')->dropDownList(ArrayHelper::map(BlogPostType::find()->all(), 'id', 'name'), ['prompt' => Module::t('', 'Select Post Type')]) ?> 46 | 'btn btn-warning']) ?> 47 |
48 |
49 | 50 | 51 | 52 | 53 |

54 | 55 | 56 | 57 |

Total: total ?>

58 |

Pages: total_pages ?>

59 |

Per page: per_page ?>

60 |

Current page: page ?>

61 | 62 | page * 100 / $csv->total_pages); 64 | $this->title = $percent . '% ' . Module::t('', 'Post import in progress'); 65 | echo yii\bootstrap\Progress::widget([ 66 | 'percent' => $percent, 67 | 'barOptions' => ['class' => 'progress-bar-danger'], 68 | 'options' => ['class' => 'active progress-striped'], 69 | 'label' => $percent . '%', 70 | 71 | ]); 72 | ?> 73 | 74 |
75 |
-------------------------------------------------------------------------------- /views/backend/importer/index.php: -------------------------------------------------------------------------------- 1 | 12 | 13 |
14 | 15 |

16 | 17 |
18 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /views/backend/importer/wordpress.php: -------------------------------------------------------------------------------- 1 | 19 | 20 |
21 | 22 |

23 | 24 | 25 |
26 | 28 | 'get', 30 | 'options' => ['enctype' => 'multipart/form-data'], 31 | ]); ?> 32 | errorSummary($wordpress); ?> 34 |
35 |
36 | field($wordpress, 'url')->textInput(['maxlength' => 255]) ?> 37 | field($wordpress, 'per_page')->textInput(['type' => 'number']) ?> 38 | field($wordpress, 'page')->textInput(['type' => 'number']) ?> 39 | field($wordpress, 'import_categories')->checkbox() ?> 40 | field($wordpress, 'overwrite')->checkbox() ?> 41 | field($wordpress, 'localize_content')->checkbox() ?> 42 | field($wordpress, 'post_type_id')->dropDownList(ArrayHelper::map(BlogPostType::find()->all(), 'id', 'name'), ['prompt' => Module::t('', 'Select Post Type')]) ?> 43 | 'btn btn-warning']) ?> 44 |
45 |
46 | 47 | 48 | 49 | 50 |

51 | 52 | 53 | 54 |

Total: total ?>

55 |

Pages: total_pages ?>

56 |

Per page: per_page ?>

57 |

Current page: page ?>

58 | 59 | page * 100 / $wordpress->total_pages); 61 | $this->title = $percent.'% '.Module::t('','Post import in progress'); 62 | echo yii\bootstrap\Progress::widget([ 63 | 'percent' => $percent, 64 | 'barOptions' => ['class' => 'progress-bar-danger'], 65 | 'options' => ['class' => 'active progress-striped'], 66 | 'label' => $percent . '%', 67 | 68 | ]); 69 | ?> 70 | 71 |
72 |
-------------------------------------------------------------------------------- /views/backend/post-type/_form.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 28 | 29 |
30 | 31 |
32 | 'post', 34 | 'options' => ['enctype' => 'multipart/form-data'], 35 | ]); ?> 36 | errorSummary($model); ?> 38 |
39 |
40 | field($model, 'title')->textInput(['maxlength' => 255]) ?> 41 | field($model, 'name')->textInput(['maxlength' => 64]) ?> 42 | field($model, 'layout')->textInput(['maxlength' => 255]) ?> 43 | field($model, 'single_pattern')->widget(trntv\aceeditor\AceEditor::class, ['mode' => 'html', 'theme' => 'github']);?> 44 | field($model, 'archive_pattern')->widget(trntv\aceeditor\AceEditor::class, ['mode' => 'html', 'theme' => 'github']);?> 45 | field($model, 'default_pattern')->widget(trntv\aceeditor\AceEditor::class, ['mode' => 'html', 'theme' => 'github']);?> 46 | field($model, 'url_pattern')->textInput(['maxlength' => 255]) ?> 47 | field($model, 'has_title')->checkbox() ?> 48 | field($model, 'has_content')->checkbox() ?> 49 | field($model, 'has_category')->checkbox() ?> 50 | field($model, 'has_brief')->checkbox() ?> 51 | field($model, 'has_comment')->checkbox() ?> 52 | field($model, 'has_banner')->checkbox() ?> 53 | field($model, 'has_book')->checkbox() ?> 54 | field($model, 'has_tag')->checkbox() ?> 55 | 'btn btn-warning']) ?> 56 |
57 |
58 | 59 |
60 |
61 | -------------------------------------------------------------------------------- /views/backend/post-type/create.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Post Type'); 11 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Post Types'), 'url' => ['index']]; 12 | $this->params['breadcrumbs'][] = $this->title; 13 | ?> 14 | 15 |
16 |

title ?>

17 | 18 | render('_form', [ 19 | 'model' => $model 20 | ]) ?> 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /views/backend/post-type/index.php: -------------------------------------------------------------------------------- 1 | 14 | 15 |

16 | 'btn btn-success']) ?> 17 |

18 | 19 | $dataprovider, 21 | 'columns' => [ 22 | 'id', 23 | 'title', 24 | ['class' => 'yii\grid\ActionColumn'] 25 | ], 26 | ]); ?> 27 | -------------------------------------------------------------------------------- /views/backend/post-type/update.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Post Type'); 12 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Post Types'), 'url' => ['index']]; 13 | $this->params['breadcrumbs'][] = $this->title; 14 | ?> 15 | 16 |
17 | 18 |

title ?>

19 | 20 | render('_form', [ 21 | 'model' => $model 22 | ]) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/backend/widget-type/create.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Create ') . Module::t('', 'Widget Type'); 14 | $this->params['breadcrumbs'] = $model->breadcrumbs; 15 | $this->params['breadcrumbs'][] = $this->title; 16 | ?> 17 |
18 | 19 | render('_form', [ 20 | 'model' => $model, 21 | ]) ?> 22 | 23 |
24 | -------------------------------------------------------------------------------- /views/backend/widget-type/index.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Widget Types'); 17 | $this->params['breadcrumbs'][] = $this->title; 18 | ?> 19 |
20 | 21 |

22 | 'btn btn-success']) ?> 23 |

24 | 25 | 26 | $dataProvider, 28 | 'columns' => [ 29 | 'id', 30 | 'title', 31 | ['class' => 'yii\grid\ActionColumn'], 32 | ], 33 | ]); ?> 34 | 35 | 36 |
37 | -------------------------------------------------------------------------------- /views/backend/widget-type/update.php: -------------------------------------------------------------------------------- 1 | title = Module::t('', 'Update ') . Module::t('', 'Widget Type') . ' ' . $model->title; 9 | $this->params['breadcrumbs'] = $model->breadcrumbs; 10 | $this->params['breadcrumbs'][] = $model->title; 11 | ?> 12 |
13 | 14 | render('_form', [ 15 | 'model' => $model, 16 | ]) ?> 17 | 18 |
19 | -------------------------------------------------------------------------------- /views/backend/widget-type/view.php: -------------------------------------------------------------------------------- 1 | title = $model->title; 11 | $this->params['breadcrumbs'][] = ['label' => Module::t('', 'Blog Categorys'), 'url' => ['index']]; 12 | $this->params['breadcrumbs'][] = $this->title; 13 | ?> 14 |
15 | 16 |

17 | $model->id], ['class' => 'btn btn-primary']) ?> 18 | $model->id], [ 19 | 'class' => 'btn btn-danger', 20 | 'data' => [ 21 | 'confirm' => Module::t('', 'Are you sure you want to delete this item?'), 22 | 'method' => 'post', 23 | ], 24 | ]) ?> 25 |

26 | 27 | $model, 29 | 'attributes' => [ 30 | 'id', 31 | [ 32 | 'attribute' => 'parent_id', 33 | 'value' => $model->parent_id ? $model->parent->title : Module::t('', 'Root Category'), 34 | ], 35 | 'title', 36 | 'slug', 37 | 'banner', 38 | [ 39 | 'attribute' => 'is_nav', 40 | 'value' => $model->isNavLabel, 41 | ], 42 | 'sort_order', 43 | 'page_size', 44 | 'template', 45 | 'redirect_url:url', 46 | [ 47 | 'attribute' => 'status', 48 | 'value' => $model->getStatus(), 49 | ], 50 | 'created_at:datetime', 51 | 'updated_at:datetime', 52 | ], 53 | ]) ?> 54 | 55 |
56 | -------------------------------------------------------------------------------- /views/frontend/default/_article.php: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 |
12 | type->has_category): ?> 13 | 17 | 18 | 19 | 42 |
43 | 44 | type->has_banner && $post->banner && $post->module->showBannerInPost) : ?> 45 |
46 | <?= $post->title; ?> 48 |
49 | 50 | 51 | type->has_title): ?> 52 |

53 | title); ?> 54 |

55 | 56 | 57 |
58 | 59 | type->has_content) { 65 | 66 | /* 67 | * Printing main post content property value 68 | * */ 69 | echo $post->content; 70 | 71 | } 72 | 73 | /* Printing books */ 74 | echo $this->render('_books', ['books' => $post->getBooks()]); 75 | 76 | ?> 77 |
78 |
79 | -------------------------------------------------------------------------------- /views/frontend/default/_book.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 |
17 | 18 |
19 | getThumbFileUrl('banner', 'mthumb')), $model->url) ?> 20 |
21 | 22 | title, $model->url) ?> 23 | 24 |
25 | -------------------------------------------------------------------------------- /views/frontend/default/_book_chapter_search_form.php: -------------------------------------------------------------------------------- 1 | 13 |
14 | 'boook-chapter-sarch-form', 16 | 'method'=>"get" 17 | ]); ?> 18 | 19 | field($model, 'q')->textInput((['maxlength' => 255])); ?> 20 | 21 | 22 | 'btn btn-primary']) ?> 23 | 24 | 25 |
26 | -------------------------------------------------------------------------------- /views/frontend/default/_books.php: -------------------------------------------------------------------------------- 1 | $books->andWhere(['status'=>\diazoxide\blog\traits\IActiveStatus::STATUS_ACTIVE]), 17 | 'pagination' => [ 18 | 'pageSize' => 20, 19 | ], 20 | ]); 21 | 22 | echo ListView::widget([ 23 | 'dataProvider' => $dataProvider, 24 | 'itemView' => '_book', 25 | 'emptyText' => '', 26 | 27 | ]); -------------------------------------------------------------------------------- /views/frontend/default/_chapter.php: -------------------------------------------------------------------------------- 1 | 14 | 15 |
title, $model->url) ?>
16 |

brief ?>

17 | 18 | -------------------------------------------------------------------------------- /views/frontend/default/_comment.php: -------------------------------------------------------------------------------- 1 | 11 |
12 |

13 | 14 | authorLink; ?> getMaskedEmail(); ?> 15 | 16 | 19 |

20 |
21 | getContent())); ?> 22 |
23 |
24 | 25 | -------------------------------------------------------------------------------- /views/frontend/default/_post.php: -------------------------------------------------------------------------------- 1 | 11 |
12 |
13 | getThumbFileUrl('banner', 'mthumb'), ['class' => 'img-responsive']), $model->url) ?> 14 |
15 |
16 |

17 | title), 50, '...')), $model->url); ?> 18 |

19 | 20 |
21 | category->title; ?> 22 |
23 | 24 |
25 | brief), 100, '...'); 27 | ?> 28 |
29 | 30 |
31 | 32 | formatter->asDatetime($model->created_at); ?> 33 | 34 | module->showClicksInArchive): ?> 35 | click; ?> 36 | 37 | 38 |
39 |
40 |
41 | -------------------------------------------------------------------------------- /views/frontend/default/archive.php: -------------------------------------------------------------------------------- 1 | title = $title; 15 | $this->params['breadcrumbs'] = $category->breadcrumbs; 16 | 17 | Yii::$app->view->registerMetaTag([ 18 | 'name' => 'description', 19 | 'content' => Yii::$app->name . ' ' . Module::t('', 'Blog') 20 | ]); 21 | Yii::$app->view->registerMetaTag([ 22 | 'name' => 'keywords', 23 | 'content' => Yii::$app->name . ', ' . Module::t('', 'Blog') 24 | ]); 25 | 26 | if (Yii::$app->get('opengraph', false)) { 27 | Yii::$app->opengraph->set([ 28 | 'title' => $this->title, 29 | 'description' => Module::t('', 'Blog'), 30 | //'image' => '', 31 | ]); 32 | } 33 | 34 | $itemListElement = []; 35 | foreach ($dataProvider->models as $key => $post) { 36 | $itemListElement[] = (object)[ 37 | "@type" => "ListItem", 38 | "http://schema.org/position" => $key, 39 | "http://schema.org/url" => $post->absoluteUrl, 40 | ]; 41 | } 42 | $itemList = (object)[ 43 | "@type" => "ItemList", 44 | "http://schema.org/itemListElement" => $itemListElement 45 | 46 | ]; 47 | $this->context->module->JsonLD->add($itemList); 48 | $this->context->module->JsonLD->registerScripts(); 49 | 50 | ?> 51 |
52 | 53 |
54 |
55 |

56 |
57 |
58 | 59 | $dataProvider, 63 | 'itemView' => '_post', 64 | 'itemOptions' => [ 65 | 'class' => 'row top-buffer-20-xs' 66 | ], 67 | 'layout' => '{items}{pager}{summary}' 68 | ]); 69 | Pjax::end(); 70 | ?> 71 |
72 | 73 | 74 | -------------------------------------------------------------------------------- /views/frontend/default/dynamic.php: -------------------------------------------------------------------------------- 1 | title = $title; 8 | 9 | ?> 10 |
11 | 12 |
13 |

14 |

15 |
16 | 17 |
-------------------------------------------------------------------------------- /views/frontend/default/navbar.php: -------------------------------------------------------------------------------- 1 | [ 9 | 'class' => 'navbar-default', 10 | 'id'=>'blog_navbar' 11 | ], 12 | ]); 13 | echo Nav::widget([ 14 | 'options' => ['class' => 'navbar-nav navbar-left'], 15 | 'items' => \diazoxide\blog\models\BlogCategory::getAllMenuItems() 16 | ]); 17 | 18 | 19 | NavBar::end(); 20 | ?> -------------------------------------------------------------------------------- /views/frontend/default/searchBookChapter.php: -------------------------------------------------------------------------------- 1 | title = "Search"; 14 | ?> 15 | 16 |
17 | 18 |
19 | render('_book_chapter_search_form',['model'=>$searchModel]) ?> 20 |
21 |
22 | $dataProvider, 25 | 'itemView' => '_chapter', 26 | 'itemOptions'=>[ 27 | 'class'=>'col-sm-3 top-buffer-20' 28 | ], 29 | 'layout' => '{items}{pager}{summary}' 30 | ]); 31 | ?> 32 |
33 |
34 |
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /views/frontend/default/viewBook.php: -------------------------------------------------------------------------------- 1 | title = $book->title; 17 | $this->params['breadcrumbs'] = $book->breadcrumbs; 18 | $this->params['breadcrumbs'][] = $book->title; 19 | 20 | $dataProvider = new ActiveDataProvider([ 21 | 'query' => $book->getChapters()->andWhere(['parent_id'=>null]), 22 | 'pagination' => [ 23 | 'pageSize' => 50, 24 | ], 25 | ]); 26 | echo ListView::widget([ 27 | 'dataProvider' => $dataProvider, 28 | 'itemView' => '_chapter', 29 | 'itemOptions'=>[ 30 | 'class'=>'col-sm-3 top-buffer-20' 31 | ], 32 | ]); -------------------------------------------------------------------------------- /views/frontend/default/viewChapter.php: -------------------------------------------------------------------------------- 1 | title = $chapter->title; 17 | $this->params['breadcrumbs'] = $chapter->breadcrumbs; 18 | $this->params['breadcrumbs'][] = $this->title; 19 | ?> 20 |

title ?>

21 |

brief ?>

22 | 23 | $chapter->getChapters(), 26 | 'pagination' => [ 27 | 'pageSize' => 50, 28 | ], 29 | ]); 30 | echo ListView::widget([ 31 | 'dataProvider' => $dataProvider, 32 | 'itemView' => '_chapter', 33 | 'itemOptions'=>[ 34 | 'class'=>'col-sm-3 top-buffer-20' 35 | ], 36 | 'emptyText' => '', 37 | 'layout' => "{summary}
{items}
{pager}", 38 | ]); 39 | ?> 40 | 41 |
42 | getParsedContent(); ?> 43 |
44 | -------------------------------------------------------------------------------- /views/frontend/layouts/dynamic.php: -------------------------------------------------------------------------------- 1 | context->module->registerAssets(); 11 | ?> 12 | 13 | beginPage() ?> 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | registerCsrfMetaTags() ?> 23 | <?= Html::encode( $this->title ) ?> 24 | head() ?> 25 | website->register(); ?> 26 | 27 | 28 | 29 | 30 | 31 | beginBody() ?> 32 | 33 |
34 |
35 | 36 | context->module->getLayoutPattern(); 40 | 41 | /** @var array $_params_ */ 42 | echo ViewPatternHelper::extract($pattern,$_params_) 43 | 44 | ?> 45 |
46 |
47 | 48 | endBody() ?> 49 | 50 | 51 | 52 | 53 | endPage() ?> 54 | -------------------------------------------------------------------------------- /views/frontend/layouts/navigation.php: -------------------------------------------------------------------------------- 1 | [ 6 | 'id' => 'header_second' 7 | ] 8 | ]); -------------------------------------------------------------------------------- /widgets/Carousel.php: -------------------------------------------------------------------------------- 1 | 'ol', 'class' => 'carousel-indicators']; 19 | 20 | /** 21 | * Renders carousel indicators. 22 | * @return string the rendering result 23 | */ 24 | public function renderIndicators() 25 | { 26 | if ($this->showIndicators === false) { 27 | return ''; 28 | } 29 | $indicators = []; 30 | for ($i = 0, $count = count($this->items); $i < $count; $i++) { 31 | 32 | $options = isset($this->items[$i]['indicator']['options']) ? $this->items[$i]['indicator']['options'] : []; 33 | $options['data']['target'] = '#' . $this->options['id']; 34 | $options['data']['slide-to'] = $i; 35 | 36 | $content = isset($this->items[$i]['indicator']['content']) ? $this->items[$i]['indicator']['content'] : ''; 37 | 38 | if ($i === 0) { 39 | Html::addCssClass($options, 'active'); 40 | } 41 | $indicators[] = Html::tag('li', $content, $options); 42 | } 43 | 44 | $indicatorsOptions = $this->indicatorsOptions; 45 | $indicatorsTag = ArrayHelper::remove($indicatorsOptions, 'tag', 'ol'); 46 | 47 | 48 | return Html::tag($indicatorsTag, implode("\n", $indicators), $indicatorsOptions); 49 | } 50 | } -------------------------------------------------------------------------------- /widgets/Comments.php: -------------------------------------------------------------------------------- 1 | 'div', 'class' => 'row']; 26 | public $show_title = true; 27 | public $title_options = ['class' => 'widget_title top-buffer-20-xs']; 28 | public $title = "Comments"; 29 | 30 | /** 31 | */ 32 | public function init() 33 | { 34 | 35 | } 36 | 37 | /** 38 | * @return string|void 39 | * @throws \Exception 40 | */ 41 | public function run() 42 | { 43 | 44 | $bodyTag = ArrayHelper::remove($this->body_options, 'tag', 'div') ?? 'div'; 45 | echo Html::beginTag($bodyTag, $this->body_options); 46 | 47 | 48 | if ($this->show_title) { 49 | $titleTag = ArrayHelper::remove($this->title_options, 'tag', 'div') ?? 'div'; 50 | echo Html::tag($titleTag, $this->title, $this->title_options); 51 | } 52 | 53 | if (isset(Yii::$app->getModule('blog')->social['facebook']['app_id'])) { 54 | echo FacebookComments::widget( 55 | [ 56 | 'app_id' => Yii::$app->getModule('blog')->social['facebook']['app_id'], 57 | 'data' => ['width' => '100%', 'numposts' => '5'] 58 | ] 59 | ); 60 | } 61 | 62 | echo Html::endTag($bodyTag); 63 | 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /widgets/Navigation.php: -------------------------------------------------------------------------------- 1 | _type = BlogPostType::findOne(['name' => $this->type]); 29 | 30 | if (!$this->_type) { 31 | throw new NotSupportedException('Navigation widget: Post type not found.'); 32 | } 33 | 34 | if ($this->vertical) { 35 | $this->buildNav(); 36 | return; 37 | } 38 | 39 | NavBar::begin([ 40 | 'brandLabel' => Module::t('', 'Categories'), 41 | 'brandOptions' => [ 42 | 'class' => 'visible-xs' 43 | ], 44 | 'innerContainerOptions' => ['class' => 'container nopadding-sm'], 45 | 'containerOptions' => ['class' => 'nopadding-sm'], 46 | 47 | 'options' => [ 48 | 'class' => 'navbar-default', 49 | 'id' => $this->options['id'], 50 | 51 | ], 52 | ]); 53 | 54 | $this->buildNav(); 55 | 56 | echo Search::widget([]); 57 | 58 | NavBar::end(); 59 | } 60 | 61 | /** 62 | * @param BlogCategory $parent 63 | * @return array 64 | */ 65 | private function buildItems($parent) 66 | { 67 | $items = []; 68 | foreach ($parent->getChildren()->where(['type_id' => $this->_type->id, 'is_nav' => true, 'status' => IActiveStatus::STATUS_ACTIVE])->all() as $child) { 69 | $items[] = ['label' => $child->titleWithIcon, 'url' => $child->url, 'items' => $this->buildItems($child)]; 70 | } 71 | return $items; 72 | } 73 | 74 | public function buildNav() 75 | { 76 | $class = 'navbar-nav navbar-left'; 77 | if ($this->vertical) { 78 | $class = 'nav-pills nav-stacked'; 79 | } 80 | 81 | $model = BlogCategory::findOne(1); 82 | 83 | echo Nav::widget([ 84 | 'encodeLabels' => false, 85 | 'options' => ['class' => $class], 86 | 'items' => $this->buildItems($model) 87 | ]); 88 | } 89 | } -------------------------------------------------------------------------------- /widgets/RecentComments.php: -------------------------------------------------------------------------------- 1 | title === null) { 23 | $this->title = 'title'; 24 | } 25 | } 26 | 27 | public function run() 28 | { 29 | //$comments = Comment::find()->where(['status' => Comment::STATUS_ACTIVE])->orderBy(['create_time' => SORT_DESC])->limit($this->maxComments)->all(); 30 | $comments = BlogComment::findRecentComments($this->maxComments); 31 | 32 | return $this->render('recentComments', [ 33 | 'title' => $this->title, 34 | 'comments' => $comments, 35 | ]); 36 | } 37 | } -------------------------------------------------------------------------------- /widgets/Search.php: -------------------------------------------------------------------------------- 1 | scenario = $model::SCENARIO_USER; 22 | echo $this->render('_search',[ 23 | 'model'=>$model 24 | ]); 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /widgets/Slider2.php: -------------------------------------------------------------------------------- 1 | view->registerCss($css); 83 | } 84 | 85 | /** 86 | * @return string 87 | * @throws \Exception 88 | */ 89 | public function run() 90 | { 91 | if(empty($this->items)) 92 | return null; 93 | return Carousel::widget([ 94 | 'items' => $this->items, 95 | 'options' => ['class' => 'carousel slide', 'data-interval' => '5000'], 96 | 'indicatorsOptions' => ['tag' => 'ul', 'class' => 'carousel-indicators hidden-sm hidden-xs hidden-md'], 97 | 'controls' => [ 98 | '', 99 | '' 100 | ] 101 | ]); 102 | } 103 | 104 | /** 105 | * @return array 106 | */ 107 | public function getItems() 108 | { 109 | $post_type = BlogPostType::findOne(['name'=>$this->post_type]); 110 | 111 | if($post_type == null){ 112 | throw new ElementNotFound('The requested post type does not exist.'); 113 | } 114 | 115 | $posts = BlogPost::find() 116 | ->where(['status' => IActiveStatus::STATUS_ACTIVE, 'is_slide' => true,'type_id'=>$post_type->id]) 117 | ->andWhere('FROM_UNIXTIME(published_at) <= NOW()') 118 | ->limit($this->itemsCount) 119 | ->orderBy(['id' => SORT_DESC]) 120 | ->all(); 121 | 122 | $items = []; 123 | 124 | foreach ($posts as $post) { 125 | $item = [ 126 | 'content' => Html::tag('div', null, ['style' => 'height:450px; width:100%; background-image:url(' . $post->getImageFileUrl('banner') . '); background-size:cover']), 127 | 'caption' => 128 | implode('', [ 129 | Html::a( 130 | Html::tag('h4', 131 | StringHelper::truncate($post->title, 200, '...') 132 | ), $post->url 133 | ), 134 | // Html::tag('p', StringHelper::truncate($post->brief, 50, '...')) 135 | ]), 136 | 'options' => [], 137 | ]; 138 | 139 | if($this->show_indicators){ 140 | $item['indicator'] = [ 141 | 'content' => implode('', [ 142 | Html::img($post->getThumbFileUrl('banner', 'xsthumb')), 143 | Html::tag('div', StringHelper::truncate($post->title, 50, '...'), ['class' => 'carousel-indicator-content']), 144 | Html::tag('p', $post->category->getTitleWithIcon(), ['class' => 'text-right text-warning']) 145 | ]), 146 | // 'options' => ['style'=>'overflow:hidden'], 147 | // 'options' => ['style' => 'zoom:2; background:url(' . $post->getThumbFileUrl('banner', 'xsthumb') . '); background-size:cover'], 148 | ]; 149 | } 150 | $items[] = $item; 151 | } 152 | return $items; 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /widgets/SocialMedia.php: -------------------------------------------------------------------------------- 1 | 'div', 'class' => 'row']; 27 | public $show_title = true; 28 | public $title_options = ['class' => 'widget_title top-buffer-20-xs']; 29 | public $title = "Social Media"; 30 | 31 | public $addThisOptions = []; 32 | 33 | /** 34 | */ 35 | public function init() 36 | { 37 | $this->addThisOptions['pub_id'] = Yii::$app->getModule('blog')->social['addthis']['pub_id'] ?? null; 38 | } 39 | 40 | /** 41 | * @return string|void 42 | * @throws \Exception 43 | */ 44 | public function run() 45 | { 46 | 47 | $bodyTag = ArrayHelper::remove($this->body_options, 'tag', 'div') ?? 'div'; 48 | echo Html::beginTag($bodyTag, $this->body_options); 49 | 50 | 51 | if ($this->show_title) { 52 | $titleTag = ArrayHelper::remove($this->title_options, 'tag', 'div') ?? 'div'; 53 | echo Html::tag($titleTag, $this->title, $this->title_options); 54 | } 55 | 56 | if ($this->addThisOptions['pub_id'] !== null) { 57 | echo AddThis::widget( 58 | 59 | $this->addThisOptions 60 | 61 | ); 62 | } 63 | 64 | echo Html::endTag($bodyTag); 65 | 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /widgets/social/AddThis.php: -------------------------------------------------------------------------------- 1 | 'mohq', 20 | 'widget-type' => 'floating' 21 | ]; 22 | 23 | public function init() 24 | { 25 | 26 | $this->data['pub-id'] = $this->pub_id; 27 | 28 | $this->view->registerJsFile('https://cdn.ampproject.org/v0/amp-addthis-0.1.js', 29 | ['position' => yii\web\View::POS_HEAD]); 30 | } 31 | 32 | public function run() 33 | { 34 | echo Html::tag('amp-addthis', '', [ 35 | 'width' => $this->width, 36 | 'height' => $this->height, 37 | 'data' => $this->data, 38 | ]); 39 | } 40 | } -------------------------------------------------------------------------------- /widgets/social/FacebookComments.php: -------------------------------------------------------------------------------- 1 | data['href'])) { 18 | $this->data['href'] = Yii::$app->request->getAbsoluteUrl(); 19 | } 20 | echo '
'; 21 | 22 | } 23 | 24 | public function run() 25 | { 26 | echo Html::tag('div', null, ['class' => 'fb-comments', 'data' => $this->data]); 27 | } 28 | } -------------------------------------------------------------------------------- /widgets/views/_feed_item.php: -------------------------------------------------------------------------------- 1 | 24 | 25 | getThumbFileUrl('banner', $imageType), 38 | ['class' => 'img-responsive pull-left'] 39 | ), 40 | $model->url 41 | ), 42 | $imageContainerOptions 43 | ); 44 | 45 | echo Html::beginTag('div', $contentContainerOptions); 46 | 47 | /** 48 | * Building title Html 49 | * @var boolean $showTitle 50 | */ 51 | if ($showTitle) 52 | 53 | echo Html::a( 54 | Html::tag( 55 | isset($titleOptions['tag']) && !empty($titleOptions['tag']) ? $titleOptions['tag'] : 'div', 56 | \yii\helpers\StringHelper::truncate(Html::encode($model->title), $titleLength, $titleSuffix), 57 | $titleOptions 58 | ), 59 | $model->url 60 | ); 61 | 62 | ?> 63 | 64 | 70 | 72 | category->title; ?> 73 | 75 | category->titleWithIcon; ?> 76 | 78 | category->icon; ?> 79 | 80 | 82 | 83 | 84 | formatter->format($model->published_at, $dateType) ?> 86 | 87 | 88 | 90 | click; ?> 91 | 92 | 93 | 96 | 97 | brief), $briefLength, $briefSuffix), 105 | $briefOptions 106 | ); 107 | } 108 | 109 | /** 110 | * Building button html 111 | */ 112 | if ($showReadMoreButton) { 113 | 114 | echo Html::a( 115 | ' ' . $readMoreButtonText, 116 | $model->url, 117 | $readMoreButtonOptions 118 | ); 119 | } 120 | echo Html::endTag('div'); 121 | 122 | echo Html::endTag($bodyTag); 123 | ?> 124 | 125 | -------------------------------------------------------------------------------- /widgets/views/_post_item.php: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 | 11 | 19 | 20 |
21 | 22 | 23 |
title), 50, "..."), $model->url) ?>
24 | 25 | brief), $briefLength, '...'), ['class' => 'small']); 27 | } ?> 28 | 29 | 30 |

31 | 32 | 33 | formatter->asDate($model->created_at); ?> 34 | 35 | 36 | 38 | category->title; ?> 39 | 40 | 41 | 43 | click; ?> 44 | 45 | 46 | 47 |

48 |

49 | url, ['class' => 'btn btn-default']); 52 | } ?> 53 |

54 | 55 | 56 |
57 | 58 | 59 |
-------------------------------------------------------------------------------- /widgets/views/_search.php: -------------------------------------------------------------------------------- 1 | 8 | 'search-form', 10 | 'method' => 'get', 11 | 'action' => '/archive', 12 | 'fieldConfig' => [ 13 | 'options' => [ 14 | 'tag' => false, 15 | ], 16 | ], 17 | 'options' => ['class' => 'navbar-form navbar-right'] 18 | ]); ?> 19 | 20 |
21 | field($model, 'q', 23 | ['errorOptions' => ['tag' => null]] 24 | ) 25 | ->textInput((['maxlength' => 255, 'placeholder' => Module::t('', 'Search')])) 26 | ->label(false); ?> 27 | 28 | 29 |
30 | ', ['class' => 'btn btn-default']) ?> 31 |
32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /widgets/views/recentComments.php: -------------------------------------------------------------------------------- 1 | 11 |
12 |
13 |
14 |
15 |
16 |
    17 | 18 |
  • authorLink; ?> 评论了 19 | post->title), $comment->getUrl()); ?> 20 |
  • 21 | 22 |
23 |
24 |
25 | --------------------------------------------------------------------------------