Skip to content

Commit

Permalink
新的主题,友情链接管理
Browse files Browse the repository at this point in the history
  • Loading branch information
endachao committed Nov 13, 2015
1 parent 058b4c2 commit 172ba75
Show file tree
Hide file tree
Showing 2,984 changed files with 203,219 additions and 13,907 deletions.
135 changes: 135 additions & 0 deletions app/Components/EndaPage.php
@@ -0,0 +1,135 @@
<?php
/**
* User: 袁超<yccphp@163.com>
* Time: 2015.11.12 下午6:16
*/
namespace App\Components;

use Illuminate\Contracts\Pagination\Presenter;
use Illuminate\Contracts\Pagination\Paginator as PaginatorContract;
use Illuminate\Pagination\BootstrapThreePresenter;
class EndaPage extends BootstrapThreePresenter implements Presenter
{
public $paginator;

public function __construct(PaginatorContract $paginator)
{
$this->paginator = $paginator;
}

/**
* Determine if the underlying paginator being presented has pages to show.
*
* @return bool
*/
public function hasPages()
{
return $this->paginator->hasPages() && count($this->paginator->items()) > 0;
}

/**
* Convert the URL window into Bootstrap HTML.
*
* @return string
*/
public function render()
{
if ($this->hasPages()) {
return sprintf(
'<ul class="pager">%s %s</ul>',
$this->getPreviousButton('<span aria-hidden="true">&larr;</span>上一页'),
$this->getNextButton('下一页<span aria-hidden="true">&rarr;</span>')
);
}

return '';
}

/**
* 获取上一页按钮
*
* @param string $text
* @return string
*/
public function getPreviousButton($text = '&laquo;')
{
if ($this->paginator->currentPage() <= 1) {
return $this->getPreviousDisabledTextWrapper($text);
}

$url = $this->paginator->url(
$this->paginator->currentPage() - 1
);

return $this->getPreviousPageWrapper($url, $text, 'prev');
}


/**
* 获取上一页li
* @param $url
* @param $page
* @param null $rel
* @return string
*/
protected function getPreviousPageWrapper($url, $page, $rel = null)
{
$rel = is_null($rel) ? '' : ' rel="'.$rel.'"';

return '<li class="previous"><a href="'.htmlentities($url).'"'.$rel.'>'.$page.'</a></li>';
}

/**
* 获取下一页按钮
*
* @param string $text
* @return string
*/
public function getNextButton($text = '&raquo;')
{
if (! $this->paginator->hasMorePages()) {
return $this->getDisabledTextWrapper($text);
}

$url = $this->paginator->url($this->paginator->currentPage() + 1);

return $this->getNextPageWrapper($url, $text, 'next');
}

/**
* 获取上一页li
* @param $url
* @param $page
* @param null $rel
* @return string
*/
protected function getNextPageWrapper($url, $page, $rel = null)
{
$rel = is_null($rel) ? '' : ' rel="'.$rel.'"';

return '<li class="next"><a href="'.htmlentities($url).'"'.$rel.'>'.$page.'</a></li>';
}


/**
* 获取上一页选择状态下的li
*
* @param string $text
* @return string
*/
protected function getPreviousDisabledTextWrapper($text)
{
return '<li class="previous disabled"><span>'.$text.'</span></li>';
}

/**
* 获取下一页选择状态下的li
*
* @param string $text
* @return string
*/
protected function getNextDisabledTextWrapper($text)
{
return '<li class="next disabled"><span>'.$text.'</span></li>';
}
}
62 changes: 0 additions & 62 deletions app/Http/Controllers/AboutController.php
Expand Up @@ -9,35 +9,6 @@

class AboutController extends Controller {

/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}

/**
* Display the specified resource.
Expand All @@ -61,37 +32,4 @@ public function show($id)
]);
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}

}
65 changes: 31 additions & 34 deletions app/Http/Controllers/ArticleController.php
@@ -1,5 +1,6 @@
<?php namespace App\Http\Controllers;

use App\Components\EndaPage;
use App\Http\Requests;
use App\Http\Controllers\Controller;

Expand All @@ -9,47 +10,43 @@
use App\Model\ArticleStatus;
use App\Model\Article;

class ArticleController extends Controller {

/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$article = Article::getNewsArticle();
$hotArticle = Article::getHotArticle(3);
class ArticleController extends Controller
{

/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$article = Article::getNewsArticle(8);
viewInit();
return homeView('index',array(
'article'=>$article,
'hotArticle'=>$hotArticle
$page = new EndaPage($article['page']);
return homeView('index', array(
'articleList' => $article,
'page' => $page
));
}


/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}


/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$article = Article::getArticleModelByArticleId($id);
$tags = Tag::getTagModelByTagIds($article->tags);
$authorArticle = Article::getArticleModelByUserId($article->user_id);

ArticleStatus::updateViewNumber($id);
$data = array(
'article'=>$article,
'tags'=>$tags,
'authorArticle'=>$authorArticle,
'article' => $article,
);
viewInit();
return homeView('article',$data);
}
return homeView('article', $data);
}

}

0 comments on commit 172ba75

Please sign in to comment.