Skip to content

Commit

Permalink
Adding backend actions
Browse files Browse the repository at this point in the history
  • Loading branch information
alve89 committed Sep 16, 2021
1 parent 96df626 commit 16caed4
Show file tree
Hide file tree
Showing 19 changed files with 771 additions and 168 deletions.
26 changes: 26 additions & 0 deletions admin/controllers/tvofileupload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

/**
* HelloWorld Controller
*
* @package Joomla.Administrator
* @subpackage com_helloworld
* @since 0.0.9
*/
// class TvoControllerTvoFileUpload extends JControllerAdmin {
// public function getModel($name = 'TvoFileUpload', $prefix = 'TvoModel', $config = array('ignore_request' => true))
// {
// $model = parent::getModel($name, $prefix, $config);
//
// return $model;
// }
// }
113 changes: 113 additions & 0 deletions admin/controllers/tvosingleteam.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
require_once('./components'. '/' . JFactory::getApplication()->input->get('option') . '/' . 'helper.php');

/**
* HelloWorld Controller
*
* @package Joomla.Administrator
* @subpackage com_helloworld
* @since 0.0.9
*/
class TvoControllerTvoSingleTeam extends JControllerForm {

public function apply() {
JSession::checkToken() or die('Invalid token');

die('apply');

}

public function cancel() {
$this->setRedirect(JRoute::_('index.php?option=com_tvo', false));
}

public function remove() {
JSession::checkToken() or die('Invalid token');
echo 'ichLöscheInhalte';
$jinput = JFactory::getApplication()->input;
$jform = $jinput->get('jform', array(), 'ARRAY');

echo '<pre>';
var_dump($jform);
echo '</pre>';

// $application = JFactory::getApplication();
// $application->enqueueMessage(JText::_('Datensatz wurde gelöscht'), 'message');
// $this->setRedirect(JRoute::_('index.php?option=com_tvo', false));
}

public function validate($formField, $regex) {
return preg_match($regex, $formField);
}

public function save() {
JSession::checkToken() or die('Invalid token');

$application = JFactory::getApplication();
$jinput = JFactory::getApplication()->input;
$jform = $jinput->get('jform', array(), 'ARRAY');

// Lade nur die Formularfelder aus dem Request
//$jform = JFactory::getApplication()->input->get('jform', array(), 'ARRAY');

$validationCheck = true;

// Validiere alle Formularfelder
foreach($jform as $fieldName => $fieldValue) {

switch($fieldName) {
case 'id':
case 'teamGamesId':
case 'teamTableId':
$regex = "/^[0-9]+$/";
break;
case 'teamName':
case 'title':
$regex = "/^[a-zA-Z0-9][a-zA-Z0-9 -]+[a-zA-Z0-9]$/";
break;
default:
$regex = "/^[0-9]+$/";
}



if( $this->validate($fieldValue, $regex) === 1 ) {
// Validation was successful => store new value
$validationCheck = ($validationCheck) ? true : false; // Keep the state if it is already false (=> at least one validation was faulty!)
// Hier
// Speichern
// Durchführen

}
else {
$validationCheck = false;
$faultyFieldName = $fieldName;
break;
}
}

if($validationCheck) {
$application->enqueueMessage(JText::_('Datensatz wurde NOCH NICHT gespeichert'), 'warning');
if($jinput->get('task') == 'apply') {
$this->setRedirect(JRoute::_('index.php?option='.$jinput->get('option').'&view=tvosingleteam&layout='.$jinput->get('layout').'&id='.$jinput->get('id'), false));
}
else {
$this->setRedirect(JRoute::_('index.php?option=com_tvo', false));
}
}
else {
$application->enqueueMessage(JText::_('Datensatz wurde nicht gespeichert werden, weil zumindest das Feld <code>' . $faultyFieldName .'</code> ungültige Inhalte enthielt.'), 'error');
$this->setRedirect(JRoute::_('index.php?option='.$jinput->get('option').'&view=tvosingleteam&layout='.$jinput->get('layout').'&id='.$jinput->get('id'), false));
}

}
}
36 changes: 36 additions & 0 deletions admin/controllers/tvoteamslist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_helloworld
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

/**
* HelloWorlds Controller
*
* @since 0.0.1
*/
class TvoControllerTvoTeamsList extends JControllerAdmin
{
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'TvoTeamsList', $prefix = 'TvoModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);

return $model;
}
}
179 changes: 179 additions & 0 deletions admin/helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?php

class ComTvoHelper {


public static function getPathToDataFile()
{
return __DIR__ . '/data.json';
}

public static function getSeasonDataFromFile($file)
{
return json_decode(file_get_contents($file));
}


public static function getSeasonDataForTeam($id)
{
$teams = self::getSeasonDataFromFile(self::getPathToDataFile());
foreach($teams as $team)
{
if($team->lvIDPathStr == $id)
{
return $team;
}
}
}




/**
* Retrieves the hello message
*
* @param array $params An object containing the module parameters
*
* @access public
*/
public static function getCurrentIDs($id)
{
// create curl ressource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, self::getCurrentUrl()."?cmd=data&lvTypeNext=club&lvIDNext=" . $id);

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
// Return the result
return $output;
}

public static function getCurrentGames($id)
{
// TVO: 986
// HSG: 1005

// create curl ressource
$ch = curl_init();

// set url
// club (!) id = 986
curl_setopt($ch, CURLOPT_URL, self::getCurrentUrl()."?cmd=data&lvTypeNext=club&lvIDNext=" . $id);

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
// Return the result
return json_decode($output)[0];
}


public static function getLatestScorings($id)
{
// create curl ressource
$ch = curl_init();

// set url
// club (!) id = 986
curl_setopt($ch, CURLOPT_URL, self::getCurrentUrl()."?cmd=data&lvTypeNext=team&lvIDNext=" . $id);

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_ENCODING, 'gzip');

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
// Return the result
return json_decode($output)[0];
}

public static function getCurrentUrl()
{
// create curl ressource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "http://www.handball4all.de/api/url/spo_vereine-01.php");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
// Return the result
return $output;
}


public static function cmp($a, $b)
{
return strcmp($a->gDateTS, $b->gDateTS);
}

public static function getTimestamp($game)
{

$dateAsArr = explode(".", $game->gDate);
$dateAsArr[2] = 2000 + $dateAsArr[2];
$timeAsArr = explode(":", $game->gTime);

$game->gDateTS = mktime($timeAsArr[0], $timeAsArr[1], 0, $dateAsArr[1], $dateAsArr[0], $dateAsArr[2]);

return $game;
}


/*
*
* Create current score
*
*/
public static function score($homegoals, $guestgoals, $homegoals1, $guestgoals1)
{
if((empty($homegoals) || empty($guestgoals)) || $homegoals == " " || $guestgoals == " ") // || (empty($homegoals) && empty($guestgoals))
{
$return = "n. v.";
}
else
{
$return = $homegoals . ' : ' . $guestgoals;
if((empty($homegoals1) || empty($guestgoals1)) || $homegoals1 == " " || $guestgoals1 == " ")
{
$return .= " (n. v.)";
}
else
{
$return .= ' (' . $homegoals1 . ' : ' . $guestgoals1 . ')';
}
}
return $return;
}

public static function varDump($var)
{
echo '<pre>';
var_dump($var);
echo '</pre>';
return;
}
}
1 change: 1 addition & 0 deletions admin/models/fields/tvoteam.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected function getOptions()

$options = array_merge(parent::getOptions(), $options);


return $options;
}
}
Loading

0 comments on commit 16caed4

Please sign in to comment.