17/09/2012 7:15am

PHP | Problem -


<?php

class ProjectPage extends Page
{

static $has_many = array (
'ProjectInfos' => 'ProjectInfo',
'ProjectGalleryImages' => 'ProjectGalleryImage'
);

public function getCMSFields()
{
$f = parent::getCMSFields();

/* PROJECT GALLERY */
$gridFieldConfig = GridFieldConfig::create();
$gridFieldConfig->addComponent(new GridFieldButtonRow('after'));
$gridFieldConfig->addComponent($add_new_button = new GridFieldAddNewButton('buttons-after-left'));
$gridFieldConfig->addComponent($sort = new GridFieldSortableHeader());
$gridFieldConfig->addComponent($datacolumns = new GridFieldDataColumns());
$gridFieldConfig->addComponent(new GridFieldEditButton());
$gridFieldConfig->addComponent(new GridFieldDeleteAction());
$gridFieldConfig->addComponent(new GridFieldDetailForm());
$gridFieldConfig->addComponent(new GridFieldSortableRows('sort_column'));

$add_new_button->setButtonName('Afbeelding toevoegen');
$datacolumns->setDisplayFields(array('Attachment.CMSThumbnail' => 'Projectafbeeldingen'));
$list = $this->ProjectGalleryImages();
$list->sort('sort_column');

$gridfield = new GridField("ProjectGalleryImages", "Projectafbeeldingen", $list, $gridFieldConfig);

$f->addFieldToTab('Root.Projectafbeeldingen', $gridfield);

/* ProjectInfo */
$grid_field_config = GridFieldConfig::create();
$grid_field_config->addComponent($data_columns = new GridFieldDataColumns);
$grid_field_config->addComponent(new GridFieldButtonRow('after'));
$grid_field_config->addComponent($add_new_button = new GridFieldAddNewButton('buttons-after-left'));
$add_new_button->setButtonName('Info toevoegen');
$grid_field_config->addComponent(new GridFieldDetailForm());
$grid_field_config->addComponent(new GridFieldEditButton());
$grid_field_config->addComponent(new GridFieldDeleteAction());
$grid_field_config->addComponent($sort = new GridFieldSortableHeader());
$grid_field_config->addComponent(new GridFieldSortableRows('sort_column'));

$which_columns = array(
"Title" => "Titel",
"MainText" => "Info"
);
$data_columns->setDisplayFields($which_columns);
$list = $this->ProjectInfos();
$list->sort('sort_column');
$gridfield = new GridField("ProjectInfos", "Technische info", $list, $grid_field_config);
$f->addFieldToTab('Root.TechnischeInfo', $gridfield);

return $f;
}
}

class ProjectPage_Controller extends Page_Controller
{ public function SelectedTag() {
if(isset($_REQUEST['tag']))
{
$tagSafeForDB = Convert::raw2sql($_REQUEST['tag']);
$SelectedTag = DataObject::get("Tag", "URLSegment = '$tagSafeForDB'");
if($SelectedTag)
{
return $SelectedTag;
} else {
return false;
}

} else {
return false;
}
}
}




<?php
class ProjectGalleryImage extends DataObject
{
static $db = array (
'sort_column' => 'Int'
);

static $has_one = array (
'Attachment' => 'ExtraImage',
'GalleryPage' => 'ProjectPage'
);

function getCMSFields() {
$f = parent::getCMSFields();
$f->removeFieldFromTab('Root.Main', 'sort_column');
$f->renameField('Attachment', 'Afbeelding');
$f->removeFieldFromTab('Root.Main', 'GalleryPageID');

$f->removeFieldFromTab('Root.Main', 'Attachment');
$upload_field = new UploadField('Attachment', 'Kies een afbeelding');
$upload_field->relationAutoSetting = false;
$upload_field->setConfig('allowedMaxFileNumber', 1);
$f->addFieldToTab('Root.Main', $upload_field);

return $f;
}
}


<?php
class ExtraImage extends Image {

function generateThumb_60_60($gd) {
$my_image = $gd->setQuality(90);
$my_image = $gd->croppedResize(60,60);
return $my_image;
}

function generateFull_800_600($gd) {
$my_image = $gd->setQuality(90);
$my_image = $gd->resizeRatio(800, 600);
return $my_image;
}

function generatePageImage($gd) {
$my_image = $gd->setQuality(90);
$my_image = $gd->croppedResize(300, 255);
return $my_image;
}
}


Post Comment