diff --git a/commons/config.php b/commons/config.php index 6efc70c..02981c8 100644 --- a/commons/config.php +++ b/commons/config.php @@ -4,4 +4,5 @@ $host = "nibblepoker.lu"; $host_uri = "https://nibblepoker.lu"; $dir_commons = dirname(__FILE__); $dir_root = realpath($dir_commons . "/../"); +$dir_content = realpath($dir_commons . "/../" . "content/"); ?> \ No newline at end of file diff --git a/commons/content.php b/commons/content.php index 72f4da2..c041a9e 100644 --- a/commons/content.php +++ b/commons/content.php @@ -2,6 +2,8 @@ -

-  '.$title.'

'); - - echo('
-'.$previewImageAlt.'
-
'); - - if(!empty($previewPreface)) { - echo('

'.$previewPreface.'

'); - } - - if(!empty($previewText)) { - echo('

'.$previewText.'
Click here

'); - } else { - echo('

Click here

'); - } - - echo('
'); - - echo('

'); - foreach($tags as &$tagValue) { - echo('  #'.$tagValue.''); - } - echo('

'); -} - -/* Defining globals and constants */ -const BLOG_ACTION_NONE = "n"; -const BLOG_ACTION_SEARCH_TAGS = "t"; -const BLOG_ACTION_SEARCH_AUTHOR = "a"; -const BLOG_ACTION_SEARCH_DATE = "d"; -//const BLOG_ACTION_ERROR_SEARCH_TYPE_INVALID = "e"; - -const BLOG_PARAM_ACTION = "c"; -const BLOG_PARAM_ARTICLE_PER_PAGE = "c"; -const BLOG_PARAM_PAGE = "p"; -const BLOG_PARAM_SEARCH_PARAM = "s"; - -$blog_action = BLOG_ACTION_NONE; -$blog_search_parameter = ""; -$current_page = 0; -$article_per_page = 10; - -/* Parsing and verifying arguments */ -if(count($_GET) > 0) { - if(array_key_exists(BLOG_PARAM_ACTION, $_GET)) { - $blog_action = $_GET[BLOG_PARAM_ACTION]; - } - if(array_key_exists(BLOG_PARAM_ARTICLE_PER_PAGE, $_GET)) { - $article_per_page = $_GET[BLOG_PARAM_ARTICLE_PER_PAGE]; - } - if(array_key_exists(BLOG_PARAM_PAGE, $_GET)) { - $current_page = $_GET[BLOG_PARAM_PAGE]; - } - if(array_key_exists(BLOG_PARAM_SEARCH_PARAM, $_GET)) { - $blog_search_parameter = $_GET[BLOG_PARAM_SEARCH_PARAM]; - } -} - -if(!($blog_action == BLOG_ACTION_NONE || $blog_action == BLOG_ACTION_SEARCH_TAGS || - $blog_action == BLOG_ACTION_SEARCH_AUTHOR || $blog_action == BLOG_ACTION_SEARCH_DATE)) { - $blog_action = BLOG_ACTION_NONE; -} - -if(!is_numeric($article_per_page)) { - $article_per_page = 10; -} - -if(!is_numeric($current_page)) { - $current_page = 0; -} - -/* Loading blog entries */ -$jsonArticles = null; - -try { - $jsonArticles = file_get_contents("articles.json"); - $jsonArticles = json_decode($jsonArticles, true); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; - $jsonArticles = null; -} - -if($jsonArticles == null) { - exit("An error occured during the JSON parsing process..."); -} - -/* Printing the articles... */ -$currentArticleId = 0; -$articlesLeft = $article_per_page; - -//TODO: Max value is not right or checked yet ! -for($currentArticleId = ($article_per_page * $current_page); $currentArticleId < count($jsonArticles); $currentArticleId++) { - //echo($jsonArticles[$currentArticleId]["id"]."
"); - printBlogPreviewCard( - $jsonArticles[$currentArticleId]["id"], - $jsonArticles[$currentArticleId]["title"], - $jsonArticles[$currentArticleId]["preview"]["preface"], - $jsonArticles[$currentArticleId]["preview"]["text"], - $jsonArticles[$currentArticleId]["preview"]["image"], - $jsonArticles[$currentArticleId]["preview"]["imageAlt"], - $jsonArticles[$currentArticleId]["tags"], - $jsonArticles[$currentArticleId]["preview"]["icon"]); -} -?> diff --git a/content/index.json b/content/index.json new file mode 100644 index 0000000..7bd06a6 --- /dev/null +++ b/content/index.json @@ -0,0 +1,17 @@ +[ + { + "id": "test01", + "title": { + "en": "Test article", + "fr": "Article de test" + }, + "preamble": { + "en": "This is a test article, please ignore it", + "fr": "Ceci est un article de test, veuillez l'ignorer." + }, + "image": "test.jpg", + "tags": [ + "programming", "purebasic" + ] + } +] \ No newline at end of file diff --git a/content/index.php b/content/index.php index f509776..cf4d56b 100644 --- a/content/index.php +++ b/content/index.php @@ -18,10 +18,12 @@

$requested_content_type:

$requested_content_display_type:

$requested_tags: []

+

count($requested_tags):

$content_has_error:

$_content_error_message_key:

localize($_content_error_message_key):

$content_error_message:

+

$filtered_content_index_data:

$content_requested_url_part:

\ No newline at end of file diff --git a/content/items/test01.json b/content/items/test01.json new file mode 100644 index 0000000..0e0dcd2 --- /dev/null +++ b/content/items/test01.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file