Example #1
0
 /**
  * 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')));
     }
 }
Example #2
0
    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>
Example #3
0
	  <?php 
        } else {
            ?>
	    <?php 
            include_partial('aMedia/selectSingle', array('limitSizes' => $limitSizes));
            ?>
	  <?php 
        }
        ?>

	<?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");
Example #4
0
 public function executeEditImages(sfRequest $request)
 {
     $this->forward404Unless(aMediaTools::userHasUploadPrivilege());
     // I'd put these in the form class, but I can't seem to access them
     // there unless the whole form is valid. I need them as metadata
     // to control the form's behavior, so that won't cut it.
     // Perhaps I could put them in a second form, since there's
     // no actual restriction on multiple form objects inside a
     // single HTML form element.
     $this->firstPass = $request->getParameter('first_pass');
     $active = $request->getParameter('active');
     $this->forward404Unless(preg_match("/^\\d+[\\d\\,]*\$/", $active));
     $this->active = explode(",", $request->getParameter('active'));
     $this->form = new aMediaEditImagesForm($this->active);
     $this->form->bind($request->getParameter('a_media_items'), $request->getFiles('a_media_items'));
     if ($this->form->isValid()) {
         $values = $this->form->getValues();
         // This is NOT automatic since this isn't a Doctrine form. http://thatsquality.com/articles/can-the-symfony-forms-framework-be-domesticated-a-simple-todo-list
         foreach ($this->form->getEmbeddedForms() as $key => $itemForm) {
             $itemForm->updateObject($values[$key]);
             $object = $itemForm->getObject();
             if ($object->getId()) {
                 // We're creating new objects only here, but the embedded form
                 // supports an id for an existing object, which is useful in
                 // other contexts. Prevent hackers from stuffing in changes
                 // to media items they don't own.
                 $this->forward404();
             }
             // updateObject doesn't handle one-to-many relations, only save() does, and we
             // can't do save() in this embedded form, so we need to implement the categories
             // relation ourselves
             $object->unlink('MediaCategories');
             $object->link('MediaCategories', $values[$key]['media_categories_list']);
             // Everything except the actual copy which can't succeed
             // until the slug is cast in stone
             $file = $values[$key]['file'];
             $object->preSaveImage($file->getTempName());
             $object->save();
             $object->saveImage($file->getTempName());
         }
         return $this->redirect('aMedia/resume');
     }
 }
Example #5
0
<?php

use_helper('a');
$page = aTools::getCurrentPage();
if ($page->admin) {
    ?>

	<div class="a-ui a-admin-header">
	  <ul class="a-ui a-controls a-admin-controls">
			<li><h3 class="a-admin-title"><?php 
    echo link_to('<span class="icon"></span>' . __('Media Library', null, 'apostrophe'), '@a_media_index', array('class' => 'a-btn big lite'));
    ?>
</h3></li>
	  	<?php 
    if (aMediaTools::userHasUploadPrivilege() && ($uploadAllowed || $embedAllowed)) {
        ?>
	  	  <?php 
        // This is important because sometimes you are selecting specific media types
        ?>
	      <?php 
        $typeLabel = aMediaTools::getBestTypeLabel();
        ?>
		    <li><a href="<?php 
        echo url_for("aMedia/resume?add=1");
        ?>
" id="a-media-add-button" class="a-btn icon big a-add"><span class="icon"></span><?php 
        echo a_('Add  ' . $typeLabel);
        ?>
</a></li>
	      <li><a href="<?php 
        echo url_for("aMedia/searchServices");
Example #6
0
 /**
  * DOCUMENT ME
  */
 protected function hasPermissionsForSelect()
 {
     $this->forward404Unless(aTools::isPotentialEditor() || aMediaTools::userHasUploadPrivilege());
 }