当前位置: 首页>>代码示例>>PHP>>正文


PHP JObject::setError方法代码示例

本文整理汇总了PHP中JObject::setError方法的典型用法代码示例。如果您正苦于以下问题:PHP JObject::setError方法的具体用法?PHP JObject::setError怎么用?PHP JObject::setError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JObject的用法示例。


在下文中一共展示了JObject::setError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setError

 /**
  * Redefine setError method inherited from Joomla! JObject class
  *
  * @access	public
  * @since	0.6
  */
 function setError($error)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $logger->finer(get_class($this) . ': ' . JText::_($error));
     parent::setError($error);
 }
开发者ID:madseller,项目名称:coperio,代码行数:14,代码来源:jincobject.php

示例2: switch

 /**
  * Validates the data submitted based on the suffix provided
  *
  * @param $suffix
  * @return html
  */
 function _processSuffix($suffix = '')
 {
     $html = "";
     switch ($suffix) {
         case "2":
             if (!($verify = $this->_verifyDB())) {
                 JError::raiseNotice('_verifyDB', $this->getError());
                 $html .= $this->_renderForm('1');
             } else {
                 // migrate the data and output the results
                 $html .= $this->_doMigration($verify);
             }
             break;
         case "1":
             if (!($verify = $this->_verifyDB())) {
                 JError::raiseNotice('_verifyDB', $this->getError());
                 $html .= $this->_renderForm('1');
             } else {
                 $suffix++;
                 $vars = new JObject();
                 $vars->preview = $verify;
                 $vars->state = $this->_getState();
                 $vars->state->uploaded_file = $this->_uploaded_file;
                 $vars->setError($this->getError());
                 // display a 'connection verified' message
                 // and request confirmation before migrating data
                 $html .= $this->_renderForm($suffix, $vars);
                 $html .= $this->_renderView($suffix, $vars);
             }
             break;
         default:
             $html .= $this->_renderForm('1');
             break;
     }
     return $html;
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:42,代码来源:tool_csvimporter.php

示例3: getTotal

 /**
  * Returns a shipping estimate, unformatted.
  *
  * @param int $shipping_method_id
  * @param int $geozone_id
  * @param array $orderItems     an array of CitruscartTableOrderItems objects, each with ->product_id and ->orderitem_quantity
  *
  * @return object with ->shipping_rate_price and ->shipping_rate_handling and ->shipping_tax_total, all decimal(12,5)
  */
 public function getTotal($shipping_method_id, $geozone_id, $orderItems)
 {
     $return = new JObject();
     $return->shipping_rate_price = '0.00000';
     $return->shipping_rate_handling = '0.00000';
     $return->shipping_tax_rate = '0.00000';
     $return->shipping_tax_total = '0.00000';
     // cast product_id as an array
     $orderItems = (array) $orderItems;
     // determine the shipping method type
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $shippingmethod = JTable::getInstance('ShippingMethods', 'CitruscartTable');
     $shippingmethod->load($shipping_method_id);
     if (empty($shippingmethod->shipping_method_id)) {
         // TODO if this is an object, setError, otherwise return false, or 0.000?
         $return->setError(JText::_('COM_CITRUSCART_UNDEFINED_SHIPPING_METHOD'));
         return $return;
     }
     switch ($shippingmethod->shipping_method_type) {
         case "2":
             // 2 = per order
             // if any of the products in the order require shipping
             $order_ships = false;
             JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
             foreach ($orderItems as $item) {
                 //$pid = $orderItems[$i]->product_id;
                 $pid = $item->product_id;
                 $product = JTable::getInstance('Products', 'CitruscartTable');
                 $product->load($pid);
                 if (!empty($product->product_ships)) {
                     $product_id = $item->product_id;
                     $order_ships = true;
                 }
             }
             if ($order_ships) {
                 //$shippingrate = CitruscartHelperShipping::getRate( $shipping_method_id, $geozone_id, $product_id );
                 //$return->shipping_rate_price      = $shippingrate->shipping_rate_price;
                 //$return->shipping_rate_handling   = $shippingrate->shipping_rate_handling;
             }
             break;
         case "1":
         case "0":
             // 0 = per item
             // 1 = weight based
             $rates = array();
             foreach ($orderItems as $item) {
                 $pid = $item->product_id;
                 $qty = $item->orderitem_quantity;
                 //$rates[$pid] = CitruscartHelperShipping::getRate( $shipping_method_id, $geozone_id, $pid, $shippingmethod->shipping_method_type );
                 //$return->shipping_rate_price      += ($rates[$pid]->shipping_rate_price * $qty);
                 //$return->shipping_rate_handling   += ($rates[$pid]->shipping_rate_handling * $qty);
             }
             break;
         default:
             // TODO if this is an object, setError, otherwise return false, or 0.000?
             $return->setError(JText::_('COM_CITRUSCART_INVALID_SHIPPING_METHOD_TYPE'));
             return $return;
             break;
     }
     // get the shipping tax rate and total
     $return->shipping_tax_rate = CitruscartHelperShipping::getTaxRate($shipping_method_id, $geozone_id);
     $return->shipping_tax_total = $return->shipping_tax_rate / 100 * ($return->shipping_rate_price + $return->shipping_rate_handling);
     return $return;
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:73,代码来源:shipping.php

示例4: getTotal

 /**
  *
  * Returns an object with the total cost of shipping for this method and the array of geozones
  *
  * @param unknown_type $shipping_method_id
  * @param array $geozones
  * @param unknown_type $orderItems
  * @param unknown_type $order_id
  */
 protected function getTotal($shipping_method_id, $geozones, $orderItems, $geozones_taxes)
 {
     $return = new JObject();
     $return->shipping_rate_id = '0';
     $return->shipping_rate_price = '0.00000';
     $return->shipping_rate_handling = '0.00000';
     $return->shipping_tax_rates = '0.00000';
     $return->shipping_tax_total = '0.00000';
     $rate_exists = false;
     $geozone_rates = array();
     //include custom modals
     $this->includeCustomModel('ShippingMethods');
     $this->includeCustomModel('ShippingRates');
     // cast product_id as an array
     $orderItems = (array) $orderItems;
     // determine the shipping method type
     $this->includeCustomTables('shipping_standard');
     $this->includeCustomTables();
     $shippingmethod = JTable::getInstance('ShippingMethods', 'Table');
     $shippingmethod->load($shipping_method_id);
     if (empty($shippingmethod->shipping_method_id)) {
         // TODO if this is an object, setError, otherwise return false, or 0.000?
         $return->setError(JText::_('J2STORE_UNDEFINED_SHIPPING_METHOD'));
         return $return;
     }
     //initiliase cart helper
     $carthelper = new J2StoreHelperCart();
     //initliase cart model
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_j2store/models');
     $cart_model = new J2StoreModelMyCart();
     switch ($shippingmethod->shipping_method_type) {
         case "2":
             // 2 = per order - price based
             // Get the total of the order, and find the rate for that
             $total = 0;
             //foreach ($orderItems as $item)
             //	{
             //		$total += $item->orderitem_final_price;
             //	}
             $order_ships = false;
             $products = $cart_model->getDataNew();
             foreach ($products as $product) {
                 //check if shipping is enabled for this item
                 if (!empty($product['shipping'])) {
                     $order_ships = true;
                     $total += $product['total'];
                     // product total
                 }
             }
             if ($order_ships) {
                 foreach ($geozones as $geozone) {
                     unset($rate);
                     $geozone_id = $geozone->geozone_id;
                     if (empty($geozone_rates[$geozone_id]) || !is_array($geozone_rates[$geozone_id])) {
                         $geozone_rates[$geozone_id] = array();
                     }
                     //	JModelLegacy::addIncludePath( JPATH_ADMINISTRATOR.'/components/com_j2store/models' );
                     $model = JModelLegacy::getInstance('ShippingRates', 'J2StoreModel');
                     $model->setState('filter_shippingmethod', $shipping_method_id);
                     $model->setState('filter_geozone', $geozone_id);
                     $model->setState('filter_weight', $total);
                     // Use weight as total
                     $items = $model->getList();
                     if (count($items) < 1) {
                         //return JTable::getInstance('ShippingRates', 'Table');
                     } else {
                         $rate = $items[0];
                         $geozone_rates[$geozone_id]['0'] = $rate;
                         // if $rate->shipping_rate_id is empty, then no real rate was found
                         if (!empty($rate->shipping_rate_id)) {
                             $rate_exists = true;
                         }
                         $geozone_rates[$geozone_id]['0']->qty = '1';
                         $geozone_rates[$geozone_id]['0']->shipping_method_type = $shippingmethod->shipping_method_type;
                     }
                 }
             }
             break;
         case "1":
             // 1 = per order - quantity based
             // first, get the total quantity of shippable items for the entire order
             // then, figure out the rate for this number of items (use the weight range field) + geozone
         // 1 = per order - quantity based
         // first, get the total quantity of shippable items for the entire order
         // then, figure out the rate for this number of items (use the weight range field) + geozone
         case "0":
             // 0 = per order - flat rate
         // 0 = per order - flat rate
         case "5":
             // 5 = per order - weight based
             // if any of the products in the order require shipping
//.........这里部分代码省略.........
开发者ID:ForAEdesWeb,项目名称:AEW4,代码行数:101,代码来源:shipping_standard.php

示例5: getTotal

 /**
  * 
  * Returns an object with the total cost of shipping for this method and the array of geozones
  * 
  * @param unknown_type $shipping_method_id
  * @param array $geozones
  * @param unknown_type $orderItems
  * @param unknown_type $order_id
  */
 protected function getTotal($shipping_method_id, $geozones, $orderItems, $geozones_taxes)
 {
     $return = new JObject();
     $return->shipping_rate_id = '0';
     $return->shipping_rate_price = '0.00000';
     $return->shipping_rate_handling = '0.00000';
     $return->shipping_tax_rate = '0.00000';
     $return->shipping_tax_total = '0.00000';
     $rate_exists = false;
     $geozone_rates = array();
     // cast product_id as an array
     $orderItems = (array) $orderItems;
     // determine the shipping method type
     $this->includeCustomTables('shipping_standard');
     $shippingmethod = JTable::getInstance('ShippingMethods', 'TiendaTable');
     $shippingmethod->load($shipping_method_id);
     if (empty($shippingmethod->shipping_method_id)) {
         // TODO if this is an object, setError, otherwise return false, or 0.000?
         $return->setError(JText::_('COM_TIENDA_UNDEFINED_SHIPPING_METHOD'));
         return $return;
     }
     switch ($shippingmethod->shipping_method_type) {
         case "6":
             // 5 = per order - price based
             // Get the total of the order, and find the rate for that
             $total = 0;
             foreach ($orderItems as $item) {
                 $total += $item->orderitem_final_price;
             }
             foreach ($geozones as $geozone) {
                 unset($rate);
                 $geozone_id = $geozone->geozone_id;
                 if (empty($geozone_rates[$geozone_id]) || !is_array($geozone_rates[$geozone_id])) {
                     $geozone_rates[$geozone_id] = array();
                 }
                 JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
                 $model = JModel::getInstance('ShippingRates', 'TiendaModel');
                 $model->setState('filter_shippingmethod', $shipping_method_id);
                 $model->setState('filter_geozone', $geozone_id);
                 $model->setState('filter_weight', $total);
                 // Use weight as total
                 $items = $model->getList();
                 if (empty($items)) {
                     return JTable::getInstance('ShippingRates', 'TiendaTable');
                 }
                 $rate = $items[0];
                 $geozone_rates[$geozone_id]['0'] = $rate;
                 // if $rate->shipping_rate_id is empty, then no real rate was found
                 if (!empty($rate->shipping_rate_id)) {
                     $rate_exists = true;
                 }
                 $geozone_rates[$geozone_id]['0']->qty = '1';
                 $geozone_rates[$geozone_id]['0']->shipping_method_type = $shippingmethod->shipping_method_type;
             }
             break;
         case "5":
             // 5 = per order - quantity based
             // first, get the total quantity of shippable items for the entire order
             // then, figure out the rate for this number of items (use the weight range field) + geozone
         // 5 = per order - quantity based
         // first, get the total quantity of shippable items for the entire order
         // then, figure out the rate for this number of items (use the weight range field) + geozone
         case "3":
         case "2":
             // 2 = per order - weight based
             // 3 = per order - flat rate
             // if any of the products in the order require shipping
             $sum_weight = 0;
             $count_shipped_items = 0;
             $order_ships = false;
             JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
             foreach ($orderItems as $item) {
                 // find out if the order ships
                 // and while looping through, sum the weight of all shippable products in the order
                 $pid = $item->product_id;
                 $product = JTable::getInstance('Products', 'TiendaTable');
                 $product->load($pid);
                 if (!empty($product->product_ships)) {
                     $product_id = $item->product_id;
                     $order_ships = true;
                     $sum_weight += $product->product_weight * $item->orderitem_quantity;
                     $count_shipped_items += $item->orderitem_quantity;
                 }
             }
             if ($order_ships) {
                 foreach ($geozones as $geozone) {
                     unset($rate);
                     $geozone_id = $geozone->geozone_id;
                     if (empty($geozone_rates[$geozone_id]) || !is_array($geozone_rates[$geozone_id])) {
                         $geozone_rates[$geozone_id] = array();
                     }
//.........这里部分代码省略.........
开发者ID:annggeel,项目名称:tienda,代码行数:101,代码来源:shipping_standard.php

示例6: setError

 /**
  * Overrides JObject's setError() method to cater for logging
  *
  * @param string $message The error message
  */
 function setError($message)
 {
     parent::setError($message);
     JoomlapackLogger::WriteLog(_JP_LOG_ERROR, $message);
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:10,代码来源:cube.php

示例7: getTotal

 public function getTotal($shipping_method_id, $orderItems)
 {
     $doc = JFactory::getDocument();
     $return = new JObject();
     $return->shipping_rate_id = '0';
     $return->shipping_rate_price = '0.00000';
     $return->shipping_rate_handling = '0.00000';
     $rate_exists = false;
     // cast product_id as an array
     $orderItems = (array) $orderItems;
     // determine the shipping method type
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'tables');
     $shippingmethod = JTable::getInstance('ShippingMethods', 'Table');
     $shippingmethod->load($shipping_method_id);
     if (empty($shippingmethod->id)) {
         // TODO if this is an object, setError, otherwise return false, or 0.000?
         $return->setError(JText::_("Undefined Shipping Method"));
         return $return;
     }
     switch ($shippingmethod->shipping_method_type) {
         case "2":
             // 5 = per order - price based
             // Get the total of the order, and find the rate for that
             $total = 0;
             foreach ($orderItems as $item) {
                 $total += $item->orderitem_final_price;
             }
             JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'models');
             $model = JModelLegacy::getInstance('ShippingRates', 'K2StoreModel');
             $model->setState('filter_shippingmethod', $shipping_method_id);
             $model->setState('filter_weight', $total);
             // Use weight as total
             $items = $model->getList();
             if (empty($items)) {
                 return JTable::getInstance('ShippingRates', 'Table');
             }
             $rate = $items[0];
             // if $rate->shipping_rate_id is empty, then no real rate was found
             if (!empty($rate->shipping_rate_id)) {
                 $rate_exists = true;
             }
             break;
         case "1":
             // 1 = per order - quantity based
             // first, get the total quantity of shippable items for the entire order
             // then, figure out the rate for this number of items (use the weight range field) + geozone
         // 1 = per order - quantity based
         // first, get the total quantity of shippable items for the entire order
         // then, figure out the rate for this number of items (use the weight range field) + geozone
         case "0":
             // 0 = per order - flat rate
             // if any of the products in the order require shipping
             $count_shipped_items = 0;
             $order_ships = false;
             foreach ($orderItems as $item) {
                 // find out if the order ships
                 // and while looping through, sum the weight of all shippable products in the order
                 $pid = $item->product_id;
                 require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'library' . DS . 'k2item.php';
                 $product_helper = new K2StoreItem();
                 $isShips = $product_helper->isShippingEnabled($pid);
                 if (!empty($isShips)) {
                     $product_id = $item->product_id;
                     $order_ships = true;
                     $count_shipped_items += $item->orderitem_quantity;
                 }
             }
             if ($order_ships) {
                 switch ($shippingmethod->shipping_method_type) {
                     case "1":
                         // quantity //based get the shipping rate for the entire order using the count of all products in the order that ship
                         $rate = $this->getRate($shipping_method_id, $product_id, '1', $count_shipped_items);
                         break;
                     default:
                     case "0":
                         // flat rate // don't use weight, just do flat rate for entire order
                         // regardless of weight and regardless of the number of items
                         $rate = $this->getRate($shipping_method_id, $product_id);
                         break;
                 }
                 // if $rate->shipping_rate_id is empty, then no real rate was found
                 if (!empty($rate->shipping_rate_id)) {
                     $rate_exists = true;
                 }
             }
             break;
         default:
             //	throw new Exception(JText::_( "Invalid Shipping Method Type" ));
             return false;
             break;
     }
     if (!$rate_exists) {
         //	throw new Exception( JText::_( "No Rate Found" ) );
         return false;
     }
     $shipping_tax_rates = array();
     $shipping_method_price = 0;
     $shipping_method_handling = 0;
     $shipping_method_tax_total = 0;
     // now calc for the entire method
//.........这里部分代码省略.........
开发者ID:A-Bush,项目名称:pprod,代码行数:101,代码来源:shipping.php

示例8: getTotal

 /**
  *
  * Returns an object with the total cost of shipping for this method and the array of geozones
  *
  * @param unknown_type $shipping_method_id
  * @param array $geozones
  * @param unknown_type $orderItems
  * @param unknown_type $order_id
  */
 protected function getTotal($shipping_method_id, $geozones, $orderItems, $geozones_taxes)
 {
     $return = new JObject();
     $return->shipping_price = '0.00000';
     $return->shipping_handling = '0.00000';
     $return->shipping_tax_total = '0.00000';
     $rate_exists = false;
     $geozone_rates = array();
     // determine the shipping method type
     $this->includeCustomTables('shipping_weightbased');
     $shippingmethod = JTable::getInstance('ShippingMethodsWeightbased', 'TiendaTable');
     $shippingmethod->load($shipping_method_id);
     if (empty($shippingmethod->shipping_method_weightbased_id)) {
         // TODO if this is an object, setError, otherwise return false, or 0.000?
         $return->setError(JText::_('COM_TIENDA_UNDEFINED_SHIPPING_METHOD'));
         return $return;
     }
     $sum_weight = $this->calculateWeight($orderItems);
     $order_ships = $sum_weight != 0;
     if ($order_ships) {
         foreach ($geozones as $geozone) {
             unset($rate);
             $geozone_id = $geozone->geozone_id;
             if (empty($geozone_rates[$geozone_id]) || !is_array($geozone_rates[$geozone_id])) {
                 $geozone_rates[$geozone_id] = array();
             }
             // get the shipping rate for the entire order using the sum weight of all products in the order that ship
             $rate = $this->getRate($shipping_method_id, $geozone_id, $sum_weight);
             // if $rate->shipping_rate_id is empty, then no real rate was found
             if (!empty($rate->shipping_rate_weightbased_id)) {
                 $rate_exists = true;
                 $geozone_rates[$geozone_id]['0'] = $rate;
             }
         }
     }
     if (!$rate_exists) {
         $this->setError(JText::_('COM_TIENDA_NO_RATE_FOUND'));
         return false;
     }
     $shipping_tax_rates = array();
     $shipping_method_price = 0;
     $shipping_method_handling = 0;
     $shipping_method_tax_total = 0;
     // now calc for the entire method
     foreach ($geozone_rates as $geozone_id => $geozone_rate_array) {
         foreach ($geozone_rate_array as $geozone_rate) {
             $shipping_tax_rates[$geozone_id] = 0;
             foreach ($geozones_taxes as $gz_tax) {
                 $shipping_tax_rates[$geozone_id] += $this->getTaxRate($shipping_method_id, $gz_tax->geozone_id);
             }
             $return->shipping_rate_weightbased_id = $geozone_rate->shipping_rate_weightbased_id;
             $rate_price = $this->calculatePriceRate($geozone_rate, $sum_weight);
             $shipping_method_price += $rate_price;
             $shipping_method_handling += $geozone_rate->shipping_handling;
             $shipping_method_tax_total += $shipping_tax_rates[$geozone_id] / 100 * ($rate_price + $geozone_rate->shipping_handling);
         }
     }
     // return formatted object
     $return->shipping_price = $shipping_method_price;
     $return->shipping_handling = $shipping_method_handling;
     $return->shipping_tax_rates = $shipping_tax_rates;
     $return->shipping_tax_total = $shipping_method_tax_total;
     $return->shipping_method_id = $shipping_method_id;
     $return->shipping_method_name = $shippingmethod->shipping_method_weightbased_name;
     return $return;
 }
开发者ID:annggeel,项目名称:tienda,代码行数:75,代码来源:shipping_weightbased.php

示例9: JObject

 function _populateDatabase(&$database, $sqlfile, &$errors)
 {
     if (!($buffer = file_get_contents($sqlfile))) {
         $vars = new JObject();
         $vars->state = $this->_getState();
         $vars->setError($this->getError());
         return $this->_getLayout("view_2", $vars);
     }
     $queries = $this->_splitSql($buffer);
     $results = array();
     $n = 0;
     foreach ($queries as $query) {
         $query = trim($query);
         if ($query != '' && $query[0] != '#') {
             $database->setQuery($query);
             $results[$n]->query = $database->getQuery();
             $results[$n]->error = '';
             if (!$database->query()) {
                 $results[$n]->error = $database->getErrorMsg();
             }
             $results[$n]->affectedRows = $database->getAffectedRows();
             $n++;
         }
     }
     return $results;
 }
开发者ID:annggeel,项目名称:tienda,代码行数:26,代码来源:tool_installsampledata.php


注:本文中的JObject::setError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。