function _createContent(&$toReturn) { $_returnUrl = new ProjectUrl('showBranchList', null, 'workflow'); $_menu[] = array('label' => CopixI18N::get('|views.menu.branches'), 'action' => $_returnUrl->getUrl()); $_returnUrl->setAction('showWorkerList'); $_menu[] = array('label' => CopixI18N::get('|views.menu.workers'), 'action' => $_returnUrl->getUrl()); $_returnUrl->setAction('showContractList'); $_menu[] = array('label' => CopixI18N::get('|views.menu.contracts'), 'action' => $_returnUrl->getUrl()); $_returnUrl->setAction('information'); $_returnUrl->setModule('welcome'); $_menu[] = array('label' => CopixI18N::get('|views.menu.help'), 'action' => $_returnUrl->getUrl()); $_template =& new CopixTpl(); $_template->assign('MENU_LIST', $_menu); // retour de la fonction : $toReturn = $_template->fetch('menu.tpl'); return true; }
/** * Store data * * @access private */ function storeData($entityName) { $_entityName = $entityName; $_httpRequest =& HttpRequest::instance(); $_session =& HttpSession::instance(); $_tagged = $_session->getAttribute('TAGGED'); $_index = $_session->getAttribute('INDEX'); $_create = $_index < 0; $_next = false; if ($_httpRequest->getAttribute('accept')) { $_httpRequest->removeAttribute('accept'); $_new = $_httpRequest->getAttribute('ENTITY'); foreach ($_session->getAttribute('ENTITY') as $_key => $_value) { $_old[$_key] = $_value; } $_equal = true; foreach ($_new as $_key => $_value) { if ($_value !== $_old[$_key]) { $_updated[$_key] = $_value; $_equal = false; } else { $_updated[$_key] = $_old[$_key]; } } if (!$_equal) { $_dao =& CopixDAOFactory::create($_entityName); if ($_create) { $_entity =& CopixDAOFactory::createRecord($_entityName); foreach ($_updated as $_key => $_value) { $_entity->{$_key} = $_value; } $_dao->insert($_entity); $_connection =& CopixDbFactory::getConnection(); $_tagged[] = $_connection->lastId(); } else { // update $_dlname = 'get' . $_entityName . 'DataList'; $_dataList = $this->{$_dlname}(); $_idLabel = $_dataList['id']['var']; $_entity = $_dao->get($_updated[$_idLabel]); foreach ($_updated as $_key => $_value) { $_entity->{$_key} = $_value; } $_dao->update($_entity); } } ++$_index; // next one ? $_next = $_create || $_index < sizeOf($_tagged); } elseif ($_httpRequest->getAttribute('cancel')) { $_httpRequest->removeAttribute('cancel'); ++$_index; // next one ? $_next = !$_create && $_index < sizeOf($_tagged); } else { // always return to the list } if ($_next) { $_session->setAttribute('INDEX', $_index); $_httpRequest->removeAttribute('ENTITY'); $_forward = $_create ? 'create' : 'update'; $_httpRequest->setAttribute($_forward, $_forward); // $_httpRequest->setAttribute('TAGGED', $_tagged); // TODO: la méthode CopixUrl::getUrl ne gère pas correctement les tableaux, d'où : foreach ($_tagged as $_key => $_Id) { $_httpRequest->setAttribute('TAGGED[' . $_key . ']', $_Id); } $_requestUrl = new ProjectUrl('manage' . $_entityName . 'Data', null, 'workflow', $_httpRequest->toArray()); } else { $_requestUrl = new ProjectUrl('show' . $_entityName . 'List', null, 'workflow'); } return new CopixActionReturn(COPIX_AR_REDIRECT, $_requestUrl->getUrl(false)); }