*
* See horde/config/prefs.php for documentation on the structure of this file.
*/
-
-// Make sure that constants are defined.
-require_once dirname(__FILE__) . '/../lib/Ansel.php';
-
$prefGroups['display'] = array(
'column' => _("General Options"),
'label' => _("Display Options"),
/**
* Identify a person in a photo
*
- * $Horde: ansel/faces/claim.php,v 1.9 2009/06/10 00:33:02 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
*
* @author Duck <duck@obala.net>
*/
-define('ANSEL_BASE', dirname(__FILE__) . '/../');
-require_once ANSEL_BASE . '/lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
-
-require_once 'Horde/Form.php';
+require_once dirname(__FILE__) . '/../lib/base.php';
$faces = Ansel_Faces::factory();
-
$face_id = Horde_Util::getFormData('face');
-$face = $faces->getFaceById($face_id);
-
-if (is_a($face, 'PEAR_Error')) {
- $notification->push($face->getMessage());
+try {
+ $face = $faces->getFaceById($face_id);
+} catch (Horde_Exception $e) {
+ $notification->push($e->getMessage());
header('Location: ' . Horde::applicationUrl('faces/search/all.php'));
exit;
}
/**
* Explicitly add/edit a face range to an image.
*
- * $Horde: ansel/faces/custom.php,v 1.14 2009/07/08 18:28:41 slusarz Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
$name = Horde_Util::getFormData('name');
if ($face_id) {
- require_once ANSEL_BASE . '/lib/Faces.php';
$faces = Ansel_Faces::factory();
-
- if (is_a($faces, 'PEAR_Error')) {
- $notification->push($faces);
- header('Location: ' . $back_url);
- exit;
+ try {
+ $face = $faces->getFaceById($face_id, true);
+ } catch (Horde_Exception $e) {
+ $notification->push($e->getMessage());
}
- $face = $faces->getFaceById($face_id, true);
- if (is_a($face, 'PEAR_Error')) {
- $notification->push($face);
- } else {
- $x1 = $face['face_x1'];
- $y1 = $face['face_y1'];
- $x2 = $face['face_x2'];
- $y2 = $face['face_y2'];
- if (!empty($face['face_name'])) {
- $name = $face['face_name'];
- }
+ $x1 = $face['face_x1'];
+ $y1 = $face['face_y1'];
+ $x2 = $face['face_x2'];
+ $y2 = $face['face_y2'];
+ if (!empty($face['face_name'])) {
+ $name = $face['face_name'];
}
}
/**
* Delete a face from an image.
*
- * $Horde: ansel/faces/delete.php,v 1.10 2009/07/30 18:02:13 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
$image_id = (int)Horde_Util::getFormData('image');
$face_id = (int)Horde_Util::getFormData('face');
}
$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
-}
-
$result = $faces->delete($image, $face_id);
-if (is_a($result, 'PEAR_Error')) {
- die($result->getMessage());
-}
+
* At least, we need to rename this to something other that image.php to
* reflect what it's used for.
*
- * $Horde: ansel/faces/face.php,v 1.6 2009/06/10 00:33:02 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
-
$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
-}
-
$face_id = Horde_Util::getFormData('face');
-$face = $faces->getFaceById($face_id);
-if (is_a($face, 'PEAR_Error')) {
+try {
+ $face = $faces->getFaceById($face_id);
+} catch (Horde_Exception $e) {
$notification->push($face->getMessage());
header('Location: ' . Horde::applicationUrl('faces/index.php'));
exit;
require ANSEL_TEMPLATES . '/common-header.inc';
require ANSEL_TEMPLATES . '/menu.inc';
-
require_once ANSEL_TEMPLATES . '/faces/face.inc';
-
require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
*
* TODO: Turn this into an Ansel_View::
*
- * $Horde: ansel/faces/gallery.php,v 1.16 2009/07/13 21:33:53 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
$customurl = Horde_Util::addParameter(Horde::applicationUrl('faces/custom.php'), 'page', $page);
$face = Ansel_Faces::factory();
$autogenerate = $face->canAutogenerate();
-
$vars = Horde_Variables::getDefaultVariables();
$pager = new Horde_UI_Pager(
'page', $vars,
/**
* Process an single image (to be called via Ajax)
*
- * $Horde: ansel/faces/image.php,v 1.10 2009/06/10 00:33:02 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
-}
$name = '';
$autocreate = true;
// or if we were asked to explicitly try again.
if (($reload || empty($result))) {
$image = &$ansel_storage->getImage($image_id);
- if (is_a($image, 'PEAR_Error')) {
- exit;
- }
-
- $result = $image->createView('screen');
- if (is_a($result, 'PEAR_Error')) {
- exit;
- }
-
+ $image->createView('screen');
$result = $faces->getFromPicture($image_id, $autocreate);
- if (is_a($result, 'PEAR_Error')) {
- exit;
- }
}
if (!empty($result)) {
/**
* Fetch face image for display
*
- * $Horde: ansel/faces/img.php,v 1.11 2009/06/10 00:33:02 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
$face_id = Horde_Util::getFormData('face');
$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- Horde::logMessage($faces, __FILE__, __LINE__, PEAR_LOG_ERR);
- exit;
-}
// Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file
// header
// Run it through PHP
$img = $faces->getFaceImageObject($face_id);
-if (is_a($img, 'PEAR_Error')) {
- exit;
-}
header('Content-type: image/' . $GLOBALS['conf']['image']['type']);
echo $img->raw();
/**
* Set the name of a single image via Ajax
*
- * $Horde: ansel/faces/name.php,v 1.9 2009/07/08 18:28:41 slusarz Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
$image_id = (int)Horde_Util::getFormData('image');
$face_id = (int)Horde_Util::getFormData('face');
$name = Horde_Util::getFormData('name');
$image = &$ansel_storage->getImage($image_id);
-if (is_a($image, 'PEAR_Error')) {
- die($image->getMessage());
-}
-
$gallery = &$ansel_storage->getGallery($image->gallery);
if (!$gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)) {
- die(_("Access denied editing the photo."));
+ throw new Horde_Exception('Access denied editing the photo.');
}
$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
-}
-
-$result = $faces->setName($face_id, $name);
-if (is_a($result, 'PEAR_Error')) {
- die($result->getDebugInfo());
-}
\ No newline at end of file
+$result = $faces->setName($face_id, $name);
\ No newline at end of file
/**
* Process an single image (to be called by ajax)
*
- * $Horde: ansel/faces/report.php,v 1.9 2009/06/10 00:33:02 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
-
-require_once 'Horde/Form.php';
-
-$faces = Ansel_Faces::factory();
$face_id = Horde_Util::getFormData('face');
-$face = $faces->getFaceById($face_id);
-if (is_a($face, 'PEAR_Error')) {
- $notification->push($face->getMessage());
+$faces = Ansel_Faces::factory();
+try {
+ $face = $faces->getFaceById($face_id);
+} catch (Horde_Exception $e) {
+ $notification->push($e->getMessage());
header('Location: ' . Horde::applicationUrl('faces/search/all.php'));
exit;
}
if ($form->validate()) {
if (Horde_Util::getFormData('submitbutton') == _("Cancel")) {
-
$notification->push(_("Action was cancelled."), 'horde.warning');
-
} else {
-
require ANSEL_BASE . '/lib/Report.php';
$report = Ansel_Report::factory();
$gallery = $ansel_storage->getGallery($face['gallery_id']);
. _("Face") . ': ' . $face_link;
$report->setTitle($title);
- $result = $report->report($body, $gallery->get('owner'));
- if (is_a($result, 'PEAR_Error')) {
- $notification->push(_("Face name was not reported.") . ' ' .
- $result->getMessage(), 'horde.error');
- } else {
- $notification->push(_("The owner of the photo was notified."), 'horde.success');
+ try {
+ $result = $report->report($body, $gallery->get('owner'));
+ } catch (Horde_Exception $e) {
+ $notification->push(sprintf(_("Face name was not reported: %s"), $e->getMessage()), 'horde.error');
}
-
+ $notification->push(_("The owner of the photo was notified."), 'horde.success');
}
header('Location: ' . Ansel_Faces::getLink($face));
/**
* Process an single image (to be called by ajax)
*
- * $Horde: ansel/faces/savecustom.php,v 1.10 2009/07/06 15:50:34 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
$image_id = (int)Horde_Util::getFormData('image_id');
$gallery_id = (int)Horde_Util::getFormData('gallery_id');
header('Location: ' . $back_url);
exit;
}
-
-$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- $notification->push($faces);
- header('Location: ' . $back_url);
- exit;
-}
-
-$result = $faces->saveCustomFace($face_id,
+try {
+ $faces = Ansel_Faces::factory();
+ $result = $faces->saveCustomFace(
+ $face_id,
$image_id,
(int)Horde_Util::getFormData('x1'),
(int)Horde_Util::getFormData('y1'),
(int)Horde_Util::getFormData('x2'),
(int)Horde_Util::getFormData('y2'),
Horde_Util::getFormData('name'));
-
-if (is_a($result, 'PEAR_Error')) {
- $notification->push($result);
- $notification->push($result->getDebugInfo());
+} catch (Horde_Exception $e) {
+ $notification->push($e->getMessage());
header('Location: ' . $back_url);
exit;
-} elseif ($face_id == 0) {
+}
+
+if ($face_id == 0) {
$notification->push(_("Face successfuly created"), 'horde.success');
} else {
$notification->push(_("Face successfuly updated"), 'horde.success');
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/UI/Pager.php';
$title = _("All faces");
$page = Horde_Util::getFormData('page', 0);
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/Form.php';
-require_once 'Horde/Image.php';
/* Search from */
$form = new Horde_Form($vars);
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/Image.php';
/* Check if image exists. */
$tmp = Horde::getTempDir();
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/UI/Pager.php';
$page = Horde_Util::getFormData('page', 0);
$perpage = $prefs->getValue('facesperpage');
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
/* Face search is allowd only to */
if (!Horde_Auth::isauthenticated()) {
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/Form.php';
-require_once 'Horde/UI/Pager.php';
/* Search from */
$form = new Horde_Form($vars);
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/UI/Pager.php';
$title = _("Named faces");
$page = Horde_Util::getFormData('page', 0);
* @author Duck <duck@obala.net>
*/
require_once 'tabs.php';
-require_once 'Horde/UI/Pager.php';
$page = Horde_Util::getFormData('page', 0);
$perpage = $prefs->getValue('facesperpage');
/**
* Process an single photo (to be called by ajax)
*
- * $Horde: ansel/faces/search/tabs.php,v 1.10 2009/07/22 21:08:09 mrubinsk Exp $
- *
* Copyright 2008-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <duck@obala.net>
*/
require_once dirname(__FILE__) . '/../../lib/base.php';
-require_once ANSEL_BASE . '/lib/Faces.php';
-require_once 'Horde/UI/Tabs.php';
$faces = Ansel_Faces::factory();
-if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
-}
-
/* Face search is allowed only to authenticated users */
if (!Horde_Auth::isauthenticated()) {
Horde_Auth::authenticationFailureRedirect();
}
$faces = Ansel_Faces::factory();
- if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
- }
-
switch($action) {
case 'process':
// process - detects all faces in the image.
// or if we were asked to explicitly try again.
if (($reload || empty($result))) {
$image = &$GLOBALS['ansel_storage']->getImage($image_id);
- if (is_a($image, 'PEAR_Error')) {
- exit;
- }
-
- $result = $image->createView('screen');
- if (is_a($result, 'PEAR_Error')) {
- exit;
- }
-
+ $image->createView('screen');
$result = $faces->getFromPicture($image_id, $autocreate);
- if (is_a($result, 'PEAR_Error')) {
- exit;
- }
}
if (!empty($result)) {
$imgdir = $GLOBALS['registry']->getImageDir('horde');
// delete - deletes a single face from an image.
$face_id = (int)Horde_Util::getPost('face');
$image = &$GLOBALS['ansel_storage']->getImage($image_id);
- if (is_a($image, 'PEAR_Error')) {
- die($image->getMessage());
- }
-
$gallery = &$GLOBALS['ansel_storage']->getGallery($image->gallery);
if (!$gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)) {
- die(_("Access denied editing the photo."));
+ throw new Horde_Exception('Access denied editing the photo.');
}
$faces = Ansel_Faces::factory();
- if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
- }
-
- $result = $faces->delete($image, $face_id);
- if (is_a($result, 'PEAR_Error')) {
- die($result->getMessage());
- }
+ $faces->delete($image, $face_id);
break;
case 'setname':
$name = Horde_Util::getPost('facename');
$image = &$GLOBALS['ansel_storage']->getImage($image_id);
- if (is_a($image, 'PEAR_Error')) {
- die($image->getMessage());
- }
-
$gallery = &$GLOBALS['ansel_storage']->getGallery($image->gallery);
if (!$gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)) {
- die(_("You are not allowed to edit this photo."));
+ throw new Horde_Exception('You are not allowed to edit this photo');
}
$faces = Ansel_Faces::factory();
- if (is_a($faces, 'PEAR_Error')) {
- die($faces->getMessage());
- }
-
$result = $faces->setName($face_id, $name);
- if (is_a($result, 'PEAR_Error')) {
- die($result->getDebugInfo());
- }
-
return array('response' => 1,
'message' => Ansel_Faces::getFaceTile($face_id));
break;
* This file provides a recent faces through the Horde_Blocks, by extending
* the Horde_Blocks class.
*
- * $Horde: ansel/lib/Block/recent_faces.php,v 1.3 2009/07/13 17:18:39 mrubinsk Exp $
- *
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Duck <Duck@obala.net>
* @package Horde_Block
*/
-class Horde_Block_ansel_recent_faces extends Horde_Block {
-
+class Horde_Block_ansel_recent_faces extends Horde_Block
+{
var $_app = 'ansel';
function _params()
function _content()
{
require_once dirname(__FILE__) . '/../base.php';
- require_once ANSEL_BASE . '/lib/Faces.php';
$faces = Ansel_Faces::factory();
-
$results = $faces->allFaces(0, $this->_params['limit']);
- if (is_a($results, 'PEAR_Error')) {
- return $results;
- }
-
$html = '';
foreach ($results as $face_id => $face) {
$facename = htmlspecialchars($face['face_name'], ENT_COMPAT, Horde_Nls::getCharset());