function nexdoc_displayTagSearchListing($query, &$data) { global $_CONF, $_TABLES, $_FMCONF, $allowableViewFoldersSql, $paddingsize, $filedescriptionOffset; $tpl = new Template($_CONF['path_layout'] . 'nexfile'); $tpl->set_file(array('filedetails' => 'filedetails.thtml', 'subfolder' => 'filelisting_subfolder_record.thtml', 'emptyfolder' => 'filelisting_emptyfolder.thtml', 'filelisting_rec' => 'filelisting_record.thtml', 'folderlisting_rec' => 'leftnav_folder_record.thtml', 'movefolder' => 'folder_onhover_move.thtml', 'tag_link' => 'taglink_record.thtml', 'tag_rec' => 'tagdesc_record.thtml', 'download_action' => 'download_link.thtml', 'editfile_action' => 'editfile_link.thtml')); $tpl->set_var('layout_url', $_CONF['layout_url']); $tpl->set_var('imgset', "{$_CONF['layout_url']}/nexfile/images"); $sql = "SELECT file.fid as fid,file.cid,file.title,file.fname,file.date,file.version,file.submitter,file.status,"; $sql .= "detail.description,category.name,category.pid "; $sql .= "FROM {$_TABLES['nxfile_files']} file "; $sql .= "LEFT JOIN {$_TABLES['nxfile_filedetail']} detail ON detail.fid=file.fid "; $sql .= "LEFT JOIN {$_TABLES['nxfile_categories']} category ON file.cid=category.cid "; $sql .= "WHERE 1=1 "; if (!empty($allowableViewFoldersSql)) { $sql .= "AND file.cid in ({$allowableViewFoldersSql}) "; } $tagcloud = new nexfileTagCloud(); $itemids = $tagcloud->search($query); if ($itemids !== FALSE) { $itemids = implode(',', $itemids); } if (!empty($itemids)) { $sql .= "AND file.fid in ({$itemids}) "; } else { $sql .= "AND 1 = 2"; // No tags match query - return 0 records } $sql .= "ORDER BY file.date DESC "; $resFiles = DB_query($sql); if (DB_numRows($resFiles) > 0) { // Show any files in this directory $i = 1; $query = stripslashes($query); while (list($fid, $subfolderId, $title, $fname, $date, $version, $submitter, $status, $description, $category, $pid) = DB_fetchARRAY($resFiles)) { $tpl->set_var('padding_left', 2 * $paddingsize); $tpl->set_var('file_desc_padding_left', $filedescriptionOffset); if ($status == 2) { $tpl->set_var('showlock', ''); } else { $tpl->set_var('showlock', 'none'); } $tpl->set_var('details_link_parms', "?fid={$fid}"); $tpl->set_var('fid', $fid); $tpl->set_var('file_name', $title); $tpl->set_var('modified_date', strftime($_CONF['shortdate'], $date)); $tpl->set_var('folder_link', "{$_CONF['site_url']}/nexfile/index.php?cid={$subfolderId}"); $tpl->set_var('folder_name', $category); $tpl->set_var('subfolder_id', $subfolderId); $tags = $tagcloud->get_itemtags($fid); nexdoc_formatfiletags($tpl, $tags, $query); nexdoc_formatFavoriteImage($tpl, $fid); $tpl->set_var('file_description', nl2br($description)); $tpl->set_var('download_link', "{$_CONF['site_url']}/nexfile/download.php?op=download&fid={$fid}"); $tpl->parse('download_action_link', 'download_action'); if ($uid > 1) { $tpl->set_var('edit_link', "{$_CONF['site_url']}/nexfile/download.php?op=editfile&fid={$fid}"); $tpl->parse('edit_action_link', 'editfile_action'); } else { $tpl->set_var('edit_action_link', ''); } $pos = strrpos($fname, '.') + 1; $ext = strtolower(substr($fname, $pos)); if (array_key_exists($ext, $_FMCONF['iconlib'])) { $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib'][$ext]); } else { $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib']['none']); } $tpl->set_var('extension_icon', $icon); if ($i == 1) { $tpl->parse('filelisting', 'filelisting_rec'); } else { $tpl->parse('filelisting', 'filelisting_rec', true); } $i++; } } else { $tpl->set_var('folder_desc_padding_left', $filedescriptionOffset); // Version 3.0 - not presently used $tpl->parse('filelisting', 'emptyfolder'); } $data['displayhtml'] = $tpl->finish($tpl->get_var('filelisting')); $data['tagcloud'] = $tagcloud->displaycloud(); }
$tpl->parse('searchtags', 'tagsearch_rec', true); } } } else { $tpl->parse('searchtags', 'tagsearch_rec'); } $data['retcode'] = 200; $data['currentsearchtags'] = $tpl->get_var('searchtags'); nexdoc_displayTagSearchListing($tags, $data); $data['header'] = nexdoc_formatHeader($cid); $data['activefolder'] = nexdoc_displayActiveFolder(0, 'searchtags'); } else { $data['retcode'] = 200; $data['currentsearchtags'] = ''; $tagcloud = new nexfileTagCloud(); $data['tagcloud'] = $tagcloud->displaycloud(); $data['displayhtml'] = nexdocsrv_generateFileListing(0, 'latestfiles'); $data['header'] = nexdoc_formatHeader($cid); $data['activefolder'] = nexdoc_displayActiveFolder(0, 'searchtags'); } } else { $tagcloud = new nexfileTagCloud(); $data['tagcloud'] = $tagcloud->displaycloud; $data['retcode'] = 203; // Partial Information } $retval = json_encode($data); break; case 'markfavorite': if ($uid > 1) { $cid = $filter->getCleanData('int', $_POST['cid']);
$tpl->set_var('newfolder_options', nexdoc_recursiveAccessOptions('admin')); $tpl->set_var('movefolder_options', nexdoc_recursiveAccessOptions(array('upload_dir'))); $tpl->set_var('newfile_category_options', nexdoc_recursiveAccessOptions(array('upload', 'upload_dir'))); $adminFolders = nexdoc_recursiveAccessOptions('admin'); if ($adminFolders != '') { $tpl->set_var('newfolder_options', $adminFolders); $tpl->parse('newfolder_dialog', 'newfolderdiv'); $tpl->parse('newfolder_menuitem', 'newfolderlink'); } $uploadFolders = nexdoc_recursiveAccessOptions(array('upload', 'upload_dir')); if ($uploadFolders != '') { $tpl->set_var('newfile_category_options', $uploadFolders); $tpl->parse('newfile_dialog', 'newfilediv'); $tpl->parse('newfile_menuitem', 'newfilelink'); } if (SEC_hasRights('nexfile.edit')) { $tpl->parse('folderadmin_link', 'folderadminlink'); } $tagcloud = new nexfileTagCloud(); $tpl->set_var('tag_cloud', $tagcloud->displaycloud()); $tpl->parse('toolbar', 'toolbar'); $tpl->parse('filelisting_header', 'header'); $tpl->parse('file_details_panel', 'filedetails'); $tpl->parse('newfolder_dialog', 'newfolderdiv'); $tpl->parse('newfile_dialog', 'newfilediv'); $tpl->parse('movefiles_dialog', 'movefilesdiv'); $tpl->parse('moveQueuefile_dialog', 'movequeuefile'); $tpl->parse('broadcast_dialog', 'broadcast'); $tpl->parse('output', 'page'); echo $tpl->finish($tpl->get_var('output')); echo COM_siteFooter();