Showing posts with label papaya CMS. Show all posts
Showing posts with label papaya CMS. Show all posts

2011-07-22

Administration Themes

The administration themes were a request from a customer. He does own development with developer, stage and production servers and wanted a subtle way to see which server he was currently changing.

A theme consists of a color set, background images, the icon and a progress animation. At the moment 7 colors are available in trunk. Because of the favorite icons it is easier to spot the right tabs, too.


2011-07-13

Papaya Callbacks

papaya CMS got a new class PapayaObjectCallbacks recently. The class can be used to define and handle callbacks for other classes and relies heavily on the magic methods. It addresses several problems.
  1. Code duplication if you have several callbacks in one class
  2. Validation before you can use the callback
  3. Easy to use, self speaking API for callbacks

PapayaObjectCallbacks is defined as a sub object with lazy initialization. An array is used to define the callbacks functions and the default return value. If you have a complex/large list of callback functions, I suggest to define a new class that extends PapayaObjectCallbacks. With a special class you can define the dynamic properties/methods using PHPDoc comments.

public function callbacks(PapayaObjectCallbacks $callbacks = NULL) {
  if (isset($callbacks)) {
    $this->_callbacks = $callbacks;
  } elseif (is_null($this->_callbacks)) {
    $this->_callbacks = new PapayaObjectCallbacks(
      array(
        'onEventOne' => TRUE,
        'onEventTwo' => 'default'
      )
    );
  }
  return $this->_callbacks;
}


To call the function is really simple. Just do it!

$result = $this->callbacks()->onEventOne($argument);

If no function was assigned to the callback the defined default will be returned. Otherwise the assigned function is called and its return value will be used. So no validation of the assignment is needed.

The user (of your class with the callbacks) can assign the callback function, now.

$someObject->callbacks()->onEventOne = array($this, 'someCallbackHandler');

In PHP equal or greater 5.3 an anonymous function is possible:

$someObject->callbacks()->onEventOne = function($context, $argumentOne) { ... };

The first argument of the callback is always a context object. The reason for this is, that we still have to be PHP 5.2 compatible, so we can not use the PHP syntax for it. In addition you can edit the context without a local variable. By default this is an instance of stdClass but you can assign any object.

$someObject->callbacks()->onEventOne->context->someProperty = 'some value';

If you like to see the implementation, you can find it in the papaya SVN.

2009-05-08

papaya CMS Nightly Builds

You can now download nightly builds from the papaya cms website. They are uploaded every night and include the system, base and free modules, the new default-xhtml template set and the matching theme.

2009-02-05

Multi Language XSLT: Language Texts

Currently I am refactoring the default templates for the upcoming papaya CMS 5 release. I will show you some of the concepts in this blog. As you probably know papaya CMS uses XSLT for its templates, which is imho a perfect choice for web applications.

You get a strict split between application logic and layout. But XSLT can do more. How about translating layout texts, like the caption of a more link, format numbers and dates? Sounds nice, doesn't it?

In the first step you need to separate the layouts texts from the xslt and create language files for easier management.

The template for this is quite small:

<xsl:template name="language-text">
  <xsl:param name="text"></xsl:param>
  <xsl:choose>
    <xsl:when
      test="$LANGUAGE_TEXTS_CURRENT/text[@ident = $text]">
      <xsl:value-of
        select="$LANGUAGE_TEXTS_CURRENT/text[@ident = $text]"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$text"/>
    <xsl:otherwise>    
  </xsl:choose>
</xsl:template>

This will check for an element text in the variable $LANGUAGE_TEXTS_CURRENT with an attribute ident that has the same value like the parameter $text and output it's content.

To fill up the variable, create a xml file with your texts.

<texts>
  <text ident="SAMPLE">Sample text</text>
</texts>

At the top of the XSL file define a global parameter and load a xml file into it. The Xpath function document() loads XML data from an URI. By default the URI is relative to the current xsl file.

<xsl:param name="LANGUAGE_TEXTS_CURRENT"
  select="document('./de-DE.xml')/texts"/>

Of course this whould be only a single fixed language file. So you have to use a variable for the file name. Xpath concat() supports a dynamic count of parameters - no need for nesting.

<xsl:param name="LANGUAGE_TEXTS_CURRENT"
  select="document(concat('./', $PAGE_LANGUAGE, '.xml'))/texts"/>

Now you can call the template to get the language specific text.

<xsl:call-template name="language-text">
  <xsl:with-param name="text">SAMPLE</text>
</xsl:call-template>

This is still a little noisy, but in standard XSLT you can not help it. However if your processor supports the EXSLT extension you can. With EXSLT you can convert a template into a function. The result whould look like this:

<xsl:value-of select="language:text('SAMPLE')" />

Less source and easier to read. You could use it in an output tag, too.

<img src="sample.png" alt="{language:text('SAMPLE')}" />

The PHP 5 ext/xsl using the libxslt library supports EXSLT. To convert the template to a function you change the declaration from "xsl:template" to "func:function" after you did import the EXSLT function namespace:

<func:function name="language:text">
  <xsl:param name="text"/>
  <func:result>
    <xsl:choose>
      <xsl:when
        test="$LANGUAGE_TEXTS_CURRENT/text[@ident = $text]">
        <xsl:value-of
          select="$LANGUAGE_TEXTS_CURRENT/text[@ident = $text]"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      <xsl:otherwise>    
    </xsl:choose>
  </func:result>
</func:function>

Here's still one little problem, if you haven't translated the language xml file to the current language or you missed a phrase the result is the text identifier. It whould be nice to fall back to a default language. So declare an additional parameter and add a condition to the template.

<xsl:param name="LANGUAGE_TEXTS_FALLBACK"
  select="document('./en-US.xml')/texts"/>
<func:function name="language:text">
  <xsl:param name="text"/>
  <func:result>
    <xsl:choose>
      <xsl:when
        test="$LANGUAGE_TEXTS_CURRENT/text[@ident = $text]">
        <xsl:value-of
          select="$LANGUAGE_TEXTS_CURRENT/text[@ident = $text]"/>
      </xsl:when>
      <xsl:when
        test="$LANGUAGE_TEXTS_FALLBACK/text[@ident = $text]">
        <xsl:value-of
          select="$LANGUAGE_TEXTS_FALLBACK/text[@ident = $text]"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      <xsl:otherwise>    
    </xsl:choose>
  </func:result>
</func:function>

You can extend this idea and have default and project specific language files.

Have fun experimenting.

2009-01-13

Papaya SVN Hook

Some slides from a PHP usergroup talk about our svn pre commit hook.

2008-03-31

Database check

The module manager can now check all database tables for changes. The result is saved to the session. Each time you look at a table it gets updated.



This works only with Javascript for now.

2008-01-17

Papaya Tips

Alexander Nichau posted some nice tips about the new papaya CMS 5 on his webpage (German). The latest tip is an Ant-Script for Eclipse PDT to update your production server.

2007-12-02

papaya 5 RC1

papaya 5 RC1 package had just got uploaded to the webserver. A beta of the German manual can be found here. The RC1 still uses FCKEditor by default. You can activate TinyMCE in the conf.inc.php:
define('PAPAYA_USE_RICHTEXT_EDITOR', 'tinymce');

2007-11-27

New Backend: Overview page, toolbars and new icons

You may have noticed that the screenshots in the blog posts show a new papaya CMS backend. The old look was a little dark and cramped. We decided to group the buttons of the main menu to add a little context.

The applications menubar is now one of these groups. Each user can add up to 5 individual application links to the button group (The limit is an option). The last button shows all applications and allows to add/remove buttons from the button group.


The overview page shows tasks, messages and page informations for the current user. The amount of items in each list are user options.

The icons in the new interface are based on the Tango Icon Theme. Some are copied, some are new, some are modified (got emblems). The flags are the FamFamFam Flag Icons created by Mark James. He created another great set of icons, too. But Silk has only 16x16 bitmaps. For papaya we need larger sizes, too. So we had to create our own. But you will recognice some of them if you know Silk.

We hope you will like it.

2007-11-15

Searchable Listboxes

The backend got searchable selects. It's pure javascript - you will not see any hint of it without it.


The javascript adds a little input field just before the select box. You input a text and the select will only show items that matches your input. All larger selects (with optgroups) got the new feature.

2007-11-14

papaya CMS in the iX 12/07

The cover topic of the december issue of the iX (a german computer magazine) are content managment systems. They tested 5 PHP bases CMS including papaya CMS 4. The text about papaya CMS is really positive. :-)

2007-10-23

Browser Compatibility 3 - Lynx

We already had support for the most major browsers, but one was still missing: Lynx.


Cool, isn't it?

2007-10-12

Browser Compatibility 2

Have a look at papaya CMS 5 in Opera 9.


Of course IE7 is supported, too:

2007-10-11

Browser Compatibility

The Screenshots here in the blog show the new papaya CMS 5 Backend in Firefox 2. But it works in other Browsers, too.

Some users may still have IE 6. He does not support all of the eye candy stuff but it works:


Of course we do not look backwards only. Here is Safari 3 on Windows:

2007-10-10

Several Websites with one installation

We just implemented a new feature into papaya CMS 5. It has now a domain handling. Just direct several domains to one papaya CMS installation. You can now set up how each domain is handled in the papaya Backend. Wildcards for subdomains are possible.


Here are the 5 options.

"default" - The domain handling does nothing, default options are used
"domain" - Redirects to the requested page on another domain
"page" - Redirects to a specified page on another domain
"language" - Redirects to a language if the main page is called without a language (e.g. / or /index.html to index.de.html)
"tree" - Limits the domain to a subtree of the pages

The last option "tree" allows you to have several websites with one papaya CMS installation. They will share the users and other data but are limited to one part of the pages.

2007-09-28

Upload Files

Finally we got an upload progress bar in the new media database using the uploadprogress extension. Looks nice, doesn't it?

The Javascript extends the used form with an onsubmit event to track the progress. So the upload still works without JS.

2007-09-03

Database debugging in Firebug

After I got the php errors in Firebug I still had some ugly debug outputs in my pages - the database errors and explains. Some lines later I got new data in Firebug.


Thanks Firebug - Web Development Evolved!

2007-08-31

PHP errors and debugs in Firebug

Do you know Firebug? It is perfect for debugging webpages. I got the idea to use it for my php error and debug outputs as well. The error handler / debug functions in papaya CMS can now use the Firebug console.log() function.


Nice detail: It works in other browsers using Firebug Lite.

Formatting a select


The list of page and box modules grows and grows. Now we added some style to keep it usable. This is pure html+css, without any javascript. It uses the optgroup tag.

If the list grows to large, we have to rethink the form concept.
x