Example #1
0
 /**
  * This function is a temporary fix until the changes are completed to Staple_Route.
  * @param string $action
  * @deprecated
  */
 public function displayPaging($action = NULL)
 {
     //Setup Link Variables
     $linkVars = array_merge($_GET, $this->pageVariables);
     //These two variables would be overridden anyway.
     if (array_key_exists('items', $linkVars)) {
         unset($linkVars['items']);
     }
     if (array_key_exists('page', $linkVars)) {
         unset($linkVars['page']);
     }
     //Set a default link action location if none is submitted.
     if ($action == NULL) {
         $action = Staple_Main::getRoute();
     }
     $buffer = "<div class=\"staple_pager row\">\n<div class=\"staple_pager_pages small-12 medium-11 columns\">\n";
     $pages = $this->getPages();
     if (count($pages) > 1) {
         if ($this->getCurrentPage() == 1) {
             $buffer .= '<a class="button tiny secondary disabled"><i class="fa fa-angle-double-left"></i></a> <a class="button tiny secondary disabled"><i class="fa fa-angle-left"></i></a> ';
         } elseif ($this->getCurrentPage() > 1) {
             $buffer .= '<a class="button tiny" href="' . Staple_Link::get($action, array_merge($linkVars, array('page' => 1))) . '"><i class="fa fa-angle-double-left"></i></a> ';
             $buffer .= '<a class="button tiny" href="' . Staple_Link::get($action, array_merge($linkVars, array('page' => $this->getCurrentPage() - 1))) . '"><i class="fa fa-angle-left"></i></a> ';
         }
         if ($pages[0] != 1) {
             $buffer .= '... ';
         }
         foreach ($pages as $page) {
             if ($this->getCurrentPage() == $page) {
                 $buffer .= '<span class="currentpage button tiny disabled">' . (int) $page . '</span> ';
             } else {
                 $buffer .= '<a class="button tiny secondary" href="' . Staple_Link::get($action, array_merge($linkVars, array('page' => (int) $page))) . '">' . (int) $page . '</a> ';
             }
         }
         if ($pages[count($pages) - 1] != $this->getNumberOfPages()) {
             $buffer .= '... ';
         }
         if ($this->getCurrentPage() == $this->getNumberOfPages()) {
             $buffer .= '<a class="button tiny secondary disabled"><i class="fa fa-angle-right"></i></a> <a class="button tiny secondary disabled"><i class="fa fa-angle-double-right"></i></a>';
         } else {
             $buffer .= '<a class="button tiny" href="' . Staple_Link::get($action, array_merge($linkVars, array('page' => $this->getCurrentPage() + 1))) . '"><i class="fa fa-angle-right"></i></a> ';
             $buffer .= '<a class="button tiny" href="' . Staple_Link::get($action, array_merge($linkVars, array('page' => $this->getNumberOfPages()))) . '"><i class="fa fa-angle-double-right"></i></a>';
         }
     } else {
         $buffer .= '<a class="button tiny secondary disabled"><i class="fa fa-angle-double-left"></i></a> <a class="button tiny secondary disabled"><i class="fa fa-angle-left"></i></a>  <a class="button tiny disabled">1</a> <a class="button tiny secondary disabled"><i class="fa fa-angle-right"></i></a> <a class="button tiny secondary disabled"><i class="fa fa-angle-double-right"></i></a>';
     }
     $buffer .= "</div>\n";
     if ($this->getDisplayItemAmountSelector() === true) {
         $buffer .= "<div class=\"staple_pager_items small-12 medium-1 columns\">\n";
         $buffer .= '<select onChange="window.location=\'' . Staple_Link::get($action, array_merge($linkVars, array('page' => 1))) . "&items='+this.value\">\n";
         foreach ($this->getItemAmountSelections() as $value) {
             $selected = '';
             if ($this->getItemsPerPage() == $value) {
                 $selected = ' selected';
             }
             $buffer .= '<option value="' . $value . '"' . $selected . '>' . $value . "</option>\n";
         }
         $buffer .= "</select>\n";
         $buffer .= "</div>\n";
     }
     $buffer .= "</div>\n";
     return $buffer;
 }
Example #2
0
 public static function GetRouteInfo()
 {
     $blah = Staple_Main::getRoute();
 }
Example #3
0
 /**
  * 
  * Dispatches to the AuthController -> index action. Throws an Exception if the controller does
  * not extend Staple_AuthController.
  * @throws Exception
  */
 private function dispatchAuthController()
 {
     $conString = $this->_settings['controller'];
     $class = substr($conString, 0, strlen($conString) - 10);
     $authCon = Staple_Main::getController($class);
     if (!$authCon instanceof Staple_AuthController) {
         $authCon = new $conString();
     }
     if ($authCon instanceof Staple_AuthController) {
         //Start the Controller
         $authCon->_start();
         //Register Auth Controller with the Front Controller
         Staple_Main::get()->registerController($authCon);
         //Set the view's controller to match the route
         $authCon->view->setController($class);
         //Set the view's action to match the route
         $authCon->view->setView('index');
         //Call the controller action, Send the route requested to the action
         //@todo Add option to customize the controller action
         call_user_func_array(array($authCon, 'index'), array(Staple_Main::getRoute()));
         //Grab the buffer contents from the controller and post it after the header.
         $buffer = ob_get_contents();
         ob_clean();
         //Process the header
         Staple_Main::get()->processHeader();
         if ($authCon->layout instanceof Staple_Layout) {
             $authCon->layout->build($buffer);
         } else {
             echo $buffer;
             $authCon->view->build();
         }
     } else {
         throw new Exception('Fatal Error connecting to Auth Controller', Staple_Error::AUTH_ERROR);
     }
 }