function __construct($type = self::PANEL, $dry_run = false, $step = false, $manual = false, $internal = false, $build = false) { if ($build) { $build = strtok(substr($build, 1), "?"); $build_params = ArrayUtil::queryStringToArray(strtok("?")); $this->build = $build; } else { if (self::$instance) { return true; } } self::$started = true; if (!defined("NODES")) { define("NODES", 1); } if (!defined("VALUES")) { define("VALUES", 2); } if (!defined("ATTRIBUTES")) { define("ATTRIBUTES", 3); } if (!defined("PAIRS")) { define("PAIRS", 4); } $this->root = sfConfig::get("sf_root_dir"); $this->schemaLocation = $this->root . "/plugins/appFlowerPlugin/schema/appflower.xsd"; // Reading parser YML config //$tmp = sfYaml::load($this->root."/plugins/appFlowerPlugin/config/app.yml"); $this->remove_fields = sfConfig::get("app_parser_remove_fields"); // Context info $this->context = sfContext::getInstance(); // Set Application.. $this->application = $this->context->getConfiguration()->getApplication(); // Set user $this->user = $this->context->getUser(); // Add JS file list //$this->loadJSFilesList(); // Action attributes.. $actionInstance = $this->context->getActionStack()->getLastEntry()->getActionInstance(); $this->attribute_holder = $actionInstance->getVarHolder()->getAll(); // Request $this->request = $actionInstance->getRequest()->getParameterHolder()->getAll(); foreach ($this->request as $param => $value) { if (!array_key_exists($param, $this->attribute_holder)) { $this->attribute_holder[$param] = $value; } } $this->currentUri = $actionInstance->getModuleName() . "/" . $actionInstance->getActionName(); if ($build) { $uri = $build; $module = strtok($build, "/"); $action = strtok("/"); $this->currentUri = $module . "/" . $action; } else { $uri = $actionInstance->getModuleName() . "/" . $actionInstance->getActionName(); $module = $actionInstance->getModuleName(); $action = $actionInstance->getActionName(); } $this->vars[$uri] = $this->attribute_holder; if ($build) { $config_vars = afConfigUtils::getConfigVars(strtok($build, "/"), strtok("/"), $this->context->getRequest()); if ($build_params) { foreach ($build_params as $n => $p) { $config_vars[$n] = $p; } } $this->vars[$uri] = $config_vars; $actionInstance->getVarHolder()->add($config_vars); } // Assign DOM Document.. if (!$build) { $this->readXmlDocument(); } else { $this->readXmlDocument(null, false, $build); } if (sfContext::getInstance()->has('profiler')) { $timer = sfTimerManager::getTimer('afRead'); $timer->addTime(); $timer = sfTimerManager::getTimer('afRender'); } parent::__construct($this->document); $root = $this->document->getElementsByTagName("view")->item(0); $view_type = $root->getAttribute("type"); $dynamic = $root->getAttribute("dynamic"); $actionInstance->view = $view_type; if ($view_type == "layout") { $this->layoutModule = $actionInstance->layoutModule = $root->getAttribute("module"); } $view_type = XmlBaseElementParser::parseValue($view_type, $root, true); $this->set("type", $view_type, $root); // Is this a Dynamic widget? If so, let's create update XML DOM. $this->namespace = $this->document->lookupNamespaceUri("i"); if ($dynamic === "true") { $this->buildXmlDocument($module, $view_type); } // Parser type if ($view_type == "layout") { $this->type = self::PAGE; } else { if ($view_type == "wizard") { $this->type = self::WIZARD; } else { $this->type = self::PANEL; } } // Is this a layout? $this->page = $view_type; try { if (!file_exists($this->schemaLocation) || !is_readable($this->schemaLocation)) { throw new XmlParserException("Was unable to read main schema document. Please check " . $this->schemaLocation . "!"); } else { if ($this->type === self::WIZARD && !isset($this->attribute_holder["current"])) { throw new XmlParserException("The step parameter must be defined in case of wizard layout!"); } } if (isset($this->attribute_holder["current"])) { $this->current = $this->attribute_holder["current"]; } if ($this->type === self::WIZARD && !$this->current) { throw new XmlParserException("The value of step parameter must be either false or a positive number!"); } $this->step = $step; if ($this->type === self::WIZARD && !isset($this->attribute_holder["step"])) { throw new XmlParserException("Required variable step cannot be found in attribute holder!"); } } catch (Exception $e) { throw $e; } if ($dry_run) { return true; } // Reading default footer and sidebar data if (!$build) { $this->parseDefaultPanels(); } // Reading Main XML Schema.. $this->schema = new DOMDocument(); $this->schema->load($this->schemaLocation); // Reading enum values.. $this->fetchEnums(); // Check widget access rights if ($this->type === self::PANEL || $this->type === self::WIZARD) { $this->checkWidgetCredentials(); } $this->enumCheck("i:viewType", $view_type); if ($this->type === self::WIZARD && isset($this->attribute_holder["init"])) { if (!$this->fetch("//i:datastore")->length) { $this->datastore = false; } else { $this->datastore = true; } } if ($build) { $this->runParser($build, "object"); } else { // Create layout if ($this->type === self::PANEL) { $this->panelIdXml = $this->context->getModuleName() . "/" . $this->context->getActionName(); self::$masterLayout = null; $this->layout = new afExtjsPanelLayout(); } else { if (self::$instance === null) { self::$instance = true; } if ($this->type === self::WIZARD) { $this->isTabbed(); if (!$this->tabbedWizard) { $wizattrs = array('id' => 'center_panel', 'title' => ""); } else { $wizattrs = array('id' => 'center_panel', 'title' => "", 'centerType' => 'group'); } $this->layout = new afExtjsWizardLayout($wizattrs); } else { $this->portalIdXml = $this->context->getModuleName() . "/" . $this->context->getActionName(); $this->portalStateObj = afPortalStatePeer::retrieveByIdXml($this->portalIdXml); if (!$this->portalStateObj) { //default values for layout & columns $this->portalConfig = new stdClass(); $this->portalConfig->layoutType = $this->fetch("//i:tab")->length ? afPortalStatePeer::TYPE_TABBED : afPortalStatePeer::TYPE_NORMAL; $this->portalConfig->content = array(); $this->portalConfig->content[0]["portalLayoutType"] = sfConfig::get("app_parser_default_layout", "[100]"); $this->portalConfig->idXml = $this->portalIdXml; } } if ($this->layout) { self::$masterLayout = $this->layout; } } $this->manualMode = $manual; /** * widget help settings * * ticket #300 - radu */ $this->widgetHelpSettings = afWidgetHelpSettingsPeer::retrieveCurrent(); // Application menu.. if ($this->context->getRequest()->getAttribute("af_first_page_request")) { /*$this->parseMenu(null,$this->layout->toolbar); print_r($this->buttons); exit(); foreach($this->buttons as $button) { if(isset($button["menus"])) { for($i = sizeof($button["menus"])-1; $i >= 0; $i--) { $button["menus"][$i]->end(); } } $button["button"]->end(); } sfProjectConfiguration::getActive()->loadHelpers(array('afExtjsToolbar')); */ } if (!$manual) { $this->runParser(1, "content"); } } }