コード例 #1
0
ファイル: map.php プロジェクト: Lothurm/J3.x
 private function getMapItems()
 {
     // check for overriding options
     $this->checkOptions();
     // get info about database setting
     $maxInfo = $this->getMaxInfo();
     switch ($this->params['selection']) {
         case "person":
             $query = self::getQueryPerson();
             break;
         case "tree":
             // continue
         // continue
         case "location":
             // continue
         // continue
         default:
             $query = self::getQueryTree();
             break;
     }
     $this->_db->setQuery($query);
     $mapItems = $this->_db->loadObjectList();
     // prepare information for interactive map
     if ($this->params['service'] == 'interactivemap') {
         $menus = JoaktreeHelper::getMenus('joaktree');
         $linkBase = 'index.php?option=com_joaktree' . '&view=joaktree' . '&tech=' . JoaktreeHelper::getTechnology() . '&Itemid=' . $menus[$this->params['tree_id']];
         $robot = JoaktreeHelper::getTechnology() == 'a' ? '' : 'rel="noindex, nofollow"';
         for ($i = 0; $i < count($mapItems); $i++) {
             $indMore = strlen($mapItems[$i]->information) > $maxInfo;
             $tmps1 = explode('|', $mapItems[$i]->information);
             if ($indMore) {
                 // remove the last element
                 array_pop($tmps1);
             }
             $info = array();
             foreach ($tmps1 as $tmp1) {
                 $tmps2 = explode('#', $tmp1);
                 $name = count($tmps2) ? htmlspecialchars(array_shift($tmps2), ENT_QUOTES) : '....';
                 $id = count($tmps2) ? array_shift($tmps2) : null;
                 $event = count($tmps2) ? JText::_(array_shift($tmps2)) : '';
                 //$dateRaw = (count($tmps2)) ? array_shift($tmps2) : null);
                 $date = count($tmps2) ? '&nbsp;' . JoaktreeHelper::displayDate(array_shift($tmps2)) : '';
                 $def_tree = count($tmps2) ? array_shift($tmps2) : null;
                 if ($id && ($this->params['selection'] == 'tree' || $this->params['selection'] == 'location')) {
                     $href = JRoute::_($linkBase . '&treeId=' . $this->params['tree_id'] . '&personId=' . $this->params['app_id'] . '!' . $id);
                     $info[] = '<a href="' . $href . '" target="_top" ' . $robot . ' >' . $name . '</a>&nbsp;(' . $event . $date . ')';
                 } else {
                     if ($id && $this->params['selection'] == 'person' && $def_tree) {
                         $href = JRoute::_($linkBase . '&treeId=' . (int) $def_tree . '&personId=' . $this->params['app_id'] . '!' . $id);
                         $info[] = '<a href="' . $href . '" target="_top" ' . $robot . ' >' . $name . '</a>&nbsp;(' . $event . $date . ')';
                     } else {
                         $info[] = $name . '&nbsp;(' . $event . $date . ')';
                     }
                 }
             }
             if ($indMore) {
                 // add text
                 $info[] = JText::_('JT_ANDMORE');
             }
             $mapItems[$i]->information = implode('<br />', $info);
             unset($info);
         }
     }
     return $mapItems;
 }
コード例 #2
0
ファイル: _partnerevents.php プロジェクト: Lothurm/J3.x
             $html .= '&nbsp;</a>';
         }
     } else {
         $html .= '<span class="jt-empty-icon">&nbsp;</span>';
     }
     $html .= '</span>';
     // end of jt-iconlabel
     // show actual value
     $html .= '<span class="jt-high-row jt-valuelabel">';
     if ($event->value != null) {
         $html .= $event->value . '&nbsp;';
     }
     if ($event->value != null and ($event->eventDate != null or $event->location != null)) {
         $html .= '(&nbsp;';
     }
     $html .= JoaktreeHelper::displayDate($event->eventDate) . '&nbsp;';
     if ($event->location != null) {
         $html .= JText::_('JT_IN') . '&nbsp;' . $event->location . '&nbsp;';
     }
     if ($event->value != null and ($event->eventDate != null or $event->location != null)) {
         $html .= ')&nbsp;';
     }
     $html .= '</span>';
     // end of jt-valuelabel
 }
 $html .= '</div>';
 if ($event->indNote == true) {
     if ($this->lists['technology'] != 'b') {
         if ($this->lists['technology'] == 'j' or $event->indAltNote == true) {
             $html .= '<div id="' . $njtid2 . '" class="jt-hide" style="position: absolute; z-index: 50;">';
         } else {
コード例 #3
0
ファイル: person.php プロジェクト: Lothurm/J3.x
 private function getRelations($query, $type = 'basic')
 {
     $relations = array();
     $this->_db->setQuery($query);
     $relations_id = $this->_db->loadAssocList();
     // loop through result and fill tmp-array
     foreach ($relations_id as $i => $relation_id) {
         // retrieve person
         $id['app_id'] = $this->app_id;
         $id['person_id'] = $relation_id['pid'];
         $id['tree_id'] = $this->tree_id;
         //$tmp               	= new joaktreeperson($id);
         $tmp = new Person($id, $type);
         if (empty($relation_id['orderNr']) || $relation_id['secondParent_id'] != '0') {
             $key = $i;
         } else {
             $key = $relation_id['orderNr'];
         }
         // check whether this person can be displayed
         if ($tmp->indNameDisplay) {
             $relations[$key] = $tmp;
             $relations[$key]->orderNr = $relation_id['orderNr'];
             $relations[$key]->birthDate = JoaktreeHelper::displayDate($relation_id['birthDate']);
             $relations[$key]->deathDate = JoaktreeHelper::displayDate($relation_id['deathDate']);
             $relations[$key]->secondParent_id = $relation_id['secondParent_id'];
             $relations[$key]->family_id = $relation_id['family_id'];
             $relations[$key]->relationtype = !empty($relation_id['subtype']) && $relation_id['subtype'] != 'natural' ? $relation_id['subtype'] : null;
         }
     }
     return $relations;
 }
コード例 #4
0
ファイル: todaymanyyearsago.php プロジェクト: Lothurm/J3.x
 public function getList($moduleId)
 {
     $moduleId = (int) $moduleId;
     $params = $this->getModuleParams($moduleId);
     $periodType = $params->get('periodType');
     $limit = (int) $params->get('searchlimit', 10);
     $userAccessLevels = JoaktreeHelper::getUserAccessLevels();
     $personStatus = $params->get('personStatus', 0);
     $showTitle = $params->get('showHeading', 1);
     $today = getdate();
     if ($params->get('freeChoice')) {
         // only when user is allowed to enter a day/month we are checking these values.
         $day = JoaktreeHelper::getDay();
         $month = JoaktreeHelper::getMonth();
     }
     // for titles we want to know if we have day and/or months from the front end
     $indUI = !isset($day) && !isset($month) || $day == 0 && $month == 0 ? false : true;
     // if day and/or month is not set, we use today's info
     $day = !isset($day) || $day == 0 ? $today['mday'] : $day;
     $month = !isset($month) || $month == 0 ? $today['mon'] : $month;
     if ($showTitle == 1) {
         if (!$indUI) {
             // nothing from front end -> use standard titles
             switch ($periodType) {
                 case 2:
                     // continue
                 // continue
                 case 3:
                     $this->_title = JText::_('JTMOD_TMYA_HEADING_THISMONTH');
                     break;
                 case 4:
                     // continue
                 // continue
                 case 5:
                     $this->_title = JText::_('JTMOD_TMYA_HEADING_THISWEEK');
                     break;
                 case 0:
                     // continue
                 // continue
                 case 1:
                     // continue
                 // continue
                 default:
                     $this->_title = JText::_('JTMOD_TMYA_HEADING_TODAY');
                     break;
             }
         } else {
             // use information from front end
             switch ($periodType) {
                 case 2:
                     // continue
                 // continue
                 case 3:
                     $this->_title = JText::_($this->getMonthName($month));
                     break;
                 case 4:
                     // continue
                 // continue
                 case 5:
                     // continue
                 // continue
                 case 0:
                     // continue
                 // continue
                 case 1:
                     // continue
                 // continue
                 default:
                     $this->_title = $day . '&nbsp;' . JText::_($this->getMonthName($month));
                     break;
             }
         }
     } else {
         $this->_title = null;
     }
     switch ($periodType) {
         case 2:
             // continue
         // continue
         case 3:
             $this->_buttonText = JText::_('JTMOD_TMYA_HEADING_THISMONTH');
             break;
         case 4:
             // continue
         // continue
         case 5:
             $this->_buttonText = JText::_('JTMOD_TMYA_HEADING_THISWEEK');
             break;
         case 0:
             // continue
         // continue
         case 1:
             // continue
         // continue
         default:
             $this->_buttonText = JText::_('JTMOD_TMYA_HEADING_TODAY');
             break;
     }
     $result = array();
     $displayAccess = JoaktreeHelper::getDisplayAccess();
     $userAccess = JoaktreeHelper::getUserAccess();
     $where = $this->_buildContentWhere($day, $month, $today['year']);
     $order = $this->_buildOrderBy();
     // retrieve person events
     $query = '( SELECT  CONCAT_WS(' . $this->_db->quote(' ') . ' ' . '                   , jpn.firstName ' . '                   , jpn.namePreposition ' . '                   , jpn.familyName ' . '                   )               AS name ' . ',         jet.app_id               AS appId ' . ',         jet.person_id            AS personId ' . ',         jan.default_tree_id      AS treeId ' . ',			IF ( ( jet.code = ' . $this->_db->Quote('EVEN') . ' ) ' . '             , IFNULL( jet.type, jet.code ) ' . '             , jet.code ' . '             )                     AS code ' . ',         jet.eventdate ' . ',         DATE_FORMAT(STR_TO_DATE(eventdate, "%d %M %Y"), "%m%d") AS sortingdate ' . ',         SUBSTR( RTRIM(jet.eventdate), -4 ) AS eventyear ' . ',         jpn.familyName           AS familyName ' . 'FROM      #__joaktree_person_events     jet ' . 'JOIN      #__joaktree_persons           jpn ' . 'ON        (   jpn.app_id = jet.app_id ' . '          AND jpn.id     = jet.person_id ' . '          ) ' . 'JOIN      #__joaktree_admin_persons     jan ' . 'ON        (   jan.app_id    = jpn.app_id ' . '          AND jan.id        = jpn.id ' . '          AND jan.published = true ' . ($personStatus == 0 ? 'AND jan.living = false ' : ' ') . ($personStatus == 1 ? 'AND jan.living = true ' : ' ') . '          AND (  (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '              OR (jan.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees             jte ' . 'ON        (   jte.app_id    = jan.app_id ' . '          AND jte.id        = jan.default_tree_id ' . '          AND jte.published = true ' . '          AND jte.access    IN ' . $userAccessLevels . ' ' . '          ) ' . 'JOIN      #__joaktree_display_settings  jds ' . 'ON        (   jds.code = jet.code ' . '          AND jds.level = ' . $this->_db->quote('person') . ' ' . '          AND jds.published = true ' . '          AND (  (jan.living = false AND jds.access       IN ' . $userAccessLevels . ') ' . '              OR (jan.living = true  AND jds.accessLiving IN ' . $userAccessLevels . ') ' . '              ) ' . '          ) ' . $where . ' ) ' . 'UNION ' . '( SELECT  CONCAT_WS(' . $this->_db->quote(' + ') . ' ' . '                   , CONCAT_WS(' . $this->_db->quote(' ') . ' ' . '                              , jpn1.firstName ' . '                              , jpn1.namePreposition ' . '                              , jpn1.familyName ' . '                              ) ' . '                   , CONCAT_WS(' . $this->_db->quote(' ') . ' ' . '                              , jpn2.firstName ' . '                              , jpn2.namePreposition ' . '                              , jpn2.familyName ' . '                              ) ' . '                   )               AS name ' . ',         jet.app_id               AS appId ' . ',         jet.person_id_1          AS personId ' . ',         jan1.default_tree_id     AS treeId ' . ',			IF ( ( jet.code = ' . $this->_db->Quote('EVEN') . ' ) ' . '             , IFNULL( jet.type, jet.code ) ' . '             , jet.code ' . '             )                     AS code ' . ',         jet.eventdate ' . ',         DATE_FORMAT(STR_TO_DATE(eventdate, "%d %M %Y"), "%m%d") AS sortingdate ' . ',         SUBSTR( RTRIM(jet.eventdate), -4 ) AS eventyear ' . ',         jpn1.familyName          AS familyName ' . 'FROM      #__joaktree_relation_events   jet ' . 'JOIN      #__joaktree_persons           jpn1 ' . 'ON        (   jpn1.app_id = jet.app_id ' . '          AND jpn1.id     = jet.person_id_1 ' . '          ) ' . 'JOIN      #__joaktree_admin_persons     jan1 ' . 'ON        (   jan1.app_id    = jpn1.app_id ' . '          AND jan1.id        = jpn1.id ' . '          AND jan1.published = true ' . ($personStatus == 0 ? 'AND jan1.living = false ' : ' ') . ($personStatus == 1 ? 'AND jan1.living = true ' : ' ') . '          AND (  (jan1.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '              OR (jan1.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees             jte1 ' . 'ON        (   jte1.app_id    = jan1.app_id ' . '          AND jte1.id        = jan1.default_tree_id ' . '          AND jte1.published = true ' . '          AND jte1.access    IN ' . $userAccessLevels . ' ' . '          ) ' . 'JOIN      #__joaktree_persons           jpn2 ' . 'ON        (   jpn2.app_id = jet.app_id ' . '          AND jpn2.id     = jet.person_id_2 ' . '          ) ' . 'JOIN      #__joaktree_admin_persons     jan2 ' . 'ON        (   jan2.app_id    = jpn2.app_id ' . '          AND jan2.id        = jpn2.id ' . '          AND jan2.published = true ' . ($personStatus == 0 ? 'AND jan2.living = false ' : ' ') . ($personStatus == 1 ? 'AND jan2.living = true ' : ' ') . '          AND (  (jan2.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '              OR (jan2.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees             jte2 ' . 'ON        (   jte2.app_id    = jan2.app_id ' . '          AND jte2.id        = jan2.default_tree_id ' . '          AND jte2.published = true ' . '          AND jte2.access    IN ' . $userAccessLevels . ' ' . '          ) ' . 'JOIN      #__joaktree_display_settings  jds ' . 'ON        (   jds.code = jet.code ' . '          AND jds.level = ' . $this->_db->quote('relation') . ' ' . '          AND jds.published = true ' . '          AND (  (   jan1.living = false ' . '                 AND jan2.living = false ' . '                 AND jds.access  IN ' . $userAccessLevels . ' ' . '                 ) ' . '              OR (   (  jan1.living = true ' . '                     OR jan2.living = true ' . '                     ) ' . '                 AND jds.accessLiving IN ' . $userAccessLevels . ' ' . '                 ) ' . '              ) ' . '          ) ' . $where . ' ) ' . $order . ' ';
     $this->_db->setQuery($query, 0, $limit);
     $temp = $this->_db->loadObjectList();
     if (count($temp)) {
         // get menuId & technology
         $menus = JoaktreeHelper::getMenus('joaktree');
         $technology = JoaktreeHelper::getTechnology();
         $linkBase = 'index.php?option=com_joaktree&view=joaktree&tech=' . $technology . '';
         $robot = $technology == 'a' ? '' : 'rel="noindex, nofollow"';
         foreach ($temp as $row) {
             $menuItemId = $menus[$row->treeId];
             $row->route = JRoute::_($linkBase . '&Itemid=' . $menuItemId . '&treeId=' . $row->treeId . '&personId=' . $row->appId . '!' . $row->personId);
             $row->robot = $robot;
             $row->yearsago = $today['year'] - (int) $row->eventyear;
             $tmp = ucwords(strtolower($row->eventdate));
             $row->eventday = substr(JoaktreeHelper::convertDateTime($tmp), 0, -4);
             $row->eventdate = JoaktreeHelper::displayDate($row->eventdate);
             $row->code = JText::_($row->code);
             $result[] = $row;
         }
     }
     unset($temp);
     return $result;
 }
コード例 #5
0
ファイル: joaktree.php プロジェクト: Lothurm/J3.x
 function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db =& JFactory::getDBO();
     $linkBase = 'index.php?option=com_joaktree&view=joaktree';
     //If the array is not correct, return it:
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     //And define the parameters. For example like this..
     $limit = $this->params->def('search_limit', 50);
     if (is_array($areas)) {
         // check whether names are searched
         $names = in_array('joaktreeName', $areas) ? 1 : 0;
         $patronym = in_array('joaktreeName', $areas) ? $this->params->def('search_patronyms', 0) : 0;
         // check whether notes are searched
         $notes = in_array('joaktreeNote', $areas) ? $this->params->def('search_notes', 0) : 0;
     } else {
         $names = 1;
         $notes = $this->params->def('search_notes', 0);
         $patronym = $this->params->def('search_patronyms', 0);
     }
     $linkType = $this->params->def('link_option', 1);
     //Use the function trim to delete spaces in front of or at the back of the searching terms
     $text = trim($text);
     //Return Array when nothing was filled in
     if ($text == '') {
         return array();
     }
     //replace joaktree
     $searchJoaktree = JText::_('JTSRCH_GENEALOGY');
     $searchNotes = JText::_('JTSRCH_NOTES');
     // user access
     $userAccessLevels = JoaktreeHelper::getUserAccessLevels();
     $displayAccess = JoaktreeHelper::getDisplayAccess();
     //After this, you have to add the database part.
     $wheres = array();
     switch ($phrase) {
         //search exact
         case 'exact':
             $text = $db->Quote('%' . $db->escape($text, true) . '%', false);
             // search in names table
             $whereNames = array();
             $whereNames[] = 'LOWER(CONCAT_WS(' . $db->Quote(' ') . ',jpn.firstName,jpn.namePreposition,jpn.familyName)) LIKE ' . $text;
             $whereNames[] = 'LOWER(CONCAT_WS(' . $db->Quote(' ') . ',jpn.firstName,jpn.patronym,jpn.namePreposition,jpn.familyName)) LIKE ' . $text;
             $whereName = '(' . implode(') OR (', $whereNames) . ')';
             // search in person-notes table
             $wherePerNote = 'LOWER(jpe.value) LIKE ' . $text . ' OR LOWER(jne.value) LIKE ' . $text;
             // search in person-notes table
             $whereRelNote = 'LOWER(jre.value) LIKE ' . $text . ' OR LOWER(jne.value) LIKE ' . $text;
             break;
             //search all or any
         //search all or any
         case 'all':
         case 'any':
             //set default
         //set default
         default:
             $words = explode(' ', $text);
             $whereNames = array();
             $whereNotes = array();
             $wherePerNotes = array();
             $whereRelNotes = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . $db->escape($word, true) . '%', false);
                 if ($patronym == 1) {
                     $whereNames[] = 'LOWER(jpn.firstName) LIKE ' . $word . 'OR LOWER(jpn.patronym) LIKE ' . $word . 'OR LOWER(jpn.namePreposition) LIKE ' . $word . 'OR LOWER(jpn.familyName) LIKE ' . $word;
                 } else {
                     $whereNames[] = 'LOWER(jpn.firstName) LIKE ' . $word . 'OR LOWER(jpn.namePreposition) LIKE ' . $word . 'OR LOWER(jpn.familyName) LIKE ' . $word;
                 }
                 $wherePerNotes[] = 'LOWER(jpe.value) LIKE ' . $word . ' OR LOWER(jne.value) LIKE ' . $word;
                 $whereRelNotes[] = 'LOWER(jre.value) LIKE ' . $word . ' OR LOWER(jne.value) LIKE ' . $word;
             }
             $whereName = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $whereNames) . ')';
             $wherePerNote = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wherePerNotes) . ')';
             $whereRelNote = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $whereRelNotes) . ')';
             break;
     }
     //ordering of the results
     switch ($ordering) {
         //alphabetic, ascending
         case 'alpha':
             $order = 'jpn.familyName ASC, jpn.firstName ASC';
             break;
             //oldest first
         //oldest first
         case 'oldest':
             //popular first
         //popular first
         case 'popular':
             //newest first
         //newest first
         case 'newest':
             //default setting: alphabetic, ascending
         //default setting: alphabetic, ascending
         default:
             $order = 'jpn.familyName ASC, jpn.firstName ASC';
     }
     //the database query;
     $query = '';
     if ($names == 1 && $notes == 1) {
         $query .= '( ';
     }
     if ($names == 1) {
         $query .= 'SELECT   CONCAT_WS(' . $db->Quote(' ') . ' ' . '                   , jpn.firstName ' . ($patronym == 1 ? ', jpn.patronym ' : '') . '                   , jpn.namePreposition ' . '                   , jpn.familyName ' . '                   )                  AS title ' . ',         CONCAT_WS( " / " ' . '                   , ' . $db->Quote($searchJoaktree) . ' ' . '                   , jte.name ' . '                   )                  AS section ' . ',         jpn.lastUpdateTimeStamp    	AS created ' . ',         "' . $linkType . '"             AS browsernav ' . ',         jpn.app_id                  AS app_id ' . ',         jpn.id                      AS person_id ' . ',         jte.id                      AS tree_id ' . ',         IF ( (jan.living = true  AND ' . $displayAccess['BIRTperson']->living . '    = 1) ' . '             , ' . $db->Quote(JText::_('JTSRCH_ALTERNATIVE')) . ' ' . '             , birth.eventDate ' . '             )                        AS birthDate ' . ',         IF ( (jan.living = true  AND ' . $displayAccess['DEATperson']->living . '    = 1) ' . '             , ' . $db->Quote(JText::_('JTSRCH_ALTERNATIVE')) . ' ' . '             , death.eventDate ' . '             )                        AS deathDate ' . ',         NULL                        AS value ' . 'FROM      #__joaktree_persons         AS jpn ' . 'JOIN      #__joaktree_admin_persons   AS jan ' . 'ON        (   jan.app_id    = jpn.app_id ' . '          AND jan.id        = jpn.id ' . '          AND jan.published = true ' . '          AND (  (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . '              OR (jan.living = true  AND ' . $displayAccess['NAMEname']->living . '    = 2 ) ' . '              ) ' . '          ) ' . 'LEFT JOIN #__joaktree_trees           AS jte ' . 'ON        (   jte.app_id    = jan.app_id ' . '          AND jte.id        = jan.default_tree_id ' . '          AND jte.published = true ' . '          AND jte.access    IN ' . $userAccessLevels . '          ) ' . 'LEFT JOIN #__joaktree_person_events birth ' . 'ON        (   birth.app_id    = jpn.app_id ' . '          AND birth.person_id = jpn.id ' . '          AND birth.code      = ' . $db->Quote('BIRT') . ' ' . '          AND (  (jan.living = false AND ' . $displayAccess['BIRTperson']->notLiving . ' > 0 ) ' . '              OR (jan.living = true  AND ' . $displayAccess['BIRTperson']->living . '    > 0 ) ' . '              ) ' . '          ) ' . 'LEFT JOIN #__joaktree_person_events death ' . 'ON        (   death.app_id    = jpn.app_id ' . '          AND death.person_id = jpn.id ' . '          AND death.code      = ' . $db->Quote('DEAT') . ' ' . '          AND (  (jan.living = false AND ' . $displayAccess['DEATperson']->notLiving . ' > 0 ) ' . '              OR (jan.living = true  AND ' . $displayAccess['DEATperson']->living . '    > 0 ) ' . '              ) ' . '          ) ' . 'WHERE ( ' . $whereName . ' ) ' . ' ';
     }
     if ($names == 1 && $notes == 1) {
         $query .= ') UNION ( ';
     }
     if ($notes == 1) {
         // person notes
         $query .= 'SELECT   CONCAT_WS(' . $db->Quote(' ') . ' ' . '                   , jpn.firstName ' . ($patronym == 1 ? ', jpn.patronym ' : '') . '                   , jpn.namePreposition ' . '                   , jpn.familyName ' . '                   )                  AS title ' . ',         CONCAT_WS( " / " ' . '                   , ' . $db->Quote($searchJoaktree) . ' ' . '                   , jte.name ' . '                   , CONCAT_WS(' . $db->Quote(' ') . ' ' . '                              , jpn.firstName ' . ($patronym == 1 ? ', jpn.patronym ' : '') . '                              , jpn.namePreposition ' . '                              , jpn.familyName ' . '                              ) ' . '                   , ' . $db->Quote($searchNotes) . ' ' . '                   )                  AS section ' . ',         jpn.lastUpdateTimeStamp    	AS created ' . ',         "' . $linkType . '"             AS browsernav ' . ',         jpn.app_id                  AS app_id ' . ',         jpn.id                      AS person_id ' . ',         jte.id                      AS tree_id ' . ',         NULL                        AS birthDate ' . ',         NULL                        AS deathDate ' . ',         IF( jne.value IS NOT NULL ' . '            , jne.value ' . '            , jpe.value ' . '            )                         AS value ' . 'FROM      #__joaktree_person_notes    AS jpe ' . 'JOIN      #__joaktree_persons         AS jpn ' . 'ON        (   jpn.app_id = jpe.app_id ' . '          AND jpn.id     = jpe.person_id ' . '          ) ' . 'JOIN      #__joaktree_admin_persons   AS jan ' . 'ON        (   jan.app_id    = jpn.app_id ' . '          AND jan.id        = jpn.id ' . '          AND jan.published = true ' . '          AND (  (   jan.living = false ' . '                 AND ' . $displayAccess['NAMEname']->notLiving . '   = 2 ' . '                 AND ' . $displayAccess['NOTEperson']->notLiving . ' = 2 ' . '                 ) ' . '              OR (   jan.living = true  ' . '                 AND ' . $displayAccess['NAMEname']->living . '      = 2 ' . '                 AND ' . $displayAccess['NOTEperson']->living . '    = 2 ' . '                 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees           AS jte ' . 'ON        (   jte.app_id    = jan.app_id ' . '          AND jte.id        = jan.default_tree_id ' . '          AND jte.published = true ' . '          AND jte.access    IN ' . $userAccessLevels . '          ) ' . 'LEFT JOIN #__joaktree_notes           AS jne ' . 'ON        (   jne.app_id = jpe.app_id ' . '          AND jne.id     = jpe.note_id ' . '          ) ' . 'WHERE ( ' . $wherePerNote . ' ) ';
     }
     // Order by name
     if ($names == 1 && $notes == 1) {
         $query .= ') ';
     }
     $query .= 'ORDER BY title ';
     //. $order;
     //Set query
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $menuJoaktree = JoaktreeHelper::getMenus('joaktree');
     $menu =& JSite::getMenu();
     $menuActive =& $menu->getActive();
     $menuActId = isset($menuActive) ? $menuActive->id : null;
     foreach ($rows as $key => $row) {
         $tmp = '';
         //The 'output' of the displayed link
         if (!empty($rows[$key]->tree_id)) {
             $rows[$key]->href = JRoute::_($linkBase . '&Itemid=' . $menuJoaktree[$rows[$key]->tree_id] . '&treeId=' . $rows[$key]->tree_id . '&personId=' . $rows[$key]->app_id . '!' . $rows[$key]->person_id);
         } else {
             // look for first child
             $query = 'SELECT    jrn.app_id                  AS app_id ' . ',         jrn.person_id_1             AS person_id ' . ',         jte.id                      AS tree_id ' . ',         jrn.type                    AS relation ' . 'FROM      #__joaktree_relations       AS jrn ' . 'JOIN      #__joaktree_admin_persons   AS jan ' . 'ON        (   jan.app_id    = jrn.app_id ' . '          AND jan.id        = jrn.person_id_1 ' . '          AND jan.published = true ' . '          AND (  (   jan.living = false ' . '                 AND ' . $displayAccess['NAMEname']->notLiving . '   = 2 ' . '                 ) ' . '              OR (   jan.living = true  ' . '                 AND ' . $displayAccess['NAMEname']->living . '      = 2 ' . '                 ) ' . '              ) ' . '          ) ' . 'JOIN      #__joaktree_trees           AS jte ' . 'ON        (   jte.app_id    = jan.app_id ' . '          AND jte.id = jan.default_tree_id ' . '          AND jte.published = true ' . '          AND jte.access  IN ' . $userAccessLevels . '          ) ' . 'WHERE     jrn.app_id        = ' . $rows[$key]->app_id . ' ' . 'AND       jrn.person_id_2   = ' . $db->Quote($rows[$key]->person_id) . ' ' . 'AND       jrn.orderNumber_2 = 1 ';
             //Set query
             $db->setQuery($query);
             $child = $db->loadObject();
             if ($child) {
                 $rows[$key]->href = JRoute::_($linkBase . '&Itemid=' . (!empty($child->tree_id) ? $menuJoaktree[$child->tree_id] : $menuActId) . '&treeId=' . (!empty($child->tree_id) ? $child->tree_id : '') . '&personId=' . $child->app_id . '!' . $child->person_id);
             } else {
                 // situation that the child is still living ...
                 $rows[$key]->href = '#';
             }
         }
         if (!empty($rows[$key]->birthDate)) {
             $tmp .= JText::_('JTSRCH_BORN') . ':&nbsp;';
             $tmp .= JoaktreeHelper::displayDate($rows[$key]->birthDate) . ';&nbsp;';
         }
         if (!empty($rows[$key]->deathDate)) {
             $tmp .= JText::_('JTSRCH_DIED') . ':&nbsp;';
             $tmp .= JoaktreeHelper::displayDate($rows[$key]->deathDate) . ';&nbsp;';
         }
         if (!empty($rows[$key]->value)) {
             $tmp .= $rows[$key]->value;
         }
         $rows[$key]->text = $tmp;
     }
     return $rows;
 }