Exemple #1
0
 /**
  * Configuration plugin action.
  *
  * @param null $plugin
  */
 public function config($plugin = null)
 {
     $plugin = UnionPlugin::aliasToName($plugin);
     $alias = UnionPlugin::nameToAlias($plugin);
     $pluginName = UnionPlugin::getFullName($plugin);
     $isLoaded = CakePlugin::loaded($plugin);
     if ($isLoaded) {
         $configs = $this->Plugins->find()->where(['alias' => $alias])->first();
         if (!$configs) {
             $configs = $this->Plugins->newEntity(['params' => [], 'alias' => $alias, 'name' => $pluginName]);
         }
         if ($this->request->is(['post', 'put'])) {
             $configs = $this->Plugins->patchEntity($configs, $this->request->data);
             if ($result = $this->Plugins->save($configs)) {
                 $this->Flash->success(__d('extensions', 'The settings has been saved.'));
                 return $this->Union->setRedirect(['apply' => ['action' => 'config', $result->alias]]);
             } else {
                 $this->Flash->error(__d('extensions', 'The settings could not be saved. Please, try again.'));
             }
         }
         Event::dispatch($plugin . '.Config.Admin.Controller', $this);
         $this->set('configs', $configs);
         $this->viewBuilder()->templatePath('Admin/Plugin');
         $this->render($plugin . '.config');
     } else {
         throw new MissingPluginException(['plugin' => $plugin]);
     }
 }
Exemple #2
0
 /**
  * Entity constructor.
  *
  * @param array $properties
  * @param array $options
  */
 public function __construct(array $properties = [], array $options = [])
 {
     $Theme = Theme::getInstance();
     if (isset($properties['alias'])) {
         $name = UnionPlugin::aliasToName($properties['alias']);
         $this->_xmlPath = $Theme->getPath() . $name . DS . $Theme->getFileName();
     }
     if ($this->_xmlPath) {
         $xml = Xml::build($this->_xmlPath);
         if ($xml instanceof \SimpleXMLElement) {
             $this->_xmlAttr = $Theme->setAttributes($xml);
         }
     }
     parent::__construct($properties, $options);
 }
Exemple #3
0
 /**
  * Create theme thumb popup.
  *
  * @return null|string
  */
 public function thumb()
 {
     $plugin = Plugin::aliasToName($this->_theme->get('alias'));
     return $this->Html->image($plugin . '.' . $this->_prevView, ['alt' => $plugin, 'popup' => true, 'url' => $this->Url->assetUrl($plugin . '.' . $this->_thumb, ['pathPrefix' => Configure::read('App.imageBaseUrl')]), 'class' => 'img-thumbnail']);
 }
Exemple #4
0
 /**
  * Get CakePHP plugin name from alias.
  *
  * @return string
  */
 public function getName()
 {
     return UnionPlugin::aliasToName($this->get('alias'));
 }
Exemple #5
0
 /**
  * On before bulk table delete (Delete theme folder).
  *
  * @param Event $event
  * @return bool
  */
 public function onModelBulkBeforeDelete(Event $event)
 {
     $theme = $event->data['theme'];
     $themeName = Plugin::aliasToName($theme->get('alias'));
     return $this->_deleteTheme($themeName);
 }