_binary From b2e3836e469cc34855378470364c300ba1490a3c Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Thu, 23 Oct 2014 00:16:26 -0700
Subject: [PATCH 1/5] - Initial changes for seamless DB upgrade/new creations.

Signed-off-by: epinapala <epinapala@ebay.com>
---
 configs/config.php         |  4 ++-
 controllers/controller.php |  4 +--
 lib/upgrade_functions.php  | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/configs/config.php b/configs/config.php
index aec8feb..91a3e7a 100755
--- a/configs/config.php
+++ b/configs/config.php
@@ -37,7 +37,7 @@ if(!defined('BASE_DIR') ||
 /** Version number for upgrade function
  * @var int
  */
-define('YIOOP_VERSION', 24);
+define('YIOOP_VERSION', 25);
 /*
     pcre is an external library to php which can cause Yioop
     to seg fault if given instances of reg expressions with
@@ -272,6 +272,8 @@ define('USER_ROLE', 2);
 define('PUBLIC_GROUP_ID', 2);
 /** ID of the group to which all Yioop users belong */
 define('PUBLIC_USER_ID', 2);
+/** ID of the group to which all Yioop Help Wiki articles belong */
+define('HELP_GROUP_ID', 3);
 if(!PROFILE) {
     return;
 }
diff --git a/controllers/controller.php b/controllers/controller.php
index 271172d..9c73885 100755
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -271,8 +271,8 @@ abstract class Controller
         $data = array();
         $data["OTHER_BACK_URL"] = "";
         if(isset($_REQUEST['back_params'])) {
-            foreach ($_REQUEST['back_params'] as
-                     $back_param_key => $back_param_value) {
+            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]"
diff --git a/lib/upgrade_functions.php b/lib/upgrade_functions.php
index 4c249f7..d12175d 100644
--- a/lib/upgrade_functions.php
+++ b/lib/upgrade_functions.php
@@ -856,6 +856,74 @@ function upgradeDatabaseVersion24(&$db)
     }
 }
 /**
+ * Upgrades a Version 24 version of the Yioop! database to a Version 25 version
+ *
+ * @param object $db datasource to use to upgrade
+ */
+function upgradeDatabaseVersion25(&$db) {
+    /** For reading HELP_GROUP_ID**/
+    require_once BASE_DIR . "/configs/config.php";
+    /** For GroupModel::setPageName method */
+    require_once BASE_DIR . "/models/group_model.php";
+    $db->execute("DELETE FROM VERSION WHERE ID < 24");
+    $db->execute("UPDATE VERSION SET ID=25 WHERE ID=24");
+    $sql = "SELECT COUNT(*) AS NUM FROM GROUPS WHERE GROUP_ID=".HELP_GROUP_ID;
+    $result = $db->execute($sql);
+    $row = ($db->fetchArray($result));
+    $is_taken = intval($row['NUM']);
+    if ($is_taken > 0) {
+        //Get the max group Id , increment it to push the old group
+        $sql = "SELECT MAX(GROUP_ID) AS MAX_GROUP_ID FROM GROUPS";
+        $result = $db->execute($sql);
+        $row = $db->fetchArray($result);
+        $max_group_id = $row['MAX_GROUP_ID'] + 1;
+        $tables_to_update_group_id = array("GROUPS", "GROUP_ITEM", "GROUP_PAGE",
+            "GROUP_PAGE_HISTORY", "USER_GROUP");
+        foreach ($tables_to_update_group_id as $table) {
+            $sql = "UPDATE $table "
+                    . "Set GROUP_ID=$max_group_id "
+                    . "WHERE "
+                    . "GROUP_ID=". HELP_GROUP_ID;
+            $db->execute($sql);
+        }
+    }
+    //Insert the Help Group
+    $creation_time = microTimestamp();
+    $sql = "INSERT INTO GROUPS VALUES(" . HELP_GROUP_ID . ",'Help','"
+            . $creation_time . "','" . ROOT_ID . "','" . PUBLIC_JOIN . "', '"
+            . GROUP_READ . "', " . NON_VOTING_GROUP . ", " . FOREVER . ")";
+    $db->execute($sql);
+    $now = time();
+    $db->execute("INSERT INTO USER_GROUP VALUES (" . ROOT_ID . ", " .
+            HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
+    $db->execute("INSERT INTO USER_GROUP VALUES (" . PUBLIC_USER_ID . ", " .
+            HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
+    //Insert into Groups
+    $help_pages = array();
+    $help_pages = getWikiHelpPages();
+    foreach ($help_pages as $page_name => $page_content) {
+        $page_content = str_replace("&amp;", "&", $page_content);
+        $page_content = @htmlentities($page_content, ENT_QUOTES, "UTF-8");
+        $group_model = new GroupModel(DB_NAME, false);
+        $group_model->db = $db;
+        $group_model->setPageName(ROOT_ID, HELP_GROUP_ID, $page_name,
+                $page_content, "en-US", "Creating Default Pages", "$page_name "
+                . "Help Page Created!", "Discuss the page in this thread!");
+    }
+}
+
+function getWikiHelpPages()
+{
+    $help_pages = array();
+    $help_pages["Help Page 1"] = <<<EOD
+title=Help Page One
+description=This is a test page for Wiki help insertion.
+END_HEAD_VARS
+==Please ignore this page.==
+EOD;
+    return $help_pages;
+}
+/**
  * Used to insert a new activity into the database at a given acitivity_id
  *
  * Inserting at an ID rather than at the end is useful since activities are
-- 
1.9.3 (Apple Git-50)


From 24214cce1171bc81290d181a19d7d1901e87dbee Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Thu, 23 Oct 2014 22:30:21 -0700
Subject: [PATCH 2/5] - Create db working - Upgrade db works on up-reving the
 version

Signed-off-by: epinapala <epinapala@ebay.com>
---
 configs/createdb.php                      |  48 ++++++++++++++++++++-
 controllers/controller.php                |   4 +-
 data/default.db                           | Bin 105472 -> 123904 bytes
 lib/upgrade_functions.php                 |  68 +++++++++++++++++++-----------
 views/elements/managelocales_element.php  |  11 +++--
 views/elements/managemachines_element.php |  10 ++++-
 views/helpers/helpbutton_helper.php       |   2 +-
 views/helpers/searchform_helper.php       |   5 ++-
 8 files changed, 113 insertions(+), 35 deletions(-)

diff --git a/configs/createdb.php b/configs/createdb.php
index b917083..d0d87c6 100755
--- a/configs/createdb.php
+++ b/configs/createdb.php
@@ -125,6 +125,17 @@ $db->execute("INSERT INTO USER_GROUP VALUES (".ROOT_ID.", ".
     PUBLIC_GROUP_ID.", ".ACTIVE_STATUS.", $now)");
 $db->execute("INSERT INTO USER_GROUP VALUES (".PUBLIC_USER_ID.", ".
     PUBLIC_GROUP_ID.", ".ACTIVE_STATUS.", $now)");
+//Create a Group for Wiki HELP.
+$sql = "INSERT INTO GROUPS VALUES(" . HELP_GROUP_ID . ",'Help','" .
+    $creation_time . "','" . ROOT_ID . "',
+    '" . PUBLIC_JOIN . "', '" . GROUP_READ .
+    "', " . NON_VOTING_GROUP . ", " . FOREVER . ")";
+$db->execute($sql);
+$now = time();
+$db->execute("INSERT INTO USER_GROUP VALUES (" . ROOT_ID . ", " .
+    HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
+$db->execute("INSERT INTO USER_GROUP VALUES (" . PUBLIC_USER_ID . ", " .
+    HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
 $public_pages = array();
 $public_pages["404"] = <<<EOD
 title=Page Not Found
@@ -537,6 +548,41 @@ foreach($public_pages as $page_name => $page_content) {
         $page_content, "en-US", "Creating Default Pages",
         "$page_name Wiki Page Created!", "Discuss the page in this thread!");
 }
+//Insert Help pages
+$help_pages = getWikiHelpPages();
+foreach($help_pages as $page_name => $page_content) {
+    $page_content = str_replace("&amp;", "&", $page_content);
+    $page_content = @htmlentities($page_content, ENT_QUOTES, "UTF-8");
+    $group_model->setPageName(ROOT_ID, HELP_GROUP_ID, $page_name,
+        $page_content, "en-US", "Creating Default Pages",
+        "$page_name Help Page Created!", "Discuss the page in this thread!");
+}
+function getWikiHelpPages()
+{
+    $help_pages = array();
+    require_once(BASE_DIR . "/models/datasources/sqlite3_manager.php");
+    $default_dbm = new Sqlite3Manager();
+    $default_dbm->connect("", "", "", BASE_DIR . "/data/default_help.db");
+    if(!$default_dbm) {
+        return false;
+    }
+    $group_model = new GroupModel(DB_NAME, true);
+    $group_model->db = $default_dbm;
+    $page_list = $group_model->getPageList(HELP_GROUP_ID, "en-US", '', 0, 200);
+    foreach($page_list[1] as $page) {
+        if(isset($page['TITLE'])) {
+            $page_info = $group_model->getPageInfoByName(
+                HELP_GROUP_ID, $page['TITLE'], "en-US", "api");
+            $page_content = str_replace("&amp;", "&", $page_info['PAGE']);
+            $page_content = html_entity_decode($page_content, ENT_QUOTES,
+                "UTF-8");
+            $help_pages[$page['TITLE']] = $page_content;
+        }
+    }
+    return $help_pages;
+}
+
+/* End Help content insertion. */
 /* we insert 1 by 1 rather than comma separate as sqlite
    does not support comma separated inserts
  */
@@ -821,7 +867,5 @@ $db->disconnect();
 if(in_array(DBMS, array('sqlite','sqlite3' ))){
     chmod(CRAWL_DIR."/data/".DB_NAME.".db", 0666);
 }
-
-
 echo "Create DB succeeded\n";
 ?>
\ No newline at end of file
diff --git a/controllers/controller.php b/controllers/controller.php
index 9c73885..271172d 100755
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -271,8 +271,8 @@ abstract class Controller
         $data = array();
         $data["OTHER_BACK_URL"] = "";
         if(isset($_REQUEST['back_params'])) {
-            foreach($_REQUEST['back_params'] as
-                    $back_param_key => $back_param_value) {
+            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]"
diff --git a/data/default.db b/data/default.db
index 450ff35739b1fabc1f0b4769402cd3e8176feaad..90520040c3e598624d00d1108e059f097745108a 100644
GIT binary patch
diff --git a/lib/upgrade_functions.php b/lib/upgrade_functions.php
index d12175d..1e99c3c 100644
--- a/lib/upgrade_functions.php
+++ b/lib/upgrade_functions.php
@@ -857,21 +857,27 @@ function upgradeDatabaseVersion24(&$db)
 }
 /**
  * Upgrades a Version 24 version of the Yioop! database to a Version 25 version
+ * This version upgrade includes creation of Help group that holds help pages.
+ * Help Group is created with GROUP_ID=HELP_GROUP_ID. If a Group with
+ * Group_ID=HELP_GROUP_ID already exists,
+ * then that GROUP is moved to the end of the GROUPS table(Max group id is
+ * used).
  *
  * @param object $db datasource to use to upgrade
  */
-function upgradeDatabaseVersion25(&$db) {
+function upgradeDatabaseVersion25(&$db)
+{
     /** For reading HELP_GROUP_ID**/
     require_once BASE_DIR . "/configs/config.php";
     /** For GroupModel::setPageName method */
     require_once BASE_DIR . "/models/group_model.php";
     $db->execute("DELETE FROM VERSION WHERE ID < 24");
     $db->execute("UPDATE VERSION SET ID=25 WHERE ID=24");
-    $sql = "SELECT COUNT(*) AS NUM FROM GROUPS WHERE GROUP_ID=".HELP_GROUP_ID;
+    $sql = "SELECT COUNT(*) AS NUM FROM GROUPS WHERE GROUP_ID=" . HELP_GROUP_ID;
     $result = $db->execute($sql);
     $row = ($db->fetchArray($result));
     $is_taken = intval($row['NUM']);
-    if ($is_taken > 0) {
+    if($is_taken > 0) {
         //Get the max group Id , increment it to push the old group
         $sql = "SELECT MAX(GROUP_ID) AS MAX_GROUP_ID FROM GROUPS";
         $result = $db->execute($sql);
@@ -879,48 +885,62 @@ function upgradeDatabaseVersion25(&$db) {
         $max_group_id = $row['MAX_GROUP_ID'] + 1;
         $tables_to_update_group_id = array("GROUPS", "GROUP_ITEM", "GROUP_PAGE",
             "GROUP_PAGE_HISTORY", "USER_GROUP");
-        foreach ($tables_to_update_group_id as $table) {
+        foreach($tables_to_update_group_id as $table) {
             $sql = "UPDATE $table "
-                    . "Set GROUP_ID=$max_group_id "
-                    . "WHERE "
-                    . "GROUP_ID=". HELP_GROUP_ID;
+                . "Set GROUP_ID=$max_group_id "
+                . "WHERE "
+                . "GROUP_ID=" . HELP_GROUP_ID;
             $db->execute($sql);
         }
     }
     //Insert the Help Group
     $creation_time = microTimestamp();
-    $sql = "INSERT INTO GROUPS VALUES(" . HELP_GROUP_ID . ",'Help','" 
-            . $creation_time . "','" . ROOT_ID . "','" . PUBLIC_JOIN . "', '" 
-            . GROUP_READ . "', " . NON_VOTING_GROUP . ", " . FOREVER . ")";
+    $sql = "INSERT INTO GROUPS VALUES(" . HELP_GROUP_ID . ",'Help','"
+        . $creation_time . "','" . ROOT_ID . "','" . PUBLIC_JOIN . "', '"
+        . GROUP_READ . "', " . NON_VOTING_GROUP . ", " . FOREVER . ")";
     $db->execute($sql);
     $now = time();
     $db->execute("INSERT INTO USER_GROUP VALUES (" . ROOT_ID . ", " .
-            HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
+        HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
     $db->execute("INSERT INTO USER_GROUP VALUES (" . PUBLIC_USER_ID . ", " .
-            HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
+        HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
     //Insert into Groups
-    $help_pages = array();
     $help_pages = getWikiHelpPages();
-    foreach ($help_pages as $page_name => $page_content) {
+    foreach($help_pages as $page_name => $page_content) {
         $page_content = str_replace("&amp;", "&", $page_content);
         $page_content = @htmlentities($page_content, ENT_QUOTES, "UTF-8");
         $group_model = new GroupModel(DB_NAME, false);
         $group_model->db = $db;
-        $group_model->setPageName(ROOT_ID, HELP_GROUP_ID, $page_name, 
-                $page_content, "en-US", "Creating Default Pages", "$page_name "
-                . "Help Page Created!", "Discuss the page in this thread!");
+        $group_model->setPageName(ROOT_ID, HELP_GROUP_ID, $page_name,
+            $page_content, "en-US", "Creating Default Pages", "$page_name "
+            . "Help Page Created!", "Discuss the page in this thread!");
     }
 }
-
+/**
+ * Reads the Help articles from default db and returns the array of pages.
+ */
 function getWikiHelpPages()
 {
     $help_pages = array();
-    $help_pages["Help Page 1"] = <<<EOD
-title=Help Page One
-description=This is a test page for Wiki help insertion.
-END_HEAD_VARS
-==Please ignore this page.==
-EOD;
+    require_once(BASE_DIR . "/models/datasources/sqlite3_manager.php");
+    $default_dbm = new Sqlite3Manager();
+    $default_dbm->connect("", "", "", BASE_DIR . "/data/default.db");
+    if(!$default_dbm) {
+        return false;
+    }
+    $group_model = new GroupModel(DB_NAME, true);
+    $group_model->db = $default_dbm;
+    $page_list = $group_model->getPageList(HELP_GROUP_ID, "en-US", '', 0, 200);
+    foreach($page_list[1] as $page) {
+        if(isset($page['TITLE'])) {
+            $page_info = $group_model->getPageInfoByName(
+                HELP_GROUP_ID, $page['TITLE'], "en-US", "api");
+            $page_content = str_replace("&amp;", "&", $page_info['PAGE']);
+            $page_content = html_entity_decode($page_content, ENT_QUOTES,
+                "UTF-8");
+            $help_pages[$page['TITLE']] = $page_content;
+        }
+    }
     return $help_pages;
 }
 /**
diff --git a/views/elements/managelocales_element.php b/views/elements/managelocales_element.php
index 1621e12..941776c 100644
--- a/views/elements/managelocales_element.php
+++ b/views/elements/managelocales_element.php
@@ -60,7 +60,9 @@ class ManagelocalesElement extends Element
         } else {
             $this->renderLocaleForm($data);
         }
-        $data['TABLE_TITLE'] = tl('managelocales_element_locale_list');
+        $data['TABLE_TITLE'] = tl('managelocales_element_locale_list')
+            ."&nbsp;" . $this->view->helper("helpbutton")->render(
+            "Locale List", $data[CSRF_TOKEN],$_REQUEST['c']);
         $data['NO_FLOAT_TABLE'] = true;
         $data['ACTIVITY'] = 'manageLocales';
         $data['VIEW'] = $this->view;
@@ -128,10 +130,13 @@ class ManagelocalesElement extends Element
         if($editlocale) {
             e("<div class='float-opposite'><a href='$base_url'>".
                 tl('manageloecales_element_add_locale_form')."</a></div>");
-            e("<h2>".tl('managelocales_element_locale_info'). "</h2>");
+            e("<h2>".tl('managelocales_element_locale_info'). "&nbsp;");
         } else {
-            e("<h2>".tl('managelocales_element_add_locale'). "</h2>");
+            e("<h2>".tl('managelocales_element_add_locale'). "&nbsp;");
         }
+        e($this->view->helper("helpbutton")->render(
+            "Add Locale", $data[CSRF_TOKEN],$_REQUEST['c']));
+        e("</h2>");
         ?>
         <form id="addLocaleForm" method="post" action=''>
         <input type="hidden" name="c" value="admin" />
diff --git a/views/elements/managemachines_element.php b/views/elements/managemachines_element.php
index 7717fda..4644405 100644
--- a/views/elements/managemachines_element.php
+++ b/views/elements/managemachines_element.php
@@ -52,7 +52,10 @@ class ManagemachinesElement extends Element
     function render($data)
     {?>
         <div class="current-activity">
-        <h2><?php e(tl('managemachines_element_add_machine'))?></h2>
+        <h2><?php e(tl('managemachines_element_add_machine') . "&nbsp;");
+            e($this->view->helper("helpbutton")->render(
+                "Manage Machines", $data[CSRF_TOKEN],$_REQUEST['c']));
+            ?></h2>
         <form id="addMachineForm" method="post" action=''>
         <input type="hidden" name="c" value="admin" />
         <input type="hidden" name="<?php e(CSRF_TOKEN); ?>" value="<?php
@@ -96,7 +99,10 @@ class ManagemachinesElement extends Element
         </table>
         </form>
 
-        <h2><?php e(tl('managemachines_element_machine_info'))?></h2>
+        <h2><?php e(tl('managemachines_element_machine_info'). "&nbsp;");
+            e($this->view->helper("helpbutton")->render(
+                "Machine Information", $data[CSRF_TOKEN],$_REQUEST['c']));
+            ?></h2>
         <div id="machinestatus" >
         <p class="red"><?php
             e(tl('managemachines_element_awaiting_status'))?></p>
diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index 07d8803..adba3c2 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -71,7 +71,7 @@ class HelpbuttonHelper extends Helper
         $target_controller)
     {
         $is_mobile = MOBILE ? "true" : "false";
-        $wiki_group_id = "7";
+        $wiki_group_id = HELP_GROUP_ID;
         $api_controller = "api";
         $api_wiki_action = "wiki";
         $api_wiki_mode = "read";
diff --git a/views/helpers/searchform_helper.php b/views/helpers/searchform_helper.php
index e43f642..6459899 100644
--- a/views/helpers/searchform_helper.php
+++ b/views/helpers/searchform_helper.php
@@ -76,7 +76,10 @@ class SearchformHelper extends Helper
         }
         e("<div class='float-opposite'><a href='$old_base_url'>".
             $return_form_name."</a></div>");
-        e("<h2>$title</h2>");
+        e("<h2>$title" . "&nbsp;");
+        e($view->helper("helpbutton")->render(
+            "Discover Groups", $data[CSRF_TOKEN],$_REQUEST['c']));
+        e("</h2>");
         $item_sep = (MOBILE) ? "<br />" : "</td><td>";
         ?>
         <form id="search-form" method="post" action='./' autocomplete="off">
-- 
1.9.3 (Apple Git-50)


From 090eed9810f86ec91f91e856f948d640492ae521 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Sat, 25 Oct 2014 12:28:57 -0700
Subject: [PATCH 3/5] =?UTF-8?q?Bug=20fixes=20and=20refactoring.=20-=20Fixe?=
 =?UTF-8?q?s=20issue=20with=20h2=20styles=20inside=20wiki=20html=20default?=
 =?UTF-8?q?ing=20to=20blue=20styling.=20-=20Fixes=20an=20issue=20with=20PH?=
 =?UTF-8?q?P=20<=3D=205.3=20incompatible=20http=5Fresponse=5Fcode,=20using?=
 =?UTF-8?q?=20a=20abckward=20compatible=20way=20from=20now=20on.=20-=20Beh?=
 =?UTF-8?q?avior=20of=20the=20way=20wiki=20toggle=20help=20is=20changed.?=
 =?UTF-8?q?=20clicking=20on=20help=20will=20only=20open=20the=20help.=20th?=
 =?UTF-8?q?is=20way,=20clicking=20on=20a=20help=20button=20will=20refresh?=
 =?UTF-8?q?=20the=20help=20when=20another=20help=20article=20is=20already?=
 =?UTF-8?q?=20open.Close=20is=20now=20done=20with=20a=20close=20button.=20?=
 =?UTF-8?q?-=20Fixes=20an=20issue=20with=20help=20not=20auto-opening=20whe?=
 =?UTF-8?q?n=20spaces=20are=20used=20in=20help=20name.=20querySelectorAll?=
 =?UTF-8?q?=20chokes=20with=20an=20invalid=20CSS=20selector.=20-Fixes=20is?=
 =?UTF-8?q?sue=20where=20back-button=20is=20not=20populated=20when=20the?=
 =?UTF-8?q?=20user=20:=20uploads=20resource,=20deletes=20resource,=20goes?=
 =?UTF-8?q?=20to=20history=20page.=20Also=20the=20default=20back=20button?=
 =?UTF-8?q?=20on=20wiki=20history=20page=20loads=20when=20only=20the=20wik?=
 =?UTF-8?q?i=20back=20button=20is=20not=20populated.=20-=20Remove=20last?=
 =?UTF-8?q?=20param=20from=20help=20button=20render,=20instead=20call=20$?=
 =?UTF-8?q?=5FREQUEST[=E2=80=98c=E2=80=99]=20directly=20in=20render=20meth?=
 =?UTF-8?q?od.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: epinapala <epinapala@ebay.com>
---
 controllers/controller.php                |  4 ++--
 css/search.css                            | 29 +++++++++++++++++++++-------
 scripts/basic.js                          |  1 -
 views/elements/api_element.php            |  2 +-
 views/elements/help_element.php           | 16 ++++++++++++++--
 views/elements/managegroups_element.php   |  2 +-
 views/elements/managelocales_element.php  |  2 +-
 views/elements/managemachines_element.php |  4 ++--
 views/elements/wiki_element.php           | 32 ++++++++++++++++++++++++++-----
 views/helpers/helpbutton_helper.php       |  5 ++---
 views/helpers/searchform_helper.php       |  2 +-
 11 files changed, 73 insertions(+), 26 deletions(-)

diff --git a/controllers/controller.php b/controllers/controller.php
index 271172d..ef25191 100755
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -287,9 +287,9 @@ abstract class Controller
             }
             $data['SCRIPT'] .= "\n" .
                 'var matches = '
-                . 'document.querySelectorAll("[data-pagename='
+                . 'document.querySelectorAll(\'[data-pagename="'
                 . $data['OPEN_HELP_PAGE']
-                . ']");'
+                . '"]\');'
                 . "matches[0].click();"
                 . "\n";
         }
diff --git a/css/search.css b/css/search.css
index 26e8ee1..8c67524 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2842,14 +2842,14 @@ table.wikitable > caption
 }
 
 .small-margin-help-pane {
-display: none;
-width: 380px;
-border: 2px solid #0094ff;
-left: -1in;
-top: 1in;
+    display: none;
+    width: 380px;
+    border: 2px solid #0094ff;
+    left: -1in;
+    top: 1in;
 }
 
-.help-pane h2 {
+.help-title {
     background:#0094ff;
     color:white;
     padding:10px;
@@ -2860,4 +2860,19 @@ top: 1in;
 }
 .wiki-resource-image{
     max-width:100%;
-}
\ No newline at end of file
+}
+
+#help-close{
+    margin-top: -25px;
+    bottom: 50px;
+    cursor: pointer;
+    color: white;
+    border: 1px solid #0094ff;
+    background: #0094ff;
+    font-size: 24px;
+    font-weight: bold;
+    line-height: 1px;
+    padding: 11px 3px;
+    border-radius: 20px;
+    margin-right: -10px;
+}
diff --git a/scripts/basic.js b/scripts/basic.js
index 4b15a3c..0eaeffa 100755
--- a/scripts/basic.js
+++ b/scripts/basic.js
@@ -411,7 +411,6 @@ function displayHelpForId(help_point, is_mobile, target_controller,
 {
     if((elt("help-frame").style.display) === "block") {
         toggleHelp('help-frame', is_mobile, target_controller);
-        return;
     }
     var tl = eval('(' + help_point.getAttribute("data-tl") + ')');
     getPageWithCallback("?c=" + api_controller + "&group_id=" +
diff --git a/views/elements/api_element.php b/views/elements/api_element.php
index f847cf3..3743aa6 100644
--- a/views/elements/api_element.php
+++ b/views/elements/api_element.php
@@ -101,7 +101,7 @@ class ApiElement extends Element implements CrawlConstants {
         }
 
         header("Content-Type: application/json");
-        http_response_code($http_code);
+        header('X-PHP-Response-Code: '.$http_code, true, $http_code);
         e(json_encode($out_array));
         exit();
     }
diff --git a/views/elements/help_element.php b/views/elements/help_element.php
index f1a32ff..d6bac13 100644
--- a/views/elements/help_element.php
+++ b/views/elements/help_element.php
@@ -57,8 +57,14 @@ class HelpElement extends Element {
             if (MOBILE) { ?>
                 <div id="mobile-help">
                     <div id="help-frame" class="frame help-pane">
+                        <div class="float-opposite">
+                            <input id="help-close" type="button"
+                                   onclick="toggleHelp('help-frame', 'true',
+                                   '<?php e($_REQUEST['c']);?>');"
+                                   value="X" />
+                        </div>
                         <div id="help-frame-head">
-                            <h2 id="page_name"></h2>
+                            <h2 id="page_name" class="help-title"></h2>
                         </div>
 
                         <div id="help-frame-body" class="wordwrap">
@@ -82,8 +88,14 @@ class HelpElement extends Element {
                 <div id="<?php e($help_id); ?>">
                   <div id="help-frame" class="frame help-pane <?php
                   e($help_class_add); ?>">
+                      <div class="float-opposite">
+                          <input id="help-close" type="button"
+                                 onclick="toggleHelp('help-frame', false,
+                                     '<?php e($_REQUEST['c']);?>');"
+                                 value="X" />
+                      </div>
                       <div id="help-frame-head">
-                          <h2 id="page_name"></h2>
+                          <h2 id="page_name" class="help-title"></h2>
                       </div>
 
                     <div id="help-frame-body" class="wordwrap">
diff --git a/views/elements/managegroups_element.php b/views/elements/managegroups_element.php
index 0a55d10..e360aeb 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(
-                            "Main", $data[CSRF_TOKEN],$_REQUEST['c']));
+                            "Browse Groups", $data[CSRF_TOKEN]));
                     ?></td>
                 <?php
                 }
diff --git a/views/elements/managelocales_element.php b/views/elements/managelocales_element.php
index 941776c..66cb435 100644
--- a/views/elements/managelocales_element.php
+++ b/views/elements/managelocales_element.php
@@ -62,7 +62,7 @@ class ManagelocalesElement extends Element
         }
         $data['TABLE_TITLE'] = tl('managelocales_element_locale_list')
             ."&nbsp;" . $this->view->helper("helpbutton")->render(
-            "Locale List", $data[CSRF_TOKEN],$_REQUEST['c']);
+            "Locale List", $data[CSRF_TOKEN]);
         $data['NO_FLOAT_TABLE'] = true;
         $data['ACTIVITY'] = 'manageLocales';
         $data['VIEW'] = $this->view;
diff --git a/views/elements/managemachines_element.php b/views/elements/managemachines_element.php
index 4644405..6ac7e93 100644
--- a/views/elements/managemachines_element.php
+++ b/views/elements/managemachines_element.php
@@ -54,7 +54,7 @@ class ManagemachinesElement extends Element
         <div class="current-activity">
         <h2><?php e(tl('managemachines_element_add_machine') . "&nbsp;");
             e($this->view->helper("helpbutton")->render(
-                "Manage Machines", $data[CSRF_TOKEN],$_REQUEST['c']));
+                "Manage Machines", $data[CSRF_TOKEN]));
             ?></h2>
         <form id="addMachineForm" method="post" action=''>
         <input type="hidden" name="c" value="admin" />
@@ -101,7 +101,7 @@ class ManagemachinesElement extends Element
 
         <h2><?php e(tl('managemachines_element_machine_info'). "&nbsp;");
             e($this->view->helper("helpbutton")->render(
-                "Machine Information", $data[CSRF_TOKEN],$_REQUEST['c']));
+                "Machine Information", $data[CSRF_TOKEN]));
             ?></h2>
         <div id="machinestatus" >
         <p class="red"><?php
diff --git a/views/elements/wiki_element.php b/views/elements/wiki_element.php
index 82de9d5..04fdc90 100644
--- a/views/elements/wiki_element.php
+++ b/views/elements/wiki_element.php
@@ -268,9 +268,13 @@ class WikiElement extends Element implements CrawlConstants
         $base_url = "?c=".$data['CONTROLLER']."&amp;a=wiki&amp;".
             CSRF_TOKEN.'='.$data[CSRF_TOKEN]."&amp;group_id=".
             $data['GROUP']['GROUP_ID'];
+        $append = "";
+        if(isset($data['OTHER_BACK_URL'])) {
+            $append = $data['OTHER_BACK_URL'];
+        }
         ?>
         <div class="float-opposite" style="position:relative; top:35px;">
-        [<a href="<?php e($base_url); ?>&amp;<?php
+        [<a href="<?php e($base_url . $append); ?>&amp;<?php
             e('&amp;arg=history&amp;page_id='.$data['PAGE_ID']); ?>"
         ><?php e(tl('wiki_element_history'))?></a>]
         [<a href="?c=<?php e($data['CONTROLLER']); ?>&amp;a=groupFeeds&amp;<?php
@@ -432,6 +436,18 @@ 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
@@ -581,9 +597,13 @@ class WikiElement extends Element implements CrawlConstants
                             "</button></td>");
                     }
                     if(!$read_mode) {
+                        $append = "";
+                        if(isset($data['OTHER_BACK_URL'])) {
+                            $append .= $data['OTHER_BACK_URL'];
+                        }
                         e("<td>[<a href='$base_url&amp;arg=edit&amp;page_name=".
                             $data['PAGE_NAME'].
-                            "&amp;delete=$name'>X</a>]</td>");
+                            "&amp;delete=$name$append'>X</a>]</td>");
                     }
                     e("</tr>");
                 }
@@ -671,12 +691,14 @@ class WikiElement extends Element implements CrawlConstants
         $base_query = "?c={$data['CONTROLLER']}&amp;".CSRF_TOKEN."=".
             $data[CSRF_TOKEN] . "&amp;group_id=".
             $data["GROUP"]["GROUP_ID"]."&amp;a=wiki";
-        ?>
-        <div class="float-opposite"><a href="<?php e($base_query .
-                    '&amp;arg=edit&amp;a=wiki&amp;page_name='.
+        //For now, Do not duplicate the back button if back url is present.
+        if(!isset($data['OTHER_BACK_URL']) || $data['OTHER_BACK_URL'] == '') {
+        ?><div class="float-opposite"><a href="<?php e($base_query .
+                    '&amp;arg=edit&amp;a=wiki&amp;page_name=' .
                     $data['PAGE_NAME']); ?>"><?php
             e(tl("wiki_view_back")); ?></a></div>
         <?php
+        }
         if(count($data['HISTORY']) > 1) { ?>
             <div>
             <form id="differenceForm" method="get" action='#'>
diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index adba3c2..1aa678a 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -67,8 +67,7 @@ class HelpbuttonHelper extends Helper
      * @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)
     {
         $is_mobile = MOBILE ? "true" : "false";
         $wiki_group_id = HELP_GROUP_ID;
@@ -80,7 +79,7 @@ class HelpbuttonHelper extends Helper
                     onclick="javascript:displayHelpForId(
                     this,'
         . $is_mobile . ',\''
-        . $target_controller . '\',\''
+        . $_REQUEST['c'] . '\',\''
         . $_REQUEST['a'] . '\',\''
         . CSRF_TOKEN . '\',\''
         . $csrf_token_value . "','$wiki_group_id','$api_controller',"
diff --git a/views/helpers/searchform_helper.php b/views/helpers/searchform_helper.php
index 6459899..c0d842f 100644
--- a/views/helpers/searchform_helper.php
+++ b/views/helpers/searchform_helper.php
@@ -78,7 +78,7 @@ class SearchformHelper extends Helper
             $return_form_name."</a></div>");
         e("<h2>$title" . "&nbsp;");
         e($view->helper("helpbutton")->render(
-            "Discover Groups", $data[CSRF_TOKEN],$_REQUEST['c']));
+            "Discover Groups", $data[CSRF_TOKEN]));
         e("</h2>");
         $item_sep = (MOBILE) ? "<br />" : "</td><td>";
         ?>
-- 
1.9.3 (Apple Git-50)


From 67d3e359e6ab76e25d66626d12d4232b4fc665a2 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Sat, 25 Oct 2014 12:57:48 -0700
Subject: [PATCH 4/5] Fixes Issue where back button does not redirect back
 properly when child help-edit is initiated from child pages.

Signed-off-by: epinapala <epinapala@ebay.com>
---
 scripts/basic.js                    | 30 +++++++++++++++++++-----------
 views/helpers/helpbutton_helper.php | 13 +++++++++++++
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/scripts/basic.js b/scripts/basic.js
index 0eaeffa..9aa0225 100755
--- a/scripts/basic.js
+++ b/scripts/basic.js
@@ -413,6 +413,8 @@ function displayHelpForId(help_point, is_mobile, target_controller,
         toggleHelp('help-frame', is_mobile, target_controller);
     }
     var tl = eval('(' + help_point.getAttribute("data-tl") + ')');
+    var back_params = eval('(' + help_point.getAttribute("data-back-params")
+    + ')');
     getPageWithCallback("?c=" + api_controller + "&group_id=" +
         help_group_id + "&" +
         "arg=" + mode + "&" +
@@ -437,7 +439,8 @@ function displayHelpForId(help_point, is_mobile, target_controller,
                 csrf_token_key,
                 csrf_token_value,
                 help_group_id,
-                data.page_name) + '">' +
+                data.page_name,
+                back_params) + '">' +
             tl["wiki_view_edit"] + '</a>]';
             toggleHelp('help-frame', is_mobile, target_controller);
         },
@@ -457,15 +460,20 @@ 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, back_params)
 {
-    return '?c=' + target_controller +
-    '&' + 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;
+    var edit_link = '?c=' + target_controller +
+        '&' + 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;
+    for (var key in back_params) {
+        var value = back_params[key];
+        edit_link += "&back_params[" + key + "]=" + value;
+    }
+    return edit_link;
 }
\ No newline at end of file
diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index 1aa678a..cfe013a 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -56,6 +56,18 @@ class HelpbuttonHelper extends Helper
             'wiki_view_edit :"' . tl('wiki_view_edit') . '",' .
             'wiki_view_read :"' . tl('wiki_view_read') . '"' .
             "}";
+        $this->backParams = "{";
+        $back_params_array = array_diff_key($_REQUEST, array_flip(
+            array("a", "c", CSRF_TOKEN, "open_help_page")
+        ));
+        $last_key = end(array_keys($back_params_array));
+        foreach($back_params_array as $key => $value) {
+            $this->backParams .= $key . ' : "' . $value . '"';
+            if($key != $last_key) {
+                $this->backParams .= ',';
+            }
+        }
+        $this->backParams .= "}";
         parent::__construct();
     }
     /**
@@ -76,6 +88,7 @@ class HelpbuttonHelper extends Helper
         $api_wiki_mode = "read";
         return '<button type="button"
                     data-tl=\'' . $this->localizationdata . '\'
+                    data-back-params=\'' . $this->backParams . '\'
                     onclick="javascript:displayHelpForId(
                     this,'
         . $is_mobile . ',\''
-- 
1.9.3 (Apple Git-50)


From 863b2970168c6f3bf245f0814f74a6918fe48cc3 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Sun, 26 Oct 2014 14:28:47 -0700
Subject: [PATCH 5/5] Fixes an issue on PHP<=5.3 with html_entity_decode. minor
 formatting cleanup. clean up help styles.

---
 css/search.css                      | 29 ++++++-----
 lib/upgrade_functions.php           |  9 ++--
 views/elements/api_element.php      | 44 +++++++++--------
 views/elements/help_element.php     | 98 +++++++++++++++++++------------------
 views/helpers/helpbutton_helper.php |  1 +
 5 files changed, 98 insertions(+), 83 deletions(-)

diff --git a/css/search.css b/css/search.css
index 8c67524..7a42778 100755
--- a/css/search.css
+++ b/css/search.css
@@ -2852,7 +2852,9 @@ table.wikitable > caption
 .help-title {
     background:#0094ff;
     color:white;
-    padding:10px;
+    font-size: 16pt;
+    margin: 0;
+    padding: .05in;
 }
 .help-pane p {
     color:#333;
@@ -2862,17 +2864,22 @@ table.wikitable > caption
     max-width:100%;
 }
 
-#help-close{
-    margin-top: -25px;
+.help-button{
     bottom: 50px;
     cursor: pointer;
-    color: white;
-    border: 1px solid #0094ff;
-    background: #0094ff;
-    font-size: 24px;
+    border: 1px solid #2d2bdb;
+    font-size: 20px;
     font-weight: bold;
-    line-height: 1px;
-    padding: 11px 3px;
-    border-radius: 20px;
-    margin-right: -10px;
+    line-height: 0.5px;
+    padding: 10px 3px;
 }
+
+button.close{
+    background: #dc143c;
+    color: whitesmoke;
+}
+
+button.default{
+    background: #d3d3d3;
+    color: black;
+}
\ No newline at end of file
diff --git a/lib/upgrade_functions.php b/lib/upgrade_functions.php
index 1e99c3c..06e24ad 100644
--- a/lib/upgrade_functions.php
+++ b/lib/upgrade_functions.php
@@ -863,7 +863,7 @@ function upgradeDatabaseVersion24(&$db)
  * then that GROUP is moved to the end of the GROUPS table(Max group id is
  * used).
  *
- * @param object $db datasource to use to upgrade
+ * @param object $db data source to use to upgrade
  */
 function upgradeDatabaseVersion25(&$db)
 {
@@ -873,7 +873,8 @@ function upgradeDatabaseVersion25(&$db)
     require_once BASE_DIR . "/models/group_model.php";
     $db->execute("DELETE FROM VERSION WHERE ID < 24");
     $db->execute("UPDATE VERSION SET ID=25 WHERE ID=24");
-    $sql = "SELECT COUNT(*) AS NUM FROM GROUPS WHERE GROUP_ID=" . HELP_GROUP_ID;
+    $sql = "SELECT COUNT(*) AS NUM FROM GROUPS WHERE GROUP_ID=" .
+        HELP_GROUP_ID;
     $result = $db->execute($sql);
     $row = ($db->fetchArray($result));
     $is_taken = intval($row['NUM']);
@@ -883,7 +884,8 @@ function upgradeDatabaseVersion25(&$db)
         $result = $db->execute($sql);
         $row = $db->fetchArray($result);
         $max_group_id = $row['MAX_GROUP_ID'] + 1;
-        $tables_to_update_group_id = array("GROUPS", "GROUP_ITEM", "GROUP_PAGE",
+        $tables_to_update_group_id = array("GROUPS", "GROUP_ITEM",
+            "GROUP_PAGE",
             "GROUP_PAGE_HISTORY", "USER_GROUP");
         foreach($tables_to_update_group_id as $table) {
             $sql = "UPDATE $table "
@@ -916,6 +918,7 @@ function upgradeDatabaseVersion25(&$db)
             . "Help Page Created!", "Discuss the page in this thread!");
     }
 }
+
 /**
  * Reads the Help articles from default db and returns the array of pages.
  */
diff --git a/views/elements/api_element.php b/views/elements/api_element.php
index 3743aa6..2d9b8d2 100644
--- a/views/elements/api_element.php
+++ b/views/elements/api_element.php
@@ -37,7 +37,6 @@ if (!defined('BASE_DIR')) {
 }
 /** Loads common constants for web crawling */
 require_once BASE_DIR . "/lib/crawl_constants.php";
-
 /**
  * Element responsible for drawing wiki pages in either admin or wiki view
  * It is also responsible for rendering wiki history pages, and listings of
@@ -47,8 +46,8 @@ require_once BASE_DIR . "/lib/crawl_constants.php";
  * @package seek_quarry
  * @subpackage element
  */
-class ApiElement extends Element implements CrawlConstants {
-
+class ApiElement extends Element implements CrawlConstants
+{
     /**
      * Draw a wiki page for group, or, depending on $data['MODE'] a listing
      * of all pages for a group, or the history of revisions of a given page
@@ -57,53 +56,56 @@ class ApiElement extends Element implements CrawlConstants {
      * @param array $data fields contain data about the page being
      * displayeed or edited, or the list of pages being displayed.
      */
-    function render($data) {
+    function render($data)
+    {
         $logged_in = isset($data["ADMIN"]) && $data["ADMIN"];
-        $can_edit = $logged_in && isset($data["CAN_EDIT"]) && $data["CAN_EDIT"];
+        $can_edit = $logged_in && isset($data["CAN_EDIT"]) &&
+            $data["CAN_EDIT"];
         $this->renderJsonDocument($data, $can_edit, $logged_in);
     }
-
     /**
      * Used to send a Wiki content response for reading. If the page does
      * not exist various create/login-to-create etc messages are displayed
      * depending of it the user is logged in. and has write permissions
      * on the group.
+     *
      * @param array $data fields PAGE used for page contents
      * @param bool $can_edit whether the current user has permissions to
      *     edit or create this page
      * @param bool $logged_in whethe current user is logged in or not
      */
-    function renderJsonDocument($data, $can_edit, $logged_in) {
+    function renderJsonDocument($data, $can_edit, $logged_in)
+    {
         $out_array = array();
         $http_code = 0;
-        if ($data["PAGE"]) {
+        if($data["PAGE"]) {
             $out_array["wiki_content"] = html_entity_decode($data['PAGE'],
-                    ENT_QUOTES);
+                ENT_QUOTES, 'UTF-8');
             $out_array['group_id'] = $data['GROUP']['GROUP_ID'];
             $out_array['group_name'] = $data['GROUP']['GROUP_NAME'];
             $out_array['page_id'] = $data['PAGE_ID'];
             $out_array['page_name'] = $data['PAGE_NAME'];
             $http_code = 200;
-        } else if (!$logged_in) {
-            $out_array["logged_in"] = false;
-            $http_code = 401;
+        } else {
+            if(!$logged_in) {
+                $out_array["logged_in"] = false;
+                $http_code = 401;
+            }
         }
-        if ($can_edit) {
+        if($can_edit) {
             $out_array["can_edit"] = true;
         }
-
-        if (isset($data['errors']) && count($data['errors']) > 0) {
+        if(isset($data['errors']) && count($data['errors']) > 0) {
             $out_array['errors'] = json_encode(
-                    array_map(
-                            function($string) {
-                        return html_entity_decode($string, ENT_QUOTES);
+                array_map(
+                    function ($string){
+                        return html_entity_decode($string, ENT_QUOTES,
+                            'UTF-8');
                     }, $data['errors']));
         }
-
         header("Content-Type: application/json");
-        header('X-PHP-Response-Code: '.$http_code, true, $http_code);
+        header('X-PHP-Response-Code: ' . $http_code, true, $http_code);
         e(json_encode($out_array));
         exit();
     }
-
 }
diff --git a/views/elements/help_element.php b/views/elements/help_element.php
index d6bac13..3acdc83 100644
--- a/views/elements/help_element.php
+++ b/views/elements/help_element.php
@@ -34,69 +34,72 @@ if (!defined('BASE_DIR')) {
     echo "BAD REQUEST";
     exit();
 }
-
 /**
  * This element is used to display the list of available activities
  * in the AdminView
  *
  * @author Eswara Rajesh Pinapala
- *
  * @package seek_quarry
  * @subpackage element
  */
-class HelpElement extends Element {
-
+class HelpElement extends Element
+{
     /**
      * Displays a list of admin activities
      *
-     * @param array $data  available activities and CSRF token
+     * @param array $data available activities and CSRF token
      */
-    function render($data) {
+    function render($data)
+    {
         ?>
         <?php
-            if (MOBILE) { ?>
-                <div id="mobile-help">
-                    <div id="help-frame" class="frame help-pane">
-                        <div class="float-opposite">
-                            <input id="help-close" type="button"
-                                   onclick="toggleHelp('help-frame', 'true',
-                                   '<?php e($_REQUEST['c']);?>');"
-                                   value="X" />
-                        </div>
-                        <div id="help-frame-head">
-                            <h2 id="page_name" class="help-title"></h2>
-                        </div>
+        if(MOBILE) {
+            ?>
+            <div id="mobile-help">
+                <div id="help-frame" class="frame help-pane">
+                    <div class="float-opposite">
+                        <button id="help-close" type="button"
+                                class="help-button close"
+                                onclick="toggleHelp('help-frame', 'true',
+                                    '<?php e($_REQUEST['c']); ?>');">X
+                        </button>
+                    </div>
+                    <div id="help-frame-head">
+                        <h2 id="page_name" class="help-title"></h2>
+                    </div>
 
-                        <div id="help-frame-body" class="wordwrap">
+                    <div id="help-frame-body" class="wordwrap">
 
-                        </div>
-                        <div id="help-frame-editor" class="wordwrap">
+                    </div>
+                    <div id="help-frame-editor" class="wordwrap">
 
-                        </div>
                     </div>
                 </div>
-            <?php } else {
-                $help_class_add = "";
-                $help_id = "";
-                if($data['c'] != 'admin'){
-                    $help_class_add = "small-margin-help-pane";
-                    $help_id ="small-margin-help";
-                }else{
-                    $help_id = "help";
-                }
-                ?>
-                <div id="<?php e($help_id); ?>">
-                  <div id="help-frame" class="frame help-pane <?php
-                  e($help_class_add); ?>">
-                      <div class="float-opposite">
-                          <input id="help-close" type="button"
-                                 onclick="toggleHelp('help-frame', false,
-                                     '<?php e($_REQUEST['c']);?>');"
-                                 value="X" />
-                      </div>
-                      <div id="help-frame-head">
-                          <h2 id="page_name" class="help-title"></h2>
-                      </div>
+            </div>
+        <?php
+        } else {
+            $help_class_add = "";
+            $help_id = "";
+            if($data['c'] != 'admin') {
+                $help_class_add = "small-margin-help-pane";
+                $help_id = "small-margin-help";
+            } else {
+                $help_id = "help";
+            }
+            ?>
+            <div id="<?php e($help_id); ?>">
+                <div id="help-frame" class="frame help-pane <?php
+                e($help_class_add); ?>">
+                    <div class="float-opposite">
+                        <button id="help-close" type="button"
+                                class="help-button close"
+                                onclick="toggleHelp('help-frame', false,
+                                    '<?php e($_REQUEST['c']); ?>');">X
+                        </button>
+                    </div>
+                    <div id="help-frame-head">
+                        <h2 id="page_name" class="help-title"></h2>
+                    </div>
 
                     <div id="help-frame-body" class="wordwrap">
 
@@ -104,11 +107,10 @@ class HelpElement extends Element {
                     <div id="help-frame-editor" class="wordwrap">
 
                     </div>
-                  </div>
                 </div>
-                <?php
-            }
+            </div>
+        <?php
+        }
     }
-
 }
 ?>
\ No newline at end of file
diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index cfe013a..92a5633 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -87,6 +87,7 @@ class HelpbuttonHelper extends Helper
         $api_wiki_action = "wiki";
         $api_wiki_mode = "read";
         return '<button type="button"
+                    class="help-button default"
                     data-tl=\'' . $this->localizationdata . '\'
                     data-back-params=\'' . $this->backParams . '\'
                     onclick="javascript:displayHelpForId(
-- 
1.9.3 (Apple Git-50)

