- Note:This extension is buggy now,and I have no intent to update it.
- Overview
- Requirements
- Features
- Installation Instructions
- Getting Started
- Resources
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 ¶
- PlUpload Widget for Yii (image uploader)
- PrettyPhoto,(lightbox clone)
- jQuery UI,for JUI dialog
- [Fancybox,(lightbox clone)]( http://fancybox.net/)
- Image extension (Kohana image library for Yii)
- Yii Extension to support Galleria JavaScript image gallery.
- Galleria Official Site
NOTE: With the exception of egalleria extension,you don't have to download these assets,they are already included in module's extension folder.
Very good
Very good! Easy to use.
Thanks for sharing!
Regards!
Thanks
How can one implement and use in a project like if I want to have articles with images, in that I have list of articles displayed with image thumbs then when clicked on will give full detailed page with may one or more images thumbs. I really like it please help. Also show how you can upload the image when you create a new article in the article _form page
@bonnie
What you are asking for is very different from what this extension does.
For what you are trying to accomplish I recommend this extension
ImageFileARbehavior.
Also go to Yii wiki and search for tutorials on how to upload images in forms.
Thanks
Thanks for the extension but your code is awfull.
@tpoxa
I never said I am a PHP or/and Yii guru.That was quite a complex extension to code-at least for my standards.I will be happy to see someone like you build the same extension with better coding practices,so I can learn too.
Not working...
Everything is setup properly and I can access the backend interface. When trying to add new gallery, the following js error appears (via firebug):
<title>404 Not Found</title> ... <h1>Not Found</h1> <p>The requested URL /imgManager/pl/returnGalForm was not found on this server.</p>
If "returnGalForm" is supposed to be a view file, it's not there!
Please re-check your zip!
@yiidf
returnGalForm is NOT a view file,that's why you can't find it n views.It's an action in PlController,which renders partially the _gallery_form view file.
The only thing that comes to my mind as the source of your problem,is the CSRF configuration.Make sure you have configured the request component with CSRF validation enabled as I demonstrate in my instructions.Or else all ajax POST requests will fail.
Still not working whatsoever
Sorry my bad - of course it's an action name. Let me take back the comment with the zip file. Nonetheless, the module is still not working. You seem to use MOD_REWRITE to omit the index.php on your side which is not the case on my side.
Now I got everything running (with the index.php and without CSRF) but it's still not working. It's showing 500 error saying there's some syntax error in the index.php:
PHP Parse error: syntax error, unexpected ';' in /Users/xxxxx/Sites/htdocs/vnfs/protected/modules/imgManager/views/pl/index.php on line 202
This is just to keep you posted. Obviously the error occurs before line 202. However, I don't have much time for debugging this right now. Will try later... and get back.
Buttons doesn't work
Buttons for Add Gallery or Save the uploaded image not work for me (add gallery in the database for test that). Please check files in zip. Thanks !!
using localhost..
IF im using localhost, how to make it work..
I also use a model and want to make it as gallery.. and the gallery created automatically when the model created.. what part to modify..?
@paejan
it will probably work if you set $current_domain='.localhost' if you develop with FireFox.Google Chrome-as far as I know-will not accept cookies from localhost.About the model,I am not sure what you mean,I already use a model for Gallery,it's inside models folder:Gal.Maybe you can modify that to suit your needs....
Still not working
i put $current_domain='.localhost'; at the top of main.php
doesnt it right..? i also can't call image gallery..? are u sure it cause by the CSRF validation? can we except that validation?
What i mean by model is my application let say is about a car. So without manage any gallery i want to set the image base on the car. So image is devide by car as gallery.. I think image table can link directly to car table instead of gal. And I hope u can guide me to modify which part of or code..
however i have to make this module run 1st.. or u can recommend any other module..?
@paejan
$current_domain='.localhost'; will do the job I guess.This is used to set the cookie.
Just follow the instructions.Of course you can except all POST requests from CSRF validation but it's a lot of work,you have to find them all in my code and replace CSRF token with a 'dontvalidate' variable set to an emprty string.(see request configuration).Or dont use CSRF validation at all,but again,you ll have to eliminate all YII_CSRF variables from POST requests.
About the images,I dont think my extension is the right one for what you are trying to accomplish.Better look at this extension
http://www.yiiframework.com/extension/fileimagearbehavior
@drumaddict
I still instresting to use ur solution as i want to link my model to multiple file /image.. and the item in model will have a gallery..
i have problem 'Error 400 The CSRF token could not be verified' when i want to login using IE but it ok in mozilla.. does it mean the CSRF thing work in mozilla and the problem bcoz of sumthing else? i also try nivomanagement ext. ang also got prob.. the uploading process end up with ! icon and the uploading process stop.. was it bcoz of the CSRF thing too?
@paejan
You got the error with IE probably because it doesn't accept cookies from localhost.That's not a problem,you are not developing with IE are you?It will work live on IE,but not in localhost.
I have no idea about your nivosliderMangement,why you got that problem.Look in Firebug for javascript errors.
As I think about it,why don't you use in your -let's say Car - model a property/column called gallery and then make it a Foreign Key which links to my Gallery model's (the name is Gal) primary key : id.So you will have a one one relationship 1car->1gallery=myultiple pictures for car.
Not the CSRF
I think the problem is not the CSRF thing bcoz i can still login with mozilla.. and i try
to login tru IE from LAN using 'ip add' instead of 'localhost' also work..
afterall now all form button doesnt work. plus some of them i add 'dontvalidate' param.
I already add the gallery directly to database and try to upload some images.. pupload did it job well but then i cant save to database as the 'save' button not response.. the image uploaded into the directory perfectly.
using same browser i can try ur demo and its work very well.. i think its all about ur jquery form..
I think the other user also still cant fix it up.. can u figure it out..? fyi im using yii 1.1.8..
@paejan
First things first.Because our conversation may be annoying to other users who are following this page(they get notification emails),please contact me through email.(Through my forum profile).I can assure you my extension works 100% if you strictly follow my instructions.I have tested on a fresh yii installation.My extension uses many ajax requests,so you won't get anywhere with debugging unless you use Firebug.About the button not working,I am sure its CSRF,look at the console in Firebug and see the error message.Again I will be glad to help you,but contact me through email.It's best to leave some space in this page for other users too.Thanks.
Great work!
Really comprehensive - and good documentation too. :D
Kudos from me.
@ jacmoe
Thank you very much jacmoe!It's an honor to get such a positive feedback from a Yii Ninja like you!I really appreciate it!
thanks...
Great!! thanks for sharing
your module very easy to join with another gallery widget especially EGalleria and PrettyPhoto, but before success install this module, i must visit demo online in order to understand your documentation.
Thanks
Hello, i have problem with your extension.
I place my site in the root directory of www so Yii::app()->basePath returns an empty string. So when I try to upload the image script is trying to place it in a folder 'gal_images'.
Is there any way to specify the full path to images folder without overriding the baseUrl to whole project?
@Byakuya
basePath is irrelevant.You can name the upload directory as you wish (just change in the configuration 'upload_directory'=>'[YOUR UPLOAD DIR]').You have to create yourself this folder inside the application root(not the server root).I pretty much repeated the instructions here.Follow the instructions carefully and you should be OK.
Undefined index: galid
I must be a total newbie, but I followed the installation steps, went to the imgManager directory in the browser and get:
Undefined index: galid
in line 74
private function loadGalAndOrder(){ 69 70 71 //Handles the gallery selection from the dropdown selection list, 72 // sets the gallery id ,the gallery record and order of images as 73 // public properties of the controller . 74 if (($_POST['galid'] !='') && ($_POST['galid'] != null)){
current domain is a virtual host by MAMP PRO,
$current_domain='gallery.com';
Is this related to the error?
@JayC
Weird,I never got that error.Maybe some setting in PHP ini related to error reporting,just guessing.Sorry I can't think of anything else...
UPDATE:If you get exceptions is probaly because of your error reporting setting in php ini.
If you set it to
,those errors will go away.
Fixes to PHP errors.
I fixed the issues that where causing the errors:
In PIController.php change line 74 to:
if (isset($_POST['galid']) && !empty($_POST['galid']) ){
In /views/pl/index.php change line 33 to:
echo CHtml::dropDownList('gal_name', (isset($_POST['galid']) && !empty($_POST['galid']))?$_POST['galid']:$ses->get('s_galid','no_gal_selected'),
in :
/views/pl/_gallery_form.php (line 130 and 137)
change the <?php// echo
to
<?php // echo
New Version
Hi
I'm trying to use the extension with the yii 1.8 and PHP 5.3.
I found several problems with php and js source.
There is a forecast of patches or new version?
@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.
@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.
Add buttton does not work
Hi
I click (+) plus button to add category . But it does not work.
pls help me.
Thanks..
@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.
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.
@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.
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?
@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...
@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...
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.
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
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
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
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.
@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.
@bmn js error
I also have to change to 1.1.8 to get that working.
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!
New version
Anybody has a version working with the latest Yii ?
too many bugs
unuseful extension
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.