Example #1
0
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new CacheBase();
         self::$_instance->init();
     }
     return self::$_instance;
 }
function modifier($id, $lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite)
{
    if (!isset($id)) {
        $id = "";
    }
    if (!$lang) {
        $lang = 1;
    }
    $contenu = new Contenu();
    $contenudesc = new Contenudesc();
    $contenu->charger($id);
    $res = $contenudesc->charger($contenu->id, $lang);
    if (!$res) {
        CacheBase::getCache()->reset_cache();
        $temp = new Contenudesc();
        $temp->contenu = $contenu->id;
        $temp->lang = $lang;
        $lastid = $temp->add();
        $contenudesc = new Contenudesc();
        $contenudesc->charger_id($lastid);
    }
    $contenu->datemodif = date("Y-m-d H:i:s");
    if ($contenu->dossier != $dossier) {
        $param_old = Contenudesc::calculer_clef_url_reecrite($contenu->id, $contenu->dossier);
        $param_new = Contenudesc::calculer_clef_url_reecrite($contenu->id, $dossier);
        $reecriture = new Reecriture();
        $query_reec = "select * from {$reecriture->table} where param='&{$param_old}' and lang={$lang} and actif=1";
        $resul_reec = $reecriture->query($query_reec);
        while ($row_reec = $reecriture->fetch_object($resul_reec)) {
            $tmpreec = new Reecriture();
            $tmpreec->charger_id($row_reec->id);
            $tmpreec->param = "&{$param_new}";
            $tmpreec->maj();
        }
        $contenu->dossier = $dossier;
        $contenu->classement = $contenu->prochain_classement();
    }
    if ($ligne == "on") {
        $contenu->ligne = 1;
    } else {
        $contenu->ligne = 0;
    }
    $contenudesc->chapo = $chapo;
    $contenudesc->description = $description;
    $contenudesc->postscriptum = $postscriptum;
    $contenudesc->titre = $titre;
    $contenudesc->chapo = str_replace("\n", "<br/>", $contenudesc->chapo);
    $contenu->maj();
    $contenudesc->maj();
    $contenudesc->reecrire($urlreecrite);
    ActionsModules::instance()->appel_module("modcont", $contenu);
    if ($urlsuiv) {
        redirige("listdos.php?parent=" . $contenu->dossier);
    } else {
        redirige("" . $_SERVER['PHP_SELF'] . "?id=" . $contenu->id . "&dossier=" . $contenu->dossier . "&lang=" . $lang);
    }
    exit;
}
Example #3
0
 /**
  * Clone the cell collection
  *
  * @param  \PHPExcel\Worksheet    $parent        The new worksheet that we're copying to
  */
 public function copyCellCollection(\PHPExcel\Worksheet $parent)
 {
     parent::copyCellCollection($parent);
     $newCollection = array();
     foreach ($this->cellCache as $k => &$cell) {
         $newCollection[$k] = clone $cell;
         $newCollection[$k]->attach($this);
     }
     $this->cellCache = $newCollection;
 }
Example #4
0
 function update_config()
 {
     foreach ($_REQUEST as $var => $value) {
         if (!preg_match('/^' . Parseur::PREFIXE . '/', $var)) {
             continue;
         }
         Variable::ecrire($var, $value);
     }
     // Bug 1.4.3.1
     if (class_exists('CacheBase')) {
         CacheBase::getCache()->reset_cache();
     }
 }
Example #5
0
 private function init()
 {
     $arrConf = Util::getConf('/image_predict', 'Memcache');
     $this->_cacheBase = CacheBase::getInstance();
     $this->_cacheBase->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
     $this->_cacheBase->setOption(Memcached::OPT_CONNECT_TIMEOUT, $arrConf['CONNECT_TIMEOUT']);
     $this->_cacheBase->setOption(Memcached::OPT_SEND_TIMEOUT, $arrConf['SEND_TIMEOUT']);
     $this->_cacheBase->setOption(Memcached::OPT_RECV_TIMEOUT, $arrConf['RECV_TIMEOUT']);
     foreach ($arrConf['Servers'] as $key => $val) {
         $serverInfo = explode(' ', $val);
         $rc = $this->_cacheBase->addServer($serverInfo[0], $serverInfo[1]);
         if (false === $rc) {
             CLog::warning("ImgPredict addServer failed," . $this->_cacheBase->getErrMsg());
         }
     }
 }
function substitclient($texte)
{
    // Les #CLIENT_RAISONnF
    $raisons = CacheBase::getCache()->query("select id from raison");
    if ($raisons) {
        foreach ($raisons as $raison) {
            $sel = $_SESSION['navig']->client->raison == $raison->id ? 'selected="selected"' : '';
            $texte = str_replace("#CLIENT_RAISON" . $raison->id . "F", $sel, $texte);
        }
    }
    $paysdesc = new Paysdesc();
    $paysdesc->charger($_SESSION['navig']->client->pays);
    $raisondesc = new Raisondesc();
    $raisondesc->charger($_SESSION['navig']->client->raison);
    $texte = str_replace("#CLIENT_IDPAYS", $_SESSION['navig']->client->pays, $texte);
    $texte = str_replace("#CLIENT_ID", intval($_SESSION['navig']->client->id), $texte);
    $texte = str_replace("#CLIENT_REF", $_SESSION['navig']->client->ref, $texte);
    $texte = str_replace("#CLIENT_RAISONID", $_SESSION['navig']->client->raison, $texte);
    $texte = str_replace("#CLIENT_RAISON", $raisondesc->long, $texte);
    $texte = str_replace("#CLIENT_ENTREPRISE", $_SESSION['navig']->client->entreprise, $texte);
    $texte = str_replace("#CLIENT_SIRET", $_SESSION['navig']->client->siret, $texte);
    $texte = str_replace("#CLIENT_INTRACOM", $_SESSION['navig']->client->intracom, $texte);
    $texte = str_replace("#CLIENT_NOM", $_SESSION['navig']->client->nom, $texte);
    $texte = str_replace("#CLIENT_PRENOM", $_SESSION['navig']->client->prenom, $texte);
    $texte = str_replace("#CLIENT_ADRESSE1", $_SESSION['navig']->client->adresse1, $texte);
    $texte = str_replace("#CLIENT_ADRESSE2", $_SESSION['navig']->client->adresse2, $texte);
    $texte = str_replace("#CLIENT_ADRESSE3", $_SESSION['navig']->client->adresse3, $texte);
    $texte = str_replace("#CLIENT_CPOSTAL", $_SESSION['navig']->client->cpostal, $texte);
    $texte = str_replace("#CLIENT_VILLE", $_SESSION['navig']->client->ville, $texte);
    $texte = str_replace("#CLIENT_PAYS", $paysdesc->titre, $texte);
    $texte = str_replace("#CLIENT_EMAIL", $_SESSION['navig']->client->email, $texte);
    $texte = str_replace("#CLIENT_TELFIXE", $_SESSION['navig']->client->telfixe, $texte);
    $texte = str_replace("#CLIENT_TELPORT", $_SESSION['navig']->client->telport, $texte);
    $texte = str_replace("#CLIENT_TYPE", $_SESSION['navig']->client->type, $texte);
    return $texte;
}
Example #7
0
 /**
  * Initialise this new cell collection
  *
  * @param    \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
  * @throws  \PHPExcel\Exception
  */
 public function __construct(\PHPExcel\Worksheet $parent)
 {
     parent::__construct($parent);
     if (is_null($this->DBHandle)) {
         $this->TableName = str_replace('.', '_', $this->getUniqueID());
         $_DBName = ':memory:';
         $this->DBHandle = new \SQLite3($_DBName);
         if ($this->DBHandle === false) {
             throw new \PHPExcel\Exception($this->DBHandle->lastErrorMsg());
         }
         if (!$this->DBHandle->exec('CREATE TABLE kvp_' . $this->TableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
             throw new \PHPExcel\Exception($this->DBHandle->lastErrorMsg());
         }
     }
     $this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_" . $this->TableName . " WHERE id = :id");
     $this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_" . $this->TableName . " VALUES(:id,:data)");
     $this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_" . $this->TableName . " SET id=:toId WHERE id=:fromId");
     $this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_" . $this->TableName . " WHERE id = :id");
 }
 /**
  * Make invalid group key (like delete group key)
  *
  * @param string $keyGroupName Group name
  * @return void
  */
 function invalidateGroupKey($keyGroupName)
 {
     $this->keyGroupVersions[$keyGroupName]++;
     $this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
 }
 function traitement_formulaire_client(&$res)
 {
     require_once __DIR__ . "/Raison.class.php";
     // L'existence de l'email
     if ($_SESSION['navig']->formcli->email != "") {
         $client = new Client();
         if ($client->existe($_SESSION['navig']->formcli->email)) {
             $res = preg_replace("/\\#EXISTE\\[([^]]*)\\]/", "\\1", $res);
         }
     }
     $res = preg_replace("/\\#EXISTE\\[[^]]*\\]/", "", $res);
     // Les infos stockées en session
     $mapping = array('RAISONID' => 'raison', 'PRENOM' => 'prenom', 'NOM' => 'nom', 'ENTREPRISE' => 'entreprise', 'SIRET' => 'siret', 'INTRACOM' => 'intracom', 'ADRESSE1' => 'adresse1', 'ADRESSE2' => 'adresse2', 'ADRESSE3' => 'adresse3', 'CPOSTAL' => 'cpostal', 'VILLE' => 'ville', 'PAYS' => 'pays', 'EMAIL' => 'email', 'MOTDEPASSE' => 'motdepasse', 'TELFIXE' => 'telfixe', 'TELPORT' => 'telport');
     $res = $this->controle_formulaire($_SESSION['navig']->formcli, $mapping, $res);
     // Le parrain
     $tmpparrain = new Client();
     $tmpparrain->charger_id($_SESSION['navig']->formcli->parrain);
     $res = str_replace("#PARRAIN", $tmpparrain->email, $res);
     // Les RAISONn et CHECKn
     $raisons = CacheBase::getCache()->query("select id from " . Raison::TABLE);
     if ($raisons) {
         foreach ($raisons as $raison) {
             $sel = $_SESSION['navig']->formcli->raison == $raison->id;
             $res = str_replace("#RAISON{$raison->id}", $sel ? 'selected="selected"' : '', $res);
             $res = str_replace("#CHECK{$raison->id}", $sel ? 'checked="checked"' : '', $res);
         }
     }
     // Compatibilité < 1.5.2
     if ($_SESSION['navig']->formcli->raison == "") {
         $res = str_replace("#RAISON0", $_SESSION['navig']->formcli->raison == "" ? 'selected="selected"' : '', $res);
     }
     return $res;
 }
 private function switchBackLevel()
 {
     self::$LEVEL = $this->levelhistory;
 }
Example #11
0
 /**
  * Initialise this new cell collection
  *
  * @param  \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
  * @param  mixed[]        $arguments    Additional initialisation arguments
  */
 public function __construct(\PHPExcel\Worksheet $parent, $arguments)
 {
     $this->memoryCacheSize = isset($arguments['memoryCacheSize']) ? $arguments['memoryCacheSize'] : '1MB';
     parent::__construct($parent);
     if (is_null($this->fileHandle)) {
         $this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
     }
 }
Example #12
0
function boucleDeclidisp($texte, $args)
{
    global $declidisp;
    $declinaison = lireTag($args, "declinaison", "int");
    $id = lireTag($args, "id", "int");
    $produit = lireTag($args, "produit", "int");
    $classement = lireTag($args, "classement", "string");
    $stockmini = lireTag($args, "stockmini", "int");
    $courante = lireTag($args, "courante", "int");
    $num = lireTag($args, "num", "int");
    $search = "";
    $limit = "";
    $res = "";
    $tdeclidisp = new Declidisp();
    $tdeclidispdesc = new Declidispdesc();
    // preparation de la requete
    if ($declinaison != "") {
        $search .= " and {$tdeclidisp->table}.declinaison=\"{$declinaison}\"";
    }
    if ($id != "") {
        $search .= " and {$tdeclidisp->table}.id=\"{$id}\"";
    }
    if ($classement == "alpha") {
        $order = "order by {$tdeclidispdesc->table}.titre";
    } else {
        if ($classement == "alphainv") {
            $order = "order by {$tdeclidispdesc->table}.titre desc";
        } else {
            if ($classement == "manuel") {
                $order = "order by {$tdeclidispdesc->table}.classement";
            }
        }
    }
    if (ActionsLang::instance()->get_action_si_trad_absente() == ActionsLang::UTILISER_LANGUE_INDIQUEE) {
        // On retourne uniquement les declidisp traduites
        $search .= " and {$tdeclidispdesc->table}.id is not null";
    }
    if ($stockmini != "" && $produit != "") {
        $stock = new Stock();
        $stock_join = "inner join {$stock->table} on {$stock->table}.produit={$produit} and {$stock->table}.declidisp = declidisp.id";
        $search .= " and {$stock->table}.valeur >= {$stockmini}";
    }
    if ($num != "") {
        $limit = " limit {$num}";
    }
    $query = "\n\t\t\tselect {$tdeclidisp->table}.* from {$tdeclidisp->table}\n\t\t\t{$stock_join}\n\t\t\tleft join {$tdeclidispdesc->table} on {$tdeclidispdesc->table}.declidisp = {$tdeclidisp->table}.id and {$tdeclidispdesc->table}.lang = " . ActionsLang::instance()->get_id_langue_courante() . "\n\t\t\twhere 1 {$search}\n\t\t\t{$order}\n\t\t\t{$limit}\n\t\t";
    $resul = CacheBase::getCache()->query($query);
    if (!empty($resul)) {
        $exdecprod = new Exdecprod();
        foreach ($resul as $row) {
            if ($courante == "1" && $row->id . "-" != $declidisp) {
                continue;
            } else {
                if ($courante == "0" && $row->id . "-" == $declidisp) {
                    continue;
                }
            }
            if ($produit != "" && $exdecprod->charger($produit, $row->id)) {
                continue;
            }
            $tdeclidispdesc = new Declidispdesc($row->id);
            $temp = str_replace("#ID", $tdeclidispdesc->declidisp, $texte);
            $temp = str_replace("#DECLINAISON", $row->declinaison, $temp);
            $temp = str_replace("#TITRE", "{$tdeclidispdesc->titre}", $temp);
            $temp = str_replace("#PRODUIT", "{$produit}", $temp);
            $res .= $temp;
        }
    }
    return $res;
}
 function getVars($query)
 {
     $row = CacheBase::getCache()->get($query);
     if ($row == FALSE) {
         if (!($resul = $this->query($query))) {
             CacheBase::getCache()->set($query, "-");
             return 0;
         }
         // Nécessaire pour une mise à jour pour les versions <= 1.5.0
         // Cnx::fetch_object() n'existe pas encore dans Cnx.class.php.
         // Le fichier install/maj.php definit la constante IN_UPDATE_THELIA.
         if (defined('IN_UPDATE_THELIA')) {
             $row = mysql_fetch_object($resul);
         } else {
             $row = $this->fetch_object($resul);
         }
         if ($row === false) {
             $row = "-";
         }
         CacheBase::getCache()->set($query, $row);
     }
     if ($row && $row != "-") {
         foreach ($this->bddvars as $var) {
             $this->{$var} = $row->{$var};
         }
         return 1;
     } else {
         return 0;
     }
     // return $this->num_rows($resul);
 }
 public function lister($type = false, $actifs_seulement = false, $nom_module = '')
 {
     $modules = new Modules();
     $where = '';
     if ($type !== false) {
         $where .= "and type={$type} ";
     }
     if ($actifs_seulement !== false) {
         $where .= "and actif=1 ";
     }
     if ($nom_module !== '') {
         $where .= "and nom='{$nom_module}' ";
     }
     $hash = md5($where);
     if (!isset(self::$list_cache[$hash])) {
         self::$list_cache[$hash] = array();
         $resul = CacheBase::getCache()->query("select * from {$modules->table} where 1 {$where} order by classement", 'Modules');
         if ($resul != "") {
             foreach ($resul as $modules) {
                 try {
                     if (!$actifs_seulement) {
                         if ($this->est_activable($modules)) {
                             $modules->activable = 1;
                         } else {
                             $modules->activable = 0;
                         }
                     }
                     self::$list_cache[$hash][] = $modules;
                 } catch (TheliaException $e) {
                     // Ignorer ce module
                 }
             }
         }
     }
     return self::$list_cache[$hash];
 }
 public function modify($lang, $folder, $online, $title, $chapo, $description, $postscriptum, $urlsuiv, $rewriteurl, $images, $documents, $tab)
 {
     if ($this->id == '') {
         throw new TheliaAdminException("Content not found", TheliaAdminException::CONTENT_NOT_FOUND);
     }
     $contenudesc = new Contenudesc($this->id, $lang);
     if ($contenudesc->id == '') {
         CacheBase::getCache()->reset_cache();
         $contenudesc->contenu = $this->id;
         $contenudesc->lang = $lang;
         $contenudesc->id = $contenudesc->add();
     }
     $this->oldFolder = $this->dossier;
     $this->datemodif = date('Y-m-d H:i:s');
     if ($this->dossier != $folder) {
         $this->checkRewrite($folder);
         $this->checkOrder($folder);
     }
     $this->ligne = $online == 'on' ? 1 : 0;
     $contenudesc->chapo = str_replace("\n", "<br />", $chapo);
     $contenudesc->titre = $title;
     $contenudesc->postscriptum = $postscriptum;
     $contenudesc->description = $description;
     $this->maj();
     $contenudesc->maj();
     $contenudesc->reecrire($rewriteurl);
     $this->setLang($lang);
     $this->updateImage($images);
     $this->getImageFile()->ajouter("photo", array("jpg", "gif", "png", "jpeg"), "uploadimage");
     $this->updateDocuments($documents);
     $this->getDocumentFile()->ajouter("document_", array(), "uploaddocument");
     ActionsModules::instance()->appel_module("modcont", new Contenu($this->id));
     if ($urlsuiv) {
         redirige('listdos.php?parent=' . $this->dossier);
     } else {
         redirige('contenu_modifier.php?id=' . $this->id . '&dossier=' . $this->dossier . '&tab=' . $tab . '&lang=' . $lang);
     }
 }
				</select></li>
	</ul>
	<ul class="ligne_fonce_BlocDescription">
		<li class="designation" style="width:280px;"><?php 
echo trad('Type_transport', 'admin');
?>
</li>
		<li><select name="type_livraison" class="form_client">
					<option value=""><?php 
echo trad('Choisir', 'admin');
?>
... </option>
				<?php 
$modules = new Modules();
$query = "select * from {$modules->table} where type=2 and actif=1";
$resul = CacheBase::getCache()->mysql_query($query, $modules->link);
foreach ($resul as $row) {
    $modulesdesc = new Modulesdesc();
    $modulesdesc->charger($row->nom);
    ?>
						<option value="<?php 
    echo $row->id;
    ?>
"><?php 
    echo $modulesdesc->titre;
    ?>
</option>
						<?php 
}
?>
				</select>
function modifier($id, $lang, $titre, $chapo, $description, $postscriptum, $ligne, $parent, $urlsuiv, $urlreecrite)
{
    $dossier = new Dossier();
    $dossierdesc = new Dossierdesc();
    $dossier->charger($id);
    $res = $dossierdesc->charger($id, $lang);
    if (!$res) {
        CacheBase::getCache()->reset_cache();
        $temp = new Dossierdesc();
        $temp->dossier = $dossier->id;
        $temp->lang = $lang;
        $lastid = $temp->add();
        $dossierdesc = new Dossierdesc();
        $dossierdesc->charger_id($lastid);
    }
    $parent_tmp = $dossier->parent;
    if ($parent != $parent_tmp) {
        $trouve = 0;
        $test = chemin_dos($parent);
        for ($i = 0; $i < count($test); $i++) {
            if ($test[$i]->dossier == $id) {
                $trouve = 1;
                break;
            }
        }
        if (!$trouve) {
            $dossier->parent = $parent;
            $dossier->classement = $dossier->prochain_classement();
        }
    }
    $dossierdesc->titre = $titre;
    $dossierdesc->chapo = $chapo;
    $dossierdesc->description = $description;
    $dossierdesc->postscriptum = $postscriptum;
    if ($ligne != "") {
        $dossier->ligne = 1;
    } else {
        $dossier->ligne = 0;
    }
    $dossier->maj();
    $dossierdesc->maj();
    if ($parent_tmp != $parent) {
        $queryclass = "select * from {$dossier->table} where parent={$parent_tmp} order by classement";
        $resclass = mysql_query($queryclass);
        if (mysql_num_rows($resclass) > 0) {
            $i = 1;
            while ($rowclass = mysql_fetch_object($resclass)) {
                $rub = new Dossier();
                $rub->charger($rowclass->id);
                $rub->classement = $i;
                $rub->maj();
                $i++;
            }
        }
    }
    $dossierdesc->reecrire($urlreecrite);
    ActionsModules::instance()->appel_module("moddos", $dossier);
    if ($urlsuiv) {
        redirige("listdos.php?parent=" . $dossier->parent);
    } else {
        redirige($_SERVER['PHP_SELF'] . "?id=" . $dossier->id . "&lang=" . $lang);
    }
}
Example #18
0
 /**
  * Initialise this new cell collection
  *
  * @param   \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
  * @param   mixed[]        $arguments    Additional initialisation arguments
  * @throws  \PHPExcel\Exception
  */
 public function __construct(\PHPExcel\Worksheet $parent, $arguments)
 {
     $memcacheServer = isset($arguments['memcacheServer']) ? $arguments['memcacheServer'] : 'localhost';
     $memcachePort = isset($arguments['memcachePort']) ? $arguments['memcachePort'] : 11211;
     $cacheTime = isset($arguments['cacheTime']) ? $arguments['cacheTime'] : 600;
     if (is_null($this->cachePrefix)) {
         $baseUnique = $this->getUniqueID();
         $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
         //    Set a new Memcache object and connect to the Memcache server
         $this->memcache = new Memcache();
         if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
             throw new \PHPExcel\Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
         }
         $this->cacheTime = $cacheTime;
         parent::__construct($parent);
     }
 }
 public function modify($lang, $parent, $lien, $online, $title, $chapo, $description, $postscriptum, $urlsuiv, $rewriteurl, $associatedContents, $associatedFeatures, $associatedVariants, $images, $documents, $tab)
 {
     if ($this->id == '') {
         throw new TheliaAdminException("Category not found", TheliaAdminException::CATEGORY_NOT_FOUND);
     }
     $rubriquedesc = new Rubriquedesc($this->id, $lang);
     if ($rubriquedesc->id == '') {
         CacheBase::getCache()->reset_cache();
         $rubriquedesc->rubrique = $this->id;
         $rubriquedesc->lang = $lang;
         $rubriquedesc->id = $rubriquedesc->add();
     }
     $this->oldParent = $this->parent;
     if ($this->parent != $parent) {
         $this->checkOrder($parent);
     }
     $this->parent = $parent;
     $this->lien = $lien;
     $this->ligne = $online == 'on' ? 1 : 0;
     $rubriquedesc->chapo = str_replace("\n", "<br />", $chapo);
     $rubriquedesc->titre = $title;
     $rubriquedesc->postscriptum = $postscriptum;
     $rubriquedesc->description = $description;
     $this->maj();
     $rubriquedesc->maj();
     $rubriquedesc->reecrire($rewriteurl);
     $this->setLang($lang);
     AssociatedContentAdmin::getInstance()->updateAssociatedContents(0, $this->id, $associatedContents);
     AssociatedVariantAdmin::getInstance()->updateAssociatedVariants($this->id, $associatedVariants);
     AssociatedFeatureAdmin::getInstance()->updateAssociatedFeatures($this->id, $associatedFeatures);
     $this->updateImage($images);
     $this->getImageFile()->ajouter("photo", array("jpg", "gif", "png", "jpeg"), "uploadimage");
     $this->updateDocuments($documents);
     $this->getDocumentFile()->ajouter("document_", array(), "uploaddocument");
     ActionsModules::instance()->appel_module("modrub", new Rubrique($this->id));
     if ($urlsuiv) {
         redirige('parcourir.php?parent=' . $this->rubrique);
     } else {
         redirige('rubrique_modifier.php?id=' . $this->id . '&tab=' . $tab . '&lang=' . $lang);
     }
 }
 /**
  * 
  * @param string $title Caracteristique title
  * @param string $display display caracteristique in boucle function
  * @param int $addAuto add automatically this caracteristique to all category
  */
 public function add($title, $display, $addAuto)
 {
     $title = trim($title);
     if (empty($title)) {
         throw new TheliaAdminException("Title caracteristique empty", TheliaAdminException::CARAC_TITLE_EMPTY);
     }
     $this->classement = $this->getMaxRank() + 1;
     $this->affiche = $display != "" ? 1 : 0;
     $this->id = parent::add();
     $caracdesc = new Caracteristiquedesc();
     $caracdesc->caracteristique = $this->id;
     $caracdesc->titre = $title;
     $caracdesc->lang = ActionsAdminLang::instance()->get_id_langue_courante();
     $caracdesc->add();
     if (intval($addAuto) == 1) {
         $query = "SELECT id FROM " . Rubrique::TABLE;
         foreach (CacheBase::getCache()->query($query) as $rub) {
             $rubcaracteristique = new Rubcaracteristique();
             $rubcaracteristique->rubrique = $rub->id;
             $rubcaracteristique->caracteristique = $this->id;
             $rubcaracteristique->add();
         }
     }
     ActionsModules::instance()->appel_module("ajcaracteristique", new Caracteristique($this->id));
     redirige("caracteristique_modifier.php?id=" . $this->id);
 }
function modifier($id, $lang, $ref, $prix, $ecotaxe, $promo, $prix2, $rubrique, $nouveaute, $perso, $poids, $stock, $tva, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite)
{
    $produit = new Produit();
    $produitdesc = new Produitdesc();
    $produit->charger($ref);
    $res = $produitdesc->charger($produit->id, $lang);
    if (!$res) {
        CacheBase::getCache()->reset_cache();
        $temp = new Produitdesc();
        $temp->produit = $produit->id;
        $temp->lang = $lang;
        $lastid = $temp->add();
        $produitdesc = new Produitdesc();
        $produitdesc->charger_id($lastid);
    }
    $prix = str_replace(",", ".", $prix);
    $produit->datemodif = date("Y-m-d H:i:s");
    $produit->prix = $prix;
    $produit->prix2 = $prix2;
    $produit->ecotaxe = $ecotaxe;
    if ($produit->rubrique != $rubrique) {
        $param_old = Produitdesc::calculer_clef_url_reecrite($produit->id, $produit->rubrique);
        $param_new = Produitdesc::calculer_clef_url_reecrite($produit->id, $rubrique);
        $reecriture = new Reecriture();
        $query_reec = "select * from {$reecriture->table} where param='&{$param_old}' and lang={$lang} and actif=1";
        $resul_reec = $reecriture->query($query_reec);
        while ($row_reec = $reecriture->fetch_object($resul_reec)) {
            $tmpreec = new Reecriture();
            $tmpreec->charger_id($row_reec->id);
            $tmpreec->param = "&{$param_new}";
            $tmpreec->maj();
        }
        $produit->rubrique = $rubrique;
        $produit->classement = $produit->prochain_classement();
    }
    if ($promo == "on") {
        $produit->promo = 1;
    } else {
        $produit->promo = 0;
    }
    if ($nouveaute == "on") {
        $produit->nouveaute = 1;
    } else {
        $produit->nouveaute = 0;
    }
    if ($ligne == "on") {
        $produit->ligne = 1;
    } else {
        $produit->ligne = 0;
    }
    $produit->perso = $perso;
    $produit->poids = $poids;
    $produit->stock = $stock;
    $produit->tva = str_replace(",", ".", $tva);
    $produitdesc->chapo = $chapo;
    $produitdesc->description = $description;
    $produitdesc->postscriptum = $postscriptum;
    $produitdesc->titre = $titre;
    $produitdesc->chapo = str_replace("\n", "<br />", $produitdesc->chapo);
    $rubcaracteristique = new Rubcaracteristique();
    $caracteristiquedesc = new Caracteristiquedesc();
    $caracval = new Caracval();
    $query = "select * from {$rubcaracteristique->table} where rubrique='" . $produit->rubrique . "'";
    $resul = mysql_query($query);
    while ($row = mysql_fetch_object($resul)) {
        $caracval = new Caracval();
        $deb = "caract";
        $deb2 = "typecaract";
        $val = $row->caracteristique;
        $var = $deb . $val;
        $var2 = $deb2 . $val;
        global ${$var};
        global ${$var2};
        $query2 = "delete from {$caracval->table} where produit='" . $produit->id . "' and caracteristique='" . $row->caracteristique . "'";
        $resul2 = mysql_query($query2);
        if (${$var2} == "c" && ${$var} != "") {
            foreach (${$var} as $selectval) {
                if ($selectval != "") {
                    $caracval->produit = $produit->id;
                    $caracval->caracteristique = $row->caracteristique;
                    $caracval->caracdisp = $selectval;
                    $caracval->add();
                }
            }
        } else {
            if (${$var} != "") {
                $caracval->produit = $produit->id;
                $caracval->caracteristique = $row->caracteristique;
                $caracval->valeur = ${$var};
                $caracval->add();
            }
        }
    }
    $produit->maj();
    $produitdesc->maj();
    $produitdesc->reecrire($urlreecrite);
    $rubdeclinaison = new Rubdeclinaison();
    $declinaisondesc = new Declinaisondesc();
    $declidisp = new Declidisp();
    $declidispdesc = new Declidispdesc();
    $query = "select * from {$rubdeclinaison->table} where rubrique='" . $rubrique . "'";
    $resul = mysql_query($query);
    $nb = 0;
    while ($row = mysql_fetch_object($resul)) {
        $declinaisondesc->charger($row->declinaison);
        $query2 = "select * from {$declidisp->table} where declinaison='{$row->declinaison}'";
        $resul2 = mysql_query($query2);
        $nbres = mysql_num_rows($resul2);
        while ($row2 = mysql_fetch_object($resul2)) {
            $var = "stock" . $row2->id;
            $var2 = "surplus" . $row2->id;
            global ${$var}, ${$var2};
            $stock = new Stock();
            if ($stock->charger($row2->id, $produit->id) == 0) {
                $stock->declidisp = $row2->id;
                $stock->produit = $produit->id;
                $stock->valeur = ${$var};
                $stock->surplus = ${$var2};
                $stock->add();
                $nb += $stock->valeur;
            } else {
                $stock->valeur = ${$var};
                $stock->surplus = ${$var2};
                $stock->maj();
                $nb += $stock->valeur;
            }
        }
    }
    if ($nb) {
        $produit->stock = $nb;
    }
    $produit->maj();
    ActionsModules::instance()->appel_module("modprod", $produit);
    if ($urlsuiv) {
        ?>
            <script type="text/javascript">
                    window.location="parcourir.php?parent=<?php 
        echo $produit->rubrique;
        ?>
";
            </script>
            <?php 
    } else {
        ?>
            <script type="text/javascript">
                    window.location="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?ref=<?php 
        echo $produit->ref;
        ?>
&rubrique=<?php 
        echo $produit->rubrique;
        ?>
&lang=<?php 
        echo $lang;
        ?>
";
            </script>
            <?php 
    }
}
Example #22
0
File: Cache.php Project: hung5s/yap
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     return CMap::mergeArray(parent::rules(), array(array('name', 'unique')));
 }
Example #23
0
 /**
  * Initialise this new cell collection
  *
  * @param  \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
  * @param  mixed[]        $arguments    Additional initialisation arguments
  */
 public function __construct(\PHPExcel\Worksheet $parent, $arguments)
 {
     $cacheTime = isset($arguments['cacheTime']) ? $arguments['cacheTime'] : 600;
     if (is_null($this->cachePrefix)) {
         $baseUnique = $this->getUniqueID();
         $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
         $this->cacheTime = $cacheTime;
         parent::__construct($parent);
     }
 }
Example #24
0
 /**
  * Initialise this new cell collection
  *
  * @param    \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
  * @param    array of mixed        $arguments    Additional initialisation arguments
  */
 public function __construct(\PHPExcel\Worksheet $parent, $arguments)
 {
     $this->cacheDirectory = isset($arguments['dir']) && $arguments['dir'] !== null ? $arguments['dir'] : \PHPExcel\Shared\File::sysGetTempDir();
     parent::__construct($parent);
     if (is_null($this->fileHandle)) {
         $baseUnique = $this->getUniqueID();
         $this->fileName = $this->cacheDirectory . '/PHPExcel.' . $baseUnique . '.cache';
         $this->fileHandle = fopen($this->fileName, 'a+');
     }
 }
Example #25
0
function arbreOption_dos($depart, $niveau, $pdossier, $dossier, $ok = 1, $lang = false)
{
    $niveau++;
    $tdossier = new Dossier();
    $query = "select * from {$tdossier->table} where parent=\"{$depart}\"";
    $resul = CacheBase::getCache()->query($query);
    for ($i = 0; $i < $niveau; $i++) {
        $espace .= "&nbsp;&nbsp;&nbsp;";
    }
    if ($resul == "" || count($resul) == 0) {
        return "";
    }
    foreach ($resul as $row) {
        $tdossierdesc = new Dossierdesc();
        $tdossierdesc->charger($row->id, $lang);
        if (!$tdossierdesc->affichage_back_office_permis()) {
            continue;
        }
        if ($pdossier == $row->id) {
            $selected = "selected=\"selected\"";
        } else {
            $selected = "";
        }
        if ($ok == 0 || $row->id == $dossier && $ok != -1) {
            $disabled = "disabled=\"disabled\"";
        } else {
            $disabled = "";
        }
        $rec .= "<option value=\"{$row->id}\" {$disabled} {$selected}>" . $espace . $tdossierdesc->titre . "</option>";
        if ($dossier == $row->id && $ok != -1 || $ok == 0) {
            $rec .= arbreOption_dos($row->id, $niveau, $pdossier, $dossier, 0, $lang);
        } else {
            $rec .= arbreOption_dos($row->id, $niveau, $pdossier, $dossier, $ok, $lang);
        }
    }
    return $rec;
}
 public function executeCountQuery($query, $alias = 'nb', $default = 0)
 {
     $num = CacheBase::getCache()->get($query);
     if ($num < 0 || $num == "") {
         try {
             $resul = $this->query($query, true);
             $num = $this->get_result($resul, 0, $alias);
         } catch (Exception $e) {
             Tlog::error("error for this query : " . $query);
             Tlog::error($e->getMessage());
             return $default;
         }
         CacheBase::getCache()->set($query, $num);
     }
     return $num;
 }
Example #27
0
 /**
  * Get a list of all cell addresses currently held in cache
  *
  * @return  string[]
  */
 public function getCellList()
 {
     if ($this->currentObjectID !== null) {
         $this->storeData();
     }
     return parent::getCellList();
 }
Example #28
0
 /**
  * Initialise this new cell collection
  *
  * @param    \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
  * @throws  \PHPExcel\Exception
  */
 public function __construct(\PHPExcel\Worksheet $parent)
 {
     parent::__construct($parent);
     if (is_null($this->DBHandle)) {
         $this->TableName = str_replace('.', '_', $this->getUniqueID());
         $_DBName = ':memory:';
         $this->DBHandle = new SQLiteDatabase($_DBName);
         if ($this->DBHandle === false) {
             throw new \PHPExcel\Exception(sqlite_error_string($this->DBHandle->lastError()));
         }
         if (!$this->DBHandle->queryExec('CREATE TABLE kvp_' . $this->TableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
             throw new \PHPExcel\Exception(sqlite_error_string($this->DBHandle->lastError()));
         }
     }
 }
 function maj()
 {
     $listv = "";
     $varid = $this->bddvars[0];
     foreach ($this->bddvars as $var) {
         $val = $this->{$var};
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         $val = $this->escape_string($val, $this->link);
         $listv .= '`' . $var . "`=\"" . $val . "\",";
     }
     $query = "update `{$this->table}` set " . rtrim($listv, ',') . " where `{$varid}`=\"" . $this->{$varid} . "\"";
     if ($this->{$varid} != "") {
         $resul = $this->query($query);
         CacheBase::getCache()->reset_cache();
     }
     return $query;
 }
 /**
  * @method void Mise a jour des modules en BD en fonction du contenu du repertoire des modules
  */
 public function mettre_a_jour()
 {
     if ($dh = opendir($this->plugins_base_dir)) {
         while ($file = readdir($dh)) {
             if ($file == '.' || $file == '..') {
                 continue;
             }
             try {
                 // Tenter d'instancier le plugin
                 $instance = $this->instancier($file);
                 $modules = new Modules();
                 if ($instance instanceof PluginsPaiements) {
                     $modules->type = Modules::PAIEMENT;
                 } else {
                     if ($instance instanceof PluginsTransports) {
                         $modules->type = Modules::TRANSPORT;
                     } else {
                         if ($instance instanceof FiltreBase) {
                             $modules->type = Modules::FILTRE;
                         } else {
                             if ($instance instanceof PluginsClassiques) {
                                 $modules->type = Modules::CLASSIQUE;
                             } else {
                                 continue;
                             }
                         }
                     }
                 }
                 // On ignore
                 // Vérifier si le module existe en BD, et l'ajouter s'il n'y est pas
                 if (!$modules->charger($file)) {
                     $modules->nom = $file;
                     $modules->actif = 0;
                     $modules->add();
                     // On en profite pour le convertir en UTF-8 au passage si nécessaire.
                     $this->conversion_utf8($this->lire_chemin_module($modules->nom));
                 }
             } catch (Exception $ex) {
                 // On ne peut pas instancier -> ignorer
             }
         }
         @closedir($dh);
     }
     // Vérifier que les plugins en base existent toujours sur disque
     $modules = new Modules();
     $result = $modules->query('select nom from ' . Modules::TABLE);
     while ($result && ($row = $modules->fetch_object($result))) {
         try {
             $this->lire_chemin_module($row->nom);
         } catch (Exception $ex) {
             // Le plugin n'existe plus sur disque -> le retirer de la BD
             if ($modules->charger($row->nom)) {
                 $modules->delete();
                 // Supprimer aussi la description
                 $modules->query("delete from " . Modulesdesc::TABLE . " where plugin='{$modules->nom}'");
             }
         }
     }
     CacheBase::getCache()->reset_cache();
 }