<commit_before><?php
App::uses('AppHelper', 'View/Helper');
App::uses('FormHelper', 'View/Helper');
App::uses('Album', 'Gallery.Model');

class GalleryHelper extends AppHelper
{
    /**
     * Gallery link helper
     *
     * This helper will create an link to a new or existing gallery
     *
     * If no arguments are passed this will create a new gallery everytime the link are clicked.
     *
     * When model & model_id arguments are passed, this will redirect to this specific gallery (it will also create a
     * new one if didn't exists)
     *
     * Example:
     * <?php echo $this->Gallery->button('product', 1) ?>
     *
     * @param null $model
     * @param null $model_id
     * @param array $html_options
     * @return string
     */
    public function link($model = null, $model_id = null, $html_options = array())
    {
        return $this->_View->Html->link(
            'Upload pictures',
            array(
                'controller' => 'albums',
                'action' => 'upload',
                'plugin' => 'gallery',
                $model,
                $model_id
            ),
            $html_options
        );
    }

    /**
     * Render a gallery with thumbnails
     *
     * @param null $model
     * @param null $model_id
     * @param null $album_id
     * @return string
     */
    public function showroom($model = null, $model_id = null, $album_id = null, $html_options = array('jquery' => true, 'swipebox' => true))
    {
        $Album = new Album();

        if ($album_id) {
            $album = $Album->findById($album_id);
        } else if ($model && $model_id) {
            $album = $Album->getAttachedAlbum($model, $model_id);
        }

        if (!empty($album)) {
            # Load scripts for the showroom (jquery, bootstrap, swipebox)
            $this->_loadScripts($html_options);

            # Render the showroom
            $this->showroomTmpl($album);
        } else {
            # Album doesn't exists
            $this->_noPhotosMessageTmpl();
        }

        return;
    }

    /**
     * This method use a album object to loop in all pictures and
     * show them using a bootstrap html pattern.
     *
     * @param $album
     */
    public function showroomTmpl($album)
    {
        if (empty($album['Picture'])) {
            $this->_noPhotosMessageTmpl();
        } else {
            foreach ($album['Picture'] as $picture) {
                $this->_thumbnailTmpl($picture);
            }<commit_msg>Added option to choose between styles on Gallery showroom<commit_after><?php
App::uses('AppHelper', 'View/Helper');
App::uses('FormHelper', 'View/Helper');
App::uses('Album', 'Gallery.Model');

class GalleryHelper extends AppHelper
{
    /**
     * Gallery link helper
     *
     * This helper will create an link to a new or existing gallery
     *
     * If no arguments are passed this will create a new gallery everytime the link are clicked.
     *
     * When model & model_id arguments are passed, this will redirect to this specific gallery (it will also create a
     * new one if didn't exists)
     *
     * Example:
     * <?php echo $this->Gallery->button('product', 1) ?>
     *
     * @param null $model
     * @param null $model_id
     * @param array $html_options
     * @return string
     */
    public function link($model = null, $model_id = null, $html_options = array())
    {
        return $this->_View->Html->link(
            'Upload pictures',
            array(
                'controller' => 'albums',
                'action' => 'upload',
                'plugin' => 'gallery',
                $model,
                $model_id
            ),
            $html_options
        );
    }

    /**
     * Render a gallery with thumbnails
     *
     * @param null $model
     * @param null $model_id
     * @param null $album_id
     * @return string
     */
    public function showroom(
        $model = null,
        $model_id = null,
        $album_id = null,
        $style = 'medium',
        $html_options = array('jquery' => true, 'swipebox' => true))
    {
        $Album = new Album();

        if ($album_id) {
            $album = $Album->findById($album_id);
        } else if ($model && $model_id) {
            $album = $Album->getAttachedAlbum($model, $model_id);
        }

        if (!empty($album)) {
            # Load scripts for the showroom (jquery, bootstrap, swipebox)
            $this->_loadScripts($html_options);

            # Render the showroom
            $this->showroomTmpl($album, $style);
        } else {
            # Album doesn't exists
            $this->_noPhotosMessageTmpl();
        }

        return;
    }

    /**
     * This method use a album object to loop in all pictures and
     * show them using a bootstrap html pattern.
     *
     * @param $album
     */
    public function showroomTmpl($album, $style = 'medium')
    {
        if (empty($album['Picture'])) {
            $this->_noPhotosMessageTmpl();
        } else {
            foreach ($album['Picture'] as $picture) {
                $this->_thumbnailTmpl($picture, $style);
            }
{'fraction_non_alphanumeric': 0.12546269238262225, 'fraction_numerical': 0.0003896356906292616, 'mean_word_length': 1.8745800671892496, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4124838', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1425, 'n_words': 415}