本文整理汇总了PHP中c2cTools::generateUniqueName方法的典型用法代码示例。如果您正苦于以下问题:PHP c2cTools::generateUniqueName方法的具体用法?PHP c2cTools::generateUniqueName怎么用?PHP c2cTools::generateUniqueName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c2cTools
的用法示例。
在下文中一共展示了c2cTools::generateUniqueName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWktFromFileUpload
/**
* Returns a 3D or 4D WKT
*/
protected function getWktFromFileUpload($request)
{
$path = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . c2cTools::generateUniqueName();
$status = $request->moveFile('gps_data', $path);
$type = c2cTools::getFileType($path);
c2cTools::log("File uploaded to: {$path} with status: {$status} and a file type of: {$type}");
$finalPath = $path;
$wkt = NULL;
// we rename file according to true type
// FIXME as for now we only accept gpx,
// this is kinda redundant...
if ($type) {
$status = rename($path, "{$path}.{$type}");
if ($status) {
$finalPath = $path . '.' . $type;
c2cTools::log("File renamed: {$finalPath}");
$wkt = $this->getWktFromFile($finalPath, $type);
c2cTools::log("wkt computed");
}
}
// we clear temp file :
unlink($finalPath);
//c2cTools::log("getWktFromFileUpload has generated this WKT: $wkt");
return $wkt;
}
示例2: handleImage
private function handleImage($image_name, $tmp_name, $temp_dir, $index = 1)
{
// copy the image to the temp directory
$filename = $tmp_name;
$unique_filename = c2cTools::generateUniqueName();
$file_ext = Images::detectExtension($filename);
$new_location = $temp_dir . $unique_filename . $file_ext;
if (!move_uploaded_file($filename, $new_location)) {
return array('error' => array('field' => 'image_file', 'msg' => 'Failed moving uploaded file'));
}
// svg
if ($file_ext == '.svg') {
if (!SVG::rasterize($temp_dir, $unique_filename, $file_ext)) {
return array('error' => array('field' => 'image_file', 'msg' => 'Failed rasterizing svg file'));
}
}
// if jpg, check if we need orientation changes
if ($file_ext == '.jpg') {
Images::correctOrientation($new_location);
}
// generate thumbnails
Images::generateThumbnails($unique_filename, $file_ext, $temp_dir);
// look iptc for a possible title (jpeg only)
if ($file_ext == '.jpg') {
$size = getimagesize($new_location, $info);
if (isset($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
if (isset($iptc['2#105'])) {
$image_title = trim($iptc['2#105'][0]);
} else {
if (isset($iptc['2#120'])) {
$image_title = trim($iptc['2#120'][0]);
}
}
}
}
if (isset($image_title)) {
$encoding = mb_detect_encoding($image_title, "UTF-8, ISO-8859-1, ISO-8859-15", true);
if ($encoding !== false) {
if ($encoding != 'UTF-8') {
$image_title = mb_convert_encoding($image_title, 'UTF-8', $encoding);
} else {
$image_title = $image_title;
}
}
// if encoding could not be detected, rather not try to put it as prefilled title
}
// we are also interested at this point on the exif date in order to reorder images on the client side
if ($file_ext == '.jpg' && ($exif = exif_read_data($new_location))) {
if (isset($exif['DateTimeOriginal'])) {
$image_date = str_replace(' ', ':', $exif['DateTimeOriginal']);
$image_date = explode(':', $image_date);
$image_date = mktime($image_date[3], $image_date[4], $image_date[5], $image_date[1], $image_date[2], $image_date[0]);
}
}
return array('image_filename' => $unique_filename . $file_ext, 'default_license' => $this->getDefaultImageLicense($this->getRequestParameter('document_id'), $this->getRequestParameter('mod')), 'image_number' => (intval($this->getRequestparameter('image_number')) + 1) * 1000 + $index, 'image_title' => isset($image_title) ? $image_title : null, 'image_datetime' => isset($image_date) && $image_date ? $image_date : null);
}