diff options
| author | 2014-12-07 15:03:42 +0100 | |
|---|---|---|
| committer | 2014-12-07 15:03:42 +0100 | |
| commit | ea849d7c68cc3de33825c1daafd06b9f8bbf747c (patch) | |
| tree | ce5b3f47f5d81e1209581322d987c5603ee0acd3 | |
| parent | 7ef4d6c033d6d12a644b6cf39940591901fdcb3b (diff) | |
Prepare better organization of view files for exts
View files must be well-splitted to simplify work for extensions.
See https://github.com/FreshRSS/FreshRSS/issues/252
| -rw-r--r-- | app/views/helpers/index/normal/entry_bottom.phtml | 84 | ||||
| -rw-r--r-- | app/views/helpers/index/normal/entry_header.phtml | 40 | ||||
| -rw-r--r-- | app/views/index/index.phtml | 23 | ||||
| -rw-r--r-- | app/views/index/normal.phtml | 157 |
4 files changed, 144 insertions, 160 deletions
diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml new file mode 100644 index 000000000..704644f99 --- /dev/null +++ b/app/views/helpers/index/normal/entry_bottom.phtml @@ -0,0 +1,84 @@ +<?php + $sharing = array(); + if (FreshRSS_Auth::hasAccess()) { + $sharing = FreshRSS_Context::$conf->sharing; + } + + $bottomline_read = FreshRSS_Context::$conf->bottomline_read; + $bottomline_favorite = FreshRSS_Context::$conf->bottomline_favorite; + $bottomline_sharing = FreshRSS_Context::$conf->bottomline_sharing && (count($sharing) > 0); + $bottomline_tags = FreshRSS_Context::$conf->bottomline_tags; + $bottomline_date = FreshRSS_Context::$conf->bottomline_date; + $bottomline_link = FreshRSS_Context::$conf->bottomline_link; +?><ul class="horizontal-list bottom"><?php + if (FreshRSS_Auth::hasAccess()) { + if ($bottomline_read) { + ?><li class="item manage"><?php + $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $this->entry->id())); + if ($this->entry->isRead()) { + $arUrl['params']['is_read'] = 0; + } + ?><a class="read" href="<?php echo Minz_Url::display($arUrl); ?>"><?php + echo _i($this->entry->isRead() ? 'read' : 'unread'); ?></a><?php + ?></li><?php + } + if ($bottomline_favorite) { + ?><li class="item manage"><?php + $arUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $this->entry->id())); + if ($this->entry->isFavorite()) { + $arUrl['params']['is_favorite'] = 0; + } + ?><a class="bookmark" href="<?php echo Minz_Url::display($arUrl); ?>"><?php + echo _i($this->entry->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php + ?></li><?php + } + } ?> + <li class="item"><?php + if ($bottomline_sharing) { + $link = urlencode($this->entry->link()); + $title = urlencode($this->entry->title() . ' · ' . $feed->name()); + ?><div class="dropdown"> + <div id="dropdown-share-<?php echo $this->entry->id();?>" class="dropdown-target"></div> + <a class="dropdown-toggle" href="#dropdown-share-<?php echo $this->entry->id();?>"> + <?php echo _i('share'); ?> + <?php echo _t('share'); ?> + </a> + + <ul class="dropdown-menu"> + <li class="dropdown-close"><a href="#close">❌</a></li> + <?php foreach ($sharing as $share) :?> + <li class="item share"> + <a target="_blank" href="<?php echo FreshRSS_Share::generateUrl(FreshRSS_Context::$conf->shares, $share, $this->entry->link(), $this->entry->title() . ' . ' . $feed->name())?>"> + <?php echo _t($share['name']);?> + </a> + </li> + <?php endforeach;?> + </ul> + </div> + <?php } ?> + </li><?php + $tags = $bottomline_tags ? $this->entry->tags() : null; + if (!empty($tags)) { + ?><li class="item"> + <div class="dropdown"> + <div id="dropdown-tags-<?php echo $this->entry->id();?>" class="dropdown-target"></div> + <?php echo _i('tag'); ?> + <a class="dropdown-toggle" href="#dropdown-tags-<?php echo $this->entry->id();?>"><?php + echo _t('related_tags'); + ?></a> + <ul class="dropdown-menu"> + <li class="dropdown-close"><a href="#close">❌</a></li><?php + foreach($tags as $tag) { + ?><li class="item"><a href="<?php echo _url('index', 'index', 'search', urlencode('#' . $tag)); ?>"><?php echo $tag; ?></a></li><?php + } ?> + </ul> + </div> + </li><?php + } + if ($bottomline_date) { + ?><li class="item date"><?php echo $this->entry->date(); ?></li><?php + } + if ($bottomline_link) { + ?><li class="item link"><a target="_blank" href="<?php echo $this->entry->link(); ?>"><?php echo _i('link'); ?></a></li><?php + } ?> +</ul> diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml new file mode 100644 index 000000000..b751b884f --- /dev/null +++ b/app/views/helpers/index/normal/entry_header.phtml @@ -0,0 +1,40 @@ +<?php + $topline_read = FreshRSS_Context::$conf->topline_read; + $topline_favorite = FreshRSS_Context::$conf->topline_favorite; + $topline_date = FreshRSS_Context::$conf->topline_date; + $topline_link = FreshRSS_Context::$conf->topline_link; +?><ul class="horizontal-list flux_header"><?php + if (FreshRSS_Auth::hasAccess()) { + if ($topline_read) { + ?><li class="item manage"><?php + $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $this->entry->id())); + if ($this->entry->isRead()) { + $arUrl['params']['is_read'] = 0; + } + ?><a class="read" href="<?php echo Minz_Url::display($arUrl); ?>"><?php + echo _i($this->entry->isRead() ? 'read' : 'unread'); ?></a><?php + ?></li><?php + } + if ($topline_favorite) { + ?><li class="item manage"><?php + $arUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $this->entry->id())); + if ($this->entry->isFavorite()) { + $arUrl['params']['is_favorite'] = 0; + } + ?><a class="bookmark" href="<?php echo Minz_Url::display($arUrl); ?>"><?php + echo _i($this->entry->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php + ?></li><?php + } + } + $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $this->entry->feed()); //We most likely already have the feed object in cache + if ($feed == null) { + $feed = $this->entry->feed(true); + if ($feed == null) { + $feed = FreshRSS_Feed::example(); + } + } + ?><li class="item website"><a href="<?php echo _url('index', 'index', 'get', 'f_' . $feed->id()); ?>"><img class="favicon" src="<?php echo $feed->favicon(); ?>" alt="✇" /> <span><?php echo $feed->name(); ?></span></a></li> + <li class="item title"><a target="_blank" href="<?php echo $this->entry->link(); ?>"><?php echo $this->entry->title(); ?></a></li> + <?php if ($topline_date) { ?><li class="item date"><?php echo $this->entry->date(); ?> </li><?php } ?> + <?php if ($topline_link) { ?><li class="item link"><a target="_blank" href="<?php echo $this->entry->link(); ?>"><?php echo _i('link'); ?></a></li><?php } ?> +</ul> diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 8b93461dd..e69de29bb 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,23 +0,0 @@ -<?php - -$output = Minz_Request::param('output', 'normal'); - -if (FreshRSS_Auth::hasAccess() || Minz_Configuration::allowAnonymous()) { - if ($output === 'normal') { - $this->renderHelper('view/normal_view'); - } elseif ($output === 'reader') { - $this->renderHelper('view/reader_view'); - } elseif ($output === 'rss') { - $this->renderHelper('view/rss_view'); - } else { - Minz_Request::_param('output', 'normal'); - $output = 'normal'; - $this->renderHelper('view/normal_view'); - } -} elseif ($output === 'rss') { - // token has already been checked in the controller so we can show the view - $this->renderHelper('view/rss_view'); -} else { - // Normally, it should not happen, but log it anyway - Minz_Log::error('Something is wrong in ' . __FILE__ . ' line ' . __LINE__); -} diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 9cbd367d0..fd2289365 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -7,23 +7,8 @@ if (!empty($this->entries)) { $display_today = true; $display_yesterday = true; $display_others = true; - if (FreshRSS_Auth::hasAccess()) { - $sharing = FreshRSS_Context::$conf->sharing; - } else { - $sharing = array(); - } $hidePosts = !FreshRSS_Context::$conf->display_posts; $lazyload = FreshRSS_Context::$conf->lazyload; - $topline_read = FreshRSS_Context::$conf->topline_read; - $topline_favorite = FreshRSS_Context::$conf->topline_favorite; - $topline_date = FreshRSS_Context::$conf->topline_date; - $topline_link = FreshRSS_Context::$conf->topline_link; - $bottomline_read = FreshRSS_Context::$conf->bottomline_read; - $bottomline_favorite = FreshRSS_Context::$conf->bottomline_favorite; - $bottomline_sharing = FreshRSS_Context::$conf->bottomline_sharing && (count($sharing)); - $bottomline_tags = FreshRSS_Context::$conf->bottomline_tags; - $bottomline_date = FreshRSS_Context::$conf->bottomline_date; - $bottomline_link = FreshRSS_Context::$conf->bottomline_link; $content_width = FreshRSS_Context::$conf->content_width; @@ -35,12 +20,12 @@ if (!empty($this->entries)) { <a href="<?php echo Minz_Url::display(Minz_Request::currentRequest()); ?>"><?php echo _t('new_article'); ?></a> </div><?php foreach ($this->entries as $item) { - $item = Minz_ExtensionManager::callHook('entry_before_display', $item); - if (is_null($item)) { + $this->entry = Minz_ExtensionManager::callHook('entry_before_display', $item); + if (is_null($this->entry)) { continue; } - if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $today)) { + if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) { ?><div class="day" id="day_today"><?php echo _t('today'); ?><span class="date"> — <?php echo timestamptodate(time(), false); ?></span><?php @@ -48,7 +33,7 @@ if (!empty($this->entries)) { ?></div><?php $display_today = false; } - if ($display_yesterday && $item->isDay(FreshRSS_Days::YESTERDAY, $today)) { + if ($display_yesterday && $this->entry->isDay(FreshRSS_Days::YESTERDAY, $today)) { ?><div class="day" id="day_yesterday"><?php echo _t('yesterday'); ?><span class="date"> — <?php echo timestamptodate(time() - 86400, false); ?></span><?php @@ -56,137 +41,35 @@ if (!empty($this->entries)) { ?></div><?php $display_yesterday = false; } - if ($display_others && $item->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { + if ($display_others && $this->entry->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?><div class="day" id="day_before_yesterday"><?php echo _t('before_yesterday'); ?><span class="name"><?php echo FreshRSS_Context::$name; ?></span><?php ?></div><?php $display_others = false; } - ?><div class="flux<?php echo !$item->isRead() ? ' not_read' : ''; ?><?php echo $item->isFavorite() ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id(); ?>"> - <ul class="horizontal-list flux_header"><?php - if (FreshRSS_Auth::hasAccess()) { - if ($topline_read) { - ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $item->id())); - if ($item->isRead()) { - $arUrl['params']['is_read'] = 0; - } - ?><a class="read" href="<?php echo Minz_Url::display($arUrl); ?>"><?php - echo _i($item->isRead() ? 'read' : 'unread'); ?></a><?php - ?></li><?php - } - if ($topline_favorite) { - ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id())); - if ($item->isFavorite()) { - $arUrl['params']['is_favorite'] = 0; - } - ?><a class="bookmark" href="<?php echo Minz_Url::display($arUrl); ?>"><?php - echo _i($item->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php - ?></li><?php - } - } - $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $item->feed()); //We most likely already have the feed object in cache - if ($feed == null) { - $feed = $item->feed(true); - if ($feed == null) { - $feed = FreshRSS_Feed::example(); - } - } - ?><li class="item website"><a href="<?php echo _url('index', 'index', 'get', 'f_' . $feed->id()); ?>"><img class="favicon" src="<?php echo $feed->favicon(); ?>" alt="✇" /> <span><?php echo $feed->name(); ?></span></a></li> - <li class="item title"><a target="_blank" href="<?php echo $item->link(); ?>"><?php echo $item->title(); ?></a></li> - <?php if ($topline_date) { ?><li class="item date"><?php echo $item->date(); ?> </li><?php } ?> - <?php if ($topline_link) { ?><li class="item link"><a target="_blank" href="<?php echo $item->link(); ?>"><?php echo _i('link'); ?></a></li><?php } ?> - </ul> + ?><div class="flux<?php echo !$this->entry->isRead() ? ' not_read' : ''; ?><?php echo $this->entry->isFavorite() ? ' favorite' : ''; ?>" id="flux_<?php echo $this->entry->id(); ?>"><?php + + $this->renderHelper('index/normal/entry_header'); - <div class="flux_content"> + ?><div class="flux_content"> <div class="content <?php echo $content_width; ?>"> - <h1 class="title"><a target="_blank" href="<?php echo $item->link(); ?>"><?php echo $item->title(); ?></a></h1> + <h1 class="title"><a target="_blank" href="<?php echo $this->entry->link(); ?>"><?php echo $this->entry->title(); ?></a></h1> <?php - $author = $item->author(); + $author = $this->entry->author(); echo $author != '' ? '<div class="author">' . _t('by_author', $author) . '</div>' : '', - $lazyload && $hidePosts ? lazyimg($item->content()) : $item->content(); + $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content(); ?> - </div> - <ul class="horizontal-list bottom"><?php - if (FreshRSS_Auth::hasAccess()) { - if ($bottomline_read) { - ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $item->id())); - if ($item->isRead()) { - $arUrl['params']['is_read'] = 0; - } - ?><a class="read" href="<?php echo Minz_Url::display($arUrl); ?>"><?php - echo _i($item->isRead() ? 'read' : 'unread'); ?></a><?php - ?></li><?php - } - if ($bottomline_favorite) { - ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id())); - if ($item->isFavorite()) { - $arUrl['params']['is_favorite'] = 0; - } - ?><a class="bookmark" href="<?php echo Minz_Url::display($arUrl); ?>"><?php - echo _i($item->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php - ?></li><?php - } - } ?> - <li class="item"><?php - if ($bottomline_sharing) { - $link = urlencode($item->link()); - $title = urlencode($item->title() . ' · ' . $feed->name()); - ?><div class="dropdown"> - <div id="dropdown-share-<?php echo $item->id();?>" class="dropdown-target"></div> - <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id();?>"> - <?php echo _i('share'); ?> - <?php echo _t('share'); ?> - </a> + </div><?php - <ul class="dropdown-menu"> - <li class="dropdown-close"><a href="#close">❌</a></li> - <?php foreach ($sharing as $share) :?> - <li class="item share"> - <a target="_blank" href="<?php echo FreshRSS_Share::generateUrl(FreshRSS_Context::$conf->shares, $share, $item->link(), $item->title() . ' . ' . $feed->name())?>"> - <?php echo _t($share['name']);?> - </a> - </li> - <?php endforeach;?> - </ul> - </div> - <?php } ?> - </li><?php - $tags = $bottomline_tags ? $item->tags() : null; - if (!empty($tags)) { - ?><li class="item"> - <div class="dropdown"> - <div id="dropdown-tags-<?php echo $item->id();?>" class="dropdown-target"></div> - <?php echo _i('tag'); ?> - <a class="dropdown-toggle" href="#dropdown-tags-<?php echo $item->id();?>"><?php - echo _t('related_tags'); - ?></a> - <ul class="dropdown-menu"> - <li class="dropdown-close"><a href="#close">❌</a></li><?php - foreach($tags as $tag) { - ?><li class="item"><a href="<?php echo _url('index', 'index', 'search', urlencode('#' . $tag)); ?>"><?php echo $tag; ?></a></li><?php - } ?> - </ul> - </div> - </li><?php - } - if ($bottomline_date) { - ?><li class="item date"><?php echo $item->date(); ?></li><?php - } - if ($bottomline_link) { - ?><li class="item link"><a target="_blank" href="<?php echo $item->link(); ?>"><?php echo _i('link'); ?></a></li><?php - } ?> - </ul> - </div> - </div> - <?php } ?> + $this->renderHelper('index/normal/entry_bottom'); - <?php $this->renderHelper('pagination'); ?> -</div> + ?></div> + </div><?php + } + + $this->renderHelper('pagination'); +?></div> <?php $this->partial('nav_entries'); ?> |
