Showing posts with label symfony plugin. Show all posts
Showing posts with label symfony plugin. Show all posts

Monday, August 8, 2011

Integrate and customize fckeditor with symfony

Till date, I always preferred tinymce rich text editor with symfony. But noticing that it does not provide inbuilt functionality for file uploading with browse.


After getting my hands burns on with plug-ins, I than moved to remove the tinymce and go with FCKEditor. Believe me it was worth opting for the later. Though it was not an easy task to get it work with symfony 1.4 but neither it was too hard if followed the basic steps.

Below are steps which provide me with perfect integration of fckEditor.

I am assuming, you already have fckeditor symfony plug-in and fckeditor js lib in your source code.

1: Copy and paste fckeditor_php5.php
           copy from projectName/web/js/fckeditor/fckeditor_php5.php TO projectName/lib/fckeditor_php5.php
2. save fckconfig.js as customconfig.js
           copy from projectName/web/js/fckeditor/fckconfig.js TO projectName/web/js/fckeditor/customconfig.js


Basically, you would have to make all your changes to customconfig.js and no change to fckconfig.js
Though it seems typical, I tried changing directly fckconfig.js but to no avail. It did not had any changes affected. :(


In customconfig.js
 1. to change the skin theme, FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/' ;
// there are 3 skins available. Default, silver and office2003
 2. To provide only required ToolbarSets, change appropriate changes to FCKConfig.ToolbarSets["Default"]
Mine is as below:

FCKConfig.ToolbarSets["Default"] = [
    ['Source','DocProps', 'Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
    ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
    ['Link','Unlink','Anchor'],
    ['Image','Flash','Table','Rule','Smiley','SpecialChar'],
    '/',
    ['Style','FontFormat','FontName','FontSize'],
    ['TextColor','BGColor'],
    ['FitWindow','ShowBlocks','-','About']        // No comma for the last row.
] ;
3. to allow fckeditor to submit data to the form set below config to false. If its set to true than no change in data would be send to serve.
FCKConfig.MsWebBrowserControlCompat = false ;
FCKConfig.PreventSubmitHandler = false ;


Now the final change:

Since we have change the config file from fckconfig.js to customconfig.js, we need to load the same js.
To change so, open fckeditor.html at     /js/fckeditor/editor/fckeditor.html
Change LoadScript( '../fckconfig.js' )  to LoadScript( '../customconfig.js' ) ;

For Symfony changes
Get the sfFCKEditorPlugin from here
install the plugin
Enable plugin from your config/ProjectConfiguration.class.php
$this->enablePlugins('sfFCKEditorPlugin');

Make the change in settings.yml in your modules directroy
all:
  .settings:
    rich_text_fck_js_dir: js/fckeditor

In the form.class, do the following for widget you need fckeditor:
$oFCKEditor = new sfWidgetFormFCKEditor(array('rows'=>50));
$this->setWidgets(array('Text'  =>  $oFCKEditor,));

This is it. Hope it helps.

For any concerns, feel free to mail me or post comments





Friday, April 29, 2011

How to add authentication in symfony for access rights - credentials

Today, I cam across issue where I needed to set access rights for certain user types in symfony for different modules.
Let me put up the steps and how it can be done:

First of all you need to make changes to security.yml in App directory:
/App/config/securiy.yml
For each module, depict whether it requires any authentication or not.

For example:
default:
  is_secure: false
modulename1:
  is_secure: true
modulename2:
  is_secure: true

Go to module where you require to have users based access
i.e App/[frontend | admin ]
in my case i wanted to set rights in frontend section:
so its apps/frontend/modules/config/security.yml
all:
  is_secure: true
  credentials: [ credentialname1, credentialname2 ]

if certain action requires authentication and certain not than:
for exmaple:
action1 and action2 below do not require any authentication where as remaining other requires authentication based on credentital.

actionname1:
  is_secure: false
actionname2:
  is_secure: true
  credentials: [ credentialname1 ]
all:
  is_secure: true
  credentials: [ credentialname2 ]

Now the final part is to assign credentials when user log-in to the system or application

Once authenticated, write the following code before any redirection:
$this->getUser()->addCredential('credentialname1');
OR
$this->getUser()->addCredential('credentialname2');

and finally, remember to clear the cache :)

Hope it helps
www.edugoog.com

Tuesday, April 26, 2011

Nice symfony plugin for flash based grpahs

I came across to build flash based graph in symfony. Found a nice plugin available , easy to integrate and has good customistion

http://www.symfony-project.org/plugins/stOfcPlugin

In case, anyone needs any help or concern, feel free to post .

Have a good time!!!