示例#1
0
 public function actionIndex()
 {
     $this->title = Yii::t('vps-uploader', 'File list');
     $query = File::find();
     $provider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['dt' => SORT_DESC]], 'pagination' => ['pageSize' => 50, 'forcePageParam' => false, 'pageSizeParam' => false, 'urlManager' => new \yii\web\UrlManager(['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['uploader/file/<page>' => 'uploader/file/index']])]]);
     // Last uploaded files.
     $last = Yii::$app->request->get('last', '');
     $this->data('last', StringHelper::explode($last));
     // Common files list.
     $this->data('files', $provider->models);
     $this->data('pagination', $provider->pagination);
 }
示例#2
0
 public function testExplode()
 {
     $this->assertEquals(['It', 'is', 'a first', 'test'], StringHelper::explode("It, is, a first, test"));
     $this->assertEquals(['It', 'is', 'a test with trimmed digits', '0', '1', '2'], StringHelper::explode("It, is, a test with trimmed digits, 0, 1, 2", ',', true, true));
     $this->assertEquals(['It', 'is', 'a second', 'test'], StringHelper::explode("It+ is+ a second+ test", '+'));
     $this->assertEquals(['Save', '', '', 'empty trimmed string'], StringHelper::explode("Save, ,, empty trimmed string", ',', true, false));
     $this->assertEquals(['Здесь', 'multibyte', 'строка'], StringHelper::explode("Здесь我 multibyte我 строка", '我'));
     $this->assertEquals(['Disable', '  trim  ', 'here but ignore empty'], StringHelper::explode("Disable,  trim  ,,,here but ignore empty", ',', false, true));
     $this->assertEquals(['It/', ' is?', ' a', ' test with rtrim'], StringHelper::explode("It/, is?, a , test with rtrim", ',', 'rtrim'));
     $this->assertEquals(['It', ' is', ' a ', ' test with closure'], StringHelper::explode("It/, is?, a , test with closure", ',', function ($value) {
         return trim($value, '/?');
     }));
 }