Commit 2ad2c705 by Aleksandar Hristov

fix for sidebar on mobile/tablet

1 parent 87bbc398
......@@ -4,7 +4,11 @@
* User: aleksandarhristov
* Date: 27.01.15
* Time: 11:31
*/
#################################################
* create.php
* this script creates new pages/sections by adding them to the database
*#################################################
**/
//include the smarty class and the global functions
require "libs/Smarty.class.php";
......
<?php
/**
* edit.php
* this script is used to update the title/text of a page/section
* it works with editor.php
*/
//include the smarty class and the global functions
require "libs/Smarty.class.php";
require "global_functions.php";
......@@ -23,28 +27,46 @@ $smarty->assign("db_page_title", get_pages());
$smarty->assign("page_section", get_sections());
//if the user hasn't submitted the changes they made in editor.php
if (!isset($_POST['editor_btn_submit']))
{
$smarty->display("tpl/edit.tpl");
}
//else if they have submitted the changes they made in editor.php
else
{
//get what we want to edit (page or section)
$to_edit = $_POST['to_edit'];
//if we want to edit a page
if($to_edit == "page")
{
//get the old title of the page (currently in the database) we want to edit
$page_to_edit = $_POST['old_title'];
//if theres no title value display the failure template with the error message
if(empty($page_to_edit))
{
$smarty->assign("error", "Something went wrong. Please try to fill the form again.");
$smarty->display("tpl/failure.tpl");
}
//else if there is a value for the old (current) title
else
{
//find the id of this page by using the title
$id = $db->querySingle("SELECT id FROM pages WHERE title = '$page_to_edit'");
//get the new title submitted by the user
$title = $_POST['new_title'];
//get the new text submitted by the user
$text = $db->escapeString($_POST['new_text']);
//update the page in the database with the new title and text
$query = $db->exec("UPDATE pages SET title = '$title', text = '$text' WHERE id = '$id'");
//if something went wrong show the failure template with the error message
if(!$query)
{
......@@ -59,23 +81,33 @@ else
}
}
}
//else if the user edited a section
else if($to_edit == "section")
{
//get the old (currently in the database) title of the section
$old_title = urldecode($_POST['old_title']);
//if it's empty display the failure template with the error message
if(empty($old_title))
{
$smarty->assign("error", "Something went wrong. Please try to fill the form again.");
$smarty->display("tpl/failure.tpl");
}
//else if it's not empty
else
{
//get the page_id and use it together with the old title to find the id of the section we want to edit
$section_to_edit = $old_title;
$page_id = $_POST['page_id'];
$id = $db->querySingle("SELECT id FROM sections WHERE page_id = '$page_id' AND title = '$section_to_edit'");
//get the new values for the text and title and update the row for this section in the database
$title = $_POST['new_title'];
$text = $db->escapeString($_POST['new_text']);
$query = $db->exec("UPDATE sections SET title = '$title', text = '$text' WHERE id = '$id'");
//if something went wrong show the failure template with the error message
if(!$query)
{
......
......@@ -16,18 +16,24 @@ $smarty = new Smarty;
//connect to the database
$db = new SQLite3('wiki.db');
//get the selected option for what the user wants to edit (page or section)
$to_edit = $_POST['select_option'];
$smarty->assign("to_edit", $to_edit);
//if the user wants to edit a page
if($to_edit == "page")
{
//if theres no title value display the failure template with the error message
if(empty($_POST['page_to_edit']))
{
$smarty->assign("error", "Something went wrong. Please try to fill the form again.");
$smarty->display("tpl/failure.tpl");
}
//else if there is a value for the title of the page the user wants to edit
else
{
//assign the old text, page_id, old title etc. and display the editor template
$page_to_edit = $_POST['page_to_edit'];
$smarty->assign("old_title", $page_to_edit);
$old_text = $db->querySingle("SELECT text FROM pages WHERE title='$page_to_edit'");
......@@ -36,15 +42,20 @@ if($to_edit == "page")
$smarty->display("tpl/editor.tpl");
}
}
//else if the user wants to edit a section
else if($to_edit == "section")
{
//if theres no title value display the failure template with the error message
if(empty($_POST['section_to_edit']))
{
$smarty->assign("error", "Something went wrong. Please try to fill the form again.");
$smarty->display("tpl/failure.tpl");
}
//else if there is a value for the title of the section the user wants to edit
else
{
//assign the old text, page_id, old title etc. and display the editor template
$old_title = $_POST['section_to_edit'];
$old_title = explode(": ", $old_title);
$section_to_edit = $old_title[1];
......
......@@ -17,16 +17,6 @@ $current_page=$_SERVER['PHP_SELF'];
//assign a value to the current page variable in the admin sidebar wrapper template using the current_page() function from global_functions.php
$smarty->assign("current_page",current_page());
$smarty->assign("h1", "# H1");
$smarty->assign("h2", "## H2");
$smarty->assign("h3", "### H3");
$smarty->assign("h4", "#### H4");
$smarty->assign("h5", "##### H5");
$smarty->assign("h6", "###### H6");
$smarty->assign("em", "*Text*");
$smarty->assign("bold", "**Text**");
$smarty->assign("strike", "~~Text~~");
$smarty->display("tpl/faq.tpl");
?>
\ No newline at end of file
......@@ -43,7 +43,7 @@ function get_pages_id()
function get_sections()
{
global $db;
$pages = $db->query("SELECT * FROM sections");
$pages = $db->query("SELECT * FROM sections ORDER BY page_id");
$page_section=array();
$i=0;
......
......@@ -24,7 +24,7 @@ $url=$_SERVER['REQUEST_URI'];
//gotta solve this, it's not certain that there's a page with id=1
if (strpos($url, '?') === false)
{
$current_page=1;
$current_page=$db->querySingle("SELECT MIN (id) FROM pages");
}
else
......
......@@ -28,29 +28,36 @@ $smarty->assign("db_page_title", get_pages());
//assign values to the array needed to display all the pages found in the database; needed when creating a section
$smarty->assign("page_section", get_sections());
//if the user hasn't submitted the form yet
if (!isset($_GET['btn_submit']))
{
$smarty->display('tpl/remove.tpl');
}
//else if they have submitted the form
else
{
//get the user choice of what they want to remove/delete
$to_remove = $_GET['select_option'];
//if the user wants to remove a page
if ($to_remove == "page")
{
//if the variable with the page value is empty print an error and show the failure template
if (empty($_GET['page_to_remove']))
{
$smarty->assign("error", "Something went wrong. Please try to fill the form again.");
$smarty->display('tpl/failure.tpl');
}
//else if the variable with the page value isn't empty
else
{
//get the title of the page to remove and find its id
$page_to_remove = $_GET['page_to_remove'];
$id = $db->querySingle("SELECT id FROM pages WHERE title = '$page_to_remove'");
//delete the page
$query=$db->exec("DELETE FROM pages WHERE id = '$id'");
//if something went wrong show the failure template with the error message
......@@ -69,22 +76,31 @@ else
}
//else if the user wants to remove a section
else if ($to_remove == "section")
{
//if the variable with the section title value is empty print an error and display the failure tempalte
if (empty($_GET['section_to_remove']))
{
$smarty->assign("error", "Something went wrong. Please try to fill the form again.");
$smarty->display('tpl/failure.tpl');
}
//else if it's not empty
else
{
//get the title of the section we want to remove in format page: section
//explode the string to get the section title without the page and the page title so that we can find the page_id as well
$section_to_remove = $_GET['section_to_remove'];
$section_to_remove = explode(": ", $section_to_remove);
$page_of_section_to_remove = $section_to_remove[0];
$section_to_remove = $section_to_remove[1];
$page_id = $db->querySingle("SELECT id FROM pages WHERE title = '$page_of_section_to_remove'");
//find the id of this section and delete it from the database
$id = $db->querySingle("SELECT id FROM sections WHERE title = '$section_to_remove'");
$query=$db->exec("DELETE FROM sections WHERE id = '$id'");
$query=$db->exec("DELETE FROM sections WHERE id = '$id' AND page_id='$page_id'");
//if something went wrong show the failure template with the error message
if(!$query)
......
......@@ -120,16 +120,13 @@ html
#wrapper.toggled #page-content-wrapper
{
opacity: 0.1;
filter: alpha(opacity=10); /* For IE8 and earlier */
overflow:hidden;
pointer-events: none;
}
#wrapper.toggled #search-container
{
opacity: 0.1;
filter: alpha(opacity=10); /* For IE8 and earlier */
overflow:hidden;
pointer-events: none;
}
......
......@@ -3,6 +3,7 @@
$("table").addClass('table table-bordered table-striped');
$("p").addClass('editable');
$("img").addClass('img-responsive');
......@@ -56,3 +57,34 @@ $("#menu-toggle").click(function(e) {
$("#wrapper").toggleClass("toggled");
});
$(".sidebar-link").click(function() {
var viewportwidth;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth
}
// older versions of IE
else
{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth
}
if (viewportwidth < 1200)
$("#wrapper").toggleClass("toggled");
});
\ No newline at end of file
......@@ -23,7 +23,7 @@
{foreach page_sections($pages[pages]) as $section_title}
{assign var=current_page_id value=return_page_id($pages[pages])}
{assign var=link value="?$current_page_id#$var"}
<li><a href={$link} class="sub-text-padding">{$section_title}</a></li>
<li><a href={$link} class="sub-text-padding sidebar-link">{$section_title}</a></li>
{assign var=var value=$var+1}
{/foreach}
</ul>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!