示例#1
0
    public static function createPageTable()
    {
        wp_redirect('http://www.google.de');
        exit;
        $myListTable = new CPT_Item_Table();
        $action = $myListTable->process_bulk_action();
        if ($action == "viewitems") {
            return PAG_Basket::createPageView();
        }
        // echo '<div class="wrap"><h2>My List Table Test</h2>';
        $myListTable->prepare_items();
        ?>
		
			<div class="wrap">
			
				<h1>Item Basket</h1>
		
		<form method="post">
		<input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
		<?php 
        $myListTable->search_box('search', 'search_id');
        $myListTable->display();
        ?>
		</form>
			</div>
		<?php 
    }
示例#2
0
 public static function load_items_callback()
 {
     // 		global $wpdb; // this is how you get access to the database
     $items = PAG_Basket::loadAllItemsFromBasket();
     // 		echo "<script> console.log('dimy0', 'test'); </script>";
     // 		print ("<script> console.log('dimy0', '" . $_POST['dimy0'] . "'); </script>");
     $_SESSION["dim_names"] = array(array($_POST['dimx0'], $_POST['dimx1'], $_POST['dimx2']), array($_POST['dimy0'], $_POST['dimy1'], $_POST['dimy2']));
     // FOR DEBUG
     $dim_names = array(array($_POST['dimx0'], $_POST['dimx1'], $_POST['dimx2']), array($_POST['dimy0'], $_POST['dimy1'], $_POST['dimy2']));
     // 		$dim_names = array(array ('dim', null, null), array('type', null, null));
     // 		$dim_values = array(array(), array());
     // 		foreach ([0,1] as $x) {
     // 			foreach ([0,1,2] as $y) {
     // 				$dim_values[$x][$y] = PAG_Explorer::getDimXValues($dim_names[$x][$y]);
     // 			}
     // 		}
     $noOfDimY = 3;
     if ($_POST['dimy2'] == "none" || $_POST['dimy2'] == null) {
         $noOfDimY = 2;
     }
     if ($_POST['dimy1'] == "none" || $_POST['dimy1'] == null) {
         $noOfDimY = 1;
     }
     if ($_POST['dimy0'] == "none" || $_POST['dimy0'] == null) {
         $noOfDimY = 0;
     }
     // group items by all dimensions (3+3)
     $res = array();
     $createHeader = true;
     $lines = array();
     $lines_href = array();
     $row_span = array(array(), array());
     foreach (PAG_Explorer::groupBy($dim_names[1][0], $items, null, false) as $k1 => $items1) {
         $level1_first = true;
         $level1_span = 0;
         foreach (PAG_Explorer::groupBy($dim_names[1][1], $items1, $k1, false) as $k2 => $items2) {
             $level2_first = true;
             $level2_span = 0;
             foreach (PAG_Explorer::groupBy($dim_names[1][2], $items2, $k2, false) as $k3 => $items3) {
                 if (createHeader) {
                     $header_values = array([], [], []);
                     $header_sizes = array([], [], []);
                 }
                 $level1_span++;
                 $level2_span++;
                 $line = array($level1_first ? PAG_Explorer::getDimensionLabel($dim_names[1][0], $k1) : "SPAN", $level2_first ? PAG_Explorer::getDimensionLabel($dim_names[1][1], $k2) : "SPAN", PAG_Explorer::getDimensionLabel($dim_names[1][2], $k3));
                 $line_href = array('', '', '');
                 $level1_first = false;
                 $level2_first = false;
                 foreach (PAG_Explorer::groupBy($dim_names[0][0], $items3, null, true) as $k4 => $items4) {
                     if (createHeader) {
                         array_push($header_values[0], PAG_Explorer::getDimensionLabel($dim_names[0][0], $k4));
                         //  (($dim_names[0][0]=="none") || ($dim_names[0][0]==null)) ? "" : $k4);
                         $count_k4 = 0;
                     }
                     foreach (PAG_Explorer::groupBy($dim_names[0][1], $items4, $k4, true) as $k5 => $items5) {
                         if (createHeader) {
                             array_push($header_values[1], PAG_Explorer::getDimensionLabel($dim_names[0][1], $k5));
                             //  (($dim_names[0][1]=="none") || ($dim_names[0][1]==null)) ? "" : $k5);
                             $count_k5 = 0;
                         }
                         foreach (PAG_Explorer::groupBy($dim_names[0][2], $items5, $k5, true) as $k6 => $items6) {
                             $res[$k1][$k2][$k3][$k4][$k5][$k6] = $items6;
                             $href = '';
                             foreach ($items6 as $i) {
                                 $href .= $href == "" ? $i->id : "," . $i->id;
                             }
                             array_push($line, count($items6));
                             array_push($line_href, $href);
                             if (createHeader) {
                                 array_push($header_values[2], PAG_Explorer::getDimensionLabel($dim_names[0][2], $k6));
                                 //  (($dim_names[0][2]=="none") || ($dim_names[0][2]==null)) ? "" : $k6);
                                 array_push($header_sizes[2], 1);
                                 $count_k4++;
                                 $count_k5++;
                             }
                         }
                         if (createHeader) {
                             array_push($header_sizes[1], $count_k5);
                         }
                     }
                     if (createHeader) {
                         array_push($header_sizes[0], $count_k4);
                     }
                 }
                 $createHeader = false;
                 array_push($lines, $line);
                 array_push($lines_href, $line_href);
             }
             array_push($row_span[1], $level2_span);
         }
         array_push($row_span[0], $level1_span);
     }
     // no nested arrays for javascript --> expand to header1, header2 etc.
     wp_send_json(array('header_values_0' => $header_values[0], 'header_values_1' => $header_values[1], 'header_values_2' => $header_values[2], 'header_sizes_0' => $header_sizes[0], 'header_sizes_1' => $header_sizes[1], 'header_sizes_2' => $header_sizes[2], 'row_span_0' => $row_span[0], 'row_span_1' => $row_span[1], 'noOfDimY' => $noOfDimY, 'lines' => $lines, 'lines_href' => $lines_href));
 }
示例#3
0
 public static function createPage()
 {
     $items = PAG_Basket::loadAllItemsFromBasket();
     $html = sprintf("<form  enctype='multipart/form-data' action='admin.php?page=generator' method='post'><table class='form-table'><tbody'>");
     $html .= sprintf("<tr><th style='padding-top:0px; padding-bottom:0px;'><label>%s</label></th>", "Number of Items");
     $html .= PAG_Generator::minMaxField("number", count($items));
     $html .= sprintf("</tr>");
     $html .= sprintf("<tr><td style='vertical-align:top; padding-top:0px; padding-bottom:0px;'><label>%s</label></td>", "Overlap");
     $html .= PAG_Generator::minMaxField("overlap", count($items));
     $html .= sprintf("</tr>");
     $html .= sprintf("<tr><td style='vertical-align:top; padding-top:0px; padding-bottom:0px;'><button type='button' onclick='\r\n\t\t\t\t\r\n\t\t\t\tif (this.innerText == \"Select ...\") {\r\n\t\t\t\t\tthis.innerText = \"Close\";\r\n\t\t\t\t\tthis.parentNode.nextSibling.firstChild.style.display=\"block\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.innerText = \"Select ...\";\r\n\t\t\t\t\tthis.parentNode.nextSibling.firstChild.style.display=\"none\";\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t'>Select ...</button></td>");
     $html .= "<td><div style='display:none'>";
     foreach ($items as $i) {
         $html .= sprintf("<input type='checkbox' name='overlap_items[]' value='%d'><label style='vertical-align:top'>%s</label><br/>", $i->id, $i->title);
     }
     $html .= sprintf("</div></td></tr>");
     // Min / Max for all categories
     $categories = array("type", "dim", "level", "topic1");
     foreach ($categories as $category) {
         $html .= 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 .= 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 .= PAG_Generator::minMaxField($category . "_" . $catval, count($catitems));
             $html .= sprintf("</tr>");
         }
     }
     $html .= sprintf("<tr><th><button type='submit' name='action' value='generate'>Generate</button></th><tr>");
     $html .= sprintf("</tbody></table></form></div>");
     // (re-)generate pools
     if ($_REQUEST['action'] == 'generate') {
         $pool = new PAG_Generator($items, array($_SESSION['min_number'], $_SESSION['min_type_itemsc'], $_SESSION['min_type_itemmc'], $_SESSION['min_dim_FW'], $_SESSION['min_dim_KW'], $_SESSION['min_dim_PW'], $_SESSION['min_level_1'], $_SESSION['min_level_2'], $_SESSION['min_level_3'], $_SESSION['min_level_4'], $_SESSION['min_level_5'], $_SESSION['min_level_6']), array($_SESSION['max_number'], $_SESSION['max_type_itemsc'], $_SESSION['max_type_itemmc'], $_SESSION['max_dim_FW'], $_SESSION['max_dim_KW'], $_SESSION['max_dim_PW'], $_SESSION['max_level_1'], $_SESSION['max_level_2'], $_SESSION['max_level_3'], $_SESSION['max_level_4'], $_SESSION['max_level_5'], $_SESSION['max_level_6']), array($_SESSION['min_overlap'], $_SESSION['max_overlap']));
         $_SESSION['generated_pools'] = $pool->generatedPools;
     }
     print "<div class='wrap'>";
     print "<h1>Task Pool Generator</h1><br/>";
     print $html;
     // show pools (from last generation; stored in Session variable)
     if (isset($_SESSION['generated_pools'])) {
         // 			print_r ($_SESSION['generated_pools']);
         print "<br/><h2>Generated Task Pools</h2>";
         printf("<table cellpadding='10px' class='widefat fixed' style='table-layout:fixed; width:%dem; background-color:rgba(0, 0, 0, 0);'>", 6 + 2 * count($items));
         print "<col width='6em;' />";
         foreach ($items as $item) {
             print "<col width='2em;' />";
         }
         foreach ($_SESSION['generated_pools'] as $pool) {
             print "<tr valign='middle'>";
             $s = "View";
             $href = "admin.php?page=view&itemids=" . join(",", $pool);
             printf("<td style='overflow: hidden; padding:0px; padding-bottom:0.5em; padding-top:0.5em; padding-left:1em' ><a href='%s' class='button'>View</a></td>", $href);
             // http://localhost/wordpress/wp-admin/admin.php?page=view&itemids=458,307,307,106
             foreach ($items as $item) {
                 $symbol = "";
                 $link = "";
                 if (in_array($item->id, $pool)) {
                     $link = sprintf("onClick='document.location.href=\"admin.php?page=view&itemid=%s\";'", $item->id);
                     if ($item->type == "itemsc") {
                         $symbol = "<span class='dashicons dashicons-marker'></span>";
                     }
                     if ($item->type == "itemmc") {
                         $symbol = "<span class='dashicons dashicons-forms'></span>";
                     }
                 }
                 printf("<td %s valign='bottom' style='overflow: hidden; padding:0px; padding-top:0.83em;' >%s</td>", $link, $symbol);
             }
             print "</tr>";
         }
         print "</table>";
     }
 }