public function testGetActiveRoute() { $request = new TestRequest(); $route = new TestRoute(array('url' => '/test_route')); // $myDispatcher = new TestDispatcher($request); $myDispatcher->addRoute($route); $cms = new CMS($myDispatcher); $cms->dispatch(); $active = $cms->getActiveRoute(); $this->assertEquals($route, $active); }
/** * Генерирует файл сайтмапа */ public static function generate() { $register = new SystemRegister('System/Sitemap'); if ($register->get('sitemap.xml')->value == 0) { return; } // Получаем все url сайта $sql = 'SELECT * FROM `' . SITEMAP_TABLE . '` where `visible`="1"'; $aSitemap = DB::query($sql); // $xmlDocument = new DOMDocument('1.0', 'utf-8'); // $urlset = $xmlDocument->createElement('urlset'); $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); foreach ($aSitemap as $row) { $url = $xmlDocument->createElement('url'); $loc = $xmlDocument->createElement('loc'); $lastmod = $xmlDocument->createElement('lastmod'); $changefreq = $xmlDocument->createElement('changefreq'); $priority = $xmlDocument->createElement('priority'); $loc->nodeValue = \Extasy\CMS::getWWWRoot() . substr($row['full_url'], 1); $lastmod->nodeValue = $row['date_updated']; $changefreq->nodeValue = $row['sitemap_xml_change']; $priority->nodeValue = $row['sitemap_xml_priority']; $url->appendChild($loc); $url->appendChild($lastmod); $url->appendChild($changefreq); $url->appendChild($priority); $urlset->appendChild($url); } $xmlDocument->appendChild($urlset); // Пишем в папку xml $xmlContents = $xmlDocument->saveXML(); file_put_contents(FILE_PATH . 'sitemap.xml', $xmlContents); }
/** * Возвращает код ссылки для удаления в станд. стиле * @param string $link */ public function deleteLink($link = '#') { $strings = CMS_Strings::getInstance(); $szDelete = $strings->getMessage('CMS_DELETE'); $szResult = '<nobr><img alt="' . $szDelete . '" src="' . CMS::getResourcesUrl() . 'extasy/pic/icons/delete.gif" /><a href="' . $link . '" onclick="return confirm(\'' . $strings->getMessage('CMS_CONFIRM_DELETE') . '\')">' . $szDelete . '</a></nobr>' . "\r\n"; return $szResult; }
public function getAdminViewValue() { $sitemapInfo = Sitemap_Sample::get($this->aValue); $result = sprintf(' %s <a href="http:%s" target="_blank">[На сайте]</a>', $sitemapInfo['name'], $sitemapInfo['full_url']); $result .= sprintf(' <a href="%ssitemap/edit.php?id=%d" target="_blank">[К администрированию]</a>', \Extasy\CMS::getDashboardWWWRoot(), $sitemapInfo['id']); return $result; }
/** * @param $path * @param $type * @param $szField */ public function show($path, $type, $szField) { $design = CMSDesign::getInstance(); // $path = stripslashes($path); $type = stripslashes($type); $szField = stripslashes($szField); $modelName = \Extasy\Model\Model::isModel($type); $fields = call_user_func($modelName, 'getFieldsInfo'); $aInfo = @getimagesize(\Extasy\CMS::getFilesPath() . ${$fields}[$szField]['base_dir'] . $path); $szFilename = \Extasy\CMS::getFilesHttpRoot() . $fields[$szField]['base_dir'] . $path; $x = '?' . rand(0, 1000000); if (isset($aInfo[2])) { $aParse['szFilename'] = $szFilename; } $design->popupBegin(); $design->popupHeader('Просмотр изображения'); $design->formBegin(); $design->br(); if (!empty($szFilename)) { print '<img src="' . $szFilename . $x . '">'; } $design->popupEnd(); $this->output(); }
public function begin($title = 'CMS - PopUp', $szAddToHead = '') { $szHTTP_ROOT = \Extasy\CMS::getWWWRoot(); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $title; ?> </title> <?php CMSDesign::getInstance()->layout->initialScriptsAndCSS(); ?> <?php echo $szAddToHead; ?> </head> <body class="PopupBody"> <table style="width:100%"> <tr> <td> <?php }
/** * Проверяет страницу, если она скрипт редиректит на страницу скрипта, иначе возвращает модель класса * @return */ protected function getModel($id) { // Получаем документ try { $aRow = SiteMap_Sample::get($id); $this->aSitemap = $aRow; } catch (SiteMapException $e) { $this->AddError(_msg('Документ не найден')); $this->jump('./'); } if (!empty($aRow['script'])) { if (!empty($aRow['script_admin_url'])) { $this->jump(\Extasy\CMS::getDashboardWWWRoot() . $aRow['script_admin_url']); } else { $this->addError('У данного скрипта нету панели редактирования'); $this->jump('./'); } } else { $this->szDocumentName = $aRow['document_name']; $this->nId = $aRow['document_id']; $validator = new \Extasy\Validators\IsModelClassNameValidator($aRow['document_name']); if (!$validator->isValid()) { throw new \ForbiddenException('Not a model class:' . $aRow['document_name']); } $szClassName = $aRow['document_name']; } $this->document = new $szClassName(); $found = $this->document->get($this->nId); if (empty($found)) { throw new NotFoundException('Document with id=' . $this->nId . ' not found'); } return $szClassName; }
public function main() { $title = 'Быстрое добавление'; $path = array(extasyTestModel::getLabel(extasyDocument::labelAllItems) => './index.php', $title => '#'); $input = new CInput(); $textarea = new CInput(); $input->name = 'level'; $textarea->name = 'urls'; $textarea->rows = 16; $textarea->style = 'width:99%'; // display design layout $design = CMSDesign::getInstance(); $design->layout->Begin($path); CMSDesign::insertScript(\Extasy\CMS::getResourcesUrl() . 'extasy/js/administrative/testSuite/quick_add.js'); $design->layout->documentBegin(); $design->text->header("Введите url списком. Каждый адрес в отдельной строке"); $design->forms->begin(); $design->table->begin(); $design->table->fullRow('Список url-ов для сканирования:'); $design->table->fullRow($textarea); $design->table->end(); $design->forms->submit('submit', 'Сохранить'); $design->forms->end(); $design->text->header("Добавление URL-ов из карты сайта"); $design->forms->begin('./quick_add', 'post', 'quickAddForm'); $design->table->begin(); $design->table->row2cell('Добавить N-уровней sitemap-дерева', $input); $design->table->end(); $design->forms->submit('getTree', 'Добавить к списку'); $design->forms->end(); $design->layout->documentEnd(); $design->layout->end(); $this->output(); }
protected function assertUrlMatchesRoute($route, $url) { $request = new \Faid\Request\HttpRequest(); $request->url($url); $route = \Extasy\CMS::getInstance()->getDispatcher()->getNamed($route, $request); $this->assertTrue((bool) $route->test($request)); }
public function testParseData() { $item = new MenuItem(); $actual = $item->getParseData(); $editLinkBase = sprintf('%ssitemap/edit.php?id=', CMS::getDashboardWWWRoot()); $expected = ['name' => self::Title, 'link' => '#', 'children' => [['link' => '#', 'name' => 'first', 'children' => [['link' => $editLinkBase . '1', 'name' => 'Редактировать'], ['link' => '#', 'name' => 'third', 'children' => [['link' => $editLinkBase . '3', 'name' => 'Редактировать']]]]], ['link' => '#', 'name' => 'second', 'children' => [['link' => $editLinkBase . '2', 'name' => 'Редактировать']]]]]; $this->assertEquals($expected, $actual); }
/** * Returns timthumb image url * @param string $url image URL * @param int $w width * @param int $h height * @return string */ public static function getTimthumbUrl($url, $w = 0, $h = 0) { $src = sprintf('%sextasy/timthumb/timthumb.php?src=%s', \Extasy\CMS::getResourcesUrl(), urlencode($url)); if (!empty($w)) { $src .= sprintf('&w=%d', $w); } if (!empty($h)) { $src .= sprintf('&h=%d', $h); } return $src; }
public function generate() { $szResult = <<<EOD <link type="text/css" rel="stylesheet" href="%sextasy/dhtml_calendar/dhtmlgoodies_calendar.css" media="screen"></LINK> <SCRIPT type="text/javascript" src="%sextasy/dhtml_calendar/dhtmlgoodies_calendar.js"></script> <input type="text" id="%s" name="%s" value="%s" /> <input type="button" value="..." class="calendarButton" onclick="displayCalendar(document.getElementById('%s'),'yyyy-mm-dd',this)"> EOD; $szResult = sprintf($szResult, CMS::getResourcesUrl(), CMS::getResourcesUrl(), htmlspecialchars($this->szName), htmlspecialchars($this->szName), $this->szDate, htmlspecialchars($this->szName)); return $szResult; }
public function main() { $design = CMSDesign::getInstance(); $scripts = array(CMS::getResourcesUrl() . 'extasy/ext3/ux/treegrid/TreeGridSorter.js', CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridColumnResizer.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridNodeUI.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridLoader.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridColumns.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGrid.js", CMS::getResourcesUrl() . 'extasy/Dashboard/administrate/acl.js'); $title = 'Редактирование списка прав'; $begin = array($title => '#'); $this->outputHeader($begin, $title, $scripts); ?> <div id="actionLayout"></div> <?php $this->outputFooter(); $this->output(); }
/** * Отображает вкладку для редактирования sitemap-страницы * @param array $sitemap ряд из таблицы SITEMAP * @param int $tabSheetId вкладка :) */ public static function outputSitemapTabSheet($sitemap, $tabSheetId, $additionalProperties = array()) { self::$sitemap = $sitemap; $design = CMSDesign::getInstance(); $szOpenLink = '<a target="_blank" href="http:' . self::$sitemap['full_url'] . '" >Открыть</a>'; $szLink = <<<HTML \t\t\t\t<a href="#" onclick=" \t\t\t\twindow.open('%ssitemap/move.php?id=%d', \t\t\t\t'_blank', \t\t\t\t'location=no,resizable=no,scrollbars=yes,titlebar=no,toolbar=no,menubar=no,width=800,height=800'); return false; ">Переместить документ</a> HTML; $szLink = sprintf($szLink, \Extasy\CMS::getDashboardWWWRoot(), $sitemap['id']); // Выводим $design->tabContentBegin($tabSheetId); // Вывод блока видимости страницы self::outputVisibility($sitemap['visible']); self::outputAliases(); // Вызов вкладки Sitemap.XML self::outputSitemapXML(); $design->tableBegin(); $design->row2cell('Создан', $sitemap['date_created']); $design->row2cell('Последнее изменение', $sitemap['date_updated']); $design->row2cell('Ревизия', $sitemap['revision_count']); $design->row2cell('Текущий URL', 'http:' . $sitemap['full_url'] . ' ' . $szOpenLink . ' ' . $szLink); if (!empty($sitemap['script'])) { $design->row2cell('Путь к скрипту', $sitemap['script']); } else { self::outputDocumentInfo($sitemap['document_id'], $sitemap['document_name']); } // Дополнительные св-ва foreach ($additionalProperties as $key => $row) { $design->row2cell($key, $row); } $design->tableEnd(); // Если это скрипт, то добавляем еще поле if (!empty($sitemap['script'])) { // Вкладка карты сайта $design->header2('Положение в карте сайта'); $design->tableBegin(); // self::outputNameFormFields(); self::outputUrlFormFields(); self::outputChangeParentFormFields(); $design->tableEnd(); } // Получаем сп $design->tabContentEnd(); }
/** * * @param DomDocument $index * @param DomDocument $sitemap */ protected function storeSitemap($index, $sitemap) { // Записываем текущий файл $name = sprintf('sitemap_list_%d.xml', $index->getElementsByTagName('sitemap')->length); $result = $sitemap->saveXML(); file_put_contents(FILE_PATH . $name, $result); // // $sitemapEl = $index->createElement('sitemap'); $loc = $index->createElement('loc', 'http:' . \Extasy\CMS::getWWWRoot() . 'files/' . $name); $lastMod = $index->createElement('lastmod', date('Y-m-d')); $sitemapEl->appendChild($loc); $sitemapEl->appendChild($lastMod); $index->getElementsByTagName('sitemapindex')->item('0')->appendChild($sitemapEl); }
public function setSitemapInfo($urlInfo) { $adminUrl = ''; // Если это скрипт и у него обозначен admin_page if (!empty($urlInfo['script']) && !empty($urlInfo['script_admin_url'])) { $adminUrl = \Extasy\CMS::getDashboardWWWRoot() . $urlInfo['script_admin_url']; } elseif (!empty($urlInfo['document_name'])) { if (ModelHelper::isEditable($urlInfo['document_name'])) { $adminUrl = \Extasy\CMS::getDashboardWWWRoot() . 'sitemap/edit.php?id=' . $urlInfo['id']; } } if (!empty($adminUrl)) { $this->setAdminUrl($adminUrl); } }
public function __construct() { $this->type = \Extasy\CMS::getInstance()->getDispatcher()->getRequest()->get('type'); if (!in_array($this->type, ['vkontakte', 'twitter', 'odnoklassniki'])) { throw new \InvalidArgumentException('Unknown social network'); } switch ($this->type) { case 'vkontakte': $this->api = VkontakteApiFactory::getInstance(); break; case 'twitter': $this->api = TwitterApiFactory::getInstance(); break; case 'odnoklassniki': $this->api = OdnoklassnikiApiFactory::getInstance(); break; } }
public function main() { $szTitle = 'Редактор реестра'; $aBegin = array($szTitle => '#'); // $aScripts = array(CMS::getResourcesUrl() . 'extasy/ext3/ux/treegrid/TreeGridSorter.js', CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridColumnResizer.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridNodeUI.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridLoader.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGridColumns.js", CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/TreeGrid.js", CMS::getResourcesUrl() . 'extasy/Dashboard/administrate/regedit.js'); $css = CMS::getResourcesUrl() . "extasy/ext3/ux/treegrid/treegrid.css"; $this->outputExtJSHeader($aBegin, $szTitle, $aScripts, $css); $design = CMSDesign::getInstance(); $design->contentBegin(); ?> <div id="regedit_layer"><!-- --></div> <?php $design->contentEnd(); // $this->outputFooter(); $this->output(); }
public function main() { $szTitle = _msg('mySQL-консоль'); $aBegin = array(_msg('Администрирование') => 'index.php', $szTitle => '#'); $aButton = array(_msg('Получить всю БД') => 'sql.php?dump=1'); $this->outputHeader($aBegin, $szTitle, CMS::getResourcesUrl() . 'extasy/Dashboard/administrate/sql_console.js'); // Выводим список запросов $design = CMSDesign::getInstance(); $this->outputError(); $design->decor->buttons($aButton); $design->text->header(_msg('Последние запросы:')); $i = 0; $szLastSQL = $this->outputSessionRequests(); $this->outputResults($szLastSQL); $this->outputRequestForm($szLastSQL); $this->outputImportDBForm(); // Выводим футер $this->outputFooter(); $this->output(); }
public function __construct() { // $auth = CMSAuth::getInstance(); if (!$auth->isSuperAdmin(UsersLogin::getCurrentSession())) { $this->addError('Access denied'); $this->jump(\Extasy\CMS::getDashboardWWWRoot()); } parent::__construct(); // Вызов формы редактирования $this->addGet('id', 'showEdit'); // Вызов формы добавления $this->addGet('add', 'showAdd'); // Вызов функции редактирования $this->addPost('id,login,password,rights', 'postEdit'); $this->addPost('id,login,password', 'postEdit'); // Вызов функции добавления $this->addPost('login,password,rights', 'postAdd'); $this->addPost('login,password', 'postAdd'); // Удаление $this->addPost('id', 'delete'); }
protected function searchSitemap() { try { ACLUser::checkCurrentUserGrants([SitemapModel::PermissionName]); $items = \Sitemap_Sample::search($this->searchPhrase, 0, 10); } catch (\Exception $e) { $items = []; } foreach ($items as $row) { $isScript = !empty($row['script_admin_url']); $add = new SearchResultModel(); $add->title = $row['name']; $add->icon = 'glyphicon glyphicon-user'; // if (!$isScript) { $route = CMS::getInstance()->getDispatcher()->getNamed('dashboard.sitemap.manage'); $add->link = $route->buildUrl() . '?id=' . $row['id']; } else { $add->link = sprintf('http://%s%s', CMS::getDashboardWWWRoot(), $row['script_admin_url']); } $this->results[] = $add; } }
/** * Отображает форму редактирования */ protected function outputEditingForm($sheets, $controls) { $sheetsEmpty = false; if (empty($sheets)) { $sheetsEmpty = true; $sheets = array(array('id' => 'mainTab', 'title' => 'Ошибка')); } if ($this->schema->getSitemapLink()) { $sitemapInfo = Sitemap_Sample::get($this->schema->getSitemapLink()); array_push($sheets, array('id' => 'sitemapTab', 'title' => 'Свойства')); } // $design = CMSDesign::getInstance(); $design->forms->begin(); // Вывод вкладок $design->tabs->sheetsBegin($sheets); // По вкладкам вывод $i = 0; if (!empty($controls)) { foreach ($controls as $list) { $design->tabs->contentBegin($sheets[$i]['id']); $design->table->begin(); foreach ($list as $control) { $design->table->row2cell($control->getTitle(), $control->outputInForm()); } $design->table->end(); $design->tabs->contentEnd(); $i++; } } else { $design->tabs->contentBegin($sheets[0]['id']); $design->decor->contentBegin(); printf('У данной схемы пока нету вкладок для редактирования<br/>'); $auth = CMSAuth::getInstance(); if ($auth->isSuperAdmin(UsersLogin::getCurrentUser())) { printf('Перейти к <a href="%scconfig/manage.php?schema=%s&edit=1">управлению</a> конфигом', \Extasy\CMS::getDashboardWWWRoot(), $this->schema->getName()); } $design->decor->contentEnd(); $design->tabs->contentEnd(); } if (!empty($sitemapInfo)) { $auth = CMSAuth::getInstance(); if ($auth->isSuperAdmin(UsersLogin::getCurrentUser())) { $link = sprintf('<a href="%scconfig/manage.php?schema=%s" target="_blank">Управление конфигом</a>', \Extasy\CMS::getDashboardWWWRoot(), $this->schema->getName()); $property = array('' => $link); } else { $property = array(); } SitemapCMSForms::outputSitemapTabSheet($sitemapInfo, $sheets[sizeof($sheets) - 1]['id'], $property); } $design->tabs->sheetsEnd(); $design->forms->hidden('schema', $this->schema->getName()); // Вывод конца $design->forms->submit('submit', 'Сохранить'); $design->forms->end(); $this->outputFooter(); }
/** * Создает документ * @param $document string имя документа * @param $place int индекс документ */ public function add($document, $place) { $place = IntegerHelper::toNatural($place); // try { $validator = new \Extasy\Validators\IsModelClassNameValidator($document); if (!$validator->isValid()) { throw new ForbiddenException('Not a model'); } $model = new $document(); $model->createEmptyDocument($place); } catch (Exception $e) { die($e); throw $e; } $this->jump(\Extasy\CMS::getDashboardWWWRoot() . 'sitemap/edit.php?id=' . $model->getSitemapId()); }
/** * * @return resource */ protected function getCurl() { $url = $this->url->getValue(); $urlInfo = parse_url($url); if (empty($urlInfo['host'])) { $url = \Extasy\CMS::getWWWRoot() . substr($url, 1); } $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_URL => $url)); if (!empty($this->method->getValue())) { curl_setopt($ch, CURLOPT_POST, true); $parameters = trim($this->parameters->getValue()); if (!empty($parameters)) { $postFields = json_decode($parameters, JSON_OBJECT_AS_ARRAY); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); } } return $ch; }
public function __construct($accessToken = null) { $this->config = \Faid\Configure\Configure::read(self::ConfigureKey); $this->config['redirect_url'] = sprintf('http://%s/oauth/vkontakte/', \Extasy\CMS::getMainDomain()); $this->token = $accessToken; }
/** * */ protected function getInitialCookies() { return sprintf(".%s\tTRUE\t/\tFALSE\t%d\t%s\t%s", \Faid\Configure\Configure::read('MainDomain'), time() + 3600, CMS::UnitTestCookieName, CMS::getUnitTestCookie()); }
public static function outputLink($userId, $userLogin) { $result = sprintf('<a href="%susers/manage?id=%d" target="_blank">%s</a>', \Extasy\CMS::getDashboardWWWRoot(), $userId, $userLogin); return $result; }
public function main() { $this->jump(\Extasy\CMS::getDashboardWWWRoot()); }
public function getViewValue() { if (file_exists($this->getValue())) { return '<img src="' . \Extasy\CMS::getFilesHttpRoot() . $this->szDir . $this->document->id->getValue() . '.' . $this->szExtension . '" alt="' . htmlspecialchars($this->aValue) . '"/>'; } }
protected static function getCurrentBaseUrl() { $request = \Extasy\CMS::getInstance()->getDispatcher()->getRequest(); $result = sprintf('//%s/', $request->domain()); return $result; }