示例#1
0
 /**
  * Get embed code
  * 
  * @return sting
  */
 public function getAjaxEmbedCode()
 {
     $result = array();
     $url = !empty($_GET['url']) ? urldecode($_GET['url']) : null;
     if ($url) {
         $embedInfo = UTIL_HttpResource::getOEmbed($url);
         if (!empty($embedInfo['html'])) {
             $result = $embedInfo;
         }
     }
     die(json_encode($result));
 }
示例#2
0
 public function addLink()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $url = $_POST['url'];
     $urlInfo = parse_url($url);
     if (empty($urlInfo['scheme'])) {
         $url = 'http://' . $url;
     }
     $url = str_replace("'", '%27', $url);
     $oembed = UTIL_HttpResource::getOEmbed($url);
     $oembedCmp = new BASE_CMP_AjaxOembedAttachment($oembed);
     $attacmentUniqId = $oembedCmp->initJs();
     unset($oembed['allImages']);
     $response = array('content' => $this->getMarkup($oembedCmp->render()), 'type' => 'link', 'result' => $oembed, 'attachment' => $attacmentUniqId);
     echo json_encode($response);
     exit;
 }
示例#3
0
 private function queryLink($query)
 {
     $url = $query['link'];
     $urlInfo = parse_url($url);
     if (empty($urlInfo['scheme'])) {
         $url = 'http://' . $url;
     }
     $oembed = @UTIL_HttpResource::getOEmbed($url);
     if (empty($oembed) || isset($oembed['result']) && $oembed['result'] == false || $oembed['type'] == 'link' && empty($oembed['title']) && empty($oembed['description'])) {
         $response = array('type' => 'link', 'result' => false, 'href' => $url);
         return $response;
     }
     $attacmentUniqId = uniqid('att');
     switch ($oembed['type']) {
         case 'video':
             $oembedCmp = new EQUESTIONS_CMP_AttVideoPreview($oembed);
             break;
         case 'photo':
             $oembedCmp = new EQUESTIONS_CMP_AttPhotoPreview($oembed['url']);
             break;
         default:
             $oembedCmp = new EQUESTIONS_CMP_AttLinkPreview($oembed);
             $attacmentUniqId = $oembedCmp->initJs($query['uniqId']);
     }
     unset($oembed['allImages']);
     $content = '<div class="al-result-preview">' . $oembedCmp->render() . '</div>';
     $response = array('content' => $this->getMarkup($content), 'type' => 'link', 'result' => $oembed, 'attachment' => $attacmentUniqId, 'processedUrl' => $query['link']);
     return $response;
 }