示例#1
0
 public function testSetType()
 {
     $register = new SystemRegister('AppData');
     $register->test1->value1->type = 'number';
     //
     $this->assertEquals('number', $register->get('test1/value1')->type);
 }
示例#2
0
 /**
  * Генерирует файл сайтмапа
  */
 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);
 }
示例#3
0
    /**
     * Тест установки sitemap-индекса к конфигу  
     */
    public function testSelectControlNames()
    {
        SystemRegisterSample::clearCache();
        $fileList = \DAO_FileSystem::getInstance()->getFileList(LIB_PATH . 'custom_config/controls/');
        $list = CConfigControlManager::selectAll();
        $this->assertEquals(sizeof($fileList), sizeof($list));
        // Добавляем в реестр файлег, но не пишем класс
        $path = LIB_PATH . 'custom_config/test.php';
        $register = new SystemRegister('Applications/cconfig/user_control_path');
        $register->insert('test', $path, '');
        file_put_contents($path, '');
        $list = CConfigControlManager::selectAll();
        $this->assertEquals(sizeof($fileList), sizeof($list));
        // Заполняем инфо о классе, таким образом класс становится доступным
        $path = 'custom_config/test2.php';
        $contents = <<<EOD
<?
class CConfigControl_Test2 extends CConfigBaseControl {
\tpublic function getXType() {
\t\treturn "test2";
\t}
}
?>
EOD;
        file_put_contents(LIB_PATH . $path, $contents);
        $register->insert('test2', $path, '');
        $list = CConfigControlManager::selectAll();
        $this->assertEquals(sizeof($fileList) + 1, sizeof($list));
    }
示例#4
0
 /**
  * Очищаем системный реестр
  */
 protected function clearSystemRegister()
 {
     SystemRegisterSample::clearCache();
     $register = new SystemRegister('Applications/cconfig');
     $register->delete('user_control_path');
     SystemRegisterSample::clearCache();
     $register->insert('user_control_path', null, '', SYSTEMREGISTER_BRANCH_TYPE);
 }
示例#5
0
 /**
  * Тестирование удаления элементов
  */
 public function testDelete()
 {
     $register = new SystemRegister('/AppData');
     //
     $register->delete('test1/value1');
     //
     try {
         $szValue = $register->test1->value1->value;
         $this->Fail('Property must be deleted');
     } catch (SystemRegisterException $e) {
     }
 }
示例#6
0
 /**
  * Проверяем удаляется ли из кеша
  * @expectedException SystemRegisterException
  */
 public function testCacheOnDeletedItem()
 {
     $register = new SystemRegister();
     $register->insert('AppData/test1/new_value', 'New Value');
     //
     $szValue = $register->get('AppData/test1/new_value');
     //
     $test1 = $register->get('AppData/test1');
     $register->delete('AppData/test1/new_value');
     //
     $test1->get('new_value');
 }
示例#7
0
 protected static function outputSitemapXML()
 {
     $register = new SystemRegister('System/Sitemap/');
     if ($register->get('sitemap.xml')->value) {
         require_once CONTROL_PATH . 'input.php';
         require_once CONTROL_PATH . 'select.php';
         //
         $priority = new CInput();
         $priority->name = 'sitemap_xml[priority]';
         $priority->value = self::$sitemap['sitemap_xml_priority'];
         $changefreq = new CSelect();
         $changefreq->items = array(array('id' => 'always', 'name' => 'Всегда'), array('id' => 'hourly', 'name' => 'Почасово'), array('id' => 'daily', 'name' => 'Ежедневно'), array('id' => 'weekly', 'name' => 'Еженедельно'), array('id' => 'monthly', 'name' => 'Ежемесячно'), array('id' => 'yearly', 'name' => 'Ежегодно'), array('id' => 'never', 'name' => 'Никогда'));
         $changefreq->name = 'sitemap_xml[change]';
         $changefreq->current = self::$sitemap['sitemap_xml_change'];
         $design = CMSDesign::getInstance();
         $design->header('Sitemap.XML');
         $design->tableBegin();
         $design->row2cell('Приоритет', $priority->generate());
         $design->row2cell('Частота', $changefreq->generate());
         $design->TableEnd();
     }
 }
示例#8
0
文件: users.php 项目: gudwin/extasy
 protected function displayRights($rightsString)
 {
     // Получаем все права существующие в системе
     $register = new SystemRegister('System/CMS/userRights');
     $fullRightsList = SystemRegisterHelper::exportData($register->getId());
     $usersRights = explode("\r\n", $rightsString);
     // Перебор прав
     $result = array();
     foreach ($fullRightsList as $key => $row) {
         $checkbox = new CCheckbox();
         $checkbox->name = 'rights[]';
         $checkbox->value = $key;
         $checkbox->title = $row['comment'];
         if (in_array($key, $usersRights)) {
             $checkbox->checked = true;
         }
         $result[] = $checkbox;
     }
     return implode('<br/>', $result);
 }
示例#9
0
<?php

namespace Extasy\tests\Audit;

use Faid\DBSimple;
use Extasy\tests\Helper as TestsHelper;
use UserAccount;
use ACL;
use Extasy\Audit\Api\ApiOperation;
use Extasy\Audit\Record;
use Extasy\Audit\Log;
use Extasy\tests\system_register\Restorator;
use Extasy\Columns\Password as passwordColumn;
$register = new \SystemRegister('/System/');
try {
    $register->delete('Audit');
} catch (\Exception $e) {
}
Restorator::restore();
\SystemRegisterSample::createCache();
TestsHelper::dbFixture(ACL_TABLE, array());
ACL::create(ApiOperation::RightName);
// user record
TestsHelper::dbFixture(USERS_TABLE, array(array('login' => 'login', 'password' => passwordColumn::hash('testtest')), array('login' => 'guest', 'password' => passwordColumn::hash('testtest'))));
// grant user permission
$user = UserAccount::getByLogin('login');
ACL::grant(ApiOperation::RightName, $user->obj_rights->getEntity());
\UsersLogin::login('login', 'testtest');
// base logs
TestsHelper::dbFixture(Log::getTableName(), array(array('name' => 'Log1', 'critical' => 0, 'enable_logging' => 1), array('name' => 'Log2', 'critical' => 1, 'enable_logging' => 1)));
// base records
示例#10
0
 protected static function loadConfig()
 {
     $register = new \SystemRegister(self::SystemRegisterPath);
     self::$config = \SystemRegisterHelper::exportData($register->getId());
 }
示例#11
0
 public function testImportUpdatingFileCacheWithDeletion()
 {
     $system = new SystemRegister('/System/');
     $this->assertEquals(false, isset($system->array));
     SystemRegisterHelper::import($system, array('XX' => '1', 'yy' => '2', 'Gisma' => 'rulit!', 'array' => array('0' => 'value1', '1' => array('1' => '2', '3' => '4'))));
     $this->assertEquals(true, isset($system->array));
     //
     SystemRegisterSample::loadAll();
     $base = new SystemRegister('System');
     $this->assertEquals(true, isset($system->array));
     $base->delete('array');
     $this->assertEquals(false, isset($base->array));
     //
     SystemRegisterSample::clearCache();
     SystemRegisterSample::loadAll();
     $system = new SystemRegister('/System/');
     $this->assertEquals(false, isset($base->array));
 }
示例#12
0
 /**
  * @expectedException SystemRegisterException
  */
 public function testfChild()
 {
     $register = new SystemRegister('/AppData');
     // Некорректный вызов
     $register->get('test1/value2');
 }
示例#13
0
文件: sample.php 项目: gudwin/extasy
 /**
  * Обновляет лист в бд
  */
 public static function update(SystemRegister $parent, $id, $szName, $szValue, $szComment, $szType)
 {
     // Экранируем переменные
     $id = intval($id);
     $szName = \Faid\DB::escape($szName);
     $szValue = \Faid\DB::escape($szValue);
     $szComment = \Faid\DB::escape($szComment);
     $szType = \Faid\DB::escape($szType);
     // запрос
     $sql = 'UPDATE `%s` SET `name`="%s",`value`="%s",`comment`="%s",`type`="%s" WHERE `id`="%s"';
     $sql = sprintf($sql, SYSTEMREGISTER_TABLE, $szName, $szValue, $szComment, $szType, $id);
     //
     DB::post($sql);
     // обновляем кеш предка
     self::updateChildCache($parent->getId());
     self::updateGetCache($szName, $parent->getId());
     return $id;
 }
示例#14
0
文件: cms.php 项目: gudwin/extasy
 public static function getRootDocuments()
 {
     $register = new SystemRegister(self::RootDocumentsKey);
     return SystemRegisterHelper::export($register->getId());
 }
示例#15
0
 /**
  * Возвращает имена классов всех контролов, с которыми в данный момент работает CConfig
  * @return array
  */
 public static function selectAll()
 {
     // Грузим все файлы в папке контролов
     $files = DAO::getInstance('fs')->getFileList(CCONFIG_CONTROLS_PATH);
     $result = array();
     foreach ($files as $row) {
         try {
             $row = basename($row, '.php');
             $result[$row] = self::loadControl($row);
         } catch (Exception $e) {
         }
     }
     // Дополняем классами, записанными в реестре
     $register = new SystemRegister('Applications/cconfig/user_control_path');
     $paths = SystemRegisterSample::selectChild($register->getId());
     foreach ($paths as $row) {
         try {
             $result[$row['name']] = self::loadControl($row['name']);
         } catch (Exception $e) {
         }
     }
     return $result;
 }
示例#16
0
<?php

$register = new SystemRegister('/System/CMS');
$register->delete('Menu');
$register->delete('routes');
SystemRegisterSample::createCache();
示例#17
0
文件: helper.php 项目: gudwin/extasy
 /**
  * Возвращает значение указанного элемента системного реестра
  * @param $path
  * @return string
  */
 public static function getValue($path)
 {
     $register = new SystemRegister('/');
     return $register->get($path)->value;
 }
示例#18
0
<?php

$register = new SystemRegister('System/CMS');
$register->delete('display_administrate_scripts');
SystemRegisterSample::clearCache();
示例#19
0
<?php

$register = new SystemRegister('/System/CMS/routes/administrate');
$register->insert('audit', 'class://Extasy\\Audit\\Controllers\\Audit/startup');
SystemRegisterSample::createCache();