public function testFormManager()
 {
     $objFormManager = new class_admin_formgenerator("test", new AdminFormB());
     $objFormManager->generateFieldsFromObject();
     $this->assertNotNull($objFormManager->getField("fielda1"));
     $this->assertNotNull($objFormManager->getField("fielda2"));
     $this->assertNotNull($objFormManager->getField("fieldb1"));
     $this->assertNotNull($objFormManager->getField("fieldb2"));
     $arrFields = $objFormManager->getArrFields();
     $arrKey = array_keys($arrFields);
     $this->assertEquals($arrKey[0], "fielda1");
     $this->assertEquals($arrKey[1], "fielda2");
     $this->assertEquals($arrKey[2], "fieldb1");
     $this->assertEquals($arrKey[3], "fieldb2");
     $objFormManager->setFieldToPosition("fielda2", 1);
     $objFormManager->setFieldToPosition("fieldb2", 4);
     $arrFields = $objFormManager->getArrFields();
     $arrKey = array_keys($arrFields);
     $this->assertEquals($arrKey[0], "fielda2");
     $this->assertEquals($arrKey[1], "fielda1");
     $this->assertEquals($arrKey[2], "fieldb1");
     $this->assertEquals($arrKey[3], "fieldb2");
 }
    /**
     * @param class_module_search_search $objSearch
     *
     * @return class_admin_formgenerator
     */
    public function getSearchAdminForm($objSearch)
    {
        $objForm = new class_admin_formgenerator("search", $objSearch);
        $objForm->generateFieldsFromObject();
        // Load filterable modules
        $arrFilterModules = $objSearch->getPossibleModulesForFilter();
        $objForm->getField("formfiltermodules")->setArrKeyValues($arrFilterModules);
        $objForm->addField(new class_formentry_checkbox("search", "filter_all"))->setStrLabel($this->getLang("select_all"))->setStrValue($objSearch->getStrInternalFilterModules() == "-1" || $objSearch->getStrInternalFilterModules() == "");
        $objForm->setFieldToPosition("search_filter_all", 3);
        $bitVisible = $objSearch->getStrInternalFilterModules() != "-1" && $objSearch->getStrInternalFilterModules() != "" || $objSearch->getObjChangeEnddate() != null || $objSearch->getObjChangeStartdate() != null;
        $objForm->setStrHiddenGroupTitle($this->getLang("form_additionalheader"));
        $objForm->addFieldToHiddenGroup($objForm->getField("formfiltermodules"));
        $objForm->addFieldToHiddenGroup($objForm->getField("formfilteruser"));
        $objForm->addFieldToHiddenGroup($objForm->getField("search_filter_all"));
        $objForm->addFieldToHiddenGroup($objForm->getField("changestartdate"));
        $objForm->addFieldToHiddenGroup($objForm->getField("changeenddate"));
        $objForm->setBitHiddenElementsVisible($bitVisible);
        //add js-code for enabling and disabling multiselect box for modules
        $strCore = class_resourceloader::getInstance()->getCorePathForModule("module_search");
        $strJS = <<<JS
            KAJONA.admin.loader.loadFile('{$strCore}/module_search/admin/scripts/search.js', function() {
                    KAJONA.admin.search.switchFilterAllModules();
                    \$('#search_filter_all').click(function() {KAJONA.admin.search.switchFilterAllModules()});

                });
JS;
        $strPlain = "<script type='text/javascript'>" . $strJS . "</script>";
        $objForm->addField(new class_formentry_plaintext())->setStrValue($strPlain);
        return $objForm;
    }
 /**
  * @param interface_usersources_user $objUser
  * @param bool $bitSelfedit
  * @param string $strMode
  *
  * @return class_admin_formgenerator|class_model
  */
 protected function getUserForm(interface_usersources_user $objUser, $bitSelfedit, $strMode)
 {
     //load a few default values
     //languages
     $arrLang = array();
     foreach ($this->arrLanguages as $strLanguage) {
         $arrLang[$strLanguage] = $this->getLang("lang_" . $strLanguage);
     }
     //skins
     $arrSkinsTemp = class_adminskin_helper::getListOfAdminskinsAvailable();
     $arrSkins = array();
     foreach ($arrSkinsTemp as $strSkin) {
         $arrSkins[$strSkin] = $strSkin;
     }
     //possible start-modules
     $arrModules = array();
     foreach (class_module_system_module::getModulesInNaviAsArray() as $arrOneModule) {
         $objOneModule = class_module_system_module::getModuleByName($arrOneModule["module_name"]);
         if (!$objOneModule->rightView()) {
             continue;
         }
         $arrModules[$objOneModule->getStrName()] = $objOneModule->getAdminInstanceOfConcreteModule()->getLang("modul_titel");
     }
     $objForm = new class_admin_formgenerator("user", $objUser);
     $objForm->addField(new class_formentry_headline())->setStrValue($this->getLang("user_personaldata"));
     //globals
     $objName = $objForm->addField(new class_formentry_text("user", "username"))->setBitMandatory(true)->setStrLabel($this->getLang("user_username"))->setStrValue($this->getParam("user_username"));
     if ($bitSelfedit) {
         $objName->setBitReadonly(true);
     }
     //generic
     //adding elements is more generic right here - load all methods
     if ($objUser->isEditable()) {
         $objAnnotations = new class_reflection($objUser);
         $arrProperties = $objAnnotations->getPropertiesWithAnnotation("@fieldType");
         foreach ($arrProperties as $strProperty => $strValue) {
             $objField = $objForm->addDynamicField($strProperty);
             if ($objField->getStrEntryName() == "user_pass" && $strMode == "new") {
                 $objField->setBitMandatory(true);
             }
         }
     }
     //system-settings
     $objForm->addField(new class_formentry_headline())->setStrValue($this->getLang("user_system"));
     $strInheritPermissionsId = $this->getParam("user_inherit_permissions_id");
     if (!empty($strInheritPermissionsId)) {
         $objForm->addField(new class_formentry_hidden("user", "inherit_permissions_id"))->setStrValue($strInheritPermissionsId);
         $objInheritUser = new class_module_user_user($strInheritPermissionsId);
         $objForm->addField(new class_formentry_plaintext("inherit_hint"))->setStrValue($this->objToolkit->warningBox($this->getLang("user_copy_info", "", array($objInheritUser->getStrDisplayName())), "alert-info"));
         $objForm->setFieldToPosition("inherit_hint", 1);
     }
     $objForm->addField(new class_formentry_dropdown("user", "skin"))->setArrKeyValues($arrSkins)->setStrValue($this->getParam("user_skin") != "" ? $this->getParam("user_skin") : class_module_system_setting::getConfigValue("_admin_skin_default_"))->setStrLabel($this->getLang("user_skin"));
     $objForm->addField(new class_formentry_dropdown("user", "language"))->setArrKeyValues($arrLang)->setStrValue($this->getParam("user_language") != "" ? $this->getParam("user_language") : "")->setStrLabel($this->getLang("user_language"))->setBitMandatory(true);
     $objForm->addField(new class_formentry_dropdown("user", "startmodule"))->setArrKeyValues($arrModules)->setStrValue($this->getParam("user_startmodule") != "" ? $this->getParam("user_startmodule") : "dashboard")->setStrLabel($this->getLang("user_startmodule"));
     $objForm->addField(new class_formentry_dropdown("user", "items_per_page"))->setArrKeyValues(array(10 => 10, 15 => 15, 25 => 25, 50 => 50))->setStrValue($this->getParam("user_items_per_page") != "" ? $this->getParam("user_items_per_page") : null)->setStrLabel($this->getLang("user_items_per_page"));
     if (!$bitSelfedit) {
         $objForm->addField(new class_formentry_checkbox("user", "adminlogin"))->setStrLabel($this->getLang("user_admin"));
         $objForm->addField(new class_formentry_checkbox("user", "portal"))->setStrLabel($this->getLang("user_portal"));
         $objForm->addField(new class_formentry_checkbox("user", "active"))->setStrLabel($this->getLang("user_aktiv"));
     }
     if (count($objUser->getGroupIdsForUser()) == 0 && empty($strInheritPermissionsId)) {
         $objForm->addField(new class_formentry_plaintext("group_hint"))->setStrValue($this->objToolkit->warningBox($this->getLang("form_user_hint_groups")));
         $objForm->setFieldToPosition("group_hint", 1);
     }
     $objForm->addField(new class_formentry_hidden("", "mode"))->setStrValue($strMode);
     $objUser->updateAdminForm($objForm);
     return $objForm;
 }