public static function getHTML_LearnOut(EAL_LearnOut $lo)
 {
     $lo_html = sprintf("\r\n\t\t\t<div onmouseover=\"this.children[1].style.display='inline';\"  onmouseout=\"this.children[1].style.display='none';\">\r\n\t\t\t\t<h1 style='display:inline'>%s</span></h1>\r\n\t\t\t\t<div style='display:none'>\r\n\t\t\t\t\t<span><a href=\"post.php?action=edit&post=%d\">Edit</a></span>\r\n\t\t\t\t</div>\r\n\t\t\t</div>", $lo->title, $lo->id);
     $lo_html .= sprintf("<div>%s</div>", wpautop(stripslashes($lo->description)));
     return sprintf("\r\n\t\t\t\t<div id='poststuff'>\r\n\t\t\t\t\t<div id='post-body' class='metabox-holder columns-2'>\r\n\t\t\t\t\t\t<div class='postbox-container' id='postbox-container-2'>\r\n\t\t\t\t\t\t\t<div class='meta-box-sortables ui-sortable'>\r\n\t\t\t\t\t\t\t\t%s\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='postbox-container' id='postbox-container-1'>\r\n\t\t\t\t\t\t\t<div style='background-color:#FFFFFF; margin-top:1em; padding:1em; border-width:1px; border-style:solid; border-color:#CCCCCC;'>\r\n\t\t\t\t\t\t\t\t%s\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>", $lo_html, CPT_LearnOut::getHTML_Metadata($lo));
 }
function WPCP_dashboard_metadata()
{
    printf('<table border="0">');
    $domain = RoleTaxonomy::getCurrentRoleDomain();
    if ($domain["name"] != "") {
        $term_count = wp_count_terms($domain["name"], array('hide_empty' => false));
        printf('<tr><td style="width:11em"><div class="dashicons-before dashicons-networking" 		style="display:inline">&nbsp;</div> %1$s</td>			<td align="right" style="width:4em"><a href="edit-tags.php?taxonomy=%2$s">%3$d</a></td></tr>', $domain["label"], $domain["name"], $term_count);
    }
    $object = new CPT_LearnOut();
    $object->init();
    $count = $object->WPCB_count_posts(NULL, $object->type, NULL);
    printf('<tr><td style="width:11em"><div class="dashicons-before dashicons-welcome-learn-more" 	style="display:inline">&nbsp;</div> Learning Outcomes</td>		<td align="right" style="width:4em"><a href="edit.php?post_type=learnout">%1$d</a></td></tr>', $count->publish + $count->pending + $count->draft);
    printf('</table>');
}
Beispiel #3
0
 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>&nbsp;&nbsp;&nbsp;<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>";
 }