Archive for March, 2010

Concrete5 errors

Wednesday, March 31st, 2010

Fatal error: Class 'CollectionAttributeKey' not found in (…)/concrete/models/collection.php on line 183

This class is defined in concrete5.3.3.1\concrete\models\attribute\categories\collection.php

The problem is easily resolved by loading the appropriate model in your code:

Loader::model('attribute/categories/collection');

Wir drehen uns im Kreis …

Thursday, March 25th, 2010

Ist das nicht verrückt? Ein Mann versucht in den Kühlschrank zu krabbeln weil er zu warm angezogen ist… anstelle einfach seinen Pulli auszuziehen.

Doch was machen wir anderes im täglichen (Gefühls)Leben?

1130935 heart rules - no loveWas ist beispielsweise Liebeskummer? Ist da nicht täglich, stündlich der Wunsch, die Gefühle eines anderen Menschen zu ändern, damit die eigenen Gefühle (Traurigkeit, Deprimiertheit, Verzweiflung …) geändert werden?

Buddha sprach vor vielen hundert Jahren vom Nicht-anhaften. Krishna unterwies Arjuna auf dem Streitfeld von Kurukshetra in genau den gleichen Dingen (… do work for work's sake …). Die Lösung ist also bekannt, wird jedoch nicht angewendet: Menschen sind Meister in der hohen Kunst des Augenverschließens – bzw. sie werden von ihren Gefühlen gemeistert und zum Augenverschließen bewegt.

Wie oft, schien es, brauchte man nur noch dieses eine Ding, diese eine Beziehung, diesen einen neuen Auftrag, und danach würde sich die Welt ändern. Die Welt, die schon seit 14 Milliarden Jahren existiert. Diese Welt zumindest.

Nun, diese Erfahrungen haben zumindest etwas gutes: man macht sie einmal, zweimal, immer wieder … bis man einfach keine Lust mehr darauf hat.

Gentlemen, der Punkt ist bei mir schon seit längerem erreicht. Jetzt mache ich es offiziell: ich habe keine Lust mehr darauf, mich von meinen Gefühlen regieren zu lassen, und "natürlich" zu reagieren. Auf Beleidigungen, Nicht-Zurückgeliebt-Werden, Ungerechtigkeiten, Drohungen, Schmähungen, Enttäuschungen uvm.

Die Zeit die ich in diesem Zustand, der sich Leben nennt, verbringen darf, schreitet unerbittlich fort. Immer weiter, bis zum Tod. Der Endpunkt der einen genauso überrascht wie einstmals das Physikum oder die Scheinfreiheit. Und es gibt noch viel zu tun! Viel zu sehen, viel zu entdecken!

Man mag einwenden, dass dieses Gefühl der Neugier auf das Leben AUCH ein Gefühl ist, und ich mich ebenfalls davon steuern lasse. Guter Einwand, schlechtes Gegenargument: es ist das harmloseste und produktivste Gefühl. Ich mache mich am wenigsten von der Welt abhängig. Wenn es in einer Richtung nichts mehr weiter zu entdecken gibt, breche ich meine Zelte ab und reite in den Sonnenuntergang.

1269371 bay at dusk

Images: sxc.hu (timobalk & plrang. Thanks, guys!)

Aurubis

Wednesday, March 24th, 2010

Aurubis AG ist der drittgrößte Kupferproduzent weltweit und der größte Kupferrecycler.

Vorher hieß die Firma Norddeutsche Affinerie AG. Die Aktien sind in der Mehrzahl im Streubesitz.

Indus

Wednesday, March 24th, 2010

Indus Holding (www.indus.de) ist eine Firma die Beteiligungen an anderen Firmen hält:

  • Bauindustrie
  • Maschinenbau
  • Automobilindustrie
  • Konsumgüter
  • Sonstiges

Der Konzern hatte 2008 einen Umsatz von 928,4 Mio. € insgesamt, davon ca. 2/3 im Inland und 1/3 im Ausland.

Der Jahresüberschuss war 2008 rückgängig auf 27,9 Mln € von vorher 49,9 Mio € 2007.

DIe Zahl der Mitarbeiter ist stetig wachsend auf zuletzt 5.862 2008.

Concrete5 :: interacting with the database

Wednesday, March 24th, 2010

The C5 API has a class Database in the core package (libraries/database.php). Alas, this is not the documentation we're looking for (we're looking for query, etc. methods, which are not present there).

Actually the methods used come directly from the included ADODB librarary. You can download a documentation here.

Usage:

//Load the Database Layer.
$db = Loader::db();
//quote the string we'll be inserting (use get_magic_quotes_gpc() as second parameter to avoid double escaping!)
$source = $db->qstr($source, get_magic_quotes_gpc());
$content = $db->qstr($content);
$sql = "insert into IdImportWizardSources (source, content) ";
$sql .= "values ($source,$content)";
if ($db->Execute($sql)===false) {
//error handling
echo 'error inserting: ' .$db->ErrorMsg();
}

Concrete5 and db.xml

Tuesday, March 23rd, 2010

How does the installation of a db.xml file in the package root directory work?

I need to create tables for my Dashboard Application (Import Wizard), which will not be used by blocks – the Import Wizard does not contain any blocks.

In the Concrete5 forum, a function installDB was mentioned. It's defined in the InstallController class like this:

protected function installDB() {

$installDirectory = $this->installData['DIR_BASE_CORE'] . '/config';
$file = $installDirectory . '/db.xml';
if (!file_exists($file)) {
throw new Exception(t('Unable to locate database import file.'));
}

$db = Loader::db();
$db->ensureEncoding();
$err = Package::installDB($file);

}

It ensures the db.xml file exists and after some other setup steps and check finally calls Package::installDB (Package is a model):

public static function installDB($xmlFile) {

if (!file_exists($xmlFile)) {
return false;
}

// currently this is just done from xml

$db = Loader::db();

// this sucks – but adodb generates errors at the beginning because it attempts
// to find a table that doesn't exist!

$handler = $db->IgnoreErrors();
if ($db->getDebug() == false) {
ob_start();
}

$schema = $db->getADOSChema();
$sql = $schema->ParseSchema($xmlFile);

$db->IgnoreErrors($handler);

if (!$sql) {
$result->message = $db->ErrorMsg();
return $result;
}

$r = $schema->ExecuteSchema();

if ($db->getDebug() == false) {
$dbLayerErrorMessage = ob_get_contents();
ob_end_clean();
}

$result = new stdClass;
$result->result = false;

if ($dbLayerErrorMessage != ") {
$result->message = $dbLayerErrorMessage;
return $result;
} if (!$r) {
$result->message = $db->ErrorMsg();
return $result;
}

$result->result = true;

$db->CacheFlush();
return $result;

}

The Code is Copyright by Concrete5 Team.

It looks like I could just drop a db.xml file in my package directory and it will be installed. But how should I name my table?

By convention, there's different prefixes:

  • atX (atAddress, atBoolean, atDateTime) = attribute types
  • btX (btForm, btFlashContent, btSearch) = block types

But there's none for helper tables, to be used just for the Dashboard wizard.

Here's a link to the AdoDB XML Schemas (AXMLS) (the language db.xml is written in). I came up with the following:

<?xml version="1.0"?>
<schema version="0.3">
<table name="IdImportWizardSources">
<field name="ID" type="I">
<key />
<unsigned />
<autoincrement />
</field>
<field name="source" type="X" />
<field name="retrieved" type="T">
<deftimestamp />
</field>
<field name="content" type="B" />

</table>
</schema>

Here I define a new table named IdImportWizardSources (Id for IdeaDay), and several field values using keywords.

Notable is the retrieved field which is automatically set to the current timestamp (deftimestamp). content has a type of BLOB which should be able to store up to 4 GB with MySQL longblob type – unfortunately the amount you can store at once also depends on your MySQL max_packet_size. (Which is usually set to around 16 MB).

The table is imported and set up automatically by Concrete, without a single line o'code.

motifake.com

Sunday, March 21st, 2010

Some cool pictures from motifake.com I want to share:

a-l-c-o-h-o-l-i-s-m-drunk-demotivational-poster-1268967040

culos-march-challenge-cartoon-better-watch-your-ass-demotivational-poster-1269004544

for-some-unknown-reason-fakery-demotivational-poster-1261762028

 

greybeards-march-challenge-cartoons-demotivational-poster-1269002832

I especially like this leather dress effect:

leather-dress-effect-demotivational-poster-1255541562

situations-vacant-demotivational-poster-1255374937

 

wet-dreams-happy-st-patricks-day-motifake-demotivational-poster-1268843547

Have a nice day! :-)

Russian and Chinese editing with Concrete 5

Sunday, March 21st, 2010

concrete multi language

It is not enough to add a Character set to your Template // or store it in UTF-8 without BOM (so the headers attached by PHP won't break).

If TinyMCE only displays gibberish instead of the Russian / Chinese / … text you entered in edit mode, you should edit your .htaccess (located in the root directory of your site) and add the following:

AddDefaultCharset UTF-8

Optionally, while you're at it, you can enable caching for your site:

#Speed UP!
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 years"
ExpiresByType text/html "access plus 30 seconds"
</IfModule>

Cat and dog of the day

Sunday, March 21st, 2010

!!002501cac5e4$96caaa00$4100a8c0@attit

OK, here's a dog to go with the cat. We already had a wolf, so a dog's OK, too. Actually I do like dogs. I just like to put an act on of adoring cats :-)

!!002601cac5e4$96ccf3f0$4100a8c0@attit

FormHelper select

Friday, March 19th, 2010

Not understanding the Concrete 5 API comment on the select function of the Form Helper, I looked into the source:

/**
* Renders a select field. First argument is the name of the field. Second is an associative array of key => display. Second argument is either the value of the field to be selected (and if it's blank we check post) or a misc. array of fields
* @param string $key
* @return $html
*/
public function select($key, $values, $valueOrArray = false, $miscFields = array())

Select builds a SELECT Dopdown with OPTIONS. That much I already understood from the API.

Here's my explanation of the parameters passed in to select:

  • $key: the name of the element to be created.
  • $values: an array of options, stored as $k=>$value. Used like this:
    '<option value="' . $k . '" ' . $selected . '>' . $value . '</option>';
  • $valueOrArray: this can either be set to the default value to be selected (use the option value, not the displayed text between the tags) OR it can be an array and is used as the array to populate $miscFields (see explanation there), omitting the default value. A bit unusual perhaps, probably it's a timesaver when you code these forms a lot.
  • $miscFields: An associative array ($k => $value): insert additional keys into the tag (i.e. multiple="multiple"

The fun in using select is, it STORES your settings between sessions. Boy, I should have used it earlier, when hand-coding this for other parts of the project.

Another note on ValidationErrorHelper:

/**
* Returns whether or not this error helper has more than one error registered within it.
* @return bool
*/
public function has() {
return (count($this->error) > 0);
}

As one can read from the source above, the Validation Helper returns whether there are errors (even if it is only one) or there are none!