Exemplo n.º 1
0
 public function __construct($options = array())
 {
     // Load the menu items
     $this->load();
     foreach ($this->_items as $item) {
         if ($item->home) {
             $this->_default[trim($item->language)] = $item->id;
         }
         // Decode the item params
         $result = new MRegistry();
         $result->loadString($item->params);
         $item->params = $result;
     }
 }
Exemplo n.º 2
0
 public function render($module, $attribs = array(), $content = null)
 {
     if (!is_object($module)) {
         $title = isset($attribs['title']) ? $attribs['title'] : null;
         $module_id = isset($attribs['number']) ? $attribs['number'] : null;
         $module = MModuleHelper::getModule($module, $title, $module_id);
         if (!is_object($module)) {
             if (is_null($content)) {
                 return '';
             } else {
                 $tmp = $module;
                 $module = new stdClass();
                 $module->params = null;
                 $module->module = $tmp;
                 $module->id = 0;
                 $module->user = 0;
             }
         }
     }
     // Get the user and configuration object
     // $user = MFactory::getUser();
     $conf = MFactory::getConfig();
     // Set the module content
     if (!is_null($content)) {
         $module->content = $content;
     }
     // Get module parameters
     $params = new MRegistry();
     $params->loadString($module->params);
     // Use parameters from template
     if (isset($attribs['params'])) {
         $template_params = new MRegistry();
         $template_params->loadString(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
         $params->merge($template_params);
         $module = clone $module;
         $module->params = (string) $params;
     }
     $contents = MModuleHelper::renderModule($module, $attribs);
     return $contents;
 }
Exemplo n.º 3
0
 protected static function _load($option)
 {
     if (isset(self::$components[$option]) and self::$components[$option] !== null) {
         return true;
     }
     mimport('framework.filesystem.folder');
     $folders = MFolder::folders(MPATH_WP_PLG);
     if (empty($folders)) {
         self::$components[$option] = new stdClass();
         return false;
     }
     self::$components = array();
     $n = count($folders);
     for ($i = 0; $i < $n; $i++) {
         $folder = @$folders[$i];
         if (empty($folder)) {
             continue;
         }
         if (substr($folder, 0, 4) != 'miwo') {
             continue;
         }
         $com = new stdClass();
         $com->id = $i;
         $com->option = 'com_' . $folder;
         $com->params = MFactory::getWOption($folder);
         $com->enabled = 1;
         // Convert the params to an object.
         if (is_string($com->params)) {
             $temp = new MRegistry();
             $temp->loadString($com->params);
             $com->params = $temp;
         }
         self::$components[$com->option] = $com;
     }
     return true;
 }
Exemplo n.º 4
0
 public static function renderModule($module, $attribs = array())
 {
     static $chrome;
     if (constant('MDEBUG')) {
         MProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     $app = MFactory::getApplication();
     // Record the scope.
     $scope = $app->scope;
     // Set scope to component name
     $app->scope = $module->module;
     // Get module parameters
     $params = new MRegistry();
     $params->loadString($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = MPATH_MODULES . '/' . $module->module . '/' . $module->module . '.php';
     // Load the module
     // $module->user is a check for 1.0 custom modules and is deprecated refactoring
     if (empty($module->user) && file_exists($path)) {
         $lang = MFactory::getLanguage();
         // 1.5 or Core then 1.6 3PD
         $lang->load($module->module, MPATH_BASE, null, false, true) || $lang->load($module->module, dirname($path), null, false, true);
         $content = '';
         ob_start();
         include $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     include_once MPATH_MODULES . '/modules.php';
     $chromePath = MPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             include_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     // Make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     //revert the scope
     $app->scope = $scope;
     if (constant('MDEBUG')) {
         MProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     return $module->content;
 }
Exemplo n.º 5
0
 public function getItem($pk = null)
 {
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the MObject before adding other data.
     $properties = $table->getProperties(1);
     $item = MArrayHelper::toObject($properties, 'MObject');
     if (property_exists($item, 'params')) {
         $registry = new MRegistry();
         $registry->loadString($item->params);
         $item->params = $registry->toArray();
     }
     return $item;
 }