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); }
/** */ 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); }
/** * 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(); }
/** * 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()); } }
/** * Perform search * * @throws Mnemo_Exception */ protected function _doSearch() { $search_pattern = $this->_vars->get('search_pattern'); $search_type = $this->_vars->get('search_type'); $search_desc = $search_type == 'desc'; $search_body = $search_type == 'body'; if (!empty($search_pattern) && ($search_body || $search_desc)) { $search_pattern = '/' . preg_quote($search_pattern, '/') . '/i'; $search_result = array(); foreach ($this->_notes as $memo_id => $memo) { if ($search_desc && preg_match($search_pattern, $memo['desc']) || $search_body && preg_match($search_pattern, $memo['body'])) { $search_result[$memo_id] = $memo; } } $this->_notes = $search_result; } elseif ($search_type == 'tags') { // Tag search, use the browser. $this->_browser->clearSearch(); $tags = $GLOBALS['injector']->getInstance('Mnemo_Tagger')->split($this->_vars->get('search_pattern')); foreach ($tags as $tag) { $this->_browser->addTag($tag); } $this->_notes = $this->_browser->getSlice(); $this->_handleActions(false); return; } $this->_baseurl->add(array('actionID' => 'search_memos', 'search_pattern' => $search_pattern, 'search_type' => $search_type)); }
/** */ 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(); }
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); } } }
/** */ 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); }
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); } }
/** * 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(); }
public function testTwoAssignees() { $share = array_shift($GLOBALS['nag_shares']->listShares('*****@*****.**')); $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', '*****@*****.**' => '*****@*****.**'), $this->_getAssignees($form)); }
/** */ 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(); }
/** * 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(); }
/** * 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()); }
/** * Check token. * * @param array $actions The list of actions that require token checking. * * @return string The verified action ID. */ protected function _checkToken($actions) { global $notification, $session; $actionID = $this->vars->actionID; /* Run through the action handlers */ if (!empty($actions) && strlen($actionID) && in_array($actionID, $actions)) { try { $session->checkToken($this->vars->get(self::INGO_TOKEN)); } catch (Horde_Exception $e) { $notification->push($e); $actionID = null; } } return $actionID; }
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(); }
/** * 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>'; } $GLOBALS['page_output']->addScriptFile('stripe.js', 'horde'); return $html . '</table>'; }
/** * Check for, and handle, image editing actions. * * @param string $actionID The action identifier. * * @return boolean True if an action was handled, otherwise false. * @throws Ansel_Exception */ public static function editActions($actionID) { global $notification, $page_output, $registry; $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $gallery_id = Horde_Util::getFormData('gallery'); $image_id = Horde_Util::getFormData('image'); $date = Ansel::getDateParameter(); $page = Horde_Util::getFormData('page', 0); $watermark_font = Horde_Util::getFormData('font'); $watermark_halign = Horde_Util::getFormData('whalign'); $watermark_valign = Horde_Util::getFormData('wvalign'); $watermark = Horde_Util::getFormData('watermark', $GLOBALS['prefs']->getValue('watermark_text')); // Get the gallery object and style information. try { $gallery = $ansel_storage->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } switch ($actionID) { case 'modify': try { $image = $ansel_storage->getImage($image_id); $ret = Horde_Util::getFormData('ret', 'gallery'); } catch (Ansel_Exception $e) { $notification->push(_("Photo not found."), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } $title = sprintf(_("Edit properties :: %s"), $image->filename); // Set up the form object. $vars = Horde_Variables::getDefaultVariables(); if ($ret == 'gallery') { $vars->set('actionID', 'saveclose'); } else { $vars->set('actionID', 'savecloseimage'); } $form = new Ansel_Form_Image($vars, $title); $renderer = new Horde_Form_Renderer(); // Set up the gallery attributes. $vars->set('image_default', $image->id == $gallery->get('default')); $vars->set('image_desc', $image->caption); $vars->set('image_tags', implode(', ', $image->getTags())); $vars->set('image_originalDate', $image->originalDate); $vars->set('image_uploaded', $image->uploaded); $page_output->header(array('title' => $title)); $form->renderActive($renderer, $vars, Horde::url('image.php'), 'post', 'multipart/form-data'); $page_output->footer(); exit; case 'savecloseimage': case 'saveclose': case 'save': $title = _("Save Photo"); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied saving photo to this gallery."), 'horde.error'); Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery', 'page' => $page), $date), true)->redirect(); exit; } // Validate the form object. $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'save'); $renderer = new Horde_Form_Renderer(); $form = new Ansel_Form_Image($vars, _("Edit a photo")); // Update existing image. if ($form->validate($vars)) { $form->getInfo($vars, $info); // Replacing photo if (!empty($info['file0']['file'])) { try { $GLOBALS['browser']->wasFileUploaded('file0'); if (filesize($info['file0']['file'])) { $data = file_get_contents($info['file0']['file']); if (getimagesize($info['file0']['file']) === false) { $notification->push(_("The file you uploaded does not appear to be a valid photo."), 'horde.error'); unset($data); } } } catch (Horde_Browser_Exception $e) { } } $image = $ansel_storage->getImage($image_id); $image->caption = $vars->get('image_desc'); $image->setTags(explode(',', $vars->get('image_tags'))); $newDate = new Horde_Date($vars->get('image_originalDate')); $image->originalDate = (int) $newDate->timestamp(); if (!empty($data)) { try { $image->replace($data); } catch (Ansel_Exception $e) { $notification->push(_("There was an error replacing the photo."), 'horde.error'); } } $image->save(); if ($vars->get('image_default')) { if ($gallery->get('default') != $image_id) { // Changing default - force refresh of stack // If we have a default-pretty already, make sure we delete it $ids = unserialize($gallery->get('default_prettythumb')); if (is_array($ids)) { foreach ($ids as $imageId) { $gallery->removeImage($imageId, true); } } $gallery->set('default_prettythumb', ''); } $gallery->set('default', $image_id); $gallery->set('default_type', 'manual'); } elseif ($gallery->get('default') == $image_id) { // Currently set as default, but we no longer wish it. $gallery->set('default', 0); $gallery->set('default_type', 'auto'); // If we have a default-pretty already, make sure we delete it $ids = unserialize($gallery->get('default_prettythumb')); if (is_array($ids)) { foreach ($ids as $imageId) { $gallery->removeImage($imageId); } } $gallery->set('default_prettythumb', ''); } $gallery->save(); $imageurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page), $date), true); if ($actionID == 'save') { $imageurl->redirect(); } elseif ($actionID == 'saveclose') { $page_output->addInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();')); $page_output->outputInlineScript(); } else { $page_output->addInlineScript(array('window.opener.location.href = "' . $imageurl . '";', 'window.close();')); $page_output->outputInlineScript(); } exit; } break; case 'editimage': case 'cropedit': case 'resizeedit': $imageGenerator_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page), $date), true); $imageurl = Horde::url('image.php')->add(array_merge(array('gallery' => $gallery_id, 'slug' => $gallery->get('slug'), 'image' => $image_id, 'page' => $page), $date)); $galleryurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'page' => $page, 'view' => 'Gallery', 'slug' => $gallery->get('slug')), $date)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied editing the photo."), 'horde.error'); // Return to the image view. $imageGenerator_url->redirect(); exit; } // Retrieve image details. $image = $ansel_storage->getImage($image_id); $title = sprintf(_("Edit %s :: %s"), $gallery->get('name'), $image->filename); if ($actionID == 'cropedit') { $geometry = $image->getDimensions('full'); $x1 = 0; $y1 = 0; $x2 = $geometry['width']; $y2 = $geometry['height']; // js and css files $page_output->addScriptFile('scriptaculous/builder.js', 'horde'); $page_output->addScriptFile('scriptaculous/effects.js', 'horde'); $page_output->addScriptFile('scriptaculous/controls.js', 'horde'); $page_output->addScriptFile('scriptaculous/dragdrop.js', 'horde'); $page_output->addScriptFile('cropper.js'); $page_output->addInlineScript('imageCropper.init();', true); $page_output->addThemeStylesheet('cropper.css'); } elseif ($actionID == 'resizeedit') { // js and css files $geometry = $image->getDimensions('full'); $page_output->addScriptFile('scriptaculous/builder.js', 'horde'); $page_output->addScriptFile('scriptaculous/effects.js', 'horde'); $page_output->addScriptFile('scriptaculous/controls.js', 'horde'); $page_output->addScriptFile('scriptaculous/dragdrop.js', 'horde'); $page_output->addScriptFile('scriptaculous/slider.js', 'horde'); $page_output->addScriptFile('resizeimage.js'); $js = array('window.Ansel = window.Ansel || {}', 'Ansel.image_geometry = ' . Horde_Serialize::serialize($geometry, Horde_Serialize::JSON), "Ansel.slider = new Control.Slider(\n 'handle1',\n 'slider-track',\n {\n minimum: 1,\n maximum: Ansel.image_geometry['width'],\n sliderValue: Ansel.image_geometry['width'],\n handleImage: 'ansel_slider_img',\n axis: 'horizontal',\n onChange: function(e) { resizeImage(e * Ansel.image_geometry['width']); },\n onSlide: function(e) { resizeImage(e * Ansel.image_geometry['width']); }\n }\n );"); $page_output->addInlineScript($js, true); } $page_output->header(array('title' => $title)); $notification->notify(array('listeners' => 'status')); if ($actionID == 'cropedit') { require ANSEL_TEMPLATES . '/image/crop_image.inc'; } elseif ($actionID == 'resizeedit') { require ANSEL_TEMPLATES . '/image/resize_image.inc'; } else { require ANSEL_TEMPLATES . '/image/edit_image.inc'; } $page_output->footer(); exit; case 'watermark': if ($watermark) { $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create(); $name = $identity->getValue('fullname'); if (empty($name)) { $name = $registry->getAuth(); } // Set up array of possible substitutions. $watermark_array = array('%N' => $name, '%L' => $registry->getAuth()); $watermark = str_replace(array_keys($watermark_array), array_values($watermark_array), $watermark); $watermark = strftime($watermark); } if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied saving photo to this gallery."), 'horde.error'); // Return to the image view Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page, 'slug' => $gallery->get('slug')), $date), true)->redirect(); exit; } else { $image = $ansel_storage->getImage($image_id); $image->watermark('screen', $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->updateData($image->raw('screen'), 'screen'); Horde::url('image.php', true)->add(array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'actionID' => 'editimage', 'page' => $page), $date))->redirect(); exit; } case 'rotate90': case 'rotate180': case 'rotate270': case 'flip': case 'mirror': case 'grayscale': case 'crop': case 'resize': if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied saving photo to this gallery."), 'horde.error'); } else { try { $image = $ansel_storage->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } switch ($actionID) { case 'rotate90': case 'rotate180': case 'rotate270': $angle = intval(substr($actionID, 6)); try { $image->rotate('full', $angle); } catch (Ansel_Exception $e) { Horde::log($e->getMessage(), 'ERR'); $notification->push($e->getMessage(), 'horde.error'); $error = true; } break; case 'flip': try { $image->flip('full'); } catch (Ansel_Exception $e) { Horde::log($e->getMessage(), 'ERR'); $notification->push($e->getMessage(), 'horde.error'); $error = true; } break; case 'mirror': try { $image->mirror('full'); } catch (Ansel_Exception $e) { Horde::log($e->getMessage(), 'ERR'); $notification->push($e->getMessage(), 'horde.error'); $error = true; } break; case 'grayscale': try { $image->grayscale('full'); } catch (Ansel_Exception $e) { Horde::log($e->getMessage(), 'ERR'); $notification->push($e->getMessage(), 'horde.error'); $error = true; } break; case 'crop': $image->load('full'); $params = Horde_Util::getFormData('params'); list($x1, $y1, $x2, $y2) = explode('.', $params); try { $image->crop($x1, $y1, $x2, $y2); } catch (Ansel_Exception $e) { Horde::log($e->getMessage(), 'ERR'); $notification->push($e->getMessage(), 'horde.error'); $error = true; } break; case 'resize': $image->load('full'); $width = Horde_Util::getFormData('width'); $height = Horde_Util::getFormData('height'); try { $image->resize($width, $height, true); } catch (Ansel_Exception $e) { Horde::log($e->getMessage(), 'ERR'); $notification->push($e->getMessage(), 'horde.error'); $error = true; } break; } if (empty($error)) { $image->updateData($image->raw()); } } Horde::url('image.php', true)->add(array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'actionID' => 'editimage', 'page' => $page), $date))->redirect(); exit; case 'setwatermark': $title = _("Watermark"); try { $image = $ansel_storage->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image->getMessage(), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'previewcustomwatermark'); $form = new Ansel_Form_Watermark($vars, _("Watermark")); $renderer = new Horde_Form_Renderer(); $page_output->header(array('title' => $title)); $form->renderActive($renderer, $vars, Horde::url('image.php'), 'post'); $page_output->footer(); exit; case 'previewcustomwatermark': $imageurl = Horde::url('image.php', true)->add(array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'page' => $page, 'watermark' => $watermark, 'font' => $watermark_font, 'whalign' => $watermark_halign, 'wvalign' => $watermark_valign, 'actionID' => 'previewwatermark'), $date)); $page_output->addInlineScript(array('window.opener.location.href = "' . $imageurl . '";', 'window.close();')); $page_output->outputInlineScript(); exit; case 'previewgrayscale': case 'previewwatermark': case 'previewflip': case 'previewmirror': case 'previewrotate90': case 'previewrotate180': case 'previewrotate270': $title = _("Edit Photo"); $action = substr($actionID, 7); $image = $ansel_storage->getImage($image_id); $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename); $page_output->header(array('title' => $title)); require ANSEL_TEMPLATES . '/image/preview_image.inc'; $page_output->footer(); exit; case 'imagerotate90': case 'imagerotate180': case 'imagerotate270': $view = Horde_Util::getFormData('view'); $angle = intval(substr($actionID, 11)); $image = $ansel_storage->getImage($image_id); $image->rotate($view, $angle); $image->display($view); exit; case 'imageflip': $view = Horde_Util::getFormData('view'); $image = $ansel_storage->getImage($image_id); $image->flip($view); $image->display($view); exit; case 'imagemirror': $view = Horde_Util::getFormData('view'); $image = $ansel_storage->getImage($image_id); $image->mirror($view); $image->display($view); exit; case 'imagegrayscale': $view = Horde_Util::getFormData('view'); $image = $ansel_storage->getImage($image_id); $image->grayscale($view); $image->display($view); exit; case 'imagewatermark': $view = Horde_Util::getFormData('view'); $image = $ansel_storage->getImage($image_id); $image->watermark($view, $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->display($view); exit; case 'previewcrop': if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied editing the photo."), 'horde.error'); Ansel::getUrlFor('view', array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page))->redirect(); } else { $x1 = (int) Horde_Util::getFormData('x1'); $y1 = (int) Horde_Util::getFormData('y1'); $x2 = (int) Horde_Util::getFormData('x2'); $y2 = (int) Horde_Util::getFormData('y2'); $title = _("Crop"); $action = substr($actionID, 7); $image = $ansel_storage->getImage($image_id); $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename); $params = $x1 . '.' . $y1 . '.' . $x2 . '.' . $y2; $page_output->header(array('title' => $title)); require ANSEL_TEMPLATES . '/image/preview_cropimage.inc'; $page_output->footer(); } exit; case 'imagecrop': if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $params = Horde_Util::getFormData('params'); list($x1, $y1, $x2, $y2) = explode('.', $params); $image = $ansel_storage->getImage($image_id); $image->load('full'); $image->crop($x1, $y1, $x2, $y2); $image->display(); } exit; } return false; }
/** * Saves the sort order to the preferences backend. * * @param Horde_Variables $vars Variables object. * @param string $source Source. */ public static function setPreferredSortOrder(Horde_Variables $vars, $source) { if (!strlen($sortby = $vars->get('sortby'))) { return; } $sources = self::getColumns(); $columns = isset($sources[$source]) ? $sources[$source] : array(); $column_name = self::getColumnName($sortby, $columns); $append = true; $ascending = $vars->get('sortdir') == 0; if ($vars->get('sortadd')) { $sortorder = self::getPreferredSortOrder(); foreach ($sortorder as $i => $elt) { if ($elt['field'] == $column_name) { $sortorder[$i]['ascending'] = $ascending; $append = false; } } } else { $sortorder = array(); } if ($append) { $sortorder[] = array('ascending' => $ascending, 'field' => $column_name); } $GLOBALS['prefs']->setValue('sortorder', serialize($sortorder)); }
/** * Return the HTML representing this view. * * @return string The HTML. * */ public function html() { global $conf, $prefs, $registry; $vars = Horde_Variables::getDefaultVariables(); if (!empty($this->_params['page'])) { $vars->add('page', $this->_params['page']); } if (!empty($this->_params['pager_url'])) { $this->_pagerurl = $this->_params['pager_url']; $override = true; } else { $override = false; $this->_pagerurl = Ansel::getUrlFor('view', array('owner' => $this->_owner, 'special' => $this->_special, 'groupby' => $this->_view->groupby, 'view' => 'List')); } $p_params = array('num' => $this->_view->numGalleries, 'url' => $this->_pagerurl, 'perpage' => $this->_view->gPerPage); if ($override) { $p_params['url_callback'] = null; } $this->_pager = new Horde_Core_Ui_Pager('page', $vars, $p_params); $preserve = array('sort_dir' => $this->_view->sortDir); if (!empty($this->_view->sortBy)) { $preserve['sort'] = $this->_view->sortBy; } $this->_pager->preserve($preserve); if ($this->_view->numGalleries) { $min = $this->_page * $this->_view->gPerPage; $max = $min + $this->_view->gPerPage; if ($max > $this->_view->numGalleries) { $max = $this->_view->numGalleries - $min; } $this->_view->start = $min + 1; $this->_view->end = min($this->_view->numGalleries, $min + $this->_view->gPerPage); if ($this->_owner) { $this->_view->refresh_link = Ansel::getUrlFor('view', array('groupby' => $this->_view->groupby, 'owner' => $this->_owner, 'page' => $this->_page, 'view' => 'List')); } else { $this->_view->refresh_link = Ansel::getUrlFor('view', array('view' => 'List', 'groupby' => $this->_view->groupby, 'page' => $this->_page)); } // Get top-level / default gallery style. if (empty($this->_params['style'])) { $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle')); } else { $style = Ansel::getStyleDefinition($this->_params['style']); } // Final touches. if (empty($this->_params['api'])) { $this->_view->breadcrumbs = Ansel::getBreadcrumbs(); $this->_view->groupbyUrl = strval(Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'owner'))); } $this->_view->pager = $this->_pager->render(); $this->_view->style = $style; $this->_view->tilesperrow = $prefs->getValue('tilesperrow'); $this->_view->cellwidth = round(100 / $this->_view->tilesperrow); $this->_view->params = $this->_params; $GLOBALS['page_output']->addScriptFile('views/common.js'); return $this->_view->render('list'); } return ' '; }
<?php /** * $Id: delete_event.php,v 1.1 2010/10/24 17:24:39 pety Exp pety $ * * Copyright 2007-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * * @author Peter Sagi <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('cloudbank'); require_once CLOUDBANK_BASE . '/lib/Cloudbank.php'; require_once CLOUDBANK_BASE . '/lib/Book.php'; /* main() */ $g_variables =& Horde_Variables::getDefaultVariables(); $g_account_id = $g_variables->get('account_id'); $g_event_id = $g_variables->get('event_id'); try { Book::Singleton()->deleteEvent($g_event_id); header('Location: ' . Horde::url('events.php', true)->add(array('ledger_account_id' => $g_account_id, 'ledger_account_type' => CloudBankConsts::LedgerAccountType_Account), NULL, false)); } catch (Exception $v_exception) { Cloudbank::PushError(Book::XtractMessage($v_exception)); $page_output->header(); $notification->notify(array('listeners' => 'status')); $page_output->footer(); }
/** * Gets the upload and sets up the upload data array. Either * fetches an upload done with this submit or retrieves stored * upload info. * @param Horde_Variables $vars The form state to check this field for * @param Horde_Form_Variable $var The Form field object to check * */ function _getUpload(&$vars, &$var) { global $session; /* Don't bother with this function if already called and set * up vars. */ if (!empty($this->_img)) { return true; } /* Check if file has been uploaded. */ $varname = $var->getVarName(); try { $GLOBALS['browser']->wasFileUploaded($varname . '[new]'); $this->_uploaded = true; /* A file has been uploaded on this submit. Save to temp dir for * preview work. */ $this->_img['img']['type'] = $this->getUploadedFileType($varname . '[new]'); /* Get the other parts of the upload. */ Horde_Array::getArrayParts($varname . '[new]', $base, $keys); /* Get the temporary file name. */ $keys_path = array_merge(array($base, 'tmp_name'), $keys); $this->_img['img']['file'] = Horde_Array::getElement($_FILES, $keys_path); /* Get the actual file name. */ $keys_path = array_merge(array($base, 'name'), $keys); $this->_img['img']['name'] = Horde_Array::getElement($_FILES, $keys_path); /* Get the file size. */ $keys_path = array_merge(array($base, 'size'), $keys); $this->_img['img']['size'] = Horde_Array::getElement($_FILES, $keys_path); /* Get any existing values for the image upload field. */ $upload = $vars->get($var->getVarName()); if (!empty($upload['hash'])) { $upload['img'] = $session->get('horde', 'form/' . $upload['hash']); $session->remove('horde', 'form/' . $upload['hash']); } /* Get the temp file if already one uploaded, otherwise create a * new temporary file. */ if (!empty($upload['img']['file'])) { $tmp_file = Horde::getTempDir() . '/' . $upload['img']['file']; } else { $tmp_file = Horde::getTempFile('Horde', false); } /* Move the browser created temp file to the new temp file. */ move_uploaded_file($this->_img['img']['file'], $tmp_file); $this->_img['img']['file'] = basename($tmp_file); } catch (Horde_Browser_Exception $e) { $this->_uploaded = $e; /* File has not been uploaded. */ $upload = $vars->get($var->getVarName()); /* File is explicitly removed */ if ($vars->get('remove_' . $var->getVarName())) { $this->_img = null; $session->remove('horde', 'form/' . $upload['hash']); return; } if ($this->_uploaded->getCode() == 4 && !empty($upload['hash']) && $session->exists('horde', 'form/' . $upload['hash'])) { $this->_img['img'] = $session->get('horde', 'form/' . $upload['hash']); $session->remove('horde', 'form/' . $upload['hash']); if (isset($this->_img['error'])) { $this->_uploaded = PEAR::raiseError($this->_img['error']); } } } if (isset($this->_img['img'])) { $session->set('horde', 'form/' . $this->getRandomId(), $this->_img['img']); } }
<?php /** * Copyright 2003-2015 Horde LLC (http://www.horde.org/) * * See the enclosed file LICENSE for license information (BSD). If you * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE. * * @author Chuck Hagenbuch <*****@*****.**> * @author Marko Djukic <*****@*****.**> * @author Michael J. Rubinsky <*****@*****.**> * @package Jonah */ require_once __DIR__ . '/../lib/Application.php'; Horde_Registry::appInit('jonah'); $params = array('vars' => Horde_Variables::getDefaultVariables(), 'registry' => &$registry, 'notification' => &$notification); $view = new Jonah_View_ChannelEdit($params); $view->run();
/** * Creates any form objects if they have not been initialised yet. */ protected function _formInit() { if (is_null($this->_vars)) { /* No existing vars set, get them now. */ $this->_vars = Horde_Variables::getDefaultVariables(); } if (!$this->_form instanceof Horde_Form) { /* No existing valid form object set so set up a new one. */ $this->_form = new Horde_Form($this->_vars); } }
} else { $form1->renderActive($renderer, $vars, $adminurl, 'post'); } } break; case 'whups_form_admin_editreplysteptwo': $form = new Whups_Form_Admin_EditReplyStepTwo($vars); $vars->set('action', 'type'); if ($vars->get('formname') == 'whups_form_admin_editreplysteptwo' && $form->validate($vars)) { try { $whups_driver->updateReply($vars->get('reply'), $vars->get('reply_name'), $vars->get('reply_text')); $notification->push(_("The form reply has been modified."), 'horde.success'); _open(); $form->renderInactive($renderer, $vars); echo '<br />'; $vars = new Horde_Variables(array('type' => $vars->get('type'))); } catch (Whups_Exception $e) { $notification->push(_("There was an error editing the form reply:") . ' ' . $e->getMessage(), 'horde.error'); } _open(); $form1 = new Whups_Form_Admin_EditReplyStepOne($vars); $form1->renderActive($renderer, $vars, $adminurl, 'post'); echo '<br />'; $form2 = new Whups_Form_Admin_AddReply($vars); $form2->renderActive($renderer, $vars, $adminurl, 'post'); } else { _open(); $form->renderActive($renderer, $vars, $adminurl, 'post'); } break; case 'whups_form_admin_deletereply':
public static function getAdminTabs() { $tabname = Horde_Util::getFormData('view'); $tabs = new Horde_Core_Ui_Tabs('view', Horde_Variables::getDefaultVariables()); $tabs->addTab(_("Telephone Numbers"), Horde::url('admin/numbers.php'), array('view' => 'numbers', id => 'tabnumbers')); $tabs->addTab(_("Accounts"), Horde::url('admin/accounts.php'), array('view' => 'accounts', id => 'tabaccounts')); if ($view === null) { $view = 'numbers'; } echo $tabs->render($view); }
<?php /** * Copyright 2001-2002 Robert E. Coyle <*****@*****.**> * Copyright 2001-2014 Horde LLC (http://www.horde.org/) * * See the enclosed file LICENSE for license information (BSD). If you * did not receive this file, see http://www.horde.org/licenses/bsdl.php. */ require_once __DIR__ . '/../lib/Application.php'; Horde_Registry::appInit('whups'); $empty = ''; $beendone = 0; $wereerrors = 0; $vars = Horde_Variables::getDefaultVariables($empty); $formname = $vars->get('formname'); Whups::addTopbarSearch(); $form1 = new Whups_Form_Ticket_CreateStepOne($vars); $form2 = new Whups_Form_Ticket_CreateStepTwo($vars); $form3 = new Whups_Form_Ticket_CreateStepThree($vars); $form4 = new Whups_Form_Ticket_CreateStepFour($vars); $r = new Horde_Form_Renderer(array('varrenderer_driver' => array('whups', 'whups'))); $valid4 = $form4->validate($vars) && $formname == 'whups_form_ticket_createstepfour'; $valid3 = $form3->validate($vars, true); $valid2 = $form2->validate($vars, !$form1->isSubmitted()); $valid1 = $form1->validate($vars, true); $doAssignForm = $GLOBALS['registry']->getAuth() && $whups_driver->isCategory('assigned', $vars->get('state')); if ($valid1 && $valid2 && $valid3 && (!$doAssignForm || $valid4)) { $form1->getInfo($vars, $info); $form2->getInfo($vars, $info); $form3->getInfo($vars, $info);
$vars->set('account', $curaccount); $Form = new ExtensionDeleteForm($vars); $FormValid = $Form->validate($vars, true); if ($Form->isSubmitted() && $FormValid) { try { $Form->execute(); $notification->push(_("Extension Deleted.")); $action = 'list'; } catch (Exception $e) { $notification->push($e); } } elseif ($Form->isSubmitted()) { // Submitted but not valid $notification->push(_("Problem processing the form. Please check below and try again."), 'horde.warning'); } $vars = Horde_Variables::getDefaultVariables(array()); $vars->set('account', $curaccount); $Form = new ExtensionDeleteForm($vars); break; case 'list': default: $action = 'list'; $title .= _("List Numbers"); } try { $accounts = $shout->storage->getAccounts(); $numbers = $shout->storage->getNumbers(); } catch (Exception $e) { $notification->push($e); } $page_output->addScriptFile('stripe.js', 'horde');
/** * Copyright 2002-2016 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. * * @author Chuck Hagenbuch <*****@*****.**> */ require_once __DIR__ . '/../../lib/Application.php'; Horde_Registry::appInit('kronolith'); // Exit if this isn't an authenticated administrative user. $default = Horde::url($prefs->getValue('defaultview') . '.php', true); if (!$registry->isAdmin()) { $default->redirect(); } $vars = Horde_Variables::getDefaultVariables(); try { $resource = Kronolith::getDriver('Resource')->getResource($vars->get('c')); if (!$resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $notification->push(_("You are not allowed to delete this resource group."), 'horde.error'); $default->redirect(); } } catch (Exception $e) { $notification->push($e); $default->redirect(); } $form = new Kronolith_Form_DeleteResourceGroup($vars, $resource); // Execute if the form is valid (must pass with POST variables only). if ($form->validate(new Horde_Variables($_POST))) { try { $form->execute();
/** * Generates the configuration file items for a part of the configuration * tree. * * @param array $section An associative array containing the * part of the traversed XML * configuration tree that should be * processed. * @param string $prefix A configuration prefix determining * the current position inside the * configuration file. This prefix will * be translated to keys of the $conf * array in the generated configuration * file. * @param Horde_Variables $formvars The processed configuration form * data. */ protected function _generatePHPConfig($section, $prefix, $formvars) { if (!is_array($section)) { return; } foreach ($section as $name => $configitem) { if (is_array($configitem) && isset($configitem['tab'])) { continue; } $prefixedname = empty($prefix) ? $name : $prefix . '|' . $name; $configname = str_replace('|', '__', $prefixedname); $quote = !isset($configitem['quote']) || $configitem['quote'] !== false; if ($configitem == 'placeholder') { $this->_phpConfig .= '$conf[\'' . str_replace('|', '\'][\'', $prefix) . "'] = array();\n"; } elseif (isset($configitem['switch'])) { $val = $formvars->getExists($configname, $wasset); if (!$wasset) { $val = isset($configitem['default']) ? $configitem['default'] : null; } if (isset($configitem['switch'][$val])) { $value = $val; if ($quote && $value != 'true' && $value != 'false') { $value = "'" . $value . "'"; } $this->_generatePHPConfig($configitem['switch'][$val]['fields'], $prefix, $formvars); } } elseif (isset($configitem['_type'])) { $val = $formvars->getExists($configname, $wasset); if (!$wasset && (array_key_exists('is_default', $configitem) && $configitem['is_default'] || !array_key_exists('is_default', $configitem))) { $val = isset($configitem['default']) ? $configitem['default'] : null; } $type = $configitem['_type']; switch ($type) { case 'multienum': if (is_array($val)) { $encvals = array(); foreach ($val as $v) { $encvals[] = $this->_quote($v); } $arrayval = "'" . implode('\', \'', $encvals) . "'"; if ($arrayval == "''") { $arrayval = ''; } } else { $arrayval = ''; } $value = 'array(' . $arrayval . ')'; break; case 'boolean': if (is_bool($val)) { $value = $val ? 'true' : 'false'; } else { $value = $val == 'on' ? 'true' : 'false'; } break; case 'stringlist': $values = explode(',', $val); if (!is_array($values)) { $value = "array('" . $this->_quote(trim($values)) . "')"; } else { $encvals = array(); foreach ($values as $v) { $encvals[] = $this->_quote(trim($v)); } $arrayval = "'" . implode('\', \'', $encvals) . "'"; if ($arrayval == "''") { $arrayval = ''; } $value = 'array(' . $arrayval . ')'; } break; case 'int': if (strlen($val)) { $value = (int) $val; } break; case 'octal': $value = sprintf('0%o', octdec($val)); break; case 'header': case 'description': break; default: if ($val != '') { $value = $val; if ($quote && $value != 'true' && $value != 'false') { $value = "'" . $this->_quote($value) . "'"; } } break; } } else { $this->_generatePHPConfig($configitem, $prefixedname, $formvars); } if (isset($value)) { $this->_phpConfig .= '$conf[\'' . str_replace('__', '\'][\'', $configname) . '\'] = ' . $value . ";\n"; } unset($value); } }