From af956d01dd5110866c3f3725a99accffe23c59ed Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Mon, 5 Dec 2011 09:52:26 +0100 Subject: [PATCH] Add the auto generated wiki page as default page --- src/IDF/Form/Admin/ProjectCreate.php | 42 +----------------------- src/IDF/WikiPage.php | 49 +++++++++++++++++++++++++++- src/IDF/relations.php | 6 ++++ src/IDF/templates/idf/wiki/base.html | 2 +- 4 files changed, 56 insertions(+), 43 deletions(-) diff --git a/src/IDF/Form/Admin/ProjectCreate.php b/src/IDF/Form/Admin/ProjectCreate.php index 2dccf59..ea847f3 100644 --- a/src/IDF/Form/Admin/ProjectCreate.php +++ b/src/IDF/Form/Admin/ProjectCreate.php @@ -339,7 +339,6 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form $conf->setVal($prop, $tmplconf->getVal($prop, $def)); } } - $project->created(); if ($this->cleaned_data['template'] == '--') { IDF_Form_MembersConf::updateMemberships($project, @@ -350,46 +349,7 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form $tmpl->getMembershipData('string')); } $project->membershipsUpdated(); - - - // Insert default wiki page - $tmpl = new Pluf_Template('idf/wiki/wiki-default-page.mdtext'); - $context = new Pluf_Template_Context(array('project' => $project)); - $content = $tmpl->render($context); - $page = new IDF_WikiPage(); - $page->project = $project; - $page->submitter = $this->user; - $page->summary = __('This is the default page for your project Wiki.'); - $page->title = 'summary-default'; - $page->create(); - $rev = new IDF_WikiRevision(); - $rev->wikipage = $page; - $rev->content = $content; - $rev->submitter = $this->user; - $rev->summary = __('Initial page creation'); - $rev->create(); - $rev->notify($project->getConf()); - - // Insert markdown help wiki page - $tmpl = new Pluf_Template('idf/wiki/wiki-markdown-help.mdtext'); - $context = new Pluf_Template_Context(array('project' => $project)); - $content = $tmpl->render($context); - $page = new IDF_WikiPage(); - $page->project = $project; - $page->submitter = $this->user; - $page->summary = __('Help about Markdown syntax.'); - $page->title = 'markdown-help'; - $page->create(); - $rev = new IDF_WikiRevision(); - $rev->wikipage = $page; - $rev->content = $content; - $rev->submitter = $this->user; - $rev->summary = __('Initial page creation'); - $rev->create(); - $rev->notify($project->getConf()); - - // To review : - // $conf->setVal('wiki_default_page', 'summary-default'); + $project->created(); return $project; } diff --git a/src/IDF/WikiPage.php b/src/IDF/WikiPage.php index 23340f0..fa5688b 100644 --- a/src/IDF/WikiPage.php +++ b/src/IDF/WikiPage.php @@ -221,4 +221,51 @@ class IDF_WikiPage extends Pluf_Model $tmpl = new Pluf_Template('idf/wiki/feedfragment.xml'); return $tmpl->render($context); } -} \ No newline at end of file + + function projectCreated($signal, &$params) + { + $project = $params['project']; + $users = $project->getMembershipData(); + $user = $users['owners'][0]; + $conf = $project->getConf(); + + // Insert default wiki page + $tmpl = new Pluf_Template('idf/wiki/wiki-default-page.mdtext'); + $context = new Pluf_Template_Context(array('project' => $project)); + $content = $tmpl->render($context); + $page = new IDF_WikiPage(); + $page->project = $project; + $page->submitter = $user; + $page->summary = __('Default page for your project Wiki.'); + $page->title = 'IndeferoSummaryDefault'; + $page->create(); + $rev = new IDF_WikiRevision(); + $rev->wikipage = $page; + $rev->content = $content; + $rev->submitter = $user; + $rev->summary = __('Initial page creation'); + $rev->create(); + $rev->notify($project->getConf()); + + // Insert markdown help wiki page + $tmpl = new Pluf_Template('idf/wiki/wiki-markdown-help.mdtext'); + $context = new Pluf_Template_Context(array('project' => $project)); + $content = $tmpl->render($context); + $page = new IDF_WikiPage(); + $page->project = $project; + $page->submitter = $user; + $page->summary = __('Help about Markdown syntax.'); + $page->title = 'IndeferoMarkdownHelp'; + $page->create(); + $rev = new IDF_WikiRevision(); + $rev->wikipage = $page; + $rev->content = $content; + $rev->submitter = $user; + $rev->summary = __('Initial page creation'); + $rev->create(); + $rev->notify($project->getConf()); + + $conf->setVal('wiki_default_page', 'IndeferoSummaryDefault'); + $conf->setVal('labels_wiki_predefined', IDF_Form_WikiConf::init_predefined); + } +} diff --git a/src/IDF/relations.php b/src/IDF/relations.php index 38f0ea1..3440afa 100644 --- a/src/IDF/relations.php +++ b/src/IDF/relations.php @@ -115,4 +115,10 @@ Pluf_Signal::connect('queuecron.php::run', Pluf_Signal::connect('IDF_Queue::processItem', Pluf::f('idf_hook_process_item', array('IDF_Webhook', 'process'))); + +# +# Wiki init +Pluf_Signal::connect('IDF_Project::created', + array('IDF_WikiPage', 'projectCreated')); + return $m; diff --git a/src/IDF/templates/idf/wiki/base.html b/src/IDF/templates/idf/wiki/base.html index 7a4fe0f..8294936 100644 --- a/src/IDF/templates/idf/wiki/base.html +++ b/src/IDF/templates/idf/wiki/base.html @@ -2,7 +2,7 @@ {block tabwiki} class="active"{/block} {block subtabs}
-{trans 'List Pages'} +{trans 'List Pages'} {if !$user.isAnonymous()} | {trans 'New Page'} {/if} {if !$user.isAnonymous() and $inView} | {trans 'Update This Page'} {/if} |