aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php22
-rw-r--r--include/comanche.php66
-rw-r--r--include/dir_fns.php26
-rw-r--r--include/widgets.php3
-rw-r--r--mod/directory.php22
-rw-r--r--view/pdl/mod_directory.pdl1
-rw-r--r--view/tpl/dir_sort_links.tpl5
7 files changed, 106 insertions, 39 deletions
diff --git a/boot.php b/boot.php
index 5f8dd20fd..d89b1bd41 100755
--- a/boot.php
+++ b/boot.php
@@ -654,7 +654,7 @@ class App {
public $profile_uid = 0; // If applicable, the channel_id of the "page owner"
public $poi = null; // "person of interest", generally a referenced connection
public $layout = array(); // Comanche parsed template
-
+ public $pdl = null;
private $perms = null; // observer permissions
private $widgets = array(); // widgets for this page
//private $widgetlist = null; // widget ordering and inclusion directives
@@ -2047,11 +2047,24 @@ function load_pdl(&$a) {
if((! $s) && (($p = theme_include($n)) != ''))
$s = @file_get_contents($p);
- if($s)
+ if($s) {
comanche_parser($a, $s);
+ $a->pdl = $s;
+ }
+ }
+}
+
+
+function exec_pdl(&$a) {
+ require_once('include/comanche.php');
+
+ if($a->pdl) {
+ comanche_parser($a, $a->pdl,1);
}
}
+
+
/**
* @brief build the page.
*
@@ -2061,6 +2074,9 @@ function load_pdl(&$a) {
*/
function construct_page(&$a) {
+
+ exec_pdl($a);
+
$comanche = ((count($a->layout)) ? true : false);
require_once(theme_include('theme_init.php'));
@@ -2074,6 +2090,7 @@ function construct_page(&$a) {
}
if($comanche) {
+
if($a->layout['nav']) {
$a->page['nav'] = get_custom_nav($a, $a->layout['nav']);
}
@@ -2124,6 +2141,7 @@ function construct_page(&$a) {
call_hooks('construct_page', $arr);
$a->layout = $arr['layout'];
+
foreach($a->layout as $k => $v) {
if((strpos($k, 'region_') === 0) && strlen($v)) {
if(strpos($v, '$region_') !== false) {
diff --git a/include/comanche.php b/include/comanche.php
index e8d3ca5a1..1ddabb693 100644
--- a/include/comanche.php
+++ b/include/comanche.php
@@ -43,7 +43,7 @@ function pdl_selector($uid, $current="") {
-function comanche_parser(&$a, $s) {
+function comanche_parser(&$a, $s, $pass = 0) {
$matches = array();
$cnt = preg_match_all("/\[comment\](.*?)\[\/comment\]/ism", $s, $matches, PREG_SET_ORDER);
@@ -53,43 +53,47 @@ function comanche_parser(&$a, $s) {
}
}
- $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches);
- if($cnt)
- $a->page['template'] = trim($matches[1]);
+ if($pass == 0) {
+ $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches);
+ if($cnt)
+ $a->page['template'] = trim($matches[1]);
- $cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches);
- if($cnt) {
- $a->page['template'] = trim($matches[2]);
- $a->page['template_style'] = trim($matches[2]) . '_' . $matches[1];
- }
+ $cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches);
+ if($cnt) {
+ $a->page['template'] = trim($matches[2]);
+ $a->page['template_style'] = trim($matches[2]) . '_' . $matches[1];
+ }
- $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches);
- if($cnt) {
- $a->page['template'] = trim($matches[1]);
- }
+ $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches);
+ if($cnt) {
+ $a->page['template'] = trim($matches[1]);
+ }
- $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches);
- if($cnt) {
- $a->layout['schema'] = trim($matches[1]);
- $a->layout['theme'] = trim($matches[2]);
- }
+ $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches);
+ if($cnt) {
+ $a->layout['schema'] = trim($matches[1]);
+ $a->layout['theme'] = trim($matches[2]);
+ }
- $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches);
- if($cnt)
- $a->layout['theme'] = trim($matches[1]);
+ $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches);
+ if($cnt)
+ $a->layout['theme'] = trim($matches[1]);
- $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
- $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]);
- }
}
+ else {
+ $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]);
+ }
+ }
- $cnt = preg_match_all("/\[webpage\](.*?)\[\/webpage\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- // only the last webpage definition is used if there is more than one
- foreach($matches as $mtch) {
- $a->layout['webpage'] = comanche_webpage($a,$mtch[1]);
+ $cnt = preg_match_all("/\[webpage\](.*?)\[\/webpage\]/ism", $s, $matches, PREG_SET_ORDER);
+ if($cnt) {
+ // only the last webpage definition is used if there is more than one
+ foreach($matches as $mtch) {
+ $a->layout['webpage'] = comanche_webpage($a,$mtch[1]);
+ }
}
}
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 37a7c04e7..468e28ae5 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -74,7 +74,26 @@ function check_upstream_directory() {
function dir_sort_links() {
- // Build urls without order and pubforums so it's easy to tack on the changed value
+ $safe_mode = 1;
+
+ $observer = get_observer_hash();
+
+ if ($observer)
+ $safe_mode = get_xconfig($observer,'directory','safe_mode');
+ if($safe_mode === false)
+ $safe_mode = 1;
+
+ if(! $safe_mode)
+ $toggle = t('Enable Safe Search');
+ else
+ $toggle = t('Disable Safe Search');
+
+ if($observer)
+ $globaldir = get_xconfig($observer,'directory','globaldir');
+ else
+ $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false);
+
+ // Build urls without order and pubforums so it's easy to tack on the changed value
// Probably there's an easier way to do this
$current_order = (($_REQUEST['order']) ? $_REQUEST['order'] : 'normal');
@@ -104,7 +123,10 @@ function dir_sort_links() {
'$selected_sort' => $current_order,
'$sorturl' => $sorturl,
'$forumsurl' => $forumsurl,
-
+ '$safemode' => t('Safe Mode'),
+ '$toggle' => $toggle,
+ '$globaldir' => $globaldir,
+ '$localdir' => t('This Website Only'),
));
return $o;
}
diff --git a/include/widgets.php b/include/widgets.php
index fbbc74224..17c740967 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -605,9 +605,6 @@ function widget_vcard($arr) {
* The following directory widgets are only useful on the directory page
*/
-function widget_dirsafemode($arr) {
- return dir_safe_mode();
-}
function widget_dirsort($arr) {
return dir_sort_links();
diff --git a/mod/directory.php b/mod/directory.php
index bc5aa41e2..dfc60b190 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -14,6 +14,20 @@ function directory_init(&$a) {
dbesc($_GET['ignore'])
);
}
+
+ $observer = get_observer_hash();
+ $global_changed = false;
+
+ if(array_key_exists('global',$_REQUEST)) {
+ $globaldir = intval($_REQUEST['global']);
+ $global_changed = true;
+ }
+ if($global_changed) {
+ $_SESSION['globaldir'] = $globaldir;
+ if($observer)
+ set_xconfig($observer,'directory','globaldir',$globaldir);
+ }
+
}
function directory_content(&$a) {
@@ -26,6 +40,11 @@ function directory_content(&$a) {
$safe_mode = 1;
$observer = get_observer_hash();
+
+ if($observer)
+ $globaldir = get_xconfig($observer,'directory','globaldir');
+ else
+ $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false);
if($observer) {
$safe_mode = get_xconfig($observer,'directory','safe_mode');
@@ -120,6 +139,9 @@ function directory_content(&$a) {
if($token)
$query .= '&t=' . $token;
+ if(! $globaldir)
+ $query .= '&hub=' . get_app()->get_hostname();
+
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
if(strpos($search,'@'))
diff --git a/view/pdl/mod_directory.pdl b/view/pdl/mod_directory.pdl
index 0bc8ed936..452ab66c7 100644
--- a/view/pdl/mod_directory.pdl
+++ b/view/pdl/mod_directory.pdl
@@ -1,6 +1,5 @@
[region=aside]
[widget=findpeople][/widget]
-[widget=dirsafemode][/widget]
[widget=dirsort][/widget]
[widget=dirtags][/widget]
[widget=suggestions][/widget]
diff --git a/view/tpl/dir_sort_links.tpl b/view/tpl/dir_sort_links.tpl
index d9ecd22c6..62cf7ff1b 100644
--- a/view/tpl/dir_sort_links.tpl
+++ b/view/tpl/dir_sort_links.tpl
@@ -1,5 +1,8 @@
<div class="widget" id="dir_sort_links">
<h3>{{$header}}</h3>
+<ul class="nav nav-pills nav-stacked">
+ <li><a href="toggle_safesearch">{{$toggle}}</a></li>
+</ul>
{{$sort}}: <select onchange='window.location.href="{{$sorturl}}&order="+this.value'>
<option value='normal' {{if $selected_sort == 'normal'}}selected='selected'{{/if}}>{{$normal}}</option>
<option value='reverse' {{if $selected_sort == 'reverse'}}selected='selected'{{/if}}>{{$reverse}}</option>
@@ -7,4 +10,6 @@
<option value='reversedate' {{if $selected_sort == 'reversedate'}}selected='selected'{{/if}}>{{$reversedate}}</option>
</select><br />
<input type='checkbox' {{if $pubforumsonly}}checked='checked'{{/if}} onchange='window.location.href="{{$forumsurl}}&pubforums="+(this.checked ? 1 : 0)'/> {{$pubforums}}<br />
+<input type='checkbox' {{if $globaldir}}{{else}}checked='checked'{{/if}} onchange='window.location.href="{{$forumsurl}}&global="+(this.checked ? 0 : 1)'/> {{$localdir}}<br />
+
</div>