本文整理汇总了PHP中Horde_Variables类的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Variables类的具体用法?PHP Horde_Variables怎么用?PHP Horde_Variables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Horde_Variables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemove
public function testRemove()
{
$vars = new Horde_Variables(array('a' => 'a', 'b' => 'b', 'c' => array(1, 2, 3), 'd' => array('z' => 'z', 'y' => array('f' => 'f', 'g' => 'g'))));
$vars->remove('a');
$vars->remove('d[y][g]');
$this->assertNull($vars->a);
$this->assertEquals('b', $vars->b);
$this->assertEquals(array(1, 2, 3), $vars->c);
$this->assertEquals(array('z' => 'z', 'y' => array('f' => 'f')), $vars->d);
}
示例2: _handle
/**
*/
protected function _handle(Horde_Variables $vars)
{
// Avoid errors if 'input' isn't set and short-circuit empty searches.
if (!isset($vars->input)) {
$result = array();
} else {
$input = $vars->get($vars->input);
$result = strlen($input) ? $this->_handleAutoCompleter($input) : array();
}
return new Horde_Core_Ajax_Response_Prototypejs($result);
}
示例3: run
/**
* Expects:
* $vars
* $registry
* $notification
*/
public function run()
{
extract($this->_params, EXTR_REFS);
/* Set up the form variables and the form. */
$form_submit = $vars->get('submitbutton');
$channel_id = $vars->get('channel_id');
try {
$channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id);
} catch (Exception $e) {
Horde::log($e, 'ERR');
$notification->push(_("Invalid channel specified for deletion."), 'horde.message');
Horde::url('channels')->redirect();
exit;
}
/* If not yet submitted set up the form vars from the fetched channel. */
if (empty($form_submit)) {
$vars = new Horde_Variables($channel);
}
/* Check permissions and deny if not allowed. */
if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::DELETE, $channel_id)) {
$notification->push(_("You are not authorised for this action."), 'horde.warning');
throw new Horde_Exception_AuthenticationFailure();
}
$title = sprintf(_("Delete News Channel \"%s\"?"), $vars->get('channel_name'));
$form = new Horde_Form($vars, $title);
$form->setButtons(array(_("Delete"), _("Do not delete")));
$form->addHidden('', 'channel_id', 'int', true, true);
$msg = _("Really delete this News Channel? All stories created in this channel will be lost!");
$form->addVariable($msg, 'confirm', 'description', false);
if ($form_submit == _("Delete")) {
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
try {
$delete = $GLOBALS['injector']->getInstance('Jonah_Driver')->deleteChannel($info);
$notification->push(_("The channel has been deleted."), 'horde.success');
Horde::url('channels')->redirect();
exit;
} catch (Exception $e) {
$notification->push(sprintf(_("There was an error deleting the channel: %s"), $e->getMessage()), 'horde.error');
}
}
} elseif (!empty($form_submit)) {
$notification->push(_("Channel has not been deleted."), 'horde.message');
Horde::url('channels')->redirect();
exit;
}
$GLOBALS['page_output']->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, $vars, Horde::selfUrl(), 'post');
$GLOBALS['page_output']->footer();
}
示例4: _handle
/**
* Form variables used:
* - input
*/
protected function _handle(Horde_Variables $vars)
{
global $injector;
$args = array('html' => !empty($vars->html));
if (isset($vars->locale)) {
$args['locale'] = $vars->locale;
}
$input = $vars->get($vars->input);
try {
return new Horde_Core_Ajax_Response_Prototypejs($injector->getInstance('Horde_Core_Factory_SpellChecker')->create($args, $input)->spellCheck($input));
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
return array('bad' => array(), 'suggestions' => array());
}
}
示例5: __construct
/**
*/
public function __construct(Horde_Variables $vars)
{
global $conf, $injector, $registry;
$this->_userid = $registry->getAuth();
if ($conf['user']['change'] === true) {
$this->_userid = $vars->get('userid', $this->_userid);
} else {
try {
$this->_userid = Horde::callHook('default_username', array(), 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}
}
$this->_backends = $injector->getInstance('Passwd_Factory_Driver')->backends;
$this->_vars = $vars;
$this->_init();
}
示例6: html
public function html($active = true)
{
global $browser, $conf, $registry;
if (!$this->contact || !$this->contact->hasPermission(Horde_Perms::READ)) {
echo '<h3>' . _("The requested contact was not found.") . '</h3>';
return;
}
$vars = new Horde_Variables();
$form = new Turba_Form_Contact($vars, $this->contact);
$form->setOpenSection(Horde_Util::getFormData('section', 0));
/* Get the contact's history. */
$history = $this->contact->getHistory();
foreach ($history as $what => $when) {
$v = $form->addVariable($what == 'created' ? _("Created") : _("Last Modified"), 'object[__' . $what . ']', 'text', false, false);
$v->disable();
$vars->set('object[__' . $what . ']', $when);
}
echo '<div id="Contact"' . ($active ? '' : ' style="display:none"') . '>';
$form->renderInactive($form->getRenderer(), $vars);
/* Comments. */
if (!empty($conf['comments']['allow']) && $registry->hasMethod('forums/doComments')) {
try {
$comments = $registry->call('forums/doComments', array('turba', $this->contact->driver->getName() . '.' . $this->contact->getValue('__key'), 'commentCallback'));
} catch (Horde_Exception $e) {
Horde::log($e, 'DEBUG');
$comments = array();
}
}
if (!empty($comments['threads'])) {
echo '<br />' . $comments['threads'];
}
if (!empty($comments['comments'])) {
echo '<br />' . $comments['comments'];
}
echo '</div>';
if ($active && $browser->hasFeature('dom')) {
if ($this->contact->hasPermission(Horde_Perms::EDIT)) {
$edit = new Turba_View_EditContact($this->contact);
$edit->html(false);
}
if ($this->contact->hasPermission(Horde_Perms::DELETE)) {
$delete = new Turba_View_DeleteContact($this->contact);
$delete->html(false);
}
}
}
示例7: _content
/**
*/
protected function _content()
{
if (!($query = $this->_getQuery())) {
return '<p class="horde-content"><em>' . _("No query to run") . '</em></p>';
}
$vars = Horde_Variables::getDefaultVariables();
$tickets = $GLOBALS['whups_driver']->executeQuery($query, $vars);
return $this->_table($tickets, 'whups_block_query_' . $query->id);
}
示例8: __construct
public function __construct(&$object, $buttons)
{
$this->koward =& Koward::singleton();
parent::__construct(Horde_Variables::getDefaultVariables());
$this->setTitle(_("Object actions"));
$this->object = $object;
if (!empty($buttons)) {
$this->setButtons($buttons);
}
}
示例9: refreshContent
/**
* Handle user initiated block refresh. Set a private member to avoid
* BC issues with having to add a parameter to the _content method.
*
* @param Horde_Variables $vars
*
* @return string
*/
public function refreshContent($vars = null)
{
if (empty($vars) || empty($vars->location)) {
$this->_refreshParams = Horde_Variables::getDefaultVariables();
$this->_refreshParams->set('location', $this->_params['location']);
} else {
$this->_refreshParams = $vars;
}
return $this->_content();
}
示例10: testTwoAssignees
public function testTwoAssignees()
{
$share = array_shift($GLOBALS['nag_shares']->listShares('test@example.com'));
$share = $GLOBALS['nag_shares']->getShare($share->getName());
$share->addUserPermission('jane', Horde_Perms::READ);
$vars = Horde_Variables::getDefaultVariables();
$vars->set('tasklist_id', $share->getName());
$form = new Nag_Form_Task($vars, _("New Task"));
$this->assertEquals(array('jane' => 'jane', 'test@example.com' => 'test@example.com'), $this->_getAssignees($form));
}
示例11: appTests
/**
*/
public function appTests()
{
$ret = '<h1>Mail Server Support Test</h1>';
$vars = Horde_Variables::getDefaultVariables();
if ($vars->user && $vars->passwd) {
$ret .= $this->_doConnectionTest($vars);
}
$self_url = Horde::selfUrl()->add('app', 'imp');
Horde::startBuffer();
require IMP_TEMPLATES . '/test/mailserver.inc';
return $ret . Horde::endBuffer();
}
示例12: run
/**
* expects
* $notification
* $registry
* $vars
*/
public function run()
{
extract($this->_params, EXTR_REFS);
$form = new Jonah_Form_Feed($vars);
/* Set up some variables. */
$formname = $vars->get('formname');
$channel_id = $vars->get('channel_id');
/* Form not yet submitted and is being edited. */
if (!$formname && $channel_id) {
$vars = new Horde_Variables($GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id));
}
/* Get the vars for channel type. */
$channel_type = $vars->get('channel_type');
/* Check permissions and deny if not allowed. */
if (!Jonah::checkPermissions(Jonah::typeToPermName($channel_type), Horde_Perms::EDIT, $channel_id)) {
$notification->push(_("You are not authorised for this action."), 'horde.warning');
throw new Horde_Exception_AuthenticationFailure();
}
/* Output the extra fields required for this channel type. */
$form->setExtraFields($channel_id);
if ($formname && empty($changed_type)) {
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
try {
$save = $GLOBALS['injector']->getInstance('Jonah_Driver')->saveChannel($info);
$notification->push(sprintf(_("The feed \"%s\" has been saved."), $info['channel_name']), 'horde.success');
Horde::url('channels')->redirect();
exit;
} catch (Exception $e) {
$notification->push(sprintf(_("There was an error saving the feed: %s"), $e->getMessage()), 'horde.error');
}
}
}
$GLOBALS['page_output']->header(array('title' => $form->getTitle()));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('channels/edit.php'), 'post');
$GLOBALS['page_output']->footer();
}
示例13: display
/**
* Display form
*
* @param integer $form_id Form id dispaly
* @param string $target_url Target url to link form to
*/
public function display($form_id, $target_url = null)
{
/* Get the stored form information from the backend. */
try {
$form_info = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getForm($form_id, Horde_Perms::READ);
} catch (Horde_Exception $e) {
throw new Ulaform_Exception($e->getMessage());
}
if (!empty($form_info['form_params']['language'])) {
Horde_Nls::setLanguageEnvironment($form_info['form_params']['language']);
}
$vars = Horde_Variables::getDefaultVariables();
$vars->set('form_id', $form_id);
$form = new Horde_Form($vars);
$form->addHidden('', 'form_id', 'int', false);
$form->addHidden('', 'user_uid', 'text', false);
$form->addHidden('', 'email', 'email', false);
$vars->set('user_uid', $GLOBALS['registry']->getAuth());
$vars->set('email', $GLOBALS['prefs']->getValue('from_addr'));
try {
$fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($form_id);
} catch (Ulaform_Exception $e) {
throw new Ulaform_Exception($e->getMessage());
}
foreach ($fields as $field) {
/* In case of these types get array from stringlist. */
if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'mlenum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') {
$field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']);
}
/* Setup the field with all the parameters. */
$form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']);
}
/* Check if submitted and validate. */
$result = array('title' => $form_info['form_name']);
if ($form->validate()) {
$form->getInfo(null, $info);
try {
$GLOBALS['ulaform_driver']->submitForm($info);
return true;
} catch (Horde_Exception $e) {
throw new Ulaform_Exception(sprintf(_("Error submitting form. %s."), $e->getMessage()));
}
}
if (is_null($target_url)) {
$target_url = Horde::selfUrl(true);
}
Horde::startBuffer();
$form->renderActive(null, null, $target_url, 'post', 'multipart/form-data');
return array('title' => $form_info['form_name'], 'form' => Horde::endBuffer());
}
示例14: _content
protected function _content()
{
$vars = Horde_Variables::getDefaultVariables();
$formname = $vars->get('formname');
$done = false;
$form = new Horde_Form($vars);
$fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($this->_params['form_id']);
foreach ($fields as $field) {
/* In case of these types get array from stringlist. */
if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') {
$field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']);
}
/* Setup the field with all the parameters. */
$form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']);
}
if ($formname) {
$form->validate($vars);
if ($form->isValid() && $formname) {
$form->getInfo($vars, $info);
$info['form_id'] = $this->_params['form_id'];
try {
$submit = $GLOBALS['ulaform_driver']->submitForm($info);
$GLOBALS['notification']->push(_("Form submitted successfully."), 'horde.success');
$done = true;
} catch (Horde_Exception $e) {
$GLOBALS['notification']->push(sprintf(_("Error submitting form. %s."), $e->getMessage()), 'horde.error');
}
}
}
/* Render active or inactive, depending if submitted or
* not. */
$render_type = $done ? 'renderInactive' : 'renderActive';
/* Render the form. */
$renderer = new Horde_Form_Renderer();
$renderer->showHeader(false);
Horde::startBuffer();
$form->{$render_type}($renderer, $vars, Horde::selfUrl(true), 'post');
return Horde::endBuffer();
}
示例15: render
/**
* Render the table.
*
* @param array $data The data to render (unused).
*
* @return mixed The HTML needed to render the table or false if failed.
*/
public function render($data = null)
{
global $notification;
try {
$result = $this->getMetaData();
} catch (Hermes_Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
return false;
}
$varRenderer = new Horde_Core_Ui_VarRenderer_Html();
$html = '<h1 class="header">';
// Table title.
if (isset($this->_config['title'])) {
$html .= $this->_config['title'];
} else {
$html .= _("Table");
}
// Hook for icons and things
if (isset($this->_config['title_extra'])) {
$html .= $this->_config['title_extra'];
}
$html .= '</h1>';
// Column titles.
$html .= '<table class="time striped" id="hermes_time" cellspacing="0"><thead><tr class="item">';
foreach ($this->_metaData['sections']['data']['columns'] as $col) {
$html .= '<th' . (isset($col['colspan']) ? ' colspan="' . $col['colspan'] . '"' : '') . '>' . $col['title'] . '</th>';
}
$html .= '</tr></thead>';
// Display data.
try {
$data = $this->_getData();
} catch (Hermes_Exception $e) {
$notification->push($e, 'horde.error');
$data = array();
}
foreach ($this->_metaData['sections'] as $secname => $section) {
if (empty($data[$secname])) {
continue;
}
/* Open the table section, either a tbody or the tfoot. */
$html .= $secname == 'footer' ? '<tfoot>' : '<tbody>';
// This Horde_Variables object is populated for each table row
// so that we can use the Horde_Core_Ui_VarRenderer.
$vars = new Horde_Variables();
$form = null;
foreach ($data[$secname] as $row) {
$html .= '<tr>';
foreach ($row as $key => $value) {
$vars->set($key, $value);
}
foreach ($section['columns'] as $col) {
$value = null;
if (isset($row[$col['name']])) {
$value = $row[$col['name']];
}
$align = '';
if (isset($col['align'])) {
$align = ' align="' . htmlspecialchars($col['align']) . '"';
}
$colspan = '';
if (isset($col['colspan'])) {
$colspan = ' colspan="' . htmlspecialchars($col['colspan']) . '"';
}
$html .= "<td{$align}{$colspan}";
if (!empty($col['nobr'])) {
$html .= ' class="nowrap"';
}
$html .= '>';
// XXX: Should probably be done at the <tr> with a class.
if (!empty($row['strong'])) {
$html .= '<strong>';
}
if (isset($col['type']) && substr($col['type'], 0, 1) == '%') {
switch ($col['type']) {
case '%html':
if (!empty($row[$col['name']])) {
$html .= $row[$col['name']];
}
break;
}
} else {
$html .= $varRenderer->render($form, $this->_formVars[$secname][$col['name']], $vars);
}
if (!empty($row['strong'])) {
$html .= '</strong>';
}
$html .= '</td>';
}
$html .= '</tr>';
}
// Close the table section.
$html .= $secname == 'footer' ? '</tfoot>' : '</tbody>';
}
//.........这里部分代码省略.........