PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/build_list_content.php

https://bitbucket.org/mpercy/deeemm-cms
PHP | 86 lines | 50 code | 20 blank | 16 comment | 10 complexity | 72cb39cf4e5a25075ec9c270263d77c9 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause
  1. <?php
  2. defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );
  3. /*===========================================================================
  4. Get title
  5. ===========================================================================*/
  6. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "core_structure` WHERE `table` = '$page'");
  7. while ($sql_result = mysql_fetch_array($sql_query)){
  8. $list_page_title = $sql_result[category_lan_ . $language];
  9. }
  10. if (htmlspecialchars($_GET["id"], ENT_QUOTES) <> '' && $action !== 'edit' && $action !=='show_index'){
  11. //read template data
  12. $main = read_file($default_url . $templates_dir . "list_article.tpl");
  13. //get article info from database
  14. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$page` WHERE `id` = '$id'");
  15. while($sql_result = mysql_fetch_array($sql_query)){
  16. $main = str_replace('[var]article_image[/var]', $article_image, $main);
  17. $main = str_replace('[var]article_date[/var]', strftime("%a %d %b %y", strtotime($sql_result[1])), $main);
  18. $main = str_replace('[var]article_image[/var]', $article_image, $main);
  19. $main = str_replace('[var]article_title[/var]', $sql_result[title_lan_ . $language], $main);
  20. $main = str_replace('[var]article_text[/var]', $sql_result[description_lan_ . $language], $main);
  21. }
  22. } else {
  23. $main .= read_file($default_url . $templates_dir . "list_index.tpl");
  24. $first_article = true;
  25. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . $page . "` ORDER BY `date` DESC");
  26. while($sql_result = @mysql_fetch_array($sql_query)){
  27. //get latest article (first article)
  28. if ($first_article) {
  29. $list_content_main_article .= read_file($default_url . $templates_dir . "list_index_item.tpl");
  30. $tool_tip = $sql_result[tool_tip_lan_ . $language];
  31. $article_text = $sql_result[description_lan_ . $language];
  32. //replace template markers with data from database
  33. $list_content_main_article = str_replace('[var]article_href[/var]', $list_item_href, $list_content_main_article);
  34. $list_content_main_article = str_replace('[var]article_title[/var]', $sql_result[title_lan_ . $language], $list_content_main_article);
  35. //show first item in entirety
  36. $list_content_main_article = str_replace('[var]article_text[/var]', $article_text, $list_content_main_article);
  37. $list_content_main_article = str_replace('[var]article_date[/var]', strftime("%A %d %B %Y", strtotime($sql_result[1])), $list_content_main_article);
  38. }
  39. /*===========================================================================
  40. Get previous articles
  41. ===========================================================================*/
  42. if (!$first_article) {
  43. $list_index_previous_articles .= read_file($content);
  44. $tool_tip = $sql_result[tool_tip_lan_ . $language];
  45. $list_item_href = '<A class="list_index_item" title="' . $tool_tip . '" href="' .$default_url .'index.php?page=' . $page . '&amp;id=' . $sql_result[id] . '">';
  46. $article_text = $sql_result[description_lan_ . $language];
  47. //$article_text = preg_replace('/\n|\r|\n\r/','<BR>',$article_text); //convert crlf to <BR>
  48. //replace template markers with data from database
  49. $list_index_previous_articles = str_replace('[var]article_href[/var]', $list_item_href, $list_index_previous_articles);
  50. $list_index_previous_articles = str_replace('[var]article_title[/var]', $sql_result[title_lan_ . $language], $list_index_previous_articles);
  51. //this line for titles only
  52. $list_index_previous_articles = str_replace('[var]article_text[/var]', '', $list_index_previous_articles);
  53. //this line for truncated article text as well
  54. //$list_index_previous_articles = str_replace('[var]article_text[/var]', balanceTags(truncate($article_text, 260)), $list_index_previous_articles);
  55. $list_index_previous_articles = str_replace('[var]article_date[/var]', strftime("%A %d %B %Y", strtotime($sql_result[1])), $list_index_previous_articles);
  56. if (!$article_text) {
  57. $previous_articles = '';
  58. } else {
  59. $previous_articles = $lan[previous_articles];
  60. }
  61. }
  62. $first_article = false;
  63. }// end while
  64. if($err=mysql_errno())return $err;
  65. }
  66. ?>