poco rating - add a test module for pulling out ratings

This commit is contained in:
friendica 2015-01-15 17:32:41 -08:00
parent e7932d97a2
commit 597b07e8cc
4 changed files with 90 additions and 5 deletions

View File

@ -534,11 +534,21 @@ function connedit_content(&$a) {
));
}
$poco_rating = get_config('system','poco_rating_enable');
// if unset default to enabled
if($poco_rating === false)
$poco_rating = true;
if($poco_rating) {
$rating = replace_macros(get_markup_template('rating_slider.tpl'),array(
'$min' => -10,
'$val' => (($contact['abook_rating']) ? $contact['abook_rating'] : 0),
));
}
else {
$rating = false;
}
$perms = array();
$channel = $a->get_channel();

38
mod/prep.php Normal file
View File

@ -0,0 +1,38 @@
<?php
function prep_content(&$a) {
if(argc() > 1)
$hash = argv(1);
if(! $hash) {
notice('Must supply a channel identififier.');
return;
}
$p = q("select * from xchan where xchan_hash like '%s'",
dbesc($hash . '%')
);
$r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash where xlink_link like '%s' and xlink_rating != 0",
dbesc($hash . '%')
);
$ret = array();
if($p && $r) {
$ret['poi'] = $p[0];
$ret['raters'] = $r;
$o = replace_macros(get_markup_template('prep.tpl'),array(
'$header' => t('Ratings'),
'$poi' => $p[0],
'$raters' => $r
));
return $o;
}
return '';
}

View File

@ -76,11 +76,12 @@
</div>
{{/if}}
{{if $rating}}
{{if $notself}}
<h3 class="abook-rating-text-desc">{{$lbl_rating_txt}}</h3>
<textarea name="rating_text" id="rating-text" >{{$rating_txt}}</textarea>
{{/if}}
{{/if}}
{{if $multiprofs }}
<div>

36
view/tpl/prep.tpl Normal file
View File

@ -0,0 +1,36 @@
<h1>{{$header}}</h1>
{{if $poi}}
<div class="directory-item lframe" id="directory-item-{{$poi.xchan_hash}}" >
<div class="contact-photo-wrapper" id="directory-photo-wrapper-{{$poi.xchan_hash}}" >
<div class="contact-photo" id="directory-photo-{{$poi.xchan_hash}}" >
<a href="{{$poi.xchan_url}}" class="directory-profile-link" id="directory-profile-link-{{$poi.xchan_hash}}" ><img class="directory-photo-img" src="{{$poi.xchan_photo_l}}" alt="{{$poi.xchan_addr}}" title="{{$poi.xchan_addr}}" /></a>
<div class="contact-name">{{$poi.xchan_name}}</div>
</div>
</div>
{{/if}}
{{if $raters}}
{{foreach $raters as $r}}
<div class="directory-item lframe" id="directory-item-{{$r.xchan_hash}}" >
<div class="contact-photo-wrapper" id="directory-photo-wrapper-{{$r.xchan_hash}}" >
<div class="contact-photo" id="directory-photo-{{$r.xchan_hash}}" >
<a href="{{$r.xchan_url}}" class="directory-profile-link" id="directory-profile-link-{{$r.xchan_hash}}" ><img class="directory-photo-img" src="{{$r.xchan_photo_l}}" alt="{{$r.xchan_addr}}" title="{{$r.xchan_addr}}" /></a>
<div class="contact-name">{{$r.xchan_name}}</div>
</div>
Rating: {{$r.xlink_rating}}
{{if $r.xlink_rating_text}}
Reason: {{$r.xlink_rating_text}}
{{/if}}
</div>
{{/foreach}}
{{/if}}