function display($tpl = null) { global $mainframe; // Check if registration is allowed $usersConfig = JComponentHelper::getParams('com_users'); if (!$usersConfig->get('allowUserRegistration')) { JError::raiseError(403, JText::_('COM_TIENDA_ACCESS_FORBIDDEN')); return; } $pathway = $mainframe->getPathway(); $document = JFactory::getDocument(); $params =& $mainframe->getParams(); // Page Title $menus = JSite::getMenu(); $menu = $menus->getActive(); // because the application sets a default page title, we need to get it // right from the menu item itself if (is_object($menu)) { $menu_params = new DSCParameter($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', JText::_('COM_TIENDA_REGISTRATION')); } } else { $params->set('page_title', JText::_('COM_TIENDA_REGISTRATION')); } $document->setTitle($params->get('page_title')); $pathway->addItem(JText::_('COM_TIENDA_NEW')); // Load the form validation behavior JHTML::_('behavior.formvalidation'); $user = JFactory::getUser(); $this->assignRef('user', $user); $this->assignRef('params', $params); parent::display($tpl); }
/** * Display function * * @since 1.5 */ function display($tpl = null) { jimport('joomla.html.html'); $mainframe = JFactory::getApplication(); // Get the page/component configuration $params =& $mainframe->getParams(); $menus = JSite::getMenu(); $menu = $menus->getActive(); // because the application sets a default page title, we need to get it // right from the menu item itself if (is_object($menu)) { $menu_params = new DSCParameter($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', JText::_('COM_TIENDA_FORGOT_YOUR_USERNAME')); } } else { $params->set('page_title', JText::_('COM_TIENDA_FORGOT_YOUR_USERNAME')); } $document = JFactory::getDocument(); $document->setTitle($params->get('page_title')); // Load the form validation behavior JHTML::_('behavior.formvalidation'); // Add the tooltip behavior JHTML::_('behavior.tooltip'); $this->assignRef('params', $params); parent::display($tpl); }
function _displayForm($tpl = null) { global $mainframe; // Load the form validation behavior JHTML::_('behavior.formvalidation'); $user = JFactory::getUser(); $params = $mainframe->getParams(); // check to see if Frontend User Params have been enabled $usersConfig = JComponentHelper::getParams('com_users'); $check = $usersConfig->get('frontend_userparams'); if ($check == '1' || $check == 1 || $check == NULL) { if ($user->authorize('com_user', 'edit')) { $params = $user->getParameters(true); } } $params->merge($params); $menus = JSite::getMenu(); $menu = $menus->getActive(); // because the application sets a default page title, we need to get it // right from the menu item itself if (is_object($menu)) { $menu_params = new DSCParameter($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', JText::_('COM_CITRUSCART_EDIT_YOUR_DETAILS')); } } else { $params->set('page_title', JText::_('COM_CITRUSCART_EDIT_YOUR_DETAILS')); } $document = JFactory::getDocument(); $document->setTitle($params->get('page_title')); $this->assignRef('user', $user); $this->assignRef('params', $params); parent::display($tpl); }
public function getItem($id = 'en-GB', $refresh = false, $emptyState = true) { if (empty($this->_item)) { $lang = JLanguage::getInstance($id); // Load only site language (Email language costants should be only there) $lang->load('com_citruscart', JPATH_ADMINISTRATOR, $id, true); $temp_paths = $lang->getPaths('com_citruscart'); foreach ($temp_paths as $p => $k) { $path = $p; } $result = new JObject(); $result->name = $lang->getName(); $result->code = $lang->getTag(); $result->path = $path; $result->strings = array(); // Load File and Take only the constants that contains "EMAIL_" $file = new DSCParameter(); $file->loadFile($path); $strings = $file->toArray(); $result_strings = array(); foreach ($strings as $k => $v) { // Only if it is a prefix! if (stripos($k, $this->email_prefix) === 0) { $result_strings[$k] = $v; } } $result->strings = array('file' => $path, 'strings' => $result_strings); JFactory::getApplication()->triggerEvent('onPrepare' . $this->getTable()->get('_suffix'), array(&$result)); $this->_item = $result; } return $this->_item; }
public function getName($item = null) { if (!empty($item) && is_numeric($item)) { $this->load($item); } elseif (is_object($item) || is_array($item)) { $this->bind($item); } $params = new DSCParameter($this->params); if ($params->get('label')) { return $params->get('label'); } return $this->name; }
/** * Displays the Tienda add to cart button * * @param $row * @param $user * @return unknown_type */ function displayCartButton($row, $user) { $params = new DSCParameter(trim($row->params)); $product_id = $params->get('tienda_product_id'); JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('Products', 'TiendaModel'); $model->setId($product_id); $product = $model->getItem(); if (!empty($product_id) && !empty($product->product_id)) { Tienda::load('TiendaHelperProduct', 'helpers.product'); if ($this->params->get('redirect_to_tienda') == '1') { Tienda::load("TiendaHelperRoute", 'helpers.route'); $router = new TiendaHelperRoute(); $link = $router->product($eventproduct->product_id); $redirect = JRoute::_($link, false); $app = JFactory::getApplication(); $app->redirect($redirect); return; } // set the redirect if ($this->params->get('redirect_back_to_ambrasubs') == '1') { $uri = JURI::getInstance(); $redirect = $uri->toString(); $return = ''; } else { Tienda::load("TiendaHelperRoute", 'helpers.route'); $router = new TiendaHelperRoute(); $itemid = $router->findItemid(array('view' => 'checkout')); $redirect = JRoute::_("index.php?option=com_tienda&view=carts&Itemid=" . $itemid, false); $uri = JURI::getInstance(); $return = $uri->toString(); } $vars->redirect = $redirect; $vars->return = $return; $vars->ambrasubs_type = $row; $vars->product = $product; echo $this->_getLayout('product_buy', $vars, $this->_element, 'ambrasubs'); } }
/** * Display function * * @since 1.5 */ function display($tpl = null) { jimport('joomla.html.html'); global $mainframe; // Load the form validation behavior JHTML::_('behavior.formvalidation'); // Add the tooltip behavior JHTML::_('behavior.tooltip'); // Get the layout $layout = $this->getLayout(); if ($layout == 'complete') { $id = $mainframe->getUserState($this->_namespace . 'id'); $token = $mainframe->getUserState($this->_namespace . 'token'); if (is_null($id) || is_null($token)) { $mainframe->redirect('index.php?option=com_user&view=reset'); } } // Get the page/component configuration $params =& $mainframe->getParams(); $menus = JSite::getMenu(); $menu = $menus->getActive(); // because the application sets a default page title, we need to get it // right from the menu item itself if (is_object($menu)) { $menu_params = new DSCParameter($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', JText::_('COM_TIENDA_FORGOT_YOUR_PASSWORD')); } } else { $params->set('page_title', JText::_('COM_TIENDA_FORGOT_YOUR_PASSWORD')); } $document = JFactory::getDocument(); $document->setTitle($params->get('page_title')); $this->assignRef('params', $params); parent::display($tpl); }
/** * * Retrieves a product's custom fields from the product_params column * in as an array of CustomField objects so that the rendering of the * custom fields can be on typed objects. * @param $product_id */ function getCustomFields($product_id) { if (empty($product_id)) { return array(); } JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('Products', 'TiendaModel'); $model->setId($product_id); $item = $model->getItem(); if (empty($item)) { return null; } $product_param = new DSCParameter(trim($item->product_params)); //todo: remove the items that are not custom fields if (empty($product_param)) { return array(); } $params = $product_param->toArray(); $custom_fields = null; foreach ($params as $key => $value) { if (strpos($key, 'custom_field') !== false) { if ($custom_fields == null) { $custom_fields = array(); } $custom_field = array(); $field_properties = explode(",", $value); foreach ($field_properties as $field_property) { $property_pair = explode(":", $field_property); if (!empty($property_pair)) { $custom_field[trim($property_pair[0])] = trim($property_pair[1]); } } $custom_field["id"] = $key; array_push($custom_fields, (object) $custom_field); } } return $custom_fields; }
/** * Changes the value of a boolean in the database * Expects the task to be in the format: {field}_{action} * where {field} = the name of the field in the database * and {action} is either switch/enable/disable * * @return unknown_type */ function boolean() { $error = false; $this->messagetype = ''; $this->message = ''; $redirect = 'index.php?option=com_tienda&view=' . $this->get('suffix'); $redirect = JRoute::_($redirect, false); $model = $this->getModel($this->get('suffix')); $row = $model->getTable(); $cids = JRequest::getVar('cid', array(0), 'post', 'array'); $task = JRequest::getVar('shippingTask'); $id = JRequest::getInt('id'); $vals = explode('.', $task); $field = $vals['0']; $action = $vals['1']; $database = JFactory::getDBO(); $query = "SELECT `params` FROM `#__plugins` WHERE `id` = '{$id}'"; $database->setQuery($query); $jparams = new DSCParameter($database->loadObject()->params); foreach (@$params_arr as $param => $val) { $jparams->set($param, $val); } $query = "UPDATE `#__plugins` SET `params`= '" . $jparams->toString() . "' WHERE `id`= '{$plg_id}'"; $database->setQuery($query); switch (strtolower($action)) { case "switch": $switch = '1'; break; case "disable": $enable = '0'; $switch = '0'; break; case "enable": $enable = '1'; $switch = '0'; break; default: $this->messagetype = 'notice'; $this->message = JText::_('COM_TIENDA_INVALID_TASK'); $this->setRedirect($redirect, $this->message, $this->messagetype); return; break; } if (!in_array($field, array_keys($row->getProperties()))) { $this->messagetype = 'notice'; $this->message = JText::_('COM_TIENDA_INVALID_FIELD') . ": {$field}"; $this->setRedirect($redirect, $this->message, $this->messagetype); return; } foreach (@$cids as $cid) { unset($row); $row = $model->getTable(); $row->load($cid); switch ($switch) { case "1": $row->{$field} = $row->{$field} ? '0' : '1'; break; case "0": default: $row->{$field} = $enable; break; } if (!$row->save()) { $this->message .= $row->getError(); $this->messagetype = 'notice'; $error = true; } } if ($error) { $this->message = JText::_('COM_TIENDA_ERROR') . ": " . $this->message; } else { $this->message = JText::_('COM_TIENDA_STATUS_CHANGED'); } $this->setRedirect($redirect, $this->message, $this->messagetype); }
/** * Method to count the number of plugin assigned to a geozone * @param obj $geozone * @return int */ public static function countPlgtoGeozone($geozone) { $count = 0; if (!is_object($geozone)) { return $count; } static $plugins; static $geozones; if (empty($plugins[$geozone->geozonetype_id])) { $suffix = CitruscartHelperPlugin::getSuffix($geozone->geozonetype_id); JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = JModelLegacy::getInstance($suffix, 'CitruscartModel'); $model->setState('filter_enabled', '1'); $plugins[$geozone->geozonetype_id] = $model->getList(); } foreach ($plugins[$geozone->geozonetype_id] as $plugin) { if (isset($plugin->params)) { if (empty($geozones[$plugin->id])) { $params = new DSCParameter($plugin->params); $geozones[$plugin->id] = explode(',', $params->get('geozones')); } if (in_array($geozone->geozone_id, $geozones[$plugin->id])) { $count++; } } } return $count; }
<?php /** this file is a new entry point, so define _JEXEC */ define('_JEXEC', 1); define('TPATH_BASE', dirname(__FILE__)); define('DS', DIRECTORY_SEPARATOR); $pathXplode = explode("/plugins", TPATH_BASE); require_once $pathXplode[0] . '/index.php'; jimport('joomla.plugin.plugin'); $plugin = JPluginHelper::getPlugin('tienda', 'payment_googlecheckout'); $params = new DSCParameter($plugin->params); chdir(".."); require_once dirname(__FILE__) . '/googleresponse.php'; require_once dirname(__FILE__) . '/googlemerchantcalculations.php'; require_once dirname(__FILE__) . '/googleresult.php'; require_once dirname(__FILE__) . '/googlerequest.php'; $path = JPATH_ROOT . '/cache'; define('RESPONSE_HANDLER_ERROR_LOG_FILE', $path . '/googleerror.log'); define('RESPONSE_HANDLER_LOG_FILE', $path . '/googlemessage.log'); $server_type = $params->get('sandbox') ? "sandbox" : "production"; // change this to go live $merchant_id = $params->get('sandbox') ? $params->get('sandbox_merchant_id') : $params->get('merchant_id'); // Your Merchant ID $merchant_key = $params->get('sandbox') ? $params->get('sandbox_merchant_key') : $params->get('merchant_key'); // Your Merchant Key $currency = $params->get('currency'); // set to GBP if in the UK $Gresponse = new GoogleResponse($merchant_id, $merchant_key); $Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type, $currency); //$response->SetLogFiles($path . '/google_error.log', $path . '/google_message.log', L_ALL); //Setup the log file
/** * If enabled, delete product on google * @param $product */ function onAfterDeleteProducts($product, $product_id) { // Check if it's enabled automatic syncing and the user has defined the account id for google if (!$this->params->get('auto_sync', '1') || !$this->account_id) { return false; } // Now let's get serious: was this product already saved on google? $params = new DSCParameter(trim($product->product_params)); $enabled = $params->get('sent_to_google', '0'); $enabled = '1'; if ($enabled) { // Delete also on google if ($this->deleteProduct($product)) { return true; } else { // Something went wrong JError::raiseWarning('GOOGLE_DELETE_ERR', JText::_('COM_TIENDA_ERROR_WHILE_DELETING_IN_GOOGLE_PRODUCTS') . $this->getError()); return false; } } return true; }
/** * Method to assign payment/shipping methods to the geozones */ function selectplugins() { $app = JFactory::getApplication(); $type = $app->input->get('type'); Citruscart::load("CitruscartHelperPlugin", 'helpers.plugin'); $suffix = CitruscartHelperPlugin::getSuffix($type); $state = parent::_setModelState(); $app = JFactory::getApplication(); $model = $this->getModel($suffix); $ns = $app->getName() . '::' . 'com.citruscart.model.' . $model->getTable()->get('_suffix'); $id = $app->input->get('id', 0); $row = $model->getTable('geozones'); $row->load($id); $state['filter_enabled'] = '1'; $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', ''); $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.name', 'cmd'); foreach ($state as $key => $value) { $model->setState($key, $value); } $view = $this->getView('geozones', 'html'); $view->set('_controller', 'geozones'); $view->set('_view', 'geozones'); $view->set('leftMenu', false); $view->set('_action', "index.php?option=com_citruscart&controller=geozones&task=selectplugins&type={$type}&tmpl=component&id=" . $model->getId()); $view->setModel($model, true); $items = $model->getList(); foreach ($items as $item) { $params = new DSCParameter($item->params); $item->geozones = explode(',', $params->get('geozones')); } $view->assign('suffix', $suffix); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->setLayout('selectplugins'); $view->setTask(true); $view->display(); }
/** * Verifies the fields in a submitted form. * Then adds the item to the users cart * * @return unknown_type */ function addToCart() { $input = JFactory::getApplication()->input; JSession::checkToken() or jexit('Invalid Token'); $product_id = $input->getInt('product_id'); $product_qty = $input->getInt('product_qty'); $filter_category = $input->getInt('filter_category'); Citruscart::load("CitruscartHelperRoute", 'helpers.route'); $router = new CitruscartHelperRoute(); if (!($itemid = $router->product($product_id, $filter_category, true))) { $itemid = $router->category(1, true); if (!$itemid) { $itemid = $input->getInt('Itemid', 0); } } // set the default redirect URL $redirect = "index.php?option=com_citruscart&view=products&task=view&id={$product_id}&filter_category={$filter_category}&Itemid=" . $itemid; $redirect = JRoute::_($redirect, false); Citruscart::load('CitruscartHelperBase', 'helpers._base'); $helper = CitruscartHelperBase::getInstance(); if (!Citruscart::getInstance()->get('shop_enabled', '1')) { $this->messagetype = 'notice'; $this->message = JText::_('COM_CITRUSCART_SHOP_DISABLED'); $this->setRedirect($redirect, $this->message, $this->messagetype); return; } // convert elements to array that can be binded $values = $input->getArray($_POST); if (isset($values['elements'])) { $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', $values['elements'])); unset($values['elements']); // convert elements to array that can be binded $values = array_merge(CitruscartHelperBase::elementsToArray($elements), $values); $intpu->set($values, 'POST'); } $files = $input->files->get('files'); $attributes = array(); foreach ($values as $key => $value) { if (substr($key, 0, 10) == 'attribute_') { $attributes[] = $value; } } sort($attributes); $attributes_csv = implode(',', $attributes); // Integrity checks on quantity being added if ($product_qty < 0) { $product_qty = '1'; } // using a helper file to determine the product's information related to inventory $availableQuantity = Citruscart::getClass('CitruscartHelperProduct', 'helpers.product')->getAvailableQuantity($product_id, $attributes_csv); if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) { $this->messagetype = 'notice'; $this->message = JText::_(JText::sprintf("COM_CITRUSCART_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $product_qty)); $this->setRedirect($redirect, $this->message, $this->messagetype); return; } // do the item's charges recur? does the cart already have a subscription in it? if so, fail with notice $product = JTable::getInstance('Products', 'CitruscartTable'); $product->load(array('product_id' => $product_id), true, false); // if product notforsale, fail if ($product->product_notforsale) { $this->messagetype = 'notice'; $this->message = JText::_('COM_CITRUSCART_PRODUCT_NOT_FOR_SALE'); $this->setRedirect($redirect, $this->message, $this->messagetype); return; } $user = JFactory::getUser(); $cart_id = $user->id; $id_type = "user_id"; if (empty($user->id)) { $session = JFactory::getSession(); $cart_id = $session->getId(); $id_type = "session"; } Citruscart::load('CitruscartHelperCarts', 'helpers.carts'); $carthelper = new CitruscartHelperCarts(); $cart_recurs = $carthelper->hasRecurringItem($cart_id, $id_type); if ($product->product_recurs && $cart_recurs) { $this->messagetype = 'notice'; $this->message = JText::_('COM_CITRUSCART_CART_ALREADY_RECURS'); $this->setRedirect($redirect, $this->message, $this->messagetype); return; } if ($product->product_recurs) { $product_qty = '1'; } // create cart object out of item properties $item = new JObject(); $item->user_id = JFactory::getUser()->id; $item->product_id = (int) $product_id; $item->product_qty = (int) $product_qty; $item->product_attributes = $attributes_csv; $item->vendor_id = '0'; // vendors only in enterprise version // if ther is another product_url, put it into the cartitem_params, to allow custom redirect if (array_key_exists('product_url', $values)) { $params = new DSCParameter(trim(@$item->cartitem_params)); $params->set('product_url', $values['product_url']); $item->cartitem_params = trim($params->__toString()); } // onAfterCreateItemForAddToCart: plugin can add values to the item before it is being validated /added // once the extra field(s) have been set, they will get automatically saved $dispatcher = JDispatcher::getInstance(); $results = JFactory::getApplication()->triggerEvent("onAfterCreateItemForAddToCart", array($item, $values, $files)); foreach ($results as $result) { foreach ($result as $key => $value) { $item->set($key, $value); } } // does the user/cart match all dependencies? $canAddToCart = $carthelper->canAddItem($item, $cart_id, $id_type); if (!$canAddToCart) { $this->messagetype = 'notice'; $this->message = JText::_('COM_CITRUSCART_CANNOT_ADD_ITEM_TO_CART') . " - " . $carthelper->getError(); $this->setRedirect($redirect, $this->message, $this->messagetype); return; } // no matter what, fire this validation plugin event for plugins that extend the checkout workflow $results = array(); $dispatcher = JDispatcher::getInstance(); $results = JFactory::getApplication()->triggerEvent("onBeforeAddToCart", array(&$item, $values)); for ($i = 0; $i < count($results); $i++) { $result = $results[$i]; if (!empty($result->error)) { $this->messagetype = 'notice'; $this->message = $result->message; $this->setRedirect($redirect, $this->message, $this->messagetype); return; } } // if here, add to cart // After login, session_id is changed by Joomla, so store this for reference $session = JFactory::getSession(); $session->set('old_sessionid', $session->getId()); // add the item to the cart Citruscart::load('CitruscartHelperCarts', 'helpers.carts'); $cart_helper = new CitruscartHelperCarts(); $cartitem = $cart_helper->addItem($item); // fire plugin event $dispatcher = JDispatcher::getInstance(); JFactory::getApplication()->triggerEvent('onAfterAddToCart', array($cartitem, $values)); // get the 'success' redirect url switch (Citruscart::getInstance()->get('addtocartaction', 'redirect')) { case "checkout": // if a base64_encoded url is present as return, use that as the return url // otherwise return == the product view page $returnUrl = base64_encode($redirect); if ($return_url = $input->getBase64('return')) { $return_url = base64_decode($return_url); if (JURI::isInternal($return_url)) { $returnUrl = base64_encode($return_url); } } // if a base64_encoded url is present as redirect, redirect there, // otherwise redirect to the checkout $itemid_checkout = $router->findItemid(array('view' => 'checkout')); $itemid_opc = $router->findItemid(array('view' => 'opc')); $checkout_view = "checkout"; $itemid = null; if ($itemid_opc) { $itemid = $itemid_opc; $checkout_view = "opc"; } elseif ($itemid_checkout) { $itemid = $itemid_checkout; } if (!$itemid) { $itemid = $input->getInt('Itemid', 0); } $redirect = JRoute::_("index.php?option=com_citruscart&view=" . $checkout_view . "&Itemid=" . $itemid, false); if ($redirect_url = $input->getBase64('redirect')) { $redirect_url = base64_decode($redirect_url); if (JURI::isInternal($redirect_url)) { $redirect = $redirect_url; } } if (strpos($redirect, '?') === false) { $redirect .= "?return=" . $returnUrl; } else { $redirect .= "&return=" . $returnUrl; } break; case "0": case "none": // redirects back to product page break; case "samepage": // redirects back to the page it came from (category, content, etc) // Take only the url without the base domain (index.php?option.....) if ($return_url = $input->getBase64('return')) { $return_url = base64_decode($return_url); $uri = JURI::getInstance(); $uri->parse($return_url); $redirect = $uri->__toString(array('path', 'query', 'fragment')); $redirect = JRoute::_($redirect, false); } break; case "lightbox": case "redirect": default: // if a base64_encoded url is present as return, use that as the return url // otherwise return == the product view page $returnUrl = base64_encode($redirect); if ($return_url = $input->getBase64('return')) { $return_url = base64_decode($return_url); if (JURI::isInternal($return_url)) { $returnUrl = base64_encode($return_url); } } // if a base64_encoded url is present as redirect, redirect there, // otherwise redirect to the cart $itemid = $router->findItemid(array('view' => 'carts')); if (!$itemid) { $itemid = $input->getInt('Itemid', 0); } $redirect = JRoute::_("index.php?option=com_citruscart&view=carts&Itemid=" . $itemid, false); if ($redirect_url = $input->getBase64('redirect')) { $redirect_url = base64_decode($redirect_url); if (JURI::isInternal($redirect_url)) { $redirect = $redirect_url; } } //$returnUrl = base64_encode( $redirect ); //$itemid = $router->findItemid( array('view'=>'checkout') ); //$redirect = JRoute::_( "index.php?option=com_citruscart&view=carts&Itemid=".$itemid, false ); if (strpos($redirect, '?') === false) { $redirect .= "?return=" . $returnUrl; } else { $redirect .= "&return=" . $returnUrl; } break; } $this->messagetype = 'message'; $this->message = JText::_('COM_CITRUSCART_ITEM_ADDED_TO_YOUR_CART'); $this->setRedirect($redirect, $this->message, $this->messagetype); return; }
function migrate() { if ($this->import_throttled_import) { $result = ''; $this->import_skip_first = $this->state->skip_first; $this->import_field_separator = $this->state->field_separator; $params = new DSCParameter(); $params->setValue('skip_first', $this->import_skip_first); $params->setValue('num_records', $this->import_num_records); $params->setValue('num_fields', $this->import_fields_num); $params->setValue('clear_fields', $this->import_clear_fields); $params->setValue('chunk_size', $this->import_chunk_size); $params->setValue('preserve_header', $this->import_preserve_header); $params->setValue('offset', $this->import_offset); $params->setValue('begin_import', $this->import_begin_import); $params->setValue('throttled_import', true); $params->setValue('rec_deliminer', $this->import_rec_deliminer); $params->setValue('field_deliminer', $this->import_field_separator); while (true) { $data = TiendaCSV::fromFileToArray($this->source_import, $this->import_fields, $this->import_fields_num, $this->parse_method, $params); $c = count($data[0]); $this->set('data', $data[0]); $result .= $this->migrate_data(); if ($c != $this->import_num_records) { break; } $params->setValue('offset', $data[1]); $params->setValue('begin_import', false); } return $result; } else { return $this->migrate_data(); } }
function onBeforeK2Save(&$item, $isNew) { //Check if Tienda is installed if (!$this->_isInstalled()) { return; } //Get Tienda plugin variables $tiendaParams = new K2Parameter($item->plugins, '', $this->_name); //Get All plugins variables $plugins = new DSCParameter($item->plugins); //Handle assignment if (JRequest::getBool('tiendaAssign')) { $plugins->merge($tiendaParams); $item->plugins = $plugins->toString(); return; } //Handle unassignment if (JRequest::getBool('tiendaUnassign')) { $plugins->set('tiendaproductID', NULL); $plugins->set('tiendaproductName', NULL); $plugins->set('tiendaproductSKU', NULL); $plugins->set('tiendaproductTax', NULL); $plugins->set('tiendaproductManufacturer', NULL); $plugins->set('tiendaproductWeight', NULL); $plugins->set('tiendaproductLength', NULL); $plugins->set('tiendaproductWidth', NULL); $plugins->set('tiendaproductHeight', NULL); $plugins->set('tiendaproductShipping', NULL); $plugins->set('tiendaproductEnabled', NULL); $item->plugins = $plugins->toString(); return; } //Handle unassignment if (JRequest::getBool('tiendaRemove')) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); $product = JTable::getInstance('Products', 'TiendaTable'); $product->delete($plugins->get('tiendaproductID')); $plugins->set('tiendaproductID', NULL); $plugins->set('tiendaproductName', NULL); $plugins->set('tiendaproductSKU', NULL); $plugins->set('tiendaproductTax', NULL); $plugins->set('tiendaproductManufacturer', NULL); $plugins->set('tiendaproductWeight', NULL); $plugins->set('tiendaproductLength', NULL); $plugins->set('tiendaproductWidth', NULL); $plugins->set('tiendaproductHeight', NULL); $plugins->set('tiendaproductShipping', NULL); $plugins->set('tiendaproductEnabled', NULL); $item->plugins = $plugins->toString(); return; } //Handle form if ($tiendaParams->get('productName', NULL) && $tiendaParams->get('productSKU', NULL)) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); $product = JTable::getInstance('Products', 'TiendaTable'); $product->product_id = $tiendaParams->get('productID', NULL); $product->product_name = $tiendaParams->get('productName', NULL); $product->product_sku = $tiendaParams->get('productSKU', NULL); $product->manufacturer_id = $tiendaParams->get('productManufacturer', 0); $product->tax_class_id = $tiendaParams->get('productTax'); $product->product_weight = $tiendaParams->get('productWeight', NULL); $product->product_length = $tiendaParams->get('productLength', NULL); $product->product_width = $tiendaParams->get('productWidth', NULL); $product->product_height = $tiendaParams->get('productHeight', NULL); $product->product_ships = $tiendaParams->get('productShipping', 0); $product->product_enabled = $tiendaParams->get('productEnabled', 1); $product->save(); $tiendaParams->set('tiendaproductID', $product->product_id); $price = $tiendaParams->get('productPrice', NULL); if ($price) { $price = JTable::getInstance('ProductPrices', 'TiendaTable'); $price->product_id = $product->product_id; $price->product_price = $tiendaParams->get('productPrice', NULL); $price->save(); } $plugins->merge($tiendaParams); $item->plugins = $plugins->toString(); } }
echo JText::_('COM_CITRUSCART_STATUS'); ?> </th> </tr> </thead> <tbody> <?php $i = 0; $k = 0; ?> <?php foreach ($items as $item) { ?> <?php $params = new DSCParameter(trim($item->wishlistitem_params)); $default_url = "index.php?option=com_citruscart&view=products&task=view&id=" . $item->product_id; $attributes = CitruscartHelperProduct::convertAttributesToArray($item->product_id, $item->product_attributes); for ($j = 0, $c = count($attributes); $j < $c; $j++) { $default_url .= '&attribute_' . $attributes[$j][0] . '=' . $attributes[$j][1]; } if ($itemid = $products_model->getItemid($item->product_id)) { $default_url .= "&Itemid=" . $itemid; } $link = $params->get('product_url', $default_url); $link = JRoute::_($link); ?> <tr class="row<?php echo $k; ?>
/** * Event is triggered after product is saved in Tienda * and updates the AS subscription type's record * * @param $product * @return unknown_type */ function onAfterSaveProducts($product) { $model = JModel::getInstance('Products', 'TiendaModel'); $model->setId($product->product_id); $product = $model->getItem(); $ambrasubs_type_id = $product->product_parameters->get('ambrasubs_type_id'); if (!empty($ambrasubs_type_id)) { $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__ambrasubs_types WHERE `id` = '{$ambrasubs_type_id}';"); $type = $db->loadObject(); $params = new DSCParameter(trim($type->params)); $params->set('tienda_product_id', $product->product_id); $type_params = $db->getEscaped(trim($params->toString())); $db->setQuery("UPDATE #__ambrasubs_types SET `params` = '{$type_params}' WHERE `id` = '{$ambrasubs_type_id}';"); $db->query(); } }
/** * Returns a DSCParameter Formatted string representing the currency * * @param $currency_id currency_id * @return $string DSCParameter formatted string */ public static function currencyToParameters($currency_id) { if (!is_numeric($currency_id)) { return false; } JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = JModel::getInstance('Currencies', 'TiendaModel'); $table = $model->getTable(); // Load the currency if (!$table->load($currency_id)) { return false; } // Convert this into a DSCParameter formatted string // a bit rough, but works smoothly and is extensible (works even if you add another parameter to the curremcy table $currency_parameters = $table; unset($table); unset($currency_parameters->currency_id); unset($currency_parameters->created_date); unset($currency_parameters->modified_date); unset($currency_parameters->currency_enabled); $param = new DSCParameter(''); $param->loadObject($currency_parameters); return $param->toString(); }
function fromFileToArray($file_path, $fields = array(), $num_fields = 0, $method = 1, $params = '') { if (empty($params)) { $params = new DSCParameter(); } $throttled = $params->getValue('throttled_import', false); if ($throttled) { $content = $file_path; } else { // parse whole file $content = file_get_contents($file_path); } // read the file return TiendaCSV::toArray($content, $fields, $num_fields, $method, $params); }
/** * * A separate space for working through all the different integrations */ function prepareParameters(&$row) { $app = JFactory::getApplication(); // this row's product_params has already been set from the textarea's POST // so we need to add to it $params = new DSCParameter(trim($row->product_params)); $params->set('amigos_commission_override', $app->input->get('amigos_commission_override')); $params->set('billets_ticket_limit_increase', $app->input->get('billets_ticket_limit_increase')); $params->set('billets_ticket_limit_exclusion', $app->input->get('billets_ticket_limit_exclusion')); $params->set('billets_hour_limit_increase', $app->input->get('billets_hour_limit_increase')); $params->set('billets_hour_limit_exclusion', $app->input->get('billets_hour_limit_exclusion')); $params->set('juga_group_csv_add', $app->input->get('juga_group_csv_add')); $params->set('juga_group_csv_remove', $app->input->get('juga_group_csv_remove')); $params->set('juga_group_csv_add_expiration', $app->input->get('juga_group_csv_add_expiration')); $params->set('juga_group_csv_remove_expiration', $app->input->get('juga_group_csv_remove_expiration')); $params->set('core_user_change_gid', $app->input->get('core_user_change_gid')); $params->set('core_user_new_gid', $app->input->get('core_user_new_gid')); $params->set('ambrasubs_type_id', $app->input->get('ambrasubs_type_id')); $params->set('hide_quantity_input', $app->input->get('param_hide_quantity_input')); $params->set('default_quantity', $app->input->get('param_default_quantity')); $params->set('hide_quantity_cart', $app->input->get('param_hide_quantity_cart')); $params->set('show_product_compare', $app->input->getInt('param_show_product_compare', 1)); $row->product_params = trim($params->__toString()); return $row; }
$attribs['style'] = 'xhtml'; foreach ($modules as $mod) { echo $renderer->render($mod, $attribs); } ?> </td> <td style="vertical-align: top; width: 30%; min-width: 30%; padding: 0px 0px 0px 5px;"> <?php $modules = JModuleHelper::getModules("citruscart_product_dashboard_right"); $document = JFactory::getDocument(); $renderer = $document->loadRenderer('module'); $attribs = array(); $attribs['style'] = 'xhtml'; foreach ($modules as $mod) { $mod_params = new DSCParameter($mod->params); if ($mod_params->get('hide_title', '1')) { $mod->showtitle = '0'; } echo $renderer->render($mod, $attribs); } ?> </td> </tr> </table> <input type="hidden" name="id" value="<?php echo $row->product_id; ?> " /> <input type="hidden" name="task" id="task" value="" />
/** * Search for the tag and replace it with the product view {Citruscartproduct} * * @param $article * @param $params * @param $limitstart */ private function doContentPrepare($context, &$row, &$params, $page = 0) { if (!$this->isInstalled()) { return true; } // simple performance check to determine whether bot should process further if (JString::strpos($row->text, 'citruscartproduct') === false) { return true; } // Get plugin info $plugin = JPluginHelper::getPlugin('content', 'citruscart_content_product'); // expression to search for $regex = '/{citruscartproduct\\s*.*?}/i'; $pluginParams = new DSCParameter($plugin->params); // check whether plugin has been unpublished if (!$pluginParams->get('enabled', 1)) { $row->text = preg_replace($regex, '', $row->text); return true; } // find all instances of plugin and put in $matches preg_match_all($regex, $row->text, $matches); // Number of plugins $count = count($matches[0]); // plugin only processes if there are any instances of the plugin in the text if ($count) { DSC::loadJQuery('latest', true, 'citruscartJQ'); $doc = JFactory::getDocument(); $uri = JURI::getInstance(); $js = "var com_citruscart = {};\n"; $js .= "com_citruscart.jbase = '" . $uri->root() . "';\n"; $doc->addScriptDeclaration($js); foreach ($matches as $match) { $this->showProducts($row, $matches, $count, $regex); } } }