Initial commit
This commit is contained in:
157
www/backoffice/classes/DocumentsAdmin.class.php
Normal file
157
www/backoffice/classes/DocumentsAdmin.class.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) 2005-2013 OpenStudio */
|
||||
/* email : info@thelia.fr */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
require_once(__DIR__."/FichierAdminBase.class.php");
|
||||
|
||||
class DocumentsAdmin extends FichierAdminBase {
|
||||
|
||||
const NOMBRE_UPLOAD = 1;
|
||||
|
||||
public function __construct($typeobjet, $idobjet, $lang) {
|
||||
|
||||
parent::__construct("Document", self::NOMBRE_UPLOAD, $typeobjet, $idobjet, $lang);
|
||||
}
|
||||
|
||||
public function action($action) {
|
||||
|
||||
switch($action){
|
||||
case 'ajouterdoc' :
|
||||
$this->ajouter($_REQUEST['id'], "doc", array(), "uploaddocument");
|
||||
break;
|
||||
|
||||
case 'modifierdoc' :
|
||||
$this->modifier($_REQUEST['id_document'], $_REQUEST['titredoc'], $_REQUEST['chapodoc'], $_REQUEST['descriptiondoc']);
|
||||
break;
|
||||
|
||||
case 'supprimerdoc' :
|
||||
$this->supprimer($_REQUEST['id_document']);
|
||||
break;
|
||||
|
||||
case 'modclassementdoc' :
|
||||
$this->modclassement($_REQUEST['id_document'],$_REQUEST['type']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function chemin_objet($fichier) {
|
||||
return sprintf("../client/document/%s", $fichier);
|
||||
}
|
||||
|
||||
public function bloc_transfert() {
|
||||
?>
|
||||
<div class="bloc_transfert">
|
||||
<div class="claire">
|
||||
<div class="designation" style="height:70px; padding-top:10px;"><?php echo trad('Transferer_documents', 'admin'); ?></div>
|
||||
<div class="champs" style="padding-top:10px;">
|
||||
<form action="<?php echo $this->nompageadmin; ?>" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="action" value="ajouterdoc" />
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $this->idobjet; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $this->lang; ?>" />
|
||||
|
||||
<?php $this->form_hidden_fieds(); ?>
|
||||
|
||||
<?php for($i=1; $i<=self::NOMBRE_UPLOAD; $i++) { ?>
|
||||
<input type="file" id="doc<?php echo($i); ?>" name="doc<?php echo($i); ?>" class="form" /><br/>
|
||||
<?php } ?>
|
||||
|
||||
<input type="submit" value="<?php echo trad('Ajouter', 'admin'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function bloc_gestion() {
|
||||
|
||||
$document = new Document();
|
||||
$documentdesc = new Documentdesc();
|
||||
|
||||
$query = "select * from $document->table where $this->typeobjet='$this->idobjet' order by classement";
|
||||
$resul =$document->query($query);
|
||||
|
||||
while($resul && $row = $document->fetch_object($resul)) {
|
||||
|
||||
$document = new Document();
|
||||
$documentdesc = new Documentdesc();
|
||||
|
||||
$documentdesc->charger($row->id, $this->lang);
|
||||
?>
|
||||
<form action="<?php echo $this->nompageadmin; ?>" method="post">
|
||||
<input type="hidden" name="action" value="modifierdoc" />
|
||||
<input type="hidden" name="id_document" value="<?php echo $row->id; ?>" />
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $this->idobjet; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $this->lang; ?>" />
|
||||
|
||||
<?php $this->form_hidden_fieds(); ?>
|
||||
|
||||
<ul>
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation"><?php echo trad('Fichier', 'admin'); ?></div>
|
||||
<div class="cellule_document"><a href="<?php echo $this->chemin_objet($row->fichier); ?>" target="_blank"><?php if(strlen($row->fichier) > 26) echo(substr($row->fichier,0,26)." ... ".substr($row->fichier,strlen($row->fichier)-3,strlen($row->fichier)));
|
||||
else echo $row->fichier; ?></a></div>
|
||||
<div class="cellule_supp_fichier">
|
||||
<a onclick="return confirm('<?php echo trad('Supprimer définitivement ce document ?', 'admin'); ?>');" href="<?php echo $this->url_page_admin() ?>&id_document=<?php echo($row->id); ?>&action=supprimerdoc"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></div>
|
||||
</li>
|
||||
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:30px;"><?php echo trad('Titre', 'admin'); ?></div>
|
||||
<div class="cellule">
|
||||
<input type="text" name="titredoc" style="width:219px;" class="form" value="<?php echo htmlspecialchars($documentdesc->titre); ?>" />
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:50px;"><?php echo trad('Chapo', 'admin'); ?></div>
|
||||
<div class="cellule"><textarea name="chapodoc" rows="2" class="form" style="width:219px;"><?php echo $documentdesc->chapo ?></textarea>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:65px;"><?php echo trad('Description', 'admin'); ?></div>
|
||||
<div class="cellule"><textarea name="descriptiondoc" class="form" rows="3" style="width:219px;"><?php echo $documentdesc->description ?></textarea></div>
|
||||
</li>
|
||||
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:30px;"><?php echo trad('Classement', 'admin'); ?></div>
|
||||
<div class="cellule">
|
||||
<div class="classement">
|
||||
<a href="<?php echo $this->url_page_admin() . "&id_document=".$row->id."&action=modclassementdoc&type=M"; ?>"><img src="gfx/up.gif" border="0" /></a></div>
|
||||
<div class="classement">
|
||||
<a href="<?php echo $this->url_page_admin() . "&id_document=".$row->id."&action=modclassementdoc&type=D"; ?>"><img src="gfx/dn.gif" border="0" /></a></div>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:30px;"> </div>
|
||||
<div class="cellule" style="height:30px; border-bottom: 1px dotted #9DACB6"><input type="submit" value="<?php echo trad('Enregistrer', 'admin'); ?>" /></div>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
176
www/backoffice/classes/FichierAdminBase.class.php
Normal file
176
www/backoffice/classes/FichierAdminBase.class.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
abstract class FichierAdminBase {
|
||||
|
||||
protected $typeobjet;
|
||||
protected $idobjet;
|
||||
protected $class;
|
||||
protected $classdesc;
|
||||
protected $lang;
|
||||
protected $nompageadmin;
|
||||
|
||||
protected $produit = false;
|
||||
protected $contenu = false;
|
||||
|
||||
protected $nombre_champs_upload;
|
||||
|
||||
public function __construct($class, $nombre_champs_upload, $typeobjet, $idobjet, $lang) {
|
||||
|
||||
$this->typeobjet = $typeobjet;
|
||||
$this->lang = $lang;
|
||||
|
||||
$this->class = ucfirst(strtolower($class));
|
||||
$this->classdesc = ucfirst(strtolower($class)."desc");
|
||||
|
||||
$this->nompageadmin = $this->typeobjet."_modifier.php";
|
||||
$this->nombre_champs_upload = $nombre_champs_upload;
|
||||
|
||||
if ($this->typeobjet == 'produit') {
|
||||
$this->produit = new Produit($idobjet);
|
||||
$this->idobjet = $this->produit->id;
|
||||
}
|
||||
else if ($this->typeobjet == 'contenu') {
|
||||
$this->contenu = new Contenu($idobjet);
|
||||
$this->idobjet = $idobjet;
|
||||
}
|
||||
else
|
||||
$this->idobjet = $idobjet;
|
||||
}
|
||||
|
||||
public function url_page_admin() {
|
||||
if ($this->produit)
|
||||
$url = "$this->nompageadmin?ref=" . $this->produit->ref . "&rubrique=" . $this->produit->rubrique."&lang=".$this->lang;
|
||||
else if ($this->contenu)
|
||||
$url = "$this->nompageadmin?id=" . $this->idobjet."&dossier=".$this->contenu->dossier."&lang=".$this->lang;
|
||||
else {
|
||||
$url = "$this->nompageadmin?id=" . $this->idobjet."&lang=".$this->lang;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function form_hidden_fieds() {
|
||||
|
||||
if ($this->produit) {
|
||||
?>
|
||||
<input type="hidden" name="ref" value="<?php echo($this->produit->ref); ?>" />
|
||||
<input type="hidden" name="rubrique" value="<?php echo($this->produit->rubrique); ?>" />
|
||||
<?php
|
||||
}
|
||||
else if ($this->contenu) {
|
||||
?>
|
||||
<input type="hidden" name="dossier" value="<?php echo($this->contenu->dossier); ?>" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract function chemin_objet($fichier);
|
||||
|
||||
protected function modclassement($id, $type){
|
||||
$obj = new $this->class();
|
||||
|
||||
if ($obj->charger($id))
|
||||
$obj->changer_classement($id, $type);
|
||||
}
|
||||
|
||||
protected function supprimer($id){
|
||||
|
||||
$obj = new $this->class();
|
||||
|
||||
if ($obj->charger($id)) {
|
||||
|
||||
if(file_exists($this->chemin_objet($obj->fichier)))
|
||||
unlink($this->chemin_objet($obj->fichier));
|
||||
|
||||
$obj->delete();
|
||||
}
|
||||
|
||||
redirige($this->url_page_admin());
|
||||
}
|
||||
|
||||
protected function modifier($id, $titre, $chapo, $description){
|
||||
|
||||
$objdesc = new $this->classdesc();
|
||||
|
||||
$colonne = strtolower($this->class);
|
||||
$objdesc->$colonne = $id;
|
||||
|
||||
$objdesc->lang = $this->lang;
|
||||
|
||||
$objdesc->charger($id,$this->lang);
|
||||
|
||||
$objdesc->titre = $titre;
|
||||
$objdesc->chapo = $chapo;
|
||||
$objdesc->description = $description;
|
||||
$objdesc->lang = $this->lang;
|
||||
$objdesc->$colonne = $id;
|
||||
|
||||
if(!$objdesc->id)
|
||||
$objdesc->add();
|
||||
else
|
||||
$objdesc->maj();
|
||||
|
||||
redirige($this->url_page_admin());
|
||||
}
|
||||
|
||||
protected function ajouter($id, $nom_arg, $extensions_valides = array(), $point_d_entree) {
|
||||
|
||||
for($i = 1; $i <= $this->nombre_champs_upload; $i++) {
|
||||
|
||||
$fichier = $_FILES[$nom_arg . $i]['tmp_name'];
|
||||
$nom = $_FILES[$nom_arg . $i]['name'];
|
||||
|
||||
if ($fichier != "") {
|
||||
|
||||
$dot = strrpos($nom, '.');
|
||||
|
||||
if ($dot !== false) {
|
||||
|
||||
$fich = substr($nom, 0, $dot);
|
||||
$extension = substr($nom, $dot+1);
|
||||
|
||||
if ($fich != "" && $extension != "" && (empty($extensions_valides) || (in_array($extension, $extensions_valides))) ) {
|
||||
|
||||
$obj = new $this->class();
|
||||
|
||||
$colonne = $this->typeobjet;
|
||||
$obj->$colonne = $id;
|
||||
|
||||
$lastid = $obj->add();
|
||||
|
||||
$obj->charger($lastid);
|
||||
$obj->fichier = eregfic(sprintf("%s_%s", $fich, $lastid)) . "." . $extension;
|
||||
$obj->maj();
|
||||
|
||||
copy($fichier, $this->chemin_objet($obj->fichier));
|
||||
|
||||
ActionsModules::instance()->appel_module($point_d_entree, $obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirige($this->url_page_admin());
|
||||
}
|
||||
}
|
||||
?>
|
||||
146
www/backoffice/classes/ImagesAdmin.class.php
Normal file
146
www/backoffice/classes/ImagesAdmin.class.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) 2005-2013 OpenStudio */
|
||||
/* email : info@thelia.fr */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
require_once(__DIR__."/FichierAdminBase.class.php");
|
||||
|
||||
class ImagesAdmin extends FichierAdminBase {
|
||||
|
||||
const NOMBRE_UPLOAD = 5;
|
||||
|
||||
public function __construct($typeobjet, $idobjet, $lang) {
|
||||
parent::__construct("Image", self::NOMBRE_UPLOAD, $typeobjet, $idobjet, $lang);
|
||||
}
|
||||
|
||||
public function action($action) {
|
||||
|
||||
switch($action){
|
||||
case 'ajouterphoto' :
|
||||
$this->ajouter($_REQUEST['id'], "photo", array("jpg", "gif", "png", "jpeg"), "uploadimage");
|
||||
break;
|
||||
|
||||
case 'modifierphoto' :
|
||||
$this->modifier($_REQUEST['id_photo'], $_REQUEST['titre_photo'], $_REQUEST['chapo_photo'], $_REQUEST['description_photo']);
|
||||
break;
|
||||
|
||||
case 'supprimerphoto' :
|
||||
$this->supprimer($_REQUEST['id_photo']);
|
||||
break;
|
||||
|
||||
case 'modclassementphoto' :
|
||||
$this->modclassement($_REQUEST['id_photo'],$_REQUEST['type']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function chemin_objet($fichier) {
|
||||
return sprintf("../client/gfx/photos/$this->typeobjet/%s", $fichier);
|
||||
}
|
||||
|
||||
public function bloc_transfert() {
|
||||
?>
|
||||
<!-- bloc transfert des images -->
|
||||
<div class="bloc_transfert">
|
||||
<div class="claire">
|
||||
<div class="designation" style="height:160px; padding-top:10px;"><?php echo trad('Transferer_images', 'admin'); ?></div>
|
||||
<div class="champs" style="padding-top:10px;">
|
||||
<form action="<?php echo $this->nompageadmin; ?>" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="action" value="ajouterphoto" />
|
||||
<input type="hidden" name="id" value="<?php echo $this->idobjet; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $this->lang; ?>" />
|
||||
<?php $this->form_hidden_fieds(); ?>
|
||||
|
||||
<?php for($i=1; $i<=self::NOMBRE_UPLOAD; $i++) { ?>
|
||||
<input type="file" id="photo<?php echo($i); ?>" name="photo<?php echo($i); ?>" class="form" /><br/>
|
||||
<?php } ?>
|
||||
<input type="submit" value="<?php echo trad('Ajouter', 'admin'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function bloc_gestion() {
|
||||
|
||||
$image = new Image();
|
||||
|
||||
$query = "select * from $image->table where $this->typeobjet='$this->idobjet' order by classement";
|
||||
|
||||
$resul = $image->query($query);
|
||||
|
||||
while($resul && $row = $image->fetch_object($resul)) {
|
||||
$imagedesc = new Imagedesc();
|
||||
$imagedesc->charger($row->id,$this->lang);
|
||||
?>
|
||||
|
||||
<form action="<?php echo $this->nompageadmin; ?>" method="post">
|
||||
<input type="hidden" name="action" value="modifierphoto" />
|
||||
<input type="hidden" name="id_photo" value="<?php echo $row->id; ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo $this->idobjet; ?>" />
|
||||
<input type="hidden" name="lang" value="<?php echo $this->lang; ?>" />
|
||||
<?php $this->form_hidden_fieds(); ?>
|
||||
|
||||
<ul>
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:208px;"> </div>
|
||||
<div class="cellule_photos" style="height:200px; overflow:hidden;"><a href="<?php echo($this->chemin_objet($row->fichier)); ?>" target="_blank"><img src="../fonctions/redimlive.php?type=<?php echo $this->typeobjet ?>&nomorig=<?php echo($row->fichier); ?>&width=&height=200&opacite=&nb=" border="0" /></a></div>
|
||||
<div class="cellule_supp"><a onclick="return confirm('<?php echo trad('Supprimer définitivement cette image ?', 'admin'); ?>');" href="<?php echo $this->url_page_admin() ?>&id_photo=<?php echo($row->id); ?>&action=supprimerphoto"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></div>
|
||||
</li>
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:30px;"><?php echo trad('Titre', 'admin'); ?></div>
|
||||
<div class="cellule">
|
||||
<input type="text" name="titre_photo" style="width:219px;" class="form" value="<?php echo htmlspecialchars($imagedesc->titre) ?>" />
|
||||
</div>
|
||||
</li>
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:50px;"><?php echo trad('Chapo', 'admin'); ?></div>
|
||||
<div class="cellule"><textarea name="chapo_photo" rows="2"class="form" style="width:219px;"><?php echo $imagedesc->chapo ?></textarea></div>
|
||||
</li>
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:65px;"><?php echo trad('Description', 'admin'); ?></div>
|
||||
<div class="cellule"><textarea name="description_photo" class="form" rows="3"><?php echo $imagedesc->description ?></textarea></div>
|
||||
</li>
|
||||
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:30px;"><?php echo trad('Classement', 'admin'); ?></div>
|
||||
<div class="cellule">
|
||||
<div class="classement">
|
||||
<a href="<?php echo $this->url_page_admin() . "&id_photo=".$row->id."&action=modclassementphoto&type=M"; ?>"><img src="gfx/up.gif" border="0" /></a></div>
|
||||
<div class="classement">
|
||||
<a href="<?php echo $this->url_page_admin() . "&id_photo=".$row->id."&action=modclassementphoto&type=D"; ?>"><img src="gfx/dn.gif" border="0" /></a></div>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="lignesimple">
|
||||
<div class="cellule_designation" style="height:30px;"> </div>
|
||||
<div class="cellule" style="height:30px; border-bottom: 1px dotted #9DACB6"><input type="submit" value="<?php echo trad('Enregistrer', 'admin'); ?>" /></div>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user