/** * Helper function for getting faces for this gallery. * * @return string The HTML */ protected function _getFaceNames() { if ($this->_view->resource->get('faces') <= 0) { return '<div id="faces_widget_content"><br /><em>' . _("No faces found") . '</em></div>'; } $faces = $GLOBALS['injector']->getInstance('Ansel_Faces'); // Check for existing faces for this gallery. $html = '<div style="display: block' . ';background:' . $this->_style->background . ';width:100%;max-height:300px;overflow:auto;" id="faces_widget_content" >'; $images = $faces->getGalleryFaces($this->_view->resource->id); if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $link_text = empty($images) ? _("Find faces") : _("Edit faces"); $html .= Horde::url('faces/gallery.php')->add('gallery', $this->_view->gallery->id)->link(array('id' => 'edit_faces', 'class' => 'widget')) . $link_text . '</a>'; } $faces_html = '<div id="faces-on-gallery">'; // Iterate over all the found faces and build the tiles. shuffle($images); foreach ($images as $face) { // Get the tile for this face $html .= Ansel_Faces::getFaceTile($face); } // Close up the nodes $html .= '</div></div></div></div>'; return $html; }
/** * Sets a name in an image. */ public function setFaceName() { global $injector, $registry; $face_id = intval($this->vars->face_id); $image_id = intval($this->vars->image_id); $name = $this->vars->face_name; $storage = $injector->getInstance('Ansel_Storage'); $image = $storage->getImage($image_id); $gallery = $storage->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { throw new Ansel_Exception('You are not allowed to edit this photo'); } $injector->getInstance('Ansel_Faces')->setName($face_id, $name); $results = new stdClass(); $results->results = Ansel_Faces::getFaceTile($face_id); return new Horde_Core_Ajax_Response($results); }
<?php if (empty($this->images)) { ?> <br /><em><?php echo _("No faces found"); ?> </em> <?php } ?> <div id="faces-on-image"> <?php foreach ($this->images as $face) { ?> <?php echo Ansel_Faces::getFaceTile($face); ?> <div id="facediv<?php echo $face['face_id']; ?> " class="face-div" style="width:<?php echo $face['face_x2'] - $face['face_x1']; ?> px;margin-left:<?php echo $face['face_x1']; ?> px;height:<?php echo $face['face_y2'] - $face['face_y1']; ?> px;margin-top:<?php echo $face['face_y1'];