123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
- class Notice_tag extends Managed_DataObject
- {
-
-
- public $__table = 'notice_tag';
- public $tag;
- public $notice_id;
- public $created;
-
-
- public static function schemaDef()
- {
- return array(
- 'description' => 'Hash tags',
- 'fields' => array(
- 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'),
- 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice tagged'),
- 'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
- ),
- 'primary key' => array('tag', 'notice_id'),
- 'foreign keys' => array(
- 'notice_tag_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
- ),
- 'indexes' => array(
- 'notice_tag_created_idx' => array('created'),
- 'notice_tag_notice_id_idx' => array('notice_id'),
- 'notice_tag_tag_created_notice_id_idx' => array('tag', 'created', 'notice_id')
- ),
- );
- }
-
- static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0)
- {
-
-
- $stream = new TagNoticeStream($tag, Profile::current());
- return $stream;
- }
- function blowCache($blowLast=false)
- {
- self::blow('notice_tag:notice_ids:%s', Cache::keyize($this->tag));
- if ($blowLast) {
- self::blow('notice_tag:notice_ids:%s;last', Cache::keyize($this->tag));
- }
- }
- static function url($tag)
- {
- if (common_config('singleuser', 'enabled')) {
-
- $nickname = User::singleUserNickname();
- $url = common_local_url('showstream',
- array('nickname' => $nickname,
- 'tag' => $tag));
- } else {
- $url = common_local_url('tag', array('tag' => $tag));
- }
- return $url;
- }
- }
|