Differences

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

deutsch:ersetzer_rts:frontend_render:wrap_show_contentx [2010/04/04 12:32]
Knut Heermann (flip-flop)
deutsch:ersetzer_rts:frontend_render:wrap_show_contentx [2018/06/03 18:09] (current)
Line 9: Line 9:
jedoch mit einem umschließenden div Container. jedoch mit einem umschließenden div Container.
-Wenn der/die eingschlossene(n) CP/CPs leer oder unsichtbar ist, wird keine Ausgabe generiert, auch kein div wrapper.+Wenn der/die eingschlossene(n) CP/CPs leer ist, wird keine Ausgabe generiert, auch kein div wrapper.
<del>Download: [[http://phpwcms.planmatrix.de/download/reptag/rt_wrap_show_contentX.zip]]</del> <del>Download: [[http://phpwcms.planmatrix.de/download/reptag/rt_wrap_show_contentX.zip]]</del>
- 
-Update 04.04.2010 KH: Verbesserung gegenüber dem Original: [PHP-Code] in den Artikeln/CPs möglich die mit diesem Tag angesprochen werden. 
\\ \\
<file> <file>
-E.g.: {WRAP_SHOW_CONTENTX:CP, 19: my_class} +Bsp.: {WRAP_SHOW_CONTENTX:CP, 19: my_class} 
-   or {WRAP_SHOW_CONTENTX:CP, 19}  -> fallback to the default class+  oder{WRAP_SHOW_CONTENTX:CP, 19}  -> Die voreingestellte Klasse wird verwendet
-Default class: WRAP_SHOW_CONTENTX+Voreingestellte Klasse: WRAP_SHOW_CONTENTX
</file> </file>
-**Datei:** template/inc_script/frontend_render/wrap_show_content.php+==== Update: ==== 
 + 
 +**- 04.04.2010 KH:** Verbesserung gegenüber dem Original: Wenn SHOW_CONTENT aus [PHP].... aufgerufen wird, ist nun ein zweites mal [PHP-Code] in den Artikeln/CPs möglich die mit diesem Tag angesprochen werden. \\ 
 +**- 05.04.2010 KH:** Parsen aller System RTs, spam -mailto: Umwandlung für JS-eMailadresse wird eingebunden.\\ 
 +**- 19.01.2011 KH:** Parsen von SHOW_CONTENT, wenn in den eingebundenen CPs dieser RT wiederholt auftaucht. 
 + 
 +**Beispiel:**  
 +<code php> 
 + 
 +[PHP] 
 +  if ( $GLOBALS['LEVEL_ID'][2] == 13 ) echo '<div>{WRAP_SHOW_CONTENTX:CP,104}</div>';    
 +[/PHP] 
 + 
 +</code> 
 +Mit dem eingebauten SHOW_CONTENT würde PHP-Code im CP 104 nicht mehr abgearbeitet. 
 + 
 +\\ 
 + 
 +===== Code: ===== 
 + 
 +**Datei:** template/inc_script/frontend_render/rt_wrap_show_contentx.php
<code php|h WRAP_SHOW_CONTENTX:....:class |h> <code php|h WRAP_SHOW_CONTENTX:....:class |h>
Line 45: Line 63:
//      08.11.08 Updated for a better handling //      08.11.08 Updated for a better handling
//      16.01.09 Enhanced WRAP_SHOW_CONTENT:  to display unvisible CPs //      16.01.09 Enhanced WRAP_SHOW_CONTENT:  to display unvisible CPs
 +//      11.01.11 Update parse SHOW_CONTENT a second time
// ================================================================== // ==================================================================
// ------------------------------------------------------------------ // ------------------------------------------------------------------
Line 51: Line 70:
   die("You Cannot Access This Script Directly, Have a Nice Day."); }    die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
 +
if( strpos($content['all'], '{WRAP_SHOW_CONTENTX:') !== FALSE ) { if( strpos($content['all'], '{WRAP_SHOW_CONTENTX:') !== FALSE ) {
- +  
 + 
/* /*
- * {SHOW_CONTENT} + * {SHOW_CONTENT}
 * thanks to Jens Zetterström who has initiated this in 2005  * thanks to Jens Zetterström who has initiated this in 2005
 * Shows the content of the article content part with the specified id.  * Shows the content of the article content part with the specified id.
Line 67: Line 86:
 *   CPAD - same as CPA, but descending  *   CPAD - same as CPA, but descending
 *   AS   - list of Article Summaries | id = id of articles, comma separated  *   AS   - list of Article Summaries | id = id of articles, comma separated
- *  CAS  - list of Article Summaries | id = id of structure level, comma separated+ *
 */  */
function showSelectedContentX($param='') { function showSelectedContentX($param='') {
- +  
- global $template_default; +    global $template_default; 
- global $db; +    global $db; 
- global $content; +    global $content; 
- global $block; +    global $block; 
- global $phpwcms; +    global $phpwcms; 
- global $aktion; +    global $aktion; 
-  +  
- $topcount = 999999; +    $topcount = 999999; 
- $template = ''; +    $template = ''; 
-  +  
- if($cp = explode(',', $param)) { +    if($cp = explode(',', $param)) { 
- $mode = strtoupper(trim($cp[0])); +        $mode   = strtoupper(trim($cp[0])); 
- if(substr($mode, 0, 2) == 'AS') { +        if(substr($mode, 0, 2) == 'AS') { 
- $mode = explode('|', $cp[0]); +            $mode = explode('|', $cp[0]); 
- if(isset($mode[1])) { +            if(isset($mode[1])) { 
- $mode[1] = trim($mode[1]); +                $mode[1] = trim($mode[1]); 
- if(is_numeric($mode[1])) { +                if(is_numeric($mode[1])) { 
- $topcount = intval($mode[1]); +                    $topcount = intval($mode[1]); 
- } elseif(empty($mode[2]) && strlen($mode[1]) > 4 && ($mode[1] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[1]))) { +                } elseif(empty($mode[2]) && strlen($mode[1]) > 4 && ($mode[1] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[1]))) { 
- $template = $mode[1]; +                    $template = $mode[1]; 
- +               
- +           
- if(isset($mode[2])) { +            if(isset($mode[2])) { 
- $mode[2] = trim($mode[2]); +                $mode[2] = trim($mode[2]); 
- if(is_numeric($mode[2])) { +                if(is_numeric($mode[2])) { 
- $topcount = intval($mode[2]); +                    $topcount = intval($mode[2]); 
- } elseif(strlen($mode[2]) > 4 && ($mode[2] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[2]))) { +                } elseif(strlen($mode[2]) > 4 && ($mode[2] == 'default' || is_file(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list/'.$mode[2]))) { 
- $template = $mode[2]; +                    $template = $mode[2]; 
- +               
- +           
- $mode = strtoupper(trim($mode[0])); +            $mode = strtoupper(trim($mode[0])); 
- if(isset($cp[1])) { // now check if  +            if(isset($cp[1])) { // now check if 
- $cp[1] = trim($cp[1]); +                $cp[1] = trim($cp[1]); 
- if(!is_numeric($cp[1])) { +                if(!is_numeric($cp[1])) { 
- switch($cp[1]) { +                    switch($cp[1]) { 
- case 'new': $cp = array('new' => 1); break; +                        case 'new':       $cp = array('new'       => 1);   break; 
- case 'random': $cp = array('random' => 1); break; +                        case 'random':   $cp = array('random'   => 1);   break; 
- case 'related': if(isset($cp[2])) { +                        case 'related':   if(isset($cp[2])) { 
- unset($cp[0], $cp[1]); +                                            unset($cp[0], $cp[1]); 
- $related = array(); +                                            $related = array(); 
- foreach($cp as $value) { +                                            foreach($cp as $value) { 
- $related[] = "article_keyword LIKE '%".aporeplace(strtoupper(trim($value)))."%'"; +                                                $related[] = "article_keyword LIKE '%".aporeplace(strtoupper(trim($value)))."%'"; 
- +                                           
- $cp = array('related' => 1); break; +                                            $cp = array('related' => 1); break; 
- +                                       
-  +  
- default: $cp = array('new' => 1); +                        default:       $cp = array('new'       => 1); 
- +                   
- +               
- +           
- +       
- unset($cp[0]); +        unset($cp[0]); 
- foreach($cp as $key => $value) { +        foreach($cp as $key => $value) { 
- $value = intval($value); +            $value   = intval($value); 
- if(!$value) { +            if(!$value) { 
- unset($cp[$key]); +                unset($cp[$key]); 
- } else { +            } else { 
- $cp[$key] = $value; +                $cp[$key] = $value; 
- +           
- +       
- if(!is_array($cp) || !count($cp)) { +        if(!is_array($cp) || !count($cp)) { 
- return ''; +            return ''; 
- +       
- } else { +    } else { 
- // oh no ID given, end function +        // oh no ID given, end function 
- return ''; +        return ''; 
-+   
-  +  
- $CNT_TMP = ''; +    $CNT_TMP = ''; 
-  +  
- if(substr($mode, 0, 2) == 'AS') { +    if(substr($mode, 0, 2) == 'AS') { 
-  +  
- if(substr($mode, -1) == 'P') { +        if(substr($mode, -1) == 'P') { 
- $mode = substr($mode, 0, -1); +            $mode = substr($mode, 0, -1); 
- $priorize = 'article_priorize DESC, '; +            $priorize = 'article_priorize DESC, '; 
- } else { +        } else { 
- $priorize = ''; +            $priorize = ''; 
- +       
-  +  
- switch($mode) { +        switch($mode) { 
-  +  
- case 'ASL': $sort = $priorize.'article_begin ASC'; break; // sorted by livedate ascending +            case 'ASL':       $sort = $priorize.'article_begin ASC';       break; // sorted by livedate ascending 
- case 'ASLD': $sort = $priorize.'article_begin DESC'; break; // sorted by livedate descending +            case 'ASLD':   $sort = $priorize.'article_begin DESC';       break; // sorted by livedate descending 
- case 'ASK': $sort = $priorize.'article_end ASC'; break; // sorted by killdate ascending +            case 'ASK':       $sort = $priorize.'article_end ASC';       break; // sorted by killdate ascending 
- case 'ASKD': $sort = $priorize.'article_end DESC'; break; // sorted by killdate descending +            case 'ASKD':   $sort = $priorize.'article_end DESC';       break; // sorted by killdate descending 
- case 'ASC': $sort = $priorize.'article_tstamp ASC'; break; // sorted by change date ascending +            case 'ASC':       $sort = $priorize.'article_tstamp ASC';       break; // sorted by change date ascending 
- case 'ASCD': $sort = $priorize.'article_tspamp DESC'; break; // sorted by change date descending +            case 'ASCD':   $sort = $priorize.'article_tspamp DESC';   break; // sorted by change date descending 
- case 'ASR': $sort = 'RAND()'; break; // random sort +            case 'ASR':       $sort = 'RAND()';                           break; // random sort 
- default: $sort = ''; +            default:       $sort = ''; 
- +  
- +       
- +  
- $CNT_TMP = list_articles_summary( get_article_data( $cp, $topcount, $sort ) , $topcount, $template); +        $CNT_TMP = list_articles_summary( get_article_data( $cp, $topcount, $sort ) , $topcount, $template); 
- +  
- +  
- } elseif($mode == 'CP' || $mode == 'CPA' || $mode == 'CPAD') { +    } elseif($mode == 'CP' || $mode == 'CPA' || $mode == 'CPAD') { 
-  +  
- $sort = ($mode=='CPAD') ? ' DESC' : ''; //means ASCENDING +        $sort = ($mode=='CPAD') ? ' DESC' : ''; //means ASCENDING 
-  +  
- foreach($cp as $value) { +        foreach($cp as $value) { 
-  +  
- if($mode == 'CP') {  +            if($mode == 'CP') { 
- // content part listing +                // content part listing 
- $sql  = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent "; +                $sql  = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecontent "; 
- $sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON "; +                $sql .= "INNER JOIN " . DB_PREPEND . "phpwcms_article ON "; 
- $sql .= DB_PREPEND . "phpwcms_article.article_id = " . DB_PREPEND . "phpwcms_articlecontent.acontent_aid "; +                $sql .= DB_PREPEND . "phpwcms_article.article_id = " . DB_PREPEND . "phpwcms_articlecontent.acontent_aid "; 
-// $sql .= "WHERE acontent_id = " . $value . " AND acontent_visible = 1 "; -kh +//               $sql .= "WHERE acontent_id = " . $value . " AND acontent_visible = 1 "; -kh 
- $sql .= "WHERE acontent_id = " . $value . " "; +                $sql .= "WHERE acontent_id = " . $value . " "; 
-  +  
- if( !FEUSER_LOGIN_STATUS ) { +                if( !FEUSER_LOGIN_STATUS ) { 
- $sql .= 'AND acontent_granted=0 '; +                    $sql .= 'AND acontent_granted=0 '; 
- +               
-  +  
- $sql .= "AND acontent_trash = 0 AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 AND "; +                $sql .= "AND acontent_trash = 0 AND " . DB_PREPEND . "phpwcms_article.article_deleted=0 AND "; 
- $sql .= DB_PREPEND."phpwcms_article.article_begin < NOW() AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() "; +                $sql .= DB_PREPEND."phpwcms_article.article_begin < NOW() AND " . DB_PREPEND . "phpwcms_article.article_end > NOW() "; 
- $sql .= "LIMIT 1"; +                $sql .= "LIMIT 1"; 
-  +  
- } else { +            } else { 
- // content parts based on article ID  +                // content parts based on article ID 
- $sql  = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent "; +                $sql  = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecontent "; 
-// $sql .= "WHERE acontent_aid=". $value." AND acontent_visible=1 AND acontent_trash=0 "; // -kh +//               $sql .= "WHERE acontent_aid=". $value." AND acontent_visible=1 AND acontent_trash=0 "; // -kh 
- $sql .= "WHERE acontent_aid=". $value." AND acontent_trash=0 "; +                $sql .= "WHERE acontent_aid=". $value." AND acontent_trash=0 "; 
-  +  
- if( !FEUSER_LOGIN_STATUS ) { +                if( !FEUSER_LOGIN_STATUS ) { 
- $sql .= 'AND acontent_granted=0 '; +                    $sql .= 'AND acontent_granted=0 '; 
- +               
-  +  
- $sql .= "ORDER BY acontent_sorting".$sort.", acontent_id"; +                $sql .= "ORDER BY acontent_sorting".$sort.", acontent_id"; 
-  +  
- +           
-  +  
- if($cresult = mysql_query($sql, $db)) { +            if($cresult = mysql_query($sql, $db)) { 
- while($crow = mysql_fetch_assoc($cresult)) { +                while($crow = mysql_fetch_assoc($cresult))  
-  +  
- if($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]])) { +                    if($crow["acontent_type"] == 30 && !isset($phpwcms['modules'][$crow["acontent_module"]])) { 
- continue; +                        continue; 
- +                   
-  +  
- if($crow["acontent_type"] == 24) { +                    if($crow["acontent_type"] == 24) { 
- // first retrieve alias ID information and settings +                        // first retrieve alias ID information and settings 
- $crow = getContentPartAlias($crow); +                        $crow = getContentPartAlias($crow); 
- +                   
-  +  
- $space = getContentPartSpacer($crow["acontent_before"], $crow["acontent_after"]); +                    $space = getContentPartSpacer($crow["acontent_before"], $crow["acontent_after"]); 
-  +  
- // Space before +                    // Space before 
- $CNT_TMP .= $space['before']; +                    $CNT_TMP .= $space['before']; 
-  +  
- // set frontend edit link +                    // set frontend edit link 
- $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']); +                    $CNT_TMP .= getFrontendEditLink('CP', $crow['acontent_aid'], $crow['acontent_id']); 
-  +  
- // include content part code section +                    // include content part code section 
- if($crow["acontent_type"] != 30) { +                    if($crow["acontent_type"] != 30) { 
-  +  
- include(PHPWCMS_ROOT.'/include/inc_front/content/cnt' . $crow["acontent_type"] . '.article.inc.php'); +                        include(PHPWCMS_ROOT.'/include/inc_front/content/cnt' . $crow["acontent_type"] . '.article.inc.php'); 
-  +  
- } elseif($crow["acontent_type"] == 30 && file_exists($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) { +                    } elseif($crow["acontent_type"] == 30 && file_exists($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php')) { 
-  +  
- $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']); +                        $CNT_TMP .= getFrontendEditLink('module', $phpwcms['modules'][$crow["acontent_module"]]['name']); 
-  +  
- // now try to include module content part code +                        // now try to include module content part code 
- include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php'); +                        include($phpwcms['modules'][$crow["acontent_module"]]['path'].'inc/cnt.article.php'); 
-  +  
- +                   
-  +  
- //check if top link should be shown +                    //check if top link should be shown 
- $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]); +                    $CNT_TMP .= getContentPartTopLink($crow["acontent_top"]); 
-  +  
- //Maybe content part ID should b used inside templates or for something different +                    //Maybe content part ID should b used inside templates or for something different 
- $CNT_TMP  = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP ); +                    $CNT_TMP  = str_replace( array('[%CPID%]', '{CPID}'), $crow["acontent_id"], $CNT_TMP ); 
-  +  
- // trigger content part functions +                    // trigger content part functions 
- $CNT_TMP = trigger_cp($CNT_TMP, $crow); +                    $CNT_TMP = trigger_cp($CNT_TMP, $crow); 
-  +  
- // Space after +                    // Space after 
- $CNT_TMP .= $space['after']; +                    $CNT_TMP .= $space['after']; 
-  +  
- +               
- mysql_free_result($cresult); +                mysql_free_result($cresult); 
- +           
- +       
-+   
-  +  
- if(empty($phpwcms["allow_cntPHP_rt"])) { +    if(empty($phpwcms["allow_cntPHP_rt"])) { 
- $CNT_TMP = remove_unsecure_rptags($CNT_TMP); +        $CNT_TMP = remove_unsecure_rptags($CNT_TMP); 
- } else  +  
- // include external PHP script (also normal HTML snippets) or return PHP var value +KH: 04.04.2010 +    //+KH: 05.04.2010 
- $CNT_TMP = render_PHPcode($CNT_TMP); +    } else 
-  +        // include external PHP script (also normal HTML snippets) or return PHP var value +KH: 04.04.2010 
- return $CNT_TMP;+        $CNT_TMP = render_PHPcode($CNT_TMP); 
 +  
 +    // parses all system RTs 
 +    $CNT_TMP = html_parser($CNT_TMP); 
 +  
 +    // Special for eMail mailto:.... 
 +    if ( ($phpwcms["allow_ext_render"]) AND (strpos($CNT_TMP, 'mailto:') != false) ) { 
 +  
 +        // try to include custom functions and replacement tags or what you want to do at this point of the script 
 +        // default dir: "phpwcms_template/inc_script/frontend_render"; only *.php files are allowed there 
 +        if ( is_file(PHPWCMS_TEMPLATE.'inc_script/frontend_render/makeEmailSpamSave.php') ) { 
 +  
 +            include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_render/makeEmailSpamSave.php'); 
 +            $CNT_TMP = replaceEmailAddress($CNT_TMP); 
 +        } 
 +    } 
 +  
 +    return $CNT_TMP;
} }
- +  
 + 
   function func_WRAP_SHOW_CONTENTX($my_param) {    function func_WRAP_SHOW_CONTENTX($my_param) {
-   +
      $my_param = str_replace(' ','',$my_param); // kill all spaces       $my_param = str_replace(' ','',$my_param); // kill all spaces
-      +
      // explode parameter for SHOW_CONTENT and the optional class name       // explode parameter for SHOW_CONTENT and the optional class name
      // $my_arr[0] = SHOW_CONTENT parameter       // $my_arr[0] = SHOW_CONTENT parameter
      // $my_arr[1] = optional own class name       // $my_arr[1] = optional own class name
      $my_arr = explode(":",$my_param);       $my_arr = explode(":",$my_param);
-      +
      if (!empty($my_arr[1])) { $my_class = $my_arr[1]; }    // custom class name = yes       if (!empty($my_arr[1])) { $my_class = $my_arr[1]; }    // custom class name = yes
      else {$my_class = 'WRAP_SHOW_CONTENTX'; }            // custom class name = no -> default name       else {$my_class = 'WRAP_SHOW_CONTENTX'; }            // custom class name = no -> default name
 +
      // set the wrapper code       // set the wrapper code
-      $div_before = '<div class="'.$my_class.'"'.LF;+      $div_before = '<div class="'.$my_class.'";>;'.LF;
      $div_behind = LF.'</div>';       $div_behind = LF.'</div>';
-      +
      $string = '';       $string = '';
      $string = showSelectedContentX($my_arr[0]);    // same as SHOW_CONTENT       $string = showSelectedContentX($my_arr[0]);    // same as SHOW_CONTENT
             
 +      // +KH 19.01.11 parse SHOW_CONTENT a second time
 +      while (strpos($string, '{SHOW_CONTENT:') != false)
 +         $string = preg_replace('/\{SHOW_CONTENT:(.*?)\}/e', 'showSelectedContent("$1");', $string);
 + 
 + 
      // Set the wrapper around       // Set the wrapper around
-      if (!$string == '') { $my_replace  = $div_before.$string.$div_behind; }  +      if (!$string == '') { $my_replace  = $div_before.$string.$div_behind; }
      else { $my_replace = ''; }       else { $my_replace = ''; }
-      +
   return $my_replace;    return $my_replace;
} }
 +
// And do it ====== // And do it ======
$content["all"] = preg_replace('/{WRAP_SHOW_CONTENTX:(.*?)}/e', 'func_WRAP_SHOW_CONTENTX("$1")', $content["all"]); $content["all"] = preg_replace('/{WRAP_SHOW_CONTENTX:(.*?)}/e', 'func_WRAP_SHOW_CONTENTX("$1")', $content["all"]);
 +
} }
?> ?>
</code> </code>
deutsch/ersetzer_rts/frontend_render/wrap_show_contentx.1270377133.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