Commit b66d693f30fe0849f03ec2898275e3236b51d123
1 parent
3ac8f2d4
KTS-1834
"Replace ktdms.com with knowledgetree.com" Done. Some files where converted to utf8 in the process which should be ok. Reviewed By: Conrad git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6420 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
516 additions
and
516 deletions
plugins/generalmetadata/GeneralMetadataPlugin.php
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | * You can contact the copyright owner regarding licensing via the contact | 23 | * You can contact the copyright owner regarding licensing via the contact |
| 24 | * details that can be found on the KnowledgeTree web site: | 24 | * details that can be found on the KnowledgeTree web site: |
| 25 | * | 25 | * |
| 26 | - * http://www.ktdms.com/ | 26 | + * http://www.knowledgetree.com/ |
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | 29 | require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); |
plugins/tagcloud/TagCloudPlugin.php
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * $Id: TagCloudPlugin.php,v 1.1 2006/02/28 16:53:49 nbm Exp $ | ||
| 5 | - * | ||
| 6 | - * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | ||
| 7 | - * | ||
| 8 | - * This program is free software; you can redistribute it and/or modify | ||
| 9 | - * it under the terms of the GNU General Public License as published by | ||
| 10 | - * the Free Software Foundation; using version 2 of the License. | ||
| 11 | - * | ||
| 12 | - * This program is distributed in the hope that it will be useful, | ||
| 13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | - * GNU General Public License for more details. | ||
| 16 | - * | ||
| 17 | - * You should have received a copy of the GNU General Public License | ||
| 18 | - * along with this program; if not, write to the Free Software | ||
| 19 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | - * | ||
| 21 | - * ------------------------------------------------------------------------- | ||
| 22 | - * | ||
| 23 | - * You can contact the copyright owner regarding licensing via the contact | ||
| 24 | - * details that can be found on the KnowledgeTree web site: | ||
| 25 | - * | ||
| 26 | - * http://www.ktdms.com/ | ||
| 27 | - */ | ||
| 28 | - | ||
| 29 | -require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | ||
| 30 | -require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | ||
| 31 | -require_once('TagCloudRedirectPage.php'); | ||
| 32 | -require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * Tag Cloud Plugin class | ||
| 36 | - * | ||
| 37 | - */ | ||
| 38 | - class TagCloudPlugin extends KTPlugin{ | ||
| 39 | - | ||
| 40 | - var $sNamespace = 'ktcore.tagcloud.plugin'; | ||
| 41 | - | ||
| 42 | - /** | ||
| 43 | - * Constructor method for plugin | ||
| 44 | - * | ||
| 45 | - * @param string $sFilename | ||
| 46 | - * @return TagCloudPlugin | ||
| 47 | - */ | ||
| 48 | - function TagCloudPlugin($sFilename = null) { | ||
| 49 | - $res = parent::KTPlugin($sFilename); | ||
| 50 | - $this->sFriendlyName = _kt('Tag Cloud Plugin'); | ||
| 51 | - return $res; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * Setup function for plugin | ||
| 56 | - * | ||
| 57 | - */ | ||
| 58 | - function setup() { | ||
| 59 | - // Register plugin components | ||
| 60 | - $this->registerCriterion('TagCloudCriterion', 'ktcore.criteria.tagcloud', KT_LIB_DIR . '/browse/Criteria.inc'); | ||
| 61 | - $this->registerDashlet('TagCloudDashlet', 'ktcore.tagcloud.feed.dashlet', 'TagCloudDashlet.php'); | ||
| 62 | - $this->registerPage('TagCloudRedirection', 'TagCloudRedirectPage', __FILE__); | ||
| 63 | - $this->registerTrigger('add', 'postValidate', 'KTAddDocumentTrigger', | ||
| 64 | - 'ktcore.triggers.tagcloud.add'); | ||
| 65 | - $this->registerTrigger('edit', 'postValidate', 'KTEditDocumentTrigger', | ||
| 66 | - 'ktcore.triggers.tagcloud.edit'); | ||
| 67 | - | ||
| 68 | - // Check if the tagcloud fielset entry exists, if not, create it | ||
| 69 | - if(!TagCloudPlugin::tagFieldsetExists()){ | ||
| 70 | - $oFieldset = TagCloudPlugin::createFieldset(); | ||
| 71 | - if (PEAR::isError($oFieldset)) { | ||
| 72 | - return false; | ||
| 73 | - } | ||
| 74 | - if($oFieldset){ | ||
| 75 | - // make the fieldset id viewable | ||
| 76 | - $iFieldsetId = $oFieldset->iId; | ||
| 77 | - } | ||
| 78 | - }else{ // if the entry exists, make the fieldset id viewable anyway | ||
| 79 | - $iFieldsetId = TagCloudPlugin::tagFieldsetExists(); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - // Check if the tagcloud document field entry exists, if not, create it | ||
| 83 | - if(!TagCloudPlugin::tagFieldExists()){ | ||
| 84 | - $oField = TagCloudPlugin::createDocumentField($iFieldsetId); | ||
| 85 | - if (PEAR::isError($oField)) { | ||
| 86 | - return false; | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - $oTemplating =& KTTemplating::getSingleton(); | ||
| 91 | - $oTemplating->addLocation('Tag Cloud Plugin', '/plugins/tagcloud/templates'); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - /** | ||
| 95 | - * function to add fieldset entry to fieldsets table | ||
| 96 | - * | ||
| 97 | - * @return unknown | ||
| 98 | - */ | ||
| 99 | - function createFieldset(){ | ||
| 100 | - // create the fieldsets entry | ||
| 101 | - $oFieldset = KTFieldset::createFromArray(array( | ||
| 102 | - 'name' => 'Tag Cloud', | ||
| 103 | - 'description' => 'Tag Cloud', | ||
| 104 | - 'namespace' => 'tagcloud', | ||
| 105 | - 'mandatory' => false, | ||
| 106 | - 'isConditional' => false, | ||
| 107 | - 'isGeneric' => true, | ||
| 108 | - 'isComplete' => false, | ||
| 109 | - 'isComplex' => false, | ||
| 110 | - 'isSystem' => false, | ||
| 111 | - )); | ||
| 112 | - | ||
| 113 | - return $oFieldset; | ||
| 114 | - } | ||
| 115 | - | ||
| 116 | - /** | ||
| 117 | - * function to add the tagcloud entry to the document_fields table | ||
| 118 | - * | ||
| 119 | - * @param int $parentId | ||
| 120 | - * @return int $id | ||
| 121 | - */ | ||
| 122 | - function createDocumentField($parentId){ | ||
| 123 | - // create the document_field entry | ||
| 124 | - $id = DocumentField::createFromArray(array( | ||
| 125 | - 'Name' => 'Tag', | ||
| 126 | - 'Description' => 'Tag Words', | ||
| 127 | - 'DataType' => 'STRING', | ||
| 128 | - 'IsGeneric' => false, | ||
| 129 | - 'HasLookup' => false, | ||
| 130 | - 'HasLookupTree' => false, | ||
| 131 | - 'ParentFieldset' => $parentId, | ||
| 132 | - 'IsMandatory' => false, | ||
| 133 | - )); | ||
| 134 | - | ||
| 135 | - return $id; | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - /** | ||
| 139 | - * function to check if the Tag field exists in the document_fields table | ||
| 140 | - * | ||
| 141 | - * @return boolean | ||
| 142 | - */ | ||
| 143 | - function tagFieldExists(){ | ||
| 144 | - $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' . | ||
| 145 | - 'WHERE df.name = \'Tag\''; | ||
| 146 | - $sTag = DBUtil::getOneResultKey(array($sQuery), 'id'); | ||
| 147 | - | ||
| 148 | - if (PEAR::isError($sTag)) { | ||
| 149 | - // XXX: log error | ||
| 150 | - return false; | ||
| 151 | - | ||
| 152 | - } | ||
| 153 | - if(!is_null($sTag)){ | ||
| 154 | - return $sTag; | ||
| 155 | - }else{ | ||
| 156 | - return false; | ||
| 157 | - } | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - /** | ||
| 161 | - * function to check if the fieldset exists in the database | ||
| 162 | - * | ||
| 163 | - * @return boolean | ||
| 164 | - */ | ||
| 165 | - function tagFieldsetExists(){ | ||
| 166 | - $sQuery = 'SELECT fs.id AS id FROM fieldsets AS fs '. | ||
| 167 | - 'WHERE namespace = \'tagcloud\''; | ||
| 168 | - $iFieldset = DBUtil::getOneResultKey(array($sQuery), 'id'); | ||
| 169 | - | ||
| 170 | - if (PEAR::isError($iFieldset)) { | ||
| 171 | - // XXX: log error | ||
| 172 | - return false; | ||
| 173 | - | ||
| 174 | - } | ||
| 175 | - if(!is_null($iFieldset)){ | ||
| 176 | - return $iFieldset; | ||
| 177 | - }else{ | ||
| 178 | - return false; | ||
| 179 | - } | ||
| 180 | - } | ||
| 181 | - } | ||
| 182 | -$oPluginRegistry =& KTPluginRegistry::getSingleton(); | ||
| 183 | -$oPluginRegistry->registerPlugin('TagCloudPlugin', 'ktcore.tagcloud.plugin', __FILE__); | ||
| 184 | - | ||
| 185 | -/** | ||
| 186 | - * Trigger for document add (postValidate) | ||
| 187 | - * | ||
| 188 | - */ | ||
| 189 | -class KTAddDocumentTrigger { | ||
| 190 | - var $aInfo = null; | ||
| 191 | - /** | ||
| 192 | - * function to set the info for the trigger | ||
| 193 | - * | ||
| 194 | - * @param array $aInfo | ||
| 195 | - */ | ||
| 196 | - function setInfo(&$aInfo) { | ||
| 197 | - $this->aInfo =& $aInfo; | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - /** | ||
| 201 | - * postValidate method for trigger | ||
| 202 | - * | ||
| 203 | - * @return unknown | ||
| 204 | - */ | ||
| 205 | - function postValidate() { | ||
| 206 | - global $default; | ||
| 207 | - $oDocument =& $this->aInfo['document']; | ||
| 208 | - $aMeta = & $this->aInfo['aOptions']; | ||
| 209 | - | ||
| 210 | - $iDocId = $oDocument->getID(); | ||
| 211 | - | ||
| 212 | - // get tag id from document_fields table where name = Tag | ||
| 213 | - $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' . | ||
| 214 | - 'WHERE df.name = \'Tag\''; | ||
| 215 | - | ||
| 216 | - $sTags = DBUtil::getOneResultKey(array($sQuery), 'id'); | ||
| 217 | - if (PEAR::isError($sTags)) { | ||
| 218 | - // XXX: log error | ||
| 219 | - return false; | ||
| 220 | - } | ||
| 221 | - $tagString = ''; | ||
| 222 | - // add tags | ||
| 223 | - if ($sTags) { | ||
| 224 | - foreach($aMeta[metadata] as $aMetaData){ | ||
| 225 | - $oProxy = $aMetaData[0]; | ||
| 226 | - if($oProxy->iId == $sTags){ | ||
| 227 | - $tagString = $aMetaData[1]; | ||
| 228 | - } | ||
| 229 | - } | ||
| 230 | - if($tagString != ''){ | ||
| 231 | - $words_table = KTUtil::getTableName('tag_words'); | ||
| 232 | - $tagString = str_replace(' ', '', $tagString); | ||
| 233 | - $tags = explode(',',$tagString); | ||
| 234 | - | ||
| 235 | - $aTagIds = array(); | ||
| 236 | - | ||
| 237 | - foreach($tags as $sTag) | ||
| 238 | - { | ||
| 239 | - $sTag=strtolower(trim($sTag)); | ||
| 240 | - | ||
| 241 | - $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag))); | ||
| 242 | - | ||
| 243 | - if (PEAR::isError($res)) { | ||
| 244 | - return $res; | ||
| 245 | - } | ||
| 246 | - | ||
| 247 | - if (is_null($res)) | ||
| 248 | - { | ||
| 249 | - $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag)); | ||
| 250 | - $aTagIds[$sTag] = $id; | ||
| 251 | - } | ||
| 252 | - else | ||
| 253 | - { | ||
| 254 | - $aTagIds[$sTag] = $res['id']; | ||
| 255 | - } | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | - $doc_tags = KTUtil::getTableName('document_tags'); | ||
| 259 | - | ||
| 260 | - foreach($aTagIds as $sTag=>$tagid) | ||
| 261 | - { | ||
| 262 | - DBUtil::autoInsert($doc_tags, array( | ||
| 263 | - | ||
| 264 | - 'document_id'=>$iDocId, | ||
| 265 | - 'tag_id'=>$tagid), | ||
| 266 | - array('noid'=>true)); | ||
| 267 | - } | ||
| 268 | - } | ||
| 269 | - } | ||
| 270 | - } | ||
| 271 | -} | ||
| 272 | - | ||
| 273 | -/** | ||
| 274 | - * Trigger for document edit (postValidate) | ||
| 275 | - * | ||
| 276 | - */ | ||
| 277 | -class KTEditDocumentTrigger { | ||
| 278 | - var $aInfo = null; | ||
| 279 | - /** | ||
| 280 | - * function to set the info for the trigger | ||
| 281 | - * | ||
| 282 | - * @param array $aInfo | ||
| 283 | - */ | ||
| 284 | - function setInfo(&$aInfo) { | ||
| 285 | - $this->aInfo =& $aInfo; | ||
| 286 | - } | ||
| 287 | - | ||
| 288 | - /** | ||
| 289 | - * postValidate method for trigger | ||
| 290 | - * | ||
| 291 | - * @return unknown | ||
| 292 | - */ | ||
| 293 | - function postValidate() { | ||
| 294 | - global $default; | ||
| 295 | - $oDocument =& $this->aInfo['document']; | ||
| 296 | - $aMeta = & $this->aInfo['aOptions']; | ||
| 297 | - // get document id | ||
| 298 | - $iDocId = $oDocument->getID(); | ||
| 299 | - | ||
| 300 | - // get all tags that are linked to the document | ||
| 301 | - $sQuery = 'SELECT tw.id FROM tag_words AS tw, document_tags AS dt, documents AS d ' . | ||
| 302 | - 'WHERE dt.tag_id = tw.id ' . | ||
| 303 | - 'AND dt.document_id = d.id ' . | ||
| 304 | - 'AND d.id = ?'; | ||
| 305 | - $aParams = array($iDocId); | ||
| 306 | - $aTagId = DBUtil::getResultArray(array($sQuery, $aParams)); | ||
| 307 | - if (PEAR::isError($aTagId)) { | ||
| 308 | - // XXX: log error | ||
| 309 | - return false; | ||
| 310 | - } | ||
| 311 | - // if there are any related tags proceed | ||
| 312 | - if ($aTagId) { | ||
| 313 | - // delete all entries from document_tags table for the document | ||
| 314 | - $sQuery = 'DELETE FROM document_tags ' . | ||
| 315 | - 'WHERE document_id = ?'; | ||
| 316 | - $aParams = array($iDocId); | ||
| 317 | - $removed = DBUtil::runQuery(array($sQuery, $aParams)); | ||
| 318 | - if (PEAR::isError($removed)) { | ||
| 319 | - // XXX: log error | ||
| 320 | - return false; | ||
| 321 | - } | ||
| 322 | - } | ||
| 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; | ||
| 339 | - } | ||
| 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 | - } | ||
| 379 | - } | ||
| 380 | - } | ||
| 381 | -} | ||
| 382 | -?> | 1 | +<?php |
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id: TagCloudPlugin.php,v 1.1 2006/02/28 16:53:49 nbm Exp $ | ||
| 5 | + * | ||
| 6 | + * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | ||
| 7 | + * | ||
| 8 | + * This program is free software; you can redistribute it and/or modify | ||
| 9 | + * it under the terms of the GNU General Public License as published by | ||
| 10 | + * the Free Software Foundation; using version 2 of the License. | ||
| 11 | + * | ||
| 12 | + * This program is distributed in the hope that it will be useful, | ||
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | + * GNU General Public License for more details. | ||
| 16 | + * | ||
| 17 | + * You should have received a copy of the GNU General Public License | ||
| 18 | + * along with this program; if not, write to the Free Software | ||
| 19 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | + * | ||
| 21 | + * ------------------------------------------------------------------------- | ||
| 22 | + * | ||
| 23 | + * You can contact the copyright owner regarding licensing via the contact | ||
| 24 | + * details that can be found on the KnowledgeTree web site: | ||
| 25 | + * | ||
| 26 | + * http://www.knowledgetree.com/ | ||
| 27 | + */ | ||
| 28 | + | ||
| 29 | +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | ||
| 30 | +require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | ||
| 31 | +require_once('TagCloudRedirectPage.php'); | ||
| 32 | +require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Tag Cloud Plugin class | ||
| 36 | + * | ||
| 37 | + */ | ||
| 38 | + class TagCloudPlugin extends KTPlugin{ | ||
| 39 | + | ||
| 40 | + var $sNamespace = 'ktcore.tagcloud.plugin'; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Constructor method for plugin | ||
| 44 | + * | ||
| 45 | + * @param string $sFilename | ||
| 46 | + * @return TagCloudPlugin | ||
| 47 | + */ | ||
| 48 | + function TagCloudPlugin($sFilename = null) { | ||
| 49 | + $res = parent::KTPlugin($sFilename); | ||
| 50 | + $this->sFriendlyName = _kt('Tag Cloud Plugin'); | ||
| 51 | + return $res; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Setup function for plugin | ||
| 56 | + * | ||
| 57 | + */ | ||
| 58 | + function setup() { | ||
| 59 | + // Register plugin components | ||
| 60 | + $this->registerCriterion('TagCloudCriterion', 'ktcore.criteria.tagcloud', KT_LIB_DIR . '/browse/Criteria.inc'); | ||
| 61 | + $this->registerDashlet('TagCloudDashlet', 'ktcore.tagcloud.feed.dashlet', 'TagCloudDashlet.php'); | ||
| 62 | + $this->registerPage('TagCloudRedirection', 'TagCloudRedirectPage', __FILE__); | ||
| 63 | + $this->registerTrigger('add', 'postValidate', 'KTAddDocumentTrigger', | ||
| 64 | + 'ktcore.triggers.tagcloud.add'); | ||
| 65 | + $this->registerTrigger('edit', 'postValidate', 'KTEditDocumentTrigger', | ||
| 66 | + 'ktcore.triggers.tagcloud.edit'); | ||
| 67 | + | ||
| 68 | + // Check if the tagcloud fielset entry exists, if not, create it | ||
| 69 | + if(!TagCloudPlugin::tagFieldsetExists()){ | ||
| 70 | + $oFieldset = TagCloudPlugin::createFieldset(); | ||
| 71 | + if (PEAR::isError($oFieldset)) { | ||
| 72 | + return false; | ||
| 73 | + } | ||
| 74 | + if($oFieldset){ | ||
| 75 | + // make the fieldset id viewable | ||
| 76 | + $iFieldsetId = $oFieldset->iId; | ||
| 77 | + } | ||
| 78 | + }else{ // if the entry exists, make the fieldset id viewable anyway | ||
| 79 | + $iFieldsetId = TagCloudPlugin::tagFieldsetExists(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + // Check if the tagcloud document field entry exists, if not, create it | ||
| 83 | + if(!TagCloudPlugin::tagFieldExists()){ | ||
| 84 | + $oField = TagCloudPlugin::createDocumentField($iFieldsetId); | ||
| 85 | + if (PEAR::isError($oField)) { | ||
| 86 | + return false; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 91 | + $oTemplating->addLocation('Tag Cloud Plugin', '/plugins/tagcloud/templates'); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * function to add fieldset entry to fieldsets table | ||
| 96 | + * | ||
| 97 | + * @return unknown | ||
| 98 | + */ | ||
| 99 | + function createFieldset(){ | ||
| 100 | + // create the fieldsets entry | ||
| 101 | + $oFieldset = KTFieldset::createFromArray(array( | ||
| 102 | + 'name' => 'Tag Cloud', | ||
| 103 | + 'description' => 'Tag Cloud', | ||
| 104 | + 'namespace' => 'tagcloud', | ||
| 105 | + 'mandatory' => false, | ||
| 106 | + 'isConditional' => false, | ||
| 107 | + 'isGeneric' => true, | ||
| 108 | + 'isComplete' => false, | ||
| 109 | + 'isComplex' => false, | ||
| 110 | + 'isSystem' => false, | ||
| 111 | + )); | ||
| 112 | + | ||
| 113 | + return $oFieldset; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * function to add the tagcloud entry to the document_fields table | ||
| 118 | + * | ||
| 119 | + * @param int $parentId | ||
| 120 | + * @return int $id | ||
| 121 | + */ | ||
| 122 | + function createDocumentField($parentId){ | ||
| 123 | + // create the document_field entry | ||
| 124 | + $id = DocumentField::createFromArray(array( | ||
| 125 | + 'Name' => 'Tag', | ||
| 126 | + 'Description' => 'Tag Words', | ||
| 127 | + 'DataType' => 'STRING', | ||
| 128 | + 'IsGeneric' => false, | ||
| 129 | + 'HasLookup' => false, | ||
| 130 | + 'HasLookupTree' => false, | ||
| 131 | + 'ParentFieldset' => $parentId, | ||
| 132 | + 'IsMandatory' => false, | ||
| 133 | + )); | ||
| 134 | + | ||
| 135 | + return $id; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * function to check if the Tag field exists in the document_fields table | ||
| 140 | + * | ||
| 141 | + * @return boolean | ||
| 142 | + */ | ||
| 143 | + function tagFieldExists(){ | ||
| 144 | + $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' . | ||
| 145 | + 'WHERE df.name = \'Tag\''; | ||
| 146 | + $sTag = DBUtil::getOneResultKey(array($sQuery), 'id'); | ||
| 147 | + | ||
| 148 | + if (PEAR::isError($sTag)) { | ||
| 149 | + // XXX: log error | ||
| 150 | + return false; | ||
| 151 | + | ||
| 152 | + } | ||
| 153 | + if(!is_null($sTag)){ | ||
| 154 | + return $sTag; | ||
| 155 | + }else{ | ||
| 156 | + return false; | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * function to check if the fieldset exists in the database | ||
| 162 | + * | ||
| 163 | + * @return boolean | ||
| 164 | + */ | ||
| 165 | + function tagFieldsetExists(){ | ||
| 166 | + $sQuery = 'SELECT fs.id AS id FROM fieldsets AS fs '. | ||
| 167 | + 'WHERE namespace = \'tagcloud\''; | ||
| 168 | + $iFieldset = DBUtil::getOneResultKey(array($sQuery), 'id'); | ||
| 169 | + | ||
| 170 | + if (PEAR::isError($iFieldset)) { | ||
| 171 | + // XXX: log error | ||
| 172 | + return false; | ||
| 173 | + | ||
| 174 | + } | ||
| 175 | + if(!is_null($iFieldset)){ | ||
| 176 | + return $iFieldset; | ||
| 177 | + }else{ | ||
| 178 | + return false; | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | +$oPluginRegistry =& KTPluginRegistry::getSingleton(); | ||
| 183 | +$oPluginRegistry->registerPlugin('TagCloudPlugin', 'ktcore.tagcloud.plugin', __FILE__); | ||
| 184 | + | ||
| 185 | +/** | ||
| 186 | + * Trigger for document add (postValidate) | ||
| 187 | + * | ||
| 188 | + */ | ||
| 189 | +class KTAddDocumentTrigger { | ||
| 190 | + var $aInfo = null; | ||
| 191 | + /** | ||
| 192 | + * function to set the info for the trigger | ||
| 193 | + * | ||
| 194 | + * @param array $aInfo | ||
| 195 | + */ | ||
| 196 | + function setInfo(&$aInfo) { | ||
| 197 | + $this->aInfo =& $aInfo; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + /** | ||
| 201 | + * postValidate method for trigger | ||
| 202 | + * | ||
| 203 | + * @return unknown | ||
| 204 | + */ | ||
| 205 | + function postValidate() { | ||
| 206 | + global $default; | ||
| 207 | + $oDocument =& $this->aInfo['document']; | ||
| 208 | + $aMeta = & $this->aInfo['aOptions']; | ||
| 209 | + | ||
| 210 | + $iDocId = $oDocument->getID(); | ||
| 211 | + | ||
| 212 | + // get tag id from document_fields table where name = Tag | ||
| 213 | + $sQuery = 'SELECT df.id AS id FROM document_fields AS df ' . | ||
| 214 | + 'WHERE df.name = \'Tag\''; | ||
| 215 | + | ||
| 216 | + $sTags = DBUtil::getOneResultKey(array($sQuery), 'id'); | ||
| 217 | + if (PEAR::isError($sTags)) { | ||
| 218 | + // XXX: log error | ||
| 219 | + return false; | ||
| 220 | + } | ||
| 221 | + $tagString = ''; | ||
| 222 | + // add tags | ||
| 223 | + if ($sTags) { | ||
| 224 | + foreach($aMeta[metadata] as $aMetaData){ | ||
| 225 | + $oProxy = $aMetaData[0]; | ||
| 226 | + if($oProxy->iId == $sTags){ | ||
| 227 | + $tagString = $aMetaData[1]; | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + if($tagString != ''){ | ||
| 231 | + $words_table = KTUtil::getTableName('tag_words'); | ||
| 232 | + $tagString = str_replace(' ', '', $tagString); | ||
| 233 | + $tags = explode(',',$tagString); | ||
| 234 | + | ||
| 235 | + $aTagIds = array(); | ||
| 236 | + | ||
| 237 | + foreach($tags as $sTag) | ||
| 238 | + { | ||
| 239 | + $sTag=strtolower(trim($sTag)); | ||
| 240 | + | ||
| 241 | + $res = DBUtil::getOneResult(array("SELECT id FROM $words_table WHERE tag = ?", array($sTag))); | ||
| 242 | + | ||
| 243 | + if (PEAR::isError($res)) { | ||
| 244 | + return $res; | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + if (is_null($res)) | ||
| 248 | + { | ||
| 249 | + $id = & DBUtil::autoInsert($words_table, array('tag'=>$sTag)); | ||
| 250 | + $aTagIds[$sTag] = $id; | ||
| 251 | + } | ||
| 252 | + else | ||
| 253 | + { | ||
| 254 | + $aTagIds[$sTag] = $res['id']; | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + $doc_tags = KTUtil::getTableName('document_tags'); | ||
| 259 | + | ||
| 260 | + foreach($aTagIds as $sTag=>$tagid) | ||
| 261 | + { | ||
| 262 | + DBUtil::autoInsert($doc_tags, array( | ||
| 263 | + | ||
| 264 | + 'document_id'=>$iDocId, | ||
| 265 | + 'tag_id'=>$tagid), | ||
| 266 | + array('noid'=>true)); | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + } | ||
| 271 | +} | ||
| 272 | + | ||
| 273 | +/** | ||
| 274 | + * Trigger for document edit (postValidate) | ||
| 275 | + * | ||
| 276 | + */ | ||
| 277 | +class KTEditDocumentTrigger { | ||
| 278 | + var $aInfo = null; | ||
| 279 | + /** | ||
| 280 | + * function to set the info for the trigger | ||
| 281 | + * | ||
| 282 | + * @param array $aInfo | ||
| 283 | + */ | ||
| 284 | + function setInfo(&$aInfo) { | ||
| 285 | + $this->aInfo =& $aInfo; | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + /** | ||
| 289 | + * postValidate method for trigger | ||
| 290 | + * | ||
| 291 | + * @return unknown | ||
| 292 | + */ | ||
| 293 | + function postValidate() { | ||
| 294 | + global $default; | ||
| 295 | + $oDocument =& $this->aInfo['document']; | ||
| 296 | + $aMeta = & $this->aInfo['aOptions']; | ||
| 297 | + // get document id | ||
| 298 | + $iDocId = $oDocument->getID(); | ||
| 299 | + | ||
| 300 | + // get all tags that are linked to the document | ||
| 301 | + $sQuery = 'SELECT tw.id FROM tag_words AS tw, document_tags AS dt, documents AS d ' . | ||
| 302 | + 'WHERE dt.tag_id = tw.id ' . | ||
| 303 | + 'AND dt.document_id = d.id ' . | ||
| 304 | + 'AND d.id = ?'; | ||
| 305 | + $aParams = array($iDocId); | ||
| 306 | + $aTagId = DBUtil::getResultArray(array($sQuery, $aParams)); | ||
| 307 | + if (PEAR::isError($aTagId)) { | ||
| 308 | + // XXX: log error | ||
| 309 | + return false; | ||
| 310 | + } | ||
| 311 | + // if there are any related tags proceed | ||
| 312 | + if ($aTagId) { | ||
| 313 | + // delete all entries from document_tags table for the document | ||
| 314 | + $sQuery = 'DELETE FROM document_tags ' . | ||
| 315 | + 'WHERE document_id = ?'; | ||
| 316 | + $aParams = array($iDocId); | ||
| 317 | + $removed = DBUtil::runQuery(array($sQuery, $aParams)); | ||
| 318 | + if (PEAR::isError($removed)) { | ||
| 319 | + // XXX: log error | ||
| 320 | + return false; | ||
| 321 | + } | ||
| 322 | + } | ||
| 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; | ||
| 339 | + } | ||
| 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 | + } | ||
| 379 | + } | ||
| 380 | + } | ||
| 381 | +} | ||
| 382 | +?> |
plugins/tagcloud/TagCloudRedirectPage.php
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id: TagCloudRedirectPage.php,v 1.1 2006/02/28 16:53:49 nbm Exp $ | ||
| 4 | - * | ||
| 5 | - * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | ||
| 6 | - * | ||
| 7 | - * This program is free software; you can redistribute it and/or modify | ||
| 8 | - * it under the terms of the GNU General Public License as published by | ||
| 9 | - * the Free Software Foundation; using version 2 of the License. | ||
| 10 | - * | ||
| 11 | - * This program is distributed in the hope that it will be useful, | ||
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | - * GNU General Public License for more details. | ||
| 15 | - * | ||
| 16 | - * You should have received a copy of the GNU General Public License | ||
| 17 | - * along with this program; if not, write to the Free Software | ||
| 18 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 19 | - * | ||
| 20 | - * ------------------------------------------------------------------------- | ||
| 21 | - * | ||
| 22 | - * You can contact the copyright owner regarding licensing via the contact | ||
| 23 | - * details that can be found on the KnowledgeTree web site: | ||
| 24 | - * | ||
| 25 | - * http://www.ktdms.com/ | ||
| 26 | - **/ | ||
| 27 | - | ||
| 28 | -require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | ||
| 29 | -require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | ||
| 30 | -require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | ||
| 31 | -require_once(KT_LIB_DIR . '/database/dbutil.inc'); | ||
| 32 | -require_once(KT_LIB_DIR . '/util/ktutil.inc'); | ||
| 33 | -require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | ||
| 34 | -require_once(KT_LIB_DIR . '/browse/Criteria.inc'); | ||
| 35 | -require_once(KT_LIB_DIR . '/search/savedsearch.inc.php'); | ||
| 36 | -require_once(KT_LIB_DIR . '/search/searchutil.inc.php'); | ||
| 37 | - | ||
| 38 | -require_once(KT_LIB_DIR . '/browse/DocumentCollection.inc.php'); | ||
| 39 | -require_once(KT_LIB_DIR . '/browse/BrowseColumns.inc.php'); | ||
| 40 | -require_once(KT_LIB_DIR . '/browse/PartialQuery.inc.php'); | ||
| 41 | - | ||
| 42 | -require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php'); | ||
| 43 | -require_once(KT_LIB_DIR . '/actions/bulkaction.php'); | ||
| 44 | - | ||
| 45 | -class TagCloudRedirectPage extends KTStandardDispatcher { | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * Dispatcher main method | ||
| 49 | - * | ||
| 50 | - * @return unknown | ||
| 51 | - */ | ||
| 52 | - function do_main() { | ||
| 53 | - $searchable_text = KTUtil::arrayGet($_REQUEST, 'tag'); | ||
| 54 | - // set breadcrumbs | ||
| 55 | - $this->aBreadcrumbs[] = array('url' => 'dashboard.php', 'name' => _kt('Dashboard')); | ||
| 56 | - $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'].'&tag='.$searchable_text, 'name' => _kt('Tag Cloud Search')); | ||
| 57 | - // set page title | ||
| 58 | - $sTitle = _kt('Search Results'); | ||
| 59 | - | ||
| 60 | - $this->oPage->setBreadcrumbDetails($sTitle); | ||
| 61 | - | ||
| 62 | - // build criteria set | ||
| 63 | - $aCriteriaSet = array( | ||
| 64 | - 'join'=>'AND', | ||
| 65 | - 'subgroup'=>array( | ||
| 66 | - 0=>array( | ||
| 67 | - 'join'=>'AND', | ||
| 68 | - 'values'=>array( | ||
| 69 | - 1=>array( | ||
| 70 | - 'data'=>array( | ||
| 71 | - 'ktcore.criteria.tagcloud'=>$searchable_text, | ||
| 72 | - 'ktcore.criteria.tagcloud_not'=>0 | ||
| 73 | - ), | ||
| 74 | - 'type'=>'ktcore.criteria.tagcloud' | ||
| 75 | - ) | ||
| 76 | - ) | ||
| 77 | - ) | ||
| 78 | - ) | ||
| 79 | - ); | ||
| 80 | - | ||
| 81 | - | ||
| 82 | - $this->browseType = 'Folder'; | ||
| 83 | - $sSearch = md5(serialize($aCriteriaSet)); | ||
| 84 | - $_SESSION['boolean_search'][$sSearch] = $aCriteriaSet; | ||
| 85 | - | ||
| 86 | - $collection = new AdvancedCollection; | ||
| 87 | - $oColumnRegistry = KTColumnRegistry::getSingleton(); | ||
| 88 | - $aColumns = $oColumnRegistry->getColumnsForView('ktcore.views.search'); | ||
| 89 | - $collection->addColumns($aColumns); | ||
| 90 | - | ||
| 91 | - // set a view option | ||
| 92 | - $aTitleOptions = array( | ||
| 93 | - 'documenturl' => $GLOBALS['KTRootUrl'] . '/view.php', | ||
| 94 | - ); | ||
| 95 | - $collection->setColumnOptions('ktcore.columns.title', $aTitleOptions); | ||
| 96 | - $collection->setColumnOptions('ktcore.columns.selection', array( | ||
| 97 | - 'rangename' => 'selection', | ||
| 98 | - 'show_folders' => true, | ||
| 99 | - 'show_documents' => true, | ||
| 100 | - )); | ||
| 101 | - | ||
| 102 | - $aOptions = $collection->getEnvironOptions(); // extract data from the environment | ||
| 103 | - | ||
| 104 | - $aOptions['return_url'] = KTUtil::addQueryString('dashboard.php', false); | ||
| 105 | - $aOptions['empty_message'] = _kt('No documents or folders match this query.'); | ||
| 106 | - $aOptions['is_browse'] = true; | ||
| 107 | - | ||
| 108 | - $collection->setOptions($aOptions); | ||
| 109 | - $collection->setQueryObject(new BooleanSearchQuery($aCriteriaSet)); | ||
| 110 | - | ||
| 111 | - $oTemplating =& KTTemplating::getSingleton(); | ||
| 112 | - $oTemplate = $oTemplating->loadTemplate('kt3/browse'); | ||
| 113 | - $aTemplateData = array( | ||
| 114 | - 'context' => $this, | ||
| 115 | - 'collection' => $collection, | ||
| 116 | - 'custom_title' => $sTitle, | ||
| 117 | - 'isEditable' => true, | ||
| 118 | - 'boolean_search' => $sSearch, | ||
| 119 | - 'bulkactions' => KTBulkActionUtil::getAllBulkActions(), | ||
| 120 | - 'browseutil' => new KTBrowseUtil(), | ||
| 121 | - 'returnaction' => 'booleanSearch', | ||
| 122 | - 'returndata' => $sSearch, | ||
| 123 | - | ||
| 124 | - ); | ||
| 125 | - return $oTemplate->render($aTemplateData); | ||
| 126 | - | ||
| 127 | - } | ||
| 128 | -} | ||
| 129 | -?> | 1 | +<?php |
| 2 | +/** | ||
| 3 | + * $Id: TagCloudRedirectPage.php,v 1.1 2006/02/28 16:53:49 nbm Exp $ | ||
| 4 | + * | ||
| 5 | + * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | ||
| 6 | + * | ||
| 7 | + * This program is free software; you can redistribute it and/or modify | ||
| 8 | + * it under the terms of the GNU General Public License as published by | ||
| 9 | + * the Free Software Foundation; using version 2 of the License. | ||
| 10 | + * | ||
| 11 | + * This program is distributed in the hope that it will be useful, | ||
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | + * GNU General Public License for more details. | ||
| 15 | + * | ||
| 16 | + * You should have received a copy of the GNU General Public License | ||
| 17 | + * along with this program; if not, write to the Free Software | ||
| 18 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 19 | + * | ||
| 20 | + * ------------------------------------------------------------------------- | ||
| 21 | + * | ||
| 22 | + * You can contact the copyright owner regarding licensing via the contact | ||
| 23 | + * details that can be found on the KnowledgeTree web site: | ||
| 24 | + * | ||
| 25 | + * http://www.knowledgetree.com/ | ||
| 26 | + **/ | ||
| 27 | + | ||
| 28 | +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | ||
| 29 | +require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | ||
| 30 | +require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | ||
| 31 | +require_once(KT_LIB_DIR . '/database/dbutil.inc'); | ||
| 32 | +require_once(KT_LIB_DIR . '/util/ktutil.inc'); | ||
| 33 | +require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | ||
| 34 | +require_once(KT_LIB_DIR . '/browse/Criteria.inc'); | ||
| 35 | +require_once(KT_LIB_DIR . '/search/savedsearch.inc.php'); | ||
| 36 | +require_once(KT_LIB_DIR . '/search/searchutil.inc.php'); | ||
| 37 | + | ||
| 38 | +require_once(KT_LIB_DIR . '/browse/DocumentCollection.inc.php'); | ||
| 39 | +require_once(KT_LIB_DIR . '/browse/BrowseColumns.inc.php'); | ||
| 40 | +require_once(KT_LIB_DIR . '/browse/PartialQuery.inc.php'); | ||
| 41 | + | ||
| 42 | +require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php'); | ||
| 43 | +require_once(KT_LIB_DIR . '/actions/bulkaction.php'); | ||
| 44 | + | ||
| 45 | +class TagCloudRedirectPage extends KTStandardDispatcher { | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * Dispatcher main method | ||
| 49 | + * | ||
| 50 | + * @return unknown | ||
| 51 | + */ | ||
| 52 | + function do_main() { | ||
| 53 | + $searchable_text = KTUtil::arrayGet($_REQUEST, 'tag'); | ||
| 54 | + // set breadcrumbs | ||
| 55 | + $this->aBreadcrumbs[] = array('url' => 'dashboard.php', 'name' => _kt('Dashboard')); | ||
| 56 | + $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'].'&tag='.$searchable_text, 'name' => _kt('Tag Cloud Search')); | ||
| 57 | + // set page title | ||
| 58 | + $sTitle = _kt('Search Results'); | ||
| 59 | + | ||
| 60 | + $this->oPage->setBreadcrumbDetails($sTitle); | ||
| 61 | + | ||
| 62 | + // build criteria set | ||
| 63 | + $aCriteriaSet = array( | ||
| 64 | + 'join'=>'AND', | ||
| 65 | + 'subgroup'=>array( | ||
| 66 | + 0=>array( | ||
| 67 | + 'join'=>'AND', | ||
| 68 | + 'values'=>array( | ||
| 69 | + 1=>array( | ||
| 70 | + 'data'=>array( | ||
| 71 | + 'ktcore.criteria.tagcloud'=>$searchable_text, | ||
| 72 | + 'ktcore.criteria.tagcloud_not'=>0 | ||
| 73 | + ), | ||
| 74 | + 'type'=>'ktcore.criteria.tagcloud' | ||
| 75 | + ) | ||
| 76 | + ) | ||
| 77 | + ) | ||
| 78 | + ) | ||
| 79 | + ); | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + $this->browseType = 'Folder'; | ||
| 83 | + $sSearch = md5(serialize($aCriteriaSet)); | ||
| 84 | + $_SESSION['boolean_search'][$sSearch] = $aCriteriaSet; | ||
| 85 | + | ||
| 86 | + $collection = new AdvancedCollection; | ||
| 87 | + $oColumnRegistry = KTColumnRegistry::getSingleton(); | ||
| 88 | + $aColumns = $oColumnRegistry->getColumnsForView('ktcore.views.search'); | ||
| 89 | + $collection->addColumns($aColumns); | ||
| 90 | + | ||
| 91 | + // set a view option | ||
| 92 | + $aTitleOptions = array( | ||
| 93 | + 'documenturl' => $GLOBALS['KTRootUrl'] . '/view.php', | ||
| 94 | + ); | ||
| 95 | + $collection->setColumnOptions('ktcore.columns.title', $aTitleOptions); | ||
| 96 | + $collection->setColumnOptions('ktcore.columns.selection', array( | ||
| 97 | + 'rangename' => 'selection', | ||
| 98 | + 'show_folders' => true, | ||
| 99 | + 'show_documents' => true, | ||
| 100 | + )); | ||
| 101 | + | ||
| 102 | + $aOptions = $collection->getEnvironOptions(); // extract data from the environment | ||
| 103 | + | ||
| 104 | + $aOptions['return_url'] = KTUtil::addQueryString('dashboard.php', false); | ||
| 105 | + $aOptions['empty_message'] = _kt('No documents or folders match this query.'); | ||
| 106 | + $aOptions['is_browse'] = true; | ||
| 107 | + | ||
| 108 | + $collection->setOptions($aOptions); | ||
| 109 | + $collection->setQueryObject(new BooleanSearchQuery($aCriteriaSet)); | ||
| 110 | + | ||
| 111 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 112 | + $oTemplate = $oTemplating->loadTemplate('kt3/browse'); | ||
| 113 | + $aTemplateData = array( | ||
| 114 | + 'context' => $this, | ||
| 115 | + 'collection' => $collection, | ||
| 116 | + 'custom_title' => $sTitle, | ||
| 117 | + 'isEditable' => true, | ||
| 118 | + 'boolean_search' => $sSearch, | ||
| 119 | + 'bulkactions' => KTBulkActionUtil::getAllBulkActions(), | ||
| 120 | + 'browseutil' => new KTBrowseUtil(), | ||
| 121 | + 'returnaction' => 'booleanSearch', | ||
| 122 | + 'returndata' => $sSearch, | ||
| 123 | + | ||
| 124 | + ); | ||
| 125 | + return $oTemplate->render($aTemplateData); | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | +} | ||
| 129 | +?> |
tests/file_gettext/test.po
| @@ -13,8 +13,8 @@ msgstr "" | @@ -13,8 +13,8 @@ msgstr "" | ||
| 13 | "X-Poedit-Country: COLOMBIA\n" | 13 | "X-Poedit-Country: COLOMBIA\n" |
| 14 | "X-Poedit-SourceCharset: utf-8\n" | 14 | "X-Poedit-SourceCharset: utf-8\n" |
| 15 | 15 | ||
| 16 | -msgid "© 2006 <a href=\"http://www.ktdms.com/\">The Jam Warehouse Software (Pty) Ltd.</a> All Rights Reserved" | ||
| 17 | -msgstr "© 2006 <a href=\"http://www.ktdms.com/\">The Jam Warehouse Software (Pty) Ltd.</a> Todos los Derechos Reservados - <a href=\"http://www.oriondatacenter.com/\">Orion Datacenter.</a> Bussines Partner para Colombia" | 16 | +msgid "© 2006 <a href=\"http://www.knowledgetree.com/\">The Jam Warehouse Software (Pty) Ltd.</a> All Rights Reserved" |
| 17 | +msgstr "© 2006 <a href=\"http://www.knowledgetree.com/\">The Jam Warehouse Software (Pty) Ltd.</a> Todos los Derechos Reservados - <a href=\"http://www.oriondatacenter.com/\">Orion Datacenter.</a> Bussines Partner para Colombia" | ||
| 18 | 18 | ||
| 19 | msgid "Document \"%s\" renamed." | 19 | msgid "Document \"%s\" renamed." |
| 20 | msgstr "El documento \"%s\" ha sido renombrado." | 20 | msgstr "El documento \"%s\" ha sido renombrado." |
tests/file_gettext/test2.po
| @@ -14,10 +14,10 @@ msgstr "" | @@ -14,10 +14,10 @@ msgstr "" | ||
| 14 | "X-Poedit-SourceCharset: utf-8\n" | 14 | "X-Poedit-SourceCharset: utf-8\n" |
| 15 | 15 | ||
| 16 | msgid "" | 16 | msgid "" |
| 17 | -"© 2006 <a href=\"http://www.ktdms.com/\">The Jam Warehouse Software " | 17 | +"© 2006 <a href=\"http://www.knowledgetree.com/\">The Jam Warehouse Software " |
| 18 | "(Pty) Ltd.</a> All Rights Reserved" | 18 | "(Pty) Ltd.</a> All Rights Reserved" |
| 19 | msgstr "" | 19 | msgstr "" |
| 20 | -"© 2006 <a href=\"http://www.ktdms.com/\">The Jam Warehouse Software " | 20 | +"© 2006 <a href=\"http://www.knowledgetree.com/\">The Jam Warehouse Software " |
| 21 | "(Pty) Ltd.</a> Todos los Derechos Reservados - <a href=\"http://www." | 21 | "(Pty) Ltd.</a> Todos los Derechos Reservados - <a href=\"http://www." |
| 22 | "oriondatacenter.com/\">Orion Datacenter.</a> Bussines Partner para Colombia" | 22 | "oriondatacenter.com/\">Orion Datacenter.</a> Bussines Partner para Colombia" |
| 23 | 23 |