Esempio n. 1
0
 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');
 }
Esempio n. 2
0
 /**
  * @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);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
 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'));
 }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
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();
 }
Esempio n. 7
0
 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'));
     }
 }
Esempio n. 8
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'));
     }
 }
Esempio n. 9
0
 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();
 }
Esempio n. 10
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();
 }
Esempio n. 11
0
 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]));
     }
 }
Esempio n. 12
0
 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();
 }
Esempio n. 13
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();
 }
Esempio n. 14
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'));
     }
 }
Esempio n. 15
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\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/');
 }
Esempio n. 16
0
 public function deleteAjaxAction(\Difra\Param\AnyInt $id)
 {
     \Difra\Plugins\Announcements::getInstance()->deleteLocation($id->val());
     $this->ajax->notify(\Difra\Locales::getInstance()->getXPath('announcements/adm/locations/deleted'));
     $this->ajax->refresh();
 }
Esempio n. 17
0
 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());
 }
Esempio n. 18
0
 /**
  * Устанавливает имя
  * @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;
 }
Esempio n. 19
0
 /**
  * Возвращает объект анонса события в xml
  * @param \DOMNode $node
  */
 public function getXML($node)
 {
     $Locale = Locales::getInstance();
     $eventNode = $node->appendChild($node->ownerDocument->createElement('event'));
     $eventNode->appendChild($node->ownerDocument->createElement('id', $this->id));
     $eventNode->appendChild($node->ownerDocument->createElement('user', $this->user));
     $eventNode->appendChild($node->ownerDocument->createElement('group', $this->group));
     $eventNode->appendChild($node->ownerDocument->createElement('category', $this->category));
     $eventNode->appendChild($node->ownerDocument->createElement('location', $this->location));
     $eventNode->appendChild($node->ownerDocument->createElement('title', htmlspecialchars($this->title)));
     $eventNode->appendChild($node->ownerDocument->createElement('link', $this->id . '-' . $this->link));
     $eventNode->appendChild($node->ownerDocument->createElement('shortDescription', $this->shortDescription));
     $eventNode->appendChild($node->ownerDocument->createElement('description', $this->description));
     $eventNode->appendChild($node->ownerDocument->createElement('status', $this->getStatus()));
     if (!is_null($this->fromEventDate) && $this->fromEventDate != '' && $this->fromEventDate != '0000-00-00' && $this->fromEventDate != 'null') {
         $fromEventDate = $Locale->getDateFromMysql($this->fromEventDate . ' 00:00:00');
         $dateNode = $eventNode->appendChild($node->ownerDocument->createElement('fromEventDate', $fromEventDate));
         $this->reFormateDate($dateNode, $this->fromEventDate);
         $eventNode->appendChild($node->ownerDocument->createElement('fromToEventDiff', $this->getEventPeriodDays()));
     }
     $dateNode = $eventNode->appendChild($node->ownerDocument->createElement('eventDate', $Locale->getDateFromMysql($this->eventDate . ' 00:00:00')));
     $this->reFormateDate($dateNode, $this->eventDate);
     $dateNode = $eventNode->appendChild($node->ownerDocument->createElement('beginDate', $Locale->getDateFromMysql($this->beginDate . ' 00:00:00')));
     $this->reFormateDate($dateNode, $this->beginDate);
     $dateNode = $eventNode->appendChild($node->ownerDocument->createElement('endDate', $Locale->getDateFromMysql($this->endDate . ' 00:00:00')));
     $this->reFormateDate($dateNode, $this->endDate);
     $isoDateNode = $eventNode->appendChild($eventNode->ownerDocument->createElement('isoDate'));
     $this->_getIsoDate($isoDateNode);
     $eventNode->appendChild($node->ownerDocument->createElement('visible', $this->visible));
     $eventNode->appendChild($node->ownerDocument->createElement('priority', $this->priority));
     $eventNode->appendChild($node->ownerDocument->createElement('modified', $Locale->getDateFromMysql($this->modified, true)));
     $eventNode->appendChild($node->ownerDocument->createElement('statusInDays', $this->statusInDays));
     /** @var \DOMElement $userNode */
     $userNode = $eventNode->appendChild($node->ownerDocument->createElement('userData'));
     if (!empty($this->userData)) {
         foreach ($this->userData as $k => $value) {
             $userNode->setAttribute($k, $value);
         }
     }
     $this->getAdditionalXML($eventNode);
     $this->getScheduleXML($eventNode);
     $this->getLocationXML($eventNode);
     if (Plugger::isEnabled('blogs') && !empty($this->groupData)) {
         /** @var \DOMElement $groupNode */
         $groupNode = $eventNode->appendChild($node->ownerDocument->createElement('groupData'));
         foreach ($this->groupData as $k => $value) {
             $groupNode->setAttribute($k, $value);
         }
     }
 }
Esempio n. 20
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/');
 }
Esempio n. 21
0
 public function saveAjaxAction(\Difra\Param\AjaxString $name, \Difra\Param\AjaxHTML $description, \Difra\Param\AjaxString $release = null, \Difra\Param\AjaxString $link = null, \Difra\Param\AjaxString $link_caption = null, \Difra\Param\AjaxString $software = null, \Difra\Param\AjaxInt $id = null, \Difra\Param\AjaxData $roles = null, \Difra\Param\AjaxFiles $image = null)
 {
     if (is_null($id) && !\Difra\Plugins\Portfolio::checkURI($name->val())) {
         $this->ajax->invalid('name');
         $this->ajax->status('name', \Difra\Locales::getInstance()->getXPath('portfolio/adm/notify/dupName'), 'problem');
         return;
     }
     if ($id) {
         $entry = \Difra\Unify::getObj('PortfolioEntry', (string) $id);
     } else {
         $entry = \Difra\Unify::createObj('PortfolioEntry');
     }
     $entry->name = $name;
     if (!is_null($release)) {
         $release = strtotime($release->val() . ' 00:00:00');
         $release = date('Y-m-d', $release);
     }
     $entry->description = $description;
     $entry->release = $release;
     $entry->link = $link;
     $entry->link_caption = $link_caption;
     $entry->software = $software;
     $entry->uri = \Difra\Locales::getInstance()->makeLink($name->val());
     $sortedAuthors = [];
     if (!is_null($roles)) {
         $authors = $roles->val();
         if (!empty($authors)) {
             foreach ($authors as $line) {
                 if (empty($line)) {
                     continue;
                 }
                 $role = false;
                 $contributors = [];
                 foreach ($line as $k => $v) {
                     if ($k === 'role') {
                         $role = $v;
                     } else {
                         $contributors[] = $v;
                     }
                 }
                 if ($role and !empty($contributors)) {
                     $sortedAuthors[] = ['role' => $role, 'contibutors' => $contributors];
                 }
             }
         }
     }
     $entry->authors = $sortedAuthors;
     try {
         $entry->save();
     } catch (\Difra\Exception $x) {
         $x->notify();
         $this->ajax->notify($x->getMessage());
         return;
     }
     if (!is_null($image)) {
         if ($id) {
             $eId = $id->val();
         } else {
             $eId = $entry->getPrimaryValue();
         }
         try {
             \Difra\Plugins\Portfolio::saveImages($eId, $image);
         } catch (\Difra\Exception $x) {
             $x->notify();
             $this->ajax->notify($x->getMessage());
             return;
         }
     }
     $Locales = \Difra\Locales::getInstance();
     if ($id) {
         $notify = $Locales->getXPath('portfolio/adm/notify/edited');
     } else {
         $notify = $Locales->getXPath('portfolio/adm/notify/added');
     }
     $this->ajax->notify($notify);
     $this->ajax->redirect('/adm/content/portfolio/');
 }
Esempio n. 22
0
 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'));
 }
Esempio n. 23
0
 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'));
 }
Esempio n. 24
0
 /**
  * Возвращает XML новости
  * @param \DOMNode $node
  */
 public function getXML($node, $withoutText = false)
 {
     $Locale = \Difra\Locales::getInstance();
     //getDateFromMysql
     $newsNode = $node->appendChild($node->ownerDocument->createElement('publication'));
     $newsNode->setAttribute('id', $this->id);
     $newsNode->setAttribute('title', $this->title);
     $newsNode->setAttribute('link', $this->link);
     $newsNode->setAttribute('trueLink', $this->getTrueLink());
     $newsNode->setAttribute('pubDate', $Locale->getDateFromMysql($this->pubDate));
     $newsNode->setAttribute('viewDate', $Locale->getDateFromMysql($this->viewDate));
     if (!is_null($this->stopDate) && $this->stopDate != '0000-00-00 00:00:00') {
         $newsNode->setAttribute('stopDate', $Locale->getDateFromMysql($this->stopDate));
     }
     $newsNode->setAttribute('visible', $this->visible);
     $newsNode->setAttribute('important', $this->important);
     if (!$withoutText) {
         $newsNode->setAttribute('body', $this->body);
         $newsNode->setAttribute('announcement', $this->announcement);
     }
     if (!is_null($this->sourceName) && $this->sourceName != '') {
         $newsNode->setAttribute('sourceName', $this->sourceName);
     }
     if (!is_null($this->sourceURL) && $this->sourceURL != '') {
         $newsNode->setAttribute('sourceURL', $this->sourceURL);
     }
 }
Esempio n. 25
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);
 }
Esempio n. 26
0
 /**
  * Проверяет на дубликаты генерируемый ури работы портфолио
  * @param $title
  * @return bool
  */
 public static function checkURI($title)
 {
     $entry = new \Difra\Unify\Search('PortfolioEntry');
     $entry->addCondition('uri', \Difra\Locales::getInstance()->makeLink($title));
     $list = $entry->getList();
     return !is_null($list) ? false : true;
 }
Esempio n. 27
0
 /**
  * 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);
 }
Esempio n. 28
0
 /**
  * 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'));
 }
Esempio n. 29
0
 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>');
         }
     }
 }
Esempio n. 30
0
 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>');
 }