예제 #1
0
파일: embed.php 프로젝트: rair/yacs
 /**
  * display content below main panel
  *
  * @param array the hosting record, if any
  * @return some HTML to be inserted into the resulting page
  */
 function &get_view_text($host = NULL)
 {
     $text = '';
     // do we have something embedded?
     if (isset($this->attributes['embed_type'])) {
         switch ($this->attributes['embed_type']) {
             // a link has been shared
             case 'href':
                 if (!isset($this->attributes['type'])) {
                     return $text;
                 }
                 // maybe some description has been added to this object
                 if (isset($this->attributes['description'])) {
                     $text .= '<div style="margin: 0.5em 0">' . skin::strip($this->attributes['description'], 50) . '</div>' . "\n";
                 }
                 // default url is the original one
                 if (!isset($this->attributes['url'])) {
                     $this->attributes['url'] = $this->attributes['embed_href'];
                 }
                 // empty url
                 if (!trim($this->attributes['url'])) {
                     return $text;
                 }
                 // what has to be embedded?
                 switch ($this->attributes['type']) {
                     // display a link in a button, and add a nice preview aside
                     case 'link':
                     default:
                         // label this link
                         $label = '';
                         if (isset($this->attributes['label'])) {
                             $label = trim($this->attributes['label']);
                         }
                         if (!$label) {
                             $label = $this->attributes['embed_href'];
                         }
                         // render this link
                         $text .= '<div style="margin: 80px auto 90px auto">' . '<a class="button tipsy_showme" href="' . $this->attributes['embed_href'] . '"><span>' . $label . '</span></a>' . '</div>';
                         Page::insert_script('$(function() {' . "\n" . '	$("a.tipsy_showme").each(function() {' . "\n" . '		$(this).tipsy({fallback: \'<div class="tipsy_thumbnail"><iframe class="tipsy_iframe" src="\'+$(this).attr("href")+\'" /></div>\',' . "\n" . '		 html: true,' . "\n" . '		 gravity: $.fn.tipsy.autoWE,' . "\n" . '		 fade: true,' . "\n" . '		 offset: 8,' . "\n" . '		 trigger: "manual",' . "\n" . '		 opacity: 1.0}).tipsy("show");' . "\n" . '	});' . "\n" . '});' . "\n");
                         break;
                         // display the photo itself
                     // display the photo itself
                     case 'photo':
                         if (isset($this->attributes['width']) && isset($this->attributes['height'])) {
                             $text .= '<img src="' . $this->attributes['url'] . '" width="' . $this->attributes['width'] . '" height="' . $this->attributes['height'] . '" alt="" />';
                         } else {
                             $text .= '<img src="' . $this->attributes['url'] . '" alt="" />';
                         }
                         break;
                         // true object embedding
                     // true object embedding
                     case 'rich':
                     case 'video':
                         if ($this->attributes['html']) {
                             $text .= $this->attributes['html'];
                         }
                         break;
                 }
                 break;
                 // a file has been shared -- laid out with other files
             // a file has been shared -- laid out with other files
             case 'upload':
                 break;
         }
     }
     if ($text) {
         $text = '<div style="margin: 1em 0 2em 0">' . $text . '</div>';
     }
     return $text;
 }