コード例 #1
0
ファイル: view.html.php プロジェクト: Lothurm/J3.x
 function display($tpl = null)
 {
     $this->lists = array();
     JHTML::stylesheet(JoaktreeHelper::joaktreecss());
     //load the language file
     MBJService::setLanguage();
     $this->lists['version'] = JoaktreeHelper::getJoaktreeVersion();
     $this->lists['providers'] = $this->get('providers');
     JoaktreeHelper::addSubmenu('default');
     $this->addToolbar();
     $this->sidebar = JHtmlSidebar::render();
     parent::display($tpl);
 }
コード例 #2
0
ファイル: jt_gedcomexport2.php プロジェクト: Lothurm/J3.x
 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;
 }
コード例 #3
0
ファイル: helper.php プロジェクト: Lothurm/J3.x
 function getJoaktreeCR()
 {
     static $crText;
     if (!isset($crText)) {
         $currentYear = strftime('%Y');
         $crText = '';
         $crText .= 'Joaktree ';
         $crText .= JoaktreeHelper::getJoaktreeVersion() . ' ';
         $crText .= '(2009-' . $currentYear . ')';
     }
     return $crText;
 }