iCrud - CRUD with i18n support

Greetings from Colombia.

I’ve developed a new CRUD that I called iCRUD (i18n crud). It is already prepared for i18n messages and also It has some improvements over standard CRUD command.

Referenced input fields are automatically created as Comboboxes instead of textbox (if it is nullable, then a ‘Please select’ option is added). In view, admin and index views, referenced fields are loaded from master table instead of showing id value only.

Also, Controllers are extended from SBaseController (SRBAC Controller), nevertheless, It works perfectly without it.

Comments and suggestions are welcome.

If you wanna give it a try, you just have to:

[list=1][]Download icrud.zip from extensions.[]Unzip icrud.zip into any directory.[]Copy all files from shell directory to protected/shell directory.[]Copy all files from messages directory to protected/messages directory.[*]Setup config/main.php file with i18n support:

    'language'=>'es',


    'charset'=>'utf-8',

and into components block:

            'messages'=>array(


                    'class'=>'CPhpMessageSource',


            ),[*]Ready to use.[/list]I hope all you enjoy it.

Best regards.

Hi,

nice Extension, but i have two urgent and one normal bug Reports/Enhancements i needed to do to get it working:

1.)

please add an ucfirst($modelClass) to shell/iCrudCommand.php in line 36, 39, 83 & 86 since the tablename of the Database doesn’t need to be identical to the Model Classname. (like this:)




  public function generateActiveField($modelClass,CDbColumnSchema $column)

        {

                if($column->isForeignKey){

                        $model=CActiveRecord::model(ucfirst($modelClass));

                        $table=$model->getTableSchema();

                        $fk = $table->foreignKeys[$column->name];

                        $fmodel=CActiveRecord::model(ucfirst($fk[0]));

                        $fmodeltable = ucfirst($fmodel->tableName());

                        $ftable=$fmodel->getTableSchema();

                        $fcolumns=$fmodel->attributeNames();


                        if($column->allowNull)

                                return("echo CHtml::activeDropDownList(\$model,'{$column->name}',CHtml::listData({$fmodeltable}::model()->findAll(), '{$ftable->primaryKey}', '{$fcolumns[1]}'),array('prompt'=>Yii::t('App', 'Choose...')))");

                        return("echo CHtml::activeDropDownList(\$model,'{$column->name}',CHtml::listData({$fmodeltable}::model()->findAll(), '{$ftable->primaryKey}', '{$fcolumns[1]}'))");

                }




(and so on)

2.)

please update the Controller Code to be compatible with yii-1.1-dev this way:

shell/icrud/controller.php

at line 20:





        public $menu = array();

        

        public $breadcrumbs = array();



(this is missing in the SBaseController of SRBAC, too at the moment…)

Nevertheless: really good Idea and good implementation so far.

3.)

In your generated Controller line 137:




   throw new CHttpException(404,Yii::t('The requested page does not exist.'));



should be




   throw new CHttpException(404,Yii::t('App', 'The requested page does not exist.'))



4.) I have made a german App message string collection for you to include in the next version, if you want to collect some default i18n message strings. I can send it by mail (this forum doesnt allow attaching files for me)

Thanks for your feedback.

Could you give me more details? I undertand your position, but I’ve not found and/or experienced problems without ucfirst statement. iCRUD has being developed for working with Yii 1.1 (my test have been on Yii 1.1 lastest svn), also, $modelClass var is loaded with model name exactly same to CRUD standard command. Nevertheless I’m gonna do more tests to verify this bug.

Fixed, generated Controller is not being extended from SBaseController anymore, since Yii 1.1 has a default Controller. This way iCRUD will be more usable and can be work with or without SRBAC. However, in srbac svn this bug has been already fixed.

Fixed.

I added you to Skype, that way we can chat about and you can send me your i18n messages file.

I’m going to upload the new version with this little fixes. And if some one wants to send a language messages file will be very helpful to all.

Again, thanks for your feedback, I hope this extension let us to do our work easier, faster, more extendable, more reliable, etc, etc, etc. We should concentrate on what is really important, not in little details.

Best regards.

I’ve uploaded a new version, also SVN is working now.

http://code.google.com/p/icrud/

Feedback, suggestions and new ideas are welcome.

Regards

I’ve published a new Beta version of iCRUD. The new version have some improvements:

  • French messages added.
  • Datatype TINYINT(1) is evaluated as BOOLEAN when MySQL databases are used.
  • Also, some minor bugs and messages fixed.

New languages and improvements are welcome.

A new version of iCRUD has been published. Several improvements and bugs fixed. Give it a try. This version is the first candidate to be stable version.

Some of the new features (and bugs fixed) are:

  • Fixed bugs in index view and controller.
  • Default view is admin (index is not anymore)
  • Breadcrumbs are using a text value (with i18n support too)
  • Foreign keys now can be filtered by combo-boxes (no bugs)
  • Fixed bugs when showing foreign keys in list, view and main views.
  • Spanish and French translations updated.
  • Some other minor optimizations and some minor fixed bugs.

I hope you enjoy this extension, and I’ll wait for your feedback. New message languages are welcome (e.g. Chinese, Portuguese), current languages are: English (default in Yii), German(thnx to thyseus)(need to be updated), Spanish and French (needs to be revised by a native, this is not my mature tongue).

Best regards.

I revised your french translation. I added the last two and modified one of them. French is my native language :)

Thanks Francois. French messages has been already updated to svn repo.

Updated German messages to svn repo. Thanks to thyseus

Last updates: Added Portuguese messages to SVN Repo.

Revision by a native is needed (I speak portuguese but a native can do it better)

I uploaded a new version of iCRUD, it has some minor bugs fixed and the addition (and fixes) of Portuguese message.

Also, It includes and extended version of FormCommand that I called iFormCommand (for testing purposes only because it is not a definitive version). FormCommand is only available since Yii 1.1.1-dev, so if you want to try this command you must download the last Yii version from SVN repository.

Feedback, suggestions and comments are welcome.

Regards.

Does anybody tried iCRUD with PostgreSQL databases?

Good News: Support for multiple languages in GiiModule is being added to iCRUD, suggestions and ideas are welcome.

Regards.

[solved]

Tried to test it out but got this error:


CException

Description


Property "CPhpMessageSource.enabled" is not defined.



[edit]

Typo in config :) placed ‘messages’=>array(‘class’=>‘CPhpMessageSource’), in log component :D

Lithuanian translation file bellow:

665

App.php

Best regards,

CoLT

Hey,

I have tried iCRUD rather successful until one relation one-many admin filter value:

Table WebUser has many Clients, and in Client admin view one value is WebUser(it’s filter works ok):

admin.php


		array(

            'name'=>'Web_user_id',

            'value'=>'$data->WebUser->name', //does not work, see error

            'filter'=>CHtml::listData(Web_user::model()->findAll(), 'id', 'name'),

        ),

Error:


PHP Error

Description


Trying to get property of non-object

Source File


C:\wamp\www\p2b8d\lib\yii\base\CComponent.php(587) : eval()'d code(1)


No source code available.


Stack Trace


#0 C:\wamp\www\p2b8d\lib\yii\base\CComponent.php(587): eval()

#1 C:\wamp\www\p2b8d\lib\yii\zii\widgets\grid\CDataColumn.php(125): CDataColumn->evaluateExpression()

#2 C:\wamp\www\p2b8d\lib\yii\zii\widgets\grid\CGridColumn.php(135): CDataColumn->renderDataCellContent()

#3 C:\wamp\www\p2b8d\lib\yii\zii\widgets\grid\CGridView.php(447): CDataColumn->renderDataCell()

#4 C:\wamp\www\p2b8d\lib\yii\zii\widgets\grid\CGridView.php(420): CGridView->renderTableRow()

#5 C:\wamp\www\p2b8d\lib\yii\zii\widgets\grid\CGridView.php(333): CGridView->renderTableBody()

#6 C:\wamp\www\p2b8d\lib\yii\zii\widgets\CBaseListView.php(152): CGridView->renderItems()

#7 unknown(0): CGridView->renderSection()

#8 C:\wamp\www\p2b8d\lib\yii\zii\widgets\CBaseListView.php(135): preg_replace_callback()

#9 C:\wamp\www\p2b8d\lib\yii\zii\widgets\CBaseListView.php(121): CGridView->renderContent()

#10 C:\wamp\www\p2b8d\lib\yii\web\CBaseController.php(174): CGridView->run()

#11 C:\wamp\www\p2b8d\views\client\admin.php(79): ClientController->widget()

#12 C:\wamp\www\p2b8d\lib\yii\web\CBaseController.php(119): require()

#13 C:\wamp\www\p2b8d\lib\yii\web\CBaseController.php(88): ClientController->renderInternal()

#14 C:\wamp\www\p2b8d\lib\yii\web\CController.php(748): ClientController->renderFile()

#15 C:\wamp\www\p2b8d\lib\yii\web\CController.php(687): ClientController->renderPartial()

#16 C:\wamp\www\p2b8d\controllers\ClientController.php(128): ClientController->render()

#17 C:\wamp\www\p2b8d\lib\yii\web\actions\CInlineAction.php(32): ClientController->actionAdmin()

#18 C:\wamp\www\p2b8d\lib\yii\web\CController.php(300): CInlineAction->run()

#19 C:\wamp\www\p2b8d\lib\yii\web\filters\CFilterChain.php(129): ClientController->runAction()

#20 C:\wamp\www\p2b8d\lib\yii\web\filters\CFilter.php(41): CFilterChain->run()

#21 C:\wamp\www\p2b8d\lib\yii\web\CController.php(999): CAccessControlFilter->filter()

#22 C:\wamp\www\p2b8d\lib\yii\web\filters\CInlineFilter.php(59): ClientController->filterAccessControl()

#23 C:\wamp\www\p2b8d\lib\yii\web\filters\CFilterChain.php(126): CInlineFilter->filter()

#24 C:\wamp\www\p2b8d\lib\yii\web\CController.php(283): CFilterChain->run()

#25 C:\wamp\www\p2b8d\lib\yii\web\CController.php(257): ClientController->runActionWithFilters()

#26 C:\wamp\www\p2b8d\lib\yii\web\CWebApplication.php(320): ClientController->run()

#27 C:\wamp\www\p2b8d\lib\yii\web\CWebApplication.php(120): CWebApplication->runController()

#28 C:\wamp\www\p2b8d\lib\yii\base\CApplication.php(135): CWebApplication->processRequest()

#29 C:\wamp\www\p2b8d\www\index.php(13): CWebApplication->run()


2010-05-06 01:22:08 Apache/2.2.11 (Win32) PHP/5.3.0 Yii Framework/1.1.2

Where could the problem be?

[edit] Enhancement

In _view solved the labelling problem with:


if (isset($data->Web_user_id)) echo CHtml::encode($data->WebUser->name); 

Thanks

CoLT