piotr karaś

› Class-attribute-based button sets in new MCE Online Editor

One of my primary postulates towards the new MCE Online Editor is that it supports different button sets, depending on explicit call or preset settings. Actually, presets would stand a much better approach, so let's forget about template declaration for a while. I decided to find out how much work it would require to make the preset approach run.

Ini structure modification

First of all, we have to store the settings we will be using later on. Current button declaration in ezoe.ini looks as follows:

[EditorSettings]
Buttons[]
Buttons[]=formatselect
Buttons[]=bold
Buttons[]=italic
Buttons[]=underline
...

We would need multi-dimentional array with multiple preset-like named blocks instead:

[EditorSettings]
ButtonPresets[]
ButtonPresets[]=full
ButtonPresets[]=mini
#...
[ButtonPreset-full]
Buttons[]
Buttons[]=formatselect
Buttons[]=bold
Buttons[]=italic
Buttons[]=underline
Buttons[]=|
Buttons[]=bullist
Buttons[]=numlist
Buttons[]=indent
Buttons[]=outdent
Buttons[]=|
Buttons[]=undo
Buttons[]=redo
#...
[ButtonPreset-mini]
Buttons[]
Buttons[]=formatselect
Buttons[]=bold
Buttons[]=italic
Buttons[]=underline
Buttons[]=|
Buttons[]=bullist
Buttons[]=numlist
Buttons[]=indent
Buttons[]=outdent

XMLBlock datatype modification

Once we're done with our preset configuration, we have to make the XML Block datatype actually display and store the preset values. First of all, we need to modify the datatype itself (kernel/classes/datatypes/ezxmltext/ezxmltexttype.php):

// Class constants declaration
const BUTTONS_FIELD = 'data_text2';
const BUTTONS_VARIABLE = '_ezxmltext_buttons_';
// Fetch and store post data - method modification
function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
{
$column = $base . self::COLS_VARIABLE . $classAttribute->attribute( 'id' );
$buttons = $base . self::BUTTONS_VARIABLE . $classAttribute->attribute( 'id' );
if ( $http->hasPostVariable( $column ) )
{
$columnValue = $http->postVariable( $column );
$classAttribute->setAttribute( self::COLS_FIELD, $columnValue );
$buttonsValue = $http->postVariable( $buttons );
$classAttribute->setAttribute( self::BUTTONS_FIELD, $buttonsValue );
return true;
}
return false;
}

The example above is not complete, there are other methods to modify, like initialization or (un)serialization ones. This should be enough to run the test, though.

We still have to modify the datatype templates. Again, we'll do the minimum: modify the datatype's class attribute template (design/standard/templates/class/datatype/edit/ezxmltext.tpl) by adding the following code:




Now, all pieces are in their place for the final cuts.

MCE Online Editor modification

First of all, we have to modify the method responsible for collecting the button settings from the configuration files. We locate the eZOEXMLInput handler class and extend the proper method:

function getEditorButtonList()
{
if ( $this->editorButtonList === null )
{
$contentClassAttributeID = $this->ContentObjectAttribute->ContentClassAttributeID;
$contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
$buttonPreset = $contentClassAttribute->DataText2;

$oeini = eZINI::instance( 'ezoe.ini' );
$buttonPresets = $oeini->variable( 'EditorSettings', 'ButtonPresets' );

if( !in_array( $buttonPreset, $buttonPresets ) )
{
$buttonPreset = $buttonPresets[0];
}
$buttonList = $oeini->variable( 'ButtonPreset-' . $buttonPreset , 'Buttons' );

$contentini = eZINI::instance( 'content.ini' );
$tags = $contentini->variable('CustomTagSettings', 'AvailableCustomTags' );
$hideButtons = array();
$showButtons = array();

// filter out underline if custom underline tag is not enabled
if ( !in_array('underline', $tags ) )
$hideButtons[] = 'underline';

// filter out pagebreak if custom pagebreak tag is not enabled
if ( !in_array('pagebreak', $tags ) )
$hideButtons[] = 'pagebreak';

// filter out relations buttons if user dosn't have access to relations
if ( !eZOEXMLInput::currentUserHasAccess( 'relations' ) )
{
$hideButtons[] = 'image';
$hideButtons[] = 'objects';
}
foreach( $buttonList as $button )
{
if ( !in_array( $button, $hideButtons ) )
$showButtons[] = $button;
}
$this->editorButtonList = $showButtons;
}
return $this->editorButtonList;
}

All this modification does is choose a proper button preset instead of a general one. It could be more warning-secured, this is the minimum.

This seems to be all, but it is not. The main MCE init template uses run-once operator to make sure that OE init is only run once. This is going to be a problem since OE button configuration is part of the init. We have to remove the run-once operator and allow multiple initializations. Now, I'm not sure at the moment if this is JavaScript-safe, but seems to work fine at first glance. Edit ezxmltext_ezoe.tpl template file and comment out run-once operators:

{*run-once*}
...
{*/run-once*}

This should be it.

Summary

As this example shows, a number of kernel-located files have to be modified in order to achieve this functionality. This takes just a couple of minutes once you know what you're doing, but kernel modification won't likely be accepted for premium support, for example. This is why I really hope this modification makes it to the eZ Publish 4.1.0 release, with some 4.0.x backward compatibility mode.

Also, note that this is hardly a substitute for server-side validation of what user is allowed to do within the OE (which ideally should automatically control what a user can do and I hope for that in eZ 4.2+), but stands a great transitional presentation-layer functionality that can be backed up with proper access control. Many projects will suffer if this is not in place...

24/06/2008 2:58 am (UTC)   Piotr Karaś   View entry   Digg!  digg it!   del.icio.us  del.icio.us

felix laate

› Attending the eZ Conference 2008

One sleepy morning I got up and went for my very first eZ Conference. My expectations were skyhigh as the Dash-8 slowly approached Torp airport. I rented a car and drove the last miles to Skien. After checking in to the hotel, I walked through the rain up the hill to Ibsenhuset where the conference [...]
23/06/2008 3:33 pm (UTC)   Felix Laate   View entry   Digg!  digg it!   del.icio.us  del.icio.us

derick rethans  eZ systems employee

› eZ Awards

Last Thursday, during the Open Nordic Conference 2008 eZ Systems handed out its annual awards again. For the eZ Components award, there were four nominees, which are all recognised for their support of the eZ Components project.

The nominees were Stefan Marr and Falko Menge: for the work on the upcoming Extended Reflection component, James Pic: for the work on the upcoming MVC additions, Andreas Schamberger: for contributions to the Template and Translation tie-in functionality, and Freddie Witherden: for the contribution of SVG font support in the Graph component.

This year's eZ Components award has been awarded to James Pic , congratulations!

23/06/2008 1:38 pm (UTC)   Derick Rethans   View entry   Digg!  digg it!   del.icio.us  del.icio.us

derick rethans  eZ systems employee

› PHP Vikinger 2008 Wrap-up

PHP Vikinger is over again. With about 35 attendees, I would think it was a great success. After opening the event, we figured out which topics people were interested in. After voting for the topics, we came up with a nice couple of topics. First we had a little discussion on QA and Testing, which Thomas Nuninnger moderated. I include my (raw) notes from this:

Selenium takes a long time to run tests, so Thomas only uses it for front end only, whereas phpunit is used for as much as possible backend code. Selenium apparently has some functionality for parallizing ( selenium grid), but there are some issues as well as you can not tell it to run specific tests parallel. WebDriver does exactly the same, except for running it in the same browser. But it's going away from actually using a real browser... which sorta defeats the point of Selenium. Thomas also mentions that sometimes a fixed value as recorded by the IDE is not good... but you can "fix" that yourself in the PHPUnit tests that Selenium can export. The IDE is getting better BTW. CruiseControl, phpUnderControl, phing (phing is not gnu make) - a port of Ant.

After this, we had a discussion about the deployment of web applications, where we discussed some different approaches such as "svn check-out", but also tools for doing so such as Capistrano.

Sebastian then explained a little bit about the PHP Object Model. We also tried to figure out a strange profiling issue in one of Zoë Slattery's applications with Xdebug, but we could not manage to figure out what it was just yet. The last talk before lunch was from Kore Nordmann about CouchDb.

After the pizza lunch provided by Klosterøya, we continued with presentations on Project Zero, by Ant Philips of IBM; the new lexer in PHP by Scott MacVicar and a talk by Sebastian Bergmann on the eZ Components' Workflow component. The last talk of the day was by Tobias Schlitt on database abstraction with eZ Components.

I will put the slides online at the PHP Vikinger website once I receive all of them.

23/06/2008 10:45 am (UTC)   Derick Rethans   View entry   Digg!  digg it!   del.icio.us  del.icio.us

damien pobel

› Racaille norvégienne :)

Merci Bård pour l'info. Thanks Bård for the information

Plus d'informations (sérieuses) sur la eZ Conference 2008 d'ici quelques jours...

22/06/2008 11:07 pm (UTC)   Damien Pobel   View entry   Digg!  digg it!   del.icio.us  del.icio.us

ez projects

› eZ XML Installer Version 0.1.2 now available

The second beta version of the eZ XML Installer has just been released.

Please see here for details.

Please go here to download and test this version.

20/06/2008 3:24 pm (UTC)   eZ Projects   View entry   Digg!  digg it!   del.icio.us  del.icio.us

ez systems north america  eZ systems employee

› Developer training in San Francisco, August 2008

eZ Partner Granite Horizon will be running eZ Publish Developer Basics training at the University of California, Berkeley from August 5 - 8. Note that this is not an Official eZ Training course, but it is based on eZ Systems material and is run by a certified eZ Publish developer.

19/06/2008 7:57 pm (UTC)   eZ Systems North America   View entry   Digg!  digg it!   del.icio.us  del.icio.us

sebastian bergmann  eZ systems employee

› eZ Components 2008.1 and ezcWorkflow 1.2

eZ Components

The eZ Components development team is happy to announce the eZ Components 2008.1 release. Starting from this version, eZ Components requires PHP 5.2.1.

In this release, there are three new components:

  • The Document component enables you to convert documents between different formats.
  • The Feed component parses and generates RSS1, RSS2 and ATOM feeds.
  • The new Search component provides a unified interface to different search engine back-ends, quite similar to what the Database and PersistentObject components provide for database access.

The eZ Components 2008.1 release also comes with a new version of my workflow engine, Workflow 1.2. Here are the highlights of this update:

A new tie-in component, WorkflowSignalSlotTiein, has been added to allow integration between the Workflow and SignalSlot components.

17/06/2008 10:40 am (UTC)   Sebastian Bergmann   View entry   Digg!  digg it!   del.icio.us  del.icio.us

maxime thomas

› D-2

Exciting ! Only two days before eZConf and the eZAwards !

So a year is gone since last time I trampled the Norvegian floor and I'm ready to go there again. Why ? Simply for the best :

  1. The bigger CMS conference in the world
  2. The eZAward after party
  3. Salmon
  4. Grenland

As a nominee, I would like to wish a good luck to everybody.

However, I've got bad news for everyone, it won't be a pleasure like last year. It seems that we will have bad weather suring the conf but it will be better just after.

And now, a little trick in order to make accept eZFlow by women.

See you in Skien !

17/06/2008 8:45 am (UTC)   Maxime Thomas   View entry   Digg!  digg it!   del.icio.us  del.icio.us

derick rethans  eZ systems employee

› Namespaces in PHP

During Stefan Priebsch' session at the Dutch PHP Conference on PHP 5.3 and PHP 6 - A look ahead a discussion popped up about PHP's namespace support. One of the things that came up is the conflicts that can arise with internal classes.

Take for example this code:

<?php
use PEAR::Date::Interval as Interval;
?>

In PHP 5.3 this would alias the class Interval in the namespace PEAR::Date to the class Interval. For now, this code would work just fine. However, if PHP would introduce a class "Interval" at some point in the future (and PHP can do this as it owns the global namespace) then the above code would suddenly stop failing. So in order to use namespaces properly, you always need to have at least two elements left, like:

<?php
use PEAR::Date as pd;
$interval = new pd::Interval;
?>

You need to make sure of course that the short name that you pick is something that does not sound to much like a class name otherwise you'll have exactly the same issue. It's not very likely that PHP will introduce a class pd though.

15/06/2008 1:01 pm (UTC)   Derick Rethans   View entry   Digg!  digg it!   del.icio.us  del.icio.us

eZ publish™ copyright © 1999-2005 eZ systems as