本文整理汇总了PHP中ArrayUtil::pop方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::pop方法的具体用法?PHP ArrayUtil::pop怎么用?PHP ArrayUtil::pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpload
//.........这里部分代码省略.........
$this->redirect(array($model->associationType . '/' . $model->associationId));
}
} else {
$this->redirect('/media/media/view', array('id' => $model->id));
}
} else {
throw new CHttpException('400', 'Invalid request.');
}
} catch (Google_AuthException $e) {
$auth->flushCredentials();
$auth->setErrors($e->getMessage());
$service = null;
$createdFile = null;
}
} else {
if (isset($_SERVER['HTTP_REFERER'])) {
$this->redirect($_SERVER['HTTP_REFERER']);
} else {
throw new CHttpException('400', 'Invalid request');
}
}
} else {
// non-google drive upload
$model = new Media();
$temp = CUploadedFile::getInstanceByName('upload');
// file uploaded through form
$tempName = $temp->getTempName();
if (isset($temp) && !empty($tempName)) {
$name = $temp->getName();
$name = str_replace(' ', '_', $name);
$check = Media::model()->findAllByAttributes(array('fileName' => $name));
// rename file if there name conflicts by suffixing "(n)"
if (count($check) != 0) {
$count = 1;
$newName = $name;
$arr = explode('.', $name);
$name = $arr[0];
while (count($check) != 0) {
$newName = $name . '(' . $count . ').' . $temp->getExtensionName();
$check = Media::model()->findAllByAttributes(array('fileName' => $newName));
$count++;
}
$name = $newName;
}
$username = Yii::app()->user->name;
// copy file to user's media uploads directory
if (FileUtil::ccopy($tempName, "uploads/media/{$username}/{$name}")) {
if (isset($_POST['associationId'])) {
$model->associationId = $_POST['associationId'];
}
if (isset($_POST['associationType'])) {
$model->associationType = $_POST['associationType'];
}
if (isset($_POST['private'])) {
$model->private = $_POST['private'];
}
$model->uploadedBy = Yii::app()->user->getName();
$model->createDate = time();
$model->lastUpdated = time();
$model->fileName = $name;
if (!$model->save()) {
$errors = $model->getErrors();
$error = ArrayUtil::pop(ArrayUtil::pop($errors));
Yii::app()->user->setFlash('top-error', Yii::t('app', 'Attachment failed. ' . $error));
$this->redirect(array($model->associationType . '/' . $model->associationType . '/view', 'id' => $model->associationId));
Yii::app()->end();
}
// handle different upload types
switch ($model->associationType) {
case 'feed':
$this->handleFeedTypeUpload($model, $name);
break;
case 'docs':
$this->redirect(array('/docs/docs/index'));
break;
case 'loginSound':
case 'notificationSound':
$this->redirect(array('/profile/settings', 'id' => Yii::app()->user->getId()));
break;
case 'bg':
case 'bg-private':
$this->redirect(array('/profile/settings', 'id' => Yii::app()->user->getId(), 'bgId' => $model->id));
break;
default:
$this->handleDefaultUpload($model, $name);
break;
}
}
} else {
if (isset($_SERVER['HTTP_REFERER'])) {
$this->redirect($_SERVER['HTTP_REFERER']);
} else {
throw new CHttpException('400', 'Invalid request');
}
}
}
} else {
throw new CHttpException('400', 'Invalid request.');
}
}