本文整理汇总了PHP中FD::math方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::math方法的具体用法?PHP FD::math怎么用?PHP FD::math使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::math方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: section
public function section()
{
$ajax = FD::ajax();
// TODO: Exact section copy. Refactor.
$location = JRequest::getCmd('location');
$name = JRequest::getCmd('name');
$override = JRequest::getBool('override', false);
$section = JRequest::getVar('section');
// Get stylesheet
$stylesheet = FD::stylesheet($location, $name, $override);
$theme = FD::themes();
$theme->set('location', $location);
$theme->set('name', $name);
// TODO: Find a proper way to do this
$theme->set('element', ucwords(str_ireplace('_', ' ', str_ireplace('mod_easysocial_', '', $name))));
$theme->set('override', $override);
$theme->set('section', $section);
$theme->set('stylesheet', $stylesheet);
// Also pass in server memory limit.
$memory_limit = ini_get('memory_limit');
$memory_limit = FD::math()->convertBytes($memory_limit) / 1024 / 1024;
$theme->set('memory_limit', $memory_limit);
$html = $theme->output('admin/themes/compiler/section');
/* Exact section copy */
$ajax->resolve($html);
$ajax->send();
}
示例2: getFile
public function getFile($name = null)
{
// Check if post_max_size is exceeded.
if (empty($_FILES) && empty($_POST)) {
return FD::exception('COM_EASYSOCIAL_EXCEPTION_UPLOAD_POST_SIZE');
}
// Get the file
if (empty($name)) {
$name = $this->name;
}
$file = JRequest::getVar($name, '', 'FILES');
// Check for invalid file object
if (empty($file)) {
return FD::exception('COM_EASYSOCIAL_EXCEPTION_UPLOAD_NO_OBJECT');
}
// If there's an error in this file
if ($file['error']) {
return FD::exception($file, SOCIAL_EXCEPTION_UPLOAD);
}
// Check if file exceeds max upload filesize
$maxsize = FD::math()->convertBytes($this->maxsize);
if ($maxsize > 0 && $file['size'] > $maxsize) {
return FD::exception(JText::sprintf('COM_EASYSOCIAL_EXCEPTION_UPLOAD_MAX_SIZE', FD::math()->convertUnits($maxsize, 'B', 'MB', false, true)));
}
// Return file
return $file;
}
示例3: upload
public function upload()
{
$ajax = FD::ajax();
$tmp = JRequest::getVar($this->inputName, '', 'FILES');
$key = JRequest::getInt('key', 0);
// Reconstruct the file array
$file = array();
foreach ($tmp as $k => $v) {
$file[$k] = $v[$key];
}
// Check for file validity
if (empty($file['tmp_name'])) {
$ajax->reject($this->getErrorHtml(JText::_('PLG_FIELDS_FILE_VALIDATION_INVALID_FILE')));
return false;
}
$maths = FD::math();
$limit = $this->params->get('size_limit', 2);
$limit = $maths->convertUnits($limit, 'MB', 'B');
$size = filesize($file['tmp_name']);
if ($size > $limit) {
$ajax->reject($this->getErrorHtml(JText::_('PLG_FIELDS_FILE_VALIDATION_FILE_SIZE_EXCEEDED')));
return false;
}
$allowed = $this->params->get('allowed');
$allowed = FD::makeArray($allowed, ',');
$info = pathinfo($file['name']);
if (!isset($info['extension']) || !empty($allowed) && !in_array($info['extension'], $allowed)) {
$ajax->reject($this->getErrorHtml(JText::_('PLG_FIELDS_FILE_VALIDATION_FILE_EXTENSION_NOT_ALLOWED')));
return false;
}
$base = SOCIAL_TMP;
if (!JFolder::exists($base) && !JFolder::create($base)) {
$ajax->reject($this->getErrorHtml(JText::_('PLG_FIELDS_FILE_ERROR_UNABLE_TO_CREATE_TEMPORARY_LOCATION')));
return false;
}
$session = JFactory::getSession()->getId();
$hash = md5($session . $this->inputName . $file['name']);
// Import necessary library
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$state = JFile::copy($file['tmp_name'], $base . '/' . $hash);
if (!$state) {
$ajax->reject($this->getErrorHtml(JText::_('PLG_FIELDS_FILE_ERROR_UNABLE_TO_MOVE_FILE')));
return false;
}
// Store this data into temporary table
$tmp = FD::table('tmp');
$tmp->uid = $this->field->id;
$tmp->type = SOCIAL_APPS_TYPE_FIELDS;
$tmp->key = $this->inputName;
$tmp->value = array('name' => $file['name'], 'mime' => $file['type'], 'size' => $file['size'], 'hash' => $hash, 'path' => $base);
$state = $tmp->store();
if (!$state) {
$ajax->reject($this->getErrorHtml(JText::_('PLG_FIELDS_FILE_ERROR_UNABLE_TO_STORE_FILE_DATA')));
return false;
}
$data = new stdClass();
$data->name = $file['name'];
$data->id = $tmp->id;
$theme = FD::themes();
$theme->set('file', $data);
$theme->set('tmp', true);
$theme->set('key', $key);
$theme->set('inputName', $this->inputName);
$theme->set('field', $this->field);
$theme->set('params', $this->params);
$html = $theme->output('fields/user/file/control');
$ajax->resolve($html);
return true;
}
示例4: round
echo $file->state;
?>
</span></td>
<td width="100%">
<a href="<?php
echo $file->uri;
?>
" target="_blank"><?php
echo $file->name;
?>
</a>
<?php
if (!is_null($file->size)) {
?>
• <strong><?php
echo round(FD::math()->convertUnits($file->size, 'B', 'KB'), 2);
?>
kb</strong>
<?php
if ($file->rules > 0) {
?>
• <strong <?php
echo $file->rules >= 4096 ? 'style="color: red;"' : '';
?>
><?php
echo JText::sprintf('COM_EASYSOCIAL_THEMES_COMPILER_CSS_RULECOUNT', $file->rules);
?>
</strong>
<?php
}
?>
示例5: compiler
public function compiler()
{
$this->setHeading('COM_EASYSOCIAL_TOOLBAR_TITLE_THEMES_COMPILER');
$this->setDescription('COM_EASYSOCIAL_DESCRIPTION_THEMES_CUSTOMIZE');
// Master set of stylesheets
$stylesheets = array();
// Site themes
$model = FD::model('Themes');
$site_themes = $model->getThemes();
$stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_SITE'), 'location' => 'site', 'override' => false, 'themes' => $site_themes);
// Site overrides
$elements = FD::stylesheet('site')->overrides();
$site_overrides = array();
// Emulate results from $model->getThemes();
// TODO: Find a proper way to do this.
foreach ($elements as $element) {
$site_overrides[] = (object) array('name' => ucwords($element), 'element' => $element);
}
$stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_SITE_OVERRIDE'), 'location' => 'site', 'override' => true, 'themes' => $site_overrides);
$super = FD::config()->get('general.super');
if ($super) {
// Admin themes
// TODO: Model to retrieve admin themes
$stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_ADMIN'), 'location' => 'admin', 'override' => false, 'themes' => array((object) array('name' => 'Default', 'element' => 'default')));
// Admin overrides
// TODO: This is strangely retrieving site overrides.
$elements = FD::stylesheet('admin')->overrides();
$admin_overrides = array();
// Emulate results from $model->getThemes();
// TODO: Find a proper way to do this.
foreach ($elements as $element) {
$admin_overrides[] = (object) array('name' => ucwords($element), 'element' => $element);
}
$stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_ADMIN_OVERRIDE'), 'location' => 'admin', 'override' => false, 'themes' => $admin_overrides);
}
// Modules
$elements = FD::stylesheet('module')->modules();
$modules = array();
// Emulate results from $model->getThemes();
// TODO: Find a proper way to do this.
foreach ($elements as $element) {
$modules[] = (object) array('name' => ucwords(str_ireplace('_', ' ', str_ireplace('mod_easysocial_', '', $element))), 'element' => $element);
}
$stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_MODULE'), 'location' => 'module', 'override' => false, 'themes' => $modules);
// Get url params
// Defaults to site/wireframe.
$location = JRequest::getCmd('location', 'site');
$name = JRequest::getCmd('name', 'wireframe');
$override = JRequest::getBool('override', false);
// Get active stylesheet
$stylesheet = FD::stylesheet($location, $name, $override);
$uuid = uniqid();
// For admin/themes/compiler
$this->set('stylesheets', $stylesheets);
// For admin/themes/compiler/form
$this->set('uuid', $uuid);
$this->set('location', $location);
$this->set('name', $name);
// TODO: Find a proper way to do this
$this->set('element', ucwords(str_ireplace('_', ' ', str_ireplace('mod_easysocial_', '', $name))));
$this->set('override', $override);
$this->set('stylesheet', $stylesheet);
$this->set('type', $stylesheet->type());
$this->set('manifest', $stylesheet->manifest());
// Also pass in server memory limit.
$memory_limit = ini_get('memory_limit');
$memory_limit = FD::math()->convertBytes($memory_limit) / 1024 / 1024;
$this->set('memory_limit', $memory_limit);
parent::display('admin/themes/compiler');
}
示例6: getSize
/**
* Retrieves the size of the attachment item.
* @todo We could add some options here to use certain units.
*
* @param null
* @return string The attachment size
*/
public function getSize()
{
return FD::math()->convertUnits($this->size);
}
示例7: round
</td>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr class="info">
<td colspan="2">
<span class="pull-left"><i class="ies-clock"></i> <b><?php
echo JText::_('COM_EASYSOCIAL_THEMES_COMPILER_TOTAL_TIME');
?>
:</b> <span data-time-total><?php
echo round($log['time_total'], 2);
?>
s</span></span>
<span class="pull-right"><i class="ies-bars"></i> <b><?php
echo JText::_('COM_EASYSOCIAL_THEMES_COMPILER_MEMORY_PEAK_USAGE');
?>
:</b> <span data-memory-usage><?php
echo round(FD::math()->convertUnits($log['mem_peak'], 'B', 'MB'), 2);
?>
mb</span></span>
</td>
</tr>
</tfoot>
</table>