Ejemplo n.º 1
0
 public static function make_tag($file, $path, $attributes)
 {
     $srcattr = 'href';
     $tag = 'a';
     $content = $file->get_filename();
     if (in_array($file->get_mimetype(), portfolio_format_image::mimetypes())) {
         $srcattr = 'src';
         $tag = 'img';
         $content = '';
     }
     $attributes[$srcattr] = $path;
     // this will override anything we might have been passed (which is good)
     $dom = new DomDocument();
     $elem = null;
     if ($content) {
         $elem = $dom->createElement($tag, $content);
     } else {
         $elem = $dom->createElement($tag);
     }
     foreach ($attributes as $key => $value) {
         $elem->setAttribute($key, $value);
     }
     $dom->appendChild($elem);
     return $dom->saveXML($elem);
 }
Ejemplo n.º 2
0
 public static function file_output($file)
 {
     $path = self::get_file_directory() . '/' . $file->get_filename();
     if (in_array($file->get_mimetype(), portfolio_format_image::mimetypes())) {
         return '<img src="' . $path . '" alt="' . $file->get_filename() . '" />';
     }
     return '<a href="' . $path . '">' . $file->get_filename() . '</a>';
 }