當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayUtil::pop方法代碼示例

本文整理匯總了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.');
     }
 }
開發者ID:shayanyi,項目名稱:CRM,代碼行數:101,代碼來源:SiteController.php


注:本文中的ArrayUtil::pop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。