/**
  * Fetches a url based on values set in the backend
  * @param array $option_array array that at least needs to contain the linking method and depending on that, the appropriate 2nd id value
  * @param string $keyprefix option set key that must be in front of every element key
  * @param string $inside if inside is passed it will be wrapped inside <a> tags with the href set to the previously returned link url
  * @param string $post_id if the function is called outside of the loop we might want to retrieve the permalink of a different post with this id
  * @return string url (with image inside <a> tag if the image string was passed)
  */
 function avia_get_link($option_array, $keyprefix, $inside = false, $post_id = false, $attr = "")
 {
     if (empty($option_array[$keyprefix . 'link'])) {
         $option_array[$keyprefix . 'link'] = "";
     }
     //check which value the link array has (possible are empty, lightbox, page, post, cat, url) and create the according link
     switch ($option_array[$keyprefix . 'link']) {
         case "lightbox":
             $url = avia_image_by_id($option_array[$keyprefix . 'image'], array('width' => 8000, 'height' => 8000), 'url');
             break;
         case "cat":
             $url = get_category_link($option_array[$keyprefix . 'link_cat']);
             break;
         case "page":
             $url = get_page_link($option_array[$keyprefix . 'link_page']);
             break;
         case "self":
             if (!is_singular() || $post_id != avia_get_the_ID() || !isset($option_array[$keyprefix . 'image'])) {
                 $url = get_permalink($post_id);
             } else {
                 $url = avia_image_by_id($option_array[$keyprefix . 'image'], array('width' => 8000, 'height' => 8000), 'url');
             }
             break;
         case "url":
             $url = $option_array[$keyprefix . 'link_url'];
             break;
         case "video":
             $video_url = $option_array[$keyprefix . 'link_video'];
             if (avia_backend_is_file($video_url, 'html5video')) {
                 $output = avia_html5_video_embed($video_url);
                 $class = "html5video";
             } else {
                 global $wp_embed;
                 $output = $wp_embed->run_shortcode("[embed]" . $video_url . "[/embed]");
                 $class = "embeded_video";
             }
             $output = "<div class='slideshow_video {$class}'>" . $output . "</div>";
             return $inside . $output;
             break;
         default:
             $url = $inside;
             break;
     }
     if (!$inside || $url == $inside) {
         return $url;
     } else {
         return "<a {$attr} href='" . $url . "'>" . $inside . "</a>";
     }
 }
Example #2
0
 static function which_video_service($video_url)
 {
     $service = "";
     if (avia_backend_is_file($video_url, 'html5video')) {
         $service = "html5";
     } else {
         if (strpos($video_url, '<iframe') !== false) {
             $service = "iframe";
         } else {
             if (strpos($video_url, 'youtube.com/watch') !== false || strpos($video_url, 'youtu.be/') !== false) {
                 $service = "youtube";
             } else {
                 if (strpos($video_url, 'vimeo.com') !== false) {
                     $service = "vimeo";
                 }
             }
         }
     }
     return $service;
 }
Example #3
0
 function _build_xml_slides($element)
 {
     global $avia_config;
     $text = $url = $title = "";
     if (!empty($element['slideshow_caption'])) {
         if (!empty($element['slideshow_caption_title'])) {
             $title = '&lt;h1&gt;' . $element['slideshow_caption_title'] . '&lt;/p&gt;';
         }
         $text = "<Text>" . $title . "&lt;p&gt;" . strip_tags($element['slideshow_caption']) . "&lt;/p&gt;</Text>";
     }
     //apply links to the image if thats what the user wanted
     $url = avia_get_link($element, 'slideshow_', false, $this->post_id);
     if ($url) {
         $url = "<Hyperlink URL='" . $url . "'  />";
     }
     if (is_numeric($element['slideshow_image'])) {
         $this->slides_xml .= '<Image Source="' . avia_image_by_id($element['slideshow_image'], 'featured', 'url') . '" Title="' . $element['slideshow_caption_title'] . '">';
         $this->slides_xml .= $text . $url;
         $this->slides_xml .= '</Image>';
     } else {
         if (avia_backend_is_file($element['slideshow_image'], 'html5video') || avia_backend_is_file($element['slideshow_image'], array('swf'))) {
             preg_match("!^(.+?)(?:\\.([^.]+))?\$!", $element['slideshow_image'], $path_split);
             $tag = 'Video';
             if ($path_split[2] == 'swf') {
                 $tag = 'Flash';
             }
             $this->slides_xml .= '<' . $tag . ' Source="' . $element['slideshow_image'] . '" Title="' . $element['slideshow_caption_title'] . '" Width="' . $avia_config['imgSize']['featured']['width'] . '" Height="' . $avia_config['imgSize']['featured']['height'] . '" Autoplay="true" >';
             $image = $path_split[1] . '.jpg';
             $checkpath = $path_split[1] . '-' . $avia_config['imgSize']['featured']['width'] . 'x' . $avia_config['imgSize']['featured']['height'] . '.jpg';
             if (@file_get_contents($checkpath, 0, NULL, 0, 1)) {
                 $image = $checkpath;
             }
             $this->slides_xml .= '<Image Source="' . $image . '" />';
             $this->slides_xml .= '</' . $tag . '>';
         }
     }
 }