示例#1
0
 public function changeposterAjaxAction(\Difra\Param\AjaxString $videoHash, \Difra\Param\AjaxFile $poster)
 {
     $Locale = \Difra\Locales::getInstance();
     $res = \Difra\Plugins\videoManager::getInstance()->savePoster($videoHash->val(), $poster->val());
     if ($res === true) {
         $this->ajax->display($Locale->getXPath('videoManager/adm/notify/posterAdded') . '<br/><br/><a class="button" href="#" onclick="window.location.reload();">' . $Locale->getXPath('videoManager/adm/close') . '</a>');
     } else {
         $this->ajax->display($Locale->getXPath('videoManager/adm/errors/' . $res) . '<br/><br/><a class="button" href="#" onclick="ajaxer.close( this );">' . $Locale->getXPath('videoManager/adm/close') . '</a>');
     }
 }
示例#2
0
 public function saveAjaxAction(\Difra\Param\AjaxFile $eventImage, \Difra\Param\AjaxString $title, \Difra\Param\AjaxString $eventDate, \Difra\Param\AjaxString $beginDate, \Difra\Param\AjaxInt $priorityValue, \Difra\Param\AjaxCheckbox $visible, \Difra\Param\AjaxSafeHTML $shortDescription, \Difra\Param\AjaxSafeHTML $description = null, \Difra\Param\AjaxInt $group = null, \Difra\Param\AjaxString $endDate = null)
 {
     $data = ['title' => $title->val(), 'eventDate' => $eventDate->val(), 'beginDate' => $beginDate->val(), 'priority' => $priorityValue->val(), 'visible' => $visible->val(), 'shortDescription' => $shortDescription->val()];
     $data['description'] = is_null($description) ? null : $description->val();
     $data['group'] = is_null($group) ? null : $group->val();
     $data['endDate'] = is_null($endDate) ? null : $endDate->val();
     // из админки пока ставим так, потом добавим выбор юзера.
     $data['user'] = 1;
     $Announcements = \Difra\Plugins\Announcements::getInstance();
     // создаём анонс
     $eventId = $Announcements->create($data);
     if (is_null($eventId)) {
         $this->ajax->error(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/createError'));
         return;
     }
     // записываем картиночку
     $Announcements->saveImage($eventId, $eventImage->val());
     \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/goodCreate'));
     $this->ajax->redirect('/adm/announcements/');
 }
示例#3
0
 public function test_Files()
 {
     $file1 = ['error' => UPLOAD_ERR_OK, 'tmp_name' => __DIR__ . '/data/file1.txt'];
     $file2 = ['error' => UPLOAD_ERR_OK, 'tmp_name' => __DIR__ . '/data/file2.txt'];
     $file3 = ['error' => UPLOAD_ERR_INI_SIZE];
     $this->assertFalse(\Difra\Param\AjaxFile::verify(null));
     $this->assertTrue(\Difra\Param\AjaxFile::verify($file1));
     $this->assertTrue(\Difra\Param\AjaxFile::verify($file2));
     $this->assertFalse(\Difra\Param\AjaxFile::verify($file3));
     $this->assertFalse(\Difra\Param\AjaxFiles::verify(null));
     $this->assertTrue(\Difra\Param\AjaxFiles::verify([$file1]));
     $this->assertTrue(\Difra\Param\AjaxFiles::verify([$file2]));
     $this->assertFalse(\Difra\Param\AjaxFiles::verify([$file3]));
     $this->assertTrue(\Difra\Param\AjaxFiles::verify([$file1, $file2]));
     $this->assertTrue(\Difra\Param\AjaxFiles::verify([$file1, $file3]));
     $this->assertTrue(\Difra\Param\AjaxFiles::verify([$file2, $file3]));
     $this->assertTrue(\Difra\Param\AjaxFiles::verify([$file1, $file2, $file3]));
     $files = new \Difra\Param\AjaxFiles([$file1, $file2, $file3]);
     $this->assertEquals($files->val(), [file_get_contents(__DIR__ . '/data/file1.txt'), file_get_contents(__DIR__ . '/data/file2.txt')]);
     $file = new \Difra\Param\AjaxFile($file3);
     $this->assertNull($file->val());
     $this->assertEquals($file->raw(), $file3);
 }