function _process($all_settings) { $setting = new base_setting($this->app); $setlib = $setting->source(); $typemap = array(SET_T_STR => 'text', SET_T_INT => 'number', SET_T_ENUM => 'select', SET_T_BOOL => 'bool', SET_T_TXT => 'text', SET_T_FILE => 'file', SET_T_IMAGE => 'image', SET_T_DIGITS => 'number'); $tabs = array_keys($all_settings); $html = view::ui()->form_start(array('tabs' => $tabs, 'method' => 'POST')); foreach ($tabs as $tab => $tab_name) { foreach ($all_settings[$tab_name] as $set) { $current_set = $pre_set = $this->app->getConf($set); if ($_POST['set'] && array_key_exists($set, $_POST['set'])) { if ($current_set != $_POST['set'][$set]) { $current_set = $_POST['set'][$set]; $this->app->setConf($set, $_POST['set'][$set]); } } $input_type = $typemap[$setlib[$set]['type']]; $form_input = array('title' => $setlib[$set]['desc'], 'type' => $input_type, 'name' => "set[" . $set . "]", 'tab' => $tab, 'value' => $current_set, 'options' => $setlib[$set]['options']); if ($input_type == 'select') { $form_input['required'] = true; } if ($input_type == 'image') { $form_input = array_merge($form_input, array('width' => $setlib[$set]['width'], 'height' => $setlib[$set]['height'])); } $html .= view::ui()->form_input($form_input); } } return $html .= view::ui()->form_end(1, app::get('ectools')->_('保存设置')); }
function block_help($params, $content, $template) { if (null !== $content) { $help_types = array('info' => array('size' => 18, 'icon' => app::get('desktop')->res_url . '/images/bundle/tips_info.gif'), 'help' => array('size' => 18, 'icon' => app::get('desktop')->res_url . '/images/bundle/tips_help.gif'), 'dialog' => array('size' => 18, 'icon' => app::get('desktop')->res_url . '/images/bundle/tips_info.gif', 'dialog' => 1), 'link' => array('size' => 15, 'icon' => app::get('desktop')->res_url . '/images/bundle/tips_help.gif'), 'link-mid' => array('size' => 14, 'icon' => app::get('desktop')->res_url . '/images/bundle/tips_help_mid.gif'), 'link-small' => array('size' => 12, 'icon' => app::get('desktop')->res_url . '/images/bundle/tips_help_small.gif')); $params['dom_id'] = view::ui()->new_dom_id(); if ($content = trim($content)) { $params['text'] = preg_replace(array('/\\n/', '/\\r/', '/\\"/', '/\'/'), array('<br>', '<br>', '"', '''), $content); } $params['type'] = isset($help_types[$params['type']]) ? $help_types[$params['type']] : $help_types['help']; $pagedata = (array) $params; $output = view::make('desktop/helper.html', $pagedata)->render(); return $output; } }
function function_wapheader() { $ret = '<base href="' . kernel::base_url(1) . '"/>'; $path = app::get('site')->res_full_url; $pathtopm = app::get('topm')->res_full_url; $debug_css = config::get('app.debug', false); $debug_js = config::get('app.debug', false); $css_mini = $debug_css ? '' : '.min'; $js_mini = $debug_js ? '' : '.min'; $cssver = view::ui()->getVer($debug_css); $jsver = view::ui()->getVer($debug_js); if ($debug_css) { $ret .= '<link rel="stylesheet" href="' . $pathtopm . '/stylesheets/base.css' . $cssver . '" />'; } else { $ret .= '<link rel="stylesheet" href="' . $pathtopm . '/stylesheets/base' . $css_mini . '.css' . $cssver . '" />'; } $ret .= '<link rel="stylesheet" href="' . $path . '/stylesheets/widgets_edit' . $css_mini . '.css' . $cssver . '" />'; $ret .= view::ui()->lang_script(array('src' => 'lang.js', 'app' => 'site')); $ret .= view::ui()->lang_script(array('src' => 'lang.js', 'app' => 'b2c', 'pdir' => 'js_mini')); if ($debug_js) { $ret .= '<script src="' . $path . '/scripts/lib/jquery.js' . $jsver . '"></script> <script src="' . $path . '/scripts/lib/jquery.cookie.js' . $jsver . '"></script> <script src="' . $pathtopm . '/scripts/gmu.js' . $jsver . '"></script> <script src="' . $pathtopm . '/scripts/common.js' . $jsver . '"></script> <script src="' . $pathtopm . '/scripts/zepto.js' . $jsver . '"></script> <script src="' . $path . '/scripts/tools.js' . $jsver . '"></script> <script src="' . $path . '/scripts/shopwidgets.js' . $jsver . '"></script>'; } else { $ret .= '<script src="' . $path . '/scripts/jquery' . $js_mini . '.js' . $jsver . '"></script> <script src="' . $path . '/scripts/ui' . $js_mini . '.js' . $jsver . '"></script> <script src="' . $path . '/scripts/shopwidgets' . $js_mini . '.js' . $jsver . '"></script>'; } if ($theme_info = app::get('site')->getConf('site.theme_' . app::get('site')->getConf('current_theme') . '_color')) { $theme_color_href = kernel::base_url(1) . '/themes/' . app::get('site')->getConf('current_theme') . '/' . $theme_info; $ret .= "<script>\n window.addEvent('domready',function(){\n new Element('link',{rel:'stylesheet',href:'" . $theme_color_href . "'}).inject(document.head);\n });\n </script>"; } /* $ret .= '<script> window.addEvent(\'domready\',function(){(parent.loadedPart[1])++}); parent.document.getElementById(\'loadpart\').style.display="none"; parent.document.getElementById(\'body\').style.display="block"; </script>'; */ foreach (kernel::serviceList('site_theme_view_helper') as $service) { if (method_exists($service, 'function_wapheader')) { $ret .= $service->function_wapheader(); } } return $ret; }
function new_mormal_tag() { $ex_p = '&wg=' . urlencode($_GET['wg']) . '&type=' . urlencode($_GET['type']) . '&app_id=' . urlencode($_GET['app_id']); if ($_POST) { $this->begin(); $tagmgr = $this->app->model('tag'); $data = array('tag_name' => $_POST['tag_name'], 'tag_abbr' => $_POST['tag_abbr'], 'tag_type' => $_GET['type'], 'app_id' => $_GET['app_id'], 'tag_mode' => 'normal', 'tag_bgcolor' => $_POST['tag_bgcolor']); $tagmgr->save($data); $this->end(); } else { $html = view::ui()->form_start(array('action' => $this->url . '&act=new_mormal_tag' . $ex_p)); $html .= view::ui()->form_input(array('title' => app::get('desktop')->_('标签名'), 'name' => 'tag_name')); $html .= view::ui()->form_input(array('title' => app::get('desktop')->_('标签备注'), 'maxlength' => '50', 'name' => 'tag_abbr')); $html .= view::ui()->form_input(array('title' => app::get('desktop')->_('标签背景色'), 'type' => 'color', 'name' => 'tag_bgcolor')); $html .= view::ui()->form_end(); echo $html; } }
function service() { echo '<h4 class="head-title" >' . app::get('desktop')->_('系统配置') . '</h4>'; if ($_POST) { $this->app->setConf('shopadminVcode', $_POST['shopamin_vocde']); } $services = app::get('base')->model('services'); $filter = array('content_type' => 'service_category', 'content_path' => 'select', 'disabled' => 1); $all_category = $services->getList('*', $filter); $filter = array('content_type' => 'service', 'disabled' => 1); $all_services = $services->getList('*', $filter); foreach ($all_services as $k => $row) { $vars = get_class_vars($row['content_path']); $servicelist[$row['content_name']][$row['content_path']] = $vars['name']; } $html .= view::ui()->form_start(array('method' => 'POST')); foreach ($all_category as $ik => $item) { if ($item['content_name'] == 'ectools_regions.ectools_mdl_regions') { unset($all_category[$ik]); continue; } $current_set = app::get('base')->getConf('service.' . $item['content_name']); if (@array_key_exists($item['content_name'], $_POST['service'])) { if ($current_set != $_POST['service'][$item['content_name']]) { $current_set = $_POST['service'][$item['content_name']]; app::get('base')->setConf('service.' . $item['content_name'], $current_set); } } $form_input = array('title' => $item['content_title'], 'type' => 'select', 'required' => true, 'name' => "service[" . $item['content_name'] . "]", 'tab' => $tab, 'value' => $current_set, 'options' => $servicelist[$item['content_name']]); $html .= view::ui()->form_input($form_input); } $select = $this->app->getConf('shopadminVcode'); if ($select === 'true') { $html .= "<tr><th><label>" . app::get('desktop')->_('后台登录启用验证码') . "</label></th><td> <select name='shopamin_vocde' type='select' ><option value='true' selected='selected'>" . app::get('desktop')->_('是') . "</option><option value='false' >" . app::get('desktop')->_('否') . "</option></select></td></tr>"; } else { $html .= "<tr><th><label>" . app::get('desktop')->_('后台登录启用验证码') . "</lable></th><td> <select name='shopamin_vocde' type='select' ><option value='true'>" . app::get('desktop')->_('是') . "</option><option value='false' selected='selected'>" . app::get('desktop')->_('否') . "</option></select></td></tr>"; } $html .= view::ui()->form_end(); $pagedata['_PAGE_CONTENT'] = $html; return $this->page(null, $pagedata); }
function function_header() { $ret = '<base href="' . kernel::base_url(1) . '"/>'; $path = app::get('site')->res_full_url; $debug_css = config::get('app.debug', false); $debug_js = config::get('app.debug', false); $css_mini = $debug_css ? '' : '.min'; $cssver = view::ui()->getVer($debug_css); $jsver = view::ui()->getVer($debug_js); $ret .= '<link rel="stylesheet" href="' . $path . '/stylesheets/widgets_edit' . $css_mini . '.css' . $cssver . '" />'; $ret .= view::ui()->lang_script(array('src' => 'lang.js', 'app' => 'site')); if ($debug_js) { $ret .= '<script src="' . $path . '/scripts/lib/mootools.js' . $jsver . '"></script> <script src="' . $path . '/scripts/lib/moomore.js' . $jsver . '"></script> <script src="' . $path . '/scripts/jstools.js' . $jsver . '"></script> <script src="' . $path . '/scripts/switchable.js' . $jsver . '"></script> <script src="' . $path . '/scripts/dragdropplus.js' . $jsver . '"></script> <script src="' . $path . '/scripts/widgetsinstance.js' . $jsver . '"></script>'; } else { $ret .= '<script src="' . $path . '/scripts/lib/mootools.min.js' . $jsver . '"></script> <script src="' . $path . '/scripts/ui.min.js' . $jsver . '"></script> <script src="' . $path . '/scripts/widgetsinstance.min.js' . $jsver . '"></script>'; } if ($theme_info = app::get('site')->getConf('site.theme_' . app::get('site')->getConf('current_theme') . '_color')) { $theme_color_href = kernel::base_url(1) . '/themes/' . app::get('site')->getConf('current_theme') . '/' . $theme_info; $ret .= "<script>\n window.addEvent('domready',function(){\n new Element('link',{href:'" . $theme_color_href . "',rel:'stylesheet'}).injectBottom(document.head);\n });\n </script>"; } /*$ret .= '<script> window.addEvent(\'domready\',function(){(parent.loadedPart[1])++}); parent.document.getElementById(\'loadpart\').style.display="none"; parent.document.getElementById(\'body\').style.display="block"; </script>'; */ foreach (kernel::serviceList('site_theme_view_helper') as $service) { if (method_exists($service, 'function_header')) { $ret .= $service->function_header(); } } return $ret; }
function _img_list() { $img = $this->app->model('image'); $html = ''; foreach ($img->getList('url,s_url,l_url,m_url,image_id,width,height,storage', $filter, 0, 20) as $item) { $url = ''; if ($item['storage'] == 'filesystem') { $url = kernel::get_resource_host_url(); } $url = $url . ($item['s_url'] ? $item['s_url'] : ($item['m_url'] ? $item['m_url'] : ($item['l_url'] ? $item['l_url'] : $item['url']))); if (max($item['width'], $item['height']) > 96) { $tag = ($item['width'] > $item['height'] ? 'width=' : 'height=') . '"96"'; } else { $tag = ''; } $html .= <<<EOF <div image_id="{$image_id}" style="text-align:center;vertical-align: middle;float:left;width:96px;height:96px;border:3px solid #ddd;margin:3px"> <img {$tag} src="{$url}" /> </div> EOF; } $pager = view::ui()->pager(array('current' => 2, 'total' => 200, 'link' => 'javascript:' . $this->var_name . '.page(%d)', 'nobutton' => false)); echo $html . $pager; }
public function index() { $post = $_POST; $typemap = array(SET_T_STR => 'text', SET_T_INT => 'number', SET_T_ENUM => 'select', SET_T_BOOL => 'bool', SET_T_TXT => 'text', SET_T_FILE => 'file', SET_T_IMAGE => 'image', SET_T_DIGITS => 'number'); $all_settings = config::get('sysconf'); $tabs = array_keys($all_settings); $html = view::ui()->form_start(array('tabs' => $tabs, 'method' => 'POST', 'id' => 'setting_form')); $input_style = false; $arrJs = array(); foreach ($tabs as $tab => $settings) { foreach ($all_settings[$settings] as $set => $setting) { $currentSet = $pre_set = app::get('sysconf')->getConf($set); if ($post['set'] && array_key_exists($set, $post['set'])) { if ($currentSet !== $post['set'][$set]) { $currentSet = $post['set'][$set]; app::get('sysconf')->setConf($set, $currentSet); } } $inputType = $typemap[$setting['type']]; $formInput = array('title' => $setting['desc'], 'type' => $typemap[$setting['type']], 'name' => "set[" . $set . "]", 'tab' => $tab, 'helpinfo' => $setting['helpinfo'], 'value' => $currentSet ? $currentSet : $setting['default'], 'options' => $setting['options'], 'vtype' => $setting['vtype'], 'class' => $setting['class'], 'id' => $setting['id'], 'default' => $setting['default']); if ($inputType == "select") { $formInput['required'] = true; } if (isset($setting['extends_attr']) && $setting['extends_attr'] && is_array($setting['extends_attr'])) { foreach ($setting['extends_attr'] as $key => $extends_attr) { $formInput[$key] = $extends_attr; } } $arrJs[] = $setting['javascript']; $html .= view::ui()->form_input($formInput); } } if (!$post) { $html .= view::ui()->form_end(); $strJs = '<script type="text/javascript">window.addEvent(\'domready\',function(){'; if (is_array($arrJs) && $arrJs) { foreach ($arrJs as $strJavascript) { $strJs .= $strJavascript; } } $strJs .= '$("main").addEvent("click",function(el){ el = el.target || el; if ($(el).get("id")){ var _id = $(el).get("id"); var _class_name = ""; if (_id.indexOf("-t") > -1){ _class_name = _id.substr(0, _id.indexOf("-t")); $$("."+_class_name).getParent("tr").show(); } if (_id.indexOf("-f") > -1){ _class_name = _id.substr(0, _id.indexOf("-f")); var _destination_node = $$("."+_class_name); _destination_node.getParent("tr").hide(); _destination_node.each(function(item){if (item.getNext(".caution") && item.getNext(".caution").hasClass("error")) item.getNext(".caution").remove();}); } } });'; $strJs .= '});</script>'; $pagedata['_PAGE_CONTENT'] .= $html . $strJs; return $this->page(null, $pagedata); } else { $this->begin(); return $this->end(true, app::get('sysconf')->_('当前配置修改成功!')); } }
public function getFinderPagerHtml() { $pre_btn_addon = $this->pagerInfo['current'] > 1 ? '' : 'disabled="disabled"'; $next_btn_addon = $this->pagerInfo['current'] < $this->pagerInfo['total'] ? '' : 'disabled="disabled"'; $from = $this->pagerInfo['from']; $to = $this->pagerInfo['to']; $pager = view::ui()->desktoppager(array('current' => $this->pagerInfo['current'], 'total' => $this->pagerInfo['total'], 'link' => 'javascript:' . $this->var_name . '.page(%d);')); $pagedata = $this->getCommonPagedata(); $pagedata['perPageSettingList'] = $this->plimit_in_sel; $pagedata['plimit'] = $this->pagelimit; $pagedata['from'] = $from; $pagedata['to'] = $to; $pagedata['pre_btn_addon'] = $pre_btn_addon; $pagedata['next_btn_addon'] = $next_btn_addon; $pagedata['pager'] = $pager; $pagedata['pinfo'] = $this->pagerInfo; return view::make('desktop/finder/view/pager.html', $pagedata)->render(); }
/** * 图片管理列表内容显示 * @param string 图片的tag * @param int 第几页的页面 * @return string html内容 */ function image_lib($tag = '', $page = 1) { $pagelimit = 12; //$otag = $this->app->model('tag'); $oimage = $this->app->model('images'); //$tags = $otag->getList('*',array('tag_type'=>'image')); $filter = array(); if ($tag) { $filter = array('tag' => array($tag)); } $images = $oimage->getList('*', $filter, $pagelimit * ($page - 1), $pagelimit); $count = $oimage->count($filter); $limitwidth = 100; foreach ($images as $key => $row) { $maxsize = max($row['width'], $row['height']); if ($maxsize > $limitwidth) { $size = 'width='; $size .= $row['width'] - $row['width'] * (($maxsize - $limitwidth) / $maxsize); $size .= ' height='; $size .= $row['height'] - $row['height'] * (($maxsize - $limitwidth) / $maxsize); } else { $size = 'width=' . $row['width'] . ' height=' . $row['height']; } $row['size'] = $size; $images[$key] = $row; } $pagedata['images'] = $images; $pagedata['pagers'] = view::ui()->pager(array('current' => $page, 'total' => ceil($count / $pagelimit), 'link' => '?app=image&ctl=admin_manage&act=image_lib&p[0]=' . $tag . '&p[1]=%d')); return view::make('image/image_lib.html', $pagedata); }
function input_select($params) { if (is_string($params['options'])) { if (!$params['id']) { $params['id'] = view::ui()->new_dom_id(); } $params['remote_url'] = $params['options']; $params['options'] = array($params['value'] => $params['value']); $script = '<script>$(\'' . $params['id'] . '\').addEvent(\'focus\',window.init_select)</script>'; } if ($params['rows']) { foreach ($params['rows'] as $r) { $step[$r[$params['valueColumn']]] = intval($r['step']); $options[$r[$params['valueColumn']]] = $r[$params['labelColumn']]; } unset($params['valueColumn'], $params['labelColumn'], $params['rows']); } else { $options = $params['options']; unset($params['options']); } $params['name'] = $params['search'] ? '_' . $params['name'] . '_search' : $params['name']; $params['class'] .= ' x-select'; $value = $params['value']; unset($params['value']); $html = utils::buildTag($params, 'select', false); if (!$params['required'] && $params['vtype'] != 'required') { $html .= '<option></option>'; } foreach ((array) $options as $k => $item) { if ($k === '0' || $k === 0) { $selected = $value === '0' || $value === 0; } else { $selected = $value == $k; } $t_step = $step[$k] ? str_repeat(' ', ($step[$k] - 1) * 3) : ''; $html .= '<option' . ($params['noselect'] ? ' disabled=true ' : ' ') . ($selected ? ' selected="selected"' : '') . ' value="' . htmlspecialchars($k) . '">' . $t_step . htmlspecialchars($item) . '</option>'; } $html .= '</select>'; return $html . $script; }
public function detail_edit($id) { $qb = app::get('site')->database()->createQueryBuilder(); $menu = $qb->select('*')->from('site_menus')->where('id=' . $qb->createPositionalParameter($id))->execute()->fetch(); if (!$menu) { return ''; } if (empty($menu['app'])) { $pagedata['menu'] = $menu; return view::make('site/admin/menu/edit_url.html', $pagedata); } else { $obj = kernel::service('site_menu.' . sprintf('%s_%s_%s', $menu['app'], $menu['ctl'], $menu['act'])); if ($obj) { $config = $menu['config']; foreach ($obj->inputs($config) as $title => $input) { $tmp['title'] = $title; $tmp['input'] = view::ui()->input($input); $html[] = $tmp; } $pagedata['menu'] = $menu; $pagedata['html'] = $html; return view::make('site/admin/menu/edit_app_module.html', $pagedata); } else { $pagedata['menu'] = $menu; return view::make('site/admin/menu/edit_module.html', $pagedata); } } }
function main() { $finder_aliasname = $_GET['finder_aliasname'] ? $_GET['finder_aliasname'] : $_POST['finder_aliasname']; if ($_POST['col']) { $finder_aliasname = $finder_aliasname . '.' . $this->controller->user->user_id; $cols = $this->app->setConf('view.' . $this->object_name . '.' . $finder_aliasname, implode(',', $_POST['col'])); if ($_POST['allcol']) { $this->app->setConf('listorder.' . $this->object_name . '.' . $finder_aliasname, implode(',', $_POST['allcol'])); } header('Content-Type:application/json; charset=utf-8'); echo '{success:"' . app::get('desktop')->_('设置成功') . '"}'; } else { $in_use = array_flip($this->getColumnNames()); $all_columns = $this->all_columns(); $listorder = explode(',', $this->app->getConf('listorder.' . $this->object_name . '.' . $finder_aliasname . '.' . $this->controller->user->user_id)); if ($listorder) { $ordered_columns = array(); foreach ($listorder as $col) { if (isset($all_columns[$col])) { $ordered_columns[$col] = $all_columns[$col]; unset($all_columns[$col]); } } $all_columns = array_merge((array) $ordered_columns, (array) $all_columns); $ordered_columns = null; } $domid = view::ui()->new_dom_id(); $html = '<div class="gridlist">'; $html .= '<form id="' . $domid . '" method="post" action="?' . $_SERVER['QUERY_STRING'] . '">'; $mv_handler = view::ui()->img(array('src' => 'bundle/grippy.gif', 'class' => 'move-handler', 'app' => 'desktop')); $i = 0; foreach ($all_columns as $key => $col) { $i++; $html .= '<div class="row">'; $html .= '<div class="row-line item"><input type="hidden" value="' . $key . '" name="allcol[]" />' . $mv_handler . '<input type="checkbox" ' . (isset($in_use[$key]) ? ' checked="checked" ' : '') . ' value="' . $key . '" name="col[]" id="finder-col-set-' . $i . '" /> <label for="finder-col-set-' . $i . '">' . app::get('desktop')->_($col['label']) . '</label></div>'; $html .= '</div>'; } $finder_id = $_GET['_finder']['finder_id']; $html .= '<!-----.mainHead-----↓ ' . app::get('desktop')->_('拖动改变顺序') . '-----.mainHead----->'; $html .= '<!-----.mainFoot-----<div class="table-action"><button class="btn btn-primary" onclick="$(\'' . $domid . '\').fireEvent(\'submit\',{stop:$empty})"><span><span>' . app::get('desktop')->_('保存提交') . '</span></span></button></div>-----.mainFoot----->'; $html .= '<input type="hidden" name="finder_aliasname" value="' . $finder_aliasname . '"/>'; $html .= '</form>'; $html .= '</div>'; $html .= <<<EOF <script> (function(){ var scrollAuto = new Scroller(\$('{$domid}').getContainer()); new Sortables(\$('{$domid}'),{clone:false,opacity:.5,handle:'.move-handler',onStart:function(){ \$('{$domid}').addClass('move-active'); scrollAuto.start(); },onComplete:function(){ scrollAuto.stop(); \$('{$domid}').removeClass('move-active'); }}); \$('{$domid}').store('target',{update:\$('main').getFirst(),onComplete:function(){ if(!\$\$('#{$domid} .row input[type=checkbox]:checked').length) return alert('请至少选择一列'); else { \$('{$domid}').getParent('.dialog').retrieve('instance').close(); window.finderGroup['{$finder_id}'].refresh(); } }}); })(); </script> EOF; return $html; } }
function input_object($params) { $return_url = $params['return_url'] ? $params['return_url'] : '?app=desktop&ctl=editor&act=object_rows'; $callback = $params['callback'] ? $params['callback'] : ''; $init = $params['data']['init'] ? $params['data']['init'] : ''; $params['breakpoint'] = isset($params['breakpoint']) ? $params['breakpoint'] : 20; $params['limitmax'] = $params['limitmax'] ? $params['limitmax'] : ''; $extendvalue = $params['extendvalue'] ? $params['extendvalue'] : ''; $object = $params['object']; if (strpos($params['object'], '@') !== false) { list($object, $app_id) = explode('@', $params['object']); $params['object'] = $object; } elseif ($params['app']) { $app_id = $params['app']; } else { throw new \InvalidArgumentException('missing app argument in typeo of object input tag in ' . __FILE__ . ' on line ' . __LINE__ . 'detail:' . var_export($params, 1)); } $app = app::get($app_id); $o = $app->model($object); $dbschema = $o->get_schema(); $params['app_id'] = $app_id; if (isset($params['filter'])) { if (!is_array($params['filter'])) { parse_str($params['filter'], $params['filter']); } } $params['domid'] = substr(md5(uniqid()), 0, 6); $key = $params['key'] ? $params['key'] : $dbschema['idColumn']; $textcol = $params['textcol'] ? $params['textcol'] : $dbschema['textColumn']; //显示列 可以多列显示 不完全修改 。。。。。。。 $textcol = explode(',', $textcol); $_textcol = $textcol; $textcol = $textcol[0]; $tmp_filter = $params['filter'] ? $params['filter'] : null; $count = $o->count($tmp_filter); if ($count <= $params['breakpoint'] && !$params['multiple'] && $params['select'] != 'checkbox') { if (strpos($textcol, '@') === false) { $list = $o->getList($key . ',' . $textcol, $tmp_filter); if (!$list[0]) { $type = array(); } foreach ($list as $row) { $label = $row[$textcol]; if (!$label && method_exists($o, 'title_modifier')) { $label = $o->title_modifier($row[$key]); } $type[$row[$key]] = $label; } } else { list($name, $table, $app_id) = explode('@', $textcol); $app = $app_id ? app::get($app_id) : $app; $mdl = $app->model($table); $list = $o->getList($key, $tmp_filter); foreach ($list as $row) { $tmp_row = $mdl->getList($name, array($mdl->idColumn => $row[$key]), 0, 1); $label = $tmp_row[0][$name]; if (!$label && method_exists($o, 'title_modifier')) { $label = $o->title_modifier($row[$key]); } $type[$row[$key]] = $label; } } $tmp_params['name'] = $params['name']; $tmp_params['value'] = $params['value']; $tmp_params['type'] = $type; if ($callback) { $tmp_params['onchange'] = $callback . '(this)'; } $str_filter = view::ui()->input($tmp_params); unset($tmp_params); return $str_filter; } $params['idcol'] = $keycol['keycol'] = $key; $params['textcol'] = implode(',', $_textcol); $params['_textcol'] = $_textcol; if ($params['value']) { if (strpos($params['view'], ':') !== false) { list($view_app, $view) = explode(':', $params['view']); $params['view_app'] = $view_app; $params['view'] = $view; } if (is_string($params['value'])) { $params['value'] = explode(',', $params['value']); } $params['items'] =& $o->getList('*', array($key => $params['value']), 0, -1); //过滤不存在的值 //某些数据被添加后 可能原表数据已删除,但此处value中还存在。 $_params_items_row_key = array(); foreach ($params['items'] as $k => $_params_items_row) { $_params_items_row_key[] = $_params_items_row[$key]; if ($extendvalue) { $params['items'][$k]['extendvalue'] = $extendvalue[$_params_items_row[$key]]; } } $params['value'] = implode(',', $_params_items_row_key); } if (isset($params['multiple']) && $params['multiple']) { if (isset($params['items']) && count($params['items'])) { $params['display_datarow'] = 'true'; } $pagedata['_input'] = $params; return view::make('desktop/finder/input.html', $pagedata)->render(); } else { if ($params['value'] && $params['select'] != 'checkbox') { $string = $params['items'][0][$textcol]; } else { $string = $params['emptytext'] ? $params['emptytext'] : app::get('desktop')->_('请选择...'); } $str_app = $params['app']; unset($params['app']); if ($params['data']) { $_params = (array) $params['data']; unset($params['data']); $params = array_merge($params, $_params); } if ($params['select'] == 'checkbox') { if ($params['default_id']) { $params['domid'] = $params['default_id']; } $params['type'] = 'checkbox'; } else { $id = "handle_" . $params['domid']; $params['type'] = 'radio'; $getdata = '&singleselect=radio'; } if (is_array($params['items'])) { foreach ($params['items'] as $key => $item) { $items[$key] = $item[$params['idcol']]; } } $params['return_url'] = urlencode($return_url); $vars = $params; $vars['items'] = $items; $getobject = array('obj_filter' => $vars['obj_filter'], 'filter' => $vars['filter'], 'name' => $vars['name'], 'object' => $vars['object']); $getobject = http_build_query($getobject); $object = http_build_query($vars); //$url = '?app=desktop&act=alertpages&goto='.urlencode('?app=desktop&ctl=editor&act=finder_common&app_id='.$app_id.'&'.$object.$getdata); $url = '?app=desktop&act=alertpages&goto=' . urlencode('?app=desktop&ctl=editor&act=finder_common&app_id=' . $app_id . '&' . $getobject . $getdata); $pagedata['string'] = $string; $pagedata['url'] = $url; $pagedata['app'] = 'app=' . $str_app; $pagedata['return_url'] = $return_url; $pagedata['id'] = $id; $pagedata['params'] = $params; $pagedata['object'] = $object; $pagedata['callback'] = $callback; $pagedata['init'] = $init; return view::make('desktop/finder/input_radio.html', $pagedata)->render(); } }
function main($object_name, $app, $filter = null, $cusrender = null) { if (strpos($_GET['object'], '@') !== false) { $tmp = explode('@', $object_name); $app = app::get($tmp[1]); $object_name = $tmp[0]; } $object = $app->model($object_name); $datatypes = kernel::single('base_db_datatype_manage')->load(); $this->dbschema = $object->get_schema(); $finder_id = $_GET['_finder']['finder_id']; foreach (kernel::servicelist('extend_filter_' . get_class($object)) as $extend_filter) { $colums = $extend_filter->get_extend_colums($this->finder_aliasname); if ($colums[$object_name]) { $this->dbschema['columns'] = array_merge((array) $this->dbschema['columns'], (array) $colums[$object_name]['columns']); } } foreach ($this->dbschema['columns'] as $c => $v) { if (!$v['filtertype']) { continue; } if (isset($filter[$c])) { continue; } if (!is_array($v['type'])) { if (strpos($v['type'], 'decimal') !== false && $v['filtertype'] == 'number') { $v['type'] = 'number'; } } $columns[$c] = $v; if (!is_array($v['type']) && $v['type'] != 'bool' && isset($datatypes[$v['type']]) && isset($datatypes[$v['type']]['searchparams'])) { $addon = '<select search="1" name="_' . $c . '_search" class="x-input-select inputstyle">'; foreach ($datatypes[$v['type']]['searchparams'] as $n => $t) { $addon .= "<option value='{$n}'>{$t}</option>"; } $addon .= '</select>'; } else { if ($v['type'] != 'bool') { $addon = app::get('desktop')->_('是'); } else { $addon = ''; } } $columns[$c]['addon'] = $addon; if ($v['type'] == 'last_modify') { $v['type'] = 'time'; } $params = array('type' => $v['type'], 'name' => $v['finder_filter_name'] ? $v['finder_filter_name'] : $c); if ($v['type'] == 'bool' && $v['default']) { $params = array_merge(array('value' => $v['default']), $params); } if ($this->name_prefix) { $params['name'] = $this->name_prefix . '[' . $params['name'] . ']'; } if ($v['type'] == 'region') { $params['app'] = 'ectools'; } if ($v['default_value']) { $params['value'] = $v['default_value']; } $inputer = view::ui()->input($params); $columns[$c]['inputer'] = $inputer; } if ($cusrender) { return array('filter_cols' => $columns, 'filter_datatypes' => $datatypes); } if ($object->has_tag) { $pagedata['app_id'] = $app->app_id; $pagedata['tag_type'] = $object_name; $tag_inputer = view::make('desktop/finder/tag_inputer.html', $pagedata)->render(); $columns['tag'] = array('filtertype' => true, 'filterdefault' => true, 'label' => app::get('desktop')->_('标签'), 'inputer' => $tag_inputer); } $pagedata['columns'] = $columns; $pagedata['datatypes'] = $datatypes; $pagedata['finder_id'] = $finder_id; return view::make('desktop/finder/finder_filter.html', $pagedata)->render(); }
function tag_edit($id) { $this->url = '?app=' . $_GET['app'] . '&ctl=' . $_GET['ctl']; $mdl_tag = app::get('desktop')->model('tag'); $tag = $mdl_tag->dump($id, '*'); $html = view::ui()->form_start(array('action' => $this->url . '&act=new_mormal_tag' . $ex_p, 'id' => 'tag_form_add', 'method' => 'post')); $html .= view::ui()->form_input(array('title' => app::get('desktop')->_('标签名'), 'name' => 'tag_name', 'value' => $tag['tag_name'])); $html .= view::ui()->form_input(array('title' => app::get('desktop')->_('标签备注'), 'name' => 'tag_abbr', 'value' => $tag['tag_abbr'])); $html .= view::ui()->form_input(array('title' => app::get('desktop')->_('标签颜色'), 'type' => 'color', 'name' => 'tag_bgcolor', 'value' => $tag['tag_bgcolor'])); //$html .= view::ui()->form_input(array('title'=>app::get('desktop')->_('标签字体色'),'type'=>'color','name'=>'tag_fgcolor','value'=>$tag['tag_fgcolor'])); $html .= '<input type="hidden" name="tag_id" value="' . $id . '"/>'; $html .= '<input type="hidden" name="app_id" value="' . $tag['app_id'] . '"/>'; $html .= '<input type="hidden" name="type" value="' . $tag['tag_type'] . '"/>'; $html .= view::ui()->form_end(); echo $html; echo <<<EOF <script> window.addEvent('domready', function(){ \$('tag_form_add').store('target',{ onComplete:function(){ if(window.finderGroup['{$_GET['finder_id']}']) window.finderGroup['{$_GET['finder_id']}'].refresh(); if(\$('tag_form_add').getParent('.dialog')) \$('tag_form_add').getParent('.dialog').retrieve('instance').close(); } }); }); </script> EOF; exit; }
function _compile_ui_function($function, $arguments, &$_result) { if (method_exists(view::ui(), $function)) { $buildArguments = $this->buildArgsArray($arguments); $_result = '<?php echo '; $_result .= 'view::ui()->' . $function . '(' . $buildArguments . ');'; $_result .= '?>'; return true; } else { return false; } }