diff --git a/admin/about.php b/admin/about.php new file mode 100644 index 0000000..6f0e758 --- /dev/null +++ b/admin/about.php @@ -0,0 +1,14 @@ + + * @version $Id$ + */ + +include_once "admin_header.php"; +$aboutObj = new icms_ipf_About(); +$aboutObj->render(); \ No newline at end of file diff --git a/admin/admin.css b/admin/admin.css new file mode 100644 index 0000000..95baad5 --- /dev/null +++ b/admin/admin.css @@ -0,0 +1 @@ +.icms_breadcrumb{margin-bottom:10px;font-size:90%;border-bottom:2px solid #E3E3F3;padding-bottom:0px;} \ No newline at end of file diff --git a/admin/admin_header.php b/admin/admin_header.php new file mode 100644 index 0000000..2af856e --- /dev/null +++ b/admin/admin_header.php @@ -0,0 +1,20 @@ + + * @version $Id$ + */ + +$icmsOnDemandPreload[] = array("module" => "imbuilding", "filename" => "adminside"); + +include_once "../../../include/cp_header.php"; +include_once ICMS_ROOT_PATH . "/modules/" . basename(dirname(dirname(__FILE__))) . "/include/common.php"; +defined("IMBUILDING_ADMIN_URL") or define("IMBUILDING_ADMIN_URL", IMBUILDING_URL . "admin/"); +include_once IMBUILDING_ROOT_PATH . "include/requirements.php"; \ No newline at end of file diff --git a/admin/field.php b/admin/field.php new file mode 100644 index 0000000..3c3140f --- /dev/null +++ b/admin/field.php @@ -0,0 +1,138 @@ + + * @version $Id$ + */ + +/** + * Edit a Field + * + * @param int $field_id Fieldid to be edited +*/ +function editfield($fieldObj) { + global $icmsModule, $icmsAdminTpl, $clean_object_id; + + $new_module = isset($_GET['newmodule']) ? (int)$_GET['newmodule'] : FALSE; + + $module_id = $object_id = FALSE; + $imbuilding_object_handler = icms_getModuleHandler("object", basename(dirname(dirname(__FILE__))), "imbuilding"); + $objectObj = $imbuilding_object_handler->get($clean_object_id); + if (!$objectObj->isNew()) { + $module_id = $objectObj->getVar("module_id"); + $object_id = $objectObj->getVar("object_id"); + } + + $fieldObj->setControl('field_refer', array( + 'itemHandler' => 'object', + 'method' => 'getObjectsReferList', + 'module' => 'imbuilding', + 'params' => array($module_id, $object_id))); + + if (!$fieldObj->isNew()) { + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_FIELDS . " > " . _CO_ICMS_EDITING); + $sform = $fieldObj->getForm(_AM_IMBUILDING_FIELD_EDIT, 'addfield'); + $sform->assign($icmsAdminTpl); + } else { + if ($new_module == 1) { + $fieldObj->setVar('new_module_wizard', TRUE); + $fieldObj->setVar('another', TRUE); + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_FIELD_CREATE_WIZARD); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_FIELD_CREATE_WIZARD_INFO); + } elseif ($new_module == 2) { + $fieldObj->setVar('new_module_wizard', TRUE); + $fieldObj->setVar('another', TRUE); + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_FIELD_CREATE_WIZARD2); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_FIELD_CREATE_WIZARD2_INFO); + } else { + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_FIELD_CREATE); + } + + $fieldObj->setVar('object_id', $clean_object_id); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_FIELDS . " > " . _CO_ICMS_CREATINGNEW); + $sform = $fieldObj->getForm(_AM_IMBUILDING_FIELD_CREATE, 'addfield'); + $sform->assign($icmsAdminTpl); + } + $icmsAdminTpl->assign('modules_breadcrumb', icms_getBreadcrumb($fieldObj->getBreadcrumb('form'))); + $icmsAdminTpl->display('db:imbuilding_admin_field.html'); +} + +include_once "admin_header.php"; + +$imbuilding_field_handler = icms_getModuleHandler('field', basename(dirname(dirname(__FILE__)))); +/** Use a naming convention that indicates the source of the content of the variable */ +$clean_op = ''; +/** Create a whitelist of valid values, be sure to use appropriate types for each value + * Be sure to include a value for no parameter, if you have a default condition + */ +$valid_op = array('mod', 'changedField', 'addfield', 'del', 'view', ''); + +if (isset($_GET['op'])) $clean_op = htmlentities($_GET['op']); +if (isset($_POST['op'])) $clean_op = htmlentities($_POST['op']); + +/** Again, use a naming convention that indicates the source of the content of the variable */ +$clean_field_id = isset($_GET['field_id']) ? (int)$_GET['field_id'] : 0 ; +$clean_object_id = isset($_GET['object_id']) ? (int)$_GET['object_id'] : 0 ; + +/** + * in_array() is a native PHP function that will determine if the value of the + * first argument is found in the array listed in the second argument. Strings + * are case sensitive and the 3rd argument determines whether type matching is + * required +*/ +if (in_array($clean_op, $valid_op, TRUE)){ + switch ($clean_op) { + case "mod": + case "changedField": + icms_cp_header(); + $fieldObj = $imbuilding_field_handler->get($clean_field_id); + editfield($fieldObj); + break; + + case "addfield": + $controller = new icms_ipf_Controller($imbuilding_field_handler); + $controller->storeFromDefaultForm(_AM_IMBUILDING_FIELD_CREATED, _AM_IMBUILDING_FIELD_MODIFIED); + break; + + case "del": + $controller = new icms_ipf_Controller($imbuilding_field_handler); + $controller->handleObjectDeletion(); + break; + + case "view" : + $imbuilding_object_handler = icms_getModuleHandler('object'); + $fieldObj = $imbuilding_field_handler->get($clean_field_id); + + icms_cp_header(); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_FIELD_VIEW . ' > ' . $fieldObj->getVar('field_name')); + $icmsAdminTpl->assign('imbuilding_field_singleview', $fieldObj->displaySingleObject(TRUE)); + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item('field_id', $clean_field_id)); + $objectTable = new icms_ipf_view_Table($imbuilding_object_handler, $criteria); + $objectTable->addColumn(new icms_ipf_view_Column('object_name', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink')); + $objectTable->addColumn(new icms_ipf_view_Column('object_desc')); + $objectTable->addIntroButton('addobject', 'object.php?op=mod&field_id=' . $clean_field_id, _AM_IMBUILDING_OBJECT_CREATE); + $icmsAdminTpl->assign('imbuilding_object_table', $objectTable->fetch()); + $icmsAdminTpl->assign('modules_breadcrumb', icms_getBreadcrumb($fieldObj->getBreadcrumb('view'))); + $icmsAdminTpl->display('db:imbuilding_admin_field.html'); + break; + + default: + icms_cp_header(); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_FIELDS); + $objectTable = new icms_ipf_view_Table($imbuilding_field_handler); + $objectTable->addColumn(new icms_ipf_view_Column('field_name', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink')); + $objectTable->addColumn(new icms_ipf_view_Column('author_name')); + $objectTable->addIntroButton('addfield', 'field.php?op=mod', _AM_IMBUILDING_FIELD_CREATE); + $icmsAdminTpl->assign('imbuilding_field_table', $objectTable->fetch()); + $icmsAdminTpl->display('db:imbuilding_admin_field.html'); + break; + } + icms_cp_footer(); +} \ No newline at end of file diff --git a/admin/index.html b/admin/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/admin/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..2554b1f --- /dev/null +++ b/admin/index.php @@ -0,0 +1,12 @@ + + * @version $Id$ + */ + +header("location: module.php"); \ No newline at end of file diff --git a/admin/menu.php b/admin/menu.php new file mode 100644 index 0000000..2e5d6be --- /dev/null +++ b/admin/menu.php @@ -0,0 +1,31 @@ + + * @version $Id$ + */ + +$adminmenu[] = array( + "title" => _MI_IMBUILDING_MODULES, + "link" => "admin/module.php"); + +$module = icms::handler("icms_module")->getByDirname(basename(dirname(dirname(__FILE__)))); + +$headermenu[] = array( + "title" => _PREFERENCES, + "link" => "../../system/admin.php?fct=preferences&op=showmod&mod=" . $module->getVar("mid")); +$headermenu[] = array( + "title" => _CO_ICMS_GOTOMODULE, + "link" => ICMS_URL . "/modules/imbuilding/"); +$headermenu[] = array( + "title" => _CO_ICMS_UPDATE_MODULE, + "link" => ICMS_URL . "/modules/system/admin.php?fct=modulesadmin&op=update&module=" . basename(dirname(dirname(__FILE__)))); +$headermenu[] = array( + "title" => _MODABOUT_ABOUT, + "link" => ICMS_URL . "/modules/imbuilding/admin/about.php"); + +unset($module_handler); \ No newline at end of file diff --git a/admin/module.php b/admin/module.php new file mode 100644 index 0000000..97983e5 --- /dev/null +++ b/admin/module.php @@ -0,0 +1,144 @@ + + * @version $Id$ + */ + +/** + * Edit a Module + * + * @param int $module_id Moduleid to be edited +*/ +function editmodule($module_id = 0) { + global $imbuilding_module_handler, $icmsModule, $icmsAdminTpl; + + $moduleObj = $imbuilding_module_handler->get($module_id); + + if (!$moduleObj->isNew()){ + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_MODULES . " > " . _CO_ICMS_EDITING); + $sform = $moduleObj->getForm(_AM_IMBUILDING_MODULE_EDIT, 'addmodule'); + $sform->assign($icmsAdminTpl); + } else { + $moduleObj->hideFieldFromForm('default_object'); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_MODULES . " > " . _CO_ICMS_CREATINGNEW); + $sform = $moduleObj->getForm(_AM_IMBUILDING_MODULE_CREATE, 'addmodule'); + $sform->assign($icmsAdminTpl); + + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_MODULE_CREATE); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_MODULE_CREATE_INFO); + + } + $icmsAdminTpl->assign('modules_breadcrumb', icms_getBreadcrumb($moduleObj->getBreadcrumb('form'))); + $icmsAdminTpl->display('db:imbuilding_admin_module.html'); +} + +include_once "admin_header.php"; + +$imbuilding_module_handler = icms_getModuleHandler('module'); +/** Use a naming convention that indicates the source of the content of the variable */ +$clean_op = 'list'; +/** Create a whitelist of valid values, be sure to use appropriate types for each value + * Be sure to include a value for no parameter, if you have a default condition + */ +$valid_op = array ('list', 'mod', 'addmodule', 'del', 'view', 'createmodule', 'changedField'); + +if (isset($_GET['op'])) $clean_op = htmlentities($_GET['op']); +if (isset($_POST['op'])) $clean_op = htmlentities($_POST['op']); + +/** Again, use a naming convention that indicates the source of the content of the variable */ +$clean_module_id = isset($_GET['module_id']) ? (int)$_GET['module_id'] : 0 ; + +/** + * in_array() is a native PHP function that will determine if the value of the + * first argument is found in the array listed in the second argument. Strings + * are case sensitive and the 3rd argument determines whether type matching is + * required +*/ +if (in_array($clean_op, $valid_op, TRUE)){ + switch ($clean_op) { + case "changedField": + $imbuilding_object_handler = icms_getModuleHandler('object'); + foreach ($_POST['mod_imbuilding_Object_objects'] as $k => $v){ + $obj = $imbuilding_object_handler->get($v); + if ($obj->getVar('sort','e') != $_POST['sort'][$k]){ + $obj->setVar('sort', (int)$_POST['sort'][$k]); + $imbuilding_object_handler->insert($obj); + } + } + redirect_header('module.php?op=view&module_id=' . (int)$_GET['module_id'], 2, _AM_IMBUILDING_OBJECT_MODIFIED); + break; + + case 'createmodule': + icms_cp_header(); + $moduleObj = $imbuilding_module_handler->get($clean_module_id); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_MODULE_GENERATION . ' > ' . $moduleObj->getVar('module_name')); + + $moduleObj = $imbuilding_module_handler->get($clean_module_id); + $newModule = new mod_imbuilding_Newmodule($moduleObj); + $newModule->create(); + + $icmsAdminTpl->assign('imbuilding_new_module', TRUE); + $icmsAdminTpl->assign('imbuilding_module_title', _AM_IMBUILDING_MODULE_GENERATED_TITLE); + $icmsAdminTpl->assign('imbuilding_module_created_info', sprintf(_AM_IMBUILDING_MODULE_GENERATED_NOZIP, ICMS_CACHE_PATH . '/imbuilding/' . $newModule->moduleinfo['modulename'])); + $icmsAdminTpl->assign('imbuilding_new_module_log', $newModule->displayLog()); + $icmsAdminTpl->assign('imbuilding_new_module_url', $newModule->archiveUrl); + $icmsAdminTpl->display('db:imbuilding_admin_module.html'); + break; + + case 'mod': + icms_cp_header(); + editmodule($clean_module_id); + break; + + case 'addmodule': + $controller = new icms_ipf_Controller($imbuilding_module_handler); + $controller->storeFromDefaultForm(_AM_IMBUILDING_MODULE_CREATED, _AM_IMBUILDING_MODULE_MODIFIED); + break; + + case 'del': + $controller = new icms_ipf_Controller($imbuilding_module_handler); + $controller->handleObjectDeletion(); + break; + + case 'view' : + $imbuilding_object_handler = icms_getModuleHandler('object'); + $moduleObj = $imbuilding_module_handler->get($clean_module_id); + + icms_cp_header(); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_MODULE_VIEW . ' > ' . $moduleObj->getVar('module_name')); + $icmsAdminTpl->assign('imbuilding_module_singleview', $moduleObj->displaySingleObject(TRUE)); + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item('module_id', $clean_module_id)); + $objectTable = new icms_ipf_view_Table($imbuilding_object_handler, $criteria); + $objectTable->addColumn(new icms_ipf_view_Column('object_name', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink')); + $objectTable->addColumn(new icms_ipf_view_Column('object_desc')); + $objectTable->addColumn(new icms_ipf_view_Column("sort", "center", 150, "getObjectSortControl")); + $objectTable->addIntroButton('addobject', 'object.php?op=mod&module_id=' . $clean_module_id, _AM_IMBUILDING_OBJECT_CREATE); + $objectTable->addActionButton("changedField", FALSE, _SUBMIT); + $objectTable->setDefaultSort("sort"); + $icmsAdminTpl->assign('imbuilding_object_table', $objectTable->fetch()); + $icmsAdminTpl->assign('modules_breadcrumb', icms_getBreadcrumb($moduleObj->getBreadcrumb('view'))); + $icmsAdminTpl->display('db:imbuilding_admin_module.html'); + break; + + default: + icms_cp_header(); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_MODULES); + $objectTable = new icms_ipf_view_Table($imbuilding_module_handler); + $objectTable->addColumn(new icms_ipf_view_Column('module_name', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink')); + $objectTable->addColumn(new icms_ipf_view_Column('author_name')); + $objectTable->addIntroButton('addmodule', 'module.php?op=mod', _AM_IMBUILDING_MODULE_CREATE); + $objectTable->addCustomAction('getCreateModuleLink'); + $icmsAdminTpl->assign('imbuilding_module_table', $objectTable->fetch()); + $icmsAdminTpl->display('db:imbuilding_admin_module.html'); + break; + } + icms_cp_footer(); +} \ No newline at end of file diff --git a/admin/object.php b/admin/object.php new file mode 100644 index 0000000..4e16c8f --- /dev/null +++ b/admin/object.php @@ -0,0 +1,131 @@ + + * @version $Id$ + */ + +/** + * Edit a Module + * + * @param int $object_id Moduleid to be edited +*/ +function editobject($object_id = 0, $finishing = FALSE) { + global $imbuilding_object_handler, $icmsModule, $icmsAdminTpl, $clean_module_id; + + $new_module = isset($_GET['newmodule']) && (int)$_GET['newmodule'] == 1; + + $objectObj = $imbuilding_object_handler->get($object_id); + + if (!$objectObj->isNew()){ + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_OBJECTS . " > " . _CO_ICMS_EDITING); + if ($finishing) { + $objectObj->hideFieldFromForm(array('module_id', 'object_name', 'object_desc', 'object_counter', 'object_dohtml', 'object_dobr', 'object_doimage', 'object_dosmiley', 'object_doxcode', 'enable_seo')); + $objectObj->setVar('new_module_wizard', TRUE); + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_OBJECT_EDIT_FINILIZE); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_OBJECT_EDIT_FINILIZE_INFO); + } else { + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_OBJECT_EDIT); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_OBJECT_EDIT_INFO); + } + $sform = $objectObj->getForm(_AM_IMBUILDING_OBJECT_EDIT, 'addobject'); + $sform->assign($icmsAdminTpl); + + } else { + if ($new_module) { + $objectObj->setVar('new_module_wizard', TRUE); + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_OBJECT_CREATE_WIZARD); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_OBJECT_CREATE_WIZARD_INFO); + } else { + $icmsAdminTpl->assign('imbuilding_form_header', _AM_IMBUILDING_OBJECT_CREATE); + $icmsAdminTpl->assign('imbuilding_form_header_info', _AM_IMBUILDING_OBJECT_CREATE_INFO); + } + $objectObj->hideFieldFromForm(array('object_identifier_name', 'object_identifier_desc')); + $objectObj->setVar('module_id', $clean_module_id); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_OBJECTS . " > " . _CO_ICMS_CREATINGNEW); + $sform = $objectObj->getForm(_AM_IMBUILDING_OBJECT_CREATE, 'addobject'); + $sform->assign($icmsAdminTpl); + } + $icmsAdminTpl->assign('modules_breadcrumb', icms_getBreadcrumb($objectObj->getBreadcrumb('form'))); + $icmsAdminTpl->display('db:imbuilding_admin_object.html'); +} + +include_once "admin_header.php"; + +$imbuilding_object_handler = icms_getModuleHandler('object'); +/** Use a naming convention that indicates the source of the content of the variable */ +$clean_op = ''; +/** Create a whitelist of valid values, be sure to use appropriate types for each value + * Be sure to include a value for no parameter, if you have a default condition + */ +$valid_op = array ('mod', 'finishing', 'addobject', 'del', 'view', ''); + +if (isset($_GET['op'])) $clean_op = htmlentities($_GET['op']); +if (isset($_POST['op'])) $clean_op = htmlentities($_POST['op']); + +/** Again, use a naming convention that indicates the source of the content of the variable */ +$clean_object_id = isset($_GET['object_id']) ? (int)$_GET['object_id'] : 0 ; +$clean_module_id = isset($_GET['module_id']) ? (int)$_GET['module_id'] : 0 ; + +/** + * in_array() is a native PHP function that will determine if the value of the + * first argument is found in the array listed in the second argument. Strings + * are case sensitive and the 3rd argument determines whether type matching is + * required +*/ +if (in_array($clean_op, $valid_op, TRUE)){ + switch ($clean_op) { + case "mod": + case "finishing": + icms_cp_header(); + editobject($clean_object_id, $clean_op=='finishing'); + break; + + case "addobject": + $controller = new icms_ipf_Controller($imbuilding_object_handler); + $controller->storeFromDefaultForm(_AM_IMBUILDING_OBJECT_CREATED, _AM_IMBUILDING_OBJECT_MODIFIED); + break; + + case "del": + $controller = new icms_ipf_Controller($imbuilding_object_handler); + $controller->handleObjectDeletion(); + break; + + case "view" : + $imbuilding_field_handler = icms_getModuleHandler('field'); + $objectObj = $imbuilding_object_handler->get($clean_object_id); + + icms_cp_header(); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_OBJECT_VIEW . ' > ' . $objectObj->getVar('object_name')); + $icmsAdminTpl->assign('imbuilding_object_singleview', $objectObj->displaySingleObject(TRUE)); + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item('object_id', $clean_object_id)); + $objectTable = new icms_ipf_view_Table($imbuilding_field_handler, $criteria); + $objectTable->addColumn(new icms_ipf_view_Column('field_name', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink')); + $objectTable->addColumn(new icms_ipf_view_Column('field_caption')); + $objectTable->addColumn(new icms_ipf_view_Column('field_type')); + $objectTable->addIntroButton('addfield', 'field.php?op=mod&object_id=' . $clean_object_id, _AM_IMBUILDING_FIELD_CREATE); + $icmsAdminTpl->assign('imbuilding_field_table', $objectTable->fetch()); + $icmsAdminTpl->assign('modules_breadcrumb', icms_getBreadcrumb($objectObj->getBreadcrumb('view'))); + $icmsAdminTpl->display('db:imbuilding_admin_object.html'); + break; + + default: + icms_cp_header(); + $icmsModule->displayAdminMenu(0, _AM_IMBUILDING_OBJECTS); + $objectTable = new icms_ipf_view_Table($imbuilding_object_handler); + $objectTable->addColumn(new icms_ipf_view_Column('object_name', _GLOBAL_LEFT, FALSE, 'getAdminViewItemLink')); + $objectTable->addColumn(new icms_ipf_view_Column('author_name')); + $objectTable->addIntroButton('addobject', 'object.php?op=mod', _AM_IMBUILDING_OBJECT_CREATE); + $icmsAdminTpl->assign('imbuilding_object_table', $objectTable->fetch()); + $icmsAdminTpl->display('db:imbuilding_admin_object.html'); + break; + } + icms_cp_footer(); +} \ No newline at end of file diff --git a/basemodule/basefiles/admin/about.php b/basemodule/basefiles/admin/about.php new file mode 100644 index 0000000..8eaec44 --- /dev/null +++ b/basemodule/basefiles/admin/about.php @@ -0,0 +1,15 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "admin_header.php"; +$aboutObj = new icms_ipf_About(); +$aboutObj->render(); \ No newline at end of file diff --git a/basemodule/basefiles/admin/admin_header.php b/basemodule/basefiles/admin/admin_header.php new file mode 100644 index 0000000..c6ad73c --- /dev/null +++ b/basemodule/basefiles/admin/admin_header.php @@ -0,0 +1,19 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "../../../include/cp_header.php"; +include_once ICMS_ROOT_PATH . "/modules/" . basename(dirname(dirname(__FILE__))) . "/include/common.php"; +if (!defined("BASEMODULE_ADMIN_URL")) define("BASEMODULE_ADMIN_URL", BASEMODULE_URL . "admin/"); +include_once BASEMODULE_ROOT_PATH . "include/requirements.php"; \ No newline at end of file diff --git a/basemodule/basefiles/admin/index.html b/basemodule/basefiles/admin/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/admin/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/admin/index.php b/basemodule/basefiles/admin/index.php new file mode 100644 index 0000000..2597a5e --- /dev/null +++ b/basemodule/basefiles/admin/index.php @@ -0,0 +1,16 @@ + + * @package basemodule + * @version $Id$ + */ + +header("location: IMBUILDING_DEFAULT_OBJECT.php"); +exit; \ No newline at end of file diff --git a/basemodule/basefiles/blocks/index.html b/basemodule/basefiles/blocks/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/blocks/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/class/form/elements/index.html b/basemodule/basefiles/class/form/elements/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/class/form/elements/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/class/form/index.html b/basemodule/basefiles/class/form/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/class/form/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/class/index.html b/basemodule/basefiles/class/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/class/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/comment_delete.php b/basemodule/basefiles/comment_delete.php new file mode 100644 index 0000000..2eab2ff --- /dev/null +++ b/basemodule/basefiles/comment_delete.php @@ -0,0 +1,16 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "header.php"; +include_once ICMS_ROOT_PATH . "/include/comment_delete.php"; \ No newline at end of file diff --git a/basemodule/basefiles/comment_edit.php b/basemodule/basefiles/comment_edit.php new file mode 100644 index 0000000..54ddcfd --- /dev/null +++ b/basemodule/basefiles/comment_edit.php @@ -0,0 +1,16 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "header.php"; +include_once ICMS_ROOT_PATH . "/include/comment_edit.php"; \ No newline at end of file diff --git a/basemodule/basefiles/comment_new.php b/basemodule/basefiles/comment_new.php new file mode 100644 index 0000000..c34a82c --- /dev/null +++ b/basemodule/basefiles/comment_new.php @@ -0,0 +1,29 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "header.php"; +$com_itemid = isset($_GET["com_itemid"]) ? (int)$_GET["com_itemid"] : 0; +if ($com_itemid > 0) { + $basemodule_post_handler = icms_getModuleHandler("post", basename(dirname(__FILE__)), "basemodule"); + $postObj = $basemodule_post_handler->get($com_itemid); + if ($postObj && !$postObj->isNew()) { + $com_replytext = "test..."; + $bodytext = $postObj->getPostLead(); + if ($bodytext != "") { + $com_replytext .= "

".$bodytext; + } + $com_replytitle = $postObj->getVar("post_title"); + include_once ICMS_ROOT_PATH . "/include/comment_new.php"; + } +} \ No newline at end of file diff --git a/basemodule/basefiles/comment_post.php b/basemodule/basefiles/comment_post.php new file mode 100644 index 0000000..143e9c0 --- /dev/null +++ b/basemodule/basefiles/comment_post.php @@ -0,0 +1,16 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "header.php"; +include_once ICMS_ROOT_PATH . "/include/comment_post.php"; \ No newline at end of file diff --git a/basemodule/basefiles/comment_reply.php b/basemodule/basefiles/comment_reply.php new file mode 100644 index 0000000..c5f7ce1 --- /dev/null +++ b/basemodule/basefiles/comment_reply.php @@ -0,0 +1,16 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "header.php"; +include_once ICMS_ROOT_PATH . "/include/comment_reply.php"; \ No newline at end of file diff --git a/basemodule/basefiles/docs/changelog.txt b/basemodule/basefiles/docs/changelog.txt new file mode 100644 index 0000000..69a5c51 --- /dev/null +++ b/basemodule/basefiles/docs/changelog.txt @@ -0,0 +1,3 @@ +=> Unreleased: Version 1.0 Beta + +- First public release of the module. \ No newline at end of file diff --git a/basemodule/basefiles/docs/install.txt b/basemodule/basefiles/docs/install.txt new file mode 100644 index 0000000..0280373 --- /dev/null +++ b/basemodule/basefiles/docs/install.txt @@ -0,0 +1,4 @@ +How to install BaseModule +========================= + +BaseModule is installed as a regular ImpressCMS module, which means you should copy the complete /basemodule folder into the /modules directory of your website. Then, log in to your site as administrator, go to System Admin > Modules, look for the BaseModule icon in the list of uninstalled modules and click in the install icon. Follow the directions in the screen and you'll be ready to go. \ No newline at end of file diff --git a/basemodule/basefiles/docs/license.txt b/basemodule/basefiles/docs/license.txt new file mode 100644 index 0000000..4513ba6 --- /dev/null +++ b/basemodule/basefiles/docs/license.txt @@ -0,0 +1,87 @@ +GNU GENERAL PUBLIC LICENSE Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is TRUE depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/basemodule/basefiles/footer.php b/basemodule/basefiles/footer.php new file mode 100644 index 0000000..198ffbf --- /dev/null +++ b/basemodule/basefiles/footer.php @@ -0,0 +1,22 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +$icmsTpl->assign("basemodule_adminpage", "" ._MD_BASEMODULE_ADMIN_PAGE . ""); +$icmsTpl->assign("basemodule_is_admin", icms_userIsAdmin(BASEMODULE_DIRNAME)); +$icmsTpl->assign('basemodule_url', BASEMODULE_URL); +$icmsTpl->assign('basemodule_images_url', BASEMODULE_IMAGES_URL); + +$xoTheme->addStylesheet(BASEMODULE_URL . 'module' . ((defined("_ADM_USE_RTL") && _ADM_USE_RTL) ? '_rtl' : '') . '.css'); + +include_once ICMS_ROOT_PATH . '/footer.php'; \ No newline at end of file diff --git a/basemodule/basefiles/header.php b/basemodule/basefiles/header.php new file mode 100644 index 0000000..02df42f --- /dev/null +++ b/basemodule/basefiles/header.php @@ -0,0 +1,14 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once "../../mainfile.php"; +include_once dirname(__FILE__) . '/include/common.php'; \ No newline at end of file diff --git a/basemodule/basefiles/images/blank.png b/basemodule/basefiles/images/blank.png new file mode 100644 index 0000000..e1ee728 Binary files /dev/null and b/basemodule/basefiles/images/blank.png differ diff --git a/basemodule/basefiles/images/comments.gif b/basemodule/basefiles/images/comments.gif new file mode 100644 index 0000000..9fb650c Binary files /dev/null and b/basemodule/basefiles/images/comments.gif differ diff --git a/basemodule/basefiles/images/icon_big.png b/basemodule/basefiles/images/icon_big.png new file mode 100644 index 0000000..7b3d5d6 Binary files /dev/null and b/basemodule/basefiles/images/icon_big.png differ diff --git a/basemodule/basefiles/images/icon_small.png b/basemodule/basefiles/images/icon_small.png new file mode 100644 index 0000000..bbeceb9 Binary files /dev/null and b/basemodule/basefiles/images/icon_small.png differ diff --git a/basemodule/basefiles/images/index.html b/basemodule/basefiles/images/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/images/rss.png b/basemodule/basefiles/images/rss.png new file mode 100644 index 0000000..02eb541 Binary files /dev/null and b/basemodule/basefiles/images/rss.png differ diff --git a/basemodule/basefiles/include/comment.inc.php b/basemodule/basefiles/include/comment.inc.php new file mode 100644 index 0000000..d59b5bc --- /dev/null +++ b/basemodule/basefiles/include/comment.inc.php @@ -0,0 +1,22 @@ + + * @package basemodule + * @version $Id$ + */ + +function basemodule_com_update($item_id, $total_num) { + $basemodule_post_handler = icms_getModuleHandler("post", basename(dirname(dirname(__FILE__))), "basemodule"); + $basemodule_post_handler->updateComments($item_id, $total_num); +} + +function basemodule_com_approve(&$comment) { + // notification mail here +} \ No newline at end of file diff --git a/basemodule/basefiles/include/common.php b/basemodule/basefiles/include/common.php new file mode 100644 index 0000000..8a81291 --- /dev/null +++ b/basemodule/basefiles/include/common.php @@ -0,0 +1,22 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +if (!defined("BASEMODULE_DIRNAME")) define("BASEMODULE_DIRNAME", $modversion["dirname"] = basename(dirname(dirname(__FILE__)))); +if (!defined("BASEMODULE_URL")) define("BASEMODULE_URL", ICMS_URL."/modules/".BASEMODULE_DIRNAME."/"); +if (!defined("BASEMODULE_ROOT_PATH")) define("BASEMODULE_ROOT_PATH", ICMS_ROOT_PATH."/modules/".BASEMODULE_DIRNAME."/"); +if (!defined("BASEMODULE_IMAGES_URL")) define("BASEMODULE_IMAGES_URL", BASEMODULE_URL."images/"); +if (!defined("BASEMODULE_ADMIN_URL")) define("BASEMODULE_ADMIN_URL", BASEMODULE_URL."admin/"); + +// Include the common language file of the module +icms_loadLanguageFile("basemodule", "common"); \ No newline at end of file diff --git a/basemodule/basefiles/include/index.html b/basemodule/basefiles/include/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/include/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/include/notification.inc.php b/basemodule/basefiles/include/notification.inc.php new file mode 100644 index 0000000..8db548a --- /dev/null +++ b/basemodule/basefiles/include/notification.inc.php @@ -0,0 +1,32 @@ + + * @package basemodule + * @version $Id$ + */ + +/** + * Notification lookup function + * + * This function is called by the notification process to get an array contaning information + * about the item for which there is a notification + * + * @param string $category category of the notification + * @param int $item_id id f the item related to this notification + * + * @return array containing 'name' and 'url' of the related item + */ +function basemodule_notify_iteminfo($category, $item_id){ + global $icmsModule, $icmsModuleConfig, $icmsConfig; + + if ($category == 'global') { + $item['name'] = ''; + $item['url'] = ''; + return $item; + } +} \ No newline at end of file diff --git a/basemodule/basefiles/include/onupdate.inc.php b/basemodule/basefiles/include/onupdate.inc.php new file mode 100644 index 0000000..983e911 --- /dev/null +++ b/basemodule/basefiles/include/onupdate.inc.php @@ -0,0 +1,45 @@ + + * $modversion['onInstall'] = "include/onupdate.inc.php"; + * $modversion['onUpdate'] = "include/onupdate.inc.php"; + * + * + * @copyright IMBUILDING_COPYRIGHT + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) + * @since 1.0 + * @author IMBUILDING_TAG_AUTHOR_NAME + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +// this needs to be the latest db version +define('BASEMODULE_DB_VERSION', 1); + +/** + * it is possible to define custom functions which will be call when the module is updating at the + * correct time in update incrementation. Simpy define a function named + */ +/* +function basemodule_db_upgrade_1() { +} +function basemodule_db_upgrade_2() { +} +*/ + +function icms_module_update_basemodule($module) { + return TRUE; +} + +function icms_module_install_basemodule($module) { + return TRUE; +} \ No newline at end of file diff --git a/basemodule/basefiles/include/requirements.php b/basemodule/basefiles/include/requirements.php new file mode 100644 index 0000000..912863c --- /dev/null +++ b/basemodule/basefiles/include/requirements.php @@ -0,0 +1,27 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +$failed_requirements = array(); + +if (ICMS_VERSION_BUILD < 50) { + $failed_requirements[] = _AM_BASEMODULE_REQUIREMENTS_ICMS_BUILD; +} + +if (count($failed_requirements) > 0) { + icms_cp_header(); + $icmsAdminTpl->assign("failed_requirements", $failed_requirements); + $icmsAdminTpl->display(BASEMODULE_ROOT_PATH . "templates/basemodule_requirements.html"); + icms_cp_footer(); + exit; +} \ No newline at end of file diff --git a/basemodule/basefiles/include/search.inc.php b/basemodule/basefiles/include/search.inc.php new file mode 100644 index 0000000..e495f45 --- /dev/null +++ b/basemodule/basefiles/include/search.inc.php @@ -0,0 +1,37 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +function basemodule_search($queryarray, $andor, $limit, $offset, $userid) { +/** To come soon in imBuilding... + + $basemodule_post_handler = icms_getModuleHandler("post", basename(dirname(dirname(__FILE__))), "basemodule"); + $postsArray = $basemodule_post_handler->getPostsForSearch($queryarray, $andor, $limit, $offset, $userid); + + $ret = array(); + + foreach ($postsArray as $postArray) { + $item['image'] = "images/post.png"; + $item['link'] = str_replace(BASEMODULE_URL, '', $postArray['itemUrl']); + $item['title'] = $postArray['post_title']; + $item['time'] = strtotime($postArray['post_published_date']); + $item['uid'] = $postArray['post_posterid']; + $ret[] = $item; + unset($item); + } + + return $ret; +*/ +} \ No newline at end of file diff --git a/basemodule/basefiles/index.php b/basemodule/basefiles/index.php new file mode 100644 index 0000000..c927e77 --- /dev/null +++ b/basemodule/basefiles/index.php @@ -0,0 +1,16 @@ + + * @package basemodule + * @version $Id$ + */ + +header('location: IMBUILDING_DEFAULT_OBJECT.php'); +exit(); \ No newline at end of file diff --git a/basemodule/basefiles/language/english/blocks.php b/basemodule/basefiles/language/english/blocks.php new file mode 100644 index 0000000..a37ec80 --- /dev/null +++ b/basemodule/basefiles/language/english/blocks.php @@ -0,0 +1,13 @@ + +* @package basemodule +* @version $Id$ +*/ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); \ No newline at end of file diff --git a/basemodule/basefiles/language/english/index.html b/basemodule/basefiles/language/english/index.html new file mode 100644 index 0000000..e69de29 diff --git a/basemodule/basefiles/language/english/mail_template/index.html b/basemodule/basefiles/language/english/mail_template/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/language/english/mail_template/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/language/index.html b/basemodule/basefiles/language/index.html new file mode 100644 index 0000000..e69de29 diff --git a/basemodule/basefiles/module.css b/basemodule/basefiles/module.css new file mode 100644 index 0000000..498fdd0 --- /dev/null +++ b/basemodule/basefiles/module.css @@ -0,0 +1,67 @@ +.post-date{float:left; margin:0 12px 10px 0;} +.post-date .month{background:#000000 url(images/post-month.gif) no-repeat scroll 0 0; color: #FFF; display:block; font-size:80%;height:25px;line-height:25px;margin:0;text-align:center;width:48px;} +.post-date .day{background:#42A4DC url(images/post-day.gif) no-repeat scroll 0 0; color: #000; display:block; font-size:140%;height:30px;line-height:25px;margin:1px 0 0;text-align:center;width:48px;} +.post-title{margin:0;padding:2px 0 5px 0;} + + +.basemodule_headertable {padding: 0; margin: 0; border-bottom: 1px solid; margin-bottom: 10px;} +.basemodule_modulename {font-size: 0.8em; text-align: left; font-weight: bold; padding-right: 0.3em; line-height: 18px;} +.basemodule_breadcrumb {font-size: 0.8em; line-height: 18px;} +.basemodule_adminlinks {padding-top: 15px; padding-bottom: 5px; font-size: 0.8em; text-align: center; line-height: 18px;} + +.basemodule_post_container { + margin-bottom: 35px; +} + .basemodule_post_container h1 { + margin-top: 20px; + margin-bottom:1px; + padding-bottom:3px; + } +.basemodule_post_info { + line-height:22px; + margin:0 0 0 60px; + font-size: 80%; +} +.basemodule_post_content {clear:both;margin:0; overflow:hidden;text-align:justify;} +.basemodule_post_categories { + background: url(images/category.png) no-repeat left center; + padding: 0px 20px; + display: block; + float: left; +} +.left_main { + padding: 0 10px 8px 0; + display:block; + float: left; + width:100%; + line-height:17px; + height:15px; + text-align:right; + vertical-align:top; +} +.basemodule_post_filed_under { + float: left; +} +#basemodule_post_comments_container {} +.basemodule_post_comments { + background-image: url(images/comments.gif); + background-repeat: no-repeat; + margin:5px 0 0 0; + padding-left: 15px; + font-size: 80%; + float: left; +} +.basemodule_post_more { + margin:5px 0 0 0; + font-size: 80%; +} +.basemodule_admin_links { + margin:5px 0 0 0; +} +#basemodule_navbar { + text-align: center; +} +#basemodule_rss { + text-align: center; + padding-top: 10px; +} \ No newline at end of file diff --git a/basemodule/basefiles/module_rtl.css b/basemodule/basefiles/module_rtl.css new file mode 100644 index 0000000..f944196 --- /dev/null +++ b/basemodule/basefiles/module_rtl.css @@ -0,0 +1,68 @@ +.post-date{float:right; margin:0 12px 10px 0;} +.post-date .month{background:#000000 url(images/post-month.gif) no-repeat scroll 0 0; color: #FFF; display:block; font-size:80%;height:25px;line-height:25px;margin:0;text-align:center;width:48px;} +.post-date .day{background:#42A4DC url(images/post-day.gif) no-repeat scroll 0 0; color: #000; display:block; font-size:140%;height:30px;line-height:25px;margin:1px 0 0;text-align:center;width:48px;} +.post-title{margin:0;padding:2px 0 5px 0;} + + +.basemodule_headertable {padding: 0; margin: 0; border-bottom: 1px solid; margin-bottom: 10px;} +.basemodule_modulename {font-size: 0.8em; text-align: left; font-weight: bold; padding-right: 0.3em; line-height: 18px;} +.basemodule_breadcrumb {font-size: 0.8em; line-height: 18px;} +.basemodule_adminlinks {padding-top: 15px; padding-bottom: 5px; font-size: 0.8em; text-align: center; line-height: 18px;} + +.basemodule_post_container { + margin-bottom: 35px; +} + .basemodule_post_container h1 { + margin-top: 20px; + margin-bottom:1px; + padding-bottom:3px; + } +.basemodule_post_info { + line-height:22px; + margin:0 0 0 60px; + font-size: 80%; +} +.basemodule_post_content {clear:both;margin:0; overflow:hidden;text-align:justify;} +.basemodule_post_categories { + background: url(images/category.png) no-repeat left center; + padding: 0px 20px; + display: block; + float: right; +} +.left_main { + padding: 0 10px 8px 0; + display:block; + float: right; + width:100%; + line-height:17px; + height:15px; + text-align:left; + vertical-align:top; +} +.basemodule_post_filed_under { + float: right; +} +#basemodule_post_comments_container {} +.basemodule_post_comments { + background-image: url(images/comments.gif); + background-repeat: no-repeat; + margin:5px 0 0 0; + text-align:right; + padding-left: 15px; + font-size: 80%; + float: right; +} +.basemodule_post_more { + margin:5px 0 0 0; + font-size: 80%; +} +.basemodule_admin_links { + margin:5px 0 0 0; +} +#basemodule_navbar { + text-align: center; +} +#basemodule_rss { + text-align: center; + padding-top: 10px; +} \ No newline at end of file diff --git a/basemodule/basefiles/notification_update.php b/basemodule/basefiles/notification_update.php new file mode 100644 index 0000000..afb622f --- /dev/null +++ b/basemodule/basefiles/notification_update.php @@ -0,0 +1,12 @@ + + * @package basemodule + * @version $Id$ + */ + +include_once '../../mainfile.php'; +include ICMS_ROOT_PATH . '/include/notification_update.php'; \ No newline at end of file diff --git a/basemodule/basefiles/rss.php b/basemodule/basefiles/rss.php new file mode 100644 index 0000000..c0f6eca --- /dev/null +++ b/basemodule/basefiles/rss.php @@ -0,0 +1,45 @@ + + * @package basemodule + * @version $Id$ + */ + +/** Include the module's header for all pages */ +include_once 'header.php'; +include_once ICMS_ROOT_PATH . '/header.php'; + +/** To come soon in imBuilding... + +$clean_post_uid = isset($_GET['uid']) ? intval($_GET['uid']) : FALSE; + +$basemodule_feed = new icms_feeds_Rss(); + +$basemodule_feed->title = $icmsConfig['sitename'] . ' - ' . $icmsModule->name(); +$basemodule_feed->url = XOOPS_URL; +$basemodule_feed->description = $icmsConfig['slogan']; +$basemodule_feed->language = _LANGCODE; +$basemodule_feed->charset = _CHARSET; +$basemodule_feed->category = $icmsModule->name(); + +$basemodule_post_handler = icms_getModuleHandler("post", basename(dirname(__FILE__)), "basemodule"); +//BasemodulePostHandler::getPosts($start = 0, $limit = 0, $post_uid = FALSE, $year = FALSE, $month = FALSE +$postsArray = $basemodule_post_handler->getPosts(0, 10, $clean_post_uid); + +foreach($postsArray as $postArray) { + $basemodule_feed->feeds[] = array ( + 'title' => $postArray['post_title'], + 'link' => str_replace('&', '&', $postArray['itemUrl']), + 'description' => htmlspecialchars(str_replace('&', '&', $postArray['post_lead']), ENT_QUOTES), + 'pubdate' => $postArray['post_published_date_int'], + 'guid' => str_replace('&', '&', $postArray['itemUrl']), + ); +} + +$basemodule_feed->render(); +*/ \ No newline at end of file diff --git a/basemodule/basefiles/templates/basemodule_footer.html b/basemodule/basefiles/templates/basemodule_footer.html new file mode 100644 index 0000000..2b824e0 --- /dev/null +++ b/basemodule/basefiles/templates/basemodule_footer.html @@ -0,0 +1,25 @@ + +<{if $basemodule_is_admin}> + +<{/if}> +<{if $basemodule_post_comment}> + + + + +
+
<{$commentsnav}> <{$lang_notice}>
+
+ + <{if $comment_mode == "flat"}> + <{include file="db:system_comments_flat.html"}> + <{elseif $comment_mode == "thread"}> + <{include file="db:system_comments_thread.html"}> + <{elseif $comment_mode == "nest"}> + <{include file="db:system_comments_nest.html"}> + <{/if}> + +
+
+<{/if}> +<{includeq file='db:system_notification_select.html'}> \ No newline at end of file diff --git a/basemodule/basefiles/templates/basemodule_header.html b/basemodule/basefiles/templates/basemodule_header.html new file mode 100644 index 0000000..3b5962f --- /dev/null +++ b/basemodule/basefiles/templates/basemodule_header.html @@ -0,0 +1,10 @@ +
+ <{if $basemodule_module_home}> + <{$basemodule_module_home}> + <{/if}> + <{if $basemodule_category_path}> + <{if $basemodule_module_home}>><{/if}><{$basemodule_category_path}> + <{/if}> +
+ +
<{if $basemodule_showSubmitLink && $basemodule_userCanSubmit}><{$smarty.const._MI_BASEMODULE_POST_ADD}><{/if}>
\ No newline at end of file diff --git a/basemodule/basefiles/templates/basemodule_requirements.html b/basemodule/basefiles/templates/basemodule_requirements.html new file mode 100644 index 0000000..2952efa --- /dev/null +++ b/basemodule/basefiles/templates/basemodule_requirements.html @@ -0,0 +1,6 @@ +

<{$smarty.const._AM_BASEMODULE_REQUIREMENTS}>

+

<{$smarty.const._AM_BASEMODULE_REQUIREMENTS_INFO}>

+<{foreach item=failed_requirement from=$failed_requirements}> +
  • <{$failed_requirement}>
  • +<{/foreach}> +

    <{$smarty.const._AM_BASEMODULE_REQUIREMENTS_SUPPORT}>

    \ No newline at end of file diff --git a/basemodule/basefiles/templates/blocks/index.html b/basemodule/basefiles/templates/blocks/index.html new file mode 100755 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/templates/blocks/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/basefiles/templates/index.html b/basemodule/basefiles/templates/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/basemodule/basefiles/templates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/basemodule/model/admin/menu.php b/basemodule/model/admin/menu.php new file mode 100644 index 0000000..2118aae --- /dev/null +++ b/basemodule/model/admin/menu.php @@ -0,0 +1,30 @@ + + * @package basemodule + * @version $Id$ + */ + +/** IMBUILDING_ADMIN_MENU_ITEMS */ + +$module = icms::handler("icms_module")->getByDirname(basename(dirname(dirname(__FILE__)))); + +$headermenu[] = array( + "title" => _PREFERENCES, + "link" => "../../system/admin.php?fct=preferences&op=showmod&mod=" . $module->getVar("mid")); +$headermenu[] = array( + "title" => _CO_ICMS_GOTOMODULE, + "link" => ICMS_URL . "/modules/basemodule/"); +$headermenu[] = array( + "title" => _CO_ICMS_UPDATE_MODULE, + "link" => ICMS_URL . "/modules/system/admin.php?fct=modulesadmin&op=update&module=" . basename(dirname(dirname(__FILE__)))); +$headermenu[] = array( + "title" => _MODABOUT_ABOUT, + "link" => ICMS_URL . "/modules/basemodule/admin/about.php"); + +unset($module_handler); \ No newline at end of file diff --git a/basemodule/model/admin/object.php b/basemodule/model/admin/object.php new file mode 100644 index 0000000..ff0c37b --- /dev/null +++ b/basemodule/model/admin/object.php @@ -0,0 +1,99 @@ + + * @package basemodule + * @version $Id$ + */ + +/** + * Edit a Item + * + * @param int $item_id Itemid to be edited +*/ +function edititem($item_id = 0) { + global $basemodule_item_handler, $icmsModule, $icmsAdminTpl; + + $itemObj = $basemodule_item_handler->get($item_id); + + if (!$itemObj->isNew()){ + $icmsModule->displayAdminMenu(/** IMBUILDING_OBJECT_SORT **/, _AM_BASEMODULE_ITEMS . " > " . _CO_ICMS_EDITING); + $sform = $itemObj->getForm(_AM_BASEMODULE_ITEM_EDIT, "additem"); + $sform->assign($icmsAdminTpl); + } else { + $icmsModule->displayAdminMenu(/** IMBUILDING_OBJECT_SORT **/, _AM_BASEMODULE_ITEMS . " > " . _CO_ICMS_CREATINGNEW); + $sform = $itemObj->getForm(_AM_BASEMODULE_ITEM_CREATE, "additem"); + $sform->assign($icmsAdminTpl); + + } + $icmsAdminTpl->display("db:basemodule_admin_item.html"); +} + +include_once "admin_header.php"; + +$basemodule_item_handler = icms_getModuleHandler("item", basename(dirname(dirname(__FILE__))), "basemodule"); +/** Use a naming convention that indicates the source of the content of the variable */ +$clean_op = ""; +/** Create a whitelist of valid values, be sure to use appropriate types for each value + * Be sure to include a value for no parameter, if you have a default condition + */ +$valid_op = array ("mod", "changedField", "additem", "del", "view", ""); + +if (isset($_GET["op"])) $clean_op = htmlentities($_GET["op"]); +if (isset($_POST["op"])) $clean_op = htmlentities($_POST["op"]); + +/** Again, use a naming convention that indicates the source of the content of the variable */ +$clean_item_id = isset($_GET["item_id"]) ? (int)$_GET["item_id"] : 0 ; + +/** + * in_array() is a native PHP function that will determine if the value of the + * first argument is found in the array listed in the second argument. Strings + * are case sensitive and the 3rd argument determines whether type matching is + * required +*/ +if (in_array($clean_op, $valid_op, TRUE)) { + switch ($clean_op) { + case "mod": + case "changedField": + icms_cp_header(); + edititem($clean_item_id); + break; + + case "additem": + $controller = new icms_ipf_Controller($basemodule_item_handler); + $controller->storeFromDefaultForm(_AM_BASEMODULE_ITEM_CREATED, _AM_BASEMODULE_ITEM_MODIFIED); + break; + + case "del": + $controller = new icms_ipf_Controller($basemodule_item_handler); + $controller->handleObjectDeletion(); + break; + + case "view" : + $itemObj = $basemodule_item_handler->get($clean_item_id); + icms_cp_header(); + $itemObj->displaySingleObject(); + break; + + default: + icms_cp_header(); + $icmsModule->displayAdminMenu(/** IMBUILDING_OBJECT_SORT **/, _AM_BASEMODULE_ITEMS); + $objectTable = new icms_ipf_view_Table($basemodule_item_handler); + $objectTable->addColumn(new icms_ipf_view_Column("object_identifier_name")); + $objectTable->addIntroButton("additem", "item.php?op=mod", _AM_BASEMODULE_ITEM_CREATE); + $icmsAdminTpl->assign("basemodule_item_table", $objectTable->fetch()); + $icmsAdminTpl->display("db:basemodule_admin_item.html"); + break; + } + icms_cp_footer(); +} +/** + * If you want to have a specific action taken because the user input was invalid, + * place it at this point. Otherwise, a blank page will be displayed + */ \ No newline at end of file diff --git a/basemodule/model/class/persistableobject.php b/basemodule/model/class/persistableobject.php new file mode 100644 index 0000000..9a1358a --- /dev/null +++ b/basemodule/model/class/persistableobject.php @@ -0,0 +1,42 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_basemodule_Item extends icms_ipf_Object { + /** + * Constructor + * + * @param mod_basemodule_Item $handler Object handler + */ + public function __construct(&$handler) { + parent::__construct($handler); + + $this->quickInitVar("item_id", XOBJ_DTYPE_INT, TRUE); +/** IMBUILDING_INITIATE_VARS **/ + } + + /** + * Overriding the icms_ipf_Object::getVar method to assign a custom method on some + * specific fields to handle the value before returning it + * + * @param str $key key of the field + * @param str $format format that is requested + * @return mixed value of the field that is requested + */ + public function getVar($key, $format = "s") { + if ($format == "s" && in_array($key, array())) { + return call_user_func(array ($this, $key)); + } + return parent::getVar($key, $format); + } +} \ No newline at end of file diff --git a/basemodule/model/class/persistableobjecthandler.php b/basemodule/model/class/persistableobjecthandler.php new file mode 100644 index 0000000..e1a74eb --- /dev/null +++ b/basemodule/model/class/persistableobjecthandler.php @@ -0,0 +1,27 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_basemodule_ItemHandler extends icms_ipf_Handler { + /** + * Constructor + * + * @param icms_db_legacy_Database $db database connection object + */ + public function __construct(&$db) { + parent::__construct($db, "item", "item_id", "object_identifier_name", "object_identifier_desc", "basemodule"); +/** IMBUILDING_HANDLER_ENABLE_UPLOAD **/ + } + +/** IMBUILDING_HANDLER_EVENT_METHODS **/ +} \ No newline at end of file diff --git a/basemodule/model/class/persistableseoobject.php b/basemodule/model/class/persistableseoobject.php new file mode 100644 index 0000000..941e921 --- /dev/null +++ b/basemodule/model/class/persistableseoobject.php @@ -0,0 +1,44 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_basemodule_Item extends icms_ipf_seo_Object { + /** + * Constructor + * + * @param mod_basemodule_Item $handler Object handler + */ + public function __construct(&$handler) { + icms_ipf_object::__construct($handler); + + $this->quickInitVar("item_id", XOBJ_DTYPE_INT, TRUE); +/** IMBUILDING_INITIATE_VARS **/ + + $this->initiateSEO(); + } + + /** + * Overriding the icms_ipf_Object::getVar method to assign a custom method on some + * specific fields to handle the value before returning it + * + * @param str $key key of the field + * @param str $format format that is requested + * @return mixed value of the field that is requested + */ + public function getVar($key, $format = "s") { + if ($format == "s" && in_array($key, array())) { + return call_user_func(array ($this, $key)); + } + return parent::getVar($key, $format); + } +} \ No newline at end of file diff --git a/basemodule/model/icms_version.php b/basemodule/model/icms_version.php new file mode 100644 index 0000000..0200027 --- /dev/null +++ b/basemodule/model/icms_version.php @@ -0,0 +1,95 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +/** General Information */ +$modversion = array( + "name" => _MI_BASEMODULE_MD_NAME, + "version" => 1.0, + "description" => _MI_BASEMODULE_MD_DESC, + "author" => "IMBUILDING_TAG_AUTHOR_NAME", + "credits" => "IMBUILDING_TAG_CREDITS", + "help" => "", + "license" => "GNU General Public License (GPL)", + "official" => 0, + "dirname" => basename(dirname(__FILE__)), + "modname" => "basemodule", + +/** Images information */ + "iconsmall" => "images/icon_small.png", + "iconbig" => "images/icon_big.png", + "image" => "images/icon_big.png", /* for backward compatibility */ + +/** Development information */ + "status_version" => "1.0", + "status" => "Beta", + "date" => "Unreleased", + "author_word" => "", + "warning" => _CO_ICMS_WARNING_BETA, + +/** Contributors */ + "developer_website_url" => "IMBUILDING_TAG_AUTHOR_WEBSITE_URL", + "developer_website_name" => "IMBUILDING_TAG_AUTHOR_WEBSITE_NAME", + "developer_email" => "IMBUILDING_TAG_AUTHOR_EMAIL", + +/** Administrative information */ + "hasAdmin" => 1, + "adminindex" => "admin/index.php", + "adminmenu" => "admin/menu.php", + +/** Install and update informations */ + "onInstall" => "include/onupdate.inc.php", + "onUpdate" => "include/onupdate.inc.php", + +/** Search information */ + "hasSearch" => 0, + "search" => array("file" => "include/search.inc.php", "func" => "basemodule_search"), + +/** Menu information */ + "hasMain" => 1, + +/** Comments information */ + "hasComments" => 1, + "comments" => array( + "itemName" => "post_id", + "pageName" => "post.php", + "callbackFile" => "include/comment.inc.php", + "callback" => array("approve" => "basemodule_com_approve", + "update" => "basemodule_com_update"))); + +/** other possible types: testers, translators, documenters and other */ +$modversion['people']['developers'][] = "IMBUILDING_TAG_DEVELOPER_INFO"; + +/** Manual */ +$modversion['manual']['wiki'][] = "English"; + +/** Database information */ +/** IMBUILDING_OBJECT_ITEMS */ +$modversion["tables"] = icms_getTablesArray($modversion['dirname'], $modversion['object_items']); + +/** Templates information */ +$modversion['templates'] = array( +/** IMBUILDING_OBJECT_TEMPLATES */ + array('file' => 'basemodule_header.html', 'description' => 'Module Header'), + array('file' => 'basemodule_footer.html', 'description' => 'Module Footer')); + +/** Blocks information */ +/** To come soon in imBuilding... */ + +/** Preferences information */ +/** To come soon in imBuilding... */ + +/** Notification information */ +/** To come soon in imBuilding... */ \ No newline at end of file diff --git a/basemodule/model/language/english/admin.php b/basemodule/model/language/english/admin.php new file mode 100644 index 0000000..102e112 --- /dev/null +++ b/basemodule/model/language/english/admin.php @@ -0,0 +1,21 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +// Requirements +define("_AM_BASEMODULE_REQUIREMENTS", "BaseModule Requirements"); +define("_AM_BASEMODULE_REQUIREMENTS_INFO", "We've reviewed your system, unfortunately it doesn't meet all the requirements needed for BaseModule to function. Below are the requirements needed."); +define("_AM_BASEMODULE_REQUIREMENTS_ICMS_BUILD", "BaseModule requires at least ImpressCMS 1.3."); +define("_AM_BASEMODULE_REQUIREMENTS_SUPPORT", "Should you have any question or concerns, please visit our forums at http://community.impresscms.org."); + +/** IMBUILDING_ADMIN_LANGUAGE_DATA */ \ No newline at end of file diff --git a/basemodule/model/language/english/admin_language.tpl b/basemodule/model/language/english/admin_language.tpl new file mode 100644 index 0000000..083de5a --- /dev/null +++ b/basemodule/model/language/english/admin_language.tpl @@ -0,0 +1,12 @@ +// Item +define("_AM_BASEMODULE_ITEMS", "Items"); +define("_AM_BASEMODULE_ITEMS_DSC", "All items in the module"); +define("_AM_BASEMODULE_ITEM_CREATE", "Add a item"); +define("_AM_BASEMODULE_ITEM", "Item"); +define("_AM_BASEMODULE_ITEM_CREATE_INFO", "Fill-out the following form to create a new item."); +define("_AM_BASEMODULE_ITEM_EDIT", "Edit this item"); +define("_AM_BASEMODULE_ITEM_EDIT_INFO", "Fill-out the following form in order to edit this item."); +define("_AM_BASEMODULE_ITEM_MODIFIED", "The item was successfully modified."); +define("_AM_BASEMODULE_ITEM_CREATED", "The item has been successfully created."); +define("_AM_BASEMODULE_ITEM_VIEW", "Item info"); +define("_AM_BASEMODULE_ITEM_VIEW_DSC", "Here is the info about this item."); \ No newline at end of file diff --git a/basemodule/model/language/english/common.php b/basemodule/model/language/english/common.php new file mode 100644 index 0000000..cfe2e58 --- /dev/null +++ b/basemodule/model/language/english/common.php @@ -0,0 +1,15 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +/** IMBUILDING_COMMON_LANGUAGE_DATA */ \ No newline at end of file diff --git a/basemodule/model/language/english/main.php b/basemodule/model/language/english/main.php new file mode 100644 index 0000000..6eeb4b6 --- /dev/null +++ b/basemodule/model/language/english/main.php @@ -0,0 +1,17 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +define("_MD_BASEMODULE_ADMIN_PAGE", ":: Admin page ::"); + +/** IMBUILDING_MAIN_LANGUAGE_DATA */ \ No newline at end of file diff --git a/basemodule/model/language/english/modinfo.php b/basemodule/model/language/english/modinfo.php new file mode 100644 index 0000000..d6cc5ea --- /dev/null +++ b/basemodule/model/language/english/modinfo.php @@ -0,0 +1,18 @@ + + * @package basemodule + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +define("_MI_BASEMODULE_MD_NAME", "BaseModule"); +define("_MI_BASEMODULE_MD_DESC", "ImpressCMS Simple BaseModule"); + +/** IMBUILDING_MI_LANGUAGE_DATA */ \ No newline at end of file diff --git a/basemodule/model/object.php b/basemodule/model/object.php new file mode 100644 index 0000000..8bb0730 --- /dev/null +++ b/basemodule/model/object.php @@ -0,0 +1,37 @@ + +* @package basemodule +* @version $Id$ +*/ + +include_once "header.php"; + +$xoopsOption["template_main"] = "basemodule_item.html"; +include_once ICMS_ROOT_PATH . "/header.php"; + +$basemodule_item_handler = icms_getModuleHandler("item", basename(dirname(__FILE__)), "basemodule"); + +/** Use a naming convention that indicates the source of the content of the variable */ +$clean_item_id = isset($_GET["item_id"]) ? (int)$_GET["item_id"] : 0 ; +$itemObj = $basemodule_item_handler->get($clean_item_id); + +if ($itemObj && !$itemObj->isNew()) { + $icmsTpl->assign("basemodule_item", $itemObj->toArray()); +} else { + $icmsTpl->assign("basemodule_title", _MD_BASEMODULE_ALL_ITEMS); + + $objectTable = new icms_ipf_view_Table($basemodule_item_handler, FALSE, array()); + $objectTable->isForUserSide(); + $objectTable->addColumn(new icms_ipf_view_Column("object_identifier_name")); + $icmsTpl->assign("basemodule_item_table", $objectTable->fetch()); +} + +$icmsTpl->assign("basemodule_module_home", 'getVar("dirname") . '/">' . icms::$module->getVar("name") . ""); + +include_once "footer.php"; \ No newline at end of file diff --git a/basemodule/model/seoobject.php b/basemodule/model/seoobject.php new file mode 100644 index 0000000..63be87f --- /dev/null +++ b/basemodule/model/seoobject.php @@ -0,0 +1,40 @@ + +* @package basemodule +* @version $Id$ +*/ + +include_once "header.php"; + +$xoopsOption["template_main"] = "basemodule_item.html"; +include_once ICMS_ROOT_PATH . "/header.php"; + +$basemodule_item_handler = icms_getModuleHandler("item", basename(dirname(__FILE__)), "basemodule"); + +/** Use a naming convention that indicates the source of the content of the variable */ +$clean_item_id = isset($_GET["item_id"]) ? (int)$_GET["item_id"] : 0 ; +$itemObj = $basemodule_item_handler->get($clean_item_id); + +if($itemObj && !$itemObj->isNew()) { + $icmsTpl->assign("basemodule_item", $itemObj->toArray()); + + $icms_metagen = new icms_ipf_Metagen($itemObj->getVar("object_identifier_name"), $itemObj->getVar("meta_keywords", "n"), $itemObj->getVar("meta_description", "n")); + $icms_metagen->createMetaTags(); +} else { + $icmsTpl->assign("basemodule_title", _MD_BASEMODULE_ALL_ITEMS); + + $objectTable = new icms_ipf_view_Table($basemodule_item_handler, FALSE, array()); + $objectTable->isForUserSide(); + $objectTable->addColumn(new icms_ipf_view_Column("object_identifier_name")); + $icmsTpl->assign("basemodule_item_table", $objectTable->fetch()); +} + +$icmsTpl->assign("basemodule_module_home", 'getVar("dirname") . '/">' . icms::$module->getVar("name") . ""); + +include_once "footer.php"; \ No newline at end of file diff --git a/basemodule/model/templates/basemodule_admin_item.html b/basemodule/model/templates/basemodule_admin_item.html new file mode 100644 index 0000000..6d72f5e --- /dev/null +++ b/basemodule/model/templates/basemodule_admin_item.html @@ -0,0 +1,4 @@ +<{if $basemodule_item_title}>

    <{$basemodule_item_title}>

    <{/if}> +<{if $basemodule_item_info}>

    <{$basemodule_item_info}>

    <{/if}> +<{if $basemodule_item_table}><{$basemodule_item_table}><{/if}> +<{if $additem}><{includeq file='db:system_common_form.html' form=$additem}><{/if}> \ No newline at end of file diff --git a/basemodule/model/templates/basemodule_item.html b/basemodule/model/templates/basemodule_item.html new file mode 100644 index 0000000..b91d660 --- /dev/null +++ b/basemodule/model/templates/basemodule_item.html @@ -0,0 +1,12 @@ +<{includeq file='db:basemodule_header.html'}> +<{if $basemodule_item}> +
    +

    <{$basemodule_item.object_identifier_name}>

    +/** IMBUILDING_OBJECT_TEMPLATE_VARS **/ +
    +<{/if}> +<{if $basemodule_item_table}> +

    <{$basemodule_title}>

    +<{$basemodule_item_table}> +<{/if}> +<{includeq file='db:basemodule_footer.html'}> \ No newline at end of file diff --git a/class/Field.php b/class/Field.php new file mode 100644 index 0000000..8b17ca6 --- /dev/null +++ b/class/Field.php @@ -0,0 +1,126 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_imbuilding_Field extends icms_ipf_Object { + /** + * Constructor + * + * @param mod_imbuilding_FieldHandler $handler Object handler + */ + public function __construct(&$handler) { + parent::__construct($handler); + + $this->quickInitVar('field_id', XOBJ_DTYPE_INT, TRUE); + $this->quickInitVar('object_id', XOBJ_DTYPE_INT); + $this->quickInitVar('field_name', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('field_caption', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('field_desc', XOBJ_DTYPE_TXTAREA); + $this->quickInitVar('field_type', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('field_refer', XOBJ_DTYPE_INT); + $this->quickInitVar('field_extra', XOBJ_DTYPE_TXTAREA); + $this->quickInitVar('field_required', XOBJ_DTYPE_INT); + $this->initNonPersistableVar('another', 'field', XOBJ_DTYPE_INT); + $this->initNonPersistableVar('new_module_wizard', XOBJ_DTYPE_INT); + + $this->hideFieldFromForm(array('object_id', 'field_extra')); + $this->hideFieldFromSingleView('object_id'); + $this->showFieldOnForm('another'); + + $this->setControl('field_desc', 'textarea'); + $this->setControl('field_type', array( + 'itemHandler' => 'field', + 'method' => 'getFieldTypesArray', + 'module' => 'imbuilding')); + $this->setControl('field_required', 'yesno'); + $this->setControl('another', 'yesno'); + } + + /** + * Overriding the icms_ipf_Object::getVar method to assign a custom method on some + * specific fields to handle the value before returning it + * + * @param str $key key of the field + * @param str $format format that is requested + * @return mixed value of the field that is requested + */ + public function getVar($key, $format = 's') { + if ($format == 's' && in_array($key, array('field_type', 'field_required'))) { + return call_user_func(array($this, $key)); + } + return parent::getVar($key, $format); + } + + public function field_type() { + $ret = $this->getVar('field_type', 'e'); + $imbuilding_field_handler = icms_getModuleHandler('field'); + $fieldTypesArray = $imbuilding_field_handler->getFieldTypesArray(); + if (isset($fieldTypesArray[$ret])) { + return $fieldTypesArray[$ret]; + } else { + return $ret; + } + } + + public function field_required() { + $ret = $this->getVar('field_required', 'e'); + if ($ret) { + return 'TRUE'; + } else { + return 'FALSE'; + } + } + + /** + * Build the breadcrumb given a specific situation + * + * @param string $situation + * @return array of items + */ + public function getBreadcrumb($situation) { + $icms_ipf_registry_Handler = icms_ipf_registry_Handler::getInstance(); + $objectObj = $icms_ipf_registry_Handler->getSingleObject('object', $this->getVar('object_id')); + $moduleObj = $icms_ipf_registry_Handler->getSingleObject('module', $objectObj->getVar('module_id')); + + $items = array (); + $items[0]['link'] = IMBUILDING_ADMIN_URL . 'module.php'; + $items[0]['caption'] = _AM_IMBUILDING_MODULES; + + switch ($situation) { + case 'view': + $items[1]['link'] = $moduleObj->getAdminViewItemLink(TRUE); + $items[1]['caption'] = $moduleObj->title(); + + $items[2]['link'] = $objectObj->getAdminViewItemLink(TRUE); + $items[2]['caption'] = $objectObj->title(); + + $items[3]['caption'] = $this->title(); + break; + case 'form': + $items[1]['link'] = $moduleObj->getAdminViewItemLink(TRUE); + $items[1]['caption'] = $moduleObj->title(); + + $items[2]['link'] = $objectObj->getAdminViewItemLink(TRUE); + $items[2]['caption'] = $objectObj->title(); + + if ($this->isNew()) { + $items[3]['caption'] = _AM_IMBUILDING_FIELD_CREATE; + } else { + $items[3]['caption'] = $this->title(); + $items[3]['link'] = $this->getAdminViewItemLink(TRUE); + $items[4]['caption'] = _AM_IMBUILDING_FIELD_EDIT; + } + break; + } + return $items; + } +} \ No newline at end of file diff --git a/class/FieldHandler.php b/class/FieldHandler.php new file mode 100644 index 0000000..39b7e20 --- /dev/null +++ b/class/FieldHandler.php @@ -0,0 +1,89 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_imbuilding_FieldHandler extends icms_ipf_Handler { + private $fieldTypesArray = FALSE; + + /** + * Constructor + */ + public function __construct(&$db) { + parent::__construct($db, 'field', 'field_id', 'field_name', 'field_desc', 'imbuilding'); + } + + public function getFieldTypesArray() { + if (!$this->fieldTypesArray) { + $this->fieldTypesArray = array( + 'XOBJ_DTYPE_TXTBOX' => 'TextBox', + 'XOBJ_DTYPE_TXTAREA' => 'TextArea', + 'XOBJ_DTYPE_INT' => 'Integer', + 'XOBJ_DTYPE_URL' => 'URL', + 'XOBJ_DTYPE_EMAIL' => 'Email', + 'XOBJ_DTYPE_OTHER' => 'Other', + 'XOBJ_DTYPE_SOURCE' => 'Source', + 'XOBJ_DTYPE_STIME' => 'Date (simple)', + 'XOBJ_DTYPE_MTIME' => 'Date (medium)', + 'XOBJ_DTYPE_LTIME' => 'Date (long)', + 'XOBJ_DTYPE_CURRENCY' => 'Currency', + 'XOBJ_DTYPE_FLOAT' => 'Float', + 'XOBJ_DTYPE_TIME_ONLY' => 'Time', + 'XOBJ_DTYPE_URLLINK' => 'URL Link', + 'XOBJ_DTYPE_FILE' => 'Rich File', + 'XOBJ_DTYPE_IMAGE' => 'Image', + 'XOBJ_DTYPE_FORM_SECTION' => 'Form Section (open)', + 'XOBJ_DTYPE_FORM_SECTION_CLOSE' => 'Form Section (close)', + //'XOBJ_DTYPE_ARRAY' => 'Array', + //'XOBJ_DTYPE_SIMPLE_ARRAY' => 'Simple Array', + 'TOBJ_DTYPE_USER' => 'User', + 'TOBJ_DTYPE_LANGUAGE' => 'Language', + 'TOBJ_DTYPE_YESNO' => 'Yes / No' + ); + asort($this->fieldTypesArray); + } + return $this->fieldTypesArray; + } + + public function getFieldsForObject($object_id, $asObject = TRUE) { + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item('object_id', $object_id)); + if ($asObject) { + return $this->getObjects($criteria); + } else { + return $this->getList($criteria); + } + } + + protected function beforeSave(&$obj) { + if ($obj->getVar("field_refer") > 0) $obj->setVar("field_type", "XOBJ_DTYPE_INT"); + return TRUE; + } + + protected function afterSave(&$obj) { + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item("object_id", $obj->getVar("object_id"))); + $criteria->add(new icms_db_criteria_Item("field_id", $obj->getVar("field_id"), "<>")); + $this->updateAll("field_refer", 0,$criteria); + if ($obj->getVar('new_module_wizard')) { + if (!$obj->getVar('another')) { + redirect_header('object.php?op=finishing&object_id=' . $obj->getVar('object_id', 'e'), 3, _AM_IMBUILDING_FIELD_CREATED); + } else { + redirect_header('field.php?op=mod&newmodule=2&object_id=' . $obj->getVar('object_id', 'e'), 3, _AM_IMBUILDING_FIELD_CREATED); + } + } else { + if ($obj->getVar('another')) { + redirect_header('field.php?op=mod&object_id=' . $obj->getVar('object_id', 'e'), 3, _AM_IMBUILDING_FIELD_CREATED); + } + } + return TRUE; + } +} \ No newline at end of file diff --git a/class/Module.php b/class/Module.php new file mode 100644 index 0000000..5a57f90 --- /dev/null +++ b/class/Module.php @@ -0,0 +1,117 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die ("ICMS root path not defined"); + +class mod_imbuilding_Module extends icms_ipf_Object { + /** + * Constructor + * + * @param mod_imbuilding_ModuleHandler $handler handler object + */ + public function __construct(& $handler) { + parent::__construct($handler); + + $this->quickInitVar('module_id', XOBJ_DTYPE_INT, TRUE); + $this->quickInitVar('module_name', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('module_desc', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('author_name', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('author_email', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('author_profile', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('author_website_url', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('author_website_name', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('author_email', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('module_copyright', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('module_credits', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('default_object', XOBJ_DTYPE_INT); + + $this->setControl('default_object', array('method' => 'getObjectsList', 'object' => &$this)); + } + + /** + * Overriding the icms_ipf_Object::getVar method to assign a custom method on some + * specific fields to handle the value before returning it + * + * @param str $key key of the field + * @param str $format format that is requested + * @return mixed value of the field that is requested + */ + public function getVar($key, $format = 's') { + if ($format == 's' && in_array($key, array('default_object'))) { + return call_user_func(array($this, $key)); + } + return parent::getVar($key, $format); + } + + public function getCreateModuleLink() { + $ret = ''; + $ret .= ''; + return $ret; + } + + public function getObjects($asObject = TRUE) { + $imbuilding_object_handler = icms_getModuleHandler('object'); + $ret = $imbuilding_object_handler->getObjectsForModule($this->id(), $asObject); + return $ret; + } + + public function getObjectsList() { + return $this->getObjects(FALSE); + } + + public function default_object() { + $ret = $this->getVar('default_object', 'e'); + + if ($ret == 0) { + $objs = $this->getObjects(TRUE); + if (count($objs) > 0) { + $ret = strtolower($objs[0]->getVar('object_name')); + } + } else { + $icms_persistable_registry = icms_ipf_registry_Handler::getInstance(); + $obj = $icms_persistable_registry->getSingleObject('object', $ret); + if ($obj) { + $ret = strtolower($obj->getVar('object_name')); + } + } + + return $ret; + } + + /** + * Build the breadcrumb given a specific situation + * + * @param string $situation + * @return array of items + */ + public function getBreadcrumb($situation) { + $items = array (); + $items[0]['link'] = IMBUILDING_ADMIN_URL . 'module.php'; + $items[0]['caption'] = _AM_IMBUILDING_MODULES; + + switch ($situation) { + case 'view': + $items[1]['caption'] = $this->title(); + break; + case 'form': + if ($this->isNew()) { + $items[1]['caption'] = _AM_IMBUILDING_MODULE_CREATE; + } else { + $items[1]['caption'] = $this->title(); + $items[1]['link'] = $this->getAdminViewItemLink(TRUE); + $items[2]['caption'] = _AM_IMBUILDING_MODULE_EDIT; + } + break; + } + return $items; + } +} diff --git a/class/ModuleHandler.php b/class/ModuleHandler.php new file mode 100644 index 0000000..34e3a82 --- /dev/null +++ b/class/ModuleHandler.php @@ -0,0 +1,34 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_imbuilding_ModuleHandler extends icms_ipf_Handler { + /** + * Constructor + */ + public function __construct(&$db) { + parent::__construct($db, 'module', 'module_id', 'module_name', '', 'imbuilding'); + } + + protected function beforeDelete(&$obj) { + $imbuilding_object_handler = icms_getModuleHandler('object', basename(dirname(dirname(__FILE__))), "imbuilding"); + $objectsObj = $obj->getObjects(); + foreach ($objectsObj as $objectObj) { + $imbuilding_object_handler->delete($objectObj); + } + return TRUE; + } + + protected function afterInsert(&$obj) { + redirect_header('object.php?op=mod&newmodule=1&module_id=' . $obj->id(), 3, _AM_IMBUILDING_MODULE_CREATED); + } +} \ No newline at end of file diff --git a/class/Newmodule.php b/class/Newmodule.php new file mode 100644 index 0000000..c4c15bc --- /dev/null +++ b/class/Newmodule.php @@ -0,0 +1,709 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_imbuilding_Newmodule { + public $moduleinfo; + public $archiveUrl = FALSE; + private $_basemoduleInfo; + private $_moduleBaseFilesPath; + private $_searchArray; + private $_replaceArray; + private $_moduleObj; + private $_log; + private $_objectsArray; + private $_sort = array(); + + /** + * Constructor + * + * @param mod_imbuilding_Module $moduleObj module object + */ + public function __construct($moduleObj) { + $this->_moduleObj = $moduleObj; + $this->_moduleBaseFilesPath = IMBUILDING_ROOT_PATH . 'basemodule/basefiles'; + $this->_basemoduleInfo['ModuleName'] = 'BaseModule'; + $this->_basemoduleInfo['MODULENAME'] = 'BASEMODULE'; + $this->_basemoduleInfo['modulename'] = 'basemodule'; + $this->_basemoduleInfo['Modulename'] = 'Basemodule'; + $this->_basemoduleInfo['author'] = 'IMBUILDING_TAG_AUTHOR_NAME'; + $this->_basemoduleInfo['author_email'] = 'IMBUILDING_TAG_AUTHOR_EMAIL'; + $this->_basemoduleInfo['author_website_name'] = 'IMBUILDING_TAG_AUTHOR_WEBSITE_NAME'; + $this->_basemoduleInfo['author_website_url'] = 'IMBUILDING_TAG_AUTHOR_WEBSITE_URL'; + $this->_basemoduleInfo['author_profile_url'] = 'IMBUILDING_TAG_AUTHOR_PROFILE_URL'; + $this->_basemoduleInfo['developer_info'] = 'IMBUILDING_TAG_DEVELOPER_INFO'; + $this->_basemoduleInfo['credits'] = 'IMBUILDING_TAG_CREDITS'; + $this->_basemoduleInfo['default_object'] = 'IMBUILDING_DEFAULT_OBJECT'; + $this->_basemoduleInfo['copyright'] = 'IMBUILDING_COPYRIGHT'; + + $this->setModuleInfo('ModuleName', $this->_moduleObj->getVar('module_name')); + $this->setModuleInfo('author', $this->_moduleObj->getVar('author_name')); + $this->setModuleInfo('author_email', $this->_moduleObj->getVar('author_email')); + $this->setModuleInfo('author_website_url', $this->_moduleObj->getVar('author_website_url')); + $this->setModuleInfo('author_profile_url', $this->_moduleObj->getVar('author_profile')); + $this->setModuleInfo('author_website_name', $this->_moduleObj->getVar('author_website_name')); + $this->setModuleInfo('credits', $this->_moduleObj->getVar('module_credits')); + $this->setModuleInfo('default_object', $this->_moduleObj->getVar('default_object')); + $this->setModuleInfo('copyright', $this->_moduleObj->getVar('module_copyright')); + } + + /** + * Set module info + * + * @param string $key module info key + * @param string $value module info value + */ + private function setModuleInfo($key, $value) { + $this->moduleinfo[$key] = trim($value); + } + + /** + * Create module + */ + public function create() { + /** check to see if the module is ready to be generated */ + $this->checkIfReady(); + + if (function_exists('mb_convert_encoding')) { + $newModuleName = mb_convert_encoding($this->moduleinfo['ModuleName'], "", "auto"); + } else { + $newModuleName = $this->moduleinfo['ModuleName']; + } + + $this->addLog('Starting the module generation process...'); + + $newModuleName = str_replace('-', 'xyz', $newModuleName); + $newModuleName = preg_replace("/[[:punct:]]/i", "", $newModuleName); + $newModuleName = str_replace('xyz', '-', $newModuleName); + $newModuleName = str_replace(' ', '_', $newModuleName); + $this->moduleinfo['ModuleName'] = $newModuleName; + + $this->moduleinfo['MODULENAME'] = strtoupper(str_replace("-", "_", $this->moduleinfo['ModuleName'])); + $this->moduleinfo['modulename'] = strtolower(str_replace("-", "_", $this->moduleinfo['ModuleName'])); + $this->moduleinfo['Modulename'] = ucfirst(strtolower($this->moduleinfo['ModuleName'])); + + $this->moduleinfo['developer_info'] = $this->getDeveloperInfo(); + + foreach ($this->moduleinfo as $k => $v) { + $this->_searchArray[] = $this->_basemoduleInfo[$k]; + $this->_replaceArray[] = $v; + } + + $this->addLog('Copying the basemodule files and replacing content'); + $this->cloneFileFolder($this->_moduleBaseFilesPath); + + foreach ($this->moduleinfo as $k => $v) { + $this->addLog("$k: $v"); + } + + $common_language_data = ''; + $admin_language_data = ''; + $mi_language_data = ''; + $main_language_data = ''; + + $this->addLog('Creating sort array'); + $imbuilding_object_handler = icms_getModuleHandler("object", basename(dirname(dirname(__FILE__))), "imbuilding"); + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item("module_id", $this->_moduleObj->getVar("module_id"))); + $criteria->setSort("sort"); + $criteria->setOrder("ASC"); + $objects = $imbuilding_object_handler->getObjects($criteria, TRUE); + $i = 0; + foreach (array_keys($objects) as $object_id) $this->_sort[$object_id] = $i++; + + $this->addLog('Creating model classes and files...'); + foreach ($objects as $objectObj) { + $this->createClassFiles($objectObj); + $common_language_data .= $this->getCommonLanguageData($objectObj); + $admin_language_data .= $this->getAdminLanguageData($objectObj); + $mi_language_data .= $this->getMiLanguageData($objectObj); + $main_language_data .= $this->getMainLanguageData($objectObj); + } + unset($objects); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/language/english/common.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/language/english/common.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace('/** IMBUILDING_COMMON_LANGUAGE_DATA */', $common_language_data, $content); + file_put_contents($newPath, $content); + $this->addLog('Common language file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/language/english/admin.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/language/english/admin.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace('/** IMBUILDING_ADMIN_LANGUAGE_DATA */', $admin_language_data, $content); + file_put_contents($newPath, $content); + $this->addLog('Admin language file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/language/english/modinfo.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/language/english/modinfo.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace('/** IMBUILDING_MI_LANGUAGE_DATA */', $mi_language_data, $content); + file_put_contents($newPath, $content); + $this->addLog('Admin language file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/language/english/main.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/language/english/main.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace('/** IMBUILDING_MAIN_LANGUAGE_DATA */', $main_language_data, $content); + file_put_contents($newPath, $content); + $this->addLog('Main language file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/icms_version.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/icms_version.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace('/** IMBUILDING_OBJECT_ITEMS */', $this->getObjectItemsArray(), $content); + $content = str_replace('/** IMBUILDING_OBJECT_TEMPLATES */', $this->getObjectTemplatesArray(), $content); + //$content = str_replace('/** IMBUILDING_NOTIFICATIONS_FROM */', $this->getNotificationsFromArray(), $content); + file_put_contents($newPath, $content); + $this->addLog('icms_version file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/admin/menu.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/admin/menu.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace('/** IMBUILDING_ADMIN_MENU_ITEMS */', $this->getAdminMenuItems(), $content); + file_put_contents($newPath, $content); + $this->addLog('admin menu file created: ' . $newPath); + + $this->addLog('Module generated succesfully'); + + $this->createArchive(); + $this->addLog('Creating archive: ' . $this->archiveUrl); + } + + /** + * Check if the module is ready to be created + */ + private function checkIfReady() { + /** check if the module's default object was set */ + if (!$this->_moduleObj->getVar('default_object', 'e')) + redirect_header('module.php?op=mod&module_id=' . $this->_moduleObj->id(), 3, _AM_IMBUILDING_CREATE_MODULE_NO_DEFAULT_OBJECT); + + /** check if all objects have a default field */ + foreach($this->_moduleObj->getObjects() as $objectObj) { + if (!$objectObj->getVar('object_identifier_name')) { + redirect_header('object.php?op=mod&object_id=' . $objectObj->id(), 3, sprintf(_AM_IMBUILDING_CREATE_MODULE_OBJECT_NO_DEFAULT_FIELD, $objectObj->title())); + } + } + } + + /** + * Get developer info + * + * @return string developer info + */ + private function getDeveloperInfo() { + if ($this->moduleinfo['author_profile_url']) { + $ret = "[url=" . $this->moduleinfo['author_profile_url'] . "]" . $this->moduleinfo['author'] . "[/url]"; + } else { + $ret = $this->moduleinfo['author']; + } + return $ret; + } + + /** + * Clone file/folder + * + * @param string $path path to file/folder to clone + */ + private function cloneFileFolder($path) { + $newPath = str_replace($this->_moduleBaseFilesPath, ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'], $path); + $newPath = str_replace('basemodule', $this->moduleinfo['modulename'], $newPath); + + if (strpos($path, '.svn') === FALSE) { + if (is_dir($path)) { + // Create new dir + if (!file_exists($newPath) && !mkdir($newPath, 0777, TRUE)){ + icms_core_Debug::message('could not create dir: ' . $newPath); + } + chmod($newPath, 0777); + // check all files in dir, and process it + if ($handle = opendir($path)) { + while ($file = readdir($handle)) { + if ($file != '.' && $file != '..') { + $this->cloneFileFolder("$path/$file"); + } + } + closedir($handle); + } + } else { + if (preg_match('/(.jpg|.gif|.png|.zip)$/i', $path)) { + copy($path, $newPath); + } else { + // file, read it + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + file_put_contents($newPath, $content); + } + } + } + } + + /** + * Create class files for object + * + * @param mod_imbuilding_Object $objectObj object object + */ + private function createClassFiles(&$objectObj) { + $enable_seo = $objectObj->getVar('enable_seo'); + $object_name = $this->getObjectName($objectObj->getVar('object_name')); + $this->_objectsArray[] = $object_name; + $classSearchArray = array( + 'item', + 'Item', + 'ITEM', + 'object_identifier_name', + 'object_identifier_desc', + '/** IMBUILDING_INITIATE_VARS **/', + '/** IMBUILDING_OBJECT_TEMPLATE_VARS **/', + '/** IMBUILDING_HANDLER_ENABLE_UPLOAD **/', + '/** IMBUILDING_HANDLER_EVENT_METHODS **/', + '/** IMBUILDING_OBJECT_SORT **/'); + + $classReplaceArray = array( + $object_name, + ucfirst($object_name), + strtoupper($object_name), + $objectObj->getVar('object_identifier_name'), + $objectObj->getVar('object_identifier_desc'), + $this->getInitiateVarsCode($objectObj), + $this->getUserTemplateVars($objectObj), + $this->getHandlerEnableUpload($objectObj), + $this->getHandlerEventMethods($objectObj), + $this->getObjectSort($objectObj)); + + if ($enable_seo) { + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/class/persistableseoobject.php'; + } else { + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/class/persistableobject.php'; + } + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/class/' . ucfirst($object_name) . '.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + file_put_contents($newPath, $content); + $this->addLog('Path of new object class file is: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/class/persistableobjecthandler.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/class/' . ucfirst($object_name) . 'Handler.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + file_put_contents($newPath, $content); + $this->addLog('Path of new handler class file is: ' . $newPath); + + if ($enable_seo) { + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/seoobject.php'; + } else { + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/object.php'; + } + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/' . $object_name . '.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + file_put_contents($newPath, $content); + $this->addLog('New user object file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/admin/object.php'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/admin/' . $object_name . '.php'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + file_put_contents($newPath, $content); + $this->addLog('New admin object file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/templates/basemodule_item.html'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/templates/' . $this->moduleinfo['modulename'] . '_' . $object_name . '.html'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + file_put_contents($newPath, $content); + $this->addLog('New user template file created: ' . $newPath); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/templates/basemodule_admin_item.html'; + $newPath = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'] . '/templates/' . $this->moduleinfo['modulename'] . '_admin_' . $object_name . '.html'; + $content = file_get_contents($path); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + file_put_contents($newPath, $content); + $this->addLog('New admin template file created: ' . $newPath); + } + + /** + * convert object name to valid object name + * + * @param string $object_name + * @return string converted object name + */ + private function getObjectName($object_name) { + $ret = strtolower($object_name); + $ret = str_replace('-', 'xyz', $ret); + $ret = preg_replace("/[[:punct:]]/i", "", $ret); + $ret = str_replace('xyz', '-', $ret); + $ret = str_replace(' ', '_', $ret); + return $ret; + } + + /** + * generate initiate vars code for object class + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getInitiateVarsCode(&$objectObj) { + $fieldObjs = $objectObj->getFields(); + $ret = ''; + $field_control = array(); + foreach($fieldObjs as $fieldObj) { + $field_name = $fieldObj->getVar('field_name'); + $this->addLog('Generating initiate var for field ' . $fieldObj->getVar('field_name')); + /** check if special type */ + $field_type = $fieldObj->getVar('field_type', 'e'); + switch ($field_type) { + case 'XOBJ_DTYPE_FILE': + $objectObj->setVar('enable_upload', TRUE); + break; + case 'XOBJ_DTYPE_IMAGE': + $field_control[] = '$this->setControl("' . $field_name . '", "image")'; + $objectObj->setVar('enable_upload', TRUE); + break; + case 'TOBJ_DTYPE_USER': + $field_type = 'XOBJ_DTYPE_INT'; + $field_control[] = '$this->setControl("' . $field_name . '", "user")'; + break; + case 'TOBJ_DTYPE_LANGUAGE': + $field_type = 'XOBJ_DTYPE_TXTBOX'; + $field_control[] = '$this->setControl("' . $field_name . '", "language")'; + break; + case 'TOBJ_DTYPE_YESNO': + $field_type = "XOBJ_DTYPE_INT"; + $field_control[] = '$this->setControl("' . $field_name . '", "yesno")'; + break; + } + + if ($fieldObj->getVar("field_refer") > 0) { + $imbuilding_object_handler = icms_getModuleHandler("object", basename(dirname(dirname(__FILE__))), "imbuilding"); + $objectObj_tmp = $imbuilding_object_handler->get($fieldObj->getVar("field_refer")); + $field_type = "XOBJ_DTYPE_INT"; + $field_control[] = '$this->setControl("' . $field_name . '", array( + "itemHandler" => "' . $objectObj_tmp->getVar("object_name") . '", + "method" => "getList", + "module" => "' . $this->moduleinfo['modulename'] . '"))'; + } + + $ret .= ' $this->quickInitVar("' . $field_name . '", ' . $field_type . ', ' . $fieldObj->getVar('field_required') . '); +'; + } + if ($objectObj->getVar('object_counter')) { + $ret .= ' $this->initCommonVar("counter"); +'; + } + if ($objectObj->getVar('object_dohtml')) { + $ret .= ' $this->initCommonVar("dohtml"); +'; + } + if ($objectObj->getVar('object_dobr')) { + $ret .= ' $this->initCommonVar("dobr"); +'; + } + if ($objectObj->getVar('object_doimage')) { + $ret .= ' $this->initCommonVar("doimage"); +'; + } + if ($objectObj->getVar('object_dosmiley')) { + $ret .= ' $this->initCommonVar("dosmiley"); +'; + } + if ($objectObj->getVar('object_doxcode')) { + $ret .= ' $this->initCommonVar("docxode"); +'; + } + + if (count($field_control) > 0) { + foreach ($field_control as $control) { + $ret .= ' ' . $control . '; +'; + } + } + + return $ret; + } + + /** + * Generate template vars for object + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getUserTemplateVars(&$objectObj) { + $fieldObjs = $objectObj->getFields(); + $object_name = $this->getObjectName($objectObj->getVar('object_name')); + $OBJECT_NAME = strtoupper($object_name); + $this->addLog('Generating user template vars for object ' . $objectObj->getVar('object_name')); + $ret = ''; + foreach ($fieldObjs as $fieldObj) { + $field_name = $fieldObj->getVar('field_name'); + if ($field_name != $objectObj->getVar('object_identifier_name')) { + $this->addLog($field_name); + if ($fieldObj->getVar('field_type', 'e') == 'XOBJ_DTYPE_TXTAREA') { + $ret .= '
    <{$smarty.const._CO_' . $this->moduleinfo['MODULENAME'] . '_' . $OBJECT_NAME . '_' . strtoupper($field_name) . '}>
    +
    <{$' . $this->moduleinfo['modulename'] . '_' . $object_name . '.' . $field_name . '}>
    +'; + } else { + $ret .= '
    <{$smarty.const._CO_' . $this->moduleinfo['MODULENAME'] . '_' . $OBJECT_NAME . '_' . strtoupper($field_name) . '}>: <{$' . $this->moduleinfo['modulename'] . '_' . $object_name . '.' . $field_name . '}>
    +'; + } + } + } + return $ret; + } + + /** + * Check if upload needs to be enabled for object handler and generate PHP code + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getHandlerEnableUpload(&$objectObj) { + if (!$objectObj->getVar("enable_upload")) return ""; + return ' $this->enableUpload(array("image/gif", "image/jpeg", "image/pjpeg", "image/png"), 512000, 800, 600);'; + } + + /** + * Generate event methods for object handler + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getHandlerEventMethods(&$objectObj) { + $imbuilding_field_handler = icms_getModuleHandler("field", basename(dirname(dirname(__FILE__))), "imbuilding"); + $fields = $imbuilding_field_handler->getObjects(icms_buildCriteria(array("field_refer" => $objectObj->getVar("object_id")))); + if (count($fields) == 0) return ""; + + $ret = ' /* + * beforeDelete event + * + * Event automatically triggered by IcmsPersistable Framework before the object is deleted + * + * @param mod_' . $this->moduleinfo['modulename'] . '_' . ucfirst($objectObj->getVar("object_name")) . ' $obj ' . ucfirst($objectObj->getVar("object_name")) . ' object + * @return bool + */ + protected function beforeDelete(&$obj) { +'; + + $objectname_id = $this->getObjectName($objectObj->getVar("object_name")) . "_id"; + $object_ids = array(); + foreach ($fields as $fieldObj) { + if (count(array_intersect($object_ids, array($fieldObj->getVar("object_id")))) > 0) continue; + $object_ids[] = $fieldObj->getVar("object_id"); + $imbuilding_object_handler = icms_getModuleHandler("object", basename(dirname(dirname(__FILE__))), "imbuilding"); + $objectObj_tmp = $imbuilding_object_handler->get($fieldObj->getVar("object_id")); + $handler = '$' . $this->moduleinfo['modulename'] . '_' . $objectObj_tmp->getVar("object_name") . '_handler'; + $ret .= ' ' . $handler . ' = icms_getModuleHandler("'. $objectObj_tmp->getVar("object_name") . '", basename(dirname(dirname(__FILE__))), "' . $this->moduleinfo['modulename'] . '"); + ' . $handler . '->deleteAll(icms_buildCriteria(array("' . $fieldObj->getVar("field_name") . '" => $obj->getVar("' . $objectname_id . '")))); +'; + } + + $ret .= ' return TRUE; + }'; + + return $ret; + } + + private function getObjectSort(&$objectObj) { + return $this->_sort[$objectObj->getVar("object_id")]; + } + + /** + * Get common language data for object + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getCommonLanguageData(&$objectObj) { + $object_name = $this->getObjectName($objectObj->getVar('object_name')); + $OBJECT_NAME = strtoupper($object_name); + $this->addLog('Adding common language data for object ' . $object_name); + $ret = "// " . $object_name . " +"; + $fieldObjs = $objectObj->getFields(); + foreach($fieldObjs as $fieldObj) { + $ret .= "define(\"_CO_" . $this->moduleinfo['MODULENAME'] . "_" . $OBJECT_NAME . "_" . strtoupper($fieldObj->getVar('field_name')) . "\", \"" . $fieldObj->getVar('field_caption') . "\"); +"; + $ret .= "define(\"_CO_" . $this->moduleinfo['MODULENAME'] . "_" . $OBJECT_NAME . "_" . strtoupper($fieldObj->getVar('field_name')) . "_DSC\", \"" . $fieldObj->getVar('field_desc') . "\"); +"; + } + return $ret; + } + + /** + * Get admin language data for object + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getAdminLanguageData(&$objectObj) { + $object_name = $this->getObjectName($objectObj->getVar('object_name')); + $OBJECT_NAME = strtoupper($object_name); + $this->addLog('Adding admin language data for object ' . $object_name); + + $classSearchArray = array( + 'item', + 'Item', + 'ITEM' + ); + $classReplaceArray = array( + $object_name, + ucfirst($object_name), + $OBJECT_NAME + ); + + $path = IMBUILDING_ROOT_PATH . 'basemodule' . '/model/language/english/admin_language.tpl'; + $handle = fopen($path, "r"); + $content = fread($handle, filesize($path)); + fclose($handle); + $content = str_replace($this->_searchArray, $this->_replaceArray, $content); + $content = str_replace($classSearchArray, $classReplaceArray, $content); + return $content; + } + + /** + * Get module info language data for object + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getMiLanguageData(&$objectObj) { + $object_name = $this->getObjectName($objectObj->getVar('object_name')); + $OBJECT_NAME = strtoupper($object_name); + $this->addLog('Adding MI language data for object ' . $object_name); + $ret = ''; + $ret .= "define(\"_MI_" . $this->moduleinfo['MODULENAME'] . "_" . $OBJECT_NAME . "S\", \"" . ucfirst($object_name) . "s\"); +"; + return $ret; + } + + /** + * Get main language data for object + * + * @param mod_imbuilding_Object $objectObj object object + * @return string + */ + private function getMainLanguageData(&$objectObj) { + $object_name = $this->getObjectName($objectObj->getVar('object_name')); + $OBJECT_NAME = strtoupper($object_name); + $this->addLog('Adding Main language data for object ' . $object_name); + $ret = ''; + $ret .= "define(\"_MD_" . $this->moduleinfo['MODULENAME'] . "_ALL_" . $OBJECT_NAME . "S\", \"All " . $object_name . "s\"); +"; + return $ret; + } + + /** + * Get object items for icms_version.php + * + * @return string + */ + private function getObjectItemsArray() { + $ret = ''; + for ($i=0; $i_objectsArray); $i++) { + if ($i == 0) { + $ret .= '$modversion[\'object_items\'][1] = \'' . $this->_objectsArray[$i] . '\'; +'; + } else { + $ret .= '$modversion[\'object_items\'][] = \'' . $this->_objectsArray[$i] . '\'; +'; + } + } + return $ret; + } + + /** + * Get template information for icms_version.php + * + * @return string + */ + private function getObjectTemplatesArray() { + $ret = ''; + if (!$this->_objectsArray) return $ret; + + foreach ($this->_objectsArray as $object) { + $object_name = $this->getObjectName($object); + $ret .= ' array("file" => "' . $this->moduleinfo['modulename'] . "_admin_" . $object_name . '.html", "description" => "' . $object_name . ' Admin Index"), + array("file" => "' . $this->moduleinfo['modulename'] . "_" . $object_name . '.html", "description" => "' . $object_name . ' Index"), +'; + } + return $ret; + } + + /** + * Get admin menu items for admin/menu.php + * + * @return string + */ + private function getAdminMenuItems() { + $ret = ''; + if (!$this->_objectsArray) return $ret; + + foreach ($this->_objectsArray as $object) { + $object_name = $this->getObjectName($object); + $OBJECT_NAME = strtoupper($object_name); + $ret .= '$adminmenu[] = array( + "title" => _MI_' . $this->moduleinfo['MODULENAME'] . '_' . $OBJECT_NAME . 'S, + "link" => "admin/' . $object_name . '.php"); +'; + } + return $ret; + } + + /** + * Generate zip archive of generated module source + */ + private function createArchive() { + //icms::$logger->disableLogger(); + include_once IMBUILDING_ROOT_PATH . 'include/easyarchives/EasyArchive.class.php'; + $arch = new archive; + $fileName = $this->moduleinfo['modulename'] . '_' . time() . '.zip'; + $archiveFilePath = ICMS_UPLOAD_PATH . '/imbuilding/packages/' . $fileName; + $archiveSource = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename']; + $arch->make($archiveSource, $archiveFilePath); + $this->archiveUrl = ICMS_UPLOAD_URL . '/imbuilding/packages/' . $fileName; + } + + /** + * add log entry + * + * @param string $text log text + */ + private function addLog($text) { + $this->_log[] = $text; + } + + /** + * display log + * + * @return string + */ + public function displayLog() { + $ret = ""; + foreach ($this->_log as $v) { + $ret .= $v . "
    "; + } + return $ret; + } +} \ No newline at end of file diff --git a/class/Object.php b/class/Object.php new file mode 100644 index 0000000..48f9b04 --- /dev/null +++ b/class/Object.php @@ -0,0 +1,144 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_imbuilding_Object extends icms_ipf_Object { + /** + * Constructor + * + * @param mod_imbuilding_ObjectHandler $handler handler object + */ + public function __construct(&$handler) { + parent::__construct($handler); + + $this->quickInitVar('object_id', XOBJ_DTYPE_INT, TRUE); + $this->quickInitVar('module_id', XOBJ_DTYPE_INT); + $this->quickInitVar('object_name', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('object_desc', XOBJ_DTYPE_TXTAREA); + $this->quickInitVar('object_identifier_name', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('object_identifier_desc', XOBJ_DTYPE_TXTBOX); + $this->quickInitVar('object_counter', XOBJ_DTYPE_INT); + $this->quickInitVar('object_dohtml', XOBJ_DTYPE_INT); + $this->quickInitVar('object_dobr', XOBJ_DTYPE_INT); + $this->quickInitVar('object_doimage', XOBJ_DTYPE_INT); + $this->quickInitVar('object_dosmiley', XOBJ_DTYPE_INT); + $this->quickInitVar('object_doxcode', XOBJ_DTYPE_INT); + $this->quickInitVar('enable_seo', XOBJ_DTYPE_INT); + $this->quickInitVar('sort', XOBJ_DTYPE_INT, TRUE, FALSE, FALSE, 0); + $this->initNonPersistableVar('new_module_wizard', XOBJ_DTYPE_INT); + $this->initNonPersistableVar('enable_upload', XOBJ_DTYPE_INT); + + $this->setControl('object_desc', 'textarea'); + $this->setControl('object_identifier_name', array ( + 'method' => 'getObjectFieldsList', + 'object' => &$this + )); + $this->setControl('object_identifier_desc', array ( + 'method' => 'getObjectFieldsList', + 'object' => &$this + )); + $this->setControl('object_counter', 'yesno'); + $this->setControl('object_dohtml', 'yesno'); + $this->setControl('object_dobr', 'yesno'); + $this->setControl('object_doimage', 'yesno'); + $this->setControl('object_dosmiley', 'yesno'); + $this->setControl('object_doxcode', 'yesno'); + $this->setControl('enable_seo', 'yesno'); + $this->hideFieldFromForm('module_id'); + $this->hideFieldFromSingleView('module_id'); + } + + /** + * Overriding the icms_ipf_Object::getVar method to assign a custom method on some + * specific fields to handle the value before returning it + * + * @param str $key key of the field + * @param str $format format that is requested + * @return mixed value of the field that is requested + */ + public function getVar($key, $format = 's') { + if ($format == 's' && in_array($key, array ('object_identifier_name', 'object_identifier_desc'))) { + return call_user_func(array ($this, $key)); + } + return parent::getVar($key, $format); + } + + public function getFields() { + $imbuilding_fields_handler = icms_getModuleHandler('field'); + $ret = $imbuilding_fields_handler->getFieldsForObject($this->id()); + return $ret; + } + + public function getObjectFieldsList() { + $imbuilding_fields_handler = icms_getModuleHandler('field'); + $ret = $imbuilding_fields_handler->getFieldsForObject($this->id(), FALSE); + return $ret; + } + + public function object_identifier_name() { + $icms_ipf_registry_Handler = icms_ipf_registry_Handler::getInstance(); + $ret = $this->getVar('object_identifier_name', 'e'); + $obj = $icms_ipf_registry_Handler->getSingleObject('field', $ret); + if ($obj) $ret = $obj->getVar('field_name'); + return $ret; + } + + public function object_identifier_desc() { + $icms_ipf_registry_Handler = icms_ipf_registry_Handler::getInstance(); + $ret = $this->getVar('object_identifier_desc', 'e'); + $obj = $icms_ipf_registry_Handler->getSingleObject('field', $ret); + if ($obj) $ret = $obj->getVar('field_name'); + return $ret; + } + + /** + * Build the breadcrumb given a specific situation + * + * @param string $situation + * @return array of items + */ + public function getBreadcrumb($situation) { + $icms_ipf_registry_Handler = icms_ipf_registry_Handler::getInstance(); + $moduleObj = $icms_ipf_registry_Handler->getSingleObject('module', $this->getVar('module_id')); + + $items = array (); + $items[0]['link'] = IMBUILDING_ADMIN_URL . 'module.php'; + $items[0]['caption'] = _AM_IMBUILDING_MODULES; + + switch ($situation) { + case 'view': + $items[1]['link'] = $moduleObj->getAdminViewItemLink(TRUE); + $items[1]['caption'] = $moduleObj->title(); + + $items[2]['caption'] = $this->title(); + break; + case 'form': + $items[1]['link'] = $moduleObj->getAdminViewItemLink(TRUE); + $items[1]['caption'] = $moduleObj->title(); + + if ($this->isNew()) { + $items[2]['caption'] = _AM_IMBUILDING_OBJECT_CREATE; + } else { + $items[2]['caption'] = $this->title(); + $items[2]['link'] = $this->getAdminViewItemLink(TRUE); + $items[3]['caption'] = _AM_IMBUILDING_OBJECT_EDIT; + } + break; + } + return $items; + } + + public function getObjectSortControl() { + $control = new icms_form_elements_Text('', 'sort[]', 3, 3, $this->getVar("sort", "e")); + return $control->render(); + } +} \ No newline at end of file diff --git a/class/ObjectHandler.php b/class/ObjectHandler.php new file mode 100644 index 0000000..474fa14 --- /dev/null +++ b/class/ObjectHandler.php @@ -0,0 +1,64 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +class mod_imbuilding_ObjectHandler extends icms_ipf_Handler { + /** + * Constructor + */ + public function __construct(&$db) { + parent::__construct($db, 'object', 'object_id', 'object_name', 'object_desc', 'imbuilding'); + } + + public function getObjectsForModule($module_id, $asObject = TRUE) { + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item('module_id', $module_id)); + if ($asObject) { + return $this->getObjects($criteria); + } else { + return $this->getList($criteria); + } + } + + public function getObjectsReferList($module_id = FALSE, $object_id = FALSE) { + $criteria = new icms_db_criteria_Compo(); + if ($module_id !== FALSE) $criteria->add(new icms_db_criteria_Item('module_id', $module_id)); + if ($object_id !== FALSE) $criteria->add(new icms_db_criteria_Item('object_id', $object_id, '<>')); + return array_merge(array(0 => "---"), $this->getList($criteria)); + } + + protected function beforeDelete(&$obj) { + $imbuilding_field_handler = icms_getModuleHandler('field'); + $fields = $obj->getFields(); + foreach($fields as $fieldObj) { + $imbuilding_field_handler->delete($fieldObj); + } + $imbuilding_field_handler->updateAll("field_refer", 0, icms_buildCriteria(array("field_refer" => $obj->getVar("object_id"))), TRUE); + return TRUE; + } + + protected function afterInsert(&$obj) { + if ($obj->getVar('new_module_wizard')) { + redirect_header('field.php?op=mod&newmodule=1&object_id=' . $obj->id(), 3, _AM_IMBUILDING_OBJECT_CREATED); + } else { + return TRUE; + } + } + + protected function afterUpdate(&$obj) { + if ($obj->getVar('new_module_wizard')) { + redirect_header('module.php', 5, _AM_IMBUILDING_MODULE_CREATED_FINISH); + } else { + return TRUE; + } + } +} \ No newline at end of file diff --git a/class/index.html b/class/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/class/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/changelog.txt b/docs/changelog.txt new file mode 100644 index 0000000..5ec397c --- /dev/null +++ b/docs/changelog.txt @@ -0,0 +1,24 @@ +imBuilding Changelog + +=== imBuilding 2.0 Final === +Release date: 18 Sept 2011 +Revision: 22688 + +'''Fixed''' +#251: required folders are missing after installation (phoenyx) +#252: added support for more object types and fixed broken ones (phoenyx) +#623: tabs are not highlighted properly (phoenyx) + +'''Added''' +#624: allow to create simple foreign key relationships (phoenyx) +#625: display log after module was generated (phoenyx) + +'''Improved''' +#621: Update imBuilding for 1.3 (phoenyx) +#622: codebase cleanup (applied coding standards) (phoenyx) + +=== imBuilding 1.0 Final === +Release date: 12/23/2009 + +See the changelog on ImpressCMS Addons Trac: +http://trac.impresscms.org/addons/log/modules/imbuilding/releases/imbuilding_1.0_final \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/docs/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/install.txt b/docs/install.txt new file mode 100644 index 0000000..e89553f --- /dev/null +++ b/docs/install.txt @@ -0,0 +1,19 @@ +/** +* Install information +* +* @copyright http://smartfactory.ca The SmartFactory +* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) +* @since 1.0 +* @author marcan aka Marc-André Lanciault +* @version $Id$ +*/ + +How to install imBuilding +============================= + +imBuilding is installed as a regular ImpressCMS module, which means you should copy the complete /imbuilding folder into the /modules directory of your website. Then, log in to your site as administrator, go to System Admin > Modules, look for the imBuilding icon in the list of uninstalled modules and click in the install icon. Follow the directions in the screen and you'll be ready to go. + + +.:: The SmartFactory ::. +.:: Open Source : smartfactory.ca ::. +.:: Professionnal : inboxinternational.com ::. \ No newline at end of file diff --git a/docs/license.txt b/docs/license.txt new file mode 100644 index 0000000..29a0567 --- /dev/null +++ b/docs/license.txt @@ -0,0 +1,98 @@ +/** +* License of the module +* +* @copyright http://smartfactory.ca The SmartFactory +* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) +* @since 1.0 +* @author marcan aka Marc-André Lanciault +* @version $Id$ +*/ + + +GNU GENERAL PUBLIC LICENSE Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is TRUE depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/docs/readme.txt b/docs/readme.txt new file mode 100644 index 0000000..f4ffb48 --- /dev/null +++ b/docs/readme.txt @@ -0,0 +1,28 @@ +/** +* Readme information +* +* @copyright http://smartfactory.ca The SmartFactory +* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) +* @since 1.0 +* @author marcan aka Marc-André Lanciault +* @version $Id$ +*/ + + +What is imBuilding ? +====================== + +imBuilding is a module allowing the creation of ImpressCMS module based on the ImpressCMS Persistable Framework. + +If you want to learn more about the ImpressCMS Persistable Framework, you can have a look at this video: +http://www.youtube.com/user/impresscms#p/a/f/1/M-wSw8b_M3Q + +Support and Feedback +==================== + +We encourage you to visit The ImpressCMS Community forums to get and offer support for this module. Feedback as also always appreciated. A dedicated forum for The SmartFactory modules is available here: +http://community.impresscms.org/modules/newbb/viewforum.php?forum=71 + +.:: The SmartFactory ::. +.:: Open Source : smartfactory.ca ::. +.:: Professionnal : inboxinternational.com ::. \ No newline at end of file diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..18dded4 --- /dev/null +++ b/footer.php @@ -0,0 +1,14 @@ + + * @package imbuilding + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); +include_once ICMS_ROOT_PATH . "/footer.php"; \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..9119f0c --- /dev/null +++ b/header.php @@ -0,0 +1,14 @@ + + * @package imbuilding + * @version $Id$ + */ + +include_once "../../mainfile.php"; +include_once dirname(__FILE__) . "/include/common.php"; \ No newline at end of file diff --git a/icms_version.php b/icms_version.php new file mode 100644 index 0000000..f4db67a --- /dev/null +++ b/icms_version.php @@ -0,0 +1,79 @@ + + * @package imbuilding + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +$modversion = array( +/** General Information */ + "name" => _MI_IMBUILDING_MD_NAME, + "version" => 2.0, + "description" => _MI_IMBUILDING_MD_DESC, + "author" => "The SmartFactory", + "credits" => "INBOX International inc.", + "help" => "", + "license" => "GNU General Public License (GPL)", + "official" => 1, + "dirname" => basename(dirname(__FILE__)), + "modname" => "imbuilding", + +/** Images information */ + "iconsmall" => "images/icon_small.png", + "iconbig" => "images/icon_big.png", + "image" => "images/icon_big.png", /* for backward compatibility */ + +/** Development information */ + "status_version" => "Final", + "status" => "Final", + "date" => "18 Sept 2011", + "author_word" => "", + "warning" => _CO_ICMS_WARNING_FINAL, + +/** Contributors */ + "developer_website_url" => "http://inboxinternational.com", + "developer_website_name" => "INBOX International inc.", + "developer_email" => "info@inboxintl.com", + +/** Administrative information */ + "hasAdmin" => 1, + "adminindex" => "admin/index.php", + "adminmenu" => "admin/menu.php", + + /** Install and update informations */ + "onInstall" => "include/onupdate.inc.php", + "onUpdate" => "include/onupdate.inc.php", + +/** Search information */ + "hasSearch" => 0, + +/** Menu information */ + "hasMain" => 0, + +/** IPF object information */ + "object_items" => array("module", "object", "field")); + +$modversion["people"]["developers"][] = "[url=http://community.impresscms.org/userinfo.php?uid=168]marcan[/url] (Marc-André Lanciault)"; +$modversion["people"]["developers"][] = "[url=http://community.impresscms.org/userinfo.php?uid=1168]phoenyx[/url]"; + +/** Manual */ +//$modversion["manual"]["wiki"][] = "English"; + +$modversion["tables"] = icms_getTablesArray($modversion["dirname"], $modversion["object_items"]); + +/** Templates information */ +$modversion["templates"] = array( + array("file" => "imbuilding_admin_index.html", "description" => "Admin Index template"), + array("file" => "imbuilding_admin_module.html", "description" => "Module admin template"), + array("file" => "imbuilding_admin_object.html", "description" => "Object Admin template"), + array("file" => "imbuilding_admin_field.html", "description" => "Field Admin template"), + array("file" => "imbuilding_requirements.html", "description" => "Requirements")); \ No newline at end of file diff --git a/images/blank.png b/images/blank.png new file mode 100644 index 0000000..e1ee728 Binary files /dev/null and b/images/blank.png differ diff --git a/images/category.png b/images/category.png new file mode 100644 index 0000000..784e8fa Binary files /dev/null and b/images/category.png differ diff --git a/images/clock.gif b/images/clock.gif new file mode 100644 index 0000000..6ac6ebc Binary files /dev/null and b/images/clock.gif differ diff --git a/images/comments.gif b/images/comments.gif new file mode 100644 index 0000000..9fb650c Binary files /dev/null and b/images/comments.gif differ diff --git a/images/cssbutton.gif b/images/cssbutton.gif new file mode 100644 index 0000000..b5ceb4a Binary files /dev/null and b/images/cssbutton.gif differ diff --git a/images/icon_big.png b/images/icon_big.png new file mode 100644 index 0000000..8b9f1d0 Binary files /dev/null and b/images/icon_big.png differ diff --git a/images/icon_medium.png b/images/icon_medium.png new file mode 100644 index 0000000..d3f2460 Binary files /dev/null and b/images/icon_medium.png differ diff --git a/images/icon_small.png b/images/icon_small.png new file mode 100644 index 0000000..594529e Binary files /dev/null and b/images/icon_small.png differ diff --git a/images/index.html b/images/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/post-day.gif b/images/post-day.gif new file mode 100644 index 0000000..2f492aa Binary files /dev/null and b/images/post-day.gif differ diff --git a/images/post-month.gif b/images/post-month.gif new file mode 100644 index 0000000..f2d6c6b Binary files /dev/null and b/images/post-month.gif differ diff --git a/images/post.png b/images/post.png new file mode 100644 index 0000000..7cd52bd Binary files /dev/null and b/images/post.png differ diff --git a/images/rss.png b/images/rss.png new file mode 100644 index 0000000..02eb541 Binary files /dev/null and b/images/rss.png differ diff --git a/images/user-pages.gif b/images/user-pages.gif new file mode 100644 index 0000000..ad39fb7 Binary files /dev/null and b/images/user-pages.gif differ diff --git a/images/user.gif b/images/user.gif new file mode 100644 index 0000000..dcb5c2a Binary files /dev/null and b/images/user.gif differ diff --git a/include/common.php b/include/common.php new file mode 100644 index 0000000..9720e51 --- /dev/null +++ b/include/common.php @@ -0,0 +1,21 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +if (!defined("IMBUILDING_DIRNAME")) define("IMBUILDING_DIRNAME", $modversion["dirname"] = basename(dirname(dirname(__FILE__)))); +if (!defined("IMBUILDING_URL")) define("IMBUILDING_URL", ICMS_URL . "/modules/" . IMBUILDING_DIRNAME . "/"); +if (!defined("IMBUILDING_ROOT_PATH")) define("IMBUILDING_ROOT_PATH", ICMS_ROOT_PATH . "/modules/" . IMBUILDING_DIRNAME . "/"); +if (!defined("IMBUILDING_IMAGES_URL")) define("IMBUILDING_IMAGES_URL", IMBUILDING_URL . "images/"); +if (!defined("IMBUILDING_ADMIN_URL")) define("IMBUILDING_ADMIN_URL", IMBUILDING_URL . "admin/"); + +// Include the common language file of the module +icms_loadLanguageFile("imbuilding", "common"); \ No newline at end of file diff --git a/include/easyarchives/EasyArchive.class.php b/include/easyarchives/EasyArchive.class.php new file mode 100755 index 0000000..fdabf76 --- /dev/null +++ b/include/easyarchives/EasyArchive.class.php @@ -0,0 +1,189 @@ +make('./', './archive.tar.gzip'); +var_export($arch->infos('./toto.bzip2')); +$arch->extract('./toto.zip', './my_dir/'); +$arch->download('./my_dir/'); +**/ + +class archive { + var $WathArchive = array ( + '.zip' =>'zip', + '.tar' =>'tar', + '.gz' =>'gz', + '.gzip' =>'gz', + '.bzip' =>'bz', + '.bz' =>'bz', + '.bzip2' =>'bz', + '.bz2' =>'bz', + '.tgz' =>'gz', + '.tgzip' =>'gz', + '.tbzip' =>'bz', + '.tbz' =>'bz', + '.tbzip2' =>'bz', + '.tbz2' =>'bz', + ); + function download ($src, $name) + { + header('Content-Type: application/force-download'); + header("Content-Transfer-Encoding: binary"); + header("Cache-Control: no-cache, must-revalidate, max-age=60"); + header("Expires: Sat, 01 Jan 2000 12:00:00 GMT"); + header('Content-Disposition: attachment;filename="'.$name."\"\n"); + $data = $this->make($src, $name, FALSE); + header("Content-Length: ".strlen($data)); + print($data); + } + function make ($src, $name="Archive.tgz", $returnFile=TRUE) + { + $ext = '.'.pathinfo ($name, PATHINFO_EXTENSION); + foreach ($this->WathArchive as $key=>$val) + if (stripos($ext, $key)!==FALSE) $comp=$val; + if ($comp == 'zip') + { + $zip = new zip; + if ($returnFile) + $result = $zip->makeZip($src, $name); + else + { + $tmpZip = './'.md5(serialize($src)).'.zip'; + $result = $zip->makeZip($src, $tmpZip); + $result = file_get_contents($tmpZip); + unlink($tmpZip); + } + return $result; + } + elseif (strlen($comp)>1) + { + if (count($src)>1 || is_dir($src[0]) || $comp == 'tar') + { + $tar = new tar; + $src = $tar->makeTar($src); + } + if ($comp == 'bz') + { + $bzip2 = new bzip2; + $src = $bzip2->makeBzip2($src); + } + elseif ($comp == 'gz') + { + $gzip = new gzip; + $src = $gzip->makeGzip($src); + } + if ($returnFile) + { + file_put_contents($dest, $src); + return $dest; + } + return $src; + } + else return 'Specifie a valid format at the end of '.$name.' filename ! '; + } + function infos ($src, $data=FALSE) + { + $ext = '.'.pathinfo ($src, PATHINFO_EXTENSION); + foreach ($this->WathArchive as $key=>$val) + if (stripos($ext, $key)!==FALSE) $comp=$val; + if ($comp == 'zip') + { + $zip = new zip; + $zipresult = $zip->infosZip($src, $data); + $result ['Items'] = count($zipresult); + foreach($zipresult as $key=>$val) + $result['UnCompSize'] += $zipresult[$key]['UnCompSize']; + $result['Size']=filesize($src); + $result['Ratio'] = $result['UnCompSize'] ? round(100 - $result['Size'] / $result['UnCompSize']*100, 1) : FALSE; + } + elseif (strlen($comp)>1) + { + $tar = new tar; + if ($comp == 'bz') + { + $bzip2 = new bzip2; + $result = $bzip2->infosBzip2($src, TRUE); + $src=$result['Data']; + } + elseif ($comp == 'gz') + { + $gzip = new gzip; + $result = $gzip->infosGzip($src, TRUE); + $src=$result['Data']; + } + if ($tar->is_tar($src) || is_file($src)) + { + $tarresult = $tar->infosTar($src, FALSE); + $result ['Items'] = count($tarresult); + $result ['UnCompSize'] = 0; + if (empty($result['Size'])) + $result['Size']=is_file($src)?filesize($src):strlen($src); + foreach($tarresult as $key=>$val) + $result['UnCompSize'] += $tarresult[$key]['size']; + $result['Ratio'] = $result['UnCompSize'] ? round(100 - $result['Size'] / $result['UnCompSize']*100, 1) : FALSE; + + } + if (!$data) unset($result['Data']); + } + else return FALSE; + return array('Items'=>$result['Items'], 'UnCompSize'=>$result['UnCompSize'], 'Size'=>$result['Size'], 'Ratio'=>$result['Ratio'],); + } + function extract ($src, $dest=FALSE) + { + $path_parts = pathinfo ($src); + if (!$dest) + $dest = $path_parts['dirname'].'/'; + $ext = '.'.$path_parts['extension']; + $name = $path_parts['filename']; + foreach ($this->WathArchive as $key=>$val) + if (stripos($ext, $key)!==FALSE) $comp=$val; + if ($comp == 'zip') + { + $zip = new zip; + return $zip->extractZip($src, $dest); + } + elseif (strlen($comp)>1) + { + $tar = new tar; + if ($comp == 'bz') + { + $bzip2 = new bzip2; + $src = $bzip2->extractBzip2($src); + } + elseif ($comp == 'gz') + { + $gzip = new gzip; + $src = $gzip->extractGzip($src); + } + if ($tar->is_tar($src) || is_file($src)) + { + return $tar->extractTar($src, $dest); + } + else file_put_contents($dest.$name, $src); + return $dest; + } + return FALSE; + } +} \ No newline at end of file diff --git a/include/easyarchives/EasyBzip2.class.php b/include/easyarchives/EasyBzip2.class.php new file mode 100755 index 0000000..144bfeb --- /dev/null +++ b/include/easyarchives/EasyBzip2.class.php @@ -0,0 +1,55 @@ +makeBzip2('./','./toto.bzip2'); +var_export($test->infosBzip2('./toto.bzip2')); +$test->extractBzip2('./toto.bzip2', './new/'); +**/ + function makeBzip2($src, $dest=FALSE) + { + $Bzip2 = bzcompress((strpos(chr(0),$src) ? file_get_contents ($src) : $src), 6); + if (empty($dest)) return $Bzip2; + elseif (file_put_contents($dest, $Bzip2)) return $dest; + return FALSE; + } + function infosBzip2 ($src, $data=TRUE) + { + $data = $this->extractBzip2 ($src); + $content = array( + 'UnCompSize'=>strlen($data), + 'Size'=>filesize($src), + 'Ratio'=>strlen($data) ? round(100 - filesize($src) / strlen($data)*100, 1) : FALSE,); + if ($data) $content['Data'] = $data; + return $content; + } + function extractBzip2($src, $dest=FALSE) + { + $bz = bzopen($src, "r"); + $data = ''; + while (!feof($bz)) + $data .= bzread($bz, 1024*1024); + bzclose($bz); + if (empty($dest)) return $data; + elseif (file_put_contents($dest, $data)) return $dest; + return FALSE; + } +} \ No newline at end of file diff --git a/include/easyarchives/EasyGzip.class.php b/include/easyarchives/EasyGzip.class.php new file mode 100755 index 0000000..6b4704e --- /dev/null +++ b/include/easyarchives/EasyGzip.class.php @@ -0,0 +1,55 @@ +makeGzip('./','./toto.gzip'); +var_export($test->infosGzip('./toto.gzip')); +$test->extractGzip('./toto.gzip', './new/'); +**/ + function makeGzip($src, $dest=FALSE) + { + $Gzip = gzencode((strpos(chr(0),$src) ? file_get_contents ($src) : $src), 6); + if (empty($dest)) return $Gzip; + elseif (file_put_contents($dest, $Gzip)) return $dest; + return FALSE; + } + function infosGzip ($src, $data=TRUE) + { + $data = $this->extractGzip ($src); + $content = array( + 'UnCompSize'=>strlen($data), + 'Size'=>filesize($src), + 'Ratio'=>strlen($data) ? round(100 - filesize($src) / strlen($data)*100, 1) : FALSE,); + if ($data) $content['Data'] = $data; + return $content; + } + function extractGzip ($src, $dest=FALSE) + { + $zp = gzopen( $src, "r" ); + $data = ''; + while (!gzeof($zp)) + $data .= gzread($zp, 1024*1024); + gzclose( $zp ); + if (empty($dest)) return $data; + elseif (file_put_contents($dest, $data)) return $dest; + return FALSE; + } +} \ No newline at end of file diff --git a/include/easyarchives/EasyTar.class.php b/include/easyarchives/EasyTar.class.php new file mode 100755 index 0000000..e21cde3 --- /dev/null +++ b/include/easyarchives/EasyTar.class.php @@ -0,0 +1,202 @@ +makeTar('./','./toto.Tar'); +var_export($test->infosTar('./toto.Tar')); +$test->extractTar('./toto.Tar', './new/'); +**/ + function infosTar ($src, $data=TRUE) + { + if ($this->is_tar($src)) + { + file_put_contents ($tmp='~tmp('.microtime().').tar', $src); + $src = $tmp; + } + $ptr = fopen($src, 'r'); + while (!feof($ptr)) + { + $infos = $this->readTarHeader ($ptr); + if ($infos['name']) + { + if (!$data) unset($infos['data']); + $result[$infos['name']]=$infos; + } + } + if (is_file($tmp)) unlink($tmp); + return $result; + } + function makeTar($src, $dest=FALSE) + { + $src = is_array($src) ? $src : array($src); + $src = array_map('realpath', $src); + foreach ($src as $item) + $Tar .= $this->addTarItem($item.((is_dir($item) && substr($item, -1)!='/')?'/':''), dirname($item).'/'); + + $Tar = str_pad($Tar, floor((strlen($Tar) + 10240 - 1) / 10240) * 10240, "\0"); + if (empty($dest)) return $Tar; + elseif (file_put_contents($dest, $Tar)) return $dest; + else FALSE; + } + function extractTar ($src, $dest) + { + if ($this->is_tar($src)) + { + file_put_contents ($tmp='~tmp('.microtime().').tar', $src); + $src = $tmp; + } + $ptr = fopen($src, 'r'); + while (!feof($ptr)) + { + $infos = $this->readTarHeader ($ptr); + if ($infos['type']=='5' && @mkdir($dest.$infos['name'], 0775, TRUE)) + $result[]=$dest.$infos['name']; + elseif (($infos['type']=='0' || $infos['type']==chr(0)) && file_put_contents($dest.$infos['name'], $infos['data'])) + $result[]=$dest.$infos['name']; + if ($infos) + chmod($dest.$infos['name'], 0775); +// chmod(, $infos['mode']); +// chgrp(, $infos['uname']); +// chown(, $infos['gname']); + } + if (is_file($tmp)) unlink($tmp); + return $result; + } + function is_tar($str) + { + $block = substr($str,0, 512); + if (strlen($block)!=512) return FALSE; + $realchecksum = octdec(substr($str,148,8)); + $checksum = 0; + $block = substr_replace($block, ' ', 148, 8); + for ($i = 0; $i < 512; $i++) + $checksum += ord(substr($block, $i, 1)); + if ($realchecksum==$checksum) return TRUE; + return FALSE; + } + function tarHeader512($infos) + { /* http://www.mkssoftware.com/docs/man4/tar.4.asp */ + $bigheader = $header = ''; + if (strlen($infos['name100'])>100) + { + $bigheader = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12", + '././@LongLink','0000000','0000000','0000000', + sprintf("%011o", strlen($infos['name100'])),'00000000000', + ' ', 'L', '', 'ustar ', '0', + $infos['userName32'], + $infos['groupName32'],'','','',''); + + $bigheader .= str_pad($infos['name100'], floor((strlen($infos['name100']) + 512 - 1) / 512) * 512, "\0"); + + $checksum = 0; + for ($i = 0; $i < 512; $i++) + $checksum += ord(substr($bigheader, $i, 1)); + $bigheader = substr_replace($bigheader, sprintf("%06o", $checksum)."\0 ", 148, 8); + } + $header = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12", // book the memorie area + substr($infos['name100'],0,100), // 0 100 File name + str_pad(substr(sprintf("%07o",$infos['mode8']),-4), 7, '0', STR_PAD_LEFT), // 100 8 File mode + sprintf("%07o", $infos['uid8']), // 108 8 Owner user ID + sprintf("%07o", $infos['gid8']), // 116 8 Group user ID + sprintf("%011o", $infos['size12']), // 124 12 File size in bytes + sprintf("%011o", $infos['mtime12']), // 136 12 Last modification time + ' ', // 148 8 Check sum for header block + $infos['link1'], // 156 1 Link indicator / ustar Type flag + $infos['link100'], // 157 100 Name of linked file + 'ustar ', // 257 6 USTAR indicator "ustar" + ' ', // 263 2 USTAR version "00" + $infos['userName32'], // 265 32 Owner user name + $infos['groupName32'], // 297 32 Owner group name + '', // 329 8 Device major number + '', // 337 8 Device minor number + $infos['prefix155'], // 345 155 Filename prefix + ''); // 500 12 ?? + + $checksum = 0; + for ($i = 0; $i < 512; $i++) + $checksum += ord(substr($header, $i, 1)); + $header = substr_replace($header, sprintf("%06o", $checksum)."\0 ", 148, 8); + + return $bigheader.$header; + } + function addTarItem ($item, $racine) + { + $infos['name100'] = str_replace($racine, '', $item); + list (, , $infos['mode8'], , $infos['uid8'], $infos['gid8'], , , , $infos['mtime12'] ) = stat($item); + $infos['size12'] = is_dir($item) ? 0 : filesize($item); + $infos['link1'] = is_link($item) ? 2 : is_dir ($item) ? 5 : 0; + $infos['link100'] == 2 ? readlink($item) : ""; + + $a=function_exists('posix_getpwuid')?posix_getpwuid (fileowner($item)):array('name'=>'Unknown'); + $infos['userName32'] = $a['name']; + + $a=function_exists('posix_getgrgid')?posix_getgrgid (filegroup($item)):array('name'=>'Unknown'); + $infos['groupName32'] = $a['name']; + $infos['prefix155'] = ''; + + $header = $this->tarHeader512($infos); + $data = str_pad(file_get_contents($item), floor(($infos['size12'] + 512 - 1) / 512) * 512, "\0"); + if (is_dir($item)) + { + $lst = scandir($item); + array_shift($lst); // remove ./ of $lst + array_shift($lst); // remove ../ of $lst + foreach ($lst as $subitem) + $sub .= $this->addTarItem($item.$subitem.(is_dir($item.$subitem)?'/':''), $racine); + } + return $header.$data.$sub; + } + function readTarHeader ($ptr) + { + $block = fread($ptr, 512); + if (strlen($block)!=512) return FALSE; + $hdr = unpack ("a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12temp", $block); + $hdr['mode']=$hdr['mode']+0; + $hdr['uid']=octdec($hdr['uid']); + $hdr['gid']=octdec($hdr['gid']); + $hdr['size']=octdec($hdr['size']); + $hdr['mtime']=octdec($hdr['mtime']); + $hdr['checksum']=octdec($hdr['checksum']); + $checksum = 0; + $block = substr_replace($block, ' ', 148, 8); + for ($i = 0; $i < 512; $i++) + $checksum += ord(substr($block, $i, 1)); + if (isset($hdr['name']) && $hdr['checksum']==$checksum) + { + if ($hdr['name']=='././@LongLink' && $hdr['type']=='L') + { + $realName = substr(fread($ptr, floor(($hdr['size'] + 512 - 1) / 512) * 512), 0, $hdr['size']-1); + $hdr2 = $this->readTarHeader ($ptr); + $hdr2['name'] = $realName; + return $hdr2; + } + elseif (strtolower(substr($hdr['magic'], 0, 5) == 'ustar')) + { + if ($hdr['size']>0) + $hdr['data'] = substr(fread($ptr, floor(($hdr['size'] + 512 - 1) / 512) * 512), 0, $hdr['size']); + else $hdr['data'] = ''; + return $hdr; + } + else return FALSE; + } + else return FALSE; + } +} \ No newline at end of file diff --git a/include/easyarchives/EasyZip.class.php b/include/easyarchives/EasyZip.class.php new file mode 100755 index 0000000..816a8ca --- /dev/null +++ b/include/easyarchives/EasyZip.class.php @@ -0,0 +1,95 @@ +makeZip('./','./toto.zip'); +var_export($test->infosZip('./toto.zip')); +$test->extractZip('./toto.zip', './new/'); +**/ + function infosZip ($src, $data=TRUE) + { + if (($zip = zip_open(realpath($src)))) + { + while (($zip_entry = zip_read($zip))) + { + $path = zip_entry_name($zip_entry); + if (zip_entry_open($zip, $zip_entry, "r")) + { + $content[$path] = array ( + 'Ratio' => zip_entry_filesize($zip_entry) ? round(100-zip_entry_compressedsize($zip_entry) / zip_entry_filesize($zip_entry)*100, 1) : FALSE, + 'Size' => zip_entry_compressedsize($zip_entry), + 'UnCompSize' => zip_entry_filesize($zip_entry)); + if ($data) + $content[$path]['Data'] = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); + zip_entry_close($zip_entry); + } + else + $content[$path] = FALSE; + } + zip_close($zip); + return $content; + } + return FALSE; + } + function extractZip ($src, $dest) + { + $zip = new ZipArchive; + if ($zip->open($src)===TRUE) + { + $zip->extractTo($dest); + $zip->close(); + return TRUE; + } + return FALSE; + } + function makeZip ($src, $dest) + { + $zip = new ZipArchive; + $src = is_array($src) ? $src : array($src); + if ($zip->open($dest, ZipArchive::CREATE) === TRUE) + { + foreach ($src as $item) + { + if (is_dir($item)) + $this->addZipItem($zip, realpath(dirname($item)).'/', realpath($item).'/'); + elseif(is_file($item)) + $zip->addFile(realpath($item), basename(realpath($item))); + } + $zip->close(); + return TRUE; + } + return FALSE; + } + function addZipItem ($zip, $racine, $dir) + { + if (is_dir($dir)) + { + $zip->addEmptyDir(str_replace($racine, '', $dir)); + $lst = scandir($dir); + array_shift($lst); + array_shift($lst); + foreach ($lst as $item) + $this->addZipItem($zip, $racine, $dir.$item.(is_dir($dir.$item)?'/':'')); + } + elseif (is_file($dir)) + $zip->addFile($dir, str_replace($racine, '', $dir)); + } +} \ No newline at end of file diff --git a/include/easyarchives/index.html b/include/easyarchives/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/include/easyarchives/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/include/index.html b/include/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/include/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/include/onupdate.inc.php b/include/onupdate.inc.php new file mode 100644 index 0000000..88870d9 --- /dev/null +++ b/include/onupdate.inc.php @@ -0,0 +1,35 @@ + + * $modversion["onInstall"] = "include/onupdate.inc.php"; + * $modversion["onUpdate"] = "include/onupdate.inc.php"; + * + * + * @copyright http://smartfactory.ca The SmartFactory + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) + * @since 1.0 + * @author marcan aka Marc-André Lanciault + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +// this needs to be the latest db version +define("IMBUILDING_DB_VERSION", 1); + +function icms_module_update_imbuilding($module) { + return TRUE; +} + +function icms_module_install_imbuilding($module) { + icms_core_Filesystem::mkdir(ICMS_UPLOAD_PATH . "/imbuilding/packages/"); + + return TRUE; +} \ No newline at end of file diff --git a/include/requirements.php b/include/requirements.php new file mode 100644 index 0000000..14219ca --- /dev/null +++ b/include/requirements.php @@ -0,0 +1,25 @@ + + * @version $Id$ + * @todo this could easily be generalized in a IcmsRequirements class and put in ImpressCMS 1.2 for other modules to use + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +$failed_requirements = array(); + +if (ICMS_VERSION_BUILD < 50) $failed_requirements[] = _AM_IMBUILDING_REQUIREMENTS_ICMS_BUILD; + +if (count($failed_requirements) > 0) { + icms_cp_header(); + $icmsAdminTpl->assign("failed_requirements", $failed_requirements); + $icmsAdminTpl->display(IMBUILDING_ROOT_PATH . "templates/imbuilding_requirements.html"); + icms_cp_footer(); + exit; +} \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..bcaeac9 --- /dev/null +++ b/index.php @@ -0,0 +1,15 @@ + + * @package imbuilding + * @version $Id$ + */ + +/** Include the module's header for all pages */ +include_once "header.php"; +header("Location: " . ICMS_URL); \ No newline at end of file diff --git a/language/english/admin.php b/language/english/admin.php new file mode 100644 index 0000000..1516732 --- /dev/null +++ b/language/english/admin.php @@ -0,0 +1,82 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +// Requirements +define("_AM_IMBUILDING_REQUIREMENTS", "imBuilding Requirements"); +define("_AM_IMBUILDING_REQUIREMENTS_INFO", "We've reviewed your system, unfortunately it doesn't meet all the requirements needed for imBuilding to function. Below are the requirements needed."); +define("_AM_IMBUILDING_REQUIREMENTS_ICMS_BUILD", "imBuilding requires at least ImpressCMS 1.1.1 RC 1."); +define("_AM_IMBUILDING_REQUIREMENTS_SUPPORT", "Should you have any question or concerns, please visit our forums at http://community.impresscms.org."); + +// Commons +define("_AM_IMBUILDING_CONTINUE", "Continue"); +define("_AM_IMBUILDING_STEP", "Step"); +define("_AM_IMBUILDING_FIRST_USE", "This is the first time you access this module. Please update the module in order to dynamically create the database scheme."); + +// module +define("_AM_IMBUILDING_MODULES", "Modules"); +//define("_AM_IMBUILDING_MODULES_DSC", "All modules in the module"); +define("_AM_IMBUILDING_MODULE_CREATE", "Create a module"); +define("_AM_IMBUILDING_MODULE", "Module"); +define("_AM_IMBUILDING_MODULE_CREATE_INFO", "This form is about the basic information of the new module you are setting up. Fill out these fields and hit the Submit button. You will then be brough to the second step where you will create your first object."); +define("_AM_IMBUILDING_MODULE_EDIT", "Edit this module"); +define("_AM_IMBUILDING_MODULE_EDIT_INFO", "Fill-out the following form in order to edit this module."); +define("_AM_IMBUILDING_MODULE_MODIFIED", "The module was successfully modified."); +define("_AM_IMBUILDING_MODULE_CREATED", "The module has been successfully created."); +define("_AM_IMBUILDING_MODULE_CREATED_FINISH", "All information about the module have been configured. You can now edit elements of the module or generate it by clicking on te Generate button next to this module in the Actions column."); +define("_AM_IMBUILDING_MODULE_VIEW", "Module info"); +//define("_AM_IMBUILDING_MODULE_VIEW_DSC", "Here is the info about this module."); +define("_AM_IMBUILDING_MODULE_GENERATION", "Module generation"); +define("_AM_IMBUILDING_CREATE_MODULE", "Generate module"); +define("_AM_IMBUILDING_SHOW_LOG", "Show Log"); +define("_AM_IMBUILDING_MODULE_CLICK_TO_DOWNLOAD", "Click here to download your new module"); +define("_AM_IMBUILDING_MODULE_GENERATED_TITLE", "New module generated"); +define("_AM_IMBUILDING_MODULE_GENERATED_INFO", "Click on the link below to download a Zip archive of your new module."); +define("_AM_IMBUILDING_MODULE_GENERATED_NOZIP", "The new module was generated. It has been place in this folder:
    %s"); +define("_AM_IMBUILDING_CREATE_MODULE_NO_DEFAULT_OBJECT", "You need to specify the default object before generating the module."); +define("_AM_IMBUILDING_CREATE_MODULE_OBJECT_NO_DEFAULT_FIELD", "An identifier is required for all objects. Please set the identifier name for the object %s."); + +// object +define("_AM_IMBUILDING_OBJECTS", "Objects"); +//define("_AM_IMBUILDING_OBJECTS_DSC", "All objects in the object"); +define("_AM_IMBUILDING_OBJECT_CREATE", "Add an object"); +define("_AM_IMBUILDING_OBJECT", "Object"); +define("_AM_IMBUILDING_OBJECT_CREATE_INFO", "Fill-out the following form to create a new object."); +define("_AM_IMBUILDING_OBJECT_CREATE_WIZARD", "Module created, now add your first object"); +define("_AM_IMBUILDING_OBJECT_CREATE_WIZARD_INFO", "The module was created. Now you can proceed to the creation of your first object. This form will collect the basic information about the object you wish to create. Once you click on the Submit button, your new object will be saved and you will be brought to a form where you will start adding fields to this object."); +define("_AM_IMBUILDING_OBJECT_EDIT", "Edit this object"); +define("_AM_IMBUILDING_OBJECT_EDIT_INFO", "Fill-out the following form in order to edit this object."); +define("_AM_IMBUILDING_OBJECT_EDIT_FINILIZE", "All fields added, now finalize Object settings"); +define("_AM_IMBUILDING_OBJECT_EDIT_FINILIZE_INFO", "All fields were created, now you need to select the fields of this object which will act as the object identifier and the object description."); +define("_AM_IMBUILDING_OBJECT_MODIFIED", "The object was successfully modified."); +define("_AM_IMBUILDING_OBJECT_CREATED", "The object has been successfully created."); +define("_AM_IMBUILDING_OBJECT_VIEW", "Object info"); +//define("_AM_IMBUILDING_OBJECT_VIEW_DSC", "Here is the info about this object."); +define("_AM_IMBUILDING_OBJECTS_OF_MODULE", "Objects of this module"); + +// field +define("_AM_IMBUILDING_FIELDS", "Fields"); +//define("_AM_IMBUILDING_FIELDS_DSC", "All fields in the field"); +define("_AM_IMBUILDING_FIELD_CREATE", "Add a field"); +define("_AM_IMBUILDING_FIELD", "Field"); +//define("_AM_IMBUILDING_FIELD_CREATE_INFO", "Fill-out the following form to create a new field in your object."); +define("_AM_IMBUILDING_FIELD_CREATE_WIZARD", "Your object was created, now start adding fields"); +define("_AM_IMBUILDING_FIELD_CREATE_WIZARD_INFO", "Fill-out the following form to create a new field in your object. After clicking on the Submit button to create this field, you will automatically be brought to a form where you will be able to add a new field. When you are don adding field, set the Add another field ? radio button to No."); +define("_AM_IMBUILDING_FIELD_CREATE_WIZARD2", "Add another field to your object"); +define("_AM_IMBUILDING_FIELD_CREATE_WIZARD2_INFO", "Fill-out the following form to create a new field in your object. After clicking on the Submit button to create this field, you will automatically be brought to a form where you will be able to add a new field. When you are don adding field, set the Add another field ? radio button to No."); +define("_AM_IMBUILDING_FIELD_EDIT", "Edit this field"); +//define("_AM_IMBUILDING_FIELD_EDIT_INFO", "Fill-out the following form in order to edit this field."); +define("_AM_IMBUILDING_FIELD_MODIFIED", "The field was successfully modified."); +define("_AM_IMBUILDING_FIELD_CREATED", "The field has been successfully created."); +define("_AM_IMBUILDING_FIELD_VIEW", "Field info"); +//define("_AM_IMBUILDING_FIELD_VIEW_DSC", "Here is the info about this field."); +define("_AM_IMBUILDING_FIELDS_OF_OBJECT", "Fields of this object"); \ No newline at end of file diff --git a/language/english/common.php b/language/english/common.php new file mode 100644 index 0000000..fed8e57 --- /dev/null +++ b/language/english/common.php @@ -0,0 +1,77 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +// module +define("_CO_IMBUILDING_MODULE_MODULE_NAME", "Module name"); +define("_CO_IMBUILDING_MODULE_MODULE_NAME_DSC", "Name you would like to use for this module"); +define("_CO_IMBUILDING_MODULE_MODULE_DESC", "Module description"); +define("_CO_IMBUILDING_MODULE_MODULE_DESC_DSC", "A small description of the module. Will be used in the About page."); +define("_CO_IMBUILDING_MODULE_AUTHOR_NAME", "Author name"); +define("_CO_IMBUILDING_MODULE_AUTHOR_NAME_DSC", "Your name will be used as the Developer Name on the About page of your module as well as in the header comments block of all PHP files."); +define("_CO_IMBUILDING_MODULE_AUTHOR_PROFILE", "Public profile URL"); +define("_CO_IMBUILDING_MODULE_AUTHOR_PROFILE_DSC", "If you have a public profile somewhere (on community.impressmcms.org or on your blog, etc. it will be used in the About page of your module.)"); +define("_CO_IMBUILDING_MODULE_AUTHOR_WEBSITE_NAME", "Name of your Web site"); +define("_CO_IMBUILDING_MODULE_AUTHOR_WEBSITE_NAME_DSC", "Your Web site will be displayed on the About page of your module."); +define("_CO_IMBUILDING_MODULE_AUTHOR_WEBSITE_URL", "URL of your Web site"); +define("_CO_IMBUILDING_MODULE_AUTHOR_WEBSITE_URL_DSC", "Your Web site will be displayed on the About page of your module."); +define("_CO_IMBUILDING_MODULE_AUTHOR_EMAIL", "Your email"); +define("_CO_IMBUILDING_MODULE_AUTHOR_EMAIL_DSC", "Your email will be displayed on the About page of your module."); +define("_CO_IMBUILDING_MODULE_MODULE_COPYRIGHT", "Module Copyright"); +define("_CO_IMBUILDING_MODULE_MODULE_COPYRIGHT_DSC", "Copyright of your module."); +define("_CO_IMBUILDING_MODULE_MODULE_CREDITS", "Credits"); +define("_CO_IMBUILDING_MODULE_MODULE_CREDITS_DSC", "Credits of the module, which will be displayed on the About page of your module."); +define("_CO_IMBUILDING_MODULE_DEFAULT_OBJECT", "Default object"); +define("_CO_IMBUILDING_MODULE_DEFAULT_OBJECT_DSC", "Select the default object of your module. This is the object that will be displayed on the index page of admin and user side of the module."); + +// object +define("_CO_IMBUILDING_OBJECT_OBJECT_NAME", "Object name"); +define("_CO_IMBUILDING_OBJECT_OBJECT_NAME_DSC", "Name of the object you want your module to manage. Example, Article."); +define("_CO_IMBUILDING_OBJECT_OBJECT_DESC", "Object description"); +define("_CO_IMBUILDING_OBJECT_OBJECT_DESC_DSC", "Description of the object. This is purely informative and will be used in the comment block of the PHP class created for this object."); +define("_CO_IMBUILDING_OBJECT_OBJECT_IDENTIFIER_NAME", "Object identifier field"); +define("_CO_IMBUILDING_OBJECT_OBJECT_IDENTIFIER_NAME_DSC", "Field which will be used as the identifier of this object. For example, title."); +define("_CO_IMBUILDING_OBJECT_OBJECT_IDENTIFIER_DESC", "Object description field"); +define("_CO_IMBUILDING_OBJECT_OBJECT_IDENTIFIER_DESC_DSC", "Field which will be used to identify the description of the object. For example, description."); +define("_CO_IMBUILDING_OBJECT_OBJECT_COUNTER", "Add a counter"); +define("_CO_IMBUILDING_OBJECT_OBJECT_COUNTER_DSC", "Select yes if you wish your object to have a hits counter."); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOHTML", "Enable HTML check"); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOHTML_DSC", "Select Yes to have your object enable or disable HTML."); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOBR", "Enable linebreak check"); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOBR_DSC", "Select Yes to have your object enable or disable linebreaks."); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOIMAGE", "Enable images check"); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOIMAGE_DSC", "Select Yes to have your object enable or disable images."); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOSMILEY", "Enable smiley check"); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOSMILEY_DSC", "Select Yes to have your object enable or disable smileys."); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOXCODE", "Enable xCode check"); +define("_CO_IMBUILDING_OBJECT_OBJECT_DOXCODE_DSC", "Select Yes to have your object enable or siable xCodes."); +define("_CO_IMBUILDING_OBJECT_ENABLE_SEO", "Enable SEO"); +define("_CO_IMBUILDING_OBJECT_ENABLE_SEO_DSC", "Enable SEO feature for this object. This will automatically add the following fields: short_url, meta_keywords and meta_description"); +define("_CO_IMBUILDING_OBJECT_SORT", "Sort"); +define("_CO_IMBUILDING_OBJECT_SORT_DSC", ""); + +// field +define("_CO_IMBUILDING_FIELD_FIELD_NAME", "Field name"); +define("_CO_IMBUILDING_FIELD_FIELD_NAME_DSC", "Name of the field. Example, title."); +define("_CO_IMBUILDING_FIELD_FIELD_CAPTION", "Field caption"); +define("_CO_IMBUILDING_FIELD_FIELD_CAPTION_DSC", "The caption of the field will be used in the add and edit form, as well as the column headers."); +define("_CO_IMBUILDING_FIELD_FIELD_DESC", "Field description"); +define("_CO_IMBUILDING_FIELD_FIELD_DESC_DSC", "Description of the field is used in the add and edit form."); +define("_CO_IMBUILDING_FIELD_FIELD_TYPE", "Field type"); +define("_CO_IMBUILDING_FIELD_FIELD_TYPE_DSC", "Type of the field"); +define("_CO_IMBUILDING_FIELD_FIELD_REFER", "Refer other object"); +define("_CO_IMBUILDING_FIELD_FIELD_REFER_DSC", "If selected, a link is created for this object to the selected object type. For example if you want to link an article to a category."); +define("_CO_IMBUILDING_FIELD_FIELD_EXTRA", "Field extra"); +define("_CO_IMBUILDING_FIELD_FIELD_REQUIRED", "Required ?"); +define("_CO_IMBUILDING_FIELD_FIELD_REQUIRED_DESC", "Select Yes to set this field as required."); +define("_CO_IMBUILDING_FIELD_ANOTHER", "Add another field ?"); +define("_CO_IMBUILDING_FIELD_ANOTHER_DSC", "Set to yes to be add another new field after saving this one."); \ No newline at end of file diff --git a/language/english/index.html b/language/english/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/language/english/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/english/modinfo.php b/language/english/modinfo.php new file mode 100644 index 0000000..7dddc7a --- /dev/null +++ b/language/english/modinfo.php @@ -0,0 +1,17 @@ + + * @version $Id$ + */ + +defined("ICMS_ROOT_PATH") or die("ICMS root path not defined"); + +// Module Info +define("_MI_IMBUILDING_MD_NAME", "imBuilding"); +define("_MI_IMBUILDING_MD_DESC", "Module to generate base code of new modules :-)"); +define("_MI_IMBUILDING_MODULES", "Modules"); \ No newline at end of file diff --git a/language/index.html b/language/index.html new file mode 100644 index 0000000..e69de29 diff --git a/preload/adminside.php b/preload/adminside.php new file mode 100644 index 0000000..89d36c2 --- /dev/null +++ b/preload/adminside.php @@ -0,0 +1,18 @@ + + * @version $Id$ + */ + +class IcmsPreloadAdminside extends icms_preload_Item { + public function eventAdminHeader() { + global $xoTheme; + $xoTheme->addStylesheet(IMBUILDING_ADMIN_URL . "/admin.css", array("media" => "screen")); + } +} \ No newline at end of file diff --git a/preload/index.html b/preload/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/preload/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/imbuilding_admin_field.html b/templates/imbuilding_admin_field.html new file mode 100644 index 0000000..78f2329 --- /dev/null +++ b/templates/imbuilding_admin_field.html @@ -0,0 +1,10 @@ +<{if $modules_breadcrumb}><{$modules_breadcrumb}><{/if}> +<{if $imbuilding_field_title}>

    <{$imbuilding_field_title}>

    <{/if}> +<{if $imbuilding_field_info}>

    <{$imbuilding_field_info}>

    <{/if}> +<{if $imbuilding_field_table}><{$imbuilding_field_table}><{/if}> +<{if $addfield}> +

    <{$imbuilding_form_header}>

    +

    <{$imbuilding_form_header_info}>

    +<{includeq file='db:system_common_form.html' form=$addfield}> +<{/if}> +<{if $imbuilding_field_singleview}><{$imbuilding_field_singleview}><{/if}> \ No newline at end of file diff --git a/templates/imbuilding_admin_index.html b/templates/imbuilding_admin_index.html new file mode 100644 index 0000000..3882160 --- /dev/null +++ b/templates/imbuilding_admin_index.html @@ -0,0 +1,3 @@ +

    <{$smarty.const._AM_IMBUILDING_STEP}> <{$imbuilding_new_module_step}>: <{$imbuilding_new_module_title}>

    +

    <{$imbuilding_new_module_info}>

    +<{includeq file='db:system_default_form.html' form=$imbuilding_new_module}> \ No newline at end of file diff --git a/templates/imbuilding_admin_module.html b/templates/imbuilding_admin_module.html new file mode 100644 index 0000000..f4fca86 --- /dev/null +++ b/templates/imbuilding_admin_module.html @@ -0,0 +1,23 @@ +<{if $modules_breadcrumb}><{$modules_breadcrumb}><{/if}> +<{if $imbuilding_module_title}>

    <{$imbuilding_module_title}>

    <{/if}> +<{if $imbuilding_module_info}>

    <{$imbuilding_module_info}>

    <{/if}> +<{if $imbuilding_module_table}><{$imbuilding_module_table}><{/if}> +<{if $addmodule}> +

    <{$imbuilding_form_header}>

    +

    <{$imbuilding_form_header_info}>

    +<{includeq file='db:system_common_form.html' form=$addmodule}> +<{/if}> +<{if $imbuilding_module_singleview}><{$imbuilding_module_singleview}><{/if}> +<{if $imbuilding_object_table}> +

    <{$smarty.const._AM_IMBUILDING_OBJECTS_OF_MODULE}>

    +<{$imbuilding_object_table}> +<{/if}> +<{if $imbuilding_new_module}> +
    + <{$imbuilding_module_created_info}>

    + <{$smarty.const._AM_IMBUILDING_MODULE_GENERATED_INFO}>
    + <{$smarty.const._AM_IMBUILDING_MODULE_CLICK_TO_DOWNLOAD}>

    + <{$smarty.const._AM_IMBUILDING_SHOW_LOG}> + +
    +<{/if}> \ No newline at end of file diff --git a/templates/imbuilding_admin_object.html b/templates/imbuilding_admin_object.html new file mode 100644 index 0000000..f275f29 --- /dev/null +++ b/templates/imbuilding_admin_object.html @@ -0,0 +1,14 @@ +<{if $modules_breadcrumb}><{$modules_breadcrumb}><{/if}> +<{if $imbuilding_object_title}>

    <{$imbuilding_object_title}>

    <{/if}> +<{if $imbuilding_object_info}>

    <{$imbuilding_object_info}>

    <{/if}> +<{if $imbuilding_object_table}><{$imbuilding_object_table}><{/if}> +<{if $addobject}> +

    <{$imbuilding_form_header}>

    +

    <{$imbuilding_form_header_info}>

    +<{includeq file='db:system_common_form.html' form=$addobject}> +<{/if}> +<{if $imbuilding_object_singleview}><{$imbuilding_object_singleview}><{/if}> +<{if $imbuilding_field_table}> +

    <{$smarty.const._AM_IMBUILDING_FIELDS_OF_OBJECT}>

    +<{$imbuilding_field_table}> +<{/if}> \ No newline at end of file diff --git a/templates/imbuilding_requirements.html b/templates/imbuilding_requirements.html new file mode 100644 index 0000000..c18dc47 --- /dev/null +++ b/templates/imbuilding_requirements.html @@ -0,0 +1,6 @@ +

    <{$smarty.const._AM_IMBUILDING_REQUIREMENTS}>

    +

    <{$smarty.const._AM_IMBUILDING_REQUIREMENTS_INFO}>

    +<{foreach item=failed_requirement from=$failed_requirements}> +
  • <{$failed_requirement}>
  • +<{/foreach}> +

    <{$smarty.const._AM_IMBUILDING_REQUIREMENTS_SUPPORT}>

    \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..990cbd6 --- /dev/null +++ b/templates/index.html @@ -0,0 +1 @@ + \ No newline at end of file