Commit 83b952cad934801ec7cc25011716e69c95a15dee
1 parent
a1c1fc93
Add system-wide saved searches and system condition management
interfaces. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3956 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
4 changed files
with
224 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/administration/searches/conditions.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +// boilerplate includes | |
| 4 | +require_once("../../../../../config/dmsDefaults.php"); | |
| 5 | +require_once(KT_DIR . "/presentation/Html.inc"); | |
| 6 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 7 | +require_once(KT_LIB_DIR . "/dispatcher.inc.php"); | |
| 8 | +require_once(KT_LIB_DIR . "/browse/Criteria.inc"); | |
| 9 | +require_once(KT_LIB_DIR . "/search/savedsearch.inc.php"); | |
| 10 | + | |
| 11 | +// specific includes | |
| 12 | + | |
| 13 | +$sectionName = "General"; | |
| 14 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | |
| 15 | + | |
| 16 | +class KTConditionDispatcher extends KTStandardDispatcher { | |
| 17 | + var $bAutomaticTransaction = true; | |
| 18 | + | |
| 19 | + function do_main() { | |
| 20 | + $oTemplate =& $this->oValidator->validateTemplate('ktcore/search/administration/conditions'); | |
| 21 | + $oTemplate->setData(array( | |
| 22 | + 'conditions' => KTSavedSearch::getConditions(), | |
| 23 | + )); | |
| 24 | + return $oTemplate->render(); | |
| 25 | + } | |
| 26 | + | |
| 27 | + function do_new() { | |
| 28 | + $oTemplating = new KTTemplating; | |
| 29 | + $oTemplate = $oTemplating->loadTemplate("ktcore/boolean_search"); | |
| 30 | + | |
| 31 | + $aCriteria = Criteria::getAllCriteria(); | |
| 32 | + | |
| 33 | + $aTemplateData = array( | |
| 34 | + "title" => "Create a new condition", | |
| 35 | + "sNameTitle" => "Name of condition", | |
| 36 | + "aCriteria" => $aCriteria, | |
| 37 | + "searchButton" => "Save", | |
| 38 | + ); | |
| 39 | + return $oTemplate->render($aTemplateData); | |
| 40 | + } | |
| 41 | + | |
| 42 | + function do_view() { | |
| 43 | + | |
| 44 | + } | |
| 45 | + | |
| 46 | + function handleOutput($data) { | |
| 47 | + global $main; | |
| 48 | + $main->bFormDisabled = true; | |
| 49 | + $main->setCentralPayload($data); | |
| 50 | + $main->render(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + // XXX: Rename to do_save | |
| 54 | + function do_performSearch() { | |
| 55 | + $datavars = KTUtil::arrayGet($_REQUEST, 'boolean_search'); | |
| 56 | + if (!is_array($datavars)) { | |
| 57 | + $datavars = unserialize($datavars); | |
| 58 | + } | |
| 59 | + | |
| 60 | + if (empty($datavars)) { | |
| 61 | + $this->errorRedirectToMain('You need to have at least 1 condition.'); | |
| 62 | + } | |
| 63 | + | |
| 64 | + $sName = $_REQUEST['name']; | |
| 65 | + $sNamespace = KTUtil::nameToLocalNamespace('Saved searches', $sName); | |
| 66 | + | |
| 67 | + $oSearch = KTSavedSearch::createFromArray(array( | |
| 68 | + 'name' => $sName, | |
| 69 | + 'namespace' => $sNamespace, | |
| 70 | + 'iscondition' => true, | |
| 71 | + 'iscomplete' => true, | |
| 72 | + 'userid' => null, | |
| 73 | + 'search' => $datavars, | |
| 74 | + )); | |
| 75 | + | |
| 76 | + $this->oValidator->notError($oSearch, array( | |
| 77 | + 'redirect_to' => 'main', | |
| 78 | + 'message' => 'Search not saved', | |
| 79 | + )); | |
| 80 | + $this->successRedirectToMain('Search saved'); | |
| 81 | + } | |
| 82 | +} | |
| 83 | + | |
| 84 | +$oDispatcher = new KTConditionDispatcher(); | |
| 85 | +$oDispatcher->dispatch(); | |
| 86 | + | |
| 87 | +?> | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/searches/savedSearch.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +// boilerplate includes | |
| 4 | +require_once("../../../../../config/dmsDefaults.php"); | |
| 5 | +require_once(KT_DIR . "/presentation/Html.inc"); | |
| 6 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 7 | +require_once(KT_LIB_DIR . "/dispatcher.inc.php"); | |
| 8 | +require_once(KT_LIB_DIR . "/browse/Criteria.inc"); | |
| 9 | +require_once(KT_LIB_DIR . "/search/savedsearch.inc.php"); | |
| 10 | + | |
| 11 | +// specific includes | |
| 12 | + | |
| 13 | +$sectionName = "General"; | |
| 14 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | |
| 15 | + | |
| 16 | +class KTSavedSearchDispatcher extends KTStandardDispatcher { | |
| 17 | + var $bAutomaticTransaction = true; | |
| 18 | + | |
| 19 | + function do_main() { | |
| 20 | + $oTemplate =& $this->oValidator->validateTemplate('ktcore/search/administration/savedsearches'); | |
| 21 | + $oTemplate->setData(array( | |
| 22 | + 'saved_searches' => KTSavedSearch::getList(), | |
| 23 | + )); | |
| 24 | + return $oTemplate->render(); | |
| 25 | + } | |
| 26 | + | |
| 27 | + function do_new() { | |
| 28 | + $oTemplating = new KTTemplating; | |
| 29 | + $oTemplate = $oTemplating->loadTemplate("ktcore/boolean_search"); | |
| 30 | + | |
| 31 | + $aCriteria = Criteria::getAllCriteria(); | |
| 32 | + | |
| 33 | + $aTemplateData = array( | |
| 34 | + "title" => "Create a new condition", | |
| 35 | + "aCriteria" => $aCriteria, | |
| 36 | + "searchButton" => "Save", | |
| 37 | + ); | |
| 38 | + return $oTemplate->render($aTemplateData); | |
| 39 | + } | |
| 40 | + | |
| 41 | + function do_view() { | |
| 42 | + | |
| 43 | + } | |
| 44 | + | |
| 45 | + function handleOutput($data) { | |
| 46 | + global $main; | |
| 47 | + $main->bFormDisabled = true; | |
| 48 | + $main->setCentralPayload($data); | |
| 49 | + $main->render(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + // XXX: Rename to do_save | |
| 53 | + function do_performSearch() { | |
| 54 | + $datavars = KTUtil::arrayGet($_REQUEST, 'boolean_search'); | |
| 55 | + if (!is_array($datavars)) { | |
| 56 | + $datavars = unserialize($datavars); | |
| 57 | + } | |
| 58 | + | |
| 59 | + if (empty($datavars)) { | |
| 60 | + $this->errorRedirectToMain('You need to have at least 1 condition.'); | |
| 61 | + } | |
| 62 | + | |
| 63 | + $sName = "Neil's saved search"; | |
| 64 | + $sNamespace = KTUtil::nameToLocalNamespace('Saved searches', $sName); | |
| 65 | + | |
| 66 | + $oSearch = KTSavedSearch::createFromArray(array( | |
| 67 | + 'name' => $sName, | |
| 68 | + 'namespace' => $sNamespace, | |
| 69 | + 'iscondition' => false, | |
| 70 | + 'iscomplete' => true, | |
| 71 | + 'userid' => null, | |
| 72 | + 'search' => $datavars, | |
| 73 | + )); | |
| 74 | + | |
| 75 | + $this->oValidator->notError($oSearch, array( | |
| 76 | + 'redirect_to' => 'main', | |
| 77 | + 'message' => 'Search not saved', | |
| 78 | + )); | |
| 79 | + $this->successRedirectToMain('Search saved'); | |
| 80 | + } | |
| 81 | +} | |
| 82 | + | |
| 83 | +$oDispatcher = new KTSavedSearchDispatcher(); | |
| 84 | +$oDispatcher->dispatch(); | |
| 85 | + | |
| 86 | +?> | ... | ... |
templates/ktcore/search/administration/conditions.smarty
0 → 100644
| 1 | +<h1>Conditions</h1> | |
| 2 | + | |
| 3 | +<h2>Create a new condition</h2> | |
| 4 | +<form> | |
| 5 | +<input type="hidden" name="action" value="new" /> | |
| 6 | +<input type="submit" name="submit" value="New" /> | |
| 7 | +</form> | |
| 8 | + | |
| 9 | +{if $conditions} | |
| 10 | +<h2>Edit existing conditions</h2> | |
| 11 | +<form> | |
| 12 | +<input type="hidden" name="action" value="edit" /> | |
| 13 | +{entity_radios entities=$conditions name="fSavedSearchId" assign=aRadios} | |
| 14 | +{foreach from=$aRadios item=sRadio} | |
| 15 | +{$sRadio}<br /> | |
| 16 | +{/foreach} | |
| 17 | +<input type="submit" name="submit" value="Edit" /> | |
| 18 | +</form> | |
| 19 | +{/if} | |
| 20 | + | ... | ... |
templates/ktcore/search/administration/savedsearches.smarty
0 → 100644
| 1 | +<h1>Saved searches</h1> | |
| 2 | + | |
| 3 | +<h2>Create a new saved search</h2> | |
| 4 | +<form> | |
| 5 | +<input type="hidden" name="action" value="new" /> | |
| 6 | +<input type="submit" name="submit" value="New" /> | |
| 7 | +</form> | |
| 8 | + | |
| 9 | +{if $saved_searches} | |
| 10 | +<h2>Edit existing saved searches</h2> | |
| 11 | +<form> | |
| 12 | +<input type="hidden" name="action" value="edit" /> | |
| 13 | +{entity_radios entities=$saved_searches name="fSavedSearchId" assign=aRadios} | |
| 14 | +{foreach from=$aRadios item=sRadio} | |
| 15 | +{$sRadio}<br /> | |
| 16 | +{/foreach} | |
| 17 | +<input type="submit" name="submit" value="Edit" /> | |
| 18 | +</form> | |
| 19 | + | |
| 20 | +<h2>Run a saved search</h2> | |
| 21 | +<form action="{"booleanSearch"|generateControllerUrl}" method="GET"> | |
| 22 | +<input type="hidden" name="action" value="booleanSearch" /> | |
| 23 | +<input type="hidden" name="qs[action]" value="performSearch" /> | |
| 24 | +{entity_radios entities=$saved_searches name="qs[fSavedSearchId]" assign=aRadios} | |
| 25 | +{foreach from=$aRadios item=sRadio} | |
| 26 | +{$sRadio}<br /> | |
| 27 | +{/foreach} | |
| 28 | +<input type="submit" name="submit" value="Run" /> | |
| 29 | +</form> | |
| 30 | +{/if} | |
| 31 | + | ... | ... |