本文整理汇总了PHP中SetupBlock::add_shorthand_int_option方法的典型用法代码示例。如果您正苦于以下问题:PHP SetupBlock::add_shorthand_int_option方法的具体用法?PHP SetupBlock::add_shorthand_int_option怎么用?PHP SetupBlock::add_shorthand_int_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SetupBlock
的用法示例。
在下文中一共展示了SetupBlock::add_shorthand_int_option方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSetupBuilding
public function onSetupBuilding(SetupBuildingEvent $event)
{
$tes = array();
$tes["Disabled"] = "none";
if (function_exists("curl_init")) {
$tes["cURL"] = "curl";
}
$tes["fopen"] = "fopen";
$tes["WGet"] = "wget";
$sb = new SetupBlock("Upload");
$sb->position = 10;
// Output the limits from PHP so the user has an idea of what they can set.
$sb->add_int_option("upload_count", "Max uploads: ");
$sb->add_label("<i>PHP Limit = " . ini_get('max_file_uploads') . "</i>");
$sb->add_shorthand_int_option("upload_size", "<br/>Max size per file: ");
$sb->add_label("<i>PHP Limit = " . ini_get('upload_max_filesize') . "</i>");
$sb->add_choice_option("transload_engine", $tes, "<br/>Transload: ");
$sb->add_bool_option("upload_tlsource", "<br/>Use transloaded URL as source if none is provided: ");
$event->panel->add_block($sb);
}
示例2: receive_event
//.........这里部分代码省略.........
$tags = '';
// Tags aren't changed when uploading. Set to null to stop PHP warnings.
if (count($_FILES)) {
foreach ($_FILES as $file) {
$ok = $this->try_upload($file, $tags, $source, $image_id);
break;
// leave the foreach loop.
}
} else {
foreach ($_POST as $name => $value) {
if (substr($name, 0, 3) == "url" && strlen($value) > 0) {
$ok = $this->try_transload($value, $tags, $source, $image_id);
break;
// leave the foreach loop.
}
}
}
$this->theme->display_upload_status($page, $ok);
} else {
if (!empty($_GET['url'])) {
$url = $_GET['url'];
$ok = $this->try_transload($url, $tags, $url, $image_id);
$this->theme->display_upload_status($page, $ok);
} else {
$this->theme->display_replace_page($page, $image_id);
}
}
}
// END of if admin / can_upload
} else {
if ($event->page_matches("upload")) {
if (!$this->can_upload($user)) {
$this->theme->display_permission_denied($page);
} else {
/* Regular Upload Image */
if (count($_FILES) + count($_POST) > 0) {
$tags = Tag::explode($_POST['tags']);
$source = isset($_POST['source']) ? $_POST['source'] : null;
$ok = true;
foreach ($_FILES as $file) {
$ok = $ok & $this->try_upload($file, $tags, $source);
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 3) == "url" && strlen($value) > 0) {
$ok = $ok & $this->try_transload($value, $tags, $source);
}
}
$this->theme->display_upload_status($page, $ok);
} else {
if (!empty($_GET['url'])) {
$url = $_GET['url'];
$tags = array('tagme');
if (!empty($_GET['tags']) && $_GET['tags'] != "null") {
$tags = Tag::explode($_GET['tags']);
}
$ok = $this->try_transload($url, $tags, $url);
$this->theme->display_upload_status($page, $ok);
} else {
if (!$is_full) {
$this->theme->display_page($page);
}
}
}
}
// END of if can_upload
}
}
}
// END of if PageRequestEvent
if ($event instanceof SetupBuildingEvent) {
$tes = array();
$tes["Disabled"] = "none";
if (function_exists("curl_init")) {
$tes["cURL"] = "curl";
}
$tes["fopen"] = "fopen";
$tes["WGet"] = "wget";
$sb = new SetupBlock("Upload");
$sb->position = 10;
// Output the limits from PHP so the user has an idea of what they can set.
$sb->add_label("<i>PHP's Upload Limit = " . ini_get('max_file_uploads') . "</i><br/>");
$sb->add_int_option("upload_count", "Max uploads: ");
$sb->add_label("<br/><i>PHP's Max Size Upload = " . ini_get('upload_max_filesize') . "</i><br/>");
$sb->add_shorthand_int_option("upload_size", "<br/>Max size per file: ");
$sb->add_bool_option("upload_anon", "<br/>Allow anonymous uploads: ");
$sb->add_bool_option("upload_replace", "<br/>Allow replacing images: ");
$sb->add_choice_option("transload_engine", $tes, "<br/>Transload: ");
$event->panel->add_block($sb);
}
if ($event instanceof DataUploadEvent) {
if ($is_full) {
throw new UploadException("Upload failed; disk nearly full");
}
if (filesize($event->tmpname) > $config->get_int('upload_size')) {
$size = to_shorthand_int(filesize($event->tmpname));
$limit = to_shorthand_int($config->get_int('upload_size'));
throw new UploadException("File too large ({$size} > {$limit})");
}
}
}
示例3: onSetupBuilding
public function onSetupBuilding(SetupBuildingEvent $event)
{
global $config;
$sb = new SetupBlock("Image Options");
$sb->position = 30;
// advanced only
//$sb->add_text_option("image_ilink", "Image link: ");
//$sb->add_text_option("image_tlink", "<br>Thumbnail link: ");
$sb->add_text_option("image_tip", "Image tooltip: ");
$sb->add_choice_option("upload_collision_handler", array('Error' => 'error', 'Merge' => 'merge'), "<br>Upload collision handler: ");
if (function_exists("exif_read_data")) {
$sb->add_bool_option("image_show_meta", "<br>Show metadata: ");
}
$event->panel->add_block($sb);
$thumbers = array();
$thumbers['Built-in GD'] = "gd";
$thumbers['ImageMagick'] = "convert";
$sb = new SetupBlock("Thumbnailing");
$sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
$sb->add_label("<br>Size ");
$sb->add_int_option("thumb_width");
$sb->add_label(" x ");
$sb->add_int_option("thumb_height");
$sb->add_label(" px at ");
$sb->add_int_option("thumb_quality");
$sb->add_label(" % quality ");
if ($config->get_string("thumb_engine") == "convert") {
$sb->add_label("<br>ImageMagick Binary: ");
$sb->add_text_option("thumb_convert_path");
}
if ($config->get_string("thumb_engine") == "gd") {
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
}
$event->panel->add_block($sb);
}
示例4: receive_event
public function receive_event(Event $event)
{
global $config, $database, $page, $user;
if (is_null($this->theme)) {
$this->theme = get_theme_object($this);
}
$is_full = disk_free_space(realpath("./images/")) < 100 * 1024 * 1024;
if ($event instanceof InitExtEvent) {
global $config;
$config->set_default_int('upload_count', 3);
$config->set_default_int('upload_size', '1MB');
$config->set_default_bool('upload_anon', false);
}
if ($event instanceof PostListBuildingEvent) {
global $user;
if ($this->can_upload($user)) {
if ($is_full) {
$this->theme->display_full($page);
} else {
$this->theme->display_block($page);
}
}
}
if ($event instanceof PageRequestEvent && $event->page_matches("upload")) {
if (count($_FILES) + count($_POST) > 0) {
$tags = Tag::explode($_POST['tags']);
$source = isset($_POST['source']) ? $_POST['source'] : null;
if ($this->can_upload($user)) {
$ok = true;
foreach ($_FILES as $file) {
$ok = $ok & $this->try_upload($file, $tags, $source);
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 3) == "url" && strlen($value) > 0) {
$ok = $ok & $this->try_transload($value, $tags, $source);
}
}
$this->theme->display_upload_status($page, $ok);
} else {
$this->theme->display_permission_denied($page);
}
} else {
if (!empty($_GET['url'])) {
global $user;
if ($this->can_upload($user)) {
$url = $_GET['url'];
$tags = array('tagme');
if (!empty($_GET['tags']) && $_GET['tags'] != "null") {
$tags = Tag::explode($_GET['tags']);
}
$ok = $this->try_transload($url, $tags, $url);
$this->theme->display_upload_status($page, $ok);
} else {
$this->theme->display_permission_denied($page);
}
} else {
if (!$is_full) {
$this->theme->display_page($page);
}
}
}
}
if ($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Upload");
$sb->position = 10;
$sb->add_int_option("upload_count", "Max uploads: ");
$sb->add_shorthand_int_option("upload_size", "<br>Max size per file: ");
$sb->add_bool_option("upload_anon", "<br>Allow anonymous uploads: ");
$sb->add_choice_option("transload_engine", array("Disabled" => "none", "cURL" => "curl", "fopen" => "fopen", "WGet" => "wget"), "<br>Transload: ");
$event->panel->add_block($sb);
}
if ($event instanceof DataUploadEvent) {
global $config;
if ($is_full) {
throw new UploadException("Upload failed; disk nearly full");
}
if (filesize($event->tmpname) > $config->get_int('upload_size')) {
$size = to_shorthand_int(filesize($event->tmpname));
$limit = to_shorthand_int($config->get_int('upload_size'));
throw new UploadException("File too large ({$size} > {$limit})");
}
}
}
示例5: onSetupBuilding
public function onSetupBuilding($event)
{
$sb = new SetupBlock("Image Options");
$sb->position = 30;
// advanced only
//$sb->add_text_option("image_ilink", "Image link: ");
//$sb->add_text_option("image_tlink", "<br>Thumbnail link: ");
$sb->add_text_option("image_tip", "Image tooltip: ");
$sb->add_choice_option("upload_collision_handler", array('Error' => 'error', 'Merge' => 'merge'), "<br>Upload collision handler: ");
if (!in_array("OS", $_SERVER) || $_SERVER["OS"] != 'Windows_NT') {
$sb->add_bool_option("image_show_meta", "<br>Show metadata: ");
}
$event->panel->add_block($sb);
$thumbers = array();
$thumbers['Built-in GD'] = "gd";
$thumbers['ImageMagick'] = "convert";
$sb = new SetupBlock("Thumbnailing");
$sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
$sb->add_label("<br>Size ");
$sb->add_int_option("thumb_width");
$sb->add_label(" x ");
$sb->add_int_option("thumb_height");
$sb->add_label(" px at ");
$sb->add_int_option("thumb_quality");
$sb->add_label(" % quality ");
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
$event->panel->add_block($sb);
}
示例6: onSetupBuilding
public function onSetupBuilding($event)
{
$sb = new SetupBlock("Image Options");
$sb->position = 30;
// advanced only
//$sb->add_text_option("image_ilink", "Image link: ");
//$sb->add_text_option("image_tlink", "<br>Thumbnail link: ");
$sb->add_text_option("image_tip", "Image tooltip: ");
$sb->add_choice_option("upload_collision_handler", array('Error' => 'error', 'Merge' => 'merge'), "<br>Upload collision handler: ");
if (!in_array("OS", $_SERVER) || $_SERVER["OS"] != 'Windows_NT') {
$sb->add_bool_option("image_show_meta", "<br>Show metadata: ");
}
$sb->add_bool_option("image_jquery_confirm", "<br>Confirm Delete with jQuery: ");
$expires = array();
$expires['1 Minute'] = 60;
$expires['1 Hour'] = 3600;
$expires['1 Day'] = 86400;
$expires['1 Month (31 days)'] = 2678400;
//(60*60*24*31)
$expires['1 Year'] = 31536000;
// 365 days (60*60*24*365)
$expires['Never'] = 3153600000.0;
// 100 years..
$sb->add_choice_option("image_expires", $expires, "<br>Image Expiration: ");
$event->panel->add_block($sb);
$thumbers = array();
$thumbers['Built-in GD'] = "gd";
$thumbers['ImageMagick'] = "convert";
$sb = new SetupBlock("Thumbnailing");
$sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
$sb->add_label("<br>Size ");
$sb->add_int_option("thumb_width");
$sb->add_label(" x ");
$sb->add_int_option("thumb_height");
$sb->add_label(" px at ");
$sb->add_int_option("thumb_quality");
$sb->add_label(" % quality ");
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
$event->panel->add_block($sb);
}