Login +

Release Notes / 1.0.8

Introduction

SillySmart 1.0.8 introduces 66 new features & bug fixes.

To browse the full list, check the roadmap :

http://redmine.sillysmart.org/versions/49

Controller

On an action, a Statics Controller or a Component, we now have access to simplified references of the following objects:

$this->_http;
$this->_session;
$this->_lang;
$this->_cookie;
$this->_security;

Model

Foreign Keys

- If the storage engine is innoDB and integrity constraints (FK) were set in the engine, the FK at the Model are automatically created by taking the PK of the related table as descriptive text.

- Each Model with FK now has a function name the related table to facilitate access to third-party data.

For example, if a Model news has a FK to user, the following simple call to retrieve the data from the user associated:

$news->user()->__get('user_email');
public function user()
{
    $this->_generic->useModel("User","main");
    $object = new Main_User();
    $object->getModel($this->__user_id);
    return $object;
}

Specific type "Address"

The specific type "Address" was added. It offers GMaps autocompletion to facilitate the entry of an address.

Specific type "Position"

The specific type "Position" was added. It offers pre-fill the field after the last known position when adding and shifting any position adjacent to the modification.

Delete

When deleting a Model by calling the delete() function, if the recordset contains specific types "File" or "FileImg" physical files are first moved to the folder /Public/Files/__Uploads/__Deprecated/tableName/

getColumns()

New generic function getColumns() to retrieve an array to a single dimension containing only the names of table columns.

Similar to:

array_keys($object->getParams())

getParams()

Adding an optional parameter to the function getParams () to retrieve automatically all the keys / values ​​of related tables or of particular tables.

$this->_generic->useModel("News");
$news = new Main_News();
if ($news->getModel(118) === true)
{
    // News keys/values only
    var_dump($news->getParams());
    // News & user keys/values
    var_dump($news->getParams(array("user")));
    // News & user & all others tables linked
    var_dump($news->getParams(true));
}

Default values

All native types Date (date, time, datetime, timestamp, year), specific types uniqid and IP Address now have default values ​​in instantiating the object. To set an IP, a token or a date, no more need to call the respective setter. Date types have the current date, the uniqid generates a token and IP Address take current IP address of the user.

toXML

If you want to easily getting the XML of the current recordset binded by the getModel($id) function, you can call the toXML() function:

if ($news->getModel(118) === true)
    $xml = $news->toXML($xml);

Will produce:

<View>
    <news>
        <news_id><![CDATA[118]]></news_id>
        <pk_lang><![CDATA[en]]></pk_lang>
        <news_title><![CDATA[  fake_news_title ]]></news_title>
        <news_content><![CDATA[<p>news content en</p>]]></news_content>
        <news_excerpt><![CDATA[<p>Fake excerpt</p>]]></news_excerpt>
        <news_more><![CDATA[<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>]]></news_more>
        <news_date><![CDATA[2012-06-08 17:45:32]]></news_date>
        <news_published><![CDATA[true]]></news_published>
        <news_photo><![CDATA[news/new_york_4_640345cff7.jpg]]></news_photo>
        <news_url><![CDATA[http://www.sillysmart.org]]></news_url>
        <article_category_id><![CDATA[1]]></article_category_id>
        <user_id><![CDATA[4]]></user_id>
    </news>
</View>

  • 1st parameter $xml is the XML modified by the current action
  • 2nd parameter $options allows to specify transformations on some columns
$options = array("news_excerpt" => array("php:strip_tags",
                                         "SLS_String:trimStringToLength:100"),
                 "news_date"    => array("SLS_Date:getDate:MONTH_LITTERAL",
                                         "php:ucwords"),
                 "news_photo"   => "SLS_String:getUrlFileImg:_0",
                 "news_title"   => "php:trim");

Each column can undergo many transformations as necessary (in the order they are
declared).

The formalism of the transformation can be of two types:
- Prefix "php": using a native function php (no class)
- Name of the class: using a static function of the class of your choice.

In both cases, the following parameters correspond to the function name and all the parameters of the latter.
If the function does not exist or it is called with an insufficient number of parameters, it raises an error.
If the function is called with too many parameters, it raises a warning.

  • 3rd parameter $fks can specify whether you want to retrieve related tables. These possible values ​​are exactly the same as for the function getParams(): default false to any joint, true to all related tables or array wanted tables.
$fks = array('user');
  • 4th parameter $nodeName can specify the name by hand to form the XML node.
    The default is the table name to be used.
$nodeName = 'my_news';

With these parameters filled, the resulting XMLshould look like:

<View>
    <my_news>
        <news_id><![CDATA[118]]></news_id>
        <pk_lang><![CDATA[en]]></pk_lang>
        <news_title><![CDATA[fake_news_title]]></news_title>
        <news_content><![CDATA[<p>news content en</p>]]></news_content>
        <news_excerpt><![CDATA[Fake excerpt]]></news_excerpt>
        <news_more><![CDATA[<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>]]></news_more>
        <news_date><![CDATA[08 June 2012]]></news_date>
        <news_published><![CDATA[true]]></news_published>
        <news_photo_original><![CDATA[http://www.sillysmart.org/Public/Files/news/new_york_4_640345cff7.jpg]]></news_photo_original>
        <news_photo_0><![CDATA[http://www.sillysmart.org/Public/Files/news/new_york_4_640345cff7_0.jpg]]></news_photo_0>
        <news_url><![CDATA[http://www.sillysmart.org]]></news_url>
        <article_category_id><![CDATA[1]]></article_category_id>
        <user_id><![CDATA[4]]></user_id>
        <user_email><![CDATA[guillaume.chatton@wandi.fr]]></user_email>           
        <user_name><![CDATA[Chatton]]></user_name>
        <user_firstname><![CDATA[Guillaume]]></user_firstname>
        <user_date><![CDATA[2011-11-23 17:02:34]]></user_date>
    </my_news>
</View>

pdoToXml

If you want to easily getting the XML for a PDO collection of recordsets (obtained by the call to the function searchModels() eg), you can call the pdoToXML() function:

$all_news = $news->searchModels("news",array(),array(0 => array("column" => "user_id",
                                                                "value"  => 4,
                                                                "mode"   => "equal")));
$xml = $news->pdoToXML($xml, $all_news);

Will produce:

<View>
    <newss>
        <news>
            <news_id><![CDATA[4]]></news_id>
            <pk_lang><![CDATA[en]]></pk_lang>
            <news_title><![CDATA[Test]]></news_title>
            <news_content><![CDATA[<p>test</p>]]></news_content>
            <news_excerpt><![CDATA[<p>excerpt</p>]]></news_excerpt>
            <news_more><![CDATA[]]></news_more>
            <news_date><![CDATA[2011-08-23 18:40:24]]></news_date>
            <news_published><![CDATA[true]]></news_published>
            <news_photo><![CDATA[news/nyc_8b08c5343f.jpg]]></news_photo>
            <news_url><![CDATA[]]></news_url>
            <article_category_id><![CDATA[4]]></article_category_id>
            <user_id><![CDATA[4]]></user_id>
        </news>
        <news>
            <news_id><![CDATA[118]]></news_id>
            <pk_lang><![CDATA[en]]></pk_lang>
            <news_title><![CDATA[  fake_news_title ]]></news_title>
            <news_content><![CDATA[<p>news content en</p>]]></news_content>
            <news_excerpt><![CDATA[<p>Fake excerpt</p>]]></news_excerpt>
            <news_more><![CDATA[<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>]]></news_more>
            <news_date><![CDATA[2012-06-08 17:45:32]]></news_date>
            <news_published><![CDATA[true]]></news_published>
            <news_photo><![CDATA[news/new_york_4_640345cff7.jpg]]></news_photo>
            <news_url><![CDATA[http://www.sillysmart.org]]></news_url>
            <article_category_id><![CDATA[1]]></article_category_id>
            <user_id><![CDATA[4]]></user_id>
        </news>
    </newss>
</View>
  • 1st parameter $xml is the XML modified by the current action
  • 2nd parameter $recordsets is the array of PDO recordsets (often returned by searchModels() or SLS_SQL3::select())
  • 3rd parameter $options allows to specify transformations on some columns in the same way than toXML() function.
  • 4th parameter $nodeNames can specify the name by hand to form the XML node.
    The default name is 'tablenames/tablename'.

View

Doctype

Multiple doctypes support. When creating a template, you can choose the doctype of your choice.

Dtd

Added support for parsing HTML. SLS_Dtd4 can now be used to parse the final HTML.

To do this, simply use the following pattern:

||| sls:method:param1:param2|||

Where method is a function of the class SLS_Dtd4 and all the parameters of the function.

If the function does not exist or it is called with an insufficient number of parameters, it raises an error.

If the function is called with too many parameters, it raises a warning.

For Multilingualism, it suffices now to call the function lang created for the occasion:

||| sls:lang:sls_monday|||

This eliminates the call-template = 'displaylang' ... and you can perform a translation to an HTML attribute without having to create a <xsl:attribute...

Back-Office

Action email

Creating a new action "Email" which allows, directly on the listing of a Model (if there is a specific type "email" on one of the columns) to check at recordsets N, choose the template email of your choice and send an email to all recordsets including dynamic information from their table.

We can also send an email from the edition of the Model:

Validation

The Back Office is subject to wide JavaScript validation in real time.

Types, specific types and filters are applied and tested live.

Bearers

Data bearers now operate similarly to FK with multiple autocomplete.

Redirect

On the actions of adding and editing, you can now choose the redirect.

And

The choice of redirection is preserved in session in order not have to reselect every interaction with forms.

cKeditor

On each entity, we can now choose specific columns on which you want to bind a ckeditor.

Shadowbox

Shadowbox is used natively on the Back Office to perform the following tasks:

  • Quick Add on action List

  • Quick Edit on action List

  • Preview specific type url on action Edit

  • Zoom specific type file img on action Edit

  • Quick Add on FK & Bearers

SLS_Bo

Deployment

To facilitate the production deployment, a tool now allows to create configuration files "_prod.xml" in batch or 1 by 1.

Monitoring

The monitoring logs older than 2 months are automatically deleted.

Privileges

The admin privileges of User Bo may be highly specific to any action.

Models

On Models listing, one can see directly if the Models are up to date or obsolete.

Opportunity to update them directly without enter model specifications.

Compressor

New tool can compress/uncompress batch all JavaScript and CSS of application to facilitate production deployment.

FK

Added ability to edit FK on Model.

Emails

Ability to manage different email templates.

IE6

In Javascript/AJAX configurations, you can enable/disable the automatic display of a toolbar for IE6 users.

Tools

Creating a Developer Toolbar to facilitate debugging by the developer.
This Toolbar allows data access http, session, cookie, XML and quick links to all sections of Bo Client.

SLS_Email5

The constructor now tolerates no parameters to automatically fetch XML configs in the connection information to the SMTP server.

If these configs are not found, the PHP native function mail() is used instead for sending.

A simple instantiation just have to send an email:

$email = new SLS_Email() ;

Various

Rewrite

SillySmart now works without Apache's mod_rewrite enabled. It uses standard writing:

http://vhost.domain.tld/index.php?mod=Controller&smod=Action¶m1=value1&...

All routing functions (getFullPath(), forward(), goDirectTo()) format the different urls following this directive.

Short tags

SillySmart now works without the support of short_tags.

Arborescence

All XML tree information has been reviewed and the data were homogenized.

At root node, we only find three main nodes:

  • //Statics for Statics Controller
  • //Components for Components
  • //View for current Action

Related :

References

  1. SLS_String - Tool SLS_String - String Treatment
  2. SLS_Date - Tool SLS_Date - Dates Handling
  3. SLS_SQL - SQL_Sql class - SQL Mother
  4. SLS_Dtd - Tool SLS_Dtd - Perform a XSL -> Php transformation
  5. SLS_Email - Send mail from a distant SMTP