Exemple #1
0
 /**
  * Protected! Use the getInstance
  */
 protected function DSCHelperImage()
 {
     // Parent Helper Construction
     parent::__construct();
     $config = DSCConfig::getInstance();
     // Load default Parameters
     $this->product_img_height = $config->get('product_img_height');
     $this->product_img_width = $config->get('product_img_width');
     $this->category_img_height = $config->get('category_img_height');
     $this->category_img_width = $config->get('category_img_width');
     $this->manufacturer_img_width = $config->get('manufacturer_img_width');
     $this->manufacturer_img_height = $config->get('manufacturer_img_height');
     $this->product_img_path = DSC::getPath('products_images');
     $this->category_img_path = DSC::getPath('categories_images');
     $this->manufacturer_img_path = DSC::getPath('manufacturers_images');
     $this->product_thumb_path = DSC::getPath('products_thumbs');
     $this->category_thumb_path = DSC::getPath('categories_thumbs');
     $this->manufacturer_thumb_path = DSC::getPath('manufacturers_thumbs');
 }
Exemple #2
0
 /**
  * save a record
  * @return void
  */
 function save()
 {
     $app = JFactory::getApplication();
     $error = false;
     $errorMsg = "";
     $model = $this->getModel($this->get('suffix'));
     $config = DSCConfig::getInstance();
     $properties = $config->getProperties();
     foreach ($properties as $key => $value) {
         unset($row);
         $row = $model->getTable('config');
         $newvalue = $app->input->get($key);
         //$newvalue = JRequest::getVar( $key );
         $value_exists = array_key_exists($key, $_POST);
         if ($value_exists && !empty($key)) {
             // proceed if newvalue present in request. prevents overwriting for non-existent values.
             $row->load(array('config_name' => $key));
             $row->config_name = $key;
             $row->value = $newvalue;
             if (!$row->save()) {
                 $error = true;
                 $errorMsg .= JText::_("Could not store") . " {$key} :: " . $row->getError() . " - ";
             }
         }
     }
     if (!$error) {
         $this->messagetype = 'message';
         $this->message = JText::_('Saved');
         JFactory::getApplication()->triggerEvent('onAfterSave' . $this->get('suffix'), array($row));
     } else {
         $this->messagetype = 'notice';
         $this->message = JText::_('Save Failed') . " - " . $errorMsg;
     }
     $redirect = "index.php?option=com_sample";
     $task = $app->input->getString('task');
     switch ($task) {
         default:
             $redirect .= "&view=" . $this->get('suffix');
             break;
     }
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
Exemple #3
0
 /**
  * Format a number according to currency rules
  *
  * @param unknown_type $amount
  * @param unknown_type $currency
  * @return unknown_type
  */
 function format($amount, $currency = '', $options = '')
 {
     // default to whatever is in config
     $config = DSCConfig::getInstance();
     $options = (array) $options;
     $num_decimals = isset($options['num_decimals']) ? $options['num_decimals'] : $config->get('currency_num_decimals', '2');
     $thousands = isset($options['thousands']) ? $options['thousands'] : $config->get('currency_thousands', ',');
     $decimal = isset($options['decimal']) ? $options['decimal'] : $config->get('currency_decimal', '.');
     $pre = isset($options['pre']) ? $options['pre'] : $config->get('currency_symbol_pre', '$');
     $post = isset($options['post']) ? $options['post'] : $config->get('currency_symbol_post', '');
     // Now check the session variable to see if there is a currency setting there
     $session_currency = DSCHelper::getSessionVariable('currency_id', 0);
     if ($session_currency) {
         // Let the code below deal with currency loading
         $currency = $session_currency;
     }
     // if currency is an object, use it's properties
     if (is_object($currency)) {
         $table = $currency;
         $num_decimals = $table->currency_decimals;
         $thousands = $table->thousands_separator;
         $decimal = $table->decimal_separator;
         $pre = $table->symbol_left;
         $post = $table->symbol_right;
     } elseif (!empty($currency) && is_numeric($currency)) {
         // TODO if currency is an integer, load the object for its id
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sample' . DS . 'tables');
         $table = JTable::getInstance('Currencies', 'DSCTable');
         $table->load((int) $currency);
         if (!empty($table->currency_id)) {
             $num_decimals = $table->currency_decimals;
             $thousands = $table->thousands_separator;
             $decimal = $table->decimal_separator;
             $pre = $table->symbol_left;
             $post = $table->symbol_right;
         }
     } elseif (!empty($currency)) {
         // TODO if currency is a string (currency_code) load the object for its code
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sample' . DS . 'tables');
         $table = JTable::getInstance('Currencies', 'DSCTable');
         $keynames = array();
         $keynames['currency_code'] = (string) $currency;
         $table->load($keynames);
         if (!empty($table->currency_id)) {
             $num_decimals = $table->currency_decimals;
             $thousands = $table->thousands_separator;
             $decimal = $table->decimal_separator;
             $pre = $table->symbol_left;
             $post = $table->symbol_right;
         }
     }
     $return = $pre . number_format($amount, $num_decimals, $decimal, $thousands) . $post;
     return $return;
 }
Exemple #4
0
 /**
  * Creates the placeholder array with the default site values
  *
  * @return unknown_type
  */
 function getPlaceholderDefaults()
 {
     $mainframe = JFactory::getApplication();
     $config = DSCConfig::getInstance();
     $site_name = $config->get('sitename', $mainframe->getCfg('sitename'));
     $site_url = $config->get('siteurl', JURI::root());
     $link_my_subscriptions = $config->get('link_my_subscriptions', JURI::root() . "/index.php?option=com_sample&view=subscriptions");
     $user_name = JText::_($config->get('default_email_user_name', 'Valued Customer'));
     // default placeholders
     $placeholders = array('site.name' => $site_name, 'site.url' => $site_url, 'user.name' => $user_name, 'link.my_subscriptions' => $link_my_subscriptions);
     return $placeholders;
 }