_binary From 035b1d8863ed92b4481b43e99f960f6c93007645 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Mon, 20 Oct 2014 00:18:53 -0700
Subject: [PATCH 1/3] Back button changes

- Created a new Icon for back button.

- When the user navigates to the Wiki edit page from a help-open page, they will see the back button. Clicking on back button will navigate the user to the help-open page, with the help article open.

- Also the back button stays in place even if the user navigates from edit -> read page or edit > edit expanded page or edit -> edit expanded > read expanded etc cases that are possible for the user to navigate.

Signed-off-by: epinapala <epinapala@ebay.com>
---
 controllers/controller.php          |  38 +++++++++++++++++++++++++++++
 css/search.css                      |   4 +++
 resources/back.png                  | Bin 0 -> 2034 bytes
 scripts/basic.js                    |  47 +++++++++++++++++++-----------------
 views/elements/wiki_element.php     |  27 +++++++++++++++++++++
 views/helpers/helpbutton_helper.php |  16 +++++++-----
 views/wiki_view.php                 |   3 +++
 7 files changed, 107 insertions(+), 28 deletions(-)
 create mode 100644 resources/back.png

diff --git a/controllers/controller.php b/controllers/controller.php
index f0a56a6..22177d4 100755
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -255,9 +255,47 @@ abstract class Controller
             }
         }
         $data['c'] = isset($_REQUEST['c']) ? $_REQUEST['c'] : NULL;
+        $data = array_merge($data,$this->setupWikiHelpBackLogic());
         $this->view($view)->render($data);
     }
     /**
+     * This is a helper method that sets proper data vars required to perform
+     * Back page logic when the user is navigating from help article to edit
+     * page,and then back to help article.
+     * @param type $data to add data vars
+     * @return string $data
+     */
+    function setupWikiHelpBackLogic() {
+        $data =  array();
+        $data["OTHER_BACK_URL"] = "";
+        if(isset($_REQUEST['back_params'])){
+            foreach($_REQUEST['back_params'] as
+                    $back_param_key => $back_param_value){
+                $data['BACK_PARAMS']["back_params[$back_param_key]"]
+                    = $back_param_value;
+                $data["OTHER_BACK_URL"] .= "&amp;back_params[$back_param_key]"
+                    ."=" . $back_param_value;
+            }
+            $data['BACK_URL'] = http_build_query($_REQUEST["back_params"]);
+        }
+
+        if (isset($_REQUEST['open_help_page'])) {
+            $data['OPEN_HELP_PAGE'] = $_REQUEST['open_help_page'];
+            if (!isset($data['SCRIPT'])) {
+                $data['SCRIPT'] = "";
+            }
+
+            $data['SCRIPT'] .= "\n" .
+                'var matches = '
+                . 'document.querySelectorAll("[data-pagename='
+                . $data['OPEN_HELP_PAGE']
+                . ']");'
+                . "matches[0].click();"
+                . "\n";
+        }
+        return $data;
+    }
+    /**
      * When an activity involves displaying tabular data (such as rows of
      * users, groups, etc), this method might be called to set up $data
      * fields for next, prev, and page links, it also makes the call to the
diff --git a/css/search.css b/css/search.css
index 696c537..7e89ba2 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2861,3 +2861,7 @@ top: 1in;
 .wiki-resource-image{
     max-width:100%;
 }
+.back-button{
+    margin-top : 5px;
+    margin-bottom : 10px;
+}
\ No newline at end of file
diff --git a/resources/back.png b/resources/back.png
new file mode 100644
index 0000000000000000000000000000000000000000..eee5c8297b17d87b6bdc26e4ba2384b9266b1090
GIT binary patch
diff --git a/scripts/basic.js b/scripts/basic.js
index 6ab029c..279522e 100755
--- a/scripts/basic.js
+++ b/scripts/basic.js
@@ -383,15 +383,15 @@ function getPageWithCallback(url, response_type, success_call_back,
  * @param String api_action api's action name.
  * @param String mode r/w mode , usually read.
  */
-function displayHelpForId( help_point, is_mobile, target_controller,
-    csrf_token_key, csrf_token_value, help_group_id, api_controller,
-    api_action, mode)
-{
+function displayHelpForId(help_point, is_mobile, target_controller,
+                          current_action, csrf_token_key, csrf_token_value,
+                          help_group_id,
+                          api_controller, api_action, mode) {
     if ((elt("help-frame").style.display) === "block") {
         toggleHelp('help-frame', is_mobile, target_controller);
         return;
     }
-    var tl = eval( '(' + help_point.getAttribute("data-tl") + ')' );
+    var tl = eval('(' + help_point.getAttribute("data-tl") + ')');
     getPageWithCallback("?c=" + api_controller + "&group_id=" +
         help_group_id + "&" +
         "arg=" + mode + "&" +
@@ -399,24 +399,25 @@ function displayHelpForId( help_point, is_mobile, target_controller,
         csrf_token_key + '=' + csrf_token_value + "&" +
         "page_name=" + help_point.getAttribute("data-pagename"),
         'json',
-        function(data) {
+        function (data) {
             elt("help-frame-body").innerHTML = parseWikiContent(
                 data.wiki_content,
                 data.group_id,
                 data.page_id
             );
             elt('page_name').innerHTML = data.page_name + ' [<a href="' +
-                getEditLink(
-                    target_controller,
-                    csrf_token_key,
-                    csrf_token_value,
-                    help_group_id,
-                    data.page_name) + '">' +
-                tl["wiki_view_edit"] + '</a>]';
+            getEditLink(
+                target_controller,
+                current_action,
+                csrf_token_key,
+                csrf_token_value,
+                help_group_id,
+                data.page_name) + '">' +
+            tl["wiki_view_edit"] + '</a>]';
 
             toggleHelp('help-frame', is_mobile, target_controller);
         },
-        function(status) {
+        function (status) {
             toggleHelp('help-frame', is_mobile, target_controller);
         });
     event.preventDefault();
@@ -431,13 +432,15 @@ function displayHelpForId( help_point, is_mobile, target_controller,
  * @param String page_name Page name,unique Identifier for wiki edit page.
  * @return String the edit link
  */
-function getEditLink(target_controller, csrf_token_key, csrf_token_value,
-    group_id, page_name)
-{
+function getEditLink(target_controller, current_action, csrf_token_key,
+                     csrf_token_value, group_id, page_name) {
     return '?c=' + target_controller +
-        '&' + csrf_token_key + '=' + csrf_token_value +
-        '&group_id=' + group_id +
-        '&arg=edit' +
-        '&a=wiki' +
-        '&page_name=' + page_name;
+    '&' + csrf_token_key + '=' + csrf_token_value +
+    '&group_id=' + group_id +
+    '&arg=edit' +
+    '&a=wiki' +
+    '&page_name=' + page_name +
+    '&back_params[open_help_page]=' + page_name +
+    '&back_params[c]=' + target_controller +
+    '&back_params[a]=' + current_action;
 }
diff --git a/views/elements/wiki_element.php b/views/elements/wiki_element.php
index a6080db..2c1dc28 100644
--- a/views/elements/wiki_element.php
+++ b/views/elements/wiki_element.php
@@ -69,6 +69,9 @@ class WikiElement extends Element implements CrawlConstants
         $other_base_query = "?c=$other_controller&amp;a=wiki&amp;group_id=".
             $data["GROUP"]["GROUP_ID"]."&amp;arg=".$data['MODE']."&amp;".
             "page_name=".$data['PAGE_NAME'];
+        if(isset($data['OTHER_BACK_URL'])){
+            $other_base_query .= $data['OTHER_BACK_URL'];
+         }
         if($logged_in) {
             $other_base_query .= $csrf_token;
             $csrf_token = "&amp;".CSRF_TOKEN."=".$data[CSRF_TOKEN];
@@ -105,6 +108,14 @@ class WikiElement extends Element implements CrawlConstants
             }
             e('<div class="small-margin-current-activity '.$page_border.'">');
         }
+        if (isset($data['BACK_URL'])) {
+            e("<div class=\"float-opposite back-button\">" .
+                "<a href=\"?" . $data['BACK_URL'] . "&amp;" . CSRF_TOKEN
+                . "=" . $data[CSRF_TOKEN] . "\">" .
+                "<img src=\"resources/back.png\" />" .
+                "</a>" .
+                "</div>");
+        }
         if(isset($data['MEDIA_NAME'])) {
             ?>
             <div class="top-margin"><b><a href="<?php e($base_query .
@@ -148,6 +159,9 @@ class WikiElement extends Element implements CrawlConstants
                     if($name != 'pages') {
                         $append = '&amp;page_name='. $data['PAGE_NAME'];
                     }
+                    if (isset($data['OTHER_BACK_URL'])) {
+                        $append .= $data['OTHER_BACK_URL'];
+                    }
                     e($bar); ?><a href="<?php e($base_query .
                         '&amp;arg='.$name.'&amp;a=wiki'.$append); ?>"><?php
                         e($translation); ?></a><?php
@@ -275,6 +289,19 @@ class WikiElement extends Element implements CrawlConstants
                 e($data[CSRF_TOKEN]); ?>" />
             <input type="hidden" name="a" value="wiki" />
             <input type="hidden" name="arg" value="edit" />
+            <?php
+            if(isset($data['BACK_PARAMS']))
+            {
+                foreach($data["BACK_PARAMS"] as
+                        $back_param_key => $back_param_value){
+                    e('<input type="hidden" '
+                        . 'name="'.$back_param_key.
+                        '" value="'.
+                        $back_param_value
+                        .'" />');
+                }
+            }
+            ?>
             <input type="hidden" name="group_id" value="<?php
                 e($data['GROUP']['GROUP_ID']); ?>" />
             <input type="hidden" name="page_name" value="<?php
diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index ad7154d..26fb1fc 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -65,11 +65,11 @@ class HelpbuttonHelper extends Helper
      *
      * @param  $help_point_id - used to set as help button id
      * @param  $csrf_token_value - csrf token to make api call/open edit link
-     * @param  $target_c - target controller to remember the view.
+     * @param  $target_controller - target controller to remember the view.
      * @return String button html.
      */
     public function render($help_point_id,
-                           $csrf_token_value, $target_c) {
+                           $csrf_token_value, $target_controller) {
         $is_mobile = MOBILE ? "true" : "false";
         $wiki_group_id = "7";
         $api_controller = "api";
@@ -77,10 +77,14 @@ class HelpbuttonHelper extends Helper
         $api_wiki_mode = "read";
 
         return '<button type="button"
-                    data-tl=\''.$this->localizationdata.'\'
-                    onclick="javascript:displayHelpForId(this,'
-        . $is_mobile . ',\'' . $target_c . '\',\''. CSRF_TOKEN .'\',\''
-        . $csrf_token_value ."','$wiki_group_id','$api_controller',"
+                    data-tl=\'' . $this->localizationdata . '\'
+                    onclick="javascript:displayHelpForId(
+                    this,'
+        . $is_mobile . ',\''
+        . $target_controller . '\',\''
+        . $_REQUEST['a'] . '\',\''
+        . CSRF_TOKEN . '\',\''
+        . $csrf_token_value . "','$wiki_group_id','$api_controller',"
         . "'$api_wiki_action','$api_wiki_mode" . '\')" '
         . 'data-pagename="' . $help_point_id . '">?</button>';
     }
diff --git a/views/wiki_view.php b/views/wiki_view.php
index 32df361..1e0b15c 100644
--- a/views/wiki_view.php
+++ b/views/wiki_view.php
@@ -108,6 +108,9 @@ class WikiView extends View
                     if($name != 'pages') {
                         $append = '&amp;page_name='. $data['PAGE_NAME'];
                     }
+                    if (isset($data['OTHER_BACK_URL'])) {
+                        $append .= $data['OTHER_BACK_URL'];
+                    }
                     ?>
                     <li class="outer"><a href="<?php e($base_query .
                         '&amp;arg='.$name.'&amp;a=wiki'.$append); ?>"><?php
-- 
1.9.3 (Apple Git-50)


From fecaa06a1b63a5e83927b2338dcbcaf4394c1537 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Tue, 21 Oct 2014 18:50:00 -0700
Subject: [PATCH 2/3] - Remove back button and replace with localized Back
 text. - JS Wiki parser Fix for Internal links. - Formatting changes

Signed-off-by: epinapala <epinapala@ebay.com>
---
 css/search.css                          |   4 --
 resources/back.png                      | Bin 2034 -> 0 bytes
 scripts/basic.js                        |  63 ++++++++++++++++++++++----------
 views/elements/managegroups_element.php |   2 +-
 views/elements/wiki_element.php         |   6 ++-
 views/helpers/helpbutton_helper.php     |  23 ++++++------
 6 files changed, 60 insertions(+), 38 deletions(-)
 delete mode 100644 resources/back.png

diff --git a/css/search.css b/css/search.css
index 7e89ba2..26e8ee1 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2860,8 +2860,4 @@ top: 1in;
 }
 .wiki-resource-image{
     max-width:100%;
-}
-.back-button{
-    margin-top : 5px;
-    margin-bottom : 10px;
 }
\ No newline at end of file
diff --git a/resources/back.png b/resources/back.png
deleted file mode 100644
index eee5c8297b17d87b6bdc26e4ba2384b9266b1090..0000000000000000000000000000000000000000
GIT binary patch
diff --git a/scripts/basic.js b/scripts/basic.js
index 279522e..8ed8937 100755
--- a/scripts/basic.js
+++ b/scripts/basic.js
@@ -262,64 +262,86 @@ function getCssProperty(elm, property) {
  * @param String wiki_text to be parsed as HTML
  * @return String parsed html.
  */
-function parseWikiContent(wiki_text, group_id, page_id)
+function parseWikiContent( wiki_text, group_id, page_id, controller_name,
+    csrf_token_key, csrf_token_value)
 {
     var html = wiki_text;
     /* note that line breaks from a text area are sent
-    as \r\n , so make sure we clean them up to replace
-    all \r\n with \n */
+     as \r\n , so make sure we clean them up to replace
+     all \r\n with \n */
     html = html.replace(/\r\n/g, "\n");
     html = parseLists(html);
     //Regex replace normal links
-    html = html.replace(/[^\[](http[^\[\s]*)/g, function(m, l) {
+    html = html.replace(/[^\[](http[^\[\s]*)/g, function ( m, l )
+    {
         // normal link
         return '<a href="' + l + '">' + l + '</a>';
     });
     //Regex replace for external links
-    html = html.replace(/[\[](http.*)[!\]]/g, function(m, l) {
+    html = html.replace(/[\[](http.*)[!\]]/g, function ( m, l )
+    {
         // external link
         var p = l.replace(/[\[\]]/g, '').split(/ /);
         var link = p.shift();
-        return '<a href="' + link + '">' + (p.length ? p.join(' ') :
-            link) + '</a>';
+        return '[<a href="' + link + '">' + (p.length ? p.join(' ') :
+            link) + '</a>]';
     });
     //Regex replace for headings
     html = html.replace(/(?:^|\n)([=]+)(.*)\1/g,
-        function(match, contents, t) {
+        function ( match, contents, t )
+        {
             return '<h' + contents.length + '>' + t + '</h' + contents.length +
-                '>';
+            '>';
         });
     //Regex replace for Bold characters
-    html = html.replace(/'''(.*?)'''/g, function(match, contents) {
+    html = html.replace(/'''(.*?)'''/g, function ( match, contents )
+    {
         return '<b>' + contents + '</b>';
     });
     //Regex replace for Italic characters
-    html = html.replace(/''(.*?)''/g, function(match, contents) {
+    html = html.replace(/''(.*?)''/g, function ( match, contents )
+    {
         return '<i>' + contents + '</i>';
     });
     //Regex for resource extraction.
     html = html.replace(/{{resource:(.+?)\|(.+?)}}/g,
-        function(match, contents, desc) {
+        function ( match, contents, desc )
+        {
             return '<img src="' + "?c=resource&a=get&f=resources&g=" +
-                group_id + "&p=" + page_id + "&n=" + contents +
-                '" alt="' + desc + '" class="wiki-resource-image"/>';
+            group_id + "&p=" + page_id + "&n=" + contents +
+            '" alt="' + desc + '" class="wiki-resource-image"/>';
         });
     //Regex replace for HR
-    html = html.replace(/----(.*?)/g, function(match, contents) {
+    html = html.replace(/----(.*?)/g, function ( match, contents )
+    {
         return contents + '<hr />';
     });
     //replace nowiki with pre tags
-    html = html.replace(/<nowiki>(.*?)<\/nowiki>/g, function(match,
-        contents) {
+    html = html.replace(/<nowiki>(.*?)<\/nowiki>/g, function ( match,
+        contents )
+    {
         return '<pre>' + contents + '</pre>';
     });
     //Regex replace for blocks
     html = html.replace(/(?:^|\n+)([^# =\*<].+)(?:\n+|$)/gm,
-        function(match, contents) {
+        function ( match, contents )
+        {
             if (contents.match(/^\^+$/))
                 return contents;
             return "\n<div>" + contents + "</div>\n";
         });
+    //Internal links to other pages.
+    html = html.replace(/\[\[(.*?)\]\]/g, function ( matches, internal_link )
+    {
+        var internal_link_array = internal_link.split(/\|/);
+        var page_name = internal_link_array.shift();
+        return '<a href="' + '?c=' + controller_name
+        + '&a=wiki&arg=read&group_id=' + group_id + '&page_name=' + page_name
+        +"&"+csrf_token_key + '=' + csrf_token_value + '">'
+        + (internal_link_array.length ? internal_link_array.join('|')
+            : page_name)
+        + '</a>';
+    });
     return html;
 }
 /*
@@ -403,7 +425,10 @@ function displayHelpForId(help_point, is_mobile, target_controller,
             elt("help-frame-body").innerHTML = parseWikiContent(
                 data.wiki_content,
                 data.group_id,
-                data.page_id
+                data.page_id,
+                target_controller,
+                csrf_token_key,
+                csrf_token_value
             );
             elt('page_name').innerHTML = data.page_name + ' [<a href="' +
             getEditLink(
diff --git a/views/elements/managegroups_element.php b/views/elements/managegroups_element.php
index a91b864..0a55d10 100755
--- a/views/elements/managegroups_element.php
+++ b/views/elements/managegroups_element.php
@@ -324,7 +324,7 @@ class ManagegroupsElement extends Element
                         e(tl('managegroups_element_browse')); ?></a>]
                     <?php
                     e($this->view->helper("helpbutton")->render(
-                            "browse_url", $data[CSRF_TOKEN],$_REQUEST['c']));
+                            "Main", $data[CSRF_TOKEN],$_REQUEST['c']));
                     ?></td>
                 <?php
                 }
diff --git a/views/elements/wiki_element.php b/views/elements/wiki_element.php
index 2c1dc28..0c8d3d3 100644
--- a/views/elements/wiki_element.php
+++ b/views/elements/wiki_element.php
@@ -58,6 +58,7 @@ class WikiElement extends Element implements CrawlConstants
         $can_edit = $logged_in && isset($data["CAN_EDIT"]) && $data["CAN_EDIT"];
         $is_admin = ($data["CONTROLLER"] == "admin");
         $arrows = ($is_admin) ? "&lt;&lt;" : "&gt;&gt;";
+        $back_arrows = "&lt;&lt;";
         $other_controller = ($is_admin) ? "group" : "admin";
         $base_query = "?c={$data['CONTROLLER']}";
         $csrf_token = "";
@@ -108,11 +109,12 @@ class WikiElement extends Element implements CrawlConstants
             }
             e('<div class="small-margin-current-activity '.$page_border.'">');
         }
-        if (isset($data['BACK_URL'])) {
+        if (isset($data['BACK_URL']))
+        {
             e("<div class=\"float-opposite back-button\">" .
                 "<a href=\"?" . $data['BACK_URL'] . "&amp;" . CSRF_TOKEN
                 . "=" . $data[CSRF_TOKEN] . "\">" .
-                "<img src=\"resources/back.png\" />" .
+                "$back_arrows " . tl('wiki_view_back') .
                 "</a>" .
                 "</div>");
         }
diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index 26fb1fc..07d8803 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -34,7 +34,7 @@ if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
 /**
  * Load base helper class if needed
  */
-require_once BASE_DIR."/views/helpers/helper.php";
+require_once BASE_DIR . "/views/helpers/helper.php";
 /**
  * This is a helper class is used to
  * draw help button for context sensitive
@@ -52,30 +52,29 @@ class HelpbuttonHelper extends Helper
      */
     function __construct()
     {
-        $this->localizationdata = "{".
-            'wiki_view_edit :"'.tl('wiki_view_edit').'",'.
-            'wiki_view_read :"'.tl('wiki_view_read').'"'.
+        $this->localizationdata = "{" .
+            'wiki_view_edit :"' . tl('wiki_view_edit') . '",' .
+            'wiki_view_read :"' . tl('wiki_view_read') . '"' .
             "}";
         parent::__construct();
     }
-
     /**
      * This method is used to render the help button,
-     * given a help point  csrf token and target controller name.
+     * given a help point  CSRF token and target controller name.
      *
      * @param  $help_point_id - used to set as help button id
-     * @param  $csrf_token_value - csrf token to make api call/open edit link
+     * @param  $csrf_token_value - CSRF token to make api call/open edit link
      * @param  $target_controller - target controller to remember the view.
      * @return String button html.
      */
-    public function render($help_point_id,
-                           $csrf_token_value, $target_controller) {
+    public function render($help_point_id, $csrf_token_value,
+        $target_controller)
+    {
         $is_mobile = MOBILE ? "true" : "false";
         $wiki_group_id = "7";
         $api_controller = "api";
-        $api_wiki_action ="wiki";
+        $api_wiki_action = "wiki";
         $api_wiki_mode = "read";
-
         return '<button type="button"
                     data-tl=\'' . $this->localizationdata . '\'
                     onclick="javascript:displayHelpForId(
@@ -89,4 +88,4 @@ class HelpbuttonHelper extends Helper
         . 'data-pagename="' . $help_point_id . '">?</button>';
     }
 }
-?>
+?>
\ No newline at end of file
-- 
1.9.3 (Apple Git-50)


From 9657465bd88c656f05091b6ae90aa89c5fbaa880 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Tue, 21 Oct 2014 19:32:47 -0700
Subject: [PATCH 3/3] - Formatting changes

Signed-off-by: epinapala <epinapala@ebay.com>
---
 controllers/controller.php      | 20 +++++-----
 scripts/basic.js                | 81 +++++++++++++++++++++--------------------
 views/elements/wiki_element.php | 28 +++++++-------
 views/wiki_view.php             |  2 +-
 4 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/controllers/controller.php b/controllers/controller.php
index 22177d4..271172d 100755
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -262,29 +262,29 @@ abstract class Controller
      * This is a helper method that sets proper data vars required to perform
      * Back page logic when the user is navigating from help article to edit
      * page,and then back to help article.
+     *
      * @param type $data to add data vars
      * @return string $data
      */
-    function setupWikiHelpBackLogic() {
-        $data =  array();
+    function setupWikiHelpBackLogic()
+    {
+        $data = array();
         $data["OTHER_BACK_URL"] = "";
-        if(isset($_REQUEST['back_params'])){
-            foreach($_REQUEST['back_params'] as
-                    $back_param_key => $back_param_value){
+        if(isset($_REQUEST['back_params'])) {
+            foreach ($_REQUEST['back_params'] as
+                     $back_param_key => $back_param_value) {
                 $data['BACK_PARAMS']["back_params[$back_param_key]"]
                     = $back_param_value;
                 $data["OTHER_BACK_URL"] .= "&amp;back_params[$back_param_key]"
-                    ."=" . $back_param_value;
+                    . "=" . $back_param_value;
             }
             $data['BACK_URL'] = http_build_query($_REQUEST["back_params"]);
         }
-
-        if (isset($_REQUEST['open_help_page'])) {
+        if(isset($_REQUEST['open_help_page'])) {
             $data['OPEN_HELP_PAGE'] = $_REQUEST['open_help_page'];
-            if (!isset($data['SCRIPT'])) {
+            if(!isset($data['SCRIPT'])) {
                 $data['SCRIPT'] = "";
             }
-
             $data['SCRIPT'] .= "\n" .
                 'var matches = '
                 . 'document.querySelectorAll("[data-pagename='
diff --git a/scripts/basic.js b/scripts/basic.js
index 8ed8937..4b15a3c 100755
--- a/scripts/basic.js
+++ b/scripts/basic.js
@@ -201,7 +201,6 @@ function toggleHelp(id, isMobile, target_controller)
         current_activity_top = getCssProperty(help_node, 'top');
     }
     obj = elt(id);
-
     if (isMobile === false) {
         toggleDisplay(id);
         var new_width;
@@ -209,12 +208,11 @@ function toggleHelp(id, isMobile, target_controller)
         //Calculate pixel to inch. clientWidth only returns in pixels.
         if (obj.style.display === "none") {
             new_width = Math.floor(getCssProperty(help_node, 'width')) +
-                decrease_width_by;
+            decrease_width_by;
         } else if (obj.style.display === "block") {
             new_width = Math.floor(getCssProperty(help_node, 'width')) -
-                decrease_width_by;
+            decrease_width_by;
         }
-
         if (new_width !== undefined) {
             help_node.style.maxWidth = new_width + "px";
         }
@@ -228,15 +226,16 @@ function toggleHelp(id, isMobile, target_controller)
             current_activity_closed = true;
         } else if (obj.style.display === "block") {
             help_node.style.top = current_activity_top +
-                height_after_toggle + "px";
+            height_after_toggle + "px";
             /* The div.clientHeight doesnt include the height
-            of the images inside the div before the images are completely
-            loaded. So we iterate through the
-            image elements, as each image loads add the image
-            height to the top of the current_activity div dynamically. */
+             of the images inside the div before the images are completely
+             loaded. So we iterate through the
+             image elements, as each image loads add the image
+             height to the top of the current_activity div dynamically. */
             for (var i = 0; i < images.length; i++) {
                 var image = images[i];
-                image.onload = function() {
+                image.onload = function ()
+                {
                     help_node.style.top = getCssProperty(help_node,
                         'top') + this.height + 'px';
                 };
@@ -251,7 +250,8 @@ function toggleHelp(id, isMobile, target_controller)
  * @param String property Css property name.
  * @return String Css property value
  */
-function getCssProperty(elm, property) {
+function getCssProperty(elm, property)
+{
     //always returns in px
     return parseInt(window.getComputedStyle(elm, null)
         .getPropertyValue(property));
@@ -262,7 +262,7 @@ function getCssProperty(elm, property) {
  * @param String wiki_text to be parsed as HTML
  * @return String parsed html.
  */
-function parseWikiContent( wiki_text, group_id, page_id, controller_name,
+function parseWikiContent(wiki_text, group_id, page_id, controller_name,
     csrf_token_key, csrf_token_value)
 {
     var html = wiki_text;
@@ -272,13 +272,13 @@ function parseWikiContent( wiki_text, group_id, page_id, controller_name,
     html = html.replace(/\r\n/g, "\n");
     html = parseLists(html);
     //Regex replace normal links
-    html = html.replace(/[^\[](http[^\[\s]*)/g, function ( m, l )
+    html = html.replace(/[^\[](http[^\[\s]*)/g, function (m, l)
     {
         // normal link
         return '<a href="' + l + '">' + l + '</a>';
     });
     //Regex replace for external links
-    html = html.replace(/[\[](http.*)[!\]]/g, function ( m, l )
+    html = html.replace(/[\[](http.*)[!\]]/g, function (m, l)
     {
         // external link
         var p = l.replace(/[\[\]]/g, '').split(/ /);
@@ -288,56 +288,56 @@ function parseWikiContent( wiki_text, group_id, page_id, controller_name,
     });
     //Regex replace for headings
     html = html.replace(/(?:^|\n)([=]+)(.*)\1/g,
-        function ( match, contents, t )
+        function (match, contents, t)
         {
             return '<h' + contents.length + '>' + t + '</h' + contents.length +
             '>';
         });
     //Regex replace for Bold characters
-    html = html.replace(/'''(.*?)'''/g, function ( match, contents )
+    html = html.replace(/'''(.*?)'''/g, function (match, contents)
     {
         return '<b>' + contents + '</b>';
     });
     //Regex replace for Italic characters
-    html = html.replace(/''(.*?)''/g, function ( match, contents )
+    html = html.replace(/''(.*?)''/g, function (match, contents)
     {
         return '<i>' + contents + '</i>';
     });
     //Regex for resource extraction.
     html = html.replace(/{{resource:(.+?)\|(.+?)}}/g,
-        function ( match, contents, desc )
+        function (match, contents, desc)
         {
             return '<img src="' + "?c=resource&a=get&f=resources&g=" +
             group_id + "&p=" + page_id + "&n=" + contents +
             '" alt="' + desc + '" class="wiki-resource-image"/>';
         });
     //Regex replace for HR
-    html = html.replace(/----(.*?)/g, function ( match, contents )
+    html = html.replace(/----(.*?)/g, function (match, contents)
     {
         return contents + '<hr />';
     });
     //replace nowiki with pre tags
-    html = html.replace(/<nowiki>(.*?)<\/nowiki>/g, function ( match,
-        contents )
+    html = html.replace(/<nowiki>(.*?)<\/nowiki>/g, function (match,
+        contents)
     {
         return '<pre>' + contents + '</pre>';
     });
     //Regex replace for blocks
     html = html.replace(/(?:^|\n+)([^# =\*<].+)(?:\n+|$)/gm,
-        function ( match, contents )
+        function (match, contents)
         {
             if (contents.match(/^\^+$/))
                 return contents;
             return "\n<div>" + contents + "</div>\n";
         });
     //Internal links to other pages.
-    html = html.replace(/\[\[(.*?)\]\]/g, function ( matches, internal_link )
+    html = html.replace(/\[\[(.*?)\]\]/g, function (matches, internal_link)
     {
         var internal_link_array = internal_link.split(/\|/);
         var page_name = internal_link_array.shift();
         return '<a href="' + '?c=' + controller_name
         + '&a=wiki&arg=read&group_id=' + group_id + '&page_name=' + page_name
-        +"&"+csrf_token_key + '=' + csrf_token_value + '">'
+        + "&" + csrf_token_key + '=' + csrf_token_value + '">'
         + (internal_link_array.length ? internal_link_array.join('|')
             : page_name)
         + '</a>';
@@ -353,16 +353,16 @@ function parseWikiContent( wiki_text, group_id, page_id, controller_name,
  */
 function parseLists(str)
 {
-    return str.replace(/(?:(?:(?:^|\n)[\*#].*)+)/g, function(match) {
+    return str.replace(/(?:(?:(?:^|\n)[\*#].*)+)/g, function (match)
+    {
         var listType = match.match(/(^|\n)#/) ? 'ol' : 'ul';
         match = match.replace(/(^|\n)[\*#][ ]{0,1}/g, "$1");
         match = parseLists(match);
         return '<' + listType + '><li>' + match.replace(/^\n/, '')
             .split(/\n/).join('</li><li>') + '</li></' + listType +
-            '>';
+        '>';
     });
 }
-
 /*
  * getPageWithCallback does a GET HTTP call on the url passed.
  * Also fires the callback functions passed as
@@ -379,9 +379,10 @@ function getPageWithCallback(url, response_type, success_call_back,
     var request = makeRequest();
     request.open('GET', url, true);
     request.responseType = response_type;
-    request.onload = function() {
+    request.onload = function ()
+    {
         var status = request.status;
-        if (status == 200) {
+        if(status == 200) {
             success_call_back && success_call_back(request.response);
         } else {
             error_handler && error_handler(status);
@@ -389,7 +390,6 @@ function getPageWithCallback(url, response_type, success_call_back,
     };
     request.send();
 };
-
 /*
  * Takes in the help point id, uses it to fetch wiki content, then
  * wiki content is being eval'd to be painted int he help pane.
@@ -406,10 +406,10 @@ function getPageWithCallback(url, response_type, success_call_back,
  * @param String mode r/w mode , usually read.
  */
 function displayHelpForId(help_point, is_mobile, target_controller,
-                          current_action, csrf_token_key, csrf_token_value,
-                          help_group_id,
-                          api_controller, api_action, mode) {
-    if ((elt("help-frame").style.display) === "block") {
+    current_action, csrf_token_key, csrf_token_value, help_group_id,
+    api_controller, api_action, mode)
+{
+    if((elt("help-frame").style.display) === "block") {
         toggleHelp('help-frame', is_mobile, target_controller);
         return;
     }
@@ -421,7 +421,8 @@ function displayHelpForId(help_point, is_mobile, target_controller,
         csrf_token_key + '=' + csrf_token_value + "&" +
         "page_name=" + help_point.getAttribute("data-pagename"),
         'json',
-        function (data) {
+        function (data)
+        {
             elt("help-frame-body").innerHTML = parseWikiContent(
                 data.wiki_content,
                 data.group_id,
@@ -439,15 +440,14 @@ function displayHelpForId(help_point, is_mobile, target_controller,
                 help_group_id,
                 data.page_name) + '">' +
             tl["wiki_view_edit"] + '</a>]';
-
             toggleHelp('help-frame', is_mobile, target_controller);
         },
-        function (status) {
+        function (status)
+        {
             toggleHelp('help-frame', is_mobile, target_controller);
         });
     event.preventDefault();
 }
-
 /*
  * Simple function to construct the Wiki Edit hyperlink with passed in params.
  * @param String target_controller Edit page's controller name.
@@ -458,7 +458,8 @@ function displayHelpForId(help_point, is_mobile, target_controller,
  * @return String the edit link
  */
 function getEditLink(target_controller, current_action, csrf_token_key,
-                     csrf_token_value, group_id, page_name) {
+    csrf_token_value, group_id, page_name)
+{
     return '?c=' + target_controller +
     '&' + csrf_token_key + '=' + csrf_token_value +
     '&group_id=' + group_id +
@@ -468,4 +469,4 @@ function getEditLink(target_controller, current_action, csrf_token_key,
     '&back_params[open_help_page]=' + page_name +
     '&back_params[c]=' + target_controller +
     '&back_params[a]=' + current_action;
-}
+}
\ No newline at end of file
diff --git a/views/elements/wiki_element.php b/views/elements/wiki_element.php
index 0c8d3d3..82de9d5 100644
--- a/views/elements/wiki_element.php
+++ b/views/elements/wiki_element.php
@@ -70,9 +70,9 @@ class WikiElement extends Element implements CrawlConstants
         $other_base_query = "?c=$other_controller&amp;a=wiki&amp;group_id=".
             $data["GROUP"]["GROUP_ID"]."&amp;arg=".$data['MODE']."&amp;".
             "page_name=".$data['PAGE_NAME'];
-        if(isset($data['OTHER_BACK_URL'])){
+        if(isset($data['OTHER_BACK_URL'])) {
             $other_base_query .= $data['OTHER_BACK_URL'];
-         }
+        }
         if($logged_in) {
             $other_base_query .= $csrf_token;
             $csrf_token = "&amp;".CSRF_TOKEN."=".$data[CSRF_TOKEN];
@@ -109,8 +109,7 @@ class WikiElement extends Element implements CrawlConstants
             }
             e('<div class="small-margin-current-activity '.$page_border.'">');
         }
-        if (isset($data['BACK_URL']))
-        {
+        if(isset($data['BACK_URL'])) {
             e("<div class=\"float-opposite back-button\">" .
                 "<a href=\"?" . $data['BACK_URL'] . "&amp;" . CSRF_TOKEN
                 . "=" . $data[CSRF_TOKEN] . "\">" .
@@ -159,14 +158,14 @@ class WikiElement extends Element implements CrawlConstants
                 } else {
                     $append = "";
                     if($name != 'pages') {
-                        $append = '&amp;page_name='. $data['PAGE_NAME'];
+                        $append = '&amp;page_name=' . $data['PAGE_NAME'];
                     }
-                    if (isset($data['OTHER_BACK_URL'])) {
+                    if(isset($data['OTHER_BACK_URL'])) {
                         $append .= $data['OTHER_BACK_URL'];
                     }
                     e($bar); ?><a href="<?php e($base_query .
-                        '&amp;arg='.$name.'&amp;a=wiki'.$append); ?>"><?php
-                        e($translation); ?></a><?php
+                        '&amp;arg=' . $name . '&amp;a=wiki' . $append); ?>"><?php
+                    e($translation); ?></a><?php
                 }
                 $bar = "|";
             }
@@ -292,15 +291,14 @@ class WikiElement extends Element implements CrawlConstants
             <input type="hidden" name="a" value="wiki" />
             <input type="hidden" name="arg" value="edit" />
             <?php
-            if(isset($data['BACK_PARAMS']))
-            {
-                foreach($data["BACK_PARAMS"] as
-                        $back_param_key => $back_param_value){
+            if(isset($data['BACK_PARAMS'])) {
+                foreach ($data["BACK_PARAMS"] as
+                         $back_param_key => $back_param_value) {
                     e('<input type="hidden" '
-                        . 'name="'.$back_param_key.
-                        '" value="'.
+                        . 'name="' . $back_param_key .
+                        '" value="' .
                         $back_param_value
-                        .'" />');
+                        . '" />');
                 }
             }
             ?>
diff --git a/views/wiki_view.php b/views/wiki_view.php
index 1e0b15c..09fac74 100644
--- a/views/wiki_view.php
+++ b/views/wiki_view.php
@@ -108,7 +108,7 @@ class WikiView extends View
                     if($name != 'pages') {
                         $append = '&amp;page_name='. $data['PAGE_NAME'];
                     }
-                    if (isset($data['OTHER_BACK_URL'])) {
+                    if(isset($data['OTHER_BACK_URL'])) {
                         $append .= $data['OTHER_BACK_URL'];
                     }
                     ?>
-- 
1.9.3 (Apple Git-50)

