/** * 视图回调函数[显示小挂件] * * @author Garbin * @param array $options * @return void */ function display_widgets($options) { $area = isset($options['area']) ? $options['area'] : ''; $page = isset($options['page']) ? $options['page'] : ''; if (!$area || !$page) { return; } include_once ROOT_PATH . '/includes/widget.base.php'; /* 获取该页面的挂件配置信息 */ $widgets = get_widget_config($this->_get_template_name(), $page); /* 如果没有该区域 */ if (!isset($widgets['config'][$area])) { return; } /* 将该区域内的挂件依次显示出来 */ foreach ($widgets['config'][$area] as $widget_id) { $widget_info = $widgets['widgets'][$widget_id]; $wn = $widget_info['name']; $options = $widget_info['options']; $widget =& widget($widget_id, $wn, $options); $widget->display(); } }
/** * 配置挂件 * * @author Garbin * @param none * @return void */ function config_widget() { if (!IS_POST) { return; } $name = !empty($_GET['name']) ? trim($_GET['name']) : null; $id = !empty($_GET['id']) ? trim($_GET['id']) : null; /* 当前所编辑的页面 */ $page = !empty($_GET['page']) ? trim($_GET['page']) : null; if (!$name || !$id || !$page) { $this->_config_respond('_d.setTitle("' . Lang::get('no_such_widget') . '");_d.setContents("message", {text:"' . Lang::get('no_such_widget') . '"});'); return; } $page_config = get_widget_config(Conf::get('template_name'), $page); $widget =& widget($id, $name, $page_config['widgets'][$id]['options']); $options = $widget->parse_config($_POST); if ($options === false) { $this->json_error($widget->get_error()); return; } $page_config['tmp'][$id]['options'] = $options; /* 保存配置信息 */ $this->_save_page_config(Conf::get('template_name'), $page, $page_config); /* 返回即时更新的数据 */ $widget->set_options($options); $contents = $widget->get_contents(); $this->_config_respond('DialogManager.close("config_dialog");parent.disableLink(parent.$(document.body));parent.$("#' . $id . '").replaceWith(document.getElementById("' . $id . '").parentNode.innerHTML);parent.init_widget("#' . $id . '");', $contents); }