Skip to content
Browse files

cleanups. Mostly whitespace

  • Loading branch information...
1 parent 17b9e7a commit 55b8299a3ae7b876bbf7f27fec82529db22fa077 @Whiteknight committed May 2, 2010
Showing with 85 additions and 92 deletions.
  1. +2 −2 BookDesigner.alias.php
  2. +25 −25 BookDesigner.i18n.php
  3. +11 −11 BookDesigner.php
  4. +47 −54 BookDesigner_body.php
View
4 BookDesigner.alias.php
@@ -1,9 +1,9 @@
<?php
$aliases = array();
-
+
/** English */
$aliases['en'] = array(
'BookDesigner' => array( 'BookDesigner' ),
);
-
+
View
50 BookDesigner.i18n.php
@@ -11,41 +11,41 @@
// TODO: Can we get access to the raw $messages array from BookDesigner_body.php?
/* *** English *** */
$messages['en'] = array(
- 'bookdesigner' => 'Book Designer',
- 'bookdesigner-desc' => "Design and create books",
- 'bookdesigner-welcome' => "This is the <b>Visual Book Design</b> outlining tool. Use this page to create an outline for your new book.",
- 'bookdesigner-qsistart' => "Quick Start Instructions",
- 'bookdesigner-qsi' => <<< EOQSI
+ 'bookdesigner' => 'Book Designer',
+ 'bookdesigner-desc' => "Design and create books",
+ 'bookdesigner-welcome' => "This is the <b>Visual Book Design</b> outlining tool. Use this page to create an outline for your new book.",
+ 'bookdesigner-qsistart' => "Quick Start Instructions",
+ 'bookdesigner-qsi' => <<< EOQSI
<ol>
<li>Click the title of a book to rename it<br>Click "<b>New Book</b>" to give your book a name</li>
<li>Click "Headings for this page" to add sections to the page<br>Click the <b>[ + ]</b> To add 1 new section</li>
<li>Click "Subpages" to create new pages in the book here<br>Click the <b>[ + ]</b> to add 1 new subpage</li>
<li>When you are finished, click <b>Publish Book!</b> to create the book
</ol>
EOQSI
- ,
- 'bookdesigner-show' => 'Show',
- 'bookdesigner-hide' => 'Hide',
- 'bookdesigner-options' => 'Options',
- 'bookdesigner-optsbook' => 'Book Options',
- 'bookdesigner-optusenamespace' => 'Specify Namespace',
- 'bookdesigner-optuseuserspace' => 'Create In User Namespace',
- 'bookdesigner-optintroductionpage' => 'Create Introduction Page',
- 'bookdesigner-optresourcespage' => 'Create Resources Page',
- 'bookdesigner-optlicensingpage' => 'Create Licensing Page',
- 'bookdesigner-optspage' => 'Page Options',
- 'bookdesigner-optcreateleaf' => 'Create Leaf Pages',
- 'bookdesigner-optnumberpages' => 'Number Pages',
- 'bookdesigner-optstemplate' => 'Template Options',
- 'bookdesigner-optheadertemplate' => 'Include Header Template',
- 'bookdesigner-optfootertemplate' => 'Include Footer Template',
- 'bookdesigner-optautogenerate' => 'Autogenerate',
- 'bookdesigner-publishbutton' => 'Publish Book!',
+ ,
+ 'bookdesigner-show' => 'Show',
+ 'bookdesigner-hide' => 'Hide',
+ 'bookdesigner-options' => 'Options',
+ 'bookdesigner-optsbook' => 'Book Options',
+ 'bookdesigner-optusenamespace' => 'Specify Namespace',
+ 'bookdesigner-optuseuserspace' => 'Create In User Namespace',
+ 'bookdesigner-optintroductionpage' => 'Create Introduction Page',
+ 'bookdesigner-optresourcespage' => 'Create Resources Page',
+ 'bookdesigner-optlicensingpage' => 'Create Licensing Page',
+ 'bookdesigner-optspage' => 'Page Options',
+ 'bookdesigner-optcreateleaf' => 'Create Leaf Pages',
+ 'bookdesigner-optnumberpages' => 'Number Pages',
+ 'bookdesigner-optstemplate' => 'Template Options',
+ 'bookdesigner-optheadertemplate' => 'Include Header Template',
+ 'bookdesigner-optfootertemplate' => 'Include Footer Template',
+ 'bookdesigner-optautogenerate' => 'Autogenerate',
+ 'bookdesigner-publishbutton' => 'Publish Book!',
- 'bookdesigner-jserror' => <<<EOJSERROR
+ 'bookdesigner-jserror' => <<<EOJSERROR
JavaScript is not working, or designer.js could not be found.
Make sure to enable JavaScript in your browser, and contact your wiki site administrator.
EOJSERROR
- ,
+ ,
);
View
22 BookDesigner.php
@@ -7,20 +7,20 @@
EOT;
exit( 1 );
}
-
+
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'BookDesigner',
- 'author' => 'Andrew Whitworth',
- 'url' => 'http://github.com/Whiteknight/mediawiki-bookdesigner',
- 'description' => 'Design and create Books',
- 'descriptionmsg' => 'BookDesigner-desc',
- 'version' => '0.0.1',
+ 'name' => 'BookDesigner',
+ 'author' => 'Andrew Whitworth',
+ 'url' => 'http://github.com/Whiteknight/mediawiki-bookdesigner',
+ 'description' => 'Design and create Books',
+ 'descriptionmsg' => 'BookDesigner-desc',
+ 'version' => '0.0.1',
);
-
+
$dir = dirname(__FILE__) . '/';
-
-$wgAutoloadClasses['BookDesigner'] = $dir . 'BookDesigner_body.php';
+
+$wgAutoloadClasses['BookDesigner'] = $dir . 'BookDesigner_body.php';
$wgExtensionMessagesFiles['BookDesigner'] = $dir . 'BookDesigner.i18n.php';
$wgExtensionAliasesFiles['BookDesigner'] = $dir . 'BookDesigner.alias.php';
-$wgSpecialPages['BookDesigner'] = 'BookDesigner';
+$wgSpecialPages['BookDesigner'] = 'BookDesigner';
View
101 BookDesigner_body.php
@@ -5,10 +5,10 @@ function __construct() {
wfLoadExtensionMessages('BookDesigner');
}
- // set this to true to enable debugging output.
- protected $debug = false;
+ # set this to true to enable debugging output.
+ protected $debug = false;
- // Internal values. Don't modify them, they get set at runtime
+ # Internal values. Don't modify them, they get set at runtime
protected $bookname = "";
protected $createleaves = false;
protected $usetemplates = false;
@@ -20,57 +20,49 @@ function __construct() {
protected $createlicensing = false;
protected $namespace = "";
- // Quick and dirty debugging utilities. The value of $this->debug determines whether
- // we print something. These functions can probably disappear soon since the
- // parseBookPage parser routine has been mostly tested.
- function _dbg($word)
- {
+ # Quick and dirty debugging utilities. The value of $this->debug determines whether
+ # we print something. These functions can probably disappear soon since the
+ # parseBookPage parser routine has been mostly tested.
+ function _dbg($word) {
global $wgOut;
if($this->debug)
$wgOut->addHTML($word);
}
- function _dbgl($word)
- {
+ function _dbgl($word) {
$this->_dbg($word . "<br/>");
}
- function GetHeaderTemplateTag()
- {
+ function GetHeaderTemplateTag() {
return $this->usetemplates ? "{{" . $this->bookname . "}}\n\n" : "";
}
- function GetFooterTemplateTag()
- {
+ function GetFooterTemplateTag() {
return "";
}
- function GetCreateFlag($isroot)
- {
+ function GetCreateFlag($isroot) {
$create = $this->createleaves || $isroot;
$this->_dbgl("Creating leaf page: " . ($createleaf ? "1" : "0"));
return $create;
}
- function CreateIntroduction($isroot)
- {
+ function CreateIntroduction($isroot) {
if ($isroot && $this->createintroduction) {
$text = $this->GetHeaderTemplateTag() . $this->GetFooterTemplateTag();
$this->CreateOnePage($this->bookname . "/Introduction", $text, "Creating Introduction page");
return "*[[" . $this->bookname . "/Introduction|Introduction]]\n";
}
return "";
}
- function CreateResources($isroot)
- {
+ function CreateResources($isroot) {
if ($isroot && $this->createresources) {
$text = $this->GetHeaderTemplateTag() . $this->GetFooterTemplateTag();
$this->CreateOnePage($this->bookname . "/Resources", $text, "Creating Resources page");
return "*[[" . $this->bookname . "/Resources|Resources]]\n";
}
return "";
}
- function CreateLicensing($isroot)
- {
+ function CreateLicensing($isroot) {
if ($isroot && $this->createlicensing) {
$text = $this->GetHeaderTemplateTag() . $this->GetFooterTemplateTag();
$this->CreateOnePage($this->bookname . "/Licensing", $text, "Creating Licensing page");
@@ -79,21 +71,20 @@ function CreateLicensing($isroot)
return "";
}
- // Home-brewed recursive descent parser. Yes there are better ways of doing
- // this, and yes this is ugly and stupid and ugly. Whatever, this is what
- // we have.
- // [] contain lists of pages. {} contain lists of headings. Each page has[]{}
- // and each heading has only []. Each bare line of text inside a set of brackets
- // is that type of thing. Empty lines are ignored.
- function parseBookPage($page, $path, $lines, $idx)
- {
+ # Home-brewed recursive descent parser. Yes there are better ways of doing
+ # this, and yes this is ugly and stupid and ugly. Whatever, this is what
+ # we have.
+ # [] contain lists of pages. {} contain lists of headings. Each page has[]{}
+ # and each heading has only []. Each bare line of text inside a set of brackets
+ # is that type of thing. Empty lines are ignored.
+ function parseBookPage($page, $path, $lines, $idx) {
global $wgOut, $wgScriptPath;
$isroot = ($idx == 1);
$subpagenum = 0;
$pagetext = $this->GetHeaderTemplateTag() . $this->CreateIntroduction($isroot);
$createleaf = $this->GetCreateFlag($isroot);
- // Loop over all subpages inside [] brackets
+ # Loop over all subpages inside [] brackets
for($i = $idx; $i < sizeof($lines); $i++) {
$line = rtrim($lines[$i]);
$this->_dbg("Line " . $i . ": " . $line . "> ");
@@ -112,7 +103,7 @@ function parseBookPage($page, $path, $lines, $idx)
break;
}
else {
- // We have a page name
+ # We have a page name
$this->_dbgl("Recurse");
$subpagenum++;
$name = ($this->numberpages ? $subpagenum . ". " : "") . $line;
@@ -124,7 +115,7 @@ function parseBookPage($page, $path, $lines, $idx)
}
$pagetext .= "\n";
- // Loop over all headings inside {} brackets
+ # Loop over all headings inside {} brackets
for($i = $idx; $i < sizeof($lines); $i++) {
$line = rtrim($lines[$i]);
$this->_dbg("Line " . $i . ": " . $line . "> ");
@@ -144,8 +135,8 @@ function parseBookPage($page, $path, $lines, $idx)
$this->_dbgl("Heading");
$createpage = TRUE;
$pagetext .= "== " . $line . " ==\n\n";
- // a heading can have pages under it, so enter another loop here to
- // handle those pages.
+ # a heading can have pages under it, so enter another loop here to
+ # handle those pages.
for($i++; $i < sizeof($lines); $i++) {
$line2 = rtrim($lines[$i]);
$this->_dbg("Line " . $i . ": " . $line2 . "> ");
@@ -168,18 +159,18 @@ function parseBookPage($page, $path, $lines, $idx)
}
}
- // Get the rest of the text, most of which is optional
+ # Get the rest of the text, most of which is optional
$pagetext = $pagetext .
$this->CreateResources($isroot) .
$this->CreateLicensing($isroot) .
$this->GetFooterTemplateTag();
- // We've parsed all direct subpages and all headings (and all subpages
- // of those). We have all the information we need now to actually create
- // this page. Page name is in $path. Page text is in $pagetext
- // We only create the page if (1) we opt to create all pages, (2) the
- // page contains subpages, (3) the page contains headings, or (4) it is
- // the main page.
+ # We've parsed all direct subpages and all headings (and all subpages
+ # of those). We have all the information we need now to actually create
+ # this page. Page name is in $path. Page text is in $pagetext
+ # We only create the page if (1) we opt to create all pages, (2) the
+ # page contains subpages, (3) the page contains headings, or (4) it is
+ # the main page.
if ($createleaf)
$this->CreateOnePage($path, $pagetext, "Creating new book automatically");
return $idx;
@@ -194,7 +185,7 @@ function CreateOnePage($path, $text, $comment)
$wgOut->addHTML("Created <a href=\"$wgScriptPath/index.php?title=$path\">$path</a><br/>");
}
- // Build the header template
+ # Build the header template
function generateHeaderTemplate( $bookname ) {
global $wgOut, $wgScriptPath;
$name = "Template:" . $bookname;
@@ -205,13 +196,15 @@ function generateHeaderTemplate( $bookname ) {
$wgOut->addHTML("Created <a href=\"$wgScriptPath/index.php?title=$name\">$name</a><br/>");
}
- // Returns an EXTREMELY basic text string for creating a header template.
- // TODO: Make this less bare-bones
+ # Returns an EXTREMELY basic text string for creating a header template.
+ # TODO: Make this less bare-bones
function getTemplateText($bookname) {
$text = <<<EOD
<div style="border: 1px solid #AAAAAA; background-color: #F8F8F8; padding: 5px; margin: auto; width: 95%">
-<center><big>'''[[$bookname]]'''</big></center>
+ <center>
+ <big>'''[[$bookname]]'''</big>
+ </center>
</div>
EOD;
@@ -250,7 +243,7 @@ function GetMessage($msgname) {
return wfMsg('bookdesigner-' . $msgname);
}
- // Main function, this is where execution starts
+ # Main function, this is where execution starts
function execute( $par ) {
global $wgRequest, $wgOut, $wgScriptPath;
$this->setHeaders();
@@ -264,19 +257,19 @@ function execute( $par ) {
if(method_exists($wgOut, "addExtensionStyle")) {
$wgOut->addExtensionStyle($csspath . "/designer.css");
} else {
- // This is a hack for older MediaWiki (1.14 and below?).
- // addStyle prepends "$wgScriptPath/skins/" to the front,
- // so we need to navigate to the correct place
+ # This is a hack for older MediaWiki (1.14 and below?).
+ # addStyle prepends "$wgScriptPath/skins/" to the front,
+ # so we need to navigate to the correct place
$wgOut->addStyle("../extensions/BookDesigner/designer.css");
}
if(isset($par)) {
- // TODO: we've specified a book name, load that book into the outline
+ # TODO: we've specified a book name, load that book into the outline
$wgOut->addHTML($par);
}
else if($wgRequest->wasPosted()) {
- // TODO: Validate that we are logged in. Also, create an option to require
- // certain permissions (either admin, or a custom permission or something)
+ # TODO: Validate that we are logged in. Also, create an option to require
+ # certain permissions (either admin, or a custom permission or something)
$text = $wgRequest->getText('VBDHiddenTextArea');
$this->getOptions();
@@ -346,7 +339,7 @@ function execute( $par ) {
<!--
TODO: This is a temporary addition to aid in debugging. It shows the intermediate code before it's transmitted to the
server. This way if there is some kind of a server error, we can save a copy of that intermediate code to a safe place
- so when we are making a hugeo outline we don't lose all that work. No i18n for debug stuff.
+ so when we are making a huge outline we don't lose all that work. No i18n for debug stuff.
-->
<small>
<a href="#" onclick="document.getElementById('VBDHiddenTextArea').style.display = 'block';">Show Intermediate Code</a>

0 comments on commit 55b8299

Please sign in to comment.
Something went wrong with that request. Please try again.