コード例 #1
0
ファイル: familylist.php プロジェクト: Lothurm/J3.x
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  * @since   11.1
  */
 protected function getOptions()
 {
     // Possible actions are: addparent, addchild, addpartner
     // Initialize variables.
     $appId = JoaktreeHelper::getApplicationId();
     $action = JoaktreeHelper::getAction();
     $personId = JoaktreeHelper::getRelationId();
     // Initialize variables.
     $options = array();
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     switch ($action) {
         case "addparent":
             // family for adding parents
             // select all parents of the person, and for every parent its family-id
             $query->select(' jrn.family_id ');
             $query->select(' jrn.person_id_2 AS pid2 ');
             $query->from(' #__joaktree_relations  jrn ');
             $query->where(' jrn.app_id      = ' . $appId . ' ');
             $query->where(' jrn.person_id_1 = ' . $db->quote($personId) . ' ');
             $query->where(' jrn.type        IN (' . $db->quote('father') . ', ' . $db->quote('mother') . ') ');
             $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
             $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND jpn.id     = jrn.person_id_2 ' . '    ) ');
             $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
             break;
         case "addchild":
             // family for adding children
             // select all partners of the person, and for every partner its family-id
             $query->select(' jrn.family_id ');
             $query->select(' IF( (jrn.person_id_1 = ' . $db->quote($personId) . ') ' . '   , jrn.person_id_2 ' . '   , jrn.person_id_1 ' . '   ) AS pid2 ');
             $query->from(' #__joaktree_relations  jrn ');
             $query->where(' jrn.app_id      = ' . $appId . ' ');
             $query->where(' (  jrn.person_id_1 = ' . $db->quote($personId) . ' ' . ' OR jrn.person_id_2 = ' . $db->quote($personId) . ' ' . ' ) ');
             $query->where(' jrn.type        = ' . $db->quote('partner') . ' ');
             $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
             $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND (  jpn.id     = jrn.person_id_1 ' . '        OR jpn.id     = jrn.person_id_2 ' . '        ) ' . '    AND jpn.id != ' . $db->quote($personId) . ' ' . '    ) ');
             $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
             break;
         default:
             // continue
             break;
     }
     if ($action == 'addparent' || $action == 'addchild') {
         // Set the query and get the result list.
         $db->setQuery($query);
         $items = $db->loadObjectlist();
         // Check for an error.
         if ($db->getErrorNum()) {
             JError::raiseWarning(500, $db->getErrorMsg());
             return $options;
         }
         // Build the field options.
         if (!empty($items)) {
             foreach ($items as $item) {
                 $options[] = JHtml::_('select.option', $item->pid2 . '!' . $item->family_id, $item->fullName);
             }
         }
     }
     if ($action == 'addpartner' || $action == 'addchild') {
         // select family-id of single parent families.
         // new partner or new child may be added to this family
         $query->clear();
         $query->select(' DISTINCT jrn.family_id ');
         $query->from(' #__joaktree_relations  jrn ');
         $query->where(' jrn.app_id = ' . $appId . ' ');
         $query->where(' jrn.person_id_2 = ' . $db->quote($personId) . ' ');
         $query->where(' jrn.type IN (' . $db->quote('father') . ', ' . $db->quote('mother') . ') ');
         $query->where(' NOT EXISTS ' . ' ( SELECT 1 ' . '   FROM   #__joaktree_relations  jrn2 ' . '   WHERE  jrn2.app_id    = jrn.app_id ' . '   AND    jrn2.family_id = jrn.family_id ' . '   AND    jrn2.type      = ' . $db->quote('partner') . ' ' . ' ) ');
         $query->select(' GROUP_CONCAT(jpn.firstName SEPARATOR ' . $db->quote(', ') . ') AS names ');
         $query->innerJoin(' #__joaktree_persons  jpn ' . ' ON (   jpn.app_id = jrn.app_id ' . '    AND jpn.id     = jrn.person_id_1 ' . '    ) ');
         $query->innerJoin(JoaktreeHelper::getJoinAdminPersons());
         $db->setQuery($query);
         $familyId = $db->loadObject();
     }
     // if familyId is unknown (either in case of addparent, of with no result for the last query
     // the familyId is set to be '0'. The option is added to the list.
     switch ($action) {
         case "addparent":
             $options[] = JHtml::_('select.option', '0!0', JText::_('JT_NEWFAMILY1'));
             break;
         case "addchild":
             $familyId = is_object($familyId) && $familyId->family_id ? $familyId->family_id : '0';
             $options[] = JHtml::_('select.option', '0!' . $familyId, JText::_('JT_NEWFAMILY3'));
             break;
         case "addpartner":
             if (is_object($familyId) && $familyId->family_id) {
                 $options[] = JHtml::_('select.option', '0!' . $familyId->family_id, $familyId->names);
             }
             // finally we add the option for a new partner / new family
             $options[] = JHtml::_('select.option', '0!0', JText::_('JT_NEWFAMILY2'));
             break;
         default:
             // continue
             break;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: Lothurm/J3.x
 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);
     }
 }
コード例 #3
0
ファイル: source.php プロジェクト: Lothurm/J3.x
 public function getAction()
 {
     return JoaktreeHelper::getAction();
 }
コード例 #4
0
ファイル: joaktreelist.php プロジェクト: Lothurm/J3.x
 public function getPersonlist()
 {
     // Lets load the content if it doesn't already exist
     if (empty($this->_personlist)) {
         $query = $this->_buildQuery();
         $this->_personlist = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
         $action = JoaktreeHelper::getAction();
         if ($action == 'saveparent1') {
             for ($i = 0, $n = count($this->_personlist); $i < $n; $i++) {
                 $this->_personlist[$i]->partners = $this->getPartners($this->_personlist[$i]->app_id, $this->_personlist[$i]->id);
             }
         }
     }
     return $this->_personlist;
 }