made the input-form switcher work, kinda

This commit is contained in:
Evan Prodromou 2011-03-06 17:27:03 -05:00
parent 17db6cce3d
commit b54a9f389c
3 changed files with 101 additions and 10 deletions

View File

@ -640,8 +640,60 @@ class Action extends HTMLOutputter // lawsuit
*/
function showNoticeForm()
{
$notice_form = new NoticeForm($this);
$notice_form->show();
$tabs = array('status' => _('Status'));
$this->elementStart('div', 'input_forms');
if (Event::handle('StartShowEntryForms', array(&$tabs))) {
$this->elementStart('ul', array('class' => 'nav',
'id' => 'input_form_nav'));
foreach ($tabs as $tag => $title) {
$attrs = array('id' => 'input_form_nav_'.$title);
if ($tag == 'status') {
$attrs['class'] = 'current';
}
$this->elementStart('li', $attrs);
$this->element('a',
array('href' => 'javascript:switchInputFormTab("'.$tag.'")'),
$title);
$this->elementEnd('li');
}
$this->elementEnd('ul');
foreach ($tabs as $tag => $title) {
$attrs = array('class' => 'input_form',
'id' => 'input_form_'.$tag);
if ($tag == 'status') {
$attrs['class'] .= ' active';
} else {
$attrs['class'] .= ' inactive';
}
$this->elementStart('div', $attrs);
$form = null;
if (Event::handle('StartMakeEntryForm', array($tag, $this, &$form))) {
if ($tag == 'status') {
$form = new NoticeForm($this);
}
Event::handle('EndMakeEntryForm', array($tag, $this, $form));
}
if (!empty($form)) {
$form->show();
}
}
}
}
/**

View File

@ -54,7 +54,7 @@ abstract class MicroAppPlugin extends Plugin
abstract function appTitle();
abstract function tag();
abstract function types();
abstract function saveNoticeFromActivity($activity, $actor);
abstract function saveNoticeFromActivity($activity, $actor, $options);
abstract function activityObjectFromNotice($notice);
abstract function showNotice($notice, $out);
abstract function entryForm($out);
@ -157,6 +157,13 @@ abstract class MicroAppPlugin extends Plugin
throw new ClientException(_('Can\'t get author for activity.'));
}
$object = $activity->objects[0];
$options = array('uri' => $object->id,
'url' => $object->link,
'is_local' => Notice::REMOTE_OMB,
'source' => 'ostatus');
$this->saveNoticeFromActivity($activity, $actor);
return false;
@ -196,7 +203,7 @@ abstract class MicroAppPlugin extends Plugin
if (!in_array($uri, $activity->context->attention) &&
(empty($original) ||
$original->profile_id != $target->id)) {
throw new ClientException(_("Bookmark not posted ".
throw new ClientException(_("Object not posted ".
"to this user."));
}
} else {
@ -206,7 +213,14 @@ abstract class MicroAppPlugin extends Plugin
$actor = Ostatus_profile::ensureActivityObjectProfile($activity->actor);
$this->saveNoticeFromActivity($activity, $actor);
$object = $activity->objects[0];
$options = array('uri' => $object->id,
'url' => $object->link,
'is_local' => Notice::REMOTE_OMB,
'source' => 'ostatus');
$this->saveNoticeFromActivity($activity, $actor, $options);
return false;
}
@ -258,8 +272,8 @@ abstract class MicroAppPlugin extends Plugin
$obj = $activity->objects[0];
$options = array('uri' => $bookmark->id,
'url' => $bookmark->link,
$options = array('uri' => $object->id,
'url' => $object->link,
'source' => 'restore');
$saved = $this->saveNoticeFromActivity($activity,
@ -275,4 +289,22 @@ abstract class MicroAppPlugin extends Plugin
return true;
}
function onStartShowEntryForms(&$tabs)
{
$tabs[$this->tag()] = $this->appTitle();
return true;
}
function onStartMakeEntryForm($tag, $out, &$form)
{
$this->log(LOG_INFO, "onStartMakeEntryForm() called for tag '$tag'");
if ($tag == $this->tag()) {
$form = $this->entryForm($out);
return false;
}
return true;
}
}

View File

@ -372,10 +372,8 @@ class BookmarkPlugin extends MicroAppPlugin
* @return Notice resulting notice
*/
function saveNoticeFromActivity($activity, $profile)
function saveNoticeFromActivity($activity, $profile, $options=array())
{
$options = array();
$bookmark = $activity->objects[0];
$relLinkEls = ActivityUtils::getLinks($bookmark->element, 'related');
@ -622,4 +620,13 @@ class BookmarkPlugin extends MicroAppPlugin
return new BookmarkForm($out);
}
function tag()
{
return 'bookmark';
}
function appTitle()
{
return _m('Bookmark');
}
}