Revision history for KlenWell
Revision [23514]
Last edited on 2016-05-20 07:38:48 by KlenWell [Replaces old-style internal links with new pipe-split links.]Additions:
password: [[http://mushpup.org/ | m{ this.domain/KlenWell }]]
wush.net [[http://wush.net/trac/wikka/login | login]]: klenwell / m{ wush.net/that.user }
Since upgrading to version 1.2, I've become more interested in exploring Wikka and developing some extension and features. More information on the development projects I'm working on can be found on [[http://klenwell.com/is/ProjectWikka | my wiki]].
I've redesigned my wiki site using the [[http://docs.wikkawiki.org/WikkaThemes | new theming system]]. The source code for that, and other wikka features I'm working on, can be found at [[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/#wikka/templates/klenwell | my Google code site]].
[[KlenwellAdminOnlyInstaller | Admin-Only Installer]]
[[http://klenwell.com/is/WikkaRecaptchaLoginRegistration | ReCaptcha Registration/Login Action]]
[[http://klenwell.com/is/WikkaRecaptchaCommentForm | ReCaptcha Comment Form]]
[[http://klenwell.com/is/WikkaActivitySummaryAction | Activity Summary Action]]
[[http://klenwell.com/is/WikkaBaseActionClass | Wikka Base Action Class]]
[[http://klenwell.com/is/WikkaSimpleActionClass | Wikka Action as a Class]]
[[http://klenwell.com/is/WikkaActionRedirect | Redirect Action]]
[[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/cli.php | Command Line Interface]] (esp. for cron jobs)
[[http://stackoverflow.com/questions/11752250/ | MySQL 5.5 Incompatible with Install Script]] ([[https://wush.net/trac/wikka/ticket/1049 | Ticket 1049]])
wush.net [[http://wush.net/trac/wikka/login | login]]: klenwell / m{ wush.net/that.user }
Since upgrading to version 1.2, I've become more interested in exploring Wikka and developing some extension and features. More information on the development projects I'm working on can be found on [[http://klenwell.com/is/ProjectWikka | my wiki]].
I've redesigned my wiki site using the [[http://docs.wikkawiki.org/WikkaThemes | new theming system]]. The source code for that, and other wikka features I'm working on, can be found at [[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/#wikka/templates/klenwell | my Google code site]].
[[KlenwellAdminOnlyInstaller | Admin-Only Installer]]
[[http://klenwell.com/is/WikkaRecaptchaLoginRegistration | ReCaptcha Registration/Login Action]]
[[http://klenwell.com/is/WikkaRecaptchaCommentForm | ReCaptcha Comment Form]]
[[http://klenwell.com/is/WikkaActivitySummaryAction | Activity Summary Action]]
[[http://klenwell.com/is/WikkaBaseActionClass | Wikka Base Action Class]]
[[http://klenwell.com/is/WikkaSimpleActionClass | Wikka Action as a Class]]
[[http://klenwell.com/is/WikkaActionRedirect | Redirect Action]]
[[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/cli.php | Command Line Interface]] (esp. for cron jobs)
[[http://stackoverflow.com/questions/11752250/ | MySQL 5.5 Incompatible with Install Script]] ([[https://wush.net/trac/wikka/ticket/1049 | Ticket 1049]])
Deletions:
wush.net [[http://wush.net/trac/wikka/login login]]: klenwell / m{ wush.net/that.user }
Since upgrading to version 1.2, I've become more interested in exploring Wikka and developing some extension and features. More information on the development projects I'm working on can be found on [[http://klenwell.com/is/ProjectWikka my wiki]].
I've redesigned my wiki site using the [[http://docs.wikkawiki.org/WikkaThemes new theming system]]. The source code for that, and other wikka features I'm working on, can be found at [[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/#wikka/templates/klenwell my Google code site]].
[[KlenwellAdminOnlyInstaller Admin-Only Installer]]
[[http://klenwell.com/is/WikkaRecaptchaLoginRegistration ReCaptcha Registration/Login Action]]
[[http://klenwell.com/is/WikkaRecaptchaCommentForm ReCaptcha Comment Form]]
[[http://klenwell.com/is/WikkaActivitySummaryAction Activity Summary Action]]
[[http://klenwell.com/is/WikkaBaseActionClass Wikka Base Action Class]]
[[http://klenwell.com/is/WikkaSimpleActionClass Wikka Action as a Class]]
[[http://klenwell.com/is/WikkaActionRedirect Redirect Action]]
[[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/cli.php Command Line Interface]] (esp. for cron jobs)
[[http://stackoverflow.com/questions/11752250/ MySQL 5.5 Incompatible with Install Script]] ([[https://wush.net/trac/wikka/ticket/1049 Ticket 1049]])
Revision [21730]
Edited on 2012-08-01 09:29:32 by KlenWell [Replaces old-style internal links with new pipe-split links.]Additions:
[[http://stackoverflow.com/questions/11752250/ MySQL 5.5 Incompatible with Install Script]] ([[https://wush.net/trac/wikka/ticket/1049 Ticket 1049]])
Deletions:
Revision [21729]
Edited on 2012-07-31 22:51:54 by KlenWell [bug report: MySQL 5.5 Incompatible with Installer]Additions:
===Bug Reports===
[[http://stackoverflow.com/questions/11752250/ MySQL 5.5 Incompatible with Install Script]]
[[http://stackoverflow.com/questions/11752250/ MySQL 5.5 Incompatible with Install Script]]
Revision [21669]
Edited on 2012-01-23 00:45:14 by KlenWell [bug report: MySQL 5.5 Incompatible with Installer]Additions:
password: [[http://mushpup.org/ m{ this.domain/KlenWell }]]
wush.net [[http://wush.net/trac/wikka/login login]]: klenwell / m{ wush.net/that.user }
wush.net [[http://wush.net/trac/wikka/login login]]: klenwell / m{ wush.net/that.user }
Deletions:
wush.net [[http://wush.net/trac/wikka/login login]]: klenwell / m{wush.net/that.user}
Revision [21668]
Edited on 2012-01-23 00:44:18 by KlenWell [bug report: MySQL 5.5 Incompatible with Installer]Deletions:
Revision [21662]
Edited on 2012-01-17 21:24:10 by KlenWell [bug report: MySQL 5.5 Incompatible with Installer]Additions:
[[KlenwellAdminOnlyInstaller Admin-Only Installer]]
Deletions:
(I can't seem to post this anywhere else):
Is it possible to restrict the installer pages to an admin? I upgraded to 1.3.2 just now. I had completed the install on a local dev version and planned to just upload that. But I found I needed to run the installer on my production site, too, to make the database updates. I noticed that while it was running, the install/upgrade pages were accessible to non-logged-in guests. This seems like a potential security vulnerability as it may display the config file.
Next time, I upgrade, I'll look into adding this restriction myself if it doesn't already exist.
Additions:
===Note on Installer===
(I can't seem to post this anywhere else):
Is it possible to restrict the installer pages to an admin? I upgraded to 1.3.2 just now. I had completed the install on a local dev version and planned to just upload that. But I found I needed to run the installer on my production site, too, to make the database updates. I noticed that while it was running, the install/upgrade pages were accessible to non-logged-in guests. This seems like a potential security vulnerability as it may display the config file.
Next time, I upgrade, I'll look into adding this restriction myself if it doesn't already exist.
(I can't seem to post this anywhere else):
Is it possible to restrict the installer pages to an admin? I upgraded to 1.3.2 just now. I had completed the install on a local dev version and planned to just upload that. But I found I needed to run the installer on my production site, too, to make the database updates. I noticed that while it was running, the install/upgrade pages were accessible to non-logged-in guests. This seems like a potential security vulnerability as it may display the config file.
Next time, I upgrade, I'll look into adding this restriction myself if it doesn't already exist.
Additions:
[[http://klenwell.com/is/WikkaBaseActionClass Wikka Base Action Class]]
Additions:
----
CodeContributions
CodeContributions
Deletions:
ReCaptcha-protected Comment and Login Forms
Additions:
[[http://klenwell.com/is/WikkaRecaptchaLoginRegistration ReCaptcha Registration/Login Action]]
Additions:
[[http://klenwell.com/is/WikkaRecaptchaCommentForm ReCaptcha Comment Form]]
Additions:
[[http://klenwell.com/is/WikkaActivitySummaryAction Activity Summary Action]]
Deletions:
Gmail Integration
Additions:
[[http://klenwell.com/is/WikkaSimpleActionClass Wikka Action as a Class]]
Additions:
===Additions and Enhancements===
[[http://klenwell.com/is/WikkaActionRedirect Redirect Action]]
[[http://klenwell.com/is/WikkaActionRedirect Redirect Action]]
Additions:
[[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/cli.php Command Line Interface]] (esp. for cron jobs)
Deletions:
Additions:
my wikka site: http://klenwell.com/is/
blog: http://klenwell.com/press/
===Wikka Development===
Since upgrading to version 1.2, I've become more interested in exploring Wikka and developing some extension and features. More information on the development projects I'm working on can be found on [[http://klenwell.com/is/ProjectWikka my wiki]].
I've redesigned my wiki site using the [[http://docs.wikkawiki.org/WikkaThemes new theming system]]. The source code for that, and other wikka features I'm working on, can be found at [[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/#wikka/templates/klenwell my Google code site]].
The wish list below includes a sampling of features I'd like to find or develop for the Wikka package. The [[http://klenwell.com/is/ProjectWikka updated list]] is available at my site.
===Wikka Wish List===
Command Line Interface (esp. for cron jobs)
Daily Report Scripts (run as cron jobs with CLI)
Gmail Integration
ReCaptcha-protected Comment and Login Forms
blog: http://klenwell.com/press/
===Wikka Development===
Since upgrading to version 1.2, I've become more interested in exploring Wikka and developing some extension and features. More information on the development projects I'm working on can be found on [[http://klenwell.com/is/ProjectWikka my wiki]].
I've redesigned my wiki site using the [[http://docs.wikkawiki.org/WikkaThemes new theming system]]. The source code for that, and other wikka features I'm working on, can be found at [[http://code.google.com/p/klenwell/source/browse/trunk/projects/php/wikka/#wikka/templates/klenwell my Google code site]].
The wish list below includes a sampling of features I'd like to find or develop for the Wikka package. The [[http://klenwell.com/is/ProjectWikka updated list]] is available at my site.
===Wikka Wish List===
Command Line Interface (esp. for cron jobs)
Daily Report Scripts (run as cron jobs with CLI)
Gmail Integration
ReCaptcha-protected Comment and Login Forms
Deletions:
blog: http://phosphorusandlime.blogspot.com/
===Code Contributions===
[[http://www.klenwell.net/is/WikkaSkinCustomization Wikka 3-Column Layout Customization]]
[[http://www.klenwell.net/is/WikkaChangeNotifier Wikka Recent Changes Notifier]]
""<a id="handler_source"></a>""
===Proposed Page Handler Revision===
A good first step in intelligently refactoring the page handler code would be identifying the discrete html elements that make up the html it outputs. I've created the following page to list out the html elements and controller events that output core wikka page:
HandlerShowSchema
The page-rendering code (''handlers/page/show.php'') for wikka, at the moment, is a bit disorganized. I notice there are some references to a new templating model in [[http://wush.net/trac/wikka/browser/trunk/handlers/show/show.php the latest release]] and notice the improvement being made. But I think this part of the code could benefit by following a more organized controller logic. Find my proposed revision of ''handlers/page/show.php'' below:
**Its advantages**
- eliminates confusing mixture of logic and presentation layers
- preserves all elements of the current source code
- offers a controller for more cleanly determining which elements of the page get displayed
- distinctly identifies each element of the resulting layout
- provides a simple prototype for a templating model
- makes it easier to change major layout elements for web designers
- my tests of it thus far have been successful
Note: this was submitted to Wikkawiki dev site as [[http://wush.net/trac/wikka/ticket/532 Ticket #532]]
**Code Source**
[[KlenwellCodeHandlerShow564 show.20070712.php]] (based on [[http://wush.net/trac/wikka/changeset/564 revision #564]])
[[KlenwellCodeHandlerShow637 show.20070805.php]] (based on [[http://wush.net/trac/wikka/changeset/637 revision #637]])
No Differences
Additions:
A good first step in intelligently refactoring the page handler code would be identifying the discrete html elements that make up the html it outputs. I've created the following page to list out the html elements and controller events that output core wikka page:
HandlerShowSchema
HandlerShowSchema
Additions:
[[KlenwellCodeHandlerShow564 show.20070712.php]] (based on [[http://wush.net/trac/wikka/changeset/564 revision #564]])
[[KlenwellCodeHandlerShow637 show.20070805.php]] (based on [[http://wush.net/trac/wikka/changeset/637 revision #637]])
[[KlenwellCodeHandlerShow637 show.20070805.php]] (based on [[http://wush.net/trac/wikka/changeset/637 revision #637]])
Deletions:
Additions:
[[KlenwellCodeHandlerShow564 show.20070712.php]] (based on [[http://wush.net/trac/wikka/browser/trunk/handlers/show/show.php?rev=564 revision #564]])
Deletions:
Additions:
**Code Source**
[[KlenwellCodeShow564 show.20070712.php]] (based on [[http://wush.net/trac/wikka/browser/trunk/handlers/show/show.php?rev=564 revision #564]])
[[KlenwellCodeShow564 show.20070712.php]] (based on [[http://wush.net/trac/wikka/browser/trunk/handlers/show/show.php?rev=564 revision #564]])
Deletions:
%%(php)
<?php
/**
* Display a page if the user has read access or is an admin.
*
* This is the default page handler used by Wikka when no other handler is specified.
* Depending on user privileges, it displays the page body or an error message. It also
* displays footer comments and a form to post comments, depending on ACL and general
* config settings.
*
* @package Handlers
* @subpackage Page
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @filesource
*
* @uses Wakka::Format()
* @uses Wakka::FormClose()
* @uses Wakka::FormOpen()
* @uses Wakka::GetConfigValue()
* @uses Wakka::GetPageTag()
* @uses Wakka::GetUser()
* @uses Wakka::GetUserName()
* @uses Wakka::HasAccess()
* @uses Wakka::Href()
* @uses Wakka::htmlspecialchars_ent()
* @uses Wakka::LoadComments()
* @uses Wakka::LoadPage()
* @uses Wakka::LoadUser()
* @uses Wakka::UserIsOwner()
* @uses Config::$anony_delete_own_comments
* @uses Config::$hide_comments
*
* @todo move <div> to template;
* @todo replace $_REQUEST with either $_GET or $_POST (or both if really
* necessary) - #312
*/
// *** Show Flags for Controller
$_SHOW['page_start'] = 0;
$_SHOW['no_access'] = 0;
$_SHOW['not_exists'] = 0;
$_SHOW['page_body'] = 0;
$_SHOW['revision_info'] = 0;
$_SHOW['revision_edit_form'] = 0;
$_SHOW['comments'] = 0;
$_SHOW['hidden_comments'] = 0;
$_SHOW['no_comments'] = 0;
$_SHOW['comment_form'] = 0;
$_SHOW['page_close'] = 0;
// *** HTML Blocks
$_HTML['page'] = '';
$_HTML['page_start'] = '';
$_HTML['no_access'] = '';
$_HTML['not_exists'] = '';
$_HTML['revision_info'] = '';
$_HTML['page_body'] = '';
$_HTML['revision_edit_form'] = '';
$_HTML['page_close_div'] = '';
$_HTML['comments_header'] = '';
$_HTML['comments'] = '';
$_HTML['comment_form'] = '';
$_HTML['hidden_comments'] = '';
$_HTML['page_close'] = '';
// *** Controller
// Default Shows
$_SHOW['page_start'] = 1;
$_SHOW['page_close'] = 1;
// Has Page Access
if (!$this->HasAccess('read'))
{
$_SHOW['no_access'] = 1;
}
// Page Exists
if ( !$this->page )
{
$_SHOW['not_exists'] = 1;
}
else
{
$_SHOW['page_body'] = 1;
}
// As Revision
if ($this->page['latest'] == 'N')
{
$_SHOW['revision_info'] = 1;
}
// Revision w/ write access
if ( ($this->page['latest'] == 'N' && $this->HasAccess('write')) && ($latest = $this->LoadPage($this->tag)) )
{
$_SHOW['revision_edit_form'] = 1;
}
// Show Comment Form
if ( $this->GetConfigValue('hide_comments') != 1 )
{
// get page tag
$tag = $this->GetPageTag();
// session settings?
if ( !isset($_SESSION['show_comments'][$tag]) )
{
$_SESSION['show_comments'][$tag] = ($this->UserWantsComments() ? '1' : '0');
}
// GET setting takes precedence
if ( isset($_GET['show_comments']) ) #312
{
if ( $_GET['show_comments'] == 0 )
{
$_SESSION['show_comments'][$tag] = 0;
}
elseif ( $_GET['show_comments'] == 1 )
{
$_SESSION['show_comments'][$tag] = 1;
}
}
if ($_SESSION['show_comments'][$tag])
{
$_SHOW['comment_form'] = 1;
}
else
{
$_SHOW['hidden_comments'] = 1;
}
}
// Show Comments?
$comments = $this->LoadComments($this->tag);
if ( $_SESSION['show_comments'][$tag] && $comments )
{
$_SHOW['comments'] = 1;
}
// *** Viewer Blocks
// Page Start
if ( $_SHOW['page_start'] )
{
$_js = ( ($user = $this->GetUser()) && ($user['doubleclickedit'] == 'N') || !$this->HasAccess('write') ) ? '' : 'ondblclick="document.location=\''.$this->Href('edit').'\';" ';
$_HTML['page_start'] = <<<HTML
<!--starting page content-->
<div class="page" {$_js }>
HTML;
}
// Generic
if ( $_SHOW['no_access'] )
{
$_HTML['no_access'] = <<<HTML
<p><em class="error">You aren't allowed to read this page.</em></p>
</div>
HTML;
}
// Page does not exist yet
if ( $_SHOW['not_exists'] )
{
$_HTML['not_exists'] = <<<HTML
<p>This page doesn't exist yet. Maybe you want to <a href="{$this->Href('edit')}">create</a> it?</p>
</div>
HTML;
}
// Revision Info
if ( $_SHOW['revision_info'] )
{
$href = $this->Href();
$alabel = $this->GetPageTag();
$ptime = $this->page['time'];
$_HTML['revision_info'] = <<<HTML
<div class="revisioninfo">
This is an old revision of <a href="{$href}">{$alabel}</a> from {$ptime}
</div>
HTML;
}
// Page Body
if ( $_SHOW['page_body'] )
{
$_HTML['page_body'] = $this->Format($this->page['body'], 'wakka');
$_HTML['page_close_div'] = "</div>\n";
}
// Revision Edit Form
if ( $_SHOW['revision_edit_form'] )
{
$form_start = $this->FormOpen('edit');
$lid = $latest['id'];
$hvalue = $this->htmlspecialchars_ent($this->page['body']);
$form_close = $this->FormClose();
$_HTML['revision_edit_form'] = <<<HTML
<br />
$form_start
<input type="hidden" name="previous" value="$lid" />
<input type="hidden" name="body" value="$hvalue" />
<input type="submit" value="Re-edit this old revision" />
$form_close
HTML;
}
// Comments Header and Form
if ( $_SHOW['comment_form'] )
{
$href = $this->Href('', '', 'show_comments=0');
$_HTML['comments_header'] = <<<HTML
<div class="commentsheader">
<span id="comments"> </span>Comments [<a href="$href">Hide comments/form</a>]
</div>
HTML;
$form_start = $this->FormOpen('addcomment');
$form_close = $this->FormClose();
$_HTML['comment_form'] = <<<HTML
<div class="commentform">
$form_start
<label for="commentbox">Add a comment to this page:<br />
<textarea id="commentbox" name="body" rows="6" cols="78"></textarea><br />
<input type="submit" value="Add Comment" accesskey="s" />
</label>
$form_close
</div>
HTML;
}
// comments themselves
if ( $_SHOW['comments'] )
{
$current_user = $this->GetUserName();
$comment_stack = '';
foreach ($comments as $comment)
{
$comment_stack .= '<div class="comment">'."\n";
$comment_stack .= '<span id="comment_'.$comment['id'].'"></span>'.$comment['comment']."\n";
$comment_stack .= "\t".'<div class="commentinfo">'."\n-- ";
$comment_stack .= ( $this->LoadUser($comment['user']) ) ? $this->Format($comment['user']) : $comment['user'];
$comment_stack .= ' ('.$comment['time'].')'."\n";
// does comment get delete form?
if ($this->UserIsOwner() || $current_user == $comment['user'] || ($this->config['anony_delete_own_comments'] && $current_user == $comment['user']) )
{
$comment_stack .= $this->FormOpen("delcomment");
$comment_stack .= '<input type="hidden" name="comment_id" value="' . $comment['id'] . '" />';
$comment_stack .= '<input type="submit" value="Delete Comment" />';
$comment_stack .= $this->FormClose();
}
$comment_stack .= "\n\t".'</div>'."\n";
$comment_stack .= '</div>'."\n";
}
$_HTML['comments'] = $comment_stack;
}
// hidden comments
if ( $_SHOW['hidden_comments'] )
{
switch (count($comments))
{
case 0:
$comment_count = '<p>There are no comments on this page. ';
$showcomments_text = 'Add comment';
break;
case 1:
$comment_count = '<p>There is one comment on this page. ';
$showcomments_text = 'Display comment';
break;
default:
$comment_count = '<p>There are '.count($comments).' comments on this page. ';
$showcomments_text = 'Display comments';
}
$href = $this->Href('', '', 'show_comments=1#comments');
$_HTML['hidden_comments'] = <<<HTML
<div class="commentsheader">
$comment_count
[<a href="$href">$showcomments_text</a>]</p>
</div>
HTML;
}
// Page Close
if ( $_SHOW['page_close'] )
{
$_HTML['page_close'] = <<<HTML
</div>
<!--closing page content-->
HTML;
}
// End Viewer Blocks
// *** TEMPLATE: stitch it all together
$_HTML['page'] = <<<HTML
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
{$_HTML['page_close_div']}
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
{$_HTML['page_close']}
HTML;
echo $_HTML['page'];
?>
%%
Additions:
The page-rendering code (''handlers/page/show.php'') for wikka, at the moment, is a bit disorganized. I notice there are some references to a new templating model in [[http://wush.net/trac/wikka/browser/trunk/handlers/show/show.php the latest release]] and notice the improvement being made. But I think this part of the code could benefit by following a more organized controller logic. Find my proposed revision of ''handlers/page/show.php'' below:
**Its advantages**
**Its advantages**
Deletions:
**It's advantages**
Additions:
""<a id="handler_source"></a>""
Additions:
- eliminates confusing mixture of logic and presentation layers
Deletions:
Additions:
<p><em class="error">You aren't allowed to read this page.</em></p>
Deletions:
No Differences
Additions:
Note: this was submitted to Wikkawiki dev site as [[http://wush.net/trac/wikka/ticket/532 Ticket #532]]
Additions:
===Proposed Page Handler Revision===
Deletions:
Additions:
The page-rendering code (''handlers/page/show.php'') for wikka, at the moment, is pretty sloppy. I notice there are some references to a new templating model in [[http://wush.net/trac/wikka/browser/trunk/handlers/show/show.php the latest release]] and notice the improvement being made. But I think this part of the code could benefit by following a more organized controller logic. Find my proposed revision of ''handlers/page/show.php'' below:
Deletions:
Additions:
password: [[http://mushpup.org/ m{this.domain/KlenWell}]]
wush.net [[http://wush.net/trac/wikka/login login]]: klenwell / m{wush.net/that.user}
wush.net [[http://wush.net/trac/wikka/login login]]: klenwell / m{wush.net/that.user}
Deletions:
Additions:
===New Page Template===
The page-rendering code (''handlers/page/show.php'') for wikka, at the moment, is pretty sloppy. I notice there are some references to a new templating model in the latest release and I admit that I have not investigated it yet. But I did rewrite the code to follow more of a MVC pattern. Find below the actual rewritten file for ''handlers/page/show.php''.
**It's advantages**
- eliminates sloppy mixture of rendering logic and output
- preserves all elements of the current source code
- offers a controller for more cleanly determining which elements of the page get displayed
- distinctly identifies each element of the resulting layout
- provides a simple prototype for a templating model
- makes it easier to change major layout elements for web designers
- my tests of it thus far have been successful
**The Source**
%%(php)
<?php
/**
* Display a page if the user has read access or is an admin.
*
* This is the default page handler used by Wikka when no other handler is specified.
* Depending on user privileges, it displays the page body or an error message. It also
* displays footer comments and a form to post comments, depending on ACL and general
* config settings.
*
* @package Handlers
* @subpackage Page
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @filesource
*
* @uses Wakka::Format()
* @uses Wakka::FormClose()
* @uses Wakka::FormOpen()
* @uses Wakka::GetConfigValue()
* @uses Wakka::GetPageTag()
* @uses Wakka::GetUser()
* @uses Wakka::GetUserName()
* @uses Wakka::HasAccess()
* @uses Wakka::Href()
* @uses Wakka::htmlspecialchars_ent()
* @uses Wakka::LoadComments()
* @uses Wakka::LoadPage()
* @uses Wakka::LoadUser()
* @uses Wakka::UserIsOwner()
* @uses Config::$anony_delete_own_comments
* @uses Config::$hide_comments
*
* @todo move <div> to template;
* @todo replace $_REQUEST with either $_GET or $_POST (or both if really
* necessary) - #312
*/
// *** Show Flags for Controller
$_SHOW['page_start'] = 0;
$_SHOW['no_access'] = 0;
$_SHOW['not_exists'] = 0;
$_SHOW['page_body'] = 0;
$_SHOW['revision_info'] = 0;
$_SHOW['revision_edit_form'] = 0;
$_SHOW['comments'] = 0;
$_SHOW['hidden_comments'] = 0;
$_SHOW['no_comments'] = 0;
$_SHOW['comment_form'] = 0;
$_SHOW['page_close'] = 0;
// *** HTML Blocks
$_HTML['page'] = '';
$_HTML['page_start'] = '';
$_HTML['no_access'] = '';
$_HTML['not_exists'] = '';
$_HTML['revision_info'] = '';
$_HTML['page_body'] = '';
$_HTML['revision_edit_form'] = '';
$_HTML['page_close_div'] = '';
$_HTML['comments_header'] = '';
$_HTML['comments'] = '';
$_HTML['comment_form'] = '';
$_HTML['hidden_comments'] = '';
$_HTML['page_close'] = '';
// *** Controller
// Default Shows
$_SHOW['page_start'] = 1;
$_SHOW['page_close'] = 1;
// Has Page Access
if (!$this->HasAccess('read'))
{
$_SHOW['no_access'] = 1;
}
// Page Exists
if ( !$this->page )
{
$_SHOW['not_exists'] = 1;
}
else
{
$_SHOW['page_body'] = 1;
}
// As Revision
if ($this->page['latest'] == 'N')
{
$_SHOW['revision_info'] = 1;
}
// Revision w/ write access
if ( ($this->page['latest'] == 'N' && $this->HasAccess('write')) && ($latest = $this->LoadPage($this->tag)) )
{
$_SHOW['revision_edit_form'] = 1;
}
// Show Comment Form
if ( $this->GetConfigValue('hide_comments') != 1 )
{
// get page tag
$tag = $this->GetPageTag();
// session settings?
if ( !isset($_SESSION['show_comments'][$tag]) )
{
$_SESSION['show_comments'][$tag] = ($this->UserWantsComments() ? '1' : '0');
}
// GET setting takes precedence
if ( isset($_GET['show_comments']) ) #312
{
if ( $_GET['show_comments'] == 0 )
{
$_SESSION['show_comments'][$tag] = 0;
}
elseif ( $_GET['show_comments'] == 1 )
{
$_SESSION['show_comments'][$tag] = 1;
}
}
if ($_SESSION['show_comments'][$tag])
{
$_SHOW['comment_form'] = 1;
}
else
{
$_SHOW['hidden_comments'] = 1;
}
}
// Show Comments?
$comments = $this->LoadComments($this->tag);
if ( $_SESSION['show_comments'][$tag] && $comments )
{
$_SHOW['comments'] = 1;
}
// *** Viewer Blocks
// Page Start
if ( $_SHOW['page_start'] )
{
$_js = ( ($user = $this->GetUser()) && ($user['doubleclickedit'] == 'N') || !$this->HasAccess('write') ) ? '' : 'ondblclick="document.location=\''.$this->Href('edit').'\';" ';
$_HTML['page_start'] = <<<HTML
<!--starting page content-->
<div class="page" {$_js }>
HTML;
// Generic
if ( $_SHOW['no_access'] )
{
$_HTML['no_access'] = <<<HTML
<p><em class="error">You aren\'t allowed to read this page.</em></p>
</div>
HTML;
}
// Page does not exist yet
if ( $_SHOW['not_exists'] )
{
$_HTML['not_exists'] = <<<HTML
<p>This page doesn't exist yet. Maybe you want to <a href="{$this->Href('edit')}">create</a> it?</p>
</div>
HTML;
}
// Revision Info
if ( $_SHOW['revision_info'] )
{
$href = $this->Href();
$alabel = $this->GetPageTag();
$ptime = $this->page['time'];
$_HTML['revision_info'] = <<<HTML
<div class="revisioninfo">
This is an old revision of <a href="{$href}">{$alabel}</a> from {$ptime}
</div>
HTML;
}
// Page Body
if ( $_SHOW['page_body'] )
{
$_HTML['page_body'] = $this->Format($this->page['body'], 'wakka');
$_HTML['page_close_div'] = "</div>\n";
}
// Revision Edit Form
if ( $_SHOW['revision_edit_form'] )
{
$form_start = $this->FormOpen('edit');
$lid = $latest['id'];
$hvalue = $this->htmlspecialchars_ent($this->page['body']);
$form_close = $this->FormClose();
$_HTML['revision_edit_form'] = <<<HTML
<br />
$form_start
<input type="hidden" name="previous" value="$lid" />
<input type="hidden" name="body" value="$hvalue" />
<input type="submit" value="Re-edit this old revision" />
$form_close
HTML;
}
// Comments Header and Form
if ( $_SHOW['comment_form'] )
{
$href = $this->Href('', '', 'show_comments=0');
$_HTML['comments_header'] = <<<HTML
<div class="commentsheader">
<span id="comments"> </span>Comments [<a href="$href">Hide comments/form</a>]
</div>
HTML;
$form_start = $this->FormOpen('addcomment');
$form_close = $this->FormClose();
$_HTML['comment_form'] = <<<HTML
<div class="commentform">
$form_start
<label for="commentbox">Add a comment to this page:<br />
<textarea id="commentbox" name="body" rows="6" cols="78"></textarea><br />
<input type="submit" value="Add Comment" accesskey="s" />
</label>
$form_close
</div>
HTML;
}
// comments themselves
if ( $_SHOW['comments'] )
{
$current_user = $this->GetUserName();
$comment_stack = '';
foreach ($comments as $comment)
{
$comment_stack .= '<div class="comment">'."\n";
$comment_stack .= '<span id="comment_'.$comment['id'].'"></span>'.$comment['comment']."\n";
$comment_stack .= "\t".'<div class="commentinfo">'."\n-- ";
$comment_stack .= ( $this->LoadUser($comment['user']) ) ? $this->Format($comment['user']) : $comment['user'];
$comment_stack .= ' ('.$comment['time'].')'."\n";
// does comment get delete form?
if ($this->UserIsOwner() || $current_user == $comment['user'] || ($this->config['anony_delete_own_comments'] && $current_user == $comment['user']) )
{
$comment_stack .= $this->FormOpen("delcomment");
$comment_stack .= '<input type="hidden" name="comment_id" value="' . $comment['id'] . '" />';
$comment_stack .= '<input type="submit" value="Delete Comment" />';
$comment_stack .= $this->FormClose();
}
$comment_stack .= "\n\t".'</div>'."\n";
$comment_stack .= '</div>'."\n";
}
$_HTML['comments'] = $comment_stack;
}
// hidden comments
if ( $_SHOW['hidden_comments'] )
{
switch (count($comments))
{
case 0:
$comment_count = '<p>There are no comments on this page. ';
$showcomments_text = 'Add comment';
break;
case 1:
$comment_count = '<p>There is one comment on this page. ';
$showcomments_text = 'Display comment';
break;
default:
$comment_count = '<p>There are '.count($comments).' comments on this page. ';
$showcomments_text = 'Display comments';
}
$href = $this->Href('', '', 'show_comments=1#comments');
$_HTML['hidden_comments'] = <<<HTML
<div class="commentsheader">
$comment_count
[<a href="$href">$showcomments_text</a>]</p>
</div>
HTML;
}
// Page Close
if ( $_SHOW['page_close'] )
{
$_HTML['page_close'] = <<<HTML
</div>
<!--closing page content-->
HTML;
}
}
// End Viewer Blocks
// *** TEMPLATE: stitch it all together
$_HTML['page'] = <<<HTML
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
{$_HTML['page_close_div']}
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
{$_HTML['page_close']}
HTML;
echo $_HTML['page'];
?>
%%
The page-rendering code (''handlers/page/show.php'') for wikka, at the moment, is pretty sloppy. I notice there are some references to a new templating model in the latest release and I admit that I have not investigated it yet. But I did rewrite the code to follow more of a MVC pattern. Find below the actual rewritten file for ''handlers/page/show.php''.
**It's advantages**
- eliminates sloppy mixture of rendering logic and output
- preserves all elements of the current source code
- offers a controller for more cleanly determining which elements of the page get displayed
- distinctly identifies each element of the resulting layout
- provides a simple prototype for a templating model
- makes it easier to change major layout elements for web designers
- my tests of it thus far have been successful
**The Source**
%%(php)
<?php
/**
* Display a page if the user has read access or is an admin.
*
* This is the default page handler used by Wikka when no other handler is specified.
* Depending on user privileges, it displays the page body or an error message. It also
* displays footer comments and a form to post comments, depending on ACL and general
* config settings.
*
* @package Handlers
* @subpackage Page
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @filesource
*
* @uses Wakka::Format()
* @uses Wakka::FormClose()
* @uses Wakka::FormOpen()
* @uses Wakka::GetConfigValue()
* @uses Wakka::GetPageTag()
* @uses Wakka::GetUser()
* @uses Wakka::GetUserName()
* @uses Wakka::HasAccess()
* @uses Wakka::Href()
* @uses Wakka::htmlspecialchars_ent()
* @uses Wakka::LoadComments()
* @uses Wakka::LoadPage()
* @uses Wakka::LoadUser()
* @uses Wakka::UserIsOwner()
* @uses Config::$anony_delete_own_comments
* @uses Config::$hide_comments
*
* @todo move <div> to template;
* @todo replace $_REQUEST with either $_GET or $_POST (or both if really
* necessary) - #312
*/
// *** Show Flags for Controller
$_SHOW['page_start'] = 0;
$_SHOW['no_access'] = 0;
$_SHOW['not_exists'] = 0;
$_SHOW['page_body'] = 0;
$_SHOW['revision_info'] = 0;
$_SHOW['revision_edit_form'] = 0;
$_SHOW['comments'] = 0;
$_SHOW['hidden_comments'] = 0;
$_SHOW['no_comments'] = 0;
$_SHOW['comment_form'] = 0;
$_SHOW['page_close'] = 0;
// *** HTML Blocks
$_HTML['page'] = '';
$_HTML['page_start'] = '';
$_HTML['no_access'] = '';
$_HTML['not_exists'] = '';
$_HTML['revision_info'] = '';
$_HTML['page_body'] = '';
$_HTML['revision_edit_form'] = '';
$_HTML['page_close_div'] = '';
$_HTML['comments_header'] = '';
$_HTML['comments'] = '';
$_HTML['comment_form'] = '';
$_HTML['hidden_comments'] = '';
$_HTML['page_close'] = '';
// *** Controller
// Default Shows
$_SHOW['page_start'] = 1;
$_SHOW['page_close'] = 1;
// Has Page Access
if (!$this->HasAccess('read'))
{
$_SHOW['no_access'] = 1;
}
// Page Exists
if ( !$this->page )
{
$_SHOW['not_exists'] = 1;
}
else
{
$_SHOW['page_body'] = 1;
}
// As Revision
if ($this->page['latest'] == 'N')
{
$_SHOW['revision_info'] = 1;
}
// Revision w/ write access
if ( ($this->page['latest'] == 'N' && $this->HasAccess('write')) && ($latest = $this->LoadPage($this->tag)) )
{
$_SHOW['revision_edit_form'] = 1;
}
// Show Comment Form
if ( $this->GetConfigValue('hide_comments') != 1 )
{
// get page tag
$tag = $this->GetPageTag();
// session settings?
if ( !isset($_SESSION['show_comments'][$tag]) )
{
$_SESSION['show_comments'][$tag] = ($this->UserWantsComments() ? '1' : '0');
}
// GET setting takes precedence
if ( isset($_GET['show_comments']) ) #312
{
if ( $_GET['show_comments'] == 0 )
{
$_SESSION['show_comments'][$tag] = 0;
}
elseif ( $_GET['show_comments'] == 1 )
{
$_SESSION['show_comments'][$tag] = 1;
}
}
if ($_SESSION['show_comments'][$tag])
{
$_SHOW['comment_form'] = 1;
}
else
{
$_SHOW['hidden_comments'] = 1;
}
}
// Show Comments?
$comments = $this->LoadComments($this->tag);
if ( $_SESSION['show_comments'][$tag] && $comments )
{
$_SHOW['comments'] = 1;
}
// *** Viewer Blocks
// Page Start
if ( $_SHOW['page_start'] )
{
$_js = ( ($user = $this->GetUser()) && ($user['doubleclickedit'] == 'N') || !$this->HasAccess('write') ) ? '' : 'ondblclick="document.location=\''.$this->Href('edit').'\';" ';
$_HTML['page_start'] = <<<HTML
<!--starting page content-->
<div class="page" {$_js }>
HTML;
// Generic
if ( $_SHOW['no_access'] )
{
$_HTML['no_access'] = <<<HTML
<p><em class="error">You aren\'t allowed to read this page.</em></p>
</div>
HTML;
}
// Page does not exist yet
if ( $_SHOW['not_exists'] )
{
$_HTML['not_exists'] = <<<HTML
<p>This page doesn't exist yet. Maybe you want to <a href="{$this->Href('edit')}">create</a> it?</p>
</div>
HTML;
}
// Revision Info
if ( $_SHOW['revision_info'] )
{
$href = $this->Href();
$alabel = $this->GetPageTag();
$ptime = $this->page['time'];
$_HTML['revision_info'] = <<<HTML
<div class="revisioninfo">
This is an old revision of <a href="{$href}">{$alabel}</a> from {$ptime}
</div>
HTML;
}
// Page Body
if ( $_SHOW['page_body'] )
{
$_HTML['page_body'] = $this->Format($this->page['body'], 'wakka');
$_HTML['page_close_div'] = "</div>\n";
}
// Revision Edit Form
if ( $_SHOW['revision_edit_form'] )
{
$form_start = $this->FormOpen('edit');
$lid = $latest['id'];
$hvalue = $this->htmlspecialchars_ent($this->page['body']);
$form_close = $this->FormClose();
$_HTML['revision_edit_form'] = <<<HTML
<br />
$form_start
<input type="hidden" name="previous" value="$lid" />
<input type="hidden" name="body" value="$hvalue" />
<input type="submit" value="Re-edit this old revision" />
$form_close
HTML;
}
// Comments Header and Form
if ( $_SHOW['comment_form'] )
{
$href = $this->Href('', '', 'show_comments=0');
$_HTML['comments_header'] = <<<HTML
<div class="commentsheader">
<span id="comments"> </span>Comments [<a href="$href">Hide comments/form</a>]
</div>
HTML;
$form_start = $this->FormOpen('addcomment');
$form_close = $this->FormClose();
$_HTML['comment_form'] = <<<HTML
<div class="commentform">
$form_start
<label for="commentbox">Add a comment to this page:<br />
<textarea id="commentbox" name="body" rows="6" cols="78"></textarea><br />
<input type="submit" value="Add Comment" accesskey="s" />
</label>
$form_close
</div>
HTML;
}
// comments themselves
if ( $_SHOW['comments'] )
{
$current_user = $this->GetUserName();
$comment_stack = '';
foreach ($comments as $comment)
{
$comment_stack .= '<div class="comment">'."\n";
$comment_stack .= '<span id="comment_'.$comment['id'].'"></span>'.$comment['comment']."\n";
$comment_stack .= "\t".'<div class="commentinfo">'."\n-- ";
$comment_stack .= ( $this->LoadUser($comment['user']) ) ? $this->Format($comment['user']) : $comment['user'];
$comment_stack .= ' ('.$comment['time'].')'."\n";
// does comment get delete form?
if ($this->UserIsOwner() || $current_user == $comment['user'] || ($this->config['anony_delete_own_comments'] && $current_user == $comment['user']) )
{
$comment_stack .= $this->FormOpen("delcomment");
$comment_stack .= '<input type="hidden" name="comment_id" value="' . $comment['id'] . '" />';
$comment_stack .= '<input type="submit" value="Delete Comment" />';
$comment_stack .= $this->FormClose();
}
$comment_stack .= "\n\t".'</div>'."\n";
$comment_stack .= '</div>'."\n";
}
$_HTML['comments'] = $comment_stack;
}
// hidden comments
if ( $_SHOW['hidden_comments'] )
{
switch (count($comments))
{
case 0:
$comment_count = '<p>There are no comments on this page. ';
$showcomments_text = 'Add comment';
break;
case 1:
$comment_count = '<p>There is one comment on this page. ';
$showcomments_text = 'Display comment';
break;
default:
$comment_count = '<p>There are '.count($comments).' comments on this page. ';
$showcomments_text = 'Display comments';
}
$href = $this->Href('', '', 'show_comments=1#comments');
$_HTML['hidden_comments'] = <<<HTML
<div class="commentsheader">
$comment_count
[<a href="$href">$showcomments_text</a>]</p>
</div>
HTML;
}
// Page Close
if ( $_SHOW['page_close'] )
{
$_HTML['page_close'] = <<<HTML
</div>
<!--closing page content-->
HTML;
}
}
// End Viewer Blocks
// *** TEMPLATE: stitch it all together
$_HTML['page'] = <<<HTML
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
{$_HTML['page_close_div']}
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
{$_HTML['page_close']}
HTML;
echo $_HTML['page'];
?>
%%
Additions:
[[http://www.klenwell.net/is/WikkaChangeNotifier Wikka Recent Changes Notifier]]
Deletions:
Additions:
blog: http://phosphorusandlime.blogspot.com/
===Code Contributions===
===Code Contributions===