/** * Prepare and sanitise the table prior to saving. * * @since 1.6 */ protected function prepareTable(&$table, $data) { // Prepare the video $pitchVideo = JArrayHelper::getValue($data, "pitch_video"); $table->set("pitch_video", $pitchVideo); // Prepare the image. if (!empty($data["pitch_image"])) { // Delete old image if I upload a new one. if (!empty($table->pitch_image)) { $params = JComponentHelper::getParams($this->option); /** @var $params Joomla\Registry\Registry */ $imagesFolder = $params->get("images_directory", "images/crowdfunding"); // Remove an image from the filesystem $pitchImage = JPAth::clean($imagesFolder . DIRECTORY_SEPARATOR . $table->pitch_image); if (is_file($pitchImage)) { JFile::delete($pitchImage); } } $table->set("pitch_image", $data["pitch_image"]); } }
protected function prepareTableData($table, $data) { // Prepare the video $pitchVideo = Joomla\Utilities\ArrayHelper::getValue($data, 'pitch_video'); $table->set('pitch_video', $pitchVideo); // Prepare the image. if (!empty($data['pitch_image'])) { // Delete old image if I upload a new one. if (JString::strlen($table->pitch_image) > 0) { $params = JComponentHelper::getParams($this->option); /** @var $params Joomla\Registry\Registry */ $imagesFolder = $params->get('images_directory', 'images/crowdfunding'); // Remove an image from the filesystem $pitchImage = JPAth::clean($imagesFolder . DIRECTORY_SEPARATOR . $table->pitch_image); if (is_file($pitchImage)) { JFile::delete($pitchImage); } } $table->set('pitch_image', $data['pitch_image']); } }