Skip to content

Commit

Permalink
重新修改上下文,兼容原来主题
Browse files Browse the repository at this point in the history
  • Loading branch information
ShingChi committed Mar 21, 2014
1 parent 6c8e81e commit a33f88e
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions var/Widget/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ public function attachments($limit = 0, $offset = 0)
* @param string $default 如果没有下一篇,显示的默认文字
* @return void
*/
public function theNext($format = '%s', $default = NULL)
public function theNext($format = '%s', $default = NULL, $custom = array())
{
$content = $this->db->fetchRow($this->select()->where('table.contents.created > ? AND table.contents.created < ?',
$this->created, $this->options->gmtTime)
Expand All @@ -1520,7 +1520,17 @@ public function theNext($format = '%s', $default = NULL)

if ($content) {
$content = $this->filter($content);
$link = '<a href="' . $content['permalink'] . '" title="' . $content['title'] . '">' . $content['title'] . '</a>';
$default = array(
'title' => NULL,
'tagClass' => NULL
);
$custom = array_merge($default, $custom);
extract($custom);

$linkText = empty($title) ? $content['title'] : $title;
$linkClass = empty($tagClass) ? '' : 'class="' . $tagClass . '" ';
$link = '<a ' . $linkClass . 'href="' . $content['permalink'] . '" title="' . $content['title'] . '">' . $linkText . '</a>';

printf($format, $link);
} else {
echo $default;
Expand All @@ -1535,7 +1545,7 @@ public function theNext($format = '%s', $default = NULL)
* @param string $default 如果没有上一篇,显示的默认文字
* @return void
*/
public function thePrev($format = '%s', $default = NULL)
public function thePrev($format = '%s', $default = NULL, $custom = array())
{
$content = $this->db->fetchRow($this->select()->where('table.contents.created < ?', $this->created)
->where('table.contents.status = ?', 'publish')
Expand All @@ -1546,7 +1556,17 @@ public function thePrev($format = '%s', $default = NULL)

if ($content) {
$content = $this->filter($content);
$link = '<a href="' . $content['permalink'] . '" title="' . $content['title'] . '">' . $content['title'] . '</a>';
$default = array(
'title' => NULL,
'tagClass' => NULL
);
$custom = array_merge($default, $custom);
extract($custom);

$linkText = empty($title) ? $content['title'] : $title;
$linkClass = empty($tagClass) ? '' : 'class="' . $tagClass . '" ';
$link = '<a ' . $linkClass . 'href="' . $content['permalink'] . '" title="' . $content['title'] . '">' . $linkText . '</a>';

printf($format, $link);
} else {
echo $default;
Expand Down

0 comments on commit a33f88e

Please sign in to comment.