예제 #1
0
 public static function init()
 {
     if (self::$hasinit) {
         return false;
     }
     // Load configuration.
     self::$config = new Config('realms.ini');
     if (!self::$config->get('general', 'service_requests')) {
         // Service unavaliable. :(
         http_response_code(503);
         // 503 Service Unavaliable.
         echo 'service unavaliable';
         exit;
         // terminate here.
     }
     // Load request registry
     self::$requestRegistry = new RequestRegistry();
     // create request registry instance
     // Dynamically load request handlers.
     $handler_files = scandir('inc/Requests');
     foreach ($handler_files as $handler_file) {
         if ($handler_file == '.' || $handler_file == '..') {
             continue;
         }
         // skip ghost files
         // Load PHP file
         require 'inc/Requests/' . $handler_file;
         // Register handler
         $classname = pathinfo($handler_file, PATHINFO_FILENAME);
         self::$requestRegistry->register(new $classname());
     }
     // Realms init finish.
     self::$hasinit = true;
     return true;
 }
예제 #2
0
 static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #3
0
 public function getFeaturedImage()
 {
     if (!isset($this->featured_image)) {
         $this->featured_image = RequestRegistry::getImageMapper()->findFeaturedImageForAlbum($this);
     }
     if ($this->featured_image == null) {
         return $this->getFirstImage();
     }
     return $this->featured_image;
 }
예제 #4
0
 function calendar_column()
 {
     $events = RequestRegistry::getNewsEventMapper()->findEventsForHomepage();
     $column = "\n\t\t\t<div id='events-column'>\n\t\t\t<h3 class='cufoned-headers'>Calendar</h3>";
     foreach ($events as $story) {
         $column .= "<p>{$story->getTitle()} - {$story->getIntroduction(10)}...&nbsp;<a href='{$this->url($story)}' class='morelink'>more</a></p>";
     }
     $column .= "\n\t\t\t<div class='rss-box'>\n\t\t\t\t<a href=''><img src='img/icons/big-rss-icon.jpg' /></a>\n\t\t\t\t<p class='rss-box-text'><a href=''>Subscribe</a> to receive updates<br /><a href=''>What is RSS?</a></p>\n\t\t\t</div>\n\t\t\t</div><!-- /news-column -->";
     return $column;
 }
예제 #5
0
 function execute(CommandContext $context)
 {
     $pageMapper = RequestRegistry::getPageMapper();
     $page = $context->get('page');
     $children = $page->getChildren();
     foreach ($children as $child) {
         $pageMapper->delete($child);
     }
     $pageMapper->delete($page);
     return;
 }
예제 #6
0
 function execute(CommandContext $context)
 {
     $albumMapper = RequestRegistry::getAlbumMapper();
     $imageMapper = RequestRegistry::getImageMapper();
     $album = $context->get('album');
     $images = $album->getImages();
     foreach ($images as $image) {
         $imageMapper->delete($image);
     }
     $albumMapper->delete($album);
     return;
 }
예제 #7
0
 function sidebar()
 {
     $sidebar = '';
     $page_mapper = RequestRegistry::getPageMapper();
     $suggested_links = $page_mapper->findSuggestedLinksForPage($this->content->getId());
     if (count($suggested_links) == 0) {
         return '';
     }
     $sidebar = "<div id='sidebar'>\n";
     $sidebar .= "<div class='sidebar-links-title'>\n" . "<p>Suggested Links</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
     foreach ($suggested_links as $link) {
         $sidebar .= "<li><a href='{$link['href']}'>{$link['anchor_text']}</a></li>";
     }
     $sidebar .= "</ul>\n</div>\n";
     return $sidebar;
 }
예제 #8
0
 function execute(CommandContext $context)
 {
     $pageMapper = RequestRegistry::getPageMapper();
     $page = null;
     if ($context->get('page-id') != null) {
         $page = $pageMapper->find($context->get('page-id'));
     }
     if ($context->get('page-slug') != null) {
         $page = $pageMapper->findBySlug($context->get('page-slug'));
     }
     if ($page === null) {
         die("need either 'page-slug' or 'page-id' in the command context please!");
     }
     $context->addParam('page', $page);
     return;
 }
예제 #9
0
 function execute(CommandContext $context)
 {
     $albumMapper = RequestRegistry::getAlbumMapper();
     $album = null;
     if ($context->get('album-id') != null) {
         $album = $albumMapper->find($context->get('album-id'));
     }
     if ($context->get('album-slug') != null) {
         $album = $albumMapper->findBySlug($context->get('album-slug'));
     }
     if ($album === null) {
         $error = "Album Not Found, Check that you've sent 'album-id' or 'album-slug' in the command context, and that it's a valid slug/id";
         throw new Exception($error);
     }
     $context->addParam('album', $album);
     return;
 }
 function gallery_grid()
 {
     $albums = RequestRegistry::getAlbumMapper()->findAllLiveAlbumsForPeriod($this->content['period']);
     $cell_counter = 0;
     $grid = "<table id='gallery-grid'>\n";
     $grid .= "<tr>\n";
     foreach ($albums as $album) {
         if (!$album->hasImages()) {
             continue;
         }
         $image = $album->getFeaturedImage();
         $cell_counter++;
         $grid .= "<td><a href='{$this->url($album)}'><img src='{$image->getSource()}' /></a><br /><span class='gallery-caption'>{$album->getTitle()}</span></td>\n";
         if ($cell_counter % 3 == 0) {
             $grid .= "\n</tr>\n<tr>\n";
         }
     }
     $grid .= "</tr>\n";
     $grid .= "</table>";
     return $grid;
 }
예제 #11
0
 /**
  * Generates sidebar for a given page object
  *
  * Displays child level pages in a list, if there are any, else nothing
  * TODO Add Approrpiate Image as per funcspec
  * TODO Consider showing sibling pages instead of child
  */
 public function sidebar()
 {
     $children = $this->content->getLiveChildren();
     if (($image = $this->content->getImage()) == null) {
         $image_mapper = RequestRegistry::getImageMapper();
         $pcs_code = SessionRegistry::getStyleCode();
         $image = $image_mapper->findRandomLiveImageForPcs($pcs_code);
     }
     $sidebar = "<div id='sidebar'>\n";
     if (count($children) > 0) {
         $sidebar .= "<div class='sidebar-links-title'>\n" . "<p>{$this->content->getTitle()}</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
         foreach ($children as $child) {
             $sidebar .= "<li><a href='{$this->url($child)}'>{$child->getTitle()}</a></li>";
         }
         $sidebar .= "</ul>\n";
     }
     if ($image != null) {
         $sidebar .= "<img src='{$image->getSource()}' id='post-image' />\n";
     }
     $sidebar .= "</div>\n";
     return $sidebar;
 }
예제 #12
0
 function sidebar()
 {
     $story = $this->content;
     //$this_months_news = CommandRunner::run('get-live-news-for-month', array('month' => date('n')))->get('news');
     $this_months_news = RequestRegistry::getNewsEventMapper()->findNewsForIndex();
     //change these out later if required
     $this_month_list = '';
     if (count($this_months_news) > 0) {
         $this_month_list = "<div class='sidebar-links-title'>\n" . "<p>Recent News</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
         foreach ($this_months_news as $news_story) {
             $this_story_arrow = $news_story == $story ? '> ' : '';
             $title = $this_story_arrow . $news_story->getTitle();
             $this_month_list .= "<li>" . "<a href='{$this->url($news_story)}'>{$title}</a>" . "</li>\n";
         }
         $this_month_list .= "</ul>\n";
     }
     $this_year = date('Y');
     $last_year = $this_year - 1;
     $two_years_ago = $last_year - 1;
     $this_month = date('F');
     $last_month = date('F', mktime(0, 0, 0, date('n') - 1, date('j'), date('Y')));
     $two_months_ago = date('F', mktime(0, 0, 0, date('n') - 2, date('j'), date('Y')));
     $archive_list = "<div class='sidebar-links-title'>\n" . "<p>News Archive</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
     foreach (array($this_month, $last_month, $two_months_ago, $this_year, $last_year, $two_years_ago) as $time) {
         $lower_time = strtolower($time);
         if (RequestRegistry::getNewsEventMapper()->newsExistsForPeriod($lower_time)) {
             $content = array('type' => 'news/archive', 'period' => $lower_time);
             $archive_list .= "<li><a href='{$this->url($content)}'>{$time}</a></li>\n";
         }
     }
     $archive_list .= "</ul>\n";
     //$archive_list .= "</div>\n";
     $sidebar = "<div id='sidebar'>\n";
     $sidebar .= $this_month_list . $archive_list;
     $sidebar .= "</div>";
     return $sidebar;
 }
예제 #13
0
 function sidebar()
 {
     $event = $this->content;
     $this_months_events = RequestRegistry::getNewsEventMapper()->findEventsForIndex();
     //change these out later if required
     $this_month_list = '';
     if (count($this_months_events) > 0) {
         $this_month_list = "<div class='sidebar-links-title'>\n" . "<p>Upcoming Events</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
         foreach ($this_months_events as $news_event) {
             $this_event_arrow = $news_event == $event ? '> ' : '';
             $title = $this_event_arrow . $news_event->getTitle();
             $this_month_list .= "<li>" . "<a href='{$this->url($news_event)}'>{$title}</a>" . "</li>\n";
         }
         $this_month_list .= "</ul>\n";
     }
     $this_year = date('Y');
     $next_year = $this_year + 1;
     $two_years_later = $next_year + 1;
     $this_month = date('F');
     $next_month = date('F', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
     $two_months_later = date('F', mktime(0, 0, 0, date('n') + 2, date('j'), date('Y')));
     $archive_list = "<div class='sidebar-links-title'>\n" . "<p>Events Calendar</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
     foreach (array($this_month, $next_month, $two_months_later, $this_year, $next_year, $two_years_later) as $time) {
         $lower_time = strtolower($time);
         //echo $lower_time;
         if (RequestRegistry::getNewsEventMapper()->eventsExistForPeriod($lower_time)) {
             $content = array('type' => 'events/calendar', 'period' => $lower_time);
             $archive_list .= "<li><a href='{$this->url($content)}'>{$time}</a></li>\n";
         }
     }
     $archive_list .= "</ul>\n";
     //$archive_list .= "</div>\n";
     $sidebar = "<div id='sidebar'>\n";
     $sidebar .= $this_month_list . $archive_list;
     $sidebar .= "</div>";
     return $sidebar;
 }
예제 #14
0
 function sidebar()
 {
     $album = $this->content;
     //Archive Albums Links List
     $this_year = date('Y');
     $last_year = $this_year - 1;
     $year_before_last = $last_year - 1;
     $this_month = date('F');
     $last_month = date('F', mktime(0, 0, 0, date('n') - 1, 1, date('Y')));
     $month_before_last = date('F', mktime(0, 0, 0, date('n') - 2, 1, date('Y')));
     $archive_array = array($this_month, $last_month, $month_before_last, $this_year, $last_year, $year_before_last);
     $archive_section = "<div class='sidebar-links-title'>\n" . "<p>Gallery Archive</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
     foreach ($archive_array as $period) {
         $lower_period = strtolower($period);
         if (!RequestRegistry::getAlbumMapper()->albumsExistForPeriod($lower_period)) {
             continue;
         }
         $content = array('type' => 'gallery/archive', 'period' => $lower_period);
         $archive_section .= "<li>" . "<a href='{$this->url($content)}'>{$period}</a></li>\n";
     }
     $archive_section .= "</ul>\n";
     //Recent Albums Link List
     $five_recent_albums = RequestRegistry::getAlbumMapper()->findFiveMostRecentLiveAlbums();
     $recent_section = "<div class='sidebar-links-title'>\n" . "<p>Recent Galleries</p>\n" . "</div>\n" . "<ul class='sidebar-links-list'>\n";
     foreach ($five_recent_albums as $album) {
         if (!$album->hasImages()) {
             continue;
         }
         $recent_section .= "<li><a href='{$this->url($album)}'>{$album->getTitle()}</a></li>\n";
     }
     $recent_section .= "</ul>\n";
     $sidebar = "<div id='sidebar'>\n";
     $sidebar .= $recent_section . $archive_section;
     $sidebar .= "</div>\n";
     return $sidebar;
 }
예제 #15
0
 function execute(CommandContext $context)
 {
     $image = $context->get('image');
     $imageMapper = RequestRegistry::getImageMapper();
     $imageMapper->insert($image);
 }
예제 #16
0
<?php

// WATCH OUT!
// Apart from the runs to the database via commands, for the most part this is a copy-paste hack-job of list-pages.php
// You might find a few variables/functions that say 'news' when they mean 'event' here, but function/variable names are all the same to the user, and we have deadlines!
include '../init.php';
//setup some helpers
include 'inc/fckeditor/fckeditor.php';
$fh = RequestRegistry::getFormHelper();
//if we're getting an event id out of $_GET['newsevent-id'], set $newsevent to that
if (isset($_GET['newsevent-id'])) {
    $newsevent = CommandRunner::run('get-news-event')->get('newsevent');
}
//if we're saving an event, send it to the database and set it as the event to show in the form
if (isset($_POST['save-button'])) {
    $parameters = array('newsevent-id' => $_POST['id']);
    $newsevent = CommandRunner::run('get-news-event', $parameters)->get('newsevent');
    $newsevent->setContentType(NewsEvent::TYPE_NEWS);
    $newsevent->setDateDisplayed($fh->timestampFromPost());
    $newsevent->setTitle($_POST['title']);
    $newsevent->setKeywords($_POST['meta-keywords']);
    $newsevent->setDescription($_POST['meta-description']);
    $newsevent->setText($_POST['content']);
    $newsevent->setStatus($_POST['status']);
    CommandRunner::run('update-news-event', array('newsevent' => $newsevent));
}
//if not then we'll take either the most forthcoming event (the one nearest in the future)
//or we'll take the most recent if we can't find one, remember this is deciding what to display initially in the form
if (!isset($newsevent)) {
    $newsevent = CommandRunner::run('get-soonest-event')->get('newsevent');
    if ($newsevent == null) {
예제 #17
0
 function execute(CommandContext $context)
 {
     $newsevent = RequestRegistry::getNewsEventMapper()->find($context->get('newsevent-id'));
     $context->addParam('newsevent', $newsevent);
 }
 function execute(CommandContext $context)
 {
     $year = $context->get('year') === null ? time('Y') : $context->get('year');
     $context->addParam('events', RequestRegistry::getNewsEventMapper()->findEventsForYear($year));
 }
 function execute(CommandContext $context)
 {
     $count = $context->get('count') === null ? 5 : $context->get('count');
     $context->addParam('events', RequestRegistry::getNewsEventMapper()->findRecentlyModifiedEvents($count));
 }
예제 #20
0
<?php

include 'init.php';
$slug = mysql_escape_string($_GET['slug']);
$news = RequestRegistry::getNewsEventMapper()->findBySlug($slug);
$view = RequestRegistry::getViewHelper($news);
?>

<?php 
include 'inc/doctype.php';
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href='/css/shared.css' />
<link rel='stylesheet' type='text/css' href='/css/pcs-default.css' />
<?php 
echo $view->pcs_stylesheet();
?>
<script type='text/javascript' src='/js/jquery-1.3.2.min.js'></script>
<script type='text/javascript' src='/js/jquery.dimensions.js'></script>
<script type='text/javascript' src='/js/jquery.tooltip.min.js'></script>
<script type='text/javascript' src='/js/font/cufon-yui.js'></script>
<script type='text/javascript' src='/js/font/Sanuk-Black_500.font.js'></script>
<script type='text/javascript' src='/js/font/Sanuk-Regular_500.font.js'></script>
<script type="text/javascript">
		Cufon.replace('h1', { fontFamily: 'Sanuk-Black'});
		Cufon.replace('li.page-nav-link>a', { fontFamily: 'Sanuk-Black'});
		Cufon.replace('li.nav-link>a', { fontFamily: 'Sanuk-Black'});
                Cufon.replace('li ul li', { fontFamily: 'Sanuk-Regular'});
                Cufon.replace("#tooltip *", { fontFamily: 'Sanuk-Black'});
                Cufon.replace("body div#main div#sidebar div.sidebar-links-title p", { fontFamily: 'Sanuk-Black'});
예제 #21
0
<?php

include 'init.php';
$query = mysql_escape_string($_REQUEST['query']);
$view = RequestRegistry::getViewHelper(array('type' => 'search'));
?>

<?php 
include 'inc/doctype.php';
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href='/css/shared.css' />
<link rel='stylesheet' type='text/css' href='/css/pcs-default.css' />
<?php 
echo $view->pcs_stylesheet();
?>
<script type='text/javascript' src='/js/jquery-1.3.2.min.js'></script>
<script type='text/javascript' src='/js/jquery.dimensions.js'></script>
<script type='text/javascript' src='/js/jquery.tooltip.min.js'></script>
<script type='text/javascript' src='/js/font/cufon-yui.js'></script>
<script type='text/javascript' src='/js/font/Sanuk-Black_500.font.js'></script>
<script type='text/javascript' src='/js/font/Sanuk-Regular_500.font.js'></script>
<script type="text/javascript">
		Cufon.replace('h1', { fontFamily: 'Sanuk-Black'});
		Cufon.replace('li.page-nav-link>a', { fontFamily: 'Sanuk-Black'});
		Cufon.replace('li.nav-link>a', { fontFamily: 'Sanuk-Black'});
                Cufon.replace('li ul li', { fontFamily: 'Sanuk-Regular'});
                Cufon.replace("#tooltip *", { fontFamily: 'Sanuk-Black'});
                Cufon.replace("body div#main div#sidebar div.sidebar-links-title p", { fontFamily: 'Sanuk-Black'});
                
 function execute(CommandContext $context)
 {
     $context->addParam('newsevent', RequestRegistry::getNewsEventMapper()->findMostRecentNews());
 }
 function execute(CommandContext $context)
 {
     $month = $context->get('month') === null ? date('n') : $context->get('month');
     $year = $context->get('year') === null ? date('Y') : $context->get('year');
     $context->addParam('events', RequestRegistry::getNewsEventMapper()->findAllEventsForMonth($month, $year));
 }
예제 #24
0
<?php

include '../init.php';
$album = CommandRunner::run('get-album')->get('album');
if (isset($_POST['submit'])) {
    $image_mapper = RequestRegistry::getImageMapper();
    $image = new Image();
    $image->setAlbumId($_POST['album-id']);
    $image_mapper->insert($image);
    $filename = $image->getId() . '.jpg';
    //$target_path = '../img/photos/' . $filename; //*nix Mode
    $target_path = "..\\img\\photos\\" . $filename;
    //Windows Mode
    //var_dump($_FILES);
    //echo $target_path;
    $success = move_uploaded_file($_FILES['uploaded-file']['tmp_name'], $target_path);
    if ($success) {
        $image->setFileName($filename);
        $image_mapper->update($image);
        header('Location: /admin/gallery.php?album-id=' . $_POST['album-id']);
    } else {
        $error_message = "There was a problem with the upload, please try again.";
        $image_mapper->delete($image);
    }
}
include '../inc/doctype.php';
?>
<html>
        <head>
                <title>Immanuel College Admin Panel</title>
                <link rel='stylesheet' type='text/css' href='css/style.css' />
예제 #25
0
 * Unfortunately this was my first time putting together an ajax heavy
 * admin panel, so this interface isn't partcularly clean.
 *
 * The code here simply accepts AJAX calls via POST, translates the values
 * into objects if required, runs a command based on whats specified in $_POST['action']
 * and then sends an object back in JSON if it's relevant to the command (rare).
 */
include '../../init.php';
//convert json objects to php objects, currently only supports one object
if (array_key_exists('obj', $_POST)) {
    $class = $_POST['type'];
    $_POST['type'] = isset($_POST['newseventtype']) ? $_POST['newseventtype'] : $_POST['type'];
    //to get around the javascript 'status' reserved word
    $_POST['status'] = isset($_POST['stat']) ? $_POST['stat'] : Content::STATUS_PENDING;
    if (isset($_POST['id'])) {
        $mapper = RequestRegistry::getMapper($class);
        $object = $mapper->find($_POST['id']);
    } else {
        $object = new $class();
    }
    $object->loadFromArray($_POST);
    $_POST[$class] = $object;
}
$context = CommandRunner::run($_POST['action'], $_POST);
$return = $context->getParamArray();
foreach ($return as $key => $value) {
    if ($value instanceof Content) {
        $return[$key] = $value->toArray();
    }
}
echo json_encode($return);
예제 #26
0
 /**
  * Returns a string representing a html select for events
  *
  * Displays all events ordered by modify date
  * Optionally, you can pass in an id to say which event is pre-selected
  *
  * @param $selectedId int (optional) the id of the preselected event
  */
 public function getEventsSelect($selectedId = null)
 {
     if (!isset($this->events_select)) {
         $news = RequestRegistry::getNewsEventMapper()->findAllEventsByModifyDate();
         $news_select = "<select id='event-select'>\n";
         $news_select .= "<option value='0'>No Event Selected</option>\n";
         foreach ($news as $story) {
             $selected = $selectedId !== null && $selectedId == $story->getId() ? ' selected' : '';
             $news_select .= "<option value='{$story->getId()}'{$selected}>" . $story->getTitle() . "</option>";
         }
         $news_select .= "</select>\n";
         $this->events_select = $news_select;
     }
     return $this->events_select;
 }
예제 #27
0
 public function execute(CommandContext $context)
 {
     $imageMapper = RequestRegistry::getImageMapper();
     $imageMapper->update($context->get('image'));
     return;
 }
예제 #28
0
<?php

include 'init.php';
$period = $_GET['period'];
$news = CommandRunner::run('get-news-for-archive')->get('news');
$view = RequestRegistry::getViewHelper(array('type' => 'news/archive'));
?>

<?php 
include 'inc/doctype.php';
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href='/css/shared.css' />
<link rel='stylesheet' type='text/css' href='/css/pcs-default.css' />
<?php 
echo $view->pcs_stylesheet();
?>
<script type='text/javascript' src='/js/jquery-1.3.2.min.js'></script>
<script type='text/javascript' src='/js/jquery.dimensions.js'></script>
<script type='text/javascript' src='/js/jquery.tooltip.min.js'></script>
<script type='text/javascript' src='/js/font/cufon-yui.js'></script>
<script type='text/javascript' src='/js/font/Sanuk-Black_500.font.js'></script>
<script type='text/javascript' src='/js/font/Sanuk-Regular_500.font.js'></script>
<script type="text/javascript">
		Cufon.replace('h1', { fontFamily: 'Sanuk-Black'});
		Cufon.replace('li.page-nav-link>a', { fontFamily: 'Sanuk-Black'});
		Cufon.replace('li.nav-link>a', { fontFamily: 'Sanuk-Black'});
                Cufon.replace('li ul li', { fontFamily: 'Sanuk-Regular'});
                Cufon.replace("#tooltip *", { fontFamily: 'Sanuk-Black'});
                Cufon.replace("body div#main div#sidebar div.sidebar-links-title p", { fontFamily: 'Sanuk-Black'});
예제 #29
0
 function execute(CommandContext $context)
 {
     $album = $context->get('album');
     $albumMapper = RequestRegistry::getAlbumMapper();
     $albumMapper->insert($album);
 }
예제 #30
0
 function execute(CommandContext $context)
 {
     $news = RequestRegistry::getNewsEventMapper()->findAllRecentNews();
     $context->addParam('news', $news);
 }