how to build schema and keep I18n attributes in the yml file using propel and symfony 1.4

I had created I18n table set and all seemed to be working well until I tried to propel:build-schema.
I had lost my attribues:

isI18N: true, i18nTable: page_i18n & isCulture: true

This is how I want my schema to looked in the beginning:

  cms:
    _attributes: { phpName: Cms, isI18N: true, i18nTable: cms_i18n }
    id:
    handle: {type: varchar, size: 50}
    created_at:
    updated_at:
  cms_i18n:
    id:      { type: integer, size:  11, foreignTable: cms, foreignReference: id,  required: true, primaryKey: true }
    culture:     { type: varchar, size:   7, required: true, primaryKey: true, isCulture: true }
    content: { phpName: Content, type: LONGVARCHAR, required: true }

 

Basically how the build-schema work flow works like this

  1. Execute symfony propel: build-schema
  2. The sfPropelBuildSchemaTask script will create an schema.xml file from the database
  3. Then sfPropelBuildSchemaTask will create a schema.yml from the newly created schema.xml before deleting it

The way to fix this problem is to modify the schema.xml before it transformed into the schema.yml

This is how I fixed the problem.

  1. You need to find and modify the sfPropelBuildSchemaTask.class.php file
  2. Find:  protected function reverseDatabase()
  3. You will see where they define the yml and the xml path
            $xmlSchemaPath = sfConfig::get('sf_config_dir') . '/' . $name . '.xml';
            $ymlSchemaPath = sfConfig::get('sf_config_dir') . '/' . $name . '.yml';
  4. below this you should find an if block. There is no use modifying the xml if it doest exists
    if (file_exists($xmlSchemaPath)) {
  5. Immediately at the start of the ‘if’ block added this code, you may need to modify to fit your situation…
                $I18ntables = array();
                $schema = file_get_contents($xmlSchemaPath);
    
                $xml = simplexml_load_file($xmlSchemaPath);
    
                //iterate once to get all i18n tables
                foreach ($xml->table as $table) {
                    foreach ($table->attributes() as $attributeskey0 => $attributesvalue1) {
                        if ($attributeskey0 == 'name') {
                            if (preg_match("/_i18n/", $attributesvalue1)) {
                                $I18ntables[] = str_replace('_i18n', '', $attributesvalue1);
                            }
                        }
                    }
                }
                 //iterate again because we dont know the order of the tables
                 //grab the sister tables and add the new attributes
                foreach ($xml->table as $table) {
                    foreach ($table->attributes() as $attributeskey0 => $attributesvalue1) {
                        if ($attributeskey0 == 'name') {
                            if (in_array($attributesvalue1, $I18ntables)) {
                                $table->addAttribute('isI18N', "true");
                                $table->addAttribute('i18nTable', strtolower($attributesvalue1 . '_i18n'));
                            }
                            //as we are scrolling through the tables again, grab the i18n table
                            //find the column called 'culture' and add a new attribut to that
                            if (preg_match("/_i18n/", $attributesvalue1)) {
    
                                foreach ($table->children() as $columnkey0 => $columnvalue1) {
                                    if ($columnkey0 == 'column') {
                                        foreach ($columnvalue1->attributes() as $collAttrKey0 => $collAttrValue1) {
                                            if ($collAttrKey0 == 'name') {
                                                if ($collAttrValue1 == 'culture') {
    
                                                    $columnvalue1->addAttribute('isCulture', 'true');
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //the schema has changed now so assign it here
                $schema = $xml->asXML();

 

 

There are a couple of rules you need to know to use my code

  • the 2 I18N tables must be named the same , except for the ‘_i18n’ appendment of course
  • The column where you set the culture must be named ‘culture’

 

 

 

 

No Comments

ORDER BY that sorts NULLS last with propel – Symfony 1.0

This propel snippet is an example on how to sort an int column ascending and putting NULLs last

$criteria->addAscendingOrderByColumn('IF(ISNULL('.FanPeer::CURRENT_CHART.'),1,0),'.FanPeer::CURRENT_CHART, Criteria::CUSTOM);

No Comments

mr sonius – easter 2011

1 Laurie Anderson – White Lily
2 Dubmission Records_Third Ear Audio_Intro_Original Mix
3 Sub Rosa_Bill Laswell_First Reading_Original Mix
4 Dig Deeper_Danny Howells_Flight Home_Original Mix
5 Sub Rosa_Bill Laswell_Assassiations 2_Original Mix
6 Grace Jones – The Crossing (Ooh The Action …)
7 Sub Rosa_Bill Laswell_Pilgrimage To Cairo_Original Mix
8 Dubmission Records_Third Ear Audio_Ethereality_Original Mix
9 Bpitch Control_Ellen Allien_Sun The Rain_Tim Hecker Remix
10 Sub Rosa_Bill Laswell_Slogans_Original Mix
11 Rong Music_Woolfy_The Warehouse_Project Sandro Remix
12 Sub Rosa_Bill Laswell_The Lord Of The Ressurection_Original Mix
13 Grace Jones – Frog And The Prince
14 Drumcode_Alan Fitzpatrick_Sub Dubbed_Original Mix
15 Sub Rosa_Bill Laswell_Morning High_Original Mix
16 inFine Music_Agoria_Kiss My Soul feat Kid A_Original Mix
17 Sub Rosa_Bill Laswell_The Western Lands_Original Mix

DOWNLOAD

No Comments

Symfony jq_sortable_element not passing parameters to action – fix

after a long debug session. i found this fix

in the jQueryHelper.php

change this line
$options['with'] = "jQuery('#$element_id').sortable('serialize', { key: 'order'})";

to

$options['with'] = "jQuery('#$element_id').sortable('serialize', { key: 'order[]'})";

in the action ;

$order = $this->getRequestParameter('order');

No Comments

mr Sonius’ – Lucid Dreams

Lucid Dreams – Health Warning
Spacewalker
Lucid Dreams – Prelucid Dreams
david holmes- rodney yates
Mission At Hand
Lucid Dreams – Dream Control & Erotic Possibilities
Heavy Loaded Head
Crooklyn Dub Outernational Presents – Bill Laswell – Finite State Machine Dub
Jon Spencer Blues Explosion – T.A.T.B. (For The Saints & Sinners Remix)
Lucid Dreams – Out-Of-The-Body Experiences
Stella Polaris Music-James Holden-A Break in The Coulds-Original Mix
Four Tet – Sleep- Eat Food- Have Visions
Lucid Dreams – Lucidity
Rong Music_Mudd_Speilplatz_Quiet Village Remix
Lucid Dreams – Achieving Lucidity
Underworld – push downstairs
Burial Mix_Rhythm Sound_Dem Never Know feat Jah Cotton_Sleeparchive Remix
Lucid Dreams – False Awakenings

http://blog.baddog.net.au/sonius/files/mr_sonius_lucid_dreams_2011_03_19.zip

No Comments

using url_for in the action in symfony 1.0

I have tried to generate an absolute url from ‘module/action’ in another action in the same way urls are generated in the view.
the trick here is to include the ‘Url’ helper in my action then adding the line..

sfLoader::loadHelpers(‘Url’);

then:
$url = url_for(‘my_module/my_action’, ‘absolute=true’);

1 Comment

Mr Sonius’ Burnout

DOWNLOAD

tracklist to come later

No Comments

Just Because 2011 01 04

DOWNLOAD

    Secret Track #1
    big 200 track 4
    The Phenomenal Handclap Band – Give it a Rest
    sound experience- devil with a bust
    Prince & The New Power Generation – Jughead
    Gommagang Start 1 – Its Rough
    Arcadion – Ghost Feeder
    Emperor Machine – 103
    Lipservice_Chicken Lips_Ron Silver_Big 200 Version
    Broadcasting – Track 12
    Ghostly International_Matthew Dear_Little People Black City_Original Mix
    Electrik Soul Recordings_Funk DVoid_Pedro Galante_Safado_Paul Woolfords Space Funk Remix
    ILabel_James Yuill_This Sweet Love_Prins Thomas Sneaky Edit
    Rush Hour_House Of Jezebel_Love Happiness_Vocal Mix

No Comments

Tropical Fruits 09-10 NYE

DOWNLOAD

No Comments

Drop 2010 08 01

DOWNLOAD

  1. The Space Between – brainticket
  2. Ninja Tune-DJ Food-Tricky Little Ears-The Cheech Wizard Pays Respect To All Living Creat
  3. Amazing Sounds_Harmonia_Eno 76_Sometimes In Autumn_Shackleton Remix
  4. RS Records-Thomas Fehlmann-Threefour Kings Club-Original Mix
  5. Sabres Of Paradise – Smokebelch II (Beatless Mix)
  6. Jaydee_Plastic Dreams_Audion Cant Go Home Mix
  7. Pyramide-The Truffle Tribe-Eternal Sound-Original Mix
  8. Analalogue Bubblebath
  9. Kompakt-Thomas Fehlmann-Speeding-Original Mix
  10. Sideshow_French Model In Dub feat Samar_Original Mix
  11. Tears For Fears – Listen
  12. Le Coeur_Introduction_Original Mix

No Comments