コード例 #1
0
 /**
  * function getViewer, used to call the appropriate viewer for the selected media type ($media_data['type'])
  *
  * @param array $media_data - associative array, at least with defined keys 'type' and 'path'
  * @param array $user_data  - associative array, at least with a defined key 'level'
  * @param array $node_data  - associative array, at least with a defined key 'level'
  * @param array $VIEWING_PREFERENCES
  * @return string
  */
 public function getViewer($media_data = array())
 {
     $media_type = isset($media_data[1]) ? $media_data[1] : null;
     if (isset($media_data['type'])) {
         $media_type = $media_data['type'];
     }
     $media_value = isset($media_data[2]) ? $media_data[2] : null;
     if (isset($media_data['value'])) {
         $media_value = $media_data['value'];
     }
     $media_title = null;
     if (isset($media_data['title']) && !is_null($media_data['title'])) {
         $media_title = $media_data['title'];
     }
     $media_width = null;
     if (isset($media_data['width']) && !is_null($media_data['width'])) {
         $media_width = $media_data['width'];
     }
     $media_height = null;
     if (isset($media_data['height']) && !is_null($media_data['height'])) {
         $media_height = $media_data['height'];
     }
     /**
      * @author giorgio 23/apr/2013
      *
      * modified: now each 'if' body outputs to a variable instead of returning immediately.
      * string is wrapped around a <div> element with proper class for css styling just before returning.
      *
      */
     /* @var $return string */
     $return = '';
     if ($media_type === _IMAGE || $media_type === _MONTESSORI) {
         $return = ImageViewer::view($this->media_path, $media_value, $this->viewing_preferences[_IMAGE], $media_title, $media_width, $media_height);
     } else {
         if ($media_type === _SOUND || $media_type === _PRONOUNCE) {
             $return = AudioPlayer::view($this->media_path, $media_value, $this->viewing_preferences[_SOUND], $media_title);
         } else {
             if ($media_type === _VIDEO || $media_type === _LABIALE || $media_type === _FINGER_SPELLING) {
                 $return = VideoPlayer::view($this->media_path, $media_value, $this->viewing_preferences[_VIDEO], $media_title, $media_width, $media_height);
             } else {
                 if ($media_type === _LIS && isset($_SESSION['mode']) && $_SESSION['mode'] == 'LIS') {
                     $return = VideoPlayer::view($this->media_path, $media_value, $this->viewing_preferences[_VIDEO], $media_title, $media_width, $media_height);
                 } else {
                     if ($media_type === _DOC) {
                         $return = DocumentViewer::view($this->media_path, $media_value, $this->viewing_preferences[_DOC]);
                     } else {
                         if ($media_type === _LINK) {
                             $return = ExternalLinkViewer::view($this->media_path, $media_value, $this->viewing_preferences[_LINK]);
                         } else {
                             $return = '';
                         }
                     }
                 }
             }
         }
     }
     /**
      * @author giorgio 23/apr/2013
      *
      * array to hold proper css classes
      */
     $cssArray = array(_IMAGE => 'image', _MONTESSORI => 'montessori', _SOUND => 'sound', _PRONOUNCE => 'pronounce', _VIDEO => 'video', _LABIALE => 'labiale', _LIS => 'lis', _FINGER_SPELLING => 'finger-spelling', _DOC => 'doc', _LINK => 'link');
     /**
      * @author giorgio 23/apr/2013
      *
      * wrap $return around a div and return as promised
      */
     if ($return !== '') {
         $return = "<div class='media " . $cssArray[$media_type] . "'>" . $return . "</div>";
     }
     return $return;
 }