Skip to content

Commit

Permalink
resync
Browse files Browse the repository at this point in the history
  • Loading branch information
herizo committed Dec 5, 2017
0 parents commit ad4fd70
Show file tree
Hide file tree
Showing 43 changed files with 1,221 additions and 0 deletions.
101 changes: 101 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php namespace Pmesolution\Blog;

use Backend;
use System\Classes\PluginBase;
use Pmesolution\Blog\Models\Comment;
use Event;

/**
* blog Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'pmesolution.blog::lang.plugin.name',
'description' => 'pmesolution.blog::lang.plugin.description',
'author' => 'pmesolution',
'icon' => 'icon-edit'
];
}

/**
* Register method, called when the plugin is first registered.
*
* @return void
*/
public function register()
{

}

/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{

}

/**
* Registers any front-end components implemented in this plugin.
*
* @return array
*/
public function registerComponents()
{

return [
'\Pmesolution\Blog\Components\Blog' => 'Blog',
'\Pmesolution\Blog\Components\Categories' => 'Categories',
'\Pmesolution\Blog\Components\Post' => 'Post',
'\Pmesolution\Blog\Components\Category' => 'Category',
'\Pmesolution\Blog\Components\Comment' => 'Comment',

];
}

/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return []; // Remove this line to activate

return [
'pmesolution.blog.some_permission' => [
'tab' => 'blog',
'label' => 'Some permission'
],
];
}

/**
* Registers back-end navigation items for this plugin.
*
* @return array
*/
public function registerNavigation()
{

return [
'blog' => [
'label' => 'pmesolution.blog::lang.menu_item.title',
'url' => Backend::url('pmesolution/blog/Post'),
'icon' => 'icon-edit',
'permissions' => ['pmesolution.blog.*'],
'order' => 500,
],
];
}
}
65 changes: 65 additions & 0 deletions assets/css/blog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.clear { clear:both;}
.bloglist {}
.bloglist ul {}
.bloglist ul li {
list-style-type:none;
}

.bloglist .featured-image {
width:250px;
margin:0 20px 0 0;
float:left;
}


.block-categories ul{
padding-left:0;
}
.block-categories ul li {
list-style-type:none;
}

.featured-image {
max-width:100%;
}

.comments {
width:100%;
margin-top:20px;
}
.comments form {
margin:40px 0;
}
.comments form label {
width:100%;
}

.comments form textarea , .comments form input {
width:350px;
display:block;
}
.comments .submit {
width:350px;
margin-top:20px;
padding:10px;
}
/*comments list*/

.comments ul {
padding-left:0;
}

.comments ul li {
width:100%;
list-style-type:none;
margin:20px 0;
}
.comments ul li .author {
font-weight:bold;
}
/* block categories */
.block-categories {}
.block-categories li a {
text-decoration:none;
color:#333;
}
30 changes: 30 additions & 0 deletions components/Blog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php namespace Pmesolution\Blog\Components;

use Cms\Classes\ComponentBase;
use Pmesolution\Blog\Models\Post;
use Session;

class Blog extends ComponentBase
{
public function articles(){
//conditions here
return Post::where('lang_id', Session::get('lang_id'))->get();
}

public function onRun(){
$this->addCss('/plugins/pmesolution/blog/assets/css/blog.css');
}

public function componentDetails()
{
return [
'name' => 'pmesolution.blog::lang.components.blog.name',
'description' => 'pmesolution.blog::lang.components.blog.description',
];
}

public function defineProperties()
{
return [];
}
}
26 changes: 26 additions & 0 deletions components/Categories.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php namespace Pmesolution\Blog\Components;

use Cms\Classes\ComponentBase;
use Pmesolution\Blog\Models\Category as ModelCategory;
use Session;

class Categories extends ComponentBase
{

public function getlist(){
return ModelCategory::where('lang_id', Session::get('lang_id'))->get();
}

public function componentDetails()
{
return [
'name' => 'pmesolution.blog::lang.components.category.name',
'description' => 'pmesolution.blog::lang.components.category.description'
];
}

public function defineProperties()
{
return [];
}
}
38 changes: 38 additions & 0 deletions components/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php namespace Pmesolution\Blog\Components;

use Cms\Classes\ComponentBase;
use Pmesolution\Blog\Models\Category as ModelCategory;
use Pmesolution\Blog\Models\Post as ModelPost;
use Redirect;

class Category extends ComponentBase
{

public $title = 'dd';
public $description = 'default description';
public function filter($slug){
$cat = ModelCategory::where('name' , $slug)->first();

if($cat !== NULL){
return Post::where('category', $cat->ID)->get();
}else {
$this->title = 'foo';
$this->description ='bar';
return Post::All();
}

}
public function componentDetails()
{
return [

'name' => 'pmesolution.blog::lang.components.category.name',
'description' => 'pmesolution.blog::lang.components.category.description'
];
}

public function defineProperties()
{
return [];
}
}
26 changes: 26 additions & 0 deletions components/Comment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php namespace Pmesolution\Blog\Components;

use Cms\Classes\ComponentBase;
use Request;
use Input;

class Comment extends ComponentBase
{
public function componentDetails()
{
return [
'name' => 'pmesolution.blog::lang.components.comment.name',
'description' => 'pmesolution.blog::lang.components.comment.description'
];
}

public function defineProperties()
{
return [];
}

public function onNewComment(){
var_dump(Input::get('name'));
return 'foo';
}
}
27 changes: 27 additions & 0 deletions components/Post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php namespace Pmesolution\Blog\Components;

use Cms\Classes\ComponentBase;
use Request;
use Pmesolution\Blog\Models\Post as Blogpost;


class Post extends ComponentBase
{
public function componentDetails()
{
return [
'name' => 'pmesolution.blog::lang.components.post.name',
'description' => 'pmesolution.blog::lang.components.post.description'
];
}

public function defineProperties()
{
return [];
}

public function getone($slug){

return Blogpost::where('slug', $slug)->first();
}
}
14 changes: 14 additions & 0 deletions components/blog/default.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="bloglist">
<ul>
{%for article in Blog.articles %}
<li>
<h3><a href="{{ url('/post') }}/{{article.slug}}">{{article.title}}</a></h3>
{% if article.featured %}
<img class="featured-image" src="{{article.featured.getpath()}}" />
{% endif%}
<p>{{article.excerpt}}</p>
<div class="clear"></div>
</li>
{% endfor %}
</ul>
</div>
7 changes: 7 additions & 0 deletions components/categories/default.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="block-categories">
<ul>
{%for item in Categories.getlist %}
<li><a href="{{item.link}}">{{item.name}}</a></li>
{% endfor %}
</ul>
</div>
11 changes: 11 additions & 0 deletions components/category/default.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div>
<h1>{{__SELF__.title}}</h1>
<p>{{ Category.description}}</p>
<p>post list</p>
{% set list=Category.filter(this.param.slug)%}
<ul>
{%for article in list %}
<li><a href="{{ url('/post') }}/{{article.slug}}">{{article.title}}</a></li>
{% endfor %}
</ul>
</div>
35 changes: 35 additions & 0 deletions components/comment/default.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- comment form -->
<div class="comments">
<form datarequest="onNewComment">
<fieldset><legend>{{ 'Submit a comment' | l }}</legend>
<label>{{ 'Name' | l }}</label>
<input type="text" id="name" name="name"/>
<br/>
<label>{{ 'email' | l }} </label>
<input type="text" id="email" name="email"/>

<label>{{ 'Message'}}</label>
<textarea id="message" name="message">
</textarea>
</fieldset>

<button class="primary submit">{{'Submit' | l }}</button>
</form>
<!-- list of old comments -->

<h4>{{ 'Comments' | l }}</h4>
<ul>
<li>
<div class="author">author1</div>
<div class="comment">comment 1</div>
</li>
<li>
<div class="author">author2</div>
<div class="comment">Comment 2</div>
</li>
<li>
<div class="author">author3</div>
<div class="comment">Comment 3</div>
</li>
</ul>
</div>
Loading

0 comments on commit ad4fd70

Please sign in to comment.