public function getAdd()
 {
     $result['title'] = 'Shop';
     $result['action'] = '/promotion/add';
     $result['submit'] = 'add';
     $categories = $this->category->getCategories();
     $result['categories'][] = array('text' => 'No category', 'options' => array('value' => 0));
     foreach ($categories as $c) {
         $currentCategory = array();
         $currentCategory['text'] = $c['name'];
         $currentCategory['options'] = array('value' => $c['id']);
         $result['categories'][] = $currentCategory;
     }
     $products = $this->product->getProducts();
     $result['products'][] = array('text' => 'No product', 'options' => array('value' => 0));
     foreach ($products as $c) {
         $currentProduct = array();
         $currentProduct['text'] = $c['name'];
         $currentProduct['options'] = array('value' => $c['id']);
         $result['products'][] = $currentProduct;
     }
     View::make('promotion.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
Ejemplo n.º 2
0
 public function showProductByCategory($id)
 {
     $category = new Category();
     $products = $category->products($id);
     $image = new Image();
     $tag = new Tag();
     view('front.category', compact('products', 'image', 'tag'));
 }
 /**
  * The function create new category in database
  *
  * @param $codeCategory
  * @param $name
  * @return models\Category
  */
 public function createCategory($codeCategory, $name)
 {
     $entityManager = DaoFactory::getFactory()->getEntityManager();
     $category = new models\Category();
     $category->setCodeCategory($codeCategory);
     $category->setName($name);
     $entityManager->persist($category);
     $entityManager->flush();
     return $category;
 }
Ejemplo n.º 4
0
 public function category($id)
 {
     $product = new Product();
     $products = $product->productCategory($id);
     $category = new Category();
     $categories = $category->getCategory($id);
     $tags = new Tag();
     $image = new Image();
     view('front.category', compact('products', 'image', 'tags', 'categories'));
 }
 public function getEdit($id)
 {
     $result['title'] = 'Edit';
     /* @var $estate \Models\ViewModels\EstateViewModel */
     $estate = $this->estate->getEstate($id);
     if ($estate == null) {
         Session::setError('The estate id is incorrect');
         Redirect::to('');
     }
     $estate->images = $this->image->getImagesByEstate($id);
     foreach ($estate->images as $i) {
         $i->thumbnailName = $this->setImageThumb($i->name);
     }
     $result['estate'] = $estate;
     $result['action'] = '/admin/estate/' . $estate->id . '/edit';
     $result['submit'] = 'Edit';
     $result['categories'] = $this->setCategoryFormOptions($this->category->getCategories(), $estate);
     $result['cities'] = $this->setCityFormOptions($this->city->getCities(), $estate);
     View::make('estate.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
 public function getEdit($id)
 {
     $result['isEditor'] = Auth::isUserInRole(array('editor', 'admin'));
     $result['isAdmin'] = Auth::isUserInRole(array('admin'));
     if ($result['isEditor']) {
         $result = array('product' => $this->product->getProductWitnUnavailable($id));
     } else {
         $result = array('product' => $this->product->getProduct($id));
     }
     $result['title'] = 'Shop';
     $result['action'] = '/product/edit/' . $result['product']['id'];
     $result['submit'] = 'edit';
     $categories = $this->category->getCategories();
     foreach ($categories as $c) {
         $currentCategory = array();
         $currentCategory['text'] = $c['name'];
         $currentCategory['options'] = array('value' => $c['id']);
         if ($id == $c['id']) {
             $currentCategory['options']['selected'] = 'true';
         }
         $result['categories'][] = $currentCategory;
     }
     View::make('product.add', $result);
     if (Auth::isAuth()) {
         View::appendTemplateToLayout('topBar', 'top_bar/user');
     } else {
         View::appendTemplateToLayout('topBar', 'top_bar/guest');
     }
     View::appendTemplateToLayout('header', 'includes/header')->appendTemplateToLayout('footer', 'includes/footer')->render();
 }
Ejemplo n.º 7
0
 /**
  * define page title and load template files
  */
 public function index()
 {
     $this->data['title'] = 'Albums';
     $this->data['category'] = Category::row('category_slug', 'playlist');
     if (isset($_POST) && !empty($_POST)) {
         //generate slug
         $slug = Url::generateSafeSlug($_POST['title']);
         $albumArray = array('album_name' => $_POST['title'], 'album_user_id' => Session::get('user_id'), 'album_description' => $_POST['description'], 'album_created' => time());
         $albumArray = Gump::xss_clean($albumArray);
         $albumArray = Gump::sanitize($albumArray);
         $album_id = $this->albumModel->create($albumArray);
         if ($album_id > 0) {
             $checkSlug = $this->albumModel->getColRow('album_slug', $slug);
             if (!is_bool($checkSlug)) {
                 $updateSlug = $this->albumModel->updateId(array('album_slug' => $slug . $album_id), $album_id);
             }
             //UPLOAD ALBUM COVER
             if ($_FILES["image"]["tmp_name"] != '') {
                 //upload file into uploads folder
                 Upload::setName(time());
                 Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
                 $update_data = array('album_image' => Upload::getFileName('images'));
                 $this->albumModel->updateId($update_data, $album_id);
             }
             Session::set('success', 'Album Created');
         } else {
             Session::set('error', 'Operation Fails');
         }
     }
     $this->data['albums'] = $this->albumModel->allalbum();
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('album/album.index', $this->data);
     View::rendertemplate('footer', $this->data);
 }
 public function postEdit($id, $name)
 {
     if ($this->category->edit($id, $name) !== 1) {
         Session::setError('something went wrong');
         Redirect::back();
     }
     Session::setMessage('done');
     Redirect::to('');
 }
Ejemplo n.º 9
0
 public function showCart()
 {
     $storage = $this->cart->all();
     $products = [];
     $category = new Category();
     $categories = $category->all();
     foreach ($storage as $id => $total) {
         $p = new Product();
         // product du Model pas du Cart
         $stmt = $p->find($id);
         $products[$stmt->title]['price'] = (double) $stmt->price;
         $products[$stmt->title]['total'] = $total;
         $products[$stmt->title]['quantity'] = $total / $stmt->price;
         $products[$stmt->title]['product_id'] = $id;
     }
     $image = new Image();
     view('front.cart', compact('products', 'image', 'categories'));
 }
Ejemplo n.º 10
0
 public function add($parameter)
 {
     $category_slug = $parameter[0];
     $this->data['title'] = 'Add Post';
     $category_model = new Category();
     $post_model = new \Models\Post();
     $album_model = new Album();
     $this->data['album_group'] = $album_model->all();
     $this->data['post_category'] = $category_model->getCol('category_slug', $category_slug);
     // var_dump(count($this->data['post_category']));
     if (isset($_POST) && !empty($_POST)) {
         $post_user_id = Session::get('user_id');
         $post_category_id = $_POST['post_category_id'];
         $post_album_id = $_POST['post_album_id'];
         $post_title = $_POST['post_title'];
         $post_body = $_POST['post_body'];
         $post_link = $_POST['post_link'];
         $post_excerpt = $_POST['post_excerpt'];
         $post_slug = Url::generateSafeSlug($post_title);
         $post_created = time();
         $post_array = array('post_user_id' => $post_user_id, 'post_category_id' => $post_category_id, 'post_album_id' => $post_album_id, 'post_title' => $post_title, 'post_body' => $post_body, 'post_link' => $post_link, 'post_excerpt' => $post_excerpt, 'post_slug' => $post_slug, 'post_created' => $post_created);
         // $insert_array = Gump::xss_clean($insert_array);
         // $insert_array = Gump::sanitize($insert_array);
         $post_id = $post_model->create($post_array);
         //UPLOAD IMAGE
         if ($_FILES["image"]["tmp_name"] != '') {
             Upload::setName(uniqid());
             Upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $update_data = array('post_image' => Upload::getFileName('images'));
             $update = $post_model->updateId($update_data, $post_id);
         }
         if ($insert_post_id > 0) {
             Session::set('success', 'post added');
             Url::redirect('post');
         }
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('post/post.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 11
0
 public function edit(Category $category)
 {
     $query = "Select id, name\n        FROM categories WHERE id = ?";
     $this->db->query($query, [$category->getId()]);
     $result = $this->db->row();
     if (!$result) {
         echo 'No such category';
         die;
     }
     $query = "Select id, name\n        FROM categories WHERE name = ?";
     $this->db->query($query, [$category->getName()]);
     $result = $this->db->row();
     if ($result) {
         echo 'The category with this name exists!';
         die;
     }
     $query = "Update categories SET name = ?\n        WHERE id = ?";
     $this->db->query($query, [$category->getName(), $category->getId()]);
     $result = $this->db->row();
     return $result;
 }
 public function postEdit($id, $name)
 {
     $validator = new Validation();
     $validator->setRule('required', $name, null, 'Name');
     if (!$validator->validate()) {
         Session::setError($validator->getErrors());
         Redirect::back();
     }
     $this->category->edit($id, $name);
     Session::setMessage('The category is edited');
     Redirect::to('');
 }
Ejemplo n.º 13
0
 public function index($array)
 {
     list($region_id, $category_id) = $array;
     $options = array('parent_id' => $category_id);
     $parents = Models\Category::find('first', array('conditions' => "category_id = {$category_id}"));
     //print_r($parents->attributes());
     if (!$category_id) {
         $options = array('conditions' => "parent_id is null");
         $c_parrent_name = $c_name = "Список категорий";
         $c_parrent_id = $c_id = 0;
     } else {
         if (!$parents->parent_id) {
             $c_parrent_id = 0;
             $c_parrent_name = "Список категорий";
         } else {
             $c_parrent_id = $parents->parent_id;
             $p = Models\Category::first(array('category_id' => $c_parrent_id));
             $c_parrent_name = ToUTF($p->name);
         }
         $options = array('parent_id' => $category_id);
         $c_name = ToUTF($parents->name);
         $c_id = $parents->category_id;
     }
     $categorys = Models\Category::find('all', $options);
     $parrent = $this->Set("parent_category");
     $parrent->addChild("category_id", $c_parrent_id);
     $parrent->addChild("category_name", $c_parrent_name);
     if ($categorys) {
         $categories = $this->Set("categories");
         $categories->addAttribute("category_id", $category_id);
         $categories->addAttribute("category_name", $c_name);
         foreach ($categorys as $key => $val) {
             $amount = Models\Category::count(array('conditions' => "parent_id = {$val->category_id}"));
             if (!$amount) {
                 $ids = new SetId($val->dirid, $val->classid, $val->grid);
                 $amount = count(Models\Category::warez($region_id, $ids));
             }
             $category = $categories->addChild("category");
             $category->addChild("category_id", $val->category_id);
             $category->addChild("category_name", ToUTF($val->name));
             $category->addChild("amount", $amount);
             $icon = $category->addChild("category_icon");
             $icon->addAttribute("width", "");
             $icon->addAttribute("height", "");
         }
     }
 }
Ejemplo n.º 14
0
 private function updateSettings()
 {
     $user = \models\User::findUser(CW::$app->user->identity->id);
     $form = new \models\forms\EditProfileForm();
     $form->userCategories = $user->categories;
     $form->userId = $user->id;
     if (empty(CW::$app->request->post())) {
         $form->username = $user->username;
         $form->description = $user->description;
         $success = false;
     } else {
         if ($form->load(CW::$app->request->post()) && $form->save()) {
             $_SESSION['user']->username = $form->username;
             $success = true;
         }
     }
     $categories = \models\Category::getAllCategories();
     return ['model' => $form, 'success' => $success, 'categories' => $categories];
 }
Ejemplo n.º 15
0
?>
								  </select>
								</div>
							  </div>

								</li>
								<li>


								 <div class="control-group">
								<label class="control-label" style="color: #fff" >Add Post</label>
								<div class="controls">
									<select name="SelectURL">
									<option>Select Module</option>
										 <?php 
$modules = Category::module();
foreach ($modules as $grp) {
    ?>
											<option	value="<?php 
    echo DIR . 'post/add/' . $grp->category_slug;
    ?>
"><?php 
    echo $grp->category_slug;
    ?>
</option>
										 <?php 
}
?>
								  </select>
								</div>
							  </div>
Ejemplo n.º 16
0
 public function add_delete_cat()
 {
     $id = $_POST['id'];
     if ($id) {
         $category = new Category($id);
         $category->delete();
         echo '';
         return true;
     }
     $v = $_POST['val'];
     $category = new Category();
     $category->setCategoryName($v);
     $id = $category->writeData();
     $return['id'] = $id;
     $return['v'] = $v;
     echo json_encode($return);
 }
Ejemplo n.º 17
0
 public function playlist()
 {
     $this->data['title'] = 'Song Playlists';
     if (isset($_POST) && !empty($_POST)) {
         //generate slug
         $slug = Url::generateSafeSlug($_POST['title']);
         $albumArray = array('album_name' => $_POST['title'], 'album_user_id' => Session::get('user_id'), 'album_category_id' => Category::id('category_title', 'playlist'), 'album_description' => $_POST['description'], 'album_slug' => $slug . 'pl', 'album_created' => time());
         $albumArray = Gump::xss_clean($albumArray);
         $albumArray = Gump::sanitize($albumArray);
         $album_id = $this->albumModel->create($albumArray);
         if ($album_id > 0) {
             $checkSlug = $this->albumModel->getColRow('album_slug', $slug);
             if (!is_bool($checkSlug)) {
                 $updateSlug = $this->albumModel->updateId(array('album_slug' => $slug . 'pl' . $album_id), $album_id);
             }
             //UPLOAD ALBUM COVER
             if ($_FILES["image"]["tmp_name"] != '') {
                 //upload file into uploads folder
                 Upload::setName(time());
                 Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, 300);
                 $update_data = array('album_image' => Upload::getFileName('images'));
                 $this->albumModel->updateId($update_data, $album_id);
             }
             Session::set('success', 'Playlist Created');
         } else {
             Session::set('error', 'Operation Fails');
         }
     }
     $this->data['albums'] = $this->albumModel->allalbum();
     $total = count(Album::type('playlist'));
     $pages = new Paginator('5', 'p');
     $this->data['albums'] = Album::type('playlist', $pages->getLimit());
     $pages->setTotal($total);
     $path = DIR . 'song/playlist?';
     $this->data['pageLinks'] = $pages->pageLinks($path, null);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('song/song.playlist', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Ejemplo n.º 18
0
 public function doAjaxLoad()
 {
     $result = Update::getUpdates(CW::$app->request->get('page'), Category::getIdByName(CW::$app->request->get('category')), CW::$app->request->get('type'), CW::$app->request->get('category'));
     CW::$app->db->close();
     return json_encode($result);
 }
Ejemplo n.º 19
0
 /**
  * Filter the query by a related \Models\Category object
  *
  * @param \Models\Category|ObjectCollection $category the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByCategory($category, $comparison = null)
 {
     if ($category instanceof \Models\Category) {
         return $this->addUsingAlias(UserTableMap::COL_ID, $category->getUserId(), $comparison);
     } elseif ($category instanceof ObjectCollection) {
         return $this->useCategoryQuery()->filterByPrimaryKeys($category->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByCategory() only accepts arguments of type \\Models\\Category or Collection');
     }
 }
Ejemplo n.º 20
0
 /**
  * Filter the query by a related \Models\Category object
  *
  * @param \Models\Category $category The related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildSharedQuery The current query, for fluid interface
  */
 public function filterByCategory($category, $comparison = null)
 {
     if ($category instanceof \Models\Category) {
         return $this->addUsingAlias(SharedTableMap::COL_WHAT_TYPE, 'category', $comparison)->addUsingAlias(SharedTableMap::COL_WHAT_ID, $category->getId(), $comparison);
     } else {
         throw new PropelException('filterByCategory() only accepts arguments of type \\Models\\Category');
     }
 }
Ejemplo n.º 21
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aNote) {
         $this->aNote->removeShared($this);
     }
     if (null !== $this->aCategory) {
         $this->aCategory->removeShared($this);
     }
     if (null !== $this->aUser) {
         $this->aUser->removeShared($this);
     }
     if (null !== $this->aGroup) {
         $this->aGroup->removeShared($this);
     }
     $this->id = null;
     $this->what_id = null;
     $this->what_type = null;
     $this->to_id = null;
     $this->to_type = null;
     $this->rights = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->applyDefaultValues();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 public function addCategory(Category $category)
 {
     $result = $this->db->prepare("\n\t\t\tINSERT INTO category(name)\n\t\t\tVALUES(?)\n\t\t");
     $result->execute([$category->getName()]);
 }
Ejemplo n.º 23
0
 /**
  * @param ChildCategory $category The ChildCategory object to add.
  */
 protected function doAddCategory(ChildCategory $category)
 {
     $this->collCategories[] = $category;
     $category->setUser($this);
 }
Ejemplo n.º 24
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeNote($this);
     }
     if (null !== $this->aCategory) {
         $this->aCategory->removeNote($this);
     }
     $this->id = null;
     $this->user_id = null;
     $this->importance = null;
     $this->title = null;
     $this->deadline = null;
     $this->category_id = null;
     $this->state = null;
     $this->repeat_after = null;
     $this->done_at = null;
     $this->public = null;
     $this->description = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->applyDefaultValues();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
Ejemplo n.º 25
0
 /**
  * Filter the query by a related \Models\Category object
  *
  * @param \Models\Category|ObjectCollection $category The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildArticleQuery The current query, for fluid interface
  */
 public function filterByCategory($category, $comparison = null)
 {
     if ($category instanceof \Models\Category) {
         return $this->addUsingAlias(ArticleTableMap::COL_ID_CATEGORY, $category->getId(), $comparison);
     } elseif ($category instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ArticleTableMap::COL_ID_CATEGORY, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCategory() only accepts arguments of type \\Models\\Category or Collection');
     }
 }
Ejemplo n.º 26
0
 /**
  * Exclude object from result
  *
  * @param   ChildCategory $category Object to remove from the list of results
  *
  * @return $this|ChildCategoryQuery The current query, for fluid interface
  */
 public function prune($category = null)
 {
     if ($category) {
         $this->addUsingAlias(CategoryTableMap::COL_ID, $category->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 27
0
 private function to_category(\Classes\Opencart\Product $product)
 {
     $category = new Category();
     if ($this->post_to_last_category) {
         $product->category = array_slice($product->category, -1, 1, true);
     }
     foreach ($product->category as $id => $name) {
         $category->add_product($product->{$this->id_field}, $id);
     }
 }
Ejemplo n.º 28
0
        ?>
            <option value="<?php 
        echo $cat->id;
        ?>
"<?php 
        echo $category->parent_id == $cat->id ? ' selected' : '';
        ?>
><?php 
        echo str_pad("", $level * 2, '|-'), e($cat->name);
        ?>
</option>
                    <?php 
        $displayParents($displayParents, $cat->children, $level + 1);
    }
};
$displayParents($displayParents, Category::getTree());
?>
</select>
    </div>
    <div class="col-xs-12 col-md-6 form-group<?php 
echo $errors->has('image_hash') ? ' has-error' : '';
?>
">
        <label>Imagine</label>
        <input type="file" name="image_hash" class="form-control">
        <?php 
if ($category->image_hash) {
    ?>
            <p class="form-control-static">
                <img src="<?php 
    echo $category->image->url(['width' => 200]);
Ejemplo n.º 29
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeArticle($this);
     }
     if (null !== $this->aImage) {
         $this->aImage->removeArticle($this);
     }
     if (null !== $this->aCategory) {
         $this->aCategory->removeArticle($this);
     }
     $this->id = null;
     $this->id_user = null;
     $this->id_image = null;
     $this->id_category = null;
     $this->title = null;
     $this->url = null;
     $this->keywords = null;
     $this->content = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }