Sunday, August 19, 2012

Yii PHP Framework v1.1.12 Download and Upgrading Instructions

Yii PHP framework has been released for v1.1.12 Stable on Aug 19, 2012 and available to download. You can download Yii Framework v1.1.12 on http://www.yiiframework.com/download/

This release mainly fixes the BC-breaking issues we have found in the prior release. It includes about 20 bug fixes, minor features and enhancements. For the complete list of changes in this release, please see:

Yii PHP Framework version 1.1.12 August 19, 2012
  • Bug #190: WSDL return tag was not generated by CWsdlGenerator when Macintosh line endings were used inside service describing docblock (resurtm)
  • Bug #1066: CMemCache: expiration time higher than 60*60*24*30 (31536000) seconds led the value to expire right away after saving (resurtm)
  • Bug #1072: Fixed the problem with getTableAlias() in defaultScope() (creocoder)
  • Bug #1076: CJavaScript::encode() was not compatible with PHP 5.1 (samdark)
  • Bug #1077: Fixed the problem with alias in CSort (creocoder)
  • Bug #1083: CFileValidator is now unsafe by default. This will prevent setting attribute when no file was uploaded (samdark)
  • Bug #1087: Reverted changes to CCookieCollection::add() introduced in 1.1.11 as they were triggering E_STRICT on some old PHP-versions (suralc)
  • Bug #1088: Fixed usage of proper CActiveForm id property when it's supplied with htmlOptions (mdomba)
  • Bug #1094: CGridView with enabled history used to clear page title in case sorting or paging performed (Opera and Firefox only) (resurtm)
  • Bug #1109: Fixed "js:" encoding BC-break in CHtml::ajax() and related methods introduced in 1.1.11 (samdark)
  • Bug #1120: Fixed duplicate events processing in CGridView when ENTER was pressed for filtering (mdomba)
  • Bug #1192: CHttpCacheFilter failed to comply with RFC 2616, section 10.3.5 (DaSourcerer)
  • Bug #1207: Fixed an issue in CHtml::resolveValue() which occurs when handling tabular data input (Qiang)
  • Bug #1225: Fixed the bug that $.fn.yiiGridView.getChecked was not working always if a custom CGridView::template was used (mdomba)
  • Bug #1243: Fixed the bug that when using CUrlManager::addRules with $append=false rules were added in reverse order (samdark)
  • Enh #243: CWebService is now able to deal with the customized WSDL generator classes, was hardcoded to the CWsdlGenerator before, added CWebService::$generatorConfig property (resurtm)
  • Enh #636: CManyManyRelation now parses foreign key for the junction table data internally, and provide public interface to access it (klimov-paul)
  • Enh #1163: CGridview does not create empty class attributes anymore (cebe)
  • Chg #1099: Changed connectionId dropdown to sticky text field in Gii model generator (mdomba)
  • Chg #1167: Reverted back the change to CComponent::evaluateExpression() about global function support (Qiang)
Upgrading Instructions for Yii Framework v1.1.12

The following upgrading instructions are cumulative. That is, if you want to upgrade from version A to version C and there is version B between A and C, you need to following the instructions for both A and B.

General upgrade instructions
  • Make a backup.
  • Clean up your 'assets' folder.
  • Replace 'framework' dir with the new one or point GIT to a fresh release and update.
  • Check if everything is OK, if not รข€” revert from backup and post issues to Yii issue tracker.
Yii Framework Tutorials

Saturday, August 18, 2012

Creating Database Design for Forum Application Software Yii Framework

After determining the features, it is time to creating database design for forum application software Yii Framework.
  • Level: Table level is used as the identity of the User level. As already exist on the features that the user in this application consists of three types of user, namely Admin, Moderator and User Ordinary. With the table level, becomes possible if we want to modify the user level.
  • Category: To divide the existing thread into certain categories. Categories can also be added, subtracted and modified as needed.
  • User: This table is used to store user information. User table is also used for the authentication process when the user login process.
  • Thread: Storing all information contained in the forum thread.
  • Comment: Keep all the comments from each thread
  • News: Saving the information inputted by the admin news which will then be displayed on the main page of the application.
  • Raputation: Keep all judgments given by the user to a user.
  • Threadstar: Storing information on an assessment carried out by the user thread.
The following SQL database on which I have made:
CREATE TABLE IF NOT EXISTS `comment` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(255) DEFAULT NULL,
 `content` text NOT NULL,
 `user_id` int(11) NOT NULL,
 `thread_id` int(11) NOT NULL,
 `datePost` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY (`id`),
 KEY `user_id` (`user_id`),
 KEY `thread_id` (`thread_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `category` (
 id` int(11) NOT NULL AUTO_INCREMENT,
 `category` varchar(100) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `level` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `level` varchar(50) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `news` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(200) NOT NULL,
 `content` text NOT NULL,
 `photo` varchar(200) NOT NULL,
 `user` int(11) NOT NULL,
 PRIMARY KEY (`id`),
 KEY `user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `raputation` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 `jenis` tinyint(1) NOT NULL,
 `pemberi_id` int(11) NOT NULL,
 `penerima_id` int(11) NOT NULL,
 PRIMARY KEY (`id`),
 KEY `pemberi_id` (`pemberi_id`),
 KEY `penerima_id` (`penerima_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `thread` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(255) NOT NULL,
 `content` text NOT NULL,
 `user_id` int(11) NOT NULL,
 `category_id` int(11) NOT NULL,
 `datePost` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY (`id`),
 KEY `user_id` (`user_id`),
 KEY `category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `threadstar` (
 `is` int(11) NOT NULL AUTO_INCREMENT,
 `nilai` int(11) NOT NULL,
 `user_id` int(11) NOT NULL,
 `thread_id` int(11) NOT NULL,
 PRIMARY KEY (`is`),
 KEY `user_id` (`user_id`),
 KEY `thread_id` (`thread_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `user` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(20) NOT NULL,
 `password` varchar(50) NOT NULL,
 `saltPassword` varchar(50) NOT NULL,
 `email` varchar(50) NOT NULL,
 `joinDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 `level_id` int(11) NOT NULL,
 `avatar` varchar(30) DEFAULT NULL,
 PRIMARY KEY (`id`),
 UNIQUE KEY `username` (`username`),
 KEY `level_id` (`level_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

ALTER TABLE `comment`
 ADD CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`user_id`)
REFERENCES `user` (`id`) ON UPDATE CASCADE,
 ADD CONSTRAINT `comment_ibfk_2` FOREIGN KEY (`thread_id`)
REFERENCES `thread` (`id`) ON UPDATE CASCADE;

ALTER TABLE `news`
 ADD CONSTRAINT `news_ibfk_1` FOREIGN KEY (`user`) REFERENCES
`user` (`id`) ON UPDATE CASCADE;

ALTER TABLE `raputation`
 ADD CONSTRAINT `raputation_ibfk_1` FOREIGN KEY (`pemberi_id`)
REFERENCES `user` (`id`),
 ADD CONSTRAINT `raputation_ibfk_2` FOREIGN KEY (`penerima_id`)
REFERENCES `user` (`id`);

ALTER TABLE `thread`
 ADD CONSTRAINT `thread_ibfk_3` FOREIGN KEY (`user_id`)
REFERENCES `user` (`id`) ON UPDATE CASCADE,
 ADD CONSTRAINT `thread_ibfk_4` FOREIGN KEY (`category_id`)
REFERENCES `category` (`id`) ON UPDATE CASCADE;

ALTER TABLE `threadstar`
 ADD CONSTRAINT `threadstar_ibfk_3` FOREIGN KEY (`user_id`)
REFERENCES `user` (`id`) ON UPDATE CASCADE,

 ADD CONSTRAINT `threadstar_ibfk_4` FOREIGN KEY (`thread_id`)
REFERENCES `thread` (`id`) ON UPDATE CASCADE;

ALTER TABLE `user`
 ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON UPDATE CASCADE;

After you finish creating the database, please create a new Yii Framework application with the name of  "forum", after that connect Yii application to the MySql database that we have made earlier, and activate the feature Gii on Yii Framework. If you've managed to do both, please generate CRUD operations on all existing tables in your database. You can look at my previous post.

Creating Forum Application Software Using Yii Framework

So far there is only a discussion of related issues and concepts of small examples of the use of Yii Framework in some case examples. I think it would be better if we learn how to build real applications with Yii Framework. I will discuss making the real application is the forum software application using Yii Framework. I will discuss the application itself is not a forum that is complex like a vBulletin forum software. I only discuss the basics of most forum applications can not be used to interface between a user with another user, each commenting on a thread, pass judgment on a thread, and others. If you are interested to develop it further, I think it is a good thing.

The following features of the application that we will create:
  • Users can register and login
  • If you have not logged in, everyone can see the forum but can not make a new post or make a comment on a post
  • If you have successfully logged in, users can create new posts and add comments
  • Each posts grouped by category
  • The first page will show the top member, list user posts and news (news) posted by admin
  • User consists of three levels, namely Admin, moderator, and the ordinary Member
  • Admin and moderator can add, edit, and delete the "post"
  • Admin and moderator can manage the "category" and "news"
  • Users have to log in to make comments on a thread
  • User can give reputation to other users

Thursday, April 26, 2012

Best Rich Text Editors Yii Framework Extensions for Web Projects

  1. TinyMCE
    This extension draws a TinyMCE HTML editor using a jQuery plugin. TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB.

    TinyMCE has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.
    Download - http://www.yiiframework.com/extension/tinymce
    Demo - http://www.tinymce.com/tryit/full.php
  2. CKEditor
    CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it. It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice.

    Because CKEditor is licensed under flexible Open Source and commercial licenses, you'll be able to integrate and use it inside any kind of application. This is the ideal editor for developers intending to provide easy and powerful solutions to their users.

    CKEditor provides all features and benefits users and developers expect having on modern web applications. Its amazing performance keep users focused on the things to be done. You will find all common features available on text editors, as well as additional components specially designed for web contents.

    If you think the default features are not enough, CKEditor provides a strong and rich JavaScript API, making it possible to extend it to fit all needs. You can even consider that it has too much features, and removing them is even easier.
    Fully compatible

    One of the strongest features in CKEditor is its almost unlimited compatibility. It's a JavaScript application, so it simply works with all server technologies, just like a simple textarea. In the browser side instead, it has been developed to be compatible with the browsers that dominate the market, namely Internet Explorer, Mozilla Firefox, Google Chrome, Safari and Opera. Even the old Internet Explorer 6 is compatible with.
    Download - http://www.yiiframework.com/extension/ckeditor
    Demo - http://ckeditor.com/demo
  3. NicEdit
    NicEdit is a WYSIWYG editor for websites. Its goal is to be as simple and fast as possible for users of your application. NicEdit is extremely lightweight and can be easily integrated in any site with minimal impact while providing visitors an effective means to express themselves in rich text.
    Download - http://www.yiiframework.com/extension/niceditor
    Demo - http://nicedit.com/demos.php
  4. CLEditor
    CLEditor is an open source jQuery plugin which provides a lightweight, full featured, cross browser, extensible, WYSIWYG HTML editor that can be easily added into any web site.

    In addition to the standard text formatting features found in other WYSIWYG editors, CLEditor also contains rich drop downs for font name, size, style, text color and highlight color. CLEditor allows you to insert images, hyperlinks and horizontal rules.
    Download - http://www.yiiframework.com/extension/cleditor
    Demo - http://premiumsoftware.net/cleditor/
  5. WYMeditor
    EWYMeditor is a wrapper for WYMeditor which is a web-based WYSIWYM (What You See Is What You Mean) XHTML editor (not WYSIWYG).

    WYMeditor's main concept is to leave details of the document's visual layout, and to concentrate on its structure and meaning, while trying to give the user as much comfort as possible (at least as WYSIWYG editors).

    WYMeditor has been created to generate perfectly structured XHTML strict code, to conform to the W3C XHTML specifications and to facilitate further processing by modern applications.

    With WYMeditor, the code can't be contaminated by visual informations like font styles and weights, borders, colors, etc. The end-user defines content meaning, which will determine its aspect by the use of style sheets. The result is easy and quick maintenance of information.

    As the code is compliant to W3C XHTML specifications, you can for example process it using a XSLT (at the client or the server side), giving you a wide range of applications.
    Download - http://www.yiiframework.com/extension/ewymeditor
    Demo - http://wymeditor.no.de/wymeditor/examples/
  6. JMarkItUp
    JMarkItUp is a set of widgets (for Html, Textile, Wiki, Markdown, BBcode, Texy) that encapsulates the markItUp Content Editor (version 1.1.10).

    markItUp! is a content editor plugin based on jQuery. It's not a WYSIWYG editor. Instead, it provides a lightweight, easy-to-use set of buttons, keyboard shortcuts, and other tools to add markup to your content.

    markItUp! is a JavaScript plugin built on the jQuery library. It allows you to turn any textarea into a markup editor. Html, Textile, Wiki Syntax, Markdown, BBcode or even your own Markup system can be easily implemented.

    markItUp! is not meant to be a “Full-Features-Out-of-the-Box”-editor. Instead it is a very lightweight, customizable and flexible engine made to meet the developer's needs in their CMSes, blogs, forums or websites. markItUp! is not a WYSIWYG editor, and it never will be.
    Download - http://www.yiiframework.com/extension/jmarkitup
    Demo - http://markitup.jaysalvat.com/examples/

Wednesday, March 21, 2012

Remove ?r= on Link URL Web Application Yii Framework

To get rid of ?r= the url link web pages on Yii Framework application then you need to do is remove the tag comment on the path-format URLs.

Example url before changed
http://localhost/webappname/index.php?r=site/index
Having changed
http://localhost/webappname/index.php/site/index

  1. Open the protected/main.config.php
  2. Find the following code
    /*
      'urlManager'=>array(
       'urlFormat'=>'path',
       'rules'=>array(
        '/'=>'/view',
        '//'=>'/',
        '/'=>'/',
       ),
      ),
      */
    In the code above we can see there is still a tag comment / * and * /
  3. Remove the tag comment / * and * /
    'urlManager'=>array(
       'urlFormat'=>'path',
       'rules'=>array(
        '/'=>'/view',
        '//'=>'/',
        '/'=>'/',
       ),
      ),
  4. Completed, please reload the page and see your web application url link.

Monday, January 9, 2012

How to Use Crud Generator (Gii Tool - Yii Code Generator)

After I have discussed previously the Controller of making post "How to Use Controller Generator (Gii Tool - Yii Code Generator)" and also the model on the post "How to Use Model Generator (Gii Tool - Yii Code Generator)", I would go again in How to Use Crud Generator (Gii Tool - Yii Code Generator). CRUD (Create Read Update Delete) generator generates a controller and views that implement CRUD operations for the specified data model. Please follow these steps below to use this generator:
  1. Open yii code generator - http://localhost/webappname/index.php?r=gii/default/login
  2. Select Crud Generator and enter the name of your model you created in the Model Generator. It should be noted that the use of uppercase and lowercase letters should be tailored to the name of the Model Class we have made to the Model Generator. In the previous example the discussion of Model Generator, Model name is its Class User (letter U in the word using the letters of the user). And select preview and cetang all existing Code File and click generate.

    On Crud Generator you will see the results on protected\views\user\

    generated controllers\UserController.php
    generated views\user\_form.php
    generated views\user\_search.php
    generated views\user\_view.php
    generated views\user\admin.php
    generated views\user\create.php
    generated views\user\index.php
    generated views\user\update.php
    generated views\user\view.php

  3. To view the results please click on try it now or go on http://localhost/webappname/index.php/user
  4. To operate the CRUD (Create-Read-Update-Delete), you must first login. Open http://localhost/webappname/index.php/site/login

  5. Then go again http://localhost/webappname/index.php/user/. You can see there is not a user.
  6. Have you gone to http://localhost/webappname/index.php/user/create. to create a new user - Create User
  7. If you have made, you can see it back in http://localhost/webappname/index.php/user/index - User List
  8. To Manage User (Create-Read-Update-Delete), you can open it in http://localhost/webappname/index.php/user/admin - Manage Users (View, Update, Delete)
Thus means that you have successfully created a web application CRUD (Create-Read-Update-Delete)

Sunday, January 8, 2012

How to Use Controller Generator (Gii Tool - Yii Code Generator)

Once we have made previous models in the example application of Model Generator (Gii Tool - Yii Code Generator), we proceed again on making the controller. Controller Generator helps you to quickly generate a new controller class, one or several controller actions and their corresponding views. The following implementation steps Controller Generator (Gii Tool - Yii Code Generator)
  1. Login to Gii - http://localhost/webappname/index.php?r=gii/default/login 
  2. Then click on the menu Controller Generator - http://localhost/webappanme/index.php/gii/controller
  3. Fill Controller ID with a user (in accordance with the table we have made)

  4. Click preview and then generate.


    Generating code using template "D:\xampp\htdocs\yii\framework\gii\generators\controller\templates\default"... generated controllers\UserController.php generated views\user\index.php done!


  5. Click to try it now or go to this link http://localhost/webappname/index.php/user, and see the results