本文整理汇总了PHP中Tag::explode方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::explode方法的具体用法?PHP Tag::explode怎么用?PHP Tag::explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::explode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_history_page
/**
* @param Page $page
* @param int $image_id
* @param array $history
*/
public function display_history_page(Page $page, $image_id, $history)
{
global $user;
$start_string = "\n\t\t\t<div style='text-align: left'>\n\t\t\t\t" . make_form(make_link("tag_history/revert")) . "\n\t\t\t\t\t<ul style='list-style-type:none;'>\n\t\t";
$history_list = "";
$n = 0;
foreach ($history as $fields) {
$n++;
$current_id = $fields['id'];
$current_tags = html_escape($fields['tags']);
$name = $fields['name'];
$h_ip = $user->can("view_ip") ? " " . show_ip($fields['user_ip'], "Tagging Image #{$image_id} as '{$current_tags}'") : "";
$setter = "<a href='" . make_link("user/" . url_escape($name)) . "'>" . html_escape($name) . "</a>{$h_ip}";
$selected = $n == 2 ? " checked" : "";
$current_tags = Tag::explode($current_tags);
$taglinks = array();
foreach ($current_tags as $tag) {
$taglinks[] = "<a href='" . make_link("post/list/" . $tag . "/1") . "'>" . $tag . "</a>";
}
$current_tags = Tag::implode($taglinks);
$history_list .= "\n\t\t\t\t<li>\n\t\t\t\t\t<input type='radio' name='revert' id='{$current_id}' value='{$current_id}'{$selected}>\n\t\t\t\t\t<label for='{$current_id}'>{$current_tags} (Set by {$setter})</label>\n\t\t\t\t</li>\n\t\t\t\t";
}
$end_string = "\n\t\t\t\t\t</ul>\n\t\t\t\t\t<input type='submit' value='Revert To'>\n\t\t\t\t</form>\n\t\t\t</div>\n\t\t";
$history_html = $start_string . $history_list . $end_string;
$page->set_title('Image ' . $image_id . ' Tag History');
$page->set_heading('Tag History: ' . $image_id);
$page->add_block(new NavBlock());
$page->add_block(new Block("Tag History", $history_html, "main", 10));
}
示例2: create_image_from_data
/**
* @param string $filename
* @param array $metadata
* @return Image|null
*/
protected function create_image_from_data($filename, $metadata)
{
global $config;
$image = new Image();
// FIXME: need more flash format specs :|
$image->width = 0;
$image->height = 0;
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
//Cheat by using the filename to store artist/title if available
require_once 'lib/getid3/getid3/getid3.php';
$getID3 = new getID3();
$ThisFileInfo = $getID3->analyze($filename, TRUE);
if (isset($ThisFileInfo['tags']['id3v2']['artist'][0]) && isset($ThisFileInfo['tags']['id3v2']['title'][0])) {
$image->filename = $ThisFileInfo['tags']['id3v2']['artist'][0] . " - " . $ThisFileInfo['tags']['id3v2']['title'][0] . ".mp3";
} else {
if (isset($ThisFileInfo['tags']['id3v1']['artist'][0]) && isset($ThisFileInfo['tags']['id3v1']['title'][0])) {
$image->filename = $ThisFileInfo['tags']['id3v1']['artist'][0] . " - " . $ThisFileInfo['tags']['id3v1']['title'][0] . ".mp3";
} else {
$image->filename = $metadata['filename'];
}
}
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;
}
示例3: create_image_from_data
/**
* @param string $filename
* @param mixed[] $metadata
* @return Image
*/
private function create_image_from_data($filename, $metadata)
{
$image = new Image();
$msp = new MiniSVGParser($filename);
$image->width = $msp->width;
$image->height = $msp->height;
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;
}
示例4: create_image_from_data
protected function create_image_from_data($filename, $metadata)
{
global $config;
$image = new Image();
// FIXME: need more flash format specs :|
$image->width = 0;
$image->height = 0;
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;
}
示例5: create_image_from_data
protected function create_image_from_data($filename, $metadata)
{
global $config;
$image = new Image();
$info = "";
if (!($info = getimagesize($filename))) {
return null;
}
$image->width = $info[0];
$image->height = $info[1];
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;
}
示例6: onPageRequest
public function onPageRequest(PageRequestEvent $event)
{
global $page, $user;
if ($event->page_matches("mass_tagger/tag") && $user->is_admin()) {
if (!isset($_POST['ids']) or !isset($_POST['tag'])) {
return;
}
$tag = $_POST['tag'];
$tag_array = explode(" ", $tag);
$pos_tag_array = array();
$neg_tag_array = array();
foreach ($tag_array as $new_tag) {
if (strpos($new_tag, '-') === 0) {
$neg_tag_array[] = substr($new_tag, 1);
} else {
$pos_tag_array[] = $new_tag;
}
}
$ids = explode(':', $_POST['ids']);
$ids = array_filter($ids, 'is_numeric');
$images = array_map("Image::by_id", $ids);
if (isset($_POST['setadd']) && $_POST['setadd'] == 'set') {
foreach ($images as $image) {
$image->set_tags(Tag::explode($tag));
}
} else {
foreach ($images as $image) {
if (!empty($neg_tag_array)) {
$img_tags = array_merge($pos_tag_array, explode(" ", $image->get_tag_list()));
$img_tags = array_diff($img_tags, $neg_tag_array);
$image->set_tags(Tag::explode($img_tags));
} else {
$image->set_tags(Tag::explode($tag . " " . $image->get_tag_list()));
}
}
}
$page->set_mode("redirect");
if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = make_link();
}
$page->set_redirect($_SERVER['HTTP_REFERER']);
}
}
示例7: resolve_list
public static function resolve_list($tags)
{
$tags = Tag::explode($tags);
$new = array();
foreach ($tags as $tag) {
$new_set = explode(' ', Tag::resolve_alias($tag));
foreach ($new_set as $new_one) {
$new[] = $new_one;
}
}
$new = array_map(array('Tag', 'sanitise'), $new);
$new = array_iunique($new);
// remove any duplicate tags
return $new;
}
示例8: mass_tag_edit
private function mass_tag_edit($search, $replace)
{
global $database;
global $config;
$search_set = Tag::explode($search);
$replace_set = Tag::explode($replace);
$last_id = -1;
while (true) {
// make sure we don't look at the same images twice.
// search returns high-ids first, so we want to look
// at images with lower IDs than the previous.
$search_forward = $search_set;
if ($last_id >= 0) {
$search_forward[] = "id<{$last_id}";
}
$images = Image::find_images(0, 100, $search_forward);
if (count($images) == 0) {
break;
}
foreach ($images as $image) {
// remove the search'ed tags
$before = $image->get_tag_array();
$after = array();
foreach ($before as $tag) {
if (!in_array($tag, $search_set)) {
$after[] = $tag;
}
}
// add the replace'd tags
foreach ($replace_set as $tag) {
$after[] = $tag;
}
$image->set_tags($after);
$last_id = $image->id;
}
}
}
示例9: mass_source_edit
/**
* @param string|string[] $tags
* @param string $source
*/
private function mass_source_edit($tags, $source)
{
$tags = Tag::explode($tags);
$last_id = -1;
while (true) {
// make sure we don't look at the same images twice.
// search returns high-ids first, so we want to look
// at images with lower IDs than the previous.
$search_forward = $tags;
if ($last_id >= 0) {
$search_forward[] = "id<{$last_id}";
}
$images = Image::find_images(0, 100, $search_forward);
if (count($images) == 0) {
break;
}
foreach ($images as $image) {
$image->set_source($source);
$last_id = $image->id;
}
}
}
示例10: handle_commands
public function handle_commands($event)
{
global $config, $page, $user;
if ($event->page_matches("artist")) {
switch ($event->get_arg(0)) {
//*************ARTIST SECTION**************
case "list":
$this->get_listing($page, $event);
$this->theme->sidebar_options("neutral");
break;
case "new":
if (!$user->is_anonymous()) {
$this->theme->new_artist_composer();
} else {
$errMessage = "You must be registered and logged in to create a new artist.";
$this->theme->display_error($page, "Error", $errMessage);
}
break;
case "new_artist":
$page->set_mode("redirect");
$page->set_redirect(make_link("artist/new"));
break;
case "create":
if (!$user->is_anonymous()) {
$newArtistID = $this->add_artist();
if ($newArtistID == -1) {
$errMessage = "Error when entering artist data.";
$this->theme->display_error($page, "Error", $errMessage);
} else {
$page->set_mode("redirect");
$page->set_redirect(make_link("artist/view/" . $newArtistID));
}
} else {
$errMessage = "You must be registered and logged in to create a new artist.";
$this->theme->display_error($page, "Error", $errMessage);
}
break;
case "view":
$artistID = $event->get_arg(1);
$artist = $this->get_artist($artistID);
$aliases = $this->get_alias($artist['id']);
$members = $this->get_members($artist['id']);
$urls = $this->get_urls($artist['id']);
$userIsLogged = !$user->is_anonymous();
$userIsAdmin = $user->is_admin();
$images = Image::find_images(0, 4, Tag::explode($artist['name']));
$this->theme->show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin);
if ($userIsLogged) {
//$this->theme->show_new_alias_composer($artistID);
//$this->theme->show_new_member_composer($artistID);
//$this->theme->show_new_url_composer($artistID);
}
$this->theme->sidebar_options("editor", $artistID, $userIsAdmin);
break;
case "edit":
$artistID = $event->get_arg(1);
$artist = $this->get_artist($artistID);
$aliases = $this->get_alias($artistID);
$members = $this->get_members($artistID);
$urls = $this->get_urls($artistID);
if (!$user->is_anonymous()) {
$this->theme->show_artist_editor($artist, $aliases, $members, $urls);
$userIsAdmin = $user->is_admin();
$this->theme->sidebar_options("editor", $artistID, $userIsAdmin);
} else {
$errMessage = "You must be registered and logged in to edit an artist.";
$this->theme->display_error($page, "Error", $errMessage);
}
break;
case "edit_artist":
$artistID = $_POST['artist_id'];
$page->set_mode("redirect");
$page->set_redirect(make_link("artist/edit/" . $artistID));
break;
case "edited":
$artistID = int_escape($_POST['id']);
$this->update_artist();
$page->set_mode("redirect");
$page->set_redirect(make_link("artist/view/" . $artistID));
break;
case "nuke_artist":
$artistID = $_POST['artist_id'];
$page->set_mode("redirect");
$page->set_redirect(make_link("artist/nuke/" . $artistID));
break;
case "nuke":
$artistID = $event->get_arg(1);
$this->delete_artist($artistID);
// this will delete the artist, it's alias, it's urls and it's members
$page->set_mode("redirect");
$page->set_redirect(make_link("artist/list"));
break;
case "add_alias":
$artistID = $_POST['artist_id'];
$this->theme->show_new_alias_composer($artistID);
break;
case "add_member":
$artistID = $_POST['artist_id'];
$this->theme->show_new_member_composer($artistID);
break;
//.........这里部分代码省略.........
示例11: build_tag_map
/**
* @param Image $image
* @return string
*/
private function build_tag_map(Image $image)
{
global $database, $config;
$html = "";
$cloud = "";
$precloud = "";
$postcloud = "";
$sort_method = $config->get_string("tageditcloud_sort");
$tags_min = $config->get_int("tageditcloud_minusage");
$used_first = $config->get_bool("tageditcloud_usedfirst");
$max_count = $config->get_int("tageditcloud_maxcount");
$def_count = $config->get_int("tageditcloud_defcount");
$ignore_tags = Tag::explode($config->get_string("tageditcloud_ignoretags"));
if (class_exists("TagCategories")) {
$categories = $database->get_all("SELECT category, color FROM image_tag_categories");
$cat_color = array();
foreach ($categories as $row) {
$cat_color[$row['category']] = $row['color'];
}
}
$tag_data = null;
switch ($sort_method) {
case 'a':
case 'p':
default:
$tag_data = $database->get_all("SELECT tag, FLOOR(LN(LN(count - :tag_min1 + 1)+1)*150)/200 AS scaled, count\n\t\t\t\t\tFROM tags WHERE count >= :tag_min2 ORDER BY " . ($sort_method == 'a' ? "tag" : "count DESC") . " LIMIT :limit", array("tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count));
break;
case 'r':
$relevant_tags = array_diff($image->get_tag_array(), $ignore_tags);
if (count($relevant_tags) > 0) {
$relevant_tags = implode(",", array_map(array($database, "escape"), $relevant_tags));
$tag_data = $database->get_all("SELECT t2.tag AS tag, COUNT(image_id) AS count, FLOOR(LN(LN(COUNT(image_id) - :tag_min1 + 1)+1)*150)/200 AS scaled\n\t\t\t\t\t\tFROM image_tags it1 JOIN image_tags it2 USING(image_id) JOIN tags t1 ON it1.tag_id = t1.id JOIN tags t2 ON it2.tag_id = t2.id\n\t\t\t\t\t\tWHERE t1.count >= :tag_min2 AND t1.tag IN({$relevant_tags}) GROUP BY t2.tag ORDER BY count DESC LIMIT :limit", array("tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count));
}
break;
}
$counter = 1;
foreach ($tag_data as $row) {
$full_tag = $row['tag'];
if (class_exists("TagCategories")) {
$tc = explode(':', $row['tag']);
if (isset($tc[1]) && isset($cat_color[$tc[0]])) {
$h_tag = html_escape($tc[1]);
$color = '; color:' . $cat_color[$tc[0]];
} else {
$h_tag = html_escape($row['tag']);
$color = '';
}
} else {
$h_tag = html_escape($row['tag']);
$color = '';
}
$size = sprintf("%.2f", max($row['scaled'], 0.5));
$js = htmlspecialchars('tageditcloud_toggle_tag(this,' . json_encode($full_tag) . ')', ENT_QUOTES);
//Ugly, but it works
if (array_search($row['tag'], $image->get_tag_array()) !== FALSE) {
if ($used_first) {
$precloud .= " <span onclick='{$js}' class='tag-selected' style='font-size: {$size}em{$color}' title='{$row['count']}'>{$h_tag}</span> \n";
continue;
} else {
$entry = " <span onclick='{$js}' class='tag-selected' style='font-size: {$size}em{$color}' title='{$row['count']}'>{$h_tag}</span> \n";
}
} else {
$entry = " <span onclick='{$js}' style='font-size: {$size}em{$color}' title='{$row['count']}'>{$h_tag}</span> \n";
}
if ($counter++ <= $def_count) {
$cloud .= $entry;
} else {
$postcloud .= $entry;
}
}
if ($precloud != '') {
$html .= "<div id='tagcloud_set'>{$precloud}</div>";
}
if ($postcloud != '') {
$postcloud = "<div id='tagcloud_extra' style='display: none;'>{$postcloud}</div>";
}
$html .= "<div id='tagcloud_unset'>{$cloud}{$postcloud}</div>";
if ($sort_method != 'a' && $counter > $def_count) {
$rem = $counter - $def_count;
$html .= "</div><br>[<span onclick='tageditcloud_toggle_extra(this);' style='color: #0000EF; font-weight:bold;'>show {$rem} more tags</span>]";
}
return "<div id='tageditcloud' class='tageditcloud'>{$html}</div>";
// FIXME: stupidasallhell
}
示例12: add_refine_block
/**
* @param Page $page
* @param string[] $search
*/
private function add_refine_block(Page $page, $search)
{
global $database, $config;
$wild_tags = Tag::explode($search);
$str_search = Tag::implode($search);
$related_tags = $database->cache->get("related_tags:{$str_search}");
if (empty($related_tags)) {
// $search_tags = array();
$tag_id_array = array();
$tags_ok = true;
foreach ($wild_tags as $tag) {
$tag = str_replace("*", "%", $tag);
$tag = str_replace("?", "_", $tag);
$tag_ids = $database->get_col("SELECT id FROM tags WHERE tag LIKE :tag", array("tag" => $tag));
// $search_tags = array_merge($search_tags,
// $database->get_col("SELECT tag FROM tags WHERE tag LIKE :tag", array("tag"=>$tag)));
$tag_id_array = array_merge($tag_id_array, $tag_ids);
$tags_ok = count($tag_ids) > 0;
if (!$tags_ok) {
break;
}
}
$tag_id_list = join(', ', $tag_id_array);
if ($tags_ok) {
$query = "\n\t\t\t\t\tSELECT t2.tag AS tag, COUNT(it2.image_id) AS calc_count\n\t\t\t\t\tFROM\n\t\t\t\t\t\timage_tags AS it1,\n\t\t\t\t\t\timage_tags AS it2,\n\t\t\t\t\t\ttags AS t1,\n\t\t\t\t\t\ttags AS t2\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tt1.id IN({$tag_id_list})\n\t\t\t\t\t\tAND it1.image_id=it2.image_id\n\t\t\t\t\t\tAND it1.tag_id = t1.id\n\t\t\t\t\t\tAND it2.tag_id = t2.id\n\t\t\t\t\tGROUP BY t2.tag\n\t\t\t\t\tORDER BY calc_count\n\t\t\t\t\tDESC LIMIT :limit\n\t\t\t\t";
$args = array("limit" => $config->get_int('tag_list_length'));
$related_tags = $database->get_all($query, $args);
$database->cache->set("related_tags:{$str_search}", $related_tags, 60 * 60);
}
}
if (!empty($related_tags)) {
$this->theme->display_refine_block($page, $related_tags, $wild_tags);
}
}
示例13: import_posts
/**
* HERE WE GET THE IMAGES FROM THE TAG ON IMPORT
* @param int $pool_id
*/
private function import_posts($pool_id)
{
global $page, $config;
$poolsMaxResults = $config->get_int("poolsMaxImportResults", 1000);
$images = $images = Image::find_images(0, $poolsMaxResults, Tag::explode($_POST["pool_tag"]));
$this->theme->pool_result($page, $images, $this->get_pool($pool_id));
}
示例14: delete_by_query
private function delete_by_query()
{
global $page;
$query = $_POST['query'];
$reason = @$_POST['reason'];
assert(strlen($query) > 1);
log_warning("admin", "Mass deleting: {$query}");
$count = 0;
foreach (Image::find_images(0, 1000000, Tag::explode($query)) as $image) {
if ($reason && class_exists("ImageBan")) {
send_event(new AddImageHashBanEvent($image->hash, $reason));
}
send_event(new ImageDeletionEvent($image));
$count++;
}
log_debug("admin", "Deleted {$count} images", true);
$page->set_mode("redirect");
$page->set_redirect(make_link("post/list"));
return false;
}
示例15: 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})");
}
}
}