function xnpbookGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $book_table = $xoopsDB->prefix('xnpbook_item_detail');
    $book_author = $xoopsDB->prefix('xnpbook_author');
    $wheres = array();
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnpbook');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($book_author . '.author', 'xnpbook_author');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($book_table . '.editor', 'xnpbook_editor');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($book_table . '.publisher', 'xnpbook_publisher');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($book_table . '.isbn', 'xnpbook_isbn');
    if ($w) {
        $wheres[] = $w;
    }
    $formdata =& xoonips_getutility('formdata');
    $xnpbook_book_pdf = $formdata->getValue('post', 'xnpbook_book_pdf', 's', false);
    if (!empty($xnpbook_book_pdf)) {
        $search_text_table = $xoopsDB->prefix('xoonips_search_text');
        $file_table = $xoopsDB->prefix('xoonips_file');
        $searchutil =& xoonips_getutility('search');
        $fulltext_query = $xnpbook_book_pdf;
        $fulltext_encoding = mb_detect_encoding($fulltext_query);
        $fulltext_criteria = new CriteriaCompo($searchutil->getFulltextSearchCriteria('search_text', $fulltext_query, $fulltext_encoding, $search_text_table));
        $fulltext_criteria->add(new Criteria('is_deleted', 0, '=', $file_table));
        $wheres[] = $fulltext_criteria->render();
    }
    $where = implode(' AND ', $wheres);
    $join = " INNER JOIN {$book_author} ON " . $book_author . '.book_id  = ' . $xoopsDB->prefix('xoonips_item_basic') . '.item_id ';
}
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 ';
}
function xnppresentationGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $formdata =& xoonips_getutility('formdata');
    $basic_table = $xoopsDB->prefix('xoonips_item_basic');
    $presentation_table = $xoopsDB->prefix('xnppresentation_item_detail');
    $presentation_creator_table = $xoopsDB->prefix('xnppresentation_creator');
    $file_table = $xoopsDB->prefix('xoonips_file');
    $search_text_table = $xoopsDB->prefix('xoonips_search_text');
    $wheres = array();
    $joins = array();
    $xnppresentation_presentation_type = $formdata->getValue('post', 'xnppresentation_presentation_type', 's', false);
    $xnppresentation_presentation_file = $formdata->getValue('post', 'xnppresentation_presentation_file', 's', false);
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnppresentation');
    if ($w) {
        $wheres[] = $w;
    }
    if (!empty($xnppresentation_presentation_type)) {
        $myts =& MyTextSanitizer::getInstance();
        $wheres[] = $presentation_table . '.presentation_type = \'' . addslashes($xnppresentation_presentation_type) . '\'';
    }
    $w = xnpGetKeywordQuery($presentation_creator_table . '.creator', 'xnppresentation_creator');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($file_table . '.caption', 'xnppresentation_caption');
    if ($w) {
        $wheres[] = $w;
        $wheres[] = " {$file_table}.file_type_id = 1";
    }
    if (!empty($xnppresentation_presentation_file)) {
        $search_text_table = $xoopsDB->prefix('xoonips_search_text');
        $file_table = $xoopsDB->prefix('xoonips_file');
        $searchutil =& xoonips_getutility('search');
        $fulltext_query = $xnppresentation_presentation_file;
        $fulltext_encoding = mb_detect_encoding($fulltext_query);
        $fulltext_criteria = new CriteriaCompo($searchutil->getFulltextSearchCriteria('search_text', $fulltext_query, $fulltext_encoding, $search_text_table));
        $fulltext_criteria->add(new Criteria('is_deleted', 0, '=', $file_table));
        $wheres[] = $fulltext_criteria->render();
    }
    $where = implode(' AND ', $wheres);
    $join = " INNER JOIN {$presentation_creator_table} ON " . $presentation_creator_table . '.presentation_id  = ' . $xoopsDB->prefix('xoonips_item_basic') . '.item_id ';
}
function xnppaperGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $formdata =& xoonips_getutility('formdata');
    $paper_table = $xoopsDB->prefix('xnppaper_item_detail');
    $paper_author_table = $xoopsDB->prefix('xnppaper_author');
    $file_table = $xoopsDB->prefix('xoonips_search_text');
    $wheres = array();
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnppaper');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($paper_table . '.journal', 'xnppaper_journal');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($paper_table . '.volume', 'xnppaper_volume');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($paper_table . '.number', 'xnppaper_number');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($paper_table . '.page', 'xnppaper_page');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($paper_table . '.pubmed_id', 'xnppaper_pubmed_id');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($paper_author_table . '.author', 'xnppaper_author');
    if ($w) {
        $wheres[] = $w;
    }
    $xnppaper_paper_pdf_reprint = $formdata->getValue('post', 'xnppaper_paper_pdf_reprint', 's', false);
    if (!empty($xnppaper_paper_pdf_reprint)) {
        $search_text_table = $xoopsDB->prefix('xoonips_search_text');
        $file_table = $xoopsDB->prefix('xoonips_file');
        $searchutil =& xoonips_getutility('search');
        $fulltext_query = $xnppaper_paper_pdf_reprint;
        $fulltext_encoding = mb_detect_encoding($fulltext_query);
        $fulltext_criteria = new CriteriaCompo($searchutil->getFulltextSearchCriteria('search_text', $fulltext_query, $fulltext_encoding, $search_text_table));
        $fulltext_criteria->add(new Criteria('is_deleted', 0, '=', $file_table));
        $wheres[] = $fulltext_criteria->render();
    }
    $where = implode(' AND ', $wheres);
    $join = '';
    $join = " INNER JOIN {$paper_author_table} on " . $paper_author_table . '.paper_id  = ' . $xoopsDB->prefix('xoonips_item_basic') . '.item_id ';
}
function xnpfilesGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $formdata =& xoonips_getutility('formdata');
    $basic_table = $xoopsDB->prefix('xoonips_item_basic');
    $data_table = $xoopsDB->prefix('xnpfiles_item_detail');
    $file_table = $xoopsDB->prefix('xoonips_file');
    $wheres = array();
    $joins = array();
    $xnpfiles_data_file_filetype = $formdata->getValue('post', 'xnpfiles_data_file_filetype', 's', false);
    $data_file_name = $formdata->getValue('post', 'data_file_name', 's', false);
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnpfiles');
    if ($w) {
        $wheres[] = $w;
    }
    if (!empty($xnpfiles_data_file_filetype)) {
        $wheres[] = $data_table . '.data_file_filetype = \'' . addslashes($xnpfiles_data_file_filetype) . '\'';
    }
    if (!empty($data_file_name)) {
        $wheres[] = $data_table . '.data_file_name = \'' . addslashes($data_file_name) . '\'';
    }
    $w = xnpGetKeywordQuery($data_table . '.data_file_mimetype', 'data_file_mimetype');
    if ($w) {
        $wheres[] = $w;
    }
    $w = '';
    foreach ($_POST as $key => $value) {
        if (substr($key, 0, 19) == 'data_file_filetype_') {
            if ($w != '') {
                $w .= ' or ';
            }
            $w .= $data_table . '.data_file_filetype = \'' . substr($key, 19) . '\'';
        }
    }
    if ($w) {
        $wheres[] = $w;
    }
    $where = implode(' and ', $wheres);
    $join = implode(' ', $joins);
}
function xnpsimulatorGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $simulator_table = $xoopsDB->prefix('xnpsimulator_item_detail');
    $simulator_developer_table = $xoopsDB->prefix('xnpsimulator_developer');
    $file_table = $xoopsDB->prefix('xoonips_file');
    $wheres = array();
    $joins = array();
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnpsimulator');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($simulator_table . '.simulator_type', 'xnpsimulator_simulator_type');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($simulator_developer_table . '.developer', 'xnpsimulator_developer');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($file_table . '.caption', 'xnpsimulator_caption');
    if ($w) {
        $wheres[] = $w;
        $wheres[] = " {$file_table}.file_type_id = 1";
    }
    $where = implode(' and ', $wheres);
    $join = " join {$simulator_developer_table} on " . $simulator_developer_table . '.simulator_id  = ' . $xoopsDB->prefix('xoonips_item_basic') . '.item_id ';
}
function xnpmemoGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $memo_table = $xoopsDB->prefix('xnpmemo_item_detail');
    $file_table = $xoopsDB->prefix('xoonips_file');
    $wheres = array();
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnpmemo');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($memo_table . '.item_link', 'xnpmemo_item_link');
    if ($w) {
        $wheres[] = $w;
    }
    $where = implode(' and ', $wheres);
    $join = '';
}
function xnptoolGetAdvancedSearchQuery(&$where, &$join)
{
    global $xoopsDB;
    $formdata =& xoonips_getutility('formdata');
    $tool_table = $xoopsDB->prefix('xnptool_item_detail');
    $tool_developer_table = $xoopsDB->prefix('xnptool_developer');
    $file_table = $xoopsDB->prefix('xoonips_file');
    $search_text_table = $xoopsDB->prefix('xoonips_search_text');
    $wheres = array();
    $joins = array();
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnptool');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($tool_table . '.tool_type', 'xnptool_tool_type');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($tool_developer_table . '.developer', 'xnptool_developer');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($file_table . '.caption', 'xnptool_caption');
    if ($w) {
        $wheres[] = $w;
        $wheres[] = " {$file_table}.file_type_id = 1";
    }
    $xnptool_tool_file = $formdata->getValue('post', 'xnptool_tool_file', 's', false);
    if (!empty($xnptool_tool_file)) {
        $search_text_table = $xoopsDB->prefix('xoonips_search_text');
        $file_table = $xoopsDB->prefix('xoonips_file');
        $searchutil =& xoonips_getutility('search');
        $fulltext_query = $xnptool_tool_file;
        $fulltext_encoding = mb_detect_encoding($fulltext_query);
        $fulltext_criteria = new CriteriaCompo($searchutil->getFulltextSearchCriteria('search_text', $fulltext_query, $fulltext_encoding, $search_text_table));
        $fulltext_criteria->add(new Criteria('is_deleted', 0, '=', $file_table));
        $wheres[] = $fulltext_criteria->render();
    }
    $where = implode(' AND ', $wheres);
    $join = " INNER JOIN {$tool_developer_table} ON " . $tool_developer_table . '.tool_id  = ' . $xoopsDB->prefix('xoonips_item_basic') . '.item_id ';
}
function xnpurlGetAdvancedSearchQuery(&$where, &$join)
{
    $formdata =& xoonips_getutility('formdata');
    global $xoopsDB;
    $url_table = $xoopsDB->prefix('xnpurl_item_detail');
    $wheres = array();
    $w = xnpGetBasicInformationAdvancedSearchQuery('xnpurl');
    if ($w) {
        $wheres[] = $w;
    }
    $w = xnpGetKeywordQuery($url_table . '.url', 'xnpurl_url');
    if ($w) {
        $wheres[] = $w;
    }
    $where = implode(' AND ', $wheres);
    $join = '';
}
Esempio n. 10
0
/** 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);
}