function xnpconferenceGetAdvancedSearchQuery(&$where, &$join) { global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $basic_table = $xoopsDB->prefix('xoonips_item_basic'); $conference_table = $xoopsDB->prefix('xnpconference_item_detail'); $conference_author_table = $xoopsDB->prefix('xnpconference_author'); $file_table = $xoopsDB->prefix('xoonips_file'); $wheres = array(); $joins = array(); $xnpconference_presentation_type = $formdata->getValue('post', 'xnpconference_presentation_type', 's', false); $xnpconference_publication_date_from = $formdata->getValue('post', 'xnpconference_publication_date_from', 'i', false); $xnpconference_publication_date_to = $formdata->getValue('post', 'xnpconference_publication_date_to', 'i', false); $w = xnpGetBasicInformationAdvancedSearchQuery('xnpconference'); if ($w) { $wheres[] = $w; } if (!empty($xnpconference_presentation_type)) { $wheres[] = $conference_table . '.presentation_type = \'' . addslashes($xnpconference_presentation_type) . '\''; } $w = xnpGetKeywordQuery($conference_table . '.conference_title', 'xnpconference_conference_title'); if ($w) { $wheres[] = $w; } $w = xnpGetKeywordQuery($conference_table . '.place', 'xnpconference_place'); if ($w) { $wheres[] = $w; } $w = xnpGetKeywordQuery($conference_author_table . '.author', 'xnpconference_creator'); if ($w) { $wheres[] = $w; } $w = xnpGetKeywordQuery($conference_table . '.abstract', 'xnpconference_abstract'); if ($w) { $wheres[] = $w; } $w = ''; if (!empty($xnpconference_publication_date_from)) { $w .= xnpGetFromQuery($conference_table . '.' . 'conference_from', 'xnpconference_publication_date_from'); } if (!empty($xnpconference_publication_date_to)) { if ($w != '') { $w .= ' AND '; } $w .= xnpGetToQuery($conference_table . '.' . 'conference_to', 'xnpconference_publication_date_to'); } if ($w != '') { $wheres[] = $w; } $w = xnpGetKeywordQuery($file_table . '.caption', 'xnpconference_caption'); if ($w) { $wheres[] = $w; $wheres[] = " {$file_table}.file_type_id = 1"; } $where = implode(' and ', $wheres); $join = " join {$conference_author_table} on " . $conference_author_table . '.conference_id = ' . $xoopsDB->prefix('xoonips_item_basic') . '.item_id '; }
/** return query of SQL for retrieve Basic Information in Advanced Search. If there is no condition in input, return empty character strings. * @param moduleName name of module * @return query of SQL */ function xnpGetBasicInformationAdvancedSearchQuery($moduleName) { $wheres = array(); global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $basic_table = $xoopsDB->prefix('xoonips_item_basic'); $title_table = $xoopsDB->prefix('xoonips_item_title'); $keyword_table = $xoopsDB->prefix('xoonips_item_keyword'); $w = xnpGetKeywordQuery($title_table . '.title', $moduleName . '_title'); if ($w) { $wheres[] = $w; } $w = xnpGetKeywordQuery($keyword_table . '.keyword', $moduleName . '_keywords'); if ($w) { $wheres[] = $w; } $w = xnpGetKeywordQuery($basic_table . '.description', $moduleName . '_description'); if ($w) { $wheres[] = $w; } $w = xnpGetKeywordQuery($basic_table . '.doi', $moduleName . '_doi'); if ($w) { $keyword = $formdata->getValue('post', $moduleName . '_doi', 's', false, ''); $w2 = sprintf('`%s`.`item_id`=%s', $basic_table, $xoopsDB->quoteString($keyword)); $wheres[] = sprintf('(%s OR %s)', $w, $w2); } $publication_date_from = $formdata->getValue('post', $moduleName . '_publication_date_from', 'n', false); $publication_date_to = $formdata->getValue('post', $moduleName . '_publication_date_to', 'n', false); $creation_date_from = $formdata->getValue('post', $moduleName . '_creation_date_from', 'n', false); if (!empty($publication_date_from)) { $wheres[] = xnpGetFromQuery($basic_table . '.' . 'publication', $moduleName . '_publication_date_from'); } if (!empty($publication_date_to)) { $wheres[] = xnpGetToQuery($basic_table . '.' . 'publication', $moduleName . '_publication_date_to'); } if (!empty($creation_date_from)) { $wheres[] = $basic_table . '.' . 'creation_date >= ' . (int) $creation_date_from; } return implode(' AND ', $wheres); }