26 Aralık 2009 Cumartesi

Şablon Klasör Taraması

Hazırladığımız şablonların herbirini bir klasör içerisinde barındırıdığımızda, bu klasör altında bulunan tüm şablonların tek tek taranarak sistemde görüntülenmesi için basit bir Klasör Tarama kodu hazırladım. Bu kod, belirtilen klasör altındaki klasörlerin içerisinde eğer varsa template.xml dosyasını şablon olarak yüklenmesini sağlıyor.
Şimdilik bu kodu ufkumuzu genişletmesi için hazırladım, tema yükleme işleminin oldukça kolaylaşacağını ve temaların sisteme uyumluluğunun hat safhada olacağını belirtmeliyim.
Hazırladığım kod şu şekilde:
/**
 * This is the test of directory listing of the adv_templates directory
 * 
 * @author Behçet MUTLU
 * @copyright 2009
 */

require_once("system/system.core.php");
@$dir = $_SERVER["DOCUMENT_ROOT"]."ADVManager/adv_templates/";

function _readdir($dir)
{
    $dh = opendir($dir);
    while (false !== ($filename = readdir($dh))) {
        $files[] = $filename;
    }
    return $files;
}

$files = _readdir($dir);

foreach($files as $file)
{
    if(is_dir($dir.$file) && $file != "." && $file != "..")
    {
        echo ">$file\n";
        foreach(_readdir($dir.$file) as $temp_file)
        {
            if($temp_file == "template.xml")
            {
                $adv = new ADVTemplate($dir.$file . "/template.xml");
                pre($adv);
            }
        }
    }
}
Bu kodun geri döndürdüğü çıktı ise şu şekildeydi:
>template1

DEBUG:  XML file, "C:/wamp/www/ADVManager/adv_templates/template1/template.xml" loaded successfully.

ADVTemplate Object
(
    [name:ADVTemplate:private] => Template 1
    [author:ADVTemplate:private] => Behçet MUTLU
    [datecreated:ADVTemplate:private] => 25-12-2009
    [copyright:ADVTemplate:private] => 2009 Adres Gezgini
    [website:ADVTemplate:private] => www.adresgezgini.com.tr
    [thumbnail:ADVTemplate:private] => adv_templates/template1/thumb.jpg
    [schema:ADVTemplate:private] => C:/wamp/www/ADVManager/adv_templates/template1/template.xml
    [isReady:ADVTemplate:private] => 1
    [xml:ADVTemplate:private] => Array
        (
            [template] => Array
                (
                    [0] => 

                    [info] => Array
                        (
                            [0] => 
    
                            [name] => Template 1
                            [author] => Behçet MUTLU
                            [copyright] => 2009 Adres Gezgini
                            [website] => www.adresgezgini.com.tr
                            [thumbnail] => adv_templates/template1/thumb.jpg
                            [datecreated] => 25-12-2009
                        )

                    [fields] => Array
                        (
                            [0] => 
    
                            [image] => Array
                                (
                                    [0] => Array
                                        (
                                            [0] => 
        
                                            [title] => Logo Resmi
                                            [description] => Eklemek istediğiniz logo resmini dosyadan seçiniz.
                                            [default] => library/image_64x64.png
                                            [@id] => image1
                                            [@width] => 64
                                            [@height] => 64
                                        )

                                    [1] => Array
                                        (
                                            [0] => 
        
                                            [title] => Ürün Resmi
                                            [description] => Eklemek istediğiniz ürün resmini dosyadan seçiniz.
                                            [default] => library/image_128x169.png
                                            [@id] => image2
                                            [@width] => 128
                                            [@height] => 169
                                        )

                                )

                            [text] => Array
                                (
                                    [0] => Array
                                        (
                                            [0] => 
        
                                            [title] => Başlık Yazısı
                                            [description] => Eklemek istediğiniz başlık yazısını belirtiniz.
                                            [default] => Başlık Yazısı
                                            [font] => Arial
                                            [color] => 000000
                                            [size] => 20
                                            [@id] => text1
                                            [@max] => 100
                                            [@min] => 10
                                        )

                                    [1] => Array
                                        (
                                            [0] => 
        
                                            [title] => Web Site Adresi
                                            [description] => Eklemek istediğiniz web site adresinizi belirtiniz.
                                            [default] => www.websiteniz.com.tr
                                            [font] => Arial
                                            [color] => 000000
                                            [size] => 12
                                            [@id] => text2
                                            [@max] => 100
                                            [@min] => 10
                                        )

                                    [2] => Array
                                        (
                                            [0] => 
        
                                            [title] => Buton Yazısı
                                            [description] => Eklemek istediğiniz buton yazısını belirtiniz.
                                            [default] => Bilgi İçin Tıklayınız
                                            [font] => Impact
                                            [color] => 000000
                                            [size] => 18
                                            [@id] => text3
                                            [@max] => 100
                                            [@min] => 10
                                        )

                                )

                        )

                )

        )

    [fields:ADVTemplate:private] => Array
        (
            [0] => 
    
            [image] => Array
                (
                    [0] => Array
                        (
                            [0] => 
        
                            [title] => Logo Resmi
                            [description] => Eklemek istediğiniz logo resmini dosyadan seçiniz.
                            [default] => library/image_64x64.png
                            [@id] => image1
                            [@width] => 64
                            [@height] => 64
                        )

                    [1] => Array
                        (
                            [0] => 
        
                            [title] => Ürün Resmi
                            [description] => Eklemek istediğiniz ürün resmini dosyadan seçiniz.
                            [default] => library/image_128x169.png
                            [@id] => image2
                            [@width] => 128
                            [@height] => 169
                        )

                )

            [text] => Array
                (
                    [0] => Array
                        (
                            [0] => 
        
                            [title] => Başlık Yazısı
                            [description] => Eklemek istediğiniz başlık yazısını belirtiniz.
                            [default] => Başlık Yazısı
                            [font] => Arial
                            [color] => 000000
                            [size] => 20
                            [@id] => text1
                            [@max] => 100
                            [@min] => 10
                        )

                    [1] => Array
                        (
                            [0] => 
        
                            [title] => Web Site Adresi
                            [description] => Eklemek istediğiniz web site adresinizi belirtiniz.
                            [default] => www.websiteniz.com.tr
                            [font] => Arial
                            [color] => 000000
                            [size] => 12
                            [@id] => text2
                            [@max] => 100
                            [@min] => 10
                        )

                    [2] => Array
                        (
                            [0] => 
        
                            [title] => Buton Yazısı
                            [description] => Eklemek istediğiniz buton yazısını belirtiniz.
                            [default] => Bilgi İçin Tıklayınız
                            [font] => Impact
                            [color] => 000000
                            [size] => 18
                            [@id] => text3
                            [@max] => 100
                            [@min] => 10
                        )

                )

        )

    [values:ADVTemplate:private] => Array
        (
            [image1] => library/image_64x64.png
            [image2] => library/image_128x169.png
            [text1] => Başlık Yazısı
            [text2] => www.websiteniz.com.tr
            [text3] => Bilgi İçin Tıklayınız
        )

)

0 yorum:

Yorum Gönder