/** * Batch copy items to a new category or current. * * @param integer $value The new category. * @param array $pks An array of row IDs. * @param array $contexts An array of item contexts. * * @return mixed An array of new IDs on success, boolean false on failure. * * @since 11.1 */ protected function batchCopy($value, $pks, $contexts) { $regionId = (int) $value; $newIds = array(); if (!parent::checkregionId($regionId)) { return false; } // Parent exists so we let's proceed while (!empty($pks)) { // Pop the first ID off the stack $pk = array_shift($pks); $this->table->reset(); // Check that the row actually exists if (!$this->table->load($pk)) { if ($error = $this->table->getError()) { // Fatal error $this->setError($error); return false; } else { // Not fatal error $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); continue; } } // Alter the title & alias $data = $this->generateNewTitle($regionId, $this->table->alias, $this->table->title); $this->table->title = $data['0']; $this->table->alias = $data['1']; // Reset the ID because we are making a copy $this->table->id = 0; // Reset hits because we are making a copy $this->table->hits = 0; // Unpublish because we are making a copy $this->table->state = 0; // New region ID $this->table->regionid = $regionId; // TODO: Deal with ordering? // $table->ordering = 1; // Get the featured state //$featured = $this->table->featured; // Check the row. if (!$this->table->check()) { $this->setError($this->table->getError()); return false; } parent::createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); // Store the row. if (!$this->table->store()) { $this->setError($this->table->getError()); return false; } // Get the new item ID $newId = $this->table->get('id'); // Add the new ID to the array $newIds[$pk] = $newId; // // Check if the town was featured and update the #__content_frontpage table // if ($featured == 1) // { // $db = $this->getDbo(); // $query = $db->getQuery(true) // ->insert($db->quoteName('#__content_frontpage')) // ->values($newId . ', 0'); // $db->setQuery($query); // $db->execute(); // } } // Clean the cache $this->cleanCache(); return $newIds; }