Exemple #1
0
 /**
  * @param \Joomla\Registry\Registry | null $state
  *
  * @return \Sp4kAppsCartItem
  *
  */
 public function getItemInstance(Joomla\Registry\Registry $state = null)
 {
     $item_type = $state->toObject()->item_type;
     $typeClass = 'Sp4kAppsCartPlugins' . ucfirst($item_type) . 'App';
     return $typeClass::getInstance($state)->getItem();
     //return Sp4kAppsCartPluginsItem::getInstance( $state );
 }
 /**
  * CVS Dump
  *
  * @param   object  $items   Items to pass through
  * @param   string  $report  Name of report to return.
  *
  * @return bool
  *
  * @since    1.7.0
  */
 public function getCsv($items, $report)
 {
     $date = new JDate('now');
     $jWeb = new JApplicationWeb();
     $csv = fopen('php://output', 'w');
     $jWeb->clearHeaders();
     // Clean the output buffer,
     @ob_end_clean();
     @ob_start();
     header("Content-type: text/csv");
     header("Content-Disposition: attachment; filename=report." . $report . '.' . $date->format('Y-m-d-His') . ".csv");
     header("Pragma: no-cache");
     header("Expires: 0");
     $count = 0;
     foreach ($items as $line) {
         foreach ($line as $c => $item) {
             if ($c == 'params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'attribs') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 $params_att = new stdClass();
                 foreach ($params as $p => $item_p) {
                     $p = 'att_' . $p;
                     if ($p == 'sex') {
                         switch ($item_p) {
                             case 0:
                                 $params_att->{$p} = 'M';
                                 break;
                             case 1:
                                 $params_att->{$p} = 'F';
                                 break;
                         }
                     } else {
                         $params_att->{$p} = $item_p;
                     }
                 }
                 unset($line->attribs);
                 $line = (object) array_merge((array) $line, (array) $params_att);
             } elseif ($c == 'kml_params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->kml_params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'category_params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->category_params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'metadata') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->metadata);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'con_position') {
                 $pos = [];
                 if ($item != 0) {
                     $positions = explode(',', $item);
                     foreach ($positions as $p => $position) {
                         $query = $this->db->getQuery(true);
                         // Join on Position.
                         $query->select('name');
                         $query->from('#__churchdirectory_position');
                         $query->where('id =' . $position);
                         $this->db->setQuery($query);
                         $pos[] = $this->db->loadResult();
                     }
                 } else {
                     $pos[] = null;
                 }
                 unset($line->con_position);
                 $line = (object) array_merge((array) $line, ['con_position' => implode(",", $pos)]);
             } elseif ($c == 'image') {
                 $line->{$c} = JUri::root() . $item;
             }
         }
         if ($count == 0) {
             $array = get_object_vars($line);
             fputcsv($csv, array_keys($array));
         }
         $count = 1;
         fputcsv($csv, (array) $line);
     }
     @ob_flush();
     @flush();
     fclose($csv);
     exit;
 }
Exemple #3
0
 private function setDummyState()
 {
     $cardState = new Joomla\Registry\Registry(['number' => '5555555555554444', 'expire_month' => '12', 'expire_year' => '2017', 'cvv2' => '123']);
     $this->getState()->set('card', $cardState->toObject());
     $transactionState = new Joomla\Registry\Registry(['total' => 100]);
     $this->getState()->set('transaction', $transactionState->toObject());
     $paymentState = new Joomla\Registry\Registry(['description' => 'test']);
     $this->getState()->set('payment', $paymentState->toObject());
 }