From 6ebb21a935436bdca03f8e6c1f9286b650ac1dc4 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 16 Oct 2015 21:44:10 +0200 Subject: [PATCH 1/3] directory.php: move html to templates --- mod/directory.php | 79 ++++++++++++++--------------- view/templates/directory_header.tpl | 28 +++++++--- view/templates/directory_item.tpl | 14 ++--- 3 files changed, 67 insertions(+), 54 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index 6fd99256f..2093b1186 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -31,7 +31,7 @@ function directory_content(&$a) { require_once("mod/proxy.php"); if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) || - (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) { + (get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) { notice( t('Public access denied.') . EOL); return; } @@ -44,27 +44,12 @@ function directory_content(&$a) { else $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); - $tpl = get_markup_template('directory_header.tpl'); - - $globaldir = ''; - $gdirpath = get_config('system','directory'); - if(strlen($gdirpath)) { - $globaldir = ''; + $gdirpath = ''; + $dirurl = get_config('system','directory'); + if(strlen($dirurl)) { + $gdirpath = zrl($dirurl,true); } - $admin = ''; - - $o .= replace_macros($tpl, array( - '$search' => $search, - '$globaldir' => $globaldir, - '$desc' => t('Find on this site'), - '$admin' => $admin, - '$finding' => (strlen($search) ? '

' . t('Finding: ') . "'" . $search . "'" . '

' : ""), - '$sitedir' => t('Site Directory'), - '$submit' => t('Find') - )); - if($search) { $search = dbesc($search); @@ -159,8 +144,6 @@ function directory_content(&$a) { $about = ((x($profile,'about') == 1) ? t('About:') : False); - $tpl = get_markup_template('directory_item.tpl'); - if($a->theme['template_engine'] === 'internal') { $location_e = template_escape($location); } @@ -168,23 +151,23 @@ function directory_content(&$a) { $location_e = $location; } - $entry = replace_macros($tpl,array( - '$id' => $rr['id'], - '$profile_link' => $profile_link, - '$photo' => proxy_url($a->get_cached_avatar_image($rr[$photo]), false, PROXY_SIZE_THUMB), - '$alt_text' => $rr['name'], - '$name' => $rr['name'], - '$details' => $pdesc . $details, - '$page_type' => $page_type, - '$profile' => $profile, - '$location' => $location_e, - '$gender' => $gender, - '$pdesc' => $pdesc, - '$marital' => $marital, - '$homepage' => $homepage, - '$about' => $about, + $entry = array( + 'id' => $rr['id'], + 'profile_link' => $profile_link, + 'photo' => proxy_url($a->get_cached_avatar_image($rr[$photo]), false, PROXY_SIZE_THUMB), + 'alt_text' => $rr['name'], + 'name' => $rr['name'], + 'details' => $pdesc . $details, + 'page_type' => $page_type, + 'profile' => $profile, + 'location' => $location_e, + 'gender' => $gender, + 'pdesc' => $pdesc, + 'marital' => $marital, + 'homepage' => $homepage, + 'about' => $about, - )); + ); $arr = array('contact' => $rr, 'entry' => $entry); @@ -193,11 +176,27 @@ function directory_content(&$a) { unset($profile); unset($location); - $o .= $entry; + if(! $arr['entry']) + continue; + + $entries[] = $arr['entry']; } - $o .= "
\r\n"; + $tpl = get_markup_template('directory_header.tpl'); + + $o .= replace_macros($tpl, array( + '$search' => $search, + '$globaldir' => t('Global Directory'), + '$gdirpath' => $gdirpath, + '$desc' => t('Find on this site'), + '$entries' => $entries, + '$finding' => t('Finding:'), + '$findterm' => (strlen($search) ? $search : ""), + '$sitedir' => t('Site Directory'), + '$submit' => t('Find') + )); + $o .= paginate($a); } diff --git a/view/templates/directory_header.tpl b/view/templates/directory_header.tpl index 2274f2e1f..ef9aa04af 100644 --- a/view/templates/directory_header.tpl +++ b/view/templates/directory_header.tpl @@ -1,17 +1,29 @@

{{$sitedir}}

-{{$globaldir}} -{{$admin}} +{{if $gdirpath}} + +{{/if}} -{{$finding}}
-
-{{$desc}} - - -
+
+ {{$desc}} + + +
+ +{{if $findterm}} +

{{$finding}} '{{$findterm}}'

+{{/if}} +
+{{foreach $entries as $entry}} + {{include file="directory_item.tpl"}} +{{/foreach}} + +
\ No newline at end of file diff --git a/view/templates/directory_item.tpl b/view/templates/directory_item.tpl index b43fcd28c..4dbe8a951 100644 --- a/view/templates/directory_item.tpl +++ b/view/templates/directory_item.tpl @@ -1,12 +1,14 @@ -
-
-
- {{$alt_text}} +
+
+
-
{{$name}}
-
{{$details}}
+
{{$entry.name}}
+
{{$entry.details}}
From 72896b0f6b1677a42970f432485df213318141e9 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 17 Oct 2015 19:45:57 +0200 Subject: [PATCH 2/3] unify directory page --- mod/directory.php | 4 +++- view/templates/directory_header.tpl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index 2093b1186..d256c590a 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -6,6 +6,8 @@ function directory_init(&$a) { if(local_user()) { require_once('include/contact_widgets.php'); + $a->page['aside'] .= follow_widget(); + $a->page['aside'] .= findpeople_widget(); } @@ -193,7 +195,7 @@ function directory_content(&$a) { '$entries' => $entries, '$finding' => t('Finding:'), '$findterm' => (strlen($search) ? $search : ""), - '$sitedir' => t('Site Directory'), + '$title' => t('Site Directory'), '$submit' => t('Find') )); diff --git a/view/templates/directory_header.tpl b/view/templates/directory_header.tpl index ef9aa04af..07d625ed4 100644 --- a/view/templates/directory_header.tpl +++ b/view/templates/directory_header.tpl @@ -1,5 +1,5 @@ -

{{$sitedir}}

+{{include file="section_title.tpl"}} {{if $gdirpath}}
    From b9d9bf8ecdc4e82637524eb59386ff8a7f54de6c Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 17 Oct 2015 21:45:55 +0200 Subject: [PATCH 3/3] directory: move pagination into template --- mod/directory.php | 5 ++--- view/templates/directory_header.tpl | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index d256c590a..46c4f38ad 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -196,11 +196,10 @@ function directory_content(&$a) { '$finding' => t('Finding:'), '$findterm' => (strlen($search) ? $search : ""), '$title' => t('Site Directory'), - '$submit' => t('Find') + '$submit' => t('Find'), + '$paginate' => paginate($a), )); - $o .= paginate($a); - } else info( t("No entries \x28some entries may be hidden\x29.") . EOL); diff --git a/view/templates/directory_header.tpl b/view/templates/directory_header.tpl index 07d625ed4..eda887a89 100644 --- a/view/templates/directory_header.tpl +++ b/view/templates/directory_header.tpl @@ -26,4 +26,6 @@ {{include file="directory_item.tpl"}} {{/foreach}} -
    \ No newline at end of file +
    + +{{$paginate}}