Пример #1
0
 public function setUp()
 {
     global $current_user, $sugar_config;
     SugarTestHelper::setUp('current_user', array(true));
     $current_user->setPreference('dec_sep', ',');
     $current_user->setPreference('num_grp_sep', '.');
     $current_user->setPreference('default_currency_significant_digits', 3);
     SugarTestHelper::setUp('app_list_strings');
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('beanList');
     parent::setUp();
     $this->lm = new LayoutManager();
     $this->lm->setAttribute('reporter', new stdClass());
     $this->currency_51568 = new Currency();
     $this->currency_51568->symbol = 'TT';
     $this->currency_51568->conversion_rate = 0.5;
     $this->currency_51568->save(false);
     $this->currency_system = new Currency();
     $this->currency_system->retrieve(-99);
     $this->backupSymbol = $this->currency_system->symbol;
     $this->currency_system->symbol = '¥';
     $this->currency_system->save(false);
     $sugar_config['default_currency_symbol'] = '¥';
     get_number_seperators(true);
 }
Пример #2
0
 private function getSugarWidgetFieldRelate()
 {
     $LayoutManager = new LayoutManager();
     $temp = (object) array('db' => $GLOBALS['db'], 'report_def_str' => '');
     $LayoutManager->setAttributePtr('reporter', $temp);
     $Widget = new SugarWidgetFieldRelate($LayoutManager);
     return $Widget;
 }
Пример #3
0
 /**
  * Test asserts that for group functions order by is alias instead of table.field
  *
  * @dataProvider dataProvider
  * @group 57902
  * @return void
  */
 public function testQueryOrderBy($layout_def, $expected)
 {
     $layoutManager = new LayoutManager();
     $db = new stdClass();
     $db->db = $GLOBALS['db'];
     $layoutManager->setAttributePtr('reporter', $db);
     $sugarWidgetReportField = new SugarWidgetReportField($layoutManager);
     $actual = $sugarWidgetReportField->queryOrderBy($layout_def);
     $this->assertContains($expected, $actual, 'ORDER BY statement uses wrong field');
 }
 /**
  * Perform a full application run 
  * 
  * @return void
  */
 public function run()
 {
     try {
         $imageIdentifierMap = $this->reader->getMappingTable();
         $this->layout->init(count($imageIdentifierMap));
         foreach ($imageIdentifierMap as $image => $identifier) {
             $this->layout->layoutImage($this->layout->getRenderer()->createMetaImage($image));
         }
         $imageLayoutMap = $this->layout->finish();
         $this->writer->writeDefinition($imageIdentifierMap, $imageLayoutMap);
     } catch (\RuntimeException $e) {
         $this->logger->log(E_ERROR, $e->getMessage());
     }
 }
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         self::$instance = new LayoutManager();
     }
     return self::$instance;
 }
Пример #6
0
 public function process($params)
 {
     if ($this->itemLayoutPath == "") {
         $this->itemLayout = LayoutManager::getLayout("default-item-layout");
     }
     $this->itemLayout = Files::readString($this->itemLayoutPath);
     $this->pageCount = $this->getRowCount() / $this->itemsPerPage;
     $this->data['itemLayout'] = $this->itemLayout;
     $this->data['itemData'] = $this->listData;
 }
Пример #7
0
 /**
  * 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);
 }
Пример #8
0
 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;
 }
Пример #9
0
 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);
 }
Пример #10
0
 /**
  * @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
 }
Пример #11
0
function bootstrap()
{
    global $CONFIG, $SYSTEM_INFO, $output_started, $body_started, $console, $profiler, $ALLOWED_MGMT_FUNCS;
    header("Content-type: application/xhtml+xml\r");
    $console = new SystemConsole();
    DEBUG("<strong>This is 29o3 " . $SYSTEM_INFO['SystemVersion'] . " Codename " . $SYSTEM_INFO['SystemCodename'] . "</strong>");
    DEBUG("SYS: Bootstrapping started...");
    $connector = new DatabaseConnector();
    $connector->setupConnection($CONFIG['DatabaseHost'], $CONFIG['DatabaseUser'], $CONFIG['DatabasePassword'], $CONFIG['DatabaseName'], $CONFIG['DatabasePort']);
    DEBUG("DB: Connected to database.");
    $request = new PageRequest($connector);
    $request->parseRequest();
    // instanciate new cache object
    $co = new cacheObject($connector, $request->getRequestedSite(), $request->getRequestedPage());
    // check if we have content for current page cached
    $cacheContent = $co->getCached();
    if ($cacheContent === false) {
        // construct header and body objects
        $header = new XHTMLHeader();
        $body = new XHTMLBody();
        $pdo = new pageDescriptionObject($header, $body, $connector, $request->getWantAdmin(), $request->getAdminFuncParam());
        $connector->executeQuery("SELECT * FROM " . mktablename("pages") . " WHERE name='" . $request->getRequestedPage() . "'");
        /* lets see what the admin wants */
        if ($request->getWantAdmin()) {
            if ($request->getRequestedPage() == "overview") {
            }
        }
        $pageInfo = $connector->fetchArray();
        $pdo->setPageDescriptionA($pageInfo, $request->getRequestedSite());
        $header->setTitle($pdo->getContent("title"));
        if ($pdo->getContent("description") != "") {
            $header->addMetaDCDescription($pdo->getContent('description'));
        }
        if ($pdo->getContent("subject") != "") {
            $header->addMetaDCSubject($pdo->getContent("subject"));
        }
        if ($pdo->getContent("date") != 0) {
            $header->addMetaDCDate(strftime("%Y-%m-%d", $pdo->getContent('date')));
        }
        if ($pdo->getContent("creator") != "") {
            $header->addMetaDCCreator($pdo->getContent("creator"));
        }
        if ($pdo->getContent("contributors") != "") {
            $c_arr = explode(";", $pdo->getContent('contributors'));
            for ($i = 0; $i <= count($c_arr) - 1; $i++) {
                $header->addMetaDCContributor($c_arr[$i]);
            }
        }
        if ($pdo->getContent("type") != "") {
            $header->addMetaDCType($pdo->getContent("type"));
        }
        if ($pdo->getContent("sources") != "") {
            $sources_array = explode(";", $pdo->getContent('sources'));
            for ($i = 0; $i <= count($sources_array) - 1; $i++) {
                $header->addMetaDCSource($sources_array[$i]);
            }
        }
        /*
        !!!	FIXME: 	THE FOLLOWING CODE CAUSES A RACE CONDITION ON BOTH APACHE2/PHP
        !!!		AND PHP-CLI. 
        !!!	SEV:   	(5) - Causes server process to fill RAM and swap -> kill
        !!!	RES:	Currently no resolution, commented out because of this.
        !!!		I'd say it has got something to do with the database for
        !!!		I cannot find an error elsewhere.
        >!<	*** FIXED ***
        >!<	F**K YOU F**K YOU DAMN CODER!!!! F**K YOU!!!
        */
        if ($pdo->getContent("language") != "") {
            $header->addMetaDCLanguage($pdo->getContent('language'));
        }
        if ($pdo->getContent('copyright') != "") {
            $header->addMetaDCRights($pdo->getContent("copyright"));
        }
        // this is the r0x0r1ng stylesheet which controls how system messages (errors, etc.) appear
        $pdo->scheduleInsertion_ExternalStylesheet("n_style.css");
        if ($pdo->getContent('no_cache') == 1) {
            $co->setScheduleCaching(false);
            DEBUG("CACHE: Caching deactivated on request.");
        }
        // now, get the page's stylesheet; it might be empty, but we'll add it if not :)
        if ($request->getWantAdmin() <= 1) {
            if ($request->getWantAdmin() == 1) {
                $co->setScheduleCaching(false);
                DEBUG("CACHE: Admin wanted, caching deactivated.");
            }
            $layoutManager = new LayoutManager($pdo);
            $pdo->getAvailableBoxes();
            $connector->executeQuery("SELECT * FROM " . mktablename("layouts") . " WHERE lname='" . $pageInfo['layout'] . "'");
            if ($connector->getNumRows() != 0) {
                $currentLayout = $connector->fetchArray();
                $layoutManager->setLayoutFile($currentLayout['file']);
                $layoutManager->parseLayout();
            } else {
                throw new GeneralException("No layout found. 29o3 cannot continue.");
            }
            if ($request->getWantAdmin()) {
                require_once $CONFIG['LibDir'] . 'admin/adminFuncs.php';
                $af = new adminFuncs($pdo, $request);
                $pdo->scheduleInsertion_ExternalStylesheet($af->getAdminStylesheet());
            }
            DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
            $connector->closeConnection();
            DEBUG("DB: Connection closed.");
            $profiler->addBreakpoint();
            DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
            DEBUG("SYS: Exiting normally.");
            // print the buffer of the header since we're done with it :)
            $pdo->doInsertions();
            // we have everything at this point... start caching procedure
            $co->doCache($pdo->getBuffers());
            if ($CONFIG['Developer_Debug'] == true) {
                if ($body) {
                    $body->eyecandyConsole($console);
                } else {
                    $console->printBuffer();
                }
            }
            if ($pdo->getBrandingState() == true) {
                $pdo->insertBodyDiv("Powered by <a href=\"http://twonineothree.berlios.de\">29o3</a> " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"], "poweredBy", "poweredBy_Banner", "Powered by 29o3");
            }
            printf('<?xml version="1.0" encoding="UTF-8"?>');
            printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">%s', "\n");
            printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%s', "\n");
            $pdo->printHeaderBuffer();
            $header_started = true;
            // destruct the header object
            $pdo->destroyHeaderObject();
            $body_started = true;
            // print out the body buffer
            $pdo->printBodyBuffer();
            printf('</html>');
            // exit normally.
            exit(0);
        } else {
            $co->setScheduleCaching(false);
            $pdo->setOmitBranding(true);
            DEBUG("CACHE: Admin wanted, caching deactivated.");
            require_once $CONFIG['LibDir'] . 'admin/adminFuncs.php';
            $co->setScheduleCaching(false);
            $af = new adminFuncs($pdo, $request);
            $pdo->scheduleInsertion_ExternalStylesheet($af->getAdminStylesheet());
            //			$pdo->insertBodyDiv("<img src=\"lib/images/adminlogotop.png\" style=\"vertical-align: top; text-align: left; border: 0; padding: 0; margin: 0;\" /><span class=\"adminMenu\" style=\"width: 100%;\">" . $af->getAdminMenu() . "</span>", "adminStripe", "2mc_menu", "29o3 management console");
            // this part is for the admin scripts which require
            // are not fetched from database
            DEBUG("SYS: Skipping normal layout and box fetching procedures");
            $header->setTitle("29o3 management console");
            $ao = NULL;
            $func = $request->getWantedAdminFunc();
            if (!array_search($func, $ALLOWED_MGMT_FUNCS)) {
                $func = "Overview";
            }
            // administration needs admin logged in
            $sm = new sessionManager($connector);
            if ($sm->checkSession() == false) {
                DEBUG("MGMT: Admin not logged in.");
                $func = "Login";
            }
            if ($func == "Logout") {
                $sm->invalidateSession();
                header("Location: " . mksyslink("?"));
            }
            require_once $CONFIG["LibDir"] . 'admin/admin' . $func . '.php';
            $name = "Admin" . $func;
            $ao = new $name($connector, $pdo, $sm);
            $ao->doPreBodyJobs();
            $pdo->insertIntoBodyBuffer($af->getAdminMenu());
            $ao->doBodyJobs();
            DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
            $profiler->addBreakpoint();
            DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
            $connector->closeConnection();
            DEBUG("DB: Connection closed.");
            DEBUG("SYS: Exiting normally.");
            if ($CONFIG['Developer_Debug'] == true) {
                if ($body) {
                    $body->eyecandyConsole($console);
                } else {
                    $console->printBuffer();
                }
            }
            //			$pdo->insertBodyDiv("Powered by <a href=\"http://twonineothree.berlios.de\">29o3</a> " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"], "poweredBy", "poweredBy_Banner", "Powered by 29o3");
            // print the buffer of the header since we're done with it :)
            printf('<?xml version="1.0" encoding="UTF-8"?>');
            printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">%s', "\n");
            printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%s', "\n");
            $pdo->doInsertions();
            $pdo->printHeaderBuffer();
            $header_started = true;
            // destruct the header object
            $pdo->destroyHeaderObject();
            $body_started = true;
            // print out the body buffer
            $pdo->printBodyBuffer();
            printf('</html>');
            // exit normally
            exit(0);
        }
    } else {
        echo $co->getCacheContent();
        DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
        $profiler->addBreakpoint();
        DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
        $connector->closeConnection();
        DEBUG("DB: Connection closed.");
        DEBUG("SYS: Exiting normally.");
        if ($CONFIG['Developer_Debug'] == true) {
            echo '<center><div class="eyecandyConsole">' . $console->getBuffer() . '</div></center>';
        }
        echo "\n</body>\n</html>";
        // exit normally
        exit(0);
    }
    // never reached
}
Пример #12
0
 /**
  * Create SugarWidget for relate field
  */
 public function getSugarWidgetFieldRelate()
 {
     $layoutManager = new LayoutManager();
     $layoutManager->setAttribute('context', 'Report');
     $db = new stdClass();
     $db->db = $GLOBALS['db'];
     $db->report_def_str = '';
     $layoutManager->setAttributePtr('reporter', $db);
     $this->sugarWidget = new SugarWidgetFieldrelate($layoutManager);
 }
Пример #13
0
<?php

LibLoader::loadOne("string_util");
LibLoader::loadOne("array_util");
LayoutManager::addLayoutFolder("views");
Пример #14
0
 * Date: 05.11.2015
 * Time: 18:55
 */
mb_internal_encoding("utf-8");
spl_autoload_register("autoload");
session_start();
KeyConfigLoader::selectFile("main");
require_once "dependencies.php";
if (KeyConfigLoader::getValue("auto-index-libraries") == "true") {
    LibLoader::indexLibraries();
}
if (KeyConfigLoader::getValue("auto-load-libraries") == "true") {
    LibLoader::loadAll();
}
if (KeyConfigLoader::getValue("auto-index-layouts") == "true") {
    LayoutManager::indexLayouts();
}
$router = new RouterController();
$router->process($_SERVER['REQUEST_URI']);
$router->createView();
function autoload($class)
{
    if (strpos($class, "Controller") !== false) {
        require_once "controllers/{$class}.php";
    } else {
        require_once "models/{$class}.php";
    }
}
function kill($var)
{
    var_dump($var);