示例#1
0
 static function Output($key = 'default', $layout = 'default')
 {
     $View = new AppView();
     if (array_key_exists($key, self::$errors)) {
         $output = '';
         foreach (self::$errors[$key] as $index => $message) {
             $View->assign('key', $key);
             $View->assign('index', $index);
             $View->assign('message', $message);
             $output .= $View->fetch(Globe::GetTemplate($layout, 'errors', Url::$data['type'])) . "\n";
         }
         unset(self::$errors[$key]);
         return $output;
     } else {
         return false;
     }
 }
示例#2
0
文件: core.php 项目: nemoDreamer/endo
$Controller->call_afterFilter();
// --------------------------------------------------
// Debug
// --------------------------------------------------
$debug_dump = '';
$debug_dump .= d_pre('Url::$data', false) . d_arr(Url::$data, false);
$debug_dump .= d_pre('$Controller->LoggedIn', false) . d_arr($Controller->LoggedIn, false);
$debug_dump .= d_pre('$Controller->filter', false) . d_arr($Controller->filter, false);
// $debug_dump .= d_pre('Error::$errors', false).d_arr(Error::$errors, false);
// $debug_dump .= d_pre('$_SESSION', false).d_arr($_SESSION, false);
// $debug_dump .= d_pre('$_SERVER', false).d_arr($_SERVER, false);
// $debug_dump .= d_pre('CONSTANTS', false).d_arr(get_constants(), false);
// --------------------------------------------------
// Output
// --------------------------------------------------
// create View
$View = new AppView();
// assign standards
$View->assign(array('id' => $Controller->name . '_' . $Controller->action, 'url' => Url::$data, 'has_errors' => Error::HasErrors(), 'debug_dump' => $debug_dump));
// assign content if no fatal
$View->assign('content', !Error::IsFatal() || DEBUG != 0 ? $Controller->output : null);
// assign case-specific
$View->assign(Globe::$variables_for_layout);
// remove junk from xml/json/...
if ($Controller->type != DEFAULT_REQUEST_TYPE) {
    $View->debugging = false;
    $View->error_reporting = false;
}
// echo
$View->display(Globe::GetTemplate($Controller->layout, 'layouts', $Controller->type));
// d_pre("execution time:".(microtime(true) - $time));
示例#3
0
 public function display($cachable = false, $urlparams = false)
 {
     $search_params = $this->search_params;
     $items = $this->items;
     // Get site params for the current application
     $params = $this->application->getParams('site');
     if (count($items) == 1 && $search_params->get('redirect_if_one')) {
         $item = array_pop($items);
         $link = JRoute::_('index.php?option=com_zoo&task=item&item_id=' . $item->id, false);
         JFactory::getApplication()->redirect($link);
     }
     // Pepare the view
     $view = new AppView(array('name' => 'category'));
     $layout = strlen($search_params->get('page_layout')) ? $search_params->get('page_layout') : 'search';
     // JSON support
     if (JRequest::getVar('format', '') == 'json') {
         $layout = 'json';
     }
     $item_layout = $search_params->find('zoofilter.item_layout', $search_params->get('layout'));
     $view->addTemplatePath($this->app->path->path('zoofilter:layouts'));
     $view->addTemplatePath($this->application->getTemplate()->getPath());
     // override by App
     $view->setLayout($layout);
     // Add the necessary variables for the view
     $view->app = $this->app;
     $view->items = $items;
     $view->application = $this->application;
     $view->item_layout = $item_layout;
     $item_ids = array();
     foreach ($items as $item) {
         $item_ids[] = $item->id;
     }
     // get item pagination
     $items_per_page = $search_params->get('items_per_page');
     $page = JRequest::getVar('page', 1);
     $view->pagination = $this->app->pagination->create($this->itemsTotal, $page, $items_per_page, 'page', 'app');
     $view->pagination->setShowAll($items_per_page == 0);
     $uri = JURI::getInstance();
     $uri->setVar('page', null);
     $view->total = $this->itemsTotal;
     $view->pagination_link = $uri->toString();
     // set template and params
     $view->assign('template', $this->application->getTemplate());
     $view->params = $params;
     $view->assign('search_params', $search_params);
     // set renderer
     $uri = JURI::getInstance();
     $permalink = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_('index.php?option=com_zoo&controller=zoofilter&task=dosearch&app_id=' . $this->application->id . '&search_id=' . $this->search_id);
     $view->show_permalink = $search_params->get('show_permalink');
     $view->permalink = $permalink;
     $view->app_id = $this->application->id;
     $view->search_id = $this->search_id;
     $view->show_title = $search_params->get('show_title');
     $view->show_ordering = $search_params->get('show_ordering');
     $view->columns = $search_params->get('columns');
     $view->page_title = $search_params->get('page_title');
     $view->renderer = $this->app->renderer->create('item');
     $view->renderer->addPath(array($this->app->path->path('component.site:'), $this->application->getTemplate()->getPath(), $this->app->path->path('zoofilter:')));
     // Add ordering
     $this->app->path->register($this->app->path->path('zoofilter:ordering/renderer'), 'renderer');
     $order_renderer = $this->app->renderer->create('ordering')->addPath(array($this->app->path->path('zoofilter:ordering')));
     $elements_layout = $search_params->get('ordering_layout');
     $type = $this->application->getType($search_params->get('type'));
     $order_elements = $order_renderer->render('item.' . $elements_layout, compact('type'));
     $view->assign('order_elements', $order_elements);
     // display view
     $view->display();
 }