Exemple #1
0
 public function matrixnavigation_action()
 {
     $tag_matrix_entries_number = 9;
     $tag_subtags_number = 6;
     if (!Request::get("tags")) {
         $this->topics = LernmarktplatzTag::findBest($tag_matrix_entries_number);
         $this->materialien = array();
     } else {
         $tags = $this->tag_history = explode(",", Request::get("tags"));
         $this->without_tags = array();
         $tag_to_search_for = array_pop($tags);
         foreach (LernmarktplatzTag::findBest($tag_matrix_entries_number, true) as $related_tag) {
             if ($related_tag['tag_hash'] !== $this->tag_history[0]) {
                 $this->without_tags[] = $related_tag['tag_hash'];
             }
         }
         //array_shift($this->tag_history);
         foreach ($tags as $tag) {
             foreach (LernmarktplatzTag::findRelated($tag, $this->without_tags, $tag_subtags_number, true) as $related_tag) {
                 $this->without_tags[] = $related_tag['tag_hash'];
             }
         }
         $this->topics = LernmarktplatzTag::findRelated($tag_to_search_for, $this->without_tags, $tag_subtags_number);
         $this->materialien = LernmarktplatzMaterial::findByTagHash($tag_to_search_for);
     }
     $output = array();
     $output['breadcrumb'] = $this->render_template_as_string("market/_breadcrumb");
     $output['matrix'] = $this->render_template_as_string("market/_matrix");
     $output['materials'] = $this->render_template_as_string("market/_materials");
     $this->render_json($output);
 }
 public function addTag($tag_name)
 {
     $tag_hash = md5($tag_name);
     if (!LernmarktplatzTag::find($tag_hash)) {
         $tag = new LernmarktplatzTag();
         $tag->setId($tag_hash);
         $tag['name'] = $tag_name;
         $tag->store();
     }
     $statement = DBManager::get()->prepare("\n            INSERT IGNORE INTO lernmarktplatz_tags_material\n            SET tag_hash = :tag_hash,\n                material_id = :material_id\n        ");
     return $statement->execute(array('tag_hash' => $tag_hash, 'material_id' => $this->getId()));
 }
?>
>
    <? $breadcrump_tags = array() ?>
    <li>
        <a href="<?php 
echo PluginEngine::getLink($plugin, array(), "market/overview");
?>
" data-tags="">
            <?php 
echo _("Zum Anfang");
?>
        </a>
    </li>
    <? foreach ($tag_history as $key => $tag) : ?>
        <li>
            <? $breadcrump_tags[] = $tag ?>
            <? $new_tag_history = implode(",", $breadcrump_tags) ?>
            <a href="<?php 
echo PluginEngine::getLink($plugin, array('tags' => $new_tag_history), "market/overview");
?>
"  data-tags="<?php 
echo $new_tag_history;
?>
">
                <?php 
echo htmlReady(LernmarktplatzTag::find($tag)->name);
?>
            </a>
        </li>
    <? endforeach ?>
</ol>