Archive for ‘ November, 2010 ’

Php 5 extend, array and __construct

// Declare a new class that extends xavier into regex
class zabyer extends xavier {
    // Declare a property to hold the filter criteria
    private $criteria;

    // Now make our constructor
    public function __construct(Iterator $i, $regex) {
        // Call the parents constructor, and store the regex
        $this->criteria = $regex;

    // Define accept
    public function accept() {
        // Just see if the regex matches the current item:
        return preg_match($this->criteria, parent::current());

// Now to test this, first define an array of values
$arr = array('macanhan', 'tibongco', 'gusa', 'gaisan', 'sm', 'cogon', 'agusan');
// Now let's create a chained Iterator.  Make a xavier that wraps
// around an ArrayIterator, and only allows items with a 'y' in them.
$it = new zabyer(new ArrayIterator($arr), '/y/i');

// Now loop and echo these all out, should include tibongco, sm, agusan.
foreach ($it as $entry) { echo "{$entry}
\n"; }

wordpress tinymce add button

i been working out for a new plugin which is called the files attachment plugin. for now i want share to you how add button in can download it here WordPress Attach File

First, i will show the php code how to hook in wordpress.  this line allow you to hook in tinymce

add_filter(‘mce_external_plugins’, ‘attachDaw’); //This function include editor_plugin.js;

add_filter(‘mce_buttons’, ‘attachAddButton’, 0); //hook this function to  tinymce

add_action(‘plugins_loaded’, ‘loadlibrary’); // loaded jquery plugin..

Set function..

function attachAddButton($button){

array_push($button, "separator", "daganPlugin");

return $button;

function attachDaw($plugin_array){
$url = trim(get_bloginfo('url'), "/")."/wp-content/plugins/sumifruAttachFile/editor_plugin.js";
$plugin_array['daganPlugin'] = $url; //call jscript editor_plugin.js

return $plugin_array;


function loadlibrary(){

wp_enqueue_script('jquery'); //call jquery script

js script editor_plugin.js
the init is link up container bind with function attachDaw($plugin_array)

ed.addCommand('string Name', 's:Object')
ed.addButton('string Name', s:Object)
you can see the documentation here

init : function(ed, url){
ed.addCommand('OpenDawBeh', function() {{
file : url + '/attachmeFiles.php', //source file
width : 500, // max width
height : 300, // max height
inline : 1
}, {
plugin_url : url // Plugin absolute URL

ed.addButton('daganPlugin', {
title : 'Attach Files', // title plugin name
cmd : 'OpenDawBeh', // call ed.addCommand('OpenDawBeh')
image: url + "/attachment.png" //button Image

ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('daganPlugin', n.nodeName == 'IMG');

// Add a node change handler, selects the button in the UI when a image is selected

getInfo : function() {
return {
longname : 'amew ka he',
author : 'Ryl Denn Sagun',
authorurl : '',
infourl : '',
version : "1.0"

tinymce.PluginManager.add('daganPlugin', tinymce.plugins.daganPlugin);