/**
  @package    admin::functions
  @author     Loaded Commerce
  @copyright  Copyright 2003-2014 Loaded Commerce, LLC
  @copyright  Portions Copyright 2003 osCommerce
  @license    https://github.com/loadedcommerce/loaded7/blob/master/LICENSE.txt
  @version    $Id: lc_cfg_set_categories_top_category.php v1.0 2013-08-08 datazen $
*/
function lc_cfg_set_categories_top_category($default = 0, $key = null)
{
    global $lC_Database, $lC_Language, $lC_Vqmod;
    include_once $lC_Vqmod->modCheck(DIR_FS_ADMIN . 'includes/classes/category_tree.php');
    include_once $lC_Vqmod->modCheck(DIR_FS_ADMIN . 'includes/applications/categories/classes/categories.php');
    $lC_Language->loadIniFile('categories.php');
    $lC_CategoryTree = new lC_CategoryTree_Admin();
    $categories = array('0' => $lC_Language->get('top_category'));
    foreach ($lC_CategoryTree->getArray() as $value) {
        // added switch for only category mode categories in selection dropdown.
        if ($value['mode'] == 'category') {
            $cid = explode('_', $value['id']);
            $count = count($cid);
            $cid = end($cid);
            $acArr = lC_Categories_Admin::getAllChildren($id);
            $categories[$cid] = str_repeat("    ", $count - 1) . ' ' . $value['title'];
        }
    }
    $css_class = 'class="input with-small-padding mid-margin-top"';
    $name = empty($key) ? 'configuration_value' : 'configuration[' . $key . ']';
    $array = array();
    $array[] = array('id' => '', 'text' => $lC_Language->get('text_select_category'));
    foreach ($categories as $key => $value) {
        $array[] = array('id' => $key, 'text' => $value);
    }
    return lc_draw_pull_down_menu($name, $array, $default, $css_class);
}
Exemplo n.º 2
0
 public static function formData($id = null, $parent = null)
 {
     global $lC_Language, $_module;
     $lC_Language->loadIniFile('categories.php');
     $lC_CategoryTree = new lC_CategoryTree_Admin();
     $result = array();
     $categories_array = array('0' => $lC_Language->get('top_category'));
     foreach ($lC_CategoryTree->getArray() as $value) {
         $cid = explode('_', $value['id']);
         $count = count($cid);
         $cid = end($cid);
         $acArr = lC_Categories_Admin::getAllChildren($id);
         if ($cid != $id && !lC_Categories_Admin::in_array_r($cid, $acArr)) {
             $categories_array[$cid] = str_repeat("    ", $count - 1) . ' ' . $value['title'];
         }
     }
     $result['categoriesArray'] = $categories_array;
     if (isset($id) && is_numeric($id)) {
         $result['cData'] = lC_Categories_Admin::get($id, $lC_Language->getID());
         $result['categoryImage'] = '';
         $lC_ObjectInfo = new lC_ObjectInfo(lC_Categories_Admin::get($id));
         if (!lc_empty($lC_ObjectInfo->get('categories_image'))) {
             $result['categoryImage'] = '<div><p>' . lc_image('../' . DIR_WS_IMAGES . 'categories/' . $lC_ObjectInfo->get('categories_image'), $lC_ObjectInfo->get('categories_name'), HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br />' . DIR_WS_CATALOG . 'images/categories/' . $lC_ObjectInfo->getProtected('categories_image') . '</p></div>';
         }
     }
     $category_names = '';
     foreach ($lC_Language->getAll() as $l) {
         if (isset($id) && is_numeric($id)) {
             $category_names .= '<span class="input" style="width:88%"><label for="categories_name[' . $l['id'] . ']" class="button silver-gradient glossy">' . $lC_Language->showImage($l['code']) . '</label>' . lc_draw_input_field('categories_name[' . $l['id'] . ']', $result['cData']['categories_name'], 'class="input-unstyled"') . '</span><br />';
         } else {
             $category_names .= '<span class="input" style="width:88%"><label for="categories_name[' . $l['id'] . ']" class="button silver-gradient glossy">' . $lC_Language->showImage($l['code']) . '</label>' . lc_draw_input_field('categories_name[' . $l['id'] . ']', null, 'class="input-unstyled"') . '</span><br />';
         }
     }
     $result['categoryNames'] = $category_names;
     $result['parentCategory'] = isset($parent) && $parent != null ? $parent : 0;
     return $result;
 }