Differences

This shows you the differences between two versions of the page.

deutsch:ersetzer_rts:frontend_render:newx [2012/02/10 20:24]
Knut Heermann (flip-flop)
deutsch:ersetzer_rts:frontend_render:newx [2018/06/03 18:09] (current)
Line 4: Line 4:
===== {NEWX: Listenzähler : Kategorie-IDs : Schlüsselwörter : Modus  [:versteckte Kategorien]} ===== ===== {NEWX: Listenzähler : Kategorie-IDs : Schlüsselwörter : Modus  [:versteckte Kategorien]} =====
- 
-FIXME Beta -> bitte testen 
Original-TAG [[http://www.phpwcms-docu.de/link_tags_.phtml|{NEW:Anzahl_angezeigter_Links:ID}]] erweitert um die Möglichkeit in mehreren Kategorien nach Artikelschlüsselwörtern zu suchen. \\ Original-TAG [[http://www.phpwcms-docu.de/link_tags_.phtml|{NEW:Anzahl_angezeigter_Links:ID}]] erweitert um die Möglichkeit in mehreren Kategorien nach Artikelschlüsselwörtern zu suchen. \\
Line 56: Line 54:
    * **{NEWX: Listenzähler : Kategorie-IDs : Schlüsselwörter : Modus : versteckte Kategorien}** \\ **{NEWX:5:3::1:1}**  -> //Suche ohne Artikelschlüsselwörter in der Kategorie-ID=3 und den darunterliegenden Kategorien auch wenn diese versteckt sind //     * **{NEWX: Listenzähler : Kategorie-IDs : Schlüsselwörter : Modus : versteckte Kategorien}** \\ **{NEWX:5:3::1:1}**  -> //Suche ohne Artikelschlüsselwörter in der Kategorie-ID=3 und den darunterliegenden Kategorien auch wenn diese versteckt sind //
 +  * **Update** V1.1 14.02.2012: Wenn eines der Schlüsselwörter %%"hidden" oder "versteckt"%% im Kategoriefeld %%"Schlüsselwörter"%% eingetragen ist, werden die Artikel dieser Kategorie nicht angezeigt. Der Kategorieschalter %%"[x] versteckt"%% muss dazu nicht gesetzt sein.
 +
 +\\
Z.B.: Z.B.:
Line 401: Line 402:
===== Script V 1.0 ===== ===== Script V 1.0 =====
-  * Update V1.0 08.02.2012: Erweitert um auch Artikel in Versteckten Kategorien anzeigen zu können [:0|:1]+**Update V1.0 08.02.2012**: Erweitert um auch Artikel in Versteckten Kategorien anzeigen zu können [:0|:1]
    * {NEWX: Listenzähler : Kategorie-IDs : Schlüsselwörter : Modus : versteckte Kategorien}     * {NEWX: Listenzähler : Kategorie-IDs : Schlüsselwörter : Modus : versteckte Kategorien}
Line 416: Line 417:
**Datei:** template/inc_script/frontend_render/rt_newx.php **Datei:** template/inc_script/frontend_render/rt_newx.php
-<code php|h {NEWX:count:category-IDs:key words:mode} |h>+<code php|h {NEWX:count:category-IDs:key words:mode:hidden} |h>
<?php <?php
/******************************************************************************************* /*******************************************************************************************
Line 772: Line 773:
</code> </code>
 +\\
 +
 +===== Script V 1.1 =====
 +
 +
 +**Update V1.1 14.02.2012**: Wie V1.0, zusätzlich
 +  * Wenn eines der Schlüsselwörter %%"hidden" oder "versteckt"%% im Kategoriefeld %%"Schlüsselwörter"%% eingetragen ist, werden die Artikel dieser Kategorie nicht angezeigt. Der Kategorieschalter %%"[x] versteckt"%% ist dazu nicht notwendig.
 +    * Um die Artikel einer bestimmten Kategorie auszublenden, die nicht als %%"[x] versteckt"%% markiert ist können die beiden Schlüsselwörter %%"hidden" oder "versteckt"%% im Kategoriefeld Schlüsselwörter verwendet werden. \\ Diese Kategorie würde in der NAVI auftauchen, da nicht versteckt, die Artikel dieser Kategorie tauchen in der NEW-Liste jedoch nicht auf.
 +    * Andersherum, wird der Schalter %%"versteckte Kategorien einbeziehen"%% im TAG gesetzt, wurden bisher die Artikel aller Kategorien ausgegeben. Auch von versteckten Kategorien die eigentlich eher systemtechnische Aufgaben habe, wie z.B. das Beherbergen versteckter CPs die mit SHOW_CONTENT hochgeholt werden. \\ Mit den beiden Keywords %%"hidden" oder "versteckt"%% kann die Artikelanzeige in NEW generell für die betreffende Kategorie abgeschaltet werden, ohne den Artikel auf %%"nicht sichbar"%% zu setzen.
 +
 +\\
 +**Datei:** template/inc_script/frontend_render/rt_newx.php
 +
 +<code php|h {NEWX:count:category-IDs:key words:mode:hidden} |h>
 +<?php
 +/*******************************************************************************************
 +   Copyright notice
 +  
 +   (c) 2002-2012 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
 + 
 +   This script is part of PHPWCMS. The PHPWCMS web content management system is
 +   free software; you can redistribute it and/or modify it under the terms of
 +   the GNU General Public License as published by the Free Software Foundation;
 +   either version 2 of the License, or (at your option) any later version.
 +  
 +   The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
 +   A copy is found in the textfile GPL.txt and important notices to the license
 +   from the author is found in LICENSE.txt distributed with these scripts.
 +  
 +   This script is distributed in the hope that it will be useful, but WITHOUT ANY
 +   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 +   PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 + 
 +   This copyright notice MUST APPEAR in all copies of the script!
 +  -------------------------------------------------------------------------------------------
 +  V 1.1
 +  10.03.11 KH (flip-flop) RT NEW cut out (frontend snippet)
 +  08.02.12 KH (flip-flop) Update V1.0: New var @hidden. Custom switch for show article without [more] is set.
 +  14.02.12 KH (flip-flop) Update V1.1: If in BE the keyword is set to "hidden" or "versteckt", the articles of the category are not displayed. (Don´t need [x] hidden).
 +  
 +  RT NEW erweitert um Schluesselwoerter, Kategorienliste (IDs) und Modus
 +   {NEWX:count:category-IDs:key word´s:category-ID:Mode}
 +...Please always fill out all fields: e.g.
 +   {NEWX:5::tip,top,flip,flop:0}          -> Output first 5 entries, search only in cad-ID=0 = home
 +   {NEWX:7:12,23,56:tip,top,flip,flop:1}  -> Output first 7 entries, search beginning in cad-ID=12,23,56 downstares in sub cats
 +   {NEWX:9:12,23,56::2}                   -> Output first 9 entries, search beginning behind cad-ID=12,23,56 downstares in sub cats, no keywords
 +  
 +   Update 08.02.12 :
 +   {NEWX:count:category-IDs:key word´s:Mode:show_hidden_categories}
 +   Show articles in hidden categories if set to 1
 +   {NEWX:9:12,23,56::2:1}                 -> Output first 9 entries, search beginning behind cad-ID=12,23,56 downstares in sub cats, no keywords, show article in hidden categories
 +   {NEWX:9:12,23,56::2:0}  or {NEWX:9:12,23,56::2}  -> The same as above, but don´t show article in hidden categories
 +  
 +   Custom switch @more:
 +   - 0 = Show article only if @more is [x]
 +   - 1 = Show article if @more is [x] or [_]
 +*********************************************************************************************/
 +// -------------------------------------------------------------------------------------------
 +// obligate check for phpwcms constants
 +  if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");}
 +// -------------------------------------------------------------------------------------------
 +
 +
 +
 +if(strpos($content["all"],'{NEWX:') !== false) {
 +
 +// CUSTOM ------------------------------------------------------------------------------------
 +
 + $more = 1;  // +KH 08.02.12: [0|1]  0 = Show article only if @more is [x] | 1 = if @more is [x] or [_]
 +
 +// -------------------------------------------------------------------------------------------
 +
 + // +KH 08.02.12: include/inc_front/front.func.inc.php
 + function my_getStructureLevelDisplayStatus(&$level_ID, &$current_ID, $hidden=0) {
 +
 +
 + // Datensatz einer Unterkategorie der aktuellen Kategorie und nicht Kategorie 0 (home))
 + if($GLOBALS['content']['struct'][$level_ID]['acat_struct'] == $current_ID && $level_ID) {
 +
 + // Kategorie fuer registrierte Benutzer und nicht eingeloggt
 + if($GLOBALS['content']['struct'][$level_ID]['acat_regonly'] && !FEUSER_LOGIN_STATUS) {
 + return false;
 + }
 + // Update V1.1: Wenn die Schluesselwoerter "hidden" oder "versteckt" gesetzt sind, dann verbergen
 + if (!empty($GLOBALS['content']['struct'][$level_ID]['acat_keywords'])) {
 +
 + if( (stripos($GLOBALS['content']['struct'][$level_ID]['acat_keywords'], 'hidden'   ) !== FALSE) OR
 + (stripos($GLOBALS['content']['struct'][$level_ID]['acat_keywords'], 'versteckt') !== FALSE)    ) {
 + return false;
 + }
 + }
 +
 + if(empty($GLOBALS['content']['struct'][$level_ID]['acat_hidden'])) {
 + return true;
 + } elseif($GLOBALS['content']['struct'][$level_ID]["acat_hidden"] == 2 && isset($GLOBALS['LEVEL_KEY'][$level_ID])) {
 + return true;
 + } elseif ($hidden) {  // +KH: IF hidden flag is set: All categories, including the hidden.
 + return true;
 + }
 + return false;
 + }
 + return false;
 + }
 +
 + // +KH 08.02.12: include/inc_front/front.func.inc.php
 + function my_getStructureChildData($level_id=0, $hidden=0) {
 + if( !isset($GLOBALS['content']['struct'][$level_id]) ) return array();
 + $struct_data = array();
 + foreach($GLOBALS['content']['struct'] as $key => $value) {
 + if( my_getStructureLevelDisplayStatus($key, $level_id, $hidden) ) {
 + $struct_data[$key] = $value;
 + }
 + }
 + return $struct_data;
 + }
 +
 +
 + function my_newX_keywords ($keywords = "")  {
 +
 + $keywords = str_replace("ALLKEYWORDS", $GLOBALS['content']['all_keywords'].',', $keywords);
 +
 + // replace unwanted chars and convert to wanted
 + $keywords = str_replace(";", ",", $keywords);
 + $keywords = str_replace("'", "", $keywords);
 + $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 => $value) {
 +
 + if(substr($keywordarray[$key], 0, 1) == '-') {
 + $doNotUse = substr($keywordarray[$key], 1);
 + foreach($keywordarray as $key2 => $value2) {
 + if($doNotUse == $value2) {
 + unset($keywordarray[$key2]);
 + unset($keywordarray[$key]);
 + }
 + }
 + }
 +
 + if(isset($keywordarray[$key]) && (strlen($keywordarray[$key]) < 3 || empty($keywordarray[$key]))) {
 + unset($keywordarray[$key]);
 + }
 + }
 + }
 + if(is_array($keywordarray) && count($keywordarray)) {
 + $where = "";
 + foreach($keywordarray as $value) {
 + //build where keyword = blabla
 + $where .= ($where) ? " OR " : "";
 + //replace every "'" to "''" for security reasons with aporeplace()
 + $where .= "article_keyword LIKE '%".aporeplace($value)."%'";
 + }
 + }
 +
 + return $where;
 + }
 +// -------------------------------------------------
 +
 + // Parse cat id string
 +
 + function my_newX_cat_id ($cat_id = "")  {
 +
 + // replace unwanted chars and convert to wanted
 + $cat_id = str_replace(";", ",", $cat_id);
 + $cat_id = str_replace("'", "", $cat_id);
 + $cat_id = str_replace(" ", ",", $cat_id);
 + $cat_id = str_replace(",,", ",", $cat_id);
 +
 + // choose comma separated keywords
 + $cat_id_array = explode (",", $cat_id);
 + $cat_id_array = array_map('trim', $cat_id_array);
 + $cat_id_array = array_diff($cat_id_array, array(''));
 + $cat_id_array = array_unique($cat_id_array);
 + $cat_id_array = array_map('strtoupper', $cat_id_array);
 +
 + // check for empty cat_ids or cat_ids smaller than 1 chars
 + if(is_array($cat_id_array) && count($cat_id_array)) {
 + foreach($cat_id_array as $key => $value) {
 +
 + if(substr($cat_id_array[$key], 0, 1) == '-') {
 + $doNotUse = substr($cat_id_array[$key], 1);
 + foreach($cat_id_array as $key2 => $value2) {
 + if($doNotUse == $value2) {
 + unset($cat_id_array[$key2]);
 + unset($cat_id_array[$key]);
 + }
 + }
 + }
 +
 + if(isset($cat_id_array[$key]) && (strlen($cat_id_array[$key]) < 1 )) {
 + unset($cat_id_array[$key]);
 + }
 + }
 + }
 +
 +// return $where;
 + return $cat_id_array;
 + }
 +// -------------------------------------------------
 +
 +
 +
 + function newX_buildStruct_TopDown($start=0, $hidden=0, &$my_cat_id='') {  // KH: V1.1 25.01.2011
 +
 + $struct = my_getStructureChildData($start, $hidden);
 +
 + foreach($struct as $value) {
 + $my_cat_id .= ($my_cat_id != '') ? ','.$value['acat_id'] : $value['acat_id'];
 + newX_buildStruct_TopDown($value['acat_id'], $hidden, $my_cat_id);
 + }
 +
 + return $my_cat_id;
 + }
 +
 +// -------------------------------------------------
 +
 +
 + function my_get_newX_articles(&$template_default, $max_cnt_links=10, $cat=0, $keywords='', $sub_cat=0, $hidden=0, $more=0, $dbcon) {
 + // find all new articles
 +
 + $cat = (empty($cat)) ? '0': trim($cat);
 + $save_cat = $cat;
 +
 + //+KH:read cCategories from string
 + $cat_id_array = my_newX_cat_id($cat);
 +
 + //+KH: Search sub-categories required??
 + if (isset($sub_cat) AND $sub_cat) {
 +
 + $temp = '';
 +
 + foreach ($cat_id_array as $value) {
 + $temp = newX_buildStruct_TopDown($value, $hidden); // find all permitted IDs behind $cat_id
 + if (!empty($temp)) $temp .= ',';
 + }
 +
 + $temp = substr ($temp, 0, -1); // Delete the last comma
 +
 + if (!empty($temp)) {
 + $cat = $temp;
 + if ($sub_cat == 1) {
 +
 + if(empty($GLOBALS['content']['struct'][$save_cat]['acat_hidden']) OR $hidden) // +KH: 08.02.12
 + $cat .= ','.$save_cat; // +KH: 20.01.11 add start category
 + }
 + }
 + }
 + else $sub_cat = false;
 +
 + $max_cnt_links = intval($max_cnt_links);
 +
 + $limit = (empty($max_cnt_links)) ?  '' : ' LIMIT '.$max_cnt_links;
 +
 +
 +
 + $cat =    "article_cid IN (".$cat.") AND ";
 +
 + $sql = 'SELECT article_id, article_title, article_cid, article_alias, article_redirect, article_morelink, ';
 +
 + switch( (empty($template_default["sort_by"]) ? '' : strtolower($template_default["sort_by"])) ) {
 +
 + case 'cdate': //use real creation date
 + $sql .= "article_created AS article_date ";
 + $sorting = 'article_created';
 + break;
 +
 + case 'ldate': //use live/start date
 + $sql .= "UNIX_TIMESTAMP(article_begin) AS article_date ";
 + $sorting = 'article_begin';
 + break;
 +
 + case 'kdate': //use kill/end date
 + $sql .= "UNIX_TIMESTAMP(article_end) AS article_date ";
 + $sorting = 'article_end';
 + break;
 +
 + default: $sql .= "UNIX_TIMESTAMP(article_tstamp) AS article_date ";
 + $sorting = 'article_tstamp';
 + }
 +
 + $sql .= "FROM ".DB_PREPEND."phpwcms_article WHERE ".$cat;
 + // VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
 + switch(VISIBLE_MODE) {
 + case 0: $sql .= "article_public=1 AND article_aktiv=1 AND ";
 + break;
 + case 1: $sql .= "article_uid=".$_SESSION["wcs_user_id"]." AND ";
 + break;
 + //case 2: admin mode no additional neccessary
 + }
 +
 + // +KH: Keyword added
 + $where = my_newX_keywords($keywords);
 +
 + if (!empty($where))
 + $where = ' AND ('.$where.')';
 + else $where = '';
 +
 + $sql .= "article_deleted=0 AND article_begin < NOW() AND article_end > NOW() ".$where." ";
 + $sql .= "ORDER BY ".$sorting." DESC".$limit;
 +
 + // new articles list
 + $new_links = "";
 + $target = ($template_default["link_target"]) ? ' target="'.$template_default["link_target"].'"' : '';
 +
 + $result = _dbQuery($sql);
 + $count  = 0;
 +
 + foreach($result as $row) {
 +
 + if(empty($row['article_redirect'])) {
 + // Feld more im Artikel nicht gesetzt und Schalter @more nicht aktiv  // +KH 08.02.12
 + if(empty($row['article_morelink']) AND !$more) {
 + continue;
 + }
 + $article_link = 'index.php?'.setGetArticleAid($row).'"'.$target;
 + } else {
 + $redirect = get_redirect_link($row['article_redirect'], ' ', '');
 + $article_link = $redirect['link'].'"'.$redirect['target'];
 + }
 +
 + $count++;
 + if($template_default["link_length"] && strlen($row['article_title']) > $template_default["link_length"]) {
 + $article_title = substr($row['article_title'], 0, $template_default["link_length"]).$template_default["cut_title_add"];
 + } else {
 + $article_title = $row['article_title'];
 + }
 + $article_title = html_specialchars($article_title);
 + if(trim($template_default["date_format"])) {
 + $article_date = $template_default["date_before"] .
 + html_specialchars(
 + international_date_format(
 + $template_default["date_language"],
 + $template_default["date_format"],
 + $row['article_date']
 + )
 + ) .
 + $template_default["date_after"];
 +// $article_title;
 + }
 + $new_links .= $template_default["link_before"];
 + $new_links .= $template_default["link_symbol"];
 + // --------------------------------------------------------
 + // +KH: if you need an other order of date and article, please change the next line: $article_title.$article_date
 + // --------------------------------------------------------
 + $new_links .= '<a href="' . $article_link . '>' . $article_date.$article_title . '</a>';
 + $new_links .= $template_default["link_after"];
 + }
 +
 + //enclose whole
 + if($new_links) $new_links = $template_default["before"].$new_links.$template_default["after"];
 +
 + // parses all system RTs  +KH 25.01.2011
 + $new_links = html_parser($new_links);
 +
 + return $new_links;
 + }
 +// -------------------------------------------------------------------------------------------
 +
 +
 + // +KH: all new article list sorted by date
 + if(strpos($content["all"],'{NEWX:') !== false) {
 + $content["all"] = preg_replace('/\{NEWX\}/e','my_get_newX_articles($template_default["news"],"10","0","","1","0",$db);',$content["all"]);
 + // NEWX: Count : catID,catID,catID : keyword,keyword,keyword : mode : hidden}
 + $content["all"] = preg_replace('/\{NEWX:(\d+):([0-9,]*):(.*?):(\d?):?([0|1]?)\}/e','my_get_newX_articles($template_default["news"],"$1","$2","$3","$4","$5",$more,$db);',$content["all"]);
 + }
 +
 +}
 +
 +?>
 +</code>
\\ \\
deutsch/ersetzer_rts/frontend_render/newx.1328901861.txt.gz · Last modified: 2018/06/03 18:07 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0