Source for file t_design.class.php
Documentation is available at t_design.class.php
*@=@=@=@ START LICENSE @=@=@=@*
Copyright or © or Copr. Stéphane TRICHET and Nicolas SOTRON
stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
This software is a computer program whose purpose is to make a
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
*@=@=@=@ END LICENSE @=@=@=@*
* @version $Id: t_design.class.php 724 2007-11-23 12:12:07Z stephanet $
* Include 'internal_components/common/cache_class/object_cached.class.php'
require_once('internal_components/common/cache_class/object_cached.class.php');
* Manage the designs for a container or a page
* (a design is a php and a template to print a page)
* @todo supprimer les tcontent invalidpagedesid, invalidpagedesid, invalidpagetitle, sqlinsert
* @version $Id: t_design.class.php 724 2007-11-23 12:12:07Z stephanet $
* Database Connexion object
* SQL Request : Get by page id
* SQL Request : get default detail design
* SQL Request : get default link design
var $req_get_default_link_design =
"SELECT MIN(des_id),des_level FROM t_design WHERE des_type='LINK' AND des_page_id = %d GROUP BY des_level;";
* SQL Request : Get design list
var $req_get_design_list =
"SELECT des_id, des_page_id, des_title, des_level FROM t_design WHERE des_type='%s' @des_page_id@ ORDER BY des_level, des_id;";
* SQL Request : Get design list by array
SELECT des_id, des_entry, des_entry_parameter, des_entry_exec, des_template
* SQL Request : get design by template name
* SQL Request : get design by page id type
* SQL Request : Select by primary key
des_entry, des_template, des_level
* SQL Request : Select all
des_entry, des_template, des_level, des_id
* SQL Request : Select product design
var $req_select_product_design =
"SELECT des_id, des_entry, des_template FROM t_design WHERE des_type='PRODUCT' AND des_page_id IN %s;";
var $req_insert =
"INSERT INTO t_design(des_type, des_page_id, des_title, des_entry, des_template, des_level) VALUES ('%s', %d, '%s', @des_entry@, '%s', @des_level@);";
* SQL Request : Delete design list
* SQL Request : Valid link design sub links
* SQL Request : valid link design
* Constructor, init the requests and objects
$tihs->m_page_id["TRASH"] =
70;
$this->m_type["DETAIL"]=
"DETAIL";
$this->m_type["CONTAINER"]=
"CONTAINER";
$this->m_type["SPECIAL_LINK"]=
"SPE_LINK";
$this->m_type["SPECIAL_DETAIL"]=
"SPE_DETAIL";
$this->m_type["PRODUCT"]=
"PRODUCT";
$this->m_entry_exec["ALWAYS_BEFORE_SESSION_DESTROY"] =
"ALWAYS_BEFORE";
* Parameter Integrity checker
* @return bool TRUE if not valid
* Parameter Integrity checker
* @return bool TRUE if not valid
* Parameter Integrity checker
* @return bool TRUE if not valid
* Parameter Integrity checker
* @return bool TRUE if not valid
* Parameter Integrity checker
* @return bool TRUE if not valid
* Parameter Integrity checker
* @return bool TRUE if not valid
* Parameter Integrity checker
* @return bool TRUE if not valid
if (0<
count($p_design)) {
* Get all the entry to exec
* Renvoit la liste des types du champs des_entry_exe
* Get the designs in an array
* Renvoit les designs contenus dans un tableau et un tableau contenant les templates ayant du t_content et un tableau contenant cette liste indexée par le nom du tpl
* @param array $p_design_list_array
* @return bool TRUE on error
$r_result =
$name_indexed_list =
array();
if (0<
count($p_design_list_array)) {
$r_result[$row[0]]['des_entry'] =
$row[1];
$r_result[$row[0]]['des_entry_parameter'] =
$row[2];
$r_result[$row[0]]['des_entry_exec'] =
$this->m_r_entry_exec[$row[3]];
$r_result[$row[0]]['des_template'] =
$row[4];
$name_indexed_list[$row[4]] =
array("des_id"=>
$row[0], "des_entry"=>
$row[1], "startup_loaded"=>
TRUE);
//print_r_net($name_indexed_list);
* @param integer $p_design_template_name
* @return bool TRUE on error
$parameters =
array($p_design_template_name);
$r_result =
array("des_id"=>
$row[0], "des_entry"=>
$row[1], "startup_loaded"=>
FALSE);
* Get the template to use to print products
* Renvoit le fichier template a utiliser pour afficher la fiche produit
* @param integer $p_page_id
* @return bool TRUE on error
$parameters =
array("(0, ".
$p_page_id.
")");
array_push($list, array("des_id"=>
$row[0], "des_entry"=>
$row[1], "des_template"=>
$row[2]) );
// Il y a forcement le résultat par défaut. Si plus on prend celui associé a la page
$r_result =
1<
count($list)?
$list[1]:
$list[0];
* Test if a deesign can be used into a container
* Indique si une apparence peut être utilisé au niveau du conteneur réclamé
* @param integer $p_des_id
* @param integer $p_page_des_id
* @param integer $p_level
* @return bool TRUE on error
if ($this->isNotValidDesID($p_des_id))
$parameters =
$result =
array();
$max_des_level =
$tem_row[0];
$parameters =
$result =
array();
* Get the list of designs of type $p_page_type linked to the page
* Renvoit la liste de design de type $p_page_type associée a la page
* @param string $p_page_type
* @param integer $p_page_id
* @return bool TRUE on error
* Get design list by type and page list
* @param string $p_page_type
* @param array $p_liste_page_id
* @return bool TRUE on error
for($i=
0; $i<
count($p_liste_page_id); $i++
) {
if (0 !=
$p_liste_page_id[$i])
if (0>=
count($list_page_id)) {
$request =
str_replace('@des_page_id@', "AND des_page_id IN %s", $request);
$r_result[$r_result_count]['des_id'] =
$row[0];
$r_result[$r_result_count]['des_page_id'] =
$row[1];
$r_result[$r_result_count]['des_title'] =
$row[2];
$r_result[$r_result_count]['des_level'] =
$row[3];
* @param integer $p_design_id
* @return bool TRUE on error
function getDesign($p_design_id, &$r_result) {
if ($this->xIsRemembered("d_".
$p_design_id, $r_remembered_object)) {
$r_result =
$r_remembered_object;
$parameters =
array($p_design_id);
//$this->m_object_dbconnexion->debug_is_on = true;
//$this->m_object_dbconnexion->debug_is_on = false;
$r_result['des_id'] =
$p_design_id;
$r_result['des_type'] =
$this->m_r_type[$row[0]];
$r_result['des_page_id'] =
$row[1];
$r_result['des_title'] =
$row[2];
$r_result['des_entry'] =
$row[3];
$r_result['des_template'] =
$row[4];
$r_result['des_level'] =
$row[5];
$this->xRemember("d_".
$p_design_id, $r_result);
* @param array $r_result_all
* @return bool TRUE on error
$r_result['des_id'] =
$row[6];
$r_result['des_type'] =
$this->m_r_type[$row[0]];
$r_result['des_page_id'] =
$row[1];
$r_result['des_title'] =
$row[2];
$r_result['des_entry'] =
$row[3];
$r_result['des_template'] =
$row[4];
$r_result['des_level'] =
$row[5];
* @param string $p_des_type 'CONTAINER', 'LINK', 'DETAIL', 'SPE_LINK', 'SPE_DETAIL', 'PRODUCT'
* @param integer $p_des_page_id
* @param string $p_page_type
* @param string $p_des_title
* @param string $p_des_entry
* @param string $p_des_template
* @param integer $p_des_level
* @return bool TRUE on error
function insert($p_des_type, $p_des_page_id, $p_page_type, $p_des_title, $p_des_entry, $p_des_template, $p_des_level, &$r_result) {
$g_object_message =
& $g_object_loader->getMessage();
if (null !=
$p_des_level) {
//Vérification - Pour faire plus beau, il faudrait recharger les informations à partir du des_page_ids
case "DETAIL" :
$p_des_page_id =
0;
if ($g_object_message->thereIsAnError()) {
if (null ==
$p_des_entry) {
$request =
str_replace("@des_entry@", " null ", $request);
$request =
str_replace("@des_entry@", " '%s' ", $request);
if (null ==
$p_des_level) {
$request =
str_replace("@des_level@", " null ", $request);
$request =
str_replace("@des_level@", " %d ", $request);
* Get link design id for insertion
* @param integer $p_page_id
* @return bool TRUE on error
if ($this->m_page_id["TRASH"] !=
$p_page_id) { //Si ce n'est pas la page poubelle
$parameters =
$result =
array();
$r_result[$ind] =
$row[0];
* Get Detail design id for insertion
* @return bool TRUE on error
$parameters =
$result =
array();
* Delete all the designs by type associated to a page id.
* Return into $r_result the list of files to delete
* Supprime toutes les apparences d'un certain type associées à un id de page. Va renvoyer la liste des fichiers supprimables
* @param string $p_des_type
* @param integer $p_page_id
* @return bool TRUE on error
function delete($p_des_type, $p_page_id, &$r_result){
$r_result["entry"] =
$r_result["template"] =
array();
$parameters =
$result =
array();
$design_list =
$entry_file =
$template_file =
array();
if ((null !=
$row[1]) &&
(0<
strlen($row[1])))
if ((null !=
$row[2]) &&
(0<
strlen($row[2])))
//Suppression des apparences
if (0<
count($design_list)) {
$parameters =
$result =
array();
//Création de la liste des fichiers entréer a supprimer - ON NE PEUT PAS ETRE SUR CAR LES FICHIERS ENTREE SONT PARTAGES AVEC TOUS LES CLIENTS
$r_result["entry"] =
$entry_file;
//Création de la liste des fichiers template a supprimer
for ($i=
0; $i<
count($template_file); $i++
) {
array_push($r_result["template"], $template_file[$i]);
* @param array $r_resut_final
* @return bool TRUE on error
function _check(&$r_resut_final) {
$function_name =
"_check";
$r_result_get_all =
array();
global $g_object_siteinformation;
$r_resut_final =
array();
// des_id,des_type,des_page_id,des_title,des_entry,des_template,des_level
foreach ($r_result_get_all as $value) {
// test si ce design sert pour une page
// soit des_id = page_link_des_id ou page_detail_des_id
// soit des_id = page_des_id
$request =
"SELECT count(*) FROM t_page WHERE page_link_des_id=".
$value['des_id'].
";";
$parameters =
$result =
array();
//$result = mysql_query($request);
$find_utility .=
"|page_link_des_id";
$request =
"SELECT count(*) FROM t_page WHERE page_detail_des_id=%d;";
$parameters =
$result =
array();
$parameters[] =
$value['des_id'];
//$result = mysql_query($request);
//Une page de détail, ou de produit peut exister mais être associé a personne
if (($r_result >
0) ||
((0 ==
$value['des_type']) &&
(("DETAIL" ==
$value['des_type']) ||
("SPE_DETAIL" ==
$value['des_type']) ||
("PRODUCT" ==
$value['des_type']))))
$find_utility .=
"|page_detail_des_id";
$request =
"SELECT count(*) FROM t_page WHERE page_id=%d;";
$parameters =
$result =
array();
$parameters[] =
$value['des_page_id'];
//$result = mysql_query($request);
$find_utility .=
"|des_page_id";
// si on a pas trouvé d'utilité au design, on le signale
if ($find_utility ==
"") {
$to_write =
$value['des_id'].
"|".
$value['des_type'].
"|".
$value['des_page_id'].
"|".
$value['des_title'].
"|".
$value['des_entry'].
"|".
$value['des_template'].
"|".
$value['des_level'];
$to_write .=
"<br/> delete from t_design where des_type='".
$value['des_type'].
"' and des_page_id ='".
$value['des_page_id'].
"' and des_title='".
$value['des_title'].
"' and des_template='".
$value['des_template'].
"';";
'col1' =>
'AUCUNE PAGE LIEE'
// si il sert, on test que les fichiers utiles soient bien en action
$to_write =
$value['des_id'].
"|".
$value['des_type'].
"|".
$value['des_page_id'].
"|".
$value['des_title'].
"|".
$value['des_entry'].
"|".
$value['des_template'].
"|".
$value['des_level'];
$to_write .=
"<br/> delete from t_design where des_type='".
$value['des_type'].
"' and des_page_id ='".
$value['des_page_id'].
"' and des_title='".
$value['des_title'].
"' and des_template='".
$value['des_template'].
"';";
'col1' =>
'des_entry INEXISTANT'
$to_write =
$value['des_id'].
"|".
$value['des_type'].
"|".
$value['des_page_id'].
"|".
$value['des_title'].
"|".
$value['des_entry'].
"|".
$value['des_template'].
"|".
$value['des_level'];
$to_write .=
"<br/> delete from t_design where des_type='".
$value['des_type'].
"' and des_page_id ='".
$value['des_page_id'].
"' and des_title='".
$value['des_title'].
"' and des_template='".
$value['des_template'].
"';";
'col1' =>
'des_template INEXISTANT'
$to_write =
sizeof($r_result_get_all);
'col1' =>
'NB lignes lues'
$r_result =
$r_resut_final;
Documentation generated on Tue, 25 Mar 2008 15:36:22 +0100 by phpDocumentor 1.3.2