/** * Method to export one or more events * * @access public * @return boolean True on success * @since 1.5.0a */ function export($cid = array(), $table, $record_name) { $result = false; if (count($cid)) { $mdlJLXExports = JModel::getInstance("jlxmlexports", 'JoomleagueModel'); JArrayHelper::toInteger($cid); $cids = implode(',', $cid); $query = "SELECT * FROM #__joomleague_eventtype WHERE id IN ({$cids})"; $this->_db->setQuery($query); $exportData = $this->_db->loadObjectList(); $SportsTypeArray = array(); $x = 0; foreach ($exportData as $event) { $SportsTypeArray[$x] = $event->sports_type_id; } $st_cids = implode(',', $SportsTypeArray); $query = "SELECT * FROM #__joomleague_sports_type WHERE id IN ({$st_cids})"; $this->_db->setQuery($query); $exportDataSportsType = $this->_db->loadObjectList(); $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; // open the events $output .= "<events>\n"; $output .= $mdlJLXExports->_addToXml($mdlJLXExports->_getJoomLeagueVersion()); $record_name = 'SportsType'; //$tabVar=' '; $tabVar = ' '; foreach ($exportDataSportsType as $name => $value) { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($record_name) . "\">\n"; foreach ($value as $name2 => $value2) { if ($name2 != 'checked_out' && $name2 != 'checked_out_time') { $output .= $tabVar . '<' . $name2 . '><![CDATA[' . JoomleagueHelper::stripInvalidXml(trim($value2)) . ']]></' . $name2 . ">\n"; } } $output .= "</record>\n"; } unset($name, $value); $record_name = 'EventType'; foreach ($exportData as $name => $value) { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($record_name) . "\">\n"; foreach ($value as $name2 => $value2) { if ($name2 != 'checked_out' && $name2 != 'checked_out_time') { $output .= $tabVar . '<' . $name2 . '><![CDATA[' . JoomleagueHelper::stripInvalidXml(trim($value2)) . ']]></' . $name2 . ">\n"; } } $output .= "</record>\n"; } unset($name, $value); // close events $output .= '</events>'; $mdlJLXExports = JModel::getInstance("jlxmlexports", 'JoomleagueModel'); $mdlJLXExports->downloadXml($output, $table); // close the application $app = JFactory::getApplication(); $app->close(); } return true; }
/** * Method to export one or more leagues * * @access public * @return boolean True on success * @since 1.5.0a */ function export($cid = array(), $table, $record_name) { if (count($cid)) { $mdlJLXExport = JModelLegacy::getInstance("jlxmlexport", 'JoomleagueModel'); JArrayHelper::toInteger($cid); $cids = implode(',', $cid); $query = "SELECT * FROM #__joomleague_" . $table . " WHERE id IN ({$cids})"; $this->_db->setQuery($query); $exportData = $this->_db->loadObjectList(); $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<" . $table . "s>\n"; // get the version of JoomLeague $output .= $mdlJLXExport->_addToXml($mdlJLXExport->_getJoomLeagueVersion()); $tabVar = ' '; $record_name = $record_name; foreach ($exportData as $name => $value) { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($record_name) . "\">\n"; foreach ($value as $name2 => $value2) { if ($name2 != 'checked_out' && $name2 != 'checked_out_time') { $output .= $tabVar . '<' . $name2 . '><![CDATA[' . JoomleagueHelper::stripInvalidXml(trim($value2)) . ']]></' . $name2 . ">\n"; } } $output .= "</record>\n"; } unset($name, $value); $output .= '</' . $table . 's>'; $mdlJLXExport->downloadXml($output, $table); $app = JFactory::getApplication(); $app->close(); } }
/** * Method to export one or more positions * * @access public * @return boolean True on success */ function export($cid = array(), $table, $record_name) { $result = false; if (count($cid)) { JArrayHelper::toInteger($cid); $cids = implode(',', $cid); $query = "SELECT * FROM #__joomleague_position WHERE id IN ({$cids})"; $this->_db->setQuery($query); $exportData = $this->_db->loadObjectList(); $SportsTypeArray = array(); $x = 0; foreach ($exportData as $position) { $SportsTypeArray[$x] = $position->sports_type_id; } $st_cids = implode(',', $SportsTypeArray); $query = "SELECT * FROM #__joomleague_sports_type WHERE id IN ({$st_cids})"; //echo $query; $this->_db->setQuery($query); $exportDataSportsType = $this->_db->loadObjectList(); $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; // open the positions $output .= "<positions>\n"; $record_name = 'SportsType'; //$tabVar=' '; $tabVar = ' '; foreach ($exportDataSportsType as $name => $value) { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($record_name) . "\">\n"; foreach ($value as $name2 => $value2) { if ($name2 != 'checked_out' && $name2 != 'checked_out_time') { $output .= $tabVar . '<' . $name2 . '><![CDATA[' . JoomleagueHelper::stripInvalidXml(trim($value2)) . ']]></' . $name2 . ">\n"; } } $output .= "</record>\n"; } unset($name, $value); $record_name_position = 'Position'; $record_name_parent_position = 'ParentPosition'; foreach ($exportData as $name => $value) { if ($value->parent_id == 0) { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($record_name_parent_position) . "\">\n"; } else { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($record_name_position) . "\">\n"; } foreach ($value as $name2 => $value2) { if ($name2 != 'checked_out' && $name2 != 'checked_out_time') { $output .= $tabVar . '<' . $name2 . '><![CDATA[' . JoomleagueHelper::stripInvalidXml(trim($value2)) . ']]></' . $name2 . ">\n"; //echo "<pre>".$name2."#".$value2."<br /></pre>"; } } $output .= "</record>\n"; } unset($name, $value); // close positions $output .= '</positions>'; $mdlJLXExports = JModelLegacy::getInstance("jlxmlexport", 'JoomleagueModel'); $mdlJLXExports->downloadXml($output, $table, true); // close the application $app = JFactory::getApplication(); $app->close(); } return true; }
/** * Add data to the xml * * @param array $data data what we want to add in the xml * * @access public * @since 1.5.0a * * @return void */ public function _addToXml($data) { if (is_array($data) && count($data) > 0) { $object = $data[0]['object']; $output = ''; foreach ($data as $name => $value) { $output .= "<record object=\"" . JoomleagueHelper::stripInvalidXml($object) . "\">\n"; foreach ($value as $key => $data) { if (!is_null($data) && !(substr($key, 0, 1) == "_") && $key != "object") { $output .= " <{$key}><![CDATA[" . JoomleagueHelper::stripInvalidXml(trim($data)) . "]]></{$key}>\n"; } } $output .= "</record>\n"; } return $output; } return false; }