/**
  @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 getFormData()
 {
     die("lineeeeee 55 <br>");
     global $_module;
     $result = lC_Categories_Admin::formData($_GET['cid'], $_GET[$_module]);
     $result['rpcStatus'] = RPC_STATUS_SUCCESS;
     echo json_encode($result);
 }
Exemplo n.º 3
0
 public function __construct()
 {
     global $lC_Language, $lC_MessageStack;
     parent::__construct();
     $this->_page_contents = 'edit.php';
     if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
         switch ($_GET['action']) {
             case 'save':
                 $data = array('image' => isset($_POST['categories_image']) ? $_POST['categories_image'] : null, 'parent_id' => $_POST['parent_id'], 'sort_order' => $_POST['sort_order'], 'mode' => $_POST['categories_mode'], 'link_target' => $_POST['categories_link_target'] == 'on' ? 1 : 0, 'custom_url' => $_POST['categories_custom_url'], 'status' => $_POST['categories_status'] == 'on' ? 1 : 0, 'nav' => $_POST['categories_visibility_nav'] == 'on' ? 1 : 0, 'box' => $_POST['categories_visibility_box'] == 'on' ? 1 : 0, 'name' => $_POST['categories_name'], 'menu_name' => $_POST['categories_menu_name'], 'blurb' => $_POST['categories_blurb'], 'description' => $_POST['categories_description'], 'permalink' => $_POST['categories_permalink'], 'tags' => $_POST['categories_tags']);
                 // access levels
                 if (isset($_POST['access_levels'])) {
                     $data['access_levels'] = $_POST['access_levels'];
                 }
                 if (isset($_POST['sync_all_products'])) {
                     $data['sync_all_products'] = $_POST['sync_all_products'];
                 }
                 if (isset($_POST['sync_all_children'])) {
                     $data['sync_all_children'] = $_POST['sync_all_children'];
                 }
                 /*
                  * Save the category information
                  *
                  * @param integer $_GET['cid'] The categories id used on update, null on insert
                  * @param array $data The categories information
                  * @access public
                  * @return boolean
                  */
                 $id = lC_Categories_Admin::save(isset($_GET['categories']) && is_numeric($_GET['categories']) ? $_GET['categories'] : null, $data);
                 if (is_numeric($id)) {
                     if (empty($_POST['save_close'])) {
                         lc_redirect_admin(lc_href_link_admin(FILENAME_DEFAULT, $this->_module . '=' . $id . '&cid=' . $_GET['cid'] . '&action=save'));
                     } else {
                         lc_redirect_admin(lc_href_link_admin(FILENAME_DEFAULT, $this->_module . '=' . $data['parent_id']));
                     }
                 } else {
                     $_SESSION['error'] = true;
                     $_SESSION['errmsg'] = $lC_Language->get('ms_error_action_not_performed');
                 }
                 break;
         }
     }
 }
Exemplo n.º 4
0
                    </div>
                  </div>
                  <div class="columns">
                    <div class="six-columns twelve-columns-mobile">
                      <label class="label" for="parent_id"><b><?php 
echo $lC_Language->get('text_parent');
?>
</b></label> 
                      <select class="select full-width" id="parent_id" name="parent_id">
                        <option value="0"><?php 
echo $lC_Language->get('text_top_category');
?>
</option>
                        <?php 
foreach ($assignedCategoryTree->getArray() as $value) {
    echo '<option value="' . $value['id'] . '"' . ($cInfo['parent_id'] == $value['id'] ? ' selected' : '') . (in_array($value['id'], lC_Categories_Admin::getChildren($_GET['categories'])) ? ' disabled' : '') . ($value['id'] == $cInfo['categories_id'] ? ' disabled' : '') . '>' . $value['title'] . '</option>' . "\n";
}
?>
                      </select>
                    </div>
                    <div class="six-columns twelve-columns-mobile small-margin-top">  
                      <?php 
echo lc_show_info_bubble($lC_Language->get('info_bubble_categories_parent'), null, 'on-left grey mid-margin-right');
?>
                      <span class="button-group" id="categories_visibility">
                        <?php 
if ($cInfo['parent_id'] == 0) {
    ?>
                        <label class="button blue-active" for="categories_visibility_nav">
                          <input type="checkbox"<?php 
    echo $cInfo['categories_visibility_nav'] == 1 ? ' checked=""' : '';
Exemplo n.º 5
0
 public static function validatePermalink($permalink_array, $cid = null, $type = null, $lid = null)
 {
     $validated = true;
     if (is_array($permalink_array)) {
         foreach ($permalink_array as $permalink) {
             if (preg_match('/^[a-z0-9_-]+$/iD', $permalink) !== 1) {
                 $validated = false;
             }
             if (lC_Categories_Admin::getPermalinkCount($permalink, $cid, $type, $lid) > 0) {
                 $validated = false;
             }
         }
     } else {
         if (preg_match('/^[a-z0-9_-]+$/iD', $permalink) !== 1) {
             $validated = false;
         }
         if (lC_Categories_Admin::getPermalinkCount($permalink, $cid, $type, $lid) > 0) {
             $validated = false;
         }
     }
     return $validated;
 }
Exemplo n.º 6
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;
 }
 public static function importCategories($filename, $cwizard, $ctype, $cbackup, $cmapdata = NULL)
 {
     global $lC_Database, $lC_Datetime, $lC_Language, $lC_Image;
     if ($cwizard == 'false') {
         $cwizard = FALSE;
     } else {
         $cwizard = TRUE;
     }
     $lC_Categories = new lC_Categories_Admin();
     $error = FALSE;
     $errormsg = "";
     $msg = "";
     $uploaddir = DIR_FS_WORK . 'products_import_export/imports/';
     // $other .= 'Upload Dir: ' . $uploaddir;
     $uploadfile = $uploaddir . basename($filename);
     if (is_null($cmapdata)) {
         $columns = array('categories_id', 'image', 'parent_id', 'sort_order', 'mode', 'link_target', 'custom_url', 'status', 'nav', 'box', 'date_added', 'language_id', 'name', 'menu_name', 'blurb', 'description', 'keyword', 'tags');
     } else {
         // do the mapping of columns here with the mapdata
         $columns = array('categories_id', 'image', 'parent_id', 'sort_order', 'mode', 'link_target', 'custom_url', 'status', 'nav', 'box', 'date_added', 'language_id', 'name', 'menu_name', 'blurb', 'description', 'keyword', 'tags');
     }
     $ext = end(explode(".", $filename));
     if ($ext == 'txt') {
         $delim = "\t";
     } else {
         if ($ext == 'csv') {
             $delim = ",";
         } else {
             $delim = "\t";
         }
     }
     $row = 0;
     if (($handle = fopen($uploadfile, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, null, "\t")) !== FALSE) {
             $num = count($data);
             for ($c = 0; $c < $num; $c++) {
                 if ($row != 0) {
                     $import_array[$row][$columns[$c]] = $data[$c];
                 }
             }
             $row++;
         }
         fclose($handle);
     }
     $match_count = 0;
     $insert_count = 0;
     if ($cwizard) {
         // p wizard stuff like return columns and etc.
         $msg .= 'CWIZARD AGAIN!~!!!!!!!!!!';
     } else {
         // do the import as usual
         // utilize import array to go through each column and run on each to check for category id and if not matched import and remove from arrray
         foreach ($import_array as $category) {
             // Get the products ID for control
             $categories_id = $category['categories_id'];
             // check for a match in the database
             $Qcheck = $lC_Database->query("SELECT * FROM :table_categories WHERE categories_id = :categories_id");
             $Qcheck->bindTable(':table_categories', TABLE_CATEGORIES);
             $Qcheck->bindInt(':categories_id', $categories_id);
             $category_check = $Qcheck->numberOfRows();
             // build a cPath for later use
             $parents = self::getParentsPath($category['categories_id']);
             if (empty($parents)) {
                 $query = "cPath=" . $category['categories_id'];
             } else {
                 $query = "cPath=" . implode("_", array_reverse(explode("_", str_replace("_0", "", self::getParentsPath($category['categories_id']))))) . "_" . $category['categories_id'];
             }
             $query = str_replace("cPath=0_", "cPath=", $query);
             if ($category_check > 0) {
                 // the category exists in the database so were just going to update the category with the new data
                 $match_count++;
                 $cdaParts = explode("/", $category['date_added']);
                 $category_date_added = date("Y-m-d H:i:s", mktime(0, 0, 0, $cdaParts[0], $cdaParts[1], $cdaParts[2]));
                 // build data array of category information
                 $data['categories_id'] = $category['categories_id'];
                 $data['image'] = $category['image'];
                 $data['parent_id'] = $category['parent_id'];
                 $data['sort_order'] = $category['sort_order'];
                 $data['mode'] = $category['mode'];
                 $data['link_target'] = $category['link_target'];
                 $data['custom_url'] = $category['custom_url'];
                 $data['status'] = $category['status'];
                 $data['nav'] = $category['nav'];
                 $data['box'] = $category['box'];
                 $data['date_added'] = $category_date_added != '' ? $category_date_added : 'now()';
                 $data['last_modified'] = $category['last_modified'];
                 $data['name'][$category['language_id']] = $category['name'];
                 $data['menu_name'][$category['language_id']] = $category['menu_name'];
                 $data['permalink'][$category['language_id']] = '';
                 $data['blurb'][$category['language_id']] = $category['blurb'];
                 $data['description'][$category['language_id']] = $category['description'];
                 $data['keyword'][$category['language_id']] = $category['keyword'];
                 $data['tags'][$category['language_id']] = $category['tags'];
                 $lC_Categories->save($categories_id, $data);
             } else {
                 // the category doesnt exist so lets write it into the database
                 $insert_count++;
                 $cdaParts = explode("/", $category['date_added']);
                 $category_date_added = date("Y-m-d H:i:s", mktime(0, 0, 0, $cdaParts[0], $cdaParts[1], $cdaParts[2]));
                 // Insert using code from the catgories class
                 $error = false;
                 $lC_Database->startTransaction();
                 $Qcat = $lC_Database->query('insert into :table_categories (categories_id, categories_image, parent_id, sort_order, categories_mode, categories_link_target, categories_custom_url, categories_status, categories_visibility_nav, categories_visibility_box, date_added) values (:categories_id, :categories_image, :parent_id, :sort_order, :categories_mode, :categories_link_target, :categories_custom_url, :categories_status, :categories_visibility_nav, :categories_visibility_box, :date_added)');
                 $Qcat->bindInt(':categories_id', $category['categories_id']);
                 $Qcat->bindInt(':parent_id', $category['parent_id']);
                 $Qcat->bindTable(':table_categories', TABLE_CATEGORIES);
                 $Qcat->bindValue(':categories_image', $category['image']);
                 $Qcat->bindValue(':date_added', $category_date_added != '' ? $category_date_added : 'now()');
                 $Qcat->bindInt(':parent_id', $category['parent_id']);
                 $Qcat->bindInt(':sort_order', $category['sort_order']);
                 $Qcat->bindValue(':categories_mode', $category['mode']);
                 $Qcat->bindInt(':categories_link_target', $category['link_target']);
                 $Qcat->bindValue(':categories_custom_url', $category['custom_url']);
                 $Qcat->bindInt(':categories_status', $category['status']);
                 $Qcat->bindInt(':categories_visibility_nav', $category['nav']);
                 $Qcat->bindInt(':categories_visibility_box', $category['box']);
                 $Qcat->setLogging($_SESSION['module'], $id);
                 $Qcat->execute();
                 // remove this line from categories for it to be re inserted
                 $Qrcd = $lC_Database->query('delete from :table_categories_description where categories_id = :categories_id and language_id = :language_id');
                 $Qrcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
                 $Qrcd->bindInt(':categories_id', $categories_id);
                 $Qrcd->bindInt(':language_id', $category['language_id']);
                 $Qrcd->execute();
                 $Qcd = $lC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name, categories_menu_name, categories_blurb, categories_description, categories_tags) values (:categories_id, :language_id, :categories_name, :categories_menu_name, :categories_blurb, :categories_description, :categories_tags)');
                 $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
                 $Qcd->bindInt(':categories_id', $categories_id);
                 $Qcd->bindInt(':language_id', $category['language_id']);
                 $Qcd->bindValue(':categories_name', $category['name']);
                 $Qcd->bindValue(':categories_menu_name', $category['menu_name']);
                 $Qcd->bindValue(':categories_blurb', $category['blurb']);
                 $Qcd->bindValue(':categories_description', $category['description']);
                 $Qcd->bindValue(':categories_tags', $category['tags']);
                 $Qcd->setLogging($_SESSION['module'], $categories_id);
                 $Qcd->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                     break;
                 }
                 // added for permalinks
                 if ($error === false) {
                     // get existing cat permalinks
                     $Qquery = $lC_Database->query("select permalink from :table_permalinks where type = :type and language_id = :language_id");
                     $Qquery->bindTable(':table_permalinks', TABLE_PERMALINKS);
                     $Qquery->bindInt(':type', 1);
                     $Qquery->bindInt(':language_id', $category['language_id']);
                     $Qquery->execute();
                     // make the array of existing permalinks
                     while ($Qquery->next()) {
                         $cat_pl_arr[] = $Qquery->value('permalink');
                     }
                     // what the new permalink is to be
                     $cat_permalink = lC_Products_import_export_Admin::generate_clean_permalink($category['name']);
                     // compare to existing cat permalinks and add random string to avoid duplicates if needed
                     if (in_array($cat_permalink, $cat_pl_arr)) {
                         $cat_permalink = $cat_permalink . '-' . self::randomString();
                     }
                     // insert the new permalink
                     $Qupdate = $lC_Database->query("insert into :table_permalinks (item_id, language_id, type, query, permalink) values (:item_id, :language_id, :type, :query, :permalink)");
                     $Qupdate->bindTable(':table_permalinks', TABLE_PERMALINKS);
                     $Qupdate->bindInt(':item_id', $categories_id);
                     $Qupdate->bindInt(':language_id', $category['language_id']);
                     $Qupdate->bindInt(':type', 1);
                     $Qupdate->bindValue(':query', $query);
                     $Qupdate->bindValue(':permalink', $cat_permalink);
                     $Qupdate->execute();
                     $Qquery->freeResult();
                     if ($lC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
                 if ($error === false) {
                     $lC_Database->commitTransaction();
                 } else {
                     $lC_Database->rollbackTransaction();
                 }
             }
         }
     }
     // end if $do
     // for all left in array match and update the records
     // use columns from import to figure out what columns are what
     if ($error || $errormsg != '') {
         if ($errormsg) {
             $icreturn['error'] = $errormsg . 'Error: ' . $error;
         }
     }
     if ($msg) {
         $icreturn['msg'] = $msg . ' cwizard: ' . $cwizard;
     }
     $icreturn['matched'] = $match_count;
     $icreturn['inserted'] = $insert_count;
     $icreturn['total'] = $match_count + $insert_count;
     return $icreturn;
 }
Exemplo n.º 8
0
</p><p class="margin-left"><input type="checkbox" class="checkbox small-margin-right" disabled> <?php 
echo $lC_Language->get('access_levels_dealer');
?>
</p>
                </div>
                <!-- VQMOD-hookpoint; DO NOT MODIFY OR REMOVE THE LINE BELOW -->
                <div id="new-category-relationship-right-div" class="six-columns twelve-columns-mobile">
                </div>
              </div>
            </fieldset>
          </div>          
          
        </div>
      </div>
      <?php 
$next_sort = lC_Categories_Admin::nextSort();
echo lc_draw_hidden_field('sort_order', $next_sort);
echo lc_draw_hidden_field('subaction', 'confirm');
?>
      <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 class="align-right">
              <p class="button-height">
                <?php 
$save = (int) $_SESSION['admin']['access'][$lC_Template->getModule()] < 3 ? '' : ' onclick="validateForm(\'#category\');"';
$close = lc_href_link_admin(FILENAME_DEFAULT, $lC_Template->getModule() . ($_GET['categories'] != '') ? 'categories=' . $_GET['categories'] : '');
button_save_close($save, true, $close);
?>
              </p>
Exemplo n.º 9
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 
}
?>
Exemplo n.º 10
0
 public static function updateCategorySort()
 {
     $updated = lC_Categories_Admin::updateCategorySort($_GET['cid'], $_GET['val']);
     if ($updated) {
         lC_Cache::clear('category_tree');
         $result['rpcStatus'] = RPC_STATUS_SUCCESS;
     }
     echo json_encode($result);
 }