Friday, February 4, 2011

Module Creating In Drupal

At minimal, create 2 kind of files:
1. hello.info
  name = Hello Module   ; this will appear in the module 
                        ; configuration and other display text
  description = A module for displaying text  
  package = My Module   ; categories your module
  core = 7.x

2. hello.module
   <?php
   /**
    * Implements hook_menu()
    *
    * Simply provide a menu entry
    */
   function hello_menu(){
        $item['hello/morning'] = array(
            'title' => 'Hello, Good Morning!',
            'description' => 'Greeting Message',
            'page callback' => 'lol',
            'access callback' => TRUE
         );
         return $item;
    }

     /**
      * Provide simply text greeting message
      */
     function lol(){
        return t('Hello, how are you today? We hope you are all right');
     }

3. You have just finished. Now place the two file in a hello folder, then archive it.
4. Open your Drupal administration page, then install the module. Then enable it
5. See in the navigation menu, and try to click it.

Thursday, February 3, 2011

For Clean URL

For clean url, don't use index function or page. Use index function or index page just for redirecting your web page because the browser cannot actually do the right way for managing the url.

Form Handling In CodeIgniter

<?php

class Blog extends CI_Controller
{
    function index()
    {
        echo "<h1>Entry Your Blog</h1>";
        echo "<form method=\"post\" action=\"blog/insert\">";
        echo "<input type=\"text\" name=\"title\">";
        echo "<textarea name=\"content\"></textarea>";
        echo "<input type=\"submit\" value=\"Save\"/></form>";
    }

    function insert()
    {
        $title = $_POST['title'];
        $content = $_POST['content'];
        $data = array(
            'title'=>$title,
            'content'=>$content
        );
        $this->db->insert('article',$data);
    }
}

$this In CodeIgniter

1. $this->load->view('view_file_name', $array, false);
2. $this->db->query($query);

Active Records

1. To query a table, type:
    $query = $this->db->get('table_name');
    foreach($query->result() as $row)
    {
        echo $row->id;
        echo $row->name;
    }
2.To insert data to a table,use:
    $data = array(
        'id'=>'1',
        'name'=>'lady gaga'
    );
    $this->db->insert('table_name',$data);

Handling Database In CI

To handle database in CodeIgniter by traditional way, 
1. set default setting in application/config/database.php to your database setting
2. set application/config/autoload.php to autoload['libraries'] = array('database');
3.Then do like this below in controller:
    $query = $this->db->query('SELECT * FROM musim');
    foreach($query->result() as $row){
        echo $row->id;     // id in table
        echo $row->name;   // name in table
        echo $row->city;   // city in table
    }
    echo 'Total Rows: '.$query->num_rows();

4. For inserting some data, use
    $query = "INSERT INTO musim VALUES (null,".$musim.")";
    $this->db->query($query);
    echo $this->db->affected_rows();

Wednesday, February 2, 2011

TinyMCE Options

The options syntax is an javascript object literal members. For example
skin: "o2k7"       // This shows that the variable is skin, while the value of the variable is silver.
Here's other options:
theme : "advanced" or "simple"    // this shows how many default toolbar icons.
theme_advanced_toolbar_align : "left", "center" or "right"    // alignment of toolbar if theme is "advanced" set.
theme_advanced_toolbar_location : "bottom" or "top"
theme_advanced_statusbar_location : "top" or "bottom"

buttons - plugins:
save - save
paste - paste


just buttons:
cut - copy - newdocument 
bold - italic - underline - strikethrough 
justifyleft - justifyright - justifycenter - justifyfull
fontselect - fontsizeselect - formatselect - styleselect

The Simplest TinyMCE

<script src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
tinyMCE.init({       
        mode : "textareas"
});
</script>

<textarea name="content" style="width:50%"></textarea>

Tuesday, February 1, 2011

Write .htaccess file in CI

In order a request to directed correctly without need to use index.php/class/function, use these .htaccess file and put in in your CI root directory. Assumption, your CIroot directory is C:\xampp\htdocs\ci

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|user_guide/*/*)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]

Hello World Using CodeIgniter

Just type blog.php file in application/controllers directory

<?php

class Blog extends CI_Controller{

    function index()
    {
        echo "Hello, World!";
    }
}

?>

Then direct your browser to localhost/ci/index.php/blog

Monday, January 31, 2011

The First Intro To CakePHP

To Add Content, just create file home.ctp in app/views/page directory
To Add Layout, just create file default.ctp in app/views/layout directory

Sunday, January 30, 2011

Mode Rewrite

The first thing to do with this module is making it on.
Type this code in .htaccess file:
RewriteEngine on


Example 1:
To make a practice, please make a two file in the directory that same as .htaccess file (one.php and two.php). Then write in your .htaccess file: 
RewriteEngine on
RewriteRule ^one\.php$ two.php

Then try to browse http://localhost/one.php
Whay you really get is the content of two.php file, not one.php file.


Example 2:
Create a index.php file
<?php
$name = $_GET['name'];
$name = !empty($name) ? $name : "No Name";
?>
<h1>Your Name: <?php echo $name; ?></h1>

Then create an .htaccess file:
RewriteEngine on
RewriteRule ^([a-z])+$ index.php?name=$1

Browse http://localhost/luna

To make a match of three arguments - name, gender and city - use:
RewriteRule ^([a-zA-Z]+)\/([a-zA-Z]+)\/([a-zA-Z]+)$ 
            index.php?name=$1&gender=$2&city=$3

RewriteRule ^([a-zA-Z\s]*)$ index.php?name=$1   // space

Removing Login Form At Front

To remove the login form block, just remove the block to disable region in the block structure administration. And you can login again to access to your account through: http://your-drupal-site.com/user

Tuesday, January 25, 2011

Module System - Hooks

Drupal module system based on hook. Hook is a function that name hook_lol(), for example. The hook, in the example, lies in lol module. So anyone who want to implement the hook must do this - me_lol(), if my module is me.
In real life, see menu module and help module in module directory. Try to open menu.module file. There you will see a function menu_help($path, $arg). Then open help.api.php file in module/help directory, and you will see hook_help($path, $arg) function

Monday, January 24, 2011

Include Files

httpd/include (29)
  - httpd.h
  - mpm_common.h
  - scoreboard.h
  - ap_compat.h
  - ap_config.h
  - ap_listen.h
  - ap_mmn.h
  - ap_mpm.h
  - ap_provider.h
  - ap_regex.h
  - ap_regkey.h
  - ap_release.h
  - http_config.h
  - http_connection.h
  - http_core.h
  - http_log.h
  - http_main.h
  - http_protocol.h
  - http_request.h
  - http_vhost.h
  - util_cfgtree.h
  - util_charset.h
  - util_abcdic.h
  - util_filter.h
  - util_ldap.h
  - util_md5.h
  - util_script.h
  - util_time.h
  - util_xml.h
   

Drupal Includes Files

ROOT/includes/
  - action.inc    -> action engine for executing stored actions
  - ajax.inc      -> function for use with drupal ajax fw
  - archiver.inc  -> classes and interfaces for archiver system
  - authorize.inc -> helper function n form handler for authorize.php
  - batch.inc     -> running process for multiple http request
  - batch.queue.inc   -> queue handlers used by batch API
  - bootstrap.inc -> functions load in every drupal request
  - cache.inc     -> get cache objects for cache bin
  - cache-install.inc -> stub cache used during installation
  - commons.inc   -> many drupal modules reference to this
  - date.inc      -> list of date format and their locals
  - entity.inc    -> interface and entity class
  - errors.inc    -> error handling
  - file.inc      -> handling file upload and server file management
  - file.mimetypes.inc -> mapping mime type with extension
  - form.inc      -> abstract representation of forms
  - graph.inc     -> directed acyclic graph function
  - image.inc     -> image manipulation
  - install.core.inc   -> installing drupal
  - install.inc   ->
  - iso.inc       -> iso for country and language list
  - language.inc  -> multiple language handling
  - locale.inc    -> for locale.module
  - lock.inc      -> database locking mechanism
  - mail.inc      -> processing and sending mail
  - menu.inc      -> drupal menu system
  - module.inc    -> process and load module
  - pager.inc     -> represent database result as page
  - password.inc  -> password hash function for authentication
  - path.inc      -> handling path 
  - registry.inc  -> code registry parser engine
  - session.inc   -> handling user session
  - stream_wrappers.inc  -> handling PHP stream function for file
  - tablesort.inc -> creation of sortable table
  - theme.inc     -> theme system. control output of drupal
  - theme.maintenance.inc -> for maintenance page
  - token.inc     -> placeholder/token replacement system
  - unicode.entities.inc  -> HTML entities
  - unicode.inc   ->
  - update.inc    -> datebase update
  - updater.inc   -> 
  - utility.inc   ->
  - xmlrpc.inc    ->
  - xmlrpcs.inc   -> defining and handling xml-rpc request
            

Drupal Folder Structures

drupal-7.0
  - includes/
  - misc
  - modules
  - profiles
  - scripts
  - themes
  - web.config     -> xml file config like .htaccess
  - .htaccess      -> server setting for this folder
  - uthorized.php  -> authorize file access
  - cron.php
  - index.php      -> direct to ROOT/includes/bootstrap.inc
  - install.php    -> direct to ROOT/includes/install.core.inc
  - update.php     -> update to another version
  - xmlrpc.php     -> handling xml-rpc request from clients
  - CHANGELOG.txt  -> new features in each version
  - COPYRIGHT.txt  -> copyright info
  - INSTALL.mysql.txt  -> config mysql for installation
  - INSTALL.pgsql.txt  -> config postgreSql for installation
  - INSTALL.sqlite.txt -> config sqlite for installation
  - INSTALL.txt        -> guide how to install drupal
  - LICENSE.txt        -> license doc
  - MAINTAINERS.txt    -> developer team
  - README.txt         -> general insight
  - robots.txt         -> search engine crawling config
  - UPGRADE.txt        -> upgrade instruction guide
   
You can browse drupal source code in http://drupalcode.org/viewvc/drupal/drupal/

Win32 Classes

1. Computer System Hardware Classes
2. Operating System Classes
3. Installed Application Classes
4. WMI Service Management Classes
5. Performance Counter Classes
6. Security Descriptor Classes

Sunday, January 23, 2011

jQuery Source Files

jquery/
  - src/
    - ajax.js
    - attributes.js
    - core.js
    - css.js
    - data.js
    - dimensions.js
    - effects.js
    - event.js
    - intro.js
    - manipulation.js
    - offset.js
    - outro.js
    - queue.js
    - sizzle-jquery.js
    - support.js
    - traversing.js
    - ajax/
      - jsonp.js
      - script.js
      - xhr.js
        

JQuery Git

jquery/
  - build/
  - speed/
  - src/
  - test/
  - .gitattributes
  - .gitignore
  - GPL-LICENSE.txt
  - MIT-LICENCE.txt
  - Makefile
  - README.md
  - version.txt
       

Tiny C File Children

header files:
tcc
  - coff.h
  - elf.h
  - i386-asm.h
  - il-opcodes.h
  - libtcc.h
  - stab.h
  - tcc.h
  - tcctok.h

c files:
  - arm-gen.c
  - c67-gen.c
  - i386-asm.c
  - i386-gen.c
  - il-gen.c
  - libtcc.c
  - tcc.c       // application files
  - tccasm.c
  - tcccoff.c
  - tccelf.c
  - tccgen.c
  - tccpe.c
  - tccpp.c
  - x86_64-gen.c

other files:
  - .cvsegnore
  - stab.def
  - Changelog
  - configure
  - COPYING
  - Makefile
  - README
  - TODO
  - VERSION
  - tcc-doc.html
  - texi2pol.pl
  - tcc-doc.texit
    

SQLite Source Files

sqlite
  - shell.c
  - sqlite3.c
  - sqlite3.h
  - sqlite3ext.h

Folder Structure Of TinyC Compiler

tcc
  - examples
  - include
  - lib
  - tests
  - win32