/** * Returns a widget type’s SVG icon. * * @param IWidget $widgetType * * @return string */ private function _getWidgetIconSvg(IWidget $widgetType) { $iconPath = $widgetType->getIconPath(); if ($iconPath && IOHelper::fileExists($iconPath) && FileHelper::getMimeType($iconPath) == 'image/svg+xml') { return IOHelper::getFileContents($iconPath); } return craft()->templates->render('_includes/defaulticon.svg', array('label' => $widgetType->getName())); }
/** * Add a Form Field * @param $field Object */ public function addField(IWidget $field) { if ($field instanceof TField) { $name = $field->getName(); if (isset($this->fields[$name])) { throw new Exception(TAdiantiCoreTranslator::translate('You have already added a field called "^1" inside the form', $name)); } if ($name) { $this->fields[$name] = $field; $field->setFormName($this->name); if ($field instanceof TButton) { $field->addFunction($this->js_function); } } } if ($field instanceof TMultiField) { $this->js_function .= "mtf{$name}.parseTableToJSON();"; if ($this->fields) { // if the button was added before multifield foreach ($this->fields as $field) { if ($field instanceof TButton) { $field->addFunction($this->js_function); } } } } }
/** * Add a Form Field * @param $field Object */ public function addField(IWidget $field) { if ($field instanceof GtkWidget) { $name = $field->getName(); if (isset($this->fields[$name])) { throw new Exception(TAdiantiCoreTranslator::translate('You have already added a field called "^1" inside the form', $name)); } $this->fields[$name] = $field; $field->setFormName($this->fname); } }