public function addAjaxActionAuth(\Difra\Param\AjaxString $module, \Difra\Param\AjaxInt $moduleId, \Difra\Param\AjaxInt $replyId, \Difra\Param\AjaxString $text) { $commentArray = ['module' => $module->val(), 'moduleId' => intval($moduleId->val()), 'replyId' => intval($replyId->val()), 'text' => $text->val()]; Comments::getInstance()->add($commentArray); //$this->ajax->notify( $moduleId->val() ); $this->ajax->refresh(); }
public function savesettingsAjaxAction(\Difra\Param\AjaxInt $perPage) { $settingsArray = ['perPage' => intval($perPage->val())]; \Difra\Plugins\News::getInstance()->saveSettings($settingsArray); $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('news/adm/settings/saved')); $this->ajax->refresh(); }
public function saveAjaxAction(\Difra\Param\AjaxInt $perpage, \Difra\Param\AjaxString $imgSizes, \Difra\Param\AjaxString $format, \Difra\Param\AjaxCheckbox $waterOn, \Difra\Param\AjaxCheckbox $waterPreviewOn, \Difra\Param\AjaxString $waterText = null, \Difra\Param\AjaxFile $waterFile = null) { $imgSizes2 = explode("\n", str_replace("\r", '', $imgSizes)); $imgSizes3 = []; foreach ($imgSizes2 as $str) { $arr = explode(' ', $str); if (sizeof($arr) != 3 or !ctype_alpha($arr[0]) or !ctype_digit($arr[1]) or !ctype_digit($arr[2]) or $arr[0] == 'f' or isset($imgSizes3[$arr[0]]) or !$arr[1] or !$arr[2]) { $this->ajax->invalid('imgSizes'); return; } $imgSizes3[$arr[0]] = [(int) $arr[1], (int) $arr[2]]; } $conf = \Difra\Config::getInstance(); $conf->setValue('gallery', 'perpage', $perpage->val()); $conf->setValue('gallery', 'imgSizes', $imgSizes3); $conf->setValue('gallery', 'watermark', $waterOn->val()); $conf->setValue('gallery', 'waterOnPreview', $waterPreviewOn->val()); $waterText = !is_null($waterText) ? $waterText->val() : ''; $conf->setValue('gallery', 'waterText', $waterText); $conf->setValue('gallery', 'format', $format->val()); if (!is_null($waterFile)) { $path = DIR_DATA . 'gallery/'; @mkdir($path, 0777, true); file_put_contents($path . 'watermark.png', \Difra\Libs\Images::convert($waterFile->val(), 'png')); } $this->ajax->notify($this->locale->getXPath('gallery/adm/config/saved')); }
public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxString $description, \Difra\Param\AjaxCheckbox $hidden, \Difra\Param\AjaxInt $id = null) { if ($id) { \Difra\Plugins\Gallery::getInstance()->albumUpdate($id->val(), $name->val(), $description->val(), !$hidden->val()); } else { \Difra\Plugins\Gallery::getInstance()->albumAdd($name->val(), $description->val(), !$hidden->val()); } $this->ajax->redirect('/adm/gallery/albums/'); }
public function createaliaseAjaxAction(\Difra\Param\AjaxInt $tagId, \Difra\Param\AjaxString $module, \Difra\Param\AjaxString $aliase) { if (\Difra\Plugins\Tags::getInstance()->createAliase($module->val(), $tagId->val(), $aliase->val())) { \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('tags/adm/aliasCreated')); $this->ajax->reload(); } else { $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('tags/adm/aliasCreateError')); } }
public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxInt $parent = null, \Difra\Param\AjaxInt $id = null) { if (!$id) { \Difra\Plugins\Catalog::getInstance()->addCategory($name->val(), $parent ? $parent->val() : null); } else { \Difra\Plugins\Catalog::getInstance()->updateCategory($id->val(), $name->val(), $parent ? $parent->val() : null); } $this->ajax->redirect('/adm/catalog/categories'); }
/** * Save page * @param \Difra\Param\AjaxString $title * @param \Difra\Param\AjaxString $tag * @param \Difra\Param\AjaxHTML $body * @param \Difra\Param\AjaxInt $id */ public function saveAjaxAction(\Difra\Param\AjaxString $title, \Difra\Param\AjaxString $tag, \Difra\Param\AjaxHTML $body, \Difra\Param\AjaxInt $id = null) { if ($id) { $page = \Difra\Plugins\CMS\Page::get($id->val()); } else { $page = \Difra\Plugins\CMS\Page::create(); } $page->setTitle($title->val()); $page->setUri($tag->val()); $page->setBody($body); Ajaxer::redirect('/adm/content/pages'); }
public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxInt $set, \Difra\Param\AjaxInt $group, \Difra\Param\AjaxInt $id = null) { if (!$id) { $ext = \Difra\Plugins\Catalog::getInstance()->addExt($name->val(), $set->val(), $group->val()); } else { $ext = \Difra\Plugins\Catalog::getInstance()->editExt($id->val(), $name->val(), $set->val(), $group->val()); } if ($set->val()) { $this->ajax->redirect('/adm/catalog/ext/values/' . $ext->getId()); } else { $this->ajax->redirect('/adm/catalog/ext'); } }
/** * @param \Difra\Param\AjaxString $name * @param \Difra\Param\AjaxString $text * @param \Difra\Param\AjaxInt $id * @param \Difra\Param\AjaxString $description * @throws Difra\Exception */ public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxString $text, \Difra\Param\AjaxInt $id = null, \Difra\Param\AjaxString $description = null) { if ($id) { if (!($snippet = \Difra\Plugins\CMS\Snippet::getById($id->val()))) { throw new \Difra\Exception('Snippet cannot be saved — bad ID'); } } else { $snippet = \Difra\Plugins\CMS\Snippet::create(); } $snippet->setName($name); $snippet->setDescription($description); $snippet->setText($text); \Difra\Ajaxer::redirect('/adm/content/snippets'); }
public function savesettingsAjaxAction(\Difra\Param\AjaxCheckbox $onLine, \Difra\Param\AjaxString $title, \Difra\Param\AjaxString $link, \Difra\Param\AjaxInt $ttl, \Difra\Param\AjaxInt $size, \Difra\Param\AjaxCheckbox $image, \Difra\Param\AjaxCheckbox $cache, \Difra\Param\AjaxString $desc = null, \Difra\Param\AjaxString $copyright = null, \Difra\Param\AjaxFile $rsslogo = null) { $settingsArray = ['onLine' => $onLine->val(), 'title' => $title->val(), 'link' => $link->val(), 'ttl' => $ttl->val(), 'size' => $size->val(), 'image' => $image->val(), 'cache' => $cache->val()]; if (!is_null($desc)) { $settingsArray['description'] = $desc->val(); } if (!is_null($copyright)) { $settingsArray['copyright'] = $copyright->val(); } if (!is_null($rsslogo)) { $settingsArray['logo'] = $rsslogo; } Difra\Plugins\Rss::saveSettings($settingsArray); $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('rss/adm/saved')); $this->ajax->refresh(); }
public function saveAjaxAction(\Difra\Param\AjaxString $value, \Difra\Param\AjaxInt $ext, \Difra\Param\AjaxFile $image = null, \Difra\Param\AjaxInt $id = null) { if ($id) { $ext = \Difra\Plugins\Catalog\Ext::get($ext); $res = $ext->updateValue($id->val(), $value, $image); } else { $ext = \Difra\Plugins\Catalog\Ext::get($ext); if (!$image and $ext->getSet() & \Difra\Plugins\Catalog\Ext::SET_IMAGES) { $this->ajax->required('image'); return; } $res = $ext->addValue($value, $image); } if ($res == \Difra\Plugins\Catalog\Ext::BAD_IMAGE) { $this->ajax->error($this->locale->getXPath('catalog/adm/ext/bad-image')); return; } $this->ajax->redirect('/adm/catalog/ext/values/' . $ext->getId()); }
public function saveAjaxAction(\Difra\Param\AjaxInt $maxdepth, \Difra\Param\AjaxInt $perpage, \Difra\Param\AjaxString $imgSizes, \Difra\Param\AjaxCheckbox $hideempty, \Difra\Param\AjaxCheckbox $allownoimage, \Difra\Param\AjaxCheckbox $usescale) { $imgSizes2 = explode("\n", str_replace("\r", '', $imgSizes)); $imgSizes3 = []; foreach ($imgSizes2 as $str) { $arr = explode(' ', $str); if (sizeof($arr) != 3 or !ctype_alpha($arr[0]) or !ctype_digit($arr[1]) or !ctype_digit($arr[2]) or $arr[0] == 'f' or isset($imgSizes3[$arr[0]]) or !$arr[1] or !$arr[2]) { $this->ajax->invalid('imgSizes'); return; } $imgSizes3[$arr[0]] = [(int) $arr[1], (int) $arr[2]]; } $conf = \Difra\Config::getInstance(); $conf->setValue('catalog', 'maxdepth', $maxdepth->val()); $conf->setValue('catalog', 'perpage', $perpage->val()); $conf->setValue('catalog', 'hideempty', $hideempty->val()); $conf->setValue('catalog', 'imgSizes', $imgSizes3); $conf->setValue('catalog', 'allownoimage', $allownoimage->val()); $conf->setValue('catalog', 'usescale', $usescale->val()); $this->ajax->notify($this->locale->getXPath('catalog/adm/config/saved')); }
public function updateAjaxAction(\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\AjaxInt $id, \Difra\Param\AjaxSafeHTML $description = null, \Difra\Param\AjaxInt $group = null, \Difra\Param\AjaxString $endDate = null, \Difra\Param\AjaxFile $eventImage = null) { $data = ['title' => $title->val(), 'eventDate' => $eventDate->val(), 'beginDate' => $beginDate->val(), 'id' => $id->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/updateError')); return; } if (!is_null($eventImage)) { $Announcements->saveImage($eventId, $eventImage->val()); } \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/goodUpdate')); $this->ajax->redirect('/adm/announcements/'); }
public function test_Int() { $this->assertTrue(\Difra\Param\AjaxInt::verify(10)); $this->assertTrue(\Difra\Param\AjaxInt::verify(0)); $this->assertTrue(\Difra\Param\AjaxInt::verify('0')); $this->assertTrue(\Difra\Param\AjaxInt::verify('10')); $this->assertFalse(\Difra\Param\AjaxInt::verify('10a')); $this->assertFalse(\Difra\Param\AjaxInt::verify('0x00')); $this->assertFalse(\Difra\Param\AjaxInt::verify('0xff')); $this->assertTrue(\Difra\Param\AjaxInt::verify(-4)); $this->assertTrue(\Difra\Param\AjaxInt::verify('-4')); $this->assertFalse(\Difra\Param\AjaxInt::verify('a')); $this->assertFalse(\Difra\Param\AjaxInt::verify(null)); $this->assertFalse(\Difra\Param\AjaxInt::verify(3.8)); $this->assertFalse(\Difra\Param\AjaxInt::verify(-4.6)); $this->assertFalse(\Difra\Param\AjaxInt::verify('3.8')); $this->assertFalse(\Difra\Param\AjaxInt::verify('-4.6')); $this->assertFalse(\Difra\Param\AjaxInt::verify(['abc'])); $this->assertFalse(\Difra\Param\AjaxInt::verify([10])); $i = new \Difra\Param\AjaxInt('-10'); $this->assertEquals($i->val(), -10); $this->assertEquals($i->raw(), -10); $this->assertEquals((string) $i, '-10'); }
public function changenameAjaxAction(\Difra\Param\AjaxInt $videoId, \Difra\Param\AjaxString $name) { $Locale = \Difra\Locales::getInstance(); \Difra\Plugins\videoManager::getInstance()->changeName($videoId->val(), $name->val()); $this->ajax->display($Locale->getXPath('videoManager/adm/notify/nameChanged') . '<br/><br/><a class="button" href="#" onclick="window.location.reload();">' . $Locale->getXPath('videoManager/adm/close') . '</a>'); }
public function createchannelAjaxAction(Param\AjaxString $name, Param\AjaxString $mount, Param\AjaxString $siteDescription = null, Param\AjaxString $description = null, Param\AjaxString $genre = null, Param\AjaxString $url, Param\AjaxInt $bitrate, Param\AjaxInt $samplerate, Param\AjaxString $hostname, Param\AjaxInt $port, Param\AjaxString $password, Param\AjaxInt $reencode, Param\AjaxInt $debug, Param\AjaxInt $onLine, Param\AjaxInt $minSongInQuery, Param\AjaxInt $minArtistInQuery, Param\AjaxInt $tracksCount) { $errors = false; $Radio = \Difra\Plugins\Radio::getInstance(); $Locales = \Difra\Locales::getInstance(); // проверяем точку монтирования if ($Radio->checkMount($mount->val())) { $errors = true; $this->ajax->invalid('mount', $Locales->getXPath('radio/errors/dupMount')); } // проверяем валидность битрейта if (!$Radio->checkBitrate($bitrate->val())) { $errors = true; $this->ajax->invalid('bitrate', $Locales->getXPath('radio/errors/invalidBitrate')); } // проверяем сэмплрейт if (!$Radio->checkSampleRate($samplerate->val())) { $errors = true; $this->ajax->invalid('samplerate', $Locales->getXPath('radio/errors/invalidSampleRate')); } if (mb_strlen($password->val()) <= 6) { $errors = true; $this->ajax->invalid('password', $Locales->getXPath('radio/errors/shortPassword')); } $dataArray = ['name' => $name->val(), 'mount' => $mount->val(), 'siteDescription' => $siteDescription->val(), 'description' => $description->val(), 'genre' => $genre->val(), 'url' => $url->val(), 'bitrate' => $bitrate->val(), 'samplerate' => $samplerate->val(), 'hostname' => $hostname->val(), 'port' => $port->val(), 'password' => $password->val(), 'reencode' => $reencode->val(), 'debug' => $debug->val(), 'onLine' => $onLine->val(), 'minSongInQuery' => $minSongInQuery->val(), 'minArtistInQuery' => $minArtistInQuery->val(), 'tracksCount' => $tracksCount->val()]; if (!$errors) { $result = $Radio->createChannel($dataArray); if ($result !== true) { $this->ajax->error($Locales->getXPath('radio/errors/' . $result)); } else { $this->ajax->display($Locales->getXPath('radio/channelAdded') . '<br/><br/><a class="button" onclick="ajaxer.close(this); switcher.page( \'/adm/radio/channels\' )">Закрыть</a>'); } } }
public function savesettingsAjaxAction(\Difra\Param\AjaxInt $timeout, \Difra\Param\AjaxInt $cachetime, \Difra\Param\AjaxInt $failtime, \Difra\Param\AjaxInt $selecttime) { \Difra\Plugins\CDN::getInstance()->saveSettings(['timeout' => $timeout->val(), 'cachetime' => $cachetime->val(), 'failtime' => $failtime->val(), 'selecttime' => $selecttime->val()]); $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('cdn/adm/notify/settingSaved')); }
public function saveAjaxAction(\Difra\Param\AjaxInt $maxPerUser, \Difra\Param\AjaxInt $maxPerGroup, \Difra\Param\AjaxInt $width, \Difra\Param\AjaxInt $height, \Difra\Param\AjaxInt $bigWidth, \Difra\Param\AjaxInt $bigHeight, \Difra\Param\AjaxInt $perPage) { $settingsArray = ['maxPerUser' => $maxPerUser->val(), 'maxPerGroup' => $maxPerGroup->val(), 'perPage' => $perPage->val(), 'width' => $width->val(), 'height' => $height->val(), 'bigWidth' => $bigWidth->val(), 'bigHeight' => $bigHeight->val()]; \Difra\Plugins\Announcements::getInstance()->saveSettings($settingsArray); $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/settingsSaved')); }
public function updateAjaxAction(\Difra\Param\AjaxString $title, \Difra\Param\AjaxString $eventDate, \Difra\Param\AjaxString $beginDate, \Difra\Param\AjaxInt $priorityValue, \Difra\Param\AjaxCheckbox $visible, \Difra\Param\AjaxInt $id, \Difra\Param\AjaxHTML $description, \Difra\Param\AjaxInt $group = null, \Difra\Param\AjaxString $shortDescription = null, \Difra\Param\AjaxString $endDate = null, \Difra\Param\AjaxFile $eventImage = null, \Difra\Param\AjaxData $additionalField = null, \Difra\Param\AjaxString $fromEventDate = null, \Difra\Param\AjaxInt $category = null, \Difra\Param\AjaxString $scheduleName = null, \Difra\Param\AjaxData $scheduleField = null, \Difra\Param\AjaxData $scheduleValue = null, \Difra\Param\AjaxInt $location = null, Param\AjaxInt $userId = null) { $data = ['title' => $title->val(), 'eventDate' => $eventDate->val(), 'beginDate' => $beginDate->val(), 'id' => $id->val(), 'priority' => $priorityValue->val(), 'visible' => $visible->val(), 'description' => $description]; $data['shortDescription'] = is_null($shortDescription) ? null : $shortDescription->val(); $data['group'] = is_null($group) ? null : $group->val(); $data['endDate'] = is_null($endDate) ? null : $endDate->val(); $data['category'] = is_null($category) ? null : $category->val(); $data['fromEventDate'] = is_null($fromEventDate) ? null : $fromEventDate->val(); $data['location'] = is_null($location) ? null : $location->val(); if (is_null($data['fromEventDate']) || $data['fromEventDate'] == '' || $data['fromEventDate'] == 'null') { $data['fromEventDate'] = $eventDate->val(); } // из админки пока ставим так, потом добавим выбор юзера. if (!is_null($userId)) { $data['user'] = $userId->val(); } else { $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/updateError')); return; } // сохраняем дополнительные поля if (!is_null($additionalField)) { \Difra\Plugins\Announcements\Additionals::saveData($eventId, $additionalField->val()); } if (!is_null($eventImage)) { $Announcements->saveImage($eventId, $eventImage); } // смотрим есть ли расписание if (!is_null($scheduleField) && !is_null($scheduleValue)) { $scheduleName = !is_null($scheduleName) ? $scheduleName->val() : null; $Announcements->saveSchedules($eventId, $scheduleName, $scheduleField->val(), $scheduleValue->val()); } $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/notify/goodUpdate')); $this->ajax->redirect('/adm/announcements/'); }
/** * Save typograph settings * @param \Difra\Param\AjaxCheckbox $spaceAfterShortWord * @param \Difra\Param\AjaxInt $lengthShortWord * @param \Difra\Param\AjaxCheckbox $spaceBeforeLastWord * @param \Difra\Param\AjaxInt $lengthLastWord * @param \Difra\Param\AjaxCheckbox $spaceAfterNum * @param \Difra\Param\AjaxCheckbox $spaceBeforeParticles * @param \Difra\Param\AjaxCheckbox $delRepeatSpace * @param \Difra\Param\AjaxCheckbox $delSpaceBeforePunctuation * @param \Difra\Param\AjaxCheckbox $delSpaceBeforeProcent * @param \Difra\Param\AjaxCheckbox $doReplaceBefore * @param \Difra\Param\AjaxCheckbox $doReplaceAfter * @param \Difra\Param\AjaxCheckbox $doMacros */ public function saveAjaxAction(\Difra\Param\AjaxCheckbox $spaceAfterShortWord, \Difra\Param\AjaxInt $lengthShortWord, \Difra\Param\AjaxCheckbox $spaceBeforeLastWord, \Difra\Param\AjaxInt $lengthLastWord, \Difra\Param\AjaxCheckbox $spaceAfterNum, \Difra\Param\AjaxCheckbox $spaceBeforeParticles, \Difra\Param\AjaxCheckbox $delRepeatSpace, \Difra\Param\AjaxCheckbox $delSpaceBeforePunctuation, \Difra\Param\AjaxCheckbox $delSpaceBeforeProcent, \Difra\Param\AjaxCheckbox $doReplaceBefore, \Difra\Param\AjaxCheckbox $doReplaceAfter, \Difra\Param\AjaxCheckbox $doMacros) { $settingsArray = ['spaceAfterShortWord' => $spaceAfterShortWord->val(), 'lengthShortWord' => $lengthShortWord->val(), 'spaceBeforeLastWord' => $spaceBeforeLastWord->val(), 'lengthLastWord' => $lengthLastWord->val(), 'spaceAfterNum' => $spaceAfterNum->val(), 'spaceBeforeParticles' => $spaceBeforeParticles->val(), 'delRepeatSpace' => $delRepeatSpace->val(), 'delSpaceBeforePunctuation' => $delSpaceBeforePunctuation->val(), 'delSpaceBeforeProcent' => $delSpaceBeforeProcent->val(), 'doReplaceBefore' => $doReplaceBefore->val(), 'doReplaceAfter' => $doReplaceAfter->val(), 'doMacros' => $doMacros->val()]; \Difra\Config::getInstance()->set('typograph', $settingsArray); $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('adm/typograph/saved')); }
/** * Save empty menu element * @param \Difra\Param\AjaxInt $menu * @param \Difra\Param\AjaxString $label * @param \Difra\Param\AjaxInt|null $id * @param \Difra\Param\AjaxInt $parent */ public function saveemptyAjaxAction(\Difra\Param\AjaxInt $menu, \Difra\Param\AjaxString $label, \Difra\Param\AjaxInt $id = null, \Difra\Param\AjaxInt $parent = null) { if ($id) { $item = \Difra\Plugins\CMS\MenuItem::get($id->val()); } else { $item = \Difra\Plugins\CMS\MenuItem::create(); } $item->setMenu($menu->val()); $item->setParent($parent ? $parent->val() : null); $item->setLinkLabel($label); \Difra\Ajaxer::redirect('/adm/content/menu/view/' . $menu->val()); }