예제 #1
0
파일: modules.php 프로젝트: vanie3/appland
 public function render($position, $params = array(), $content = null)
 {
     $renderer = $this->_doc->loadRenderer('module');
     $buffer = '';
     foreach (MModuleHelper::getModules($position) as $mod) {
         $buffer .= $renderer->render($mod, $params, $content);
     }
     return $buffer;
 }
예제 #2
0
파일: helper.php 프로젝트: vanie3/appland
 public static function startWidgets($option)
 {
     $modules = MModuleHelper::getModules();
     foreach ($modules as $module) {
         if (!is_object($module)) {
             continue;
         }
         if (!strpos($module->module, $option)) {
             continue;
         }
         $class_name = $module->module . '_widget';
         if (!defined($class_name)) {
             define($class_name, $class_name);
         }
         eval('class ' . $class_name . ' extends MWidget {public $class_name = ' . $class_name . ';};');
         add_action('widgets_init', create_function('', 'return register_widget(' . $class_name . ');'));
     }
 }
예제 #3
0
파일: module.php 프로젝트: vanie3/appland
 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;
 }
예제 #4
0
 public function modulePreDisplay()
 {
     # check
     $option = MRequest::getCmd('option');
     if (!empty($option)) {
         return;
     }
     # get all sidebar widgets
     $sidebars_widgets = wp_get_sidebars_widgets();
     unset($sidebars_widgets['wp_inactive_widgets']);
     # get all miwi modules
     mimport('framework.application.module.helper');
     $modules = MModuleHelper::getModules();
     # load sidebar modules
     foreach ($modules as $module) {
         foreach ($sidebars_widgets as $_sidebars_widgets) {
             $is_in = preg_grep("/" . $module->id . "_widget./", $_sidebars_widgets);
             if (!empty($is_in)) {
                 MModuleHelper::renderModule($module);
                 $loaded[$module->id] = $module->id;
                 break;
             }
         }
     }
 }
예제 #5
0
파일: html.php 프로젝트: vanie3/appland
 public function countModules($condition)
 {
     $operators = '(\\+|\\-|\\*|\\/|==|\\!=|\\<\\>|\\<|\\>|\\<=|\\>=|and|or|xor)';
     $words = preg_split('# ' . $operators . ' #', $condition, null, PREG_SPLIT_DELIM_CAPTURE);
     for ($i = 0, $n = count($words); $i < $n; $i += 2) {
         // odd parts (modules)
         $name = strtolower($words[$i]);
         $words[$i] = isset(parent::$_buffer['modules'][$name]) && parent::$_buffer['modules'][$name] === false ? 0 : count(MModuleHelper::getModules($name));
     }
     $str = 'return ' . implode(' ', $words) . ';';
     return eval($str);
 }
예제 #6
0
파일: helper.php 프로젝트: vanie3/appland
 protected static function &_load($module_id = null)
 {
     /*if (self::$modules !== null) {
     			return self::$modules;
     		}*/
     mimport('framework.filesystem.folder');
     if (!MFolder::exists(MPATH_MODULES)) {
         self::$modules = 0;
         return self::$modules;
     }
     $folders = MFolder::folders(MPATH_MODULES);
     if (empty($folders)) {
         self::$modules = 0;
         return self::$modules;
     }
     self::$modules = array();
     foreach ($folders as $folder) {
         if (strpos($folder, 'quickicons')) {
             continue;
         }
         $mod = new stdClass();
         $mod->id = $folder;
         $mod->title = $folder;
         $mod->module = $folder;
         $mod->name = $folder;
         $mod->menuid = 0;
         $mod->position = $folder;
         $mod->user = 0;
         $mod->params = null;
         $mod->style = null;
         $mod->content = '';
         $mod->showtitle = 0;
         $mod->control = '';
         $params = MFactory::getWOption('widget_' . $folder . '_widget', false, $module_id);
         if ($params != null) {
             $mod->params = json_encode($params);
         }
         self::$modules[] = $mod;
     }
     return self::$modules;
 }