[dev] [commit] r931 - patches templates/admin wwwbase/admin wwwbase/ajax wwwbase/js

automailer at dexonline.ro automailer at dexonline.ro
Sat Aug 17 19:55:07 EEST 2013


Author: grigoroiualex
Date: Sat Aug 17 19:55:07 2013
New Revision: 931

Log:
Added link to visualTag from admin page and a counter for the unrevised images. Added a select2 input for the lexeme. With this all the fields from visualTag table will be completed. Removed the isMain column.

Added:
   patches/00095.sql
   wwwbase/ajax/visualTag.php
Modified:
   templates/admin/index.ihtml
   templates/admin/visualTag.ihtml
   wwwbase/admin/visualTag.php
   wwwbase/ajax/reportCounter.php
   wwwbase/js/dex.js
   wwwbase/js/visualTag.js

Added: patches/00095.sql
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ patches/00095.sql	Sat Aug 17 19:55:07 2013	(r931)
@@ -0,0 +1,3 @@
+ALTER TABLE VisualTag DROP lexemId;
+ALTER TABLE VisualTag DROP isMain;
+ALTER TABLE VisualTag ADD lexemeId INT(11) AFTER imageId;

Modified: templates/admin/index.ihtml
==============================================================================
--- templates/admin/index.ihtml	Fri Aug 16 05:00:31 2013	(r930)
+++ templates/admin/index.ihtml	Sat Aug 17 19:55:07 2013	(r931)
@@ -36,6 +36,9 @@
   <a href="wotd.php">Word of the Day:</a>
   <span id="span_wotd"><img src="{$imgRoot}/icons/hourglass.png" alt="hourglass"/></span><br/>
 {/if}
+
+<a href="visualTag.php">Imagini (Visual Dict) nerevizuite:</a>
+<span id="span_visualTag"><img src="{$imgRoot}/icons/hourglass.png" alt="hourglass"/></span><br/>
 <br/>
 
 <form action="lexemEdit.php" method="get">

Modified: templates/admin/visualTag.ihtml
==============================================================================
--- templates/admin/visualTag.ihtml	Fri Aug 16 05:00:31 2013	(r930)
+++ templates/admin/visualTag.ihtml	Sat Aug 17 19:55:07 2013	(r931)
@@ -37,23 +37,31 @@
       <label>Id imagine:
         <input type="text" size="4" value="{$imageId}" name="imageId"/>
       </label><br/>
-        <label>Cuvânt:
-        <input id="lexem" type="text" size="15" name="lexem"/>
+
+      <label>Cuvânt:
+        <input id="selectLexeme" type="hidden"/>
       </label><br/>
+
+      <label>Id lexem
+        <input id="lexemeId" type="text" size="10" name="lexemeId"/>
+      </label><br/>
+
+      <label>Lexem
+        <input id="lexeme" type="text" size="15" name="lexeme"/>
+      </label><br/>
+
       <label>Coordonatele centrului etichetei:
         <input id="xTag" type="text" size="4" name="xTag"/>
         <input id="yTag" type="text" size="4" name="yTag"/>
         <button id="setCoordTag" type="button">Setează coordonatele</button>
       </label><br/>
+
       <label>Coordonatele zonei etichetate:
         <input id="xImg" type="text" size="4" name="xImg"/>
         <input id="yImg" type="text" size="4" name="yImg"/>
         <button id="setCoordImg" type="button">Setează coordonatele</button>
       </label><br/>
-      <label>Etichetă principală?
-        <input type="radio" name="isMain" value="1"/>Da
-        <input type="radio" name="isMain" value="0"/>Nu
-      </label><br/>
+
       <button id="saveSel" type="submit" name="action" value="save">Salvează eticheta</button>
     </form>
   

Modified: wwwbase/admin/visualTag.php
==============================================================================
--- wwwbase/admin/visualTag.php	Fri Aug 16 05:00:31 2013	(r930)
+++ wwwbase/admin/visualTag.php	Sat Aug 17 19:55:07 2013	(r931)
@@ -10,7 +10,8 @@
 
 if(util_getRequestParameter('action') == 'save') {
   $imageId = util_getRequestParameter('imageId');
-  $lexem = util_getRequestParameter('lexem');
+  $lexemeId = util_getrequestParameter('lexemeId');
+  $lexeme = util_getRequestParameter('lexeme');
   $xTag = util_getRequestParameter('xTag');
   $yTag = util_getRequestParameter('yTag');
   $xImg = util_getRequestParameter('xImg');
@@ -19,10 +20,8 @@
 
   $line = Model::factory('VisualTag')->create();
   $line->imageId = $imageId;
-  if(!empty($isMain)) {
-    $line->isMain = $isMain;
-  }
-  $line->label = $lexem;
+  $line->lexemeId = $lexemeId;
+  $line->label = $lexeme;
   $line->textXCoord = $xTag;
   $line->textYCoord = $yTag;
   $line->imgXCoord = $xImg;
@@ -65,6 +64,6 @@
 }
 
 SmartyWrap::assign('sectionTitle', 'Etichetare imagini pentru definiții');
-SmartyWrap::addCss('jcrop');
-SmartyWrap::addJs('jquery', 'jcrop', 'visualTag');
+SmartyWrap::addCss('jcrop', 'select2');
+SmartyWrap::addJs('jquery', 'jcrop', 'visualTag', 'select2');
 SmartyWrap::displayAdminPage('admin/visualTag.ihtml'); 

Modified: wwwbase/ajax/reportCounter.php
==============================================================================
--- wwwbase/ajax/reportCounter.php	Fri Aug 16 05:00:31 2013	(r930)
+++ wwwbase/ajax/reportCounter.php	Sat Aug 17 19:55:07 2013	(r931)
@@ -21,6 +21,7 @@
     ->find_one();
   print $r->c;
   break;
+case 'visualTag': echo Model::factory('Visual')->where('revised', 0)->count(); break;
 default: echo 'Necunoscut';
 }
 

Added: wwwbase/ajax/visualTag.php
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ wwwbase/ajax/visualTag.php	Sat Aug 17 19:55:07 2013	(r931)
@@ -0,0 +1,17 @@
+<?php
+require_once('../../phplib/util.php');
+
+$query = util_getRequestParameter('term');
+$f = fopen('/tmp/select.txt', 'a');
+
+$field = StringUtil::hasDiacritics($query) ? 'formNoAccent' : 'formUtf8General';
+
+$lexems = Model::factory('Lexem')->where_like($field, "{$query}%")->order_by_asc('formNoAccent')->limit(10)->find_many();
+
+$resp = array('more' => 'false', 'results' => array());
+foreach($lexems as $lexem) {
+  $resp['results'][] = array('id' => $lexem->id, 'text' => (string)$lexem->formUtf8General);
+}
+
+echo json_encode($resp);
+?>

Modified: wwwbase/js/dex.js
==============================================================================
--- wwwbase/js/dex.js	Fri Aug 16 05:00:31 2013	(r930)
+++ wwwbase/js/dex.js	Sat Aug 17 19:55:07 2013	(r931)
@@ -343,7 +343,7 @@
 
 function startReportCounters() {
   reports = ['unassociatedLexems', 'unassociatedDefinitions', 'definitionsWithTypos', 'temporaryDefinitions', 'temporaryLexems', 'lexemsWithComments',
-             'lexemsWithoutAccents', 'definitionsWithAmbiguousAbbrev', 'wotd'];
+             'lexemsWithoutAccents', 'definitionsWithAmbiguousAbbrev', 'wotd', 'visualTag'];
   for (var i = 0; i < reports.length; i++) {
     $.ajax({
       url: wwwRoot + 'ajax/reportCounter.php',

Modified: wwwbase/js/visualTag.js
==============================================================================
--- wwwbase/js/visualTag.js	Fri Aug 16 05:00:31 2013	(r930)
+++ wwwbase/js/visualTag.js	Sat Aug 17 19:55:07 2013	(r931)
@@ -46,6 +46,8 @@
   $('#clrSel').click(function(e) {
     jcrop_api.release();
 
+    alert($('#lexem').select2('data').text);
+
     resetCoords();
   });
 
@@ -71,25 +73,55 @@
     $('#helpText').toggle();
   });
 
+  $('#selectLexeme').select2({
+    initSelection: function(element, callback) {
+      var data = {id: element.val(), text: element.val()};
+      callback(data);
+    },
+    placeholder: "Scrie lexemul",
+    allowclear: true,
+    minimumInputLength: 1,
+    context: this,
+    ajax: {
+      url: wwwRoot + 'ajax/visualTag.php',
+      dataType: 'json',
+      data: function(term, page) { return {term: term}; }, 
+      results: function(data, page) { return { results: data.results }; },
+    },
+    formatResult: function(data) {
+      return data.text;
+    },
+    formatSelection: function(data) {
+      return data.text;
+    },
+    width: '200px',
+
+  }).on('change', function(e) {
+    var id = $(this).select2('data').id;
+    var text = $(this).select2('data').text;
+
+    $('#lexemeId').val(id);
+    $('#lexeme').val(text);
+  });
 });
 
-  function validateTag() {
-    var lexem = document.getElementById('lexem').value;
-    var xImg = document.getElementById('xImg').value;
-    var yImg = document.getElementById('yImg').value;
-    var xTag = document.getElementById('xTag').value;
-    var yTag = document.getElementById('yTag').value;
-
-    if(!lexem) {
-      alert('Ai uitat să completezi câmpul Cuvânt');
-      return false;
-
-    } else if(!xImg || !yImg) {
-      alert('Ai uitat să completezi câmpurile Coordonatele centrului etichetei');
-      return false;
-
-    } else if(!xTag || !yTag) {
-      alert('Ai uitat să completezi câmpurile Coordonatele zonei etichetate');
-      return false;
-    }
-  };
+function validateTag() {
+  var lexem = document.getElementById('lexem').value;
+  var xImg = document.getElementById('xImg').value;
+  var yImg = document.getElementById('yImg').value;
+  var xTag = document.getElementById('xTag').value;
+  var yTag = document.getElementById('yTag').value;
+
+  if(!lexem) {
+    alert('Ai uitat să completezi câmpul Cuvânt');
+    return false;
+
+  } else if(!xImg || !yImg) {
+    alert('Ai uitat să completezi câmpurile Coordonatele centrului etichetei');
+    return false;
+
+  } else if(!xTag || !yTag) {
+    alert('Ai uitat să completezi câmpurile Coordonatele zonei etichetate');
+    return false;
+  }
+};


More information about the Dev mailing list