|
| |
1 |
|
<?php |
|
| |
2 |
|
|
|
| |
3 |
|
$MODULE_NAME = 'in-news'; |
|
| |
4 |
|
|
|
| |
5 |
|
|
|
| |
6 |
|
if (!defined('REL_PATH')) |
|
| |
7 |
|
{ |
|
| |
8 |
|
define('REL_PATH', defined('IS_INSTALL') && IS_INSTALL ? 'admin' : 'in-news/admin'); |
|
| |
9 |
|
$relation_level = count( explode('/', REL_PATH) ); |
|
| |
10 |
|
define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) ); |
|
| |
11 |
|
} |
|
| |
12 |
|
if (!defined('IS_INSTALL')) define('IS_INSTALL', 1); |
|
| |
13 |
|
require_once FULL_PATH.'/kernel/startup.php'; |
|
| |
14 |
|
|
|
| |
15 |
|
|
|
| |
16 |
|
$application =& kApplication::Instance(); |
|
| |
17 |
|
$application->Init(); |
|
| |
18 |
|
|
|
| |
19 |
|
require_once FULL_PATH.'/admin/install/install_lib.php'; |
|
| |
20 |
|
require_once FULL_PATH.'/kernel/include/tag-class.php'; |
|
| |
21 |
|
if( !isset($objTagList) ) $objTagList = new clsTagList(); |
|
| |
22 |
|
|
|
| |
23 |
|
$ado =& GetADODBConnection(); |
|
| |
24 |
|
|
|
| |
25 |
|
|
|
| |
26 |
|
$ml_formatter =& $application->recallObject('kMultiLanguage'); |
|
| |
27 |
|
$name_field = $ml_formatter->LangFieldName('Name'); |
|
| |
28 |
|
$description_field = $ml_formatter->LangFieldName('Description'); |
|
| |
29 |
|
|
|
| |
30 |
|
$cat =& $application->recallObject('c', null, Array('skip_autoload' => true)); |
|
| |
31 |
|
$cat->Clear(); |
|
| |
32 |
|
$cat_fields = Array($name_field => 'News', 'AutomaticFilename' => 1, 'Filename' => 'News', |
|
| |
33 |
|
$description_field => 'News Articles', 'Status' => 1, 'ParentId' => 0, |
|
| |
34 |
|
'CategoryTemplate' => 'innews/index', 'CachedCategoryTemplate' => 'innews/index'); |
|
| |
35 |
|
$cat->SetDBFieldsFromHash($cat_fields); |
|
| |
36 |
|
$cat->Create(); |
|
| |
37 |
|
|
|
| |
38 |
|
$cat_id = $cat->GetID(); |
|
| |
39 |
|
|
|
| |
40 |
|
$filename = FULL_PATH.'/'.$MODULE_NAME.'/admin/install/inportal_schema.sql'; |
|
| |
41 |
|
if (file_exists($filename)) RunSchemaFile($ado, $filename); |
|
| |
42 |
|
|
|
| |
43 |
|
$filename = FULL_PATH.'/'.$MODULE_NAME.'/admin/install/inportal_data.sql'; |
|
| |
44 |
|
if (file_exists($filename)) |
|
| |
45 |
|
{ |
|
| |
46 |
|
$sql = file($filename); |
|
| |
47 |
|
for ($x = 0; $x < count($sql); $x++) |
|
| |
48 |
|
{ |
|
| |
49 |
|
$sql[$x] = str_replace('{NewsCatId}', $cat_id, $sql[$x]); |
|
| |
50 |
|
} |
|
| |
51 |
|
RunSQLText($ado, $sql); |
|
| |
52 |
|
|
|
| |
53 |
|
$sql = 'SELECT Version FROM '.TABLE_PREFIX.'Modules WHERE Name = '.$ado->qstr('In-News'); |
|
| |
54 |
|
$mod_version = $application->Conn->GetOne($sql); |
|
| |
55 |
|
|
|
| |
56 |
|
if (!(isset($ini_file) && $ini_file)) { |
|
| |
57 |
|
$ini_file = FULL_PATH.'/config.php'; |
|
| |
58 |
|
$ini_vars = inst_parse_portal_ini($ini_file, true); |
|
| |
59 |
|
} |
|
| |
60 |
|
|
|
| |
61 |
|
set_ini_value('Module Versions', 'In-News', $mod_version); |
|
| |
62 |
|
save_values(); |
|
| |
63 |
|
|
|
| |
64 |
|
$objTagList->ParseFile(FULL_PATH.'/'.$MODULE_NAME.'/parser.php'); |
|
| |
65 |
|
} |
|
| |
66 |
|
|
|
| |
67 |
|
linkCustomFields($MODULE_NAME, 'n', 2); |
|
| |
68 |
|
linkCustomFields('KERNEL', 'c', 1); |
|
| |
69 |
|
|
|
| |
70 |
|
$cat->defineFields(); |
|
| |
71 |
|
$application->removeObject('c-cdata'); |
|
| |
72 |
|
$cat->SetDBField('cust_n_ItemTemplate', 'innews/detail'); |
|
| |
73 |
|
$cat->Update(); |
|
| |
74 |
|
|
|
| |
75 |
|
$sql = 'DELETE FROM '.TABLE_PREFIX.'Cache WHERE (VarName = "config_files") OR (VarName LIKE "%_parsed")'; |
|
| |
76 |
|
$application->Conn->Query($sql); |
|
| |
77 |
|
|
|
| |
78 |
|
$objModules->Refresh(); |
|
| |
79 |
|
$objModules->SetModuleRoot('In-News', $cat_id); |
|
| |
80 |
|
|
|
| |
81 |
|
$inp_cat =& $objCatList->GetCategory($cat_id); |
|
| |
82 |
|
$inp_cat->UpdateCachedPath(); |
|
| |
83 |
|
$inp_cat->UpdateACL(); |
|
| |
84 |
|
|
|
| |
85 |
|
finalizeModuleInstall($MODULE_NAME); |
|
| |
86 |
|
|
|
| |
87 |
|
?> |