|
From: <os...@us...> - 2014-03-04 16:57:40
|
Revision: 5183
http://sourceforge.net/p/oscss/svn/5183
Author: oscim
Date: 2014-03-04 16:57:37 +0000 (Tue, 04 Mar 2014)
Log Message:
-----------
Fix
clean code
Modified Paths:
--------------
trunk/catalog/admin/includes/classes/drivers/sqlnewsletters_modeles.php
trunk/catalog/admin/includes/languages/fr_FR/Adminuser.txt
trunk/catalog/admin/includes/modules/pages/newslettersModeles.php
trunk/catalog/checkout_shipping_address.php
Modified: trunk/catalog/admin/includes/classes/drivers/sqlnewsletters_modeles.php
===================================================================
--- trunk/catalog/admin/includes/classes/drivers/sqlnewsletters_modeles.php 2014-02-28 15:55:20 UTC (rev 5182)
+++ trunk/catalog/admin/includes/classes/drivers/sqlnewsletters_modeles.php 2014-03-04 16:57:37 UTC (rev 5183)
@@ -12,31 +12,25 @@
@brief manage db update/insert/delete for navigation_links
*/
+error_reporting(E_ALL);
+require_once( DIR_FS_ADMIN . DIR_WS_CLASSES . 'SqlFilesDataDriverClass.php');
-
-
class sqlnewsletters_modeles
- implements ModSqlDataDriver{
+ extends SqlFilesDataDriverClass
+ implements ModSqlDataDriver
+ {
- public static $modules;
+ /**
+ @var boolean use submodule in this class
+ */
+ public $use_modules = false;
- protected static $_instance;
- protected function __construct(){
- }
-
-
- public static function getInstance() {
- if(self::$_instance == null) self::$_instance = new self();
- return self::$_instance;
- }
-
-
/**
@brief create new ligne in table configuration
*/
public static function create($option){
- self::getInstance();
+ new self();
$DB=Database::getInstance();
$error = 0 ;
$sql_data_array = array();
@@ -73,37 +67,63 @@
@brief update ligne in table configuration
*/
public static function update($option){
- self::getInstance();
+ new self();
+ $DB=Database::getInstance();
+ $error=0;
+ $specimen = self::Specimen();
if(!isset($option['id']))
- return 'id';
+ return false;
- $DB=Database::getInstance();
- $error = 0 ;
+
$where ='';
-
if(isset($option['id'])) $where .="AND nmodele_id = '".(int)$option['id']."' ";
if(isset($option['languages_id'])) $where .="AND languages_id = '".(int)$option['languages_id']."' ";
if(isset($option['status'])) $where .="AND status = '".(int)$option['status']."' ";
- if(isset($option['post']))
- $post = $option['post'];
+ $post =array();
+ if(isset($option['post'])){
+ $post=(array)$option['post'];
+ }
- $DB->beginTransaction();
+
+ $dataarray = (array)(isset($option['sqlarray'])? $option['sqlarray'] : array() );
- if(isset($post['status']))$sql_data_array['status'] = tep_db_prepare_input($post['status']);
- if(isset($post['title']))$sql_data_array['title'] = tep_db_prepare_input($post['title']);
- if(isset($post['content']))$sql_data_array['nmodele_content'] = tep_db_prepare_input($post['content']);
+ self::PrepaDataAfterUse( $specimen , $dataarray, $post );
- if(count((array)$sql_data_array)<= 0)
- return false;
+ $sql_data_array_prem = self::GetSqlArray();
+ $sql_data_array_lg = self::GetSqlArrayLg();
+
+// print_r($sql_data_array);
+// print_r($sql_data_array_lg);
+// exit;
+ $DB->beginTransaction();
- $sql_data_array['last_update'] = 'NOW()';
+
+ if(isset($sql_data_array_lg['lg']) && count($sql_data_array_lg['lg']) > 0){
+ foreach($sql_data_array_lg['lg'] as $key=>$sql_data_array){
+ $sql_data_array['last_update'] = 'NOW()';
+
+ if($sql_data_array_prem['status'])
+ $sql_data_array['status'] = $sql_data_array_prem['status'];
- if( !tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array, 'update' , substr($where,3) ) )
+ if( !tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array, 'update' , substr($where,3) ) )
$error++;
+ }
+ }
+// if(isset($post['status']))$sql_data_array['status'] = tep_db_prepare_input($post['status']);
+// if(isset($post['title']))$sql_data_array['title'] = tep_db_prepare_input($post['title']);
+// if(isset($post['content']))$sql_data_array['nmodele_content'] = tep_db_prepare_input($post['content']);
+// if(count((array)$sql_data_array)<= 0)
+// return false;
+//
+// $sql_data_array['last_update'] = 'NOW()';
+//
+// if( !tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array, 'update' , substr($where,3) ) )
+// $error++;
+
if( $error > 0){
$DB->rollbackTransaction();
return false;
@@ -136,7 +156,7 @@
*/
public static function fetch($option,$shortkey=false){
- self::getInstance();
+ new self();
$DB=Database::getInstance();
$where ="";
@@ -145,42 +165,53 @@
if(isset($option['status'])) $where .="AND status = '".(int)$option['status']."' ";
- if($where=='')
- return false;
-
-
$sql="SELECT * FROM " . TABLE_NEWSLETTERS_MODELES . " a ".
- " WHERE ".substr($where,3);
+ " WHERE 1 ".$where;
- $res=$DB->query($sql);
-
+ $res = $DB->query($sql);
$num = $res->__get('numRows');
- if($num == 1){
- $result=$res->fetchAssoc();
+ if($num == 1)
+ $cInfo_array[] = $res->fetchAssoc();
+ else
+ foreach($res->fetchAllAssoc() as $row)
+ $cInfo_array[] = $row;
+ foreach($cInfo_array as $row) {
+ $row['lg'] = array();
+
+ $catlg = array(
+ 'title'=>$row['title'],
+ 'nmodele_content'=>$row['nmodele_content']
+ );
+ $row['lg'][ $row['languages_id'] ] =((!$shortkey)? $catlg : self::CleanKey($catlg)) ;
+
+
+ $result[] = $row;
+ }
+
- return ((!$shortkey)? $result : self::CleanKey($result));
+ if($num == 1){
+ return ((!$shortkey)? $result[0] : self::CleanKey($result[0])) ;
}
elseif($num > 1){
$array=array();
- foreach($res->fetchAllAssoc() as $result)
- $array[]= ((!$shortkey)? $result : self::CleanKey($result));
+ foreach($result as $lg)
+ $array[]= ((!$shortkey)? $lg : self::CleanKey($lg));
return $array;
}
-
- return false;
+ return false;
}
/**
@brief delete row
*/
public static function delete($option){
- self::getInstance();
+ new self();
$DB=Database::getInstance();
$where ="";
@@ -208,27 +239,55 @@
@return array product empty
*/
public static function Specimen($shortkey=false){
+
+ new self();
+
+ $ListLanguages=tep_get_languages();
+
+ $tmp_lg = array();
+ for ($i=0, $n=sizeof($ListLanguages); $i<$n; $i++) {
+ $tmp = array(
+ 'nmodele_content' => '', // depend language table
+ 'title' => '', // depend language table
+ 'language_id' => $ListLanguages[$i]['id'],
+ );
+
+ $tmp_lg[$ListLanguages[$i]['id']] = ((!$shortkey)? $tmp : self::CleanKey($tmp));
+ }
+
+
$par = array(
- 'nmodele_id' => '',
- 'languages_id' => 1,
- 'status' => 0,
- 'date_added' => '',
- 'last_update' => '',
- 'title' => '',
- 'nmodele_content' => '',
+ 'nmodele_id' => '',
+ 'languages_id' => 1,
+ 'status' => 0,
+ 'date_added' => '',
+ 'last_update' => '',
+
+ // language table
+ 'lg' =>$tmp_lg,
);
return ((!$shortkey)? $par : self::CleanKey($par));
}
+
+ /**
+ @fn ExtractForm($data)
+ @brief extract data forms for put in db
+ @param $data array
+ @return array
+ */
+ public static function ExtractForm($data){
+
+ return self::ExtractDataForm(self::Specimen(), $data);
+ }
-
/**
@fn CleanKey()
@brief Clean string name key
*/
public static function CleanKey($array){
- self::getInstance();
+ new self();
$object= new stdclass();
foreach($array as $key=>$value){
Modified: trunk/catalog/admin/includes/languages/fr_FR/Adminuser.txt
===================================================================
--- trunk/catalog/admin/includes/languages/fr_FR/Adminuser.txt 2014-02-28 15:55:20 UTC (rev 5182)
+++ trunk/catalog/admin/includes/languages/fr_FR/Adminuser.txt 2014-03-04 16:57:37 UTC (rev 5183)
@@ -16,8 +16,8 @@
/* entry */
$lang['@adminUsers table heading id']="Id" ;
- $lang['@adminUsers table heading lastname']="Prénom" ;
- $lang['@adminUsers table heading firstname']="Nom" ;
+ $lang['@adminUsers table heading lastname']="Nom" ;
+ $lang['@adminUsers table heading firstname']="Prénom" ;
$lang['@adminUsers table heading email']="Email" ;
$lang['@adminUsers table heading groups name']="Groupe" ;
$lang['@adminUsers table heading lognum']="Accès" ;
Modified: trunk/catalog/admin/includes/modules/pages/newslettersModeles.php
===================================================================
--- trunk/catalog/admin/includes/modules/pages/newslettersModeles.php 2014-02-28 15:55:20 UTC (rev 5182)
+++ trunk/catalog/admin/includes/modules/pages/newslettersModeles.php 2014-03-04 16:57:37 UTC (rev 5183)
@@ -12,15 +12,24 @@
require_once(DIR_FS_ADMIN . DIR_WS_CLASSES .'ModTreePage.php');
+require_once(DIR_FS_ADMIN . DIR_WS_CLASSES .'listeners/EventMessListener.php');
/**
@class newslettersModeles
*/
class newslettersModeles
extends ModTreePage /// new abstract class for nextgen module
implements
- ExtModPage,
- InterfacedTJsonS,
- InterfaceModule {
+ InterfaceModule
+ ,ExtModConfig
+ ,InterfacedTJsonS
+ ,InterfacedInnerHtml
+
+ // Events Interface for display and exec all notification
+ , EventMessInterface
+
+ // Event propagation Action
+// , EventTriggersCacheInterface
+ {
const FILENAME ='newslettersModeles.php';
@@ -63,9 +72,14 @@
self::$modules=new AcaFactory(__CLASS__);
// Event
EventsHandlerActive::ActiveForClass(__CLASS__);
- //
- MGabCont::SetCurrentName(__CLASS__);
-
+ // instancie MLinkTo
+ MLinkTo::getInstance(self::$datatype);
+ // Set Name in MAster Gab
+ MGabCont::SetCurrentName(__CLASS__);
+ //
+ self::$languages = tep_get_languages();
+
+
/**
@remarks not load if not first init
*/
@@ -80,7 +94,6 @@
foreach(tep_get_languages() as $row)
$list_lg[] = array('id'=>$row['id'], 'text'=>$row['name']);
- MGabCont::SetCurrentName(__CLASS__);
/**
@remarks define var execution sql in GetDBValue()
@@ -109,21 +122,21 @@
'class'=>'tcenter',
'default'=>true,
);
- self::$allfields['nm.languages_id'] = array(
- 'sort'=>true,
- 'search'=>true,
- 'alias'=>'languages_id',
- 'text'=>__('newslettersmodeles table heading languages id'),
- 'width'=>'2%',
- 'class'=>'tcenter',
- 'default'=>true,
- 'edit'=>array(
- 'input_type'=>'select',
- 'input_size'=>'1',
- 'input_name'=>'languages_id',
- 'select_values'=>$list_lg,
- ),
- );
+// self::$allfields['nm.languages_id'] = array(
+// 'sort'=>true,
+// 'search'=>true,
+// 'alias'=>'languages_id',
+// 'text'=>__('newslettersmodeles table heading languages id'),
+// 'width'=>'2%',
+// 'class'=>'tcenter',
+// 'default'=>true,
+// 'edit'=>array(
+// 'input_type'=>'select',
+// 'input_size'=>'1',
+// 'input_name'=>'languages_id',
+// 'select_values'=>$list_lg,
+// ),
+// );
self::$allfields['nm.status'] = array(
'sort'=>true,
'search'=>true,
@@ -132,6 +145,17 @@
'width'=>'2%',
'class'=>'tcenter',
'default'=>true,
+ 'edit'=>array(
+ 'input_type'=>'radio',
+ 'input_size'=>'1',
+ 'input_name'=>'status',
+ 'values_list'=>array(
+ array('id'=>0, 'text'=>__('@products text status off') ),
+ array('id'=>1, 'text'=>__('@products text status on') ),
+ ),
+ 'position_col'=>'right',
+ 'position_grp'=>5
+ ),
);
self::$allfields['nm.title'] = array(
'sort'=>true,
@@ -142,10 +166,10 @@
'class'=>'tcenter',
'default'=>true,
'edit'=>array(
- 'input_name'=>'title',
+ 'input_name'=>'lg[title]',
'input_size'=>'64',
'required_status'=>true,
-// 'active_value_language'=>true,
+ 'active_value_language'=>true,
),
);
self::$allfields['nm.nmodele_content'] = array(
@@ -158,10 +182,10 @@
'default'=>true,
'edit'=>array(
'input_type'=>'textarea@advanced',
- 'input_name'=>'content',
- 'input_size'=>'1',
+ 'input_name'=>'lg[nmodele_content]',
+ 'input_size'=>'64',
'required_status'=>true,
-// 'active_value_language'=>true,
+ 'active_value_language'=>true,
),
);
self::$allfields['nm.date_added'] = array(
@@ -182,6 +206,18 @@
'class'=>'tcenter',
'default'=>true,
);
+
+// if( self::$action == 'edit' ){
+// self::$allfields['nm.last_update'] = array(
+// 'sort'=>true,
+// 'search'=>true,
+// 'alias'=>'modified',
+// 'text'=>__('newslettersmodeles table heading last update'),
+// 'width'=>'5%',
+// 'class'=>'tcenter',
+// 'default'=>true,
+// );
+// }
/// @remarks min fields and not view directly colonne fields
@@ -270,45 +306,45 @@
/**
@remarks Normal page
*/
- case 'insert':
- case 'update':
- $newsletter_id = self::$Id;
+// case 'insert':
+// case 'update':
+// $newsletter_id = self::$Id;
+//
+// $newsletter_module = tep_db_prepare_input($_POST['module']);
+// $title = tep_db_prepare_input($_POST['title']);
+// $content = tep_db_prepare_input($_POST['content']);
+//
+// $newsletter_error = false;
+//
+// if ($newsletter_error == false) {
+// $sql_data_array = array('languages_id' => 1,
+// 'nmodele_content' => $content,
+// 'title' => $title,
+// );
+//
+// if (self::$action == 'insert') {
+// $sql_data_array['date_added'] = 'now()';
+// $sql_data_array['status'] = '0';
+// // $sql_data_array['locked'] = '0';
+//
+// $res=tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array);
+// $newsletter_id = $res->__get('insertId');
+// }
+// elseif (self::$action == 'update') {
+// $sql_data_array['last_update'] = 'now()';
+// tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array, 'update', "nmodele_id = '" . (int)$newsletter_id . "'");
+// }
+//
+// tep_redirect(tep_href_link(self::FILENAME, 'cID=' . $newsletter_id));
+// } else {
+// //! init wisywyg
+// $oscss->_add_ext(BO_WISIWYG_SELECTED,'editeur/');
+// echo $oscss->_call(BO_WISIWYG_SELECTED,'_top','content','600','400');
+// }
+// break;
+//
- $newsletter_module = tep_db_prepare_input($_POST['module']);
- $title = tep_db_prepare_input($_POST['title']);
- $content = tep_db_prepare_input($_POST['content']);
- $newsletter_error = false;
-
- if ($newsletter_error == false) {
- $sql_data_array = array('languages_id' => 1,
- 'nmodele_content' => $content,
- 'title' => $title,
- );
-
- if (self::$action == 'insert') {
- $sql_data_array['date_added'] = 'now()';
- $sql_data_array['status'] = '0';
- // $sql_data_array['locked'] = '0';
-
- $res=tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array);
- $newsletter_id = $res->__get('insertId');
- }
- elseif (self::$action == 'update') {
- $sql_data_array['last_update'] = 'now()';
- tep_db_perform(TABLE_NEWSLETTERS_MODELES, $sql_data_array, 'update', "nmodele_id = '" . (int)$newsletter_id . "'");
- }
-
- tep_redirect(tep_href_link(self::FILENAME, 'cID=' . $newsletter_id));
- } else {
- //! init wisywyg
- $oscss->_add_ext(BO_WISIWYG_SELECTED,'editeur/');
- echo $oscss->_call(BO_WISIWYG_SELECTED,'_top','content','600','400');
- }
- break;
-
-
-
default:
parent::GenericAction();
@@ -418,6 +454,7 @@
@remarks Normal View Page
*/
case 'preview':
+ $MG = false;
self::$Info=self::GetDBValue(self::$Id);
break;
default:
@@ -425,7 +462,7 @@
}
if( ! empty($action) )
- return MGabCont::CallGab($action,__FUNCTION__, (($MG)?self::MASTER : __CLASS__) );
+ return MGabCont::CallGab($action,__FUNCTION__, (($MG)? self::MASTER : __CLASS__) );
}
Modified: trunk/catalog/checkout_shipping_address.php
===================================================================
--- trunk/catalog/checkout_shipping_address.php 2014-02-28 15:55:20 UTC (rev 5182)
+++ trunk/catalog/checkout_shipping_address.php 2014-03-04 16:57:37 UTC (rev 5183)
@@ -1,14 +1,15 @@
<?php
/**
- @licence GPL 2005-2013 The osCSS developers - osCSS Open Source E-commerce
+ @licence GPL 2005-2014 The osCSS developers - osCSS Open Source E-commerce
@portion code Copyright (c) 2002 osCommerce
@package osCSS-2 <www http://www.oscss.org>
- @version 2.1.2
+ @version 2.2.0
@date 09/12/2013, 22:44
@author oscim <mail aur...@os...> <www http://www.oscim.fr>
@encode UTF-8
- *\file
- *\brief page display shipping choose and/or add address
+ @file checkout_shipping_address.php
+ @dir /
+ @brief page display shipping choose and/or add address
*/
require('includes/application_top.php');
@@ -46,26 +47,32 @@
// process a new shipping address
if (tep_not_null($_POST['firstname']) && tep_not_null($_POST['lastname']) && tep_not_null($_POST['street_address'])) {
- $cust=customer::getInstance($customer_id);
- $res=$cust->the_customer();
- $addBook=$cust->userLoadAddress($res['customers_default_address_id']);
+ $cust=customer::getInstance($customer_id);
+ $res=$cust->the_customer();
+ $addBook=$cust->userLoadAddress($res['customers_default_address_id']);
- /// if address book not completed, update
- if(empty($addBook['entry_gender']) && empty($addBook['entry_street_address']) )
- $res=$cust->userAddAddressBook($_POST, $addBook['address_book_id']);
- /// add new adress
- else
- $res=$cust->userAddAddressBook($_POST);
+ /// if address book not completed, update
+ if(empty($addBook['entry_gender']) && empty($addBook['entry_street_address']) )
+ $res=$cust->userAddAddressBook($_POST, $addBook['address_book_id']);
+ /// add new adress
+ else
+ $res=$cust->userAddAddressBook($_POST);
- if($res == false)
- tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'));
+ if($res == false)
+ tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'));
- if (!tep_session_is_registered('sendto')) tep_session_register('sendto');
- $sendto = tep_db_insert_id($res);
+ if (!tep_session_is_registered('sendto'))
+ tep_session_register('sendto');
+ $sendto = tep_db_insert_id($res);
- if (tep_session_is_registered('shipping')) tep_session_unregister('shipping');
+ if (tep_session_is_registered('shipping'))
+ tep_session_unregister('shipping');
- tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
+ $_SESSION['country_id'] = $_POST['country'];
+ if (_cst_bool('ACCOUNT_STATE'))
+ $_SESSION['zone_id'] = $_POST['state_id'];
+
+ tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
// process the selected shipping destination
} elseif (isset($_POST['address'])) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|