Example #1
0
 public static function getProductFormData($id = null)
 {
     global $_module, $lC_Database, $lC_Language;
     $lC_Language->loadIniFile('products.php');
     $lC_CategoryTree = new lC_CategoryTree_Admin();
     $result = array();
     if (isset($id) && is_numeric($id)) {
         $Qcategories = $lC_Database->query('select categories_id from :table_products_to_categories where products_id = :products_id');
         $Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qcategories->bindInt(':products_id', $id);
         $Qcategories->execute();
         $in_categories = array();
         while ($Qcategories->next()) {
             $in_categories[] = $Qcategories->valueInt('categories_id');
         }
         $cnt = 0;
         $in_categories_path = '';
         foreach ($in_categories as $category_id) {
             $in_categories_path .= $lC_CategoryTree->getPath($category_id, 0, ' &raquo; ') . '<br />';
             if ($category_id == 0) {
                 $categories_array[] = array('id' => $category_id, 'text' => $lC_Language->get('top_category'));
             } else {
                 $categories_array[] = array('id' => $category_id, 'text' => $lC_CategoryTree->getPath($category_id, 0, ' &raquo; '));
             }
             $cnt++;
         }
         $result['inCategoriesCount'] = $cnt;
         $result['inCategoriesCheckbox'] = lc_draw_checkbox_field('product_categories[]', $categories_array, true, null, '&nbsp;<br />');
         if (!empty($in_categories_path)) {
             $in_categories_path = substr($in_categories_path, 0, -6);
             if (substr($in_categories_path, 0, 6) == '<br />') {
                 $in_categories_path = $lC_Language->get('top_category') . '<br />' . $in_categories_path;
             }
         }
         $result['categoryPath'] = $in_categories_path;
     }
     $categories_array = array('0' => '-- ' . $lC_Language->get('top_category') . ' --');
     foreach ($lC_CategoryTree->getArray() as $value) {
         $pid = end(explode('_', $value['id']));
         if (lC_Categories_Admin::getParent($pid) != 0) {
             foreach (explode('_', $value['id']) as $cats) {
                 if ($pid != $cats) {
                     $Qcpn = $lC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and language_id = :language_id');
                     $Qcpn->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
                     $Qcpn->bindInt(':language_id', $lC_Language->getID());
                     $Qcpn->bindInt(':categories_id', $cats);
                     $Qcpn->execute();
                     $titlestr .= $Qcpn->value('categories_name') . ' &raquo; ';
                 }
             }
             $title = $titlestr . $value['title'];
             unset($titlestr);
         } else {
             $title = $value['title'];
         }
         $categories_array[$value['id']] = $title;
     }
     $result['categoriesArray'] = $categories_array;
     return $result;
 }
Example #2
0
</option>
        <option value="delete"><?php 
echo $lC_Language->get('text_delete');
?>
</option>
      </select>
    </div>
    </form>
    <div class="clear-both"></div>
    <div class="six-columns twelve-columns-tablet">
      <div id="buttons-menu-div-listing">
        <div id="buttons-container" style="position: relative;" class="clear-both">
          <div style="float:right;">
            <p class="button-height" align="right">
              <?php 
$parentID = lC_Categories_Admin::getParent($_GET['categories']);
if (!empty($_GET['categories']) && is_numeric($_GET['categories'])) {
    ?>
                <a class="button" href="<?php 
    echo lc_href_link_admin(FILENAME_DEFAULT, $lC_Template->getModule() . ($parentID != '0' ? '=' . $parentID : NULL));
    ?>
">
                  <span class="button-icon anthracite-gradient">
                    <span class="icon-reply"></span>
                  </span><?php 
    echo $lC_Language->get('button_back');
    ?>
                </a>&nbsp;
                <?php 
}
?>