static function bindCustomEmbeddedFieldParams(&$obj, $fieldtype)
 {
     //vmdebug('bindCustomEmbeddedFieldParams begin',$obj);
     if (!class_exists('tsmartModelCustom')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'custom.php';
     }
     if ($obj->field_type == 'E') {
         JPluginHelper::importPlugin('vmcustom');
         $dispatcher = JDispatcher::getInstance();
         $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsCustomVM3', array(&$obj));
         if (!empty($obj->_varsToPushParam)) {
             if (empty($obj->_varsToPushParamCustom)) {
                 $obj->_varsToPushParamCustom = $obj->_varsToPushParam;
             }
             if (empty($obj->_varsToPushParamCustomField)) {
                 $obj->_varsToPushParamCustomField = $obj->_varsToPushParam;
             }
         }
     } else {
         $obj->_varsToPushParamCustom = tsmartModelCustom::getVarsToPush($fieldtype);
         $obj->_varsToPushParam = $obj->_varsToPushParamCustomField = $obj->_varsToPushParamCustom;
         //vmdebug('my $obj->_varsToPushParamCustom',$obj->_varsToPushParamCustomField);
     }
     if (!empty($obj->_varsToPushParam)) {
         //$obj ->_xParams = 'custom_params';
         tsmTable::bindParameterable($obj, 'custom_params', $obj->_varsToPushParamCustom);
         $obj->_xParams = 'customfield_params';
         tsmTable::bindParameterable($obj, $obj->_xParams, $obj->_varsToPushParamCustomField);
     }
 }
Exemple #2
0
    function display($tpl = null)
    {
        // Load the helper(s)
        if (!class_exists('VmHTML')) {
            require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
        }
        if (!class_exists('vmCustomPlugin')) {
            require VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php';
        }
        $model = tmsModel::getModel('custom');
        // TODO Make an Icon for custom
        $this->SetViewTitle('PRODUCT_CUSTOM_FIELD');
        $layoutName = vRequest::getCmd('layout', 'default');
        if ($layoutName == 'edit') {
            $this->addStandardEditViewCommands();
            $this->customPlugin = '';
            $this->custom = $model->getCustom();
            $this->fieldTypes = tsmartModelCustom::getCustomTypes();
            $this->customfields = tmsModel::getModel('customfields');
            //vmdebug('TsmartViewCustom',$this->custom);
            JPluginHelper::importPlugin('vmcustom');
            $dispatcher = JDispatcher::getInstance();
            $retValue = $dispatcher->trigger('plgVmOnDisplayEdit', array($this->custom->tsmart_custom_id, &$this->customPlugin));
            $this->SetViewTitle('PRODUCT_CUSTOM_FIELD', $this->custom->custom_title);
            $selected = 0;
            $this->custom->form = false;
            if (!empty($this->custom->custom_jplugin_id)) {
                tsmConfig::loadJLang('plg_vmpsplugin', false);
                JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields');
                $selected = $this->custom->custom_jplugin_id;
                // Get the payment XML.
                $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->custom->custom_element . DS . $this->custom->custom_element . '.xml');
                if (file_exists($formFile)) {
                    $this->custom->form = JForm::getInstance($this->custom->custom_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                    $this->custom->params = new stdClass();
                    $varsToPush = vmPlugin::getVarsToPushFromForm($this->custom->form);
                    tsmTable::bindParameterableToSubField($this->custom, $varsToPush);
                    $this->custom->form->bind($this->custom->getProperties());
                }
            } else {
                $varsToPush = tsmartModelCustom::getVarsToPush($this->custom->field_type);
                if (!empty($varsToPush)) {
                    JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields');
                    $formString = '<vmconfig>' . chr(10) . '<fields name="params">' . chr(10) . '<fieldset name="extraParams">' . chr(10);
                    foreach ($varsToPush as $key => $push) {
                        if ('_' == substr($key, 0, 1)) {
                            continue;
                        }
                        //$default = 0;
                        $formString .= '<field
						name="' . $key . '"
        				id="' . $key . 'Field"
        				label="com_tsmart_CUSTOM_PARAM_' . strtoupper($key) . '"
        				description="com_tsmart_CUSTOM_PARAM_' . strtoupper($key) . '_DESC"
        				default="' . $push[0] . '"
						';
                        if (isset($push[2])) {
                            $formString .= 'type="' . $push[2] . '" >';
                        } else {
                            if ($push[1] == 'int') {
                                $formString .= 'type="radio" >
    											<option value="0">JNO</option>
    											<option value="1">JYES</option>';
                            } else {
                                if ($push[1] == 'string') {
                                    $formString .= 'type="text" >' . chr(10);
                                }
                            }
                        }
                        $formString .= chr(10) . '</field>' . chr(10);
                    }
                    $formString .= '</fieldset>' . chr(10) . '</fields>' . chr(10) . '</vmconfig>';
                    $this->custom->form = JForm::getInstance($this->custom->field_type, $formString, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                    $this->custom->params = new stdClass();
                    tsmTable::bindParameterableToSubField($this->custom, $varsToPush);
                    $this->custom->form->bind($this->custom->getProperties());
                }
            }
            if (!empty($this->custom->custom_parent_id)) {
                $list = ShopFunctions::renderOrderingList('customs', 'custom_title', $this->custom->ordering, 'WHERE custom_parent_id ="' . (int) $this->custom->custom_parent_id . '" ');
                $this->ordering = VmHTML::row('raw', 'com_tsmart_ORDERING', $list);
            } else {
                $this->ordering = '';
                $this->addHidden('ordering', $this->custom->ordering);
            }
            $this->pluginList = self::renderInstalledCustomPlugins($selected);
        } else {
            JToolBarHelper::custom('createClone', 'copy', 'copy', tsmText::_('com_tsmart_CLONE'), true);
            JToolBarHelper::custom('toggle.admin_only.1', 'publish', '', tsmText::_('com_tsmart_TOGGLE_ADMIN'), true);
            JToolBarHelper::custom('toggle.admin_only.0', 'unpublish', '', tsmText::_('com_tsmart_TOGGLE_ADMIN'), true);
            JToolBarHelper::custom('toggle.is_hidden.1', 'publish', '', tsmText::_('com_tsmart_TOGGLE_HIDDEN'), true);
            JToolBarHelper::custom('toggle.is_hidden.0', 'unpublish', '', tsmText::_('com_tsmart_TOGGLE_HIDDEN'), true);
            $this->addStandardDefaultViewCommands();
            $this->addStandardDefaultViewLists($model);
            $this->custom_parent_id = vRequest::getInt('custom_parent_id', false);
            $this->customs = $model->getCustoms($this->custom_parent_id, vRequest::getCmd('keyword'));
            $this->pagination = $model->getPagination();
            $model->custom_parent_id = $this->custom_parent_id;
            $this->customsSelect = $model->displayCustomSelection();
        }
        parent::display($tpl);
    }