public function executeBreadcrumb($request) { $this->type = aMediaTools::getSearchParameter('type'); $this->tag = aMediaTools::getSearchParameter('tag'); $this->search = aMediaTools::getSearchParameter('search'); $this->categorySlug = aMediaTools::getSearchParameter('category'); $this->crumbs = array(); // I tried calling I18N here but that requires enabling // I18N for every project which the I18N helper does not... // I'm not internationalizing this site, so I give up. // If you're reading this, tell me how to localize these labels // without punishing noninternationalized sites. I really don't // want to push this much logic into a template. tom@punkave.com $this->crumbs[] = array("label" => "Home", "link" => "@homepage", "first" => true); $this->crumbs[] = array("label" => "Media", "link" => "aMedia/index"); if ($this->type) { $this->crumbs[] = array("label" => $this->type, "link" => aUrl::addParams("aMedia/index", array("type" => $this->type))); } if ($this->categorySlug) { $this->crumbs[] = array("label" => $this->category, "link" => aUrl::addParams("aMedia/index", array('type' => $this->type, "category" => $this->categorySlug))); } if ($this->tag) { $this->crumbs[] = array("label" => htmlspecialchars($this->tag), "link" => aUrl::addParams("aMedia/index", array("type" => $this->type, 'category' => $this->categorySlug, "tag" => $this->tag))); } if ($this->search) { $this->crumbs[] = array("label" => htmlspecialchars($this->search), "link" => aUrl::addParams("aMedia/index", array("type" => $this->type, 'category' => $this->categorySlug, "tag" => $this->tag, "search" => $this->search))); } if (isset($this->item)) { $this->crumbs[] = array("label" => $this->item->getTitle(), "link" => aUrl::addParams("aMedia/show", array("slug" => $this->item->getSlug()))); } $this->crumbs[count($this->crumbs) - 1]['last'] = true; }
/** * 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'); }