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

/includes/build_newsbox_content.php

https://bitbucket.org/mpercy/deeemm-cms
PHP | 53 lines | 34 code | 11 blank | 8 comment | 4 complexity | 17aeb13c524e1e74c92f4ab49af6de12 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause
  1. <?php
  2. defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );
  3. $value = NULL;
  4. //===========================================================================
  5. //>create newsbox article
  6. //===========================================================================
  7. foreach ($newsbox_libraries as $value){
  8. //>get newsbox title in current language from structure
  9. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "core_structure` WHERE `table` = '$value'");
  10. while ($sql_result = mysql_fetch_array($sql_query)){
  11. $newsbox_item_title = $sql_result[category_lan_ . $language];
  12. $newsbox_article = $sql_result[table];
  13. }
  14. //>get total number of articles in table
  15. $sql_result = mysql_query("select count(*) from `" . $db_table_prefix . 'cat_' . "$value`");
  16. $num_newsarticles = mysql_result($sql_result,0);
  17. if ($num_newsarticles > 0) {
  18. //>read template + add to newsbox list
  19. $newsbox .= read_file($default_url . $templates_dir . "newsbox.tpl");
  20. //>get latest article
  21. $sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$value` ORDER BY `date` DESC LIMIT 1");
  22. while($sql_result = mysql_fetch_array($sql_query)){
  23. $news_image = $media_dir . $sql_result[image];
  24. $headline_text = strip_tags($sql_result[title_lan_ . $language]);
  25. $tool_tip = strip_tags($sql_result[tool_tip_lan_ . $language]);
  26. $story_text = strip_tags($sql_result[description_lan_ . $language]);
  27. $story_id = strip_tags($sql_result[id]);
  28. $newsbox_item_date = strftime("%a %d %b %Y", strtotime($sql_result[date]));
  29. }
  30. //>truncate characters and add link
  31. if(strlen($story_text) > 140) {
  32. $story_text = truncate($story_text, 210);
  33. $story_text = balanceTags($story_text);
  34. $story_text .= '<A class="float_right" title="' . $tool_tip . '" href="' . $default_url . '?page=' .$value . '&amp;id=' . $story_id . '"> ...Read More</A><BR /><BR />';
  35. }
  36. $newsbox = replace_variables($newsbox);
  37. } else {
  38. $headline_text = $lan[no_news];
  39. }
  40. }
  41. $value = NULL;
  42. ?>