Monday, November 22, 2010

Symfony : Radio Widgets with formatting

Hi,
symfony provides concept of widget. it's just like a sub-framework that provide classes to output HTML fields like input, textarea, select, radio etc...

Suppose you want to create widgets for the set of radio buttons with the option of html formatting of the radio button. creating a form class in module lib directory say Itinerary.Form.class.php
// Itinerary.Form.class.php
class ItineraryForm extends sfForm
{

  public static function radioFormatter($widgets, $inputs)
  {
    $rows = array();
    foreach ($inputs as $input)
    {
      $rows[] = $input['input'].$input['label'];
    }
    return "".implode("", $rows)."";
  }

  public function configure()
  {
      $tourTipChoice    =    array(
                                                         'tourItinerary'                => 'Itinerary',
                                                         'InclusionsExclusions'=> 'Inclusions/ Exclusions',
                                                         'sightSeeing'                 => 'Sightseeing'
                             );

    $this->setWidgets(array( 'tourTip'   => new sfWidgetFormSelectRadio(array(
'choices'                => $tourTipChoice,
                                                                              'formatter'            => array($this, 'radioFormatter')
                                                                             ))
                      ));

    $this->validatorSchema->setOption('allow_extra_fields', true);      
    $this->validatorSchema->setOption('filter_extra_fields', false);
    $this->setDefault('tourTip', 'Itinerary');
  }
}



after that just creating the object this class in action.class.php.
suppose you want to render the widget in your index file. so just create object inside the index funciton like as :
public function executeIndex(sfWebRequest $request)
  {
      $this->form = new ItineraryTourForm();  //Used to call form widgets
  }

now you have to call only the function inside template i.e. in indexSuccess.php

echo $form['tourTip']->render();

It will render the  radio button list in the vertical format as we set in formatter. If we want to add other event on the radio button like onclick(), onsubmit() etc... i.e.

echo $form['tourTip']->render( array('onclick'=> 'showtourTip(this.value);'));

Wednesday, June 23, 2010

Symfony Propel-Database Backup

In symfony, we can take backup of our database with the help symfony commands i.e.

>> To Take dump of your DB
# symfony propel-dump-data application-name file.yml
EX:
# symfony propel-dump-data frontend dump.yml

it will create dump.yml file in data/fixtures/dump.yml.

>> To Reuse of your dump data into your DB
# symfony propel:data-load application-name
EX:
# symfony propel:data-load frontend

It will re-create your db structure......

Friday, June 4, 2010

ProcessMaker -- Open Source Business Process Management

Hi,

From Last few days i was working on processmaker, that is use to design business process for mid sized or SME organization.

it take 3-4 days to config and know about what it is. when i start to configuration, i was just wondering with so many question...
what should i do to start it??, what it will give me??, in what area it will be useful???, is it so powerful tool??

After a long research, I found many solution and good point is that it's have online library/templates to learn new things/feature.

In online library, where you can just edit process and can use in your need...

By the way, I just found out some of the features there are following...

ProcessMaker makes it easy to optimize workflow management and business operations.
1. Create workflow maps, or choose from templates.
2. Design custom forms for all your organization's processes.
3. Pull data from other forms, databases and external sources through web services.
4. Track case progress to see where process delays occur.
5. Analyze results to improve efficiency and effectiveness.

ProcessMaker is a user-friendly workflow manangement system:
1. No programming experience necessary.
2. Easy-to-use AJAX interface for simple process creation and instant preview.
3. Drag-and-drop, browser-based interface makes it simple to map processes.
4. Add users, dynaforms, documents, messages, and alerts with the click of a button.
5. Optional HTML editor gives full control over form appearance.

ProcessMaker gives your organization the advantage of open source:
1. Lower implementation costs, higher value.
2. No vendor lock-in.
3. Installs on Linux & Windows (LAMP/WAMP).
4. Integrates with databases including MySql, Oracle, SQL, PostgreSql.
5. Connects with third party systems through web services.
6. Easy to share information with DMS, BI, CMS, ERP systems.


At the end, here you can assign user rights on particular task to view uploaded file,trigger of mail,view of generated doc/report etc...

Symfony with PostgreSql

PostgreSql connection with symfony is bit tuffer then mysql db.
For that, you have to edit some of the file in your application directory....
Step 1: Edit config/database.yml

Step 2: Edit file config/propel.ini
here set....
propel.database = pgsql
propel.database.creatUrl = pgsql://user:password@server-ip/database-name
propel.database.url = pgsql://user:password@server-ip/database-name
Step 3: Edit file apps/frontend/config/setting.yml
here set...
use_database: on
orm: propel
Step 4: symfony cc
After that build your model that create sql and respected table classes. via..
1. symfony propel: build-model //create classes
2. symfony propel:build-sql // cretae .sql file
3. symfony propel:insert-sql //create table structure

Wednesday, March 10, 2010

Symfony : Plugin Installation

To install plugin in Symfony
# symfony plugin:install sfGuardPlugin
Uninstalling the plugin is just remove of plugin from the project
# symfony plugin:uninstall sfGuardPlugin
To upgrade the plugin
# symfony plugin:upgrade sfGuardPlugin
To list the installed plugin
symfony plugin:list

Symfony Installation in Linux

To Install Symfony framework, required php-pear package. that help to install/un-install the symfony.
There are few steps to install it and run on CLI:
Step 1: yum install php-pear*
Step 2: pear install symfony/symfony
OR
Step 2: if you are specific to install symfony version
pear install symfony/symfony-1.1.9
check symfony version:
# symfony -V
TO Un-Install Symfony
pear uninstall symfony/symfony

Friday, February 5, 2010

Javascript: table cell highlighting on radio button change

Hello,
Below code for making table cell highlight on change of radio-button.

In Head Section:


In Body tag :

Monday, February 1, 2010

Session in Symfony

Hi,
setting of session in symfony --
in action.class.php
session object for the current user is accessed in the action with the getUser() method and is an instance of the sfUser class.
This class contains a parameter holder that allows you to store any user attribute in it.
Ex:
class myModule extends sfActions
{
   public function executeFirst()
   {
    $name = $this->getRequestParameter('name');
    $this->getUser()->setAttribute('name', $name);
   }
   public function executeSecond()
   {
    $ses_name = $this->getUser()->getAttribute('name'); //Retrieve session values
   }
}

attributes are stored in a parameter holder that can be accessed by the getAttributeHolder() method. It allows for easy clean-up of the user attributes with the usual parameter holder methods.

//To remove session variable
$this->getUser()->getAttributeHolder()->remove('name');

//To clear session varaible
$this->getUser()->getAttributeHolder()->clear();

In Template:
The user session attributes are also available in the templates by default via the $sf_user variable, which stores the current sfUser object.

Ex:
$sf_user->getAttribute('name');

Monday, January 25, 2010

KDE Big Font Size problem

Hi friends,

Last few days..i faced problem in KDE font size that comes in menu of system settings.
i can't view any of the setting.
at last, i find the solution and getting relax and good feel.
just follow some steps:
step1: Go to System Setting
step2: select Look & feel->Appearance
step3: select fonts category
step4: set force fonts DPI = 96 DPI

then, Restart the system i got the desired output.

Above issue you can solve via cli:

step 1: go to /home/{User}/.kde/share/config/
step 2: vi kcmfonts
step 3: set forceFontDPI=96
step 4: reboot the system

i hope, above points will help you, if you are in the same boat. :)