public static function save($post_id, $post)
 {
     global $wpdb;
     $item = new EAL_LearnOut();
     $item->init($post_id, $post);
     $wpdb->replace("{$wpdb->prefix}eal_{$item->type}", array('id' => $item->id, 'title' => $item->title, 'description' => $item->description, 'level_FW' => $item->level["FW"], 'level_KW' => $item->level["KW"], 'level_PW' => $item->level["PW"], 'domain' => $item->domain), array('%d', '%s', '%s', '%d', '%d', '%d', '%s'));
 }
    public function WPCB_register_meta_box_cb()
    {
        global $learnout;
        $learnout = new EAL_LearnOut();
        $learnout->load();
        $domain = RoleTaxonomy::getCurrentRoleDomain();
        if ($domain["name"] != "" && $learnout->domain != $domain["name"]) {
            wp_die("Learning outcome  does not belong to your current domain!");
        }
        global $post;
        ?>
  <style> #minor-publishing { display: none; } </style> <?php 
        add_meta_box('mb_description', 'Beschreibung', array($this, 'WPCB_mb_editor'), $this->type, 'normal', 'default', array('name' => 'learnout_description', 'value' => $learnout->description));
        add_meta_box('mb_item_level', 'Anforderungsstufe', array($this, 'WPCB_mb_level'), $this->type, 'side', 'default', array('level' => $learnout->level, 'prefix' => 'learnout'));
        add_meta_box('mb_item_taxonomy', RoleTaxonomy::getDomains()[$learnout->domain], array($this, 'WPCB_mb_taxonomy'), $this->type, 'side', 'default', array("taxonomy" => $learnout->domain));
        // term selections --> show buttons for text modules
        ?>
<script>

	function showTermButtons (j) {
		j("#eal_topicterms").empty()		
		// search all checked terms incl. their ancestors
		j("#topic-all").find ("input[type='checkbox']").filter(":checked").parentsUntil(j( "#topic-all" )).filter ("li").children("label").each (function (i, e) {
			// add term button
			j("#eal_topicterms").append ("<a style='margin:3px' class='button' onclick=\"addTermToEditor('" + e.childNodes[1].textContent + "');\">" + e.childNodes[1].textContent + "</a>");
		})
	}
		
	function codeAddress() {
	
		var j = jQuery.noConflict();
		showTermButtons(j)	
	
		// add "on change" handler to all terms (input-checkbox); both in tab "All" as well "Must used"
		j("#topic-all").add(j("#topic-pop")).change(function() { showTermButtons (j); });
	}
	
	window.onload = codeAddress;
</script>
<?php 
    }
Beispiel #3
0
    public static function getHTML_Metadata(EAL_Item $item, $editable, $namePrefix)
    {
        // Status and Id
        $res = sprintf("<div>%s (%d)</div><br/>", $item->getStatusString(), $item->id);
        // Learning Outcome (Title + Description), if available
        $learnout = $item->getLearnOut();
        if ($editable) {
            $res .= sprintf("<div>%s</div>", EAL_LearnOut::getListOfLearningOutcomes($learnout == null ? 0 : $learnout->id, $namePrefix));
        } else {
            if (!is_null($learnout)) {
                $res .= sprintf("<div><b>%s</b>: %s</div><br/>", $learnout->title, $learnout->description);
            }
        }
        // Level-Table
        $res .= sprintf("<div>%s</div><br/>", CPT_Object::getLevelHTML($namePrefix, $item->level, is_null($learnout) ? null : $learnout->level, $editable ? "" : "disabled", 1, ''));
        // Taxonomy Terms: Name of Taxonomy and list of terms (if available)
        $res .= sprintf("<div><b>%s</b>:", RoleTaxonomy::getDomains()[$item->domain]);
        if ($editable) {
            $res .= sprintf('
				<div class="inside">
					<div class="categorydiv">
						<div id="topic-all" class="tabs-panel"><input type="hidden" name="%1$s_taxonomy[]" value="0">
							<ul id="topicchecklist" data-wp-lists="list:topic" class="categorychecklist form-no-clear">
							%2$s
							</ul>
						</div>
					</div>
				</div>', $namePrefix, CPT_Item::getHTML_TopicHierarchy($namePrefix, get_terms(array('taxonomy' => $item->domain, 'hide_empty' => false)), 0, wp_get_post_terms($item->id, $item->domain, array("fields" => "ids"))));
        } else {
            $terms = wp_get_post_terms($item->id, $item->domain, array("fields" => "names"));
            if (count($terms) > 0) {
                $res .= sprintf("<div style='margin-left:1em'>");
                foreach ($terms as $t) {
                    $res .= sprintf("%s</br>", $t);
                }
                $res .= sprintf("</div>");
            }
        }
        $res .= sprintf("</div>");
        return $res;
    }