Notice_tag.php 2.4 KB
Newer Older
1
<?php
2
/*
3
 * StatusNet - the distributed open-source microblogging tool
4
 * Copyright (C) 2008, 2009, StatusNet, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

20
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
21

22
class Notice_tag extends Memcached_DataObject
23 24 25 26 27 28 29 30 31 32
{
    ###START_AUTOCODE
    /* the code below is auto generated do not remove the above tag */

    public $__table = 'notice_tag';                      // table name
    public $tag;                             // varchar(64)  primary_key not_null
    public $notice_id;                       // int(4)  primary_key not_null
    public $created;                         // datetime()   not_null

    /* Static get */
33 34
    function staticGet($k,$v=null)
    { return Memcached_DataObject::staticGet('Notice_tag',$k,$v); }
35 36 37

    /* the code above is auto generated do not remove the tag below */
    ###END_AUTOCODE
38

39 40
    static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0)
    {
41
        $stream = new TagNoticeStream($tag);
42 43
        
        return $stream->getNotices($offset, $limit, $sinceId, $maxId);
44 45 46
    }

    function blowCache($blowLast=false)
47
    {
48
        self::blow('notice_tag:notice_ids:%s', Cache::keyize($this->tag));
49
        if ($blowLast) {
50
            self::blow('notice_tag:notice_ids:%s;last', Cache::keyize($this->tag));
51 52
        }
    }
53

54
    function pkeyGet($kv)
55 56 57
    {
        return Memcached_DataObject::pkeyGet('Notice_tag', $kv);
    }
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

	static function url($tag)
	{
		if (common_config('singleuser', 'enabled')) {
			// regular TagAction isn't set up in 1user mode
			$nickname = User::singleUserNickname();
			$url = common_local_url('showstream',
									array('nickname' => $nickname,
										  'tag' => $tag));
		} else {
			$url = common_local_url('tag', array('tag' => $tag));
		}

		return $url;
	}
73
}