public function display()
 {
     //编译按钮的属性
     foreach ($this->_buttonList as &$e) {
         $e['attr'] = $this->compileHtmlAttr($e['attr']);
     }
     unset($e);
     //显示页面
     $this->assign('title', $this->_title);
     $this->assign('list', $this->_list);
     $this->assign('buttonList', $this->_buttonList);
     $this->assign('savePostUrl', $this->_savePostUrl);
     parent::display('admin_sort');
 }
 /**
  * 显示分类树,仅支持内部调
  * @param  array $tree 分类树
  * @author Rocks
  */
 public function tree($tree = null)
 {
     if (empty($tree)) {
         echo '';
         return;
     }
     $this->assign('tree', $tree);
     parent::display('tree');
 }
 /**
  * $solist 判断是否属于选择返回数据的列表页,如果是在列表页->display('admin_solist');@mingyangliu
  * */
 public function display($solist = '')
 {
     //key类型的等价转换
     //map转换成text
     $this->convertKey('map', 'text', function ($value, $key) {
         return $key['opt'][$value];
     });
     //uid转换成text
     $this->convertKey('uid', 'text', function ($value) {
         $value = query_user(array('nickname', 'uid', 'space_url'), $value);
         return "<a href='" . $value['space_url'] . "' target='_blank'>[{$value[uid]}]" . $value['nickname'] . '</a>';
     });
     //nickname转换成text
     $this->convertKey('nickname', 'text', function ($value) {
         $value = query_user(array('nickname', 'uid', 'space_url'), $value);
         exit;
         return "<a href='" . $value['space_url'] . "' target='_blank'>[{$value[uid]}]" . $value['nickname'] . '</a>';
     });
     //time转换成text
     $this->convertKey('time', 'text', function ($value) {
         if ($value != 0) {
             return time_format($value);
         } else {
             return '-';
         }
     });
     //trunctext转换成text
     $this->convertKey('trunktext', 'text', function ($value, $key) {
         $length = $key['opt'];
         return msubstr($value, 0, $length);
     });
     //text转换成html
     $this->convertKey('text', 'html', function ($value) {
         return $value;
     });
     //link转换为html
     $this->convertKey('link', 'html', function ($value, $key, $item) {
         $value = htmlspecialchars($value);
         $getUrl = $key['opt'];
         $url = $getUrl($item);
         //允许字段为空,如果字段名为空将标题名填充到A变现里
         if (!$value) {
             return "<a href=\"{$url}\" target=\"_blank\">" . $key['title'] . "</a>";
         } else {
             return "<a href=\"{$url}\" target=\"_blank\">{$value}</a>";
         }
     });
     //如果icon为空
     $this->convertKey('icon', 'html', function ($value, $key, $item) {
         $value = htmlspecialchars($value);
         if ($value == '') {
             $html = "无";
         } else {
             $html = "<i class=\"{$value}\"></i> {$value}";
         }
         return $html;
     });
     //image转换为图片
     $this->convertKey('image', 'html', function ($value, $key, $item) {
         if (intval($value)) {
             //value是图片id
             $value = htmlspecialchars($value);
             $sc_src = get_cover($value, 'path');
             $src = getThumbImageById($value, 80, 80);
             $sc_src = $sc_src == '' ? $src : $sc_src;
             $html = "<div class='popup-gallery'><a title=\"查看大图\" href=\"{$sc_src}\"><img src=\"{$sc_src}\"/ style=\"width:80px;height:80px\"></a></div>";
         } else {
             //value是图片路径
             $sc_src = $value;
             $html = "<div class='popup-gallery'><a title=\"查看大图\" href=\"{$sc_src}\"><img src=\"{$sc_src}\"/ style=\"border-radius:100%;\"></a></div>";
         }
         return $html;
     });
     //doaction转换为html
     $this->convertKey('doaction', 'html', function ($value, $key, $item) {
         $actions = $key['opt']['actions'];
         $result = array();
         foreach ($actions as $action) {
             $getUrl = $action['get_url'];
             $linkText = $action['text'];
             $url = $getUrl($item);
             if (isset($action['opt'])) {
                 $content = array();
                 foreach ($action['opt'] as $key => $value) {
                     $value = htmlspecialchars($value);
                     $content[] = "{$key}=\"{$value}\"";
                 }
                 $content = implode(' ', $content);
                 if (isset($action['opt']['data-role']) && $action['opt']['data-role'] == "modal_popup") {
                     //模态弹窗
                     $result[] = "<a href=\" javascrapt:void(0);\" modal-url=\"{$url}\" " . $content . ">{$linkText}</a>";
                 } else {
                     $result[] = "<a href=\"{$url}\" " . $content . ">{$linkText}</a>";
                 }
             } else {
                 $result[] = "<a href=\"{$url}\">{$linkText}</a>";
             }
         }
         return implode(' ', $result);
     });
     //Join转换为html
     $this->convertKey('Join', 'html', function ($value, $key) {
         if ($value != 0) {
             $val = get_table_field($value, $key['opt']['mate'], $key['opt']['return'], $key['opt']['model']);
             if (!$key['opt']['url']) {
                 return $val;
             } else {
                 $urld = U($key['opt']['url'], array($key['opt']['return'] => $value));
                 return "<a href=\"{$urld}\">{$val}</a>";
             }
         } else {
             return '-';
         }
     });
     //status转换为html
     $setStatusUrl = $this->_setStatusUrl;
     $that =& $this;
     $this->convertKey('status', 'html', function ($value, $key, $item) use($setStatusUrl, $that) {
         //如果没有设置修改状态的URL,则直接返回文字
         $map = $key['opt'];
         $text = $map[$value];
         if (!$setStatusUrl) {
             return $text;
         }
         //返回带链接的文字
         $switchStatus = $value == 1 ? 0 : 1;
         $url = $that->addUrlParam($setStatusUrl, array('status' => $switchStatus, 'ids' => $item['id']));
         return "<a href=\"{$url}\" class=\"ajax-get\">{$text}</a>";
     });
     //如果html为空
     $this->convertKey('html', 'html', function ($value) {
         if ($value === '') {
             return '<span style="color:#bbb;">(空)</span>';
         }
         return $value;
     });
     //编译buttonList中的属性
     foreach ($this->_buttonList as &$button) {
         $button['tag'] = isset($button['attr']['href']) ? 'a' : 'button';
         $this->addDefaultCssClass($button);
         $button['attr'] = $this->compileHtmlAttr($button['attr']);
     }
     //生成翻页HTML代码
     C('VAR_PAGE', 'page');
     $pager = new \Think\Page($this->_pagination['totalCount'], $this->_pagination['listRows'], $_REQUEST);
     $pager->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
     $paginationHtml = $pager->show();
     //显示页面
     $this->assign('title', $this->_title);
     $this->assign('suggest', $this->_suggest);
     $this->assign('keyList', $this->_keyList);
     $this->assign('buttonList', $this->_buttonList);
     $this->assign('pagination', $paginationHtml);
     $this->assign('list', $this->_data);
     /*加入搜索 陈一枭*/
     $this->assign('searches', $this->_search);
     $this->assign('searchPostUrl', $this->_searchPostUrl);
     /*加入筛选select 郑钟良*/
     $this->assign('selects', $this->_select);
     $this->assign('selectPostUrl', $this->_selectPostUrl);
     //如果是选择返回数据的列表页就调用admin_solist模板文件,否则编译原有模板
     if ($solist) {
         parent::display('admin_solist');
     } else {
         parent::display('admin_list');
     }
 }
 public function display($templateFile = '', $charset = '', $contentType = '', $content = '', $prefix = '')
 {
     //将数据融入到key中
     foreach ($this->_keyList as &$e) {
         if ($e['type'] == 'multiInput') {
             $e['name'] = explode('|', $e['name']);
         }
         //修正在编辑信息时无法正常显示已经保存的地区信息/***修改的代码****/
         if (is_array($e['name'])) {
             $i = 0;
             $n = count($e['name']);
             while ($n > 0) {
                 $e['value'][$i] = $this->_data[$e['name'][$i]];
                 $i++;
                 $n--;
             }
         } else {
             $e['value'] = $this->_data[$e['name']];
         }
         //原代码
         /*$e['value'] = $this->_data[$e['name']];*/
     }
     //编译按钮的html属性
     foreach ($this->_buttonList as &$button) {
         $button['attr'] = $this->compileHtmlAttr($button['attr']);
     }
     //显示页面
     $this->assign('group', $this->_group);
     $this->assign('title', $this->_title);
     $this->assign('suggest', $this->_suggest);
     $this->assign('keyList', $this->_keyList);
     $this->assign('buttonList', $this->_buttonList);
     $this->assign('savePostUrl', $this->_savePostUrl);
     parent::display('admin_config');
 }
 public function display()
 {
     //将数据融入到key中
     foreach ($this->_keyList as &$e) {
         $e['value'] = $this->_data[$e['name']];
     }
     //编译按钮的html属性
     foreach ($this->_buttonList as &$button) {
         $button['attr'] = $this->compileHtmlAttr($button['attr']);
     }
     //显示页面
     $this->assign('title', $this->_title);
     $this->assign('keyList', $this->_keyList);
     $this->assign('buttonList', $this->_buttonList);
     $this->assign('savePostUrl', $this->_savePostUrl);
     parent::display('admin_config');
 }
Exemplo n.º 6
0
 public function display()
 {
     //key类型的等价转换
     //map转换成text
     $this->convertKey('map', 'text', function ($value, $key) {
         return $key['opt'][$value];
     });
     //uid转换成text
     $this->convertKey('uid', 'text', function ($value) {
         $value = query_user(array('username', 'uid', 'space_url'), $value);
         return "<a href='" . $value['space_url'] . "' target='_blank'>[{$value[uid]}]" . $value['username'] . '</a>';
     });
     //time转换成text
     $this->convertKey('time', 'text', function ($value) {
         return time_format($value);
     });
     //trunctext转换成text
     $this->convertKey('trunktext', 'text', function ($value, $key) {
         $length = $key['opt'];
         return msubstr($value, 0, $length);
     });
     //text转换成html
     $this->convertKey('text', 'html', function ($value) {
         return $value;
     });
     //link转换为html
     $this->convertKey('link', 'html', function ($value, $key, $item) {
         $value = htmlspecialchars($value);
         $getUrl = $key['opt'];
         $url = $getUrl($item);
         return "<a href=\"{$url}\">{$value}</a>";
     });
     //doaction转换为html
     $this->convertKey('doaction', 'html', function ($value, $key, $item) {
         $actions = $key['opt']['actions'];
         $result = array();
         foreach ($actions as $action) {
             $getUrl = $action['get_url'];
             $linkText = $action['text'];
             $url = $getUrl($item);
             $result[] = "<a href=\"{$url}\">{$linkText}</a>";
         }
         return implode(' ', $result);
     });
     //status转换为html
     $setStatusUrl = $this->_setStatusUrl;
     $that =& $this;
     $this->convertKey('status', 'html', function ($value, $key, $item) use($setStatusUrl, $that) {
         //如果没有设置修改状态的URL,则直接返回文字
         $map = $key['opt'];
         $text = $map[$value];
         if (!$setStatusUrl) {
             return $text;
         }
         //返回带链接的文字
         $switchStatus = $value == 1 ? 0 : 1;
         $url = $that->addUrlParam($setStatusUrl, array('status' => $switchStatus, 'ids' => $item['id']));
         return "<a href=\"{$url}\" class=\"ajax-get\">{$text}</a>";
     });
     //如果html为空
     $this->convertKey('html', 'html', function ($value) {
         if ($value === '') {
             return '<span style="color:#bbb;">(空)</span>';
         }
         return $value;
     });
     //编译buttonList中的属性
     foreach ($this->_buttonList as &$button) {
         $button['tag'] = isset($button['attr']['href']) ? 'a' : 'button';
         $this->addDefaultCssClass($button);
         $button['attr'] = $this->compileHtmlAttr($button['attr']);
     }
     //生成翻页HTML代码
     C('VAR_PAGE', 'page');
     $pager = new \Think\Page($this->_pagination['totalCount'], $this->_pagination['listRows'], $_REQUEST);
     $pager->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
     $paginationHtml = $pager->show();
     //显示页面
     $this->assign('title', $this->_title);
     $this->assign('keyList', $this->_keyList);
     $this->assign('buttonList', $this->_buttonList);
     $this->assign('pagination', $paginationHtml);
     $this->assign('list', $this->_data);
     /*加入搜索 陈一枭*/
     $this->assign('searches', $this->_search);
     $this->assign('searchPostUrl', $this->_searchPostUrl);
     parent::display('admin_list');
 }