Пример #1
0
 public function handleWeb(Request $request)
 {
     $preferences = $this->context->getService('preferences');
     $config = $this->context->getService('config');
     $uri = $this->context->getService('uri');
     $theme_instance = \Foolz\Theme\Loader::forge('foolslide');
     $theme_instance->addDir($config->get('foolz/foolslide', 'package', 'directories.themes'));
     $theme_instance->addDir(VAPPPATH . 'foolz/foolslide/themes/');
     $theme_instance->setBaseUrl($uri->base() . 'foolslide/');
     $theme_instance->setPublicDir(DOCROOT . 'foolslide/');
     // set an ->enabled on the themes we want to use
     /** @var Auth $auth */
     $auth = $this->context->getService('auth');
     if ($auth->hasAccess('maccess.admin')) {
         Event::forge('Foolz\\Foolframe\\Model\\System::environment.result')->setCall(function ($result) use($config) {
             $environment = $result->getParam('environment');
             foreach ($config->get('foolz/foolslide', 'environment') as $section => $data) {
                 foreach ($data as $k => $i) {
                     array_push($environment[$section]['data'], $i);
                 }
             }
             $result->setParam('environment', $environment)->set($environment);
         })->setPriority(0);
         foreach ($theme_instance->getAll() as $theme) {
             $theme->enabled = true;
         }
     } else {
         if ($themes_enabled = $preferences->get('foolslide.theme.active_themes')) {
             $themes_enabled = unserialize($themes_enabled);
         } else {
             $themes_enabled = ['foolz/foolslide-theme-foolslide' => 1];
         }
         foreach ($themes_enabled as $key => $item) {
             if (!$item && !$auth->hasAccess('maccess.admin')) {
                 continue;
             }
             try {
                 $theme = $theme_instance->get($key);
                 $theme->enabled = true;
             } catch (\OutOfBoundsException $e) {
             }
         }
     }
     try {
         $theme_name = $request->query->get('theme', $request->cookies->get($this->context->getService('config')->get('foolz/foolframe', 'config', 'config.cookie_prefix') . 'theme')) ?: $preferences->get('foolslide.theme.default');
         $theme_name_exploded = explode('/', $theme_name);
         // must get rid of the style
         if (count($theme_name_exploded) >= 2) {
             $theme_name = $theme_name_exploded[0] . '/' . $theme_name_exploded[1];
         }
         $theme = $theme_instance->get($theme_name);
         if (!isset($theme->enabled) || !$theme->enabled) {
             throw new \OutOfBoundsException();
         }
     } catch (\OutOfBoundsException $e) {
         $theme = $theme_instance->get('foolz/foolslide-theme-foolslide');
     }
     $theme->bootstrap();
 }
Пример #2
0
 public function before()
 {
     $this->notices = $this->getContext()->getService('notices');
     $this->uri = $this->getContext()->getService('uri');
     $this->config = $this->getContext()->getService('config');
     $this->install = new \Foolz\FoolFrame\Model\Install($this->getContext());
     $theme_instance = \Foolz\Theme\Loader::forge('foolframe_admin');
     $theme_instance->addDir(VENDPATH . 'foolz/foolframe/assets/themes-admin/');
     $theme_instance->setBaseUrl($this->uri->base() . 'foolframe/');
     $theme_instance->setPublicDir(DOCROOT . 'foolframe/');
     $this->theme = $theme_instance->get('foolz/foolframe-theme-admin');
     $this->builder = $this->theme->createBuilder();
     $this->builder->createLayout('base');
     $this->builder->createPartial('navbar', 'install/navbar');
     $this->builder->getProps()->addTitle(_i('FoolFrame Installation'));
     $this->param_manager = $this->builder->getParamManager();
     $this->param_manager->setParams(['context' => $this->getContext(), 'request' => $this->getRequest(), 'notices' => $this->notices, 'controller_title' => _i('FoolFrame Installation')]);
 }
Пример #3
0
 public function before()
 {
     $this->config = $this->getContext()->getService('config');
     $this->preferences = $this->getContext()->getService('preferences');
     $this->uri = $this->getContext()->getService('uri');
     $this->profiler = $this->getContext()->getService('profiler');
     $this->radix_coll = $this->getContext()->getService('foolslide.radix_collection');
     $this->media_factory = $this->getContext()->getService('foolslide.media_factory');
     $this->comment_factory = $this->getContext()->getService('foolslide.comment_factory');
     $this->ban_factory = $this->getContext()->getService('foolslide.ban_factory');
     $this->report_coll = $this->getContext()->getService('foolslide.report_collection');
     // this has already been forged in the foolslide bootstrap
     $theme_instance = \Foolz\Theme\Loader::forge('foolslide');
     if ($this->getQuery('theme')) {
         try {
             $theme_name = $this->getQuery('theme', $this->getCookie('theme')) ?: $this->preferences->get('foolslide.theme.default');
             $theme = $theme_instance->get($theme_name);
             if (!isset($theme->enabled) || !$theme->enabled) {
                 throw new \OutOfBoundsException();
             }
             $this->theme = $theme;
         } catch (\OutOfBoundsException $e) {
             $theme_name = 'foolz/foolslide-theme-foolslide';
             $this->theme = $theme_instance->get($theme_name);
         }
         $this->builder = $this->theme->createBuilder();
         $this->builder->getParamManager()->setParams(['context' => $this->getContext(), 'request' => $this->getRequest()]);
     }
     // convenience objects for saving some RAM
     $this->comment_obj = new Comment($this->getContext());
     $this->media_obj = new Media($this->getContext());
 }
Пример #4
0
 public function before()
 {
     $this->config = $this->getContext()->getService('config');
     $this->preferences = $this->getContext()->getService('preferences');
     $this->uri = $this->getContext()->getService('uri');
     $this->profiler = $this->getContext()->getService('profiler');
     $this->radix_coll = $this->getContext()->getService('foolfuuka.radix_collection');
     $this->media_factory = $this->getContext()->getService('foolfuuka.media_factory');
     $this->comment_factory = $this->getContext()->getService('foolfuuka.comment_factory');
     // this has already been forged in the foolfuuka bootstrap
     $theme_instance = \Foolz\Theme\Loader::forge('foolfuuka');
     try {
         $theme_name = $this->getQuery('theme', $this->getCookie('theme')) ?: $this->preferences->get('foolfuuka.theme.default');
         $theme_name_exploded = explode('/', $theme_name);
         if (count($theme_name_exploded) >= 2) {
             $theme_name = $theme_name_exploded[0] . '/' . $theme_name_exploded[1];
         }
         $theme = $theme_instance->get($theme_name);
         if (!isset($theme->enabled) || !$theme->enabled) {
             throw new \OutOfBoundsException();
         }
         $this->theme = $theme;
     } catch (\OutOfBoundsException $e) {
         $theme_name = 'foolz/foolfuuka-theme-foolfuuka';
         $this->theme = $theme_instance->get('foolz/foolfuuka-theme-foolfuuka');
     }
     // TODO this is currently bootstrapped in the foolfuuka bootstrap because we need it running before the router.
     //$this->theme->bootstrap();
     $this->builder = $this->theme->createBuilder();
     $this->param_manager = $this->builder->getParamManager();
     $this->builder->createLayout('chan');
     if (count($theme_name_exploded) == 3) {
         try {
             $this->builder->setStyle($theme_name_exploded[2]);
         } catch (\OutOfBoundsException $e) {
             // just let it go with default on getStyle()
         }
     }
     $pass = $this->getCookie('reply_password', '');
     $name = $this->getCookie('reply_name');
     $email = $this->getCookie('reply_email');
     // KEEP THIS IN SYNC WITH THE ONE IN THE POSTS ADMIN PANEL
     $to_bind = ['context' => $this->getContext(), 'request' => $this->getRequest(), 'user_name' => $name, 'user_email' => $email, 'user_pass' => $pass, 'disable_headers' => false, 'is_page' => false, 'is_thread' => false, 'is_last50' => false, 'order' => false, 'modifiers' => [], 'backend_vars' => ['user_name' => $name, 'user_email' => $email, 'user_pass' => $pass, 'site_url' => $this->uri->base(), 'default_url' => $this->uri->base(), 'archive_url' => $this->uri->base(), 'system_url' => $this->uri->base(), 'api_url' => $this->uri->base(), 'cookie_domain' => $this->config->get('foolz/foolframe', 'config', 'config.cookie_domain'), 'cookie_prefix' => $this->config->get('foolz/foolframe', 'config', 'config.cookie_prefix'), 'selected_theme' => $theme_name, 'csrf_token_key' => 'csrf_token', 'images' => ['banned_image' => $this->theme->getAssetManager()->getAssetLink('images/banned-image.png'), 'banned_image_width' => 150, 'banned_image_height' => 150, 'missing_image' => $this->theme->getAssetManager()->getAssetLink('images/missing-image.jpg'), 'missing_image_width' => 150, 'missing_image_height' => 150], 'gettext' => ['submit_state' => _i('Submitting'), 'thread_is_real_time' => _i('This thread is being displayed in real time.'), 'update_now' => _i('Update now'), 'ghost_mode' => _i('This thread has entered ghost mode. Your reply will be marked as a ghost post and will only affect the ghost index.')]]];
     $this->param_manager->setParams($to_bind);
     $this->builder->createPartial('tools_modal', 'tools_modal');
     $this->builder->createPartial('tools_search', 'tools_search');
     $this->builder->createPartial('tools_advanced_search', 'advanced_search');
 }
Пример #5
0
 /**
  * Selects the theme. Can be overridden so other controllers can use their own admin components
  *
  * @param Loader $theme_instance
  */
 public function setupTheme(Loader $theme_instance)
 {
     // we need to load more themes
     $theme_instance->addDir(VENDPATH . 'foolz/foolfuuka/public/themes-admin');
     $this->theme = $theme_instance->get('foolz/foolfuuka-theme-admin');
 }
Пример #6
0
 /**
  * Selects the theme. Can be overridden so other controllers can use their own admin components
  *
  * @param Loader $theme_instance
  */
 public function setupTheme(Loader $theme_instance)
 {
     // we need to load more themes
     $theme_instance->addDir(ASSETSPATH . 'public/themes-admin');
     $this->theme = $theme_instance->get('foolz/foolslide-theme-admin');
 }
Пример #7
0
 /**
  * Selects the theme. Can be overridden so other controllers can use their own admin components
  *
  * @param Loader $theme_instance
  */
 public function setupTheme(Loader $theme_instance)
 {
     $this->theme = $theme_instance->get('foolz/foolframe-theme-admin');
 }