public function getLocationIndex() { $app = JFactory::getApplication('site'); $index = $app->getUserState('joaktree.locations.index'); if (!$index) { $index = array(); // retrieve the index information from the database $query = $this->_db->getQuery(true); $query->select(' DISTINCT indexLoc '); $query->from(' #__joaktree_locations '); $query->order(' indexLoc '); $this->_db->setQuery($query); $results = $this->_db->loadRowList(); $params = JoaktreeHelper::getJTParams(); $groupCountLoc = (int) $params->get('groupCountLoc', '3'); $i = 0; $n = 0; foreach ($results as $result) { $n++; $index[$i][$n] = array_shift($result); if ($n == $groupCountLoc || $groupCountLoc == 0) { $i++; $n = 0; } } $app->setUserState('joaktree.locations.index', $index); } return $index; }
function display($tpl = null) { $params = JoaktreeHelper::getJTParams(); // Access $lists['userAccess'] = $this->get('access'); $lists['treeId'] = $this->get('treeId'); $lists['technology'] = $this->get('technology'); // Person + generations $personId = array(); $this->person = $this->get('person'); $personId[] = $this->person->id . '|1'; $lists['ancestorLevel'] = $params->get('ancestorlevel', 1); $lists['startGenNum'] = 1; $lists['endGenNum'] = $lists['ancestorLevel'] + 4; $lists['app_id'] = $this->person->app_id; // show dates $lists['showDates'] = $params->get('ancestordates', 0); // last update $lists['lastUpdate'] = JText::_('JT_LASTUPDATED') . ': ' . JoaktreeHelper::convertDateTime($this->person->lastUpdateDate); // copyright $lists['CR'] = JoaktreeHelper::getJoaktreeCR(); $this->assignRef('personId', $personId); $this->assignRef('lists', $lists); parent::display($tpl); }
public function store() { $params = JoaktreeHelper::getJTParams($this->app_id); $indLogging = $params->get('indLogging'); if ($indLogging) { // Logging is switched on $ret = parent::store(); } else { // Logging is switched off $ret = true; } return $ret; }
/** * Display the view */ public function display($tpl = null) { // First load the treeId! $this->lists['treeId'] = $this->get('treeId'); // Load the parameters. $this->params = JoaktreeHelper::getJTParams(true); if ($this->params->get('siteedit', 1)) { $this->canDo = JoaktreeHelper::getActions(); } else { $this->canDo = null; } // set up style sheets and javascript files JHTML::stylesheet(JoaktreeHelper::joaktreecss()); JHTML::stylesheet(JoaktreeHelper::joaktreecss($this->params->get('theme'))); $document =& JFactory::getDocument(); $document->addScript(JoaktreeHelper::joaktreejs('toggle.js')); $this->lists['lineEnd'] = $document->_getLineEnd(); // Initialiase variables. $this->form = $this->get('Form'); $this->lists['appId'] = $this->get('applicationId'); $this->lists['appName'] = $this->get('applicationName'); $relationId = $this->get('relationId'); if (isset($relationId)) { $this->relation = $this->get('relation'); $this->lists['action'] = $this->get('action'); } $this->lists['action'] = isset($this->lists['action']) ? $this->lists['action'] : 'new'; $this->picture = $this->get('picture'); $personId = $this->get('personId'); if (isset($personId)) { $this->lists['userAccess'] = $this->get('access'); $this->item = $this->get('Item'); $this->lists['indLiving'] = $this->item->living; } else { $this->lists['userAccess'] = true; $this->lists['indLiving'] = false; } $patronym = $this->params->get('patronym', 0); $this->lists['indPatronym'] = $patronym == 0 ? false : true; $familyname = $this->params->get('familyname', 0); $this->lists['indNamePreposition'] = $familyname == 1 ? true : false; $this->lists['CR'] = JoaktreeHelper::getJoaktreeCR(); if ($this->lists['userAccess']) { // set title if (isset($personId)) { $title = $this->item->firstName . ' ' . $this->item->familyName; $document->setTitle($title); } } parent::display($tpl); }
function display($tpl = null) { $params = JoaktreeHelper::getJTParams(); $document =& JFactory::getDocument(); // set up style sheets and javascript files JHTML::stylesheet(JoaktreeHelper::joaktreecss()); JHTML::stylesheet(JoaktreeHelper::joaktreecss($params->get('theme'))); // Access $lists['userAccess'] = $this->get('access'); $lists['treeId'] = $this->get('treeId'); $lists['technology'] = $this->get('technology'); // Person + generations $personId = array(); $this->person = $this->get('person'); $personId[] = $this->person->id . '|1'; $lists['ancestorLevel'] = $params->get('ancestorlevel', 1); $lists['startGenNum'] = 1; $lists['endGenNum'] = $lists['ancestorLevel'] + 4; $lists['app_id'] = $this->person->app_id; // show dates $lists['showDates'] = $params->get('ancestordates', 0); // last update $lists['lastUpdate'] = JoaktreeHelper::lastUpdateDateTimePerson($this->person->lastUpdateDate); // copyright $lists['CR'] = JoaktreeHelper::getJoaktreeCR(); $this->assignRef('personId', $personId); $this->assignRef('lists', $lists); if ($lists['userAccess']) { // set title, meta title $document->setTitle($this->person->fullName); $document->setMetadata('title', $this->person->fullName); // set additional meta tags if ($params->get('menu-meta_description')) { $document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $params->get('menu-meta_keywords')); } // robots if ($this->person->robots > 0) { $document->setMetadata('robots', JoaktreeHelper::stringRobots($this->person->robots)); } else { if ($params->get('robots')) { $document->setMetadata('robots', $params->get('robots')); } } } parent::display($tpl); }
public function setCookie() { static $indOneTime; if (isset($indOneTime) && $indOneTime) { return true; } // set up cookie $params = JoaktreeHelper::getJTParams(); $indCookie = $params->get('indCookies', true); if ($indCookie) { // we fetch the cookie $cookie = new JInputCookie(); $tmp = $cookie->get('jt_last_persons', '', 'string'); // prepare the array if ($tmp) { $personList = (array) json_decode(base64_decode($tmp)); } else { $personList = array(); } // check whether this person is already in array $person =& $this->getPerson(); $value = $person->app_id . '!' . $person->id . '!' . $person->tree_id; if (in_array($value, $personList)) { // loop through array and move person to first position $newList = array(); $newList[] = $value; foreach ($personList as $item) { if ($item != $value) { $newList[] = $item; } } } else { // place the first person to start of array $newList = $personList; array_unshift($newList, $value); } // if the array is too big, remove the last person if (count($newList) > 10) { array_pop($newList); } // and store the new cookie //$expire = mktime().time()+60*60*24*180; $expire = time() + 60 * 60 * 24 * 180; $cookie->set('jt_last_persons', base64_encode(json_encode($newList)), $expire, '/'); } $indOneTime = true; return true; }
public function log($crud, $changeDateTimeOverride = null) { if (!$this->check()) { return false; } $params = JoaktreeHelper::getJTParams($this->app_id); $indLogging = $params->get('indLogging'); if ($indLogging) { // Logging is switched on switch ($crud) { case "C": $this->logevent = 'JT_C_' . strtoupper($this->object); break; case "R": $this->logevent = 'JT_R_' . strtoupper($this->object); break; case "U": $this->logevent = 'JT_U_' . strtoupper($this->object); break; case "D": $this->logevent = 'JT_D_' . strtoupper($this->object); break; case "L": // Time of gedcom load $this->logevent = 'JT_L_' . strtoupper($this->object); break; case "I": // Date/time is imported from GedCom file $this->logevent = 'JT_I_' . strtoupper($this->object); break; default: $this->logevent = 'JT_A_' . strtoupper($this->object); break; } if (empty($changeDateTimeOverride)) { // If no timestamp value is passed to functon, than current time is used. $currentdate = JFactory::getDate(); $this->changeDateTime = $currentdate->Format('Y-m-d H:i:s', false, false); } else { $this->changeDateTime = $changeDateTimeOverride; } $ret = $this->store(); } else { // Logging is switched off $ret = true; } return $ret; }
public function getAccess() { static $_access; if (!isset($_access)) { $params = JoaktreeHelper::getJTParams(); $ancestorEnabled = $params->get('ancestorchart', 0); if ($ancestorEnabled != 1) { // chart is not enabled $_access = false; } else { // chart is enabled $_access = JoaktreeHelper::getAccess(); } } return $_access; }
function display($tpl = null) { $params = JoaktreeHelper::getJTParams(); // Access $lists['userAccess'] = $this->get('access'); $lists['treeId'] = $this->get('treeId'); $lists['technology'] = $this->get('technology'); // Person + generations $personId = array(); $this->person = $this->get('person'); $personId[] = $this->person->id . '|1'; $lists['startGenNum'] = 1; $lists['endGenNum'] = (int) $params->get('descendantlevel', 20); $lists['app_id'] = $this->person->app_id; $this->assignRef('personId', $personId); $this->assignRef('lists', $lists); parent::display($tpl); }
function display($tpl = null) { $this->lists = array(); // Load the parameters. $this->params = JoaktreeHelper::getJTParams(); // Get data from the model $this->treeinfo = $this->get('treeinfo'); $menus = $this->get('menus'); // Id's and settings $this->lists['tree_id'] = $this->get('treeId'); $this->lists['userAccess'] = $this->get('access'); $this->lists['menuItemId'] = $menus[$this->lists['tree_id']]; //namelist $this->lists['columns'] = (int) $this->params->get('columns', '3'); $this->namelist = $this->get('namelist'); $this->lists['numberRows'] = (int) ceil(count($this->namelist) / $this->lists['columns']); $this->lists['link'] = 'index.php?option=com_joaktree' . '&view=joaktreelist' . '&Itemid=' . $this->lists['menuItemId'] . '&treeId=' . $this->lists['tree_id']; parent::display($tpl); }
function display($tpl = null) { $this->lists = array(); // Load the parameters. $this->params = JoaktreeHelper::getJTParams(); // Get data from the model $this->treeinfo = $this->get('treeinfo'); $menus = $this->get('menus'); // Id's and settings $this->lists['tree_id'] = $this->get('treeId'); $this->lists['userAccess'] = $this->get('access'); $this->lists['menuItemId'] = $menus[$this->lists['tree_id']]; $this->lists['interactiveMap'] = $this->get('interactiveMap'); //location list $this->lists['columns'] = (int) $this->params->get('columnsLoc', '3'); $this->locationlist = $this->get('locationlist'); $this->lists['numberRows'] = (int) ceil(count($this->locationlist) / $this->lists['columns']); $this->lists['linkMap'] = 'index.php?option=com_joaktree' . '&view=interactivemap' . '&tmpl=component' . '&format=raw' . '&treeId=' . $this->lists['tree_id']; $this->lists['linkList'] = 'index.php?option=com_joaktree' . '&view=joaktreelist' . '&tmpl=component' . '&layout=location' . '&treeId=' . $this->lists['tree_id']; parent::display($tpl); }
function display($tpl = null) { $this->lists = array(); // Load the parameters. $this->params = JoaktreeHelper::getJTParams(); $document =& JFactory::getDocument(); $app = JFactory::getApplication('site'); // Get data from the model $this->treeinfo = $this->get('treeinfo'); $menus = $this->get('menus'); // set up style sheets and javascript files JHTML::stylesheet(JoaktreeHelper::joaktreecss()); JHTML::stylesheet(JoaktreeHelper::joaktreecss($this->params->get('theme'))); // add script $this->lists['interactiveMap'] = $this->get('interactiveMap'); $this->lists['indFilter'] = $this->get('locationFilter'); $this->lists['tree_id'] = $this->get('treeId'); $this->lists['script'] = $this->addScript(); // get text $this->articles = Tree::getArticles($this->lists['tree_id']); // Id's and settings $this->lists['userAccess'] = $this->get('access'); $this->lists['menuItemId'] = $menus[$this->lists['tree_id']]; $this->lists['indMap'] = false; $tmp = $this->get('mapUrl'); if ($tmp) { $this->lists['indMap'] = true; $this->lists['map'] = explode("|", $tmp); } // distance options if ($this->lists['interactiveMap']) { $distance = $app->getUserStateFromRequest('com_joaktree.map.distance', 'distance', 0, 'int'); $this->lists['distance'] = $this->getDistanceSelect($distance); } //location list $this->lists['index'] = $this->get('locationIndex'); $this->lists['columns'] = (int) $this->params->get('columnsLoc', '3'); $this->locationlist = $this->get('locationlist'); $this->lists['numberRows'] = (int) ceil(count($this->locationlist) / $this->lists['columns']); $this->lists['linkMap'] = 'index.php?option=com_joaktree' . '&view=interactivemap' . '&tmpl=component' . '&format=raw' . '&treeId=' . $this->lists['tree_id']; $this->lists['linkList'] = 'index.php?option=com_joaktree' . '&view=joaktreelist' . '&tmpl=component' . '&layout=location' . '&treeId=' . $this->lists['tree_id']; // last update $this->lists['lastUpdate'] = $this->get('lastUpdate'); // copyright $this->lists['CR'] = JoaktreeHelper::getJoaktreeCR(); if ($this->lists['userAccess']) { // set title, meta title if ($this->params->get('treeName')) { $title = $this->params->get('treeName'); $document->setTitle($title); $document->setMetadata('title', $title); } // set additional meta tags if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } // robots if ($this->params->get('treeRobots') > 0) { $document->setMetadata('robots', JoaktreeHelper::stringRobots($this->params->get('treeRobots'))); } else { if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } } } parent::display($tpl); }
private function admin_page_person() { static $age_no_page; if (!isset($age_no_page)) { $params = JoaktreeHelper::getJTParams($this->app_id); $age_no_page = (int) $params->get('age_no_page', 0); } $show_page = true; if (isset($this->birthYear) and isset($this->deathYear) and isset($age_no_page)) { $age = $this->deathYear - $this->birthYear; if ($age >= 0 and $age < $age_no_page) { $show_page = false; } else { $show_page = true; } } else { $show_page = true; } return $show_page; }
public function process($part) { // initialize parameters and paths / filename $params = JoaktreeHelper::getJTParams($this->procObject->id); $conversion_type = $params->get('unicode2utf'); $path = JPATH_ROOT . DS . $params->get('gedcomfile_path'); $filename = $path . DS . $params->get('gedcomfile_name'); $patronymSetting = (int) $params->get('patronym'); $truncate_rel_value = (int) $params->get('truncrelations'); // $procStep = (int) $params->get('processStep', 1); $procStepSize = (int) $params->get('procStepSize', 50); $ret = true; // $indAjax = ($procStep == 1); $indAjax = true; // check if gedcom file exists if (!JFile::exists($filename)) { $this->procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_NOGEDCOM', $filename); $this->procObject->status = 'error'; return $this->procObject; } // initialize array $objectLine = array(); $this->objectLines = array(); // What type of conversion if ($conversion_type == 0) { // no conversion $conversion = false; } else { if ($conversion_type == 1) { // conversion from ANSEL to UTF-8 $conversion = true; $this->unicode2utf = true; } else { if ($conversion_type == 2) { // conversion from ANSEL to Unicode $conversion = true; $this->unicode2utf = false; } else { // parameter has unknown value: no conversion $conversion = false; } } } // remove double and trailing characters, like comma's if ($params->get('removeChar')) { $removeChar = $params->get('removeChar'); } else { $removeChar = false; } // initialize counters $teller0 = 0; // counter for gedcom objects $tellert = 0; // counter for total number of lines in file // Loop through the array looking for header info. $ansel = false; $char_done = false; $vers_done = false; // open file $handle = @fopen($filename, "r"); if ($handle && $this->procObject->status == 'new') { // loop through the lines while (!feof($handle)) { $line = fgets($handle, 4096); $line = trim($line); // we are ready if ($char_done and $vers_done) { break; } // remove end-of-line characters $line = rtrim($line, "\r\n"); // split line into three parts with space as deviding character $elements = explode(" ", $line, 3); if (!isset($elements[0])) { $elements[0] = null; } else { $elements[0] = trim($elements[0]); } if (!isset($elements[1])) { $elements[1] = null; } else { $elements[1] = trim($elements[1]); } if (!isset($elements[2])) { $elements[2] = null; } else { $elements[2] = trim($elements[2]); } // first part of line is the level; $level = $elements[0]; // process only the header: so is this the header if ($level == 0) { if ($elements[1] == 'HEAD') { $ind_header = true; } else { $ind_header = false; } } // process only the header if ($ind_header == true) { // see whether we have to transer ANSEL to UTF-8 // other character sets are left alone. if ($elements[1] == 'CHAR') { $char_done = true; if ($elements[2] == 'ANSEL') { $ansel = true; } } // check the version of GEDCOM: is this the GEDCOM and not SOURCE? if ($elements[1] == 'GEDC') { $ind_get_vers = true; } else { $ind_get_vers = false; } // check version of GEDCOM if ($elements[1] == 'VERS' and $ind_get_vers) { $vers_done = true; $version = substr($elements[2], 0, 3); if ($version != '5.5' and $version != '5.5.1') { $this->procObject->msg .= '<br />' . JText::_('JTGEDCOM_MESSAGE_NOV55'); $this->procObject->status = 'error'; return $this->procObject; } } } // end of if ind_header == true } // end of loop } // if charcter set is ANSEL if ($conversion == true and $ansel == true) { $result = $this->prepareANSEL(); if ($result) { $this->procObject->msg .= $result; } } $this->objectType = 'START'; switch ($part) { case "person": $filterTag = 'INDI'; break; case "family": $filterTag = 'FAM'; // remove relations if ($truncate_rel_value == 1 && $this->procObject->status == 'new') { $relation_notes =& JMFPKTable::getInstance('joaktree_relation_notes', 'Table'); $retdelete = $relation_notes->truncateApp($this->procObject->id); $relation_events =& JMFPKTable::getInstance('joaktree_relation_events', 'Table'); $retdelete = $relation_events->truncateApp($this->procObject->id); $relations =& JMFPKTable::getInstance('joaktree_relations', 'Table'); $retdelete = $relations->truncateApp($this->procObject->id); $relation_citations =& JMFPKTable::getInstance('joaktree_citations', 'Table'); $retdelete = $relation_citations->truncateRelationCitations($this->procObject->id); } break; case "source": $filterTag = 'SOUR'; break; case "repository": $filterTag = 'REPO'; break; case "note": $filterTag = 'NOTE'; break; case "document": $filterTag = 'OBJE'; break; case "all": // same as default // same as default default: $filterTag = null; // remove relations if ($truncate_rel_value == 1 && $this->procObject->status == 'new') { $relation_notes =& JMFPKTable::getInstance('joaktree_relation_notes', 'Table'); $retdelete = $relation_notes->truncateApp($this->procObject->id); $relation_events =& JMFPKTable::getInstance('joaktree_relation_events', 'Table'); $retdelete = $relation_events->truncateApp($this->procObject->id); $relations =& JMFPKTable::getInstance('joaktree_relations', 'Table'); $retdelete = $relations->truncateApp($this->procObject->id); $relation_citations =& JMFPKTable::getInstance('joaktree_citations', 'Table'); $retdelete = $relation_citations->truncateRelationCitations($this->procObject->id); } break; } $indProcess = false; if (!$indAjax) { // we will not be looping back to the caller // instead we will go one time through the whole GedCom file // so status is set now to 'progress' $this->procObject->status = 'progress'; } // Loop through the array. if ($handle && ($this->procObject->status == 'progress' || $this->procObject->status == 'new')) { // move to the beginning fseek($handle, $this->procObject->cursor); // loop through the lines while (!feof($handle)) { $line = fgets($handle); $line = trim($line); $tellert++; // remove end-of-line characters $line = rtrim($line, "\r\n"); // if ANSEL convert the line if ($conversion == true and $ansel == true) { $line = $this->convertANSEL($line); } // remove double or trailing characters if ($removeChar) { $remove = true; while ($remove) { $line = str_replace($removeChar . $removeChar, $removeChar, $line, $countReplace); if ($countReplace == 0) { $remove = false; } } $line = trim($line, $removeChar); } // split line into three parts with space as deviding character $elements = explode(" ", $line, 3); if (!isset($elements[0])) { $elements[0] = null; } else { $elements[0] = trim($elements[0]); } if (!isset($elements[1])) { $elements[1] = null; } else { $elements[1] = trim($elements[1]); } if (!isset($elements[2])) { $elements[2] = null; } else { $elements[2] = trim($elements[2]); } // first part of line is the level; $level = $elements[0]; // the level 0 lines are the main lines (=gedcom objects) // these lines are stored in object table // when level is greater than 0, it is a depending line and // stored in object-line table if ($level == 0) { // level = 0: we dealing with the object // first process the previous object (if existing) if ($indProcess) { $this->process_object(); if ($indAjax && $teller0 == $procStepSize) { $this->procObject->cursor = $fileCursor; $this->procObject->status = 'progress'; fclose($handle); return $this->procObject; } } // set boolean to check the first objectline $indFirstLine = true; if ($elements[2] == null) { // third element is empty for level 0 line // tag is in the second element // there is no value. this will be filled with value from counter object_value_id $this->objectType = $elements[1]; $this->objectKey = null; } else { // third element is not empty. this countains the tag // second element contains the value // value has to be stripped from @ characters // However third element may also contain a value ... it is weird but true $subelems = explode(" ", $elements[2], 2); if (!isset($subelems[0])) { $subelems[0] = null; } else { $subelems[0] = trim($subelems[0]); } if (!isset($subelems[1])) { $subelems[1] = null; } else { $subelems[1] = trim($subelems[1]); } if ($subelems[1] == null) { // everything is ok and normal $this->objectType = $elements[2]; $this->objectKey = ltrim(rtrim($elements[1], '@'), '@'); } else { // extra value found in the line!! $this->objectType = $subelems[0]; $this->objectKey = ltrim(rtrim($elements[1], '@'), '@'); // this is really a new tag. $objectLine['object_id'] = $this->objectKey; $objectLine['level'] = 1; $objectLine['tag'] = "TEXT"; $objectLine['value'] = $subelems[1]; // keep the object line $this->objectLines[] = $objectLine; $indFirstLine = false; } } $teller0++; if ($filterTag) { if ($filterTag == $this->objectType) { $indProcess = true; } else { $indProcess = false; } } else { $indProcess = true; } } else { if ($indProcess) { // level <> 0: we dealing with object lines // element 2 contains the tag; element 3 contains the value $tag = $elements[1]; $value = $elements[2]; // replace special characters in value // & (= ampersand) $value = str_replace("&", "&", $value); // < (= less than sign) $value = str_replace("<", "<", $value); // > (= greater than sign) $value = str_replace(">", ">", $value); // ' (= single quote) //$value = str_replace("'", "'", $value); //$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); // Deal with the first line if it is not a real tag if ($indFirstLine) { // Aldfaer uses for notes as first line CONC. // This should be text, and here we fix it. if ($tag == 'CONC' or $tag == 'CONT') { $tag = 'TEXT'; } $indFirstLine = false; } if ($tag == 'CONC' or $tag == 'CONT') { // this line is a continutation of the previouse line $objectLine = array_pop($this->objectLines); if ($tag == 'CONC') { $objectLine['value'] = $objectLine['value'] . $value; } else { if ($tag == 'CONT') { $objectLine['value'] = $objectLine['value'] . ' ' . $value; } } // keep the object line $this->objectLines[] = $objectLine; } else { // this is really a new tag. $objectLine['object_id'] = $this->objectKey; $objectLine['level'] = $level; $objectLine['tag'] = $tag; $objectLine['value'] = $value; // keep the object line $this->objectLines[] = $objectLine; } } } // end of check on level = 0 $fileCursor = ftell($handle); } // end of loop through array } if ($handle) { fclose($handle); } // if the number of objects is smaller than the step size // status never reached 'progress'. It is still 'new'. if ($indAjax && $this->procObject->status == 'new' && $teller0 < $procStepSize) { $this->procObject->cursor = $fileCursor; $this->procObject->status = 'progress'; return $this->procObject; } $this->procObject->cursor = isset($fileCursor) ? $fileCursor : 0; if ($this->procObject->status == 'progress') { // status is progress: this means our last action was reading the file // we are done with that for now - time for a new status $this->procObject->status = 'endload'; if ($indAjax) { // we are looping back to the caller return $this->procObject; } } if ($patronymSetting != 0 && $patronymSetting != 1 && $this->procObject->status == 'endload') { // we are not setting the patronyms - just update the status to the next $this->procObject->status = 'endpat'; if ($indAjax) { // we are looping back to the caller return $this->procObject; } } // if setting is NOT to retrieve patronyms from name string, patronyms have to determined now if (($patronymSetting == 0 || $patronymSetting == 1) && $this->procObject->status == 'endload') { $ret = jt_names::setPatronyms($this->procObject->id); if (!$ret) { // if no result - an error occured and we stop $this->procObject->status = 'error'; $this->procObject->msg .= JText::_('JTGEDCOM_MESSAGE_NOSUCPATRONYMS'); return $this->procObject; } else { // we are done - so change the status $this->procObject->status = 'endpat'; if ($indAjax) { // we are looping back to the caller $this->procObject->msg .= JText::_('JTGEDCOM_MESSAGE_SUCPATRONYMS'); return $this->procObject; } } } // Set the indicators for different types of relationships after processing all persons if ($this->procObject->status == 'endpat') { $ret = jt_relations::setRelationIndicators($this->procObject->id); // if no result - an error occured and we stop if (!$ret) { $this->procObject->status = 'error'; $this->procObject->msg .= JText::_('JTGEDCOM_MESSAGE_NOSUCRELINDICATORS'); return $this->procObject; } else { $this->procObject->status = 'endrel'; if ($indAjax) { // we are looping back to the caller $this->procObject->msg .= JText::_('JTGEDCOM_MESSAGE_SUCRELINDICATORS'); return $this->procObject; } } } return $this->procObject; }
function display($tpl = null) { // Load the parameters. $app = JFactory::getApplication('site'); $params = JoaktreeHelper::getJTParams(); $document =& JFactory::getDocument(); // Find the value for tech $technology = $this->get('technology'); // set up style sheets and javascript files JHTML::stylesheet(JoaktreeHelper::joaktreecss()); JHTML::stylesheet(JoaktreeHelper::joaktreecss($params->get('theme'))); // get user info $userId = $this->get('userId'); if (!$userId || $userId == 0) { $document->addScript(JoaktreeHelper::joaktreejs('jtform.js')); } // Get data from the model $personlist = $this->get('personlist'); $pagination =& $this->get('Pagination'); $tree_id = $this->get('treeId'); $patronymSetting = $this->get('patronymSetting'); $userAccess = $this->get('access'); $menus1 =& $this->get('menusJoaktree'); $menus2 =& $this->get('menusJoaktreelist'); // Id's and settings $lists['tree_id'] = $tree_id; $lists['relationId'] = $this->get('relationId'); $lists['menuItemId'] = $menus1[$tree_id]; $lists['menuItemId2'] = $menus2[$tree_id]; $lists['patronym'] = $patronymSetting; $lists['userAccess'] = $userAccess; $lists['technology'] = $technology; $lists['action'] = JoaktreeHelper::getAction(); //Filter $context = 'com_joaktree.joaktreelist.list.'; $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'jpn.familyName', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); $search1 = $app->getUserStateFromRequest($context . 'search1', 'search1', '', 'string'); $search1 = JString::strtolower($search1); $search2 = $app->getUserStateFromRequest($context . 'search2', 'search2', '', 'string'); $search2 = JString::strtolower($search2); $search3 = $app->getUserStateFromRequest($context . 'search3', 'search3', '', 'string'); $search3 = JString::strtolower($search3); $search4 = $app->getUserStateFromRequest($context . 'search4', 'search4', '', 'string'); $search4 = base64_decode($search4); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['searchWidth'] = (int) $params->get('search_width', '120'); $lists['search1'] = $search1; $lists['search2'] = $search2; $lists['search3'] = $search3; $lists['search4'] = $search4; // last update $lists['lastUpdate'] = $this->get('lastUpdate'); // copyright $lists['CR'] = JoaktreeHelper::getJoaktreeCR(); $this->assignRef('pagination', $pagination); $this->assignRef('personlist', $personlist); $this->assignRef('lists', $lists); if (($lists['action'] == 'save' || $lists['action'] == 'saveparent1') && count($personlist) == 0) { JFactory::getDocument()->addScriptDeclaration('window.parent.jtSavePerson();'); } else { if ($lists['userAccess']) { // set title, meta title if ($params->get('treeName')) { $title = $params->get('treeName'); $document->setTitle($title); $document->setMetadata('title', $title); } // set additional meta tags if ($params->get('menu-meta_description')) { $document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $params->get('menu-meta_keywords')); } // robots if ($params->get('treeRobots') > 0) { $document->setMetadata('robots', JoaktreeHelper::stringRobots($params->get('treeRobots'))); } else { if ($params->get('robots')) { $document->setMetadata('robots', $params->get('robots')); } } } parent::display($tpl); } }
public function getStaticMap() { if ($this->map == 1) { $items = array(); // find locations in person events $events = $this->getPersonEvents(); foreach ((array) $events as $event) { if (isset($event->longitude) && !empty($event->longitude) && isset($event->latitude) && !empty($event->latitude)) { $tmp = new JObject(); $tmp->longitude = $event->longitude; $tmp->latitude = $event->latitude; $tmp->label = JText::_($event->code); array_push($items, $tmp); unset($tmp); } } if (count($items)) { // get parameters $params = JoaktreeHelper::getJTParams(); $options = array(); $options['width'] = (int) $params->get('pxMapWidth', 700); $options['height'] = (int) $params->get('pxHeight', 225); $options['color'] = $params->get('statMarkerColor'); $service = MBJServiceStaticmap::getInstance(); $map = $service->_('fetch', $items, $options); return $map; } else { return false; } } else { return false; } }
public function getGedcom() { $canDo = JoaktreeHelper::getActions(); $localMsg = ''; if ($canDo->get('core.create') && $canDo->get('core.edit')) { $cids = JFactory::getApplication()->input->get('cid', null, 'array'); if (count($cids) == 0) { // no applications are selected $return = JText::_('JTGEDCOM_MESSAGE_NOAPPLICATIONS'); } else { foreach ($cids as $cid_num => $app_id) { $procObject = new processObject(); $current = strftime('%H:%M:%S'); $procObject->msg = JText::_('JTPROCESS_START') . ':' . $current; $procObject->id = (int) $app_id; $procObject->msg .= '<br />' . JText::sprintf('JTPROCESS_START_MSG', $procObject->id); $params = JoaktreeHelper::getJTParams($procObject->id); $processStep = (int) $params->get('processStep', 9); // as of version 1.2: new method if ($processStep == 4) { $gedcomfile = new jt_gedcomfile2($procObject); $procObject = $gedcomfile->process('person'); } if ($processStep == 5) { $gedcomfile = new jt_gedcomfile2($procObject); $procObject = $gedcomfile->process('family'); $ret = jt_gedcomfile2::clear_gedcom(); if ($ret) { $procObject->msg .= '<br />' . $ret; } } if ($processStep == 6) { $gedcomfile = new jt_gedcomfile2($procObject); $procObject = $gedcomfile->process('source'); } if ($processStep == 7) { $gedcomfile = new jt_gedcomfile2($procObject); $procObject = $gedcomfile->process('repository'); $procObject = $gedcomfile->process('note'); $procObject = $gedcomfile->process('document'); } if ($processStep == 9) { $gedcomfile = new jt_gedcomfile2($procObject); $procObject = $gedcomfile->process('all'); $ret = jt_gedcomfile2::clear_gedcom(); if ($ret) { $procObject->msg .= '<br />' . $ret; } } if ($procObject->status != 'error') { $this->setInitialChar(); $this->setLastUpdateDateTime(); if ($procObject->persons > 0) { $procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_PERSONS', $procObject->persons); } if ($procObject->families > 0) { $procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_FAMILIES', $procObject->families); } if ($procObject->sources > 0) { $procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_SOURCES', $procObject->sources); } if ($procObject->repos > 0) { $procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_REPOS', $procObject->repos); } if ($procObject->notes > 0) { $procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_NOTES', $procObject->notes); } if ($procObject->unknown > 0) { $procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_UNKNOWN', $procObject->unknown); } $procObject->msg .= '<br />' . JText::sprintf('JTPROCESS_END_MSG', $procObject->id); } else { $return = $procObject->msg; } $current = strftime('%H:%M:%S'); $procObject->msg .= '<br />' . JText::_('JTPROCESS_END') . ':' . $current; $localMsg .= $procObject->msg; } $return = $localMsg; } } else { $return = JText::_('JT_NOTAUTHORISED'); } return $return; }
public function getPatronymSetting() { static $_patronymSetting; if (!isset($_patronymSetting)) { $params = JoaktreeHelper::getJTParams(); $_patronymSetting = (int) $params->get('patronym'); } return $_patronymSetting; }
public function getButtons($counter, $but = array('save' => true, 'cancel' => true, 'check' => false, 'done' => false, 'add' => false), $indParent1 = false) { $html = array(); if ($counter == 1) { $html[] = '<div class="jt-buttonbar" style="margin-left: 10px;">'; } else { $html[] = '<div class="jt-buttonbar" style="margin-left: 10px; margin-top: 10px;">'; } if ($but['save'] && !$but['check']) { $html[] = ' <a href="#" '; $html[] = ' id="save' . $counter . '"'; $html[] = ' class="jt-button-closed jt-buttonlabel"'; $html[] = ' title="' . JText::_('JSAVE') . '" '; $html[] = ' onclick="jtsubmitbutton(\'save\');"'; $html[] = ' >'; $html[] = JText::_('JSAVE'); $html[] = ' </a>'; $html[] = ' '; } if ($but['save'] && $but['check']) { $html[] = ' <a href="#" '; $html[] = ' id="save' . $counter . '"'; $html[] = ' class="modal_check jt-button-closed jt-buttonlabel" '; $html[] = ' title="' . JText::_('JSAVE') . '" '; $html[] = ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}" '; $html[] = ' >'; $html[] = JText::_('JSAVE'); $html[] = ' </a>'; $html[] = ' '; } if ($but['done']) { $html[] = ' <a href="#" '; $html[] = ' id="done' . $counter . '"'; $html[] = ' class="jt-button-closed jt-buttonlabel" '; $html[] = ' title="' . JText::_('JT_DONE') . '" '; $html[] = ' onclick="jtsubmitbutton(\'cancel\');"'; $html[] = ' >'; $html[] = JText::_('JT_DONE'); $html[] = ' </a>'; $html[] = ' '; } if ($but['add']) { $html[] = ' <a href="#" '; $html[] = ' id="add' . $counter . '"'; $html[] = ' class="jt-button-closed jt-buttonlabel" '; $html[] = ' title="' . JText::_('JTADD_DESC') . '" '; $html[] = ' onclick="document.getElementById(\'mediaForm\').object.value=\'media\'; jtsubmitbutton(\'edit\');"'; $html[] = ' >'; $html[] = JText::_('JTADD'); $html[] = ' </a>'; $html[] = ' '; } if ($but['cancel']) { $html[] = ' <a href="#" '; $html[] = ' id="cancel' . $counter . '"'; $html[] = ' class="jt-button-closed jt-buttonlabel" '; $html[] = ' title="' . JText::_('JCANCEL') . '" '; $html[] = ' onclick="jtsubmitbutton(\'cancel\');"'; $html[] = ' >'; $html[] = JText::_('JCANCEL'); $html[] = ' </a>'; $html[] = ' '; } if ($but['check'] && $counter == 1) { $params = JoaktreeHelper::getJTParams(true); $patronym = $params->get('patronym', 0); $router = JSite::getRouter(); $link1 = 'index.php?option=com_joaktree' . '&view=joaktreelist' . '&layout=check' . '&tmpl=component' . '&treeId=' . JoaktreeHelper::getTreeId() . '&action=select'; $link2 = 'index.php?option=com_joaktree' . '&view=joaktreelist' . '&layout=check' . '&tmpl=component' . '&treeId=' . JoaktreeHelper::getTreeId() . '&action=' . ($indParent1 ? 'saveparent1' : 'save'); // $relId = JoaktreeHelper::getRelationId(); // if ($relId) { // $link1 .= '&relationId='.$relId; // $link2 .= '&relationId='.$relId; // } // Build the script. $script = array(); $script[] = 'function setCheckValue() {'; $script[] = ' var link1 = "' . JRoute::_($link1) . '";'; $script[] = ' var link2 = "' . JRoute::_($link2) . '";'; $script[] = ' var link = "";'; $script[] = ' var search1 = document.getElementById("jform_person_firstName").value;'; if ($patronym) { $script[] = ' var search2 = document.getElementById("jform_person_patronym").value;'; } $script[] = ' var search3 = document.getElementById("jform_person_rawFamilyName").value;'; if ($patronym) { $script[] = ' if ((search1 == "") && (search2 == "") && (search3 == "")) {'; $script[] = ' link1 = "#"; link2 = "#";'; $script[] = ' } else {'; if ($router->getMode() == JROUTER_MODE_SEF) { $script[] = ' if (search1 != "") { link = link + "/f-" + search1; } '; $script[] = ' if (search2 != "") { link = link + "/s-" + search2; } '; $script[] = ' if (search3 != "") { link = link + "/n-" + search3; } '; } else { $script[] = ' if (search1 != "") { link = link + "&search1=" + search1; } '; $script[] = ' if (search2 != "") { link = link + "&search2=" + search2; } '; $script[] = ' if (search3 != "") { link = link + "&search3=" + search3; } '; } $script[] = ' }'; } else { // no search2 (= patronym) $script[] = ' if ((search1 == "") && (search3 == "")) {'; $script[] = ' link1 = "#"; link2 = "#";'; $script[] = ' } else {'; if ($router->getMode() == JROUTER_MODE_SEF) { $script[] = ' if (search1 != "") { link = link + "/f-" + search1; } '; $script[] = ' if (search3 != "") { link = link + "/n-" + search3; } '; } else { $script[] = ' if (search1 != "") { link = link + "&search1=" + search1; } '; $script[] = ' if (search3 != "") { link = link + "&search3=" + search3; } '; } $script[] = ' }'; } $script[] = ' document.getElementById("check1").setProperty("href", link1 + link);'; $script[] = ' document.getElementById("save1").setProperty("href", link2 + link);'; $script[] = ' document.getElementById("save2").setProperty("href", link2 + link);'; $script[] = '}'; $script[] = 'function jtNewPerson() {'; $script[] = ' SqueezeBox.close();'; $script[] = ' document.getElementById("newstatus").value="checked";'; $script[] = ' var el1 = document.getElementById("save1");'; $script[] = ' el1.setProperty("href", "' . Jroute::_('index.php?option=com_joaktree&view=close') . '");'; $script[] = ' el1.removeProperty("rel");'; $script[] = ' el1.setProperty("onclick", "jtsubmitbutton(\'save\');");'; $script[] = ' var el2 = document.getElementById("save2");'; $script[] = ' el2.setProperty("href", "' . Jroute::_('index.php?option=com_joaktree&view=close') . '");'; $script[] = ' el2.removeProperty("rel");'; $script[] = ' el2.setProperty("onclick", "jtsubmitbutton(\'save\');");'; $script[] = '}'; if ($indParent1) { $script[] = 'function jtSelectPerson(appId, personId, relationId, familyId) {'; $script[] = ' SqueezeBox.close();'; $script[] = ' var fam = new Element("option", {value: relationId + "!" + familyId}); '; $script[] = ' fam.inject(document.getElementById("jform_person_relations_family"));'; $script[] = ' document.getElementById("jform_person_relations_family").value = relationId + "!" + familyId;'; $script[] = ' document.getElementById("jform_person_id").value = personId;'; $script[] = ' document.getElementById("jform_person_status").value = "relation";'; $script[] = ' jtsubmitbutton("select");'; $script[] = '}'; } else { $script[] = 'function jtSelectPerson(appId, personId) {'; $script[] = ' SqueezeBox.close();'; $script[] = ' document.getElementById("jform_person_id").value = personId;'; $script[] = ' document.getElementById("jform_person_status").value = "relation";'; $script[] = ' jtsubmitbutton("select");'; $script[] = '}'; } $script[] = 'function jtSavePerson() {'; $script[] = ' SqueezeBox.close();'; $script[] = ' jtsubmitbutton("save");'; $script[] = '}'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Load the modal behavior script. $html[] = JHtml::_('behavior.modal', 'a.modal_check'); $html[] = '<input type="hidden" id="newstatus" value="unchecked" />'; $html[] = '<span id="cp_label" class="jt-edit-2">'; $html[] = ' <a href="#" '; $html[] = ' id="check' . $counter . '"'; $html[] = ' class="modal_check jt-button-closed jt-buttonlabel" '; $html[] = ' title="' . JText::_('JT_CHECK') . '" '; $html[] = ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}" '; $html[] = ' >'; $html[] = JText::_('JT_CHECK'); $html[] = ' </a>'; $html[] = '</span>'; $html[] = ' '; } $html[] = '</div>'; $html[] = '<div class="clearfix"></div>'; return implode("\n", $html); }
function display($tpl = null) { // Load the parameters. $model = $this->getModel(); $this->params = JoaktreeHelper::getJTParams(); $document =& JFactory::getDocument(); if ($this->params->get('siteedit', 1)) { $canDo = JoaktreeHelper::getActions(); } else { $canDo = null; } // Find the value for tech $technology = $this->get('technology'); // set up style sheets and javascript files JHTML::stylesheet(JoaktreeHelper::joaktreecss()); JHTML::stylesheet(JoaktreeHelper::joaktreecss($this->params->get('theme'))); // Set up shadowbox JHTML::stylesheet(JoaktreeHelper::shadowboxcss()); $document->addScript(JoaktreeHelper::shadowboxjs()); // Set up modal behavior JHtml::_('behavior.modal', 'a.modal'); if ($technology != 'b') { // javascript template - no ajax // default template includes ajax JHTML::stylesheet(JoaktreeHelper::briaskcss()); $document->addScript(JoaktreeHelper::joaktreejs('mod_briaskISS.js')); $document->addScript(JoaktreeHelper::joaktreejs('toggle.js')); } if ($technology != 'b' and $technology != 'j') { // default template includes ajax $document->addScript(JoaktreeHelper::joaktreejs('jtajax.js')); } // Access $lists['userAccess'] = $this->get('access'); $lists['technology'] = $technology; $edit = $this->get('action'); $lists['edit'] = $edit == 'edit' ? true : false; // Person $this->person = $this->get('person'); $model->setCookie(); $Html['lineage'] = $this->showLineage(); $lists['showAncestors'] = (int) $this->params->get('ancestorchart', 0); $lists['showDescendants'] = (int) $this->params->get('descendantchart', 0); $lists['numberArticles'] = $this->person->getArticleCount(); // Pictures $Html['pictures'] = $this->showPictures(); $lists['nextDelay'] = round((int) $this->params->get('nextDelay', 0) / 1000, 3); $lists['transDelay'] = round((int) $this->params->get('transDelay', 0) / 1000, 3); // Static map if ($this->person->map == 1) { $Html['staticmap'] = $this->person->getStaticMap(); $lists['indStaticMap'] = $Html['staticmap'] ? true : false; } // Interactive map if ($this->person->map == 2) { $Html['interactivemap'] = $this->person->getInteractiveMap(); $lists['indInteractiveMap'] = $Html['interactivemap'] ? true : false; $lists['pxHeightMap'] = (int) $this->params->get('pxHeight', 0); } // last update $lists['showUpdate '] = $this->params->get('show_update'); if ($lists['showUpdate '] != 'N') { $lists['lastUpdate'] = JoaktreeHelper::lastUpdateDateTimePerson($this->person->lastUpdateDate); $lists['showchange'] = (int) $this->params->get('indLogging', 0); } // copyright $lists['CR'] = JoaktreeHelper::getJoaktreeCR(); //return $retObject = new stdClass(); $retObject->object = 'prsn'; $retObject->app_id = $this->person->app_id; $retObject->object_id = $this->person->id; $lists['retId'] = base64_encode(json_encode($retObject)); // tab behavior if ((int) $this->params->get('indTabBehavior') == 1) { $lists['action'] = 'onClick'; } else { $lists['action'] = 'onMouseOver'; } $this->assignRef('Html', $Html); $this->assignRef('canDo', $canDo); $this->assignRef('lists', $lists); if ($lists['userAccess']) { // set title, meta title $title = $this->person->firstName . ' ' . $this->person->familyName; $document->setTitle($title); $document->setMetadata('title', $title); // set additional meta tags if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } // robots if ($this->person->robots > 0) { $document->setMetadata('robots', JoaktreeHelper::stringRobots($this->person->robots)); } else { if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } } } parent::display($tpl); }
function display($tpl = null) { $this->lists = array(); // Load the parameters. $this->params = JoaktreeHelper::getJTParams(); $document =& JFactory::getDocument(); $app = JFactory::getApplication('site'); // Get data from the model $this->treeinfo = $this->get('treeinfo'); $menus = $this->get('menus'); // set up style sheets and javascript files JHTML::stylesheet(JoaktreeHelper::joaktreecss()); JHTML::stylesheet(JoaktreeHelper::joaktreecss($this->params->get('theme'))); // add script $this->lists['indFilter'] = $this->get('nameFilter'); $this->lists['tree_id'] = $this->get('treeId'); $this->lists['script'] = $this->addScript(); // get text $this->articles = Tree::getArticles($this->lists['tree_id']); // Id's and settings $this->lists['userAccess'] = $this->get('access'); $this->lists['menuItemId'] = $menus[$this->lists['tree_id']]; if ($this->treeinfo->indPersonCount) { $this->lists['personCount'] = $this->get('personCount'); } if ($this->treeinfo->indMarriageCount) { $this->lists['marriageCount'] = $this->get('marriageCount'); } //namelist $this->lists['index'] = $this->get('nameIndex'); $this->lists['columns'] = (int) $this->params->get('columns', '3'); $this->namelist = $this->get('namelist'); $this->lists['numberRows'] = (int) ceil(count($this->namelist) / $this->lists['columns']); $this->lists['link'] = 'index.php?option=com_joaktree' . '&view=joaktreelist' . '&Itemid=' . $this->lists['menuItemId'] . '&treeId=' . $this->lists['tree_id']; // last update $this->lists['lastUpdate'] = $this->get('lastUpdate'); // copyright $this->lists['CR'] = JoaktreeHelper::getJoaktreeCR(); $this->assignRef('treeinfo', $this->treeinfo); $this->assignRef('html', $html); $this->assignRef('lists', $this->lists); if ($this->lists['userAccess']) { // set title, meta title if ($this->params->get('treeName')) { $title = $this->params->get('treeName'); $document->setTitle($title); $document->setMetadata('title', $title); } // set additional meta tags if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } // robots if ($this->params->get('treeRobots') > 0) { $document->setMetadata('robots', JoaktreeHelper::stringRobots($this->params->get('treeRobots'))); } else { if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } } } parent::display($tpl); }
public function process() { // initialize parameters and paths / filename $params = JoaktreeHelper::getJTParams($this->procObject->id); $path = JPATH_ROOT . DS . $params->get('gedcomfile_path'); $filename = $path . DS . 'export_' . $params->get('gedcomfile_name'); $patronymSetting = (int) $params->get('patronym'); $patronymString = $params->get('patronymSeparation', '-'); $procStepSize = (int) $params->get('procStepSize', 50); $ret = true; // check if family_id are filled correctly if ($this->procObject->status == 'new' && $this->checkFamily_id()) { $this->procObject->msg .= '<br />' . $this->fixFamily_id(); return $this->procObject; } // check if gedcom file exists, when status is new if (JFile::exists($filename) && $this->procObject->status == 'new') { $this->procObject->msg .= '<br />' . JText::sprintf('JTGEDCOM_MESSAGE_GEDCOM', $filename); $this->procObject->status = 'end'; return $this->procObject; } // initialize array $objectLine = array(); $this->objectLines = array(); // initialize counters $teller0 = 0; // counter for gedcom objects $tellert = 0; // counter for total number of lines in file $this->objectType = 'START'; // open file $handle = @fopen($filename, "a"); // Loop through the array. if ($handle) { if ($this->procObject->status == 'new') { $date = JFactory::getDate(); fwrite($handle, $this->jt("0 HEAD\r\n")); fwrite($handle, $this->jt("1 SOUR JOAKTREE\r\n")); fwrite($handle, $this->jt("2 VERS " . JoaktreeHelper::getJoaktreeVersion() . "\r\n")); fwrite($handle, $this->jt("1 DEST JOAKTREE\r\n")); fwrite($handle, $this->jt("1 DATE " . $date->format('d M Y') . "\r\n")); fwrite($handle, $this->jt("1 CHAR UTF-8\r\n")); fwrite($handle, $this->jt("1 FILE " . $filename . "\r\n")); fwrite($handle, $this->jt("1 GEDC\r\n")); fwrite($handle, $this->jt("2 VERS 5.5\r\n")); fwrite($handle, $this->jt("2 FORM LINEAGE-LINKED\r\n")); $this->procObject->status = 'person'; } if ($this->procObject->status == 'person') { $offset = $this->procObject->persons; $persons = $this->getPersons($offset, $procStepSize); if (count($persons) == 0) { $this->procObject->status = 'family'; return $this->procObject; } foreach ($persons as $person) { $this->procObject->persons++; fwrite($handle, $this->jt("0 @" . $person['id'] . "@ INDI\r\n")); // names - main name + subnames if ($patronymSetting == 9 && !empty($person['patronym'])) { // add patronym to name field using patronymString-separation $firstName = $person['firstName'] . ' ' . $patronymString . $person['patronym'] . $patronymString; } else { $firstName = $person['firstName']; } fwrite($handle, $this->jt("1 NAME " . $firstName . " /" . $person['familyName'] . "/\r\n")); $this->getNames($handle, 2, $person['id']); if ($patronymSetting == 2) { // add patronym to _PATR field fwrite($handle, $this->jt("2 _PATR " . $person['patronym'] . "\r\n")); } if (!empty($person['prefix'])) { fwrite($handle, $this->jt("2 NPFX " . $person['prefix'] . "\r\n")); } if (!empty($person['suffix'])) { fwrite($handle, $this->jt("2 NSFX " . $person['suffix'] . "\r\n")); } // sex fwrite($handle, $this->jt("1 SEX " . $person['sex'] . "\r\n")); // last change $this->getPersonLog($handle, 1, $person['id']); // person events $this->getPersonEvents($handle, 1, $person['id']); // person notes if ($person['indNote']) { $this->getPersonNotes($handle, 1, $person['id']); } // person documents $this->getDocuments($handle, 1, $person['id']); // person citations if ($person['indCitation']) { $this->getCites($handle, 1, $person['id'], 'EMPTY', 0, $type = 'person'); } // person as adult (partner, parent) in family if ($person['indHasPartner'] || $person['indHasChild']) { $this->getPersonFamilies($handle, 1, $person['id'], $type = 'adult'); } // person as child in family if ($person['indHasParent']) { $this->getPersonFamilies($handle, 1, $person['id'], $type = 'child'); } } // end loop through persons // done with persons return $this->procObject; } if ($this->procObject->status == 'family') { $offset = $this->procObject->families; $families = $this->getFamilies($offset, $procStepSize); if (count($families) == 0) { $this->procObject->status = 'note'; return $this->procObject; } foreach ($families as $family) { $this->procObject->families++; fwrite($handle, $this->jt("0 @" . $family['family_id'] . "@ FAM\r\n")); // partners $partnerSets = $this->getFamilyPartners($family['family_id']); if (is_array($partnerSets)) { foreach ($partnerSets as $partnerSet) { if ($partnerSet['sex1'] == 'M' && $partnerSet['sex2'] == 'F') { fwrite($handle, $this->jt("1 HUSB @" . $partnerSet['person_id_1'] . "@\r\n")); fwrite($handle, $this->jt("1 WIFE @" . $partnerSet['person_id_2'] . "@\r\n")); } else { if ($partnerSet['sex1'] == 'F' && $partnerSet['sex2'] == 'M') { fwrite($handle, $this->jt("1 HUSB @" . $partnerSet['person_id_2'] . "@\r\n")); fwrite($handle, $this->jt("1 WIFE @" . $partnerSet['person_id_1'] . "@\r\n")); } else { $tag1 = $partnerSet['sex1'] == 'F' ? 'WIFE' : 'HUSB'; $tag2 = $partnerSet['sex2'] == 'F' ? 'WIFE' : 'HUSB'; if ($partnerSet['person_id_1'] < $partnerSet['person_id_2']) { fwrite($handle, $this->jt("1 " . $tag1 . " @" . $partnerSet['person_id_1'] . "@\r\n")); fwrite($handle, $this->jt("1 " . $tag2 . " @" . $partnerSet['person_id_2'] . "@\r\n")); } else { fwrite($handle, $this->jt("1 " . $tag2 . " @" . $partnerSet['person_id_2'] . "@\r\n")); fwrite($handle, $this->jt("1 " . $tag1 . " @" . $partnerSet['person_id_1'] . "@\r\n")); } } } } } else { // single parent family $singleParents = $this->getSingleParent($family['family_id']); if (is_array($singleParents)) { foreach ($singleParents as $singleParent) { $tag = $singleParent['type'] == 'mother' ? 'WIFE' : 'HUSB'; fwrite($handle, $this->jt("1 " . $tag . " @" . $singleParent['person_id'] . "@\r\n")); } } } // children $this->getFamilyChildren($handle, 1, $family['family_id']); // person events if (is_array($partnerSets)) { foreach ($partnerSets as $partnerSet) { $this->getRelationEvents($handle, 1, $partnerSet['person_id_1'], $partnerSet['person_id_2']); } } } // done with families return $this->procObject; } if ($this->procObject->status == 'note') { $offset = $this->procObject->notes; $notes = $this->getNotes($offset, $procStepSize); if (count($notes) == 0) { $this->procObject->status = 'source'; return $this->procObject; } foreach ($notes as $note) { $this->procObject->notes++; fwrite($handle, $this->jt("0 @" . $note['id'] . "@ NOTE\r\n")); if (!empty($note['value'])) { $this->exportLongText($handle, 'TEXT', 1, $note['value']); } } // done with notes return $this->procObject; } if ($this->procObject->status == 'source') { $offset = $this->procObject->sources; $sources = $this->getSources($offset, $procStepSize); if (count($sources) == 0) { $this->procObject->status = 'repo'; return $this->procObject; } foreach ($sources as $source) { $this->procObject->sources++; fwrite($handle, $this->jt("0 @" . $source['id'] . "@ SOUR\r\n")); if (!empty($source['author'])) { $this->exportLongText($handle, 'AUTH', 1, $source['author']); } if (!empty($source['title'])) { $this->exportLongText($handle, 'TITL', 1, $source['title']); } if (!empty($source['publication'])) { $this->exportLongText($handle, 'PUBL', 1, $source['publication']); } if (!empty($source['information'])) { $this->exportLongText($handle, 'TEXT', 1, $source['information']); } if (!empty($source['repo_id'])) { fwrite($handle, $this->jt("1 REPO @" . $source['repo_id'] . "@\r\n")); } } // done with sources return $this->procObject; } if ($this->procObject->status == 'repo') { $offset = $this->procObject->repos; $repos = $this->getRepos($offset, $procStepSize); if (count($repos) == 0) { $this->procObject->status = 'close'; return $this->procObject; } foreach ($repos as $repo) { $this->procObject->repos++; fwrite($handle, $this->jt("0 @" . $repo['id'] . "@ REPO\r\n")); if (!empty($repo['name'])) { fwrite($handle, $this->jt("1 NAME " . $repo['name'] . "\r\n")); } if (!empty($repo['website'])) { fwrite($handle, $this->jt("1 WWW " . $repo['website'] . "\r\n")); } } // done with repos return $this->procObject; } if ($this->procObject->status == 'close') { fwrite($handle, $this->jt("0 TRLR\r\n")); $this->procObject->status = 'stop'; } } if ($handle) { fclose($handle); } return $this->procObject; }
private function assignFT() { $procPersObject = $this->getProcPersonObject(); $resPersObject = new procPersonObject(); $resPersObject->id = $procPersObject->id; $resPersObject->tree_ids = $procPersObject->tree_ids; $app_id = $procPersObject->id; $params = JoaktreeHelper::getJTParams($app_id); $query = $this->_db->getQuery(true); switch ($this->procObject->status) { case 'start': // continue // continue case 'starttree': // continue // continue case 'progtree': // only for startree and progtree are we executing the first part $finished = false; // Initialize table $tree_persons =& JTable::getInstance('joaktree_tree_persons', 'Table'); if ($this->procObject->status == 'start') { // initial steps $query->clear(); $query->delete(' #__joaktree_tree_persons '); $query->where(' app_id = ' . $app_id . ' '); $query->where(' tree_id IN ( ' . implode(',', $procPersObject->tree_ids) . ' ) '); $this->_db->setQuery($query); $msg = $this->_db->query(); // empty the default tree attribute for all persons in the system $query->clear(); $query->update(' #__joaktree_admin_persons '); $query->set(' default_tree_id = null '); $query->where(' app_id = ' . $app_id . ' '); $query->where(' default_tree_id IN ( ' . implode(',', $procPersObject->tree_ids) . ' ) '); $this->_db->setQuery($query); $msg = $this->_db->query(); $this->procObject->status = 'starttree'; } // select parameters of the tree $tree_id = array_shift($procPersObject->tree_ids); $query->clear(); $query->select(' * '); $query->from(' #__joaktree_trees '); $query->where(' app_id = ' . $app_id . ' '); $query->where(' id = ' . $tree_id . ' '); $this->_db->setQuery($query); $tree = $this->_db->loadObject(); $this->procObject->msg = $this->procObject->status == 'starttree' ? 'Assigning persons to tree: ' . $tree->name : null; if ($tree->holds == 'descendants' and isset($tree->root_person_id) && $tree->root_person_id != null) { // Initialize arrays for processing $now = array(); $next = array(); if ($this->procObject->status == 'starttree') { // First person we start with is the root-person of the tree // For logic this person is always male (even if she is not) $personObject = new personObject(); $personObject->i = $tree->root_person_id; $personObject->s = 'M'; // Therefore the type of this first person (root-person) is R $personObject->t = 'R'; // lineage is filled with the first person. $personObject->l = $tree->root_person_id; $now[] = $personObject; unset($personObject); } else { if ($this->procObject->status == 'progtree') { $now = $procPersObject->persons; } } // there is an array of persons to process NOW. // loop through every record in this array (i.e. person_now) foreach ($now as $person) { // check that the person-tree combination (primary key) does not exists yet if ($tree_persons->load($person->i . '+' . $tree_id) == false) { // the person-tree combination does not exists // therefore the attributes for a new record are filled // primary key is combination of person-id and tree-id separated by + $tree_persons->set('id', $person->i . '+' . $tree_id); $tree_persons->set('app_id', $app_id); $tree_persons->set('tree_id', $tree_id); $tree_persons->set('person_id', $person->i); $tree_persons->set('type', $person->t); $tree_persons->set('lineage', $person->l); // insert the new record $ret = $tree_persons->store(); // after the new record is inserted, look for all relations of the newly inserted person // the relations are husband or wife (type = P for partner of) // and relations are father or mother (type = C for child) $lineage = array($this->_db->quote($person->l), 'jrn.person_id_1'); $quer1 = '( ' . 'SELECT jrn.person_id_1 AS i ' . ', ' . $this->_db->quote('P') . ' AS t ' . ', NULL AS l ' . ', jpn.sex AS s ' . 'FROM #__joaktree_relations jrn ' . 'INNER JOIN #__joaktree_persons jpn ' . 'ON ( jpn.app_id = jrn.app_id ' . ' AND jpn.id = jrn.person_id_1 ' . ' ) ' . 'WHERE jrn.app_id = ' . $app_id . ' ' . 'AND jrn.person_id_2 = ' . $this->_db->quote($person->i) . ' ' . 'AND jrn.type = ' . $this->_db->quote('partner') . ' ' . ') UNION ( ' . 'SELECT jrn.person_id_2 AS i ' . ', ' . $this->_db->quote('P') . ' AS t ' . ', NULL AS l ' . ', jpn.sex AS s ' . 'FROM #__joaktree_relations jrn ' . 'INNER JOIN #__joaktree_persons jpn ' . 'ON ( jpn.app_id = jrn.app_id ' . ' AND jpn.id = jrn.person_id_2 ' . ' ) ' . 'WHERE jrn.app_id = ' . $app_id . ' ' . 'AND jrn.person_id_1 = ' . $this->_db->quote($person->i) . ' ' . 'AND jrn.type = ' . $this->_db->quote('partner') . ' ' . ') UNION ( ' . 'SELECT jrn.person_id_1 AS i ' . ', ' . $this->_db->quote('C') . ' AS t ' . ', ' . $query->concatenate($lineage, ' ') . ' AS l ' . ', jpn.sex AS s ' . 'FROM #__joaktree_relations jrn ' . 'INNER JOIN #__joaktree_persons jpn ' . 'ON ( jpn.app_id = jrn.app_id ' . ' AND jpn.id = jrn.person_id_1 ' . ' ) ' . 'WHERE jrn.app_id = ' . $app_id . ' ' . 'AND jrn.person_id_2 = ' . $this->_db->quote($person->i) . ' ' . 'AND jrn.type IN ( ' . $this->_db->quote('father') . ', ' . $this->_db->quote('mother') . ') ' . ') '; $this->_db->setQuery($quer1); $tmp1 = $this->_db->loadObjectList(); $next = array_merge($next, $tmp1); unset($tmp1); } // end of if statement - adding new record for person-tree combination } // end of for-loop for the array being processed NOW // the NOW array is processed; a NEXT array is filled -> save it for later $resPersObject->persons = $next; // this is a loop: it can stop (a) when the next is empty // (that means: there is nothing to be processed anymore) if (count($next) == 0) { $finished = true; } } // end of check whether only descendants are in the tree if ($tree->holds == 'all' || $tree->holds == 'descendants' && (!isset($tree->root_person_id) || $tree->root_person_id == null)) { $quer1 = 'UPDATE #__joaktree_tree_persons jtp' . ', ( SELECT jpn.id AS id ' . ' , jpn.app_id AS app_id ' . ' FROM #__joaktree_persons jpn ' . ' WHERE jpn.app_id = ' . $app_id . ' ' . ' ) jpn_iv ' . 'SET jtp.app_id = jpn_iv.app_id ' . ', jtp.tree_id = ' . $tree_id . ' ' . ', jtp.person_id = jpn_iv.id ' . ', jtp.type = ' . $this->_db->Quote('R') . ' ' . ', jtp.lineage = null ' . 'WHERE jtp.id = CONCAT_WS(' . $this->_db->Quote('+') . ', jpn_iv.id, ' . $tree_id . ') '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $quer1 = 'INSERT IGNORE ' . 'INTO #__joaktree_tree_persons ' . '( id ' . ', app_id ' . ', tree_id ' . ', person_id ' . ', type ' . ', lineage ' . ') ' . 'SELECT CONCAT_WS(' . $this->_db->Quote('+') . ', jpn.id, ' . $tree_id . ') ' . ', jpn.app_id ' . ', ' . $tree_id . ' ' . ', jpn.id ' . ', ' . $this->_db->Quote('R') . ' ' . ', null ' . 'FROM #__joaktree_persons jpn ' . 'WHERE jpn.app_id = ' . $app_id . ' '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); // // everyone gets the same default tree // $query->clear(); // $query->update(' #__joaktree_admin_persons '); // $query->set( ' default_tree_id = '.$tree_id.' '); // $query->where( ' app_id = '.$app_id.' '); // $query->where( ' default_tree_id IS NULL '); // // $msg = $this->_db->setQuery( $query ); // $msg = $this->_db->query( ); // the whole tree is done by one set of statements $finished = true; $resPersObject->persons = null; } // end of check whether all persons are in the tree if ($finished) { // finished with this tree - up to the next tree $resPersObject->tree_ids = $procPersObject->tree_ids; if (count($resPersObject->tree_ids) > 0) { $returnStatus = 'starttree'; } else { // we are realy done $returnStatus = 'endtree'; } } else { $returnStatus = 'progtree'; } // save the PersonObject $this->setProcPersonObject($resPersObject); break; case 'endtree': // PERSONS WITH 0 or 1 TREE // after filling the tree_person table, the default tree for every person is determined // for which it is not yet filled // different default trees for different persons // select all persons in the system without default tree // if 0 trees are found, there is no tree (and thus no default tree) for this person // if 1 tree is found, this tree is the default tree for this person $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jtp1.person_id ' . ' , jtp1.tree_id ' . ' FROM #__joaktree_tree_persons jtp1 ' . ' INNER JOIN ( SELECT jtp2.person_id ' . ' , MIN(jtp2.tree_id) AS tree_id ' . ' FROM #__joaktree_tree_persons jtp2 ' . ' WHERE jtp2.app_id = ' . $app_id . ' ' . ' GROUP BY jtp2.person_id ' . ' HAVING COUNT(jtp2.tree_id) = 1 ' . ' ) iv_jtp2 ' . ' ON ( iv_jtp2.person_id = jtp1.person_id ' . ' AND iv_jtp2.tree_id = jtp1.tree_id ' . ' ) ' . ' WHERE jtp1.app_id = ' . $app_id . ' ' . ' ) iv_jtp1 ' . 'SET jan.default_tree_id = iv_jtp1.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jtp1.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $this->procObject->msg = 'Setting up default trees for persons.'; $returnStatus = 'treedef_1'; break; case 'treedef_1': // PERSONS WITH EXACTLY 1 TREE // select all persons in the system without default tree // and update the default tree $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jtp1.person_id ' . ' , jtp1.tree_id ' . ' FROM #__joaktree_tree_persons jtp1 ' . ' INNER JOIN ( SELECT jtp2.person_id ' . ' , MIN(jtp2.tree_id) AS tree_id ' . ' FROM #__joaktree_tree_persons jtp2 ' . ' INNER JOIN #__joaktree_trees jte ' . ' ON ( jte.app_id = jtp2.app_id ' . ' AND jte.id = jtp2.tree_id ' . ' ) ' . ' WHERE jtp2.app_id = ' . $app_id . ' ' . ' GROUP BY jtp2.person_id ' . ' HAVING COUNT(jtp2.tree_id) = 1 ' . ' ) iv_jtp2 ' . ' ON ( iv_jtp2.person_id = jtp1.person_id ' . ' AND iv_jtp2.tree_id = jtp1.tree_id ' . ' ) ' . ' WHERE jtp1.app_id = ' . $app_id . ' ' . ' ) iv_jtp1 ' . 'SET jan.default_tree_id = iv_jtp1.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jtp1.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $returnStatus = 'treedef_2'; break; case 'treedef_2': // PERSONS WITH MORE THAN 1 TREE // select all persons in the system without default tree // update with default tree of first father $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jrn.person_id_1 AS person_id ' . ' , MIN(jan2.default_tree_id) AS tree_id ' . ' FROM #__joaktree_relations jrn ' . ' INNER JOIN #__joaktree_admin_persons jan2 ' . ' ON ( jan2.app_id = jrn.app_id ' . ' AND jan2.id = jrn.person_id_2 ' . ' ) ' . ' WHERE jrn.app_id = ' . $app_id . ' ' . ' AND jrn.type = ' . $this->_db->quote('father') . ' ' . ' AND IFNULL(jrn.orderNumber_1, 0) = ' . ' ( SELECT IFNULL(MIN(jrn2.orderNumber_1), 0) ' . ' FROM #__joaktree_relations jrn2 ' . ' WHERE jrn2.app_id = jrn.app_id ' . ' AND jrn2.person_id_1 = jrn.person_id_1 ' . ' AND jrn2.type = jrn.type ' . ' ) ' . ' GROUP BY jrn.person_id_1 ' . ' ) iv_jrn ' . 'SET jan.default_tree_id = iv_jrn.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jrn.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $returnStatus = 'treedef_3'; break; case 'treedef_3': // select all persons in the system without default tree // update with default tree of first mother $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jrn.person_id_1 AS person_id ' . ' , MIN(jan2.default_tree_id) AS tree_id ' . ' FROM #__joaktree_relations jrn ' . ' INNER JOIN #__joaktree_admin_persons jan2 ' . ' ON ( jan2.app_id = jrn.app_id ' . ' AND jan2.id = jrn.person_id_2 ' . ' ) ' . ' WHERE jrn.app_id = ' . $app_id . ' ' . ' AND jrn.type = ' . $this->_db->quote('mother') . ' ' . ' AND IFNULL(jrn.orderNumber_1, 0) = ' . ' ( SELECT IFNULL(MIN(jrn2.orderNumber_1), 0) ' . ' FROM #__joaktree_relations jrn2 ' . ' WHERE jrn2.app_id = jrn.app_id ' . ' AND jrn2.person_id_1 = jrn.person_id_1 ' . ' AND jrn2.type = jrn.type ' . ' ) ' . ' GROUP BY jrn.person_id_1 ' . ' ) iv_jrn ' . 'SET jan.default_tree_id = iv_jrn.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jrn.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $returnStatus = 'treedef_4'; break; case 'treedef_4': // select all persons in the system without default tree // update with default tree of first partner (a) $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jrn.person_id_1 AS person_id ' . ' , MIN(jan2.default_tree_id) AS tree_id ' . ' FROM #__joaktree_relations jrn ' . ' INNER JOIN #__joaktree_admin_persons jan2 ' . ' ON ( jan2.app_id = jrn.app_id ' . ' AND jan2.id = jrn.person_id_2 ' . ' ) ' . ' WHERE jrn.app_id = ' . $app_id . ' ' . ' AND jrn.type = ' . $this->_db->quote('partner') . ' ' . ' AND IFNULL(jrn.orderNumber_1, 0) = ' . ' ( SELECT IFNULL(MIN(jrn2.orderNumber_1), 0) ' . ' FROM #__joaktree_relations jrn2 ' . ' WHERE jrn2.app_id = jrn.app_id ' . ' AND jrn2.person_id_1 = jrn.person_id_1 ' . ' AND jrn2.type = jrn.type ' . ' ) ' . ' GROUP BY jrn.person_id_1 ' . ' ) iv_jrn ' . 'SET jan.default_tree_id = iv_jrn.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jrn.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); // update with default tree of first partner (b) $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jrn.person_id_2 AS person_id ' . ' , MIN(jan2.default_tree_id) AS tree_id ' . ' FROM #__joaktree_relations jrn ' . ' INNER JOIN #__joaktree_admin_persons jan2 ' . ' ON ( jan2.app_id = jrn.app_id ' . ' AND jan2.id = jrn.person_id_1 ' . ' ) ' . ' WHERE jrn.app_id = ' . $app_id . ' ' . ' AND jrn.type = ' . $this->_db->quote('partner') . ' ' . ' AND IFNULL(jrn.orderNumber_2, 0) = ' . ' ( SELECT IFNULL(MIN(jrn2.orderNumber_2), 0) ' . ' FROM #__joaktree_relations jrn2 ' . ' WHERE jrn2.app_id = jrn.app_id ' . ' AND jrn2.person_id_1 = jrn.person_id_2 ' . ' AND jrn2.type = jrn.type ' . ' ) ' . ' GROUP BY jrn.person_id_2 ' . ' ) iv_jrn ' . 'SET jan.default_tree_id = iv_jrn.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jrn.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $returnStatus = 'treedef_5'; break; case 'treedef_5': // PERSONS WITH MORE THAN 1 TREE // select all persons in the system without default tree // update with first tree (lowest number) $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jtp1.person_id ' . ' , jtp1.tree_id ' . ' FROM #__joaktree_tree_persons jtp1 ' . ' INNER JOIN ( SELECT jtp2.person_id ' . ' , MIN(jtp2.tree_id) AS tree_id ' . ' FROM #__joaktree_tree_persons jtp2 ' . ' INNER JOIN #__joaktree_trees jte ' . ' ON ( jte.app_id = jtp2.app_id ' . ' AND jte.id = jtp2.tree_id ' . ' ) ' . ' WHERE jtp2.app_id = ' . $app_id . ' ' . ' GROUP BY jtp2.person_id ' . ' ) iv_jtp2 ' . ' ON ( iv_jtp2.person_id = jtp1.person_id ' . ' AND iv_jtp2.tree_id = jtp1.tree_id ' . ' ) ' . ' WHERE jtp1.app_id = ' . $app_id . ' ' . ' ) iv_jtp1 ' . 'SET jan.default_tree_id = iv_jtp1.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jtp1.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $returnStatus = 'treedef_6'; break; case 'treedef_6': // PERSONS WITH MORE THAN 1 TREE // select all persons in the system without default tree // update with first tree (lowest number) $quer1 = 'UPDATE #__joaktree_admin_persons jan ' . ', ( SELECT jtp1.person_id ' . ' , jtp1.tree_id ' . ' FROM #__joaktree_tree_persons jtp1 ' . ' INNER JOIN ( SELECT jtp2.person_id ' . ' , MIN(jtp2.tree_id) AS tree_id ' . ' FROM #__joaktree_tree_persons jtp2 ' . ' WHERE jtp2.app_id = ' . $app_id . ' ' . ' GROUP BY jtp2.person_id ' . ' ) iv_jtp2 ' . ' ON ( iv_jtp2.person_id = jtp1.person_id ' . ' AND iv_jtp2.tree_id = jtp1.tree_id ' . ' ) ' . ' WHERE jtp1.app_id = ' . $app_id . ' ' . ' ) iv_jtp1 ' . 'SET jan.default_tree_id = iv_jtp1.tree_id ' . 'WHERE jan.app_id = ' . $app_id . ' ' . 'AND jan.id = iv_jtp1.person_id ' . 'AND jan.default_tree_id IS NULL '; $msg = $this->_db->setQuery($quer1); $msg = $this->_db->query(); $this->deleteProcPersonObject(); $returnStatus = 'endtreedef'; break; case 'error': default: $returnStatus = 'error'; break; } // end of switch return $returnStatus; }
private function _buildQuery() { $params = JoaktreeHelper::getJTParams(); //JComponentHelper::getParams('com_joaktree') ; $abbreviation = (int) $params->get('abbreviation', 0); $levels = JoaktreeHelper::getUserAccessLevels(); $displayAccess = JoaktreeHelper::getDisplayAccess(); if ($abbreviation == null or $abbreviation <= 0) { // no abbreviation of names $displayFamilyName = JoaktreeHelper::getConcatenatedDutchFamilyName(false); } else { // abbreviation on n characters, where n = $abbreviation $displayFamilyName = 'SUBSTR( ' . JoaktreeHelper::getConcatenatedDutchFamilyName(false) . ' ' . ' , 1 ' . ' , ' . $abbreviation . ' ' . ' )'; } $query = $this->_db->getQuery(true); $query->select(' COUNT(' . $displayFamilyName . ') AS nameCount '); $query->select(' ' . $displayFamilyName . ' AS familyName '); $query->from(' #__joaktree_tree_persons jtp '); $query->innerJoin(' #__joaktree_trees jte ' . ' ON ( jte.app_id = jtp.app_id ' . ' AND jte.id = jtp.tree_id ' . ' ) '); $query->innerJoin(' #__joaktree_persons jpn ' . ' ON ( jpn.app_id = jtp.app_id ' . ' AND jpn.id = jtp.person_id ' . ' ) '); $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(false)); // Get the WHERE clauses for the query $wheres = $this->_buildContentWhere(); foreach ($wheres as $where) { $query->where(' ' . $where . ' '); } // GROUP BY $query->group(' ' . $displayFamilyName . ' '); return $query; }
private function save_media(&$form) { // saving link for 1 picture if (!empty($form['person']['media']['path_file'][0])) { $docId = $form['person']['media']['status'][0] == 'new' ? null : $form['person']['media']['id'][0]; // Store the document $tabMedia = JTable::getInstance('joaktree_documents', 'Table'); // Bind the form fields to the table $tabMedia->app_id = $form['person']['app_id']; $tabMedia->id = $docId; // file $params = JoaktreeHelper::getJTParams(); $gedcomroot = $params->get('gedcomDocumentRoot', ''); $joomlaroot = $params->get('joomlaDocumentRoot', ''); if ($gedcomroot && $joomlaroot) { $tabMedia->file = str_replace($joomlaroot, $gedcomroot, $form['person']['media']['path_file'][0]); } else { if ($gedcomroot && !$joomlaroot) { $tabMedia->file = $gedcomroot . $form['person']['media']['path_file'][0]; } else { if (!$gedcomroot && $joomlaroot) { $tabMedia->file = str_replace($joomlaroot, '', $form['person']['media']['path_file'][0]); } else { $tabMedia->file = $form['person']['media']['path_file'][0]; } } } // $tabMedia->file = str_replace($joomlaroot, $gedcomroot, $form['person']['media']['path_file'][0] ); $tabMedia->title = htmlspecialchars($form['person']['media']['title'][0], ENT_QUOTES, 'UTF-8'); // fileformat $format = explode('.', $form['person']['media']['path_file'][0]); $tabMedia->fileformat = strtoupper(array_pop($format)); // not used yet $tabMedia->indCitation = false; $tabMedia->note_id = null; $tabMedia->note = null; //htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); // Make sure the table is valid if (!$tabMedia->check()) { $this->setError('Error checking media: '); return false; // Else store the table to the database } else { $docId = $tabMedia->store(false); if (!$docId) { $this->setError('Error saving media: ' . $tabMedia->getError()); return false; } } // link document to person $tabDocPerson = JTable::getInstance('joaktree_person_documents', 'Table'); $tabDocPerson->app_id = $form['person']['app_id']; $tabDocPerson->person_id = $form['person']['id']; $tabDocPerson->document_id = $docId; // Make sure the table is valid if (!$tabDocPerson->check()) { $this->setError('Error checking document-person: '); return false; // Else store the table to the database } else { if (!$tabDocPerson->store(false)) { $this->setError('Error saving document-person: ' . $tabDocPerson->getError()); return false; } } } return true; }