diff --git a/go_trainer/api/api_go_trainer.php b/go_trainer/api/api_go_trainer.php index 62eff54..f0f6cdb 100644 --- a/go_trainer/api/api_go_trainer.php +++ b/go_trainer/api/api_go_trainer.php @@ -1,2 +1,81 @@ prepare( 'selGuide', + 'SELECT * FROM `go_trainer_guides` WHERE `title` = ?;', + array($title)); + $res = $con->prepare( 'insertVote', + 'INSERT INTO `go_trainer_guides` (`id`, `cat`, `parent_type`, `parent_id`, `title`, `author`, `body`, `created`, `last_edit`) ' + . ' VALUES (NULL, ?, 0, 0, ?, ?, ?, NOW(), NOW()); +', + array($cat, $title, \SYSTEM\SECURITY\Security::getUser()->id, $text)); + return JsonResult::ok(); + } + } + public static function call_guides_action_rate($rating, $guide) { + if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + return; + } + else{ + $rated = \SQL\GO_TRAINER_GET_HASRATED::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, $guide)); + if ($rating == $rated['rating']){ + return JsonResult::fail(); + } + if ($rated){ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'updateRate', + 'UPDATE go_trainer_rating SET rating=?, `timestamp`=NOW() WHERE id=?;', + array($rating, $rated['id'])); + return JsonResult::ok(); + } + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selRate', + 'SELECT * FROM `go_trainer_rating` WHERE `user_id` = ?;', + array(\SYSTEM\SECURITY\Security::getUser()->id)); + $res = $con->prepare( 'insertRate', + 'INSERT INTO `go_trainer_rating` (`id`, `user_id`, `rating`, `relation_type`, `relation_id`, `timestamp`)' + . ' VALUES (NULL, ?, ?, 1, ?, NOW());', + array(\SYSTEM\SECURITY\Security::getUser()->id, $rating, $guide)); + return JsonResult::ok(); + } + } + public static function call_guides_action_comment($text, $guide) { + if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + return; + } + else{ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selGuide', + 'SELECT * FROM `go_trainer_guides` WHERE `id` = ?;', + array($guide)); + $res = $con->prepare( 'insertComment', + 'INSERT INTO `go_trainer_guides` (`id`, `cat`, `parent_type`, `parent_id`, `title`, `author`, `body`, `created`, `last_edit`) ' + . ' VALUES (NULL, ?, 1, ?, ?, ?, ?, NOW(), NOW()); +', + array('', $guide, '', \SYSTEM\SECURITY\Security::getUser()->id, $text)); + return JsonResult::ok(); + } + } + public static function call_guides_action_search ($searchstring){ + $result = lists::generate_guidelist($searchstring); + return $result; + } + public static function call_guides_action_save_profile_picture ($url){ + if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + return; + } + else{ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'updateProfilePic', + 'INSERT INTO go_trainer_trainer (system_user_id, profile_picture_url, last_edit) VALUES(?, ?, NOW()) ON DUPLICATE KEY UPDATE profile_picture_url = ?;', + array(\SYSTEM\SECURITY\Security::getUser()->id, $url, $url)); + return JsonResult::ok(); + } + } + +} diff --git a/go_trainer/api/autoload.inc b/go_trainer/api/autoload.inc index f4aad13..b0636db 100644 --- a/go_trainer/api/autoload.inc +++ b/go_trainer/api/autoload.inc @@ -1,3 +1,4 @@ SERVERPATH()); + } + elseif (\SYSTEM\SECURITY\Security::isLoggedIn()) { + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guide/tpl/default_new_comment_loggedin.tpl'))->SERVERPATH()); + } + else{ + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guide/tpl/default_new_comment_loggedout.tpl'))->SERVERPATH()); + } + + } +} diff --git a/go_trainer/api/guides/lists.php b/go_trainer/api/guides/lists.php new file mode 100644 index 0000000..c1de4ce --- /dev/null +++ b/go_trainer/api/guides/lists.php @@ -0,0 +1,98 @@ +next()){ + $avg_rating = \SQL\GO_TRAINER_GET_AVERAGE_GUIDE_RATING::Q1(array($guide['id'])); + if($avg_rating['AVG(rating)'] < 1.5 && $avg_rating['AVG(rating)'] > 0){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_1.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 1.5 && $avg_rating['AVG(rating)'] < 2.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_2.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 2.5 && $avg_rating['AVG(rating)'] < 3.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_3.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 3.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_4.jpg'; + } + else{ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_none.jpg'; + } + $guide['guide_created'] = \SYSTEM\time::time_ago_string(strtotime($guide['created'])); + $guide['guide_last_edit'] = \SYSTEM\time::time_ago_string(strtotime($guide['last_edit'])); + $guide['guide_author_arr'] = \SQL\GO_TRAINER_ID_TO_USERNAME::Q1(array($guide['author'])); + $guide['guide_author'] = $guide['guide_author_arr']['username']; + $result .= SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guides/tpl/guide_list_item.tpl'))->SERVERPATH(), $guide); + } + return $result; + } + else{ + $searchstring = '%'.$filter.'%'; + $guides = \SQL\GO_TRAINER_GENERATE_GUIDELIST_SEARCH::QA(array($searchstring, $searchstring)); + foreach($guides as $guide){ + $avg_rating = \SQL\GO_TRAINER_GET_AVERAGE_GUIDE_RATING::Q1(array($guide['id'])); + if($avg_rating['AVG(rating)'] < 1.5 && $avg_rating['AVG(rating)'] > 0){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_1.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 1.5 && $avg_rating['AVG(rating)'] < 2.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_2.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 2.5 && $avg_rating['AVG(rating)'] < 3.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_3.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 3.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_4.jpg'; + } + else{ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_none.jpg'; + } + $guide['guide_created'] = \SYSTEM\time::time_ago_string(strtotime($guide['created'])); + $guide['guide_last_edit'] = \SYSTEM\time::time_ago_string(strtotime($guide['last_edit'])); + $guide['guide_author_arr'] = \SQL\GO_TRAINER_ID_TO_USERNAME::Q1(array($guide['author'])); + $guide['guide_author'] = $guide['guide_author_arr']['username']; + $result .= SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guides/tpl/guide_list_item.tpl'))->SERVERPATH(), $guide); + } + return $result; + } + + } + public static function generate_guidelist_by_author($author){ + $result = ''; + $guides = \SQL\GO_TRAINER_GENERATE_GUIDELIST_BY_AUTHOR::QA(array($author)); + foreach($guides as $guide){ + $avg_rating = \SQL\GO_TRAINER_GET_AVERAGE_GUIDE_RATING::Q1(array($guide['id'])); + if($avg_rating['AVG(rating)'] < 1.5 && $avg_rating['AVG(rating)'] > 0){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_1.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 1.5 && $avg_rating['AVG(rating)'] < 2.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_2.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 2.5 && $avg_rating['AVG(rating)'] < 3.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_3.jpg'; + } + elseif($avg_rating['AVG(rating)'] >= 3.5){ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_4.jpg'; + } + else{ + $guide['average_rating_img'] = './api.php?call=files&cat=rating&id=rating_none.jpg'; + } + $guide['average_rating'] = $avg_rating['AVG(rating)']; + $result .= SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account_panel/tpl/default_account_panel_guides_written_guide.tpl'))->SERVERPATH(), $guide); + } + + return $result; + } + public static function generate_commentlist_by_author($author){ + $result = ''; + $comments = \SQL\GO_TRAINER_GENERATE_COMMENTLIST_BY_AUTHOR::QA(array($author)); + foreach($comments as $comment){ + $result .= SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account_panel/tpl/default_account_panel_comments_written_comment.tpl'))->SERVERPATH(), $comment); + } + + return $result; + } +} + diff --git a/go_trainer/api/guides/rate.php b/go_trainer/api/guides/rate.php new file mode 100644 index 0000000..193b300 --- /dev/null +++ b/go_trainer/api/guides/rate.php @@ -0,0 +1,20 @@ +SERVERPATH(), $rating); + } + else{ + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guide/tpl/default_rating.tpl'))->SERVERPATH(), $rating); + } + + } + +} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + diff --git a/go_trainer/files/autoload.inc b/go_trainer/files/autoload.inc index 108d544..8075c83 100644 --- a/go_trainer/files/autoload.inc +++ b/go_trainer/files/autoload.inc @@ -1,3 +1,4 @@ trainer = $trainer; + } + public static function js(){ + return array( new PPAGE('default_account_panel/js/default_account_panel.js'));} + public static function css(){ + return array( new PPAGE('default_account_panel/css/default_account_panel.css'));} + + public function html(){ + $vars = array(); + $trainerdata = \SQL\GO_TRAINER_GET_TRAINER::Q1(array($this->trainer)); + $vars['id'] = $trainerdata['id']; + $vars['title'] = $trainerdata['username']; + $vars['profile_picture_url'] = $trainerdata['profile_picture_url']; + $vars['joindate'] = $trainerdata['joindate']; + $vars['guides_written'] = lists::generate_guidelist_by_author(\SYSTEM\SECURITY\Security::getUser()->id); + $vars['comments_written'] = lists::generate_commentlist_by_author(\SYSTEM\SECURITY\Security::getUser()->id); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('demo_basic')); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('time')); + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account_panel/tpl/default_account_panel.tpl'))->SERVERPATH(), $vars); + } +} \ No newline at end of file diff --git a/go_trainer/page/default_account_panel/js/default_account_panel.js b/go_trainer/page/default_account_panel/js/default_account_panel.js new file mode 100644 index 0000000..cbcbc66 --- /dev/null +++ b/go_trainer/page/default_account_panel/js/default_account_panel.js @@ -0,0 +1,21 @@ +function init_account_panel(){ + save_profile_picture_url(); +} +function save_profile_picture_url(){ + $('#btn_save_profile_picture_url').click(function(){ + var formData = new FormData($('#form_img')); + $.ajax({ + url: './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_files&action=upload&cat=img', //Server script to process data + type: 'POST', + //Ajax events + success: function(){alert('ok');}, + error: function(){alert('fail');}, + // Form data + data: formData, + //Options to tell jQuery not to process data or worry about content-type. + cache: false, + contentType: false, + processData: false + }); +}); +} \ No newline at end of file diff --git a/go_trainer/page/default_account_panel/tpl/default_account_panel.tpl b/go_trainer/page/default_account_panel/tpl/default_account_panel.tpl new file mode 100644 index 0000000..e460ecc --- /dev/null +++ b/go_trainer/page/default_account_panel/tpl/default_account_panel.tpl @@ -0,0 +1,43 @@ +
+
+

${title}

Mitglied seit: ${joindate}

+
+
+ Du hast kein Profilbild hinterlegt +

URL deines Profilbilds

+ + speichern +
+
+
+
+

Verfasste Beiträge

+
+
+
+
+
+

Titel

+
+
+

Letzter Eintrag

+
+
+

Kommentare

+
+
+

Bewertung

+
+
+
+ ${guides_written} +
+
+

Verfasste Kommentare

+
+
+
+ ${comments_written} +
+
+ \ No newline at end of file diff --git a/go_trainer/page/default_account_panel/tpl/default_account_panel_comments_written_comment.tpl b/go_trainer/page/default_account_panel/tpl/default_account_panel_comments_written_comment.tpl new file mode 100644 index 0000000..e9ac089 --- /dev/null +++ b/go_trainer/page/default_account_panel/tpl/default_account_panel_comments_written_comment.tpl @@ -0,0 +1,18 @@ +
+
+
+ ${body} +
+
+ Datum: ${last_edit} +
+ +
+
+
+
+
+ + diff --git a/go_trainer/page/default_account_panel/tpl/default_account_panel_guides_written_guide.tpl b/go_trainer/page/default_account_panel/tpl/default_account_panel_guides_written_guide.tpl new file mode 100644 index 0000000..bc4def2 --- /dev/null +++ b/go_trainer/page/default_account_panel/tpl/default_account_panel_guides_written_guide.tpl @@ -0,0 +1,23 @@ + +
+
+
+

${title}

+
+
+ ${last_edit} +
+
+ ${comments} +
+
+ +

Durchschnitt: ${average_rating}

+
+
+
+
+
+
+
+ diff --git a/go_trainer/page/default_account_panel/tpl/text.tpl b/go_trainer/page/default_account_panel/tpl/text.tpl new file mode 100644 index 0000000..5143b83 --- /dev/null +++ b/go_trainer/page/default_account_panel/tpl/text.tpl @@ -0,0 +1,3 @@ +${text} +
+
\ No newline at end of file diff --git a/go_trainer/page/default_guide/css/default_guide.css b/go_trainer/page/default_guide/css/default_guide.css new file mode 100644 index 0000000..6015ec6 --- /dev/null +++ b/go_trainer/page/default_guide/css/default_guide.css @@ -0,0 +1,13 @@ +.guide_row{ + max-width: 1200px; + margin: auto; + margin-bottom: 30px; + background: white; + padding: 20px; +} +.ratedparent1 .ratedclass1{ + display: none; +} +.vote_class{ + width: 95%; +} \ No newline at end of file diff --git a/go_trainer/page/default_guide/default_guide.php b/go_trainer/page/default_guide/default_guide.php new file mode 100644 index 0000000..625d2f4 --- /dev/null +++ b/go_trainer/page/default_guide/default_guide.php @@ -0,0 +1,41 @@ +guide = $guide; + } + public static function js(){ + return array( new PPAGE('default_guide/js/default_guide.js'));} + public static function css(){ + return array( new PPAGE('default_guide/css/default_guide.css'));} + public static function comments($guide){ + $result = ''; + $comments = \SQL\GO_TRAINER_GENERATE_COMMENTLIST::QA(array($guide)); + foreach($comments as $row){ + $comment['body'] = $row['body']; + $comment['comment_created'] = \SYSTEM\time::time_ago_string(strtotime($row['created'])); + $comment['comment_last_edit'] = \SYSTEM\time::time_ago_string(strtotime($row['last_edit'])); + $comment['comment_author_arr'] = \SQL\GO_TRAINER_ID_TO_USERNAME::Q1(array($row['author'])); + $comment['comment_author'] = $comment['comment_author_arr']['username']; + $result .= SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guide/tpl/default_comment.tpl'))->SERVERPATH(), $comment); + } + + return $result; + } + public function html(){ + $vars = array(); + $guidedata = \SQL\GO_TRAINER_GET_GUIDE::Q1(array($this->guide)); + $vars['id'] = $guidedata['id']; + $vars['title'] = $guidedata['title']; + $vars['rating'] = rate::rating($guidedata['id']); + $vars['last_edit'] = \SYSTEM\time::time_ago_string(strtotime($guidedata['last_edit'])); + $vars['text'] = $guidedata['body']; + $vars['new_comment'] = comment::new_comment($vars['id']); + $vars['commentlist'] = $this->comments($this->guide); + $vars['guide_author_arr'] = \SQL\GO_TRAINER_ID_TO_USERNAME::Q1(array($guidedata['author'])); + $vars['author'] = $vars['guide_author_arr']['username']; + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('demo_basic')); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('time')); + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guide/tpl/default_guide.tpl'))->SERVERPATH(), $vars); + } +} \ No newline at end of file diff --git a/go_trainer/page/default_guide/js/default_guide.js b/go_trainer/page/default_guide/js/default_guide.js new file mode 100644 index 0000000..65e9f92 --- /dev/null +++ b/go_trainer/page/default_guide/js/default_guide.js @@ -0,0 +1,84 @@ +function init_guide(){ + rate_click_1(); + rate_click_2(); + rate_click_3(); + rate_click_4(); + new_comment_click(); +} + +function rate_click_1(){ + $('#vote_class_1').click(function(){ + var rating = 1; + var guide = $('#guide_tag').attr('guide'); + $.getJSON('./api.php?call=guides&action=rate&rating=' + rating + '&guide=' + guide, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); +}); +} +function rate_click_2(){ + $('#vote_class_2').click(function(){ + var rating = 2; + var guide = $('#guide_tag').attr('guide'); + $.getJSON('./api.php?call=guides&action=rate&rating=' + rating + '&guide=' + guide, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); +}); +} +function rate_click_3(){ + $('#vote_class_3').click(function(){ + var rating = 3; + var guide = $('#guide_tag').attr('guide'); + $.getJSON('./api.php?call=guides&action=rate&rating=' + rating + '&guide=' + guide, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); +}); +} +function rate_click_4(){ + $('#vote_class_4').click(function(){ + var rating = 4; + var guide = $('#guide_tag').attr('guide'); + $.getJSON('./api.php?call=guides&action=rate&rating=' + rating + '&guide=' + guide, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); +}); +} +function new_comment_click(){ + $('#new_comment_send').click(function(){ + var text = $('#new_comment_textarea').val(); + var guide = $('#guide_tag').attr('guide'); + alert(text); + $.getJSON('./api.php?call=guides&action=comment&text=' + text + '&guide=' + guide, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); +}); +} \ No newline at end of file diff --git a/go_trainer/page/default_guide/tpl/default_comment.tpl b/go_trainer/page/default_guide/tpl/default_comment.tpl new file mode 100644 index 0000000..bd5c6b2 --- /dev/null +++ b/go_trainer/page/default_guide/tpl/default_comment.tpl @@ -0,0 +1,14 @@ +
+
+ ${body} +
+
+

${comment_author}

+

${comment_created}

+
+
+
+ + + + diff --git a/go_trainer/page/default_guide/tpl/default_guide.tpl b/go_trainer/page/default_guide/tpl/default_guide.tpl new file mode 100644 index 0000000..c21a056 --- /dev/null +++ b/go_trainer/page/default_guide/tpl/default_guide.tpl @@ -0,0 +1,22 @@ +
+
+

${title}

+

by ${author}, seit dem letzten Eintrag sind ${last_edit}

+
+
+ ${text} +
+
+
+ ${rating} +
+

Beitrag kommentieren

+ ${new_comment} +
+
+

Kommentare

+
+ ${commentlist} +
+
+ \ No newline at end of file diff --git a/go_trainer/page/default_guide/tpl/default_new_comment_loggedin.tpl b/go_trainer/page/default_guide/tpl/default_new_comment_loggedin.tpl new file mode 100644 index 0000000..627a630 --- /dev/null +++ b/go_trainer/page/default_guide/tpl/default_new_comment_loggedin.tpl @@ -0,0 +1,9 @@ +
+

Um einen Kommentar zu schreiben musst du eingeloggt sein und den Beitrag bereits geratet haben.

+
+
+ +
+
+ abschicken +
\ No newline at end of file diff --git a/go_trainer/page/default_guide/tpl/default_new_comment_loggedout.tpl b/go_trainer/page/default_guide/tpl/default_new_comment_loggedout.tpl new file mode 100644 index 0000000..301e104 --- /dev/null +++ b/go_trainer/page/default_guide/tpl/default_new_comment_loggedout.tpl @@ -0,0 +1,3 @@ +
+

Um einen Kommentar zu schreiben musst du eingeloggt sein und den Beitrag bereits bewertet haben.

+
diff --git a/go_trainer/page/default_guide/tpl/default_rating.tpl b/go_trainer/page/default_guide/tpl/default_rating.tpl new file mode 100644 index 0000000..fa0d61e --- /dev/null +++ b/go_trainer/page/default_guide/tpl/default_rating.tpl @@ -0,0 +1,35 @@ +
+
+
+ ${class_1} +
+
+ ${class_2} +
+
+ ${class_3} +
+
+ ${class_4} +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/go_trainer/page/default_guide/tpl/default_rating_loggedout.tpl b/go_trainer/page/default_guide/tpl/default_rating_loggedout.tpl new file mode 100644 index 0000000..f89ca7a --- /dev/null +++ b/go_trainer/page/default_guide/tpl/default_rating_loggedout.tpl @@ -0,0 +1,34 @@ +
+
+
+ ${class_1} +
+
+ ${class_2} +
+
+ ${class_3} +
+
+ ${class_4} +
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+

Um eine Bewertung abzugeben, musst du eingeloggt sein!

+
+
diff --git a/go_trainer/page/default_guide/tpl/text.tpl b/go_trainer/page/default_guide/tpl/text.tpl new file mode 100644 index 0000000..5143b83 --- /dev/null +++ b/go_trainer/page/default_guide/tpl/text.tpl @@ -0,0 +1,3 @@ +${text} +
+
\ No newline at end of file diff --git a/go_trainer/page/default_guides/css/default_guides.css b/go_trainer/page/default_guides/css/default_guides.css index 0029847..16cf2ec 100644 --- a/go_trainer/page/default_guides/css/default_guides.css +++ b/go_trainer/page/default_guides/css/default_guides.css @@ -1,5 +1,30 @@ -#start_main{ - width: 100%; +.guide_head_row{ + max-width: 1200px; + margin: auto; + margin-bottom: 30px; background: white; + } +.guide_row{ + max-width: 1200px; + margin: auto; + margin-bottom: 30px; + background: white; + padding: 30px; +} +.list_item{ + margin: 20px 0 20px 0; +} +.list_item p{ + +} +.black_side{ + background: #333333; + padding: 0; +} +.black_side p{ + background: #333333; + padding: 10px; + color: white; +} \ No newline at end of file diff --git a/go_trainer/page/default_guides/default_guides.php b/go_trainer/page/default_guides/default_guides.php index 0dbdc89..bee408c 100644 --- a/go_trainer/page/default_guides/default_guides.php +++ b/go_trainer/page/default_guides/default_guides.php @@ -1,12 +1,14 @@ SERVERPATH(), $vars); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('time')); + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_guides/tpl/default_guides.tpl'))->SERVERPATH(), $vars); } } \ No newline at end of file diff --git a/go_trainer/page/default_guides/js/default_guides.js b/go_trainer/page/default_guides/js/default_guides.js index b1690a3..0a0769d 100644 --- a/go_trainer/page/default_guides/js/default_guides.js +++ b/go_trainer/page/default_guides/js/default_guides.js @@ -1,3 +1,10 @@ -function init_start(){ - +function init_guides(){ + search(); +} +function search(){ + $('#search_btn').click(function(){ + var searchstring = $('#search_input').val(); + $('#guideslist_frame').load('./api.php?call=guides&action=search&searchstring=' + searchstring, function(data) { + }); +}); } \ No newline at end of file diff --git a/go_trainer/page/default_guides/tpl/default_guides.tpl b/go_trainer/page/default_guides/tpl/default_guides.tpl index fe410b4..2369472 100644 --- a/go_trainer/page/default_guides/tpl/default_guides.tpl +++ b/go_trainer/page/default_guides/tpl/default_guides.tpl @@ -1,3 +1,69 @@ -
- ${start_content} + +
+
+
+
+ + + +
+
+

+ Guides +

+ Hier findest du Guides und Hilfe aus der Community zu Pokemon, Spielweisen, Tipps & Tricks! + +
+
+
+
+
+
+ + + +
+
+

+ Contribute +

+ Erstelle einen guide für die Community! +

Du musst dich einloggen um einen Beitrag erstellen zu können.

+ +
+
+
+
+
+
+ + + + + +
+
+
+ +
+
+
+
+
+
+

Titel

+
+
+

Info

+
+
+

Bewertung

+
+
+
+
+
+ ${guidelist} +
+
\ No newline at end of file diff --git a/go_trainer/page/default_guides/tpl/guide_list_item.tpl b/go_trainer/page/default_guides/tpl/guide_list_item.tpl new file mode 100644 index 0000000..9a16e99 --- /dev/null +++ b/go_trainer/page/default_guides/tpl/guide_list_item.tpl @@ -0,0 +1,16 @@ +
+
+ +
+

${title}

+
+
+
+

geschrieben von ${guide_author}

+

${guide_last_edit}seit dem letzen edit am ${last_edit}

+
+
+ +
+
+
\ No newline at end of file diff --git a/go_trainer/page/default_new_guide/css/default_new_guide.css b/go_trainer/page/default_new_guide/css/default_new_guide.css index 0029847..7503f58 100644 --- a/go_trainer/page/default_new_guide/css/default_new_guide.css +++ b/go_trainer/page/default_new_guide/css/default_new_guide.css @@ -1,5 +1,13 @@ -#start_main{ - width: 100%; +.new_guide_row{ background: white; + max-width: 1200px; + margin: auto; + padding: 40px; } - +.new_guide_title{ + background: white; + +} +.new_guide_body{ + background: white; +} \ No newline at end of file diff --git a/go_trainer/page/default_new_guide/default_new_guide.php b/go_trainer/page/default_new_guide/default_new_guide.php index 0dbdc89..4dea6ce 100644 --- a/go_trainer/page/default_new_guide/default_new_guide.php +++ b/go_trainer/page/default_new_guide/default_new_guide.php @@ -1,12 +1,15 @@ SERVERPATH(), $vars); + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_new_guide/tpl/default_new_guide.tpl'))->SERVERPATH(), $vars); } } \ No newline at end of file diff --git a/go_trainer/page/default_new_guide/js/default_new_guide.js b/go_trainer/page/default_new_guide/js/default_new_guide.js index b1690a3..54f87ae 100644 --- a/go_trainer/page/default_new_guide/js/default_new_guide.js +++ b/go_trainer/page/default_new_guide/js/default_new_guide.js @@ -1,3 +1,101 @@ -function init_start(){ - +function init_new_guide(){ + init_tinymce(); + $('#btn_save').click(function(){ + var title = $('#title_text').val(); + var cat = $('#cat_text').val(); + var text = encodeURIComponent(tinymce.activeEditor.getContent({format : 'raw'})); + if (title == "" || cat == "" || text == ""){ + alert('data missing'); + return; + } + $.getJSON('./api.php?call=guides&action=new&title=' + title + '&cat=' + cat + '&text=' + text, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); +}); +} +function init_tinymce(){ + tinymce.remove(); + tinymce.init({ // General options + /* + formats : { + italic : {inline : 'span', 'classes' : 'italic'}}, + // Theme options + theme_modern_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", + theme_modern_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", + theme_modern_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", + theme_modern_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", + theme_modern_toolbar_location : "top", + theme_modern_toolbar_align : "left", + theme_modern_statusbar_location : "bottom", + theme_modern_resizing : true, + + // Example content CSS (should be your site CSS) + content_css : "../../page/index.css"*/ + // General options +/* mode : "textareas", + + plugins : "autolink,lists,pagebreak,layer,table,save,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,template,code",*/ + //xhtmlxtras,emotions,advimage,advlink,iespell,inlinepopups,advhr,style,spellchecker, + + // Theme options + /*theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", + theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", + theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", + theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", + theme_advanced_toolbar_location : "top", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + theme_advanced_resizing : true,*/ + + // Skin options + //skin : "o2k7", + //skin_variant : "silver", + width: "99%", + height: "250px", + + // Example content CSS (should be your site CSS) + //content_css : "css/example.css", + //content_css : "../../page/index.css" + + // Drop lists for link/image/media/template dialogs + /*template_external_list_url : "js/template_list.js", + external_link_list_url : "js/link_list.js", + external_image_list_url : "js/image_list.js", + media_external_list_url : "js/media_list.js", + + // Replace values for the template plugin + template_replace_values : { + username : "Some User", + staffid : "991234" + }*/ + //extended_valid_elements: "iframe[title|class|type|width|height|src|frameborder|allowFullScreen]", + //extended_valid_elements: "iframe[class|src|frameborder=0|alt|title|width|height|align|name]", + //extended_valid_elements: "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]", + selector: "textarea", + theme: "modern", + //theme : "advanced", + plugins: [ + "advlist autolink lists link image charmap print preview hr anchor pagebreak", + "searchreplace wordcount visualblocks visualchars code fullscreen", + "insertdatetime nonbreaking save table contextmenu directionality",//media + "emoticons template paste textcolor" + ], + toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", + toolbar2: "print preview | forecolor backcolor emoticons",//media + image_advtab: true, + templates: [ + {title: 'Test template 1', content: 'Test 1'}, + {title: 'Test template 2', content: 'Test 2'} + ], + //remove p tag + forced_root_block : "", + force_br_newlines : true, + force_p_newlines : false +}); } \ No newline at end of file diff --git a/go_trainer/page/default_new_guide/tpl/default_new_guide.tpl b/go_trainer/page/default_new_guide/tpl/default_new_guide.tpl index fe410b4..b510ad2 100644 --- a/go_trainer/page/default_new_guide/tpl/default_new_guide.tpl +++ b/go_trainer/page/default_new_guide/tpl/default_new_guide.tpl @@ -1,3 +1,48 @@ -
- ${start_content} -
+
+
+
+ +
+
+

+ Erstelle einen Guide +

+

+ +

+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/go_trainer/page/default_page/css/default_page.css b/go_trainer/page/default_page/css/default_page.css index 7506582..d9207bb 100644 --- a/go_trainer/page/default_page/css/default_page.css +++ b/go_trainer/page/default_page/css/default_page.css @@ -18,10 +18,9 @@ body { #menu { width: 100%; - background: #cc3333; } -#menu_content { +#nav { font-family: Arial; font-size: 16pt; width: 90%; @@ -31,28 +30,24 @@ body { color: white; } -#menu_content a:visited{ +#nav a:visited{ text-decoration: none; color: white; } -#menu_content a:hover{ +#nav a:hover{ text-decoration: none; text-shadow: 1px 0px white; } -#menu_content a:link{ +#nav a:link{ text-decoration: none; color: white; } #content { background: white; - width: 55%; padding: 25px; - margin: auto; - color: #666666; - box-shadow: 0 0px 0px 0px white, 0 0px 0px 0px white, 5px 0 5px -4px rgba(102, 102, 102, 0.8), -5px 0 5px -5px rgba(102, 102, 102, 0.8); } #footer { @@ -75,4 +70,8 @@ body { #footer a:visited{ text-decoration: none; color: white; +} + +.row{ + margin: 0; } \ No newline at end of file diff --git a/go_trainer/page/default_page/default_page.php b/go_trainer/page/default_page/default_page.php index 76cc7c5..ae6f5e4 100644 --- a/go_trainer/page/default_page/default_page.php +++ b/go_trainer/page/default_page/default_page.php @@ -3,22 +3,45 @@ class default_page extends \SYSTEM\PAGE\Page { private static function js(){ return \SYSTEM\HTML\html::script(\LIB\lib_jquery::js()->WEBPATH()). \SYSTEM\HTML\html::script(\LIB\lib_bootstrap::js()->WEBPATH()). + \SYSTEM\HTML\html::script(\LIB\lib_jqbootstrapvalidation::js()->WEBPATH()). \SYSTEM\HTML\html::script(\LIB\lib_system::js()->WEBPATH()). + \SYSTEM\HTML\html::script(\LIB\lib_tinymce::js()->WEBPATH(false)). \SYSTEM\HTML\html::script((new PPAGE('default_page/js/default_page.js'))->WEBPATH()); } private static function css(){ - return \SYSTEM\HTML\html::link(\LIB\lib_bootstrap::css()->WEBPATH()). + return \SYSTEM\HTML\html::link(\LIB\lib_bootstrap::css()->WEBPATH(false)). \SYSTEM\HTML\html::link((new PPAGE('default_page/css/default_page.css'))->WEBPATH()); } + public function getloggedinform(){ + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/login/loggedinform.tpl'))->SERVERPATH(), array());} + public function exchange_registerform(){ + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/login/register_form.tpl'))->SERVERPATH(), array());} + + public function getloginform(){ + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/login/loginform.tpl'))->SERVERPATH(), array());} + + public function exchange_loginform(){ + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/login/loggedinformtop.tpl'))->SERVERPATH(), array());} public function html($_escaped_fragment_ = null){ $vars = array(); + if (\SYSTEM\SECURITY\Security::isLoggedIn()){ + $vars['menu_account_display_class'] = 'style="display: block"'; + $vars['registerform'] = $this->getloggedinform(); + $vars['loginform'] = $this->exchange_loginform(); + } + else { + $vars['menu_account_display_class'] = 'style="display: none"'; + $vars['registerform'] = $this->exchange_registerform(); + $vars['loginform'] = $this->getloginform() ; + } $vars['js'] = ''; if(!$_escaped_fragment_){ $vars['js'] = self::js();} $vars['css'] = self::css(); - $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('demo_basic')); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('basic')); + return SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/default_page.tpl'))->SERVERPATH(), $vars); } } \ No newline at end of file diff --git a/go_trainer/page/default_page/js/default_page.js b/go_trainer/page/default_page/js/default_page.js index fb963ae..7aba2b5 100644 --- a/go_trainer/page/default_page/js/default_page.js +++ b/go_trainer/page/default_page/js/default_page.js @@ -1,3 +1,38 @@ $(document).ready(function() { - new SYSTEM('./api.php',1,'start'); -}); \ No newline at end of file + new SYSTEM('./api.php',1,'start'); + register_login(); + register_logout(); +}); + + + +function register_login(){ + $("#form_login input").not("[type=submit]").jqBootstrapValidation({ + preventSubmit: true, + submitError: function($form, event, errors) {}, + submitSuccess: function($form, event){ + $.get('./api.php?call=account&action=login&username=' + $('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) { + if(data == 1){ + window.location.reload(); + } else { + $('#help-block-user-password-combi-wrong').attr('style', 'display: block;'); + } + }); + event.preventDefault(); + } + }); +} +function register_logout(){ + $('#btn_logout').click(function(){ + $.get('./api.php?call=account&action=logout', function () { + window.location.reload(); + }); + }) +} +function encode_utf8(c) { + return unescape(encodeURIComponent(c)); +} + +function decode_utf8(c) { + return decodeURIComponent(escape(c)); +} \ No newline at end of file diff --git a/go_trainer/page/default_page/tpl/default_page.tpl b/go_trainer/page/default_page/tpl/default_page.tpl index 97c9cbc..4dadbb4 100644 --- a/go_trainer/page/default_page/tpl/default_page.tpl +++ b/go_trainer/page/default_page/tpl/default_page.tpl @@ -10,7 +10,7 @@ ${js} - + -