Example #1
0
foreach ($storage->getComponentsData() as $comp_data) {
    $comp_class = $comp_data['type'];
    $c = new $comp_class();
    $CACHE = array();
    foreach ($comp_data as $name => $val) {
        if (in_array($name, array('x', 'y', 'width', 'parent', 'id', 'datasource'))) {
            $CACHE[$name] = $val;
        }
        $c->setPropertyValue($name, $val);
    }
    // load datasource
    if (isset($CACHE['datasource'])) {
        $ds = $storage->getDatasource($comp_class, $CACHE['datasource']);
        $c->setDatasource($ds);
    }
    $page->addComponent($c);
    $script = "\n\t\ttmp= new {$comp_class}();\n\t\ttmp.setup( \$('{$CACHE['id']}') );\n\n\t\tnew Effect.Move( tmp._div, {\n\t\t\tmode: 'absolute',\n\t\t\tx: {$CACHE['x']},\n\t\t\ty: {$CACHE['y']}\n\t\t});\n\n\t";
    foreach ($c->getProperties() as $name => $prop) {
        $script .= "tmp['{$name}']= unescape(\"{$prop->value}\");\n";
    }
    $script .= "tmp.updateContent();";
    $xtpl->concat('ADDED_JS', $script);
    switch ($c->getPropertyValue('position')) {
        case 'fixed':
            $xtpl->concat('ADDED_JS', "DragDrop.addDraggable(\$('{$CACHE['id']}'), null, 'global_group', {handle: 'handle'});");
            if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
                $c->setCSSStyle('position', 'absolute');
                $c->setCSSStyle('left', "expression( {$CACHE['x']} + ( ignoreMe2 = document.body.scrollLeft ) + 'px' )");
                $c->setCSSStyle('top', "expression( {$CACHE['y']} + ( ignoreMe = document.body.scrollTop ) + 'px' )");
            } else {
                $c->setCSSStyle('position', 'fixed');