Example #1
0
 public static function getAll($id = null)
 {
     global $_module, $lC_Database, $lC_Language, $current_category_id;
     $media = $_GET['media'];
     $result = array('entries' => array());
     $result = array('aaData' => array());
     if (!is_numeric($id)) {
         if (isset($current_category_id) && is_numeric($current_category_id)) {
             $id = $current_category_id;
         } else {
             $id = 0;
         }
     }
     $Qcategories = $lC_Database->query('select c.*, cd.categories_name from :table_categories c, :table_categories_description cd where c.categories_id = cd.categories_id and cd.language_id = :language_id and c.parent_id = :parent_id order by c.sort_order, cd.categories_name');
     $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
     $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
     $Qcategories->bindInt(':language_id', $lC_Language->getID());
     $Qcategories->bindInt(':parent_id', $id);
     $Qcategories->execute();
     while ($Qcategories->next()) {
         $check = '<td><input class="batch" type="checkbox" name="batch[]" value="' . $Qcategories->value('categories_id') . '" id="' . $Qcategories->value('categories_id') . '"></td>';
         $category = '<td><span class="icon-list icon-size2 dragsort" title="' . $lC_Language->get('text_sort') . '" style="cursor:move;"></span><a href="' . lc_href_link_admin(FILENAME_DEFAULT, $_module . '=' . $Qcategories->value('categories_id')) . '"><span class="icon-' . lC_Categories_Admin::getCategoryIcon($Qcategories->value('categories_mode')) . ' margin-left"></span><span class="mid-margin-left">' . $Qcategories->value('categories_name') . '</span></a></td>';
         $status = '<td><span class="align-center" id="status_' . $Qcategories->value('categories_id') . '" onclick="updateStatus(\'' . $Qcategories->value('categories_id') . '\', \'' . ($Qcategories->value('categories_status') == 1 ? 0 : 1) . '\');">' . ($Qcategories->valueInt('categories_status') == 1 ? '<span class="icon-tick icon-size2 icon-green cursor-pointer with-tooltip" title="' . $lC_Language->get('text_disable_category') . '"></span>' : '<span class="icon-cross icon-size2 icon-red cursor-pointer with-tooltip" title="' . $lC_Language->get('text_enable_category') . '"></span>') . '</span></td>';
         $visibility = '<td>' . ($Qcategories->valueInt('parent_id') == 0 ? '  <span class="align-center margin-right" id="nav_' . $Qcategories->value('categories_id') . '" onclick="updateVisibilityNav(\'' . $Qcategories->value('categories_id') . '\', \'' . ($Qcategories->value('categories_visibility_nav') == 1 ? 0 : 1) . '\');">' . ($Qcategories->valueInt('categories_visibility_nav') == 1 ? '<span class="icon-directions icon-size2 icon-green cursor-pointer with-tooltip" title="' . $lC_Language->get('text_hide_in_nav') . '"></span>' : '<span class="icon-directions icon-size2 icon-silver cursor-pointer with-tooltip" title="' . $lC_Language->get('text_show_in_nav') . '"></span>') . '  </span>' : '') . '  <span class="align-center" id="box_' . $Qcategories->value('categories_id') . '" onclick="updateVisibilityBox(\'' . $Qcategories->value('categories_id') . '\', \'' . ($Qcategories->value('categories_visibility_box') == 1 ? 0 : 1) . '\');">' . ($Qcategories->valueInt('categories_visibility_box') == 1 ? '<span class="icon-browser icon-size2 icon-green cursor-pointer with-tooltip" title="' . $lC_Language->get('text_hide_in_box') . '"></span>' : '<span class="icon-browser icon-size2 icon-silver cursor-pointer with-tooltip" title="' . $lC_Language->get('text_show_in_box') . '"></span>') . '  </span>' . '</td>';
         $mode = '<td>' . $lC_Language->get('text_mode_' . $Qcategories->value('categories_mode')) . '</td>';
         $sort = '<td><input type="text" onfocus="this.select();" name="sort_order_' . $Qcategories->value('categories_id') . '" onchange="updateCategorySort(this.value, \'' . $Qcategories->value('categories_id') . '\');" value="' . $Qcategories->valueInt('sort_order') . '" class="sort input" /></td>';
         $action = '<td class="align-right vertical-center">
                <span class="button-group" style="white-space:nowrap;">
                  <a href="' . ((int) ($_SESSION['admin']['access'][$_module] < 3) ? '#' : lc_href_link_admin(FILENAME_DEFAULT, $_module . '=' . $Qcategories->value('categories_id') . '&cid=' . ($_GET['categories'] ? $_GET['categories'] : 0) . '&action=save')) . '" class="button icon-pencil' . ((int) ($_SESSION['admin']['access'][$_module] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_edit')) . '</a>
                  <a href="' . ((int) ($_SESSION['admin']['access']['languages'] < 4) ? '#' : 'javascript://" onclick="moveCategory(\'' . $Qcategories->value('categories_id') . '\', \'' . urlencode($Qcategories->valueProtected('categories_name')) . '\')"') . '" class="button icon-cloud-upload with-tooltip ' . ((int) ($_SESSION['admin']['access']['languages'] < 4) ? 'disabled' : NULL) . '" title="' . $lC_Language->get('icon_move') . '"></a>
                </span>
                <span class="button-group">
                  <a href="' . ((int) ($_SESSION['admin']['access']['languages'] < 4) ? '#' : 'javascript://" onclick="deleteCategory(\'' . $Qcategories->value('categories_id') . '\', \'' . urlencode($Qcategories->valueProtected('categories_name')) . '\')"') . '" class="button icon-trash with-tooltip ' . ((int) ($_SESSION['admin']['access']['languages'] < 4) ? 'disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a>
                </span>
              </td>';
         $result['aaData'][] = array("{$check}", "{$category}", "{$status}", "{$visibility}", "{$mode}", "{$sort}", "{$action}");
         $result['entries'][] = $Qcategories->toArray();
     }
     $Qcategories->freeResult();
     return $result;
 }