Skip to content

Commit

Permalink
EOY: Add 2015 support to year-end insight stream
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Nov 30, 2015
1 parent 156d013 commit ea430f7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
2 changes: 1 addition & 1 deletion webapp/2014/index.php
Expand Up @@ -28,5 +28,5 @@
chdir('..');
require_once 'init.php';

$controller = new InsightEOYStreamController();
$controller = new InsightEOYStreamController(false, '2014-11-01');
echo $controller->go();
32 changes: 32 additions & 0 deletions webapp/2015/index.php
@@ -0,0 +1,32 @@
<?php
/**
*
* ThinkUp/webapp/2015/index.php
*
* Copyright (c) 2014-2015 Gina Trapani
*
* LICENSE:
*
* This file is part of ThinkUp (http://thinkup.com).
*
* ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
* later version.
*
* ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with ThinkUp. If not, see
* <http://www.gnu.org/licenses/>.
*
*
* @author Gina Trapani <ginatrapani[at]gmail[dot]com>
* @license http://www.gnu.org/licenses/gpl.html
* @copyright 2014-2015 Gina Trapani
*/
chdir('..');
require_once 'init.php';

$controller = new InsightEOYStreamController(false, '2015-11-01');
echo $controller->go();
2 changes: 1 addition & 1 deletion webapp/_lib/class.Utils.php
Expand Up @@ -264,7 +264,7 @@ public static function validateURL($url) {
* @return str
*/
public static function getSiteRootPathFromFileSystem() {
$dirs_under_root = array('account', 'post', 'session', 'user', 'install', 'tests', 'crawler', '2014');
$dirs_under_root = array('account', 'post', 'session', 'user', 'install', 'tests', 'crawler', '2014', '2015');
if (isset($_SERVER['PHP_SELF'])) {
$current_script_path = explode('/', $_SERVER['PHP_SELF']);
} else {
Expand Down
18 changes: 15 additions & 3 deletions webapp/_lib/controller/class.InsightEOYStreamController.php
Expand Up @@ -36,6 +36,16 @@ class InsightEOYStreamController extends InsightStreamController {
* @var string
*/
var $tpl_name = 'insights-eoy.tpl';
/**
* Show insights since.
* @var str
*/
var $since;

public function __construct($session_started=false, $since=null) {
parent::__construct($session_started);
$this->since = $since;
}
/**
* Load view with data to display page of insights.
*/
Expand All @@ -48,25 +58,27 @@ protected function displayPageOfInsights() {
$this->addToView('tomorrows_teaser', $tomorrows_teaser);

$this->addToView('is_year_end', true);
$this->addToView('year_end_year', substr($this->since, 0, 4));
$insight_dao = DAOFactory::getDAO('InsightDAO');

$page = (isset($_GET['page']) && is_numeric($_GET['page']))?$_GET['page']:1;
if (Session::isLoggedIn()) {
if ($this->isAdmin()) {
///show all insights for all service users
$insights = $insight_dao->getAllInstanceEOYInsights($page_count=(self::PAGE_INSIGHTS_COUNT+1),
$page);
$page, $this->since);
} else {
//show only service users owner owns
$owner_dao = DAOFactory::getDAO('OwnerDAO');
$owner = $owner_dao->getByEmail($this->getLoggedInUser());

$insights = $insight_dao->getAllOwnerInstanceEOYInsights($owner->id,
$page_count=(self::PAGE_INSIGHTS_COUNT+1), $page);
$page_count=(self::PAGE_INSIGHTS_COUNT+1), $page, $this->since);
}
} else {
//show just public service users in stream
$insights = $insight_dao->getPublicEOYInsights($page_count=(self::PAGE_INSIGHTS_COUNT+1), $page);
$insights = $insight_dao->getPublicEOYInsights($page_count=(self::PAGE_INSIGHTS_COUNT+1), $page,
$this->since);
}
if (isset($insights) && sizeof($insights) > 0) {
if (sizeof($insights) == (self::PAGE_INSIGHTS_COUNT+1)) {
Expand Down
8 changes: 4 additions & 4 deletions webapp/_lib/dao/class.InsightMySQLDAO.php
Expand Up @@ -279,16 +279,16 @@ public function getPublicInsights($page_count=10, $page_number=1) {
return self::getInsightsForInstances($page_count, $page_number, $public_only = true);
}

public function getPublicEOYInsights($page_count=10, $page_number=1) {
return self::getEOYInsightsForInstances($page_count, $page_number, $public_only = true);
public function getPublicEOYInsights($page_count=10, $page_number=1, $since='12-01-2014') {
return self::getEOYInsightsForInstances($page_count, $page_number, $public_only = true, 1, $since);
}

public function getAllInstanceInsights($page_count=10, $page_number=1) {
return self::getInsightsForInstances($page_count, $page_number, $public_only = false);
}

public function getAllInstanceEOYInsights($page_count=10, $page_number=1) {
return self::getEOYInsightsForInstances($page_count, $page_number, $public_only = false);
public function getAllInstanceEOYInsights($page_count=10, $page_number=1, $since='12-01-2014') {
return self::getEOYInsightsForInstances($page_count, $page_number, $public_only = false, 1, $since);
}

public function getAllInstanceInsightsSince($since) {
Expand Down
12 changes: 6 additions & 6 deletions webapp/_lib/view/insights.tpl
Expand Up @@ -27,10 +27,10 @@
{/capture}
<div class="stream-yearend-header">
<h1>
<img src="{$site_root_path}assets/img/yearend/calendar-{$img_date|strip|substr:1:8}.png" class="calendar">{if isset($thinkup_username)}{$thinkup_username}'s {else}My {/if}Best of 2014
<img src="{$site_root_path}assets/img/yearend/calendar-{$img_date|strip|substr:1:8}.png" class="calendar">{if isset($thinkup_username)}{$thinkup_username}'s {else}My {/if}Best of {$year_end_year}

<span class="share-buttons">
<a class="btn btn-yearend" href="https://twitter.com/intent/tweet?related=thinkup&amp;text={if isset($thinkup_username)}{$thinkup_username}'s+{else}Your+{/if}Best+of+2014&amp;url={$thinkup_application_url}2014/&amp;via=thinkup"><i class="fa fa-fw fa-twitter"></i></a><a class="btn btn-yearend" href="https://www.facebook.com/sharer.php?u={$thinkup_application_url}2014/"><i class="fa fa-fw fa-facebook"></i></a>
<a class="btn btn-yearend" href="https://twitter.com/intent/tweet?related=thinkup&amp;text={if isset($thinkup_username)}{$thinkup_username}'s+{else}Your+{/if}Best+of+{$year_end_year}&amp;url={$thinkup_application_url}{$year_end_year}/&amp;via=thinkup"><i class="fa fa-fw fa-twitter"></i></a><a class="btn btn-yearend" href="https://www.facebook.com/sharer.php?u={$thinkup_application_url}{$year_end_year}/"><i class="fa fa-fw fa-facebook"></i></a>
</span>
</h1>

Expand Down Expand Up @@ -125,8 +125,8 @@
(isset($i->related_data.hero_image) and $i->emphasis > '1') | $i->slug eq 'weekly_graph'}insight-wide{/if}{if $i->slug|strpos:'eoy_'===0}insight-yearend insight-wide{/if}" id="insight-{$i->id}">
{if $i->slug|strpos:'eoy_'===0}
<div class="insight-yearend-header">
<img src="{$site_root_path}assets/img/thinkup-logo-white.png" alt="ThinkUp" class="logo"> Best of 2014
<a class="btn" href="{$site_root_path}2014/">See more</a>
<img src="{$site_root_path}assets/img/thinkup-logo-white.png" alt="ThinkUp" class="logo"> Best of {$i->date|date_format:"%Y"}
<a class="btn" href="{$site_root_path}{$i->date|date_format:'%Y'}/">See more</a>
</div>
{/if}
<div class="panel-heading{if $i->header_image neq ''} panel-heading-illustrated{/if}">
Expand Down Expand Up @@ -184,12 +184,12 @@
<ul class="pager">
{if $next_page}
<li class="previous">
<a href="{$site_root_path}{if $is_year_end}2014/{else}insights.php{/if}?{if $smarty.get.v}v={$smarty.get.v}&amp;{/if}{if $smarty.get.u}u={$smarty.get.u}&amp;{/if}{if $smarty.get.n}n={$smarty.get.n|urlencode}&amp;{/if}page={$next_page}" id="next_page" class="pull-left btn btn-small"><i class="fa fa-arrow-left"></i> Older</a>
<a href="{$site_root_path}{if $is_year_end}{$year_end_year}/{else}insights.php{/if}?{if $smarty.get.v}v={$smarty.get.v}&amp;{/if}{if $smarty.get.u}u={$smarty.get.u}&amp;{/if}{if $smarty.get.n}n={$smarty.get.n|urlencode}&amp;{/if}page={$next_page}" id="next_page" class="pull-left btn btn-small"><i class="fa fa-arrow-left"></i> Older</a>
</li>
{/if}
{if $last_page}
<li class="next">
<a href="{$site_root_path}{if $is_year_end}2014/{else}insights.php{/if}?{if $smarty.get.v}v={$smarty.get.v}&amp;{/if}{if $smarty.get.u}u={$smarty.get.u}&amp;{/if}{if $smarty.get.n}n={$smarty.get.n|urlencode}&amp;{/if}page={$last_page}" id="last_page" class="pull-right btn btn-small">Newer <i class="fa fa-arrow-right"></i></a>
<a href="{$site_root_path}{if $is_year_end}{$year_end_year}/{else}insights.php{/if}?{if $smarty.get.v}v={$smarty.get.v}&amp;{/if}{if $smarty.get.u}u={$smarty.get.u}&amp;{/if}{if $smarty.get.n}n={$smarty.get.n|urlencode}&amp;{/if}page={$last_page}" id="last_page" class="pull-right btn btn-small">Newer <i class="fa fa-arrow-right"></i></a>
</li>
{/if}
</ul>
Expand Down

0 comments on commit ea430f7

Please sign in to comment.