NAVIGATION
This shows you the differences between two versions of the page.
english:phpwcms_replacer_rts:frontend_render:xdownload [2010/05/21 01:31] Knut Heermann (flip-flop) |
english:phpwcms_replacer_rts:frontend_render:xdownload [2018/06/03 18:09] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{indexmenu_n>20}} | {{indexmenu_n>20}} | ||
- | ====== xdownload by ids, tags, folder ids ====== | + | ====== [xdownload=IDs||t:ags||f:older-IDs/] ====== |
Download rt for files from file center. | Download rt for files from file center. | ||
Line 15: | Line 15: | ||
**E.g. v1.2:** ##%%[xdownload= t: a string tag, tag05, tag06 : template, greedy, max_count, sort_by /]%%## | **E.g. v1.2:** ##%%[xdownload= t: a string tag, tag05, tag06 : template, greedy, max_count, sort_by /]%%## | ||
+ | |||
+ | **E.g. v1.3:** ##%%[xdownload= t: a string tag, tag05, tag06 : template, operator, greedy, max_count, sort_by /]%%## | ||
\\ | \\ | ||
Line 23: | Line 25: | ||
V1.2: ##%%[xdownload= t: a string tag, tag05, tag06 : x_download_01, 1, 5, ext_asc /]%%## | V1.2: ##%%[xdownload= t: a string tag, tag05, tag06 : x_download_01, 1, 5, ext_asc /]%%## | ||
+ | |||
+ | V1.3: ##%%[xdownload= t: a string tag, tag05, tag06 : x_download_01, OR, 1, 5, ext_asc /]%%## | ||
\\ | \\ | ||
Line 31: | Line 35: | ||
\\ | \\ | ||
- | **Overview file infos** //(a very special filebrowser: comming soon)//: | + | **Overview file infos** //(a very special filebrowser: [[english/other-enhancements/backend/custom-links-in-home/filebrowserx]])//: |
{{:english:phpwcms_replacer_rts:frontend_render:xdownload_filebrowser02_en_1.gif|}} | {{:english:phpwcms_replacer_rts:frontend_render:xdownload_filebrowser02_en_1.gif|}} | ||
Line 40: | Line 44: | ||
{{:english:phpwcms_replacer_rts:frontend_render:xdownload_fe02_en_1.gif|}} | {{:english:phpwcms_replacer_rts:frontend_render:xdownload_fe02_en_1.gif|}} | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ===== Short Description: ===== | ||
+ | |||
+ | |||
+ | **possible opportunities:** | ||
+ | * **Output:** template based like filelist | ||
+ | * **tag search** is "word sensitive" or "%%*all character strings*%%" [ungreedy=0|greedy=1] | ||
+ | * **logical operators** [AND|OR|NOT] if tag is selected //(V1.3) (only important in tag mode)// | ||
+ | * **max count** files are displayed [int] | ||
+ | * minimal **key lenght** [int] //(only important in tag mode)// | ||
+ | * - | ||
+ | * Optional parameter input: ":template name, AND|OR|NOT, ungreedy|greedy, max count, sort by" //(V1.2/3)// | ||
+ | * - | ||
+ | * **sort order** [string] | ||
+ | * - sort_asc / sort_desc | ||
+ | * - tstamp_asc / tstamp_desc | ||
+ | * - name_asc / name_desc | ||
+ | * - ext_asc / ext_desc | ||
+ | * - type_asc / type_desc | ||
+ | * - shortinfo_asc / shortinfo_desc | ||
+ | * - longinfo_asc / longinfo_desc | ||
+ | * - copyright_asc / copyright_desc | ||
+ | * - | ||
+ | * **file description line:** info from filecenter | ||
+ | * FILE_DESCRIPTION|FILE_NAME|FILE_TITLE|_target|WxHxC|Copyright | ||
+ | * - FILE_DESCRIPTION = long info | ||
+ | * - FILE_NAME = filename | ||
+ | * - FILE_TITLE = short info | ||
+ | * - _target = set up in RT (see in CUSTOM VAR or template) | ||
+ | * - WxHxC = set up in RT (see in CUSTOM VAR or template) | ||
+ | * - Copyright = copyright | ||
+ | * - | ||
+ | * V1.1: BB code and lang replace like [en]...[/en] [de]...[/de] available | ||
+ | |||
+ | |||
+ | \\ | ||
---- | ---- | ||
+ | ---- | ||
+ | |||
\\ | \\ | ||
+ | |||
**rt_xdownload** V1.0 14.05.10 | **rt_xdownload** V1.0 14.05.10 | ||
Line 55: | Line 100: | ||
**Update:** template 19.05.2010 KH: Optional lightBox feature inserted and small bugs removed\\ | **Update:** template 19.05.2010 KH: Optional lightBox feature inserted and small bugs removed\\ | ||
**Update:** V 1.2 20.05.2010 KH: optional parameter input by tag | **Update:** V 1.2 20.05.2010 KH: optional parameter input by tag | ||
+ | **Update:** V 1.3 21.05.2010 KH: enhanced with logical operators [AND|OR|NOT] if tag selected | ||
Line 65: | Line 111: | ||
**Tag v1.2:** \\ | **Tag v1.2:** \\ | ||
* **%%[xdownload= t: tag1, tag2, tag3 : template, greedy, max_count, sort_by /]%%** -> selected by tags | * **%%[xdownload= t: tag1, tag2, tag3 : template, greedy, max_count, sort_by /]%%** -> selected by tags | ||
- | * **%%[xdownload= f: id1, d2, d3 : template, greedy, max_count, sort_by /]%%** -> selected by folder ids | + | * **%%[xdownload= f: id1, d2, d3 : template, , max_count, sort_by /]%%** -> selected by folder ids |
- | * **%%[xdownload= id1, id2, id3 : template, greedy, max_count, sort_by /]%%** -> image ids | + | * **%%[xdownload= id1, id2, id3 : template, , max_count, sort_by /]%%** -> image ids |
* - or e.g. | * - or e.g. | ||
- | * **%%[xdownload= XX, XX, XX : template,,, sort_by /]%%** -> image ids | + | * **%%[xdownload= XX, XX, XX : template,,, sort_by /]%%** -> image ids //(The "template" is located in template/inc_cntpart/filelist/* with the name e.g. "template.html")// \\ |
* or like v1.1 | * or like v1.1 | ||
+ | |||
+ | \\ | ||
+ | |||
+ | **Tag v1.3:** \\ | ||
+ | * **%%[xdownload= t: tag1, tag2, tag3 : template, operator, greedy, max_count, sort_by /]%%** -> selected by tags | ||
+ | * **%%[xdownload= f: id1, d2, d3 : template, operator, , max_count, sort_by /]%%** -> selected by folder ids | ||
+ | * **%%[xdownload= id1, id2, id3 : template, operator, , max_count, sort_by /]%%** -> image ids | ||
Line 84: | Line 137: | ||
- | ===== Short Description: ===== | ||
- | |||
- | **possible opportunities:** | ||
- | * **Output:** template based like filelist | ||
- | * **tag search** is "word sensitive" or "%%*all character strings*%%" [ungreedy=0|greedy=1] | ||
- | * **max count** files are displayed [int] | ||
- | * minimal **key lenght** [int] | ||
- | * - | ||
- | * Optional parameter input by tag: ":template name, greedy|ungreedy, max count, sort by" //(V1.2)// | ||
- | * - | ||
- | * **sort order** [string] | ||
- | * - sort_asc / sort_desc | ||
- | * - tstamp_asc / tstamp_desc | ||
- | * - name_asc / name_desc | ||
- | * - ext_asc / ext_desc | ||
- | * - type_asc / type_desc | ||
- | * - shortinfo_asc / shortinfo_desc | ||
- | * - longinfo_asc / longinfo_desc | ||
- | * - copyright_asc / copyright_desc | ||
- | * - | ||
- | * **file description line:** info from filecenter | ||
- | * FILE_DESCRIPTION|FILE_NAME|FILE_TITLE|_target|WxHxC|Copyright | ||
- | * - FILE_DESCRIPTION = long info | ||
- | * - FILE_NAME = filename | ||
- | * - FILE_TITLE = short info | ||
- | * - _target = set up in RT (see in CUSTOM VAR or template) | ||
- | * - WxHxC = set up in RT (see in CUSTOM VAR or template) | ||
- | * - Copyright = copyright | ||
- | * - | ||
- | * V1.1: BB code and lang replace like [en]...[/en] [de]...[/de] available | ||
- | |||
- | |||
- | \\ | ||
- | ---- | ||
- | ---- | ||
- | |||
- | \\ | ||
===== PHP v1.1: ===== | ===== PHP v1.1: ===== | ||
Line 132: | Line 148: | ||
/** | /** | ||
* ***************************************************************************** | * ***************************************************************************** | ||
- | * 14.05.2010 K.Heermann http://planmatrix.de | + | * 14.05.2010 V1.1 K.Heermann http://planmatrix.de |
* Update 18.05.2010 V1.1: Update parsing bbcode and call lang_replace if available | * Update 18.05.2010 V1.1: Update parsing bbcode and call lang_replace if available | ||
* | * | ||
Line 165: | Line 181: | ||
* - Copyright = copyright | * - Copyright = copyright | ||
* | * | ||
+ | * http://www.phpwcms-howto.de/wiki/doku.php/english/phpwcms_replacer_rts/frontend_render/xdownload | ||
* ***************************************************************************** | * ***************************************************************************** | ||
*/ | */ | ||
Line 186: | Line 203: | ||
$download_template = 'x_download.html'; // template in "template/inc_cntpart/filelist/*" | $download_template = 'x_download.html'; // template in "template/inc_cntpart/filelist/*" | ||
- | $key_lenght = 2; //Min lenght of entry | + | $key_lenght = 1; //Min lenght of entry |
$max_count = ''; // Max count of files | $max_count = ''; // Max count of files | ||
Line 462: | Line 479: | ||
/** | /** | ||
* ***************************************************************************** | * ***************************************************************************** | ||
- | * 14.05.2010 K.Heermann http://planmatrix.de | + | * 14.05.2010 V1.2 K.Heermann http://planmatrix.de |
* Update 18.05.2010 V1.1: Update parsing bbcode and call lang_replace if available | * Update 18.05.2010 V1.1: Update parsing bbcode and call lang_replace if available | ||
* Update 20.05.2010 V1.2: Update optional parameter input by tag | * Update 20.05.2010 V1.2: Update optional parameter input by tag | ||
Line 505: | Line 522: | ||
* - Copyright = copyright | * - Copyright = copyright | ||
* | * | ||
+ | * http://www.phpwcms-howto.de/wiki/doku.php/english/phpwcms_replacer_rts/frontend_render/xdownload | ||
* ***************************************************************************** | * ***************************************************************************** | ||
*/ | */ | ||
Line 534: | Line 552: | ||
$download_template = 'x_download.html'; // template in "template/inc_cntpart/filelist/*" | $download_template = 'x_download.html'; // template in "template/inc_cntpart/filelist/*" | ||
- | $key_lenght = 2; //Min lenght of entry | + | $key_lenght = 1; //Min lenght of entry |
$max_count = ''; // Max count of files | $max_count = ''; // Max count of files | ||
Line 783: | Line 801: | ||
// [xdownload= t: tag1, tag2, tag3:template,greedy,max_count,sort_by/] | // [xdownload= t: tag1, tag2, tag3:template,greedy,max_count,sort_by/] | ||
+ | |||
+ | $content["all"] = preg_replace_callback('/\[xdownload=(.*?)\/\]/i', 'parse_xdownloads', $content["all"]); | ||
+ | //$content["all"] = preg_replace_callback('/\[xdownload=(.*?)\](.*?)\[\/xdownload\]/is', 'parse_xdownloads', $content["all"]); | ||
+ | |||
+ | |||
+ | // if ../frontend_render/lang_replace.php is available, then call it a second time on the safe side | ||
+ | if (is_file(PHPWCMS_TEMPLATE.'inc_script/frontend_render/lang_replace.php')) | ||
+ | include(PHPWCMS_TEMPLATE.'inc_script/frontend_render/lang_replace.php'); | ||
+ | |||
+ | ?> | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | ===== PHP v1.3: ===== | ||
+ | |||
+ | **Update 21.05.2010 V1.3:** enhanced with logical operators [AND|OR|NOT] if tag selected | ||
+ | * [xdownload= t: tag1, tag2, tag3 : template, operator, greedy, max_count, sort_by /] | ||
+ | * e.g. | ||
+ | * [xdownload= t: tag1, tag2, tag3 : x_download_01, AND, 1, 5, ext_asc /] | ||
+ | * tag1, tag2, tag3 : search by tag : using the template x_download_01.html, AND logical linked, all character strings from tag, sort by file extension | ||
+ | * (In this case "x_download_01" is the name of file in template/inc_cntpart/filelist/ without an extend). | ||
+ | \\ | ||
+ | **File:** template/inc_script/frontend_render/rt_xdownload.php | ||
+ | |||
+ | |||
+ | <code php |h rt_xdownload |h > | ||
+ | <?php | ||
+ | /** | ||
+ | * ***************************************************************************** | ||
+ | * 14.05.2010 V1.0 K.Heermann http://planmatrix.de | ||
+ | * Update 18.05.2010 V1.1: parsing bbcode and call lang_replace if available | ||
+ | * Update 20.05.2010 V1.2: optional parameter input by tag | ||
+ | * + template name, greedy|ungreedy, max count, sort by | ||
+ | * + e.g.: | ||
+ | * + [xdownload= t: tag1, tag2, tag3 : template, greedy, max_count, sort_by /] // tags | ||
+ | * + If there is no parameter, the default values from script are catched | ||
+ | * | ||
+ | * Update 21.05.2010 V1.3: enhanced with logical operators [AND|OR|NOT] if tag selected | ||
+ | * + e.g.: | ||
+ | * + [xdownload= t: tag1, tag2, tag3 : template, operator, greedy, max_count, sort_by /] // tags | ||
+ | * | ||
+ | * | ||
+ | * File download selected by Tags or image ids or filecenter folder id | ||
+ | * | ||
+ | * Tags v1.1: | ||
+ | * - [xdownload= t: tag1, tag2, tag3/] // tags | ||
+ | * - [xdownload= f: id1, id2, id3/] // folder ids | ||
+ | * - [xdownload= id1, id2, id3/] // image ids | ||
+ | * | ||
+ | * Tags v1.2: | ||
+ | * - [xdownload= t: tag1, tag2, tag3 : template, greedy, max_count, sort_by/] // tags | ||
+ | * - [xdownload= f: id1, id2, id3 : template, , max_count, sort_by/] // folder ids | ||
+ | * - [xdownload= id1, id2, id3 : template, , max_count, sort_by/] // image ids | ||
+ | * | ||
+ | * Tags v1.3: | ||
+ | * - [xdownload= t: tag1, tag2, tag3 : template, operator, greedy, max_count, sort_by/] // tags | ||
+ | * - [xdownload= f: id1, id2, id3 : template, , , max_count, sort_by/] // folder ids | ||
+ | * - [xdownload= id1, id2, id3 : template, , , max_count, sort_by/] // image ids | ||
+ | * | ||
+ | * possible opportunities: | ||
+ | * - Output: template based like filelist | ||
+ | * - tag search is "word sensitive" or "all character strings" [ungreedy|greedy] | ||
+ | * - tags search in dependence from operator [AND|OR|NOT] // OR = default | ||
+ | * - max_count = maximum number of output | ||
+ | * | ||
+ | * - sort order | ||
+ | * - sort_asc / sort_desc | ||
+ | * - tstamp_asc / tstamp_desc | ||
+ | * - name_asc / name_desc | ||
+ | * - ext_asc / ext_desc | ||
+ | * - type_asc / type_desc | ||
+ | * - shortinfo_asc / shortinfo_desc | ||
+ | * - longinfo_asc / longinfo_desc | ||
+ | * - copyright_asc / copyright_desc | ||
+ | * | ||
+ | * - file description line: info from filecenter | ||
+ | * FILE_DESCRIPTION|FILE_NAME|FILE_TITLE|_target|WxHxC|Copyright | ||
+ | * - FILE_DESCRIPTION = long info | ||
+ | * - FILE_NAME = filename | ||
+ | * - FILE_TITLE = short info | ||
+ | * - _target = set up in RT (see in CUSTOM VAR or template) | ||
+ | * - WxHxC = set up in RT (see in CUSTOM VAR or template) | ||
+ | * - Copyright = copyright | ||
+ | * | ||
+ | * http://www.phpwcms-howto.de/wiki/doku.php/english/phpwcms_replacer_rts/frontend_render/xdownload | ||
+ | * ***************************************************************************** | ||
+ | */ | ||
+ | // ----------------------------------------------------------------------------- | ||
+ | // obligate check for phpwcms constants | ||
+ | if (!defined('PHPWCMS_ROOT')) { | ||
+ | die("You Cannot Access This Script Directly, Have a Nice Day."); } | ||
+ | // ----------------------------------------------------------------------------- | ||
+ | |||
+ | |||
+ | |||
+ | function parse_xdownloads($match) { | ||
+ | |||
+ | if(isset($match[1])) { | ||
+ | |||
+ | $param = explode(':', $match[1]); | ||
+ | |||
+ | foreach ($param as $key => $val) // kill all begin/end spaces | ||
+ | $param[$key] = trim($val); | ||
+ | |||
+ | if ( strtolower($param[0]) !== 't' AND strtolower($param[0]) !== 'f' ) { | ||
+ | array_unshift($param, "i"); // fill up the first place in array | ||
+ | } | ||
+ | |||
+ | // =============== CUSTOM VAR ================================================== | ||
+ | // Tag: [xdownload= t: tag1, tag2, tag3 : template, operator, greedy, max_count, sort_by /] | ||
+ | |||
+ | |||
+ | $download_template = 'x_download.html'; // template in "template/inc_cntpart/filelist/*" | ||
+ | |||
+ | $key_lenght = 1; //Min lenght of entry | ||
+ | |||
+ | $max_count = ''; // Max count of files | ||
+ | |||
+ | $sort_by = 'sort_asc'; // Sort order | ||
+ | |||
+ | // sort_asc / sort_desc: f_sort -> sort field | ||
+ | // tstamp_asc / tstamp_desc: f_tstamp -> Timestamp | ||
+ | // name_asc / name_desc: f_name -> Filename | ||
+ | // ext_asc / ext_desc: f_ext -> File extension | ||
+ | // type_asc / type_desc: f_type -> File type | ||
+ | // shortinfo_asc / shortinfo_desc: f_shortinfo -> Short info | ||
+ | // longinfo_asc / longinfo_desc: f_longinfo -> Long info | ||
+ | // copyright_asc / copyright_desc: f_copyright -> Copyright | ||
+ | |||
+ | $operator = 'OR'; // if tag is selected [AND|OR|NOT] (Uppercase letter!!) | ||
+ | |||
+ | $greedy = 1; // [0|1] [ungreedy|greedy] = [word sensitive | all character strings] | ||
+ | |||
+ | $WxHxC = ''; // e.g. 100x100x1 [Width x Height x Crop] if there is an image | ||
+ | $_target = '_self'; | ||
+ | |||
+ | // =============== END CUSTOM VAR ============================================== | ||
+ | |||
+ | if (count($param) >= 2) $keywords = $param[1]; | ||
+ | |||
+ | if (count($param) === 3) { // parameter available | ||
+ | |||
+ | $cparam = explode(',',$param[2]); | ||
+ | |||
+ | foreach ($cparam as $key => $val) // kill all begin/end spaces | ||
+ | $cparam[$key] = trim($val); | ||
+ | |||
+ | $download_template = (empty($cparam[0])) ? $download_template : strip_tags($cparam[0]).'.html'; | ||
+ | $operator = (empty($cparam[1])) ? $operator : strtoupper(strip_tags($cparam[1])); | ||
+ | $greedy = (empty($cparam[2]) AND ($cparam[1] != '0')) ? $greedy : intval($cparam[2]); // Update 21.05.10 | ||
+ | $max_count = (empty($cparam[3])) ? $max_count : intval($cparam[3]); // Update 21.05.10 | ||
+ | $sort_by = (empty($cparam[4])) ? $sort_by : strtolower(strip_tags($cparam[4])); | ||
+ | } | ||
+ | |||
+ | switch ($param[0]) { | ||
+ | |||
+ | case 'f': $flag = 'folder'; break; | ||
+ | |||
+ | case 't': $flag = 'tag'; | ||
+ | // $key_lenght = 3; // Min lenght of tag word | ||
+ | if ($greedy) { | ||
+ | // $where .= "f_tags LIKE '%".aporeplace($val)."%'"; // greedy | ||
+ | $f_tags['1'] = "LIKE '%"; | ||
+ | $f_tags['2'] = "%'"; | ||
+ | } else { | ||
+ | // $where .= "f_tags REGEXP '[[:<:]]".aporeplace($val)."[[:>:]]'"; // ungreedy | ||
+ | $f_tags['1'] = "REGEXP '[[:<:]]"; | ||
+ | $f_tags['2'] = "[[:>:]]'"; | ||
+ | } | ||
+ | |||
+ | break; | ||
+ | |||
+ | default: $flag = 'id'; break; // default = id | ||
+ | } | ||
+ | |||
+ | // ============ front.func.inc.php: function get_related_articles | ||
+ | |||
+ | // keywords: string with separated tags | ||
+ | |||
+ | // replace unwanted chars and convert to wanted | ||
+ | $keywords = str_replace(";", ",", $keywords); | ||
+ | $keywords = str_replace("'", "", $keywords); | ||
+ | // if (!$greedy) $keywords = str_replace(" ", ",", $keywords); // disabled 21.05.10 | ||
+ | $keywords = str_replace(",,", ",", $keywords); | ||
+ | |||
+ | // choose comma separated keywords | ||
+ | $keywordarray = explode (",", $keywords); | ||
+ | $keywordarray = array_map('trim', $keywordarray); | ||
+ | $keywordarray = array_diff($keywordarray, array('')); | ||
+ | $keywordarray = array_unique($keywordarray); | ||
+ | $keywordarray = array_map('strtoupper', $keywordarray); | ||
+ | // check for empty keywords or keywords smaller than 3 chars | ||
+ | if(is_array($keywordarray) && count($keywordarray)) { | ||
+ | foreach($keywordarray as $key => $val) { | ||
+ | |||
+ | if(substr($keywordarray[$key], 0, 1) == '-') { | ||
+ | $doNotUse = substr($keywordarray[$key], 1); | ||
+ | foreach($keywordarray as $key2 => $val2) { | ||
+ | if($doNotUse == $val2) { | ||
+ | unset($keywordarray[$key2]); | ||
+ | unset($keywordarray[$key]); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if ( isset($keywordarray[$key]) && | ||
+ | ( strlen($keywordarray[$key]) < $key_lenght || | ||
+ | empty($keywordarray[$key]) ) | ||
+ | ) { | ||
+ | |||
+ | unset($keywordarray[$key]); | ||
+ | } | ||
+ | // val into integer if no tag | ||
+ | if ($flag != 'tag') $keywordarray[$key] = intval($keywordarray[$key]); | ||
+ | } | ||
+ | } | ||
+ | // ============ | ||
+ | |||
+ | |||
+ | |||
+ | if(is_array($keywordarray) && count($keywordarray)) { | ||
+ | |||
+ | $where = ''; | ||
+ | |||
+ | if ($flag =='tag') { | ||
+ | |||
+ | $first_op = ''; | ||
+ | |||
+ | if (in_array($operator, array('AND','OR','NOT'))) { // Update 21.05.10 | ||
+ | |||
+ | if ($operator == 'NOT') { | ||
+ | $operator = 'AND NOT'; | ||
+ | $first_op = 'NOT '; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | foreach($keywordarray as $val) { | ||
+ | //build where keyword = blabla | ||
+ | $where .= ($where) ? " $operator " : "$first_op"; | ||
+ | |||
+ | //replace every "'" to "''" for security reasons with aporeplace() | ||
+ | // $where .= "f_tags LIKE '%".aporeplace($val)."%'"; | ||
+ | $where .= " f_tags ".$f_tags['1'].aporeplace($val).$f_tags['2']; // [greedy|ungreedy] | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if ($flag =='folder') { | ||
+ | |||
+ | $val = implode('","', $keywordarray); | ||
+ | |||
+ | $where .= 'f_pid IN ("'.$val.'")'; // | ||
+ | } | ||
+ | |||
+ | if ($flag =='id') { | ||
+ | |||
+ | $val = implode('","', $keywordarray); | ||
+ | |||
+ | $where .= 'f_id IN ("'.$val.'")'; // | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | $limit = ($max_count) ? " LIMIT ".$max_count : ""; | ||
+ | $sql = "SELECT f_id, f_pid, f_tags, f_name, f_shortinfo, f_longinfo, f_copyright "; | ||
+ | $sql .= "FROM ".DB_PREPEND."phpwcms_file "; | ||
+ | $sql .= "WHERE f_aktiv=1 AND f_public=1 AND f_trash=0 AND f_kid=1 AND "; | ||
+ | $sql .= "(".$where.") "; | ||
+ | |||
+ | if(empty($sort_by)) $sort_by = ''; | ||
+ | |||
+ | switch($sort_by) { | ||
+ | |||
+ | case 'sort_asc': $sql .= "ORDER BY f_sort"; break; | ||
+ | case 'sort_desc': $sql .= "ORDER BY f_sort DESC"; break; | ||
+ | |||
+ | case 'tstamp_asc': $sql .= "ORDER BY f_tstamp"; break; | ||
+ | case 'tstamp_desc': $sql .= "ORDER BY f_tstamp DESC"; break; | ||
+ | |||
+ | case 'name_asc': $sql .= "ORDER BY f_name"; break; | ||
+ | case 'name_desc': $sql .= "ORDER BY f_name DESC"; break; | ||
+ | |||
+ | case 'ext_asc': $sql .= "ORDER BY f_ext"; break; | ||
+ | case 'ext_desc': $sql .= "ORDER BY f_ext DESC"; break; | ||
+ | |||
+ | case 'type_asc': $sql .= "ORDER BY f_type"; break; | ||
+ | case 'type_desc': $sql .= "ORDER BY f_type DESC"; break; | ||
+ | |||
+ | case 'shortinfo_asc': $sql .= "ORDER BY f_shortinfo"; break; | ||
+ | case 'shortinfo_desc': $sql .= "ORDER BY f_shortinfo DESC"; break; | ||
+ | |||
+ | case 'longinfo_asc': $sql .= "ORDER BY f_longinfo"; break; | ||
+ | case 'longinfo_desc': $sql .= "ORDER BY f_longinfo DESC"; break; | ||
+ | |||
+ | case 'copyright_asc': $sql .= "ORDER BY f_copyright"; break; | ||
+ | case 'copyright_desc': $sql .= "ORDER BY f_copyright DESC"; break; | ||
+ | |||
+ | default: $sql .= "ORDER BY f_pid DESC"; | ||
+ | } | ||
+ | |||
+ | $sql .= $limit.';'; | ||
+ | |||
+ | // Read database | ||
+ | $result = _dbQuery($sql); | ||
+ | |||
+ | $id =''; // using for transfer into filelist cp | ||
+ | // ------------------------------------------------ | ||
+ | $caption = ''; // FILE_DESCRIPTION|FILE_NAME|FILE_TITLE|_target|WxHxC|Copyright | ||
+ | // check if info for the file is available | ||
+ | // [0] = normal file description like before | ||
+ | // [1] = name the file (it's not the file name) | ||
+ | // [2] = title | ||
+ | // [3] = target (where to open a new file -> default is _blank even if empty | ||
+ | // [4] = if it is an image try to show a thumbnail instead of the file icon -> here thumbnail WIDTHxHEIGHT | ||
+ | // [5] = copyright information | ||
+ | // ------------------------------------------------ | ||
+ | |||
+ | if(isset($result[0])) { | ||
+ | |||
+ | foreach($result as $row) { | ||
+ | |||
+ | $id .= ','.$row['f_id']; | ||
+ | |||
+ | // catch all informations for caption | ||
+ | $caption .= str_replace(LF,'',$row['f_longinfo']).'|'. | ||
+ | $row['f_name'].'|'. | ||
+ | $row['f_shortinfo'].'|'. | ||
+ | $_target.'|'. | ||
+ | $WxHxC.'|'. | ||
+ | $row['f_copyright'].LF; | ||
+ | } | ||
+ | } | ||
+ | if ($id) $id = substr($id, 1); // Kill first comma | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | // ============ END front.func.inc.php: function get_related_articles | ||
+ | |||
+ | |||
+ | |||
+ | $value = array(); | ||
+ | |||
+ | // IDs for transfer to file list basic function | ||
+ | $value['cnt_object']['cnt_files']['id'] = convertStringToArray($id); | ||
+ | |||
+ | if(isset($value['cnt_object']['cnt_files']['id']) && is_array($value['cnt_object']['cnt_files']['id']) && count($value['cnt_object']['cnt_files']['id'])) | ||
+ | { | ||
+ | global $phpwcms; | ||
+ | |||
+ | $IS_NEWS_CP = true; | ||
+ | |||
+ | $news = array(); | ||
+ | $news['files_result'] = ''; | ||
+ | |||
+ | $crow = array(); | ||
+ | |||
+ | //$caption = 'FILE_DESCRIPTION|FILE_NAME|FILE_TITLE|_target|100x100x1|Copyright Text'.LF; | ||
+ | $value['cnt_object']['cnt_files']['caption'] = isset($caption) ? @html_entity_decode(trim($caption), ENT_QUOTES, PHPWCMS_CHARSET) : ''; | ||
+ | $value['files_direct_download'] = 0; | ||
+ | $value['files_template'] = $download_template; | ||
+ | |||
+ | // include content part files renderer | ||
+ | include(PHPWCMS_ROOT.'/include/inc_front/content/cnt7.article.inc.php'); | ||
+ | |||
+ | return render_bbcode_basics($news['files_result']); // parse the bbcode and return | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | return ''; | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | // [xdownload= t: tag1, tag2, tag3:template,operator,greedy,max_count,sort_by/] | ||
$content["all"] = preg_replace_callback('/\[xdownload=(.*?)\/\]/i', 'parse_xdownloads', $content["all"]); | $content["all"] = preg_replace_callback('/\[xdownload=(.*?)\/\]/i', 'parse_xdownloads', $content["all"]); | ||
Line 799: | Line 1195: | ||
===== Template: ===== | ===== Template: ===== | ||
- | Update: 19.05.2010 KH: optional lightBox feature inserted and small bugs removed | + | **Update: 19.05.2010 KH:** optional lightBox feature inserted and small bugs removed |
**File:** template/inc_cntpart/filelist/x_download.html | **File:** template/inc_cntpart/filelist/x_download.html |