preparatory work for site ratings

This commit is contained in:
friendica 2015-02-15 21:22:05 -08:00
parent 2e3daf77bb
commit 8774089005
3 changed files with 28 additions and 10 deletions

View File

@ -35,7 +35,7 @@ function ratings_init(&$a) {
$results = false; $results = false;
$x = z_fetch_url($url . '/ratingsearch/' . $hash); $x = z_fetch_url($url . '/ratingsearch/' . urlencode($hash));
if($x['success']) if($x['success'])
@ -48,6 +48,7 @@ function ratings_init(&$a) {
return; return;
} }
if(array_key_exists('xchan_hash',$results['target']))
$a->poi = $results['target']; $a->poi = $results['target'];
$friends = array(); $friends = array();
@ -62,9 +63,9 @@ function ratings_init(&$a) {
} }
} }
$a->data = array_merge($friends,$others); $a->data = array('target' => $results['target'], 'results' => array_merge($friends,$others));
if(! $a->data) { if(! $a->data['results']) {
notice( t('No ratings') . EOL); notice( t('No ratings') . EOL);
} }
@ -90,11 +91,16 @@ function ratings_content(&$a) {
if(! $poco_rating) if(! $poco_rating)
return; return;
$site_target = ((array_key_exists('target',$a->data) && array_key_exists('site_url',$a->data['target'])) ?
$a->data['target']['site_url'] : '');
$o = replace_macros(get_markup_template('prep.tpl'),array( $o = replace_macros(get_markup_template('prep.tpl'),array(
'$header' => t('Ratings'), '$header' => t('Ratings'),
'$rating_lbl' => t('Rating: ' ), '$rating_lbl' => t('Rating: ' ),
'$website' => t('Website: '),
'$site' => $site_target,
'$rating_text_lbl' => t('Description: '), '$rating_text_lbl' => t('Description: '),
'$raters' => $a->data '$raters' => $a->data['results']
)); ));
return $o; return $o;

View File

@ -32,12 +32,19 @@ function ratingsearch_init(&$a) {
dbesc($hash . '%') dbesc($hash . '%')
); );
if($p) if(! $p) {
$ret['target'] = $p[0]; $p = q("select * from site where site_url like '%s' ",
else { dbesc('%' . $hash)
);
if(! $p) {
$ret['message'] = 'channel not found'; $ret['message'] = 'channel not found';
json_return_and_die($ret); json_return_and_die($ret);
} }
}
if($p)
$ret['target'] = $p[0];
$ret['success'] = true; $ret['success'] = true;

View File

@ -1,5 +1,10 @@
<h1>{{$header}}</h1> <h1>{{$header}}</h1>
{{if $site}}
<h3>{{$website}} {{$site}}</h3>
{{/if}}
{{if $raters}} {{if $raters}}
{{foreach $raters as $r}} {{foreach $raters as $r}}