Skip to content

Commit

Permalink
joomla 4
Browse files Browse the repository at this point in the history
  • Loading branch information
diddipoeler committed Mar 19, 2023
1 parent 1c7c155 commit c82d82d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
16 changes: 16 additions & 0 deletions admin/controllers/players.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@
class sportsmanagementControllerplayers extends JSMControllerAdmin
{


/**
* sportsmanagementControllerplayers::importupload()
*
* @return void
*/
function importupload()
{
$model = $this->getModel();
$post = Factory::getApplication()->input->post->getArray(array());
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$model = $this->getModel();
$msg = $model->importupload($post);

}

/**
* sportsmanagementControllerplayers::assign()
*
Expand Down
38 changes: 38 additions & 0 deletions admin/models/players.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,44 @@ public function __construct($config = array())
parent::setDbo($this->jsmdb);
}



/**
* sportsmanagementModelplayers::importupload()
* https://www.w3schools.com/php/php_file_upload.asp
* @param mixed $post
* @return void
*/
function importupload($post = array())
{
Factory::getApplication()->enqueueMessage(Text::_(__METHOD__.' '.__LINE__.' task <pre>'.print_r(Factory::getApplication()->input->post->getArray(),true).'</pre>' ), '');
$target_dir = "tmp/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
Factory::getApplication()->enqueueMessage(Text::_(__METHOD__.' '.__LINE__.' task <pre>'.print_r($target_file,true).'</pre>' ), '');


// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}




}




/**
* sportsmanagementModelplayers::getListQuery()
*
Expand Down
15 changes: 12 additions & 3 deletions admin/views/players/tmpl/players_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;

?>
<fieldset class="adminform">
Expand All @@ -20,20 +21,28 @@
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files</span>
<input type="file" name="files[]" multiple>
<input type="file" name="fileToUpload" id="fileToUpload">
</span>
<button type="button" class="btn btn-primary start" data-ng-click="submit()">

<button type="button" class="btn btn-primary start" onclick="this.form.submit();">
<i class="glyphicon glyphicon-upload"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">

<button type="reset" class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel upload</span>
</button>

<button type="button" class="btn btn-danger delete">
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>

</div>

<input type="hidden" name="task" value="players.importupload"/>
<?php echo HTMLHelper::_('form.token') . "\n"; ?>

</form>
</fieldset>
2 changes: 2 additions & 0 deletions admin/views/players/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function init()
$this->persontype = 0;
$this->whichview = $this->jinput->get('whichview');

// Factory::getApplication()->enqueueMessage(Text::_(__METHOD__.' '.__LINE__.' task <pre>'.print_r(Factory::getApplication()->input->post->getArray(),true).'</pre>' ), '');

switch ($this->getLayout())
{
case 'assignpersons':
Expand Down

0 comments on commit c82d82d

Please sign in to comment.