/** * Drops all translated copies of the table, as well as all nodes */ public function delete($wheres) { $nooku = KFactory::get('admin::com.nooku.model.nooku'); $nodes = KFactory::get('admin::com.nooku.table.nodes'); $languages = $nooku->getAddedLanguages(); foreach ($wheres as $where) { $table_name = KFactory::get('admin::com.nooku.table.tables')->find($where)->get('table_name'); // Delete all items for this table from the nodes table $query = $this->_db->getQuery()->where('table_name', '=', $table_name); $nodes->delete($query); if ($err = $nodes->getError()) { //throw new KDatabaseTableException($err); } // Delete all #__isocode_table_name foreach ($languages as $language) { $query = 'DROP TABLE ' . $this->_db->quoteName('#__' . strtolower($language->iso_code) . '_' . $table_name); $this->_db->execute($query); if ($err = $this->_db->getError()) { //throw new KDatabaseTableException($err); } } } // Delete the table item in nooku_tables return parent::delete($wheres); }
/** * Drops all tables for the language, as well as all nodes */ public function delete($wheres) { $nooku = KFactory::get('admin::com.nooku.model.nooku'); $nodes = KFactory::get('admin::com.nooku.table.nodes'); $tables = $nooku->getTables(); $primary = $nooku->getPrimaryLanguage(); foreach ($wheres as $key => $where) { $iso_code = KFactory::get('admin::com.nooku.table.languages')->find($where)->get('iso_code'); // the primary language can't be deleted if ($primary->iso_code == $iso_code) { unset($wheres[$key]); JError::raiseNotice(0, "The primary language can't be deleted"); if (count($wheres)) { continue; } else { return true; } } // Delete all items for this lang from the nodes table $query = $this->_db->getQuery()->where('iso_code', '=', $iso_code); $nodes->delete($query); // Delete all #__isocode_table_name foreach ($tables as $table) { $query = 'DROP TABLE ' . $this->_db->quoteName('#__' . strtolower($iso_code) . '_' . $table->table_name); $this->_db->execute($query); } } // Delete the table item in nooku_tables return parent::delete($wheres); }