$pool) { $linksPools[] = "" . html_escape($pool['info']['title']) . ""; if (array_key_exists('nav', $pool)) { $navlinks = ""; if (!empty($pool['nav']['prev'])) { $navlinks .= 'Prev'; } if (!empty($pool['nav']['next'])) { $navlinks .= 'Next'; } if (!empty($navlinks)) { $navlinks .= "
"; $linksPools[] = $navlinks; } } } if (count($linksPools) > 0) { $page->add_block(new Block("Pools", implode("
", $linksPools), "left")); } } public function get_adder_html(Image $image, array $pools): string { $h = ""; foreach ($pools as $pool) { $h .= ""; } $editor = "\n" . make_form(make_link("pool/add_post")) . " "; return $editor; } /** * HERE WE SHOWS THE LIST OF POOLS. */ public function list_pools(Page $page, array $pools, int $pageNumber, int $totalPages) { $html = ' '; // Build up the list of pools. foreach ($pools as $pool) { $pool_link = '' . html_escape($pool['title']) . ""; $user_link = '' . html_escape($pool['user_name']) . ""; $public = ($pool['public'] == "Y" ? "Yes" : "No"); $html .= "" . "" . "" . "" . "" . ""; } $html .= "
Name Creator Posts Public
" . $pool_link . "" . $user_link . "" . $pool['posts'] . "" . $public . "
"; $order_html = ''; $this->display_top(null, "Pools"); $page->add_block(new Block("Order By", $order_html, "left", 15)); $page->add_block(new Block("Pools", $html, "main", 10)); $this->display_paginator($page, "pool/list", null, $pageNumber, $totalPages); } /* * HERE WE DISPLAY THE NEW POOL COMPOSER */ public function new_pool_composer(Page $page) { $create_html = " " . make_form(make_link("pool/create")) . "
Title:
Public?
Description:
"; $this->display_top(null, "Create Pool"); $page->add_block(new Block("Create Pool", $create_html, "main", 20)); } private function display_top(?array $pools, string $heading, bool $check_all = false) { global $page, $user; $page->set_title($heading); $page->set_heading($heading); $poolnav_html = ' Pool Index
Create Pool
Pool Changes '; $page->add_block(new NavBlock()); $page->add_block(new Block("Pool Navigation", $poolnav_html, "left", 10)); if (!is_null($pools) && count($pools) == 1) { $pool = $pools[0]; if ($pool['public'] == "Y" || $user->is_admin()) {// IF THE POOL IS PUBLIC OR IS ADMIN SHOW EDIT PANEL if (!$user->is_anonymous()) {// IF THE USER IS REGISTERED AND LOGGED IN SHOW EDIT PANEL $this->sidebar_options($page, $pool, $check_all); } } $tfe = new TextFormattingEvent($pool['description']); send_event($tfe); $page->add_block(new Block(html_escape($pool['title']), $tfe->formatted, "main", 10)); } } /** * HERE WE DISPLAY THE POOL WITH TITLE DESCRIPTION AND IMAGES WITH PAGINATION. */ public function view_pool(array $pools, array $images, int $pageNumber, int $totalPages) { global $page; $this->display_top($pools, "Pool: " . html_escape($pools[0]['title'])); $pool_images = ''; foreach ($images as $image) { $thumb_html = $this->build_thumb_html($image); $pool_images .= "\n" . $thumb_html . "\n"; } $page->add_block(new Block("Viewing Posts", $pool_images, "main", 30)); $this->display_paginator($page, "pool/view/" . $pools[0]['id'], null, $pageNumber, $totalPages); } /** * HERE WE DISPLAY THE POOL OPTIONS ON SIDEBAR BUT WE HIDE REMOVE OPTION IF THE USER IS NOT THE OWNER OR ADMIN. */ public function sidebar_options(Page $page, array $pool, bool $check_all) { global $user; $editor = "\n" . make_form(make_link('pool/import')) . ' ' . make_form(make_link('pool/edit')) . ' ' . make_form(make_link('pool/order')) . ' '; if ($user->id == $pool['user_id'] || $user->is_admin()) { $editor .= " " . make_form(make_link("pool/nuke")) . " "; } if ($check_all) { $editor .= "
"; } $page->add_block(new Block("Manage Pool", $editor, "left", 15)); } /** * HERE WE DISPLAY THE RESULT OF THE SEARCH ON IMPORT. */ public function pool_result(Page $page, array $images, array $pool) { $this->display_top($pool, "Importing Posts", true); $pool_images = " "; $pool_images .= "
"; foreach ($images as $image) { $thumb_html = $this->build_thumb_html($image); $pool_images .= '' . $thumb_html . '
' . '' . '
'; } $pool_images .= "
" . "" . "" . "
"; $page->add_block(new Block("Import", $pool_images, "main", 30)); } /** * HERE WE DISPLAY THE POOL ORDERER. * WE LIST ALL IMAGES ON POOL WITHOUT PAGINATION AND WITH A TEXT INPUT TO SET A NUMBER AND CHANGE THE ORDER */ public function edit_order(Page $page, array $pools, array $images) { $this->display_top($pools, "Sorting Pool"); $pool_images = "\n
"; $i = 0; foreach ($images as $pair) { $image = $pair[0]; $thumb_html = $this->build_thumb_html($image); $pool_images .= '' . "\n" . $thumb_html . "\n" . '
' . '' . '
'; $i++; } $pool_images .= "
" . "" . "" . "
"; $page->add_block(new Block("Sorting Posts", $pool_images, "main", 30)); } /** * HERE WE DISPLAY THE POOL EDITOR. * * WE LIST ALL IMAGES ON POOL WITHOUT PAGINATION AND WITH * A CHECKBOX TO SELECT WHICH IMAGE WE WANT TO REMOVE */ public function edit_pool(Page $page, array $pools, array $images) { /* EDIT POOL DESCRIPTION */ $desc_html = " " . make_form(make_link("pool/edit_description")) . "
"; /* REMOVE POOLS */ $pool_images = "\n
"; foreach ($images as $pair) { $image = $pair[0]; $thumb_html = $this->build_thumb_html($image); $pool_images .= '' . "\n" . $thumb_html . "\n" . '
' . '
'; } $pool_images .= "
" . "" . "" . "
"; $pools[0]['description'] = ""; //This is a rough fix to avoid showing the description twice. $this->display_top($pools, "Editing Pool", true); $page->add_block(new Block("Editing Description", $desc_html, "main", 28)); $page->add_block(new Block("Editing Posts", $pool_images, "main", 30)); } /** * HERE WE DISPLAY THE HISTORY LIST. */ public function show_history(array $histories, int $pageNumber, int $totalPages) { global $page; $html = ' '; foreach ($histories as $history) { $pool_link = "" . html_escape($history['title']) . ""; $user_link = "" . html_escape($history['user_name']) . ""; $revert_link = "Revert"; if ($history['action'] == 1) { $prefix = "+"; } elseif ($history['action'] == 0) { $prefix = "-"; } else { throw new Exception("history['action'] not in {0, 1}"); } $images = trim($history['images']); $images = explode(" ", $images); $image_link = ""; foreach ($images as $image) { $image_link .= "" . $prefix . $image . " "; } $html .= "" . "" . "" . "" . "" . "" . "" . ""; } $html .= "
Pool Post Count Changes Updater Date Action
" . $pool_link . "" . $history['count'] . "" . $image_link . "" . $user_link . "" . $history['date'] . "" . $revert_link . "
"; $this->display_top(null, "Recent Changes"); $page->add_block(new Block("Recent Changes", $html, "main", 10)); $this->display_paginator($page, "pool/updated", null, $pageNumber, $totalPages); } public function get_bulk_pool_selector(array $pools) { $output = ""; } public function get_bulk_pool_input(array $search_terms) { return ""; } }