当前位置: 首页>>代码示例>>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;未经允许,请勿转载。