Convert ALL tabs to 4 spaces across the application.

This commit is contained in:
Buster Neece 2014-06-05 01:48:36 -05:00
parent 4602990c59
commit 2f614ae19c
307 changed files with 17031 additions and 17031 deletions

View File

@ -27,9 +27,9 @@ define("DF_UPLOAD_FOLDER", DF_INCLUDE_STATIC);
// Self-reference to current script.
if (isset($_SERVER['REQUEST_URI']))
define("DF_THIS_PAGE", reset(explode("?", $_SERVER['REQUEST_URI'])));
define("DF_THIS_PAGE", reset(explode("?", $_SERVER['REQUEST_URI'])));
else
define("DF_THIS_PAGE", '');
define("DF_THIS_PAGE", '');
define("DF_TIME", time());
@ -41,9 +41,9 @@ if (!defined('DF_APPLICATION_ENV'))
// Static URL.
if (DF_APPLICATION_ENV == 'production')
define("DF_URL_STATIC", (DF_IS_SECURE ? 'https:' : 'http:').'//ponyvillelive.com/static');
define("DF_URL_STATIC", (DF_IS_SECURE ? 'https:' : 'http:').'//ponyvillelive.com/static');
else
define("DF_URL_STATIC", '/static');
define("DF_URL_STATIC", '/static');
// Set error reporting for the bootstrapping process.
error_reporting(E_ALL & ~E_NOTICE);
@ -56,14 +56,14 @@ $module_config_dirs = array();
$modules = scandir(DF_INCLUDE_MODULES);
foreach($modules as $module)
{
if ($module != '.' && $module != '..')
{
$config_directory = DF_INCLUDE_MODULES.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'config';
if (file_exists($config_directory))
{
$module_config_dirs[$module] = $config_directory;
}
}
if ($module != '.' && $module != '..')
{
$config_directory = DF_INCLUDE_MODULES.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'config';
if (file_exists($config_directory))
{
$module_config_dirs[$module] = $config_directory;
}
}
}
// Set include paths.
@ -81,16 +81,16 @@ $config->preload(array('application','general'));
$module_config = array();
if ($module_config_dirs)
{
foreach($module_config_dirs as $module_name => $config_dir)
$module_config[$module_name] = new \DF\Config($config_dir);
foreach($module_config_dirs as $module_name => $config_dir)
$module_config[$module_name] = new \DF\Config($config_dir);
}
$autoload_classes = $config->application->autoload->toArray();
foreach($autoload_classes['psr0'] as $class_key => $class_dir)
$autoloader->add($class_key, $class_dir);
$autoloader->add($class_key, $class_dir);
foreach($autoload_classes['psr4'] as $class_key => $class_dir)
$autoloader->addPsr4($class_key, $class_dir);
$autoloader->addPsr4($class_key, $class_dir);
// Initialize the ZendFramework Application Bootstrapper.
$application = new \Zend_Application('application', $config->application);

View File

@ -3,70 +3,70 @@ $affiliates = \Entity\Affiliate::fetch(true);
$columns = \DF\Utilities::columns($affiliates, 2);
?>
<div class="footer-inner">
<div class="row-fluid">
<div class="span8">
<div class="headline"><h3>Friends &amp; Affiliates</h3></div>
<div class="row-fluid">
<div class="span8">
<div class="headline"><h3>Friends &amp; Affiliates</h3></div>
<div class="row-fluid">
<? foreach($columns as $column): ?>
<div class="span6">
<ul class="media-list">
<? foreach($column as $affiliate): ?>
<li class="media">
<div class="media-object pull-left">
<a href="<?=$affiliate['web_url'] ?>" target="_blank">
<img src="<?=\DF\Url::content($affiliate['image_url']) ?>" style="width: 40px;">
</a>
</div>
<div class="media-body">
<h4>
<? if (isset($affiliate['custom'])): ?>
<?=$affiliate['custom'] ?><br>
<? else: ?>
<a href="<?=$affiliate['web_url'] ?>" target="_blank"><?=$affiliate['name'] ?></a><br>
<? endif; ?>
<small><?=$affiliate['description'] ?></small>
</h4>
</div>
</li>
<? endforeach; ?>
</ul>
</div>
<? endforeach; ?>
</div>
</div>
<div class="row-fluid">
<? foreach($columns as $column): ?>
<div class="span6">
<ul class="media-list">
<? foreach($column as $affiliate): ?>
<li class="media">
<div class="media-object pull-left">
<a href="<?=$affiliate['web_url'] ?>" target="_blank">
<img src="<?=\DF\Url::content($affiliate['image_url']) ?>" style="width: 40px;">
</a>
</div>
<div class="media-body">
<h4>
<? if (isset($affiliate['custom'])): ?>
<?=$affiliate['custom'] ?><br>
<? else: ?>
<a href="<?=$affiliate['web_url'] ?>" target="_blank"><?=$affiliate['name'] ?></a><br>
<? endif; ?>
<small><?=$affiliate['description'] ?></small>
</h4>
</div>
</li>
<? endforeach; ?>
</ul>
</div>
<? endforeach; ?>
</div>
</div>
<div class="span4">
<div class="headline"><h3>Support PVL</h3></div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ATKJ53AWWRQP4">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br>
<ul class="unstyled">
<li><a href="http://www.zazzle.com/ponyvillelive" target="_blank"><i class="icon-money"></i> Swag Store</a></li>
</ul>
<div class="span4">
<div class="headline"><h3>Support PVL</h3></div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ATKJ53AWWRQP4">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br>
<ul class="unstyled">
<li><a href="http://www.zazzle.com/ponyvillelive" target="_blank"><i class="icon-money"></i> Swag Store</a></li>
</ul>
<div class="headline"><h3>Contact Us</h3></div>
<ul class="unstyled">
<li><a href="mailto:info@ponyvillelive.com"><i class="icon-envelope"></i> General Information</a></li>
<li><a href="mailto:pr@ponyvillelive.com"><i class="icon-envelope"></i> Public Relations</a></li>
<li><a href="mailto:silvereagle@ponyvillelive.com"><i class="icon-envelope"></i> Director, Silver Eagle</a></li>
<li><a href="mailto:weareborg@ponyvillelive.com"><i class="icon-envelope"></i> Associate Director, WeAreBorg</a></li>
</ul>
<div class="headline"><h3>Contact Us</h3></div>
<ul class="unstyled">
<li><a href="mailto:info@ponyvillelive.com"><i class="icon-envelope"></i> General Information</a></li>
<li><a href="mailto:pr@ponyvillelive.com"><i class="icon-envelope"></i> Public Relations</a></li>
<li><a href="mailto:silvereagle@ponyvillelive.com"><i class="icon-envelope"></i> Director, Silver Eagle</a></li>
<li><a href="mailto:weareborg@ponyvillelive.com"><i class="icon-envelope"></i> Associate Director, WeAreBorg</a></li>
</ul>
<div class="headline"><h3>Follow &amp; Like Us</h3></div>
<div class="headline"><h3>Follow &amp; Like Us</h3></div>
<ul class="unstyled">
<li><a href="http://news.ponyvillelive.com/" target="_blank"><img src="<?=\DF\Url::content('social/tumblr_16.png') ?>" alt="Tumblr"> Tumblr</a></li>
<li><a href="https://plus.google.com/+PonyvilleLiveGlobal" rel="publisher" target="_blank"><img src="<?=\DF\Url::content('social/google_plus_16.png') ?>" alt="Google Plus"> Google+</a></li>
<li><a href="https://www.youtube.com/ponyvilleliveglobal" target="_blank"><img src="<?=\DF\Url::content('social/youtube_16.png') ?>" alt="YouTube"> YouTube</a></li>
<li><a href="https://www.facebook.com/pages/Ponyville-LIVE/517435684948331" target="_blank"><img src="<?=\DF\Url::content('social/facebook_16.png') ?>" alt="Facebook"> Facebook</a></li>
<li><a href="https://twitter.com/PonyvilleLive" target="_blank"><img src="<?=\DF\Url::content('social/twitter_16.png') ?>" alt="Twitter"> Twitter</a></li>
<li><a href="http://steamcommunity.com/groups/ponyvillelive" target="_blank"><img src="<?=\DF\Url::content('social/steam_16.png') ?>" alt="Steam"> Steam</a></li>
</ul>
</div>
</div>
<ul class="unstyled">
<li><a href="http://news.ponyvillelive.com/" target="_blank"><img src="<?=\DF\Url::content('social/tumblr_16.png') ?>" alt="Tumblr"> Tumblr</a></li>
<li><a href="https://plus.google.com/+PonyvilleLiveGlobal" rel="publisher" target="_blank"><img src="<?=\DF\Url::content('social/google_plus_16.png') ?>" alt="Google Plus"> Google+</a></li>
<li><a href="https://www.youtube.com/ponyvilleliveglobal" target="_blank"><img src="<?=\DF\Url::content('social/youtube_16.png') ?>" alt="YouTube"> YouTube</a></li>
<li><a href="https://www.facebook.com/pages/Ponyville-LIVE/517435684948331" target="_blank"><img src="<?=\DF\Url::content('social/facebook_16.png') ?>" alt="Facebook"> Facebook</a></li>
<li><a href="https://twitter.com/PonyvilleLive" target="_blank"><img src="<?=\DF\Url::content('social/twitter_16.png') ?>" alt="Twitter"> Twitter</a></li>
<li><a href="http://steamcommunity.com/groups/ponyvillelive" target="_blank"><img src="<?=\DF\Url::content('social/steam_16.png') ?>" alt="Steam"> Steam</a></li>
</ul>
</div>
</div>
</div>

View File

@ -6,39 +6,39 @@ soundManager.debugMode = false;
</script>
<div id="sidebar" class="well">
<ul class="nav nav-list">
<li><a href="<?=$this->route(array('module' => 'mlpma')) ?>" class="ajax"><i class="icon-home"></i> Home</a></li>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'index', 'action' => 'download')) ?>" class="ajax"><i class="icon-download"></i> Download the Archive</a></li>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'submit')) ?>"><i class="icon-plus-sign"></i> Submit a Song </a></li>
<ul class="nav nav-list">
<li><a href="<?=$this->route(array('module' => 'mlpma')) ?>" class="ajax"><i class="icon-home"></i> Home</a></li>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'index', 'action' => 'download')) ?>" class="ajax"><i class="icon-download"></i> Download the Archive</a></li>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'submit')) ?>"><i class="icon-plus-sign"></i> Submit a Song </a></li>
<li class="nav-header">Search the Archive</li>
<li>
<form id="form-search" action="<?=$this->route(array('module' => 'mlpma', 'controller' => 'search', 'origin' => 'header')) ?>" method="get" class="form-inline no-disable">
<input type="text" name="q" title="Search terms" placeholder="Song, Artist, Album..." class="half-width" value="<?=$this->q ?>">
<?=$this->button(array(
'type' => 'submit',
'class' => 'primary btn-small',
'text' => 'Search',
)) ?>
</form>
</li>
<li class="nav-header">Search the Archive</li>
<li>
<form id="form-search" action="<?=$this->route(array('module' => 'mlpma', 'controller' => 'search', 'origin' => 'header')) ?>" method="get" class="form-inline no-disable">
<input type="text" name="q" title="Search terms" placeholder="Song, Artist, Album..." class="half-width" value="<?=$this->q ?>">
<?=$this->button(array(
'type' => 'submit',
'class' => 'primary btn-small',
'text' => 'Search',
)) ?>
</form>
</li>
<li class="nav-header">Top Artists</li>
<li class="nav-header">Top Artists</li>
<li class="nav-header">Top Genres</li>
<?
$genres = \Entity\ArchiveGenre::getTop();
foreach($genres as $genre_id => $genre): ?>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'search', 'genre' => $genre['name'])) ?>" class="ajax"><i class="icon-folder-close"></i> <?=$genre['name'] ?></a></li>
<? endforeach; ?>
<li class="nav-header">Top Genres</li>
<?
$genres = \Entity\ArchiveGenre::getTop();
foreach($genres as $genre_id => $genre): ?>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'search', 'genre' => $genre['name'])) ?>" class="ajax"><i class="icon-folder-close"></i> <?=$genre['name'] ?></a></li>
<? endforeach; ?>
<? if ($this->acl->isAllowed('administer mlpma songs')): ?>
<li class="nav-header">Administration</li>
<? if ($this->acl->isAllowed('administer mlpma songs')): ?>
<li class="nav-header">Administration</li>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'manage', 'action' => 'import')) ?>"><i class="icon-inbox"></i><span>Import New Music</span></a></li>
<li><a href="<?=$this->route(array('module' => 'mlpma', 'controller' => 'manage', 'action' => 'import')) ?>"><i class="icon-inbox"></i><span>Import New Music</span></a></li>
<? endif; ?>
<? endif; ?>
</ul>
</ul>
</div>

View File

@ -5,48 +5,48 @@ $podcasts = \Entity\Podcast::fetchArray('name');
<ul class="nav primary_menu">
<!-- About PVL -->
<li class="dropdown">
<a href="<?=$this->route(array('controller' => 'about')) ?>"><i class="icon-info-sign"></i> About</a>
<ul class="dropdown-menu">
<li><a href="<?=$this->route(array('controller' => 'about')) ?>"><i class="icon-info-sign"></i> About Ponyville Live!</a></li>
<li><a href="<?=$this->route(array('controller' => 'events')) ?>"><i class="icon-group"></i> Conventions</a></li>
<li><a href="<?=$this->route(array('controller' => 'events', 'action' => 'schedule')) ?>"><i class="icon-calendar"></i> Station Schedules</a></li>
<li class="divider"></li>
<li><a href="<?=$this->route(array('action' => 'app')) ?>"><i class="icon-cloud-download"></i> Plugins &amp; Apps</a></li>
<li><a href="http://docs.ponyvillelive.apiary.io/" target="_blank"><i class="icon-cog"></i> PVL Data API</a></li>
<li class="divider"></li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ATKJ53AWWRQP4" target="_blank"><i class="icon-money"></i> Donate to Support PVL!</a></li>
</ul>
</li>
<!-- Stations -->
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="icon-music"></i> Radio</a>
<ul class="dropdown-menu">
<? foreach($categories['audio']['stations'] as $station): ?>
<li><a href="<?=$station['web_url'] ?>" title="<?=$station['genre'] ?>" target="_blank"><?=$station['name'] ?></a></li>
<? endforeach; ?>
</ul>
</li>
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="icon-facetime-video"></i> Video</a>
<ul class="dropdown-menu">
<? foreach($categories['video']['stations'] as $station): ?>
<li><a href="<?=$station['web_url'] ?>" title="<?=$station['genre'] ?>" target="_blank"><?=$station['name'] ?></a></li>
<? endforeach; ?>
</ul>
</li>
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="icon-rss"></i> Shows</a>
<ul class="dropdown-menu">
<li><a href="<?=$this->route(array('controller' => 'show')) ?>">Show Directory</a></li>
<li class="divider"></li>
<? foreach($podcasts as $podcast): ?>
<li><a href="<?=$podcast['web_url'] ?>" title="<?=$podcast['description'] ?>" target="_blank"><?=$podcast['name'] ?></a></li>
<? endforeach; ?>
</ul>
</li>
<!-- About PVL -->
<li class="dropdown">
<a href="<?=$this->route(array('controller' => 'about')) ?>"><i class="icon-info-sign"></i> About</a>
<ul class="dropdown-menu">
<li><a href="<?=$this->route(array('controller' => 'about')) ?>"><i class="icon-info-sign"></i> About Ponyville Live!</a></li>
<li><a href="<?=$this->route(array('controller' => 'events')) ?>"><i class="icon-group"></i> Conventions</a></li>
<li><a href="<?=$this->route(array('controller' => 'events', 'action' => 'schedule')) ?>"><i class="icon-calendar"></i> Station Schedules</a></li>
<li class="divider"></li>
<li><a href="<?=$this->route(array('action' => 'app')) ?>"><i class="icon-cloud-download"></i> Plugins &amp; Apps</a></li>
<li><a href="http://docs.ponyvillelive.apiary.io/" target="_blank"><i class="icon-cog"></i> PVL Data API</a></li>
<li class="divider"></li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ATKJ53AWWRQP4" target="_blank"><i class="icon-money"></i> Donate to Support PVL!</a></li>
</ul>
</li>
<!-- Stations -->
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="icon-music"></i> Radio</a>
<ul class="dropdown-menu">
<? foreach($categories['audio']['stations'] as $station): ?>
<li><a href="<?=$station['web_url'] ?>" title="<?=$station['genre'] ?>" target="_blank"><?=$station['name'] ?></a></li>
<? endforeach; ?>
</ul>
</li>
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="icon-facetime-video"></i> Video</a>
<ul class="dropdown-menu">
<? foreach($categories['video']['stations'] as $station): ?>
<li><a href="<?=$station['web_url'] ?>" title="<?=$station['genre'] ?>" target="_blank"><?=$station['name'] ?></a></li>
<? endforeach; ?>
</ul>
</li>
<li class="dropdown">
<a href="#" data-toggle="dropdown"><i class="icon-rss"></i> Shows</a>
<ul class="dropdown-menu">
<li><a href="<?=$this->route(array('controller' => 'show')) ?>">Show Directory</a></li>
<li class="divider"></li>
<? foreach($podcasts as $podcast): ?>
<li><a href="<?=$podcast['web_url'] ?>" title="<?=$podcast['description'] ?>" target="_blank"><?=$podcast['name'] ?></a></li>
<? endforeach; ?>
</ul>
</li>
<li><a href="<?=$this->route(array('action' => 'index', 'mode' => 'chat')) ?>"><i class="icon-comment"></i> Chat</a></li>
<li><a href="<?=$this->route(array('action' => 'index', 'mode' => 'chat')) ?>"><i class="icon-comment"></i> Chat</a></li>
</ul>

View File

@ -1,31 +1,31 @@
<ul class="media-list">
<? foreach($this->podcasts as $podcast_info): ?>
<?
$podcast = $podcast_info['record'];
$episodes = $podcast_info['episodes'];
$ep = $episodes[0];
?>
<li class="media podcast">
<div class="media-object pull-left">
<a href="<?=$this->routeFromHere(array('action' => 'podcast', 'id' => $podcast->id)) ?>" class="fancybox fancybox.ajax">
<img class="station-image" src="<?=\DF\Url::content($podcast->image_url) ?>" style="width: 40px;">
<div class="station-play-button">
<i class="icon-rss"></i>
</div>
</a>
</div>
<div class="media-body">
<div class="station-info">
<h4><?=$podcast->name ?><br>
<span class="genre-info"><small>
<?=$podcast->description ?>
</small></span>
</h4>
<?
$podcast = $podcast_info['record'];
$episodes = $podcast_info['episodes'];
$ep = $episodes[0];
?>
<li class="media podcast">
<div class="media-object pull-left">
<a href="<?=$this->routeFromHere(array('action' => 'podcast', 'id' => $podcast->id)) ?>" class="fancybox fancybox.ajax">
<img class="station-image" src="<?=\DF\Url::content($podcast->image_url) ?>" style="width: 40px;">
<div class="station-play-button">
<i class="icon-rss"></i>
</div>
</a>
</div>
<div class="media-body">
<div class="station-info">
<h4><?=$podcast->name ?><br>
<span class="genre-info"><small>
<?=$podcast->description ?>
</small></span>
</h4>
<small>Newest Episode (<?=date('F j, Y', $ep['timestamp']) ?>):</small><br>
<a href="<?=$ep['web_url'] ?>" target="_blank"><b><?=$ep['title'] ?></b></a>
</div>
</div>
</li>
<small>Newest Episode (<?=date('F j, Y', $ep['timestamp']) ?>):</small><br>
<a href="<?=$ep['web_url'] ?>" target="_blank"><b><?=$ep['title'] ?></b></a>
</div>
</div>
</li>
<? endforeach; ?>
</ul>

View File

@ -1,122 +1,122 @@
<ul class="media-list" style="padding-bottom: 0; margin-bottom: 0;">
<? foreach((array)$this->stations as $station): ?>
<li class="media station clearfix rendermode-<?=$this->render_mode ?>" id="station_<?=\Entity\Station::getStationShortName($station['name']) ?>"
data-id="<?=$station['id'] ?>"
data-name="<?=$station['name'] ?>"
data-type="<?=$station['type'] ?>"
data-stream="<?=$station['stream_url'] ?>"
data-image="<?=\DF\Url::content($station['image_url']) ?>"
data-chat="<?=$station['irc'] ?>"
data-inactive="<? if ($station['hide_if_inactive']): ?>hide<? else: ?>show<? endif; ?>"
data-historyid="0"
style="margin-top: 0;">
<li class="media station clearfix rendermode-<?=$this->render_mode ?>" id="station_<?=\Entity\Station::getStationShortName($station['name']) ?>"
data-id="<?=$station['id'] ?>"
data-name="<?=$station['name'] ?>"
data-type="<?=$station['type'] ?>"
data-stream="<?=$station['stream_url'] ?>"
data-image="<?=\DF\Url::content($station['image_url']) ?>"
data-chat="<?=$station['irc'] ?>"
data-inactive="<? if ($station['hide_if_inactive']): ?>hide<? else: ?>show<? endif; ?>"
data-historyid="0"
style="margin-top: 0;">
<!-- Station Like/Share Buttons -->
<div class="show-when-playing station-link buttons btn-toolbar pull-right">
<div class="btn-group">
<a href="#" class="btn btn-small btn-inverse dropdown-toggle" type="button" data-toggle="dropdown"><i class="icon-reorder"></i></a>
<ul class="dropdown-menu">
<? if ($station['requests_enabled']): ?>
<li><a href="<?=$this->route(array('controller' => 'station', 'action' => 'request', 'id' => $station['id'])) ?>" target="_blank"><i class="icon-question-sign"></i> Request a Song</a></li>
<? endif; ?>
<li><a href="#" class="btn-show-history"><i class="icon-time"></i> Recently Played</a></li>
<li><a href="<?=$station['web_url'] ?>" target="_blank"><i class="icon-globe"></i> Station Site</a></li>
<li><a href="<?=$this->route(array('controller' => 'station', 'action' => 'playlist', 'format' => 'pls', 'id' => $station['id'])) ?>"><i class="icon-download"></i> Download PLS</a></li>
</ul>
</div>
</div>
<!-- Station Like/Share Buttons -->
<div class="show-when-playing station-link buttons btn-toolbar pull-right">
<div class="btn-group">
<a href="#" class="btn btn-small btn-inverse dropdown-toggle" type="button" data-toggle="dropdown"><i class="icon-reorder"></i></a>
<ul class="dropdown-menu">
<? if ($station['requests_enabled']): ?>
<li><a href="<?=$this->route(array('controller' => 'station', 'action' => 'request', 'id' => $station['id'])) ?>" target="_blank"><i class="icon-question-sign"></i> Request a Song</a></li>
<? endif; ?>
<li><a href="#" class="btn-show-history"><i class="icon-time"></i> Recently Played</a></li>
<li><a href="<?=$station['web_url'] ?>" target="_blank"><i class="icon-globe"></i> Station Site</a></li>
<li><a href="<?=$this->route(array('controller' => 'station', 'action' => 'playlist', 'format' => 'pls', 'id' => $station['id'])) ?>"><i class="icon-download"></i> Download PLS</a></li>
</ul>
</div>
</div>
<div class="media-object pull-left center">
<div><img class="station-image" src="<?=\DF\Url::content($station['image_url']) ?>"></div>
<div class="show-when-playing vote-wrapper">
<a href="<?=$this->route(array('module' => 'default', 'controller' => 'song')) ?>" class="btn-like" title="Like This Song"><i class="icon-thumbs-up"></i></a>
<div class="nowplaying-score" data-original="0">0</div>
<a href="<?=$this->route(array('module' => 'default', 'controller' => 'song')) ?>" class="btn-dislike" title="Dislike This Song"><i class="icon-thumbs-down"></i></a>
</div>
</div>
<div class="media-object pull-left center">
<div><img class="station-image" src="<?=\DF\Url::content($station['image_url']) ?>"></div>
<div class="show-when-playing vote-wrapper">
<a href="<?=$this->route(array('module' => 'default', 'controller' => 'song')) ?>" class="btn-like" title="Like This Song"><i class="icon-thumbs-up"></i></a>
<div class="nowplaying-score" data-original="0">0</div>
<a href="<?=$this->route(array('module' => 'default', 'controller' => 'song')) ?>" class="btn-dislike" title="Dislike This Song"><i class="icon-thumbs-down"></i></a>
</div>
</div>
<div class="media-body">
<div class="station-info">
<!-- Station Header -->
<h4>
<? if ($station['nickname']): ?>
<?=$station['nickname'] ?>
<? else: ?>
<?=$station['name'] ?>
<? endif; ?>
<span class="nowplaying-info">
<small>
<span class="nowplaying-live">Live! &bull; </span>
<span class="nowplaying-listeners"></span>
<span class="nowplaying-status"> &bull; Now Playing</span>
</small>
</span>
<? if ($station['genre']): ?>
<span class="genre-info">
<small>
<?=$station['genre'] ?>
</small>
</span>
<? endif; ?>
</h4>
<div class="media-body">
<div class="station-info">
<!-- Station Header -->
<h4>
<? if ($station['nickname']): ?>
<?=$station['nickname'] ?>
<? else: ?>
<?=$station['name'] ?>
<? endif; ?>
<span class="nowplaying-info">
<small>
<span class="nowplaying-live">Live! &bull; </span>
<span class="nowplaying-listeners"></span>
<span class="nowplaying-status"> &bull; Now Playing</span>
</small>
</span>
<? if ($station['genre']): ?>
<span class="genre-info">
<small>
<?=$station['genre'] ?>
</small>
</span>
<? endif; ?>
</h4>
<? if ($station['now']): ?>
<div class="nowplaying-onair">
<i class="icon-star"></i> On Air: <?=$station['now']['title'] ?>
</div>
<? else: ?>
<div class="nowplaying-onair" style="display: none;"></div>
<? endif; ?>
<? if ($station['now']): ?>
<div class="nowplaying-onair">
<i class="icon-star"></i> On Air: <?=$station['now']['title'] ?>
</div>
<? else: ?>
<div class="nowplaying-onair" style="display: none;"></div>
<? endif; ?>
<div class="show-when-playing">
<div class="station-player-container"></div>
</div>
<div class="show-when-playing">
<div class="station-player-container"></div>
</div>
<!-- Now Playing Information -->
<div><big><span class="nowplaying-artist">Loading...</span></big></div>
<div><span class="nowplaying-title">Loading...</span></div>
<!-- Now Playing Information -->
<div><big><span class="nowplaying-artist">Loading...</span></big></div>
<div><span class="nowplaying-title">Loading...</span></div>
<div class="station-history" style="display: none;"></div>
</div>
<div class="station-history" style="display: none;"></div>
</div>
<? /*
<div class="station-player show-when-playing">
<? /*
<div class="station-player show-when-playing">
<!-- Station Links -->
<div class="station-link buttons btn-toolbar">
<div class="btn-group">
<? if ($this->render_mode != 'embed'): ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-thumbs-up',
'text' => 'Like',
'href' => $this->route(array('action' => 'like', 'origin' => 'pvl')),
'class' => 'btn-success btn-like',
)) ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-facebook',
'title' => 'Share on Facebook',
'href' => '#',
'class' => 'btn-icon-only btn-primary btn-share-station btn-share-facebook',
)) ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-twitter',
'title' => 'Share on Twitter',
'href' => '#',
'class' => 'btn-icon-only btn-primary btn-share-station btn-share-twitter',
)) ?>
<!-- Station Links -->
<div class="station-link buttons btn-toolbar">
<div class="btn-group">
<? if ($this->render_mode != 'embed'): ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-thumbs-up',
'text' => 'Like',
'href' => $this->route(array('action' => 'like', 'origin' => 'pvl')),
'class' => 'btn-success btn-like',
)) ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-facebook',
'title' => 'Share on Facebook',
'href' => '#',
'class' => 'btn-icon-only btn-primary btn-share-station btn-share-facebook',
)) ?>
<?=$this->button(array(
'type' => 'small',
'icon' => 'icon-twitter',
'title' => 'Share on Twitter',
'href' => '#',
'class' => 'btn-icon-only btn-primary btn-share-station btn-share-twitter',
)) ?>
</div>
</div>
</div>
</div>
</div>
*/ ?>
</div>
</li>
</div>
*/ ?>
</div>
</li>
<? endforeach; ?>
</ul>

View File

@ -2,39 +2,39 @@
$skin = \PVL\Customization::get('theme');
?>
<ul class="loginbar pull-right">
<?
$tz_info = \PVL\Timezone::getInfo();
$tz_text = $tz_info['now']->format('g:ia').' '.$tz_info['abbr'];
?>
<li><a href="<?=$this->route(array('controller' => 'account', 'action' => 'timezone')) ?>" class="fancybox fancybox.ajax"><i class="icon-time"></i> <?=$tz_text ?></a></li>
<li class="divider">&nbsp;</li>
<li><a href="<?=$this->route(array('controller' => 'account', 'action' => 'theme', 'skin' => 'toggle')) ?>"><i class="icon-adjust"></i> <? if ($skin == 'light'): ?>Dark Theme<? else: ?>Light Theme<? endif; ?></a></li>
<li class="divider">&nbsp;</li>
<li><a href="<?=$this->route(array('module' => 'mobile')) ?>" class="btn-tune-in"><i class="icon-youtube-play"></i> Player</a></li>
<li class="divider">&nbsp;</li>
<!--
<li><a href="<?=$this->route(array('module' => 'default', 'controller' => 'index', 'action' => 'app')) ?>"><i class="icon-cloud-download"></i> Plugins &amp; Apps</a></li>
<li class="divider">&nbsp;</li>
-->
<?
$tz_info = \PVL\Timezone::getInfo();
$tz_text = $tz_info['now']->format('g:ia').' '.$tz_info['abbr'];
?>
<li><a href="<?=$this->route(array('controller' => 'account', 'action' => 'timezone')) ?>" class="fancybox fancybox.ajax"><i class="icon-time"></i> <?=$tz_text ?></a></li>
<li class="divider">&nbsp;</li>
<li><a href="<?=$this->route(array('controller' => 'account', 'action' => 'theme', 'skin' => 'toggle')) ?>"><i class="icon-adjust"></i> <? if ($skin == 'light'): ?>Dark Theme<? else: ?>Light Theme<? endif; ?></a></li>
<li class="divider">&nbsp;</li>
<li><a href="<?=$this->route(array('module' => 'mobile')) ?>" class="btn-tune-in"><i class="icon-youtube-play"></i> Player</a></li>
<li class="divider">&nbsp;</li>
<!--
<li><a href="<?=$this->route(array('module' => 'default', 'controller' => 'index', 'action' => 'app')) ?>"><i class="icon-cloud-download"></i> Plugins &amp; Apps</a></li>
<li class="divider">&nbsp;</li>
-->
<? if ($this->auth->isLoggedIn()): ?>
<?
$user = $this->auth->getLoggedInUser();
?>
<? if ($this->acl->isAllowed('view administration')): ?>
<li><a href="<?=$this->route(array('module' => 'admin')) ?>"><i class="icon-cog"></i> Admin</a></li>
<li class="divider">&nbsp;</li>
<? endif; ?>
<? if (\Entity\Station::canSeeStationCenter($user)): ?>
<li><a href="<?=$this->route(array('module' => 'stations')) ?>"><i class="icon-group"></i> Station Center</a></li>
<li class="divider">&nbsp;</li>
<? endif; ?>
<li><b><?=$user->name ?></b></li>
<? if ($this->auth->isMasqueraded()): ?>
<li><a href="<?=$this->route(array('module' => 'account', 'controller' => 'logout', 'action' => 'endimpersonate')) ?>"><i class="icon-signout"></i> Switch User</a></li>
<? else: ?>
<li><a href="<?=$this->route(array('module' => 'account', 'controller' => 'logout')) ?>"><i class="icon-signout"></i> Sign Out</a></li>
<? endif; ?>
<?
$user = $this->auth->getLoggedInUser();
?>
<? if ($this->acl->isAllowed('view administration')): ?>
<li><a href="<?=$this->route(array('module' => 'admin')) ?>"><i class="icon-cog"></i> Admin</a></li>
<li class="divider">&nbsp;</li>
<? endif; ?>
<? if (\Entity\Station::canSeeStationCenter($user)): ?>
<li><a href="<?=$this->route(array('module' => 'stations')) ?>"><i class="icon-group"></i> Station Center</a></li>
<li class="divider">&nbsp;</li>
<? endif; ?>
<li><b><?=$user->name ?></b></li>
<? if ($this->auth->isMasqueraded()): ?>
<li><a href="<?=$this->route(array('module' => 'account', 'controller' => 'logout', 'action' => 'endimpersonate')) ?>"><i class="icon-signout"></i> Switch User</a></li>
<? else: ?>
<li><a href="<?=$this->route(array('module' => 'account', 'controller' => 'logout')) ?>"><i class="icon-signout"></i> Sign Out</a></li>
<? endif; ?>
<? else: ?>
<li><a href="<?=$this->route(array('module' => 'default', 'controller' => 'account', 'action' => 'login')) ?>"><i class="icon-signin"></i> Sign In</a></li>
<li><a href="<?=$this->route(array('module' => 'default', 'controller' => 'account', 'action' => 'login')) ?>"><i class="icon-signin"></i> Sign In</a></li>
<? endif; ?>
</ul>

View File

@ -5,94 +5,94 @@
return array(
// Mandrill SMTP service.
'smtp' => array(
'server' => 'smtp.mandrillapp.com',
'port' => '587',
'auth' => 'login',
'username' => '',
'password' => '',
),
// Mandrill SMTP service.
'smtp' => array(
'server' => 'smtp.mandrillapp.com',
'port' => '587',
'auth' => 'login',
'username' => '',
'password' => '',
),
// YouTube v3 API key.
'youtube_v3' => '',
// YouTube v3 API key.
'youtube_v3' => '',
// Twitter API settings.
'twitter' => array(
'consumer_key' => '',
'consumer_secret' => '',
'user_token' => '',
'user_secret' => '',
// Twitter API settings.
'twitter' => array(
'consumer_key' => '',
'consumer_secret' => '',
'user_token' => '',
'user_secret' => '',
'curl_ssl_verifyhost' => 0,
'curl_ssl_verifypeer' => false,
),
'curl_ssl_verifyhost' => 0,
'curl_ssl_verifypeer' => false,
),
// Hybrid/oAuth API settings.
'hybrid_auth' => array(
'base_url' => \DF\Url::baseUrl(TRUE),
// Hybrid/oAuth API settings.
'hybrid_auth' => array(
'base_url' => \DF\Url::baseUrl(TRUE),
// Enable debug mode (specify "debug_file" below).
'debug_mode' => false,
'debug_file' => '',
// Enable debug mode (specify "debug_file" below).
'debug_mode' => false,
'debug_file' => '',
'providers' => array (
"OpenID" => array (
"enabled" => true
),
'providers' => array (
"OpenID" => array (
"enabled" => true
),
"Google" => array (
"enabled" => true,
"keys" => array(
"id" => "",
"secret" => "",
),
),
"Google" => array (
"enabled" => true,
"keys" => array(
"id" => "",
"secret" => "",
),
),
"Facebook" => array (
"enabled" => true,
"keys" => array(
"id" => "",
"secret" => ""
),
"scope" => "email, user_about_me", // optional
),
"Facebook" => array (
"enabled" => true,
"keys" => array(
"id" => "",
"secret" => ""
),
"scope" => "email, user_about_me", // optional
),
"Twitter" => array (
"enabled" => true,
"keys" => array(
"key" => "",
"secret" => "",
),
),
"Twitter" => array (
"enabled" => true,
"keys" => array(
"key" => "",
"secret" => "",
),
),
"Tumblr" => array (
"enabled" => true,
"keys" => array(
"key" => "",
"secret" => ""
),
),
),
),
"Tumblr" => array (
"enabled" => true,
"keys" => array(
"key" => "",
"secret" => ""
),
),
),
),
// CentovaCast API settings.
'centovacast' => array(
// IP or hostname of the CentovaCast server.
'host' => '198.27.112.218',
// CentovaCast API settings.
'centovacast' => array(
// IP or hostname of the CentovaCast server.
'host' => '198.27.112.218',
'db_user' => 'centova',
'db_pass' => '',
'db_name' => 'centova',
'db_user' => 'centova',
'db_pass' => '',
'db_name' => 'centova',
// Time zone to use when submitting requests.
'timezone' => 'US/Eastern',
),
// Time zone to use when submitting requests.
'timezone' => 'US/Eastern',
),
// ReCAPTCHA Service keys.
'recaptcha' => array(
'public_key' => '',
'private_key' => '',
),
// ReCAPTCHA Service keys.
'recaptcha' => array(
'public_key' => '',
'private_key' => '',
),
);

View File

@ -6,102 +6,102 @@
$session_lifetime = 86400*7;
$config = array(
// Application name
'name' => 'Ponyville Live!',
'analytics_code' => 'UA-37359273-1',
// Primary application web address
'base_url' => (DF_IS_SECURE ? 'https' : 'http').'://'.($_SERVER["HTTP_HOST"] ? $_SERVER["HTTP_HOST"] : 'ponyvillelive.com'),
// DF Messenger mail settings
'mail' => array(
'templates' => DF_INCLUDE_BASE.'/messages',
// Application name
'name' => 'Ponyville Live!',
'analytics_code' => 'UA-37359273-1',
// Primary application web address
'base_url' => (DF_IS_SECURE ? 'https' : 'http').'://'.($_SERVER["HTTP_HOST"] ? $_SERVER["HTTP_HOST"] : 'ponyvillelive.com'),
// DF Messenger mail settings
'mail' => array(
'templates' => DF_INCLUDE_BASE.'/messages',
'from_addr' => 'info@ponyvillelive.com',
'from_name' => 'Ponyville Live!',
'use_smtp' => true,
'use_smtp' => true,
),
'phpSettings' => array(
'display_startup_errors' => 0,
'display_errors' => 0,
'log_errors' => 1,
'error_log' => DF_INCLUDE_TEMP.'/php_errors.log',
'error_reporting' => E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT,
'session' => array(
'save_path' => DF_INCLUDE_TEMP.DIRECTORY_SEPARATOR.'sessions',
'gc_maxlifetime' => $session_lifetime,
'cookie_lifetime' => $session_lifetime,
),
),
'bootstrap' => array(
'path' => 'DF/Application/Bootstrap.php',
'class' => '\DF\Application\Bootstrap',
),
'includePaths' => array(
DF_INCLUDE_LIB.'/ThirdParty',
'phpSettings' => array(
'display_startup_errors' => 0,
'display_errors' => 0,
'log_errors' => 1,
'error_log' => DF_INCLUDE_TEMP.'/php_errors.log',
'error_reporting' => E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT,
'session' => array(
'save_path' => DF_INCLUDE_TEMP.DIRECTORY_SEPARATOR.'sessions',
'gc_maxlifetime' => $session_lifetime,
'cookie_lifetime' => $session_lifetime,
),
),
'bootstrap' => array(
'path' => 'DF/Application/Bootstrap.php',
'class' => '\DF\Application\Bootstrap',
),
'includePaths' => array(
DF_INCLUDE_LIB.'/ThirdParty',
),
'pluginpaths' => array(
'DF\Application\Resource\\' => 'DF/Application/Resource',
),
'pluginpaths' => array(
'DF\Application\Resource\\' => 'DF/Application/Resource',
),
'autoload' => array(
'psr0' => array(
'DF' => DF_INCLUDE_LIB,
'PVL' => DF_INCLUDE_LIB,
'Entity' => DF_INCLUDE_MODELS,
'Hybrid' => DF_INCLUDE_LIB.'/ThirdParty',
'Hybrid_' => DF_INCLUDE_LIB.'/ThirdParty/Hybrid',
'psr0' => array(
'DF' => DF_INCLUDE_LIB,
'PVL' => DF_INCLUDE_LIB,
'Entity' => DF_INCLUDE_MODELS,
'Hybrid' => DF_INCLUDE_LIB.'/ThirdParty',
'Hybrid_' => DF_INCLUDE_LIB.'/ThirdParty/Hybrid',
),
'psr4' => array(
'\\Proxy\\' => DF_INCLUDE_TEMP.'/proxies',
'psr4' => array(
'\\Proxy\\' => DF_INCLUDE_TEMP.'/proxies',
),
),
),
'resources' => array(
/* RESOURCES: Locale */
'locale' => array(
'default' => 'en_US',
),
/* RESOURCES: Front Controller */
'frontController' => array(
'throwerrors' => true,
'moduleDirectory' => DF_INCLUDE_MODULES,
'moduleControllerDirectoryName' => "controllers",
'defaultModule' => "default",
'defaultAction' => "index",
'defaultControllerName' => "index",
),
/* RESOURCES: Doctrine ORM Layer */
'doctrine' => array(
'resources' => array(
/* RESOURCES: Locale */
'locale' => array(
'default' => 'en_US',
),
/* RESOURCES: Front Controller */
'frontController' => array(
'throwerrors' => true,
'moduleDirectory' => DF_INCLUDE_MODULES,
'moduleControllerDirectoryName' => "controllers",
'defaultModule' => "default",
'defaultAction' => "index",
'defaultControllerName' => "index",
),
/* RESOURCES: Doctrine ORM Layer */
'doctrine' => array(
'autoGenerateProxies' => (DF_APPLICATION_ENV == "development"),
'proxyNamespace' => 'Proxy',
'proxyPath' => DF_INCLUDE_TEMP.'/proxies',
'modelPath' => DF_INCLUDE_MODELS,
),
/* RESOURCES: Menu */
'menu' => array(
'enabled' => true,
),
/* RESOURCES: Layout */
'layout' => array(
'layout' => 'default',
'layoutPath' => DF_INCLUDE_APP.'/layouts',
'commonTemplates' => DF_INCLUDE_BASE.'/common',
),
),
/* RESOURCES: Menu */
'menu' => array(
'enabled' => true,
),
/* RESOURCES: Layout */
'layout' => array(
'layout' => 'default',
'layoutPath' => DF_INCLUDE_APP.'/layouts',
'commonTemplates' => DF_INCLUDE_BASE.'/common',
),
/* RESOURCES: Session */
'session' => array(
'use_only_cookies' => true,
'remember_me_seconds' => $session_lifetime,
),
),
/* RESOURCES: Session */
'session' => array(
'use_only_cookies' => true,
'remember_me_seconds' => $session_lifetime,
),
),
);
/**
@ -110,10 +110,10 @@ $config = array(
if (DF_APPLICATION_ENV != 'production')
{
$config['phpSettings']['display_startup_errors'] = 1;
$config['phpSettings']['display_errors'] = 1;
$config['phpSettings']['display_startup_errors'] = 1;
$config['phpSettings']['display_errors'] = 1;
unset($config['base_url']);
unset($config['base_url']);
}
return $config;

View File

@ -4,10 +4,10 @@
*/
return array(
// Backend driver to use with the database.
'driver' => 'pdo_mysql',
// Backend driver to use with the database.
'driver' => 'pdo_mysql',
// Host or IP to connect to (default: localhost).
// Host or IP to connect to (default: localhost).
'host' => 'localhost',
// Name of the primary application database.
@ -24,6 +24,6 @@ return array(
// Other options to send to the PDO adapter for the database.
'driverOptions' => array(
1002 => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci',
1002 => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci',
),
);

View File

@ -7,94 +7,94 @@ define('DF_OPT_NO', 0);
define('DF_OPT_YES', 1);
return array(
// Yes/no options.
'opts_yesno' => array(
DF_OPT_NO => 'No',
DF_OPT_YES => 'Yes',
),
// Yes/no options.
'opts_yesno' => array(
DF_OPT_NO => 'No',
DF_OPT_YES => 'Yes',
),
// Gender options.
'opts_gender' => array(
'M' => 'Male',
'F' => 'Female',
),
'opts_gender' => array(
'M' => 'Male',
'F' => 'Female',
),
// Month options.
'months' => array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December',
),
'months' => array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December',
),
// US State options.
'states' => array(
'AK' => 'Alaska',
'AL' => 'Alabama',
'AR' => 'Arkansas',
'AS' => 'American Samoa',
'AZ' => 'Arizona',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DC' => 'D.C.',
'DE' => 'Delaware',
'FL' => 'Florida',
'FM' => 'Micronesia',
'GA' => 'Georgia',
'GU' => 'Guam',
'HI' => 'Hawaii',
'IA' => 'Iowa',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'MA' => 'Massachusetts',
'MD' => 'Maryland',
'ME' => 'Maine',
'MH' => 'Marshall Islands',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MO' => 'Missouri',
'MP' => 'Marianas',
'MS' => 'Mississippi',
'MT' => 'Montana',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'NE' => 'Nebraska',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NV' => 'Nevada',
'NY' => 'New York',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'PR' => 'Puerto Rico',
'PW' => 'Palau',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VA' => 'Virginia',
'VI' => 'Virgin Islands',
'VT' => 'Vermont',
'WA' => 'Washington',
'WI' => 'Wisconsin',
'WV' => 'West Virginia',
'WY' => 'Wyoming',
),
'states' => array(
'AK' => 'Alaska',
'AL' => 'Alabama',
'AR' => 'Arkansas',
'AS' => 'American Samoa',
'AZ' => 'Arizona',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DC' => 'D.C.',
'DE' => 'Delaware',
'FL' => 'Florida',
'FM' => 'Micronesia',
'GA' => 'Georgia',
'GU' => 'Guam',
'HI' => 'Hawaii',
'IA' => 'Iowa',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'MA' => 'Massachusetts',
'MD' => 'Maryland',
'ME' => 'Maine',
'MH' => 'Marshall Islands',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MO' => 'Missouri',
'MP' => 'Marianas',
'MS' => 'Mississippi',
'MT' => 'Montana',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'NE' => 'Nebraska',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NV' => 'Nevada',
'NY' => 'New York',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'PR' => 'Puerto Rico',
'PW' => 'Palau',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VA' => 'Virginia',
'VI' => 'Virgin Islands',
'VT' => 'Vermont',
'WA' => 'Washington',
'WI' => 'Wisconsin',
'WV' => 'West Virginia',
'WY' => 'Wyoming',
),
);

View File

@ -1,10 +1,10 @@
<?php
return array(
// Default theme used to render PVL site.
'default_theme' => 'light',
// Default theme used to render PVL site.
'default_theme' => 'light',
'customization_defaults' => array(
'theme' => 'light',
'timezone' => 'America/New_York',
),
'customization_defaults' => array(
'theme' => 'light',
'timezone' => 'America/New_York',
),
);

View File

@ -31,43 +31,43 @@ $this->headTitle($this->config->application->name);
if (count($title_items) == 1)
{
$this->headTitle()->append('Bringing Pony People Together');
$this->headTitle()->append('24/7 Pony Radio, Video, Podcasts, Convention Coverage & More');
$this->headTitle()->append('Bringing Pony People Together');
$this->headTitle()->append('24/7 Pony Radio, Video, Podcasts, Convention Coverage & More');
}
if (DF_APPLICATION_ENV != "production")
$this->headTitle()->prepend('('.ucfirst(DF_APPLICATION_ENV).')');
$this->headTitle()->prepend('('.ucfirst(DF_APPLICATION_ENV).')');
echo $this->headTitle()->setSeparator(" - ")->toString();
$this->headLink()
->appendStylesheet('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css', 'all')
->appendStylesheet('//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css', 'all')
->appendStylesheet(\DF\Url::content('common/jquery/fancybox/jquery.fancybox.css'), 'all')
->appendStylesheet(\DF\Url::content('common/bootstrap2_r2/df-ui-printable.css'), 'print')
->appendStylesheet('//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700', 'screen')
->appendStylesheet(\DF\Url::content('mid2013/style.css'), 'all')
->appendStylesheet(\DF\Url::content('mid2013/skin_'.$skin.'.css'));
->appendStylesheet('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css', 'all')
->appendStylesheet('//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css', 'all')
->appendStylesheet(\DF\Url::content('common/jquery/fancybox/jquery.fancybox.css'), 'all')
->appendStylesheet(\DF\Url::content('common/bootstrap2_r2/df-ui-printable.css'), 'print')
->appendStylesheet('//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700', 'screen')
->appendStylesheet(\DF\Url::content('mid2013/style.css'), 'all')
->appendStylesheet(\DF\Url::content('mid2013/skin_'.$skin.'.css'));
if ($this->custom_styles)
{
foreach($this->custom_styles as $stylesheet_url)
$this->headLink()->appendStylesheet($stylesheet_url);
foreach($this->custom_styles as $stylesheet_url)
$this->headLink()->appendStylesheet($stylesheet_url);
}
$this->headScript()
->prependFile(\DF\Url::cdn('jquery', '1.10.1'))
->appendFile(\DF\Url::content('common/jquery/fancybox/jquery.fancybox.pack.js'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/bootstrap/js/bootstrap.min.js'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/layout.js'))
->appendFile(\DF\Url::content('swfobject.js'))
->appendFile(\DF\Url::content('js/jquery.hammer-full.min.js'))
->appendFile(\DF\Url::content('global.js'));
->prependFile(\DF\Url::cdn('jquery', '1.10.1'))
->appendFile(\DF\Url::content('common/jquery/fancybox/jquery.fancybox.pack.js'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/bootstrap/js/bootstrap.min.js'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/layout.js'))
->appendFile(\DF\Url::content('swfobject.js'))
->appendFile(\DF\Url::content('js/jquery.hammer-full.min.js'))
->appendFile(\DF\Url::content('global.js'));
if ($this->custom_scripts)
{
foreach($this->custom_scripts as $script_url)
$this->headScript()->appendFile($script_url);
foreach($this->custom_scripts as $script_url)
$this->headScript()->appendFile($script_url);
}
echo $this->headMeta()."\n";
@ -111,7 +111,7 @@ ga('send', 'pageview');
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<?=$this->renderCommon('nav') ?>
<?=$this->renderCommon('nav') ?>
</div>
</div>
</div>
@ -119,83 +119,83 @@ ga('send', 'pageview');
</div>
<? if ($this->placeholder('content_top')->toString()): ?>
<?=$this->placeholder('content_top')->toString() ?>
<?=$this->placeholder('content_top')->toString() ?>
<? else: ?>
<div id="secondary_header_stripe">&nbsp;</div>
<div id="secondary_header_stripe">&nbsp;</div>
<? endif; ?>
<div id="body-wrapper">
<div id="body" class="container">
<div id="page_wrapper">
<div id="page">
<?
if (\DF\Flash::hasMessages()):
$messages = \DF\Flash::getMessages();
foreach($messages as $message):
?>
<div class="content-top-alert alert alert-<?=$message['color'] ?>" data-alert="alert">
<a class="close" data-dismiss="alert" href="#">×</a>
<?=$message['message'] ?>
</div>
<?
endforeach;
endif;
?>
<div id="content_wrapper">
<div id="content">
<?
$breadcrumb = $this->breadcrumb()->render();
if ($breadcrumb):
?>
<div id="breadcrumb">
<a href="<?=\DF\Url::baseUrl() ?>/"><?=$this->config->application->name ?></a> &raquo; <?=$breadcrumb ?>
</div>
<? endif; ?>
<div id="body" class="container">
<div id="page_wrapper">
<div id="page">
<?
if (\DF\Flash::hasMessages()):
$messages = \DF\Flash::getMessages();
foreach($messages as $message):
?>
<div class="content-top-alert alert alert-<?=$message['color'] ?>" data-alert="alert">
<a class="close" data-dismiss="alert" href="#">×</a>
<?=$message['message'] ?>
</div>
<?
endforeach;
endif;
?>
<div id="content_wrapper">
<div id="content">
<?
$breadcrumb = $this->breadcrumb()->render();
if ($breadcrumb):
?>
<div id="breadcrumb">
<a href="<?=\DF\Url::baseUrl() ?>/"><?=$this->config->application->name ?></a> &raquo; <?=$breadcrumb ?>
</div>
<? endif; ?>
<? if (!$this->layout()->hide_title): ?>
<h1 class="title"><?=$title ?></h1>
<? endif; ?>
<? if ($this->layout()->tabs): ?>
<div id="content_tabs">
<?=$this->layout()->tabs ?>
</div>
<? endif; ?>
<? if (!$this->layout()->hide_title): ?>
<h1 class="title"><?=$title ?></h1>
<? endif; ?>
<? if ($this->layout()->tabs): ?>
<div id="content_tabs">
<?=$this->layout()->tabs ?>
</div>
<? endif; ?>
<? if ($this->layout()->subtitle): ?>
<h2 class="title"><?=$this->layout()->subtitle ?></h2>
<? endif; ?>
<? if ($this->layout()->subtitle): ?>
<h2 class="title"><?=$this->layout()->subtitle ?></h2>
<? endif; ?>
<? if ($this->layout()->manual): ?>
<?php echo $this->layout()->content; ?>
<? else: ?>
<div class="row-fluid">
<div class="span12">
<div class="content_inner">
<?php echo $this->layout()->content; ?>
</div>
</div>
</div>
<? endif; ?>
</div>
</div>
</div>
</div>
</div>
<? if ($this->layout()->manual): ?>
<?php echo $this->layout()->content; ?>
<? else: ?>
<div class="row-fluid">
<div class="span12">
<div class="content_inner">
<?php echo $this->layout()->content; ?>
</div>
</div>
</div>
<? endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="container">
<?=$this->renderCommon('footer') ?>
</div>
<div class="container">
<?=$this->renderCommon('footer') ?>
</div>
</div>
<div class="copyright">
<div class="container">
<p>MLP is copyright &copy; Hasbro. All creations are &copy; to their respective artists. All songs are property of their respective artists.<br>
Copyright &copy; 2012-<?=date('Y') ?> <a href="http://www.bravelyblue.com/" target="_blank">Bravely Blue Media LLC</a> and Ponyville Live! All rights reserved.</p>
</div>
<div class="container">
<p>MLP is copyright &copy; Hasbro. All creations are &copy; to their respective artists. All songs are property of their respective artists.<br>
Copyright &copy; 2012-<?=date('Y') ?> <a href="http://www.bravelyblue.com/" target="_blank">Bravely Blue Media LLC</a> and Ponyville Live! All rights reserved.</p>
</div>
</div>
</body>
</html>

View File

@ -21,18 +21,18 @@ if (DF_APPLICATION_ENV != "production")
echo $this->headTitle()->setSeparator(" | ")->toString();
$this->headLink()
->appendStylesheet('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css', 'all')
->appendStylesheet('//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css', 'all')
->appendStylesheet(\DF\Url::content('common/jquery/fancybox/jquery.fancybox.css'), 'all')
->appendStylesheet(\DF\Url::content('mid2013/embeds/'.$skin.'.css'))
->appendStylesheet('http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700', 'screen');
->appendStylesheet('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css', 'all')
->appendStylesheet('//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css', 'all')
->appendStylesheet(\DF\Url::content('common/jquery/fancybox/jquery.fancybox.css'), 'all')
->appendStylesheet(\DF\Url::content('mid2013/embeds/'.$skin.'.css'))
->appendStylesheet('http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700', 'screen');
$this->headScript()
->prependFile(\DF\Url::cdn('jquery', '1.8'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/bootstrap/js/bootstrap.min.js'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/layout.js'))
->appendFile(\DF\Url::content('global.js'))
->appendFile(\DF\Url::content('swfobject.js'));
->prependFile(\DF\Url::cdn('jquery', '1.8'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/bootstrap/js/bootstrap.min.js'))
->appendFile(\DF\Url::content('common/bootstrap2_r2/layout.js'))
->appendFile(\DF\Url::content('global.js'))
->appendFile(\DF\Url::content('swfobject.js'));
echo $this->headMeta();
echo $this->headLink();
@ -56,25 +56,25 @@ ga('send', 'pageview');
<!-- End Google Universal Analytics -->
<div id="body-wrapper">
<div id="body" class="container">
<? if ($title): ?>
<h1 class="title"><?=$title ?></h1>
<? endif; ?>
<div id="body" class="container">
<? if ($title): ?>
<h1 class="title"><?=$title ?></h1>
<? endif; ?>
<? if ($this->layout()->manual): ?>
<?php echo $this->layout()->content; ?>
<? else: ?>
<div class="row-fluid">
<div class="span12">
<div class="floating">
<div class="content_inner">
<?php echo $this->layout()->content; ?>
</div>
</div>
</div>
</div>
<? endif; ?>
</div>
<? if ($this->layout()->manual): ?>
<?php echo $this->layout()->content; ?>
<? else: ?>
<div class="row-fluid">
<div class="span12">
<div class="floating">
<div class="content_inner">
<?php echo $this->layout()->content; ?>
</div>
</div>
</div>
</div>
<? endif; ?>
</div>
</div>
</body>
</html>

View File

@ -5,88 +5,88 @@
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #FFFFFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #FFFFFF;
}
body, td, th, div {
font-family: "Tahoma", Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000;
font-family: "Tahoma", Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000;
}
h1 {
font-size: 20px;
font-weight: normal;
font-size: 20px;
font-weight: normal;
}
h2 {
font-size: 17px;
font-weight: bold;
font-size: 17px;
font-weight: bold;
}
h3 {
font-size: 14px;
font-weight: bold;
font-size: 14px;
font-weight: bold;
}
small {
font-size: 11px;
color: #999999;
font-size: 11px;
color: #999999;
}
dt {
font-weight: bold;
font-weight: bold;
}
#content-wrapper {
padding: 5px;
background-color: #FFFFFF;
padding: 5px;
background-color: #FFFFFF;
}
#content {
border-top: 1px solid #CCC;
border-bottom: 1px solid #CCC;
padding-top: 20px;
padding-bottom: 20px;
border-top: 1px solid #CCC;
border-bottom: 1px solid #CCC;
padding-top: 20px;
padding-bottom: 20px;
}
#footer {
font-size: 11px;
color: #999999;
font-size: 11px;
color: #999999;
}
table.datatable {
border: 1px solid #CCC;
border-collapse: collapse;
border: 1px solid #CCC;
border-collapse: collapse;
}
table.datatable th {
background: #EEE;
border: 1px solid #CCC;
padding: 6px 4px;
background: #EEE;
border: 1px solid #CCC;
padding: 6px 4px;
}
table.datatable tfoot tr td {
background: #EEE;
border-left: 1px solid #CCC;
border-top: 1px solid #CCC;
padding: 6px 4px;
background: #EEE;
border-left: 1px solid #CCC;
border-top: 1px solid #CCC;
padding: 6px 4px;
}
table.datatable tr td {
background: #EEE;
border-left: 1px solid #CCC;
border-bottom: 1px solid #EEE;
padding: 4px;
vertical-align: top;
background: #EEE;
border-left: 1px solid #CCC;
border-bottom: 1px solid #EEE;
padding: 4px;
vertical-align: top;
}
table.datatable tr.even td {
background: #EDF5FF;
background: #EDF5FF;
}
table.datatable tr.odd td {
background: #FFF;
background: #FFF;
}
table tr td.left_padded,
table tr th.left_padded {
padding-left: 10px;
padding-left: 10px;
}
-->
</style>

View File

@ -2,34 +2,34 @@
$this->placeholder('content_top')->captureStart();
?>
<div id="secondary_header_stripe">
<a href="<?=$this->route(array('module' => 'mlpma')) ?>" class="ajax"><img src="<?=\DF\Url::content('mlpma/mlpma_logo.png') ?>" alt="The MLP Music Archive, a Ponyville Live! Project"></a>
<a href="<?=$this->route(array('module' => 'mlpma')) ?>" class="ajax"><img src="<?=\DF\Url::content('mlpma/mlpma_logo.png') ?>" alt="The MLP Music Archive, a Ponyville Live! Project"></a>
</div>
<?
$this->placeholder('content_top')->captureEnd();
$this->custom_styles = array(
\DF\Url::content('mlpma/style.css'),
\DF\Url::content('fap/css/jquery.fullwidthAudioPlayer.css'),
\DF\Url::content('fap/css/jquery.fullwidthAudioPlayer-responsive.css'),
\DF\Url::content('mlpma/style.css'),
\DF\Url::content('fap/css/jquery.fullwidthAudioPlayer.css'),
\DF\Url::content('fap/css/jquery.fullwidthAudioPlayer-responsive.css'),
);
$this->custom_scripts = array(
\DF\Url::content('mlpma/jquery.scrollto.min.js'),
\DF\Url::content('mlpma/jquery.history.min.js'),
\DF\Url::content('mlpma/jquery.ajaxify.js'),
\DF\Url::content('fap/js/jquery-ui.js'),
\DF\Url::content('fap/js/soundmanager2-nodebug-jsmin.js'),
'//connect.soundcloud.com/sdk.js',
\DF\Url::content('fap/js/jquery.fullwidthAudioPlayer.js'),
\DF\Url::content('fap/js/amplify.min.js'),
\DF\Url::content('mlpma/custom.js'),
\DF\Url::content('mlpma/jquery.scrollto.min.js'),
\DF\Url::content('mlpma/jquery.history.min.js'),
\DF\Url::content('mlpma/jquery.ajaxify.js'),
\DF\Url::content('fap/js/jquery-ui.js'),
\DF\Url::content('fap/js/soundmanager2-nodebug-jsmin.js'),
'//connect.soundcloud.com/sdk.js',
\DF\Url::content('fap/js/jquery.fullwidthAudioPlayer.js'),
\DF\Url::content('fap/js/amplify.min.js'),
\DF\Url::content('mlpma/custom.js'),
);
$this->layout()->manual = true;
$this->layout()->content = '
<div class="row-fluid">
<div class="span3">'.$this->renderCommon('mlpma').'</div>
<div class="span9">'.$this->layout()->content.'</div>
<div class="span3">'.$this->renderCommon('mlpma').'</div>
<div class="span9">'.$this->layout()->content.'</div>
</div>
';

View File

@ -38,22 +38,22 @@ if (!$this->layout()->subtitle && $this->layout()->show_subtitle)
$this->headTitle($this->config->application->name);
if (DF_APPLICATION_ENV != "production")
$this->headTitle()->prepend('('.ucfirst(DF_APPLICATION_ENV).')');
$this->headTitle()->prepend('('.ucfirst(DF_APPLICATION_ENV).')');
echo $this->headTitle()->setSeparator(" - ")->toString();
$this->headLink()
->appendStylesheet('//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', 'all')
->appendStylesheet('//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700', 'screen')
->appendStylesheet(\DF\Url::content('mobile/jquery.mobile-1.4.0.min.css'), 'all')
->appendStylesheet(\DF\Url::content('mobile/custom.css'), 'all');
->appendStylesheet('//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', 'all')
->appendStylesheet('//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700', 'screen')
->appendStylesheet(\DF\Url::content('mobile/jquery.mobile-1.4.0.min.css'), 'all')
->appendStylesheet(\DF\Url::content('mobile/custom.css'), 'all');
$this->headScript()
->prependFile(\DF\Url::cdn('jquery', '1.11.0'))
->appendFile(\DF\Url::content('swfobject.js'))
->appendFile(\DF\Url::content('mobile/jquery.mobile-1.4.0.min.js'))
->appendFile(\DF\Url::content('mobile/custom.js'))
->appendFile(\DF\Url::content('jplayer/jquery.jplayer.min.js'));
->prependFile(\DF\Url::cdn('jquery', '1.11.0'))
->appendFile(\DF\Url::content('swfobject.js'))
->appendFile(\DF\Url::content('mobile/jquery.mobile-1.4.0.min.js'))
->appendFile(\DF\Url::content('mobile/custom.js'))
->appendFile(\DF\Url::content('jplayer/jquery.jplayer.min.js'));
echo $this->headMeta()."\n";
echo $this->headLink()."\n";
@ -79,59 +79,59 @@ ga('send', 'pageview');
<!-- End Google Universal Analytics -->
<div id="webapp">
<!-- Header -->
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<a id="btn_back" href="<?=$this->route(array('module' => 'mobile')) ?>" class="ui-btn-left ui-alt-icon ui-nodisc-icon ui-btn ui-icon-home ui-btn-icon-notext ui-corner-all" data-role="button" role="button">Back</a>
<h1><?=$title ?></h1>
</div>
<!-- Header -->
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<a id="btn_back" href="<?=$this->route(array('module' => 'mobile')) ?>" class="ui-btn-left ui-alt-icon ui-nodisc-icon ui-btn ui-icon-home ui-btn-icon-notext ui-corner-all" data-role="button" role="button">Back</a>
<h1><?=$title ?></h1>
</div>
<!-- Main Body -->
<?
$uri_raw = $_SERVER['REQUEST_URI'];
$uri_class = preg_replace("/[^A-Za-z0-9_\/]/", '', $uri_raw);
$uri_class = trim($uri_class, '/');
$uri_class = 'page-'.str_replace('/', '_', $uri_class);
?>
<div id="page" data-role="page" data-title="<?=$title ?>" data-url="<?=$uri_raw ?>" class="<?=$uri_class ?>">
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<?php echo $this->layout()->content; ?>
</div>
</div>
<!-- Main Body -->
<?
$uri_raw = $_SERVER['REQUEST_URI'];
$uri_class = preg_replace("/[^A-Za-z0-9_\/]/", '', $uri_raw);
$uri_class = trim($uri_class, '/');
$uri_class = 'page-'.str_replace('/', '_', $uri_class);
?>
<div id="page" data-role="page" data-title="<?=$title ?>" data-url="<?=$uri_raw ?>" class="<?=$uri_class ?>">
<div role="main" class="ui-content jqm-content jqm-fullwidth">
<?php echo $this->layout()->content; ?>
</div>
</div>
<!-- Footer Nav -->
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<div id="player_controls" data-role="controlgroup">
<a class="ui-corner-all ui-btn ui-btn-left" id="player_pause"><i class="fa fa-stop"></i></a>
<div id="volume_icon_left"><i class="fa fa-volume-off"></i></div>
<div id="volume_icon_right"><i class="fa fa-volume-up"></i></div>
<!-- Footer Nav -->
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<div id="player_controls" data-role="controlgroup">
<a class="ui-corner-all ui-btn ui-btn-left" id="player_pause"><i class="fa fa-stop"></i></a>
<div id="volume_icon_left"><i class="fa fa-volume-off"></i></div>
<div id="volume_icon_right"><i class="fa fa-volume-up"></i></div>
<input type="range" class="volume_slider" name="player_volume" id="player_volume" min="0" max="100" value="50" data-role="none" data-highlight="true" data-mini="true">
</div>
<input type="range" class="volume_slider" name="player_volume" id="player_volume" min="0" max="100" value="50" data-role="none" data-highlight="true" data-mini="true">
</div>
<div data-role="navbar">
<ul>
<li><a href="<?=$this->route(array('module' => 'mobile', 'action' => 'view', 'type' => 'radio')) ?>">
<span class="icon"><i class="fa fa-music"></i></span>
<span class="tab-label">Radio</span>
</a></li>
<li><a href="<?=$this->route(array('module' => 'mobile', 'action' => 'view', 'type' => 'video')) ?>">
<span class="icon"><i class="fa fa-video-camera"></i></span>
<span class="tab-label">Video</span>
</a></li>
<li><a href="<?=$this->route(array('module' => 'mobile', 'action' => 'view', 'type' => 'show')) ?>">
<span class="icon"><i class="fa fa-rss"></i></span>
<span class="tab-label">Shows</span>
</a></li>
<li><a href="<?=$this->route(array('module' => 'mobile', 'controller' => 'requests')) ?>">
<span class="icon"><i class="fa fa-comments"></i></span>
<span class="tab-label">Requests</span>
</a></li>
</ul>
</div>
</div>
<div data-role="navbar">
<ul>
<li><a href="<?=$this->route(array('module' => 'mobile', 'action' => 'view', 'type' => 'radio')) ?>">
<span class="icon"><i class="fa fa-music"></i></span>
<span class="tab-label">Radio</span>
</a></li>
<li><a href="<?=$this->route(array('module' => 'mobile', 'action' => 'view', 'type' => 'video')) ?>">
<span class="icon"><i class="fa fa-video-camera"></i></span>
<span class="tab-label">Video</span>
</a></li>
<li><a href="<?=$this->route(array('module' => 'mobile', 'action' => 'view', 'type' => 'show')) ?>">
<span class="icon"><i class="fa fa-rss"></i></span>
<span class="tab-label">Shows</span>
</a></li>
<li><a href="<?=$this->route(array('module' => 'mobile', 'controller' => 'requests')) ?>">
<span class="icon"><i class="fa fa-comments"></i></span>
<span class="tab-label">Requests</span>
</a></li>
</ul>
</div>
</div>
<!-- Radio Player -->
<div id="pvl-jplayer" style="width: 0; height: 0;"></div>
<!-- Radio Player -->
<div id="pvl-jplayer" style="width: 0; height: 0;"></div>
</div>
</body>

View File

@ -11,12 +11,12 @@ class Acl
{
public static function getInstance()
{
return \Zend_Registry::get('acl');
return \Zend_Registry::get('acl');
}
public static function __callStatic($name, $arguments)
{
$instance = self::getInstance();
return call_user_func_array(array($instance, $name), $arguments);
$instance = self::getInstance();
return call_user_func_array(array($instance, $name), $arguments);
}
}

View File

@ -10,32 +10,32 @@ use \Entity\Role;
class Instance
{
protected $_actions = NULL;
public function __construct()
{}
public function init()
{
if (null === $this->_actions)
{
$this->_actions = array();
protected $_actions = NULL;
public function __construct()
{}
public function init()
{
if (null === $this->_actions)
{
$this->_actions = array();
$em = \Zend_Registry::get('em');
$query = $em->createQuery('SELECT r, a FROM \Entity\Role r JOIN r.actions a');
$roles_with_actions = $query->getArrayResult();
foreach($roles_with_actions as $role)
{
foreach((array)$role['actions'] as $action)
{
$this->_actions[$role['id']][] = $action['name'];
}
}
}
}
foreach($roles_with_actions as $role)
{
foreach((array)$role['actions'] as $action)
{
$this->_actions[$role['id']][] = $action['name'];
}
}
}
}
public function userAllowed($action, User $user = null)
public function userAllowed($action, User $user = null)
{
static $roles;
static $cache;
@ -43,8 +43,8 @@ class Instance
$action = array_map('strtolower', (array)$action);
asort($action);
$memoize = md5(serialize($action));
$user_id = ($user instanceof User) ? $user->id : 'anonymous';
$user_id = ($user instanceof User) ? $user->id : 'anonymous';
if( !isset($cache[$user_id][$memoize]) )
{
@ -53,17 +53,17 @@ class Instance
if(!isset($roles[$user_id]))
{
$roles[$user_id] = array();
if (count($user->roles) > 0)
{
foreach($user->roles as $role)
{
$roles[$user_id][] = $role->id;
}
}
if (count($user->roles) > 0)
{
foreach($user->roles as $role)
{
$roles[$user_id][] = $role->id;
}
}
}
$cache[$user_id][$memoize] = $this->roleAllowed($roles[$user_id], $action);
$cache[$user_id][$memoize] = $this->roleAllowed($roles[$user_id], $action);
}
else
{
@ -74,26 +74,26 @@ class Instance
return $cache[$user_id][$memoize];
}
public function isAllowed($action)
public function isAllowed($action)
{
$auth = \Zend_Registry::get('auth');
$user = $auth->getLoggedInUser();
$is_logged_in = ($user instanceof User);
if ($action == "is logged in")
return ($is_logged_in);
elseif ($action == "is not logged in")
return (!$is_logged_in);
elseif ($is_logged_in)
return $this->userAllowed($action, $user);
else
return false;
$auth = \Zend_Registry::get('auth');
$user = $auth->getLoggedInUser();
$is_logged_in = ($user instanceof User);
if ($action == "is logged in")
return ($is_logged_in);
elseif ($action == "is not logged in")
return (!$is_logged_in);
elseif ($is_logged_in)
return $this->userAllowed($action, $user);
else
return false;
}
public function roleAllowed($role_id, $action, $exact_only = FALSE)
public function roleAllowed($role_id, $action, $exact_only = FALSE)
{
$this->init();
$this->init();
if(is_array($role_id))
{
foreach($role_id as $r)
@ -114,36 +114,36 @@ class Instance
}
else
{
// Without "exact_only" flag, matches based on root-level access are permitted.
if (!$exact_only)
{
if($role_id == 1) //ROOT
return true;
if (in_array('administer all', (array)$this->_actions[$role_id]))
return true;
}
if (isset($this->_actions[$role_id]) && in_array($action, $this->_actions[$role_id]))
return true;
return false;
// Without "exact_only" flag, matches based on root-level access are permitted.
if (!$exact_only)
{
if($role_id == 1) //ROOT
return true;
if (in_array('administer all', (array)$this->_actions[$role_id]))
return true;
}
if (isset($this->_actions[$role_id]) && in_array($action, $this->_actions[$role_id]))
return true;
return false;
}
}
/**
* Pretty wrapper around the 'isAllowed' function that throws a UI-friendly exception upon failure.
*/
public function checkPermission($action)
{
$auth = \Zend_Registry::get('auth');
if (!$this->isAllowed($action))
{
if (!$auth->isLoggedIn())
throw new \DF\Exception\NotLoggedIn();
else
throw new \DF\Exception\PermissionDenied();
}
}
/**
* Pretty wrapper around the 'isAllowed' function that throws a UI-friendly exception upon failure.
*/
public function checkPermission($action)
{
$auth = \Zend_Registry::get('auth');
if (!$this->isAllowed($action))
{
if (!$auth->isLoggedIn())
throw new \DF\Exception\NotLoggedIn();
else
throw new \DF\Exception\PermissionDenied();
}
}
}

View File

@ -1,7 +1,7 @@
<?php
namespace DF\Application;
class Bootstrap extends \Zend_Application_Bootstrap_Bootstrap
{
{
public function _initView()
{
return self::getNewView(TRUE);

View File

@ -2,51 +2,51 @@
namespace DF\Application;
class Maintenance
{
public static function render($message, $title = NULL)
{
$layout = self::getLayout();
if ($title !== NULL)
$layout->getView()->headTitle($title);
$layout->content = $message;
return $layout->render();
}
public static function display($message, $title = NULL)
{
echo self::render($message, $title);
}
public static function getLayout()
{
static $layout;
if ($layout === NULL)
{
$registry = \Zend_Registry::getInstance();
if (isset($registry['config']))
$config = $registry['config'];
else
$config = $_GLOBALS['config'];
// Initialize Zend routing.
$front = \Zend_Controller_Front::getInstance();
$front->setRequest(new \Zend_Controller_Request_Http);
// Special handling for .php scripts being accessed directly.
if (stristr($_SERVER['REQUEST_URI'], '.php') !== FALSE)
$front->setBaseUrl(substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')));
// Set up maintenance layout.
$layout = new \Zend_Layout();
$layout->setLayoutPath($config->application->resources->layout->layoutPath);
$layout->getView()->assign(array(
'config' => $config,
));
$layout->setLayout('maintenance');
}
return $layout;
}
public static function render($message, $title = NULL)
{
$layout = self::getLayout();
if ($title !== NULL)
$layout->getView()->headTitle($title);
$layout->content = $message;
return $layout->render();
}
public static function display($message, $title = NULL)
{
echo self::render($message, $title);
}
public static function getLayout()
{
static $layout;
if ($layout === NULL)
{
$registry = \Zend_Registry::getInstance();
if (isset($registry['config']))
$config = $registry['config'];
else
$config = $_GLOBALS['config'];
// Initialize Zend routing.
$front = \Zend_Controller_Front::getInstance();
$front->setRequest(new \Zend_Controller_Request_Http);
// Special handling for .php scripts being accessed directly.
if (stristr($_SERVER['REQUEST_URI'], '.php') !== FALSE)
$front->setBaseUrl(substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')));
// Set up maintenance layout.
$layout = new \Zend_Layout();
$layout->setLayoutPath($config->application->resources->layout->layoutPath);
$layout->getView()->assign(array(
'config' => $config,
));
$layout->setLayout('maintenance');
}
return $layout;
}
}

View File

@ -44,8 +44,8 @@ class Doctrine extends \Zend_Application_Resource_ResourceAbstract
if ($options['conn']['platform'])
{
$class_obj = new \ReflectionClass($options['conn']['platform']);
$options['conn']['platform'] = $class_obj->newInstance();
$class_obj = new \ReflectionClass($options['conn']['platform']);
$options['conn']['platform'] = $class_obj->newInstance();
}
$metadata_driver = $config->newDefaultAnnotationDriver($options['modelPath']);
@ -63,9 +63,9 @@ class Doctrine extends \Zend_Application_Resource_ResourceAbstract
if (!file_exists($update_reference_path))
{
@file_put_contents($update_reference_path, 'This file is automatically modified to track proxy regeneration.');
@touch($upload_reference_path);
}
@file_put_contents($update_reference_path, 'This file is automatically modified to track proxy regeneration.');
@touch($upload_reference_path);
}
clearstatcache();
$last_upload_time = (int)@filemtime($upload_reference_path);
@ -73,22 +73,22 @@ class Doctrine extends \Zend_Application_Resource_ResourceAbstract
if ($last_upload_time >= $last_update_time)
{
@touch($update_reference_path);
// Flush the cache.
@touch($update_reference_path);
// Flush the cache.
$cache->flushAll();
// Clear the proxy directory.
$proxy_dir = $options['proxyPath'];
@mkdir($proxy_dir);
$files = glob($proxy_dir.DIRECTORY_SEPARATOR.'*.php');
foreach((array)$files as $file)
@unlink($file);
// Trigger proxy regeneration below.
$regen_proxies = TRUE;
$config->setAutoGenerateProxyClasses(TRUE);
$files = glob($proxy_dir.DIRECTORY_SEPARATOR.'*.php');
foreach((array)$files as $file)
@unlink($file);
// Trigger proxy regeneration below.
$regen_proxies = TRUE;
$config->setAutoGenerateProxyClasses(TRUE);
}
}
else
@ -104,10 +104,10 @@ class Doctrine extends \Zend_Application_Resource_ResourceAbstract
$config->setProxyNamespace($options['proxyNamespace']);
if (!$regen_proxies)
$config->setAutoGenerateProxyClasses($options['autoGenerateProxies']);
$config->setAutoGenerateProxyClasses($options['autoGenerateProxies']);
if (isset($options['conn']['debug']) && $options['conn']['debug'])
$config->setSQLLogger(new \DF\Doctrine\Logger\EchoSQL);
$config->setSQLLogger(new \DF\Doctrine\Logger\EchoSQL);
$config->addFilter('softdelete', '\DF\Doctrine\Filter\SoftDelete');
$config->addCustomNumericFunction('RAND', '\DF\Doctrine\Functions\Rand');
@ -120,27 +120,27 @@ class Doctrine extends \Zend_Application_Resource_ResourceAbstract
// Trigger proxy regeneration.
if ($regen_proxies)
{
$metadatas = $em->getMetadataFactory()->getAllMetadata();
$metadatas = $em->getMetadataFactory()->getAllMetadata();
$em->getProxyFactory()->generateProxyClasses($metadatas);
}
// Try the connection before rendering the page.
try
{
$em->getConnection()->connect();
}
$em->getConnection()->connect();
}
catch(\Exception $e)
{
$db_config_location = str_replace(DF_INCLUDE_ROOT, '', DF_INCLUDE_APP).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'application.conf.php';
\DF\Application\Maintenance::display('
<h2>Database Error</h2>
<p>The system could not connect to the database. Verify that the information listed in "<i>'.$db_config_location.'</i>" is correct.</p>
<blockquote>'.$e->getMessage().'</blockquote>
');
exit;
}
$db_config_location = str_replace(DF_INCLUDE_ROOT, '', DF_INCLUDE_APP).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'application.conf.php';
\DF\Application\Maintenance::display('
<h2>Database Error</h2>
<p>The system could not connect to the database. Verify that the information listed in "<i>'.$db_config_location.'</i>" is correct.</p>
<blockquote>'.$e->getMessage().'</blockquote>
');
exit;
}
return $em;
}
}

View File

@ -8,40 +8,40 @@ class Menu extends \Zend_Application_Resource_ResourceAbstract
if (!$menu)
{
$menu = $this->_loadMenu();
$this->_setMenuCache($menu);
$menu = $this->_loadMenu();
$this->_setMenuCache($menu);
}
return new \DF\Menu($menu);
return new \DF\Menu($menu);
}
protected function _getMenuCache()
{
// Never cache menus on dev environments.
if (DF_APPLICATION_ENV == "dev")
return NULL;
// Compare to environment file timestamp, updated upon phing.
$upload_reference_path = DF_INCLUDE_BASE.DIRECTORY_SEPARATOR . '.env';
$last_upload_time = (int)@filemtime($upload_reference_path);
$cache_contents = \DF\Cache::get('df_menu');
$cache_timestamp = \DF\Cache::get('df_menu_timestamp');
if ($cache_contents && $cache_timestamp >= $last_upload_time)
return $cache_contents;
else
return NULL;
// Never cache menus on dev environments.
if (DF_APPLICATION_ENV == "dev")
return NULL;
// Compare to environment file timestamp, updated upon phing.
$upload_reference_path = DF_INCLUDE_BASE.DIRECTORY_SEPARATOR . '.env';
$last_upload_time = (int)@filemtime($upload_reference_path);
$cache_contents = \DF\Cache::get('df_menu');
$cache_timestamp = \DF\Cache::get('df_menu_timestamp');
if ($cache_contents && $cache_timestamp >= $last_upload_time)
return $cache_contents;
else
return NULL;
}
protected function _setMenuCache($menu)
{
\DF\Cache::save($menu, 'df_menu');
\DF\Cache::save(time(), 'df_menu_timestamp');
\DF\Cache::save($menu, 'df_menu');
\DF\Cache::save(time(), 'df_menu_timestamp');
}
protected function _loadMenu()
{
$menu = array();
$menu = array();
foreach(new \DirectoryIterator(DF_INCLUDE_MODULES) as $item)
{
if( $item->isDir() && !$item->isDot() )
@ -49,9 +49,9 @@ class Menu extends \Zend_Application_Resource_ResourceAbstract
$menu_file = $item->getPathname().DIRECTORY_SEPARATOR.'menu.php';
if(file_exists($menu_file))
{
$new_menu = (array)include_once($menu_file);
$menu = $this->_mergeFlat($menu, $new_menu);
}
$new_menu = (array)include_once($menu_file);
$menu = $this->_mergeFlat($menu, $new_menu);
}
}
}
return $menu;
@ -59,7 +59,7 @@ class Menu extends \Zend_Application_Resource_ResourceAbstract
protected function _mergeFlat()
{
$arrays = func_get_args();
$arrays = func_get_args();
$base = array_shift($arrays);
foreach ($arrays as $array)

View File

@ -8,12 +8,12 @@ class Auth
{
public static function getInstance()
{
return \Zend_Registry::get('auth');
return \Zend_Registry::get('auth');
}
public static function __callStatic($name, $arguments)
{
$instance = self::getInstance();
return call_user_func_array(array($instance, $name), $arguments);
$instance = self::getInstance();
return call_user_func_array(array($instance, $name), $arguments);
}
}

View File

@ -3,40 +3,40 @@ namespace DF\Auth\Adapter;
class Cas implements \Zend_Auth_Adapter_Interface
{
protected $_options;
protected $_options;
public function __construct($options)
{
$this->setOptions($options);
$this->setOptions($options);
}
public function setOptions($options)
{
$this->_options = $options;
}
public function setOptions($options)
{
$this->_options = $options;
}
public function authenticate()
{
try
{
$auth_result = $this->login();
if ($auth_result['success'])
{
$result = new \Zend_Auth_Result(
$auth_result = $this->login();
if ($auth_result['success'])
{
$result = new \Zend_Auth_Result(
\Zend_Auth_Result::SUCCESS,
$auth_result,
array()
);
}
else
{
$result = new \Zend_Auth_Result(
}
else
{
$result = new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE_UNCATEGORIZED,
null,
array($auth_result['message'])
);
}
}
}
catch( \Exception $e )
{
@ -51,88 +51,88 @@ class Cas implements \Zend_Auth_Adapter_Interface
return $result;
}
public function login($destination_url = NULL)
{
// Get the CAS ticket if it has been set.
$ticket = (isset($_REQUEST['ticket'])) ? $_REQUEST['ticket'] : '';
if (is_null($destination_url) || empty($destination_url))
{
$destination_url = $this->getServiceUrl();
}
if (!empty($ticket))
{
$validate = (substr($ticket, 0, 2) == 'ST') ? 'serviceValidate' : 'proxyValidate';
$query_string = array(
'service' => $destination_url,
'ticket' => $ticket,
);
$file_url = $this->_options['cas_base'].'/'.$validate.'?'.http_build_query($query_string);
$file = file_get_contents($file_url);
public function login($destination_url = NULL)
{
// Get the CAS ticket if it has been set.
$ticket = (isset($_REQUEST['ticket'])) ? $_REQUEST['ticket'] : '';
if (is_null($destination_url) || empty($destination_url))
{
$destination_url = $this->getServiceUrl();
}
if (!empty($ticket))
{
$validate = (substr($ticket, 0, 2) == 'ST') ? 'serviceValidate' : 'proxyValidate';
$query_string = array(
'service' => $destination_url,
'ticket' => $ticket,
);
$file_url = $this->_options['cas_base'].'/'.$validate.'?'.http_build_query($query_string);
$file = file_get_contents($file_url);
if (!$file)
{
throw new \Exception('Could Not Authenticate: The CAS service did not return a complete response.');
}
}
else
{
$query_string = array('service' => $destination_url);
if ($this->_options['renew'])
{
$query_string['renew'] = 'true';
}
// Redirect to login page.
header("Location: ".$this->_options['cas_base'].'/login?'.http_build_query($query_string));
exit;
}
$xml_array = \DF\Export::XmlToArray($file);
$return_value = array();
if (isset($xml_array['cas:serviceResponse']['cas:authenticationSuccess']))
{
$attributes = $xml_array['cas:serviceResponse']['cas:authenticationSuccess'][0]['cas:attributes'][0];
$return_value['success'] = TRUE;
$return_value['uin'] = $attributes['cas:tamuEduPersonUIN'];
$return_value['netid'] = $attributes['cas:tamuEduPersonNetID'];
}
else
{
$return_value['success'] = FALSE;
$return_value['message'] = $xml_array['cas:serviceResponse']['cas:authenticationFailure']['code'];
}
return $return_value;
}
public function logout($destination_url = NULL)
{
if ($this->_options['full_logout'])
{
if (is_null($destination_url))
{
$destination_url = $this->getServiceUrl();
}
$url_params = array(
'service' => $destination_url,
);
// Redirect to login page.
header("Location: ".$this->_options['cas_base'].'/logout?'.http_build_query($url_params));
exit;
}
}
private function getServiceUrl()
{
return \DF\Url::current(TRUE, FALSE);
}
if (!$file)
{
throw new \Exception('Could Not Authenticate: The CAS service did not return a complete response.');
}
}
else
{
$query_string = array('service' => $destination_url);
if ($this->_options['renew'])
{
$query_string['renew'] = 'true';
}
// Redirect to login page.
header("Location: ".$this->_options['cas_base'].'/login?'.http_build_query($query_string));
exit;
}
$xml_array = \DF\Export::XmlToArray($file);
$return_value = array();
if (isset($xml_array['cas:serviceResponse']['cas:authenticationSuccess']))
{
$attributes = $xml_array['cas:serviceResponse']['cas:authenticationSuccess'][0]['cas:attributes'][0];
$return_value['success'] = TRUE;
$return_value['uin'] = $attributes['cas:tamuEduPersonUIN'];
$return_value['netid'] = $attributes['cas:tamuEduPersonNetID'];
}
else
{
$return_value['success'] = FALSE;
$return_value['message'] = $xml_array['cas:serviceResponse']['cas:authenticationFailure']['code'];
}
return $return_value;
}
public function logout($destination_url = NULL)
{
if ($this->_options['full_logout'])
{
if (is_null($destination_url))
{
$destination_url = $this->getServiceUrl();
}
$url_params = array(
'service' => $destination_url,
);
// Redirect to login page.
header("Location: ".$this->_options['cas_base'].'/logout?'.http_build_query($url_params));
exit;
}
}
private function getServiceUrl()
{
return \DF\Url::current(TRUE, FALSE);
}
}

View File

@ -9,17 +9,17 @@ define(LDAP_OPT_DIAGNOSTIC_MESSAGE, 0x0032);
class Ldap implements \Zend_Auth_Adapter_Interface
{
protected $_options = array();
protected $_options = array();
public function __construct($options = array())
public function __construct($options = array())
{
$this->setOptions($options);
$this->setOptions($options);
}
public function setOptions($options)
{
$this->_options = array_merge($this->_options, (array)$options);
}
public function setOptions($options)
{
$this->_options = array_merge($this->_options, (array)$options);
}
/**
* (non-PHPdoc)
@ -29,6 +29,6 @@ class Ldap implements \Zend_Auth_Adapter_Interface
*/
public function authenticate()
{
return \DF\Service\Ldap::authenticate($this->_options['username'], $this->_options['password']);
return \DF\Service\Ldap::authenticate($this->_options['username'], $this->_options['password']);
}
}

View File

@ -9,21 +9,21 @@ use \Entity\User;
class Model implements \Zend_Auth_Adapter_Interface
{
protected $_options = array();
protected $_options = array();
public function __construct($options = array())
public function __construct($options = array())
{
$this->setOptions($options);
$this->setOptions($options);
}
public function setOptions($options)
{
$this->_options = array_merge($this->_options, (array)$options);
}
public function setOptions($options)
{
$this->_options = array_merge($this->_options, (array)$options);
}
public function authenticate()
{
$user = $this->modelAuth($this->_options['username'], $this->_options['password']);
$user = $this->modelAuth($this->_options['username'], $this->_options['password']);
if ($user !== FALSE)
{
@ -35,16 +35,16 @@ class Model implements \Zend_Auth_Adapter_Interface
}
else
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null,
array('Could not determine credentials to be authentic.')
);
}
return new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null,
array('Could not determine credentials to be authentic.')
);
}
}
public function modelAuth($username, $password)
{
return \Entity\User::authenticate($username, $password);
return \Entity\User::authenticate($username, $password);
}
}

View File

@ -5,26 +5,26 @@ use \Entity\User;
class Cas extends Instance
{
public function __construct()
{
parent::__construct();
$config = \Zend_Registry::get('config');
$this->_adapter = new Adapter\Cas($config->services->cas->toArray());
}
public function authenticate()
public function __construct()
{
$response = parent::authenticate();
parent::__construct();
$config = \Zend_Registry::get('config');
$this->_adapter = new Adapter\Cas($config->services->cas->toArray());
}
public function authenticate()
{
$response = parent::authenticate();
if($response->isValid())
{
$identity = $response->getIdentity();
$user = User::getOrCreate($identity['uin']);
$this->_session->identity = $identity;
$this->_session->user_id = $user['id'];
$this->_user = $user;
$identity = $response->getIdentity();
$user = User::getOrCreate($identity['uin']);
$this->_session->identity = $identity;
$this->_session->user_id = $user['id'];
$this->_user = $user;
return true;
}
else

View File

@ -5,10 +5,10 @@
namespace DF\Auth\Exception;
class InvalidUser extends \DF\Exception\DisplayOnly {
public function __construct($message = NULL, $code = 0, Exception $previous = null) {
if (!$message)
$message = 'Your account has experienced an error and has been logged out for security purposes. Please log in again to continue.';
public function __construct($message = NULL, $code = 0, Exception $previous = null) {
if (!$message)
$message = 'Your account has experienced an error and has been logged out for security purposes. Please log in again to continue.';
parent::__construct($message, $code, $previous);
}
}

View File

@ -5,28 +5,28 @@ use \Entity\User;
class Instance
{
protected $_adapter;
protected $_session;
protected $_adapter;
protected $_session;
protected $_user = NULL;
protected $_masqueraded_user = NULL;
public function __construct()
{
$this->_session = $this->getSession();
}
public function getSession()
public function __construct()
{
$class_name = strtolower(str_replace(array('\\', '_'), array('', ''), get_called_class()));
return \DF\Session::get('auth_'.$class_name.'_user');
$this->_session = $this->getSession();
}
public function login()
public function getSession()
{
$class_name = strtolower(str_replace(array('\\', '_'), array('', ''), get_called_class()));
return \DF\Session::get('auth_'.$class_name.'_user');
}
public function login()
{
if ($this->isLoggedIn() || php_sapi_name() == 'cli')
return true;
else
return $this->authenticate();
return $this->authenticate();
}
public function authenticate()
@ -39,20 +39,20 @@ class Instance
return $result;
}
public function logout($destination = NULL, $unset_session = true)
public function logout($destination = NULL, $unset_session = true)
{
unset($this->_session->identity);
unset($this->_session->user_id);
unset($this->_session->identity);
unset($this->_session->user_id);
unset($this->_session->masquerade_user_id);
if ($unset_session)
@session_unset();
if (method_exists($this->_adapter, 'logout'))
$this->_adapter->logout($destination);
@session_unset();
if (method_exists($this->_adapter, 'logout'))
$this->_adapter->logout($destination);
}
public function isLoggedIn()
public function isLoggedIn()
{
if( php_sapi_name() == 'cli' )
return false;
@ -63,94 +63,94 @@ class Instance
public function getLoggedInUser($real_user_only = FALSE)
{
if ($this->isMasqueraded() && !$real_user_only)
return $this->getMasquerade();
else
return $this->getUser();
}
if ($this->isMasqueraded() && !$real_user_only)
return $this->getMasquerade();
else
return $this->getUser();
}
public function getUser()
public function getUser()
{
if ($this->_user === NULL)
{
$user_id = (int)$this->_session->user_id;
if ($user_id == 0)
{
$this->_user = FALSE;
return false;
}
$user = User::find($user_id);
if ($user instanceof User)
{
$this->_user = $user;
}
else
{
unset($this->_session->user_id);
$this->_user = FALSE;
$this->logout();
throw new Exception\InvalidUser;
}
}
return $this->_user;
$user_id = (int)$this->_session->user_id;
if ($user_id == 0)
{
$this->_user = FALSE;
return false;
}
$user = User::find($user_id);
if ($user instanceof User)
{
$this->_user = $user;
}
else
{
unset($this->_session->user_id);
$this->_user = FALSE;
$this->logout();
throw new Exception\InvalidUser;
}
}
return $this->_user;
}
public function setUser(User $user)
{
// Prevent any previous identity from being used.
unset($this->_session->identity);
$this->_session->user_id = $user->id;
$this->_user = $user;
return true;
// Prevent any previous identity from being used.
unset($this->_session->identity);
$this->_session->user_id = $user->id;
$this->_user = $user;
return true;
}
public function getAdapter()
{
return $this->_adapter;
}
public function setAdapter($adapter)
{
$this->_adapter = $adapter;
}
public function setAdapterOptions($options)
{
if (method_exists($this->_adapter, 'setOptions'))
$this->_adapter->setOptions($options);
}
public function exists($response = null)
public function getAdapter()
{
$user_id = (int)$this->_session->user_id;
$user = User::find($user_id);
return ($user instanceof User);
return $this->_adapter;
}
public function setAdapter($adapter)
{
$this->_adapter = $adapter;
}
public function setAdapterOptions($options)
{
if (method_exists($this->_adapter, 'setOptions'))
$this->_adapter->setOptions($options);
}
public function exists($response = null)
{
$user_id = (int)$this->_session->user_id;
$user = User::find($user_id);
return ($user instanceof User);
}
public function getIdentity()
{
return $this->_session->identity;
return $this->_session->identity;
}
public function setIdentity($identity)
{
$this->_session->identity = $identity;
}
public function clearIdentity()
{
unset($this->_session->identity);
}
/**
* Masquerading
*/
public function masqueradeAsUser($user_info)
$this->_session->identity = $identity;
}
public function clearIdentity()
{
if (!($user_info instanceof User))
$user_info = User::getRepository()->findOneByUsername($user_info);
unset($this->_session->identity);
}
/**
* Masquerading
*/
public function masqueradeAsUser($user_info)
{
if (!($user_info instanceof User))
$user_info = User::getRepository()->findOneByUsername($user_info);
$this->_session->masquerade_user_id = $user_info->id;
$this->_masqueraded_user = $user;
@ -158,7 +158,7 @@ class Instance
public function endMasquerade()
{
unset($this->_session->masquerade_user_id);
unset($this->_session->masquerade_user_id);
$this->_masqueraded_user = null;
}
@ -169,36 +169,36 @@ class Instance
public function isMasqueraded()
{
if (!$this->isLoggedIn())
{
$this->_masqueraded_user = FALSE;
return NULL;
}
if (!$this->isLoggedIn())
{
$this->_masqueraded_user = FALSE;
return NULL;
}
if ($this->_masqueraded_user === NULL)
{
if (!$this->_session->masquerade_user_id)
{
$this->_masqueraded_user = FALSE;
}
else
{
$mask_user_id = (int)$this->_session->masquerade_user_id;
if ($mask_user_id != 0)
$user = User::find($mask_user_id);
if ($user instanceof User)
{
$this->_masqueraded_user = $user;
}
else
{
unset($this->_session->user_id);
unset($this->_session->masquerade_user_id);
$this->_masqueraded_user = FALSE;
}
}
$this->_masqueraded_user = FALSE;
}
else
{
$mask_user_id = (int)$this->_session->masquerade_user_id;
if ($mask_user_id != 0)
$user = User::find($mask_user_id);
if ($user instanceof User)
{
$this->_masqueraded_user = $user;
}
else
{
unset($this->_session->user_id);
unset($this->_session->masquerade_user_id);
$this->_masqueraded_user = FALSE;
}
}
}
return $this->_masqueraded_user;

View File

@ -6,60 +6,60 @@ use \Entity\Role;
class Ldap extends Instance
{
public function __construct()
{
parent::__construct();
$this->_adapter = new Adapter\Ldap;
}
public function authenticate($credentials = NULL)
{
$this->_adapter->setOptions($credentials);
$response = parent::authenticate();
if($response->isValid())
{
$identity = $response->getIdentity();
$this->_session->identity = $identity;
}
else
{
if($response->getCode() != \Zend_Auth_Result::FAILURE_UNCATEGORIZED)
{
foreach($response->getMessages() as $message)
\DF\Flash::addMessage($message);
}
return false;
}
$user = User::getOrCreate($identity, 'ldap');
$this->_session->user_id = $user['id'];
$this->_user = $user;
public function __construct()
{
parent::__construct();
$this->_adapter = new Adapter\Ldap;
}
public function authenticate($credentials = NULL)
{
$this->_adapter->setOptions($credentials);
$response = parent::authenticate();
if($response->isValid())
{
$identity = $response->getIdentity();
$this->_session->identity = $identity;
}
else
{
if($response->getCode() != \Zend_Auth_Result::FAILURE_UNCATEGORIZED)
{
foreach($response->getMessages() as $message)
\DF\Flash::addMessage($message);
}
return false;
}
$user = User::getOrCreate($identity, 'ldap');
$this->_session->user_id = $user['id'];
$this->_user = $user;
return true;
}
public function getUser()
{
$user = parent::getUser();
$identity = $this->getIdentity();
if ($user instanceof User)
{
return $user;
}
elseif ($identity)
{
$user = User::getOrCreate($identity, 'ldap');
if ($user instanceof User)
{
$this->_session->user_id = $user['id'];
$this->_user = $user;
return $user;
}
return false;
}
$user = parent::getUser();
$identity = $this->getIdentity();
if ($user instanceof User)
{
return $user;
}
elseif ($identity)
{
$user = User::getOrCreate($identity, 'ldap');
if ($user instanceof User)
{
$this->_session->user_id = $user['id'];
$this->_user = $user;
return $user;
}
return false;
}
}
}

View File

@ -5,25 +5,25 @@ use \Entity\User;
class Model extends Instance
{
public function __construct()
{
parent::__construct();
$this->_adapter = new Adapter\Model;
}
public function authenticate($credentials = NULL)
public function __construct()
{
$this->_adapter->setOptions($credentials);
$response = parent::authenticate();
parent::__construct();
$this->_adapter = new Adapter\Model;
}
public function authenticate($credentials = NULL)
{
$this->_adapter->setOptions($credentials);
$response = parent::authenticate();
if($response->isValid())
{
$identity = $response->getIdentity();
$user = User::find($identity['id']);
$this->_session->identity = $identity;
$this->_session->user_id = $user['id'];
$this->_user = $user;
$identity = $response->getIdentity();
$user = User::find($identity['id']);
$this->_session->identity = $identity;
$this->_session->user_id = $user['id'];
$this->_user = $user;
return true;
}
else

View File

@ -3,10 +3,10 @@ namespace DF\Auth\Storage;
class Session extends \Zend_Auth_Storage_Session
{
public function __construct($namespace = 'default', $member = self::MEMBER_DEFAULT)
{
$this->_namespace = $namespace;
$this->_member = $member;
$this->_session = \DF\Session::get('zend_auth_'.$this->_namespace);
}
public function __construct($namespace = 'default', $member = self::MEMBER_DEFAULT)
{
$this->_namespace = $namespace;
$this->_member = $member;
$this->_session = \DF\Session::get('zend_auth_'.$this->_namespace);
}
}

View File

@ -11,104 +11,104 @@ class Cache
* User Cache
*/
// Load data from the cache.
public static function load($id)
{
$cache = self::getCache();
return $cache->load($id);
}
// Alias of the "load" function.
public static function get($id, $default = NULL)
{
return self::load($id);
}
// Test whether an ID is present in the cache.
public static function test($id)
{
$cache = self::getCache();
return $cache->test($id);
}
// Save an item to the cache.
public static function save($data, $id, $tags = array(), $specificLifetime = false)
{
$cache = self::getCache();
return $cache->save($data, $id, $tags, $specificLifetime);
}
// Alias for the "set" function.
public static function set($data, $id, $tags = array(), $specificLifetime = false)
{
self::save($data, $id, $tags, $specificLifetime);
}
// Special callback function to get or save a new cache entry.
public static function getOrSet($id, $default = NULL, $tags = array(), $specificLifetime = false)
{
$result = self::load($id);
if ($result === false)
{
$result = (is_callable($default)) ? $default() : $default;
if ($result !== null)
{
self::save($result, $id, $tags, $specificLifetime);
}
}
return $result;
}
// Delete an item from the cache.
public static function remove($id)
{
$cache = self::getCache();
return $cache->remove($id);
}
// Clean the cache.
public static function clean($mode = 'all', $tags = array())
{
if ($mode == 'all' && $tags)
$mode = \Zend_Cache::CLEANING_MODE_MATCHING_TAG;
$cache = self::getCache();
return $cache->clean($mode, $tags);
}
// Get all cache keys.
public static function getKeys()
{
$cache = self::getCache();
return $cache->getIds();
}
// Load data from the cache.
public static function load($id)
{
$cache = self::getCache();
return $cache->load($id);
}
// Alias of the "load" function.
public static function get($id, $default = NULL)
{
return self::load($id);
}
// Retrieve or initialize the cache.
// Test whether an ID is present in the cache.
public static function test($id)
{
$cache = self::getCache();
return $cache->test($id);
}
// Save an item to the cache.
public static function save($data, $id, $tags = array(), $specificLifetime = false)
{
$cache = self::getCache();
return $cache->save($data, $id, $tags, $specificLifetime);
}
// Alias for the "set" function.
public static function set($data, $id, $tags = array(), $specificLifetime = false)
{
self::save($data, $id, $tags, $specificLifetime);
}
// Special callback function to get or save a new cache entry.
public static function getOrSet($id, $default = NULL, $tags = array(), $specificLifetime = false)
{
$result = self::load($id);
if ($result === false)
{
$result = (is_callable($default)) ? $default() : $default;
if ($result !== null)
{
self::save($result, $id, $tags, $specificLifetime);
}
}
return $result;
}
// Delete an item from the cache.
public static function remove($id)
{
$cache = self::getCache();
return $cache->remove($id);
}
// Clean the cache.
public static function clean($mode = 'all', $tags = array())
{
if ($mode == 'all' && $tags)
$mode = \Zend_Cache::CLEANING_MODE_MATCHING_TAG;
$cache = self::getCache();
return $cache->clean($mode, $tags);
}
// Get all cache keys.
public static function getKeys()
{
$cache = self::getCache();
return $cache->getIds();
}
// Retrieve or initialize the cache.
protected static $_user_cache;
public static function getCache()
{
public static function getCache()
{
return self::getUserCache();
}
public static function getUserCache()
{
if (!is_object(self::$_user_cache))
{
$frontend_name = 'Core';
$frontend_options = array(
if (!is_object(self::$_user_cache))
{
$frontend_name = 'Core';
$frontend_options = array(
'cache_id_prefix' => self::getSitePrefix().'_user_',
'lifetime' => 3600,
'automatic_serialization' => true
);
// Choose the most optimal caching mechanism available.
'lifetime' => 3600,
'automatic_serialization' => true
);
// Choose the most optimal caching mechanism available.
list($backend_name, $backend_options) = self::getBackendCache();
self::$_user_cache = \Zend_Cache::factory($frontend_name, $backend_name, $frontend_options, $backend_options);
}
return self::$_user_cache;
}
self::$_user_cache = \Zend_Cache::factory($frontend_name, $backend_name, $frontend_options, $backend_options);
}
return self::$_user_cache;
}
/**
* Page Cache
@ -128,27 +128,27 @@ class Cache
public static function getPageCache()
{
if (!is_object(self::$_page_cache))
{
$frontend_name = 'Page';
$frontend_options = array(
{
$frontend_name = 'Page';
$frontend_options = array(
'cache_id_prefix' => self::getSitePrefix().'_page_',
'lifetime' => 3600,
'automatic_serialization' => true,
'lifetime' => 3600,
'automatic_serialization' => true,
'default_options' => array(
'cache_with_session_variables' => TRUE,
'cache_with_cookie_variables' => TRUE,
'make_id_with_session_variables' => FALSE,
'make_id_with_cookie_variables' => FALSE,
),
);
// Choose the most optimal caching mechanism available.
);
// Choose the most optimal caching mechanism available.
list($backend_name, $backend_options) = self::getBackendCache();
self::$_page_cache = \Zend_Cache::factory($frontend_name, $backend_name, $frontend_options, $backend_options);
}
return self::$_page_cache;
self::$_page_cache = \Zend_Cache::factory($frontend_name, $backend_name, $frontend_options, $backend_options);
}
return self::$_page_cache;
}
/**

View File

@ -6,222 +6,222 @@
namespace DF;
class Calendar
{
protected $_datecode;
protected $_month;
protected $_year;
protected $_start_timestamp;
protected $_mid_timestamp;
protected $_end_timestamp;
protected $_records;
public function __construct($datecode = NULL)
{
$datecode = ($datecode) ? (int)$datecode : date('Ym');
$this->setDateCode($datecode);
$this->_records = array();
}
public function setDateCode($datecode)
{
$this->_datecode = $datecode;
$this->_month = (int)substr($datecode, 4, 2);
$this->_year = (int)substr($datecode, 0, 4);
$mid_timestamp = mktime(0, 0, 0, $this->_month, 15, $this->_year);
if (!$this->isValidDate($mid_timestamp))
{
throw new \DF\Exception\DisplayOnly('Invalid date/time specified.');
}
$this->_start_timestamp = mktime(0, 0, 0, $this->_month, 1, $this->_year);
$this->_mid_timestamp = $mid_timestamp;
$this->_end_timestamp = mktime(0, 0, 0, $this->_month+1, 1, $this->_year);
}
public function getDateCode()
{
return $this->_datecode;
}
public function getTimestamps()
{
return array(
'start' => $this->_start_timestamp,
'mid' => $this->_mid_timestamp,
'end' => $this->_end_timestamp,
);
}
public function setRecords($records)
{
$this->_records = $records;
}
public function fetch($records = NULL)
{
if ($records)
$this->setRecords($records);
$return_vars = array();
// Current page.
$current_page_timestamp = $this->_mid_timestamp;
$return_vars['current_page_datecode'] = date('Ym', $current_page_timestamp);
$return_vars['current_page_text'] = date('F Y', $current_page_timestamp);
// Surrounding pages.
$prev_page_timestamp = strtotime("-1 month", $this->_mid_timestamp);
if ($this->isValidDate($prev_page_timestamp))
{
$return_vars['prev_page_datecode'] = date('Ym', $prev_page_timestamp);
$return_vars['prev_page_text'] = date('F Y', $prev_page_timestamp);
}
$next_page_timestamp = strtotime("+1 month", $this->_mid_timestamp);
if ($this->isValidDate($next_page_timestamp))
{
$return_vars['next_page_datecode'] = date('Ym', $next_page_timestamp);
$return_vars['next_page_text'] = date('F Y', $next_page_timestamp);
}
// Retrieves the day (Sunday = 0, Monday = 1, etc.) of the first day of the month.
$first_calendar_day = date('w', $this->_start_timestamp);
$days_in_previous_month = date('t', $prev_page_timestamp);
// Creates the cells containing the previous month's days, starting the first row.
for($i = 0; $i < $first_calendar_day+1; $i++)
{
$calendar_days[$i+1] = array(
'day' => $days_in_previous_month - ($first_calendar_day - $i) + 1,
'disabled' => true,
'records' => array(),
);
}
// Creates the cells containing the current month's days.
$k = $first_calendar_day+1;
$starting_index = $k;
$days_in_current_month = date('t', $this->_mid_timestamp);
for($i = 0; $i < $days_in_current_month; $i++)
{
$calendar_days[$i+$k] = array(
'day' => $i+1,
'records' => array()
);
}
// Creates the cells containing the next month's days, finishing the last row.
$k = $days_in_current_month + $k - 1;
$last_calendar_day = date('w', $this->_end_timestamp);
$j = 1;
for($i = $last_calendar_day+1; $i <= 7; $i++)
{
$calendar_days[$k+$j] = array(
'day' => $j,
'disabled' => true,
'class' => 'disabled',
'records' => array()
);
$j++;
}
$today_info = array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'));
$today = new \Zend_Date($today_info);
$today_timestamp = $today->getTimestamp();
// Create timestamp values for each day.
$day_timestamps = array();
for($i = 0; $i < $days_in_current_month; $i++)
{
$date_info = array(
'year' => $this->_year,
'month' => $this->_month,
'day' => $i+1,
);
$date = new \Zend_Date($date_info);
$date_timestamp = $date->getTimestamp();
$k = $starting_index+$i;
$day_timestamps[$k] = array(
'start' => $date_timestamp,
'end' => $date_timestamp + 86399,
);
if ($date_timestamp == $today_timestamp)
$calendar_days[$k]['class'] = 'blue';
}
// Populate records into days.
if ($this->_records)
{
foreach($this->_records as $record)
{
// Determine the "start" and "end" timestamps for the item.
if (isset($record['timestamp']))
{
$start_timestamp = (int)$record['timestamp'];
$end_timestamp = (int)$record['timestamp'];
}
else if (isset($record['start_timestamp']))
{
$start_timestamp = (int)$record['start_timestamp'];
$end_timestamp = (int)$record['end_timestamp'];
}
if ($start_timestamp && $end_timestamp)
{
foreach($day_timestamps as $i => $timestamps)
{
$day_start = $timestamps['start'];
$day_end = $timestamps['end'];
protected $_datecode;
protected $_month;
protected $_year;
protected $_start_timestamp;
protected $_mid_timestamp;
protected $_end_timestamp;
protected $_records;
public function __construct($datecode = NULL)
{
$datecode = ($datecode) ? (int)$datecode : date('Ym');
$this->setDateCode($datecode);
$this->_records = array();
}
public function setDateCode($datecode)
{
$this->_datecode = $datecode;
$this->_month = (int)substr($datecode, 4, 2);
$this->_year = (int)substr($datecode, 0, 4);
$mid_timestamp = mktime(0, 0, 0, $this->_month, 15, $this->_year);
if (!$this->isValidDate($mid_timestamp))
{
throw new \DF\Exception\DisplayOnly('Invalid date/time specified.');
}
$this->_start_timestamp = mktime(0, 0, 0, $this->_month, 1, $this->_year);
$this->_mid_timestamp = $mid_timestamp;
$this->_end_timestamp = mktime(0, 0, 0, $this->_month+1, 1, $this->_year);
}
public function getDateCode()
{
return $this->_datecode;
}
public function getTimestamps()
{
return array(
'start' => $this->_start_timestamp,
'mid' => $this->_mid_timestamp,
'end' => $this->_end_timestamp,
);
}
public function setRecords($records)
{
$this->_records = $records;
}
public function fetch($records = NULL)
{
if ($records)
$this->setRecords($records);
$return_vars = array();
// Current page.
$current_page_timestamp = $this->_mid_timestamp;
$return_vars['current_page_datecode'] = date('Ym', $current_page_timestamp);
$return_vars['current_page_text'] = date('F Y', $current_page_timestamp);
// Surrounding pages.
$prev_page_timestamp = strtotime("-1 month", $this->_mid_timestamp);
if ($this->isValidDate($prev_page_timestamp))
{
$return_vars['prev_page_datecode'] = date('Ym', $prev_page_timestamp);
$return_vars['prev_page_text'] = date('F Y', $prev_page_timestamp);
}
$next_page_timestamp = strtotime("+1 month", $this->_mid_timestamp);
if ($this->isValidDate($next_page_timestamp))
{
$return_vars['next_page_datecode'] = date('Ym', $next_page_timestamp);
$return_vars['next_page_text'] = date('F Y', $next_page_timestamp);
}
// Retrieves the day (Sunday = 0, Monday = 1, etc.) of the first day of the month.
$first_calendar_day = date('w', $this->_start_timestamp);
$days_in_previous_month = date('t', $prev_page_timestamp);
// Creates the cells containing the previous month's days, starting the first row.
for($i = 0; $i < $first_calendar_day+1; $i++)
{
$calendar_days[$i+1] = array(
'day' => $days_in_previous_month - ($first_calendar_day - $i) + 1,
'disabled' => true,
'records' => array(),
);
}
// Creates the cells containing the current month's days.
$k = $first_calendar_day+1;
$starting_index = $k;
$days_in_current_month = date('t', $this->_mid_timestamp);
for($i = 0; $i < $days_in_current_month; $i++)
{
$calendar_days[$i+$k] = array(
'day' => $i+1,
'records' => array()
);
}
// Creates the cells containing the next month's days, finishing the last row.
$k = $days_in_current_month + $k - 1;
$last_calendar_day = date('w', $this->_end_timestamp);
$j = 1;
for($i = $last_calendar_day+1; $i <= 7; $i++)
{
$calendar_days[$k+$j] = array(
'day' => $j,
'disabled' => true,
'class' => 'disabled',
'records' => array()
);
$j++;
}
$today_info = array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'));
$today = new \Zend_Date($today_info);
$today_timestamp = $today->getTimestamp();
// Create timestamp values for each day.
$day_timestamps = array();
for($i = 0; $i < $days_in_current_month; $i++)
{
$date_info = array(
'year' => $this->_year,
'month' => $this->_month,
'day' => $i+1,
);
$date = new \Zend_Date($date_info);
$date_timestamp = $date->getTimestamp();
$k = $starting_index+$i;
$day_timestamps[$k] = array(
'start' => $date_timestamp,
'end' => $date_timestamp + 86399,
);
if ($date_timestamp == $today_timestamp)
$calendar_days[$k]['class'] = 'blue';
}
// Populate records into days.
if ($this->_records)
{
foreach($this->_records as $record)
{
// Determine the "start" and "end" timestamps for the item.
if (isset($record['timestamp']))
{
$start_timestamp = (int)$record['timestamp'];
$end_timestamp = (int)$record['timestamp'];
}
else if (isset($record['start_timestamp']))
{
$start_timestamp = (int)$record['start_timestamp'];
$end_timestamp = (int)$record['end_timestamp'];
}
if ($start_timestamp && $end_timestamp)
{
foreach($day_timestamps as $i => $timestamps)
{
$day_start = $timestamps['start'];
$day_end = $timestamps['end'];
$day_record = $record;
$day_record['starts_today'] = ($start_timestamp > $day_start && $start_timestamp < $day_end);
$day_record['ends_today'] = ($end_timestamp > $day_start && $end_timestamp < $day_end);
$day_record['only_today'] = ($day_record['starts_today'] && $day_record['ends_today']);
$day_record = $record;
$day_record['starts_today'] = ($start_timestamp > $day_start && $start_timestamp < $day_end);
$day_record['ends_today'] = ($end_timestamp > $day_start && $end_timestamp < $day_end);
$day_record['only_today'] = ($day_record['starts_today'] && $day_record['ends_today']);
if ($day_record['is_all_day'])
$day_record['time'] = 'All Day';
elseif ($day_record['only_today'])
$day_record['time'] = date('g:ia', $start_timestamp).' to '.date('g:ia', $end_timestamp);
elseif ($day_record['starts_today'])
$day_record['time'] = 'Starts '.date('g:ia', $start_timestamp);
elseif ($day_record['ends_today'])
$day_record['time'] = 'Ends '.date('g:ia', $end_timestamp);
else
$day_record['time'] = 'All Day';
if ($start_timestamp < $day_end && $end_timestamp > $day_start)
{
$calendar_days[$i]['records'][] = $day_record;
}
}
}
}
}
// Reassign calendar days into rows.
$new_calendar_days = array();
foreach($calendar_days as $calendar_day_num => $calendar_day_info)
{
$current_row = floor(($calendar_day_num-1) / 7);
$new_calendar_days[$current_row][] = $calendar_day_info;
}
$return_vars['days'] = $new_calendar_days;
return $return_vars;
}
protected function isValidDate($timestamp)
{
$threshold = 86400 * 365 * 5; // 5 Years
return ($timestamp >= (time() - $threshold) && $timestamp <= (time() + $threshold));
}
if ($day_record['is_all_day'])
$day_record['time'] = 'All Day';
elseif ($day_record['only_today'])
$day_record['time'] = date('g:ia', $start_timestamp).' to '.date('g:ia', $end_timestamp);
elseif ($day_record['starts_today'])
$day_record['time'] = 'Starts '.date('g:ia', $start_timestamp);
elseif ($day_record['ends_today'])
$day_record['time'] = 'Ends '.date('g:ia', $end_timestamp);
else
$day_record['time'] = 'All Day';
if ($start_timestamp < $day_end && $end_timestamp > $day_start)
{
$calendar_days[$i]['records'][] = $day_record;
}
}
}
}
}
// Reassign calendar days into rows.
$new_calendar_days = array();
foreach($calendar_days as $calendar_day_num => $calendar_day_info)
{
$current_row = floor(($calendar_day_num-1) / 7);
$new_calendar_days[$current_row][] = $calendar_day_info;
}
$return_vars['days'] = $new_calendar_days;
return $return_vars;
}
protected function isValidDate($timestamp)
{
$threshold = 86400 * 365 * 5; // 5 Years
return ($timestamp >= (time() - $threshold) && $timestamp <= (time() + $threshold));
}
}

View File

@ -9,86 +9,86 @@ require_once('Zend/Config.php');
class Config
{
protected $_baseFolder;
protected $_loaded_configs;
public function __construct($baseFolder)
{
$this->_loaded_configs = array();
if(is_dir($baseFolder))
$this->_baseFolder = $baseFolder;
else
throw new \Zend_Exception("Invalid base folder for configurations.");
}
public function preload($configs)
{
$config_array = (is_array($configs)) ? $configs : array($configs);
foreach($config_array as $config_item)
{
$this->__get($config_item);
}
}
public function __set($name, $value)
{
throw new \Zend_Exception("Configuration is read-only.");
}
public function __get($name)
{
if (!isset($this->_loaded_configs[$name]))
{
$config_name = str_replace(array('.','..'), array('', ''), $name);
$config_base = $this->_baseFolder.DIRECTORY_SEPARATOR.$config_name;
if (is_dir($config_base))
return new self($config_base); // Return entire directories.
else
$this_config = $this->getFile($config_base); // Return single files.
$this->_loaded_configs[$name] = $this_config;
}
return $this->_loaded_configs[$name];
}
public function getFile($config_base)
{
if (file_exists($config_base))
return new \Zend_Config(require $config_base);
if (file_exists($config_base.'.conf.php'))
return new \Zend_Config(require $config_base.'.conf.php');
else if (file_exists($config_base.'.ini'))
return new \Zend_Config_Ini($config_base.'.ini');
else if (file_exists($config_base.'.xml'))
return new \Zend_Config_Xml($config_base.'.xml');
else
return new \Zend_Config(array());
}
/**
* Static Functions
*/
public static function loadConfig($directory)
{
return new self($directory);
}
public static function loadModuleConfig($directory)
{
$module_config = array();
protected $_baseFolder;
protected $_loaded_configs;
public function __construct($baseFolder)
{
$this->_loaded_configs = array();
if(is_dir($baseFolder))
$this->_baseFolder = $baseFolder;
else
throw new \Zend_Exception("Invalid base folder for configurations.");
}
public function preload($configs)
{
$config_array = (is_array($configs)) ? $configs : array($configs);
foreach($config_array as $config_item)
{
$this->__get($config_item);
}
}
public function __set($name, $value)
{
throw new \Zend_Exception("Configuration is read-only.");
}
public function __get($name)
{
if (!isset($this->_loaded_configs[$name]))
{
$config_name = str_replace(array('.','..'), array('', ''), $name);
$config_base = $this->_baseFolder.DIRECTORY_SEPARATOR.$config_name;
if (is_dir($config_base))
return new self($config_base); // Return entire directories.
else
$this_config = $this->getFile($config_base); // Return single files.
$this->_loaded_configs[$name] = $this_config;
}
return $this->_loaded_configs[$name];
}
public function getFile($config_base)
{
if (file_exists($config_base))
return new \Zend_Config(require $config_base);
if (file_exists($config_base.'.conf.php'))
return new \Zend_Config(require $config_base.'.conf.php');
else if (file_exists($config_base.'.ini'))
return new \Zend_Config_Ini($config_base.'.ini');
else if (file_exists($config_base.'.xml'))
return new \Zend_Config_Xml($config_base.'.xml');
else
return new \Zend_Config(array());
}
/**
* Static Functions
*/
public static function loadConfig($directory)
{
return new self($directory);
}
public static function loadModuleConfig($directory)
{
$module_config = array();
foreach(new \DirectoryIterator($directory) as $item)
{
if($item->isDir() && !$item->isDot())
{
$config = $item->getPathname().DIRECTORY_SEPARATOR.'config';
if(file_exists($config))
$module_config[$item->getFilename()] = new self($config);
$config = $item->getPathname().DIRECTORY_SEPARATOR.'config';
if(file_exists($config))
$module_config[$item->getFilename()] = new self($config);
}
}
return $module_config;
}
}
}

View File

@ -8,75 +8,75 @@ use DF\Flash;
class Action extends \Zend_Controller_Action
{
public $config;
public $module_config;
public $auth;
public $acl;
public $test_mode;
public $config;
public $module_config;
public $auth;
public $acl;
public $test_mode;
public $em;
public $module_name;
public function init()
{
$this->config = $this->view->config = \Zend_Registry::get('config');
$this->module_config = $this->view->module_config = \Zend_Registry::get('module_config');
$this->auth = $this->view->auth = \Zend_Registry::get('auth');
$this->acl = $this->view->acl = \Zend_Registry::get('acl');
$this->config = $this->view->config = \Zend_Registry::get('config');
$this->module_config = $this->view->module_config = \Zend_Registry::get('module_config');
$this->auth = $this->view->auth = \Zend_Registry::get('auth');
$this->acl = $this->view->acl = \Zend_Registry::get('acl');
$this->em = \Zend_Registry::get('em');
$this->module_name = $this->_getModuleName();
\Zend_Registry::set('module_name', $this->module_name);
if (isset($this->module_config[$this->module_name]))
$this->current_module_config = $this->module_config[$this->module_name];
$this->test_mode = $this->isTestMode();
if ($this->test_mode)
{
$front = $this->getFrontController();
$front->setParam('noErrorHandler', true);
}
$this->module_name = $this->_getModuleName();
\Zend_Registry::set('module_name', $this->module_name);
if (isset($this->module_config[$this->module_name]))
$this->current_module_config = $this->module_config[$this->module_name];
$this->test_mode = $this->isTestMode();
if ($this->test_mode)
{
$front = $this->getFrontController();
$front->setParam('noErrorHandler', true);
}
$this->preInit();
$isAllowed = $this->permissions();
if (!$isAllowed)
{
if (!\DF\Auth::isLoggedIn())
throw new NotLoggedIn;
else
throw new PermissionDenied;
}
$isAllowed = $this->permissions();
if (!$isAllowed)
{
if (!\DF\Auth::isLoggedIn())
throw new NotLoggedIn;
else
throw new PermissionDenied;
}
$this->postInit();
}
public function preInit() {}
public function postInit() {}
protected function _getModuleName()
{
$front = $this->getFrontController();
$request = $this->getRequest();
$module = $request->getModuleName();
if (!$module)
$module = $front->getDispatcher()->getDefaultModule();
return $module;
}
protected function _getControllerName()
{
return $this->getRequest()->getControllerName();
}
protected function _getActionName()
{
return $this->getRequest()->getActionName();
}
protected function _getMvcPath($appendPath = null)
protected function _getModuleName()
{
$front = $this->getFrontController();
$request = $this->getRequest();
$module = $request->getModuleName();
if (!$module)
$module = $front->getDispatcher()->getDefaultModule();
return $module;
}
protected function _getControllerName()
{
return $this->getRequest()->getControllerName();
}
protected function _getActionName()
{
return $this->getRequest()->getActionName();
}
protected function _getMvcPath($appendPath = null)
{
if (!isset($this->_mvcPath)) {
$front = $this->getFrontController();
@ -100,49 +100,49 @@ class Action extends \Zend_Controller_Action
{
return true;
}
public function preDispatch()
{
$is_ajax = ($this->isAjax());
$this->view->is_ajax = $is_ajax;
if ($is_ajax)
\Zend_Layout::getMvcInstance()->disableLayout();
public function preDispatch()
{
$is_ajax = ($this->isAjax());
$this->view->is_ajax = $is_ajax;
if ($is_ajax)
\Zend_Layout::getMvcInstance()->disableLayout();
if ($this->_hasParam('debug') && $this->_getParam('debug') === 'true')
{
error_reporting(E_ALL & ~E_STRICT);
ini_set('display_errors', 1);
}
}
public function postDispatch()
{
$db_log = $this->em->getConnection()->getConfiguration()->getSQLLogger();
if ($db_log instanceof \Doctrine\DBAL\Logging\SQLLogger)
{
if (DF_APPLICATION_ENV != "production" || $this->acl->isAllowed('administer all'))
{
$logger = new \Zend_Log(new \Zend_Log_Writer_Firebug);
foreach((array)$db_log->queries as $query)
$logger->info(round($query['executionMS'], 5).': '.$query['sql']);
}
}
}
public function isAjax()
{
return $this->_request->isXmlHttpRequest();
}
public function renderJson($json_data)
{
$this->doNotRender();
$this->getResponse()->appendBody(\Zend_Json::encode($json_data));
}
if ($this->_hasParam('debug') && $this->_getParam('debug') === 'true')
{
error_reporting(E_ALL & ~E_STRICT);
ini_set('display_errors', 1);
}
}
public function postDispatch()
{
$db_log = $this->em->getConnection()->getConfiguration()->getSQLLogger();
if ($db_log instanceof \Doctrine\DBAL\Logging\SQLLogger)
{
if (DF_APPLICATION_ENV != "production" || $this->acl->isAllowed('administer all'))
{
$logger = new \Zend_Log(new \Zend_Log_Writer_Firebug);
foreach((array)$db_log->queries as $query)
$logger->info(round($query['executionMS'], 5).': '.$query['sql']);
}
}
}
public function isAjax()
{
return $this->_request->isXmlHttpRequest();
}
public function renderJson($json_data)
{
$this->doNotRender();
$this->getResponse()->appendBody(\Zend_Json::encode($json_data));
}
public function getResource($resource_name)
{
if( isset($this->getInvokeArg('bootstrap')->getContainer()->{$resource_name}) )
@ -150,17 +150,17 @@ class Action extends \Zend_Controller_Action
else
return false;
}
public function flash($message, $level = Flash::INFO)
{
return $this->alert($message, $level);
}
public function alert($message, $level = Flash::INFO)
{
$func_args = func_get_args();
call_user_func_array('\DF\Flash::addMessage', $func_args);
}
public function flash($message, $level = Flash::INFO)
{
return $this->alert($message, $level);
}
public function alert($message, $level = Flash::INFO)
{
$func_args = func_get_args();
call_user_func_array('\DF\Flash::addMessage', $func_args);
}
public function redirect($url, array $options = null)
{
@ -174,32 +174,32 @@ class Action extends \Zend_Controller_Action
$this->_helper->_redirector->gotoUrl($url, $options);
}
protected function redirectHome()
{
$this->redirect(Url::route(array(
'module' => 'default',
'controller' => 'index',
'action' => 'index',
)));
}
protected function redirectHere()
{
$this->redirect(Url::route(array(), NULL, FALSE));
}
protected function redirectToRoute()
{
$func_args = func_get_args();
$routed_url = call_user_func_array('\DF\Url::route', $func_args);
$this->redirect($routed_url);
}
protected function redirectFromHere()
{
$func_args = func_get_args();
$routed_url = Url::route($func_args[0], NULL, FALSE);
$this->redirect($routed_url);
}
protected function redirectHome()
{
$this->redirect(Url::route(array(
'module' => 'default',
'controller' => 'index',
'action' => 'index',
)));
}
protected function redirectHere()
{
$this->redirect(Url::route(array(), NULL, FALSE));
}
protected function redirectToRoute()
{
$func_args = func_get_args();
$routed_url = call_user_func_array('\DF\Url::route', $func_args);
$this->redirect($routed_url);
}
protected function redirectFromHere()
{
$func_args = func_get_args();
$routed_url = Url::route($func_args[0], NULL, FALSE);
$this->redirect($routed_url);
}
protected function doNotRender()
{
@ -209,49 +209,49 @@ class Action extends \Zend_Controller_Action
protected function isTestMode()
{
return (defined('DF_TEST_MODE') && DF_TEST_MODE == true);
return (defined('DF_TEST_MODE') && DF_TEST_MODE == true);
}
protected function renderForm($form, $mode = 'edit', $form_title = NULL)
{
$this->_helper->viewRenderer->setNoRender();
$body = '';
if ($form_title)
{
// Show visible title.
$body .= '<h2>'.$form_title.'</h2>';
}
if ($this->isAjax())
{
// Show title if otherwise not set.
if (!$form_title)
{
$title = current($this->view->headTitle()->getIterator());
$body .= '<h2 class="page_title">'.$title.'</h2>';
}
// Proper action routing.
if (!$form->getAction())
{
$form->setAction(\DF\Url::current());
}
}
// Form render mode.
if ($mode == 'edit')
$body .= $form->render();
else
$body .= $form->renderView();
$this->getResponse()->appendBody($body);
$this->_helper->viewRenderer->setNoRender();
$body = '';
if ($form_title)
{
// Show visible title.
$body .= '<h2>'.$form_title.'</h2>';
}
if ($this->isAjax())
{
// Show title if otherwise not set.
if (!$form_title)
{
$title = current($this->view->headTitle()->getIterator());
$body .= '<h2 class="page_title">'.$title.'</h2>';
}
// Proper action routing.
if (!$form->getAction())
{
$form->setAction(\DF\Url::current());
}
}
// Form render mode.
if ($mode == 'edit')
$body .= $form->render();
else
$body .= $form->renderView();
$this->getResponse()->appendBody($body);
}
/**
* Referrer storage
*/
/**
* Referrer storage
*/
protected function storeReferrer($namespace = 'default', $loose = true)
{
$session = new \Zend_Session_Namespace('df_referrer_'.strtolower($namespace));
@ -293,10 +293,10 @@ class Action extends \Zend_Controller_Action
$this->redirect(Url::referrer($default));
}
/**
* CSRF security token validation
*/
/**
* CSRF security token validation
*/
protected function validateToken($token, $redirect = true)
{
if(!\DF\Csrf::validateToken($token) )
@ -320,17 +320,17 @@ class Action extends \Zend_Controller_Action
protected function convertGetToParam($params)
{
if (!is_array($params))
$params = array($params);
$url_changes = array();
foreach($params as $param)
{
if (isset($_GET[$param]))
$url_changes[$param] = $_GET[$param];
}
if (count($url_changes) > 0)
$this->redirectFromHere($url_changes);
if (!is_array($params))
$params = array($params);
$url_changes = array();
foreach($params as $param)
{
if (isset($_GET[$param]))
$url_changes[$param] = $_GET[$param];
}
if (count($url_changes) > 0)
$this->redirectFromHere($url_changes);
}
}

View File

@ -4,7 +4,7 @@ class Csrf
{
public static function getToken()
{
$session = new \Zend_Session_Namespace('csrf');
$session = new \Zend_Session_Namespace('csrf');
if( !isset($session->token) )
self::resetToken();
@ -13,7 +13,7 @@ class Csrf
public static function validateToken($token)
{
$session = new \Zend_Session_Namespace('csrf');
$session = new \Zend_Session_Namespace('csrf');
$old_token = $session->token;
self::resetToken();
@ -23,7 +23,7 @@ class Csrf
public static function resetToken()
{
$session = new \Zend_Session_Namespace('csrf');
$session->token = sprintf("%s:%d", md5(uniqid(mt_rand(), true)), time());
$session = new \Zend_Session_Namespace('csrf');
$session->token = sprintf("%s:%d", md5(uniqid(mt_rand(), true)), time());
}
}

View File

@ -9,26 +9,26 @@ class Cache extends \Doctrine\Common\Cache\CacheProvider
{
protected function doFetch($id, $testCacheValidity = true)
{
return \DF\Cache::get($this->_filterCacheId($id));
return \DF\Cache::get($this->_filterCacheId($id));
}
protected function doContains($id)
{
return \DF\Cache::test($this->_filterCacheId($id));
return \DF\Cache::test($this->_filterCacheId($id));
}
protected function doSave($id, $data, $lifeTime = NULL)
{
if ($lifeTime == 0)
$lifeTime = NULL;
\DF\Cache::save($data, $this->_filterCacheId($id), array(), $lifeTime);
if ($lifeTime == 0)
$lifeTime = NULL;
\DF\Cache::save($data, $this->_filterCacheId($id), array(), $lifeTime);
return true;
}
protected function doDelete($id)
{
\DF\Cache::remove($this->_filterCacheId($id));
\DF\Cache::remove($this->_filterCacheId($id));
}
protected function doGetStats()
@ -43,25 +43,25 @@ class Cache extends \Doctrine\Common\Cache\CacheProvider
public function getIds()
{
$all_keys = \DF\Cache::getKeys();
if (!$this->_prefix)
{
return $all_keys;
}
else
{
$relevant_keys = array();
foreach((array)$all_keys as $key_name => $key_value)
{
if (strpos($key_name, $this->_prefix) === 0)
{
$filtered_name = str_replace($this->_prefix.'_', '', $key_name);
$relevant_keys[$filtered_name] = $key_value;
}
}
return $relevant_keys;
}
$all_keys = \DF\Cache::getKeys();
if (!$this->_prefix)
{
return $all_keys;
}
else
{
$relevant_keys = array();
foreach((array)$all_keys as $key_name => $key_value)
{
if (strpos($key_name, $this->_prefix) === 0)
{
$filtered_name = str_replace($this->_prefix.'_', '', $key_name);
$relevant_keys[$filtered_name] = $key_value;
}
}
return $relevant_keys;
}
}
protected function _filterCacheId($id)

View File

@ -12,9 +12,9 @@ class Entity implements \ArrayAccess
$method_name = $this->_getMethodName($key, 'get');
if (method_exists($this, $method_name))
return $this->$method_name();
else
return $this->_getVar($key);
return $this->$method_name();
else
return $this->_getVar($key);
}
public function __set($key, $value)
@ -22,9 +22,9 @@ class Entity implements \ArrayAccess
$method_name = $this->_getMethodName($key, 'set');
if (method_exists($this, $method_name))
return $this->$method_name($value);
else
return $this->_setVar($key, $value);
return $this->$method_name($value);
else
return $this->_setVar($key, $value);
}
public function __call($method, $arguments)
@ -42,15 +42,15 @@ class Entity implements \ArrayAccess
protected function _getVar($var)
{
if (property_exists($this, $var))
return $this->$var;
else
return NULL;
if (property_exists($this, $var))
return $this->$var;
else
return NULL;
}
protected function _setVar($var, $value)
{
if (property_exists($this, $var))
$this->$var = $value;
if (property_exists($this, $var))
$this->$var = $value;
}
// Converts "varNameBlah" to "var_name_blah".
@ -62,7 +62,7 @@ class Entity implements \ArrayAccess
// Converts "getvar_name_blah" to "getVarNameBlah".
protected function _getMethodName($var, $prefix = '')
{
return $prefix.str_replace(" ", "", ucwords(strtr($var, "_-", " ")));
return $prefix.str_replace(" ", "", ucwords(strtr($var, "_-", " ")));
}
/**
@ -75,20 +75,20 @@ class Entity implements \ArrayAccess
}
public function offsetSet($key, $value)
{
$method_name = $this->_getMethodName($key, 'set');
$method_name = $this->_getMethodName($key, 'set');
if (method_exists($this, $method_name))
return $this->$method_name($value);
else
return $this->_setVar($key, $value);
return $this->$method_name($value);
else
return $this->_setVar($key, $value);
}
public function offsetGet($key)
{
$method_name = $this->_getMethodName($key, 'get');
if (method_exists($this, $method_name))
return $this->$method_name();
else
return $this->_getVar($key);
return $this->$method_name();
else
return $this->_getVar($key);
}
public function offsetUnset($offset)
{
@ -210,9 +210,9 @@ class Entity implements \ArrayAccess
else
{
if (!isset($meta->fieldMappings[$field]))
$field_info = array();
else
$field_info = $meta->fieldMappings[$field];
$field_info = array();
else
$field_info = $meta->fieldMappings[$field];
switch($field_info['type'])
{
@ -221,11 +221,11 @@ class Entity implements \ArrayAccess
if (!($value instanceof \DateTime))
{
if ($value)
{
{
if (!is_numeric($value))
$value = strtotime($value);
$value = \DateTime::createFromFormat(\DateTime::ISO8601, date(\DateTime::ISO8601, (int)$value));
$value = strtotime($value);
$value = \DateTime::createFromFormat(\DateTime::ISO8601, date(\DateTime::ISO8601, (int)$value));
}
else
{
@ -253,9 +253,9 @@ class Entity implements \ArrayAccess
break;
case "boolean":
if ($value !== NULL)
$value = (bool)$value;
break;
if ($value !== NULL)
$value = (bool)$value;
break;
}
$this->__set($field, $value);
@ -290,9 +290,9 @@ class Entity implements \ArrayAccess
$prop_val = $property->getValue($this);
if (isset($class_meta->fieldMappings[$prop_name]))
$prop_info = $class_meta->fieldMappings[$prop_name];
else
$prop_info = array();
$prop_info = $class_meta->fieldMappings[$prop_name];
else
$prop_info = array();
if (is_array($prop_val))
{
@ -300,10 +300,10 @@ class Entity implements \ArrayAccess
}
else if (!is_object($prop_val))
{
if ($prop_info['type'] == "array")
$return_arr[$prop_name] = (array)$prop_val;
else
$return_arr[$prop_name] = (string)$prop_val;
if ($prop_info['type'] == "array")
$return_arr[$prop_name] = (array)$prop_val;
else
$return_arr[$prop_name] = (string)$prop_val;
}
else if ($prop_val instanceof \DateTime)
{
@ -311,34 +311,34 @@ class Entity implements \ArrayAccess
}
else if ($deep)
{
if ($prop_val instanceof \Doctrine\Common\Collections\Collection)
{
$return_val = array();
if (count($prop_val) > 0)
{
foreach($prop_val as $val_obj)
{
if ($form_mode)
{
$obj_meta = $em->getClassMetadata(get_class($val_obj));
$id_field = $obj_meta->identifier;
if ($prop_val instanceof \Doctrine\Common\Collections\Collection)
{
$return_val = array();
if (count($prop_val) > 0)
{
foreach($prop_val as $val_obj)
{
if ($form_mode)
{
$obj_meta = $em->getClassMetadata(get_class($val_obj));
$id_field = $obj_meta->identifier;
if ($id_field && count($id_field) == 1)
$return_val[] = $val_obj->{$id_field[0]};
}
else
{
$return_val[] = $val_obj->toArray(FALSE);
}
}
}
if ($id_field && count($id_field) == 1)
$return_val[] = $val_obj->{$id_field[0]};
}
else
{
$return_val[] = $val_obj->toArray(FALSE);
}
}
}
$return_arr[$prop_name] = $return_val;
}
else
{
$return_arr[$prop_name] = $prop_val->toArray(FALSE);
}
$return_arr[$prop_name] = $return_val;
}
else
{
$return_arr[$prop_name] = $prop_val->toArray(FALSE);
}
}
}
}
@ -349,7 +349,7 @@ class Entity implements \ArrayAccess
/* Save (A Docrine 1 Classic) */
public function save()
{
$em = self::getEntityManager();
$em = self::getEntityManager();
$em->persist($this);
$em->flush($this);
}
@ -357,32 +357,32 @@ class Entity implements \ArrayAccess
/* Delete (A Docrine 1 Classic) */
public function delete($hard_delete = FALSE)
{
$em = \Zend_Registry::get('em');
// Support for soft-deletion.
if (!$hard_delete && property_exists($this, 'deleted_at'))
{
// Determine type of deleted field.
$class_meta = $em->getClassMetadata(get_called_class());
$deleted_at_type = $class_meta->fieldMappings['deleted_at']['type'];
if ($deleted_at_type == "datetime")
$this->deleted_at = new \DateTime('NOW');
else
$this->deleted_at = true;
$this->save();
}
else
{
$em = \Zend_Registry::get('em');
$em->remove($this);
$em->flush();
}
$em = \Zend_Registry::get('em');
// Support for soft-deletion.
if (!$hard_delete && property_exists($this, 'deleted_at'))
{
// Determine type of deleted field.
$class_meta = $em->getClassMetadata(get_called_class());
$deleted_at_type = $class_meta->fieldMappings['deleted_at']['type'];
if ($deleted_at_type == "datetime")
$this->deleted_at = new \DateTime('NOW');
else
$this->deleted_at = true;
$this->save();
}
else
{
$em = \Zend_Registry::get('em');
$em->remove($this);
$em->flush();
}
}
public function hardDelete()
{
return $this->delete(TRUE);
return $this->delete(TRUE);
}
public function detach()
@ -405,13 +405,13 @@ class Entity implements \ArrayAccess
public static function getEntityManager()
{
static $em;
if ($em === NULL)
$em = \Zend_Registry::get('em');
return $em;
}
static $em;
if ($em === NULL)
$em = \Zend_Registry::get('em');
return $em;
}
/* Fetch the global entity manager to get a repository class. */
public static function getRepository()
@ -447,34 +447,34 @@ class Entity implements \ArrayAccess
/* Generic dropdown builder function (can be overridden for specialized use cases). */
public static function fetchSelect($add_blank = FALSE, \Closure $display = NULL, $pk = 'id', $order_by = 'name')
{
$select = array();
// Specify custom text in the $add_blank parameter to override.
if ($add_blank !== FALSE)
$select[''] = ($add_blank === TRUE) ? 'Select...' : $add_blank;
// Build query for records.
$class = get_called_class();
$em = self::getEntityManager();
$qb = $em->createQueryBuilder()->from($class, 'e');
if ($display === NULL)
$qb->select('e.'.$pk)->addSelect('e.name')->orderBy('e.'.$order_by, 'ASC');
else
$qb->select('e')->orderBy('e.'.$order_by, 'ASC');
$results = $qb->getQuery()->getArrayResult();
// Assemble select values and, if necessary, call $display callback.
foreach((array)$results as $result)
{
$key = $result[$pk];
$value = ($display === NULL) ? $result['name'] : $display($result);
$select[$key] = $value;
}
return $select;
$select = array();
// Specify custom text in the $add_blank parameter to override.
if ($add_blank !== FALSE)
$select[''] = ($add_blank === TRUE) ? 'Select...' : $add_blank;
// Build query for records.
$class = get_called_class();
$em = self::getEntityManager();
$qb = $em->createQueryBuilder()->from($class, 'e');
if ($display === NULL)
$qb->select('e.'.$pk)->addSelect('e.name')->orderBy('e.'.$order_by, 'ASC');
else
$qb->select('e')->orderBy('e.'.$order_by, 'ASC');
$results = $qb->getQuery()->getArrayResult();
// Assemble select values and, if necessary, call $display callback.
foreach((array)$results as $result)
{
$key = $result[$pk];
$value = ($display === NULL) ? $result['name'] : $display($result);
$select[$key] = $value;
}
return $select;
}
/* Find a specific item by primary key. */

View File

@ -7,21 +7,21 @@ class SoftDelete extends SQLFilter
{
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
if (!isset($targetEntity->fieldMappings['deleted_at']))
return '';
// Check for whether filter is being called from within a proxy and exempt from filter if so.
$has_proxy = FALSE;
$backtrace = debug_backtrace();
foreach($backtrace as $log)
{
if (stristr($log['class'], 'Proxy') !== FALSE)
$has_proxy = TRUE;
}
if ($has_proxy)
return '';
else
return $targetTableAlias.'.deleted_at IS NULL';
if (!isset($targetEntity->fieldMappings['deleted_at']))
return '';
// Check for whether filter is being called from within a proxy and exempt from filter if so.
$has_proxy = FALSE;
$backtrace = debug_backtrace();
foreach($backtrace as $log)
{
if (stristr($log['class'], 'Proxy') !== FALSE)
$has_proxy = TRUE;
}
if ($has_proxy)
return '';
else
return $targetTableAlias.'.deleted_at IS NULL';
}
}

View File

@ -3,13 +3,13 @@ namespace DF\Doctrine\Logger;
class EchoSQL extends \Doctrine\DBAL\Logging\EchoSQLLogger
{
public function startQuery($sql, array $params = null, array $types = null)
public function startQuery($sql, array $params = null, array $types = null)
{
echo $sql.PHP_EOL;
echo $sql.PHP_EOL;
if ($params) {
var_dump($params);
}
}
if ($types) {
var_dump($types);

View File

@ -13,23 +13,23 @@ use Doctrine\DBAL\Types\Type;
class Mssql extends \Doctrine\DBAL\Platforms\SQLServer2008Platform
{
/**
/**
* @override
*/
public function getAlterTableSQL(TableDiff $diff)
{
static $schema;
// Initialize schema.
if ($schema === NULL)
{
$em = \Zend_Registry::get('em');
$sm = $em->getConnection()->getSchemaManager();
$schema = $sm->createSchema();
}
$current_table = $schema->getTable($diff->name);
$sql = array();
static $schema;
// Initialize schema.
if ($schema === NULL)
{
$em = \Zend_Registry::get('em');
$sm = $em->getConnection()->getSchemaManager();
$schema = $sm->createSchema();
}
$current_table = $schema->getTable($diff->name);
$sql = array();
$queryParts = array();
if ($diff->newName !== false) {
@ -44,21 +44,21 @@ class Mssql extends \Doctrine\DBAL\Platforms\SQLServer2008Platform
$queryParts[] = 'DROP COLUMN ' . $column->getQuotedName($this);
}
foreach ($diff->changedColumns AS $columnDiff)
{
// Check for columns that aren't really different (custom types).
$current_column = $current_table->getColumn($columnDiff->oldColumnName)->toArray();
$column = $columnDiff->column->toArray();
$current_def = $current_column['type']->getSqlDeclaration($current_column, $this);
$new_def = $column['type']->getSqlDeclaration($column, $this);
if ($new_def != $current_def)
$queryParts[] = 'ALTER COLUMN '.$columnDiff->oldColumnName.' '.$new_def;
foreach ($diff->changedColumns AS $columnDiff)
{
// Check for columns that aren't really different (custom types).
$current_column = $current_table->getColumn($columnDiff->oldColumnName)->toArray();
$column = $columnDiff->column->toArray();
$current_def = $current_column['type']->getSqlDeclaration($current_column, $this);
$new_def = $column['type']->getSqlDeclaration($column, $this);
if ($new_def != $current_def)
$queryParts[] = 'ALTER COLUMN '.$columnDiff->oldColumnName.' '.$new_def;
}
foreach ($diff->renamedColumns AS $oldColumnName => $column) {
$sql[] = "EXEC sp_rename @objname = '".$diff->name.".".$oldColumnName."', @newname = '".$column->getQuotedName($this)."', @objtype = 'COLUMN'";
$sql[] = "EXEC sp_rename @objname = '".$diff->name.".".$oldColumnName."', @newname = '".$column->getQuotedName($this)."', @objtype = 'COLUMN'";
}
foreach ($queryParts as $query) {

View File

@ -14,7 +14,7 @@ class SoftArray extends ArrayType
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{
if ($value === null)
return null;
return null;
$value = (is_resource($value)) ? stream_get_contents($value) : $value;

View File

@ -10,30 +10,30 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
*/
class UnixDateTime extends IntegerType
{
const TYPENAME = 'unixdatetime';
public function getName()
{
return self::TYPENAME;
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
const TYPENAME = 'unixdatetime';
public function getName()
{
if ($value !== NULL)
{
if ($value instanceof \DateTime)
return $value->getTimestamp();
else
return (int)$value;
}
return NULL;
return self::TYPENAME;
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value !== NULL)
{
if ($value instanceof \DateTime)
return $value->getTimestamp();
else
return (int)$value;
}
return NULL;
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ((int)$value)
return \DateTime::createFromFormat(\DateTime::ISO8601, date(\DateTime::ISO8601, (int)$value));
else
return NULL;
if ((int)$value)
return \DateTime::createFromFormat(\DateTime::ISO8601, date(\DateTime::ISO8601, (int)$value));
else
return NULL;
}
}

View File

@ -10,37 +10,37 @@ define("DF_ENCRYPTION_CIPHER", MCRYPT_RIJNDAEL_128);
class Encryption
{
public static function encrypt($string)
{
// Create initialization vector.
$iv_size = mcrypt_get_iv_size(DF_ENCRYPTION_CIPHER, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
// Trim encryption key to size supported by this cipher.
$key = substr(DF_ENCRYPTION_KEY, 0, mcrypt_get_key_size(DF_ENCRYPTION_CIPHER, MCRYPT_MODE_ECB));
$encrypted_string = mcrypt_encrypt(DF_ENCRYPTION_CIPHER, $key, trim($string), MCRYPT_MODE_ECB, $iv);
// Package the encrypted string for easy storage.
return base64_encode($encrypted_string).'|'.base64_encode($iv);
}
public static function decrypt($string)
{
// Unpackage the encoded, encrypted string.
list($encoded_string, $encoded_iv) = explode('|', $string);
$encrypted_string = base64_decode($encoded_string);
$iv = base64_decode($encoded_iv);
// Trim encryption key to size supported by this cipher.
$key = substr(DF_ENCRYPTION_KEY, 0, mcrypt_get_key_size(DF_ENCRYPTION_CIPHER, MCRYPT_MODE_ECB));
return trim(mcrypt_decrypt(DF_ENCRYPTION_CIPHER, $key, $encrypted_string, MCRYPT_MODE_ECB, $iv));
}
public static function digest($string)
{
return sha1($string.DF_ENCRYPTION_KEY);
}
public static function encrypt($string)
{
// Create initialization vector.
$iv_size = mcrypt_get_iv_size(DF_ENCRYPTION_CIPHER, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
// Trim encryption key to size supported by this cipher.
$key = substr(DF_ENCRYPTION_KEY, 0, mcrypt_get_key_size(DF_ENCRYPTION_CIPHER, MCRYPT_MODE_ECB));
$encrypted_string = mcrypt_encrypt(DF_ENCRYPTION_CIPHER, $key, trim($string), MCRYPT_MODE_ECB, $iv);
// Package the encrypted string for easy storage.
return base64_encode($encrypted_string).'|'.base64_encode($iv);
}
public static function decrypt($string)
{
// Unpackage the encoded, encrypted string.
list($encoded_string, $encoded_iv) = explode('|', $string);
$encrypted_string = base64_decode($encoded_string);
$iv = base64_decode($encoded_iv);
// Trim encryption key to size supported by this cipher.
$key = substr(DF_ENCRYPTION_KEY, 0, mcrypt_get_key_size(DF_ENCRYPTION_CIPHER, MCRYPT_MODE_ECB));
return trim(mcrypt_decrypt(DF_ENCRYPTION_CIPHER, $key, $encrypted_string, MCRYPT_MODE_ECB, $iv));
}
public static function digest($string)
{
return sha1($string.DF_ENCRYPTION_KEY);
}
}

View File

@ -6,186 +6,186 @@
namespace DF;
class Export
{
/**
* CSV
**/
public static function csv($table_data, $headers_first_row = TRUE, $file_name = "ExportedData")
{
self::exportToCSV($table_data, $headers_first_row, $file_name);
}
public static function exportToCSV($table_data, $headers_first_row = TRUE, $file_name = "ExportedData")
{
// Header data associated with CSV files.
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", FALSE);
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=".$file_name.".csv");
echo self::convertToCSV($table_data, $headers_first_row);
exit;
}
public static function convertToCSV($table_data, $headers_first_row = FALSE)
{
$final_display = array();
$row_count = 0;
foreach($table_data as $table_row)
{
$row_count++;
$col_count = 0;
$display_row1 = array();
$display_row2 = array();
foreach($table_row as $table_col => $table_val)
{
$col_count++;
if (!$headers_first_row && $row_count == 1)
{
$display_row1[] = '"'.self::filterTexttoCSV($table_col).'"';
}
$display_row2[] = '"'.self::filterTexttoCSV($table_val).'"';
}
if ($display_row1)
{
$final_display[] = implode(',', $display_row1);
}
if ($display_row2)
{
$final_display[] = implode(',', $display_row2);
}
}
return implode("\n", $final_display);
}
public static function filterTextToCSV($text)
{
return str_replace('"', '""', $text);
}
/**
* Excel
*/
public static function excel($data, $version = 'Excel2007')
{
$doc = new \PHPExcel();
$doc->setActiveSheetIndex(0);
$sheet = $doc->getActiveSheet();
$sheet->setTitle('Exported Data');
$sheet->fromArray($data);
$version_specific = array(
'xlsx' => array(
'writer' => 'Excel2007',
'extension' => '.xlsx',
'mime-type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
),
'xls' => array(
'writer' => 'Excel5',
'extension' => '.xls',
'mime-type' => 'application/vnd.ms-excel',
),
'csv' => array(
'writer' => 'CSV',
'extension' => '.csv',
'mime-type' => 'text/csv',
),
'html' => array(
'writer' => 'HTML',
'extension' => '.html',
'mime-type' => 'text/html',
),
'pdf' => array(
'writer' => 'PDF',
'extension' => '.pdf',
'mime-type' => 'application/pdf',
),
);
$filename = 'Exported Data ('.date('Y-m-d').')';
$filename .= $version_specific[$version]['extension'];
$mime_type = $version_specific[$version]['mime-type'];
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", FALSE);
header("Content-Type: ".$mime_type);
header("Content-Disposition: attachment; filename=".$filename);
$writer = \PHPExcel_IOFactory::createWriter($doc, $version_specific[$version]['writer']);
$writer->save('php://output');
}
/**
* JSON
**/
public static function json($table_data)
{
return \Zend_Json::encode($table_data);
}
public static function exportToJSON($table_data)
{
return \Zend_Json::encode($table_data);
}
/**
* PDF
*/
public static function getPdfFonts()
{
$fonts_by_name = array(
'courier' => \Zend_Pdf_Font::FONT_COURIER,
'courier_bold' => \Zend_Pdf_Font::FONT_COURIER_BOLD,
'helvetica' => \Zend_Pdf_Font::FONT_HELVETICA,
'helvetica_bold' => \Zend_Pdf_Font::FONT_HELVETICA_BOLD,
'helvetica_oblique' => \Zend_Pdf_Font::FONT_HELVETICA_OBLIQUE,
);
$fonts_by_path = array(
'trebuchet' => DF_INCLUDE_STATIC.'/fonts/trebuc.ttf',
'trebuchet_bold' => DF_INCLUDE_STATIC.'/fonts/trebucbd.ttf',
'trebuchet_italic' => DF_INCLUDE_STATIC.'/fonts/trebucit.ttf',
'trebuchet_bolditalic' => DF_INCLUDE_STATIC.'/fonts/trebucbi.ttf',
'tahoma' => DF_INCLUDE_STATIC.'/fonts/tahoma.ttf',
'tahoma_bold' => DF_INCLUDE_STATIC.'/fonts/tahomabd.ttf',
'barcode' => DF_INCLUDE_STATIC.'/fonts/FRE3OF9X.TTF',
);
$font_results = array();
foreach($fonts_by_name as $font_key => $font_name)
{
$font_results[$font_key] = \Zend_Pdf_Font::fontWithName($font_name);
}
foreach($fonts_by_path as $font_key => $font_path)
{
if (file_exists($font_path))
$font_results[$font_key] = \Zend_Pdf_Font::fontWithPath($font_path);
}
return $font_results;
}
public static function displayPdf($pdf_obj)
{
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", FALSE);
header("Content-type: application/pdf");
echo $pdf_obj->render();
exit;
}
/**
* XML to Array
*/
public static function XmlToArray($xml)
{
/**
* CSV
**/
public static function csv($table_data, $headers_first_row = TRUE, $file_name = "ExportedData")
{
self::exportToCSV($table_data, $headers_first_row, $file_name);
}
public static function exportToCSV($table_data, $headers_first_row = TRUE, $file_name = "ExportedData")
{
// Header data associated with CSV files.
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", FALSE);
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=".$file_name.".csv");
echo self::convertToCSV($table_data, $headers_first_row);
exit;
}
public static function convertToCSV($table_data, $headers_first_row = FALSE)
{
$final_display = array();
$row_count = 0;
foreach($table_data as $table_row)
{
$row_count++;
$col_count = 0;
$display_row1 = array();
$display_row2 = array();
foreach($table_row as $table_col => $table_val)
{
$col_count++;
if (!$headers_first_row && $row_count == 1)
{
$display_row1[] = '"'.self::filterTexttoCSV($table_col).'"';
}
$display_row2[] = '"'.self::filterTexttoCSV($table_val).'"';
}
if ($display_row1)
{
$final_display[] = implode(',', $display_row1);
}
if ($display_row2)
{
$final_display[] = implode(',', $display_row2);
}
}
return implode("\n", $final_display);
}
public static function filterTextToCSV($text)
{
return str_replace('"', '""', $text);
}
/**
* Excel
*/
public static function excel($data, $version = 'Excel2007')
{
$doc = new \PHPExcel();
$doc->setActiveSheetIndex(0);
$sheet = $doc->getActiveSheet();
$sheet->setTitle('Exported Data');
$sheet->fromArray($data);
$version_specific = array(
'xlsx' => array(
'writer' => 'Excel2007',
'extension' => '.xlsx',
'mime-type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
),
'xls' => array(
'writer' => 'Excel5',
'extension' => '.xls',
'mime-type' => 'application/vnd.ms-excel',
),
'csv' => array(
'writer' => 'CSV',
'extension' => '.csv',
'mime-type' => 'text/csv',
),
'html' => array(
'writer' => 'HTML',
'extension' => '.html',
'mime-type' => 'text/html',
),
'pdf' => array(
'writer' => 'PDF',
'extension' => '.pdf',
'mime-type' => 'application/pdf',
),
);
$filename = 'Exported Data ('.date('Y-m-d').')';
$filename .= $version_specific[$version]['extension'];
$mime_type = $version_specific[$version]['mime-type'];
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", FALSE);
header("Content-Type: ".$mime_type);
header("Content-Disposition: attachment; filename=".$filename);
$writer = \PHPExcel_IOFactory::createWriter($doc, $version_specific[$version]['writer']);
$writer->save('php://output');
}
/**
* JSON
**/
public static function json($table_data)
{
return \Zend_Json::encode($table_data);
}
public static function exportToJSON($table_data)
{
return \Zend_Json::encode($table_data);
}
/**
* PDF
*/
public static function getPdfFonts()
{
$fonts_by_name = array(
'courier' => \Zend_Pdf_Font::FONT_COURIER,
'courier_bold' => \Zend_Pdf_Font::FONT_COURIER_BOLD,
'helvetica' => \Zend_Pdf_Font::FONT_HELVETICA,
'helvetica_bold' => \Zend_Pdf_Font::FONT_HELVETICA_BOLD,
'helvetica_oblique' => \Zend_Pdf_Font::FONT_HELVETICA_OBLIQUE,
);
$fonts_by_path = array(
'trebuchet' => DF_INCLUDE_STATIC.'/fonts/trebuc.ttf',
'trebuchet_bold' => DF_INCLUDE_STATIC.'/fonts/trebucbd.ttf',
'trebuchet_italic' => DF_INCLUDE_STATIC.'/fonts/trebucit.ttf',
'trebuchet_bolditalic' => DF_INCLUDE_STATIC.'/fonts/trebucbi.ttf',
'tahoma' => DF_INCLUDE_STATIC.'/fonts/tahoma.ttf',
'tahoma_bold' => DF_INCLUDE_STATIC.'/fonts/tahomabd.ttf',
'barcode' => DF_INCLUDE_STATIC.'/fonts/FRE3OF9X.TTF',
);
$font_results = array();
foreach($fonts_by_name as $font_key => $font_name)
{
$font_results[$font_key] = \Zend_Pdf_Font::fontWithName($font_name);
}
foreach($fonts_by_path as $font_key => $font_path)
{
if (file_exists($font_path))
$font_results[$font_key] = \Zend_Pdf_Font::fontWithPath($font_path);
}
return $font_results;
}
public static function displayPdf($pdf_obj)
{
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", FALSE);
header("Content-type: application/pdf");
echo $pdf_obj->render();
exit;
}
/**
* XML to Array
*/
public static function XmlToArray($xml)
{
$values = $index = $array = array();
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
@ -199,7 +199,7 @@ class Export
return $array;
}
protected static function _struct_to_array($values, &$i)
protected static function _struct_to_array($values, &$i)
{
$child = array();
if (isset($values[$i]['value'])) array_push($child, $values[$i]['value']);
@ -207,28 +207,28 @@ class Export
while ($i++ < count($values)) {
switch ($values[$i]['type']) {
case 'cdata':
array_push($child, $values[$i]['value']);
break;
array_push($child, $values[$i]['value']);
break;
case 'complete':
$name = $values[$i]['tag'];
if(!empty($name)){
$child[$name]= ($values[$i]['value'])?($values[$i]['value']):'';
if(isset($values[$i]['attributes'])) {
$child[$name] = $values[$i]['attributes'];
}
}
break;
$child[$name]= ($values[$i]['value'])?($values[$i]['value']):'';
if(isset($values[$i]['attributes'])) {
$child[$name] = $values[$i]['attributes'];
}
}
break;
case 'open':
$name = $values[$i]['tag'];
$size = isset($child[$name]) ? sizeof($child[$name]) : 0;
$child[$name][$size] = self::_struct_to_array($values, $i);
break;
break;
case 'close':
return $child;
break;
return $child;
break;
}
}
return $child;
@ -236,29 +236,29 @@ class Export
public static function ArrayToXml($array)
{
$xml_info = new \SimpleXMLElement('<?xml version="1.0"?><return></return>');
self::_arr_to_xml($array, $xml_info);
$xml_info = new \SimpleXMLElement('<?xml version="1.0"?><return></return>');
self::_arr_to_xml($array, $xml_info);
return $xml_info->asXML();
return $xml_info->asXML();
}
protected static function _arr_to_xml($array, &$xml)
{
foreach((array)$array as $key => $value)
{
if(is_array($value))
{
$key = is_numeric($key) ? "item$key" : $key;
$subnode = $xml->addChild("$key");
foreach((array)$array as $key => $value)
{
if(is_array($value))
{
$key = is_numeric($key) ? "item$key" : $key;
$subnode = $xml->addChild("$key");
self::_arr_to_xml($value, $subnode);
}
else
{
$key = is_numeric($key) ? "item$key" : $key;
$xml->addChild("$key", htmlspecialchars($value));
}
}
self::_arr_to_xml($value, $subnode);
}
else
{
$key = is_numeric($key) ? "item$key" : $key;
$xml->addChild("$key", htmlspecialchars($value));
}
}
}
/**

View File

@ -6,146 +6,146 @@
namespace DF;
class File
{
public static function getFileExtension($file_name)
{
return substr($file_name, strrpos($file_name, '.')+1);
}
public static function getFilePath($file_name)
{
if (is_readable($file_name) || stristr($file_name, DF_UPLOAD_FOLDER) !== FALSE)
return $file_name;
else
return DF_UPLOAD_FOLDER.'/'.str_replace('..','',$file_name);
}
public static function getFileUrl($file_name)
{
if (defined('DF_UPLOAD_URL'))
return DF_UPLOAD_URL.'/'.$file_name;
else
return \DF\Url::content($file_name);
}
public static function isValidFile($uploaded_file, $allowed_extensions = NULL)
{
$is_valid_upload = (!empty($uploaded_file) && $uploaded_file['error'] == UPLOAD_ERR_OK);
if (!is_null($allowed_extensions))
{
$file_extension = self::getFileExtension($uploaded_file['name']);
$is_valid_extension = in_array($file_extension, $allowed_extensions);
}
else
{
$is_valid_extension = TRUE;
}
return $is_valid_upload && $is_valid_extension;
}
public static function moveUploadedFile($uploaded_file, $file_name = '')
{
if (!self::isValidFile($uploaded_file))
{
switch($uploaded_file['error'])
{
case UPLOAD_ERR_INI_SIZE:
throw new \DF\Exception\DisplayOnly('File Upload Error: The file you are attempting to upload is larger than allowed (upload_max_filesize).');
break;
case UPLOAD_ERR_FORM_SIZE:
throw new \DF\Exception\DisplayOnly('File Upload Error: The file you are attempting to upload is larger than allowed (MAX_FILE_SIZE).');
break;
case UPLOAD_ERR_PARTIAL:
throw new \DF\Exception\DisplayOnly('File Upload Error: The file you are attempting to upload was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
throw new \DF\Exception\DisplayOnly('File Upload Error: No file was uploaded.');
break;
case UPLOAD_ERR_NO_TMP_DIR:
throw new \DF\Exception\DisplayOnly('File Upload Error: Missing a temporary folder.');
break;
case UPLOAD_ERR_CANT_WRITE:
throw new \DF\Exception\DisplayOnly('File Upload Error: Failed to write file to disk.');
break;
case UPLOAD_ERR_EXTENSION:
throw new \DF\Exception\DisplayOnly('File Upload Error: Upload stopped by extension.');
break;
default:
throw new \DF\Exception\DisplayOnly('File Upload Error: No file was specified.');
break;
}
exit;
}
if (empty($file_name))
{
$file_name = basename($uploaded_file['name']);
}
// Replace .??? with the correct file extension if listed.
$file_name = str_replace('.???', '.'.self::getFileExtension($uploaded_file['name']), $file_name);
$upload_path = self::getFilePath($file_name);
if (move_uploaded_file($uploaded_file['tmp_name'], $upload_path))
{
return $file_name;
}
else
{
throw new \DF\Exception\DisplayOnly('File Upload Error: Could not upload the file requested.');
exit;
}
}
public static function createFileFromData($file_name, $file_data)
{
file_put_contents(self::getFilePath($file_name), $file_data);
return $file_name;
}
public static function getFilePointer($file_name)
{
return fopen(self::getFilePath($file_name), 'r');
}
public static function getFileExtension($file_name)
{
return substr($file_name, strrpos($file_name, '.')+1);
}
public static function getFilePath($file_name)
{
if (is_readable($file_name) || stristr($file_name, DF_UPLOAD_FOLDER) !== FALSE)
return $file_name;
else
return DF_UPLOAD_FOLDER.'/'.str_replace('..','',$file_name);
}
public static function getFileUrl($file_name)
{
if (defined('DF_UPLOAD_URL'))
return DF_UPLOAD_URL.'/'.$file_name;
else
return \DF\Url::content($file_name);
}
public static function isValidFile($uploaded_file, $allowed_extensions = NULL)
{
$is_valid_upload = (!empty($uploaded_file) && $uploaded_file['error'] == UPLOAD_ERR_OK);
if (!is_null($allowed_extensions))
{
$file_extension = self::getFileExtension($uploaded_file['name']);
$is_valid_extension = in_array($file_extension, $allowed_extensions);
}
else
{
$is_valid_extension = TRUE;
}
return $is_valid_upload && $is_valid_extension;
}
public static function moveUploadedFile($uploaded_file, $file_name = '')
{
if (!self::isValidFile($uploaded_file))
{
switch($uploaded_file['error'])
{
case UPLOAD_ERR_INI_SIZE:
throw new \DF\Exception\DisplayOnly('File Upload Error: The file you are attempting to upload is larger than allowed (upload_max_filesize).');
break;
case UPLOAD_ERR_FORM_SIZE:
throw new \DF\Exception\DisplayOnly('File Upload Error: The file you are attempting to upload is larger than allowed (MAX_FILE_SIZE).');
break;
case UPLOAD_ERR_PARTIAL:
throw new \DF\Exception\DisplayOnly('File Upload Error: The file you are attempting to upload was only partially uploaded.');
break;
case UPLOAD_ERR_NO_FILE:
throw new \DF\Exception\DisplayOnly('File Upload Error: No file was uploaded.');
break;
case UPLOAD_ERR_NO_TMP_DIR:
throw new \DF\Exception\DisplayOnly('File Upload Error: Missing a temporary folder.');
break;
case UPLOAD_ERR_CANT_WRITE:
throw new \DF\Exception\DisplayOnly('File Upload Error: Failed to write file to disk.');
break;
case UPLOAD_ERR_EXTENSION:
throw new \DF\Exception\DisplayOnly('File Upload Error: Upload stopped by extension.');
break;
default:
throw new \DF\Exception\DisplayOnly('File Upload Error: No file was specified.');
break;
}
exit;
}
if (empty($file_name))
{
$file_name = basename($uploaded_file['name']);
}
// Replace .??? with the correct file extension if listed.
$file_name = str_replace('.???', '.'.self::getFileExtension($uploaded_file['name']), $file_name);
$upload_path = self::getFilePath($file_name);
if (move_uploaded_file($uploaded_file['tmp_name'], $upload_path))
{
return $file_name;
}
else
{
throw new \DF\Exception\DisplayOnly('File Upload Error: Could not upload the file requested.');
exit;
}
}
public static function createFileFromData($file_name, $file_data)
{
file_put_contents(self::getFilePath($file_name), $file_data);
return $file_name;
}
public static function getFilePointer($file_name)
{
return fopen(self::getFilePath($file_name), 'r');
}
public static function getFileContents($file_name)
{
return file_get_contents(self::getFilePath($file_name));
}
public static function getCSV($file_name)
{
@ini_set('auto_detect_line_endings', 1);
$csv_data = array();
$handle = fopen(self::getFilePath($file_name), "r");
while (($data = fgetcsv($handle)) !== FALSE)
{
$csv_data[] = $data;
}
fclose($handle);
return $csv_data;
}
// Returns a "clean" array with the first row's text as the column names.
public static function getCleanCSV($file_name)
{
$csv_data = self::getCSV($file_name);
$clean_data = array();
if ($csv_data)
{
$headers = array();
$row_num = 0;
public static function getFileContents($file_name)
{
return file_get_contents(self::getFilePath($file_name));
}
public static function getCSV($file_name)
{
@ini_set('auto_detect_line_endings', 1);
$csv_data = array();
$handle = fopen(self::getFilePath($file_name), "r");
while (($data = fgetcsv($handle)) !== FALSE)
{
$csv_data[] = $data;
}
fclose($handle);
return $csv_data;
}
// Returns a "clean" array with the first row's text as the column names.
public static function getCleanCSV($file_name)
{
$csv_data = self::getCSV($file_name);
$clean_data = array();
if ($csv_data)
{
$headers = array();
$row_num = 0;
$col_num = 0;
$header_row = array_shift($csv_data);
@ -157,36 +157,36 @@ class File
$col_num++;
}
foreach($csv_data as $csv_row)
{
$col_num = 0;
$clean_row = array();
foreach($csv_row as $csv_col)
{
$col_name = (isset($headers[$col_num])) ? $headers[$col_num] : $col_num;
$clean_row[$col_name] = $csv_col;
$col_num++;
}
foreach($csv_data as $csv_row)
{
$col_num = 0;
$clean_row = array();
foreach($csv_row as $csv_col)
{
$col_name = (isset($headers[$col_num])) ? $headers[$col_num] : $col_num;
$clean_row[$col_name] = $csv_col;
$col_num++;
}
$clean_data[] = $clean_row;
$row_num++;
}
}
return $clean_data;
}
public static function renameFile($old_file, $new_file)
{
$old_file_path = self::getFilePath($old_file);
$new_file_path = self::getFilePath($new_file);
rename($old_file_path, $new_file_path);
return $new_file;
}
public static function deleteFile($file_name)
{
unlink(self::getFilePath($file_name));
}
$row_num++;
}
}
return $clean_data;
}
public static function renameFile($old_file, $new_file)
{
$old_file_path = self::getFilePath($old_file);
$new_file_path = self::getFilePath($new_file);
rename($old_file_path, $new_file_path);
return $new_file;
}
public static function deleteFile($file_name)
{
unlink(self::getFilePath($file_name));
}
}

View File

@ -4,10 +4,10 @@ class WebAddress implements \Zend_Filter_Interface
{
public function filter($value)
{
$value = trim($value);
if ($value && substr($value, 0, 4) != "http")
$value = 'http://'.str_replace('http://', '', $value);
return $value;
$value = trim($value);
if ($value && substr($value, 0, 4) != "http")
$value = 'http://'.str_replace('http://', '', $value);
return $value;
}
}

View File

@ -13,7 +13,7 @@ class Form extends \Zend_Form
$this->addElementPrefixPath('\DF\Validate\\', 'DF/Validate', \Zend_Form_Element::VALIDATE);
$this->addElementPrefixPath('\DF\Filter\\', 'DF/Filter', \Zend_Form_Element::FILTER);
$this->setElementFilters(array('StringTrim'));
if ($options instanceof \Zend_Config)
@ -23,23 +23,23 @@ class Form extends \Zend_Form
{
foreach($options['groups'] as $group_key => $group)
{
// Special handling for items named "submit".
if ($group_key == "submit")
$group_key = "submit_grp";
$group_elements = (array)$group['elements'];
unset($group['elements']);
$options['displayGroups'][$group_key] = array(
'elements' => array(),
'options' => $group,
);
foreach($group_elements as $element_key => $element_info)
{
$options['displayGroups'][$group_key]['elements'][] = $element_key;
$options['elements'][$element_key] = $element_info;
}
// Special handling for items named "submit".
if ($group_key == "submit")
$group_key = "submit_grp";
$group_elements = (array)$group['elements'];
unset($group['elements']);
$options['displayGroups'][$group_key] = array(
'elements' => array(),
'options' => $group,
);
foreach($group_elements as $element_key => $element_info)
{
$options['displayGroups'][$group_key]['elements'][] = $element_key;
$options['elements'][$element_key] = $element_info;
}
}
unset($options['groups']);
@ -47,14 +47,14 @@ class Form extends \Zend_Form
// Check for default value.
$defaults = array();
foreach((array)$options['elements'] as $element_name => $element_info)
{
if (isset($element_info[1]['default']))
{
$defaults[$element_name] = $element_info[1]['default'];
unset($options['elements'][$element_name][1]['default']);
}
}
foreach((array)$options['elements'] as $element_name => $element_info)
{
if (isset($element_info[1]['default']))
{
$defaults[$element_name] = $element_info[1]['default'];
unset($options['elements'][$element_name][1]['default']);
}
}
parent::__construct($options);
$this->setDefaults($defaults);
@ -62,41 +62,41 @@ class Form extends \Zend_Form
public function isSubForm()
{
return FALSE;
return FALSE;
}
public function setDefault($name, $value)
public function setDefault($name, $value)
{
$name = (string) $name;
if ($element = $this->getElement($name))
{
$element->setAttrib('df_raw_value', $value);
{
$element->setAttrib('df_raw_value', $value);
}
return parent::setDefault($name, $value);
return parent::setDefault($name, $value);
}
protected function _dissolveArrayValue($value, $arrayPath)
{
return (array)parent::_dissolveArrayValue($value, $arrayPath);
return (array)parent::_dissolveArrayValue($value, $arrayPath);
}
public function clearAllDecorators()
{
$this->clearDecorators();
foreach($this->getElements() as $element)
$element->clearDecorators();
foreach($this->getDisplayGroups() as $group)
$group->clearDecorators();
foreach($this->getSubForms() as $form)
{
if ($form instanceof self)
$form->clearAllDecorators();
else
$form->clearDecorators();
}
$this->clearDecorators();
foreach($this->getElements() as $element)
$element->clearDecorators();
foreach($this->getDisplayGroups() as $group)
$group->clearDecorators();
foreach($this->getSubForms() as $form)
{
if ($form instanceof self)
$form->clearAllDecorators();
else
$form->clearDecorators();
}
return $this;
}
@ -105,31 +105,31 @@ class Form extends \Zend_Form
{
foreach($this->getElements() as $element)
{
$element->setDecorators(array(
$element->setDecorators(array(
array(
'SpanFormErrors',
array(
'class' => 'help-block error',
'escape' => FALSE,
'placement' => \Zend_Form_Decorator_Abstract::PREPEND,
),
),
array(
'Description',
array(
'tag' => 'span',
'class' => 'help-block '.$errors,
'escape' => FALSE,
'placement' => \Zend_Form_Decorator_Abstract::PREPEND,
)
),
));
if ($element instanceof \Zend_Form_Element_File)
{
array(
'SpanFormErrors',
array(
'class' => 'help-block error',
'escape' => FALSE,
'placement' => \Zend_Form_Decorator_Abstract::PREPEND,
),
),
array(
'Description',
array(
'tag' => 'span',
'class' => 'help-block '.$errors,
'escape' => FALSE,
'placement' => \Zend_Form_Decorator_Abstract::PREPEND,
)
),
));
if ($element instanceof \Zend_Form_Element_File)
{
$element->addDecorators(array(
array(
'FormFileEdit',
@ -137,172 +137,172 @@ class Form extends \Zend_Form
'placement' => \Zend_Form_Decorator_Abstract::APPEND,
),
),
));
}
else
{
$element->addDecorators(array(
array(
'ViewHelper',
array(
'placement' => \Zend_Form_Decorator_Abstract::APPEND,
),
),
));
}
if (!($element instanceof \Zend_Form_Element_Button || $element instanceof \Zend_Form_Element_Submit))
{
$element->addDecorators(array(
array(
'Label',
array(
'escape' => FALSE,
'optionalSuffix' => ':',
'requiredSuffix' => '<span style="color: #FF0000;">*</span>:',
),
),
array(
'HtmlTag',
array(
'tag' => 'div',
'class' => 'clearfix control-group',
),
),
));
}
if( $element instanceOf \Zend_Form_Element_Hidden )
{
$element->setDecorators(array(
'ViewHelper',
));
}
));
}
else
{
$element->addDecorators(array(
array(
'ViewHelper',
array(
'placement' => \Zend_Form_Decorator_Abstract::APPEND,
),
),
));
}
if (!($element instanceof \Zend_Form_Element_Button || $element instanceof \Zend_Form_Element_Submit))
{
$element->addDecorators(array(
array(
'Label',
array(
'escape' => FALSE,
'optionalSuffix' => ':',
'requiredSuffix' => '<span style="color: #FF0000;">*</span>:',
),
),
array(
'HtmlTag',
array(
'tag' => 'div',
'class' => 'clearfix control-group',
),
),
));
}
if( $element instanceOf \Zend_Form_Element_Hidden )
{
$element->setDecorators(array(
'ViewHelper',
));
}
}
$subform_decorators = array(
array(
'Description',
array(
'tag' => 'span',
'class' => 'help-block in-fieldset',
'escape' => FALSE,
)
),
$subform_decorators = array(
array(
'FormElements',
array(
'tag' => '',
)
),
'Description',
array(
'tag' => 'span',
'class' => 'help-block in-fieldset',
'escape' => FALSE,
)
),
array(
'FormElements',
array(
'tag' => '',
)
),
);
$group_decorators = array_merge($subform_decorators, array(
array('Fieldset'),
array('Fieldset'),
));
if (!$this->isSubForm())
{
$this->setDecorators(array(
array('FormErrors'),
array('FormElements'),
array('Form', array(
'class' => 'form-stacked df-form',
)),
));
$this->setDecorators(array(
array('FormErrors'),
array('FormElements'),
array('Form', array(
'class' => 'form-stacked df-form',
)),
));
}
$this->setDisplayGroupDecorators($group_decorators);
$this->setDisplayGroupDecorators($group_decorators);
$this->setSubFormDecorators($subform_decorators);
}
public function render(\Zend_View_Interface $view = null)
{
$view_mode = $GLOBALS['df_form_mode'];
if ($view_mode == "view" || $view_mode == "message")
$this->preRenderView($view);
else
$this->preRender($view);
return parent::render($view);
$view_mode = $GLOBALS['df_form_mode'];
if ($view_mode == "view" || $view_mode == "message")
$this->preRenderView($view);
else
$this->preRender($view);
return parent::render($view);
}
public function renderSpecial(\Zend_View_Interface $view = null, $view_mode = 'edit')
{
$GLOBALS['df_form_mode'] = $view_mode;
$return_value = $this->render($view);
$GLOBALS['df_form_mode'] = NULL;
return $return_value;
$GLOBALS['df_form_mode'] = $view_mode;
$return_value = $this->render($view);
$GLOBALS['df_form_mode'] = NULL;
return $return_value;
}
public function renderView(\Zend_View_Interface $view = null)
{
return $this->renderSpecial($view, 'view');
return $this->renderSpecial($view, 'view');
}
public function renderMessage(\Zend_View_Interface $view = null)
{
return $this->renderSpecial($view, 'message');
return $this->renderSpecial($view, 'message');
}
/**
* Read-only view
*/
public function preRenderView(\Zend_View_Interface $view = null)
{
foreach($this->getElements() as $element)
/**
* Read-only view
*/
public function preRenderView(\Zend_View_Interface $view = null)
{
foreach($this->getElements() as $element)
{
$element->setDecorators(array(
'FormView',
));
if ($element instanceof \Zend_Form_Element_Button ||
$element instanceof \Zend_Form_Element_Submit ||
$element instanceof \Zend_Form_Element_Hidden ||
$element instanceof Form\Element\Markup)
{
// Don't show these types of elements in this view
$element->clearDecorators();
}
else if ($element instanceof \Zend_Form_Element_File)
{
// Add a fake "Form File View" decorator, since Zend_Form_Element_File needs it.
$element->addDecorators(array(
'FormFileView',
));
}
$element->setDecorators(array(
'FormView',
));
if ($element instanceof \Zend_Form_Element_Button ||
$element instanceof \Zend_Form_Element_Submit ||
$element instanceof \Zend_Form_Element_Hidden ||
$element instanceof Form\Element\Markup)
{
// Don't show these types of elements in this view
$element->clearDecorators();
}
else if ($element instanceof \Zend_Form_Element_File)
{
// Add a fake "Form File View" decorator, since Zend_Form_Element_File needs it.
$element->addDecorators(array(
'FormFileView',
));
}
}
$group_decorators = array(
$group_decorators = array(
array('FormElements'),
array('FormView'),
);
$this->setDecorators($group_decorators);
$this->setDisplayGroupDecorators($group_decorators);
$this->setDecorators($group_decorators);
$this->setDisplayGroupDecorators($group_decorators);
$this->setSubFormDecorators($group_decorators);
}
/**
* File upload processing
*/
public function processFiles($destination_folder, $file_name_prefix = '')
{
$return_fields = array();
// Check for upload directory.
$base_dir = DF_UPLOAD_FOLDER.DIRECTORY_SEPARATOR.$destination_folder;
if (!file_exists($base_dir))
@mkdir($base_dir);
foreach($this->getElements() as $element_name => $element)
{
if ($element instanceof \Zend_Form_Element_File)
{
$element_name_clean = preg_replace('#[^a-zA-Z0-9\_]#', '', $element_name);
$file_names = (array)$element->getFileName();
}
/**
* File upload processing
*/
public function processFiles($destination_folder, $file_name_prefix = '')
{
$return_fields = array();
// Check for upload directory.
$base_dir = DF_UPLOAD_FOLDER.DIRECTORY_SEPARATOR.$destination_folder;
if (!file_exists($base_dir))
@mkdir($base_dir);
foreach($this->getElements() as $element_name => $element)
{
if ($element instanceof \Zend_Form_Element_File)
{
$element_name_clean = preg_replace('#[^a-zA-Z0-9\_]#', '', $element_name);
$file_names = (array)$element->getFileName();
$original_files = (array)$element->getOriginalValue();
if (!empty($file_names))
@ -322,9 +322,9 @@ class Form extends \Zend_Form
$i++;
}
}
}
}
return $return_fields;
}
}
}
return $return_fields;
}
}

View File

@ -11,8 +11,8 @@ class DtDdWrapper extends \Zend_Form_Decorator_Abstract
$dd = '<dd id="' . $elementName . '-element">' . $content . '</dd>';
if( null !== $dtLabel )
return $dt.$dd;
else
return $dd;
return $dt.$dd;
else
return $dd;
}
}

View File

@ -3,15 +3,15 @@ namespace DF\Form\Decorator;
class FormErrors extends \Zend_Form_Decorator_FormErrors
{
public function render($content)
public function render($content)
{
$errors = parent::render('');
if (empty($errors))
return $content;
$markup = '<div class="alert block-message alert-error"><p>The form could not be submitted because the following errors occurred:</p>'.$errors.'</div>';
$errors = parent::render('');
if (empty($errors))
return $content;
$markup = '<div class="alert block-message alert-error"><p>The form could not be submitted because the following errors occurred:</p>'.$errors.'</div>';
switch ($this->getPlacement()) {
case self::APPEND:
return $content . $this->getSeparator() . $markup;

View File

@ -8,11 +8,11 @@ class FormFileEdit extends \Zend_Form_Decorator_File implements \Zend_Form_Decor
$element = $this->getElement();
$value = $element->getOriginalValue();
if (defined('DF_UPLOAD_URL') && DF_UPLOAD_URL)
$url_base = DF_UPLOAD_URL;
else
$url_base = \DF\Url::content();
if (defined('DF_UPLOAD_URL') && DF_UPLOAD_URL)
$url_base = DF_UPLOAD_URL;
else
$url_base = \DF\Url::content();
if ($value)
{
@ -27,7 +27,7 @@ class FormFileEdit extends \Zend_Form_Decorator_File implements \Zend_Form_Decor
$i++;
$file_url = $url_base.'/'.$existing_file;
$form_field .= '<div>#'.$i.': <a href="'.$file_url.'" target="_blank">Download File</a></div>';
$form_field .= '<div>#'.$i.': <a href="'.$file_url.'" target="_blank">Download File</a></div>';
}
$form_field .= '</dd>';

View File

@ -4,6 +4,6 @@ class FormFileView extends \Zend_Form_Decorator_Abstract implements \Zend_Form_D
{
public function render($content)
{
return $content;
return $content;
}
}

View File

@ -5,130 +5,130 @@ class FormView extends \Zend_Form_Decorator_Form
{
public function render($content)
{
$view_mode = $GLOBALS['df_form_mode'];
$element = $this->getElement();
// Special handling for subforms and forms themselves.
if ($element instanceof \Zend_Form)
{
$elements = $element->getElements();
$groups = $element->getDisplayGroups();
$attribs = $element->getAttribs();
$content = trim($content);
// Wrap content in DL tag if not otherwise done.
if (count($groups) == 0 && $content)
$content = '<dl>'.$content.'</dl>';
if ($view_mode == "message")
return $content;
else
return '<div class="form-view">'.$content.'</div>';
}
// Special handling for formsets.
if ($element instanceof \Zend_Form_DisplayGroup)
{
if (trim($content))
{
$attribs = $element->getAttribs();
$return = '';
if ($attribs['legend'])
$return .= '<h3>'.$attribs['legend'].'</h3>';
$return .= '<dl>'.trim($content).'</dl>';
return $return;
}
return NULL;
}
if ($element->getIgnore() == TRUE)
return NULL;
$element_attribs = $element->getAttribs();
$element_options = (isset($element_attribs['options'])) ? $element_attribs['options'] : array();
$element_value = $element_attribs['df_raw_value'];
if ($element_value === NULL)
return NULL;
$return_content = '';
if ($element instanceof \Zend_Form_Element_File)
{
if (defined('DF_UPLOAD_URL') && DF_UPLOAD_URL)
$url_base = DF_UPLOAD_URL;
else
$url_base = \DF\Url::content();
$files = (array)$element_value;
$i = 1;
foreach($files as $file)
{
$file_url = $url_base.'/'.$file;
$return_content .= '<div>#'.$i.': <a href="'.$file_url.'" target="_blank">Download File</a>';
$i++;
}
}
else if ($element instanceof \DF\Form\Element\UnixDate)
{
$return_content .= ($element_value != 0) ? date('F j, Y', $element_value) : '';
}
else if ($element instanceof \DF\Form\Element\UnixDateTime)
{
$return_content .= ($element_value != 0) ? date('F j, Y g:ia', $element_value) : '';
}
else if (is_array($element_value))
{
$return_content .= '<ul>';
foreach($element_value as $element_value_item)
{
if (isset($element_options[$element_value_item]))
$element_value_item = $element_options[$element_value_item];
$return_content .= '<li>'.$element_value_item.'</li>';
}
$return_content .= '</ul>';
}
else
{
$validators = (array)$element->getValidators();
$validator_classes = array_keys($validators);
$filters = (array)$element->getFilters();
$filter_classes = array_keys($filters);
if ($element_value && in_array('Zend_Validate_EmailAddress', $validator_classes))
{
$element_value = '<a href="mailto:'.$element_value.'">'.$element_value.'</a>';
}
elseif ($element_value && in_array('DF\Filter\WebAddress', $filter_classes))
{
$element_value = '<a href="'.$element_value.'" target="_blank">'.$element_value.'</a>';
}
if ($element_options)
$return_content .= nl2br($element_options[$element_value]);
else
$return_content .= nl2br($element_value);
}
if (trim($return_content))
{
$label_raw = $element->getLabel();
if ($label_raw)
$label = '<dt>'.$label_raw.':</dt>';
else
$label = '';
return $label.'<dd>'.$return_content.'</dd>';
}
$view_mode = $GLOBALS['df_form_mode'];
$element = $this->getElement();
// Special handling for subforms and forms themselves.
if ($element instanceof \Zend_Form)
{
$elements = $element->getElements();
$groups = $element->getDisplayGroups();
$attribs = $element->getAttribs();
$content = trim($content);
// Wrap content in DL tag if not otherwise done.
if (count($groups) == 0 && $content)
$content = '<dl>'.$content.'</dl>';
if ($view_mode == "message")
return $content;
else
return '<div class="form-view">'.$content.'</div>';
}
// Special handling for formsets.
if ($element instanceof \Zend_Form_DisplayGroup)
{
if (trim($content))
{
$attribs = $element->getAttribs();
$return = '';
if ($attribs['legend'])
$return .= '<h3>'.$attribs['legend'].'</h3>';
$return .= '<dl>'.trim($content).'</dl>';
return $return;
}
return NULL;
}
if ($element->getIgnore() == TRUE)
return NULL;
$element_attribs = $element->getAttribs();
$element_options = (isset($element_attribs['options'])) ? $element_attribs['options'] : array();
$element_value = $element_attribs['df_raw_value'];
if ($element_value === NULL)
return NULL;
$return_content = '';
if ($element instanceof \Zend_Form_Element_File)
{
if (defined('DF_UPLOAD_URL') && DF_UPLOAD_URL)
$url_base = DF_UPLOAD_URL;
else
$url_base = \DF\Url::content();
$files = (array)$element_value;
$i = 1;
foreach($files as $file)
{
$file_url = $url_base.'/'.$file;
$return_content .= '<div>#'.$i.': <a href="'.$file_url.'" target="_blank">Download File</a>';
$i++;
}
}
else if ($element instanceof \DF\Form\Element\UnixDate)
{
$return_content .= ($element_value != 0) ? date('F j, Y', $element_value) : '';
}
else if ($element instanceof \DF\Form\Element\UnixDateTime)
{
$return_content .= ($element_value != 0) ? date('F j, Y g:ia', $element_value) : '';
}
else if (is_array($element_value))
{
$return_content .= '<ul>';
foreach($element_value as $element_value_item)
{
if (isset($element_options[$element_value_item]))
$element_value_item = $element_options[$element_value_item];
$return_content .= '<li>'.$element_value_item.'</li>';
}
$return_content .= '</ul>';
}
else
{
$validators = (array)$element->getValidators();
$validator_classes = array_keys($validators);
$filters = (array)$element->getFilters();
$filter_classes = array_keys($filters);
if ($element_value && in_array('Zend_Validate_EmailAddress', $validator_classes))
{
$element_value = '<a href="mailto:'.$element_value.'">'.$element_value.'</a>';
}
elseif ($element_value && in_array('DF\Filter\WebAddress', $filter_classes))
{
$element_value = '<a href="'.$element_value.'" target="_blank">'.$element_value.'</a>';
}
if ($element_options)
$return_content .= nl2br($element_options[$element_value]);
else
$return_content .= nl2br($element_value);
}
if (trim($return_content))
{
$label_raw = $element->getLabel();
if ($label_raw)
$label = '<dt>'.$label_raw.':</dt>';
else
$label = '';
return $label.'<dd>'.$return_content.'</dd>';
}
}
}

View File

@ -6,14 +6,14 @@
namespace DF\Form\Element;
class File extends \Zend_Form_Element_File
{
protected $_original_value;
public function setValue($value)
{
$this->_original_value = $value;
}
public function getOriginalValue()
{
return $this->_original_value;
}
protected $_original_value;
public function setValue($value)
{
$this->_original_value = $value;
}
public function getOriginalValue()
{
return $this->_original_value;
}
}

View File

@ -10,6 +10,6 @@ class Markup extends \Zend_Form_Element
public function getValue()
{
return NULL;
return NULL;
}
}

View File

@ -20,15 +20,15 @@ class UnixDate extends \Zend_Form_Element_Xhtml
elseif (is_string($value))
$timestamp = strtotime($value);
elseif ($value instanceof \DateTime)
$timestamp = $value->getTimestamp();
$timestamp = $value->getTimestamp();
elseif (is_array($value))
$timestamp = self::processArray($value);
else if (!$value)
$timestamp = 0;
else
$timestamp = 0;
else
throw new \Exception('Invalid date value provided');
$this->field_timestamp = (int)$timestamp;
$this->field_timestamp = (int)$timestamp;
$this->field_year = ($timestamp) ? date('Y', $timestamp) : '';
$this->field_month = ($timestamp) ? date('m', $timestamp) : '';
$this->field_day = ($timestamp) ? date('d', $timestamp) : '';
@ -38,24 +38,24 @@ class UnixDate extends \Zend_Form_Element_Xhtml
public function getValue()
{
return $this->field_timestamp;
}
return $this->field_timestamp;
}
public static function processArray($value, $default_timestamp = null)
{
$default_timestamp = $default_timestamp ?: time();
if (empty($value['month']) && empty($value['day']) && empty($value['year']))
{
return $default_timestamp;
}
else
{
$month = (!empty($value['month'])) ? (int)$value['month'] : date('m', $default_timestamp);
$day = (!empty($value['day'])) ? (int)$value['day'] : date('d', $default_timestamp);
$year = (!empty($value['year'])) ? (int)$value['year'] : date('Y', $default_timestamp);
return strtotime($month.'/'.$day.'/'.$year.' 00:00:00');
}
$default_timestamp = $default_timestamp ?: time();
if (empty($value['month']) && empty($value['day']) && empty($value['year']))
{
return $default_timestamp;
}
else
{
$month = (!empty($value['month'])) ? (int)$value['month'] : date('m', $default_timestamp);
$day = (!empty($value['day'])) ? (int)$value['day'] : date('d', $default_timestamp);
$year = (!empty($value['year'])) ? (int)$value['year'] : date('Y', $default_timestamp);
return strtotime($month.'/'.$day.'/'.$year.' 00:00:00');
}
}
}

View File

@ -25,12 +25,12 @@ class UnixDateTime extends \Zend_Form_Element_Xhtml
elseif (is_string($value))
$timestamp = strtotime($value);
elseif ($value instanceof \DateTime)
$timestamp = $value->getTimestamp();
$timestamp = $value->getTimestamp();
elseif (is_array($value))
$timestamp = self::processArray($value);
else if (!$value)
$timestamp = 0;
else
$timestamp = 0;
else
throw new \Exception('Invalid date value provided');
$this->field_timestamp = (int)$timestamp;
@ -53,16 +53,16 @@ class UnixDateTime extends \Zend_Form_Element_Xhtml
public static function processArray($value, $default_timestamp = null)
{
$default_timestamp = $default_timestamp ?: time();
$month = (isset($value['month'])) ? (int)$value['month'] : date('m', $default_timestamp);
$day = (isset($value['day'])) ? (int)$value['day'] : date('d', $default_timestamp);
$year = (isset($value['year'])) ? (int)$value['year'] : date('Y', $default_timestamp);
$hour = (isset($value['hour'])) ? (int)$value['hour'] : date('g', $default_timestamp);
$minute = (isset($value['minute'])) ? (int)$value['minute'] : date('i', $default_timestamp);
$meridian = (isset($value['meridian'])) ? $value['meridian'] : date('a', $default_timestamp);
return strtotime($month.'/'.$day.'/'.$year.' '.$hour.':'.str_pad($minute, 2, '0', STR_PAD_LEFT).' '.$meridian);
$default_timestamp = $default_timestamp ?: time();
$month = (isset($value['month'])) ? (int)$value['month'] : date('m', $default_timestamp);
$day = (isset($value['day'])) ? (int)$value['day'] : date('d', $default_timestamp);
$year = (isset($value['year'])) ? (int)$value['year'] : date('Y', $default_timestamp);
$hour = (isset($value['hour'])) ? (int)$value['hour'] : date('g', $default_timestamp);
$minute = (isset($value['minute'])) ? (int)$value['minute'] : date('i', $default_timestamp);
$meridian = (isset($value['meridian'])) ? $value['meridian'] : date('a', $default_timestamp);
return strtotime($month.'/'.$day.'/'.$year.' '.$hour.':'.str_pad($minute, 2, '0', STR_PAD_LEFT).' '.$meridian);
}
}

View File

@ -2,8 +2,8 @@
namespace DF\Form;
class SubForm extends \DF\Form
{
public function isSubForm()
{
return TRUE;
}
public function isSubForm()
{
return TRUE;
}
}

View File

@ -6,90 +6,90 @@
namespace DF;
class Image
{
public static function resizeImage($source_file, $dest_file, $width, $height)
{
if (!is_readable($source_file))
$source_file = File::getFilePath($source_file);
if (!is_readable($dest_file))
$dest_file = File::getFilePath($dest_file);
if (!file_exists($source_file))
throw new Exception('Original image file not found!');
$source_extension = strtolower(File::getFileExtension($source_file));
$dest_extension = strtolower(File::getFileExtension($dest_file));
public static function resizeImage($source_file, $dest_file, $width, $height)
{
if (!is_readable($source_file))
$source_file = File::getFilePath($source_file);
if (!is_readable($dest_file))
$dest_file = File::getFilePath($dest_file);
if (!file_exists($source_file))
throw new Exception('Original image file not found!');
$source_extension = strtolower(File::getFileExtension($source_file));
$dest_extension = strtolower(File::getFileExtension($dest_file));
switch($source_extension)
{
case 'jpg':
case 'jpeg':
$image = imagecreatefromjpeg($source_file);
break;
case 'gif':
$image = imagecreatefromgif($source_file);
break;
case 'png':
$image = imagecreatefrompng($source_file);
break;
}
$image_width = imagesx($image);
$image_height = imagesy($image);
// Don't resize if the uploaded picture if smaller than the requirements.
if ($image_width <= $width && $image_height <= $height)
{
$resized_image = $image;
switch($source_extension)
{
case 'jpg':
case 'jpeg':
$image = imagecreatefromjpeg($source_file);
break;
case 'gif':
$image = imagecreatefromgif($source_file);
break;
case 'png':
$image = imagecreatefrompng($source_file);
break;
}
$image_width = imagesx($image);
$image_height = imagesy($image);
// Don't resize if the uploaded picture if smaller than the requirements.
if ($image_width <= $width && $image_height <= $height)
{
$resized_image = $image;
if ($dest_extension == 'png')
{
imagealphablending($resized_image, false);
imagesavealpha($resized_image, true);
if ($dest_extension == 'png')
{
imagealphablending($resized_image, false);
imagesavealpha($resized_image, true);
$transparent = imagecolorallocatealpha($resized_image, 255, 255, 255, 127);
imagefilledrectangle($resized_image, 0, 0, $resized_width, $resized_height, $transparent);
}
}
else
{
// Create file resized to the proper proportions.
$resized_ratio_width = $width / $image_width;
$resized_ratio_height = $height / $image_height;
$resized_ratio = min($resized_ratio_width, $resized_ratio_height);
$resized_width = round($image_width * $resized_ratio);
$resized_height = round($image_height * $resized_ratio);
$transparent = imagecolorallocatealpha($resized_image, 255, 255, 255, 127);
imagefilledrectangle($resized_image, 0, 0, $resized_width, $resized_height, $transparent);
}
}
else
{
// Create file resized to the proper proportions.
$resized_ratio_width = $width / $image_width;
$resized_ratio_height = $height / $image_height;
$resized_ratio = min($resized_ratio_width, $resized_ratio_height);
$resized_width = round($image_width * $resized_ratio);
$resized_height = round($image_height * $resized_ratio);
$resized_image = imagecreatetruecolor($resized_width, $resized_height);
$resized_image = imagecreatetruecolor($resized_width, $resized_height);
if ($dest_extension == 'png')
{
imagealphablending($resized_image, false);
imagesavealpha($resized_image, true);
if ($dest_extension == 'png')
{
imagealphablending($resized_image, false);
imagesavealpha($resized_image, true);
$transparent = imagecolorallocatealpha($resized_image, 255, 255, 255, 127);
imagefilledrectangle($resized_image, 0, 0, $resized_width, $resized_height, $transparent);
}
$transparent = imagecolorallocatealpha($resized_image, 255, 255, 255, 127);
imagefilledrectangle($resized_image, 0, 0, $resized_width, $resized_height, $transparent);
}
imagecopyresampled($resized_image, $image, 0, 0, 0, 0, $resized_width, $resized_height, $image_width, $image_height);
}
switch($dest_extension)
{
case 'jpg':
case 'jpeg':
imagejpeg($resized_image, $dest_file, 90);
break;
case 'gif':
imagegif($resized_image, $dest_file);
break;
case 'png':
imagepng($resized_image, $dest_file, 0);
break;
}
}
imagecopyresampled($resized_image, $image, 0, 0, 0, 0, $resized_width, $resized_height, $image_width, $image_height);
}
switch($dest_extension)
{
case 'jpg':
case 'jpeg':
imagejpeg($resized_image, $dest_file, 90);
break;
case 'gif':
imagegif($resized_image, $dest_file);
break;
case 'png':
imagepng($resized_image, $dest_file, 0);
break;
}
}
}

View File

@ -10,32 +10,32 @@ class Loader
public static function loadClass($class_name)
{
if (strpos($class_name, '\\') === 0)
$class_name = substr($class_name, 1);
// Look through pre-assigned list of include paths first.
if (strpos($class_name, '\\') === 0)
$class_name = substr($class_name, 1);
// Look through pre-assigned list of include paths first.
foreach(self::$autoload_classes as $class_prefix => $class_dir)
{
if (strpos($class_name, $class_prefix) === 0)
{
// Special handling for Doctrine 2.2 proxies.
if ($class_prefix == "Proxy")
{
$find = array('\\', 'Proxy');
$replace = array('', 'Proxy'.DIRECTORY_SEPARATOR);
$class_path = $class_dir.DIRECTORY_SEPARATOR.str_replace($find, $replace, $class_name).'.php';
}
else
{
$find = array('\\', '_');
$replace = array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
$class_path = $class_dir.DIRECTORY_SEPARATOR.str_replace($find, $replace, $class_name).'.php';
}
if (@include($class_path))
return true;
else
break;
// Special handling for Doctrine 2.2 proxies.
if ($class_prefix == "Proxy")
{
$find = array('\\', 'Proxy');
$replace = array('', 'Proxy'.DIRECTORY_SEPARATOR);
$class_path = $class_dir.DIRECTORY_SEPARATOR.str_replace($find, $replace, $class_name).'.php';
}
else
{
$find = array('\\', '_');
$replace = array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
$class_path = $class_dir.DIRECTORY_SEPARATOR.str_replace($find, $replace, $class_name).'.php';
}
if (@include($class_path))
return true;
else
break;
}
}
@ -43,14 +43,14 @@ class Loader
$class_path = $class_name.'.php';
if (@include($class_path))
return true;
// Try loading the directory-separated filename (other legacy classes).
$class_path = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
return true;
// Try loading the directory-separated filename (other legacy classes).
$class_path = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
if (@include($class_path))
return true;
return false;
return true;
return false;
}
public static function register($class_paths)
@ -70,8 +70,8 @@ class Loader
if (defined('DF_INCLUDE_LIB_LOCAL'))
{
$include_path[] = DF_INCLUDE_LIB_LOCAL;
$include_path[] = DF_INCLUDE_LIB_LOCAL.DIRECTORY_SEPARATOR.'ThirdParty';
$include_path[] = DF_INCLUDE_LIB_LOCAL;
$include_path[] = DF_INCLUDE_LIB_LOCAL.DIRECTORY_SEPARATOR.'ThirdParty';
}
$include_path[] = get_include_path();

View File

@ -6,29 +6,29 @@
namespace DF;
class Messenger
{
/**
* New messenger method.
* Uses an expandable array of options and supports direct template rendering and subject prepending.
*/
public static function send($message_options)
{
/**
* New messenger method.
* Uses an expandable array of options and supports direct template rendering and subject prepending.
*/
public static function send($message_options)
{
$config = \Zend_Registry::get('config');
$default_options = array(
'reply_to' => NULL,
'delivery_date' => NULL,
'options' => NULL,
);
$options = array_merge($default_options, $message_options);
// Render the template as the message if a template is specified.
if (isset($options['template']))
{
$layout = new \Zend_Layout();
$layout->setLayoutPath($config->application->resources->layout->layoutPath);
$layout->setLayout('message');
$view_renderer = Application\Bootstrap::getNewView(FALSE);
$default_options = array(
'reply_to' => NULL,
'delivery_date' => NULL,
'options' => NULL,
);
$options = array_merge($default_options, $message_options);
// Render the template as the message if a template is specified.
if (isset($options['template']))
{
$layout = new \Zend_Layout();
$layout->setLayoutPath($config->application->resources->layout->layoutPath);
$layout->setLayout('message');
$view_renderer = Application\Bootstrap::getNewView(FALSE);
$view = $view_renderer->view;
if (isset($options['module']))
@ -41,151 +41,151 @@ class Messenger
$view->subject = $options['subject'];
$view->assign((array)$options['vars']);
$layout->content = $view->render($options['template'].'.phtml');
$layout->content = $view->render($options['template'].'.phtml');
$options['message'] = $layout->render();
}
else if (isset($options['body']) && !isset($options['message']))
{
$options['message'] = $options['body'];
unset($options['body']);
}
// Append the system name as a prefix to the message.
if (!isset($options['no_prefix']) || $options['no_prefix'] == FALSE)
{
$app_name = $config->application->name;
$options['subject'] = $app_name.': '.$options['subject'];
}
self::sendMail($options);
}
// Deliver a message.
public static function sendMail()
{
$options['message'] = $layout->render();
}
else if (isset($options['body']) && !isset($options['message']))
{
$options['message'] = $options['body'];
unset($options['body']);
}
// Append the system name as a prefix to the message.
if (!isset($options['no_prefix']) || $options['no_prefix'] == FALSE)
{
$app_name = $config->application->name;
$options['subject'] = $app_name.': '.$options['subject'];
}
self::sendMail($options);
}
// Deliver a message.
public static function sendMail()
{
// Do not deliver mail on development environments.
if (DF_APPLICATION_ENV == "development" && !defined('DF_FORCE_EMAIL'))
return;
// Allow support for legacy argument style or new style.
$args = func_get_args();
if (func_num_args() == 1)
{
$options = $args[0];
}
else
{
$options = array_merge(array(
'to' => $args[0],
'subject' => $args[1],
'message' => $args[2],
'reply_to' => $args[3],
'delivery_date' => $args[4],
), $args[5]);
}
$config = \Zend_Registry::get('config');
// Allow support for legacy argument style or new style.
$args = func_get_args();
if (func_num_args() == 1)
{
$options = $args[0];
}
else
{
$options = array_merge(array(
'to' => $args[0],
'subject' => $args[1],
'message' => $args[2],
'reply_to' => $args[3],
'delivery_date' => $args[4],
), $args[5]);
}
$config = \Zend_Registry::get('config');
$mail_config = $config->application->mail->toArray();
$validator = new \Zend_Validate_EmailAddress();
$validator = new \Zend_Validate_EmailAddress();
if (isset($mail_config['use_smtp']) && $mail_config['use_smtp'])
{
$smtp_config = $config->apis->smtp->toArray();
$smtp_server = $smtp_config['server'];
unset($smtp_config['server']);
if (isset($mail_config['use_smtp']) && $mail_config['use_smtp'])
{
$smtp_config = $config->apis->smtp->toArray();
$smtp_server = $smtp_config['server'];
unset($smtp_config['server']);
$transport = new \Zend_Mail_Transport_Smtp($smtp_server, $smtp_config);
}
else
{
$transport = new \Zend_Mail_Transport_Sendmail();
}
if (!is_array($options['to']))
$options['to'] = array($options['to']);
foreach((array)$options['to'] as $mail_to_addr)
{
if ($mail_to_addr && $validator->isValid($mail_to_addr))
{
$mail = new \Zend_Mail();
$mail->setSubject($options['subject']);
$from_addr = (isset($options['from'])) ? $options['from'] : $mail_config['from_addr'];
$from_name = (isset($options['from_name'])) ? $options['from_name'] : $mail_config['from_name'];
$transport = new \Zend_Mail_Transport_Smtp($smtp_server, $smtp_config);
}
else
{
$transport = new \Zend_Mail_Transport_Sendmail();
}
if (!is_array($options['to']))
$options['to'] = array($options['to']);
foreach((array)$options['to'] as $mail_to_addr)
{
if ($mail_to_addr && $validator->isValid($mail_to_addr))
{
$mail = new \Zend_Mail();
$mail->setSubject($options['subject']);
$from_addr = (isset($options['from'])) ? $options['from'] : $mail_config['from_addr'];
$from_name = (isset($options['from_name'])) ? $options['from_name'] : $mail_config['from_name'];
$mail->setFrom($from_addr, $from_name);
if (isset($mail_config['bounce_addr']))
$mail->setReturnPath($mail_config['bounce_addr']);
// Include a specific "Direct replies to" header if specified.
if ($options['reply_to'] && $validator->isValid($options['reply_to']))
$mail->setReplyTo($options['reply_to']);
else if (isset($mail_config['reply_to']) && $mail_config['reply_to'])
$mail->setReplyTo($mail_config['reply_to']);
// Change the type of the e-mail's body if specified in the options.
if (isset($options['text_only']) && $options['text_only'])
$mail->setBodyText(strip_tags($options['message']));
else
$mail->setBodyHtml($options['message'], NULL, \Zend_Mime::ENCODING_8BIT);
// Add attachment if specified in options.
if (isset($options['attachments']))
{
foreach((array)$options['attachments'] as $attachment)
{
if ($attachment instanceof \Zend_Mime_Part)
$mail->addAttachment($attachment);
else
$mail->addAttachment(self::attachFile($attachment));
}
}
// Modify the mail type if specified.
if (isset($options['type']))
$mail->setType($options['type']);
$mail->addTo($mail_to_addr);
$mail->send($transport);
}
}
}
// Get a file attachment object for use in main messenging functions.
public static function attachFile($file_path, $file_name = NULL, $mime_type = NULL)
{
if (!file_exists($file_path))
throw new Exception('File not found for attachment!');
// Get the name of the file.
$file_name = (!is_null($file_name)) ? $file_name : basename($file_path);
// Compose the attachment object.
$at = new \Zend_Mime_Part(file_get_contents($file_path));
if (!is_null($mime_type))
$at->type = $mime_type;
$at->filename = $file_name;
$at->disposition = \Zend_Mime::DISPOSITION_INLINE;
$at->encoding = \Zend_Mime::ENCODING_BASE64;
return $at;
}
// Attach an iCalendar invitation.
// Include a specific "Direct replies to" header if specified.
if ($options['reply_to'] && $validator->isValid($options['reply_to']))
$mail->setReplyTo($options['reply_to']);
else if (isset($mail_config['reply_to']) && $mail_config['reply_to'])
$mail->setReplyTo($mail_config['reply_to']);
// Change the type of the e-mail's body if specified in the options.
if (isset($options['text_only']) && $options['text_only'])
$mail->setBodyText(strip_tags($options['message']));
else
$mail->setBodyHtml($options['message'], NULL, \Zend_Mime::ENCODING_8BIT);
// Add attachment if specified in options.
if (isset($options['attachments']))
{
foreach((array)$options['attachments'] as $attachment)
{
if ($attachment instanceof \Zend_Mime_Part)
$mail->addAttachment($attachment);
else
$mail->addAttachment(self::attachFile($attachment));
}
}
// Modify the mail type if specified.
if (isset($options['type']))
$mail->setType($options['type']);
$mail->addTo($mail_to_addr);
$mail->send($transport);
}
}
}
// Get a file attachment object for use in main messenging functions.
public static function attachFile($file_path, $file_name = NULL, $mime_type = NULL)
{
if (!file_exists($file_path))
throw new Exception('File not found for attachment!');
// Get the name of the file.
$file_name = (!is_null($file_name)) ? $file_name : basename($file_path);
// Compose the attachment object.
$at = new \Zend_Mime_Part(file_get_contents($file_path));
if (!is_null($mime_type))
$at->type = $mime_type;
$at->filename = $file_name;
$at->disposition = \Zend_Mime::DISPOSITION_INLINE;
$at->encoding = \Zend_Mime::ENCODING_BASE64;
return $at;
}
// Attach an iCalendar invitation.
public static function attachInvite($ics_data)
{
// Compose the attachment object.
$at = new \Zend_Mime_Part($ics_data);
$at->type = 'text/calendar';
$at->filename = 'calendar.ics';
$at->disposition = \Zend_Mime::DISPOSITION_INLINE;
$at->encoding = \Zend_Mime::ENCODING_8BIT;
return $at;
}
$at->disposition = \Zend_Mime::DISPOSITION_INLINE;
$at->encoding = \Zend_Mime::ENCODING_8BIT;
return $at;
}
}

View File

@ -68,7 +68,7 @@ class Navigation extends \Zend_Navigation
else
{
$retval = '<ul>'.implode("\n", $items).'</ul>';
return $retval;
return $retval;
}
}
@ -126,52 +126,52 @@ class Navigation extends \Zend_Navigation
if( !self::_checkPermission($page) )
return '';
$class = str_replace('here', '', $class);
$class = str_replace('here', '', $class);
if( self::_isPageActive($page) )
{
$class = $class . " " . $currentClass;
if (!$page->hasChildren()) $class = $class . " nochildren";
}
$retval = '';
$page_label = $page->getLabel();
$retval .= ($page_label) ? '<a href="'.$page->getHref().'" class="'.$class.'">'.$page_label.'</a>' : '';
$retval = '';
$page_label = $page->getLabel();
$retval .= ($page_label) ? '<a href="'.$page->getHref().'" class="'.$class.'">'.$page_label.'</a>' : '';
if( $page->hasChildren() && $levels != 0 )
{
$sub_retval = '';
$sub_retval = '';
foreach( $page as $child )
{
$sub_retval .= $this->_navRender($child, $levels - 1, $class, $currentClass);
}
if (!empty($sub_retval))
$retval .= '<ul>'.$sub_retval.'</ul>';
if (!empty($sub_retval))
$retval .= '<ul>'.$sub_retval.'</ul>';
}
if (isset($page->show_only_with_subpages) && !$sub_retval)
return '';
if (!empty($retval))
return '<li>'.$retval.'</li>';
else
return '';
if (!empty($retval))
return '<li>'.$retval.'</li>';
else
return '';
}
protected static function _checkPermission(\Zend_Navigation_Page $page)
{
if(isset($page->permission))
{
$acl = Acl::getInstance();
if (isset($page->is_dept) && $page->is_dept && method_exists($acl, 'isAllowedInDepartment'))
return $acl->isAllowedInDepartment($page->permission);
else
return $acl->isAllowed($page->permission);
}
return true;
if(isset($page->permission))
{
$acl = Acl::getInstance();
if (isset($page->is_dept) && $page->is_dept && method_exists($acl, 'isAllowedInDepartment'))
return $acl->isAllowedInDepartment($page->permission);
else
return $acl->isAllowed($page->permission);
}
return true;
}
protected static function _isPageActive(\Zend_Navigation_Page $page)

View File

@ -5,12 +5,12 @@ class Paginator extends \Zend_Paginator
{
public function __construct($paged_object, $page = 1, $limit = 10)
{
if ($paged_object instanceof \Doctrine\ORM\Query || $paged_object instanceof \Doctrine\ORM\QueryBuilder)
parent::__construct(new Paginator\Adapter\DoctrineQuery($paged_object));
elseif (is_array($paged_object))
parent::__construct(new \Zend_Paginator_Adapter_Array($paged_object));
else
parent::__construct(new \Zend_Paginator_Adapter_Null($paged_object));
if ($paged_object instanceof \Doctrine\ORM\Query || $paged_object instanceof \Doctrine\ORM\QueryBuilder)
parent::__construct(new Paginator\Adapter\DoctrineQuery($paged_object));
elseif (is_array($paged_object))
parent::__construct(new \Zend_Paginator_Adapter_Array($paged_object));
else
parent::__construct(new \Zend_Paginator_Adapter_Null($paged_object));
$this->setItemCountPerPage($limit);
$this->setCurrentPageNumber($page);

View File

@ -11,9 +11,9 @@ class DoctrineQuery implements \Zend_Paginator_Adapter_Interface
public function __construct($query)
{
if ($query instanceof QueryBuilder)
$query = $query->getQuery();
if ($query instanceof QueryBuilder)
$query = $query->getQuery();
$this->_query = $query;
}

View File

@ -7,18 +7,18 @@ namespace DF\Service;
class DoitApi
{
const TIMEOUT = 300;
protected $_settings;
protected $_http_client;
public function __construct()
{
$config = \Zend_Registry::get('config');
$this->_settings = $config->services->doitapi->toArray();
}
public function __call($method, $params = array())
const TIMEOUT = 300;
protected $_settings;
protected $_http_client;
public function __construct()
{
$config = \Zend_Registry::get('config');
$this->_settings = $config->services->doitapi->toArray();
}
public function __call($method, $params = array())
{
return $this->request($method, $params);
}
@ -26,138 +26,138 @@ class DoitApi
/**
* Custom Wrapper Functions
*/
public function checkAvailability()
{
try
{
$response = $this->request('isServerAlive');
return ($response);
}
catch (Exception $e)
{
return false;
}
}
public function logException($exception, $user = NULL)
{
try
{
$config = \Zend_Registry::get('config');
return $this->request('logException', array($config->application->shortcode, array(
'environment' => DF_APPLICATION_ENV,
'user' => $user,
'message' => $exception->getMessage(),
'exception' => get_class($exception),
'file' => $exception->getFile(),
'stack_trace' => $exception->getTraceAsString(),
'ip' => $_SERVER['REMOTE_ADDR'],
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
'request_uri' => $_SERVER['REQUEST_URI'],
'referrer' => $_SERVER['HTTP_REFERRER'],
'request_params' => $_REQUEST,
)));
}
catch (\Exception $e)
{
return $e->getMessage();
}
}
/**
* Standard API Calls
*/
protected function request($method, $params = array(), $id = NULL)
{
set_time_limit(self::TIMEOUT+30);
$client = $this->getHttpClient();
$client->setUri($this->_settings['service_uri']);
$request_string = array(
'jsonrpc' => '2.0',
'method' => $method,
'params' => $params,
'id' => $id,
public function checkAvailability()
{
try
{
$response = $this->request('isServerAlive');
return ($response);
}
catch (Exception $e)
{
return false;
}
}
public function logException($exception, $user = NULL)
{
try
{
$config = \Zend_Registry::get('config');
return $this->request('logException', array($config->application->shortcode, array(
'environment' => DF_APPLICATION_ENV,
'user' => $user,
'message' => $exception->getMessage(),
'exception' => get_class($exception),
'file' => $exception->getFile(),
'stack_trace' => $exception->getTraceAsString(),
'ip' => $_SERVER['REMOTE_ADDR'],
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
'request_uri' => $_SERVER['REQUEST_URI'],
'referrer' => $_SERVER['HTTP_REFERRER'],
'request_params' => $_REQUEST,
)));
}
catch (\Exception $e)
{
return $e->getMessage();
}
}
/**
* Standard API Calls
*/
protected function request($method, $params = array(), $id = NULL)
{
set_time_limit(self::TIMEOUT+30);
$client = $this->getHttpClient();
$client->setUri($this->_settings['service_uri']);
$request_string = array(
'jsonrpc' => '2.0',
'method' => $method,
'params' => $params,
'id' => $id,
);
$request_string = json_encode($request_string);
$client->setRawData($request_string, 'application/json');
$client->setHeaders('X-Compass-Api-Request-Signature: '.$this->getRequestSignature($request_string));
$response = $client->request('POST');
if ($response->isSuccessful() && $this->validateResponse($response))
{
$response_text = $response->getBody();
$response_json = json_decode($response_text, TRUE);
if (isset($response_json['result']))
{
return $response_json['result'];
}
}
else
{
throw new \Exception('Invalid Response (HTTP '.$response->getStatus().'): '.$response->getBody());
}
}
$request_string = json_encode($request_string);
$client->setRawData($request_string, 'application/json');
$client->setHeaders('X-Compass-Api-Request-Signature: '.$this->getRequestSignature($request_string));
$response = $client->request('POST');
if ($response->isSuccessful() && $this->validateResponse($response))
{
$response_text = $response->getBody();
$response_json = json_decode($response_text, TRUE);
if (isset($response_json['result']))
{
return $response_json['result'];
}
}
else
{
throw new \Exception('Invalid Response (HTTP '.$response->getStatus().'): '.$response->getBody());
}
}
protected function getHttpClient()
{
if (!is_object($this->_http_client))
{
if (DF_APPLICATION_ENV == "standalone")
{
$this->_http_client = new \Zend_Http_Client(NULL, array(
'adapter' => new \Zend_Http_Client_Adapter_Test,
));
}
else
{
$this->_http_client = new \Zend_Http_Client();
$this->_http_client->setConfig(array(
'timeout' => self::TIMEOUT,
'keepalive' => true,
));
}
}
$this->_http_client->resetParameters();
return $this->_http_client;
}
protected function validateResponse($response)
protected function getHttpClient()
{
if (!is_object($this->_http_client))
{
if (DF_APPLICATION_ENV == "standalone")
{
$this->_http_client = new \Zend_Http_Client(NULL, array(
'adapter' => new \Zend_Http_Client_Adapter_Test,
));
}
else
{
$this->_http_client = new \Zend_Http_Client();
$this->_http_client->setConfig(array(
'timeout' => self::TIMEOUT,
'keepalive' => true,
));
}
}
$this->_http_client->resetParameters();
return $this->_http_client;
}
protected function validateResponse($response)
{
$signature = $response->getHeader('X-Compass-Api-Response-Signature', 'unsigned');
if(strtolower($signature) == 'unsigned')
{
if($response->hasData('error'))
return true;
else
return false;
return true;
else
return false;
}
$hash = $this->getDataHash($response->getBody());
return ($hash == $signature);
$hash = $this->getDataHash($response->getBody());
return ($hash == $signature);
}
protected function getDataHash($data)
{
$hash = hash_hmac("sha256", $data, $this->_settings['private_key']);
return $hash;
}
protected function getRequestSignature($data)
{
$hash = $this->getDataHash($data);
return $this->_settings['api_key'].':'.$hash;
}
protected function getDataHash($data)
{
$hash = hash_hmac("sha256", $data, $this->_settings['private_key']);
return $hash;
}
protected function getRequestSignature($data)
{
$hash = $this->getDataHash($data);
return $this->_settings['api_key'].':'.$hash;
}
}

View File

@ -2,8 +2,8 @@
namespace DF\Service;
class Geography {
const TAMU_LATITUDE = 30.620477;
const TAMU_LONGITUDE = -96.325982;
const TAMU_LATITUDE = 30.620477;
const TAMU_LONGITUDE = -96.325982;
public static function getProvinces($countryCode = null)
{
@ -24,96 +24,96 @@ class Geography {
}
public static function getCountryName($id)
{
$countries = self::$countries;
if (isset($countries[$id]))
return $countries[$id];
else
return NULL;
$countries = self::$countries;
if (isset($countries[$id]))
return $countries[$id];
else
return NULL;
}
public static function getLatLong($address = "", $city = "College Station", $state = "TX", $zip = "77840")
{
$service_uri = 'http://where.yahooapis.com/geocode';
{
$service_uri = 'http://where.yahooapis.com/geocode';
$service_app_id = 'GPbstELV34EOLmhJU8b_nxgbrOxknJxtFjnIn8WOQ4tkmM22OpY8wzL0v3n3';
$url_params = array(
'appid' => $service_app_id,
'flags' => 'P',
'q' => $address.', '.$city.', '.$state.' '.$zip,
$url_params = array(
'appid' => $service_app_id,
'flags' => 'P',
'q' => $address.', '.$city.', '.$state.' '.$zip,
);
$request_url = $service_uri.'?'.http_build_query($url_params);
$response_raw = @file_get_contents($request_url);
$response = unserialize($response_raw);
if (count($response['ResultSet']['Result']) > 0)
{
$result = $response['ResultSet']['Result'][0];
return array(
'lat' => (double)$result['latitude'],
'lon' => (double)$result['longitude'],
);
}
else
{
return array(
'lat' => self::TAMU_LATITUDE,
'lon' => self::TAMU_LONGITUDE,
);
}
}
public static function getDistanceToCampus($latitude1, $longitude1)
{
$latitude2 = self::TAMU_LATITUDE;
$longitude2 = self::TAMU_LONGITUDE;
$theta = $longitude1 - $longitude2;
$distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$distance = acos($distance);
$distance = rad2deg($distance);
$distance = $distance * 60 * 1.1515;
return round($distance, 2);
}
/**
* Process an address submitted in this format:
* Array ( address_1, address_2, address_unit, address_city, address_state, address_zip )
*/
public static function processAddress($address_array)
{
$latlon = self::getLatLong($address_array['address_1'], $address_array['address_city'], $address_array['address_state'], $address_array['address_zip']);
$lat = $latlon['lat'];
$lon = $latlon['lon'];
if ($lat != 0 && $lon != 0)
{
$distance = self::getDistanceToCampus($lat, $lon);
}
else
{
$distance = 0;
$lat = self::TAMU_LATITUDE;
$lon = self::TAMU_LONGITUDE;
}
return array(
'latitude' => $lat,
'longitude' => $lon,
'distance' => $distance,
);
}
/**
* Static Arrays
*/
static $provinces = array(
$response_raw = @file_get_contents($request_url);
$response = unserialize($response_raw);
if (count($response['ResultSet']['Result']) > 0)
{
$result = $response['ResultSet']['Result'][0];
return array(
'lat' => (double)$result['latitude'],
'lon' => (double)$result['longitude'],
);
}
else
{
return array(
'lat' => self::TAMU_LATITUDE,
'lon' => self::TAMU_LONGITUDE,
);
}
}
public static function getDistanceToCampus($latitude1, $longitude1)
{
$latitude2 = self::TAMU_LATITUDE;
$longitude2 = self::TAMU_LONGITUDE;
$theta = $longitude1 - $longitude2;
$distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$distance = acos($distance);
$distance = rad2deg($distance);
$distance = $distance * 60 * 1.1515;
return round($distance, 2);
}
/**
* Process an address submitted in this format:
* Array ( address_1, address_2, address_unit, address_city, address_state, address_zip )
*/
public static function processAddress($address_array)
{
$latlon = self::getLatLong($address_array['address_1'], $address_array['address_city'], $address_array['address_state'], $address_array['address_zip']);
$lat = $latlon['lat'];
$lon = $latlon['lon'];
if ($lat != 0 && $lon != 0)
{
$distance = self::getDistanceToCampus($lat, $lon);
}
else
{
$distance = 0;
$lat = self::TAMU_LATITUDE;
$lon = self::TAMU_LONGITUDE;
}
return array(
'latitude' => $lat,
'longitude' => $lon,
'distance' => $distance,
);
}
/**
* Static Arrays
*/
static $provinces = array(
'US' => array(
'AL' => 'Alabama',
'AK' => 'Alaska',

View File

@ -6,9 +6,9 @@ namespace DF\Service;
class Gravatar
{
public static function get($email, $size=50)
{
$grav_prefix = (DF_IS_SECURE) ? 'https://secure.gravatar.com' : 'http://www.gravatar.com';
public static function get($email, $size=50)
{
$grav_prefix = (DF_IS_SECURE) ? 'https://secure.gravatar.com' : 'http://www.gravatar.com';
$url_params = array(
'd' => 'mm',
@ -16,6 +16,6 @@ class Gravatar
'size' => $size,
);
$grav_url = $grav_prefix.'/avatar/'.md5(strtolower($email)).'?'.http_build_query($url_params);
return htmlspecialchars($grav_url);
}
return htmlspecialchars($grav_url);
}
}

View File

@ -11,173 +11,173 @@ use \Entity\Role;
class Ldap
{
public static function authenticate($username, $password)
{
$ldapconn = self::init();
$user_entry = self::findByUsername($username);
if ($user_entry)
{
$user_dn = $user_entry['ldap_dn'];
$login = @ldap_bind($ldapconn, $user_dn, $password);
public static function authenticate($username, $password)
{
$ldapconn = self::init();
$user_entry = self::findByUsername($username);
if ($user_entry)
{
$user_dn = $user_entry['ldap_dn'];
$login = @ldap_bind($ldapconn, $user_dn, $password);
if ($user_dn && $login)
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::SUCCESS,
$user_entry,
array()
);
}
else
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE,
null,
(array)'Login failed.'
);
}
}
else
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null,
array(
'Username not found.'
)
);
}
}
if ($user_dn && $login)
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::SUCCESS,
$user_entry,
array()
);
}
else
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE,
null,
(array)'Login failed.'
);
}
}
else
{
return new \Zend_Auth_Result(
\Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
null,
array(
'Username not found.'
)
);
}
}
public static function search($query)
{
$fields_to_search = array(
'sAMAccountName',
'cn',
);
public static function search($query)
{
$fields_to_search = array(
'sAMAccountName',
'cn',
);
foreach($fields_to_search as $search_field)
{
$result = self::findByField($search_field, $query);
if ($result)
return $result;
}
foreach($fields_to_search as $search_field)
{
$result = self::findByField($search_field, $query);
if ($result)
return $result;
}
return NULL;
}
public static function findById($id)
{ return self::findByField('sID', $id); }
public static function findByUsername($username)
{ return self::findByField('sAMAccountName', $username); }
return NULL;
}
public static function findById($id)
{ return self::findByField('sID', $id); }
public static function findByUsername($username)
{ return self::findByField('sAMAccountName', $username); }
public static function findByName()
{ return self::findByField('cn', $username); }
public static function findByName()
{ return self::findByField('cn', $username); }
public static function findByField($field_name, $field_val)
{
$settings = self::getSettings();
$ldapconn = self::init();
public static function findByField($field_name, $field_val)
{
$settings = self::getSettings();
$ldapconn = self::init();
$search_dn = $field_name.'='.$field_val;
$results = ldap_search($ldapconn, $settings['basedn'], $search_dn);
$entries = ldap_get_entries($ldapconn, $results);
$search_dn = $field_name.'='.$field_val;
$results = ldap_search($ldapconn, $settings['basedn'], $search_dn);
$entries = ldap_get_entries($ldapconn, $results);
if ($entries['count'] > 0)
{
$entry = $entries[0];
return self::processEntry($entry);
}
if ($entries['count'] > 0)
{
$entry = $entries[0];
return self::processEntry($entry);
}
return NULL;
}
return NULL;
}
public static function processEntry($entry)
{
$settings = self::getSettings();
public static function processEntry($entry)
{
$settings = self::getSettings();
// Parse user roles.
$user_roles = array();
// Parse user roles.
$user_roles = array();
foreach((array)$entry['memberof'] as $group_item)
{
$addr_parts = ldap_explode_dn($group_item, 1);
$group_name = ($addr_parts) ? trim($addr_parts[0]) : NULL;
foreach((array)$entry['memberof'] as $group_item)
{
$addr_parts = ldap_explode_dn($group_item, 1);
$group_name = ($addr_parts) ? trim($addr_parts[0]) : NULL;
if (isset($settings['role_mapping'][$group_name]))
{
$role_name = $settings['role_mapping'][$group_name];
if (isset($settings['role_mapping'][$group_name]))
{
$role_name = $settings['role_mapping'][$group_name];
if ($role_name instanceof Role)
{
$user_roles[] = $role->id;
}
else
{
$role = Role::getRepository()->findOneByName($role_name);
if ($role instanceof Role)
$user_roles[] = $role->id;
}
}
}
if ($role_name instanceof Role)
{
$user_roles[] = $role->id;
}
else
{
$role = Role::getRepository()->findOneByName($role_name);
if ($role instanceof Role)
$user_roles[] = $role->id;
}
}
}
// Parse department name.
$addr_parts = ldap_explode_dn($entry['dn'], 1);
$addr_parts = ($addr_parts) ? array_reverse($addr_parts) : array();
$dept_name = $addr_parts[6];
return array(
'ldap_guid' => base64_encode($entry['objectguid'][0]),
'ldap_dn' => $entry['dn'],
'username' => $entry['samaccountname'][0],
'firstname' => $entry['givenname'][0],
'lastname' => $entry['sn'][0],
'title' => $entry['title'][0],
'dept' => $dept_name,
'email' => $entry['mail'][0],
'phone' => $entry['telephonenumber'][0],
'roles' => $user_roles,
);
}
// Parse department name.
$addr_parts = ldap_explode_dn($entry['dn'], 1);
$addr_parts = ($addr_parts) ? array_reverse($addr_parts) : array();
$dept_name = $addr_parts[6];
return array(
'ldap_guid' => base64_encode($entry['objectguid'][0]),
'ldap_dn' => $entry['dn'],
'username' => $entry['samaccountname'][0],
'firstname' => $entry['givenname'][0],
'lastname' => $entry['sn'][0],
'title' => $entry['title'][0],
'dept' => $dept_name,
'email' => $entry['mail'][0],
'phone' => $entry['telephonenumber'][0],
'roles' => $user_roles,
);
}
public static function init()
{
static $ldapconn;
if (!$ldapconn)
{
if (DF_APPLICATION_ENV == "standalone")
throw new \DF\Exception('LDAP authentication called in a standalone environment.');
$settings = self::getSettings();
ldap_set_option($ldapconn, LDAP_OPT_DEBUG_LEVEL, 7);
$ldapconn = ldap_connect($settings['server']);
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if ($settings['tls'])
{
putenv('LDAPTLS_REQCERT=never') or die('Failed to setup the env');
ldap_start_tls($ldapconn);
}
public static function init()
{
static $ldapconn;
if (!$ldapconn)
{
if (DF_APPLICATION_ENV == "standalone")
throw new \DF\Exception('LDAP authentication called in a standalone environment.');
$settings = self::getSettings();
ldap_set_option($ldapconn, LDAP_OPT_DEBUG_LEVEL, 7);
$ldapconn = ldap_connect($settings['server']);
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if ($settings['tls'])
{
putenv('LDAPTLS_REQCERT=never') or die('Failed to setup the env');
ldap_start_tls($ldapconn);
}
@ldap_bind($ldapconn, $settings['binddn'], $settings['bindpw']);
}
@ldap_bind($ldapconn, $settings['binddn'], $settings['bindpw']);
}
return $ldapconn;
}
return $ldapconn;
}
public static function getSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->ldap->toArray();
}
return $settings;
}
public static function getSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->ldap->toArray();
}
return $settings;
}
}

View File

@ -6,76 +6,76 @@
namespace DF\Service;
class TamuRest
{
public static function getByUin($uin)
{
return self::request('uin', $uin);
}
public function getByNetid($netid)
{
return self::request('netid', $netid);
}
public function getByUid($uid)
{
return self::request('uid', $uid);
}
protected static function request($criteria, $value)
{
if (DF_APPLICATION_ENV == "standalone")
return NULL;
$settings = self::getSettings();
$replacement_pattern = array(
'{CRITERIA}' => urlencode($criteria),
'{VALUE}' => urlencode($value),
'{FORMAT}' => 'json',
);
$uri_base = $settings['uri_base'];
$uri_page = str_replace(array_keys($replacement_pattern), array_values($replacement_pattern), $settings['uri_style']);
$http_client = new \Zend_Http_Client();
$http_client->setUri($uri_base.$uri_page);
$date_header = gmdate('D, d M Y H:i:s \G\M\T'); // Valid HTTP header date format.
$authentication_string = $uri_page."\n".$date_header."\n".$settings['identifier'];
$signature = base64_encode(hash_hmac('sha256', $authentication_string, $settings['shared_secret'], TRUE));
$http_client->setHeaders(array(
'Date' => $date_header,
'Authorization' => 'TAM '.$settings['identifier'].':'.$signature
));
try
{
{
public static function getByUin($uin)
{
return self::request('uin', $uin);
}
public function getByNetid($netid)
{
return self::request('netid', $netid);
}
public function getByUid($uid)
{
return self::request('uid', $uid);
}
protected static function request($criteria, $value)
{
if (DF_APPLICATION_ENV == "standalone")
return NULL;
$settings = self::getSettings();
$replacement_pattern = array(
'{CRITERIA}' => urlencode($criteria),
'{VALUE}' => urlencode($value),
'{FORMAT}' => 'json',
);
$uri_base = $settings['uri_base'];
$uri_page = str_replace(array_keys($replacement_pattern), array_values($replacement_pattern), $settings['uri_style']);
$http_client = new \Zend_Http_Client();
$http_client->setUri($uri_base.$uri_page);
$date_header = gmdate('D, d M Y H:i:s \G\M\T'); // Valid HTTP header date format.
$authentication_string = $uri_page."\n".$date_header."\n".$settings['identifier'];
$signature = base64_encode(hash_hmac('sha256', $authentication_string, $settings['shared_secret'], TRUE));
$http_client->setHeaders(array(
'Date' => $date_header,
'Authorization' => 'TAM '.$settings['identifier'].':'.$signature
));
try
{
$response = $http_client->request('GET');
}
catch(\Exception $e)
{
return NULL;
}
if ($response->isSuccessful())
{
$body = $response->getBody();
return \Zend_Json::decode($body);
}
else
{
return NULL;
}
}
protected static function getSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->tamurest->toArray();
}
return $settings;
}
if ($response->isSuccessful())
{
$body = $response->getBody();
return \Zend_Json::decode($body);
}
else
{
return NULL;
}
}
protected static function getSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->tamurest->toArray();
}
return $settings;
}
}

View File

@ -7,125 +7,125 @@ namespace DF\Service;
class TouchNet
{
// Creates a new transaction in the local database and returns the data necessary to create the form post.
public static function createTransaction($amount, $user, $site_id = null)
{
$record = new \Entity\Touchnet();
$record->user = $user;
$record->time_created = time();
$record->time_updated = time();
$record->payment_status = 'pending';
$record->save();
$record_id = $record->id;
$trans_id = self::getTransactionId($record_id);
$record->transaction_id = $trans_id;
$record->save();
$settings = self::getSettings();
// Compose the transaction information array and return it.
$transaction_data = array(
'record' => $record,
'url' => $settings->form_url,
'fields' => array(
'UPAY_SITE_ID' => (!is_null($site_id)) ? $site_id : $settings->site_id,
'EXT_TRANS_ID' => $trans_id,
'EXT_TRANS_ID_LABEL' => $settings->trans_id_label,
'AMT' => number_format($amount, 2, '.', ''),
'VALIDATION_KEY' => self::getValidationKey($amount, $trans_id),
),
);
return $transaction_data;
}
// Creates a new transaction in the local database and returns the data necessary to create the form post.
public static function createTransaction($amount, $user, $site_id = null)
{
$record = new \Entity\Touchnet();
$record->user = $user;
$record->time_created = time();
$record->time_updated = time();
$record->payment_status = 'pending';
$record->save();
$record_id = $record->id;
$trans_id = self::getTransactionId($record_id);
$record->transaction_id = $trans_id;
$record->save();
$settings = self::getSettings();
// Compose the transaction information array and return it.
$transaction_data = array(
'record' => $record,
'url' => $settings->form_url,
'fields' => array(
'UPAY_SITE_ID' => (!is_null($site_id)) ? $site_id : $settings->site_id,
'EXT_TRANS_ID' => $trans_id,
'EXT_TRANS_ID_LABEL' => $settings->trans_id_label,
'AMT' => number_format($amount, 2, '.', ''),
'VALIDATION_KEY' => self::getValidationKey($amount, $trans_id),
),
);
return $transaction_data;
}
// Get the validation key for a transaction.
public static function getValidationKey($amount, $trans_id)
{
$settings = self::getSettings();
$encode_string = $settings->posting_key . $trans_id . number_format($amount, 2, '.', '');
return base64_encode(md5($encode_string, true));
}
// Generate a new transaction ID.
public static function getTransactionId($record_id)
{
$settings = self::getSettings();
$record_hash = strtoupper(md5($settings->posting_key.$record_id));
$record_id_string = str_pad($record_id, 6, '0', STR_PAD_LEFT);
return substr($record_hash, 0, 5).$record_id_string;
}
// Handle the submission of posting URL data from the payment system. Returns the UserID to mark as paid if applicable.
public static function processPostData()
{
$settings = self::getSettings();
// Check for valid posting key.
if (strcmp($_REQUEST['posting_key'], $settings->posting_key) == 0)
{
// Check for existing transaction ID.
$trans_id = $_REQUEST['EXT_TRANS_ID'];
$record = \Entity\Touchnet::getRepository()->findOneBy(array('transaction_id' => $trans_id));
if ($record instanceof \Entity\Touchnet)
{
if ($_REQUEST['pmt_status'] == "success")
{
$record->payment_status = 'success';
$record->payment_amount = floatval($_REQUEST['pmt_amt']);
$record->payment_card_type = (string)$_REQUEST['card_type'];
$record->payment_name = (string)$_REQUEST['name_on_acct'];
$record->payment_order_id = intval($_REQUEST['sys_tracking_id']);
$record->payment_internal_trans_id = $_REQUEST['tpg_trans_id'];
$record->time_updated = time();
$record->save();
return $record;
}
else if ($_REQUEST['pmt_status'] == "cancelled")
{
$record->payment_status = 'cancelled';
$record->time_updated = time();
$record->save();
return NULL;
}
else
{
self::error('Invalid status code provided.');
}
}
else
{
self::error('Transaction not found!');
}
}
else
{
self::error('Invalid posting key specified!');
}
}
public static function error($text)
{
file_put_contents(DF_INCLUDE_WEsB.'/touchnet.txt', $text, FILE_APPEND);
throw new \DF\Exception($text);
}
public static function getSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->touchnet;
}
return $settings;
}
// Get the validation key for a transaction.
public static function getValidationKey($amount, $trans_id)
{
$settings = self::getSettings();
$encode_string = $settings->posting_key . $trans_id . number_format($amount, 2, '.', '');
return base64_encode(md5($encode_string, true));
}
// Generate a new transaction ID.
public static function getTransactionId($record_id)
{
$settings = self::getSettings();
$record_hash = strtoupper(md5($settings->posting_key.$record_id));
$record_id_string = str_pad($record_id, 6, '0', STR_PAD_LEFT);
return substr($record_hash, 0, 5).$record_id_string;
}
// Handle the submission of posting URL data from the payment system. Returns the UserID to mark as paid if applicable.
public static function processPostData()
{
$settings = self::getSettings();
// Check for valid posting key.
if (strcmp($_REQUEST['posting_key'], $settings->posting_key) == 0)
{
// Check for existing transaction ID.
$trans_id = $_REQUEST['EXT_TRANS_ID'];
$record = \Entity\Touchnet::getRepository()->findOneBy(array('transaction_id' => $trans_id));
if ($record instanceof \Entity\Touchnet)
{
if ($_REQUEST['pmt_status'] == "success")
{
$record->payment_status = 'success';
$record->payment_amount = floatval($_REQUEST['pmt_amt']);
$record->payment_card_type = (string)$_REQUEST['card_type'];
$record->payment_name = (string)$_REQUEST['name_on_acct'];
$record->payment_order_id = intval($_REQUEST['sys_tracking_id']);
$record->payment_internal_trans_id = $_REQUEST['tpg_trans_id'];
$record->time_updated = time();
$record->save();
return $record;
}
else if ($_REQUEST['pmt_status'] == "cancelled")
{
$record->payment_status = 'cancelled';
$record->time_updated = time();
$record->save();
return NULL;
}
else
{
self::error('Invalid status code provided.');
}
}
else
{
self::error('Transaction not found!');
}
}
else
{
self::error('Invalid posting key specified!');
}
}
public static function error($text)
{
file_put_contents(DF_INCLUDE_WEsB.'/touchnet.txt', $text, FILE_APPEND);
throw new \DF\Exception($text);
}
public static function getSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->touchnet;
}
return $settings;
}
}

View File

@ -3,52 +3,52 @@ namespace DF\Service;
class Twilio
{
public static function getInstance()
{
static $twilio;
public static function getInstance()
{
static $twilio;
if (!$twilio)
{
$settings = self::loadSettings();
if (!$twilio)
{
$settings = self::loadSettings();
$http = new \Services_Twilio_TinyHttp('https://api.twilio.com', array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => false
)));
$twilio = new \Services_Twilio($settings['account_id'], $settings['auth_token'], '2010-04-01', $http);
}
$http = new \Services_Twilio_TinyHttp('https://api.twilio.com', array('curlopts' => array(
CURLOPT_SSL_VERIFYPEER => false
)));
$twilio = new \Services_Twilio($settings['account_id'], $settings['auth_token'], '2010-04-01', $http);
}
return $twilio;
}
return $twilio;
}
public static function loadSettings()
{
static $settings;
public static function loadSettings()
{
static $settings;
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->twilio->toArray();
}
if (!$settings)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->twilio->toArray();
}
return $settings;
}
return $settings;
}
public static function sms($number, $message)
{
$client = self::getInstance();
$settings = self::loadSettings();
public static function sms($number, $message)
{
$client = self::getInstance();
$settings = self::loadSettings();
$number = preg_replace("/[^0-9]/", "", $number);
if (strlen($number) > 10)
$number = substr($number, -10);
if ($number)
{
return $client->account->sms_messages->create(
$settings['from_number'],
$number,
$message
);
}
}
$number = preg_replace("/[^0-9]/", "", $number);
if (strlen($number) > 10)
$number = substr($number, -10);
if ($number)
{
return $client->account->sms_messages->create(
$settings['from_number'],
$number,
$message
);
}
}
}

View File

@ -7,38 +7,38 @@
namespace DF;
class Session
{
public static function get($namespace = 'default')
{
return self::getNamespace($namespace);
}
public static function getNamespace($namespace = 'default')
{
static $sessions;
if ($sessions === NULL)
$sessions = array();
$session_name = self::getNamespaceName($namespace);
if (!isset($sessions[$session_name]))
$sessions[$session_name] = new \Zend_Session_Namespace($session_name);
return $sessions[$session_name];
}
public static function getNamespaceName($suffix = 'default')
{
$app_hash = strtoupper(substr(md5(DF_INCLUDE_BASE), 0, 5));
return 'DF_'.$app_hash.'_'.$suffix;
}
public static function suspend()
{
@session_write_close();
}
public static function resume()
{
@session_start();
}
public static function get($namespace = 'default')
{
return self::getNamespace($namespace);
}
public static function getNamespace($namespace = 'default')
{
static $sessions;
if ($sessions === NULL)
$sessions = array();
$session_name = self::getNamespaceName($namespace);
if (!isset($sessions[$session_name]))
$sessions[$session_name] = new \Zend_Session_Namespace($session_name);
return $sessions[$session_name];
}
public static function getNamespaceName($suffix = 'default')
{
$app_hash = strtoupper(substr(md5(DF_INCLUDE_BASE), 0, 5));
return 'DF_'.$app_hash.'_'.$suffix;
}
public static function suspend()
{
@session_write_close();
}
public static function resume()
{
@session_start();
}
}

View File

@ -6,17 +6,17 @@ namespace DF\Test;
*/
class TestCase extends \Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = \Zend_Registry::get('application');
parent::setUp();
}
public function tearDown()
{
$this->resetRequest();
$this->resetResponse();
parent::tearDown();
}
public function setUp()
{
$this->bootstrap = \Zend_Registry::get('application');
parent::setUp();
}
public function tearDown()
{
$this->resetRequest();
$this->resetResponse();
parent::tearDown();
}
}

View File

@ -9,71 +9,71 @@ class Url
*/
public static function baseUrl($include_domain = TRUE)
{
$config = \Zend_Registry::get('config');
if ($config->application->base_url && $include_domain === TRUE)
{
$base_url = $config->application->base_url;
if (DF_IS_SECURE)
$base_url = str_replace('http://', 'https://', $base_url);
return $base_url;
}
else
{
$base_url = \Zend_Controller_Front::getInstance()->getBaseUrl();
if ($include_domain)
return self::domain(TRUE).$base_url;
else
return $base_url;
}
$config = \Zend_Registry::get('config');
if ($config->application->base_url && $include_domain === TRUE)
{
$base_url = $config->application->base_url;
if (DF_IS_SECURE)
$base_url = str_replace('http://', 'https://', $base_url);
return $base_url;
}
else
{
$base_url = \Zend_Controller_Front::getInstance()->getBaseUrl();
if ($include_domain)
return self::domain(TRUE).$base_url;
else
return $base_url;
}
}
public static function content($file_name = NULL)
{
if (defined('DF_URL_STATIC'))
$static_url_base = DF_URL_STATIC;
else
$static_url_base = self::baseUrl(FALSE).'/static';
if ($file_name !== NULL)
return $static_url_base.'/'.$file_name;
else
return $static_url_base;
if (defined('DF_URL_STATIC'))
$static_url_base = DF_URL_STATIC;
else
$static_url_base = self::baseUrl(FALSE).'/static';
if ($file_name !== NULL)
return $static_url_base.'/'.$file_name;
else
return $static_url_base;
}
public static function file($file_name = NULL)
{
if (defined('DF_UPLOAD_URL'))
{
$upload_url_base = self::baseUrl().DF_UPLOAD_URL;
if ($file_name !== NULL)
return $static_url_base.'/'.$file_name;
else
return $static_url_base;
}
else
{
return self::content($file_name);
}
if (defined('DF_UPLOAD_URL'))
{
$upload_url_base = self::baseUrl().DF_UPLOAD_URL;
if ($file_name !== NULL)
return $static_url_base.'/'.$file_name;
else
return $static_url_base;
}
else
{
return self::content($file_name);
}
}
public static function cdn($library_name, $library_version)
{
$cdn_base = '//ajax.googleapis.com/ajax/libs';
switch($library_name)
{
case 'jquery':
return $cdn_base.'/jquery/'.$library_version.'/jquery.min.js';
break;
case 'jqueryui':
return $cdn_base.'/jqueryui/'.$library_version.'/jquery-ui.min.js';
break;
}
$cdn_base = '//ajax.googleapis.com/ajax/libs';
switch($library_name)
{
case 'jquery':
return $cdn_base.'/jquery/'.$library_version.'/jquery.min.js';
break;
case 'jqueryui':
return $cdn_base.'/jqueryui/'.$library_version.'/jquery-ui.min.js';
break;
}
}
public static function domain($includeScheme = false)
@ -100,30 +100,30 @@ class Url
return $default;
}
public static function current($includeSchemeDomain = TRUE, $include_request_uri = TRUE)
public static function current($includeSchemeDomain = TRUE, $include_request_uri = TRUE)
{
$prefix = '';
if($includeSchemeDomain)
{
$prefix = 'http' . (DF_IS_SECURE ? 's' : '') . '://' . $_SERVER['HTTP_HOST'];
}
$uri = '';
if (isset($_SERVER['REQUEST_URI']))
$uri = '';
if (isset($_SERVER['REQUEST_URI']))
{
$uri = $_SERVER['REQUEST_URI'];
}
else
{
$uri = self::route($request->getParams()).self::arrayToGetString($_GET);
}
if (!$include_request_uri && strstr($uri, '?') !== FALSE)
{
$uri = substr($uri, 0, strpos($uri, '?'));
}
return $prefix.$uri;
$uri = $_SERVER['REQUEST_URI'];
}
else
{
$uri = self::route($request->getParams()).self::arrayToGetString($_GET);
}
if (!$include_request_uri && strstr($uri, '?') !== FALSE)
{
$uri = substr($uri, 0, strpos($uri, '?'));
}
return $prefix.$uri;
}
/**
@ -138,7 +138,7 @@ class Url
*/
public static function route(array $options = array(), $route = null, $reset = true, $encode = true, array $get = array())
{
$target = '';
$target = '';
if (isset($options['#target']))
{
$target = '#'.str_replace('#', '', $options['#target']);
@ -151,42 +151,42 @@ class Url
public static function getRouter()
{
static $router;
if (!$router)
{
$front = \Zend_Controller_Front::getInstance();
$request = $front->getRequest();
if (!$request)
{
$request = new \Zend_Controller_Request_Http;
$front->setRequest($request);
}
$config = \Zend_Registry::get('config');
if ($config->application->base_url)
$request->setBaseUrl($config->application->base_url);
$router = $front->getRouter();
if (!$router)
{
$router = new \Zend_Controller_Router_Rewrite;
$front->setRouter($router);
}
$router->addDefaultRoutes();
}
return $router;
static $router;
if (!$router)
{
$front = \Zend_Controller_Front::getInstance();
$request = $front->getRequest();
if (!$request)
{
$request = new \Zend_Controller_Request_Http;
$front->setRequest($request);
}
$config = \Zend_Registry::get('config');
if ($config->application->base_url)
$request->setBaseUrl($config->application->base_url);
$router = $front->getRouter();
if (!$router)
{
$router = new \Zend_Controller_Router_Rewrite;
$front->setRouter($router);
}
$router->addDefaultRoutes();
}
return $router;
}
// Route to a URL without resetting the current routing path.
public static function routeFromHere($options = array())
{
$options = (is_array($options)) ? $options : array('action' => $options);
return self::route($options, NULL, FALSE);
}
// Route to a URL without resetting the current routing path.
public static function routeFromHere($options = array())
{
$options = (is_array($options)) ? $options : array('action' => $options);
return self::route($options, NULL, FALSE);
}
protected static function arrayToGetString(array $get, $preserve_existing_get = false)
{

View File

@ -7,136 +7,136 @@ namespace DF;
class Utilities
{
public static function getNewsFeed($feed_url, $cache_name = NULL, $cache_expires = 900)
{
if (!is_null($cache_name))
{
$feed_cache = \DF\Cache::get('feed_'.$cache_name);
}
if (!$feed_cache)
{
// Catch the occasional error when the RSS feed is malformed or the HTTP request times out.
try
{
$http_client = \Zend_Feed::getHttpClient();
$http_client->setConfig(array('timeout' => 60));
$news_feed = new \Zend_Feed_Rss($feed_url);
}
catch(Exception $e)
{
$news_feed = NULL;
}
if (!is_null($news_feed))
{
$latest_news = array();
$article_num = 0;
foreach ($news_feed as $item)
{
$article_num++;
// Process categories.
$categories_raw = (is_array($item->category)) ? $item->category : array($item->category);
$categories = array();
foreach($categories_raw as $category)
{
$categories[] = $category->__toString();
}
// Process main description.
$description = trim($item->description()); // Remove extraneous tags.
// $description = preg_replace('/[^(\x20-\x7F)]+/',' ', $description); // Strip "exotic" non-ASCII characters.
// $description = preg_replace('/<a[^(>)]+>read more<\/a>/i', '', $description); // Remove "read more" link.
$news_item = array(
'num' => $article_num,
'title' => $item->title(),
'timestamp' => strtotime($item->pubDate()),
'description' => $description,
'link' => $item->link(),
'categories' => $categories,
);
$latest_news[] = $news_item;
}
public static function getNewsFeed($feed_url, $cache_name = NULL, $cache_expires = 900)
{
if (!is_null($cache_name))
{
$feed_cache = \DF\Cache::get('feed_'.$cache_name);
}
if (!$feed_cache)
{
// Catch the occasional error when the RSS feed is malformed or the HTTP request times out.
try
{
$http_client = \Zend_Feed::getHttpClient();
$http_client->setConfig(array('timeout' => 60));
$news_feed = new \Zend_Feed_Rss($feed_url);
}
catch(Exception $e)
{
$news_feed = NULL;
}
if (!is_null($news_feed))
{
$latest_news = array();
$article_num = 0;
foreach ($news_feed as $item)
{
$article_num++;
// Process categories.
$categories_raw = (is_array($item->category)) ? $item->category : array($item->category);
$categories = array();
foreach($categories_raw as $category)
{
$categories[] = $category->__toString();
}
// Process main description.
$description = trim($item->description()); // Remove extraneous tags.
// $description = preg_replace('/[^(\x20-\x7F)]+/',' ', $description); // Strip "exotic" non-ASCII characters.
// $description = preg_replace('/<a[^(>)]+>read more<\/a>/i', '', $description); // Remove "read more" link.
$news_item = array(
'num' => $article_num,
'title' => $item->title(),
'timestamp' => strtotime($item->pubDate()),
'description' => $description,
'link' => $item->link(),
'categories' => $categories,
);
$latest_news[] = $news_item;
}
$latest_news = array_slice($latest_news, 0, 10);
if (!is_null($cache_name))
{
\DF\Cache::set($latest_news, 'feed_'.$cache_name, array('feeds', $cache_name));
}
}
}
else
{
$latest_news = $feed_cache;
}
return $latest_news;
}
/**
* Random Image
*/
public static function randomImage($static_dir)
{
$img = null;
$folder = DF_INCLUDE_STATIC.DIRECTORY_SEPARATOR.$static_dir;
$extList = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
);
$handle = opendir($folder);
while ($file = readdir($handle))
{
$file_info = pathinfo($file);
$file_ext = strtolower($file_info['extension']);
if (isset($extList[$file_ext]))
$fileList[] = $file;
}
closedir($handle);
if (count($fileList) > 0)
{
$imageNumber = time() % count($fileList);
$img = $fileList[$imageNumber];
}
return \DF\Url::content($static_dir.'/'.$img);
}
$latest_news = array_slice($latest_news, 0, 10);
if (!is_null($cache_name))
{
\DF\Cache::set($latest_news, 'feed_'.$cache_name, array('feeds', $cache_name));
}
}
}
else
{
$latest_news = $feed_cache;
}
return $latest_news;
}
/**
* Random Image
*/
public static function randomImage($static_dir)
{
$img = null;
$folder = DF_INCLUDE_STATIC.DIRECTORY_SEPARATOR.$static_dir;
$extList = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
);
$handle = opendir($folder);
while ($file = readdir($handle))
{
$file_info = pathinfo($file);
$file_ext = strtolower($file_info['extension']);
if (isset($extList[$file_ext]))
$fileList[] = $file;
}
closedir($handle);
if (count($fileList) > 0)
{
$imageNumber = time() % count($fileList);
$img = $fileList[$imageNumber];
}
return \DF\Url::content($static_dir.'/'.$img);
}
/**
* Password Generation
*/
/**
* Password Generation
*/
const PASSWORD_LENGTH = 9;
// Replacement for print_r.
public static function print_r($var, $return = FALSE)
{
$return_value = '<pre style="font-size: 13px; font-family: Consolas, Courier New, Courier, monospace; color: #000; background: #EFEFEF; border: 1px solid #CCC; padding: 5px;">';
$return_value .= print_r($var, TRUE);
$return_value .= '</pre>';
if ($return)
{
return $return_value;
}
else
{
echo $return_value;
}
}
const PASSWORD_LENGTH = 9;
// Replacement for print_r.
public static function print_r($var, $return = FALSE)
{
$return_value = '<pre style="font-size: 13px; font-family: Consolas, Courier New, Courier, monospace; color: #000; background: #EFEFEF; border: 1px solid #CCC; padding: 5px;">';
$return_value .= print_r($var, TRUE);
$return_value .= '</pre>';
if ($return)
{
return $return_value;
}
else
{
echo $return_value;
}
}
/**
* Number handling
@ -151,91 +151,91 @@ class Utilities
public static function money_format($number)
{
if ($number < 0)
return '-$'.number_format(abs($number), 2);
else
return '$'.number_format($number, 2);
}
public static function getFiscalYear($timestamp = NULL)
{
if ($timestamp === NULL)
$timestamp = time();
$fiscal_year = intval(date('Y', $timestamp));
$fiscal_month = intval(date('m', $timestamp));
if ($fiscal_month >= 9)
$fiscal_year++;
return $fiscal_year;
}
/**
* Security
*/
public static function generatePassword($char_length = self::PASSWORD_LENGTH)
{
// String of all possible characters. Avoids using certain letters and numbers that closely resemble others.
$numeric_chars = str_split('234679');
$uppercase_chars = str_split('ACDEFGHJKLMNPQRTWXYZ');
$lowercase_chars = str_split('acdefghjkmnpqrtwxyz');
$chars = array($numeric_chars, $uppercase_chars, $lowercase_chars);
$password = '';
for($i = 1; $i <= $char_length; $i++)
{
$char_array = $chars[$i % 3];
$password .= $char_array[mt_rand(0, count($char_array)-1)];
}
return str_shuffle($password);
}
// Get the plain-english value of a given timestamp.
public static function timeToText($timestamp)
{
return self::timeDifferenceText(0, $timestamp);
}
// Get the plain-english difference between two timestamps.
public static function timeDifferenceText($timestamp1, $timestamp2)
{
$time_diff = abs($timestamp1 - $timestamp2);
$diff_text = "";
if ($time_diff < 60)
{
$time_num = intval($time_diff);
$time_unit = 'second';
}
else if ($time_diff >= 60 && $time_diff < 3600)
{
$time_num = round($time_diff / 60, 1);
$time_unit = 'minute';
}
else if ($time_diff >= 3600 && $time_diff < 216000)
{
$time_num = round($time_diff / 3600, 1);
$time_unit = 'hour';
}
else if ($time_diff >= 216000 && $time_diff < 10368000)
{
$time_num = round($time_diff / 86400);
$time_unit = 'day';
}
else
{
$time_num = round($time_diff / 2592000);
$time_unit = 'month';
}
$diff_text = $time_num.' '.$time_unit.(($time_num != 1)?'s':'');
return $diff_text;
}
if ($number < 0)
return '-$'.number_format(abs($number), 2);
else
return '$'.number_format($number, 2);
}
public static function getFiscalYear($timestamp = NULL)
{
if ($timestamp === NULL)
$timestamp = time();
$fiscal_year = intval(date('Y', $timestamp));
$fiscal_month = intval(date('m', $timestamp));
if ($fiscal_month >= 9)
$fiscal_year++;
return $fiscal_year;
}
/**
* Security
*/
public static function generatePassword($char_length = self::PASSWORD_LENGTH)
{
// String of all possible characters. Avoids using certain letters and numbers that closely resemble others.
$numeric_chars = str_split('234679');
$uppercase_chars = str_split('ACDEFGHJKLMNPQRTWXYZ');
$lowercase_chars = str_split('acdefghjkmnpqrtwxyz');
$chars = array($numeric_chars, $uppercase_chars, $lowercase_chars);
$password = '';
for($i = 1; $i <= $char_length; $i++)
{
$char_array = $chars[$i % 3];
$password .= $char_array[mt_rand(0, count($char_array)-1)];
}
return str_shuffle($password);
}
// Get the plain-english value of a given timestamp.
public static function timeToText($timestamp)
{
return self::timeDifferenceText(0, $timestamp);
}
// Get the plain-english difference between two timestamps.
public static function timeDifferenceText($timestamp1, $timestamp2)
{
$time_diff = abs($timestamp1 - $timestamp2);
$diff_text = "";
if ($time_diff < 60)
{
$time_num = intval($time_diff);
$time_unit = 'second';
}
else if ($time_diff >= 60 && $time_diff < 3600)
{
$time_num = round($time_diff / 60, 1);
$time_unit = 'minute';
}
else if ($time_diff >= 3600 && $time_diff < 216000)
{
$time_num = round($time_diff / 3600, 1);
$time_unit = 'hour';
}
else if ($time_diff >= 216000 && $time_diff < 10368000)
{
$time_num = round($time_diff / 86400);
$time_unit = 'day';
}
else
{
$time_num = round($time_diff / 2592000);
$time_unit = 'month';
}
$diff_text = $time_num.' '.$time_unit.(($time_num != 1)?'s':'');
return $diff_text;
}
/**
/**
* Truncate text (adding "..." if needed)
*/
public static function truncateText($text, $limit = 80, $pad = '...')
@ -262,8 +262,8 @@ class Utilities
public static function truncateUrl($url, $length=40)
{
$url = str_replace(array('http://', 'https://', 'www.'), array('', '', ''), $url);
return self::truncateText(rtrim($url, '/'), $length);
$url = str_replace(array('http://', 'https://', 'www.'), array('', '', ''), $url);
return self::truncateText(rtrim($url, '/'), $length);
}
/**
@ -271,13 +271,13 @@ class Utilities
*/
public static function pairs($array)
{
return array_combine($array, $array);
return array_combine($array, $array);
}
public static function columns($array, $num_cols = 2, $preserve_keys = true)
{
$items_total = (int)count($array);
$items_per_col = ceil($items_total / $num_cols);
return array_chunk($array, $items_per_col, $preserve_keys);
$items_total = (int)count($array);
$items_per_col = ceil($items_total / $num_cols);
return array_chunk($array, $items_per_col, $preserve_keys);
}
}

View File

@ -9,8 +9,8 @@ define('DF_CORE_VERSION', 'DF_Z1_D2_2011');
class Version
{
public static function getVersion()
{
return DF_CORE_VERSION;
}
public static function getVersion()
{
return DF_CORE_VERSION;
}
}

View File

@ -4,6 +4,6 @@ class Alert extends \Zend_View_Helper_Abstract
{
public function alert($message, $level = \DF\Flash::INFO)
{
\DF\Flash::addMessage($message, $level);
\DF\Flash::addMessage($message, $level);
}
}

View File

@ -2,20 +2,20 @@
namespace DF\View\Helper;
class Analytics extends \Zend_View_Helper_Abstract
{
public function analytics($account_number)
{
$analytics_script = "
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '".$account_number."']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
";
return '<script type="text/javascript">'.preg_replace("/\t+/", "", $analytics_script).'</script>';
public function analytics($account_number)
{
$analytics_script = "
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '".$account_number."']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
";
return '<script type="text/javascript">'.preg_replace("/\t+/", "", $analytics_script).'</script>';
}
}

View File

@ -4,7 +4,7 @@ class Breadcrumb extends \Zend_View_Helper_Abstract
{
public function breadcrumb($menu_name = 'default')
{
$nav_item = $this->view->menu($menu_name);
return $this->view->navigation()->breadcrumbs($nav_item)->setSeparator(' &raquo; ')->setMinDepth(1);
$nav_item = $this->view->menu($menu_name);
return $this->view->navigation()->breadcrumbs($nav_item)->setSeparator(' &raquo; ')->setMinDepth(1);
}
}

View File

@ -5,55 +5,55 @@ class Button extends \Zend_View_Helper_Abstract
/**
* @return A string containing the icon's image tag.
*/
public function button($params)
{
$defaults = array(
'type' => 'link',
'class' => '',
);
$params = array_merge($defaults, $params);
$params['class'] .= ' btn ui-button';
$button_icon = (isset($params['icon'])) ? $this->view->icon($params['icon']) : '';
$button_type = $params['type'];
$button_text = $params['text'];
unset($params['text'], $params['icon']);
switch($button_type)
{
case "button":
case "submit":
$button_string = array();
foreach($params as $param_key => $param_val)
{
$button_string[] = $param_key.'="'.$param_val.'"';
}
return '<button '.implode(' ', $button_string).'>'.$button_icon.$button_text.'</button>';
break;
case "link":
case "small":
case "mini":
case "large":
case "block":
default:
unset($params['type']);
$defaults = array(
'href' => '#',
);
$params = array_merge($defaults, $params);
if ($button_type != "link")
$params['class'] .= ' btn-'.$button_type;
$button_string = array();
foreach ($params as $param_key => $param_val)
{
$button_string[] = $param_key.'="'.$param_val.'"';
}
return '<a '.implode(' ', $button_string).'>'.$button_icon.$button_text.'</a>';
break;
}
public function button($params)
{
$defaults = array(
'type' => 'link',
'class' => '',
);
$params = array_merge($defaults, $params);
$params['class'] .= ' btn ui-button';
$button_icon = (isset($params['icon'])) ? $this->view->icon($params['icon']) : '';
$button_type = $params['type'];
$button_text = $params['text'];
unset($params['text'], $params['icon']);
switch($button_type)
{
case "button":
case "submit":
$button_string = array();
foreach($params as $param_key => $param_val)
{
$button_string[] = $param_key.'="'.$param_val.'"';
}
return '<button '.implode(' ', $button_string).'>'.$button_icon.$button_text.'</button>';
break;
case "link":
case "small":
case "mini":
case "large":
case "block":
default:
unset($params['type']);
$defaults = array(
'href' => '#',
);
$params = array_merge($defaults, $params);
if ($button_type != "link")
$params['class'] .= ' btn-'.$button_type;
$button_string = array();
foreach ($params as $param_key => $param_val)
{
$button_string[] = $param_key.'="'.$param_val.'"';
}
return '<a '.implode(' ', $button_string).'>'.$button_icon.$button_text.'</a>';
break;
}
}
}

View File

@ -2,12 +2,12 @@
namespace DF\View\Helper;
class DdFormErrors extends \Zend_View_Helper_FormErrors
{
public function ddFormErrors($errors, array $options = null)
public function ddFormErrors($errors, array $options = null)
{
$this->setElementStart('<dd%s>');
$this->setElementEnd('</dd>');
$this->setElementSeparator('<br />');
return parent::formErrors($errors, $options);
}
$this->setElementStart('<dd%s>');
$this->setElementEnd('</dd>');
$this->setElementSeparator('<br />');
return parent::formErrors($errors, $options);
}
}

View File

@ -3,14 +3,14 @@ namespace DF\View\Helper;
class Fieldset extends \Zend_View_Helper_Fieldset
{
public function fieldset($name, $content, $attribs = null)
public function fieldset($name, $content, $attribs = null)
{
$info = $this->_getInfo($name, $content, $attribs);
extract($info);
if (!$attribs['legend'])
return $content;
else
return parent::fieldset($name, $content, $attribs);
return $content;
else
return parent::fieldset($name, $content, $attribs);
}
}

View File

@ -2,12 +2,12 @@
namespace DF\View\Helper;
class FormErrors extends \Zend_View_Helper_FormErrors
{
public function formErrors($errors, array $options = null)
public function formErrors($errors, array $options = null)
{
$this->setElementStart('<dd%s>');
$this->setElementEnd('</dd>');
$this->setElementSeparator('<br />');
return parent::formErrors($errors, $options);
}
$this->setElementStart('<dd%s>');
$this->setElementEnd('</dd>');
$this->setElementSeparator('<br />');
return parent::formErrors($errors, $options);
}
}

View File

@ -4,7 +4,7 @@ class FormMarkup extends \Zend_View_Helper_FormElement
{
public function formMarkup($name, $value = null, $attribs = null)
{
$info = $this->_getInfo($name, $value, $attribs);
$info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
$markup = $attribs['markup'];
@ -14,9 +14,9 @@ class FormMarkup extends \Zend_View_Helper_FormElement
$return = '<span';
foreach($attribs as $attr_key => $attr_item)
$return .= ' '.$attr_key.'="'.$attr_item.'"';
$return .= '>'.$markup.'</span>';
$return .= ' '.$attr_key.'="'.$attr_item.'"';
$return .= '>'.$markup.'</span>';
return $return;
}
}
}

View File

@ -6,10 +6,10 @@ class FormMultiCheckbox extends \Zend_View_Helper_FormMultiCheckbox
public function formMultiCheckbox($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n")
{
$raw = parent::formRadio($name, $value, $attribs, $options);
$raw_items = explode("<br />", $raw);
$ul_class = ($attribs['inline']) ? 'inputs-list inline' : 'inputs-list';
return '<ul class="'.$ul_class.'"><li>'.implode('</li><li>', $raw_items).'</li></ul>';
$raw = parent::formRadio($name, $value, $attribs, $options);
$raw_items = explode("<br />", $raw);
$ul_class = ($attribs['inline']) ? 'inputs-list inline' : 'inputs-list';
return '<ul class="'.$ul_class.'"><li>'.implode('</li><li>', $raw_items).'</li></ul>';
}
}

View File

@ -6,10 +6,10 @@ class FormRadio extends \Zend_View_Helper_FormRadio
public function formRadio($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n")
{
$raw = parent::formRadio($name, $value, $attribs, $options, "<br />");
$raw_items = explode("<br />", $raw);
$ul_class = ($attribs['inline'] || $listsep == ' ') ? 'inputs-list inline' : 'inputs-list';
return '<ul class="'.$ul_class.'"><li>'.implode('</li><li>', $raw_items).'</li></ul>';
$raw = parent::formRadio($name, $value, $attribs, $options, "<br />");
$raw_items = explode("<br />", $raw);
$ul_class = ($attribs['inline'] || $listsep == ' ') ? 'inputs-list inline' : 'inputs-list';
return '<ul class="'.$ul_class.'"><li>'.implode('</li><li>', $raw_items).'</li></ul>';
}
}

View File

@ -4,14 +4,14 @@ class FormUnixDate extends \Zend_View_Helper_FormElement
{
public function formUnixDate($name, $orig_value = null, $attribs = null)
{
$info = $this->_getInfo($name, $orig_value, $attribs);
$info = $this->_getInfo($name, $orig_value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable
if (empty($attribs))
{
$element = new \DF\Form\Element\UnixDate($name);
$element->setValue($orig_value);
$attribs = (array)$element->getAttribs();
$element = new \DF\Form\Element\UnixDate($name);
$element->setValue($orig_value);
$attribs = (array)$element->getAttribs();
}
$config = \Zend_Registry::get('config');

View File

@ -9,9 +9,9 @@ class FormUnixDateTime extends \Zend_View_Helper_FormElement
if (empty($attribs))
{
$element = new \DF\Form\Element\UnixDateTime($name);
$element->setValue($orig_value);
$attribs = (array)$element->getAttribs();
$element = new \DF\Form\Element\UnixDateTime($name);
$element->setValue($orig_value);
$attribs = (array)$element->getAttribs();
}
$config = \Zend_Registry::get('config');

View File

@ -6,13 +6,13 @@ class Icon extends \Zend_View_Helper_Abstract
* @return A string containing the icon's image tag.
*/
public function icon($params)
{
{
if (!is_array($params))
$params = array('image' => $params);
// Default values for icons.
$defaults = array(
'type' => 'png',
'type' => 'png',
'alt' => '(Icon)',
'class' => 'icon',
);
@ -20,39 +20,39 @@ class Icon extends \Zend_View_Helper_Abstract
if (substr($params['image'], 0, 5) == "icon-")
{
$params['class'] .= ' '.$params['image'];
unset($params['type'], $params['image']);
return $this->iconComposeTag('i', $params);
$params['class'] .= ' '.$params['image'];
unset($params['type'], $params['image']);
return $this->iconComposeTag('i', $params);
}
else if ($params['type'] == "png")
{
$params['class'] .= ' ui-silk ui-silk-'.str_replace('_', '-', $params['image']);
unset($params['type'], $params['image']);
return $this->iconComposeTag('span', $params);
}
else
{
$icon_name = str_replace('.png', '', $params['image']).'.png';
$params['src'] = \DF\Url::content('common/icons/'.$params['type'].'/'.$icon_name);
unset($params['size'], $params['image'], $params['type']);
return $this->iconComposeTag('img', $params, '');
}
else if ($params['type'] == "png")
{
$params['class'] .= ' ui-silk ui-silk-'.str_replace('_', '-', $params['image']);
unset($params['type'], $params['image']);
return $this->iconComposeTag('span', $params);
}
else
{
$icon_name = str_replace('.png', '', $params['image']).'.png';
$params['src'] = \DF\Url::content('common/icons/'.$params['type'].'/'.$icon_name);
unset($params['size'], $params['image'], $params['type']);
return $this->iconComposeTag('img', $params, '');
}
}
public function iconComposeTag($tag_type = 'span', $params, $tag_contents = '')
{
$tag_string = array();
foreach((array)$params as $key => $val)
{
if (!empty($val))
$tag_string[] = $key.'="'.htmlspecialchars(trim($val)).'"';
}
if ($tag_type == "img")
return '<'.$tag_type.' '.implode(' ', $tag_string).'>';
else
return '<'.$tag_type.' '.implode(' ', $tag_string).'>'.$tag_contents.'</'.$tag_type.'>';
}
public function iconComposeTag($tag_type = 'span', $params, $tag_contents = '')
{
$tag_string = array();
foreach((array)$params as $key => $val)
{
if (!empty($val))
$tag_string[] = $key.'="'.htmlspecialchars(trim($val)).'"';
}
if ($tag_type == "img")
return '<'.$tag_type.' '.implode(' ', $tag_string).'>';
else
return '<'.$tag_type.' '.implode(' ', $tag_string).'>'.$tag_contents.'</'.$tag_type.'>';
}
}

View File

@ -6,8 +6,8 @@
namespace DF\View\Helper;
class Ifset extends \Zend_View_Helper_Abstract
{
public function ifset($original_var, $default_value = "")
{
return ($original_var) ? $original_var : $default_value;
}
public function ifset($original_var, $default_value = "")
{
return ($original_var) ? $original_var : $default_value;
}
}

View File

@ -6,14 +6,14 @@
namespace DF\View\Helper;
class Link extends \Zend_View_Helper_Abstract
{
public function link($url, $text = NULL, $target = NULL)
{
public function link($url, $text = NULL, $target = NULL)
{
if ($text === NULL)
$text = $url;
if ($target !== NULL)
$target = 'target="'.$target.'"';
if ($target !== NULL)
$target = 'target="'.$target.'"';
return '<a href="'.$url.'" '.$target.'>'.$text.'</a>';
}
}
}

View File

@ -6,12 +6,12 @@
namespace DF\View\Helper;
class Mailto extends \Zend_View_Helper_Abstract
{
public function mailto($address, $link_text = NULL)
{
$address = substr(chunk_split(bin2hex(" $address"), 2, ";&#x"), 3,-3);
$link_text = (is_null($link_text)) ? $address : $link_text;
return '<a href="mailto:'.$address.'">'.$link_text.'</a>';
}
public function mailto($address, $link_text = NULL)
{
$address = substr(chunk_split(bin2hex(" $address"), 2, ";&#x"), 3,-3);
$link_text = (is_null($link_text)) ? $address : $link_text;
return '<a href="mailto:'.$address.'">'.$link_text.'</a>';
}
}

View File

@ -2,8 +2,8 @@
namespace DF\View\Helper;
class Money extends \Zend_View_Helper_Abstract
{
public function money($amount)
{
return \DF\Utilities::money_format($amount);
}
public function money($amount)
{
return \DF\Utilities::money_format($amount);
}
}

View File

@ -4,15 +4,15 @@ class Paginate extends \Zend_View_Helper_Abstract
{
public function paginate($pager)
{
if (!($pager instanceof \Zend_Paginator))
return '';
if (!($pager instanceof \Zend_Paginator))
return '';
$pages = (array)$pager->getPages();
$query_string = '';
if (!empty($_GET))
$query_string = '?'.http_build_query($_GET);
$query_string = '';
if (!empty($_GET))
$query_string = '?'.http_build_query($_GET);
$return_string = '';
if ($pages['pageCount'] > 1)

View File

@ -22,17 +22,17 @@ class Pluralize extends \Zend_View_Helper_Abstract
array( '/(x|ch|ss|sh)$/i', "$1es" ),
array( '/([^aeiouy]|qu)y$/i', "$1ies" ),
array( '/([^aeiouy]|qu)ies$/i', "$1y" ),
array( '/(hive)$/i', "$1s" ),
array( '/(?:([^f])fe|([lr])f)$/i', "$1$2ves" ),
array( '/sis$/i', "ses" ),
array( '/([ti])um$/i', "$1a" ),
array( '/(buffal|tomat)o$/i', "$1oes" ),
array( '/(hive)$/i', "$1s" ),
array( '/(?:([^f])fe|([lr])f)$/i', "$1$2ves" ),
array( '/sis$/i', "ses" ),
array( '/([ti])um$/i', "$1a" ),
array( '/(buffal|tomat)o$/i', "$1oes" ),
array( '/(bu)s$/i', "$1ses" ),
array( '/(alias|status)$/i', "$1es" ),
array( '/(octop|vir)us$/i', "$1i" ),
array( '/(ax|test)is$/i', "$1es" ),
array( '/s$/i', "s" ),
array( '/$/', "s" )
array( '/(alias|status)$/i', "$1es" ),
array( '/(octop|vir)us$/i', "$1i" ),
array( '/(ax|test)is$/i', "$1es" ),
array( '/s$/i', "s" ),
array( '/$/', "s" )
);
$irregular = array(
@ -44,14 +44,14 @@ class Pluralize extends \Zend_View_Helper_Abstract
);
$uncountable = array(
'sheep',
'fish',
'series',
'species',
'money',
'rice',
'information',
'equipment'
'sheep',
'fish',
'series',
'species',
'money',
'rice',
'information',
'equipment'
);
// save some time in the case that singular and plural are the same

View File

@ -2,31 +2,31 @@
namespace DF\View\Helper;
class PubNub extends \Zend_View_Helper_Abstract
{
public function pubNub()
public function pubNub()
{
static $is_attached;
if (!$is_attached)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->pubnub->toArray();
$pubnub_settings = array(
'publish_key' => $settings['pub_key'],
'subscribe_key' => $settings['sub_key'],
'origin' => 'pubsub.pubnub.com',
'ssl' => (DF_IS_SECURE) ? true : false,
);
$this->view->headScript()->appendFile('http://cdn.pubnub.com/pubnub-3.1.min.js');
$this->view->headScript()->appendScript('
(function(){
var pubnub = PUBNUB.init('.json_encode($pubnub_settings).');
$.pubnub = pubnub;
})();
');
$is_attached = TRUE;
}
static $is_attached;
if (!$is_attached)
{
$config = \Zend_Registry::get('config');
$settings = $config->services->pubnub->toArray();
$pubnub_settings = array(
'publish_key' => $settings['pub_key'],
'subscribe_key' => $settings['sub_key'],
'origin' => 'pubsub.pubnub.com',
'ssl' => (DF_IS_SECURE) ? true : false,
);
$this->view->headScript()->appendFile('http://cdn.pubnub.com/pubnub-3.1.min.js');
$this->view->headScript()->appendScript('
(function(){
var pubnub = PUBNUB.init('.json_encode($pubnub_settings).');
$.pubnub = pubnub;
})();
');
$is_attached = TRUE;
}
}
}

View File

@ -6,8 +6,8 @@
namespace DF\View\Helper;
class RenderBlock extends \Zend_View_Helper_Abstract
{
public function renderBlock($block_name, $vars = array(), $title = FALSE)
{
return \Entity\Block::render($block_name, $vars, $title);
}
public function renderBlock($block_name, $vars = array(), $title = FALSE)
{
return \Entity\Block::render($block_name, $vars, $title);
}
}

View File

@ -6,17 +6,17 @@
namespace DF\View\Helper;
class RenderCommon extends \Zend_View_Helper_Abstract
{
public function renderCommon($target, $vars = array())
{
$config = \Zend_Registry::get('config');
$assign_vars = array_merge((array)$this->view->getVars(), $vars);
$view_renderer = \DF\Application\Bootstrap::getNewView(FALSE);
$view = $view_renderer->view;
$view->setScriptPath($config->application->resources->layout->commonTemplates);
$view->assign((array)$assign_vars);
return $view->render($target.'.phtml');
}
public function renderCommon($target, $vars = array())
{
$config = \Zend_Registry::get('config');
$assign_vars = array_merge((array)$this->view->getVars(), $vars);
$view_renderer = \DF\Application\Bootstrap::getNewView(FALSE);
$view = $view_renderer->view;
$view->setScriptPath($config->application->resources->layout->commonTemplates);
$view->assign((array)$assign_vars);
return $view->render($target.'.phtml');
}
}

Some files were not shown because too many files have changed in this diff Show More