コード例 #1
0
ファイル: Admin.php プロジェクト: subashemphasize/test_site
 public function render(HTML_QuickForm2_Renderer $renderer)
 {
     if (method_exists($renderer->getJavascriptBuilder(), 'addValidateJs')) {
         $renderer->getJavascriptBuilder()->addValidateJs('errorElement: "span"');
     }
     return parent::render($renderer);
 }
コード例 #2
0
ファイル: Proxy.php プロジェクト: FluentDevelopment/piwik
 public function __toString()
 {
     if (method_exists($this->_renderer, '__toString')) {
         return $this->_renderer->__toString();
     }
     trigger_error("Fatal error: Object of class " . get_class($this->_renderer) . " could not be converted to string", E_USER_ERROR);
 }
コード例 #3
0
ファイル: login.php プロジェクト: yusukehirohara0903/test
 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');
 }
コード例 #4
0
 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());
 }
コード例 #5
0
ファイル: search.php プロジェクト: yusukehirohara0903/test
 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');
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
ファイル: package-edit.php プロジェクト: stof/pearweb
    }
}
$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 ?');
コード例 #10
0
ファイル: PEditAlbum.php プロジェクト: GunnarWinqvist/SSKL
    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("&amp;", "&", $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&amp;album=" . $idAlbum . "&amp;pict=" . $row->idPicture . "'>\n            <img src='" . WS_PICTUREARCHIVE . PA_THUMBPREFIX . $row->idPicture . ".jpg' />\n            </a>";
    }
    $result->close();
}
/*
コード例 #11
0
ファイル: sliiing.php プロジェクト: grlf/eyedock
 public function render(HTML_QuickForm2_Renderer $renderer)
 {
     $renderer->getJavascriptBuilder()->addElementJavascript($this->getJs());
     return parent::render($renderer);
 }
コード例 #12
0
 /**
  * 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]);
             }
             $calendar_new = array('date' => $data['date'], 'name' => $data['name'], 'shortname' => $data['shortname'], 'type' => $data['type'], 'content' => $data['entry_content'], 'rights' => $data['rights'], 'valid' => 1);
             // update calendar
             $calendar->update($calendar_new);
             // put entry to output
             // smarty-template
             $sCD = new JudoIntranetSmarty();
             // write entry
             try {
                 $calendar->write_db('update');
                 // smarty
                 $sCD->assign('data', $calendar->details_to_html());
                 return $sCD->fetch('smarty.calendar.details.tpl');
             } catch (Exception $e) {
                 $GLOBALS['Error']->handle_error($e);
                 return $GLOBALS['Error']->to_html($e);
             }
         } else {
             return $form->render($renderer);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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;
 }
コード例 #15
0
      .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>
コード例 #16
0
ファイル: LaraForm.php プロジェクト: larakit/lk
 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();
 }
コード例 #17
0
ファイル: Callback.php プロジェクト: grlf/eyedock
 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;
 }
コード例 #18
0
 /**
  * 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);
                     // get field name and value
                     $values = array();
                     foreach ($fields as $field) {
                         $values[] = $field->value_to_html();
                     }
                     // smarty
                     $sAe = new JudoIntranetSmarty();
                     $sAe->assign('a', $announcement);
                     for ($i = 0; $i < count($values); $i++) {
                         if (preg_match('/\\{\\$a\\..*\\}/U', $values[$i]['value'])) {
                             $values[$i]['value'] = $sAe->fetch('string:' . $values[$i]['value']);
                         }
                     }
                     $sAe->assign('v', $values);
                     return $sAe->fetch('smarty.announcement.edit.tpl');
                 } else {
                     return $form->render($renderer);
                 }
             } else {
                 // error
                 $errno = $GLOBALS['Error']->error_raised('WrongParams', 'entry:cid_or_pid', 'cid_or_pid');
                 $GLOBALS['Error']->handle_error($errno);
                 return $GLOBALS['Error']->to_html($errno);
             }
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('MissingParams', 'entry:cid_or_pid', 'cid_or_pid');
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
コード例 #19
0
ファイル: Hierselect.php プロジェクト: restiaka/Guinn-App-Gen
 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>";
 }
コード例 #20
0
 /**
  * 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) {
                         $img = array('src' => 'img/done.png', 'alt' => parent::lang('class.ProtocolView#correct#difflist#imgDone'), 'title' => parent::lang('class.ProtocolView#correct#difflist#imgDone'));
                     }
                     $list[] = array('href' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $correction['uid'], 'title' => parent::lang('class.ProtocolView#correct#difflist#correctedBy') . ': ' . $user->get_userinfo('name'), 'text' => $user->get_userinfo('name') . ' (' . date('d.m.Y', strtotime($correction['modified'])) . ')', 'img' => $img);
                 }
                 // smarty
                 $sPCo->assign('caption', parent::lang('class.ProtocolView#correct#difflist#caption'));
                 $sPCo->assign('list', $list);
             }
             // return
             return $sPCo->fetch('smarty.protocolcorrection.owner.tpl');
         } else {
             // get ProtocolCorretion object
             $correction = new ProtocolCorrection($protocol);
             // formular
             $form = new HTML_QuickForm2('correctProtocol', 'post', array('name' => 'correctProtocol', 'action' => 'protocol.php?id=correct&pid=' . $pid));
             $datasource = array('protocol' => $correction->get_protocol());
             // 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'));
             // submit-button
             $form->addElement('submit', 'submit', array('value' => parent::lang('class.ProtocolView#entry#form#submitButton')));
             // validate
             if ($form->validate()) {
                 // get form data
                 $data = $form->getValue();
                 $correctionUpdate = array('protocol' => $data['protocol'], 'modified' => date('U'), 'pid' => $pid);
                 // update protocol
                 $correction->update($correctionUpdate);
                 // write to db
                 $action = 'new';
                 if (ProtocolCorrection::hasCorrected($pid) === true) {
                     $action = 'update';
                 }
                 $correction->writeDb($action);
                 return parent::lang('class.ProtocolView#correct#message#done');
             } else {
                 return $form->render($renderer);
             }
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
コード例 #21
0
ファイル: QuickForm2.php プロジェクト: sergiokessler/perio
 /**
  * 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;
 }
コード例 #22
0
ファイル: Group.php プロジェクト: N3X15/ATBBS-Plus
 public function __toString()
 {
     require_once 'HTML/QuickForm2/Renderer.php';
     return $this->render(HTML_QuickForm2_Renderer::factory('default')->setTemplateForId($this->getId(), '{content}'))->__toString();
 }
コード例 #23
0
 public function testValidatorAlwaysPresentWhenClientRulesAdded()
 {
     $fieldset = new HTML_QuickForm2_Container_Fieldset();
     $repeat = new HTML_QuickForm2_Container_Repeat(null, null, array('prototype' => $fieldset));
     $fieldset->addText('foo')->addRule('required', 'Required!', null, HTML_QuickForm2_Rule::CLIENT_SERVER);
     $repeat->setIndexes(array());
     $renderer = HTML_QuickForm2_Renderer::factory('array');
     $renderer->getJavascriptBuilder()->setFormId('fake-repeat');
     $repeat->render($renderer);
     $this->assertContains('new qf.Validator', $renderer->getJavascriptBuilder()->getValidator());
 }
コード例 #24
0
ファイル: Callback.php プロジェクト: sergiokessler/perio
 public static function _renderGroup(HTML_QuickForm2_Renderer $renderer, HTML_QuickForm2_Container_Group $group)
 {
     $error = $group->getError();
     if ($error) {
         $html[] = '<div class="form-group error">';
         $renderer->errors[] = $error;
     } else {
         $html[] = '<div class="form-group">';
     }
     $html[] = "\n";
     $html[] = $renderer->renderLabel($group);
     $html[] = '<div class="form-control">';
     //        $html[] = '<div class="input inline">';
     $html[] = "\n";
     $separator = $group->getSeparator();
     /*
             foreach ($group as $element) {
                 echo '<pre>';
                 var_dump($element);
                 echo '</pre>';
                 //$elements[] = (string)$element;
             }
     */
     /*
             $elements[]  = (string)array_pop($group->getElements());
             echo '<pre>';
             //var_dump($elements);
             echo '</pre>';
             /*
             foreach($elements as $k => $v)
             {
                 $elements[$k] = (string)$elements[$k];
             }*/
     /*
         echo '<pre>';
         //var_dump($elements);
         echo '</pre>';
     */
     $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;
     if ($error) {
         $html[] = '<span class="help-inline">' . $error . '</span>';
     } else {
         $label = $group->getLabel();
         if (is_array($label) && !empty($label[1])) {
             $html[] = '<span class="help-block">' . $label[1] . '</span>';
         }
     }
     $html[] = "\n";
     //        $html[] = '</div>';
     $html[] = '</div>';
     $html[] = '</div><!-- of group -->';
     return implode('', $html);
     /*
     $break = HTML_Common2::getOption('linebreak');
     //$html[] = '<div class="row">';
     $error = $group->getError();
     if ($error) {
         $html[] = '<div class="form-inline control-group error">';
         $html[] = $renderer->renderLabel($group);
     
         if ($renderer->getOption('group_errors')) {
             $renderer->errors[] = $error;
         } else {
             $html[] = '<span class="help-inline">'.$error.'</span><br />';
         }
     } else {
         $html[] = '<span class="form-inline">';
         $html[] = $renderer->renderLabel($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[] = '</span>';
     //$html[] = '</div>';
     return implode($break, $html) . $break;
     */
 }
コード例 #25
0
ファイル: form_m.php プロジェクト: restiaka/Guinn-App-Gen
 function campaign_add($gid = 0)
 {
     if (!preg_match('/^[0-9]+$/', $gid)) {
         return 'Sorry No Related Content Available.';
     }
     $form = new HTMLQuickForm2('campaign', 'POST', 'action="' . site_url('admin/campaign/add/' . $gid) . '"');
     $form->setAttribute('enctype', 'multipart/form-data');
     /**/
     if ($gid) {
         $campaign = $this->campaign_m->detailCampaign($gid);
         if (!$campaign) {
             return 'Sorry No Related Content Available.';
         }
         $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('title' => $campaign['title'], 'description' => $campaign['description'], 'startdate' => $campaign['startdate'], 'upload_enddate' => $campaign['upload_enddate'], 'winner_selectiondate' => $campaign['winner_selectiondate'], 'enddate' => $campaign['enddate'], 'gid' => $campaign['GID'], 'media_has_uploadonce' => $campaign['media_has_uploadonce'], 'media_has_approval' => $campaign['media_has_approval'], 'media_has_fbcomment' => $campaign['media_has_fbcomment'], 'media_has_fblike' => $campaign['media_has_fblike'], 'media_has_vote' => $campaign['media_has_vote'], 'campaign_rules' => html_entity_decode($campaign['campaign_rules']), 'APP_APPLICATION_ID' => $campaign['APP_APPLICATION_ID'])));
     } else {
         $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('startdate' => date('Y-m-d H:i:s'), 'upload_enddate' => date('Y-m-d H:i:s'), 'enddate' => date('Y-m-d H:i:s'), 'winner_selectiondate' => date('Y-m-d H:i:s'))));
     }
     /**/
     $form->addElement('hidden', 'gid');
     $form->addElement('static', '', '', array('content' => '<b>Your Facebook Application Name/ID ?</b> <a href="' . site_url('admin/app/add') . '">Add</a>'));
     $fb_options[''] = 'Select Apps Name';
     if ($appIDrow = $this->db->get_results("SELECT APP_APPLICATION_ID, APP_APPLICATION_NAME \n\t\t\t\t\t\t\t\t\t\t\t   FROM campaign_app", 'ARRAY_A')) {
         foreach ($appIDrow as $conf) {
             $fb_options[$conf['APP_APPLICATION_ID']] = $conf['APP_APPLICATION_NAME'];
         }
     }
     $APP_APPLICATION_ID = $form->addElement('select', 'APP_APPLICATION_ID', '', array('options' => $fb_options));
     if (count($fb_options) <= 1) {
         $form->addElement('static', '', '', array('content' => '<b style="color:red;">*All APPLICATION ID has been registered please create new one! Please go to <a href="' . site_url('admin/app/add') . '">App</a> panel.</b>'));
     }
     $APP_APPLICATION_ID->addRule('required', 'Facebook App Name is required', null, HTML_QuickForm2_Rule::SERVER);
     $APP_APPLICATION_ID->addRule('callback', 'Can\'t change this, someone already registered', 'callback_validateAppID_availability');
     $form->addElement('static', '', '', array('content' => '<b>Title for your campaign ?</b>'));
     $stitle = $form->addElement('text', 'title', array('style' => ''));
     $form->addElement('static', '', '', array('content' => '<b>What is your campaign all about ?</b>'));
     $sdescription = $form->addElement('textarea', 'description', array('class' => 'mceNoEditor'));
     /* 		$allowed_maxfilesize = 1024*1024;
     		$allowed_mimetype = 'image/gif,image/jpeg,image/pjpeg,image/png';
     
     		$form->addElement('static','','',array('content'=>'<b>Upload Header Image for your Campaign ? (image width will be resize to 400px)</b>'));
     		$r_file = $form->addElement('file','image_header_uploadfile','size="80"');
     		$r_file->addRule('mimetype', 'Image is not valid file type', explode(',',$allowed_mimetype),HTML_QuickForm2_Rule::SERVER);
     		$r_file->addRule('maxfilesize', 'Image filesize is exceeded ', $allowed_maxfilesize,HTML_QuickForm2_Rule::SERVER);
     		
     		if($gid){
     			$form->addElement('static','','',array('content'=>'<img src="'.site_url('image/campaign')."?src=".$campaign['image_header'].'">'));
     		} */
     $date_set = $gid ? array('format' => 'dFY His', 'maxYear' => date('Y')) : array('format' => 'dFY His', 'minYear' => date('Y'), 'maxYear' => date('Y') + 1);
     $form->addElement('static', '', '', array('content' => '<b>When will your campaign will start ?</b>'));
     $startdate_group = $form->addElement('group');
     $startdate_group->addElement('date', 'startdate', '', $date_set, 'style="width:100px;"');
     $startdate_group->addRule('callback', 'Start Date with this Facebook App Name/ID cannot be Overlap with other Campaigns', 'callback_validateStartDate');
     $form->addElement('static', '', '', array('content' => '<b>When will Upload end ?</b>'));
     $upload_enddate_group = $form->addElement('group');
     $upload_enddate_group->addElement('date', 'upload_enddate', '', $date_set, 'style="width:100px;"');
     $upload_enddate_group->addRule('callback', 'Date must be longer than start date', 'callback_validateUploadEndDate');
     $form->addElement('static', '', '', array('content' => '<b>Judging and Announcement before campaign end ?</b>'));
     $winner_selectiondate_group = $form->addElement('group');
     $winner_selectiondate_group->addElement('date', 'winner_selectiondate', '', $date_set, 'style="width:100px;"');
     $winner_selectiondate_group->addRule('callback', 'Date must be longer than Upload date and shorter or the same as end date', 'callback_validateWinnerDate');
     $form->addElement('static', '', '', array('content' => '<b>When will your campaign end ?</b>'));
     $enddate_group = $form->addElement('group');
     $enddate_group->addElement('date', 'enddate', '', $date_set, 'style="width:100px;"');
     $enddate_group->addRule('callback', 'Date must be longer than upload end date', 'callback_validateEndDate');
     $form->addElement('static', '', '', array('content' => '<b>Set allowed media to be use for the contest ?</b>'));
     $fsAddFields = $form->addElement('group');
     $data_media_source = @$campaign['allowed_media_source'] ? explode(',', $campaign['allowed_media_source']) : array();
     foreach (array('youtube' => 'Youtube Only (Video)', 'file' => 'File Upload (Image Only)') as $k => $v) {
         $checked = count(array_intersect($data_media_source, explode(',', $k))) == count($data_media_source) ? 'checked = "checked"' : '';
         $fsAddFields->addElement('radio', 'allowed_media_source', $checked . "  value='" . $k . "' style='width:0px;'");
         $fsAddFields->addElement('static', '', '', array('content' => $v . '<br/>'));
     }
     $allowed_media_fields = $form->addElement('hidden', 'allowed_media_fields', array('style' => ''))->setValue("media_source=Upload Content Here&media_description=It's About");
     $allowed_mimetype = $form->addElement('hidden', 'allowed_mimetype', array('style' => ''))->setValue('image/gif,image/jpeg,image/pjpeg,image/png');
     $form->addElement('static', '', '', array('content' => '<b>Does User can only upload once ?</b>'));
     $media_has_uploadonce = $form->addElement('select', 'media_has_uploadonce', '', array('options' => array('1' => 'Yes', '0' => 'No')));
     $form->addElement('static', '', '', array('content' => '<b>Does the uploaded media has vote system ?</b>'));
     $media_has_approval = $form->addElement('select', 'media_has_vote', '', array('options' => array('1' => 'Yes', '0' => 'No')));
     $form->addElement('static', '', '', array('content' => '<b>Does the uploaded media need approval by admin before published ?</b>'));
     $media_has_approval = $form->addElement('select', 'media_has_approval', '', array('options' => array('1' => 'Yes', '0' => 'No')));
     $form->addElement('static', '', '', array('content' => '<b>Does media use Facebook Comments (Social Plugin) ?</b>'));
     $media_has_fbcomment = $form->addElement('select', 'media_has_fbcomment', '', array('options' => array('1' => 'Yes', '0' => 'No')));
     $form->addElement('static', '', '', array('content' => '<b>Does media use Facebook Like (Social Plugin) ?</b>'));
     $media_has_fblike = $form->addElement('select', 'media_has_fblike', '', array('options' => array('1' => 'Yes', '0' => 'No')));
     $form->addElement('static', '', '', array('content' => '<b>Define your Campaign Rules/FAQ ?</b>'));
     $campaign_rules = $form->addElement('textarea', 'campaign_rules', array('style' => 'height:400px', 'id' => 'campaign_rules'));
     $stitle->addRule('required', 'Title is required', null, HTML_QuickForm2_Rule::SERVER);
     $sdescription->addRule('required', 'Description is required', null, HTML_QuickForm2_Rule::SERVER);
     $button = $form->addElement('submit', '', 'value="Submit Campaign"');
     $html = array();
     if ($form->validate()) {
         $data = $form->getValue();
         unset($data['submit'], $data['_qf__campaign']);
         extract($data['startdate']);
         $data['startdate'] = $Y . '-' . $F . '-' . $d . ' ' . $H . ':' . $i . ':' . $s;
         extract($data['enddate']);
         $data['enddate'] = $Y . '-' . $F . '-' . $d . ' ' . $H . ':' . $i . ':' . $s;
         extract($data['upload_enddate']);
         $data['upload_enddate'] = $Y . '-' . $F . '-' . $d . ' ' . $H . ':' . $i . ':' . $s;
         extract($data['winner_selectiondate']);
         $data['winner_selectiondate'] = $Y . '-' . $F . '-' . $d . ' ' . $H . ':' . $i . ':' . $s;
         $data['allowed_media_fields'] = html_entity_decode($data['allowed_media_fields']);
         $allowed_media_source = explode(',', $data['allowed_media_source']);
         if ($media = array_intersect(array('plixi', 'twitpic', 'yfrog'), $allowed_media_source)) {
             $data['allowed_media_source'] = implode(',', $media);
             $data['allowed_media_type'] = 'image';
         } elseif ($media = array_intersect(array('youtube', 'facebook'), $allowed_media_source)) {
             $data['allowed_media_source'] = implode(',', $media);
             $data['allowed_media_type'] = 'video';
         } elseif ($media = array_intersect(array('file'), $allowed_media_source)) {
             $data['allowed_media_source'] = implode(',', $media);
             $data['allowed_media_type'] = 'image';
         }
         $ok = false;
         if ($gid) {
             if ($ok = $this->campaign_m->updateCampaign($data)) {
                 $this->notify->set_message('success', 'Data has been successfuly updated.');
             } else {
                 $this->notify->set_message('error', 'Data has failed to be updated.');
             }
         } else {
             unset($data['gid']);
             if ($ok = $this->campaign_m->addCampaign($data)) {
                 $this->notify->set_message('success', 'Data has been successfuly submitted.');
             } else {
                 $this->notify->set_message('error', 'Data has failed to be submitted.');
             }
         }
         if ($ok) {
             $form->removeChild($button);
             $form->toggleFrozen(true);
         }
     }
     $renderer = HTML_QuickForm2_Renderer::factory('default');
     $form_layout = $form->render($renderer);
     return $form_layout;
 }
コード例 #26
0
 public function testRenderStaticLabels()
 {
     $element = HTML_QuickForm2_Factory::createElement('text', 'static')->setLabel(array('a label', 'another label', 'foo' => 'named label'));
     $renderer = HTML_QuickForm2_Renderer::factory('array')->setOption('static_labels', false);
     $array = $element->render($renderer)->toArray();
     $this->assertInternalType('array', $array['label']);
     $array = $element->render($renderer->setOption('static_labels', true)->reset())->toArray();
     $this->assertEquals('a label', $array['label']);
     $this->assertEquals('another label', $array['label_2']);
     $this->assertEquals('named label', $array['label_foo']);
 }
コード例 #27
0
ファイル: PApplication.php プロジェクト: GunnarWinqvist/SSKL
    $text = "Ny anmälan till Svenska Skolföreningen i Kuala Lumpur. \n";
    foreach ($form->getValue() as $parameter => $value) {
        $text .= $parameter . "\t" . $value . "\n";
    }
    mail($eMailAdr, $subject, $text, $headers);
    $form->removeChild($submitButton);
    // Tag bort sänd-knappen.
    $form->removeChild($kommentar);
    // Tag bort kommentarer.
    $form->toggleFrozen(true);
    // Frys formuläret inför ny visning.
    if ($debugEnable) {
        $debug .= "eMailAdr=" . $eMailAdr . " subject=" . $subject . "text=" . $text . " headers=" . $headers . "<br />\r\n";
    }
}
$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 en 
            (<em>*</em>).'))->setTemplateForId('submit', '<div class="element">{element} or 
        <a href="/">Cancel</a></div>');
$form->render($renderer);
$mainTextHTML .= $renderer;
/*
 * Skriv ut sidan.
 */
$page = new CHTMLPage();
$pageTitle = "Application";
require TP_PAGES . 'rightColumn.php';
$page->printPage($pageTitle, $mainTextHTML, "", $rightColumnHTML);
?>

コード例 #28
0
ファイル: InputHidden.php プロジェクト: grlf/eyedock
 public function render(HTML_QuickForm2_Renderer $renderer)
 {
     $renderer->renderHidden($this);
     $this->renderClientRules($renderer->getJavascriptBuilder());
     return $renderer;
 }
コード例 #29
0
ファイル: nota_search.php プロジェクト: sergiokessler/perio
$form->addElement('select', 'provincia', $campo_medio)->setLabel('Provincia:')->loadOptions($pcia_select);
$form->addElement('text', 'medio', $campo_medio)->setLabel('Medio:');
$form->addElement('select', 'mencion')->setLabel('Mención:')->loadOptions($mencion_escala);
$form->addElement('select', 'valoracion')->setLabel('Valoración:')->loadOptions($valoracion_select);
$form->addElement('text', 'texto', $campo_largo)->setLabel('Texto:');
$form->addElement('date', 'fecha_carga_desde', $campo_corto, array('addEmptyOption' => true, 'emptyOptionText' => array('Y' => 'Anio:', 'M' => 'Mes:', 'd' => 'Dia:')))->setLabel('Fecha carga desde:');
$form->addElement('date', 'fecha_carga_hasta', $campo_corto, array('addEmptyOption' => true, 'emptyOptionText' => array('Y' => 'Anio:', 'M' => 'Mes:', 'd' => 'Dia:')))->setLabel('Fecha carga hasta:');
$submit = $form->addSubmit('btnSubmit', array('value' => 'Buscar'))->addClass(array('btn', 'btn-primary'));
////////////////////////////////////////////////////////////
// renderer fixes
function renderSubmit($renderer, $submit)
{
    return '<div class="form-actions">' . $submit . '</div>';
}
require_once 'HTML/QuickForm2/Renderer.php';
$renderer = HTML_QuickForm2_Renderer::factory('callback');
$renderer->setCallbackForId($submit->getId(), 'renderSubmit');
$renderer->setOption(array('errors_prefix' => 'El formulario contiene errores:', 'required_note' => '<span class="required">*</span> denota campos requeridos'));
////////////////////////////////////////////////////////////
include_once 'header.php';
echo '<div class="page-header">';
echo '  <img class="pull-right" src="img/logo_sumar_small.png">';
echo '  <h1>Búsqueda de notas</h1>';
echo '</div>';
// Output javascript libraries, needed by hierselect
//echo $renderer->getJavascriptBuilder()->getLibraries(true, true);
$form->render($renderer);
echo '<div class="noprint">';
echo $renderer;
echo '</div>';
if (isset($_GET['btnSubmit']) and $_GET['btnSubmit'] != '') {
コード例 #30
0
ファイル: View.php プロジェクト: neolf/PIWIK4MOBILE
 /**
  * Add form to view
  *
  * @param Piwik_QuickForm2 $form
  */
 public function addForm($form)
 {
     if ($form instanceof Piwik_QuickForm2) {
         static $registered = false;
         if (!$registered) {
             HTML_QuickForm2_Renderer::register('smarty', 'HTML_QuickForm2_Renderer_Smarty');
             $registered = true;
         }
         // Create the renderer object
         $renderer = HTML_QuickForm2_Renderer::factory('smarty');
         $renderer->setOption('group_errors', true);
         // build the HTML for the form
         $form->render($renderer);
         // assign array with form data
         $this->smarty->assign('form_data', $renderer->toArray());
         $this->smarty->assign('element_list', $form->getElementList());
     }
 }