Ansel::selectGalleries PHP Method

selectGalleries() public static method

Return a string containing an
public static selectGalleries ( array $params = [] ) : string
$params array An array of options:
  (integer)selected  The gallery_id of the gallery that is selected
  (integer)perm      The permissions filter to use [Horde_Perms::SHOW]
  (mixed)attributes  Restrict the galleries returned to those matching
                     the filters. Can be an array of attribute/values
                     pairs or a gallery owner username.
  (boolean)all_levels
  (integer)from      The gallery to start listing at.
  (integer)count     The number of galleries to return.
  (integer)ignore    An Ansel_Gallery id to ignore when building the tree.
return string The HTML to display the option list.
    public static function selectGalleries($params = array())
    {
        $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries($params);
        $params = new Horde_Support_Array($params);
        $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('gallery_tree', 'Select');
        // Remove the ignored gallery, make sure it's also not the selected
        if ($params->ignore) {
            if ($params->selected == $params->ignore) {
                $params->selected = null;
            }
        }
        foreach ($galleries as $gallery) {
            $gallery_id = $gallery->id;
            $gallery_name = $gallery->get('name');
            $label = Horde_String::abbreviate($gallery_name);
            $len = Horde_String::length($gallery_name);
            $treeparams = array();
            $treeparams['selected'] = $gallery_id == $params->selected;
            $parent = $gallery->getParent();
            $parent = empty($parent) ? null : $parent->id;
            $tree->addNode(array('id' => $gallery->id, 'parent' => $parent, 'label' => $label, 'params' => $treeparams));
        }
        return $tree->getTree();
    }

Usage Example

Example #1
0
            <?php 
    if ($this->option_copy) {
        ?>
              | <?php 
        echo $this->contentTag('a', _("Copy"), array('title' => _("Copy"), 'class' => 'widget', 'id' => 'anselgallery_copy'));
        ?>
            <?php 
    }
    ?>
            <select name="new_gallery">
              <option value="-1"><?php 
    echo _("Selected photos to");
    ?>
</option>
              <?php 
    echo Ansel::selectGalleries(array('perm' => Horde_Perms::EDIT));
    ?>
            </select>
          </td>
        </tr>
      </table>
    <?php 
}
?>
    <?php 
if (!$this->numTiles) {
    ?>
      <div class="text"><em><?php 
    echo _("There are no photos in this gallery.");
    ?>
</em></div>
All Usage Examples Of Ansel::selectGalleries