private function open_popup_for_filter($current_url, $key)
 {
     $key = (string) $media_url->category_id;
     $doc = HD::http_get_document($current_url . '/' . $key);
     $pop_up_items = array();
     $xml = simplexml_load_string($doc);
     foreach ($xml->Directory as $c) {
         $key = (string) $c->attributes()->key;
         $prompt = (string) $c->attributes()->prompt;
         if ($key != 'all' && $key != 'folder' && !$prompt) {
             $pop_up_items[] = array(GuiMenuItemDef::caption => (string) $c->attributes()->title, GuiMenuItemDef::action => ActionFactory::open_folder($this->get_right_media_url($media_url, $key), $key));
         }
     }
     $action = ActionFactory::show_popup_menu($pop_up_items);
 }
Beispiel #2
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new ActionFactory();
     }
     return self::$instance;
 }
 public function execute()
 {
     switch ($_REQUEST['checkout_type']) {
         case 'cart':
             if ($_REQUEST['payment_method_id'] == 'paypal') {
                 $actionInstance = ActionFactory::factory('KanCart.ShoppingCart.PayPalWPS.Done');
                 $actionInstance->init();
                 $actionInstance->execute();
                 $this->result = $actionInstance->getResult();
             } else {
                 $kancartPaymentService = ServiceFactory::factory('KancartPayment');
                 list($result, $order_id) = $kancartPaymentService->kancartPaymentDone($_REQUEST['order_id'], $_REQUEST['custom_kc_comments'], $_REQUEST['payment_status']);
                 if ($result === TRUE) {
                     $orderService = ServiceFactory::factory('Order');
                     $info = $orderService->getPaymentOrderInfoById($order_id);
                     $this->setSuccess($info);
                 } else {
                     $this->setError('0xFFFF', $order_id);
                 }
             }
         case 'order':
             break;
         default:
             break;
     }
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Entry handler: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if (!isset($user_input->entry_id)) {
         return null;
     }
     $add_params = array('entry_id' => $user_input->entry_id);
     if ($user_input->entry_id === 'setup' || $user_input->entry_id === 'tv') {
         $res = $this->session->apply_subscription($plugin_cookies, $user_input);
         if ($res !== false) {
             if (!isset($res['action'])) {
                 return ActionFactory::close_dialog_and_run(ActionFactory::open_folder());
             }
             return $res['need_close_dialog'] ? ActionFactory::close_dialog_and_run($res['action']) : $res['action'];
         } else {
             if ($this->session->is_logged_in()) {
                 return ActionFactory::open_folder();
             }
             if (!isset($plugin_cookies->user_name) || $plugin_cookies->user_name === '') {
                 return $this->session->do_get_edit_subscription_action($plugin_cookies, $this, $add_params);
             }
             return ActionFactory::open_folder();
         }
     }
     return null;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod search: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->action_type === 'apply') {
         $control_id = $user_input->control_id;
         if ($control_id === 'pattern') {
             $pattern = $user_input->pattern;
             $plugin_cookies->vod_search_pattern = $pattern;
             hd_print("Vod search: applying pattern '{$pattern}'");
             $defs = $this->do_get_control_defs($plugin_cookies);
             return ActionFactory::reset_controls($defs, ActionFactory::open_folder($this->vod->get_search_media_url_str($pattern), $pattern));
         }
     } else {
         if ($user_input->action_type === 'confirm') {
             $control_id = $user_input->control_id;
             $new_value = $user_input->{$control_id};
             if ($control_id === 'pattern') {
                 $pattern = $user_input->pattern;
                 if (preg_match('/^\\s*$/', $pattern)) {
                     return ActionFactory::show_error(false, 'Pattern should not be empty');
                 }
             }
         }
     }
     return null;
 }
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     $enter_action = ActionFactory::open_folder();
     $pop_up_action = UserInputHandlerRegistry::create_action($this, 'pop_up', null, 'Filtos');
     return array(GUI_EVENT_KEY_ENTER => $enter_action, GUI_EVENT_KEY_PLAY => $enter_action, GUI_EVENT_KEY_POPUP_MENU => $pop_up_action);
 }
 protected function call_plugin_impl($call_ctx)
 {
     static $plugin;
     if (is_null($plugin)) {
         try {
             hd_print('Instantiating plugin...');
             $plugin = $this->create_plugin();
             hd_print('Plugin instance created.');
         } catch (Exception $e) {
             hd_print('Error: can not instantiate plugin (' . $e->getMessage() . ')');
             return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, 'System error', array('Can not create PHP plugin instance.', 'Call the PHP plugin vendor.')));
         }
     }
     // assert($plugin);
     $out_data = null;
     try {
         $out_data = $this->invoke_operation($plugin, $call_ctx);
     } catch (DuneException $e) {
         hd_print("Error: DuneException caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => $e->get_error_action());
     } catch (Exception $e) {
         hd_print("Error: Exception caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, 'System error', array('Unhandled PHP plugin error.', 'Call the PHP plugin vendor.')));
     }
     // Note: change_tv_favorites() may return NULL even if it's completed
     // successfully.
     $plugin_output_data = array(PluginOutputData::has_data => !is_null($out_data), PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => false, PluginOutputData::error_action => null);
     if ($plugin_output_data[PluginOutputData::has_data]) {
         $plugin_output_data[PluginOutputData::data_type] = $this->get_out_type_code($call_ctx->op_type_code);
         $plugin_output_data[PluginOutputData::data] = $out_data;
     }
     return $plugin_output_data;
 }
 protected function call_plugin_impl($call_ctx)
 {
     static $plugin;
     if (is_null($plugin)) {
         try {
             hd_print('Instantiating plugin...');
             $plugin = $this->create_plugin();
             hd_print('Plugin instance created.');
         } catch (Exception $e) {
             hd_print('Error: can not instantiate plugin (' . $e->getMessage() . ')');
             return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, T::t('title_application_error'), array(T::t('msg_plugin_init_failed'))));
         }
     }
     $out_data = null;
     try {
         $out_data = $this->invoke_operation($plugin, $call_ctx);
     } catch (DuneException $e) {
         hd_print("Error: DuneException caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => $e->get_error_action());
     } catch (Exception $e) {
         hd_print("Error: Exception caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, T::t('title_application_error'), array(T::t('msg_unhandled_plugin_error'))));
     }
     $plugin_output_data = array(PluginOutputData::has_data => !is_null($out_data), PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => false, PluginOutputData::error_action => null);
     if ($plugin_output_data[PluginOutputData::has_data]) {
         $plugin_output_data[PluginOutputData::data_type] = $this->get_out_type_code($call_ctx->op_type_code);
         $plugin_output_data[PluginOutputData::data] = $out_data;
     }
     return $plugin_output_data;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'popup_menu') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $movie_id = $media_url->movie_id;
         $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
         $add_favorite_action = UserInputHandlerRegistry::create_action($this, 'add_favorite');
         $caption = 'Add to My Movies';
         $menu_items[] = array(GuiMenuItemDef::caption => $caption, GuiMenuItemDef::action => $add_favorite_action);
         return ActionFactory::show_popup_menu($menu_items);
     } else {
         if ($user_input->control_id == 'add_favorite') {
             if (!isset($user_input->selected_media_url)) {
                 return null;
             }
             $media_url = MediaURL::decode($user_input->selected_media_url);
             $movie_id = $media_url->movie_id;
             $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
             if ($is_favorite) {
                 return ActionFactory::show_title_dialog('Movie already resides in My Movies');
             } else {
                 $this->vod->add_favorite_movie($movie_id, $plugin_cookies);
                 return ActionFactory::show_title_dialog('Movie has been added to My Movies');
             }
         }
     }
     return null;
 }
Beispiel #10
0
 function process_query($twitter_query)
 {
     if ($this->debug) {
         echo "Processing query {$twitter_query}<br/>";
     }
     $twitter_query = trim(str_replace("@twitlookup", "", $twitter_query));
     $lookup_object = ActionFactory::get_lookup_object($twitter_query, "twitter");
     $type = $lookup_object->get_type();
     if ($this->debug) {
         echo "Type: {$type}<br/>";
     }
     $actual_search_term = $lookup_object->get_actual_search_term();
     if ($this->debug) {
         echo "Getting message<br/>";
     }
     $message = $this->get_message($lookup_object);
     if ($this->debug) {
         echo "<b>Message is</b> {$message}<br/>";
     }
     if ($message) {
         if (is_array($message)) {
             foreach ($message as $mess) {
                 $mess = trim($lookup_object->get_hash_tags . " " . $mess);
                 echo "{$mess}<br/>";
             }
         } else {
             $message = trim($lookup_object->get_hash_tags . " " . $message);
             echo "{$message}<br/>";
         }
     }
     $message = "";
     unset($lookup_object);
 }
Beispiel #11
0
 /**
  * Despacha a la acción correspondiente al request. Luego de la ejecución devuelve la referencia a la
  * acción.
  *
  * @access public
  * @return (object) referencia a la acción creada
  */
 function dispatch()
 {
     // Tomar la accion que viene por GET
     $action = $_GET['accion'];
     // Buscar el path de la clase para la accion correspondiente o un path por defecto
     $actionFactory = new ActionFactory($action);
     $actionParams = $actionFactory->create();
     $class_name = $actionParams['clase'];
     $modulo = $actionParams['modulo'];
     $action_name = $actionParams['nombre'];
     // Incluir el archivo con la clase
     include_once 'acciones/' . $modulo . '/accion.' . $class_name . '.php';
     // Crear la clase de la accion correspondiente
     eval('$action = new $class_name;');
     $action->ejecutarCiclo();
     return $action;
 }
 public function doMakePlayListAndPlay(&$user_input, &$plugin_cookies)
 {
     hd_print(__METHOD__ . print_r($plugin_cookies, true));
     $media_url = MediaURL::decode($user_input->selected_media_url);
     $url = $this->base_url . $media_url->key;
     $musics = $this->getTrackUrlsFromUrl($url, $plugin_cookies);
     return ActionFactory::launch_media_url($this->makePlayList($musics));
 }
 public function testMakeAction_insertion()
 {
     $action = ActionFactory::make('i(ra)');
     $this->assertTrue($action != null, "Erreur : l'action retournée est nulle.");
     $this->assertEquals(1, $action->type(), "Erreur sur le type");
     $this->assertEquals('ra', $action->insertedChars(), "Erreur sur les caractères insérés");
     $action = ActionFactory::make('i(ng)');
     $this->assertTrue($action != null, "Erreur : l'action retournée est nulle.");
     $this->assertEquals(1, $action->type(), "Erreur sur le type.");
     $this->assertEquals('ng', $action->insertedChars(), "Erreur sur les caractères insérés");
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     $cacheFile = __DIR__ . '/www/index.html';
     $dir = dirname($cacheFile);
     if (!file_exists($dir)) {
         mkdir($dir, true);
     }
     ob_start();
     phpinfo();
     file_put_contents($cacheFile, ob_get_clean());
     return ActionFactory::launch_media_url('www://http://127.0.0.1/plugins/phpinfo/index.html:::fullscreen=1');
 }
Beispiel #15
0
 static function getNewAction($name, $params)
 {
     if (empty(ActionFactory::$loaded_actions)) {
         ActionFactory::loadFunctionList();
     }
     if (isset(ActionFactory::$loaded_actions[$name])) {
         require_once ActionFactory::$loaded_actions[$name]['file'];
         $class = ActionFactory::$loaded_actions[$name]['class'];
         return new $class($params);
     }
     return false;
 }
 public function execute()
 {
     //SESSION
     $session = SessionFactory::create();
     $selectedRoleId = $session->get('selected-role-id');
     //ACTIONS
     $actions = ActionFactory::create();
     $datahandler = DatahandlerFactory::create('D_UpdateActions');
     $data = $datahandler->setIndata($actions);
     //REDIRECTOR
     $redirector = RedirectorFactory::create();
     $redirector->redirectTo('index.php?selected-role-id=' . $selectedRoleId . '&A_ReadActionsWithStatus');
 }
 private function get_update_action($sel_increment, &$user_input, &$plugin_cookies)
 {
     $parent_media_url = MediaURL::decode($user_input->parent_media_url);
     $num_favorites = count($this->tv->get_fav_channel_ids($plugin_cookies));
     $sel_ndx = $user_input->sel_ndx + $sel_increment;
     if ($sel_ndx < 0) {
         $sel_ndx = 0;
     }
     if ($sel_ndx >= $num_favorites) {
         $sel_ndx = $num_favorites - 1;
     }
     $range = HD::create_regular_folder_range($this->get_all_folder_items($parent_media_url, $plugin_cookies));
     return ActionFactory::update_regular_folder($range, true, $sel_ndx);
 }
Beispiel #18
0
 private function addNextToChunk($chunckArray, $currentChunk, $index)
 {
     hd_print(__METHOD__);
     // hd_print('chunckArray =' . print_r($chunckArray, true));
     // hd_print('currentChunk =' . print_r($currentChunk, true));
     // hd_print('index =' . print_r($index, true));
     if ($index >= count($chunckArray)) {
         hd_print('é maior' . print_r($currentChunk, true));
         return $currentChunk;
     } else {
         hd_print('Não é maior');
     }
     $currentChunk[] = $chunckArray[$index];
     $currentChunk[] = array(GuiMenuItemDef::is_separator => true);
     $currentChunk[] = array(GuiMenuItemDef::caption => $this->nextText, GuiMenuItemDef::action => ActionFactory::show_popup_menu($this->addNextToChunk($chunckArray, $currentChunk, $index + 1)));
 }
Beispiel #19
0
 public static function deregister()
 {
     if (!self::$_logged_in) {
         return false;
     }
     $result = ZTVDaemonController::deregister();
     if ($result->output === false) {
         hd_print('Error: can not execute arescam.');
         throw new DuneException('%tr%caption_system_error', 0, ActionFactory::show_error(true, '%tr%caption_system_error', array('%tr%error_daemon_execution_failed', '%tr%error_contact_support')));
     }
     if ($result->rc === 0) {
         self::$_logged_in = false;
         self::$_login_expire = 0;
         return true;
     }
     return false;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'remove_favorite') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $movie_id = $media_url->movie_id;
         $this->vod->remove_favorite_movie($movie_id, $plugin_cookies);
         return ActionFactory::invalidate_folders(array(self::get_media_url_str($movie_id)));
     }
     return null;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod genres: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'select_genre') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $genre_id = $media_url->genre_id;
         $caption = $this->vod->get_genre_caption($genre_id);
         $media_url_str = $this->vod->get_genre_media_url_str($genre_id);
         return ActionFactory::open_folder($media_url_str, $caption);
     }
     return null;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Movie: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'favorites') {
         $movie_id = $user_input->movie_id;
         $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
         if ($is_favorite) {
             $this->vod->remove_favorite_movie($movie_id, $plugin_cookies);
         } else {
             $this->vod->add_favorite_movie($movie_id, $plugin_cookies);
         }
         $message = $is_favorite ? 'Movie has been removed from My Movies' : 'Movie has been added to My Movies';
         return ActionFactory::show_title_dialog($message, ActionFactory::invalidate_folders(array(self::get_media_url_str($movie_id), VodFavoritesScreen::get_media_url_str())));
     }
     return null;
 }
 public function execute()
 {
     //SESSION
     $session = SessionFactory::create();
     if ($session->get("authenticated") == null) {
         $session->set("authenticated", false);
     }
     if ($session->get("authorized") == null) {
         $session->set("authorized", false);
     }
     //ACTIONS
     $actions = ActionFactory::create();
     //REQUESTHANDLER AND SELECTACTIONKEY
     $requestHandler = RequestHandlerFactory::create();
     $selectedActionKey = $requestHandler->getSelectedActionKey();
     //VALIDATOR
     $validator = ValidatorFactory::create();
     //REDIRECTOR
     $redirector = RedirectorFactory::create();
     ////LOGICA DE AUTENTICACIÓN Y AUTORIZACIÓN:
     //Si no está autenticado se ejecuta la acción de autenticación
     //, esto podría ser también si selecciona Authenticate
     $validator->ifFalse($session->get("authenticated"))->execute($actions['A_Authenticate']);
     //Si selecciona Logout Action se le permite ejecutar siempre.
     $validator->ifTrue($selectedActionKey == 'A_Logout')->execute($actions['A_Logout']);
     //Si después de ser autenticado entra aquí no está autenticado
     //se ejecuta Logout:
     $validator->ifFalse($session->get("authenticated"))->execute($actions['A_Logout']);
     //Si está autenticado y no autorizado se ejecuta la acción de autorización
     //(siempre se debe autorizar, para que esto sea más eficiente armar un cache en
     //session con las acciones autorizadas)
     $actions['A_Authorize']->execute();
     //Si está autenticado y no autorizado:
     // $validator->ifFalse( $authorizer->isAuthorized() )
     $validator->ifFalse($session->get("authorized"))->respond(NO_AUTHORIZED_ACTION);
     /*Si está autenticado y autorizado y quiere ejecutar login lo 
     		redirijo a default a default action:*/
     $validator->ifTrue($selectedActionKey == "A_Authenticate")->redirectTo('index.php?A_EnterFilterDataForm');
     //Si está autenticado y autorizado y ejecuta una acción no existente
     $validator->ifFalse(array_key_exists($selectedActionKey, $actions))->respond($selectedActionKey . " " . NOT_IMPLEMENTED);
     //Si está autenticado y autorizado y ejecuta una acción existente
     $actions[$selectedActionKey]->execute();
 }
 public function execute()
 {
     switch ($_REQUEST['checkout_type']) {
         case 'cart':
             $paymentMethodID = $this->getParam('payment_method_id');
             if (!$paymentMethodID) {
                 $this->setError('', 'Payment_method_id is empty.');
             } else {
                 $actionInstance = ActionFactory::factory('KanCart.ShoppingCart.Checkout');
                 $actionInstance->init();
                 $actionInstance->execute();
                 $this->result = $actionInstance->getResult();
             }
             break;
         case 'order':
             break;
         default:
             break;
     }
 }
Beispiel #25
0
 public static function call($json_request)
 {
     $json_reply = null;
     for ($i = 0; $i < 3; ++$i) {
         try {
             $doc = HD::http_post_document(static::API_URL, json_encode($json_request));
             $json_reply = json_decode($doc);
         } catch (Exception $e) {
             hd_print('Error: failed to do HTTP-request.');
             if ($i == 2) {
                 throw new DuneException('API is unavailable', 0, ActionFactory::show_error(true, 'Системная ошибка', array('Сервер недоступен(' . $e->getMessage() . ').', 'Пожалуйста обратитесь в тех. поддержку.')));
             }
             usleep(100000 << $i);
             continue;
         }
         break;
     }
     if (is_null($json_reply)) {
         hd_print("Error: failed to decode API reply: '{$doc}'");
         throw new DuneException('API returned empty result', 0, ActionFactory::show_error(true, 'Системная ошибка', array('Сервер вернул пустой ответ.', 'Пожалуйста обратитесь в тех. поддержку.')));
     }
     if (isset($json_reply->error) && $json_reply->error) {
         hd_print("Error: API returned error status({$doc})");
         throw new DuneException('API returned error', $json_reply->code, ActionFactory::show_error(true, 'Системная ошибка', array('Сервер вернул ошибку(' . $json_reply->message . ').', 'Пожалуйста обратитесь в тех. поддержку.')));
     }
     // TODO: Think of a better check.
     if (!isset($json_request['method'])) {
         $request_count = count($json_request);
         $reply_count = count($json_reply);
         if ($request_count != $reply_count) {
             return false;
         }
         for ($i = 0, $n = 0; $i < $reply_count; $n = $n + ($json_reply[$i]->result ? 1 : 0), $i++) {
         }
         if ($i != $n) {
             return false;
         }
     }
     return $json_reply;
 }
Beispiel #26
0
 /**
  * Materialize view by IDs in changelog
  *
  * @return void
  * @throws \Exception
  */
 public function update()
 {
     if ($this->getState()->getMode() == View\StateInterface::MODE_ENABLED && $this->getState()->getStatus() == View\StateInterface::STATUS_IDLE) {
         $currentVersionId = $this->getChangelog()->getVersion();
         $lastVersionId = $this->getState()->getVersionId();
         $ids = $this->getChangelog()->getList($lastVersionId, $currentVersionId);
         if ($ids) {
             $action = $this->actionFactory->get($this->getActionClass());
             $this->getState()->setStatus(View\StateInterface::STATUS_WORKING)->save();
             try {
                 $action->execute($ids);
                 $this->getState()->loadByView($this->getId());
                 $statusToRestore = $this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED ? View\StateInterface::STATUS_SUSPENDED : View\StateInterface::STATUS_IDLE;
                 $this->getState()->setVersionId($currentVersionId)->setStatus($statusToRestore)->save();
             } catch (\Exception $exception) {
                 $this->getState()->loadByView($this->getId());
                 $statusToRestore = $this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED ? View\StateInterface::STATUS_SUSPENDED : View\StateInterface::STATUS_IDLE;
                 $this->getState()->setStatus($statusToRestore)->save();
                 throw $exception;
             }
         }
     }
 }
 public function getPlexBaseUrl(&$plugin_cookies, $handler)
 {
     //    hd_print(__METHOD__ . ':' . print_r($plugin_cookies, true));
     // if ($currentPlexBaseUR) {
     //     return $currentPlexBaseUR;
     // }else {
     // hd_print(__METHOD__);
     $plexIp = $plugin_cookies->plexIp;
     $plexPort = $plugin_cookies->plexPort;
     //quick fix.
     //caso o usuário tenha instalado por cima de uma versão antiga que ainda não tenha esses items esses não são setados.
     //caso esses não sejam setados o plugin não consegue achar o conection type e com isso não sabe qual url usar.
     $connectionMethod = $plugin_cookies->connectionMethod ? $plugin_cookies->connectionMethod : HTTP_CONNECTION_TYPE;
     $hasSeenCaptionColor = $plugin_cookies->hasSeenCaptionColor ? $plugin_cookies->hasSeenCaptionColor : DEFAULT_HAS_SEEN_CAPTION_COLOR;
     $notSeenCaptionColor = $plugin_cookies->notSeenCaptionColor ? $plugin_cookies->notSeenCaptionColor : DEFAULT_NOT_SEEN_CAPTION_COLOR;
     if (!$plexIp || !$plexPort) {
         $btnSaveAction = UserInputHandlerRegistry::create_action($handler, 'savePref');
         throw new DuneException('Error: emplexer not configured, please go to setup and set ip and port', 0, ActionFactory::show_configuration_modal('configure your emplexer.', $plugin_cookies, $btnSaveAction));
     }
     //checa se precisa criar o cache_dir;
     EmplexerConfig::getInstance()->createCacheDirIfNeeded($plugin_cookies);
     return "http://{$plexIp}:{$plexPort}";
     // }
 }
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
* 
*****/
require_once "class.ActionFactory.php";
$search_phrase = $_REQUEST['msg'];
$lookup_object = ActionFactory::get_lookup_object($search_phrase, "cricket");
echo "SEARCH PHRASE " . $search_phrase . "<br>";
$type = $lookup_object->get_type();
echo "TYPE " . $type . "<br>";
switch ($type) {
    case "cricket":
        perform_cricket_search($lookup_object);
        break;
    case "help":
        echo $lookup_object->the_output();
        break;
    case "credits":
        echo $lookup_object->the_output();
        break;
    default:
        $lookup_object = new DefaultLookup($search_phrase, "cricket");
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Tv favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'info') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $channel_id = $media_url->channel_id;
         $channels = $this->tv->get_channels();
         $c = $channels->get($channel_id);
         $id = $c->get_id();
         $title = $c->get_title();
         return ActionFactory::show_title_dialog("Channel '{$title}' (id={$id})");
     } else {
         if ($user_input->control_id == 'popup_menu') {
             if (!isset($user_input->selected_media_url)) {
                 return null;
             }
             $media_url = MediaURL::decode($user_input->selected_media_url);
             $channel_id = $media_url->channel_id;
             $is_favorite = $this->tv->is_favorite_channel_id($channel_id, $plugin_cookies);
             $add_favorite_action = UserInputHandlerRegistry::create_action($this, 'add_favorite');
             $caption = 'Add to Favorites';
             $menu_items[] = array(GuiMenuItemDef::caption => $caption, GuiMenuItemDef::action => $add_favorite_action);
             return ActionFactory::show_popup_menu($menu_items);
         } else {
             if ($user_input->control_id == 'add_favorite') {
                 if (!isset($user_input->selected_media_url)) {
                     return null;
                 }
                 $media_url = MediaURL::decode($user_input->selected_media_url);
                 $channel_id = $media_url->channel_id;
                 $is_favorite = $this->tv->is_favorite_channel_id($channel_id, $plugin_cookies);
                 if ($is_favorite) {
                     return ActionFactory::show_title_dialog('Channel already resides in Favorites', $this->get_sel_item_update_action($user_input, $plugin_cookies));
                 } else {
                     $this->tv->change_tv_favorites(PLUGIN_FAVORITES_OP_ADD, $channel_id, $plugin_cookies);
                     return ActionFactory::show_title_dialog('Channel has been added to Favorites', $this->get_sel_item_update_action($user_input, $plugin_cookies));
                 }
             }
         }
     }
     return null;
 }
Beispiel #30
0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
* 
*****/
require_once "class.ActionFactory.php";
$search_phrase = $_REQUEST['msg'];
$lookup_object = ActionFactory::get_lookup_object($search_phrase, "twitter");
$type = $lookup_object->get_type();
echo "<a href='form.php'>NEXT SEARCH</a><br />";
echo get_output($lookup_object);
unset($lookup_object);
function get_output($lookup_object)
{
    $got_errors = false;
    if ($lookup_object->is_ready() && $lookup_object->is_search()) {
        $got_results = $lookup_object->_perform();
        if ($got_results) {
            $defintions = $lookup_object->the_output();
            if (is_array($defintions)) {
                //Util::print_array($defintions);
                if ($defintions[$lookup_object->get_type()]) {
                    foreach ($defintions[$lookup_object->get_type()] as $defi) {