function __set($property, $value) { $ipn = '_' . $property; if (in_array($property, array('Cal', 'Image', 'Activated'))) { if ($property == 'Activated') { $value2 = $value; $value = (int) (bool) $value; } if ($value != @$this->{$ipn} && ($value || @$this->{$ipn})) { if (@$this->{$ipn} !== false && $this->mayI(EDIT)) { if (!$this->mayI(EDIT)) { return false; } if ($property == 'Activated') { if (!$this->mayI(PUBLISH)) { return false; } } elseif ($property == 'Cal') { $this->registerUpdate(); if (is_object($value)) { $this->_Cal = $value; $value = $value->ID; } } Metadata::set($property, $value); } } $this->{$ipn} = $property == 'Activated' && $value2 == '' ? $value2 : $value; } elseif ($property == 'Publish') { $this->setActive($value); } else { parent::__set($property, $value); } }
function sp_sql_qiushis_paged($tag = "", $pagesize = 20, $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}') { $tag = sp_param_lable($tag); $field = !empty($tag['field']) ? $tag['field'] : 'b.*'; $limit = !empty($tag['limit']) ? $tag['limit'] : ''; $order = !empty($tag['order']) ? $tag['order'] : 'createtime desc'; $field = "a.cat_name,c.user_login,c.user_nicename," . $field; $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.status" => 1, "a.status" => 1); if (isset($tag['cid'])) { $where['cid'] = array('in', $tag['cid']); } $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushis = $qiushi_cat_model->field($field)->alias("a")->join($join)->join($join2)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $return['count'] = $totalsize; $return['items'] = $qiushis; $return['page'] = $page->show('default'); return $return; }
function __set($property, $value) { if ($property == 'Publish') { $this->setActive($value); } else { parent::__set($property, $value); } }
function __set($property, $value) { switch ($property) { case 'start': case 'end': case 'soft_deadline': case 'hard_deadline': case 'send_reminder': case 'calendar': global $DB; $DB->events->update(array($property => $value), array('id' => $this->ID), true); return $this->{'_' . $property} = $value; default: return parent::__set($property, $value); } }
public function index() { $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.status" => 1, "a.status" => 1); $catid = I("get.cat", 0, "intval"); if (!empty($catid)) { $where['a.id'] = $catid; } $order = array("b.istop" => "desc"); $sort = I("get.sort", 0, "intval"); if (empty($sort)) { $order['b.createtime'] = "desc"; } else { $sort == 1 ? $order['b.last_comment'] = "desc" : ""; //按最新回复 if ($sort == 2) { //精华 $where['b.star'] = array("gt", 0); $order['b.createtime'] = "desc"; } } $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, 15); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushis = $qiushi_cat_model->field("a.cat_name,b.*,c.user_login,c.user_nicename")->alias("a")->join($join)->join($join2)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("pager", $page->show('default')); $qiushi_cats = $qiushi_cat_model->where(array("status" => 1))->order("listorder asc")->select(); $this->assign("qiushi_cats", $qiushi_cats); $catid = I("get.cat", 0, "intval"); if (!empty($catid)) { $qiushi_cat = $qiushi_cat_model->where(array("id" => $catid))->find(); $this->assign("qiushi_cat", $qiushi_cat); } $this->assign("qiushis", $qiushis); $this->display(":index"); }
public function index() { $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.uid" => get_current_userid()); $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, 10); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushi_cats = $qiushi_cat_model->where(array("status" => 1))->select(); $this->assign("qiushi_cats", $qiushi_cats); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $qiushis = $qiushi_cat_model->field("a.cat_name,b.*,c.user_login,c.user_nicename")->alias("a")->join($join)->join($join2)->where($where)->order("b.createtime desc")->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("pager", $page->show('default')); $this->assign("qiushis", $qiushis); $this->display(); }
/** * 功能:根据关键字 搜索文章(包含子分类中文章),已经分页,调用方式同sp_sql_posts_paged<br> * @author WelkinVan 2014-12-04 * @param string $keyword 关键字. * @param string $tag 查询标签,以字符串方式传入,例:"field:post_title,post_content;limit:0,8;order:post_date desc,listorder desc;where:id>0;"<br> * field:调用post指定字段,如(id,post_title...) 默认全部<br> * limit:数据条数,默认值为10,可以指定从第几条开始,如3,8(表示共调用8条,从第3条开始)<br> * order:排序方式,如:post_date desc<br> * where:查询条件,字符串形式,和sql语句一样 * @param int $pagesize 每页条数. * @param string $pagetpl 以字符串方式传入,例:"{first}{prev}{liststart}{list}{listend}{next}{last}" */ function sp_sql_posts_paged_bykeyword($keyword, $tag, $pagesize = 20, $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}') { $where = array(); $tag = sp_param_lable($tag); $field = !empty($tag['field']) ? $tag['field'] : '*'; $limit = !empty($tag['limit']) ? $tag['limit'] : ''; $order = !empty($tag['order']) ? $tag['order'] : 'post_date'; //根据参数生成查询条件 $where['status'] = array('eq', 1); $where['post_status'] = array('eq', 1); $where['post_title'] = array('like', '%' . $keyword . '%'); if (isset($tag['cid'])) { $where['term_id'] = array('in', $tag['cid']); } if (isset($tag['ids'])) { $where['object_id'] = array('in', $tag['ids']); } $join = "" . C('DB_PREFIX') . 'posts as b on a.object_id =b.id'; $join2 = "" . C('DB_PREFIX') . 'users as c on b.post_author = c.id'; $rs = M("TermRelationships"); $totalsize = $rs->alias("a")->join($join)->join($join2)->field($field)->where($where)->count(); import('Page'); if ($pagesize == 0) { $pagesize = 20; } $PageParam = C("VAR_PAGE"); $page = new Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $page->SetPager('default', $pagetpl, array("listlong" => "9", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $posts = $rs->alias("a")->join($join)->join($join2)->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $content['count'] = $totalsize; $content['posts'] = $posts; $content['page'] = $page->show('default'); return $content; }
/** * 商品列表,带page * @ 处理标签函数 * @ $tag以字符串方式传入,通过sp_param_lable函数解析为以下变量。例:"order:add_time desc,update_time desc;" * ids:调用指定id的一个或多个数据,如 1,2,3 * field:调用goods指定字段,如(goods_id,goods_name...) 默认全部 * limit:数据条数,默认值为10,可以指定从第几条开始,如3,8(表示共调用8条,从第3条开始) * order:推荐方式(add_time) (desc/asc/rand()) */ function sp_sql_goods_paged($tag, $pagesize = 20) { $where = array(); $tag = sp_param_lable($tag); $field = !empty($tag['field']) ? $tag['field'] : '*'; $limit = !empty($tag['limit']) ? $tag['limit'] : ''; $order = !empty($tag['order']) ? $tag['order'] : 'add_time'; //根据参数生成查询条件 $where['goods_state'] = array('eq', 1); if (isset($tag['cid'])) { $where['term_id'] = array('in', $tag['cid']); } if (isset($tag['keywords'])) { $where['goods_name'] = array('like', "%" . $tag['keywords'] . "%"); } if (isset($tag['ids'])) { $where['goods_id'] = array('in', $tag['ids']); } $goods = D("Goods"); $totalsize = $goods->field($field)->where($where)->count(); import('Page'); if ($pagesize == 0) { $pagesize = 20; } $PageParam = C("VAR_PAGE"); $page = new Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $page->SetPager('default', '<div class="page">{prev} {list} {listend} {next}</div>', array("listlong" => "6", "first" => "首页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $list = $goods->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $content['goods'] = $list; $content['count'] = $totalsize; $content['page'] = $page->show('default'); return $content; }
function __set($property, $value) { if ($property == 'path') { if (preg_match('#^' . $this->rootDir() . '(/|$)#', $value)) { $this->_path = $value; $this->expandPath(); } } elseif ($property != 'Name') { return parent::__set($property, $value); } }