コード例 #1
0
ファイル: vmtable.php プロジェクト: juanmcortez/Lectorum
 /**
  * As shortcat, Important the & MUST be there, even in php5.3
  *
  * @author Max Milbers
  * @param array/obj $data input data as assoc array or obj
  * @param boolean $preload You can preload the data here too preserve not updated data
  * @return array/obj $data the updated data
  */
 public function bindChecknStore(&$data, $preload = false)
 {
     $tblKey = $this->_tbl_key;
     $ok = true;
     if ($this->_translatable) {
         if (!class_exists('VmTableData')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtabledata.php';
         }
         $db = JFactory::getDBO();
         $dataTable = clone $this;
         $langTable = new VmTableData($this->_tbl_lang, $tblKey, $db);
         $langTable->setPrimaryKey($tblKey);
         $langData = array();
         $langObKeys = array();
         $langUniqueKeys = array();
         if (is_object($data)) {
             foreach ($this->_translatableFields as $name) {
                 if (isset($data->{$name})) {
                     //We directly store language stuff "escaped"
                     $langData[$name] = htmlentities($data->{$name}, ENT_QUOTES, "UTF-8");
                 } else {
                     //	$langData[$name] = '';
                 }
                 unset($dataTable->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_unique_name[$name]);
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data->$tblKey;
         } else {
             foreach ($this->_translatableFields as $name) {
                 if (isset($data[$name])) {
                     //$langData[$name] = $data[$name];
                     $langData[$name] = htmlentities($data[$name], ENT_QUOTES, "UTF-8");
                 } else {
                     //	$langData[$name] = '';
                 }
                 unset($dataTable->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_unique_name[$name]);
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data[$tblKey];
         }
         $langTable->_unique_name = $langUniqueKeys;
         $langTable->_obkeys = $langObKeys;
         $langTable->_slugAutoName = $this->_slugAutoName;
         unset($dataTable->_slugAutoName);
         $langTable->_slugName = 'slug';
         unset($dataTable->_slugName);
         $langTable->setProperties($langData);
         $langTable->_translatable = false;
         //We must check the langtable BEFORE we store the normal table, cause the langtable is often defining if there are enough data to store it (for exmple the name)
         if ($ok) {
             //vmdebug('my langtable before bind',$langTable->id);
             if (!$langTable->bind($data)) {
                 $ok = false;
                 $msg = 'bind';
                 // 			vmdebug('Problem in bind '.get_class($this).' '.$this->_db->getErrorMsg());
                 vmdebug('Problem in bind ' . get_class($this) . ' ');
             }
         }
         if ($ok) {
             if (!$langTable->check()) {
                 $ok = false;
                 vmdebug('Check returned false ' . get_class($langTable) . ' ' . $this->_tbl . ' ' . $langTable->_db->getErrorMsg());
             }
         }
         if ($ok) {
             $dataTable->bindChecknStoreNoLang($data, $preload);
             $this->bind($dataTable);
             $langTable->{$tblKey} = !empty($this->{$tblKey}) ? $this->{$tblKey} : 0;
             //vmdebug('bindChecknStoreNoLang my $tblKey '.$tblKey.' '.$langTable->$tblKey);
             if ($ok and $preload) {
                 if (!empty($langTable->{$tblKey})) {
                     $id = $langTable->{$tblKey};
                     if (!$langTable->load($id)) {
                         $ok = false;
                         vmdebug('Preloading of language table failed, no id given, cannot store ' . $this->_tbl);
                     }
                 } else {
                     if ($ok) {
                         if (!$langTable->bind($data)) {
                             $ok = false;
                             vmdebug('Problem in bind ' . get_class($this) . ' ');
                         }
                     }
                     if ($ok) {
                         if (!$langTable->check()) {
                             $ok = false;
                             vmdebug('Check returned false ' . get_class($langTable) . ' ' . $this->_tbl . ' ' . $langTable->_db->getErrorMsg());
                         }
                     }
                 }
             }
             if ($ok) {
                 if (!$langTable->store()) {
                     $ok = false;
                     // $msg .= ' store';
                     vmdebug('Problem in store with langtable ' . get_class($langTable) . ' with ' . $tblKey . ' = ' . $this->{$tblKey} . ' ' . $langTable->_db->getErrorMsg());
                 } else {
                     $this->bind($langTable);
                     if ($this->_lhash) {
                         self::$_cache['l'][$this->_lhash] = $this->loadFieldValues(false);
                     }
                 }
             }
         }
     } else {
         if (!$this->bindChecknStoreNoLang($data, $preload)) {
             $ok = false;
         }
     }
     return $ok;
 }
コード例 #2
0
ファイル: vmplugin.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param      $tableName
	 * @param      $tableFields
	 * @param      $primaryKey
	 * @param      $tableId
	 * @param bool $loggable
	 * @return VmTableData
	 */
	protected function createPluginTableObject ($tableName, $tableFields, $primaryKey, $tableId, $loggable = FALSE) {

		if (!class_exists ('VmTableData')) {
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'vmtabledata.php');
		}
		$db = JFactory::getDBO ();
		$table = new VmTableData($tableName, $tableId, $db);
		foreach ($tableFields as $field) {
			$table->$field = 0;
		}

		if ($primaryKey !== 0) {
			$table->setPrimaryKey ($primaryKey);
		}
		if ($loggable) {
			$table->setLoggable ();
		}

		if($this->_cryptedFields){
			$this->_vmpCtable->setCryptedFields($this->_cryptedFields);
		}

		/*if (!$this->_tableChecked) {
			$this->onStoreInstallPluginTable ($this->_psType);
			$this->_tableChecked = TRUE;
		}*/

		return $table;
	}
コード例 #3
0
ファイル: vmtable.php プロジェクト: joselapria/virtuemart
 /**
  * As shortcat, Important the & MUST be there, even in php5.3
  *
  * @author Max Milbers
  * @param array/obj $data input data as assoc array or obj
  * @param boolean $preload You can preload the data here too preserve not updated data
  * @return array/obj $data the updated data
  */
 public function bindChecknStore(&$data, $preload = false)
 {
     $tblKey = $this->_tbl_key;
     if ($this->_translatable) {
         if (!class_exists('VmTableData')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtabledata.php';
         }
         $db = JFactory::getDBO();
         $langTable = new VmTableData($this->_tbl_lang, $tblKey, $db);
         $langTable->setPrimaryKey($tblKey);
         $langData = array();
         $langObKeys = array();
         $langUniqueKeys = array();
         if (is_object($data)) {
             foreach ($this->_translatableFields as $name) {
                 if (!empty($data->{$name})) {
                     $langData[$name] = $data->{$name};
                 } else {
                     $langData[$name] = '';
                 }
                 unset($this->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_unique_name[$name]);
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data->$tblKey;
         } else {
             foreach ($this->_translatableFields as $name) {
                 if (!empty($data[$name])) {
                     $langData[$name] = $data[$name];
                 } else {
                     $langData[$name] = '';
                 }
                 unset($this->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_unique_name[$name]);
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data[$tblKey];
         }
         $langTable->_unique_name = $langUniqueKeys;
         $langTable->_obkeys = $langObKeys;
         $langTable->_slugAutoName = $this->_slugAutoName;
         unset($this->_slugAutoName);
         $langTable->_slugName = 'slug';
         unset($this->_slugName);
         $langTable->setProperties($langData);
         $langTable->_translatable = false;
         // 			$dataLang = $data;
         // 			vmdebug('my $dataLang',$langTable,$data);
         // 			vmdebug('my $table $this',$this);
         $this->bindChecknStoreNoLang($data, $preload);
         // 			vmdebug('bindchecknstore',$langData,$this);
         $langTable->{$tblKey} = !empty($this->{$tblKey}) ? $this->{$tblKey} : 0;
         $ok = true;
         if ($ok) {
             if (!$langTable->check()) {
                 $ok = false;
                 // $msg .= ' check';
                 vmdebug('Check returned false ' . get_class($langTable) . ' ' . $this->_tbl . ' ' . $langTable->_db->getErrorMsg());
             }
         }
         if ($ok) {
             if (!$langTable->store()) {
                 $ok = false;
                 // $msg .= ' store';
                 vmdebug('Problem in store ' . get_class($langTable) . ' ' . $langTable->_db->getErrorMsg());
             }
         }
         // 			if(is_object($data)){
         // 				$data->$tblKey = !empty($langTable->$tblKey) ? $langTable->$tblKey : 0;
         // 			}else {
         // 				$data[$tblKey] = !empty($langTable->$tblKey) ? $langTable->$tblKey : 0;
         // 			}
         // 			$langTable->bindChecknStoreNoLang($data,$preload);
     } else {
         $this->bindChecknStoreNoLang($data, $preload);
     }
     return true;
 }
コード例 #4
0
ファイル: vmplugin.php プロジェクト: aldegtyarev/stelsvelo
 /**
  * @param      $tableName
  * @param      $tableFields
  * @param      $primaryKey
  * @param      $tableId
  * @param bool $loggable
  * @return VmTableData
  */
 protected function createPluginTableObject($tableName, $tableFields, $primaryKey, $tableId, $loggable = FALSE)
 {
     if (!class_exists('VmTableData')) {
         require JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'vmtabledata.php';
     }
     $db = JFactory::getDBO();
     $table = new VmTableData($tableName, $tableId, $db);
     foreach ($tableFields as $field) {
         $table->{$field} = 0;
     }
     /*
     if (substr($tableName, 0, 6) == 'TableS')
     if (!isset($table->shipment_logos)) $table->shipment_logos = ''; 
     if (substr($tableName, 0, 6) == 'TableP')
     if (!isset($table->payment_logos)) $table->payment_logos = ''; 
     
     if (!isset($table->cost_per_transaction)) $table->cost_per_transaction = 0; 
     if (!isset($table->cost_percent_total)) $table->cost_percent_total = 0; 
     */
     if ($primaryKey !== 0) {
         $table->setPrimaryKey($primaryKey);
     }
     if ($loggable) {
         $table->setLoggable();
     }
     if ($this->_cryptedFields) {
         $this->_vmpCtable->setCryptedFields($this->_cryptedFields);
     }
     if (!OPCJ3) {
         if (!$this->_tableChecked) {
             $this->onStoreInstallPluginTable($this->_psType);
             $this->_tableChecked = TRUE;
         }
     }
     return $table;
 }
コード例 #5
0
ファイル: vmplugin.php プロジェクト: joselapria/virtuemart
 protected function createPluginTableObject($tableName, $tableFields, $primaryKey, $tableId, $loggable = false)
 {
     if (!class_exists('VmTableData')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtabledata.php';
     }
     $db = JFactory::getDBO();
     $table = new VmTableData($tableName, $tableId, $db);
     foreach ($tableFields as $field) {
         $table->{$field} = 0;
     }
     if ($primaryKey !== 0) {
         $table->setPrimaryKey($primaryKey);
     }
     if ($loggable) {
         $table->setLoggable();
     }
     if (!$this->_tableChecked) {
         vmdebug('createPluginTableObject executing onStoreInstallPluginTable');
         $this->onStoreInstallPluginTable($this->_psType);
         $this->_tableChecked = true;
     }
     return $table;
 }