/** * @param mixed $key * @param string $type * * @return void */ function renderInputForm($key, $type) { global $PMF_LANG, $faqConfig; switch ($type) { case 'area': printf('<textarea name="edit[%s]" rows="4" class="form-control">%s</textarea>', $key, str_replace('<', '<', str_replace('>', '>', $faqConfig->get($key)))); printf("</div>\n"); break; case 'input': if ('' == $faqConfig->get($key) && 'socialnetworks.twitterAccessTokenKey' == $key && isset($_SESSION['access_token'])) { $value = $_SESSION['access_token']['oauth_token']; } elseif ('' == $faqConfig->get($key) && 'socialnetworks.twitterAccessTokenSecret' == $key && isset($_SESSION['access_token'])) { $value = $_SESSION['access_token']['oauth_token_secret']; } else { $value = str_replace('"', '"', $faqConfig->get($key)); } printf('<input class="form-control" type="%s" name="edit[%s]" value="%s" step="1" min="0">', is_numeric($value) ? 'number' : 'text', $key, $value); echo "</div>\n"; break; case 'select': printf('<select name="edit[%s]" size="1" class="form-control">', $key); switch ($key) { case 'main.language': $languages = PMF_Language::getAvailableLanguages(); if (count($languages) > 0) { echo PMF_Language::languageOptions(str_replace(array('language_', '.php'), '', $faqConfig->get('main.language')), false, true); } else { echo '<option value="language_en.php">English</option>'; } break; case 'records.orderby': echo PMF_Configuration::sortingOptions($faqConfig->get($key)); break; case 'records.sortby': printf('<option value="DESC"%s>%s</option>', 'DESC' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['ad_conf_desc']); printf('<option value="ASC"%s>%s</option>', 'ASC' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['ad_conf_asc']); break; case 'security.permLevel': echo PMF_Perm::permOptions($faqConfig->get($key)); break; case 'main.templateSet': $faqSystem = new PMF_System(); $templates = $faqSystem->getAvailableTemplates(); foreach ($templates as $template => $selected) { printf("<option%s>%s</option>", $selected === true ? ' selected' : '', $template); } break; case "records.attachmentsStorageType": foreach ($PMF_LANG['att_storage_type'] as $i => $item) { $selected = $faqConfig->get($key) == $i ? ' selected' : ''; printf('<option value="%d"%s>%s</option>', $i, $selected, $item); } break; case "records.orderingPopularFaqs": printf('<option value="visits"%s>%s</option>', 'visits' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['records.orderingPopularFaqs.visits']); printf('<option value="voting"%s>%s</option>', 'voting' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['records.orderingPopularFaqs.voting']); break; case "search.relevance": printf('<option value="thema,content,keywords"%s>%s</option>', 'thema,content,keywords' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.thema-content-keywords']); printf('<option value="thema,keywords,content"%s>%s</option>', 'thema,keywords,content' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.thema-keywords-content']); printf('<option value="content,thema,keywords"%s>%s</option>', 'content,thema,keywords' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.content-thema-keywords']); printf('<option value="content,keywords,thema"%s>%s</option>', 'content,keywords,thema' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.content-keywords-thema']); printf('<option value="keywords,content,thema"%s>%s</option>', 'keywords,content,thema' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.keywords-content-thema']); printf('<option value="keywords,thema,content"%s>%s</option>', 'keywords,thema,content' == $faqConfig->get($key) ? ' selected' : '', $PMF_LANG['search.relevance.keywords-thema-content']); break; } echo "</select>\n</div>\n"; break; case 'checkbox': printf('<div class="checkbox"><input type="checkbox" name="edit[%s]" value="true"', $key); if ($faqConfig->get($key)) { echo ' checked'; } if ('security.ldapSupport' === $key && !extension_loaded('ldap')) { echo ' disabled'; } if ('security.useSslOnly' === $key && empty($_SERVER['HTTPS'])) { echo ' disabled'; } if ('security.ssoSupport' === $key && empty($_SERVER['REMOTE_USER'])) { echo ' disabled'; } echo ">\n</div></div>\n"; break; case 'print': printf('<input type="text" readonly name="edit[%s]" class="form-control" value="%s"></div>', $key, str_replace('"', '"', $faqConfig->get($key)), $faqConfig->get($key)); break; } }