Ejemplo n.º 1
0
 public function overview_action()
 {
     if (Navigation::hasItem("/lernmarktplatz/overview")) {
         Navigation::activateItem("/lernmarktplatz/overview");
     }
     $tag_matrix_entries_number = 9;
     $tag_subtags_number = 6;
     if (Request::get("disable_maininfo")) {
         UserConfig::get($GLOBALS['user']->id)->store("LERNMARKTPLATZ_DISABLE_MAININFO", 1);
         $this->redirect("market/overview");
     }
     if (Request::get("tags")) {
         $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->more_tags = LernmarktplatzTag::findRelated($tag_to_search_for, $this->without_tags, $tag_subtags_number);
         $this->materialien = LernmarktplatzMaterial::findByTagHash($tag_to_search_for);
     } elseif (Request::get("search")) {
         $this->materialien = LernmarktplatzMaterial::findByText(Request::get("search"));
     } elseif (Request::get("tag")) {
         $this->materialien = LernmarktplatzMaterial::findByTag(Request::get("tag"));
     } else {
         $this->best_nine_tags = LernmarktplatzTag::findBest($tag_matrix_entries_number);
     }
 }
Ejemplo n.º 2
0
 public function search_items_action()
 {
     $host = LernmarktplatzHost::thisOne();
     if (Request::get("text")) {
         $this->materialien = LernmarktplatzMaterial::findByText(studip_utf8decode(Request::get("text")));
     } elseif (Request::get("tag")) {
         $this->materialien = LernmarktplatzMaterial::findByTag(studip_utf8decode(Request::get("tag")));
     }
     $output = array('results' => array());
     foreach ($this->materialien as $material) {
         $data = array();
         $data['host'] = array('name' => $material->host ? $material->host['name'] : $host['name'], 'url' => $material->host ? $material->host['url'] : $host['url'], 'public_key' => $material->host ? $material->host['public_key'] : $host['public_key']);
         $data['data'] = $material->toArray();
         unset($data['data']['material_id']);
         if ($material->host) {
             $foreign_user = LernmarktplatzUser::find($material['user_id']);
             $data['user'] = array('user_id' => $foreign_user ? $foreign_user->foreign_user_id : "unbekannt", 'name' => $foreign_user ? $foreign_user->name : "unbekannt", 'avatar' => $foreign_user ? $foreign_user->avatar : null);
         } else {
             $data['user'] = array('user_id' => $material->host ? LernmarktplatzUser::find($material['user_id'])->foreign_user_id : $material['user_id'], 'name' => get_fullname($material['user_id']), 'avatar' => Avatar::getAvatar($material['user_id'])->getURL(Avatar::NORMAL));
         }
         $data['topics'] = array();
         foreach ($material->getTopics() as $topic) {
             $data['topics'][] = $topic['name'];
         }
         $output['results'][] = $data;
     }
     $this->render_json($output);
 }