[dev] [commit] r1030 - templates/admin wwwbase/admin wwwbase/ajax wwwbase/elfinder-connector wwwbase/js wwwbase/styles

automailer at dexonline.ro automailer at dexonline.ro
Tue Oct 22 20:34:18 EEST 2013


Author: grigoroiualex
Date: Tue Oct 22 20:34:18 2013
New Revision: 1030

Log:
Commented some code.
If an image can't be found at the address specified in the Visual table, an error appears
on the tagging page instead of the image.
Added custom links to the admin header for an easier navigation between visualDict pages.
An image can be deleted from the summary tables.
Managed to correctly wrap the tags lexemes in the table cell.

Added:
   wwwbase/ajax/visualImagesEdit.php
Modified:
   templates/admin/visualTag.ihtml
   templates/admin/visualTagging.ihtml
   wwwbase/admin/visualTag.php
   wwwbase/ajax/visualGetImages.php
   wwwbase/elfinder-connector/visual_connector.php
   wwwbase/js/visualTag.js
   wwwbase/styles/visualDict.css

Modified: templates/admin/visualTag.ihtml
==============================================================================
--- templates/admin/visualTag.ihtml	Mon Oct 21 21:20:24 2013	(r1029)
+++ templates/admin/visualTag.ihtml	Tue Oct 22 20:34:18 2013	(r1030)
@@ -1,14 +1,21 @@
 <br/>
-<div id="revised">
-  <table id="revisedTable"></table>
-  <div id="revisedPaging"></div>
-</div>
-<div id="unrevised">
-  <table id="unrevisedTable"></table>
-  <div id="unrevisedPaging"></div>
+<div class="tablesWrapper">
+  <div id="revised">
+    <table id="revisedTable"></table>
+    <div id="revisedPaging"></div>
+  </div>
+  <div id="unrevised">
+    <table id="unrevisedTable"></table>
+    <div id="unrevisedPaging"></div>
+  </div>
 </div>
 
 <form diplay="none" method="post">
   <input id="imgToTag" type="hidden" name="imgToTag"/>
   <input type="hidden" name="tagging" value="1"/>
-</form>
\ No newline at end of file
+</form>
+
+<div class="extraAdminHeaderLinks"> 
+  | <a href="visual.php">Pagina de încărcare</a>
+  | <a href="">Tabelele centralizatoare</a>
+</div>

Modified: templates/admin/visualTagging.ihtml
==============================================================================
--- templates/admin/visualTagging.ihtml	Mon Oct 21 21:20:24 2013	(r1029)
+++ templates/admin/visualTagging.ihtml	Tue Oct 22 20:34:18 2013	(r1030)
@@ -1,7 +1,7 @@
 <br/>
 {if !$imgLexemeId}
-  <div class="visualTagImg">
-    <img src="{$imagePath}"/>
+  <div id="visualTagCanvas">
+    <img class="visualTagImg" src="{$imagePath}"/>
   </div> 
   <div>
     <form action="visualTag.php" method="post">
@@ -19,7 +19,7 @@
 {else}
   {include file="common/bits/prototypes.ihtml"}
   <div id="visualTagCanvas">
-    <img src="{$imagePath}" id="jcrop" title="{$imageId}"/>
+    <img  id="jcrop" class="visualTagImg" src="{$imagePath}" title="{$imageId}"/>
     <div id="selectionOptions">
       <label>Coordonatele centrului selecției:
         <input id="x" type="text" size="4" name="x"/>
@@ -66,23 +66,23 @@
         <input id="lexemId" type="hidden"/>
       </label><br/>
 
-      <input id="lexemeId" type="hidden"/>
+      <input id="lexemeId" type="hidden"/><br/>
 
       <label>Text de afișat
         <input id="label" type="text" size="20"/>
       </label><br/>
 
-      <label>Coordonatele centrului etichetei:
+      <label>Coordonatele centrului etichetei:<br/>
         <input id="xTag" type="text" size="4"/>
         <input id="yTag" type="text" size="4"/>
         <button id="setCoordTag" type="button">Setează coordonatele</button>
       </label><br/>
 
-      <label>Coordonatele zonei etichetate:
+      <label>Coordonatele zonei etichetate:<br/>
         <input id="xImg" type="text" size="4"/>
         <input id="yImg" type="text" size="4"/>
         <button id="setCoordImg" type="button">Setează coordonatele</button>
-      </label><br/>
+      </label><br/><br/>
 
       <button id="saveSel" type="button">Salvează eticheta</button>
     </div>
@@ -98,3 +98,16 @@
     $(replaceSubmitEvent);
   </script>
 {/if}
+
+<p class="missingImageError">
+  Hopa! Au apărut probleme la încărcarea imaginii.<br/>
+  Dacă imaginea nu apare după un refresh, înseamnă că ea lipsește din
+  din sistemul de fișiere. Pentru a te asigura că aceasta este 
+  situația, mergi la pagina cu tabelele centralizatoare și verifică 
+  dacă ea se găsește la linkul specificat.
+</p>
+
+<div class="extraAdminHeaderLinks"> 
+  | <a href="visual.php">Pagina de încărcare</a>
+  | <a href="">Tabelele centralizatoare</a>
+</div>

Modified: wwwbase/admin/visualTag.php
==============================================================================
--- wwwbase/admin/visualTag.php	Mon Oct 21 21:20:24 2013	(r1029)
+++ wwwbase/admin/visualTag.php	Tue Oct 22 20:34:18 2013	(r1030)
@@ -1,6 +1,5 @@
 <?php
-require_once '../../phplib/util.php' ;
-require_once '../../phplib/models/Visual.php' ;
+require_once('../../phplib/util.php');
 util_assertModerator(PRIV_VISUAL);
 util_assertNotMirror();
 RecentLink::createOrUpdate('Etichetare Imagini Definiții');
@@ -10,6 +9,7 @@
 $action = util_getRequestParameter('action');
 $tagging = util_getRequestParameter('tagging');
 
+// Marks the image as completely revised 
 if($action == 'finishedTagging') {
   $imageId = util_getRequestParameter('imageId');
 
@@ -23,6 +23,7 @@
   FlashMessage::add('Modificările au fost salvate. Mulțumim!');
   util_redirect(util_getWwwRoot() . 'admin/visualTag.php');
 
+// Sets the lexeme associated with the image 
 } else if($action == 'setImgLexemeId') {
   $imgLexemeId = util_getRequestParameter('imgLexemeId');
   $imageId = util_getRequestParameter('imageId');
@@ -37,6 +38,7 @@
   $tagging = true;
   $imgToTag = $line->id;
 
+// Resets the lexeme associated with the image 
 } else if($action == 'resetImgLexemeId') {
   $imageId = util_getRequestParameter('imageId');
 
@@ -55,6 +57,9 @@
 SmartyWrap::addCss('jcrop', 'select2', 'jqgrid', 'jqueryui', 'gallery');
 SmartyWrap::addJs('jquery', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid', 'gallery'); 
 
+// Checks which of the visualTag page needs to be loaded
+// visualTag.ihtml is for the tables with the revised/unrevised images
+// visualTagging.ihtml is for the tagging process
 if($tagging) {
   $imgToTag = isset($imgToTag) ? $imgToTag : util_getRequestParameter('imgToTag');
   $line = Visual::get_by_id($imgToTag);

Modified: wwwbase/ajax/visualGetImages.php
==============================================================================
--- wwwbase/ajax/visualGetImages.php	Mon Oct 21 21:20:24 2013	(r1029)
+++ wwwbase/ajax/visualGetImages.php	Tue Oct 22 20:34:18 2013	(r1030)
@@ -26,15 +26,15 @@
 
   foreach ($tagsLexemes as $tagLexeme) {
   	$row = Lexem::get_by_id($tagLexeme->lexemeId);
-  	$lexemes .= $row->formUtf8General . ', ';
+  	$lexemes .= $row->formUtf8General . ' ';
   }
 
   $lexemes .= '</div>';
 
   $user = User::get_by_id($line->userId);
   $link = '<a title="Click pentru a vedea imaginea" href="' . Visual::getImageWww($line->path) . '">' . basename($line->path) . '</a>';
-  $images[] = array('lexeme' => $lexemes, 'user' => $user->nick, 'width' => $line->width, 
-  									'height' => $line->height, 'userId' => $line->userId, 'imageId' => $line->id,
+  $images[] = array('id' => $line->id, 'lexeme' => $lexemes, 'user' => $user->nick,
+                    'width' => $line->width, 'height' => $line->height, 'userId' => $line->userId,
                     'latestMod' => date('d.m.Y', $line->modDate), 'link' => $link);
 }
 

Added: wwwbase/ajax/visualImagesEdit.php
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ wwwbase/ajax/visualImagesEdit.php	Tue Oct 22 20:34:18 2013	(r1030)
@@ -0,0 +1,17 @@
+<?php
+
+require_once('../../phplib/util.php');
+
+$oper = util_getRequestParameter('oper');
+$id = util_getRequestParameter('id');
+
+switch($oper) {
+  case 'del':
+    $line = Visual::get_by_id($id);
+    if(!empty($line)) {
+      $line->delete();
+    }
+    break;
+}
+
+?>
\ No newline at end of file

Modified: wwwbase/elfinder-connector/visual_connector.php
==============================================================================
--- wwwbase/elfinder-connector/visual_connector.php	Mon Oct 21 21:20:24 2013	(r1029)
+++ wwwbase/elfinder-connector/visual_connector.php	Tue Oct 22 20:34:18 2013	(r1030)
@@ -58,4 +58,3 @@
 // run elFinder
 $connector = new elFinderConnector(new elFinder($opts));
 $connector->run();
-

Modified: wwwbase/js/visualTag.js
==============================================================================
--- wwwbase/js/visualTag.js	Mon Oct 21 21:20:24 2013	(r1029)
+++ wwwbase/js/visualTag.js	Tue Oct 22 20:34:18 2013	(r1030)
@@ -21,16 +21,16 @@
     closeOnEscape: true,
     reloadAfterSubmit: true
   };
-  var imagesTable = function(revised, elementId, pagerId, message) {
-    $('#' + elementId).jqGrid({
+  var imagesTable = function(revised) {
+    $('#' + revised + 'Table').jqGrid({
       url: wwwRoot + 'ajax/visualGetImages.php',
-      postData: {revised: revised},
+      postData: {revised: revised == 'revised' ? 1 : 0},
       datatype: 'json',
       cmTemplate: {sortable: false},
-      colNames: ['Link Imagine', 'Id imagine', 'Lexeme asociat imaginii','Id User', 'User', 'Lățime', 'Înălțime', 'Ultima Modificare'],
+      colNames: ['Id', 'Link Imagine', 'Lexeme asociat imaginii','Id User', 'User', 'Lățime', 'Înălțime', 'Ultima Modificare'],
       colModel: [
+        {name: 'id', index: 'id', hidden: true},
         {name: 'link', index: 'link', width: 100},
-        {name: 'imageId', index: 'imageId', hidden: true},
         {name: 'lexeme', index: 'lexeme', width: 160, align: 'center'},
         {name: 'userId', index: 'userId', hidden: true},
         {name: 'user', index: 'user', width: 100, align: 'center'},
@@ -43,28 +43,40 @@
       width: '700px',
       height: '100%',
       rowList: [20, 50, 100, 200],
-      pager: $('#' + pagerId),
+      pager: $('#' + revised + 'Paging'),
       viewrecords: true,
-      caption: 'Imagini a căror etichetare este ' + message,
+      caption: 'Imagini a căror etichetare este ' + (
+        revised == 'revised' ? 'completă' : 'incompletă'),
+      editurl: wwwRoot + 'ajax/visualImagesEdit.php',
       ondblClickRow: function(rowid) {
-        $('#imgToTag').val($(this).jqGrid('getCell', rowid, 'imageId'));
+        $('#imgToTag').val($(this).jqGrid('getCell', rowid, 'id'));
         $('form').submit();
       }
-    });
+    })
+    .navGrid('#' + revised + 'Paging', {
+      add: false,
+      search: false,
+      edit: false,
+      deltitle: 'șterge',
+      refreshtitle: 'reîncarcă'
+    }, {}, {}, delOptions);
   }
   
   initJcrop();
   resetAllFields();
-  addLinkToHeader();
+  imageLoadError();
+  addLinksToAdminHeader();
 
   function initJcrop() {
-    $('#jcrop').Jcrop({
-      boxHeight: 500,
-      boxWidth: 500,
-      onSelect: setCoords,
-      onChange: setCoords
-    }, function() {
-      jcrop_api = this;
+    $('#jcrop').load(function() {
+      $(this).Jcrop({
+        boxHeight: 500,
+        boxWidth: 500,
+        onSelect: setCoords,
+        onChange: setCoords
+      }, function() {
+        jcrop_api = this;
+      });
     });
   }
 
@@ -77,7 +89,7 @@
     $('#y').val(coords.cy);
   }
 
-  /** Clears the actual selection */
+  /** Clears the actual jcrop selection */
   $('#clrSel').click(function(e) {
     jcrop_api.release();
 
@@ -162,8 +174,8 @@
   })
   .navGrid('#tagsPaging', gridOptions, editOptions, addOptions, delOptions);
 
-  imagesTable(1, 'revisedTable', 'revisedPaging', 'completă');
-  imagesTable(0, 'unrevisedTable', 'unrevisedPaging', 'incompletă');
+  imagesTable('revised');
+  imagesTable('unrevised');
 });
 
 /** Replaces the submit event that triggers on change, set in select2Dev.js */
@@ -180,6 +192,7 @@
   });
 }
 
+/* Checks if the needed tag information has been entered */
 function validateTag() {
   var data = {
     id: '',
@@ -208,6 +221,7 @@
   return data;
 }
 
+/* Checks if the lexeme has been entered */
 function validateLexeme() {
   if(!($('#imgLexemeId').val())) {
     alert('Ai uitat să completezi ce lexem descrie cel mai bine imaginea');
@@ -223,6 +237,7 @@
   }
 }
 
+/* Resets all tag info fields values */
 function resetAllFields() {
   $('#label').val('');
   $('#xTag').val('');
@@ -232,6 +247,16 @@
   $('#lexemId').select2('data', {id: '', text: ''});
 }
 
-function addLinkToHeader() {
-  $('.links').append(' | <a href="visual.php">Pagina de încărcare</a>');
+/* Adds links to admin header so that it is easier to navigate between
+   Visual Dict components */
+function addLinksToAdminHeader() {
+  $('.links').append($('.extraAdminHeaderLinks').html());
+}
+
+/* Prints an error message instead of the image, in case it is 
+   missing from the database */
+function imageLoadError() {
+  $('.visualTagImg').error(function() {
+    $('#visualTagCanvas').html($('.missingImageError').css('display', 'block'));
+  });
 }

Modified: wwwbase/styles/visualDict.css
==============================================================================
--- wwwbase/styles/visualDict.css	Mon Oct 21 21:20:24 2013	(r1029)
+++ wwwbase/styles/visualDict.css	Tue Oct 22 20:34:18 2013	(r1030)
@@ -8,16 +8,12 @@
   border: 1px solid black;
 }
 
-.visualTagImg img {
+#visualTagCanvas img {
   float: left;
   max-width: 500px;
   max-height: 500px;
 }
 
-#helpText {
-  display: none;
-}
-
 #tagOptions {
   float: left;
   width: 320px;
@@ -29,11 +25,6 @@
   width: 430px;
 }
 
-
-#tagsInfo {
-  display: none;
-}
-
 #gallery {
   float: right;
 }
@@ -72,3 +63,14 @@
 .mainLexeme {
   font-weight: bold;
 }
+
+.allLexemes {
+  white-space: pre-line;
+}
+
+.missingImageError,
+.extraAdminHeaderLinks,
+#helpText,
+#tagsInfo {
+  display: none;
+}


More information about the Dev mailing list