public function showAction($id = null, $slug = null)
 {
     $id = $this->filter->sanitize($id, "int");
     $images = array();
     $model = \Models\Articles::findFirst(array("conditions" => "id = ?1", "bind" => array(1 => "{$id}")));
     $images = $model->getImages();
     $user = $model->owner;
     Tag::setTitle($model->title);
     $this->view->setVar('model', $model);
     $this->view->setVar('images', $images);
     $this->view->setVar('user', $user);
 }
Esempio n. 2
0
<?php

use Models\Articles;
// Ajout au panier
if (@$_REQUEST["action"] == 'add') {
    $article = Articles::findByPk($_REQUEST["id"]);
    // Si l'article est déjà dans le panier, on en ajoute 1, sinon on en met un premier
    $nombre = 0;
    if (isset($_SESSION["panier"][$_REQUEST["id"]])) {
        $nombre = $_SESSION["panier"][$_REQUEST["id"]]["nombre"];
    }
    // On ajoute l'article à la session panier
    $_SESSION["panier"][$_REQUEST["id"]] = array('id' => $_REQUEST["id"], 'titre' => $article["title"], 'prix' => $article["price"], 'nombre' => $nombre + 1);
    Header("Location:" . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
}
// Modification d'un article du panier
if (@$_REQUEST["action"] == 'mod') {
    if (@$_REQUEST["id"] != '') {
        // Suppression de l'article du panier
        if (@$_REQUEST["nombre"] == 0) {
            unset($_SESSION["panier"][$_REQUEST["id"]]);
            // S'il n'y a plus d'articles dans le panier, on le supprime
            if (count($_SESSION["panier"]) == 0) {
                unset($_SESSION["panier"]);
            }
        } else {
            $_SESSION["panier"][$_REQUEST["id"]]["nombre"] = $_REQUEST["nombre"];
        }
    }
    Header("Location:" . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
}
 public function loadModel($id)
 {
     $model = \Models\Articles::findFirst("id = '{$id}'");
     if ($model === null) {
         $this->flashSession->error("Статья не найдена");
         return $this->response->redirect("backend/articles/index");
     }
     return $model;
 }
Esempio n. 4
0
<div id="view"><?php 
//Selection de l'article
$article = \Models\Articles::findByPk($_GET["id"]);
?>
	<h1><?php 
echo $article->title;
?>
</h1>
	<img src="assets/images/articles/<?php 
echo $article->picture;
?>
" alt="<?php 
echo $article->title;
?>
" />
	<p><?php 
echo $article->description;
?>
</p>
	<div class="prix"><?php 
echo number_format($article->price, 2);
?>
</div>
	<a href="basket?action=add&amp;id=<?php 
echo $article->primaryKey;
?>
">Ajouter au panier</a>
	<br /><br /><?php 
?>
</div>
Esempio n. 5
0
<?php

use Models\Articles;
$article = Articles::findByPk($_GET["id"]);
?>

<div id="view">
	<h1><?php 
echo $article->title;
?>
</h1>
	<img src="assets/images/articles/<?php 
echo $article->picture;
?>
" alt="<?php 
echo $article->title;
?>
" />
	<p><?php 
echo $article->description;
?>
</p>
	<div class="prix"><?php 
echo number_format($article->price, 2);
?>
</div>
	<a href="basket?action=add&amp;id=<?php 
echo $article->id;
?>
">Ajouter au panier</a>
</div>