major cleanup of directory options
This commit is contained in:
parent
bd4d2f3b44
commit
f6da235a7d
@ -80,6 +80,8 @@ function dir_sort_links() {
|
||||
|
||||
if ($observer)
|
||||
$safe_mode = get_xconfig($observer,'directory','safe_mode');
|
||||
else
|
||||
$safe_mode = ((array_key_exists('safemode',$_SESSION)) ? intval($_SESSION['safemode']) : false);
|
||||
if($safe_mode === false)
|
||||
$safe_mode = 1;
|
||||
|
||||
@ -96,7 +98,7 @@ function dir_sort_links() {
|
||||
// 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');
|
||||
$current_order = (($_REQUEST['order']) ? $_REQUEST['order'] : 'date');
|
||||
$url = 'directory?f=';
|
||||
|
||||
$tmp = array_merge($_GET,$_POST);
|
||||
@ -107,6 +109,8 @@ function dir_sort_links() {
|
||||
|
||||
$tmp = array_merge($_GET,$_POST);
|
||||
unset($tmp['pubforums']);
|
||||
unset($tmp['global']);
|
||||
unset($tmp['safe']);
|
||||
unset($tmp['q']);
|
||||
unset($tmp['f']);
|
||||
$forumsurl = $url . http_build_query($tmp);
|
||||
@ -125,7 +129,10 @@ function dir_sort_links() {
|
||||
'$forumsurl' => $forumsurl,
|
||||
'$safemode' => t('Safe Mode'),
|
||||
'$toggle' => $toggle,
|
||||
'$globaldir' => $globaldir,
|
||||
'$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'','',' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''),
|
||||
|
||||
'$pubforums' => array('pubforums', t('Public Forums Only'),(x($_REQUEST,'pubforums') ? $_REQUEST['pubforums'] : ''),'','',' onchange=\'window.location.href="' . $forumsurl . '&pubforums="+(this.checked ? 1 : 0)\''),
|
||||
'$globaldir' => array('globaldir', t('This Website Only'), 1-intval($globaldir),'','',' onchange=\'window.location.href="' . $forumsurl . '&global="+(this.checked ? 0 : 1)\''),
|
||||
'$localdir' => t('This Website Only'),
|
||||
));
|
||||
return $o;
|
||||
|
@ -17,6 +17,7 @@ function directory_init(&$a) {
|
||||
|
||||
$observer = get_observer_hash();
|
||||
$global_changed = false;
|
||||
$safe_changed = false;
|
||||
|
||||
if(array_key_exists('global',$_REQUEST)) {
|
||||
$globaldir = intval($_REQUEST['global']);
|
||||
@ -28,6 +29,16 @@ function directory_init(&$a) {
|
||||
set_xconfig($observer,'directory','globaldir',$globaldir);
|
||||
}
|
||||
|
||||
if(array_key_exists('safe',$_REQUEST)) {
|
||||
$safemode = intval($_REQUEST['safe']);
|
||||
$safe_changed = true;
|
||||
}
|
||||
if($safe_changed) {
|
||||
$_SESSION['safemode'] = $safemode;
|
||||
if($observer)
|
||||
set_xconfig($observer,'directory','safe_mode',$safemode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function directory_content(&$a) {
|
||||
@ -46,20 +57,18 @@ function directory_content(&$a) {
|
||||
else
|
||||
$globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false);
|
||||
|
||||
if($observer) {
|
||||
if($observer)
|
||||
$safe_mode = get_xconfig($observer,'directory','safe_mode');
|
||||
}
|
||||
else
|
||||
$safe_mode = ((array_key_exists('safemode',$_SESSION)) ? intval($_SESSION['safemode']) : false);
|
||||
if($safe_mode === false)
|
||||
$safe_mode = 1;
|
||||
else
|
||||
$safe_mode = intval($safe_mode);
|
||||
|
||||
if(x($_REQUEST,'safe'))
|
||||
$safe_mode = (intval($_REQUEST['safe']));
|
||||
|
||||
$pubforums = null;
|
||||
if(array_key_exists('pubforums',$_REQUEST))
|
||||
$pubforums = intval($_REQUEST['pubforums']);
|
||||
if(! $pubforums)
|
||||
$pubforums = null;
|
||||
|
||||
$o = '';
|
||||
nav_set_selected('directory');
|
||||
@ -153,16 +162,11 @@ function directory_content(&$a) {
|
||||
if(! is_null($pubforums))
|
||||
$query .= '&pubforums=' . intval($pubforums);
|
||||
|
||||
if(! is_null($pubforums))
|
||||
$query .= '&pubforums=' . intval($pubforums);
|
||||
|
||||
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'normal');
|
||||
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : 'date');
|
||||
|
||||
if($sort_order)
|
||||
$query .= '&order=' . urlencode($sort_order);
|
||||
|
||||
|
||||
|
||||
if($a->pager['page'] != 1)
|
||||
$query .= '&p=' . $a->pager['page'];
|
||||
|
||||
|
@ -119,7 +119,7 @@ function dirsearch_content(&$a) {
|
||||
$sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords);
|
||||
|
||||
if($forums)
|
||||
$sql_extra .= dir_flag_build($joiner,'xprof_flags',XCHAN_FLAGS_PUBFORUM, $forums);
|
||||
$sql_extra .= dir_flag_build(' AND ','xchan_flags',XCHAN_FLAGS_PUBFORUM, $forums);
|
||||
|
||||
|
||||
// we only support an age range currently. You must set both agege
|
||||
@ -188,6 +188,11 @@ function dirsearch_content(&$a) {
|
||||
|
||||
if($sort_order == 'normal') {
|
||||
$order = " order by xchan_name asc ";
|
||||
|
||||
// Start the alphabetic search at 'A'
|
||||
// This will make a handful of channels whose names begin with
|
||||
// punctuation un-searchable in this mode
|
||||
|
||||
$safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 ";
|
||||
}
|
||||
elseif($sort_order == 'reverse')
|
||||
@ -241,49 +246,22 @@ function dirsearch_content(&$a) {
|
||||
}
|
||||
else {
|
||||
|
||||
// The query mangling is designed to make alphabetic searches start with 'A' and not precede real names
|
||||
// with those containing a bunch of punctuation
|
||||
|
||||
if($sort_order == 'normal') {
|
||||
$sql = $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) > 64 ";
|
||||
}
|
||||
else {
|
||||
$sql = $safesql;
|
||||
}
|
||||
|
||||
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $sql $order $qlimit ",
|
||||
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ",
|
||||
intval(XCHAN_FLAGS_HIDDEN),
|
||||
intval(XCHAN_FLAGS_ORPHAN),
|
||||
intval(XCHAN_FLAGS_DELETED)
|
||||
);
|
||||
|
||||
$ret['page'] = $page + 1;
|
||||
$ret['records'] = count($r);
|
||||
|
||||
|
||||
if(! $r) {
|
||||
|
||||
if($sort_order == 'normal') {
|
||||
$sql = $safesql .= " and ascii(substr(xchan_name FROM 1 FOR 1)) <= 64 ";
|
||||
|
||||
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $sql $order $qlimit ",
|
||||
intval(XCHAN_FLAGS_HIDDEN),
|
||||
intval(XCHAN_FLAGS_ORPHAN),
|
||||
intval(XCHAN_FLAGS_DELETED)
|
||||
);
|
||||
|
||||
$ret['page'] = $page + 1;
|
||||
$ret['records'] = count($r);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($r) {
|
||||
|
||||
$entries = array();
|
||||
|
||||
|
||||
foreach($r as $rr) {
|
||||
|
||||
$entry = array();
|
||||
@ -348,7 +326,7 @@ function dir_query_build($joiner,$field,$s) {
|
||||
}
|
||||
|
||||
function dir_flag_build($joiner,$field,$bit,$s) {
|
||||
return dbesc($joiner) . " ( " . dbesc('xchan_flags') . " & " . intval($bit) . " ) " . ((intval($s)) ? '>' : '=' ) . " 0 ";
|
||||
return dbesc($joiner) . " ( " . dbesc($field) . " & " . intval($bit) . " ) " . ((intval($s)) ? '>' : '=' ) . " 0 ";
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
<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>
|
||||
|
||||
{{include file="field_checkbox.tpl" field=$safemode}}
|
||||
{{include file="field_checkbox.tpl" field=$globaldir}}
|
||||
{{include file="field_checkbox.tpl" field=$pubforums}}
|
||||
|
||||
{{$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>
|
||||
<option value='date' {{if $selected_sort == 'date'}}selected='selected'{{/if}}>{{$date}}</option>
|
||||
<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>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="form-group field checkbox">
|
||||
<label for="id_{{$field.0}}">{{$field.1}}</label>
|
||||
<div class="pull-right"><input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}}><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label></div>
|
||||
<div class="pull-right"><input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}} {{if $field.5}}{{$field.5}}{{/if}} /><label class="switchlabel" for='id_{{$field.0}}'> <span class="onoffswitch-inner" data-on='{{if $field.4}}{{$field.4.1}}{{/if}}' data-off='{{if $field.4}}{{$field.4.0}}{{/if}}'></span><span class="onoffswitch-switch"></span></label></div>
|
||||
<span class="help-block">{{$field.3}}</span>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
Reference in New Issue
Block a user