Exemple #1
0
 protected function tokenParamToCode(Token $token)
 {
     $name = $token->getProp('name');
     $props = $token->getAllProps();
     if (!isset($props['type']) && isset($props['values'])) {
         $props['type'] = 'select';
     }
     if ($props['type'] === 'select' && !preg_match("~^`~", $props['values'])) {
         $props['values'] = self::parseCssLikeProps($props['values']);
         if (!isset($props['default'])) {
             $props['default'] = current(array_keys($props['values']));
         }
     }
     fx::cdebug($props);
     unset($props['name']);
     $val_var = "\$param__" . $name . "_value";
     $code = "<?php\n";
     $code .= $val_var . " = \$context->get('" . $name . "');\n";
     $val_is_null = $val_var . "_is_null";
     $code .= $val_is_null . " = is_null(" . $val_var . ");\n";
     if (isset($props['default'])) {
         // handle computable defaults
         $default_val = "'" . $props['default'] . "'";
         $code .= "if (" . $val_is_null . ") {\n";
         $code .= $val_var . " = " . $default_val . ";\n";
         $code .= "\$context->set('" . $name . "', " . $val_var . ");\n";
         $code .= "}\n";
     }
     $code .= "if (\$_is_admin ) {\n";
     $exported_props = array("'is_forced' => !" . $val_is_null . " && \$context->getLastVarLevel() !== 1", "'value' => " . $val_var);
     foreach ($props as $k => $v) {
         $c_prop = "'" . $k . "' => ";
         if (!is_string($v)) {
             $c_prop .= var_export($v, 1);
         } elseif (preg_match("~^\\`.+\\`\$~", $v)) {
             $c_prop .= trim($v, '`');
         } else {
             $c_prop .= "'" . addslashes($v) . "'";
         }
         $exported_props[] = $c_prop;
     }
     $code .= "\$this->registerParam('" . $name . "', array(" . join(", ", $exported_props) . ") );\n";
     $code .= "}\n";
     $code .= "?>";
     return $code;
 }
Exemple #2
0
<?php

use Floxim\Floxim\System\Fx as fx;
$component = $this->getComponent();
$sort_fields = $component->getAllFields()->find(function ($f) {
    if ($f instanceof \Floxim\Floxim\Field\Link || $f instanceof \Floxim\Floxim\Field\MultiLink || $f instanceof \Floxim\Floxim\Field\Text || $f instanceof \Floxim\Floxim\Field\Image || in_array($f['keyword'], array('priority', 'is_published', 'is_branch_published', 'type', 'url', 'h1', 'title'))) {
        return false;
    }
    return true;
})->getValues(fx::isAdmin() ? 'name' : 'id', 'keyword');
$content_exists = fx::content($component['keyword'])->contentExists();
$is_new_infoblock = !$this->getParam('infoblock_id');
$component_infoblocks = fx::data('infoblock')->getContentInfoblocks($component['keyword']);
fx::cdebug(debug_backtrace());
return array('actions' => array('*list*' => array('settings' => array('limit' => array('label' => fx::alang('Count entries', 'controller_component'), 'class_name' => 'fx_field_limit'), 'pagination' => array('label' => fx::alang('Paginate?', 'controller_component'), 'type' => 'hidden', 'parent' => array('limit' => '!=')), 'sorting' => array('name' => 'sorting', 'label' => fx::alang('Sorting', 'controller_component'), 'type' => 'select', 'values' => $sort_fields), 'sorting_dir' => array('name' => 'sorting_dir', 'label' => fx::alang('Order', 'controller_component'), 'type' => 'select', 'values' => array('asc' => fx::alang('Ascending', 'controller_component'), 'desc' => fx::alang('Descending', 'controller_component')), 'parent' => array('sorting' => '!=manual')))), '*list' => array('disabled' => true), '*list_infoblock' => array('name' => fx::util()->ucfirst($component->getItemName('list')), 'install' => function ($ib, $ctr, $params) {
    $ctr->bindLostContent($ib, $params);
}, 'default_scope' => function () {
    $ds = fx::env('page_id') . '-this-';
    return $ds;
}, 'settings' => array('sorting' => array('values' => array(array('manual', fx::alang('Manual', 'controller_component'))) + $sort_fields)) + $this->getParentConfigFields() + $this->getTargetConfigFields() + $this->getLostContentField(), 'defaults' => array('!pagination' => true)), '*list_filtered' => array('name' => fx::util()->ucfirst(fx::alang('%s by filter', 'controller_component', $component->getItemName('list'))), 'settings' => array('conditions' => function ($ctr) {
    return $ctr->getConditionsField();
}, 'sorting' => array('values' => array(array('manual', fx::alang('Manual', 'controller_component'))) + $sort_fields)), 'defaults' => array('limit' => 10)), '*list_selected' => array('name' => fx::util()->ucfirst(fx::alang('%s selected', 'controller_component', $component->getItemName('list'))), 'settings' => array('selected' => function ($ctr) {
    return $ctr->getSelectedField();
}, 'allow_select_doubles' => array('type' => 'checkbox', 'label' => fx::alang('Allow doubles', 'controller_component')), 'is_pass_through' => array('label' => fx::alang('Pass-through data', 'controller_component'), 'type' => 'checkbox', 'parent' => array('scope[complex_scope]' => '!~this')), 'sorting' => array('values' => array(array('manual', fx::alang('Manual', 'controller_component'))) + $sort_fields)), 'defaults' => array('!pagination' => false, '!limit' => 0, '!allow_select_doubles' => true, 'is_pass_through' => 'false'), 'save' => function ($ib, $ctr, $params) {
    // update linkers
    $ctr->saveSelectedLinkers($params['params']['selected']);
}, 'delete' => function ($ib, $ctr, $params) {
    // drop linkers
    $ctr->dropSelectedLinkers();
}), '*list_filtered*, *list_selected*, *listing_by*' => array('check_context' => function () use($content_exists) {
    return $content_exists;