本文整理汇总了PHP中Element::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::factory方法的具体用法?PHP Element::factory怎么用?PHP Element::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct('formLogin', 'Login');
$this->addElement(Element::factory('text', 'username', 'Username'));
$this->addElement(Element::factory('password', 'password', 'Password'));
$this->addButtons(Form::BTN_SUBMIT);
$this->getElement('submit')->setCaption('Login');
}
示例2: __construct
public function __construct()
{
parent::__construct('formDeleteUser', 'Delete user?');
requirePriv('USER_DELETE');
$this->addElement(Element::factory('hidden', 'uid', null, $_REQUEST['formDeleteUser-uid']));
$this->addElement(Element::factory('html', 'msg', null, 'Sure?'));
$this->addButtons(Form::BTN_SUBMIT);
}
示例3: __construct
public function __construct()
{
parent::__construct('formRegister', 'Register a new account');
$this->addElement(Element::factory('alphanumeric', 'username', 'Username'));
$this->addElement(Element::factory('password', 'password1', 'Password'));
$this->addElement(Element::factory('password', 'password2', 'Password (confirm)'));
$this->addElement(Element::factory('text', 'email', 'E-Mail address'));
$this->addButtons(Form::BTN_SUBMIT);
}
示例4: __construct
public function __construct()
{
parent::__construct('formChangePassword', 'Change password');
if (!Session::isLoggedIn()) {
throw new Exception('You need to be logged in to change your password.');
}
$this->addElement(Element::factory('password', 'password1', 'New password'));
$this->addElement(Element::factory('password', 'password2', 'Password (confirm)'));
$this->addButtons(Form::BTN_SUBMIT);
}
示例5: getElementOrganization
private function getElementOrganization()
{
global $db;
$sql = 'SELECT o.id, o.title FROM organizers o WHERE o.published = 1 ORDER BY o.title ASC';
$stmt = $db->query($sql);
$el = Element::factory('select', 'organization', 'Organization');
foreach ($stmt->fetchAll() as $organization) {
$el->addOption($organization['title'], $organization['id']);
}
return $el;
}
示例6: getGroupSelectionElement
private function getGroupSelectionElement($currentGroup)
{
global $db;
$el = Element::factory('select', 'group', 'Primary group');
$sql = 'SELECT g.id, g.title FROM groups g';
$stmt = $db->prepare($sql);
$stmt->execute();
foreach ($stmt->fetchAll() as $group) {
$el->addOption($group['title'], $group['id']);
}
$el->setValue($currentGroup);
return $el;
}
示例7: getElementSleeping
private function getElementSleeping($val)
{
$el = Element::factory('select', 'sleeping', 'Sleeping');
$el->addOption('Not aranged by organizer');
$el->addOption('Not an overnight event');
$el->addOption('Private rooms at venue');
$el->addOption('Indoors at venue');
$el->addOption('Indoors and camping at venue');
$el->addOption('Indoors, camping and private rooms at venue');
$el->addOption('Indoors at venue. Camping and hotels nearby.');
$el->setValue($val);
return $el;
}
示例8: __construct
public function __construct($id, $isNewArticle = false)
{
$this->id = $id;
Session::requirePriv('EDIT_BLOG');
if (empty($isNewArticle)) {
parent::__construct('editBlogPost', 'New post');
} else {
parent::__construct('editBlogPost', 'Edit post');
}
$post = $this->getPost();
$this->addElement(Element::factory('textarea', 'title', 'Title', $post['title']));
$this->addElement(Element::factory('textarea', 'content', 'Content', $post['content']));
$this->addDefaultButtons();
}
示例9: getOrganizerList
public static function getOrganizerList($includeNull = false)
{
global $db;
$sql = 'SELECT id, title FROM organizers ORDER BY title ASC';
$stmt = $db->prepare($sql);
$stmt->execute();
$el = Element::factory('select', 'organizer', 'Organizer');
foreach ($stmt->fetchAll() as $orgie) {
$el->addOption($orgie['title'], $orgie['id']);
}
if ($includeNull) {
$el->addOption('(null)', 0);
}
return $el;
}
示例10: __construct
public function __construct()
{
parent::__construct('newOrganizer', 'New Organizer');
if (Session::getUser()->hasPriv('CREATE_ORGANIZERS')) {
$this->addElement(Element::factory('html', 'description', null, 'This will appear in the organizers list as soon as you submit the form.'));
} else {
$currentOrganizer = Session::getUser()->getData('organization');
if (empty($currentOrganizer) && $currentOrganizer != 0) {
throw new PermissionException('Cannot create another organizer, you already have one aginst your account');
}
$this->addElement(Element::factory('html', 'description', null, 'This will not appear in the organizers list immidiately, it will first have to be approved by one of our smiling friendly admins - they accept bribes in the form of cake.'));
}
$this->addElement(Element::factory('text', 'title', 'Title'));
$this->addElement(Element::factory('text', 'websiteUrl', 'Website URL'));
$this->addElement(Element::factory('textarea', 'blurb', 'Blurb', null, 'A blurb describes the organizer, prehaps the year you started, how experienced you are, or if you like cake. Its best to leave event specific information to when you go to create events.'));
$this->addButtons(Form::BTN_SUBMIT);
}
示例11: __construct
public function __construct()
{
parent::__construct('formEditVenue', 'Edit Venue');
$venue = $this->getVenue();
if (Session::getUser()->getData('organization') != $venue['organizer']) {
Session::requirePriv('EDIT_VENUE');
}
$this->addElement(Element::factory('hidden', 'id', null, $venue['id']));
$this->addElement(Element::factory('text', 'title', 'Title', $venue['title']));
$this->addElement(Element::factory('text', 'lat', 'Lat', $venue['lat']));
$this->getElement('lat')->setMinMaxLengths(1, 10);
$this->addElement(Element::factory('text', 'lng', 'Lng', $venue['lng']));
$this->getElement('lng')->setMinMaxLengths(1, 10);
$this->addElement(FormHelpers::getElementCountry($venue['country']));
$this->addElement(FormHelpers::getOrganizerList());
$this->getElement('organizer')->setValue($venue['organizer']);
$this->addButtons(Form::BTN_SUBMIT);
}
示例12: __construct
public function __construct()
{
parent::__construct('newVenue', 'New Venue');
$this->addElement(Element::factory('html', 'desc', null, 'A venue is a physical place where an event will be hosted, this may be a convention centre, a hall or just your house. You can specify detail such as sleeping arangements when the event is created.'));
$this->addElement(Element::factory('text', 'title', 'Title', null, 'eg: Budleigh Salterton town hall, Cheltenham Racecourse, etc.'));
$this->addElement(FormHelpers::getElementCountry('United Kingdom'));
$this->addElement(Element::factory('html', 'locationDesc', null, '<br />The geodetic (WGS84) latitude/longitude of your venue. This can be awkward, but it allows us to put a pin on the map. We cannot use post/zip codes because many countries do not have them! <a href = "http://www.getlatlon.com/">http://getlatlong.com</a> will convert an address to a rough lat/lng. '));
$this->addElement(Element::factory('numeric', 'lat', 'Latitude'))->setAllowNegative(true);
$this->addElement(Element::factory('numeric', 'lng', 'Longitude'))->setAllowNegative(true);
if (Session::hasPriv('NEW_VENUE')) {
$this->addElement(FormHelpers::getOrganizerList());
if (isset($_REQUEST['formNewVenue-organizer'])) {
$this->getElement('organizer')->setValue($_REQUEST['formNewVenue-organizer']);
}
}
$this->addButtons(Form::BTN_SUBMIT);
$this->requireFields(array('title', 'lat', 'lng', 'country'));
}
示例13: process
public function process()
{
global $db;
$sql = 'INSERT INTO events (title, dateStart, dateFinish, organizer, venue, published, website, createdDate, createdBy) VALUES (:title, :dateStart, :dateFinish, :organizer, :venue, :published, :website, :createdDate, :createdBy)';
$stmt = $db->prepare($sql);
$stmt->bindValue(':title', $this->getElementValue('title'));
$stmt->bindValue(':dateStart', $this->getElementValue('dateStart'));
$stmt->bindValue(':dateFinish', $this->getElementValue('dateFinish'));
$stmt->bindValue(':website', $this->getElementValue('eventWebsite'));
$stmt->bindValue(':createdDate', date(DATE_ATOM));
$stmt->bindValue(':createdBy', Session::getUser()->getId());
if (Session::getUser()->hasPriv('CREATE_EVENTS')) {
$this->addElement(Element::factory('html', 'msg', null, 'Hi superuser.'));
$stmt->bindValue(':organizer', $this->getElementValue('organizer'));
$stmt->bindValue(':published', 1);
$stmt->bindValue(':venue', $this->getElementValue('venue'));
} else {
if (Session::getUser()->getData('organization') != null) {
$stmt->bindValue(':venue', $this->getElementValue('venue'));
$organizer = fetchOrganizer(Session::getUser()->getData('organization'));
if ($organizer['published']) {
$this->addElement(Element::factory('html', 'msg', null, 'You are authorized to create public events for your organization.'));
$stmt->bindValue(':organizer', $organizer['id']);
$stmt->bindValue(':published', 1);
} else {
$this->addElement(Element::factory('html', 'msg', null, 'Your event will be linked to your organization, but will not be public until your organization has been approved.'));
$stmt->bindValue(':organizer', $organizer['id']);
$stmt->bindValue(':published', 0);
}
} else {
$this->addElement(Element::factory('html', 'msg', null, 'You can create events, but they will not appear in public lists until approved.'));
$stmt->bindValue(':organizer', '');
$stmt->bindValue(':published', 0);
$stmt->bindValue(':venue', '');
}
}
$stmt->execute();
$eventId = $db->lastInsertId();
Logger::messageDebug('Event ' . $this->getElementValue('title') . ' created by: ' . Session::getUser()->getUsername(), LocalEventType::CREATE_EVENT);
redirect('viewEvent.php?id=' . $eventId, 'Event created.');
}
示例14: __construct
public function __construct()
{
parent::__construct('formSendEmailToUser', 'Send email to user');
Session::requirePriv('SEND_EMAIL');
$uid = $_REQUEST['formSendEmailToUser-uid'];
$uid = intval($uid);
$this->user = User::getUserById($uid);
$sql = 'SELECT o.* FROM users u LEFT JOIN organizers o ON u.organization = o.id WHERE u.id = :userId LIMIT 1';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':userId', $this->user->getId());
$stmt->execute();
if ($stmt->numRows()) {
$this->organizer = $stmt->fetchRow();
} else {
$this->organizer = array('title' => '???', 'id' => '0');
}
$this->addElement(Element::factory('hidden', 'uid', null, $uid));
$this->addElement(Element::factory('text', 'email', 'Send to', $this->user->getData('email'), 'User: <a href = "viewUser.php?id=' . $this->user->getId() . '">' . $this->user->getData('username') . '</a> Organizer: <a href = "viewOrganizer.php?id=' . $this->organizer['id'] . '">' . $this->organizer['title'] . '</a>'));
$this->addElement(Element::factory('text', 'subject', 'Subject', 'Message from a human!'));
$this->addElement(Element::factory('textarea', 'body', 'Body', 'Hey ' . $this->user->getUsername() . ', ' . "\n\n" . 'Your message here.' . "\n\n- lanlist.org ", 'No footer will be appended. From: mailer@lanlist.org'));
$this->loadTemplate();
$this->addButtons(Form::BTN_SUBMIT);
}
示例15: __construct
public function __construct()
{
parent::__construct('formEditOrganizer', 'Edit Organizer');
$organizer = fetchOrganizer($_REQUEST['formEditOrganizer-id']);
if (Session::getUser()->hasPriv('PUBLISH_ORGANIZERS')) {
$this->addElement(Element::factory('checkbox', 'published', 'Published', $organizer['published']));
}
$this->addElement(Element::factory('text', 'title', 'Title', $organizer['title']));
$this->addElement(Element::factory('hidden', 'id', null, $organizer['id']));
$this->addElement(Element::factory('text', 'websiteUrl', 'Website', $organizer['websiteUrl']));
$this->addElement(Element::factory('date', 'assumedStale', 'Assumed stale since', $organizer['assumedStale']));
$this->addElement(Element::factory('text', 'steamGroupUrl', 'Steam group URL', htmlify($organizer['steamGroupUrl'])));
$this->getElement('steamGroupUrl')->setMinMaxLengths(0, 255);
$this->addElement(Element::factory('textarea', 'blurb', 'Blurb', $organizer['blurb']));
$this->addElement(Element::factory('file', 'banner', 'Banner image', null, 'Your organizer banner image. Preferably a PNG, maximum image size is 468x160'));
$this->getElement('banner')->destinationDir = 'resources/images/organizer-logos/';
$this->getElement('banner')->destinationFilename = $organizer['id'] . '.jpg';
$this->getElement('banner')->setMaxImageBounds(468, 160);
if (!Session::hasPriv('EDIT_ORGANIZER') && Session::getUser()->getData('organization') != $organizer['id']) {
throw new PermissionsException();
}
$this->addButtons(Form::BTN_SUBMIT);
}