예제 #1
1
파일: faker.php 프로젝트: hadesain/thelia
     $image = new \Thelia\Model\BrandImage();
     $image->setBrandId($brandId);
     generate_image($image, 'brand', $brandId);
     $document = new \Thelia\Model\BrandDocument();
     $document->setBrandId($brandId);
     generate_document($document, 'brand', $brandId);
 }
 echo "Creating categories and products\n";
 //categories and products
 $productIdList = array();
 $virtualProductList = array();
 $categoryIdList = array();
 for ($i = 1; $i < $numberCategories; $i++) {
     $category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList);
     for ($j = 1; $j < rand(0, $numberCategories); $j++) {
         $subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList, $contentIdList);
         for ($k = 0; $k < rand(0, $numberProducts); $k++) {
             createProduct($faker, $subcategory, $k, $template, $brandIdList, $productIdList, $virtualProductList);
         }
     }
     for ($k = 1; $k < rand(1, $numberProducts); $k++) {
         createProduct($faker, $category, $k, $template, $brandIdList, $productIdList, $virtualProductList);
     }
 }
 foreach ($productIdList as $productId) {
     //add random accessories - or not
     $alreadyPicked = array();
     for ($i = 1; $i < rand(0, 4); $i++) {
         $accessory = new Thelia\Model\Accessory();
         do {
             $pick = array_rand($productIdList, 1);
예제 #2
0
function getCategory($name)
{
    if (empty($name)) {
        $name = "Default";
    }
    $tmp = split("!", $name);
    $maingroup = 0;
    $found = true;
    $i = 0;
    do {
        $sql = "select D.*,C.parent_id from categories C left join categories_description D on C.categories_id=D.categories_id ";
        $sql .= "where categories_name like '" . $tmp[$i] . "' and C.parent_id={$maingroup}";
        $rs = getAll("shop", $sql, "getCategory");
        if ($rs[0]["categories_id"]) {
            $maingroup = $rs[0]["categories_id"];
            echo $maingroup . ":" . $rs[0]["categories_name"] . " ";
            $i++;
        } else {
            $found = false;
        }
    } while ($rs and $found and $i < count($tmp));
    for (; $i < count($tmp); $i++) {
        $maingroup = createCategory($tmp[$i], $maingroup);
    }
    return $maingroup;
}
예제 #3
0
function getCategory($name, $Lang, $Languages)
{
    if (empty($name)) {
        $name = "Default";
    }
    $tmp = split("!", $name);
    $maingroup = 0;
    $found = true;
    $i = 0;
    do {
        $sql = "select D.*,C.parent_id from " . PREFIX . "categories C left join " . PREFIX . "categories_description D on C.categories_id=D.categories_id ";
        $sql .= "where (categories_name = '" . $tmp[$i] . "' or categories_meta_title ='" . $tmp[$i] . "') and ";
        $sql .= "C.parent_id={$maingroup} and language_id={$Lang}";
        $rs = getAll("shop", $sql, "getCategory");
        if ($rs) {
            $maingroup = $rs[0]["categories_id"];
            $i++;
        } else {
            $found = false;
        }
    } while ($rs and $found and $i < count($tmp));
    for (; $i < count($tmp); $i++) {
        $maingroup = createCategory($tmp[$i], $maingroup, $Lang, $Languages);
    }
    return $maingroup;
}
예제 #4
0
function getCategory($name)
{
    global $db;
    if (empty($name)) {
        $name = "Default";
    }
    $tmp = split("!", $name);
    $maingroup = 0;
    $found = true;
    $i = 0;
    do {
        $sql = "select D.*,C.parent_id from " . PREFIX . "categories C left join " . PREFIX . "categories_description D on C.categories_id=D.categories_id where categories_name like '" . $tmp[$i] . "' and C.parent_id={$maingroup}";
        $rs = $db->getAll($sql, DB_FETCHMODE_ASSOC);
        if ($rs[0]["categories_id"]) {
            $maingroup = $rs[0]["categories_id"];
            echo $maingroup . ":" . $rs[0]["categories_name"] . " ";
            $i++;
        } else {
            $found = false;
        }
    } while ($rs and $found and $i < count($tmp));
    for (; $i < count($tmp); $i++) {
        $maingroup = createCategory($tmp[$i], $maingroup);
    }
    return $maingroup;
}
예제 #5
0
파일: populate.php 프로젝트: ahrasis/tools
 private function _makeCategories()
 {
     require_once SUBSDIR . '/Categories.subs.php';
     while ($this->counters['categories']['current'] < $this->counters['categories']['max'] && $this->blockSize--) {
         $catOptions = array('move_after' => 0, 'cat_name' => 'Category Number ' . ++$this->counters['categories']['current'], 'is_collapsible' => 1);
         createCategory($catOptions);
     }
     $this->_pause();
 }
예제 #6
0
파일: Populate.php 프로젝트: rhodefey/tools
 private function makeCategories()
 {
     global $sourcedir;
     require_once $sourcedir . '/Subs-Categories.php';
     while ($this->counters['categories']['current'] < $this->counters['categories']['max'] && $this->blockSize--) {
         $catOptions = array('move_after' => 0, 'cat_name' => 'Category Number ' . ++$this->counters['categories']['current'], 'is_collapsible' => 1);
         createCategory($catOptions);
     }
     $this->pause();
 }
예제 #7
0
             break;
         }
     }
 case 'createcategory':
     if ($isallowed && $mode == 'createcategory') {
         $smarty->assign('languages', $lang->listLanguages());
         $grouplist = $rights->getAllGroups();
         $smarty->assign('groups', $grouplist);
         if (isset($_POST['create']) && trim($_POST['name']) != '') {
             $assigned_groups = array();
             foreach ($grouplist as $group) {
                 if (@$_POST['group_' . $group['groupid']] == '1') {
                     $assigned_groups[] = $group['groupid'];
                 }
             }
             createCategory($_POST['name'], $categoryid, $assigned_groups, $_POST['language']);
         } else {
             $breadcrumbs->addElement($lang->get('createcategory'), makeURL($mod, array('mode' => 'createcategory')));
             $smarty->assign('path', $template_dir . "/createcategory.tpl");
             break;
         }
     }
 default:
     if (isVisible($categoryid)) {
         $showcategories = true;
         if ($downloadid > 0) {
             $dl = getDownload($downloadid);
             if (isset($_POST['download'])) {
                 increaseDownloadCounter($downloadid);
                 $dl['counter']++;
                 $addr = trim($config->get('media', 'mail-notification-address'));
예제 #8
0
파일: ajaxTest.php 프로젝트: balvarob/test
function getData($code, $connection)
{
    if (!isTokenUser()) {
        $code = 4;
    }
    switch ($code) {
        //////////////////////CASE -1/////////////////////////////////////
        //Si entra aqui es porque ningun dato de S_POST coincide con una acción valida. Ya que el $dataCode por defecto es -1
        case -1:
            $response = array("error" => 1030, "description" => "Error no se ejecuto ninguna acción, verifica los parametros de entrada.");
            break;
            //////////////////////CASE 0/////////////////////////////////////
            //Obtenemos las opciones a mostrar de un pregunta y las devolvemos en un array en formato json
        //////////////////////CASE 0/////////////////////////////////////
        //Obtenemos las opciones a mostrar de un pregunta y las devolvemos en un array en formato json
        case 0:
            if ($connection) {
                $id_pregunta = $_POST["id_pregunta"];
                $dataOptions = $connection->query("SELECT * FROM " . TABLE_PREFIX . TABLE_OPCIONES . " where id_pregunta = " . $id_pregunta);
                $data;
                /*
                 * obtenemos los datos de la base de datos en un array asociativo.
                 */
                while ($fila = $dataOptions->fetch_assoc()) {
                    $data[] = $fila;
                }
                //dado que los valores de la base de datos vienen en codificacion utf-8, hay que transformar aquellas columnas con campos de texto.
                $dataResponse = codificationArray($data, "m_option");
                //para la variable m_option de la tabla n_opciones se codifica en utf-8
                $response = $dataResponse;
            } else {
                $response = array("error" => 1020, "description" => "Error conexión no establecida");
            }
            break;
            //////////////////////CASE 1/////////////////////////////////////
            //Devolvemos la pregunta dado una paginacion ( con un LIMIT en la select filtramos la paginación)			.
        //////////////////////CASE 1/////////////////////////////////////
        //Devolvemos la pregunta dado una paginacion ( con un LIMIT en la select filtramos la paginación)			.
        case 1:
            if (!isTokenTest()) {
                createTokenTest(getTokenUser());
            } else {
                if (isTokenTest() && isset($_POST["isFirstSelectedTest"]) && $_POST["isFirstSelectedTest"] == "true") {
                    //$response = array("error" => 1200, "Error token desincronizado");
                    $response = array("error" => 1200, "desError" => "Test desincronizado", "page" => getPage(), "category" => getCategory(), "token_test" => getTokenTest(), "token_user" => getTokenUser());
                    break;
                }
            }
            //sincronizamos el avanze de paginas
            if (!isPage()) {
                createPage(intval($_POST["pagination"]));
            } else {
                if (isset($_SESSION["is_page_refresh"]) && $_SESSION["is_page_refresh"] && getPage() < intval($_POST["pagination"])) {
                    createPage(intval(getPage()) + 1);
                } else {
                    if (isset($_SESSION["is_page_refresh"]) && $_SESSION["is_page_refresh"]) {
                        createPage(intval(getPage()));
                    } else {
                        createPage(intval(getPage()) + 1);
                    }
                }
            }
            if (!isCategory()) {
                //si no esta sincroniada la categoria se sincroniza
                createCategory(intval($_POST["id"]));
            }
            if ($connection) {
                $pagination = getPage();
                //numero de pagina.
                $id = $_POST["id"];
                //id categoria: 1- ingles, 2- aleman...
                $result = $connection->query("SELECT * FROM " . TABLE_PREFIX . TABLE_PREGUNTAS . " where id_title = " . $id . " LIMIT " . $pagination . ",1");
                $countLengthData = $connection->query("SELECT count(id) as count FROM " . TABLE_PREFIX . TABLE_PREGUNTAS . " where id_title = " . $id);
                $data = array();
                while ($fila = $result->fetch_assoc()) {
                    $data[] = $fila;
                }
                $dataResponse = codificationArray($data, "question");
                //para la variable question de la tabla n_preguntas se codifica en utf-8
                $dataLength = $countLengthData->fetch_assoc();
                $dataResponse[1] = $dataLength;
                //numero de preguntas para la categoria actual
                if (!isCountQuestion()) {
                    createCountQuestion($dataLength);
                }
                $dataResponse[2] = getTokenTest();
                $dataResponse[3] = getTokenUser();
                $response = $dataResponse;
            } else {
                $response = array("error" => 1020, "description" => "Error conexión no establecida");
            }
            break;
            //////////////////////CASE 2/////////////////////////////////////
            // Actualizamos el progresso del cliente.
        //////////////////////CASE 2/////////////////////////////////////
        // Actualizamos el progresso del cliente.
        case 2:
            if (isPage()) {
                $canContinue = false;
                if (isset($_POST["pageUpdate"]) && $_POST["pageUpdate"]) {
                    if (intval(getPage()) == intval($_POST["pageUpdate"])) {
                        $canContinue = true;
                    } else {
                        $canContinue = false;
                    }
                } else {
                    $canContinue = true;
                }
                if ($canContinue === true) {
                    if (isset($_SESSION["u_email"])) {
                        $emailClient = $_SESSION["u_email"];
                        $id_question = $_POST["id_question"];
                        $id_option = $_POST["id_option"];
                        if ($connection) {
                            if (!isset($_SESSION["id_cliente"])) {
                                $resultQueryClientes = $connection->query("select id from " . TABLE_PREFIX . TABLE_CLIENTES . " WHERE email = '{$emailClient}'");
                                $responseQueryClientes = $resultQueryClientes->fetch_assoc();
                                $_SESSION["id_cliente"] = $responseQueryClientes["id"];
                            }
                            $query = "SELECT count(o.id) as count\n\t\t\t\t\t\t\t\t\t\t  FROM " . TABLE_PREFIX . TABLE_PREGUNTAS . " p inner join " . TABLE_PREFIX . TABLE_OPCIONES . " o\n\t\t\t\t\t\t\t\t\t\t  on o.id_pregunta = p.id\n\t\t\t\t\t\t\t\t\t\t  where {$id_option}. = (select id_opcion from " . TABLE_PREFIX . TABLE_RESPUESTA . " where id_pregunta = {$id_question})";
                            $resultCountCorrect = $connection->query($query);
                            $countCorrectOption = $resultCountCorrect->fetch_assoc();
                            $codeTemp = getTokenTest();
                            $id_client = $_SESSION["id_cliente"];
                            $id_category = getCategory();
                            $date_update = date("Y-m-d H:i:s");
                            $insert = $connection->query("INSERT INTO " . TABLE_PREFIX . TABLE_HISTORY_TEST . " (id_client,id_option,id_question,id_title,code_validation,m_date) VALUES({$id_client},{$id_option},{$id_question},{$id_category},'{$codeTemp}','{$date_update}')");
                            //obtenemos el numero de preguntas de esta categoria.
                            $countQuestionResult = $connection->query("SELECT count(id) as count FROM " . TABLE_PREFIX . TABLE_PREGUNTAS . " where id_title = " . $id_category);
                            $countQuestionTemp = $countQuestionResult->fetch_assoc();
                            $countQuestion = $countQuestionTemp["count"];
                            if (intval($countCorrectOption["count"] > 0)) {
                                //si es mayor que cero significa que es la que tenemos marcada como buena en la base de datos.
                                if (!isset($_SESSION["correctCount"])) {
                                    //si el correctCount no está creado aún lo creamos con valor a 1 porque yá tenemos una respuesta correcta.
                                    $_SESSION["correctCount"] = 1;
                                } else {
                                    //si ya estaba activo, solo incrementamos su valor en 1.
                                    $_SESSION["correctCount"] = intval($_SESSION["correctCount"]) + 1;
                                }
                                $dataUpdate = array("check" => $_SESSION['correctCount']);
                            } else {
                                $dataUpdate = array("check" => -1);
                                //editamos el mensaje de respuesta.
                            }
                        } else {
                            $dataUpdate = array("error" => 1020, "description" => "Error conexión no establecida");
                        }
                    } else {
                        $dataUpdate = array("error" => 1050, "description" => "Error de session, la sessión ha expirado.");
                    }
                } else {
                    $dataUpdate = array("error" => 1200, "desError" => "Test desincronizado", "page" => getPage(), "category" => getCategory(), "token_test" => getTokenTest(), "token_user" => getTokenUser());
                }
                $response = $dataUpdate;
                break;
            } else {
                $response = array("error" => 1050, "description" => "Error de session, la sessión ha expirado.");
                break;
            }
        case 3:
            //aqui el cliente a finalizado el test y mostramos el detalle de los resultados.
            $id_client = $_SESSION["id_cliente"];
            $date_update = date("Y-m-d H:i:s");
            $id_category = getCategory();
            $puntuacion = $_SESSION["correctCount"];
            $token_test = getTokenTest();
            $result = $connection->query("INSERT INTO " . TABLE_PREFIX . TABLE_HISTORY . " (id_client,id_title,code_validation,m_date,points) VALUES ({$id_client},{$id_category},'{$token_test}','{$date_update}',{$puntuacion})");
            if ($result) {
                $response = array("check" => "register inserted.", "data" => array("num_question" => getCountQuestion(), "correctCount" => getCorrectCount()));
            } else {
                $response = array("error" => $connection->error);
            }
            $dataEndTest = isEndTest($id_category, $token_test, $connection);
            if ($dataEndTest) {
                $_SESSION["end_test"] = true;
                sendResult($_SESSION["u_email"], "Resultado del Test en GRUPOIOE", showResume($dataEndTest, $connection));
            }
            break;
        case 4:
            //aqui no existe el token de usuario, la sesion posiblemente haya expirado.
            $response = array("error" => 1100, "description" => "Error token expirado");
            break;
        case 5:
            //aqui devolvemos si hay un test activo o no.
            $response = array("isTestActive" => isTokenTest());
            break;
        case 6:
            //aqui estamos devolviendo los datos desde la cache de la sesion.
            if (isTestFinished()) {
                $response = array("cache" => "get data from cache.", "data" => array("num_question" => getCountQuestion(), "correctCount" => getCorrectCount()));
            } else {
                $response = array("page" => getPage(), "category" => getCategory(), "token_test" => getTokenTest(), "token_user" => getTokenUser());
            }
            break;
            //////////////////////DEFAULT/////////////////////////////////////
            //cualquier accion no contemplada entrara aqui.
        //////////////////////DEFAULT/////////////////////////////////////
        //cualquier accion no contemplada entrara aqui.
        default:
            $response = array("error" => 1040, "description" => "Error de PHP, error inesperado");
            break;
    }
    $connection->close();
    echo json_encode($response);
}
while (($line = fgetcsv($file)) !== FALSE) {
    $count++;
    //$line is an array of the csv elements
    if (!empty($line[0]) && !empty($line[1])) {
        $data['general']['path'] = $line[0];
        $data['general']['name'] = $line[1];
        $data['general']['meta_title'] = "";
        $data['general']['meta_description'] = "";
        $data['general']['is_active'] = "";
        $data['general']['url_key'] = "";
        $data['general']['display_mode'] = "PRODUCTS";
        $data['general']['is_anchor'] = 0;
        $data['category']['parent'] = $line[0];
        // 3 top level
        $storeId = 0;
        createCategory($data, $storeId);
        sleep(0.5);
        unset($data);
    }
}
function createCategory($data, $storeId)
{
    echo "Starting {$data['general']['name']} [{$data['category']['parent']}] ...";
    $category = Mage::getModel('catalog/category');
    $category->setStoreId($storeId);
    # Fix must be applied to run script
    #http://www.magentocommerce.com/boards/appserv/main.php/viewreply/157328/
    if (is_array($data)) {
        $category->addData($data['general']);
        if (!$category->getId()) {
            $parentId = $data['category']['parent'];
예제 #10
0
     loadCategories($node);
     break;
 case "create_category":
     $parent = '';
     $name = '';
     $description = '';
     if (isset($_REQUEST['parent'])) {
         $parent = $_REQUEST['parent'];
     }
     if (isset($_REQUEST['name'])) {
         $name = $_REQUEST['name'];
     }
     if (isset($_REQUEST['description'])) {
         $description = $_REQUEST['description'];
     }
     createCategory($name, $parent, $description);
     break;
 case "update_category":
     $id = '';
     $name = '';
     $description = '';
     $type = '';
     // rename,move,merge
     $target = '';
     //only for move and merge
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
     }
     if (isset($_REQUEST['name'])) {
         $name = $_REQUEST['name'];
     }
예제 #11
0
    <div id="page-wrapper">

        <div class="container-fluid">

            <!-- Page Heading -->
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">
                        Admin Panel
                        <small>Author</small>
                    </h1>

                    <div class="col-xs-6">

                        <?php 
createCategory();
?>

                        <form action="" method="post">
                            <div class="form-group">
                                <label for="category_input">Add Category</label>
                                <input type="text" class="form-control" name="category_input">
                            </div>
                            <div class="form-group">
                                <input type="submit" class="btn btn-primary" name="submit" value="Add Category">
                            </div>
                        </form>

                        <?php 
if (isset($_GET['edit'])) {
    include 'views/update_gategories.php';
예제 #12
0
function createField($name, $details)
{
    switch ($details->{'type'}) {
        case 'text':
            createFieldText($name, $details);
            break;
        case 'checkbox':
            createFieldCheckBox($name, $details);
            break;
        case 'hidden':
            createFieldHidden($name, $details);
            break;
        case 'category':
            createCategory($name, $details);
            break;
    }
}
예제 #13
0
session_start();
is_login(DOCROOT . "admin/login/");
//checking whether admin logged in or not.
if ($_POST) {
    $categoryname = htmlentities($_POST['categoryname'], ENT_QUOTES);
    $category_url = htmlentities($_POST['permalink'], ENT_QUOTES);
    //$category_img = htmlentities($_POST['imglink'], ENT_QUOTES);
    $queryString = "select * from coupons_category where category_name = '{$categoryname}' ";
    $resultSet = mysql_query($queryString);
    if (mysql_num_rows($resultSet) > 0) {
        set_response_mes(-1, $admin_language['categoryexist']);
        $redirect_url = DOCROOT . 'add/category/';
        url_redirect($redirect_url);
    } else {
        createCategory($categoryname, $category_url, $category_img);
        set_response_mes(1, $admin_language['categoryadded']);
        $redirect_url = DOCROOT . 'add/category/';
        url_redirect($redirect_url);
    }
}
?>

<script type="text/javascript">
/* validation */
$(document).ready(function(){ $("#form_createcategory").validate();});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
$(".toggleul_4").slideToggle(); 
예제 #14
0
    switch ($action) {
        case 'getAllCategoriesDT':
            echo getAllCategoriesDT();
            break;
        case 'deleteCategory':
            $id = $_POST['id'];
            echo deleteCategory($id);
            break;
        case 'editCategory':
            $id = $_POST['id'];
            $category = $_POST['category'];
            echo editCategory($id, $category);
            break;
        case 'createCategory':
            $category = $_POST['category'];
            echo createCategory($category);
            break;
    }
}
function getAllCategoriesDT()
{
    global $bdd, $_TABLES;
    if (!is_null($bdd) && !is_null($_TABLES)) {
        $content = '<thead>';
        $content .= '<tr>';
        $content .= '<th>Id</th>';
        $content .= '<th>Category</th>';
        $content .= '<th>Action</th>';
        $content .= '</tr>';
        $content .= '</thead>';
        $content .= '<tbody>';
예제 #15
0
function syncCreateCategory($usermail, $password, $name, $parentid = 0)
{
    global $db;
    $tbl_cat = MYSQL_TABLE_PREFIX . 'media_categories';
    $assigned_groups = getAssignedGroups($usermail, $password);
    if ($assigned_groups == false) {
        return false;
    }
    $parentid = (int) $parentid;
    $parent = $db->selectOneRow($tbl_cat, "*", "`categoryid`=" . $parentid);
    if ($parent == null && $parentid > 0) {
        return false;
    }
    if ($db->selectOneRow($tbl_cat, "*", "`name`='" . secureMySQL($name) . "'") != null) {
        return false;
    }
    createCategory($name, $parentid);
    return true;
}
예제 #16
0
<?php

if (isset($_GET['detail']) && $_GET['detail'] == 'createMain') {
    if (isset($_POST['category_name']) && !empty($_POST['category_name'])) {
        $msg = createCategory($_POST['category_name'], $db, $_POST['subcategory_name']);
        if ($msg) {
            $responseMain[] = 'Kategorie erfolgreich angelegt';
        } else {
            $responseMain[] = 'Kategorie konnte nicht angelegt werden!';
        }
    } elseif (empty($_POST['category_name'])) {
        $responseMain[] = 'Kategoriename!';
    }
}
if (isset($_GET['detail']) && $_GET['detail'] == 'createSub') {
    if (isset($_POST['subcategory_name'], $_POST['parent_category']) && !empty($_POST['subcategory_name']) && !empty($_POST['parent_category'])) {
        $msg = createSubcategory($_POST['subcategory_name'], $_POST['parent_category'], $db);
        if ($msg) {
            $responseSub[] = 'Unterkategorie erfolgreich angelegt';
        } else {
            $responseSub[] = 'Unterkategorie konnte nicht angelegt werden!';
        }
    } elseif (empty($_POST['subcategory_name'])) {
        $responseSub[] = 'Unterkategoriename!';
    }
}
if (isset($_GET['detail']) && $_GET['detail'] == 'edit') {
    $msg = updateCategories($_POST, $db);
    if ($msg) {
        header('Location: /dashboard/categories');
    } else {
예제 #17
0
     $file = $filepath . $filename;
     $f = fopen($file, 'r');
     $last_order_id = '';
     while ($data = fgetcsv($f)) {
         $order_id = $data[0];
         if ($order_id == $last_order_id and $last_order_id != '') {
             array_push($product, array_slice($data, -16));
         } else {
             if ($order_id != $last_order_id) {
                 custom_order::import_orders($order, $product);
                 $product = array();
                 $order = array_slice($data, 0, 76);
                 array_push($product, array_slice($data, -16));
             }
         }
         $return = createCategory($category);
     }
     custom_order::import_orders($order, $product);
     exit;
 } else {
     if ($method == 'test') {
         $order = new custom_order();
         $order->createOrder(1, '');
         exit;
     } else {
         $errorcode = 10062;
         throw new Exception("INVALID_METHOD");
     }
 }
 $result = array("data" => $data, "success" => 1, "errorcode" => 0);
 if (isset($param['array']) and trim($param['array']) != '') {
예제 #18
0
파일: create.php 프로젝트: sebadorn/aestas3
        header('Location: ../admin.php?error=missing_data_for_media');
        exit;
    }
    $media = new ae_MediaModel();
    $media->load($_POST['edit-id']);
    $media->setMediaPath('../../media/');
    $media->setName($_POST['media-name']);
    if (!$media->save()) {
        return FALSE;
    }
    return $media->getId();
}
$id = FALSE;
switch ($_POST['area']) {
    case 'category':
        $id = createCategory();
        break;
    case 'cofilter':
        $id = createCommentfilter();
        break;
    case 'comment':
        $id = updateComment();
        break;
    case 'media':
        $id = updateMedia();
        break;
    case 'page':
        $id = createPage();
        break;
    case 'post':
        $id = createPost();
예제 #19
0
        <!-- Optional theme -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
    </head>
    <body>
        <?php 
require_once '../../includes/session-start.req-inc.php';
require_once '../../includes/access-required.html.php';
if (isPostRequest()) {
    $category = filter_input(INPUT_POST, 'category');
    $errors = array();
    if (!isValidCategory($category)) {
        $errors[] = 'Category is not valid';
    }
    if (count($errors) == 0) {
        if (createCategory($category)) {
            $results = 'Category added';
        } else {
            $results = 'Category was not added';
        }
    }
}
?>
        
         <h1>Add Category</h1>
        
          <?php 
if (isset($errors) && count($errors) > 0) {
    ?>
            <ul>
                <?php 
예제 #20
0
function EditCategory2()
{
    global $db_prefix, $sourcedir;
    checkSession();
    require_once $sourcedir . '/Subs-Boards.php';
    $_POST['cat'] = (int) $_POST['cat'];
    // Add a new category or modify an existing one..
    if (isset($_POST['edit']) || isset($_POST['add'])) {
        $catOptions = array();
        if (isset($_POST['cat_order'])) {
            $catOptions['move_after'] = (int) $_POST['cat_order'];
        }
        // Change "This & That" to "This &amp; That" but don't change "&cent" to "&amp;cent;"...
        $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['cat_name']);
        $catOptions['is_collapsible'] = isset($_POST['collapse']);
        if (isset($_POST['add'])) {
            createCategory($catOptions);
        } else {
            modifyCategory($_POST['cat'], $catOptions);
        }
    } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) {
        EditCategory();
        return;
    } elseif (isset($_POST['delete'])) {
        // First off - check if we are moving all the current boards first - before we start deleting!
        if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) {
            if (empty($_POST['cat_to'])) {
                fatal_lang_error('mboards_delete_error');
            }
            deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']);
        } else {
            deleteCategories(array($_POST['cat']));
        }
    }
    redirectexit('action=manageboards');
}
예제 #21
-1
function getCategory($name)
{
    global $db;
    if (empty($name)) {
        $name = "Default";
    }
    preg_match("/^(\\[(.*)\\])?([^!]+)!?(.*)/", $name, $ref);
    if ($ref[1] != "") {
        $tab = $ref[2];
        $main = $ref[3];
        if ($ref[4] != "") {
            $sub = $ref[4];
        } else {
            $sub = false;
        }
    } else {
        if ($ref[3] != "" and $ref[3] != $ref[0]) {
            $tab = false;
            $main = $ref[3];
            if ($ref[4] != "") {
                $sub = $ref[4];
            } else {
                $sub = false;
            }
        } else {
            $tab = false;
            $sub = false;
            if (substr($name, 0, 1) == "[") {
                $main = "Default";
            } else {
                $main = $name;
            }
        }
    }
    $found = true;
    // suche die Hauptgruppe
    $sql = "select * from kategorien where Name like '" . $main . "' and  Unterkategorie_von is Null";
    $rs = $db->getAll($sql, DB_FETCHMODE_ASSOC);
    if ($rs[0]["Kategorie_ID"]) {
        // gefunden
        $maingroup = $rs[0]["Kategorie_ID"];
    } else {
        // nicht gefunden, anlegen
        $maingroup = createCategory($main, "Null", "{$tab}");
    }
    echo $maingroup . ":" . $main . " ";
    if ($sub && $maingroup) {
        // suche Unterkategorie wenn eine gegeben
        $sql = "select * from kategorien where Name like '{$sub}' and  Unterkategorie_von = '{$main}'";
        $rs = $db->getAll($sql, DB_FETCHMODE_ASSOC);
        if ($rs[0]["Kategorie_ID"]) {
            // gefunden
            $maingroup = $rs[0]["Kategorie_ID"];
        } else {
            // nicht gefunden, anlegen
            $maingroup = createCategory($sub, "'{$main}'", "");
        }
    }
    echo $sub . " ";
    return $maingroup;
}
예제 #22
-1
<?php

require_once '_crud.php';
header('Content-Type: application/json');
$request = json_decode(file_get_contents('php://input'));
$result = new DataSourceResult($database);
$data = $result->read($table, $read_columns, $request);
// build child objects for category and supplier by converting
// the flat data into a child object, for both
foreach ($data['data'] as $key => $product) {
    $supplier = createSupplier($product['SupplierID'], $product['SupplierName']);
    $product['Supplier'] = $supplier;
    $category = createCategory($product['CategoryID'], $product['CategoryName']);
    $product['Category'] = $category;
    unset($product['SupplierID']);
    unset($product['SupplierName']);
    unset($product['CategoryID']);
    unset($product['CategoryName']);
    $data['data'][$key] = $product;
}
echo json_encode($data);
예제 #23
-1
 /**
  * Function for handling a submitted form saving the category.
  *
  * What it does:
  * - complete the modifications to a specific category.
  * - It also handles deletion of a category.
  * - It requires manage_boards permission.
  * - Called by ?action=admin;area=manageboards;sa=cat2
  * - Redirects to ?action=admin;area=manageboards.
  */
 public function action_cat2()
 {
     checkSession();
     validateToken('admin-bc-' . $_REQUEST['cat']);
     require_once SUBSDIR . '/Categories.subs.php';
     $_POST['cat'] = (int) $_POST['cat'];
     // Add a new category or modify an existing one..
     if (isset($_POST['edit']) || isset($_POST['add'])) {
         $catOptions = array();
         if (isset($_POST['cat_order'])) {
             $catOptions['move_after'] = (int) $_POST['cat_order'];
         }
         // Change "This & That" to "This &amp; That" but don't change "&cent" to "&amp;cent;"...
         $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['cat_name']);
         $catOptions['is_collapsible'] = isset($_POST['collapse']);
         if (isset($_POST['add'])) {
             createCategory($catOptions);
         } else {
             modifyCategory($_POST['cat'], $catOptions);
         }
     } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) {
         $this->action_cat();
         return;
     } elseif (isset($_POST['delete'])) {
         // First off - check if we are moving all the current boards first - before we start deleting!
         if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) {
             if (empty($_POST['cat_to'])) {
                 fatal_lang_error('mboards_delete_error');
             }
             deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']);
         } else {
             deleteCategories(array($_POST['cat']));
         }
     }
     redirectexit('action=admin;area=manageboards');
 }