Trade Republic - Provisionsfrei Aktien handeln
Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: MODUL: Themenwelten

    koshiro

    • Fördermitglied
    • Beiträge: 2.297
    Re: MODUL: Themenwelten
    Antwort #165 am: 17. Juni 2019, 13:09:14
    Hallo Marcus,
    okay dann werde ich das Modul mal normal mit den Original Dateien Installieren, und es versuchen an zu passen. Und dann noch eine Frage. Was muss den geändert werden um das die Ausgabe auch vom Content Manager funktioniert, denn da ist es so selbst wenn die Original Dateien verwendet werden das er mir nichts ausgiebt.
    Gruß
    Micha
    Marktplatz - Eine große Auswahl an neuen und hilfreichen Modulen sowie modernen Templates für die modified eCommerce Shopsoftware

    Marcus Kreusch

    • Fördermitglied
    • Beiträge: 312
    • Geschlecht:
    Re: MODUL: Themenwelten
    Antwort #166 am: 17. Juni 2019, 13:15:22
    Hallo Micha,

    bei mir im Test hatte das vorhin funktioniert. Am besten installierst du es wirklich nochmal original und wenn es dann noch ein Problem gibt, schau ich gern nochmal drauf :-)

    Beste Grüße
    Marcus

    koshiro

    • Fördermitglied
    • Beiträge: 2.297
    Re: MODUL: Themenwelten
    Antwort #167 am: 17. Juni 2019, 21:02:31
    Hallo Marcus,
    so habe es jetzt eingebaut, und es funktioniert auch einwandfrei beim Content Manager.
    Aber ich nutze ja diese Modifikation von Whiteflash aus der Antwort #136, und dort schreibt er ja das man eigene Templates nutzen kann, aber bei mir geht das nicht. Kann man die modifier.contentenhancer.php nicht so anpassen das man jedes Template nutzen könnte?
    Beste Grüße
    Micha

    Marcus Kreusch

    • Fördermitglied
    • Beiträge: 312
    • Geschlecht:
    Re: MODUL: Themenwelten
    Antwort #168 am: 19. Juni 2019, 18:33:00
    Hallo Micha,

    das ist doch schonmal sehr gut :-)
    Eigene Templates sollten mit der Erweiterung tatsächlich funktionieren, aber das Template muss natürlich korrekt geschrieben sein. Also am besten das Original-Template heranziehen und von da aus Stück für Stück verändern. Insbesondere die Variablennamen müssen natürlich beibehalten werden.

    Beste Grüße
    Marcus

    demoncleaner

    • Fördermitglied
    • Beiträge: 468
    Re: MODUL: Themenwelten
    Antwort #169 am: 23. Januar 2020, 10:16:30
    Ich vermuter ich habe noch einen Bug entdeckt.

    Sowas hier wollte bei mir einfach nicht klappen

    Code: PHP  [Auswählen]
    [products products_models='4010053, 4010097']
     

    Aus den Logfiles konnte ich dann entnehmen, dass die Query so ausgeführt wurde.

    Code: PHP  [Auswählen]
     WHERE
                        p.products_status = 1  AND p.group_permission_0=1  AND p.products_model IN ('4010053', '4010097')  AND in File:

     

    Also das AND hinten dran war einfach zu viel.
    Mein Verdacht war, dass das an folgenden Zeilen lag:

    Code: PHP  [Auswählen]
         // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q .= generateKeywordsequence($categories_ids, $keywords, 'pd', array('products_keywords', 'products_name', 'products_description'), 'AND');

                    // Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q = convertRestrictions($q, $restrictions);
     

    Aus meiner Sicht dürften die gar nicht greifen sondern nur dann wenn nach keywords gefragt wird.
    Also hab ich da noch mal folgendes drum gepackt.

    Code: PHP  [Auswählen]
    if(is_array($keywords)){
                    // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q .= generateKeywordsequence($categories_ids, $keywords, 'pd', array('products_keywords', 'products_name', 'products_description'), 'AND');

                    // Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q = convertRestrictions($q, $restrictions);
            }
     

    und nun scheint es zu gehen.
    Kann das jemand bestätigen? Ich bin verwundert, weil ja der Bug - wenn es einer ist - eigentlich schon längst hätte auffalen müssen.

    demoncleaner

    • Fördermitglied
    • Beiträge: 468
    Re: MODUL: Themenwelten
    Antwort #170 am: 23. Januar 2020, 10:41:17
    Ich hab das Ganze auch mal grad erweitert, so dass man auch nach products_id auflisten kann:

    Code: PHP  [Auswählen]
    <?php

    function smarty_modifier_contentenhancer ($html) {
       
       
        // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying setting template
        if(preg_match_all('/(\[([\w\d ]*)template[^\]]+\])/', $html, $matches)){
            foreach($matches[1] AS $snippet){
                if(preg_match('/template\=\'([^\']+)\'/', $snippet, $template_matches)){
                    if (!empty($template_matches[1])) {
                        $template=$template_matches[1];
                        $template_usage=(!empty($matches[2][0])) ? $matches[2][0] : "all";
                        $html = str_replace($snippet, '', $html);
                        break;
                    }
                }
            }
        }
        // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying setting template


        if(preg_match_all('/(\[products [^\]]+\])/', $html, $matches)){
            foreach($matches[1] AS $snippet){
                $products_models = null;
                $products_ids = null;
                $categories_ids = null;
                $keywords = null;

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/products_models\=\'([^\']+)\'/', $snippet, $model_matches)){
                    $t_models = explode(',', $model_matches[1]);
                    $products_models = array();
                    foreach($t_models AS $model){
                        $raw_model = xtc_db_input(trim($model));
                        if (strlen($raw_model) < 10) { $raw_model = str_pad($raw_model, 10, "0", STR_PAD_LEFT); }
                        $products_models[] = xtc_db_input(sanitizeIdentifyerstrings($raw_model));
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/products_ids\=\'([^\']+)\'/', $snippet, $id_matches)){
                    $t_ids = explode(',', $id_matches[1]);
                    $products_ids = array();
                    foreach($t_ids AS $id){
                        $raw_id = xtc_db_input(trim($id));
                        if (strlen($raw_id) < 10) { $raw_id = str_pad($raw_id, 10, "0", STR_PAD_LEFT); }
                        $products_ids[] = xtc_db_input(sanitizeIdentifyerstrings($raw_id));
                    }
                }

               
                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/categories_ids\=\'([^\']+)\'/', $snippet, $categories_ids_matches)){
                    $t_categories_ids = explode(',', $categories_ids_matches[1]);
                    $categories_ids = array();
                    foreach($t_categories_ids AS $categories_id){
                        $categories_ids[] = (int)$categories_id;
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/keywords\=\'([^\']+)\'/', $snippet, $keyword_matches)){
                    $t_keywords = explode(',', $keyword_matches[1]);
                    $keywords = array();
                    foreach($t_keywords AS $keyword){
                        $keywords[] = xtc_db_input(trim($keyword));
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Products (with selected template) for keyword with  $limit, $order_by, $exclusion (change function call)
                if (($template_usage == 'all') || ($template_usage == 'categories')) {
                    $html = str_replace($snippet, parseProducts($products_models,$products_ids, $categories_ids, $keywords, $restrictions, $template), $html);
                } else {
                    $html = str_replace($snippet, parseProducts($products_models,$products_ids, $categories_ids, $keywords, $restrictions), $html);
                }
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Products (with selected template) for keyword with  $limit, $order_by, $exclusion (change function call)

            }
        }

        if(preg_match_all('/(\[categories [^\]]+\])/', $html, $matches)){
            foreach($matches[1] AS $snippet){

                if(preg_match('/categories_ids\=\'([^\']+)\'/', $snippet, $categories_ids_matches)){
                    $t_categories_ids = explode(',', $categories_ids_matches[1]);
                    $categories_ids = array();
                    foreach($t_categories_ids AS $categories_id){
                        $categories_ids[] = (int)$categories_id;
                    }
                }

                if(preg_match('/keywords\=\'([^\']+)\'/', $snippet, $keyword_matches)){
                    $t_keywords = explode(',', $keyword_matches[1]);
                    $keywords = array();
                    foreach($t_keywords AS $keyword){
                        $keywords[] = xtc_db_input(trim($keyword));
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Categories (with selected template)
                $restrictions=setRestrictions($snippet);
                if (($template_usage == 'all') || ($template_usage == 'categories')) {
                    $html = str_replace($snippet, parseCategories($categories_ids, $keywords, $restrictions, $template), $html);
                } else {
                    $html = str_replace($snippet, parseCategories($categories_ids, $keywords, $restrictions), $html);
                }
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Categories (with selected template)
            }
        }

        // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword with  $limit, $order_by, $exclusion (change function call)
        $html = parseSubstitutions($html);
        // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword with  $limit, $order_by, $exclusion (change function call)

        return $html;

    }


    function /* parseCategories($categories_ids = NULL) { */
        parseCategories($categories_ids = null, $keywords = null, $restrictions = null, $template = '/module/modules/content_enhancer/listing_cats.html'){ // Whiteflash: Modul Content-Enhancer - mod modifying sql_settings for keyword with $limit

        if ((is_array($categories_ids)) || (is_array($keywords))) {

            if (GROUP_CHECK == 'true') {
                    $group_check = "c.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 AND";
            }

            // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
            $keywords_sequence = generateKeywordsequence($categories_ids, $keywords, 'cd', array('categories_name', 'categories_description'));

            $q = "SELECT
                            c.categories_id,
                            c.categories_image,  
                            cd.categories_name,
                            cd.categories_description
                    FROM categories AS c
                    LEFT JOIN categories_description as cd
                    ON c.categories_id = cd.categories_id
                    WHERE c.categories_id IN ('"
    .implode("', '", $categories_ids)."')
                    "
    .$keywords_sequence." -- Whiteflash 2018-10-23: add keywords_sequence
                    AND "
    .$group_check." c.categories_status = '1'
                    AND cd.language_id = '"
    .(int) $_SESSION['languages_id'] ."'
                    ORDER BY FIND_IN_SET(c.categories_id,'"
    .implode(",", $categories_ids)."')";

            // Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for restrictions
            $q = convertRestrictions($q, $restrictions);

            $categories_query = xtDBquery($q);

            while($categories = xtc_db_fetch_array($categories_query, true)) {
                $category_link =xtc_category_link($categories['categories_id'],$categories['categories_name']);
                $module_content[] = array ('CATEGORY_NAME'        => $categories['categories_name'],
                    'CATEGORY_IMAGE_TRUE'  => $categories['categories_image'],        
                    'CATEGORY_IMAGE'       => DIR_WS_IMAGES .'categories/' . $categories['categories_image'],
                    'CATEGORY_LINK'        => xtc_href_link(FILENAME_DEFAULT,  xtc_get_all_get_params(array(array('cat','page','filter_id','manufacturers_id'))) . $category_link),
                    'CATEGORY_DESCRIPTION' => $categories['categories_description'],
                    'CATEGORY_DESCRIPTION_INTRO' => shortenStringOnNextSpace($categories['categories_description'])
                 );


            }      
            //echo "<pre>";
            //var_dump($module_content);
            //echo "</pre>";
            $smarty = new Smarty;
            $smarty->assign('categories', $module_content);
            $smarty->assign('language', $_SESSION["language"]);

            // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $template_chck = str_replace('//', '/', DIR_FS_CATALOG) .'templates/'. CURRENT_TEMPLATE. $template;
            $used_template = (file_exists($template_chck)) ? CURRENT_TEMPLATE.$template : CURRENT_TEMPLATE.'/module/modules/content_enhancer/listing_cats.html';
            // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $html = $smarty->fetch($used_template);

            return $html;
        }
    }

    function /* parseProducts($products_models = null, $categories_ids = null, $keywords = null){ */
        parseProducts($products_models = null, $products_ids = null, $categories_ids = null, $keywords = null, $restrictions = null, $template = '/module/modules/content_enhancer/listing.html'){ // Whiteflash: Modul Content-Enhancer - mod modifying sql_settings for keyword with $limit
        if(is_array($products_models) || is_array($products_ids) || is_array($categories_ids) || is_array($keywords)){
            $group_check = '';
            $fsk_lock = '';

            if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
                $fsk_lock = ' AND p.products_fsk18!=1';
            }

            if (GROUP_CHECK == 'true') {
                $group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
            }

            $q = "SELECT * FROM
                            "
    .TABLE_PRODUCTS." p
                            JOIN "
    .TABLE_PRODUCTS_DESCRIPTION." pd ON (p.products_id = pd.products_id AND pd.language_id = ".(int)$_SESSION["languages_id"].")
                  WHERE
                        p.products_status = 1 "
    .$fsk_lock.$group_check;

            if(is_array($products_models)){
                $q .= " AND p.products_model IN ('".implode("', '", $products_models)."') ";
            }

            if(is_array($products_ids)){
                $q .= " AND p.products_id IN ('".implode("', '", $products_ids)."') ";
            }

            if(is_array($categories_ids)){
                $q .= " AND p.products_id IN (SELECT p2c.products_id FROM ".TABLE_PRODUCTS_TO_CATEGORIES." p2c WHERE p2c.categories_id IN (".implode(',', $categories_ids).")) ";
            }
           
           
            if(is_array($keywords)){
                    // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q .= generateKeywordsequence($categories_ids, $keywords, 'pd', array('products_keywords', 'products_name', 'products_description'), 'AND');

                    // Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q = convertRestrictions($q, $restrictions);
            }
           
            global $product;
            $module_content = array();
            $listing_query = xtDBquery($q);
            while ($listing = xtc_db_fetch_array($listing_query, true)) {

                 // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                if (is_array($restrictions['excludes'])) {
                    foreach ($restrictions['excludes'] as $column => $values) {
                        if ((!empty($listing[$column])) && (in_array($listing[$column], $values))) continue 2;
                    }
                }
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword

                $module_content[] =  $product->buildDataArray($listing);
            }

            $smarty = new Smarty;
            $smarty->assign('products', $module_content);
            $smarty->assign('language', $_SESSION["language"]);

            // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $template_chck = str_replace('//', '/', DIR_FS_CATALOG) .'templates/'. CURRENT_TEMPLATE. $template;
            $used_template = (file_exists($template_chck)) ? CURRENT_TEMPLATE.$template : CURRENT_TEMPLATE.'/module/modules/content_enhancer/listing.html';
            // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $html = $smarty->fetch($used_template);
            return $html;

        }

        return '';
    }

    /**
     *
     * @param type $input
     * @param type $target_length
     * @return string
     * @author Whiteflash, 2018-10-23
     */

    function shortenStringOnNextSpace($input, $target_length = 125) {


        $shorty = substr($input, 0, strpos($input, " ", $target_length));
        if ((!empty($shorty)) && (strlen($shorty) < strlen($input))) $shorty .= "...";

        return $shorty;
    }

    /**
     *
     * @param type $q
     * @param type $restrictions
     * @return string
     * @author Whiteflash, 2018-10-23
     */

    function convertRestrictions($q, $restrictions) {

       
        if (!empty($restrictions['excludes']['products_id'])) {
            $q .= " AND p.products_id NOT IN(";
            foreach ($restrictions['excludes']['products_id'] as $xcl_id) { $q .= $xcl_id.", "; }
            if (substr($q, -2) == ', ') { $q = substr($q, 0, -2); }
            $q .= ")";
        }
        if (!empty($restrictions['order_by'][0])) $q .= " ORDER BY ".$restrictions['order_by'][0]." ".$restrictions['order_by'][1];
        if (!empty($restrictions['limit'])) $q .= " LIMIT ".$restrictions['limit'];
        if (!empty($restrictions['random'])) {
            if (($order_by_pos = strpos($q, 'ORDER BY')) !== false) $q = substr($q, 0, $order_by_pos);
            $q .= " ORDER BY RAND() ".((!empty($restrictions['random'])) ? ( (strtolower($restrictions['random']) == 'all') ? "" : "LIMIT ".$restrictions['random']."") : "")." ";
        }

        return $q;
    }

    /**
     *
     * @param array $categories_ids
     * @param array $keywords
     * @param string $table_shortcut
     * @param array $table_fields
     * @param string $concatenate, optional (null)
     * @return string keywordsequence
     * @author Whiteflash, 2018-10-23
     */

    function generateKeywordsequence($categories_ids, $keywords, $table_shortcut, $table_fields, $concatenate = null) {

        $keywords_sequence = (!empty($concatenate)) ? " ".$concatenate : "";
        if(is_array($keywords)) {
            $connector = (empty($categories_ids)) ? " " : " OR";
            $keywords_sequence .= $connector." (1!=1";
            foreach($keywords AS $keyword){
                for ($i=0;$i<count($table_fields);$i++) { $keywords_sequence .= " OR (".$table_shortcut.".".$table_fields[$i]." LIKE ('%".$keyword."%'))"; }
            }
            $keywords_sequence .= ")";
        }
        if (strlen($keywords_sequence) < 5) { $keywords_sequence = ''; }
       
        return $keywords_sequence;
    }

    /**
     *
     * @param type $html
     * @return type
     * @author Whiteflash, 2018-10-23
     */

    function parseSubstitutions($html) {

        if (strpos($html, 'substitutions') !== false) {

            if(preg_match_all('/(\[substitutions [^\]]+\])/', $html, $matches)){
                foreach($matches[1] AS $match){

                    $quantifier = '';
                    $regex = '{(.[^{]*?)}';
                    $regex = '(?<={)(.[^{]*?)(?=})';

                    $left_brace = strpos($match, '{');
                    $right_brace = strrpos($match, '}');

                    $captured_raw_jsonstring = substr($match, $left_brace, (($right_brace - $left_brace) + 1));
                    $captured_jsonstring = str_replace('\'', '"', strip_tags($captured_raw_jsonstring));

                    $arguments = json_decode($captured_jsonstring);

                    if ($arguments !== NULL) {                        
                        foreach ($arguments as $search => $argument) {
                            if (is_object($argument)) {
                                $substitution = $limit = null;
                                $validity_range = array();
                                foreach ($argument as $command => $c_argument) {
                                    if ($command == 'substitution') {
                                        $substitution = $c_argument;
                                    } elseif ($command == 'limit') {
                                        $limit = $c_argument;
                                    } elseif ($command == 'validity') {
                                        if (!is_object($c_argument)) {
                                            $validity_range = array($c_argument);
                                        } else {
                                            foreach ($c_argument as $cc_key => $cc_argument) { $validity_range[] = $cc_argument; }
                                        }
                                    } else {
                                        // unknown $command
                                    }
                                }

                                // check if substitution found
                                if ($substitution !== null) {
                                    foreach ($validity_range as $identifyer) {
                                        $elements = array();
                                        if (($identifyer == 'products_name') || ($identifyer == 'name')) {
                                            $tagname = 'div';
                                            $elements = findElements($html, $search, $tagname, array('class', 'nameWr'));
                                        } elseif ($identifyer == 'text') {
                                            $tagname = 'p';
                                            $elements = findElements($html, $search, $tagname, array());
                                        } else {
                                            continue;
                                        }

                                        if(!empty($elements)) {
                                            $count_replaces = 0;
                                            foreach ($elements as $element) {
                                                if (($limit !== null) && ($count_replaces >= $limit)) { continue; }
                                                $new_replace = str_replace($search, $substitution, $element['inner_html']);
                                                $html = str_replace($element['inner_html'], $new_replace, $html);
                                                $count_replaces++;
                                            }
                                        }
                                    }
                                }
                            } else {
                                $html = str_replace($search, $argument, $html);
                            }
                        }
                    }
                    // remove substitutions-instructions from output
                    if (strpos($html, '[substitutions')!==false)
                        $html = preg_replace('/(\[substitutions [^\]]+\])/', '', $html);
                }
            }
        }

        return $html;
    }

    /**
     *
     * @param string $string
     * @param string $search
     * @param string $tagname
     * @param array $identifying, optional
     * @return array | boolean false on error
     * @author Whiteflash, 2018-10-23
     */

    function findElements($string, $search, $tagname, $identifying = array()) {


        $elements = array();
        $security_chars = 10;

        while (($pos = (strpos($string, $tagname, $offset))) !== false) {

            $end_of_tag_pos = strpos($string, '>', $pos);
            $start_of_next_tag_pos = null;

            if (!empty($identifying)) {
                $identifyer_length = strlen($identifying[0]) + strlen($identifying[1]) + $security_chars;
                $controllstring = substr($string, $pos, $identifyer_length);
                if (strpos($controllstring, $identifying[1]) === false) {
                    $start_of_next_tag_pos = strpos($string, '</'.$tagname, $end_of_tag_pos);
                    $start_of_next_tag_pos_sec = strpos($string, '</ '.$tagname, $end_of_tag_pos);
                } else {
                    // nothing? - no, do nothing
                }
            } else {
                $start_of_next_tag_pos = strpos($string, '</'.$tagname, $end_of_tag_pos);
                $start_of_next_tag_pos_sec = strpos($string, '</ '.$tagname, $end_of_tag_pos);
            }

            // check for problems in setup of the html-tags
            if (($start_of_next_tag_pos_sec - $start_of_next_tag_pos) > 1) { return false; }

            // recompare start-pos of next tag
            if ($start_of_next_tag_pos_sec > $start_of_next_tag_pos) $start_of_next_tag_pos = $start_of_next_tag_pos_sec;

            if ($start_of_next_tag_pos !== null) {
                $inner_html = substr($string, ($end_of_tag_pos + 1), (($start_of_next_tag_pos - $end_of_tag_pos) - 1));
                if (strpos($inner_html, $search) !== false) {
                    $elements[] = array('inner_html'=>$inner_html, 'start'=>($end_of_tag_pos + 1), 'end'=>(($start_of_next_tag_pos - $end_of_tag_pos) - 1));
                }
            }
            // upcount offset
            $offset = $pos + 1;
        }

        return $elements;
    }

    /**
     * Function evaluates all restrictions from the given snippet-string.
     * @param string $snippet
     * @return array
     * @author Whiteflash, 2018-10-23
     */

    function setRestrictions($snippet) {
       
        // return already known restrictions
        if (key_exists($snippet, $_SESSION['snippets'])) return $_SESSION['snippets'][$snippet];

        $restrictions = array();

        if(preg_match('/limit\=\'([^\']+)\'/', $snippet, $modding_matches)) $restrictions['limit'] = intval($modding_matches[1]);
        if(preg_match('/order_by\=\'([^\']+)\'/', $snippet, $modding_matches)) $restrictions['order_by'] = (!empty($modding_matches[1]))?explode(':', $modding_matches[1]):null;
        if(preg_match('/random\=\'([^\']+)\'/', $snippet, $modding_matches)) $restrictions['random'] = intval($modding_matches[1]);
        // check order_by-statement
        if (!strstr($restrictions['order_by'][0], '.')) getColumsTable($restrictions['order_by'][0]);
        if (empty($restrictions['order_by'][1])) $restrictions['order_by'][1] = 'asc';

        if(preg_match('/excludes\=\'([^\']+)\'/', $snippet, $modding_matches)) $excludes = (!empty($modding_matches[1]))?explode(':', $modding_matches[1]):null;
        // check excludes-statement
        if (strstr($excludes[0], '.')) unsetColumsTable($excludes[0]);
        $excludes[1]=explode(',', $excludes[1]);
        array_walk($excludes[1], 'trim');
        $restrictions['excludes']=array($excludes[0] => $excludes[1]);
       
        // prepare (and save) restriction
        if (!is_array($_SESSION['snippets'])) $_SESSION['snippets'] = array();
        $_SESSION['snippets'][$snippet] = $restrictions;

        return $restrictions;
    }

    /**
     * Unsets all given table-prefixes of th given $input.
     * @param string $input
     * @author by Whiteflash, 2018-10-23
     */

    function unsetColumnsTable(&$input) {

        $input=preg_replace('#.*\.#', '', $input);
    }

    /**
     * Switches table-prefix for $input (column) or set it to null, if no match given.
     * @param string $input
     * @author Whiteflash, 2018-10-23
     */

    function getColumsTable(&$input) {


        switch ($input) {
            case "products_id": $input='p.'.$input; break;
            case "products_model": $input='p.'.$input; break;
            case "products_status": $input='p.'.$input; break;
            case "products_name": $input='pd.'.$input; break;
            case "products_keywords": $input='pd.'.$input; break;

            default: $input=null;
        }
    }

    /**
     * Function replaces all non-digit characters from incomming string.
     * @param type $input
     * @return string
     */

    function sanitizeIdentifyerstrings($input) {
       
        return preg_replace('/[^\d]*/', '', $input);
    }
    ?>
     

    Timm

    • Fördermitglied
    • Beiträge: 6.165
    Re: MODUL: Themenwelten
    Antwort #171 am: 23. Januar 2020, 21:47:44
    Damit es nicht verloren geht.

    Hier Inserttags als smarty.modifier gibts was ähnliches. Vielleicht sogar mit größerem Umfang.

    Gruß Timm

    demoncleaner

    • Fördermitglied
    • Beiträge: 468
    Re: MODUL: Themenwelten
    Antwort #172 am: 25. Januar 2020, 08:18:42
    Vielleicht verstehe ich das Modul Inserttags als smarty.modifier falsch aber damit kann ich doch nicht leicht - so wie hier - an gewünschter Stelle zB die Artikel einer ganzen Kategorie anzeigen und komplett auflisten, oder doch?

    demoncleaner

    • Fördermitglied
    • Beiträge: 468
    Re: MODUL: Themenwelten
    Antwort #173 am: 25. Januar 2020, 09:06:10
    Leider habe ich gerade festgestellt, dass bei meinem Umbau oben um auch products_ids eingeben zu können die restrictions nicht mehr funktionieren. Heißt ich kann weder was excluden noch über order_by sortieren. Leider finde ich den Fehler nicht.
    Prinzipiell hab ich einfach nur überall dort wo products_models vorhanden war products_ids ergänzt.

    demoncleaner

    • Fördermitglied
    • Beiträge: 468
    Re: MODUL: Themenwelten
    Antwort #174 am: 25. Januar 2020, 10:14:46
    Sorry. Hier jetzt nochmal die korrekte Version wo auch products_ids eingegeben werden können.

    Ich habe außerdem bei order_by eine Änderung vorgenommen. Da ich nach product_name sortieren wollte mir es dann die Produkte aber nicht richtig sortiert hat.

    Ich hatte:

    "Produkt 1000"

    vor

    "Produkt 500"

    stehen. Was in meinem Fall schlecht war.

    Folgendes habe ich dafür verändert:

    Ersetze:

    Code: PHP  [Auswählen]
    if (!empty($restrictions['order_by'][0])) $q .= " ORDER BY ".$restrictions['order_by'][0]." ".$restrictions['order_by'][1];
     

    durch:
    Code: PHP  [Auswählen]
     if (!empty($restrictions['order_by'][0])) $q .= " ORDER BY LENGTH(".$restrictions['order_by'][0]."), ".$restrictions['order_by'][0]."  ".$restrictions['order_by'][1];
     

    Und hier nochmal der gesamte Code:

    Code: PHP  [Auswählen]
    <?php

    function smarty_modifier_contentenhancer ($html) {
       
       
        // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying setting template
        if(preg_match_all('/(\[([\w\d ]*)template[^\]]+\])/', $html, $matches)){
            foreach($matches[1] AS $snippet){
                if(preg_match('/template\=\'([^\']+)\'/', $snippet, $template_matches)){
                    if (!empty($template_matches[1])) {
                        $template=$template_matches[1];
                        $template_usage=(!empty($matches[2][0])) ? $matches[2][0] : "all";
                        $html = str_replace($snippet, '', $html);
                        break;
                    }
                }
            }
        }
        // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying setting template


        if(preg_match_all('/(\[products [^\]]+\])/', $html, $matches)){
            foreach($matches[1] AS $snippet){
                $products_models = null;
                $products_ids = null;
                $categories_ids = null;
                $keywords = null;

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/products_models\=\'([^\']+)\'/', $snippet, $model_matches)){
                    $t_models = explode(',', $model_matches[1]);
                    $products_models = array();
                    foreach($t_models AS $model){
                        $raw_model = xtc_db_input(trim($model));
                        if (strlen($raw_model) < 10) { $raw_model = str_pad($raw_model, 10, "0", STR_PAD_LEFT); }
                        $products_models[] = xtc_db_input(sanitizeIdentifyerstrings($raw_model));
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/products_ids\=\'([^\']+)\'/', $snippet, $id_matches)){
                    $t_ids = explode(',', $id_matches[1]);
                    $products_ids = array();
                    foreach($t_ids AS $id){
                        $raw_id = xtc_db_input(trim($id));
                        if (strlen($raw_id) < 10) { $raw_id = str_pad($raw_id, 10, "0", STR_PAD_LEFT); }
                        $products_ids[] = xtc_db_input(sanitizeIdentifyerstrings($raw_id));
                    }
                }

               
                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/categories_ids\=\'([^\']+)\'/', $snippet, $categories_ids_matches)){
                    $t_categories_ids = explode(',', $categories_ids_matches[1]);
                    $categories_ids = array();
                    foreach($t_categories_ids AS $categories_id){
                        $categories_ids[] = (int)$categories_id;
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models
                $restrictions=setRestrictions($snippet);
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for product_models

                if(preg_match('/keywords\=\'([^\']+)\'/', $snippet, $keyword_matches)){
                    $t_keywords = explode(',', $keyword_matches[1]);
                    $keywords = array();
                    foreach($t_keywords AS $keyword){
                        $keywords[] = xtc_db_input(trim($keyword));
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Products (with selected template) for keyword with  $limit, $order_by, $exclusion (change function call)
                if (($template_usage == 'all') || ($template_usage == 'categories')) {
                    $html = str_replace($snippet, parseProducts($products_models,$products_ids, $categories_ids, $keywords, $restrictions, $template), $html);
                } else {
                    $html = str_replace($snippet, parseProducts($products_models,$products_ids, $categories_ids, $keywords, $restrictions), $html);
                }
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Products (with selected template) for keyword with  $limit, $order_by, $exclusion (change function call)

            }
        }

        if(preg_match_all('/(\[categories [^\]]+\])/', $html, $matches)){
            foreach($matches[1] AS $snippet){

                if(preg_match('/categories_ids\=\'([^\']+)\'/', $snippet, $categories_ids_matches)){
                    $t_categories_ids = explode(',', $categories_ids_matches[1]);
                    $categories_ids = array();
                    foreach($t_categories_ids AS $categories_id){
                        $categories_ids[] = (int)$categories_id;
                    }
                }

                if(preg_match('/keywords\=\'([^\']+)\'/', $snippet, $keyword_matches)){
                    $t_keywords = explode(',', $keyword_matches[1]);
                    $keywords = array();
                    foreach($t_keywords AS $keyword){
                        $keywords[] = xtc_db_input(trim($keyword));
                    }
                }

                // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Categories (with selected template)
                $restrictions=setRestrictions($snippet);
                if (($template_usage == 'all') || ($template_usage == 'categories')) {
                    $html = str_replace($snippet, parseCategories($categories_ids, $keywords, $restrictions, $template), $html);
                } else {
                    $html = str_replace($snippet, parseCategories($categories_ids, $keywords, $restrictions), $html);
                }
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - parse Categories (with selected template)
            }
        }

        // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword with  $limit, $order_by, $exclusion (change function call)
        $html = parseSubstitutions($html);
        // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword with  $limit, $order_by, $exclusion (change function call)

        return $html;

    }


    function /* parseCategories($categories_ids = NULL) { */
        parseCategories($categories_ids = null, $keywords = null, $restrictions = null, $template = '/module/modules/content_enhancer/listing_cats.html'){ // Whiteflash: Modul Content-Enhancer - mod modifying sql_settings for keyword with $limit

        if ((is_array($categories_ids)) || (is_array($keywords))) {

            if (GROUP_CHECK == 'true') {
                    $group_check = "c.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 AND";
            }

            // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
            $keywords_sequence = generateKeywordsequence($categories_ids, $keywords, 'cd', array('categories_name', 'categories_description'));

            $q = "SELECT
                            c.categories_id,
                            c.categories_image,  
                            cd.categories_name,
                            cd.categories_description
                    FROM categories AS c
                    LEFT JOIN categories_description as cd
                    ON c.categories_id = cd.categories_id
                    WHERE c.categories_id IN ('"
    .implode("', '", $categories_ids)."')
                    "
    .$keywords_sequence." -- Whiteflash 2018-10-23: add keywords_sequence
                    AND "
    .$group_check." c.categories_status = '1'
                    AND cd.language_id = '"
    .(int) $_SESSION['languages_id'] ."'
                    ORDER BY FIND_IN_SET(c.categories_id,'"
    .implode(",", $categories_ids)."')";

            // Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for restrictions
            $q = convertRestrictions($q, $restrictions);

            $categories_query = xtDBquery($q);

            while($categories = xtc_db_fetch_array($categories_query, true)) {
                $category_link =xtc_category_link($categories['categories_id'],$categories['categories_name']);
                $module_content[] = array ('CATEGORY_NAME'        => $categories['categories_name'],
                    'CATEGORY_IMAGE_TRUE'  => $categories['categories_image'],        
                    'CATEGORY_IMAGE'       => DIR_WS_IMAGES .'categories/' . $categories['categories_image'],
                    'CATEGORY_LINK'        => xtc_href_link(FILENAME_DEFAULT,  xtc_get_all_get_params(array(array('cat','page','filter_id','manufacturers_id'))) . $category_link),
                    'CATEGORY_DESCRIPTION' => $categories['categories_description'],
                    'CATEGORY_DESCRIPTION_INTRO' => shortenStringOnNextSpace($categories['categories_description'])
                 );


            }      
            //echo "<pre>";
            //var_dump($module_content);
            //echo "</pre>";
            $smarty = new Smarty;
            $smarty->assign('categories', $module_content);
            $smarty->assign('language', $_SESSION["language"]);

            // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $template_chck = str_replace('//', '/', DIR_FS_CATALOG) .'templates/'. CURRENT_TEMPLATE. $template;
            $used_template = (file_exists($template_chck)) ? CURRENT_TEMPLATE.$template : CURRENT_TEMPLATE.'/module/modules/content_enhancer/listing_cats.html';
            // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $html = $smarty->fetch($used_template);

            return $html;
        }
    }

    function /* parseProducts($products_models = null, $categories_ids = null, $keywords = null){ */
        parseProducts($products_models = null, $products_ids = null, $categories_ids = null, $keywords = null, $restrictions = null, $template = '/module/modules/content_enhancer/listing.html'){ // Whiteflash: Modul Content-Enhancer - mod modifying sql_settings for keyword with $limit
        if(is_array($products_models) || is_array($products_ids) || is_array($categories_ids) || is_array($keywords)){
            $group_check = '';
            $fsk_lock = '';

            if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
                $fsk_lock = ' AND p.products_fsk18!=1';
            }

            if (GROUP_CHECK == 'true') {
                $group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
            }

            $q = "SELECT * FROM
                            "
    .TABLE_PRODUCTS." p
                            JOIN "
    .TABLE_PRODUCTS_DESCRIPTION." pd ON (p.products_id = pd.products_id AND pd.language_id = ".(int)$_SESSION["languages_id"].")
                  WHERE
                        p.products_status = 1 "
    .$fsk_lock.$group_check;

            if(is_array($products_models)){
                $q .= " AND p.products_model IN ('".implode("', '", $products_models)."') ";
            }

            if(is_array($products_ids)){
                $q .= " AND p.products_id IN ('".implode("', '", $products_ids)."') ";
            }

            if(is_array($categories_ids)){
                $q .= " AND p.products_id IN (SELECT p2c.products_id FROM ".TABLE_PRODUCTS_TO_CATEGORIES." p2c WHERE p2c.categories_id IN (".implode(',', $categories_ids).")) ";
            }
           
           
            if(is_array($keywords)){
                    // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q .= generateKeywordsequence($categories_ids, $keywords, 'pd', array('products_keywords', 'products_name', 'products_description'), 'AND');
            }
                    // Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                    $q = convertRestrictions($q, $restrictions);
           
           
            global $product;
            $module_content = array();
            $listing_query = xtDBquery($q);
            while ($listing = xtc_db_fetch_array($listing_query, true)) {

                 // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword
                if (is_array($restrictions['excludes'])) {
                    foreach ($restrictions['excludes'] as $column => $values) {
                        if ((!empty($listing[$column])) && (in_array($listing[$column], $values))) continue 2;
                    }
                }
                // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - mod modifying sql_settings for keyword

                $module_content[] =  $product->buildDataArray($listing);
            }

            $smarty = new Smarty;
            $smarty->assign('products', $module_content);
            $smarty->assign('language', $_SESSION["language"]);

            // BOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $template_chck = str_replace('//', '/', DIR_FS_CATALOG) .'templates/'. CURRENT_TEMPLATE. $template;
            $used_template = (file_exists($template_chck)) ? CURRENT_TEMPLATE.$template : CURRENT_TEMPLATE.'/module/modules/content_enhancer/listing.html';
            // EOF - Whiteflash 2018-10-23: Modul Content-Enhancer - check template file and set ready for use
            $html = $smarty->fetch($used_template);
            return $html;

        }

        return '';
    }

    /**
     *
     * @param type $input
     * @param type $target_length
     * @return string
     * @author Whiteflash, 2018-10-23
     */

    function shortenStringOnNextSpace($input, $target_length = 125) {


        $shorty = substr($input, 0, strpos($input, " ", $target_length));
        if ((!empty($shorty)) && (strlen($shorty) < strlen($input))) $shorty .= "...";

        return $shorty;
    }

    /**
     *
     * @param type $q
     * @param type $restrictions
     * @return string
     * @author Whiteflash, 2018-10-23
     */

    function convertRestrictions($q, $restrictions) {

       
        if (!empty($restrictions['excludes']['products_id'])) {
            $q .= " AND p.products_id NOT IN(";
            foreach ($restrictions['excludes']['products_id'] as $xcl_id) { $q .= $xcl_id.", "; }
            if (substr($q, -2) == ', ') { $q = substr($q, 0, -2); }
            $q .= ")";
        }
        if (!empty($restrictions['order_by'][0])) $q .= " ORDER BY LENGTH(".$restrictions['order_by'][0]."), ".$restrictions['order_by'][0]."  ".$restrictions['order_by'][1];
        if (!empty($restrictions['limit'])) $q .= " LIMIT ".$restrictions['limit'];
        if (!empty($restrictions['random'])) {
            if (($order_by_pos = strpos($q, 'ORDER BY')) !== false) $q = substr($q, 0, $order_by_pos);
            $q .= " ORDER BY RAND() ".((!empty($restrictions['random'])) ? ( (strtolower($restrictions['random']) == 'all') ? "" : "LIMIT ".$restrictions['random']."") : "")." ";
        }

        return $q;
    }

    /**
     *
     * @param array $categories_ids
     * @param array $keywords
     * @param string $table_shortcut
     * @param array $table_fields
     * @param string $concatenate, optional (null)
     * @return string keywordsequence
     * @author Whiteflash, 2018-10-23
     */

    function generateKeywordsequence($categories_ids, $keywords, $table_shortcut, $table_fields, $concatenate = null) {

        $keywords_sequence = (!empty($concatenate)) ? " ".$concatenate : "";
        if(is_array($keywords)) {
            $connector = (empty($categories_ids)) ? " " : " OR";
            $keywords_sequence .= $connector." (1!=1";
            foreach($keywords AS $keyword){
                for ($i=0;$i<count($table_fields);$i++) { $keywords_sequence .= " OR (".$table_shortcut.".".$table_fields[$i]." LIKE ('%".$keyword."%'))"; }
            }
            $keywords_sequence .= ")";
        }
        if (strlen($keywords_sequence) < 5) { $keywords_sequence = ''; }
       
        return $keywords_sequence;
    }

    /**
     *
     * @param type $html
     * @return type
     * @author Whiteflash, 2018-10-23
     */

    function parseSubstitutions($html) {

        if (strpos($html, 'substitutions') !== false) {

            if(preg_match_all('/(\[substitutions [^\]]+\])/', $html, $matches)){
                foreach($matches[1] AS $match){

                    $quantifier = '';
                    $regex = '{(.[^{]*?)}';
                    $regex = '(?<={)(.[^{]*?)(?=})';

                    $left_brace = strpos($match, '{');
                    $right_brace = strrpos($match, '}');

                    $captured_raw_jsonstring = substr($match, $left_brace, (($right_brace - $left_brace) + 1));
                    $captured_jsonstring = str_replace('\'', '"', strip_tags($captured_raw_jsonstring));

                    $arguments = json_decode($captured_jsonstring);

                    if ($arguments !== NULL) {                        
                        foreach ($arguments as $search => $argument) {
                            if (is_object($argument)) {
                                $substitution = $limit = null;
                                $validity_range = array();
                                foreach ($argument as $command => $c_argument) {
                                    if ($command == 'substitution') {
                                        $substitution = $c_argument;
                                    } elseif ($command == 'limit') {
                                        $limit = $c_argument;
                                    } elseif ($command == 'validity') {
                                        if (!is_object($c_argument)) {
                                            $validity_range = array($c_argument);
                                        } else {
                                            foreach ($c_argument as $cc_key => $cc_argument) { $validity_range[] = $cc_argument; }
                                        }
                                    } else {
                                        // unknown $command
                                    }
                                }

                                // check if substitution found
                                if ($substitution !== null) {
                                    foreach ($validity_range as $identifyer) {
                                        $elements = array();
                                        if (($identifyer == 'products_name') || ($identifyer == 'name')) {
                                            $tagname = 'div';
                                            $elements = findElements($html, $search, $tagname, array('class', 'nameWr'));
                                        } elseif ($identifyer == 'text') {
                                            $tagname = 'p';
                                            $elements = findElements($html, $search, $tagname, array());
                                        } else {
                                            continue;
                                        }

                                        if(!empty($elements)) {
                                            $count_replaces = 0;
                                            foreach ($elements as $element) {
                                                if (($limit !== null) && ($count_replaces >= $limit)) { continue; }
                                                $new_replace = str_replace($search, $substitution, $element['inner_html']);
                                                $html = str_replace($element['inner_html'], $new_replace, $html);
                                                $count_replaces++;
                                            }
                                        }
                                    }
                                }
                            } else {
                                $html = str_replace($search, $argument, $html);
                            }
                        }
                    }
                    // remove substitutions-instructions from output
                    if (strpos($html, '[substitutions')!==false)
                        $html = preg_replace('/(\[substitutions [^\]]+\])/', '', $html);
                }
            }
        }

        return $html;
    }

    /**
     *
     * @param string $string
     * @param string $search
     * @param string $tagname
     * @param array $identifying, optional
     * @return array | boolean false on error
     * @author Whiteflash, 2018-10-23
     */

    function findElements($string, $search, $tagname, $identifying = array()) {


        $elements = array();
        $security_chars = 10;

        while (($pos = (strpos($string, $tagname, $offset))) !== false) {

            $end_of_tag_pos = strpos($string, '>', $pos);
            $start_of_next_tag_pos = null;

            if (!empty($identifying)) {
                $identifyer_length = strlen($identifying[0]) + strlen($identifying[1]) + $security_chars;
                $controllstring = substr($string, $pos, $identifyer_length);
                if (strpos($controllstring, $identifying[1]) === false) {
                    $start_of_next_tag_pos = strpos($string, '</'.$tagname, $end_of_tag_pos);
                    $start_of_next_tag_pos_sec = strpos($string, '</ '.$tagname, $end_of_tag_pos);
                } else {
                    // nothing? - no, do nothing
                }
            } else {
                $start_of_next_tag_pos = strpos($string, '</'.$tagname, $end_of_tag_pos);
                $start_of_next_tag_pos_sec = strpos($string, '</ '.$tagname, $end_of_tag_pos);
            }

            // check for problems in setup of the html-tags
            if (($start_of_next_tag_pos_sec - $start_of_next_tag_pos) > 1) { return false; }

            // recompare start-pos of next tag
            if ($start_of_next_tag_pos_sec > $start_of_next_tag_pos) $start_of_next_tag_pos = $start_of_next_tag_pos_sec;

            if ($start_of_next_tag_pos !== null) {
                $inner_html = substr($string, ($end_of_tag_pos + 1), (($start_of_next_tag_pos - $end_of_tag_pos) - 1));
                if (strpos($inner_html, $search) !== false) {
                    $elements[] = array('inner_html'=>$inner_html, 'start'=>($end_of_tag_pos + 1), 'end'=>(($start_of_next_tag_pos - $end_of_tag_pos) - 1));
                }
            }
            // upcount offset
            $offset = $pos + 1;
        }

        return $elements;
    }

    /**
     * Function evaluates all restrictions from the given snippet-string.
     * @param string $snippet
     * @return array
     * @author Whiteflash, 2018-10-23
     */

    function setRestrictions($snippet) {
       
        // return already known restrictions
        if (key_exists($snippet, $_SESSION['snippets'])) return $_SESSION['snippets'][$snippet];

        $restrictions = array();

        if(preg_match('/limit\=\'([^\']+)\'/', $snippet, $modding_matches)) $restrictions['limit'] = intval($modding_matches[1]);
        if(preg_match('/order_by\=\'([^\']+)\'/', $snippet, $modding_matches)) $restrictions['order_by'] = (!empty($modding_matches[1]))?explode(':', $modding_matches[1]):null;
        if(preg_match('/random\=\'([^\']+)\'/', $snippet, $modding_matches)) $restrictions['random'] = intval($modding_matches[1]);
        // check order_by-statement
        if (!strstr($restrictions['order_by'][0], '.')) getColumsTable($restrictions['order_by'][0]);
        if (empty($restrictions['order_by'][1])) $restrictions['order_by'][1] = 'asc';

        if(preg_match('/excludes\=\'([^\']+)\'/', $snippet, $modding_matches)) $excludes = (!empty($modding_matches[1]))?explode(':', $modding_matches[1]):null;
        // check excludes-statement
        if (strstr($excludes[0], '.')) unsetColumsTable($excludes[0]);
        $excludes[1]=explode(',', $excludes[1]);
        array_walk($excludes[1], 'trim');
        $restrictions['excludes']=array($excludes[0] => $excludes[1]);
       
        // prepare (and save) restriction
        if (!is_array($_SESSION['snippets'])) $_SESSION['snippets'] = array();
        $_SESSION['snippets'][$snippet] = $restrictions;

        return $restrictions;
    }

    /**
     * Unsets all given table-prefixes of th given $input.
     * @param string $input
     * @author by Whiteflash, 2018-10-23
     */

    function unsetColumnsTable(&$input) {

        $input=preg_replace('#.*\.#', '', $input);
    }

    /**
     * Switches table-prefix for $input (column) or set it to null, if no match given.
     * @param string $input
     * @author Whiteflash, 2018-10-23
     */

    function getColumsTable(&$input) {


        switch ($input) {
            case "products_id": $input='p.'.$input; break;
            case "products_model": $input='p.'.$input; break;
            case "products_status": $input='p.'.$input; break;
            case "products_name": $input='pd.'.$input; break;
            case "products_keywords": $input='pd.'.$input; break;

            default: $input=null;
        }
    }

    /**
     * Function replaces all non-digit characters from incomming string.
     * @param type $input
     * @return string
     */

    function sanitizeIdentifyerstrings($input) {
       
        return preg_replace('/[^\d]*/', '', $input);
    }
    ?>
     

    Timm

    • Fördermitglied
    • Beiträge: 6.165
    Re: MODUL: Themenwelten
    Antwort #175 am: 04. Februar 2020, 13:07:15
    Moin

    1)
    In meinem 2.0.5.0 Testshop mit PHP 7.3.14 wirft das Modul folgenden Fehler (Notice).

    Code: XML  [Auswählen]
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Undefined variable: group_check in File: /var/www/vhosts/example.de/shopfgbz/templates/tpl_modified_responsive_1/smarty/modifier.contentenhancer.php on Line: 76        {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #0 - /var/www/vhosts/example.de/shopfgbz/templates_c/55112b99fc46dbaf3cc12d4f4e7ebf1a81f8fd88_0.file.index.html.php called at Line 116        {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #1 - /var/www/vhosts/example.de/shopfgbz/includes/external/smarty/smarty_3/sysplugins/smarty_template_resource_base.php called at Line 123    {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #2 - /var/www/vhosts/example.de/shopfgbz/includes/external/smarty/smarty_3/sysplugins/smarty_template_compiled.php called at Line 114 {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #3 - /var/www/vhosts/example.de/shopfgbz/includes/external/smarty/smarty_3/sysplugins/smarty_internal_template.php called at Line 216 {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #4 - /var/www/vhosts/example.de/shopfgbz/includes/external/smarty/smarty_3/sysplugins/smarty_internal_templatebase.php called at Line 232     {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #5 - /var/www/vhosts/example.de/shopfgbz/includes/external/smarty/smarty_3/sysplugins/smarty_internal_templatebase.php called at Line 134     {}      {}
    [2020-02-04 11:45:58]   [notice]        [modified]      [pid:15293]     Backtrace #6 - /var/www/vhosts/example.de/shopfgbz/index.php called at Line 41  {}      {}

    Wo oder wie kann man die Variable definieren?

    2)
    Seit 2.0.5.0 gibt es die Methode "get image" für die Klasse main. Hat jemand Zeit und Lust das Modul dahingehend upzudaten?

    Dadurch könnte man/ich sich /mir zb das Einbinden von Dateien ersparen zur Manipulation von Bildnamen. Eventuell gäbe es noch weitere Vorteile und es hat nicht nur für mich Vorteile.

    3)
    Theoretisch wäre es wohl sogar möglich die Änderungen in der Index.html durch short code updatesicher das Template betreffend auszulagern. Soll aber aufwendiger sein. Mir nicht so wichtig, da die Datei eh bei mir geändert ist. Aber vielleicht mal interessant, wenn jemand das updatesicher umbauen möchte.

    Dann wären nur noch das css File nicht updatesicher, dass in der general_bottom.css.php eingebunden wird. Aber vielleicht gibts da ja auch irgendwann ein extra Verzeichnis, wie es in Shopversion 2.0.5.0 bei den Javascriptfiles gemacht wurde.

    Gruß Timm

    EDIT:

    4)
    Man kann Produkte auf eine Content-Seite packen, die alle bestimmte keywords enthalten. Diese Keywords wird aber wohl kaum einer noch füllen, da Google sich dafür nicht interessiert.

    Wäre es auch möglich Artikel dort zu platzieren, die einen bestimmten Wert einer Artikeleigenschaft gemein haben?

    Bsp. wäre: Zeige alle Produkte, die bei der Artikeleigenschaft Farbe den Wert rot haben. Dadurch könnte man sich extra Seiten bauen mit Artikeln die alle die Farbe rot haben und das über Kategorien hinweg. Das wäre in meinem Fall eine Landingpage für rote Stoffe. Falls jemand bei Google nur rote Stoffe eingibt, scheint mir das ziemlich sinnvoll.

    karsta.de

    • Experte
    • Beiträge: 3.048
    Re: MODUL: Themenwelten
    Antwort #176 am: 04. Februar 2020, 13:56:01
    Hallo Timm,
    zu 1.
    Hier sind inzwischen so viele verschiedene Änderungen und das Modul scheinbar bei jedem ein anderes.
    Bei mir läuft das Modul unter PHP 7.3.11, Shopversion 2.0.5.0 fehlerfrei.
    Vielleicht hängst du mal deine smarty-Datei ran, damit man den Fehler lokalisieren und dir vielleicht helfen kann.

    BG Karsta

    Timm

    • Fördermitglied
    • Beiträge: 6.165
    Re: MODUL: Themenwelten
    Antwort #177 am: 04. Februar 2020, 15:54:00
    Hallo Karsta

    Ich nutze die v1.4.2 aus Beitrag 1.

    In der Datei hab ich nur eine Änderung (Einbindung einer Datei für die Bildernamenmanipulation), aber die hat denke ich mit der Fehlermeldung nichts zu tun, da es wesentlich weiter unten in der Datei eingetragen ist.

    Gruß Timm

    karsta.de

    • Experte
    • Beiträge: 3.048
    Re: MODUL: Themenwelten
    Antwort #178 am: 04. Februar 2020, 17:11:07
    Hast du den Kundengruppencheck an?
    Die Zeile, die den Fehler anzeigt ist in meinem Script gleich. Schreib mal in Zeile 63
    $group_check = '';
    also vor  if (GROUP_CHECK == 'true') {

    BG Karsta

    Timm

    • Fördermitglied
    • Beiträge: 6.165
    Re: MODUL: Themenwelten
    Antwort #179 am: 04. Februar 2020, 17:45:53
    Danke Karsta

    Kundengruppencheck war und ist deaktiviert.

    Mit der neuen Zeile kommt der Fehler nicht mehr. Vorher reichte es schon auf die Startseite zu gehen, wo mit dem Modul die Kategorien angezeigt werden. Kann/soll das standardmäßig dann so bleiben? Würde das den Kundengruppencheck beeinflussen, falls man ihn mal nutzen wollen würde?

    Gruß Timm
    5 Antworten
    3476 Aufrufe
    12. September 2010, 21:03:02 von Haina
    9 Antworten
    3125 Aufrufe
    04. Januar 2019, 17:14:15 von Shorty
    106 Antworten
    52114 Aufrufe
    06. März 2021, 19:27:04 von awids
               
    anything