public function testFilter() { $filter = new Html(); $this->assertEquals('<a>test</a>', $filter->apply('<a>test</a>')); $this->assertEquals('test', $filter->apply('test')); // test error message $this->assertErrorMessage($filter->getErrorMessage()); }
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { echo "<form name='notificationtargets_form' id='notificationtargets_form'\n method='post' action=' "; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class ='tab_cadre_fixe'>"; echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>'; echo '<td>' . __('Access', 'formcreator') . '</td>'; echo '<td>'; Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1)); echo '</td>'; if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) { echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>'; $table = getTableForItemType(__CLASS__); $table_profile = getTableForItemType('Profile'); $query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n FROM {$table_profile} p\n LEFT JOIN {$table} f\n ON p.`id` = f.`plugin_formcreator_profiles_id`\n AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id']; $result = $GLOBALS['DB']->query($query); while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) { $checked = $profile ? ' checked' : ''; echo '<tr><td colspan="2"><label>'; echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> '; echo $name; echo '</label></td></tr>'; } } echo '<tr>'; echo '<td class="center" colspan="2">'; echo '<input type="hidden" name="profiles_id[]" value="0" />'; echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />'; echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />'; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); }
public function check() { $username = $_POST['username']; $password = $_POST['password']; $conn = Db::getConnection(); $sql = "SELECT username, password, admin\n\t\t\t\tFROM users\n\t\t\t\tWHERE username = '******'"; $q = $conn->prepare($sql); $q->execute(); $users = $q->fetch(\PDO::FETCH_ASSOC); //var_dump($users);die(' proba'); $logger = new Logger(); $error = $logger->checkCredentials($password, $users); //$isAdmin = $logger->checkAdmin($password,$users); //var_dump($error);die(' ajde vise!!!'); if ($error) { //echo '<pre>'; var_dump($error);die(); echo '</pre>'; $html = new Html($this->controllerName); $html->error = $error; //echo '<pre>'; var_dump($html->error);die(); echo '</pre>'; $html->render('index'); } else { $user = new User($users['username'], $users['admin']); $user->login(); //var_dump($user);die(' jebem li ga'); header('Location: /'); } }
/** * Test that the storage number can be set and retrieved. */ public function testSetGetStorageAsText() { $text = 'test'; $html = new Html(); $html->set('test', $text); $this->assertSame($text, $html->get('test')); }
function tagField($db, $limit = null) { $nsid = $_SESSION['namespace_id'] ? $_SESSION['namespace_id'] : DB_PUBNS; $sql = sprintf('select t.name, m.tag, count(m.tag) as num from tagmap as ' . 'm, tags as t where t.id=m.tag and t.namespace=%d group by tag ' . 'order by date desc', $nsid); $sql .= !is_null($limit) ? ' LIMIT ' . $limit : null; $max_size = 250; $min_size = 100; if (!($result = $db->query($sql))) { debug_hook('Failed to load tag cloud!', __METHOD__); return; } while ($row = $result->fetch_assoc()) { $tags[$row['name']] = $row['num']; } $max_value = max(array_values($tags)); $min_value = min(array_values($tags)); $spread = $max_value - $min_value; if ($spread == 0) { $spread = 1; } $step = ($max_size - $min_size) / $spread; print '<div id="tags">'; foreach ($tags as $key => $value) { $size = ceil($min_size + ($value - $min_value) * $step); $a = new Html('a'); $a->attr('style', 'font-size: ' . $size . '%'); $a->attr('href', DB_LOC . '/tags/' . urlencode($key)); $a->data(str_replace('_', ' ', $key)); $a->write(); print '(' . $value . '), '; } print '<a href="' . DB_LOC . '/">all</a>'; print '</div>'; }
public function add($data) { $ContentModel = ContentModel::getInstance($this->_mid); if (!isset($this->_model[$this->_mid])) { $this->error = '模型不存在'; } $ContentInputModel = new ContentInputModel($this->_mid); $insertData = $ContentInputModel->get($data); if ($insertData == false) { $this->error = $ContentInputModel->error; return false; } if ($ContentModel->create($insertData)) { $result = $ContentModel->add($insertData); $aid = $result[$ContentModel->table]; $this->editTagData($aid); M('upload')->where(array('uid' => $_SESSION['uid']))->save(array('state' => 1)); //============记录动态 $DMessage = "发表了文章:<a target='_blank' href='" . U('Index/Index/content', array('mid' => $insertData['mid'], 'cid' => $insertData['cid'], 'aid' => $aid)) . "'>{$insertData['title']}</a>"; addDynamic($_SESSION['uid'], $DMessage); //内容静态 $Html = new Html(); $Html->content($this->find($aid)); $categoryCache = cache('category'); $cat = $categoryCache[$insertData['cid']]; $Html->relation_category($insertData['cid']); $Html->index(); return $aid; } else { $this->error = $ContentModel->error; return false; } }
public function create() { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $username = $_POST['username']; $password = password_hash($_POST['password'], PASSWORD_BCRYPT); $conn = Db::getConnection(); $sql = "SELECT *\n\t\t\t\tFROM users"; $q = $conn->prepare($sql); $q->execute(); $users = $q->fetchAll(\PDO::FETCH_ASSOC); $validator = new Validator(); $error = $validator->validateRegisterForm($_POST, $users); //echo '<pre>'; var_dump($error); echo '</pre>';die(); if ($error) { //echo '<pre>'; var_dump($error);die(); echo '</pre>'; $html = new Html($this->controllerName); $html->error = $error; //echo '<pre>'; var_dump($html->error);die(); echo '</pre>'; //;kweojn'dlfv'dlfkv $html->render('index'); } else { $newUserSql = "INSERT INTO users\n\t\t\t(`firstname`, `lastname`, `email`, `username`, `password`, `admin`)\n\t\t\tVALUES\n\t\t\t('{$firstname}', '{$lastname}', '{$email}', '{$username}', '{$password}', '0')"; $q = $conn->prepare($newUserSql); $q->execute(); header('Location: /login/index'); } }
public function placeLink(Html $row, DibiRow $data, $pres) { foreach ($row->getChildren() as $cell) { $inside = $cell->getText(); $cell->setText(''); $cell->add(Html::el('a')->href($this->link(":Front:{$pres}:", $data['link']))->setText($inside)); } }
function _before_add() { $html = new Html(); $fields_type = $this->_mod->site_model_fields(); $this->assign('fields_type', $html->select($fields_type, 'formtype')); $regexp = $this->_mod->regexp(); $this->assign('verification_select', $html->select($regexp, 'verification_select', '', 'id="J_verification_select" style="width:100px"')); }
private function getPreAuthPage() { $mainTag = new Html(); $head = new Head(); $head->addChild("\n <title>Admin page</title>\n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n <link rel='shortcut icon' href='images/system/favicon.ico' type='image/x-icon'/>\n <link rel='stylesheet' type='text/css' href='/src/front/style/style-less.css'/>\n <script type='text/javascript' src='/src/front/js/fixies.js'></script>\n <script type='text/javascript' src='/src/front/js/ext/jquery.js'></script>\n <script type='text/javascript' src='/src/front/js/ext/jquery-1.10.2.js'></script>\n <script type='text/javascript' src='/src/front/js/ext/tinycolor.js'></script>\n <script type='text/javascript' src='/src/front/js/v-utils.js'></script>\n <script type='text/javascript' src='/src/front/js/utils.js'></script>\n <script type='text/javascript' src='/src/front/js/admin.js'></script>\n <script type='text/javascript' src='/src/front/js/components/vCore-effects.js'></script>\n "); $body = new Body(); $body->addChild("\n <div class='admin_auth_container' >\n <div class='auth_header f-20'>Авторизация</div>\n <label class='f-15' for='user'>User</label>\n <input id='user'>\n <label class='f-15' for='password'>Password</label>\n <input id='password' type='password'>\n <button class='button f-20 input_hover'>Войти</button>\n </div>\n <script type='text/javascript'>\n /*inputHoverModule.update();*/\n </script>\n "); return $mainTag->addChildList([$head, $body]); }
public function deploy($element, $flag, $alias = '', $view = '', $schema = '') { $h = new Html(); if ($flag == 0) { $attr = '{"id":"' . $alias . '-' . $view . '"}'; $h->b($element, 0, 1, $schema, $attr); } else { $h->b($element, 1, 1); } }
public function getHtml() { $html = new Html(); $head = new Head(); $head->addChild("\n <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n <meta http-equiv='cache-control' content='max-age=0' />\n <meta http-equiv='cache-control' content='no-cache' />\n <meta http-equiv='expires' content='0' />\n <meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' />\n <meta http-equiv='pragma' content='no-cache' />\n <link rel='stylesheet' type='text/css' href='/src/front/style/admin-page.css'>\n "); $head->addChild(Components::getMenu()); $head->addChildList($this->getHeadContent()); $body = new Body(); $body->addChildList($this->getGeneralContent()); return $this->pagePrefix . $html->addChildList([$head, $body])->getHtml(); }
function _before_edit() { $html = new Html(); $advertising_list = $this->get_advertising(); $input_data = join(',', $advertising_list); $selected = $this->_mod->where(array('id' => $this->_get('id')))->getField('advertising'); $advertising = $html->input('select', 'advertising', $input_data, 'advertising', '', $selected); $this->assign('advertising', $advertising); //广告位 $this->assign('iframe_tools', true); //iFrame弹窗 }
public function testInterpret() { /** @var \Magento\Framework\View\Layout\Reader\Context $readerContext */ $readerContext = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\Layout\\Reader\\Context'); $pageXml = new \Magento\Framework\View\Layout\Element(__DIR__ . '/_files/_layout_update.xml', 0, true); $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>'); $html = new Html(); foreach ($pageXml->xpath('html') as $htmlElement) { $html->interpret($readerContext, $htmlElement, $parentElement); } $structure = $readerContext->getPageConfigStructure(); $this->assertEquals(['html' => ['test-name' => 'test-value']], $structure->getElementAttributes()); }
public function index() { $conn = Db::getConnection(); $articleModel = new Article(); $firstFiveArticles = $articleModel->getArticles($conn, 5); //var_dump($firstFiveArticles);die('lele'); foreach ($firstFiveArticles as &$article) { $article['time'] = $articleModel->formatArticleDate($article["time"]); //date("d.m.Y H:i",strtotime($article["time"])) } $html = new Html($this->controllerName); $html->firstFiveArticles = $firstFiveArticles; $html->render('home'); //var_dump($result);die(); }
public static function sendMessage($inputData) { $body = "\n\t\t\t<br>\n\t\t\tName: " . \Html::entities($inputData['name']) . "<br>\n\t\t\tEmail: " . \Html::entities($inputData['email']) . "<br>\n\t\t\tSubject: " . \Html::entities($inputData['subject']) . "<br>\n\t\t\tMessage: <br>" . \Html::entities($inputData['message']) . "<br>\n\t\t"; \Mail::send('templates.email.standard', array('body' => $body), function ($message) { $message->to(config('gtcms.adminEmail'))->subject(config('gtcms.contactMessageSubject')); }); }
/** * Render the special page boddy * @param string $par The username */ public function executeWhenAvailable($par = '') { $this->offset = $this->getRequest()->getVal('offset', false); if ($par) { // enter article history view $this->user = User::newFromName($par, false); if ($this->user && ($this->user->idForName() || User::isIP($par))) { // set page title as on desktop site - bug 66656 $username = $this->user->getName(); $out = $this->getOutput(); $out->addModuleStyles(array('mobile.pagelist.styles', 'mobile.pagesummary.styles')); $out->setHTMLTitle($this->msg('pagetitle', $this->msg('contributions-title', $username)->plain())->inContentLanguage()); if (User::isIP($par)) { $this->renderHeaderBar($par); } else { $this->renderHeaderBar($this->user->getUserPage()); } $res = $this->doQuery(); $out->addHtml(Html::openElement('div', array('class' => 'content-unstyled'))); $this->showContributions($res); $out->addHtml(Html::closeElement('div')); return; } } $this->showPageNotFound(); }
function displayValue($output_type, $row) { if (isset($row[$this->name]) && $row[$this->name]) { return Html::convDate($row[$this->name]); } return ''; }
public function fetchElement($name, $value, &$node, $control_name) { require_once dirname(__DIR__) . DS . 'models' . DS . 'poll.php'; $options = \Components\Poll\Models\Poll::all()->whereEquals('published', 1)->rows()->raw(); array_unshift($options, \Html::select('option', '0', '- ' . \Lang::txt('Select Poll') . ' -', 'id', 'title')); return \Html::select('genericlist', $options, $control_name . '[' . $name . ']', 'class="inputbox"', 'id', 'title', $value, $control_name . $name); }
static function showForGroup(Group $group) { global $DB; $ID = $group->getField('id'); if (!$group->can($ID, READ)) { return false; } $canedit = $group->can($ID, UPDATE); if ($canedit) { // Get data $item = new self(); if (!$item->getFromDB($ID)) { $item->getEmpty(); } $rand = mt_rand(); echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />"; echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='center'>"; Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl'])); echo "</td></tr>"; echo "</td><td class='center'>"; if ($item->fields["id"]) { echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>"; echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n class='submit'>"; } else { echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>"; } echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); } }
function OnPageLoad() { echo new XhtmlElement('h1', Html::Encode('Delete category: ' . $this->data_object->GetName())); if ($this->deleted) { ?> <p>The category has been deleted.</p> <p><a href="/yesnosorry/categorylist.php">View all categories</a></p> <?php } else { if ($this->has_permission) { ?> <p>Deleting a category cannot be undone.</p> <ul> <li>Its competitions will not be listed in a category</li> </ul> <p>Are you sure you want to delete this category?</p> <form action="<?php echo Html::Encode($this->data_object->GetDeleteCategoryUrl()); ?> " method="post" class="deleteButtons"> <div> <input type="submit" value="Delete category" name="delete" /> <input type="submit" value="Cancel" name="cancel" /> </div> </form> <?php } else { ?> <p>Sorry, you're not allowed to delete this category.</p> <p><a href="/yesnosorry/categorylist.php">Go back to the list of categories</a></p> <?php } } }
public static function validate_registration(Fieldset $form, $auth) { $form->field('password')->add_rule('match_value', $form->field('password2')->get_attribute('value')); $val = $form->validation(); $val->set_message('required', 'The field :field is required'); $val->set_message('valid_email', 'The field :field must be an email address'); $val->set_message('match_value', 'The passwords must match'); if ($val->run()) { $username = $form->field('username')->get_attribute('value'); $password = $form->field('password')->get_attribute('value'); $email = $form->field('email')->get_attribute('value'); try { $user = $auth->create_user($username, $password, $email); } catch (Exception $e) { $error = $e->getMessage(); } if (isset($user)) { $auth->login($username, $password); } else { if (isset($error)) { $li = $error; } else { $li = 'Something went wrong with creating the user!'; } $errors = Html::ul(array($li)); return array('e_found' => true, 'errors' => $errors); } } else { $errors = $val->show_errors(); return array('e_found' => true, 'errors' => $errors); } }
/** * Displays the reCAPTCHA widget. * If $this->recaptcha_error is set, it will display an error in the widget. * */ function getForm() { global $wgReCaptchaPublicKey, $wgReCaptchaTheme; $useHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'; $js = 'var RecaptchaOptions = ' . Xml::encodeJsVar(array('theme' => $wgReCaptchaTheme, 'tabindex' => 1)); return Html::inlineScript($js) . recaptcha_get_html($wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps); }
public function run() { AdminlteAsset::register($this->getView()); Html::addCssClass($this->options, ['widget' => 'progress']); if ($this->vertical) { Html::addCssClass($this->options, 'vertical'); } if (!empty($this->size)) { Html::addCssClass($this->options, $this->size); } $barOptions = ['class' => 'progress-bar']; if (!empty($this->type)) { Html::addCssClass($barOptions, 'progress-bar-' . $this->type); } if ($this->striped) { Html::addCssClass($barOptions, 'progress-bar-striped'); } $barOptions['style']['width'] = $this->value . '%'; if (empty($this->text)) { $text = ''; } else { $text = Html::tag('span', $text, ['class' => 'sr-only']); } return Html::tag('div', Html::tag('div', $text, $barOptions), $this->options); }
/** * Output a form to allow searching for a user */ function switchForm() { global $wgScript; $this->getOutput()->addModules('ext.centralauth.globaluserautocomplete'); $this->getOutput()->addModuleStyles('mediawiki.special'); $this->getOutput()->addHTML(Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1')) . Html::hidden('title', $this->getPageTitle()) . Xml::openElement('fieldset') . Xml::element('legend', array(), $this->msg('userrights-lookup-user')->text()) . Xml::inputLabel($this->msg('userrights-user-editname')->text(), 'user', 'username', 30, $this->mTarget, array('class' => 'mw-autocomplete-global-user')) . ' <br />' . Xml::submitButton($this->msg('editusergroup')->text()) . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n"); }
/** * Generates HTML for the uploads page for the passed user. * * @param User $user * @return string */ public function getUserUploadsPageHtml(User $user) { $uploadCount = $this->getUserUploadCount($user->getName()); $mobileContext = MobileContext::singleton(); $html = ''; $attrs = array(); if ($uploadCount !== false) { $threshold = $this->getUploadCountThreshold(); // FIXME: Use Html class? $html .= '<div class="content">'; if ($mobileContext->userCanUpload()) { $html .= '<div class="ctaUploadPhoto"></div>'; } if ($uploadCount > $threshold) { $msg = $this->msg('mobile-frontend-photo-upload-user-count-over-limit')->text(); } else { $msg = $this->msg('mobile-frontend-photo-upload-user-count')->numParams($uploadCount)->parse(); if ($uploadCount === 0) { $attrs = array('style' => 'display:none'); } } $html .= Html::openElement('h2', $attrs) . $msg . Html::closeElement('h2'); $html .= '</div>'; } return $html; }
/** * Helper function to display a hidden field for different versions * of MediaWiki. */ static function hiddenField( $name, $value ) { if ( class_exists( 'Html' ) ) { return "\t" . Html::hidden( $name, $value ) . "\n"; } else { return "\t" . Xml::hidden( $name, $value ) . "\n"; } }
function OnPreRender() { /* @var $o_season Season */ /* @var $o_team Team */ $this->SetCaption($this->o_competition->GetName()); $o_headings = new XhtmlRow(array('Name of team', 'Ground address', 'Contact details')); $o_headings->SetIsHeader(true); $this->AddRow($o_headings); foreach ($this->o_competition->GetLatestSeason()->GetTeams() as $o_team) { if ($o_team instanceof Team) { $o_row = new XhtmlRow(); $o_row->AddCell(new XhtmlAnchor(Html::Encode($o_team->GetName()), $o_team->GetEditTeamUrl())); $o_row->AddCell(new PostalAddressControl($o_team->GetGround()->GetAddress())); $private = $o_team->GetPrivateContact(); $public = $o_team->GetContact(); $private_header = '<h2 style="margin:0; font-size:1.1em; color: #900;">Private</h2>'; if ($private and $public) { $contact = $public . $private_header . $private; } else { $contact = $private ? $private_header . $private : $public; } $o_row->AddCell(nl2br(XhtmlMarkup::ApplySimpleTags(XhtmlMarkup::ApplyLinks($contact, true)))); $this->AddRow($o_row); } } parent::OnPreRender(); }
function showForm() { $this->getfromDB(1); $target = self::getFormURL(); echo "<div align='center'><form method='post' action=\"{$target}\">"; echo "<table class='tab_cadre' cellpadding='5'><tr ><th colspan='2'>"; echo self::getTypeName(0) . "</th></tr>"; echo "<tr class='tab_bg_1'><td>"; echo "<select name=\"unit\" size=\"1\"> "; echo "<option "; if ($this->isMetricUnit()) { echo "selected "; } echo "value='" . self::METRIC_UNIT . "'>" . __('metric', 'racks') . "</option>"; echo "<option "; if (!$this->isMetricUnit()) { echo "selected "; } echo "value='" . self::NON_METRIC_UNIT . "'>" . __('English', 'racks') . "</option>"; echo "</select> "; echo "</td>"; echo "<td>"; echo Html::hidden('id', array('value' => 1)); echo Html::submit(_sx('button', 'Post'), array('name' => 'update')); echo "</table>"; Html::closeForm(); echo "</div>"; }
public function testNestedCollection() { $html = new Html('html'); $head = $html->import('head'); $head->title('Example'); $data = $html->render(); $this->assertEquals('<html><head><title>Example</title></head></html>', $data); }