1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- defined('GNUSOCIAL') || die();
- 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', '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')
- ),
- );
- }
- public static function getStream(
- $tag,
- $offset = 0,
- $limit = 20,
- $sinceId = 0,
- $maxId = 0
- ) {
-
-
- $stream = new TagNoticeStream($tag, Profile::current());
- return $stream;
- }
- public 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));
- }
- }
- public static function url($tag)
- {
- if (common_config('singleuser', 'enabled')) {
-
- $nickname = User::singleUserNickname();
- $url = common_local_url(
- 'showstream',
- [
- 'nickname' => $nickname,
- 'tag' => $tag,
- ]
- );
- } else {
- $url = common_local_url('tag', ['tag' => $tag]);
- }
- return $url;
- }
- }
|