/** * Discover the element * * @return bool True on success */ public function discoverElement() { NenoHelper::setSetupState(JText::sprintf('COM_NENO_INSTALLATION_MESSAGE_PARSING_GROUP_TABLE', $this->group->getGroupName(), $this->getFilename()), 2); // Check if there are children not discovered $languageString = NenoContentElementLanguageString::load(array('discovered' => 0, '_limit' => 1, 'languagefile_id' => $this->id)); if (empty($languageString)) { $this->setDiscovered(true)->persist(); } else { NenoSettings::set('installation_level', '2.2'); NenoSettings::set('discovering_element_1.2', $this->id); } }
/** * Discover the element * * @return bool True on success */ public function discoverElement() { NenoHelper::setSetupState(JText::sprintf('COM_NENO_INSTALLATION_MESSAGE_PARSING_GROUP_TABLE', $this->group->getGroupName(), $this->getTableName()), 2); if ($this->translate) { // Check if there are children not discovered $field = NenoContentElementField::load(array('discovered' => 0, 'table_id' => $this->id, '_limit' => 1, 'translate' => 1)); if (!empty($field)) { NenoSettings::set('installation_level', '2.1'); NenoSettings::set('discovering_element_1.1', $this->id); } else { NenoSettings::set('discovering_element_1.1', 0); $this->setDiscovered(true)->persist(); } } else { NenoHelper::setSetupState(JText::sprintf('COM_NENO_INSTALLATION_MESSAGE_TABLE_TOO_MANY_RECORDS', $this->group->getGroupName(), $this->getTableName()), 2, 'error'); } }
/** * Get all the tables of the component that matches with the Joomla naming convention. * * @param NenoContentElementGroup $group Component name * @param string $tablePattern Table Pattern * @param bool $includeDiscovered Included tables that have been discovered already * * @return array */ public static function getComponentTables(NenoContentElementGroup $group, $tablePattern = null, $includeDiscovered = true) { /* @var $db NenoDatabaseDriverMysqlx */ $db = JFactory::getDbo(); $tables = $group->isOtherGroup() ? NenoHelperBackend::getTablesNotDiscovered() : $db->getComponentTables($tablePattern === null ? $group->getGroupName() : $tablePattern); $result = array(); for ($i = 0; $i < count($tables); $i++) { // Get Table name $tableName = self::unifyTableName($tables[$i]); $table = null; $tablesIgnored = self::getDoNotTranslateTables(); if (!in_array($tableName, $tablesIgnored)) { if (!self::isTableAlreadyDiscovered($tableName)) { $table = self::createTableInstance($tableName, $group); } elseif ($includeDiscovered) { $table = NenoContentElementTable::load(array('table_name' => $tableName, 'group_id' => $group->getId())); } } if (!empty($table)) { $result[] = $table; } } return $result; }
/** * Get all the tables of the component that matches with the Joomla naming convention. * * @param NenoContentElementGroup $group Component name * @param string $tablePattern Table Pattern * @param bool $includeDiscovered Included tables that have been discovered already * * @return array */ public static function getComponentTables(NenoContentElementGroup $group, $tablePattern = null, $includeDiscovered = true) { /* @var $db NenoDatabaseDriverMysqlx */ $db = JFactory::getDbo(); $tables = $db->getComponentTables($tablePattern === null ? $group->getGroupName() : $tablePattern); $result = array(); for ($i = 0; $i < count($tables); $i++) { // Get Table name $tableName = self::unifyTableName($tables[$i]); $table = null; $tablesIgnored = self::getDoNotTranslateTables(); if (!in_array($tableName, $tablesIgnored)) { if (!self::isTableAlreadyDiscovered($tableName)) { // Create an array with the table information $tableData = array('tableName' => $tableName, 'primaryKey' => $db->getPrimaryKey($tableName), 'translate' => 1, 'group' => $group); // Create ContentElement object $table = new NenoContentElementTable($tableData); // Get all the columns a table contains $fields = $db->getTableColumns($table->getTableName()); foreach ($fields as $fieldName => $fieldType) { $fieldData = array('fieldName' => $fieldName, 'fieldType' => $fieldType, 'translate' => NenoContentElementField::isTranslatableType($fieldType), 'table' => $table); $field = new NenoContentElementField($fieldData); $table->addField($field); } } elseif ($includeDiscovered) { $table = NenoContentElementTable::load(array('table_name' => $tableName, 'group_id' => $group->getId())); } } if (!empty($table)) { $result[] = $table; } } return $result; }