mostly filebased Content Presentation System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 line
1.6KB

  1. <?php
  2. namespace Modules;
  3. class Pictures extends \Prefab {
  4. static function render_an_image($args) {
  5. $f3 = \Base::instance();
  6. $attr = $args['@attrib'];
  7. //var_dump($attr);
  8. $a=array(
  9. 'img'=>'',
  10. 'hover'=>'',
  11. 'link'=>''
  12. );
  13. $img = array_key_exists('img', $attr) ? $attr['img'] : false;
  14. $alt = array_key_exists('hover', $attr) ? $attr['hover'] : false;
  15. $url = array_key_exists('link', $attr) ? $attr['link'] : false;
  16. echo $img."sss"."<br>";
  17. var_dump($a);
  18. if($img /*&& is_file($img)*/) {
  19. $a['img'] = $img;
  20. } else {
  21. $a['img'] = $f3->get('RESOURCES')."img/default.png";
  22. }
  23. if($alt && is_file($alt)) {
  24. $a['hover'] = $alt;
  25. } else {
  26. $a['hover'] = $a['img'];
  27. }
  28. if($url) {
  29. $a['link'] = $url;
  30. } else {
  31. $a['link'] = '/';
  32. }
  33. //var_dump($a);
  34. //var_dump($args);
  35. //$out = sprintf("<code>%s</code>",);
  36. return self::hover_pic_with_link($a['img'],$a['hover'],$a['link']);
  37. }
  38. static function hover_pic_with_link($pic1,$pic2,$link) {
  39. return sprintf('<a href="%s"><img src="%s" alt="%s" /></a>',$link,$pic1,$pic2);
  40. }
  41. static function makeImageLink($url,$href=false) {
  42. if($href) {
  43. return sprintf("<a href=\"%s\"><img class=\"post-image\" src=\"%s\" /></a>",$href, $url);
  44. }
  45. return sprintf("<img class=\"post-image\" src=\"%s\" />", $url);
  46. }
  47. }