1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: class Ansel_Widget_GalleryFaces extends Ansel_Widget_Base
14: {
15: 16: 17: 18: 19:
20: protected $_supported_views = array('Gallery');
21:
22: 23: 24: 25: 26: 27:
28: public function __construct($params)
29: {
30: parent::__construct($params);
31: $this->_title = _("People in this gallery");
32: }
33:
34: 35: 36: 37: 38:
39: public function html()
40: {
41: if ($GLOBALS['conf']['faces']['driver']) {
42: $html = $this->_getFaceNames();
43: return $this->_htmlBegin() . $html . $this->_htmlEnd();
44: } else {
45: return '';
46: }
47: }
48:
49: 50: 51: 52: 53:
54: protected function _getFaceNames()
55: {
56: if ($this->_view->resource->get('faces')) {
57: return '<div id="faces_widget_content"><br /><em>' . _("No faces found") . '</em></div>';
58: }
59:
60: $faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
61:
62:
63: $html = '<div style="display: block'
64: . ';background:' . $this->_style->background
65: . ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >';
66:
67: $images = $faces->getGalleryFaces($this->_view->resource->id);
68: if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
69: $link_text = (empty($images) ? _("Find faces") : _("Edit faces"));
70: $html .= Horde::url('faces/gallery.php')->add('gallery', $this->_view->gallery->id)->link(
71: array('id' => 'edit_faces',
72: 'class' => 'widget'))
73: . $link_text . '</a>';
74: }
75:
76: $faces_html = '<div id="faces-on-gallery">';
77:
78:
79: shuffle($images);
80: foreach ($images as $face) {
81:
82: $html .= Ansel_Faces::getFaceTile($face);
83: }
84:
85:
86: $html .= '</div></div></div></div>';
87:
88: return $html;
89: }
90:
91: }
92: