public static function init() { //get list of all registered modules self::$_modules = Jelly::select('module')->execute()->as_array('name'); //Jx_Debug::dump(self::$_modules,'module listing'); $paths = array(); //go through the modules directory and get directory names $iter = new DirectoryIterator(MODPATH); foreach ($iter as $f) { if (!$f->isDot() && $f->isDir()) { //compare with registered modules $fname = $f->getFilename(); if (self::isRegistered($fname)) { if (self::isActivated($fname) && !self::isPermanent($fname)) { //if registered, activated, and not permanent, run init.php for the module //permanent modules are initialized by Kohana directly. $path = MODPATH . $fname; $paths[] = realpath(MODPATH . $fname) . DS; } } else { self::register($fname); } } } Kohana::addPaths($paths); foreach ($paths as $path) { if (is_file($path . 'init.php')) { require_once $path . 'init.php'; } } }
/** * Gets a listing of all currently installed modules and whether they are active or not * @return void */ public function action_all() { $modules = Jx_Modules::get_all(); $data = array(); foreach ($modules as $name => $values) { $obj = new stdClass(); $obj->name = ucfirst($name); $obj->id = $values['id']; $obj->active = Jx_Modules::isActivated($name); $obj->permanent = Jx_Modules::isPermanent($name); $obj->version = Jx_Modules::getVersion($name); $data[] = $obj; } $this->template->data = $data; $this->template->success = true; }
public function before() { $this->session = Session::instance(); $this->config = Kohana::config('loader'); //search all activated modules for media and normalize in the //config array //Jx_Debug::dump(Jx_Modules::get_all()); foreach (Jx_Modules::get_all() as $mod => $arr) { $basePath = MODPATH . $mod . DS . 'media' . DS . $mod . DS; if ($arr['activated'] && file_exists($basePath)) { $create = false; $jsPath = null; $cssPath = null; $imgPath = null; $imgUrl = null; if (is_dir($basePath . 'js')) { $jsPath = $basePath . 'js' . DS; $create = true; } if (is_dir($basePath . 'css')) { $cssPath = $basePath . 'css' . DS; $create = true; } $img = false; if (is_dir($basePath . 'images')) { $imgPath = $basePath . 'images' . DS; $imgUrl = '../images/'; $create = true; $img = true; } if ($create && $img) { $this->config['repos'][$mod] = array('imageUrl' => $imgUrl, 'paths' => array('js' => $jsPath, 'css' => $cssPath, 'images' => $imgPath)); //Jx_Debug::dump($this->config['repos'][$mod], 'config for '.$mod); } elseif ($create) { $this->config['repos'][$mod] = array('paths' => array('js' => $jsPath, 'css' => $cssPath)); //Jx_Debug::dump($this->config['repos'][$mod], 'config for '.$mod); } } } //Jx_Debug::dump($this->config); }
<?php if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } //we need to go through and initialize all of the modules we need to use Jx_Modules::init(); Route::add('media', 'media/<action>/<file>(.<ext>)', null, 'admin')->defaults(array('controller' => 'media')); //add event callbacks as needed Jx_Event::addObserver(array('Jx_Modules', 'onGetAdminMenu'), 'getAdminMenu'); Jx_Event::addObserver(array('Jx_Settings', 'onGetAdminMenu'), 'getAdminMenu');