/** * Accessors definition * @param string $method * @param array $arguments * @return mixed */ public function __call($method, $arguments = array()) { $action = substr($method, 0, 3); $property = isset($arguments[0]) ? $arguments[0] : null; $values = isset($arguments[1]) ? (array) $arguments[1] : null; if (!in_array($action, array('get', 'set', 'add')) || !isset($this->{$property})) { throw new sfRuntimeException('Method "%s" does not exists for class %s', $method, getclass($this)); } switch ($action) { case 'get': return $this->{$property}; break; case 'set': $this->{$property} = $values; return $this; break; case 'add': foreach ($values as $value) { if (!in_array($value, $this->{$property})) { $this->{$property}[] = $value; } } return $this; break; } }
/** * Enqueues styles using the coreect hook with top priority so they appear before all other styles. Init is not usually the palce to enqueue styles, but for this reset, this is the place! * * @param none * @return object cbrcssNormalise * @throws wp_die if this lass is instantiated more than once */ public function __construct() { if (isset(self::$_this)) { wp_die(sprintf(__('%s can only be created once', 'cross-browser-css-normalise'), getclass($this))); } self::$_this = $this; add_action('init', array($this, 'cbcss_enqueue_style'), 1); }
/** * Set up the list of coupon codes that have been applied to the shopping * cart. */ public function setUpAppliedCouponsList() { $GLOBALS['SNIPPETS']['Coupons'] = ''; $coupons = $this->quote->getAppliedCoupons(); if(empty($coupons)) { return; } $GLOBALS['SNIPPETS']['FreeShippingCoupons'] = ''; $GLOBALS['SNIPPETS']['NormalCoupons'] = ''; $freeShippingTypesIds = array(4,3); foreach ($coupons as $coupon) { $GLOBALS['CouponId'] = $coupon['id']; $GLOBALS['CouponCode'] = $coupon['code']; $GLOBALS['CouponDiscount'] = currencyConvertFormatPrice($coupon['totalDiscount'] * -1); $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon"); if (!empty ($coupon['discountType']) && getclass('ISC_COUPON')->isFreeShippingCoupon($coupon['discountType'])) { $GLOBALS['SNIPPETS']['FreeShippingCoupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon"); } else { $GLOBALS['SNIPPETS']['NormalCoupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon"); } } }
/** * Return the command as a string for the whole instance * * @param string $instance * * @return string * @throws ProgrammingError */ public function getGlobalCommand($instance = null) { throw new ProgrammingError(getclass($this) . ' does not provide a global command'); }
function getOrderTotalRows($order) { $taxColumnAppend = '_ex_tax'; if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) { $taxColumnAppend = '_inc_tax'; } $totalRows = array(); // Subtotal $totalRows['subtotal'] = array( 'label' => getLang('Subtotal'), 'value' => $order['subtotal'.$taxColumnAppend] ); // Gift Wrapping if($order['wrapping_cost'.$taxColumnAppend] > 0) { $totalRows['giftWrapping'] = array( 'label' => getLang('GiftWrapping'), 'value' => $order['wrapping_cost'.$taxColumnAppend] ); } // Discount Amount if($order['orddiscountamount'] > 0) { $totalRows['discount'] = array( 'label' => getLang('Discount'), 'value' => $order['orddiscountamount'] * -1, ); } // Coupon codes $query = " SELECT * FROM [|PREFIX|]order_coupons WHERE ordcouporderid='".$order['orderid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); $freeShippingCoupons = array(); while($coupon = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { if($coupon['applied_discount'] == 0) { continue; } $couponRow = array( 'label' => getLang('CouponCode').' ('.$coupon['ordcouponcode'].')', 'value' => $coupon['applied_discount'] * -1, ); if (getclass('ISC_COUPON')->isFreeShippingCoupon($coupon['ordcoupontype'])) { $freeShippingCoupons['coupon-'.$coupon['ordcoupid']] = $couponRow; continue; } $totalRows['coupon-'.$coupon['ordcoupid']] = $couponRow; }; // Shipping & handling if($order['shipping_address_count'] > 1) { $query = " SELECT * FROM [|PREFIX|]order_shipping WHERE order_id='".$order['orderid']."' ORDER BY order_address_id "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); $destinationCounter = 0; while($shipping = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $destinationCounter++; $totalRows['shipping-'.$shipping['id']] = array( 'label' => getLang('Shipping_Destination_Number', array('number' => $destinationCounter)).' ('.$shipping['method'].')', 'value' => $shipping['cost'.$taxColumnAppend] ); } } else if(!$order['ordisdigital']) { $totalRows['shipping'] = array( 'label' => getLang('Shipping'), 'value' => $order['shipping_cost'.$taxColumnAppend] ); if (!empty ($freeShippingCoupons)) { $totalRows['shipping']['value'] = 0; foreach($freeShippingCoupons as $key=>$val) { $totalRows[$key] = $val; $totalRows['shipping']['value'] += (int)$val['value']; } if ($totalRows['shipping']['value'] < 0) { $totalRows['shipping']['value'] *= -1; } } } if($order['handling_cost'.$taxColumnAppend] > 0) { $totalRows['handling'] = array( 'label' => getLang('Handling'), 'value' => $order['handling_cost'.$taxColumnAppend] ); } // Taxes $taxes = array(); $includedTaxes = array(); if($order['total_tax']) { // Show a single summary of applied tax if(getConfig('taxChargesOnOrdersBreakdown') == TAX_BREAKDOWN_SUMMARY) { $taxes[] = array( 'name' => getConfig('taxLabel'), 'total' => $order['total_tax'] ); } else { // Whilst the loop here seems like overhead for now, when we // switch to the new template system on the front end, we'll // just assign $taxes to the template to allow further // customization. $query = " SELECT name, tax_rate_id, SUM(priority_amount) AS priority_amount, priority FROM [|PREFIX|]order_taxes WHERE order_id='".$order['orderid']."' GROUP BY priority, tax_rate_id ORDER BY priority "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while($tax = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { if(!isset($taxes[$tax['priority']])) { $taxes[$tax['priority']] = array( 'name' => $tax['name'], 'total' => $tax['priority_amount'], ); continue; } $taxes[$tax['priority']]['name'] .= ' + ' . $tax['name']; } } if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) { $includedTaxes = $taxes; $taxes = array(); } } foreach($taxes as $id => $taxRate) { if($taxRate['total'] == 0) { continue; } $totalRows['tax-'.$id] = array( 'label' => $taxRate['name'], 'value' => $taxRate['total'], ); } // Gift Certificates if($order['ordgiftcertificateamount'] > 0) { $totalRows['giftCertificates'] = array( 'label' => getLang('GiftCertificates'), 'value' => $order['ordgiftcertificateamount'] * -1, ); } // Store Credit if($order['ordstorecreditamount'] > 0) { $totalRows['storeCredit'] = array( 'label' => getLang('StoreCredit'), 'value' => $order['ordstorecreditamount'] * -1, ); } $totalRows['total'] = array( 'label' => getLang('GrandTotal'), 'value' => $order['total_inc_tax'], ); // Included taxes foreach($includedTaxes as $id => $taxRate) { if($taxRate['total'] == 0) { continue; } $totalRows['tax-'.$id] = array( 'label' => $taxRate['name'] . ' ' . getLang('IncludedInTotal'), 'value' => $taxRate['total'], ); } return $totalRows; }
echo "Author: Senorsen. Without any copyright, but follow the LICENSE.\n"; echo "\n"; exit(0); } if ($argc == 2) { $stuid = $passwd = $argv[1]; } if ($argc == 3) { $stuid = $argv[1]; $passwd = $argv[2]; } echo "CProgramming Submitter by Senorsen - sen@senorsen.com\n"; echo "Please see the LICENSE.\n"; $login_ret = login($stuid, $passwd); getannounce($login_ret); $classes = getclass(); echo "\n"; echo "+---------------------------------------------+\n"; foreach ($classes as $key => $value) { printf("ID: %2d %5s %10s %13s %12s\n", $key, $value->id, $value->no, $value->name, $value->teacher); } echo "+---------------------------------------------+\n"; sleep(1); foreach ($classes as $key => $value) { echo "Try {$key}-{$value->id} : "; $lianxis = getlianxi($value->id); if ($lianxis == FALSE) { continue; } echo "Your practices: \n"; foreach ($lianxis as $kk => $vv) {
/** * Extract an array out of $data or throw an exception if not possible. * * @param array|KeyValueContainer|\Traversable $data Something that can be converted to an array. * * @return array Native array representation of $data * * @throws InvalidArgumentException If $data can not be converted to an array. */ private function toArray($data) { if (is_array($data)) { return $data; } if ($data instanceof KeyValueContainer) { return $data->toArray(); } if ($data instanceof \Traversable) { return iterator_to_array($data); } throw new InvalidArgumentException(sprintf('Expected array, Traversable or KeyValueContainer, got "%s"', is_object($data) ? getclass($data) : get_type($data))); }
public static function getQuoteTotalRows(ISC_QUOTE $quote, $displayIncTax = null, $expandShipping = true) { if($displayIncTax === null) { $displayIncTax = false; if(getConfig('taxDefaultTaxDisplayCart') == TAX_PRICES_DISPLAY_INCLUSIVE) { $displayIncTax = true; } } $totalRows = array(); // Subtotal $totalRows['subtotal'] = array( 'label' => getLang('Subtotal'), 'value' => $quote->getSubTotal($displayIncTax) ); // Gift Wrapping $wrappingCost = $quote->getWrappingCost($displayIncTax); if($wrappingCost > 0) { $totalRows['giftWrapping'] = array( 'label' => getLang('GiftWrapping'), 'value' => $wrappingCost ); } // Coupon codes $quote->reapplyCoupons(); $coupons = $quote->getAppliedCoupons(); $freeShippingCoupons = array(); foreach($coupons as $coupon) { // Discard the coupon if it's already expired. if (isset ($coupon['expiresDate']) && $quote->isCouponExpired($coupon['expiresDate'])) { $quote->removeCoupon($coupon['code']); continue; } $couponRow = array( 'type' => 'coupon', 'label' => getLang('Coupon').' ('.$coupon['code'].')', 'value' => $coupon['totalDiscount'] * -1, 'id' => $coupon['id'], ); if (getclass('ISC_COUPON')->isFreeShippingCoupon($coupon['discountType'])) { $freeShippingCoupons['coupon-'.$coupon['id']] = $couponRow; continue; } $totalRows['coupon-'.$coupon['id']] = $couponRow; } // Discount Amount $discountAmount = $quote->getDiscountAmount(); if($discountAmount > 0){ $totalRows['discount'] = array( 'label' => getLang('Discount'), 'value' => $discountAmount * -1, ); } // Shipping & handling if(!$quote->isDigital()) { // show each shipping quote separately? if ($expandShipping) { $shippingAddresses = $quote->getShippingAddresses(); foreach($shippingAddresses as $address) { if(!$address->hasShippingMethod()) { continue; } $totalRows['shipping-'.$address->getId()] = array( 'label' => getLang('Shipping').' ('.$address->getShippingProvider().')', 'value' => $address->getNonDiscountedShippingCost($displayIncTax) ); } } else { $totalRows['shipping'] = array( 'label' => getLang('Shipping'), 'value' => $quote->getNonDiscountedShippingCost($displayIncTax), ); } // Added the free shipping coupon display below shipping cost // Only if we have free shipping coupon applied if (!empty ($freeShippingCoupons)) { foreach ($freeShippingCoupons as $key=>$val) { $totalRows[$key] = $val; } } } $handlingCost = $quote->getHandlingCost($displayIncTax); if($handlingCost > 0) { $totalRows['handling'] = array( 'label' => getLang('Handling'), 'value' => $handlingCost ); } // Taxes $taxes = array(); $includedTaxes = array(); $taxTotal = $quote->getTaxTotal(); if($taxTotal) { $taxAppend = ''; if(getConfig('taxDefaultTaxDisplayCart') == TAX_PRICES_DISPLAY_INCLUSIVE) { $taxAppend = ' '.getLang('IncludedInTotal'); } // Show a single summary of applied tax if(getConfig('taxChargesInCartBreakdown') == TAX_BREAKDOWN_SUMMARY) { $taxes[] = array( 'name' => getConfig('taxLabel').$taxAppend, 'total' => $taxTotal, ); } else { $taxSummary = $quote->getTaxRateSummary(); foreach($taxSummary as $taxRateName => $taxRateAmount) { if($taxRateAmount == 0) { continue; } $taxes[] = array( 'name' => $taxRateName.$taxAppend, 'total' => $taxRateAmount, ); } } if(getConfig('taxDefaultTaxDisplayCart') == TAX_PRICES_DISPLAY_INCLUSIVE) { $includedTaxes = $taxes; $taxes = array(); } } foreach($taxes as $id => $taxRate) { $totalRows['tax-'.$id] = array( 'label' => $taxRate['name'], 'value' => $taxRate['total'], ); } // Gift Certificates $giftCertificates = $quote->getAppliedGiftCertificates(); foreach($giftCertificates as $giftCertificate) { $totalRows['giftcertificate-'.$giftCertificate['id']] = array( 'type' => 'giftCertificate', 'label' => getLang('GiftCertificate').' ('.$giftCertificate['code'].')', 'value' => $giftCertificate['used'] * -1, 'id' => $giftCertificate['id'], ); } $totalRows['total'] = array( 'label' => getLang('GrandTotal'), 'value' => $quote->getGrandTotal($displayIncTax), ); // Included taxes foreach($includedTaxes as $id => $taxRate) { $totalRows['tax-'.$id] = array( 'label' => $taxRate['name'], 'value' => $taxRate['total'], ); } return $totalRows; }
public function set_cache_folder($foldername) { if (is_object(self::$cache) && getclass(self::$cache) == 'File_Cache') { self::$cache->setCacheFolder($foldername); } }
public function applyCoupon($coupon) { $this->removeAllCoupons(); if(is_string($coupon) || is_numeric($coupon)) { // Look up the coupon code $code = trim($coupon); $coupon = $this->fetchCoupon($code); if (!$coupon || !$coupon['couponcode']) { throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidCouponCode'), ISC_QUOTE_EXCEPTION::COUPON_INVALID); } // Check if the coupon actually applies to any of the items in the cart $appliesTo = array(); $query = " SELECT valueid FROM [|PREFIX|]coupon_values WHERE couponid='".$coupon['couponid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while ($value = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $appliesTo[] = $value['valueid']; } } else { $appliesTo = $coupon['appliesto']; } // Coupon code is disabled, it can't be applied if (isset($coupon['couponenabled']) && $coupon['couponenabled'] == 0) { throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidCouponDisabled'), ISC_QUOTE_EXCEPTION::COUPON_DISABLED); } // If the coupon has expired, it can't be used if (isset($coupon['couponexpires']) && $coupon['couponexpires'] != 0) { // coupon expires at 23:59:59 of the day $expires = $coupon['couponexpires'] + 86399; if (isc_mktime() > $expires) { throw new ISC_QUOTE_EXCEPTION( sprintf(GetLang('InvalidCouponExpired'), date(GetConfig('DisplayDateFormat'), $coupon['couponexpires'])), ISC_QUOTE_EXCEPTION::COUPON_EXPIRED_TIME ); } } // Has the coupon already reached it's maximum number of uses? It can't be used if (isset($coupon['couponmaxuses']) && $coupon['couponnumuses'] && $coupon['couponmaxuses'] != 0 && $coupon['couponnumuses'] >= $coupon['couponmaxuses']) { throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidCouponExpiredUses'), ISC_QUOTE_EXCEPTION::COUPON_EXPIRED_USES); return false; } // check max use per customer info if (isset($coupon['couponmaxusespercus']) && (int)$coupon['couponmaxusespercus'] > 0) { if (getclass('ISC_COUPON')->isPerCustomerUsageLimitReached($coupon['couponid'], $coupon['couponmaxusespercus'])) { throw new ISC_QUOTE_EXCEPTION(getLang('InvalidCouponExpiredUses'), ISC_QUOTE_EXCEPTION::COUPON_EXPIRED_USES); return false; } } // Does the cart subtotal meet the minimum purchase amount required? $subtotal = $this->getBaseSubTotal(); if (isset($coupon['couponminpurchase']) && $coupon['couponminpurchase'] > 0 && $subtotal < $coupon['couponminpurchase']) { $amountDiff = $coupon['couponminpurchase'] - $subtotal; $amountDiff = CurrencyConvertFormatPrice($amountDiff); $invalidCouponMesg = sprintf(GetLang('InvalidCouponMinPrice'), $amountDiff); throw new ISC_QUOTE_EXCEPTION($invalidCouponMesg, ISC_QUOTE_EXCEPTION::COUPON_MIN_PURCHASE); } if ($coupon['coupontype'] == 1) { $discountType = 'percent'; } else { $discountType = 'fixed'; } if (empty($appliesTo)) { return 0; } $totalCouponDiscount = 0; $applyOrderDiscount = false; $applyDiscountShipping = false; $applyFreeShipping = false; $shippingLocationUnapplied = false; $shippingMethodUnapplied = false; $appliesToQuote = false; foreach ($this->items as $item) { $applyToItem = false; if ($coupon['couponappliesto'] == 'products') { if (in_array($item->getProductId(), $appliesTo)) { $applyToItem = true; } } else if ($coupon['couponappliesto'] == 'categories') { if (in_array('0', $appliesTo)) { $applyToItem = true; } else { $categories = $item->getCategoryIds(); foreach ($categories as $categoryId) { if (in_array($categoryId, $appliesTo)) { $applyToItem = true; break; } } } } // if the coupon restricted by location if (!empty ($coupon['location_restricted']) && $applyToItem) { // Checking address based on individual item's address $shippingAddress = $item->getAddress(); try { $applyToItem = $this->_isCouponValidByLocation($shippingAddress, (int)$coupon['couponid']); } catch(ISC_QUOTE_EXCEPTION $e) { throw $e; } if (!$applyToItem) { $shippingLocationUnapplied = true; } } // if the coupon restricted by shipping method if (!empty ($coupon['shipping_method_restricted']) && $applyToItem) { $shippingAddress = $item->getAddress(); $applyToItem = $this->_isCouponValidByShippingMethod($shippingAddress, (int)$coupon['couponid']); if (!$applyToItem) { $shippingMethodUnapplied = true; } } // Coupon does not apply to this product. Continue. if ($applyToItem == false) { continue; } $appliesToQuote = true; // Percentage discount if ($coupon['coupontype'] == 1) { $discountAmount = $item->getDiscountedBaseTotal() * ($coupon['couponamount'] / 100); $discountAmount = round($discountAmount, getConfig('DecimalPlaces')); } // Discount the entire order - do this outside the item loop else if ($coupon['coupontype'] == 2) { $applyOrderDiscount = true; break; } // Discound on Shipping Coupon else if ($coupon['coupontype'] == 3) { $applyDiscountShipping = true; break; } // Freeshipping Coupon else if ($coupon['coupontype'] == 4) { $applyFreeShipping = true; break; } // Discount a fixed amount off each item else { $discountedBaseTotal = $item->getDiscountedBaseTotal(); $discountAmount = $coupon['couponamount'] * $item->getQuantity(); if ($discountAmount > $discountedBaseTotal) { $discountAmount = $discountedBaseTotal; } } // Add the coupons in under 'coupon' as only one coupon is allowed per product $totalCouponDiscount += $discountAmount; $item->addDiscount('coupon', $discountAmount); } if ($applyOrderDiscount) { // If a coupon is applied to an entire order, it cancels out any other // already applied coupons $existingCoupons = $this->getAppliedCoupons(); foreach ($existingCoupons as $existingCoupon) { $this->removeCoupon($existingCoupon['code']); } $totalCouponDiscount = $coupon['couponamount']; $runningTotal = $totalCouponDiscount; foreach ($this->items as $item) { $discountedBase = $item->getDiscountedBaseTotal(); if($discountedBase - $runningTotal < 0) { $item->addDiscount('total-coupon', $discountedBase); $runningTotal -= $discountedBase; } else { $item->addDiscount('total-coupon', $runningTotal); $runningTotal -= $runningTotal; } if($runningTotal <= 0) { break; } } } if ($totalCouponDiscount > $subtotal) { $totalCouponDiscount = $subtotal; } if ($applyDiscountShipping) { $discountAmount = 0; $shippingAddresses = $this->getShippingAddresses(); if (!empty ($shippingAddresses)) { $discountRemaining = $coupon['couponamount']; // do check if each address has the ability to get the discount. foreach ($shippingAddresses as $shippingAddress) { $applyToAddress = true; if (!empty ($coupon['location_restricted'])) { try { $applyToAddress = $this->_isCouponValidByLocation($shippingAddress, (int)$coupon['couponid']); } catch(ISC_QUOTE_EXCEPTION $e) { throw $e; } } // if the coupon restricted by shipping methods if (!empty ($coupon['shipping_method_restricted'])) { $applyToAddress = $this->_isCouponValidByShippingMethod($shippingAddress, (int)$coupon['couponid']); } // apply the discount to the address if ($applyToAddress) { $shippingCost = $shippingAddress->getNonDiscountedShippingCost(true); $postDiscountRemaining = $shippingCost - $discountRemaining; if ($postDiscountRemaining < 0) { $discountRemaining -= $shippingCost; $discountAmount += $shippingCost; } else { $discountAmount += $discountRemaining; $discountRemaining -= $discountRemaining; } $shippingAddress->addDiscount('total-coupon', $discountAmount); if($discountRemaining <= 0) { break; } } } } $totalCouponDiscount = round($discountAmount, getConfig('DecimalPlaces')); } if ($applyFreeShipping) { $discountAmount = 0; $shippingAddresses = $this->getShippingAddresses(); if (!empty ($shippingAddresses)) { $discountRemaining = $coupon['couponamount']; // do check if each address has the ability to get the discount. foreach ($shippingAddresses as $shippingAddress) { $applyToAddress = true; if (!empty ($coupon['location_restricted'])) { $applyToAddress = $this->_isCouponValidByLocation($shippingAddress, (int)$coupon['couponid']); } // if the coupon restricted by shipping methods if (!empty ($coupon['shipping_method_restricted'])) { $applyToAddress = $this->_isCouponValidByShippingMethod($shippingAddress, (int)$coupon['couponid']); } // apply the discount to the address if ($applyToAddress) { $discountAmount += round($shippingAddress->getNonDiscountedShippingCost(true), getConfig('DecimalPlaces')); $shippingAddress->addDiscount('total-coupon', $discountAmount); } } } $totalCouponDiscount = round($discountAmount, getConfig('DecimalPlaces')); } if(!$appliesToQuote) { if ($shippingLocationUnapplied) { throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidCouponLocation'), ISC_QUOTE_EXCEPTION::COUPON_LOCATION_DOES_NOT_APPLY); } else if ($shippingMethodUnapplied) { throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidCouponMethod'), ISC_QUOTE_EXCEPTION::COUPON_METHOD_DOES_NOT_APPLY); } else { throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidCouponCode'), ISC_QUOTE_EXCEPTION::COUPON_DOES_NOT_APPLY); } } $coupon = array( 'id' => $coupon['couponid'], 'code' => $coupon['couponcode'], 'name' => $coupon['couponname'], 'discountType' => $coupon['coupontype'], 'discountAmount' => $coupon['couponamount'], 'expiresDate' => $coupon['couponexpires'], 'totalDiscount' => round($totalCouponDiscount, getConfig('DecimalPlaces')), ); $this->addCoupon($coupon); return $this; }
/** * @param TMasterSlaveDbConnectionForceMaster * @throws TDbException if no master connection exists */ public function setForceMaster($value) { if ($this->getMasterConnection() === null) { throw new TDbException('slavedbconnection_requires_master', getclass($this), 'MasterConnection'); } $this->getMasterConnection()->setForceMaster($value); }
<?php $dirname = dirname(__FILE__); defined('DS') or define('DS', DIRECTORY_SEPARATOR); require_once $dirname . '/helpers.php'; require_once $dirname . '/app/core/Loader.php'; require_once $dirname . '/app/libs/Smarty.class.php'; $basename = basename($dirname); $autoloader = new Loader(); $autoloader->register(); $class = getclass(); Bootstrap::app($class); function getclass() { $dirname = dirname(__FILE__); $basename = basename($dirname); return ucfirst($basename); }
/** * Insert $el into the list and make it as a head. * * @param mixed $val * @return void */ public function insert($val) { // Make sure element being inserted is type of Node. if (!is_object($val) || getclass($val) !== "Node") { $node = new Node($val); } else { $node = $val; } $this->_head->setPrev($node); $node->setNext($this->_head); $node->setPrev($this->_sentinel); $this->_head = $node; }
if (isset($_REQUEST['class'])) { $class = $_REQUEST['class']; } else { $class = null; } if (isset($_REQUEST['version'])) { $version = $_REQUEST['version']; } else { $version = null; } switch ($v) { case 'list': listclasses($uid); break; case 'get': getclass($class); break; case 'put': if (isset($_REQUEST['classname'])) { saveclass($uid, $classname, $version, $data, $class); } break; case 'delete': # code... break; default: # code... break; } } }
public function insert($val) { if (!is_object($val) || getclass($val) !== 'Node') { $newNode = new Node($val); } else { $newNode = $val; } $newNode->setLeft($this->_sentinel); $newNode->setRight($this->_sentinel); $node = $this->_root; $parent = $this->_sentinel; while ($node !== $this->_sentinel) { $parent = $node; if ($newNode->val() < $node->val()) { $node = $node->left(); } else { $node = $node->right(); } } if ($parent === $this->_sentinel) { $newNode->setParent($this->_sentinel); $this->_root = $newNode; } else { if ($newNode->val() < $parent->val()) { $parent->setLeft($newNode); } else { $parent->setRight($newNode); } $newNode->setParent($parent); } }