/** * Render the requested Report * * @param sfWebRequest $request The request. It's expected to have the following * parameters: * <ul> * <li>array<b> export</b> With the report selection and desired output rendering * format. * <li>array<b> options</b> With custom options that wlil be pased to the callback * function provided by the report designer for generating the LogicalScreen. * <li>string<b> logicalScreen</b> With a string representation of a XML DOM. * if provided, step1 gets bypassed, thus <b>options</b> param is ignored. * </li> * </ul> * * @return sfView::NONE renderText() with the report contents. */ public function executeRender(sfWebRequest $request) { $this->_confSrc = ConfigManager::includeConfig(); $exportForm = new SelectReportForm(array(), $this->_confSrc); $exportForm->bind($request->getParameter('export')); $this->redirectUnless($exportForm->isValid(), 'export/index'); $config = ConfigManager::configureExport($exportForm->getValues(), (array) $request->getParameter('options', array())); $dom = new DOMDocument(); $dom = $dom->loadXML($request->getParameter('logicalScreen', null)) ? $dom : null; $report = LayoutManager::getInstance()->render($config, $this->getResponse(), $dom); $this->getResponse()->setContent(''); return $this->renderText($report); }
public static function displayForm(YuppForm2 $form) { $formHTML = ""; if ($form->isAjax()) { $lm = LayoutManager::getInstance(); $jslib = $lm->getJSLib(); if (is_null($jslib)) { $jslib = 'prototype'; } // Libreria por defecto. eval('$formHTML .= self::display_ajax_form_' . $jslib . '($form);'); //$formHTML .= self::display_ajax_form_jquery($form); //$formHTML .= self::display_ajax_form_prototype($form); } $fieldCount = 0; $formHTML .= '<form action="' . $form->getUrl() . '" ' . 'id="' . $form->getId() . '" ' . 'name="' . $form->getId() . '" ' . 'method="' . $form->getMethod() . '" ' . ($form->hasFileFields() ? 'enctype="multipart/form-data"' : '') . '>'; $fieldsOrGroups = $form->get(); foreach ($fieldsOrGroups as $fieldOrGroup) { $fieldCount++; $fieldOrGroup->fieldNumber = $fieldCount; if ($fieldOrGroup instanceof YuppFormField2) { $formHTML .= self::displayField($fieldOrGroup); } else { $formHTML .= self::displayGroup($fieldOrGroup); } } $formHTML .= '</form>'; echo $formHTML; }
private static function render($logic_route, $command, $context, $router) { // Configuro el command para la view... // Si la pagina es fisica $pagePath = 'apps/' . $logic_route['app'] . '/views/' . $logic_route['controller'] . '/' . $command->viewName() . '.view.php'; //echo $pagePath . '<br/>'; //Logger::struct($logic_route, 'render logic route'); //Logger::struct($command, 'render command'); //$pagePath = realpath('./'.$pagePath); // Resuelve .. y . // FIXME: en linux puede tener problemas resolviendo . y .. en la path, necesitaria resolverla a la canonica // realpath se desactiva en algunos hostings por temas de seguridad, habria que implementar una alternativa // http://php.net/manual/en/function.realpath.php if (!file_exists($pagePath)) { // Intento resolver path con .. en linux $pagePath = preg_replace('/\\w+\\/\\.\\.\\//', '', $pagePath); // Saca .. pero no saca . y deberia } //echo $pagePath . '<br/>'; //apps/cms2/views/page/../cms/displayPageRO.view.php //apps/cms2/views/cms/displayPageRO.view.php // Si la ruta referenciada no existe, intento mostrar la vista de scafolding correspondiente // a la accion, pero las acciones con vistas dinamicas son solo para acciones: 'show','list','edit','create'. if (!file_exists($pagePath)) { //Logger::getInstance()->log("no existe pagePath $pagePath " . __FILE__); //Logger::getInstance()->log("view name es " . $command->viewName()); // Si puedo mostrar la vista dinamica: if (in_array($command->viewName(), array('show', 'list', 'edit', 'create', 'index', 'appControllers', 'dbStatus'))) { $pagePath = 'core/mvc/view/scaffoldedViews/' . $command->viewName() . '.view.php'; // No puede no existir, es parte del framework! } else { if (is_numeric($command->viewName())) { // FIXME: verificar que existe, porque no se implementaron todos los errores... $pagePath = 'core/mvc/view/error/' . $command->viewName() . '.view.php'; // No puede no existir, es parte del framework! // FIXME: poner un error general por si no esta en la lista $codes = array(403 => 'Forbidden', 404 => 'Not Found', 500 => 'Internal Server Error'); header("HTTP/1.0 " . $command->viewName() . " " . $codes[$command->viewName()]); } else { // Tira 404: Not Found // Sobreescribo el command $command = ViewCommand::display('404', new ArrayObject(array('message' => 'La vista <b>' . $pagePath . '</b> no existe')), new ArrayObject()); $pagePath = 'core/mvc/view/error/404.view.php'; header("HTTP/1.0 404 Not Found"); } } // FIXME: con esto de arriba no es necesario tener mas el "mode". } $command->setPagePath($pagePath); // FIXME: No se usa para nada el pagePath en el command. // Model va a ser accedida desde las vistas. $model = Model::getInstance(); $model->setModel($command->params()); // $command->params() es el modelo devuelto por la accion del controller. $model->addFlash($command->flash()); // Solucion a agregar flash cuando se hace redirect $model->addFlash($router->getFlashParams()); /// ACTUALIZAR CONTEXTO /// $context->setModel($model); //$context->update(); /// ACTUALIZAR CONTEXTO /// $layoutManager = LayoutManager::getInstance(); $layoutManager->renderWithLayout($pagePath); }
/** * @param params array asociativo con los valores * - app (opcional) nombre de la app donde esta la libreria * - name (obligatorio) nombre de la libreria JS */ public static function js($params) { // Registra la libreria en LayoutManager en lugar de retornar un string... LayoutManager::getInstance()->addJSLibReference($params); /* // Busca la ubicacion en una app particular if ( array_key_exists('app', $params) ) $res = '<script type="text/javascript" src="'. $_base_dir .'/apps/'. $params['app'] .'/javascript/'. $params['name'] .'.js"></script>'; else // Ubicacion por defecto de todos los javascripts de todos los modulos $res = '<script type="text/javascript" src="' . $_base_dir . '/js/' . $params['name'] . '.js"></script>'; return $res; */ return ''; // FIXME: no retornar nada }