{{indexmenu_n>25}} ====== [xdownload=IDs||t:ags||f:older-IDs/] ====== FIXME translate Download Replacement TAG für Dateien aus der Dateizentrale. Mögliche Auswahl für den Datei-download: **TAGs** oder **Bilder-IDs** oder **Verzeichnis-IDs**. Die Beschreibungen für, Dateiname, Copyright, ...., kommen direkt aus der Dateinzentrale. Die Ausgabe wird generiert durch die Basisfunktion vom CP Dateiliste. **Z.B. v1.1:** ##%%[xdownload= t: Eine Zeichenkette als tag, tag05, tag06/]%%## **Z.B. v1.2:** ##%%[xdownload= t: Eine Zeichenkette als tag, tag05, tag06 : Template, gierig, max.-Anzahl, Sortierreihenfolge /]%%## **Z.B. v1.3:** ##%%[xdownload= t: Eine Zeichenkette als tag, tag05, tag06 : Template, Operator, gierig, max.-Anzahl, Sortierreihenfolge /]%%## \\ **Backend** z.B. CP Einfacher Text: {{:english:phpwcms_replacer_rts:frontend_render:xdownload_be02_en_1.gif|}} 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 /]%%## \\ **Dateizentrale:** {{:english:phpwcms_replacer_rts:frontend_render:xdownload_filecenter01_en_1.gif|}} \\ **Übersicht Dateiinformationen** //(ein sehr spezieller Datei-Brwoser: [[deutsch/andere-erweiterungen/backend/custom-links-in-home/filebrowserx]])//: {{:english:phpwcms_replacer_rts:frontend_render:xdownload_filebrowser02_en_1.gif|}} \\ **Frontend** Ausgabe mit einem Template vom CP Dateiliste: {{:english:phpwcms_replacer_rts:frontend_render:xdownload_fe02_en_1.gif|}} \\ ===== Kurze Beschreibung: ===== **Mögliche Einstellungen:** * **Ausgabe:** Template basierend auf dem CP Dateiliste * **"tag"-Suche** ist "wortsensitiv" oder "%%*alle Zeichenketten*%%" [nicht gierig=0|gierig=1] * **Logische Operatoren** [AND|OR|NOT] wenn "tag" ausgewählt ist //(V1.3) (nur wichtig im "tag"-Modus)// * **Max.-Anzahl** Dateien werden angezeigt [int] * minimale **Schlüssellänge** [int] //(nur wichtig im "tag"-Modus)// wird im Script eingestellt * - * Optionale Parametereingabe: ":Templatename, AND|OR|NOT, nicht gierig|gierig, max.-Anzahl, Sortierreihenfolge" //(V1.2/3)// * - * **Sortierreihenfolge** [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 (bitte in CUSTOM VAR oder Template nachsehen) * - WxHxC = set up in RT (bitte in CUSTOM VAR oder Template nachsehen) * - Copyright = copyright * - * V1.1: BB Code und "lang" ersetzen wie [en]...[/en] [de]...[/de] möglich \\ ---- ---- \\ **rt_xdownload** V1.0 14.05.2010 Docu: -- \\ Forum: [[http://forum.phpwcms.org/viewtopic.php?p=124320]] **Autor:** K.Heermann (flip-flop) http://planmatrix.de \\ **CMS Version:** >= 1.46 r402 \\ **Version:** V1.0 \\ **Update:** V 1.1 18.05.2010 KH: Interpretieren von bbcode und "lang_replace" wenn vorhanden möglich \\ **Update:** Template 19.05.2010 KH: Optionales lightBox-Feature eingefügt und einige kleine Fehler beseitigt \\ **Update:** V 1.2 20.05.2010 KH: Optionale Parametereingabe über den RT \\ **Update:** V 1.3 21.05.2010 KH: Erweitert mit den logischen Operatoren [AND|OR|NOT] wenn mit tags selektiert wird **Tag v1.1:** \\ * **%%[xdownload= t: tag1, tag2, tag3/]%%** -> Selektion mit tags * **%%[xdownload= f: id1, d2, d3/]%%** -> Selektion mit Verzeichnis-IDs * **%%[xdownload= id1, id2, id3/]%%** -> Bilder-IDs \\ **Tag v1.2:** \\ * **%%[xdownload= t: tag1, tag2, tag3 : template, greedy, max_count, sort_by /]%%** -> Selektion mit tags * **%%[xdownload= f: id1, d2, d3 : template, , max_count, sort_by /]%%** -> Selektion mit Verzeichnis-IDs * **%%[xdownload= id1, id2, id3 : template, , max_count, sort_by /]%%** -> Bilder-IDs * - oder z.B. * **%%[xdownload= XX, XX, XX : template,,, sort_by /]%%** -> Bilder-IDs //(Das "Template" befindet sich in template/inc_cntpart/filelist/* mit dem Namen z.B. "template.html")// \\ * oder wie V1.1 \\ **Tag v1.3:** \\ * **%%[xdownload= t: tag1, tag2, tag3 : template, operator, greedy, max_count, sort_by /]%%** -> Selektion mit tags * **%%[xdownload= f: id1, d2, d3 : template, operator, , max_count, sort_by /]%%** -> Selektion mit Verzeichnis-IDs * **%%[xdownload= id1, id2, id3 : template, operator, , max_count, sort_by /]%%** -> Bilder-IDs \\ Dateiname: **rt_xdownload.php** Verzeichnis: ** template/inc_script/frontend_render/ ** **Bedingung:** -> [[http://www.phpwcms-docu.de/confincphp_de.phtml|/config/phpwcms/conf.inc.php]] \\ * ##$phpwcms['allow_ext_render'] = 1;## \\ ===== PHP v1.1: ===== **Datei:** template/inc_script/frontend_render/rt_xdownload.php 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 $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 ============================================== $flag = 'id'; // default = id // using folders? if (stripos($match[1], 'f:') !== false) { $match[1] = preg_replace('/^\s*f:\s*(.*?)/i','$1',$match[1]); $flag = 'folder'; } // using tags? elseif (stripos($match[1], 't:') !== false) { $match[1] = preg_replace('/^\s*t:\s*(.*?)/i','$1',$match[1]); $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'] = "[[:>:]]'"; } } // ============ front.func.inc.php: function get_related_articles // keywords: string with separated tags $keywords = $match[1]; // replace unwanted chars and convert to wanted $keywords = str_replace(";", ",", $keywords); $keywords = str_replace("'", "", $keywords); if (!$greedy) $keywords = str_replace(" ", ",", $keywords); $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') { foreach($keywordarray as $val) { //build where keyword = blabla $where .= ($where) ? " OR " : ""; //replace every "'" to "''" for security reasons with aporeplace() $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 $caption = @html_entity_decode(trim($caption), ENT_QUOTES, PHPWCMS_CHARSET); } // ============ 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 ''; } $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'); ?> \\ ===== PHP v1.2: ===== **Update 20.05.2010 V1.2:** Optional: Parametereingabe über den RT-Aufruf * [xdownload= t: tag1, tag2, tag3 : template, greedy, max_count, sort_by /] * e.g. * [xdownload= t: tag1, tag2, tag3 : x_download_01, 1, 5, ext_asc /] * tag1, tag2, tag3 : Suche mit tags : verwende das Template x_download_01.html, alle Zeichenketten fom tag, sortiert nach Datei-Extension * (In diesem Fall ist "x_download_01" der Name der Datei in template/inc_cntpart/filelist/ ohne Extend). \\ **Datei:** template/inc_script/frontend_render/rt_xdownload.php $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, 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 $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'; $greedy = (empty($cparam[1])) ? $greedy : intval($cparam[1]); $max_count = (empty($cparam[2])) ? $max_count : intval($cparam[2]); $sort_by = (empty($cparam[3])) ? $sort_by : strtolower(strip_tags($cparam[3])); } 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); $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') { foreach($keywordarray as $val) { //build where keyword = blabla $where .= ($where) ? " OR " : ""; //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,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'); ?> \\ ===== PHP v1.3: ===== **Update 21.05.2010 V1.3:** Erweitert durch die logischen Operatoren [AND|OR|NOT] wenn mit tags selektiert wird * [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). \\ **Datei:** template/inc_script/frontend_render/rt_xdownload.php $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=(.*?)\](.*?)\[\/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'); ?> \\ ===== Template: ===== **Update: 19.05.2010 KH:** optional lightBox feature inserted and small bugs removed **File:** template/inc_cntpart/filelist/x_download.html ; this is formatted like WIN.INI ; please: do not use comments for value lines icon_path = "img/icons/" icon_name = "small_icon_{FILE_EXT}.gif" thumbnail = 1 thumbnail_width = 50 thumbnail_height = 50 thumbnail_crop = 1 lightbox_init = 0 file_size_round = 1 file_size_space = " " date_format = "%d.%m.%y" set_locale = "de_DE@Euro"

[FILE_IMAGE_ELSE][/FILE_IMAGE_ELSE] [FILE_IMAGE] [/FILE_IMAGE] [FILE_TITLE]{FILE_TITLE}[/FILE_TITLE][FILE_TITLE_ELSE]{FILE_NAME}[/FILE_TITLE_ELSE]

[FILE_DESCRIPTION] {FILE_DESCRIPTION}
[/FILE_DESCRIPTION][FILE_COPYRIGHT]

Copyright: {FILE_COPYRIGHT}
[/FILE_COPYRIGHT]

{FILE_EXT}, {FILE_SIZE}, {FILE_DATE}, {FILE_DOWNLOADS} downloads (XDownload) [FILE_IMAGE][FILE_IMAGE_WIDTH] width: {FILE_IMAGE_WIDTH}px, height: {FILE_IMAGE_HEIGHT}px
mode: {FILE_IMAGE_CHANNEL}, MIME type: {FILE_IMAGE_MIME}
format: [FILE_IMAGE_LANDSCAPE]landscape[/FILE_IMAGE_LANDSCAPE][FILE_IMAGE_PORTRAIT]portrait[/FILE_IMAGE_PORTRAIT] [/FILE_IMAGE_WIDTH][/FILE_IMAGE]