/usr/share/horde/ansel/lib/Widget/ImageFaces.php is in php-horde-ansel 3.0.5+debian0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | <?php
/**
* Horde_Widget_ImageFaces:: class to display a widget containing mini
* thumbnails of faces in the image.
*
* Copyright 2008-2016 Horde LLC (http://www.horde.org/)
*
* @author Duck <duck@obala.net>
* @author Michael J. Rubinsky <mrubinsk@horde.org>
*
* @package Ansel
*/
class Ansel_Widget_ImageFaces extends Ansel_Widget_Base
{
/**
* The views this Widget may appear in
*
* @var array
*/
protected $_supported_views = array('Image');
/**
* Attach widget to supplied view.
*
* @param Ansel_View_Base $view
*
* @return boolean
*/
public function attach(Ansel_View_Base $view)
{
if (empty($GLOBALS['conf']['faces']['driver'])) {
return false;
}
$GLOBALS['page_output']->addScriptFile('imagefaces.js');
return parent::attach($view);
}
/**
* Return the HTML representing this widget.
*
* @return string The HTML for this widget.
*/
public function html()
{
$view = $GLOBALS['injector']->getInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/widgets');
$view->title = _("People in this Photo");
$view->background = $this->_style->background;
$view->hasEdit = $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
$faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
$view->images = $faces->getImageFacesData($this->_view->resource->id, true);
if ($view->hasEdit) {
$view->editUrl = strval(Horde::url('faces/gallery.php')->add('gallery', $this->_view->gallery->id));
$view->manualUrl = strval(Horde::url('faces/custom.php')->add(array('image' => $this->_view->resource->id, 'url' => $this->_params['selfUrl'])));
// Attach the ajax edit actions
$GLOBALS['injector']
->getInstance('Horde_Core_Factory_Imple')
->create(
'Ansel_Ajax_Imple_EditFaces',
array('id' => 'edit_faces', 'image_id' => $this->_view->resource->id)
);
}
$faces_js = '';
// Iterate over all the found faces and build the tiles.
foreach ($view->images as $face) {
// Attach events to the face tile for showing the overlay
$faces_js .= '$(\'facediv' . $face['face_id'] . '\').observe(\'mouseover\', function() {showFace(' . $face['face_id'] . ')});'
. '$(\'facediv' . $face['face_id'] . '\').observe(\'mouseout\', function() {hideFace(' . $face['face_id'] . ')});'
. '$(\'face' . $face['face_id'] . '\').firstDescendant().observe(\'mouseover\', function() {showFace(' . $face['face_id'] . ')});'
. '$(\'face' . $face['face_id'] . '\').firstDescendant().observe(\'mouseout\', function() {hideFace(' . $face['face_id'] . ')});';
}
$GLOBALS['page_output']->addInlineScript($faces_js, 'dom');
return $view->render('imagefaces');
}
}
|