private function find_routes($org, $dest, &$flights) { $result = array(); $queue = new SplPriorityQueue(); foreach ($flights as $flight) { if ($flight['org_id'] == $org) { $route = new Route($this->route_opts); $num_seats = Flight::get_open_seats_on_flight($flight['flight_id'], $this->user); $route->add_flight($flight, $num_seats); $queue->insert($route, $route->get_joy()); } } //BFS to find all routes that take < 10 hours $count = 0; while ($queue->count() > 0 && $count < $this->opts['max_results']) { $cur_route = $queue->extract(); if ($cur_route->get_dest() == $dest) { $result[] = $cur_route; $count++; continue; } foreach ($flights as $flight) { if (!array_key_exists($flight['dest_id'], $cur_route->visited) && $flight['org_id'] == $cur_route->get_dest() && $flight['e_depart_time'] > 30 * 60 + $cur_route->get_arrival_time()) { $new_route = $cur_route->copy(); $num_seats = Flight::get_open_seats_on_flight($flight['flight_id'], $this->user); $new_route->add_flight($flight, $num_seats); if ($new_route->get_trip_time() < 24 * 60 * 60 && $new_route->seats >= $this->opts['passengers']) { $queue->insert($new_route, $new_route->get_joy()); } } } } return $result; }
private function find_routes($org, $dest, &$flights) { $result = array(); $queue = new SplPriorityQueue(); foreach ($flights as $flight) { if ($flight['org_id'] == $org) { $route = new Route($this->route_opts); $route->add_flight($flight); array_push($this->id, $flight['flight_id']); $queue->insert($route, $route->get_joy()); } } //BFS to find all routes that take < 10 hours $count = 0; while ($queue->count() > 0 && $count < $this->opts['max_results']) { $cur_route = $queue->extract(); if ($cur_route->get_dest() == $dest) { $result[] = $cur_route; $count++; continue; } foreach ($flights as $flight) { if ($flight['org_id'] == $cur_route->get_dest() && $flight['e_depart_time'] > 30 * 60 + $cur_route->get_arrival_time()) { $new_route = $cur_route->copy(); $new_route->add_flight($flight); array_push($this->id, $flight['flight_id']); if ($new_route->get_trip_time() < 24 * 60 * 60) { $queue->insert($new_route, $new_route->get_joy()); } } } } return $result; }
public function process(ContainerBuilder $container) { if ($container->hasDefinition('templating')) { return; } if ($container->hasDefinition('templating.engine.php')) { $helpers = array(); foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) { if (isset($attributes[0]['alias'])) { $helpers[$attributes[0]['alias']] = $id; } } $definition = $container->getDefinition('templating.engine.php'); $arguments = $definition->getArguments(); $definition->setArguments($arguments); if (count($helpers) > 0) { $definition->addMethodCall('setHelpers', array($helpers)); } } if ($container->hasDefinition('templating.engine.delegating')) { $queue = new \SplPriorityQueue(); foreach ($container->findTaggedServiceIds('templating.engine') as $id => $attributes) { $queue->insert($id, isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0); } $engines = array(); foreach ($queue as $engine) { $engines[] = $engine; } $container->getDefinition('templating.engine.delegating')->addMethodCall('setEngineIds', array($engines)); } }
public function process(ContainerBuilder $container) { if (false === $container->hasDefinition('profiler')) { return; } $definition = $container->getDefinition('profiler'); $collectors = new \SplPriorityQueue(); $order = PHP_INT_MAX; foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $template = null; if (isset($attributes[0]['template'])) { if (!isset($attributes[0]['id'])) { throw new \InvalidArgumentException(sprintf('Data collector service "%s" must have an id attribute in order to specify a template', $id)); } $template = array($attributes[0]['id'], $attributes[0]['template']); } $collectors->insert(array($id, $template), array($priority, --$order)); } $templates = array(); foreach ($collectors as $collector) { $definition->addMethodCall('add', array(new Reference($collector[0]))); $templates[$collector[0]] = $collector[1]; } $container->setParameter('data_collector.templates', $templates); }
/** * Detach the listener from the events manager * * @param string eventType * @param object handler */ public function detach($eventType, $handler) { if (!is_object($handler)) { throw new \Exception("Event handler must be an Object"); } if (isset($this->_events[$eventType])) { if (is_object($this->_events[$eventType])) { // SplPriorityQueue hasn't method for element deletion, so we need to rebuild queue $newPriorityQueue = new PriorityQueue(); $newPriorityQueue->setExtractFlags(\SplPriorityQueue::EXTR_DATA); $priorityQueue->setExtractFlags(PriorityQueue::EXTR_BOTH); $priorityQueue->top(); while ($priorityQueue->valid()) { $data = $priorityQueue->current(); $priorityQueue->next(); if ($data['data'] !== $handler) { $newPriorityQueue->insert($data['data'], $data['priority']); } } $this->_events[$eventType] = $newPriorityQueue; } else { $key = array_search($handler, $priorityQueue, true); if ($key !== false) { unset($priorityQueue[$key]); } $this->_events[$eventType] = $priorityQueue; } } }
/** * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * * @throws \InvalidArgumentException */ public function process(ContainerBuilder $container) { // configure the profiler service if (FALSE === $container->hasDefinition('profiler')) { return; } $definition = $container->getDefinition('profiler'); $collectors = new \SplPriorityQueue(); $order = PHP_INT_MAX; foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $template = NULL; if (isset($attributes[0]['template'])) { if (!isset($attributes[0]['id'])) { throw new \InvalidArgumentException(sprintf('Data collector service "%s" must have an id attribute in order to specify a template', $id)); } if (!isset($attributes[0]['title'])) { throw new \InvalidArgumentException(sprintf('Data collector service "%s" must have a title attribute', $id)); } $template = [$attributes[0]['id'], $attributes[0]['template'], $attributes[0]['title']]; } $collectors->insert([$id, $template], [-$priority, --$order]); } $templates = []; foreach ($collectors as $collector) { $definition->addMethodCall('add', [new Reference($collector[0])]); $templates[$collector[0]] = $collector[1]; } $container->setParameter('data_collector.templates', $templates); // set parameter to store the public folder path $path = 'file:' . DRUPAL_ROOT . '/' . PublicStream::basePath() . '/profiler'; $container->setParameter('data_collector.storage', $path); }
public function execute() { // Get the application $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_ddcbalanceit'); if ($params->get('required_account') == 1) { $user = JFactory::getUser(); if ($user->get('guest')) { $app->redirect('index.php', JText::_('COM_DDCBALANCEIT_ACCOUNT_REQUIRED_MSG')); } } // Get the document object. $document = JFactory::getDocument(); $viewName = $app->input->getWord('view', 'dashboard'); $viewFormat = $document->getType(); $layoutName = $app->input->getWord('layout', 'default'); $app->input->set('view', $viewName); // Register the layout paths for the view $paths = new SplPriorityQueue(); $paths->insert(JPATH_COMPONENT . '/views/' . $viewName . '/tmpl', 'normal'); $viewClass = 'DdcbalanceitViews' . ucfirst($viewName) . ucfirst($viewFormat); $modelClass = 'DdcbalanceitModels' . ucfirst($viewName); if (false === class_exists($modelClass)) { $modelClass = 'DdcbalanceitModelsDefault'; } $view = new $viewClass(new $modelClass(), $paths); $view->setLayout($layoutName); // Render our view. echo $view->render(); return true; }
public function process(ContainerBuilder $container) { $definitions = new \SplPriorityQueue(); $order = PHP_INT_MAX; foreach ($container->getDefinitions() as $id => $definition) { if (!($decorated = $definition->getDecoratedService())) { continue; } $definitions->insert(array($id, $definition), array($decorated[2], --$order)); } foreach ($definitions as list($id, $definition)) { list($inner, $renamedId) = $definition->getDecoratedService(); $definition->setDecoratedService(null); if (!$renamedId) { $renamedId = $id . '.inner'; } // we create a new alias/service for the service we are replacing // to be able to reference it in the new one if ($container->hasAlias($inner)) { $alias = $container->getAlias($inner); $public = $alias->isPublic(); $container->setAlias($renamedId, new Alias((string) $alias, false)); } else { $definition = $container->getDefinition($inner); $public = $definition->isPublic(); $definition->setPublic(false); $container->setDefinition($renamedId, $definition); } $container->setAlias($inner, new Alias($id, $public)); } }
/** * Add a step to the current workflow * * @param Step $step * @param integer|null $priority * * @return $this */ public function addStep(Step $step, $priority = null) { $priority = null === $priority && $step instanceof PriorityStep ? $step->getPriority() : $priority; $priority = null === $priority ? 0 : $priority; $this->steps->insert($step, $priority); return $this; }
/** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('gremo_buzz')) { return; } // Build listeners queue from tagged services $listeners = new \SplPriorityQueue(); foreach ($container->findTaggedServiceIds('gremo_buzz.listener') as $id => $attrs) { $class = $container->getDefinition($id)->getClass(); $class = $container->getParameterBag()->resolveValue($class); $reflector = new \ReflectionClass($class); $interface = 'Buzz\\Listener\\ListenerInterface'; // Check if the service implements the above interface if (!$reflector->isSubclassOf($interface)) { throw new InvalidArgumentException(sprintf("Service '%s' must implement '%s'.", $id, $interface)); } // Add a reference to the listeners queue providing a default priority $listeners->insert(new Reference($id), isset($attrs[0]['priority']) ? $attrs[0]['priority'] : 0); } if (!empty($listeners)) { $browser = $container->getDefinition('gremo_buzz'); // Add listeners starting from those with higher priority foreach ($listeners as $listener) { $browser->addMethodCall('addListener', array($listener)); } } }
public static function getView($viewName, $layoutName = 'default', $viewFormat = 'html', $vars = null) { // Get the application $app = \Cobalt\Container::fetch('app'); $document = $app->getDocument(); $app->input->set('view', $viewName); // Register the layout paths for the view $paths = new \SplPriorityQueue(); $themeOverride = JPATH_THEMES . '/' . $app->get('theme') . '/html/' . strtolower($viewName); if (is_dir($themeOverride)) { $paths->insert($themeOverride, 'normal'); } $paths->insert(JPATH_COBALT . '/View/' . ucfirst($viewName) . '/tmpl', 'normal'); $viewClass = 'Cobalt\\View\\' . ucfirst($viewName) . '\\' . ucfirst($viewFormat); $modelClass = ucfirst($viewName); if (class_exists('Cobalt\\Model\\' . $modelClass) === false) { $modelClass = 'DefaultModel'; } $model = self::getModel($modelClass); /** @var $view \Joomla\View\AbstractHtmlView **/ $view = new $viewClass($model, $paths); $view->setLayout($layoutName); $view->document = $document; if (isset($vars)) { $view->bypass = true; foreach ($vars as $varName => $var) { $view->{$varName} = $var; } } return $view; }
public function execute() { // Get the document object. $document = $this->getApplication()->getDocument(); $viewFormat = $this->getInput()->getWord('format', 'html'); $viewName = $this->getInput()->getWord('view', 'dashboard'); $layoutName = $this->getInput()->getWord('layout', 'default'); $this->getInput()->set('view', $viewName); // Register the layout paths for the view $paths = new \SplPriorityQueue(); $themeOverride = JPATH_THEMES . '/' . $this->getApplication()->get('theme') . '/html/' . strtolower($viewName); if (is_dir($themeOverride)) { $paths->insert($themeOverride, 'normal'); } $paths->insert(JPATH_COBALT . '/View/' . ucfirst($viewName) . '/tmpl', 'normal'); $viewClass = 'Cobalt\\View\\' . ucfirst($viewName) . '\\' . ucfirst($viewFormat); $modelClass = ucfirst($viewName); if (class_exists('Cobalt\\Model\\' . $modelClass) === false) { $modelClass = 'DefaultModel'; } $model = $this->getModel($modelClass); /** @var $view \Joomla\View\AbstractHtmlView **/ $view = new $viewClass($model, $paths); $view->setLayout($layoutName); $view->document = $document; // Render our view. echo $view->render(); return true; }
protected function loadConfiguration() { $sources = new \SplPriorityQueue(); foreach ($this->getKomponents() as $komponent) { foreach ($komponent->getConfigurationSources($this->getContextName()) as $source) { $sources->insert($source, $source->getPriority()); } } $cfg = new TestConfigLoader(); $this->testLoader->loadConfigurationSources($cfg); foreach ($this->testLoader->findRules() as $rule) { $rule->loadConfigurationSources($cfg); } foreach ($cfg as $source) { $sources->insert($source, $source->getPriority()); } $loader = new ConfigurationLoader(); $loader->registerLoader(new PhpConfigurationLoader()); $loader->registerLoader(new YamlConfigurationLoader()); $config = new Configuration(); $params = $this->getContainerParams(); foreach ($sources as $source) { $config = $config->mergeWith($source->loadConfiguration($loader, $params)); } foreach ($this->testLoader->findRules() as $rule) { $config = $config->mergeWith($rule->loadConfiguration()); } return $config->mergeWith($this->testLoader->loadConfiguration()); }
/** * {@inheritDoc} */ public function __construct($options = null) { if (is_array($options) && !array_intersect(array_keys($options), array('constraints', 'stopOnError'))) { $options = array('constraints' => $options); } parent::__construct($options); // convert array of constraints into SplPriorityQueue if (is_array($this->constraints)) { $queue = new \SplPriorityQueue(); $constraints = $this->constraints; $constraints = array_reverse($constraints); foreach ($constraints as $index => $constraint) { $queue->insert($constraint, $index); } $this->constraints = $queue; } if (!$this->constraints instanceof \SplPriorityQueue) { throw new ConstraintDefinitionException('The option "constraints" is expected to be a SplPriorityQueue in constraint ' . __CLASS__ . '.'); } $constraintsCopy = $this->getConstraints(); // set extraction mode to both priority and data $constraintsCopy->setExtractFlags(\SplPriorityQueue::EXTR_BOTH); // loop through the priority chain for options validation while ($constraintsCopy->valid()) { $constraint = $constraintsCopy->current(); // fail if the constraint is not actually a constraint if (!$constraint['data'] instanceof Constraint) { throw new ConstraintDefinitionException('The option "constraints" (priority: ' . $constraint['priority'] . ') is not a Constraint, in ' . __CLASS__ . '.'); } // move to next constraint $constraintsCopy->next(); } }
/** * 刷新监听者队列 */ protected function refreshQueue() { $this->storage->rewind(); $this->queue = new \SplPriorityQueue(); foreach ($this->storage as $listener) { $priority = $this->storage->getInfo(); $this->queue->insert($listener, $priority); } }
/** * getEngine * * @return PhpEngine */ protected function getEngine() { $engine = new PhpEngine(); $paths = new \SplPriorityQueue(); $paths->insert(__DIR__ . '/tmpl', 0); $engine->setLayout('default'); $engine->setPaths($paths); return $engine; }
private function getRequestedContentTypes(ResponseInterface $response) : \SplPriorityQueue { preg_match_all('#(?:^|(?:, ?))(?P<type>[^/,;]+/[^/,;]+)[^,]*?(?:;q=(?P<weight>[01]\\.[0-9]+))?#uiD', $response->getContentType(), $matches); $types = new \SplPriorityQueue(); foreach ($matches['type'] as $idx => $type) { $types->insert($type, $matches['weight'][$idx] ?: 1.0); } return $types; }
/** * Method to load the paths queue. * * @return \SplPriorityQueue The paths queue. * * @since 1.0.0 */ protected function loadPaths() { $app = \JFactory::getApplication(); $theme = $app->get('theme'); $option = $app->input->getString('option'); $tmplPaths = new \SplPriorityQueue(); $tmplPaths->insert(JPATH_COMPONENT . '/views/' . $this->name . '/tmpl', 0); $tmplPaths->insert(JPATH_THEMES . '/' . $theme . '/html/' . $option . '/' . $this->name, 1); return $tmplPaths; }
/** * Method to instantiate the view. * * @param JModel $model The model object. * @param SplPriorityQueue $paths The paths queue. * * @since 3.2 */ public function __construct(JModel $model, SplPriorityQueue $paths = null) { $app = JFactory::getApplication(); $component = JApplicationHelper::getComponentName(); $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component); if (isset($paths)) { $paths->insert(JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName(), 2); } parent::__construct($model, $paths); }
public function process(ContainerBuilder $container) { $extensions = new \SplPriorityQueue(); foreach ($container->findTaggedServiceIds('symedit_menu.menu_extension') as $id => $tag) { $priority = isset($tag[0]['priority']) ? $tag[0]['priority'] : 0; $extensions->insert(new Reference($id), $priority); } $sortedExtensions = iterator_to_array($extensions); $menuProviderDefinition = $container->getDefinition('symedit_menu.provider.symedit'); $menuProviderDefinition->replaceArgument(2, $sortedExtensions); }
/** * Attach a filter to the chain * * @param callable|FilterInterface $callback * @param int $priority * @throws \InvalidArgumentException * @return FilterChain */ public function attach($callback, $priority = self::DEFAULT_PRIORITY) { if (!is_callable($callback)) { if (!$callback instanceof FilterInterface) { throw new \InvalidArgumentException(sprintf('Expected a valid PHP callback; received "%s"', is_object($callback) ? get_class($callback) : gettype($callback))); } $callback = [$callback, 'filter']; } $this->filters->insert($callback, $priority); return $this; }
/** * {@inheritdoc} */ public function process(ContainerBuilder $container) { $loaders = new \SplPriorityQueue(); foreach ($container->findTaggedServiceIds('symedit_theme.template_loader') as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $loaders->insert(new Reference($id), $priority); } $loaders = iterator_to_array($loaders); ksort($loaders); $container->getDefinition('symedit_theme.template.loader')->replaceArgument(0, array_values($loaders)); }
/** * Constructor. * * @param \SplPriorityQueue|string[] $paths * @param int $priority */ public function __construct($paths = array(), $priority = self::NORMAL) { if (!$paths instanceof \SplPriorityQueue) { $queue = new \SplPriorityQueue(); foreach ((array) $paths as $path) { $queue->insert($path, $priority); } $paths = $queue; } $this->paths = $paths; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { $paths = new \SplPriorityQueue(); $paths->insert('libraries/windwalker/resource/asset/{type}', 800); $paths->insert('libraries/windwalker/test/Asset/Stub/{type}', 500); $paths->insert('media/jui/{type}', 300); $paths->insert('media/{name}/{type}', 100); $this->instance = new AssetManager('test', $paths); $this->instance->setDoc($this->doc = new MockHtmlDocument()); $this->doc->reset(); }
/** * Finds all services with the given tag name and order them by their priority. * Can be replaced by PriorityTaggedServiceTrait when upgraded to Symfony 3.0. * * @param string $tagName * @param ContainerBuilder $container * * @return Reference[] */ private function findAndSortTaggedServices($tagName, ContainerBuilder $container) { $services = $container->findTaggedServiceIds($tagName); $queue = new \SplPriorityQueue(); foreach ($services as $serviceId => $tags) { foreach ($tags as $attributes) { $priority = isset($attributes['priority']) ? $attributes['priority'] : 0; $queue->insert(new Reference($serviceId), $priority); } } return iterator_to_array($queue, false); }
public static function addToDeactiveQueue(\SplPriorityQueue $queue, Block $location, $updateLevel) { if ($updateLevel <= 0) { return; } for ($s = 0; $s <= 5; $s++) { $sideBlock = $location->getSide($s); if ($sideBlock->getPowerLevel() === $updateLevel - 1) { $queue->insert($sideBlock, $sideBlock->getPowerLevel()); } } }
/** * The priority sorting algorithm has been backported from Symfony 3.2. * * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php * * @param ContainerBuilder $container * @param string $type */ private function registerDataProviders(ContainerBuilder $container, string $type) { $services = $container->findTaggedServiceIds('api_platform.' . $type . '_data_provider'); $queue = new \SplPriorityQueue(); foreach ($services as $serviceId => $tags) { foreach ($tags as $attributes) { $priority = $attributes['priority'] ?? 0; $queue->insert(new Reference($serviceId), $priority); } } $container->getDefinition('api_platform.' . $type . '_data_provider')->addArgument(iterator_to_array($queue, false)); }
public static function parse($query) { $list = new \SplPriorityQueue(); array_map(function ($e) use($list) { preg_match_all('(([^;]+)(?=\\s*;\\s*(\\w+)\\s*=\\s*([^;]+))*)', $e, $p); $params = array_map('trim', array_merge(['type' => current($p[0])], array_combine($p[2], $p[3]))); unset($params['']); $params['q'] = isset($params['q']) ? 1.0 * $params['q'] : ($params['q'] = 1.0); $list->insert($params, $params['q']); }, preg_split('(\\s*,\\s*)', $query)); return array_values(iterator_to_array($list)); }
/** * Поиск самого дешёвого пути между двумя локациями * Для поиска используется алгоритм Дейкстры * * @see http://www.sitepoint.com/data-structures-4/ * * @param array $data Массив с локациями и ценой проезда между ними [][src, dst, cost] * @param string $source Название исходного пункта * @param string $target Название конечного пункта * * @return SplStack */ function find_path(array $data, $source, $target) { $graph = build_graph($data); // массив лучших цен кратчайшего пути для каждой локации $best_cost = []; // массив предыдущих локаций для каждой локации $prev_loc = array(); // очередь из необработанных локаций $queue = new SplPriorityQueue(); foreach ($graph as $src => $dst) { $best_cost[$src] = INF; // изначальные значения цен бесконечны $prev_loc[$src] = null; // предыдущие локации неизвестны foreach ($dst as $name => $cost) { // используем цену как приоритет в очереди $queue->insert($name, $cost); } } // цена поездки в исходный пункт = 0 $best_cost[$source] = 0; while (!$queue->isEmpty()) { // получаем минимальную цену $u = $queue->extract(); if (empty($graph[$u])) { continue; } // обрабатываем доступные маршруты для локации foreach ($graph[$u] as $v => $cost) { // альтернативная цена для маршрута $alt = $best_cost[$u] + $cost; if ($alt < $best_cost[$v]) { // обновляем минимальную цену для локации $best_cost[$v] = $alt; // добавляем локацию в массив предыдущих локаций $prev_loc[$v] = $u; } } } // ищем дешёвый путь и складываем его в стек $stack = new SplStack(); $u = $target; $final_cost = 0; // проходим в обратном порядке от пункта назначения к исходному пункту while (isset($prev_loc[$u]) && $prev_loc[$u]) { $stack->push($u); $final_cost += $graph[$u][$prev_loc[$u]]; $u = $prev_loc[$u]; } $stack->push($source); return [$stack, $final_cost]; }
/** * Method to display global configuration. * * @return boolean True on success, false on failure. * * @since 3.2 */ public function execute() { // Get the application $app = $this->getApplication(); // Get the document object. $document = JFactory::getDocument(); $viewName = $this->input->getWord('view', 'templates'); $viewFormat = $document->getType(); $layoutName = $this->input->getWord('layout', 'default'); // Access backend com_config JLoader::register('TemplatesController', JPATH_ADMINISTRATOR . '/components/com_templates/controller.php'); JLoader::register('TemplatesViewStyle', JPATH_ADMINISTRATOR . '/components/com_templates/views/style/view.json.php'); JLoader::register('TemplatesModelStyle', JPATH_ADMINISTRATOR . '/components/com_templates/models/style.php'); $displayClass = new TemplatesController(); // Set backend required params $document->setType('json'); $this->input->set('id', $app->getTemplate('template')->id); // Execute backend controller $serviceData = json_decode($displayClass->display(), true); // Reset params back after requesting from service $document->setType('html'); $this->input->set('view', $viewName); // Register the layout paths for the view $paths = new SplPriorityQueue(); $paths->insert(JPATH_COMPONENT . '/view/' . $viewName . '/tmpl', 'normal'); $viewClass = 'ConfigView' . ucfirst($viewName) . ucfirst($viewFormat); $modelClass = 'ConfigModel' . ucfirst($viewName); if (class_exists($viewClass)) { if ($viewName != 'close') { $model = new $modelClass(); // Access check. if (!JFactory::getUser()->authorise('core.admin', $model->getState('component.option'))) { $app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); return; } } $view = new $viewClass($model, $paths); $view->setLayout($layoutName); // Push document object into the view. $view->document = $document; // Load form and bind data $form = $model->getForm(); if ($form) { $form->bind($serviceData); } // Set form and data to the view $view->form =& $form; // Render view. echo $view->render(); } return true; }