rendered paste body<?phpclass urunler extends R_Core { public function __construct() { R_Core::__construct(); $this->resimler_klasoru = '../urunResimleri'; } public function index() { $this->eklemeFormu(); } public function eklemeFormu() { /*$urunEkle_template = new R_Template('templates/urunEkle.html'); $urunEkle_template->display();*/ session_start('urunEkleForm'); $form = new form("urunEkleForm"); $form->setAttributes(array('width'=>750, 'action'=>'urunler/ekle', 'enc-type'=>'multipart/form-data')); $form->setAttributes(array('jsIncludesPath'=>'/panel/rohanrhu-framework/php-form-builder-class/includes')); self::$db->select('kategoriler', 'id, adi'); $form->addTextBox('Ürün', 'adi'); $form->addSelect('Ürün Kategorisi', 'kategori', '', self::$db->get_2d('id', 'adi'), array('multiple'=>'multiple')); $form->addWebEditor('Ürün İçeriği', 'icerik', ''); $form->addFile('Resim', 'resim[]', array('multiple'=>'multiple')); $form->addButton('Ekle'); $form->render(); } public function listele($kategori=false) { if ($kategori) { self::$db->where(array('kategori'=>(int)$kategori), 'urunler'); } self::$db->select('urunler'); while ($urun = self::$db->get()) { echo $urun['adi'].' - '.$urun['tarih'].' - Düzenle - Sil'; echo '<br /><br />'; } $this->eklemeFormu(); } public function ekle() { $urun_id = self::$db->insert('urunler', array('adi'=>$_POST['adi'], 'kategori'=>(int)$_POST['kategori'][0], 'icerik'=>$_POST['icerik'], 'tarih'=>'NOW()', 'sira'=>self::$db->get_max('urunler', 'sira')+1 )); if (!$urun_id) { $this->r_error_print('Ürün eklenirken bir sorun oluştu'); } $resimler = $_FILES['resim']; for ($i=0; $i < count($resimler['name']); $i++) { if (!strstr($resimler['type'][$i], 'image')) { $this->r_error_print('<b>Desteklenmeyen dosya türü:</b> '.$resimler['name'][$i]); continue; } $resim_yukleme_sonucu = copy($resimler['tmp_name'][$i], 'c:\\wamp\\www\\panel\\urunResimleri\\'.$resimler['name'][$i]); $sonuc = self::$db->insert('resimler', array('resim'=>$resimler['name'][$i], 'parent'=>$urun_id )); } if ($sonuc) { echo "Ürün başarıyla eklendi."; } else { echo mysql_error(); } }}?>