public function get_search_request($args) { $authorized_categories = MediaService::get_authorized_categories(Category::ROOT_CATEGORY); $weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1; $request = "SELECT " . $args['id_search'] . " AS id_search,\r\n\t\t\tf.id AS id_content,\r\n\t\t\tf.name AS title,\r\n\t\t\t( 2 * FT_SEARCH_RELEVANCE(f.name, '" . $args['search'] . "') + FT_SEARCH_RELEVANCE(f.contents, '" . $args['search'] . "') ) / 3 * " . $weight . " AS relevance,\r\n\t\t\tCONCAT('" . PATH_TO_ROOT . "/media/media.php?id=', f.id, '&cat=', f.idcat) AS link\r\n\t\t\tFROM " . PREFIX . "media f\r\n\t\t\tWHERE ( FT_SEARCH(f.name, '" . $args['search'] . "') OR FT_SEARCH(f.contents, '" . $args['search'] . "') )\r\n\t\t\tAND idcat IN (" . implode(", ", $authorized_categories) . ")\r\n\t\t\tORDER BY relevance DESC\r\n\t\t\tLIMIT " . MEDIA_MAX_SEARCH_RESULTS . " OFFSET 0"; return $request; }
/** * @desc Return the categories manager. */ public static function get_categories_manager() { if (self::$categories_manager === null) { $categories_items_parameters = new CategoriesItemsParameters(); $categories_items_parameters->set_table_name_contains_items(MediaSetup::$media_table); $categories_items_parameters->set_field_name_id_category('idcat'); self::$categories_manager = new CategoriesManager(MediaCategoriesCache::load(), $categories_items_parameters); } return self::$categories_manager; }
/** * Draws this datatype as a HTML widget directly into the output stream */ function drawWidget() { $mediaService = new MediaService(); $fileArray = $mediaService->listMedia(); ?> <select name="<?php echo $this->getName()?>" id="<?php echo $this->getName()?>"> <option value=""></option> <?php foreach($fileArray as $file) { /* @var $file File */ $selected = ""; if ($file->getHttpPath() == $this->getValue()) $selected = "selected=\"selected\""; ?> <option <?php echo $selected?> value="<?php echo $file->getHttpPath()?>"><?php echo $file->getTitle()?></option> <?php }?> </select> <? }
function bread_crumb($id) { global $Bread_crumb; $Bread_crumb->add(LangLoader::get_message('module_title', 'common', 'media'), MediaUrlBuilder::home()); $categories = array_reverse(MediaService::get_categories_manager()->get_parents($id, true)); foreach ($categories as $category) { if ($category->get_id() != Category::ROOT_CATEGORY) { $Bread_crumb->add($category->get_name(), url('media.php?cat=' . $category->get_id(), 'media-0-' . $category->get_id() . '+' . $category->get_rewrited_name() . '.php')); } } }
/** * Return a list of related videos for a specific video entry * * @action listRelatedMedieEntries * @param string $entryId * @param KalturaRelatedScope $scope * @param KalturaFilterPager $pager * @return KalturaMediaListResponse */ public function listRelatedMedieEntriesAction($entryId, KalturaRelatedScope $scope = null, KalturaFilterPager $pager = null) { $mediaService = new MediaService(); $mediaService->initService('media', 'media', 'get'); $entry = $mediaService->getAction($entryId); if (!$scope) { $scope = new KalturaRelatedScope(); } if (!$pager) { $pager = new KalturaFilterPager(); } $originalKs = kCurrentContext::$ks; $adminKs = $this->getAdminSessionForPartner($entry->partnerId); $mediaEntryFilter = new KalturaMediaEntryFilter(); $mediaEntryFilter->tagsMultiLikeOr = $entry->tags; $mediaEntryFilter->orderBy = KalturaMediaEntryOrderBy::CREATED_AT_DESC; $mediaEntryFilter->advancedSearch = $this->getAdvancedSearch($entry, $scope); kCurrentContext::initKsPartnerUser($adminKs); $mediaService->initService('media', 'media', 'list'); $response = $mediaService->listAction($mediaEntryFilter, $pager); kCurrentContext::initKsPartnerUser($originalKs); return $response; }
function get_feed_data_struct($idcat = 0, $name = '') { if (MediaService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) { require_once PATH_TO_ROOT . '/media/media_constant.php'; $category = MediaService::get_categories_manager()->get_categories_cache()->get_category($idcat); $site_name = GeneralConfig::load()->get_site_name(); $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name; $feed_module_name = LangLoader::get_message('module_title', 'common', 'media'); $data = new FeedData(); $data->set_title($feed_module_name . ' - ' . $site_name); $data->set_date(new Date()); $data->set_link(SyndicationUrlBuilder::rss('media', $idcat)); $data->set_host(HOST); $data->set_desc($feed_module_name . ' - ' . $site_name); $data->set_lang(LangLoader::get_message('xml_lang', 'main')); $data->set_auth_bit(Category::READ_AUTHORIZATIONS); $categories = MediaService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true); $ids_categories = array_keys($categories); $results = PersistenceContext::get_querier()->select('SELECT media.*, cat.image FROM ' . MediaSetup::$media_table . ' media LEFT JOIN ' . MediaSetup::$media_cats_table . ' cat ON cat.id = media.idcat WHERE media.idcat IN :ids_categories AND infos = :status_approved ORDER BY timestamp DESC', array('ids_categories' => $ids_categories, 'status_approved' => MEDIA_STATUS_APROBED)); foreach ($results as $row) { // Rewriting $link = new Url('/media/media' . url('.php?id=' . $row['id'], '-' . $row['id'] . '+' . Url::encode_rewrite($row['name']) . '.php')); $item = new FeedItem(); $item->set_title($row['name']); $item->set_link($link); $item->set_guid($link); $item->set_desc(FormatingHelper::second_parse($row['contents'])); $item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE)); $item->set_image_url($row['image']); $item->set_auth(MediaService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY)); $enclosure = new FeedItemEnclosure(); $enclosure->set_lenght(@filesize($row['url'])); $enclosure->set_type($row['mime_type']); $enclosure->set_url($row['url']); $item->set_enclosure($enclosure); $data->add_item($item); } $results->dispose(); return $data; } }
/** * Uploads and extracts an archive, placing them in temporary nodes for handling. */ public function uploadArchive() { $params = $this->Request->getParameters(); $files = $this->Request->getUploadedFiles(); try { $params['_uploadedFiles'] = $files; $nodes = $this->MediaService->uploadArchive($params); if (!is_array($nodes)) { $nodes = array($nodes); } // build output $output = array('totalRecords' => count($nodes), 'nodes' => array()); foreach ($nodes as $node) { $c = $this->_buildNodeJSON($node, true, true); $output['nodes'][] = $c; } $this->sendJSON($output); } catch (Exception $e) { $this->sendExceptionError($e); } }
protected function get_categories_manager() { return MediaService::get_categories_manager(); }
Feed::clear_cache('media'); AppContext::get_response()->redirect('media' . url('.php?id=' . $media['idedit'])); } elseif (!$media['idedit'] && (($auth_write = MediaAuthorizationsService::check_authorizations($media['idcat'])->write()) || MediaAuthorizationsService::check_authorizations($media['idcat'])->contribution())) { $result = PersistenceContext::get_querier()->insert(PREFIX . "media", array('idcat' => $media['idcat'], 'iduser' => AppContext::get_current_user()->get_id(), 'timestamp' => time(), 'name' => $media['name'], 'contents' => FormatingHelper::strparse($media['contents']), 'url' => $media['url'], 'mime_type' => $media['mime_type'], 'infos' => MediaAuthorizationsService::check_authorizations($media['idcat'])->write() ? MEDIA_STATUS_APROBED : 0, 'width' => $media['width'], 'height' => $media['height'])); $new_id_media = $result->get_last_inserted_id(); // Feeds Regeneration Feed::clear_cache('media'); if (!$auth_write) { $media_contribution = new Contribution(); $media_contribution->set_id_in_module($new_id_media); $media_contribution->set_description(stripslashes($media['counterpart'])); $media_contribution->set_entitled($media['name']); $media_contribution->set_fixing_url('/media/media_action.php?edit=' . $new_id_media); $media_contribution->set_poster_id(AppContext::get_current_user()->get_id()); $media_contribution->set_module('media'); $media_contribution->set_auth(Authorizations::capture_and_shift_bit_auth(MediaService::get_categories_manager()->get_heritated_authorizations($media['idcat'], Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT)); ContributionService::save_contribution($media_contribution); DispatchManager::redirect(new UserContributionSuccessController()); } else { AppContext::get_response()->redirect('media' . url('.php?id=' . $new_id_media)); } } else { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } } else { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $tpl->display(); require_once '../kernel/footer.php';
private function generate_response() { $response = new SiteDisplayResponse($this->tpl); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->get_category()->get_name(), $this->lang['module_title']); $graphical_environment->get_seo_meta_data()->set_description($this->get_category()->get_description()); $graphical_environment->get_seo_meta_data()->set_canonical_url(MediaUrlBuilder::display_category($this->get_category()->get_id(), $this->get_category()->get_rewrited_name(), AppContext::get_request()->get_getint('page', 1))); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], MediaUrlBuilder::home()); $categories = array_reverse(MediaService::get_categories_manager()->get_parents($this->get_category()->get_id(), true)); foreach ($categories as $id => $category) { if ($category->get_id() != Category::ROOT_CATEGORY) { $breadcrumb->add($category->get_name(), MediaUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())); } } return $response; }
public function __construct() { parent::__construct(MediaService::get_categories_manager()); }
bread_crumb($media['idcat']); $Bread_crumb->add($media['name'], url('media.php?id=' . $id_media, 'media-' . $id_media . '-' . $media['idcat'] . '+' . Url::encode_rewrite($media['name']) . '.php')); define('TITLE', $media['name']); require_once '../kernel/header.php'; //MAJ du compteur. PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "media SET counter = counter + 1 WHERE id = :id", array('id' => $id_media)); $notation = new Notation(); $notation->set_module_name('media'); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_id_in_module($id_media); $notation->set_number_notes($media['number_notes']); $notation->set_average_notes($media['average_notes']); $notation->set_user_already_noted(!empty($media['note'])); $nbr_notes = $media['number_notes']; $group_color = User::get_group_color($media['groups'], $media['level']); $tpl->put_all(array('ID' => $id_media, 'C_DISPLAY_MEDIA' => true, 'C_ROOT_CATEGORY' => $media['idcat'] == Category::ROOT_CATEGORY, 'C_MODO' => MediaAuthorizationsService::check_authorizations($media['idcat'])->moderation(), 'C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'ID_MEDIA' => $id_media, 'NAME' => $media['name'], 'CONTENTS' => stripslashes(FormatingHelper::second_parse($media['contents'])), 'COUNT' => $media['counter'], 'KERNEL_NOTATION' => NotationService::display_active_image($notation), 'HITS' => (int) $media['counter'] + 1 > 1 ? sprintf($MEDIA_LANG['n_times'], (int) $media['counter'] + 1) : sprintf($MEDIA_LANG['n_time'], (int) $media['counter'] + 1), 'U_COM' => PATH_TO_ROOT . '/media/media' . url('.php?id=' . $id_media . '&com=0', '-' . $id_media . '-' . $media['idcat'] . '+' . Url::encode_rewrite($media['name']) . '.php?com=0') . '#comments-list', 'L_COM' => CommentsService::get_number_and_lang_comments('media', $id_media), 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_SIZE' => $LANG['size'], 'L_MEDIA_INFOS' => $MEDIA_LANG['media_infos'], 'DATE' => Date::to_format($media['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'L_MODO_PANEL' => $LANG['modo_panel'], 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'HEIGHT_P' => $media['height'] + 50, 'L_VIEWED' => $LANG['view'], 'L_BY' => $LANG['by'], 'BY' => !empty($media['display_name']) ? '<a href="' . UserUrlBuilder::profile($media['iduser'])->rel() . '" class="' . UserService::get_level_class($media['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $media['display_name'] . '</a>' : $LANG['guest'], 'U_UNVISIBLE_MEDIA' => url('media_action.php?unvisible=' . $id_media . '&token=' . AppContext::get_session()->get_token()), 'U_EDIT_MEDIA' => url('media_action.php?edit=' . $id_media), 'U_DELETE_MEDIA' => url('media_action.php?del=' . $id_media . '&token=' . AppContext::get_session()->get_token()), 'U_POPUP_MEDIA' => url('media_popup.php?id=' . $id_media), 'CATEGORY_NAME' => $media['idcat'] == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : MediaService::get_categories_manager()->get_categories_cache()->get_category($media['idcat'])->get_name(), 'U_EDIT_CATEGORY' => $media['idcat'] == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($media['idcat'])->rel())); if (empty($mime_type_tpl[$media['mime_type']])) { $media_tpl = new FileTemplate('media/format/media_other.tpl'); } else { $media_tpl = new FileTemplate('media/' . $mime_type_tpl[$media['mime_type']]); } $media_tpl->put_all(array('URL' => $media['url'], 'MIME' => $media['mime_type'], 'WIDTH' => $media['width'], 'HEIGHT' => $media['height'])); $tpl->put('media_format', $media_tpl); //Affichage commentaires. if (AppContext::get_request()->get_getint('com', 0) == 0) { $comments_topic = new MediaCommentsTopic(); $comments_topic->set_id_in_module($id_media); $comments_topic->set_url(new Url('/media/media.php?id=' . $id_media . '&com=0')); $tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render())); } $tpl->display();
/** * Get content of an experience details - this function is called by two above funtions * @param String $experienceId: id of the SharcExperience * @param String $designerId: id of the designer * @param String $userId: id of the SharcUser */ public static function getSnapshotForSpvt($designerId, $experienceId, $userId) { $response = array(); $response["status"] = SUCCESS; //Get all POIs of the experience $objPois = SharcPoiExperience::where('experienceId', $experienceId)->get(); $tmpPois = $objPois->toArray(); $i = 0; for ($i; $i < $objPois->count(); $i++) { $rs = SharcPoiDesigner::where('id', $objPois[$i]->poiDesignerId)->where('designerId', $designerId)->get(); $tmpPois[$i]["poiDesigner"] = $rs[0]->toArray(); //Thumbnail $media = SharcMediaExperience::where('entityId', $objPois[$i]->id)->where('entityType', 'POI')->where('mainMedia', 1)->get(); if ($media->count() > 0) { $mediaDesigner = SharcMediaDesigner::where('id', $media[0]->mediaDesignerId)->where('designerId', $designerId)->get(); if ($mediaDesigner->count() > 0) { $tmpPois[$i]["thumbnail"] = $mediaDesigner[0]->content; } else { $tmpPois[$i]["thumbnail"] = ""; } } else { $tmpPois[$i]["thumbnail"] = ""; } //Media for POI $media = MediaService::getMediaForEntityServer($designerId, $experienceId, $objPois[$i]->id, "POI"); $tmpPois[$i]["media"] = $media->toArray(); //Responses for POI by this user $tmpPois[$i]["responses"] = SharcResponse::where('experienceId', $experienceId)->where('userId', $userId)->where('entityId', $objPois[$i]->id)->get()->toArray(); } $response["data"]["allPois"] = $tmpPois; //Get all Routes of the experience $objRoutes = SharcRouteExperience::where('experienceId', $experienceId)->get(); $tmpRoutes = $objRoutes->toArray(); $i = 0; for ($i; $i < $objRoutes->count(); $i++) { $rs = SharcRouteDesigner::where('id', $objRoutes[$i]->routeDesignerId)->where('designerId', $designerId)->get(); $tmpRoutes[$i]["routeDesigner"] = $rs[0]->toArray(); } $response["data"]["allRoutes"] = $tmpRoutes; //Get all responses $response["data"]["allResponses"] = SharcResponse::where('experienceId', $experienceId)->where('userId', $userId)->where('entityType', 'NEW')->get()->toArray(); return $response; }
/** * Create a new Response = 1 SharcResponseDesigner + 1 SharcResponseExperience * @param String $objResponse: a json object containing info of both Response */ public static function addNewResponse($objResponse) { $response = array(); try { //'contentType', 'content', 'size', 'designerId' $sharcResponse = SharcResponse::create(array('id' => $objResponse['id'], 'experienceId' => $objResponse['experienceId'], 'userId' => $objResponse['userId'], 'contentType' => $objResponse['contentType'], 'content' => $objResponse['content'], 'description' => $objResponse['description'], 'entityType' => $objResponse['entityType'], 'entityId' => $objResponse['entityId'], 'status' => $objResponse['status'], 'size' => $objResponse['size'], 'submittedDate' => $objResponse['submittedDate'], 'fileId' => $objResponse['fileId'])); $experience = SharcExperience::find($sharcResponse->experienceId); $status = ""; if ($experience != null) { //change status of response based on moderation mode switch ($experience->moderationMode) { case 0: $sharcResponse->status = "accepted"; $status = "accepted. Other people will be able to see your response"; //Create a mew POI here if response is for a new location if ($sharcResponse->entityType == "NEW") { //Create a new POI $objPoi = array(); $objPoi['id'] = 0; $objPoi['experienceId'] = $sharcResponse->experienceId; $objPoi['description'] = "Created from a response"; $objPoi['typeList'] = ""; $objPoi['eoiList'] = ""; $objPoi['routeList'] = ""; $objPoi['poiDesigner'] = array(); $objPoi['poiDesigner']['id'] = 0; $objPoi['poiDesigner']['name'] = $sharcResponse->description . " (created by a user named {$curResponse->userId})"; $objPoi['poiDesigner']['coordinate'] = $sharcResponse->entityId; $objPoi['poiDesigner']['triggerZone'] = "circle 00ff00 20 " . $sharcResponse->entityId; $objPoi['poiDesigner']['designerId'] = $experience->designerId; $response = PoiService::addNewPoi($objPoi); //Create a media if ($response["status"] == SUCCESS) { $objMedia = array(); $objMedia['id'] = 0; $objMedia['entityType'] = "POI"; $objMedia['entityId'] = $response['data']['id']; $objMedia['experienceId'] = $sharcResponse->experienceId; $objMedia['caption'] = $sharcResponse->description; $objMedia['context'] = ""; if ($sharcResponse->contentType == "image") { $objMedia['mainMedia'] = 1; } else { $objMedia['mainMedia'] = 0; } $objMedia['visible'] = 1; $objMedia['order'] = 0; $objMedia['mediaDesigner'] = array(); $objMedia['mediaDesigner']['id'] = $sharcResponse->id; $objMedia['mediaDesigner']['name'] = $sharcResponse->description; $objMedia['mediaDesigner']['contentType'] = $sharcResponse->contentType; $objMedia['mediaDesigner']['content'] = $sharcResponse->content; $objMedia['mediaDesigner']['size'] = $sharcResponse->size; $objMedia['mediaDesigner']['createdDate'] = $sharcResponse->submittedDate; $objMedia['mediaDesigner']['fileId'] = $sharcResponse->fileId; $objMedia['mediaDesigner']['designerId'] = $experience->designerId; $response = MediaService::addNewMedia($objMedia); } $sharcResponse->status = "Made a new POI"; } break; case 1: $sharcResponse->status = "waiting"; $status = "submitted and is waiting for moderation. We will notify you the outcome once the moderator has made a decision"; break; case 2: $sharcResponse->status = "private"; $status = "submitted successfully. However only you can see this response via our SPVT tool because the designer of this experience has chosen not to show responses in their experience"; break; } } $result = $sharcResponse->save(); if ($result) { //= 1 success $response["status"] = SUCCESS; $response["data"] = $sharcResponse->toArray(); $proName = $experience->name; //Get consumer info $user = SharcUser::find($sharcResponse->userId); $conEmail = $user->email; $conName = $user->username; //Sending email to designer if moderate is needed $subject = "A new response from SMEP"; if ($experience->moderationMode == 1) { $user = SharcUser::find($experience->designerId); $authEmail = $user->email; $authName = $user->username; $msg = "Dear {$authName} \n\nA response has been submitted to your {$proName} experience by {$conName}. Please sign into SLAT to moderate the response. Once you have logged in, please go to menu Response -> Moderate new responses \n\nPlease do not reply to this automatic email. You can contact us at thesharcproject@gmail.com.\n\nThank you.\n\nThe SHARC project team."; $headers = "From: SHARC-Authoring-Tool" . "\r\n" . "CC: thesharcproject@gmail.com"; // use wordwrap() if lines are longer than 70 characters //$msg = wordwrap($msg,70); mail($authEmail, $subject, $msg, $headers); } $msg = "Dear {$conName} \n\nYour response to the {$proName} experience has been {$status}.\n\nPlease do not reply to this automatic email. You can contact us at thesharcproject@gmail.com.\n\nThank you.\n\nThe SHARC project team."; $headers = "From: SMET" . "\r\n" . "CC: thesharcproject@gmail.com"; mail($conEmail, $subject, $msg, $headers); } else { //error $response["status"] = ERROR; $response["data"] = INTERNAL_SERVER_ERROR; } } catch (Exception $e) { $response["status"] = ERROR; $response["data"] = Utils::getExceptionMessage($e); } return $response; }
$rs = UserService::checkAuthentication($app->request->headers->get('apiKey')); if ($rs["status"] != SUCCESS) { Utils::echoResponse($rs); return; } $userId = $rs['data']->id; //So even with a valid apiKey, the designer can access her own resources only $response = ExperienceService::getExperienceOfConsumer($userId); Utils::echoResponse($response); }); //Get content of an experience for SPVT $app->get('/experienceSnapshotForSpvt/:experienceId/:userId', function ($experienceId, $userId) use($app) { $rs = UserService::checkAuthentication($app->request->headers->get('apiKey')); if ($rs["status"] != SUCCESS) { Utils::echoResponse($rs); return; } $userId = $rs['data']->id; //So even with a valid apiKey, the designer can access her own resources only $response = ExperienceService::getExperienceSnapshotForSpvt($experienceId, $userId); Utils::echoResponse($response); }); $app->map('/hello', function () { echo "Welcome to SHARC 2.0 RESTful Web services"; })->via('GET', 'POST'); $app->map('/test/:designerId/:experienceId', function ($designerId, $experienceId) { //$results = Capsule::se DB::s:select('select * from SharcUsers where id = ?', array(5)); //echo $results->toJson(); echo MediaService::getMediaSizeForExperience($designerId, $experienceId); })->via('GET'); $app->run();
/** * Update the content resource associated with the entry. * * @action updateContent * @param string $entryId Entry id to update * @param KalturaResource $resource Resource to be used to replace entry content * @param int $conversionProfileId The conversion profile id to be used on the entry * @return KalturaBaseEntry The updated entry * * @throws KalturaErrors::ENTRY_ID_NOT_FOUND * @validateUser entry entryId edit */ function updateContentAction($entryId, KalturaResource $resource, $conversionProfileId = null) { $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } $baseEntry = new KalturaBaseEntry(); $baseEntry->fromObject($dbEntry); switch ($dbEntry->getType()) { case entryType::MEDIA_CLIP: $service = new MediaService(); $service->initService('media', 'media', $this->actionName); $service->replaceResource($resource, $dbEntry, $conversionProfileId); $baseEntry->fromObject($dbEntry); return $baseEntry; case entryType::MIX: case entryType::PLAYLIST: case entryType::DATA: case entryType::LIVE_STREAM: default: // TODO load from plugin manager other entry services such as document throw new KalturaAPIException(KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED, $baseEntry->type); } return $baseEntry; }
} else { $db_where = null; } } else { $cat = 0; $db_where = null; $sub_cats = true; } $nbr_media = PersistenceContext::get_querier()->count(PREFIX . "media", 'WHERE ' . ($sub_cats && !empty($authorized_categories) ? 'idcat IN :authorized_categories' : 'idcat = :idcat') . (is_null($db_where) ? '' : ' AND infos = :infos'), array('authorized_categories' => $authorized_categories, 'idcat' => !empty($cat) ? $cat : 0, 'infos' => $db_where)); $categories_cache = MediaService::get_categories_manager()->get_categories_cache(); //On crée une pagination si le nombre de fichier est trop important. $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $nbr_media, $NUMBER_ELEMENTS_PER_PAGE); $pagination->set_url(new Url('/media/moderation_media.php?p=%d')); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $result = PersistenceContext::get_querier()->select("SELECT media.*, media_cats.name AS cat_name\n\t\tFROM " . MediaSetup::$media_table . " media\n\t\tLEFT JOIN " . MediaSetup::$media_cats_table . " media_cats ON media_cats.id = media.idcat\n\t\tWHERE " . ($sub_cats && !empty($authorized_categories) ? 'idcat IN :authorized_categories' : 'idcat = :idcat') . (is_null($db_where) ? '' : ' AND infos = :infos') . "\n\t\tORDER BY infos ASC, timestamp DESC\n\t\tLIMIT :number_items_per_page OFFSET :display_from", array('authorized_categories' => $authorized_categories, 'idcat' => !empty($cat) ? $cat : 0, 'infos' => $db_where, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { $js_array[] = $row['id']; $tpl->assign_block_vars('files', array('ID' => $row['id'], 'NAME' => $row['name'], 'U_FILE' => url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $row['idcat'] . '+' . Url::encode_rewrite($row['name']) . '.php'), 'U_EDIT' => url('media_action.php?edit=' . $row['id']), 'CAT' => $categories_cache->category_exists($row['idcat']) ? $row['cat_name'] : $LANG['unknown'], 'U_CAT' => url('media.php?cat=' . $row['idcat']), 'COLOR' => $row['infos'] == MEDIA_STATUS_UNVISIBLE ? '#FFEE99' : ($row['infos'] == MEDIA_STATUS_APROBED ? '#CCFFCC' : '#FFCCCC'), 'SHOW' => $row['infos'] == MEDIA_STATUS_APROBED ? ' checked="checked"' : '', 'HIDE' => $row['infos'] == MEDIA_STATUS_UNVISIBLE ? ' checked="checked"' : '', 'UNAPROBED' => $row['infos'] == MEDIA_STATUS_UNAPROBED ? ' checked="checked"' : '')); } $result->dispose(); $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS); $tpl->put_all(array('C_DISPLAY' => true, 'C_PAGINATION' => $pagination->has_several_pages(), 'L_FILTER' => $MEDIA_LANG['filter'], 'L_DISPLAY_FILE' => $MEDIA_LANG['display_file'], 'L_ALL' => $MEDIA_LANG['all_file'], 'SELECTED_ALL' => is_null($db_where) ? ' selected="selected"' : '', 'L_FVISIBLE' => $MEDIA_LANG['visible'], 'SELECTED_VISIBLE' => $db_where === MEDIA_STATUS_APROBED ? ' selected="selected"' : '', 'L_FUNVISIBLE' => $MEDIA_LANG['unvisible'], 'SELECTED_UNVISIBLE' => $db_where === MEDIA_STATUS_UNVISIBLE ? ' selected="selected"' : '', 'L_FUNAPROBED' => $MEDIA_LANG['unaprobed'], 'SELECTED_UNAPROBED' => $db_where === MEDIA_STATUS_UNAPROBED ? ' selected="selected"' : '', 'L_CATEGORIES' => $MEDIA_LANG['from_cats'], 'CATEGORIES_TREE' => MediaService::get_categories_manager()->get_select_categories_form_field('idcat', LangLoader::get_message('form.category', 'common'), $cat, $search_category_children_options)->display()->render(), 'L_INCLUDE_SUB_CATS' => $MEDIA_LANG['include_sub_cats'], 'SUB_CATS' => is_null($sub_cats) ? ' checked="checked"' : ($sub_cats ? ' checked="checked"' : ''), 'L_MODO_PANEL' => $LANG['modo_panel'], 'L_NAME' => $LANG['name'], 'L_VISIBLE' => $MEDIA_LANG['show_media_short'], 'L_UNVISIBLE' => $MEDIA_LANG['hide_media_short'], 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'C_NO_MODERATION' => $nbr_media > 0 ? 0 : 1, 'L_NO_MODERATION' => $MEDIA_LANG['no_media_moderate'], 'L_CONFIRM_DELETE_ALL' => str_replace('\'', '\\\'', $MEDIA_LANG['confirm_delete_media_all']), 'L_LEGEND' => $MEDIA_LANG['legend'], 'L_FILE_UNAPROBED' => $MEDIA_LANG['file_unaprobed'], 'L_FILE_UNVISIBLE' => $MEDIA_LANG['file_unvisible'], 'L_FILE_VISIBLE' => $MEDIA_LANG['file_visible'], 'PAGINATION' => $pagination->display(), 'L_SUBMIT' => $LANG['submit'], 'L_RESET' => $LANG['reset'], 'JS_ARRAY' => '"' . implode('", "', $js_array) . '"')); } $tpl->display(); require_once '../kernel/footer.php';
<?php require_once "service/mediaService.php"; $mediaService = new MediaService(); $fileArray = $mediaService->listImages(); echo "Files in images dir: "; print_r($fileArray);
private function is_authorized($bit, $mode = Authorizations::AUTH_CHILD_PRIORITY) { $auth = MediaService::get_categories_manager()->get_heritated_authorizations($this->id_category, $bit, $mode); return AppContext::get_current_user()->check_auth($auth, $bit); }
private function save() { $this->config->set_items_number_per_page($this->form->get_value('items_number_per_page')); $this->config->set_categories_number_per_page($this->form->get_value('categories_number_per_page')); $this->config->set_columns_number_per_line($this->form->get_value('columns_number_per_line')); if ($this->form->get_value('author_displayed')) { $this->config->display_author(); } else { $this->config->hide_author(); } if ($this->form->get_value('comments_enabled')) { $this->config->enable_comments(); } else { $this->config->disable_comments(); } if ($this->form->get_value('notation_enabled')) { $this->config->enable_notation(); $this->config->set_notation_scale($this->form->get_value('notation_scale')); if ($this->form->get_value('notation_scale') != $this->config->get_notation_scale()) { NotationService::update_notation_scale('media', $this->config->get_notation_scale(), $this->form->get_value('notation_scale')); } } else { $this->config->disable_notation(); } $this->config->set_max_video_width($this->form->get_value('max_video_width')); $this->config->set_max_video_height($this->form->get_value('max_video_height')); $this->config->set_root_category_description($this->form->get_value('root_category_description')); $this->config->set_root_category_content_type($this->form->get_value('root_category_content_type')->get_raw_value()); $this->config->set_authorizations($this->form->get_value('authorizations')->build_auth_array()); MediaConfig::save(); MediaService::get_categories_manager()->regenerate_cache(); }