/** * Create event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * @param array &$params Parameters passed from the Smarty plugin function. * * @see Zikula_Form_AbstractPlugin * @return void */ public function create(Zikula_Form_View $view, &$params) { $hasModule = isset($params['module']) && !empty($params['module']); $hasObjecttype = isset($params['objecttype']) && !empty($params['objecttype']); $hasIdField = isset($params['idField']) && !empty($params['idField']); $hasDisplayField = isset($params['displayField']) && !empty($params['displayField']); $hasRecordClass = isset($params['recordClass']) && !empty($params['recordClass']); if ($hasRecordClass) { $this->recordClass = $params['recordClass']; $idColumns = Doctrine::getTable($this->recordClass)->getIdentifierColumnNames(); if (count($idColumns) > 1) { $view->trigger_error(__f('Error! in %1$s: an invalid %2$s parameter was received.', array('formdropdownrelationlist', 'recordClass'))); } $this->idField = $idColumns[0]; } else { if (!$hasModule) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('formdropdownrelationlist', 'module'))); } $this->module = $params['module']; unset($params['module']); if (!ModUtil::available($this->module)) { $view->trigger_error(__f('Error! in %1$s: an invalid %2$s parameter was received.', array('formdropdownrelationlist', 'module'))); } if (!$hasObjecttype) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('formdropdownrelationlist', 'objecttype'))); } $this->objecttype = $params['objecttype']; unset($params['objecttype']); if (!$hasIdField) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('formdropdownrelationlist', 'idField'))); } $this->idField = $params['idField']; unset($params['idField']); if (isset($params['prefix'])) { $this->prefix = $params['prefix']; unset($params['prefix']); } } if (!isset($params['displayField']) || empty($params['displayField'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('formdropdownrelationlist', 'displayField'))); } $this->displayField = $params['displayField']; unset($params['displayField']); $this->displayFieldTwo = ''; if (isset($params['displayField2'])) { $this->displayFieldTwo = $params['displayField2']; unset($params['displayField2']); } if (isset($params['where'])) { $this->where = $params['where']; unset($params['where']); } if (isset($params['orderby'])) { $this->orderby = $params['orderby']; unset($params['orderby']); } if (isset($params['pos'])) { $this->pos = $params['pos']; unset($params['pos']); } if (isset($params['num'])) { $this->num = $params['num']; unset($params['num']); } if (isset($params['showEmptyValue'])) { $this->showEmptyValue = $params['showEmptyValue']; unset($params['showEmptyValue']); } parent::create($view, $params); $this->cssClass .= ' z-form-relationlist'; }
/** * Create event handler. * * @param Zikula_Form_View $view Reference to Zikula_Form_View object. * @param array &$params Parameters passed from the Smarty plugin function. * * @see Zikula_Form_AbstractPlugin * @return void */ public function create(Zikula_Form_View $view, &$params) { if (!isset($params['objectType']) || empty($params['objectType'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('muvideoRelationSelectorList', 'objectType'))); } $this->objectType = $params['objectType']; unset($params['objectType']); if (!isset($params['aliasReverse']) || empty($params['aliasReverse'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('relationtesterRelationSelectorList', 'aliasReverse'))); } $this->aliasReverse = $params['aliasReverse']; unset($params['aliasReverse']); if (isset($params['where'])) { $this->where = $params['where']; unset($params['where']); } if (isset($params['orderBy'])) { $this->orderBy = $params['orderBy']; unset($params['orderBy']); } elseif (isset($params['orderby'])) { $this->orderBy = $params['orderby']; unset($params['orderby']); } if (isset($params['num'])) { $this->resultsPerPage = intval($params['num']); unset($params['num']); } if (isset($params['pos'])) { $this->currentPage = intval($params['pos']); unset($params['pos']); } if (isset($params['showEmptyValue'])) { $this->showEmptyValue = (bool) $params['showEmptyValue']; unset($params['showEmptyValue']); } parent::create($view, $params); $this->idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $this->objectType)); $this->cssClass .= ' ' . $this->getStyleClass() . ' ' . strtolower($this->objectType); }