X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FBlog%2FBlogPlugin.php;h=8d5532b8b17c508c1cce18f1960c20aaf07e7a9c;hb=e7c6c6fc763ee94c34214f31980eabe83177a265;hp=7f8e8fd1d0b37700a16563d0fa666ca6b4388e8a;hpb=01996b1a460693227ef263d44477bc12d297a70a;p=quix0rs-gnu-social.git diff --git a/plugins/Blog/BlogPlugin.php b/plugins/Blog/BlogPlugin.php index 7f8e8fd1d0..8d5532b8b1 100644 --- a/plugins/Blog/BlogPlugin.php +++ b/plugins/Blog/BlogPlugin.php @@ -50,6 +50,9 @@ if (!defined('STATUSNET')) { class BlogPlugin extends MicroAppPlugin { + + var $oldSaveNew = true; + /** * Database schema setup * @@ -62,48 +65,23 @@ class BlogPlugin extends MicroAppPlugin { $schema = Schema::get(); - $schema->ensureTable('blog_entry', BlogEntry::schemaDef()); + $schema->ensureTable('blog_entry', Blog_entry::schemaDef()); return true; } - - /** - * Load related modules when needed - * - * @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__); - - switch ($cls) - { - case 'NewblogentryAction': - case 'ShowblogentryAction': - include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php'; - return false; - case 'BlogEntryForm': - case 'BlogEntryListItem': - include_once $dir . '/'.strtolower($cls).'.php'; - return false; - case 'BlogEntry': - include_once $dir . '/'.$cls.'.php'; - return false; - default: - return true; - } + + public function newFormAction(){ + return 'newblogentry'; } /** * Map URLs to actions * - * @param Net_URL_Mapper $m path-to-action mapper + * @param URLMapper $m path-to-action mapper * * @return boolean hook value; true means continue processing, false means stop. */ - function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $m->connect('blog/new', array('action' => 'newblogentry')); @@ -116,17 +94,19 @@ class BlogPlugin extends MicroAppPlugin function onPluginVersion(&$versions) { $versions[] = array('name' => 'Blog', - 'version' => STATUSNET_VERSION, + 'version' => GNUSOCIAL_VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Blog', 'rawdescription' => + // TRANS: Plugin description. _m('Let users write and share long-form texts.')); return true; } function appTitle() { - return _m('Blog'); + // TRANS: Blog application title. + return _m('TITLE','Blog'); } function tag() @@ -136,10 +116,10 @@ class BlogPlugin extends MicroAppPlugin function types() { - return array(BlogEntry::TYPE); + return array(Blog_entry::TYPE); } - function saveNoticeFromActivity($activity, $actor, $options=array()) + function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options=array()) { if (count($activity->objects) != 1) { // TRANS: Exception thrown when there are too many activity objects. @@ -148,8 +128,8 @@ class BlogPlugin extends MicroAppPlugin $entryObj = $activity->objects[0]; - if ($entryObj->type != BlogEntry::TYPE) { - // TRANS: Exception thrown when blog plugin comes across a non-event type object. + if ($entryObj->type != Blog_entry::TYPE) { + // TRANS: Exception thrown when blog plugin comes across a non-blog entry type object. throw new ClientException(_m('Wrong type for object.')); } @@ -157,7 +137,7 @@ class BlogPlugin extends MicroAppPlugin switch ($activity->verb) { case ActivityVerb::POST: - $notice = BlogEntry::saveNew($actor, + $notice = Blog_entry::saveNew($actor, $entryObj->title, $entryObj->content, $options); @@ -170,12 +150,13 @@ class BlogPlugin extends MicroAppPlugin return $notice; } - function activityObjectFromNotice($notice) + function activityObjectFromNotice(Notice $notice) { - $entry = BlogEntry::fromNotice($notice); + $entry = Blog_entry::fromNotice($notice); if (empty($entry)) { - throw new ClientException(sprintf(_('No blog entry for notice %s'), + // TRANS: Exception thrown when requesting a non-existing blog entry for notice. + throw new ClientException(sprintf(_m('No blog entry for notice %s.'), $notice->id)); } @@ -187,11 +168,11 @@ class BlogPlugin extends MicroAppPlugin return new BlogEntryForm($out); } - function deleteRelated($notice) + function deleteRelated(Notice $notice) { - if ($notice->object_type == BlogEntry::TYPE) { - $entry = BlogEntry::fromNotice($notice); - if (exists($entry)) { + if ($notice->object_type == Blog_entry::TYPE) { + $entry = Blog_entry::fromNotice($notice); + if (!empty($entry)) { $entry->delete(); } } @@ -201,10 +182,19 @@ class BlogPlugin extends MicroAppPlugin { $notice = $nli->notice; - if ($notice->object_type == BlogEntry::TYPE) { + if ($notice->object_type == Blog_entry::TYPE) { return new BlogEntryListItem($nli); } - + return null; } + + function onEndShowScripts($action) + { + $action->script(common_path('plugins/TinyMCE/js/jquery.tinymce.js')); + $action->inlineScript('var _tinymce_path = "'.common_path('plugins/TinyMCE/js/tiny_mce.js').'";'."\n". + 'var _tinymce_placeholder = "'.common_path('plugins/TinyMCE/icons/placeholder.png').'";'."\n"); + $action->script($this->path('blog.js')); + return true; + } }