Hallöchen,
Ich habe durch mein Fernstudium eine kleine Aufgabe bekommen...wo ich nicht mehr durchblicke und schier am verzweifeln bin... oder sonst wo im web etwas dazu finde...
Es dreht sich hierbei um eine YAML datei die im HTML als Bookmark mit Tabellen aufgeführt ausgegeben werden soll... dazu eine Tagcloud mit den 50 Häufigsten Tags... alles kein problem.. aber jetzt soll ich ein Formular schreiben was beim Eingeben eines Keywords auch nur die Bookmarks anzeigt was dieses Keyword besitzen...
vielleicht kann mir jemand erklären was ich die ganze zeit falsch mache :/
HTML AUSGABE :
PHP CODE....
danke im vorraus...
Spank
Ich habe durch mein Fernstudium eine kleine Aufgabe bekommen...wo ich nicht mehr durchblicke und schier am verzweifeln bin... oder sonst wo im web etwas dazu finde...
Es dreht sich hierbei um eine YAML datei die im HTML als Bookmark mit Tabellen aufgeführt ausgegeben werden soll... dazu eine Tagcloud mit den 50 Häufigsten Tags... alles kein problem.. aber jetzt soll ich ein Formular schreiben was beim Eingeben eines Keywords auch nur die Bookmarks anzeigt was dieses Keyword besitzen...
vielleicht kann mir jemand erklären was ich die ganze zeit falsch mache :/
HTML AUSGABE :
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Bookmarkliste</title> <style type="text/css"> .block { border:thick; border-color:#000; margin-left:auto; margin-right:auto; padding: 10px; word-spacing:10px; height:265px; width:400px; } </style> </head> <body> <div align="center"> <form method="POST" action="index.php"> <input type="text" name="tagsuche" value="###TAGSEARCH###"> <input type="submit" name="submit" value="Tag Suchen"> <input type="hidden" name="sent" value="1"> </form> </div> <hr> <div align="center"> <h1> Bookmarkliste von Michael Ibsen </h1> </div> <div class="bookmark"> <table class="bookmark" border="1"> ###BOOKMARKS### </table> </div> </body> </html>
PHP-Code:
<?php
################################################
########### Parser für die Bookmarkliste #############
################################################
require_once 'spyc.php';
/**
* eine Yaml datei in das Skript laden
*
*/
$strBookmarks = '';
$arrBookmarks = Spyc::YAMLLoad('bookmarks.yml');
$strTemplate = file_get_contents('template.html');
$strBookmarkEntryTemplate = file_get_contents('bookmarkentry.html');
foreach ($arrBookmarks['bookmarks'] as $arrBookmark) {
$strBookmarkEntry = $strBookmarkEntryTemplate;
if (!isset($arrBookmark['title'])) {
$arrBookmark['title'] = 'Ohne Titel';
}
if (!isset($arrBookmark['desc'])) {
$arrBookmark['desc'] = 'Ohne Beschreibung';
}
if (!isset($arrBookmark['keywords'])) {
$arrBookmark['keywords'] = '';
}
$strBookmarkEntry = str_replace ('###TITLE###', $arrBookmark['title'], $strBookmarkEntry);
$strBookmarkEntry = str_replace ('###IMAGE###', '...', $strBookmarkEntry);
$strBookmarkEntry = str_replace ('###DESC###', $arrBookmark['desc'], $strBookmarkEntry);
$strBookmarkEntry = str_replace ('###KEYWORD###', $arrBookmark['keywords'], $strBookmarkEntry);
//Datumsauslese, wenn kein Datum vorhanden ist gibt er Nichts aus.
if (!isset($arrBookmark['date'])) {
$strBookmarkEntry = str_replace ('###DATE###', '', $strBookmarkEntry);
} else {
$strBookmarkEntry = str_replace ('###DATE###', $arrBookmark['date'], $strBookmarkEntry);
}
// Auslesen der einzelnen URL
if (isset($arrBookmark['url'])) {
$strBookmarkEntry = str_replace ('###URL###', $arrBookmark['url'], $strBookmarkEntry);
//Auslesen und Aufreihen mehrerer URLs
} else if (isset($arrBookmark['urls'])) {
$strURLS = '';
foreach ($arrBookmark['urls'] as $strURL) {
$strURLS .= $strURL . '<br />';
}
$strBookmarkEntry = str_replace ('###URL###', $strURLS, $strBookmarkEntry);
}
$strBookmarks .= $strBookmarkEntry;
}
$strTemplate = str_replace ('###BOOKMARKS###', $strBookmarks, $strTemplate);
print $strTemplate;
// Keywords und deren Häufigkeit auslesen
$arrKeywordCollection = array();
foreach ($arrBookmarks['bookmarks'] as $arrBookmark) {
if (isset($arrBookmark['keywords'])) {
$arrKeywords = explode(',', $arrBookmark['keywords']);
foreach ($arrKeywords as $strKeyword) {
$strKeyword = trim($strKeyword);
if (isset($arrKeywordCollection [$strKeyword])) {
$arrKeywordCollection[$strKeyword]++;
}
else {
$arrKeywordCollection[$strKeyword] = 1;
}
}
}
}
################################################
################## TAGCLOUD ####################
################################################
function printTagCloud($arrTags) {
// $arrTags is the array
$max_size = 30; // Maximale Schriftgröße in px
$min_size = 15; // Minimale Schriftgröße in p
// lgrößte und kleinste Anzahl im Array
$max_qty = max(array_values($arrTags));
$min_qty = min(array_values($arrTags));
// fden durchschnitt der größen im Array finden
$spread = $max_qty - $min_qty;
if ($spread == 0) {
$spread = 1;
}
// die fortlaufende Schriftgröße einstellen
$step = ($max_size - $min_size) / ($spread);
foreach ($arrTags as $strKeyword => $value) {
$size = round($min_size + (($value - $min_qty) * $step));
print '<a href="#" style="font-size: ' . $size . 'px" title="' . $value . ' things tagged with ' . $strKeyword . '">' . $strKeyword . '</a> ';
}
}
$arrTags = array('"action:calculate"' => 1, '"action:create"' => 1, '"action:draw"' => 3, '"action:parse"' => 1, '"action:scribble"' => 3, '"action:select"' => 1, '"lang:javascript"' => 5, 'AJAX' => 3, 'Adressen' => 1, 'Anwendungsentwicklung' => 1, 'Apache' => 1, 'Backup' => 1, 'Bahnhof' => 3, 'Benutzer' => 1, 'Berlin' => 1, 'Betriebswirtschaft' => 1, 'Bilder' => 1, 'Blogger und Journalisten' => 1, 'Buch' => 1, 'Bugbase' => 1, 'Bus' => 1, 'Bürowirtschaft' => 1, 'CBIR' => 1, 'CMS' => 1, 'CMYK' => 1, 'CSS' => 2, 'Certificate' => 1, 'Code' => 1, 'Compact Policy' => 1, 'Content Based Image Recognition' => 1, 'Darmstadt' => 1, 'Data Security' => 1, 'Datenschutz' => 2, 'Datenschutzrichtlinie' => 1, 'EMail' => 1, 'EPA' => 1, 'Einrichtung' => 1, 'Elben' => 1, 'Embedded' => 1, 'Exchange' => 1, 'ExtJS' => 1, 'Farbe' => 1, 'Farbraum' => 1, 'Flash' => 1, 'Font' => 1, 'Forensik' => 1, 'Foto' => 1, 'Framework' => 1, 'Frankreich' => 1, 'Geisterbahnhof' => 1, 'Geschichte' => 2, 'Google' => 2, 'History' => 2, 'Image' => 2, 'Industriebetriebslehre' => 1, 'Informationswirtschaft' => 1, 'Internet Explorer' => 3, 'JavaScript' => 4, 'Javascript' => 1, 'Kalender' => 1, 'Karte' => 1, 'Keylogger' => 1, 'Kompatibilitätsmodus' => 1, 'Kontakte' => 1, 'Lernen' => 1, 'Linux' => 2, 'MSIE' => 3, 'Macro' => 1, 'Mail' => 1, 'Mathematik' => 1, 'Maus' => 1, 'Methoden und Verfahren' => 1, 'Microsoft' => 3, 'N97' => 1, 'Nokia' => 1, 'Outddor' => 1, 'Outlook' => 1, 'P3P' => 2, 'PHP' => 2, 'PHP action:click' => 1, 'PIM' => 1, 'PNG' => 2, 'Palm' => 1, 'Policy' => 1, 'Polygon' => 1, 'Polyline' => 1, 'Praktische Philosophie' => 1, 'RGB' => 1, 'RTE' => 1, 'Ration' => 1, 'Rechnungswesen' => 1, 'Rechte' => 1, 'Richtexteditor' => 1, 'Roboter' => 1, 'Ruby' => 1, 'Rucksack' => 1, 'S-Bahn' => 2, 'SEO' => 1, 'SQLite' => 1, 'SSH' => 1, 'SSL' => 1, 'Schrift' => 1, 'Security' => 2, 'Server' => 1, 'Shop' => 1, 'Shorts' => 1, 'Spanien' => 1, 'Suchmaschinenoptimierung' => 1, 'Survival' => 1, 'T-Shirt' => 1, 'TIZ' => 1, 'Tastatur' => 1, 'Termine' => 1, 'Textverarbeitung' => 1, 'Tipps' => 1, 'Tolkien' => 1, 'Tube' => 1, 'Tungsten' => 1, 'Typo3' => 3, 'U-Bahn' => 5, 'U-Bahnstationen' => 1, 'UML' => 7, 'University of Berkeley' => 1, 'Version 4.x' => 1, 'Videos' => 1, 'Volkswirtschaft' => 1, 'Vorrat' => 1, 'Wiki' => 1, 'Windows' => 2, 'Windows mobile' => 1, 'Wordpress' => 1, 'Zertifikat' => 1, 'abdruck' => 1, 'access time' => 1, 'accessibility' => 1, 'action:advertise' => 1, 'action:automate' => 1, 'action:clean' => 2, 'action:click' => 1, 'action:collect' => 1, 'action:combine' => 1, 'action:compile' => 1, 'action:configure' => 4, 'action:control' => 1, 'action:convert' => 8, 'action:count' => 2, 'action:create' => 9, 'action:develop' => 8, 'action:draw' => 2, 'action:edit' => 3, 'action:embed' => 1, 'action:format' => 1, 'action:generate' => 1, 'action:implement' => 1, 'action:install' => 1, 'action:invent' => 1, 'action:learn' => 2, 'action:manage' => 1, 'action:optimize' => 1, 'action:organize' => 2, 'action:plan' => 5, 'action:protect' => 1, 'action:read' => 1, 'action:record' => 1, 'action:resize' => 1, 'action:search' => 1, 'action:sing' => 1, 'action:sync' => 2, 'action:talk' => 2, 'action:test' => 2, 'action:think' => 2, 'action:view' => 1, 'action:visualise' => 1, 'action:work' => 1, 'ad' => 1, 'adobe' => 1, 'adressen' => 1, 'ads' => 1, 'adventure' => 1, 'agenten' => 1, 'ai' => 1, 'ajax' => 3, 'alternative datenströme' => 1, 'analysis' => 1, 'apache' => 3, 'ascii' => 1, 'atime' => 1, 'audio' => 2, 'barchart' => 1, 'barrierefreiheit' => 1, 'bewerbung' => 1, 'bilder' => 2, 'bin' => 1, 'blaue_moewe' => 1, 'book' => 2, 'books' => 1, 'bot' => 1, 'bronze' => 1, 'bronzegiessen' => 1, 'browser' => 3, 'buildingbase' => 1, 'cachewolf' => 2, 'cakePHP' => 1, 'ccc' => 1, 'ce' => 1, 'celtic' => 1, 'char' => 2, 'character' => 2, 'characterset' => 1, 'charset' => 1, 'cheatsheet' => 3, 'city:Berlin' => 4, 'city:London' => 1, 'city:koblenz' => 1, 'cleaner' => 2, 'clickable_imagemap' => 1, 'clustering' => 1, 'code' => 1, 'cognition' => 1, 'color' => 1, 'company:cisco' => 1, 'company:google' => 1, 'company:iriver' => 2, 'company:microsoft' => 1, 'company:nusphere' => 1, 'company:teambits' => 1, 'compatMode' => 1, 'compile' => 1, 'cookies' => 1, 'coordinates' => 2, 'coords' => 1, 'country:ddr' => 1, 'country:deutschland' => 1, 'crawler' => 1, 'cross_site_scripting' => 1, 'crowd' => 1, 'crowdsourcing' => 1, 'css' => 10, 'database' => 1, 'datebook.dat' => 1, 'datenbank' => 2, 'datenschutz' => 1, 'design' => 6, 'deutschland' => 2, 'development' => 1, 'dez' => 1, 'diaschau' => 1, 'dictionary' => 1, 'die_aerzte' => 1, 'die_streuner' => 1, 'disclaimer' => 1, 'doctype' => 1, 'documentMode' => 1, 'download' => 1, 'ebook' => 4, 'ecology' => 1, 'editor' => 3, 'embed' => 1, 'emission' => 1, 'english' => 2, 'entities' => 1, 'epub' => 3, 'erd' => 1, 'event' => 1, 'example' => 3, 'excel' => 1, 'exchange' => 1, 'extjs' => 2, 'feature maps' => 1, 'fernsehen' => 1, 'film' => 1, 'firefox' => 1, 'flash' => 2, 'font' => 1, 'form' => 2, 'format:markdown' => 1, 'formular' => 2, 'framework' => 1, 'free' => 4, 'freelancer' => 1, 'game' => 1, 'gauss' => 1, 'geheim' => 1, 'geo' => 8, 'gettext' => 1, 'gimmicks' => 1, 'glaube' => 1, 'google' => 6, 'google_map' => 3, 'google_maps' => 4, 'gopal' => 2, 'gpl' => 1, 'gps' => 2, 'grafik' => 1, 'graph' => 1, 'gutes_design' => 2, 'hack' => 2, 'handy' => 1, 'hardware:iriver_story' => 2, 'heatmap' => 2, 'herr_der_ringe' => 1, 'hessen' => 1, 'hex' => 1, 'hitchhiker' => 1, 'hlz' => 1, 'htaccess' => 3, 'html' => 12, 'i18n' => 1, 'idea' => 1, 'image' => 4, 'impressum' => 2, 'imprint' => 2, 'informatik' => 1, 'internet' => 2, 'internet explorer' => 2, 'internetrecht' => 1, 'inventor' => 1, 'iriver' => 1, 'jQuery' => 2, 'javascript' => 5, 'jenny' => 2, 'job' => 1, 'jobs' => 1, 'jpg' => 1, 'jquery' => 3, 'json' => 1, 'kalender' => 1, 'kaufen' => 1, 'ki' => 1, 'kinder' => 1, 'kohonen' => 1, 'kontakte' => 1, 'koordinaten' => 4, 'l10n' => 1, 'landesregierung' => 1, 'lang:javascript' => 4, 'lang:latein' => 1, 'lang:php' => 5, 'layout' => 1, 'lego' => 1, 'lernen' => 1, 'lgs' => 1, 'license' => 1, 'lineare_gleichung' => 1, 'linux' => 1, 'listener' => 1, 'lizenz' => 1, 'local' => 1, 'lokalisten' => 1, 'mail' => 2, 'mannheim' => 1, 'map' => 11, 'markdown' => 1, 'marker' => 1, 'markup' => 1, 'mathe' => 1, 'mathematik' => 1, 'meinvz' => 1, 'memex' => 1, 'memox' => 1, 'menu' => 1, 'menü' => 1, 'methode' => 1, 'microsoft' => 1, 'mistudy' => 2, 'mitarbeiter' => 1, 'mittelalter' => 1, 'mod_rewrite' => 3, 'model' => 5, 'modification time' => 1, 'movie' => 1, 'mp3' => 2, 'msie' => 2, 'music' => 1, 'musik' => 2, 'mysql' => 2, 'navi' => 6, 'netzwerkbetriebssystem' => 2, 'neural networks' => 1, 'ntfs' => 1, 'oct' => 1, 'odt' => 2, 'office' => 1, 'online' => 2, 'ontology' => 1, 'oo' => 3, 'open' => 1, 'openoffice' => 2, 'opensource' => 1, 'organisation:kgb' => 1, 'ortssuche' => 1, 'oswd' => 2, 'outlook' => 2, 'outsourcing' => 1, 'owl' => 1, 'p3p' => 1, 'password' => 1, 'passwort' => 1, 'pda' => 3, 'person:HeikeHofmann' => 1, 'person:bill_clinton' => 1, 'person:douglas_adams' => 1, 'person:edwards_demming' => 1, 'person:hilary_duff' => 1, 'person:joel_spolsky' => 1, 'person:licklider' => 1, 'person:person_kutz' => 1, 'person:peter_tandler' => 1, 'person:peter_zoeller-greer' => 4, 'person:roland_koch' => 1, 'person:siebel' => 2, 'php' => 5, 'phped' => 1, 'pioneer' => 1, 'pna' => 2, 'podcast' => 1, 'poi' => 5, 'polygon' => 3, 'praktikanten' => 1, 'praktikum' => 1, 'privacy' => 1, 'problem' => 1, 'programmierer' => 2, 'programming' => 3, 'recht' => 3, 'reference' => 1, 'referenz' => 1, 'regionen' => 1, 'rewritecond' => 3, 'rewriterule' => 3, 'robotics' => 2, 'rules' => 1, 'safemode' => 1, 'schrift' => 1, 'schriftart' => 1, 'schuelervz' => 1, 'schule' => 1, 'security' => 5, 'selectbox' => 1, 'semantic' => 2, 'semantic_web' => 1, 'semaphor' => 1, 'seo' => 4, 'sequence_diagram' => 1, 'shop' => 1, 'sicherheit' => 1, 'silikon' => 1, 'sinji_galeb' => 1, 'sitemap' => 1, 'slideshow' => 1, 'social' => 1, 'social_media' => 1, 'software' => 2, 'software_engineering' => 1, 'softwareengineering' => 2, 'song' => 1, 'sound' => 1, 'source' => 1, 'spam' => 1, 'sprache' => 1, 'spuren' => 2, 'stadtentwicklung' => 1, 'standard' => 1, 'steampunk' => 1, 'stellen' => 1, 'story' => 1, 'studivz' => 1, 'swf' => 1, 'synchronisation' => 1, 'tabs' => 1, 'template' => 3, 'termine' => 1, 'text' => 1, 'thaought' => 1, 'thesaurus' => 1, 'thumbnail' => 1, 'thunderbird' => 1, 'tiki' => 1, 'tipps' => 2, 'tool' => 3, 'transonic' => 2, 'transparenz' => 2, 'tricks' => 1, 'troubleshooting' => 1, 'ttf' => 1, 'tutorial' => 3, 'typo3' => 3, 'urheberrecht' => 2, 'usability' => 1, 'video' => 3, 'virtual_pages' => 1, 'w3c' => 2, 'web' => 3, 'web3.0' => 1, 'webdesign' => 12, 'webshop' => 1, 'website' => 3, 'wer-kennt-wen' => 1, 'werbung' => 1, 'werkburg' => 1, 'windows' => 1, 'wireframe' => 3, 'wissen' => 1, 'wissenmanagement' => 1, 'word' => 1, 'worker' => 1, 'www' => 2, 'xing' => 1, 'xss' => 1, 'yaml' => 1, 'zahlensender' => 1, 'zeichen' => 1, 'zitat' => 1, 'Überleben' => 1);
//Sortieren der Häufigkeit und deren löschen aus den
//Arrays,dann Anzeige der 50 häufigsten Tags
arsort($arrTags);
$arrMostFrequentTags = array_slice($arrTags, 0, 50);
ksort($arrMostFrequentTags);
print '<div class="block">';
printTagCloud($arrMostFrequentTags);
print '</div>';
################################################
################## TAGSEARCH ###################
################################################
if (isset($_REQUEST['sent'])) {
$strFormular = str_replace ('###TAGSEARCH###', $_REQUEST['tagsuche'], $strFormular);
foreach ($arrBookmarks['bookmarks'] as $arrBookmark) {
$strBookmarkEntry = $strBookmarkEntryTemplate;
if (!isset($arrBookmark['title'])) {
$arrBookmark['title'] = 'Ohne Titel';
}
if (!isset($arrBookmark['desc'])) {
$arrBookmark['desc'] = 'Ohne Beschreibung';
}
if (!isset($arrBookmark['keywords'])) {
$arrBookmark['keywords'] = '';
}
$strBookmarkEntry = str_replace ('###TITLE###', $arrBookmark['title'], $strBookmarkEntry);
$strBookmarkEntry = str_replace ('###IMAGE###', '...', $strBookmarkEntry);
$strBookmarkEntry = str_replace ('###DESC###', $arrBookmark['desc'], $strBookmarkEntry);
$strBookmarkEntry = str_replace ('###KEYWORD###', $arrBookmark['keywords'], $strBookmarkEntry);
//Datumsauslese, wenn kein Datum vorhanden ist gibt er Nichts aus.
if (!isset($arrBookmark['date'])) {
$strBookmarkEntry = str_replace ('###DATE###', '', $strBookmarkEntry);
} else {
$strBookmarkEntry = str_replace ('###DATE###', $arrBookmark['date'], $strBookmarkEntry);
}
// Auslesen der einzelnen URL
if (isset($arrBookmark['url'])) {
$strBookmarkEntry = str_replace ('###URL###', $arrBookmark['url'], $strBookmarkEntry);
//Auslesen und Aufreihen mehrerer URLs
} else if (isset($arrBookmark['urls'])) {
$strURLS = '';
foreach ($arrBookmark['urls'] as $strURL) {
$strURLS .= $strURL . '<br />';
}
$strBookmarkEntry = str_replace ('###URL###', $strURLS, $strBookmarkEntry);
}
$strBookmarks .= $strBookmarkEntry;
}
}
?>
Spank
Kommentar