1: <?php
2: 3: 4: 5: 6: 7: 8:
9: class Ansel_Widget_OwnerFaces extends Ansel_Widget_Base
10: {
11: protected $_faces;
12: protected $_count;
13: protected $_owner;
14:
15: 16: 17: 18: 19:
20: public function html()
21: {
22: if (!$GLOBALS['conf']['faces']['driver']) {
23: return '';
24: }
25:
26: $this->_faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
27: $this->_owner = $this->_view->gallery->get('owner');
28: try {
29: $this->_count = $this->_faces->countOwnerFaces($this->_owner);
30: } catch (Horde_Exception $e) {
31: Horde::logMessage($e->getMessage(), 'ERR');
32: $this->_count = 0;
33: }
34: if (empty($this->_count)) {
35: return null;
36: }
37:
38: $this->_title = Horde::url('faces/search/owner.php')->add('owner', $this->_owner)->link()
39: . sprintf(_("People in galleries owned by %s (%d of %d)"), $this->_owner, min(12, $this->_count), number_format($this->_count))
40: . '</a>';
41:
42: $html = $this->_htmlBegin();
43:
44: $results = $this->_faces->ownerFaces($this->_owner, 0, 12, true);
45: $html .= '<div style="display: block'
46: . ';background:' . $this->_style->background
47: . ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >';
48: foreach ($results as $face) {
49: $facename = htmlspecialchars($face['face_name']);
50: $html .= '<a href="' . Ansel_Faces::getLink($face) . '" title="' . $facename . '">'
51: . '<img src="' . $this->_faces->getFaceUrl($face['image_id'], $face['face_id'], 'mini')
52: . '" style="padding-bottom: 5px; padding-left: 5px" alt="' . $facename . '" /></a>';
53: }
54:
55: return $html . '</div>' . $this->_htmlEnd();
56: }
57: }
58: