示例#1
0
 public function getdata()
 {
     // ini_set('display_startup_errors', 0);
     // ini_set('display_errors', 0);
     // ini_set('error_reporting', E_ALL);
     $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : null;
     $service = isset($_REQUEST['service']) ? $_REQUEST['service'] : 'facebook';
     $cache = isset($_REQUEST['cache']) ? $_REQUEST['cache'] : 1;
     if (isset($_GET['remove-cache']) && $_GET['remove-cache']) {
         Ynmediaimporter::clearCache();
         unset($_GET['remove-cache']);
     }
     $provider = Ynmediaimporter::getProvider($service);
     $data = array('html' => '', 'message' => '');
     try {
         list($items, $params, $media) = $provider->getData($_GET, $cache);
         $arrItems = array();
         foreach ($items as $item) {
             $t = $item;
             if (!is_array($t['title'])) {
                 $t['title'] = urlencode($t['title']);
             }
             array_push($arrItems, $t);
         }
         $aParams['items'] = $arrItems;
         $aParams['params'] = $params;
         $aParams['item_count'] = count($items);
         $aParams['userId'] = OW::getUser()->getId();
         $component = null;
         if ('photo' == $media) {
             //$script = 'index/__photos.tpl';
             $component = new YNMEDIAIMPORTER_CMP_PhotoBrowse($aParams);
         } else {
             //$script = 'index/__albums.tpl';
             $component = new YNMEDIAIMPORTER_CMP_AlbumBrowse($aParams);
         }
         $data['html'] = $component->render();
     } catch (Exception $e) {
         $data['message'] = $e->getMessage();
     }
     echo json_encode($data);
     exit(0);
 }