XT Commerce



  • Apart from xtcommerce being a big pile of pure failure (every single function in it's own .inc.php file, globals called $foo, ...), i just stumbled upon a small function that made me go WhatTF:

    I'd guess the coder got paid by the character as i cannot really see any advantage of using this function... 

    function xtc_string_to_int($string) {
        return (int)$string;
    }

     

     

    Ok, i see you are not shocked enough, maybe this one will add some value to this post. It took me a while to figure out how this function works.

     

     

    function xtc_show_category($counter) {
        global $foo, $categories_string, $id;

        // image for first level
        $img_1='<img src="templates/'.CURRENT_TEMPLATE.'/img/icon_arrow.jpg" alt="" />&nbsp;';

        for ($a=0; $a<$foo[$counter]['level']; $a++) {
            if ($foo[$counter]['level']=='1') {
                $categories_string .= "&nbsp;-&nbsp;";
            }
            $categories_string .= "&nbsp;&nbsp;";
        }
        if ($foo[$counter]['level']=='') {
            if (strlen($categories_string)=='0') {
                $categories_string .='<table width="100%"><tr><td class="moduleRow">';
            } else {
                $categories_string .='</td></tr></table><table width="100%"><tr><td class="moduleRow">';
            }

            $categories_string .= $img_1;
            $categories_string .= '<b><a href="';
        } else {
            $categories_string .= '<a href="';
        }

        $cPath_new=xtc_category_link($counter,$foo[$counter]['name']);

        $categories_string .= xtc_href_link(FILENAME_DEFAULT, $cPath_new);
        $categories_string .= '">';

        if ( ($id) && (in_array($counter, $id)) ) {
            $categories_string .= '<b>';
        }

        // display category name
        $categories_string .= $foo[$counter]['name'];

        if ( ($id) && (in_array($counter, $id)) ) {
            $categories_string .= '</b>';
        }

        if ($foo[$counter]['level']=='') {
            $categories_string .= '</a></b>';
        } else {
            $categories_string .= '</a>';
        }

        if (SHOW_COUNTS == 'true') {
            $products_in_category = xtc_count_products_in_category($counter);
            if ($products_in_category > 0) {
                $categories_string .= '&nbsp;(' . $products_in_category . ')';
            }
        }

        $categories_string .= '<br />';

        if ($foo[$counter]['next_id']) {
            xtc_show_category($foo[$counter]['next_id']);
        } else {
            $categories_string .= '</td></tr></table>';
        }
    }

     

    Indentation by me. I tried to shorten this stuff but this would have only been possible by removing several WTFs.



  • It appears to be another fork/ripoff of osCommerce, another big pile of fail I've had the pleasure of working with.

    For example, take an xtc_ function and google it replacing "xtc" with "tep" (osCommerce's prefix for many built-in fuctions, which reference its former name, "the exchange project"). The coding style looks identical, including the braindead "templating" approach, even though XT claims to use Smarty. Ugh.



  •  Well, it _does_ use smarty, eventhough in a "echo $output" way.

    For example the templates for all the boxes (what's new, cart, newsletter, etc) looks exactly this way:

     

     {config_load file="$language/lang_$language.conf" section="boxes"}
    <table width="100%" border="0" cellpadding="2" cellspacing="0">
      <tr>
        <td class="infoBoxHeading"><table width="100%"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td class="infoBoxHeading">{#heading_content#} </td>
            <td></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td class="infoBox" align="left"><table width="95%"  border="0" cellpadding="2" cellspacing="0">
            <tr>
              <td class="boxText">{$BOX_CONTENT}</td>
            </tr>
        </table></td>
      </tr>
    </table>
     

     

    I leave it to you to figure out how they create $BOX_CONTENT (hint: $content .= "<img ...>";)



  • @whoever said:

    Ok, i see you are not shocked enough, maybe this one will add some value to this post. It took me a while to figure out how this function works.

     function xtc_show_category($counter) {

    //insert ugly "nbsp-based text category links tree in HTML table" code here

    }

     

    It took you a while to figure out what that does? Sure the code is uglier than a mexican hairless, but there is still no way it should take more than maybe 30 seconds to figure out what it's doing...

    Granted, it definitely be a million times easier to debug if they hadn't used a recursive string concatenation to print the table, but still.


Log in to reply