Example #1
0
 protected function _fetchData(KViewContext $context)
 {
     $state = $this->getModel()->getState();
     $container = $this->getModel()->getContainer();
     $config = new KObjectConfig($state->config);
     $config->append(array('router' => array('defaults' => array('option' => 'com_' . substr($container->slug, 0, strpos($container->slug, '-')), 'routed' => '1')), 'initial_response' => true))->append($this->getConfig()->config);
     if ($config->initial_response === true) {
         $count = 0;
         $query = $state->getValues();
         unset($query['config']);
         $query['thumbnails'] = $this->getModel()->getContainer()->getParameters()->thumbnails;
         if (strpos($this->getLayout(), 'compact') !== false) {
             $query['limit'] = 0;
             $count = ComFilesIteratorDirectory::countNodes(array('path' => $this->getModel()->getPath()));
         }
         if ($count < 100) {
             $controller = $this->getObject('com:files.controller.node');
             $controller->getRequest()->setQuery($query);
             $config->initial_response = $controller->format('json')->render();
         } else {
             unset($config->initial_response);
         }
     }
     $state->config = $config->toArray();
     $context->data->sitebase = trim(JURI::root(), '/');
     $context->data->token = $this->getObject('user')->getSession()->getToken();
     $context->data->container = $container;
     $context->data->debug = KClassLoader::getInstance()->isDebug();
     parent::_fetchData($context);
     $context->parameters = $state->getValues();
     $context->parameters->config = $config;
 }
 protected function _actionDispatch(KDispatcherContextInterface $context)
 {
     $job_dispatcher = $this->getController();
     $context = $job_dispatcher->getContext();
     $job_dispatcher->synchronize($context);
     $job_dispatcher->dispatch($context);
     $result = array('continue' => (bool) $job_dispatcher->getNextJob(), 'logs' => KClassLoader::getInstance()->isDebug() ? $context->getLogs() : array());
     $context->request->setFormat('json');
     $context->response->setContent(json_encode($result), 'application/json');
     $context->response->headers->set('Cache-Control', 'no-cache');
     $this->send();
 }
Example #3
0
 /**
  * Constructor
  *
  * Prevent creating instances of this class by making the constructor private
  *
  * @param  array  $config An optional array with configuration options.
  */
 private final function __construct($config = array())
 {
     //Initialize the root path
     if (isset($config['root_path'])) {
         $this->_root_path = $config['root_path'];
     } else {
         $this->_root_path = realpath($_SERVER['DOCUMENT_ROOT']);
     }
     //Initialize the base path
     if (isset($config['base_path'])) {
         $this->_base_path = $config['base_path'];
     } else {
         $this->_base_path = $this->_root_path;
     }
     //Initialize the vendor path
     if (isset($config['vendor_path'])) {
         $this->_vendor_path = $config['vendor_path'];
     } else {
         $this->_vendor_path = $this->_root_path . '/libraries/vendor';
     }
     //Load the legacy functions
     require_once dirname(__FILE__) . '/legacy.php';
     //Setup the loader
     require_once dirname(__FILE__) . '/class/loader.php';
     if (!isset($config['class_loader'])) {
         $config['class_loader'] = KClassLoader::getInstance($config);
     }
     //Setup the factory
     $manager = KObjectManager::getInstance($config);
     //Register the component class locator
     $manager->getClassLoader()->registerLocator(new KClassLocatorComponent(array('namespaces' => array('\\' => $this->_base_path . '/components', 'Koowa' => dirname(dirname(__FILE__))))));
     //Register the component object locator
     $manager->registerLocator('lib:object.locator.component');
     //Register the composer class locator
     if (file_exists($this->getVendorPath())) {
         $manager->getClassLoader()->registerLocator(new KClassLocatorComposer(array('vendor_path' => $this->getVendorPath())));
     }
     //Warm-up the stream factory
     $manager->getObject('lib:filesystem.stream.factory');
 }