Eindpresentatie stage
INHOUD
- Stageopdracht
- Aanpak stageopdracht
- Resultaat stageopdracht
- Punten voor verbetering stageopdracht
- Reflectie stage
- Tijd voor vragen
Stageopdracht
Overzicht van de stageopdracht
STAGEOPDRACHT
- Opzetten development omgeving
- Tools leren gebruiken en beheersen
- Gebruik ontwikkelplatform Dropsolid
- Zelfstandig Cooldrops websites aanmaken
- Basis drupal coding
Aanpak stageopdracht
Hoe heb ik deze stageopdracht aangepakt?
Aanpak stageopdracht
- Eerste 2 weken opleiding
- Eerste Cooldrops project
- Drupal trainingen
- Aanpak nieuwe projecten
- Aanpak bestaande projecten
Resultaat stageopdracht
Resultaat na 3 maanden stage
RESULTAAT STAGEOPDRACHT
- Grondwerken Doom
- Carthage
- Tom Buysse
- Riverpark
- Bug fixing op verschillende sites (8)
- Opmaak verschillende projecten
MIGRATE TOM BUYSSE
- 2 modules schrijven
- Importeren afbeeldingen
- Importeren cultivar csv bestand
- 2 overzichtspagina's cultivar met filter
- Detailpagina cultivar
- tombuysse.local
Afbeeldingen importeren
Cultivar photo import
Migrate Tom Buysse
name = "Tom Buysse Cultivar photo migration"
description = "Importeert de afbeeldingen via een upload veld. Deze worden geplaatst in de cutlivar map onder
sites/default/files. Wanneer een afbeelding al bestaat, wordt deze overschreven.
Ook worden de afbeeldingen omgezet naar kleine letters indien hier nog grote letters in staan."
core = 7.x
version = "7.x-1.0"
package = "Dropsolid"
dependencies[] = migrate
dependencies[] = migrate_ui
dependencies[] = plupload
files[] = cultivar_photo_import_form.inc
cultivar_photo_import.info
Migrate Tom Buysse
<?php
/**
* Implements hook_menu_api()
*/
function cultivar_photo_import_menu(){
$items = array();
$items['admin/import/photos'] = array(
'title' => 'Import pictures',
'page callback' => 'drupal_get_form',
'page arguments' => array('import_pictures'),
'access callback' => TRUE,
'description' => 'Imports the pictures with plupload',
'type' => MENU_LOCAL_TASK,
'file' => 'cultivar_photo_import_form.inc',
);
return $items;
}
cultivar_photo_import.module
Migrate Tom Buysse
<?php
function import_pictures($form_state, &$form_state){
$form['item_plupload'] = array(
'#type' => 'plupload',
'#title' => t('Upload images'),
'#description' => t('Meerdere afbeeldingen uploaden'),
'#upload_validators' => array(
'file_validate_extensions' => array(
'jpg'),
'my_custom_file_validator' => array('some validation criteria'),
),
'#plupload_settings' => array(
'runtimes' => 'html5',
'chunk_size' => '2mb',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
function import_pictures_submit($form, &$form_state) {
$saved_files = array(); //Array to capture file objects
$scheme = variable_get('file_default_scheme', 'public') . '://';
$directoryname = 'cultivar'; // Directory where images are collected
$imagebankpath = $scheme . $directoryname;
file_prepare_directory($imagebankpath, FILE_CREATE_DIRECTORY); // Create the folder if it doesn't exist
// We can't use file_save_upload() because of
// http://www.jacobsingh.name/content/tight-coupling-no-not
// file_uri_to_object();
foreach ($form_state['values']['item_plupload'] as $uploaded_file) {
if ($uploaded_file['status'] == 'done') {
$source = $uploaded_file['tmppath'];
$destination = strtolower(file_stream_wrapper_uri_normalize($imagebankpath .'/'. $uploaded_file['name']));
$oldfiles = file_load_multiple(array(),array('uri'=> $destination));
$oldfile = reset($oldfiles);
if($oldfile){
file_delete($oldfile);
}
// Rename it to its original name, and put it in its final home.
// Note - not using file_move here because if we call file_get_mime
// (in file_uri_to_object) while it has a .tmp extension, it horks.
$destination = file_unmanaged_move($source, $destination, FILE_EXISTS_REPLACE);
$file = plupload_file_uri_to_object($destination);
file_save($file);
$saved_files[] = $file;
}
else {
form_set_error('uploadfiles', "Upload of {$uploaded_file['name']} failed");
}
}
}
cultivar_photo_import_form.inc
Cutlivar importeren
Cultivar import
Migrate Tom Buysse
name = "Tom Buysse Cultivar migration"
description = "Importeert de verschillende cultivar uit een csv bestand."
core = 7.x
version = "7.x-1.0"
package = "Dropsolid"
dependencies[] = migrate
dependencies[] = migrate_ui
dependencies[] = field
dependencies[] = file
dependencies[] = image
dependencies[] = number
dependencies[] = text
files[] = cultivar_import_migration.inc
files[] = cultivar_import_form.inc
files[] = cultivar_import_cron.inc
cultivar_import.info
Migrate Tom Buysse
<?php
/**
* Implements hook_migrate_api()
*/
/*
cultiar_import_ds_field_info:
custom display suite infoveld dat de 2 andere ds velden (eigenschappen en afbeeldingen) aanroept.
worden alletwee gebruikt op de detailpagina van een cultivar
cultivar_import_ds_field_eigenschappen_desc:
haalt de eigenschaptitels op zodanig dat deze op de detailpagina getoond worden.
cultivar_import_ds_field_cultivar_images:
haalt de afbeeldingen op aan de hand van de codes. Deze worden dan in een imagegallery gestoken met beschrijving.
function cultivar_import_migrate_api
deze roept de verschillende migrate classes aan, voor alle taxonomietermen 1 en
voor het content type cultivar en de field collections die aan cultivar hangen
function cultivar_import_menu()
*/
require_once 'cultivar_import_cron.inc';
function cultivar_import_ds_fields_info($entity_type){
$fields = array();
$fields['node']['cultivar_images'] = array(
'title' => t('Cultivar images'),
'field_type' => DS_FIELD_TYPE_FUNCTION,
'function' => 'cultivar_import_ds_field_cultivar_images',
);
$fields['node']['eigenschappen_desc'] = array(
'title' => t('Eigenschappen beschrijving'),
'field_type'=> DS_FIELD_TYPE_FUNCTION,
'function' =>'cultivar_import_ds_field_eigenschappen_desc',
);
if(isset($fields[$entity_type])){
return array($entity_type => $fields[$entity_type]);
}
return;
}
function cultivar_import_ds_field_eigenschappen_desc($field){
//in deze functie worden de titels van de eigenschappen opgehaald en geplaatst zodanig dat er slechts 1 titel moet zijn voor
//alle eigenschappen
if($field['build']['field_cultivar_properties']){
$value = $field['entity']->field_cultivar_properties['und'][0]['value'];
$content= '<div class="eigenschappen-titels"> <div class="eigenschap-item">';
$content .= $field['build']['field_cultivar_properties'][0]['entity']['field_collection_item'][$value]['field_botanisch']['#title'];
$content .= '</div><div class="eigenschap-item">';
$content .= $field['build']['field_cultivar_properties'][0]['entity']['field_collection_item'][$value]['field_diameter']['#title'];
$content .= '</div><div class="eigenschap-item">';
$content .= $field['build']['field_cultivar_properties'][0]['entity']['field_collection_item'][$value]['field_potmaat']['#title'];
$content .= '</div><div class="eigenschap-item">';
$content .= $field['build']['field_cultivar_properties'][0]['entity']['field_collection_item'][$value]['field_kleur']['#title'];
$content .= '</div><div class="eigenschap-item">';
$content .= $field['build']['field_cultivar_properties'][0]['entity']['field_collection_item'][$value]['field_bloeiperiode']['#title'];
$content .= '</div><div class="eigenschap-item">';
$content .= $field['build']['field_cultivar_properties'][0]['entity']['field_collection_item'][$value]['field_cultivar_in_stock']['#title'];
$content .= '</div></div>';
}
return $content;
}
function cultivar_import_ds_field_cultivar_images($field){
$image_style_thumbnail = 'aanbod_detail_gallery_thumb';
$image_style_big = 'aanbod_detail_gallery';
$cultivarnode = node_load($field['entity']->vid);
$entitys = $cultivarnode->field_cultivar_properties['und'];
$content = '<div class="cultivar_images" id="gallery" style="display:none">';
foreach($entitys as $entityitem){
$entitytoload = $entityitem['value'];
$field_collection = entity_load('field_collection_item',array($entitytoload));
$field_collection = $field_collection[$entitytoload];
$query = db_select('migrate_map_cultivar_field_group','n');
$query ->condition('n.destid1', $entitytoload, '=')
->fields('n', array('sourceid1','sourceid2','sourceid3','sourceid4','sourceid5','sourceid6'));
$result = $query->execute();
//description wordt opgesteld voor in de image gallery als beschrijven bij iedere afbeelding.
$description = $field_collection->field_botanisch['und'][0]['taxonomy_term']->name;
$description .= ' ';
$description .= $field_collection->field_kleur['und'][0]['taxonomy_term']->name;
$description .= '. Diameter van ';
$description .= $field_collection->field_diameter['und'][0]['taxonomy_term']->name;
$description .= ', potmaat van ';
$description .= $field_collection->field_potmaat['und'][0]['taxonomy_term']->name;
$description .= ', bloeit ';
$description .= $field_collection->field_bloeiperiode['und'][0]['taxonomy_term']->name;
$description .= '.';
if($field_collection->field_cultivar_in_stock['und'][0]['value']){
$description .= ' In stock.';
}
else{
$description .= ' Niet in stock.';
}
foreach ($result as $key => $value) {
$imagekey = $value->sourceid2 . $value->sourceid3 . '-' . $value->sourceid1 . '-' . $value->sourceid5 . $value->sourceid6 . '.jpg';
$imageURI = strtolower('public://cultivar/' . $imagekey);
$largeimage = theme('image_style',array('style_name' => $image_style_big, 'path' => $imageURI,));
preg_match('@src="([^"]+)"@', $largeimage, $match);
$largeimagesrc = array_pop($match);
$content .= theme('image_style', array('style_name'=> $image_style_thumbnail, 'path' => $imageURI,
'attributes' => array('data-image' => $largeimagesrc, 'data-description' => $description),'alt' => $description));
}
}
$content .= '</div>';
return $content;
}
function cultivar_import_migrate_api(){
$api = array(
'api' => 2,
'groups' => array(
'cultivar_group' => array(
'title' => t('Importeer cultivar'),
),
),
'migrations' => array(
'cultivar' => array(
'class_name' => 'cultivar',
'group_name' => 'cultivar_group',
),
'cultivar_field_group' => array(
'class_name' => 'cultivar_field_group',
'group_name' => 'cultivar_group',
),
'botanisch' => array(
'class_name' => 'botanisch_term',
'group_name' => 'cultivar_group',
),
'diameter_type' => array(
'class_name' => 'diameter_type_term',
'group_name' => 'cultivar_group',
),
'potmaat' => array(
'class_name' => 'potmaat_term',
'group_name' => 'cultivar_group',
),
'kleur' => array(
'class_name' => 'kleur_term',
'group_name' => 'cultivar_group',
),
'bloeiperiode' => array(
'class_name' => 'bloeiperiode_term',
'group_name' => 'cultivar_group',
)
)
);
return $api;
}
function cultivar_import_menu(){
$items = array();
$items['admin/import/cultivar'] = array(
'title' => 'Import Cultivar',
'page callback' => 'drupal_get_form',
'page arguments' => array('import_cultivar'),
'access callback' => TRUE,
'description' => 'Imports csv off the cultivar',
'type' => MENU_LOCAL_TASK,
'file' => 'cultivar_import_form.inc',
);
return $items;
}
cultivar_import.module
Migrate Tom Buysse
<?php
/**
* Import cultivar.
*
* @param array $nids
*/
function cultivar_import_cron(){
_cultivar_import_migrate_botanisch();
_cultivar_import_migrate_diameter_type();
_cultivar_import_migrate_potmaat();
_cultivar_import_migrate_kleur();
_cultivar_import_migrate_bloeiperiode();
_cultivar_import_migrate_rollback();
_cultivar_import_migrate_cultivar();
_cultivar_import_migrate_cultivar_field_group();
}
function _cultivar_import_migrate_rollback($nids = NULL){
$class_name = 'cultivar';
$machine_name = 'cultivar';
_cultivar_import_rollback($nids,$class_name,$machine_name);
$class_name = 'cultivar_field_group';
$machine_name = 'cultivar_field_group';
_cultivar_import_rollback($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_botanisch($nids = NULL) {
$class_name = 'botanisch_term';
$machine_name = 'botanisch';
_cultivar_import_all($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_diameter_type($nids = NULL) {
$class_name = 'diameter_type_term';
$machine_name = 'diameter_type';
_cultivar_import_all($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_potmaat($nids = NULL) {
$class_name = 'potmaat_term';
$machine_name = 'potmaat';
_cultivar_import_all($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_kleur($nids = NULL) {
$class_name = 'kleur_term';
$machine_name = 'kleur';
_cultivar_import_all($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_bloeiperiode($nids = NULL) {
$class_name = 'bloeiperiode_term';
$machine_name = 'bloeiperiode';
_cultivar_import_all($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_cultivar($nids = NULL) {
$class_name = 'cultivar';
$machine_name = 'cultivar';
_cultivar_import_all($nids,$class_name,$machine_name);
}
function _cultivar_import_migrate_cultivar_field_group($nids = NULL) {
$class_name = 'cultivar_field_group';
$machine_name = 'cultivar_field_group';
_cultivar_import_field_group($nids,$class_name,$machine_name);
}
function _cultivar_import_all($nids, $class_name, $machine_name){
if ($nids) {
MigrationBase::registerMigration($class_name, $machine_name, array('group_name' => 'cultivar_group', 'nids' => $nids, 'import' => 1));
}
else {
MigrationBase::registerMigration($class_name, $machine_name, array('group_name' => 'cultivar_group', 'default_uid' => 1, 'import' => 1));
}
$migration = Migration::getInstance($machine_name);
$migration->prepareUpdate();
$result = $migration->processImport();
}
function _cultivar_import_field_group($nids, $class_name, $machine_name){
if ($nids) {
MigrationBase::registerMigration($class_name, $machine_name, array('group_name' => 'cultivar_group', 'nids' => $nids, 'import' => 1));
}
else {
MigrationBase::registerMigration($class_name, $machine_name, array('group_name' => 'cultivar_group', 'default_uid' => 1, 'import' => 1));
}
$migration = Migration::getInstance($machine_name);
//hierbij geen prepareupdate(), deze zorgt voor een clone() error bij het kopieren van de field collections.
$result = $migration->processImport();
}
function _cultivar_import_rollback($nids, $class_name, $machine_name){
if ($nids) {
MigrationBase::registerMigration($class_name, $machine_name, array('group_name' => 'cultivar_group', 'nids' => $nids, 'import' => 1));
}
else {
MigrationBase::registerMigration($class_name, $machine_name, array('group_name' => 'cultivar_group', 'default_uid' => 1, 'import' => 1));
}
$migration = Migration::getInstance($machine_name);
$result = $migration->processRollback();
}
cultivar_photo_import_cron.inc
Migrate Tom Buysse
<?php
function import_cultivar($form_state, &$form_state){
$form['file'] = array(
'#type' => 'file',
'#title' => t('CSV Bestand'),
'#description' => t('Laad hier het csv bestand op. Let erop dat het csv bestand <strong>gescheiden is met , </strong>en niet met ;<br />
Zorg ervoor dat het bestand dat je upload 1 van de volgende bestandsnamen heeft:<br />
<ul>
<li>cultivar.csv voor alle cultivare te importeren</li>
<li>bloeiperiode.csv voor de verschillende bloeiperiodes.</li>
<li>botanisch.csv voor de verschillende botanische termen</li>
<li>diameter.csv voor de verschillende diameters</li>
<li>kleur.csv voor de verschillende kleuren</li>
<li>potmaat.csv voor de verschillende potmaten</li>
</ul>
'),
'#upload_validators' => array(
'file_validate_extensions' => array('csv'),
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
$path = '/sites/default/files/cultivar_import';
$form['helptext'] = array(
'#markup'=> '<br /><h1>Info voor importeren</h1>Wanneer u het csv bestand van een van de cultivar eigenschappen opent in kladblok, moeten die er als volgt uitzien:.<br />
Zoals u kan zien zijn er hier geen titels voor code en naam.<br />
In excel is dit gewoon een tabel met in de 1ste kolom de codes en in de 2de kolom de beschrijving.<br />
<img src="' . $path .'/richtlijnen_taxonomy_terms.png" />
<br /><br />
Wanneer u het csv bestand van de cultivare opent in kladblok, moet deze er als volgt uit zien:<br />
Hier is dit dus wel met 2rijen voor titels en ondertitels.<br />
Ook is het belangrijk dat de codes van alle cultivar kloppen. De planten worden aan de hand van deze codes ingeladen.<br />
Wanneer een plant er niet of niet goed door komt, is dit waarschijnlijk omdat er een code verkeerd staat.<br /><br />
<img src="' . $path . '/richtlijnen_cultivar.png" /><br />
In excel ziet dit er als volgt uit. (voordat excel als csv opgeslagen wordt.)<br /><br />
<img src="' .$path . '/richtlijnen_cultivar_xlsx.png" /><br />
<br />
'
);
return $form;
}
function import_cultivar_validate($form, &$form_state){
$file = file_save_upload('file', array(
'file_validate_extensions' => array('csv'),
));
$file->status = 1;
file_save($file);
if ($file){
if($file = file_move($file, 'public://csv', FILE_EXISTS_REPLACE)){
$form_state['storage']['file'] = $file;
drupal_set_message(t('The file has been uploaded'));
}
else{
form_set_error('file', t("Failed to write the uploaded file to the site's filder."));
}
}
else{
form_set_error('file',t('No file was uploaded.'));
}
}
cultivar_import_form.inc
Migrate Tom Buysse
<?php
//classes die eindigen op _term zijn klassen gemaakt voor het
//importeren van de taxonomie termen
class botanisch_term extends Migration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import de Botanisch taxonomy term');
$path= 'public://';
$pathcsv=$path."csv/botanisch.csv";
$options=array(
"delimiter" =>",",
"header_rows" => false,
);
$columns = array(
array("id","id"),
array("title","title"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
),
MigrateDestinationTerm::getKeySchema()
);
$this->destination = new MigrateDestinationTerm('botanisch');
$this->addFieldMapping('name', 'title');
}
public function prepareRow($row) {
}
public function prepare($entity, $row) {
}
public function complete($entity, $row){
}
public function postImport(){
parent::postImport();
$sections = $this->getMap()->getRowsNeedingUpdate(99999);
$section_ids = array();
foreach ($sections as $section) {
taxonomy_term_delete($section->destid1);
$section_ids[] = $section->destid1;
}
if(count($section_ids)>0){
db_delete("migrate_map_botanisch")->condition("destid1",$section_ids, "IN")->execute();
}
}
}
class diameter_type_term extends Migration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import de Diameter / Type taxonomy term');
$path= 'public://';
$pathcsv=$path."csv/diameter.csv";
$options=array(
"delimiter" =>",",
"header_rows" => false,
);
$columns = array(
array("id","id"),
array("title","title"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
),
MigrateDestinationTerm::getKeySchema()
);
$this->destination = new MigrateDestinationTerm('diameter_type');
$this->addFieldMapping('name', 'title');
}
public function prepareRow($row) {
}
public function prepare($entity, $row) {
}
public function complete($entity, $row){
}
public function postImport(){
parent::postImport();
$sections = $this->getMap()->getRowsNeedingUpdate(99999);
$section_ids = array();
foreach ($sections as $section) {
taxonomy_term_delete($section->destid1);
$section_ids[] = $section->destid1;
}
if(count($section_ids)>0){
db_delete("migrate_map_diameter_type")->condition("destid1",$section_ids, "IN")->execute();
}
}
}
class potmaat_term extends Migration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import de potmaten');
$path= 'public://';
$pathcsv=$path."csv/potmaat.csv";
$options=array(
"delimiter" =>",",
"header_rows" => false,
);
$columns = array(
array("id","id"),
array("title","title"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
),
MigrateDestinationTerm::getKeySchema()
);
$this->destination = new MigrateDestinationTerm('potmaat');
$this->addFieldMapping('name', 'title');
}
public function prepareRow($row) {
}
public function prepare($entity, $row) {
}
public function complete($entity, $row){
}
}
class kleur_term extends Migration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import de kleuren');
$path= 'public://';
$pathcsv=$path."csv/kleur.csv";
$options=array(
"delimiter" =>",",
"header_rows" => false,
);
$columns = array(
array("id","id"),
array("title","title"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
),
MigrateDestinationTerm::getKeySchema()
);
$this->destination = new MigrateDestinationTerm('kleur');
$this->addFieldMapping('name', 'title');
}
public function prepareRow($row) {
}
public function prepare($entity, $row) {
}
public function complete($entity, $row){
}
public function postImport(){
parent::postImport();
$sections = $this->getMap()->getRowsNeedingUpdate(99999);
$section_ids = array();
foreach ($sections as $section) {
taxonomy_term_delete($section->destid1);
$section_ids[] = $section->destid1;
}
if(count($section_ids)>0){
db_delete("migrate_map_kleur")->condition("destid1",$section_ids, "IN")->execute();
}
}
}
class bloeiperiode_term extends Migration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import de bloeiperodes');
$path= 'public://';
$pathcsv=$path."csv/bloeiperiode.csv";
$options=array(
"delimiter" =>",",
"header_rows" => false,
);
$columns = array(
array("id","id"),
array("title","title"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
),
MigrateDestinationTerm::getKeySchema()
);
$this->destination = new MigrateDestinationTerm('bloeiperiode');
$this->addFieldMapping('name', 'title');
}
public function prepareRow($row) {
}
public function prepare($entity, $row) {
}
public function complete($entity, $row){
}
public function postImport(){
parent::postImport();
$sections = $this->getMap()->getRowsNeedingUpdate(99999);
$section_ids = array();
foreach ($sections as $section) {
taxonomy_term_delete($section->destid1);
$section_ids[] = $section->destid1;
}
if(count($section_ids)>0){
db_delete("migrate_map_bloeiperiode")->condition("destid1",$section_ids, "IN")->execute();
}
}
}
cultivar_import_migration.inc
Migrate Tom Buysse
class cultivar extends Migration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Importeer de cultivare');
$path= 'public://';
$pathcsv = $path. "csv/cultivar.csv";
$options=array(
"delimiter" => ",",
"header_rows" => 2,
);
$columns = array(
array("botanisch_code","botanisch_code"),
array("botanisch_desc","botanisch_desc"),
array("diameter_code","diameter_code"),
array("diameter_desc","diameter_desc"),
array("potmaat_code","potmaat_code"),
array("potmaat_desc","potmaat_desc"),
array("cultivar_code","cultivar_code"),
array("cultivar_desc","cultivar_desc"),
array("kleur_code","kleur_code"),
array("kleur_desc","kleur_desc"),
array("bloeiperiode_code","bloeiperiode_code"),
array("bloeiperiode_desc","bloeiperiode_desc"),
array("beschikbaar","beschikbaar"),
array("foto","foto"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->map = new MigrateSQLMap($this->machineName,
array(
'cultivar_code'=> array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
),
MigrateDestinationNode::getKeySchema()
);
$this->destination = new MigrateDestinationNode('cultivar');
$this->addFieldMapping('title','cultivar_desc');
}
public function prepareRow($row) {
}
public function prepare($entity, $row) {
}
public function complete($entity, $row) {
}
public function postImport(){
parent::postImport();
$migrate_array = array();
$csv_array = array();
$ids_to_delete = array();
$csv = array_map('str_getcsv' , file($this->source));
$query = db_select('migrate_map_cultivar','n');
$query->fields('n', array('sourceid1','destid1'));
$queryresult = $query->execute();
foreach($csv as $key => $value){
$sourcekey =$value[6];
$csv_array[] = $sourcekey;
}
foreach($queryresult as $key => $value){
if(!in_array($value->sourceid1,$csv_array)){
$ids_to_delete[] = $value->destid1;
}
}
if(!empty($ids_to_delete)){
db_delete("migrate_map_cultivar")->condition("destid1",$ids_to_delete, "IN")->execute();
node_delete_multiple($ids_to_delete);
}
}
}
class cultivar_field_group extends Migration{
public function __construct(){
parent::__construct();
$this->description = t('Cultivar field group migration');
$path= 'public://';
$pathcsv = $path. "csv/cultivar.csv";
$options=array(
"delimiter" => ",",
"header_rows" => 2,
);
$columns = array(
array("botanisch_code","botanisch_code"),
array("field_botanisch","botanisch_desc"),
array("diameter_code","diameter_code"),
array("field_diameter","diameter_desc"),
array("potmaat_code","potmaat_code"),
array("field_potmaat","potmaat_desc"),
array("cultivar_code","cultivar_code"),
array("cultivar_desc","cultivar_desc"),
array("kleur_code","kleur_code"),
array("field_kleur","kleur_desc"),
array("bloeiperiode_code","bloeiperiode_code"),
array("field_bloeiperiode","bloeiperiode_desc"),
array("beschikbaar","beschikbaar"),
array("foto","foto"),
);
$this->source = new MigrateSourceCSV($pathcsv, $columns, $options);
$this->destination = new MigrateDestinationFieldCollection(
'field_cultivar_properties', array('host_entity_type' => 'node')
);
$this->map = new MigrateSQLMap($this->machineName,
array(
'cultivar_code'=> array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE
),
'botanisch_code' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE
),
'diameter_code' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE
),
'potmaat_code' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE
),
'kleur_code' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE
),
'bloeiperiode_code' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE
),
),
MigrateDestinationFieldCollection::getKeySchema()
);
$this->addFieldMapping('host_entity_id' , 'cultivar_code')->sourceMigration('Cultivar');
$this->addFieldMapping('field_botanisch','field_botanisch');
$this->addFieldMapping('field_diameter','field_diameter');
$this->addFieldMapping('field_potmaat','field_potmaat');
$this->addFieldMapping('field_kleur','field_kleur');
$this->addFieldMapping('field_bloeiperiode','field_bloeiperiode');
$this->addFieldMapping('field_cultivar_in_stock','beschikbaar');
}
public function prepareRow($row) {
if($row->beschikbaar == 'JA'){
$row->beschikbaar = 1;
}else{
$row->beschikbaar = 0;
}
}
public function postImport(){
parent::postImport();
$migrate_array = array();
$csv_array = array();
$ids_to_delete = array();
$csv = array_map('str_getcsv' , file($this->source));
$query = db_select('migrate_map_cultivar_field_group','n');
$query->fields('n', array('sourceid1','sourceid2','sourceid3','sourceid4','sourceid5','sourceid6','destid1'));
$queryresult = $query->execute();
foreach($csv as $key => $value){
$sourcekey = $value[0] . $value[2] . $value[4] . $value[6] . $value[8] . $value[10];
$csv_array[] = $sourcekey;
}
foreach($queryresult as $key => $value){
$migratekey = $value->sourceid2 . $value->sourceid3 . $value->sourceid4 . $value->sourceid1 . $value->sourceid5 . $value->sourceid6;
if(!in_array($migratekey,$csv_array)){
$ids_to_delete[] = $value->destid1;
if(entity_load('field_collection_item', array($value->destid1))){
entity_delete('field_collection_item', array($value->destid1));
}
}
$migrate_array[$migratekey] = $value->destid1;
}
if(!empty($ids_to_delete)){
db_delete("migrate_map_cultivar_field_group")->condition("destid1",$ids_to_delete, "IN")->execute();
}
}
}
cultivar_import_migration.inc (2)
Overzichtspagina met filters
Template files
Migrate Tom Buysse
<?php
//eerste gedeelte, hier wordt gekeken welke diameters er actief zijn bij welke cultivare, hierdoor kan er gefitlerd worden
//bij de diameters als die er niet is voor een bepaalde cultivar.
$viewnode = $view->result;
$array = array();
$arraykeys;
foreach ($viewnode as $node) {
$node = $node->field_field_cultivar_properties;
foreach ($node as $property) {
$raw = $property['raw']['value'];
$property = $property['rendered']['entity']['field_collection_item'][$raw];
//om te kijken of in stock, volgend lijntje uit commentaar (voor huidig aanbod)
//$instock = $property['field_cultivar_in_stock']['#items'][0]['value'];
$key= $property['field_diameter']['#items'][0]['tid'];
$value = $property['field_botanisch']['#items'][0]['tid'];
if(!array_key_exists($key, $array)){
$arraykeys .= ' ';
$arraykeys .= $key;
}
$array[$key][] = $value;
}
}
?>
<!--filter 1 voor botanische termen, allemaal tonen-->
<?php
$terms = array();
$vid = NULL;
$vid_machine_name = 'botanisch';
$vocabulary = taxonomy_vocabulary_machine_name_load($vid_machine_name);
$all_term_ids; //alltermids is om alle termen van cultivar in te laden, zodat deze op de all klasse van diameter gezet kunnen worden.
if(!empty($vocabulary->vid)){
$vid = $vocabulary->vid;
}
if (!empty($vid)) {
$terms = taxonomy_get_tree($vid);
}
?>
<?php if (!empty($terms)): ?>
<h1>Cultivar</h1>
<div class="cultivar-filter cultivar" data-filter-group="cultivar">
<button class="button filter-item is-checked" data-filter = ".all"><?php print t('Alle') ?></button>
<?php foreach ($terms as $term): ?>
<?php $all_term_ids .= $term->tid;
$all_term_ids .= ' ';
?>
<button class="button filter-item" data-filter=".<?php print $term->tid; ?>"><?php print $term->name; ?></button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!--filter 2 voor diameters, allemaal tonen, maar filter van botanische termen op toegepast-->
<h1>Diameter / type</h1>
<?php
$terms = array();
$vid = NULL;
$vid_machine_name = 'diameter_type';
$vocabulary = taxonomy_vocabulary_machine_name_load($vid_machine_name);
if(!empty($vocabulary->vid)){
$vid = $vocabulary->vid;
}
if (!empty($vid)) {
$terms = taxonomy_get_tree($vid);
}
?>
<?php if (!empty($terms)): ?>
<div class="cultivar-filter diameter isotope" data-filter-group="diameter">
<button class="button filter-item isotope-item is-checked all <?php print $all_term_ids; print $arraykeys ?>" data-filter = ".all"><?php print t('Alle') ?></button>
<?php foreach ($terms as $term): ?>
<?php
//hier worde de klasses toegevoegd aan de button om zo mee te filteren op botanische term.
$classfilter = '';
if(array_key_exists($term->tid, $array)){
foreach ($array[$term->tid] as $item) {
$classfilter .=$item;
$classfilter .= ' ';
}
?>
<button class="button filter-item isotope-item all <?php print $classfilter; print $arraykeys; ?>" data-filter=".<?php print $term->tid; ?>"><?php print $term->name; ?></button>
<?php } endforeach; ?>
</div>
<?php endif; ?>
totaal_aanbod_filter.php en huidig_aanbod_filter.php
Migrate Tom Buysse
<?php
/**
* @file
* Default simple view template to display a rows in a grid.
*
* - $rows contains a nested array of rows. Each row contains an array of
* columns.
*
* @ingroup views_templates
*/
?>
<div id="filters">
<?php
require_once 'totaal_aanbod_filter.tpl.php';
?>
</div>
<div class="isotope">
<?php $i=0; foreach ($rows as $id => $row): ?>
<?php print $row; ?>
<?php $i++; endforeach; ?>
</div>
views-view-unformatted--totaal-aanbod.tpl.php
Migrate Tom Buysse
<?php
/**
* @file
* Default simple view template to display a rows in a grid.
*
* - $rows contains a nested array of rows. Each row contains an array of
* columns.
*
* @ingroup views_templates
*/
?>
<div id="filters">
<?php
require_once 'huidig_aanbod_filter.tpl.php';
?>
</div>
<div class="isotope">
<?php $i=0; foreach ($rows as $id => $row): ?>
<?php print $row; ?>
<?php $i++; endforeach; ?>
</div>
views-view-unformatted--huidig-aanbod.tpl.php
Migrate Tom Buysse
<?php
$image_style = 'aanbod_overzicht';
$terms = array();
$node = node_load($fields['field_cultivar_properties']->raw);
$nodenrs = $node->field_cultivar_properties['und'];
$filteritems = $node->field_cultivar_properties['und'];
$node = $node->field_cultivar_properties['und'][0]['value'];
$field_collection = entity_load('field_collection_item',array($node));
$field_collection = $field_collection[$node];
$query = db_select('migrate_map_cultivar_field_group','n');
$query->condition('n.destid1',$node, '=')
->fields('n', array('sourceid1','sourceid2','sourceid3','sourceid4','sourceid5','sourceid6'));
$result = $query->execute();
$link = $fields['title']->content;
preg_match_all('/<a[^>]+href=([\'"])(.+?)\1[^>]*>/i', $link, $linkurl);
$content = '<div class="isotope-item isotope-item-markup all';
foreach ($filteritems as $key => $value) {
$filter_item = entity_load('field_collection_item',array($value));
$filter_item_cultivar = $filter_item[$value['value']]->field_botanisch['und'][0]['tid'];
$filter_item_diameter = $filter_item[$value['value']]->field_diameter['und'][0]['tid'];
if(!in_array($filter_item_cultivar, $terms)){
$terms[] = $filter_item_cultivar;
$content .= ' ';
$content .= $filter_item_cultivar;
}
if(!in_array($filter_item_diameter, $terms)){
$terms[] = $filter_item_diameter;
$content .= ' ';
$content .= $filter_item_diameter;
}
}
$content .= '">';
$content .= $linkurl[0][0];
foreach ($result as $key => $value) {
$imagekey = $value->sourceid2 . $value->sourceid3 . '-' . $value->sourceid1 . '-' . $value->sourceid5 . $value->sourceid6 . '.jpg';
$imageURI = strtolower('public://cultivar/' . $imagekey);
preg_match('@src="([^"]+)"@', $largeimage, $match);
$content .= theme('image_style', array('style_name'=> $image_style, 'path' => $imageURI, 'alt' => $imagekey));
}
$content .='</a>';
//gedeelte om in stock te kunnen opzoeken of niet, hierboven eigenlijk identiek aan totaal aanbod.
$inStock = false;
foreach($nodenrs as $nodenr){
$field_collection = entity_load('field_collection_item',array($nodenr['value']));
$field_collection = $field_collection[$nodenr['value']];
if($field_collection->field_cultivar_in_stock['und'][0]['value']){
$inStock = true;
}
}
if($inStock){
print $content;
print $fields['title']->content;
print '</div>';
}
?>
view-view-fields--huidig-aanbod.tpl.php
Riverpark
- Eerste Dropsolid van start
- Samen met Laurens
- Website bedoeld om te hergebruiken
- Javascript code
- riverpark.be
Riverpark.be
jQuery(document).ready(function($) {
/* add class for first half of troeven */
var troeven = $('.troef');
var half = troeven.length /2;
var htmlString;
var htmlnewString;
for (i = (half); i < troeven.length; i++) {
$(troeven[i]).addClass("right");
}
$('.troef').wrapInner($("<span></span>"));
var addedToDocument = false;
var wrapper = document.createElement("div");
wrapper.id = "left";
var nodesToWrap = document.getElementsByClassName("troef");
var half = nodesToWrap.length/2;
for (var index = 0; index < nodesToWrap.length; index++) {
var node = nodesToWrap[index];
if (! addedToDocument) {
if(index < half){
node.parentNode.insertBefore(wrapper, node);
} else{
node.parentNode.insertBefore(wrapper2,node);
}
addedToDocument = true;
}
if(index < half){
node.parentNode.removeChild(node);
wrapper.appendChild(node);
}
}
var screenwidth = window.screen.width;
if(screenwidth < 767){
$('.jcarousel-item').width(screenwidth - 15);
}
});
troeven.js
Migrate Tom Buysse
jQuery(document).ready(function($) {
//javascript om de autoscroll en de knoppen af te zetten indien er 3
//of minder items zijn.
//Door de circular wordt er altijd een placeholder geplaatst achteraan indien er slechts 3 items zijn
//daarom het aantal placeholders berekenen en het verschil berekenen
var carousel_items = $(".jcarousel-view--nieuws--block > .jcarousel-item").length;
var placeholder_items = $(".jcarousel-view--nieuws--block > .jcarousel-item-placeholder").length;
carousel_items = carousel_items - placeholder_items;
if (carousel_items <= 3 ){
$(".jcarousel-prev").hide();
$(".jcarousel-next").hide();
$(".jcarousel").jcarousel('startAuto', 0);
}
});
jcarousel.js
Opmaak verschillende projecten
- Altijd met SASS
- Session friday
- Mixin library
Mixin library
//TO DO
//mixin variables
//standaard kleur van de icoontjes
$icon-color: #000000;
$shadow-bottom-color: rgba(0, 0, 0, 0.7);
$shadow-bottom-height: 5px;
$button-default-color: #ffffff;
$button-shadow-bottom-height: 4px;
// Breakpoints
$onepx: em-calc(1) !default;
$hdpi-ratio-default: 1.3 !default;
$breakpoint-large-default: em-calc(1440) !default;
$breakpoint-medium-default: em-calc(959) !default;
$breakpoint-small-default: em-calc(767) !default;
//icon variables voor de verschillende meest gebruikte icons
$home: "\f015";
$map-marker: "\f041";
$envelope-o: "\f003";
$building-o: "\f0F7";
$fax: "\f1ac";
$mobile: "\f10b";
$check: "\f00c";
$star: "\f005";
$phone: "\f095";
@mixin icon($content, $color: $icon-color) {
@if $content == "home" {
$content: $home;
}
@else if $content == "map-marker" {
$content: $map-marker;
}
@else if $content == "envelope-o" or $content == "envelope" {
$content: $envelope-o;
}
@else if $content == "building-o" or $content == "building" {
$content: $building-o;
}
@else if $content == "fax" {
$content: $fax;
}
@else if $content == "mobile" {
$content: $mobile;
}
@else if $content == "check" {
$content: $check;
}
@else if $content == "star" {
$content: $star;
}
@else if $content == "phone" {
$content: $phone;
}
position: relative;
&:before {
font-family: FontAwesome;
position: absolute;
left: -17px;
color: $color;
content: $content;
margin-top: 1px;
}
}
@mixin gradient($top-color: #000000, $bottom-color: #ffffff) {
background: $top-color;
/* Old browsers */
background: -moz-linear-gradient(top, $top-color 0%, $bottom-color 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, $top-color), color-stop(100%, $bottom-color));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, $top-color 0%, $bottom-color 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, $top-color 0%, $bottom-color 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, $top-color 0%, $bottom-color 100%);
/* IE10+ */
background: linear-gradient(to bottom, $top-color 0%, $bottom-color 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$top-color', endColorstr='$bottom-color',GradientType=0 );
/* IE6-9 */
}
//zet shadow bottom met een kleine transiton
@mixin shadow-bottom($height: $shadow-bottom-height, $rgba-color: $shadow-bottom-color) {
-webkit-box-shadow: 0px $height $height 0px $rgba-color;
-moz-box-shadow: 0px $height $height 0px $rgba-color;
box-shadow: 0px $height $height 0px $rgba-color;
}
//mixin voor een button aan te maken, eerste parameter is het kleur dat meegegeven wordt.
//2de parameter zorgt er voor dat er een klikeffect komt indien het op ja staat.
//Fallback geschreven voor als 1ste parameter yes of no is en geen kleur meegegeven.
@mixin button($color: $button-default-color, $clickable: no) {
@if $color == yes or $color == no {
$clickable: $color;
$color: $button-default-color;
}
display: inline-block;
background-color: $color;
border: 1px solid mix(black, $color, 25%);
border-radius: 5px;
padding: .5em 1em;
&:hover {
cursor: pointer;
background-color: mix(black, $color, 15%);
border-color: mix(black, $color, 40%);
}
@include shadow-bottom($button-shadow-bottom-height, mix(black, $color, 30%));
@if $clickable == yes {
&:active {
margin-top: $button-shadow-bottom-height;
@include shadow-bottom(0px);
}
transition: all 0.1s;
}
}
//useful mixins from juice
//
// Calculate rems from a px value
// ------------------------------
@function rem-calc($px, $base-val: $base-px-default) {
@if not unitless($px) {
$px: strip-units($px);
}
@if not unitless($base-val) {
$base-val: strip-units($base-val);
}
@return ($px / $base-val) * 1rem;
}
// Breakpoints
// Inspiration: http://www.sitepoint.com/managing-responsive-breakpoints-sass/
// ---------------------------------------------------------------------------
$breakpoints: (
"large-only": "(min-width: #{$breakpoint-medium-default + $onepx})",
"large-up": "(min-width: #{$breakpoint-medium-default + $onepx})",
"large": "(max-width: #{$breakpoint-large-default})",
"medium-only": "(min-width: #{$breakpoint-small-default + $onepx}) and (max-width: #{$breakpoint-medium-default})",
"medium-up": "(min-width: #{$breakpoint-small-default + $onepx})",
"medium": "(max-width: #{$breakpoint-medium-default})",
"small-only": "(max-width: #{$breakpoint-small-default})",
"small": "(max-width: #{$breakpoint-small-default})"
);
@mixin bp($break, $viewport1: null) {
// preset breakpoint
@if not $viewport1 {
@if map-has-key($breakpoints, $break) {
@media only screen and #{map-get($breakpoints, $break)} { @content; }
}
@else {
@warn "Couldn't find a breakpoint named #{$break}.";
}
}
@else {
// min breakpoint
@if $break == min {
@media screen and (min-width: $viewport1) { @content; }
}
// max breakpoint
@else if $break == max {
@media screen and (max-width: $viewport1) { @content; }
}
// min & max breakpoint
@else {
@media screen and (min-width: $break) and (max-width: $viewport1) { @content; }
}
}
}
// Single side border radius
// -------------------------
@mixin border-top-radius($radius: $border-radius-default) {
border-top-right-radius: $radius;
border-top-left-radius: $radius;
}
@mixin border-right-radius($radius: $border-radius-default) {
border-top-right-radius: $radius;
border-bottom-right-radius: $radius;
}
@mixin border-bottom-radius($radius: $border-radius-default) {
border-bottom-right-radius: $radius;
border-bottom-left-radius: $radius;
}
@mixin border-left-radius($radius: $border-radius-default) {
border-top-left-radius: $radius;
border-bottom-left-radius: $radius;
}
_functions.scss
Punten voor verbetering stageopdracht
Tips om de stageopdracht beter te maken
PUNTEN VOOR VERBETERING STAGEOPDRACHT
- Weinig punten voor verbetering
- Briefing begin zeer handig
- Ruime mogelijkheid voor hulp
- Tijd voor projecten
- Tom Buysse iets onduidelijk
Reflectie stage
Mijn bevinding na 3 maanden stage lopen
REFLECTIE STAGE
- Veel bijgeleerd
- Goede sfeer op stage
- Tevreden van resultaten
- Iets te traag bij Tom Buysse
- Blijven verder werken in Drupal
Tijd voor vragen
Dankwoord
Eindpresentatie stage
By Brent Gees
Eindpresentatie stage
Eindpresentatie van mijn stage bij Dropsolid NV
- 2,409