コード例 #1
0
 /**
  * Returns the fitting form generator for the model. The result is cached so that the a model returns always the
  * same instance
  *
  * @param interface_model $objInstance
  * @return class_admin_formgenerator
  * @throws class_exception
  */
 public static function createByModel(interface_model $objInstance)
 {
     // check whether the form was already generated
     $objForm = self::getFormForModel($objInstance);
     if ($objForm !== null) {
         return $objForm;
     }
     // check whether a specific form generator class was specified per annotation
     $objReflection = new class_reflection($objInstance);
     $arrValues = $objReflection->getAnnotationValuesFromClass(self::STR_FORMGENERATOR_ANNOTATION);
     if (!empty($arrValues)) {
         $strClass = current($arrValues);
         if (class_exists($strClass)) {
             $objForm = new $strClass($objInstance->getArrModule("module"), $objInstance);
         } else {
             throw new class_exception("Provided form generator class does not exist", class_exception::$level_ERROR);
         }
     } else {
         $objForm = new class_admin_formgenerator($objInstance->getArrModule("module"), $objInstance);
     }
     // check whether we have an correct instance
     if ($objForm instanceof class_admin_formgenerator) {
         $objForm->generateFieldsFromObject();
         return self::$arrForms[self::getKeyByModel($objInstance)] = $objForm;
     } else {
         throw new class_exception("Provided form generator must be an instance of class_admin_formgenerator", class_exception::$level_ERROR);
     }
 }
コード例 #2
0
 /**
  * @return class_admin_formgenerator|null
  */
 public function getAdminForm()
 {
     if ($this->objAdminForm == null) {
         $objAnnotations = new class_reflection($this);
         $arrTargetTables = $objAnnotations->getAnnotationValuesFromClass(class_orm_base::STR_ANNOTATION_TARGETTABLE);
         if (count($arrTargetTables) == 0) {
             return null;
         }
         $this->objAdminForm = new class_admin_formgenerator("", $this);
         $this->objAdminForm->generateFieldsFromObject();
     }
     return $this->objAdminForm;
 }
コード例 #3
0
 /**
  * Checks if the references of the source object is correctly set after validation
  */
 public function testObjectValidator()
 {
     $objModule = class_module_system_module::getModuleByName("news");
     if ($objModule == null) {
         return;
     }
     $objNews = new class_module_news_news();
     $objForm = new class_admin_formgenerator("news", $objNews);
     $objForm->generateFieldsFromObject();
     $objSourceObjectBefore = $objForm->getObjSourceobject();
     $arrFieldsBefore = $objForm->getArrFields();
     $objForm->validateForm();
     $objSourceObjectAfter = $objForm->getObjSourceobject();
     $arrFieldsAfter = $objForm->getArrFields();
     //Now check if the reference to the source object before validation is the same as after
     foreach ($objForm->getArrFields() as $intIndex => $objField) {
         if ($arrFieldsAfter != null) {
             $this->assertTrue($arrFieldsBefore[$intIndex]->getObjSourceObject() === $arrFieldsAfter[$intIndex]->getObjSourceObject());
             if ($arrFieldsBefore[$intIndex]->getObjSourceObject() != null) {
                 $this->assertTrue($arrFieldsBefore[$intIndex]->getObjSourceObject() === $objSourceObjectBefore);
                 $this->assertTrue($arrFieldsBefore[$intIndex]->getObjSourceObject() === $objSourceObjectAfter);
             }
             if ($arrFieldsAfter[$intIndex]->getObjSourceObject() != null) {
                 $this->assertTrue($arrFieldsAfter[$intIndex]->getObjSourceObject() === $objSourceObjectBefore);
                 $this->assertTrue($arrFieldsAfter[$intIndex]->getObjSourceObject() === $objSourceObjectAfter);
             }
         }
     }
     $this->assertTrue($objSourceObjectAfter === $objSourceObjectBefore);
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     $this->getField("path")->setStrOpener(class_link::getLinkAdminDialog("mediamanager", "folderListFolderview", "&form_element=" . $this->getField("path")->getStrEntryName(), $this->getLang("commons_open_browser"), $this->getLang("commons_open_browser"), "icon_externalBrowser", $this->getLang("commons_open_browser")))->setStrHint($this->getLang("mediamanager_path_h"));
     $this->getField("uploadfilter")->setStrHint($this->getLang("mediamanager_upload_filter_h"));
     $this->getField("viewfilter")->setStrHint($this->getLang("mediamanager_view_filter_h"));
 }
コード例 #5
0
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     $objNews = $this->getObjSourceobject();
     if ($objNews->getSystemid() != class_module_system_module::getModuleByName("news")->getSystemid()) {
         //search the languages maintained
         $objLanguageManager = class_module_languages_languageset::getLanguagesetForSystemid($objNews->getSystemid());
         if ($objLanguageManager != null) {
             $arrMaintained = $objLanguageManager->getArrLanguageSet();
             $arrDD = array();
             foreach ($arrMaintained as $strLanguageId => $strSystemid) {
                 $objLanguage = new class_module_languages_language($strLanguageId);
                 $arrDD[$strSystemid] = $this->getLang("lang_" . $objLanguage->getStrName(), "languages");
             }
             class_module_languages_admin::enableLanguageSwitch();
             class_module_languages_admin::setArrLanguageSwitchEntries($arrDD);
             class_module_languages_admin::setStrOnChangeHandler("window.location='" . class_link::getLinkAdminHref("news", "editNews") . (class_module_system_setting::getConfigValue("_system_mod_rewrite_") == "true" ? "?" : "&") . "systemid='+this.value+'&pe=" . class_carrier::getInstance()->getParam("pe") . "';");
             class_module_languages_admin::setStrActiveKey($objNews->getSystemid());
         }
     }
     $arrCats = class_module_news_category::getObjectList();
     if (count($arrCats) > 0) {
         $arrKeyValues = array();
         /** @var class_module_news_category $objOneCat */
         foreach ($arrCats as $objOneCat) {
             $arrKeyValues[$objOneCat->getSystemid()] = $objOneCat->getStrDisplayName();
         }
         $this->getField("cats")->setStrLabel($this->getLang("commons_categories"))->setArrKeyValues($arrKeyValues);
     }
     if (class_module_system_setting::getConfigValue("_news_news_datetime_") == "true") {
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateStart", $objNews), "datestart")->setBitMandatory(true)->setStrLabel($this->getLang("form_news_datestart"));
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateEnd", $objNews), "dateend")->setStrLabel($this->getLang("form_news_dateend"));
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateSpecial", $objNews), "datespecial")->setStrLabel($this->getLang("form_news_datespecial"));
     }
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     if (validateSystemid($this->getField("userid")->getStrValue())) {
         $this->getField("userid")->setBitMandatory(true);
         $this->getField("forename")->setBitMandatory(false);
         $this->getField("lastname")->setBitMandatory(false);
         $this->getField("email")->setBitMandatory(false);
     }
 }
コード例 #7
0
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     /** @var class_module_news_category[] $arrNewsCats */
     $arrNewsCats = class_module_news_category::getObjectList();
     $arrCatsDD = array();
     foreach ($arrNewsCats as $objOneCat) {
         $arrCatsDD[$objOneCat->getSystemid()] = $objOneCat->getStrTitle();
     }
     $arrCatsDD["0"] = $this->getLang("commons_all_categories");
     $this->getField("cat")->setArrKeyValues($arrCatsDD);
 }
コード例 #8
0
 /**
  * @inheritdoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     //inject the categories formentries
     $arrCats = class_module_faqs_category::getObjectList();
     if (count($arrCats) > 0) {
         $arrKeyValues = array();
         /** @var class_module_faqs_category $objOneCat */
         foreach ($arrCats as $objOneCat) {
             $arrKeyValues[$objOneCat->getSystemid()] = $objOneCat->getStrDisplayName();
         }
         $this->getField("cats")->setStrLabel($this->getLang("commons_categories"))->setArrKeyValues($arrKeyValues);
     }
 }
コード例 #9
0
 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");
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     if (validateSystemid($this->getField("messagerefid")->getStrValue()) && $this->getField("body")->getStrValue() == "") {
         $objRefMessage = class_objectfactory::getInstance()->getObject($this->getField("messagerefid")->getStrValue());
         if ($objRefMessage instanceof class_module_messaging_message) {
             $arrBody = preg_split('/$\\R?^/m', $objRefMessage->getStrBody());
             array_walk($arrBody, function (&$strValue) {
                 $strValue = "> " . $strValue;
             });
             $this->getField("body")->setStrValue("\r\n\r\n\r\n" . implode("\r\n", $arrBody));
         }
     }
 }
コード例 #11
0
 /**
  * Hook to update the admin-form when editing / creating a single user
  * @param class_admin_formgenerator $objForm
  *
  * @return mixed
  */
 public function updateAdminForm(class_admin_formgenerator $objForm)
 {
     $objForm->getField("user_username")->setBitReadonly(true);
 }
コード例 #12
0
 private function getPointAdminForm(class_module_navigation_point $objPoint)
 {
     $objForm = new class_admin_formgenerator("point", $objPoint);
     $objForm->generateFieldsFromObject();
     return $objForm;
 }
コード例 #13
0
 /**
  * @return class_admin_formgenerator
  */
 private function getPackAdminForm()
 {
     $objFormgenerator = new class_admin_formgenerator("pack", new class_module_system_common());
     $objFormgenerator->addField(new class_formentry_text("pack", "name"))->setStrLabel($this->getLang("pack_name"))->setBitMandatory(true)->setStrValue($this->getParam("pack_name"));
     $objFormgenerator->addField(new class_formentry_headline())->setStrValue($this->getLang("pack_copy_include"));
     $arrModules = class_resourceloader::getInstance()->getArrModules();
     foreach ($arrModules as $strOneModule) {
         //validate if there's a template-folder existing
         if (is_dir(class_resourceloader::getInstance()->getCorePathForModule($strOneModule, true) . "/" . $strOneModule . "/templates")) {
             $objFormgenerator->addField(new class_formentry_checkbox("pack", "modules[" . $strOneModule . "]"))->setStrLabel($strOneModule)->setStrValue($strOneModule == "module_pages");
         }
     }
     return $objFormgenerator;
 }
コード例 #14
0
 /**
  * Generates a simple form to edit and create elements' basic data.
  *
  * @param class_module_pages_element $objElement
  *
  * @return class_admin_formgenerator
  */
 private function getElementForm(class_module_pages_element $objElement)
 {
     //Fetch Admin classes
     $arrClasses = class_resourceloader::getInstance()->getFolderContent("/admin/elements", array(".php"));
     $arrClassesAdmin = array();
     foreach ($arrClasses as $strClass) {
         $arrClassesAdmin[$strClass] = $strClass;
     }
     //Fetch Portal-Classes
     $arrClassesPortal = array();
     $arrClasses = class_resourceloader::getInstance()->getFolderContent("/portal/elements", array(".php"));
     foreach ($arrClasses as $strClass) {
         $arrClassesPortal[$strClass] = $strClass;
     }
     $objForm = new class_admin_formgenerator("element", $objElement);
     //redefine for proper lang-rendering
     $objElement->setArrModuleEntry("modul", "pages");
     $objForm->generateFieldsFromObject();
     $objForm->getField("cachetime")->setStrHint($this->getLang("element_cachetime_hint"));
     $objForm->getField("classadmin")->setArrKeyValues($arrClassesAdmin);
     $objForm->getField("classportal")->setArrKeyValues($arrClassesPortal);
     //check if the config-vals may be overriden
     /** @var $objAdminInstance class_element_admin */
     if ($objElement->getSystemid() != "") {
         $objAdminInstance = $objElement->getAdminElementInstance();
         if ($objAdminInstance->getConfigVal1Name() != "") {
             $objForm->addDynamicField("strConfigval1")->setStrLabel($objAdminInstance->getConfigVal1Name());
         }
         if ($objAdminInstance->getConfigVal2Name() != "") {
             $objForm->addDynamicField("strConfigval2")->setStrLabel($objAdminInstance->getConfigVal2Name());
         }
         if ($objAdminInstance->getConfigVal3Name() != "") {
             $objForm->addDynamicField("strConfigval3")->setStrLabel($objAdminInstance->getConfigVal3Name());
         }
     }
     return $objForm;
 }
コード例 #15
0
    /**
     * @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;
    }
コード例 #16
0
 /**
  * @param class_admin_formgenerator $objForm
  *
  * @return bool
  */
 protected function checkAdditionalEditData(class_admin_formgenerator $objForm)
 {
     $arrParams = class_carrier::getAllParams();
     $bitPass = true;
     if (isset($arrParams["user_pass"])) {
         $bitPass = $this->checkPasswords($this->getParam("user_pass"), $this->getParam("user_pass2"));
         if (!$bitPass) {
             $objForm->addValidationError("password", $this->getLang("required_password_equal"));
         }
     }
     $arrUsers = class_module_user_user::getAllUsersByName($this->getParam("user_username"));
     if (count($arrUsers) > 0) {
         $objUser = $arrUsers[0];
         if ($objUser->getSystemid() != $this->getSystemid()) {
             $objForm->addValidationError("user_username", $this->getLang("required_user_existing"));
             $bitPass = false;
         }
     }
     return $bitPass;
 }
コード例 #17
0
 /**
  * @param class_module_workflows_handler $objHandler
  *
  * @return class_admin_formgenerator
  */
 private function getHandlerForm(class_module_workflows_handler $objHandler)
 {
     $objForm = new class_admin_formgenerator("handler", $objHandler);
     $objForm->generateFieldsFromObject();
     $arrNames = $objHandler->getObjInstanceOfHandler()->getConfigValueNames();
     $objForm->getField("configval1")->setStrLabel(isset($arrNames[0]) ? $arrNames[0] : $this->getLang("workflow_handler_val1"));
     $objForm->getField("configval2")->setStrLabel(isset($arrNames[1]) ? $arrNames[1] : $this->getLang("workflow_handler_val2"));
     $objForm->getField("configval3")->setStrLabel(isset($arrNames[2]) ? $arrNames[2] : $this->getLang("workflow_handler_val3"));
     return $objForm;
 }
コード例 #18
0
 /**
  * @see interface_admin_systemtask::getAdminForm()
  * @return string
  */
 public function getAdminForm()
 {
     $strFormName = "permissions";
     $objForm = new class_admin_formgenerator($strFormName, new class_module_system_common());
     $arrGroups = array();
     foreach (class_module_user_group::getObjectList() as $objOneGroup) {
         $arrGroups[$objOneGroup->getSystemid()] = $objOneGroup->getStrDisplayName();
     }
     $objForm->addField(new class_formentry_plaintext())->setStrValue($this->objToolkit->warningBox($this->getLang("systemtask_permissions_hint")));
     $objForm->addField(new class_formentry_dropdown("", "groupid"))->setStrLabel($this->getLang("systemtask_permissions_groupid"))->setBitMandatory(true)->setArrKeyValues($arrGroups);
     $objForm->addField(new class_formentry_text("", "recordid"))->setStrLabel($this->getLang("systemtask_permissions_systemid"))->setBitMandatory(true);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_VIEW))->setStrLabel(class_rights::$STR_RIGHT_VIEW);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_EDIT))->setStrLabel(class_rights::$STR_RIGHT_EDIT);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_DELETE))->setStrLabel(class_rights::$STR_RIGHT_DELETE);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT))->setStrLabel(class_rights::$STR_RIGHT_RIGHT);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT1))->setStrLabel(class_rights::$STR_RIGHT_RIGHT1);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT2))->setStrLabel(class_rights::$STR_RIGHT_RIGHT2);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT3))->setStrLabel(class_rights::$STR_RIGHT_RIGHT3);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT4))->setStrLabel(class_rights::$STR_RIGHT_RIGHT4);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT5))->setStrLabel(class_rights::$STR_RIGHT_RIGHT5);
     $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_CHANGELOG))->setStrLabel(class_rights::$STR_RIGHT_CHANGELOG);
     return $objForm;
 }
 /**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     $this->addField(new class_formentry_hidden("", "source"))->setStrValue(class_carrier::getInstance()->getParam("source"));
 }
コード例 #20
0
 /**
  * Creates a form to send mails to specific users.
  *
  * @return class_admin_formgenerator
  */
 private function getMailForm()
 {
     $objFormgenerator = new class_admin_formgenerator("mail", new class_module_system_common());
     $objFormgenerator->addField(new class_formentry_text("mail", "recipient"))->setStrLabel($this->getLang("mail_recipient"))->setBitMandatory(true)->setObjValidator(new class_email_validator());
     $objFormgenerator->addField(new class_formentry_user("mail", "cc"))->setStrLabel($this->getLang("mail_cc"));
     $objFormgenerator->addField(new class_formentry_text("mail", "subject"))->setStrLabel($this->getLang("mail_subject"))->setBitMandatory(true);
     $objFormgenerator->addField(new class_formentry_textarea("mail", "body"))->setStrLabel($this->getLang("mail_body"))->setBitMandatory(true);
     return $objFormgenerator;
 }
コード例 #21
0
 /**
  * Hook to update the admin-form when editing / creating a single group
  * @param class_admin_formgenerator $objForm
  *
  * @return mixed
  */
 public function updateAdminForm(class_admin_formgenerator $objForm)
 {
     $arrDD = array();
     foreach (class_ldap::getAllInstances() as $objOneInstance) {
         $arrDD[$objOneInstance->getIntCfgNr()] = $objOneInstance->getStrCfgName();
     }
     $objForm->getField("cfg")->setArrKeyValues($arrDD);
 }
コード例 #22
0
 /**
  * Creates the admin-form object
  *
  * @param class_module_languages_language $objLanguage
  *
  * @return class_admin_formgenerator
  */
 private function getAdminForm(class_module_languages_language $objLanguage)
 {
     $objLang = new class_module_languages_language();
     $arrLanguages = $objLang->getAllLanguagesAvailable();
     $arrLanguagesDD = array();
     foreach ($arrLanguages as $strLangShort) {
         $arrLanguagesDD[$strLangShort] = $this->getLang("lang_" . $strLangShort);
     }
     $objForm = new class_admin_formgenerator("language", $objLanguage);
     $objForm->addDynamicField("strName")->setArrKeyValues($arrLanguagesDD);
     $objForm->addDynamicField("bitDefault");
     return $objForm;
 }