public static function HTML_itemlist(array $items, string $dir, string $name) { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('.previewButton').click(function(){ console.log ($(this).parent().parent().siblings("div").children(":last-child")); $(this).parent().parent().siblings("div").children(":last-child").css({display:"none"}); $(this).parent().parent().children(":last-child").toggle(); }); $('.importAll').change(function(){ $(this).siblings("div").find(".importCheckbox").prop("checked",this.checked); noofchecked = $(this).parent().parent().parent().find(".importCheckbox:checked").length; $("#importButton").text("Import " + noofchecked + " Item(s)"); }); $('.importCheckbox').change(function(){ noofchecked = $(this).parent().parent().parent().find(".importCheckbox:checked").length; $(this).parent().parent().parent().find(".importAll").prop("checked", noofchecked == ($(this).parent().parent().parent().find(".importCheckbox").length)); $("#importButton").text("Import " + noofchecked + " Item(s)"); }); }); </script> <?php printf("<div class='wrap'><h1>Select Items & Test Results for Import</h1>"); printf("<form enctype='multipart/form-data' action='admin.php?page=import-items' method='post'>"); printf("<input type='hidden' name='file_dir' value='%s'>", $dir); printf("<input type='hidden' name='file_name' value='%s'>", $name); printf("<div style='margin-top:2em'>"); printf("<input class='importAll' type='checkbox' value='1' checked> "); printf("<button id='importButton' type='submit' name='action' value='import'>Import %s Items</button>", count($items)); foreach ($items as $ident => $item) { // if ($item->type == "itemsc") $symbol = "<span class='dashicons dashicons-marker'></span>"; // if ($item->type == "itemmc") $symbol = "<span class='dashicons dashicons-forms'></span>"; printf("\t\t\t\t\t\r\n\t\t\t\t<div style='margin-top:2em;'>\r\n\t\t\t\t\t<hr/>\r\n\t\t\t\t\t<div style='margin-top:0em;'>\r\n\t\t\t\t\t\t<input class='importCheckbox' type='checkbox' name='import[]' value='%s' checked> \r\n\t\t\t\t\t\t<input class='previewButton' type='button' value='Preview'></input> \r\n\t\t\t\t\t\t%s %s\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div style='margin-top:2em; display:none'>\r\n\t\t\t\t\t\t%s\r\n\t\t\t\t\t\t<br style='clear:both;'/>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t", $ident, $item->title, $symbol, CPT_Item::getHTML_Item($item, FALSE, TRUE, $ident . "_")); } printf("</div></form></div>"); }
public static function createPageView() { $itemids = array(); /* try to get learning outcomes */ $post_label = "Learning Outcome"; if ($_REQUEST['learnoutid'] != null) { $itemids = [$_REQUEST['learnoutid']]; } if ($_REQUEST['learnoutids'] != null) { if (is_array($_REQUEST['learnoutids'])) { $itemids = $_REQUEST['learnoutids']; } if (is_string($_REQUEST['learnoutids'])) { $itemids = explode(",", $_REQUEST["learnoutids"]); } } if (count($itemids) == 0) { // no learning outcomes found --> get reviews $post_label = "Review"; if ($_REQUEST['reviewid'] != null) { $itemids = [$_REQUEST['reviewid']]; } if ($_REQUEST['reviewids'] != null) { if (is_array($_REQUEST['reviewids'])) { $itemids = $_REQUEST['reviewids']; } if (is_string($_REQUEST['reviewids'])) { $itemids = explode(",", $_REQUEST["reviewids"]); } } } if (count($itemids) == 0) { // nothing found --> get items $post_label = "Item"; if ($_REQUEST['itemid'] != null) { $itemids = [$_REQUEST['itemid']]; } if ($_REQUEST['itemids'] != null) { if (is_array($_REQUEST['itemids'])) { $itemids = $_REQUEST['itemids']; } if (is_string($_REQUEST['itemids'])) { $itemids = explode(",", $_REQUEST["itemids"]); } } // fallback: get items from basket if (count($itemids) == 0) { $itemids = RoleTaxonomy::getCurrentBasket(); } // get_user_meta(get_current_user_id(), 'itembasket', true); } $html_list = ""; $html_select = "<form><select onChange='for (x=0; x<this.form.nextSibling.childNodes.length; x++) { this.form.nextSibling.childNodes[x].style.display = ((this.value<0) || (this.value==x)) ? \"block\" : \"none\"; }'>"; $html_select .= sprintf('<option value="-1" selected>[All %1$d %2$ss]</option>', count($itemids), $post_label); $count = 0; $items = array(); foreach ($itemids as $item_id) { $post = get_post($item_id); if ($post == null) { continue; } $item = null; if ($post->post_type == 'itemsc') { $item = new EAL_ItemSC(); } if ($post->post_type == 'itemmc') { $item = new EAL_ItemMC(); } if ($post->post_type == 'learnout') { $item = new EAL_LearnOut(); } if ($post->post_type == 'review') { $item = new EAL_Review(); } if ($item != null) { $item->loadById($item_id); $html_select .= sprintf("<option value='%d'>%s</option>", $count, $post->post_type == 'review' ? $item->getItem()->title : $item->title); $html_list .= sprintf("<div style='margin-top:2em;'><hr/>%s<br style='clear:both;'/></div>", substr($post->post_type, 0, 4) == "item" ? CPT_Item::getHTML_Item($item, FALSE) : ($post->post_type == 'learnout' ? CPT_LearnOut::getHTML_LearnOut($item) : CPT_Review::getHTML_Review($item))); $count++; array_push($items, $item); } } $html_select .= "</select> <input type='checkbox' checked \r\n\t\t\tonChange='for (x=0; x<this.form.nextSibling.childNodes.length; x++) { this.form.nextSibling.childNodes[x].querySelector(\"#postbox-container-1\").style.display = (this.checked==true) ? \"block\" : \"none\"; }'/> Show Metadata</form>"; if ($post_label == "Item") { $html_info = sprintf("<form style='margin-top:5em' enctype='multipart/form-data' action='admin.php?page=view&download=1&itemids=%s' method='post'><table class='form-table'><tbody'>", implode(",", $itemids)); $html_info .= sprintf("<tr><th style='padding-top:0px; padding-bottom:0px;'><label>%s</label></th>", "Number of Items"); $html_info .= sprintf("<td style='padding-top:0px; padding-bottom:0px;'>"); $html_info .= sprintf("<input style='width:5em' type='number' value='%d' readonly/>", count($items)); $html_info .= sprintf("</td></tr>"); // Min / Max for all categories $categories = array("type", "dim", "level", "topic1"); foreach ($categories as $category) { $html_info .= sprintf("<tr><th style='padding-bottom:0.5em;'><label>%s</label></th></tr>", EAL_Item::$category_label[$category]); foreach (PAG_Explorer::groupBy($category, $items, NULL, true) as $catval => $catitems) { $html_info .= sprintf("<tr><td style='padding-top:0px; padding-bottom:0px;'><label>%s</label></td>", $category == "topic1" ? $catval : EAL_Item::$category_value_label[$category][$catval]); $html_info .= sprintf("<td style='padding-top:0px; padding-bottom:0px;'>"); $html_info .= sprintf("<input style='width:5em' type='number' value='%d' readonly/>", count($catitems)); $html_info .= sprintf("</td></tr>"); } } $html_info .= sprintf("<tr><th><button type='submit' name='action' value='download'>Download</button></th><tr>"); $html_info .= sprintf("</tbody></table></form></div>"); } printf('<div class="wrap"><h1>%1$s Viewer</h1>', $post_label); if ($_REQUEST['download'] == '1') { $ilias = new EXP_Ilias(); $link = $ilias->generateExport($itemids); printf("<h2><a href='%s'>Download</a></h2>", $link); } if (count($itemids) > 1 || count($itemids) == 1) { print $html_select; print "<div style='margin-top:2em'>{$html_list}{$html_info}</div>"; } else { print "<div style='margin-top:2em'>{$html_list}</div>"; } print "</div>"; }
public function WPCB_mb_item($post, $vars) { global $review; if (!is_null($review->getItem())) { $html = CPT_Item::getHTML_Item($review->getItem()); echo $html; } }