[dev] [commit] r921 - phplib/models templates/admin wwwbase/admin wwwbase/elfinder-connector wwwbase/js wwwbase/styles
Catalin Francu
cata at francu.com
Fri Aug 2 13:57:28 EEST 2013
Arată bine. Am făcut câteva mici modificări și le fac acum commit:
- visualTag.ihtml: {if}-ul din smarty era imbricat greșit cu un <div> html
- visualTag.php: am setat doar o variabilă care indică dacă avem sau nu
imagini, iar mesajul propriu-zis stă în template.
- visual_connector.php: parametrul 'disabled' cerea un vector de stringuri.
Acum chiar blochează comanda duplicate, mișto.
- flex.css: am redenumit clasa pentru float. E mai bine ca clasele să
indice scopul acelei bucăți de HTML, nu doar să reformuleze ce face CSS-ul.
Asta pentru că designul se poate schimba, dar scopul acelei regiuni (să fie
un canvas) rămâne.
Cătălin
On Wed, Jul 31, 2013 at 9:22 PM, <automailer at dexonline.ro> wrote:
> Author: grigoroiualex
> Date: Wed Jul 31 21:22:33 2013
> New Revision: 921
>
> Log:
> Made some minor changes and tweaks to Visual and elFinder. Added *Infant*
> VisualTag
>
> Added:
> phplib/models/VisualTag.php
> templates/admin/visualTag.ihtml
> wwwbase/admin/visualTag.php
> wwwbase/js/visualTag.js
> Modified:
> phplib/models/Visual.php
> wwwbase/elfinder-connector/elFinderModToDB.class.php
> wwwbase/elfinder-connector/visual_connector.php
> wwwbase/styles/flex.css
>
> Modified: phplib/models/Visual.php
>
> ==============================================================================
> --- phplib/models/Visual.php Wed Jul 31 14:30:58 2013 (r920)
> +++ phplib/models/Visual.php Wed Jul 31 21:22:33 2013 (r921)
> @@ -11,7 +11,11 @@
>
> return $matches[0];
> }
> -
> -}
>
> + function delete() {
> + VisualTag::deleteByImageId($this->id);
> +
> + parent::delete();
> + }
> +}
> ?>
>
> Added: phplib/models/VisualTag.php
>
> ==============================================================================
> --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ phplib/models/VisualTag.php Wed Jul 31 21:22:33 2013 (r921)
> @@ -0,0 +1,13 @@
> +<?php
> +
> +class VisualTag extends BaseObject implements DatedObject {
> + public static $_table = 'VisualTag';
> +
> + public static function deleteByImageId($imageId) {
> + $tags = VisualTag::get_all_by_imageId($imageId);
> +
> + foreach($tags as $tag) {
> + $tag->delete();
> + }
> + }
> +}
>
> Added: templates/admin/visualTag.ihtml
>
> ==============================================================================
> --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ templates/admin/visualTag.ihtml Wed Jul 31 21:22:33 2013
> (r921)
> @@ -0,0 +1,55 @@
> +<br/>
> +<div class="floatMe">
> + {if count($msg) == 0}
> + <img src="{$imagePath}" id="jcrop"/>
> + <label>Coordonatele centrului selecției:
> + <input id="x" type="text" size="4" name="x"/>
> + <input id="y" type="text" size="4" name="y"/>
> + </label>
> + <button type="button" id="clrSel">Șterge selecția</button>
> + <form action="visualTag.php" method="post">
> + <input type="hidden" value="{$imageId}" name="imageId"/>
> + <button type="submit" name="action" value="finishedTagging">
> + Etichetarea este completă
> + </button>
> + </form>
> +</div>
> +
> +<div>
> + <form action="visualTag.php" method="post">
> + <label>Id imagine:
> + <input type="text" size="4" value="{$imageId}" name="imageId"/>
> + </label><br/>
> + <label>Cuvânt:
> + <input type="text" size="15" name="lexem"/>
> + </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 centrului zonei indicate:
> + <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>Tag 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>
> +
> + <h3>Etichete salvate</h3>
> + <form action="visualTag.php" method="post">
> + {foreach from=$savedTags item=tag}
> + <label>{$tag->label}
> + <input type="hidden" name="savedTagId" value="{$tag->id}"/>
> + <button type="submit" name="action" value="delete">Șterge
> eticheta</button>
> + </label><br/>
> + {/foreach}
> + </form>
> + {else}
> + <p>{$msg}</p>
> + {/if}
> +</div>
>
> Added: wwwbase/admin/visualTag.php
>
> ==============================================================================
> --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ wwwbase/admin/visualTag.php Wed Jul 31 21:22:33 2013 (r921)
> @@ -0,0 +1,66 @@
> +<?php
> +require_once '../../phplib/util.php' ;
> +require_once '../../phplib/models/Visual.php' ;
> +//util_assertModerator(PRIV_VISUAL);
> +util_assertNotMirror();
> +RecentLink::createOrUpdate('Tăguire Imagini Definiții');
> +
> +$rootPath = util_getImgRoot() . '/';
> +$savedTags = '';
> +
> +if(util_getRequestParameter('action') == 'save') {
> + $imageId = util_getRequestParameter('imageId');
> + $lexem = util_getRequestParameter('lexem');
> + $xTag = util_getRequestParameter('xTag');
> + $yTag = util_getRequestParameter('yTag');
> + $xImg = util_getRequestParameter('xImg');
> + $yImg = util_getRequestParameter('yImg');
> + $isMain = util_getRequestParameter('isMain');
> +
> + $line = Model::factory('VisualTag')->create();
> + $line->imageId = $imageId;
> + $line->isMain = $isMain;
> + $line->label = $lexem;
> + $line->textXCoord = $xTag;
> + $line->textYCoord = $yTag;
> + $line->imgXCoord = $xImg;
> + $line->imgYCoord = $yImg;
> + $line->save();
> +
> +} else if(util_getRequestParameter('action') == 'delete') {
> + $tagId = util_getRequestParameter('savedTagId');
> +
> + $line = VisualTag::get_by_id($tagId);
> + if(!empty($line)) {
> + $line->delete();
> + }
> +
> +} else if(util_getRequestParameter('action') == 'finishedTagging') {
> + $imageId = util_getRequestParameter('imageId');
> +
> + $line = Visual::get_by_id($imageId);
> + $line->revised = 1;
> + $line->save();
> +}
> +
> +//$line = Model::factory('Visual')->where('revised', 0)->find_one();
> +$line = Visual::get_by_revised(0);
> +if(!empty($line)) {
> + $imagePath = $rootPath . $line->path;
> + $imageId = $line->id;
> +
> + $tags = VisualTag::get_all_by_imageId($imageId);
> +
> + SmartyWrap::assign('savedTags', $tags);
> + SmartyWrap::assign('imagePath', $imagePath);
> + SmartyWrap::assign('imageId', $imageId);
> +
> +} else {
> + $msg = 'Toate imaginile au fost revizuite. Mulțumim!';
> + SmartyWrap::assign('msg', $msg);
> +}
> +
> +SmartyWrap::assign('sectionTitle', 'Tăguire imagini pentru definiții');
> +SmartyWrap::addCss('jcrop');
> +SmartyWrap::addJs('jquery', 'jcrop', 'visualTag');
> +SmartyWrap::displayAdminPage('admin/visualTag.ihtml');
>
> Modified: wwwbase/elfinder-connector/elFinderModToDB.class.php
>
> ==============================================================================
> --- wwwbase/elfinder-connector/elFinderModToDB.class.php Wed Jul 31
> 14:30:58 2013 (r920)
> +++ wwwbase/elfinder-connector/elFinderModToDB.class.php Wed Jul 31
> 21:22:33 2013 (r921)
> @@ -13,7 +13,6 @@
> public function action($cmd, $result, $args, $elfinder) {
>
> switch($cmd){
> - case 'duplicate':
> case 'upload':
> if(!empty($result['added'])) {
> foreach($result['added'] as $file) {
> @@ -96,14 +95,6 @@
> }
> }
> break;
> -
> - /*case 'duplicate':
> - if(!empty($result['added'])) {
> - $txt = fopen('/tmp/duplicate.txt', 'w');
> - fwrite($txt, $elfinder->realpath($result['added'][0]['hash']));
> - fclose($txt);
> - }
> - break;*/
> }
> }
> }
>
> Modified: wwwbase/elfinder-connector/visual_connector.php
>
> ==============================================================================
> --- wwwbase/elfinder-connector/visual_connector.php Wed Jul 31
> 14:30:58 2013 (r920)
> +++ wwwbase/elfinder-connector/visual_connector.php Wed Jul 31
> 21:22:33 2013 (r921)
> @@ -42,7 +42,7 @@
> 'debug' => true,
> 'bind' => array(
> 'mkdir mkfile rename duplicate upload rm paste' => array($myLogger,
> 'log'),
> - 'upload rm rename paste duplicate' => array($myModder, 'action')
> + 'upload rm rename paste' => array($myModder, 'action')
> ),
> 'roots' => array(
> array(
> @@ -52,7 +52,7 @@
> 'accessControl' => 'access', // disable and hide dot starting files
> (OPTIONAL)
> 'alias' => 'Imagini cuvântul zilei', // display this
> instead of root directory name
> 'uploadAllow' => array('image'), // mimetypes allowed to upload
> - 'disabled' => array('resize, mkfile'), // list of not allowed
> commands
> + 'disabled' => array('resize, mkfile, duplicate'), // list of
> not allowed commands
> 'imgLib' => 'gd', // image manipulation library (imagick,
> mogrify, gd)
> 'tmbPath' => '.tmb', // directory name for image thumbnails.
> Set to "" to avoid thumbnails generation
> )
>
> Added: wwwbase/js/visualTag.js
>
> ==============================================================================
> --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ wwwbase/js/visualTag.js Wed Jul 31 21:22:33 2013 (r921)
> @@ -0,0 +1,78 @@
> +jQuery(document).ready(function() {
> +
> + var jcrop_api;
> + var coords = new Object();
> +
> + initJcrop();
> + resetCoords();
> +
> + function initJcrop() {
> + $('#jcrop').Jcrop({
> + boxHeight: 500,
> + boxWidth: 500,
> + onSelect: showCoords,
> + onChange: showCoords,
> + onRelease: resetCoords
> + }, function() {
> + jcrop_api = this;
> + });
> + };
> +
> + //Shows centre of the selection coordinates
> + function showCoords(c) {
> + setCoords(c);
> +
> + $('#x').val(coords.cx);
> + $('#y').val(coords.cy);
> + };
> +
> + function setCoords(c) {
> + var q = new Array();
> + q = calculateCentre(c);
> +
> + coords.x = c.x;
> + coords.y = c.y;
> + coords.w = c.w;
> + coords.h = c.h;
> + coords.cx = q[0];
> + coords.cy = q[1];
> + };
> +
> + function calculateCentre(c) {
> + var centre = new Array();
> +
> + centre[0] = Math.round((2 * c.x + c.w) / 2);
> + centre[1] = Math.round((2 * c.y + c.h) / 2);
> +
> + return centre;
> + };
> +
> + //Clears the actual selection
> + $('#clrSel').click(function(e) {
> + jcrop_api.release();
> +
> + resetCoords();
> + });
> +
> + function resetCoords() {
> + coords.x = 0;
> + coords.y = 0;
> + coords.w = 0;
> + coords.h = 0;
> + coords.cx = 0;
> + coords.cy = 0;
> +
> + $('#x').val('');
> + $('#y').val('');
> + };
> +
> + $('#setCoordTag').click(function() {
> + $('#xTag').val(coords.cx);
> + $('#yTag').val(coords.cy);
> + });
> +
> + $('#setCoordImg').click(function() {
> + $('#xImg').val(coords.cx);
> + $('#yImg').val(coords.cy);
> + });
> +});
>
> Modified: wwwbase/styles/flex.css
>
> ==============================================================================
> --- wwwbase/styles/flex.css Wed Jul 31 14:30:58 2013 (r920)
> +++ wwwbase/styles/flex.css Wed Jul 31 21:22:33 2013 (r921)
> @@ -389,3 +389,8 @@
> .ui-widget-header .ui-icon {
> background-image:
> url("lightness-1.10.3/images/ui-icons_222222_256x240.png");
> }
> +
> +/* VisualTag */
> +.floatMe {
> + float: left;
> +}
> _______________________________________________
> Dev mailing list
> Dev at dexonline.ro
> http://list.dexonline.ro/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.dexonline.ro/pipermail/dev/attachments/20130802/30ff43e9/attachment-0001.html>
More information about the Dev
mailing list