public function __construct($module) { parent::__construct(); $this->assign('__action', 'add'); $tpl = Mreg::get('tpl'); $tpl->concat('adminTitle', ' :: ' . $this->moduloptions['title'] . ' :: ' . __('Add record')); $mopts = PEAR::getStaticProperty('m_office', 'options'); $mopt = $mopts['modules'][$module]; $table = $mopt['table']; $do = M_Office_Util::doForModule($module); $this->append('subActions', '<a href="' . M_Office_Util::getQueryParams(array(), array('record', 'doSingleAction')) . '">' . __('Go to the %s list', array($mopt['title'])) . '</a>'); $formBuilder =& MyFB::create($do); // linkNewValue creates an issue if some linked elements are put in predefgroups // $formBuilder->linkNewValue = true; $form = new MyQuickForm('editRecord', 'POST', M_Office_Util::getQueryParams(array(), array(), false), '_self', null, true); $form->addElement('hidden', 'submittedNewRecord', 1); if (isset($_REQUEST['filterField'])) { $form->addElement('hidden', 'filterField', $_REQUEST['filterField']); $form->addElement('hidden', 'filterValue', $_REQUEST['filterValue']); $do->{$_REQUEST['filterField']} = $_REQUEST['filterValue']; } $links = $do->links(); if (key_exists($_REQUEST['filterField'], $links)) { $linfo = explode(':', $links[$_REQUEST['filterField']]); $form->addElement('static', 'mod', '', __('Add record with %s = %s', array($_REQUEST['filterField'], $_REQUEST['filterValue'])) . '. ' . '<a href="' . M_Office_Util::getQueryParams(array('table' => $linfo[0], 'record' => $_REQUEST['filterValue']), array('addRecord', 'filterField', 'filterValue')) . '">' . __('Back to main record') . '</a>'); } $formBuilder->useForm($form); $formBuilder->getForm(); if ($this->getOption('createAnother', $table)) { $form->addElement('static', ' ', ' '); $form->addElement('checkbox', 'returnHere', __('Create another record')); if (isset($_REQUEST['returnHere']) && $_REQUEST['returnHere']) { $form->setDefaults(array('returnHere' => true)); } } M_Office_Util::addHiddenFields($form); if ($form->validate()) { if (PEAR::isError($ret = $form->process(array(&$formBuilder, 'processForm'), false))) { $this->append('error', __('An error occured while inserting record') . ' : ' . $ret->getMessage()); } else { $pk = DB_DataObject_FormBuilder::_getPrimaryKey($do); $this->say(__('New record was successfully created. Its identifier is : %s', array($do->{$pk}))); if ($this->getOption('createAnother', $table) && isset($_REQUEST['returnHere']) && $_REQUEST['returnHere']) { M_Office_Util::refresh(M_Office_Util::getQueryParams(array('returnHere' => $_REQUEST['returnHere']), array(), false)); } else { $pk = DB_DataObject_FormBuilder::_getPrimaryKey($do); M_Office_Util::refresh(M_Office_Util::getQueryParams(array('record' => $do->{$pk}), array('returnHere', 'addRecord'), false)); } } } elseif ($form->isSubmitted()) { } $this->assign('addForm', $form); $this->assign('do', $do); }
public function executeAction($action) { Mreg::get('setup')->setUpEnv(); $this->populateCMS($action); $action = $this->_content->{$this->_dbmodulaction} ? $this->_content->{$this->_dbmodulaction} : $action; try { parent::executeAction($action); } catch (Error404Exception $e) { if ($this->_dbnotfound) { throw new Error404Exception('content data not found !'); } $action = 'index'; parent::executeAction($action); } }
protected function generateOptions() { $AuthOptions = PEAR::getStaticProperty('m_office', 'options'); $userOpt = $AuthOptions['auth']; $opt = array('all' => PEAR::getStaticProperty('Module', 'global')); $options = array('caching' => MODE == 'developpement' ? false : true, 'cacheDir' => $opt['all']['cacheDir'] . '/config/' . ($userOpt ? User::getInstance('office')->getId() . '/' : ''), 'lifeTime' => null, 'fileNameProtection' => false, 'automaticSerialization' => true); $optcache = new Cache_Lite($options); if (!($moduleopt = $optcache->get($this->_modulename))) { if (@(include_once $this->_path . $this->_modulename . '.conf.php')) { if (!is_array($config)) { $config = array(); } $moduleopt = MArray::array_merge_recursive_unique($opt, $config); } else { $moduleopt = $opt; } $useropt = Mreg::get('authHelper')->getPrivilegesForModule(User::getInstance('office'), $this->_modulename); $moduleopt = MArray::array_merge_recursive_unique($moduleopt, $useropt); $optcache->save($moduleopt); } return $moduleopt; }
function getBlock() { $tpl = $this->tplInstance($this->module); Mreg::get('tpl')->addJS('office/fromtableHelpers'); $parentEdit = $this->getGlobalOption('edit', 'showtable', $this->parentModule); $add = $this->getGlobalOption('add', 'showtable', $this->table) && $parentEdit; $edit = $this->getGlobalOption('edit', 'showtable', $this->table) && $parentEdit; $delete = $this->getGlobalOption('delete', 'showtable', $this->table) && $parentEdit; $title = $this->getOption('title', $this->table); if (strlen($title) < 2) { $title = $this->table; } $tpl->assign('add', $add); $tpl->assign('title', $title); if ($add) { $tpl->assignRef('addform', $this->getAddFormObject()); } $tpl->assign('table', $this->table); $tpl->assign('field', $this->field); $tpl->assign('value', $this->value); $tpl->assign('edit', $edit); $tpl->assign('delete', $delete); $tpl->assign('parent', $this->parentDo); $do = M_Office_Util::doForTable($this->table); $do->{$this->field} = $this->value; if (is_array($do->fb_linkOrderFields)) { $do->orderBy(); $do->orderBy(implode(',', $do->fb_linkOrderFields)); } $do->find(); $tpl->assignRef('do', $do); $keys = $do->keys(); $pk = $keys[0]; $tpl->assign('pk', $pk); return $tpl->fetch('ajaxfromtable/bloc'); }
public function prepare($do, $module, $pager = true) { $do->loadPlugin('pager'); $fb = MyFB::create($do); $builder = $fb->builder; if ($builder) { $builder->before_form($fb); } $f = array_keys($do->table()); if ($do->i18nFields) { $f = array_merge($f, $do->i18nFields); } $this->fieldNames = array_combine($f, $f); if (is_array($fb->fieldLabels)) { foreach ($fb->fieldLabels as $k => &$v) { if (is_array($v)) { if (key_exists('unit', $v)) { $unitFormatters[$k] = $v['unit']; } $v = $v[0]; } } $this->fieldNames = array_merge($this->fieldNames, $fb->fieldLabels); } if ($pager) { $perPage = $this->getControllerOption('recordsPerPage', $module); $perPage = $perPage === true ? 10 : $perPage; } else { $perPage = 100000000000; } $do->getPlugin('pager')->setOption('perPage', $perPage); $pk = $do->pkName(); $AllFields = array_keys($do->table()); $links = $do->links(); $fields = $this->getControllerOption('fields', $module); $columns = $this->getControllerOption('columns', $module); if (!is_array($columns)) { $columns = $fields; } if (!is_array($fields)) { $fields = array_diff($AllFields, array($pk)); } $usedFields = array_intersect($fields, $AllFields); $fb->fieldsToRender = $fields; $do->selectAdd(); $plugins = $do->_getPluginsDef(); if (is_array($plugins['i18n'])) { $tmparr = array_intersect($fields, $plugins['i18n']); $i18nfields = implode(',' . $do->tablename() . '_i18n' . '.', $tmparr); if (!empty($i18nfields)) { $i18nfields = $do->tablename() . '_i18n' . '.' . $i18nfields; } $fieldsToRender = array_merge($usedFields, $tmparr); unset($tmparr); } elseif (is_array($plugins['l10n'])) { $tmparr = array_intersect($fields, $plugins['l10n']); $i18nfields = implode(',' . $do->tablename() . '_l10n' . '.', $tmparr); $i18nfields = $do->tablename() . '_l10n' . '.' . $i18nfields; $fieldsToRender = array_merge($usedFields, $tmparr); unset($tmparr); } else { $i18nfields = null; $fieldsToRender = $usedFields; } if ($plugins['tag'] && in_array('tagplugin_cache', $AllFields)) { $usedFields[] = 'tagplugin_cache'; } if (!in_array($pk, $usedFields)) { $selectAdd = $do->tablename() . '.' . $pk . ',' . $do->tablename() . '.' . implode(',' . $do->tablename() . '.', $usedFields) . ($i18nfields ? ',' . $i18nfields : ''); } else { $selectAdd = $do->tablename() . '.' . implode(',' . $do->tablename() . '.', $usedFields) . ($i18nfields ? ',' . $i18nfields : ''); } $do->selectAdd('distinct ' . $selectAdd); $fb->populateOptions(); $specialElements = $fb->_getSpecialElementNames(); $eltTypes = $do->table(); foreach ($fieldsToRender as $aField) { switch (true) { case array_key_exists($aField, $links): $fieldTypes[$aField] = 'link'; break; case is_array($fb->enumFields) && in_array($aField, $fb->enumFields): $fieldTypes[$aField] = 'enum'; break; case $eltTypes[$aField] & DB_DATAOBJECT_BOOL: $fieldTypes[$aField] = 'bool'; break; case $eltTypes[$aField] & DB_DATAOBJECT_TIME: $fieldTypes[$aField] = 'datetime'; break; case $eltTypes[$aField] & DB_DATAOBJECT_DATE: $fieldTypes[$aField] = 'date'; break; default: $fieldTypes[$aField] = 'bypass'; } } foreach ($columns as $field) { $columnsTypes[$field] = $fieldTypes[$field]; } $this->columns = $columnsTypes; if (can('update', $module) || can('read', $module)) { Mreg::get('tpl')->assign('edit', true); } if ($this->_controller->hasActions) { Mreg::get('tpl')->assign('selectable', true); Mreg::get('tpl')->addJSinline("\n \$('a[rel=checkboxes]').click(function() {\n \$('#showTableForm input:checkbox').each(function(){\$(this).prop('checked',true);});\n return false;\n });\n \$('a[rel=uncheckboxes]').click(function() {\n \$('#showTableForm input:checkbox').prop('checked',false);\n });\n ", 'ready'); } Mreg::get('tpl')->concat('adminTitle', ' ' . 'page ' . ($_REQUEST['pageID'] ? $_REQUEST['pageID'] : 1)); if (isset($_REQUEST['_ps'])) { $do->orderBy(); $do->getPlugin('pager')->setValues($_REQUEST['_ps'], $_REQUEST['_pd']); } elseif ($ord = $this->_controller->moduloptions['order']) { $do->orderBy(); $do->getPlugin('pager')->setDefaultSort($ord); } elseif (isset($fb->linkOrderFields) && is_array($fb->linkOrderFields)) { $do->getPlugin('pager')->setDefaultSort($fb->linkOrderFields); } $this->fields = $fieldTypes; $do->find(); $this->do = $do; $this->totalItems = $do->getPlugin('pager')->totalItems; }
public static function getPaths($role) { try { $paths = Mreg::get("{$role}_paths"); } catch (Exception $e) { $paths = array(); } return $paths; }
protected function getPluginCommand($plugin, $command, $params = array()) { if (!FileUtils::file_exists_incpath('M/plugins/' . $plugin . '/commands/' . $command . '.php')) { if (!FileUtils::file_exists_incpath('M/plugins/' . $plugin)) { throw new Exception($plugin . ' plugin does not exist'); } else { throw new Exception($plugin . ' does not have ' . $command . ' command'); } } require_once 'M/plugins/' . $plugin . '/commands/' . $command . '.php'; $className = $plugin . '_Command_' . $command; // Setting up options including Databases DSN Mreg::get('setup')->setUpEnv(); // Executing $com = new $className(); return $com; }
<?php /** * M PHP Framework * @package M */ /** * M PHP Framework * * Controller main file for office app * * @package M * @author Arnaud Sellenet <demental at github> * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License * @version 0.1 */ define('APP_NAME', '{$APP_NAME}'); define('IN_ADMIN', 1); require '{$APP_RELATIVE_FILE_TO_ROOT}/M_startup.php'; require 'M/Office.php'; define('ROOT_ADMIN_URL', SITE_URL . '{$APP_RELATIVE_FILE_FROM_DOCROOT}'); Mreg::get('setup')->setUpEnv(); $frontend = new M_Office(); header('Content-type:text/html; charset=utf-8'); echo $frontend->display();
/** * * description * * @param $action * @return unknown_type */ protected function forceExecute($action) { $meth = 'doExec' . $action; $options = array('caching' => $this->getConfig('caching', $action), 'cacheDir' => $this->getConfig('cacheDir', $action), 'lifeTime' => $this->getConfig('cacheTime', $action, 7200), 'fileNameProtection' => false); $this->cache = new Cache_Lite($options); if ($cache_id = $this->getCacheId($action)) { Log::info($action . ' is cachable with cacheId = ' . $cache_id); if ($this->_cachedData = $this->cache->get($cache_id . '_' . ($this->isAjaxRequest() ? 'ajax' : ''))) { Log::info($action . ' is retreived from cache with cacheId = ' . $cache_id); return; } } Log::info($action . ' is not in cache'); // Mreg::get('setup')->setUpEnv(); // !gestion template_dir rajouté dans le setup coupons Mreg::get('setup')->setUpEnv(); $optionsEnv =& PEAR::getStaticProperty('Module', 'global'); $optionsThis = $this->config; $diff = array_diff($optionsEnv['template_dir'], $optionsThis['all']['template_dir']); if (is_array($diff)) { foreach ($diff as $k => $v) { $this->view->addPath($v, 'after'); } } Log::info('env setup. launching preExecute'); $this->preExecuteAction($action); Log::info('preExecute launched. Launching ' . get_class($this) . '::' . $meth); call_user_func(array($this, $meth)); Log::info('doExec launched'); $this->postExecuteAction($action); }
/** * * Generate a preference file from database configuration table * * @access public * @param string $file filename with path * @static * */ public static function savePrefFile() { $file = APP_ROOT . 'app/cache/' . self::getPrefFile(); $setup = Mreg::get('setup'); if (is_object($setup)) { $setup->setUpEnv(); } $prefs = DB_DataObject::factory('preferences'); $prefs->find(); while ($prefs->fetch()) { self::$prefArr[$prefs->var] = self::parsePref($prefs); } file_put_contents($file, serialize(self::$prefArr)); }
public function append($var, $val) { Mreg::get('tpl')->append($var, $val); }
public function reloadContainer() { if (class_exists('Mreg')) { try { Mreg::get('setup')->setUpEnv(); } catch (Exception $e) { } } $this->currentContainer = NULL; $this->currentContainer =& DB_DataObject::factory($this->containers[$this->context]['table']); $this->currentContainer->get($this->getId()); }
function &prepare(&$do, $module, $pager = true) { $this->_do =& $do; $do->orderBy($do->treeFields['left'] . ' ASC'); $unitFormatters = array(); if (is_array($do->fb_fieldLabels)) { foreach ($do->fb_fieldLabels as $k => &$v) { if (is_array($v)) { if (key_exists('unit', $v)) { $unitFormatters[$k] = $v['unit']; } $v = $v[0]; } } } $pk = MyFB::_getPrimaryKey($do); $fields = $this->getControllerOption('fields', $do->tableName()); if (!is_array($fields)) { $fields = array_keys($do->table()); } $do->fb_fieldsToRender = $fields; $fb =& MyFB::create($do); $fb->populateOptions(); $specialElements = $fb->_getSpecialElementNames(); $this->fields = $fields; if ($this->getControllerOption('edit', $do->tableName()) || $this->getControllerOption('view', $do->tableName())) { $this->fields[] = array($pk, array('M_Office_View_tree', 'getEditLink'), array('database' => $do->database(), 'table' => $do->tableName(), 'pk' => $pk)); $this->fields[] = array($pk, array('M_Office_View_tree', 'getChildLink'), array('database' => $do->database(), 'table' => $do->tableName(), 'pk' => $pk)); } if ($this->_controller->hasActions) { $this->fields[] = array($pk, array('M_Office_View_tree', 'getSelectedEntry'), array('pk' => $pk)); } $formatters = $this->getControllerOption('formatters', $do->tableName()); if (!is_array($formatters)) { $formatters = array(); } Mreg::get('tpl')->addJS('interface'); Mreg::get('tpl')->addJSinline(' $("a[rel=treeviewtoggle]").toggle( function(){ $(this).parent().parent().find("ul").hide(); }, function(){ $(this).parent().parent().find("ul").show(); } );', 'ready'); }
public function fetch() { try { $tpl = Mreg::get('tpl'); $tpl->concat('adminTitle', ' :: ' . $this->getOption('adminTitle')); if (self::isAjaxRequest()) { M_Office::$dsp = '__defaut/ajaxindex'; $vars = $tpl->getVars(); $action = $vars['__action']; if (!is_array($action)) { $tpl->assign('__action', array($action . '.bloc', $action)); } } $tables = $this->getGlobalOption('searchInTables', 'frontendhome'); if (array_key_exists('flashmessages', $_SESSION)) { $tpl->assign('messages', $_SESSION['flashmessages']); } if (count($tables) == 0) { $tpl->assign('showlivesearch', false); } else { $tpl->assign('showlivesearch', true); } return $tpl->fetch(M_Office::$dsp); } catch (Exception $e) { M_Office::$dsp = '__defaut/error'; $tpl->assign('message', $e->getMessage()); $tpl->assign('error', $e); return $tpl->fetch(M_Office::$dsp); } }
public function run() { $this->do = $this->getRecord(); deny_unless_can('read', $this->do); $this->assign('__action', 'edit'); $this->append('subActions', '<a href="' . M_Office_Util::getQueryParams(array(), array('record', 'doSingleAction', '__record_ref')) . '">' . __('< Back to list') . '</a>'); $tpl = Mreg::get('tpl'); $tpl->concat('adminTitle', $this->do->__toString() . ' :: ' . $this->moduloptions['title']); $tpl->assign('adminHeader', $this->do->__toString()); $database = $this->do->database(); /** * * Actions * **/ if (isset($_REQUEST['doSingleAction']) && $this->getGlobalOption('actions', 'showtable', $this->module)) { $subController = new M_Office_Actions($this->getOptions()); $subController->run($this->do, $_REQUEST['doSingleAction'], 'single'); if ($subController->hasOutput()) { return; } } $this->createActions(); $formBuilder = MyFB::create($this->do); if (!can('update', $this->module)) { $formBuilder->userEditableFields = array('__fakefield'); } $editopts = PEAR::getStaticProperty('m_office_editrecord', 'options'); if (!empty($editopts['tableOptions'][$this->module]['fields'])) { $formBuilder->fieldsToRender = $editopts['tableOptions'][$this->module]['fields']; } $form = new MyQuickForm('editRecord', 'POST', M_Office_Util::doURL($this->do, $this->module, array()), '_self', null, true); $formBuilder->elementTypeAttributes = array('longtext' => array('cols' => 50, 'rows' => 10)); $formBuilder->useForm($form); if ($this->getOption('edit', $this->module)) { $this->assign('editable', true); } else { $doFreeze = true; } $form = $formBuilder->getForm(); if (PEAR::isError($form)) { throw new Exception($form->getMessage() . ' ' . print_r($form->getUserInfo(), true)); } if ($doFreeze) { $form->freeze(); $submit = $form->getElement('__submit__'); if (!PEAR::isError($submit)) { $form->removeElement('__submit__'); } } if ($form->validate()) { $ret = $form->process(array($formBuilder, 'processForm'), false); if (PEAR::isError($ret)) { $this->append('errors', __('An error occured while updating record') . ' : ' . $ret->getMessage()); $this->assign('__action', 'error'); return; } else { $params_to_remove = array(); $values = $form->exportValues(); if ($values['__backtolist__']) { $params_to_remove[] = 'record'; } if (!key_exists('debug', $_REQUEST)) { $this->say(__('Record saved !')); M_Office_Util::refresh(M_Office_Util::doURL($this->do, $this->module, array(), $params_to_remove)); } } } $this->assign('editForm', $form); if ($linkFromTables = $this->getOption('linkFromTables', $this->table)) { $ajaxFrom = $this->getOption('ajaxLinksFromTable', $this->table); if (!is_array($ajaxFrom)) { $ajaxFrom = array(); } foreach ($this->do->reverseLinks() as $linkFromTable => $field) { list($linkTab, $linkField) = explode(':', $linkFromTable); switch (true) { case !$this->getGlobalOption('view', 'showtable', $linkTab): break; case key_exists($linkTab, $ajaxFrom): $fromfield = $ajaxFrom[$linkFromTable]['fromfield']; if ($fromfield == $linkField || !$fromfield) { $info = $ajaxFrom[$linkTab]; $aja = new M_Office_ajaxFromTable($this->do, $this->module, $linkTab, $linkField, $this->do->{$field}); if ($info['position'] == 'before') { $ajaxLinksBefore[] = $aja->getBlock(); } else { $ajaxLinksAfter[] = $aja->getBlock(); } } break; case $linkFromTables === TRUE || is_array($linkFromTables) && in_array($linkTab, $linkFromTables): if ($linkInfo = $this->getLinkFromTableItem($linkTab, $linkField, $field)) { $linkFromTableArray[] = $linkInfo; } break; } } } M::hook($this->do->tableName(), 'alterLinkFromTables', array(&$linkFromTableArray, $this->do)); $this->assign('linkFromTables', $linkFromTableArray); $this->assign('ajaxFrom', array('before' => $ajaxLinksBefore, 'after' => $ajaxLinksAfter)); $related = ''; if (($linkToTables = $this->getOption('linkToTables', $this->table)) && is_array($links = $this->do->links())) { foreach ($links as $linkField => $link) { list($linkTab, $linkRec) = explode(':', $link); if ((!is_array($linkToTables) || in_array($linkTab, $linkToTables)) && $this->getOption('view', $linkTab)) { $linkDo = $this->do->getLink($linkField); if ($linkDo) { $this->append('linkToTables', array('table' => $linkTab, 'link' => M_Office_Util::DoUrl($linkDo, $linkTab, array(), array('page')))); } } } } $this->assign('related', $related); $this->assign('do', $this->do); }
/** * Creates the form for action parameters, if params are required for the current action * @return null if no param * @return HTML_QuickForm if params */ public function createParamsForm() { $tpl = Mreg::get('tpl'); $tpl->concat('adminTitle', ' :: ' . $this->getActionTitle()); if ($this->actiondo instanceof M_Plugin) { $tpl->addPath('M/DB/DataObject/Plugin/' . $this->actiondo->getFolderName() . '/templates/', 'before'); } $prepareMethod = 'prepare' . $this->actionName; if (method_exists($this->actiondo, $prepareMethod) || is_array($this->_actionInfo['chainable'])) { $qfAction = new MyQuickForm('actionparamsForm', 'POST', M_Office_Util::getQueryParams(array(), array('selected', 'doaction', 'glaction', 'doSingleAction'), false), '_self', null, true); Mreg::get('tpl')->addJSinline('$("input[type=text],textarea","form[name=actionparamsForm]").eq(0).focus()', 'ready'); Mreg::get('tpl')->assign('do', $do); $qfAction->addElement('header', 'qfActionHeader', $this->getActionTitle()); $qfAction->addElement('hidden', $this->typeval, $this->actionName); $qfAction->addElement('hidden', '__actionscope', $this->scope); if ($this->scope == 'selected') { M_Office_Util::addHiddenField($qfAction, 'selected', $this->getSelectedIds()); } $selectedDo = $this->getSelected(true); if ('single' == $this->type) { $selectedDo->fetch(); } if (method_exists($this->actiondo, $prepareMethod)) { if (is_a($this->actiondo, 'M_Plugin')) { call_user_func(array($this->actiondo, $prepareMethod), $qfAction, $selectedDo); } else { call_user_func(array($selectedDo, $prepareMethod), $qfAction); } } if ($this->_actionInfo['chainable'] && count($this->nextactions) == 0) { $qfAction->addElement('select', '__nextaction', __('Execute this action then ...'), array_merge(array('' => ''), $this->getNextActions())); } if (count($this->nextactions) > 0) { $qfAction->addElement('hidden', '__actionchain', implode(',', $this->nextactions)); } $qfAction->addElement('submit', '__submit__', __('Execute')); return $qfAction; } else { return null; } }
protected function getModuleCommand($module, $command, $params = array()) { $modulePath = APP_ROOT . 'app/' . APP_NAME . '/modules/' . $module . '/'; if (!file_exists($modulePath . '/commands/' . $command . '.php')) { if (file_exists($modulePath)) { throw new Exception($module . ' module does not exist'); } else { throw new Exception($module . ' does not have ' . $command . ' command'); } } require_once $modulePath . '/commands/' . $command . '.php'; $className = $module . '_Command_' . $command; // Setting up options including Databases DSN Mreg::get('setup')->setUpEnv(); // Executing $com = new $className(); return $com; }
public static function outputform(&$form, $template = 'bordered', $addwait = true) { if ($addwait) { $formId = $form->getAttribute('id'); Mtpl::addJSinline(' $("#' . $formId . ' input:submit").click(function() { $(\'<span><img src="images/indicator.gif" />' . __('Loading... Please wait') . '</span>\').prependTo($(this).parent()); }); ', 'ready'); } $options = PEAR::getStaticProperty('M_Office', 'options'); $tpl = Mreg::get('tpl')->instance(); $tpl->assignRef('form', $form); return $tpl->fetch('form-' . $template); }
function __construct($module) { parent::__construct(); $this->assign('module', $module); $this->module = $module; deny_unless_can('read', $module); if ((isset($_REQUEST['record']) || isset($_REQUEST['__record_ref'])) && ($this->getOption('edit', $module) || $this->getOption('view', $module))) { $subController = new M_Office_EditRecord($module, $_REQUEST['record'], $additionalFilter); $subController->__record_ref = $_REQUEST['__record_ref']; $subController->run(); return; } if (isset($_REQUEST['addRecord']) && $this->getOption('add', $module)) { deny_unless_can('create', $module); $subController = new M_Office_AddRecord($module); $subController->run(); return; } $opts = PEAR::getStaticProperty('m_office', 'options'); $this->moduloptions = $opts['modules'][$module]; $this->table = $this->moduloptions['table']; if (!$this->getOption('view', $module)) { M_Office_Util::refresh(ROOT_ADMIN_URL . ROOT_ADMIN_SCRIPT); } if ($this->getOption('search', $module)) { // 1. Url curation if needed // if(!key_exists('_c_',$_REQUEST) && !M_Office::isAjaxRequest()) { // M_Office_Util::refresh(M_Office::cleanURL(array('_c_'=>1),array('searchSubmit','__submit__'))); // } // 2. Process search $doSearch = M_Office_Util::doForModule($this->module); $searchForm = M_Office_Util::getSearchForm($doSearch, $this->module); $this->assign('search', $searchForm); $searchValues = $searchForm->exportValues(); } else { $searchValues = array(); } $do = $this->getSearchDO($searchValues); if (isset($_REQUEST['doaction']) && $this->getOption('actions', $module)) { $order = trim($_REQUEST['_ps'] . ' ' . $_REQUEST['_pd']); if ($order) { $do->orderBy(); $do->orderBy($order); } $subController = new M_Office_Actions($this->getOptions()); $subController->run($do, $_REQUEST['doaction'], 'batch'); if ($subController->has_output) { return; } } elseif (isset($_REQUEST['glaction']) && $this->getOption('actions', $module)) { $subController = new M_Office_Actions($this->getOptions()); $subController->run($do, $_REQUEST['glaction'], 'global'); if ($subController->has_output) { return; } } if ($this->getAndProcessActions(clone $do, $module)) { return; } if ($this->getOption('view', $this->module) === TRUE) { $dg = new M_Office_View_DOPaging($this); $this->assign('__listview', 'dopaging'); } else { $class = 'M_Office_View_' . $this->getOption('view', $this->module); $dg = new $class($this); $this->assign('__listview', $this->getOption('view', $this->module)); } $tpl = Mreg::get('tpl'); $do_before_fetch = clone $do; $tpl->assign('do_before_fetch', $do_before_fetch); $tpl->concat('adminTitle', $this->moduloptions['title'] . ' :: Listing'); $tpl->assign('adminHeader', $this->moduloptions['title']); $pagination = $this->paginate === false ? false : true; $dg->prepare($do, $this->module, $pagination); $this->assign('dg', $dg); $this->assign('total', $total); $this->assign('pager', $dg->getPaging()); $this->assign('fields', $dg->getFields()); $this->assign('__action', 'showtable'); $deleteForm = new MyQuickForm('showTableForm', 'post', M_Office_Util::getQueryParams(array(), array()), '_self', null, true); M_Office_Util::addHiddenFields($deleteForm, array(), true); }