function processRequest() { $this->assign('__action', 'livesearch'); $this->assign('searchText', $this->searchtext); $searchin = $this->expand ? array($this->expandTable) : $this->getGlobalOption('searchInTables', 'frontendhome'); if (!is_array($searchin) || count($searchin) == 0) { return array('message' => __('No search domain')); } $out = array(); foreach ($searchin as $table) { $obj = M_Office_Util::doForTable($table); if (method_exists($obj, 'livesearch')) { $obj->livesearch($this->searchtext); $out[$table] = $obj; } } foreach ($out as $table => $obj) { $cnt = 0; foreach ($obj as $rec) { $result = $rec->liveSearchText(); if (!is_array($result)) { $result = array('text' => $result); } $ret[$table][] = array_merge($result, array('url' => M_Office_Util::doURL($rec, $table, array(), array('livesearch', 'format')))); $cnt++; if ($cnt > 10) { break; } } if ($cnt == 0) { $ret[$table] = array(); } } $this->assign('output', $this->format($ret, $_GET['format'])); }
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 setup() { M_Office_Util::$mainOptions = PEAR::getStaticProperty('m_office', 'options'); M::addPaths('module', array(APP_ROOT . 'app/_shared/modules/', APP_ROOT . 'app/' . APP_NAME . '/modules/', 'M/Office/modules/')); M::addPaths('template', array(OFFICE_TEMPLATES_FOLDER, APP_ROOT . 'app/_shared/templates/', APP_ROOT . 'app/' . APP_NAME . '/templates/')); if (Config::getPref('theme')) { M::addPaths('template', array(APP_ROOT . 'public/themes/' . Config::getPref('theme') . '/templates/')); } $tpl = new Mtpl(M::getPaths('template')); $tpl->assign('jsdir', SITE_URL . 'js/'); Mreg::set('tpl', $tpl); }
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); }
public function __construct($do, $delete) { parent::__construct(); foreach ($delete as $deleteId) { $deldo = DB_DataObject::factory($do->tableName()); $deldo->get($deleteId); if ($deldo->delete()) { $this->say(__('Record # %s was deleted', array($deleteId))); } unset($deldo); } $this->say(__('The selected records were deleted')); M_Office_Util::refresh(M_Office::URL($this->_initRequest($_POST))); return; }
/** * 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); }
protected function &getSearchForm() { if (!$this->getConfig('search')) { return false; } if ($this->_searchform) { return $this->_searchform; } $do = $this->getDO(); $form = new MyQuickForm('searchform', 'GET', URL::get($this->_modulename . '/list'), '', null, true); if (method_exists($do, 'prepareSearchForm')) { $do->prepareSearchForm(); } $formBuilder = MyFB::create($do); $formBuilder->selectAddEmpty = array(); if (is_array($do->links())) { foreach ($do->links() as $field => $link) { $formBuilder->selectAddEmpty[] = $field; } } if (is_array($formBuilder->enumFields)) { foreach ($formBuilder->enumFields as $field) { $formBuilder->selectAddEmpty[] = $field; } } $formBuilder->linkNewValue = false; if ($o = $do->getPlugin('ownership')) { if ($o->userIsInAdminMode()) { $formBuilder->fieldsToRender[] = $do->ownerShipField; $formBuilder->fieldLabels[$do->ownerShipField] = 'géré par'; } } $formBuilder->userEditableFields = $do->fb_fieldsToRender; $formBuilder->formHeaderText = __('Search'); $formBuilder->submitText = '>>'; $formBuilder->preGenerateFormCallback = 'fake'; $formBuilder->useForm($form); $specialElements = array_keys($formBuilder->_getSpecialElementNames()); foreach ($specialElements as $specialField) { unset($fieldsToRender[$specialField]); } $formBuilder->getForm(); $form->addElement('hidden', 'searchSubmit', 1); $form->_rules = array(); $form->_formRules = array(); $form->_required = array(); M_Office_Util::addHiddenFields($form, array('search', 'page'), true); $form->addElement('checkbox', '__dontpaginate', '', __('Afficher les résultats sur une seule page')); $this->_searchform = $form; return $this->_searchform; }
<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'); ?> </a> <br /> <?php echo __('Scope');
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 }
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); }
<?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')); }
<?php if ($edit) { ?> <td> <a href="<?php echo M_Office_Util::doURL($do, $_REQUEST['module']); ?> "><i class="icon-pencil"></i></a> </td> <?php }
" 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));
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; }