/** * 表情转换,可以通过hook(zotop.smiles)扩展 * * */ public static function smiles($str) { $smiles = array(':)' => url::theme() . '/image/smiles/smile.gif', ':-)' => url::theme() . '/image/smiles/cool.gif'); $smiles = zotop::filter('zotop.smiles', $smiles); foreach ($smiles as $key => $val) { $str = str_replace($key, '<img src=' . $val . ' class="zotop-smile"/>', $str); } return $str; }
/** * 写入登陆信息 * */ public function login($data = array()) { $data = array_merge($this->data, (array) $data); $data = zotop::filter('zotop.user.login', $data); //刷新信息 $this->refresh(); //记录用户数据 zotop::user($data); return true; }
/** * 写入登陆信息 * */ public function login($data = array()) { $data = array_merge($this->bind(), (array) $data); $data = zotop::filter('zotop.user.login', $data); //刷新信息 $this->refresh(); //记录用户数据 zotop::user($data); zotop::log('login', zotop::t('用户 <b>{$username}</b> 于 {$time} 登陆成功', array('username' => $data['username'], 'time' => TIME))); return true; }
/** * 系统关闭,并输出渲染内容 * * @return string */ public static function shutdown() { //获取页面内容 $contents = ob_get_contents(); //清理输出数据 ob_end_clean(); //渲染页面内容 $contents = zotop::filter('system.render', $contents); //输入页面内容 echo $contents; }
public function sideAction() { $tools = array('reboot' => array('id' => 'reboot', 'title' => '系统重启', 'href' => zotop::url('zotop/system/reboot')), 'close' => array('id' => 'close', 'title' => '关闭网站', 'href' => zotop::url('zotop/system/close')), 'config' => array('id' => 'config', 'title' => '注册表管理', 'href' => zotop::url('zotop/config'))); $tools = zotop::filter('zotop.system.tools', $tools); $users = array('user' => array('id' => 'reboot', 'title' => '系统用户管理', 'href' => zotop::url('zotop/user')), 'usergroup' => array('id' => 'close', 'title' => '系统用户组管理', 'href' => zotop::url('zotop/usergroup'))); $modules = array('list' => array('id' => 'list', 'title' => '模块列表', 'href' => zotop::url('zotop/module')), 'install' => array('id' => 'uninstalled', 'title' => '安装新模块', 'href' => zotop::url('zotop/module/uninstalled'))); $page = new side(); $page->title = '系统控制面板'; $page->set('tools', $page->navlist($tools)); $page->set('users', $page->navlist($users)); $page->set('modules', $page->navlist($modules)); $page->display(); }
/** * 根据参数生成完整的URL,如:url::build('site://zotop/index/default/arg1/arg2',array('param1'=>'1'),'#top') * * @param string $uri 如:{application}://{module}/{controller}/{action}/{arg1}/arg2 组成 * @param array|string $params URL参数 ,一般为数组,也可以是字符串,如:param1/1/param2/2 * @param string $extra 额外数据:如锚点信息等 * @return string 如:/index.php/module/controller/action/arg1/arg2?param1=1¶m2=2#top */ public static function build($uri = '', $params = null, $extra = '') { $application = ''; if (strpos($uri, '://')) { list($application, $uri) = explode('://', $uri); } //获取入口文件地址 if (empty($application)) { $base = url::scriptname(); } else { $base = zotop::application($application, 'url') . '/' . zotop::application($application, 'base'); $base = url::decode($base); } //uri处理 if ($u = explode('/', trim($uri, '/'))) { //获取namespace 和 arguments $namespace = array_slice($u, 0, 3); $namespace = implode('/', $namespace); $arguments = array_slice($u, 3); //namespace切换 $namespace = zotop::filter('zotop.namespace', $namespace, &$arguments); foreach ($arguments as $arg) { $querystring .= '/' . $arg; } //querystring $querystring = $namespace . $querystring; $querystring = empty($querystring) ? '' : '/' . $uri; $querystring .= empty($suffix) ? '' : $suffix; } //处理id/5/n/6 形式的参数 if (!is_array($params)) { $args = explode('/', $params); while ($key = array_shift($args)) { $params[$key] = array_shift($args); } } if (is_array($params) && !empty($params)) { if (strpos($querystring, '?')) { $querystring .= '&' . http_build_query($params); } else { $querystring .= '?' . http_build_query($params); } } //组装url $url = $base . $querystring . $extra; $url = url::clean($url); return $url; }
/** * 解析URI * * URI 由模块名/控制器/动作/参数组成,采用如下的格式: * * @code php * module/controller/action/param1/param2 * @endcode * */ public static function execute() { $u = explode('/', trim(router::$uri, '/')); //获取namespace 和 arguments $namespace = implode('/', array_slice($u, 0, 3)); $arguments = array_slice($u, 3); $namespace = zotop::filter('zotop.namespace', $namespace, &$arguments); if ($namespace) { list(router::$module, router::$controller, router::$action) = explode('/', $namespace); } //处理参数 for ($i = 0, $cnt = count($arguments); $i < $cnt; $i++) { $arguments[$i] = rawurldecode($arguments[$i]); } router::$arguments = $arguments; }
function xheditor_rc1($attrs) { $attrs['class'] = isset($attrs['class']) ? 'editor ' . $attrs['class'] : 'editor'; $tools = array('image' => '<a href="' . zotop::url('system/image/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-imageuploader button-icon"></span><span class="button-text">插入图片</span></a>', 'file' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-fileuploader button-icon"></span><span class="button-text">插入文件</span></a>', 'template' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-template button-icon"></span><span class="button-text">插入模板</span></a>'); $tools = zotop::filter('editor.tools', $tools); $tools = arr::take('tools', $attrs) === false ? array() : $tools; $url = zotop::module('xheditor', 'url'); $html[] = html::script($url . '/editor/xheditor-zh-cn.min.js'); $html[] = html::script($url . '/common/global.js'); if (is_array($tools) && !empty($tools)) { $html[] = '<div class="field-toolbar">'; foreach ($tools as $tool) { $html[] = ' ' . $tool; } $html[] = '</div>'; } $html[] = ' ' . field::textarea($attrs); return implode("\n", $html); }
public function controls() { $controls = array(); $controls['folder']['name'] = '文件夹'; $controls['text']['name'] = '单行文本输入控件'; $controls['textarea']['name'] = '多行文本输入控件'; $controls['select']['name'] = '单选下拉控件'; $controls['select']['attr']['options'] = array('type' => 'textarea', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'description' => '每行一个,选项名称和选项值使用<b>|</b>隔开'); $controls['radio']['name'] = '单选按钮控件'; $controls['radio']['attr']['options'] = array('type' => 'textarea', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'description' => '每行一个,选项名称和选项值使用<b>|</b>隔开'); $controls['checkbox']['name'] = '复选框控件'; $controls['checkbox']['attr']['options'] = array('type' => 'textarea', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'description' => '每行一个,选项名称和选项值使用<b>|</b>隔开'); $controls['image']['name'] = '图片上传控件'; $controls['image']['attr']['upload'] = array('type' => 'radio', 'label' => '图片上传', 'options' => array(true => '允许上传', false => '不允许上传')); $controls['editor']['name'] = '富文本编辑器'; $controls['editor']['attr']['toolbar'] = array('type' => 'radio', 'label' => '编辑器类型', 'options' => array('basic' => '简洁型', 'standard' => '标准型', 'full' => '全功能型'), 'value' => 'standard'); $controls = zotop::filter('config.controls', $controls); return $controls; }
public function navbar() { $navbar = array('index' => array('id' => 'index', 'title' => '模型列表', 'href' => zotop::url('content/model')), 'add' => array('id' => 'add', 'title' => '添加模型', 'href' => zotop::url('content/model/add')), 'edit' => array('id' => 'edit', 'title' => '编辑模型', 'href' => '')); $navbar = zotop::filter('content.model.navbar', $navbar); return $navbar; }
public function controls() { $controls = array('width' => array('type' => 'text', 'name' => 'settings[width]', 'label' => '控件宽度', 'value' => '', 'valid' => '', 'description' => '控件的宽度,单位为<b>px</b>'), 'height' => array('type' => 'text', 'name' => 'settings[height]', 'label' => '控件高度', 'value' => '', 'valid' => '', 'description' => '控件的高度,单位为<b>px</b>'), 'style' => array('type' => 'text', 'name' => 'settings[style]', 'label' => '控件样式', 'value' => '', 'valid' => '', 'description' => '控件的style属性'), 'class' => array('type' => 'text', 'name' => 'settings[class]', 'label' => '控件风格', 'value' => '', 'valid' => '', 'description' => '控件的class属性'), 'options' => array('type' => 'textarea', 'name' => 'settings[options]', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'valid' => '', 'description' => '每行一个,值和数据使用<b> | </b>隔开'), 'upload' => array('type' => 'radio', 'name' => 'settings[upload]', 'options' => array('1' => '允许上传', '0' => '不允许上传'), 'label' => '上传设置', 'value' => '0', 'valid' => '')); $controls = zotop::filter('zotop.config.field.controls', $controls); return $controls; }
/** * 更新数据 * * @param mix $data 待更新的数据 * @param mix $where 条件 * * @return array */ public function update($data = array(), $where = '') { $data = empty($data) ? $this->bind() : $data; $data = zotop::filter($this->table() . '.update', $data, $where); $data = $this->_check_data($data); if (!is_array($where)) { $key = $this->key(); if (empty($where)) { if (isset($data[$key])) { $where = array($key, '=', $data[$key]); } else { $where = array($key, '=', $this->{$key}); } } if (is_numeric($where) || is_string($where)) { $where = array($key, '=', $where); } } if (is_array($data) && !empty($data) && !$this->error()) { $update = $this->db()->set($data)->where($where)->update(); } unset($data); return $update; }
public function navbar($categoryid = 0) { $navbar = array('index' => array('id' => 'index', 'title' => zotop::t('内容列表'), 'href' => zotop::url("content/content/index/{$categoryid}")), 'add' => array('id' => 'add', 'title' => zotop::t('添加内容'), 'href' => zotop::url("content/content/add/{$categoryid}")), 'edit' => array('id' => 'edit', 'title' => zotop::t('编辑内容')), 'category' => array('id' => 'category', 'title' => zotop::t('栏目设置'), 'href' => zotop::url("content/category/edit/{$categoryid}"), 'class' => 'dialog')); $navbar = zotop::filter('content.content.navbar', $navbar); return $navbar; }
public function navbar() { $navbar = array('index' => array('id' => 'index', 'title' => '首 页', 'href' => zotop::url('content')), 'setting' => array('id' => 'setting', 'title' => '模块设置', 'href' => zotop::url('content/setting'))); $navbar = zotop::filter('content.index.navbar', $navbar); return $navbar; }
public function status() { $status = array('100' => zotop::t('通过审核并发布'), '0' => zotop::t('等待审核'), '-1' => zotop::t('未通过审核'), '-50' => zotop::t('草稿')); $status = zotop::filter($this->table() . '.status', $status); return $status; }
/** * 删除数据 * * @param mix $where 删除条件 * * @return mix */ public function delete($where) { if (!is_array($where)) { $key = $this->key(); if (empty($where)) { $where = array($key, '=', $this->{$key}); } if (is_numeric($where) || is_string($where)) { $where = array($key, '=', $where); } } $data = zotop::filter($this->table() . '.delete', $data); return $this->db()->where($where)->delete(); }
public function navbar() { $navbar = array('index' => array('id' => 'index', 'title' => '首 页', 'href' => zotop::url('system/system'))); $navbar = zotop::filter('system.system.navbar', $navbar); return $navbar; }
public function navbar() { $navbar = array('main' => array('title' => '首页', 'href' => url::build('system/index/main')), 'phpinfo' => array('title' => 'phpinfo', 'href' => url::build('system/index/phpinfo'))); $navbar = zotop::filter('system.main.navbar', $navbar); return $navbar; }
public function navbar() { $navbar = array(array('id' => 'main', 'title' => '首页', 'href' => url::build('zotop/main')), array('id' => 'phpinfo', 'title' => 'phpinfo', 'href' => url::build('zotop/main/phpinfo'))); $navbar = zotop::filter('zotop.main.navbar', $navbar); return $navbar; }
public function navbar($dir = '/') { $navbar = array(array('id' => 'index', 'title' => '文件管理', 'href' => zotop::url('webftp/index/index', array('dir' => rawurlencode($dir)))), array('id' => 'folder/new', 'title' => '新建文件夹', 'href' => zotop::url('webftp/folder/new', array('dir' => rawurlencode($dir))), 'class' => 'dialog'), array('id' => 'file/new', 'title' => '新建文件', 'href' => zotop::url('webftp/file/new', array('dir' => rawurlencode($dir))), 'class' => 'dialog')); $navbar = zotop::filter('webftp.admin.index.navbar', $navbar); return $navbar; }
public function navbar($parentid = 0) { $navbar = array('index' => array('id' => 'index', 'title' => zotop::t('栏目列表'), 'href' => zotop::url("content/category/index/{$parentid}")), 'add' => array('id' => 'add', 'title' => zotop::t('添加子栏目'), 'href' => zotop::url("content/category/add/{$parentid}"), 'class' => 'dialog {width:650}')); $navbar = zotop::filter('content.category.navbar', $navbar); return $navbar; }
public function types() { $types = array('text' => zotop::t('文本'), 'document' => zotop::t('文档'), 'image' => zotop::t('图像'), 'video' => zotop::t('视频'), 'audio' => zotop::t('音频'), 'flash' => zotop::t('flash'), 'zip' => zotop::t('压缩文件'), 'unknown' => zotop::t('其它')); $types = zotop::filter('zotop.file.types', $types); return $types; }
public function controls() { $controls = array(); $controls['text']['name'] = '单行文本输入控件'; $controls['text']['attr']['type'] = array('type' => 'select', 'options' => array('VARCHAR' => '变长字符 VARCHAR(255)', 'CHAR' => '定长字符 CHAR(10)', 'int' => '整数 INT(10)', 'TINYINT' => '整数 TINYINT(3)', 'SMALLINT' => '整数 SMALLINT(5)', 'MEDIUMINT' => '整数 MEDIUMINT(8)'), 'label' => '数据类型', 'name' => 'type', 'valid' => 'required:true', 'value' => 'varchar', 'description' => ''); $controls['text']['attr']['maxlength'] = array('type' => 'text', 'label' => '字段长度', 'name' => 'maxlength', 'valid' => 'required:true,number:true,min:1,max:255', 'value' => 255, 'description' => ''); $controls['textarea']['name'] = '多行文本输入控件'; $controls['textarea']['attr']['type'] = array('type' => 'select', 'label' => '数据类型', 'options' => array('VARCHAR' => '变长字符 VARCHAR(255)', 'MEDIUMTEXT' => 'MEDIUMTEXT', 'TEXT' => 'TEXT'), 'name' => 'type', 'value' => 'MEDIUMTEXT', 'description' => ''); $controls['textarea']['attr']['maxlength'] = array('type' => 'text', 'label' => '字段长度', 'name' => 'maxlength', 'value' => '', 'valid' => 'number:true'); $controls['select']['name'] = '单选下拉控件'; $controls['select']['attr']['options'] = array('type' => 'textarea', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'description' => '每行一个,选项名称和选项值使用<b>|</b>隔开'); $controls['select']['attr']['type'] = array('type' => 'select', 'options' => array('VARCHAR' => '变长字符 VARCHAR(255)', 'CHAR' => '定长字符 CHAR(10)', 'int' => '整数 INT(10)', 'TINYINT' => '整数 TINYINT(3)', 'SMALLINT' => '整数 SMALLINT(5)', 'MEDIUMINT' => '整数 MEDIUMINT(8)'), 'label' => '数据类型', 'name' => 'type', 'valid' => 'required:true', 'value' => 'varchar', 'description' => ''); $controls['select']['attr']['maxlength'] = array('type' => 'text', 'label' => '字段长度', 'name' => 'maxlength', 'valid' => 'required:true,number:true,min:1,max:255', 'value' => 255, 'description' => ''); $controls['radio']['name'] = '单选按钮控件'; $controls['radio']['attr']['options'] = array('type' => 'textarea', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'description' => '每行一个,选项名称和选项值使用<b>|</b>隔开'); $controls['radio']['attr']['type'] = array('type' => 'select', 'options' => array('VARCHAR' => '变长字符 VARCHAR(255)', 'CHAR' => '定长字符 CHAR(10)', 'int' => '整数 INT(10)', 'TINYINT' => '整数 TINYINT(3)', 'SMALLINT' => '整数 SMALLINT(5)', 'MEDIUMINT' => '整数 MEDIUMINT(8)'), 'label' => '数据类型', 'name' => 'type', 'valid' => 'required:true', 'value' => 'varchar', 'description' => ''); $controls['radio']['attr']['maxlength'] = array('type' => 'text', 'label' => '字段长度', 'name' => 'maxlength', 'valid' => 'required:true,number:true,min:1,max:255', 'value' => 255, 'description' => ''); $controls['checkbox']['name'] = '复选框控件'; $controls['checkbox']['attr']['options'] = array('type' => 'textarea', 'label' => '控件选项', 'value' => '选项名称1|选项值1', 'description' => '每行一个,选项名称和选项值使用<b>|</b>隔开'); $controls['checkbox']['attr']['type'] = array('type' => 'select', 'options' => array('VARCHAR' => '变长字符 VARCHAR(255)', 'CHAR' => '定长字符 CHAR(10)', 'int' => '整数 INT(10)', 'TINYINT' => '整数 TINYINT(3)', 'SMALLINT' => '整数 SMALLINT(5)', 'MEDIUMINT' => '整数 MEDIUMINT(8)'), 'label' => '数据类型', 'name' => 'type', 'valid' => 'required:true', 'value' => 'varchar', 'description' => ''); $controls['checkbox']['attr']['maxlength'] = array('type' => 'text', 'label' => '字段长度', 'name' => 'maxlength', 'valid' => 'required:true,number:true,min:1,max:255', 'value' => 255, 'description' => ''); $controls['image']['name'] = '图片上传控件'; $controls['image']['attr']['upload'] = array('type' => 'radio', 'label' => '图片上传', 'options' => array(true => '允许上传', false => '不允许上传')); $controls['image']['attr']['type'] = array('type' => 'hidden', 'name' => 'type', 'value' => 'varchar'); $controls['image']['attr']['maxlength'] = array('type' => 'hidden', 'name' => 'maxlength', 'value' => 255); $controls['editor']['name'] = '富文本编辑器'; $controls['editor']['attr']['toolbar'] = array('type' => 'radio', 'label' => '编辑器类型', 'options' => array('basic' => '简洁型', 'standard' => '标准型', 'full' => '全功能型'), 'value' => 'standard'); $controls['editor']['attr']['type'] = array('type' => 'select', 'label' => '数据类型', 'options' => array('TEXT' => 'TEXT', 'MEDIUMTEXT' => 'MEDIUMTEXT'), 'name' => 'type', 'value' => 'MEDIUMTEXT', 'description' => ''); $controls['editor']['attr']['maxlength'] = array('type' => 'hidden', 'name' => 'maxlength', 'value' => ''); $controls['keywords']['name'] = '关键词控件'; $controls['keywords']['attr']['type'] = array('type' => 'hidden', 'name' => 'type', 'value' => 'varchar'); $controls['keywords']['attr']['maxlength'] = array('type' => 'hidden', 'name' => 'maxlength', 'value' => 255); $controls = zotop::filter('field.controls', $controls); return $controls; }
public function navbar() { $navbar = array('index' => array('id' => 'index', 'title' => '站点设置', 'href' => zotop::url('system/setting/index')), 'upload' => array('id' => 'upload', 'title' => '上传设置', 'href' => zotop::url('system/setting/upload')), 'cache' => array('id' => 'cache', 'title' => '缓存设置', 'href' => zotop::url('system/setting/cache')), 'theme' => array('id' => 'theme', 'title' => '主题设置', 'href' => zotop::url('system/setting/theme')), 'email' => array('id' => 'email', 'title' => '邮件设置', 'href' => zotop::url('system/setting/email'))); $navbar = zotop::filter('system.setting.navbar', $navbar); return $navbar; }
public function navbar() { $navbar = array(array('id' => 'default', 'title' => '文件管理', 'href' => url::build('filemanager/index'))); $navbar = zotop::filter('filemanager.index.navbar', $navbar); return $navbar; }
public function navbar($parentid = 'root') { $navbar = array(array('id' => 'index', 'title' => '节点列表', 'href' => zotop::url('system/config/index/' . $parentid)), array('id' => 'add', 'title' => '添加节点', 'href' => zotop::url('system/config/add/' . $parentid), 'class' => 'dialog')); $navbar = zotop::filter('system.config.navbar', $navbar, $parentid); return $navbar; }
public function navbar($modelid) { $navbar = array('index' => array('id' => 'index', 'title' => '字段列表', 'href' => zotop::url("content/field/index/{$modelid}")), 'add' => array('id' => 'add', 'title' => '添加字段', 'href' => zotop::url("content/field/add/{$modelid}")), 'edit' => array('id' => 'edit', 'title' => '编辑字段', 'href' => ''), 'preview' => array('id' => 'preview', 'title' => '预览', 'href' => zotop::url("content/field/preview/{$modelid}"))); $navbar = zotop::filter('content.field.navbar', $navbar); return $navbar; }