mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
straighten out some directory stuff, which required some Comanche structural changes
This commit is contained in:
parent
e73d0ee418
commit
22391a2437
7 changed files with 110 additions and 43 deletions
22
boot.php
22
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) {
|
||||
|
|
|
@ -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,6 +53,7 @@ function comanche_parser(&$a, $s) {
|
|||
}
|
||||
}
|
||||
|
||||
if($pass == 0) {
|
||||
$cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches);
|
||||
if($cnt)
|
||||
$a->page['template'] = trim($matches[1]);
|
||||
|
@ -78,6 +79,8 @@ function comanche_parser(&$a, $s) {
|
|||
if($cnt)
|
||||
$a->layout['theme'] = trim($matches[1]);
|
||||
|
||||
}
|
||||
else {
|
||||
$cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||
if($cnt) {
|
||||
foreach($matches as $mtch) {
|
||||
|
@ -92,6 +95,7 @@ function comanche_parser(&$a, $s) {
|
|||
$a->layout['webpage'] = comanche_webpage($a,$mtch[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,25 @@ function check_upstream_directory() {
|
|||
|
||||
function dir_sort_links() {
|
||||
|
||||
$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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
@ -27,6 +41,11 @@ function directory_content(&$a) {
|
|||
|
||||
$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,'@'))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
[region=aside]
|
||||
[widget=findpeople][/widget]
|
||||
[widget=dirsafemode][/widget]
|
||||
[widget=dirsort][/widget]
|
||||
[widget=dirtags][/widget]
|
||||
[widget=suggestions][/widget]
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue