Beispiel #1
0
 /**
  * Apply View
  * @param Zend_View_Interface $view
  */
 public function setView(Zend_View_Interface $view)
 {
     # Apply
     $this->_App = Bal_App::getPlugin('Bal_Controller_Plugin_App');
     # Set
     $this->view = $view;
     # Done
     return true;
 }
Beispiel #2
0
 /**
  * Initialise
  * @return
  */
 public function init()
 {
     # Prepare
     $App = $this->getHelper('App');
     $App->prepareLog();
     $actionName = $this->getRequest()->getActionName();
     # Layout
     $App->setArea('back');
     # Login
     $App->setOption('logged_in_forward', array(array('action' => 'dashboard'), 'back', true))->setOption('logged_out_forward', array(array('action' => 'login'), 'back', true));
     # Authenticate / redirect to login if need be
     if (in_array($actionName, array(false, 'login', 'index'))) {
         # Within Safe Area, Authenticate WITHOUT Redirects
         $App->authenticate(false, false);
     } else {
         # Outside Safe Area, Authenticate WITH Redirects
         $App->authenticate(true, false);
         # Check Permission Access For Admin Area
         try {
             $User = $App->getUser();
             if (delve($User, 'id') && !$App->hasPermission('admin')) {
                 # Log
                 $Log = Bal_App::getLog();
                 $log_details = array('User' => $User->toArray(false), 'base_url' => $App->getBaseUrl(), 'front_url' => $App->getAreaUrl('front'), 'back_url' => $App->getAreaUrl('back'));
                 $Log->log(array('log-admin-permission', $log_details), Bal_Log::ERR, array('friendly' => true, 'details' => $log_details));
                 # Logout
                 $this->getHelper('redirector')->goToRoute(array('action' => 'login'), 'back', true);
                 //$App->logout(true);
                 // ^ Don't log them out, just redirect them back to the login page
             }
         } catch (Exception $Exception) {
             # Log the Event and Continue
             $Exceptor = new Bal_Exceptor($Exception);
             $Exceptor->log();
         }
     }
     # Navigation
     $App->applyNavigation();
     # Done
     return true;
 }
Beispiel #3
0
 /**
  * Set Message Code: content-subscription
  * @return string
  */
 protected function _templateContentSubscription(&$params, &$data)
 {
     # Prepare
     $Locale = Bal_App::getLocale();
     $View = Bal_App::getView(false);
     $Message = $this;
     # Prepare Urls
     $rootUrl = $View->app()->getRootUrl();
     $baseUrl = $View->app()->getBaseUrl(true);
     # --------------------------
     # Prepare
     $Content = $this->Content;
     # Prepare URL
     $contentUrl = $rootUrl . $View->url()->content($Content)->toString();
     $params['Content_url'] = $contentUrl;
     # Send On
     $send_on = strtotime($Content->published_at);
     $this->send_on = doctrine_timestamp($send_on);
     # Adjust Dates
     $params['Message']['Content']['published_at'] = $Locale->date($params['Message']['Content']['published_at']);
     # --------------------------
     return true;
 }
Beispiel #4
0
 public function subscribeAction()
 {
     # Prepare
     $App = $this->getHelper('App');
     $Request = $this->getRequest();
     $Response = $this->getResponse();
     $Log = Bal_App::getLog();
     # --------------------------
     # Fetch
     $email = fetch_param('subscribe.email', $Request->getParam('email'));
     # Subscribe
     try {
         $Subscriber = new User();
         $Subscriber->email = $email;
         $Subscriber->setTags('newsletter');
         $Subscriber->save();
         # Log
         $log_details = array('Subscriber' => $Subscriber->toArray());
         $Log->log(array('log-subscriber-save', $log_details), Bal_Log::NOTICE, array('friendly' => true, 'class' => 'success', 'details' => $log_details));
     } catch (Exception $Exception) {
         # Log the Event
         $Exceptor = new Bal_Exceptor($Exception);
         $Exceptor->log();
     }
     # --------------------------
     # Done
     return $this->_forward('index');
 }
Beispiel #5
0
    $Bootstrapr = Bootstrapr::getInstance();
}
# Bootstrap
$Bootstrapr->bootstrap('zend-application');
$Application->bootstrap('balphp');
$Application->bootstrap('config');
# Requires
require_once implode(DIRECTORY_SEPARATOR, array(BALPHP_PATH, 'core', 'functions', '_image.funcs.php'));
require_once implode(DIRECTORY_SEPARATOR, array(BALPHP_PATH, 'core', 'functions', '_files.funcs.php'));
# Fetch Paths
$media_path = Bal_App::getConfig('media_path');
$media_url = Bal_App::getConfig('media_url');
$images_path = Bal_App::getConfig('media_images_path');
$images_url = Bal_App::getConfig('media_images_url');
$default_quality = Bal_App::getConfig('media.resize.default.quality', 90);
$resize_supported = Bal_App::getConfig('media.resize.supported', array());
# Fetch
$image_location = ltrim($_GET['image'], DIRECTORY_SEPARATOR);
$height = intval(!empty($_GET['height']) ? $_GET['height'] : (!empty($_GET['h']) ? $_GET['h'] : 0));
$width = intval(!empty($_GET['width']) ? $_GET['width'] : (!empty($_GET['w']) ? $_GET['w'] : 0));
$quality = intval(!empty($_GET['quality']) ? $_GET['quality'] : (!empty($_GET['q']) ? $_GET['q'] : $default_quality));
# Check
function check_resize_support($list, $value)
{
    return !$value || in_array($value, $list);
}
if (!check_resize_support($resize_supported['height'], $height) || !check_resize_support($resize_supported['width'], $width) || !check_resize_support($resize_supported['quality'], $quality)) {
    throw new Exception('An unsupported combination of width, height and quality was specified. Please adjust your configuration.');
}
# Prepare
$image_path = realpath($media_path . DIRECTORY_SEPARATOR . $image_location);
Beispiel #6
0
 /**
  * Render the Content description
  * @param {array|Content} $Content
  * @param array $params
  * @return string rendered content
  */
 public static function renderDescription($Content, array $params = array())
 {
     # Prepare
     $WidgetHelper = Bal_App::getViewHelper('widget');
     $cache = delve($params, 'cache', Bal_App::getConfig('content.cache', false));
     # Fetch
     $description = delve($Content, 'description');
     $description_rendered = delve($Content, 'description_rendered');
     # Prepare Params
     $params['Content'] = $Content;
     # Render Description
     $render = $cache && $description_rendered ? $description_rendered : $WidgetHelper->renderAll(format_to_output($description, 'rich'), $params += array('Content' => $Content));
     # Return render
     return $render;
 }
Beispiel #7
0
<?php

# Load
if (empty($GLOBALS['Application'])) {
    # Bootstrap
    require_once dirname(__FILE__) . '/bootstrapr.php';
    $Bootstrapr = Bootstrapr::getInstance();
    $Bootstrapr->bootstrap('zend-application');
}
# Load
$GLOBALS['Application']->bootstrap('ScriptSetup');
# Prepare
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
# App
Bal_App::getInstance($Application)->setup();
die;