summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Adsense/AdsensePlugin.php48
-rw-r--r--plugins/Adsense/adsenseadminpanel.php223
-rw-r--r--plugins/MobileProfile/mp-screen.css6
-rw-r--r--plugins/OStatus/OStatusPlugin.php3
-rw-r--r--plugins/OStatus/actions/hostmeta.php3
-rw-r--r--plugins/OStatus/lib/magicenvelope.php28
-rw-r--r--plugins/OStatus/lib/salmon.php4
-rw-r--r--plugins/OStatus/lib/xrd.php94
-rw-r--r--plugins/OStatus/lib/xrdaction.php5
-rw-r--r--plugins/TwitterBridge/TwitterBridgePlugin.php13
-rw-r--r--plugins/TwitterBridge/twitteradminpanel.php29
11 files changed, 360 insertions, 96 deletions
diff --git a/plugins/Adsense/AdsensePlugin.php b/plugins/Adsense/AdsensePlugin.php
index ab2b9a6fb..cd6fc3503 100644
--- a/plugins/Adsense/AdsensePlugin.php
+++ b/plugins/Adsense/AdsensePlugin.php
@@ -83,6 +83,21 @@ class AdsensePlugin extends UAPPlugin
public $adScript = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
public $client = null;
+ function initialize()
+ {
+ parent::initialize();
+
+ // A little bit of chicanery so we avoid overwriting values that
+ // are passed in with the constructor
+
+ foreach (array('mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper', 'adScript', 'client') as $setting) {
+ $value = common_config('adsense', strtolower($setting));
+ if (!empty($value)) { // not found
+ $this->$setting = $value;
+ }
+ }
+ }
+
/**
* Show a medium rectangle 'ad'
*
@@ -157,4 +172,37 @@ class AdsensePlugin extends UAPPlugin
$action->script($this->adScript);
}
+
+ function onRouterInitialized($m)
+ {
+ $m->connect('admin/adsense',
+ array('action' => 'adsenseadminpanel'));
+
+ return true;
+ }
+
+ function onAutoload($cls)
+ {
+ $dir = dirname(__FILE__);
+
+ switch ($cls)
+ {
+ case 'AdsenseadminpanelAction':
+ require_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onEndAdminPanelNav($menu) {
+ if (AdminPanelAction::canAdmin('adsense')) {
+ // TRANS: Menu item title/tooltip
+ $menu_title = _('Adsense configuration');
+ // TRANS: Menu item for site administration
+ $menu->out->menuItem(common_local_url('adsenseadminpanel'), _('Adsense'),
+ $menu_title, $action_name == 'adsenseadminpanel', 'nav_adsense_admin_panel');
+ }
+ return true;
+ }
} \ No newline at end of file
diff --git a/plugins/Adsense/adsenseadminpanel.php b/plugins/Adsense/adsenseadminpanel.php
new file mode 100644
index 000000000..7b99cf805
--- /dev/null
+++ b/plugins/Adsense/adsenseadminpanel.php
@@ -0,0 +1,223 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Adsense administration panel
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Adsense
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @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);
+}
+
+/**
+ * Administer adsense settings
+ *
+ * @category Adsense
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class AdsenseadminpanelAction extends AdminPanelAction
+{
+ /**
+ * Returns the page title
+ *
+ * @return string page title
+ */
+
+ function title()
+ {
+ return _('Adsense');
+ }
+
+ /**
+ * Instructions for using this form.
+ *
+ * @return string instructions
+ */
+
+ function getInstructions()
+ {
+ return _('Adsense settings for this StatusNet site');
+ }
+
+ /**
+ * Show the site admin panel form
+ *
+ * @return void
+ */
+
+ function showForm()
+ {
+ $form = new AdsenseAdminPanelForm($this);
+ $form->show();
+ return;
+ }
+
+ /**
+ * Save settings from the form
+ *
+ * @return void
+ */
+
+ function saveSettings()
+ {
+ static $settings = array('adsense' => array('adScript', 'client', 'mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper'));
+
+ $values = array();
+
+ foreach ($settings as $section => $parts) {
+ foreach ($parts as $setting) {
+ $values[$section][$setting] = $this->trimmed($setting);
+ }
+ }
+
+ // This throws an exception on validation errors
+
+ $this->validate($values);
+
+ // assert(all values are valid);
+
+ $config = new Config();
+
+ $config->query('BEGIN');
+
+ foreach ($settings as $section => $parts) {
+ foreach ($parts as $setting) {
+ Config::save($section, $setting, $values[$section][$setting]);
+ }
+ }
+
+ $config->query('COMMIT');
+
+ return;
+ }
+
+ function validate(&$values)
+ {
+ }
+}
+
+/**
+ * Form for the adsense admin panel
+ */
+
+class AdsenseAdminPanelForm extends AdminForm
+{
+ /**
+ * ID of the form
+ *
+ * @return int ID of the form
+ */
+
+ function id()
+ {
+ return 'form_adsense_admin_panel';
+ }
+
+ /**
+ * class of the form
+ *
+ * @return string class of the form
+ */
+
+ function formClass()
+ {
+ return 'form_adsense';
+ }
+
+ /**
+ * Action of the form
+ *
+ * @return string URL of the action
+ */
+
+ function action()
+ {
+ return common_local_url('adsenseadminpanel');
+ }
+
+ /**
+ * Data elements of the form
+ *
+ * @return void
+ */
+
+ function formData()
+ {
+ $this->out->elementStart('fieldset', array('id' => 'adsense_admin'));
+ $this->out->elementStart('ul', 'form_data');
+ $this->li();
+ $this->input('client',
+ _('Client ID'),
+ _('Google client ID'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('adScript',
+ _('Ad Script URL'),
+ _('Script URL (advanced)'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('mediumRectangle',
+ _('Medium rectangle'),
+ _('Medium rectangle slot code'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('rectangle',
+ _('Rectangle'),
+ _('Rectangle slot code'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('leaderboard',
+ _('Leaderboard'),
+ _('Leaderboard slot code'),
+ 'adsense');
+ $this->unli();
+ $this->li();
+ $this->input('wideSkyscraper',
+ _('Skyscraper'),
+ _('Wide skyscraper slot code'),
+ 'adsense');
+ $this->unli();
+ $this->out->elementEnd('ul');
+ }
+
+ /**
+ * Action elements
+ *
+ * @return void
+ */
+
+ function formActions()
+ {
+ $this->out->submit('submit', _('Save'), 'submit', null, _('Save AdSense settings'));
+ }
+}
diff --git a/plugins/MobileProfile/mp-screen.css b/plugins/MobileProfile/mp-screen.css
index 0fc801612..1f70b5612 100644
--- a/plugins/MobileProfile/mp-screen.css
+++ b/plugins/MobileProfile/mp-screen.css
@@ -2,7 +2,7 @@
*
* @package StatusNet
* @author Sarven Capadisli <csarven@status.net>
- * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009-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/
*/
@@ -195,10 +195,6 @@ width:43px;
margin-right:1%;
}
-.notice-options form {
-width:16px;
-height:16px;
-}
.notice-options form.processing {
background-image:none;
}
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 4fc9d4108..70971c5b3 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -158,6 +158,9 @@ class OStatusPlugin extends Plugin
// Also, we'll add in the salmon link
$salmon = common_local_url($salmonAction, array('id' => $id));
+ $feed->addLink($salmon, array('rel' => Salmon::REL_SALMON));
+
+ // XXX: these are deprecated
$feed->addLink($salmon, array('rel' => Salmon::NS_REPLIES));
$feed->addLink($salmon, array('rel' => Salmon::NS_MENTIONS));
}
diff --git a/plugins/OStatus/actions/hostmeta.php b/plugins/OStatus/actions/hostmeta.php
index 6d35ada6c..8ca07f916 100644
--- a/plugins/OStatus/actions/hostmeta.php
+++ b/plugins/OStatus/actions/hostmeta.php
@@ -36,13 +36,12 @@ class HostMetaAction extends Action
$url.= '?uri={uri}';
$xrd = new XRD();
-
- $xrd = new XRD();
$xrd->host = $domain;
$xrd->links[] = array('rel' => Discovery::LRDD_REL,
'template' => $url,
'title' => array('Resource Descriptor'));
+ header('Content-type: application/xrd+xml');
print $xrd->toXML();
}
}
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index f39686b71..3bdf24b31 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -97,24 +97,18 @@ class MagicEnvelope
}
public function toXML($env) {
- $dom = new DOMDocument();
-
- $envelope = $dom->createElementNS(MagicEnvelope::NS, 'me:env');
- $envelope->setAttribute('xmlns:me', MagicEnvelope::NS);
- $data = $dom->createElementNS(MagicEnvelope::NS, 'me:data', $env['data']);
- $data->setAttribute('type', $env['data_type']);
- $envelope->appendChild($data);
- $enc = $dom->createElementNS(MagicEnvelope::NS, 'me:encoding', $env['encoding']);
- $envelope->appendChild($enc);
- $alg = $dom->createElementNS(MagicEnvelope::NS, 'me:alg', $env['alg']);
- $envelope->appendChild($alg);
- $sig = $dom->createElementNS(MagicEnvelope::NS, 'me:sig', $env['sig']);
- $envelope->appendChild($sig);
-
- $dom->appendChild($envelope);
+ $xs = new XMLStringer();
+ $xs->startXML();
+ $xs->elementStart('me:env', array('xmlns:me' => MagicEnvelope::NS));
+ $xs->element('me:data', array('type' => $env['data_type']), $env['data']);
+ $xs->element('me:encoding', null, $env['encoding']);
+ $xs->element('me:alg', null, $env['alg']);
+ $xs->element('me:sig', null, $env['sig']);
+ $xs->elementEnd('me:env');
-
- return $dom->saveXML();
+ $string = $xs->getString();
+ common_debug($string);
+ return $string;
}
diff --git a/plugins/OStatus/lib/salmon.php b/plugins/OStatus/lib/salmon.php
index 3d3341bc6..ef7719a40 100644
--- a/plugins/OStatus/lib/salmon.php
+++ b/plugins/OStatus/lib/salmon.php
@@ -28,9 +28,11 @@
*/
class Salmon
{
+ const REL_SALMON = 'salmon';
+ const REL_MENTIONED = 'mentioned';
+ // XXX: these are deprecated
const NS_REPLIES = "http://salmon-protocol.org/ns/salmon-replies";
-
const NS_MENTIONS = "http://salmon-protocol.org/ns/salmon-mention";
/**
diff --git a/plugins/OStatus/lib/xrd.php b/plugins/OStatus/lib/xrd.php
index 34b28790b..a10b9f427 100644
--- a/plugins/OStatus/lib/xrd.php
+++ b/plugins/OStatus/lib/xrd.php
@@ -106,44 +106,43 @@ class XRD
public function toXML()
{
- $dom = new DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = true;
-
- $xrd_dom = $dom->createElementNS(XRD::XRD_NS, 'XRD');
- $dom->appendChild($xrd_dom);
+ $xs = new XMLStringer();
+
+ $xs->startXML();
+ $xs->elementStart('XRD', array('xmlns' => XRD::XRD_NS));
if ($this->host) {
- $host_dom = $dom->createElement('hm:Host', $this->host);
- $xrd_dom->setAttributeNS(XRD::XML_NS, 'xmlns:hm', XRD::HOST_META_NS);
- $xrd_dom->appendChild($host_dom);
+ $xs->element('hm:Host', array('xmlns:hm' => XRD::HOST_META_NS), $this->host);
}
- if ($this->expires) {
- $expires_dom = $dom->createElement('Expires', $this->expires);
- $xrd_dom->appendChild($expires_dom);
- }
-
- if ($this->subject) {
- $subject_dom = $dom->createElement('Subject', $this->subject);
- $xrd_dom->appendChild($subject_dom);
- }
-
- foreach ($this->alias as $alias) {
- $alias_dom = $dom->createElement('Alias', $alias);
- $xrd_dom->appendChild($alias_dom);
- }
-
- foreach ($this->types as $type) {
- $type_dom = $dom->createElement('Type', $type);
- $xrd_dom->appendChild($type_dom);
- }
-
- foreach ($this->links as $link) {
- $link_dom = $this->saveLink($dom, $link);
- $xrd_dom->appendChild($link_dom);
- }
-
- return $dom->saveXML();
+ if ($this->expires) {
+ $xs->element('Expires', null, $this->expires);
+ }
+
+ if ($this->subject) {
+ $xs->element('Subject', null, $this->subject);
+ }
+
+ foreach ($this->alias as $alias) {
+ $xs->element('Alias', null, $alias);
+ }
+
+ foreach ($this->links as $link) {
+ $titles = array();
+ if (isset($link['title'])) {
+ $titles = $link['title'];
+ unset($link['title']);
+ }
+ $xs->elementStart('Link', $link);
+ foreach ($titles as $title) {
+ $xs->element('Title', null, $title);
+ }
+ $xs->elementEnd('Link');
+ }
+
+ $xs->elementEnd('XRD');
+
+ return $xs->getString();
}
function parseType($element)
@@ -169,32 +168,5 @@ class XRD
return $link;
}
-
- function saveLink($doc, $link)
- {
- $link_element = $doc->createElement('Link');
- if (!empty($link['rel'])) {
- $link_element->setAttribute('rel', $link['rel']);
- }
- if (!empty($link['type'])) {
- $link_element->setAttribute('type', $link['type']);
- }
- if (!empty($link['href'])) {
- $link_element->setAttribute('href', $link['href']);
- }
- if (!empty($link['template'])) {
- $link_element->setAttribute('template', $link['template']);
- }
-
- if (!empty($link['title']) && is_array($link['title'])) {
- foreach($link['title'] as $title) {
- $title = $doc->createElement('Title', $title);
- $link_element->appendChild($title);
- }
- }
-
-
- return $link_element;
- }
}
diff --git a/plugins/OStatus/lib/xrdaction.php b/plugins/OStatus/lib/xrdaction.php
index f1a56e0a8..d8cf648d6 100644
--- a/plugins/OStatus/lib/xrdaction.php
+++ b/plugins/OStatus/lib/xrdaction.php
@@ -76,6 +76,9 @@ class XrdAction extends Action
$salmon_url = common_local_url('usersalmon',
array('id' => $this->user->id));
+ $xrd->links[] = array('rel' => Salmon::REL_SALMON,
+ 'href' => $salmon_url);
+ // XXX : Deprecated - to be removed.
$xrd->links[] = array('rel' => Salmon::NS_REPLIES,
'href' => $salmon_url);
@@ -98,7 +101,7 @@ class XrdAction extends Action
$xrd->links[] = array('rel' => 'http://ostatus.org/schema/1.0/subscribe',
'template' => $url );
- header('Content-type: text/xml');
+ header('Content-type: application/xrd+xml');
print $xrd->toXML();
}
diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php
index 65b3a6b38..0505a328f 100644
--- a/plugins/TwitterBridge/TwitterBridgePlugin.php
+++ b/plugins/TwitterBridge/TwitterBridgePlugin.php
@@ -50,6 +50,7 @@ class TwitterBridgePlugin extends Plugin
{
const VERSION = STATUSNET_VERSION;
+ public $adminImportControl = false; // Should the 'import' checkbox be exposed in the admin panel?
/**
* Initializer for the plugin.
@@ -322,5 +323,17 @@ class TwitterBridgePlugin extends Plugin
return true;
}
+ /**
+ * Expose the adminImportControl setting to the administration panel code.
+ * This allows us to disable the import bridge enabling checkbox for administrators,
+ * since on a bulk farm site we can't yet automate the import daemon setup.
+ *
+ * @return boolean hook value;
+ */
+ function onTwitterBridgeAdminImportControl()
+ {
+ return (bool)$this->adminImportControl;
+ }
+
}
diff --git a/plugins/TwitterBridge/twitteradminpanel.php b/plugins/TwitterBridge/twitteradminpanel.php
index a78a92c66..69f8da078 100644
--- a/plugins/TwitterBridge/twitteradminpanel.php
+++ b/plugins/TwitterBridge/twitteradminpanel.php
@@ -92,9 +92,11 @@ class TwitteradminpanelAction extends AdminPanelAction
);
static $booleans = array(
- 'twitter' => array('signin'),
- 'twitterimport' => array('enabled')
+ 'twitter' => array('signin')
);
+ if (Event::handle('TwitterBridgeAdminImportControl')) {
+ $booleans['twitterimport'] = array('enabled');
+ }
$values = array();
@@ -155,6 +157,13 @@ class TwitteradminpanelAction extends AdminPanelAction
);
}
}
+
+ function isImportEnabled()
+ {
+ // Since daemon setup isn't automated yet...
+ // @todo: if merged into main queues, detect presence of daemon config
+ return true;
+ }
}
class TwitterAdminPanelForm extends AdminForm
@@ -263,13 +272,15 @@ class TwitterAdminPanelForm extends AdminForm
);
$this->unli();
- $this->li();
- $this->out->checkbox(
- 'enabled', _m('Enable Twitter import'),
- (bool) $this->value('enabled', 'twitterimport'),
- _m('Allow users to import their Twitter friends\' timelines')
- );
- $this->unli();
+ if (Event::handle('TwitterBridgeAdminImportControl')) {
+ $this->li();
+ $this->out->checkbox(
+ 'enabled', _m('Enable Twitter import'),
+ (bool) $this->value('enabled', 'twitterimport'),
+ _m('Allow users to import their Twitter friends\' timelines. Requires daemons to be manually configured.')
+ );
+ $this->unli();
+ }
$this->out->elementEnd('ul');