Exemplo n.º 1
0
 /**
  * Method to export features tables as CSV
  */
 public function export()
 {
     $features = JRequest::getVar('cid', array(), 'post', 'array');
     if (!empty($features)) {
         $config = JFactory::getConfig();
         $exportPath = $config->get('tmp_path') . DS . 'jea_export';
         if (JFolder::create($exportPath) === false) {
             $msg = JText::_('JLIB_FILESYSTEM_ERROR_FOLDER_CREATE') . ' : ' . $exportPath;
             $this->setRedirect('index.php?option=com_jea&view=features', $msg, 'warning');
         } else {
             $xmlPath = JPATH_COMPONENT . '/models/forms/features/';
             $xmlFiles = JFolder::files($xmlPath);
             $model = $this->getModel();
             $files = array();
             foreach ($xmlFiles as $filename) {
                 if (preg_match('/^[0-9]{2}-([a-z]*).xml/', $filename, $matches)) {
                     $feature = $matches[1];
                     if (in_array($feature, $features)) {
                         $form = simplexml_load_file($xmlPath . DS . $filename);
                         $table = (string) $form['table'];
                         $files[] = array('data' => $model->getCSVData($table), 'name' => $table . '.csv');
                     }
                 }
             }
             $zipFile = $exportPath . DS . 'jea_export_' . uniqid() . '.zip';
             $zip = JArchive::getAdapter('zip');
             $zip->create($zipFile, $files);
             JResponse::setHeader('Content-Type', 'application/zip');
             JResponse::setHeader('Content-Disposition', 'attachment; filename="jea_features.zip"');
             JResponse::setHeader('Content-Transfer-Encoding', 'binary');
             JResponse::setBody(readfile($zipFile));
             echo JResponse::toString();
             // clean tmp files
             JFile::delete($zipFile);
             JFolder::delete($exportPath);
             Jexit();
         }
     } else {
         $msg = JText::_('JERROR_NO_ITEMS_SELECTED');
         $this->setRedirect('index.php?option=com_jea&view=features', $msg);
     }
 }
Exemplo n.º 2
0
 /**
  * Add the product to the cart, with JS
  *
  * @author Max Milbers
  * @access public
  */
 public function viewJS()
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart(false);
     $this->data = $cart->prepareAjaxData();
     $lang = JFactory::getLanguage();
     $extension = 'com_virtuemart';
     $lang->load($extension);
     //  when AJAX it needs to be loaded manually here >> in case you are outside virtuemart !!!
     if ($this->data->totalProduct > 1) {
         $this->data->totalProductTxt = JText::sprintf('COM_VIRTUEMART_CART_X_PRODUCTS', $this->data->totalProduct);
     } else {
         if ($this->data->totalProduct == 1) {
             $this->data->totalProductTxt = JText::_('COM_VIRTUEMART_CART_ONE_PRODUCT');
         } else {
             $this->data->totalProductTxt = JText::_('COM_VIRTUEMART_EMPTY_CART');
         }
     }
     if ($this->data->dataValidated == true) {
         $taskRoute = '&task=confirm';
         $linkName = JText::_('COM_VIRTUEMART_CART_CONFIRM');
     } else {
         $taskRoute = '';
         $linkName = JText::_('COM_VIRTUEMART_CART_SHOW');
     }
     $this->data->cart_show = '<a class="floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart" . $taskRoute, $this->useXHTML, $this->useSSL) . '">' . $linkName . '</a>';
     $this->data->billTotal = $lang->_('COM_VIRTUEMART_CART_TOTAL') . ' : <strong>' . $this->data->billTotal . '</strong>';
     echo json_encode($this->data);
     Jexit();
 }
Exemplo n.º 3
0
 /**
  * Add the product to the cart, with JS
  *
  * @access public
  */
 public function viewJS()
 {
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart(false);
     $cart->prepareCartData();
     $data = $cart->prepareAjaxData(true);
     echo json_encode($data);
     Jexit();
 }
Exemplo n.º 4
0
    /**
     * Function to return options for date select, depending of event
     *
     * @since	3.5.9
     */
    public static function getOptionsEventDates($view = null, $id = null)
    {
        $jinput = JFactory::getApplication()->input;
        $regid = $jinput->get('regid', '0');
        $eventid = $jinput->get('eventid', '0');
        $data = JFactory::getApplication()->getUserState('com_icagenda.' . $view . '.data', array());
        $date = isset($data['date']) ? $data['date'] : '';
        $date_format_global = JComponentHelper::getParams('com_icagenda')->get('date_format_global', 'Y - m - d');
        $separator = JComponentHelper::getParams('com_icagenda')->get('date_separator', ' ');
        if ($eventid != 0 && $view == 'mail') {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
            $query->select('r.id as reg_id, r.date AS reg_date, r.period AS reg_period, r.eventid AS reg_eventid, sum(r.people) AS reg_count')->from('`#__icagenda_registration` AS r');
            $query->select('e.startdate AS startdate, e.enddate AS enddate, e.weekdays AS weekdays')->join('LEFT', $db->quoteName('#__icagenda_events') . ' AS e ON e.id = r.eventid');
            $query->where('r.state = 1');
            $query->where('r.email <> ""');
            $query->group('r.date');
            $query->where('r.eventid = ' . (int) $eventid);
            $db->setQuery($query);
            $result = $db->loadObjectList();
        } elseif ($view == 'registration') {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
            $query->select('next AS next, dates AS dates,
							startdate AS startdate, enddate AS enddate, weekdays AS weekdays,
							id AS id, state AS state, access AS access, params AS params');
            $query->from('`#__icagenda_events` AS e');
            $query->where(' e.id = ' . $eventid);
            $db->setQuery($query);
            $i = $db->loadObject();
            if ($regid != 0) {
                $reg_query = $db->getQuery(true);
                $reg_query->select('r.id as reg_id, r.date AS reg_date, r.period AS reg_period, r.eventid AS reg_eventid')->from('`#__icagenda_registration` AS r');
                $reg_query->where('r.id = ' . (int) $regid);
                $db->setQuery($reg_query);
                $obj = $db->loadObject();
                $reg_date = $obj->reg_date;
                $reg_period = $obj->reg_period;
            } else {
                $reg_date = '';
                $reg_period = '';
            }
        }
        $options = '';
        if ($view == 'mail') {
            $options .= '<option value="">' . JText::_('COM_ICAGENDA_SELECT_DATE') . '</option>';
            $options .= '<option value="all"';
            $options .= $date == 'all' ? ' selected="selected"' : '';
            $options .= '>' . strtoupper(JText::_('COM_ICAGENDA_REGISTRATION_ALL_DATES')) . '</option>';
        } elseif ($i && $view == 'registration') {
            $options .= self::getOptionsAllDates($i, 'registration', $reg_date, $reg_period);
        }
        if (isset($result) && $view == 'mail') {
            foreach ($result as $r) {
                // Full period (no single date selected, supposes registration for full period)
                if (!$r->reg_date && $r->reg_period == 0) {
                    // Check the period if is separated into individual dates
                    $is_full_period = $r->weekdays || $r->weekdays == '0' ? false : true;
                    if ($is_full_period && iCDate::isDate($r->startdate) && iCDate::isDate($r->enddate)) {
                        $option_value = '0';
                        $option_date = self::formatDate($r->startdate) . ' &#x279c; ' . self::formatDate($r->startdate);
                    } else {
                        $option_value = '0';
                        $option_date = JText::_('COM_ICAGENDA_ADMIN_REGISTRATION_FOR_ALL_PERIOD');
                    }
                } elseif (!$r->reg_date && $r->reg_period == 1) {
                    $option_value = '1';
                    $option_date = JText::_('COM_ICAGENDA_ADMIN_REGISTRATION_FOR_ALL_DATES');
                } else {
                    if (iCDate::isDate($r->reg_date)) {
                        $regDate = iCGlobalize::dateFormat($r->reg_date, $date_format_global, $separator);
                        $time = date('H:i', strtotime($r->reg_date));
                        $regTime = $time && $time != '00:00' ? ' - ' . $time : '';
                    }
                    $option_value = $r->reg_date;
                    // Date format (global option).
                    // NOTE: Date saved in database with versions before 3.3.8 can not be formatted
                    //       Will return a string (date in old format) with double quote.
                    $option_date = iCDate::isDate($r->reg_date) ? $regDate . $regTime : '"' . $r->reg_date . '"';
                }
                $options .= '<option value="' . $option_value . '"';
                $options .= $date == $option_value ? ' selected="selected"' : '';
                $options .= '>' . $option_date . ' (&#10003;' . $r->reg_count . ')</option>';
            }
        }
        echo $options;
        Jexit();
    }