├── README.md ├── admin └── menu.php ├── include.php ├── install ├── db │ ├── install.sql │ └── uninstall.sql └── index.php ├── lang └── ru │ └── lib │ └── data.php └── lib ├── data.php └── test.php /README.md: -------------------------------------------------------------------------------- 1 | # Пример реализации простого модуля 1C:Битрикс d7 2 | -------------------------------------------------------------------------------- /admin/menu.php: -------------------------------------------------------------------------------- 1 | 'global_menu_content', 8 | 'sort' => 400, 9 | 'text' => "Тестовый модуль", 10 | 'title' => "", 11 | 'url' => 'perfmon_table.php?lang=ru&table_name=brainkit_test' 12 | ), 13 | ); 14 | return $aMenu; -------------------------------------------------------------------------------- /include.php: -------------------------------------------------------------------------------- 1 | "lib/test.php", 6 | ) 7 | ); 8 | -------------------------------------------------------------------------------- /install/db/install.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `brainkit_test` ( 2 | `ID` INT(11) NOT NULL AUTO_INCREMENT, 3 | `TITLE` VARCHAR(65536) NOT NULL, 4 | `SORT` INT(11) DEFAULT 500, 5 | `CREATED` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 6 | PRIMARY KEY(ID) 7 | ); -------------------------------------------------------------------------------- /install/db/uninstall.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `brainkit_test`; -------------------------------------------------------------------------------- /install/index.php: -------------------------------------------------------------------------------- 1 | MODULE_VERSION = "1.0.0"; 20 | $this->MODULE_VERSION_DATE = "20.03.2016"; 21 | $this->MODULE_NAME = "Пример модуля D7"; 22 | $this->MODULE_DESCRIPTION = "Тестовый модуль для разработчиков, можно использовать как основу для разработки новых модулей для 1С:Битрикс"; 23 | } 24 | 25 | function DoInstall() 26 | { 27 | $this->InstallDB(); 28 | $this->InstallEvents(); 29 | $this->InstallFiles(); 30 | \Bitrix\Main\ModuleManager::RegisterModule("brainkit.d7"); 31 | return true; 32 | } 33 | 34 | function DoUninstall() 35 | { 36 | $this->UnInstallDB(); 37 | $this->UnInstallEvents(); 38 | $this->UnInstallFiles(); 39 | \Bitrix\Main\ModuleManager::UnRegisterModule("brainkit.d7"); 40 | return true; 41 | } 42 | 43 | function InstallDB() 44 | { 45 | global $DB; 46 | $this->errors = false; 47 | $this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/brainkit.d7/install/db/install.sql"); 48 | if (!$this->errors) { 49 | 50 | return true; 51 | } else 52 | return $this->errors; 53 | } 54 | 55 | function UnInstallDB() 56 | { 57 | global $DB; 58 | $this->errors = false; 59 | $this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/local/modules/Brainkit.D7/install/db/uninstall.sql"); 60 | if (!$this->errors) { 61 | return true; 62 | } else 63 | return $this->errors; 64 | } 65 | 66 | function InstallEvents() 67 | { 68 | return true; 69 | } 70 | 71 | function UnInstallEvents() 72 | { 73 | return true; 74 | } 75 | 76 | function InstallFiles() 77 | { 78 | return true; 79 | } 80 | 81 | function UnInstallFiles() 82 | { 83 | return true; 84 | } 85 | } -------------------------------------------------------------------------------- /lang/ru/lib/data.php: -------------------------------------------------------------------------------- 1 | 13 | *
  • ID int mandatory 14 | *
  • LINK string mandatory 15 | *
  • PATH string mandatory 16 | *
  • SORT int optional default 500 17 | *
  • CREATED datetime mandatory default 'CURRENT_TIMESTAMP' 18 | * 19 | * 20 | * @package \Brainkit\Data 21 | **/ 22 | 23 | class DataTable extends Entity\DataManager 24 | { 25 | /** 26 | * Returns DB table name for entity. 27 | * 28 | * @return string 29 | */ 30 | public static function getTableName() 31 | { 32 | return 'brainkit_test'; 33 | } 34 | 35 | /** 36 | * Returns entity map definition. 37 | * 38 | * @return array 39 | */ 40 | public static function getMap() 41 | { 42 | return array( 43 | 'ID' => array( 44 | 'data_type' => 'integer', 45 | 'primary' => true, 46 | 'autocomplete' => true, 47 | 'title' => Loc::getMessage('DATA_ENTITY_ID_FIELD'), 48 | ), 49 | 'TITLE' => array( 50 | 'data_type' => 'text', 51 | 'required' => true, 52 | 'title' => Loc::getMessage('DATA_ENTITY_TITLE_FIELD'), 53 | ), 54 | 'SORT' => array( 55 | 'data_type' => 'integer', 56 | 'title' => Loc::getMessage('DATA_ENTITY_SORT_FIELD'), 57 | ), 58 | 'CREATED' => array( 59 | 'data_type' => 'datetime', 60 | 'title' => Loc::getMessage('DATA_ENTITY_CREATED_FIELD'), 61 | ), 62 | ); 63 | } 64 | } -------------------------------------------------------------------------------- /lib/test.php: -------------------------------------------------------------------------------- 1 | array('*') 13 | )); 14 | $row = $result->fetch(); 15 | print "
    "; print_r($row); print "
    "; 16 | return $row; 17 | } 18 | 19 | } 20 | --------------------------------------------------------------------------------