]> git.mxchange.org Git - friendica.git/commitdiff
directory.php: move html to templates
authorrabuzarus <>
Fri, 16 Oct 2015 19:44:10 +0000 (21:44 +0200)
committerrabuzarus <>
Fri, 16 Oct 2015 19:44:10 +0000 (21:44 +0200)
mod/directory.php
view/templates/directory_header.tpl
view/templates/directory_item.tpl

index 6fd99256f0a80c06586c0f80b583ed150494526a..2093b1186309887bfc76c3b017c1167a6f5c1364 100644 (file)
@@ -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 = '<ul><li><div id="global-directory-link"><a href="'
-               . zrl($gdirpath,true) . '">' . t('Global Directory') . '</a></div></li></ul>';
+       $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) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
-               '$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 .= "<div class=\"directory-end\" ></div>\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);
 
        }
index 2274f2e1f8ecd0ed71389466c2c9488dd51912c8..ef9aa04af5684abf95df489b563a4de3f29ebbc9 100644 (file)
@@ -1,17 +1,29 @@
 
 <h1>{{$sitedir}}</h1>
 
-{{$globaldir}}
-{{$admin}}
+{{if $gdirpath}}
+       <ul>
+               <li><div id="global-directory-link"><a href="{{$gdirpath}}">{{$globaldir}}</a></div></li>
+       </ul>
+{{/if}}
 
-{{$finding}}
 
 <div id="directory-search-wrapper">
-<form id="directory-search-form" action="directory" method="get" >
-<span class="dirsearch-desc">{{$desc}}</span>
-<input type="text" name="search" id="directory-search" class="search-input" onfocus="this.select();" value="{{$search|escape:'html'}}" />
-<input type="submit" name="submit" id="directory-search-submit" value="{{$submit|escape:'html'}}" class="button" />
-</form>
+       <form id="directory-search-form" action="directory" method="get" >
+               <span class="dirsearch-desc">{{$desc}}</span>
+               <input type="text" name="search" id="directory-search" class="search-input" onfocus="this.select();" value="{{$search|escape:'html'}}" />
+               <input type="submit" name="submit" id="directory-search-submit" value="{{$submit|escape:'html'}}" class="button" />
+       </form>
 </div>
+
+{{if $findterm}}
+       <h4>{{$finding}} '{{$findterm}}'</h4>
+{{/if}}
+
 <div id="directory-search-end"></div>
 
+{{foreach $entries as $entry}}
+       {{include file="directory_item.tpl"}}
+{{/foreach}}
+
+<div class="directory-end" ></div>
\ No newline at end of file
index b43fcd28cf8393f9549503a60f3c0af938c3d32a..4dbe8a951f5ecee53886a023f0fc80513e55929e 100644 (file)
@@ -1,12 +1,14 @@
 
 
-<div class="directory-item lframe" id="directory-item-{{$id}}" >
-       <div class="contact-photo-wrapper" id="directory-photo-wrapper-{{$id}}" > 
-               <div class="contact-photo" id="directory-photo-{{$id}}" >
-                       <a href="{{$profile_link}}" class="directory-profile-link" id="directory-profile-link-{{$id}}" ><img class="directory-photo-img" src="{{$photo}}" alt="{{$alt_text}}" title="{{$alt_text}}" /></a>
+<div class="directory-item lframe" id="directory-item-{{$entry.id}}" >
+       <div class="contact-photo-wrapper" id="directory-photo-wrapper-{{$entry.id}}" > 
+               <div class="contact-photo" id="directory-photo-{{$entry.id}}" >
+                       <a href="{{$entry.profile_link}}" class="directory-profile-link" id="directory-profile-link-{{$entry.id}}" >
+                               <img class="directory-photo-img" src="{{$entry.photo}}" alt="{{$entry.alt_text}}" title="{{$entry.alt_text}}" />
+                       </a>
                </div>
        </div>
 
-       <div class="contact-name" id="directory-name-{{$id}}">{{$name}}</div>
-       <div class="contact-details">{{$details}}</div>
+       <div class="contact-name" id="directory-name-{{$entry.id}}">{{$entry.name}}</div>
+       <div class="contact-details">{{$entry.details}}</div>
 </div>