PageRenderTime 58ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/extensions/jlextdfbnetplayerimport/admin/models/jlextdfbnetplayerimport.php

https://gitlab.com/julienv/joomleague
PHP | 1844 lines | 1217 code | 262 blank | 365 comment | 151 complexity | 8866eeb06a9935e84ff5cee7420edaaa MD5 | raw file
  1. <?php
  2. /**
  3. * @copyright Copyright (C) 2005-2014 joomleague.at. All rights reserved.
  4. * @license GNU/GPL, see LICENSE.php
  5. * Joomla! is free software. This version may have been modified pursuant
  6. * to the GNU General Public License, and as distributed it includes or
  7. * is derivative of works licensed under the GNU General Public License or
  8. * other free or open source software licenses.
  9. * See COPYRIGHT.php for copyright notices and details.
  10. */
  11. /**
  12. * DFBNet Import by diddipoeler, www.fussballineuropa.de
  13. * Modified to work as an extension for JoomLeague 2.x by heart
  14. */
  15. // Check to ensure this file is included in Joomla!
  16. defined( '_JEXEC' ) or die( 'Restricted access' );
  17. $maxImportTime=JComponentHelper::getParams('com_joomleague')->get('max_import_time',0);
  18. if (empty($maxImportTime))
  19. {
  20. $maxImportTime=480;
  21. }
  22. if ((int)ini_get('max_execution_time') < $maxImportTime){@set_time_limit($maxImportTime);}
  23. $maxImportMemory=JComponentHelper::getParams('com_joomleague')->get('max_import_memory',0);
  24. if (empty($maxImportMemory))
  25. {
  26. $maxImportMemory='150M';
  27. }
  28. if ((int)ini_get('memory_limit') < (int)$maxImportMemory){@ini_set('memory_limit',$maxImportMemory);}
  29. jimport( 'joomla.application.component.model' );
  30. jimport('joomla.html.pane');
  31. require_once( JPATH_COMPONENT_SITE . DS. 'extensions' . DS. 'jlextdfbnetplayerimport' . DS. 'admin' . DS. 'helpers' . DS . 'helper.php' );
  32. require_once( JPATH_COMPONENT_SITE . DS. 'extensions' . DS. 'jlextdfbnetplayerimport' . DS. 'admin' . DS. 'helpers' . DS . 'ical.php' );
  33. //require_once( JPATH_COMPONENT_SITE . DS. 'extensions' . DS. 'jlextdfbnetplayerimport' . DS. 'admin' . DS. 'helpers' . DS . 'iCal2csv.php' );
  34. require_once ( JPATH_COMPONENT_SITE .DS . 'helpers' . DS . 'countries.php' );
  35. // import JArrayHelper
  36. jimport( 'joomla.utilities.array' );
  37. jimport( 'joomla.utilities.arrayhelper' ) ;
  38. // import JFile
  39. jimport('joomla.filesystem.file');
  40. jimport( 'joomla.utilities.utility' );
  41. class JoomleagueModeljlextdfbnetplayerimport extends JModel
  42. {
  43. var $_datas=array();
  44. var $_league_id=0;
  45. var $_season_id=0;
  46. var $_sportstype_id=0;
  47. var $import_version='';
  48. var $debug_info = false;
  49. var $_project_id = 0;
  50. function __construct( )
  51. {
  52. $show_debug_info = JComponentHelper::getParams('com_joomleague')->get('show_debug_info',0);
  53. if ( $show_debug_info )
  54. {
  55. $this->debug_info = true;
  56. }
  57. else
  58. {
  59. $this->debug_info = false;
  60. }
  61. parent::__construct( );
  62. }
  63. private function dump_header($text)
  64. {
  65. echo "<h1>$text</h1>";
  66. }
  67. private function dump_variable($description, $variable)
  68. {
  69. echo "<b>$description</b><pre>".print_r($variable,true)."</pre>";
  70. }
  71. function multisort($array, $sort_by, $key1, $key2=NULL, $key3=NULL, $key4=NULL, $key5=NULL, $key6=NULL)
  72. {
  73. // usage (only enter the keys you want sorted):
  74. // $sorted = multisort($array,'year','name','phone','address');
  75. // sort by ?
  76. foreach ($array as $pos => $val)
  77. $tmp_array[$pos] = $val[$sort_by];
  78. asort($tmp_array);
  79. // display however you want
  80. foreach ($tmp_array as $pos => $val){
  81. $return_array[$pos][$sort_by] = $array[$pos][$sort_by];
  82. $return_array[$pos][$key1] = $array[$pos][$key1];
  83. if (isset($key2)){
  84. $return_array[$pos][$key2] = $array[$pos][$key2];
  85. }
  86. if (isset($key3)){
  87. $return_array[$pos][$key3] = $array[$pos][$key3];
  88. }
  89. if (isset($key4)){
  90. $return_array[$pos][$key4] = $array[$pos][$key4];
  91. }
  92. if (isset($key5)){
  93. $return_array[$pos][$key5] = $array[$pos][$key5];
  94. }
  95. if (isset($key6)){
  96. $return_array[$pos][$key6] = $array[$pos][$key6];
  97. }
  98. }
  99. return $return_array;
  100. }
  101. function super_unique($array)
  102. {
  103. $result = array_map("unserialize", array_unique(array_map("serialize", $array)));
  104. foreach ($result as $key => $value)
  105. {
  106. if ( is_array($value) )
  107. {
  108. $result[$key] = $this->super_unique($value);
  109. }
  110. }
  111. return $result;
  112. }
  113. function property_value_in_array($array, $property, $value)
  114. {
  115. $flag = false;
  116. // echo 'property_value_in_array property -> '.$property.'<br>';
  117. // echo 'property_value_in_array property -> '.$value.'<br>';
  118. // echo 'property_value_in_array array<pre>';
  119. // print_r($array);
  120. // echo '</pre>';
  121. foreach($array[0] as $object)
  122. {
  123. // if(!is_object($object) || !property_exists($object, $property))
  124. // {
  125. // return false;
  126. // }
  127. // echo 'object->property -> '.$object->$property.'<br>';
  128. // echo 'value -> '.$value.'<br>';
  129. if($object->$property == $value)
  130. {
  131. $flag = true;
  132. }
  133. else
  134. {
  135. $flag = false;
  136. }
  137. }
  138. return $flag;
  139. }
  140. function getUpdateData()
  141. {
  142. global $mainframe, $option;
  143. $mainframe = JFactory::getApplication();
  144. $document = JFactory::getDocument();
  145. $lang = JFactory::getLanguage();
  146. $this->_success_text = '';
  147. $my_text = '';
  148. // echo 'lang <br>';
  149. // echo '<pre>';
  150. // print_r($lang);
  151. // echo '</pre>';
  152. // echo 'Die aktuelle Sprache lautet: ' . $lang->getName() . '<br>';
  153. //$teile = explode("-",$lang->getTag());
  154. // $country = Countries::convertIso2to3($teile[1]);
  155. // echo 'Das aktuelle Land lautet: ' . $country . '<br>';
  156. $country = "DEU"; // DFBNet gibt es nur in D, also ist die eingestellte Joomla Sprache nicht relevant
  157. $option='com_joomleague';
  158. $project = $mainframe->getUserState( $option . 'project', 0 );
  159. if ( !$project )
  160. {
  161. $mainframe->enqueueMessage(JText::_('COM_JOOMLEAGUE_ADMIN_DFBNET_IMPORT_NO_PROJECT'),'Error');
  162. }
  163. else
  164. {
  165. $this->getData();
  166. //$mainframe->enqueueMessage(JText::_('_datas match]<br><pre>'.print_r($this->_datas['match'],true).'</pre>' ),'');
  167. $updatedata = $this->getProjectUpdateData($this->_datas['match'],$project);
  168. // echo '<pre>';
  169. // print_r($updatedata);
  170. // echo '</pre><br>';
  171. foreach ( $updatedata as $row)
  172. {
  173. $p_match = $this->getTable('match');
  174. // paarung ist nicht vorhanden ?
  175. if ( !$row->id )
  176. {
  177. // sicherheitshalber nachschauen ob die paarung schon da ist
  178. $query = "SELECT ma.id
  179. from #__joomleague_match as ma
  180. where ma.round_id = '$row->round_id'
  181. and ma.projectteam1_id = '$row->projectteam1_id'
  182. and ma.projectteam2_id = '$row->projectteam2_id'
  183. ";
  184. $this->_db->setQuery( $query );
  185. $tempid = $this->_db->loadResult();
  186. if ( $tempid )
  187. {
  188. $p_match->set('id',$tempid);
  189. }
  190. else
  191. {
  192. $p_match->set('round_id',$row->round_id);
  193. }
  194. }
  195. else
  196. {
  197. $p_match->set('id',$row->id);
  198. }
  199. // spiel wurde verlegt
  200. if ( $row->match_date_verlegt )
  201. {
  202. $p_match->set('match_date',$row->match_date_verlegt);
  203. }
  204. else
  205. {
  206. $p_match->set('match_date',$row->match_date);
  207. }
  208. $p_match->set('published',$row->published);
  209. $p_match->set('count_result',$row->count_result);
  210. $p_match->set('show_report',$row->show_report);
  211. $p_match->set('summary',$row->summary);
  212. $p_match->set('projectteam1_id',$row->projectteam1_id);
  213. $p_match->set('projectteam2_id',$row->projectteam2_id);
  214. $p_match->set('match_number',$row->match_number);
  215. if ( is_numeric($row->team1_result) && is_numeric($row->team2_result) &&
  216. isset($row->team1_result) && isset($row->team2_result) )
  217. {
  218. $my_text .= '<span style="color:blue">';
  219. $my_text .= JText::sprintf('COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_RESULT_YES');
  220. $my_text .= '</span><br />';
  221. $this->_success_text['COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_DATA']=$my_text;
  222. }
  223. else
  224. {
  225. $my_text .= '<span style="color:red">';
  226. $my_text .= JText::sprintf('COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_RESULT_NO');
  227. $my_text .= '</span><br />';
  228. $this->_success_text['COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_DATA']=$my_text;
  229. }
  230. if ($p_match->store()===false)
  231. {
  232. $my_text .= 'COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_DATA_ERROR';
  233. $my_text .= $row->match_number;
  234. $my_text .= "<br />Error: _updateMatches<br />#$my_text#<br />#<pre>".print_r($p_match,true).'</pre>#';
  235. $this->_success_text['COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_DATA']=$my_text;
  236. return false;
  237. }
  238. else
  239. {
  240. $my_text .= '<span style="color:green">';
  241. $my_text .= JText::sprintf( 'Update Spielnummer: %1$s / Paarung: %2$s - %3$s',
  242. '</span><strong>'.$row->match_number.'</strong><span style="color:green">',
  243. "</span><strong>$row->projectteam1_dfbnet</strong>",
  244. "<strong>$row->projectteam2_dfbnet</strong>");
  245. $my_text .= '<br />';
  246. $this->_success_text['COM_JOOMLEAGUE_ADMIN_DFBNET_UPDATE_MATCH_DATA']=$my_text;
  247. }
  248. }
  249. }
  250. $this->_SetRoundDates($project);
  251. return $this->_success_text;
  252. }
  253. function getProjectUpdateData($csvdata,$project)
  254. {
  255. global $mainframe, $option;
  256. $mainframe = JFactory::getApplication();
  257. $document = JFactory::getDocument();
  258. $exportmatch = array();
  259. foreach ( $csvdata as $row )
  260. {
  261. $tempmatch = new stdClass();
  262. // round_id suchen
  263. $query = "SELECT r.id
  264. from #__joomleague_round as r
  265. where r.project_id = '$project'
  266. and r.roundcode = '$row->round_id'
  267. ";
  268. $this->_db->setQuery( $query );
  269. $tempmatch->round_id = $this->_db->loadResult();
  270. $tempmatch->roundcode = $row->round_id;
  271. $tempmatch->match_date = $row->match_date;
  272. $tempmatch->match_date_verlegt = $row->match_date_verlegt;
  273. $tempmatch->match_number = $row->match_number;
  274. $tempmatch->published = 1;
  275. $tempmatch->count_result = 1;
  276. $tempmatch->show_report = 1;
  277. $tempmatch->projectteam1_dfbnet = $row->projectteam1_dfbnet;
  278. $tempmatch->projectteam2_dfbnet = $row->projectteam2_dfbnet;
  279. // projectteam1_id suchen
  280. $query = "SELECT pt.id
  281. from #__joomleague_project_team as pt
  282. inner join #__joomleague_team as te
  283. on te.id = pt.team_id
  284. where pt.project_id = '$project'
  285. and te.name like '$row->projectteam1_dfbnet'
  286. ";
  287. $this->_db->setQuery( $query );
  288. $tempmatch->projectteam1_id = $this->_db->loadResult();
  289. // projectteam2_id suchen
  290. $query = "SELECT pt.id
  291. from #__joomleague_project_team as pt
  292. inner join #__joomleague_team as te
  293. on te.id = pt.team_id
  294. where pt.project_id = '$project'
  295. and te.name like '$row->projectteam2_dfbnet'
  296. ";
  297. $this->_db->setQuery( $query );
  298. $tempmatch->projectteam2_id = $this->_db->loadResult();
  299. $tempmatch->team1_result = $row->team1_result;
  300. $tempmatch->team2_result = $row->team2_result;
  301. $tempmatch->summary = '';
  302. $query = "SELECT ma.id
  303. from #__joomleague_match as ma
  304. where ma.round_id = '$tempmatch->round_id'
  305. and ma.projectteam1_id = '$tempmatch->projectteam1_id'
  306. and ma.projectteam2_id = '$tempmatch->projectteam2_id'
  307. ";
  308. $this->_db->setQuery( $query );
  309. $tempmatch->id = $this->_db->loadResult();
  310. $exportmatch[] = $tempmatch;
  311. }
  312. $updatematches = array_merge($exportmatch);
  313. return $updatematches;
  314. }
  315. function getData()
  316. {
  317. global $mainframe, $option;
  318. $mainframe = JFactory::getApplication();
  319. $document = JFactory::getDocument();
  320. //$lang = JFactory::getLanguage();
  321. if ( $this->debug_info )
  322. {
  323. $this->pane = JPane::getInstance('sliders');
  324. echo $this->pane->startPane('pane');
  325. }
  326. // echo 'lang <br>';
  327. // echo '<pre>';
  328. // print_r($lang);
  329. // echo '</pre>';
  330. // echo 'Die aktuelle Sprache lautet: ' . $lang->getName() . '<br>';
  331. // $teile = explode("-",$lang->getTag());
  332. // $country = Countries::convertIso2to3($teile[1]);
  333. // echo 'Das aktuelle Land lautet: ' . $country . '<br>';
  334. $country = "DEU"; // DFBNet gibt es nur in D, also ist die eingestellte Joomla Sprache nicht relevant
  335. $option='com_joomleague';
  336. $project = $mainframe->getUserState( $option . 'project', 0 );
  337. //$lmoimportuseteams=$mainframe->getUserState($option.'lmoimportuseteams');
  338. $whichfile=$mainframe->getUserState($option.'whichfile');
  339. $mainframe->enqueueMessage(JText::_('Welches Land? '.$country),'');
  340. $mainframe->enqueueMessage(JText::_('Welche Art von Datei? '.$whichfile),'');
  341. //$delimiter=$mainframe->getUserState($option.'delimiter');
  342. $post = JRequest::get('post');
  343. $this->_league_new_country = $country;
  344. $exportpositioneventtype = array();
  345. $exportplayer = array();
  346. $exportpersons = array();
  347. $exportpersonstemp = array();
  348. $exportclubs = array();
  349. $exportclubsstandardplayground = array();
  350. $exportplaygroundclubib = array();
  351. $exportteams = array();
  352. $exportteamstemp = array();
  353. $exportteamplayer = array();
  354. $exportprojectteam = array();
  355. $exportprojectteams = array();
  356. $exportreferee = array();
  357. $exportprojectposition = array();
  358. $exportposition = array();
  359. $exportparentposition = array();
  360. $exportplayground = array();
  361. $exportplaygroundtemp = array();
  362. $exportteamplaygroundtemp = array();
  363. $exportround = array();
  364. $exportmatch = array();
  365. $exportmatchplayer = array();
  366. $exportmatchevent = array();
  367. $exportevent = array();
  368. $exportpositiontemp = array();
  369. $exportposition = array();
  370. $exportparentposition = array();
  371. $exportprojectposition = array();
  372. $exportmatchreferee = array();
  373. $exportmatchplan = array();
  374. $temp_match_number = array();
  375. $startline = 0;
  376. // echo 'post <br>';
  377. // echo '<pre>';
  378. // print_r($post[projects]);
  379. // echo '</pre>';
  380. if ( isset($post['projects']) )
  381. {
  382. $this->_project_id = $post['projects'];
  383. }
  384. $file = JPATH_SITE.DS.'tmp'.DS.'joomleague_import.csv';
  385. $mainframe->enqueueMessage(JText::_('Datei? '.$file),'');
  386. if ( $whichfile == 'playerfile' )
  387. {
  388. /*
  389. * ##### structure of playerfile #####
  390. * Passnr.;
  391. * Name;
  392. * Vorname;
  393. * Altersklasse;
  394. * Geburtsdatum;
  395. * Spielrecht Pflicht / Verband;
  396. * Spielrecht Freundschaft / Privat;
  397. * Abmeldung;
  398. * Spielerstatus;
  399. * Gast/Zweitspielrecht;
  400. * Spielzeit;
  401. * Spielart;
  402. * Passdruck;
  403. * Einsetzbar;
  404. * Stammverein
  405. */
  406. $startline = 9 ;
  407. }
  408. elseif ( $whichfile == 'matchfile' )
  409. {
  410. /*
  411. * ##### structure of matchfile #####
  412. * Datum;0
  413. * Zeit;1
  414. * Saison;2
  415. * Verband;3
  416. * Mannschaftsart_Key;4
  417. * Mannschaftsart;5
  418. * Spielklasse_Key;6
  419. * Spielklasse;7
  420. * Spielgebiet_Key;8
  421. * Spielgebiet;9
  422. * Rahmenspielplan;10
  423. * Staffel_Nr;11
  424. * Staffel;12
  425. * Staffelkennung;13
  426. * Staffelleiter;14
  427. * Spieldatum;15
  428. * Uhrzeit;16
  429. * Wochentag;17
  430. * Spieltag;18
  431. * Schlüsseltag;19
  432. * Spielkennung;22
  433. * Heimmannschaft;20
  434. * Gastmannschaft;21
  435. * freigegeben;23
  436. * Spielstätte;24
  437. * Spielleitung;25
  438. * Assistent 1;26
  439. * Assistent 2;27
  440. * verlegtWochentag;28
  441. * verlegtSpieldatum;29
  442. * verlegtUhrzeit;30
  443. */
  444. $startline = 1 ;
  445. }
  446. elseif ( $whichfile == 'icsfile' )
  447. {
  448. // kalender file vom bfv anfang
  449. $ical = new ical();
  450. $ical->parse($file);
  451. $icsfile = $ical->get_all_data();
  452. if ( $this->debug_info )
  453. {
  454. echo $this->pane->startPanel('icsfile','icsfile');
  455. $this->dump_header("icsfile");
  456. $this->dump_variable("icsfile", $icsfile);
  457. echo $this->pane->endPanel();
  458. echo $this->pane->startPanel('icsfile Termine','icsfile Termine');
  459. $this->dump_header("icsfile Termine");
  460. $this->dump_variable("icsfile Termine", $icsfile['VEVENT']);
  461. echo $this->pane->endPanel();
  462. //echo 'icsfile -> <br /><pre>~'.print_r($icsfile,true).'~</pre><br />';
  463. //echo 'icsfile termine -> <br /><pre>~'.print_r($icsfile['VEVENT'],true).'~</pre><br />';
  464. }
  465. //
  466. $lfdnumber = 0;
  467. $lfdnumberteam = 1;
  468. $lfdnumbermatch = 1;
  469. $lfdnumberplayground = 1;
  470. for ($a=0; $a < sizeof($icsfile['VEVENT']) ;$a++ )
  471. {
  472. // Mannschaften, die spielfrei haben werden in der ics Datei "mit fehlender Gastmannschaft", z.B.
  473. // SUMMARY:FC Kempten-\, BZL Schwaben Süd
  474. // bzw. "mit fehlender Heimmannschaft" ausgegeben, z.B.
  475. // SUMMARY:-SVO Germaringen\, BZL Schwaben Süd
  476. // Diese VEVENT Blöcke sollen ausgeschlossen werden
  477. if ( (!strstr($icsfile['VEVENT'][$a]['SUMMARY'], "-\,")) && (!strpos($icsfile['VEVENT'][$a]['SUMMARY'], "-") == "0" ) )
  478. {
  479. //$mainframe->enqueueMessage($a .' -> '.$icsfile['VEVENT'][$a]['SUMMARY'] .'<br>');
  480. //$mainframe->enqueueMessage($a .' -> '.strpos($icsfile['VEVENT'][$a]['SUMMARY'], "-").'<br>');
  481. $icsfile['VEVENT'][$a]['UID'] = $lfdnumbermatch;
  482. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['match_date'] = date('Y-m-d', $icsfile['VEVENT'][$a]['DTSTART'])." ".date('H:i',$icsfile['VEVENT'][$a]['DTSTART']);
  483. // Paarung
  484. $teile = explode("\,",$icsfile['VEVENT'][$a]['SUMMARY']);
  485. $teile2 = explode("-",$teile[0]);
  486. if ( empty($lfdnumber) )
  487. {
  488. $projectname = trim($teile[1]);
  489. }
  490. $text = $teile[0];
  491. $anzahltrenner = substr_count($text, '-');
  492. //$mainframe->enqueueMessage('Ich habe -> '.$anzahltrenner.' Trennzeichen <br>');
  493. if ($anzahltrenner > 1) {
  494. $convert = array(
  495. '-SV' => ':SV',
  496. '-SVO' => ':SVO',
  497. '-FC' => ':FC',
  498. '-TSV' => ':TSV',
  499. '-JFG' => ':JFG',
  500. '-TV' => ':TV',
  501. '-ASV' => ':ASV',
  502. '-SSV' => ':SSV',
  503. '-(SG)' => ':(SG)',
  504. '-SpVgg' => ':SpVgg',
  505. '-VfB' => ':VfB',
  506. '-FSV' => ':FSV',
  507. '-BSK' => ':BSK'
  508. );
  509. if (preg_match("/-SV/i", $teile[0]) ||
  510. preg_match("/-SVO/i", $teile[0]) ||
  511. preg_match("/-TSV/i", $teile[0]) ||
  512. preg_match("/-JFG/i", $teile[0]) ||
  513. preg_match("/-TV/i", $teile[0]) ||
  514. preg_match("/-ASV/i", $teile[0]) ||
  515. preg_match("/-SSV/i", $teile[0]) ||
  516. preg_match("/-(SG)/i", $teile[0]) ||
  517. preg_match("/-SpVgg/i", $teile[0]) ||
  518. preg_match("/-VfB/i", $teile[0]) ||
  519. preg_match("/-FSV/i", $teile[0]) ||
  520. preg_match("/-BSK/i", $teile[0]) ||
  521. preg_match("/-FC/i", $teile[0])
  522. ) {
  523. $teile[0] = str_replace(array_keys($convert), array_values($convert), $teile[0]);
  524. $teile2 = explode(":", $teile[0]);
  525. } else {
  526. $pos = strrpos($teile[0], "-");
  527. //echo 'letzte position -> '.$pos.' trennzeichen <br>';
  528. $teile2[0] = substr($teile[0], 0, $pos);
  529. $teile2[1] = substr($teile[0], $pos + 1, 100);
  530. }
  531. }
  532. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['heim'] = trim($teile2[0]);
  533. $valueheim = trim($teile2[0]);
  534. //$exportteamplaygroundtemp[$valueheim] = $valueplayground;
  535. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['gast'] = trim($teile2[1]);
  536. $valuegast = trim($teile2[1]);
  537. // heimmannschaft
  538. if ( array_key_exists($valueheim, $exportteamstemp) )
  539. {
  540. }
  541. else
  542. {
  543. $exportteamstemp[$valueheim] = $lfdnumberteam;
  544. $lfdnumberteam++;
  545. }
  546. // gastmannschaft
  547. if ( array_key_exists($valuegast, $exportteamstemp) )
  548. {
  549. }
  550. else
  551. {
  552. $exportteamstemp[$valuegast] = $lfdnumberteam;
  553. $lfdnumberteam++;
  554. }
  555. if ( isset($icsfile['VEVENT'][$a]['LOCATION']) )
  556. {
  557. // sportanlage neu
  558. $teile = explode("\,",$icsfile['VEVENT'][$a]['LOCATION']);
  559. if ( sizeof($teile) === 4 )
  560. {
  561. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground'] = trim($teile[0]);
  562. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_strasse'] = trim($teile[1]);
  563. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_plz'] = trim($teile[2]);
  564. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_ort'] = trim($teile[3]);
  565. $valueplayground = trim($teile[0]);
  566. $address = trim($teile[1]);
  567. $zipcode = trim($teile[2]);
  568. $city = trim($teile[3]);
  569. }
  570. else
  571. {
  572. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground'] = '';
  573. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_strasse'] = trim($teile[0]);
  574. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_plz'] = trim($teile[1]);
  575. $exportmatchplan[$icsfile['VEVENT'][$a]['UID']]['playground_ort'] = trim($teile[2]);
  576. $valueplayground = $valueheim;
  577. $address = trim($teile[0]);
  578. $zipcode = trim($teile[1]);
  579. $city = trim($teile[2]);
  580. }
  581. }
  582. if ( $valueplayground )
  583. {
  584. $exportteamplaygroundtemp[$valueheim] = $valueplayground;
  585. if ( array_key_exists($valueplayground, $exportplaygroundtemp) )
  586. {
  587. }
  588. else
  589. {
  590. $exportplaygroundtemp[$valueplayground] = $lfdnumberplayground;
  591. $temp = new stdClass();
  592. $temp->id = $lfdnumberplayground;
  593. $temp->name = $valueplayground;
  594. $temp->short_name = $valueplayground;
  595. $temp->alias = $valueplayground;
  596. $temp->club_id = $exportteamstemp[$valueheim];
  597. $temp->address = $address;
  598. $temp->zipcode = $zipcode;
  599. $temp->city = $city;
  600. $temp->country = $country;
  601. $temp->max_visitors = 0;
  602. $exportplayground[] = $temp;
  603. $lfdnumberplayground++;
  604. }
  605. }
  606. if ( empty($lfdnumber) )
  607. {
  608. $temp = new stdClass();
  609. $temp->name = $projectname;
  610. $temp->exportRoutine = '2010-09-19 23:00:00';
  611. $this->_datas['exportversion'] = $temp;
  612. $temp = new stdClass();
  613. $temp->name = '';
  614. $this->_datas['season'] = $temp;
  615. $temp = new stdClass();
  616. $temp->id = 1;
  617. $temp->name = 'COM_JOOMLEAGUE_ST_SOCCER';
  618. $this->_datas['sportstype'] = $temp;
  619. $temp = new stdClass();
  620. $temp->name = $projectname;
  621. $temp->alias = $projectname;
  622. $temp->short_name = $projectname;
  623. $temp->middle_name = $projectname;
  624. $temp->country = $country;
  625. $this->_datas['league'] = $temp;
  626. $temp = new stdClass();
  627. $temp->name = $projectname;
  628. $temp->serveroffset = 0;
  629. $temp->project_type = 'SIMPLE_LEAGUE';
  630. $temp->current_round_auto = '2';
  631. $temp->auto_time = '2880';
  632. $temp->start_date = '2013-08-08';
  633. $temp->start_time = '15:30';
  634. $temp->game_regular_time = '90';
  635. $temp->game_parts = '2';
  636. $temp->halftime = '15';
  637. $temp->points_after_regular_time = '3,1,0';
  638. $temp->use_legs = '0';
  639. $temp->allow_add_time = '0';
  640. $temp->add_time = '30';
  641. $temp->points_after_add_time = '3,1,0';
  642. $temp->points_after_penalty = '3,1,0';
  643. $this->_datas['project'] = $temp;
  644. }
  645. $lfdnumber++;
  646. $lfdnumbermatch++;
  647. } //spielfreie Mannschaften ausschließen
  648. }
  649. ksort($exportmatchplan);
  650. if ( $this->debug_info )
  651. {
  652. echo $this->pane->startPanel('icsfile exportmatchplan','icsfile exportmatchplan');
  653. $this->dump_header("icsfile exportmatchplan");
  654. $this->dump_variable("icsfile exportmatchplan", $exportmatchplan);
  655. echo $this->pane->endPanel();
  656. echo $this->pane->startPanel('icsfile exportteamstemp','icsfile exportteamstemp');
  657. $this->dump_header("icsfile exportteamstemp");
  658. $this->dump_variable("icsfile exportteamstemp", $exportteamstemp);
  659. echo $this->pane->endPanel();
  660. //echo 'icsfile exportmatchplan -> <br /><pre>~'.print_r($exportmatchplan,true).'~</pre><br />';
  661. //echo 'icsfile exportteamstemp -> <br /><pre>~'.print_r($exportteamstemp,true).'~</pre><br />';
  662. }
  663. //$mainframe->enqueueMessage('<pre>'.print_r($exportteamstemp,true).'</pre>');
  664. // teams verarbeiten
  665. foreach ( $exportteamstemp as $key => $value )
  666. {
  667. // team
  668. $temp = new stdClass();
  669. $temp->id = $value;
  670. $temp->club_id = $value;
  671. $temp->name = $key;
  672. $temp->middle_name = $key;
  673. $temp->short_name = $key;
  674. //$temp->info = '';
  675. $temp->info = 'Herren ';
  676. $temp->extended = '';
  677. $exportteams[] = $temp;
  678. $standard_playground = $exportteamplaygroundtemp[$key];
  679. $standard_playground_nummer = $exportplaygroundtemp[$standard_playground];
  680. // club
  681. $temp = new stdClass();
  682. $temp->id = $value;
  683. $temp->name = $key;
  684. $temp->country = $country;
  685. $temp->extended = '';
  686. $temp->standard_playground = $standard_playground_nummer;
  687. $exportclubs[] = $temp;
  688. // projektteam
  689. $temp = new stdClass();
  690. $temp->id = $value;
  691. $temp->team_id = $value;
  692. $temp->project_team_id = $value;
  693. $temp->is_in_score = 1;
  694. $temp->standard_playground = $standard_playground_nummer;
  695. $exportprojectteams[] = $temp;
  696. }
  697. $anzahlteams = sizeof($exportteamstemp);
  698. $mainframe->enqueueMessage(JText::_('Wir haben '.$anzahlteams.' Teams f&uuml;r die Berechnung der Spieltage und Paarungen pro Spieltag'),'');
  699. if ( $anzahlteams % 2 == 0 )
  700. {
  701. $anzahltage = ( $anzahlteams - 1 ) * 2;
  702. $anzahlpaarungen = $anzahlteams / 2;
  703. }
  704. else
  705. {
  706. //$anzahltage = ( $anzahlteams - 1 ) * 2;
  707. $anzahltage = $anzahlteams * 2;
  708. $anzahlpaarungen = ( $anzahlteams - 1 ) / 2;
  709. }
  710. $mainframe->enqueueMessage(JText::_('Wir haben '.$anzahltage.' Spieltage'),'');
  711. $mainframe->enqueueMessage(JText::_('Wir haben '.$anzahlpaarungen.' Paarungen pro Spieltag'),'');
  712. // echo "icsfile exportplaygroundtemp<pre>";
  713. // print_r($exportplaygroundtemp);
  714. // echo "</pre>";
  715. // so jetzt die runden erstellen
  716. for ($a=1; $a <= $anzahltage ;$a++ )
  717. {
  718. $temp = new stdClass();
  719. $temp->id = $a;
  720. $temp->roundcode = $a;
  721. $temp->name = $a.'. Spieltag';
  722. $temp->alias = $a.'-spieltag';
  723. $temp->round_date_first = '';
  724. $temp->round_date_last = '';
  725. $exportround[$a] = $temp;
  726. }
  727. // so jetzt die spiele erstellen
  728. $lfdnumbermatch = 1;
  729. $lfdnumberpaarung = 1;
  730. $lfdnumberspieltag = 1;
  731. foreach ( $exportmatchplan as $key => $value )
  732. {
  733. // echo "icsfile spiele erstellen<pre>";
  734. // print_r($value);
  735. // echo "</pre>";
  736. $tempmatch = new stdClass();
  737. $tempmatch->id = $lfdnumbermatch;
  738. $tempmatch->match_number = $lfdnumbermatch;
  739. $tempmatch->published = 1;
  740. $tempmatch->count_result = 1;
  741. $tempmatch->show_report = 1;
  742. $tempmatch->team1_result = '';
  743. $tempmatch->team2_result = '';
  744. $tempmatch->summary = '';
  745. $tempmatch->match_date = $value['match_date'];
  746. if ( isset($value['playground']) )
  747. {
  748. if ( array_key_exists($value['playground'], $exportplaygroundtemp) )
  749. {
  750. $tempmatch->playground_id = $exportplaygroundtemp[$value['playground']];
  751. }
  752. }
  753. $tempmatch->projectteam1_id = $exportteamstemp[$value['heim']];
  754. $tempmatch->projectteam2_id = $exportteamstemp[$value['gast']];
  755. $tempmatch->round_id = $lfdnumberspieltag;
  756. $exportmatch[] = $tempmatch;
  757. if ( $lfdnumberpaarung == $anzahlpaarungen )
  758. {
  759. $lfdnumberpaarung = 0;
  760. $lfdnumberspieltag++;
  761. }
  762. $lfdnumbermatch++;
  763. $lfdnumberpaarung++;
  764. }
  765. // daten übergeben
  766. $this->_datas['round'] = array_merge($exportround);
  767. $this->_datas['match'] = array_merge($exportmatch);
  768. $this->_datas['team'] = array_merge($exportteams);
  769. $this->_datas['projectteam'] = array_merge($exportprojectteams);
  770. $this->_datas['club'] = array_merge($exportclubs);
  771. $this->_datas['playground'] = array_merge($exportplayground);
  772. /**
  773. * das ganze für den standardimport aufbereiten
  774. */
  775. $output = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
  776. // open the project
  777. $output .= "<project>\n";
  778. // set the version of JoomLeague
  779. $output .= $this->_addToXml($this->_setJoomLeagueVersion());
  780. // set the project datas
  781. if ( isset($this->_datas['project']) )
  782. {
  783. $output .= $this->_addToXml($this->_setProjectData($this->_datas['project']));
  784. }
  785. // set league data of project
  786. if ( isset($this->_datas['league']) )
  787. {
  788. $output .= $this->_addToXml($this->_setLeagueData($this->_datas['league']));
  789. }
  790. // set season data of project
  791. if ( isset($this->_datas['season']) )
  792. {
  793. $output .= $this->_addToXml($this->_setSeasonData($this->_datas['season']));
  794. }
  795. // set the rounds data
  796. if ( isset($this->_datas['round']) )
  797. {
  798. $output .= $this->_addToXml($this->_setXMLData($this->_datas['round'], 'Round') );
  799. }
  800. // set the teams data
  801. if ( isset($this->_datas['team']) )
  802. {
  803. $output .= $this->_addToXml($this->_setXMLData($this->_datas['team'], 'JL_Team'));
  804. }
  805. // set the clubs data
  806. if ( isset($this->_datas['club']) )
  807. {
  808. $output .= $this->_addToXml($this->_setXMLData($this->_datas['club'], 'Club'));
  809. }
  810. // set the matches data
  811. if ( isset($this->_datas['match']) )
  812. {
  813. $output .= $this->_addToXml($this->_setXMLData($this->_datas['match'], 'Match'));
  814. }
  815. // set the positions data
  816. if ( isset($this->_datas['position']) )
  817. {
  818. // von mir
  819. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['position'], 'Position'));
  820. }
  821. // set the positions parent data
  822. if ( isset($this->_datas['parentposition']) )
  823. {
  824. // von mir
  825. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['parentposition'], 'ParentPosition'));
  826. }
  827. // set position data of project
  828. if ( isset($this->_datas['projectposition']) )
  829. {
  830. // von mir
  831. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['projectposition'], 'ProjectPosition'));
  832. }
  833. // set the matchreferee data
  834. if ( isset($this->_datas['matchreferee']) )
  835. {
  836. // von mir
  837. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['matchreferee'], 'MatchReferee'));
  838. }
  839. // set the person data
  840. if ( isset($this->_datas['person']) )
  841. {
  842. // von mir
  843. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['person'], 'Person'));
  844. }
  845. // set the projectreferee data
  846. if ( isset($this->_datas['projectreferee']) )
  847. {
  848. // von mir
  849. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['projectreferee'], 'ProjectReferee'));
  850. }
  851. // set the projectteam data
  852. if ( isset($this->_datas['projectteam']) )
  853. {
  854. $output .= $this->_addToXml($this->_setXMLData($this->_datas['projectteam'], 'ProjectTeam'));
  855. }
  856. // set playground data of project
  857. if ( isset($this->_datas['playground']) )
  858. {
  859. // von mir
  860. //$output .= $this->_addToXml($this->_setXMLData($this->_datas['playground'], 'Playground'));
  861. }
  862. // close the project
  863. $output .= '</project>';
  864. // mal als test
  865. $xmlfile = $output;
  866. $file = JPATH_SITE.DS.'tmp'.DS.'joomleague_import.jlg';
  867. JFile::write($file, $xmlfile);
  868. if ( $this->debug_info )
  869. {
  870. echo $this->pane->startPanel('getdata club','getdata club');
  871. $this->dump_header("getdata club");
  872. $this->dump_variable("this->_datas['club']", $this->_datas['club']);
  873. echo $this->pane->endPanel();
  874. echo $this->pane->startPanel('getdata team','getdata team');
  875. $this->dump_header("getdata team");
  876. $this->dump_variable("this->_datas['team']", $this->_datas['team']);
  877. echo $this->pane->endPanel();
  878. echo $this->pane->startPanel('getdata projectteam','getdata projectteam');
  879. $this->dump_header("getdata projectteam");
  880. $this->dump_variable("this->_datas['projectteam']", $this->_datas['projectteam']);
  881. echo $this->pane->endPanel();
  882. echo $this->pane->startPanel('getdata playground','getdata playground');
  883. $this->dump_header("getdata playground");
  884. $this->dump_variable("this->_datas['playground']", $this->_datas['playground']);
  885. echo $this->pane->endPanel();
  886. echo $this->pane->startPanel('getdata round','getdata round');
  887. $this->dump_header("getdata round");
  888. $this->dump_variable("this->_datas['round']", $this->_datas['round']);
  889. echo $this->pane->endPanel();
  890. echo $this->pane->startPanel('getdata match','getdata match');
  891. $this->dump_header("getdata match");
  892. $this->dump_variable("this->_datas['match']", $this->_datas['match']);
  893. echo $this->pane->endPanel();
  894. }
  895. }
  896. // kalender file vom bfv ende
  897. /*
  898. csv->data
  899. Array
  900. (
  901. [0] => Array
  902. (
  903. [Datum] => 27.07.2010
  904. [Zeit] => 00:43:12
  905. [Saison] => 10/11
  906. [Verband] => Schleswig-Holsteinischer Fußballverband
  907. [Mannschaftsart_Key] => 013
  908. [Mannschaftsart] => Herren
  909. [Spielklasse_Key] => 058
  910. [Spielklasse] => Kreisklasse C
  911. [Spielgebiet_Key] => 032
  912. [Spielgebiet] => Kreis Nordfriesland
  913. [Rahmenspielplan] => 3
  914. [Staffel_Nr] => 2
  915. [Staffel] => Kreisklasse C-Süd
  916. [Staffelkennung] => 040423
  917. [Staffelleiter] => Bülter, Dirk
  918. [Spieldatum] => 28.08.2010
  919. [Uhrzeit] => 16:00
  920. [Wochentag] => Samstag
  921. [Spieltag] => 1
  922. [Schlüsseltag] => 2
  923. [Spielkennung] => 040423 001
  924. [Heimmannschaft] => TSV Drelsdorf III
  925. [Gastmannschaft] => 1.FC Wittbek
  926. [freigegeben] => Nein
  927. [Spielstätte] => A-Platz Drelsdorf
  928. [Spielleitung] => ,
  929. [Assistent 1] => ,
  930. [Assistent 2] => ,
  931. [verlegtWochentag] =>
  932. [verlegtSpieldatum] =>
  933. [verlegtUhrzeit] =>
  934. )
  935. */
  936. $teamid = 1;
  937. $this->fileName = JFile::read($file);
  938. $this->lines = file( $file );
  939. if( $this->lines )
  940. {
  941. $row = 0;
  942. /*
  943. foreach($this->lines as $line )
  944. {
  945. if ( $startline <= $row && $row <= count($this->lines) )
  946. {
  947. // spielerliste
  948. if ( $whichfile == 'playerfile' )
  949. {
  950. $fields = array();
  951. if ($delimiter == "\\t") {
  952. $fields = explode("\t", $line);
  953. } else {
  954. $fields = explode($delimiter, $line);
  955. }
  956. $temp = new stdClass();
  957. $temp->id = 0;
  958. $temp->knvbnr = $fields[0];
  959. $temp->lastname = $fields[1];
  960. $temp->firstname = $fields[2];
  961. $temp->country = $country;
  962. $temp->nickname = '';
  963. $temp->position_id = '';
  964. //$temp->lastname = utf8_encode ($temp->lastname);
  965. //$temp->firstname = utf8_encode ($temp->firstname);
  966. $temp->info = $fields[3];
  967. $datetime = strtotime($fields[4]);
  968. $temp->birthday = date('Y-m-d', $datetime);
  969. $exportplayer[] = $temp;
  970. $fields = "";
  971. }
  972. elseif ( $whichfile == 'matchfile' )
  973. {
  974. // spielplan anfang
  975. // spielplan ende
  976. }
  977. }
  978. $row++;
  979. }
  980. */
  981. if ( $whichfile == 'playerfile' )
  982. {
  983. // Spielerdatei
  984. # tab delimited, and encoding conversion
  985. $csv = new parseCSV();
  986. $csv->encoding('UTF-16', 'UTF-8');
  987. // Spielerdatei des DFBNet ist seit 2013 mit einem Tabulator als Delimiter, deswegen ist eine Auswahl nicht erforderlich
  988. $csv->delimiter = "\t";
  989. // switch ($delimiter)
  990. // {
  991. // case ";":
  992. // $csv->delimiter = ";";
  993. // break;
  994. // case ",":
  995. // $csv->delimiter = ",";
  996. // break;
  997. // default:
  998. // $csv->delimiter = "\t";
  999. // break;
  1000. // }
  1001. //$startrow = $jRegistry->get('cfg_dfbnet_player_startrow') - 2;
  1002. //$csv->parse($file,$startrow);
  1003. $startline = $startline - 1;
  1004. $csv->parse($file,$startline);
  1005. //$mainframe->enqueueMessage(JText::_('DEBUG Ausgabe der verarbeiteten Spielerdatei:<br><pre>'.print_r($csv->data,true).'</pre>' ),'');
  1006. // anfang schleife csv file
  1007. for($a=0; $a < sizeof($csv->data); $a++ )
  1008. {
  1009. $temp = new stdClass();
  1010. $temp->id = 0;
  1011. $temp->knvbnr = $csv->data[$a]['Passnr.'];
  1012. $temp->lastname = $csv->data[$a]['Name'];
  1013. $temp->firstname = $csv->data[$a]['Vorname'];
  1014. $temp->info = $csv->data[$a]['Altersklasse'];
  1015. $datetime = strtotime($csv->data[$a]['Geburtsdatum']);
  1016. $temp->birthday = date('Y-m-d', $datetime);
  1017. $temp->country = $country;
  1018. $temp->nickname = '';
  1019. $temp->position_id = '';
  1020. //$temp->lastname = utf8_encode ($temp->lastname);
  1021. //$temp->firstname = utf8_encode ($temp->firstname);
  1022. $exportplayer[] = $temp;
  1023. }
  1024. // spielerdatei
  1025. $temp = new stdClass();
  1026. $temp->name = 'playerfile';
  1027. $temp->exportRoutine = '2010-09-19 23:00:00';
  1028. $this->_datas['exportversion'] = $temp;
  1029. $this->_datas['person'] = array_merge($exportplayer);
  1030. }
  1031. elseif ( $whichfile == 'matchfile' )
  1032. {
  1033. // Spielplan anfang
  1034. # tab delimited, and encoding conversion
  1035. $csv = new parseCSV();
  1036. $csv->encoding('UTF-16', 'UTF-8');
  1037. // Spielplan des DFBNet ist seit 2013 mit einem Tabulator als Delimiter, deswegen ist eine Auswahl nicht erforderlich
  1038. $csv->delimiter = "\t";
  1039. // switch ($delimiter)
  1040. // {
  1041. // case ";":
  1042. // $csv->delimiter = ";";
  1043. // break;
  1044. // case ",":
  1045. // $csv->delimiter = ",";
  1046. // break;
  1047. // default:
  1048. // $csv->delimiter = "\t";
  1049. // break;
  1050. // }
  1051. $csv->parse($file);
  1052. if ( sizeof($csv->data) == 0 )
  1053. {
  1054. $mainframe->enqueueMessage(JText::_('Falsches Dateiformat'),'Error');
  1055. $importcsv = false;
  1056. }
  1057. else
  1058. {
  1059. //$mainframe->enqueueMessage(JText::_('result<br><pre>'.print_r($csv->data[0],true).'</pre>' ),'');
  1060. //$mainframe->enqueueMessage(JText::_('result<br><pre>'.print_r($csv->data,true).'</pre>' ),'');
  1061. $importcsv = true;
  1062. }
  1063. // echo 'csv->data<pre>';
  1064. // print_r($csv->data);
  1065. // echo '</pre>';
  1066. $lfdnumber = 0;
  1067. $lfdnumberteam = 1;
  1068. $lfdnumbermatch = 1;
  1069. $lfdnumberplayground = 1;
  1070. $lfdnumberperson = 1;
  1071. $lfdnumbermatchreferee = 1;
  1072. // anfang schleife csv file
  1073. for($a=0; $a < sizeof($csv->data); $a++ )
  1074. {
  1075. if ( empty($lfdnumber) )
  1076. {
  1077. /*
  1078. [Saison] => 10/11
  1079. [Verband] => Schleswig-Holsteinischer Fußballverband
  1080. [Mannschaftsart_Key] => 013
  1081. [Mannschaftsart] => Herren
  1082. [Spielklasse_Key] => 058
  1083. [Spielklasse] => Kreisklasse C
  1084. [Spielgebiet_Key] => 032
  1085. [Spielgebiet] => Kreis Nordfriesland
  1086. [Rahmenspielplan] => 3
  1087. [Staffel_Nr] => 2
  1088. [Staffel] => Kreisklasse C-Süd
  1089. */
  1090. $temp = new stdClass();
  1091. $temp->name = $csv->data[$a]['Verband'];
  1092. $temp->exportRoutine = '2010-09-19 23:00:00';
  1093. $this->_datas['exportversion'] = $temp;
  1094. $temp = new stdClass();
  1095. $temp->name = $csv->data[$a]['Saison'];
  1096. $this->_datas['season'] = $temp;
  1097. $temp = new stdClass();
  1098. $temp->name = $csv->data[$a]['Staffel'].' '.$csv->data[$a]['Staffel_Nr'];
  1099. $temp->country = $country;
  1100. $this->_datas['league'] = $temp;
  1101. $temp = new stdClass();
  1102. $temp->id = 1;
  1103. $temp->name = 'COM_JOOMLEAGUE_ST_SOCCER';
  1104. $this->_datas['sportstype'] = $temp;
  1105. $temp = new stdClass();
  1106. $temp->name = $csv->data[$a]['Staffel'].' '.$csv->data[$a]['Saison'];
  1107. $temp->serveroffset = 0;
  1108. $temp->sports_type_id = 1;
  1109. $temp->project_type = 'SIMPLE_LEAGUE';
  1110. $temp->current_round_auto = '2';
  1111. $temp->auto_time = '2880';
  1112. $temp->start_date = '2013-08-08';
  1113. $temp->start_time = '15:30';
  1114. $temp->game_regular_time = '90';
  1115. $temp->game_parts = '2';
  1116. $temp->halftime = '15';
  1117. $temp->points_after_regular_time = '3,1,0';
  1118. $temp->use_legs = '0';
  1119. $temp->allow_add_time = '0';
  1120. $temp->add_time = '30';
  1121. $temp->points_after_add_time = '3,1,0';
  1122. $temp->points_after_penalty = '3,1,0';
  1123. $this->_datas['project'] = $temp;
  1124. }
  1125. $valuematchday = $csv->data[$a]['Spieltag'];
  1126. if ( isset($exportround[$valuematchday]) )
  1127. {
  1128. }
  1129. else
  1130. {
  1131. $temp = new stdClass();
  1132. $temp->id = $valuematchday;
  1133. $temp->roundcode = $valuematchday;
  1134. $temp->name = $valuematchday.'. Spieltag';
  1135. $temp->alias = $valuematchday.'-spieltag';
  1136. $temp->round_date_first = '';
  1137. $temp->round_date_last = '';
  1138. $exportround[$valuematchday] = $temp;
  1139. }
  1140. // dfbnet heimmannschaft
  1141. $valueheim = $csv->data[$a]['Heim Mannschaft'];
  1142. if ( empty($valueheim) )
  1143. {
  1144. $valueheim = $csv->data[$a]['Heimmannschaft'];
  1145. }
  1146. if ( $valueheim != 'Spielfrei' )
  1147. {
  1148. if (in_array($valueheim, $exportteamstemp))
  1149. {
  1150. // echo $valueheim." <- enthalten<br>";
  1151. $exportclubsstandardplayground[$valueheim] = $csv->data[$a]['Spielstätte'];
  1152. $exportplaygroundclubib[$csv->data[$a]['Spielstätte']] = $valueheim;
  1153. }
  1154. else
  1155. {
  1156. // echo $valueheim." <- nicht enthalten<br>";
  1157. $exportclubsstandardplayground[$valueheim] = $csv->data[$a]['Spielstätte'];
  1158. $exportplaygroundclubib[$csv->data[$a]['Spielstätte']] = $valueheim;
  1159. $exportteamstemp[] = $valueheim;
  1160. $temp = new stdClass();
  1161. $temp->id = $lfdnumberteam;
  1162. $temp->club_id = $lfdnumberteam;
  1163. $temp->name = $valueheim;
  1164. $temp->middle_name = $valueheim;
  1165. $temp->short_name = $valueheim;
  1166. $temp->info = $csv->data[$a]['Mannschaftsart'];
  1167. $temp->extended = '';
  1168. $exportteams[] = $temp;
  1169. $mainframe->setUserState( $option."teamart", $temp->info );
  1170. // der clubname muss um die mannschaftsnummer verkürzt werden
  1171. if ( substr($valueheim, -4, 4) == ' III')
  1172. {
  1173. $convert = array (
  1174. ' III' => ''
  1175. );
  1176. $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim );
  1177. }
  1178. if ( substr($valueheim, -3, 3) == ' II')
  1179. {
  1180. $convert = array (
  1181. ' II' => ''
  1182. );
  1183. $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim );
  1184. }
  1185. if ( substr($valueheim, -2, 2) == ' I')
  1186. {
  1187. $convert = array (
  1188. ' I' => ''
  1189. );
  1190. $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim );
  1191. }
  1192. if ( substr($valueheim, -2, 2) == ' 3')
  1193. {
  1194. $convert = array (
  1195. ' 3' => ''
  1196. );
  1197. $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim );
  1198. }
  1199. if ( substr($valueheim, -2, 2) == ' 2')
  1200. {
  1201. $convert = array (
  1202. ' 2' => ''
  1203. );
  1204. $valueheim = str_replace(array_keys($convert), array_values($convert), $valueheim );
  1205. }
  1206. $temp = new stdClass();
  1207. $temp->id = $lfdnumberteam;
  1208. $club_id = $lfdnumberteam;
  1209. $temp->name = $valueheim;
  1210. $temp->country = $country;
  1211. $temp->extended = '';
  1212. $temp->standard_playground = $lfdnumberplayground;
  1213. $exportclubs[] = $temp;
  1214. $temp = new stdClass();
  1215. $temp->id = $lfdnumberteam;
  1216. $temp->team_id = $lfdnumberteam;
  1217. $temp->project_team_id = $lfdnumberteam;
  1218. $temp->is_in_score = 1;
  1219. $temp->division_id = 0;
  1220. $temp->start_points = 0;
  1221. $temp->points_finally = 0;
  1222. $temp->neg_points_finally = 0;
  1223. $temp->matches_finally = 0;
  1224. $temp->won_finally = 0;
  1225. $temp->draws_finally = 0;
  1226. $temp->lost_finally = 0;
  1227. $temp->homegoals_finally = 0;
  1228. $temp->guestgoals_finally = 0;
  1229. $temp->diffgoals_finally = 0;
  1230. $temp->standard_playground = $lfdnumberplayground;
  1231. $exportprojectteams[] = $temp;
  1232. $lfdnumberteam++;
  1233. }
  1234. }
  1235. // dfbnet gastmannschaft
  1236. $valuegast = $csv->data[$a]['Gast Mannschaft'];
  1237. if ( empty($valuegast) )
  1238. {
  1239. $valuegast = $csv->data[$a]['Gastmannschaft'];
  1240. }
  1241. if ( $valuegast != 'Spielfrei' )
  1242. {
  1243. if (in_array($valuegast, $exportteamstemp))
  1244. {
  1245. // echo $valuegast." <- enthalten<br>";
  1246. }
  1247. else
  1248. {
  1249. // echo $valuegast." <- nicht enthalten<br>";
  1250. $exportteamstemp[] = $valuegast;
  1251. $temp = new stdClass();
  1252. $temp->id = $lfdnumberteam;
  1253. $temp->club_id = $lfdnumberteam;
  1254. $temp->name = $valuegast;
  1255. $temp->middle_name = $valuegast;
  1256. $temp->short_name = $valuegast;
  1257. $temp->info = $csv->data[$a]['Mannschaftsart'];
  1258. $temp->extended = '';
  1259. $exportteams[] = $temp;
  1260. // der clubname muss um die mannschaftsnummer verkürzt werden
  1261. if ( substr($valuegast, -4, 4) == ' III')
  1262. {
  1263. $convert = array (
  1264. ' III' => ''
  1265. );
  1266. $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast );
  1267. }
  1268. if ( substr($valuegast, -3, 3) == ' II')
  1269. {
  1270. $convert = array (
  1271. ' II' => ''
  1272. );
  1273. $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast );
  1274. }
  1275. if ( substr($valuegast, -2, 2) == ' I')
  1276. {
  1277. $convert = array (
  1278. ' I' => ''
  1279. );
  1280. $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast );
  1281. }
  1282. if ( substr($valuegast, -2, 2) == ' 3')
  1283. {
  1284. $convert = array (
  1285. ' 3' => ''
  1286. );
  1287. $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast );
  1288. }
  1289. if ( substr($valuegast, -2, 2) == ' 2')
  1290. {
  1291. $convert = array (
  1292. ' 2' => ''
  1293. );
  1294. $valuegast = str_replace(array_keys($convert), array_values($convert), $valuegast );
  1295. }
  1296. $temp = new stdClass();
  1297. $temp->id = $lfdnumberteam;
  1298. $temp->name = $valuegast;
  1299. $temp->standard_playground = 0;
  1300. $temp->country = $country;
  1301. $temp->extended = '';
  1302. $exportclubs[] = $temp;
  1303. $temp = new stdClass();
  1304. $temp->id = $lfdnumberteam;
  1305. $temp->team_id = $lfdnumberteam;
  1306. $temp->project_team_id = $lfdnumberteam;
  1307. $temp->is_in_score = 1;
  1308. $temp->division_id = 0;
  1309. $temp->start_points = 0;
  1310. $temp->points_finally = 0;
  1311. $temp->neg_points_finally = 0;
  1312. $temp->matches_finally = 0;
  1313. $temp->won_finally = 0;
  1314. $temp->draws_finally = 0;
  1315. $temp->lost_finally = 0;
  1316. $temp->homegoals_finally = 0;
  1317. $temp->guestgoals_finally = 0;
  1318. $temp->diffgoals_finally = 0;
  1319. $temp->standard_playground = 0;
  1320. $exportprojectteams[] = $temp;
  1321. $lfdnumberteam++;
  1322. }
  1323. }
  1324. // dfbnet spielstaette
  1325. $valueplayground = $csv->data[$a]['Spielstätte'];
  1326. if ( $valueplayground )
  1327. {
  1328. if ( array_key_exists($valueplayground, $exportplaygroundtemp) )
  1329. {
  1330. // echo $valueplayground." <- enthalten<br>";
  1331. }
  1332. else
  1333. {
  1334. // echo $valueplayground." <- nicht enthalten<br>";
  1335. $exportplaygroundtemp[$valueplayground] = $lfdnumberplayground;
  1336. $temp = new stdClass();
  1337. $temp->id = $lfdnumberplayground;
  1338. $matchnumberplayground = $lfdnumberplayground;
  1339. $temp->name = $valueplayground;
  1340. $temp->short_name = $valueplayground;
  1341. $temp->country = $country;
  1342. $temp->max_visitors = 0;
  1343. $valueheimsuchen = $exportplaygroundclubib[$valueplayground];
  1344. foreach ( $exportteamstemp as $key => $value )
  1345. {
  1346. if ( $value == $valueheimsuchen )
  1347. {
  1348. $club_id = $key + 1;
  1349. }
  1350. }
  1351. $temp->club_id = $club_id;
  1352. $exportplayground[] = $temp;
  1353. //$mainframe->enqueueMessage(JText::_('playground -> '.$valueplayground ),'Notice');
  1354. //$mainframe->enqueueMessage(JText::_('heimmannschaft suchen -> '.$valueheimsuchen ),'Notice');
  1355. //$mainframe->enqueueMessage(JText::_('heimmannschaft club-id -> '.$club_id ),'Notice');
  1356. $lfdnumberplayground++;
  1357. }
  1358. }
  1359. $valueperson = $csv->data[$a]['Spielleitung'];
  1360. $valueperson1 = $csv->data[$a]['Assistent 1'];
  1361. $valueperson2 = $csv->data[$a]['Assistent 2'];
  1362. //if (in_array($valueperson, $exportpersonstemp))
  1363. if (array_key_exists($valueperson, $exportpersonstemp))
  1364. {
  1365. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1366. {
  1367. // nichts machen
  1368. }
  1369. else
  1370. {
  1371. $tempmatchreferee = new stdClass();
  1372. $tempmatchreferee->id = $lfdnumbermatchreferee;
  1373. $tempmatchreferee->match_id = $lfdnumbermatch;
  1374. $tempmatchreferee->project_referee_id = $exportpersonstemp[$valueperson];
  1375. $tempmatchreferee->project_position_id = 1000;
  1376. $exportmatchreferee[] = $tempmatchreferee;
  1377. $lfdnumbermatchreferee++;
  1378. }
  1379. }
  1380. else
  1381. {
  1382. if ( strlen($valueperson) > 6 && $valueperson )
  1383. {
  1384. // echo $valueperson." <- nicht enthalten<br>";
  1385. $exportpersonstemp[$valueperson] = $lfdnumberperson;
  1386. // nach- und vorname richtig setzen
  1387. $teile = explode(",",$valueperson);
  1388. $temp = new stdClass();
  1389. $temp->id = $lfdnumberperson;
  1390. $temp->person_id = $lfdnumberperson;
  1391. $temp->project_position_id = 1000;
  1392. $exportreferee[] = $temp;
  1393. $temp = new stdClass();
  1394. $temp->id = $lfdnumberperson;
  1395. $temp->lastname = trim($teile[0]);
  1396. $temp->firstname = trim($teile[1]);
  1397. $temp->nickname = '';
  1398. $temp->knvbnr = '';
  1399. $temp->location = '';
  1400. $temp->birthday = '0000-00-00';
  1401. $temp->country = $country;
  1402. $temp->position_id = 1000;
  1403. $temp->info = 'Schiri';
  1404. $exportpersons[] = $temp;
  1405. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1406. {
  1407. // nichts machen
  1408. }
  1409. else
  1410. {
  1411. $tempmatchreferee = new stdClass();
  1412. $tempmatchreferee->id = $lfdnumbermatchreferee;
  1413. $tempmatchreferee->match_id = $lfdnumbermatch;
  1414. $tempmatchreferee->project_referee_id = $lfdnumberperson;
  1415. $tempmatchreferee->project_position_id = 1000;
  1416. $exportmatchreferee[] = $tempmatchreferee;
  1417. $lfdnumbermatchreferee++;
  1418. }
  1419. $lfdnumberperson++;
  1420. }
  1421. }
  1422. // 1.assistent
  1423. if (array_key_exists($valueperson1, $exportpersonstemp))
  1424. {
  1425. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1426. {
  1427. // nichts machen
  1428. }
  1429. else
  1430. {
  1431. $tempmatchreferee = new stdClass();
  1432. $tempmatchreferee->id = $lfdnumbermatchreferee;
  1433. $tempmatchreferee->match_id = $lfdnumbermatch;
  1434. $tempmatchreferee->project_referee_id = $exportpersonstemp[$valueperson1];
  1435. $tempmatchreferee->project_position_id = 1001;
  1436. $exportmatchreferee[] = $tempmatchreferee;
  1437. $lfdnumbermatchreferee++;
  1438. }
  1439. }
  1440. else
  1441. {
  1442. if ( strlen($valueperson1) > 6 && $valueperson1 )
  1443. {
  1444. // echo $valueperson." <- nicht enthalten<br>";
  1445. $exportpersonstemp[$valueperson1] = $lfdnumberperson;
  1446. // nach- und vorname richtig setzen
  1447. $teile = explode(",",$valueperson1);
  1448. $temp = new stdClass();
  1449. $temp->id = $lfdnumberperson;
  1450. $temp->person_id = $lfdnumberperson;
  1451. $temp->project_position_id = 1001;
  1452. $exportreferee[] = $temp;
  1453. $temp = new stdClass();
  1454. $temp->id = $lfdnumberperson;
  1455. $temp->lastname = trim($teile[0]);
  1456. $temp->firstname = trim($teile[1]);
  1457. $temp->nickname = '';
  1458. $temp->knvbnr = '';
  1459. $temp->location = '';
  1460. $temp->birthday = '0000-00-00';
  1461. $temp->country = $country;
  1462. $temp->position_id = 1001;
  1463. $temp->info = 'Schiri';
  1464. $exportpersons[] = $temp;
  1465. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1466. {
  1467. // nichts machen
  1468. }
  1469. else
  1470. {
  1471. $tempmatchreferee = new stdClass();
  1472. $tempmatchreferee->id = $lfdnumbermatchreferee;
  1473. $tempmatchreferee->match_id = $lfdnumbermatch;
  1474. $tempmatchreferee->project_referee_id = $lfdnumberperson;
  1475. $tempmatchreferee->project_position_id = 1001;
  1476. $exportmatchreferee[] = $tempmatchreferee;
  1477. $lfdnumbermatchreferee++;
  1478. }
  1479. $lfdnumberperson++;
  1480. }
  1481. }
  1482. // 2.assistent
  1483. if (array_key_exists($valueperson2, $exportpersonstemp))
  1484. {
  1485. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1486. {
  1487. // nichts machen
  1488. }
  1489. else
  1490. {
  1491. $tempmatchreferee = new stdClass();
  1492. $tempmatchreferee->id = $lfdnumbermatchreferee;
  1493. $tempmatchreferee->match_id = $lfdnumbermatch;
  1494. $tempmatchreferee->project_referee_id = $exportpersonstemp[$valueperson2];
  1495. $tempmatchreferee->project_position_id = 1002;
  1496. $exportmatchreferee[] = $tempmatchreferee;
  1497. $lfdnumbermatchreferee++;
  1498. }
  1499. }
  1500. else
  1501. {
  1502. if ( strlen($valueperson2) > 6 && $valueperson2 )
  1503. {
  1504. // echo $valueperson." <- nicht enthalten<br>";
  1505. $exportpersonstemp[$valueperson2] = $lfdnumberperson;
  1506. // nach- und vorname richtig setzen
  1507. $teile = explode(",",$valueperson2);
  1508. $temp = new stdClass();
  1509. $temp->id = $lfdnumberperson;
  1510. $temp->person_id = $lfdnumberperson;
  1511. $temp->project_position_id = 1002;
  1512. $exportreferee[] = $temp;
  1513. $temp = new stdClass();
  1514. $temp->id = $lfdnumberperson;
  1515. $temp->lastname = trim($teile[0]);
  1516. $temp->firstname = trim($teile[1]);
  1517. $temp->nickname = '';
  1518. $temp->knvbnr = '';
  1519. $temp->location = '';
  1520. $temp->birthday = '0000-00-00';
  1521. $temp->country = $country;
  1522. $temp->position_id = 1002;
  1523. $temp->info = 'Schiri';
  1524. $exportpersons[] = $temp;
  1525. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1526. {
  1527. // nichts machen
  1528. }
  1529. else
  1530. {
  1531. $tempmatchreferee = new stdClass();
  1532. $tempmatchreferee->id = $lfdnumbermatchreferee;
  1533. $tempmatchreferee->match_id = $lfdnumbermatch;
  1534. $tempmatchreferee->project_referee_id = $lfdnumberperson;
  1535. $tempmatchreferee->project_position_id = 1002;
  1536. $exportmatchreferee[] = $tempmatchreferee;
  1537. $lfdnumbermatchreferee++;
  1538. }
  1539. $lfdnumberperson++;
  1540. }
  1541. }
  1542. // echo 'paarung -> '.$csv->data[$a]['Heimmannschaft']." <-> ".$csv->data[$a]['Gastmannschaft'].'<br>';
  1543. if ( $csv->data[$a]['Heimmannschaft'] == 'Spielfrei' || $csv->data[$a]['Gastmannschaft'] == 'Spielfrei' )
  1544. {
  1545. // nichts machen
  1546. }
  1547. else
  1548. {
  1549. $round_id = $csv->data[$a]['Spieltag'];
  1550. $tempmatch = new stdClass();
  1551. $tempmatch->id = $lfdnumbermatch;
  1552. $tempmatch->round_id = $round_id;
  1553. $datetime = strtotime($csv->data[$a]['Spieldatum']);
  1554. $tempmatch->match_date = date('Y-m-d', $datetime)." ".$csv->data[$a]['Uhrzeit'];
  1555. if ( $csv->data[$a]['verlegtSpieldatum'] )
  1556. {
  1557. $datetime = strtotime($csv->data[$a]['verlegtSpieldatum']);
  1558. $tempmatch->match_date_verlegt = date('Y-m-d', $datetime)." ".$csv->data[$a]['verlegtUhrzeit'];
  1559. }
  1560. else
  1561. {
  1562. $tempmatch->match_date_verlegt = '';
  1563. }
  1564. // datum im spieltag setzen
  1565. if ( !$exportround[$round_id]->round_date_first && !$exportround[$round_id]->round_date_last )
  1566. {
  1567. $exportround[$round_id]->round_date_first = date('Y-m-d', $datetime);
  1568. $exportround[$round_id]->round_date_last = date('Y-m-d', $datetime);
  1569. }
  1570. if ( $exportround[$round_id]->round_date_first && $exportround[$round_id]->round_date_last )
  1571. {
  1572. $datetime_first = strtotime($exportround[$round_id]->round_date_first);
  1573. $datetime_last = strtotime($exportround[$round_id]->round_date_last);
  1574. // echo 'round_id -> '.$round_id.' datetime -> '.$datetime.' datetime_first -> '.$datetime_first.' datetime_last -> '.$datetime_last.'<br>';
  1575. // echo 'round_id -> '.$round_id.' date -> '.date('Y-m-d', $datetime).' date_first -> '.$exportround[$round_id]->round_date_first.' date_last -> '.$exportround[$round_id]->round_date_last.