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 loginForm($table) { $form = new MyQuickForm('loginform', 'POST', M_Office_Util::getQueryParams(array(), array(), false), '_self', null, true); $authDO = DB_DataObject::factory($table); $authDO->prepareForLogin(false, false); $authFB = MyFB::create($authDO); $authFB->useForm($form); $authFB->getForm(); if ($form->validate()) { M_Office_Util::refresh($_SERVER['REQUEST_URI']); } M_Office::$dsp = 'login'; $this->assign('loginForm', $form); }
" class="editlinelink" rel="<?php echo $table . $do->{$pk}; ?> "> <?php echo Icons::getIcon('edit'); ?> </a> <?php } ?> <?php if ($delete) { ?> <a href="<?php echo M_Office_Util::getQueryParams(array('module' => $table, 'deleteFromTableRecord' => $do->{$pk}, 'ajaxfromtable' => 1), array_keys($_GET), false); ?> " class="deletelinelink" rel="<?php echo $table . $do->{$pk}; ?> "> <?php echo Icons::getIcon('delete'); ?> </a> <?php } ?> </span> <span><?php echo $this->i('recordhtmlsummary', array('record' => $do));
$this->i('showtable_beforelistview', array('do' => $do_before_fetch), true); ?> <br style="clear:left" /> <br /> <span style="float:right;display:block"><?php _e('Total records'); ?> : <b><?php echo $dg->totalItems; ?> </b></span> <?php if ($selectable) { ?> <form id="showTableForm" method="post" action="<?php echo M_Office_Util::getQueryParams(array(), array(), false); ?> "> <?php echo M_Office_Util::hiddenFields(array(), true); } $this->i('listview/' . $__listview, array('dg' => $dg, 'pager' => $pager, 'fields' => $fields, 'selectable' => $selectable, 'edit' => $edit)); if ($selectable) { ?> <br /> <a href="javascript:void(0)" rel="checkboxes"><?php _e('Check all'); ?> </a>/<a href="javascript:void(0)" rel="uncheckboxes"><?php echo __('Uncheck all'); ?>
<?php $this->i('form-discrete', array('form' => $actionform, 'cancel' => true, 'cancelurl' => M_Office_Util::getQueryParams(array(), array('doSingleAction', 'glaction', 'doaction')))); if ($isdownload) { $this->startCapture('js'); ?> var nextDone = false; $('form').bind('submit',function(){ if(!nextDone) { $('<input type="submit" value=">> <?php _e('Next'); ?> " name="__submitnext__"/>').appendTo($(this).find('.submitbutton')); } nextDone = true; }); <?php $this->endCapture(); Mtpl::addJSinline($this->getCapture('js')); }
/** * 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; } }
public static function URL($params = array(), $remove = array(), $entities = false, $clean = false) { if (!is_array($params)) { $tmp = explode('/', $params); $params = $remove; $params['module'] = $tmp[0]; $params['action'] = $tmp[1]; $remove = $entities; $entities = false; } return M_Office_Util::getQueryParams($params, $remove, $entities, $clean); }
public function doExecList() { $this->table = $table; if (!$this->getConfig('view', $table)) { M_Office_Util::refresh(ROOT_ADMIN_URL . ROOT_ADMIN_SCRIPT); } $do =& $this->doForTable($table); if ($this->getOption('search', $table)) { $doSearch =& $this->doForTable($table); $searchForm =& M_Office_Util::getSearchForm($doSearch); $this->assign('search', $searchForm); if (isset($_REQUEST['searchSubmit'])) { $do = $this->getSearchDO($searchForm); } } if ($this->getAndProcessActions(clone $do, $table)) { return; } if (isset($_REQUEST['record']) && ($this->getOption('edit', $table) || $this->getOption('view', $table))) { $subController = new M_Office_EditRecord($table, $_REQUEST['record']); $this->assign('__action', 'edit'); return; } if ($this->getOption('view', $do->tableName()) === TRUE) { $dg =& new M_Office_View_DOPaging($this); $this->assign('__listview', 'dopaging'); } else { $class = 'M_Office_View_' . $this->getOption('view', $do->tableName()); $dg = new $class($this); $this->assign('__listview', $this->getOption('view', $do->tableName())); } $dg->prepare($do, true, isset($searchWhere) ? $paginate ? true : false : true); $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(), false), '_self', null, true); M_Office_Util::addHiddenFields($deleteForm, array(), true); }
public function getLinkFromTableItem($linkTab, $linkField, $field) { $linkDo = DB_DataObject::factory($linkTab); if (PEAR::isError($linkDo)) { throw new Exception($linkTab . ' is not defined'); } $info = M_Office_Util::getModuleInfo($linkTab); if (!$info && !$linkDo->isNtable()) { return; } if ($nfield = $linkDo->isNtable()) { $nFields = $linkDo->links(); $ntableArray = explode(':', $nFields[$nfield]); $nDo = DB_DataObject::factory($ntableArray[0]); $linkDo->{$linkField} = $this->do->{$field}; $nDo->joinAdd($linkDo); $nbLinkedRecords = $nDo->count(); $parameters = array('module' => $nDo->tableName(), 'filternField' => $linkField, 'filternTable' => $linkTab, 'filternValue' => $this->do->{$field}); $removed = array('module', 'filternValue', 'filternField', 'record', '__record_ref'); $link = M_Office_Util::getQueryParams($parameters, $removed); $add = false; $tableName = __("modules.{$ntableArray['0']}.frontname") . ' <small>(n-n)</small>'; } else { $linkDo->{$linkField} = $this->do->{$field}; $nbLinkedRecords = $linkDo->count(); $parameters = array('module' => $linkTab, 'filterField' => $linkField, 'filterValue' => $this->do->{$field}); $removed = array('module', 'filterValue', 'filterField', 'record', '__record_ref'); if ($nbLinkedRecords == 1) { $keys = $linkDo->keys(); $key = $keys[0]; $linkDo->find(true); $link = M_Office_Util::doURL($linkDo, $linkTab, array('filterField' => $linkField, 'filterValue' => $this->do->{$field})); } else { $link = M_Office_Util::getQueryParams($parameters, $removed); } $tableName = __("modules.{$linkTab}.frontname"); $add = $this->getGlobalOption('add', 'showtable', $linkTab) ? true : false; } return array('table' => $linkTab, 'linkField' => $linkField, 'field' => $field, 'link' => $link, 'nb' => $nbLinkedRecords, 'tablename' => $tableName, 'add' => $add); }
function &getAddFormObject($record = null) { if (is_null($record)) { $record = $this->getObject(); } if (!$record->isNew()) { $formaction = 'updateFromTableRecord'; $formclass = 'updateFromTableForm'; $formactionval = $record->pk(); $formname = 'addFromTable__' . $this->table . $record->pk(); $update = $this->table . $record->pk(); $sub = "OK"; } else { $formaction = 'addFromTableRecord'; $formclass = 'addFromTableForm'; $formactionval = 1; $formname = 'addFromTable__' . $this->table; $update = 'endList__' . $this->table; $sub = "+"; } $form = new MyQuickForm($formname, 'POST', M_Office_Util::getQueryParams(array('module' => $this->table, 'filterField' => $this->field, 'filterValue' => $this->value, $formaction => $formactionval, 'ajaxfromtable' => 1), array_keys($_REQUEST), false)); $form->updateAttributes(array('class' => $formclass, 'target' => $update)); Mtpl::addJS('jquery.form'); $record->fb_requiredRuleMessage = __('The field "%s" is required'); $record->fb_ruleViolationMessage = __('The field "%s" is not valid'); $record->fb_formAddHeader = true; $record->fb_createSubmit = false; $record->fb_submitText = $sub; $this->fb =& MyFB::create($record); $this->fb->useForm($form); $this->fb->getForm(); if ($form->elementExists($this->field)) { $form->removeElement($this->field); } $form->addElement('submit', '__submit__', '+'); $form->addElement('hidden', $this->field, $this->value); // $form->addElement('static','st','','<pre>'.print_r($_REQUEST,true).'</pre>'); return $form; }
function getChildLink($params, $args = null) { return '<a href="' . M_Office_Util::getQueryParams(array('addRecord' => 1, 'filterField' => 'parent_id', 'filterValue' => $params['record'][$args['pk']])) . '">+Enfant</a>'; }
<div style="text-align: center; clear: both;"> <?php if ($regenerate) { ?> <a href="<?php echo M_Office_Util::getQueryParams(array('regenerate' => 1), array('record', 'page', 'delete', 'table')); ?> ">Regénérer les modèles</a> <?php } ?> </div>
</p><?php $remaining = $step > 0 ? ($timeout + 2) * (($total - $start) / $step) : 0; ?> Temps restant estimé : <?php echo round($remaining / 60); ?> m <?php echo $remaining % 60; ?> s</p> <?php if ($timeout) { ?> <p>Cette page se rafraîchit automatiquement toutes les <?php echo $timeout / 1000; ?> secondes...</p> <?php } if ($remaining > 100) { ?> <p>Vous pouvez continuer à travailler en <a href="<?php echo M_Office_Util::getQueryParams(array(), array('glaction', 'step', '__start', 'doaction', 'dosingleaction')); ?> " target="_blank">cliquant ce lien</a> (ouvre l'office dans une nouvelle fenêtre)</p> <?php } ?> <input type="submit" name="__submit__" id="next" value="Suivants" /> </form>
<?php foreach ($data as $arec) { ?> <li><a href="<?php echo $arec['link']; ?> "><?php echo $arec['nb']; ?> <?php echo $arec['tablename']; ?> </a> <?php if ($arec['add']) { ?> <a href="<?php echo M_Office_Util::getQueryParams(array('module' => $arec['table'], 'addRecord' => 1, 'filterField' => $arec['linkField'], 'filterValue' => $do->{$arec['field']}), array('record', '__record_ref')); ?> ">[+]</a> <?php } ?> </li> <?php } ?> </ul> <?php }
function getAndProcessActions(&$do, $table) { $batchActions = array(); $globalActions = array(); /* $do->find();*/ $this->assign('globalActions', array()); if ($this->getOption('delete', $table)) { $batchActions['delete'] = array('title' => __('Delete')); } if (can('add', $table) && $do->can_add_with_parameters($_REQUEST['filterField'], $_REQUEST['filterValue'])) { $this->append('globalActions', array('url' => M_Office_Util::getQueryParams(array('addRecord' => 1)), 'title' => '<strong>+</strong>', 'attributes' => 'class="addlink"')); } $acts = $this->getOption('actions', $table); if ($acts) { if (method_exists($do, 'getBatchMethods')) { $batchActions = $this->filterActions(array_merge($batchActions, $do->getBatchMethods()), $acts); $this->assign('batchActions', $batchActions); } if (method_exists($do, 'getGlobalMethods')) { $globalActions = $this->filterActions($do->getGlobalMethods(), $acts); } foreach ($globalActions as $k => $v) { $this->append('globalActions', array('url' => M_Office_Util::getQueryParams(array('glaction' => $k)), 'title' => $v['title'])); } } if (count($batchActions) > 0) { $this->hasActions = true; } return false; }