/** * @param bool $isNew * @param array $data * @param FabrikAdminModelList $listModel * * @throws Exception * * @return array */ private function getInsertFields($isNew, $data, $listModel, $dbTableName) { $db = FabrikWorker::getDbo(true); $fields = array('id' => 'internalid', 'date_time' => 'date'); $createGroup = $data['_createGroup']; $recordInDatabase = $data['record_in_database']; $jForm = $this->app->input->get('jform', array(), 'array'); $this->contentTypeModel = JModelLegacy::getInstance('ContentTypeImport', 'FabrikAdminModel', array('listModel' => $listModel)); $groups = FArrayHelper::getValue($data, 'current_groups'); $contentType = ArrayHelper::getValue($jForm, 'contenttype'); if ($createGroup) { $this->contentTypeModel->check($contentType); } if (empty($groups) && !$isNew) { throw new Exception(FText::_('COM_FABRIK_ERR_ONE_GROUP_MUST_BE_SELECTED')); } // If new and record in db and group selected then we want to get those groups elements to create fields for in the db table if ($isNew && $recordInDatabase) { if (!empty($groups)) { $query = $db->getQuery(true); $query->select('plugin, name')->from('#__fabrik_elements')->where('group_id IN (' . implode(',', $groups) . ')'); $db->setQuery($query); $rows = $db->loadObjectList(); foreach ($rows as $row) { $fields[$row->name] = $row->plugin; } $this->_makeFormGroups($groups); } } if ($createGroup) { $fields = $this->contentTypeModel->import($contentType, $dbTableName); } return $fields; }
/** * Add a filesystem path where content type XML files should be searched for. * You may either pass a string or an array of paths. * * @param mixed $path A filesystem path or array of filesystem paths to add. * * @return array An array of filesystem paths to find Content type XML files. */ public static function addContentTypeIncludePath($path = null) { // If the internal paths have not been initialised, do so with the base table path. if (empty(self::$_contentTypeIncludePaths)) { self::$_contentTypeIncludePaths = JPATH_COMPONENT_ADMINISTRATOR . '/models/content_types'; } // Convert the passed path(s) to add to an array. settype($path, 'array'); // If we have new paths to add, do so. if (!empty($path)) { // Check and add each individual new path. foreach ($path as $dir) { // Sanitize path. $dir = trim($dir); // Add to the front of the list so that custom paths are searched first. if (!in_array($dir, self::$_contentTypeIncludePaths)) { array_unshift(self::$_contentTypeIncludePaths, $dir); } } } return self::$_contentTypeIncludePaths; }