示例#1
0
文件: news.php 项目: difra-org/difra
 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();
 }
示例#2
0
文件: entry.php 项目: difra-org/difra
 /**
  * @param \DOMNode $node
  */
 protected function postProcessXML($node)
 {
     // дата релиза
     if (!is_null($this->release)) {
         $release = date('d-m-Y', strtotime($this->release . ' 00:00:00'));
         $node->setAttribute('release', $release);
         $xDate = explode('-', $release);
         $fullDate = $xDate[0] . ' ' . \Difra\Locales::getInstance()->getXPath('portfolio/months/m_' . $xDate[1]) . ' ' . $xDate[2];
         $node->setAttribute('fullDate', $fullDate);
     }
     // авторы
     if (!is_null($this->authors)) {
         $authorsArray = unserialize($this->authors);
         if (!empty($authorsArray)) {
             foreach ($authorsArray as $k => $data) {
                 if (isset($data['role'])) {
                     $roleNode = $node->appendChild($node->ownerDocument->createElement('role'));
                     $roleNode->setAttribute('name', $data['role']);
                     if (isset($data['contibutors']) && is_array($data['contibutors'])) {
                         foreach ($data['contibutors'] as $cName) {
                             $cNode = $roleNode->appendChild($node->ownerDocument->createElement('contibutor'));
                             $cNode->setAttribute('name', $cName);
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
 function __construct()
 {
     // установки символов
     $Locale = \Difra\Locales::getInstance();
     $this->quot11 = $Locale->getXPath('typographer/quot11');
     $this->quot12 = $Locale->getXPath('typographer/quot12');
     $this->quot21 = $Locale->getXPath('typographer/quot21');
     $this->quot22 = $Locale->getXPath('typographer/quot22');
     $this->space = $Locale->getXPath('typographer/space');
     $this->tire = $Locale->getXPath('typographer/tire');
     $this->tireinterval = $Locale->getXPath('typographer/tireinterval');
     $this->number = $Locale->getXPath('typographer/number');
     $this->hellip = $Locale->getXPath('typographer/hellip');
     $this->sect = $Locale->getXPath('typographer/sect');
     $this->sup2 = $Locale->getXPath('typographer/sup2');
     $this->sup3 = $Locale->getXPath('typographer/sup3');
     $this->deg = $Locale->getXPath('typographer/deg');
     $this->euro = $Locale->getXPath('typographer/euro');
     $this->cent = $Locale->getXPath('typographer/cent');
     $this->pound = $Locale->getXPath('typographer/pound');
     $this->Prime = $Locale->getXPath('typographer/Prime');
     $this->times = $Locale->getXPath('typographer/times');
     $this->plusmn = $Locale->getXPath('typographer/plusmn');
     $this->darr = $Locale->getXPath('typographer/darr');
     $this->uarr = $Locale->getXPath('typographer/uarr');
     $this->larr = $Locale->getXPath('typographer/larr');
     $this->rarr = $Locale->getXPath('typographer/rarr');
     $this->crarr = $Locale->getXPath('typographer/crarr');
     $this->_setSettings();
 }
示例#4
0
 /**
  * Disable plugin
  *
  * @param \Difra\Param\AnyString $name
  */
 public function disableAjaxAction(\Difra\Param\AnyString $name)
 {
     if (!\Difra\Plugger::turnOff($name->val())) {
         \Difra\Ajaxer::notify(\Difra\Locales::get('adm/plugins/failed'));
     }
     \Difra\Ajaxer::refresh();
 }
示例#5
0
文件: index.php 项目: difra-org/difra
 public function saveformAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxString $uri, \Difra\Param\AjaxString $notify, \Difra\Param\AjaxString $button, \Difra\Param\AjaxHTML $description = null, \Difra\Param\AjaxData $fieldType = null, \Difra\Param\AjaxData $fieldName = null, \Difra\Param\AjaxData $fieldDescription = null, \Difra\Param\AjaxData $fieldMandatory = null, \Difra\Param\AjaxData $selectVariants = null, \Difra\Param\AjaxInt $formId = null, \Difra\Param\AjaxString $originalUri = null)
 {
     if (is_null($fieldType) || is_null($fieldName)) {
         return $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/create/noFieldsNotify'));
     }
     $FP = \Difra\Plugins\FormProcessor::getInstance();
     $uri = $uri->val();
     $originalUri = !is_null($originalUri) ? $originalUri->val() : null;
     if (is_null($formId) && $uri != $originalUri) {
         if ($FP->checkDupUri($uri)) {
             return $this->ajax->invalid('uri', \Difra\Locales::getInstance()->getXPath('formProcessor/adm/create/duplicateUri'));
         }
     }
     $errorField = $FP->checkEmptyNameFields($fieldType, $fieldName);
     if ($errorField !== true) {
         return $this->ajax->notify($errorField);
     }
     $mainFieldsArray = ['title' => $name->val(), 'uri' => $uri, 'answer' => $notify->val(), 'submit' => $button->val(), 'description' => $description];
     $fieldMandatory = !is_null($fieldMandatory) ? $fieldMandatory->val() : null;
     $selectVariants = !is_null($selectVariants) ? $selectVariants->val() : null;
     $formFieldsArray = ['names' => $fieldName->val(), 'mandatory' => $fieldMandatory, 'types' => $fieldType->val(), 'descriptions' => $fieldDescription->val(), 'variants' => $selectVariants];
     if (!is_null($formId)) {
         if (!$FP->updateForm($formId->val(), $mainFieldsArray, $formFieldsArray)) {
             return $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/edit/idError'));
         }
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/edit/formUpdated'));
     } else {
         $FP->createForm($mainFieldsArray, $formFieldsArray);
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('formProcessor/adm/create/formAdded'));
     }
     $this->ajax->redirect('/adm/formprocessor/manage');
 }
示例#6
0
文件: index.php 项目: difra-org/difra
 public function savesettingsAjaxAction(\Difra\Param\AjaxString $consumerKey, \Difra\Param\AjaxString $consumerSecret, \Difra\Param\AjaxString $oauthToken, \Difra\Param\AjaxString $oauthSecret, \Difra\Param\AjaxCheckbox $postToTwitter)
 {
     $oAuthArray = ['consumerKey' => $consumerKey->val(), 'consumerSecret' => $consumerSecret->val(), 'accessToken' => $oauthToken->val(), 'accessTokenSecret' => $oauthSecret->val(), 'postToTwitter' => $postToTwitter->val()];
     \Difra\Config::getInstance()->set('oAuth', $oAuthArray);
     \Difra\Ajaxer::refresh();
     \Difra\Ajaxer::notify(\Difra\Locales::getInstance()->getXPath('twitter/adm/oAuth/settingsSaved'));
 }
示例#7
0
文件: index.php 项目: difra-org/difra
 public function indexAction(Param\AnyString $portfolioLink = null)
 {
     if (!is_null($portfolioLink)) {
         $this->_viewWork($portfolioLink->val());
         return;
     }
     $mainXml = $this->root->appendChild($this->xml->createElement('PortfolioView'));
     $this->root->setAttribute('pageTitle', \Difra\Locales::getInstance()->getXPath('portfolio/adm/portfolio'));
     $search = new \Difra\Unify\Search('PortfolioEntry');
     $search->setOrder('release', 'release');
     $workList = $search->getList();
     $idArray = [];
     $newYear = 0;
     foreach ($workList as $work) {
         $workNode = $mainXml->appendChild($this->xml->createElement('PortfolioEntry'));
         $work->getXML($workNode);
         if (!is_null($work->release)) {
             $xRelease = explode('-', $work->release);
             if ($newYear != $xRelease[0]) {
                 $workNode->setAttribute('newYear', $xRelease[0]);
                 $newYear = $xRelease[0];
             }
         }
         $idArray[] = $work->id;
     }
     if (!empty($idArray)) {
         \Difra\Plugins\Portfolio::getMainImagesXML($idArray, $mainXml);
     }
 }
示例#8
0
文件: tags.php 项目: difra-org/difra
 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'));
     }
 }
示例#9
0
文件: pages.php 项目: difra-org/difra
 /**
  * Delete page
  * @param \Difra\Param\AnyInt $id
  * @param \Difra\Param\AjaxCheckbox $confirm
  */
 public function deleteAjaxAction(\Difra\Param\AnyInt $id, \Difra\Param\AjaxCheckbox $confirm = null)
 {
     if ($confirm and $confirm->val()) {
         \Difra\Plugins\CMS\Page::get($id->val())->delete();
         Ajaxer::close();
         Ajaxer::redirect('/adm/content/pages');
         return;
     }
     $page = \Difra\Plugins\CMS\Page::get($id->val());
     Ajaxer::display('<span>' . \Difra\Locales::get('cms/adm/delete-page-confirm-1') . $page->getTitle() . \Difra\Locales::get('cms/adm/delete-page-confirm-2') . '</span>' . '<form action="/adm/content/pages/delete/' . $id . '" method="post" class="ajaxer">' . '<input type="hidden" name="confirm" value="1"/>' . '<input type="submit" value="Да"/>' . '<a href="#" onclick="ajaxer.close(this)" class="button">Нет</a>' . '</form>');
 }
示例#10
0
 /**
  * @param \Difra\Param\AnyInt $id
  * @param \Difra\Param\AjaxInt $confirm
  */
 public function delAjaxAction(\Difra\Param\AnyInt $id, \Difra\Param\AjaxInt $confirm = null)
 {
     if (!($snippet = \Difra\Plugins\CMS\Snippet::getById($id->val()))) {
         \Difra\Ajaxer::redirect('/adm/cms/snippets');
     }
     if (!$confirm) {
         \Difra\Ajaxer::confirm(\Difra\Locales::get('cms/adm/snippet/del-confirm1') . $snippet->getName() . \Difra\Locales::get('cms/adm/snippet/del-confirm2'));
         return;
     }
     $snippet->del();
     \Difra\Ajaxer::close();
     \Difra\Ajaxer::redirect('/adm/content/snippets');
 }
示例#11
0
文件: list.php 项目: difra-org/difra
 /**
  * Edit user (submit)
  * @param Param\AnyInt $id
  * @param Param\AjaxEmail $email
  * @param Param\AjaxCheckbox $change_pw
  * @param Param\AjaxString|null $new_pw
  * @param Param\AjaxData|null $fieldName
  * @param Param\AjaxData|null $fieldValue
  */
 public function saveAjaxAction(Param\AnyInt $id, Param\AjaxEmail $email, Param\AjaxCheckbox $change_pw, Param\AjaxString $new_pw = null, Param\AjaxData $fieldName = null, Param\AjaxData $fieldValue = null)
 {
     $user = User::getById($id->val());
     $user->setEmail($email->val());
     //        $userData['addonFields'] = !is_null($fieldName) ? $fieldName->val() : null;
     //        $userData['addonValues'] = !is_null($fieldValue) ? $fieldValue->val() : null;
     if ($change_pw->val() and $new_pw and $new_pw->val()) {
         $user->setPassword($new_pw->val());
         Ajaxer::notify(Locales::get('auth/adm/userDataSavedPassChanged'));
     } else {
         Ajaxer::notify(Locales::get('auth/adm/userDataSaved'));
     }
     Ajaxer::refresh();
 }
示例#12
0
 public function chooseAjaxAction(\Difra\Param\AnyInt $id)
 {
     $this->subInit();
     try {
         $class = \Difra\Unify\Storage::getClass('WidgetsDirectory');
         $object = $class::get((string) $id);
         if ($object->directory != static::directory) {
             throw new \Difra\Exception('This item does not exist in this directory.');
         }
         \Difra\Ajaxer::getInstance()->close();
         $this->action($object->name);
     } catch (\Difra\Exception $ex) {
         \Difra\Ajaxer::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('widgets/directory/choose-error'));
     }
 }
示例#13
0
文件: index.php 项目: difra-org/difra
 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();
 }
示例#14
0
 public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxString $alias, \Difra\Param\AjaxInt $id = null, \Difra\Param\AjaxString $originalAlias = null)
 {
     $id = !is_null($id) ? $id->val() : null;
     if (is_null($id) || $originalAlias->val() != $alias->val()) {
         if (\Difra\Plugins\Announcements\Additionals::checkAlias($alias->val())) {
             \Difra\Ajaxer::getInstance()->invalid('alias', \Difra\Locales::getInstance()->getXPath('announcements/adm/additionals/duplicateName'));
             return;
         }
     }
     \Difra\Plugins\Announcements::getInstance()->saveAdditionalField($name->val(), $alias->val(), $id);
     if (is_null($id)) {
         \Difra\Ajaxer::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/additionals/added'));
     } else {
         \Difra\Ajaxer::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/additionals/updated'));
     }
     \Difra\Ajaxer::getInstance()->refresh();
 }
示例#15
0
文件: index.php 项目: difra-org/difra
 public function saveAjaxAction(\Difra\Param\AjaxString $imgSizes)
 {
     $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');
             $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('portfolio/adm/notify/badImageSizes'));
             return;
         }
         $imgSizes3[$arr[0]] = [(int) $arr[1], (int) $arr[2]];
         $Config = \Difra\Config::getInstance();
         $Config->setValue('portfolio_settings', 'imgSizes', $imgSizes3);
     }
     $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('portfolio/adm/notify/settingSaved'));
     $this->ajax->refresh();
 }
示例#16
0
 public function saveAjaxAction(\Difra\Param\AjaxString $categoryName, \Difra\Param\AjaxString $categoryAlias, \Difra\Param\AjaxInt $catId = null, \Difra\Param\AjaxString $originalAlias = null)
 {
     $catId = !is_null($catId) ? $catId->val() : null;
     $Announcements = \Difra\Plugins\Announcements::getInstance();
     if (is_null($catId) || $originalAlias->val() != $categoryAlias->val()) {
         if (\Difra\Plugins\Announcements\Category::checkName($categoryAlias->val())) {
             $this->ajax->invalid('categoryAlias', \Difra\Locales::getInstance()->getXPath('announcements/adm/category/duplicateName'));
             return;
         }
     }
     $Announcements->saveCategory($categoryAlias->val(), $categoryName->val(), $catId);
     if (is_null($catId)) {
         $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/category/added'));
     } else {
         $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/category/updated'));
     }
     $this->ajax->refresh();
 }
示例#17
0
文件: rss.php 项目: difra-org/difra
 private function rssImage()
 {
     if ($this->settings['image'] == 0) {
         return;
     }
     $imagePath = DIR_DATA . 'rss/';
     if (file_exists($imagePath . 'rsslogo.png')) {
         $Locales = \Difra\Locales::getInstance();
         $mainHost = Envi::getHost();
         $sizes = getimagesize($imagePath . 'rssLogo.png');
         $imageNode = $this->channel->appendChild($this->rssDoc->createElement('image'));
         $imageNode->appendChild($this->rssDoc->createElement('title', $Locales->getXPath('rss/imageTitle')));
         $imageNode->appendChild($this->rssDoc->createElement('link', 'http://' . $mainHost));
         $imageNode->appendChild($this->rssDoc->createElement('url', 'http://' . $mainHost . '/rss/rsslogo.png'));
         $imageNode->appendChild($this->rssDoc->createElement('width', $sizes[0]));
         $imageNode->appendChild($this->rssDoc->createElement('height', $sizes[1]));
     }
 }
示例#18
0
 /**
  * @backupGlobals enabled
  */
 public function test_actions()
 {
     \Difra\Debugger::disable();
     \Difra\Ajaxer::clean();
     $actions = [];
     \Difra\Ajaxer::notify('notification message');
     $actions[] = ['action' => 'notify', 'message' => 'notification message', 'lang' => ['close' => \Difra\Locales::get('notifications/close')]];
     \Difra\Ajaxer::display('<span>test</span>');
     $actions[] = ['action' => 'display', 'html' => '<span>test</span>'];
     \Difra\Ajaxer::error('error message <span>test</span>');
     $actions[] = ['action' => 'error', 'message' => 'error message &lt;span&gt;test&lt;/span&gt;', 'lang' => ['close' => \Difra\Locales::get('notifications/close')]];
     \Difra\Ajaxer::required('element');
     $actions[] = ['action' => 'require', 'name' => 'element'];
     \Difra\Ajaxer::invalid('inv1');
     $actions[] = ['action' => 'invalid', 'name' => 'inv1'];
     \Difra\Ajaxer::invalid('inv2');
     $actions[] = ['action' => 'invalid', 'name' => 'inv2'];
     \Difra\Ajaxer::status('field1', 'bad value', 'problem');
     $actions[] = ['action' => 'status', 'name' => 'field1', 'message' => 'bad value', 'classname' => 'problem'];
     \Difra\Ajaxer::redirect('/some/page');
     $actions[] = ['action' => 'redirect', 'url' => '/some/page'];
     $_SERVER['HTTP_REFERER'] = '/current/page';
     \Difra\Ajaxer::refresh();
     $actions[] = ['action' => 'redirect', 'url' => '/current/page'];
     \Difra\Ajaxer::reload();
     $actions[] = ['action' => 'reload'];
     \Difra\Ajaxer::load('someid', 'some <b>content</b>');
     $actions[] = ['action' => 'load', 'target' => 'someid', 'html' => 'some <b>content</b>'];
     \Difra\Ajaxer::close();
     $actions[] = ['action' => 'close'];
     \Difra\Ajaxer::reset();
     $actions[] = ['action' => 'reset'];
     \Difra\Envi::setUri('/current/page');
     \Difra\Ajaxer::confirm('Are you sure?');
     $actions[] = ['action' => 'display', 'html' => '<form action="/current/page" class="ajaxer"><input type="hidden" name="confirm" value="1"/>' . '<div>Are you sure?</div>' . '<input type="submit" value="' . \Difra\Locales::get('ajaxer/confirm-yes') . '"/>' . '<input type="button" value="' . \Difra\Locales::get('ajaxer/confirm-no') . '" onclick="ajaxer.close(this)"/>' . '</form>'];
     $this->assertEquals(\Difra\Ajaxer::getResponse(), json_encode(['actions' => $actions], \Difra\Ajaxer::getJsonFlags()));
     \Difra\Ajaxer::clean();
     $this->assertEquals(\Difra\Ajaxer::getResponse(), '[]');
     $this->assertFalse(\Difra\Ajaxer::hasProblem());
     \Difra\Ajaxer::reload();
     \Difra\Ajaxer::clean(true);
     $this->assertEquals(\Difra\Ajaxer::getResponse(), '[]');
     $this->assertTrue(\Difra\Ajaxer::hasProblem());
 }
示例#19
0
文件: up.php 项目: difra-org/difra
 /**
  * Upload image
  */
 public function indexAction()
 {
     \Difra\View::$rendered = true;
     if (!isset($_GET['CKEditorFuncNum'])) {
         die;
     }
     $funcnum = $_GET['CKEditorFuncNum'];
     if (!isset($_FILES['upload']) or $_FILES['upload']['error'] != UPLOAD_ERR_OK) {
         die("<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction({$funcnum}, '','" . \Difra\Locales::get('editor/upload-error') . "');</script>");
     }
     $img = Images::convert(file_get_contents($_FILES['upload']['tmp_name']));
     if (!$img) {
         die("<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction({$funcnum},'','" . \Difra\Locales::get('editor/upload-notimage') . "');</script>");
     }
     try {
         $link = \Difra\Libs\Vault::add($img);
         $link = "/up/tmp/{$link}";
     } catch (\Difra\Exception $ex) {
         die("<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction({$funcnum},'','" . $ex->getMessage() . "');</script>");
     }
     die('<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $funcnum . ",'" . $link . "');</script>");
 }
示例#20
0
 public function indexAction(\Difra\Param\AnyInt $id = null, \Difra\Param\NamedInt $page = null)
 {
     if (!is_null($id)) {
         /** @var \DOMElement $albumNode */
         $albumNode = $this->root->appendChild($this->xml->createElement('GalleryAlbum'));
         $album = \Difra\Plugins\Gallery\Album::get($id->val());
         if (!$album->load()) {
             throw new \Difra\View\HttpError(404);
         }
         $album->getXML($albumNode);
         $albumNode->setAttribute('id', $id);
         $sizesNode = $albumNode->appendChild($this->xml->createElement('sizes'));
         $album->getSizesXML($sizesNode);
         $Locale = \Difra\Locales::getInstance();
         $pageTitle = $Locale->getXPath('gallery/title-album') . $Locale->getXPath('gallery/arrow') . $album->getName();
         $this->root->setAttribute('pageTitle', $pageTitle);
     } else {
         $perpage = \Difra\Config::getInstance()->getValue('gallery', 'perpage');
         $listNode = $this->root->appendChild($this->xml->createElement('GalleryList'));
         \Difra\Plugins\Gallery::getInstance()->getAlbumsListXML($listNode, true, $page ? $page->val() : 1, $perpage ? $perpage : 20);
         $this->root->setAttribute('pageTitle', \Difra\Locales::getInstance()->getXPath('gallery/title'));
     }
 }
示例#21
0
文件: radio.php 项目: difra-org/difra
 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>');
         }
     }
 }
示例#22
0
文件: XML.php 项目: difra-org/difra
 /**
  * Fill output XML with some common data
  * @param \DOMDocument|null $xml
  * @param null $instance
  */
 public static function fillXML(&$xml = null, $instance = null)
 {
     $controller = Controller::getInstance();
     if (is_null($xml)) {
         $xml = $controller->xml;
         $node = $controller->realRoot;
     } else {
         $node = $xml->documentElement;
     }
     Debugger::addLine('Filling XML data for render: Started');
     // TODO: sync this with Envi::getState()
     $node->setAttribute('lang', Envi\Setup::getLocale());
     $node->setAttribute('site', Envi::getSubsite());
     $node->setAttribute('host', $host = Envi::getHost());
     $node->setAttribute('mainhost', $mainhost = Envi::getHost(true));
     $node->setAttribute('protocol', Envi::getProtocol());
     $node->setAttribute('fullhost', Envi::getURLPrefix());
     $node->setAttribute('instance', $instance ? $instance : View::$instance);
     $node->setAttribute('uri', Envi::getUri());
     $node->setAttribute('controllerUri', Action::getControllerUri());
     if ($host != $mainhost) {
         $node->setAttribute('urlprefix', Envi::getURLPrefix(true));
     }
     // get user agent
     Envi\UserAgent::getUserAgentXML($node);
     // ajax flag
     $node->setAttribute('ajax', (Request::isAjax() or isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'SwitchPage') ? '1' : '0');
     $node->setAttribute('switcher', (!$controller->cache and isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'SwitchPage') ? '1' : '0');
     // build and version number
     $node->setAttribute('build', Version::getBuild());
     $node->setAttribute('framework', Version::getFrameworkVersion(false));
     $node->setAttribute('frameworkLong', Version::getFrameworkVersion(true));
     // date
     /** @var $dateNode \DOMElement */
     $dateNode = $node->appendChild($xml->createElement('date'));
     $dateKeys = ['d', 'e', 'A', 'a', 'm', 'B', 'b', 'Y', 'y', 'c', 'x', 'H', 'M', 'S'];
     $dateValues = explode('|', strftime('%' . implode('|%', $dateKeys)));
     $dateCombined = array_combine($dateKeys, $dateValues);
     $dateNode->setAttribute('ts', time());
     foreach ($dateCombined as $k => $v) {
         $dateNode->setAttribute($k, $v);
     }
     // debug flag
     $node->setAttribute('debug', Debugger::isEnabled() ? '1' : '0');
     // config values (for js variable)
     $configNode = $node->appendChild($xml->createElement('config'));
     Envi::getStateXML($configNode);
     // menu
     if ($menuResource = Resourcer::getInstance('menu')->compile(View::$instance)) {
         $menuXML = new \DOMDocument();
         $menuXML->loadXML($menuResource);
         $node->appendChild($xml->importNode($menuXML->documentElement, true));
     }
     // auth
     Auth::getInstance()->getAuthXML($node);
     // locale
     Locales::getInstance()->getLocaleXML($node);
     // Add config js object
     $config = Envi::getState();
     $confJS = '';
     foreach ($config as $k => $v) {
         $confJS .= "config.{$k}='" . addslashes($v) . "';";
     }
     $node->setAttribute('jsConfig', $confJS);
     Debugger::addLine('Filling XML data for render: Done');
     Debugger::debugXML($node);
 }
示例#23
0
 /**
  * Render message body from template
  * @param string $template
  * @param array $data
  */
 public function render($template, $data)
 {
     $xml = new \DOMDocument();
     /** @var \DOMelement $root */
     $root = $xml->appendChild($xml->createElement('mail'));
     $root->setAttribute('host', Envi::getHost(true));
     Locales::getInstance()->getLocaleXML($root);
     if (!empty($data)) {
         foreach ($data as $k => $v) {
             $root->setAttribute($k, $v);
         }
     }
     $this->body = View::render($xml, $template, true);
 }
示例#24
0
 /**
  * Sets cookie that makes Ajaxer show notification popup
  * @param string $message
  * @param bool|string $error
  */
 public function notify($message, $error = false)
 {
     if ($error === false) {
         $error = 'ok';
     } elseif ($error === true) {
         $error = 'error';
     }
     $this->set('notify', ['type' => $error, 'message' => (string) $message, 'lang' => ['close' => Locales::get('notifications/close')]]);
 }
示例#25
0
 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/');
 }
示例#26
0
文件: menu.php 项目: difra-org/difra
 /**
  * Delete menu element
  * @param Difra\Param\AnyInt $id
  * @param Difra\Param\AjaxCheckbox $confirm
  */
 public function deleteAjaxAction(\Difra\Param\AnyInt $id, \Difra\Param\AjaxCheckbox $confirm = null)
 {
     if (!$confirm or !$confirm->val()) {
         \Difra\Ajaxer::display('<span>' . \Difra\Locales::get('cms/adm/menuitem/delete-item-confirm') . '</span>' . '<form action="/adm/content/menu/delete/' . $id . '" method="post" class="ajaxer">' . '<input type="hidden" name="confirm" value="1"/>' . '<input type="submit" value="Да"/>' . '<a href="#" onclick="ajaxer.close(this)" class="button">Нет</a>' . '</form>');
     } else {
         \Difra\Plugins\CMS\MenuItem::get($id->val())->delete();
         \Difra\Ajaxer::refresh();
         \Difra\Ajaxer::close();
     }
 }
示例#27
0
文件: post.php 项目: difra-org/difra
 public function updateAjaxActionAuth(Param\AjaxInt $id, Param\AjaxString $title, Param\AjaxSafeHTML $text, Param\AjaxString $tags = null)
 {
     if (!($post = Blogs\Post::getById($id))) {
         \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('blogs/notifies/post_not_found'), true);
         $this->view->redirect('/');
     }
     $Auth = \Difra\Auth::getInstance();
     if ($post->getUser() != $Auth->getEmail() && !$Auth->isModerator()) {
         $group = $post->getBlog()->getGroup();
         if (!$group or $group->getOwner() != \Difra\Auth::getInstance()->getEmail()) {
             \Difra\Libs\Cookies::getInstance()->notify(\Difra\Locales::getInstance()->getXPath('blogs/notifies/edit_post_denied'), true);
             $this->view->redirect('/');
         }
     }
     $post->setTitle($title->val());
     $post->setText($text->val());
     $post->setVisible(1);
     $post->save();
     $post = $post->getBlog()->getPost($post->getId());
     if (class_exists('Difra\\Plugins\\Tags')) {
         $tagsArray = Difra\Plugins\Tags::getInstance()->tagsFromString($tags);
         Difra\Plugins\Tags::getInstance()->update('posts', $id->val(), $tagsArray);
     }
     // убираем метку о редактировании поста
     unset($_SESSION['editPost']);
     $this->ajax->redirect($post->getUrl());
 }
示例#28
0
文件: item.php 项目: difra-org/difra
 /**
  * Устанавливает имя
  * @param string $name
  */
 public function setName($name)
 {
     $this->load();
     if ($this->name == $name) {
         return;
     }
     $this->name = $name;
     $this->link = Locales::getInstance()->makeLink($name);
     $this->modified = true;
 }
示例#29
0
文件: login.php 项目: difra-org/difra
 /**
  * After ajax password change stuff
  */
 protected function afterPasswordChangeAjax()
 {
     Ajaxer::notify(Locales::get('auth/password/changed'));
     Ajaxer::reset();
 }
示例#30
0
 /**
  * Change password using recovery link (already logged in stub)
  * @param AnyString $code
  */
 public function submitAjaxActionAuth(AnyString $code)
 {
     Ajaxer::error(Locales::get('auth/recover/already_logged'));
 }