function check() { // check for valid name but not by text if ((int) $this->textonly == 1) { } else { if (trim($this->filename) == '') { $this->setError(JText::_('FILE MUST HAVE A FILENAME')); return false; } } if (empty($this->title)) { $this->title = PhocaDownloadFile::getTitleFromFilenameWithoutExt($this->filename); } if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = PhocaDownloadUtils::getAliasName($this->alias); return true; }
protected function _addAllFilesFromFolder(&$existingImages, $category_id, $fullPath, $rel_path, $data = array()) { $count = 0; $fileList = JFolder::files($fullPath); natcasesort($fileList); // Iterate over the files if they exist //file - abc.img, file_no - folder/abc.img // Make a copy for play and preview (1) -------- if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) { $path = PhocaDownloadPath::getPathSet(); $storedfoldername = ltrim(str_replace(DS, '/', JPath::clean($rel_path)), '/'); $paramsC = JComponentHelper::getParams('com_phocadownload'); $overwriteExistingFiles = $paramsC->get('overwrite_existing_files', 0); } // ------------------------------------------------ if ($fileList !== false) { foreach ($fileList as $filename) { $storedfilename = ltrim(str_replace(DS, '/', JPath::clean($rel_path . DS . $filename)), '/'); //$ext = strtolower(JFile::getExt($filename)); if (JFile::exists($fullPath . DS . $filename) && substr($filename, 0, 1) != '.' && strtolower($filename) !== 'index.html' && !$this->_FileExist($existingImages, $storedfilename, $category_id)) { $row =& $this->getTable('phocadownload'); $datam = array(); $datam['published'] = $data['published']; $datam['catid'] = $category_id; $datam['filename'] = $storedfilename; $datam['approved'] = $data['approved']; $datam['language'] = $data['language']; if ($data['title'] != '') { $datam['title'] = $data['title']; } else { $datam['title'] = PhocaDownloadFile::getTitleFromFilenameWithoutExt($filename); } if ($data['alias'] != '') { $datam['alias'] = $data['alias']; } else { $datam['alias'] = $data['alias']; //PhocaDownloadFile::get AliasName($datam['title']); } $datam['token'] = PhocaDownloadUtils::getToken($datam['title'] . $datam['filename']); $image = new JObject(); // Make a copy for play and preview (2) if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) { $o = $this->_copyPreviewAndPlay($filename, $storedfilename, $storedfoldername, $path, $overwriteExistingFiles); $datam['filename_play'] = $o['filename_play']; $datam['filename_preview'] = $o['filename_preview']; } // Save // Bind the form fields to the Phoca download table if (!$row->bind($datam)) { $this->setError($this->_db->getErrorMsg()); return false; } // Create the timestamp for the date $row->date = gmdate('Y-m-d H:i:s'); // if new item, order last in appropriate group if (!$row->id) { $where = 'catid = ' . (int) $row->catid; $row->ordering = $row->getNextOrder($where); } // Make sure the Phoca download table is valid if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return false; } // Store the Phoca download table to the database if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // -------------------------------------------- /*if ($this->firstImageFolder == '') { $this->setFirstImageFolder($row->filename); }*/ $image->filename = $storedfilename; $image->catid = $category_id; $existingImages[] =& $image; $count++; } } } // $this->setfileCount($count); return $count; }