Example #1
0
 /**
  * Load all the options of a given plugin
  *
  * @param string $plugin The plugin to find the options of
  *
  * @return array All the options of the plugin with their values
  */
 public static function getPluginOptions($plugin)
 {
     if (!App::isInstalled()) {
         return array();
     }
     if (!isset(self::$options[$plugin])) {
         $options = OptionModel::getListByExample(new DBExample(array('plugin' => $plugin)));
         self::$options[$plugin] = array();
         foreach ($options as $option) {
             self::$options[$plugin][$option->key] = $option->value;
         }
     }
     return self::$options[$plugin];
 }
Example #2
0
<?php

/**
 * Initialise the plugin install
 *
 * @author  Elvyrra SAS
 * @license http://rem.mit-license.org/ MIT
 */
namespace Hawk\Plugins\Install;

if (!App::isInstalled()) {
    // First install page : Choose the language
    App::router()->get('install', '/install', array('action' => 'InstallController.setLanguage'));
    // Install Hawk
    App::router()->any('install-settings', '/install/settings/{language}', array('where' => array('language' => '[a-z]{2}'), 'action' => 'InstallController.settings'));
}
Example #3
0
 /**
  * Get the main menu items
  * @return array The main menu items
  */
 public function getMainMenu()
 {
     if (!App::isInstalled()) {
         return array();
     }
     $user = App::session()->getUser();
     $menus = array('applications' => array(), 'settings' => array());
     // Get the menus
     $items = MenuItem::getAvailableItems($user);
     // Filter the menus that have no action and no item
     $items = array_filter($items, function ($item) {
         return $item->action || count($item->visibleItems) > 0;
     });
     foreach ($items as $id => $item) {
         if ($item->labelKey === 'user.username') {
             $item->label = $user->getUsername();
         }
         if (in_array($item->plugin, PLugin::$mainPlugins)) {
             $menus['settings'][] = $item;
         } else {
             $menus['applications'][] = $item;
         }
     }
     // Trigger an event to add or remove menus from plugins
     $event = new Event(self::EVENT_AFTER_GET_MENUS, array('menus' => $menus));
     $event->trigger();
     $menus = $event->getData('menus');
     App::response()->setContentType('json');
     return $menus;
     return View::make(Theme::getSelected()->getView('main-menu.tpl'), array('menus' => $menus, 'logo' => Option::get('main.logo') ? Plugin::current()->getUserfilesUrl(Option::get('main.logo')) : ''));
 }
Example #4
0
 /**
  * Get the theme configured for the application
  *
  * @return Theme The selected theme
  */
 public static function getSelected()
 {
     return self::get(App::isInstalled() ? Option::get('main.selected-theme') : self::DEFAULT_THEME);
 }