Friday, May 21, 2010

Zend Framework 1.10.4 PHP Versions Compatibilty

PHP_Compatinfo






Module Minimum PHP Version C Extensions / File (if it ends with .php)
Acl 5.0.0 0
Amf 5.0.0 0 date,dom,mysql,mysqli,pcre,SimpleXML
Application 5.0.0 0 pcre,SPL
Barcode 5.0.0 3 gd,pcre
Cache 5.2.1 3 date,hash,pcre,SPL,SQLite
Cache 5.2.1 1 Cache/Backend.php
Captcha 5.1.0 3 date,gd,SPL
Config 5.0.0 0 dom,SimpleXML
Console 5.0.0 0 pcre
Controller 5.0.0 1 pcre,session,SPL
Crypt 5.2.0 0 Crypt/Rsa.php
Crypt 5.2.0 1 Crypt/DiffieHellman.php
Crypt 5.2.0 0 Crypt/Rsa/Key/Public.php
Crypt 5.2.0 0 Crypt/Rsa/Key/Private.php
Currency 5.0.0 0
Date 5.2.0 1 date
Date 5.2.0 0 Date.php
Date 5.2.0 1 Date/DateObject.php
Db 5.1.0 3 mysqli,pcre,SPL
Dom 5.1.0 0 dom,libxml,pcre
Feed 5.1.2 1 ctype,date,dom,hash,iconv,libxml,pcre
File 5.2.1 5 File/Transfer/Adapter/Abstract.php
Form 5.0.0 0 pcre
Gdata 5.1.0 1 ctype,date,dom,openssl,pcre
Http 5.2.1 5 Http/Client.php
Json 5.0.0 1 mbstring,pcre
Json 5.3.0 1 Json.php
Layout 5.0.0 0
Ldap 5.2.0 0 Ldap/Node/Abstract.php
Locale 5.0.0 6 bcmath,iconv,pcre,SimpleXML
Log 5.0.0 5 dom,pcre
Measure 5.0.0 0 pcre
Memory 5.0.0 0
Navigation 5.2.0 0 Navigation/Page.php
Oauth 5.0.0 0 date,pcre
OpenId 5.0.0 5 date,pcre
OpenId 5.2.0 3 OpenId.php
Pdf 5.2.0 2 Pdf.php
Pdf 5.2.0 0 Pdf/Page.php
ProgressBar 5.0.0 4 pcre
Queue 5.0.0 2 date,pcre
Search 5.0.0 7 dom,iconv,mbstring,pcre,SimpleXML
Serializer 5.2.0 2 Serializer/Adapter/Wddx.php
Serializer 5.2.0 2 Serializer/Adapter/Igbinary.php
Serializer 5.2.0 0 Serializer/Adapter/PhpCode.php
Serializer 5.2.0 0 Serializer/Adapter/PhpSerialize.php
Service 5.2.1 2 date,dom,hash,iconv,libxml,pcre,session,SimpleXML,SPL,xml
Service 5.2.0 0 Service/WindowsAzure/Storage.php
Service 5.2.1 0 Service/WindowsAzure/Storage/Blob/Stream.php
Session 5.0.0 0 date,pcre,session,SPL
Test 5.0.0 0 pcre,SPL
Text 5.0.0 1 ctype,iconv,pcre,SPL
Translate 5.0.0 0 pcre,SPL,xml
Uri 5.1.0 0 ctype,pcre
Wildfire 5.0.0 0
XmlRpc 5.1.2 2 date,dom,iconv,pcre,SimpleXML,xmlwriter

Thursday, May 20, 2010

ExtJS Grid with ASP.NET MVC backend w/ paging

The main issue of this post is to show how to use EXT JS Grids, and how to use a backend that feeds them. The backend is developed in C# using ASP.NET MVC, but could be virtualy any source that could effectively generate a JSON stream.


First, have a look at our C# JSON Generator. We have to remember that we must give the View two elements: The total number of elements to display and the data in a List.








<%@ Page Language="C#" %>
<%@ Import Namespace="iPrimeCRM.Models" %>
{"totalCount" : <%= Html.Encode((int)ViewData["total"]) %>,
"data" :[
<% for (int i = 0; i < ((List Case>)ViewData["list"]).Count; i++ )
{%>
<%if (i > 0){%>
,
<% }%>
{
<%Case case= (List Case>)ViewData["list"]).ElementAt(i);%>
"Id" : <%=case.CASEID%>,
"Name" : "<%=Html.Encode(case.NAME)%>",
"Type" : "<%=Html.Encode(case.TYPE)%>",
"Priority" : "<%=Html.Encode(case.PRIORITY)%>"
}
<%} %>
]
}


You must change just the part where the fields per row are set, remembering that each object on the List must be converted to its JSON representation:

"Field Name" : "Value"
"Field Name" : 34  // if it is an integer


We must obtain something like this (without the indentation)

{
    "totalCount" : 1,
    "data": [
        {
            "Id" : 1,
            "Name" : "Saint Andrews School",
            "Type" : "Schools and Universities",
            "Priority" : "High"
        }
    ]
}


To check if our JSON stream is OK, we could use an online tool called JSONLint on www.jsonlint.com which validates the result.

(This could be done with PHP, Java, Python or any Language... that's the great thing about this).

Now we have the HTML content and javascript code that will consume this JSON stream to show a Grid. Remember to include the ExtJS scripts before.


<script type="text/javascript" language="javascript">

Ext.onReady(function() {

var casesGridReader = new Ext.data.JsonReader({ root: 'data',
totalProperty: 'totalCount'
},
[
{ name: 'Id' },
{ name: 'Name' },
{ name: 'Type' },
{ name: 'Priority' }
]);

var casesDataProxy = new Ext.data.HttpProxy({
url: '../../ServiceCase/ListCasesJSON'
});

var casesDataStore = new Ext.data.Store({
proxy: casesDataProxy,
remoteSort: true,
reader: casesGridReader
});

casesDataStore.load({ params: { start: 0, limit: 10} });

var casesPagingBar = new Ext.PagingToolbar({
pageSize: 2,
store: casesDataStore,
displayInfo: true,
displayMsg: 'Showing Cases {0} - {1} from {2}'
});

var checkBoxSelMod = new Ext.grid.CheckboxSelectionModel();

var casesGrid = new Ext.grid.GridPanel({
store: casesDataStore,
columns: [
checkBoxSelMod,
{
header: '# Case',
dataIndex: 'Id',
width: 50
}, {
header: 'Name',
dataIndex: 'Name',
width: 150
}, {
header: 'Type',
dataIndex: 'Type',
width: 90
}, {
header: 'Priority',
dataIndex: 'Priority',
width: 80
}
],
bbar: casesPagingBar,
renderTo: 'gridDiv',
width: 700,
autoHeight: true,
loadMask: true,
selModel: checkBoxSelMod,
frame: false

});

</script>

Remember that:

  • Limit : 10  means that the grid thinks it will receive 10 or less elements in the JSON stream, it does it to calculate the number of pages it will show. The pagination should be done on server side.
  • We should include a DIV called "gridDiv" where the Grid will be rendered.
  • If anything fails remember you could check JSON streams on JSONLint. 


Many thanks to Marita Arce for writing the original Spanish version.



How to install PHPUnit in Centos 5.x

yum install php-pear-PHPUnit

In the file /etc/php.ini add the following line:

include_path = ".:/usr/share/pear/"

How to solve Eclipse bug on Ubuntu (click not working on buttons / updates)

To solve this bug just create a custom launcher for your app.

Create the file: eclipseLauncher.sh


export GDK_NATIVE_WINDOWS=true
"/path/to/eclipse"

Give the file execution permission:

chmod a+x eclipseLauncher.sh

Execute this file when you want to start Eclipse.

This applies for MyEclipse and Zend Studio too.