Yii 1.1: gallerymanager

Gallery and Image Management for the end user.
43 followers

Note:This extension is buggy now,and I have no intent to update it.

Overview

A module that provides backend Gallery and Image Management for the end user,and a native Gallery widget to render the images on the front end.The Gallery Widget comes with an option to render the images in EGalleria,(a jQuery Slider,see RESOURCES).It can easily be modified to render the images in the slider of your choice.

Requirements

Developed and tested with Yii 1.1.8,but will probably work with older versions too.

Features

  • Single Administration Page with tabs for easy management.
  • Mostly Ajax based operations with page refreshes kept to minimum.
  • Create,Update,Delete Galleries.Provide title and description.
  • Bulk Upload of images,(maximum number of images and maximum file size configurable).
  • Update title,description and link for images,Delete Images.
  • Drag and Drop Reordering of images.
  • Render the images on the front end with native widget: Can be used as stand alone or with the slider of your choice. The widget comes with an option for usage in EGalleria.

In Home Page you see the rendering of the stand alone Gallery widget which uses PrettyPhoto. In useInEGalleria you see the widget rendered in EGalleria. In Gallery Manager you can test creating,updating and deleting of galleries and images. Your images will not appear in Home page,only in Management page. Note that you cannot edit or delete the National Geographic Gallery.

Installation Instructions

  • Hide index.php from your requests,if you have'nt done so yet.You can find detailed instructions on how to do this here..Also,in urlManager configuration in config/main.php file set
'urlFormat'=>'path',
'showScriptName'=>false,
  • This module has CSRF (Cross-Site Request Forgery) validation enabled.POST ajax requests will not work unless you configure your request in config/main.php to use CSRF validation: At the top of the config/main.php file (outside of the configuration array):
$current_domain='mydomain.com';

In the configuration array,inside the components array:

... other components..
'request' => array(
                   'class' => 'CHttpRequest',
                   'enableCookieValidation' => true,
                   'enableCsrfValidation' => !isset($_POST['dontvalidate']) ? true : false,
           'csrfCookie' => array( 'domain' => '.' . $current_domain )
                                           ),
...other components..

Note: If you are developing with Google Chrome,this browser does not accept cookies with domain .localhost,so it's better to set up a virtual host in your local enviroment in this case. If you have reasons to not use CSRF validation,you can search in the module's code for the YII_CSRF_TOKEN variable and remove it from POST ajax requests.

  • I have developed this module to serve the needs of a bilingual application.So for every title and description column in the database there is a tr_title and tr_description for translated values.The default source language assumed is "en",(not "en_US" which is the default in Yii),so if language is "en", title and description will be used,in any other case the translated counterparts will be used.Use this information to modify your application accordingly.If you don't need the bilingual feature,just do a code search for
Yii::app()->language =='en'

and remove the language conditional statements.

  • Exctract the downloaded zip and copy imgManager folder to modules folder of your Yii application.
  • Create the two tables in your database using the gallery_manager.sql file found in data folder.
  • Create the folder that images will be uploaded to, with a name of your choice, inside the base folder of your Yii application (:same level as protected).In module configuration (see below) you will specify the name of the folder you just created as 'upload_directory'.
  • In config/main.php of your Yii application include imgManager in modules array,like so: (The module is configured with default values.)
'modules'=>array(
 
    //...other modules...
 
  'imgManager' => array(
                       'import'=>array('imgManager.*','imgManager.components.*'),
                        'layout'=>'application.views.layouts.column1',
                        'upload_directory'=>'gal_images',
                        'max_file_number' => '10',//max number of files for bulk upload.
                        'max_file_size' => '1mb',
                                                      ),
    //...other modules...
     );

Getting Started

Backend

  • Navigate to the module ( [baseURL]/imgManager ).You should see the administration page.
  • Click the Gallery Administration tab and create your first gallery by clicking on the + button on the right.
  • Select the newly created gallery from the dropdown list,go to Image Uploader tab and upload some images.
  • Provide titles and descriptions,and save.Go to Uploaded Images tab and rearrange the order of the images with drag and drop.Clicking on the thumbnails will show the full sized image in PrettyPhoto.(In Google Chrome the drag and drop event also fires the click event and opens the full sized image.).
  • Clicking on the pencil icon will bring up an update form,where you can change title,description and link.The link can be used in sliders.For example in EGalleria a link is set by specifying the longdesc attribute of the img tag.actionGetlinks in PlController is used to fetch available links to populate the autocomplete dropdown list.For demonstration purposes,some hard coded links are returned from this action.You can modify this action to return offsite or onsite links,like links to your application's articles for example.

Frontend

  • To show a gallery on the frontend simply include this line in your view file:
<?php  $this->widget('imgManager.widgets.Gallery',array('galleryID' =>[the gallery ID integer])); ?>

You can have multiple instances of this widget in the same page,for more than one galleries.

  • You can also use this widget inside EGalleria (see RESOURCES section for link to egalleria extension).You simply include in your view file the following code:
<?php
   $this->beginWidget('application.extensions.EGalleria.EGalleria',
                      array('galleria'=>array(
                                              'width'=>900,
                                              'lightbox'=>true,
                                              'autoplay'=>true
                                               )
                           ));
?>
   <?php  $this->widget('imgManager.widgets.Gallery',array('galleryID' =>[the gallery ID integer],'useInEGalleria'=>true));?>
   <?php $this->endWidget(); ?>

Note that you can modify the Gallery Widget so that it outputs image tags in the format that your favorite slider expects.See prepareForEGalleria function in Gallery widget class and _EGalleria_Item in widget/views to give you an idea.

Cheers,Spiros 'drumaddict' Kabasakalis.

Resources

NOTE: With the exception of egalleria extension,you don't have to download these assets,they are already included in module's extension folder.

Total 20 comments

#13638 report it
krasavcheg.ua at 2013/06/13 05:13am
too many bugs

unuseful extension

#9179 report it
jbernier at 2012/07/26 03:52pm
New version

Anybody has a version working with the latest Yii ?

#7179 report it
drumaddict at 2012/03/01 07:58am
about the problems...

Guys:You are on your own!At the moment,i have no time to maintain this extension,and come up with a new version for every framework release.Thanks for your understanding!

#7172 report it
gear at 2012/03/01 03:20am
@bmn js error

I also have to change to 1.1.8 to get that working.

#7164 report it
aquasite.pl at 2012/02/29 05:40am
@bmn js errors

I had the same problem. I solve it by changing framework back to 1.1.8. I know that is not the best idea but I can't find (I don't have time for it) what causes errors.

#7158 report it
gear at 2012/02/29 12:53am
Unable to submit on Create A New Gallery form

I've fixed /views/pl/_gallery_form.php line 130 and 137.

I then compare mine against the demo, btw there's a bg-form-field.gif 404 error. At the demo site, when I enter the title and go to the next field, it performs an ajax query and a tick_circle.png was presented. On mine, it doesn't perform ajax query and also submit doesn't do anything. Can anyone help please?

Ops, sorry guys, was doing some debugging, submit works. bg-form-field.gif is definitely 404 error.

#6610 report it
at 2012/01/21 03:43am
js errors

i am getting js errors all over the place. i believe it's due to incompatible/duplicate jquery libraries. the one i can't get past is 'element.propAttr is not a function'. i can only get gallerymanager to work by deleting yii's jquery-ui.min.js, but this obviously breaks other parts of my app.

something is registering jui/js/jquery-ui.min.js after the body (POS_END?), but for the life of me i can't figure out where. i have disabled all other modules.

anyone else have these issues or can explain what is going on?

#6607 report it
gareth at 2012/01/20 03:14pm
easy authentication

This looks like an easy way to set up authentication on the module

http://www.yiiframework.com/wiki/89/module-based-login/

I would appreciate a walkthrough specific to the Image Gallery Admin using this authentication method

For example on step 2 I am unsure which page this code should be placed on as we would only want authentication on the admin - not on viewing the gallery

#6363 report it
gareth at 2012/01/03 09:38am
Image file path changed

Just to save others a head ache

If you change your folders some how EG have the whole site in a subfolder during development but not the final hosted site - this will alter the image file path in the database

You must manually change the image table to the correct filepath in that case

This is once it all works prior to final upload or if changing development servers

#6224 report it
Flávio Fagundes at 2011/12/20 05:59am
another extension

Guys

I don't like the needs to alter: "error reporting" in php.ini is not STRICT.

I will found another extension.

Tnx

#6188 report it
gareth at 2011/12/17 10:42pm
Cant create gallery

Nailed it !!

again saved by KieranA

the error of the "X" button not creating a new gallery is due to the errors in in : /views/pl/_gallery_form.php (line 130 and 137)

Many thanks.

#6187 report it
drumaddict at 2011/12/17 07:48pm
@gareththomasnz

Lower the error reporting level in your php.ini so that it doesnt throw those undefined variable exceptions.Make sure you have hidden index.php from requests.Please don't post tons of debugging code here,send it to my email box next time...

#6148 report it
drumaddict at 2011/12/15 02:08pm
@Bman900

Sorry I don't know how to help you.Maybe EGalleria has been updated to a new version that breaks my extension,but I really don't have time to investigate this...

#6144 report it
Bman900 at 2011/12/15 09:13am
EGalleria extension

Thank you drumaddict, and I am having another problem, I used your code to implement the gallery with EGalleria, and I have downloaded the extension but instead of looking like your site, the big version of the images are displayed right under each other. What could be causing this?

#6141 report it
drumaddict at 2011/12/15 08:53am
@Bman900

The extension does not deal with authentication/authorization since it's up to the individual how to implement this.I personally use RBAC which is configured to handle all controller actions,not just a particular module or extension.

#6139 report it
Bman900 at 2011/12/15 08:35am
User Premission?

Is there a way I can allow registered users to be able to upload only. And admins are the only ones able to delete and create galleries? Thank you.

#5999 report it
drumaddict at 2011/12/04 07:20am
@subakaran

I cannot help you without an error message.I assume you have firebug on firefox,watch the console for errors.Follow the instructions carefully,and make sure your error reporting in php.ini is not STRICT.If the problem persists please mail me personally in my profile.

#5997 report it
subakaran at 2011/12/04 05:55am
Add buttton does not work

Hi I click (+) plus button to add category . But it does not work.

pls help me.

Thanks..

#5970 report it
Flávio Fagundes at 2011/12/01 10:43am
@drumaddict

I tried a few times and got error on several points.

\app\protected\modules\imgManager\controllers\PlController.php(74) \yii\db\ar\CActiveRecord.php(2276) \app\protected\modules\imgManager\views\pl\index.php(32) \app\protected\modules\imgManager\views\pl_gallery_form.php(130)137

Please, could you provide the source with a downloadable source demo?

Would greatly appreciate it.

#5967 report it
drumaddict at 2011/12/01 07:17am
@flaviofagundes

I am using PHP 5.3 and yii 1.8 too,and the extension works fine,as you can see in the demo. Make sure you don't have a strict setting for error reporting in php.ini,otherwise it may raise some undefined variable exceptions.I would like to organize the code in this extension,maybe eliminate some duplicate javascript-when and if I find the time.But the extension works.

Leave a comment

Please to leave your comment.

Create extension