From 4c09c1dc477ef920aa408a99c88deac4e43df6e8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 1 Mar 2011 17:01:35 -0800 Subject: [PATCH 001/726] Workaround for bug causing fatal error during favoriting; Profile::getCurrentNotice() was returning an ArrayList instead of a Notice directly due to pulling through Profile::getNotices(). This caused failure in Fave::addNew() which specifies it wants a Notice. Caused failure of the 'fav' IM command. --- classes/Profile.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/Profile.php b/classes/Profile.php index fd41c6139a..d030e38b1b 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -186,6 +186,10 @@ class Profile extends Memcached_DataObject $notice = $this->getNotices(0, 1); if ($notice->fetch()) { + if ($notice instanceof ArrayWrapper) { + // hack for things trying to work with single notices + return $notice->_items[0]; + } return $notice; } else { return null; From 3eb900e31f49c7d973266bb76e99eb0737f37880 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 1 Mar 2011 17:09:41 -0800 Subject: [PATCH 002/726] More fixes for 'fav' IM command: don't die with a fatal error if the notice has already been favored, and don't spew a warning when checking for user ID match. --- lib/command.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/command.php b/lib/command.php index 3fb4d76c75..29aa286d1d 100644 --- a/lib/command.php +++ b/lib/command.php @@ -287,6 +287,18 @@ class FavCommand extends Command function handle($channel) { $notice = $this->getNotice($this->other); + + $fave = new Fave(); + $fave->user_id = $this->user->id; + $fave->notice_id = $notice->id; + $fave->find(); + + if ($fave->fetch()) { + // TRANS: Error message text shown when a favorite could not be set because it has already been favorited. + $channel->error($this->user, _('Could not create favorite: already favorited.')); + return; + } + $fave = Fave::addNew($this->user->getProfile(), $notice); if (!$fave) { @@ -300,7 +312,7 @@ class FavCommand extends Command $other = User::staticGet('id', $notice->profile_id); - if ($other && $other->id != $user->id) { + if ($other && $other->id != $this->user->id) { if ($other->email && $other->emailnotifyfav) { mail_notify_fave($other, $this->user, $notice); } From 9ad00f726fff19caf5731eaf643b9910fef5e28f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 2 Mar 2011 12:49:37 -0800 Subject: [PATCH 003/726] Add unsubscribe option to resub-feed.php --- plugins/OStatus/scripts/resub-feed.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/OStatus/scripts/resub-feed.php b/plugins/OStatus/scripts/resub-feed.php index 8803c0118b..a08d837993 100644 --- a/plugins/OStatus/scripts/resub-feed.php +++ b/plugins/OStatus/scripts/resub-feed.php @@ -20,11 +20,17 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); +$longoptions = array('unsub'); +$shortoptions = 'u'; + $helptext = <<huburi with new subscription for $sub->uri\n"; -$ok = $sub->subscribe(); + +if (have_option('u') || have_option('--unsub')) { + print "Pinging hub $sub->huburi with unsubscription for $sub->uri\n"; + $ok = $sub->unsubscribe(); +} else { + print "Pinging hub $sub->huburi with new subscription for $sub->uri\n"; + $ok = $sub->subscribe(); +} if ($ok) { print "ok\n"; From 399c83db87e343d3c9845d97f83f0029f1eade38 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 2 Mar 2011 09:57:02 +0100 Subject: [PATCH 004/726] Fix typo in documentation. Spotted by Nikerabbit. --- actions/apigrouplistall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php index d05baa0992..73359ed3f9 100644 --- a/actions/apigrouplistall.php +++ b/actions/apigrouplistall.php @@ -89,7 +89,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction $taguribase = TagURI::base(); $id = "tag:$taguribase:Groups"; $link = common_local_url('groups'); - // TRANS: Message is used as a subtitle when listing the lastest 20 groups. %s is a site name. + // TRANS: Message is used as a subtitle when listing the latest 20 groups. %s is a site name. $subtitle = sprintf(_("groups on %s"), $sitename); switch($this->format) { From 418abd8da4c8650dcb7b3ca60259dcd86fd5d4f2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 3 Mar 2011 12:09:51 -0500 Subject: [PATCH 005/726] Revert "New version, dev cycle" This reverts commit 96d0141848e6965d0e588b151054737495fb4900. --- lib/common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/common.php b/lib/common.php index db111df5f9..35a5391052 100644 --- a/lib/common.php +++ b/lib/common.php @@ -22,13 +22,13 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } //exit with 200 response, if this is checking fancy from the installer if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; } -define('STATUSNET_BASE_VERSION', '0.9.8'); -define('STATUSNET_LIFECYCLE', 'dev'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' +define('STATUSNET_BASE_VERSION', '0.9.7'); +define('STATUSNET_LIFECYCLE', 'beta2'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' define('STATUSNET_VERSION', STATUSNET_BASE_VERSION . STATUSNET_LIFECYCLE); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility -define('STATUSNET_CODENAME', 'Letter Never Sent'); +define('STATUSNET_CODENAME', 'World Leader Pretend'); define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_STREAM_SIZE', 48); From 6b5d183bac5a22aa68f3b4c9aa9b9c471e2a99e4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 3 Mar 2011 12:10:43 -0500 Subject: [PATCH 006/726] beta3 --- lib/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index 35a5391052..900ce9fa5b 100644 --- a/lib/common.php +++ b/lib/common.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; } define('STATUSNET_BASE_VERSION', '0.9.7'); -define('STATUSNET_LIFECYCLE', 'beta2'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' +define('STATUSNET_LIFECYCLE', 'beta3'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' define('STATUSNET_VERSION', STATUSNET_BASE_VERSION . STATUSNET_LIFECYCLE); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility From 64925a275e8393a234183e0b97c0711ed56876a6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 4 Mar 2011 15:26:25 -0500 Subject: [PATCH 007/726] format Atom datetimes as UTC --- lib/activity.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/activity.php b/lib/activity.php index b781e49846..837be94ece 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -708,7 +708,6 @@ class Activity { $dateStr = date('d F Y H:i:s', $tm); $d = new DateTime($dateStr, new DateTimeZone('UTC')); - $d->setTimezone(new DateTimeZone(common_timezone())); return $d->format('c'); } } From 316fd01e20830c4c4afb3fbe4fd1a367a24de779 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 4 Mar 2011 15:26:25 -0500 Subject: [PATCH 008/726] format Atom datetimes as UTC --- lib/activity.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/activity.php b/lib/activity.php index b781e49846..837be94ece 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -708,7 +708,6 @@ class Activity { $dateStr = date('d F Y H:i:s', $tm); $d = new DateTime($dateStr, new DateTimeZone('UTC')); - $d->setTimezone(new DateTimeZone(common_timezone())); return $d->format('c'); } } From 32a00059fabdce72e7d9914b6ea5658bb16ef3ab Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Sun, 6 Mar 2011 23:26:27 +0530 Subject: [PATCH 009/726] Database schema --- db/095topeopletags.sql | 4 +++ db/core.php | 73 +++++++++++++++++++++++++++++++++++++++++- db/statusnet.sql | 49 +++++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 db/095topeopletags.sql diff --git a/db/095topeopletags.sql b/db/095topeopletags.sql new file mode 100644 index 0000000000..e193b98156 --- /dev/null +++ b/db/095topeopletags.sql @@ -0,0 +1,4 @@ +/* populate people tags metadata */ + +insert into profile_list (tagger, tag, modified, description, private) + select distinct tagger, tag, modified, null, false from profile_tag; diff --git a/db/core.php b/db/core.php index 55d724b505..9f9c7a24bb 100644 --- a/db/core.php +++ b/db/core.php @@ -604,8 +604,9 @@ $schema['profile_tag'] = array( ), 'primary key' => array('tagger', 'tagged', 'tag'), 'foreign keys' => array( - 'profile_tag_tagger_fkey' => array('user', array('tagger' => 'id')), + 'profile_tag_tagger_fkey' => array('profile', array('tagger' => 'id')), 'profile_tag_tagged_fkey' => array('profile', array('tagged' => 'id')), + 'profile_tag_tag_fkey' => array('profile_list', array('tag' => 'tag')), ), 'indexes' => array( 'profile_tag_modified_idx' => array('modified'), @@ -614,6 +615,76 @@ $schema['profile_tag'] = array( ), ); +$schema['profile_list'] = array( + 'fields' => array( + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'), + 'tagger' => array('type' => 'int', 'not null' => true, 'description' => 'user making the tag'), + 'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'people tag'), + 'description' => array('type' => 'text', 'description' => 'description of the people tag'), + 'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'), + + 'created' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'), + + 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), + 'mainpage' => array('type' => 'varchar', 'length' => 255, 'description' => 'page to link to'), + 'tagged_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of people tagged with this tag by this user'), + 'subscriber_count' => array('type' => 'int', 'default' => 0, 'description' => 'number of subscribers to this tag'), + ), + 'primary key' => array('tagger', 'tag'), + 'unique keys' => array( + 'profile_list_id_key' => array('id') + ), + 'foreign keys' => array( + 'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')), + ), + 'indexes' => array( + 'profile_list_modified_idx' => array('modified'), + 'profile_list_tag_idx' => array('tag'), + 'profile_list_tagger_tag_idx' => array('tagger', 'tag'), + 'profile_list_tagged_count_idx' => array('tagged_count'), + 'profile_list_subscriber_count_idx' => array('subscriber_count'), + ), +); + +$schema['profile_tag_inbox'] = array( + 'description' => 'Many-many table listing notices associated with people tags.', + 'fields' => array( + 'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'people tag receiving the message'), + 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice received'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date the notice was created'), + ), + 'primary key' => array('profile_tag_id', 'notice_id'), + 'foreign keys' => array( + 'profile_tag_inbox_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), + 'profile_tag_inbox_notice_id_fkey' => array('notice', array('notice_id' => 'id')), + ), + 'indexes' => array( + 'profile_tag_inbox_created_idx' => array('created'), + 'profile_tag_inbox_profile_tag_id_idx' => array('profile_tag_id'), + ), +); + +$schema['profile_tag_subscription'] = array( + 'fields' => array( + 'profile_tag_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile_tag'), + 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), + + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('profile_tag_id', 'profile_id'), + 'foreign keys' => array( + 'profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')), + 'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + ), + 'indexes' => array( + // @fixme probably we want a (profile_id, created) index here? + 'profile_tag_subscription_profile_id_idx' => array('profile_id'), + 'profile_tag_subscription_created_idx' => array('created'), + ), +); + $schema['profile_block'] = array( 'fields' => array( 'blocker' => array('type' => 'int', 'not null' => true, 'description' => 'user making the block'), diff --git a/db/statusnet.sql b/db/statusnet.sql index debe6f095c..29a555948b 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -403,7 +403,7 @@ create table notice_inbox ( ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; create table profile_tag ( - tagger integer not null comment 'user making the tag' references user (id), + tagger integer not null comment 'user making the tag' references profile (id), tagged integer not null comment 'profile tagged' references profile (id), tag varchar(64) not null comment 'hash tag associated with this notice', modified timestamp comment 'date the tag was added', @@ -414,6 +414,53 @@ create table profile_tag ( index profile_tag_tagged_idx (tagged) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; +/* people tag metadata */ +create table profile_list ( + id integer auto_increment unique key comment 'unique identifier', + tagger integer not null comment 'user making the tag' references profile (id), + tag varchar(64) not null comment 'hash tag', + description text comment 'description for the tag', + private tinyint(1) default 0 comment 'is this list private', + + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified', + + uri varchar(255) unique key comment 'universal identifier', + mainpage varchar(255) comment 'page for tag info info to link to', + tagged_count smallint not null default 0 comment 'number of people tagged', + subscriber_count smallint not null default 0 comment 'number of people subscribing', + + constraint primary key (tagger, tag), + index profile_list_tag_idx (tag), + index profile_list_tagged_count_idx (tagged_count), + index profile_list_modified_idx (modified), + index profile_list_subscriber_count_idx (subscriber_count) +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table profile_tag_inbox ( + profile_tag_id integer not null comment 'peopletag receiving the message' references profile_tag (id), + notice_id integer not null comment 'notice received' references notice (id), + created datetime not null comment 'date the notice was created', + + constraint primary key (profile_tag_id, notice_id), + index profile_tag_inbox_created_idx (created), + index profile_tag_inbox_notice_id_idx (notice_id) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table profile_tag_subscription ( + profile_tag_id integer not null comment 'foreign key to profile_tag' references profile_list (id), + + profile_id integer not null comment 'foreign key to profile table' references profile (id), + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified', + + constraint primary key (profile_tag_id, profile_id), + index profile_tag_subscription_profile_id_idx (profile_id), + index profile_tag_subscription_created_idx (created) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + create table profile_block ( blocker integer not null comment 'user making the block' references user (id), blocked integer not null comment 'profile that is blocked' references profile (id), From 1b1a427237cb4151eb42a30a4d3a1d9774fdafc5 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Sun, 6 Mar 2011 23:28:03 +0530 Subject: [PATCH 010/726] DB_DataObjects for people tags --- classes/Notice.php | 115 ++++ classes/Profile.php | 203 ++++++ classes/Profile_list.php | 929 +++++++++++++++++++++++++++ classes/Profile_tag.php | 269 ++++++-- classes/Profile_tag_inbox.php | 27 + classes/Profile_tag_subscription.php | 103 +++ classes/User.php | 6 +- classes/statusnet.ini | 37 ++ classes/statusnet.links.ini | 20 + 9 files changed, 1658 insertions(+), 51 deletions(-) create mode 100644 classes/Profile_list.php create mode 100644 classes/Profile_tag_inbox.php create mode 100644 classes/Profile_tag_subscription.php diff --git a/classes/Notice.php b/classes/Notice.php index 157fdf2dc4..21795ae21b 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -429,6 +429,12 @@ class Notice extends Memcached_DataObject $notice->saveGroups(); } + if (isset($peopletags)) { + $notice->saveProfileTags($peopletags); + } else { + $notice->saveProfileTags(); + } + if (isset($urls)) { $notice->saveKnownUrls($urls); } else { @@ -797,6 +803,7 @@ class Notice extends Memcached_DataObject } $users = $this->getSubscribedUsers(); + $ptags = $this->getProfileTags(); // FIXME: kind of ignoring 'transitional'... // we'll probably stop supporting inboxless mode @@ -817,6 +824,18 @@ class Notice extends Memcached_DataObject } } + foreach ($ptags as $ptag) { + $users = $ptag->getUserSubscribers(); + foreach ($users as $id) { + if (!array_key_exists($id, $ni)) { + $user = User::staticGet('id', $id); + if (!$user->hasBlocked($profile)) { + $ni[$id] = NOTICE_INBOX_SOURCE_PROFILE_TAG; + } + } + } + } + foreach ($recipients as $recipient) { if (!array_key_exists($recipient, $ni)) { $ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY; @@ -913,6 +932,39 @@ class Notice extends Memcached_DataObject return $ids; } + function getProfileTags() + { + // Don't save ptags for repeats, for now. + + if (!empty($this->repeat_of)) { + return array(); + } + + // XXX: cache me + + $ptags = array(); + + $ptagi = new Profile_tag_inbox(); + + $ptagi->selectAdd(); + $ptagi->selectAdd('profile_tag_id'); + + $ptagi->notice_id = $this->id; + + if ($ptagi->find()) { + while ($ptagi->fetch()) { + $profile_list = Profile_list::staticGet('id', $ptagi->profile_tag_id); + if ($profile_list) { + $ptags[] = $profile_list; + } + } + } + + $ptagi->free(); + + return $ptags; + } + /** * Record this notice to the given group inboxes for delivery. * Overrides the regular parsing of !group markup. @@ -1034,6 +1086,69 @@ class Notice extends Memcached_DataObject return true; } + /** + * record targets into profile_tag_inbox. + * @return array of Profile_list objects + */ + function saveProfileTags($known=array()) + { + // Don't save ptags for repeats, for now + + if (!empty($this->repeat_of)) { + return array(); + } + + if (is_array($known)) { + $ptags = $known; + } else { + $ptags = array(); + } + + $ptag = new Profile_tag(); + $ptag->tagged = $this->profile_id; + + if($ptag->find()) { + while($ptag->fetch()) { + $plist = Profile_list::getByTaggerAndTag($ptag->tagger, $ptag->tag); + $ptags[] = clone($plist); + } + } + + foreach ($ptags as $target) { + $this->addToProfileTagInbox($target); + } + + return $ptags; + } + + function addToProfileTagInbox($plist) + { + $ptagi = Profile_tag_inbox::pkeyGet(array('profile_tag_id' => $plist->id, + 'notice_id' => $this->id)); + + if (empty($ptagi)) { + + $ptagi = new Profile_tag_inbox(); + + $ptagi->query('BEGIN'); + $ptagi->profile_tag_id = $plist->id; + $ptagi->notice_id = $this->id; + $ptagi->created = $this->created; + + $result = $ptagi->insert(); + if (!$result) { + common_log_db_error($ptagi, 'INSERT', __FILE__); + throw new ServerException(_('Problem saving profile_tag inbox.')); + } + + $ptagi->query('COMMIT'); + + self::blow('profile_tag:notice_ids:%d', $ptagi->profile_tag_id); + } + + return true; + } + /** * Save reply records indicating that this notice needs to be * delivered to the local users with the given URIs. diff --git a/classes/Profile.php b/classes/Profile.php index 88edf5cbb3..963b41e0d4 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -339,6 +339,183 @@ class Profile extends Memcached_DataObject return $groups; } + function isTagged($peopletag) + { + $tag = Profile_tag::pkeyGet(array('tagger' => $peopletag->tagger, + 'tagged' => $this->id, + 'tag' => $peopletag->tag)); + return !empty($tag); + } + + function canTag($tagged) + { + if (empty($tagged)) { + return false; + } + + if ($tagged->id == $this->id) { + return true; + } + + $all = common_config('peopletag', 'allow_tagging', 'all'); + $local = common_config('peopletag', 'allow_tagging', 'local'); + $remote = common_config('peopletag', 'allow_tagging', 'remote'); + $subs = common_config('peopletag', 'allow_tagging', 'subs'); + + if ($all) { + return true; + } + + $tagged_user = $tagged->getUser(); + if (!empty($tagged_user)) { + if ($local) { + return true; + } + } else if ($subs) { + return (Subscription::exists($this, $tagged) || + Subscription::exists($tagged, $this)); + } else if ($remote) { + return true; + } + return false; + } + + function getOwnedTags($auth_user, $offset=0, $limit=null, $since_id=0, $max_id=0) + { + $tags = new Profile_list(); + $tags->tagger = $this->id; + + if (($auth_user instanceof User || $auth_user instanceof Profile) && + $auth_user->id === $this->id) { + // no condition, get both private and public tags + } else { + $tags->private = false; + } + + $tags->selectAdd('id as "cursor"'); + + if ($since_id>0) { + $tags->whereAdd('id > '.$since_id); + } + + if ($max_id>0) { + $tags->whereAdd('id <= '.$max_id); + } + + if($offset>=0 && !is_null($limit)) { + $tags->limit($offset, $limit); + } + + $tags->orderBy('id DESC'); + $tags->find(); + + return $tags; + } + + function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0) + { + $lists = new Profile_list(); + + $tags = new Profile_tag(); + $tags->tagged = $this->id; + + $lists->joinAdd($tags); + #@fixme: postgres (round(date_part('epoch', my_date))) + $lists->selectAdd('unix_timestamp(profile_tag.modified) as "cursor"'); + + if ($auth_user instanceof User || $auth_user instanceof Profile) { + $lists->whereAdd('( ( profile_list.private = false ) ' . + 'OR ( profile_list.tagger = ' . $auth_user->id . ' AND ' . + 'profile_list.private = true ) )'); + } else { + $lists->private = false; + } + + if ($since_id>0) { + $lists->whereAdd('cursor > '.$since_id); + } + + if ($max_id>0) { + $lists->whereAdd('cursor <= '.$max_id); + } + + if($offset>=0 && !is_null($limit)) { + $lists->limit($offset, $limit); + } + + $lists->orderBy('profile_tag.modified DESC'); + $lists->find(); + + return $lists; + } + + function getPrivateTags($offset=0, $limit=null, $since_id=0, $max_id=0) + { + $tags = new Profile_list(); + $tags->private = true; + $tags->tagger = $this->id; + + if ($since_id>0) { + $tags->whereAdd('id > '.$since_id); + } + + if ($max_id>0) { + $tags->whereAdd('id <= '.$max_id); + } + + if($offset>=0 && !is_null($limit)) { + $tags->limit($offset, $limit); + } + + $tags->orderBy('id DESC'); + $tags->find(); + + return $tags; + } + + function hasLocalTags() + { + $tags = new Profile_tag(); + + $tags->joinAdd(array('tagger', 'user:id')); + $tags->whereAdd('tagged = '.$this->id); + $tags->whereAdd('tagger != '.$this->id); + + $tags->limit(0, 1); + $tags->fetch(); + + return ($tags->N == 0) ? false : true; + } + + function getTagSubscriptions($offset=0, $limit=null, $since_id=0, $max_id=0) + { + $lists = new Profile_list(); + $subs = new Profile_tag_subscription(); + + $lists->joinAdd($subs); + #@fixme: postgres (round(date_part('epoch', my_date))) + $lists->selectAdd('unix_timestamp(profile_tag_subscription.created) as "cursor"'); + + $lists->whereAdd('profile_tag_subscription.profile_id = '.$this->id); + + if ($since_id>0) { + $lists->whereAdd('cursor > '.$since_id); + } + + if ($max_id>0) { + $lists->whereAdd('cursor <= '.$max_id); + } + + if($offset>=0 && !is_null($limit)) { + $lists->limit($offset, $limit); + } + + $lists->orderBy('"cursor" DESC'); + $lists->find(); + + return $lists; + } + function avatarUrl($size=AVATAR_PROFILE_SIZE) { $avatar = $this->getAvatar($size); @@ -385,6 +562,32 @@ class Profile extends Memcached_DataObject return new ArrayWrapper($profiles); } + + function getTaggedSubscribers($tag) + { + $qry = + 'SELECT profile.* ' . + 'FROM profile JOIN (subscription, profile_tag, profile_list) ' . + 'ON profile.id = subscription.subscriber ' . + 'AND profile.id = profile_tag.tagged ' . + 'AND profile_tag.tagger = profile_list.tagger AND profile_tag.tag = profile_list.tag ' . + 'WHERE subscription.subscribed = %d ' . + 'AND subscription.subscribed != subscription.subscriber ' . + 'AND profile_tag.tagger = %d AND profile_tag.tag = "%s" ' . + 'AND profile_list.private = false ' . + 'ORDER BY subscription.created DESC'; + + $profile = new Profile(); + $tagged = array(); + + $cnt = $profile->query(sprintf($qry, $this->id, $this->id, $tag)); + + while ($profile->fetch()) { + $tagged[] = clone($profile); + } + return $tagged; + } + function subscriptionCount() { $c = Cache::instance(); diff --git a/classes/Profile_list.php b/classes/Profile_list.php new file mode 100644 index 0000000000..df7bef5201 --- /dev/null +++ b/classes/Profile_list.php @@ -0,0 +1,929 @@ +. + * + * @category Notices + * @package StatusNet + * @author Shashi Gowda + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Table Definition for profile_list + */ +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; + +class Profile_list extends Memcached_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + public $__table = 'profile_list'; // table name + public $id; // int(4) primary_key not_null + public $tagger; // int(4) + public $tag; // varchar(64) + public $description; // text + public $private; // tinyint(1) + public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00 + public $modified; // timestamp not_null default_CURRENT_TIMESTAMP + public $uri; // varchar(255) unique_key + public $mainpage; // varchar(255) + public $tagged_count; // smallint + public $subscriber_count; // smallint + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Profile_list',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE + + /** + * return a profile_list record, given its tag and tagger. + * + * @param array $kv ideally array('tag' => $tag, 'tagger' => $tagger) + * + * @return Profile_list a Profile_list object with the given tag and tagger. + */ + + function pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Profile_list', $kv); + } + + /** + * get the tagger of this profile_list object + * + * @return Profile the tagger + */ + + function getTagger() + { + return Profile::staticGet('id', $this->tagger); + } + + /** + * return a string to identify this + * profile_list in the user interface etc. + * + * @return String + */ + + function getBestName() + { + return $this->tag; + } + + /** + * return a uri string for this profile_list + * + * @return String uri + */ + + function getUri() + { + $uri = null; + if (Event::handle('StartProfiletagGetUri', array($this, &$uri))) { + if (!empty($this->uri)) { + $uri = $this->uri; + } else { + $uri = common_local_url('profiletagbyid', + array('id' => $this->id, 'tagger_id' => $this->tagger)); + } + } + Event::handle('EndProfiletagGetUri', array($this, &$uri)); + return $uri; + } + + /** + * return a url to the homepage of this item + * + * @return String home url + */ + + function homeUrl() + { + $url = null; + if (Event::handle('StartUserPeopletagHomeUrl', array($this, &$url))) { + // normally stored in mainpage, but older ones may be null + if (!empty($this->mainpage)) { + $url = $this->mainpage; + } else { + $url = common_local_url('showprofiletag', + array('tagger' => $this->getTagger()->nickname, + 'tag' => $this->tag)); + } + } + Event::handle('EndUserPeopletagHomeUrl', array($this, &$url)); + return $url; + } + + /** + * return an immutable url for this object + * + * @return String permalink + */ + + function permalink() + { + $url = null; + if (Event::handle('StartProfiletagPermalink', array($this, &$url))) { + $url = common_local_url('profiletagbyid', + array('id' => $this->id)); + } + Event::handle('EndProfiletagPermalink', array($this, &$url)); + return $url; + } + + /** + * Query notices by users associated with this tag, + * but first check the cache before hitting the DB. + * + * @param integer $offset offset + * @param integer $limit maximum no of results + * @param integer $since_id=null since this id + * @param integer $max_id=null maximum id in result + * + * @return Notice the query + */ + + function getNotices($offset, $limit, $since_id=null, $max_id=null) + { + $ids = Notice::stream(array($this, '_streamDirect'), + array(), + 'profile_tag:notice_ids:' . $this->id, + $offset, $limit, $since_id, $max_id); + + return Notice::getStreamByIds($ids); + } + + /** + * Query notices by users associated with this tag from the database. + * + * @param integer $offset offset + * @param integer $limit maximum no of results + * @param integer $since_id=null since this id + * @param integer $max_id=null maximum id in result + * + * @return array array of notice ids. + */ + + function _streamDirect($offset, $limit, $since_id, $max_id) + { + $inbox = new Profile_tag_inbox(); + + $inbox->profile_tag_id = $this->id; + + $inbox->selectAdd(); + $inbox->selectAdd('notice_id'); + + if ($since_id != 0) { + $inbox->whereAdd('notice_id > ' . $since_id); + } + + if ($max_id != 0) { + $inbox->whereAdd('notice_id <= ' . $max_id); + } + + $inbox->orderBy('notice_id DESC'); + + if (!is_null($offset)) { + $inbox->limit($offset, $limit); + } + + $ids = array(); + + if ($inbox->find()) { + while ($inbox->fetch()) { + $ids[] = $inbox->notice_id; + } + } + + return $ids; + } + + /** + * Get subscribers (local and remote) to this people tag + * Order by reverse chronology + * + * @param integer $offset offset + * @param integer $limit maximum no of results + * @param integer $since_id=null since unix timestamp + * @param integer $upto=null maximum unix timestamp when subscription was made + * + * @return Profile results + */ + + function getSubscribers($offset=0, $limit=null, $since=0, $upto=0) + { + $subs = new Profile(); + $sub = new Profile_tag_subscription(); + $sub->profile_tag_id = $this->id; + + $subs->joinAdd($sub); + $subs->selectAdd('unix_timestamp(profile_tag_subscription.' . + 'created) as "cursor"'); + + if ($since != 0) { + $subs->whereAdd('cursor > ' . $since); + } + + if ($upto != 0) { + $subs->whereAdd('cursor <= ' . $upto); + } + + if ($limit != null) { + $subs->limit($offset, $limit); + } + + $subs->orderBy('profile_tag_subscription.created DESC'); + $subs->find(); + + return $subs; + } + + /** + * Get all and only local subscribers to this people tag + * used for distributing notices to user inboxes. + * + * @return array ids of users + */ + + function getUserSubscribers() + { + // XXX: cache this + + $user = new User(); + if(common_config('db','quote_identifiers')) + $user_table = '"user"'; + else $user_table = 'user'; + + $qry = + 'SELECT id ' . + 'FROM '. $user_table .' JOIN profile_tag_subscription '. + 'ON '. $user_table .'.id = profile_tag_subscription.profile_id ' . + 'WHERE profile_tag_subscription.profile_tag_id = %d '; + + $user->query(sprintf($qry, $this->id)); + + $ids = array(); + + while ($user->fetch()) { + $ids[] = $user->id; + } + + $user->free(); + + return $ids; + } + + /** + * Check to see if a given profile has + * subscribed to this people tag's timeline + * + * @param mixed $id User or Profile object or integer id + * + * @return boolean subscription status + */ + + function hasSubscriber($id) + { + if (!is_numeric($id)) { + $id = $id->id; + } + + $sub = Profile_tag_subscription::pkeyGet(array('profile_tag_id' => $this->id, + 'profile_id' => $id)); + return !empty($sub); + } + + /** + * Get profiles tagged with this people tag, + * include modified timestamp as a "cursor" field + * order by descending order of modified time + * + * @param integer $offset offset + * @param integer $limit maximum no of results + * @param integer $since_id=null since unix timestamp + * @param integer $upto=null maximum unix timestamp when subscription was made + * + * @return Profile results + */ + + function getTagged($offset=0, $limit=null, $since=0, $upto=0) + { + $tagged = new Profile(); + $tagged->joinAdd(array('id', 'profile_tag:tagged')); + + #@fixme: postgres + $tagged->selectAdd('unix_timestamp(profile_tag.modified) as "cursor"'); + $tagged->whereAdd('profile_tag.tagger = '.$this->tagger); + $tagged->whereAdd("profile_tag.tag = '{$this->tag}'"); + + if ($since != 0) { + $tagged->whereAdd('cursor > ' . $since); + } + + if ($upto != 0) { + $tagged->whereAdd('cursor <= ' . $upto); + } + + if ($limit != null) { + $tagged->limit($offset, $limit); + } + + $tagged->orderBy('profile_tag.modified DESC'); + $tagged->find(); + + return $tagged; + } + + /** + * Gracefully delete one or many people tags + * along with their members and subscriptions data + * + * @return boolean success + */ + + function delete() + { + // force delete one item at a time. + if (empty($this->id)) { + $this->find(); + while ($this->fetch()) { + $this->delete(); + } + } + + Profile_tag::cleanup($this); + Profile_tag_subscription::cleanup($this); + + return parent::delete(); + } + + /** + * Update a people tag gracefully + * also change "tag" fields in profile_tag table + * + * @param Profile_list $orig Object's original form + * + * @return boolean success + */ + + function update($orig=null) + { + $result = true; + + if (!is_object($orig) && !$orig instanceof Profile_list) { + parent::update($orig); + } + + // if original tag was different + // check to see if the new tag already exists + // if not, rename the tag correctly + if($orig->tag != $this->tag || $orig->tagger != $this->tagger) { + $existing = Profile_list::getByTaggerAndTag($this->tagger, $this->tag); + if(!empty($existing)) { + throw new ServerException(_('The tag you are trying to rename ' . + 'to already exists.')); + } + // move the tag + // XXX: allow OStatus plugin to send out profile tag + $result = Profile_tag::moveTag($orig, $this); + } + parent::update($orig); + return $result; + } + + /** + * return an xml string representing this people tag + * as the author of an atom feed + * + * @return string atom author element + */ + + function asAtomAuthor() + { + $xs = new XMLStringer(true); + + $tagger = $this->getTagger(); + $xs->elementStart('author'); + $xs->element('name', null, '@' . $tagger->nickname . '/' . $this->tag); + $xs->element('uri', null, $this->permalink()); + $xs->elementEnd('author'); + + return $xs->getString(); + } + + /** + * return an xml string to represent this people tag + * as the subject of an activitystreams feed. + * + * @return string activitystreams subject + */ + + function asActivitySubject() + { + return $this->asActivityNoun('subject'); + } + + /** + * return an xml string to represent this people tag + * as a noun in an activitystreams feed. + * + * @param string $element the xml tag + * + * @return string activitystreams noun + */ + + function asActivityNoun($element) + { + $noun = ActivityObject::fromPeopletag($this); + return $noun->asString('activity:' . $element); + } + + /** + * get the cached number of profiles tagged with this + * people tag, re-count if the argument is true. + * + * @param boolean $recount whether to ignore cache + * + * @return integer count + */ + + function taggedCount($recount=false) + { + if (!$recount) { + return $this->tagged_count; + } + + $tags = new Profile_tag(); + $tags->tag = $this->tag; + $tags->tagger = $this->tagger; + $orig = clone($this); + $this->tagged_count = (int) $tags->count('distinct tagged'); + $this->update($orig); + + return $this->tagged_count; + } + + /** + * get the cached number of profiles subscribed to this + * people tag, re-count if the argument is true. + * + * @param boolean $recount whether to ignore cache + * + * @return integer count + */ + + function subscriberCount($recount=false) + { + if ($recount) { + return $this->subscriber_count; + } + + $sub = new Profile_tag_subscription(); + $sub->profile_tag_id = $this->id; + $orig = clone($this); + $this->subscriber_count = (int) $sub->count('distinct profile_id'); + $this->update($orig); + + return $this->subscriber_count; + } + + /** + * get the Profile_list object by the + * given tagger and with given tag + * + * @param integer $tagger the id of the creator profile + * @param integer $tag the tag + * + * @return integer count + */ + + static function getByTaggerAndTag($tagger, $tag) + { + $ptag = Profile_list::pkeyGet(array('tagger' => $tagger, 'tag' => $tag)); + return $ptag; + } + + /** + * create a profile_list record for a tag, tagger pair + * if it doesn't exist, return it. + * + * @param integer $tagger the tagger + * @param string $tag the tag + * @param string $description description + * @param boolean $private protected or not + * + * @return Profile_list the people tag object + */ + + static function ensureTag($tagger, $tag, $description=null, $private=false) + { + $ptag = Profile_list::getByTaggerAndTag($tagger, $tag); + + if(empty($ptag->id)) { + $args = array( + 'tag' => $tag, + 'tagger' => $tagger, + 'description' => $description, + 'private' => $private + ); + + $new_tag = Profile_list::saveNew($args); + + return $new_tag; + } + return $ptag; + } + + /** + * get the maximum number of characters + * that can be used in the description of + * a people tag. + * + * determined by $config['peopletag']['desclimit'] + * if not set, falls back to $config['site']['textlimit'] + * + * @return integer maximum number of characters + */ + + static function maxDescription() + { + $desclimit = common_config('peopletag', 'desclimit'); + // null => use global limit (distinct from 0!) + if (is_null($desclimit)) { + $desclimit = common_config('site', 'textlimit'); + } + return $desclimit; + } + + /** + * check if the length of given text exceeds + * character limit. + * + * @param string $desc the description + * + * @return boolean is the descripition too long? + */ + + static function descriptionTooLong($desc) + { + $desclimit = self::maxDescription(); + return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit)); + } + + /** + * save a new people tag, this should be always used + * since it makes uri, homeurl, created and modified + * timestamps and performs checks. + * + * @param array $fields an array with fields and their values + * + * @return mixed Profile_list on success, false on fail + */ + static function saveNew($fields) { + + extract($fields); + + $ptag = new Profile_list(); + + $ptag->query('BEGIN'); + + if (empty($tagger)) { + throw new Exception(_('No tagger specified.')); + } + + if (empty($tag)) { + throw new Exception(_('No tag specified.')); + } + + if (empty($mainpage)) { + $mainpage = null; + } + + if (empty($uri)) { + // fill in later... + $uri = null; + } + + if (empty($mainpage)) { + $mainpage = null; + } + + if (empty($description)) { + $description = null; + } + + if (empty($private)) { + $private = false; + } + + $ptag->tagger = $tagger; + $ptag->tag = $tag; + $ptag->description = $description; + $ptag->private = $private; + $ptag->uri = $uri; + $ptag->mainpage = $mainpage; + $ptag->created = common_sql_now(); + $ptag->modified = common_sql_now(); + + $result = $ptag->insert(); + + if (!$result) { + common_log_db_error($ptag, 'INSERT', __FILE__); + throw new ServerException(_('Could not create profile tag.')); + } + + if (!isset($uri) || empty($uri)) { + $orig = clone($ptag); + $ptag->uri = common_local_url('profiletagbyid', array('id' => $ptag->id, 'tagger_id' => $ptag->tagger)); + $result = $ptag->update($orig); + if (!$result) { + common_log_db_error($ptag, 'UPDATE', __FILE__); + throw new ServerException(_('Could not set profile tag URI.')); + } + } + + if (!isset($mainpage) || empty($mainpage)) { + $orig = clone($ptag); + $user = User::staticGet('id', $ptag->tagger); + if(!empty($user)) { + $ptag->mainpage = common_local_url('showprofiletag', array('tag' => $ptag->tag, 'tagger' => $user->nickname)); + } else { + $ptag->mainpage = $uri; // assume this is a remote peopletag and the uri works + } + + $result = $ptag->update($orig); + if (!$result) { + common_log_db_error($ptag, 'UPDATE', __FILE__); + throw new ServerException(_('Could not set profile tag mainpage.')); + } + } + return $ptag; + } + + /** + * get all items at given cursor position for api + * + * @param callback $fn a function that takes the following arguments in order: + * $offset, $limit, $since_id, $max_id + * and returns a Profile_list object after making the DB query + * @param array $args arguments required for $fn + * @param integer $cursor the cursor + * @param integer $count max. number of results + * + * Algorithm: + * - if cursor is 0, return empty list + * - if cursor is -1, get first 21 items, next_cursor = 20th prev_cursor = 0 + * - if cursor is +ve get 22 consecutive items before starting at cursor + * - return items[1..20] if items[0] == cursor else return items[0..21] + * - prev_cursor = items[1] + * - next_cursor = id of the last item being returned + * + * - if cursor is -ve get 22 consecutive items after cursor starting at cursor + * - return items[1..20] + * + * @returns array (array (mixed items), int next_cursor, int previous_cursor) + */ + + // XXX: This should be in Memcached_DataObject... eventually. + + static function getAtCursor($fn, $args, $cursor, $count=20) + { + $items = array(); + + $since_id = 0; + $max_id = 0; + $next_cursor = 0; + $prev_cursor = 0; + + if($cursor > 0) { + // if cursor is +ve fetch $count+2 items before cursor starting at cursor + $max_id = $cursor; + $fn_args = array_merge($args, array(0, $count+2, 0, $max_id)); + $list = call_user_func_array($fn, $fn_args); + while($list->fetch()) { + $items[] = clone($list); + } + + if ((isset($items[0]->cursor) && $items[0]->cursor == $cursor) || + $items[0]->id == $cursor) { + array_shift($items); + $prev_cursor = isset($items[0]->cursor) ? + -$items[0]->cursor : -$items[0]->id; + } else { + if (count($items) > $count+1) { + array_shift($items); + } + // this means the cursor item has been deleted, check to see if there are more + $fn_args = array_merge($args, array(0, 1, $cursor)); + $more = call_user_func($fn, $fn_args); + if (!$more->fetch() || empty($more)) { + // no more items. + $prev_cursor = 0; + } else { + $prev_cursor = isset($items[0]->cursor) ? + -$items[0]->cursor : -$items[0]->id; + } + } + + if (count($items)==$count+1) { + // this means there is a next page. + $next = array_pop($items); + $next_cursor = isset($next->cursor) ? + $items[$count-1]->cursor : $items[$count-1]->id; + } + + } else if($cursor < -1) { + // if cursor is -ve fetch $count+2 items created after -$cursor-1 + $cursor = abs($cursor); + $since_id = $cursor-1; + + $fn_args = array_merge($args, array(0, $count+2, $since_id)); + $list = call_user_func_array($fn, $fn_args); + while($list->fetch()) { + $items[] = clone($list); + } + + $end = count($items)-1; + if ((isset($items[$end]->cursor) && $items[$end]->cursor == $cursor) || + $items[$end]->id == $cursor) { + array_pop($items); + $next_cursor = isset($items[$end-1]->cursor) ? + $items[$end-1]->cursor : $items[$end-1]->id; + } else { + $next_cursor = isset($items[$end]->cursor) ? + $items[$end]->cursor : $items[$end]->id; + if ($end > $count) array_pop($items); // excess item. + + // check if there are more items for next page + $fn_args = array_merge($args, array(0, 1, 0, $cursor)); + $more = call_user_func_array($fn, $fn_args); + if (!$more->fetch() || empty($more)) { + $next_cursor = 0; + } + } + + if (count($items) == $count+1) { + // this means there is a previous page. + $prev = array_shift($items); + $prev_cursor = isset($prev->cursor) ? + -$items[0]->cursor : -$items[0]->id; + } + } else if($cursor == -1) { + $fn_args = array_merge($args, array(0, $count+1)); + $list = call_user_func_array($fn, $fn_args); + + while($list->fetch()) { + $items[] = clone($list); + } + + if (count($items)==$count+1) { + $next = array_pop($items); + if(isset($next->cursor)) { + $next_cursor = $items[$count-1]->cursor; + } else { + $next_cursor = $items[$count-1]->id; + } + } + + } + return array($items, $next_cursor, $prev_cursor); + } + + /** + * save a collection of people tags into the cache + * + * @param string $ckey cache key + * @param Profile_list &$tag the results to store + * @param integer $offset offset for slicing results + * @param integer $limit maximum number of results + * + * @return boolean success + */ + + static function setCache($ckey, &$tag, $offset=0, $limit=null) { + $cache = Cache::instance(); + if (empty($cache)) { + return false; + } + $str = ''; + $tags = array(); + while ($tag->fetch()) { + $str .= $tag->tagger . ':' . $tag->tag . ';'; + $tags[] = clone($tag); + } + $str = substr($str, 0, -1); + if ($offset>=0 && !is_null($limit)) { + $tags = array_slice($tags, $offset, $limit); + } + + $tag = new ArrayWrapper($tags); + + return self::cacheSet($ckey, $str); + } + + /** + * get people tags from the cache + * + * @param string $ckey cache key + * @param integer $offset offset for slicing + * @param integer $limit limit + * + * @return Profile_list results + */ + + static function getCached($ckey, $offset=0, $limit=null) { + + $keys_str = self::cacheGet($ckey); + if ($keys_str === false) { + return false; + } + + $pairs = explode(';', $keys_str); + $keys = array(); + foreach ($pairs as $pair) { + $keys[] = explode(':', $pair); + } + + if ($offset>=0 && !is_null($limit)) { + $keys = array_slice($keys, $offset, $limit); + } + return self::getByKeys($keys); + } + + /** + * get Profile_list objects from the database + * given their (tag, tagger) key pairs. + * + * @param array $keys array of array(tagger, tag) + * + * @return Profile_list results + */ + + static function getByKeys($keys) { + $cache = Cache::instance(); + + if (!empty($cache)) { + $tags = array(); + + foreach ($keys as $key) { + $t = Profile_list::getByTaggerAndTag($key[0], $key[1]); + if (!empty($t)) { + $tags[] = $t; + } + } + return new ArrayWrapper($tags); + } else { + $tag = new Profile_list(); + if (empty($keys)) { + //if no IDs requested, just return the tag object + return $tag; + } + + $pairs = array(); + foreach ($keys as $key) { + $pairs[] = '(' . $key[0] . ', "' . $key[1] . '")'; + } + + $tag->whereAdd('(tagger, tag) in (' . implode(', ', $pairs) . ')'); + + $tag->find(); + + $temp = array(); + + while ($tag->fetch()) { + $temp[$tag->tagger.'-'.$tag->tag] = clone($tag); + } + + $wrapped = array(); + + foreach ($keys as $key) { + $id = $key[0].'-'.$key[1]; + if (array_key_exists($id, $temp)) { + $wrapped[] = $temp[$id]; + } + } + + return new ArrayWrapper($wrapped); + } + } +} diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index ab6bab0964..183f79145a 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -22,31 +22,91 @@ class Profile_tag extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - static function getTags($tagger, $tagged) { - $tags = array(); + function pkeyGet($kv) { + return Memcached_DataObject::pkeyGet('Profile_tag', $kv); + } - # XXX: store this in memcached + function links() + { + return array('tagger,tag' => 'profile_list:tagger,tag'); + } - $profile_tag = new Profile_tag(); - $profile_tag->tagger = $tagger; - $profile_tag->tagged = $tagged; + function getMeta() + { + return Profile_list::pkeyGet(array('tagger' => $this->tagger, 'tag' => $this->tag)); + } - $profile_tag->find(); + static function getTags($tagger, $tagged, $auth_user=null) { - while ($profile_tag->fetch()) { - $tags[] = $profile_tag->tag; + $profile_list = new Profile_list(); + $include_priv = 1; + + if (!($auth_user instanceof User || + $auth_user instanceof Profile) || + ($auth_user->id !== $tagger)) { + + $profile_list->private = false; + $include_priv = 0; } - $profile_tag->free(); + $key = sprintf('profile_tag:tagger_tagged_privacy:%d-%d-%d', $tagger, $tagged, $include_priv); + $tags = Profile_list::getCached($key); + if ($tags !== false) { + return $tags; + } + + $profile_tag = new Profile_tag(); + $profile_list->tagger = $tagger; + $profile_tag->tagged = $tagged; + + $profile_list->selectAdd(); + + // only fetch id, tag, mainpage and + // private hoping this will be faster + $profile_list->selectAdd('profile_list.id, ' . + 'profile_list.tag, ' . + 'profile_list.mainpage, ' . + 'profile_list.private'); + $profile_list->joinAdd($profile_tag); + $profile_list->find(); + + Profile_list::setCache($key, $profile_list); + + return $profile_list; + } + + static function getTagsArray($tagger, $tagged, $auth_user_id=null) + { + $ptag = new Profile_tag(); + $ptag->tagger = $tagger; + $ptag->tagged = $tagged; + + if ($tagger != $auth_user_id) { + $list = new Profile_list(); + $list->private = false; + $ptag->joinAdd($list); + $ptag->selectAdd(); + $ptag->selectAdd('profile_tag.tag'); + } + + $tags = array(); + $ptag->find(); + while ($ptag->fetch()) { + $tags[] = $ptag->tag; + } + $ptag->free(); return $tags; } - static function setTags($tagger, $tagged, $newtags) { - $newtags = array_unique($newtags); - $oldtags = Profile_tag::getTags($tagger, $tagged); + static function setTags($tagger, $tagged, $newtags, $privacy=array()) { - # Delete stuff that's old that not in new + $newtags = array_unique($newtags); + $oldtags = self::getTagsArray($tagger, $tagged, $tagger); + + $ptag = new Profile_tag(); + + # Delete stuff that's in old and not in new $to_delete = array_diff($oldtags, $newtags); @@ -54,48 +114,161 @@ class Profile_tag extends Memcached_DataObject $to_insert = array_diff($newtags, $oldtags); - $profile_tag = new Profile_tag(); - - $profile_tag->tagger = $tagger; - $profile_tag->tagged = $tagged; - - $profile_tag->query('BEGIN'); - foreach ($to_delete as $deltag) { - $profile_tag->tag = $deltag; - $result = $profile_tag->delete(); - if (!$result) { - common_log_db_error($profile_tag, 'DELETE', __FILE__); - return false; - } + self::unTag($tagger, $tagged, $deltag); } foreach ($to_insert as $instag) { - $profile_tag->tag = $instag; - $result = $profile_tag->insert(); - if (!$result) { - common_log_db_error($profile_tag, 'INSERT', __FILE__); - return false; - } + $private = isset($privacy[$instag]) ? $privacy[$instag] : false; + self::setTag($tagger, $tagged, $instag, null, $private); } - - $profile_tag->query('COMMIT'); - return true; } - # Return profiles with a given tag - static function getTagged($tagger, $tag) { - $profile = new Profile(); - $profile->query('SELECT profile.* ' . - 'FROM profile JOIN profile_tag ' . - 'ON profile.id = profile_tag.tagged ' . - 'WHERE profile_tag.tagger = ' . $tagger . ' ' . - 'AND profile_tag.tag = "' . $tag . '" '); - $tagged = array(); - while ($profile->fetch()) { - $tagged[] = clone($profile); + # set a single tag + static function setTag($tagger, $tagged, $tag, $desc=null, $private=false) { + + $ptag = Profile_tag::pkeyGet(array('tagger' => $tagger, + 'tagged' => $tagged, + 'tag' => $tag)); + + # if tag already exists, return it + if(!empty($ptag)) { + return $ptag; } - return $tagged; + + $tagger_profile = Profile::staticGet('id', $tagger); + $tagged_profile = Profile::staticGet('id', $tagged); + + if (Event::handle('StartTagProfile', array($tagger_profile, $tagged_profile, $tag))) { + + if (!$tagger_profile->canTag($tagged_profile)) { + throw new ClientException(_('You cannot tag this user.')); + return false; + } + + $tags = new Profile_list(); + $tags->tagger = $tagger; + $count = (int) $tags->count('distinct tag'); + + if ($count >= common_config('peopletag', 'maxtags')) { + throw new ClientException(sprintf(_('You already have created %d or more tags ' . + 'which is the maximum allowed number of tags. ' . + 'Try using or deleting some existing tags.'), + common_config('peopletag', 'maxtags'))); + return false; + } + + $plist = new Profile_list(); + $plist->query('BEGIN'); + + $profile_list = Profile_list::ensureTag($tagger, $tag, $desc, $private); + + if ($profile_list->taggedCount() >= common_config('peopletag', 'maxpeople')) { + throw new ClientException(sprintf(_('You already have %d or more people tagged %s ' . + 'which is the maximum allowed number.' . + 'Try untagging others with the same tag first.'), + common_config('peopletag', 'maxpeople'), $tag)); + return false; + } + + $newtag = new Profile_tag(); + + $newtag->tagger = $tagger; + $newtag->tagged = $tagged; + $newtag->tag = $tag; + + $result = $newtag->insert(); + + + if (!$result) { + common_log_db_error($newtag, 'INSERT', __FILE__); + return false; + } + + try { + $plist->query('COMMIT'); + Event::handle('EndTagProfile', array($newtag)); + } catch (Exception $e) { + $newtag->delete(); + $profile_list->delete(); + throw $e; + return false; + } + + $profile_list->taggedCount(true); + self::blowCaches($tagger, $tagged); + } + + return $newtag; + } + + static function unTag($tagger, $tagged, $tag) { + $ptag = Profile_tag::pkeyGet(array('tagger' => $tagger, + 'tagged' => $tagged, + 'tag' => $tag)); + if (!$ptag) { + return true; + } + + if (Event::handle('StartUntagProfile', array($ptag))) { + $orig = clone($ptag); + $result = $ptag->delete(); + if (!$result) { + common_log_db_error($this, 'DELETE', __FILE__); + return false; + } + Event::handle('EndUntagProfile', array($orig)); + if ($result) { + $profile_list = Profile_list::pkeyGet(array('tag' => $tag, 'tagger' => $tagger)); + $profile_list->taggedCount(true); + self::blowCaches($tagger, $tagged); + return true; + } + return false; + } + } + + // @fixme: move this to Profile_list? + static function cleanup($profile_list) { + $ptag = new Profile_tag(); + $ptag->tagger = $profile_list->tagger; + $ptag->tag = $profile_list->tag; + $ptag->find(); + + while($ptag->fetch()) { + if (Event::handle('StartUntagProfile', array($ptag))) { + $orig = clone($ptag); + $result = $ptag->delete(); + if (!$result) { + common_log_db_error($this, 'DELETE', __FILE__); + } + Event::handle('EndUntagProfile', array($orig)); + } + } + } + + // move a tag! + static function moveTag($orig, $new) { + $tags = new Profile_tag(); + $qry = 'UPDATE profile_tag SET ' . + 'tag = "%s", tagger = "%s" ' . + 'WHERE tag = "%s" ' . + 'AND tagger = "%s"'; + $result = $tags->query(sprintf($qry, $new->tag, $new->tagger, + $orig->tag, $orig->tagger)); + + if (!$result) { + common_log_db_error($tags, 'UPDATE', __FILE__); + return false; + } + return true; + } + + static function blowCaches($tagger, $tagged) { + foreach (array(0, 1) as $perm) { + self::blow(sprintf('profile_tag:tagger_tagged_privacy:%d-%d-%d', $tagger, $tagged, $perm)); + } + return true; } } diff --git a/classes/Profile_tag_inbox.php b/classes/Profile_tag_inbox.php new file mode 100644 index 0000000000..dd517b3088 --- /dev/null +++ b/classes/Profile_tag_inbox.php @@ -0,0 +1,27 @@ +private) { + return false; + } + + if (Event::handle('StartSubscribePeopletag', array($peopletag, $profile))) { + $args = array('profile_tag_id' => $peopletag->id, + 'profile_id' => $profile->id); + $existing = Profile_tag_subscription::pkeyGet($args); + if(!empty($existing)) { + return $existing; + } + + $sub = new Profile_tag_subscription(); + $sub->profile_tag_id = $peopletag->id; + $sub->profile_id = $profile->id; + $sub->created = common_sql_now(); + + $result = $sub->insert(); + + if (!$result) { + common_log_db_error($sub, 'INSERT', __FILE__); + throw new Exception(_("Adding people tag subscription failed.")); + } + + $ptag = Profile_list::staticGet('id', $peopletag->id); + $ptag->subscriberCount(true); + + Event::handle('EndSubscribePeopletag', array($peopletag, $profile)); + return $ptag; + } + } + + static function remove($peopletag, $profile) + { + $sub = Profile_tag_subscription::pkeyGet(array('profile_tag_id' => $peopletag->id, + 'profile_id' => $profile->id)); + + if (empty($sub)) { + // silence is golden? + return true; + } + + if (Event::handle('StartUnsubscribePeopletag', array($peopletag, $profile))) { + $result = $sub->delete(); + + if (!$result) { + common_log_db_error($sub, 'DELETE', __FILE__); + throw new Exception(_("Removing people tag subscription failed.")); + } + + $peopletag->subscriberCount(true); + + Event::handle('EndUnsubscribePeopletag', array($peopletag, $profile)); + return true; + } + } + + // called if a tag gets deleted / made private + static function cleanup($profile_list) { + $subs = new self(); + $subs->profile_tag_id = $profile_list->id; + $subs->find(); + + while($subs->fetch()) { + $profile = Profile::staticGet('id', $subs->profile_id); + Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile)); + // Delete anyway + $subs->delete(); + Event::handle('StartUnsubscribePeopletag', array($profile_list, $profile)); + } + } +} diff --git a/classes/User.php b/classes/User.php index 970e167a3b..be362e67fa 100644 --- a/classes/User.php +++ b/classes/User.php @@ -504,12 +504,12 @@ class User extends Memcached_DataObject function getSelfTags() { - return Profile_tag::getTags($this->id, $this->id); + return Profile_tag::getTagsArray($this->id, $this->id, $this->id); } - function setSelfTags($newtags) + function setSelfTags($newtags, $privacy) { - return Profile_tag::setTags($this->id, $this->id, $newtags); + return Profile_tag::setTags($this->id, $this->id, $newtags, $privacy); } function block($other) diff --git a/classes/statusnet.ini b/classes/statusnet.ini index bf8d173805..6b68dfe713 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -460,6 +460,43 @@ tagger = K tagged = K tag = K +[profile_list] +id = 129 +tagger = 129 +tag = 130 +description = 34 +private = 17 +created = 142 +modified = 384 +uri = 130 +mainpage = 130 +tagged_count = 129 +subscriber_count = 129 + +[profile_list__keys] +id = U +tagger = K +tag = K + +[profile_tag_inbox] +profile_tag_id = 129 +notice_id = 129 +created = 142 + +[profile_tag_inbox__keys] +profile_tag_id = K +notice_id = K + +[profile_tag_subscription] +profile_tag_id = 129 +profile_id = 129 +created = 142 +modified = 384 + +[profile_tag_subscription__keys] +profile_tag_id = K +profile_id = K + [queue_item] id = 129 frame = 194 diff --git a/classes/statusnet.links.ini b/classes/statusnet.links.ini index b9dd5af0c9..28bf03fd45 100644 --- a/classes/statusnet.links.ini +++ b/classes/statusnet.links.ini @@ -55,3 +55,23 @@ file_id = file:id file_id = file:id post_id = notice:id +[profile_list] +tagger = profile:id + +[profile_tag] +tagger = profile:id +tagged = profile:id +; in class definition: +;tag,tagger = profile_list:tag,tagger + +[profile_list] +tagger = profile:id + +[profile_tag_inbox] +profile_tag_id = profile_list:id +notice_id = notice:id + +[profile_tag_subscription] +profile_tag_id = profile_list:id +profile_id = profile:id + From 4b8ee81ca90a5c1b49dd8224a2d6b2e7b6d813ed Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Sun, 6 Mar 2011 23:33:39 +0530 Subject: [PATCH 011/726] Utility functions for people tags --- lib/default.php | 5 +++++ lib/framework.php | 1 + lib/util.php | 20 +++++++++++--------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/default.php b/lib/default.php index c612557d69..40372e756b 100644 --- a/lib/default.php +++ b/lib/default.php @@ -269,6 +269,11 @@ $default = 'group' => array('maxaliases' => 3, 'desclimit' => null), + 'peopletag' => + array('maxtags' => 100, // maximum number of tags a user can create. + 'maxpeople' => 500, // maximum no. of people with the same tag by the same user + 'allow_tagging' => array('all' => true), // equivalent to array('local' => true, 'remote' => true) + 'desclimit' => null), 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'), 'search' => array('type' => 'fulltext'), diff --git a/lib/framework.php b/lib/framework.php index 350a1c268d..b624e312e1 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -45,6 +45,7 @@ define('NOTICE_INBOX_SOURCE_SUB', 1); define('NOTICE_INBOX_SOURCE_GROUP', 2); define('NOTICE_INBOX_SOURCE_REPLY', 3); define('NOTICE_INBOX_SOURCE_FORWARD', 4); +define('NOTICE_INBOX_SOURCE_PROFILE_TAG', 5); define('NOTICE_INBOX_SOURCE_GATEWAY', -1); # append our extlib dir as the last-resort place to find libs diff --git a/lib/util.php b/lib/util.php index 9f84e3120a..2e6768f90e 100644 --- a/lib/util.php +++ b/lib/util.php @@ -753,17 +753,19 @@ function common_find_mentions($text, $notice) foreach ($hmatches[1] as $hmatch) { $tag = common_canonical_tag($hmatch[0]); + $plist = Profile_list::getByTaggerAndTag($sender->id, $tag); + if (!empty($plist) && !$plist->private) { + $tagged = $sender->getTaggedSubscribers($tag); - $tagged = Profile_tag::getTagged($sender->id, $tag); + $url = common_local_url('showprofiletag', + array('tagger' => $sender->nickname, + 'tag' => $tag)); - $url = common_local_url('subscriptions', - array('nickname' => $sender->nickname, - 'tag' => $tag)); - - $mentions[] = array('mentioned' => $tagged, - 'text' => $hmatch[0], - 'position' => $hmatch[1], - 'url' => $url); + $mentions[] = array('mentioned' => $tagged, + 'text' => $hmatch[0], + 'position' => $hmatch[1], + 'url' => $url); + } } Event::handle('EndFindMentions', array($sender, $text, &$mentions)); From 371e923c37d947c8b276f555e612763f331dd31c Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Sun, 6 Mar 2011 23:36:38 +0530 Subject: [PATCH 012/726] Twitter lists compatible people tags api --- actions/apilist.php | 275 +++++++++++++++++++++++++++++++ actions/apilistmember.php | 124 ++++++++++++++ actions/apilistmembers.php | 173 +++++++++++++++++++ actions/apilistmemberships.php | 136 +++++++++++++++ actions/apilists.php | 244 +++++++++++++++++++++++++++ actions/apilistsubscriber.php | 91 ++++++++++ actions/apilistsubscribers.php | 125 ++++++++++++++ actions/apilistsubscriptions.php | 126 ++++++++++++++ actions/apitimelinelist.php | 266 ++++++++++++++++++++++++++++++ lib/activityobject.php | 31 +++- lib/activityverb.php | 1 + lib/apiaction.php | 149 +++++++++++++++++ lib/apilistusers.php | 207 +++++++++++++++++++++++ lib/atomlistnoticefeed.php | 105 ++++++++++++ lib/router.php | 66 ++++++++ 15 files changed, 2117 insertions(+), 2 deletions(-) create mode 100644 actions/apilist.php create mode 100644 actions/apilistmember.php create mode 100644 actions/apilistmembers.php create mode 100644 actions/apilistmemberships.php create mode 100644 actions/apilists.php create mode 100644 actions/apilistsubscriber.php create mode 100644 actions/apilistsubscribers.php create mode 100644 actions/apilistsubscriptions.php create mode 100644 actions/apitimelinelist.php create mode 100644 lib/apilistusers.php create mode 100644 lib/atomlistnoticefeed.php diff --git a/actions/apilist.php b/actions/apilist.php new file mode 100644 index 0000000000..7a9ce70c5c --- /dev/null +++ b/actions/apilist.php @@ -0,0 +1,275 @@ +. + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apibareauth.php'; + +class ApiListAction extends ApiBareAuthAction +{ + /** + * The list in question in the current request + */ + + var $list = null; + + /** + * Is this an update request? + */ + + var $update = false; + + /** + * Is this a delete request? + */ + + var $delete = false; + + /** + * Set the flags for handling the request. Show list if this is a GET + * request, update it if it is POST, delete list if method is DELETE + * or if method is POST and an argument _method is set to DELETE. Act + * like we don't know if the current user has no access to the list. + * + * Takes parameters: + * - user: the user id or nickname + * - id: the id of the tag or the tag itself + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + $this->delete = ($_SERVER['REQUEST_METHOD'] == 'DELETE' || + ($this->trimmed('_method') == 'DELETE' && + $_SERVER['REQUEST_METHOD'] == 'POST')); + + // update list if method is POST or PUT and $this->delete is not true + $this->update = (!$this->delete && + in_array($_SERVER['REQUEST_METHOD'], array('POST', 'PUT'))); + + $this->user = $this->getTargetUser($this->arg('user')); + $this->list = $this->getTargetList($this->arg('user'), $this->arg('id')); + + if (empty($this->list)) { + $this->clientError(_('Not found'), 404, $this->format); + return false; + } + + return true; + } + + /** + * Handle the request + * + * @return boolean success flag + */ + + function handle($args) + { + parent::handle($args); + + if($this->delete) { + $this->handleDelete(); + return true; + } + + if($this->update) { + $this->handlePut(); + return true; + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($this->list); + break; + case 'json': + $this->showSingleJsonList($this->list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } + + /** + * require authentication if it is a write action or user is ambiguous + * + */ + + function requiresAuth() + { + return parent::requiresAuth() || + $this->create || $this->delete; + } + + /** + * Update a list + * + * @return boolean success + */ + + function handlePut() + { + if($this->auth_user->id != $this->list->tagger) { + $this->clientError( + _('You can not update lists that don\'t belong to you.'), + 401, + $this->format + ); + } + + $new_list = clone($this->list); + $new_list->tag = common_canonical_tag($this->arg('name')); + $new_list->description = common_canonical_tag($this->arg('description')); + $new_list->private = ($this->arg('mode') === 'private') ? true : false; + + $result = $new_list->update($this->list); + + if(!$result) { + $this->clientError( + _('An error occured.'), + 503, + $this->format + ); + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($new_list); + break; + case 'json': + $this->showSingleJsonList($new_list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } + + /** + * Delete a list + * + * @return boolean success + */ + + function handleDelete() + { + if($this->auth_user->id != $this->list->tagger) { + $this->clientError( + _('You can not delete lists that don\'t belong to you.'), + 401, + $this->format + ); + } + + $record = clone($this->list); + $this->list->delete(); + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($record); + break; + case 'json': + $this->showSingleJsonList($record); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } + + /** + * Indicate that this resource is not read-only. + * + * @return boolean is_read-only=false + */ + + function isReadOnly($args) + { + return false; + } + + /** + * When was the list (people tag) last updated? + * + * @return String time_last_modified + */ + + function lastModified() + { + if(!empty($this->list)) { + return strtotime($this->list->modified); + } + return null; + } + + /** + * An entity tag for this list + * + * Returns an Etag based on the action name, language, user ID and + * timestamps of the first and last list the user has joined + * + * @return string etag + */ + + function etag() + { + if (!empty($this->list)) { + + return '"' . implode( + ':', + array($this->arg('action'), + common_language(), + $this->user->id, + strtotime($this->list->created), + strtotime($this->list->modified)) + ) + . '"'; + } + + return null; + } + +} diff --git a/actions/apilistmember.php b/actions/apilistmember.php new file mode 100644 index 0000000000..18d6ea370b --- /dev/null +++ b/actions/apilistmember.php @@ -0,0 +1,124 @@ +. + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apibareauth.php'; + +/** + * Action handler for Twitter list_memeber methods + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * @see ApiBareAuthAction + */ + +class ApiListMemberAction extends ApiBareAuthAction +{ + /** + * Set the flags for handling the request. Show the profile if this + * is a GET request AND the profile is a member of the list, add a member + * if it is a POST, remove the profile from the list if method is DELETE + * or if method is POST and an argument _method is set to DELETE. Act + * like we don't know if the current user has no access to the list. + * + * Takes parameters: + * - user: the user id or nickname + * - list_id: the id of the tag or the tag itself + * - id: the id of the member being looked for/added/removed + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + $this->user = $this->getTargetUser($this->arg('id')); + $this->list = $this->getTargetList($this->arg('user'), $this->arg('list_id')); + + if (empty($this->list)) { + $this->clientError(_('Not found'), 404, $this->format); + return false; + } + + if (empty($this->user)) { + $this->clientError(_('No such user'), 404, $this->format); + return false; + } + return true; + } + + /** + * Handle the request + * + * @return boolean success flag + */ + + function handle($args) + { + parent::handle($args); + + $arr = array('tagger' => $this->list->tagger, + 'tag' => $this->list->tag, + 'tagged' => $this->user->id); + $ptag = Profile_tag::pkeyGet($arr); + + if(empty($ptag)) { + $this->clientError( + _('The specified user is not a member of this list'), + 400, + $this->format + ); + } + + $user = $this->twitterUserArray($this->user->getProfile(), true); + + switch($this->format) { + case 'xml': + $this->showTwitterXmlUser($user, 'user', true); + break; + case 'json': + $this->showSingleJsonUser($user); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + return true; + } +} diff --git a/actions/apilistmembers.php b/actions/apilistmembers.php new file mode 100644 index 0000000000..c6e92fa612 --- /dev/null +++ b/actions/apilistmembers.php @@ -0,0 +1,173 @@ +. + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apilistusers.php'; + +class ApiListMembersAction extends ApiListUsersAction +{ + /** + * Add a user to a list (tag someone) + * + * @return boolean success + */ + + function handlePost() + { + if($this->auth_user->id != $this->list->tagger) { + $this->clientError( + _('You aren\'t allowed to add members to this list'), + 401, + $this->format + ); + return false; + } + + if($this->user === false) { + $this->clientError( + _('You must specify a member'), + 400, + $this->format + ); + return false; + } + + $result = Profile_tag::setTag($this->auth_user->id, + $this->user->id, $this->list->tag); + + if(empty($result)) { + $this->clientError( + _('An error occured.'), + 500, + $this->format + ); + return false; + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($this->list); + break; + case 'json': + $this->showSingleJsonList($this->list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + return false; + break; + } + } + + /** + * Remove a user from a list (untag someone) + * + * @return boolean success + */ + + function handleDelete() + { + if($this->auth_user->id != $this->list->tagger) { + $this->clientError( + _('You aren\'t allowed to remove members from this list'), + 401, + $this->format + ); + return false; + } + + if($this->user === false) { + $this->clientError( + _('You must specify a member'), + 400, + $this->format + ); + return false; + } + + $args = array('tagger' => $this->auth_user->id, + 'tagged' => $this->user->id, + 'tag' => $this->list->tag); + $ptag = Profile_tag::pkeyGet($args); + + if(empty($ptag)) { + $this->clientError( + _('The user you are trying to remove from the list is not a member'), + 400, + $this->format + ); + return false; + } + + $result = $ptag->delete(); + + if(empty($result)) { + $this->clientError( + _('An error occured.'), + 500, + $this->format + ); + return false; + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($this->list); + break; + case 'json': + $this->showSingleJsonList($this->list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + return false; + break; + } + return true; + } + + /** + * List the members of a list (people tagged) + */ + + function getUsers() + { + $fn = array($this->list, 'getTagged'); + list($this->users, $this->next_cursor, $this->prev_cursor) = + Profile_list::getAtCursor($fn, array(), $this->cursor, 20); + } +} diff --git a/actions/apilistmemberships.php b/actions/apilistmemberships.php new file mode 100644 index 0000000000..635f970e87 --- /dev/null +++ b/actions/apilistmemberships.php @@ -0,0 +1,136 @@ +. + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apibareauth.php'; + +/** + * Action handler for API method to list lists a user belongs to. + * (people tags for a user) + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * @see ApiBareAuthAction + */ + +class ApiListMembershipsAction extends ApiBareAuthAction +{ + var $lists = array(); + var $cursor = -1; + var $next_cursor = 0; + var $prev_cursor = 0; + + /** + * Prepare for running the action + * Take arguments for running:s + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + + $this->cursor = (int) $this->arg('cursor', -1); + $this->user = $this->getTargetUser($this->arg('user')); + + if (empty($this->user)) { + $this->clientError(_('No such user.'), 404, $this->format); + return; + } + + $this->getLists(); + + return true; + } + + /** + * Handle the request + * + * Show the lists + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + switch($this->format) { + case 'xml': + $this->showXmlLists($this->lists, $this->next_cursor, $this->prev_cursor); + break; + case 'json': + $this->showJsonLists($this->lists, $this->next_cursor, $this->prev_cursor); + break; + default: + $this->clientError( + _('API method not found.'), + 400, + $this->format + ); + break; + } + } + + /** + * Return true if read only. + * + * MAY override + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ + + function isReadOnly($args) + { + return true; + } + + function getLists() + { + $profile = $this->user->getProfile(); + $fn = array($profile, 'getOtherTags'); + + # 20 lists + list($this->lists, $this->next_cursor, $this->prev_cursor) = + Profile_list::getAtCursor($fn, array($this->auth_user), $this->cursor, 20); + } +} diff --git a/actions/apilists.php b/actions/apilists.php new file mode 100644 index 0000000000..f520e32972 --- /dev/null +++ b/actions/apilists.php @@ -0,0 +1,244 @@ +. + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apibareauth.php'; + +/** + * Action handler for Twitter list_memeber methods + * + * @category API + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * @see ApiBareAuthAction + */ + +class ApiListsAction extends ApiBareAuthAction +{ + var $lists = null; + var $cursor = 0; + var $next_cursor = 0; + var $prev_cursor = 0; + var $create = false; + + /** + * Set the flags for handling the request. List lists created by user if this + * is a GET request, create a new list if it is a POST request. + * + * Takes parameters: + * - user: the user id or nickname + * Parameters for POST request + * - name: name of the new list (the people tag itself) + * - mode: (optional) mode for the new list private/public + * - description: (optional) description for the list + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + $this->create = ($_SERVER['REQUEST_METHOD'] == 'POST'); + + if (!$this->create) { + + $this->user = $this->getTargetUser($this->arg('user')); + + if (empty($this->user)) { + $this->clientError(_('No such user.'), 404, $this->format); + return false; + } + $this->getLists(); + } + + return true; + } + + /** + * require authentication if it is a write action or user is ambiguous + * + */ + + function requiresAuth() + { + return parent::requiresAuth() || + $this->create || $this->delete; + } + + /** + * Handle request: + * Show the lists the user has created if the request method is GET + * Create a new list by diferring to handlePost() if it is POST. + */ + + function handle($args) + { + parent::handle($args); + + if($this->create) { + return $this->handlePost(); + } + + switch($this->format) { + case 'xml': + $this->showXmlLists($this->lists, $this->next_cursor, $this->prev_cursor); + break; + case 'json': + $this->showJsonLists($this->lists, $this->next_cursor, $this->prev_cursor); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } + + /** + * Create a new list + * + * @return boolean success + */ + + function handlePost() + { + $name=$this->arg('name'); + if(empty($name)) { + // mimick twitter + print _("A list's name can't be blank."); + exit(1); + } + + // twitter creates a new list by appending a number to the end + // if the list by the given name already exists + // it makes more sense to return the existing list instead + + $private = null; + if ($this->arg('mode') === 'public') { + $private = false; + } else if ($this->arg('mode') === 'private') { + $private = true; + } + + $list = Profile_list::ensureTag($this->auth_user->id, + $this->arg('name'), + $this->arg('description'), + $private); + if (empty($list)) { + return false; + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($list); + break; + case 'json': + $this->showSingleJsonList($list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + return true; + } + + /** + * Get lists + */ + + function getLists() + { + $cursor = (int) $this->arg('cursor', -1); + + // twitter fixes count at 20 + // there is no argument named count + $count = 20; + $profile = $this->user->getProfile(); + $fn = array($profile, 'getOwnedTags'); + + list($this->lists, + $this->next_cursor, + $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->auth_user), $cursor, $count); + } + + function isReadOnly($args) + { + return false; + } + + function lastModified() + { + if (!$this->create && !empty($this->lists) && (count($this->lists) > 0)) { + return strtotime($this->lists[0]->created); + } + + return null; + } + + /** + * An entity tag for this list of lists + * + * Returns an Etag based on the action name, language, user ID and + * timestamps of the first and last list the user has joined + * + * @return string etag + */ + + function etag() + { + if (!$this->create && !empty($this->lists) && (count($this->lists) > 0)) { + + $last = count($this->lists) - 1; + + return '"' . implode( + ':', + array($this->arg('action'), + common_language(), + $this->user->id, + strtotime($this->lists[0]->created), + strtotime($this->lists[$last]->created)) + ) + . '"'; + } + + return null; + } + +} diff --git a/actions/apilistsubscriber.php b/actions/apilistsubscriber.php new file mode 100644 index 0000000000..d6816b9b91 --- /dev/null +++ b/actions/apilistsubscriber.php @@ -0,0 +1,91 @@ +. + * + * @category API + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apiauth.php'; + +class ApiListSubscriberAction extends ApiBareAuthAction +{ + var $list = null; + + function prepare($args) + { + parent::prepare($args); + + $this->user = $this->getTargetUser($this->arg('id')); + $this->list = $this->getTargetList($this->arg('user'), $this->arg('list_id')); + + if (empty($this->list)) { + $this->clientError(_('Not found'), 404, $this->format); + return false; + } + + if (empty($this->user)) { + $this->clientError(_('No such user'), 404, $this->format); + return false; + } + return true; + } + + function handle($args) + { + parent::handle($args); + + $arr = array('profile_tag_id' => $this->list->id, + 'profile_id' => $this->user->id); + $sub = Profile_tag_subscription::pkeyGet($arr); + + if(empty($sub)) { + $this->clientError( + _('The specified user is not a subscriber of this list'), + 400, + $this->format + ); + } + + $user = $this->twitterUserArray($this->user->getProfile(), true); + + switch($this->format) { + case 'xml': + $this->showTwitterXmlUser($user, 'user', true); + break; + case 'json': + $this->showSingleJsonUser($user); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } +} diff --git a/actions/apilistsubscribers.php b/actions/apilistsubscribers.php new file mode 100644 index 0000000000..e8468a195d --- /dev/null +++ b/actions/apilistsubscribers.php @@ -0,0 +1,125 @@ +. + * + * @category API + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apilistusers.php'; + +class ApiListSubscribersAction extends ApiListUsersAction +{ + /** + * Subscribe to list + * + * @return boolean success + */ + + function handlePost() + { + $result = Profile_tag_subscription::add($this->list, + $this->auth_user); + + if(empty($result)) { + $this->clientError( + _('An error occured.'), + 500, + $this->format + ); + return false; + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($this->list); + break; + case 'json': + $this->showSingleJsonList($this->list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + return false; + break; + } + } + + function handleDelete() + { + $args = array('profile_tag_id' => $this->list->id, + 'profile_id' => $this->auth_user->id); + $ptag = Profile_tag_subscription::pkeyGet($args); + + if(empty($ptag)) { + $this->clientError( + _('You are not subscribed to this list'), + 400, + $this->format + ); + return false; + } + + Profile_tag_subscription::remove($this->list, $this->auth_user); + + if(empty($result)) { + $this->clientError( + _('An error occured.'), + 500, + $this->format + ); + return false; + } + + switch($this->format) { + case 'xml': + $this->showSingleXmlList($this->list); + break; + case 'json': + $this->showSingleJsonList($this->list); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + return false; + break; + } + return true; + } + + function getUsers() + { + $fn = array($this->list, 'getSubscribers'); + list($this->users, $this->next_cursor, $this->prev_cursor) = + Profile_list::getAtCursor($fn, array(), $this->cursor, 20); + } +} diff --git a/actions/apilistsubscriptions.php b/actions/apilistsubscriptions.php new file mode 100644 index 0000000000..764360e149 --- /dev/null +++ b/actions/apilistsubscriptions.php @@ -0,0 +1,126 @@ +. + * + * @category API + * @package StatusNet + * @copyright 2009 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apibareauth.php'; + +class ApiListSubscriptionsAction extends ApiBareAuthAction +{ + var $lists = array(); + var $cursor = -1; + var $next_cursor = 0; + var $prev_cursor = 0; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + + $this->cursor = (int) $this->arg('cursor', -1); + $this->user = $this->getTargetUser($this->arg('user')); + $this->getLists(); + + return true; + } + + /** + * Handle the request + * + * Show the lists + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + if (empty($this->user)) { + $this->clientError(_('No such user.'), 404, $this->format); + return; + } + + switch($this->format) { + case 'xml': + $this->showXmlLists($this->lists, $this->next_cursor, $this->prev_cursor); + break; + case 'json': + $this->showJsonLists($this->lists, $this->next_cursor, $this->prev_cursor); + break; + default: + $this->clientError( + _('API method not found.'), + 400, + $this->format + ); + break; + } + } + + /** + * Return true if read only. + * + * MAY override + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ + + function isReadOnly($args) + { + return true; + } + + function getLists() + { + if(empty($this->user)) { + return; + } + + $profile = $this->user->getProfile(); + $fn = array($profile, 'getTagSubscriptions'); + # 20 lists + list($this->lists, $this->next_cursor, $this->prev_cursor) = + Profile_list::getAtCursor($fn, array(), $this->cursor, 20); + } +} diff --git a/actions/apitimelinelist.php b/actions/apitimelinelist.php new file mode 100644 index 0000000000..f28eb59d53 --- /dev/null +++ b/actions/apitimelinelist.php @@ -0,0 +1,266 @@ +. + * + * @category API + * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Zach Copley + * @copyright 2009 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apiprivateauth.php'; +require_once INSTALLDIR . '/lib/atomlistnoticefeed.php'; + +/** + * Returns the most recent notices (default 20) posted to the list specified by ID + * + * @category API + * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ApiTimelineListAction extends ApiPrivateAuthAction +{ + + var $list = null; + var $notices = array(); + var $next_cursor = 0; + var $prev_cursor = 0; + var $cursor = -1; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + + $this->cursor = (int) $this->arg('cursor', -1); + $this->list = $this->getTargetList($this->arg('user'), $this->arg('id')); + + return true; + } + + /** + * Handle the request + * + * Just show the notices + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + if (empty($this->list)) { + $this->clientError(_('List not found.'), 404, $this->format); + return false; + } + + $this->getNotices(); + $this->showTimeline(); + } + + /** + * Show the timeline of notices + * + * @return void + */ + + function showTimeline() + { + // We'll pull common formatting out of this for other formats + $atom = new AtomListNoticeFeed($this->list, $this->auth_user); + + $self = $this->getSelfUri(); + + switch($this->format) { + case 'xml': + $this->initDocument('xml'); + $this->elementStart('statuses_list', + array('xmlns:statusnet' => 'http://status.net/schema/api/1/')); + $this->elementStart('statuses', array('type' => 'array')); + + foreach ($this->notices as $n) { + $twitter_status = $this->twitterStatusArray($n); + $this->showTwitterXmlStatus($twitter_status); + } + + $this->elementEnd('statuses'); + $this->element('next_cursor', null, $this->next_cursor); + $this->element('previous_cursor', null, $this->prev_cursor); + $this->elementEnd('statuses_list'); + $this->endDocument('xml'); + break; + case 'rss': + $this->showRssTimeline( + $this->notices, + $atom->title, + $this->list->getUri(), + $atom->subtitle, + null, + $atom->logo, + $self + ); + break; + case 'atom': + + header('Content-Type: application/atom+xml; charset=utf-8'); + + try { + $atom->setId($self); + $atom->setSelfLink($self); + $atom->addEntryFromNotices($this->notices); + $this->raw($atom->getString()); + } catch (Atom10FeedException $e) { + $this->serverError( + 'Could not generate feed for list - ' . $e->getMessage() + ); + return; + } + + break; + case 'json': + $this->initDocument('json'); + + $statuses = array(); + foreach ($this->notices as $n) { + $twitter_status = $this->twitterStatusArray($n); + array_push($statuses, $twitter_status); + } + + $statuses_list = array('statuses' => $statuses, + 'next_cursor' => $this->next_cusror, + 'next_cursor_str' => strval($this->next_cusror), + 'previous_cursor' => $this->prev_cusror, + 'previous_cursor_str' => strval($this->prev_cusror) + ); + $this->showJsonObjects($statuses_list); + + $this->initDocument('json'); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } + + /** + * Get notices + * + * @return array notices + */ + + function getNotices() + { + $fn = array($this->list, 'getNotices'); + list($this->notices, $this->next_cursor, $this->prev_cursor) = + Profile_list::getAtCursor($fn, array(), $this->cursor, 20); + if (!$this->notices) { + $this->notices = array(); + } + } + + /** + * Is this action read only? + * + * @param array $args other arguments + * + * @return boolean true + */ + + function isReadOnly($args) + { + return true; + } + + /** + * When was this feed last modified? + * + * @return string datestamp of the latest notice in the stream + */ + + function lastModified() + { + if (!empty($this->notices) && (count($this->notices) > 0)) { + return strtotime($this->notices[0]->created); + } + + return null; + } + + /** + * An entity tag for this stream + * + * Returns an Etag based on the action name, language, list ID and + * timestamps of the first and last notice in the timeline + * + * @return string etag + */ + + function etag() + { + if (!empty($this->notices) && (count($this->notices) > 0)) { + + $last = count($this->notices) - 1; + + return '"' . implode( + ':', + array($this->arg('action'), + common_language(), + $this->list->id, + strtotime($this->notices[0]->created), + strtotime($this->notices[$last]->created)) + ) + . '"'; + } + + return null; + } + +} diff --git a/lib/activityobject.php b/lib/activityobject.php index a69e1a1b42..7771455443 100644 --- a/lib/activityobject.php +++ b/lib/activityobject.php @@ -64,6 +64,7 @@ class ActivityObject const BOOKMARK = 'http://activitystrea.ms/schema/1.0/bookmark'; const PERSON = 'http://activitystrea.ms/schema/1.0/person'; const GROUP = 'http://activitystrea.ms/schema/1.0/group'; + const _LIST = 'http://activitystrea.ms/schema/1.0/list'; // LIST is reserved const PLACE = 'http://activitystrea.ms/schema/1.0/place'; const COMMENT = 'http://activitystrea.ms/schema/1.0/comment'; // ^^^^^^^^^^ tea! @@ -92,6 +93,7 @@ class ActivityObject public $title; public $summary; public $content; + public $owner; public $link; public $source; public $avatarLinks = array(); @@ -168,6 +170,10 @@ class ActivityObject Activity::MEDIA ); } + if ($this->type == self::_LIST) { + $owner = ActivityUtils::child($this->element, Activity::AUTHOR, Activity::SPEC); + $this->owner = new ActivityObject($owner); + } } private function _fromAuthor($element) @@ -520,13 +526,29 @@ class ActivityObject AVATAR_MINI_SIZE); $object->poco = PoCo::fromGroup($group); - - Event::handle('EndActivityObjectFromGroup', array($group, &$object)); + Event::handle('EndActivityObjectFromGroup', array($group, &$object)); } return $object; } + static function fromPeopletag($ptag) + { + $object = new ActivityObject(); + if (Event::handle('StartActivityObjectFromPeopletag', array($ptag, &$object))) { + $object->type = ActivityObject::_LIST; + + $object->id = $ptag->getUri(); + $object->title = $ptag->tag; + $object->summary = $ptag->description; + $object->link = $ptag->homeUrl(); + $object->owner = Profile::staticGet('id', $ptag->tagger); + $object->poco = PoCo::fromProfile($object->owner); + Event::handle('EndActivityObjectFromPeopletag', array($ptag, &$object)); + } + return $object; + } + function outputTo($xo, $tag='activity:object') { if (!empty($tag)) { @@ -601,6 +623,11 @@ class ActivityObject } } + if(!empty($this->owner)) { + $owner = $this->owner->asActivityNoun(self::AUTHOR); + $xo->raw($owner); + } + if (!empty($this->geopoint)) { $xo->element( 'georss:point', diff --git a/lib/activityverb.php b/lib/activityverb.php index 264351308b..5ee68f2880 100644 --- a/lib/activityverb.php +++ b/lib/activityverb.php @@ -59,6 +59,7 @@ class ActivityVerb const UNFAVORITE = 'http://ostatus.org/schema/1.0/unfavorite'; const UNFOLLOW = 'http://ostatus.org/schema/1.0/unfollow'; const LEAVE = 'http://ostatus.org/schema/1.0/leave'; + const UNTAG = 'http://ostatus.org/schema/1.0/untag'; // For simple profile-update pings; no content to share. const UPDATE_PROFILE = 'http://ostatus.org/schema/1.0/update-profile'; diff --git a/lib/apiaction.php b/lib/apiaction.php index ebda36db7f..a77d5da13f 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -458,6 +458,32 @@ class ApiAction extends Action return $entry; } + function twitterListArray($list) + { + $profile = Profile::staticGet('id', $list->tagger); + + $twitter_list = array(); + $twitter_list['id'] = $list->id; + $twitter_list['name'] = $list->tag; + $twitter_list['full_name'] = '@'.$profile->nickname.'/'.$list->tag;; + $twitter_list['slug'] = $list->tag; + $twitter_list['description'] = $list->description; + $twitter_list['subscriber_count'] = $list->subscriberCount(); + $twitter_list['member_count'] = $list->taggedCount(); + $twitter_list['uri'] = $list->getUri(); + + if (isset($this->auth_user)) { + $twitter_list['following'] = $list->hasSubscriber($this->auth_user); + } else { + $twitter_list['following'] = false; + } + + $twitter_list['mode'] = ($list->private) ? 'private' : 'public'; + $twitter_list['user'] = $this->twitterUserArray($profile, false); + + return $twitter_list; + } + function twitterRssEntryArray($notice) { $entry = array(); @@ -633,6 +659,20 @@ class ApiAction extends Action $this->elementEnd('group'); } + function showTwitterXmlList($twitter_list) + { + $this->elementStart('list'); + foreach($twitter_list as $element => $value) { + if($element == 'user') { + $this->showTwitterXmlUser($value, 'user'); + } + else { + $this->element($element, null, $value); + } + } + $this->elementEnd('list'); + } + function showTwitterXmlUser($twitter_user, $role='user', $namespaces=false) { $attrs = array(); @@ -1110,6 +1150,65 @@ class ApiAction extends Action $this->endDocument('xml'); } + function showXmlLists($list, $next_cursor=0, $prev_cursor=0) + { + + $this->initDocument('xml'); + $this->elementStart('lists_list'); + $this->elementStart('lists', array('type' => 'array')); + + if (is_array($list)) { + foreach ($list as $l) { + $twitter_list = $this->twitterListArray($l); + $this->showTwitterXmlList($twitter_list); + } + } else { + while ($list->fetch()) { + $twitter_list = $this->twitterListArray($list); + $this->showTwitterXmlList($twitter_list); + } + } + + $this->elementEnd('lists'); + + $this->element('next_cursor', null, $next_cursor); + $this->element('previous_cursor', null, $prev_cursor); + + $this->elementEnd('lists_list'); + $this->endDocument('xml'); + } + + function showJsonLists($list, $next_cursor=0, $prev_cursor=0) + { + $this->initDocument('json'); + + $lists = array(); + + if (is_array($list)) { + foreach ($list as $l) { + $twitter_list = $this->twitterListArray($l); + array_push($lists, $twitter_list); + } + } else { + while ($list->fetch()) { + $twitter_list = $this->twitterListArray($list); + array_push($lists, $twitter_list); + } + } + + $lists_list = array( + 'lists' => $lists, + 'next_cursor' => $next_cursor, + 'next_cursor_str' => strval($next_cursor), + 'previous_cursor' => $prev_cursor, + 'previous_cursor_str' => strval($prev_cursor) + ); + + $this->showJsonObjects($lists_list); + + $this->endDocument('json'); + } + function showTwitterXmlUsers($user) { $this->initDocument('xml'); @@ -1171,6 +1270,22 @@ class ApiAction extends Action $this->endDocument('xml'); } + function showSingleJsonList($list) + { + $this->initDocument('json'); + $twitter_list = $this->twitterListArray($list); + $this->showJsonObjects($twitter_list); + $this->endDocument('json'); + } + + function showSingleXmlList($list) + { + $this->initDocument('xml'); + $twitter_list = $this->twitterListArray($list); + $this->showTwitterXmlList($twitter_list); + $this->endDocument('xml'); + } + function dateTwitter($dt) { $dateStr = date('d F Y H:i:s', strtotime($dt)); @@ -1464,6 +1579,40 @@ class ApiAction extends Action } } + function getTargetList($user=null, $id=null) + { + $tagger = $this->getTargetUser($user); + $list = null; + + if (empty($id)) { + $id = $this->arg('id'); + } + + if($id) { + if (is_numeric($id)) { + $list = Profile_list::staticGet('id', $id); + + // only if the list with the id belongs to the tagger + if(empty($list) || $list->tagger != $tagger->id) { + $list = null; + } + } + if (empty($list)) { + $tag = common_canonical_tag($id); + $list = Profile_list::getByTaggerAndTag($tagger->id, $tag); + } + + if (!empty($list) && $list->private) { + if ($this->auth_user->id == $list->tagger) { + return $list; + } + } else { + return $list; + } + } + return null; + } + /** * Returns query argument or default value if not found. Certain * parameters used throughout the API are lightly scrubbed and diff --git a/lib/apilistusers.php b/lib/apilistusers.php new file mode 100644 index 0000000000..e4451c7c41 --- /dev/null +++ b/lib/apilistusers.php @@ -0,0 +1,207 @@ +. + * + * @category API + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apibareauth.php'; + +class ApiListUsersAction extends ApiBareAuthAction +{ + var $list = null; + var $user = false; + var $create = false; + var $delete = false; + var $cursor = -1; + var $next_cursor = 0; + var $prev_cursor = 0; + var $users = null; + + function prepare($args) + { + // delete list member if method is DELETE or if method is POST and an argument + // _method is set to DELETE + $this->delete = ($_SERVER['REQUEST_METHOD'] == 'DELETE' || + ($this->trimmed('_method') == 'DELETE' && + $_SERVER['REQUEST_METHOD'] == 'POST')); + + // add member if method is POST + $this->create = (!$this->delete && + $_SERVER['REQUEST_METHOD'] == 'POST'); + + if($this->arg('id')) { + $this->user = $this->getTargetUser($this->arg('id')); + } + + parent::prepare($args); + + $this->list = $this->getTargetList($this->arg('user'), $this->arg('list_id')); + + if (empty($this->list)) { + $this->clientError(_('Not found'), 404, $this->format); + return false; + } + + if(!$this->create && !$this->delete) { + $this->getUsers(); + } + return true; + } + + function requiresAuth() + { + return parent::requiresAuth() || + $this->create || $this->delete; + } + + function handle($args) + { + parent::handle($args); + + if($this->delete) { + return $this->handleDelete(); + } + + if($this->create) { + return $this->handlePost(); + } + + switch($this->format) { + case 'xml': + $this->initDocument('xml'); + $this->elementStart('users_list', array('xmlns:statusnet' => + 'http://status.net/schema/api/1/')); + $this->elementStart('users', array('type' => 'array')); + + if (is_array($this->users)) { + foreach ($this->users as $u) { + $twitter_user = $this->twitterUserArray($u, true); + $this->showTwitterXmlUser($twitter_user); + } + } else { + while ($this->users->fetch()) { + $twitter_user = $this->twitterUserArray($this->users, true); + $this->showTwitterXmlUser($twitter_user); + } + } + + $this->elementEnd('users'); + $this->element('next_cursor', null, $this->next_cursor); + $this->element('previous_cursor', null, $this->prev_cursor); + $this->elementEnd('users_list'); + break; + case 'json': + $this->initDocument('json'); + + $users = array(); + + if (is_array($this->users)) { + foreach ($this->users as $u) { + $twitter_user = $this->twitterUserArray($u, true); + array_push($users, $twitter_user); + } + } else { + while ($this->users->fetch()) { + $twitter_user = $this->twitterUserArray($this->users, true); + array_push($users, $twitter_user); + } + } + + $users_list = array('users' => $users, + 'next_cursor' => $this->next_cursor, + 'next_cursor_str' => strval($this->next_cursor), + 'previous_cursor' => $this->prev_cursor, + 'previous_cursor_str' => strval($this->prev_cursor)); + + $this->showJsonObjects($users_list); + + $this->endDocument('json'); + break; + default: + $this->clientError( + _('API method not found.'), + 404, + $this->format + ); + break; + } + } + + function handlePost() + { + } + + function handleDelete() + { + } + + function getUsers() + { + } + + function isReadOnly($args) + { + return false; + } + + function lastModified() + { + if(!empty($this->list)) { + return strtotime($this->list->modified); + } + return null; + } + + /** + * An entity tag for this list + * + * Returns an Etag based on the action name, language, user ID and + * timestamps of the first and last list the user has joined + * + * @return string etag + */ + + function etag() + { + if (!empty($this->list)) { + + return '"' . implode( + ':', + array($this->arg('action'), + common_language(), + $this->list->id, + strtotime($this->list->created), + strtotime($this->list->modified)) + ) + . '"'; + } + + return null; + } + +} diff --git a/lib/atomlistnoticefeed.php b/lib/atomlistnoticefeed.php new file mode 100644 index 0000000000..fec7e16846 --- /dev/null +++ b/lib/atomlistnoticefeed.php @@ -0,0 +1,105 @@ +. + * + * @category Feed + * @package StatusNet + * @author Zach Copley + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) +{ + exit(1); +} + +/** + * Class for list notice feeds. May contain a reference to the list. + * + * @category Feed + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ +class AtomListNoticeFeed extends AtomNoticeFeed +{ + private $list; + private $tagger; + + /** + * Constructor + * + * @param List $list the list for the feed + * @param User $cur the current authenticated user, if any + * @param boolean $indent flag to turn indenting on or off + * + * @return void + */ + function __construct($list, $cur = null, $indent = true) { + parent::__construct($cur, $indent); + $this->list = $list; + $this->tagger = Profile::staticGet('id', $list->tagger); + + // TRANS: Title in atom list notice feed. %s is a list name. + $title = sprintf(_("Timeline for people tagged #%s by %s"), $list->tag, $this->tagger->nickname); + $this->setTitle($title); + + $sitename = common_config('site', 'name'); + $subtitle = sprintf( + // TRANS: Message is used as a subtitle in atom list notice feed. + // TRANS: %1$s is a list name, %2$s is a site name. + _('Updates from %1$s\'s %2$s people tag on %3$s!'), + $this->tagger->nickname, + $list->tag, + $sitename + ); + $this->setSubtitle($subtitle); + + $avatar = $this->tagger->avatarUrl(AVATAR_PROFILE_SIZE); + $this->setLogo($avatar); + + $this->setUpdated('now'); + + $self = common_local_url('ApiTimelineList', + array('user' => $this->tagger->nickname, + 'id' => $list->tag, + 'format' => 'atom')); + $this->setId($self); + $this->setSelfLink($self); + + // FIXME: Stop using activity:subject? + $ao = ActivityObject::fromPeopletag($this->list); + + $this->addAuthorRaw($ao->asString('author'). + $ao->asString('activity:subject')); + + $this->addLink($this->list->getUri()); + } + + function getList() + { + return $this->list; + } + +} diff --git a/lib/router.php b/lib/router.php index ccc4b09781..ee1e4cd849 100644 --- a/lib/router.php +++ b/lib/router.php @@ -766,6 +766,72 @@ class Router 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); + // Lists (people tags) + + $m->connect('api/lists/memberships.:format', + array('action' => 'ApiListMemberships', + 'format' => '(xml|json)')); + + $m->connect('api/:user/lists/memberships.:format', + array('action' => 'ApiListMemberships', + 'user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + + $m->connect('api/lists/subscriptions.:format', + array('action' => 'ApiListSubscriptions', + 'format' => '(xml|json)')); + + $m->connect('api/:user/lists/subscriptions.:format', + array('action' => 'ApiListSubscriptions', + 'user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + $m->connect('api/lists.:format', + array('action' => 'ApiLists', + 'format' => '(xml|json)')); + + $m->connect('api/:user/lists.:format', + array('action' => 'ApiLists', + 'user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + + $m->connect('api/:user/lists/:id.:format', + array('action' => 'ApiList', + 'user' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + + $m->connect('api/:user/lists/:id/statuses.:format', + array('action' => 'ApiTimelineList', + 'user' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json|rss|atom)')); + + $m->connect('api/:user/:list_id/members.:format', + array('action' => 'ApiListMembers', + 'user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + + $m->connect('api/:user/:list_id/subscribers.:format', + array('action' => 'ApiListSubscribers', + 'user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + + $m->connect('api/:user/:list_id/members/:id.:format', + array('action' => 'ApiListMember', + 'user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + + $m->connect('api/:user/:list_id/subscribers/:id.:format', + array('action' => 'ApiListSubscriber', + 'user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)')); + // Tags $m->connect('api/statusnet/tags/timeline/:tag.:format', array('action' => 'ApiTimelineTag', From f446db8e2ae9be8ae7b8489ddffcc04c6074b6f2 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Mon, 7 Mar 2011 00:39:24 +0530 Subject: [PATCH 013/726] people tag UI elements --- lib/peopletageditform.php | 200 +++++++++++ lib/peopletaggroupnav.php | 145 ++++++++ lib/peopletaglist.php | 320 +++++++++++++++++ lib/peopletags.php | 191 +++++++++++ lib/peopletagsbysubssection.php | 76 +++++ lib/peopletagsection.php | 139 ++++++++ lib/personalgroupnav.php | 6 + lib/profilelist.php | 19 ++ lib/publicgroupnav.php | 4 + lib/subgroupnav.php | 9 + lib/subscribepeopletagform.php | 114 +++++++ lib/subscriberspeopleselftagcloudsection.php | 2 +- lib/subscriberspeopletagcloudsection.php | 2 +- ...subscriptionspeopleselftagcloudsection.php | 2 +- lib/subscriptionspeopletagcloudsection.php | 2 +- lib/togglepeopletag.php | 322 ++++++++++++++++++ lib/unsubscribepeopletagform.php | 114 +++++++ lib/userprofile.php | 25 +- 18 files changed, 1673 insertions(+), 19 deletions(-) create mode 100644 lib/peopletageditform.php create mode 100644 lib/peopletaggroupnav.php create mode 100644 lib/peopletaglist.php create mode 100644 lib/peopletags.php create mode 100644 lib/peopletagsbysubssection.php create mode 100644 lib/peopletagsection.php create mode 100644 lib/subscribepeopletagform.php create mode 100644 lib/togglepeopletag.php create mode 100644 lib/unsubscribepeopletagform.php diff --git a/lib/peopletageditform.php b/lib/peopletageditform.php new file mode 100644 index 0000000000..d0b867ac37 --- /dev/null +++ b/lib/peopletageditform.php @@ -0,0 +1,200 @@ +. + * + * @category Form + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/form.php'; +require_once INSTALLDIR.'/lib/togglepeopletag.php'; + +/** + * Form for editing a peopletag + * + * @category Form + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see GroupEditForm + */ + +class PeopletagEditForm extends Form +{ + /** + * peopletag to edit + */ + + var $peopletag = null; + var $tagger = null; + + /** + * Constructor + * + * @param Action $out output channel + * @param User_group $group group to join + */ + + function __construct($out=null, Profile_list $peopletag=null) + { + parent::__construct($out); + + $this->peopletag = $peopletag; + $this->tagger = Profile::staticGet('id', $peopletag->tagger); + } + + /** + * ID of the form + * + * @return string ID of the form + */ + + function id() + { + return 'form_peopletag_edit-' . $this->peopletag->id; + } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_settings'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('editpeopletag', + array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag)); + } + + /** + * Name of the form + * + * @return void + */ + + function formLegend() + { + $this->out->element('legend', null, sprintf(_('Edit peopletag %s'), $this->peopletag->tag)); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $id = $this->peopletag->id; + $tag = $this->peopletag->tag; + $description = $this->peopletag->description; + $private = $this->peopletag->private; + + $this->out->elementStart('ul', 'form_data'); + + $this->out->elementStart('li'); + $this->out->hidden('id', $id); + $this->out->input('tag', _('Tag'), + ($this->out->arg('tag')) ? $this->out->arg('tag') : $tag, + _('Change the tag (letters, numbers, -, ., and _ are allowed)')); + $this->out->elementEnd('li'); + + $this->out->elementStart('li'); + $desclimit = Profile_list::maxDescription(); + if ($desclimit == 0) { + $descinstr = _('Describe the people tag or topic'); + } else { + $descinstr = sprintf(_('Describe the people tag or topic in %d characters'), $desclimit); + } + $this->out->textarea('description', _('Description'), + ($this->out->arg('description')) ? $this->out->arg('description') : $description, + $descinstr); + $this->out->checkbox('private', _('Private'), $private); + $this->out->elementEnd('li'); + $this->out->elementEnd('ul'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Save')); + $this->out->submit('form_action-yes', + _m('BUTTON','Delete'), + 'submit', + 'delete', + _('Delete this people tag')); + } + + function showProfileList() + { + $tagged = $this->peopletag->getTagged(); + $this->out->element('h2', null, 'Add or remove people'); + + $this->out->elementStart('div', 'profile_search_wrap'); + $this->out->element('h3', null, 'Add user'); + $search = new SearchProfileForm($this->out, $this->peopletag); + $search->show(); + $this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty')); + $this->out->elementEnd('div'); + + $this->out->elementStart('ul', 'profile-lister'); + while ($tagged->fetch()) { + $this->out->elementStart('li', 'entity_removable_profile'); + $this->showProfileItem($tagged); + $this->out->elementStart('span', 'entity_actions'); + $untag = new UntagButton($this->out, $tagged, $this->peopletag); + $untag->show(); + $this->out->elementEnd('span'); + $this->out->elementEnd('li'); + } + $this->out->elementEnd('ul'); + } + + function showProfileItem($profile) + { + $item = new TaggedProfileItem($this->out, $profile); + $item->show(); + } +} diff --git a/lib/peopletaggroupnav.php b/lib/peopletaggroupnav.php new file mode 100644 index 0000000000..2c9a65fd44 --- /dev/null +++ b/lib/peopletaggroupnav.php @@ -0,0 +1,145 @@ +. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; + +/** + * Base class for all actions + * + * This is the base class for all actions in the package. An action is + * more or less a "view" in an MVC framework. + * + * Actions are responsible for extracting and validating parameters; using + * model classes to read and write to the database; and doing ouput. + * + * @category Output + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see HTMLOutputter + */ + +class PeopletagGroupNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + $user = null; + + // FIXME: we should probably pass this in + + $action = $this->action->trimmed('action'); + $nickname = $this->action->trimmed('tagger'); + $tag = $this->action->trimmed('tag'); + + if ($nickname) { + $user = User::staticGet('nickname', $nickname); + $user_profile = $user->getProfile(); + + if ($tag) { + $tag = Profile_list::pkeyGet(array('tagger' => $user->id, + 'tag' => $tag)); + } else { + $tag = false; + } + + } else { + $user_profile = false; + } + + $this->out->elementStart('ul', array('class' => 'nav')); + + if (Event::handle('StartPeopletagGroupNav', array($this))) { + // People tag timeline + $this->out->menuItem(common_local_url('showprofiletag', array('tagger' => $user_profile->nickname, + 'tag' => $tag->tag)), + _('People tag'), + sprintf(_('%s tag by %s'), $tag->tag, + (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), + $action == 'showprofiletag', 'nav_timeline_peopletag'); + + // Tagged + $this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname, + 'tag' => $tag->tag)), + _('Tagged'), + sprintf(_('%s tag by %s'), $tag->tag, + (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), + $action == 'peopletagged', 'nav_peopletag_tagged'); + + // Subscribers + $this->out->menuItem(common_local_url('peopletagsubscribers', array('tagger' => $user->nickname, + 'tag' => $tag->tag)), + _('Subscribers'), + sprintf(_('Subscribers to %s tag by %s'), $tag->tag, + (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), + $action == 'peopletagsubscribers', 'nav_peopletag_subscribers'); + + $cur = common_current_user(); + if (!empty($cur) && $user_profile->id == $cur->id) { + // Edit + $this->out->menuItem(common_local_url('editpeopletag', array('tagger' => $user->nickname, + 'tag' => $tag->tag)), + _('Edit'), + sprintf(_('Edit %s tag by you'), $tag->tag, + (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), + $action == 'editpeopletag', 'nav_peopletag_edit'); + } + + Event::handle('EndPeopletagGroupNav', array($this)); + } + $this->out->elementEnd('ul'); + } +} diff --git a/lib/peopletaglist.php b/lib/peopletaglist.php new file mode 100644 index 0000000000..8a4caf44fe --- /dev/null +++ b/lib/peopletaglist.php @@ -0,0 +1,320 @@ +. + * + * @category Public + * @package StatusNet + * @author Shashi Gowda + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; + +define('PEOPLETAGS_PER_PAGE', 20); + +/** + * Widget to show a list of peopletags + * + * @category Public + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletagList extends Widget +{ + /** Current peopletag, peopletag query. */ + var $peopletag = null; + /** current user **/ + var $user = null; + + function __construct($peopletag, $action=null) + { + parent::__construct($action); + + $this->peopletag = $peopletag; + + if (!empty($owner)) { + $this->user = $owner; + } else { + $this->user = common_current_user(); + } + } + + function show() + { + $this->out->elementStart('ul', 'peopletags xoxo hfeed'); + + $cnt = 0; + + while ($this->peopletag->fetch()) { + $cnt++; + if($cnt > PEOPLETAGS_PER_PAGE) { + break; + } + $this->showPeopletag(); + } + + $this->out->elementEnd('ul'); + + return $cnt; + } + + function showPeopletag() + { + $ptag = new PeopletagListItem($this->peopletag, $this->user, $this->out); + $ptag->show(); + } +} + +class PeopletagListItem extends Widget +{ + var $peopletag = null; + var $current = null; + var $profile = null; + + /** + * constructor + * + * Also initializes the owner attribute. + * + * @param Notice $notice The notice we'll display + */ + + function __construct($peopletag, $current, $out=null) + { + parent::__construct($out); + $this->peopletag = $peopletag; + $this->current = $current; + $this->profile = Profile::staticGet('id', $this->peopletag->tagger); + } + + /** + * recipe function for displaying a single peopletag. + * + * This uses all the other methods to correctly display a notice. Override + * it or one of the others to fine-tune the output. + * + * @return void + */ + + function url() + { + return $this->peopletag->homeUrl(); + } + + function show() + { + if (empty($this->peopletag)) { + common_log(LOG_WARNING, "Trying to show missing peopletag; skipping."); + return; + } + + if (Event::handle('StartShowPeopletagItem', array($this))) { + $this->showStart(); + $this->showPeopletag(); + $this->showStats(); + $this->showEnd(); + Event::handle('EndShowPeopletagItem', array($this)); + } + } + + function showStart() + { + $mode = ($this->peopletag->private) ? 'private' : 'public'; + $this->out->elementStart('li', array('class' => 'hentry peopletag mode-' . $mode, + 'id' => 'peopletag-' . $this->peopletag->id)); + } + + function showEnd() + { + $this->out->elementEnd('li'); + } + + function showPeopletag() + { + $this->showCreator(); + $this->showTag(); + $this->showPrivacy(); + $this->showUpdated(); + $this->showActions(); + $this->showDescription(); + } + + function showStats() + { + $this->out->elementStart('div', 'entry-summary entity_statistics'); + $this->out->elementStart('span', 'tagged-count'); + $this->out->element('a', + array('href' => common_local_url('peopletagged', + array('tagger' => $this->profile->nickname, + 'tag' => $this->peopletag->tag))), + _('Tagged')); + $this->out->raw($this->peopletag->taggedCount()); + $this->out->elementEnd('span'); + + $this->out->elementStart('span', 'subscriber-count'); + $this->out->element('a', + array('href' => common_local_url('peopletagsubscribers', + array('tagger' => $this->profile->nickname, + 'tag' => $this->peopletag->tag))), + _('Subscribers')); + $this->out->raw($this->peopletag->subscriberCount()); + $this->out->elementEnd('span'); + $this->out->elementEnd('div'); + } + + function showOwnerOptions() + { + $this->out->elementStart('li', 'entity_edit'); + $this->out->element('a', array('href' => + common_local_url('editpeopletag', array('tagger' => $this->profile->nickname, + 'tag' => $this->peopletag->tag)), + 'title' => _('Edit peopletag settings')), + _('Edit')); + $this->out->elementEnd('li'); + } + + function showSubscribeForm() + { + $this->out->elementStart('li'); + + if (Event::handle('StartSubscribePeopletagForm', array($this->out, $this->peopletag))) { + if ($this->current) { + if ($this->peopletag->hasSubscriber($this->current->id)) { + $form = new UnsubscribePeopletagForm($this->out, $this->peopletag); + $form->show(); + } else { + $form = new SubscribePeopletagForm($this->out, $this->peopletag); + $form->show(); + } + } + Event::handle('EndSubscribePeopletagForm', array($this->out, $this->peopletag)); + } + + $this->out->elementEnd('li'); + } + + function showCreator() + { + $this->out->elementStart('span', 'author vcard'); + $attrs = array(); + $attrs['href'] = $this->profile->profileurl; + $attrs['class'] = 'url'; + $attrs['rel'] = 'contact'; + + if (!empty($this->profile->fullname)) { + $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')'; + } + $this->out->elementStart('a', $attrs); + $this->showAvatar(); + $this->out->text(' '); + $this->out->element('span', 'nickname fn', + htmlspecialchars($this->profile->nickname)); + + $this->out->elementEnd('a'); + $this->out->elementEnd('span'); + } + + function showUpdated() + { + if (!empty($this->peopletag->modified)) { + $this->out->element('abbr', + array('title' => common_date_w3dtf($this->peopletag->modified), + 'class' => 'updated'), + common_date_string($this->peopletag->modified)); + } + } + + function showPrivacy() + { + if ($this->peopletag->private) { + $this->out->elementStart('a', + array('href' => common_local_url('peopletagsbyuser', + array('nickname' => $this->profile->nickname, 'private' => 1)))); + $this->out->element('span', 'privacy_mode', _('Private')); + $this->out->elementEnd('a'); + } + } + + function showTag() + { + $this->out->elementStart('span', 'entry-title tag'); + $this->out->element('a', + array('rel' => 'bookmark', + 'href' => $this->url()), + htmlspecialchars($this->peopletag->tag)); + $this->out->elementEnd('span'); + } + + /** + * show the avatar of the peopletag's creator + * + * This will use the default avatar if no avatar is assigned for the author. + * It makes a link to the author's profile. + * + * @return void + */ + + function showAvatar($size=AVATAR_STREAM_SIZE) + { + $avatar = $this->profile->getAvatar($size); + + $this->out->element('img', array('src' => ($avatar) ? + $avatar->displayUrl() : + Avatar::defaultImage($size), + 'class' => 'avatar photo', + 'width' => $size, + 'height' => $size, + 'alt' => + ($this->profile->fullname) ? + $this->profile->fullname : + $this->profile->nickname)); + } + + function showActions() + { + $this->out->elementStart('div', 'entity_actions'); + $this->out->elementStart('ul'); + + if (!$this->peopletag->private) { + $this->showSubscribeForm(); + } + + if (!empty($this->current) && $this->profile->id == $this->current->id) { + $this->showOwnerOptions(); + } + $this->out->elementEnd('ul'); + $this->out->elementEnd('div'); + } + + function showDescription() + { + $this->out->element('div', 'entry-content description', + $this->peopletag->description); + } +} diff --git a/lib/peopletags.php b/lib/peopletags.php new file mode 100644 index 0000000000..96b85afd4f --- /dev/null +++ b/lib/peopletags.php @@ -0,0 +1,191 @@ +. + * + * @category Action + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; + +/* + * Show a bunch of peopletags + * provide ajax editing if the current user owns the tags + * + * @category Action + * @pacage StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + */ + +class PeopletagsWidget extends Widget +{ + /* + * the query, current peopletag. + * or an array of strings (tags) + */ + + var $tag=null; + + var $user=null; + var $tagger=null; + var $tagged=null; + + function __construct($out, $tagger, $tagged) + { + parent::__construct($out); + + $this->user = common_current_user(); + $this->tag = Profile_tag::getTags($tagger->id, $tagged->id, $this->user); + $this->tagger = $tagger; + $this->tagged = $tagged; + } + + function show() + { + if (Event::handle('StartShowPeopletags', array($this, $this->tagger, $this->tagged))) { + if ($this->tag->N > 0) { + $this->showTags(); + } + else { + $this->showEmptyList(); + } + Event::handle('EndShowPeopletags', array($this, $this->tagger, $this->tagged)); + } + } + + function url() + { + return $this->tag->homeUrl(); + } + + function label() + { + return _('Tags by you'); + } + + function showTags() + { + $this->out->elementStart('dl', 'entity_tags user_profile_tags'); + $this->out->element('dt', null, $this->label()); + $this->out->elementStart('dd'); + + $class = 'tags xoxo'; + if ($this->isEditable()) { + $class .= ' editable'; + } + + $tags = array(); + $this->out->elementStart('ul', $class); + while ($this->tag->fetch()) { + $mode = $this->tag->private ? 'private' : 'public'; + $tags[] = $this->tag->tag; + + $this->out->elementStart('li', 'hashptag mode-' . $mode); + // Avoid space by using raw output. + $pt = '#'; + $this->out->raw($pt); + $this->out->elementEnd('li'); + } + $this->out->elementEnd('ul'); + + if ($this->isEditable()) { + $this->showEditTagForm($tags); + } + + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); + } + + function showEditTagForm($tags=null) + { + $this->out->elementStart('span', 'form_tag_user_wrap'); + $this->out->elementStart('form', array('method' => 'post', + 'class' => 'form_tag_user', + 'name' => 'tagprofile', + 'action' => common_local_url('tagprofile', array('id' => $this->tagged->id)))); + + $this->out->elementStart('fieldset'); + $this->out->element('legend', null, _('Edit tags')); + $this->out->hidden('token', common_session_token()); + $this->out->hidden('id', $this->tagged->id); + + if (!$tags) { + $tags = array(); + } + + $this->out->input('tags', $this->label(), + ($this->out->arg('tags')) ? $this->out->arg('tags') : implode(' ', $tags)); + $this->out->submit('save', _('Save')); + + $this->out->elementEnd('fieldset'); + $this->out->elementEnd('form'); + $this->out->elementEnd('span'); + } + + function showEmptyList() + { + $this->out->elementStart('dl', 'entity_tags user_profile_tags'); + $this->out->element('dt', null, $this->label()); + $this->out->elementStart('dd'); + + $class = 'tags'; + if ($this->isEditable()) { + $class .= ' editable'; + } + + $this->out->elementStart('ul', $class); + $this->out->element('li', null, _('(None)')); + $this->out->elementEnd('ul'); + + if ($this->isEditable()) { + $this->showEditTagForm(); + } + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); + } + + function isEditable() + { + return !empty($this->user) && $this->tagger->id == $this->user->id; + } +} + +class SelftagsWidget extends PeopletagsWidget +{ + function url($tag) + { + // link to self tag page + return common_local_url('selftag', array('tag' => $tag)); + } + + function label() + { + return _('Tags'); + } +} diff --git a/lib/peopletagsbysubssection.php b/lib/peopletagsbysubssection.php new file mode 100644 index 0000000000..779e7d8ef9 --- /dev/null +++ b/lib/peopletagsbysubssection.php @@ -0,0 +1,76 @@ +. + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Peopletags with the most subscribers section + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletagsBySubsSection extends PeopletagSection +{ + function getPeopletags() + { + $qry = 'SELECT profile_list.*, subscriber_count as value ' . + 'FROM profile_list WHERE profile_list.private = false ' . + 'ORDER BY value DESC '; + + $limit = PEOPLETAGS_PER_SECTION; + $offset = 0; + + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + + $peopletag = Memcached_DataObject::cachedQuery('Profile_list', + $qry, + 3600); + return $peopletag; + } + + function title() + { + return _('People tags with most subscribers'); + } + + function divId() + { + return 'top_peopletags_by_subs'; + } +} diff --git a/lib/peopletagsection.php b/lib/peopletagsection.php new file mode 100644 index 0000000000..6722f3a149 --- /dev/null +++ b/lib/peopletagsection.php @@ -0,0 +1,139 @@ +. + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/peopletaglist.php'; + +define('PEOPLETAGS_PER_SECTION', 6); + +/** + * Base class for sections + * + * These are the widgets that show interesting data about a person + * peopletag, or site. + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletagSection extends Section +{ + function showContent() + { + $tags = $this->getPeopletags(); + + if (!$tags) { + return false; + } + + $cnt = 0; + + $this->out->elementStart('table', 'peopletag_section'); + + while ($tags->fetch() && ++$cnt <= PEOPLETAGS_PER_SECTION) { + $this->showPeopletag($tags); + } + + $this->out->elementEnd('table'); + + return ($cnt > PEOPLETAGS_PER_SECTION); + } + + function getPeopletags() + { + return null; + } + + function showPeopletag($peopletag) + { + $tag = new PeopletagSectionItem($peopletag, null, $this->out); + $tag->show(); + } +} + +class PeopletagSectionItem extends PeopletagListItem +{ + function showStart() + { + } + + function showEnd() + { + } + + function showPeopletag() + { + $this->showCreator(); + $this->showTag(); + $this->showPrivacy(); + } + + function show() + { + if (empty($this->peopletag)) { + common_log(LOG_WARNING, "Trying to show missing peopletag; skipping."); + return; + } + + $this->out->elementStart('tr'); + + $this->out->elementStart('td', 'peopletag'); + $this->showPeopletag(); + $this->out->elementEnd('td'); + + if ($this->peopletag->value) { + $this->out->element('td', 'value', $this->peopletag->value); + } + $this->out->elementEnd('tr'); + } + + function showTag() + { + $title = _('Tagged: ') . $this->peopletag->taggedCount() . + ' ' . _('Subscribers: ') . $this->peopletag->subscriberCount(); + + $this->out->elementStart('span', 'entry-title tag'); + $this->out->element('a', + array('rel' => 'bookmark', + 'href' => $this->url(), + 'title' => $title), + htmlspecialchars($this->peopletag->tag)); + $this->out->elementEnd('span'); + } + + function showAvatar() + { + parent::showAvatar(AVATAR_MINI_SIZE); + } +} diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index 72d0893af7..ccd4ab506f 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -109,6 +109,12 @@ class PersonalGroupNav extends Widget _('Favorites'), sprintf(_('%s\'s favorite notices'), ($user_profile) ? $name : _('User')), $action == 'showfavorites', 'nav_timeline_favorites'); + $this->out->menuItem(common_local_url('peopletagsbyuser', array('nickname' => + $nickname)), + _('People tags'), + sprintf(_('People tags by %s'), ($user_profile) ? $user_profile->getBestName() : _('User')), + in_array($action, array('peopletagsbyuser', 'peopletagsforuser')), + 'nav_timeline_peopletags'); $cur = common_current_user(); diff --git a/lib/profilelist.php b/lib/profilelist.php index b010fb7249..af38fa71d9 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -33,6 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { } require_once INSTALLDIR.'/lib/widget.php'; +require_once INSTALLDIR.'/lib/peopletags.php'; /** * Widget to show a list of profiles @@ -168,6 +169,10 @@ class ProfileListItem extends Widget $this->showBio(); Event::handle('EndProfileListItemBio', array($this)); } + if (Event::handle('StartProfileListItemTags', array($this))) { + $this->showTags(); + Event::handle('EndProfileListItemTags', array($this)); + } Event::handle('EndProfileListItemProfileElements', array($this)); } $this->endProfile(); @@ -238,6 +243,20 @@ class ProfileListItem extends Widget } } + function showTags() + { + $user = common_current_user(); + if (!empty($user)) { + if ($user->id == $this->profile->id) { + $tags = new SelftagsWidget($this->out, $user, $this->profile); + $tags->show(); + } else if ($user->getProfile()->canTag($this->profile)) { + $tags = new PeopletagsWidget($this->out, $user, $this->profile); + $tags->show(); + } + } + } + function endProfile() { $this->out->elementEnd('div'); diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php index ae9cbdebb4..c2dc11831a 100644 --- a/lib/publicgroupnav.php +++ b/lib/publicgroupnav.php @@ -84,6 +84,10 @@ class PublicGroupNav extends Widget $this->out->menuItem(common_local_url('publictagcloud'), _('Recent tags'), _('Recent tags'), $action_name == 'publictagcloud', 'nav_recent-tags'); + $this->out->menuItem(common_local_url('publicpeopletagcloud'), _('People tags'), + _('People tags'), in_array($action_name, array('publicpeopletagcloud', + 'peopletag', 'selftag')), 'nav_people-tags'); + if (count(common_config('nickname', 'featured')) > 0) { $this->out->menuItem(common_local_url('featured'), _('Featured'), _('Featured users'), $action_name == 'featured', 'nav_featured'); diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index be3ba27480..5fccb15744 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -106,6 +106,15 @@ class SubGroupNav extends Widget $this->user->nickname), $action == 'usergroups', 'nav_usergroups'); + $this->out->menuItem(common_local_url('peopletagsbyuser', + array('nickname' => + $this->user->nickname)), + _('People tags'), + sprintf(_('People tags by %s'), + $this->user->nickname), + in_array($action, array('peopletagsbyuser', 'peopletagsforuser')), + 'nav_timeline_peopletags'); + if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) { $this->out->menuItem(common_local_url('invite'), _('Invite'), diff --git a/lib/subscribepeopletagform.php b/lib/subscribepeopletagform.php new file mode 100644 index 0000000000..9489b01a1c --- /dev/null +++ b/lib/subscribepeopletagform.php @@ -0,0 +1,114 @@ +. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for subscribing to a peopletag + * + * @category Form + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see UnsubscribeForm + */ + +class SubscribePeopletagForm extends Form +{ + /** + * peopletag for the user to join + */ + + var $peopletag = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param peopletag $peopletag peopletag to subscribe to + */ + + function __construct($out=null, $peopletag=null) + { + parent::__construct($out); + + $this->peopletag = $peopletag; + } + + /** + * ID of the form + * + * @return string ID of the form + */ + + function id() + { + return 'peopletag-subscribe-' . $this->peopletag->id; + } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_peopletag_subscribe'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('subscribepeopletag', + array('id' => $this->peopletag->id)); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Subscribe')); + } +} diff --git a/lib/subscriberspeopleselftagcloudsection.php b/lib/subscriberspeopleselftagcloudsection.php index 5a570ae282..b4ada901c0 100644 --- a/lib/subscriberspeopleselftagcloudsection.php +++ b/lib/subscriberspeopleselftagcloudsection.php @@ -52,7 +52,7 @@ class SubscribersPeopleSelfTagCloudSection extends SubPeopleTagCloudSection // return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged group by tag order by weight desc'; - return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc'; + return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on profile_list.tag = profile_tag.tag and profile_list.tagger = profile_tag.tagger and profile_tag.tagger = subscriber where subscribed=%d and subscribed != subscriber and profile_tag.tagger = tagged and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc'; // return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscribed where subscriber=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc'; diff --git a/lib/subscriberspeopletagcloudsection.php b/lib/subscriberspeopletagcloudsection.php index 284996b591..65c4a4f066 100644 --- a/lib/subscriberspeopletagcloudsection.php +++ b/lib/subscriberspeopletagcloudsection.php @@ -55,7 +55,7 @@ class SubscribersPeopleTagCloudSection extends SubPeopleTagCloudSection function query() { // return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed group by tag order by weight desc'; - return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed and tag is not null group by tag order by weight desc'; + return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on subscriber=profile_tag.tagged and subscribed=profile_tag.tagger and profile_tag.tagger = profile_list.tagger and profile_tag.tag = profile_list.tag where subscribed=%d and subscriber != subscribed and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc'; } } diff --git a/lib/subscriptionspeopleselftagcloudsection.php b/lib/subscriptionspeopleselftagcloudsection.php index 9be60dfa14..cb87ae0440 100644 --- a/lib/subscriptionspeopleselftagcloudsection.php +++ b/lib/subscriptionspeopleselftagcloudsection.php @@ -53,7 +53,7 @@ class SubscriptionsPeopleSelfTagCloudSection extends SubPeopleTagCloudSection - return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscribed where subscriber=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc'; + return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on profile_tag.tagger = subscribed and profile_tag.tag = profile_list.tag and profile_tag.tagger = profile_tag.tagger where subscriber=%d and subscribed != subscriber and profile_tag.tagger = profile_tag.tagged and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc'; // return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc'; } diff --git a/lib/subscriptionspeopletagcloudsection.php b/lib/subscriptionspeopletagcloudsection.php index fde24b282e..1a42bf90be 100644 --- a/lib/subscriptionspeopletagcloudsection.php +++ b/lib/subscriptionspeopletagcloudsection.php @@ -55,7 +55,7 @@ class SubscriptionsPeopleTagCloudSection extends SubPeopleTagCloudSection function query() { // return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed group by tag order by weight desc'; - return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed and tag is not null group by tag order by weight desc'; + return 'select profile_tag.tag, count(profile_tag.tag) as weight from subscription left join (profile_tag, profile_list) on subscriber=profile_tag.tagger and subscribed=tagged and profile_tag.tag = profile_list.tag and profile_tag.tagger = profile_list.tagger where subscriber=%d and subscriber != subscribed and profile_list.private = false and profile_tag.tag is not null group by profile_tag.tag order by weight desc'; } } diff --git a/lib/togglepeopletag.php b/lib/togglepeopletag.php new file mode 100644 index 0000000000..a6e07177fb --- /dev/null +++ b/lib/togglepeopletag.php @@ -0,0 +1,322 @@ +. + * + * @category Form + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for editing a peopletag + * + * @category Form + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see GroupEditForm + */ + +class SearchProfileForm extends Form +{ + var $peopletag; + + function __construct($out, Profile_list $peopletag) + { + parent::__construct($out); + $this->peopletag = $peopletag; + } + + /** + * ID of the form + * + * @return string ID of the form + */ + + function id() + { + return 'form_peopletag-add-' . $this->peopletag->id; + } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_peopletag_edit_user_search'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('profilecompletion'); + } + + /** + * Name of the form + * + * @return void + */ + + function formLegend() + { + $this->out->element('legend', null, sprintf(_('Search and list people'))); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $fields = array('fulltext' => 'Everything', + 'nickname' => 'Nickname', + 'fullname' => 'Fullname', + 'description' => 'Description', + 'location' => 'Location', + 'uri' => 'Uri (Remote users)'); + + + $this->out->hidden('peopletag_id', $this->peopletag->id); + $this->out->input('q', null); + $this->out->dropdown('field', _('Search in'), $fields, + _('Choose a field to search'), false, 'fulltext'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Search')); + } +} + +class UntagButton extends Form +{ + var $profile; + var $peopletag; + + function __construct($out, Profile $profile, Profile_list $peopletag) + { + parent::__construct($out); + $this->profile = $profile; + $this->peopletag = $peopletag; + } + + /** + * ID of the form + * + * @return string ID of the form + */ + + function id() + { + return 'form_peopletag-' . $this->peopletag->id . '-remove-' . $this->profile->id; + } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_user_remove_peopletag'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('removepeopletag'); + } + + /** + * Name of the form + * + * @return void + */ + + function formLegend() + { + $this->out->element('legend', null, sprintf(_('Untag %s as %s'), + $this->profile->nickname, $this->peopletag->tag)); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $this->out->hidden('peopletag_id', $this->peopletag->id); + $this->out->hidden('tagged', $this->profile->id); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Remove')); + } +} + + +class TagButton extends Form +{ + var $profile; + var $peopletag; + + function __construct($out, Profile $profile, Profile_list $peopletag) + { + parent::__construct($out); + $this->profile = $profile; + $this->peopletag = $peopletag; + } + + /** + * ID of the form + * + * @return string ID of the form + */ + + function id() + { + return 'form_peopletag-' . $this->peopletag->id . '-add-' . $this->profile->id; + } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_user_add_peopletag'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('addpeopletag'); + } + + /** + * Name of the form + * + * @return void + */ + + function formLegend() + { + $this->out->element('legend', null, sprintf(_('Tag %s as %s'), + $this->profile->nickname, $this->peopletag->tag)); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + UntagButton::formData(); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Add')); + } +} + +class TaggedProfileItem extends Widget +{ + var $profile=null; + + function __construct($out=null, $profile) + { + parent::__construct($out); + $this->profile = $profile; + } + + function show() + { + $this->out->elementStart('a', array('class' => 'url', + 'href' => $this->profile->profileurl, + 'title' => $this->profile->getBestName())); + $avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE); + $this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : + Avatar::defaultImage(AVATAR_MINI_SIZE)), + 'width' => AVATAR_MINI_SIZE, + 'height' => AVATAR_MINI_SIZE, + 'class' => 'avatar photo', + 'alt' => $this->profile->getBestName())); + $this->out->element('span', 'fn nickname', $this->profile->nickname); + $this->out->elementEnd('a'); + } +} diff --git a/lib/unsubscribepeopletagform.php b/lib/unsubscribepeopletagform.php new file mode 100644 index 0000000000..777025c89d --- /dev/null +++ b/lib/unsubscribepeopletagform.php @@ -0,0 +1,114 @@ +. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for unsubscribing to a peopletag + * + * @category Form + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see UnunsubscribeForm + */ + +class UnsubscribePeopletagForm extends Form +{ + /** + * peopletag for the user to join + */ + + var $peopletag = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param peopletag $peopletag peopletag to unsubscribe to + */ + + function __construct($out=null, $peopletag=null) + { + parent::__construct($out); + + $this->peopletag = $peopletag; + } + + /** + * ID of the form + * + * @return string ID of the form + */ + + function id() + { + return 'peopletag-unsubscribe-' . $this->peopletag->id; + } + + /** + * class of the form + * + * @return string of the form class + */ + + function formClass() + { + return 'form_peopletag_unsubscribe'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('unsubscribepeopletag', + array('id' => $this->peopletag->id)); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', _('Unsubscribe')); + } +} diff --git a/lib/userprofile.php b/lib/userprofile.php index 0b7efb22fc..66d049e9e5 100644 --- a/lib/userprofile.php +++ b/lib/userprofile.php @@ -33,6 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { } require_once INSTALLDIR.'/lib/widget.php'; +require_once INSTALLDIR.'/lib/peopletags.php'; /** * Profile of a user @@ -188,23 +189,17 @@ class UserProfile extends Widget function showProfileTags() { - if (Event::handle('StartProfilePageProfileTags', array($this->out, $this->profile))) { - $tags = Profile_tag::getTags($this->profile->id, $this->profile->id); + $cur = common_current_user(); - if (count($tags) > 0) { - $this->out->elementStart('ul', 'tags xoxo entity_tags'); - foreach ($tags as $tag) { - $this->out->elementStart('li'); - // Avoid space by using raw output. - $pt = '#'; - $this->out->raw($pt); - $this->out->elementEnd('li'); - } - $this->out->elementEnd('ul'); + $self_tags = new SelftagsWidget($this->out, $this->profile, $this->profile); + $self_tags->show(); + + if ($cur) { + // don't show self-tags again + if ($cur->id != $this->profile->id && $cur->getProfile()->canTag($this->profile)) { + $tags = new PeopletagsWidget($this->out, $cur, $this->profile); + $tags->show(); } - Event::handle('EndProfilePageProfileTags', array($this->out, $this->profile)); } } From 382e4d2cdbd2dbfa211077fb9bce35441b8743cd Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Mon, 7 Mar 2011 00:43:31 +0530 Subject: [PATCH 014/726] people tag actions --- actions/addpeopletag.php | 172 ++++++++++++++ actions/editpeopletag.php | 311 +++++++++++++++++++++++++ actions/peopletag.php | 211 ++++++++--------- actions/peopletagautocomplete.php | 104 +++++++++ actions/peopletagged.php | 223 ++++++++++++++++++ actions/peopletagsbyuser.php | 258 +++++++++++++++++++++ actions/peopletagsforuser.php | 170 ++++++++++++++ actions/peopletagsubscribers.php | 238 +++++++++++++++++++ actions/peopletagsubscriptions.php | 138 +++++++++++ actions/profilecompletion.php | 214 +++++++++++++++++ actions/profilesettings.php | 30 ++- actions/profiletagbyid.php | 92 ++++++++ actions/public.php | 2 + actions/publicpeopletagcloud.php | 173 ++++++++++++++ actions/removepeopletag.php | 173 ++++++++++++++ actions/selftag.php | 204 +++++++++++++++++ actions/showprofiletag.php | 354 +++++++++++++++++++++++++++++ actions/subscribepeopletag.php | 144 ++++++++++++ actions/tagother.php | 220 ------------------ actions/tagprofile.php | 249 ++++++++++++++++++++ actions/unsubscribepeopletag.php | 142 ++++++++++++ lib/action.php | 2 + lib/router.php | 78 ++++++- 23 files changed, 3549 insertions(+), 353 deletions(-) create mode 100644 actions/addpeopletag.php create mode 100644 actions/editpeopletag.php create mode 100644 actions/peopletagautocomplete.php create mode 100644 actions/peopletagged.php create mode 100644 actions/peopletagsbyuser.php create mode 100644 actions/peopletagsforuser.php create mode 100644 actions/peopletagsubscribers.php create mode 100644 actions/peopletagsubscriptions.php create mode 100644 actions/profilecompletion.php create mode 100644 actions/profiletagbyid.php create mode 100644 actions/publicpeopletagcloud.php create mode 100644 actions/removepeopletag.php create mode 100644 actions/selftag.php create mode 100644 actions/showprofiletag.php create mode 100644 actions/subscribepeopletag.php delete mode 100644 actions/tagother.php create mode 100644 actions/tagprofile.php create mode 100644 actions/unsubscribepeopletag.php diff --git a/actions/addpeopletag.php b/actions/addpeopletag.php new file mode 100644 index 0000000000..3176a116c9 --- /dev/null +++ b/actions/addpeopletag.php @@ -0,0 +1,172 @@ +. + * + * PHP version 5 + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/togglepeopletag.php'; + +/** + * + * Action to tag a profile with a single tag. + * + * Takes parameters: + * + * - tagged: the ID of the profile being tagged + * - token: session token to prevent CSRF attacks + * - ajax: boolean; whether to return Ajax or full-browser results + * - peopletag_id: the ID of the tag being used + * + * Only works if the current user is logged in. + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +class AddpeopletagAction extends Action +{ + var $user; + var $tagged; + var $peopletag; + + /** + * Check pre-requisites and instantiate attributes + * + * @param Array $args array of arguments (URL, GET, POST) + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + // CSRF protection + + $token = $this->trimmed('token'); + + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token.'. + ' Try again, please.')); + return false; + } + + // Only for logged-in users + + $this->user = common_current_user(); + + if (empty($this->user)) { + $this->clientError(_('Not logged in.')); + return false; + } + + // Profile to subscribe to + + $tagged_id = $this->arg('tagged'); + + $this->tagged = Profile::staticGet('id', $tagged_id); + + if (empty($this->tagged)) { + $this->clientError(_('No such profile.')); + return false; + } + + $id = $this->arg('peopletag_id'); + $this->peopletag = Profile_list::staticGet('id', $id); + + if (empty($this->peopletag)) { + $this->clientError(_('No such peopletag.')); + return false; + } + + // OMB 0.1 doesn't have a mechanism for local-server- + // originated tag. + + $omb01 = Remote_profile::staticGet('id', $tagged_id); + + if (!empty($omb01)) { + $this->clientError(_('You cannot tag an OMB 0.1'. + ' remote profile with this action.')); + return false; + } + + return true; + } + + /** + * Handle request + * + * Does the tagging and returns results. + * + * @param Array $args unused. + * + * @return void + */ + + function handle($args) + { + + // Throws exception on error + $ptag = Profile_tag::setTag($this->user->id, $this->tagged->id, + $this->peopletag->tag); + + if (!$ptag) { + $user = User::staticGet('id', $id); + if ($user) { + $this->clientError( + sprintf(_('There was an unexpected error while tagging %s'), + $user->nickname)); + } else { + $this->clientError(sprintf(_('There was a problem tagging %s.' . + 'The remote server is probably not responding correctly, ' . + 'please try retrying later.'), $this->profile->profileurl)); + } + return false; + } + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Subscribed')); + $this->elementEnd('head'); + $this->elementStart('body'); + $unsubscribe = new UntagButton($this, $this->tagged, $this->peopletag); + $unsubscribe->show(); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + $url = common_local_url('subscriptions', + array('nickname' => $this->user->nickname)); + common_redirect($url, 303); + } + } +} diff --git a/actions/editpeopletag.php b/actions/editpeopletag.php new file mode 100644 index 0000000000..b00ccc8abb --- /dev/null +++ b/actions/editpeopletag.php @@ -0,0 +1,311 @@ +. + * + * @category Group + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Add a new group + * + * This is the form for adding a new group + * + * @category Group + * @package StatusNet + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class EditpeopletagAction extends OwnerDesignAction +{ + + var $msg, $confirm, $confirm_args=array(); + + function title() + { + if ($_SERVER['REQUEST_METHOD'] == 'POST' && $this->boolean('delete')) { + return sprintf(_('Delete %s people tag'), $this->peopletag->tag); + } + return sprintf(_('Edit people tag %s'), $this->peopletag->tag); + } + + /** + * Prepare to run + */ + + function prepare($args) + { + parent::prepare($args); + + if (!common_logged_in()) { + $this->clientError(_('Not logged in.')); + return false; + } + + $id = $this->arg('id'); + $tagger_arg = $this->arg('tagger'); + $tag_arg = $this->arg('tag'); + + $tagger = common_canonical_nickname($tagger_arg); + $tag = common_canonical_tag($tag_arg); + + $current = common_current_user(); + + // Permanent redirect on non-canonical tag + + if ($tagger_arg != $tagger || $tag_arg != $tag) { + $args = array('tagger' => $tagger, 'tag' => $tag); + common_redirect(common_local_url('editpeopletag', $args), 301); + return false; + } + + $user = null; + if ($id) { + $this->peopletag = Profile_list::staticGet('id', $id); + if (!empty($this->peopletag)) { + $user = User::staticGet('id', $this->peopletag->tagger); + } + } else { + if (!$tagger) { + $this->clientError(_('No tagger or ID.'), 404); + return false; + } + + $user = User::staticGet('nickname', $tagger); + $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag)); + } + + if (!$this->peopletag) { + $this->clientError(_('No such peopletag.'), 404); + return false; + } + + if (!$user) { + // This should not be happening + $this->clientError(_('Not a local user.'), 404); + return false; + } + + if ($current->id != $user->id) { + $this->clientError(_('You must be the creator of the tag to edit it.'), 404); + return false; + } + + $this->tagger = $user->getProfile(); + + return true; + } + + /** + * Handle the request + * + * On GET, show the form. On POST, try to save the group. + * + * @param array $args unused + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->trySave(); + } else { + $this->showForm(); + } + } + + function showConfirm($msg=null, $fwd=null) + { + $this->confirm = $msg; + $this->confirm_args = $fwd; + $this->showPage(); + } + + function showConfirmForm() + { + $this->elementStart('form', array('id' => 'form_peopletag_edit_confirm', + 'class' => 'form_settings', + 'method' => 'post', + 'action' => common_local_url('editpeopletag', + array('tagger' => $this->tagger->nickname, + 'tag' => $this->peopletag->tag)))); + $this->elementStart('fieldset'); + $this->hidden('token', common_session_token()); + $this->hidden('id', $this->arg('id')); + + foreach ($this->confirm_args as $key => $val) { + $this->hidden($key, $val); + } + + $this->submit('form_action-no', + _m('BUTTON','No'), + 'submit form_action-primary', + 'cancel'); + $this->submit('form_action-yes', + _m('BUTTON','Yes'), + 'submit form_action-secondary', + 'confirm'); + $this->elementEnd('fieldset'); + $this->elementEnd('form'); + } + + function showForm($msg=null) + { + $this->msg = $msg; + $this->showPage(); + } + + function showLocalNav() + { + $nav = new PeopletagGroupNav($this, $this->peopletag); + $nav->show(); + } + + function showContent() + { + if ($this->confirm) { + $this->showConfirmForm(); + return; + } + + $form = new PeopletagEditForm($this, $this->peopletag); + $form->show(); + + $form->showProfileList(); + } + + function showPageNotice() + { + if ($this->msg) { + $this->element('p', 'error', $this->msg); + } else if ($this->confirm) { + $this->element('p', 'instructions', $this->confirm); + } else { + $this->element('p', 'instructions', + _('Use this form to edit the people tag.')); + } + } + + function showScripts() + { + parent::showScripts(); + $this->autofocus('tag'); + } + + function trySave() + { + $tag = common_canonical_tag($this->trimmed('tag')); + $description = $this->trimmed('description'); + $private = $this->boolean('private'); + $delete = $this->arg('delete'); + $confirm = $this->arg('confirm'); + $cancel = $this->arg('cancel'); + + if ($delete && $cancel) { + $this->showForm(_('Delete aborted.')); + return; + } + + $set_private = $private && $this->peopletag->private != $private; + + if ($delete && !$confirm) { + $this->showConfirm(_('Deleting this tag will permanantly remove ' . + 'all its subscription and membership records. ' . + 'Do you still want to continue?'), array('delete' => 1)); + return; + } else if (common_valid_tag($tag)) { + $this->showForm(_('Invalid tag.')); + return; + } else if ($tag != $this->peopletag->tag && $this->tagExists($tag)) { + $this->showForm(sprintf(_('You already have a tag named %s.'), $tag)); + return; + } else if (Profile_list::descriptionTooLong($description)) { + $this->showForm(sprintf(_('description is too long (max %d chars).'), Profile_list::maxDescription())); + return; + } else if ($set_private && !$confirm && !$cancel) { + $fwd = array('tag' => $tag, + 'description' => $description, + 'private' => (int) $private); + + $this->showConfirm(_('Setting a public tag as private will ' . + 'permanently remove all the existing ' . + 'subscriptions to it. Do you still want to continue?'), $fwd); + return; + } + + $this->peopletag->query('BEGIN'); + + $orig = clone($this->peopletag); + + $this->peopletag->tag = $tag; + $this->peopletag->description = $description; + if (!$set_private || $confirm) { + $this->peopletag->private = $private; + } + + $result = $this->peopletag->update($orig); + + if (!$result) { + common_log_db_error($this->group, 'UPDATE', __FILE__); + $this->serverError(_('Could not update peopletag.')); + } + + $this->peopletag->query('COMMIT'); + + if ($set_private && $confirm) { + Profile_tag_subscription::cleanup($this->peopletag); + } + + if ($delete) { + // This might take quite a bit of time. + $this->peopletag->delete(); + // send home. + common_redirect(common_local_url('all', + array('nickname' => $this->tagger->nickname)), + 303); + } + + if ($tag != $orig->tag) { + common_redirect(common_local_url('editpeopletag', + array('tagger' => $this->tagger->nickname, + 'tag' => $tag)), + 303); + } else { + $this->showForm(_('Options saved.')); + } + } + + function tagExists($tag) + { + $args = array('tagger' => $this->tagger->id, 'tag' => $tag); + $ptag = Profile_list::pkeyGet($args); + + return !empty($ptag); + } +} diff --git a/actions/peopletag.php b/actions/peopletag.php index 7287cfbf99..d549586f13 100644 --- a/actions/peopletag.php +++ b/actions/peopletag.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Action for showing profiles self-tagged with a given tag + * People tags by a user * * PHP version 5 * @@ -16,13 +16,16 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * + * PHP version 5 + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * - * @category Action + * @category Personal * @package StatusNet * @author Evan Prodromou * @author Zach Copley + * @author Shashi Gowda * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -32,149 +35,125 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -/** - * This class outputs a paginated list of profiles self-tagged with a given tag - * - * @category Output - * @package StatusNet - * @author Evan Prodromou - * @author Zach Copley - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - * - * @see Action - */ +require_once INSTALLDIR.'/lib/peopletaglist.php'; +// cache 3 pages +define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1); class PeopletagAction extends Action { - - var $tag = null; var $page = null; + var $tag = null; - /** - * For initializing members of the class. - * - * @param array $argarray misc. arguments - * - * @return boolean true - */ - function prepare($argarray) + function isReadOnly($args) { - parent::prepare($argarray); + return true; + } - $this->tag = $this->trimmed('tag'); - - if (!common_valid_profile_tag($this->tag)) { - $this->clientError(sprintf(_('Not a valid people tag: %s.'), - $this->tag)); - return; + function title() + { + if ($this->page == 1) { + return sprintf(_("Public people tag %s"), $this->tag); + } else { + return sprintf(_("Public people tag %s, page %d"), $this->tag, $this->page); } + } - $this->page = ($this->arg('page')) ? $this->arg('page') : 1; + function prepare($args) + { + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - common_set_returnto($this->selfUrl()); + $tag_arg = $this->arg('tag'); + $tag = common_canonical_tag($tag_arg); + + // Permanent redirect on non-canonical nickname + + if ($tag_arg != $tag) { + $args = array('tag' => $nickname); + if ($this->page && $this->page != 1) { + $args['page'] = $this->page; + } + common_redirect(common_local_url('peopletag', $args), 301); + return false; + } + $this->tag = $tag; return true; } - /** - * Handler method - * - * @param array $argarray is ignored since it's now passed in in prepare() - * - * @return boolean is read only action? - */ - function handle($argarray) + function handle($args) { - parent::handle($argarray); + parent::handle($args); $this->showPage(); } - /** - * Whips up a query to get a list of profiles based on the provided - * people tag and page, initalizes a ProfileList widget, and displays - * it to the user. - * - * @return nothing - */ + function showLocalNav() + { + $nav = new PublicGroupNav($this); + $nav->show(); + } + + function showAnonymousMessage() + { + $notice = + _('People tags are how you sort similar ' . + 'people on %%site.name%%, a [micro-blogging]' . + '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . + 'based on the Free Software [StatusNet](http://status.net/) tool. ' . + 'You can then easily keep track of what they ' . + 'are doing by subscribing to the tag\'s timeline.' ); + $this->elementStart('div', array('id' => 'anon_notice')); + $this->raw(common_markup_to_html($notice)); + $this->elementEnd('div'); + } + function showContent() { + $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE; + $limit = PEOPLETAGS_PER_PAGE + 1; - $profile = new Profile(); + $ptags = new Profile_list(); + $ptags->tag = $this->tag; - $offset = ($this->page - 1) * PROFILES_PER_PAGE; - $limit = PROFILES_PER_PAGE + 1; + $user = common_current_user(); - if (common_config('db', 'type') == 'pgsql') { - $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset; + if (empty($user)) { + $ckey = sprintf('profile_list:tag:%s', $this->tag); + $ptags->private = false; + $ptags->orderBy('profile_list.modified DESC'); + + $c = Cache::instance(); + if ($offset+$limit <= PEOPLETAG_CACHE_WINDOW && !empty($c)) { + $cached_ptags = Profile_list::getCached($ckey, $offset, $limit); + if ($cached_ptags === false) { + $ptags->limit(0, PEOPLETAG_CACHE_WINDOW); + $ptags->find(); + + Profile_list::setCache($ckey, $ptags, $offset, $limit); + } else { + $ptags = clone($cached_ptags); + } + } else { + $ptags->limit($offset, $limit); + $ptags->find(); + } } else { - $lim = ' LIMIT ' . $offset . ', ' . $limit; + $ptags->whereAdd('(profile_list.private = false OR (' . + ' profile_list.tagger =' . $user->id . + ' AND profile_list.private = true) )'); + + $ptags->orderBy('profile_list.modified DESC'); + $ptags->find(); } - // XXX: memcached this + $pl = new PeopletagList($ptags, $this); + $cnt = $pl->show(); - $qry = 'SELECT profile.* ' . - 'FROM profile JOIN profile_tag ' . - 'ON profile.id = profile_tag.tagger ' . - 'WHERE profile_tag.tagger = profile_tag.tagged ' . - "AND tag = '%s' " . - 'ORDER BY profile_tag.modified DESC%s'; - - $profile->query(sprintf($qry, $this->tag, $lim)); - - $ptl = new PeopleTagList($profile, $this); // pass the ammunition - $cnt = $ptl->show(); - - $this->pagination($this->page > 1, - $cnt > PROFILES_PER_PAGE, - $this->page, - 'peopletag', - array('tag' => $this->tag)); + $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE, + $this->page, 'peopletag', array('tag' => $this->tag)); } - /** - * Returns the page title - * - * @return string page title - */ - function title() + function showSections() { - return sprintf(_('Users self-tagged with %1$s - page %2$d'), - $this->tag, $this->page); - } - -} - -class PeopleTagList extends ProfileList -{ - function newListItem($profile) - { - return new PeopleTagListItem($profile, $this->action); } } - -class PeopleTagListItem extends ProfileListItem -{ - function linkAttributes() - { - $aAttrs = parent::linkAttributes(); - - if (common_config('nofollow', 'peopletag')) { - $aAttrs['rel'] .= ' nofollow'; - } - - return $aAttrs; - } - - function homepageAttributes() - { - $aAttrs = parent::linkAttributes(); - - if (common_config('nofollow', 'peopletag')) { - $aAttrs['rel'] = 'nofollow'; - } - - return $aAttrs; - } -} - diff --git a/actions/peopletagautocomplete.php b/actions/peopletagautocomplete.php new file mode 100644 index 0000000000..db11a24667 --- /dev/null +++ b/actions/peopletagautocomplete.php @@ -0,0 +1,104 @@ +. + * + * PHP version 5 + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class PeopletagautocompleteAction extends Action +{ + var $user; + + /** + * Check pre-requisites and instantiate attributes + * + * @param Array $args array of arguments (URL, GET, POST) + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + // Only for logged-in users + + $this->user = common_current_user(); + + if (empty($this->user)) { + $this->clientError(_('Not logged in.')); + return false; + } + + // CSRF protection + + $token = $this->trimmed('token'); + + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token.'. + ' Try again, please.')); + return false; + } + + return true; + } + + /** + * Handle request + * + * Does the subscription and returns results. + * + * @param Array $args unused. + * + * @return void + */ + + function handle($args) + { + $profile = $this->user->getProfile(); + $tags = $profile->getOwnedTags(common_current_user()); + + $tags_array = array(); + while ($tags->fetch()) { + $arr = array(); + $arr['tag'] = $tags->tag; + $arr['mode'] = $tags->private ? 'private' : 'public'; + // $arr['url'] = $tags->homeUrl(); + $arr['freq'] = $tags->taggedCount(); + + $tags_array[] = $arr; + } + + $tags->free(); + + //common_log(LOG_DEBUG, 'Autocomplete data: ' . json_encode($tags_array)); + print(json_encode($tags_array)); + exit(0); + } +} diff --git a/actions/peopletagged.php b/actions/peopletagged.php new file mode 100644 index 0000000000..5038d1e213 --- /dev/null +++ b/actions/peopletagged.php @@ -0,0 +1,223 @@ +. + * + * @category Group + * @package StatusNet + * @author Shashi Gowda + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once(INSTALLDIR.'/lib/profilelist.php'); + +/** + * List of people tagged by the user with a tag + * + * @category Peopletag + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletaggedAction extends OwnerDesignAction +{ + var $page = null; + var $peopletag = null; + var $tagger = null; + + function isReadOnly($args) + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + + $tagger_arg = $this->arg('tagger'); + $tag_arg = $this->arg('tag'); + $tagger = common_canonical_nickname($tagger_arg); + $tag = common_canonical_tag($tag_arg); + + // Permanent redirect on non-canonical nickname + + if ($tagger_arg != $tagger || $tag_arg != $tag) { + $args = array('tagger' => $nickname, 'tag' => $tag); + if ($this->page != 1) { + $args['page'] = $this->page; + } + common_redirect(common_local_url('peopletagged', $args), 301); + return false; + } + + if (!$tagger) { + $this->clientError(_('No tagger.'), 404); + return false; + } + + $user = User::staticGet('nickname', $tagger); + + if (!$user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->tagger = $user->getProfile(); + $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag)); + + if (!$this->peopletag) { + $this->clientError(_('No such peopletag.'), 404); + return false; + } + + return true; + } + + function title() + { + if ($this->page == 1) { + return sprintf(_('People tagged %s by %s'), + $this->peopletag->tag, $this->tagger->nickname); + } else { + return sprintf(_('People tagged %s by %s, page %d'), + $this->peopletag->tag, $this->user->nickname, + $this->page); + } + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showPageNotice() + { + } + + function showLocalNav() + { + $nav = new PeopletagGroupNav($this, $this->peopletag); + $nav->show(); + } + + function showContent() + { + $offset = ($this->page-1) * PROFILES_PER_PAGE; + $limit = PROFILES_PER_PAGE + 1; + + $cnt = 0; + + $subs = $this->peopletag->getTagged($offset, $limit); + + if ($subs) { + $subscriber_list = new PeopletagMemberList($subs, $this->peopletag, $this); + $cnt = $subscriber_list->show(); + } + + $subs->free(); + + $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, + $this->page, 'peopletagged', + array('tagger' => $this->tagger->nickname, + 'tag' => $this->peopletag->tag)); + } +} + +class PeopletagMemberList extends ProfileList +{ + var $peopletag = null; + + function __construct($profile, $peopletag, $action) + { + parent::__construct($profile, $action); + + $this->peopletag = $peopletag; + } + + function newListItem($profile) + { + return new PeopletagMemberListItem($profile, $this->peopletag, $this->action); + } +} + +class PeopletagMemberListItem extends ProfileListItem +{ + var $peopletag = null; + + function __construct($profile, $peopletag, $action) + { + parent::__construct($profile, $action); + + $this->peopletag = $peopletag; + } + + function showFullName() + { + parent::showFullName(); + if ($this->profile->id == $this->peopletag->tagger) { + $this->out->text(' '); + $this->out->element('span', 'role', _('Creator')); + } + } + + function showActions() + { + $this->startActions(); + if (Event::handle('StartProfileListItemActionElements', array($this))) { + $this->showSubscribeButton(); + // TODO: Untag button + Event::handle('EndProfileListItemActionElements', array($this)); + } + $this->endActions(); + } + + function linkAttributes() + { + // tagging people is healthy page-rank flow. + return parent::linkAttributes(); + } + + /** + * Fetch necessary return-to arguments for the profile forms + * to return to this list when they're done. + * + * @return array + */ + protected function returnToArgs() + { + $args = array('action' => 'peopletagged', + 'tag' => $this->peopletag->tag, + 'tagger' => $this->profile->nickname); + $page = $this->out->arg('page'); + if ($page) { + $args['param-page'] = $page; + } + return $args; + } +} diff --git a/actions/peopletagsbyuser.php b/actions/peopletagsbyuser.php new file mode 100644 index 0000000000..3158b715bc --- /dev/null +++ b/actions/peopletagsbyuser.php @@ -0,0 +1,258 @@ +. + * + * @category Personal + * @package StatusNet + * @author Shashi Gowda + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/peopletaglist.php'; + +class PeopletagsbyuserAction extends OwnerDesignAction +{ + var $page = null; + var $tagger = null; + var $tags = null; + + function isReadOnly($args) + { + return true; + } + + function title() + { + if ($this->page == 1) { + if ($this->isOwner()) { + if ($this->arg('private')) { + return _('Private people tags by you'); + } else if ($this->arg('public')) { + return _('Public people tags by you'); + } + return _('People tags by you'); + } + return sprintf(_("People tags by %s"), $this->tagger->nickname); + } else { + return sprintf(_("People tags by %s, page %d"), $this->tagger->nickname, $this->page); + } + } + + function prepare($args) + { + parent::prepare($args); + + if ($this->arg('public') && $this->arg('private')) { + $this->args['public'] = $this->args['private'] = false; + } + + $nickname_arg = $this->arg('nickname'); + $nickname = common_canonical_nickname($nickname_arg); + + // Permanent redirect on non-canonical nickname + + if ($nickname_arg != $nickname) { + $args = $this->getSelfUrlArgs(); + if ($this->arg('page') && $this->arg('page') != 1) { + $args['page'] = $this->arg['page']; + } + common_redirect(common_local_url('peopletagsbyuser', $args), 301); + return false; + } + + $this->user = User::staticGet('nickname', $nickname); + + if (!$this->user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->tagger = $this->user->getProfile(); + + if (!$this->tagger) { + $this->serverError(_('User has no profile.')); + return false; + } + + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + + + $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE; + $limit = PEOPLETAGS_PER_PAGE + 1; + + $user = common_current_user(); + if ($this->arg('public')) { + $this->tags = $this->tagger->getOwnedTags(false, $offset, $limit); + } else if ($this->arg('private')) { + if (empty($user)) { + $this->clientError(_('Not logged in'), 403); + } + + if ($this->isOwner()) { + $this->tags = $this->tagger->getPrivateTags($offset, $limit); + } else { + $this->clientError(_('You cannot view others\' private people tags'), 403); + } + } else { + $this->tags = $this->tagger->getOwnedTags(common_current_user(), $offset, $limit); + } + return true; + } + + function handle($args) + { + parent::handle($args); + + # Post from the tag dropdown; redirect to a GET + + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + common_redirect(common_local_url('peopletagsbyuser', $this->getSelfUrlArgs()), 303); + return; + } + + $this->showPage(); + } + + function showModeSelector() + { + $this->elementStart('dl', array('id'=>'filter_tags')); + $this->element('dt', null, _('Mode')); + $this->elementStart('dd'); + $this->elementStart('ul'); + $this->elementStart('li', array('id' => 'filter_tags_for', + 'class' => 'child_1')); + $this->element('a', + array('href' => + common_local_url('peopletagsforuser', + array('nickname' => $this->user->nickname))), + sprintf(_('People tags for %s'), $this->tagger->nickname)); + $this->elementEnd('li'); + + if ($this->isOwner()) { + $this->elementStart('li', array('id'=>'filter_tags_item')); + $this->elementStart('form', array('name' => 'modeselector', + 'id' => 'form_filter_bymode', + 'action' => common_local_url('peopletagsbyuser', + array('nickname' => $this->tagger->nickname)), + 'method' => 'post')); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Select tag to filter')); + + $priv = $this->arg('private'); + $pub = $this->arg('public'); + + if (!$priv && !$pub) { + $priv = $pub = true; + } + $this->checkbox('private', _m('Private'), $priv, + _m('Show private tags')); + $this->checkbox('public', _m('Public'), $pub, + _m('Show public tags')); + $this->hidden('nickname', $this->user->nickname); + $this->submit('submit', _('Go')); + $this->elementEnd('fieldset'); + $this->elementEnd('form'); + $this->elementEnd('li'); + } + $this->elementEnd('ul'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + function showLocalNav() + { + $nav = new PersonalGroupNav($this); + $nav->show(); + } + + function showAnonymousMessage() + { + $notice = + sprintf(_('These are people tags created by **%s**. ' . + 'People tags are how you sort similar ' . + 'people on %%%%site.name%%%%, a [micro-blogging]' . + '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . + 'based on the Free Software [StatusNet](http://status.net/) tool. ' . + 'You can easily keep track of what they ' . + 'are doing by subscribing to the tag\'s timeline.' ), $this->tagger->nickname); + $this->elementStart('div', array('id' => 'anon_notice')); + $this->raw(common_markup_to_html($notice)); + $this->elementEnd('div'); + } + + function showPageNotice() + { + $this->elementStart('div', 'instructions'); + $this->showModeSelector(); + $this->elementEnd('div'); + } + + function showContent() + { + #TODO: controls here. + + $pl = new PeopletagList($this->tags, $this); + $cnt = $pl->show(); + + if ($cnt == 0) { + $this->showEmptyListMessage(); + } + $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE, + $this->page, 'peopletagsbyuser', $this->getSelfUrlArgs()); + } + + function getSelfUrlArgs() + { + $args = array(); + if ($this->arg('private')) { + $args['private'] = 1; + } else if ($this->arg('public')) { + $args['public'] = 1; + } + $args['nickname'] = $this->trimmed('nickname'); + + return $args; + } + + function isOwner() + { + $user = common_current_user(); + return !empty($user) && $user->id == $this->tagger->id; + } + + function showEmptyListMessage() + { + $message = sprintf(_('%s has not created any [people tags](%%%%doc.tags%%%%) yet.'), $this->tagger->nickname); + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + + function showSections() + { + #TODO: tags with most subscribers + #TODO: tags with most "members" + } +} diff --git a/actions/peopletagsforuser.php b/actions/peopletagsforuser.php new file mode 100644 index 0000000000..b6875b300b --- /dev/null +++ b/actions/peopletagsforuser.php @@ -0,0 +1,170 @@ +. + * + * @category Personal + * @package StatusNet + * @author Shashi Gowda + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/peopletaglist.php'; + +class PeopletagsforuserAction extends OwnerDesignAction +{ + var $page = null; + var $tagged = null; + + function isReadOnly($args) + { + return true; + } + + function title() + { + if ($this->page == 1) { + return sprintf(_("People tags for %s"), $this->tagged->nickname); + } else { + return sprintf(_("People tags for %s, page %d"), $this->tagged->nickname, $this->page); + } + } + + function prepare($args) + { + parent::prepare($args); + + $nickname_arg = $this->arg('nickname'); + $nickname = common_canonical_nickname($nickname_arg); + + // Permanent redirect on non-canonical nickname + + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + if ($this->arg('page') && $this->arg('page') != 1) { + $args['page'] = $this->arg['page']; + } + common_redirect(common_local_url('peopletagsforuser', $args), 301); + return false; + } + + $this->user = User::staticGet('nickname', $nickname); + + if (!$this->user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->tagged = $this->user->getProfile(); + + if (!$this->tagged) { + $this->serverError(_('User has no profile.')); + return false; + } + + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + + return true; + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showLocalNav() + { + $nav = new PersonalGroupNav($this); + $nav->show(); + } + + function showAnonymousMessage() + { + $notice = + sprintf(_('These are people tags for **%s**. ' . + 'People tags are how you sort similar ' . + 'people on %%%%site.name%%%%, a [micro-blogging]' . + '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . + 'based on the Free Software [StatusNet](http://status.net/) tool. ' . + 'You can easily keep track of what they ' . + 'are doing by subscribing to the tag\'s timeline.' ), $this->tagged->nickname); + $this->elementStart('div', array('id' => 'anon_notice')); + $this->raw(common_markup_to_html($notice)); + $this->elementEnd('div'); + } + + function showPageNotice() + { + $this->elementStart('dl', 'filter_tags'); + $this->elementStart('dd', array('id' => 'filter_tags_for', + 'class' => 'child_1')); + + $user = common_current_user(); + $text = ($this->tagged->id == @$user->id) ? _('People tags by you') : + sprintf(_('People tags by %s'), $this->tagged->nickname); + $this->element('a', + array('href' => + common_local_url('peopletagsbyuser', + array('nickname' => $this->tagged->nickname))), + $text); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + + + function showContent() + { + #TODO: controls here. + + $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE; + $limit = PEOPLETAGS_PER_PAGE + 1; + + $ptags = $this->tagged->getOtherTags(common_current_user(), $offset, $limit); + + $pl = new PeopletagList($ptags, $this); + $cnt = $pl->show(); + + if ($cnt == 0) { + $this->showEmptyListMessage(); + } + $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE, + $this->page, 'peopletagsforuser', array('nickname' => $this->tagged->id)); + } + + function showEmptyListMessage() + { + $message = sprintf(_('%s has not been [tagged](%%%%doc.tags%%%%) by anyone yet.'), $this->tagged->nickname); + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + + function showSections() + { + #TODO: tags with most subscribers + #TODO: tags with most "members" + } +} diff --git a/actions/peopletagsubscribers.php b/actions/peopletagsubscribers.php new file mode 100644 index 0000000000..1f2feeca29 --- /dev/null +++ b/actions/peopletagsubscribers.php @@ -0,0 +1,238 @@ +. + * + * @category Group + * @package StatusNet + * @author Evan Prodromou + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once(INSTALLDIR.'/lib/profilelist.php'); + +/** + * List of peopletag subscribers + * + * @category Peopletag + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class PeopletagsubscribersAction extends OwnerDesignAction +{ + var $page = null; + var $peopletag = null; + var $tagger = null; + + function isReadOnly($args) + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + + $tagger_arg = $this->arg('tagger'); + $tag_arg = $this->arg('tag'); + $tagger = common_canonical_nickname($tagger_arg); + $tag = common_canonical_tag($tag_arg); + + // Permanent redirect on non-canonical nickname + + if ($tagger_arg != $tagger || $tag_arg != $tag) { + $args = array('tagger' => $nickname, 'tag' => $tag); + if ($this->page != 1) { + $args['page'] = $this->page; + } + common_redirect(common_local_url('peopletagged', $args), 301); + return false; + } + + if (!$tagger) { + $this->clientError(_('No tagger.'), 404); + return false; + } + + $user = User::staticGet('nickname', $tagger); + + if (!$user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->tagger = $user->getProfile(); + $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag)); + + if (!$this->peopletag) { + $this->clientError(_('No such peopletag.'), 404); + return false; + } + + return true; + } + + function title() + { + if ($this->page == 1) { + return sprintf(_('Subscribers of people tagged %s by %s'), + $this->peopletag->tag, $this->tagger->nickname); + } else { + return sprintf(_('Subscribers of people tagged %s by %s, page %d'), + $this->peopletag->tag, $this->tagger->nickname, + $this->page); + } + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showPageNotice() + { + } + + function showLocalNav() + { + $nav = new PeopletagGroupNav($this); + $nav->show(); + } + + function showContent() + { + $offset = ($this->page-1) * PROFILES_PER_PAGE; + $limit = PROFILES_PER_PAGE + 1; + + $cnt = 0; + + $subs = $this->peopletag->getSubscribers($offset, $limit); + + if ($subs) { + $subscriber_list = new PeopletagSubscriberList($subs, $this->peopletag, $this); + $cnt = $subscriber_list->show(); + } + + $subs->free(); + + $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, + $this->page, 'peopletagsubscribers', + array('tagger' => $this->tagger->nickname, + 'tag' => $this->peopletag->tag)); + } +} + +class PeopletagSubscriberList extends ProfileList +{ + var $peopletag = null; + + function __construct($profile, $peopletag, $action) + { + parent::__construct($profile, $action); + + $this->peopletag = $peopletag; + } + + function newListItem($profile) + { + return new PeopletagSubscriberListItem($profile, $this->peopletag, $this->action); + } +} + +class PeopletagSubscriberListItem extends ProfileListItem +{ + var $peopletag = null; + + function __construct($profile, $peopletag, $action) + { + parent::__construct($profile, $action); + + $this->peopletag = $peopletag; + } + + function showFullName() + { + parent::showFullName(); + if ($this->profile->id == $this->peopletag->tagger) { + $this->out->text(' '); + $this->out->element('span', 'role', _('Creator')); + } + } + + function showActions() + { + $this->startActions(); + if (Event::handle('StartProfileListItemActionElements', array($this))) { + $this->showSubscribeButton(); + Event::handle('EndProfileListItemActionElements', array($this)); + } + $this->endActions(); + } + + function linkAttributes() + { + $aAttrs = parent::linkAttributes(); + + if (common_config('nofollow', 'members')) { + $aAttrs['rel'] .= ' nofollow'; + } + + return $aAttrs; + } + + function homepageAttributes() + { + $aAttrs = parent::linkAttributes(); + + if (common_config('nofollow', 'members')) { + $aAttrs['rel'] = 'nofollow'; + } + + return $aAttrs; + } + + /** + * Fetch necessary return-to arguments for the profile forms + * to return to this list when they're done. + * + * @return array + */ + protected function returnToArgs() + { + $args = array('action' => 'peopletagsubscribers', + 'tag' => $this->peopletag->tag, + 'tagger' => $this->profile->nickname); + $page = $this->out->arg('page'); + if ($page) { + $args['param-page'] = $page; + } + return $args; + } +} diff --git a/actions/peopletagsubscriptions.php b/actions/peopletagsubscriptions.php new file mode 100644 index 0000000000..b45651d1a2 --- /dev/null +++ b/actions/peopletagsubscriptions.php @@ -0,0 +1,138 @@ +. + * + * @category Personal + * @package StatusNet + * @author Shashi Gowda + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/peopletaglist.php'; + +class PeopletagsubscriptionsAction extends OwnerDesignAction +{ + var $page = null; + var $profile = null; + + function isReadOnly($args) + { + return true; + } + + function title() + { + if ($this->page == 1) { + return sprintf(_("People tags subscriptions by %s"), $this->profile->nickname); + } else { + return sprintf(_("People tags subscriptions by %s, page %d"), $this->profile->nickname, $this->page); + } + } + + function prepare($args) + { + parent::prepare($args); + + $nickname_arg = $this->arg('nickname'); + $nickname = common_canonical_nickname($nickname_arg); + + // Permanent redirect on non-canonical nickname + + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + if ($this->arg('page') && $this->arg('page') != 1) { + $args['page'] = $this->arg['page']; + } + common_redirect(common_local_url('peopletagsbyuser', $args), 301); + return false; + } + + $user = User::staticGet('nickname', $nickname); + + if (!$user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->profile = $user->getProfile(); + + if (!$this->profile) { + $this->serverError(_('User has no profile.')); + return false; + } + + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + + return true; + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showLocalNav() + { + $nav = new PersonalGroupNav($this); + $nav->show(); + } + + function showAnonymousMessage() + { + $notice = + sprintf(_('These are people tags subscribed to by **%s**. ' . + 'People tags are how you sort similar ' . + 'people on %%%%site.name%%%%, a [micro-blogging]' . + '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . + 'based on the Free Software [StatusNet](http://status.net/) tool. ' . + 'You can easily keep track of what they ' . + 'are doing by subscribing to the tag\'s timeline.' ), $this->profile->nickname); + $this->elementStart('div', array('id' => 'anon_notice')); + $this->raw(common_markup_to_html($notice)); + $this->elementEnd('div'); + } + + function showContent() + { + $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE; + $limit = PEOPLETAGS_PER_PAGE + 1; + + $ptags = $this->profile->getTagSubscriptions($offset, $limit); + + $pl = new PeopletagList($ptags, $this); + $cnt = $pl->show(); + + $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE, + $this->page, 'peopletagsubscriptions', array('nickname' => $this->profile->id)); + } + + function showSections() + { + #TODO: tags with most subscribers + #TODO: tags with most "members" + } +} diff --git a/actions/profilecompletion.php b/actions/profilecompletion.php new file mode 100644 index 0000000000..8208f3bd37 --- /dev/null +++ b/actions/profilecompletion.php @@ -0,0 +1,214 @@ +. + * + * PHP version 5 + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/peopletageditform.php'; + +/** + * Subscription action + * + * Subscribing to a profile. Does not work for OMB 0.1 remote subscriptions, + * but may work for other remote subscription protocols, like OStatus. + * + * Takes parameters: + * + * - subscribeto: a profile ID + * - token: session token to prevent CSRF attacks + * - ajax: boolean; whether to return Ajax or full-browser results + * + * Only works if the current user is logged in. + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +class ProfilecompletionAction extends Action +{ + var $user; + var $peopletag; + var $field; + var $msg; + + /** + * Check pre-requisites and instantiate attributes + * + * @param Array $args array of arguments (URL, GET, POST) + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + // CSRF protection + + $token = $this->trimmed('token'); + + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token.'. + ' Try again, please.')); + return false; + } + + // Only for logged-in users + + $this->user = common_current_user(); + + if (empty($this->user)) { + $this->clientError(_('Not logged in.')); + return false; + } + + $id = $this->arg('peopletag_id'); + $this->peopletag = Profile_list::staticGet('id', $id); + + if (empty($this->peopletag)) { + $this->clientError(_('No such peopletag.')); + return false; + } + + $field = $this->arg('field'); + if (!in_array($field, array('fulltext', 'nickname', 'fullname', 'description', 'location', 'uri'))) { + $this->clientError(sprintf(_('Unidentified field %s'), htmlspecialchars($field)), 404); + return false; + } + $this->field = $field; + + return true; + } + + /** + * Handle request + * + * Does the subscription and returns results. + * + * @param Array $args unused. + * + * @return void + */ + + function handle($args) + { + $this->msg = null; + + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Search results')); + $this->elementEnd('head'); + $this->elementStart('body'); + $profiles = $this->getResults(); + + if ($this->msg !== null) { + $this->element('p', 'error', $this->msg); + } else { + if (count($profiles) > 0) { + $this->elementStart('ul', array('id' => 'profile_search_results', 'class' => 'profile-lister')); + foreach ($profiles as $profile) { + $this->showProfileItem($profile); + } + $this->elementEnd('ul'); + } else { + $this->element('p', 'error', _('No results.')); + } + } + $this->elementEnd('body'); + $this->elementEnd('html'); + } + + function getResults() + { + $profiles = array(); + $q = $this->arg('q'); + $q = strtolower($q); + if (strlen($q) < 3) { + $this->msg = _('The search string must be atleast 3 characters long'); + } + $page = $this->arg('page'); + $page = (int) (empty($page) ? 1 : $page); + + $profile = new Profile(); + $search_engine = $profile->getSearchEngine('profile'); + + if (Event::handle('StartProfileCompletionSearch', array($this, &$profile, $search_engine))) { + $search_engine->set_sort_mode('chron'); + $search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1); + + if (false === $search_engine->query($q)) { + $cnt = 0; + } + else { + $cnt = $profile->find(); + } + Event::handle('EndProfileCompletionSearch', $this, &$profile, $search_engine); + } + + while ($profile->fetch()) { + $profiles[] = clone($profile); + } + return $this->filter($profiles); + } + + function filter($profiles) + { + $current = $this->user->getProfile(); + $filtered_profiles = array(); + foreach ($profiles as $profile) { + if ($current->canTag($profile)) { + $filtered_profiles[] = $profile; + } + } + return $filtered_profiles; + } + + function showProfileItem($profile) + { + $this->elementStart('li', 'entity_removable_profile'); + $item = new TaggedProfileItem($this, $profile); + $item->show(); + $this->elementStart('span', 'entity_actions'); + + if ($profile->isTagged($this->peopletag)) { + $untag = new UntagButton($this, $profile, $this->peopletag); + $untag->show(); + } else { + $tag = new TagButton($this, $profile, $this->peopletag); + $tag->show(); + } + + $this->elementEnd('span'); + $this->elementEnd('li'); + } +} diff --git a/actions/profilesettings.php b/actions/profilesettings.php index e1d686ca29..046bedf8ac 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -279,18 +279,24 @@ class ProfilesettingsAction extends SettingsAction return; } - if ($tagstring) { - $tags = array_map('common_canonical_tag', preg_split('/[\s,]+/', $tagstring)); - } else { - $tags = array(); - } + $tags = array(); + $tag_priv = array(); + if (is_string($tagstring) && strlen($tagstring) > 0) { - foreach ($tags as $tag) { - if (!common_valid_profile_tag($tag)) { - // TRANS: Validation error in form for profile settings. - // TRANS: %s is an invalid tag. - $this->showForm(sprintf(_('Invalid tag: "%s".'), $tag)); - return; + $tags = preg_split('/[\s,]+/', $tagstring); + + foreach ($tags as &$tag) { + $private = @$tag[0] === '.'; + + $tag = common_canonical_tag($tag); + if (!common_valid_profile_tag($tag)) { + // TRANS: Validation error in form for profile settings. + // TRANS: %s is an invalid tag. + $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag)); + return; + } + + $tag_priv[$tag] = $private; } } @@ -421,7 +427,7 @@ class ProfilesettingsAction extends SettingsAction } // Set the user tags - $result = $user->setSelfTags($tags); + $result = $user->setSelfTags($tags, $tag_priv); if (!$result) { // TRANS: Server error thrown when user profile settings tags could not be saved. diff --git a/actions/profiletagbyid.php b/actions/profiletagbyid.php new file mode 100644 index 0000000000..7de5737e9a --- /dev/null +++ b/actions/profiletagbyid.php @@ -0,0 +1,92 @@ +. + * + * @category Peopletag + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +class ProfiletagbyidAction extends Action +{ + /** peopletag we're viewing. */ + var $peopletag = null; + + /** + * Is this page read-only? + * + * @return boolean true + */ + + function isReadOnly($args) + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + + $id = $this->arg('id'); + $tagger_id = $this->arg('tagger_id'); + + if (!$id) { + $this->clientError(_('No ID.')); + return false; + } + + common_debug("Peopletag id $id by user id $tagger_id"); + + $this->peopletag = Profile_list::staticGet('id', $id); + + if (!$this->peopletag) { + $this->clientError(_('No such people tag.'), 404); + return false; + } + + $user = User::staticGet('id', $tagger_id); + if (!$user) { + // remote peopletag, permanently redirect + common_redirect($this->peopletag->permalink(), 301); + } + + return true; + } + + /** + * Handle the request + * + * Shows a profile for the group, some controls, and a list of + * group notices. + * + * @return void + */ + + function handle($args) + { + common_redirect($this->peopletag->homeUrl(), 303); + } +} diff --git a/actions/public.php b/actions/public.php index 727c76d528..ca9af4601e 100644 --- a/actions/public.php +++ b/actions/public.php @@ -232,6 +232,8 @@ class PublicAction extends Action $pop->show(); $gbp = new GroupsByMembersSection($this); $gbp->show(); + $ptp = new PeopletagsBySubsSection($this); + $ptp->show(); $feat = new FeaturedUsersSection($this); $feat->show(); } diff --git a/actions/publicpeopletagcloud.php b/actions/publicpeopletagcloud.php new file mode 100644 index 0000000000..dc252fe4c8 --- /dev/null +++ b/actions/publicpeopletagcloud.php @@ -0,0 +1,173 @@ +. + * + * @category Public + * @package StatusNet + * @author Mike Cochrane + * @author Evan Prodromou + * @copyright 2008 Mike Cochrane + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } + +define('TAGS_PER_PAGE', 100); + +/** + * Public tag cloud for notices + * + * @category Personal + * @package StatusNet + * @author Mike Cochrane + * @author Evan Prodromou + * @copyright 2008 Mike Cochrane + * @copyright 2008-2009 StatusNet, Inc. + * @link http://status.net/ + */ + +class PublicpeopletagcloudAction extends Action +{ + function isReadOnly($args) + { + return true; + } + + function title() + { + return _('Public people tag cloud'); + } + + function showPageNotice() + { + $this->element('p', 'instructions', + sprintf(_('These are most used people tags on %s '), + common_config('site', 'name'))); + } + + function showEmptyList() + { + $message = _('No one has [tagged](%%doc.tags%%) anyone yet.') . ' '; + + if (common_logged_in()) { + $message .= _('Be the first to tag someone!'); + } + else { + $message .= _('Why not [register an account](%%action.register%%) and be the first to tag someone!'); + } + + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + + function showLocalNav() + { + $nav = new PublicGroupNav($this); + $nav->show(); + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showContent() + { + // XXX: cache this + + $tags = new Profile_tag(); + $plist = new Profile_list(); + $plist->private = false; + + $tags->joinAdd($plist); + $tags->selectAdd(); + $tags->selectAdd('profile_tag.tag'); + $tags->selectAdd('count(profile_tag.tag) as weight'); + $tags->groupBy('profile_tag.tag'); + $tags->orderBy('weight DESC'); + + $tags->limit(TAGS_PER_PAGE); + + $cnt = $tags->find(); + + if ($cnt > 0) { + $this->elementStart('div', array('id' => 'tagcloud', + 'class' => 'section')); + + $tw = array(); + $sum = 0; + while ($tags->fetch()) { + $tw[$tags->tag] = $tags->weight; + $sum += $tags->weight; + } + + ksort($tw); + + $this->elementStart('dl'); + $this->element('dt', null, _('People tag cloud')); + $this->elementStart('dd'); + $this->elementStart('ul', 'tags xoxo tag-cloud'); + foreach ($tw as $tag => $weight) { + if ($sum) { + $weightedSum = $weight/$sum; + } else { + $weightedSum = 0.5; + } + $this->showTag($tag, $weight, $weightedSum); + } + $this->elementEnd('ul'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + $this->elementEnd('div'); + } else { + $this->showEmptyList(); + } + } + + function showTag($tag, $weight, $relative) + { + if ($relative > 0.1) { + $rel = 'tag-cloud-7'; + } else if ($relative > 0.05) { + $rel = 'tag-cloud-6'; + } else if ($relative > 0.02) { + $rel = 'tag-cloud-5'; + } else if ($relative > 0.01) { + $rel = 'tag-cloud-4'; + } else if ($relative > 0.005) { + $rel = 'tag-cloud-3'; + } else if ($relative > 0.002) { + $rel = 'tag-cloud-2'; + } else { + $rel = 'tag-cloud-1'; + } + + $this->elementStart('li', $rel); + + $count = ($weight == 1) ? '1 person tagged' : '%d people tagged'; + $this->element('a', array('href' => common_local_url('peopletag', array('tag' => $tag)), + 'title' => sprintf(_($count), $weight)), $tag); + $this->elementEnd('li'); + } +} diff --git a/actions/removepeopletag.php b/actions/removepeopletag.php new file mode 100644 index 0000000000..aa8ae2b6ad --- /dev/null +++ b/actions/removepeopletag.php @@ -0,0 +1,173 @@ +. + * + * PHP version 5 + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/togglepeopletag.php'; + +/** + * Subscription action + * + * Subscribing to a profile. Does not work for OMB 0.1 remote subscriptions, + * but may work for other remote subscription protocols, like OStatus. + * + * Takes parameters: + * + * - subscribeto: a profile ID + * - token: session token to prevent CSRF attacks + * - ajax: boolean; whether to return Ajax or full-browser results + * + * Only works if the current user is logged in. + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +class RemovepeopletagAction extends Action +{ + var $user; + var $tagged; + var $peopletag; + + /** + * Check pre-requisites and instantiate attributes + * + * @param Array $args array of arguments (URL, GET, POST) + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + // CSRF protection + + $token = $this->trimmed('token'); + + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token.'. + ' Try again, please.')); + return false; + } + + // Only for logged-in users + + $this->user = common_current_user(); + + if (empty($this->user)) { + $this->clientError(_('Not logged in.')); + return false; + } + + // Profile to subscribe to + + $tagged_id = $this->arg('tagged'); + + $this->tagged = Profile::staticGet('id', $tagged_id); + + if (empty($this->tagged)) { + $this->clientError(_('No such profile.')); + return false; + } + + $id = $this->arg('peopletag_id'); + $this->peopletag = Profile_list::staticGet('id', $id); + + if (empty($this->peopletag)) { + $this->clientError(_('No such peopletag.')); + return false; + } + + // OMB 0.1 doesn't have a mechanism for local-server- + // originated tag. + + $omb01 = Remote_profile::staticGet('id', $tagged_id); + + if (!empty($omb01)) { + $this->clientError(_('You cannot tag or untag an OMB 0.1'. + ' remote profile with this action.')); + return false; + } + + return true; + } + + /** + * Handle request + * + * Does the subscription and returns results. + * + * @param Array $args unused. + * + * @return void + */ + + function handle($args) + { + // Throws exception on error + + $ptag = Profile_tag::unTag($this->user->id, $this->tagged->id, + $this->peopletag->tag); + + if (!$ptag) { + $user = User::staticGet('id', $this->tagged->id); + if ($user) { + $this->clientError( + sprintf(_('There was an unexpected error while tagging %s'), + $user->nickname)); + } else { + $this->clientError(sprintf(_('There was a problem tagging %s.' . + 'The remote server is probably not responding correctly, ' . + 'please try retrying later.'), $this->profile->profileurl)); + } + return false; + } + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Untagged')); + $this->elementEnd('head'); + $this->elementStart('body'); + $unsubscribe = new TagButton($this, $this->tagged, $this->peopletag); + $unsubscribe->show(); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + $url = common_local_url('subscriptions', + array('nickname' => $this->user->nickname)); + common_redirect($url, 303); + } + } +} diff --git a/actions/selftag.php b/actions/selftag.php new file mode 100644 index 0000000000..0efb896f6b --- /dev/null +++ b/actions/selftag.php @@ -0,0 +1,204 @@ +. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @author Zach Copley + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * This class outputs a paginated list of profiles self-tagged with a given tag + * + * @category Output + * @package StatusNet + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see Action + */ + +class SelftagAction extends Action +{ + + var $tag = null; + var $page = null; + + /** + * For initializing members of the class. + * + * @param array $argarray misc. arguments + * + * @return boolean true + */ + function prepare($argarray) + { + parent::prepare($argarray); + + $this->tag = $this->trimmed('tag'); + + if (!common_valid_profile_tag($this->tag)) { + $this->clientError(sprintf(_('Not a valid people tag: %s.'), + $this->tag)); + return; + } + + $this->page = ($this->arg('page')) ? $this->arg('page') : 1; + + common_set_returnto($this->selfUrl()); + + return true; + } + + /** + * Handler method + * + * @param array $argarray is ignored since it's now passed in in prepare() + * + * @return boolean is read only action? + */ + function handle($argarray) + { + parent::handle($argarray); + $this->showPage(); + } + + /** + * Whips up a query to get a list of profiles based on the provided + * people tag and page, initalizes a ProfileList widget, and displays + * it to the user. + * + * @return nothing + */ + function showContent() + { + + $profile = new Profile(); + + $offset = ($this->page - 1) * PROFILES_PER_PAGE; + $limit = PROFILES_PER_PAGE + 1; + + if (common_config('db', 'type') == 'pgsql') { + $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $lim = ' LIMIT ' . $offset . ', ' . $limit; + } + + // XXX: memcached this + + $qry = 'SELECT profile.* ' . + 'FROM profile JOIN ( profile_tag, profile_list ) ' . + 'ON profile.id = profile_tag.tagger ' . + 'AND profile_tag.tagger = profile_list.tagger ' . + 'AND profile_list.tag = profile_tag.tag ' . + 'WHERE profile_tag.tagger = profile_tag.tagged ' . + "AND profile_tag.tag = '%s' "; + + $user = common_current_user(); + if (empty($user)) { + $qry .= 'AND profile_list.private = false '; + } else { + $qry .= 'AND (profile_list.tagger = ' . $user->id . + ' OR profile_list.private = false) '; + } + + $qry .= 'ORDER BY profile_tag.modified DESC%s'; + + $profile->query(sprintf($qry, $this->tag, $lim)); + + $ptl = new SelfTagProfileList($profile, $this); // pass the ammunition + $cnt = $ptl->show(); + + $this->pagination($this->page > 1, + $cnt > PROFILES_PER_PAGE, + $this->page, + 'selftag', + array('tag' => $this->tag)); + } + + /** + * Returns the page title + * + * @return string page title + */ + function title() + { + return sprintf(_('Users self-tagged with %1$s - page %2$d'), + $this->tag, $this->page); + } + +} + +class SelfTagProfileList extends ProfileList +{ + function newListItem($profile) + { + return new SelfTagProfileListItem($profile, $this->action); + } +} + +class SelfTagProfileListItem extends ProfileListItem +{ + function linkAttributes() + { + $aAttrs = parent::linkAttributes(); + + if (common_config('nofollow', 'selftag')) { + $aAttrs['rel'] .= ' nofollow'; + } + + return $aAttrs; + } + + function homepageAttributes() + { + $aAttrs = parent::linkAttributes(); + + if (common_config('nofollow', 'selftag')) { + $aAttrs['rel'] = 'nofollow'; + } + + return $aAttrs; + } + + function showTags() + { + $selftags = new SelfTagsWidget($this->out, $this->profile, $this->profile); + $selftags->show(); + + $user = common_current_user(); + + if (!empty($user) && $user->id != $this->profile->id && + $user->getProfile()->canTag($this->profile)) { + $yourtags = new PeopleTagsWidget($this->out, $user, $this->profile); + $yourtags->show(); + } + } +} diff --git a/actions/showprofiletag.php b/actions/showprofiletag.php new file mode 100644 index 0000000000..a4cace6e96 --- /dev/null +++ b/actions/showprofiletag.php @@ -0,0 +1,354 @@ +. + * + * @category Actions + * @package Actions + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @link http://status.net + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/profileminilist.php'; +require_once INSTALLDIR.'/lib/peopletaglist.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; + +class ShowprofiletagAction extends Action +{ + var $notice, $tagger, $peopletag; + + function isReadOnly($args) + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + + $tagger_arg = $this->arg('tagger'); + $tag_arg = $this->arg('tag'); + $tagger = common_canonical_nickname($tagger_arg); + $tag = common_canonical_tag($tag_arg); + + // Permanent redirect on non-canonical nickname + + if ($tagger_arg != $tagger || $tag_arg != $tag) { + $args = array('tagger' => $nickname, 'tag' => $tag); + if ($this->page != 1) { + $args['page'] = $this->page; + } + common_redirect(common_local_url('showprofiletag', $args), 301); + return false; + } + + if (!$tagger) { + $this->clientError(_('No tagger.'), 404); + return false; + } + + $user = User::staticGet('nickname', $tagger); + + if (!$user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->tagger = $user->getProfile(); + $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag)); + + $current = common_current_user(); + $can_see = !empty($this->peopletag) && (!$this->peopletag->private || + ($this->peopletag->private && $this->peopletag->tagger === $current->id)); + + if (!$can_see) { + $this->clientError(_('No such peopletag.'), 404); + return false; + } + + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + $this->notice = $this->peopletag->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + + if ($this->page > 1 && $this->notice->N == 0) { + // TRANS: Server error when page not found (404) + $this->serverError(_('No such page.'), $code = 404); + } + + return true; + } + + function handle($args) + { + parent::handle($args); + + if (!$this->peopletag) { + $this->clientError(_('No such user.')); + return; + } + + $this->showPage(); + } + + function title() + { + if ($this->page > 1) { + + if($this->peopletag->private) { + return sprintf(_('Private timeline for people tagged %s by you, page %d'), + $this->peopletag->tag, $this->page); + } + + $current = common_current_user(); + if (!empty($current) && $current->id == $this->peopletag->tagger) { + return sprintf(_('Timeline for people tagged %s by you, page %d'), + $this->peopletag->tag, $this->page); + } + + // TRANS: Page title. %1$s is user nickname, %2$d is page number + return sprintf(_('Timeline for people tagged %1$s by %2$s, page %3$d'), + $this->peopletag->tag, + $this->tagger->nickname, + $this->page + ); + } else { + + if($this->peopletag->private) { + return sprintf(_('Private timeline of people tagged %s by you'), + $this->peopletag->tag, $this->page); + } + + $current = common_current_user(); + if (!empty($current) && $current->id == $this->peopletag->tagger) { + return sprintf(_('Timeline for people tagged %s by you'), + $this->peopletag->tag, $this->page); + } + + // TRANS: Page title. %1$s is user nickname, %2$d is page number + return sprintf(_('Timeline for people tagged %1$s by %2$s'), + $this->peopletag->tag, + $this->tagger->nickname, + $this->page + ); + } + } + + function getFeeds() + { + #XXX: make these actually work + return array(new Feed(Feed::RSS2, + common_local_url( + 'ApiTimelineList', array( + 'user' => $this->tagger->id, + 'id' => $this->peopletag->id, + 'format' => 'rss' + ) + ), + // TRANS: %1$s is user nickname + sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->tagger->nickname)), + new Feed(Feed::ATOM, + common_local_url( + 'ApiTimelineList', array( + 'user' => $this->tagger->id, + 'id' => $this->peopletag->id, + 'format' => 'atom' + ) + ), + // TRANS: %1$s is user nickname + sprintf(_('Feed for people tagged %s by %s (Atom)'), + $this->peopletag->tag, $this->tagger->nickname + ) + ) + ); + } + + function showLocalNav() + { + $nav = new PeopletagGroupNav($this); + $nav->show(); + } + + function showEmptyListMessage() + { + // TRANS: %1$s is user nickname + $message = sprintf(_('This is the timeline for people tagged %s by %s but no one has posted anything yet.'), $this->peopletag->tag, $this->tagger->nickname) . ' '; + + if (common_logged_in()) { + $current_user = common_current_user(); + if ($this->tagger->id == $current_user->id) { + $message .= _('Try tagging more people.'); + } + } else { + $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline.'); + } + + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + + function showContent() + { + $this->showPeopletag(); + $this->showNotices(); + } + + function showPeopletag() + { + $cur = common_current_user(); + $tag = new Peopletag($this->peopletag, $cur, $this); + $tag->show(); + } + + function showNotices() + { + if (Event::handle('StartShowProfileTagContent', array($this))) { + $nl = new NoticeList($this->notice, $this); + + $cnt = $nl->show(); + + if (0 == $cnt) { + $this->showEmptyListMessage(); + } + + $this->pagination( + $this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'showprofiletag', array('tag' => $this->peopletag->tag, + 'tagger' => $this->tagger->nickname) + ); + + Event::handle('EndShowProfileTagContent', array($this)); + } + } + + function showSections() + { + $this->showTagged(); + if (!$this->peopletag->private) { + $this->showSubscribers(); + } + # $this->showStatistics(); + } + + function showPageTitle() + { + $this->element('h1', null, $this->title()); + } + + function showTagged() + { + $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1); + + $this->elementStart('div', array('id' => 'entity_tagged', + 'class' => 'section')); + if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) { + + $title = ''; + + $current = common_current_user(); + if(!empty($current) && $this->peopletag->tagger == $current->id) { + $title = sprintf(_('People tagged %s by you'), $this->peopletag->tag); + } else { + $title = sprintf(_('People tagged %1$s by %2$s'), + $this->peopletag->tag, + $this->tagger->nickname); + } + + $this->element('h2', null, $title); + + $cnt = 0; + + if (!empty($profile)) { + $pml = new ProfileMiniList($profile, $this); + $cnt = $pml->show(); + if ($cnt == 0) { + $this->element('p', null, _('(None)')); + } + } + + if ($cnt > PROFILES_PER_MINILIST) { + $this->elementStart('p'); + $this->element('a', array('href' => common_local_url('taggedprofiles', + array('nickname' => $this->tagger->nickname, + 'profiletag' => $this->peopletag->tag)), + 'class' => 'more'), + _('Show all')); + $this->elementEnd('p'); + } + + Event::handle('EndShowTaggedProfilesMiniList', array($this)); + } + $this->elementEnd('div'); + } + + function showSubscribers() + { + $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1); + + $this->elementStart('div', array('id' => 'entity_subscribers', + 'class' => 'section')); + if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) { + $this->element('h2', null, _('Subscribers')); + + $cnt = 0; + + if (!empty($profile)) { + $pml = new ProfileMiniList($profile, $this); + $cnt = $pml->show(); + if ($cnt == 0) { + $this->element('p', null, _('(None)')); + } + } + + if ($cnt > PROFILES_PER_MINILIST) { + $this->elementStart('p'); + $this->element('a', array('href' => common_local_url('profiletagsubscribers', + array('nickname' => $this->tagger->nickname, + 'profiletag' => $this->peopletag->tag)), + 'class' => 'more'), + _('All subscribers')); + $this->elementEnd('p'); + } + + Event::handle('EndShowProfileTagSubscribersMiniList', array($this)); + } + $this->elementEnd('div'); + } +} + +class Peopletag extends PeopletagListItem +{ + function showStart() + { + $mode = $this->peopletag->private ? 'private' : 'public'; + $this->out->elementStart('div', array('class' => 'hentry peopletag peopletag-profile mode-'.$mode, + 'id' => 'peopletag-' . $this->peopletag->id)); + } + + function showEnd() + { + $this->out->elementEnd('div'); + } + + function showAvatar() + { + parent::showAvatar(AVATAR_PROFILE_SIZE); + } +} diff --git a/actions/subscribepeopletag.php b/actions/subscribepeopletag.php new file mode 100644 index 0000000000..e38ecb2d3e --- /dev/null +++ b/actions/subscribepeopletag.php @@ -0,0 +1,144 @@ +. + * + * @category Peopletag + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Subscribe to a peopletag + * + * This is the action for subscribing to a peopletag. It works more or less like the join action + * for groups. + * + * @category Peopletag + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class SubscribepeopletagAction extends Action +{ + var $peopletag = null; + var $tagger = null; + + /** + * Prepare to run + */ + + function prepare($args) + { + parent::prepare($args); + + if (!common_logged_in()) { + $this->clientError(_('You must be logged in to unsubscribe to a peopletag.')); + return false; + } + // Only allow POST requests + + if ($_SERVER['REQUEST_METHOD'] != 'POST') { + $this->clientError(_('This action only accepts POST requests.')); + return false; + } + + // CSRF protection + + $token = $this->trimmed('token'); + + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token.'. + ' Try again, please.')); + return false; + } + + $tagger_arg = $this->trimmed('tagger'); + $tag_arg = $this->trimmed('tag'); + + $id = intval($this->arg('id')); + if ($id) { + $this->peopletag = Profile_list::staticGet('id', $id); + } else { + $this->clientError(_('No ID given.'), 404); + return false; + } + + if (!$this->peopletag || $this->peopletag->private) { + $this->clientError(_('No such peopletag.'), 404); + return false; + } + + $this->tagger = Profile::staticGet('id', $this->peopletag->tagger); + + return true; + } + + /** + * Handle the request + * + * On POST, add the current user to the group + * + * @param array $args unused + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + $cur = common_current_user(); + + try { + Profile_tag_subscription::add($this->peopletag, $cur); + } catch (Exception $e) { + $this->serverError(sprintf(_('Could not subscribe user %1$s to peopletag %2$s.'), + $cur->nickname, $this->peopletag->tag) . ' ' . $e->getMessage()); + } + + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, sprintf(_('%1$s subscribed to peopletag %2$s by %3$s'), + $cur->nickname, + $this->peopletag->tag, + $this->tagger->nickname)); + $this->elementEnd('head'); + $this->elementStart('body'); + $lf = new UnsubscribePeopletagForm($this, $this->peopletag); + $lf->show(); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + common_redirect(common_local_url('peopletagsubscribers', + array('tagger' => $this->tagger->nickname, + 'tag' =>$this->peopletag->tag)), + 303); + } + } +} diff --git a/actions/tagother.php b/actions/tagother.php deleted file mode 100644 index 258c13bdcc..0000000000 --- a/actions/tagother.php +++ /dev/null @@ -1,220 +0,0 @@ -. - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -require_once(INSTALLDIR.'/lib/settingsaction.php'); - -class TagotherAction extends Action -{ - var $profile = null; - var $error = null; - - function prepare($args) - { - parent::prepare($args); - if (!common_logged_in()) { - $this->clientError(_('Not logged in.'), 403); - return false; - } - - $id = $this->trimmed('id'); - if (!$id) { - $this->clientError(_('No ID argument.')); - return false; - } - - $this->profile = Profile::staticGet('id', $id); - - if (!$this->profile) { - $this->clientError(_('No profile with that ID.')); - return false; - } - - return true; - } - - function handle($args) - { - parent::handle($args); - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $this->saveTags(); - } else { - $this->showForm($profile); - } - } - - function title() - { - return sprintf(_('Tag %s'), $this->profile->nickname); - } - - function showForm($error=null) - { - $this->error = $error; - $this->showPage(); - } - - function showContent() - { - $this->elementStart('div', 'entity_profile vcard author'); - $this->element('h2', null, _('User profile')); - - $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); - $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE), - 'class' => 'photo avatar entity_depiction', - 'width' => AVATAR_PROFILE_SIZE, - 'height' => AVATAR_PROFILE_SIZE, - 'alt' => - ($this->profile->fullname) ? $this->profile->fullname : - $this->profile->nickname)); - - $this->element('a', array('href' => $this->profile->profileurl, - 'class' => 'entity_nickname nickname'), - $this->profile->nickname); - - if ($this->profile->fullname) { - $this->element('div', 'fn entity_fn', $this->profile->fullname); - } - - if ($this->profile->location) { - $this->element('div', 'label entity_location', $this->profile->location); - } - - if ($this->profile->homepage) { - $this->element('a', array('href' => $this->profile->homepage, - 'rel' => 'me', - 'class' => 'url entity_url'), - $this->profile->homepage); - } - - if ($this->profile->bio) { - $this->element('div', 'note entity_note', $this->profile->bio); - } - - $this->elementEnd('div'); - - $this->elementStart('form', array('method' => 'post', - 'id' => 'form_tag_user', - 'class' => 'form_settings', - 'name' => 'tagother', - 'action' => common_local_url('tagother', array('id' => $this->profile->id)))); - - $this->elementStart('fieldset'); - $this->element('legend', null, _('Tag user')); - $this->hidden('token', common_session_token()); - $this->hidden('id', $this->profile->id); - - $user = common_current_user(); - - $this->elementStart('ul', 'form_data'); - $this->elementStart('li'); - $this->input('tags', _('Tags'), - ($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $this->profile->id)), - _('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated')); - $this->elementEnd('li'); - $this->elementEnd('ul'); - $this->submit('save', _('Save')); - $this->elementEnd('fieldset'); - $this->elementEnd('form'); - } - - function saveTags() - { - $id = $this->trimmed('id'); - $tagstring = $this->trimmed('tags'); - $token = $this->trimmed('token'); - - if (!$token || $token != common_session_token()) { - $this->showForm(_('There was a problem with your session token. '. - 'Try again, please.')); - return; - } - - if (is_string($tagstring) && strlen($tagstring) > 0) { - - $tags = array_map('common_canonical_tag', - preg_split('/[\s,]+/', $tagstring)); - - foreach ($tags as $tag) { - if (!common_valid_profile_tag($tag)) { - $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag)); - return; - } - } - } else { - $tags = array(); - } - - $user = common_current_user(); - - if (!Subscription::pkeyGet(array('subscriber' => $user->id, - 'subscribed' => $this->profile->id)) && - !Subscription::pkeyGet(array('subscriber' => $this->profile->id, - 'subscribed' => $user->id))) - { - $this->clientError(_('You can only tag people you are subscribed to or who are subscribed to you.')); - return; - } - - $result = Profile_tag::setTags($user->id, $this->profile->id, $tags); - - if (!$result) { - $this->clientError(_('Could not save tags.')); - return; - } - - $action = $user->isSubscribed($this->profile) ? 'subscriptions' : 'subscribers'; - - if ($this->boolean('ajax')) { - $this->startHTML('text/xml;charset=utf-8'); - $this->elementStart('head'); - $this->element('title', null, _('Tags')); - $this->elementEnd('head'); - $this->elementStart('body'); - $this->elementStart('p', 'subtags'); - foreach ($tags as $tag) { - $this->element('a', array('href' => common_local_url($action, - array('nickname' => $user->nickname, - 'tag' => $tag))), - $tag); - } - $this->elementEnd('p'); - $this->elementEnd('body'); - $this->elementEnd('html'); - } else { - common_redirect(common_local_url($action, array('nickname' => - $user->nickname)), - 303); - } - } - - function showPageNotice() - { - if ($this->error) { - $this->element('p', 'error', $this->error); - } else { - $this->elementStart('div', 'instructions'); - $this->element('p', null, - _('Use this form to add tags to your subscribers or subscriptions.')); - $this->elementEnd('div'); - } - } -} - diff --git a/actions/tagprofile.php b/actions/tagprofile.php new file mode 100644 index 0000000000..8c0e039dd6 --- /dev/null +++ b/actions/tagprofile.php @@ -0,0 +1,249 @@ +. + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } + +require_once INSTALLDIR . '/lib/settingsaction.php'; +require_once INSTALLDIR . '/lib/peopletags.php'; + +class TagprofileAction extends Action +{ + var $profile = null; + var $error = null; + + function prepare($args) + { + parent::prepare($args); + if (!common_logged_in()) { + common_set_returnto($_SERVER['REQUEST_URI']); + if (Event::handle('RedirectToLogin', array($this, null))) { + common_redirect(common_local_url('login'), 303); + } + } + + $id = $this->trimmed('id'); + if (!$id) { + $this->profile = false; + } else { + $this->profile = Profile::staticGet('id', $id); + + if (!$this->profile) { + $this->clientError(_('No profile with that ID.')); + return false; + } + } + + $current = common_current_user()->getProfile(); + if ($this->profile && !$current->canTag($this->profile)) { + $this->clientError(_('You cannot tag this user.')); + } + return true; + } + + function handle($args) + { + parent::handle($args); + if (Event::handle('StartTagProfileAction', array($this, $this->profile))) { + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->saveTags(); + } else { + $this->showForm(); + } + Event::handle('EndTagProfileAction', array($this, $this->profile)); + } + } + + function title() + { + if (!$this->profile) { + return _('Tag a profile'); + } + return sprintf(_('Tag %s'), $this->profile->nickname); + } + + function showForm($error=null) + { + $this->error = $error; + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Error')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->element('p', 'error', $error); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + $this->showPage(); + } + } + + function showContent() + { + if (Event::handle('StartShowTagProfileForm', array($this, $this->profile)) && $this->profile) { + $this->elementStart('div', 'entity_profile vcard author'); + $this->element('h2', null, _('User profile')); + + $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); + $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE), + 'class' => 'photo avatar entity_depiction', + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => + ($this->profile->fullname) ? $this->profile->fullname : + $this->profile->nickname)); + + $this->element('a', array('href' => $this->profile->profileurl, + 'class' => 'entity_nickname nickname'), + $this->profile->nickname); + if ($this->profile->fullname) { + $this->element('div', 'fn entity_fn', $this->profile->fullname); + } + + if ($this->profile->location) { + $this->element('div', 'label entity_location', $this->profile->location); + } + + if ($this->profile->homepage) { + $this->element('a', array('href' => $this->profile->homepage, + 'rel' => 'me', + 'class' => 'url entity_url'), + $this->profile->homepage); + } + + if ($this->profile->bio) { + $this->element('div', 'note entity_note', $this->profile->bio); + } + + $this->elementEnd('div'); + + $this->elementStart('form', array('method' => 'post', + 'id' => 'form_tag_user', + 'class' => 'form_settings', + 'name' => 'tagprofile', + 'action' => common_local_url('tagprofile', array('id' => $this->profile->id)))); + + $this->elementStart('fieldset'); + $this->element('legend', null, _('Tag user')); + $this->hidden('token', common_session_token()); + $this->hidden('id', $this->profile->id); + + $user = common_current_user(); + + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); + + $tags = Profile_tag::getTagsArray($user->id, $this->profile->id, $user->id); + $this->input('tags', _('Tags'), + ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $tags), + _('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated')); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->submit('save', _('Save')); + $this->elementEnd('fieldset'); + $this->elementEnd('form'); + + Event::handle('EndShowTagProfileForm', array($this, $this->profile)); + } + } + + function saveTags() + { + $id = $this->trimmed('id'); + $tagstring = $this->trimmed('tags'); + $token = $this->trimmed('token'); + + if (Event::handle('StartSavePeopletags', array($this, $tagstring))) { + if (!$token || $token != common_session_token()) { + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); + return; + } + + $tags = array(); + $tag_priv = array(); + + if (is_string($tagstring) && strlen($tagstring) > 0) { + + $tags = preg_split('/[\s,]+/', $tagstring); + + foreach ($tags as &$tag) { + $private = @$tag[0] === '.'; + + $tag = common_canonical_tag($tag); + if (!common_valid_profile_tag($tag)) { + $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag)); + return; + } + + $tag_priv[$tag] = $private; + } + } + + $user = common_current_user(); + + try { + $result = Profile_tag::setTags($user->id, $this->profile->id, $tags, $tag_priv); + if (!$result) { + throw new Exception('The tags could not be saved.'); + } + } catch (Exception $e) { + $this->showForm($e->getMessage()); + return false; + } + + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, _('Tags')); + $this->elementEnd('head'); + $this->elementStart('body'); + + if ($user->id == $this->profile->id) { + $widget = new SelftagsWidget($this, $user, $this->profile); + $widget->show(); + } else { + $widget = new PeopletagsWidget($this, $user, $this->profile); + $widget->show(); + } + + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + $this->error = 'Tags saved.'; + $this->showForm(); + } + + Event::handle('EndSavePeopletags', array($this, $tagstring)); + } + } + + function showPageNotice() + { + if ($this->error) { + $this->element('p', 'error', $this->error); + } else { + $this->elementStart('div', 'instructions'); + $this->element('p', null, + _('Use this form to add tags to your subscribers or subscriptions.')); + $this->elementEnd('div'); + } + } +} + diff --git a/actions/unsubscribepeopletag.php b/actions/unsubscribepeopletag.php new file mode 100644 index 0000000000..a912cc10f9 --- /dev/null +++ b/actions/unsubscribepeopletag.php @@ -0,0 +1,142 @@ +. + * + * @category Peopletag + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Unsubscribe to a peopletag + * + * This is the action for subscribing to a peopletag. It works more or less like the join action + * for groups. + * + * @category Peopletag + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class UnsubscribepeopletagAction extends Action +{ + var $peopletag = null; + var $tagger = null; + + /** + * Prepare to run + */ + + function prepare($args) + { + parent::prepare($args); + + if (!common_logged_in()) { + $this->clientError(_('You must be logged in to unsubscribe to a peopletag.')); + return false; + } + // Only allow POST requests + + if ($_SERVER['REQUEST_METHOD'] != 'POST') { + $this->clientError(_('This action only accepts POST requests.')); + return false; + } + + // CSRF protection + + $token = $this->trimmed('token'); + + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token.'. + ' Try again, please.')); + return false; + } + + $tagger_arg = $this->trimmed('tagger'); + $tag_arg = $this->trimmed('tag'); + + $id = intval($this->arg('id')); + if ($id) { + $this->peopletag = Profile_list::staticGet('id', $id); + } else { + $this->clientError(_('No ID given.'), 404); + return false; + } + + if (!$this->peopletag || $this->peopletag->private) { + $this->clientError(_('No such peopletag.'), 404); + return false; + } + + $this->tagger = Profile::staticGet('id', $this->peopletag->tagger); + + return true; + } + + /** + * Handle the request + * + * On POST, add the current user to the group + * + * @param array $args unused + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + $cur = common_current_user(); + + Profile_tag_subscription::remove($this->peopletag, $cur); + + if ($this->boolean('ajax')) { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + $this->element('title', null, sprintf(_('%1$s unsubscribed to peopletag %2$s by %3$s'), + $cur->nickname, + $this->peopletag->tag, + $this->tagger->nickname)); + $this->elementEnd('head'); + $this->elementStart('body'); + $lf = new SubscribePeopletagForm($this, $this->peopletag); + $lf->show(); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + if (common_get_returnto()) { + common_redirect(common_get_returnto(), 303); + return true; + } + common_redirect(common_local_url('peopletagsbyuser', + array('nickname' => $this->tagger->nickname)), + 303); + } + } +} diff --git a/lib/action.php b/lib/action.php index 31e52dfcf2..80b3176253 100644 --- a/lib/action.php +++ b/lib/action.php @@ -291,6 +291,8 @@ class Action extends HTMLOutputter // lawsuit $this->script('jquery.cookie.min.js'); $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/json2.min.js').'"); }'); $this->script('jquery.joverlay.min.js'); + $this->inlineScript('function _loadTagInput(init) { $.getScript("'.common_path('js/jquery.timers.js'). '"); $.getScript("'.common_path('js/jquery.tagInput.js').'", init); } var _peopletagAC = "' . common_local_url('peopletagautocomplete') . '";'); + Event::handle('EndShowJQueryScripts', array($this)); } if (Event::handle('StartShowStatusNetScripts', array($this)) && diff --git a/lib/router.php b/lib/router.php index ee1e4cd849..7f17f2d0a5 100644 --- a/lib/router.php +++ b/lib/router.php @@ -227,7 +227,9 @@ class Router $m->connect('main/sup/:seconds', array('action' => 'sup'), array('seconds' => '[0-9]+')); - $m->connect('main/tagother/:id', array('action' => 'tagother')); + $m->connect('main/tagprofile', array('action' => 'tagprofile')); + $m->connect('main/tagprofile/:id', array('action' => 'tagprofile'), + array('id' => '[0-9]+')); $m->connect('main/oembed', array('action' => 'oembed')); @@ -355,10 +357,6 @@ class Router array('action' => 'tag'), array('tag' => self::REGEX_TAG)); - $m->connect('peopletag/:tag', - array('action' => 'peopletag'), - array('tag' => self::REGEX_TAG)); - // groups $m->connect('group/new', array('action' => 'newgroup')); @@ -959,6 +957,76 @@ class Router array('nickname' => Nickname::DISPLAY_FMT)); } + // people tags + + $m->connect('peopletags', array('action' => 'publicpeopletagcloud')); + + $m->connect('peopletag/:tag', array('action' => 'peopletag', + 'tag' => self::REGEX_TAG)); + + $m->connect('selftag/:tag', array('action' => 'selftag', + 'tag' => self::REGEX_TAG)); + + $m->connect('main/addpeopletag', array('action' => 'addpeopletag')); + + $m->connect('main/removepeopletag', array('action' => 'removepeopletag')); + + $m->connect('main/profilecompletion', array('action' => 'profilecompletion')); + + $m->connect('main/peopletagautocomplete', array('action' => 'peopletagautocomplete')); + + $m->connect(':nickname/peopletags', + array('action' => 'peopletagsbyuser', + 'nickname' => Nickname::DISPLAY_FMT)); + + $m->connect(':nickname/peopletags/private', + array('action' => 'peopletagsbyuser', + 'nickname' => Nickname::DISPLAY_FMT, + 'private' => 1)); + + $m->connect(':nickname/peopletags/public', + array('action' => 'peopletagsbyuser', + 'nickname' => Nickname::DISPLAY_FMT, + 'public' => 1)); + + $m->connect(':nickname/othertags', + array('action' => 'peopletagsforuser', + 'nickname' => Nickname::DISPLAY_FMT)); + + $m->connect(':nickname/peopletagsubscriptions', + array('action' => 'peopletagsubscriptions', + 'nickname' => Nickname::DISPLAY_FMT)); + + $m->connect(':tagger/all/:tag/subscribers', + array('action' => 'peopletagsubscribers', + 'tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG)); + + $m->connect(':tagger/all/:tag/tagged', + array('action' => 'peopletagged', + 'tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG)); + + $m->connect(':tagger/all/:tag/edit', + array('action' => 'editpeopletag', + 'tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG)); + + foreach(array('subscribe', 'unsubscribe') as $v) { + $m->connect('peopletag/:id/'.$v, + array('action' => $v.'peopletag', + 'id' => '[0-9]{1,64}')); + } + $m->connect('user/:tagger_id/profiletag/:id/id', + array('action' => 'profiletagbyid', + 'tagger_id' => '[0-9]+', + 'id' => '[0-9]+')); + + $m->connect(':tagger/all/:tag', + array('action' => 'showprofiletag', + 'tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG)); + foreach (array('subscriptions', 'subscribers') as $a) { $m->connect(':nickname/'.$a.'/:tag', array('action' => $a), From b372ed721d83dce3ef65ae03ca7d59d13cf3a5d2 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Mon, 7 Mar 2011 00:44:21 +0530 Subject: [PATCH 015/726] styling for people tag UI --- js/jquery.tagInput.js | 381 ++++++++++++++++++++++++++++++++++ js/jquery.timers.js | 138 ++++++++++++ js/util.js | 126 +++++++++++ js/util.min.js | 2 +- theme/base/css/display.css | 175 ++++++++++++++-- theme/default/css/display.css | 65 +++++- 6 files changed, 867 insertions(+), 20 deletions(-) create mode 100644 js/jquery.tagInput.js create mode 100644 js/jquery.timers.js diff --git a/js/jquery.tagInput.js b/js/jquery.tagInput.js new file mode 100644 index 0000000000..8ed4058fb2 --- /dev/null +++ b/js/jquery.tagInput.js @@ -0,0 +1,381 @@ +/* + Copyright (c) 2009 Open Lab, http://www.open-lab.com/ + Written by Roberto Bicchierai http://roberto.open-lab.com. + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +/** + * options.tags an object array [{tag:"tag1",freq:1},{tag:"tag2",freq:2}, {tag:"tag3",freq:3},{tag:"tag4",freq:4} ]. + * options.jsonUrl an url returning a json object array in the same format of options.tag. The url will be called with + * "search" parameter to be used server side to filter results + * option.autoFilter true/false default=true when active show only matching tags, "false" should be used for server-side filtering + * option.autoStart true/false default=false when active dropdown will appear entering field, otherwise when typing + * options.sortBy "frequency"|"tag"|"none" default="tag" + * options.tagSeparator default="," any separator char as space, comma, semicolumn + * options.boldify true/false default trrue boldify the matching part of tag in dropdown + * + * options.suggestedTags callback an object array like ["sugtag1","sugtag2","sugtag3"] + * options.suggestedTagsPlaceHolder jquery proxy for suggested tag placeholder. When placeholder is supplied (hence unique), tagField should be applied on a single input + * (something like $("#myTagFiled").tagField(...) will works fine: $(":text").tagField(...) probably not!) + */ + +if (typeof(String.prototype.trim) == "undefined"){ + String.prototype.trim = function () { + return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); + }; +} + + + +jQuery.fn.tagInput = function(options) { + // -------------------------- start default option values -------------------------- + if (!options.tags && !options.jsonUrl) { + options.tags = [ { tag:"tag1", freq:1 }, { tag:"tag2", freq:2 }, { tag:"tag3", freq:3 }, { tag:"tag4", freq:4 } ]; + } + + if (typeof(options.tagSeparator) == "undefined") + options.tagSeparator = ","; + + if (typeof(options.autoFilter) == "undefined") + options.autoFilter = true; + + if (typeof(options.autoStart) == "undefined") + options.autoStart = false; + + if (typeof(options.boldify) == "undefined") + options.boldify = true; + + if (typeof(options.animate) == "undefined") + options.animate = true; + + if (typeof(options.animate) != "function") { + options._animate = options.animate; + options.animate = function(show, el, cb) { + var func = (options._animate) ? (show ? 'fadeIn' : 'fadeOut') : (show ? 'show' : 'hide'); + el[func](cb); + } + } + + if (typeof(options.sortBy) == "undefined") + options.sortBy = "tag"; + + if (typeof(options.sortBy) == "string") { + options._sortBy = options.sortBy; + options.sortBy = function(obj) { return obj[options._sortBy]; } + } + + if (typeof(options.formatLine) == "undefined") + options.formatLine = function (i, obj, search, matches) { + var tag = obj.tag; + if (options.boldify && matches) { + tag = "" + tag.substring(0, search.length) + "" + tag.substring(search.length); + } + + var line = $("
"); + line.append("
" + tag + "
"); + if (obj.freq) + line.append("
" + obj.freq + "
"); + return line; + } + + if (typeof(options.formatValue == "undefined")) + options.formatValue = function (obj, i) { + return obj.tag; + } + // -------------------------- end default option values -------------------------- + + + this.each(function() { + + var theInput = $(this); + var theDiv; + + theInput.addClass("tagInput"); + theInput.tagOptions=options; + theInput.attr('autocomplete', 'off'); + + var suggestedTagsPlaceHolder=options.suggestedTagsPlaceHolder; + //create suggested tags place if the case + if (options.suggestedTags){ + if (!suggestedTagsPlaceHolder){ + //create a placeholder + var stl=$("
suggested tags:
"); + suggestedTagsPlaceHolder=stl.find(".tagInputSuggestedTagList"); + theInput.after(stl); + } + + //fill with suggestions + for (var tag in options.suggestedTags) { + suggestedTagsPlaceHolder.append($("" + options.suggestedTags[tag] + "")); + } + + // bind click on suggestion tags + suggestedTagsPlaceHolder.find(".tag").click(function() { + var element = $(this); + var val = theInput.val(); + var tag = element.text(); + + //check if already present + var re = new RegExp(tag + "\\b","g"); + if (containsTag(val, tag)) { + val = val.replace(re, ""); //remove all the tag + element.removeClass("tagUsed"); + } else { + val = val + options.tagSeparator + tag; + element.addClass("tagUsed"); + } + theInput.val(refurbishTags(val)); +// selectSuggTagFromInput(); + + }); + + } + + + // -------------------------- INPUT FOCUS -------------------------- + var tagInputFocus = function () { + theDiv = $("#__tagInputDiv"); + // check if the result box exists + if (theDiv.size() <= 0) { + //create the div + theDiv = $(""); + theInput.after(theDiv); + theDiv.css({left:theInput.position().left}); + } + if (options.autoStart) + tagInputRefreshDiv(theInput, theDiv); + }; + + + // -------------------------- INPUT BLUR -------------------------- + var tagInputBlur = function () { + // reformat string + theDiv = $("#__tagInputDiv"); + theInput.val(refurbishTags(theInput.val())); + + options.animate(0, theDiv, function() { + theDiv.remove(); + }); + }; + + + // -------------------------- INPUT KEYBOARD -------------------------- + var tagInputKey = function (e) { + var rows = theDiv.find("div.tagInputLine"); + var rowNum = rows.index(theDiv.find("div.tagInputSel")); + + var ret = true; + switch (e.which) { + case 38: //up arrow + rowNum = (rowNum < 1 ? 0 : rowNum - 1 ); + tagInputHLSCR(rows.eq(rowNum), true); + break; + + case 40: //down arrow + rowNum = (rowNum < rows.size() - 1 ? rowNum + 1 : rows.size() - 1 ); + tagInputHLSCR(rows.eq(rowNum), false); + break; + + case 9: //tab + case 13: //enter + if (theDiv.is(":visible")){ + var theRow = rows.eq(rowNum); + tagInputClickRow(theRow); + ret = false; + } + break; + + case 27: //esc + options.animate(0, theDiv); + break; + + default: + $(document).stopTime("tagInputRefresh"); + $(document).oneTime(400, "tagInputRefresh", function() { + tagInputRefreshDiv(); + }); + break; + } + return ret; + }; + + + // -------------------------- TAG DIV HIGHLIGHT AND SCROLL -------------------------- + var tagInputHLSCR = function(theRowJQ, isUp) { + if (theRowJQ.size() > 0) { + var div = theDiv.get(0); + var theRow = theRowJQ.get(0); + if (isUp) { + if (theDiv.scrollTop() > theRow.offsetTop) { + theDiv.scrollTop(theRow.offsetTop); + } + } else { + if ((theRow.offsetTop + theRow.offsetHeight) > (div.scrollTop + div.offsetHeight)) { + div.scrollTop = theRow.offsetTop + theRow.offsetHeight - div.offsetHeight; + } + } + theDiv.find("div.tagInputSel").removeClass("tagInputSel"); + theRowJQ.addClass("tagInputSel"); + } + }; + + + // -------------------------- TAG LINE CLICK -------------------------- + var tagInputClickRow = function(theRow) { + + var lastComma = theInput.val().lastIndexOf(options.tagSeparator); + var sep= lastComma<=0? (""):(options.tagSeparator+ (options.tagSeparator==" "?"":" ")); + var newVal = (theInput.val().substr(0, lastComma) + sep + theRow.attr('id').replace('val-','')).trim(); + theInput.val(newVal); + theDiv.hide(); + $().oneTime(200, function() { + theInput.focus(); + }); + }; + + + // -------------------------- REFILL TAG BOX -------------------------- + var tagInputRefreshDiv = function () { + + var lastComma = theInput.val().lastIndexOf(options.tagSeparator); + var search = theInput.val().substr(lastComma + 1).trim(); + + + // -------------------------- FILLING THE DIV -------------------------- + var fillingCallbak = function(tags) { + tags = tags.sort(function (a, b) { + if (options.sortBy(a) < options.sortBy(b)) + return 1; + if (options.sortBy(a) > options.sortBy(b)) + return -1; + return 0; + }); + + for (var i in tags) { + tags[i]._val = options.formatValue(tags[i], i); + var el = tags[i]; + var matches = el._val.toLocaleLowerCase().indexOf(search.toLocaleLowerCase()) == 0; + if (!options.autoFilter || matches) { + var line = $(options.formatLine(i, el, search, matches)); + if (!line.is('.tagInputLine')) + line = $("
").append(line); + line.attr('id', 'val-' + el._val); + theDiv.append(line); + } + } + if (theDiv.html()!=""){ + options.animate(true, theDiv); + } + + theDiv.find("div:first").addClass("tagInputSel"); + theDiv.find("div.tagInputLine").bind("click", function() { + tagInputClickRow($(this)); + }); + }; + + + if (search != "" || options.autoStart) { + theDiv.html(""); + + if (options.tags) + fillingCallbak(options.tags); + else{ + var data = {search:search}; + $.getJSON(options.jsonUrl, data, fillingCallbak ); + } + } else { + options.animate(false, theDiv); + } + }; + + // -------------------------- CLEAN THE TAG LIST FROM EXTRA SPACES, DOUBLE COMMAS ETC. -------------------------- + var refurbishTags = function (tagString) { + var splitted = tagString.split(options.tagSeparator); + var res = ""; + var first = true; + for (var i = 0; i < splitted.length; i++) { + if (splitted[i].trim() != "") { + if (first) { + first = false; + res = res + splitted[i].trim(); + } else { + res = res + options.tagSeparator+ (options.tagSeparator==" "?"":" ") + splitted[i].trim(); + } + } + } + return( res); + }; + + // -------------------------- TEST IF TAG IS PRESENT -------------------------- + var containsTag=function (tagString,tag){ + var splitted = tagString.split(options.tagSeparator); + var res=""; + var found=false; + tag=tag.trim(); + for(i = 0; i < splitted.length; i++){ + var testTag=splitted[i].trim(); + if (testTag==tag){ + found=true; + break; + } + } + return found; + }; + + + // -------------------------- SELECT TAGS BASING ON USER INPUT -------------------------- + var delayedSelectTagFromInput= function(){ + var element = $(this); + $().stopTime("suggTagRefresh"); + $().oneTime(200, "suggTagRefresh", function() { + selectSuggTagFromInput(); + }); + + }; + + var selectSuggTagFromInput = function () { + var val = theInput.val(); + suggestedTagsPlaceHolder.find(".tag").each(function(){ + var el = $(this); + var tag=el.text(); + + //check if already present + if (containsTag(val,tag)) { + el.addClass("tagUsed"); + } else { + el.removeClass("tagUsed"); + } + }); + + }; + + + + + // -------------------------- INPUT BINDINGS -------------------------- + $(this).bind("focus", tagInputFocus).bind("blur", tagInputBlur).bind("keydown", tagInputKey); + if (options.suggestedTags) + $(this).bind("keyup",delayedSelectTagFromInput) ; + + + }); + return this; +}; + + diff --git a/js/jquery.timers.js b/js/jquery.timers.js new file mode 100644 index 0000000000..bb51157d40 --- /dev/null +++ b/js/jquery.timers.js @@ -0,0 +1,138 @@ +/** + * jQuery.timers - Timer abstractions for jQuery + * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com) + * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/). + * Date: 2009/10/16 + * + * @author Blair Mitchelmore + * @version 1.2 + * + **/ + +jQuery.fn.extend({ + everyTime: function(interval, label, fn, times) { + return this.each(function() { + jQuery.timer.add(this, interval, label, fn, times); + }); + }, + oneTime: function(interval, label, fn) { + return this.each(function() { + jQuery.timer.add(this, interval, label, fn, 1); + }); + }, + stopTime: function(label, fn) { + return this.each(function() { + jQuery.timer.remove(this, label, fn); + }); + } +}); + +jQuery.extend({ + timer: { + global: [], + guid: 1, + dataKey: "jQuery.timer", + regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/, + powers: { + // Yeah this is major overkill... + 'ms': 1, + 'cs': 10, + 'ds': 100, + 's': 1000, + 'das': 10000, + 'hs': 100000, + 'ks': 1000000 + }, + timeParse: function(value) { + if (value == undefined || value == null) + return null; + var result = this.regex.exec(jQuery.trim(value.toString())); + if (result[2]) { + var num = parseFloat(result[1]); + var mult = this.powers[result[2]] || 1; + return num * mult; + } else { + return value; + } + }, + add: function(element, interval, label, fn, times) { + var counter = 0; + + if (jQuery.isFunction(label)) { + if (!times) + times = fn; + fn = label; + label = interval; + } + + interval = jQuery.timer.timeParse(interval); + + if (typeof interval != 'number' || isNaN(interval) || interval < 0) + return; + + if (typeof times != 'number' || isNaN(times) || times < 0) + times = 0; + + times = times || 0; + + var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {}); + + if (!timers[label]) + timers[label] = {}; + + fn.timerID = fn.timerID || this.guid++; + + var handler = function() { + if ((++counter > times && times !== 0) || fn.call(element, counter) === false) + jQuery.timer.remove(element, label, fn); + }; + + handler.timerID = fn.timerID; + + if (!timers[label][fn.timerID]) + timers[label][fn.timerID] = window.setInterval(handler,interval); + + this.global.push( element ); + + }, + remove: function(element, label, fn) { + var timers = jQuery.data(element, this.dataKey), ret; + + if ( timers ) { + + if (!label) { + for ( label in timers ) + this.remove(element, label, fn); + } else if ( timers[label] ) { + if ( fn ) { + if ( fn.timerID ) { + window.clearInterval(timers[label][fn.timerID]); + delete timers[label][fn.timerID]; + } + } else { + for ( var fn in timers[label] ) { + window.clearInterval(timers[label][fn]); + delete timers[label][fn]; + } + } + + for ( ret in timers[label] ) break; + if ( !ret ) { + ret = null; + delete timers[label]; + } + } + + for ( ret in timers ) break; + if ( !ret ) + jQuery.removeData(element, this.dataKey); + } + } + } +}); + +jQuery(window).bind("unload", function() { + jQuery.each(jQuery.timer.global, function(index, item) { + jQuery.timer.remove(item); + }); +}); diff --git a/js/util.js b/js/util.js index cc94c5ced7..84943e8b24 100644 --- a/js/util.js +++ b/js/util.js @@ -450,6 +450,74 @@ var SN = { // StatusNet }); }, + FormProfileSearchXHR: function(form) { + $.ajax({ + type: 'POST', + dataType: 'xml', + url: form.attr('action'), + data: form.serialize() + '&ajax=1', + beforeSend: function(xhr) { + form + .addClass(SN.C.S.Processing) + .find('.submit') + .addClass(SN.C.S.Disabled) + .attr(SN.C.S.Disabled, SN.C.S.Disabled); + }, + error: function (xhr, textStatus, errorThrown) { + alert(errorThrown || textStatus); + }, + success: function(data, textStatus) { + var results_placeholder = $('#profile_search_results'); + if (typeof($('ul', data)[0]) != 'undefined') { + var list = document._importNode($('ul', data)[0], true); + results_placeholder.replaceWith(list); + } + else { + var _error = $('
  • ').append(document._importNode($('p', data)[0], true)); + results_placeholder.html(_error); + } + form + .removeClass(SN.C.S.Processing) + .find('.submit') + .removeClass(SN.C.S.Disabled) + .attr(SN.C.S.Disabled, false); + } + }); + }, + + FormPeopletagsXHR: function(form) { + $.ajax({ + type: 'POST', + dataType: 'xml', + url: form.attr('action'), + data: form.serialize() + '&ajax=1', + beforeSend: function(xhr) { + form.addClass(SN.C.S.Processing) + .find('.submit') + .addClass(SN.C.S.Disabled) + .attr(SN.C.S.Disabled, SN.C.S.Disabled); + }, + error: function (xhr, textStatus, errorThrown) { + alert(errorThrown || textStatus); + }, + success: function(data, textStatus) { + var results_placeholder = form.parents('.entity_tags'); + if (typeof($('.entity_tags', data)[0]) != 'undefined') { + var tags = document._importNode($('.entity_tags', data)[0], true); + $(tags).find('.editable').append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
    ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
    ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("title");h.removeAttr("title");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
    ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change()});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".entry-title .author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("."+SN.C.S.FormNotice).each(function(){var a=$(this);SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a)})}},Notices:function(){if($("body.user_in").length>0){SN.U.NoticeFavor();SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})}}};$(document).ready(function(){SN.Init.UploadForms();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c0){for(var c=0,b=e.childNodes.length;c0){var j=c.pop();j()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(j){if(d()){return true}h(j);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(k,n,o){var m=this;if(!g(function(){m.getCurrentPosition(k,n,o)})){return}if(google.loader.ClientLocation){var l=google.loader.ClientLocation;var j={coords:{latitude:l.latitude,longitude:l.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:l.address.city,country:l.address.country,country_code:l.address.country_code,region:l.address.region},timestamp:new Date()};k(j);this.lastPosition=j}else{if(n==="function"){n({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(j,l,m){this.getCurrentPosition(j,l,m);var k=this;var n=setInterval(function(){k.getCurrentPosition(j,l,m)},10000);return n},clearWatch:function(j){clearInterval(j)},getPermission:function(l,j,k){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()}; \ No newline at end of file +var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307]},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find("[name=status_textarea]");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find("[name=status_textarea]").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{a.replaceWith(document._importNode($("p",b)[0],true))}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('

    ').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find("[name=status_textarea]").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(i,f){a();var n=$("#"+SN.C.S.Error,i);if(n.length>0){c("error",n.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var m=document._importNode($("li",i)[0],true);var k=$("#notices_primary .notices:first");var l=b.closest("li.notice-reply");if(l.length>0){var e=$(m).attr("id");if($("#"+e).length==0){var j=l.closest("li.notice");l.replaceWith(m);SN.U.NoticeInlineReplyPlaceholder(j)}else{l.remove()}}else{if(k.length>0&&SN.U.belongsOnTimeline(m)){if($("#"+m.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('
      ')}$($(g+" .notices")[0]).append(m)}else{k.prepend(m)}$("#"+m.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+m.id));SN.U.NoticeReplyTo($("#"+m.id))}}else{c("success",$("title",i).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},FormProfileSearchXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:a.attr("action"),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(d,f){var b=$("#profile_search_results");if(typeof($("ul",d)[0])!="undefined"){var c=document._importNode($("ul",d)[0],true);b.replaceWith(c)}else{var e=$("
    • ").append(document._importNode($("p",d)[0],true));b.html(e)}a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,false)}})},FormPeopletagsXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:a.attr("action"),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(d,e){var c=a.parents(".entity_tags");if(typeof($(".entity_tags",d)[0])!="undefined"){var b=document._importNode($(".entity_tags",d)[0],true);$(b).find(".editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
      ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
      ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("title");h.removeAttr("title");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
      ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change()});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".entry-title .author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("."+SN.C.S.FormNotice).each(function(){var a=$(this);SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a)})}},Notices:function(){if($("body.user_in").length>0){SN.U.NoticeFavor();SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(){$(".form_tag_user #tags").tagInput({tags:SN.C.PtagACData,tagSeparator:" ",animate:false,formatLine:function(d,g,c,f){var a=""+g.tag.substring(0,c.length)+""+g.tag.substring(c.length);var b=$("
      ").addClass("mode-"+g.mode);b.append($("
      "+a+" "+g.mode+"
      "));if(g.freq){b.append("
      "+g.freq+"
      ")}return b}})},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
      ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
      ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("data-api");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
      ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var j=$(this);if(j.has(g.target).length==0){var h=j.find(".notice_data-text:first");var i=$.trim(h.val());if(i==""||i==h.data("initialText")){var e=j.closest("li.notice");j.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false});$("form.ajax input[type=submit]").live("click",function(){var a=$(this);var b=a.closest("form");b.find(".hidden-submit-button").remove();$('').attr("name",a.attr("name")).val(a.val()).appendTo(b)})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c0){for(var c=0,b=e.childNodes.length;c0){var j=c.pop();j()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(j){if(d()){return true}h(j);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(k,n,o){var m=this;if(!g(function(){m.getCurrentPosition(k,n,o)})){return}if(google.loader.ClientLocation){var l=google.loader.ClientLocation;var j={coords:{latitude:l.latitude,longitude:l.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:l.address.city,country:l.address.country,country_code:l.address.country_code,region:l.address.region},timestamp:new Date()};k(j);this.lastPosition=j}else{if(n==="function"){n({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(j,l,m){this.getCurrentPosition(j,l,m);var k=this;var n=setInterval(function(){k.getCurrentPosition(j,l,m)},10000);return n},clearWatch:function(j){clearInterval(j)},getPermission:function(l,j,k){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()}; \ No newline at end of file +var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find(".notice_data-text:first");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(d,e,c){var b=null;if(d.responseXML){b=$("#error",d.responseXML).text()}alert(b||c||e);a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled)},success:function(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{if(typeof($("p",b)[0])!="undefined"){a.replaceWith(document._importNode($("p",b)[0],true))}else{alert("Unknown error.")}}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('

      ').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(i,f){a();var o=$("#"+SN.C.S.Error,i);if(o.length>0){c("error",o.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var n=document._importNode($("li",i)[0],true);var j=$("#notices_primary .notices:first");var l=b.closest("li.notice-reply");if(l.length>0){var k=b.closest(".threaded-replies");var m=k.find(".notice-reply-placeholder");l.remove();var e=$(n).attr("id");if($("#"+e).length==0){$(n).insertBefore(m)}else{}m.show()}else{if(j.length>0&&SN.U.belongsOnTimeline(n)){if($("#"+n.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('
        ')}$($(g+" .notices")[0]).append(n)}else{j.prepend(n)}$("#"+n.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+n.id));SN.U.switchInputFormTab("placeholder")}}else{c("success",$("title",i).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",true).attr("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){$("#content .notice_reply").live("click",function(c){c.preventDefault();var b=$(this).closest("li.notice");var a=($(".author .nickname",b).length>0)?$($(".author .nickname",b)[0]):$(".author .nickname.uid");SN.U.NoticeInlineReplyTrigger(b,"@"+a.text());return false})},NoticeReplyTo:function(a){},NoticeInlineReplyTrigger:function(i,j){var b=$($(".notice_id",i)[0]).text();var e=i;var f=i.closest(".notices");if(f.hasClass("threaded-replies")){e=f.closest(".notice")}else{f=$("ul.threaded-replies",i);if(f.length==0){f=$('
          ');i.append(f)}}var k=$(".notice-reply-form",f);var d=function(){k.find("input[name=inreplyto]").val(b);var n=k.find("textarea");if(n.length==0){throw"No textarea"}var m="";if(j){m=j+" "}n.val(m+n.val().replace(RegExp(m,"i"),""));n.data("initialText",$.trim(j+""));n.focus();if(n[0].setSelectionRange){var l=n.val().length;n[0].setSelectionRange(l,l)}};if(k.length>0){d()}else{var h=f.find("li.notice-reply-placeholder").hide();var g=$("li.notice-reply",f);if(g.length==0){g=$('
        • ');var c=function(l){var m=document._importNode(l,true);g.append(m);f.append(g);var n=k=$(m);SN.Init.NoticeFormSetup(n);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(l,n,m){c($("form",l)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");var c=$('
        • ');c.find("input").val(SN.msg("reply_placeholder"));a.append(c)},NoticeInlineReplySetup:function(){$("li.notice-reply-placeholder input").live("focus",function(){var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false});$("li.notice-reply-comments a").live("click",function(){var a=$(this).attr("href");var b=$(this).closest(".threaded-replies");$.get(a,{ajax:1},function(d,f,e){var c=$(".threaded-replies",d);if(c.length){b.replaceWith(document._importNode(c[0],true))}});return false})},NoticeRepeat:function(){$(".form_repeat").live("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.bind("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
          ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
          ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("data-api");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
          ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var j=$(this);if(j.has(g.target).length==0){var h=j.find(".notice_data-text:first");var i=$.trim(h.val());if(i==""||i==h.data("initialText")){var e=j.closest("li.notice");j.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false});$("form.ajax input[type=submit]").live("click",function(){var a=$(this);var b=a.closest("form");b.find(".hidden-submit-button").remove();$('').attr("name",a.attr("name")).val(a.val()).appendTo(b)})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})},CheckBoxes:function(){$("span[class='checkbox-wrapper']").addClass("unchecked");$(".checkbox-wrapper").click(function(){if($(this).children("input").attr("checked")){$(this).children("input").attr({checked:""});$(this).removeClass("checked");$(this).addClass("unchecked");$(this).children("label").text("Private?")}else{$(this).children("input").attr({checked:"checked"});$(this).removeClass("unchecked");$(this).addClass("checked");$(this).children("label").text("Private")}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();SN.Init.CheckBoxes();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}}); \ No newline at end of file From 6954cb35082737f3da87f3b8eadab8e91d1e6d4c Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 5 Apr 2011 09:12:54 -0700 Subject: [PATCH 184/726] QnA - Add ToSelector to new question --- plugins/QnA/actions/qnanewquestion.php | 9 ++++++++- plugins/QnA/lib/qnanewquestionform.php | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/QnA/actions/qnanewquestion.php b/plugins/QnA/actions/qnanewquestion.php index 561b11575a..3399c5eda8 100644 --- a/plugins/QnA/actions/qnanewquestion.php +++ b/plugins/QnA/actions/qnanewquestion.php @@ -130,10 +130,17 @@ class QnanewquestionAction extends Action throw new ClientException(_m('Question must have a title.')); } + // Notice options + $options = array(); + + // Does the heavy-lifting for getting "To:" information + ToSelector::fillOptions($this, $options); + $saved = QnA_Question::saveNew( $this->user->getProfile(), $this->title, - $this->description + $this->description, + $options ); } catch (ClientException $ce) { $this->error = $ce->getMessage(); diff --git a/plugins/QnA/lib/qnanewquestionform.php b/plugins/QnA/lib/qnanewquestionform.php index 114e6199a1..1def13a8c4 100644 --- a/plugins/QnA/lib/qnanewquestionform.php +++ b/plugins/QnA/lib/qnanewquestionform.php @@ -121,6 +121,12 @@ class QnanewquestionForm extends Form $this->unli(); $this->out->elementEnd('ul'); + $toWidget = new ToSelector( + $this->out, + common_current_user(), + null + ); + $toWidget->show(); $this->out->elementEnd('fieldset'); } From 6a7f3501e5bbb4b8fa5c768edd90e366b9bc04d1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 12:27:07 -0400 Subject: [PATCH 185/726] forgot other two files while minifying --- js/util.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/util.min.js b/js/util.min.js index 4689c6209a..6143645e44 100644 --- a/js/util.min.js +++ b/js/util.min.js @@ -1 +1 @@ -var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find(".notice_data-text:first");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(d,e,c){var b=null;if(d.responseXML){b=$("#error",d.responseXML).text()}alert(b||c||e);a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled)},success:function(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{if(typeof($("p",b)[0])!="undefined"){a.replaceWith(document._importNode($("p",b)[0],true))}else{alert("Unknown error.")}}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('

          ').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(i,f){a();var o=$("#"+SN.C.S.Error,i);if(o.length>0){c("error",o.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var n=document._importNode($("li",i)[0],true);var j=$("#notices_primary .notices:first");var l=b.closest("li.notice-reply");if(l.length>0){var k=b.closest(".threaded-replies");var m=k.find(".notice-reply-placeholder");l.remove();var e=$(n).attr("id");if($("#"+e).length==0){$(n).insertBefore(m)}else{}m.show()}else{if(j.length>0&&SN.U.belongsOnTimeline(n)){if($("#"+n.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('
            ')}$($(g+" .notices")[0]).append(n)}else{j.prepend(n)}$("#"+n.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+n.id));SN.U.switchInputFormTab("placeholder")}}else{c("success",$("title",i).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",true).attr("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){$("#content .notice_reply").live("click",function(c){c.preventDefault();var b=$(this).closest("li.notice");var a=($(".author .nickname",b).length>0)?$($(".author .nickname",b)[0]):$(".author .nickname.uid");SN.U.NoticeInlineReplyTrigger(b,"@"+a.text());return false})},NoticeReplyTo:function(a){},NoticeInlineReplyTrigger:function(i,j){var b=$($(".notice_id",i)[0]).text();var e=i;var f=i.closest(".notices");if(f.hasClass("threaded-replies")){e=f.closest(".notice")}else{f=$("ul.threaded-replies",i);if(f.length==0){f=$('
              ');i.append(f)}}var k=$(".notice-reply-form",f);var d=function(){k.find("input[name=inreplyto]").val(b);var n=k.find("textarea");if(n.length==0){throw"No textarea"}var m="";if(j){m=j+" "}n.val(m+n.val().replace(RegExp(m,"i"),""));n.data("initialText",$.trim(j+""));n.focus();if(n[0].setSelectionRange){var l=n.val().length;n[0].setSelectionRange(l,l)}};if(k.length>0){d()}else{var h=f.find("li.notice-reply-placeholder").hide();var g=$("li.notice-reply",f);if(g.length==0){g=$('
            • ');var c=function(l){var m=document._importNode(l,true);g.append(m);f.append(g);var n=k=$(m);SN.Init.NoticeFormSetup(n);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(l,n,m){c($("form",l)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");var c=$('
            • ');c.find("input").val(SN.msg("reply_placeholder"));a.append(c)},NoticeInlineReplySetup:function(){$("li.notice-reply-placeholder input").live("focus",function(){var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false});$("li.notice-reply-comments a").live("click",function(){var a=$(this).attr("href");var b=$(this).closest(".threaded-replies");$.get(a,{ajax:1},function(d,f,e){var c=$(".threaded-replies",d);if(c.length){b.replaceWith(document._importNode(c[0],true))}});return false})},NoticeRepeat:function(){$(".form_repeat").live("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.bind("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
              ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
              ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("data-api");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
              ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var j=$(this);if(j.has(g.target).length==0){var h=j.find(".notice_data-text:first");var i=$.trim(h.val());if(i==""||i==h.data("initialText")){var e=j.closest("li.notice");j.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false});$("form.ajax input[type=submit]").live("click",function(){var a=$(this);var b=a.closest("form");b.find(".hidden-submit-button").remove();$('').attr("name",a.attr("name")).val(a.val()).appendTo(b)})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})},CheckBoxes:function(){$("span[class='checkbox-wrapper']").addClass("unchecked");$(".checkbox-wrapper").click(function(){if($(this).children("input").attr("checked")){$(this).children("input").attr({checked:""});$(this).removeClass("checked");$(this).addClass("unchecked");$(this).children("label").text("Private?")}else{$(this).children("input").attr({checked:"checked"});$(this).removeClass("unchecked");$(this).addClass("checked");$(this).children("label").text("Private")}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();SN.Init.CheckBoxes();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}}); \ No newline at end of file +var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find(".notice_data-text:first");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(d,e,c){var b=null;if(d.responseXML){b=$("#error",d.responseXML).text()}alert(b||c||e);a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled)},success:function(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{if(typeof($("p",b)[0])!="undefined"){a.replaceWith(document._importNode($("p",b)[0],true))}else{alert("Unknown error.")}}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('

              ').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(i,f){a();var o=$("#"+SN.C.S.Error,i);if(o.length>0){c("error",o.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var n=document._importNode($("li",i)[0],true);var j=$("#notices_primary .notices:first");var l=b.closest("li.notice-reply");if(l.length>0){var k=b.closest(".threaded-replies");var m=k.find(".notice-reply-placeholder");l.remove();var e=$(n).attr("id");if($("#"+e).length==0){$(n).insertBefore(m)}else{}m.show()}else{if(j.length>0&&SN.U.belongsOnTimeline(n)){if($("#"+n.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('
                ')}$($(g+" .notices")[0]).append(n)}else{j.prepend(n)}$("#"+n.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+n.id));SN.U.switchInputFormTab("placeholder")}}else{c("success",$("title",i).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",true).attr("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){$("#content .notice_reply").live("click",function(c){c.preventDefault();var b=$(this).closest("li.notice");var a=($(".author .nickname",b).length>0)?$($(".author .nickname",b)[0]):$(".author .nickname.uid");SN.U.NoticeInlineReplyTrigger(b,"@"+a.text());return false})},NoticeReplyTo:function(a){},NoticeInlineReplyTrigger:function(i,j){var b=$($(".notice_id",i)[0]).text();var e=i;var f=i.closest(".notices");if(f.hasClass("threaded-replies")){e=f.closest(".notice")}else{f=$("ul.threaded-replies",i);if(f.length==0){f=$('
                  ');i.append(f)}}var k=$(".notice-reply-form",f);var d=function(){k.find("input[name=inreplyto]").val(b);var n=k.find("textarea");if(n.length==0){throw"No textarea"}var m="";if(j){m=j+" "}n.val(m+n.val().replace(RegExp(m,"i"),""));n.data("initialText",$.trim(j+""));n.focus();if(n[0].setSelectionRange){var l=n.val().length;n[0].setSelectionRange(l,l)}};if(k.length>0){d()}else{var h=f.find("li.notice-reply-placeholder").hide();var g=$("li.notice-reply",f);if(g.length==0){g=$('
                • ');var c=function(l){var m=document._importNode(l,true);g.append(m);f.append(g);var n=k=$(m);SN.Init.NoticeFormSetup(n);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(l,n,m){c($("form",l)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");var c=$('
                • ');c.find("input").val(SN.msg("reply_placeholder"));a.append(c)},NoticeInlineReplySetup:function(){$("li.notice-reply-placeholder input").live("focus",function(){var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false});$("li.notice-reply-comments a").live("click",function(){var a=$(this).attr("href");var b=$(this).closest(".threaded-replies");$.get(a,{ajax:1},function(d,f,e){var c=$(".threaded-replies",d);if(c.length){b.replaceWith(document._importNode(c[0],true))}});return false})},NoticeRepeat:function(){$(".form_repeat").live("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.bind("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("data-api");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var j=$(this);if(j.has(g.target).length==0){var h=j.find(".notice_data-text:first");var i=$.trim(h.val());if(i==""||i==h.data("initialText")){var e=j.closest("li.notice");j.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){SN.U.NewDirectMessage()}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false});$("form.ajax input[type=submit]").live("click",function(){var a=$(this);var b=a.closest("form");b.find(".hidden-submit-button").remove();$('').attr("name",a.attr("name")).val(a.val()).appendTo(b)})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})},CheckBoxes:function(){$("span[class='checkbox-wrapper']").addClass("unchecked");$(".checkbox-wrapper").click(function(){if($(this).children("input").attr("checked")){$(this).children("input").attr({checked:""});$(this).removeClass("checked");$(this).addClass("unchecked");$(this).children("label").text("Private?")}else{$(this).children("input").attr({checked:"checked"});$(this).removeClass("unchecked");$(this).addClass("checked");$(this).children("label").text("Private")}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();SN.Init.CheckBoxes();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c0){for(var c=0,b=e.childNodes.length;c0){var j=c.pop();j()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(j){if(d()){return true}h(j);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(k,n,o){var m=this;if(!g(function(){m.getCurrentPosition(k,n,o)})){return}if(google.loader.ClientLocation){var l=google.loader.ClientLocation;var j={coords:{latitude:l.latitude,longitude:l.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:l.address.city,country:l.address.country,country_code:l.address.country_code,region:l.address.region},timestamp:new Date()};k(j);this.lastPosition=j}else{if(n==="function"){n({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(j,l,m){this.getCurrentPosition(j,l,m);var k=this;var n=setInterval(function(){k.getCurrentPosition(j,l,m)},10000);return n},clearWatch:function(j){clearInterval(j)},getPermission:function(l,j,k){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()}; \ No newline at end of file From 5bc6a8c614d371529972183fc75531cbeaa25585 Mon Sep 17 00:00:00 2001 From: Samantha Doherty Date: Tue, 5 Apr 2011 12:38:15 -0400 Subject: [PATCH 186/726] Style changes for privacy selectors and markers. --- lib/toselector.php | 4 +- theme/neo/README | 4 ++ theme/neo/css/display.css | 71 ++++++++++++++++++++++++++++++++- theme/neo/images/lock.png | Bin 0 -> 749 bytes theme/neo/images/lock_open.png | Bin 0 -> 727 bytes 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 theme/neo/images/lock.png create mode 100644 theme/neo/images/lock_open.png diff --git a/lib/toselector.php b/lib/toselector.php index 7234a603d8..bcbfe86ec9 100644 --- a/lib/toselector.php +++ b/lib/toselector.php @@ -118,10 +118,12 @@ class ToSelector extends Widget false, $default); + $this->out->elementStart('span', 'checkbox-wrapper'); $this->out->checkbox('notice_private', // TRANS: Checkbox label in widget for selecting potential addressees to mark the notice private. - _('Private'), + _('Private?'), $this->private); + $this->out->elementEnd('span'); } static function fillOptions($action, &$options) diff --git a/theme/neo/README b/theme/neo/README index 39d9e0f060..42e1b4763c 100644 --- a/theme/neo/README +++ b/theme/neo/README @@ -1,2 +1,6 @@ Default avatars are modified from an image by Francesco 'Architetto' Rollandin. http://www.openclipart.org/detail/34957 + +Icons by Mark James +http://www.famfamfam.com/lab/icons/silk/ +http://creativecommons.org/licenses/by/2.5/ Creative Commons Attribution 2.5 License diff --git a/theme/neo/css/display.css b/theme/neo/css/display.css index 5659ca3ae1..61258bfab6 100644 --- a/theme/neo/css/display.css +++ b/theme/neo/css/display.css @@ -286,7 +286,7 @@ address { padding-bottom: 15px; } -#input_form_status { +#input_form_status, #input_form_direct { padding-bottom: 45px; } @@ -333,6 +333,10 @@ address { font-size: 1.2em; } +#form_notice-direct.form_notice textarea { + width: 498px; +} + .form_notice label.notice_data-attach { top: 0px; right: 0px; @@ -355,6 +359,11 @@ address { z-index: 99; } +#form_notice-direct.form_notice .count { + top: 80px; + right: 10px; +} + .form_notice #notice_action-submit { position: absolute; top: 100%; @@ -397,6 +406,52 @@ address { margin-bottom: 10px !important; } +.to-selector { + padding-top: 15px; + z-index: 99; +} + +.form_settings label[for=notice_to] { + margin-left: 100px; + margin-right: 5px; +} + +.checkbox-wrapper { + padding: 2px; + clear: left; + display: block; + margin-left: 26%; +} + +.form_notice .checkbox-wrapper { + display: inline; + margin-left: 10px; +} + +.form_settings .checkbox-wrapper label.checkbox { + margin-left: 0px; + margin-top: 6px; + line-height: 1.2em; + left: -3px; +} + +.checkbox-wrapper #notice_private { + display:none; +} + +.checkbox-wrapper.unchecked label.checkbox { + padding-left: 20px; + background: url(../images/lock_open.png) no-repeat 0px 0px; + opacity: 0.6; +} + +.checkbox-wrapper.checked label.checkbox { + padding-left: 20px; + background: url(../images/lock.png) no-repeat 0px 0px; + color: red; + opacity: 1; +} + #aside_primary { width: 218px; float: left; @@ -1246,6 +1301,20 @@ table.profile_list tr.alt { filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FB6104', endColorstr='#fc8035',GradientType=0 ); } +/* Limited-scope specific styles */ + +.limited-scope .entry-content .timestamp { + padding-left: 20px; + position: relative; +} + +.limited-scope .entry-content .timestamp:before { + content: url(../images/lock.png); + position: absolute; + top: -2px; + left: 0px; +} + /* QnA specific styles */ #content .question .entry-title, #content .qna-full-question .entry-title { diff --git a/theme/neo/images/lock.png b/theme/neo/images/lock.png new file mode 100644 index 0000000000000000000000000000000000000000..2ebc4f6f9663e32cad77d67ef93ab8843dfea3c0 GIT binary patch literal 749 zcmVe|tv9>?g+k#9o0pTxd@;_sq{kwlU;^VvV*?BV8P@}BoaZTQUROpWV6|-M`|^n&)=+8tHo3*<<$NU zU`%V~ZF;?hBSYsjJ6%JzV}E(D{pOLqQklliUf9um_tGl-wty`y*p?eYNW56P>X@1s zZs7KrRZKtmV7Lqj^5Fgr7_`LjhdJK@ltF&O`j7?*NUM$KvmNGz)3WjM?V$vHlPT0AFyF?kLE<#HZabCSW3-oa*6;Z zrXD`Ulwd<^2glP%1Y1Kc1Ij%DU^=ME(jKf6APNlA$Uu;J4bVilQHSWX5uJ$9Zsp4M z0%!@LvyTxz=Z6stxlichODIY+yNGt%RM;m`>H4LOKLFs9Y%b5aUN|2|{0Zw|<_~i} fmXz*V19AKYarLKlJyH=-*k3W|aiVYC~e{STzB+=%NyKm^5w z3m4+bm8cXnzG}0Gw2c^Ol0K$0_ity0#@^}dhsl97GUJu9lkxh`Okt_0|=(|h`!tol*)tahk*i! zgS8GLCq{|Gd7N1T=a4u`0gM4BU}M^~w|L$b3WtyL{rO$Q?PPfL6z$J7;&2In&vryC zqT@6`g9u_Zg@Xt1vO7RIY-D-g8eo{1!oIz%ujUZ52IBq#JOI%e5ertc^kIf}?KOA? zx9*6-2qdQcN5WDRs@&WP6I?Nxm{No*quRTbIBKa{opLb zA%3`w)e+)sGB0CNfH Date: Tue, 5 Apr 2011 12:53:49 -0400 Subject: [PATCH 187/726] Revert "Paging fix for public timeline: drop replies from the stuff we pull in for the threaded web view." This reverts commit 880661de4e8fd6735e9eba57e059fca0c719666b. --- actions/public.php | 7 ++----- lib/publicnoticestream.php | 22 +++------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/actions/public.php b/actions/public.php index 1b6c14b2e6..b029407250 100644 --- a/actions/public.php +++ b/actions/public.php @@ -85,11 +85,8 @@ class PublicAction extends Action common_set_returnto($this->selfUrl()); - $stream = new PublicNoticeStream(PublicNoticeStream::THREADED); - $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, - NOTICES_PER_PAGE + 1, - 0, - 0); + $this->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); if (!$this->notice) { // TRANS: Server error displayed when a public timeline cannot be retrieved. diff --git a/lib/publicnoticestream.php b/lib/publicnoticestream.php index 08ac790fab..5c8d313d46 100644 --- a/lib/publicnoticestream.php +++ b/lib/publicnoticestream.php @@ -47,16 +47,10 @@ if (!defined('STATUSNET')) { class PublicNoticeStream extends ScopingNoticeStream { - const THREADED=true; - - /** - * - * @param boolean $threaded set to true to exclude replies, for later fetching - */ - function __construct($threaded=false) + function __construct() { - parent::__construct(new CachingNoticeStream(new RawPublicNoticeStream($threaded), - $threaded ? 'public:threaded' : 'public')); + parent::__construct(new CachingNoticeStream(new RawPublicNoticeStream(), + 'public')); } } @@ -73,13 +67,6 @@ class PublicNoticeStream extends ScopingNoticeStream class RawPublicNoticeStream extends NoticeStream { - var $threaded; - - function __construct($threaded=false) - { - $this->threaded = $threaded; - } - function getNoticeIds($offset, $limit, $since_id, $max_id) { $notice = new Notice(); @@ -100,9 +87,6 @@ class RawPublicNoticeStream extends NoticeStream $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC); $notice->whereAdd('is_local !='. Notice::GATEWAY); } - if ($this->threaded) { - $notice->whereAdd('reply_to IS NULL'); - } Notice::addWhereSinceId($notice, $since_id); Notice::addWhereMaxId($notice, $max_id); From f753258a749c8bad8391a5f673676ee46600fe5d Mon Sep 17 00:00:00 2001 From: Samantha Doherty Date: Tue, 5 Apr 2011 13:23:41 -0400 Subject: [PATCH 188/726] Style for best QnA answer. --- theme/neo/css/display.css | 5 +++++ theme/neo/images/rosette.png | Bin 0 -> 673 bytes 2 files changed, 5 insertions(+) create mode 100644 theme/neo/images/rosette.png diff --git a/theme/neo/css/display.css b/theme/neo/css/display.css index 61258bfab6..555b280825 100644 --- a/theme/neo/css/display.css +++ b/theme/neo/css/display.css @@ -1408,4 +1408,9 @@ table.profile_list tr.alt { margin-top: 0px; } +.question p.best { + background: url(../images/rosette.png) no-repeat top left; + padding-left: 20px; +} + }/*end of @media screen, projection, tv*/ diff --git a/theme/neo/images/rosette.png b/theme/neo/images/rosette.png new file mode 100644 index 0000000000000000000000000000000000000000..f233bc77053bf3d4b0c8fafd2a9c58bf34603b61 GIT binary patch literal 673 zcmV;S0$%-zP)N@1p=a9KakdI4{r9Fsj0rE)+ zb~J|8lW*Tz02$`Zaxk^6sfOa5!ghcM1=puT<{WmU!JK!6{4kb3fZrJ*ROjE>@quHyr}*Cr;=Aa64! zj|O-=Sx^U(hAq-h=kq`Q2V>dc0LCnFFu6l&F;*d8IpiIHH4yNNu{%yB`v73}L;K|S z5BXjfZJO%>P`FNNQN^m$1zjx5c5Y{17VpEWq!t0|e{#P8+?shbj%;~D00000NkvXX Hu0mjf+-WMY literal 0 HcmV?d00001 From 2d2c134a1f464021f2b3d3837eac95521ac02af5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 13:28:41 -0400 Subject: [PATCH 189/726] fix constructor error in FileNoticeStream --- lib/filenoticestream.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/filenoticestream.php b/lib/filenoticestream.php index 8c01893634..2b5e53eaf7 100644 --- a/lib/filenoticestream.php +++ b/lib/filenoticestream.php @@ -60,7 +60,6 @@ class RawFileNoticeStream extends NoticeStream function __construct($file) { - parent::__construct(); $this->file = $file; } From 8ef341d5890d56d947bd2e01f3ef65adbceb8668 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 5 Apr 2011 10:29:10 -0700 Subject: [PATCH 190/726] QnA - best answers were not getting the 'best' class on their lis (fixed) --- plugins/QnA/QnAPlugin.php | 2 +- plugins/QnA/actions/qnanewquestion.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index fe42975065..16fbc2f063 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -309,7 +309,7 @@ class QnAPlugin extends MicroAppPlugin $cls = array('hentry', 'notice', 'answer'); - $answer = QnA_Answer::staticGet('uri', $notice->uri); + $answer = QnA_Answer::staticGet('uri', $nli->notice->uri); if (!empty($answer) && !empty($answer->best)) { $cls[] = 'best'; diff --git a/plugins/QnA/actions/qnanewquestion.php b/plugins/QnA/actions/qnanewquestion.php index 3399c5eda8..6610188c47 100644 --- a/plugins/QnA/actions/qnanewquestion.php +++ b/plugins/QnA/actions/qnanewquestion.php @@ -88,7 +88,6 @@ class QnanewquestionAction extends Action } $this->title = $this->trimmed('title'); - common_debug("TITLE = " . $this->title); $this->description = $this->trimmed('description'); return true; From 4b9c3335d49f695f7f9d4490472ff7100dd38978 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 13:30:05 -0400 Subject: [PATCH 191/726] default to private sites --- lib/default.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/default.php b/lib/default.php index 9872d8ffd3..6c7b18bccd 100644 --- a/lib/default.php +++ b/lib/default.php @@ -53,7 +53,7 @@ $default = 'broughtbyurl' => null, 'closed' => false, 'inviteonly' => false, - 'private' => false, + 'private' => true, 'ssl' => 'never', 'sslserver' => null, 'shorturllength' => 30, @@ -301,12 +301,14 @@ $default = array('disabled' => true), 'plugins' => array('default' => array('Geonames' => null, - 'Mapstraction' => null, - 'OStatus' => null, - 'WikiHashtags' => null, - 'RSSCloud' => null, 'ClientSideShorten' => null, 'StrictTransportSecurity' => null, + 'Bookmark' => null, + 'Event' => null, + 'Poll' => null, + 'QnA' => null, + 'SearchSub' => null, + 'TagSub' => null, 'OpenID' => null), 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories 'server' => null, From c9ca11eb647450ab552a4608545981bf3e907092 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 13:43:54 -0400 Subject: [PATCH 192/726] include limited-scope class on bookmarks in output --- plugins/Bookmark/BookmarkPlugin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index a24f207720..daefa12c39 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -294,7 +294,11 @@ class BookmarkPlugin extends MicroAppPlugin $nb = Bookmark::getByNotice($nli->notice); if (!empty($nb)) { $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id; - $nli->out->elementStart('li', array('class' => 'hentry notice bookmark', + $class = 'hentry notice bookmark'; + if ($nli->notice->scope != 0 && $nli->notice->scope != 1) { + $class .= ' limited-scope'; + } + $nli->out->elementStart('li', array('class' => $class, 'id' => 'notice-' . $id)); Event::handle('EndOpenNoticeListItemElement', array($nli)); return false; From 4397686c912f386cc4c1bc802232ef640afecd40 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 13:43:54 -0400 Subject: [PATCH 193/726] include limited-scope class on bookmarks in output --- plugins/Bookmark/BookmarkPlugin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index a24f207720..daefa12c39 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -294,7 +294,11 @@ class BookmarkPlugin extends MicroAppPlugin $nb = Bookmark::getByNotice($nli->notice); if (!empty($nb)) { $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id; - $nli->out->elementStart('li', array('class' => 'hentry notice bookmark', + $class = 'hentry notice bookmark'; + if ($nli->notice->scope != 0 && $nli->notice->scope != 1) { + $class .= ' limited-scope'; + } + $nli->out->elementStart('li', array('class' => $class, 'id' => 'notice-' . $id)); Event::handle('EndOpenNoticeListItemElement', array($nli)); return false; From d3b9aabac3af32be582a2922f062d1612ab1db60 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 13:46:44 -0400 Subject: [PATCH 194/726] Questions show private lock correctly --- plugins/QnA/QnAPlugin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index fe42975065..0b9b81645c 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -295,9 +295,13 @@ class QnAPlugin extends MicroAppPlugin { case QnA_Question::OBJECT_TYPE: $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id; + $class = 'hentry notice question'; + if ($nli->notice->scope != 0 && $nli->notice->scope != 1) { + $class .= ' limited-scope'; + } $nli->out->elementStart( 'li', array( - 'class' => 'hentry notice question', + 'class' => $class, 'id' => 'notice-' . $id ) ); From 8697f1a1e783bfe7588fe1d9dbcf36514e82226a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 15:47:35 -0400 Subject: [PATCH 195/726] alpha2 --- lib/framework.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/framework.php b/lib/framework.php index ab163db06d..ed199ea504 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -20,7 +20,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } define('STATUSNET_BASE_VERSION', '1.0.0'); -define('STATUSNET_LIFECYCLE', 'alpha1'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' +define('STATUSNET_LIFECYCLE', 'alpha2'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release' define('STATUSNET_VERSION', STATUSNET_BASE_VERSION . STATUSNET_LIFECYCLE); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility From 9568d17cb9499d859445ee5c541f4610236b0f9f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 17:02:48 -0400 Subject: [PATCH 196/726] Add streams to left nav --- lib/defaultlocalnav.php | 5 +++ lib/streamsnav.php | 83 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 lib/streamsnav.php diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index b9b45c8e01..f150407621 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -62,6 +62,11 @@ class DefaultLocalNav extends Menu // TRANS: Menu item in default local navigation panel. $this->submenu(_m('MENU','Public'), $bn); + if (!empty($user)) { + $sn = new StreamsNav($this->action); + $this->submenu(_m('MENU', 'Streams'), $sn); + } + $this->action->elementEnd('ul'); } } diff --git a/lib/streamsnav.php b/lib/streamsnav.php new file mode 100644 index 0000000000..2051cc3484 --- /dev/null +++ b/lib/streamsnav.php @@ -0,0 +1,83 @@ +. + * + * @category Cache + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Menu for streams you follow + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class StreamsNav extends Menu +{ + /** + * Show the menu + * + * @return void + */ + function show() + { + $user = common_current_user(); + + if (empty($user)) { + throw new ServerException('Cannot show personal group navigation without a current user.'); + } + + $action = $this->actionName; + + $this->out->elementStart('ul', array('class' => 'nav')); + + if (Event::handle('StartStreamsNav', array($this))) { + $group = $user->getGroups(); + + while ($group->fetch()) { + $this->out->menuItem(($group->mainpage) ? $group->mainpage : common_local_url('showgroup', + array('nickname' => $group->nickname)), + $group->getBestName(), + '', + $action == 'showgroup' && $this->action->arg('nickname') == $group->nickname, + 'nav_timeline_group_'.$group->nickname); + } + Event::handle('EndStreamsNav', array($this)); + } + + $this->out->elementEnd('ul'); + } +} From efd2c68de961551659a7cb48fffd34a24394c01c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 17:20:17 -0400 Subject: [PATCH 197/726] cache groups per user --- classes/Profile.php | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 73a98d4ff5..f7a94413b2 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -245,30 +245,37 @@ class Profile extends Memcached_DataObject return !empty($request); } - function getGroups($offset=0, $limit=null) + function getGroups($offset=0, $limit=PROFILES_PER_PAGE) { - $qry = - 'SELECT user_group.* ' . - 'FROM user_group JOIN group_member '. - 'ON user_group.id = group_member.group_id ' . - 'WHERE group_member.profile_id = %d ' . - 'ORDER BY group_member.created DESC '; + $ids = array(); + + $keypart = sprintf('profile:groups:%d', $this->id); - if ($offset>0 && !is_null($limit)) { - if ($offset) { - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; + $idstring = self::cacheGet($keypart); + + if ($idstring !== false) { + $ids = explode(',', $idstring); + } else { + $gm = new Group_member(); + + $gm->profile_id = $this->id; + + if ($gm->find()) { + while ($gm->fetch()) { + $ids[] = $gm->group_id; } } + + self::cacheSet($keypart, implode(',', $ids)); } - $groups = new User_group(); + $groups = array(); - $cnt = $groups->query(sprintf($qry, $this->id)); + foreach ($ids as $id) { + $groups[] = User_group::staticGet('id', $id); + } - return $groups; + return new ArrayWrapper($groups); } /** @@ -286,6 +293,7 @@ class Profile extends Memcached_DataObject } else { if (Event::handle('StartJoinGroup', array($group, $this))) { $join = Group_member::join($group->id, $this->id); + self::blow('profile:groups:%d', $this->id); Event::handle('EndJoinGroup', array($group, $this)); } } @@ -305,6 +313,7 @@ class Profile extends Memcached_DataObject { if (Event::handle('StartLeaveGroup', array($group, $this))) { Group_member::leave($group->id, $this->id); + self::blow('profile:groups:%d', $this->id); Event::handle('EndLeaveGroup', array($group, $this)); } } From a36fa8364ab8b0dfb7e3d1adf73733830adacc86 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 17:49:45 -0400 Subject: [PATCH 198/726] Move streams nav to groups nav --- lib/defaultlocalnav.php | 6 ++-- lib/{streamsnav.php => groupsnav.php} | 43 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 18 deletions(-) rename lib/{streamsnav.php => groupsnav.php} (62%) diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index f150407621..a61ebbb585 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -63,8 +63,10 @@ class DefaultLocalNav extends Menu $this->submenu(_m('MENU','Public'), $bn); if (!empty($user)) { - $sn = new StreamsNav($this->action); - $this->submenu(_m('MENU', 'Streams'), $sn); + $sn = new GroupsNav($this->action, $user); + if ($sn->haveGroups()) { + $this->submenu(_m('MENU', 'Groups'), $sn); + } } $this->action->elementEnd('ul'); diff --git a/lib/streamsnav.php b/lib/groupsnav.php similarity index 62% rename from lib/streamsnav.php rename to lib/groupsnav.php index 2051cc3484..1d2066f2e5 100644 --- a/lib/streamsnav.php +++ b/lib/groupsnav.php @@ -45,8 +45,23 @@ if (!defined('STATUSNET')) { * @link http://status.net/ */ -class StreamsNav extends Menu +class GroupsNav extends Menu { + protected $user; + protected $groups; + + function __construct($action, $user) + { + parent::__construct($action); + $this->user = $user; + $this->groups = $user->getGroups(); + } + + function haveGroups() + { + return (!empty($this->groups) && ($this->groups->N > 0)); + } + /** * Show the menu * @@ -54,28 +69,24 @@ class StreamsNav extends Menu */ function show() { - $user = common_current_user(); - - if (empty($user)) { - throw new ServerException('Cannot show personal group navigation without a current user.'); - } - $action = $this->actionName; $this->out->elementStart('ul', array('class' => 'nav')); - if (Event::handle('StartStreamsNav', array($this))) { - $group = $user->getGroups(); + if (Event::handle('StartGroupsNav', array($this))) { - while ($group->fetch()) { - $this->out->menuItem(($group->mainpage) ? $group->mainpage : common_local_url('showgroup', - array('nickname' => $group->nickname)), - $group->getBestName(), + while ($this->groups->fetch()) { + $this->out->menuItem(($this->groups->mainpage) ? + $this->groups->mainpage : + common_local_url('showgroup', + array('nickname' => $this->groups->nickname)), + $this->groups->getBestName(), '', - $action == 'showgroup' && $this->action->arg('nickname') == $group->nickname, - 'nav_timeline_group_'.$group->nickname); + $action == 'showgroup' && + $this->action->arg('nickname') == $this->groups->nickname, + 'nav_timeline_group_'.$this->groups->nickname); } - Event::handle('EndStreamsNav', array($this)); + Event::handle('EndGroupsNav', array($this)); } $this->out->elementEnd('ul'); From 5f6512c92f457e6a96327b053319f194391ef10a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 17:49:45 -0400 Subject: [PATCH 199/726] Move streams nav to groups nav --- lib/defaultlocalnav.php | 6 ++-- lib/{streamsnav.php => groupsnav.php} | 43 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 18 deletions(-) rename lib/{streamsnav.php => groupsnav.php} (62%) diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index f150407621..a61ebbb585 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -63,8 +63,10 @@ class DefaultLocalNav extends Menu $this->submenu(_m('MENU','Public'), $bn); if (!empty($user)) { - $sn = new StreamsNav($this->action); - $this->submenu(_m('MENU', 'Streams'), $sn); + $sn = new GroupsNav($this->action, $user); + if ($sn->haveGroups()) { + $this->submenu(_m('MENU', 'Groups'), $sn); + } } $this->action->elementEnd('ul'); diff --git a/lib/streamsnav.php b/lib/groupsnav.php similarity index 62% rename from lib/streamsnav.php rename to lib/groupsnav.php index 2051cc3484..1d2066f2e5 100644 --- a/lib/streamsnav.php +++ b/lib/groupsnav.php @@ -45,8 +45,23 @@ if (!defined('STATUSNET')) { * @link http://status.net/ */ -class StreamsNav extends Menu +class GroupsNav extends Menu { + protected $user; + protected $groups; + + function __construct($action, $user) + { + parent::__construct($action); + $this->user = $user; + $this->groups = $user->getGroups(); + } + + function haveGroups() + { + return (!empty($this->groups) && ($this->groups->N > 0)); + } + /** * Show the menu * @@ -54,28 +69,24 @@ class StreamsNav extends Menu */ function show() { - $user = common_current_user(); - - if (empty($user)) { - throw new ServerException('Cannot show personal group navigation without a current user.'); - } - $action = $this->actionName; $this->out->elementStart('ul', array('class' => 'nav')); - if (Event::handle('StartStreamsNav', array($this))) { - $group = $user->getGroups(); + if (Event::handle('StartGroupsNav', array($this))) { - while ($group->fetch()) { - $this->out->menuItem(($group->mainpage) ? $group->mainpage : common_local_url('showgroup', - array('nickname' => $group->nickname)), - $group->getBestName(), + while ($this->groups->fetch()) { + $this->out->menuItem(($this->groups->mainpage) ? + $this->groups->mainpage : + common_local_url('showgroup', + array('nickname' => $this->groups->nickname)), + $this->groups->getBestName(), '', - $action == 'showgroup' && $this->action->arg('nickname') == $group->nickname, - 'nav_timeline_group_'.$group->nickname); + $action == 'showgroup' && + $this->action->arg('nickname') == $this->groups->nickname, + 'nav_timeline_group_'.$this->groups->nickname); } - Event::handle('EndStreamsNav', array($this)); + Event::handle('EndGroupsNav', array($this)); } $this->out->elementEnd('ul'); From 2138c3b3392c7823b32c434e2a829aa73a182f23 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:07:10 -0400 Subject: [PATCH 200/726] a hook for showing the default local nav --- EVENTS.txt | 8 ++++++++ lib/defaultlocalnav.php | 33 +++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 1494a9c890..b328785e7b 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1139,3 +1139,11 @@ StartNoticeWhoGets: Called at start of inbox delivery prep; plugins can schedule EndNoticeWhoGets: Called at end of inbox delivery prep; plugins can filter out profiles from receiving inbox delivery here. Be aware that output can be cached or used several times, so should remain idempotent. - $notice Notice - &$ni: in/out array mapping profile IDs to constants: NOTICE_INBOX_SOURCE_SUB etc + +StartDefaultLocalNav: When showing the default local nav +- $menu: the menu +- $user: current user + +EndDefaultLocalNav: When showing the default local nav +- $menu: the menu +- $user: current user diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index a61ebbb585..1201ae7468 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -48,25 +48,30 @@ class DefaultLocalNav extends Menu { function show() { - $this->action->elementStart('ul', array('id' => 'nav_local_default')); - $user = common_current_user(); - if (!empty($user)) { - $pn = new PersonalGroupNav($this->action); - // TRANS: Menu item in default local navigation panel. - $this->submenu(_m('MENU','Home'), $pn); - } + $this->action->elementStart('ul', array('id' => 'nav_local_default')); - $bn = new PublicGroupNav($this->action); - // TRANS: Menu item in default local navigation panel. - $this->submenu(_m('MENU','Public'), $bn); + if (Event::handle('StartDefaultLocalNav', array($this, $user))) { - if (!empty($user)) { - $sn = new GroupsNav($this->action, $user); - if ($sn->haveGroups()) { - $this->submenu(_m('MENU', 'Groups'), $sn); + if (!empty($user)) { + $pn = new PersonalGroupNav($this->action); + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU','Home'), $pn); } + + $bn = new PublicGroupNav($this->action); + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU','Public'), $bn); + + if (!empty($user)) { + $sn = new GroupsNav($this->action, $user); + if ($sn->haveGroups()) { + $this->submenu(_m('MENU', 'Groups'), $sn); + } + } + + Event::handle('EndDefaultLocalNav', array($this, $user)); } $this->action->elementEnd('ul'); From a6620dbaf4b0ff67f9cdec82f582b03dccf439a8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:14:48 -0400 Subject: [PATCH 201/726] Added tagsub to the left-hand menu --- plugins/TagSub/TagSub.php | 27 ++++++++++++ plugins/TagSub/TagSubPlugin.php | 25 +++++++++++ plugins/TagSub/tagsubmenu.php | 76 +++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 plugins/TagSub/tagsubmenu.php diff --git a/plugins/TagSub/TagSub.php b/plugins/TagSub/TagSub.php index a734b4fc5f..c2da072693 100644 --- a/plugins/TagSub/TagSub.php +++ b/plugins/TagSub/TagSub.php @@ -120,6 +120,7 @@ class TagSub extends Managed_DataObject $ts->profile_id = $profile->id; $ts->created = common_sql_now(); $ts->insert(); + self::blow('tagsub:by_profile:%d', $profile->id); return $ts; } @@ -135,6 +136,32 @@ class TagSub extends Managed_DataObject 'profile_id' => $profile->id)); if ($ts) { $ts->delete(); + self::blow('tagsub:by_profile:%d', $profile->id); } } + + static function forProfile(Profile $profile) + { + $tags = array(); + + $keypart = sprintf('tagsub:by_profile:%d', $profile->id); + $tagstring = self::cacheGet($keypart); + + if ($tagstring !== false) { + $tags = explode(',', $tagstring); + } else { + $tagsub = new TagSub(); + $tagsub->profile_id = $profile->id; + + if ($tagsub->find()) { + while ($tagsub->fetch()) { + $tags[] = $tagsub->tag; + } + } + + self::cacheSet($keypart, implode(',', $tags)); + } + + return $tags; + } } diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 53a06ab5bf..13e525bb62 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -80,6 +80,7 @@ class TagSubPlugin extends Plugin case 'TagunsubAction': case 'TagsubsAction': case 'TagSubForm': + case 'TagSubMenu': case 'TagUnsubForm': include_once $dir.'/'.strtolower($cls).'.php'; return false; @@ -239,4 +240,28 @@ class TagSubPlugin extends Plugin } return true; } + + function onEndDefaultLocalNav($menu, $user) + { + $user = common_current_user(); + + $tags = TagSub::forProfile($user->getProfile()); + + if (!empty($tags)) { + $tagSubMenu = new TagSubMenu($menu->out, $user, $tags); + $menu->submenu(_m('Tags'), $tagSubMenu); + } + + foreach ($tags as $tag) { + $menu->out->menuItem(common_local_url('tag', + array('tag' => $tag)), + sprintf('#%s', $tag), + sprintf(_('Notices tagged with %s'), $tag), + $menu->actionName == 'tag' && $menu->action->arg('tag') == $tag, + 'nav_streams_tag_'.$tag); + } + + return true; + } + } diff --git a/plugins/TagSub/tagsubmenu.php b/plugins/TagSub/tagsubmenu.php new file mode 100644 index 0000000000..44770651d9 --- /dev/null +++ b/plugins/TagSub/tagsubmenu.php @@ -0,0 +1,76 @@ +. + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Class comment + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class TagSubMenu extends Menu +{ + protected $user; + protected $tags; + + function __construct($out, $user, $tags) + { + parent::__construct($out); + $this->user = $user; + $this->tags = $tags; + } + + function show() + { + $this->out->elementStart('ul', array('class' => 'nav')); + + foreach ($tags as $tag) { + $this->out->menuItem(common_local_url('tag', + array('tag' => $tag)), + sprintf('#%s', $tag), + sprintf(_('Notices tagged with %s'), $tag), + $this->actionName == 'tag' && $this->action->arg('tag') == $tag, + 'nav_streams_tag_'.$tag); + } + + $this->out->elementEnd('ul'); + } + +} From 097d76b3d211c633a68802c506dbc97fdc49b5fb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:14:48 -0400 Subject: [PATCH 202/726] Added tagsub to the left-hand menu --- plugins/TagSub/TagSub.php | 27 ++++++++++++ plugins/TagSub/TagSubPlugin.php | 25 +++++++++++ plugins/TagSub/tagsubmenu.php | 76 +++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 plugins/TagSub/tagsubmenu.php diff --git a/plugins/TagSub/TagSub.php b/plugins/TagSub/TagSub.php index a734b4fc5f..c2da072693 100644 --- a/plugins/TagSub/TagSub.php +++ b/plugins/TagSub/TagSub.php @@ -120,6 +120,7 @@ class TagSub extends Managed_DataObject $ts->profile_id = $profile->id; $ts->created = common_sql_now(); $ts->insert(); + self::blow('tagsub:by_profile:%d', $profile->id); return $ts; } @@ -135,6 +136,32 @@ class TagSub extends Managed_DataObject 'profile_id' => $profile->id)); if ($ts) { $ts->delete(); + self::blow('tagsub:by_profile:%d', $profile->id); } } + + static function forProfile(Profile $profile) + { + $tags = array(); + + $keypart = sprintf('tagsub:by_profile:%d', $profile->id); + $tagstring = self::cacheGet($keypart); + + if ($tagstring !== false) { + $tags = explode(',', $tagstring); + } else { + $tagsub = new TagSub(); + $tagsub->profile_id = $profile->id; + + if ($tagsub->find()) { + while ($tagsub->fetch()) { + $tags[] = $tagsub->tag; + } + } + + self::cacheSet($keypart, implode(',', $tags)); + } + + return $tags; + } } diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 53a06ab5bf..13e525bb62 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -80,6 +80,7 @@ class TagSubPlugin extends Plugin case 'TagunsubAction': case 'TagsubsAction': case 'TagSubForm': + case 'TagSubMenu': case 'TagUnsubForm': include_once $dir.'/'.strtolower($cls).'.php'; return false; @@ -239,4 +240,28 @@ class TagSubPlugin extends Plugin } return true; } + + function onEndDefaultLocalNav($menu, $user) + { + $user = common_current_user(); + + $tags = TagSub::forProfile($user->getProfile()); + + if (!empty($tags)) { + $tagSubMenu = new TagSubMenu($menu->out, $user, $tags); + $menu->submenu(_m('Tags'), $tagSubMenu); + } + + foreach ($tags as $tag) { + $menu->out->menuItem(common_local_url('tag', + array('tag' => $tag)), + sprintf('#%s', $tag), + sprintf(_('Notices tagged with %s'), $tag), + $menu->actionName == 'tag' && $menu->action->arg('tag') == $tag, + 'nav_streams_tag_'.$tag); + } + + return true; + } + } diff --git a/plugins/TagSub/tagsubmenu.php b/plugins/TagSub/tagsubmenu.php new file mode 100644 index 0000000000..44770651d9 --- /dev/null +++ b/plugins/TagSub/tagsubmenu.php @@ -0,0 +1,76 @@ +. + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Class comment + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class TagSubMenu extends Menu +{ + protected $user; + protected $tags; + + function __construct($out, $user, $tags) + { + parent::__construct($out); + $this->user = $user; + $this->tags = $tags; + } + + function show() + { + $this->out->elementStart('ul', array('class' => 'nav')); + + foreach ($tags as $tag) { + $this->out->menuItem(common_local_url('tag', + array('tag' => $tag)), + sprintf('#%s', $tag), + sprintf(_('Notices tagged with %s'), $tag), + $this->actionName == 'tag' && $this->action->arg('tag') == $tag, + 'nav_streams_tag_'.$tag); + } + + $this->out->elementEnd('ul'); + } + +} From 3377cd59ce84b85334ea3f057fcf6797c9ff38ec Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:07:10 -0400 Subject: [PATCH 203/726] a hook for showing the default local nav --- EVENTS.txt | 8 ++++++++ lib/defaultlocalnav.php | 33 +++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 1494a9c890..b328785e7b 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1139,3 +1139,11 @@ StartNoticeWhoGets: Called at start of inbox delivery prep; plugins can schedule EndNoticeWhoGets: Called at end of inbox delivery prep; plugins can filter out profiles from receiving inbox delivery here. Be aware that output can be cached or used several times, so should remain idempotent. - $notice Notice - &$ni: in/out array mapping profile IDs to constants: NOTICE_INBOX_SOURCE_SUB etc + +StartDefaultLocalNav: When showing the default local nav +- $menu: the menu +- $user: current user + +EndDefaultLocalNav: When showing the default local nav +- $menu: the menu +- $user: current user diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index a61ebbb585..1201ae7468 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -48,25 +48,30 @@ class DefaultLocalNav extends Menu { function show() { - $this->action->elementStart('ul', array('id' => 'nav_local_default')); - $user = common_current_user(); - if (!empty($user)) { - $pn = new PersonalGroupNav($this->action); - // TRANS: Menu item in default local navigation panel. - $this->submenu(_m('MENU','Home'), $pn); - } + $this->action->elementStart('ul', array('id' => 'nav_local_default')); - $bn = new PublicGroupNav($this->action); - // TRANS: Menu item in default local navigation panel. - $this->submenu(_m('MENU','Public'), $bn); + if (Event::handle('StartDefaultLocalNav', array($this, $user))) { - if (!empty($user)) { - $sn = new GroupsNav($this->action, $user); - if ($sn->haveGroups()) { - $this->submenu(_m('MENU', 'Groups'), $sn); + if (!empty($user)) { + $pn = new PersonalGroupNav($this->action); + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU','Home'), $pn); } + + $bn = new PublicGroupNav($this->action); + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU','Public'), $bn); + + if (!empty($user)) { + $sn = new GroupsNav($this->action, $user); + if ($sn->haveGroups()) { + $this->submenu(_m('MENU', 'Groups'), $sn); + } + } + + Event::handle('EndDefaultLocalNav', array($this, $user)); } $this->action->elementEnd('ul'); From 1459443b2110039a085103ee33522c79840288d5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:19:11 -0400 Subject: [PATCH 204/726] cut-and-paste error in TagSubMenu --- plugins/TagSub/TagSubPlugin.php | 9 --------- plugins/TagSub/tagsubmenu.php | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 13e525bb62..8fbb113362 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -252,15 +252,6 @@ class TagSubPlugin extends Plugin $menu->submenu(_m('Tags'), $tagSubMenu); } - foreach ($tags as $tag) { - $menu->out->menuItem(common_local_url('tag', - array('tag' => $tag)), - sprintf('#%s', $tag), - sprintf(_('Notices tagged with %s'), $tag), - $menu->actionName == 'tag' && $menu->action->arg('tag') == $tag, - 'nav_streams_tag_'.$tag); - } - return true; } diff --git a/plugins/TagSub/tagsubmenu.php b/plugins/TagSub/tagsubmenu.php index 44770651d9..e2ddf04ef9 100644 --- a/plugins/TagSub/tagsubmenu.php +++ b/plugins/TagSub/tagsubmenu.php @@ -61,7 +61,7 @@ class TagSubMenu extends Menu { $this->out->elementStart('ul', array('class' => 'nav')); - foreach ($tags as $tag) { + foreach ($this->tags as $tag) { $this->out->menuItem(common_local_url('tag', array('tag' => $tag)), sprintf('#%s', $tag), From a5de3a076b7f7e225b2a1b16809acf088a5f0861 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:19:11 -0400 Subject: [PATCH 205/726] cut-and-paste error in TagSubMenu --- plugins/TagSub/TagSubPlugin.php | 9 --------- plugins/TagSub/tagsubmenu.php | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 13e525bb62..8fbb113362 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -252,15 +252,6 @@ class TagSubPlugin extends Plugin $menu->submenu(_m('Tags'), $tagSubMenu); } - foreach ($tags as $tag) { - $menu->out->menuItem(common_local_url('tag', - array('tag' => $tag)), - sprintf('#%s', $tag), - sprintf(_('Notices tagged with %s'), $tag), - $menu->actionName == 'tag' && $menu->action->arg('tag') == $tag, - 'nav_streams_tag_'.$tag); - } - return true; } diff --git a/plugins/TagSub/tagsubmenu.php b/plugins/TagSub/tagsubmenu.php index 44770651d9..e2ddf04ef9 100644 --- a/plugins/TagSub/tagsubmenu.php +++ b/plugins/TagSub/tagsubmenu.php @@ -61,7 +61,7 @@ class TagSubMenu extends Menu { $this->out->elementStart('ul', array('class' => 'nav')); - foreach ($tags as $tag) { + foreach ($this->tags as $tag) { $this->out->menuItem(common_local_url('tag', array('tag' => $tag)), sprintf('#%s', $tag), From b3e7dd70e25ffecddcb24e676bfc9ae328f16c70 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:27:01 -0400 Subject: [PATCH 206/726] don't put bogus groups into the groups array --- classes/Profile.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/Profile.php b/classes/Profile.php index f7a94413b2..9f63980242 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -272,7 +272,10 @@ class Profile extends Memcached_DataObject $groups = array(); foreach ($ids as $id) { - $groups[] = User_group::staticGet('id', $id); + $group = User_group::staticGet('id', $id); + if (!empty($group)) { + $groups[] = $group; + } } return new ArrayWrapper($groups); From f2a9c9c26dfca9ae1635bd114e3be4c58ba325d3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:29:09 -0400 Subject: [PATCH 207/726] check for 0-tag menu --- plugins/TagSub/TagSubPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 8fbb113362..a9b24b0b59 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -247,7 +247,7 @@ class TagSubPlugin extends Plugin $tags = TagSub::forProfile($user->getProfile()); - if (!empty($tags)) { + if (!empty($tags) && count($tags) > 0) { $tagSubMenu = new TagSubMenu($menu->out, $user, $tags); $menu->submenu(_m('Tags'), $tagSubMenu); } From 11bbc5adcdbb479b3ac1c7826d0cfd1e2eea24c7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:36:49 -0400 Subject: [PATCH 208/726] a little more protection against empty tags --- plugins/TagSub/TagSub.php | 6 ++++-- plugins/TagSub/tagsubmenu.php | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/TagSub/TagSub.php b/plugins/TagSub/TagSub.php index c2da072693..9662811bf9 100644 --- a/plugins/TagSub/TagSub.php +++ b/plugins/TagSub/TagSub.php @@ -147,7 +147,7 @@ class TagSub extends Managed_DataObject $keypart = sprintf('tagsub:by_profile:%d', $profile->id); $tagstring = self::cacheGet($keypart); - if ($tagstring !== false) { + if ($tagstring !== false && !empty($tagstring)) { $tags = explode(',', $tagstring); } else { $tagsub = new TagSub(); @@ -155,7 +155,9 @@ class TagSub extends Managed_DataObject if ($tagsub->find()) { while ($tagsub->fetch()) { - $tags[] = $tagsub->tag; + if (!empty($tagsub->tag)) { + $tags[] = $tagsub->tag; + } } } diff --git a/plugins/TagSub/tagsubmenu.php b/plugins/TagSub/tagsubmenu.php index e2ddf04ef9..e57a8a8a97 100644 --- a/plugins/TagSub/tagsubmenu.php +++ b/plugins/TagSub/tagsubmenu.php @@ -62,12 +62,14 @@ class TagSubMenu extends Menu $this->out->elementStart('ul', array('class' => 'nav')); foreach ($this->tags as $tag) { + if (!empty($tag)) { $this->out->menuItem(common_local_url('tag', array('tag' => $tag)), sprintf('#%s', $tag), sprintf(_('Notices tagged with %s'), $tag), $this->actionName == 'tag' && $this->action->arg('tag') == $tag, 'nav_streams_tag_'.$tag); + } } $this->out->elementEnd('ul'); From cffbda8183041883584dc0092dbe932c5e465bc9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 5 Apr 2011 18:45:37 -0400 Subject: [PATCH 209/726] add search submenu to default local nav --- plugins/SearchSub/SearchSub.php | 29 ++++++++++ plugins/SearchSub/SearchSubPlugin.php | 16 ++++++ plugins/SearchSub/searchsubmenu.php | 78 +++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 plugins/SearchSub/searchsubmenu.php diff --git a/plugins/SearchSub/SearchSub.php b/plugins/SearchSub/SearchSub.php index cbf64d39cc..b903e88e2e 100644 --- a/plugins/SearchSub/SearchSub.php +++ b/plugins/SearchSub/SearchSub.php @@ -120,6 +120,7 @@ class SearchSub extends Managed_DataObject $ts->profile_id = $profile->id; $ts->created = common_sql_now(); $ts->insert(); + self::blow('searchsub:by_profile:%d', $profile->id); return $ts; } @@ -135,6 +136,34 @@ class SearchSub extends Managed_DataObject 'profile_id' => $profile->id)); if ($ts) { $ts->delete(); + self::blow('searchsub:by_profile:%d', $profile->id); } } + + static function forProfile(Profile $profile) + { + $searches = array(); + + $keypart = sprintf('searchsub:by_profile:%d', $profile->id); + $searchstring = self::cacheGet($keypart); + + if ($searchstring !== false && !empty($searchstring)) { + $searches = explode(',', $searchstring); + } else { + $searchsub = new SearchSub(); + $searchsub->profile_id = $profile->id; + + if ($searchsub->find()) { + while ($searchsub->fetch()) { + if (!empty($searchsub->search)) { + $searches[] = $searchsub->search; + } + } + } + + self::cacheSet($keypart, implode(',', $searches)); + } + + return $searches; + } } diff --git a/plugins/SearchSub/SearchSubPlugin.php b/plugins/SearchSub/SearchSubPlugin.php index c07f7695da..813b8290d8 100644 --- a/plugins/SearchSub/SearchSubPlugin.php +++ b/plugins/SearchSub/SearchSubPlugin.php @@ -80,6 +80,7 @@ class SearchSubPlugin extends Plugin case 'SearchunsubAction': case 'SearchsubsAction': case 'SearchSubForm': + case 'SearchSubMenu': case 'SearchUnsubForm': case 'SearchSubTrackCommand': case 'SearchSubTrackOffCommand': @@ -318,4 +319,19 @@ class SearchSubPlugin extends Plugin // TRANS: Help message for IM/SMS command "tracking" $commands["tracking"] = _m('COMMANDHELP', "List all your search subscriptions."); } + + function onEndDefaultLocalNav($menu, $user) + { + $user = common_current_user(); + + $searches = SearchSub::forProfile($user->getProfile()); + + if (!empty($searches) && count($searches) > 0) { + $searchSubMenu = new SearchSubMenu($menu->out, $user, $searches); + $menu->submenu(_m('Searches'), $searchSubMenu); + } + + return true; + } + } diff --git a/plugins/SearchSub/searchsubmenu.php b/plugins/SearchSub/searchsubmenu.php new file mode 100644 index 0000000000..684f5c7db2 --- /dev/null +++ b/plugins/SearchSub/searchsubmenu.php @@ -0,0 +1,78 @@ +. + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Class comment + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class SearchSubMenu extends Menu +{ + protected $user; + protected $searches; + + function __construct($out, $user, $searches) + { + parent::__construct($out); + $this->user = $user; + $this->searches = $searches; + } + + function show() + { + $this->out->elementStart('ul', array('class' => 'nav')); + + foreach ($this->searches as $search) { + if (!empty($search)) { + $this->out->menuItem(common_local_url('noticesearch', + array('q' => $search)), + sprintf('"%s"', $search), + sprintf(_('Notices including %s'), $search), + $this->actionName == 'noticesearch' && $this->action->arg('q') == $search, + 'nav_streams_search_'.$search); + } + } + + $this->out->elementEnd('ul'); + } + +} From 3d36c755a339ee8fe756b5cc6211d6f17d9d1bd9 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 01:40:03 +0200 Subject: [PATCH 210/726] Fix translator documentation issues. --- lib/activityimporter.php | 16 ++++++++-------- lib/activitymover.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/activityimporter.php b/lib/activityimporter.php index 270b285a26..bd812609de 100644 --- a/lib/activityimporter.php +++ b/lib/activityimporter.php @@ -104,7 +104,7 @@ class ActivityImporter extends QueueHandler if ($activity->objects[0]->id == $author->id) { if (!$this->trusted) { // TRANS: Client exception thrown when trying to force a subscription for an untrusted user. - throw new ClientException(_("Cannot force subscription for untrusted user.")); + throw new ClientException(_('Cannot force subscription for untrusted user.')); } $other = $activity->actor; @@ -113,8 +113,8 @@ class ActivityImporter extends QueueHandler if (!empty($otherUser)) { $otherProfile = $otherUser->getProfile(); } else { - // TRANS: Client exception thrown when trying to for a remote user to subscribe. - throw new Exception(_("Cannot force remote user to subscribe.")); + // TRANS: Client exception thrown when trying to force a remote user to subscribe. + throw new Exception(_('Cannot force remote user to subscribe.')); } // XXX: don't do this for untrusted input! @@ -129,13 +129,13 @@ class ActivityImporter extends QueueHandler if (empty($otherProfile)) { // TRANS: Client exception thrown when trying to subscribe to an unknown profile. - throw new ClientException(_("Unknown profile.")); + throw new ClientException(_('Unknown profile.')); } Subscription::start($profile, $otherProfile); } else { // TRANS: Client exception thrown when trying to import an event not related to the importing user. - throw new Exception(_("This activity seems unrelated to our user.")); + throw new Exception(_('This activity seems unrelated to our user.')); } } @@ -151,7 +151,7 @@ class ActivityImporter extends QueueHandler $oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]); if (!$oprofile->isGroup()) { // TRANS: Client exception thrown when trying to join a remote group that is not a group. - throw new ClientException(_("Remote profile is not a group!")); + throw new ClientException(_('Remote profile is not a group!')); } $group = $oprofile->localGroup(); } @@ -201,7 +201,7 @@ class ActivityImporter extends QueueHandler } } else { // TRANS: Client exception thrown when trying to overwrite the author information for a non-trusted user during import. - throw new ClientException(_("Not overwriting author info for non-trusted user.")); + throw new ClientException(_('Not overwriting author info for non-trusted user.')); } } @@ -217,7 +217,7 @@ class ActivityImporter extends QueueHandler // @fixme fetch from $sourceUrl? // TRANS: Client exception thrown when trying to import a notice without content. // TRANS: %s is the notice URI. - throw new ClientException(sprintf(_("No content for notice %s."),$sourceUri)); + throw new ClientException(sprintf(_('No content for notice %s.'),$sourceUri)); } // Get (safe!) HTML and text versions of the content diff --git a/lib/activitymover.php b/lib/activitymover.php index 3380a92c82..6d9d77b215 100644 --- a/lib/activitymover.php +++ b/lib/activitymover.php @@ -81,7 +81,7 @@ class ActivityMover extends QueueHandler function moveActivity($act, $sink, $user, $remote) { if (empty($user)) { - // TRANS: Exception thrown if no user is provided. %s is a user ID. + // TRANS: Exception thrown if a non-existing user is provided. %s is a user ID. throw new Exception(sprintf(_('No such user "%s".'),$act->actor->id)); } From 69778f12c8bc69485c3f3ade0d76b60ac139b013 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 01:55:29 +0200 Subject: [PATCH 211/726] Update translator documentation. Whitespace updates. --- lib/defaultlocalnav.php | 1 + lib/groupeditform.php | 6 ++++-- lib/groupsnav.php | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index 1201ae7468..84a6267ac9 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -67,6 +67,7 @@ class DefaultLocalNav extends Menu if (!empty($user)) { $sn = new GroupsNav($this->action, $user); if ($sn->haveGroups()) { + // TRANS: Menu item in default local navigation panel. $this->submenu(_m('MENU', 'Groups'), $sn); } } diff --git a/lib/groupeditform.php b/lib/groupeditform.php index c1218ab354..b795c1387d 100644 --- a/lib/groupeditform.php +++ b/lib/groupeditform.php @@ -202,10 +202,12 @@ class GroupEditForm extends Form $this->out->elementEnd('li'); } $this->out->elementStart('li'); - $this->out->checkbox('private', _('Private'), + // TRANS: Checkbox field label on group edit form to mark a group private. + $this->out->checkbox('private', _m('LABEL','Private'), ($this->out->arg('private')) ? $this->out->arg('private') : ((!empty($this->group)) ? $this->group->isPrivate() : false), - _('New members must be approved by admin and all posts are forced to be private')); + // TRANS: Checkbox field title on group edit form to mark a group private. + _('New members must be approved by admin and all posts are forced to be private.')); $this->out->elementEnd('li'); Event::handle('EndGroupEditFormData', array($this)); } diff --git a/lib/groupsnav.php b/lib/groupsnav.php index 1d2066f2e5..26058c2b7e 100644 --- a/lib/groupsnav.php +++ b/lib/groupsnav.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Menu for streams - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class GroupsNav extends Menu { protected $user; @@ -74,7 +73,7 @@ class GroupsNav extends Menu $this->out->elementStart('ul', array('class' => 'nav')); if (Event::handle('StartGroupsNav', array($this))) { - + while ($this->groups->fetch()) { $this->out->menuItem(($this->groups->mainpage) ? $this->groups->mainpage : @@ -82,7 +81,7 @@ class GroupsNav extends Menu array('nickname' => $this->groups->nickname)), $this->groups->getBestName(), '', - $action == 'showgroup' && + $action == 'showgroup' && $this->action->arg('nickname') == $this->groups->nickname, 'nav_timeline_group_'.$this->groups->nickname); } From cca159883a57366c25f0b67a61f22ecc198669bb Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 02:11:09 +0200 Subject: [PATCH 212/726] Update translator documentation. i18n/L10n issues fixed. Superfluous whitespace removed. --- ...AccountManagementControlDocumentAction.php | 2 -- .../AccountManagementSessionStatusAction.php | 2 -- .../AccountManager/AccountManagerPlugin.php | 2 -- plugins/Adsense/AdsensePlugin.php | 3 +- plugins/Adsense/adsenseadminpanel.php | 29 ++++++++++++++----- plugins/Aim/AimPlugin.php | 12 ++++---- plugins/Aim/Fake_Aim.php | 1 - plugins/Aim/aimmanager.php | 4 +-- plugins/AnonymousFave/AnonymousFavePlugin.php | 3 -- plugins/AnonymousFave/anonfavorform.php | 2 -- .../scripts/initialize_fave_tallys.php | 1 - 11 files changed, 33 insertions(+), 28 deletions(-) diff --git a/plugins/AccountManager/AccountManagementControlDocumentAction.php b/plugins/AccountManager/AccountManagementControlDocumentAction.php index 3fcea5af42..955779b4ee 100644 --- a/plugins/AccountManager/AccountManagementControlDocumentAction.php +++ b/plugins/AccountManager/AccountManagementControlDocumentAction.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class AccountManagementControlDocumentAction extends Action { /** @@ -50,7 +49,6 @@ class AccountManagementControlDocumentAction extends Action * * @return void */ - function handle($args) { parent::handle($args); diff --git a/plugins/AccountManager/AccountManagementSessionStatusAction.php b/plugins/AccountManager/AccountManagementSessionStatusAction.php index 48b6034ff6..9eeff72402 100644 --- a/plugins/AccountManager/AccountManagementSessionStatusAction.php +++ b/plugins/AccountManager/AccountManagementSessionStatusAction.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class AccountManagementSessionStatusAction extends Action { /** @@ -50,7 +49,6 @@ class AccountManagementSessionStatusAction extends Action * * @return void */ - function handle($args) { parent::handle($args); diff --git a/plugins/AccountManager/AccountManagerPlugin.php b/plugins/AccountManager/AccountManagerPlugin.php index 52dd64a24b..9563252c73 100644 --- a/plugins/AccountManager/AccountManagerPlugin.php +++ b/plugins/AccountManager/AccountManagerPlugin.php @@ -33,7 +33,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { class AccountManagerPlugin extends Plugin { - const AM_REL = 'acct-mgmt'; function __construct() @@ -99,7 +98,6 @@ class AccountManagerPlugin extends Plugin default: return true; } - } function onPluginVersion(&$versions) diff --git a/plugins/Adsense/AdsensePlugin.php b/plugins/Adsense/AdsensePlugin.php index fec033331a..fa8afb1807 100644 --- a/plugins/Adsense/AdsensePlugin.php +++ b/plugins/Adsense/AdsensePlugin.php @@ -193,7 +193,7 @@ class AdsensePlugin extends UAPPlugin // TRANS: Menu item title/tooltip $menu_title = _m('AdSense configuration'); // TRANS: Menu item for site administration - $menu->out->menuItem(common_local_url('adsenseadminpanel'), _m('AdSense'), + $menu->out->menuItem(common_local_url('adsenseadminpanel'), _m('MENU','AdSense'), $menu_title, $action_name == 'adsenseadminpanel', 'nav_adsense_admin_panel'); } return true; @@ -206,6 +206,7 @@ class AdsensePlugin extends UAPPlugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Adsense', 'rawdescription' => + // TRANS: Plugin description. _m('Plugin to add Google AdSense to StatusNet sites.')); return true; } diff --git a/plugins/Adsense/adsenseadminpanel.php b/plugins/Adsense/adsenseadminpanel.php index 110cc9e2b7..224c82b2fc 100644 --- a/plugins/Adsense/adsenseadminpanel.php +++ b/plugins/Adsense/adsenseadminpanel.php @@ -161,38 +161,50 @@ class AdsenseAdminPanelForm extends AdminForm $this->out->elementStart('ul', 'form_data'); $this->li(); $this->input('client', + // TRANS: Field label in AdSense administration panel. _m('Client ID'), - _m('Google client ID'), + // TRANS: Field title in AdSense administration panel. + _m('Google client ID.'), 'adsense'); $this->unli(); $this->li(); $this->input('adScript', + // TRANS: Field label in AdSense administration panel. _m('Ad script URL'), - _m('Script URL (advanced)'), + // TRANS: Field title in AdSense administration panel. + _m('Script URL (advanced).'), 'adsense'); $this->unli(); $this->li(); $this->input('mediumRectangle', + // TRANS: Field label in AdSense administration panel. _m('Medium rectangle'), - _m('Medium rectangle slot code'), + // TRANS: Field title in AdSense administration panel. + _m('Medium rectangle slot code.'), 'adsense'); $this->unli(); $this->li(); $this->input('rectangle', + // TRANS: Field label in AdSense administration panel. _m('Rectangle'), - _m('Rectangle slot code'), + // TRANS: Field title in AdSense administration panel. + _m('Rectangle slot code.'), 'adsense'); $this->unli(); $this->li(); $this->input('leaderboard', + // TRANS: Field label in AdSense administration panel. _m('Leaderboard'), - _m('Leaderboard slot code'), + // TRANS: Field title in AdSense administration panel. + _m('Leaderboard slot code.'), 'adsense'); $this->unli(); $this->li(); $this->input('wideSkyscraper', + // TRANS: Field label in AdSense administration panel. _m('Skyscraper'), - _m('Wide skyscraper slot code'), + // TRANS: Field title in AdSense administration panel. + _m('Wide skyscraper slot code.'), 'adsense'); $this->unli(); $this->out->elementEnd('ul'); @@ -205,6 +217,9 @@ class AdsenseAdminPanelForm extends AdminForm */ function formActions() { - $this->out->submit('submit', _m('Save'), 'submit', null, _m('Save AdSense settings')); + // TRANS: Button text to save settings in AdSense administration panel. + $this->out->submit('submit', _m('BUTTON','Save'), + // TRANS: Button title to save settings in AdSense administration panel. + 'submit', null, _m('Save AdSense settings.')); } } diff --git a/plugins/Aim/AimPlugin.php b/plugins/Aim/AimPlugin.php index 3a1799a2d8..e44505b21c 100644 --- a/plugins/Aim/AimPlugin.php +++ b/plugins/Aim/AimPlugin.php @@ -46,7 +46,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/ext * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class AimPlugin extends ImPlugin { public $user = null; @@ -57,6 +56,7 @@ class AimPlugin extends ImPlugin function getDisplayName() { + // TRANS: Display name. return _m('AIM'); } @@ -116,7 +116,7 @@ class AimPlugin extends ImPlugin function microiduri($screenname) { - return 'aim:' . $screenname; + return 'aim:' . $screenname; } function sendMessage($screenname, $body) @@ -145,10 +145,12 @@ class AimPlugin extends ImPlugin function initialize(){ if(!isset($this->user)){ - throw new Exception("must specify a user"); + // TRANS: Exception thrown in AIM plugin when user has not been specified. + throw new Exception(_m('Must specify a user.')); } if(!isset($this->password)){ - throw new Exception("must specify a password"); + // TRANS: Exception thrown in AIM plugin when password has not been specified. + throw new Exception(_m('Must specify a password.')); } $this->fake_aim = new Fake_Aim($this->user,$this->password,4); @@ -162,8 +164,8 @@ class AimPlugin extends ImPlugin 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:AIM', 'rawdescription' => + // TRANS: Plugin description. _m('The AIM plugin allows users to send and receive notices over the AIM network.')); return true; } } - diff --git a/plugins/Aim/Fake_Aim.php b/plugins/Aim/Fake_Aim.php index 139b68f82b..e24c0f2bfb 100644 --- a/plugins/Aim/Fake_Aim.php +++ b/plugins/Aim/Fake_Aim.php @@ -40,4 +40,3 @@ class Fake_Aim extends Aim $this->would_be_sent = array($sflap_type, $sflap_data, $no_null, $formatted); } } - diff --git a/plugins/Aim/aimmanager.php b/plugins/Aim/aimmanager.php index 8ff7ab7e70..619a9ad0a7 100644 --- a/plugins/Aim/aimmanager.php +++ b/plugins/Aim/aimmanager.php @@ -29,10 +29,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } * In a multi-site queuedaemon.php run, one connection will be instantiated * for each site being handled by the current process that has XMPP enabled. */ - class AimManager extends ImManager { - public $conn = null; /** * Initialize connection to server. @@ -77,6 +75,8 @@ class AimManager extends ImManager $this->conn->registerHandler("IMIn",array($this,"handle_aim_message")); $this->conn->myServer="toc.oscar.aol.com"; $this->conn->signon(); + // @todo i18n FIXME: Update translator documentation, please. + // TRANS: No idea what the use case for this message is. $this->conn->setProfile(_m('Send me a message to post a notice'),false); } return $this->conn; diff --git a/plugins/AnonymousFave/AnonymousFavePlugin.php b/plugins/AnonymousFave/AnonymousFavePlugin.php index 96edf82e12..917f5a7e8c 100644 --- a/plugins/AnonymousFave/AnonymousFavePlugin.php +++ b/plugins/AnonymousFave/AnonymousFavePlugin.php @@ -56,10 +56,8 @@ define('ANONYMOUS_FAVE_PLUGIN_VERSION', '0.1'); * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class AnonymousFavePlugin extends Plugin { - // Array of users who should not have anon faving. The default is // that anonymous faving is allowed for all users. public $restricted = array(); @@ -327,5 +325,4 @@ class AnonymousFavePlugin extends Plugin return true; } - } diff --git a/plugins/AnonymousFave/anonfavorform.php b/plugins/AnonymousFave/anonfavorform.php index 2fbd015e36..a68fdaf2b3 100644 --- a/plugins/AnonymousFave/anonfavorform.php +++ b/plugins/AnonymousFave/anonfavorform.php @@ -46,7 +46,6 @@ require_once INSTALLDIR.'/lib/form.php'; */ class AnonFavorForm extends FavorForm { - /** * Constructor * @@ -67,5 +66,4 @@ class AnonFavorForm extends FavorForm { return common_local_url('AnonFavor'); } - } diff --git a/plugins/AnonymousFave/scripts/initialize_fave_tallys.php b/plugins/AnonymousFave/scripts/initialize_fave_tallys.php index f7ea6d1ef7..a955620db5 100755 --- a/plugins/AnonymousFave/scripts/initialize_fave_tallys.php +++ b/plugins/AnonymousFave/scripts/initialize_fave_tallys.php @@ -35,4 +35,3 @@ $notice->find(); while ($notice->fetch()) { Fave_tally::ensureTally($notice->id); } - From 14aef781ad7c544016d362c937c8cdff57d0fcf0 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Wed, 6 Apr 2011 11:25:50 +0530 Subject: [PATCH 213/726] Use the cool and new NoticeStream for people tag timeline --- classes/Profile_list.php | 7 +-- lib/peopletagnoticestream.php | 105 ++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 lib/peopletagnoticestream.php diff --git a/classes/Profile_list.php b/classes/Profile_list.php index df7bef5201..0bdf12e0e3 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -165,12 +165,9 @@ class Profile_list extends Memcached_DataObject function getNotices($offset, $limit, $since_id=null, $max_id=null) { - $ids = Notice::stream(array($this, '_streamDirect'), - array(), - 'profile_tag:notice_ids:' . $this->id, - $offset, $limit, $since_id, $max_id); + $stream = new PeopletagNoticeStream($this); - return Notice::getStreamByIds($ids); + return $stream->getNotices($offset, $limit, $since_id, $max_id); } /** diff --git a/lib/peopletagnoticestream.php b/lib/peopletagnoticestream.php new file mode 100644 index 0000000000..b5367fe5bc --- /dev/null +++ b/lib/peopletagnoticestream.php @@ -0,0 +1,105 @@ +. + * + * @category Stream + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Stream of notices for a people tag + * + * @category Stream + * @package StatusNet + * @author Evan Prodromou + * @author Shashi Gowda + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ +class PeopletagNoticeStream extends ScopingNoticeStream +{ + function __construct($plist) + { + parent::__construct(new CachingNoticeStream(new RawPeopletagNoticeStream($plist), + 'profile_tag:notice_ids:' . $plist->id)); + } +} + +/** + * Stream of notices for a people tag + * + * @category Stream + * @package StatusNet + * @author Evan Prodromou + * @author Shashi Gowda + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ +class RawPeopletagNoticeStream extends NoticeStream +{ + protected $profile_tag; + + function __construct($profile_tag) + { + $this->profile_tag = $profile_tag; + } + + function getNoticeIds($offset, $limit, $since_id, $max_id) + { + $inbox = new Profile_tag_inbox(); + + $inbox->profile_tag_id = $this->profile_tag->id; + + $inbox->selectAdd(); + $inbox->selectAdd('notice_id'); + + Notice::addWhereSinceId($inbox, $since_id, 'notice_id'); + Notice::addWhereMaxId($inbox, $max_id, 'notice_id'); + + $inbox->orderBy('created DESC, notice_id DESC'); + + if (!is_null($offset)) { + $inbox->limit($offset, $limit); + } + + $ids = array(); + + if ($inbox->find()) { + while ($inbox->fetch()) { + $ids[] = $inbox->notice_id; + } + } + + return $ids; + } +} From 5f591e05ae6238fed4a9577bdbc2949480d17db4 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 14:57:48 +0200 Subject: [PATCH 214/726] Update translator documentation. i18n/L10n fixes. Superfluous whitespace removed. onPluginVersion() added where missing. --- plugins/APC/APCPlugin.php | 4 +--- plugins/AccountManager/AccountManagerPlugin.php | 1 + plugins/Adsense/adsenseadminpanel.php | 2 ++ plugins/ApiLogger/ApiLoggerPlugin.php | 12 ++++++++++++ plugins/Autocomplete/AutocompletePlugin.php | 1 + plugins/Autocomplete/autocomplete.php | 3 ++- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/plugins/APC/APCPlugin.php b/plugins/APC/APCPlugin.php index 0069779004..851a4b4abc 100644 --- a/plugins/APC/APCPlugin.php +++ b/plugins/APC/APCPlugin.php @@ -60,7 +60,6 @@ class APCPlugin extends Plugin * * @return boolean hook success */ - function onStartCacheGet(&$key, &$value) { $value = apc_fetch($key); @@ -79,7 +78,6 @@ class APCPlugin extends Plugin * * @return boolean hook success */ - function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success) { $success = apc_store($key, $value, ((is_null($expiry)) ? 0 : $expiry)); @@ -97,7 +95,6 @@ class APCPlugin extends Plugin * * @return boolean hook success */ - function onStartCacheDelete(&$key, &$success) { $success = apc_delete($key); @@ -112,6 +109,7 @@ class APCPlugin extends Plugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:APC', 'rawdescription' => + // TRANS: Plugin description. _m('Use the APC variable cache to cache query results.')); return true; } diff --git a/plugins/AccountManager/AccountManagerPlugin.php b/plugins/AccountManager/AccountManagerPlugin.php index 9563252c73..3b399af8c8 100644 --- a/plugins/AccountManager/AccountManagerPlugin.php +++ b/plugins/AccountManager/AccountManagerPlugin.php @@ -107,6 +107,7 @@ class AccountManagerPlugin extends Plugin 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:AccountManager', 'rawdescription' => + // TRANS: Plugin description. _m('The Account Manager plugin implements the Account Manager specification.')); return true; } diff --git a/plugins/Adsense/adsenseadminpanel.php b/plugins/Adsense/adsenseadminpanel.php index 224c82b2fc..8a5c0cf07e 100644 --- a/plugins/Adsense/adsenseadminpanel.php +++ b/plugins/Adsense/adsenseadminpanel.php @@ -49,6 +49,7 @@ class AdsenseadminpanelAction extends AdminPanelAction */ function title() { + // TRANS: Title of AdSense administrator panel. return _m('TITLE', 'AdSense'); } @@ -59,6 +60,7 @@ class AdsenseadminpanelAction extends AdminPanelAction */ function getInstructions() { + // TRANS: Instructions for AdSense administrator panel. return _m('AdSense settings for this StatusNet site'); } diff --git a/plugins/ApiLogger/ApiLoggerPlugin.php b/plugins/ApiLogger/ApiLoggerPlugin.php index deb54008e5..a35fce7c55 100644 --- a/plugins/ApiLogger/ApiLoggerPlugin.php +++ b/plugins/ApiLogger/ApiLoggerPlugin.php @@ -74,4 +74,16 @@ class ApiLoggerPlugin extends Plugin } return true; } + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'ApiLogger', + 'version' => STATUSNET_VERSION, + 'author' => 'Brion Vibber', + 'homepage' => 'http://status.net/wiki/Plugin:ApiLogger', + 'rawdescription' => + // TRANS: Plugin description. + _m('Logging of API requests.')); + return true; + } } diff --git a/plugins/Autocomplete/AutocompletePlugin.php b/plugins/Autocomplete/AutocompletePlugin.php index 1479ead602..9a015dd704 100644 --- a/plugins/Autocomplete/AutocompletePlugin.php +++ b/plugins/Autocomplete/AutocompletePlugin.php @@ -79,6 +79,7 @@ class AutocompletePlugin extends Plugin 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:Autocomplete', 'rawdescription' => + // TRANS: Plugin description. _m('The autocomplete plugin allows users to autocomplete screen names in @ replies. When an "@" is typed into the notice text area, an autocomplete box is displayed populated with the user\'s friend\' screen names.')); return true; } diff --git a/plugins/Autocomplete/autocomplete.php b/plugins/Autocomplete/autocomplete.php index e15e95ec19..0bb1b783db 100644 --- a/plugins/Autocomplete/autocomplete.php +++ b/plugins/Autocomplete/autocomplete.php @@ -94,7 +94,8 @@ class AutocompleteAction extends Action $cur = common_current_user(); if (!$cur) { - throw new ClientException('Access forbidden', true); + // TRANS: Client exception in autocomplete plugin. + throw new ClientException(_m('Access forbidden.'), true); } $this->groups=array(); $this->users=array(); From e25cb9b57009e6ac0010f20b9f14374d33acff47 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 15:07:23 +0200 Subject: [PATCH 215/726] Shorten plugin description. --- plugins/Autocomplete/AutocompletePlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Autocomplete/AutocompletePlugin.php b/plugins/Autocomplete/AutocompletePlugin.php index 9a015dd704..39b933afd9 100644 --- a/plugins/Autocomplete/AutocompletePlugin.php +++ b/plugins/Autocomplete/AutocompletePlugin.php @@ -80,7 +80,7 @@ class AutocompletePlugin extends Plugin 'homepage' => 'http://status.net/wiki/Plugin:Autocomplete', 'rawdescription' => // TRANS: Plugin description. - _m('The autocomplete plugin allows users to autocomplete screen names in @ replies. When an "@" is typed into the notice text area, an autocomplete box is displayed populated with the user\'s friend\' screen names.')); + _m('The autocomplete plugin adds autocompletion for @ replies.')); return true; } } From cc78aca0d2db7c58ee4433d6ecb0a57d54ef5d8a Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 15:08:39 +0200 Subject: [PATCH 216/726] L10n and whitespace updates. --- plugins/AnonymousFave/AnonymousFavePlugin.php | 4 ++-- plugins/AnonymousFave/Fave_tally.php | 6 +++--- plugins/AnonymousFave/anonfavor.php | 2 +- plugins/ApiLogger/ApiLoggerPlugin.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/AnonymousFave/AnonymousFavePlugin.php b/plugins/AnonymousFave/AnonymousFavePlugin.php index 917f5a7e8c..af6ea20bd3 100644 --- a/plugins/AnonymousFave/AnonymousFavePlugin.php +++ b/plugins/AnonymousFave/AnonymousFavePlugin.php @@ -235,7 +235,7 @@ class AnonymousFavePlugin extends Plugin if (!$id) { // TRANS: Server exception. - throw new ServerException(_m("Couldn't create anonymous user session.")); + throw new ServerException(_m("Could not create anonymous user session.")); } // Stick the Profile ID into the nickname @@ -246,7 +246,7 @@ class AnonymousFavePlugin extends Plugin if (!$result) { // TRANS: Server exception. - throw new ServerException(_m("Couldn't create anonymous user session.")); + throw new ServerException(_m("Could not create anonymous user session.")); } common_log( diff --git a/plugins/AnonymousFave/Fave_tally.php b/plugins/AnonymousFave/Fave_tally.php index f48a1e82b3..7a44c2350d 100644 --- a/plugins/AnonymousFave/Fave_tally.php +++ b/plugins/AnonymousFave/Fave_tally.php @@ -152,7 +152,7 @@ class Fave_tally extends Memcached_DataObject $msg = sprintf( // TRANS: Server exception. // TRANS: %d is the notice ID (number). - _m("Couldn't update favorite tally for notice ID %d."), + _m("Could not update favorite tally for notice ID %d."), $noticeID ); throw new ServerException($msg); @@ -181,7 +181,7 @@ class Fave_tally extends Memcached_DataObject $msg = sprintf( // TRANS: Server exception. // TRANS: %d is the notice ID (number). - _m("Couldn't update favorite tally for notice ID %d."), + _m("Could not update favorite tally for notice ID %d."), $noticeID ); throw new ServerException($msg); @@ -212,7 +212,7 @@ class Fave_tally extends Memcached_DataObject $msg = sprintf( // TRANS: Server exception. // TRANS: %d is the notice ID (number). - _m("Couldn't create favorite tally for notice ID %d."), + _m("Could not create favorite tally for notice ID %d."), $noticeID ); throw new ServerException($msg); diff --git a/plugins/AnonymousFave/anonfavor.php b/plugins/AnonymousFave/anonfavor.php index ad13525a07..f20d55a863 100644 --- a/plugins/AnonymousFave/anonfavor.php +++ b/plugins/AnonymousFave/anonfavor.php @@ -57,7 +57,7 @@ class AnonFavorAction extends RedirectingAction if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error. - $this->clientError( _m('Could not favor notice! Please make sure your browser has cookies enabled.') + $this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.') ); return; } diff --git a/plugins/ApiLogger/ApiLoggerPlugin.php b/plugins/ApiLogger/ApiLoggerPlugin.php index a35fce7c55..bea78f78a3 100644 --- a/plugins/ApiLogger/ApiLoggerPlugin.php +++ b/plugins/ApiLogger/ApiLoggerPlugin.php @@ -83,7 +83,7 @@ class ApiLoggerPlugin extends Plugin 'homepage' => 'http://status.net/wiki/Plugin:ApiLogger', 'rawdescription' => // TRANS: Plugin description. - _m('Logging of API requests.')); + _m('Allows random sampling of API requests.')); return true; } } From 1a91f8543850c94e56805ba3848a7d9ec0fc30d3 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 15:12:56 +0200 Subject: [PATCH 217/726] Tabs to spaces. --- plugins/Awesomeness/AwesomenessPlugin.php | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/Awesomeness/AwesomenessPlugin.php b/plugins/Awesomeness/AwesomenessPlugin.php index 31f8ea35f4..edcbe6660f 100644 --- a/plugins/Awesomeness/AwesomenessPlugin.php +++ b/plugins/Awesomeness/AwesomenessPlugin.php @@ -42,7 +42,7 @@ if (!defined('STATUSNET')) { class AwesomenessPlugin extends Plugin { - const VERSION = '0.0.42'; + const VERSION = '0.0.42'; public function onPluginVersion(&$versions) { @@ -72,22 +72,22 @@ class AwesomenessPlugin extends Plugin $action->elementStart('div', array('id' => 'cornify_section', 'class' => 'section')); - $action->raw( - << - Cornify - - EOT - ); + ); - $action->elementEnd('div'); + $action->elementEnd('div'); } /** @@ -102,7 +102,7 @@ EOT */ function onStartSaveNewNoticeWeb($action, $user, &$content, &$options) { - $content = htmlspecialchars($content); - $options['rendered'] = preg_replace("/(^|\s|-)((?:awesome|awesomeness)[\?!\.\,]?)(\s|$)/i", " $2 ", $content); + $content = htmlspecialchars($content); + $options['rendered'] = preg_replace("/(^|\s|-)((?:awesome|awesomeness)[\?!\.\,]?)(\s|$)/i", " $2 ", $content); } } From 5b660bd3c60575922267ed072ac4d0228b04c2e6 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 15:36:03 +0200 Subject: [PATCH 218/726] Update translator documentation. i18n/L10n fixes. Superfluous whitespace removed. --- plugins/AutoSandbox/AutoSandboxPlugin.php | 9 ++++--- plugins/BitlyUrl/BitlyUrlPlugin.php | 8 +++++-- plugins/BitlyUrl/bitlyadminpanelaction.php | 28 ++++++++++++---------- plugins/Blacklist/BlacklistPlugin.php | 17 ++++++------- plugins/Blacklist/blacklistadminpanel.php | 18 ++++++++++---- 5 files changed, 49 insertions(+), 31 deletions(-) diff --git a/plugins/AutoSandbox/AutoSandboxPlugin.php b/plugins/AutoSandbox/AutoSandboxPlugin.php index 16683e1402..ebdc613243 100644 --- a/plugins/AutoSandbox/AutoSandboxPlugin.php +++ b/plugins/AutoSandbox/AutoSandboxPlugin.php @@ -63,21 +63,24 @@ class AutoSandboxPlugin extends Plugin 'author' => 'Sean Carmody', 'homepage' => 'http://status.net/wiki/Plugin:AutoSandbox', 'rawdescription' => + // TRANS: Plugin description. _m('Automatically sandboxes newly registered members.')); return true; } function onStartRegistrationFormData($action) { + // TRANS: User instructions after registration. $instr = _m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline.'); if (isset($this->contact)) { $contactuser = User::staticGet('nickname', $this->contact); if (!empty($contactuser)) { $contactlink = "@uri\">$contactuser->nickname"; - // TRANS: $contactlink is a clickable e-mailaddress. - $instr = _m("Note you will initially be \"sandboxed\" so your posts will not appear in the public timeline. ". - 'Send a message to $contactlink to speed up the unsandboxing process.'); + // TRANS: User instructions after registration. + // TRANS: %s is a clickable e-mailaddress. + $instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. '. + 'Send a message to %s to speed up the unsandboxing process.'),$contactlink); } } diff --git a/plugins/BitlyUrl/BitlyUrlPlugin.php b/plugins/BitlyUrl/BitlyUrlPlugin.php index 8e8bf8d46e..24a260ec40 100644 --- a/plugins/BitlyUrl/BitlyUrlPlugin.php +++ b/plugins/BitlyUrl/BitlyUrlPlugin.php @@ -43,7 +43,8 @@ class BitlyUrlPlugin extends UrlShortenerPlugin function onInitializePlugin(){ parent::onInitializePlugin(); if(!isset($this->serviceUrl)){ - throw new Exception(_m("You must specify a serviceUrl for bit.ly shortening.")); + // TRANS: Exception thrown when bit.ly URL shortening plugin was configured incorrectly. + throw new Exception(_m('You must specify a serviceUrl for bit.ly URL shortening.')); } } @@ -170,6 +171,7 @@ class BitlyUrlPlugin extends UrlShortenerPlugin 'author' => 'Craig Andrews, Brion Vibber', 'homepage' => 'http://status.net/wiki/Plugin:BitlyUrl', 'rawdescription' => + // TRANS: Plugin description. %1$s is the URL shortening service base URL (for example "bit.ly"). sprintf(_m('Uses %1$s URL-shortener service.'), $this->shortenerName)); @@ -211,8 +213,10 @@ class BitlyUrlPlugin extends UrlShortenerPlugin $action_name = $nav->action->trimmed('action'); $nav->out->menuItem(common_local_url('bitlyadminpanel'), + // TRANS: Menu item in administration menus for bit.ly URL shortening settings. _m('bit.ly'), - _m('bit.ly URL shortening'), + // TRANS: Title for menu item in administration menus for bit.ly URL shortening settings. + _m('bit.ly URL shortening.'), $action_name == 'bitlyadminpanel', 'nav_bitly_admin_panel'); } diff --git a/plugins/BitlyUrl/bitlyadminpanelaction.php b/plugins/BitlyUrl/bitlyadminpanelaction.php index 70cb664b84..53e0ec9f21 100644 --- a/plugins/BitlyUrl/bitlyadminpanelaction.php +++ b/plugins/BitlyUrl/bitlyadminpanelaction.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class BitlyadminpanelAction extends AdminPanelAction { /** @@ -48,9 +47,9 @@ class BitlyadminpanelAction extends AdminPanelAction * * @return string page title */ - function title() { + // TRANS: Title of administration panel. return _m('bit.ly URL shortening'); } @@ -59,9 +58,10 @@ class BitlyadminpanelAction extends AdminPanelAction * * @return string instructions */ - function getInstructions() { + // TRANS: Instructions for administration panel. + // TRANS: This message contains Markdown links in the form [decsription](link). return _m('URL shortening with bit.ly requires ' . '[a bit.ly account and API key](http://bit.ly/a/your_api_key). ' . 'This verifies that this is an authorized account, and ' . @@ -73,7 +73,6 @@ class BitlyadminpanelAction extends AdminPanelAction * * @return void */ - function showForm() { $form = new BitlyAdminPanelForm($this); @@ -86,7 +85,6 @@ class BitlyadminpanelAction extends AdminPanelAction * * @return void */ - function saveSettings() { static $settings = array( @@ -129,13 +127,15 @@ class BitlyadminpanelAction extends AdminPanelAction if (mb_strlen($values['bitly']['default_apikey']) > 255) { $this->clientError( - _m("Invalid login. Max length is 255 characters.") + // TRANS: Client error displayed when using too long a key. + _m('Invalid login. Maximum length is 255 characters.') ); } if (mb_strlen($values['bitly']['default_apikey']) > 255) { $this->clientError( - _m("Invalid API key. Max length is 255 characters.") + // TRANS: Client error displayed when using too long a key. + _m('Invalid API key. Maximum length is 255 characters.') ); } } @@ -148,7 +148,6 @@ class BitlyAdminPanelForm extends AdminForm * * @return int ID of the form */ - function id() { return 'bitlyadminpanel'; @@ -159,7 +158,6 @@ class BitlyAdminPanelForm extends AdminForm * * @return string class of the form */ - function formClass() { return 'form_settings'; @@ -170,7 +168,6 @@ class BitlyAdminPanelForm extends AdminForm * * @return string URL of the action */ - function action() { return common_local_url('bitlyadminpanel'); @@ -181,14 +178,14 @@ class BitlyAdminPanelForm extends AdminForm * * @return void */ - function formData() { $this->out->elementStart( 'fieldset', array('id' => 'settings_bitly') ); - $this->out->element('legend', null, _m('Credentials')); + // TRANS: Fieldset legend in administration panel for bit.ly username and API key. + $this->out->element('legend', null, _m('LEGEND','Credentials')); // Do we have global defaults to fall back on? $login = $apiKey = false; @@ -196,9 +193,11 @@ class BitlyAdminPanelForm extends AdminForm $haveGlobalDefaults = ($login && $apiKey); if ($login && $apiKey) { $this->out->element('p', 'form_guide', + // TRANS: Form guide in administration panel for bit.ly URL shortening. _m('Leave these empty to use global default credentials.')); } else { $this->out->element('p', 'form_guide', + // TRANS: Form guide in administration panel for bit.ly URL shortening. _m('If you leave these empty, bit.ly will be unavailable to users.')); } $this->out->elementStart('ul', 'form_data'); @@ -206,6 +205,7 @@ class BitlyAdminPanelForm extends AdminForm $this->li(); $this->input( 'default_login', + // TRANS: Field label in administration panel for bit.ly URL shortening. _m('Login name'), null, 'bitly' @@ -215,6 +215,7 @@ class BitlyAdminPanelForm extends AdminForm $this->li(); $this->input( 'default_apikey', + // TRANS: Field label in administration panel for bit.ly URL shortening. _m('API key'), null, 'bitly' @@ -230,13 +231,14 @@ class BitlyAdminPanelForm extends AdminForm * * @return void */ - function formActions() { $this->out->submit('submit', + // TRANS: Button text to save setting in administration panel for bit.ly URL shortening. _m('BUTTON','Save'), 'submit', null, + // TRANS: Button title to save setting in administration panel for bit.ly URL shortening. _m('Save bit.ly settings')); } } diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php index 855263b5e0..6bfd4f4089 100644 --- a/plugins/Blacklist/BlacklistPlugin.php +++ b/plugins/Blacklist/BlacklistPlugin.php @@ -126,7 +126,7 @@ class BlacklistPlugin extends Plugin } else if (is_string($config)) { return explode("\r\n", $config); } else { - throw new Exception("Unknown data type for config $section + $setting"); + throw new Exception(sprintf(_m('Unknown data type for config %1$s + %2$s.'),$section, $setting)); } } @@ -340,6 +340,7 @@ class BlacklistPlugin extends Plugin 'homepage' => 'http://status.net/wiki/Plugin:Blacklist', 'description' => + // TRANS: Plugin description. _m('Keeps a blacklist of forbidden nickname '. 'and URL patterns.')); return true; @@ -380,7 +381,7 @@ class BlacklistPlugin extends Plugin // TRANS: Menu item in admin panel. _m('MENU','Blacklist'), // TRANS: Tooltip for menu item in admin panel. - _m('TOOLTIP','Blacklist configuration'), + _m('TOOLTIP','Blacklist configuration.'), $action_name == 'blacklistadminpanel', 'nav_blacklist_admin_panel'); } @@ -406,7 +407,7 @@ class BlacklistPlugin extends Plugin $action->elementStart('li'); $this->checkboxAndText($action, 'blacklistnickname', - // TRANS: Checkbox with text label in the delete user form. + // TRANS: Checkbox label in the blacklist user form. _m('Add this nickname pattern to blacklist'), 'blacklistnicknamepattern', $this->patternizeNickname($user->nickname)); @@ -416,7 +417,7 @@ class BlacklistPlugin extends Plugin $action->elementStart('li'); $this->checkboxAndText($action, 'blacklisthomepage', - // TRANS: Checkbox with text label in the delete user form. + // TRANS: Checkbox label in the blacklist user form. _m('Add this homepage pattern to blacklist'), 'blacklisthomepagepattern', $this->patternizeHomepage($profile->homepage)); @@ -496,7 +497,7 @@ class BlacklistPlugin extends Plugin if (!empty($homepage)) { if (!$this->_checkUrl($homepage)) { // TRANS: Exception thrown trying to post a notice while having set a blocked homepage URL. %s is the blocked URL. - $msg = sprintf(_m("Users from \"%s\" blocked."), + $msg = sprintf(_m("Users from \"%s\" are blocked."), $homepage); throw new ClientException($msg); } @@ -507,7 +508,7 @@ class BlacklistPlugin extends Plugin if (!empty($nickname)) { if (!$this->_checkNickname($nickname)) { // TRANS: Exception thrown trying to post a notice while having a blocked nickname. %s is the blocked nickname. - $msg = sprintf(_m("Posts from nickname \"%s\" disallowed."), + $msg = sprintf(_m("Notices from nickname \"%s\" disallowed."), $nickname); throw new ClientException($msg); } @@ -531,7 +532,7 @@ class BlacklistPlugin extends Plugin if (!$this->_checkUrl($url)) { // TRANS: Client exception thrown trying to subscribe to a person with a blocked homepage or site URL. %s is the blocked URL. - $msg = sprintf(_m("Users from \"%s\" blocked."), + $msg = sprintf(_m("Users from \"%s\" are blocked."), $url); throw new ClientException($msg); } @@ -542,7 +543,7 @@ class BlacklistPlugin extends Plugin if (!empty($nickname)) { if (!$this->_checkNickname($nickname)) { // TRANS: Client exception thrown trying to subscribe to a person with a blocked nickname. %s is the blocked nickname. - $msg = sprintf(_m("Can't subscribe to nickname \"%s\"."), + $msg = sprintf(_m("Cannot subscribe to nickname \"%s\"."), $nickname); throw new ClientException($msg); } diff --git a/plugins/Blacklist/blacklistadminpanel.php b/plugins/Blacklist/blacklistadminpanel.php index 9019bb9ad2..ee1c2138b8 100644 --- a/plugins/Blacklist/blacklistadminpanel.php +++ b/plugins/Blacklist/blacklistadminpanel.php @@ -49,7 +49,8 @@ class BlacklistadminpanelAction extends AdminPanelAction */ function title() { - return _m('Blacklist'); + // TRANS: Title of blacklist plugin administration panel. + return _m('TITLE','Blacklist'); } /** @@ -59,6 +60,7 @@ class BlacklistadminpanelAction extends AdminPanelAction */ function getInstructions() { + // TRANS: Instructions for blacklist plugin administration panel. return _m('Blacklisted URLs and nicknames'); } @@ -171,17 +173,21 @@ class BlacklistAdminPanelForm extends Form $nickPatterns = Nickname_blacklist::getPatterns(); + // TRANS: Field label in blacklist plugin administration panel. $this->out->textarea('blacklist-nicknames', _m('Nicknames'), implode("\r\n", $nickPatterns), - _m('Patterns of nicknames to block, one per line')); + // TRANS: Field title in blacklist plugin administration panel. + _m('Patterns of nicknames to block, one per line.')); $this->out->elementEnd('li'); $urlPatterns = Homepage_blacklist::getPatterns(); $this->out->elementStart('li'); + // TRANS: Field label in blacklist plugin administration panel. $this->out->textarea('blacklist-urls', _m('URLs'), implode("\r\n", $urlPatterns), - _m('Patterns of URLs to block, one per line')); + // TRANS: Field title in blacklist plugin administration panel. + _m('Patterns of URLs to block, one per line.')); $this->out->elementEnd('li'); $this->out->elementEnd('ul'); @@ -195,9 +201,11 @@ class BlacklistAdminPanelForm extends Form function formActions() { $this->out->submit('submit', - _m('Save'), + // TRANS: Button text in blacklist plugin administration panel to save settings. + _m('BUTTON','Save'), 'submit', null, - _m('Save site settings')); + // TRANS: Button title in blacklist plugin administration panel to save settings. + _m('Save site settings.')); } } From b85c4923a21c9082bb14ed2edf24c8b8c827f0a3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 10:25:59 -0400 Subject: [PATCH 219/726] Remove unused and non-standard USER_AGENT constant from File_redirection --- classes/File_redirection.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 1096f500bf..74e89db5f2 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -23,8 +23,6 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; require_once INSTALLDIR.'/classes/File.php'; require_once INSTALLDIR.'/classes/File_oembed.php'; -define('USER_AGENT', 'StatusNet user agent / file probe'); - /** * Table Definition for file_redirection */ From 553a0c8b9bd23e4560f05306d0f76072d215a4a4 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 16:36:35 +0200 Subject: [PATCH 220/726] i18n/L10n updates/fixes. Translator documentation added/updated. Whitespace updates. --- plugins/BlankAd/BlankAdPlugin.php | 1 + plugins/BlogspamNet/BlogspamNetPlugin.php | 13 +++- plugins/Bookmark/Bookmark.php | 27 +++----- plugins/Bookmark/BookmarkPlugin.php | 46 +++++-------- plugins/Bookmark/bookmarkform.php | 31 +++++---- plugins/Bookmark/bookmarkpopup.php | 14 ++-- plugins/Bookmark/deliciousbackupimporter.php | 20 +++--- .../Bookmark/deliciousbookmarkimporter.php | 7 +- plugins/Bookmark/importbookmarks.php | 20 ++++-- plugins/Bookmark/importdelicious.php | 68 ++++++++++--------- plugins/Bookmark/newbookmark.php | 20 +++--- plugins/Bookmark/noticebyurl.php | 22 +++--- plugins/Bookmark/showbookmark.php | 1 - 13 files changed, 140 insertions(+), 150 deletions(-) diff --git a/plugins/BlankAd/BlankAdPlugin.php b/plugins/BlankAd/BlankAdPlugin.php index 9128e7bcdb..1205cc0f7e 100644 --- a/plugins/BlankAd/BlankAdPlugin.php +++ b/plugins/BlankAd/BlankAdPlugin.php @@ -124,6 +124,7 @@ class BlankAdPlugin extends UAPPlugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:BlankAdPlugin', 'rawdescription' => + // TRANS: Plugin description. _m('Plugin for testing ad layout.')); return true; } diff --git a/plugins/BlogspamNet/BlogspamNetPlugin.php b/plugins/BlogspamNet/BlogspamNetPlugin.php index 06198e6c54..edb9406d9a 100644 --- a/plugins/BlogspamNet/BlogspamNetPlugin.php +++ b/plugins/BlogspamNet/BlogspamNetPlugin.php @@ -82,13 +82,19 @@ class BlogspamNetPlugin extends Plugin } else { common_debug("Blogspamnet results = " . $response); if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) { - throw new ServerException(sprintf(_m("Error from %1$s: %2$s"), $this->baseUrl, $match[2]), 500); + // TRANS: Server exception thrown when blogspam.net returns error status. + // TRANS: %1$s is the base URL, %2$s is the error (unknown contents; no period). + throw new ServerException(sprintf(_m('Error from %1$s: %2$s'), $this->baseUrl, $match[2]), 500); } else if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) { - throw new ClientException(sprintf(_m("Spam checker results: %s"), $match[2]), 400); + // TRANS: Server exception thrown when blogspam.net returns spam status. + // TRANS: Does not end with period because of unknown contents for %s (spam match). + throw new ClientException(sprintf(_m('Spam checker results: %s'), $match[2]), 400); } else if (preg_match('/^OK$/', $response)) { // don't do anything } else { - throw new ServerException(sprintf(_m("Unexpected response from %1$s: %2$s"), $this->baseUrl, $response), 500); + // TRANS: Server exception thrown when blogspam.net returns an unexpected status. + // TRANS: %1$s is the base URL, %2$s is the response (unknown contents; no period). + throw new ServerException(sprintf(_m('Unexpected response from %1$s: %2$s'), $this->baseUrl, $response), 500); } } return true; @@ -149,6 +155,7 @@ class BlogspamNetPlugin extends Plugin 'author' => 'Evan Prodromou, Brion Vibber', 'homepage' => 'http://status.net/wiki/Plugin:BlogspamNet', 'rawdescription' => + // TRANS: Plugin description. _m('Plugin to check submitted notices with blogspam.net.')); return true; } diff --git a/plugins/Bookmark/Bookmark.php b/plugins/Bookmark/Bookmark.php index 9ae4f7cfc6..66c451c5c8 100644 --- a/plugins/Bookmark/Bookmark.php +++ b/plugins/Bookmark/Bookmark.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET')) { * * @see DB_DataObject */ - class Bookmark extends Memcached_DataObject { public $__table = 'bookmark'; // table name @@ -65,7 +64,6 @@ class Bookmark extends Memcached_DataObject * @return User_greeting_count object found, or null for no hits * */ - function staticGet($k, $v=null) { return Memcached_DataObject::staticGet('Bookmark', $k, $v); @@ -83,7 +81,6 @@ class Bookmark extends Memcached_DataObject * @return Bookmark object found, or null for no hits * */ - function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Bookmark', $kv); @@ -97,7 +94,6 @@ class Bookmark extends Memcached_DataObject * * @return array array of column definitions */ - function table() { return array('id' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL, @@ -106,7 +102,7 @@ class Bookmark extends Memcached_DataObject 'title' => DB_DATAOBJECT_STR, 'description' => DB_DATAOBJECT_STR, 'uri' => DB_DATAOBJECT_STR, - 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + + 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL); } @@ -115,7 +111,6 @@ class Bookmark extends Memcached_DataObject * * @return array list of key field names */ - function keys() { return array_keys($this->keyTypes()); @@ -126,7 +121,6 @@ class Bookmark extends Memcached_DataObject * * @return array associative array of key definitions */ - function keyTypes() { return array('id' => 'K', @@ -138,7 +132,6 @@ class Bookmark extends Memcached_DataObject * * @return array magic three-false array that stops auto-incrementing. */ - function sequenceKey() { return array(false, false, false); @@ -146,12 +139,11 @@ class Bookmark extends Memcached_DataObject /** * Get a bookmark based on a notice - * + * * @param Notice $notice Notice to check for * * @return Bookmark found bookmark or null */ - function getByNotice($notice) { return self::staticGet('uri', $notice->uri); @@ -165,11 +157,10 @@ class Bookmark extends Memcached_DataObject * * @return Bookmark bookmark found or null */ - static function getByURL($profile, $url) { $nb = new Bookmark(); - + $nb->profile_id = $profile->id; $nb->url = $url; @@ -192,13 +183,13 @@ class Bookmark extends Memcached_DataObject * * @return Notice saved notice */ - static function saveNew($profile, $title, $url, $rawtags, $description, $options=null) { $nb = self::getByURL($profile, $url); if (!empty($nb)) { + // TRANS: Client exception thrown when trying to save a new bookmark that already exists. throw new ClientException(_m('Bookmark already exists.')); } @@ -209,6 +200,7 @@ class Bookmark extends Memcached_DataObject if (array_key_exists('uri', $options)) { $other = Bookmark::staticGet('uri', $options['uri']); if (!empty($other)) { + // TRANS: Client exception thrown when trying to save a new bookmark that already exists. throw new ClientException(_m('Bookmark already exists.')); } } @@ -281,15 +273,15 @@ class Bookmark extends Memcached_DataObject try { $user = User::staticGet('id', $profile->id); - $shortUrl = File_redirection::makeShort($url, + $shortUrl = File_redirection::makeShort($url, empty($user) ? null : $user); } catch (Exception $e) { // Don't let this stop us. $shortUrl = $url; } - // @todo FIXME: i18n documentation. - // TRANS: %1$s is a title, %2$s is a short URL, %3$s is a description, + // TRANS: Bookmark content. + // TRANS: %1$s is a title, %2$s is a short URL, %3$s is the bookmark description, // TRANS: %4$s is space separated list of hash tags. $content = sprintf(_m('"%1$s" %2$s %3$s %4$s'), $title, @@ -297,6 +289,9 @@ class Bookmark extends Memcached_DataObject $description, implode(' ', $hashtags)); + // TRANS: Rendered bookmark content. + // TRANS: %1$s is a URL, %2$s the bookmark title, %3$s is the bookmark description, + // TRANS: %4$s is space separated list of hash tags. $rendered = sprintf(_m(''. '%2$s '. '%3$s '. diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index daefa12c39..b8e86e3aa8 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -43,7 +43,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class BookmarkPlugin extends MicroAppPlugin { const VERSION = '0.1'; @@ -60,7 +59,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value */ - function onUserRightsCheck($profile, $right, &$result) { if ($right == self::IMPORTDELICIOUS) { @@ -78,7 +76,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value; true means continue processing, false means stop. */ - function onCheckSchema() { $schema = Schema::get(); @@ -127,7 +124,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value */ - function onEndShowStyles($action) { $action->cssLink($this->path('bookmark.css')); @@ -141,7 +137,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value; true means continue processing, false means stop. */ - function onAutoload($cls) { $dir = dirname(__FILE__); @@ -175,7 +170,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value; true means continue processing, false means stop. */ - function onRouterInitialized($m) { $m->connect('main/bookmark/new', @@ -204,10 +198,9 @@ class BookmarkPlugin extends MicroAppPlugin * Add our two queue handlers to the queue manager * * @param QueueManager $qm current queue manager - * + * * @return boolean hook value */ - function onEndInitializeQueueManager($qm) { $qm->connect('dlcsback', 'DeliciousBackupImporter'); @@ -219,10 +212,9 @@ class BookmarkPlugin extends MicroAppPlugin * Plugin version data * * @param array &$versions array of version data - * + * * @return value */ - function onPluginVersion(&$versions) { $versions[] = array('name' => 'Sample', @@ -230,6 +222,7 @@ class BookmarkPlugin extends MicroAppPlugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Bookmark', 'rawdescription' => + // TRANS: Plugin description. _m('Simple extension for supporting bookmarks.')); return true; } @@ -242,7 +235,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value */ - function onStartLoadDoc(&$title, &$output) { if ($title == 'bookmarklet') { @@ -256,8 +248,6 @@ class BookmarkPlugin extends MicroAppPlugin return true; } - - /** * Show a link to our delicious import page on profile settings form * @@ -265,15 +255,15 @@ class BookmarkPlugin extends MicroAppPlugin * * @return boolean hook value */ - function onEndProfileSettingsActions($action) { $user = common_current_user(); - + if (!empty($user) && $user->hasRight(self::IMPORTDELICIOUS)) { $action->elementStart('li'); $action->element('a', array('href' => common_local_url('importdelicious')), + // TRANS: Link text in proile leading to import form. _m('Import del.icio.us bookmarks')); $action->elementEnd('li'); } @@ -314,7 +304,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return Notice resulting notice. */ - static private function _postRemoteBookmark(Ostatus_profile $author, Activity $activity) { @@ -324,7 +313,7 @@ class BookmarkPlugin extends MicroAppPlugin 'url' => $bookmark->link, 'is_local' => Notice::REMOTE_OMB, 'source' => 'ostatus'); - + return self::_postBookmark($author->localProfile(), $activity, $options); } @@ -335,7 +324,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return true if it's a Post of a Bookmark, else false */ - static private function _isPostBookmark($activity) { return ($activity->verb == ActivityVerb::POST && @@ -351,10 +339,9 @@ class BookmarkPlugin extends MicroAppPlugin * When a notice is deleted, delete the related Bookmark * * @param Notice $notice Notice being deleted - * + * * @return boolean hook value */ - function deleteRelated($notice) { $nb = Bookmark::getByNotice($notice); @@ -375,7 +362,6 @@ class BookmarkPlugin extends MicroAppPlugin * * @return Notice resulting notice */ - function saveNoticeFromActivity($activity, $profile, $options=array()) { $bookmark = $activity->objects[0]; @@ -383,6 +369,7 @@ class BookmarkPlugin extends MicroAppPlugin $relLinkEls = ActivityUtils::getLinks($bookmark->element, 'related'); if (count($relLinkEls) < 1) { + // TRANS: Client exception thrown when a bookmark is formatted incorrectly. throw new ClientException(_m('Expected exactly 1 link '. 'rel=related in a Bookmark.')); } @@ -476,6 +463,7 @@ class BookmarkPlugin extends MicroAppPlugin $attachments = $notice->attachments(); if (count($attachments) != 1) { + // TRANS: Server exception thrown when a bookmark has multiple attachments. throw new ServerException(_m('Bookmark notice with the '. 'wrong number of attachments.')); } @@ -490,7 +478,7 @@ class BookmarkPlugin extends MicroAppPlugin } $object->extra[] = array('link', $attrs, null); - + // Attributes of the thumbnail, if any $thumbnail = $target->getThumbnail(); @@ -530,7 +518,8 @@ class BookmarkPlugin extends MicroAppPlugin if (count($atts) < 1) { // Something wrong; let default code deal with it. - throw new Exception("That can't be right."); + // TRANS: Exception thrown when a bookmark has no attachments. + throw new Exception(_m('Bookmark has no attachments.')); } $att = $atts[0]; @@ -562,7 +551,7 @@ class BookmarkPlugin extends MicroAppPlugin if (!empty($replies) || !empty($tags)) { $out->elementStart('ul', array('class' => 'bookmark-tags')); - + foreach ($replies as $reply) { $other = Profile::staticGet('id', $reply); $out->elementStart('li'); @@ -576,7 +565,7 @@ class BookmarkPlugin extends MicroAppPlugin foreach ($tags as $tag) { $out->elementStart('li'); - $out->element('a', + $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag); @@ -612,7 +601,7 @@ class BookmarkPlugin extends MicroAppPlugin $avatar = $profile->getAvatar(AVATAR_MINI_SIZE); - $out->element('img', + $out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE), @@ -624,7 +613,7 @@ class BookmarkPlugin extends MicroAppPlugin $out->raw(' '); // avoid   for AJAX XML compatibility $out->elementStart('span', 'vcard author'); // hack for belongsOnTimeline; JS needs to be able to find the author - $out->element('a', + $out->element('a', array('class' => 'url', 'href' => $profile->profileurl, 'title' => $profile->getBestName()), @@ -644,6 +633,7 @@ class BookmarkPlugin extends MicroAppPlugin function appTitle() { - return _m('Bookmark'); + // TRANS: Application title. + return _m('TITLE','Bookmark'); } } diff --git a/plugins/Bookmark/bookmarkform.php b/plugins/Bookmark/bookmarkform.php index ac7ca08f66..b1321a994b 100644 --- a/plugins/Bookmark/bookmarkform.php +++ b/plugins/Bookmark/bookmarkform.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Form for adding a new bookmark - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class BookmarkForm extends Form { private $_title = null; @@ -63,7 +62,6 @@ class BookmarkForm extends Form * * @return void */ - function __construct($out=null, $title=null, $url=null, $tags=null, $description=null) { @@ -80,7 +78,6 @@ class BookmarkForm extends Form * * @return int ID of the form */ - function id() { return 'form_new_bookmark'; @@ -91,7 +88,6 @@ class BookmarkForm extends Form * * @return string class of the form */ - function formClass() { return 'form_settings ajax-notice'; @@ -102,7 +98,6 @@ class BookmarkForm extends Form * * @return string URL of the action */ - function action() { return common_local_url('newbookmark'); @@ -113,7 +108,6 @@ class BookmarkForm extends Form * * @return void */ - function formData() { $this->out->elementStart('fieldset', array('id' => 'new_bookmark_data')); @@ -121,30 +115,38 @@ class BookmarkForm extends Form $this->li(); $this->out->input('title', + // TRANS: Field label on form for adding a new bookmark. _m('LABEL','Title'), $this->_title, - _m('Title of the bookmark')); + // TRANS: Field title on form for adding a new bookmark. + _m('Title of the bookmark.')); $this->unli(); $this->li(); $this->out->input('url', + // TRANS: Field label on form for adding a new bookmark. _m('LABEL','URL'), - $this->_url, - _m('URL to bookmark')); + $this->_url, + // TRANS: Field title on form for adding a new bookmark. + _m('URL to bookmark.')); $this->unli(); $this->li(); $this->out->input('tags', + // TRANS: Field label on form for adding a new bookmark. _m('LABEL','Tags'), - $this->_tags, - _m('Comma- or space-separated list of tags')); + $this->_tags, + // TRANS: Field title on form for adding a new bookmark. + _m('Comma- or space-separated list of tags.')); $this->unli(); $this->li(); $this->out->input('description', + // TRANS: Field label on form for adding a new bookmark. _m('LABEL','Description'), - $this->_description, - _m('Description of the URL')); + $this->_description, + // TRANS: Field title on form for adding a new bookmark. + _m('Description of the URL.')); $this->unli(); $this->out->elementEnd('ul'); @@ -165,6 +167,7 @@ class BookmarkForm extends Form function formActions() { + // TRANS: Button text for action to save a new bookmark. $this->out->submit('submit', _m('BUTTON', 'Save')); } } diff --git a/plugins/Bookmark/bookmarkpopup.php b/plugins/Bookmark/bookmarkpopup.php index f254557b81..3defe08d30 100644 --- a/plugins/Bookmark/bookmarkpopup.php +++ b/plugins/Bookmark/bookmarkpopup.php @@ -49,13 +49,12 @@ class BookmarkpopupAction extends NewbookmarkAction * * @return void */ - function showTitle() { - // TRANS: Title for mini-posting window loaded from bookmarklet. - // TRANS: %s is the StatusNet site name. - $this->element('title', - null, sprintf(_m('Bookmark on %s'), + $this->element('title', + // TRANS: Title for mini-posting window loaded from bookmarklet. + // TRANS: %s is the StatusNet site name. + null, sprintf(_m('Bookmark on %s'), common_config('site', 'name'))); } @@ -66,7 +65,6 @@ class BookmarkpopupAction extends NewbookmarkAction * * @return void */ - function showHeader() { $this->elementStart('div', array('id' => 'header')); @@ -86,10 +84,9 @@ class BookmarkpopupAction extends NewbookmarkAction /** * Hide the core section of the page - * + * * @return void */ - function showCore() { } @@ -99,7 +96,6 @@ class BookmarkpopupAction extends NewbookmarkAction * * @return void */ - function showFooter() { } diff --git a/plugins/Bookmark/deliciousbackupimporter.php b/plugins/Bookmark/deliciousbackupimporter.php index a8d2819fe7..1eb015f380 100644 --- a/plugins/Bookmark/deliciousbackupimporter.php +++ b/plugins/Bookmark/deliciousbackupimporter.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Importer class for Delicious.com backups - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class DeliciousBackupImporter extends QueueHandler { /** @@ -52,7 +51,6 @@ class DeliciousBackupImporter extends QueueHandler * * @return string transport string */ - function transport() { return 'dlcsback'; @@ -72,7 +70,6 @@ class DeliciousBackupImporter extends QueueHandler * * @return boolean success value */ - function handle($data) { list($user, $body) = $data; @@ -82,7 +79,8 @@ class DeliciousBackupImporter extends QueueHandler $dls = $doc->getElementsByTagName('dl'); if ($dls->length != 1) { - throw new ClientException(_m("Bad import file.")); + // TRANS: Client exception thrown when a file upload is incorrect. + throw new ClientException(_m('Bad import file.')); } $dl = $dls->item(0); @@ -123,7 +121,7 @@ class DeliciousBackupImporter extends QueueHandler common_log(LOG_INFO, 'Skipping the

                  in the

                  .'); break; default: - common_log(LOG_WARNING, + common_log(LOG_WARNING, "Unexpected element $child->tagName ". " found in import."); } @@ -146,12 +144,12 @@ class DeliciousBackupImporter extends QueueHandler /** * Import a single bookmark - * + * * Takes a
                  /
                  pair. The
                  has a single * in it with some non-standard attributes. - * + * * A
                  sequence will appear as a
                  with - * anothe
                  as a child. We handle this case recursively. + * anothe
                  as a child. We handle this case recursively. * * @param User $user User to import data as * @param DOMElement $dt
                  element @@ -159,12 +157,12 @@ class DeliciousBackupImporter extends QueueHandler * * @return Notice imported notice */ - function importBookmark($user, $dt, $dd = null) { $as = $dt->getElementsByTagName('a'); if ($as->length == 0) { + // TRANS: Client exception thrown when a bookmark in an import file is incorrectly formatted. throw new ClientException(_m("No tag in a
                  .")); } @@ -173,6 +171,7 @@ class DeliciousBackupImporter extends QueueHandler $private = $a->getAttribute('private'); if ($private != 0) { + // TRANS: Client exception thrown when a bookmark in an import file is private. throw new ClientException(_m('Skipping private bookmark.')); } @@ -306,5 +305,4 @@ class DeliciousBackupImporter extends QueueHandler $this->fixListItem($node); } } - } diff --git a/plugins/Bookmark/deliciousbookmarkimporter.php b/plugins/Bookmark/deliciousbookmarkimporter.php index 018239f49d..96fe621c2f 100644 --- a/plugins/Bookmark/deliciousbookmarkimporter.php +++ b/plugins/Bookmark/deliciousbookmarkimporter.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Importer class for Delicious.com bookmarks - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class DeliciousBookmarkImporter extends QueueHandler { /** @@ -52,7 +51,6 @@ class DeliciousBookmarkImporter extends QueueHandler * * @return string 'dlcsbkmk' */ - function transport() { return 'dlcsbkmk'; @@ -60,12 +58,11 @@ class DeliciousBookmarkImporter extends QueueHandler /** * Handle the data - * + * * @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark() * * @return boolean success value */ - function handle($data) { $profile = Profile::staticGet('id', $data['profile_id']); diff --git a/plugins/Bookmark/importbookmarks.php b/plugins/Bookmark/importbookmarks.php index e16cf9d633..c47a042973 100644 --- a/plugins/Bookmark/importbookmarks.php +++ b/plugins/Bookmark/importbookmarks.php @@ -4,7 +4,7 @@ * Copyright (C) 2010 StatusNet, Inc. * * Import a bookmarks file as notices - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -46,7 +46,7 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; /** * Get the bookmarks file as a string - * + * * Uses the -f or --file parameter to open and read a * a bookmarks file * @@ -63,19 +63,25 @@ function getBookmarksFile() } if (!file_exists($filename)) { - throw new Exception("No such file '$filename'."); + // TRANS: Exception thrown when a file upload cannot be found. + // TRANS: %s is the file that could not be found. + throw new Exception(sprintf(_m('No such file "%s".'),$filename)); } if (!is_file($filename)) { - throw new Exception("Not a regular file: '$filename'."); + // TRANS: Exception thrown when a file upload is incorrect. + // TRANS: %s is the irregular file. + throw new Exception(sprintf(_m('Not a regular file: "%s".'),$filename)); } if (!is_readable($filename)) { - throw new Exception("File '$filename' not readable."); + // TRANS: Exception thrown when a file upload is not readable. + // TRANS: %s is the file that could not be read. + throw new Exception(sprintf(_m('File "%s" not readable.'),$filename)); } // TRANS: %s is the filename that contains a backup for a user. - printfv(_m("Getting backup from file \"%s\".")."\n", $filename); + printfv(_m('Getting backup from file "%s".')."\n", $filename); $html = file_get_contents($filename); @@ -87,7 +93,7 @@ try { $html = getBookmarksFile(); $qm = QueueManager::get(); - + $qm->enqueue(array($user, $html), 'dlcsback'); } catch (Exception $e) { diff --git a/plugins/Bookmark/importdelicious.php b/plugins/Bookmark/importdelicious.php index 0d206e456d..85a63e8470 100644 --- a/plugins/Bookmark/importdelicious.php +++ b/plugins/Bookmark/importdelicious.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Import del.icio.us bookmarks backups - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class ImportdeliciousAction extends Action { protected $success = false; @@ -55,9 +54,9 @@ class ImportdeliciousAction extends Action * * @return string page title */ - function title() { + // TRANS: Title for page to import del.icio.us bookmark backups on. return _m("Import del.icio.us bookmarks"); } @@ -68,7 +67,6 @@ class ImportdeliciousAction extends Action * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); @@ -76,12 +74,14 @@ class ImportdeliciousAction extends Action $cur = common_current_user(); if (empty($cur)) { + // TRANS: Client exception thrown when trying to import bookmarks without being logged in. throw new ClientException(_m('Only logged-in users can '. 'import del.icio.us backups.'), 403); } if (!$cur->hasRight(BookmarkPlugin::IMPORTDELICIOUS)) { + // TRANS: Client exception thrown when trying to import bookmarks without having the rights to do so. throw new ClientException(_m('You may not restore your account.'), 403); } @@ -95,7 +95,6 @@ class ImportdeliciousAction extends Action * * @return void */ - function handle($argarray=null) { parent::handle($argarray); @@ -110,17 +109,17 @@ class ImportdeliciousAction extends Action /** * Queue a file for importation - * + * * Uses the DeliciousBackupImporter class; may take a long time! * * @return void */ - function importDelicious() { $this->checkSessionToken(); if (!isset($_FILES[ImportDeliciousForm::FILEINPUT]['error'])) { + // TRANS: Client exception thrown when trying to import bookmarks and upload fails. throw new ClientException(_m('No uploaded file.')); } @@ -134,36 +133,37 @@ class ImportdeliciousAction extends Action return; case UPLOAD_ERR_FORM_SIZE: throw new ClientException( - // TRANS: Client exception. + // TRANS: Client exception thrown when an uploaded file is too large. _m('The uploaded file exceeds the MAX_FILE_SIZE directive' . ' that was specified in the HTML form.')); return; case UPLOAD_ERR_PARTIAL: @unlink($_FILES[ImportDeliciousForm::FILEINPUT]['tmp_name']); - // TRANS: Client exception. + // TRANS: Client exception thrown when a file was only partially uploaded. throw new ClientException(_m('The uploaded file was only' . ' partially uploaded.')); return; case UPLOAD_ERR_NO_FILE: // No file; probably just a non-AJAX submission. + // TRANS: Client exception thrown when a file upload has failed. throw new ClientException(_m('No uploaded file.')); return; case UPLOAD_ERR_NO_TMP_DIR: - // TRANS: Client exception thrown when a temporary folder is not present + // TRANS: Client exception thrown when a temporary folder is not present. throw new ClientException(_m('Missing a temporary folder.')); return; case UPLOAD_ERR_CANT_WRITE: - // TRANS: Client exception thrown when writing to disk is not possible + // TRANS: Client exception thrown when writing to disk is not possible. throw new ClientException(_m('Failed to write file to disk.')); return; case UPLOAD_ERR_EXTENSION: - // TRANS: Client exception thrown when a file upload has been stopped + // TRANS: Client exception thrown when a file upload has been stopped. throw new ClientException(_m('File upload stopped by extension.')); return; default: common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . $_FILES[ImportDeliciousForm::FILEINPUT]['error']); - // TRANS: Client exception thrown when a file upload operation has failed + // TRANS: Client exception thrown when a file upload operation has failed. throw new ClientException(_m('System error uploading file.')); return; } @@ -172,18 +172,24 @@ class ImportdeliciousAction extends Action try { if (!file_exists($filename)) { - throw new ServerException("No such file '$filename'."); + // TRANS: Server exception thrown when a file upload cannot be found. + // TRANS: %s is the file that could not be found. + throw new ServerException(sprintf(_m('No such file "%s".'),$filename)); } - + if (!is_file($filename)) { - throw new ServerException("Not a regular file: '$filename'."); + // TRANS: Server exception thrown when a file upload is incorrect. + // TRANS: %s is the irregular file. + throw new ServerException(sprintf(_m('Not a regular file: "%s".'),$filename)); } - + if (!is_readable($filename)) { - throw new ServerException("File '$filename' not readable."); + // TRANS: Server exception thrown when a file upload is not readable. + // TRANS: %s is the file that could not be read. + throw new ServerException(sprintf(_m('File "%s" not readable.'),$filename)); } - - common_debug(sprintf(_m("Getting backup from file '%s'."), $filename)); + + common_debug(sprintf("Getting backup from file '%s'.", $filename)); $html = file_get_contents($filename); @@ -214,14 +220,15 @@ class ImportdeliciousAction extends Action * * @return void */ - function showContent() { if ($this->success) { $this->element('p', null, + // TRANS: Success message after importing bookmarks. _m('Bookmarks have been imported. Your bookmarks should now appear in search and your profile page.')); } else if ($this->inprogress) { $this->element('p', null, + // TRANS: Busy message for importing bookmarks. _m('Bookmarks are being imported. Please wait a few minutes for results.')); } else { $form = new ImportDeliciousForm($this); @@ -238,7 +245,6 @@ class ImportdeliciousAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { return !$this->isPost(); @@ -255,21 +261,19 @@ class ImportdeliciousAction extends Action * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class ImportDeliciousForm extends Form { const FILEINPUT = 'deliciousbackupfile'; /** * Constructor - * + * * Set the encoding type, since this is a file upload. * * @param HTMLOutputter $out output channel * * @return ImportDeliciousForm this */ - function __construct($out=null) { parent::__construct($out); @@ -281,7 +285,6 @@ class ImportDeliciousForm extends Form * * @return string the form's class */ - function formClass() { return 'form_import_delicious'; @@ -292,7 +295,6 @@ class ImportDeliciousForm extends Form * * @return string the form's action URL */ - function action() { return common_local_url('importdelicious'); @@ -300,19 +302,19 @@ class ImportDeliciousForm extends Form /** * Output form data - * + * * Really, just instructions for doing a backup. * * @return void */ - function formData() { $this->out->elementStart('p', 'instructions'); + // TRANS: Form instructions for importing bookmarks. $this->out->raw(_m('You can upload a backed-up '. 'delicious.com bookmarks file.')); - + $this->out->elementEnd('p'); $this->out->elementStart('ul', 'form_data'); @@ -328,7 +330,7 @@ class ImportDeliciousForm extends Form /** * Buttons for the form - * + * * In this case, a single submit button * * @return void @@ -337,9 +339,11 @@ class ImportDeliciousForm extends Form function formActions() { $this->out->submit('submit', + // TRANS: Button text on form to import bookmarks. _m('BUTTON', 'Upload'), 'submit', null, - _m('Upload the file')); + // TRANS: Button title on form to import bookmarks. + _m('Upload the file.')); } } diff --git a/plugins/Bookmark/newbookmark.php b/plugins/Bookmark/newbookmark.php index e24631b436..92e9bc81c5 100644 --- a/plugins/Bookmark/newbookmark.php +++ b/plugins/Bookmark/newbookmark.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Add a new bookmark - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -43,7 +43,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class NewbookmarkAction extends Action { protected $user = null; @@ -59,9 +58,9 @@ class NewbookmarkAction extends Action * * @return string Action title */ - function title() { + // TRANS: Title for action to create a new bookmark. return _m('New bookmark'); } @@ -72,7 +71,6 @@ class NewbookmarkAction extends Action * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); @@ -80,7 +78,8 @@ class NewbookmarkAction extends Action $this->user = common_current_user(); if (empty($this->user)) { - throw new ClientException(_m("Must be logged in to post a bookmark."), + // TRANS: Client exception thrown when trying to create a new bookmark while not logged in. + throw new ClientException(_m('Must be logged in to post a bookmark.'), 403); } @@ -103,7 +102,6 @@ class NewbookmarkAction extends Action * * @return void */ - function handle($argarray=null) { parent::handle($argarray); @@ -122,7 +120,6 @@ class NewbookmarkAction extends Action * * @return void */ - function newBookmark() { if ($this->boolean('ajax')) { @@ -130,10 +127,12 @@ class NewbookmarkAction extends Action } try { if (empty($this->title)) { + // TRANS: Client exception thrown when trying to create a new bookmark without a title. throw new ClientException(_m('Bookmark must have a title.')); } if (empty($this->url)) { + // TRANS: Client exception thrown when trying to create a new bookmark without a URL. throw new ClientException(_m('Bookmark must have an URL.')); } @@ -159,8 +158,8 @@ class NewbookmarkAction extends Action $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); - // TRANS: Page title after sending a notice. - $this->element('title', null, _m('Notice posted')); + // TRANS: Page title after posting a bookmark. + $this->element('title', null, _m('Bookmark posted')); $this->elementEnd('head'); $this->elementStart('body'); $this->showNotice($saved); @@ -192,7 +191,6 @@ class NewbookmarkAction extends Action * * @return void */ - function showContent() { if (!empty($this->error)) { @@ -219,7 +217,6 @@ class NewbookmarkAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { if ($_SERVER['REQUEST_METHOD'] == 'GET' || @@ -230,4 +227,3 @@ class NewbookmarkAction extends Action } } } - \ No newline at end of file diff --git a/plugins/Bookmark/noticebyurl.php b/plugins/Bookmark/noticebyurl.php index b8bea78051..0f40db8fcc 100644 --- a/plugins/Bookmark/noticebyurl.php +++ b/plugins/Bookmark/noticebyurl.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Notice stream of notices with a given attachment - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class NoticebyurlAction extends Action { protected $url = null; @@ -59,15 +58,15 @@ class NoticebyurlAction extends Action * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); - + $this->file = File::staticGet('id', $this->trimmed('id')); if (empty($this->file)) { - throw new ClientException(_m('Unknown URL')); + // TRANS: Client exception thrown when an unknown URL is provided. + throw new ClientException(_m('Unknown URL.')); } $pageArg = $this->trimmed('page'); @@ -85,13 +84,16 @@ class NoticebyurlAction extends Action * * @return string page title */ - function title() { if ($this->page == 1) { - return sprintf(_m("Notices linking to %s"), $this->file->url); + // TRANS: Title of notice stream of notices with a given attachment (first page). + // TRANS: %s is the URL. + return sprintf(_m('Notices linking to %s'), $this->file->url); } else { - return sprintf(_m("Notices linking to %1$s, page %2$d"), + // TRANS: Title of notice stream of notices with a given attachment (all but first page). + // TRANS: %1$s is the URL, %2$s is the page number. + return sprintf(_m('Notices linking to %1$s, page %2$d'), $this->file->url, $this->page); } @@ -104,7 +106,6 @@ class NoticebyurlAction extends Action * * @return void */ - function handle($argarray=null) { $this->showPage(); @@ -117,7 +118,6 @@ class NoticebyurlAction extends Action * * @return void */ - function showContent() { $nl = new NoticeList($this->notices, $this); @@ -142,7 +142,6 @@ class NoticebyurlAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { return true; @@ -169,7 +168,6 @@ class NoticebyurlAction extends Action * * @return string etag http header */ - function etag() { return null; diff --git a/plugins/Bookmark/showbookmark.php b/plugins/Bookmark/showbookmark.php index 6b9bf9bc25..9220afffff 100644 --- a/plugins/Bookmark/showbookmark.php +++ b/plugins/Bookmark/showbookmark.php @@ -50,7 +50,6 @@ class ShowbookmarkAction extends ShownoticeAction function getNotice() { - $this->id = $this->trimmed('id'); $this->bookmark = Bookmark::staticGet('id', $this->id); From b541443370583afb8c08cdac175d49b98565150c Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 6 Apr 2011 11:15:32 -0700 Subject: [PATCH 221/726] QnA - Fix typo --- plugins/QnA/QnAPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index 375e87f615..f03f3e3395 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -205,7 +205,7 @@ class QnAPlugin extends MicroAppPlugin $questionObj = $activity->objects[0]; - if ($questinoObj->type != QnA_Question::OBJECT_TYPE) { + if ($questionObj->type != QnA_Question::OBJECT_TYPE) { throw new Exception('Wrong type for object.'); } From caa6690f4c2511a839e31a9df71e9e97f43577c9 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 18:46:55 +0200 Subject: [PATCH 222/726] Update translator documentation. Whitespace updates. Break lines in README at or before 80 characters. L10n updates. --- plugins/CacheLog/CacheLogPlugin.php | 1 + plugins/CasAuthentication/CasAuthenticationPlugin.php | 3 +++ plugins/CasAuthentication/caslogin.php | 3 +++ plugins/ClientSideShorten/ClientSideShortenPlugin.php | 1 + plugins/ClientSideShorten/README | 3 ++- plugins/ClientSideShorten/shorten.js | 4 ++-- plugins/ClientSideShorten/shorten.php | 3 ++- plugins/Comet/bayeux.class.inc.php | 1 - plugins/Comet/cometupdate.js | 3 --- plugins/DirectionDetector/DirectionDetectorPlugin.php | 1 + 10 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/CacheLog/CacheLogPlugin.php b/plugins/CacheLog/CacheLogPlugin.php index ab9538df05..9eb3350784 100644 --- a/plugins/CacheLog/CacheLogPlugin.php +++ b/plugins/CacheLog/CacheLogPlugin.php @@ -103,6 +103,7 @@ class CacheLogPlugin extends Plugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:CacheLog', 'description' => + // TRANS: Plugin description. _m('Log reads and writes to the cache.')); return true; } diff --git a/plugins/CasAuthentication/CasAuthenticationPlugin.php b/plugins/CasAuthentication/CasAuthenticationPlugin.php index 3196bd94a7..ecc642b856 100644 --- a/plugins/CasAuthentication/CasAuthenticationPlugin.php +++ b/plugins/CasAuthentication/CasAuthenticationPlugin.php @@ -125,12 +125,15 @@ class CasAuthenticationPlugin extends AuthenticationPlugin function onInitializePlugin(){ parent::onInitializePlugin(); if(!isset($this->server)){ + // TRANS: Exception thrown when the CAS Authentication plugin has been configured incorrectly. throw new Exception(_m("Specifying a server is required.")); } if(!isset($this->port)){ + // TRANS: Exception thrown when the CAS Authentication plugin has been configured incorrectly. throw new Exception(_m("Specifying a port is required.")); } if(!isset($this->path)){ + // TRANS: Exception thrown when the CAS Authentication plugin has been configured incorrectly. throw new Exception(_m("Specifying a path is required.")); } //These values need to be accessible to a action object diff --git a/plugins/CasAuthentication/caslogin.php b/plugins/CasAuthentication/caslogin.php index 3301ce5824..0e16427184 100644 --- a/plugins/CasAuthentication/caslogin.php +++ b/plugins/CasAuthentication/caslogin.php @@ -25,6 +25,7 @@ class CasloginAction extends Action { parent::handle($args); if (common_is_real_login()) { + // TRANS: Client error displayed when trying to log in while already logged on. $this->clientError(_m('Already logged in.')); } else { global $casSettings; @@ -36,12 +37,14 @@ class CasloginAction extends Action $casTempPassword = common_good_rand(16); $user = common_check_user(phpCAS::getUser(), $casTempPassword); if (!$user) { + // TRANS: Server error displayed when trying to log in with incorrect username or password. $this->serverError(_m('Incorrect username or password.')); return; } // success! if (!common_set_user($user)) { + // TRANS: Server error displayed when login fails in CAS authentication plugin. $this->serverError(_m('Error setting user. You are probably not authorized.')); return; } diff --git a/plugins/ClientSideShorten/ClientSideShortenPlugin.php b/plugins/ClientSideShorten/ClientSideShortenPlugin.php index 65e27a0374..6379acd334 100644 --- a/plugins/ClientSideShorten/ClientSideShortenPlugin.php +++ b/plugins/ClientSideShorten/ClientSideShortenPlugin.php @@ -73,6 +73,7 @@ class ClientSideShortenPlugin extends Plugin 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:ClientSideShorten', 'rawdescription' => + // TRANS: Plugin description. _m('ClientSideShorten causes the web interface\'s notice form to automatically shorten URLs as they entered, and before the notice is submitted.')); return true; } diff --git a/plugins/ClientSideShorten/README b/plugins/ClientSideShorten/README index e6524c9c7d..70300a85b4 100644 --- a/plugins/ClientSideShorten/README +++ b/plugins/ClientSideShorten/README @@ -1,4 +1,5 @@ -ClientSideShorten causes the web interface's notice form to automatically shorten urls as they entered, and before the notice is submitted. +ClientSideShorten causes the web interface's notice form to automatically +shorten URLs as they entered, and before the notice is submitted. Installation ============ diff --git a/plugins/ClientSideShorten/shorten.js b/plugins/ClientSideShorten/shorten.js index bdffb81e26..d7e17d5284 100644 --- a/plugins/ClientSideShorten/shorten.js +++ b/plugins/ClientSideShorten/shorten.js @@ -16,7 +16,7 @@ function delayed () { if (!execAsap) func.apply(obj, args); - timeout = null; + timeout = null; }; if (timeout) @@ -24,7 +24,7 @@ else if (execAsap) func.apply(obj, args); - timeout = setTimeout(delayed, threshold || 100); + timeout = setTimeout(delayed, threshold || 100); }; } jQuery.fn[sr] = function(fn){ return fn ? this.bind('keypress', debounce(fn, 1000)) : this.trigger(sr); }; diff --git a/plugins/ClientSideShorten/shorten.php b/plugins/ClientSideShorten/shorten.php index 3e7121db8b..6840d532aa 100644 --- a/plugins/ClientSideShorten/shorten.php +++ b/plugins/ClientSideShorten/shorten.php @@ -52,7 +52,8 @@ class ShortenAction extends Action $this->users=array(); $this->text = $this->arg('text'); if(is_null($this->text)){ - throw new ClientException(_m('\'text\' argument must be specified.')); + // TRANS: Client exception thrown when a text argument is not present. + throw new ClientException(_m('"text" argument must be specified.')); } return true; } diff --git a/plugins/Comet/bayeux.class.inc.php b/plugins/Comet/bayeux.class.inc.php index 39ad8a8fc6..4fe8600f84 100644 --- a/plugins/Comet/bayeux.class.inc.php +++ b/plugins/Comet/bayeux.class.inc.php @@ -1,6 +1,5 @@ http://morglog.alleycatracing.com diff --git a/plugins/Comet/cometupdate.js b/plugins/Comet/cometupdate.js index 72cca004b7..50b02b7f34 100644 --- a/plugins/Comet/cometupdate.js +++ b/plugins/Comet/cometupdate.js @@ -1,6 +1,4 @@ // update the local timeline from a Comet server -// - var CometUpdate = function() { var _server; @@ -27,4 +25,3 @@ var CometUpdate = function() } } }(); - diff --git a/plugins/DirectionDetector/DirectionDetectorPlugin.php b/plugins/DirectionDetector/DirectionDetectorPlugin.php index ec206dd75c..be8dbea8e5 100644 --- a/plugins/DirectionDetector/DirectionDetectorPlugin.php +++ b/plugins/DirectionDetector/DirectionDetectorPlugin.php @@ -261,6 +261,7 @@ class DirectionDetectorPlugin extends Plugin { 'version' => DIRECTIONDETECTORPLUGIN_VERSION, 'author' => 'Behrooz Shabani', 'homepage' => $url, + // TRANS: Plugin description. 'rawdescription' => _m('Shows notices with right-to-left content in correct direction.') ); return true; From 512bd91deed74b2cb567d5c0afe10514423e46db Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 6 Apr 2011 23:43:30 +0200 Subject: [PATCH 223/726] Translator documentation added. Whitespace updates. --- plugins/Directory/DirectoryPlugin.php | 8 +++++--- plugins/DiskCache/DiskCachePlugin.php | 5 +---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/Directory/DirectoryPlugin.php b/plugins/Directory/DirectoryPlugin.php index cba75802e5..4fe1eaec9e 100644 --- a/plugins/Directory/DirectoryPlugin.php +++ b/plugins/Directory/DirectoryPlugin.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { */ class DirectoryPlugin extends Plugin { - private $dir = null; /** @@ -165,8 +164,10 @@ class DirectoryPlugin extends Plugin $nav->out->menuItem( common_local_url('userdirectory'), - _m('Directory'), - _m('User Directory'), + // TRANS: Menu item text for user directory. + _m('MENU','Directory'), + // TRANS: Menu item title for user directory. + _m('User Directory.'), $actionName == 'userdirectory', 'nav_directory' ); @@ -184,6 +185,7 @@ class DirectoryPlugin extends Plugin 'version' => STATUSNET_VERSION, 'author' => 'Zach Copley', 'homepage' => 'http://status.net/wiki/Plugin:Directory', + // TRANS: Plugin description. 'rawdescription' => _m('Add a user directory.') ); diff --git a/plugins/DiskCache/DiskCachePlugin.php b/plugins/DiskCache/DiskCachePlugin.php index 47d4b153cf..d021a6641a 100644 --- a/plugins/DiskCache/DiskCachePlugin.php +++ b/plugins/DiskCache/DiskCachePlugin.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class DiskCachePlugin extends Plugin { var $root = '/tmp'; @@ -64,7 +63,6 @@ class DiskCachePlugin extends Plugin * * @return boolean hook success */ - function onStartCacheGet(&$key, &$value) { $filename = $this->keyToFilename($key); @@ -91,7 +89,6 @@ class DiskCachePlugin extends Plugin * * @return boolean hook success */ - function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success) { $filename = $this->keyToFilename($key); @@ -152,7 +149,6 @@ class DiskCachePlugin extends Plugin * * @return boolean hook success */ - function onStartCacheDelete(&$key, &$success) { $filename = $this->keyToFilename($key); @@ -172,6 +168,7 @@ class DiskCachePlugin extends Plugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:DiskCache', 'rawdescription' => + // TRANS: Plugin description. _m('Plugin to implement cache interface with disk files.')); return true; } From 4b5f76d688fee47585aec0b3d0c92d0af8c0225b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 17:57:33 -0400 Subject: [PATCH 224/726] more flexible oEmbed handling --- README | 16 ++++++++-- lib/default.php | 5 ++- lib/oembedhelper.php | 76 ++++++++++++++++++++++++++++++++------------ 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/README b/README index ef032cad84..5f58179bfe 100644 --- a/README +++ b/README @@ -1393,12 +1393,22 @@ desclimit: maximum number of characters to allow in group descriptions. null (default) means to use the site-wide text limits. 0 means no limit. -oohembed +oembed -------- -oEmbed endpoint for multimedia attachments (links in posts). +oEmbed endpoint for multimedia attachments (links in posts). Will also +work as 'oohembed' for backwards compatibility. -endpoint: oohembed endpoint using http://oohembed.com/ software. +endpoint: oohembed endpoint using http://oohembed.com/ software. Defaults to + 'http://oohembed.com/oohembed/'. +order: Array of methods to check for OEmbed data. Methods include 'built-in' + (use a built-in function to simulate oEmbed for some sites), + 'well-known' (use well-known public oEmbed endpoints), + 'discovery' (discover using headers in HTML), 'service' (use + a third-party service, like oohembed or embed.ly. Default is + array('built-in', 'well-known', 'service', 'discovery'). Note that very + few sites implement oEmbed; 'discovery' is going to fail 99% of the + time. search ------ diff --git a/lib/default.php b/lib/default.php index 6c7b18bccd..84eaf3bf2a 100644 --- a/lib/default.php +++ b/lib/default.php @@ -269,7 +269,10 @@ $default = 'group' => array('maxaliases' => 3, 'desclimit' => null), - 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'), + 'oembed' => + array('endpoint' => 'http://oohembed.com/oohembed/', + 'order' => array('built-in', 'well-known', 'service', 'discovery'), + ), 'search' => array('type' => 'fulltext'), 'sessions' => diff --git a/lib/oembedhelper.php b/lib/oembedhelper.php index 3cd20c8e8e..4aae815918 100644 --- a/lib/oembedhelper.php +++ b/lib/oembedhelper.php @@ -43,6 +43,13 @@ class oEmbedHelper protected static $apiMap = array( 'flickr.com' => 'http://www.flickr.com/services/oembed/', 'yfrog.com' => 'http://www.yfrog.com/api/oembed', + 'youtube.com' => 'http://www.youtube.com/oembed', + 'viddler.com' => 'http://lab.viddler.com/services/oembed/', + 'qik.com' => 'http://qik.com/api/oembed.json', + 'revision3.com' => 'http://revision3.com/api/oembed/', + 'hulu.com' => 'http://www.hulu.com/api/oembed.json', + 'vimeo.com' => 'http://www.vimeo.com/api/oembed.json', + 'my.opera.com' => 'http://my.opera.com/service/oembed', ); protected static $functionMap = array( 'twitpic.com' => 'oEmbedHelper::twitPic', @@ -74,30 +81,59 @@ class oEmbedHelper $host = substr($host, 4); } - // Blacklist: systems with no oEmbed API of their own, which are - // either missing from or broken on oohembed.com's proxy. - // we know how to look data up in another way... - if (array_key_exists($host, self::$functionMap)) { - $func = self::$functionMap[$host]; - return call_user_func($func, $url, $params); - } + common_log(LOG_INFO, 'Checking for oEmbed data for ' . $url); - // Whitelist: known API endpoints for sites that don't provide discovery... - if (array_key_exists($host, self::$apiMap)) { - $api = self::$apiMap[$host]; - } else { - try { - $api = self::discover($url); - } catch (Exception $e) { - // Discovery failed... fall back to oohembed if enabled. - $oohembed = common_config('oohembed', 'endpoint'); - if ($oohembed) { - $api = $oohembed; - } else { - throw $e; + // You can fiddle with the order of discovery -- either skipping + // some types or re-ordering them. + + $order = common_config('oembed', 'order'); + + foreach ($order as $method) { + + switch ($method) { + case 'built-in': + common_log(LOG_INFO, 'Considering built-in oEmbed methods...'); + // Blacklist: systems with no oEmbed API of their own, which are + // either missing from or broken on oohembed.com's proxy. + // we know how to look data up in another way... + if (array_key_exists($host, self::$functionMap)) { + common_log(LOG_INFO, 'We have a built-in method for ' . $host); + $func = self::$functionMap[$host]; + return call_user_func($func, $url, $params); } + break; + case 'well-known': + common_log(LOG_INFO, 'Considering well-known oEmbed endpoints...'); + // Whitelist: known API endpoints for sites that don't provide discovery... + if (array_key_exists($host, self::$apiMap)) { + $api = self::$apiMap[$host]; + common_log(LOG_INFO, 'Using well-known endpoint "' . $api . '" for "' . $host . '"'); + break 2; + } + break; + case 'discovery': + try { + common_log(LOG_INFO, 'Trying to discover an oEmbed endpoint using link headers.'); + $api = self::discover($url); + common_log(LOG_INFO, 'Found API endpoint ' . $api . ' for URL ' . $url); + break 2; + } catch (Exception $e) { + common_log(LOG_INFO, 'Could not find an oEmbed endpoint using link headers.'); + // Just ignore it! + } + break; + case 'service': + $api = common_config('oembed', 'endpoint'); + common_log(LOG_INFO, 'Using service API endpoint ' . $api); + break 2; + break; } } + + if (empty($api)) { + throw new ServerException(_('No oEmbed API endpoint available.')); + } + return self::getObjectFrom($api, $url, $params); } From 29243cd21aa9c0575bb3c1376d350469e7531804 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 18:12:25 -0400 Subject: [PATCH 225/726] make Profile::isMember() and Profile::isAdmin() use caching pkeyGet() --- classes/Profile.php | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 9f63980242..d87ace42c5 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -211,31 +211,16 @@ class Profile extends Memcached_DataObject function isMember($group) { - $mem = new Group_member(); - - $mem->group_id = $group->id; - $mem->profile_id = $this->id; - - if ($mem->find()) { - return true; - } else { - return false; - } + $gm = Group_member::pkeyGet(array('profile_id' => $this->id, + 'group_id' => $group->id)); + return (!empty($gm)); } function isAdmin($group) { - $mem = new Group_member(); - - $mem->group_id = $group->id; - $mem->profile_id = $this->id; - $mem->is_admin = 1; - - if ($mem->find()) { - return true; - } else { - return false; - } + $gm = Group_member::pkeyGet(array('profile_id' => $this->id, + 'group_id' => $group->id)); + return (!empty($gm) && $gm->is_admin); } function isPendingMember($group) From a2782523d75d73ad833a6e0440c60f3bcb647d33 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 18:33:05 -0400 Subject: [PATCH 226/726] add some timing comments to output to debug poor performance --- lib/action.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/action.php b/lib/action.php index 48a9cdeb3d..d8efad0740 100644 --- a/lib/action.php +++ b/lib/action.php @@ -118,7 +118,7 @@ class Action extends HTMLOutputter // lawsuit } } - function endHTML() + function timingComment() { global $_startTime; @@ -127,10 +127,15 @@ class Action extends HTMLOutputter // lawsuit $diff = round(($endTime - $_startTime) * 1000); $this->raw(""); } + } + function endHTML() + { + $this->timingComment(); return parent::endHTML(); } + /** * Show head, a template method. * @@ -139,6 +144,7 @@ class Action extends HTMLOutputter // lawsuit function showHead() { // XXX: attributes (profile?) + $this->timingComment(); $this->elementStart('head'); if (Event::handle('StartShowHeadElements', array($this))) { if (Event::handle('StartShowHeadTitle', array($this))) { @@ -154,6 +160,7 @@ class Action extends HTMLOutputter // lawsuit Event::handle('EndShowHeadElements', array($this)); } $this->elementEnd('head'); + $this->timingComment(); } /** @@ -467,25 +474,31 @@ class Action extends HTMLOutputter // lawsuit */ function showBody() { + $this->timingComment(); $this->elementStart('body', (common_current_user()) ? array('id' => strtolower($this->trimmed('action')), 'class' => 'user_in') : array('id' => strtolower($this->trimmed('action')))); $this->elementStart('div', array('id' => 'wrap')); if (Event::handle('StartShowHeader', array($this))) { + $this->timingComment(); $this->showHeader(); $this->flush(); + $this->timingComment(); Event::handle('EndShowHeader', array($this)); } $this->showCore(); $this->flush(); if (Event::handle('StartShowFooter', array($this))) { + $this->timingComment(); $this->showFooter(); $this->flush(); + $this->timingComment(); Event::handle('EndShowFooter', array($this)); } $this->elementEnd('div'); $this->showScripts(); $this->elementEnd('body'); + $this->timingComment(); } /** @@ -703,18 +716,24 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('div', array('id' => 'content_wrapper')); $this->elementStart('div', array('id' => 'site_nav_local_views_wrapper')); if (Event::handle('StartShowLocalNavBlock', array($this))) { + $this->timingComment(); $this->showLocalNavBlock(); $this->flush(); + $this->timingComment(); Event::handle('EndShowLocalNavBlock', array($this)); } if (Event::handle('StartShowContentBlock', array($this))) { + $this->timingComment(); $this->showContentBlock(); $this->flush(); + $this->timingComment(); Event::handle('EndShowContentBlock', array($this)); } if (Event::handle('StartShowAside', array($this))) { + $this->timingComment(); $this->showAside(); $this->flush(); + $this->timingComment(); Event::handle('EndShowAside', array($this)); } $this->elementEnd('div'); From d9ca956ecf9fcae9fe6ddc7e392f4ea901e09ca2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 22:46:28 -0400 Subject: [PATCH 227/726] SQLStatsPlugin to get some profiling data on SQL queries --- plugins/SQLStats/SQLStatsPlugin.php | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 plugins/SQLStats/SQLStatsPlugin.php diff --git a/plugins/SQLStats/SQLStatsPlugin.php b/plugins/SQLStats/SQLStatsPlugin.php new file mode 100644 index 0000000000..9e810a3ffc --- /dev/null +++ b/plugins/SQLStats/SQLStatsPlugin.php @@ -0,0 +1,83 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Check DB queries for filesorts and such and log em. + * + * @package SQLStatsPlugin + * @maintainer Evan Prodromou + */ + +class SQLStatsPlugin extends Plugin +{ + protected $queryCount = 0; + protected $queryStart = 0; + protected $queryTimes = array(); + protected $queries = array(); + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'SQLStats', + 'version' => STATUSNET_VERSION, + 'author' => 'Evan Prodromou', + 'homepage' => 'http://status.net/wiki/Plugin:SQLStats', + 'rawdescription' => + _m('Debug tool to watch for poorly indexed DB queries.')); + + return true; + } + + function onStartDBQuery($obj, $query, &$result) + { + $this->queryStart = microtime(true); + return true; + } + + function onEndDBQuery($obj, $query, &$result) + { + $endTime = microtime(true); + $this->queryTimes[] = round(($endTime - $this->queryStart) * 1000); + $this->queries[] = trim(preg_replace('/\s/', ' ', $query)); + $this->queryStart = 0; + + return true; + } + + function cleanup() + { + $this->log(LOG_INFO, sprintf('%d queries this hit (total = %d, avg = %d, max = %d, min = %d)', + count($this->queryTimes), + array_sum($this->queryTimes), + array_sum($this->queryTimes)/count($this->queryTimes), + max($this->queryTimes), + min($this->queryTimes))); + + $verbose = common_config('sqlstats', 'verbose'); + + if ($verbose) { + foreach ($this->queries as $query) { + $this->log(LOG_INFO, $query); + } + } + } +} From 44c64816a5e90cc85769693e5f6bcb96934f57ef Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 22:47:17 -0400 Subject: [PATCH 228/726] cache groups per notice --- classes/Notice.php | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index a4f530c44f..8098a8ace8 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1250,28 +1250,40 @@ class Notice extends Memcached_DataObject return array(); } - // XXX: cache me + $ids = array(); + + $keypart = sprintf('notice:groups:%d', $this->id); + + $idstr = self::cacheGet($keypart); + + if ($idstr !== false) { + $ids = explode(',', $idstr); + } else { + $gi = new Group_inbox(); + + $gi->selectAdd(); + $gi->selectAdd('group_id'); + + $gi->notice_id = $this->id; + + if ($gi->find()) { + while ($gi->fetch()) { + $ids[] = $gi->group_id; + } + } + + self::cacheSet($keypart, implode(',', $ids)); + } $groups = array(); - $gi = new Group_inbox(); - - $gi->selectAdd(); - $gi->selectAdd('group_id'); - - $gi->notice_id = $this->id; - - if ($gi->find()) { - while ($gi->fetch()) { - $group = User_group::staticGet('id', $gi->group_id); - if ($group) { - $groups[] = $group; - } + foreach ($ids as $id) { + $group = User_group::staticGet('id', $id); + if ($group) { + $groups[] = $group; } } - $gi->free(); - return $groups; } From 2a124c1397d92ab4b50627144a54d33c1695d691 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 22:48:33 -0400 Subject: [PATCH 229/726] make User_group use caching staticGet() --- classes/User_group.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/User_group.php b/classes/User_group.php index f72cc57533..e993961118 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -31,7 +31,9 @@ class User_group extends Memcached_DataObject public $force_scope; // tinyint /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); } + function staticGet($k,$v=NULL) { + return Memcached_DataObject::staticGet('User_group',$k,$v); + } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE From b8fdf6636fb37013886788422629e3c7dcee22dd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 22:49:09 -0400 Subject: [PATCH 230/726] make Group_block use caching staticGet() --- classes/Group_block.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Group_block.php b/classes/Group_block.php index ffc57a496e..68feaef4de 100644 --- a/classes/Group_block.php +++ b/classes/Group_block.php @@ -35,7 +35,7 @@ class Group_block extends Memcached_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Group_block',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Group_block',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE From fa8592f50be74c84f8db5750513ee3914bf105e0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 22:51:46 -0400 Subject: [PATCH 231/726] Make Login_token use caching staticGet() --- classes/Login_token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Login_token.php b/classes/Login_token.php index 20d5d9dbce..7a9388c947 100644 --- a/classes/Login_token.php +++ b/classes/Login_token.php @@ -35,7 +35,7 @@ class Login_token extends Memcached_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Login_token',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Login_token',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE From 59d0e2f37335345d62cd558d6804fc38b3b810c2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:17:17 -0400 Subject: [PATCH 232/726] cache the notice count for threaded view --- classes/Conversation.php | 19 +++++++++++++++++++ classes/Notice.php | 1 + lib/threadednoticelist.php | 5 ++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/classes/Conversation.php b/classes/Conversation.php index aab55723f6..e029c20ba0 100755 --- a/classes/Conversation.php +++ b/classes/Conversation.php @@ -74,4 +74,23 @@ class Conversation extends Memcached_DataObject return $conv; } + + static function noticeCount($id) + { + $keypart = sprintf('conversation:notice_count:%d', $id); + + $cnt = self::cacheGet($keypart); + + if ($cnt !== false) { + return $cnt; + } + + $notice = new Notice(); + $notice->conversation = $id; + $cnt = $notice->count(); + + self::cacheSet($keypart, $cnt); + + return $cnt; + } } diff --git a/classes/Notice.php b/classes/Notice.php index 8098a8ace8..763547a0e1 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -567,6 +567,7 @@ class Notice extends Memcached_DataObject // was not the root of the conversation. What to do now? self::blow('notice:conversation_ids:%d', $this->conversation); + self::blow('conversation::notice_count:%d', $this->conversation); if (!empty($this->repeat_of)) { self::blow('notice:repeats:%d', $this->repeat_of); diff --git a/lib/threadednoticelist.php b/lib/threadednoticelist.php index 700b6ed1ee..b686e17629 100644 --- a/lib/threadednoticelist.php +++ b/lib/threadednoticelist.php @@ -284,9 +284,8 @@ class ThreadedNoticeListMoreItem extends NoticeListItem $id = $this->notice->conversation; $url = common_local_url('conversationreplies', array('id' => $id)); - $notice = new Notice(); - $notice->conversation = $id; - $n = $notice->count() - 1; + $n = Conversation::noticeCount($id) - 1; + // TRANS: Link to show replies for a notice. // TRANS: %d is the number of replies to a notice and used for plural. $msg = sprintf(_m('Show reply', 'Show all %d replies', $n), $n); From d3d0ec5ebe7ac3093569a607cd58f9bbe65a1e28 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:25:24 -0400 Subject: [PATCH 233/726] cache tags per notice --- classes/Notice.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 763547a0e1..8e0307b19d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2004,14 +2004,24 @@ class Notice extends Memcached_DataObject public function getTags() { $tags = array(); - $tag = new Notice_tag(); - $tag->notice_id = $this->id; - if ($tag->find()) { - while ($tag->fetch()) { - $tags[] = $tag->tag; + + $keypart = sprintf('notice:tags:%d', $this->id); + + $tagstr = self::cacheGet($keypart); + + if ($tagstr !== false) { + $tags = explode(',', $tagstr); + } else { + $tag = new Notice_tag(); + $tag->notice_id = $this->id; + if ($tag->find()) { + while ($tag->fetch()) { + $tags[] = $tag->tag; + } } + self::cacheSet($keypart, implode(',', $tags)); } - $tag->free(); + return $tags; } From 419ae3f18d7663d95dbae577c41b3ccc1ffef6be Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:33:35 -0400 Subject: [PATCH 234/726] Cache results for attachments --- classes/Notice.php | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 8e0307b19d..b948e9de73 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -719,18 +719,33 @@ class Notice extends Memcached_DataObject } function attachments() { - // XXX: cache this - $att = array(); - $f2p = new File_to_post; - $f2p->post_id = $this->id; - if ($f2p->find()) { - while ($f2p->fetch()) { - $f = File::staticGet($f2p->file_id); - if ($f) { - $att[] = clone($f); + + $keypart = sprintf('notice:file_ids:%d', $this->id); + + $idstr = self::cacheGet($keypart); + + if ($idstr !== false) { + $ids = explode(',', $idstr); + } else { + $f2p = new File_to_post; + $f2p->post_id = $this->id; + if ($f2p->find()) { + while ($f2p->fetch()) { + $ids[] = $f2p->file_id; } } + self::cacheSet($keypart, implode(',', $ids)); } + + $att = array(); + + foreach ($ids as $id) { + $f = File::staticGet('id', $id); + if (!empty($f)) { + $att[] = clone($f); + } + } + return $att; } From f9dc2fc0ab72200b6069de98ed41828d4d2fb387 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:46:51 -0400 Subject: [PATCH 235/726] cache getReplies() values --- classes/Notice.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index b948e9de73..6ca4c711fd 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1208,23 +1208,28 @@ class Notice extends Memcached_DataObject */ function getReplies() { - // XXX: cache me + $keypart = sprintf('notice:reply_ids:%d', $this->id); - $ids = array(); + $idstr = self::cacheGet($keypart); - $reply = new Reply(); - $reply->selectAdd(); - $reply->selectAdd('profile_id'); - $reply->notice_id = $this->id; + if ($idstr !== false) { + $ids = explode(',', $idstr); + } else { + $ids = array(); - if ($reply->find()) { - while($reply->fetch()) { - $ids[] = $reply->profile_id; + $reply = new Reply(); + $reply->selectAdd(); + $reply->selectAdd('profile_id'); + $reply->notice_id = $this->id; + + if ($reply->find()) { + while($reply->fetch()) { + $ids[] = $reply->profile_id; + } } + self::cacheSet($keypart, implode(',', $ids)); } - $reply->free(); - return $ids; } From bf39c95795024e8dd99ca0b35fd562f5960040ef Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:47:05 -0400 Subject: [PATCH 236/726] Bookmarks more robust to missing profiles --- plugins/Bookmark/BookmarkPlugin.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index b8e86e3aa8..db2a32f392 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -554,13 +554,15 @@ class BookmarkPlugin extends MicroAppPlugin foreach ($replies as $reply) { $other = Profile::staticGet('id', $reply); - $out->elementStart('li'); - $out->element('a', array('rel' => 'tag', - 'href' => $other->profileurl, - 'title' => $other->getBestName()), - sprintf('for:%s', $other->nickname)); - $out->elementEnd('li'); - $out->text(' '); + if (!empty($other)) { + $out->elementStart('li'); + $out->element('a', array('rel' => 'tag', + 'href' => $other->profileurl, + 'title' => $other->getBestName()), + sprintf('for:%s', $other->nickname)); + $out->elementEnd('li'); + $out->text(' '); + } } foreach ($tags as $tag) { From 524b98bfa3fd340ade6ce8b0e7f23ce773db5d92 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:48:10 -0400 Subject: [PATCH 237/726] remove debugging statement from Happening --- plugins/Event/Happening.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/Event/Happening.php b/plugins/Event/Happening.php index bbea213a1a..ec3e12595d 100644 --- a/plugins/Event/Happening.php +++ b/plugins/Event/Happening.php @@ -215,7 +215,6 @@ class Happening extends Managed_DataObject function getRSVP($profile) { - common_log(LOG_DEBUG, "Finding RSVP for " . $profile->id . ', ' . $this->id); return RSVP::pkeyGet(array('profile_id' => $profile->id, 'event_id' => $this->id)); } From a1fa47d904382b7d8a5708392ffb7a1fb1789a66 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 00:01:51 -0400 Subject: [PATCH 238/726] Cache RSVP counts for Event plugin --- plugins/Event/RSVP.php | 47 ++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/plugins/Event/RSVP.php b/plugins/Event/RSVP.php index 314d297a36..85862d375d 100644 --- a/plugins/Event/RSVP.php +++ b/plugins/Event/RSVP.php @@ -138,8 +138,6 @@ class RSVP extends Managed_DataObject function saveNew($profile, $event, $verb, $options=array()) { - common_debug("RSVP::saveNew({$profile->id}, {$event->id}, '$verb', 'some options');"); - if (array_key_exists('uri', $options)) { $other = RSVP::staticGet('uri', $options['uri']); if (!empty($other)) { @@ -161,8 +159,6 @@ class RSVP extends Managed_DataObject $rsvp->event_id = $event->id; $rsvp->response = self::codeFor($verb); - common_debug("Got value {$rsvp->response} for verb {$verb}"); - if (array_key_exists('created', $options)) { $rsvp->created = $options['created']; } else { @@ -178,6 +174,8 @@ class RSVP extends Managed_DataObject $rsvp->insert(); + self::blow('rsvp:for-event:%s', $event->id); + // XXX: come up with something sexier $content = $rsvp->asString(); @@ -256,18 +254,39 @@ class RSVP extends Managed_DataObject static function forEvent($event) { + $keypart = sprintf('rsvp:for-event:%s', $event->id); + + $idstr = self::cacheGet($keypart); + + if ($idstr !== false) { + $ids = explode(',', $idstr); + } else { + $ids = array(); + + $rsvp = new RSVP(); + + $rsvp->selectAdd(); + $rsvp->selectAdd('id'); + + $rsvp->event_id = $event->id; + + if ($rsvp->find()) { + while ($rsvp->fetch()) { + $ids[] = $rsvp->id; + } + } + self::cacheSet($keypart, implode(',', $ids)); + } + $rsvps = array(RSVP::POSITIVE => array(), RSVP::NEGATIVE => array(), RSVP::POSSIBLE => array()); - $rsvp = new RSVP(); - - $rsvp->event_id = $event->id; - - if ($rsvp->find()) { - while ($rsvp->fetch()) { + foreach ($ids as $id) { + $rsvp = RSVP::staticGet('id', $id); + if (!empty($rsvp)) { $verb = self::verbFor($rsvp->response); - $rsvps[$verb][] = clone($rsvp); + $rsvps[$verb][] = $rsvp; } } @@ -375,4 +394,10 @@ class RSVP extends Managed_DataObject $profile->getBestName(), $eventTitle); } + + function delete() + { + self::blow('rsvp:for-event:%s', $event->id); + parent::delete(); + } } From ca0f59d46a5b1b6a3b39f151c0118e46520a9e5a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 00:07:39 -0400 Subject: [PATCH 239/726] Revert "add some timing comments to output to debug poor performance" This reverts commit a2782523d75d73ad833a6e0440c60f3bcb647d33. --- lib/action.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/lib/action.php b/lib/action.php index d8efad0740..48a9cdeb3d 100644 --- a/lib/action.php +++ b/lib/action.php @@ -118,7 +118,7 @@ class Action extends HTMLOutputter // lawsuit } } - function timingComment() + function endHTML() { global $_startTime; @@ -127,15 +127,10 @@ class Action extends HTMLOutputter // lawsuit $diff = round(($endTime - $_startTime) * 1000); $this->raw(""); } - } - function endHTML() - { - $this->timingComment(); return parent::endHTML(); } - /** * Show head, a template method. * @@ -144,7 +139,6 @@ class Action extends HTMLOutputter // lawsuit function showHead() { // XXX: attributes (profile?) - $this->timingComment(); $this->elementStart('head'); if (Event::handle('StartShowHeadElements', array($this))) { if (Event::handle('StartShowHeadTitle', array($this))) { @@ -160,7 +154,6 @@ class Action extends HTMLOutputter // lawsuit Event::handle('EndShowHeadElements', array($this)); } $this->elementEnd('head'); - $this->timingComment(); } /** @@ -474,31 +467,25 @@ class Action extends HTMLOutputter // lawsuit */ function showBody() { - $this->timingComment(); $this->elementStart('body', (common_current_user()) ? array('id' => strtolower($this->trimmed('action')), 'class' => 'user_in') : array('id' => strtolower($this->trimmed('action')))); $this->elementStart('div', array('id' => 'wrap')); if (Event::handle('StartShowHeader', array($this))) { - $this->timingComment(); $this->showHeader(); $this->flush(); - $this->timingComment(); Event::handle('EndShowHeader', array($this)); } $this->showCore(); $this->flush(); if (Event::handle('StartShowFooter', array($this))) { - $this->timingComment(); $this->showFooter(); $this->flush(); - $this->timingComment(); Event::handle('EndShowFooter', array($this)); } $this->elementEnd('div'); $this->showScripts(); $this->elementEnd('body'); - $this->timingComment(); } /** @@ -716,24 +703,18 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('div', array('id' => 'content_wrapper')); $this->elementStart('div', array('id' => 'site_nav_local_views_wrapper')); if (Event::handle('StartShowLocalNavBlock', array($this))) { - $this->timingComment(); $this->showLocalNavBlock(); $this->flush(); - $this->timingComment(); Event::handle('EndShowLocalNavBlock', array($this)); } if (Event::handle('StartShowContentBlock', array($this))) { - $this->timingComment(); $this->showContentBlock(); $this->flush(); - $this->timingComment(); Event::handle('EndShowContentBlock', array($this)); } if (Event::handle('StartShowAside', array($this))) { - $this->timingComment(); $this->showAside(); $this->flush(); - $this->timingComment(); Event::handle('EndShowAside', array($this)); } $this->elementEnd('div'); From 6806a42e2c87056baacc4c9dfa1842045b9f1172 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 7 Apr 2011 10:06:23 +0200 Subject: [PATCH 240/726] Update translator documentation. --- plugins/Disqus/DisqusPlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/Disqus/DisqusPlugin.php b/plugins/Disqus/DisqusPlugin.php index add089e77f..ad9435b7f9 100644 --- a/plugins/Disqus/DisqusPlugin.php +++ b/plugins/Disqus/DisqusPlugin.php @@ -140,6 +140,7 @@ ENDOFSCRIPT; $action->elementStart('noscript'); // TRANS: User notification that JavaScript is required for Disqus comment display. + // TRANS: This message contains Markdown links in the form [description](link). $noScriptMsg = sprintf(_m("Please enable JavaScript to view the [comments powered by Disqus](http://disqus.com/?ref_noscript=%s)."), $this->shortname); $output = common_markup_to_html($noScriptMsg); $action->raw($output); From 8a0f67b773c0c3fe7c3642730fdb184f288ba45d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 10:25:53 -0400 Subject: [PATCH 241/726] Uninitialized value for attachments --- classes/Notice.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/Notice.php b/classes/Notice.php index 6ca4c711fd..363e52dbdd 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -727,6 +727,7 @@ class Notice extends Memcached_DataObject if ($idstr !== false) { $ids = explode(',', $idstr); } else { + $ids = array(); $f2p = new File_to_post; $f2p->post_id = $this->id; if ($f2p->find()) { From 5b9319d081309264772100a25d15e2db0538ccb6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 10:52:28 -0400 Subject: [PATCH 242/726] profiles were getting overwritten in Notice::asActivity() --- classes/Notice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 363e52dbdd..c908e7e3a7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1391,9 +1391,9 @@ class Notice extends Memcached_DataObject $reply_ids = $this->getReplies(); foreach ($reply_ids as $id) { - $profile = Profile::staticGet('id', $id); - if (!empty($profile)) { - $ctx->attention[] = $profile->getUri(); + $rprofile = Profile::staticGet('id', $id); + if (!empty($rprofile)) { + $ctx->attention[] = $rprofile->getUri(); } } From 5dfb8e2bc418d1144c953214a40b4dd730ca148b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 14:52:44 -0400 Subject: [PATCH 243/726] Use InboxNoticeStream class for inbox Move the code for inbox fetching to the InboxNoticeStream class. --- actions/all.php | 14 ++-- classes/Inbox.php | 161 +------------------------------------- classes/User.php | 29 ++++--- lib/inboxnoticestream.php | 136 ++++++++++++++++++++++++++++++++ 4 files changed, 165 insertions(+), 175 deletions(-) create mode 100644 lib/inboxnoticestream.php diff --git a/actions/all.php b/actions/all.php index 2826319c0d..74a0059346 100644 --- a/actions/all.php +++ b/actions/all.php @@ -55,17 +55,17 @@ class AllAction extends ProfileAction function prepare($args) { parent::prepare($args); - $cur = common_current_user(); - if (!empty($cur) && $cur->id == $this->user->id) { - $this->notice = $this->user->noticeInboxThreaded(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - } else { - $this->notice = $this->user->noticesWithFriendsThreaded(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - } + $stream = new InboxNoticeStream($this->user); + + $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1, + null, + null); if ($this->page > 1 && $this->notice->N == 0) { // TRANS: Server error when page not found (404). - $this->serverError(_('No such page.'), $code = 404); + $this->serverError(_('No such page.'), 404); } return true; diff --git a/classes/Inbox.php b/classes/Inbox.php index feaead249b..336bba048c 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -157,168 +157,11 @@ class Inbox extends Memcached_DataObject } } - function stream($user_id, $offset, $limit, $since_id, $max_id, $own=false) - { - $inbox = Inbox::staticGet('user_id', $user_id); - - if (empty($inbox)) { - $inbox = Inbox::fromNoticeInbox($user_id); - if (empty($inbox)) { - return array(); - } else { - $inbox->encache(); - } - } - - $ids = $inbox->unpack(); - - if (!empty($since_id)) { - $newids = array(); - foreach ($ids as $id) { - if ($id > $since_id) { - $newids[] = $id; - } - } - $ids = $newids; - } - - if (!empty($max_id)) { - $newids = array(); - foreach ($ids as $id) { - if ($id <= $max_id) { - $newids[] = $id; - } - } - $ids = $newids; - } - - $ids = array_slice($ids, $offset, $limit); - - return $ids; - } - - /** - * Wrapper for Inbox::stream() and Notice::getStreamByIds() returning - * additional items up to the limit if we were short due to deleted - * notices still being listed in the inbox. - * - * This is meant to assist threaded views, and optimizes paging for - * threadness. Not ideal for very late pages, as we have to bump about - * through all previous items. - * - * Should avoid duplicates in paging, though. - * - * @param int $user_id - * @param int $offset skip past the most recent N notices (after since_id checks) - * @param int $limit - * @param mixed $since_id return only notices after but not including this id - * @param mixed $max_id return only notices up to and including this id - * @param mixed $own ignored? - * @return array of Notice objects - * - * @todo consider repacking the inbox when this happens? - * @fixme reimplement $own if we need it? - */ - function streamNoticesThreaded($user_id, $offset, $limit, $since_id, $max_id, $own=false) - { - // So what we want is: - // * slurp in the beginning of the notice list - // * filter out deleted notices - // * replace any reply notices with their conversation roots - // * filter out any duplicate conversations - // * return $limit notices after skipping $offset from the most recent - - $ids = self::stream($user_id, 0, self::MAX_NOTICES, $since_id, $max_id, $own); - - // Do a bulk lookup for the first $limit items - // Fast path when nothing's deleted. - $firstChunk = array_slice($ids, 0, $offset + $limit); - $notices = NoticeStream::getStreamByIds($firstChunk); - - assert($notices instanceof ArrayWrapper); - $items = $notices->_items; - - // Extract the latest non-deleted item in each convo - $noticeByConvo = array(); - foreach ($items as $notice) { - if (empty($noticeByConvo[$notice->conversation])) { - $noticeByConvo[$notice->conversation] = $notice; - } - } - - $wanted = count($firstChunk); // raw entry count in the inbox up to our $limit - // There were deleted notices, we'll need to look for more. - $remainder = array_slice($ids, $limit); - - for ($i = $offset + $limit; count($noticeByConvo) < $wanted && $i < count($ids); $i++) { - $notice = Notice::staticGet($ids[$i]); - if ($notice && empty($noticeByConvo[$notice->conversation])) { - $noticeByConvo[$notice->conversation] = $notice; - } - } - - $slice = array_slice($noticeByConvo, $offset, $limit, false); - return new ArrayWrapper($slice); - } - - /** - * Wrapper for Inbox::stream() and Notice::getStreamByIds() returning - * additional items up to the limit if we were short due to deleted - * notices still being listed in the inbox. - * - * The fast path (when no items are deleted) should be just as fast; the - * offset parameter is applied *before* lookups for maximum efficiency. - * - * This means offset-based paging may show duplicates, but similar behavior - * already exists when new notices are posted between page views, so we - * think people will be ok with this until id-based paging is introduced - * to the user interface. - * - * @param int $user_id - * @param int $offset skip past the most recent N notices (after since_id checks) - * @param int $limit - * @param mixed $since_id return only notices after but not including this id - * @param mixed $max_id return only notices up to and including this id - * @param mixed $own ignored? - * @return array of Notice objects - * - * @todo consider repacking the inbox when this happens? - * @fixme reimplement $own if we need it? - */ - function streamNotices($user_id, $offset, $limit, $since_id, $max_id, $own=false) - { - $ids = self::stream($user_id, $offset, self::MAX_NOTICES, $since_id, $max_id, $own); - - // Do a bulk lookup for the first $limit items - // Fast path when nothing's deleted. - $firstChunk = array_slice($ids, 0, $limit); - $notices = NoticeStream::getStreamByIds($firstChunk); - - $wanted = count($firstChunk); // raw entry count in the inbox up to our $limit - if ($notices->N >= $wanted) { - return $notices; - } - - // There were deleted notices, we'll need to look for more. - assert($notices instanceof ArrayWrapper); - $items = $notices->_items; - $remainder = array_slice($ids, $limit); - - while (count($items) < $wanted && count($remainder) > 0) { - $notice = Notice::staticGet(array_shift($remainder)); - if ($notice) { - $items[] = $notice; - } else { - } - } - return new ArrayWrapper($items); - } - /** * Saves a list of integer notice_ids into a packed blob in this object. * @param array $ids list of integer notice_ids */ - protected function pack(array $ids) + function pack(array $ids) { $this->notice_ids = call_user_func_array('pack', array_merge(array('N*'), $ids)); } @@ -326,7 +169,7 @@ class Inbox extends Memcached_DataObject /** * @return array of integer notice_ids */ - protected function unpack() + function unpack() { return unpack('N*', $this->notice_ids); } diff --git a/classes/User.php b/classes/User.php index 4fe7efc858..c968375115 100644 --- a/classes/User.php +++ b/classes/User.php @@ -478,34 +478,45 @@ class User extends Memcached_DataObject return Fave::stream($this->id, $offset, $limit, $own, $since_id, $max_id); } + function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) + { + $stream = new InboxNoticeStream($this); + return $stream->getNotices($offset, $limit, $since_id, $before_id); + } + + // DEPRECATED, use noticeInbox() + function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false); + $this->noticeInbox($offset, $limit, $since_id, $before_id); } + // DEPRECATED, use noticeInbox() + function noticesWithFriendsThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNoticesThreaded($this->id, $offset, $limit, $since_id, $before_id, false); + $this->noticeInbox($offset, $limit, $since_id, $before_id); } - function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true); - } + // DEPRECATED, use noticeInbox() function noticeInboxThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNoticesThreaded($this->id, $offset, $limit, $since_id, $before_id, true); + $this->noticeInbox($offset, $limit, $since_id, $before_id); } + // DEPRECATED, use noticeInbox() + function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false); + $this->noticeInbox($offset, $limit, $since_id, $before_id); } + // DEPRECATED, use noticeInbox() + function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true); + $this->noticeInbox($offset, $limit, $since_id, $before_id); } function blowFavesCache() diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php new file mode 100644 index 0000000000..c7939f7977 --- /dev/null +++ b/lib/inboxnoticestream.php @@ -0,0 +1,136 @@ +. + * + * @category Cache + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Stream of notices for the user's inbox + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class InboxNoticeStream extends ScopingNoticeStream +{ + /** + * Constructor + * + * @param User $user User to get a stream for + */ + function __construct($user) + { + // Note: we don't use CachingNoticeStream since RawInboxNoticeStream + // uses Inbox::staticGet(), which is cached. + parent::__construct(new RawInboxNoticeStream($user)); + } +} + +/** + * Raw stream of notices for the user's inbox + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ +class RawInboxNoticeStream extends NoticeStream +{ + protected $user = null; + protected $inbox = null; + + /** + * Constructor + * + * @param User $user User to get a stream for + */ + function __construct($user) + { + $this->user = $user; + $this->inbox = Inbox::staticGet('user_id', $user->id); + } + + /** + * Get IDs in a range + * + * @param int $offset Offset from start + * @param int $limit Limit of number to get + * @param int $since_id Since this notice + * @param int $max_id Before this notice + * + * @return Array IDs found + */ + function getNoticeIds($offset, $limit, $since_id, $max_id) + { + if (empty($this->inbox)) { + $this->inbox = Inbox::fromNoticeInbox($user_id); + if (empty($this->inbox)) { + return array(); + } else { + $this->inbox->encache(); + } + } + + $ids = $this->inbox->unpack(); + + if (!empty($since_id)) { + $newids = array(); + foreach ($ids as $id) { + if ($id > $since_id) { + $newids[] = $id; + } + } + $ids = $newids; + } + + if (!empty($max_id)) { + $newids = array(); + foreach ($ids as $id) { + if ($id <= $max_id) { + $newids[] = $id; + } + } + $ids = $newids; + } + + $ids = array_slice($ids, $offset, $limit); + + return $ids; + } +} \ No newline at end of file From e5495e7df8e3404e68e06517fbbbe852df2bc832 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Fri, 8 Apr 2011 00:39:40 +0530 Subject: [PATCH 244/726] Fix subscription lists --- lib/subscriptionlist.php | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/lib/subscriptionlist.php b/lib/subscriptionlist.php index ea0aa7f1ab..e260c5f7c9 100644 --- a/lib/subscriptionlist.php +++ b/lib/subscriptionlist.php @@ -92,37 +92,4 @@ class SubscriptionListItem extends ProfileListItem $user = common_current_user(); return (!empty($user) && ($this->owner->id == $user->id)); } - - function showTags() - { - $tags = Profile_tag::getTags($this->owner->id, $this->profile->id); - - if ($this->isOwn()) { - $this->out->element('a', array('href' => common_local_url('tagother', - array('id' => $this->profile->id))), - // TRANS: Description for link to "tag other users" in widget to show a list of profiles. - _('Tags')); - } else { - // TRANS: Text widget to show a list of profiles with their tags. - $this->out->text(_('Tags')); - } - if ($tags) { - $this->out->elementStart('ul', 'tags xoxo entity_tags'); - foreach ($tags as $tag) { - $this->out->elementStart('li'); - // Avoid space by using raw output. - $pt = '#'; - $this->out->raw($pt); - $this->out->elementEnd('li'); - } - $this->out->elementEnd('ul'); - } else { - // TRANS: Text if there are no tags in widget to show a list of profiles by tag. - $this->out->text(_('(None)')); - } - } } From 84d848f78cfcb04bceaf8b3a154a7b261a39c1b7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:27:40 -0400 Subject: [PATCH 245/726] correctly return values --- classes/User.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/User.php b/classes/User.php index c968375115..f2b5b08371 100644 --- a/classes/User.php +++ b/classes/User.php @@ -488,28 +488,28 @@ class User extends Memcached_DataObject function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $this->noticeInbox($offset, $limit, $since_id, $before_id); + return $this->noticeInbox($offset, $limit, $since_id, $before_id); } // DEPRECATED, use noticeInbox() function noticesWithFriendsThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $this->noticeInbox($offset, $limit, $since_id, $before_id); + return $this->noticeInbox($offset, $limit, $since_id, $before_id); } // DEPRECATED, use noticeInbox() function noticeInboxThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $this->noticeInbox($offset, $limit, $since_id, $before_id); + return $this->noticeInbox($offset, $limit, $since_id, $before_id); } // DEPRECATED, use noticeInbox() function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $this->noticeInbox($offset, $limit, $since_id, $before_id); + return $this->noticeInbox($offset, $limit, $since_id, $before_id); } // DEPRECATED, use noticeInbox() From 328373e29ce1429c7f7482c52d04ebe8bb70a00a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:28:09 -0400 Subject: [PATCH 246/726] use inboxnoticestream in API --- actions/apitimelinefriends.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 00eb4de502..279265a30e 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -289,15 +289,12 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction { $notices = array(); - if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) { - $notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count, - $this->count, $this->since_id, - $this->max_id); - } else { - $notice = $this->user->friendsTimeline(($this->page-1) * $this->count, - $this->count, $this->since_id, - $this->max_id); - } + $stream = new InboxNoticeStream($this->user); + + $notice = $stream->getNotices(($this->page-1) * $this->count, + $this->count, + $this->since_id, + $this->max_id); while ($notice->fetch()) { $notices[] = clone($notice); From 831eaa039bc5b70532bc556ee47a45ebd03ac5de Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:28:25 -0400 Subject: [PATCH 247/726] use inboxnoticestream in RSS 1.0 --- actions/allrss.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/actions/allrss.php b/actions/allrss.php index 573bb4eb2f..6d82e551e7 100644 --- a/actions/allrss.php +++ b/actions/allrss.php @@ -83,16 +83,9 @@ class AllrssAction extends Rss10Action */ function getNotices($limit=0) { - $cur = common_current_user(); - $user = $this->user; + $stream = new InboxNoticeStream($this->user); + $notice = $stream->getNotices(0, $limit, null, null); - if (!empty($cur) && $cur->id == $user->id) { - $notice = $this->user->noticeInbox(0, $limit); - } else { - $notice = $this->user->noticesWithFriends(0, $limit); - } - - $notice = $user->noticesWithFriends(0, $limit); $notices = array(); while ($notice->fetch()) { From 9cfd1a59ee129bdd875cc6e211925554e3f1a675 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:29:56 -0400 Subject: [PATCH 248/726] use InboxNoticeStream for createsim --- scripts/createsim.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/createsim.php b/scripts/createsim.php index b460be1dd2..f25890676e 100644 --- a/scripts/createsim.php +++ b/scripts/createsim.php @@ -82,7 +82,8 @@ function newNotice($i, $tagmax) if ($is_reply == 0) { common_set_user($user); - $notices = $user->noticesWithFriends(0, 20); + $stream = new InboxNoticeStream($user); + $notices = $stream->getNotices(0, 20, null, null); if ($notices->N > 0) { $nval = rand(0, $notices->N - 1); $notices->fetch(); // go to 0th From fbc18a3c67c732e3daad50c61b858b3e1593e1fb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:35:00 -0400 Subject: [PATCH 249/726] change apitimelinehome to use InboxNoticeStream --- actions/apitimelinehome.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/actions/apitimelinehome.php b/actions/apitimelinehome.php index 96642cbfab..3c18a5b0bf 100644 --- a/actions/apitimelinehome.php +++ b/actions/apitimelinehome.php @@ -192,19 +192,12 @@ class ApiTimelineHomeAction extends ApiBareAuthAction { $notices = array(); - if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) { - $notice = $this->user->noticeInbox( - ($this->page-1) * $this->count, - $this->count, $this->since_id, - $this->max_id - ); - } else { - $notice = $this->user->noticesWithFriends( - ($this->page-1) * $this->count, - $this->count, $this->since_id, - $this->max_id - ); - } + $stream = new InboxNoticeStream($this->user); + + $notice = $stream->getNotices(($this->page-1) * $this->count, + $this->count, + $this->since_id, + $this->max_id); while ($notice->fetch()) { $notices[] = clone($notice); From 684d0a386d5405a692df6c62c147a482e75e3f51 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:39:23 -0400 Subject: [PATCH 250/726] allow passing a profile to inboxnoticestream --- lib/inboxnoticestream.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php index c7939f7977..7570210d3e 100644 --- a/lib/inboxnoticestream.php +++ b/lib/inboxnoticestream.php @@ -52,11 +52,11 @@ class InboxNoticeStream extends ScopingNoticeStream * * @param User $user User to get a stream for */ - function __construct($user) + function __construct($user, $profile = null) { // Note: we don't use CachingNoticeStream since RawInboxNoticeStream // uses Inbox::staticGet(), which is cached. - parent::__construct(new RawInboxNoticeStream($user)); + parent::__construct(new RawInboxNoticeStream($user), $profile); } } From 45ba33e2ac09e61266e454cdf04e15f402dc180c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 15:41:34 -0400 Subject: [PATCH 251/726] use InboxNoticeStream in AllmapAction in Mapstraction --- plugins/Mapstraction/allmap.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/Mapstraction/allmap.php b/plugins/Mapstraction/allmap.php index 62d8d04458..d1a9fddabb 100644 --- a/plugins/Mapstraction/allmap.php +++ b/plugins/Mapstraction/allmap.php @@ -46,15 +46,15 @@ class AllmapAction extends MapAction { function prepare($args) { - if(parent::prepare($args)) { + if (parent::prepare($args)) { $cur = common_current_user(); - if (!empty($cur) && $cur->id == $this->user->id) { - $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - } else { - $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - } + $stream = new InboxNoticeStream($this->user, $cur->getProfile()); + $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1, + null, + null); return true; - }else{ + } else { return false; } } From 3e4016b388181a1185fca496f89780de76875ea4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 16:24:56 -0400 Subject: [PATCH 252/726] do a short-term cache of notice scope --- classes/Notice.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index c908e7e3a7..c80e57dc97 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2182,6 +2182,21 @@ class Notice extends Memcached_DataObject * @return boolean whether the profile is in the notice's scope */ function inScope($profile) + { + $keypart = sprintf('notice:in-scope-for:%d:%d', $this->id, $profile->id); + + $result = self::cacheGet($keypart); + + if ($result === false) { + $bResult = $this->_inScope($profile); + $result = ($bResult) ? 1 : 0; + self::cacheSet($keypart, $result, 0, 300); + } + + return ($result == 1) ? true : false; + } + + protected function _inScope($profile) { // If there's no scope, anyone (even anon) is in scope. From adf4d960133c262f2e7358546c99b727806cebde Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 16:55:32 -0400 Subject: [PATCH 253/726] store oft-requested stuff in the data object --- classes/Notice.php | 16 ++++++++++------ classes/Profile.php | 8 +++++++- classes/User.php | 13 +++++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index c80e57dc97..1688443301 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -96,17 +96,21 @@ class Notice extends Memcached_DataObject const GROUP_SCOPE = 4; const FOLLOWER_SCOPE = 8; + protected $_profile = -1; + function getProfile() { - $profile = Profile::staticGet('id', $this->profile_id); + if ($this->_profile == -1) { + $this->_profile = Profile::staticGet('id', $this->profile_id); - if (empty($profile)) { - // TRANS: Server exception thrown when a user profile for a notice cannot be found. - // TRANS: %1$d is a profile ID (number), %2$d is a notice ID (number). - throw new ServerException(sprintf(_('No such profile (%1$d) for notice (%2$d).'), $this->profile_id, $this->id)); + if (empty($this->_profile)) { + // TRANS: Server exception thrown when a user profile for a notice cannot be found. + // TRANS: %1$d is a profile ID (number), %2$d is a notice ID (number). + throw new ServerException(sprintf(_('No such profile (%1$d) for notice (%2$d).'), $this->profile_id, $this->id)); + } } - return $profile; + return $this->_profile; } function delete() diff --git a/classes/Profile.php b/classes/Profile.php index d87ace42c5..b8c4932780 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -52,9 +52,15 @@ class Profile extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + protected $_user = -1; // Uninitialized value distinct from null + function getUser() { - return User::staticGet('id', $this->id); + if ($this->_user == -1) { + $this->_user = User::staticGet('id', $this->id); + } + + return $this->_user; } function getAvatar($width, $height=null) diff --git a/classes/User.php b/classes/User.php index f2b5b08371..48b0f49f3d 100644 --- a/classes/User.php +++ b/classes/User.php @@ -73,16 +73,21 @@ class User extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + protected $_profile = -1; + /** * @return Profile */ function getProfile() { - $profile = Profile::staticGet('id', $this->id); - if (empty($profile)) { - throw new UserNoProfileException($this); + if ($this->_profile == -1) { // invalid but distinct from null + $this->_profile = Profile::staticGet('id', $this->id); + if (empty($this->_profile)) { + throw new UserNoProfileException($this); + } } - return $profile; + + return $this->_profile; } function isSubscribed($other) From 731bdab804d78012279c6d09a8d4fe783f00593d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 16:57:16 -0400 Subject: [PATCH 254/726] Use pkeyGet() instead of idStream() for fave caching --- classes/Profile.php | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index b8c4932780..2c15826282 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -471,34 +471,6 @@ class Profile extends Memcached_DataObject function hasFave($notice) { - $cache = Cache::instance(); - - // XXX: Kind of a hack. - - if (!empty($cache)) { - // This is the stream of favorite notices, in rev chron - // order. This forces it into cache. - - $ids = Fave::idStream($this->id, 0, CachingNoticeStream::CACHE_WINDOW); - - // If it's in the list, then it's a fave - - if (in_array($notice->id, $ids)) { - return true; - } - - // If we're not past the end of the cache window, - // then the cache has all available faves, so this one - // is not a fave. - - if (count($ids) < CachingNoticeStream::CACHE_WINDOW) { - return false; - } - - // Otherwise, cache doesn't have all faves; - // fall through to the default - } - $fave = Fave::pkeyGet(array('user_id' => $this->id, 'notice_id' => $notice->id)); return ((is_null($fave)) ? false : true); From a5aade0a3b8649b2d58174a22678d83633383cf0 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 7 Apr 2011 12:21:43 +0200 Subject: [PATCH 255/726] Update maintainer e-mail address. Update translator documentation. --- plugins/SQLStats/SQLStatsPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/SQLStats/SQLStatsPlugin.php b/plugins/SQLStats/SQLStatsPlugin.php index 9e810a3ffc..20a9cbada2 100644 --- a/plugins/SQLStats/SQLStatsPlugin.php +++ b/plugins/SQLStats/SQLStatsPlugin.php @@ -25,9 +25,8 @@ if (!defined('STATUSNET')) { * Check DB queries for filesorts and such and log em. * * @package SQLStatsPlugin - * @maintainer Evan Prodromou + * @maintainer Evan Prodromou */ - class SQLStatsPlugin extends Plugin { protected $queryCount = 0; @@ -42,6 +41,7 @@ class SQLStatsPlugin extends Plugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:SQLStats', 'rawdescription' => + // TRANS: Plugin decription. _m('Debug tool to watch for poorly indexed DB queries.')); return true; From f9f437f5dadc5affd1216d0cce0f7c2487902c0e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 7 Apr 2011 12:24:08 +0200 Subject: [PATCH 256/726] Update translator documentation. --- lib/oembedhelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oembedhelper.php b/lib/oembedhelper.php index 4aae815918..6d8064e660 100644 --- a/lib/oembedhelper.php +++ b/lib/oembedhelper.php @@ -131,6 +131,7 @@ class oEmbedHelper } if (empty($api)) { + // TRANS: Server exception thrown in oEmbed action if no API endpoint is available. throw new ServerException(_('No oEmbed API endpoint available.')); } From 2640232c68223f98f08ad7c5fc06ec4b8e99f5e5 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 7 Apr 2011 14:01:40 +0200 Subject: [PATCH 257/726] Update translator documentation. L10n and i18n updates. Break long lines in README before or at 80 characters. Superfluous whitespace removed. --- plugins/Echo/EchoPlugin.php | 1 + .../EmailAuthenticationPlugin.php | 1 + plugins/EmailAuthentication/README | 5 +- plugins/EmailSummary/EmailSummaryPlugin.php | 54 ++++++++----------- plugins/EmailSummary/Email_summary_status.php | 10 +--- .../EmailSummary/siteemailsummaryhandler.php | 16 +++--- .../EmailSummary/useremailsummaryhandler.php | 54 +++++++++---------- plugins/Enjit/enjitqueuehandler.php | 2 +- plugins/Event/EventPlugin.php | 27 ++++++---- plugins/Event/Happening.php | 5 +- plugins/Event/RSVP.php | 40 ++++++++++++-- plugins/Event/cancelrsvp.php | 17 +++--- plugins/Event/cancelrsvpform.php | 12 ++--- plugins/Event/event.css | 1 - plugins/Event/eventform.php | 27 +++++++--- plugins/Event/newevent.php | 26 +++++---- plugins/Event/newrsvp.php | 21 ++++---- plugins/Event/rsvpform.php | 14 +++-- plugins/Event/showevent.php | 2 +- plugins/Event/showrsvp.php | 2 +- 20 files changed, 182 insertions(+), 155 deletions(-) diff --git a/plugins/Echo/EchoPlugin.php b/plugins/Echo/EchoPlugin.php index cd8d8c0e73..a6f87bc38d 100644 --- a/plugins/Echo/EchoPlugin.php +++ b/plugins/Echo/EchoPlugin.php @@ -108,6 +108,7 @@ class EchoPlugin extends Plugin 'author' => 'Zach Copley', 'homepage' => 'http://status.net/wiki/Plugin:Echo', 'rawdescription' => + // TRANS: Plugin description. _m('Use Echo'. ' to add commenting to notice pages.')); return true; diff --git a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php index 689d6231d1..e55614ea43 100644 --- a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php +++ b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php @@ -57,6 +57,7 @@ class EmailAuthenticationPlugin extends Plugin 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:EmailAuthentication', 'rawdescription' => + // TRANS: Plugin description. _m('The Email Authentication plugin allows users to login using their email address.')); return true; } diff --git a/plugins/EmailAuthentication/README b/plugins/EmailAuthentication/README index 3208156896..3fc40794be 100644 --- a/plugins/EmailAuthentication/README +++ b/plugins/EmailAuthentication/README @@ -1,7 +1,8 @@ The Email Authentication plugin allows users to login using their email address. -The provided email address is used to lookup the user's nickname, then that nickname and the provided password is checked. +The provided email address is used to lookup the user's nickname, then that +nickname and the provided password is checked. Installation ============ -add "addPlugin('emailAuthentication');" to the bottom of your config.php +add "addPlugin('emailAuthentication');" to the bottom of your config.php. diff --git a/plugins/EmailSummary/EmailSummaryPlugin.php b/plugins/EmailSummary/EmailSummaryPlugin.php index 66c1214106..36aec6c96c 100644 --- a/plugins/EmailSummary/EmailSummaryPlugin.php +++ b/plugins/EmailSummary/EmailSummaryPlugin.php @@ -43,7 +43,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class EmailSummaryPlugin extends Plugin { /** @@ -51,13 +50,11 @@ class EmailSummaryPlugin extends Plugin * * @return boolean hook value */ - function onCheckSchema() { $schema = Schema::get(); // For storing user-submitted flags on profiles - $schema->ensureTable('email_summary_status', array(new ColumnDef('user_id', 'integer', null, false, 'PRI'), @@ -80,9 +77,8 @@ class EmailSummaryPlugin extends Plugin * @param string $cls Name of the class to be loaded * * @return boolean hook value; true means continue processing, false means stop. - * + * */ - function onAutoload($cls) { $dir = dirname(__FILE__); @@ -107,9 +103,7 @@ class EmailSummaryPlugin extends Plugin * @param array &$versions array of version data * * @return boolean hook value; true means continue processing, false means stop. - * */ - function onPluginVersion(&$versions) { $versions[] = array('name' => 'EmailSummary', @@ -117,86 +111,84 @@ class EmailSummaryPlugin extends Plugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:EmailSummary', 'rawdescription' => + // TRANS: Plugin description. _m('Send an email summary of the inbox to users.')); return true; } /** * Register our queue handlers - * + * * @param QueueManager $qm Current queue manager - * + * * @return boolean hook value */ - function onEndInitializeQueueManager($qm) { $qm->connect('sitesum', 'SiteEmailSummaryHandler'); $qm->connect('usersum', 'UserEmailSummaryHandler'); return true; } - + /** * Add a checkbox to turn off email summaries - * + * * @param Action $action Action being executed (emailsettings) - * + * * @return boolean hook value */ - function onEndEmailFormData($action) { $user = common_current_user(); - + $action->elementStart('li'); $action->checkbox('emailsummary', // TRANS: Checkbox label in e-mail preferences form. - _m('Send me a periodic summary of updates from my network.'), + _m('Send me a periodic summary of updates from my network'), Email_summary_status::getSendSummary($user->id)); $action->elementEnd('li'); return true; } - + /** * Add a checkbox to turn off email summaries - * + * * @param Action $action Action being executed (emailsettings) - * + * * @return boolean hook value */ - function onEndEmailSaveForm($action) { $sendSummary = $action->boolean('emailsummary'); - + $user = common_current_user(); - + if (!empty($user)) { - + $ess = Email_summary_status::staticGet('user_id', $user->id); - + if (empty($ess)) { - + $ess = new Email_summary_status(); $ess->user_id = $user->id; $ess->send_summary = $sendSummary; $ess->created = common_sql_now(); $ess->modified = common_sql_now(); - + $ess->insert(); - + } else { - + $orig = clone($ess); - + $ess->send_summary = $sendSummary; $ess->modified = common_sql_now(); - + $ess->update($orig); } } - + return true; } } diff --git a/plugins/EmailSummary/Email_summary_status.php b/plugins/EmailSummary/Email_summary_status.php index 7072370faf..0c9e880f18 100644 --- a/plugins/EmailSummary/Email_summary_status.php +++ b/plugins/EmailSummary/Email_summary_status.php @@ -35,7 +35,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; /** * Data class for email summaries - * + * * Email summary information for users * * @category Action @@ -46,7 +46,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; * * @see DB_DataObject */ - class Email_summary_status extends Memcached_DataObject { public $__table = 'email_summary_status'; // table name @@ -78,7 +77,6 @@ class Email_summary_status extends Memcached_DataObject * * @return array array of column definitions */ - function table() { return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL, @@ -93,7 +91,6 @@ class Email_summary_status extends Memcached_DataObject * * @return array list of key field names */ - function keys() { return array_keys($this->keyTypes()); @@ -121,7 +118,6 @@ class Email_summary_status extends Memcached_DataObject * * @return array magic three-false array that stops auto-incrementing. */ - function sequenceKey() { return array(false, false, false); @@ -134,7 +130,6 @@ class Email_summary_status extends Memcached_DataObject * * @return int flag for whether to send this user a summary email */ - static function getSendSummary($user_id) { $ess = Email_summary_status::staticGet('user_id', $user_id); @@ -153,11 +148,10 @@ class Email_summary_status extends Memcached_DataObject * * @return Email_summary_status instance for this user, with count already incremented. */ - static function getLastSummaryID($user_id) { $ess = Email_summary_status::staticGet('user_id', $user_id); - + if (!empty($ess)) { return $ess->last_summary_id; } else { diff --git a/plugins/EmailSummary/siteemailsummaryhandler.php b/plugins/EmailSummary/siteemailsummaryhandler.php index 1c0d4997de..3369a5a703 100644 --- a/plugins/EmailSummary/siteemailsummaryhandler.php +++ b/plugins/EmailSummary/siteemailsummaryhandler.php @@ -1,7 +1,7 @@ find(); - + while ($user->fetch()) { try { $qm->enqueue($user->id, 'usersum'); @@ -89,8 +86,7 @@ class SiteEmailSummaryHandler extends QueueHandler } catch (Exception $e) { common_log(LOG_WARNING, $e->getMessage()); } - + return true; } } - diff --git a/plugins/EmailSummary/useremailsummaryhandler.php b/plugins/EmailSummary/useremailsummaryhandler.php index 5e10af40eb..2c8c0d9039 100644 --- a/plugins/EmailSummary/useremailsummaryhandler.php +++ b/plugins/EmailSummary/useremailsummaryhandler.php @@ -1,7 +1,7 @@ send_summary) { common_log(LOG_INFO, sprintf('Not sending email summary for user %s by request.', $user_id)); return true; } $since_id = null; - + if (!empty($ess)) { $since_id = $ess->last_summary_id; } - + $user = User::staticGet('id', $user_id); if (empty($user)) { common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no such user.', $user_id)); return true; } - + if (empty($user->email)) { common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no email address.', $user_id)); return true; } - + $profile = $user->getProfile(); - + if (empty($profile)) { common_log(LOG_WARNING, sprintf('Not sending email summary for user %s; no profile.', $user_id)); return true; } - + $notice = $user->ownFriendsTimeline(0, self::MAX_NOTICES, $since_id); if (empty($notice) || $notice->N == 0) { @@ -117,18 +113,20 @@ class UserEmailSummaryHandler extends QueueHandler // figuring out a better way. -ESP $new_top = null; - + if ($notice instanceof ArrayWrapper) { $new_top = $notice->_items[0]->id; } - + $out = new XMLStringer(); $out->elementStart('div', array('width' => '100%', 'style' => 'background-color: #ffffff; border: 4px solid #4c609a; padding: 10px;')); $out->elementStart('div', array('style' => 'color: #ffffff; background-color: #4c609a; font-weight: bold; margin-bottom: 10px; padding: 4px;')); - $out->raw(sprintf(_m('Recent updates from %1s for %2s:'), + // TRANS: Text in e-mail summary. + // TRANS: %1$s is the StatusNet sitename, %2$s is the recipient's profile name. + $out->raw(sprintf(_m('Recent updates from %1$s for %2s:'), common_config('site', 'name'), $profile->getBestName())); $out->elementEnd('div'); @@ -137,13 +135,12 @@ class UserEmailSummaryHandler extends QueueHandler 'style' => 'border: none; border-collapse: collapse;', 'cellpadding' => '6')); while ($notice->fetch()) { - $profile = Profile::staticGet('id', $notice->profile_id); - + if (empty($profile)) { continue; } - + $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); $out->elementStart('tr'); @@ -191,7 +188,7 @@ class UserEmailSummaryHandler extends QueueHandler $out->elementEnd('td'); $out->elementEnd('tr'); } - + $out->elementEnd('table'); $out->raw(sprintf(_m('

                  change your email settings for %2s

                  '), @@ -199,35 +196,32 @@ class UserEmailSummaryHandler extends QueueHandler common_config('site', 'name'))); $out->elementEnd('div'); - + $body = $out->getString(); - + // FIXME: do something for people who don't like HTML email - + mail_to_user($user, _m('Updates from your network'), $body, array('Content-Type' => 'text/html; charset=UTF-8')); if (empty($ess)) { - $ess = new Email_summary_status(); - + $ess->user_id = $user_id; $ess->created = common_sql_now(); $ess->last_summary_id = $new_top; $ess->modified = common_sql_now(); $ess->insert(); - } else { - $orig = clone($ess); - + $ess->last_summary_id = $new_top; $ess->modified = common_sql_now(); $ess->update($orig); } - + return true; } } diff --git a/plugins/Enjit/enjitqueuehandler.php b/plugins/Enjit/enjitqueuehandler.php index 4a68f4f6b6..284f29477c 100644 --- a/plugins/Enjit/enjitqueuehandler.php +++ b/plugins/Enjit/enjitqueuehandler.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { /** * Queue handler for watching new notices and posting to enjit. - * @fixme is this actually being used/functional atm? + * @todo FIXME: Is this actually being used/functional atm? */ class EnjitQueueHandler extends QueueHandler { diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 528c855bda..63d92e63c7 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -105,7 +105,6 @@ class EventPlugin extends MicroappPlugin * * @return boolean hook value; true means continue processing, false means stop. */ - function onRouterInitialized($m) { $m->connect('main/event/new', @@ -130,12 +129,14 @@ class EventPlugin extends MicroappPlugin 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Event', 'description' => + // TRANS: Plugin description. _m('Event invitations and RSVPs.')); return true; } function appTitle() { - return _m('Event'); + // TRANS: Title for event application. + return _m('TITLE','Event'); } function tag() { @@ -162,12 +163,13 @@ class EventPlugin extends MicroappPlugin function saveNoticeFromActivity($activity, $actor, $options=array()) { if (count($activity->objects) != 1) { - throw new Exception('Too many activity objects.'); + throw new Exception(_('Too many activity objects.')); } $happeningObj = $activity->objects[0]; if ($happeningObj->type != Happening::OBJECT_TYPE) { + // TRANS: Exception thrown when event plugin comes across a non-event type object. throw new Exception(_m('Wrong type for object.')); } @@ -175,8 +177,8 @@ class EventPlugin extends MicroappPlugin switch ($activity->verb) { case ActivityVerb::POST: - $notice = Happening::saveNew($actor, - $start_time, + $notice = Happening::saveNew($actor, + $start_time, $end_time, $happeningObj->title, null, @@ -189,12 +191,14 @@ class EventPlugin extends MicroappPlugin $happening = Happening::staticGet('uri', $happeningObj->id); if (empty($happening)) { // FIXME: save the event + // TRANS: Exception thrown when trying to RSVP for an unknown event. throw new Exception(_m('RSVP for unknown event.')); } $notice = RSVP::saveNew($actor, $happening, $activity->verb, $options); break; default: - throw new Exception(_m('Unknown verb for events')); + // TRANS: Exception thrown when event plugin comes across a undefined verb. + throw new Exception(_m('Unknown verb for events.')); } return $notice; @@ -207,7 +211,6 @@ class EventPlugin extends MicroappPlugin * * @return ActivityObject */ - function activityObjectFromNotice($notice) { $happening = null; @@ -225,12 +228,14 @@ class EventPlugin extends MicroappPlugin } if (empty($happening)) { + // TRANS: Exception thrown when event plugin comes across a unknown object type. throw new Exception(_m('Unknown object type.')); } $notice = $happening->getNotice(); if (empty($notice)) { + // TRANS: Exception thrown when referring to a notice that is not an event an in event context. throw new Exception(_m('Unknown event notice.')); } @@ -264,7 +269,6 @@ class EventPlugin extends MicroappPlugin * * @return ActivityObject */ - function onEndNoticeAsActivity($notice, &$act) { switch ($notice->object_type) { case RSVP::POSITIVE: @@ -282,7 +286,6 @@ class EventPlugin extends MicroappPlugin * @param Notice $notice * @param HTMLOutputter $out */ - function showNotice($notice, $out) { switch ($notice->object_type) { @@ -365,6 +368,7 @@ class EventPlugin extends MicroappPlugin $out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN + // TRANS: Field label for event description. $out->element('strong', null, _m('Time:')); $out->element('abbr', array('class' => 'dtstart', @@ -385,6 +389,7 @@ class EventPlugin extends MicroappPlugin if (!empty($event->location)) { $out->elementStart('div', 'event-location'); + // TRANS: Field label for event description. $out->element('strong', null, _m('Location:')); $out->element('span', 'location', $event->location); $out->elementEnd('div'); @@ -392,6 +397,7 @@ class EventPlugin extends MicroappPlugin if (!empty($event->description)) { $out->elementStart('div', 'event-description'); + // TRANS: Field label for event description. $out->element('strong', null, _m('Description:')); $out->element('span', 'description', $event->description); $out->elementEnd('div'); @@ -400,6 +406,7 @@ class EventPlugin extends MicroappPlugin $rsvps = $event->getRSVPs(); $out->elementStart('div', 'event-rsvps'); + // TRANS: Field label for event description. $out->element('strong', null, _m('Attending:')); $out->element('span', 'event-rsvps', // TRANS: RSVP counts. @@ -433,7 +440,6 @@ class EventPlugin extends MicroappPlugin * @param HTMLOutputter $out * @return Widget */ - function entryForm($out) { return new EventForm($out); @@ -444,7 +450,6 @@ class EventPlugin extends MicroappPlugin * * @param Notice $notice */ - function deleteRelated($notice) { switch ($notice->object_type) { diff --git a/plugins/Event/Happening.php b/plugins/Event/Happening.php index ec3e12595d..a2811252c0 100644 --- a/plugins/Event/Happening.php +++ b/plugins/Event/Happening.php @@ -47,7 +47,6 @@ if (!defined('STATUSNET')) { * * @see Managed_DataObject */ - class Happening extends Managed_DataObject { const OBJECT_TYPE = 'http://activitystrea.ms/schema/1.0/event'; @@ -122,6 +121,7 @@ class Happening extends Managed_DataObject if (array_key_exists('uri', $options)) { $other = Happening::staticGet('uri', $options['uri']); if (!empty($other)) { + // TRANS: Client exception thrown when trying to create an event that already exists. throw new ClientException(_m('Event already exists.')); } } @@ -163,6 +163,9 @@ class Happening extends Managed_DataObject $location, $description); + // TRANS: Rendered event description. %1$s is a title, %2$s is start time, %3$s is start time, + // TRANS: %4$s is end time, %5$s is end time, %6$s is location, %7$s is description. + // TRANS: Class names should not be translated. $rendered = sprintf(_m(''. '%1$s '. '%3$s - '. diff --git a/plugins/Event/RSVP.php b/plugins/Event/RSVP.php index 85862d375d..1f47958e9a 100644 --- a/plugins/Event/RSVP.php +++ b/plugins/Event/RSVP.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET')) { * * @see Managed_DataObject */ - class RSVP extends Managed_DataObject { const POSITIVE = 'http://activitystrea.ms/schema/1.0/rsvp-yes'; @@ -64,7 +63,6 @@ class RSVP extends Managed_DataObject * @param mixed $v Value to lookup * * @return RSVP object found, or null for no hits - * */ function staticGet($k, $v=null) { @@ -77,7 +75,6 @@ class RSVP extends Managed_DataObject * @param array $kv array of key-value mappings * * @return Bookmark object found, or null for no hits - * */ function pkeyGet($kv) @@ -141,6 +138,7 @@ class RSVP extends Managed_DataObject if (array_key_exists('uri', $options)) { $other = RSVP::staticGet('uri', $options['uri']); if (!empty($other)) { + // TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond"). throw new ClientException(_m('RSVP already exists.')); } } @@ -149,6 +147,7 @@ class RSVP extends Managed_DataObject 'event_id' => $event->id)); if (!empty($other)) { + // TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond"). throw new ClientException(_m('RSVP already exists.')); } @@ -179,7 +178,7 @@ class RSVP extends Managed_DataObject // XXX: come up with something sexier $content = $rsvp->asString(); - + $rendered = $rsvp->asHTML(); $options = array_merge(array('object_type' => $verb), @@ -217,7 +216,8 @@ class RSVP extends Managed_DataObject return '?'; break; default: - throw new Exception(sprintf(_m('Unknown verb "%s"'),$verb)); + // TRANS: Exception thrown when requesting an undefined verb for RSVP. + throw new Exception(sprintf(_m('Unknown verb "%s".'),$verb)); } } @@ -234,6 +234,7 @@ class RSVP extends Managed_DataObject return RSVP::POSSIBLE; break; default: + // TRANS: Exception thrown when requesting an undefined code for RSVP. throw new Exception(sprintf(_m('Unknown code "%s".'),$code)); } } @@ -242,6 +243,8 @@ class RSVP extends Managed_DataObject { $notice = Notice::staticGet('uri', $this->uri); if (empty($notice)) { + // TRANS: Server exception thrown when requesting a non-exsting notice for an RSVP ("please respond"). + // TRANS: %s is the RSVP with the missing notice. throw new ServerException(sprintf(_m('RSVP %s does not correspond to a notice in the database.'),$this->id)); } return $notice; @@ -297,6 +300,8 @@ class RSVP extends Managed_DataObject { $profile = Profile::staticGet('id', $this->profile_id); if (empty($profile)) { + // TRANS: Exception thrown when requesting a non-existing profile. + // TRANS: %s is the ID of the non-existing profile. throw new Exception(sprintf(_m('No profile with ID %s.'),$this->profile_id)); } return $profile; @@ -306,6 +311,8 @@ class RSVP extends Managed_DataObject { $event = Happening::staticGet('id', $this->event_id); if (empty($event)) { + // TRANS: Exception thrown when requesting a non-existing event. + // TRANS: %s is the ID of the non-existing event. throw new Exception(sprintf(_m('No event with ID %s.'),$this->event_id)); } return $event; @@ -335,21 +342,34 @@ class RSVP extends Managed_DataObject switch ($response) { case 'Y': + // TRANS: HTML version of an RSVP ("please respond") status for a user. + // TRANS: %1$s is a profile URL, %2$s a profile name, + // TRANS: %3$s is an event URL, %4$s an event title. $fmt = _m("%2\$s is attending %4\$s."); break; case 'N': + // TRANS: HTML version of an RSVP ("please respond") status for a user. + // TRANS: %1$s is a profile URL, %2$s a profile name, + // TRANS: %3$s is an event URL, %4$s an event title. $fmt = _m("%2\$s is not attending %4\$s."); break; case '?': + // TRANS: HTML version of an RSVP ("please respond") status for a user. + // TRANS: %1$s is a profile URL, %2$s a profile name, + // TRANS: %3$s is an event URL, %4$s an event title. $fmt = _m("%2\$s might attend %4\$s."); break; default: + // TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code. + // TRANS: %s is the non-existing response code. throw new Exception(sprintf(_m('Unknown response code %s.'),$response)); break; } if (empty($event)) { $eventUrl = '#'; + // TRANS: Used as event title when not event title is available. + // TRANS: Used as: Username [is [not ] attending|might attend] an unknown event. $eventTitle = _m('an unknown event'); } else { $notice = $event->getNotice(); @@ -370,20 +390,30 @@ class RSVP extends Managed_DataObject switch ($response) { case 'Y': + // TRANS: Plain text version of an RSVP ("please respond") status for a user. + // TRANS: %1$s is a profile name, %2$s is an event title. $fmt = _m('%1$s is attending %2$s.'); break; case 'N': + // TRANS: Plain text version of an RSVP ("please respond") status for a user. + // TRANS: %1$s is a profile name, %2$s is an event title. $fmt = _m('%1$s is not attending %2$s.'); break; case '?': + // TRANS: Plain text version of an RSVP ("please respond") status for a user. + // TRANS: %1$s is a profile name, %2$s is an event title. $fmt = _m('%1$s might attend %2$s.'); break; default: + // TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code. + // TRANS: %s is the non-existing response code. throw new Exception(sprintf(_m('Unknown response code %s.'),$response)); break; } if (empty($event)) { + // TRANS: Used as event title when not event title is available. + // TRANS: Used as: Username [is [not ] attending|might attend] an unknown event. $eventTitle = _m('an unknown event'); } else { $notice = $event->getNotice(); diff --git a/plugins/Event/cancelrsvp.php b/plugins/Event/cancelrsvp.php index 94f78bfca6..6b0ddb2287 100644 --- a/plugins/Event/cancelrsvp.php +++ b/plugins/Event/cancelrsvp.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Cancel the RSVP for an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ + if (!defined('STATUSNET')) { // This check helps protect against security problems; // your code file can't be executed directly from the web. @@ -43,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class CancelrsvpAction extends Action { protected $user = null; @@ -55,10 +55,10 @@ class CancelrsvpAction extends Action * * @return string Action title */ - function title() { - return _m('Cancel RSVP'); + // TRANS: Title for RSVP ("please respond") action. + return _m('TITLE','Cancel RSVP'); } /** @@ -68,7 +68,6 @@ class CancelrsvpAction extends Action * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); @@ -79,24 +78,28 @@ class CancelrsvpAction extends Action $rsvpId = $this->trimmed('rsvp'); if (empty($rsvpId)) { + // TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item. throw new ClientException(_m('No such RSVP.')); } $this->rsvp = RSVP::staticGet('id', $rsvpId); if (empty($this->rsvp)) { + // TRANS: Client exception thrown when referring to a non-existing RSVP ("please respond") item. throw new ClientException(_m('No such RSVP.')); } $this->event = Happening::staticGet('id', $this->rsvp->event_id); if (empty($this->event)) { + // TRANS: Client exception thrown when referring to a non-existing event. throw new ClientException(_m('No such event.')); } $this->user = common_current_user(); if (empty($this->user)) { + // TRANS: Client exception thrown when trying tp RSVP ("please respond") while not logged in. throw new ClientException(_m('You must be logged in to RSVP for an event.')); } @@ -110,7 +113,6 @@ class CancelrsvpAction extends Action * * @return void */ - function handle($argarray=null) { parent::handle($argarray); @@ -129,7 +131,6 @@ class CancelrsvpAction extends Action * * @return void */ - function cancelRSVP() { try { @@ -171,7 +172,6 @@ class CancelrsvpAction extends Action * * @return void */ - function showContent() { if (!empty($this->error)) { @@ -194,7 +194,6 @@ class CancelrsvpAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { if ($_SERVER['REQUEST_METHOD'] == 'GET' || diff --git a/plugins/Event/cancelrsvpform.php b/plugins/Event/cancelrsvpform.php index 14161d1897..107351135a 100644 --- a/plugins/Event/cancelrsvpform.php +++ b/plugins/Event/cancelrsvpform.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Form to RSVP for an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class CancelRSVPForm extends Form { protected $rsvp = null; @@ -60,7 +59,6 @@ class CancelRSVPForm extends Form * * @return int ID of the form */ - function id() { return 'form_event_rsvp'; @@ -71,7 +69,6 @@ class CancelRSVPForm extends Form * * @return string class of the form */ - function formClass() { return 'ajax'; @@ -82,7 +79,6 @@ class CancelRSVPForm extends Form * * @return string URL of the action */ - function action() { return common_local_url('cancelrsvp'); @@ -93,7 +89,6 @@ class CancelRSVPForm extends Form * * @return void */ - function formData() { $this->out->elementStart('fieldset', array('id' => 'new_rsvp_data')); @@ -102,12 +97,15 @@ class CancelRSVPForm extends Form switch (RSVP::verbFor($this->rsvp->response)) { case RSVP::POSITIVE: + // TRANS: Possible status for RSVP ("please respond") item. $this->out->text(_m('You will attend this event.')); break; case RSVP::NEGATIVE: + // TRANS: Possible status for RSVP ("please respond") item. $this->out->text(_m('You will not attend this event.')); break; case RSVP::POSSIBLE: + // TRANS: Possible status for RSVP ("please respond") item. $this->out->text(_m('You might attend this event.')); break; } @@ -120,9 +118,9 @@ class CancelRSVPForm extends Form * * @return void */ - function formActions() { + // TRANS: Button text to cancel responding to an RSVP ("please respond") item. $this->out->submit('cancel', _m('BUTTON', 'Cancel')); } } diff --git a/plugins/Event/event.css b/plugins/Event/event.css index a922bb5791..8c9cbbb082 100644 --- a/plugins/Event/event.css +++ b/plugins/Event/event.css @@ -6,4 +6,3 @@ .event-title { margin-left: 0px; } #content .event .entry-title { margin-left: 0px; } #content .event .entry-content { margin-left: 0px; } - diff --git a/plugins/Event/eventform.php b/plugins/Event/eventform.php index 9c9a86229b..832604a31d 100644 --- a/plugins/Event/eventform.php +++ b/plugins/Event/eventform.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Form for entering an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class EventForm extends Form { /** @@ -52,7 +51,6 @@ class EventForm extends Form * * @return int ID of the form */ - function id() { return 'form_new_event'; @@ -63,7 +61,6 @@ class EventForm extends Form * * @return string class of the form */ - function formClass() { return 'form_settings ajax-notice'; @@ -74,7 +71,6 @@ class EventForm extends Form * * @return string URL of the action */ - function action() { return common_local_url('newevent'); @@ -85,7 +81,6 @@ class EventForm extends Form * * @return void */ - function formData() { $this->out->elementStart('fieldset', array('id' => 'new_bookmark_data')); @@ -93,57 +88,73 @@ class EventForm extends Form $this->li(); $this->out->input('title', + // TRANS: Field label on event form. _m('LABEL','Title'), null, + // TRANS: Field title on event form. _m('Title of the event.')); $this->unli(); $this->li(); $this->out->input('startdate', + // TRANS: Field label on event form. _m('LABEL','Start date'), null, + // TRANS: Field title on event form. _m('Date the event starts.')); $this->unli(); $this->li(); $this->out->input('starttime', + // TRANS: Field label on event form. _m('LABEL','Start time'), null, + // TRANS: Field title on event form. _m('Time the event starts.')); $this->unli(); $this->li(); $this->out->input('enddate', + // TRANS: Field label on event form. _m('LABEL','End date'), - null, + null, + // TRANS: Field title on event form. _m('Date the event ends.')); $this->unli(); $this->li(); $this->out->input('endtime', + // TRANS: Field label on event form. _m('LABEL','End time'), null, + // TRANS: Field title on event form. _m('Time the event ends.')); $this->unli(); $this->li(); $this->out->input('location', + // TRANS: Field label on event form. _m('LABEL','Location'), null, + // TRANS: Field title on event form. _m('Event location.')); $this->unli(); $this->li(); $this->out->input('url', + // TRANS: Field label on event form. _m('LABEL','URL'), null, + // TRANS: Field title on event form. _m('URL for more information.')); $this->unli(); $this->li(); $this->out->input('description', + // TRANS: Field label on event form. _m('LABEL','Description'), null, + // TRANS: Field title on event form. _m('Description of the event.')); $this->unli(); @@ -162,9 +173,9 @@ class EventForm extends Form * * @return void */ - function formActions() { + // TRANS: Button text to save an event.. $this->out->submit('submit', _m('BUTTON', 'Save')); } } diff --git a/plugins/Event/newevent.php b/plugins/Event/newevent.php index 93baa37b6b..cadf0e1433 100644 --- a/plugins/Event/newevent.php +++ b/plugins/Event/newevent.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Add a new event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ + if (!defined('STATUSNET')) { // This check helps protect against security problems; // your code file can't be executed directly from the web. @@ -43,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class NeweventAction extends Action { protected $user = null; @@ -60,10 +60,10 @@ class NeweventAction extends Action * * @return string Action title */ - function title() { - return _m('New event'); + // TRANS: Title for new event form. + return _m('TITLE','New event'); } /** @@ -73,7 +73,6 @@ class NeweventAction extends Action * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); @@ -81,6 +80,7 @@ class NeweventAction extends Action $this->user = common_current_user(); if (empty($this->user)) { + // TRANS: Client exception thrown when trying to post an event while not logged in. throw new ClientException(_m('Must be logged in to post a event.'), 403); } @@ -92,6 +92,7 @@ class NeweventAction extends Action $this->title = $this->trimmed('title'); if (empty($this->title)) { + // TRANS: Client exception thrown when trying to post an event without providing a title. throw new ClientException(_m('Title required.')); } @@ -102,6 +103,7 @@ class NeweventAction extends Action $startDate = $this->trimmed('startdate'); if (empty($startDate)) { + // TRANS: Client exception thrown when trying to post an event without providing a start date. throw new ClientException(_m('Start date required.')); } @@ -114,6 +116,7 @@ class NeweventAction extends Action $endDate = $this->trimmed('enddate'); if (empty($endDate)) { + // TRANS: Client exception thrown when trying to post an event without providing an end date. throw new ClientException(_m('End date required.')); } @@ -135,12 +138,16 @@ class NeweventAction extends Action $this->endTime = strtotime($end); if ($this->startTime == 0) { + // TRANS: Client exception thrown when trying to post an event with a date that cannot be processed. + // TRANS: %s is the data that could not be processed. throw new Exception(sprintf(_m('Could not parse date "%s".'), $start)); } if ($this->endTime == 0) { + // TRANS: Client exception thrown when trying to post an event with a date that cannot be processed. + // TRANS: %s is the data that could not be processed. throw new Exception(sprintf(_m('Could not parse date "%s".'), $end)); } @@ -155,7 +162,6 @@ class NeweventAction extends Action * * @return void */ - function handle($argarray=null) { parent::handle($argarray); @@ -174,19 +180,21 @@ class NeweventAction extends Action * * @return void */ - function newEvent() { try { if (empty($this->title)) { + // TRANS: Client exception thrown when trying to post an event without providing a title. throw new ClientException(_m('Event must have a title.')); } if (empty($this->startTime)) { + // TRANS: Client exception thrown when trying to post an event without providing a start time. throw new ClientException(_m('Event must have a start time.')); } if (empty($this->endTime)) { + // TRANS: Client exception thrown when trying to post an event without providing an end time. throw new ClientException(_m('Event must have an end time.')); } @@ -195,7 +203,7 @@ class NeweventAction extends Action // Does the heavy-lifting for getting "To:" information ToSelector::fillOptions($this, $options); - + $profile = $this->user->getProfile(); $saved = Happening::saveNew($profile, @@ -239,7 +247,6 @@ class NeweventAction extends Action * * @return void */ - function showContent() { if (!empty($this->error)) { @@ -262,7 +269,6 @@ class NeweventAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { if ($_SERVER['REQUEST_METHOD'] == 'GET' || diff --git a/plugins/Event/newrsvp.php b/plugins/Event/newrsvp.php index cb7f72d49c..b000767340 100644 --- a/plugins/Event/newrsvp.php +++ b/plugins/Event/newrsvp.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * RSVP for an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -27,6 +27,7 @@ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ + if (!defined('STATUSNET')) { // This check helps protect against security problems; // your code file can't be executed directly from the web. @@ -43,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class NewrsvpAction extends Action { protected $user = null; @@ -55,10 +55,10 @@ class NewrsvpAction extends Action * * @return string Action title */ - function title() { - return _m('New RSVP'); + // TRANS: Title for RSVP ("please respond") action. + return _m('TITLE','New RSVP'); } /** @@ -68,7 +68,6 @@ class NewrsvpAction extends Action * * @return boolean true */ - function prepare($argarray) { parent::prepare($argarray); @@ -79,18 +78,21 @@ class NewrsvpAction extends Action $eventId = $this->trimmed('event'); if (empty($eventId)) { + // TRANS: Client exception thrown when requesting a non-exsting event. throw new ClientException(_m('No such event.')); } $this->event = Happening::staticGet('id', $eventId); if (empty($this->event)) { + // TRANS: Client exception thrown when requesting a non-exsting event. throw new ClientException(_m('No such event.')); } $this->user = common_current_user(); if (empty($this->user)) { + // TRANS: Client exception thrown when trying to RSVP ("please respond") while not logged in. throw new ClientException(_m('You must be logged in to RSVP for an event.')); } @@ -107,7 +109,8 @@ class NewrsvpAction extends Action $this->verb = RSVP::POSSIBLE; break; default: - throw new ClientException('Unknown submit value.'); + // TRANS: Client exception thrown when using an invalud value for RSVP ("please respond"). + throw new ClientException(_('Unknown submit value.')); } return true; @@ -120,7 +123,6 @@ class NewrsvpAction extends Action * * @return void */ - function handle($argarray=null) { parent::handle($argarray); @@ -139,7 +141,6 @@ class NewrsvpAction extends Action * * @return void */ - function newRSVP() { try { @@ -158,7 +159,7 @@ class NewrsvpAction extends Action $this->xw->startDocument('1.0', 'UTF-8'); $this->elementStart('html'); $this->elementStart('head'); - // TRANS: Page title after sending a notice. + // TRANS: Page title after creating an event. $this->element('title', null, _m('Event saved')); $this->elementEnd('head'); $this->elementStart('body'); @@ -178,7 +179,6 @@ class NewrsvpAction extends Action * * @return void */ - function showContent() { if (!empty($this->error)) { @@ -201,7 +201,6 @@ class NewrsvpAction extends Action * * @return boolean is read only action? */ - function isReadOnly($args) { if ($_SERVER['REQUEST_METHOD'] == 'GET' || diff --git a/plugins/Event/rsvpform.php b/plugins/Event/rsvpform.php index 494e64929f..6f86004f94 100644 --- a/plugins/Event/rsvpform.php +++ b/plugins/Event/rsvpform.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Form to RSVP for an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class RSVPForm extends Form { protected $event = null; @@ -60,7 +59,6 @@ class RSVPForm extends Form * * @return int ID of the form */ - function id() { return 'form_event_rsvp'; @@ -71,7 +69,6 @@ class RSVPForm extends Form * * @return string class of the form */ - function formClass() { return 'ajax'; @@ -82,7 +79,6 @@ class RSVPForm extends Form * * @return string URL of the action */ - function action() { return common_local_url('newrsvp'); @@ -93,11 +89,11 @@ class RSVPForm extends Form * * @return void */ - function formData() { $this->out->elementStart('fieldset', array('id' => 'new_rsvp_data')); + // TRANS: Field label on form to RSVP ("please respond") for an event. $this->out->text(_m('RSVP:')); $this->out->hidden('event', $this->event->id); @@ -111,14 +107,16 @@ class RSVPForm extends Form * * @return void */ - function formActions() { + // TRANS: Button text for RSVP ("please respond") reply to confirm attendence. $this->submitButton('yes', _m('BUTTON', 'Yes')); + // TRANS: Button text for RSVP ("please respond") reply to deny attendence. $this->submitButton('no', _m('BUTTON', 'No')); + // TRANS: Button text for RSVP ("please respond") reply to indicate one might attend. $this->submitButton('maybe', _m('BUTTON', 'Maybe')); } - + function submitButton($id, $label) { $this->out->element('input', array('type' => 'submit', diff --git a/plugins/Event/showevent.php b/plugins/Event/showevent.php index e5afd47d00..52e17f860a 100644 --- a/plugins/Event/showevent.php +++ b/plugins/Event/showevent.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Show a single event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify diff --git a/plugins/Event/showrsvp.php b/plugins/Event/showrsvp.php index 7b129177e1..da80448af8 100644 --- a/plugins/Event/showrsvp.php +++ b/plugins/Event/showrsvp.php @@ -4,7 +4,7 @@ * Copyright (C) 2010, StatusNet, Inc. * * Show a single RSVP - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify From a9eaaf634197de91175d6528ca648bbfcc0aa2fd Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 7 Apr 2011 22:25:16 +0200 Subject: [PATCH 258/726] Update translator documentation. Whitespace updates. L10n/i18n updates. --- .../ExtendedProfile/ExtendedProfilePlugin.php | 7 ++- .../classes/Profile_detail.php | 4 +- .../ExtendedProfile/lib/extendedprofile.php | 24 +++++++++ .../lib/extendedprofilewidget.php | 54 ++++++++++++++----- 4 files changed, 69 insertions(+), 20 deletions(-) diff --git a/plugins/ExtendedProfile/ExtendedProfilePlugin.php b/plugins/ExtendedProfile/ExtendedProfilePlugin.php index ce1593dad5..51584e9f91 100644 --- a/plugins/ExtendedProfile/ExtendedProfilePlugin.php +++ b/plugins/ExtendedProfile/ExtendedProfilePlugin.php @@ -29,7 +29,6 @@ if (!defined('STATUSNET')) { */ class ExtendedProfilePlugin extends Plugin { - function onPluginVersion(&$versions) { $versions[] = array( @@ -37,8 +36,8 @@ class ExtendedProfilePlugin extends Plugin 'version' => STATUSNET_VERSION, 'author' => 'Brion Vibber, Samantha Doherty, Zach Copley', 'homepage' => 'http://status.net/wiki/Plugin:ExtendedProfile', - 'rawdescription' => _m( - 'UI extensions for additional profile fields.') + // TRANS: Plugin description. + 'rawdescription' => _m('UI extensions for additional profile fields.') ); return true; @@ -120,9 +119,9 @@ class ExtendedProfilePlugin extends Plugin $user = User::staticGet('id', $profile->id); if ($user) { $url = common_local_url('profiledetail', array('nickname' => $user->nickname)); + // TRANS: Link text on user profile page leading to extended profile page. $out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...')); } return true; } - } diff --git a/plugins/ExtendedProfile/classes/Profile_detail.php b/plugins/ExtendedProfile/classes/Profile_detail.php index 96869b0e63..94e52c396c 100644 --- a/plugins/ExtendedProfile/classes/Profile_detail.php +++ b/plugins/ExtendedProfile/classes/Profile_detail.php @@ -80,7 +80,6 @@ class Profile_detail extends Managed_DataObject * @return User_greeting_count object found, or null for no hits * */ - function staticGet($k, $v=null) { return Memcached_DataObject::staticGet('Profile_detail', $k, $v); @@ -98,7 +97,6 @@ class Profile_detail extends Managed_DataObject * @return Bookmark object found, or null for no hits * */ - function pkeyGet($kv) { return Memcached_DataObject::pkeyGet('Profile_detail', $kv); @@ -107,6 +105,7 @@ class Profile_detail extends Managed_DataObject static function schemaDef() { return array( + // No need for i18n. Table properties. 'description' => 'Additional profile details for the ExtendedProfile plugin', 'fields' => array( @@ -138,5 +137,4 @@ class Profile_detail extends Managed_DataObject ) ); } - } diff --git a/plugins/ExtendedProfile/lib/extendedprofile.php b/plugins/ExtendedProfile/lib/extendedprofile.php index fa632e5073..d73170b235 100644 --- a/plugins/ExtendedProfile/lib/extendedprofile.php +++ b/plugins/ExtendedProfile/lib/extendedprofile.php @@ -116,6 +116,7 @@ class ExtendedProfile if (empty($phones)) { $pArrays[] = array( + // TRANS: Field label for extended profile properties. 'label' => _m('Phone'), 'index' => 0, 'type' => 'phone', @@ -126,6 +127,7 @@ class ExtendedProfile } else { for ($i = 0; $i < sizeof($phones); $i++) { $pa = array( + // TRANS: Field label for extended profile properties. 'label' => _m('Phone'), 'type' => 'phone', 'index' => intval($phones[$i]->value_index), @@ -147,12 +149,14 @@ class ExtendedProfile if (empty($ims)) { $iArrays[] = array( + // TRANS: Field label for extended profile properties (Instant Messaging). 'label' => _m('IM'), 'type' => 'im' ); } else { for ($i = 0; $i < sizeof($ims); $i++) { $ia = array( + // TRANS: Field label for extended profile properties (Instant Messaging). 'label' => _m('IM'), 'type' => 'im', 'index' => intval($ims[$i]->value_index), @@ -173,12 +177,14 @@ class ExtendedProfile if (empty($sites)) { $wArrays[] = array( + // TRANS: Field label for extended profile properties. 'label' => _m('Website'), 'type' => 'website' ); } else { for ($i = 0; $i < sizeof($sites); $i++) { $wa = array( + // TRANS: Field label for extended profile properties. 'label' => _m('Website'), 'type' => 'website', 'index' => intval($sites[$i]->value_index), @@ -202,6 +208,7 @@ class ExtendedProfile if (empty($companies)) { $eArrays[] = array( + // TRANS: Field label for extended profile properties. 'label' => _m('Employer'), 'type' => 'experience', 'company' => null, @@ -213,6 +220,7 @@ class ExtendedProfile } else { for ($i = 0; $i < sizeof($companies); $i++) { $ea = array( + // TRANS: Field label for extended profile properties. 'label' => _m('Employer'), 'type' => 'experience', 'company' => $companies[$i]->field_value, @@ -239,6 +247,7 @@ class ExtendedProfile if (empty($schools)) { $iArrays[] = array( 'type' => 'education', + // TRANS: Field label for extended profile properties. 'label' => _m('Institution'), 'school' => null, 'degree' => null, @@ -251,6 +260,7 @@ class ExtendedProfile for ($i = 0; $i < sizeof($schools); $i++) { $ia = array( 'type' => 'education', + // TRANS: Field label for extended profile properties. 'label' => _m('Institution'), 'school' => $schools[$i]->field_value, 'degree' => isset($degrees[$i]->field_value) ? $degrees[$i]->field_value : null, @@ -275,32 +285,39 @@ class ExtendedProfile { return array( 'basic' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Personal'), 'fields' => array( 'fullname' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Full name'), 'profile' => 'fullname', 'vcard' => 'fn', ), 'title' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Title'), 'vcard' => 'title', ), 'manager' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Manager'), 'type' => 'person', 'vcard' => 'x-manager', ), 'location' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Location'), 'profile' => 'location' ), 'bio' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Bio'), 'type' => 'textarea', 'profile' => 'bio', ), 'tags' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Tags'), 'type' => 'tags', 'profile' => 'tags', @@ -308,6 +325,7 @@ class ExtendedProfile ), ), 'contact' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Contact'), 'fields' => array( 'phone' => $this->getPhones(), @@ -316,29 +334,35 @@ class ExtendedProfile ), ), 'personal' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Personal'), 'fields' => array( 'birthday' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Birthday'), 'type' => 'date', 'vcard' => 'bday', ), 'spouse' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Spouse\'s name'), 'vcard' => 'x-spouse', ), 'kids' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Kids\' names') ), ), ), 'experience' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Work experience'), 'fields' => array( 'experience' => $this->getExperiences() ), ), 'education' => array( + // TRANS: Field label for extended profile properties. 'label' => _m('Education'), 'fields' => array( 'education' => $this->getEducation() diff --git a/plugins/ExtendedProfile/lib/extendedprofilewidget.php b/plugins/ExtendedProfile/lib/extendedprofilewidget.php index 24c8b2f3d4..03be420bea 100644 --- a/plugins/ExtendedProfile/lib/extendedprofilewidget.php +++ b/plugins/ExtendedProfile/lib/extendedprofilewidget.php @@ -80,9 +80,11 @@ class ExtendedProfileWidget extends Form // For JQuery UI modal dialog $this->out->elementStart( 'div', - array('id' => 'confirm-dialog', 'title' => 'Confirmation Required') + // TRANS: Title for extended profile entry deletion dialog. + array('id' => 'confirm-dialog', 'title' => _m('Confirmation Required')) ); - $this->out->text('Really delete this entry?'); + // TRANS: Confirmation text for extended profile entry deletion dialog. + $this->out->text(_m('Really delete this entry?')); $this->out->elementEnd('div'); $this->showSections(); } @@ -163,7 +165,9 @@ class ExtendedProfileWidget extends Form if (!empty($field['value'])) { $this->out->text($field['value']); if (!empty($field['rel'])) { - $this->out->text(' (' . $field['rel'] . ')'); + // TRANS: Value between parentheses (phone number, website, or IM address). + $outtext = sprintf(_m('(%s)'),$field['rel']); + $this->out->text(' '.$outtext); } } $this->out->elementEnd('div'); @@ -174,7 +178,9 @@ class ExtendedProfileWidget extends Form $this->out->elementStart('div', array('class' => 'im-display')); $this->out->text($field['value']); if (!empty($field['rel'])) { - $this->out->text(' (' . $field['rel'] . ')'); + // TRANS: Value between parentheses (phone number, website, or IM address). + $outtext = sprintf(_m('(%s)'),$field['rel']); + $this->out->text(' '.$outtext); } $this->out->elementEnd('div'); } @@ -196,7 +202,9 @@ class ExtendedProfileWidget extends Form ); if (!empty($field['rel'])) { - $this->out->text(' (' . $field['rel'] . ')'); + // TRANS: Value between parentheses (phone number, website, or IM address). + $outtext = sprintf(_m('(%s)'),$field['rel']); + $this->out->text(' '.$outtext); } $this->out->elementEnd('div'); } @@ -314,11 +322,13 @@ class ExtendedProfileWidget extends Form protected function showExperience($name, $field) { $this->out->elementStart('div', 'experience-item'); + // TRANS: Field label in experience area of extended profile. $this->out->element('div', 'label', _m('Company')); if (!empty($field['company'])) { $this->out->element('div', 'field', $field['company']); + // TRANS: Field label in experience area of extended profile (when did one start a position). $this->out->element('div', 'label', _m('Start')); $this->out->element( 'div', @@ -326,6 +336,7 @@ class ExtendedProfileWidget extends Form date('j M Y', strtotime($field['start']) ) ); + // TRANS: Field label in experience area of extended profile (when did one end a position). $this->out->element('div', 'label', _m('End')); $this->out->element( 'div', @@ -338,7 +349,8 @@ class ExtendedProfileWidget extends Form $this->out->element( 'div', array('class' => 'field current'), - '(' . _m('Current') . ')' + // TRANS: Field value in experience area of extended profile (one still holds a position). + _m('(Current)') ); } } @@ -356,6 +368,7 @@ class ExtendedProfileWidget extends Form ) ); + // TRANS: Field label in experience edit area of extended profile (which company does one work for). $this->out->element('div', 'label', _m('Company')); $this->out->input( $id, @@ -363,6 +376,7 @@ class ExtendedProfileWidget extends Form isset($field['company']) ? $field['company'] : null ); + // TRANS: Field label in experience edit area of extended profile (when did one start at a company). $this->out->element('div', 'label', _m('Start')); $this->out->input( $id . '-start', @@ -370,6 +384,7 @@ class ExtendedProfileWidget extends Form isset($field['start']) ? date('j M Y', strtotime($field['start'])) : null ); + // TRANS: Field label in experience edit area of extended profile (when did one terminate at a company). $this->out->element('div', 'label', _m('End')); $this->out->input( @@ -384,6 +399,7 @@ class ExtendedProfileWidget extends Form $this->out->elementStart('div', 'current-checkbox'); $this->out->checkbox( $id . '-current', + // TRANS: Checkbox label in experience edit area of extended profile (one still works at a company). _m('Current'), $field['current'] ); @@ -396,14 +412,17 @@ class ExtendedProfileWidget extends Form protected function showEducation($name, $field) { $this->out->elementStart('div', 'education-item'); + // TRANS: Field label in education area of extended profile. $this->out->element('div', 'label', _m('Institution')); if (!empty($field['school'])) { - $this->out->element('div', 'field', $field['school']); + // TRANS: Field label in education area of extended profile. $this->out->element('div', 'label', _m('Degree')); $this->out->element('div', 'field', $field['degree']); + // TRANS: Field label in education area of extended profile. $this->out->element('div', 'label', _m('Description')); $this->out->element('div', 'field', $field['description']); + // TRANS: Field label in education area of extended profile (when did one start an education). $this->out->element('div', 'label', _m('Start')); $this->out->element( 'div', @@ -411,6 +430,7 @@ class ExtendedProfileWidget extends Form date('j M Y', strtotime($field['start']) ) ); + // TRANS: Field label in education area of extended profile (when did one end a education). $this->out->element('div', 'label', _m('End')); $this->out->element( 'div', @@ -432,6 +452,7 @@ class ExtendedProfileWidget extends Form 'class' => 'education-item' ) ); + // TRANS: Field label in education edit area of extended profile. $this->out->element('div', 'label', _m('Institution')); $this->out->input( $id, @@ -439,6 +460,7 @@ class ExtendedProfileWidget extends Form isset($field['school']) ? $field['school'] : null ); + // TRANS: Field label in education edit area of extended profile. $this->out->element('div', 'label', _m('Degree')); $this->out->input( $id . '-degree', @@ -446,6 +468,7 @@ class ExtendedProfileWidget extends Form isset($field['degree']) ? $field['degree'] : null ); + // TRANS: Field label in education edit area of extended profile. $this->out->element('div', 'label', _m('Description')); $this->out->textarea( @@ -454,17 +477,21 @@ class ExtendedProfileWidget extends Form isset($field['description']) ? $field['description'] : null ); + // TRANS: Field label in education edit area of extended profile (when did one start an education). $this->out->element('div', 'label', _m('Start')); $this->out->input( $id . '-start', null, + // @todo FIXME: does date format need i18n? If so, should probly be dealt with in core. isset($field['start']) ? date('j M Y', strtotime($field['start'])) : null ); + // TRANS: Field label in education edit area of extended profile (when did one end an education). $this->out->element('div', 'label', _m('End')); $this->out->input( $id . '-end', null, + // @todo FIXME: does date format need i18n? If so, should probly be dealt with in core. isset($field['end']) ? date('j M Y', strtotime($field['end'])) : null ); @@ -491,7 +518,8 @@ class ExtendedProfileWidget extends Form 'href' => 'javascript://', 'style' => 'display: none;' ), - 'Add another item' + // TRANS: Link description in extended profile page to add another profile element. + _m('Add another item') ); } @@ -601,7 +629,8 @@ class ExtendedProfileWidget extends Form $this->showEditableEducation($name, $field); break; default: - $out->input($id, null, "TYPE: $type"); + // TRANS: Field label for undefined field in extended profile. + $out->input($id, null, sprintf(_m('TYPE: %s'),$type)); } } @@ -610,14 +639,16 @@ class ExtendedProfileWidget extends Form * * @return void */ - function formActions() { $this->out->submit( 'save', + // TRANS: Button text for saving extended profile properties. _m('BUTTON','Save'), 'submit form_action-secondary', 'save', + // TRANS: . + // TRANS: Button title for saving extended profile properties. _m('Save details') ); } @@ -627,7 +658,6 @@ class ExtendedProfileWidget extends Form * * @return string ID of the form */ - function id() { return 'profile-details-' . $this->profile->id; @@ -638,7 +668,6 @@ class ExtendedProfileWidget extends Form * * @return string of the form class */ - function formClass() { return 'form_profile_details form_settings'; @@ -649,7 +678,6 @@ class ExtendedProfileWidget extends Form * * @return string URL of the action */ - function action() { return common_local_url('profiledetailsettings'); From 8d99a5f949b1addd83dd6d9a3ca9403e3f4a0ca9 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 8 Apr 2011 01:49:34 +0200 Subject: [PATCH 259/726] Whitespace updates. --- lib/inboxnoticestream.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php index 7570210d3e..09c3edb281 100644 --- a/lib/inboxnoticestream.php +++ b/lib/inboxnoticestream.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Stream of notices for the user's inbox - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class InboxNoticeStream extends ScopingNoticeStream { /** @@ -133,4 +132,4 @@ class RawInboxNoticeStream extends NoticeStream return $ids; } -} \ No newline at end of file +} From 3e8bf13aab25050cce09a3180ea7b56c41ed40e3 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 8 Apr 2011 10:59:10 +0200 Subject: [PATCH 260/726] Update translator documentation. L10n/i18n updates. --- .../FacebookBridge/FacebookBridgePlugin.php | 24 +++--- .../actions/facebookadminpanel.php | 18 ++++- .../actions/facebookdeauthorize.php | 3 +- .../actions/facebookfinishlogin.php | 33 +++++--- .../FacebookBridge/actions/facebooklogin.php | 12 +-- .../actions/facebooksettings.php | 26 ++++--- .../FacebookBridge/classes/Notice_to_item.php | 7 -- plugins/FacebookBridge/lib/facebookclient.php | 77 +++++++------------ 8 files changed, 98 insertions(+), 102 deletions(-) diff --git a/plugins/FacebookBridge/FacebookBridgePlugin.php b/plugins/FacebookBridge/FacebookBridgePlugin.php index 68e931e387..d893baf62d 100644 --- a/plugins/FacebookBridge/FacebookBridgePlugin.php +++ b/plugins/FacebookBridge/FacebookBridgePlugin.php @@ -101,7 +101,6 @@ class FacebookBridgePlugin extends Plugin */ function onAutoload($cls) { - $dir = dirname(__FILE__); //common_debug("class = " . $cls); @@ -128,7 +127,6 @@ class FacebookBridgePlugin extends Plugin default: return true; } - } /** @@ -214,10 +212,11 @@ class FacebookBridgePlugin extends Plugin if ($this->hasApplication()) { $action->menuItem( + // TRANS: Menu item for "Facebook" login. common_local_url('facebooklogin'), _m('MENU', 'Facebook'), - // TRANS: Tooltip for menu item "Facebook". - _m('Login or register using Facebook'), + // TRANS: Menu title for "Facebook" login. + _m('Login or register using Facebook.'), 'facebooklogin' === $action_name ); } @@ -253,10 +252,10 @@ class FacebookBridgePlugin extends Plugin $nav->out->menuItem( common_local_url('facebookadminpanel'), - // TRANS: Menu item. + // TRANS: Menu item for "Facebook" in administration panel. _m('MENU','Facebook'), - // TRANS: Tooltip for menu item "Facebook". - _m('Facebook integration configuration'), + // TRANS: Menu title for "Facebook" in administration panel. + _m('Facebook integration configuration.'), $action_name == 'facebookadminpanel', 'nav_facebook_admin_panel' ); @@ -294,16 +293,14 @@ class FacebookBridgePlugin extends Plugin $action->menuItem( common_local_url('facebooksettings'), - // TRANS: Menu item tab. + // TRANS: Menu item for "Facebook" in user settings. _m('MENU','Facebook'), - // TRANS: Tooltip for menu item "Facebook". - _m('Facebook settings'), + // TRANS: Menu title for "Facebook" in user settings. + _m('Facebook settings.'), $action_name === 'facebooksettings' ); - } } - } /* @@ -324,7 +321,6 @@ class FacebookBridgePlugin extends Plugin if (!empty($appId) && !empty($secret)) { return true; } - } return false; @@ -420,7 +416,6 @@ ENDOFSCRIPT; common_debug("LOGOUT URL = $logoutUrl"); common_redirect($logoutUrl, 303); } - } } @@ -561,6 +556,7 @@ ENDOFSCRIPT; 'author' => 'Craig Andrews, Zach Copley', 'homepage' => 'http://status.net/wiki/Plugin:FacebookBridge', 'rawdescription' => + // TRANS: Plugin description. _m('A plugin for integrating StatusNet with Facebook.') ); diff --git a/plugins/FacebookBridge/actions/facebookadminpanel.php b/plugins/FacebookBridge/actions/facebookadminpanel.php index 034b58b2fa..21c3589008 100644 --- a/plugins/FacebookBridge/actions/facebookadminpanel.php +++ b/plugins/FacebookBridge/actions/facebookadminpanel.php @@ -49,7 +49,8 @@ class FacebookadminpanelAction extends AdminPanelAction */ function title() { - return _m('Facebook'); + // TRANS: Title for Facebook administration panel. + return _m('TITLE','Facebook integration settings'); } /** @@ -59,6 +60,7 @@ class FacebookadminpanelAction extends AdminPanelAction */ function getInstructions() { + // TRANS: Instruction for Facebook administration panel. return _m('Facebook integration settings'); } @@ -120,12 +122,14 @@ class FacebookadminpanelAction extends AdminPanelAction if (mb_strlen($values['facebook']['appid']) > 255) { $this->clientError( + // TRANS: Client error displayed when providing too long a Facebook application ID. _m("Invalid Facebook ID. Maximum length is 255 characters.") ); } if (mb_strlen($values['facebook']['secret']) > 255) { $this->clientError( + // TRANS: Client error displayed when providing too long a Facebook secret key. _m("Invalid Facebook secret. Maximum length is 255 characters.") ); } @@ -175,13 +179,16 @@ class FacebookAdminPanelForm extends AdminForm 'fieldset', array('id' => 'settings_facebook-application') ); + // TRANS: Fieldset legend. $this->out->element('legend', null, _m('Facebook application settings')); $this->out->elementStart('ul', 'form_data'); $this->li(); $this->input( 'appid', + // TRANS: Field label for Facebook application ID. _m('Application ID'), + // TRANS: Field title for Facebook application ID. _m('ID of your Facebook application.'), 'facebook' ); @@ -190,7 +197,9 @@ class FacebookAdminPanelForm extends AdminForm $this->li(); $this->input( 'secret', - _m('Secret'), + // TRANS: Field label for Facebook secret key. + _m('Secret'), + // TRANS: Field title for Facebook secret key. _m('Application secret.'), 'facebook' ); @@ -207,6 +216,9 @@ class FacebookAdminPanelForm extends AdminForm */ function formActions() { - $this->out->submit('submit', _m('BUTTON','Save'), 'submit', null, _m('Save Facebook settings.')); + // TRANS: Button text to save Facebook integration settings. + $this->out->submit('submit', _m('BUTTON','Save'), + // TRANS: Button title to save Facebook integration settings. + 'submit', null, _m('Save Facebook settings.')); } } diff --git a/plugins/FacebookBridge/actions/facebookdeauthorize.php b/plugins/FacebookBridge/actions/facebookdeauthorize.php index 6813ccf1d2..1a83c3a003 100644 --- a/plugins/FacebookBridge/actions/facebookdeauthorize.php +++ b/plugins/FacebookBridge/actions/facebookdeauthorize.php @@ -140,5 +140,4 @@ class FacebookdeauthorizeAction extends Action } } } - -} \ No newline at end of file +} diff --git a/plugins/FacebookBridge/actions/facebookfinishlogin.php b/plugins/FacebookBridge/actions/facebookfinishlogin.php index f952ad2e2b..3d2fb571d7 100644 --- a/plugins/FacebookBridge/actions/facebookfinishlogin.php +++ b/plugins/FacebookBridge/actions/facebookfinishlogin.php @@ -38,7 +38,6 @@ class FacebookfinishloginAction extends Action private $fbuser = null; // Facebook user object (JSON) function prepare($args) { - parent::prepare($args); $this->facebook = new Facebook( @@ -64,7 +63,6 @@ class FacebookfinishloginAction extends Action } if (!empty($this->fbuser)) { - // OKAY, all is well... proceed to register common_debug("Found a valid Facebook user.", __FILE__); @@ -85,6 +83,7 @@ class FacebookfinishloginAction extends Action ); $this->clientError( + // TRANS: Client error displayed when trying to connect to Facebook while not logged in. _m('You must be logged into Facebook to register a local account using Facebook.') ); } @@ -115,6 +114,8 @@ class FacebookfinishloginAction extends Action ); $this->clientError( + // TRANS: Client error displayed when trying to connect to a Facebook account that is already linked + // TRANS: in the same StatusNet site. _m('There is already a local account linked with that Facebook account.') ); @@ -138,6 +139,7 @@ class FacebookfinishloginAction extends Action if (!$token || $token != common_session_token()) { $this->showForm( + // TRANS: Client error displayed when the session token does not match or is not given. _m('There was a problem with your session token. Try again, please.') ); return; @@ -147,6 +149,7 @@ class FacebookfinishloginAction extends Action if (!$this->boolean('license')) { $this->showForm( + // TRANS: Form validation error displayed when user has not agreed to the license. _m('You cannot register if you do not agree to the license.'), $this->trimmed('newname') ); @@ -164,6 +167,7 @@ class FacebookfinishloginAction extends Action } else { $this->showForm( + // TRANS: Form validation error displayed when an unhandled error occurs. _m('An unknown error has occured.'), $this->trimmed('newname') ); @@ -180,8 +184,9 @@ class FacebookfinishloginAction extends Action $this->element( 'div', 'instructions', - // TRANS: %s is the site name. sprintf( + // TRANS: Form instructions for connecting to Facebook. + // TRANS: %s is the site name. _m('This is the first time you have logged into %s so we must connect your Facebook to a local account. You can either create a new local account, or connect with an existing local account.'), common_config('site', 'name') ) @@ -209,7 +214,7 @@ class FacebookfinishloginAction extends Action } /** - * @fixme much of this duplicates core code, which is very fragile. + * @todo FIXME: Much of this duplicates core code, which is very fragile. * Should probably be replaced with an extensible mini version of * the core registration form. */ @@ -225,7 +230,7 @@ class FacebookfinishloginAction extends Action 'class' => 'form_settings', 'action' => common_local_url('facebookfinishlogin'))); $this->elementStart('fieldset', array('id' => 'settings_facebook_connect_options')); - // TRANS: Legend. + // TRANS: Fieldset legend. $this->element('legend', null, _m('Connection options')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); @@ -252,9 +257,10 @@ class FacebookfinishloginAction extends Action $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('legend', null, - // TRANS: Legend. + // TRANS: Fieldset legend. _m('Create new account')); $this->element('p', null, + // TRANS: Form instructions. _m('Create a new user with this nickname.')); $this->elementStart('ul', 'form_data'); @@ -265,6 +271,7 @@ class FacebookfinishloginAction extends Action // TRANS: Field label. $this->input('newname', _m('New nickname'), ($this->username) ? $this->username : '', + // TRANS: Field title. _m('1-64 lowercase letters or numbers, no punctuation or spaces.')); $this->elementEnd('li'); @@ -272,15 +279,16 @@ class FacebookfinishloginAction extends Action Event::handle('EndRegistrationFormData', array($this)); $this->elementEnd('ul'); - // TRANS: Submit button. + // TRANS: Submit button to create a new account. $this->submit('create', _m('BUTTON','Create')); $this->elementEnd('fieldset'); $this->elementStart('fieldset'); - // TRANS: Legend. $this->element('legend', null, + // TRANS: Fieldset legend. _m('Connect existing account')); $this->element('p', null, + // TRANS: Form instructions. _m('If you already have an account, login with your username and password to connect it to your Facebook.')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); @@ -288,10 +296,11 @@ class FacebookfinishloginAction extends Action $this->input('nickname', _m('Existing nickname')); $this->elementEnd('li'); $this->elementStart('li'); + // TRANS: Field label. $this->password('password', _m('Password')); $this->elementEnd('li'); $this->elementEnd('ul'); - // TRANS: Submit button. + // TRANS: Submit button to connect a Facebook account to an existing StatusNet account. $this->submit('connect', _m('BUTTON','Connect')); $this->elementEnd('fieldset'); @@ -344,11 +353,13 @@ class FacebookfinishloginAction extends Action } if (!User::allowed_nickname($nickname)) { + // TRANS: Form validation error displayed when picking a nickname that is not allowed. $this->showForm(_m('Nickname not allowed.')); return; } if (User::staticGet('nickname', $nickname)) { + // TRANS: Form validation error displayed when picking a nickname that is already in use. $this->showForm(_m('Nickname already in use. Try another one.')); return; } @@ -377,6 +388,7 @@ class FacebookfinishloginAction extends Action $result = $this->flinkUser($user->id, $this->fbuid); if (!$result) { + // TRANS: Server error displayed when connecting to Facebook fails. $this->serverError(_m('Error connecting user to Facebook.')); return; } @@ -479,6 +491,7 @@ class FacebookfinishloginAction extends Action $password = $this->trimmed('password'); if (!common_check_user($nickname, $password)) { + // TRANS: Form validation error displayed when username/password combination is incorrect. $this->showForm(_m('Invalid username or password.')); return; } @@ -516,6 +529,7 @@ class FacebookfinishloginAction extends Action $result = $this->flinkUser($user->id, $this->fbuid); if (empty($result)) { + // TRANS: Server error displayed when connecting to Facebook fails. $this->serverError(_m('Error connecting user to Facebook.')); return; } @@ -687,5 +701,4 @@ class FacebookfinishloginAction extends Action return false; } - } diff --git a/plugins/FacebookBridge/actions/facebooklogin.php b/plugins/FacebookBridge/actions/facebooklogin.php index 924dd46565..fa3cc7a6f2 100644 --- a/plugins/FacebookBridge/actions/facebooklogin.php +++ b/plugins/FacebookBridge/actions/facebooklogin.php @@ -34,12 +34,12 @@ if (!defined('STATUSNET')) { class FacebookloginAction extends Action { - function handle($args) { parent::handle($args); if (common_is_real_login()) { + // TRANS: Client error displayed when trying to login while already logged in. $this->clientError(_m('Already logged in.')); } else { $this->showPage(); @@ -48,7 +48,7 @@ class FacebookloginAction extends Action function getInstructions() { - // TRANS: Instructions. + // TRANS: Form instructions. return _m('Login with your Facebook Account'); } @@ -68,7 +68,6 @@ class FacebookloginAction extends Action } function showContent() { - $this->elementStart('fieldset'); $facebook = Facebookclient::getFacebook(); @@ -90,8 +89,10 @@ class FacebookloginAction extends Action $attrs = array( 'src' => Plugin::staticPath('FacebookBridge', 'images/login-button.png'), - 'alt' => 'Login with Facebook', - 'title' => 'Login with Facebook' + // TRANS: Alt text for "Login with Facebook" image. + 'alt' => _m('Login with Facebook'), + // TRANS: Title for "Login with Facebook" image. + 'title' => _m('Login with Facebook.') ); $this->element('img', $attrs); @@ -117,4 +118,3 @@ class FacebookloginAction extends Action $nav->show(); } } - diff --git a/plugins/FacebookBridge/actions/facebooksettings.php b/plugins/FacebookBridge/actions/facebooksettings.php index 7d45cc03e6..aaa2204035 100644 --- a/plugins/FacebookBridge/actions/facebooksettings.php +++ b/plugins/FacebookBridge/actions/facebooksettings.php @@ -83,6 +83,7 @@ class FacebooksettingsAction extends SettingsAction { $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm( + // TRANS: Client error displayed when the session token does not match or is not given. _m('There was a problem with your session token. Try again, please.') ); return; @@ -102,7 +103,7 @@ class FacebooksettingsAction extends SettingsAction { */ function title() { // TRANS: Page title for Facebook settings. - return _m('Facebook settings'); + return _m('TITLE','Facebook settings'); } /** @@ -111,6 +112,7 @@ class FacebooksettingsAction extends SettingsAction { * @return instructions for use */ function getInstructions() { + // TRANS: Instructions for Facebook settings. return _m('Facebook settings'); } @@ -134,6 +136,7 @@ class FacebooksettingsAction extends SettingsAction { $this->hidden('token', common_session_token()); + // TRANS: Form note. User is connected to facebook. $this->element('p', 'form_note', _m('Connected Facebook user')); $this->elementStart('p', array('class' => 'facebook-user-display')); @@ -161,6 +164,7 @@ class FacebooksettingsAction extends SettingsAction { $this->checkbox( 'noticesync', + // TRANS: Checkbox label in Facebook settings. _m('Publish my notices to Facebook.'), ($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND) : true ); @@ -171,6 +175,7 @@ class FacebooksettingsAction extends SettingsAction { $this->checkbox( 'replysync', + // TRANS: Checkbox label in Facebook settings. _m('Send "@" replies to Facebook.'), ($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true ); @@ -188,13 +193,14 @@ class FacebooksettingsAction extends SettingsAction { $this->elementStart('fieldset'); - // TRANS: Legend. + // TRANS: Fieldset legend for form to disconnect from Facebook. $this->element('legend', null, _m('Disconnect my account from Facebook')); if (empty($this->user->password)) { $this->elementStart('p', array('class' => 'form_guide')); $msg = sprintf( + // TRANS: Notice in disconnect from Facebook form if user has no local StatusNet password. _m( 'Disconnecting your Faceboook would make it impossible to ' . 'log in! Please [set a password](%s) first.' @@ -206,14 +212,11 @@ class FacebooksettingsAction extends SettingsAction { $this->elementEnd('p'); } else { // @todo FIXME: i18n: This message is not being used. - $msg = sprintf( - // TRANS: Message displayed when initiating disconnect of a StatusNet user - // TRANS: from a Facebook account. %1$s is the StatusNet site name. - _m( - 'Keep your %1$s account but disconnect from Facebook. ' . - 'You\'ll use your %1$s password to log in.' - ), - common_config('site', 'name') + // TRANS: Message displayed when initiating disconnect of a StatusNet user + // TRANS: from a Facebook account. %1$s is the StatusNet site name. + $msg = sprintf(_m('Keep your %1$s account but disconnect from Facebook. ' . + 'You\'ll use your %1$s password to log in.'), + common_config('site', 'name') ); // TRANS: Submit button. @@ -240,6 +243,7 @@ class FacebooksettingsAction extends SettingsAction { $result = $this->flink->update($original); if ($result === false) { + // TRANS: Notice in case saving of synchronisation preferences fail. $this->showForm(_m('There was a problem saving your sync preferences.')); } else { // TRANS: Confirmation that synchronisation settings have been saved into the system. @@ -257,10 +261,12 @@ class FacebooksettingsAction extends SettingsAction { if ($result === false) { common_log_db_error($user, 'DELETE', __FILE__); + // TRANS: Server error displayed when deleting the link to a Facebook account fails. $this->serverError(_m('Could not delete link to Facebook.')); return; } + // TRANS: Confirmation message. StatusNet account was unlinked from Facebook. $this->showForm(_m('You have disconnected from Facebook.'), true); } } diff --git a/plugins/FacebookBridge/classes/Notice_to_item.php b/plugins/FacebookBridge/classes/Notice_to_item.php index a6a8030342..d37c95ffc1 100644 --- a/plugins/FacebookBridge/classes/Notice_to_item.php +++ b/plugins/FacebookBridge/classes/Notice_to_item.php @@ -48,7 +48,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; * * @see DB_DataObject */ - class Notice_to_item extends Memcached_DataObject { public $__table = 'notice_to_item'; // table name @@ -67,7 +66,6 @@ class Notice_to_item extends Memcached_DataObject * @return Notice_to_item object found, or null for no hits * */ - function staticGet($k, $v=null) { return Memcached_DataObject::staticGet('Notice_to_item', $k, $v); @@ -81,7 +79,6 @@ class Notice_to_item extends Memcached_DataObject * * @return array array of column definitions */ - function table() { return array( @@ -109,7 +106,6 @@ class Notice_to_item extends Memcached_DataObject * * @return array list of key field names */ - function keys() { return array_keys($this->keyTypes()); @@ -127,7 +123,6 @@ class Notice_to_item extends Memcached_DataObject * 'K' for primary key: for compound keys, add an entry for each component; * 'U' for unique keys: compound keys are not well supported here. */ - function keyTypes() { return array('notice_id' => 'K', 'item_id' => 'U'); @@ -143,7 +138,6 @@ class Notice_to_item extends Memcached_DataObject * * @return array magic three-false array that stops auto-incrementing. */ - function sequenceKey() { return array(false, false, false); @@ -157,7 +151,6 @@ class Notice_to_item extends Memcached_DataObject * * @return Notice_to_item new object for this value */ - static function saveNew($notice_id, $item_id) { $n2i = Notice_to_item::staticGet('notice_id', $notice_id); diff --git a/plugins/FacebookBridge/lib/facebookclient.php b/plugins/FacebookBridge/lib/facebookclient.php index 37d6a0a7a0..ec1331b2a0 100644 --- a/plugins/FacebookBridge/lib/facebookclient.php +++ b/plugins/FacebookBridge/lib/facebookclient.php @@ -340,7 +340,8 @@ class Facebookclient function checkPermission($permission) { if (!in_array($permission, array('publish_stream', 'status_update'))) { - throw new ServerException("No such permission!"); + // TRANS: Server exception thrown when permission check fails. + throw new ServerException(_('No such permission!')); } $fbuid = $this->flink->foreign_id; @@ -397,7 +398,6 @@ class Facebookclient ); return false; - } } @@ -461,7 +461,7 @@ class Facebookclient ), __FILE__ ); - // @fixme: We want to rety at a later time when the throttling has expired + // @todo FIXME: We want to rety at a later time when the throttling has expired // instead of just giving up. return true; break; @@ -582,7 +582,6 @@ class Facebookclient ); if (!empty($result)) { // result will contain the item ID - // Save a mapping Notice_to_item::saveNew($this->notice->id, $result); @@ -598,7 +597,6 @@ class Facebookclient ), __FILE__ ); - } else { $msg = sprintf( @@ -740,7 +738,6 @@ class Facebookclient $result = $this->mailFacebookDisconnect(); if (!$result) { - $msg = 'Unable to send email to notify %s (%d), fbuid %d ' . 'about his/her Facebook link being removed.'; @@ -755,9 +752,7 @@ class Facebookclient __FILE__ ); } - } else { - $msg = 'Unable to send email to notify %s (%d), fbuid %d ' . 'about his/her Facebook link being removed because the ' . 'user has not set an email address.'; @@ -789,26 +784,23 @@ class Facebookclient common_switch_locale($this->user->language); + // TRANS: E-mail subject. $subject = _m('Your Facebook connection has been removed'); - $msg = <<user->nickname, $siteName ); @@ -848,22 +840,21 @@ BODY; common_switch_locale($user->language); + // TRANS: E-mail subject. %s is the StatusNet sitename. $subject = _m('Contact the %s administrator to retrieve your account'); - $msg = <<nickname, $siteName, $siteEmail @@ -990,9 +981,7 @@ BODY; $n2i = Notice_to_item::staticGet('notice_id', $this->notice->id); if (!empty($this->flink) && !empty($n2i)) { - try { - $result = $this->facebook->api( array( 'method' => 'stream.remove', @@ -1002,7 +991,6 @@ BODY; ); if (!empty($result) && result == true) { - common_log( LOG_INFO, sprintf( @@ -1020,7 +1008,6 @@ BODY; } else { throw new FaceboookApiException(var_export($result, true)); } - } catch (FacebookApiException $e) { common_log( LOG_WARNING, @@ -1049,9 +1036,7 @@ BODY; $n2i = Notice_to_item::staticGet('notice_id', $this->notice->id); if (!empty($this->flink) && !empty($n2i)) { - try { - $result = $this->facebook->api( array( 'method' => 'stream.addlike', @@ -1061,7 +1046,6 @@ BODY; ); if (!empty($result) && result == true) { - common_log( LOG_INFO, sprintf( @@ -1073,11 +1057,9 @@ BODY; ), __FILE__ ); - } else { throw new FacebookApiException(var_export($result, true)); } - } catch (FacebookApiException $e) { common_log( LOG_WARNING, @@ -1105,9 +1087,7 @@ BODY; $n2i = Notice_to_item::staticGet('notice_id', $this->notice->id); if (!empty($this->flink) && !empty($n2i)) { - try { - $result = $this->facebook->api( array( 'method' => 'stream.removeLike', @@ -1117,7 +1097,6 @@ BODY; ); if (!empty($result) && result == true) { - common_log( LOG_INFO, sprintf( @@ -1133,7 +1112,6 @@ BODY; } else { throw new FacebookApiException(var_export($result, true)); } - } catch (FacebookApiException $e) { common_log( LOG_WARNING, @@ -1151,5 +1129,4 @@ BODY; } } } - } From c44a94e8f59d879b5e829f990e4d2818f34ccbd3 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Fri, 8 Apr 2011 13:55:01 +0530 Subject: [PATCH 261/726] Port autocomplete from tagInput to jQuery UI, send Last-Modified header and look for it in JS. --- actions/peopletagautocomplete.php | 61 +++-- js/jquery.tagInput.js | 381 ------------------------------ js/jquery.timers.js | 138 ----------- js/util.js | 99 ++++++-- js/util.min.js | 2 +- lib/action.php | 4 +- theme/base/css/display.css | 24 +- theme/rebase/css/display.css | 34 +-- 8 files changed, 141 insertions(+), 602 deletions(-) delete mode 100644 js/jquery.tagInput.js delete mode 100644 js/jquery.timers.js diff --git a/actions/peopletagautocomplete.php b/actions/peopletagautocomplete.php index db11a24667..04b9baefbe 100644 --- a/actions/peopletagautocomplete.php +++ b/actions/peopletagautocomplete.php @@ -34,6 +34,8 @@ if (!defined('STATUSNET')) { class PeopletagautocompleteAction extends Action { var $user; + var $tags; + var $last_mod; /** * Check pre-requisites and instantiate attributes @@ -66,13 +68,47 @@ class PeopletagautocompleteAction extends Action return false; } + $profile = $this->user->getProfile(); + $tags = $profile->getOwnedTags(common_current_user()); + + $this->tags = array(); + while ($tags->fetch()) { + + if (empty($this->last_mod)) { + $this->last_mod = $tags->modified; + } + + $arr = array(); + $arr['tag'] = $tags->tag; + $arr['mode'] = $tags->private ? 'private' : 'public'; + // $arr['url'] = $tags->homeUrl(); + $arr['freq'] = $tags->taggedCount(); + + $this->tags[] = $arr; + } + + $tags->free(); + return true; } + /** + * Last modified time + * + * Helps in browser-caching + * + * @return String time + */ + + function lastModified() + { + return strtotime($this->last_mod); + } + /** * Handle request * - * Does the subscription and returns results. + * Print the JSON autocomplete data * * @param Array $args unused. * @@ -81,24 +117,11 @@ class PeopletagautocompleteAction extends Action function handle($args) { - $profile = $this->user->getProfile(); - $tags = $profile->getOwnedTags(common_current_user()); - - $tags_array = array(); - while ($tags->fetch()) { - $arr = array(); - $arr['tag'] = $tags->tag; - $arr['mode'] = $tags->private ? 'private' : 'public'; - // $arr['url'] = $tags->homeUrl(); - $arr['freq'] = $tags->taggedCount(); - - $tags_array[] = $arr; + //common_log(LOG_DEBUG, 'Autocomplete data: ' . json_encode($this->tags)); + if ($this->tags) { + print(json_encode($this->tags)); + exit(0); } - - $tags->free(); - - //common_log(LOG_DEBUG, 'Autocomplete data: ' . json_encode($tags_array)); - print(json_encode($tags_array)); - exit(0); + return false; } } diff --git a/js/jquery.tagInput.js b/js/jquery.tagInput.js deleted file mode 100644 index 8ed4058fb2..0000000000 --- a/js/jquery.tagInput.js +++ /dev/null @@ -1,381 +0,0 @@ -/* - Copyright (c) 2009 Open Lab, http://www.open-lab.com/ - Written by Roberto Bicchierai http://roberto.open-lab.com. - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -/** - * options.tags an object array [{tag:"tag1",freq:1},{tag:"tag2",freq:2}, {tag:"tag3",freq:3},{tag:"tag4",freq:4} ]. - * options.jsonUrl an url returning a json object array in the same format of options.tag. The url will be called with - * "search" parameter to be used server side to filter results - * option.autoFilter true/false default=true when active show only matching tags, "false" should be used for server-side filtering - * option.autoStart true/false default=false when active dropdown will appear entering field, otherwise when typing - * options.sortBy "frequency"|"tag"|"none" default="tag" - * options.tagSeparator default="," any separator char as space, comma, semicolumn - * options.boldify true/false default trrue boldify the matching part of tag in dropdown - * - * options.suggestedTags callback an object array like ["sugtag1","sugtag2","sugtag3"] - * options.suggestedTagsPlaceHolder jquery proxy for suggested tag placeholder. When placeholder is supplied (hence unique), tagField should be applied on a single input - * (something like $("#myTagFiled").tagField(...) will works fine: $(":text").tagField(...) probably not!) - */ - -if (typeof(String.prototype.trim) == "undefined"){ - String.prototype.trim = function () { - return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); - }; -} - - - -jQuery.fn.tagInput = function(options) { - // -------------------------- start default option values -------------------------- - if (!options.tags && !options.jsonUrl) { - options.tags = [ { tag:"tag1", freq:1 }, { tag:"tag2", freq:2 }, { tag:"tag3", freq:3 }, { tag:"tag4", freq:4 } ]; - } - - if (typeof(options.tagSeparator) == "undefined") - options.tagSeparator = ","; - - if (typeof(options.autoFilter) == "undefined") - options.autoFilter = true; - - if (typeof(options.autoStart) == "undefined") - options.autoStart = false; - - if (typeof(options.boldify) == "undefined") - options.boldify = true; - - if (typeof(options.animate) == "undefined") - options.animate = true; - - if (typeof(options.animate) != "function") { - options._animate = options.animate; - options.animate = function(show, el, cb) { - var func = (options._animate) ? (show ? 'fadeIn' : 'fadeOut') : (show ? 'show' : 'hide'); - el[func](cb); - } - } - - if (typeof(options.sortBy) == "undefined") - options.sortBy = "tag"; - - if (typeof(options.sortBy) == "string") { - options._sortBy = options.sortBy; - options.sortBy = function(obj) { return obj[options._sortBy]; } - } - - if (typeof(options.formatLine) == "undefined") - options.formatLine = function (i, obj, search, matches) { - var tag = obj.tag; - if (options.boldify && matches) { - tag = "" + tag.substring(0, search.length) + "" + tag.substring(search.length); - } - - var line = $("
                  "); - line.append("
                  " + tag + "
                  "); - if (obj.freq) - line.append("
                  " + obj.freq + "
                  "); - return line; - } - - if (typeof(options.formatValue == "undefined")) - options.formatValue = function (obj, i) { - return obj.tag; - } - // -------------------------- end default option values -------------------------- - - - this.each(function() { - - var theInput = $(this); - var theDiv; - - theInput.addClass("tagInput"); - theInput.tagOptions=options; - theInput.attr('autocomplete', 'off'); - - var suggestedTagsPlaceHolder=options.suggestedTagsPlaceHolder; - //create suggested tags place if the case - if (options.suggestedTags){ - if (!suggestedTagsPlaceHolder){ - //create a placeholder - var stl=$("
                  suggested tags:
                  "); - suggestedTagsPlaceHolder=stl.find(".tagInputSuggestedTagList"); - theInput.after(stl); - } - - //fill with suggestions - for (var tag in options.suggestedTags) { - suggestedTagsPlaceHolder.append($("" + options.suggestedTags[tag] + "")); - } - - // bind click on suggestion tags - suggestedTagsPlaceHolder.find(".tag").click(function() { - var element = $(this); - var val = theInput.val(); - var tag = element.text(); - - //check if already present - var re = new RegExp(tag + "\\b","g"); - if (containsTag(val, tag)) { - val = val.replace(re, ""); //remove all the tag - element.removeClass("tagUsed"); - } else { - val = val + options.tagSeparator + tag; - element.addClass("tagUsed"); - } - theInput.val(refurbishTags(val)); -// selectSuggTagFromInput(); - - }); - - } - - - // -------------------------- INPUT FOCUS -------------------------- - var tagInputFocus = function () { - theDiv = $("#__tagInputDiv"); - // check if the result box exists - if (theDiv.size() <= 0) { - //create the div - theDiv = $(""); - theInput.after(theDiv); - theDiv.css({left:theInput.position().left}); - } - if (options.autoStart) - tagInputRefreshDiv(theInput, theDiv); - }; - - - // -------------------------- INPUT BLUR -------------------------- - var tagInputBlur = function () { - // reformat string - theDiv = $("#__tagInputDiv"); - theInput.val(refurbishTags(theInput.val())); - - options.animate(0, theDiv, function() { - theDiv.remove(); - }); - }; - - - // -------------------------- INPUT KEYBOARD -------------------------- - var tagInputKey = function (e) { - var rows = theDiv.find("div.tagInputLine"); - var rowNum = rows.index(theDiv.find("div.tagInputSel")); - - var ret = true; - switch (e.which) { - case 38: //up arrow - rowNum = (rowNum < 1 ? 0 : rowNum - 1 ); - tagInputHLSCR(rows.eq(rowNum), true); - break; - - case 40: //down arrow - rowNum = (rowNum < rows.size() - 1 ? rowNum + 1 : rows.size() - 1 ); - tagInputHLSCR(rows.eq(rowNum), false); - break; - - case 9: //tab - case 13: //enter - if (theDiv.is(":visible")){ - var theRow = rows.eq(rowNum); - tagInputClickRow(theRow); - ret = false; - } - break; - - case 27: //esc - options.animate(0, theDiv); - break; - - default: - $(document).stopTime("tagInputRefresh"); - $(document).oneTime(400, "tagInputRefresh", function() { - tagInputRefreshDiv(); - }); - break; - } - return ret; - }; - - - // -------------------------- TAG DIV HIGHLIGHT AND SCROLL -------------------------- - var tagInputHLSCR = function(theRowJQ, isUp) { - if (theRowJQ.size() > 0) { - var div = theDiv.get(0); - var theRow = theRowJQ.get(0); - if (isUp) { - if (theDiv.scrollTop() > theRow.offsetTop) { - theDiv.scrollTop(theRow.offsetTop); - } - } else { - if ((theRow.offsetTop + theRow.offsetHeight) > (div.scrollTop + div.offsetHeight)) { - div.scrollTop = theRow.offsetTop + theRow.offsetHeight - div.offsetHeight; - } - } - theDiv.find("div.tagInputSel").removeClass("tagInputSel"); - theRowJQ.addClass("tagInputSel"); - } - }; - - - // -------------------------- TAG LINE CLICK -------------------------- - var tagInputClickRow = function(theRow) { - - var lastComma = theInput.val().lastIndexOf(options.tagSeparator); - var sep= lastComma<=0? (""):(options.tagSeparator+ (options.tagSeparator==" "?"":" ")); - var newVal = (theInput.val().substr(0, lastComma) + sep + theRow.attr('id').replace('val-','')).trim(); - theInput.val(newVal); - theDiv.hide(); - $().oneTime(200, function() { - theInput.focus(); - }); - }; - - - // -------------------------- REFILL TAG BOX -------------------------- - var tagInputRefreshDiv = function () { - - var lastComma = theInput.val().lastIndexOf(options.tagSeparator); - var search = theInput.val().substr(lastComma + 1).trim(); - - - // -------------------------- FILLING THE DIV -------------------------- - var fillingCallbak = function(tags) { - tags = tags.sort(function (a, b) { - if (options.sortBy(a) < options.sortBy(b)) - return 1; - if (options.sortBy(a) > options.sortBy(b)) - return -1; - return 0; - }); - - for (var i in tags) { - tags[i]._val = options.formatValue(tags[i], i); - var el = tags[i]; - var matches = el._val.toLocaleLowerCase().indexOf(search.toLocaleLowerCase()) == 0; - if (!options.autoFilter || matches) { - var line = $(options.formatLine(i, el, search, matches)); - if (!line.is('.tagInputLine')) - line = $("
                  ").append(line); - line.attr('id', 'val-' + el._val); - theDiv.append(line); - } - } - if (theDiv.html()!=""){ - options.animate(true, theDiv); - } - - theDiv.find("div:first").addClass("tagInputSel"); - theDiv.find("div.tagInputLine").bind("click", function() { - tagInputClickRow($(this)); - }); - }; - - - if (search != "" || options.autoStart) { - theDiv.html(""); - - if (options.tags) - fillingCallbak(options.tags); - else{ - var data = {search:search}; - $.getJSON(options.jsonUrl, data, fillingCallbak ); - } - } else { - options.animate(false, theDiv); - } - }; - - // -------------------------- CLEAN THE TAG LIST FROM EXTRA SPACES, DOUBLE COMMAS ETC. -------------------------- - var refurbishTags = function (tagString) { - var splitted = tagString.split(options.tagSeparator); - var res = ""; - var first = true; - for (var i = 0; i < splitted.length; i++) { - if (splitted[i].trim() != "") { - if (first) { - first = false; - res = res + splitted[i].trim(); - } else { - res = res + options.tagSeparator+ (options.tagSeparator==" "?"":" ") + splitted[i].trim(); - } - } - } - return( res); - }; - - // -------------------------- TEST IF TAG IS PRESENT -------------------------- - var containsTag=function (tagString,tag){ - var splitted = tagString.split(options.tagSeparator); - var res=""; - var found=false; - tag=tag.trim(); - for(i = 0; i < splitted.length; i++){ - var testTag=splitted[i].trim(); - if (testTag==tag){ - found=true; - break; - } - } - return found; - }; - - - // -------------------------- SELECT TAGS BASING ON USER INPUT -------------------------- - var delayedSelectTagFromInput= function(){ - var element = $(this); - $().stopTime("suggTagRefresh"); - $().oneTime(200, "suggTagRefresh", function() { - selectSuggTagFromInput(); - }); - - }; - - var selectSuggTagFromInput = function () { - var val = theInput.val(); - suggestedTagsPlaceHolder.find(".tag").each(function(){ - var el = $(this); - var tag=el.text(); - - //check if already present - if (containsTag(val,tag)) { - el.addClass("tagUsed"); - } else { - el.removeClass("tagUsed"); - } - }); - - }; - - - - - // -------------------------- INPUT BINDINGS -------------------------- - $(this).bind("focus", tagInputFocus).bind("blur", tagInputBlur).bind("keydown", tagInputKey); - if (options.suggestedTags) - $(this).bind("keyup",delayedSelectTagFromInput) ; - - - }); - return this; -}; - - diff --git a/js/jquery.timers.js b/js/jquery.timers.js deleted file mode 100644 index bb51157d40..0000000000 --- a/js/jquery.timers.js +++ /dev/null @@ -1,138 +0,0 @@ -/** - * jQuery.timers - Timer abstractions for jQuery - * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com) - * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/). - * Date: 2009/10/16 - * - * @author Blair Mitchelmore - * @version 1.2 - * - **/ - -jQuery.fn.extend({ - everyTime: function(interval, label, fn, times) { - return this.each(function() { - jQuery.timer.add(this, interval, label, fn, times); - }); - }, - oneTime: function(interval, label, fn) { - return this.each(function() { - jQuery.timer.add(this, interval, label, fn, 1); - }); - }, - stopTime: function(label, fn) { - return this.each(function() { - jQuery.timer.remove(this, label, fn); - }); - } -}); - -jQuery.extend({ - timer: { - global: [], - guid: 1, - dataKey: "jQuery.timer", - regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/, - powers: { - // Yeah this is major overkill... - 'ms': 1, - 'cs': 10, - 'ds': 100, - 's': 1000, - 'das': 10000, - 'hs': 100000, - 'ks': 1000000 - }, - timeParse: function(value) { - if (value == undefined || value == null) - return null; - var result = this.regex.exec(jQuery.trim(value.toString())); - if (result[2]) { - var num = parseFloat(result[1]); - var mult = this.powers[result[2]] || 1; - return num * mult; - } else { - return value; - } - }, - add: function(element, interval, label, fn, times) { - var counter = 0; - - if (jQuery.isFunction(label)) { - if (!times) - times = fn; - fn = label; - label = interval; - } - - interval = jQuery.timer.timeParse(interval); - - if (typeof interval != 'number' || isNaN(interval) || interval < 0) - return; - - if (typeof times != 'number' || isNaN(times) || times < 0) - times = 0; - - times = times || 0; - - var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {}); - - if (!timers[label]) - timers[label] = {}; - - fn.timerID = fn.timerID || this.guid++; - - var handler = function() { - if ((++counter > times && times !== 0) || fn.call(element, counter) === false) - jQuery.timer.remove(element, label, fn); - }; - - handler.timerID = fn.timerID; - - if (!timers[label][fn.timerID]) - timers[label][fn.timerID] = window.setInterval(handler,interval); - - this.global.push( element ); - - }, - remove: function(element, label, fn) { - var timers = jQuery.data(element, this.dataKey), ret; - - if ( timers ) { - - if (!label) { - for ( label in timers ) - this.remove(element, label, fn); - } else if ( timers[label] ) { - if ( fn ) { - if ( fn.timerID ) { - window.clearInterval(timers[label][fn.timerID]); - delete timers[label][fn.timerID]; - } - } else { - for ( var fn in timers[label] ) { - window.clearInterval(timers[label][fn]); - delete timers[label][fn]; - } - } - - for ( ret in timers[label] ) break; - if ( !ret ) { - ret = null; - delete timers[label]; - } - } - - for ( ret in timers ) break; - if ( !ret ) - jQuery.removeData(element, this.dataKey); - } - } - } -}); - -jQuery(window).bind("unload", function() { - jQuery.each(jQuery.timer.global, function(index, item) { - jQuery.timer.remove(item); - }); -}); diff --git a/js/util.js b/js/util.js index 9d8e139088..844a5adb8d 100644 --- a/js/util.js +++ b/js/util.js @@ -518,8 +518,8 @@ var SN = { // StatusNet url: form.attr('action'), data: form.serialize() + '&ajax=1', beforeSend: function(xhr) { - form.addClass(SN.C.S.Processing) - .find('.submit') + form.find('.submit') + .addClass(SN.C.S.Processing) .addClass(SN.C.S.Disabled) .attr(SN.C.S.Disabled, SN.C.S.Disabled); }, @@ -1543,39 +1543,94 @@ var SN = { // StatusNet }); }, - PeopletagAutocomplete: function() { - $('.form_tag_user #tags').tagInput({ - tags: SN.C.PtagACData, - tagSeparator: " ", - animate: false, - formatLine: function (i, e, search, matches) { - var tag = "" + e.tag.substring(0, search.length) + "" + e.tag.substring(search.length); + /** + * Called when a people tag edit box is shown in the interface + * + * - loads the jQuery UI autocomplete plugin + * - sets event handlers for tag completion + * + */ + PeopletagAutocomplete: function(txtBox) { + var split = function(val) { + return val.split( /\s+/ ); + } + var extractLast = function(term) { + return split(term).pop(); + } - var line = $("
                  ").addClass('mode-' + e.mode); - line.append($("
                  " + tag - + " " + e.mode + "
                  ")); - if (e.freq) - line.append("
                  " + e.freq + "
                  "); - return line; + // don't navigate away from the field on tab when selecting an item + txtBox.live( "keydown", function( event ) { + if ( event.keyCode === $.ui.keyCode.TAB && + $(this).data( "autocomplete" ).menu.active ) { + event.preventDefault(); } - }); + }).autocomplete({ + minLength: 0, + source: function(request, response) { + // delegate back to autocomplete, but extract the last term + response($.ui.autocomplete.filter( + SN.C.PtagACData, extractLast(request.term))); + }, + focus: function() { + return false; + }, + select: function(event, ui) { + var terms = split(this.value); + terms.pop(); + terms.push(ui.item.value); + terms.push(""); + this.value = terms.join(" "); + return false; + } + }).data('autocomplete')._renderItem = function(ul, item) { + // FIXME: with jQuery UI you cannot have it highlight the match + var _l = '' + item.tag + + ' ' + item.mode + '' + + '' + item.freq + '' + + return $("
                • ") + .addClass('mode-' + item.mode) + .addClass('ptag-ac-line') + .data("item.autocomplete", item) + .append(_l) + .appendTo(ul); + } }, + /** + * Run setup for the ajax people tags editor + * + * - show edit button + * - set event handle for click on edit button + * - loads people tag autocompletion data if not already present + * or if it is stale. + * + */ PeopleTags: function() { $('.user_profile_tags .editable').append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(j){var i=$("").attr("title",e).attr("alt",e).attr("src",j).attr("style","height: 120px");d.find(".attach-status").append(i)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var k=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var l=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var j=a.find("label.notice_data-geo");function f(n){j.attr("title",jQuery.trim(j.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(n){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(n)}else{a.find(".geo_status_wrapper").remove()}}function m(n,o){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(n,o,function(p){var q,r;if(typeof(p.location_ns)!="undefined"){a.find("[name=location_ns]").val(p.location_ns);q=p.location_ns}if(typeof(p.location_id)!="undefined"){a.find("[name=location_id]").val(p.location_id);r=p.location_id}if(typeof(p.name)=="undefined"){NLN_text=o.lat+";"+o.lon}else{NLN_text=p.name}SN.U.NoticeGeoStatus(a,NLN_text,o.lat,o.lon,p.url);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(o.lat);a.find("[name=lon]").val(o.lon);a.find("[name=location_ns]").val(q);a.find("[name=location_id]").val(r);a.find("[name=notice_data-geo]").attr("checked",true);var s={NLat:o.lat,NLon:o.lon,NLNS:q,NLID:r,NLN:NLN_text,NLNU:p.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(s),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var i=h.attr("data-api");j.attr("title",j.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){j.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(p){a.find("[name=lat]").val(p.coords.latitude);a.find("[name=lon]").val(p.coords.longitude);var q={lat:p.coords.latitude,lon:p.coords.longitude,token:$("#token").val()};m(i,q)},function(p){switch(p.code){case p.PERMISSION_DENIED:f("Location permission denied.");break;case p.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&k.length>0){var n={lat:e,lon:k,token:$("#token").val()};m(i,n)}else{f();c.remove();j.remove()}}}else{var o=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(o.NLat);a.find("[name=lon]").val(o.NLon);a.find("[name=location_ns]").val(o.NLNS);a.find("[name=location_id]").val(o.NLID);a.find("[name=notice_data-geo]").attr("checked",o.NDG);SN.U.NoticeGeoStatus(a,o.NLN,o.NLat,o.NLon,o.NLNU);j.attr("title",NoticeDataGeo_text.ShareDisable+" ("+o.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var j=$(this);if(j.has(g.target).length==0){var h=j.find(".notice_data-text:first");var i=$.trim(h.val());if(i==""||i==h.data("initialText")){var e=j.closest("li.notice");j.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(){$(".form_tag_user #tags").tagInput({tags:SN.C.PtagACData,tagSeparator:" ",animate:false,formatLine:function(d,g,c,f){var a=""+g.tag.substring(0,c.length)+""+g.tag.substring(c.length);var b=$("
                  ").addClass("mode-"+g.mode);b.append($("
                  "+a+" "+g.mode+"
                  "));if(g.freq){b.append("
                  "+g.freq+"
                  ")}return b}})},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var b=$(this);SN.Init.NoticeFormSetup(b)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("
                  ").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$("fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$("fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find("textarea:first").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append($("form",$(b).children()));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)},"xml")}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=a}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
                  ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
                  ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
                  ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
                • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('