Commit 8725c822ec9391762ef35d7efc1197922af99341

Authored by Jalaloedien Abrahams
1 parent f685c72d

KTS-1557

"Implement Tag Cloud system. "
Fixed. Fixed edit error

Reviewed By: Conrad

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6339 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/tagcloud/TagCloudPlugin.php
... ... @@ -320,64 +320,62 @@ class KTEditDocumentTrigger {
320 320 return false;
321 321 }
322 322 }
323   - // proceed to add the tags as per normal
324   - if($res){
325   - $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' .
326   - 'WHERE df.name = \'Tag\'';
327   -
328   - $sTags = DBUtil::getOneResultKey(array($sQuery), 'id');
329   - if (PEAR::isError($sTags)) {
330   - // XXX: log error
331   - return false;
332   - }
333   - $tagString = '';
334   - if ($sTags) {
335   - foreach($aMeta as $aMetaData){
336   - $oProxy = $aMetaData[0];
337   - if($oProxy->iId == $sTags){
338   - $tagString = $aMetaData[1];
339   - break;
340   - }
  323 + // proceed to add the tags as per normaly
  324 + $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' .
  325 + 'WHERE df.name = \'Tag\'';
  326 +
  327 + $sTags = DBUtil::getOneResultKey(array($sQuery), 'id');
  328 + if (PEAR::isError($sTags)) {
  329 + // XXX: log error
  330 + return false;
  331 + }
  332 + $tagString = '';
  333 + if ($sTags) {
  334 + foreach($aMeta as $aMetaData){
  335 + $oProxy = $aMetaData[0];
  336 + if($oProxy->iId == $sTags){
  337 + $tagString = $aMetaData[1];
  338 + break;
341 339 }
342   - if($tagString != ''){
343   - $words_table = KTUtil::getTableName('tag_words');
344   - $tagString = str_replace(' ', ' ', $tagString);
345   - $tags = explode(',',$tagString);
346   -
347   - $aTagIds = array();
348   -
349   - foreach($tags as $sTag)
350   - {
351   - $sTag=strtolower(trim($sTag));
352   -
353   - $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag)));
354   -
355   - if (PEAR::isError($res)) {
356   - return $res;
357   - }
358   -
359   - if (is_null($res))
360   - {
361   - $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag));
362   - $aTagIds[$sTag] = $id;
363   - }
364   - else
365   - {
366   - $aTagIds[$sTag] = $res['id'];
367   - }
368   - }
369   -
370   - $doc_tags = KTUtil::getTableName('document_tags');
371   -
372   - foreach($aTagIds as $sTag=>$tagid)
373   - {
374   - DBUtil::autoInsert($doc_tags, array(
375   - 'document_id'=>$iDocId,
376   - 'tag_id'=>$tagid),
377   - array('noid'=>true));
378   - }
379   - }
380   - }
  340 + }
  341 + if($tagString != ''){
  342 + $words_table = KTUtil::getTableName('tag_words');
  343 + $tagString = str_replace(' ', ' ', $tagString);
  344 + $tags = explode(',',$tagString);
  345 +
  346 + $aTagIds = array();
  347 +
  348 + foreach($tags as $sTag)
  349 + {
  350 + $sTag=strtolower(trim($sTag));
  351 +
  352 + $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag)));
  353 +
  354 + if (PEAR::isError($res)) {
  355 + return $res;
  356 + }
  357 +
  358 + if (is_null($res))
  359 + {
  360 + $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag));
  361 + $aTagIds[$sTag] = $id;
  362 + }
  363 + else
  364 + {
  365 + $aTagIds[$sTag] = $res['id'];
  366 + }
  367 + }
  368 +
  369 + $doc_tags = KTUtil::getTableName('document_tags');
  370 +
  371 + foreach($aTagIds as $sTag=>$tagid)
  372 + {
  373 + DBUtil::autoInsert($doc_tags, array(
  374 + 'document_id'=>$iDocId,
  375 + 'tag_id'=>$tagid),
  376 + array('noid'=>true));
  377 + }
  378 + }
381 379 }
382 380 }
383 381 }
... ...