本文整理汇总了PHP中PhocaGalleryFile::getFileFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP PhocaGalleryFile::getFileFormat方法的具体用法?PHP PhocaGalleryFile::getFileFormat怎么用?PHP PhocaGalleryFile::getFileFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhocaGalleryFile
的用法示例。
在下文中一共展示了PhocaGalleryFile::getFileFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addAllImagesFromFolder
protected function _addAllImagesFromFolder(&$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
if ($fileList !== false) {
foreach ($fileList as $filename) {
$storedfilename = ltrim(str_replace(DS, '/', JPath::clean($rel_path . DS . $filename)), '/');
$ext = strtolower(JFile::getExt($filename));
// Don't create thumbnails from defined files (don't save them into a database)...
$dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($filename);
if ($dontCreateThumb == 1) {
$ext = '';
// WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE
}
if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg') {
if (JFile::exists($fullPath . DS . $filename) && substr($filename, 0, 1) != '.' && strtolower($filename) !== 'index.html' && !$this->_ImageExist($existingImages, $storedfilename, $category_id)) {
$row = $this->getTable('phocagallery');
$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'] = PhocaGalleryFile::getTitleFromFile($filename);
}
if ($data['alias'] != '') {
$datam['alias'] = $data['alias'];
} else {
$datam['alias'] = $datam['title'];
//PhocaGalleryText::getAliasName($datam['title']);
}
$datam['imgorigsize'] = PhocaGalleryFile::getFileSize($datam['filename'], 0);
$datam['format'] = PhocaGalleryFile::getFileFormat($datam['filename']);
// Geo
phocagalleryimport('phocagallery.geo.geo');
$coords = PhocaGalleryGeo::getGeoCoords($datam['filename']);
$datam['longitude'] = $coords['longitude'];
$datam['latitude'] = $coords['latitude'];
if ($datam['latitude'] != '' && $datam['longitude'] != '') {
$datam['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
}
// Save
// Bind the form fields to the Phoca gallery 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 gallery table is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the Phoca gallery table to the database
if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
if ($this->firstImageFolder == '') {
$this->setFirstImageFolder($row->filename);
}
$image = new JObject();
$image->filename = $storedfilename;
$image->catid = $category_id;
$existingImages[] =& $image;
$count++;
}
}
}
}
// $this->setImageCount($count);
return $count;
}
示例2: save
function save($data)
{
$params =& JComponentHelper::getParams('com_phocagallery');
$clean_thumbnails = $params->get('clean_thumbnails', 0);
$fileOriginalNotExist = 0;
if ((int) $data['extid'] > 0) {
$data['imgorigsize'] = 0;
if ($data['title'] == '') {
$data['title'] = 'External Image';
}
} else {
//If this file doesn't exists don't save it
if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
//$this->setError('Original File does not exist');
//return false;
$fileOriginalNotExist = 1;
$errorMsg = JText::_('COM_PHOCAGALLERY_ORIGINAL_IMAGE_NOT_EXIST');
}
$data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
$data['format'] = PhocaGalleryFile::getFileFormat($data['filename']);
//If there is no title and no alias, use filename as title and alias
if ($data['title'] == '') {
$data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
}
}
if ($data['extlink1link'] != '') {
$extlink1 = str_replace('http://', '', $data['extlink1link']);
$data['extlink1'] = $extlink1 . '|' . $data['extlink1title'] . '|' . $data['extlink1target'] . '|' . $data['extlink1icon'];
} else {
$data['extlink1'] = $data['extlink1link'] . '|' . $data['extlink1title'] . '|' . $data['extlink1target'] . '|' . $data['extlink1icon'];
}
if ($data['extlink2link'] != '') {
$extlink2 = str_replace('http://', '', $data['extlink2link']);
$data['extlink2'] = $extlink2 . '|' . $data['extlink2title'] . '|' . $data['extlink2target'] . '|' . $data['extlink2icon'];
} else {
$data['extlink2'] = $data['extlink2link'] . '|' . $data['extlink2title'] . '|' . $data['extlink2target'] . '|' . $data['extlink2icon'];
}
// Geo
if ($data['longitude'] == '' || $data['latitude'] == '') {
phocagalleryimport('phocagallery.geo.geo');
$coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
if ($data['longitude'] == '') {
$data['longitude'] = $coords['longitude'];
}
if ($data['latitude'] == '') {
$data['latitude'] = $coords['latitude'];
}
if ($data['latitude'] != '' && $data['longitude'] != '' && $data['zoom'] == '') {
$data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
}
}
if ($data['alias'] == '') {
$data['alias'] = $data['title'];
}
//clean alias name (no bad characters)
//$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
// if new item, order last in appropriate group
//if (!$row->id) {
// $where = 'catid = ' . (int) $row->catid ;
// $row->ordering = $row->getNextOrder( $where );
//}
// = = = = = = = = = =
// Initialise variables;
$dispatcher = JDispatcher::getInstance();
$table = $this->getTable();
$pk = !empty($data['id']) ? $data['id'] : (int) $this->getState($this->getName() . '.id');
$isNew = true;
// Include the content plugins for the on save events.
JPluginHelper::importPlugin('content');
// Load the row if saving an existing record.
if ($pk > 0) {
$table->load($pk);
$isNew = false;
}
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
if (intval($table->date) == 0) {
$table->date = JFactory::getDate()->toSql();
}
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Trigger the onContentBeforeSave event.
/*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}*/
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
//.........这里部分代码省略.........