function __construct() { $id = array(); $id['map'] = Map::getMapId(true); $id['location'] = Map::getLocationId(true); $id['distance'] = Map::getDistance(true); $id['person'] = JoaktreeHelper::getPersonId(false, true); $id['tree'] = JoaktreeHelper::getTreeId(false, true); $id['app'] = JoaktreeHelper::getApplicationId(false, true); $this->map = new Map($id); parent::__construct(); }
function getArticleList() { $nullDate = $this->_db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSql(); $params = JComponentHelper::getParams('com_joaktree'); $indArticleLink = (int) $params->get('indArticleLink', 9); $displayAccess = JoaktreeHelper::getDisplayAccess(); $userAccess = JoaktreeHelper::getUserAccess(); $accessLevels = JoaktreeHelper::getUserAccessLevels(); $related = array(); $likes = array(); // situation: article is shown to user -> find other related articles + related persons if ($this->_option == 'com_content' && $this->_view == 'article' && $this->_id) { // select the meta keywords from the article and fill the "likes" parameter $query = $this->_db->getQuery(true); $query->select(' metakey '); $query->from(' #__content '); $query->where(' id = ' . (int) $this->_id . ' '); $this->_db->setQuery($query); if ($metakey = trim($this->_db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { // surround with commas so first and last items have surrounding commas $likes[] = ',' . $this->_db->escape($key) . ','; } } } } // situation: persons is shown to user -> find related articles // and fill the "likes" parameter with parameters from the person if ($this->_option == 'com_joaktree' && $this->_view == 'joaktree') { $query = $this->_db->getQuery(true); // get tree id $treeId = JoaktreeHelper::getTreeId(); // get application id $appId = JoaktreeHelper::getApplicationId(); // get the person id $personId = JoaktreeHelper::getPersonId(); // check acces to person and tree is allowed $accessAllowed = JoaktreeHelper::getAccess(); // retrieve name of person, if access is allowed if ($accessAllowed and $indArticleLink != 0) { $concat_string = ' CONCAT_WS( "," '; if ($indArticleLink == 1 or $indArticleLink == 9) { // 1: By ID; 9: All options $concat_string .= ' , CONCAT_WS( ' . $this->_db->quote('!') . ' ' . ' , jpn.app_id ' . ' , jpn.id ' . ' ) ' . ' , jpn.id '; } if ($indArticleLink == 2 or $indArticleLink == 5 or $indArticleLink == 9) { // 2: By first name; 5: All names; 9: All options $concat_string .= ' , jpn.firstName '; } if ($indArticleLink == 3 or $indArticleLink == 5 or $indArticleLink == 9) { // 3: By family name; 5: All names; 9: All options $concat_string .= ' , CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . ' , jpn.namePreposition ' . ' , jpn.familyName ' . ' ) '; } if ($indArticleLink == 4 or $indArticleLink == 5 or $indArticleLink == 9) { // 4: By first + family name; 5: All names; 9: All options $concat_string .= ' , CONCAT_WS( ' . $this->_db->quote(' ') . ' ' . ' , jpn.firstName ' . ' , jpn.namePreposition ' . ' , jpn.familyName ' . ' ) '; } $concat_string .= ' ) AS metakey '; $query->select($concat_string); $query->from(' #__joaktree_persons jpn '); $query->innerJoin(' #__joaktree_admin_persons jan ' . ' ON ( jan.app_id = jpn.app_id ' . ' AND jan.id = jpn.id ' . ' AND jan.published = true ' . ' AND jan.page = true ' . ' AND ( (jan.living = false AND ' . $displayAccess['NAMEname']->notLiving . ' = 2 ) ' . ' OR (jan.living = true AND ' . $displayAccess['NAMEname']->living . ' = 2 ) ' . ' ) ' . ' ) '); $query->where(' jpn.id = ' . $this->_db->quote($personId) . ' '); $this->_db->setQuery($query); if ($metakey = trim($this->_db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { // surround with commas so first and last items have surrounding commas $likes[] = ',' . $this->_db->escape($key) . ','; } } } } } // the "likes" parameter is filled - either from article or from person // process the "likes" - search in keyword of articles if (count($likes)) { // select other items based on the metakey field 'like' the keys found $query = $this->_db->getQuery(true); $query->select(' a.id '); $query->select(' a.title '); $query->select(' DATE_FORMAT(a.created, "%Y-%m-%d") AS created '); $query->select(' a.catid '); $query->select(' CASE WHEN CHAR_LENGTH(a.alias) ' . ' THEN CONCAT_WS(":", a.id, a.alias) ' . ' ELSE a.id ' . ' END AS slug '); $query->select(' a.language '); $query->from(' #__content AS a '); // join with categories $query->select(' cc.access AS cat_access '); $query->select(' cc.published AS cat_state '); $query->select(' CASE WHEN CHAR_LENGTH(cc.alias) ' . ' THEN CONCAT_WS(":", cc.id, cc.alias) ' . ' ELSE cc.id ' . ' END AS catslug '); $query->leftJoin(' #__categories AS cc ' . ' ON ( cc.id = a.catid ' . ' AND cc.published = 1 ' . ' AND cc.access IN ' . $accessLevels . ' ' . ' ) '); $query->where(' a.id != ' . (int) $this->_id . ' '); $query->where(' a.state = 1 '); $query->where(' a.access IN ' . $accessLevels . ' '); $query->where(' ( CONCAT( "," ' . ' , REPLACE( a.metakey ' . ' , ", " ' . ' , "," ' . ' ) ' . ' , "," ' . ' ) ' . ' LIKE "%' . implode('%" OR CONCAT( "," ' . ' , REPLACE( a.metakey ' . ' , ", " ' . ' , "," ' . ' ) ' . ' , "," ' . ' ) LIKE "%', $likes) . '%" ' . ' ) '); //remove single space after commas in keywords $query->where(' ( a.publish_up = ' . $this->_db->Quote($nullDate) . ' ' . ' OR a.publish_up <= ' . $this->_db->Quote($now) . ' ' . ' ) '); $query->where(' ( a.publish_down = ' . $this->_db->Quote($nullDate) . ' ' . ' OR a.publish_down >= ' . $this->_db->Quote($now) . ' ' . ' ) '); // Filter by language if ($this->languageFilter) { $query->where('a.language in (' . $this->_db->Quote(JFactory::getLanguage()->getTag()) . ',' . $this->_db->Quote('*') . ') '); } $query->order(' a.title '); $this->_db->setQuery($query); $temp = $this->_db->loadObjectList(); if (count($temp)) { foreach ($temp as $row) { if (($row->cat_state == 1 || $row->cat_state == '') && (in_array($row->cat_access, $userAccess) || $row->cat_access == '')) { $row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug)); $row->robot = ''; $related[] = $row; } } } unset($temp); } return $related; }
public function getTreeId() { return JoaktreeHelper::getTreeId(); }
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); }