some faces cleanup.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 31 May 2010 19:20:22 +0000 (15:20 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 31 May 2010 19:20:58 +0000 (15:20 -0400)
this code is still a complete mess and needs to be completely rewritten for H4

ansel/faces/face.php
ansel/faces/image.php
ansel/lib/Ajax/Imple/EditFaces.php
ansel/templates/faces/face.inc
ansel/templates/faces/gallery.inc
ansel/templates/faces/image.inc

index f306408..38856da 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Shows all images that the supplied, named face appears on?
+ * Shows all images that the supplied, named face appears on.
  *
  * TODO: Maybe incorporate this into some kind of generic "result" view?
  * At least, we need to rename this to something other that image.php to
@@ -13,7 +13,6 @@
  *
  * @author Duck <duck@obala.net>
  */
-
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
@@ -28,7 +27,7 @@ try {
 }
 
 $title = _("Face") . ' :: ' . $face['face_name'];
-
+$facename = htmlspecialchars($face['face_name']);
 require ANSEL_TEMPLATES . '/common-header.inc';
 require ANSEL_TEMPLATES . '/menu.inc';
 require_once ANSEL_TEMPLATES . '/faces/face.inc';
index 873a6a7..3ba044e 100644 (file)
@@ -24,7 +24,7 @@ $result = $faces->getImageFacesData($image_id);
 // Attempt to get faces from the picture if we don't already have results,
 // or if we were asked to explicitly try again.
 if (($reload || empty($result))) {
-    $image = &$ansel_storage->getImage($image_id);
+    $image = $ansel_storage->getImage($image_id);
     try {
         $image->createView('screen');
         $result = $faces->getFromPicture($image_id, $autocreate);
index 44d0d0d..2e1d0cb 100644 (file)
@@ -49,16 +49,15 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
                 // Attempt to get faces from the picture if we don't already have results,
                 // or if we were asked to explicitly try again.
                 if (($reload || empty($result))) {
-                    $image = &$GLOBALS['ansel_storage']->getImage($image_id);
+                    $image = $GLOBALS['ansel_storage']->getImage($image_id);
                     $image->createView('screen');
                     $result = $faces->getFromPicture($image_id, $autocreate);
                 }
                 if (!empty($result)) {
-                    $imgdir = Horde_Themes::img(null, 'horde');
                     $customurl = Horde::applicationUrl('faces/custom.php');
                     $url = (!empty($args['url']) ? urldecode($args['url']) : '');
                     Horde::startBuffer();
-                    require_once ANSEL_TEMPLATES . '/faces/image.inc';
+                    include ANSEL_TEMPLATES . '/faces/image.inc';
                     $html = Horde::endBuffer();
                     return array('response' => 1,
                                  'message' => $html);
@@ -71,14 +70,13 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
             case 'delete':
                 // delete - deletes a single face from an image.
                 $face_id = (int)$post['face'];
-                $image = &$GLOBALS['ansel_storage']->getImage($image_id);
-                $gallery = &$GLOBALS['ansel_storage']->getGallery($image->gallery);
+                $image = $GLOBALS['ansel_storage']->getImage($image_id);
+                $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
                 if (!$gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
                     throw new Horde_Exception('Access denied editing the photo.');
                 }
 
-                $faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
-                $faces->delete($image, $face_id);
+                Ansel_Faces::delete($image, $face_id);
                 break;
 
             case 'setname':
index b064dea..774cf93 100755 (executable)
@@ -2,18 +2,14 @@
 <table>
  <tr valign="top">
   <td style="text-align: center">
-   <?php $facename = htmlspecialchars($face['face_name']);
-         echo $facebame;
-   ?><br />
+   <?php echo $facename;?><br />
    <img src="<?php echo $faces->getFaceUrl($face['image_id'], $face_id) ?>" style="padding: 5px;" alt="<?php echo $facename?>" /><br />
    <?php echo sprintf(ngettext("%d gallery", "%d galleries", count($face['galleries'])), count($face['galleries'])); ?><br />
    <?php if ($GLOBALS['conf']['report_content']['driver']): ?>
    <a href="<?php echo Horde_Util::addParameter(Horde::applicationUrl('faces/report.php'), 'face', $face_id) ?>" class="small" title="<?php echo _("Report abuse or submit a removal request") ?>"><?php echo _("Report") ?></a><br />
-   <?php
-    endif;
-    if ($conf['faces']['search']) {
-        echo '<a href="' . Horde_Util::addParameter(Horde::applicationUrl('faces/search/image_search.php'), 'face_id', $face_id)
-             . '" title="' . _("Find similar") . '">' . _("Similar faces") . '</a>';
+   <?php endif; ?>
+   <?php if ($conf['faces']['search']) {
+        echo '<a href="' . Horde_Util::addParameter(Horde::applicationUrl('faces/search/image_search.php'), 'face_id', $face_id) . '" title="' . _("Find similar") . '">' . _("Similar faces") . '</a>';
     }
     ?>
   </td>
    <?php
     $styleDef = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
     $style = $styleDef['name'];
-
     foreach (array_keys($face['galleries']) as $gallery_id) {
         foreach ($face['galleries'][$gallery_id] as $imageId) {
             echo '<div style="float: left; text-align: center;"><img src="' . Ansel::getImageUrl($imageId, 'thumb', false, $style) . '" style="padding: 5px;" alt="' . $imageId . '" /><br />';
             echo '<a href="' . Ansel::getUrlFor('view', array('view' => 'Image',
-                                                                    'gallery' => $gallery_id,
-                                                                    'image' => $imageId));
+                                                              'gallery' => $gallery_id,
+                                                              'image' => $imageId));
 
             echo '">' . _("Photo") . '</a> / ';
             echo '<a href="' . Ansel::getUrlFor('view', array('view' => 'Gallery',
@@ -35,7 +30,6 @@
             echo '">' . _("Gallery") . '</a></div>';
         }
     }
-
     ?>
   </td>
  </tr>
index dbdcb26..5e0746a 100644 (file)
  foreach ($images as $image):
     $imageids[$image->id] = $image->id;
  ?>
   <tr>
-     <td style="text-align: center">
-     <?php echo $image->filename; ?><br /><br />
-     <?php if ($autogenerate): ?>
-      <a href="javascript:void(0)" onclick="proccessImageFaces(<?php echo $image->id ?>, 1)">
-      <?php echo $reloadimage . _("Reget faces for this photo") ?></a><br />
-     <?php endif; ?>
-
-     <a href="<?php echo Horde_Util::addParameter($customurl, array('image' => $image->id, 'gallery' => $image->gallery)) ?>">
-     <?php echo  $customimage .  _("Add a custom face range") ?></a><br />
-    </td>
-    <td style="text-align: center">
-    <a href="<?php echo Ansel::getUrlFor('view', array('view' => 'Image', 'image' => $image->id, 'gallery' => $image->gallery)); ?>" target="_blank">
-    <img src="<?php echo Ansel::getImageUrl($image->id, 'thumb'); ?>" alt="<?php echo htmlspecialchars($image->filename)?>" /></a></td>
-    <td><div id="processface<?php echo $image->id ?>" name="processface<?php echo $image->id ?>"><?php echo _("Loading...") ?></div></td>
   </tr>
+ <tr>
+  <td style="text-align: center">
+   <?php echo $image->filename; ?><br /><br />
+   <?php if ($autogenerate): ?>
+    <a href="javascript:void(0)" onclick="proccessImageFaces(<?php echo $image->id ?>, 1)">
+    <?php echo $reloadimage . _("Reget faces for this photo") ?></a><br />
+   <?php endif; ?>
+   <?php echo $customurl->add(array('image' => $image->id, 'gallery' => $image->gallery))->link()?>
+   <?php echo  $customimage .  _("Add a custom face range") ?></a><br />
+  </td>
+  <td style="text-align: center">
+   <a href="<?php echo Ansel::getUrlFor('view', array('view' => 'Image', 'image' => $image->id, 'gallery' => $image->gallery)); ?>" target="_blank">
+   <img src="<?php echo Ansel::getImageUrl($image->id, 'thumb'); ?>" alt="<?php echo htmlspecialchars($image->filename)?>" /></a>
+  </td>
+  <td><div id="processface<?php echo $image->id ?>" name="processface<?php echo $image->id ?>"><?php echo _("Loading...") ?></div></td>
+ </tr>
  <?php endforeach; ?>
 </table>
 <?php echo $pager->render() ?>
index 272ca21..c21ee04 100755 (executable)
@@ -1,12 +1,9 @@
 <?php foreach ($result as $face_id => $face_name):?>
     <div id="face<?php echo $face_id ?>">
-    <img src="<?php echo $autocreate ? $faces->getFaceUrl($image_id, $face_id) : Horde_Util::addParameter(Horde::applicationUrl('faces/img.php'), 'face', $face_id); ?>" alt="<?php echo $face_id ?>" style="padding-bottom: 5px; padding-left: 5px; width: 50px; height: 50px;" />
-    <input type="text" name="facename<?php echo $face_id ?>" id="facename<?php echo $face_id ?>" size="15" value="<?php echo $face_name ?>" />
-    <a href="javascript:void(0)" onclick="Ansel.setFaceName(<?php echo $image_id ?>, <?php echo $face_id ?>)" title="<?php echo _("Save face name") ?>">
-      <img src="<?php echo $imgdir ?>/save.png" alt="[icon]" /></a>
-    <a href="javascript:void(0)" onclick="Ansel.deleteFace(<?php echo $image_id ?>, <?php echo $face_id ?>)" title="<?php echo _("Delete face") ?>">
-      <img src="<?php echo $imgdir ?>/delete.png" alt="[icon]" /></a>
-    <a href="<?php echo Horde_Util::addParameter($customurl, array('face' => $face_id, 'image' => $image_id, 'url' => (!empty($url) ? $url : '')), null, false) ?>" title="<?php echo _("Edit face region") ?>">
-      <img src="<?php echo $imgdir ?>/edit.png" alt="[icon]" /></a>
+      <img src="<?php echo $autocreate ? $faces->getFaceUrl($image_id, $face_id) : Horde::applicationUrl('faces/img.php')->add('face', $face_id); ?>" alt="<?php echo $face_id ?>" style="padding-bottom: 5px; padding-left: 5px; width: 50px; height: 50px;" />
+      <input type="text" name="facename<?php echo $face_id ?>" id="facename<?php echo $face_id ?>" size="15" value="<?php echo $face_name ?>" />
+      <a href="javascript:void(0)" onclick="Ansel.setFaceName(<?php echo $image_id ?>, <?php echo $face_id ?>)" title="<?php echo _("Save face name") . '">' . Horde::img('save.png')?></a>
+      <a href="javascript:void(0)" onclick="Ansel.deleteFace(<?php echo $image_id ?>, <?php echo $face_id ?>)" title="<?php echo _("Delete face") . '">' . Horde::img('delete.png')?></a>
+      <?php echo $customurl->add(array('face' => $face_id, 'image' => $image_id, 'url' => (!empty($url) ? $url : '')))->link(array('title' => _("Edit face region"))) . Horde::img('edit.png')?></a>
     </div>
 <?php endforeach;?>