本文整理汇总了PHP中HTML_QuickForm2_Renderer类的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm2_Renderer类的具体用法?PHP HTML_QuickForm2_Renderer怎么用?PHP HTML_QuickForm2_Renderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTML_QuickForm2_Renderer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render
public function render(HTML_QuickForm2_Renderer $renderer)
{
if (method_exists($renderer->getJavascriptBuilder(), 'addValidateJs')) {
$renderer->getJavascriptBuilder()->addValidateJs('errorElement: "span"');
}
return parent::render($renderer);
}
开发者ID:subashemphasize,项目名称:test_site,代码行数:7,代码来源:Admin.php
示例2: createForm
function createForm($form)
{
HTML_QuickForm2_Renderer::register('smarty', 'HTML_QuickForm2_Renderer_Smarty');
$renderer = HTML_QuickForm2_Renderer::factory('smarty');
$renderer->setOption('old_compat', true);
$renderer->setOption('group_errors', true);
// フォームの作成
$FormData = $form->render($renderer)->toArray();
$this->smarty->assign('form', $FormData);
$this->smarty->display('login.html');
}
开发者ID:yusukehirohara0903,项目名称:test,代码行数:11,代码来源:login.php
示例3: testGroupHiddens
public function testGroupHiddens()
{
$form = new HTML_QuickForm2('testGroupHiddens', 'post', null, false);
$hidden = $form->addHidden('aHiddenElement');
$renderer = HTML_QuickForm2_Renderer::factory('stub');
$renderer->setOption('group_hiddens', false);
$form->render($renderer);
$this->assertEquals(array(), $renderer->getHidden());
$renderer->setOption('group_hiddens', true);
$form->render($renderer);
$this->assertEquals(array($hidden->__toString()), $renderer->getHidden());
}
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:12,代码来源:StubTest.php
示例4: createForm
function createForm($form, $add_data = NULL)
{
// smartyインスタンス作成
$smarty = $this->getSmarty();
HTML_QuickForm2_Renderer::register('smarty', 'HTML_QuickForm2_Renderer_Smarty');
$renderer = HTML_QuickForm2_Renderer::factory('smarty');
$renderer->setOption('old_compat', true);
// フォームの作成
$FormData = $form->render($renderer)->toArray();
$smarty->assign('data', $add_data);
$smarty->assign('form', $FormData);
$smarty->display('search.html');
}
开发者ID:yusukehirohara0903,项目名称:test,代码行数:13,代码来源:search.php
示例5: renderForm
function renderForm($addHidden)
{
$this->initPossibleConditions();
$t = new Am_View();
$renderer = HTML_QuickForm2_Renderer::factory('array');
if (!$this->form) {
$this->createForm(array());
}
$this->form->render($renderer);
$t->assign('form', $renderer->toArray());
$t->assign('description', $this->getDescription(true));
$t->assign('serialized', $this->serialize());
$t->assign('hidden', $addHidden);
$t->assign('loadSearchOptions', Am_Controller::renderOptions($this->getLoadOptions(), $this->saved_search_id));
return $t->render($this->template);
}
开发者ID:subashemphasize,项目名称:test_site,代码行数:16,代码来源:Renderable.php
示例6: render
public function render(HTML_QuickForm2_Renderer $renderer)
{
// render as a normal select when frozen
if ($this->frozen) {
$renderer->renderElement($this);
} else {
$jsBuilder = $renderer->getJavascriptBuilder();
$this->renderClientRules($jsBuilder);
$jsBuilder->addLibrary('dualselect', 'dualselect.js', 'js/', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR);
$keepSorted = empty($this->data['keepSorted']) ? 'false' : 'true';
$jsBuilder->addElementJavascript("qf.elements.dualselect.init('{$this->getId()}', {$keepSorted});");
// Fall back to using the Default renderer if custom one does not have a plugin
if ($renderer->methodExists('renderDualSelect')) {
$renderer->renderDualSelect($this);
} else {
$renderer->renderElement($this);
}
}
return $renderer;
}
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:20,代码来源:dualselect.php
示例7: render
/**
* This element is rendered using renderHidden() method
*
* renderHidden() is used to
* - prevent using the standard element template as this button is
* expected to be hidden
* - render it above all other submit buttons since hidden elements
* are usually at the top of the form
*
* @param HTML_QuickForm2_Renderer Renderer instance
* @return HTML_QuickForm2_Renderer
*/
public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->renderHidden($this);
return $renderer;
}
开发者ID:restiaka,项目名称:Guinn-App-Gen,代码行数:17,代码来源:DefaultAction.php
示例8: report_error
}
}
$row = package::info((int) $_GET['id']);
if (empty($row['name'])) {
report_error('Illegal package id');
response_footer();
exit;
}
print_package_navigation($row['packageid'], $row['name'], '/package-edit.php?id=' . $row['packageid']);
$sth = $dbh->query('SELECT id, name FROM categories ORDER BY name');
while ($cat_row = $sth->fetchRow(DB_FETCHMODE_ASSOC)) {
$rows[$cat_row['id']] = $cat_row['name'];
}
$form = new HTML_QuickForm2('package-edit', 'post', array('action' => '/package-edit.php?id=' . $row['packageid']));
$form->removeAttribute('name');
$renderer = HTML_QuickForm2_Renderer::factory('default');
// Set defaults for the form elements
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('name' => htmlspecialchars($row['name']), 'license' => htmlspecialchars($row['license']), 'summary' => htmlspecialchars($row['summary']), 'description' => htmlspecialchars($row['description']), 'category' => (int) $row['categoryid'], 'homepage' => htmlspecialchars($row['homepage']), 'doc_link' => htmlspecialchars($row['doc_link']), 'bug_link' => htmlspecialchars($row['bug_link']), 'cvs_link' => htmlspecialchars($row['cvs_link']), 'unmaintained' => $row['unmaintained'] ? true : false, 'newpk_id' => (int) $row['newpk_id'], 'new_channel' => htmlspecialchars($row['new_channel']), 'new_package' => htmlspecialchars($row['new_package']))));
$form->addElement('text', 'name', array('maxlength' => "80", 'accesskey' => "c"))->setLabel('Pa<span class="accesskey">c</span>kage Name');
$form->addElement('text', 'license', array('maxlength' => "50", 'placeholder' => 'BSD'))->setLabel('License:');
$form->addElement('textarea', 'summary', array('cols' => "75", 'rows' => "7", 'maxlength' => "255"))->setLabel('Summary');
$form->addElement('textarea', 'description', array('cols' => "75", 'rows' => "12"))->setLabel('Description');
$form->addElement('select', 'category')->setLabel('Category:')->loadOptions($rows);
$manager = new Tags_Manager();
$sl = $form->addElement('select', 'tags', array('multiple' => 'multiple'))->setLabel('Tags:')->loadOptions(array('' => '(none)') + $manager->getTags(false, true));
$sl->setValue(array_keys($manager->getTags($row['name'], true)));
$form->addElement('text', 'homepage', array('maxlength' => 255, 'accesskey' => "O"))->setLabel('H<span class="accesskey">o</span>mepage:');
$form->addElement('text', 'doc_link', array('maxlength' => 255, 'placeholder' => 'http://example.com/manual'))->setLabel('Documentation URI:');
$form->addElement('url', 'bug_link', array('maxlength' => 255, 'placeholder' => 'http://example.com/bugs'))->setLabel('Bug Tracker URI:');
$form->addElement('url', 'cvs_link', array('maxlength' => 255, 'placeholder' => 'http://example.com/svn/trunk'))->setLabel('Web version control URI');
$form->addElement('checkbox', 'unmaintained')->setLabel('Is this package unmaintained ?');
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:package-edit.php
示例9: str_replace
if ($debugEnable) {
$form->removeChild($buttons);
// Remove buttons.
$form->toggleFrozen(true);
// Freeze the form for display.
$mainTextHTML .= "<a title='Vidare' href='?p={$redirect}'>\n <img src='images/accept.png' alt='Vidare' /></a> <br />\r\n";
} else {
$redirect = str_replace("&", "&", $redirect);
header('Location: ' . WS_SITELINK . "?p={$redirect}");
exit;
}
}
/*
* If the form is incorrect filled it is displayed again with comments.
*/
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_hiddens' => true, 'group_errors' => true, 'errors_prefix' => 'Följand information saknas eller är felaktigt ifylld:', 'errors_suffix' => '', 'required_note' => 'Obligatoriska fält är markerade med <em>*</em>'))->setTemplateForId('submit', '<div class="element">{element} or <a href="/">Cancel</a></div>');
$form->render($renderer);
$mainTextHTML .= "<h3>Formulär för att skapa ett nytt album eller editera ett \n gammalt.</h3><br />\r\n" . $renderer;
/*
* Add all thumbs in the album, if there are any, with possibility to
* chose signature picture.
*/
$query = "\n SELECT idPicture FROM {$tablePicture} \n WHERE picture_idAlbum = {$idAlbum};\n";
if ($idAlbum and $result = $dbAccess->SingleQuery($query)) {
$mainTextHTML .= "<h3>Välj signaturbild för albumet</h3>";
while ($row = $result->fetch_object()) {
$mainTextHTML .= "<a href='?p=sign_pict&album=" . $idAlbum . "&pict=" . $row->idPicture . "'>\n <img src='" . WS_PICTUREARCHIVE . PA_THUMBPREFIX . $row->idPicture . ".jpg' />\n </a>";
}
$result->close();
}
/*
开发者ID:GunnarWinqvist,项目名称:SSKL,代码行数:31,代码来源:PEditAlbum.php
示例10: render
public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->getJavascriptBuilder()->addElementJavascript($this->getJs());
return parent::render($renderer);
}
开发者ID:grlf,项目名称:eyedock,代码行数:5,代码来源:sliiing.php
示例11: edit
/**
* edit edits the given entry
*
* @param int $cid entry-id for calendar
* @return string html-string
*/
private function edit($cid)
{
// check rights
if (Rights::check_rights($cid, 'calendar')) {
// smarty-templates
$sD = new JudoIntranetSmarty();
// get calendar-object
$calendar = new Calendar($cid);
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.CalendarView#page#caption#edit') . ": \"{$cid}\" (" . $calendar->get_name() . ")");
// get rights
$cRights = $calendar->get_rights()->get_rights();
// check public access
$kPublicAccess = array_search(0, $cRights);
$publicAccess = false;
if ($kPublicAccess !== false) {
$publicAccess = true;
unset($cRights[$kPublicAccess]);
}
// prepare return
$return = '';
$form = new HTML_QuickForm2('edit_calendar_entry', 'post', array('name' => 'edit_calendar_entry', 'action' => 'calendar.php?id=edit&cid=' . $cid));
$now_year = (int) date('Y');
$year_min = $now_year;
$year_max = $now_year + 3;
// get datasource
$datasource = array('date' => $calendar->get_date(), 'name' => $calendar->get_name(), 'shortname' => $calendar->get_shortname(), 'type' => $calendar->return_type(), 'entry_content' => $calendar->get_content(), 'rights' => $cRights);
// add public access
if ($publicAccess) {
$datasource['public'] = 1;
}
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.CalendarView#entry#form#requiredNote'));
// elements
// date
$date = $form->addElement('text', 'date', array());
$date->setLabel(parent::lang('class.CalendarView#entry#form#date') . ':');
// rule
$date->addRule('required', parent::lang('class.CalendarView#entry#rule#required.date'));
$date->addRule('callback', parent::lang('class.CalendarView#entry#rule#check.date'), array($this, 'callback_check_date'));
// add jquery-datepicker
// smarty
$sD->assign('elementid', 'date-0');
$sD->assign('dateFormat', 'yy-mm-dd');
$sD->assign('dateValue', $calendar->get_date());
$this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
// name
$name = $form->addElement('text', 'name');
$name->setLabel(parent::lang('class.CalendarView#entry#form#name') . ':');
$name->addRule('required', parent::lang('class.CalendarView#entry#rule#required.name'));
$name->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('name.desc') . ']', $_SESSION['GC']->get_config('name.regexp'));
// shortname
$shortname = $form->addElement('text', 'shortname');
$shortname->setLabel(parent::lang('class.CalendarView#entry#form#shortname') . ':');
$shortname->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('name.desc') . ']', $_SESSION['GC']->get_config('name.regexp'));
// type
$options = array_merge(array(0 => '--'), Calendar::return_types());
$type = $form->addElement('select', 'type');
$type->setLabel(parent::lang('class.CalendarView#entry#form#type') . ':');
$type->loadOptions($options);
$type->addRule('required', parent::lang('class.CalendarView#entry#rule#required.type'));
$type->addRule('callback', parent::lang('class.CalendarView#entry#rule#check.select'), array($this, 'callback_check_select'));
// entry_content
$content = $form->addElement('textarea', 'entry_content');
$content->setLabel(parent::lang('class.CalendarView#entry#form#entry_content') . ':');
$content->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
// select rights
$options = $_SESSION['user']->return_all_groups('sort');
$rights = $form->addElement('select', 'rights', array('multiple' => 'multiple', 'size' => 5));
$rights->setLabel(parent::lang('class.CalendarView#entry#form#rights') . ':');
$rights->loadOptions($options);
// checkbox public
$rights = $form->addElement('checkbox', 'public');
$rights->setLabel(parent::lang('class.CalendarView#entry#form#public') . ':');
// submit-button
$form->addElement('submit', 'submit', array('value' => parent::lang('class.CalendarView#entry#form#submitButton')));
// validate
if ($form->validate()) {
// create calendar-object
$data = $form->getValue();
// check $data['rights']
if (!isset($data['rights'])) {
$data['rights'] = array();
}
// merge with own groups, add admin
$data['rights'] = array_merge($data['rights'], $_SESSION['user']->get_groups(), array(1));
// add public access
$kPublicAccess = array_search(0, $data['rights']);
if ($kPublicAccess === false && isset($data['public']) && $data['public'] == 1) {
$data['rights'][] = 0;
} elseif ($kPublicAccess !== false && !isset($data['public'])) {
unset($data['rights'][$kPublicAccess]);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.CalendarView.php
示例12: __toString
public function __toString()
{
HTML_QuickForm2_Loader::loadClass('HTML_QuickForm2_Renderer');
$renderer = $this->render(HTML_QuickForm2_Renderer::factory('default'));
return $renderer->__toString() . $renderer->getJavascriptBuilder()->getSetupCode(null, true);
}
开发者ID:WillSwales,项目名称:financial-maths-mediawiki,代码行数:6,代码来源:Container.php
示例13: getAssignFormRendered
protected function getAssignFormRendered()
{
$form = $this->getForm(self::FORM_ASSIGN);
$renderer = HTML_QuickForm2_Renderer::factory('array');
$form->render($renderer);
$form = $renderer->toArray();
$elements = array();
foreach ($form['elements'] as $element) {
$elements[$element['id']] = $element;
}
$form['elements'] = $elements;
return $form;
}
开发者ID:alexanderTsig,项目名称:arabic,代码行数:13,代码来源:AdminImportController.php
示例14: HTML_QuickForm2
.quickform div.errors ul { margin:0; }
.quickform div.error input { border-color: #C00; background-color: #FEF; }
.quickform div.qf-checkable label,
.quickform div.qf-checkable input { display: inline; float: none; }
.quickform div.qf-checkable div,
.quickform div.qf-message { margin-left: 170px; }
.quickform div.qf-message { font-size: 88%; color: #C00; }
</style>
<title>HTML_QuickForm2 default renderer example</title>
</head>
<body>
<?php
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer.php';
$form = new HTML_QuickForm2('example');
$fs = $form->addFieldset()->setLabel('Your information');
$username = $fs->addText('username')->setLabel('Username');
$username->addRule('required', 'Username is required');
$password = $fs->addPassword('pass')->setLabel(array('Password', 'Password should be 8 characters at minimum'));
$password->addRule('required', 'Password is required');
$form->addHidden('my_hidden1')->setValue('1');
$form->addHidden('my_hidden2')->setValue('2');
$form->addSubmit('submit', array('value' => 'Send', 'id' => 'submit'));
if ($form->validate()) {
$form->toggleFrozen(true);
}
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_hiddens' => true, 'group_errors' => true, 'required_note' => '<strong>Note:</strong> Required fields are marked with an asterisk (<em>*</em>).'))->setTemplateForId('submit', '<div class="element">{element} or <a href="/">Cancel</a></div>')->setTemplateForClass('HTML_QuickForm2_Element_Input', '<div class="element<qf:error> error</qf:error>"><qf:error>{error}</qf:error>' . '<label for="{id}" class="qf-label<qf:required> required</qf:required>">{label}</label>' . '{element}' . '<qf:label_2><div class="qf-label-1">{label_2}</div></qf:label_2></div>');
echo $form->render($renderer);
?>
</body>
</html>
开发者ID:andreaswarnaar,项目名称:HTML_QuickForm2.1,代码行数:31,代码来源:default-renderer.php
示例15: toString
function toString($tpl)
{
$renderer = \HTML_QuickForm2_Renderer::factory('larakit_form');
$this->render($renderer);
larajs()->addInline($renderer->getJavascriptBuilder()->getFormJavascript($this->getId(), false));
return \View::make($tpl, ['is_submited' => (bool) $this->isSubmitted(), 'form' => $renderer->toArray(), 'meta' => \Larakit\QuickForm\Register::$elements])->__toString();
}
开发者ID:larakit,项目名称:lk,代码行数:7,代码来源:LaraForm.php
示例16: _renderGroup
public static function _renderGroup(HTML_QuickForm2_Renderer $renderer, HTML_QuickForm2_Container_Group $group)
{
$break = HTML_Common2::getOption('linebreak');
$html[] = '<div class="row">';
$html[] = $renderer->renderLabel($group);
$error = $group->getError();
if ($error) {
$html[] = '<div class="element group error">';
if ($renderer->getOption('group_errors')) {
$renderer->errors[] = $error;
} else {
$html[] = '<span class="error">' . $error . '</span><br />';
}
} else {
$html[] = '<div class="element group">';
}
$separator = $group->getSeparator();
$elements = array_pop($renderer->html);
if (!is_array($separator)) {
$content = implode((string) $separator, $elements);
} else {
$content = '';
$cSeparator = count($separator);
for ($i = 0, $count = count($elements); $i < $count; $i++) {
$content .= (0 == $i ? '' : $separator[($i - 1) % $cSeparator]) . $elements[$i];
}
}
$html[] = $content;
$html[] = '</div>';
$html[] = '</div>';
return implode($break, $html) . $break;
}
开发者ID:grlf,项目名称:eyedock,代码行数:32,代码来源:Callback.php
示例17: edit
/**
* edit edits the entry
*
* @return string html-string
*/
private function edit()
{
// smarty-templates
$sD = new JudoIntranetSmarty();
// check rights
if (Rights::check_rights($this->get('cid'), 'calendar')) {
// check cid and pid given
if ($this->get('cid') !== false && $this->get('pid') !== false) {
// check cid and pid exists
if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.AnnouncementView#page#caption#edit'));
// prepare return
$return = '';
// get preset
$preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
// get fields
$fields = $preset->get_fields();
// formular
$form = new HTML_QuickForm2('edit_announcement', 'post', array('name' => 'edit_announcement', 'action' => 'announcement.php?id=edit&cid=' . $this->get('cid') . '&pid=' . $this->get('pid')));
// values
$datasource = array();
foreach ($fields as $field) {
// read values
$field->read_value();
// check type
if ($field->get_type() == 'text') {
// check defaults
$datasource['calendar-' . $field->get_id()]['manual'] = '';
$datasource['calendar-' . $field->get_id()]['defaults'] = 0;
if ($field->get_value() == '') {
$datasource['calendar-' . $field->get_id()]['defaults'] = 'd' . $field->get_defaults();
} else {
$datasource['calendar-' . $field->get_id()]['manual'] = $field->get_value();
}
} elseif ($field->get_type() == 'dbhierselect') {
// explode value
list($v_first, $v_second) = explode('|', $field->get_value(), 2);
// set values
$datasource['calendar-' . $field->get_id()][0] = $v_first;
$datasource['calendar-' . $field->get_id()][1] = $v_second;
} elseif ($field->get_type() == 'dbselect') {
// check multiple
if (strpos($field->get_value(), '|') !== false) {
// separate value
$values = explode('|', $field->get_value());
foreach ($values as $i => $value) {
$datasource['calendar-' . $field->get_id()][$i] = $value;
}
} else {
$datasource['calendar-' . $field->get_id()] = $field->get_value();
}
} else {
$datasource['calendar-' . $field->get_id()] = $field->get_value();
}
}
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.AnnouncementView#entry#form#requiredNote'));
// generate field-quickform and add to form
foreach ($fields as $field) {
// generate quickform
$field_id = $field->read_quickform(array(), true);
// check $field_id
if ($field_id != '' && $field->get_type() == 'date') {
// smarty
$sD->assign('elementid', $field_id . '-0');
$sD->assign('dateFormat', 'yy-mm-dd');
$sD->assign('dateValue', $field->get_value());
$this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
}
// add to form
$form->appendChild($field->get_quickform());
}
// submit-button
$form->addSubmit('submit', array('value' => parent::lang('class.AnnouncementView#edit#form#submitButton')));
// validate
if ($form->validate()) {
// get calendar
$calendar = new Calendar($this->get('cid'));
// prepare marker-array
$announcement = array('version' => date('dmy'));
// get data
$data = $form->getValue();
// insert values
foreach ($fields as $field) {
// values to db
$field->value($data[$field->get_table() . '-' . $field->get_id()]);
$field->write_db('update');
}
// add calendar-fields to array
$calendar->add_marks($announcement);
// add field-names and -values to array
$preset->add_marks($announcement);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.AnnouncementView.php
示例18: __toString
public function __toString()
{
require_once 'HTML/QuickForm2/Renderer.php';
$cr = HTML_Common2::getOption('linebreak');
return $this->render(HTML_QuickForm2_Renderer::factory('default')->setTemplateForId($this->getId(), '{content}'))->__toString() . "<script type=\"text/javascript\">{$cr}//<![CDATA[{$cr}" . $this->_generateInitScript() . "{$cr}//]]>{$cr}</script>";
}
开发者ID:restiaka,项目名称:Guinn-App-Gen,代码行数:6,代码来源:Hierselect.php
示例19: correct
/**
* correct handles the corrections of the protocol
*
* @param int $pid entry-id for protocol
* @return string html of the correction page
*/
private function correct($pid)
{
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#correct'));
// get protocol object
$protocol = new Protocol($pid);
$correctable = $protocol->get_correctable(false);
// js tiny_mce
$tmce = array('element' => 'protocol-0', 'css' => 'templates/protocols/tmce_' . $protocol->get_preset()->get_path() . '.css', 'transitem' => parent::lang('class.ProtocolView#new_entry#tmce#item'), 'transdecision' => parent::lang('class.ProtocolView#new_entry#tmce#decision'));
// smarty
$this->tpl->assign('tmce', $tmce);
// check rights
if (Rights::check_rights($pid, 'protocol', true) && (in_array($_SESSION['user']->get_id(), $correctable['correctors']) || $_SESSION['user']->get_userinfo('name') == $protocol->get_owner())) {
// check owner
if ($_SESSION['user']->get_userinfo('name') == $protocol->get_owner()) {
// smarty
$sPCo = new JudoIntranetSmarty();
// check action
if ($this->get('action') == 'diff' && $this->get('uid') !== false) {
// diff correction of $uid
// get correction
$correction = new ProtocolCorrection($protocol, $this->get('uid'));
// clean protocols for diff
$diffBase = html_entity_decode(preg_replace('/<.*>/U', '', $protocol->get_protocol()));
$diffNew = html_entity_decode(preg_replace('/<.*>/U', '', $correction->get_protocol()));
// smarty
$sJsDL = new JudoIntranetSmarty();
// activate difflib js-files
$this->tpl->assign('jsdifflib', true);
// set values for difflib
$difflib = array('protDiffBase' => 'protDiffBase-0', 'protDiffNew' => 'protDiffNew-0', 'protDiffOut' => 'diffOut', 'protDiffBaseCaption' => parent::lang('class.ProtocolView#correct#diff#baseCaption'), 'protDiffNewCaption' => parent::lang('class.ProtocolView#correct#diff#newCaption'));
// add difflib values to js-template
$sJsDL->assign('dl', $difflib);
$this->add_jquery($sJsDL->fetch('smarty.js-jsdifflib.tpl'));
// add diffOut to template
$sPCo->assign('diffOut', 'diffOut');
// build form
$form = new HTML_QuickForm2('diffCorrection', 'post', array('name' => 'diffCorrection', 'action' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid')));
$datasource = array('protocol' => $protocol->get_protocol(), 'protDiffBase' => $diffBase, 'protDiffNew' => $diffNew);
// add datasource
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.ProtocolView#entry#form#requiredNote'));
// elements
// protocol text
$protocolTA = $form->addElement('textarea', 'protocol');
$protocolTA->setLabel(parent::lang('class.ProtocolView#entry#form#protocol') . ':');
$protocolTA->addRule('regex', parent::lang('class.ProtocolView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
// checkbox to mark correction as finished
$finished = $form->addElement('checkbox', 'finished');
$finished->setLabel(parent::lang('class.ProtocolView#entry#form#finished') . ':');
// hidden textareas for texts to diff
$protocolBase = $form->addElement('textarea', 'protDiffBase');
$protocolNew = $form->addElement('textarea', 'protDiffNew');
// submit-button
$form->addElement('submit', 'submit', array('value' => parent::lang('class.ProtocolView#entry#form#submitButton')));
// add form to template
$sPCo->assign('c', true);
$sPCo->assign('form', $form->render($renderer));
// validate
if ($form->validate()) {
// get form data
$data = $form->getValue();
// check finished
if (!isset($data['finished'])) {
$data['finished'] = 0;
}
$correctionUpdate = array('finished' => $data['finished']);
$protocolUpdate = array('protocol' => $data['protocol']);
// update
$protocol->update($protocolUpdate);
$correction->update($correctionUpdate);
$protocol->writeDb('update');
$correction->writeDb('update');
// message
$message = array('message' => parent::lang('class.ProtocolView#correct#message#corrected'), 'href' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid'), 'title' => parent::lang('class.ProtocolView#correct#message#back'), 'text' => parent::lang('class.ProtocolView#correct#message#back'));
// assign to template
$sPCo->assign('c', false);
$sPCo->assign('message', $message);
}
} else {
// list all corrections
// get corrections
$corrections = ProtocolCorrection::listCorrections($pid);
// put information together
$list = array();
$user = new User();
foreach ($corrections as $correction) {
// change user
$user->change_user($correction['uid'], false, 'id');
// fill list
$img = false;
if ($correction['finished'] == 1) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.ProtocolView.php
示例20: render
/**
* Renders the form using the given renderer
*
* @param HTML_QuickForm2_Renderer Renderer instance
* @return HTML_QuickForm2_Renderer
*/
public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->startForm($this);
$renderer->getJavascriptBuilder()->setFormId($this->getId());
foreach ($this as $element) {
$element->render($renderer);
}
$this->renderClientRules($renderer->getJavascriptBuilder());
$renderer->finishForm($this);
return $renderer;
}
开发者ID:sergiokessler,项目名称:perio,代码行数:17,代码来源:QuickForm2.php
注:本文中的HTML_QuickForm2_Renderer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论