本文整理汇总了PHP中Kit::ReturnBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Kit::ReturnBytes方法的具体用法?PHP Kit::ReturnBytes怎么用?PHP Kit::ReturnBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kit
的用法示例。
在下文中一共展示了Kit::ReturnBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddFormForLibraryMedia
protected function AddFormForLibraryMedia()
{
global $session;
$db =& $this->db;
$user =& $this->user;
$this->response = new ResponseManager();
// Check we have room in the library
$libraryLimit = Config::GetSetting('LIBRARY_SIZE_LIMIT_KB');
if ($libraryLimit > 0) {
$fileSize = $this->db->GetSingleValue('SELECT IFNULL(SUM(FileSize), 0) AS SumSize FROM media', 'SumSize', _INT);
if ($fileSize / 1024 > $libraryLimit) {
trigger_error(sprintf(__('Your library is full. Library Limit: %s K'), $libraryLimit), E_USER_ERROR);
}
}
// Check this user doesn't have a quota
if (!UserGroup::isQuotaFullByUser($user->userid)) {
$this->ThrowError(__('You have exceeded your library quota.'));
}
// Would like to get the regions width / height
$layoutid = $this->layoutid;
$regionid = $this->regionid;
// Set the Session / Security information
$sessionId = session_id();
$securityToken = CreateFormToken();
$backgroundImage = Kit::GetParam('backgroundImage', _GET, _BOOL, false);
$session->setSecurityToken($securityToken);
// Set some defaults based on the type of media we are
// TODO: this should be passed in
switch ($this->type) {
case 'video':
case 'localvideo':
case 'genericfile':
case 'font':
$defaultDuration = 0;
break;
case 'image':
$defaultDuration = Config::GetSetting('jpg_length');
break;
case 'flash':
$defaultDuration = Config::GetSetting('swf_length');
break;
case 'powerpoint':
$defaultDuration = Config::GetSetting('ppt_length');
break;
default:
$defaultDuration = 10;
}
// Save button is different depending on if we are on a region or not
if ($regionid != '' && $this->showRegionOptions) {
setSession('content', 'mediatype', $this->type);
$this->response->AddButton(__('Assign to Layout'), 'XiboAssignToLayout(' . $layoutid . ',"' . $regionid . '")');
$this->response->AddButton(__('View Library'), 'XiboSwapDialog("index.php?p=content&q=LibraryAssignForm&layoutid=' . $layoutid . '®ionid=' . $regionid . '")');
$this->response->AddButton(__('Close'), 'XiboSwapDialog("index.php?p=timeline&layoutid=' . $layoutid . '®ionid=' . $regionid . '&q=RegionOptions")');
} elseif ($regionid != '' && !$this->showRegionOptions) {
$this->response->AddButton(__('Close'), 'XiboDialogClose()');
} elseif ($backgroundImage) {
$this->response->AddButton(__('Close'), 'XiboSwapDialog("index.php?p=layout&q=BackgroundForm&modify=true&layoutid=' . $layoutid . '")');
// Background override url is used on the theme to add a button next to each uploaded file (if in background override)
Theme::Set('background_override_url', "index.php?p=layout&q=BackgroundForm&modify=true&layoutid={$layoutid}&backgroundOveride=");
} else {
$this->response->AddButton(__('Close'), 'XiboSwapDialog("index.php?p=content&q=displayForms&sp=add");XiboRefreshAllGrids()');
}
// Setup the theme
Theme::Set('form_upload_id', 'fileupload');
Theme::Set('form_action', 'index.php?p=content&q=JqueryFileUpload&type=' . $this->type);
Theme::Set('form_meta', '<input type="hidden" id="PHPSESSID" value="' . $sessionId . '" /><input type="hidden" id="SecurityToken" value="' . $securityToken . '" /><input type="hidden" name="type" value="' . $this->type . '"><input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" name="regionid" value="' . $regionid . '">');
Theme::Set('form_valid_ext', '/(\\.|\\/)' . implode('|', $this->validExtensions) . '$/i');
Theme::Set('form_max_size', Kit::ReturnBytes($this->maxFileSize));
Theme::Set('valid_extensions', sprintf(__('This form accepts: %s files up to a maximum size of %s'), $this->validExtensionsText, $this->maxFileSize));
Theme::Set('default_duration', $defaultDuration);
$form = Theme::RenderReturn('library_form_media_add');
$this->response->html = $form;
$this->response->dialogTitle = sprintf(__('Add New %s'), __($this->displayType));
$this->response->dialogSize = true;
$this->response->dialogWidth = '450px';
$this->response->dialogHeight = '280px';
$this->response->callBack = 'MediaFormInitUpload';
$this->response->dialogClass = 'modal-big';
return $this->response;
}