本文整理汇总了PHP中form::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP form::factory方法的具体用法?PHP form::factory怎么用?PHP form::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类form
的用法示例。
在下文中一共展示了form::factory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formBlock
public static function formBlock($module)
{
$form = form::factory('module', 'id=' . $module->getModulId(), 'index.php');
$form->setSave(false);
$form->addFormAttribute('class', '');
$form->setSuccessMessage(null);
$input = $module->OutputFilter($form->get('input'), $module->getSql());
$form->addRawField($input);
$form->addHiddenField('structure_id', $module->getStructureId());
if ($module->getId()) {
$form->setMode('edit');
$online = $module->get('online');
} else {
$form->setMode('add');
$online = 1;
$form->delButton('save-back');
}
$form->addHiddenField('modul', $module->getModulId());
$form->addHiddenField('sort', $module->getSort());
$field = $form->addRadioField('online', $online);
$field->fieldName(lang::get('block_status'));
$field->add(1, lang::get('online'));
$field->add(0, lang::get('offline'));
$form->addHiddenField('id', $module->getId());
$form->addParam('structure_id', type::super('structure_id', 'int'));
return $form;
}
示例2:
if ($action == 'delete') {
if (dyn::get('user')->get('id') == $id) {
echo message::danger(lang::get('user_self_deleted'));
} else {
$sql = sql::factory();
$sql->setTable('user');
$sql->setWhere('id=' . $id);
$sql->delete();
echo message::success(lang::get('user_deleted'));
}
$action = '';
}
if ($action == 'add' || $action == 'edit') {
layout::addJsCode("\n\tvar page_admin_button = \$('#pageadmin-button');\n\tvar page_admin_content = \$('#pageadmin-content');\n\t\n\tpage_admin_button.change(function() {\n\t\t\tif(page_admin_button.is(':checked')) {\n\t\t\t\tpage_admin_content.stop().slideUp(300);\n\t\t\t} else {\n\t\t\t\tpage_admin_content.stop().slideDown(300);\n\t\t\t}\n\t});");
$form = form::factory('user', 'id=' . $id, 'index.php');
$field = $form->addTextField('firstname', $form->get('firstname'));
$field->fieldName(lang::get('firstname'));
$field->autofocus();
$field = $form->addTextField('name', $form->get('name'));
$field->fieldName(lang::get('name'));
$field = $form->addTextField('email', $form->get('email'));
$field->fieldName(lang::get('email_adress'));
$field->addValidator('notEmpty', lang::get('user_email_empty'));
$field->addValidator('email', lang::get('user_wrong_email'));
if ($form->get('password') != $form->sql->getValue('password')) {
$password = userLogin::hash($form->get('password'), $form->get('salt'));
} else {
$password = $form->sql->getValue('password');
}
$field = $form->addTextField('password', $password);
示例3: json_decode
</div>
</div>
</div>
</div>
<?php
//Wenn action
} else {
if (ajax::is() && dyn::get('user')->hasPerm('page[edit]')) {
$post = type::super('array');
$sort = json_decode($post, true);
pageMisc::sortStructure($sort, 0);
echo message::success(lang::get('save_sorting'), true);
}
if (in_array($action, ['edit', 'add']) && dyn::get('user')->hasPerm('page[edit]')) {
$form = form::factory('structure', 'id=' . $id, 'index.php');
$field = $form->addTextField('name', $form->get('name'));
$field->fieldName(lang::get('name'));
$field->autofocus();
$template = template::factory(dyn::get('template'));
$field = $form->addElement('template', $template->getTemplates('template', $form->get('template')));
$field->fieldName(lang::get('template'));
$field = $form->addRadioField('online', $form->get('online'));
$field->fieldName(lang::get('status'));
$field->add(1, lang::get('online'));
$field->add(0, lang::get('offline'));
if ($action == 'edit') {
$form->addHiddenField('id', $id);
}
extension::add('FORM_AFTER_SAVE', function ($sql) use($action, $id) {
if ($action == 'add') {
示例4:
?>
</h3>
</div>
<div class="panel-body">
<?php
echo $table->show();
?>
</div>
</div>
</div>
</div>
<?php
}
if ($action == 'add' || $action == 'edit') {
$form = form::factory('module', 'id=' . $id, 'index.php');
$field = $form->addTextField('name', $form->get('name'));
$field->fieldName(lang::get('name'));
$field->autofocus();
$field = $form->addTextareaField('input', $form->get('input'));
$field->fieldName(lang::get('input'));
$field = $form->addTextareaField('output', $form->get('output'));
$field->fieldName(lang::get('output'));
$field = $form->addCheckboxField('blocks', $form->get('blocks'));
$field->fieldName(lang::get('only_blocks'));
$field->add(1, '');
if ($action == 'edit') {
$form->addHiddenField('id', $id);
$button = '<a class="btn btn-sm btn-warning" href="' . url::backend('structure', ['subpage' => 'module', 'action' => 'export', 'id' => $id]) . '">' . lang::get('export') . '</a>';
$title = '"' . $form->get('name') . '" ' . lang::get('edit');
} else {
示例5: substr
echo lang::get('delete_cache');
?>
</a>
<a href="<?php
echo url::backend('settings', ['subpage' => 'main', 'action' => 'loadTemplate']);
?>
" class="btn btn-sm btn-default"><?php
echo lang::get('load_template');
?>
</a>
</div>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<?php
$form = form::factory('user', 'id=1', 'index.php');
$form->setSave(false);
$form->addFormAttribute('class', '');
$form->delButton('save');
$form->delButton('back');
$form->addParam('subpage', backend::$getVars[1]);
if ($form->isSubmit()) {
if (substr($form->get('hp_url'), 0, 5) == 'https') {
$url = 'https://' . str_replace(['http://', 'https://'], '', $form->get('hp_url'));
} else {
$url = 'http://' . str_replace(['http://', 'https://'], '', $form->get('hp_url'));
}
$endSlash = substr($url, -1, 1);
if ($endSlash != '/') {
$url .= '/';
}
示例6: addon
<?php
$config = new addon('seo');
$form = form::factory('user', 'id=' . dyn::get('user')->get('id'), 'index.php');
$form->setSave(false);
$form->delButton('save-back');
$field = $form->addSelectField('ending', $form->get('ending', $config->get('ending')));
$field->fieldName(lang::get('ending'));
$field->add('/', '/');
$field->add('.html', '.html');
$field = $form->addSelectField('start_url', $form->get('start_url', $config->get('start_url')));
$field->fieldName(lang::get('start_page'));
$field->add('0', dyn::get('hp_url'));
$field->add('1', dyn::get('hp_url') . seo_rewrite::rewriteId(dyn::get('start_page')));
$field = $form->addCheckboxField('robots', $form->get('robots', $config->get('robots')));
$field->fieldName(lang::get('seo_site_indexing'));
$field->add('1', '');
if ($form->isSubmit()) {
$config->add('ending', $form->get('ending'), true);
$config->add('start_url', $form->get('start_url'), true);
$config->add('robots', $form->get('robots'), true);
if (!$config->saveConfig()) {
$this->setErrorMessage(lang::get('seo_not_saved'));
}
addonConfig::loadAllConfig();
seo_rewrite::generatePathlist();
}
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php
示例7: BackendFormular
protected static function BackendFormular($name, $tablename, $action, $id)
{
$prefix = substr($name, 0, 3) . '_';
$form = form::factory('metainfos', 'id=' . $id, 'index.php');
$field = $form->addRawField($prefix);
$field->fieldName(lang::get('prefix'));
$field = $form->addTextField('label', $form->get('label'));
$field->fieldName(lang::get('description'));
$field->autofocus();
$field = $form->addTextField('name', $form->get('name'));
$field->fieldName(lang::get('name'));
$field = $form->addSelectField('formtype', $form->get('formtype'));
$field->fieldName(lang::get('field_type'));
$field->addAttribute('id', 'formtype');
foreach (self::$types as $type) {
$field->add($type, $type);
}
$field = $form->addTextField('default', $form->get('default'));
$field->fieldName(lang::get('default_value'));
$field->setSuffix('<small>' . lang::get('meta_pre_selection') . '</small>');
$style = in_array($form->get('formtype'), ['select', 'radio', 'checkbox']) ? 'block' : 'none';
$field = $form->addTextareaField('params', $form->get('params'));
$field->fieldName(lang::get('meta_parameter'));
$field->setPrefix('<div id="param_info" style="display:' . $style . '">');
$field->setSuffix(lang::get('examples') . ':<br />a) all|user|admin<br />b) 1:all|2:user|3:admin</div>');
$field = $form->addTextareaField('attributes', $form->get('attributes'));
$field->fieldName('HTML-Attribute');
$field->setSuffix('<small>' . lang::get('examples') . ':<br /> style=color:red<br />multiple=multiple<br />class=my_css_class</small>');
$form->addHiddenField('type', $name);
if ($action == 'edit') {
$form->addHiddenField('id', $id);
}
if ($form->isSubmit()) {
switch ($form->get('formtype')) {
case 'textarea':
$type = 'text';
break;
default:
$type = 'VARCHAR(255)';
break;
}
$colum = sql::showColums($tablename, $prefix . $form->get('name'), false);
$colum->result();
$isRight = function () use($action, $colum, $form, $prefix) {
if ($action == 'add' && $colum->num()) {
return false;
}
if ($action == 'edit' && $form->sql->getValue('name') != $form->get('name')) {
$sql = sql::factory();
return (bool) (!$sql->num('SELECT id FROM ' . sql::table('metainfos') . ' WHERE `name` = "' . $form->get('name') . '" AND `type` = "' . $form->get('type') . '"'));
}
return true;
};
if ($isRight()) {
$sql = sql::factory();
if ($action == 'add') {
$sql->query('ALTER TABLE ' . $tablename . ' ADD `' . $prefix . $form->get('name') . '` ' . $type . ' DEFAULT "' . $form->get('default') . '" ');
} else {
$sql->query('ALTER TABLE ' . $tablename . ' CHANGE `' . $prefix . $form->sql->getValue('name') . '` `' . $prefix . $form->get('name') . '` ' . $type . ' DEFAULT "' . $form->get('default') . '" ');
}
} else {
$form->setErrorMessage(sprintf(lang::get('col_name_exists'), $prefix . $form->get('name')));
$form->setSave(false);
}
}
?>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php
echo lang::get('metainfo_edit');
?>
</h3>
</div>
<div class="panel-body">
<?php
echo $form->show();
?>
</div>
</div>
</div>
</div>
<?php
self::jsSelect();
}
示例8: generateForm
public static function generateForm($id)
{
$form = form::factory('structure', 'id=' . $id, 'index.php');
$form->addParam('action', 'seo');
$form->setMode('edit');
if ($form->get('seo_title')) {
$title = $form->get('seo_title');
} else {
$title = $form->get('name');
}
$field = $form->addTextField('seo_title', $form->get('seo_title'));
$field->fieldName(lang::get('title'));
$field->setId('seo-title-text');
$field->setSuffix('<p class="help-block"><span id="seo-title">' . $title . '</span> | ' . dyn::get('hp_name') . '</p>');
$field = $form->addTextareaField('seo_keywords', $form->get('seo_keywords'));
$field->fieldName(lang::get('seo_keywords'));
$field->addRows(2);
$field = $form->addTextareaField('seo_description', $form->get('seo_description'));
$field->fieldName(lang::get('description'));
$field->addRows(2);
$field = $form->addCheckboxField('seo_robots', $form->get('seo_robots', 1));
$field->fieldName(lang::get('seo_index'));
$field->add(1, '');
if ($form->get('seo_costum_url')) {
$url = $form->get('seo_costum_url');
} else {
$url = seo_rewrite::makeSEOName($form->get('name'));
}
$field = $form->addTextField('seo_costum_url', $form->get('seo_costum_url'));
$field->fieldName(lang::get('seo_self_url'));
$field->setId('seo-costum-url-text');
$field->setSuffix('<p class="help-block">' . dyn::get('hp_url') . '<span id="seo-costum-url">' . $url . '</span></p>');
$form->addHiddenField('id', $id);
if ($form->isSubmit()) {
$costum_url = $form->get('seo_costum_url');
$costum_url = str_replace(dyn::get('hp_url'), '', $costum_url);
$costum_url = str_replace('.html', '', $costum_url);
$costum_url = trim($costum_url, '/');
$costum_url = seo_rewrite::makeSEOName($costum_url);
if ($costum_url && $costum_url != '.html') {
$form->addPost('seo_costum_url', $costum_url);
} else {
$form->addPost('seo_costum_url', '');
}
}
?>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title pull-left" id="seo-default-title"><?php
echo $form->get('name');
?>
</h3>
<span class="pull-right">
<a href="<?php
echo url::backend('structure', ['subpage' => 'pages', 'action' => 'edit', 'id' => $id]);
?>
" class="btn btn-sm btn-warning"><?php
echo lang::get('edit');
?>
</a>
<a href="<?php
echo url::backend('structure', ['subpage' => 'pages', 'structure_id' => $id]);
?>
" class="btn btn-sm btn-default"><?php
echo lang::get('back');
?>
</a>
</span>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<?php
echo $form->show();
?>
</div>
</div>
</div>
</div>
<?php
}
示例9: while
<?php
if ($action == 'delete') {
$sql = sql::factory();
$sql->setTable('community_user');
$sql->setWhere('id=' . $id);
$sql->delete();
}
if ($action == 'edit' || $action == 'add') {
$form = form::factory('community_user', 'id=' . $id, 'index.php');
$field = $form->addTextField('username', $form->get('username'));
$field->fieldName('Username');
$field = $form->addTextField('email', $form->get('email'));
$field->fieldName('E-Mail');
if (addonConfig::isActive('medienmanager')) {
$field = $form->addTextField('avatar', $form->get('avatar'));
$field->fieldName('Profilbild');
}
$field = $form->addCheckboxField('admin', $form->get('admin'));
$field->add(1, 'Admin');
$form->show();
}
if ($action == '') {
$table = table::factory();
$table->setSql('SELECT * FROM ' . sql::table('community_user'));
$table->addRow()->addCell('Id')->addCell(lang::get('username'))->addCell(lang::get('action'));
while ($table->isNext()) {
$edit = '<a href="' . url::backend('community', ['subpage' => 'user', 'action' => 'edit', 'id' => $table->get('id')]) . '" class="btn btn-sm btn-default fa fa-pencil-square-o></a>';
$delete = '<a href="' . url::backend('community', ['subpage' => 'user', 'action' => 'delete', 'id' => $table->get('id')]) . '" class="btn btn-sm btn-danger fa fa-trash-o"></a>';
$table->addRow()->addCell($table->get('id'))->addCell($table->get('username'))->addCell('<span class="btn-group">' . $edit . $delete . '</span>');
$table->next();
示例10: foreach
$catId = type::super('catId', 'int', 0);
$subaction = type::super('subaction', 'string');
if ($action == 'delete' && dyn::get('user')->hasPerm('media[delete]')) {
echo mediaUtils::deleteFile($id);
$action = '';
}
if ($action == 'deleteFiles') {
$files = type::post('file', '', []);
foreach ($files as $id) {
echo mediaUtils::deleteFile($id);
}
$action = '';
}
if (in_array($action, ['add', 'edit']) && dyn::get('user')->hasPerm('media[edit]')) {
$form = form::factory('media', 'id=' . $id, 'index.php');
$form->addFormAttribute('enctype', 'multipart/form-data');
$field = $form->addTextField('title', $form->get('title'));
$field->fieldName(lang::get('title'));
$field->autofocus();
$category = type::session('media_cat', 'int', $form->get('category'));
$field = $form->addRawField('<select class="form-control" name="category">' . mediaUtils::getTreeStructure(0, 0, ' ', $category) . '</select>');
$field->fieldName(lang::get('category'));
$field = $form->addRawField('<input type="file" name="file" />');
$field->fieldName(lang::get('select_file'));
if ($action == 'edit') {
$form->addHiddenField('id', $id);
}
if ($form->isSubmit()) {
type::addSession('media_cat', $form->get('category'));
$file = type::files('file');
示例11:
</div>
</div>
<?php
}
} else {
if ($action == 'delete' && dyn::get('user')->hasPerm('page[delete]')) {
$sql = sql::factory();
$sql->setTable('slots');
$sql->setWhere('id=' . $id);
$sql->delete();
echo message::success(lang::get('slot_deleted'), true);
$action = '';
}
if ($action == 'add' || $action == 'edit' && dyn::get('user')->hasPerm('page[edit]')) {
layout::addJsCode("\n\tvar button = \$('#allcat-button');\n\tvar content = \$('#allcat-content');\n\t\n\tbutton.change(function() {\n\t\t\tif(button.is(':checked')) {\n\t\t\t\tcontent.stop().slideUp(300);\n\t\t\t} else {\n\t\t\t\tcontent.stop().slideDown(300);\n\t\t\t}\n\t});");
$form = form::factory('slots', 'id=' . $id, 'index.php');
$field = $form->addTextField('name', $form->get('name'));
$field->fieldName(lang::get('name'));
$field->autofocus();
$field = $form->addTextField('description', $form->get('description'));
$field->fieldName(lang::get('description'));
$field = $form->addRawField('<select name="modul" class="form-control">' . pageAreaHtml::moduleList($form->get('modul')) . '</select>');
$field->fieldName(lang::get('module'));
$field = $form->addCheckboxField('is-structure', $form->get('is-structure'));
$field->fieldName(lang::get('slots_show'));
$field->add('1', lang::get('all_categories'), ['id' => 'allcat-button']);
$select = pageMisc::getTreeStructure(true, $form->get('structure'));
if ($form->get('is-structure') == 1) {
$select->addAttribute('style', 'display:none;');
}
$select->setMultiple();
示例12:
} else {
if ($action == 'delete' && dyn::get('user')->hasPerm('page[delete]')) {
$delete = sql::factory();
$delete->setTable('blocks');
$delete->setWhere('id=' . $id);
$delete->delete();
$content = sql::factory();
$content->setTable('structure_area');
$content->setWhere('block = 1 AND structure_id=' . $id);
$content->delete();
echo message::success(lang::get('block_deleted'));
$action = '';
}
if ($action == 'add' || $action == 'edit' && dyn::get('user')->hasPerm('page[edit]')) {
layout::addJsCode("\n\t\tvar button = \$('#allcat-button');\n\t\tvar content = \$('#allcat-content');\n\t\t\n\t\tbutton.change(function() {\n\t\t\t\tif(button.is(':checked')) {\n\t\t\t\t\tcontent.stop().slideUp(300);\n\t\t\t\t} else {\n\t\t\t\t\tcontent.stop().slideDown(300);\n\t\t\t\t}\n\t\t});");
$form = form::factory('blocks', 'id=' . $id, 'index.php');
$field = $form->addTextField('name', $form->get('name'));
$field->fieldName(lang::get('name'));
$field->autofocus();
$field = $form->addTextField('description', $form->get('description'));
$field->fieldName(lang::get('description'));
$field = $form->addCheckboxField('is-structure', $form->get('is-structure'));
$field->fieldName(lang::get('blocks_show'));
$field->add('1', lang::get('all_pages'), ['id' => 'allcat-button']);
$select = pageMisc::getTreeStructure(true, $form->get('structure'));
if ($form->get('is-structure') == 1) {
$select->addAttribute('style', 'display:none;');
}
$select->setMultiple();
$select->setSize(10);
$select->setId('allcat-content');