本文整理汇总了PHP中SetupBlock::add_choice_option方法的典型用法代码示例。如果您正苦于以下问题:PHP SetupBlock::add_choice_option方法的具体用法?PHP SetupBlock::add_choice_option怎么用?PHP SetupBlock::add_choice_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SetupBlock
的用法示例。
在下文中一共展示了SetupBlock::add_choice_option方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSetupBuilding
public function onSetupBuilding(SetupBuildingEvent $event)
{
$privs = array();
$privs['Safe Only'] = 's';
$privs['Safe and Unknown'] = 'su';
$privs['Safe and Questionable'] = 'sq';
$privs['Safe, Questionable, Unknown'] = 'squ';
$privs['All'] = 'sqeu';
$sb = new SetupBlock("Image Ratings");
$sb->add_choice_option("ext_rating_anon_privs", $privs, "Anonymous: ");
$sb->add_choice_option("ext_rating_user_privs", $privs, "<br>Users: ");
$sb->add_choice_option("ext_rating_admin_privs", $privs, "<br>Admins: ");
$event->panel->add_block($sb);
}
示例2: onSetupBuilding
public function onSetupBuilding($event)
{
$counters = array();
foreach (glob("ext/home/counters/*") as $counter_dirname) {
$name = str_replace("ext/home/counters/", "", $counter_dirname);
$counters[ucfirst($name)] = $name;
}
$sb = new SetupBlock("Home Page");
$sb->add_longtext_option("home_links", 'Page Links - Example: [/post/list|Posts]<br>');
$sb->add_longtext_option("home_text", "<br>Page Text:<br>");
$sb->add_choice_option("home_counter", $counters, "<br>Counter: ");
$event->panel->add_block($sb);
}
示例3: receive_event
public function receive_event(Event $event)
{
global $config, $database, $page, $user;
//if(is_null($this->theme)) $this->theme = get_theme_object($this);
if ($event instanceof ImageInfoBoxBuildingEvent) {
if (!$config->get_bool("tageditcloud_disable")) {
if ($this->can_tag($event->image)) {
if (!($cfg_minusage = $config->get_int("tageditcloud_minusage"))) {
$cfg_minusage = 2;
}
if (!($cfg_defcount = $config->get_int("tageditcloud_defcount"))) {
$cfg_defcount = 40;
}
if (!($cfg_maxcount = $config->get_int("tageditcloud_maxcount"))) {
$cfg_maxcount = 4096;
}
if ($config->get_string("tageditcloud_sort") != "p") {
$event->add_part($this->build_tag_map($event->image, $cfg_minusage, false), 40);
} else {
$event->add_part($this->build_tag_map($event->image, $cfg_defcount, $cfg_maxcount), 40);
}
}
}
}
if ($event instanceof InitExtEvent) {
$config->set_default_bool("tageditcloud_disable", false);
$config->set_default_bool("tageditcloud_usedfirst", true);
$config->set_default_string("tageditcloud_sort", 'a');
$config->set_default_int("tageditcloud_minusage", 2);
$config->set_default_int("tageditcloud_defcount", 40);
$config->set_default_int("tageditcloud_maxcount", 4096);
}
if ($event instanceof SetupBuildingEvent) {
$sort_by = array('Alphabetical' => 'a', 'Popularity' => 'p');
$sb = new SetupBlock("Tag Edit Cloud");
$sb->add_bool_option("tageditcloud_disable", "Disable Tag Selection Cloud: ");
$sb->add_choice_option("tageditcloud_sort", $sort_by, "<br>Sort the tags by:");
$sb->add_bool_option("tageditcloud_usedfirst", "<br>Always show used tags first: ");
$sb->add_label("<br><b>Alpha sort</b>:<br>Only show tags used at least ");
$sb->add_int_option("tageditcloud_minusage");
$sb->add_label(" times.<br><b>Popularity sort</b>:<br>Show ");
$sb->add_int_option("tageditcloud_defcount");
$sb->add_label(" tags by default.<br>Show a maximum of ");
$sb->add_int_option("tageditcloud_maxcount");
$sb->add_label(" tags.");
$event->panel->add_block($sb);
}
}
示例4: onSetupBuilding
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sort_by = array('Alphabetical' => 'a', 'Popularity' => 'p', 'Relevance' => 'r');
$sb = new SetupBlock("Tag Edit Cloud");
$sb->add_bool_option("tageditcloud_disable", "Disable Tag Selection Cloud: ");
$sb->add_choice_option("tageditcloud_sort", $sort_by, "<br>Sort the tags by:");
$sb->add_bool_option("tageditcloud_usedfirst", "<br>Always show used tags first: ");
$sb->add_label("<br><b>Alpha sort</b>:<br>Only show tags used at least ");
$sb->add_int_option("tageditcloud_minusage");
$sb->add_label(" times.<br><b>Popularity/Relevance sort</b>:<br>Show ");
$sb->add_int_option("tageditcloud_defcount");
$sb->add_label(" tags by default.<br>Show a maximum of ");
$sb->add_int_option("tageditcloud_maxcount");
$sb->add_label(" tags.");
$sb->add_label("<br><b>Relevance sort</b>:<br>Ignore tags (space separated): ");
$sb->add_text_option("tageditcloud_ignoretags");
$event->panel->add_block($sb);
}
示例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: receive_event
public function receive_event(Event $event)
{
global $config, $database, $page, $user;
if (is_null($this->theme)) {
$this->theme = get_theme_object($this);
}
if ($event instanceof AdminBuildingEvent) {
$this->theme->display_bulk_rater();
}
if ($event instanceof PageRequestEvent && $event->page_matches("admin/bulk_rate")) {
global $database, $user, $page;
if (!$user->is_admin()) {
throw PermissionDeniedException();
} else {
$n = 0;
while (true) {
$images = Image::find_images($n, 100, Tag::explode($_POST["query"]));
if (count($images) == 0) {
break;
}
foreach ($images as $image) {
send_event(new RatingSetEvent($image, $user, $_POST['rating']));
}
$n += 100;
}
#$database->execute("
# update images set rating=? where images.id in (
# select image_id from image_tags join tags
# on image_tags.tag_id = tags.id where tags.tag = ?);
# ", array($_POST["rating"], $_POST["tag"]));
$page->set_mode("redirect");
$page->set_redirect(make_link("admin"));
}
}
if ($event instanceof InitExtEvent) {
if ($config->get_int("ext_ratings2_version") < 2) {
$this->install();
}
$config->set_default_string("ext_rating_anon_privs", 'squ');
$config->set_default_string("ext_rating_user_privs", 'sqeu');
$config->set_default_string("ext_rating_admin_privs", 'sqeu');
}
if ($event instanceof RatingSetEvent) {
$this->set_rating($event->image->id, $event->rating);
}
if ($event instanceof ImageInfoBoxBuildingEvent) {
if ($this->can_rate()) {
$event->add_part($this->theme->get_rater_html($event->image->id, $event->image->rating), 80);
}
}
if ($event instanceof ImageInfoSetEvent) {
if ($this->can_rate() && isset($_POST["rating"])) {
send_event(new RatingSetEvent($event->image, $user, $_POST['rating']));
}
}
if ($event instanceof SetupBuildingEvent) {
$privs = array();
$privs['Safe Only'] = 's';
$privs['Safe and Unknown'] = 'su';
$privs['Safe and Questionable'] = 'sq';
$privs['Safe, Questionable, Unknown'] = 'squ';
$privs['All'] = 'sqeu';
$sb = new SetupBlock("Image Ratings");
$sb->add_choice_option("ext_rating_anon_privs", $privs, "Anonymous: ");
$sb->add_choice_option("ext_rating_user_privs", $privs, "<br>Users: ");
$sb->add_choice_option("ext_rating_admin_privs", $privs, "<br>Admins: ");
$event->panel->add_block($sb);
}
if ($event instanceof ParseLinkTemplateEvent) {
$event->replace('$rating', $this->theme->rating_to_name($event->image->rating));
}
if ($event instanceof SearchTermParseEvent) {
$matches = array();
if (is_null($event->term) && $this->no_rating_query($event->context)) {
$set = Ratings::privs_to_sql(Ratings::get_user_privs($user));
$event->add_querylet(new Querylet("rating IN ({$set})"));
}
if (preg_match("/^rating=([sqeu]+)\$/", $event->term, $matches)) {
$sqes = $matches[1];
$arr = array();
for ($i = 0; $i < strlen($sqes); $i++) {
$arr[] = "'" . $sqes[$i] . "'";
}
$set = join(', ', $arr);
$event->add_querylet(new Querylet("rating IN ({$set})"));
}
if (preg_match("/^rating=(safe|questionable|explicit|unknown)\$/", strtolower($event->term), $matches)) {
$text = $matches[1];
$char = $text[0];
$event->add_querylet(new Querylet("rating = ?", array($char)));
}
}
}
示例7: 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})");
}
}
}
示例8: 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})");
}
}
}
示例9: onSetupBuilding
public function onSetupBuilding(Event $event)
{
global $config;
$hosts = array("None" => "none", "Gravatar" => "gravatar");
$sb = new SetupBlock("User Options");
$sb->add_bool_option("login_signup_enabled", "Allow new signups: ");
$sb->add_longtext_option("login_tac", "<br>Terms & Conditions:<br>");
$sb->add_choice_option("avatar_host", $hosts, "<br>Avatars: ");
if ($config->get_string("avatar_host") == "gravatar") {
$sb->add_label("<br> <br><b>Gravatar Options</b>");
$sb->add_choice_option("avatar_gravatar_type", array('Default' => 'default', 'Wavatar' => 'wavatar', 'Monster ID' => 'monsterid', 'Identicon' => 'identicon'), "<br>Type: ");
$sb->add_choice_option("avatar_gravatar_rating", array('G' => 'g', 'PG' => 'pg', 'R' => 'r', 'X' => 'x'), "<br>Rating: ");
}
$event->panel->add_block($sb);
}