openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 726957f1aa4264b7036007d38d445a28e19f8e55
parent 12853298c7adac54a04ff1b215abd9f1cbf4b252
Author: Jan Dankert <devnull@localhost>
Date:   Thu, 21 Mar 2013 01:48:18 +0100

Suchfunktion wieder funktionsfähig, Vereinfachung der Projekt-Suchfunktion, Fix für Formulare mit GET-Methode.

Diffstat:
action/SearchAction.class.php | 358++++++++++++++++++++++++++++++++-----------------------------------------------
config/config-default.php | 11++++++-----
themes/default/include/html/form.inc.php | 5++++-
themes/default/js/openrat.js | 22++++++++++------------
themes/default/js/plugin/jquery-plugin-orSearch.js | 6+++---
themes/default/templates/search/content.tpl.src.xml | 45---------------------------------------------
themes/default/templates/search/prop.tpl.src.xml | 65-----------------------------------------------------------------
themes/default/templates/search/result.tpl.src.xml | 8++++----
8 files changed, 171 insertions(+), 349 deletions(-)

diff --git a/action/SearchAction.class.php b/action/SearchAction.class.php @@ -16,6 +16,14 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +define('SEARCH_FLAG_ID' , 1); +define('SEARCH_FLAG_NAME' , 2); +define('SEARCH_FLAG_FILENAME' , 4); +define('SEARCH_FLAG_DESCRIPTION', 8); +define('SEARCH_FLAG_VALUE' ,16); + + /** * Action-Klasse fuer die Suchfunktion. * @@ -23,10 +31,10 @@ * @version $Revision$ * @package openrat.actions */ - class SearchAction extends Action { public $security = SECURITY_USER; + /** * leerer Kontruktor @@ -36,54 +44,32 @@ class SearchAction extends Action } - public function showView() - { - $this->nextSubAction('content'); - } - - public function showAction() - { - $this->nextSubAction('content'); - } - - public function editView() { - $this->nextSubAction('content'); + $user = Session::getUser(); + $this->setTemplateVar( 'users' ,User::listAll() ); + $this->setTemplateVar( 'act_userid',$user->userid ); } - - public function editPost() - { - $this->nextSubAction('content'); - } - - /** * Durchf?hren der Suche * und Anzeige der Ergebnisse */ - public function contentPost() + public function resultView() { - global $conf_php; - - $listObjectIds = array(); - $listTemplateIds = array(); + $suchText = $this->getRequestVar('text'); + $searchFlags = 0; - switch( $this->getRequestVar('type') ) - { - case 'value': - $e = new Value(); - $language = Session::getProjectLanguage(); - $e->languageid = $language->languageid; - - $listObjectIds = $e->getObjectIdsByValue( $this->getRequestVar('text') ); - - $template = new Template(); - $listTemplateIds = $template->getTemplateIdsByValue( $this->getRequestVar('text') ); - break; - + if ( $this->hasRequestVar('id' ) ) $searchFlags |= SEARCH_FLAG_ID; + if ( $this->hasRequestVar('filename' ) ) $searchFlags |= SEARCH_FLAG_FILENAME; + if ( $this->hasRequestVar('name' ) ) $searchFlags |= SEARCH_FLAG_NAME; + if ( $this->hasRequestVar('description') ) $searchFlags |= SEARCH_FLAG_DESCRIPTION; + if ( $this->hasRequestVar('content' ) ) $searchFlags |= SEARCH_FLAG_VALUE; + + $this->performSearch($suchText, $searchFlags); + + /* case 'lastchange_user': $e = new Value(); @@ -92,110 +78,12 @@ class SearchAction extends Action $listObjectIds = $e->getObjectIdsByLastChangeUserId( $this->getRequestVar('userid') ); break; - } - - - $this->explainResult( $listObjectIds, $listTemplateIds ); - + }*/ } /** - * - */ - private function explainResult( $listObjectIds, $listTemplateIds ) - { - $resultList = array(); - - foreach( $listObjectIds as $objectid ) - { - $o = new Object( $objectid ); - $o->load(); - $resultList[$objectid] = array(); - $resultList[$objectid]['url'] = Html::url($o->getType(),'',$objectid); - $resultList[$objectid]['type'] = $o->getType(); - $resultList[$objectid]['name'] = $o->name; - $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate; - - if ( $o->desc != '' ) - $resultList[$objectid]['desc'] = $o->desc; - else - $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); - } - - foreach( $listTemplateIds as $templateid ) - { - $t = new Template( $templateid ); - $t->load(); - $resultList['t'.$templateid] = array(); - $resultList['t'.$templateid]['url' ] = Html::url('template','',$templateid); - $resultList['t'.$templateid]['type'] = 'template'; - $resultList['t'.$templateid]['name'] = $t->name; - $resultList['t'.$templateid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); - $resultList['t'.$templateid]['lastchange_date'] = 0; - } - - $this->setTemplateVar( 'result',$resultList ); - } - - - /** - * Durchf?hren der Suche - * und Anzeige der Ergebnisse - */ - public function propPost() - { - global $conf_php; - - $listObjectIds = array(); - $listTemplateIds = array(); - - switch( $this->getRequestVar('type') ) - { - case 'id': - $o = new Object(); - if ( $o->isObjectId($this->getRequestVar('text')) ) - $listObjectIds[] = $this->getRequestVar('text'); - break; - - case 'filename': - $o = new Object(); - $listObjectIds = $o->getObjectIdsByFilename( $this->getRequestVar('text') ); - - $f = new File(); - $listObjectIds += $f->getObjectIdsByExtension( $this->getRequestVar('text') ); - break; - - case 'name': - $o = new Object(); - $listObjectIds = $o->getObjectIdsByName( $this->getRequestVar('text') ); - break; - - case 'description': - $o = new Object(); - $listObjectIds = $o->getObjectIdsByDescription( $this->getRequestVar('text') ); - break; - - case 'create_user': - $o = new Object(); - $listObjectIds = $o->getObjectIdsByCreateUserId( $this->getRequestVar('userid') ); - break; - - case 'lastchange_user': - $o = new Object(); - $listObjectIds = $o->getObjectIdsByLastChangeUserId( $this->getRequestVar('userid') ); - break; - - default: - die('search method unknown: '.$this->getRequestVar('type') ); - } - - $this->explainResult( $listObjectIds, $listTemplateIds ); - } - - - /** * Durchf?hren der Suche * und Anzeige der Ergebnisse */ @@ -203,90 +91,132 @@ class SearchAction extends Action { global $conf; - $listObjectIds = array(); - $listTemplateIds = array(); - $text = $this->getRequestVar('search'); - $project = Session::getProject(); - if ( is_object($project) && $project->projectid == -1 ) - { - $resultList = array(); - - $user = User::loadWithName($text); - if ( is_object($user) ) - { - $userResult = array( 'url' => Html::url('template','',$templateid), - 'type' => 'user', - 'name' => $user->name, - 'desc' => lang('NO_DESCRIPTION_AVAILABLE'), - 'lastchange_date' => 0 ); - } - $resultList[] = $userResult; - - $this->setTemplateVar( 'result',$resultList ); - } - else - { - $o = new Object(); - if ( Object::available( intval($text) ) ) - $listObjectIds[] = intval( $text ); - - if ( $conf['search']['quicksearch']['search_name'] ) - { - $o = new Object(); - $listObjectIds += $o->getObjectIdsByName( $text ); - } - - if ( $conf['search']['quicksearch']['search_description'] ) - { - $o = new Object(); - $listObjectIds += $o->getObjectIdsByDescription( $text ); - } - - if ( $conf['search']['quicksearch']['search_filename'] ) - { - $o = new Object(); - $listObjectIds += $o->getObjectIdsByFilename( $text ); - - $f = new File(); - $listObjectIds += $f->getObjectIdsByExtension( $text ); - } - - // Inhalte durchsuchen - if ( $conf['search']['quicksearch']['search_content'] ) - { - $e = new Value(); - $listObjectIds += $e->getObjectIdsByValue( $text ); - - $template = new Template(); - $listTemplateIds += $template->getTemplateIdsByValue( $text ); - } - - $this->explainResult( $listObjectIds, $listTemplateIds ); - } - + $flag = $conf['search']['quicksearch']['flag']; + $searchFlags = 0; + if ( $flag['id' ] ) $searchFlags |= SEARCH_FLAG_ID; + if ( $flag['name' ] ) $searchFlags |= SEARCH_FLAG_NAME; + if ( $flag['filename' ] ) $searchFlags |= SEARCH_FLAG_FILENAME; + if ( $flag['description'] ) $searchFlags |= SEARCH_FLAG_DESCRIPTION; + if ( $flag['content' ] ) $searchFlags |= SEARCH_FLAG_VALUE; + + $this->performSearch($text, $searchFlags); } - public function propView() - { - $user = Session::getUser(); - $this->setTemplateVar( 'users' ,User::listAll() ); - $this->setTemplateVar( 'act_userid',$user->userid ); - } - - - public function contentView() - { - $user = Session::getUser(); - $this->setTemplateVar( 'users' ,User::listAll() ); - $this->setTemplateVar( 'act_userid',$user->userid ); - } - function result() + /** + * Durchf?hren der Suche + * und Anzeige der Ergebnisse + */ + private function performSearch( $text, $flag) { - } + global $conf; + + $listObjectIds = array(); + $listTemplateIds = array(); + + $project = Session::getProject(); + if ( is_object($project) && $project->projectid == -1 ) + { + $resultList = array(); + + $user = User::loadWithName($text); + if ( is_object($user) ) + { + $userResult = array( 'url' => Html::url('template','',$templateid), + 'type' => 'user', + 'name' => $user->name, + 'desc' => lang('NO_DESCRIPTION_AVAILABLE'), + 'lastchange_date' => 0 ); + } + $resultList[] = $userResult; + + $this->setTemplateVar( 'result',$resultList ); + } + else + { + if ( $flag & SEARCH_FLAG_ID && Object::available( intval($text) ) ) + $listObjectIds[] = intval( $text ); + + if ( $flag & SEARCH_FLAG_NAME ) + { + $o = new Object(); + $listObjectIds += $o->getObjectIdsByName( $text ); + } + + if ( $flag & SEARCH_FLAG_DESCRIPTION ) + { + $o = new Object(); + $listObjectIds += $o->getObjectIdsByDescription( $text ); + } + + if ( $flag & SEARCH_FLAG_FILENAME ) + { + $o = new Object(); + $listObjectIds += $o->getObjectIdsByFilename( $text ); + + $f = new File(); + $listObjectIds += $f->getObjectIdsByExtension( $text ); + } + + // Inhalte durchsuchen + if ( $flag & SEARCH_FLAG_VALUE ) + { + $e = new Value(); + $listObjectIds += $e->getObjectIdsByValue( $text ); + + $template = new Template(); + $listTemplateIds += $template->getTemplateIdsByValue( $text ); + } + + $this->explainResult( $listObjectIds, $listTemplateIds ); + } + + } + + + /** + * + */ + private function explainResult( $listObjectIds, $listTemplateIds ) + { + $resultList = array(); + + foreach( $listObjectIds as $objectid ) + { + $o = new Object( $objectid ); + $o->load(); + $resultList[$objectid] = array(); + $resultList[$objectid]['id' ] = $objectid; + $resultList[$objectid]['url' ] = Html::url($o->getType(),'',$objectid); + $resultList[$objectid]['type'] = $o->getType(); + $resultList[$objectid]['name'] = $o->name; + $resultList[$objectid]['lastchange_date'] = $o->lastchangeDate; + + if ( $o->desc != '' ) + $resultList[$objectid]['desc'] = $o->desc; + else + $resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + } + + foreach( $listTemplateIds as $templateid ) + { + $t = new Template( $templateid ); + $t->load(); + $resultList['t'.$templateid] = array(); + $resultList['t'.$templateid]['id' ] = $templateid; + $resultList['t'.$templateid]['url' ] = Html::url('template','',$templateid); + $resultList['t'.$templateid]['type'] = 'template'; + $resultList['t'.$templateid]['name'] = $t->name; + $resultList['t'.$templateid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE'); + $resultList['t'.$templateid]['lastchange_date'] = 0; + } + + $this->setTemplateVar( 'result',$resultList ); + } + } ?> \ No newline at end of file diff --git a/config/config-default.php b/config/config-default.php @@ -698,11 +698,12 @@ $conf['replace']['copy']= "(c),&copy"; $conf['search'] = array(); $conf['search']['']='0'; $conf['search']['quicksearch'] = array(); -$conf['search']['quicksearch']['show_button']=false; -$conf['search']['quicksearch']['search_name']=true; -$conf['search']['quicksearch']['search_filename']=true; -$conf['search']['quicksearch']['search_description']=true; -$conf['search']['quicksearch']['search_content']=false; +$conf['search']['quicksearch']['flag'] = array(); +$conf['search']['quicksearch']['flag']['id']=true; +$conf['search']['quicksearch']['flag']['name']=true; +$conf['search']['quicksearch']['flag']['filename']=true; +$conf['search']['quicksearch']['flag']['description']=true; +$conf['search']['quicksearch']['flag']['content']=false; $conf['security'] = array(); $conf['security']['readonly']=false; $conf['security']['nopublish']=false; diff --git a/themes/default/include/html/form.inc.php b/themes/default/include/html/form.inc.php @@ -45,7 +45,10 @@ ?><form name="<?php echo $attr_name ?>" target="<?php echo $attr_target ?>" - action="<?php echo Html::url( $attr_action,$attr_subaction,$attr_id ) ?>" + action="" + data-method="<?php echo $attr_subaction ?>" + data-action="<?php echo $attr_action ?>" + data-id="<?php echo $requestId ?>" method="<?php echo $attr_method ?>" enctype="<?php echo $attr_enctype ?>" class="<?php echo $attr_action ?>" diff --git a/themes/default/js/openrat.js b/themes/default/js/openrat.js @@ -398,7 +398,7 @@ function loadViewByName(viewName, url ) * @param jo * @param url URL, von der der Inhalt geladen wird. */ -function loadView(contentEl,action,method,id ) +function loadView(contentEl,action,method,id,params ) { // Schauen, ob der Inhalt schon geladen ist... var targetEl = $(contentEl).children('div.sheet.action-'+action+'.method-'+method+'.id-'+id); @@ -424,7 +424,7 @@ function loadView(contentEl,action,method,id ) } } - var url = createUrl(action,method,id,0); // URL für das Laden erzeugen. + var url = createUrl(action,method,id,params); // URL für das Laden erzeugen. $(targetEl).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(response, status, xhr) { $(targetEl).fadeTo(350,1); @@ -1054,18 +1054,16 @@ function formSubmit(form) var params = $(form).serializeArray(); var url = './dispatcher.php'; // Alle Parameter befinden sich im Formular - var method = $(form).attr('method').toUpperCase(); + var formMethod = $(form).attr('method').toUpperCase(); - if ( method == 'GET' ) + if ( formMethod == 'GET' ) { // GET-Request - var method = $(form).closest('div.panel').attr('data-method'); - var p = $(form).closest('div.panel'); - var action = p.attr('data-action'); - var id = p.attr('data-id'); - params.output = 'html'; - //alert(method+'/'+action+'/'+id); - loadView( $(form).closest('div.content'),createUrl(action,method,id,params)); + var action = $(form).data('action'); + var method = $(form).data('method'); + var id = $(form).data('id' ); + + loadView( $(form).closest('div.content'),action,method,id,params); } else { @@ -1441,7 +1439,7 @@ function createUrl(action,subaction,id,extraid) { url += '?action='+action+'&subaction='+subaction+'&id='+id; } - + console.log("URL="+url); return url; } diff --git a/themes/default/js/plugin/jquery-plugin-orSearch.js b/themes/default/js/plugin/jquery-plugin-orSearch.js @@ -15,11 +15,11 @@ jQuery.fn.orSearch = function( options ) if ( val.length > 3 ) { $(settings.dropdown).html(''); - $.ajax( { 'type':'GET',url:'./dispatcher.php?action=search&subaction=quicksearch&search='+val, data:null, success:function(data, textStatus, jqXHR) + $.ajax( { 'type':'GET',url:'./dispatcher.php?action=search&subaction=quicksearch&output=json&search='+val, data:null, success:function(data, textStatus, jqXHR) { - for( id in data.result ) + for( id in data.output.result ) { - var result = data.result[id]; + var result = data.output.result[id]; // Suchergebnis-Zeile in das Ergebnis schreiben. $(settings.dropdown).append('<div class="entry clickable" title="'+result.desc+'"><a href="javascript:void(0);" data-type="open" data-name="'+result.name+'" data-action="'+result.type+'" data-id="'+id+'"><img src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+result.type+'.png" />'+result.name+'</a></div>'); diff --git a/themes/default/templates/search/content.tpl.src.xml b/themes/default/templates/search/content.tpl.src.xml @@ -1,44 +0,0 @@ -<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> - <header views="prop,content" /> - - <form> - <row> - <column colspan="2"> - <group title="message:global_user"></group> - </column> - </row> - <row> - <column> - <radio name="type" value="lastchange_user"></radio> - <label for="type" value="lastchange_user"> - <text key="lastchange_user"></text> - </label> - </column> - <column> - <selectbox list="users" name="userid" default="var:act_userid"></selectbox> - </column> - </row> - <row> - <column colspan="2"> - <group title="message:SEARCH_CONTENT"></group> - </column> - </row> - <row> - <column> - <radio name="type" value="value" default="true"></radio> - <label for="type" value="value"> - <text key="value"></text> - </label> - </column> - <column> - <input name="text"></input> - </column> - </row> - <row> - <column colspan="2" class="act"> - <button type="ok"></button> - </column> - </row> - </form> -</output>- \ No newline at end of file diff --git a/themes/default/templates/search/prop.tpl.src.xml b/themes/default/templates/search/prop.tpl.src.xml @@ -1,64 +0,0 @@ -<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> - <header views="prop,content" /> - <form> - <row> - <column colspan="2"> - <group title="message:global_user"></group> - </column> - </row> - <row> - <column> - <radio name="type" value="create_user"></radio> - <label for="type" value="create_user"> - <text key="create_user"></text> - </label> - <newline></newline> - <radio name="type" value="lastchange_user"></radio> - <label for="type" value="lastchange_user"> - <text key="lastchange_user"></text> - </label> - </column> - <column> - <selectbox list="users" name="userid" default="var:act_userid"></selectbox> - </column> - </row> - <row> - <column colspan="2"> - <group title="message:MENU_SEARCH_PROP"></group> - </column> - </row> - <row> - <column> - <radio name="type" value="id"></radio> - <label for="type" value="id"> - <text key="id"></text> - </label> - <newline></newline> - <radio name="type" value="name" default="true"></radio> - <label for="type" value="name"> - <text key="name"></text> - </label> - <newline></newline> - <radio name="type" value="description"></radio> - <label for="type" value="description"> - <text key="description"></text> - </label> - <newline></newline> - <radio name="type" value="filename"></radio> - <label for="type" value="filename"> - <text key="filename"></text> - </label> - <newline></newline> - </column> - <column> - <input name="text"></input> - </column> - </row> - <row class=""> - <column colspan="2" class="act"> - <button type="ok"></button> - </column> - </row> - </form> -</output>- \ No newline at end of file diff --git a/themes/default/templates/search/result.tpl.src.xml b/themes/default/templates/search/result.tpl.src.xml @@ -2,17 +2,17 @@ xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> <table> <row> - <column class="help"> + <column class="header"> <text key="GLOBAL_NAME"></text> </column> - <column class="help"> + <column class="header"> <text key="GLOBAL_LASTCHANGE"></text> </column> </row> <list list="result" extract="true"> <row class="data"> - <column> - <link url="var:url" target="cms_main"> + <column class="clickable"> + <link type="open" action="var:type" name="var:name" id="var:id"> <image type="var:type"></image> <text var="name" title="var:desc"></text> </link>