/** * Public function that creates a single instance */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Show confirmation form before removing item from page */ private function pageItems_Delete() { global $language; $id = fix_id($_REQUEST['id']); $manager = UserPageItemsManager::getInstance(); // grab item from database $item = $manager->getSingleItem($manager->getFieldNames(), array('id' => $id)); if ($item->type == user_page::VIDEO) { // get video title $video_manager = YouTube_VideoManager::getInstance(); $name = $video_manager->getItemValue('title', array('id' => $item->item)); } else { // get gallery title $gallery_manager = GalleryGroupManager::getInstance(); $name = $gallery_manager->getItemValue('name', array('id' => $item->item)); } // create template $template = new TemplateHandler('confirmation.xml', $this->path . 'templates/'); $template->setMappedModule($this->name); // parse template $params = array('message' => $this->getLanguageConstant('message_page_item_delete'), 'name' => $name, 'yes_text' => $this->getLanguageConstant('delete'), 'no_text' => $this->getLanguageConstant('cancel'), 'yes_action' => window_LoadContent('user_pages_items_delete', url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'page_items_delete_commit'), array('id', $id))), 'no_action' => window_Close('user_pages_items_delete')); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); }
/** * Generate list of videos in for of a JSON object */ private function json_VideoList() { global $language; $limit = isset($tag_params['limit']) ? fix_id($tag_params['limit']) : null; $order_by = isset($tag_params['order_by']) ? explode(',', fix_chars($tag_params['order_by'])) : array('id'); $order_asc = isset($tag_params['order_asc']) && $tag_params['order_asc'] == 'yes' ? true : false; $all_languages = isset($_REQUEST['all_languages']) && $_REQUEST['all_languages'] == 'yes'; $manager = YouTube_VideoManager::getInstance(); $items = $manager->getItems($manager->getFieldNames(), array(), $order_by, $order_asc, $limit); $result = array('error' => false, 'error_message' => '', 'items' => array()); if (count($items) > 0) { foreach ($items as $item) { $result['items'][] = array('id' => $item->id, 'video_id' => $item->video_id, 'title' => $all_languages ? $item->title : $item->title[$language], 'thumbnail' => $this->getThumbnailURL($item->video_id)); } } else { } print json_encode($result); }