Selasa, 31 Maret 2015

Implementasi CLEditor di Codeigniter

,
Bahan yang dibutuhkan :
  1. XAMPP (saya menggunakan versi 1.8.1) Dapat di download disini
  2. Codeigniter (saya menggunakan versi 2.2.0) Dapat di download disini
  3. Jquery (saya menggunakan versi 2.1.3) Dapat di download disini
  4. CLEditor (saya menggunakan versi 1.4.4) Dapat di download disini
Langkah Pertama
  • Install XAMPP
  • Jalankan service apache
Langkah Kedua
  • buat directory baru di htdocs untuk menyimpan project kita (saya membuat dengan nama CLEditor)
  • extract file codeigniter hasil download ke directory yang tadi telah kita buat di htdocs
  • panggil project kita di browser.
  • jika muncul halaman welcome seperti berikut maka proses instalasi codeigniter berhasil
Langkah Ketiga
  • Buat sebuah directory di root codeigniter (saya membuat dengan nama assets) 
  • buat directory di dalam directory assets untuk menyinpan file CLEditor (saya membuat dengan nama cleditor)
  • extract file CLEditor yang sudah di download kedalam directory cleditor
  • buat directory di dalam assets (saya membuat dengan nama js)
  • copy file jquery-2.1.3.min.js ke dalam directory js
Langkah Keempat
  • buat sebuah controller baru di ".\application\controllers\" saya membuat controller dengan nama home.
  • Buka routes.php di ".\application\config\"
  • cari text berikut $route['default_controller'] = "welcome"; rubah menjadi $route['default_controller'] = "home";'
  • edit home controller seperti dibwah ini untuk menampilkan halaman dimana nanti kita akan mengimplementasikan CLEditor didalamnya.
  • class Home extends CI_Controller{
        function __construct() {
            parent::__construct();
            $this->load->helper('url', 'file');
        }
        
        function index(){
            $this->load->view('home');
        }
    }
Langkah Kelima

  • buat sebuah file php dengan nama home di ".\application\views\" dan isikan seperti dibawah ini

Langkah Keenam
  • panggil dibrowser maka akan tampil seperti berikut 



Read more →

Kamis, 05 Februari 2015

Menghilangkan index.php pada url codeigniter di web server centos 6.5

,
Secara default URL codeigniter akan tampil "domain/index.php/controller", agar lebih enak dilihat (menurut pendapat saya saja sih) perlu menghilangkan "index.php" di URL tersebut. Berikut langkah-langkahnya.

  1. masuk ke dirctory website secara default "/var/www/html/" buka "application/config/config.php".
  2. Update code $config['index_page'] = 'index.php'; menjadi $config['index_page'] = '';  (hilangkan index.php).
  3. Buat file .htaccess di root directory website (bukan root directory server), didalam file .htaccess  masukan script berikut :
  4. # .htaccess file
    RewriteEngine On
    # Removes index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
  5. Buka "/etc/httpd/conf/httpd.conf", cari file berikut :
  6. pastikan di "AllowOverride All". Jika sudah restart servis httpd, lalu jalankan website.
Read more →

Kamis, 04 Desember 2014

Upload File Berbeda Type Dalam Satu Form di Codeigniter

,
Saya menggunakan codeigniter 2.2.0 dan membuat form upload sesuai user guide (File Uploading Class). Ketika saya membuat form upload hanya untuk satu file type tidak menagalami kendala, namun saya mengalami kendala saat dalam satu form mempunyai dua fasilitas upload dengan type file yang berbeda (gambar & pdf). Berikut contoh source code yang saya buat :
Dan berikut code controllernya:

function do_upload() {
        $this->load->library('upload');
        //config untuk upload gambar
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'jpg|png';
        $config['overwrite'] = FALSE;
        $config['max_size'] = '5000';
        $this->upload->initialize($config);
        if (!$this->upload->do_upload('gambar')) {
            /*
             * LOAD HALAMAN ERROR GAMBAR
             */
        } else {
            unset($config);
            $config['upload_path'] = './uploads/';
            $config['upload_path'] = './assets/download/news/';
            $config['allowed_types'] = 'pdf';
            $config['overwrite'] = FALSE;
            $config['max_size'] = '15000';
            $this->upload->initialize($config);
            if (!$this->upload->do_upload('file_download')) {
                /*
                 * LOAD HALAMAN ERROR FILE PDF
                 */
            } else {
                /*
                 * LOAD HALAMAN SUKSES
                 */
            }
        }
    }

dengan menambahkan $this->upload->initialize($config); kita dapat setting configurasi untuk file upload selanjutnya.

Read more →

Kamis, 06 November 2014

Setting wordwrap di netbeans

,
Word Wrap adalah sebuah fungsi  yang ada pada word processor  dan program aplikasi untuk teks yang membuat suatu baris kumpulan kata-kata yang tidak bisa dilihat secara seluruhnya pada jendela aplikasi ( window ) dipindahkan kebaris selanjjutnya secara otomatis untuk bisa dilihat keseluruhan bagiannya dari baris tersebut.
Secara default di netbeans fungsi wordwrap ini di setting off, untuk mengaktifkan wordwrap caranya sebagai berikut :

  1. Jalankan netbeans
  2. Masuk menu tools
  3. Pilih options
  4. Pada jendela yang muncul pilih tab editor
  5. Pilih menu formating
  6. Pada line wrap pilih after word atau anywhere, untuk priviewnya dapat dilihat pada kolom sebelah kanan.
  7. Klik OK untuk menyimpan.

Read more →

Selasa, 04 November 2014

Copy Directory Recrusive Via CMD XCOPY

,
Contoh Kasus ingin backup data (overwite yang sudah ada) dari directory C:\xampp\htdocs ke directory D:\backup.
@echo off
echo copying files
xcopy /E/Y C:\xampp\htdocs D:\backup
/E : opsi untuk copy directory beserta sub directory dan semua isi di dalamnya
/Y : opsi untuk overwrite
berikut opsi lengkapnya :

help xcopy
hasilnya seperti dibawah ini :
@echo off
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Imam Syaifulloh>help xcopy
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies the size of each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
  /B           Copies the Symbolic Link itself versus the target of the link.
  /J           Copies using unbuffered I/O. Recommended for very large files.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

C:\Users\Imam Syaifulloh>

Sumber Referensi
Read more →