This is default featured post 1 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 2 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 3 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 4 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
This is default featured post 5 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.
Senin, 20 Desember 2010
Jumat, 17 Desember 2010
javascript Cache in firefox
Kamis, 02 Desember 2010
Contoh Konfigurasi Pagination CodeIgniter
//contoh url index.php/folder/control/function/offset
//maka urutan offset adalah yang ke-4
$offset = $this->uri->segment(4);
$config['base_url'] = site_url() . '/admin/materi/index/';
$config['total_rows'] = $this->mmateri->get_count();
$config['per_page'] = 5;
$config['uri_segment'] = 4; //penting
$this->pagination->initialize($config);
$paginator=$this->pagination->create_links();
$data["offset"] = $offset;
$data['result'] = $this->mmateri->get_paged($config['per_page'],$offset);
$data['total_page'] = $paginator;
$this->load->view('admin/materi', $data);
Jumat, 26 November 2010
PHP Programming Pattern
Got this from fluppycat.com
PHP Design Patterns Reference and Examples
GoF Creational Patterns | |
Sets of methods to make various objects. | |
Make and return one object various ways. | |
Methods to make and return components of one object various ways. | |
Make new objects by cloning the objects which you set as prototypes. | |
A class distributes the only instance of itself. | |
GoF Structural Patterns | |
A class extends another class, takes in an object, and makes the taken object behave like the extended class. | |
An abstraction and implementation are in different class hierarchies. | |
Assemble groups of objects with the same signature. | |
One class takes in another class, both of which extend the same abstract class, and adds functionality. | |
One class has a method that performs a complex process calling several other classes. | |
The reusable and variable parts of a class are broken into two classes to save resources. | |
One class controls the creation of and access to objects in another class. | |
GoF Behavorial Patterns | |
A method called in one class can move up a hierarchy to find an object that can properly execute the method. | |
An object encapsulates everything needed to execute a method in another object. | |
Define a macro language and syntax, parsing input into objects which perform the correct opertaions. | |
One object can traverse the elements of another object. | |
An object distributes communication between two or more objects. | |
One object stores another objects state. | |
An object notifies other object(s) if it changes. | |
An object appears to change its` class when the class it passes calls through to switches itself for a related class. | |
An object controls which of a family of methods is called. Each method is in its` own class that extends a common base class. | |
An abstract class defines various methods, and has one non-overridden method which calls the various methods. | |
One or more related classes have the same method, which calls a method specific for themselves in another class. | |
Other PHP Design Patterns | |
MVC - Model View Controller - shown using procedural and not OO architecture. | |
Object Oriented PHP Basics | |
The basics of creating a class with OO PHP. | |
The basics of creating an abstract class with OO PHP. | |
The basics of creating an interface with OO PHP. | |
The basics of using Statics with OO PHP. | |
The basics of using this and parent with OO PHP. | |
PHP Performance Testing | |
Which is faster in PHP - if / elseif or switch? | |
Other PHP Stuff | |
As a contractor and freelancer I`ve had a number of interviews, and the same questions seem come up on a regular basis. | |
A few of the many emails about patterns and PHP I have gotten over the past few years. |
MongoDB : a Database that worth to try
MongoDB is document oriented database, mean it's not store database based on table but it store database like json object. So i will find out things that maybe related to my previous experiences with rdbms. In it's web it has a console like tutorial, that was fascinating to test and see if its works.
Kamis, 25 November 2010
Tools PHP Development
https://github.com/sebastianbergmann/
PHPUnit
Phpdcd
Dan masih banyak yang lainnyaa..... ( bang Rhoma mode on)
Tools Java : profiler -> yourkit
http://www.yourkit.com/download/index.jsp
General:
Easiest installation and configuration
Unlimited profiling for one fee
Profiling of J2EE applications
Ability to profile in production environment
32-bit and 64-bit Java support
Automated profiling: profiler API and command line tool
Filters in CPU and memory views
Bacaan Baru : Rife java web framework
RIFE is a full-stack web application framework with tools and APIs to implement most common web features. Each of its toolkits is usable by itself and together they offer powerful integrated features that boost your productivity. RIFE ensures that every declaration and definition is handled in one place in the code. This simplifies the developer's task by reducing code replication, enforcing consistency, and easing maintenance.
RIFE's differentiators are:
- you get 90% of the features with 10% of the usual effort, thanks to its full stack
- logic-less HTML templates that can be previewed in any browser and edited with standard tools
- uniform component model, designed from the ground up for reusability: applications, sub-sites, pages, porlets, widgets, ... can be easily packaged and placed in any other context
- integrated native Java web continuations and flow continuations
- metaprogramming, driven by your domain model, but without polluting it
- flexible declaration and configuration with support for plain Java as well as XML
- core support for web data flow as well as page logic flow
- integrates with existing solutions such as Spring and standard JDBC datasources
- multi-dimensional conversational state management with scoping
- language-independent template engine with support for XHTML, HTML, XML, Text, SQL, Java
- persistence layer with content management integration and versioning
- designed for the creation of consistent maintainable applications as well as on quick delivery
- embraces standard protocols and specifications, providing larger building blocks by wrapping lower layers with high-level functionalities
- out-of-container testing with full introspection capabilities of the executed flow and components
- lightweight execution model that has been proven in production
- built for Java 5 with intelligent downgraded support for Java 4
- designed for developer comfort: minimal application restarts thanks to automatic detection of file modifications
Tools Keren : Microemulator – can convert jad to apk
Dengan tools ini bisa convert JAD ke APK , jadi buat yang punya program game bisa dengan mudah konversi ke android. Gila!
http://www.microemu.org/microemu-webstart/index.html
http://microemu.blogspot.com/2009/08/converting-javame-applications-to.html
- Application demonstration in web browser applet
- Java Web Start demonstration
- Faster development of application in Eclipse
- Using standard java profiling tools to tune your application
- Creation of unit tests for J2ME application that runs during build process
- Development support for platforms where no emulator is available. See api modules
- Support for MIDP 2.0
- Generic Connection Framework
- Support for MMAPI (JSR 135)
- Support for FileConnection API (JSR 75)
- Support for Nokia APIs
- Support for Siemens APIs
- Skinnable and configurable interface
- Works with different graphics libraries; currently with Swing and SWT
- Platform independent: Windows, Linux, OSX
Rabu, 24 November 2010
CakePHP Swf object
Examples
<div id="flashy"><p>No flash loaded</p></div>
<?php echo $flash->renderSwf('test.swf',400,200,'flashy');?><?php
$flash->init(array('width'=>200,'height'=>100));
echo $flash->renderSwf('test1.swf');
echo $flash->renderSwf('test12swf');
?><?php
echo $flash->renderSwf('fl_countdown_v3_3.swf?mo=1&da=24&snd=off&co=AA3333',800,250,false,array('params' => array('movie'=>'?mo=1&da=24&snd=off&co=AA3333')));
?>
Links
Fungsi jQuery untuk mengecek apakah variabel adalah function
To check if variable is a function
jQuery.isFunction(varName);
contoh penggunaan :
var x = function(){
alert("aa");
}
if(jQuery.isFunction(x)){
x();
}
Membatalkan jQuery ajax request
Sebenernya gak Cuma jQuery, tapi ajax secara keseluruhan.
var x = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
//kill the request
x.abort()
Sumber : http://stackoverflow.com/questions/446594/kill-ajax-requests-using-javascript-using-jquery
Tempat Kerja Impian
stackoverflow.com
•20 days vacation
•ridiculous health insurance (no copay)
•free catered lunch
•insanely great workstations, chairs, and desks
•free monthly metrocards
•gym membership reimbursement
•flexible hours
•employees will never be poked with a sharp stick
Selasa, 23 November 2010
Don’t use <A href=’#’> as your custom object
When you need custom object such as treestate checkbox or even six state checkbox please don't use <a href='#'> as your container of object/css background. It will makes page autoscrolled to the top of page and its annyoying. So use <span> instead when you need custom object to your page.
Jumat, 19 November 2010
Using Apache virtual directory with cakephp
Change your .htaccess file in your application folder, in my case is myapp
/--myapp
|--app
|--cake
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myapp
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This should be working.
Agar jQuery object selalu bisa berfungsi setelah recreate
Seringkali object – object dicreate ulang untuk mendapatkan kesan interaktif. Tapi seringkali juga object – object tersebut kehilangan fungsi yang telah diikat/bind atas object itu. Untuk itu pada saat object selesai digunakan
- Unbind , misal jQuery(this).unbind() , perintah ini akan memastikan bahwa action telah hilang sehingga object bisa aman dihilangkan dari memory
- Remove, misal jQuery(this).remove(), setelah melakukan unbind, printah remove memastikan object sudah benar2 tidak ada lagi dilayar.
PERHATIAN : remove tanpa unbind() akan menyebabkan memory penuh, karena referensi action tidak bisa dibersihkan oleh javascript garbage collector.
Rabu, 03 November 2010
Sony Ericsson Android WebSDK is PhoneGap
http://developer.sonyericsson.com/wportal/devworld/search-downloads?cat=[1.716760,+1.706824,+1.706817]
Jumat, 29 Oktober 2010
Cursor dan Custom Cursor
cursor: auto | the default cursor |
cursor: crosshair | a gunsight-style cross |
cursor: default | the system's normal arrow pointer |
cursor: pointer | the normal hand pointer that appears when you hover over a link |
cursor: hand | a value that is only supported in IE. Don't use it, use pointer instead |
cursor: wait | the waiting cursor, generally a watch or hourglass (non-animated, sadly) |
cursor: text | the text-selecting 'I-beam' thing |
cursor: help | an arrow with a question-mark |
cursor: move | crosshair with arrows on the ends, useful for drag and drop applications |
|
|
cursor: n-resize | an arrow pointing north |
cursor: ne-resize | an arrow pointing north-east |
cursor: nw-resize | an arrow pointing north-west |
cursor: e-resize | an arrow pointing east |
cursor: w-resize | an arrow pointing west |
cursor: s-resize | an arrow pointing south |
cursor: se-resize | an arrow pointing south-east |
cursor: sw-resize | an arrow pointing south-west |
Custom Cursors
Finally, if all of those cursors aren't enough for you, you can supply your own customcursors by uploading the cursor file and pointing to it from in your CSS, just like you would point to an image. Custom cursors work similarly to fonts in CSS: you supply a list ofcursors you'd like to use. The browser will try to download and use each cursor in order. If one is not available or unusable, it will fall back on the next one and so on until it reaches a generic cursor at the end of the list which is used if none of the others are available. You code it like this:
a.help {cursor: url(questionmark.svg), url(/cursors/questionmark.cur), help; }
This code will instruct the browser to first look for an SVG file called "questionmark.svg". If this doesn't work or the browser doesn't support SVG graphics, it will look for a .cur file, which is a common cursor format. If neither of these files end up being available, it will fall back to the normal help cursor.
Kamis, 28 Oktober 2010
PHP win32 Service
<?php
if ($argv[1] == 'run')
{
win32_start_service_ctrl_dispatcher('dummyphp1');
while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message())
{
# do your work here.
# try not to take up more than 30 seconds before going around the loop
# again
sleep(10);
}
}
if($argv[1]=="register")
{
win32_create_service(array(
'service' => 'dummyphp1', # the name of your service
'display' => 'sample dummy PHP service #1', # description
'params' => 'd:\w32service.php run', # path to the script and parameters
));
}
else if($argv[1]=="unregister"){
win32_delete_service('dummyphp1');
}
else
{
echo "dummy Service\n";
echo "-----------------------------------\n";
echo "register - register this service \n";
echo "unregister - unregister this service \n";
echo "run - run this service \n";
}
?>
Rabu, 27 Oktober 2010
Sumber bacaan Penggiat Startup Lokal
Ini ada website yang membahas dan menginformasikan kegiatan – kegiatan startup lokal dan juga info – info tentang perkembangan tren bisnis web yang sekarang mengarah ke social content alias web 2.0
Selasa, 26 Oktober 2010
Prasyarat Android Market
Getting Started
Before you can publish software on the Android Market, you must do three things:
- Create a developer profile
- Pay a registration fee ($25.00) with your credit card (using Google Checkout)
- Agree to the Android Market Developer Distribution Agreement
Kamis, 21 Oktober 2010
PHP cURL function to get Data from Web
Source : http://davidwalsh.name/download-urls-content-php-curl
function get_data($url)
{
$userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Menggunakan Codeigniter untuk Aplikasi CommandLine (CLI)
Ada kalanya kita perlu menggunakan Command Line interface untuk melakukan suatu process. Tapi karena sudah terbiasa dengan Codeigniter, maka kita tentunya tidak mau kehilangan fungsi – fungsi maupub library yang sudah ada didalam codeigniter. Nah berikut ini caranya :
- Pastikan PHP telah bisa dipanggil dari Command Line. (Kalo di linux pasti udah bisa. Kalo di Windows harus setup Environment variabel dari Ctrl Panel->System->Advanced->Environment Variables :: cari Path modifikasi jadi ;LOKASI/PHP/PHP.exe)
- Buka http://codeigniter.com/wiki/CI_on_the_command_line/ . Download MY_URI.zip
- Extract MY_URI , letakan MY_URI.PHP ke application/libraries
- Dalam config.php ubah $config['uri_protocol'] = "CLI"
- Test dengan cara : php index.php nama_controller nama_fungsi
Selamat mencoba!
Jumat, 15 Oktober 2010
Javascript In Array Like PHP
Array.prototype.in_array = function(p_val)
{
for(var i = 0, l = this.length; i < l; i++) {
if(this[i] == p_val) {
return
true;
}
}
return
false;
}
Rabu, 13 Oktober 2010
Jumlah Maksimum Varchar di MSSQL Server
In SQL Server 2000 and SQL Server 7, a row cannot exceed 8000 bytes in size. This means that a VARBINARY column can only store 8000 bytes (assuming it is the only column in a table), a VARCHAR column can store up to 8000 characters and an NVARCHAR column can store up to 4000 characters (2 bytes per unicode character). This limitation stems from the 8 KB internal page size SQL Server uses to save data to disk.
To store more data in a single column, you needed to use the TEXT, NTEXT, or IMAGE data types (BLOBs) which are stored in a collection of 8 KB data pages that are separate from the data pages that store the other data in the same table. These data pages are arranged in a B-tree structure. BLOBs are hard to work with and manipulate. They cannot be used as variables in a procedure or a function and they cannot be used inside string functions such as REPLACE, CHARINDEX or SUBSTRING. In most cases, you have to use READTEXT, WRITETEXT, and UPDATETEXT commands to manipulate BLOBs.
To solve this problem, Microsoft introduced the VARCHAR(MAX), NVARCHAR(MAX), and VARBINARY(MAX) data types in SQL Server 2005. These data types can hold the same amount of data BLOBs can hold (2 GB) and they are stored in the same type of data pages used for other data types. When data in a MAX data type exceeds 8 KB, an over-flow page is used. SQL Server 2005 automatically assigns an over-flow indicator to the page and knows how to manipulate data rows the same way it manipulates other data types. You can declare variables of MAX data types inside a stored procedure or function and even pass them as variables. You can also use them inside string functions.
Microsoft recommend using MAX data types instead of BLOBs in SQL Server 2005. In fact, BLOBs are being deprecated in future releases of SQL Server.
Senin, 11 Oktober 2010
Javasript multithreading example
Source : http://articles.sitepoint.com/article/multi-threading-javascript/2
function process()
{
var above = 0, below = 0;
for(var i=0; i<1000000; i++)
{
if(Math.random() * 2 > 1)
{
above ++;
}
else
{
below ++;
}
}
}
function test2()
{
var result2 = document.getElementById('result2');
var start = new Date().getTime();
var i = 0, limit = 100, busy = false;
var processor = setInterval(function()
{
if(!busy)
{
busy = true;
result2.value = 'time=' +
(new Date().getTime() - start) + ' [i=' + i + ']';
process();
if(++i == limit)
{
clearInterval(processor);
result2.value = 'time=' +
(new Date().getTime() - start) + ' [done]';
}
busy = false;
}
}, 100);
}
Rabu, 06 Oktober 2010
Using FooStack PHPunit for codeigniter
This is not a result. This just what i have try.
- I am using CI 1.7.2 standard folder.
- Put fooStack in system/application/libraries
- Put tests in system/application
- Make sure nothing is loaded automatically excep database in autoload.
- If Other libraries loaded then it will generate error. Example session shouldn't be loaded.
Create your Common Controller by Extending Codeigniter Controller
Sometimes we need to create a base controller of our own application. Here are steps to build and use your own controller based on Codeigniter controller
- Create a controller that extend code igniter controller
- Put your controller in same directory where Codeigniter main controller exist
- Edit Codeigniter.php, find code that load controller class
- Add same code to load your controller
- Use it by extend your own controller in same manner like it is CI base controller
Senin, 04 Oktober 2010
SuperFish Jquery Plugin Menu
Download : http://users.tpg.com.au/j_birch/plugins/superfish/#download
Sample Code:
//link to the CSS files for this menu type
<link rel="stylesheet" type="text/css" media="screen" href="superfish.css" />
// link to the JavaScript files (hoverIntent is optional)
<script type="text/javascript" src="hoverIntent.js"></script>
<script type="text/javascript" src="jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="superfish.js"></script>
// initialise Superfish
<script type="text/javascript">
$(document).ready(function(){
$("ul.sf-menu").superfish().find('ul').bgIframe({opacity:false});
});
</script>
Jumat, 01 Oktober 2010
Solved : message: Cannot open user default database. Using master database instead

php draft printing
- A standard receipt printer such as the Epson TM-T88III receipt printer uses the parallel port.
- To print to the parallel-port receipt printer, you print through port PRN (exactly the same as printing from DOS prompt).
- From within PHP-GTK2, you need to first establish the connection with the printer by using $handle = fopen("PRN", "w");
- Thereafter, to print anything to the printer, you just "write" to it like the file handle: fwrite($handle, 'text to printer');
- There are newer receipt printer that uses USB. I believe you should be able to print to such printers through PRN too.
Kamis, 30 September 2010
JQuery : get HTML Content of object
We can get html content of Jquery object by using html(), this method will return child content of the object. So the workaround is wrap object into any element and get the element child :)
var html = $("<div>").append( $("#some_div").clone()).html();
Ok. That's obviously simple right ? Happy Coding!
Codeigniter : Melihat Query untuk debug
User specific Javascript timer
Long time ago i only know cron or task scheduler and javascript timer to do scheduled process. A few days ago i realize that i can do scheduled task using specific user, in this case i can use admin user
to do specific task that suppose to be runned only by admin. Well, i can use this for anything i guest including game engine.
Rabu, 29 September 2010
JasperReport Export ke Text
Sumber Tulisan : http://www.coderanch.com/t/62982/open-source/Jasper-Report-Text-Exporter
JRTextExporter uses a very smart algorithm to convert reports in graphics to reports in text. It first creates a virtual text grid based on your report's size and the character dimensiona given to the exporter. Then it places each individual item to the text grid based on the item's location in pixels.
There are three very important parameters effecting how the exporter converts the output
1- Width and Height of the reports in pixels
2- Widths and Heights of the individual report elements (labels etc.)
3- Character Width and Height parameters of the exporter
To fit the report to the text grid, you need to make a simple calcuation:
First find the maximum number of characters that can be fit to a row when you would print the report in text (Let's assume that it is 80 characters long and call this number MAX_CHAR_PER_ROW).
Then find the maximum number of characters that can be fit to a column when you would print the report in text (Let's assume that it is 44 characters height and call this number MAX_CHAR_PER_COL).
Then Divide your reports dimensions with these numbers to find the character height and width. LEt's assume the dimensions of the report are REPORT_WIDTH and REPORT_HEIGHT and the corresponding values are 524 and 524. Now the characters dimensions are calculated as:
CHAR_WIDTH = REPORT_WIDTH / MAX_CHAR_PER_ROW
CHAR_HEIGHT = REPORT_HEIGHT / MAX_CHAR_PER_COL
CHAR_WIDTH = 524 / 80 = 6.55
CHAR_HEIGHT = 524 / 44 = 11.9
Of course, the resulting values will not be integers most of the time. Then if you want a perfect match, CHAR_WIDTH and CHAR_HEIGHT must be floating numbers. But the original exporter only accepts integers parameters. At this point, use my modified exporter here. I already converted these parameters to float.
Here is how you may send character dimensions to the exporter.
exporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float(6.55));//6.55 //6
exporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float(11.9)); //11//10
Another notice! Make sure that CHAR_HEIGHT is not lower that the actual heights of the report items. Otherwise, the items will not added to the grid since the exporter truncates their heights to 0 because of the arithmetic operation inside the exporter. Another solution would be using rounding instead of truncation by modifying the exporter a little more. Anyway, I did not need that feature since the character height is ok for my case.
/**
* Transforms y coordinates from pixel space to character space.
*/
protected int calculateYCoord(int y)
{
int result = Math.round((float)pageHeight * y / jasperPrint.getPageHeight());
return result;
}
/**
* Transforms x coordinates from pixel space to character space.
*/
protected int calculateXCoord(int x)
{
int result = Math.round((float)pageWidth * x / jasperPrint.getPageWidth());
return result;
}
Selasa, 28 September 2010
jQuery Dialog Example
$("#new_config").dialog
({ autoOpen: false,
height:400,
width:400,
resizable:false,
modal:true
});
<!--- Dialog Box start --->
<div
id="new_config"
title="Dialog Title"
style='width:400px;height:300px;display:none;'>
<div
style="padding:3px 0">
<strong
id="dialog_title"></strong>
<!-- content -->
<div
id="tabcontent_newconfig">
<!—your conten -->
</div>
<!-- content -->
</div>
</div>
<!--- Dialog Box end --->
Jquery $.post Example
function saveItem()
{
var mod_name = $("#module_name").val();
var item_name = $("#item_name").val();
var item_val = $("#item_value").val();
var desc = $("#desc").val();
var id = $("#id_item").val();
json = "{\"module\":\"" + escape(mod_name) +
"\",\"name\":\"" + escape(item_name) +
"\",\"value\":\""+ escape(item_val) +
"\",\"desc\":\""+ escape(desc) +
"\",\"id\":\""+ id +
"\"}";
config_url = _base_url + "/index.php/admin/gconfig/save";
$.post(config_url,{data:json},function(result){
if(result)
{
//alert(result);
resetForm();
//reload only selected mod
url_reload = "url:"+ _base_url +"/index.php/admin/gconfig/index_json/"+ mod_name +"}";
$("#table_flex0").flexReload();
}
});
$("#new_config").dialog('close');
}
Kamis, 23 September 2010
Tentang Ocular
Sumber asli : http://codeigniter.com/forums/viewthread/130213/
I'm using Ocular on a new project, and it's really a huge timesaver. One thing that I found useful is to have two default templates, one for full requests and one for ajax requests. In application/config/constants.php I appended this snippet, per someone else's suggestion elsewhere in the forums:
/*
|--------------------------------------------------------------------------
| detect Ajax request
|--------------------------------------------------------------------------
|
*/
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
And in config/ocular.php I added a second default_template value (@ line 102) like this:
$config['OCU_default_template'] = "application";
$config['OCU_default_ajax_template'] = "blank";
Then in libraries/Ocular.php in Ocular::render() (lines 111-112 in v1.0.1) I made a small change to the default template:
// controller template doesn't exist, so use the application default
$template = $this->ci->config->item('OCU_template_dir') . "/" . $this->ci->config->item(IS_AJAX ? 'OCU_default_ajax_template' : 'OCU_default_template');
Just thought this might be useful for someone.
Library Codeigniter yang utama
Dari http://geshan.blogspot.com/2010/03/3-codeigniter-libraries-that-will-make.html
EzAuth : Authentikasi – mending pake lib orang deh daripada buat ulang :p
Ocular : Templating
DataMapper : ORM
Untuk project selanjutnya pake ini aja. ;)
Rabu, 22 September 2010
Memodifikasi Flexigrid QuickSearch button agar tidak muncul di bar bawah
- Tambahkan beberapa parameter baru di flexigrid options. Set nilai default agar compatible dengan behavior asli flexigrid
showQuickSearch: true,
quickSearchatTop: false,
quickSearchatBottom: true,
- Modifikasi kode yang memuat if(p.searchitems) menjadi
//add search button
if(p.showQuickSearch)
{
if(p.quickSearchatBottom)
{
if (p.searchitems)
{
$('.pDiv2',g.pDiv).prepend("<div class='pGroup'> <div class='pSearch pButton'><span></span></div> </div> <div class='btnseparator'></div>");
$('.pSearch',g.pDiv).click(function(){$(g.sDiv).slideToggle('fast',function(){$('.sDiv:visible input:first',g.gDiv).trigger('focus');});});
//add search box
g.sDiv.className = 'sDiv';
sitems = p.searchitems;
var sopt = "";
for (var s = 0; s < sitems.length; s++)
{
if (p.qtype=='' && sitems[s].isdefault==true)
{
p.qtype = sitems[s].name;
sel = 'selected="selected"';
} else sel = '';
sopt += "<option value='" + sitems[s].name + "' " + sel + " >" + sitems[s].display + " </option>";
}
if (p.qtype=='') p.qtype = sitems[0].name;
$(g.sDiv).append("<div class='sDiv2'>Quick Search <input type='text' size='30' name='q' class='qsbox' /> <select name='qtype' id='qtype'>"+sopt+"</select> <input type='button' value='Clear' /></div>");
$('input[name=q],select[name=qtype]',g.sDiv).keydown(function(e){if(e.keyCode==13) g.doSearch()});
$('input[value=Clear]',g.sDiv).click(function(){$('input[name=q]',g.sDiv).val(''); p.query = ''; g.doSearch(); });
$(g.bDiv).after(g.sDiv);
}
}
if(p.quickSearchatTop)
{
if (p.searchitems)
{
g.sDiv.className = 'sDiv';
sitems = p.searchitems;
var sopt = "";
for (var s = 0; s < sitems.length; s++)
{
if (p.qtype=='' && sitems[s].isdefault==true)
{
p.qtype = sitems[s].name;
sel = 'selected="selected"';
} else sel = '';
sopt += "<option value='" + sitems[s].name + "' " + sel + " >" + sitems[s].display + " </option>";
}
$('.tDiv2').append("<div class='btnseparator'></div><div class='fbutton_x'><span style='padding-left: 2px;padding-right:2px;'><label></label><input type='text' size='30' name='q' class='qsbox' style='color:#999999;' value='Quick Search'/> <select name='qtype' id='qtype'>"+sopt+"</select> <input type='button' value='Clear' /></span></div>");
if (p.qtype=='') p.qtype = sitems[0].name;
$('input[name=q],select[name=qtype]',g.tDiv).keydown(
function(e){
if(e.keyCode==13)
{
//satiri @ 22-09-2010
//add timeout to support update in .qsbox
setTimeout(
function(){g.doSearch();},
200
);
}
});
$(".qsbox").click(function(){
if($(this).val()=="Quick Search"){
$(this).val("");
$(this).css("color","#000000");
}
});
$(".qsbox").mouseout(function(){
if($(this).val()==""){
$(this).val("Quick Search");
$(this).css("color","#999999");
}
});
$('input[value=Clear]',g.tDiv).click(function(){
$('input[name=q]',g.tDiv).val('');
$(".qsbox").val("Quick Search");
$(".qsbox").css("color","#999999");
p.query = '';
g.doSearch();
});
}
}
}