diff --git a/cis/index.php b/cis/index.php index 1503aa2f7..bda01ef70 100644 --- a/cis/index.php +++ b/cis/index.php @@ -92,26 +92,27 @@ function loadampel() + - -
+ +
- -
Powered by FH Complete 2.0
- + +
+ Powered by FH Complete 2.0 +
+ + - - - - - - - + + + getAll(true); @@ -119,14 +120,19 @@ function loadampel() { echo ' '.$row->sprache.''; } - ?> + ?> + + +
+ + +
- diff --git a/cis/private/tools/suche.php b/cis/private/tools/suche.php new file mode 100755 index 000000000..6da88d167 --- /dev/null +++ b/cis/private/tools/suche.php @@ -0,0 +1,192 @@ + + */ +/** + * Globale Suche + */ +require_once('../../../config/cis.config.inc.php'); +require_once('../../../include/functions.inc.php'); +require_once('../../../include/phrasen.class.php'); +require_once('../../../include/content.class.php'); +require_once('../../../include/benutzer.class.php'); + +$uid = get_uid(); +$db = new basis_db(); +$sprache = getSprache(); +$p = new phrasen($sprache); +echo ' + + + + + + + Globale Suche + +'; + +echo '

',$p->t('tools/suche'),'

'; + +$search = (isset($_REQUEST['search'])?$_REQUEST['search']:''); + +echo '
+ + +
'; + +if($search=='') + exit; + +$searchItems = explode(' ',$search); + +searchContent($searchItems); + +searchPerson($searchItems); + + +function searchPerson($searchItems) +{ + global $db, $p; + $bn = new benutzer(); + $bn->search($searchItems); + + echo '

',$p->t('global/personen'),'

'; + + if(count($bn->result)>0) + { + echo ' + + + + + + + + + + + + + + + '; + foreach($bn->result as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->alias!='') + $mail = $row->alias.'@'.DOMAIN; + else + $mail = $row->uid.'@'.DOMAIN; + echo ''; + echo ''; + echo "\n"; + } + echo '
',$p->t('global/titel'),'',$p->t('global/vorname'),'',$p->t('global/nachname'),'',$p->t('global/titel'),'',$p->t('global/studiengang'),'',$p->t('global/telefonnummer'),'',$p->t('global/mail'),'
',$row->titelpre,'',$row->vorname,'',$row->nachname,'',$row->titelpost,'',$row->studiengang,'',$row->telefonklappe,'',$mail,'
'; + } +} +function searchContent($searchItems) +{ + global $db,$p; + $cms = new content(); + $cms->search($searchItems); + + echo '

',$p->t('tools/content'),'

'; + echo ''; + +} +function findAndMark($content, $items) +{ + foreach($items as $row) + { + if($row!='') + { + $item = $row; + break; + } + } + //CDATA und HTML Tags entfernen + $content = mb_str_replace('<[CDATA[', '', $content); + $content = mb_str_replace(']]>', '', $content); + $content = strip_tags($content); + $item = mb_strtolower($item); + + $beginn = mb_strpos(mb_strtolower($content), $item); + $len = mb_strlen($item); + + //Im Content sind die Umlaute teilweise codiert gespeichert + //Wenn der Eintrag nicht gefunden wird, wird mit Codierten Zeichen nochmals gesucht + if($beginn=='') + { + $beginn = mb_strpos(mb_strtolower($content), htmlentities($item,ENT_NOQUOTES,'UTF-8')); + $len = mb_strlen(htmlentities($item,ENT_NOQUOTES,'UTF-8')); + } + + if($beginn=='') + { + $beginn=0; + $len=0; + } + $start = (($beginn-100)>0?($beginn-100):0); + //echo "start: $start
beginn: $beginn
beginn-start: ".($beginn-$start); + //echo "
item:".$item.'
'; + $preview=''; + if($start!=0) + $preview='...'; + + $preview .= mb_substr($content, $start, ($beginn-$start)); + $preview.=''; + $preview.= mb_substr($content, $beginn, $len); + $preview.=''; + $preview.= mb_substr($content, $beginn+$len, 300); + + $laenge = $beginn+$len+300; + if($laenge'; +?> \ No newline at end of file diff --git a/include/benutzer.class.php b/include/benutzer.class.php index d8be70f9b..527bafc13 100644 --- a/include/benutzer.class.php +++ b/include/benutzer.class.php @@ -28,6 +28,7 @@ class benutzer extends person public $bnaktiv=true; // boolean public $alias; // varchar(256) public $bn_ext_id; + public $result = array(); /** * Konstruktor - Uebergibt die Connection und laedt optional einen Benutzer @@ -257,5 +258,62 @@ class benutzer extends person return false; } } + + public function search($searchItems) + { + $qry = "SELECT * FROM (SELECT + distinct on (uid) vorname, nachname, uid, titelpre, titelpost,alias, + (SELECT UPPER(tbl_studiengang.typ || tbl_studiengang.kurzbz) + FROM public.tbl_student JOIN public.tbl_studiengang USING(studiengang_kz) + WHERE student_uid=tbl_benutzer.uid) as studiengang, + (SELECT tbl_kontakt.kontakt || ' - ' ||telefonklappe + FROM public.tbl_mitarbeiter + LEFT JOIN public.tbl_kontakt USING(standort_id) + WHERE + mitarbeiter_uid=tbl_benutzer.uid + AND (tbl_kontakt.kontakttyp='telefon' OR tbl_kontakt.kontakttyp is null) + ) as klappe + FROM + public.tbl_person + JOIN public.tbl_benutzer USING(person_id) + WHERE + tbl_benutzer.aktiv + AND ("; + + $qry.=" lower(vorname || ' ' || nachname) like lower('%".addslashes(implode(' ',$searchItems))."%')"; + $qry.=" OR lower(nachname || ' ' || vorname) like lower('%".addslashes(implode(' ',$searchItems))."%')"; + $qry.=" OR lower(uid) like lower('%".addslashes(implode(' ',$searchItems))."%')"; + + foreach($searchItems as $value) + { + $qry.=" OR lower(uid) = lower('".addslashes($value)."')"; + } + $qry.=")) a ORDER BY nachname, vorname"; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new benutzer(); + + $obj->titelpre = $row->titelpre; + $obj->vorname = $row->vorname; + $obj->nachname = $row->nachname; + $obj->titelpost = $row->titelpost; + $obj->uid = $row->uid; + $obj->studiengang = $row->studiengang; + $obj->telefonklappe = $row->klappe; + $obj->alias = $row->alias; + + $this->result[] = $obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } } ?> \ No newline at end of file diff --git a/include/content.class.php b/include/content.class.php index 5637f5104..72b99f512 100644 --- a/include/content.class.php +++ b/include/content.class.php @@ -1234,5 +1234,46 @@ class content extends basis_db } } + /** + * Durchsucht den Content + * + * @param array $searchItems + */ + public function search($searchItems) + { + $qry = "SELECT + distinct on(content_id) * + FROM + campus.tbl_contentsprache + JOIN campus.tbl_content USING(content_id) + WHERE + sichtbar=true + AND aktiv=true + AND template_kurzbz IN('contentmittitel','contentohnetitel','redirect')"; + foreach($searchItems as $value) + $qry.=" AND (lower(content::text) like lower('%".addslashes($value)."%') + OR lower(content::text) like lower('%".addslashes(htmlentities($value,ENT_NOQUOTES,'UTF-8'))."%'))"; + $qry.=" ORDER BY content_id DESC"; + + if($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new content(); + $obj->content_id = $row->content_id; + $obj->content = $row->content; + $obj->titel = $row->titel; + + $this->result[] = $obj; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + } ?> \ No newline at end of file diff --git a/locale/de-AT/tools.php b/locale/de-AT/tools.php index c78929395..f1915a729 100755 --- a/locale/de-AT/tools.php +++ b/locale/de-AT/tools.php @@ -50,4 +50,9 @@ $this->phrasen['tools/datei']='Datei '; $this->phrasen['tools/wurdeNichtGefunden']=' wurde nicht gefunden!'; $this->phrasen['tools/fehlerBeimLesenDerDatei']='Fehler beim Lesen der Datei '; $this->phrasen['tools/keineDatenGefunden']='Keine Daten gefunden'; + +//Suche +$this->phrasen['tools/suche']='Globale Suche'; +$this->phrasen['tools/content']='Content'; + ?> diff --git a/locale/en-US/tools.php b/locale/en-US/tools.php index 6572bb0af..4d7b92686 100755 --- a/locale/en-US/tools.php +++ b/locale/en-US/tools.php @@ -50,4 +50,9 @@ $this->phrasen['tools/datei']='File '; $this->phrasen['tools/wurdeNichtGefunden']=' was not found!'; $this->phrasen['tools/fehlerBeimLesenDerDatei']='Error reading file '; $this->phrasen['tools/keineDatenGefunden']='No data found'; + +//Suche +$this->phrasen['tools/suche']='Global Search'; +$this->phrasen['tools/content']='Content'; + ?> diff --git a/skin/images/search.png b/skin/images/search.png new file mode 100755 index 000000000..3bba3d228 Binary files /dev/null and b/skin/images/search.png differ diff --git a/skin/styles/tw.css b/skin/styles/tw.css index 6e96575db..535e8d899 100644 --- a/skin/styles/tw.css +++ b/skin/styles/tw.css @@ -691,3 +691,27 @@ option.inactive { background-color: lightgreen; } + +.suchmarker +{ + font-weight: bold; + text-decoration: underline; + font-size: medium; +} +.suchergebnis:hover +{ + background-color: #EEEEEE; +} +.suchergebnis a +{ + font-weight: bold; +} +.suchicon +{ + margin:0px; +} +.suchicon:hover +{ + cursor:pointer; + cursor:hand; +}