Skip to content

Commit 05e06f7

Browse files
committed
Update code
1 parent 9a804e8 commit 05e06f7

8 files changed

Lines changed: 96 additions & 58 deletions

File tree

inc/conf.const.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
3-
* @author SORIA Pierre-Henry
3+
* @author Pierre-Henry Soria
44
* @email pierrehs@hotmail.com
55
* @link http://github.com/pH-7/Nav-Doc-Script-V2
6-
* @copyright Copyright pH7 Script All Rights Reserved.
6+
* @copyright (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
77
* @license CC-BY - http://creativecommons.org/licenses/by/3.0/
88
*/
9+
910
namespace PH7\Doc;
1011
defined('PH7') or exit('Restricted access');
1112

@@ -15,7 +16,7 @@
1516
########## URL ##########
1617

1718
$sHttp = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'] == 'on')) ? 'https://' : 'http://';
18-
$sPhp_self = dirname(htmlspecialchars($_SERVER['PHP_SELF']));
19+
$sPhp_self = dirname(htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES));
1920

2021
#################### CONSTANTS ####################
2122

inc/conf.lang.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
3-
* @author SORIA Pierre-Henry
3+
* @author Pierre-Henry Soria
44
* @email pierrehs@hotmail.com
55
* @link http://github.com/pH-7/Nav-Doc-Script-V2
6-
* @copyright Copyright pH7 Script All Rights Reserved.
6+
* @copyright (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
77
* @license CC-BY - http://creativecommons.org/licenses/by/3.0/
88
*/
9+
910
namespace PH7\Doc;
1011
defined('PH7') or exit('Restricted access');
1112

inc/scripts/fns.html.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
3-
* @author SORIA Pierre-Henry
3+
* @author Pierre-Henry Soria
44
* @email pierrehs@hotmail.com
55
* @link http://github.com/pH-7/Nav-Doc-Script-V2
6-
* @copyright Copyright pH7 Script All Rights Reserved.
6+
* @copyright (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
77
* @license CC-BY - http://creativecommons.org/licenses/by/3.0/
88
*/
9+
910
namespace PH7\Doc;
1011
defined('PH7') or exit('Restricted access');
1112

inc/scripts/fns.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<?php
22
/**
3-
* @author SORIA Pierre-Henry
3+
* @author Pierre-Henry Soria
44
* @email pierrehs@hotmail.com
55
* @link http://github.com/pH-7/Nav-Doc-Script-V2
6-
* @copyright Copyright pH7 Script All Rights Reserved.
6+
* @copyright (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
77
* @license CC-BY - http://creativecommons.org/licenses/by/3.0/
88
*/
9+
910
namespace PH7\Doc;
1011
defined('PH7') or exit('Restricted access');
1112

1213
/**
13-
* @desc Gets Browser User Language.
14+
* @desc Detect the user's preferred language.
1415
* @return string The first two lowercase letter of the browser language.
1516
*/
1617
function get_browser_lang() {
1718
$aLang = explode(',' ,@$_SERVER['HTTP_ACCEPT_LANGUAGE']);
18-
return htmlspecialchars(strtolower(substr(chop($aLang[0]), 0, 2)));
19+
return escape(strtolower(substr(chop($aLang[0]), 0, 2)));
1920
}
2021

2122
/**
@@ -53,16 +54,13 @@ function parse_var($sContent) {
5354
}
5455

5556
/**
56-
* @desc Gets the page name.
57+
* @desc Get the page name.
5758
* @return string
5859
*/
5960
function get_page_name() {
60-
if(empty($_GET['p']))
61-
{
61+
if(empty($_GET['p'])) {
6262
$sName = SITE_SLOGAN;
63-
}
64-
else
65-
{
63+
} else {
6664
$sPageName = str_replace(array('-','_'), '', $_GET['p']);
6765
$sName = ucfirst($sPageName);
6866
}
@@ -131,6 +129,14 @@ function set_lang() {
131129
return $sLang;
132130
}
133131

132+
/**
133+
* @desc Escape function with htmlspecialchars() PHP function.
134+
* @return string
135+
*/
136+
function escape($sVal) {
137+
return htmlspecialchars($sVal, ENT_QUOTES);
138+
}
139+
134140
/**
135141
* @desc Sets an error 404 page with HTTP 404 code status.
136142
* @return void

index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
/**
3-
* @author SORIA Pierre-Henry
3+
* @author Pierre-Henry Soria
44
* @email pierrehs@hotmail.com
55
* @link http://github.com/pH-7/Nav-Doc-Script-V2
6-
* @copyright Copyright pH7 Script All Rights Reserved.
6+
* @copyright (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
77
* @license CC-BY - http://creativecommons.org/licenses/by/3.0/
88
*/
99

static/js/ajph.js

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,64 @@
1-
/**
2-
* @author SORIA Pierre-Henry
3-
* @email pierrehs@hotmail.com
4-
* @link http://github.com/pH-7/Nav-Doc-Script-V2
5-
* @copyright Copyright pH7 Script All Rights Reserved.
6-
* @license CC-BY - http://creativecommons.org/licenses/by/3.0/
1+
/*
2+
* Title: AjPH
3+
* Description: Loading pages in Ajax with HTML5 pushState.
4+
*
5+
* Author: Pierre-Henry Soria <ph7software@gmail.com>
6+
* Copyright: (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
7+
* License: GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
8+
* Version: 1.3
79
*/
810

9-
$(document).ready(function() {
10-
if (window.history && history.pushState) {
11-
historyedited = false;
12-
$(window).bind('popstate', function(e) {
13-
if (historyedited) {
14-
loadPage(location.pathname + location.search);
15-
}
16-
});
17-
doPager();
18-
}
11+
$(document).ready(function()
12+
{
13+
if(window.history && history.pushState)
14+
{
15+
bHistoryEdited = false;
16+
$(window).bind('popstate', function() {
17+
if(bHistoryEdited) {
18+
loadPage(location.pathname + location.search);
19+
}
20+
});
21+
doPager();
22+
}
1923
});
2024

21-
function doPager() {
22-
$('a[data-load=ajax]').click(function(e) {
23-
e.preventDefault();
24-
$('#ajph').html("<div id='loading'>Loading...</div>");
25-
loadPage($(this).attr('href'));
26-
history.pushState(null, null, $(this).attr('href'));
27-
historyedited = true;
28-
});
25+
function doPager()
26+
{
27+
// Loading the ajax pages
28+
$('a[data-load=ajax]').click(function(oE)
29+
{
30+
oE.preventDefault();
31+
$('#ajph').html("<div id='loading'>Loading...</div>");
32+
loadPage($(this).attr('href'));
33+
history.pushState(null, null, $(this).attr('href'));
34+
bHistoryEdited = true;
35+
});
2936
}
3037

31-
function loadPage(link) {
32-
$.ajax({
33-
url: link,
34-
processData: true,
35-
dataType:'html',
36-
success: function(data) {
37-
var content = $(data).find("#sub_ajph");
38-
var title = $(data).filter('title').text();
39-
document.title = title;
4038

41-
$('#ajph').fadeOut('200',function(){
42-
$(this).html(content.html()).fadeIn('200');
43-
});
44-
}
45-
});
46-
doPager();
39+
/**
40+
* Load page.
41+
*
42+
* @param {String} Link
43+
* @return {Void}
44+
*/
45+
function loadPage(sLink)
46+
{
47+
$.ajax({
48+
url: sLink,
49+
processData: true,
50+
dataType:'html',
51+
success: function(oData)
52+
{
53+
var oContent = $(oData).find("#sub_ajph"); // Get the new Contents
54+
var oTitle = $(oData).filter('title'); // Get the new Title tag
55+
var oHeadings = $(oData).find('#headings:first'); // Get the Headings Group
56+
$('title').text(oTitle.text()); // Set Title
57+
$('#headings:first').html(oHeadings.html()); // Set the Headings Group
58+
$('#ajph').fadeOut(200, function() {
59+
$(this).html(oContent.html()).fadeIn(200); // Set Contents
60+
});
61+
}
62+
});
63+
doPager();
4764
}

themes/base/css/common.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
/*
2+
* Author: Pierre-Henry Soria <ph7software@gmail.com>
3+
* Copyright: (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
4+
* License: GNU General Public License <http://www.gnu.org/licenses/gpl.html>
5+
*/
6+
17
body{margin:0;padding:0;color:#555;font:normal 10pt Arial,Helvetica,sans-serif;background:#EFEFEF}.success{color:green}.error,.warning,.mandatory{color:red;font-size:13px}.italic{font-style:italic}.underline{text-decoration:underline}input{margin:6px;width:220px;height:24px;font-size:16px}input[type="submit"],input[type="reset"]{width:190px}iframe{border:1px #475C9E solid;width:100%}ul li{display:block}#block{margin-top:5px}.center{text-align:center;margin-left:auto;margin-right:auto;width:80%}.right{float:right}.left{float:left}.success,.error,.warning,.mandatory{font-weight:bold}

themes/base/css/js/ajph.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
/*
2+
* Author: Pierre-Henry Soria <ph7software@gmail.com>
3+
* Copyright: (c) 2012-2013, Pierre-Henry Soria. All Rights Reserved.
4+
* License: GNU General Public License <http://www.gnu.org/licenses/gpl.html>
5+
*/
6+
17
#loading{position:absolute;z-index:50000;text-shadow:0 1px 0 #FFF;text-align:center;width:200px;height:20px;line-height:20px;left:613px;top:0px;font-family:Arial,sans-serif,"Helvetica Neue",Helvetica;font-size:12px;color:#333;background-color:rgb(255,241,168);font-weight:bold;}

0 commit comments

Comments
 (0)