Exemplo n.º 1
0
 /**
  * Render comments and respond form html.
  *
  * @param AppView $view The view the comments are rendered on
  * @param Item $item The item whos comments are rendered
  *
  * @return string The html output
  *
  * @since 2.0
  */
 public function renderComments($view, $item)
 {
     if ($item->getApplication()->isCommentsEnabled()) {
         // get application params
         $params = $this->app->parameter->create($item->getApplication()->getParams()->get('global.comments.'));
         if ($params->get('twitter_enable') && !function_exists('curl_init')) {
             $this->app->error->raiseWarning(500, JText::_('To use Twitter, CURL needs to be enabled in your php settings.'));
             $params->set('twitter_enable', false);
         }
         // get active author
         $active_author = $this->activeAuthor();
         // get comment content from session
         $content = $this->app->system->session->get('com_zoo.comment.content');
         $params->set('content', $content);
         // get comments and build tree
         $approved = $item->canManageComments() ? Comment::STATE_UNAPPROVED : Comment::STATE_APPROVED;
         $comments = $item->getCommentTree($approved);
         // build captcha
         $captcha = false;
         if ($plugin = $params->get('captcha', false) and (!$params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) {
             $captcha = JCaptcha::getInstance($plugin);
         }
         if ($item->isCommentsEnabled() || count($comments) - 1) {
             // create comments html
             return $view->partial('comments', compact('item', 'active_author', 'comments', 'params', 'captcha'));
         }
     }
     return null;
 }
Exemplo n.º 2
0
 public function execute()
 {
     if ($this->argument === NULL) {
         $this->controller->{$this->action}();
     } else {
         $this->controller->{$this->action}($this->argument);
     }
     // TODO: check for non-default template
     $template = DEFAULT_TEMPLATE;
     $view = new AppView($this->page, $template);
     $view->show_view_with_context_variables($this->controller->getModelViewContext());
 }
Exemplo n.º 3
0
 public function __construct(&$controller)
 {
     parent::__construct($controller);
     if ($controller->html) {
         throw new AppViewException('wrong render type');
     }
 }
Exemplo n.º 4
0
 /**
  * Test the view paths listed in config constant APP_TEST_VIEW_PATH_LIST
  * by validating the HTML as well-formatted and legal XHTML.
  */
 public function view_paths_test()
 {
     foreach ($this->view_paths as $view_path) {
         $html = uri_get_contents(AppView::uri($view_path));
         $errors = $this->app->xhtml_errors($html);
         $this->should("validate \"{$view_path}\" as XHTML", !$errors, $errors);
     }
 }
Exemplo n.º 5
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;
     }
 }
 /**
  * Render form content
  * @return bool|string
  */
 public function __toString()
 {
     $this->init();
     $this->view->action = $this->_action;
     $this->view->method = $this->_method;
     $this->view->form = $this;
     return $this->view->render();
 }
Exemplo n.º 7
0
 public function __construct(&$controller)
 {
     parent::__construct($controller);
     if (!$controller->html) {
         throw new AppViewException('Unknow Return Format');
     }
     require "Smarty.class.php";
     $this->smarty = new Smarty();
 }
 /**
  * @param $config array
  */
 public static function run($config)
 {
     static::$_config = $config;
     // initialize error handling
     register_shutdown_function(array('App', 'onFatalError'));
     set_exception_handler(array('App', 'onException'));
     set_error_handler(array('App', 'onError'));
     $response = App::response();
     // init response
     $response->enableBuffering();
     // start output buffering
     // initialize class Autoloader
     $autoloader = static::autoloader();
     // initialize Router
     $router = static::router();
     $parsedUrl = $router->parseRequestUrl(App::request()->getUrl());
     $controllerClassName = $parsedUrl['controller'];
     $actionMethodName = $parsedUrl['action'];
     $parameters = $parsedUrl['parameters'];
     if (!$autoloader->classDefined($controllerClassName)) {
         trigger_error('Controller "' . $controllerClassName . '" not found');
         App::response()->sendNotFoundAndExit();
     }
     /** @var $controller AppController */
     $controller = new $controllerClassName();
     $controller->setAction($actionMethodName);
     $controller->setParameters($parameters);
     // get response from action
     $actionContent = $controller->run();
     // get layout from controller
     $layout = $controller->getLayout();
     if ($layout) {
         // if layout not disabled ( @see AppController::disableLayout() )
         $layoutView = new AppView('layouts/' . $layout);
         $layoutView->title = static::$_config['applicationName'];
         $layoutView->content = $actionContent;
         // insert action response into page layout
         // render page
         echo $layoutView->render();
     }
     // send response to client
     App::response()->sendContent();
 }
Exemplo n.º 9
0
 public function show()
 {
     include_once "views/app.php";
     $app = new App();
     $result = $app->show();
     $this->user = unserialize($_SESSION["user"]);
     $this->vars = array();
     $this->vars["user"] = $this->user;
     $this->vars["result"] = $result;
     AppView::show($this->vars);
 }
 /**
  * Render results of action
  * @param string $viewPath
  */
 protected function render($viewPath = '')
 {
     // (!) Not render here, just prepare
     $this->_doRender = true;
     if ('' == $viewPath) {
         $controllerViewPath = App::uncamelize(preg_replace('/Controller$/', '', get_class($this)));
         $actionViewPath = App::uncamelize(preg_replace('/Action$/', '', $this->_actionMethod));
         $viewPath = $controllerViewPath . DIRECTORY_SEPARATOR . $actionViewPath;
     }
     $this->view->setViewPath($viewPath);
 }
Exemplo n.º 11
0
 /**
  * Return the object value for an object name (e.g. "user->name")
  *
  * @param String $name the object name and property (e.g. "user->name")
  * @return String the object value or NULL if it was not found
  */
 public static function object_value_for($name)
 {
     $value = NULL;
     if (strstr($name, Symbol::ARROW)) {
         list($object_name, $field) = explode(Symbol::ARROW, $name);
         $object = AppView::get($object_name);
         $value = h($object->{$field});
     }
     return $value;
 }
Exemplo n.º 12
0
| ,_)| |__  (_)   ___ | |/')    __  | ,_)
| |  |  _ `\| | /'___)| , <   /'__`\| |  
| |_ | | | || |( (___ | |\`\ (  ___/| |_ 
`\__)(_) (_)(_)`\____)(_) (_)`\____)`\__)

** Thicket was designed and built by Gyan Prayaga (gyan.biz) as a
** robust, compatible, and easy-to-deploy MVC framework for forums, 
** voting sites, personal bookmarking sites, and more. 
**
** Enjoy! 
**
*/
include_once 'includes/engine/config.php';
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$path = preg_replace('/\\.[^.\\s]{3,4}$/', '', $root . $path);
$path = str_replace(url, '', $path);
if (!$path) {
    $path = '/';
}
include './includes/engine/functions.php';
class AppView
{
    function execute()
    {
        global $path;
        construct($path);
    }
}
$AppRender = new AppView();
$AppRender->execute();
Exemplo n.º 13
0
/**
 * Get a normalized URI, using the current app's prefix settings
 *
 * @param String $uri the URI to normalize (e.g. "user/sign-up")
 * @param String $prefix an optional URI prefix
 * @return String the normalized URI
 */
function uri($uri, $prefix = NULL)
{
    return AppView::uri($uri, $prefix);
}
Exemplo n.º 14
0
$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));
Exemplo n.º 15
0
 /**
  * Initialization hook method.
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     $this->response->type('ajax');
 }
Exemplo n.º 16
0
 /**
  * Set View global variables
  *
  * @param array $vars
  * @return void
  */
 public static function set(array $vars)
 {
     self::$vars = array_merge(self::$vars, $vars);
 }
Exemplo n.º 17
0
 public function __construct($resourceName)
 {
     parent::__construct($resourceName);
 }
Exemplo n.º 18
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();
 }
Exemplo n.º 19
0
 /**
  * Render the view path by extracting the render array
  *
  * @param String $__path_to_the_view_file the path to the view file
  * @param Object $render the data to render in the view
  * @return String the rendered output to be returned to the client
  */
 public static function render($__path_to_the_view_file, $render)
 {
     self::$render = $render;
     ob_start();
     extract((array) $render);
     include $__path_to_the_view_file;
     if (isset($php_errormsg) && isset($app) && $app instanceof App) {
         $app->add_error_message($php_errormsg);
     }
     return ob_get_clean();
 }
Exemplo n.º 20
0
 /**
  * use AppView for render view
  * if viewVars has key 'data' using json or xml
  *
  * @param $action
  * @param $path with DS end
  * @override method
  */
 public function render($action = null, $path = null)
 {
     if ($this->_hasRendered) {
         return $this->output;
     }
     $this->beforeRender();
     $this->Component->beforeRender($this);
     if (is_null($this->view)) {
         App::import("vendor", "inc/view");
         try {
             $this->view = AppView::getInstance($this->params['url']['ext'], $this);
             $this->output .= $this->view->render($action, $path);
         } catch (AppViewException $e) {
             $this->_stop();
         }
     }
     $this->_hasRendered = true;
     return $this->output;
 }