/**
  * Prints out debug information.
  * @since       3
  */
 protected function _printDebugInfo($sTemplatePath, $aArguments, $aOptions, $aProducts)
 {
     echo "<pre style='height: 300px; overflow-y: scroll; overflow-x: auto; padding: 0 1em'>";
     echo "<h3>Debug Info</h3>";
     echo "<h4>Template Path</h4>";
     AmazonAutoLinks_Debug::dump($sTemplatePath);
     echo "<h4>Unit Arguments</h4>";
     AmazonAutoLinks_Debug::dump($aArguments);
     echo "<h4>Plugin Options</h4>";
     AmazonAutoLinks_Debug::dump($aOptions);
     echo "<h4>Fetched Data</h4>";
     AmazonAutoLinks_Debug::dump($aProducts);
     echo "<span style='float:right;'>" . AmazonAutoLinks_Registry::NAME . ' ' . AmazonAutoLinks_Registry::VERSION . "</span>";
     echo "</pre>";
 }
 /**
  * @since       3.2.2
  * @return      string
  * @callback    filter      aal_filter_unit_output
  */
 public function _replyToAddHTMLBodies($sProductHTML, $sASIN, $sLocale)
 {
     $_aHTMLs = $this->_aHTMLs;
     $this->_aHTMLs = array();
     // reset for next outputs.
     return $sProductHTML . '<pre class="debug" style="max-height: 300px; overflow-y: scroll; overflow-x: auto; padding: 0 1em; word-wrap: break-word; word-break: break-all; margin: 1em 0;">' . '<h3>' . __('Debug Info', 'amazon-auto-links') . ' - ' . __('HTTP Bodies', 'amazon-auto-links') . '</h3>' . AmazonAutoLinks_Debug::get($_aHTMLs) . "</pre>";
 }
    /**
     * 
     * @uses        flush()
     */
    protected function _printPreviewTable($aPageElements)
    {
        // Instantiate the core object - the fetching process should be done while rendering the HTML output
        // because it takes some time so the flush() function is used in the middle.
        $_oAALCatPreview = new AmazonAutoLinks_Unit_category($this->oUnitOption);
        $_oAALUnitPreview = new AmazonAutoLinks_Unit_category($this->oUnitOption);
        // Buttons
        $bReachedLimit = $this->isNumberOfCategoryReachedLimit(count($this->oUnitOption->get('categories')) + count($this->oUnitOption->get('categories_exclude')));
        $bIsAlreadyAdded = $this->isAddedCategory($aPageElements['sBreadcrumb'], $this->oUnitOption->get('categories'));
        $bIsAlreadyAddedExcludingCategory = $this->isAddedCategory($aPageElements['sBreadcrumb'], $this->oUnitOption->get('categories_exclude'));
        $bIsSubCategoryOfAddedItems = $this->isSubCategoryOfAddedItems($aPageElements['sBreadcrumb'], $this->oUnitOption->get('categories'));
        $sAddDisabled = $this->isEmpty($aPageElements['sRSSURL']) || $bIsAlreadyAdded || $bIsAlreadyAddedExcludingCategory ? "disabled='disabled'" : "";
        $sExcludeDisabled = $this->isEmpty($this->oUnitOption->get('categories')) || $bIsAlreadyAdded || $bIsAlreadyAddedExcludingCategory || !$bIsSubCategoryOfAddedItems ? "disabled='disabled'" : "";
        $sRemoveDisabled = $this->isEmpty($this->oUnitOption->get('categories')) ? "disabled='disabled'" : "";
        $sCreateDisabled = $this->isEmpty($this->oUnitOption->get('categories')) ? "disabled='disabled'" : "";
        $sCreateOrSave = $aPageElements['bNew'] ? __('Create', 'amazon-auto-links') : __('Save', 'amazon-auto-links');
        // Arrows
        $sAddArrow = $aPageElements['bNew'] && !$this->isEmpty($aPageElements['sRSSURL']) && $this->isEmpty($this->oUnitOption->get('categories')) ? "<img class='category-select-right-arrow' title='" . __('Add the current selection!', 'amazon-auto-links') . "' src='" . AmazonAutoLinks_Registry::getPluginURL('asset/image/arrow_right.png') . "'/>" : "";
        $sCreateArrow = $aPageElements['bNew'] && !$this->isEmpty($aPageElements['sRSSURL']) && !$this->isEmpty($this->oUnitOption->get('categories')) ? "<img class='category-select-right-arrow' title='" . __('Create the unit!', 'amazon-auto-links') . "' src='" . AmazonAutoLinks_Registry::getPluginURL('asset/image/arrow_right.png') . "'/>" : "";
        $sSelectArrow = $aPageElements['bNew'] && $this->isEmpty($aPageElements['sRSSURL']) && $this->isEmpty($this->oUnitOption->get('categories')) ? "<img class='category-select-left-bottom-arrow' title='" . __('Select a category from the links!', 'amazon-auto-links') . "' src='" . AmazonAutoLinks_Registry::getPluginURL('asset/image/arrow_left_bottom.png') . "'/>" : "";
        ?>

<input type="hidden" name="amazon_auto_links_cat_select[category][breadcrumb]" value="<?php 
        echo $this->oEncrypt->encode($aPageElements['sBreadcrumb']);
        ?>
" />
<input type="hidden" name="amazon_auto_links_cat_select[category][feed_url]" value="<?php 
        echo $aPageElements['sRSSURL'];
        ?>
" />
<input type="hidden" name="amazon_auto_links_cat_select[category][page_url]" value="<?php 
        echo $aPageElements['sPageURL'];
        ?>
" />
<table class="category-select-table">
    <tbody>
        <tr>
            <td class="category-select-first-column">                
                <h3><?php 
        _e('Current Selection', 'amazon-auto-links');
        ?>
</h3>
                <p class="category-select-breadcrumb"><?php 
        echo $aPageElements['sBreadcrumb'];
        ?>
</p>
            </td>
            <td class="category-select-second-column" colspan="2">        
                <div class="category-select-submit-buttons">
                    <span class="primary"><a class="button button-primary" href="<?php 
        echo $aPageElements['sBounceURL'];
        ?>
"><?php 
        _e('Go Back', 'amazon-auto-links');
        ?>
</a></span>
                    <span class="primary"><?php 
        echo $sCreateArrow;
        ?>
<input type="submit" name="amazon_auto_links_cat_select[save]" class="button button-primary" value="<?php 
        echo $sCreateOrSave;
        ?>
" <?php 
        echo $sCreateDisabled;
        ?>
 /></span>
                    <span><?php 
        echo $sAddArrow;
        ?>
<input type="submit" name="amazon_auto_links_cat_select[add]" class="button button-secondary" value="<?php 
        _e('Add Category', 'amazon-auto-links');
        ?>
" <?php 
        echo $sAddDisabled;
        ?>
 /></span>
                    <span><input type="submit" name="amazon_auto_links_cat_select[exclude]" class="button button-secondary" value="<?php 
        _e('Add Excluding Category', 'amazon-auto-links');
        ?>
" <?php 
        echo $sExcludeDisabled;
        ?>
 /></span>
                    <span><input type="submit" name="amazon_auto_links_cat_select[remove]" class="button button-secondary" value="<?php 
        _e('Remove Checked', 'amazon-auto-links');
        ?>
" <?php 
        echo $sRemoveDisabled;
        ?>
 /></span>
                </div>
                <div>
                    <h3><?php 
        _e('Added Categories', 'amazon-auto-links');
        ?>
</h3>
                    <?php 
        echo $aPageElements['sSelectedCategories'];
        ?>
                    <h3><?php 
        _e('Added Excluding Sub-categories', 'amazon-auto-links');
        ?>
</h3>
                    <?php 
        echo $aPageElements['sSelectedExcludingCategories'];
        ?>
                </div>
            </td>
        </tr>
        <tr>
            <td class="category-select-first-column">
                <h3><?php 
        _e('Select Category', 'amazon-auto-links');
        ?>
</h3>
                <?php 
        echo $sSelectArrow;
        ?>
                <?php 
        echo $aPageElements['sSidebarHTML'];
        ?>
            </td>
            <td class="category-select-second-column category-select-preview-left">
                <h3>
                    <?php 
        echo $aPageElements['sRSSURL'] ? __('Preview of This Category', 'amazon-auto-links') : __('No Preview', 'amazon-auto-links');
        ?>
                </h3>                        
                <div class="widthfixer" style="width:<?php 
        echo $this->oUnitOption->get('image_size');
        ?>
px;"></div>
                <?php 
        if ($aPageElements['sRSSURL']) {
            $_oAALCatPreview->render(array($aPageElements['sRSSURL']));
            // flush();
        } else {
            _e('Please select a category from the list on the left.', 'amazon-auto-links');
        }
        ?>
            </td>
            <td class="category-select-third-column category-select-preview-right">
                <h3><?php 
        _e('Unit Preview', 'amazon-auto-links');
        ?>
</h3>                            
                <div class="widthfixer" style="width:<?php 
        echo $this->oUnitOption->get('image_size');
        ?>
px;"></div>
                <?php 
        if (!$this->isEmpty($aPageElements['aSelectedRSSURLs'])) {
            $_oAALUnitPreview->render($aPageElements['aSelectedRSSURLs']);
            flush();
        } else {
            _e('Please add a category from the list after selecting it.', 'amazon-auto-links');
        }
        ?>
            </td>
        </tr>
    </tbody>
</table>    
            <?php 
        // Debug info
        $_oOption = AmazonAutoLinks_Option::getInstance();
        if ($_oOption->isDebug()) {
            echo "<h4>" . __('Debug Info', 'amazon-auto-links') . "</h4>";
            echo "<h5>" . __('Page URL', 'amazon-auto-links') . "</h5>";
            AmazonAutoLinks_Debug::dump($aPageElements['sPageURL']);
            echo "<h5>" . __('Feed URL', 'amazon-auto-links') . "</h5>";
            AmazonAutoLinks_Debug::dump($aPageElements['sRSSURL']);
        }
    }