function general_action() { $this->pageTitle = 'Ustawienia ogólne'; $form = new Form('wmelon.options.general', 'options/general_save', 'options/general'); // input values $config = Watermelon::$config; $siteName = $config->siteName; $footer = $config->footer; $head = $config->headTags; $tail = $config->tailTags; $userData = Users::userData(); $login = $userData->login; $nick = $userData->nick; $email = $userData->email; $sblamKey = Config::get('wmelon.sblam.apiKey'); // label notes $footer_label = 'Możesz używać HTML<br>oraz <em>$/</em> dla linków na stronie'; $head_label = '"sekcja <head>"; skrypty, arkusze stylów itp.'; $tail_label = 'Skrypty, dodane na końcu strony'; $login_label = 'Nazwa użyta podczas logowania. Uważaj, żeby przypadkiem nie zmienić.'; $nick_label = 'Nazwa pokazywana przy Twoich komentarzach itp.'; $email_label = 'Zostanie użyty obok Twoich komentarzy do pokazania <a href="http://gravatar.com/" target="_blank">gravatara</a>'; if (!empty($email)) { $email_label .= '<br>Podgląd: '; $email_label .= '<img src="http://gravatar.com/avatar/' . md5($email) . '?s=64&d=mm" style="vertical-align:middle" />'; } $sblamKey_label = ''; // input args $siteName = array('value' => $siteName); $footer = array('value' => $footer, 'labelNote' => $footer_label); $head = array('value' => $head, 'labelNote' => $head_label); $tail = array('value' => $tail, 'labelNote' => $tail_label); $login = array('value' => $login, 'labelNote' => $login_label); $nick = array('value' => $nick, 'labelNote' => $nick_label); $email = array('value' => $email, 'labelNote' => $email_label); $sblamKey = array('value' => $sblamKey, 'labelNote' => $sblamKey_label); // adding inputs $form->addHTML('<fieldset id="siteOptions"><legend>Strona</legend>'); $form->addInput('text', 'siteName', 'Nazwa strony', true, $siteName); $form->addInput('textarea', 'footer', 'Stopka', false, $footer); $form->addInput('textarea', 'head', 'Własne tagi na początek strony', false, $head); $form->addInput('textarea', 'tail', 'Własne tagi na koniec strony', false, $tail); $form->addHTML('</fieldset>'); $form->addHTML('<fieldset id="adminOptions"><legend>Ty</legend>'); $form->addInput('text', 'login', 'Twój login', true, $login); $form->addInput('text', 'nick', 'Twój nick', false, $nick); $form->addInput('password', 'pass', 'Twoje hasło', false); $form->addInput('password', 'pass2', 'Twoje hasło (powtórz)', false); $form->addHTML('</fieldset>'); $form->addHTML('<fieldset id="sblamOptions"><legend>Sblam!</legend>'); $form->addHTML('<p>Sblam! to filtr antyspamowy użyty w Watermelonie. Aby działał poprawnie należy ustalić dla niego <em>klucz API</em>. Własny klucz możesz <a href="http://sblam.com/key.html">wygenerować na stronie Sblam!</a></p>'); $form->addInput('text', 'sblamKey', 'Klucz API', false, $sblamKey); $form->addHTML('</fieldset>'); // rendering echo $form->generate(); }
function login_action($backPage = '') { $this->pageTitle = 'Logowanie'; $form = new Form('wmelon.users.login', 'users/loginSubmit', 'users/login'); $form->submitLabel = 'Zaloguj'; $form->addInput('text', 'login', 'Login'); $form->addInput('password', 'pass', 'Hasło'); $form->addInput('hidden', 'backPage', $backPage); echo $form->generate(); }
protected function build(PageBody &$body, SubMenu &$submenu) { $submenu->addLink("Sign in", "#", TRUE); $submenu->addLink("Sign up", "#"); $submenu->addLink("Forget Password", "#"); $loginForm = new Form("login"); $loginForm->addInput(Input::textInput("email", "Enter your Email:")); $loginForm->addInput(Input::textInput("password", "Enter your Password:")); $body->addToCenter($loginForm); }
protected function build(PageBody &$body, SubMenu &$submenu) { //var_dump($_SESSION['db']); $subPage = isset($_GET['subpage']) ? $_GET['subpage'] : ''; if (isset($_GET['event'])) { $this->event = Database::getRow('Event', $_GET['event']); $this->event->id = $_GET['event']; // for testing $this->pageName = $this->event->name; //var_dump($this->event); } if ($this->event == null) { $body->addToTop(new Message("No Event", Message::DANGER)); } $submenu->addLink("Event Details", "?page=Event&event=" . $this->event->id, $subPage == ''); $submenu->addLink("Update Event", "?page=Event&event=" . $this->event->id . "&subpage=update", $subPage == 'update'); $submenu->addSplitter(); $submenu->addLink("Send Email Invitation", "?page=Event&event=" . $this->event->id . "&subpage=send", $subPage == 'send'); $submenu->addLink("Add VIP Participant", "#"); $submenu->addSplitter(); $submenu->addLink("Show All Participants", "#", false, false, 100); $submenu->addLink("Show Missing Participants", "#", false, false, 90); $submenu->addLink("Show Event Attendances", "#", false, false, 10); $submenu->addSplitter(); $submenu->addLink("Build Schedule", "#"); $submenu->addLink("Send Schedule", "#"); $submenu->addLink("Start Timer", "#"); $submenu->addSplitter(); $submenu->addDangerLink("Delete Event", "#"); $body->addToTop(new CustomHTML("\n <div class='page-header'>\n <h1> " . $this->event->name . " <small>" . $this->event->address . "</small></h1>\n </div>\n ")); if ($subPage == '') { $body->addToCenter(new CustomHTML("\n <dl class='dl-horizontal' style='font-size:18px'>\n <dt>Name</dt>\n <dd>" . $this->event->name . "</dd>\n <dt>Address</dt>\n <dd>" . $this->event->address . "</dd>\n </dl>\n ")); } else { if ($subPage == 'update') { $form = new Form("Event"); $form->addInput(Input::textInput("eventName", "Event Name", $this->event->name)); $form->addInput(Input::textareaInput("eventAddress", "Event Address", $this->event->address)); $body->addToCenter($form); } else { if ($subPage == 'send') { $form = new Form("Event"); $form->addInput(Input::tokenInput("emails", "Send To:")); $form->addInput(Input::textInput("subject", "Subject", "Invitation to " . $this->event->name)); $form->addInput(Input::textareaInput("message", "Message")); $body->addToCenter($form); } } } // $table = new HtmlTable(); // $table->addRow(["Name", $this->event->name]); // $table->addRow(["Address", $this->event->address]); // // $body->addToCenter($table); }
public function testToHTML() { $args = array('action' => 'http://google.com', 'method' => 'GET', 'id' => 'my_id', 'name' => 'some_name', 'class' => array('form-class')); $form = new Form("default", $args); $input_args = array('field_type' => 'meta_key', 'format' => 'checkbox', 'values' => array('one', 'two')); $input = new Input("myinput", $input_args); $form->addInput($input); $input_args = array('field_type' => 'search', 'format' => 'text', 'placeholder' => 'Enter keywords...'); $input = new Input("myinput", $input_args); $form->addInput($input); $this->assertTrue(is_string($form->toHTML())); }
public static function display() { $messages = ""; if ($_POST['cc_form'] === 'add-group') { $group = $_POST['group']; $rows = Database::select('users', 'name', array('name = ? AND type = ?', $group, 'group'), null, 1)->fetch(PDO::FETCH_ASSOC); if (!empty($rows)) { $messages .= Message::error(__('admin', 'group-in-use')); } else { $row = DB::select('users', array('data'), array('users_id = ?', $_GET['parent']))->fetch(PDO::FETCH_ASSOC); $inheritance = unserialize($row['data']); $inheritance = $inheritance['permissions']; $result = Database::insert('users', array('name' => filter('admin_add_group_name', $group), 'type' => 'group', 'group' => '-1', 'data' => serialize(filter('admin_add_group_data', array('permissions' => $inheritance))))); if ($result === 1) { $messages .= Message::success(__('admin', 'group-added')); } } } $form = new Form('self', 'post', 'add-group'); $form->startFieldset(__("admin", 'group-information')); $form->addInput(__('admin', 'group-name'), 'text', 'group', self::get('group')); $groups = Users::allGroups(); foreach ($groups as $key => $value) { $groups[$value->getId()] = $value->getName(); } $form->addSelectList(__('admin', 'inherit-permissions'), 'parent', $groups); plugin('admin_add_group_custom_fields', array(&$form)); $form->addSubmit('', 'add-group', __('admin', 'add-group')); $form->endFieldset(); plugin('admin_add_group_custom_fieldset', array(&$form)); $form = $form->endAndGetHTML(); return array(__('admin', 'add-group'), $messages . $form); }
protected function build(PageBody &$body, SubMenu &$submenu) { $form = new Form("Test"); //$form->addInput("list1", "list", "Exsample List:", ["1", "2", "3"]); $form->addInput(Input::textInput("input1", "Enter your name: ")); $form->addInput(Input::selectInput("list1", "Example List:", ["A", "B", "C"])); //$form->addInput(Input::dateInput("date", "choose a date: ")); $left = new CustomHTML(' <div class="list-group"> <a href="#" class="list-group-item active">Home</a> <a href="#" class="list-group-item">Profile</a> <a href="#" class="list-group-item">Messages</a> </div>'); $submenu->addLink("Home", "?page=home"); $submenu->addLink("Login", "?page=login"); $submenu->addLink("Top", "#top"); $submenu->addLink("Down", "#down"); $right = new CustomHTML(' <div class="panel panel-default"> <div class="panel-heading">Panel heading without title</div> <div class="panel-body"> Panel content </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Panel title</h3> </div> <div class="panel-body"> Panel content </div> </div>'); $body->addToLeft($left); $body->addToRight($right); $body->addToCenter($form); $body->addToTop(new Message("This is a test page", Message::INFO)); if (isset($_POST['list1'])) { $body->addToTop(new Message("the value of list1=" . $_POST['list1'], Message::SUCCESS)); } }
public static function display() { $messages = ""; if ($_POST['cc_form'] === 'add-user') { $username = $_POST['username']; $password = $_POST['password']; $cpassword = $_POST['confirm-password']; $group = $_POST['group']; if ($password != $cpassword) { $messages .= Message::error(__('admin', 'passwords-dont-match')); } else { $rows = Database::select('users', 'name', array('name = ? AND type = ?', $username, 'user'), null, 1)->fetch(PDO::FETCH_ASSOC); if (!empty($rows)) { $messages .= Message::error(__('admin', 'username-in-use')); } else { $hash = hash('whirlpool', $password); $result = Database::insert('users', array('name' => filter('admin_add_user_username', $username), 'value' => $hash, 'type' => 'user', 'group' => filter('admin_add_group', $group), 'data' => serialize(filter('admin_add_user_data', array())))); if ($result === 1) { $messages .= Message::success(__('admin', 'user-added')); } } } } $form = new Form('self', 'post', 'add-user'); $groups = Users::allGroups(); foreach ($groups as $key => $value) { $groups[$value->getId()] = $value->getName(); } $form->startFieldset(__("admin", 'user-information')); $form->addInput(__('admin', 'username'), 'text', 'username', self::get('username')); $form->addInput(__('admin', 'password'), 'password', 'password'); $form->addInput(__('admin', 'confirm-password'), 'password', 'confirm-password'); $form->addSelectList(__('admin', 'group'), 'group', $groups, true, self::get('group')); plugin('admin_add_user_custom_fields', array(&$form)); $form->addSubmit('', 'add-user', __('admin', 'add-user')); $form->endFieldset(); plugin('admin_add_user_custom_fieldset', array(&$form)); $form = $form->endAndGetHTML(); return array(__('admin', 'add-user'), $messages . $form); }
/** * Constructor * * @param Form $form The form this fieldset is asssociated to * @param string $name The fieldset name * @param array $inputs The inputs in this fieldset * @param array $params The parameters to apply to this fieldset */ public function __construct($form, $name, $inputs = array(), $params = array()) { $this->name = $name; $this->form = $form; $this->id = $form->id . '-' . $this->name . '-fieldset'; $this->map($params); if ($this->legend) { $this->legendId = $form->id . '-' . $this->name . '-legend'; } foreach ($inputs as &$input) { $form->addInput($input, $this->name); $this->inputs[$input->name] = $input; } }
protected function build(PageBody &$body, SubMenu &$submenu) { $this->pageName = "New Event"; $form = new Form("Event"); $form->addInput(Input::textInput("eventName", "Event Name")); $form->addInput(Input::textareaInput("eventAddress", "Address")); $form->addInput(Input::createGroupInput([Input::dateInput("eventDay", "Day"), Input::timeInput("eventTime", "time")])); $form->addInput(Input::createGroupInput([Input::dateInput("eventDeadline", "Registration Deadline"), Input::timeInput("eventDeadlineTime", "Registration Deadline Time")])); $form->addInput(Input::textInput("eventFee", "Registration Fee")); $form->addInput(Input::textInput("eventStuFee", "Student Fee")); $form->addInput(Input::tokenInput("organizations", "Organizations")); $body->addToCenter($form); }
public static function display() { if (!is_numeric($_GET['id'])) { cc_redirect(Admin::link('users')); } if ($_POST['cc_form'] == 'edit-group') { $id = $_GET['id']; $previous = (array) unserialize(urldecode($_POST['previous'])); $group = $_POST['group']; $permissions = (array) $_POST['permissions']; $new = array_merge($previous, $permissions); foreach ($new as $k => $v) { if ($v == "1") { $new[$k] = true; } if (!array_key_exists($k, $permissions)) { $new[$k] = false; } } if (DB::update('users', array('name', 'data'), array($group, serialize(filter('admin_edit_group_data', array('permissions' => $new)))), array('users_id = ?', $id))) { $message = Message::success(__('admin', 'group-information-updated')); } else { $message = Message::error(__('admin', 'database-error')); } } $p = Permissions::getAll(); $g = new Group((int) $_GET['id']); $p_form = new Form(''); $p_form->setCC_Form('edit-group'); $p_form->startFieldset(__('admin', 'group-information')); $p_form->addInput(__('admin', 'group-name'), 'text', 'group', $g->getName()); $p_form->endFieldset(); $p_form->addHTML(sprintf("<h3>%s</h3>", __('admin', 'permissions'))); $p_table = new Table('permissions'); $p_table->addHeader(array('Name', 'Allowed')); foreach ($p as $k => $v) { $previous[$v['name']] = $g->isAllowed($v['name']); $p_table->addRow(array(__('permissions', $v['name']), sprintf('<input type="checkbox" name="permissions[%s]"%svalue="1"/>', $v['name'], $g->isAllowed($v['name']) ? ' checked="checked"' : ''))); } $p_form->addHidden('previous', urlencode(serialize($previous))); $p_form->addHTML($p_table->html()); $p_form->addSubmit('', 'save-permissions', __('admin', 'save-changes')); return array(sprintf('%s: %s', __('admin', 'edit-group'), $g->getName()), $message . $p_form->html()); }
//set up some content for the token: $token_str = ''; //list items in cart foreach ($cart as $product) { $content .= '<div class="cart-item">'; $content .= $product->product_name; $content .= ' $' . $product->price; $pid = $product->id; $quantity = $cart->getProductQuantity($product->id); $content .= ' x ' . $quantity . '= $' . $product->price * $quantity; $content .= " | <a href='profile.php?type=product&id={$pid}'>view</a> | "; $content .= "<a href='cart-remove.php?pid={$pid}'>remove</a>"; $content .= '</div>'; //add to token string $token_str .= $product->price; } //show total price $content .= '<p class="total">TOTAL: '; $content .= $cart->getFormattedTotal(); $form = new Form(); $form->setAction('checkout.php'); $token = md5(time() . $token_str . $customer_id); //also add a salt? from file or db $_SESSION['form_token'] = $token; $form->addInput('token', '', $token, 'hidden'); $form->addInput('submit', null, 'Check out', 'submit'); $content .= $form->render(); $content .= '<p class="back"><a href="index.php">Back to shopping</a></p>'; //} } require_once 'template.php';
$error_msg = ''; $content = ''; if (isset($_POST['submit'])) { if ($_POST['password'] == $_POST['password_confirm']) { $customer = new Customer(); $success = $customer->newAccount(strip_tags($_POST['email']), strip_tags($_POST['first_name']), strip_tags($_POST['last_name']), strip_tags($_POST['password'])); if ($success) { $content .= 'New account created. <a href="login.php">Login</a>'; //TODO: email confirmation } else { if ($customer->error_msg) { $error_msg = strip_tags($customer->error_msg); } else { $error_msg = 'Error creating new account.'; } } } else { $error_msg = 'Passwords do not match.'; } } else { $form = new Form(); $form->addInput('first_name', 'First Name'); $form->addInput('last_name', 'Last Name'); $form->addInput('email', 'Email'); $form->addInput('password', 'Password', null, 'password'); $form->addInput('password_confirm', 'Confirm Password', null, 'password'); $form->addInput('submit', null, 'Register', 'submit'); $content .= $form->render(); } //template require_once 'template.php';
$address_options[] = array($a->id, $a->address1); } } $form = new Form(); $form->addSelectList('address_id', 'Ship to', $address_options); $form->addText('Or ship to a different address'); //token $token_str = ''; //make a string from the cart ids converted to hex foreach ($_SESSION['cart'] as $id) { $token_str .= dechex($id); } $token = md5($customer_id . time() . $token_str); //also add a salt? from file or db $_SESSION['form_token'] = $token; $form->addInput('token', '', $token, 'hidden'); $form->addInput('address1', 'Address Line 1'); $form->addInput('address2', 'Address Line 2'); $form->addInput('city', 'City'); $form->addInput('state', 'State'); $form->addInput('zip', 'Zip'); //$form->addInput('country','Country'); //add payment fields here $form->addInput('submit', null, 'Place Order', 'submit'); $content .= $form->render(); //choose payment -- paypal API sandbox??? } else { //if not valid require_once 'template.php'; exit; }
function edit_action($id) { $id = (int) $id; // getting data $data = $this->model->pageData_id($id); if (!$data) { SiteRedirect('pages'); } // back to link if ($this->params->backTo == 'site') { $backTo = '?backTo=site'; $backToLabel = ' lub <a href="#/' . $data->name . '">powróć do strony</a>'; } else { $backToLabel = ', <a href="$/pages/">powróć do listy stron</a> lub <a href="#/' . $data->name . '">obejrzyj stronę</a>'; } // form options $this->pageTitle = 'Edytuj stronę'; $form = new Form('wmelon.pages.editPage', 'pages/editSubmit/' . $id . $backTo, 'pages/edit/' . $id . $backTo); $form->displaySubmitButton = false; // inputs labels $nameLabel = 'Nie zmieniaj, jeśli <em>naprawdę</em> nie wiesz co robisz'; // inputs args $titleArgs = array('value' => $data->title); $contentArgs = array('value' => $data->content, 'style' => 'width: 100%; height:30em'); $nameArgs = array('value' => $data->name, 'labelNote' => $nameLabel); // adding inputs $form->addInput('text', 'title', 'Tytuł', true, $titleArgs); $form->addInput('textarea', 'content', 'Treść', true, $contentArgs); $form->addInput('text', 'name', 'Nazwa', true, $nameArgs); $form->addHTML('<label><span></span><input type="submit" value="Zapisz">' . $backToLabel . '</label>'); echo $form->generate(); }
public static function display() { $r = ""; if ($_POST['cc_form'] == 'settings') { $name_lookup = array(); Database::beginTransaction(); foreach ($_POST as $key => $value) { if ($key == 'cc_form') { continue; } if (substr($key, 0, 12) == 'cc_settings_') { $name_lookup[substr($key, 12)] = explode('|', $value); continue; } $setting_name = $key; //var_dump(array_key_exists($key, $name_lookup),$name_lookup); if (!array_key_exists($setting_name, $name_lookup)) { continue; } if ($key == 'clean-urls') { $value = (bool) $value; } Database::update('settings', array('data'), array(serialize($value)), array('package = ? AND name = ?', $name_lookup[$setting_name][1], $name_lookup[$setting_name][0])); } $r .= Message::success(__('admin', 'settings-saved')); Database::endTransaction(); } $settings = Database::select('settings', '*', array('package = ? OR package = ? OR package = ? OR package = ?', 'core', 'admin', 'site', 'gui'), array('package', 'ASC', 'name', 'ASC')); $settings = $settings->fetchAll(PDO::FETCH_ASSOC); $rows = array(); foreach ($settings as $row) { if (!array_key_exists($row['package'], $rows)) { $rows[$row['package']] = array(); } $rows[$row['package']][] = $row; } ksort($rows); $form = new Form('self', 'POST', 'settings'); foreach ($rows as $cat => $catRows) { $form->startFieldset(__('settings', $cat)); foreach ($catRows as $row) { $data = unserialize($row['data']); $form->addHidden('cc_settings_' . UTF8::slugify($row['name']), $row['name'] . '|' . $row['package']); if ($row['name'] == 'clean urls') { $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), array(1 => __('admin', 'yes'), 0 => __('admin', 'no')), true, $data); } else { if ($row['name'] == 'theme') { $themes = Themes::getThemeList(); $options = array(); foreach ($themes as $slug => $ini) { $options[$slug] = $ini['name']; } $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $options, true, $data); } else { if ($row['name'] == 'locale') { $locales = i18n::getLocales(); $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $locales, false, $data); } else { if ($row['name'] == 'homepage id') { $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Content::optionListArrayFromArray(Content::parseNavigation()), true, $data); } else { if ($row['name'] == 'site name') { $form->addInput(__('settings', $row['name']), 'text', UTF8::slugify($row['name']), $data); } else { if ($row['name'] == 'editor') { $editors = Editors::getNamesOfRegistered(); $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $editors, false, $data); } else { if ($row['name'] == 'homepage') { $form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Admin::getAdminPageOptions(), true, $data); } } } } } } } } $form->endFieldset(); } $form->startFieldset(''); $form->addSubmit('', 'save-settings', __('admin', 'save')); $form->endFieldset(); return array(__('admin', 'settings'), $r . $form->endAndGetHTML()); }
function edit_action($id, $backPage) { $id = (int) $id; // getting data $data = $this->model->commentData($id); if (!$data) { SiteRedirect('comments'); } // displaying form $this->pageTitle = 'Edytuj wpis'; $form = new Form('wmelon.comments.editComment', 'comments/editSubmit/' . $id . '/' . $backPage, 'comments/edit/' . $id . '/' . $backPage); $form->addInput('textarea', 'content', 'Treść', true, array('style' => 'width: 100%; height:30em', 'value' => $data->content)); echo $form->generate(); }
function edit_action($id) { $id = (int) $id; // getting data $data = $this->model->postData_id($id); if (!$data) { SiteRedirect('blog'); } // back to link $backTo = isset($this->params->backTo) ? '?backTo=' . $this->params->backTo : ''; $postURL = '#/' . date('Y/m', $data->published) . '/' . $data->name; switch ($this->params->backTo) { case 'post': $backToLabel = ' lub <a href="' . $postURL . '">powróć do wpisu</a>'; break; case 'site': $backToLabel = ' lub <a href="#/#blogpost-' . $data->id . '">powróć do strony</a>'; // TODO: and what if the post is not on first page? break; default: $backToLabel = ', <a href="$/blog/">powróć do listy wpisów</a> albo <a href="' . $postURL . '">obejrzyj wpis</a>'; break; } // options $this->pageTitle = 'Edytuj wpis'; $form = new Form('wmelon.blog.editPost', 'blog/editSubmit/' . $id . $backTo, 'blog/edit/' . $id . $backTo); $form->displaySubmitButton = false; // label notes $summary_note = 'Jeśli chcesz, napisz krótko wstęp lub streszczenie wpisu - zostanie ono pokazane na stronie głównej i w czytnikach kanałów'; // inputs args $titleArgs = array('value' => $data->title); $contentArgs = array('value' => $data->content, 'style' => 'width: 100%; height:30em'); $summaryArgs = array('value' => $data->summary, 'labelNote' => $summary_note); $allowCommentsArgs = array('value' => $data->allowComments); // adding inputs $form->addInput('text', 'title', 'Tytuł', true, $titleArgs); $form->addInput('textarea', 'content', 'Treść', true, $contentArgs); $form->addInput('textarea', 'summary', 'Streszczenie', false, $summaryArgs); $form->addInput('checkbox', 'allowComments', 'Pozwól na komentarze', false, $allowCommentsArgs); // submit buttons $form->addHTML('<br><label><span></span>'); $form->addHTML('<input type="submit" name="submit_save" value="Zapisz">'); if ($data->status == 'draft') { $form->addHTML('<input type="submit" name="submit_publish" value="Opublikuj">'); } $form->addHTML($backToLabel); $form->addHTML('</label>'); echo $form->generate(); }
if (isset($_SESSION['cid'])) { //if they are logged in, this is the log-out form unset($_SESSION['cid']); unset($_SESSION['cart']); $info_msg = 'You are now logged out. Thank you for visiting.'; } //Determine the page to send the user when they successfully log in if (isset($_GET['ref'])) { //to prevent undefined index notice if (in_array('cart', $allowed_refs) && (int) $_GET['n']) { $ref = 'cart'; $id = (int) $_GET['n']; } } //login form $form = new Form(); $form->addInput('email', 'Email'); $form->addInput('password', 'Password', null, 'password'); //send the reference info is there is some. if ($ref) { $form->addInput('ref', '', $ref, 'hidden'); } if ($id) { $form->addInput('n', '', $id, 'hidden'); } $form->addInput('submit', null, 'Log in', 'submit'); //need to add a token field $content .= $form->render(); } //display require_once 'template.php';
<title>Form.php Örnek Kullanım</title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <link href="css/style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/validation.js"></script> </head> <body> <div align='center'> <?php include_once 'FormCreator/Form.php'; //FormHelper ile amele işlerin yaptırılacağı bir class yazılabilir. try { $form = new Form("test.php"); $form->setFormAttributes(array('id' => 'formId')); $form->setTableAttributes(array("class" => "table")); $form->addInput("text", "name", "Email")->setValidation(array("required" => true, "min" => 3)); $form->addInput("password", "pass", "Şifre")->setValidation(array("required" => true, "min" => 8)); $form->addInput("text", "yas", "Yaş"); $form->addLabel("Cinsiyet:"); $form->addRadioButton("cinsiyet", "erkek", "Erkek", array("checked" => "checked")); $form->addRadioButton("cinsiyet", "bayan", "Bayan"); $form->addComboBox("carbrand", "Arabanızın Markası", array('mercedes' => 'Mercedes', 'bmw' => 'BMW')); //$form->addTextArea(32, 5, "adres","Adres"); //$form->addCheckBox("termofuse", "read", "Kullanmıcı Sözleşmesini okudum")->setValidation(array("mustBeChecked"=>true)); $form->addTermsOfUse("files/file.txt", true); $form->addInput("submit", "dugme", "Kaydet"); echo $form->show(); } catch (Exception $ex) { echo $ex->getMessage(); } ?>
?> </title> <?php load_library(array('bootstrap-css', 'jquery')); queue_css(TH_PUB_ADMIN . 'design/styles.css'); load_css(); load_js(); ?> </head> <body class="login"> <div id="login-wrapper"> <h2><?php _e('login_cc'); ?> </h2> <?php $form = new Form('self', 'post', 'login'); $form->startFieldset(''); $form->addInput(__("Username"), 'text', 'cc_login_uname'); $form->addInput(__("Password"), 'password', 'cc_login_passwd'); $form->addInput(__("remember-me"), 'checkbox', 'cc_login_remember', 'yes'); $form->addSubmit('', 'cc_login_login', __('login_cc')); $form->endFieldset(); echo $form->endAndGetHTML(); i18n::restore(); ?> </div> </body> </html>
$is_edit = 0; $button = 'Add New Product'; //is this an edit? if (isset($_GET['id']) && (int) $_GET['id'] > 0) { $is_edit = 1; $id = (int) $_GET['id']; $product = new Product($id); $name = $product->product_name; $num = $product->product_num; $price = $product->price; $quantity = $product->quantity_on_hand; $desc = $product->description; $action = 'Edit'; $button = 'Edit'; } $title = $action . ' Product'; $form = new Form(); $form->addInput('product_name', 'Product Name', $name); $form->addInput('product_num', 'Product Number', $num); $form->addInput('price', 'Price', $price); $form->addInput('quantity', 'Quantity on Hand', $quantity); $form->addTextArea('desc', 'Description', $desc); if ($is_edit) { $form->addInput('id', '', $id, 'hidden'); } $form->addInput('submit', null, $button, 'submit'); $content = $form->render(); } $content .= '<p class="back"><a href="product-list.php">Back to product list</a></p>'; //---Display---// require_once '../template.php';
public static function display() { $id = $_GET['id']; if (!is_numeric($id)) { i18n::restore(); cc_redirect(Admin::link('users')); return 'redirected.'; } $messages = ""; if ($_POST['cc_form'] === 'edit-user') { $username = $_POST['name']; $password = $_POST['password']; $cpassword = $_POST['confirm-password']; $group = $_POST['group']; if ($password != $cpassword) { $messages .= Message::error(__('admin', 'passwords-dont-match')); } else { $result = Database::select('users', '*', array('users_id = ?', $id)); $row = $result->fetch(PDO::FETCH_ASSOC); $result = Database::select('users', '*', array('name = ?', $username)); if (!empty($result)) { $userRow = $result->fetch(PDO::FETCH_ASSOC); } else { $result = false; } if ($result && $userRow['name'] == $username && $id != $userRow['id']) { $messages .= Message::error(__('admin', 'username-in-use')); } else { if (!empty($password) && !empty($cpassword) && $password == $cpassword) { $hash = hash('whirlpool', $password); } else { $hash = $row['value']; } $data = unserialize($row['data']); $result = Database::update('users', array('name' => filter('admin_edit_user_username', $username), 'value' => $hash, 'type' => 'user', 'group' => filter('admin_edit_group', $group), 'data' => serialize(filter('admin_edit_user_data', $data))), null, array('id = ?', $id)); if ($result === 1) { $messages .= Message::success(__('admin', 'user-updated')); } } } } $result = Database::select('users', '*', array('users_id = ?', $id)); if (empty($result)) { i18n::restore(); cc_redirect(Admin::link('users')); } self::$row = $result->fetch(PDO::FETCH_ASSOC); $form = new Form('self', 'post', 'edit-user'); $groups = Users::allGroups(); foreach ($groups as $key => $value) { $groups[$value->getId()] = $value->getName(); } $form->startFieldset(__("admin", 'user-information')); $form->addInput(__('admin', 'username'), 'text', 'name', self::get('name')); $form->addInput(__('admin', 'password'), 'password', 'password'); $form->addInput(__('admin', 'confirm-password'), 'password', 'confirm-password'); $form->addSelectList(__('admin', 'group'), 'group', $groups, true, self::get('group')); plugin('admin_edit_user_custom_fields', array(&$form)); $form->addSubmit('', 'edit-user', __('admin', 'edit-user')); $form->endFieldset(); plugin('admin_edit_user_custom_fieldset', array(&$form)); $form = $form->endAndGetHTML(); return array(sprintf("%s: %s", __('admin', 'edit-user'), self::get('name')), $messages . $form); }
public static function create_display() { i18n::set('admin'); if ($_POST['cc_form'] == 'create_page') { plugin('admin_create_post_pre_proccessing'); $id = $_GET['id']; $title = filter('admin_create_post_title', self::get('title')); $content = filter('admin_create_post_content', self::get('content_area')); $last_modified = filter('admin_create_post_last_modified', time()); $settings = filter('admin_create_post_settings', self::get('settings')); $weight = filter('admin_create_post_weight', self::get('weight')); $menutitle = filter('admin_create_post_menutitle', self::get('menutitle')); $parent_id = filter('admin_create_post_parent_id', self::get('parent_id')); $slug = filter('admin_create_post_slug', self::get('slug')); if (empty($menutitle) || empty($slug)) { $message = Message::error(__('blank-error')); plugin('admin_create_post_blank_error'); } else { plugin('admin_create_post_post_proccessing'); $values = array('title' => $title, 'content' => $content, 'settings' => unserialize($settings), 'weight' => $weight, 'menutitle' => $menutitle, 'parent_id' => $parent_id, 'slug' => $slug); $values = filter('admin_create_post_posted_values', $values); $values['settings'] = serialize($values['settings']); $res = Content::createNode($_GET['type'], $values); if ($res) { $message = Message::success(sprintf(__('page-creation-successful') . ' (<a href="%s">%s</a>)', Admin::link('content'), __('view-all-pages'))); } else { $message = Message::error(__('page-creation-failed')); } } //Hooks::bind('post_edit_page', 'EditPage::handlePost'); } $r = $message; $themeList = array_subkeys(Themes::getThemeList(), 'name'); $themeList['-1'] = 'Default Theme'; ksort($themeList); $form = new Form('self', 'post', 'create_page'); $form->addHidden('settings', 'a:0:{}'); $form->startFieldset(__('page-info'), array('id' => 'page_info_f')); $form->addInput(__('page-title'), 'text', 'title', self::get('title'), array('class' => 'large')); $form->addHidden('content_type', self::get('type')); $form->addSelectList(__('theme-override'), 'theme', $themeList); $form->addSelectList(__('parent'), 'parent_id', self::buildParentOptions(), true, $_POST['parent_id'] ? $_POST['parent_id'] : '0'); $form->endFieldset(); plugin('admin_create_custom_fields', array(&$form)); $form->startFieldset(__('menu-settings'), array('id' => 'menu_settings_f')); $form->addInput(__('menu-title'), 'text', 'menutitle', self::get('menutitle')); $form->addInput(__('slug'), 'text', 'slug', self::get('slug')); $form->addInput(__('weight'), 'text', 'weight', $_POST['weight'] ? $_POST['weight'] : '0'); $form->endFieldset(); plugin('admin_create_custom_fields2', array(&$form)); $form->startFieldset(__('content')); $content = self::get('content_area'); $form->addEditor('<p></p>', 'content_area', empty($content) ? "<p></p>" : $content); $form->endFieldset(); plugin('admin_create_custom_fields3', array(&$form)); $form->addSubmit('', 'save', __('save')); i18n::restore(); return array(__('admin', 'add-page'), $r . $form->endAndGetHTML()); }
public static function commentsView($id, $type, $backPage, $open = true) { $id = (int) $id; $type = (string) $type; $backPage = (string) $backPage; $model = new Comments_Model(); // comments $commentsObj = $model->commentsFor($id, $type); $approvedCount = 0; // counter of approved comments $unapprovedCount = 0; // counter of unapproved comments $visibleCount = 0; // counter of comments visible to user // visibilityToken if (!Users::isLogged() && isset($_SESSION['wmelon.comments.visibilityToken'])) { $visibilityToken = $_SESSION['wmelon.comments.visibilityToken']; } // composing comments array foreach ($commentsObj as $comment) { // tools $linkEnding = $comment->id . '/' . base64_encode($backPage . '#comment-' . $comment->id); $comment->editHref = '%/comments/edit/' . $linkEnding; $comment->deleteHref = '%/comments/delete/' . $comment->id . '/' . base64_encode($backPage . '#comments'); $comment->approveHref = '%/comments/approve/' . $linkEnding; $comment->rejectHref = '%/comments/reject/' . $linkEnding; // visibility // (comment is visible if admin or comment is approved or comment visibility token match user's visibility token) $comment->visible = Users::isLogged() || $comment->approved || $comment->visibilityToken == $visibilityToken && !empty($comment->visibilityToken); if ($comment->visible) { $visibleCount++; } // additional information (for admin) if (Users::isLogged() && $comment->authorID === null) { $comment->additionalInfo = $comment->authorEmail . '; IP:' . $comment->authorIP; } // if commented as logged user $authorID = $comment->authorID; if ($authorID !== null) { // author's user data $comment->author = Users::userData(1); // CSS class (for admin comments distinction) $comment->cssClass = 'adminComment'; } // "awaiting moderation" CSS class if (!$comment->approved) { $comment->cssClass .= ' awaitingModerationComment'; } // comments counter if ($comment->approved) { $approvedCount++; } else { $unapprovedCount++; } //-- $comments[] = $comment; } // form $submitPage = 'comments/post/' . $id . '/' . $type . '/' . base64_encode($backPage); $form = new Form('wmelon.comments.addComment', $submitPage, $backPage . '#commentForm-link'); $form->globalMessages = false; $form->submitLabel = 'Zapisz'; // user data inputs (if not logged in) if (!Users::isLogged()) { // remembered user data $name = $_SESSION['wmelon.comments.name']; $email = $_SESSION['wmelon.comments.email']; $website = $_SESSION['wmelon.comments.website']; // inputs args $name = array('value' => $name); $email = array('value' => $email); $website = array('value' => $website, 'labelNote' => '(Opcjonalnie)'); // adding inputs $form->addInput('text', 'name', 'Imię', true, $name); $form->addInput('email', 'email', 'Email', true, $email); $form->addInput('url', 'website', 'Strona', false, $website); } // content input $form->addInput('textarea', 'content', 'Komentarz'); // comments counter $commentsCount = Users::isLogged() ? $commentsObj->rows : $approvedCount; // number of visible (approved) comments - for user and all comments - for admin if ($commentsCount > 0) { $commentsCountStr = $commentsCount . ' ' . pl_inflect($commentsCount, 'komentarzy', 'komentarz', 'komentarze'); } if (Users::isLogged() && $unapprovedCount > 0) { $commentsCountStr .= ' <span class="important">(' . $unapprovedCount . ' do sprawdzenia!)</span>'; } // view $view = Loader::view('/comments/comments'); $view->comments = $comments; $view->areComments = $commentsObj->exists; $view->commentsCount = $commentsCountStr; $view->visibleCount = $visibleCount; $view->visibilityToken = $visibilityToken; $view->id = $id; $view->type = $type; $view->backPage = $backPage; $view->form = $form->generate(); $view->open = $open; return $view->generate(); }
//cache the data //$cache = new Cache($id,$type); //$cache->setCache($data_array); } $content = ''; foreach ($data_array as $field => $value) { if ($field == 'title') { $title = $value; } else { $content .= "<p>{$field}: {$value}</p>"; } } if ($type == 'product') { //display 'Add to Cart' button $form = new Form(); $form->addInput('pid', '', $id, 'hidden'); $form->addInput('qty', 'Quantity', 1, 'text', 2); $form->addInput('submit', null, 'Add to Cart', 'submit'); $form->setAction('cart-add.php'); $content .= $form->render(); $content .= '<p><br/><a href="index.php">Back to shopping</a></p>'; } if ($type == 'customer') { //display list of addresses $addresses = new AddressList($id); if (!empty($addresses)) { $content .= '<h3>Addresses</h3>'; foreach ($addresses as $a) { $content .= '<div class="cust-address">'; $content .= $a->getFullAddress(); $content .= '</div>';
public static function create_display() { i18n::set('external-link-nodetype'); $message = ""; if ($_POST['cc_form'] == 'create_external_link') { $id = $_GET['id']; $weight = self::get('weight'); $menutitle = self::get('menutitle'); $parent_id = self::get('parent_id'); $slug = self::get('slug'); if (empty($url) || empty($text)) { $message = Message::error(__('blank-error')); } else { if (empty($weight)) { $weight = '0'; } $values = array('title' => '', 'content' => '', 'settings' => 'a:0:{}', 'weight' => $weight, 'menutitle' => $menutitle, 'parent_id' => $parent_id, 'slug' => $slug); $res = Content::createNode($_GET['type'], $values); if ($res) { $message = Message::success(sprintf(__('link-creation-successful') . ' (<a href="%s">%s</a>)', Admin::link('content'), __('admin', 'view-all-pages'))); } else { $message = Message::error(__('link-creation-failed')); } } } $r = $message; $form = new Form('self', 'post', 'create_external_link'); $form->addInput(__('url'), 'text', 'slug', self::get('slug')); $form->addInput(__('display-text'), 'text', 'menutitle', self::get('menutitle')); $form->addSelectList(__('parent'), 'parent_id', PageNode::buildParentOptions(), true, $_POST['parent_id'] ? $_POST['parent_id'] : '0'); $form->addInput(__('weight'), 'text', 'weight', self::get('weight')); $form->addSubmit('', 'create', 'Create'); i18n::restore(); return array(__('external-link-nodetype', 'create-external-link'), $form->endAndGetHTML()); }