/** * You too can do this in a plugin dependent on a, see the provided stylesheet * for how to correctly specify an icon to go with your button. See the * apostrophePluginConfiguration class for the registration of the event listener. */ public static function getGlobalButtons() { // Only if we have suitable credentials if (aMediaTools::userHasUploadPrivilege()) { aTools::addGlobalButtons(array(new aGlobalButton('media', 'Media', 'aMedia/index', 'a-media', '/admin/media', 'aMedia'))); } }
public static function listenToRoutingLoadConfigurationEvent(sfEvent $event) { $r = $event->getSubject(); if (aMediaTools::getOption("routes_register") && in_array('aMedia', sfConfig::get('sf_enabled_modules'))) { // Since the media plugin is now an engine, we need our own // catch-all rule for administrative URLs in the media area. // Prepending it first means it matches last $r->prependRoute('a_media_other', new aRoute('/:action', array('module' => 'aMedia'))); $r->prependRoute('a_media_image_show', new aRoute('/view/:slug', array('module' => 'aMedia', 'action' => 'show'), array('slug' => '^[\\w\\-]+$'))); // Allow permalinks for PDF originals $r->prependRoute('a_media_image_original', new sfRoute('/uploads/media_items/:slug.original.:format', array('module' => 'aMediaBackend', 'action' => 'original'), array('slug' => '^[\\w\\-]+$', 'format' => '^(jpg|png|gif|pdf)$'))); $r->prependRoute('a_media_image', new sfRoute('/uploads/media_items/:slug.:width.:height.:resizeType.:format', array('module' => 'aMediaBackend', 'action' => 'image'), array('slug' => '^[\\w\\-]+$', 'width' => '^\\d+$', 'height' => '^\\d+$', 'resizeType' => '^\\w$', 'format' => '^(jpg|png|gif)$'))); // What we want: // /media <-- everything // /image <-- media of type image // /video <-- media of type video // /tag/tagname <-- media with this tag // /image/tag/tagname <-- images with this tag // /video/tag/tagname <-- video with this tag // /media?search=blah blah blah <-- searches are full of // dirty URL-unfriendly characters and // are traditionally query strings. $r->prependRoute('a_media_index', new aRoute('/', array('module' => 'aMedia', 'action' => 'index'))); $r->prependRoute('a_media_index_type', new aRoute('/:type', array('module' => 'aMedia', 'action' => 'index'), array('type' => '(image|video)'))); $r->prependRoute('a_media_index_category', new aRoute('/category/:category', array('module' => 'aMedia', 'action' => 'index'), array('category' => '.*'))); $r->prependRoute('a_media_index_tag', new aRoute('/tag/:tag', array('module' => 'aMedia', 'action' => 'index'), array('tag' => '.*'))); $r->prependRoute('a_media_select', new aRoute('/select', array('class' => 'aRoute', 'module' => 'aMedia', 'action' => 'select'))); $r->prependRoute('a_media_info', new sfRoute('/info', array('module' => 'aMediaBackend', 'action' => 'info'))); $r->prependRoute('a_media_tags', new sfRoute('/tags', array('module' => 'aMediaBackend', 'action' => 'tags'))); $r->prependRoute('a_media_upload_images', new aRoute('/uploadImages', array('module' => 'aMedia', 'action' => 'uploadImages'))); $r->prependRoute('a_media_edit_images', new aRoute('/editImages', array('module' => 'aMedia', 'action' => 'editImages'))); $r->prependRoute('a_media_new_video', new aRoute('/newVideo', array('module' => 'aMedia', 'action' => 'newVideo'))); $r->prependRoute('a_media_edit_video', new aRoute('/editVideo', array('module' => 'aMedia', 'action' => 'editVideo'))); } }
/** * DOCUMENT ME * @param mixed $type * @param mixed $default * @return mixed */ protected function getExtensionFromType($type, $default = '') { $extensionsByMimeType = array_flip(aMediaTools::getOption('mime_types')); if (isset($extensionsByMimeType[$type])) { return '.' . $extensionsByMimeType[$type]; } return $default; }
/** * DOCUMENT ME */ public function setup() { parent::setup(); $services = aMediaTools::getEmbedServiceNames(); $this->setWidget('service', new aWidgetFormChoice(array('choices' => array_combine($services, $services), 'expanded' => true, 'default' => 'YouTube'))); $this->setValidator('service', new sfValidatorChoice(array('choices' => $services))); $this->widgetSchema->setFormFormatterName('aAdmin'); }
/** * Thanks yet again to http:thatsquality.com/articles/can-the-symfony-forms-framework-be-domesticated-a-simple-todo-list * @param mixed $validator * @param mixed $values * @param mixed $args * @return mixed */ public function atLeastOne($validator, $values, $args) { for ($i = 0; $i < aMediaTools::getOption('batch_max'); $i++) { if (!is_null($values["item-{$i}"]['file'])) { return $values; } } throw new sfValidatorError($validator, 'at_least_one'); }
public function configure() { for ($i = 0; $i < aMediaTools::getOption('batch_max'); $i++) { if (isset($this->active[$i])) { $this->embedForm("item-{$i}", new aMediaImageForm()); } } $this->widgetSchema->setNameFormat('a_media_items[%s]'); // $this->widgetSchema->setFormFormatterName('aAdmin'); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }
public function configure() { for ($i = 0; $i < aMediaTools::getOption('batch_max'); $i++) { $uploadImageForm = new aMediaUploadImageForm(); $this->embedForm("item-{$i}", $uploadImageForm); $this->widgetSchema->setNameFormat('a_media_items[%s]'); $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'atLeastOne')))); } $this->widgetSchema->setFormFormatterName('aAdmin'); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }
/** * DOCUMENT ME */ public function configure() { $services = aMediaTools::getEmbedServiceNames(); $this->setWidget('service', new aWidgetFormChoice(array('choices' => array_combine($services, $services), 'expanded' => true, 'default' => 'YouTube'))); $this->setValidator('service', new sfValidatorChoice(array('choices' => $services))); $this->setWidget('q', new sfWidgetFormInput(array(), array('class' => 'a-search-video a-search-form'))); $this->setValidator('q', new sfValidatorString(array('required' => true))); $this->widgetSchema->setNameFormat('aMediaSearchServices[%s]'); $this->widgetSchema->setFormFormatterName('aAdmin'); $this->widgetSchema->setLabel('q', ' '); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }
/** * DOCUMENT ME */ public function postConfigure() { if ($this->getObject()->isNew()) { $permissionIds = array(); $permissionNames = array(sfConfig::get('app_a_group_editor_permission', 'editor'), aMediaTools::getOption('upload_credential'), 'blog_author', 'view_locked'); foreach ($permissionNames as $permissionName) { $permission = Doctrine::getTable('sfGuardPermission')->findOneByName($permissionName); if ($permission) { $permissionIds[] = $permission->id; } } $this->setDefault('permissions_list', $permissionIds); } }
/** * DOCUMENT ME */ public function configure() { $this->setWidget("file", new aWidgetFormInputFilePersistent(array("image-preview" => array("width" => 50, "height" => 50, "resizeType" => "c")))); $mimeTypes = aMediaTools::getOption('mime_types'); // It comes back as a mapping of extensions to types, get the types $extensions = array_keys($mimeTypes); $mimeTypes = array_values($mimeTypes); $this->setValidator("file", new aValidatorFilePersistent(array("mime_types" => $mimeTypes, 'validated_file_class' => 'aValidatedFile', "required" => false), array("mime_types" => "The following file types are accepted: " . implode(', ', $extensions)))); // Without this, the radio buttons on the edit form will not have a default $this->setWidget("view_is_secure", new sfWidgetFormInputHidden(array('default' => '0'))); $this->setValidator("view_is_secure", new sfValidatorPass(array('required' => false))); $this->setDefault('view_is_secure', 0); // The same as the edit form by design $this->widgetSchema->setNameFormat('a_media_item[%s]'); $this->widgetSchema->setFormFormatterName('aAdmin'); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }
public static function listenToRoutingLoadConfigurationEvent(sfEvent $event) { $r = $event->getSubject(); if (aMediaTools::getOption("routes_register") && in_array('aMedia', sfConfig::get('sf_enabled_modules'))) { // Since the media plugin is now an engine, we need our own // catch-all rule for administrative URLs in the media area. // Prepending it first means it matches last $r->prependRoute('a_media_other', new aRoute('/:action', array('module' => 'aMedia'))); $r->prependRoute('a_media_image_show', new aRoute('/view/:slug', array('module' => 'aMedia', 'action' => 'show'), array('slug' => '^' . aTools::getSlugRegexpFragment() . '$'))); // Allow permalinks for PDF originals $r->prependRoute('a_media_image_original', new sfRoute(sfConfig::get('app_a_routes_media_image_original', '/uploads/media_items/:slug.original.:format'), array('module' => 'aMediaBackend', 'action' => 'original'), array('slug' => '^' . aTools::getSlugRegexpFragment() . '$', 'format' => '^(\\w+)$'))); $route = new sfRoute(sfConfig::get('app_a_routes_media_image', '/uploads/media_items/:slug.:width.:height.:resizeType.:format'), array('module' => 'aMediaBackend', 'action' => 'image'), array('slug' => '^' . aTools::getSlugRegexpFragment() . '$', 'width' => '^\\d+$', 'height' => '^\\d+$', 'resizeType' => '^\\w$', 'format' => '^(jpg|png|gif)$')); $r->prependRoute('a_media_image', $route); $route = new sfRoute(sfConfig::get('app_a_routes_media_image_cropped', '/uploads/media_items/:slug.:cropLeft.:cropTop.:cropWidth.:cropHeight.:width.:height.:resizeType.:format'), array('module' => 'aMediaBackend', 'action' => 'image'), array('slug' => '^' . aTools::getSlugRegexpFragment() . '$', 'width' => '^\\d+$', 'height' => '^\\d+$', 'cropLeft' => '^\\d+$', 'cropTop' => '^\\d+$', 'cropWidth' => '^\\d+$', 'cropHeight' => '^\\d+$', 'resizeType' => '^\\w$', 'format' => '^(jpg|png|gif)$')); $r->prependRoute('a_media_image_cropped', $route); // What we want: // /media <-- everything // /image <-- media of type image // /video <-- media of type video // /tag/tagname <-- media with this tag // /image/tag/tagname <-- images with this tag // /video/tag/tagname <-- video with this tag // /media?search=blah blah blah <-- searches are full of // dirty URL-unfriendly characters and // are traditionally query strings. $r->prependRoute('a_media_index', new aRoute('/', array('module' => 'aMedia', 'action' => 'index'))); $r->prependRoute('a_media_index_type', new aRoute('/:type', array('module' => 'aMedia', 'action' => 'index'), array('type' => '(image|video)'))); $r->prependRoute('a_media_index_category', new aRoute('/category/:category', array('module' => 'aMedia', 'action' => 'index'), array('category' => '.*'))); // Support for existing pretty-URL tag links so they don't 404. We don't recommend // this for the generation of new links because it doesn't handle various // punctuation well with a wide variety of webserver configurations $r->prependRoute('a_media_index_deprecated_tag', new aRoute('/tag/:tag', array('module' => 'aMedia', 'action' => 'index'), array('tag' => '.*'))); // We removed :tag because we allow tags with dots and such and pretty URLs // work great until your rewrite rules decide they are supposed to be static files $r->prependRoute('a_media_index_tag', new aRoute('/tag', array('module' => 'aMedia', 'action' => 'index'), array('tag' => '.*'))); $r->prependRoute('a_media_select', new aRoute('/select', array('class' => 'aRoute', 'module' => 'aMedia', 'action' => 'select'))); $r->prependRoute('a_media_info', new sfRoute('/info', array('module' => 'aMediaBackend', 'action' => 'info'))); $r->prependRoute('a_media_tags', new sfRoute('/tags', array('module' => 'aMediaBackend', 'action' => 'tags'))); $r->prependRoute('a_media_upload', new aRoute('/upload', array('module' => 'aMedia', 'action' => 'upload'))); $r->prependRoute('a_media_edit_multiple', new aRoute('/editMultiple', array('module' => 'aMedia', 'action' => 'editMultiple'))); $r->prependRoute('a_media_edit', new aRoute('/edit', array('module' => 'aMedia', 'action' => 'edit'))); $r->prependRoute('a_media_new_video', new aRoute('/newVideo', array('module' => 'aMedia', 'action' => 'newVideo'))); $r->prependRoute('a_media_edit_video', new aRoute('/editVideo', array('module' => 'aMedia', 'action' => 'editVideo'))); } }
public function configure() { unset($this['type']); unset($this['service_url']); unset($this['slug']); unset($this['width']); unset($this['height']); unset($this['format']); $this->setWidget('file', new aWidgetFormInputFilePersistent(array('image-preview' => aMediaTools::getOption('gallery_constraints')))); $item = $this->getObject(); if (!$item->isNew()) { $this->getWidget('file')->setOption('default-preview', $item->getOriginalPath()); } $this->setValidator('file', new aValidatorFilePersistent(array('mime_types' => array('image/jpeg', 'image/png', 'image/gif'), 'required' => !$this->getObject()->getId()), array('mime_types' => 'JPEG, PNG and GIF only.', 'required' => 'Select a JPEG, PNG or GIF file'))); $this->setValidator('title', new sfValidatorString(array('min_length' => 3, 'max_length' => 200, 'required' => true), array('min_length' => 'Title must be at least 3 characters.', 'max_length' => 'Title must be <200 characters.', 'required' => 'You must provide a title.'))); $this->setWidget('view_is_secure', new sfWidgetFormSelectRadio(array('choices' => array(0 => 'Public', 1 => 'Hidden'), 'default' => 0))); $this->setValidator('view_is_secure', new sfValidatorBoolean()); $this->widgetSchema->setLabel('view_is_secure', 'Permissions'); $this->widgetSchema->setNameFormat('a_media_item[%s]'); // $this->widgetSchema->setFormFormatterName('aAdmin'); $this->widgetSchema->setLabel('media_categories_list', 'Categories'); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }
<?php echo $form->renderHiddenFields(); ?> <input type="hidden" name="active" value="<?php echo implode(",", $active); ?> " /> <?php $n = 0; ?> <ul> <?php for ($i = 0; $i < aMediaTools::getOption('batch_max'); $i++) { ?> <?php if (isset($form["item-{$i}"])) { ?> <?php // What we're passing here is actually a widget schema ?> <?php // (they get nested when embedded forms are present), but ?> <?php // it supports the same methods as a form for rendering purposes ?> <?php include_partial('aMedia/editImage', array("item" => false, "firstPass" => $firstPass, "form" => $form["item-{$i}"], "n" => $n, 'i' => $i, 'itemFormScripts' => 'false'));
/** * DOCUMENT ME * @param mixed $arguments * @param mixed $options */ protected function execute($arguments = array(), $options = array()) { // We need a basic context so we can call helpers to format text $context = sfContext::createInstance($this->configuration); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); // PDO connection not so useful, get the doctrine one $conn = Doctrine_Manager::connection(); $accounts = Doctrine::getTable('aEmbedMediaAccount')->findAll(); foreach ($accounts as $a) { $perPage = 50; $service = aMediaTools::getEmbedService($a->service); if (!$service) { // An account for a service that has been deconfigured continue; } $total = null; $page = 1; $serviceUrls = array(); while (true) { $results = $service->browseUser($a->username, $page, $perPage); if ($results === false) { // We hit the rate limit, the account is bad, etc. Just // be tolerant and retry later. Would be nice to distinguish // these cases but it's not that hard to figure out an // account is gone break; } foreach ($results['results'] as $result) { $serviceUrls[] = $result['url']; } // We hit the end of the results for this user if (!count($results['results'])) { break; } $page++; } if (count($serviceUrls)) { $existingServiceUrls = Doctrine::getTable('aMediaItem')->createQuery('m')->select('m.service_url')->andWhereIn('m.service_url', $serviceUrls)->execute(array(), Doctrine::HYDRATE_SINGLE_SCALAR); } else { $existingServiceUrls = array(); } $existingServiceUrls = array_flip($existingServiceUrls); foreach ($serviceUrls as $serviceUrl) { if (!isset($existingServiceUrls[$serviceUrl])) { // If Doctrine becomes a performance problem I could use PDO // and set lucene_dirty to let that clean itself up later $id = $service->getIdFromUrl($serviceUrl); $info = $service->getInfo($id); if (!$info) { // We are not actually allowed meaningful access to this video. Password protected for example continue; } $item = new aMediaItem(); $item->setTitle($info['title']); // We want tags to be lower case, and slashes break routes in most server configs. $info['tags'] = str_replace('/', '-', aString::strtolower($info['tags'])); $item->setTags($info['tags']); $item->setDescription(aHtml::textToHtml($info['description'])); $item->setCredit($info['credit']); $item->setServiceUrl($info['url']); $item->setType($service->getType()); // The dance is this: get the thumbnail if there is one; // call preSaveFile to learn the width, height and format // before saving; save; and then saveFile to copy it to a // filename based on the slug, which is unknown until after save $thumbnail = $service->getThumbnail($id); if ($thumbnail) { // Grab a local copy of the thumbnail, and get the pain // over with all at once in a predictable way if // the service provider fails to give it to us. $thumbnailCopy = aFiles::getTemporaryFilename(); if (copy($thumbnail, $thumbnailCopy)) { $item->preSaveFile($thumbnailCopy); } } $item->save(); if ($thumbnail) { $item->saveFile($thumbnailCopy); } $item->free(); } } } }
<?php // Compatible with sf_escaping_strategy: true $limitSizes = isset($limitSizes) ? $sf_data->getRaw('limitSizes') : null; use_helper('a'); // Pretties up metatypes like _downloadable, returns "media item" if there is no specific type $type = aMediaTools::getNiceTypeName(); ?> <div class="a-ui a-media-select clearfix"> <h3><?php echo __('You are selecting a %type%.', array('%type%' => __($type, null, 'apostrophe')), 'apostrophe'); ?> </h3> <div id="a-media-selection-wrapper" class="a-ui a-media-selection-wrapper"> <div class="a-media-selection-help"> <?php // Thanks to Galileo for i18n corrections here ?> <?php // I adjusted the wording here to avoid saying "click on" as sometimes there is an explicit select button etc. ?> <h4> <?php echo __('Use the browsing and searching features to locate the %type% you want, then click to select it.', array('%type%' => __($type, null, 'apostrophe')), 'apostrophe'); ?> <?php if ($limitSizes) { ?>
/** * * The input value must be an array potentially containing two * keys, newfile and persistid. newfile must contain an array of * the following subkeys, if it is present: * * tmp_name: The absolute temporary path to the newly uploaded file * name: The browser-submitted file name (optional, but necessary to distinguish amongst Microsoft Office formats) * type: The browser-submitted file content type (required although our guessers never trust it) * error: The error code (optional) * size: The file size in bytes (optional) * The persistid key allows lookup of a previously uploaded file * when no new file has been submitted. * A RARE BUT USEFUL CASE: if you need to prefill this cache before * invoking the form for the first time, you can instantiate this * validator yourself: * $vfp = new aValidatorFilePersistent(); * $guid = aGuid::generate(); * $vfp->clean( * array( * 'newfile' => * array('tmp_name' => $myexistingfile), * 'persistid' => $guid)); * Then set array('persistid' => $guid) as the default value * for the file widget. This logic is most easily encapsulated in * the configure() method of your form class. * @see sfValidatorFile * @see sfValidatorBase * @param mixed $value * @return mixed */ public function clean($value) { $persistid = false; if (isset($value['persistid'])) { $persistid = $value['persistid']; } $newFile = false; $persistentDir = $this->getPersistentDir(); if (!self::validPersistId($persistid)) { $persistid = false; } $cvalue = false; // Why do we tolerate the newfile fork being entirely absent? // Because with persistent file upload widgets, it's safe to // redirect a form submission to another action via the GET method // after validation... which is extremely useful if you want to // split something into an iframed initial upload action and // a non-iframed annotation action and you need to be able to // stuff the state of the form into a URL and do window.parent.location =. // As long as we tolerate the absence of the newfile button, we can // rebuild the submission from what's in // getRequest()->getParameterHolder()->getAll(), and that is useful. if (!isset($value['newfile']) || $this->isEmpty($value['newfile'])) { if ($persistid !== false) { $filePath = "{$persistentDir}/{$persistid}.file"; $data = false; if (file_exists($filePath)) { $dataPath = "{$persistentDir}/{$persistid}.data"; // Don't let them expire touch($filePath); touch($dataPath); $data = file_get_contents($dataPath); if (strlen($data)) { $data = unserialize($data); } } if ($data) { $cvalue = $data; } } } else { $newFile = true; $cvalue = $value['newfile']; } if (isset($cvalue['name'])) { $this->originalName = $cvalue['name']; } else { $this->originalName = ''; } try { $result = parent::clean($cvalue); } catch (Exception $e) { // If there is a validation error stop keeping this // file around and don't display the reassuring // "you don't have to upload again" message side by side // with the validation error. if ($persistid !== false) { $infoPath = "{$persistentDir}/{$persistid}.data"; $filePath = "{$persistentDir}/{$persistid}.file"; @unlink($infoPath); @unlink($filePath); } throw $e; } if ($newFile) { // Expiration of abandoned stuff has to happen somewhere self::removeOldFiles($persistentDir); if ($persistid !== false) { $filePath = "{$persistentDir}/{$persistid}.file"; copy($cvalue['tmp_name'], $filePath); $data = $cvalue; $data['newfile'] = true; $data['tmp_name'] = $filePath; // It's useful to know the mime type and true extension for // supplying previews and icons $extensionsByMimeType = array_flip(aMediaTools::getOption('mime_types')); if (!isset($cvalue['type'])) { // It's not sensible to trust a browser-submitted mime type anyway, // so don't force non-web invocations of this code to supply one $cvalue['type'] = 'unknown/unknown'; } $data['mime_type'] = $this->getMimeType($filePath, $cvalue['type']); if (isset($extensionsByMimeType[$data['mime_type']])) { $data['extension'] = $extensionsByMimeType[$data['mime_type']]; } self::putFileInfo($persistid, $data); } } elseif ($persistid !== false) { $data = self::getFileInfo($persistid); if ($data !== false) { $data['newfile'] = false; self::putFileInfo($persistid, $data); } } return $result; }
<?php use_helper('jQuery'); ?> <div id="a-media-plugin"> <?php include_component('aMedia', 'browser'); ?> <div class="a-media-library"> <?php $id = $mediaItem->getId(); $options = aDimensions::constrain($mediaItem->getWidth(), $mediaItem->getHeight(), $mediaItem->getFormat(), aMediaTools::getOption('show_constraints')); $embedCode = $mediaItem->getEmbedCode($options['width'], $options['height'], $options['resizeType'], $options['format']); ?> <?php // This was inside a ul which doesn't make sense ?> <?php echo link_to(__('Media Library', null, 'apostrophe'), '@a_media_index', array('class' => 'a-btn big icon a-arrow-left thin', 'id' => 'media-library-back-button')); ?> <ul class="a-media-item-content" id="a-media-item-content-<?php echo $mediaItem->getId(); ?>
?> <?php } ?> <?php if (aMediaTools::userHasUploadPrivilege()) { ?> <ul class="a-controls a-media-controls"> <?php $selecting = aMediaTools::isSelecting(); ?> <?php $type = aMediaTools::getAttribute('type'); ?> <?php if (!($selecting && $type && $type !== 'image')) { ?> <li><a href="<?php echo url_for("aMedia/uploadImages"); ?> " class="a-btn icon a-add"><?php echo __('Add Images', null, 'apostrophe'); ?> </a></li> <?php } ?>
protected function getItem() { return aMediaTools::getItem($this); }
/** * Select a media item or items, then redirect to the URL * specified by the $after parameter, at which time the above * information retrieving methods are valid for use. * The $actions parameter should be the current actions class * ($this, if you are writing an executeFoo method). * $after is the URL to redirect to after the selection is completed or cancelled. * For backwards compatibility this URL will receive several GET method parameters, * however you should use the methods above rather than consulting them. The methods * above are not limited by URL length considerations. * $currentIds should contain a list of ids or a list of aMediaItems that are * currently selected (allowing the user to modify the list rather than making * an entirely new selection), or a single item or id, or false for no current selection. * $options is a hash which may contain: * multiple => true: allow multiple media items to be selected * 'type', 'aspect-width', 'aspect-height', 'minimum-width', 'minimum-height', * 'width', 'height': enforce these constraints on type or dimensions * type can currently be image, video or pdf * 'label': set the reminder message that appears at the top of the media browser * to remind the user why they are there and what they are looking for * 'cropping' => true: allow the user to crop each selected item. Cropping * parameters can be retrieved later with getCroppingInfo() * 'croppingInfo' => an array of existing cropping info as returned by * getCroppingInfo after a previous successful selection. Allows the user to * edit a selection with existing cropping choices * @param mixed $actions * @param mixed $after * @param mixed $currentIds * @param mixed $options * @return mixed */ public function select($actions, $after, $currentIds = false, $options = array()) { if ($currentIds === false) { $currentIds = array(); } elseif ($currentIds instanceof aMediaItem) { $currentIds = array($currentIds); } elseif (!is_array($currentIds)) { $currentIds = array($currentIds); } if ($currentIds[0] instanceof aMediaItem) { $currentIds = aArray::getIds($currentIds); } aMediaTools::setSelecting($after, $options['multiple'], $ids, $options); return $actions->redirect("aMedia/index"); }
?> class="a-media-thumb-link"> <?php if ($type == 'video') { ?> <span class="a-media-play-btn"></span><?php } ?> <?php if ($type == 'pdf') { ?> <span class="a-media-pdf-btn"></span><?php } ?> <img src="<?php echo url_for($mediaItem->getScaledUrl(aMediaTools::getOption('gallery_constraints'))); ?> " /> </a> </li> <?php // Stored as HTML ?> <li class="a-media-item-title"> <h3> <a <?php echo $linkAttributes; ?> ><?php echo htmlspecialchars($mediaItem->getTitle());
/** * DOCUMENT ME * @return mixed */ public function isAdmin() { return sfContext::getInstance()->getUser()->hasCredential(aMediaTools::getOption('admin_credential')); }
private function getItem() { return aMediaTools::getItem($this); }
?> <label class="full">Embed Preview</label> <div class="a-form-field"> <?php echo $embedCode; ?> </div> <label class="full">Embed Thumbnail</label> <?php } ?> <?php $widget = $form['file']->getWidget(); ?> <?php $previewUrl = $widget->getPreviewUrl($form['file']->getValue(), aMediaTools::getOption('gallery_constraints')); ?> <div class="a-form-field"> <?php if ($previewUrl) { ?> <?php echo image_tag($previewUrl); ?> <?php } else { ?> <?php $format = $widget->getFormat($form['file']->getValue()); ?> <?php
<?php // Compatible with sf_escaping_strategy: true $mediaItem = isset($mediaItem) ? $sf_data->getRaw('mediaItem') : null; $layout = isset($layout) ? $sf_data->getRaw('layout') : null; use_helper('a'); ?> <?php $type = aMediaTools::getAttribute('type'); $selecting = aMediaTools::isSelecting(); ?> <?php $body_class = 'a-media a-media-show'; $body_class .= $selecting ? ' a-media-selecting a-previewing' : ''; slot('body_class', $body_class); ?> <?php $i = 1; ?> <?php slot('a-page-header'); ?> <?php include_partial('aMedia/mediaHeader', array('uploadAllowed' => $uploadAllowed, 'embedAllowed' => $embedAllowed)); end_slot(); ?>
/** * DOCUMENT ME */ public function configure() { // This call was missing, preventing easy extension of all media item edit forms at the project level parent::configure(); unset($this['id']); unset($this['type']); unset($this['service_url']); unset($this['slug']); unset($this['width']); unset($this['height']); unset($this['format']); unset($this['embed']); $this->setWidget('file', new aWidgetFormInputFilePersistent(array())); $item = $this->getObject(); // A safe assumption because we always go through the separate upload form on the first pass. // This label is a hint that changing the file is not mandatory // The 'Replace File' label is safer than superimposing a file button // on something that may or may not be a preview or generally a good thing // to try to read a button on top of $this->getWidget('file')->setLabel('Select a new file'); if (!$item->isNew()) { $this->getWidget('file')->setOption('default-preview', $item->getOriginalPath()); } $mimeTypes = aMediaTools::getOption('mime_types'); // It comes back as a mapping of extensions to types, get the types $extensions = array_keys($mimeTypes); $mimeTypes = array_values($mimeTypes); $type = false; if (!$this->getObject()->isNew()) { // You can't change the major type of an existing media object as // this would break slots (a .doc where a .gif should be...) $type = $this->getObject()->type; } // What we are selecting to add to a page if (!$type) { $type = aMediaTools::getType(); } if (!$type) { // What we are filtering for $type = aMediaTools::getSearchParameter('type'); } if ($type) { // This supports composite types like _downloadable $infos = aMediaTools::getTypeInfos($type); $extensions = array(); foreach ($infos as $info) { if ($info['embeddable']) { // This widget is actually supplying a thumbnail - allow gif, jpg and png $info['extensions'] = array('gif', 'jpg', 'png'); } foreach ($info['extensions'] as $extension) { $extensions[] = $extension; } } $mimeTypes = array(); $mimeTypesByExtension = aMediaTools::getOption('mime_types'); foreach ($extensions as $extension) { // Careful, if we are filtering for a particular type then not everything // will be on the list if (isset($mimeTypesByExtension[$extension])) { $mimeTypes[] = $mimeTypesByExtension[$extension]; } } } // The file is mandatory if it's new. Otherwise // we have a problem when they get the file type wrong // for one of two and we have to reject that one, // then they resubmit - we can add an affirmative way // to remove one item from the annotation form later $this->setValidator("file", new aValidatorFilePersistent(array("mime_types" => $mimeTypes, 'validated_file_class' => 'aValidatedFile', "required" => $this->getObject()->isNew() ? true : false), array("mime_types" => "The following file types are accepted: " . implode(', ', $extensions)))); // Necessary to work around FCK's "id and name cannot differ" problem // ... But we do it in the action which knows when that matters // $this->widgetSchema->setNameFormat('a_media_item_'.$this->getObject()->getId().'_%s'); // $this->widgetSchema->setFormFormatterName('aAdmin'); }
for ($i = $n; $i < min(count($results), $n + $layout['columns']); $i++) { ?> <?php include_partial('aMedia/mediaItem', array('mediaItem' => $results[$i], 'layout' => $layout, 'i' => $i, 'selecting' => $selecting, 'autoplay' => true)); ?> <?php } ?> </div> <?php } ?> </div> <?php if (!$pager->count() && aMediaTools::userHasUploadPrivilege()) { ?> <?php include_partial('aMedia/noMediaItemsArea'); ?> <?php } ?> <div class="a-media-footer clearfix"> <div class="a-media-library-controls a-ui bottom"> <?php include_slot('a-media-library-controls'); ?> </div> </div>
<hr class="a-hr"/> <h4 class="a-account-preview-name">Account: <span><?php echo a_entities($name); ?> </span></h4> <h5 class="a-account-preview-description"><?php echo $description; ?> </h5> <ul class="a-account-preview-recent"> <?php foreach ($results['results'] as $result) { ?> <li><?php echo $service->embed($result['id'], aMediaTools::getOption('video_account_preview_width'), aMediaTools::getOption('video_account_preview_height')); ?> </li> <?php } ?> </ul> <div class="a-account-preview-confirm"> <p class="a-help">Add this account so that all new media associated with it will automatically be added to the media repository on an ongoing basis.</p> <ul class="a-ui a-controls"> <li><?php echo a_js_button(a_('Add This Account'), array('big', 'icon', 'a-add'), 'a-account-preview-ok'); ?> </li> <li><?php
<ul class="a-controls a-media-upload-form-footer" id="a-media-video-add-by-url-form-submit"> <li><input type="submit" value="<?php echo __('Go', null, 'apostrophe'); ?> " class="a-submit" /></li> <li><?php echo link_to_function(__("Cancel", null, 'apostrophe'), "\$('#a-media-video-add-by-url-form').hide(); \$('#a-media-video-add-by-url-heading').hide(); \$('#a-media-video-buttons').show();", array("class" => "a-cancel a-btn icon event-default")); ?> </li> </ul> </form> <?php if (aMediaTools::getOption('embed_codes')) { ?> <h4 id="a-media-video-add-by-embed-heading" class="a-media-video-heading"><?php echo __('Add by Embed Code', null, 'apostrophe'); ?> </h4> <form id="a-media-video-add-by-embed-form" class="a-media-search-form" method="POST" action="<?php echo url_for("aMedia/editVideo"); ?> "> <div class="a-form-row a-search-field" style="position:relative"> <label for="a-media-video-embed"></label> <?php $form = new aMediaVideoEmbedForm();
<?php use_helper('a'); use_javascript('/sfDoctrineActAsTaggablePlugin/js/pkTagahead.js'); $options = array('choose-one' => a_('Choose Categories')); if (sfContext::getInstance()->getUser()->hasCredential(aMediaTools::getOption('admin_credential'))) { ?> <?php $options['add'] = a_('+ New Category'); } a_js_call('aMultipleSelectAll(?)', $options);