Exemplo n.º 1
0
 public function actionBulkCreate(array $names = array(), $parentId = 0, $vocabularyId = 0)
 {
     $vocabularyId = CPropertyValue::ensureInteger($vocabularyId);
     if (!$vocabularyId) {
         return errorHandler()->log('Missing Vocabulary Id');
     }
     foreach ($names as $catName) {
         $catName = trim($catName);
         if ($catName == '') {
             continue;
         }
         $model = new Term('single_save');
         $model->v_id = $vocabularyId;
         $model->name = $catName;
         $model->alias = Utility::createAlias($model, $model->name);
         $model->state = Term::STATE_ACTIVE;
         $model->parentId = $parentId;
         if (!$model->save()) {
             $this->result->fail(ERROR_HANDLING_DB, 'save category failed');
         } else {
             if ($model->parentId) {
                 $relation = TermHierarchy::model()->findByAttributes(array('term_id' => $model->id));
                 if (!is_object($relation)) {
                     $relation = new TermHierarchy();
                     $relation->term_id = $model->id;
                 }
                 $relation->parent_id = $model->parentId;
                 if (!$relation->save()) {
                     Yii::log(CVarDumper::dumpAsString($relation->getErrors()), CLogger::LEVEL_ERROR);
                 }
             }
         }
     }
 }
 public function testEnsureInteger()
 {
     $entries = array(array(123, 123), array(1.23, 1), array(null, 0), array('', 0), array('abc', 0), array('123', 123), array('1.23', 1), array(' 1.23', 1), array(' 1.23abc', 1), array('abc1.23abc', 0), array(true, 1), array(false, 0), array(array(), 0), array(array(0), 1));
     foreach ($entries as $index => $entry) {
         $this->assertTrue(CPropertyValue::ensureInteger($entry[0]) === $entry[1], "Comparison {$index}: {$this->varToString($entry[0])}=={$this->varToString($entry[1])}");
     }
 }
Exemplo n.º 3
0
 /**
  * This function generates the products grid
  * based on the criteria. It also generates the
  * pagination object need for the users to navigate
  * through products.
  *
  * @return void
  */
 public function generateProductGrid()
 {
     $this->_numberOfRecords = Product::model()->count($this->_productGridCriteria);
     $this->_pages = new CPagination($this->_numberOfRecords);
     $this->_pages->setPageSize(CPropertyValue::ensureInteger(Yii::app()->params['PRODUCTS_PER_PAGE']));
     $this->_pages->applyLimit($this->_productGridCriteria);
     $this->_productsGrid = self::createBookends(Product::model()->findAll($this->_productGridCriteria));
 }
Exemplo n.º 4
0
 public function getIsGuest()
 {
     $customer = Customer::model()->findByPk($this->id);
     if ($customer !== null) {
         return CPropertyValue::ensureInteger($customer->record_type) === Customer::GUEST;
     }
     return parent::getIsGuest();
 }
Exemplo n.º 5
0
 public function render($params = array())
 {
     $height = CPropertyValue::ensureInteger($params['height']);
     $height -= $height > 40 ? 20 : 0;
     parent::appendOption($this->_htmlOptions, 'class', $this->_cssClass);
     parent::appendOption($this->_htmlOptions, 'style', 'height: ' . $height . 'px;');
     echo CHtml::tag('li', $this->_htmlOptions, $this->_data);
 }
Exemplo n.º 6
0
 public function init()
 {
     parent::init();
     //find workflow by id
     $workflowId = app()->request->getParam('workflow_id', null);
     if ($workflowId !== null) {
         $this->setWorkflow(CPropertyValue::ensureInteger($workflowId));
     }
 }
Exemplo n.º 7
0
 public static function parseTree($objRet, $root = 0)
 {
     $return = array();
     # Traverse the tree and search for direct children of the root
     foreach ($objRet as $objItem) {
         if (CPropertyValue::ensureInteger($objItem->child_count) > 0 || CPropertyValue::ensureBoolean(Yii::app()->params['DISPLAY_EMPTY_CATEGORY'])) {
             $return[] = array('text' => CHtml::link($objItem->family, $objItem->Link), 'label' => $objItem->family, 'link' => $objItem->Link, 'request_url' => $objItem->request_url, 'url' => $objItem->Link, 'id' => $objItem->id, 'child_count' => $objItem->child_count, 'children' => null, 'items' => null);
         }
     }
     return empty($return) ? null : $return;
 }
Exemplo n.º 8
0
 /**
  * Responds to {@link CActiveRecord::onAfterSave} event.
  * Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
  * @param CModelEvent $event event parameter
  */
 public function afterSave($event)
 {
     $data = array();
     $objectId = $this->getOwner()->{$this->objectAttribute};
     if ($this->useActiveField) {
         $data = $this->getOwner()->{$this->name};
         if (!is_array($data) && !is_object($data)) {
             $data = array((int) $data);
         }
     } else {
         if (isset($_POST[$this->name])) {
             $data = $_POST[$this->name];
             if (!is_array($data) && !is_object($data)) {
                 $data = array((int) $data);
             }
         }
     }
     //delete old
     $sql = "DELETE FROM " . SITE_ID . '_' . "taxonomy_index t" . "\n USING " . SITE_ID . '_' . "taxonomy_term tt, " . SITE_ID . '_' . "taxonomy_vocabulary tv" . "\n WHERE tt.id = t.term_id AND tv.id = tt.v_id" . (is_numeric($this->taxonomy) ? "\n AND (tv.id = :id)" : "\n AND (tv.alias = :alias)") . "\n AND tv.module = :module AND t.object_id = :object_id";
     if (count($data)) {
         foreach ($data as $index => $val) {
             $data[$index] = CPropertyValue::ensureInteger($val);
         }
         $dataString = implode(',', $data);
         $sql .= "\n AND t.term_id NOT IN ({$dataString})";
     }
     $command = TermRelation::model()->getDbConnection()->createCommand($sql);
     if (is_numeric($this->taxonomy)) {
         $command->bindParam(":id", $this->taxonomy, PDO::PARAM_INT);
     } else {
         $command->bindParam(":alias", $this->taxonomy, PDO::PARAM_STR);
     }
     $command->bindParam(":module", $this->module, PDO::PARAM_STR);
     $command->bindParam(":object_id", $objectId, PDO::PARAM_INT);
     $command->execute();
     //update/create
     if (count($data)) {
         foreach ($data as $val) {
             $relation = TermRelation::model()->findByAttributes(array('object_id' => $objectId, 'term_id' => $val));
             if (!is_object($relation)) {
                 $relation = new TermRelation();
             }
             $relation->object_id = $objectId;
             $relation->term_id = $val;
             if (!$relation->save()) {
                 Yii::log(CVarDumper::dumpAsString($relation->getErrors()), CLogger::LEVEL_ERROR);
             }
         }
     }
 }
Exemplo n.º 9
0
 /**
  * @return void
  */
 public function actionIndex()
 {
     $model = new Tag('search');
     $model->userId = Yii::app()->user->id;
     /* @var CHttpRequest $request */
     $request = Yii::app()->request;
     if ($request->getQuery('pagesize') != null) {
         /* @var Setting $setting */
         $setting = Setting::model()->name(Setting::PAGINATION_PAGE_SIZE_TAGS)->find();
         $pageSize = CPropertyValue::ensureInteger($request->getQuery('pagesize'));
         if ($pageSize > 0) {
             $setting->value = $pageSize;
             $setting->save();
         }
     }
     if (isset($_GET['Tag'])) {
         $model->attributes = $_GET['Tag'];
     }
     $this->render('index', array('model' => $model));
 }
Exemplo n.º 10
0
 /**
  * Default action.
  *
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  *
  * @return void
  */
 public function actionIndex()
 {
     $homePage = _xls_get_conf('HOME_PAGE', '*products');
     switch ($homePage) {
         case "*index":
             if (Yii::app()->params['LIGHTSPEED_MT'] == '1') {
                 if (Yii::app()->theme->info->showCustomIndexOption) {
                     $this->render("/site/index");
                 } else {
                     $this->forward("search/browse");
                 }
             } else {
                 $this->render("/site/index");
             }
             break;
         case "*products":
             $this->forward("search/browse");
             break;
         default:
             //Custom Page
             $objCustomPage = CustomPage::LoadByKey($homePage);
             $productsGrid = null;
             $dataProvider = null;
             if (!$objCustomPage instanceof CustomPage) {
                 _xls_404();
             }
             $this->pageTitle = $objCustomPage->PageTitle;
             $this->pageDescription = $objCustomPage->meta_description;
             $this->pageImageUrl = '';
             $this->breadcrumbs = array($objCustomPage->title => $objCustomPage->RequestUrl);
             if (CPropertyValue::ensureInteger($objCustomPage->product_display) === 2) {
                 $productsGrid = new ProductGrid($objCustomPage->getProductGridCriteria());
             } else {
                 $dataProvider = $objCustomPage->taggedProducts();
             }
             $this->canonicalUrl = $objCustomPage->canonicalUrl;
             $this->render('/custompage/index', array('model' => $objCustomPage, 'dataProvider' => $dataProvider, 'productsGrid' => $productsGrid));
             break;
     }
 }
Exemplo n.º 11
0
 /**
  * activeDropDownList Taxonomy
  * 
  * @param string $name
  * @param string $taxonomy
  * @param string $module
  * @param int $objectId
  * @param array $htmlOptions
  */
 public static function activeDropDownList($model, $attribute, $taxonomy, $module, $htmlOptions = array())
 {
     $properties = array('model' => $model, 'attribute' => $attribute, 'taxonomy' => $taxonomy, 'module' => $module, 'objectId' => $model->getPrimaryKey());
     if (isset($htmlOptions['type'])) {
         $properties['type'] = CPropertyValue::ensureString($htmlOptions['type']);
         unset($htmlOptions['type']);
     }
     if (isset($htmlOptions['objectId'])) {
         $properties['objectId'] = CPropertyValue::ensureInteger($htmlOptions['objectId']);
         unset($htmlOptions['objectId']);
     }
     if (isset($htmlOptions['repeatChar'])) {
         $properties['repeatChar'] = CPropertyValue::ensureString($htmlOptions['repeatChar']);
         unset($htmlOptions['repeatChar']);
     }
     if (isset($htmlOptions['useRepeatChar'])) {
         $properties['useRepeatChar'] = CPropertyValue::ensureBoolean($htmlOptions['useRepeatChar']);
         unset($htmlOptions['useRepeatChar']);
     }
     $properties['htmlOptions'] = $htmlOptions;
     return Yii::app()->controller->widget('ListTaxonomy', $properties, true);
 }
 public function convertType($value)
 {
     $value = trim($value);
     if (ctype_digit($value)) {
         return CPropertyValue::ensureInteger($value);
     }
     if (is_numeric($value)) {
         return CPropertyValue::ensureFloat($value);
     }
     if (strcasecmp($value, 'null') == 0) {
         return null;
     } else {
         if (strcasecmp($value, 'true') == 0 || strcasecmp($value, 'false') == 0) {
             return CPropertyValue::ensureBoolean($value);
         } else {
             if (preg_match('/^\\(.+\\)|\\(\\)$/', $value)) {
                 return CPropertyValue::ensureArray($value);
             }
         }
     }
     return $value;
 }
 private function prepareOutput()
 {
     $preparedAttributes = array();
     foreach ($this->getAttributes() as $key => $value) {
         if (in_array($key, array('enableClientValidation', 'safe', 'skipOnError', 'allowEmpty'))) {
             $preparedAttributes[$key] = CPropertyValue::ensureBoolean($value);
         }
         if ($key === 'except' || $key === 'on') {
             if (!is_null($value)) {
                 $preparedAttributes[$key] = array_map('trim', explode(',', $value));
             }
         }
         if ($key === 'is' || $key === 'max' || $key === 'min') {
             if (!is_null($value)) {
                 $preparedAttributes[$key] = CPropertyValue::ensureInteger($value);
             } else {
                 $preparedAttributes[$key] = null;
             }
         }
     }
     return $preparedAttributes;
 }
Exemplo n.º 14
0
 /**
  * @throws CHttpException
  * @return void
  */
 public function actionSetSidebarPositions()
 {
     // only ajax-request are allowed
     if (!Yii::app()->request->isAjaxRequest) {
         throw new CHttpException(400);
     }
     $neededParams = array(Setting::MOST_VIEWED_ENTRIES_WIDGET_POSITION, Setting::RECENT_ENTRIES_WIDGET_POSITION, Setting::TAG_CLOUD_WIDGET_POSITION);
     // check if all needed params exist
     foreach ($neededParams as $paramName) {
         if (!isset($_POST[$paramName])) {
             throw new CHttpException(401);
         }
     }
     // save settings
     foreach ($neededParams as $paramName) {
         /* @var Setting $model */
         $param = CPropertyValue::ensureInteger($_POST[$paramName]);
         $model = Setting::model()->findByAttributes(array('name' => $paramName));
         $model->value = $param;
         $model->save();
     }
     echo '1';
 }
Exemplo n.º 15
0
 /**
  * Build array combining product categories, families and Custom Pages.
  *
  * @return array
  */
 public function getMenuTree()
 {
     $categoryTree = Category::GetTree();
     $extraTopLevelItems = CustomPage::GetTree();
     // Whether the families (aka. manufacturers) are displayed the product menu.
     // ENABLE_FAMILIES:
     //	0     => No families in the product menu.
     //	1     => Separate menu item at bottom of product menu.
     //	2     => Separate menu item at top of product menu.
     //	3     => Blended into the top level of the menu.
     //
     if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) > 0) {
         $familyTree = Family::GetTree();
         if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 3) {
             $extraTopLevelItems += $familyTree;
         }
     }
     // The behaviour varies here because OnSite customers are able to
     // configure the menu_position of their categories. A more thorough
     // solution might modify the menu code to return the menu_position for
     // each menu item for sorting, however Categories should already be
     // sorted by menu_position.
     if (CPropertyValue::ensureInteger(Yii::app()->params['LIGHTSPEED_CLOUD']) !== 0) {
         // Retail: Sort the entire menu alphabetically.
         $objTree = $categoryTree + $extraTopLevelItems;
         ksort($objTree);
     } else {
         // OnSite: Only sort the extras alphabetically (categories are
         // already sorted by menu_position).
         ksort($extraTopLevelItems);
         $objTree = $categoryTree + $extraTopLevelItems;
     }
     if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 1 || CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 2) {
         $familyMenu['families_brands_menu'] = array('text' => CHtml::link(Yii::t('category', Yii::app()->params['ENABLE_FAMILIES_MENU_LABEL']), $this->createUrl("search/browse", array('brand' => '*'))), 'label' => Yii::t('category', Yii::app()->params['ENABLE_FAMILIES_MENU_LABEL']), 'link' => $this->createUrl("search/browse", array('brand' => '*')), 'url' => $this->createUrl("search/browse", array('brand' => '*')), 'id' => 0, 'child_count' => count($familyTree), 'hasChildren' => 1, 'children' => $familyTree, 'items' => $familyTree);
         if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 1) {
             // The manufacturers menu is at the bottom.
             $objTree = $objTree + $familyMenu;
         } elseif (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 2) {
             // The manufacturers menu is at the top.
             $objTree = $familyMenu + $objTree;
         }
     }
     $this->_objFullTree = $objTree;
     return $this->_objFullTree;
 }
Exemplo n.º 16
0
 public function actionAddress()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/myaccount"));
     }
     $this->breadcrumbs = array(Yii::t('global', 'My Account') => $this->createUrl("/myaccount"), Yii::t('global', 'Add an address') => $this->createUrl("myaccount/address"));
     $model = new CustomerAddress();
     $model->country_id = _xls_get_conf('DEFAULT_COUNTRY', 224);
     $checkout = new CheckoutForm();
     //For logged in users we grab the current model
     $objCustomer = Customer::GetCurrent();
     $id = null;
     if (Yii::app()->getRequest()->getParam('id') != null) {
         $id = Yii::app()->getRequest()->getParam('id');
     } elseif (isset($_POST['CustomerAddress']) && isset($_POST['CustomerAddress']['id'])) {
         $id = $_POST['CustomerAddress']['id'];
     }
     $objAddress = CustomerAddress::model()->findByPk($id);
     if ($id && $objAddress instanceof CustomerAddress && $objAddress->customer_id == Yii::app()->user->id) {
         $model = $objAddress;
     }
     // collect user input data
     if (isset($_POST['CustomerAddress'])) {
         $model->setScenario('Default');
         $model->attributes = $_POST['CustomerAddress'];
         if ($model->validate()) {
             $model->customer_id = $objCustomer->id;
             if (!$model->save()) {
                 Yii::log('Error creating new customer address ' . print_r($model->getErrors(), true), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
             }
             if (CPropertyValue::ensureBoolean($model->makeDefaultBilling) === true) {
                 $objCustomer->default_billing_id = $model->id;
             } elseif (CPropertyValue::ensureInteger($objCustomer->default_billing_id) === CPropertyValue::ensureInteger($model->id)) {
                 $objCustomer->default_billing_id = null;
             }
             if (CPropertyValue::ensureBoolean($model->makeDefaultShipping) === true) {
                 $objCustomer->default_shipping_id = $model->id;
             } elseif (CPropertyValue::ensureInteger($objCustomer->default_shipping_id) === CPropertyValue::ensureInteger($model->id)) {
                 $objCustomer->default_shipping_id = null;
             }
             $objCustomer->save();
             ShoppingCart::displayNoTaxMessage();
             try {
                 Yii::app()->shoppingcart->setTaxCodeByDefaultShippingAddress();
             } catch (Exception $e) {
                 Yii::log('Error updating customer cart ' . $e->getMessage(), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
             }
             Yii::app()->shoppingcart->save();
             if (Yii::app()->request->isAjaxRequest === false) {
                 $this->redirect($this->createUrl("/myaccount"));
             }
         }
     }
     if ($id && $objCustomer->default_billing_id == $model->id) {
         $model->makeDefaultBilling = 1;
     }
     if ($id && $objCustomer->default_shipping_id == $model->id) {
         $model->makeDefaultShipping = 1;
     }
     // Added Ajax for Brooklyn2014
     if (Yii::app()->request->isAjaxRequest) {
         unset($model->password);
         $errors = $model->getErrors();
         if (empty($errors) === false) {
             $response = array('status' => 'error', 'errors' => $errors);
         } else {
             $response = array('status' => 'success', 'address' => $model);
         }
         $this->renderJSON($response);
     } else {
         $this->render('address', array('model' => $model, 'checkout' => $checkout));
     }
 }
Exemplo n.º 17
0
                            <?php 
        echo $item->priority != 1 ? "<div class=\"comment\">" . $item->Priority . "</div>" : "";
        ?>
                        </div>
                        <div class="link">
                            <?php 
        if (is_null($item->cart_item_id) && $item->product->IsAddable) {
            echo CHtml::ajaxLink(Yii::t('product', 'Add to Cart'), array('cart/AddToCart'), array('data' => array('id' => $item->product_id, 'qty' => $item->qty, 'wishid' => $item->id), 'type' => 'POST', 'dataType' => 'json', 'success' => 'js:function(data){
			                    if (data.action=="alert") {
			                      alert(data.errormsg);
								} else if (data.action=="success") {
									$("#shoppingcart").html(data.shoppingcart);
					                $("#addToCart' . $item->id . '").prop("disabled", true);
					                $("#addToCart' . $item->id . '").addClass("disabled");
					                $("#addToCart' . $item->id . '").html(data.purchaseStatus);
					                var afterAddCart = ' . CJSON::encode(CPropertyValue::ensureInteger(_xls_get_conf('AFTER_ADD_CART'))) . ';
					                var validPurchaseStatus = "' . Yii::t("wishlist", "Being Purchased") . '";
									if (data.purchaseStatus === validPurchaseStatus)
									{
										if (afterAddCart === 1)
										{
											window.location.href = "' . Yii::app()->createUrl("/editcart") . '";
										}
										else
										{
											$("#shoppingcart").replaceWith(data.shoppingcart);
											$("#cartItemsTotal").text(data.totalItemCount);
											sleep(250, showModal);
										}
					                }
					        }}'), array('id' => 'addToCart' . $item->id, 'class' => 'addcart no-selection'));
Exemplo n.º 18
0
Arquivo: mics.php Projeto: hung5s/yap
function aesDecrypt($data, $encode = 'url')
{
    if ($data == CPropertyValue::ensureInteger($data) . '') {
        //xmail('Decrypting data which is not encrypted', app()->request->requestUri, SETTINGS_DEV_EMAILS);
        return $data;
    }
    $key = hasParam('SETTINGS_AES_ENCRYPT_IV', 'aninditioncmskey');
    Yii::import('Xpress.extensions.vendors.encryption.AES_Encryption');
    $aes = new AES_Encryption(hasParam('SETTINGS_AES_ENCRYPT_KEY', '5682825638385896'), $key);
    switch ($encode) {
        case 'url':
            $data = base64_decode(strtr($data, array('-' => '+', '_' => '/')));
            break;
        case 'base64':
            $data = base64_decode($data);
            break;
    }
    return $aes->decrypt($data);
}
Exemplo n.º 19
0
 /**
  * The "thank you" page, which also serves as the receipt page.
  *
  * This page contains a form which allows a guest customer to turn their
  * account into a normal one.
  *
  * @return void
  * @throws CHttpException
  */
 public function actionThankyou()
 {
     $strLink = Yii::app()->getRequest()->getQuery('linkid');
     // Redirect to homepage if there is no link id.
     if (empty($strLink)) {
         $this->redirect($this->createAbsoluteUrl("/", array(), 'http'));
     }
     // redirect to old receipt in the rare case Web Store is back on an old theme
     if (Yii::app()->theme->info->advancedCheckout === false) {
         $this->redirect($this->createAbsoluteUrl('/cart/receipt', array('getuid' => $strLink)));
     }
     $objCart = Cart::model()->findByAttributes(array('linkid' => $strLink));
     if ($objCart instanceof Cart === false) {
         _xls_404();
     }
     // Send any emails we may still have.
     Checkout::sendEmails($objCart->id);
     $customer = Customer::model()->findByPk(Yii::app()->user->id);
     // In order to upgrade from GUEST to NORMAL_USER there mustn't already
     // be a normal user with this email address.
     $registeredCustomerWithSameEmail = null;
     if ($customer !== null) {
         $registeredCustomerWithSameEmail = Customer::model()->findByAttributes(array('record_type' => Customer::NORMAL_USER, 'email' => $customer->email));
     }
     // Whether to show the createNewAccount section.
     // SSL is required for this, but is enforced by CheckoutController::beforeAction.
     $canCreateNewAccount = $customer !== null && $objCart !== null && $objCart->customer !== null && $customer->id === $objCart->customer->id && CPropertyValue::ensureInteger($customer->record_type) === Customer::GUEST && $registeredCustomerWithSameEmail === null;
     // Whether to show the "your account has been created" message.
     $showAccountCreated = false;
     // Possibility for guests to register for normal account.
     if ($canCreateNewAccount) {
         $customer->scenario = Customer::SCENARIO_UPDATEPASSWORD;
         if (isset($_POST['Customer'])) {
             $customer->password = $_POST['Customer']['password'];
             $customer->password_repeat = $_POST['Customer']['password_repeat'];
             $customer->record_type = Customer::NORMAL_USER;
             $customer->allow_login = Customer::NORMAL_USER;
             if ($customer->validate() === true) {
                 $customer->save();
                 $showAccountCreated = true;
                 $canCreateNewAccount = false;
             } else {
                 $this->checkoutForm->addErrors($customer->getErrors());
             }
         }
     }
     $this->layout = '/layouts/checkout-confirmation';
     $this->render('thankyou', array('cart' => $objCart, 'model' => $customer, 'showCreateNewAccount' => $canCreateNewAccount, 'showAccountCreated' => $showAccountCreated, 'arrError' => $this->formatErrors()));
 }
Exemplo n.º 20
0
<?php

Yii::app()->clientScript->registerScript('instantiate Product', '$(document).ready(function () {
			var options =' . CJSON::encode(array('afterAddCart' => CPropertyValue::ensureInteger(_xls_get_conf('AFTER_ADD_CART')), 'editCartUrl' => Yii::app()->createUrl('/editcart'), 'addToWishListUrl' => Yii::app()->createUrl('/wishlist/add'), 'addToCartUrl' => Yii::app()->createUrl('/cart/AddToCart'), 'isAddable' => $model->getIsAddable(), 'isMaster' => $model->IsMaster, 'id' => $model->id, 'qty' => CHtml::activeId($model, 'intQty'))) . '
			product = new Product(options);
		});', CClientScript::POS_END);
?>

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'product'));
//Note we used form-named DIVs with the Yii CHtml::tag() command so our javascript
// can update fields when choosing matrix items
?>
	<div id="product_details">
		<div class="row-fluid">
			<div class="span5 product_detail_image">
				<div id="photos">
					<?php 
echo $this->renderPartial('/product/_photos', array('model' => $model), true);
?>
				</div>
				<div class="row-fluid">
					<?php 
if (_xls_get_conf('SHOW_SHARING')) {
    echo $this->renderPartial('/site/_sharing_tools', array('product' => $model), true);
}
?>
				</div>
			</div>
			<div class="span7">
				<div class="row productheader">
Exemplo n.º 21
0
 /**
  * @param string $name
  * @return integer
  */
 public function getAsInteger($name)
 {
     return CPropertyValue::ensureInteger($this->get($name));
 }
Exemplo n.º 22
0
<div id="custom_content" class="col-sm-12">
	<?php 
echo $model->page;
?>
</div>

<?php 
if (CPropertyValue::ensureInteger($model->product_display) === CustomPage::PRODUCT_DISPLAY_GRID) {
    ?>
	<?php 
    $this->renderPartial('/custompage/_grid', array('productsGrid' => $productsGrid));
} else {
    ?>
<div class="col-sm-9 clearfix">
	<?php 
    $this->widget('ext.JCarousel.JCarousel', array('dataProvider' => $model->taggedProducts(), 'thumbUrl' => '$data->SliderImage', 'imageUrl' => '$data->Link', 'emptyText' => '', 'altText' => '$data->Title', 'titleText' => '$data->Title', 'captionText' => '$data->Title."<br>"._xls_currency($data->Price)', 'target' => 'do-not-delete-this', 'visible' => true, 'skin' => 'slider', 'clickCallback' => 'window.location.href=itemSrc;'));
    ?>
</div>
<?php 
}
Exemplo n.º 23
0
 /**
  * Erase expired carts and their associated items.
  * A cart is considered expired if
  *	1. it was last modified over CART_LIFE days ago AND
  *	2. it has no id_str associated with it AND
  *	3. it is of type cart, giftregistry or awaitpayment AND
  *	4. it has no items in it OR
  *	5. it has no customer_id associated with it
  *
  *	1. AND 2. AND 3. AND (4. OR 5.)
  *
  * @return int The number of carts + items that were erased.
  */
 public static function eraseExpired()
 {
     // Erase carts older than CART_LIFE days.
     $cartLife = CPropertyValue::ensureInteger(_xls_get_conf('CART_LIFE', 30));
     // We can't use the class constants directly in the call to
     // bindParam(), put them in variables first.
     $cartType = CPropertyValue::ensureInteger(CartType::cart);
     $giftRegistryType = CPropertyValue::ensureInteger(CartType::giftregistry);
     $awaitPaymentType = CPropertyValue::ensureInteger(CartType::awaitpayment);
     $deleteSql = "\n\t\t\tDELETE c, ci\n\t\t\tFROM xlsws_cart c\n\t\t\tLEFT JOIN xlsws_cart_item ci\n\t\t\tON c.id = ci.cart_id\n\t\t\tWHERE\n\t\t\t\t(c.customer_id IS NULL OR ci.id IS NULL) AND\n\t\t\t\t(c.cart_type IN (:cart, :giftregistry, :awaitpayment) AND\n\t\t\t\tc.modified < CURDATE() - INTERVAL :cartlife DAY AND\n\t\t\t\tc.id_str IS NULL)";
     $deleteCommand = Yii::app()->db->createcommand($deleteSql);
     $deleteCommand->bindparam(":cart", $cartType, PDO::PARAM_INT);
     $deleteCommand->bindparam(":giftregistry", $giftRegistryType, PDO::PARAM_INT);
     $deleteCommand->bindparam(":awaitpayment", $awaitPaymentType, PDO::PARAM_INT);
     $deleteCommand->bindparam(":cartlife", $cartLife, PDO::PARAM_INT);
     $transaction = Yii::app()->db->beginTransaction();
     try {
         Yii::app()->db->createCommand("set foreign_key_checks = 0")->execute();
         $numErased = $deleteCommand->execute();
         Yii::app()->db->createCommand("set foreign_key_checks = 1")->execute();
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollback();
     }
     return $numErased;
 }
Exemplo n.º 24
0
 public function registerCssFile($url, $media = '', $order = 0)
 {
     $order = CPropertyValue::ensureInteger($order);
     if ($order) {
         $this->orderCssFiles[$url] = $order;
     }
     return parent::registerCssFile($url, $media);
 }
Exemplo n.º 25
0
 /**
  * Set the Gravatar image size. You may request images anywhere from 1px up to 512px,
  * however note that many users have lower resolution images, so requesting larger
  * sizes may result in pixelation/low-quality images.
  * By default, images are represented at 80px by 80px if no size parameter is supplied.
  * @see http://en.gravatar.com/site/implement/images/#size
  * @param integer $value the Gravatar image size
  */
 public function setSize($value)
 {
     $value = CPropertyValue::ensureInteger($value);
     if ($value < 1 || $value > 512) {
         throw new CException(Yii::t('application', 'Invalid Gravatar size value "{value}". Please make sure it is between {min} and {max} (inclusive).', array('{value}' => $value, '{min}' => 1, '{max}' => 512)));
     }
     $this->_size = $value;
 }
Exemplo n.º 26
0
 /**
  * Short Description.
  *
  * @return void
  */
 public function actionEdit()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     $model = Configuration::model()->findAllByAttributes(array('configuration_type_id' => $id), array('order' => 'sort_order'));
     if ($this->IsCloud) {
         $model = $this->sanitizeEditModule($model, 'Cloud');
     }
     if ($this->IsMT) {
         $model = $this->sanitizeEditModule($model, 'MT');
     }
     if ($this->isHosted) {
         $model = $this->sanitizeEditModule($model, 'Hosted');
     }
     if (isset($_POST['Configuration'])) {
         $valid = true;
         foreach ($model as $i => $item) {
             if (isset($_POST['Configuration'][$i])) {
                 $item->attributes = $_POST['Configuration'][$i];
             }
             if ($item->key_name == 'LANG_MENU' && $item->key_value == 1) {
                 $itemLanguages = $model[2];
                 $itemLanguages->attributes = $_POST['Configuration'][2];
                 if (empty($itemLanguages->key_value)) {
                     $valid = false;
                 }
             }
             if ($item->options == "INT") {
                 if ((int) $item->key_value) {
                     $valid = true;
                 } else {
                     $valid = false;
                 }
             }
             if ($item->options == "EMAIL") {
                 $valid = $this->validateEmail($item) && $valid;
             } else {
                 $valid = $item->validate() && $valid;
             }
             if (!$valid) {
                 if ($item->options == 'EMAIL') {
                     Yii::app()->user->setFlash('error', $item->title . ' is not a valid email address');
                 } elseif ($item->key_name == 'LANG_MENU') {
                     Yii::app()->user->setFlash('error', 'Languages field cannot be empty when language menu is enabled');
                 } elseif ($item->options == "INT") {
                     Yii::app()->user->setFlash('error', $item->title . ': ' . 'Only numbers are allowed', true);
                 } else {
                     $err = $item->getErrors();
                     Yii::app()->user->setFlash('error', $item->title . ' -- ' . print_r($err['key_value'][0], true));
                 }
                 break;
             }
         }
         if ($valid) {
             foreach ($model as $i => $item) {
                 $item->attributes = $_POST['Configuration'][$i];
                 if ($item->options == "PASSWORD") {
                     $item->key_value = _xls_encrypt($item->key_value);
                 }
                 if ($item->save() === false) {
                     Yii::app()->user->setFlash('error', print_r($item->getErrors(), true));
                 } else {
                     Yii::app()->user->setFlash('success', Yii::t('admin', 'Configuration updated on {time}.', array('{time}' => date('d F, Y  h:i:sa'))));
                     $item->postConfigurationChange();
                 }
                 if ($item->key_name == 'EMAIL_TEST' && $item->key_value == 1) {
                     $this->sendEmailTest();
                 }
             }
         }
     }
     foreach ($model as $i => $item) {
         if ($item->options == 'BOOL') {
             $this->registerOnOff($item->id, "Configuration_{$i}_key_value", $item->key_value);
         }
         if ($item->options == 'PASSWORD') {
             $model[$i]->key_value = _xls_decrypt($model[$i]->key_value);
         }
         $model[$i]->title = Yii::t('admin', $item->title, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
         $model[$i]->helper_text = Yii::t('admin', $item->helper_text, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
     }
     /*
      * http://www.yiiframework.com/doc/api/1.1/CModel#generateAttributeLabel-detail
      *
      * Unless we define the label attribute in activeLabelEx htmlOptions in the view,
      * the label will be generated when it calls CModel::generateAttributeLabel().
      * This is a problem for the labels we want to display on pages like the Google Integration
      * page that have labels which deliberately require dashes and camel-case formatting.
      */
     $defineLabel = false;
     switch (CPropertyValue::ensureInteger($id)) {
         case 20:
             // IntegrationController::GOOGLE = 20
             $defineLabel = true;
             break;
         default:
             break;
     }
     $this->render('admin.views.default.edit', array('model' => $model, 'defineLabel' => $defineLabel));
 }
 public function setCountLimit($value)
 {
     $this->_countLimit = CPropertyValue::ensureInteger($value);
 }
Exemplo n.º 28
0
 /**
  * This function returns the regular price of a product if its web price was set lower than
  * its regular price. If the web price is not lower than the regular price this function
  * returns 'null'.
  *
  * @param int $intQuantity
  * @return null|string
  */
 public function getSlashedPriceValue($intQuantity = 1)
 {
     if (CPropertyValue::ensureInteger(Yii::app()->params['PRICE_REQUIRE_LOGIN']) === 1 && Yii::app()->user->IsGuest) {
         return null;
     }
     $taxInclusive = Yii::app()->shoppingcart->IsTaxIn;
     if ($this->IsMaster()) {
         $childProducts = $this->getChildProducts();
         if (count($childProducts) == 0) {
             return _sp("Missing Child Products?");
         }
         switch (_xls_get_conf('MATRIX_PRICE')) {
             case Product::HIGHEST_PRICE:
                 //Show Highest Price
                 return end($childProducts)->getSell() > end($childProducts)->getPriceValue($intQuantity, $taxInclusive) ? end($childProducts)->getSell() : null;
             case Product::PRICE_RANGE:
                 $low = $childProducts[0]->getPriceValue($intQuantity, $taxInclusive);
                 $high = end($childProducts)->getPriceValue($intQuantity, $taxInclusive);
                 // If the price range returns a single value we can display
                 // the slashed price.
                 if ($low == $high && end($childProducts)->getSell() > $high) {
                     return end($childProducts)->getSell();
                 }
                 return null;
             case Product::CLICK_FOR_PRICING:
                 return $this->getSell() > $this->getPriceValue($intQuantity, $taxInclusive) ? $this->getSell() : null;
             case Product::LOWEST_PRICE:
                 return $childProducts[0]->getSell() > $childProducts[0]->getPriceValue($intQuantity, $taxInclusive) ? $childProducts[0]->getSell() : null;
             case Product::MASTER_PRICE:
             default:
                 return $this->getSell() > $this->getPriceValue($intQuantity, $taxInclusive) ? $this->getSell() : null;
         }
     } else {
         return $this->getSell() > $this->getPriceValue($intQuantity, $taxInclusive) ? $this->getSell() : null;
     }
 }
Exemplo n.º 29
0
 public function setHeight($value)
 {
     $this->height = CPropertyValue::ensureInteger($value);
 }
Exemplo n.º 30
0
 /**
  * @param mixed $message error message or a CModel object that has errors
  * @param int    $code Use different codes for different errors
  */
 public function __construct($message, $code = 0)
 {
     if ($code === 0) {
         $code = self::ERR_BUSINESS_EXCEPTION;
     }
     if ($message instanceof CModel) {
         $message = CHtml::errorSummary($message, '');
     }
     // we don't use the code from PHP's Exception object
     parent::__construct($message, CPropertyValue::ensureInteger($code));
     $this->errorCode = $code;
     $this->message = $message;
 }