/** * Theme admin page * * @param type $action * @param type $subaction */ public function admin($action = NULL, $subaction = NULL) { $form = new Form('Admin.theme'); if ($form->is_ajaxed) { if ($form->elements->logo->is_ajaxed) { $cogear->set('theme.logo', ''); } if ($form->elements->favicon->is_ajaxed) { $cogear->set('theme.favicon', ''); } } else { $form->setValues(array('logo' => config('theme.logo'), 'favicon' => config('theme.favicon'))); } if ($result = $form->result()) { $result->logo && $cogear->set('theme.logo', $result->logo); $result->favicon && $cogear->set('theme.favicon', $result->favicon); } append('content', $form->render()); }
/** * It Renders content according to Part['Type'] * * @author Fernando Ontiveros Lira <*****@*****.**> * * @param intPos = 0 * @return void * */ public function RenderContent0($intPos = 0, $showXMLFormName = false) { global $G_FORM; global $G_TABLE; global $G_TMP_TARGET; global $G_OP_MENU; global $G_IMAGE_FILENAME; global $G_IMAGE_PARTS; global $_SESSION; //Changed from $HTTP_SESSION_VARS global $G_OBJGRAPH; //For graphLayout component $this->intPos = $intPos; $Part = $this->Parts[$intPos]; $this->publishType = $Part['Type']; switch ($this->publishType) { case 'externalContent': $G_CONTENT = new Content(); if ($Part['Content'] != "") { $G_CONTENT = G::LoadContent($Part['Content']); } G::LoadTemplateExternal($Part['Template']); break; case 'image': $G_IMAGE_FILENAME = $Part['File']; $G_IMAGE_PARTS = $Part['Data']; break; case 'appform': global $APP_FORM; $G_FORM = $APP_FORM; break; case 'xmlform': case 'dynaform': global $G_FORM; if ($Part['AbsolutePath']) { $sPath = $Part['AbsolutePath']; } else { if ($this->publishType == 'xmlform') { $sPath = PATH_XMLFORM; } else { $sPath = PATH_DYNAFORM; } } //if the xmlform file doesn't exists, then try with the plugins folders if (!is_file($sPath . $Part['File'] . '.xml')) { $aux = explode(PATH_SEP, $Part['File']); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) > 2) { //Subfolders $filename = array_pop($aux); $aux0 = implode(PATH_SEP, $aux); $aux = array(); $aux[0] = $aux0; $aux[1] = $filename; } if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($response = $oPluginRegistry->isRegisteredFolder($aux[0])) { if ($response !== true) { $sPath = PATH_PLUGINS . $response . PATH_SEP; } else { $sPath = PATH_PLUGINS; } } } } if (!class_exists($Part['Template']) || $Part['Template'] === 'xmlform') { $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, false); } else { eval('$G_FORM = new ' . $Part['Template'] . ' ( $Part[\'File\'] , "' . $sPath . '");'); } if ($this->publishType == 'dynaform' && ($Part['Template'] == 'xmlform' || $Part['Template'] == 'xmlform_preview')) { $dynaformShow = isset($G_FORM->printdynaform) && $G_FORM->printdynaform ? 'gulliver/dynaforms_OptionsPrint' : 'gulliver/dynaforms_Options'; $G_FORM->fields = G::array_merges(array('__DYNAFORM_OPTIONS' => new XmlForm_Field_XmlMenu(new Xml_Node('__DYNAFORM_OPTIONS', 'complete', '', array('type' => 'xmlmenu', 'xmlfile' => $dynaformShow, 'parentFormId' => $G_FORM->id)), SYS_LANG, PATH_XMLFORM, $G_FORM)), $G_FORM->fields); } //Needed to make ajax calls //The action in the form tag. if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->action = urlencode(G::encrypt($Part['Target'], URL_KEY)); } else { $G_FORM->action = $Part['Target']; } if (!(isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '')) { if ($this->publishType == 'dynaform') { $Part['ajaxServer'] = '../gulliver/defaultAjaxDynaform'; } else { $Part['ajaxServer'] = '../gulliver/defaultAjax'; } } if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } $G_FORM->setValues($Part['Data']); $G_FORM->setValues(array('G_FORM_ID' => $G_FORM->id)); //Asegurese de que no entre cuando $Part['Template']=="grid" //de hecho soo deberia usarse cuando $Part['Template']=="xmlform" if ($this->publishType == 'dynaform' && $Part['Template'] == "xmlform" || $Part['Template'] == "xmlform") { $G_FORM->values = G::array_merges(array('__DYNAFORM_OPTIONS' => isset($Part['Data']['__DYNAFORM_OPTIONS']) ? $Part['Data']['__DYNAFORM_OPTIONS'] : ''), $G_FORM->values); if (isset($G_FORM->nextstepsave)) { switch ($G_FORM->nextstepsave) { // this condition validates if the next step link is configured to Save and Go the next step or show a prompt case 'save': // Save and Next only if there are no required fields can submit the form. $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {document.getElementById("' . $G_FORM->id . '").submit();}return false;'; break; case 'prompt': // Show Prompt only if there are no required fields can submit the form. $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {if(dynaFormChanged(document.getElementsByTagName(\'form\').item(0))) {new leimnud.module.app.confirm().make({label:"@G::LoadTranslation(ID_DYNAFORM_SAVE_CHANGES)", action:function(){document.getElementById("' . $G_FORM->id . '").submit();}.extend(this), cancel:function(){window.location = getField("DYN_FORWARD").href;}.extend(this)});return false;} else {window.location = getField("DYN_FORWARD").href;return false;}}return false;'; break; } } } if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } // by default load the core template if ($Part['Template'] == 'xmlform_preview') { $Part['Template'] = 'xmlform'; } $template = PATH_CORE . 'templates/' . $Part['Template'] . '.html'; //erik: new feature, now templates such as xmlform.html can be personalized via skins if (defined('SYS_SKIN') && strtolower(SYS_SKIN) != 'classic') { // First, verify if the template exists on Custom skins path if (is_file(PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { $template = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; //Second, verify if the template exists on base skins path } elseif (is_file(G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { $template = G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; } } //end new feature if ($Part['Template'] == 'grid') { print '<form class="formDefault">'; } $scriptCode = ''; if ($this->localMode != '') { // @# las modification by erik in 09/06/2008 $G_FORM->mode = $this->localMode; } print $G_FORM->render($template, $scriptCode); if ($Part['Template'] == 'grid') { print '</form>'; } $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptFile($G_FORM->scriptURL); $oHeadPublisher->addScriptCode($scriptCode); /** * We've implemented the conditional show hide fields.. * * @author Erik A. Ortiz <*****@*****.**> * @date Fri Feb 19, 2009 */ if ($this->publishType == 'dynaform') { if (isset($_SESSION['CURRENT_DYN_UID']) || isset($_SESSION['CONDITION_DYN_UID'])) { require_once "classes/model/FieldCondition.php"; $oFieldCondition = new FieldCondition(); //This dynaform has show/hide field conditions if (isset($_SESSION['CURRENT_DYN_UID']) && $_SESSION['CURRENT_DYN_UID'] != '') { $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CURRENT_DYN_UID"]); //lsl } else { if (isset($_SESSION['CONDITION_DYN_UID']) && $_SESSION['CONDITION_DYN_UID'] != '') { $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CONDITION_DYN_UID"]); //lsl } } } } if (isset($ConditionalShowHideRoutines) && $ConditionalShowHideRoutines) { G::evalJScript($ConditionalShowHideRoutines); } break; case 'pagedtable': global $G_FORM; //if the xmlform file doesn't exists, then try with the plugins folders $sPath = PATH_XMLFORM; if (!is_file($sPath . $Part['File'])) { $aux = explode(PATH_SEP, $Part['File']); if (count($aux) == 2) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; } } } $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true); if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } $G_FORM->setValues($Part['Data']); if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } G::LoadSystem('pagedTable'); $oTable = new pagedTable(); $oTable->template = 'templates/' . $Part['Template'] . '.html'; $G_FORM->xmlform = ''; $G_FORM->xmlform->fileXml = $G_FORM->fileName; $G_FORM->xmlform->home = $G_FORM->home; $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; $G_FORM->values = array_merge($G_FORM->values, $Part['Data']); $oTable->setupFromXmlform($G_FORM); if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') { $oTable->ajaxServer = $Part['ajaxServer']; } /* Start Block: Load user configuration for the pagedTable */ G::LoadClass('configuration'); $objUID = $Part['File']; $conf = new Configurations(); $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', ''); $oTable->__OBJ_UID = $objUID; /* End Block */ /* Start Block: PagedTable Right Click */ G::LoadClass('popupMenu'); $pm = new popupMenu('gulliver/pagedTable_PopupMenu'); $pm->name = $oTable->id; $fields = array_keys($oTable->fields); foreach ($fields as $f) { switch (strtolower($oTable->fields[$f]['Type'])) { case 'javascript': case 'button': case 'private': case 'hidden': case 'cellmark': break; default: $label = $oTable->fields[$f]['Label'] != '' ? $oTable->fields[$f]['Label'] : $f; $label = str_replace("\n", ' ', $label); $pm->fields[$f] = new XmlForm_Field_popupOption(new Xml_Node($f, 'complete', '', array('label' => $label, 'type' => 'popupOption', 'launch' => $oTable->id . '.showHideField("' . $f . '")'))); $pm->values[$f] = ''; } } $sc = ''; $pm->values['PAGED_TABLE_ID'] = $oTable->id; print $pm->render(PATH_CORE . 'templates/popupMenu.html', $sc); /* End Block */ $oTable->renderTable(); /* Start Block: Load PagedTable Right Click */ print '<script type="text/javascript">'; print $sc; print 'loadPopupMenu_' . $oTable->id . '();'; print '</script>'; /* End Block */ break; case 'propeltable': global $G_FORM; //if the xmlform file doesn't exists, then try with the plugins folders if ($Part['AbsolutePath']) { $sPath = ''; } else { $sPath = PATH_XMLFORM; } if (!is_file($sPath . $Part['File'])) { $aux = explode(PATH_SEP, $Part['File']); //search in PLUGINS folder, probably the file is in plugin if (count($aux) == 2) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; } } //search in PATH_DYNAFORM folder if (!is_file($sPath . PATH_SEP . $Part['File'] . '.xml')) { $sPath = PATH_DYNAFORM; } } //PATH_DATA_PUBLIC ??? if (!file_exists($sPath . PATH_SEP . $Part['File'] . '.xml') && defined('PATH_DATA_PUBLIC')) { $sPath = PATH_DATA_PUBLIC; } $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true); if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } G::LoadClass('propelTable'); $oTable = new propelTable(); $oTable->template = $Part['Template']; $oTable->criteria = $Part['Content']; if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') { $oTable->ajaxServer = $Part['ajaxServer']; } if (!isset($G_FORM->xmlform)) { $G_FORM->xmlform = new stdclass(); } $G_FORM->xmlform->fileXml = $G_FORM->fileName; $G_FORM->xmlform->home = $G_FORM->home; if (!isset($G_FORM->xmlform->tree)) { $G_FORM->xmlform->tree = new stdclass(); } $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; if (is_array($Part['Data'])) { $G_FORM->values = array_merge($G_FORM->values, $Part['Data']); } $oTable->setupFromXmlform($G_FORM); /* Start Block: Load user configuration for the pagedTable */ G::LoadClass('configuration'); $objUID = $Part['File']; $conf = new Configurations($oTable); $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', ''); $oTable->__OBJ_UID = $objUID; //$oTable->__OBJ_UID = ''; /* End Block */ /* Start Block: PagedTable Right Click */ G::LoadClass('popupMenu'); $pm = new popupMenu('gulliver/pagedTable_PopupMenu'); $sc = $pm->renderPopup($oTable->id, $oTable->fields); /* End Block */ //krumo ( $Part ); if ($this->ROWS_PER_PAGE) { $oTable->rowsPerPage = $this->ROWS_PER_PAGE; } try { if (is_array($Part['Data'])) { $oTable->renderTable('', $Part['Data']); } else { $oTable->renderTable(); } print $sc; } catch (Exception $e) { $aMessage['MESSAGE'] = $e->getMessage(); $this->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); } break; case 'panel-init': global $mainPanelScript; global $panelName; global $tabCount; //G::LoadThirdParty( 'pear/json', 'class.json' ); //$json = new Services_JSON(); $tabCount = 0; $panelName = $Part['Template']; $data = $Part['File']; if (!is_array($data)) { $data = array(); } $data = G::array_merges(array('title' => '', 'style' => array(), 'left' => 'getAbsoluteLeft(mycontent)', 'top' => 'getAbsoluteTop(mycontent)', 'width' => 700, 'height' => 600, 'drag' => true, 'close' => true, 'modal' => true, 'roll' => false, 'resize' => false, 'tabWidth' => 120, 'tabStep' => 3, 'blinkToFront' => true, 'tabSpace' => 10), $data); $mainPanelScript = 'var ' . $panelName . '={},' . $panelName . 'Tabs=[];' . 'leimnud.event.add(window,"load",function(){' . $panelName . ' = new leimnud.module.panel();' . 'var mycontent=document.getElementById("' . $this->publisherId . '[' . $intPos . ']");' . $panelName . '.options={' . 'size:{w:' . $data['width'] . ',h:' . $data['height'] . '},' . 'position:{x:' . $data['left'] . ',y:' . $data['top'] . '},' . 'title:"' . addcslashes($data['title'], '\\"') . '",' . 'theme:"processmaker",' . 'statusBar:true,' . 'headerBar:true,' . 'control:{' . ' close:' . ($data['close'] ? 'true' : 'false') . ',' . ' roll:' . ($data['roll'] ? 'true' : 'false') . ',' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' resize:' . ($data['resize'] ? 'true' : 'false') . '},' . 'fx:{' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' modal:' . ($data['modal'] ? 'true' : 'false') . ',' . ' blinkToFront:' . ($data['blinkToFront'] ? 'true' : 'false') . '}' . '};' . $panelName . '.setStyle=' . Bootstrap::json_encode($data['style']) . ';' . $panelName . '.tab={' . 'width:' . ($data['tabWidth'] + $data['tabSpace']) . ',' . 'optWidth:' . $data['tabWidth'] . ',' . 'step :' . $data['tabStep'] . ',' . 'options:[]' . '};'; print ' '; break; case 'panel-tab': global $tabCount; global $mainPanelScript; global $panelName; $onChange = $Part['Content']; $beforeChange = $Part['Data']; if (SYS_LANG == 'es') { $mainPanelScript = str_replace("120", "150", $mainPanelScript); } else { $mainPanelScript = str_replace("150", "120", $mainPanelScript); } $mainPanelScript .= $panelName . 'Tabs[' . $tabCount . ']=' . 'document.getElementById("' . $Part['File'] . '");' . $panelName . '.tab.options[' . $panelName . '.tab.options.length]=' . '{' . 'title :"' . addcslashes($Part['Template'], '\\"') . '",' . 'noClear :true,' . 'content :function(){' . ($beforeChange != '' ? 'if (typeof(' . $beforeChange . ')!=="undefined") {' . $beforeChange . '();}' : '') . $panelName . 'Clear();' . $panelName . 'Tabs[' . $tabCount . '].style.display="";' . ($onChange != '' ? 'if (typeof(' . $onChange . ')!=="undefined") {' . $onChange . '();}' : '') . '}.extend(' . $panelName . '),' . 'selected:' . ($tabCount == 0 ? 'true' : 'false') . '};'; $tabCount++; break; case 'panel-close': global $mainPanelScript; global $panelName; global $tabCount; $mainPanelScript .= $panelName . '.make();'; $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . '.addContent(' . $panelName . 'Tabs[r]);'; $mainPanelScript .= '});'; $mainPanelScript .= 'function ' . $panelName . 'Clear(){'; $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}'; $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptCode($mainPanelScript); break; case 'blank': print ' '; break; case 'varform': global $G_FORM; $G_FORM = new Form(); G::LoadSystem("varform"); $xml = new varForm(); //$xml->parseFile ( ); $xml->renderForm($G_FORM, $Part['File']); $G_FORM->Values = $Part['Data']; $G_FORM->SetUp($Part['Target']); $G_FORM->width = 500; break; case 'table': $G_TMP_TARGET = $Part['Target']; $G_TABLE = G::LoadRawTable($Part['File'], $this->dbc, $Part['Data']); break; case 'menu': $G_TMP_TARGET = $Part['Target']; $G_OP_MENU = new Menu(); $G_OP_MENU->Load($Part['File']); break; case 'smarty': //To do: Please check it 26/06/07 $template = new Smarty(); $template->compile_dir = PATH_SMARTY_C; $template->cache_dir = PATH_SMARTY_CACHE; $template->config_dir = PATH_THIRDPARTY . 'smarty/configs'; $template->caching = false; $dataArray = $Part['Data']; // verify if there are templates folders registered, template and method folders are the same $folderTemplate = explode('/', $Part['Template']); $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($folderTemplate[0])) { $template->templateFile = PATH_PLUGINS . $Part['Template'] . '.html'; } else { $template->templateFile = PATH_TPL . $Part['Template'] . '.html'; } // last change to load the template, maybe absolute path was given if (!is_file($template->templateFile)) { $template->templateFile = strpos($Part['Template'], '.html') !== false ? $Part['Template'] : $Part['Template'] . '.html'; } //assign the variables and use the template $template $template->assign($dataArray); print $template->fetch($template->templateFile); break; case 'template': //To do: Please check it 26/06/07 if (gettype($Part['Data']) == 'array') { G::LoadSystem('template'); //template phpBB $template = new Template(); $template->set_filenames(array('body' => $Part['Template'] . '.html')); $dataArray = $Part['Data']; if (is_array($dataArray)) { foreach ($dataArray as $key => $val) { if (is_array($val)) { foreach ($val as $key_val => $val_array) { $template->assign_block_vars($key, $val_array); } } else { $template->assign_vars(array($key => $val)); } } } $template->pparse('body'); } if (gettype($Part['Data']) == 'object' && strtolower(get_class($Part['Data'])) == 'templatepower') { $Part['Data']->printToScreen(); } return; break; case 'view': case 'content': //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment $aux = explode(PATH_SEP, $Part['Template']); if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { //if the template doesn't exists, then try it with the plugins folders, after the normal Template $userTemplate = G::ExpandPath('templates') . $Part['Template']; $globalTemplate = PATH_TEMPLATE . $Part['Template']; if (!is_file($userTemplate) && !is_file($globalTemplate)) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $pluginTemplate = PATH_PLUGINS . $Part['Template'] . '.php'; include $pluginTemplate; } } } break; case 'graphLayout': //Added by JHL to render GraphLayout component $G_OBJGRAPH = $Part['Data']; $G_TMP_TARGET = $Part['Target']; $G_TMP_FILE = $Part['File']; break; } //krumo( $Part['Template'] ); //check if this LoadTemplate is used, byOnti 12th Aug 2008 G::LoadTemplate($Part['Template']); $G_TABLE = null; }
public function testConditionalValueWithSubform() { $form = new Form(array('main_field' => array('required'), 'options' => new Form(array('sub_field' => array('required' => create_function('$form', 'return $form->getParent()->main_field == 42;')))))); $this->assertTrue($form->validate(array('main_field' => 42, 'options' => array('sub_field' => 1))), 'Required evaluates to true'); $form->setValues(array()); $this->assertFalse($form->validate(array('main_field' => 42, 'options' => array())), 'Required evaluates to true'); $form->setValues(array()); $this->assertTrue($form->validate(array('main_field' => 0, 'options' => array('sub_field' => 1))), 'Required evaluates to false'); $form->setValues(array()); $this->assertTrue($form->validate(array('main_field' => 0, 'options' => array())), 'Required evaluates to false'); }
<?php include "forms_process.class.php"; $_POST["fn"] = "jonathan"; $_POST["ln"] = "de montalembert"; $_POST["mphone"] = "+8618600014793"; $_POST["mail"] = "*****@*****.**"; $_POST["country"] = "france"; $_POST["city"] = "paris"; $_POST['lang'] = 'en'; $_POST['fullname'] = $_POST["fn"] . ' ' . $_POST["ln"]; $form = new Form($_POST); // if($form->setConnection('localhost', 'root', '', 'fuel_dev')) // echo 'connected'; // else // echo 'not connected'; // $form->received(); // $form->getStructure("callback"); // $form->setConnection('localhost', 'root', '', 'fuel_dev'); $form->setValues("city fn mphone mail country lang")->setColumns("city name phone email country language")->setTable("form"); date_default_timezone_set('Asia/Shanghai'); $form->add(array("fromURL" => "google", "website" => "cn")); $form->addIP("user_ip"); $form->check("mail")->exist()->isEmail(); $form->check("mphone")->isPhone(); if ($form->save()) { echo 'success'; } else { echo 'not saved'; }
public static function renderArray($formId, $items, $values, $buttons = 1) { $form = new Form($formId); $opts = array(); if (empty($items['ajax'])) { $items["ajax"] = array("Hidden", "", "", array("value" => "false")); } else { $opts['ajax'] = true; $opts['ajaxCallback'] = $items['ajax']; unset($items['ajax']); } if ($buttons) { $items["noneSubmitButton"] = array("Button", "Submit"); if ($buttons != Form::$SUBMIT) { if (!empty($values['id'])) { if (is_array($buttons)) { foreach ($buttons as $k => $b) { $items[$k] = $b; } $items['noneRemoveButton'] = array("Button", "Remove", "button", array("class" => "btn-danger", "data-toggle" => "modal", "data-target" => "#rmConfirm")); } } if (!empty($items['ajax'])) { $items["noneCancelButton"] = array("Button", "Cancel", "button", array("onclick" => "history.go(-1);")); } } } $form->configure($opts); $form->addElements($items); if (!empty($values)) { $form->setValues($values); } $form->render(); }
$submitForm->updateOrAddTableRow(array("id")); } $applist = db_get("SELECT * FROM login_app", "row"); echo printHeader(); ?> <div class='container'> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <?php foreach ($applist as $appinfo) { $miniform = new Form(); $miniform->table = $table; $miniform->horizontal = true; $miniform->addElements($editable_fields); $miniform->setValues($appinfo); echo $miniform->panel($appinfo["ID"], $appinfo["FULLNAME"]); } $newform = new Form(); $newform->table = $table; $newform->horizontal = true; $newform->addElements($editable_fields); echo $newform->panel("", "New App"); ?> </div> </div> </body> </html>
/** * Dispatch request */ public function index($action = '', $subaction = 'index') { $cogear = getInstance(); $args = $cogear->router->getArgs(); $rev_args = array_reverse($args); $class = array(); $stop = FALSE; while ($piece = array_pop($rev_args)) { $class[] = ucfirst($piece); $gear = implode('_', $class); if ($cogear->gears->$gear) { $callback = array($cogear->gears->$gear, 'admin'); if (is_callable($callback)) { $cogear->router->exec($callback, $rev_args); $stop = TRUE; break; } } } if ($stop) return; switch ($action) { case 'clear': break; case 'gears': $this->gears($subaction); break; case 'theme': $form = new Form('Admin.theme'); if ($form->is_ajaxed) { if($form->elements->logo->is_ajaxed){ $cogear->set('theme.logo', ''); } if($form->elements->favicon->is_ajaxed){ $cogear->set('theme.favicon', ''); } } else { $form->setValues(array( 'logo' => config('theme.logo'), 'favicon' => config('theme.favicon'), )); } if ($result = $form->result()) { $result->logo && $cogear->set('theme.logo', $result->logo); $result->favicon && $cogear->set('theme.favicon', $result->favicon); } append('content', $form->render()); break; } }
public function testRepopulate() { Form::$errors = array(); Form::setValues(array('test' => 'something')); $actual = Form::open()->text('test')->close(); $expected = '<form action="" method="post" class="" id="" ><input type="text" name="test" id="test" value="something" class="text" /></form>'; $this->assertEquals(trim_html($expected), trim_html($actual)); // Make sure values override Form::setValues(array('test' => 'something')); $actual = Form::open()->text('test', 'else')->close(); $expected = '<form action="" method="post" class="" id="" ><input type="text" name="test" id="test" value="something" class="text" /></form>'; $this->assertEquals(trim_html($expected), trim_html($actual)); // Make sure values fall through if set directly in the form tag Form::setValues(array('test' => 'something')); $actual = Form::open()->text('test2', 'else')->close(); $expected = '<form action="" method="post" class="" id="" ><input type="text" name="test2" id="test2" value="else" class="text" /></form>'; $this->assertEquals(trim_html($expected), trim_html($actual)); }
/** * Returns a Form object for the first node in the list. * * @param array $arguments An array of values for the form fields * @param string $method The method for the form * * @return Form A Form instance * * @throws \InvalidArgumentException If the current node list is empty */ public function form(array $values = null, $method = null) { if (!count($this)) { throw new \InvalidArgumentException('The current node list is empty.'); } $form = new Form($this->getNode(0), $method, $this->host, $this->path); if (null !== $values) { $form->setValues($values); } return $form; }
public function getForm() { if ($this->form == null) { $this->processFields(); $currentObj = get_class($this); if (isset($this->parentidfield) && isset($this->parentid)) { $this->row[$this->parentidfield] = $this->parentid; } $miniform = new Form(); $miniform->international = $this->international; $miniform->table = $this->table; $miniform->horizontal = true; if (isset($this->formsubmit) && !$this->formsubmit) { $miniform->submit_button = false; } if (isset($this->formdelete) && $this->formdelete) { $miniform->delete_button = true; } if (isset($this->idfield)) { $miniform->idfields[] = $this->idfield; } if (isset($this->formtags)) { $miniform->formtags = $this->formtags; } if ($this->customFormHeader != "") { $miniform->formtags = false; } $miniform->addElements($this->fields); if (!empty($this->row)) { $miniform->setValues($this->row); } $this->form = $miniform; } return $this->form; }
public function edit($params) { if (!isset($params['questionId'])) { throw new Redirect404Exception(); } $questionId = (int) @$params['questionId']; if (empty($questionId)) { throw new Redirect404Exception(); } $this->addContentMenu(); $this->contentMenu->getElement('qst_index')->setActive(true); $editQuestion = $this->questionService->findQuestionById($questionId); $parent = $editQuestion->parent; $parentIsset = false; if (!empty($parent)) { $parentDto = $this->questionService->findQuestionByName($parent); $parentIsset = !empty($parentDto) ? true : false; if ($parentIsset) { $this->assign('parentUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $parentDto->id))); $this->assign('parentLabel', $this->questionService->getQuestionLang($parentDto->name)); } } $this->assign('parentIsset', $parentIsset); if ($editQuestion === null) { throw new Redirect404Exception(); } $this->assign('question', $editQuestion); //$editQuestionToAccountType = $this->questionService->findAccountTypeByQuestionName( $editQuestion->name ); // get available account types from DB /* @var BOL_QuestionService $this->questionService */ $accountTypes = $this->questionService->findAllAccountTypes(); $serviceLang = BOL_LanguageService::getInstance(); $language = OW::getLanguage(); $currentLanguageId = OW::getLanguage()->getCurrentId(); $accounts = array(BOL_QuestionService::ALL_ACCOUNT_TYPES => $language->text('base', 'questions_account_type_all')); /* @var $value BOL_QuestionAccount */ foreach ($accountTypes as $value) { $accounts[$value->name] = $language->text('base', 'questions_account_type_' . $value->name); } $sections = $this->questionService->findAllSections(); // need to hide sections select box if (empty($section)) { $this->assign('no_sections', true); } $sectionsArray = array(); /* @var $section BOL_QuestionSection */ foreach ($sections as $section) { $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label'); } $presentations = array(); $presentationsLabel = array(); $presentationList = $this->questionService->getPresentations(); if ($editQuestion->name != 'password') { unset($presentationList[BOL_QuestionService::QUESTION_PRESENTATION_PASSWORD]); } foreach ($presentationList as $presentationKey => $presentation) { if ($presentationList[$editQuestion->presentation] == $presentation) { $presentations[$presentationKey] = $presentationKey; //TODO add langs with presentation labels $presentationsLabel[$presentationKey] = $language->text('base', 'questions_question_presentation_' . $presentationKey . '_label'); } } $presentation = $editQuestion->presentation; if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) { $session = OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR); if (isset($session['qst_answer_type']) && isset($presentations[$session['qst_answer_type']])) { $presentation = $presentations[$session['qst_answer_type']]; } } if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) { $presentation = $presentations[$_POST['qst_answer_type']]; } //$this->addForm(new LanguageValueEditForm( 'base', 'questions_question_' . ($editQuestion->id) . '_label', $this ) ); //-- ------------------------------------- //-- add question values form creating //-- ------------------------------------- $questionValues = $this->questionService->findQuestionValues($editQuestion->name); $this->assign('questionValues', $questionValues); //add field values form $addQuestionValuesForm = new AddValuesForm($questionId); $addQuestionValuesForm->setAction($this->ajaxResponderUrl); $this->addForm($addQuestionValuesForm); //-- ------------------------------------- //-- edit field form creating //-- ------------------------------------- $editForm = new Form('qst_edit_form'); $editForm->setId('qst_edit_form'); $disableActionList = array('disable_account_type' => false, 'disable_answer_type' => false, 'disable_presentation' => false, 'disable_column_count' => false, 'disable_display_config' => false, 'disable_required' => false, 'disable_on_join' => false, 'disable_on_view' => false, 'disable_on_search' => false, 'disable_on_edit' => false); $event = new OW_Event('admin.disable_fields_on_edit_profile_question', array('questionDto' => $editQuestion), $disableActionList); OW::getEventManager()->trigger($event); $disableActionList = $event->getData(); if (count($accountTypes) > 1) { $qstAccountType = new Selectbox('qst_account_type'); $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label')); $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description')); $qstAccountType->setOptions($accounts); $qstAccountType->setValue(BOL_QuestionService::ALL_ACCOUNT_TYPES); $qstAccountType->setHasInvitation(false); if ($editQuestion->accountTypeName !== null) { $qstAccountType->setValue($editQuestion->accountTypeName); } if ($editQuestion->base == 1) { $qstAccountType->addAttribute('disabled', 'disabled'); } else { if ($disableActionList['disable_account_type']) { $qstAnswerType->setRequired(false); $qstAccountType->addAttribute('disabled', 'disabled'); } } $editForm->addElement($qstAccountType); } if (!empty($sectionsArray)) { $qstSection = new Selectbox('qst_section'); $qstSection->setLabel($language->text('admin', 'questions_question_section_label')); $qstSection->setOptions($sectionsArray); $qstSection->setValue($editQuestion->sectionName); $qstSection->setHasInvitation(false); $editForm->addElement($qstSection); } $qstAnswerType = new Selectbox('qst_answer_type'); $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label')); $qstAnswerType->addAttribute('class', $qstAnswerType->getName()); $qstAnswerType->setOptions($presentationsLabel); $qstAnswerType->setValue($presentation); $qstAnswerType->setRequired(); $qstAnswerType->setHasInvitation(false); if ($parentIsset) { $qstAnswerType->setValue($parentDto->columnCount); $qstAnswerType->addAttribute('disabled', 'disabled'); } if ((int) $editQuestion->base === 1 || count($presentations) <= 1 || $parentIsset || $disableActionList['disable_answer_type']) { $qstAnswerType->setRequired(false); $qstAnswerType->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstAnswerType); $columnCountPresentation = array(BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX, BOL_QuestionService::QUESTION_PRESENTATION_RADIO); if (in_array($presentation, $columnCountPresentation)) { $qstColumnCount = new Selectbox('qst_column_count'); $qstColumnCount->addAttribute('class', $qstColumnCount->getName()); $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label')); $qstColumnCount->setRequired(); $qstColumnCount->setOptions($this->qstColumnCountValues); $qstColumnCount->setValue($editQuestion->columnCount); $parentIsset = !empty($parentDto) ? true : false; if ($parentIsset) { $qstColumnCount->setValue($parentDto->columnCount); $qstColumnCount->addAttribute('disabled', 'disabled'); $qstColumnCount->setRequired(false); } else { if ($disableActionList['disable_column_count']) { $qstAnswerType->setRequired(false); $qstAnswerType->addAttribute('disabled', 'disabled'); } } $editForm->addElement($qstColumnCount); } $presentationConfigList = BOL_QuestionService::getInstance()->getConfigList($presentation); $presentationConfigValues = json_decode($editQuestion->custom, true); if ($editQuestion->name !== 'joinStamp' && !$disableActionList['disable_display_config']) { foreach ($presentationConfigList as $config) { $className = $config->presentationClass; /* @var $qstConfig OW_FormElement */ $qstConfig = new $className($config->name); $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label')); if (!empty($config->description)) { $qstConfig->setDescription($config->description); } if (isset($presentationConfigValues[$config->name])) { $qstConfig->setValue($presentationConfigValues[$config->name]); } $editForm->addElement($qstConfig); } } $qstRequired = new CheckboxField('qst_required'); $qstRequired->setLabel($language->text('admin', 'questions_required_label')); $qstRequired->setDescription($language->text('admin', 'questions_required_description')); $qstRequired->setValue((bool) $editQuestion->required); if ((int) $editQuestion->base === 1 || $disableActionList['disable_required']) { $qstRequired->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstRequired); $qstOnSignUp = new CheckboxField('qst_on_sign_up'); $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label')); $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description')); $qstOnSignUp->setValue((bool) $editQuestion->onJoin); if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_join']) { $qstOnSignUp->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstOnSignUp); $qstOnEdit = new CheckboxField('qst_on_edit'); $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label')); $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description')); $qstOnEdit->setValue((bool) $editQuestion->onEdit); $description = $language->text('admin', 'questions_on_edit_description'); if ($editQuestion->name === 'username') { $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description') . "<br/><br/>" . $language->text('admin', 'questions_edit_username_warning')); } else { if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_edit']) { $qstOnEdit->addAttribute('disabled', 'disabled'); } } $editForm->addElement($qstOnEdit); $qstOnView = new CheckboxField('qst_on_view'); $qstOnView->setLabel($language->text('admin', 'questions_on_view_label')); $qstOnView->setDescription($language->text('admin', 'questions_on_view_description')); $qstOnView->setValue((bool) $editQuestion->onView); if ((int) $editQuestion->base === 1 && $editQuestion->name !== 'joinStamp' || $disableActionList['disable_on_view']) { $qstOnView->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstOnView); $qstOnSearch = new CheckboxField('qst_on_search'); $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label')); $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description')); $qstOnSearch->setValue((bool) $editQuestion->onSearch); if ((int) $editQuestion->base === 1 && $editQuestion->name != 'username' || $parentIsset || $disableActionList['disable_on_search']) { $qstOnSearch->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstOnSearch); $qstSubmit = new Submit('qst_submit'); $qstSubmit->addAttribute('class', 'ow_button ow_ic_save'); $qstSubmit->setValue($language->text('admin', 'btn_label_edit')); $editForm->addElement($qstSubmit); if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) { $editForm->setValues(OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR)); OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR); } $this->addForm($editForm); if (OW_Request::getInstance()->isPost()) { if ((isset($_POST['qst_submit_and_add']) || isset($_POST['qst_submit'])) && $editForm->isValid($_POST)) { OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR); $updated = false; $data = $editForm->getValues(); $elements = $editForm->getElements(); foreach ($elements as $element) { if (!$element->getAttribute('disabled')) { switch ($element->getName()) { case 'qst_required': $editQuestion->required = isset($_POST['qst_required']) ? 1 : 0; break; case 'qst_on_sign_up': $editQuestion->onJoin = isset($_POST['qst_on_sign_up']) ? 1 : 0; break; case 'qst_on_edit': $editQuestion->onEdit = isset($_POST['qst_on_edit']) ? 1 : 0; break; case 'qst_on_search': $editQuestion->onSearch = isset($_POST['qst_on_search']) ? 1 : 0; break; case 'qst_on_view': $editQuestion->onView = isset($_POST['qst_on_view']) ? 1 : 0; break; case 'qst_answer_type': $editQuestion->presentation = htmlspecialchars($data['qst_answer_type']); break; case 'qst_column_count': $editQuestion->columnCount = htmlspecialchars($data['qst_column_count']); break; case 'qst_section': if (!empty($data['qst_section'])) { $section = $this->questionService->findSectionBySectionName(htmlspecialchars(trim($data['qst_section']))); $sectionName = null; if (isset($section)) { $sectionName = $section->name; } if ($editQuestion->sectionName !== $sectionName) { $editQuestion->sectionName = $sectionName; $editQuestion->sortOrder = (int) BOL_QuestionService::getInstance()->findLastQuestionOrder($editQuestion->sectionName) + 1; } } break; case 'qst_account_type': if ($data['qst_account_type'] !== null) { $editQuestion->accountTypeName = htmlspecialchars(trim($data['qst_account_type'])); if ($editQuestion->accountTypeName === BOL_QuestionService::ALL_ACCOUNT_TYPES) { $editQuestion->accountTypeName = null; } } break; } } } if (!$disableActionList['disable_display_config']) { // save question configs $configs = array(); foreach ($presentationConfigList as $config) { if (isset($data[$config->name])) { $configs[$config->name] = $data[$config->name]; } } $editQuestion->custom = json_encode($configs); } $this->questionService->saveOrUpdateQuestion($editQuestion); if (OW::getDbo()->getAffectedRows() > 0) { $updated = true; $list = $this->questionService->findQuestionChildren($editQuestion->name); /* @var BOL_Question $child */ foreach ($list as $child) { $child->columnCount = $editQuestion->columnCount; $this->questionService->saveOrUpdateQuestion($child); } } //update question values sort if (isset($_POST['question_values_order'])) { $valuesOrder = json_decode($_POST['question_values_order'], true); if (isset($valuesOrder) && count($valuesOrder) > 0 && is_array($valuesOrder)) { foreach ($questionValues as $questionValue) { if (isset($valuesOrder[$questionValue->value])) { $questionValue->sortOrder = (int) $valuesOrder[$questionValue->value]; } $this->questionService->saveOrUpdateQuestionValue($questionValue); if (OW::getDbo()->getAffectedRows() > 0) { $updated = true; } } } } if ($updated) { OW::getFeedback()->info($language->text('admin', 'questions_update_question_message')); } else { OW::getFeedback()->info($language->text('admin', 'questions_question_was_not_updated_message')); } //exit; $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'index')); } $editForm->setValues($_POST); OW::getSession()->set(self::EDIT_QUESTION_SESSION_VAR, $_POST); //OW::getFeedback()->error($language->text('admin', 'questions_question_was_not_updated_message')); $this->redirect(); } $types = array(); foreach ($this->questionService->getPresentations() as $presentation => $type) { if ($type === 'select') { $types[] = $presentation; } } $questionLabel = $this->questionService->getQuestionLang($editQuestion->name); $questionDescription = $this->questionService->getQuestionDescriptionLang($editQuestion->name); $noValue = $language->text('admin', 'questions_empty_lang_value'); $questionLabel = mb_strlen(trim($questionLabel)) == 0 || $questionLabel == ' ' ? $noValue : $questionLabel; $questionDescription = mb_strlen(trim($questionDescription)) == 0 || $questionDescription == ' ' ? $noValue : $questionDescription; $this->assign('questionLabel', $questionLabel); $this->assign('questionDescription', $questionDescription); $language->addKeyForJs('admin', 'questions_empty_lang_value'); $language->addKeyForJs('admin', 'questions_edit_question_name_title'); $language->addKeyForJs('admin', 'questions_edit_question_description_title'); $language->addKeyForJs('admin', 'questions_edit_question_value_title'); $language->addKeyForJs('admin', 'questions_edit_delete_value_confirm_message'); $fields = array(); foreach ($editForm->getElements() as $element) { if (!$element instanceof HiddenField) { $fields[$element->getName()] = $element->getName(); } } $this->assign('formData', $fields); $script = ' window.editQuestion = new editQuestion(' . json_encode(array('types' => $types, 'ajaxResponderUrl' => $this->ajaxResponderUrl)) . '); '; OW::getDocument()->addOnloadScript($script); $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl(); $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl(); OW::getDocument()->addScript($jsDir . "questions.js"); OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js"); }
/** * Default dispatcher * * @param string $action */ public function index_action($action = '', $subaction = NULL) { if (!empty($_POST['token'])) { // Get the profile of authorized user $UserProfile = $this->api->getAuthInfo($_POST['token']); // Check for errors if (!empty($UserProfile->error_type)) { // Debug info for developer error(t($UserProfile->error_type . ": " . $UserProfile->error_message)); } elseif (empty($UserProfile)) { error(t('Temporary error with Loginza authentification.')); } else { $this->session->loginza = $UserProfile; } } if ($loginza = $this->session->loginza) { /** * There we have 3 ways of workflow * * 1. User is logged in. Add new identity to database if it's not exist. * 2. User is registred. Authorize. * 3. User is not registred. Show register form connected and fullfilled with Loginza data (login, e-mail and so on). */ $user = new Db_ORM('users_loginza'); $user->identity = $loginza->identity; // If user is logged in if ($this->user->id) { // If integration is found if ($user->find()) { // If integration belongs to the current user if ($user->uid == $this->user->id) { $user->loginza->data = json_encode($loginza); $user->update(); flash_info(t('Your integration with profile <b>%s</b> was updated successfully.', 'Loginza', $loginza->identity), t('Updated succeed.')); } else { flash_error(t('Profile <b>%s</b> is integrated with sombody else account. You cannot use it before someone would left it out.', 'Loginza', $loginza->identity), t('Update failure.')); } } else { // Create new database record $user->uid = $this->user->id; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; // Redirect to user profile redirect(Url::gear('user') . 'edit/#tab-social'); } else { // Record found → try to log in if ($user->find()) { $search = new User_Object(); $search->id = $user->uid; if ($search->find()) { $this->user->forceLogin($user->uid, 'id'); } else { flash_error(t('Cannot find user with id <b>%s</b>.', 'Loginza', $user->uid)); } $this->session->loginza = NULL; // This tiny little redirect caused error by Loginza "Invalid / empty session data! Retry auth.: // Left it where it is for memories. // Important! Do not uncomment! //back(); } else { if (!access('user register')) { return info('You don\'t have an access to registration'); } success('First step of registration is done. Please, fill some fields to complete your registration.'); $form = new Form('User.register'); $UserProfile = new Loginza_UserProfile($loginza); $tpl = new Template('Loginza.register'); $tpl->loginza = $loginza; $tpl->profile = $UserProfile; append('content', $tpl->render()); $data['login'] = $UserProfile->genFullName(); isset($loginza->email) && ($data['email'] = $loginza->email); $form->setValues($data); if ($data = $form->result()) { $this->user->object($data); $this->user->hashPassword(); if ($uid = $this->user->save()) { // Create new database record $user->uid = $uid; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; flash_success('User was successfully registered! Please, check your email for further instructions.', 'Registration succeed.'); redirect(); } append('content', $form->render()); } } } }
/** * @covers Form::getValues */ public function testGetValues() { $this->myForm->setValues(array('fail, sent')); $this->assertNotEmpty($this->myForm->getValues()); }
/** * Show pages * * @param string $type */ public function index($action = '', $subaction = NULL) { new Menu_Tabs('pages', Url::gear('pages')); switch ($action) { case 'create': if (!page_access('pages create')) { return; } $form = new Form('Pages.createdit'); if ($result = $form->result()) { $page = new Pages_Object(); $page->object($result); $page->aid = cogear()->user->id; $page->created_date = time(); $page->last_update = time(); $page->save(); flash_success(t('New page has been successfully added!', 'Pages')); redirect($page->getUrl()); } append('content', $form->render()); break; case 'show': $this->showPage($subaction); break; case 'edit': $page = new Pages_Object(); $page->where('id', intval($subaction)); if ($page->find()) { if (access('pages edit_all') or $cogear->user->id == $page->aid) { $form = new Form('Pages.createdit'); $form->init(); if (access('pages delete')) { $form->addElement('delete', array('label' => t('Delete'), 'type' => 'submit')); } $form->setValues($page->object()); if ($result = $form->result()) { if ($result->delete) { $page->delete(); redirect(Url::gear('pages')); } $page->object()->mix($result); $page->last_update = time(); $page->update(); $link = $page->getUrl(); success(t('Page has been update. You can visit it by link <a href="%s">%s</a>', 'Pages', $link, $link)); //redirect($page->getUrl()); } $form->elements->submit->setValue(t('Update')); append('content', $form->render()); } else { return _403(); } } else { return _404(); } break; default: $this->showPages($action); } }