Exemple #1
0
 /**
  * Displays a layout file with room for a left menu bar
  * @param $tpl
  * @return unknown_type
  */
 public function displayWithLeftMenu($tpl = null, $menuname)
 {
     // TODO This is an ugly, quick hack - fix it
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td style='width: 180px; padding-right: 5px; vertical-align: top;' >";
     DSC::load('DSCMenu', 'library.menu');
     if ($menu = DSCMenu::getInstance($menuname)) {
         $menu->display('leftmenu', $menu);
     }
     $modules = JModuleHelper::getModules($this->_name . "_left");
     $document = JFactory::getDocument();
     $renderer = $document->loadRenderer('module');
     $attribs = array();
     $attribs['style'] = 'xhtml';
     foreach ($modules as $mod) {
         echo $renderer->render($mod, $attribs);
     }
     echo "</td>";
     echo "<td style='vertical-align: top;' >";
     parent::display($tpl);
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
Exemple #2
0
 /**
  * Format and convert a number according to currency rules
  *
  * @param unknown_type $amount
  * @param unknown_type $currency
  * @return unknown_type
  */
 public static function _($amount, $currency = '', $options = '')
 {
     // default to whatever is in config
     $config = DSC::getApp();
     $options = (array) $options;
     $default_currencyid = $config->get('default_currencyid', '1');
     $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;
         if ($default_currencyid != $table->currency_id) {
             $convertTo = $table->currency_code;
         }
     } 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;
             if ($default_currencyid != $currency) {
                 $convertTo = $table->currency_code;
             }
         }
     } 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;
             if ($default_currencyid != $table->currency_id) {
                 $convertTo = $table->currency_code;
             }
         }
     }
     // if the currency code we're using is diff from the store-wide currency, then we need to convert the amount
     if (!empty($convertTo)) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sample' . DS . 'tables');
         $table = JTable::getInstance('Currencies', 'DSCTable');
         $table->load((int) $default_currencyid);
         DSC::load('DSCHelperCurrency', 'helpers.currency');
         $amount = DSCHelperCurrency::convert($table->currency_code, $convertTo, $amount);
     }
     $return = $pre . number_format($amount, $num_decimals, $decimal, $thousands) . $post;
     return $return;
 }
Exemple #3
0
 /**
  * Method to intelligently load class files in the framework
  *
  * @param string $classname   The class name
  * @param string $filepath    The filepath ( dot notation )
  * @param array  $options
  * @return boolean
  */
 public static function load($classname, $filepath = 'controller', $options = array('site' => 'admin', 'type' => 'components', 'ext' => 'com_mysite'))
 {
     return parent::load($classname, $filepath, $options);
 }
Exemple #4
0
 *   - added JPEG compression quality setting. Thanks Vad</li>
 *  <li><b>v 0.14</b> 14/03/2005<br>
 *   - reworked the class file to allow parsing with phpDocumentor</li>
 *  <li><b>v 0.13</b> 07/03/2005<br>
 *   - fixed a bug with {@link image_ratio}. Thanks Justin.<br>
 *   - added {@link image_ratio_no_zoom_in} and {@link image_ratio_no_zoom_out} </li>
 *  <li><b>v 0.12</b> 21/01/2005<br>
 *   - added {@link image_ratio} to resize within max values, keeping image ratio</li>
 *  <li><b>v 0.11</b> 22/08/2003<br>
 *   - update for GD2 (changed imageresized() into imagecopyresampled() and imagecreate() into imagecreatetruecolor())</li>
 * </ul>
 *
 * @package   cmf
 * @subpackage external
 */
DSC::load('DSCImage', 'library.image');
class DSCUpload extends DSCImage
{
    /**
     * Class version
     *
     * @access public
     * @var string
     */
    var $version;
    /**
     * Uploaded file name
     *
     * @access public
     * @var string
     */
Exemple #5
0
 /**
  * Returns
  *
  * @param object
  * @param mixed Boolean
  * @param mixed Boolean
  * @return array
  */
 private function getEmailContent($data, $type = 'order')
 {
     $mainframe = JFactory::getApplication();
     $type = strtolower($type);
     $lang = JFactory::getLanguage();
     $lang->load('com_sample', JPATH_ADMINISTRATOR);
     $return = new stdClass();
     $return->body = '';
     $return->subject = '';
     // get config settings
     $config = DSCConfig::getInstance();
     $sitename = $config->get('sitename', $mainframe->getCfg('sitename'));
     $siteurl = $config->get('siteurl', JURI::root());
     // get the placeholders array here so the switch statement can add to it
     $placeholders = $this->getPlaceholderDefaults();
     switch ($type) {
         case "subscription_expiring":
             $return->subject = JText::_('EMAIL_EXPIRING_SUBSCRIPTION_SUBJECT');
             $return->body = JText::_('EMAIL_EXPIRING_SUBSCRIPTION_BODY');
             if ($this->use_html) {
                 $return->body = nl2br($return->body);
             }
             $placeholders['user.name'] = $data->user_name;
             $placeholders['product.name'] = $data->product_name;
             break;
         case "subscription_expired":
             $return->subject = JText::_('EMAIL_EXPIRED_SUBSCRIPTION_SUBJECT');
             $return->body = JText::_('EMAIL_EXPIRED_SUBSCRIPTION_BODY');
             if ($this->use_html) {
                 $return->body = nl2br($return->body);
             }
             $placeholders['user.name'] = $data->user_name;
             $placeholders['product.name'] = $data->product_name;
             break;
         case "subscription_new":
         case "new_subscription":
         case "subscription":
             $user = JFactory::getUser($data->user_id);
             $link = JURI::root() . "index.php?option=com_sample&view=orders&task=view&id=" . $data->order_id;
             $link = JRoute::_($link, false);
             if (count($data->history) == 1) {
                 // new order
                 $return->subject = sprintf(JText::_('EMAIL_NEW_ORDER_SUBJECT'), $data->order_id);
                 // set the email body
                 $text = JText::_('EMAIL_DEAR') . " " . $user->name . ",\n\n";
                 $text .= JText::_("EMAIL_THANKS_NEW_SUBSCRIPTION") . "\n\n";
                 $text .= JText::_("EMAIL_CHECK") . " " . $link . "\n\n";
                 $text .= JText::_("EMAIL_RECEIPT_FOLLOWS") . "\n\n";
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
                 // get the order body
                 DSC::load('DSCHelperOrder', 'helpers.order');
                 $text .= DSCHelperOrder::getOrderHtmlForEmail($data->order_id);
             } else {
                 // Status Change
                 $return->subject = JText::_('EMAIL_SUBSCRIPTION_STATUS_CHANGE');
                 $last_history = count($data->history) - 1;
                 $text = JText::_('EMAIL_DEAR') . " " . $user->name . ",\n\n";
                 $text .= sprintf(JText::_("EMAIL_ORDER_UPDATED"), $data->order_id);
                 if (!empty($data->history[$last_history]->comments)) {
                     $text .= sprintf(JText::_("EMAIL_ADDITIONAL_COMMENTS"), $data->history[$last_history]->comments);
                 }
                 $text .= JText::_("EMAIL_CHECK") . " " . $link;
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
             }
             $return->body = $text;
             $placeholders['user.name'] = $user->get('name');
             break;
         case "new_order":
         case "order":
         default:
             //$user = JUser::getInstance($data->user_id);
             $user = JFactory::getUser($data->user_id);
             $link = JURI::root() . "index.php?option=com_sample&view=orders&task=view&id=" . $data->order_id;
             $link = JRoute::_($link, false);
             if ($type == 'new_order') {
                 // new order
                 $return->subject = sprintf(JText::_('EMAIL_NEW_ORDER_SUBJECT'), $data->order_id);
                 // set the email body
                 $text = JText::_('EMAIL_DEAR') . " " . $user->name . ",\n\n";
                 $text .= JText::_("EMAIL_THANKS_NEW_ORDER") . "\n\n";
                 $text .= JText::_("EMAIL_CHECK") . " " . $link . "\n\n";
                 $text .= JText::_("EMAIL_RECEIPT_FOLLOWS") . "\n\n";
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
                 // get the order body
                 DSC::load('DSCHelperOrder', 'helpers.order');
                 $text .= DSCHelperOrder::getOrderHtmlForEmail($data->order_id);
             } else {
                 // Status Change
                 $return->subject = JText::_('EMAIL_ORDER_STATUS_CHANGE');
                 $last_history = count($data->orderhistory) - 1;
                 $text = JText::_('EMAIL_DEAR') . " " . $user->name . ",\n\n";
                 $text .= sprintf(JText::_("EMAIL_ORDER_UPDATED"), $data->order_id);
                 $text .= JText::_("EMAIL_NEW_STATUS") . " " . $data->orderhistory[$last_history]->order_state_name . "\n\n";
                 if (!empty($data->orderhistory[$last_history]->comments)) {
                     $text .= sprintf(JText::_("EMAIL_ADDITIONAL_COMMENTS"), $data->orderhistory[$last_history]->comments);
                 }
                 $text .= JText::_("EMAIL_CHECK") . " " . $link;
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
             }
             $return->body = $text;
             $placeholders['user.name'] = $user->get('name');
             break;
     }
     // replace placeholders in language strings - great idea, Oleg
     $return->subject = $this->replacePlaceholders($return->subject, $placeholders);
     $return->body = $this->replacePlaceholders($return->body, $placeholders);
     return $return;
 }