示例#1
0
    protected function getWhereClause()
    {
        if ($this->where_clause === null) {
            $instance_id = $this->app->getInstanceId();
            $where = sprintf('PinholePhoto.status in (%s, %s)
				and ImageSet.instance %s %s', $this->app->db->quote(PinholePhoto::STATUS_PUBLISHED, 'integer'), $this->app->db->quote(PinholePhoto::STATUS_UNPUBLISHED, 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
            $clause = new AdminSearchClause('date:photo_date');
            $clause->table = 'PinholePhoto';
            $clause->value = $this->ui->getWidget('search_start_date')->value;
            $clause->operator = AdminSearchClause::OP_GTE;
            $where .= $clause->getClause($this->app->db, 'and');
            $clause = new AdminSearchClause('date:photo_date');
            $clause->table = 'PinholePhoto';
            $clause->value = $this->ui->getWidget('search_end_date')->value;
            $clause->operator = AdminSearchClause::OP_LT;
            $where .= $clause->getClause($this->app->db, 'and');
            if ($this->ui->getWidget('search_non_geo_tagged')->value) {
                $where .= sprintf(' and PinholePhoto.gps_latitude is null ');
            }
            $status = $this->ui->getWidget('search_status')->value;
            if ($status !== null) {
                switch ($status) {
                    case 'published':
                        $where .= sprintf(' and PinholePhoto.status = %s', $this->app->db->quote(PinholePhoto::STATUS_PUBLISHED, 'integer'));
                        break;
                    case 'hidden':
                        $where .= sprintf(' and PinholePhoto.status = %s', $this->app->db->quote(PinholePhoto::STATUS_UNPUBLISHED, 'integer'));
                        break;
                    case 'private':
                    case 'public':
                        $where .= sprintf(' and PinholePhoto.private = %s', $this->app->db->quote($status == 'private', 'boolean'));
                        break;
                    case 'for_sale':
                    case 'not_for_sale':
                        $where .= sprintf(' and PinholePhoto.for_sale = %s', $this->app->db->quote($status == 'for_sale', 'boolean'));
                        break;
                }
            }
            $tags = $this->ui->getWidget('search_tags')->getSelectedTagArray();
            foreach ($tags as $name => $title) {
                $where .= sprintf(' and PinholePhoto.id in (select photo from
					PinholePhotoTagBinding inner join PinholeTag on
					PinholeTag.id = PinholePhotoTagBinding.tag
					where PinholeTag.name = %s)', $this->app->db->quote($name, 'text'));
            }
            $this->where = $where;
        }
        return $this->where;
    }
示例#2
0
文件: Index.php 项目: nburka/blorg
 protected function getWhereClause()
 {
     if ($this->where_clause === null) {
         $instance_id = $this->app->getInstanceId();
         $where = sprintf('instance %s %s ', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
         $title = $this->ui->getWidget('search_title')->value;
         if (trim($title) != '') {
             $clause = new AdminSearchClause('title', $title);
             $clause->table = 'BlorgTag';
             $clause->operator = $this->ui->getWidget('search_title_operator')->value;
             $where .= $clause->getClause($this->app->db, 'and');
         }
         $this->where_clause = $where;
     }
     return $this->where_clause;
 }
示例#3
0
    protected function getWhereClause()
    {
        if ($this->where_clause === null) {
            $instance_id = $this->app->getInstanceId();
            // default where clause
            $where = sprintf('instance %s %s ', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
            // keywords are included in the where clause if fulltext searching
            // is turned off
            $keywords = $this->ui->getWidget('search_keywords')->value;
            if (trim($keywords) != '' && $this->getSearchType() === null) {
                $where .= ' and ( ';
                $clause = new AdminSearchClause('title', $keywords);
                $clause->table = 'BlorgPost';
                $clause->operator = AdminSearchClause::OP_CONTAINS;
                $where .= $clause->getClause($this->app->db, '');
                $clause = new AdminSearchClause('bodytext', $keywords);
                $clause->table = 'BlorgPost';
                $clause->operator = AdminSearchClause::OP_CONTAINS;
                $where .= $clause->getClause($this->app->db, 'or');
                $where .= ') ';
            }
            // author
            $author_clause = new AdminSearchClause('integer:author', $this->ui->getWidget('search_author')->value);
            $where .= $author_clause->getClause($this->app->db);
            // enabled
            $enabled_clause = new AdminSearchClause('boolean:enabled', $this->ui->getWidget('search_enabled')->value);
            $where .= $enabled_clause->getClause($this->app->db);
            // date range gt
            $search_date_gt = $this->ui->getWidget('search_publish_date_gt');
            if ($search_date_gt->value !== null) {
                // clone so the date displayed will stay the same
                $date_gt = clone $search_date_gt->value;
                $date_gt->setTZ($this->app->default_time_zone);
                $date_gt->toUTC();
                $clause = new AdminSearchClause('date:publish_date');
                $clause->table = 'BlorgPost';
                $clause->value = $date_gt->getDate();
                $clause->operator = AdminSearchClause::OP_GT;
                $where .= $clause->getClause($this->app->db);
            }
            // date range lt
            $search_date_lt = $this->ui->getWidget('search_publish_date_lt');
            if ($search_date_lt->value !== null) {
                // clone so the date displayed will stay the same
                $date_lt = clone $search_date_lt->value;
                $date_lt->setTZ($this->app->default_time_zone);
                $date_lt->toUTC();
                $clause = new AdminSearchClause('date:publish_date');
                $clause->table = 'BlorgPost';
                $clause->value = $date_lt->getDate();
                $clause->operator = AdminSearchClause::OP_LT;
                $where .= $clause->getClause($this->app->db);
            }
            // tags
            $tags = $this->ui->getWidget('search_tags')->getSelectedTagArray();
            foreach ($tags as $shortname => $title) {
                $where .= sprintf(' and BlorgPost.id in (select post from
					BlorgPostTagBinding inner join BlorgTag on
					BlorgTag.id = BlorgPostTagBinding.tag
					where BlorgTag.shortname = %s)', $this->app->db->quote($shortname, 'text'));
            }
            $this->where_clause = $where;
        }
        return $this->where_clause;
    }
示例#4
0
文件: Index.php 项目: nburka/blorg
 protected function getAuthorWhereClause()
 {
     $where = '';
     $author = $this->ui->getWidget('search_author')->value;
     if (trim($author) != '') {
         $fullname_clause = new AdminSearchClause('fullname', $author);
         $fullname_clause->table = 'BlorgComment';
         $fullname_clause->operator = AdminSearchClause::OP_CONTAINS;
         $author_clause = new AdminSearchClause('name', $author);
         $author_clause->table = 'BlorgAuthor';
         $author_clause->operator = AdminSearchClause::OP_CONTAINS;
         $where .= ' and (';
         $where .= $fullname_clause->getClause($this->app->db, '');
         $where .= $author_clause->getClause($this->app->db, 'or');
         $where .= ')';
     }
     return $where;
 }
示例#5
0
 protected function getWhereClause()
 {
     if ($this->where_clause === null) {
         $instance_id = $this->app->getInstanceId();
         $this->where_clause = sprintf('PinholeTag.instance %s %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
         $clause = new AdminSearchClause('title');
         $clause->table = 'PinholeTag';
         $clause->value = $this->ui->getWidget('search_title')->value;
         $clause->operator = $this->ui->getWidget('search_title_operator')->value;
         $this->where_clause .= $clause->getClause($this->app->db, 'and');
         $clause = new AdminSearchClause('boolean:archived');
         $clause->table = 'PinholeTag';
         $clause->value = $this->ui->getWidget('search_archived')->value;
         $this->where_clause .= $clause->getClause($this->app->db, 'and');
     }
     return $this->where_clause;
 }