示例#1
0
    function init()
    {
        parent::init();
        $this->add('H2')->set('Image Uploading');
        $this->add('P')->set('Image uploading and storing is implemented as additional layer on top of Files and Filestore.
				You will need to have a separate table for Image storage. By default the original image is stored in
				filestore but image is also being resized to the thumbnail size, then stored as a separate file.
				');
        $this->add('P')->set('By using Image class you can tweak the resolution of your thumbnails, then the image would
				be handled completely automatically by the controller.
				');
        $this->add('P')->set('Implementation of Image comes as a Model, Class, View and Form Field. You can further extend
				your image class to add relationship between image and your users for example.
				');
        $this->setCode(<<<'EOD'

$c=$p->add('Controller_Filestore_Image');
$c->addField('sample_file')->datatype('boolean');
$c->setMasterField('sample_file',true);

$c->setMaxResize('thumb', 100,200);

$f=$p->add('Form');
$f->addField('image','upload_image')->setController($c);

$p->add('H4')->set('Previously Uploaded Images');

$c->setActualFields(array('original_filename','filesize'));
$g=$p->add('MVCGrid')->setController($c);

$f->addButton('Refresh')->js('click',$p->js()->reload());

EOD
);
    }
示例#2
0
    function init()
    {
        parent::init();
        $this->setCode(<<<'EOD'
$f=$p->add('Form');
$f->addField('line','name')->validateNotNull();
$f->addField('line','surname');
$f->addButton('Try me')->js('click',$f->js()->submit());
if($f->isSubmitted()){
  $f->js()->univ()->alert('Thank you, '.$f->get('name').
	  ' '.$f->get('surname'))->execute();
}
EOD
);
    }
示例#3
0
文件: Upload.php 项目: xepan/xepan
    function init()
    {
        parent::init();
        $this->add('H2')->set('File Uploading');
        $this->add('P')->set('File management in PHP is often messy, involves temporary directories or is even stuck in
				MySQL. Agile Toolkit implements a powerful yet very simple "Filestore". This is a class which helps to keep
				your files organized. From the moment your file upload have finished and it have been saved to a upload
				directory - Filestore creates a new record for this file using MVC concept. 
				');
        $this->add('P')->set('What is really important is the flexibility and simplicity of this approach. You can now add
				upload field to your form and when form data is saved - you will receive filestore_file_id in upload field.
				The record in the database will automatically contain the file meta-information such as size and original
				name.
				');
        $this->add('P')->set('In this example we are going beyond that. We are slightly modifying File model/controller by
				defining new field "sample_file" and saying that it must always be true in our case. By using that, you can
				only see or upload files which conform to this condition, therefore you will not be able to see any other
				files in the filestore.
				');
        $this->setCode(<<<'EOD'

$c=$p->add('Controller_Filestore_File');
$c->addField('sample_file')->type('boolean');
$c->addCondition('sample_file',true);

$f=$p->add('Form');
$f->addField('upload','upload_file')->setController($c);

$p->add('H4')->set('Previously Uploaded Files');

$c->setActualFields(array('original_filename','filesize'));
$g=$p->add('MVCGrid')
 ->setController($c);
$g->addColumnPlain('delete','delete');

$f->addButton('Refresh')->js('click',$p->js()->reload());

EOD
);
    }