diff options
author | Shashi Gowda <connect2shashi@gmail.com> | 2010-06-13 07:27:56 -0400 |
---|---|---|
committer | Shashi Gowda <connect2shashi@gmail.com> | 2010-06-13 07:29:31 -0400 |
commit | 3cf486c7f41ce088824c29c2c7457e5f1631a8f1 (patch) | |
tree | 9a150c123fc3673b4f9e6117153cbe6e0839a70a | |
parent | 5e5a7d69e50bc010fb2fe4c5fff621efd53a4d77 (diff) |
Some improvements
-rw-r--r-- | plugins/SocialObject/NewSocialObjectAction.php | 14 | ||||
-rw-r--r-- | plugins/SocialObject/SocialObject.php | 15 | ||||
-rw-r--r-- | plugins/SocialObject/SocialObjectPlugin.php | 30 | ||||
-rw-r--r-- | plugins/SocialObject/todo | 2 |
4 files changed, 42 insertions, 19 deletions
diff --git a/plugins/SocialObject/NewSocialObjectAction.php b/plugins/SocialObject/NewSocialObjectAction.php index dd58cacbf..79522b3f4 100644 --- a/plugins/SocialObject/NewSocialObjectAction.php +++ b/plugins/SocialObject/NewSocialObjectAction.php @@ -35,6 +35,8 @@ if (!defined('STATUSNET')) { exit(1); } +require_once INSTALLDIR . '/actions/newnotice.php'; + class NewSocialObjectAction extends NewnoticeAction { private $slug=null; @@ -168,14 +170,10 @@ class NewSocialObjectAction extends NewnoticeAction { } - function save() - { - # save your custom data, video, event or whatever. - } - - function saveNew() + function saveNew($notice) { - # save new social-object to its table. + $cls = $this->dbclass; + $cls::saveNew($notice, $this); } function showPage() @@ -199,7 +197,7 @@ class NewSocialObjectAction extends NewnoticeAction function showNoticeForm() { - $this->showSocialObjectForm(); + $this->showSocialObjectForm(); # instead. } # when user choses to post a social object, diff --git a/plugins/SocialObject/SocialObject.php b/plugins/SocialObject/SocialObject.php index 45e1def2c..f4b84dd9f 100644 --- a/plugins/SocialObject/SocialObject.php +++ b/plugins/SocialObject/SocialObject.php @@ -40,19 +40,18 @@ class SocialObject extends Memcached_DataObject var $slug=null; # used in cache key # save a new object - static function saveNew($args) + static function saveNew($notice, $action) { - # save everything, add a - # Notice entry too. - # call Notice::saveNew with options - # like replies, groups and tags. - # and, cache blowing action. + # $notice is the Notice object already saved, + # $action is the new object action, can be used + # for arguments. eg. $action->args('whatever'); } function delete() { # delete me and my associated Notice - # more cache blowing action + $notice = Notice::staticGet('id', $this->id); + $notice->delete(); parent::delete(); } @@ -67,7 +66,7 @@ class SocialObject extends Memcached_DataObject } # return an array for Schema::ensureTable to define the table - static function tableDef() + static function schemaDef() { return array(); } diff --git a/plugins/SocialObject/SocialObjectPlugin.php b/plugins/SocialObject/SocialObjectPlugin.php index 6654b0045..7c63c8a70 100644 --- a/plugins/SocialObject/SocialObjectPlugin.php +++ b/plugins/SocialObject/SocialObjectPlugin.php @@ -47,13 +47,36 @@ class SocialObjectPlugin extends Plugin private $slug_plural=null; # Database class private $dbclass=null; + # path to the plugin directory + private $plugin_path = null; + + function initialize() + { + # set $this->plugin_path here. + } + + function onAutoload($cls) + { + $actions = array(); + foreach(array('Public', 'User', 'Group') as $a) { + $actions[] = $a.$this->slug_plural.'Action'; + } + $actions[] = 'New'.$this->slug.'Action'; + $actions[] = $this->dbclass; + + if(in_array($cls, $actions)) { + require_once $this->plugin_path."/$cls.php"; + return false; + } + return true; + } # setup DB tables etc. function onCheckSchema() { $schema = Schema::get(); $classname = $this->dbclass - $schema->ensureTable($classname::tableDef()); + $schema->ensureTable($classname::schemaDef()); return true; } @@ -71,6 +94,9 @@ class SocialObjectPlugin extends Plugin $m->connect('group/:group/'.$this->slug_plural, array('action' => 'group'.$this->slug_plural, 'group' => '[a-zA-Z0-9]{1,64}')); + # create new + $m->connect($this->slug.'/new', + array('action' => 'new'.$this->slug_plural)); # more to come in future: popular & lists. return true; } @@ -124,7 +150,7 @@ class SocialObjectPlugin extends Plugin array('href' => common_local_url('shownoticeform').'#social-'.$this->slug, 'title' => $this->name) , $this->name); - $form->out->elementEnd('ul'); + $form->out->elementEnd('li'); } # if the notice being shown has metadata for diff --git a/plugins/SocialObject/todo b/plugins/SocialObject/todo index 5b3ad28b1..51d0eac16 100644 --- a/plugins/SocialObject/todo +++ b/plugins/SocialObject/todo @@ -1,2 +1,2 @@ -- autoload files +- make a way to way to configure names at one place - think about exchange over OStatus |