public function execute() { $addressbook = new AddressBookService(); $this->data['groups'] = $addressbook->getAllGroups($this->uid); $this->data['title'] = 'addressbook'; $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); }
public function execute() { $password = md5($this->context->post('password')); $username = trim($this->context->post('username')); if ($username && $password) { $addressbookService = new AddressBookService(); $uid = $addressbookService->getUserIdByName($username); if ($uid) { $data = $addressbookService->getUserById($uid); } else { $data = array(); } if ($data && $data['password'] == $password) { $authCode = $data['uid'] . "\t" . $data['password']; $this->message = "登陆成功"; } else { $this->message = "帐号密码错误"; $authCode = ''; } /** * 保存时间86400秒(一天) */ C("LtCookie")->setCookie('auth', $authCode, time() + 86400); $this->data['forward'] = C('LtUrl')->generate('Default', 'Index'); } else { $this->message = "请输入帐号和密码登陆"; $this->data['forward'] = C('LtUrl')->generate('User', 'Login'); } $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); $this->data['title'] = '用户登陆'; $this->responseType = 'tpl'; $this->layout = 'result'; }
public function execute() { $page = $this->context->get('page'); $page = max(intval($page), 1); $page_size = $this->configHandle->get('page_size'); if (empty($page_size)) { $page_size = 25; } $param['limit'] = $page_size; $param['offset'] = ($page - 1) * $page_size; $param['op'] = $this->context->get('op'); $param['gid'] = $this->context->post('gid'); $param['q'] = $this->context->post('q'); $param['field'] = $this->context->post('field'); // userid $uid = $this->data['uid']; $addressBookService = new AddressBookService(); // 取当前用户通讯录的所有分组 $this->data['groups'] = $addressBookService->getAllGroups($uid); $this->data['data'] = $addressBookService->getAddressBookListByUserId($uid, $param); $count = $this->data['data']['count']; // 分页 :page 会自动被替换掉 $base_url = LtObjectUtil::singleton('LtUrl')->generate('Default', 'Index', array('page' => ':page')); $pagination = new LtPagination(); $pagination->init(); $this->data['pages'] = $pagination->pager($page, $count, $base_url); // 页面标题 $this->data['title'] = 'addressbook'; // 入口文件url路径 $this->data['baseurl'] = $this->configHandle->get('baseurl'); }
public function execute() { $this->code = 200; $this->message = "Welcome, please signin"; $this->data["username"] = "******"; $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); }
public function execute() { $gid = $this->context->get('gid'); $addressbook = new AddressBookService(); $this->data['group'] = $addressbook->getGroupsById($this->uid, $gid); $this->data['title'] = 'addressbook'; $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); }
public function __construct() { if (!$this->configHandle instanceof LtConfig) { if (class_exists("LtObjectUtil", false)) { $this->configHandle = LtObjectUtil::singleton("LtConfig"); } else { $this->configHandle = new LtConfig(); } } }
public function __construct() { $this->db = LtObjectUtil::singleton('LtDb'); $this->dbh = $this->db->getDbHandle(); $this->smc = $this->db->getSqlMapClient(); //必需在子类赋值 //$this->table = $db->getTDG('your-table-name'); //必需在子类赋值 //$this->primaryKey = 'primary-key'; }
public function execute() { $data = $this->context->post('data'); $data['uid'] = $this->uid; $addressbook = new AddressBookService(); $addressbook->addAddressBook($data); $this->code = 200; $this->data['forward'] = C('LtUrl')->generate('Default', 'Index'); $this->data['title'] = 'addressbook'; $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); $this->layout = 'result'; }
public function execute() { $id = $this->context->get('id'); $addressbook = new AddressBookService(); $addressbook->delAddressBook($id); $this->code = 200; $this->message = '删除成功'; $this->data['title'] = 'addressbook'; $this->data['forward'] = C('LtUrl')->generate('Default', 'Index'); $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); $this->layout = 'result'; }
public function execute() { $gid = $this->context->get('gid'); $addressbook = new AddressBookService(); $addressbook->deleteGroup($this->uid, $gid); $this->code = 200; $this->message = '删除成功'; $this->data['title'] = 'addressbook'; $this->data['forward'] = C('LtUrl')->generate('Groups', 'Index'); $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); $this->responseType = 'tpl'; $this->layout = 'result'; }
public function execute() { $data = $this->context->post('data'); $addressbook = new AddressBookService(); $addressbook->updateGroup($this->uid, $data); $this->code = 200; $this->data['forward'] = C('LtUrl')->generate('Groups', 'Index'); $this->data['title'] = 'addressbook'; $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); $this->responseType = 'tpl'; $this->layout = 'result'; // 使用不同的页面布局 }
public function beforeExecute() { // layout setting $this->responseType = "tpl"; $layout = "Do" == substr($this->context->uri["action"], 0, 2) ? "resultPage" : "defaultPage"; $this->layout = $layout; $this->data["baseurl"] = ($baseURL = LtObjectUtil::singleton("LtConfig")->get("baseurl")) ? $baseURL : "/"; $this->data["HtmlEditor"] = null; $this->data["topMenus"] = null; $this->data["footerJS"] = null; $this->data["title"] = $layout == "resultPage" ? "操作提示" : "运维管理"; $this->data['moduleType'] = array('java', 'jar', 'php', 'c'); }
/** * 最常用的使用方式(推荐) * ------------------------------------------------------------------- * LtObjectUtil要求: * # 通过singleton()管理单件 * * ------------------------------------------------------------------- * LtObjectUtil建议(不强求): * # 使用singleton()方法时,参数的大小写 和类名大小写最好保持一致 * * 本测试用例期望效果: * 实现单件模式:通过singleton()多次获取实例,实际使用的都是同一个实例 */ public function testSingleton() { /** * 这是唯一一个不遵守“Lotus组件初始化三步曲”规则的组件 * 因为它需要用个冒号静态调用 */ $countInst = count(LtObjectUtil::$instances); $obj1 = LtObjectUtil::singleton("stdClass"); //stdClass是php内置的类 $obj2 = LtObjectUtil::singleton("stdClass"); $countInst = count(LtObjectUtil::$instances) - $countInst; $this->assertTrue($obj1 === $obj2); $this->assertEquals(1, $countInst); $obj2->prop = 1; $this->assertEquals(1, $obj1->prop); }
/** * 调用singleton()传入空值 * * @expectedException PHPUnit_Framework_Error */ public function testBlankClass() { LtObjectUtil::singleton(""); }
function CC($className) { return LtObjectUtil::singleton($className); }
include $lotusHome . "runtime/MVC/Action.php"; include $lotusHome . "runtime/MVC/Component.php"; include $lotusHome . "runtime/MVC/Context.php"; include $lotusHome . "runtime/MVC/View.php"; include $lotusHome . "runtime/MVC/TemplateView.php"; include $lotusHome . "runtime/Validator/Validator.php"; include $lotusHome . "runtime/Validator/ValidatorDtd.php"; /** * 加载Action类文件 */ $appDir = "./simplest_tpl/"; include $appDir . "action/User-Signin.Action.php"; include $appDir . "action/Index-Index.Action.php"; include $appDir . "action/test-UsingComponent.Action.php"; include $appDir . "action/stock-Price.Component.php"; include $appDir . "action/test-UsingBlankLayout.Action.php"; include $appDir . "action/test-PassData.Action.php"; include $appDir . "action/test-UsingTitle.Action.php"; /** * 实例化 */ $dispatcher = LtObjectUtil::singleton('LtDispatcher'); $dispatcher->viewDir = "./simplest_tpl/view/"; /** * 保存模板编译后的文件目录, * 如果不指定,默认在view同级目录生成LtTemplateView目录 */ $dispatcher->viewTplDir = "/tmp/Lotus/templateView/"; $module = isset($_GET['module']) ? $_GET['module'] : 'Index'; $action = isset($_GET['action']) ? $_GET['action'] : 'Index'; $dispatcher->dispatchAction($module, $action);
public function execute() { $this->data['title'] = "用户注册"; $this->data['username'] = "******"; $this->data['baseurl'] = LtObjectUtil::singleton('LtConfig')->get('baseurl'); }
<ol> <li><a href="<?php echo LtObjectUtil::singleton("LtUrl", true)->generate("hello", "world"); ?> ">hello world</a></li> </ol>
protected function runMVC() { $router = LtObjectUtil::singleton('LtRouter'); $router->init(); $dispatcher = LtObjectUtil::singleton('LtDispatcher'); $dispatcher->viewDir = $this->app_dir . 'view/'; $dispatcher->viewTplDir = $this->data_dir . 'templateView/'; if (!$this->devMode) { $dispatcher->viewTplAutoCompile = false; } else { $dispatcher->viewTplAutoCompile = true; } $dispatcher->dispatchAction($router->module, $router->action); }
/** * run mvc */ protected function runMVC() { $router = LtObjectUtil::singleton('LtRouter', false); $router->init(); $dispatcher = LtObjectUtil::singleton('LtDispatcher', false); $dispatcher->configHandle = $this->configHandle; $dispatcher->viewDir = $this->app_dir . 'view/'; $dispatcher->projDir = $this->proj_dir; $dispatcher->appDir = $this->app_dir; $prefix = sprintf("%u", crc32(serialize($this->app_dir))); if (!$this->devMode) { // 生产环境下,修改模板文件后,必需手工删除模板引擎编译后的文件 $dispatcher->viewTplDir = $this->cache_dir . 'Lotus-' . $prefix . '-tpl/'; $dispatcher->viewTplAutoCompile = false; } else { // 开发模式下模板引擎比较源文件编译后的文件日期来决定是否重新编译 $dispatcher->viewTplDir = $this->cache_dir . 'Lotus-' . $prefix . '-tpl-dev/'; $dispatcher->viewTplAutoCompile = true; } $dispatcher->dispatchAction($router->module, $router->action); }