Example #1
0
 protected function getInput()
 {
     $app = JFactory::getApplication();
     // Detect Gantry Framework or fail gracefully.
     if (!class_exists('Gantry5\\Loader')) {
         $app->enqueueMessage(JText::sprintf('MOD_GANTRY5_PLUGIN_MISSING', JText::_('MOD_GANTRY5_PARTICLE')), 'error');
         return '';
     }
     if (!defined('GANTRYADMIN_PATH')) {
         define('GANTRYADMIN_PATH', JPATH_ADMINISTRATOR . '/components/com_gantry5');
     }
     // Initialize administrator or fail gracefully.
     try {
         Gantry5\Loader::setup();
         $this->container = Gantry\Framework\Gantry::instance();
         $this->container['router'] = function ($c) {
             return new \Gantry\Admin\Router($c);
         };
     } catch (Exception $e) {
         $app->enqueueMessage(JText::sprintf($e->getMessage()), 'error');
         return '';
     }
     // FIXME: Better style detection.
     $style = \Gantry\Joomla\StyleHelper::getStyle(['home' => 1, 'client_id' => 0]);
     $this->container['router']->setStyle($style->id)->load();
     $field = ['default' => true, 'scope' => '', 'name' => $this->name, 'field' => ['type' => 'gantry.particle', 'label' => 'Particle', 'class' => 'input-small', 'picker_label' => 'Pick a Particle', 'overridable' => false], 'value' => json_decode($this->value, true)];
     $params = ['content' => $this->container['admin.theme']->render('@gantry-admin/forms/fields/gantry/particle.html.twig', $field)];
     return $this->container['admin.theme']->render('@gantry-admin/partials/layout.html.twig', $params);
 }
Example #2
0
 public function preset($id)
 {
     if (is_numeric($id)) {
         $style = StyleHelper::getStyle($id);
         $params = json_decode($style->params, true);
         $id = isset($params['preset']) ? $params['preset'] : 'default';
     }
     return $id;
 }
Example #3
0
 public function setAssignment($value)
 {
     $options = $this->assignmentOptions();
     if (!isset($options[$value])) {
         throw new \RuntimeException('Invalid value for default assignment!', 400);
     }
     $style = StyleHelper::getStyle($this->style_id);
     $style->home = $value;
     if (!$style->check() || !$style->store()) {
         throw new \RuntimeException($style->getError());
     }
     // Clean the cache.
     CacheHelper::cleanTemplates();
 }