Exemplo n.º 1
0
 /**
  * Computes the pagination
  * 
  */
 public function computePagination()
 {
     $dispatcher = frontDispatcher::getInstance();
     $controllerName = substr($dispatcher->getController(), 0, -10);
     if (!empty($this->itemsPerPage)) {
         $this->pagination = new stdClass();
         $this->pagination->links = array();
         $this->pagination->pages = ceil($this->totalCount / $this->itemsPerPage);
         $offset = 0;
         for ($i = 0; $i < $this->pagination->pages; $i++) {
             $page = new stdClass();
             $page->title = $i + 1;
             $page->offset = $offset;
             $page->link = "/?controller={$controllerName}&action=list&offset={$offset}";
             // render previous link
             if ($offset - $this->itemsPerPage >= 0) {
                 $previous = $offset - $this->itemsPerPage;
                 $page->previous = "/?controller={$controllerName}&action=list&offset={$previous}";
             }
             // render next link
             if ($offset + $this->itemsPerPage < $this->pagination->pages * $this->itemsPerPage) {
                 $next = $offset + $this->itemsPerPage;
                 $page->next = "/?controller={$controllerName}&action=list&offset={$next}";
             }
             $this->pagination->links[$offset] = $page;
             $offset += $this->itemsPerPage;
         }
     }
 }
Exemplo n.º 2
0
{
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
//set_error_handler("exception_error_handler");
require_once dirname(__FILE__) . '/../conf/configuration_front.php';
require_once dirname(__FILE__) . '/../core/autoloadManager.php';
autoloadManager::setSaveFile(dirname(__FILE__) . '/../tmp/front.php');
autoloadManager::addFolder(CORE);
autoloadManager::addFolder(BUSINESS);
spl_autoload_register('autoloadManager::loadClass');
$_REQUEST['controller'] = Toolbox::getArrayParameter($_REQUEST, 'controller', 'Feed');
$_REQUEST['action'] = Toolbox::getArrayParameter($_REQUEST, 'action', 'index');
// jquery based ajax application
$from = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH'] ? 'ajax' : 'http';
try {
    $front = frontDispatcher::getInstance();
    // Init Session
    // Save header for ajax call, so that we can either root or return false for ajax calls
    $actions = AccessHelper::getActions();
    // authenticate
    $AuthManager = new AuthManager($actions);
    $AuthManager->authenticate($front, '/?controller=Feed&action=index', $from);
    // Inject Dynamically changing objects
    $Container = ContainerFactory::get('front');
    $Container['Access'] = $actions;
    $Container['AuthManager'] = $AuthManager;
    $Container['Request'] = $_REQUEST;
    $Container['Session'] = SessionManager::getSession('front');
    // Route
    $front->route($Container);
} catch (Exception $e) {