Ejemplo n.º 1
0
 public static function execute(ApplicationAbstract $application)
 {
     $data = array('name' => $_POST['categories_name'], 'image' => isset($_POST['cImageSelected']) ? $_POST['cImageSelected'] : null, 'parent_id' => $_POST['parent_id']);
     if (Categories::save(isset($_GET['id']) && is_numeric($_GET['id']) ? $_GET['id'] : null, $data)) {
         Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_success_action_performed'), 'success');
     } else {
         Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_action_not_performed'), 'error');
     }
     OSCOM::redirect(OSCOM::getLink(null, null, 'cid=' . $application->getCurrentCategoryID()));
 }
Ejemplo n.º 2
0
 public static function execute(ApplicationAbstract $application)
 {
     $parent_id = $application->getTree()->getParentID($_GET['id']);
     if (Categories::delete($_GET['id'])) {
         Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_success_action_performed'), 'success');
     } else {
         Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_action_not_performed'), 'error');
     }
     OSCOM::redirect(OSCOM::getLink(null, null, 'cid=' . $parent_id));
 }
Ejemplo n.º 3
0
 public static function execute()
 {
     $result = array();
     $data = array();
     $counter = 0;
     foreach ($_GET['row'] as $row) {
         $data[] = array('id' => $row, 'sort_order' => $counter);
         $counter++;
     }
     if (Categories::saveSortOrder($data)) {
         $result['rpcStatus'] = RPC::STATUS_SUCCESS;
     }
     echo json_encode($result);
 }
Ejemplo n.º 4
0
 public static function execute()
 {
     if (!isset($_GET['search'])) {
         $_GET['search'] = '';
     }
     if (!isset($_GET['cid'])) {
         $_GET['cid'] = 0;
     }
     if (!empty($_GET['search'])) {
         $result = Categories::find($_GET['search'], $_GET['cid']);
     } else {
         $result = Categories::getAll($_GET['cid']);
     }
     $result['rpcStatus'] = RPC::STATUS_SUCCESS;
     echo json_encode($result);
 }
Ejemplo n.º 5
0
 public static function execute(ApplicationAbstract $application)
 {
     $error = false;
     foreach ($_POST['batch'] as $id) {
         if (!Categories::move($id, $_POST['parent_id'])) {
             $error = true;
             break;
         }
     }
     if ($error === false) {
         Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_success_action_performed'), 'success');
     } else {
         Registry::get('MessageStack')->add(null, OSCOM::getDef('ms_error_action_not_performed'), 'error');
     }
     OSCOM::redirect(OSCOM::getLink(null, null, 'cid=' . $application->getCurrentCategoryID()));
 }
Ejemplo n.º 6
0
 public static function execute($id)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     $data = array('id' => $id);
     foreach (array_merge(array($data['id']), $OSCOM_CategoryTree->getChildren($data['id'])) as $c) {
         Categories::deleteImage($c);
     }
     if (OSCOM::callDB('Admin\\Categories\\Delete', $data)) {
         Cache::clear('categories');
         Cache::clear('category_tree');
         Cache::clear('also_purchased');
         return true;
     }
     return false;
 }
Ejemplo n.º 7
0
 public static function execute($id = null, $data)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     if (is_numeric($id)) {
         $data['id'] = $id;
     }
     // Prevent another big bang and check if category is not being moved to a child category
     if (isset($data['id']) && $OSCOM_CategoryTree->getParentID($data['id']) != $data['parent_id']) {
         if (in_array($data['id'], explode('_', $OSCOM_CategoryTree->buildBreadcrumb($data['parent_id'])))) {
             return false;
         }
     }
     if (isset($data['image'])) {
         $new_image = $data['image'];
         while (file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $new_image)) {
             $new_image = rand(10, 99) . $new_image;
         }
         if (rename(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload/' . $data['image'], OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $new_image)) {
             if (is_numeric($id)) {
                 $old_image = Categories::get($id, 'categories_image');
                 unlink(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $old_image);
             }
             $data['image'] = $new_image;
         } else {
             $data['image'] = null;
         }
     }
     if (OSCOM::callDB('Admin\\Categories\\Save', $data)) {
         Cache::clear('categories');
         Cache::clear('category_tree');
         Cache::clear('also_purchased');
         return true;
     }
     return false;
 }
Ejemplo n.º 8
0
  <fieldset>
    <p><label for="parent_id"><?php 
echo OSCOM::getDef('field_parent_category');
?>
</label><?php 
echo HTML::selectMenu('parent_id', array_merge(array(array('id' => '0', 'text' => OSCOM::getDef('top_category'))), $OSCOM_Application->getCategoryList()), $OSCOM_ObjectInfo->getInt('parent_id'));
?>
</p>
    <p><label><?php 
echo OSCOM::getDef('field_name');
?>
</label></p>

<?php 
foreach ($OSCOM_Language->getAll() as $l) {
    echo '<p>' . $OSCOM_Language->showImage($l['code']) . '&nbsp;' . $l['name'] . '<br />' . HTML::inputField('categories_name[' . $l['id'] . ']', Categories::get($OSCOM_ObjectInfo->getInt('categories_id'), 'categories_name', $l['id'])) . '</p>';
}
?>

    <p><label><?php 
echo OSCOM::getDef('field_image');
?>
</label></p>
    <p id="cImage" class="imageSelectorPlaceholder"></p>

    <p><label><?php 
echo OSCOM::getDef('field_image_browser');
?>
</label></p>
    <div class="imageSelector">
      <ul id="cImages"></ul>