Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show configured upload limit when uploading installer package. (Dependency #11026) #11255

Merged
merged 4 commits into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
<?php echo JText::_('COM_JOOMLAUPDATE_VIEW_UPLOAD_PACKAGE_FILE'); ?>
</td>
<td>
<input class="input_box" id="install_package" name="install_package" type="file" size="57" />
<input class="input_box" id="install_package" name="install_package" type="file" size="57" /><br>
<?php $maxSize = JHtml::_('number.bytes', JUtility::getMaxUploadSize()); ?>
<?php echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?>
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@
</div>
<div class="controls">
<input required type="file" id="upload-file" name="Filedata[]" multiple /><button class="btn btn-primary" id="upload-submit"><span class="icon-upload icon-white"></span> <?php echo JText::_('COM_MEDIA_START_UPLOAD'); ?></button>
<p class="help-block"><?php echo $this->config->get('upload_maxsize') == '0' ? JText::_('COM_MEDIA_UPLOAD_FILES_NOLIMIT') : JText::sprintf('COM_MEDIA_UPLOAD_FILES', $this->config->get('upload_maxsize')); ?></p>
<p class="help-block"><?php
$cMax = (int) $this->config->get('upload_maxsize');
$maxSize = JUtility::getMaxUploadSize($cMax . 'MB');

echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', JHtml::_('number.bytes', $maxSize));
?></p>
</div>
</div>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@
<fieldset id="upload-noflash" class="actions">
<label for="upload-file" class="control-label"><?php echo JText::_('COM_MEDIA_UPLOAD_FILE'); ?></label>
<input required type="file" id="upload-file" name="Filedata[]" multiple /> <button class="btn btn-primary" id="upload-submit"><span class="icon-upload icon-white"></span> <?php echo JText::_('COM_MEDIA_START_UPLOAD'); ?></button>
<p class="help-block"><?php echo $this->config->get('upload_maxsize') == '0' ? JText::_('COM_MEDIA_UPLOAD_FILES_NOLIMIT') : JText::sprintf('COM_MEDIA_UPLOAD_FILES', $this->config->get('upload_maxsize')); ?></p>
<p class="help-block"><?php
$cMax = (int) $this->config->get('upload_maxsize');
$maxSize = JUtility::getMaxUploadSize($cMax . 'MB');

echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', JHtml::_('number.bytes', $maxSize));
?></p>
</fieldset>
<input class="update-folder" type="hidden" name="folder" id="folder" value="<?php echo $this->state->folder; ?>" />
<?php JFactory::getSession()->set('com_media.return_url', 'index.php?option=com_media'); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
<input type="hidden" class="address" name="address" />
<input type="file" name="files" required />
<?php echo JHtml::_('form.token'); ?>
<input type="submit" value="<?php echo JText::_('COM_TEMPLATES_BUTTON_UPLOAD');?>" class="btn btn-primary" />
<input type="submit" value="<?php echo JText::_('COM_TEMPLATES_BUTTON_UPLOAD');?>" class="btn btn-primary" /><br>
<?php $maxSize = JHtml::_('number.bytes', JUtility::getMaxUploadSize()); ?>
<?php echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?>
</fieldset>
</form>
<?php if ($this->type != 'home'): ?>
Expand Down
2 changes: 0 additions & 2 deletions administrator/language/en-GB/en-GB.com_media.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ COM_MEDIA_START_UPLOAD="Start Upload"
COM_MEDIA_THUMBNAIL_VIEW="Thumbnail View"
COM_MEDIA_TITLE="Image Title"
COM_MEDIA_UPLOAD_COMPLETE="Upload Complete: %s"
COM_MEDIA_UPLOAD_FILES_NOLIMIT="Upload files (No maximum size)"
COM_MEDIA_UPLOAD_FILES="Upload files (Maximum Size: %s MB)"
COM_MEDIA_UPLOAD_FILE="Upload file"
COM_MEDIA_UPLOAD_SUCCESSFUL="Upload Successful"
COM_MEDIA_UPLOAD="Upload"
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ JGLOBAL_LOOKING_FOR="Looking for"
JGLOBAL_LT="&lt;"
JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC="The number of subcategory levels to display."
JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL="Subcategory Levels"
JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT="Maximum upload size: <strong>%s</strong>"
JGLOBAL_MAXLEVEL_DESC="Maximum number of levels of subcategories to show."
JGLOBAL_MAXLEVEL_LABEL="Subcategory Levels"
JGLOBAL_MENU_SELECTION="Menu Selection:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ function clearCoords()
<fieldset>
<input type="hidden" class="address" name="address" />
<input type="file" name="files" required />
<input type="submit" value="<?php echo JText::_('COM_TEMPLATES_BUTTON_UPLOAD');?>" class="btn btn-primary" />
<input type="submit" value="<?php echo JText::_('COM_TEMPLATES_BUTTON_UPLOAD');?>" class="btn btn-primary" /><br>
<?php $maxSize = JHtml::_('number.bytes', JUtility::getMaxUploadSize()); ?>
<?php echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?>
</fieldset>
</form>
<br />
Expand Down
2 changes: 0 additions & 2 deletions language/en-GB/en-GB.com_media.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,4 @@ COM_MEDIA_UP="Up"
COM_MEDIA_UPLOAD="Upload"
COM_MEDIA_UPLOAD_COMPLETE="Upload Complete"
COM_MEDIA_UPLOAD_FILE="Upload file"
COM_MEDIA_UPLOAD_FILES="Upload files (Maximum Size: %s MB)"
COM_MEDIA_UPLOAD_FILES_NOLIMIT="Upload files (No maximum size)"
COM_MEDIA_UPLOAD_SUCCESSFUL="Upload Successful"
1 change: 1 addition & 0 deletions language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ JGLOBAL_KEEP_TYPING="Keep typing ..."
JGLOBAL_LEFT="Left"
JGLOBAL_LOOKING_FOR="Looking for"
JGLOBAL_LT="&lt;"
JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT="Maximum upload size: <strong>%s</strong>"
JGLOBAL_NEWITEMSLAST_DESC="New items default to the last position. Ordering can be changed after this item has been saved."
JGLOBAL_NO_MATCHING_RESULTS="No Matching Results"
JGLOBAL_NUM="#"
Expand Down
5 changes: 4 additions & 1 deletion layouts/joomla/form/field/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@
<?php echo $disabled ? ' disabled' : ''; ?>
<?php echo $autofocus ? ' autofocus' : ''; ?>
<?php echo !empty($onchange) ? ' onchange="' . $onchange . '"' : ''; ?>
<?php echo $required ? ' required aria-required="true"' : ''; ?> />
<?php echo $required ? ' required aria-required="true"' : ''; ?> /><br>
<?php
$maxSize = JHtml::_('number.bytes', JUtility::getMaxUploadSize());
echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize);
33 changes: 33 additions & 0 deletions libraries/joomla/utilities/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,37 @@ public static function parseAttributes($string)

return $retarray;
}

/**
* Method to get the maximum allowed file size for the HTTP uploads based on the active PHP configuration
*
* @param mixed $custom A custom upper limit, if the PHP settings are all above this then this will be used
*
* @return int Size in number of bytes
*
* @since __DEPLOY_VERSION__
*/
public static function getMaxUploadSize($custom = null)
{
if ($custom)
{
$custom = JHtml::_('number.bytes', $custom, '');

if ($custom > 0)
{
$sizes[] = $custom;
}
}

/*
* Read INI settings which affects upload size limits
* and Convert each into number of bytes so that we can compare
*/
$sizes[] = JHtml::_('number.bytes', ini_get('memory_limit'), '');
$sizes[] = JHtml::_('number.bytes', ini_get('post_max_size'), '');
$sizes[] = JHtml::_('number.bytes', ini_get('upload_max_filesize'), '');

// The minimum of these is the limiting factor
return min($sizes);
}
}
4 changes: 3 additions & 1 deletion plugins/installer/packageinstaller/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
<div class="control-group">
<label for="install_package" class="control-label"><?php echo JText::_('PLG_INSTALLER_PACKAGEINSTALLER_EXTENSION_PACKAGE_FILE'); ?></label>
<div class="controls">
<input class="input_box" id="install_package" name="install_package" type="file" size="57" />
<input class="input_box" id="install_package" name="install_package" type="file" size="57" /><br>
<?php $maxSize = JHtml::_('number.bytes', JUtility::getMaxUploadSize()); ?>
<?php echo JText::sprintf('JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT', $maxSize); ?>
</div>
</div>
<div class="form-actions">
Expand Down