本文整理汇总了PHP中FileHelper::getExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::getExtension方法的具体用法?PHP FileHelper::getExtension怎么用?PHP FileHelper::getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::getExtension方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPost
public function actionPost()
{
$model = new PostResumeForm(Yii::app()->user->id);
//check max job post
if ($model->getCountUserJobs() < Yii::app()->params['maxResumeJobTitles']) {
if (isset($_POST['PostResumeForm'])) {
$model->attributes = $_POST['PostResumeForm'];
$model->resumeFile = CUploadedFile::getInstance($model, 'resumeFile');
$model->portfolioFile = CUploadedFile::getInstance($model, 'portfolioFile');
if ($model->validate()) {
//checks the number of job titles submitted are within the limit boundry
if (count($model->jobTitles) + $model->getCountUserJobs() > Yii::app()->params['maxResumeJobTitles']) {
Yii::app()->user->setFlash('warning', sprintf(Yii::t('app', 'msg.warning.max_job_titles_exceed'), Yii::app()->params['maxResumeJobTitles']));
$this->redirect(Yii::app()->createAbsoluteUrl($this->getModule()->returnUrl));
Yii::app()->end();
return;
}
$extension = FileHelper::getExtension($model->resumeFile->name);
if (!empty($model->portfolioFile->name)) {
$extension_PortFolio = FileHelper::getExtension($model->portfolioFile->name);
} else {
$extension_PortFolio = "";
}
//saved file name in the following pattern
// {user_id}cv{time_stamp_string}.{extension}
$fileName = Yii::app()->user->id . 'cv' . Yii::app()->dateFormatter->format('yyyy-MM-dd_H-mm-ss', time()) . '.' . $extension;
if (!empty($extension_PortFolio)) {
$fileName_PortFolio = Yii::app()->user->id . 'pf' . Yii::app()->dateFormatter->format('yyyy-MM-dd_H-mm-ss', time()) . '.' . $extension_PortFolio;
} else {
$fileName_PortFolio = "";
}
if ($model->save(Yii::app()->user->id, $fileName, $fileName_PortFolio)) {
//if(!empty($fileName_PortFolio))
//{
$userFilePath = FileHelper::getFilePath(Yii::getPathOfAlias('site.files') . '/resumes/' . Yii::app()->user->id . '/');
$model->resumeFile->saveAs($userFilePath . $fileName);
if (!empty($fileName_PortFolio)) {
$model->portfolioFile->saveAs($userFilePath . $fileName_PortFolio);
}
Yii::app()->user->setFlash('success', Yii::t('app', 'msg.success.post_resume'));
//}
}
//checks the number of job titles submitted are within the limit boundry
if (count($model->jobTitles) + $model->getCountUserJobs() > Yii::app()->params['maxResumeJobTitles']) {
$this->refresh(true);
} else {
$this->redirect($this->createAbsoluteUrl('index'));
}
}
}
$this->render('post', array('model' => $model));
} else {
Yii::app()->user->setFlash('warning', sprintf(Yii::t('app', 'msg.warning.max_job_titles_exceed'), Yii::app()->params['maxResumeJobTitles']));
$this->redirect(Yii::app()->createAbsoluteUrl($this->getModule()->returnUrl));
}
}
示例2: resizeDown
public static function resizeDown($image, $width, $height)
{
if (substr($image, 0, 1) == '/' || ini_get('allow_url_fopen')) {
if (substr($image, 0, 1) == '/') {
$sourcePath = Yii::getPathOfAlias('webroot') . $image;
} else {
$sourcePath = $image;
}
$extension = FileHelper::getExtension($sourcePath);
$filename = pathinfo($sourcePath, PATHINFO_FILENAME);
$resizeUrl = '/files/.resized/' . $filename . '_' . substr(md5($sourcePath), 0, 8) . '_' . $width . 'x' . $height . '.' . $extension;
$resizePath = Yii::getPathOfAlias('webroot') . $resizeUrl;
if (!is_dir(dirname($resizePath))) {
mkdir(dirname($resizePath));
@chmod(dirname($resizePath), 0777);
}
Yii::import('application.vendors.wideimage.WideImage', true);
WideImage::load($sourcePath)->resizeDown($width, $height)->saveToFile($resizePath);
$image = $resizeUrl;
}
return $image;
}
示例3: array
<tr>
<th><?php
echo CHtml::activeLabel($product, 'image_path');
?>
</th>
<td>
<?php
echo CHtml::activeFileField($product, 'productFile');
?>
<?php
if ($product->image_path) {
?>
<br />
<?php
if (FileHelper::getExtension($product->image_path) == 'swf') {
?>
<?php
echo CHtml::link($product->getProductFileUrl(), $product->getProductFileUrl(), array('target' => '_blank'));
?>
<?php
} else {
?>
<?php
echo CHtml::image($product->getProductFileUrl(), '', array('style' => 'width:300px;'));
?>
<?php
}
?>
<br />
<?php
示例4: _populateFilesVariable
/**
* _populateFilesVariable
* @description Reads the configured folder and populates the array with filenames.
* @author Henrik Hussfelt
* @since 1.0
*/
private function _populateFilesVariable()
{
// Get config
$filesConfig = $this->getSetting('files');
// Create files array
$files = array();
// Check if folder is found and set to handle
if ($handle = opendir($filesConfig['start_path'])) {
// Start file-counter, so that we have a path to move to and use in XML file
$x = 0;
// Loop through all files
while (false !== ($file = readdir($handle))) {
// But skip any files that begin with .
if (substr($file, 0, 1) != ".") {
// Prepare content name for Alfresco XML file
$content_name = "content" . $x . "." . FileHelper::getExtension($file);
// Create array
$fileArr = array('name' => $file, 'content_name' => $content_name);
// Add to array
array_push($files, $fileArr);
// Add one to counter
$x += 1;
}
}
// Set the main varable
$this->_files = $files;
// Close the directory
closedir($handle);
}
// If there where no files, kill app
if (count($this->_files) == 0) {
die('No files in folder: ' . $filesConfig['start_path'] . ' Nothing to do. Goodbye!');
}
}
示例5: ob_get_clean
?>
<?php
$basicContent = ob_get_clean();
?>
<?php
$tabs = array('基本资料' => $basicContent);
?>
<?php
foreach (I18nHelper::getFrontendLanguages() as $lang => $attr) {
?>
<?php
ob_start();
?>
<?php
$this->widget('zii.widgets.CDetailView', array('htmlOptions' => array('class' => 'form'), 'data' => $banner, 'attributes' => array(array('name' => 'title', 'value' => $banner->i18nFormData['title_' . $lang]), array('name' => 'banner_path', 'value' => CHtml::image(Helper::mediaUrl(Banner::UPLOAD_THUMBNAIL_IMAGE_PATH . $banner->i18nFormData['banner_path_' . $lang])), 'type' => 'html', 'visible' => strlen($banner->i18nFormData['banner_path_' . $lang]) > 0 && in_array(FileHelper::getExtension($banner->i18nFormData['banner_path_' . $lang]), array('jpg', 'jpeg', 'gif', 'png'))), array('name' => 'banner_path', 'value' => CHtml::link($banner->i18nFormData['banner_path_' . $lang], Helper::mediaUrl(Banner::UPLOAD_THUMBNAIL_IMAGE_PATH . $banner->i18nFormData['banner_path_' . $lang])), 'type' => 'html', 'visible' => strlen(Banner::UPLOAD_THUMBNAIL_IMAGE_PATH . $banner->i18nFormData['banner_path_' . $lang]) > 0 && in_array(FileHelper::getExtension(Banner::UPLOAD_THUMBNAIL_IMAGE_PATH . $banner->i18nFormData['banner_path_' . $lang]), array('jpg', 'jpeg', 'gif', 'png')) == false), array('name' => 'is_released', 'value' => $banner->i18nFormData['is_released_' . $lang] ? '是' : '否'))));
?>
<?php
$i18nContent = ob_get_clean();
?>
<?php
$tabs += array($attr['label'] => $i18nContent);
?>
<?php
}
?>
<?php
$this->widget('zii.widgets.jui.CJuiTabs', array('tabs' => $tabs));
?>