move icon stuff back to app_render() and send navapps through app_render()

This commit is contained in:
Mario Vavti 2017-02-06 20:10:10 +01:00
parent dce5e8d0cc
commit 70edcabca1
8 changed files with 22 additions and 22 deletions

View File

@ -26,7 +26,6 @@ class Apps {
foreach($files as $f) { foreach($files as $f) {
$x = self::parse_app_description($f,$translate); $x = self::parse_app_description($f,$translate);
if($x) { if($x) {
$x['icon'] = ((strpos($x['photo'],'icon:') === 0) ? substr($x['photo'],5) : '');
$ret[] = $x; $ret[] = $x;
} }
} }
@ -40,7 +39,6 @@ class Apps {
$x = self::parse_app_description($f,$translate); $x = self::parse_app_description($f,$translate);
if($x) { if($x) {
$x['plugin'] = $plugin; $x['plugin'] = $plugin;
$x['icon'] = ((strpos($x['photo'],'icon:') === 0) ? substr($x['photo'],5) : '');
$ret[] = $x; $ret[] = $x;
} }
} }
@ -341,9 +339,11 @@ class Apps {
} }
$install_action = (($installed) ? t('Update') : t('Install')); $install_action = (($installed) ? t('Update') : t('Install'));
$icon = ((strpos($papp['photo'],'icon:') === 0) ? substr($papp['photo'],5) : '');
return replace_macros(get_markup_template('app.tpl'),array( return replace_macros(get_markup_template('app.tpl'),array(
'$app' => $papp, '$app' => $papp,
'$icon' => $icon,
'$hosturl' => $hosturl, '$hosturl' => $hosturl,
'$purchase' => (($papp['page'] && (! $installed)) ? t('Purchase') : ''), '$purchase' => (($papp['page'] && (! $installed)) ? t('Purchase') : ''),
'$install' => (($hosturl && $mode == 'view') ? $install_action : ''), '$install' => (($hosturl && $mode == 'view') ? $install_action : ''),
@ -351,7 +351,8 @@ class Apps {
'$delete' => ((local_channel() && $installed && $mode == 'edit') ? t('Delete') : ''), '$delete' => ((local_channel() && $installed && $mode == 'edit') ? t('Delete') : ''),
'$undelete' => ((local_channel() && $installed && $mode == 'edit') ? t('Undelete') : ''), '$undelete' => ((local_channel() && $installed && $mode == 'edit') ? t('Undelete') : ''),
'$deleted' => $papp['deleted'], '$deleted' => $papp['deleted'],
'$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true) '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true),
'$navapps' => ((local_channel() && $installed && $mode == 'nav') ? true : false)
)); ));
} }
@ -512,8 +513,6 @@ class Apps {
intval(TERM_OBJ_APP), intval(TERM_OBJ_APP),
intval($r[$x]['id']) intval($r[$x]['id'])
); );
$r[$x]['app_icon'] = ((strpos($r[$x]['app_photo'],'icon:') === 0) ? substr($r[$x]['app_photo'],5) : '');
} }
} }

View File

@ -38,7 +38,7 @@ class Apps extends \Zotlabs\Web\Controller {
foreach($syslist as $app) { foreach($syslist as $app) {
$apps[] = Zlib\Apps::app_render($app,$mode); $apps[] = Zlib\Apps::app_render($app,$mode);
} }
return replace_macros(get_markup_template('myapps.tpl'), array( return replace_macros(get_markup_template('myapps.tpl'), array(
'$sitename' => get_config('system','sitename'), '$sitename' => get_config('system','sitename'),
'$cat' => ((array_key_exists('cat',$_GET) && $_GET['cat']) ? ' - ' . escape_tags($_GET['cat']) : ''), '$cat' => ((array_key_exists('cat',$_GET) && $_GET['cat']) ? ' - ' . escape_tags($_GET['cat']) : ''),

View File

@ -1,6 +1,6 @@
version: 1 version: 1
url: $baseurl/chat/$nick url: $baseurl/chat/$nick
requires: local_channel requires: local_channel, ajaxchat
name: My Chatrooms name: My Chatrooms
photo: icon:comments-o photo: icon:comments-o
categories: Productivity categories: Productivity

View File

@ -1,6 +1,6 @@
version: 1 version: 1
url: $baseurl/wiki/$nick url: $baseurl/wiki/$nick
requires: local_channel requires: local_channel, wiki
name: Wiki name: Wiki
photo: icon:pencil-square-o photo: icon:pencil-square-o
categories: Productivity categories: Productivity

View File

@ -273,10 +273,9 @@ EOT;
$syslist = Zlib\Apps::get_system_apps(true); $syslist = Zlib\Apps::get_system_apps(true);
} }
$navapps = replace_macros(get_markup_template('navapps.tpl'), array( foreach($syslist as $app) {
'$apps' => $syslist, $navapps[] = Zlib\Apps::app_render($app,'nav');
'$localuser' => local_channel(), }
));
$tpl = get_markup_template('nav.tpl'); $tpl = get_markup_template('nav.tpl');

View File

@ -1,6 +1,7 @@
{{if !$navapps}}
<div class="app-container"> <div class="app-container">
<div class="app-detail{{if $deleted}} app-deleted{{/if}}"> <div class="app-detail{{if $deleted}} app-deleted{{/if}}">
<a href="{{$app.url}}" {{if $ap.target}}target="{{$app.target}}" {{/if}}{{if $app.desc}}title="{{$app.desc}}{{if $app.price}} ({{$app.price}}){{/if}}"{{else}}title="{{$app.name}}"{{/if}}>{{if $app.icon}}<i class="app-icon fa fa-fw fa-{{$app.icon}}"></i>{{else}}<img src="{{$app.photo}}" width="80" height="80" />{{/if}} <a href="{{$app.url}}"{{if $app.target}} target="{{$app.target}}"{{/if}}{{if $app.desc}} title="{{$app.desc}}{{if $app.price}} ({{$app.price}}){{/if}}"{{else}}title="{{$app.name}}"{{/if}}>{{if $icon}}<i class="app-icon fa fa-fw fa-{{$icon}}"></i>{{else}}<img src="{{$app.photo}}" width="80" height="80" />{{/if}}
<div class="app-name" style="text-align:center;">{{$app.name}}</div> <div class="app-name" style="text-align:center;">{{$app.name}}</div>
</a> </a>
</div> </div>
@ -24,4 +25,7 @@
</div> </div>
{{/if}} {{/if}}
</div> </div>
{{else}}
<li><a href="{{$app.url}}">{{if $icon}}<i class="generic-icons-nav fa fa-fw fa-{{$icon}}"></i>{{else}}<img src="{{$app.photo}}" width="16" height="16" style="margin-right:9px;"/>{{/if}}{{$app.name}}</a></li>
{{/if}}

View File

@ -170,7 +170,13 @@
<li class=""> <li class="">
<a href="#" data-toggle="dropdown"><i class="fa fa-bars"></i></a> <a href="#" data-toggle="dropdown"><i class="fa fa-bars"></i></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{{$navapps}} {{foreach $navapps as $navapp}}
{{$navapp}}
{{/foreach}}
{{if $localuser}}
<li class="divider"></li>
<li><a href="/apps"><i class="generic-icons-nav fa fa-fw fa-plus-circle"></i>Add Apps</a></li>
{{/if}}
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -1,8 +0,0 @@
{{foreach $apps as $app}}
<li><a href="{{$app.url}}">{{if $app.icon}}<i class="generic-icons-nav fa fa-fw fa-{{$app.icon}}"></i>{{else}}<img src="{{$app.photo}}" width="16" height="16" style="margin-right:9px;"/>{{/if}}{{$app.name}}</a></li>
{{/foreach}}
{{if $localuser}}
<li class="divider"></li>
<li><a href="/apps"><i class="generic-icons-nav fa fa-fw fa-plus-circle"></i>Add Apps</a></li>
{{/if}}