On branch master
[event_calendar.git] / install.eventcalendar.php
blobd9154035f2615a2bb7af95bddba97f7ca9891afd
1 <?php
3 /*
4 * Event Calendar for Elxis CMS 2008.x and 2009.x
6 * Installer Handler
8 * @version 1.1
9 * @package eventCalendar
10 * @author Apostolos Koutsoulelos <akoutsoulelos@yahoo.gr>
11 * @copyright Copyright (C) 2009-2010 Apostolos Koutsoulelos. All rights reserved.
12 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
13 * @link
16 // Prevent direct inclusion of this file
17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
19 // Initialize variables
21 // Function automatically triggered by Elxis to fire the installation process
22 function com_install() {
23 global $database, $alang, $mainframe, $fmanager;
25 // Load and execute adodb xml schema file
26 if (file_exists($mainframe->getCfg('absolute_path').'/includes/adodb/adodb-xmlschema03.inc.php')) {
27 require_once($mainframe->getCfg('absolute_path').'/includes/adodb/adodb-xmlschema03.inc.php');
28 $schemafile = $mainframe->getCfg('absolute_path').'/administrator/components/com_eventcalendar/schema/eventschema03.xml';
29 } else {
30 require_once($mainframe->getCfg('absolute_path').'/includes/adodb/adodb-xmlschema.inc.php');
31 $schemafile = $mainframe->getCfg('absolute_path').'/administrator/components/com_eventcalendar/schema/eventschema.xml';
33 $schema = new adoSchema($database->_resource);
34 $schema->ContinueOnError(true);
35 $schema->SetPrefix($mainframe->getCfg('dbprefix'));
36 $schema->ParseSchema($schemafile);
37 $schema->ExecuteSchema();
39 //Load component's language
40 $ipath = $mainframe->getCfg('absolute_path').'/components/com_eventcalendar';
41 if (file_exists($ipath.'/language/'.$alang.'.php')) {
42 require_once($ipath.'/language/'.$alang.'.php');
43 } else if (file_exists($ipath.'/language/'.$mainframe->getCfg('alang').'.php')) {
44 require_once($ipath.'/language/'.$mainframe->getCfg('alang').'.php');
45 } else {
46 require_once($ipath.'/language/english.php');
48 $lng = new clsEventCalendarLanguage();
50 $install_errors = array();
52 // Set default parameters
53 $query = "UPDATE #__components SET params='".
54 "newauto=\n".
55 "newall=\n".
56 "changesauto=\n".
57 "changesall=\n".
58 "timetable=a:1:{i:0;s:10:\"0:00-23:59\";}\n".
59 "timetable_selected=0\n".
60 "who_can_post_events=25\n".
61 "who_can_edit_events=25\n".
62 "week_startingday=0\n".
63 "show_weeknumber=1\n".
64 "week_number_links=1\n".
65 "default_view=monthview\n".
66 "view_nav=1\n".
67 "view_print=1\n".
68 "view_rss=1\n".
69 "view_catlist=1\n".
70 "view_periodicity=0\n".
71 "view_reservation=1\n".
72 "col_catlist=3\n".
73 "rss_cache=0\n".
74 "rss_cachetime=3600\n".
75 "rss_num=5\n".
76 "rss_title=EventCalendar RSS feeds\n".
77 "rss_description=EventCalendar web syndication.\n".
78 "rss_img=elxis_rss.png\n".
79 "rss_imgalt=EventCalendar RSS feeds\n".
80 "rss_limittext=0\n".
81 "rss_textlength=20\n".
82 "rss_multilang=0\n".
83 "rss_live=0\n".
84 "pp_mail=mypaypal@email.com\n".
85 "p_curlist=EUR\n".
86 "css_filename=default.css\n'".
87 "\n WHERE admin_menu_link='option=com_eventcalendar' AND link='option=com_eventcalendar'";
88 $database->setQuery($query);
89 if (!$database->query()) { $install_errors[] = $lng->INS_ERROR_MENU_PARAMS; }
91 // Set up new icons for admin menu
92 $database->setQuery("UPDATE #__components SET admin_menu_img='js/ThemeOffice/edit.png' WHERE admin_menu_link='option=com_eventcalendar'");
93 if (!$database->query()) { $install_errors[] = $lng->INS_ERROR_MENU_EVENTS; }
95 $database->setQuery("UPDATE #__components SET admin_menu_img='js/ThemeOffice/edit.png' WHERE admin_menu_link='option=com_eventcalendar&task=anniversries'");
96 if (!$database->query()) { $install_errors[] = $lng->INS_ERROR_MENU_ANNI; }
98 $database->setQuery("UPDATE #__components SET admin_menu_img='../administrator/components/com_eventcalendar/images/calendar_menu.png' WHERE admin_menu_link='option=com_eventcalendar' AND link='option=com_eventcalendar'");
99 if (!$database->query()) { $install_errors[] = $lng->INS_ERROR_MENU_MAIN; }
101 $database->setQuery("UPDATE #__components SET admin_menu_img='js/ThemeOffice/categories.png' WHERE admin_menu_link='option=com_categories&section=com_eventcalendar'");
102 if (!$database->query()) { $install_errors[] = $lng->INS_ERROR_MENU_CATEGORIES; }
104 $database->setQuery("UPDATE #__components SET admin_menu_img='js/ThemeOffice/config.png' WHERE admin_menu_link='option=com_eventcalendar&task=cp'");
105 if (!$database->query()) { $install_errors[] = $lng->INS_ERROR_MENU_CONFIGURATION; }
107 //Add SEO Pro functionality
108 $source = $mainframe->getCfg('absolute_path').'/administrator/components/com_eventcalendar/seopro.com_eventcalendar.php';
109 $destination = $mainframe->getCfg('absolute_path').'/includes/seopro/com_eventcalendar.php';
110 $success = $fmanager->copyFile($source, $destination);
111 if (!$success) { $install_errors[] = $lng->INS_ERROR_SEOPRO; }
113 //Add IOS Sitemap extention
114 if ( (file_exists($mainframe->getCfg('absolute_path').'/administrator/components/com_sitemap/')) && (!file_exists($mainframe->getCfg('absolute_path').'/administrator/components/com_sitemap/extensions/eventcalendar.sitemap.php')) ) {
115 $source = $mainframe->getCfg('absolute_path').'/administrator/components/com_eventcalendar/eventcalendar.sitemap.php';
116 $destination = $mainframe->getCfg('absolute_path').'/administrator/components/com_sitemap/extensions/eventcalendar.sitemap.php';
117 $success = $fmanager->copyFile($source, $destination);
118 if (!$success) { $install_errors[] = $lng->INS_ERROR_SITEMAP; }
122 <table class="adminheading">
123 <tr>
124 <th class="install"><?php echo $lng->INS_HEADER; ?></th>
125 </tr>
126 </table>
128 <table class="adminform" style="empty-cells:hide">
129 <?php
130 if (count($install_errors) > 0) { ?>
131 <tr>
132 <td class="menudottedline" style="background-color:red;">
133 <?php echo $lng->INS_ERROR_NOTICE_TITLE; ?>:
134 </td>
135 <td>
136 <?php
137 foreach ($install_errors as $install_error) {
138 echo $install_error."<br />\n";
140 echo $lng->INS_ERROR_NOTICE;
142 </td>
143 </tr>
144 <?php
147 <tr>
148 <th colspan="2"><?php echo $lng->INS_TITLE; ?></th>
149 </tr>
150 <tr>
151 <td colspan="2"><?php echo $lng->INS_BODY; ?></td>
152 </tr>
153 </table>
154 <?php