public function Errors(CompositeView $view) { if (count($view->getErrors())) { echo '<ul class="november-error">'; foreach ($view->getErrors() as $id => $error) { echo '<li>' . $error . '</li>'; } echo '</ul>'; } }
public function ShowFlash(CompositeView $view) { $flash = $view->flash(); if ($flash == null) { return; } echo '<div class="november-flash">'; if (is_array($flash)) { $this->outputArray($flash); } else { echo $flash; } echo '</div>'; }
<p> <?php $this->wikiCode($this->status->completednotes); ?> </p> <?php } if (mb_strlen($this->status->todonotes)) { ?> <h2>Todo</h2> <p> <?php $this->wikiCode($this->status->todonotes); ?> </p> <?php } ?> <?php $view = new CompositeView(); $view->project = $this->project; $view->status = $this->status; $content = $view->render('project/displaystatus.php'); echo $content; ?> </body> </html>
/** * creates the 'status' view of a project. */ public function statusAction() { $project = $this->byId(); $view = new CompositeView(); $projectStatus = $this->_getParam('projectstatus', null); $status = null; if ($projectStatus) { $status = $this->projectService->getStatus($projectStatus); } else { $status = $this->projectService->getProjectStatus($project, $this->_getParam('period', 7)); } $view->project = $project; $view->status = $status; $content = $view->render('project/status.php'); if ($this->_getParam('pdf')) { ini_set('memory_limit', '32M'); include_once "dompdf/dompdf_config.inc.php"; include_once "dompdf/include/dompdf.cls.php"; include_once "dompdf/include/frame_tree.cls.php"; include_once "dompdf/include/stylesheet.cls.php"; include_once "dompdf/include/frame.cls.php"; include_once "dompdf/include/style.cls.php"; include_once "dompdf/include/attribute_translator.cls.php"; include_once "dompdf/include/frame_factory.cls.php"; include_once "dompdf/include/frame_decorator.cls.php"; include_once "dompdf/include/positioner.cls.php"; include_once "dompdf/include/block_positioner.cls.php"; include_once "dompdf/include/block_frame_decorator.cls.php"; include_once "dompdf/include/frame_reflower.cls.php"; include_once "dompdf/include/block_frame_reflower.cls.php"; include_once "dompdf/include/frame_reflower.cls.php"; include_once "dompdf/include/text_frame_reflower.cls.php"; include_once "dompdf/include/canvas_factory.cls.php"; include_once "dompdf/include/canvas.cls.php"; include_once "dompdf/include/abstract_renderer.cls.php"; include_once "dompdf/include/renderer.cls.php"; include_once "dompdf/include/cpdf_adapter.cls.php"; include_once "dompdf/include/font_metrics.cls.php"; include_once "dompdf/include/block_renderer.cls.php"; include_once "dompdf/include/text_renderer.cls.php"; include_once "dompdf/include/image_cache.cls.php"; include_once "dompdf/include/text_frame_decorator.cls.php"; include_once "dompdf/include/inline_positioner.cls.php"; include_once "dompdf/include/page_frame_reflower.cls.php"; include_once "dompdf/include/list_bullet_frame_decorator.cls.php"; include_once "dompdf/include/list_bullet_positioner.cls.php"; include_once "dompdf/include/list_bullet_frame_reflower.cls.php"; include_once "dompdf/include/list_bullet_image_frame_decorator.cls.php"; include_once "dompdf/include/list_bullet_renderer.cls.php"; include_once "dompdf/include/page_frame_decorator.cls.php"; include_once "dompdf/include/table_frame_decorator.cls.php"; include_once "dompdf/include/cellmap.cls.php"; include_once "dompdf/include/table_frame_reflower.cls.php"; include_once "dompdf/include/table_row_frame_decorator.cls.php"; include_once "dompdf/include/null_positioner.cls.php"; include_once "dompdf/include/table_row_frame_reflower.cls.php"; include_once "dompdf/include/table_cell_frame_decorator.cls.php"; include_once "dompdf/include/table_cell_positioner.cls.php"; include_once "dompdf/include/table_cell_frame_reflower.cls.php"; include_once "dompdf/include/table_row_group_frame_decorator.cls.php"; include_once "dompdf/include/table_row_group_frame_reflower.cls.php"; include_once "dompdf/include/table_cell_renderer.cls.php"; include_once "dompdf/include/inline_frame_decorator.cls.php"; include_once "dompdf/include/inline_frame_reflower.cls.php"; include_once "dompdf/include/image_frame_decorator.cls.php"; include_once "dompdf/include/image_frame_reflower.cls.php"; include_once "dompdf/include/inline_renderer.cls.php"; include_once "dompdf/include/image_renderer.cls.php"; include_once "dompdf/include/dompdf_exception.cls.php"; $dompdf = new DOMPDF(); $dompdf->load_html($content); $dompdf->render(); $date = date('Y-m-d'); if ($status->created) { $date = date('Y-m-d', strtotime($status->created)); } $name = $project->title . ' status-' . $date . '.pdf'; $dompdf->stream($name); } else { echo $content; } }
/** * View the expenses for a given user / client */ public function viewAction() { $view = new CompositeView(); $view->addScriptPath('extensions/expenses/views'); $report = $this->byId(null, 'ExpenseReport'); $client = null; $user = null; $expenses = array(); // we either have a fixed report, or we have a dynamic one if ($report) { if (mb_strlen($report->username)) { $expenses = $this->expenseService->getExpenses(array('userreportid=' => $report->id)); $user = $this->userService->getUserByField('username', $report->username); } else { $expenses = $this->expenseService->getExpenses(array('expensereportid=' => $report->id)); $client = $this->clientService->getClient($report->clientid); } $view->start = $report->from; $view->end = $report->to; } else { $client = $this->clientService->getClient($this->_getParam('clientid')); $user = $this->userService->getUserByField('username', $this->_getParam('username')); $view->user = $user; $start = $this->_getParam('start', $this->_getParam('start', $this->calculateDefaultStartDate())); $end = $this->_getParam('end', $this->_getParam('end', $this->calculateDefaultEndDate())); $expenses = $this->expenseService->getDynamicExpenseReport($start, $end, $user, $client); $view->start = $start; $view->end = $end; } $view->expenses = $expenses; $view->client = $client; $view->user = $user; $view->report = $report; $view->mode = $this->_getParam('pdf') ? 'pdf' : 'html'; $content = $view->render('expense/view.php'); if ($this->_getParam('pdf')) { ini_set('memory_limit', '32M'); include_once "dompdf/dompdf_config.inc.php"; include_once "dompdf/include/dompdf.cls.php"; include_once "dompdf/include/frame_tree.cls.php"; include_once "dompdf/include/stylesheet.cls.php"; include_once "dompdf/include/frame.cls.php"; include_once "dompdf/include/style.cls.php"; include_once "dompdf/include/attribute_translator.cls.php"; include_once "dompdf/include/frame_factory.cls.php"; include_once "dompdf/include/frame_decorator.cls.php"; include_once "dompdf/include/positioner.cls.php"; include_once "dompdf/include/block_positioner.cls.php"; include_once "dompdf/include/block_frame_decorator.cls.php"; include_once "dompdf/include/frame_reflower.cls.php"; include_once "dompdf/include/block_frame_reflower.cls.php"; include_once "dompdf/include/frame_reflower.cls.php"; include_once "dompdf/include/text_frame_reflower.cls.php"; include_once "dompdf/include/canvas_factory.cls.php"; include_once "dompdf/include/canvas.cls.php"; include_once "dompdf/include/abstract_renderer.cls.php"; include_once "dompdf/include/renderer.cls.php"; include_once "dompdf/include/cpdf_adapter.cls.php"; include_once "dompdf/include/font_metrics.cls.php"; include_once "dompdf/include/block_renderer.cls.php"; include_once "dompdf/include/text_renderer.cls.php"; include_once "dompdf/include/image_cache.cls.php"; include_once "dompdf/include/text_frame_decorator.cls.php"; include_once "dompdf/include/inline_positioner.cls.php"; include_once "dompdf/include/page_frame_reflower.cls.php"; include_once "dompdf/include/page_frame_decorator.cls.php"; include_once "dompdf/include/table_frame_decorator.cls.php"; include_once "dompdf/include/cellmap.cls.php"; include_once "dompdf/include/table_frame_reflower.cls.php"; include_once "dompdf/include/table_row_frame_decorator.cls.php"; include_once "dompdf/include/null_positioner.cls.php"; include_once "dompdf/include/table_row_frame_reflower.cls.php"; include_once "dompdf/include/table_cell_frame_decorator.cls.php"; include_once "dompdf/include/table_cell_positioner.cls.php"; include_once "dompdf/include/table_cell_frame_reflower.cls.php"; include_once "dompdf/include/table_row_group_frame_decorator.cls.php"; include_once "dompdf/include/table_row_group_frame_reflower.cls.php"; include_once "dompdf/include/table_cell_renderer.cls.php"; include_once "dompdf/include/inline_frame_decorator.cls.php"; include_once "dompdf/include/inline_frame_reflower.cls.php"; include_once "dompdf/include/image_frame_decorator.cls.php"; include_once "dompdf/include/image_frame_reflower.cls.php"; include_once "dompdf/include/inline_renderer.cls.php"; include_once "dompdf/include/image_renderer.cls.php"; include_once "dompdf/include/dompdf_exception.cls.php"; $dompdf = new DOMPDF(); // $dompdf->set_paper('letter', 'landscape'); $dompdf->load_html($content); $dompdf->render(); $name = "expenses-" . date('Y-m-d', strtotime($view->start)) . '-to-' . date('Y-m-d', strtotime($view->end)) . '.pdf'; $dompdf->stream($name); } else { echo $content; } }
<h3> Completed Tasks </h3> <table class="item-table" cellpadding="0" cellspacing="0"> <thead> <tr> <th width="40%">Title</th> <th>Due</th> <th>Assigned To</th> <th>Actions</th> </tr> </thead> <tbody> <?php $taskRowView = new CompositeView('task/task-line-item.php'); foreach ($this->completedTasks as $task) { $taskRowView->task = $task; $taskRowView->project = $this->project; echo $taskRowView->render('null'); } ?> </tbody> </table> <?php $this->pager($this->totalCompleted, $this->taskListSize, $this->completedPagerName, array('#tasks')); ?> </div>
/** * Enter description here... * * @param unknown_type $template * @param unknown_type $model */ public function generateEmail($template, $model) { $view = new CompositeView(); $view->setScriptPath(APP_DIR . '/views/emails'); $view->assign($model); return $view->render($template); }
/** * When a master view is created, it is passed its * script immediately, but its script path is * in a different location * * @param unknown_type $viewFile */ public function __construct($script = '', $path = 'views/layouts') { parent::__construct($script); $this->setViewFile('layouts/' . $script); // $this->setScriptPath(APP_DIR.'/'.$path); }
/** * Flash something up to the user. * * @param string $string */ protected function flash($string) { $this->view->flash($string); }
/** * Allows the dispatching and processing of a separate * controller request from inside an existing view. * * Should be used for read only stuff (please!) * * @param string $controller * @param string $action * @param array $params A list of parameters to bind into the new request * @param string $module * @param array $requestParams A list of parameters to pull from the current request */ public function Dispatch($controller, $action, $params = array(), $module = null, $requestParams = array()) { // If no module, use the current request module $oldRequest = null; $ctrl = Zend_Controller_Front::getInstance(); $oldRequest = $ctrl->getRequest(); if ($module == null) { /* @var $request Zend_Controller_Request_Abstract */ $name = null; if ($oldRequest) { $name = $oldRequest->getModuleName(); } if ($name && $name != 'default') { $module = $name; } } else { if ($module == 'default') { $module = ''; } } $key = $controller . '|' . $action . '|' . $module; if (isset(self::$__DISPATCHED[$key])) { za()->log("Recursive dispatch detected {$key} ", Zend_Log::ERR); return; } self::$__DISPATCHED[$key] = true; $request = new Zend_Controller_Request_Http(); $response = new Zend_Controller_Response_Http(); $request->setControllerName($controller); $request->setActionName($action); if ($params) { $request->setParams($params); } if (count($requestParams)) { foreach ($requestParams as $rp) { // get from the current request and stick into the new $value = $oldRequest->getParam($rp, ''); $request->setParam($rp, $value); } } if ($module) { $request->setModuleName($module); } $oldView = Zend_Registry::get(NovemberApplication::$ZEND_VIEW); $allPaths = $oldView->getAllPaths(); $newView = new CompositeView(); foreach ($allPaths['script'] as $scriptPath) { $newView->addScriptPath($scriptPath); } foreach ($allPaths['helper'] as $prefix => $path) { $newView->addHelperPath($path, $prefix); } foreach ($allPaths['filter'] as $prefix => $path) { $newView->addFilterPath($path, $prefix); } Zend_Registry::set(NovemberApplication::$ZEND_VIEW, $newView); $dispatcher = new InjectingDispatcher(); $dispatcher->addControllerDirectory('controllers', 'default'); $dispatcher->setParams($params)->setResponse($response); $request->setDispatched(true); $dispatcher->dispatch($request, $response); $response->outputBody(); Zend_Registry::set(NovemberApplication::$ZEND_VIEW, $oldView); }