Skip to content

Instantly share code, notes, and snippets.

View dpobel's full-sized avatar

Damien Pobel dpobel

View GitHub Profile
@dpobel
dpobel / location.php
Created June 21, 2011 12:33
Avoid repository call in objects (ie lazy load)
<?php
namespace ezp\Content;
class Location extends Base implements \ezp\DomainObjectInterface
{
// lots of stuff before
/**
* Parent Location of the Location or a Proxy object representing it
<?php
require_once 'extension/api/testsBootstrap.php';
try
{
$handler = new \ezp\Persistence\Storage\Legacy\Handler( array( 'dsn' => 'mysql://muser:mpasswd@localhost/mdatabase' ) ); // force the use of an eZ Publish database
$sc = new ezp\Base\ServiceContainer( \ezp\Base\Configuration::getInstance( 'service' )->getAll(), array( '@persistence_handler' => $handler ) );
$repository = $sc->getRepository();
<?php
require_once 'extension/api/testsBootstrap.php';
try
{
$handler = new \ezp\Persistence\Storage\Legacy\Handler( array( 'dsn' => 'mysql://muser:mpasswd@localhost/mdatabase' ) );
$sc = new ezp\Base\ServiceContainer( \ezp\Base\Configuration::getInstance( 'service' )->getAll(), array( '@persistence_handler' => $handler ) );
$repository = $sc->getRepository();
<?php
require_once 'extension/api/testsBootstrap.php';
try
{
$handler = new \ezp\Persistence\Storage\Legacy\Handler( array( 'dsn' => 'mysql://muser:mpasswd@localhost/mdatabase' ) );
$sc = new ezp\Base\ServiceContainer( \ezp\Base\Configuration::getInstance( 'service' )->getAll(), array( '@persistence_handler' => $handler ) );
$repository = $sc->getRepository();
@dpobel
dpobel / skeleton.php
Created December 23, 2011 12:47
Test skeleton
<?php
// the API should be in extension/api
// change the login and the password of the databse below
require_once 'extension/api/bootstrap.php';
try
{
$handler = new \ezp\Persistence\Storage\Legacy\Handler( array( 'dsn' => 'mysql://muser:mpasswd@localhost/mdatabase' ) );
@dpobel
dpobel / example.txt
Created March 14, 2012 08:45
Y.eZ.FlyOut how to
Example of how to use Y.eZ.FlyOut, here we're gonna show the debug output after a scroll from the user.
1. First enable the site.ini/[DebugSettings]/DebugOutput
2. Add the test_flyout.js and test_flyout.css files in design.ini, for instance in extension/ezdemodesign/settings/design.ini.append.php this gives:
<?php /*
[ExtensionSettings]
DesignExtensions[]=ezdemodesign
@dpobel
dpobel / decimal.php
Created March 27, 2012 12:53
Decimal test in Oracle
<?php
$db = eZDB::instance();
$cli = eZCLI::instance();
$cli->output( 'DBCharset ' . $db->Charset );
$cli->output( 'NLS_NUMERIC_CHARACTERS in nls_session_parameters' );
$cli->output( print_r( $db->arrayQuery( "select * from nls_session_parameters where parameter='NLS_NUMERIC_CHARACTERS'" ), true ) );
ezautosave certification questions:
What does the ezautosave extension in its default configuration ?
1. Automatically send for publishing a draft at a given date
2. Automatically store a currently edited draft at fixed interval
3. Automatically backup your database at fixed interval
4. Automatically store a currently edited draft when the user change something in the content edit form
5. Automatically discard a too old draft to save space on your system
[ May 11 2012 14:37:42 ] [127.0.0.1] eZPostgreSQLDB:
Error: error executing query: SELECT
count( DISTINCT ezcontentobject_tree.node_id ) as count
FROM
ezcontentobject_tree
INNER JOIN ezcontentobject
INNER JOIN ezcontentclass
INNER JOIN ezcontentobject_name
@dpobel
dpobel / list.php
Created June 1, 2012 09:23
Version and language list of a content object
<?php
$object = eZContentObject::fetch( 98 );
foreach ( $object->attribute( 'versions' ) as $version )
{
$cli->output( 'Version ' . $version->attribute( 'version' ) );
$languages = eZContentLanguage::decodeLanguageMask( $version->attribute( 'language_mask' ) );