endBuffer() public static method

End buffering output.
public static endBuffer ( ) : string
return string The buffered output.
Example #1
0
 /**
  */
 public function status()
 {
     global $notification;
     Horde::startBuffer();
     $notification->notify(array('listeners' => array('status', 'audio')));
     return Horde::endBuffer();
 }
Example #2
0
 /**
  */
 protected function _handle(Horde_Variables $vars)
 {
     global $injector, $prefs;
     $faces = $injector->getInstance('Ansel_Faces');
     $image_id = intval($vars->image_id);
     $results = $faces->getImageFacesData($image_id);
     // Attempt to get faces from the picture if we don't already have
     // results, or if we were asked to explicitly try again.
     if (empty($results)) {
         $image = $injector->getInstance('Ansel_Storage')->getImage($image_id);
         $image->createView('screen', null, $prefs->getValue('watermark_auto') ? $prefs->getValue('watermark_text', '') : '');
         $results = $faces->getFromPicture($image_id, true);
     }
     if (empty($results)) {
         $results = new stdClass();
         $results->response = _("No faces found");
         return new Horde_Core_Ajax_Response($results);
     }
     $customurl = Horde::url('faces/custom.php');
     Horde::startBuffer();
     include ANSEL_TEMPLATES . '/faces/image.inc';
     $response = new stdClass();
     $response->response = Horde::endBuffer();
     return new Horde_Core_Ajax_Response($response);
 }
Example #3
0
 function getDimensions()
 {
     $tmp_file = Horde_Util::getTempFile('fax', true, '/tmp');
     Horde::startBuffer();
     var_dump($tmp_file);
     Horde::log('Created temp file:' . Horde::endBuffer() . ':', 'DEBUG');
     $fp = fopen($tmp_file, 'w');
     fwrite($fp, $this->_data);
     fclose($fp);
     /* Run a ImageMagick identify command on the file to get the details. */
     $command = sprintf('%s %s', $this->_cmd['identify'], $tmp_file);
     Horde::log('External command call by Hylax_Image::getDimensions(): :' . $command . ':', 'DEBUG');
     exec($command, $output, $retval);
     $init = strlen($tmp_file);
     /* Figure out the dimensions from the output. */
     Horde::log('External command output by Hylax_Image::getDimensions(): ' . serialize($output), 'DEBUG');
     foreach ($output as $key => $line) {
         if (substr($line, 0, $init) != $tmp_file) {
             continue;
         }
         $info = explode(' ', $line);
         $dims = explode('+', $info[2]);
         list($width, $height) = explode('x', $dims[0]);
         $this->_pages[$key]['width'] = $width;
         $this->_pages[$key]['height'] = $height;
     }
 }
Example #4
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification;
     /* Redirect if forward is not available. */
     $this->_assertCategory(Ingo_Storage::ACTION_FORWARD, _("Forward"));
     if ($this->vars->submitbutton == _("Return to Rules List")) {
         Ingo_Basic_Filters::url()->redirect();
     }
     /* Get the forward object and rule. */
     $ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
     $forward = $ingo_storage->retrieve(Ingo_Storage::ACTION_FORWARD);
     $filters = $ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
     $fwd_id = $filters->findRuleId(Ingo_Storage::ACTION_FORWARD);
     $fwd_rule = $filters->getRule($fwd_id);
     /* Build form. */
     $form = new Ingo_Form_Forward($this->vars);
     /* Perform requested actions. Ingo_Form_Forward does token checking
      * for us. */
     if ($form->validate($this->vars)) {
         $forward->setForwardAddresses($this->vars->addresses);
         $forward->setForwardKeep($this->vars->keep_copy == 'on');
         try {
             $ingo_storage->store($forward);
             $notification->push(_("Changes saved."), 'horde.success');
             if ($this->vars->submitbutton == _("Save and Enable")) {
                 $filters->ruleEnable($fwd_id);
                 $ingo_storage->store($filters);
                 $notification->push(_("Rule Enabled"), 'horde.success');
                 $fwd_rule['disable'] = false;
             } elseif ($this->vars->submitbutton == _("Save and Disable")) {
                 $filters->ruleDisable($fwd_id);
                 $ingo_storage->store($filters);
                 $notification->push(_("Rule Disabled"), 'horde.success');
                 $fwd_rule['disable'] = true;
             }
             Ingo_Script_Util::update();
         } catch (Ingo_Exception $e) {
             $notification->push($e);
         }
     }
     /* Add buttons depending on the above actions. */
     $form->setCustomButtons($fwd_rule['disable']);
     /* Set default values. */
     if (!$form->isSubmitted()) {
         $this->vars->keep_copy = $forward->getForwardKeep();
         $this->vars->addresses = implode("\n", $forward->getForwardAddresses());
     }
     /* Set form title. */
     $form_title = _("Forward");
     if (!empty($fwd_rule['disable'])) {
         $form_title .= ' [<span class="horde-form-error">' . _("Disabled") . '</span>]';
     }
     $form_title .= ' ' . Horde_Help::link('ingo', 'forward');
     $form->setTitle($form_title);
     $this->header = _("Forwards Edit");
     Horde::startBuffer();
     $form->renderActive(new Horde_Form_Renderer(array('encode_title' => false, 'varrenderer_driver' => array('ingo', 'ingo'))), $this->vars, self::url(), 'post');
     $this->output = Horde::endBuffer();
 }
Example #5
0
 /**
  */
 protected function _content()
 {
     $cloud = new Horde_Core_Ui_TagCloud();
     foreach ($this->_getTags() as $tag) {
         $cloud->addElement($tag['tag_name'], '#', $tag['count'], null, 'doSearch(\'' . $tag['tag_name'] . '\'); return false;');
     }
     Horde::startBuffer();
     include HORDE_TEMPLATES . '/block/cloud.inc';
     return Horde::endBuffer() . '<div>&nbsp;' . Horde_Themes_Image::tag('loading.gif', array('attr' => array('id' => 'cloudloadingimg', 'style' => 'display:none;'))) . '</div>' . $cloud->buildHTML() . '<div id="cloudsearch"></div>';
 }
Example #6
0
 /**
  * Return the full rendered version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _render()
 {
     $data = $this->_impRender(false);
     $item = reset($data);
     Horde::startBuffer();
     $GLOBALS['page_output']->includeStylesheetFiles();
     $item['data'] = '<html><head>' . Horde::endBuffer() . '</head><body>' . $item['data'] . '</body></html>';
     $data[key($data)] = $item;
     return $data;
 }
Example #7
0
 /**
  */
 protected function _content()
 {
     global $page_output, $registry;
     $abooks = empty($this->_params['addressbooks']) ? array_keys($this->_options) : $this->_params['addressbooks'];
     $page_output->addInlineJsVars(array('TurbaMinisearch.abooks' => $abooks, 'TurbaMinisearch.URI_AJAX' => $registry->getServiceLink('ajax', 'turba')->url));
     $page_output->addScriptFile('minisearch.js');
     Horde::startBuffer();
     include TURBA_TEMPLATES . '/block/minisearch.inc';
     return Horde::endBuffer();
 }
Example #8
0
 /**
  * Return the HTML representing this view.
  *
  * @return string  The HTML.
  */
 public function html()
 {
     $view = $this->_getHordeView();
     if (!empty($this->view->api)) {
         Horde::startBuffer();
         $prototypejs = new Horde_Script_File_JsDir('prototype.js', 'horde');
         echo $prototypejs->tag_full;
         $html = Horde::endBuffer();
         return $html . $view->render('gallery');
     }
     return $view->render('gallery');
 }
Example #9
0
 /**
  * Any application specific tests that need to be done.
  *
  * @return string  HTML output.
  */
 public function appTests()
 {
     $ret = '<h1>LDAP Support Test</h1>';
     $params = array('server' => Horde_Util::getPost('server'), 'port' => Horde_Util::getPost('port', 389), 'basedn' => Horde_Util::getPost('basedn'), 'user' => Horde_Util::getPost('user'), 'passwd' => Horde_Util::getPost('passwd'), 'filter' => Horde_Util::getPost('filter'), 'proto' => Horde_Util::getPost('proto'));
     if (!empty($params['server']) && !empty($params['basedn']) && !empty($params['filter'])) {
         $ret .= $this->_doConnectionTest($params);
     }
     $self_url = Horde::selfUrl()->add('app', 'turba');
     Horde::startBuffer();
     require TURBA_TEMPLATES . '/test/ldapserver.inc';
     return $ret . Horde::endBuffer();
 }
Example #10
0
File: Test.php Project: horde/horde
 /**
  */
 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();
 }
Example #11
0
 /**
  */
 protected function _content()
 {
     $qManager = new Whups_Query_Manager();
     $queries = $qManager->listQueries($GLOBALS['registry']->getAuth(), true);
     $myqueries = new Whups_View_SavedQueries(array('results' => $queries));
     Horde::startBuffer();
     $myqueries->html(false);
     $html = Horde::endBuffer();
     if ($html) {
         return $html;
     }
     return '<p class="horde-content"><em>' . _("No queries have been saved.") . '</em></p>';
 }
Example #12
0
 /**
  * Return the full rendered version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _render()
 {
     $ret = $this->_renderInline();
     if (!empty($ret)) {
         reset($ret);
         $GLOBALS['page_output']->topbar = $GLOBALS['page_output']->sidebar = false;
         Horde::startBuffer();
         $GLOBALS['page_output']->header(array('html_id' => 'htmlAllowScroll'));
         echo $ret[key($ret)]['data'];
         $GLOBALS['page_output']->footer();
         $ret[key($ret)]['data'] = Horde::endBuffer();
     }
     return $ret;
 }
Example #13
0
 function getPage()
 {
     $this->_pageParams['registry']->pushApp('turba', array('check_perms' => false));
     $this->fakeAuth();
     $page = new Turba_BrowsePage($this->_pageParams);
     Horde::startBuffer();
     $page->run();
     $this->_output = Horde::endBuffer();
     if ($push_result) {
         $this->_pageParams['registry']->popApp();
     }
     $this->assertNoUnwantedPattern('/<b>Warning/', $this->_output);
     $this->assertNoUnwantedPattern('/<b>Fatal error/i', $this->_output);
     return $this->_output;
 }
Example #14
0
 /**
  * Loads a chunk of PHP code (usually an HTML template) from the
  * application's templates directory.
  *
  * @return object  Object with the following properties:
  *   - chunk: (string) A chunk of PHP output.
  */
 public function chunkContent()
 {
     $chunk = basename($this->vars->chunk);
     $result = new stdClass();
     if (!empty($chunk)) {
         Horde::startBuffer();
         try {
             include $GLOBALS['registry']->get('templates', $this->_base->app) . '/chunks/' . $chunk . '.php';
             $result->chunk = Horde::endBuffer();
         } catch (Exception $e) {
             Horde::endBuffer();
             throw $e;
         }
     }
     return $result;
 }
Example #15
0
File: Itip.php Project: Gomez/horde
 /**
  * Return the full rendered version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _render()
 {
     global $page_output;
     $ret = $this->_renderInline();
     if (!empty($ret)) {
         reset($ret);
         $page_output->topbar = $page_output->sidebar = false;
         $mimecss = new Horde_Themes_Element('mime.css');
         $page_output->addStylesheet($mimecss->fs, $mimecss->uri);
         Horde::startBuffer();
         $page_output->header(array('html_id' => 'htmlAllowScroll'));
         echo $ret[key($ret)]['data'];
         $page_output->footer();
         $ret[key($ret)]['data'] = Horde::endBuffer();
     }
     return $ret;
 }
Example #16
0
 /**
  * Constructor.
  *
  * @param string $app        Application.
  * @param string $conf_file  Configuration file name.
  * @param mixed $vars        List of config variables to load.
  *
  * @throws Horde_Exception
  */
 public function __construct($app, $conf_file, $vars = null)
 {
     global $conf, $registry;
     $flist = array();
     /* Load global configuration file. */
     $conf_dir = $app == 'horde' && defined('HORDE_BASE') ? HORDE_BASE . '/config/' : $registry->get('fileroot', $app) . '/config/';
     $flist[] = $conf_dir . $conf_file;
     $pinfo = pathinfo($conf_file);
     /* Load global configuration stanzas in '.d' directory. */
     $dir = $conf_dir . $pinfo['filename'] . '.d';
     if (is_dir($dir) && ($conf_d = glob($dir . '/*.php')) !== false) {
         $flist = array_merge($flist, $conf_d);
     }
     /* Load local version of configuration file. */
     $flist[] = $conf_dir . $pinfo['filename'] . '.local.' . $pinfo['extension'];
     $end = count($flist) - 1;
     $load = 0;
     while (list($k, $v) = each($flist)) {
         if (file_exists($v)) {
             Horde::startBuffer();
             $success = (include $v);
             $this->output .= Horde::endBuffer();
             if (!$success) {
                 throw new Horde_Exception(sprintf('Failed to import configuration file "%s".', $v));
             }
             ++$load;
         }
         if ($k === $end && !empty($conf['vhosts'])) {
             /* Load vhost configuration file. The vhost conf.php is not
              * determined until here because, if this is Horde, the vhost
              * configuration variable is not available until this
              * point. */
             $flist[] = $conf_dir . $pinfo['filename'] . '-' . $conf['server']['name'] . '.' . $pinfo['extension'];
         }
     }
     /* Return an error if no version of the config file exists. */
     if (!$load) {
         throw new Horde_Exception(sprintf('Failed to import configuration file "%s".', $conf_dir . $conf_file));
     }
     if (!is_null($vars)) {
         $this->config = compact($vars);
     }
     Horde::log('Load config file (' . $conf_file . '; app: ' . $app . ')', 'DEBUG');
 }
Example #17
0
    function printJavaScript()
    {
        $pieces = explode('%s', $this->_params['format']);
        $fields = $this->_params['fields'];
        $val_first = substr($this->_params['format'], 0, 2) == '%s';
        if ($val_first) {
            array_shift($pieces);
        }
        if (substr($this->_params['format'], -2) == '%s') {
            array_pop($pieces);
        }
        $args = array();
        if ($val_first) {
            $args[] = "document.getElementById('" . array_shift($fields) . "').value";
        }
        while (count($pieces)) {
            $args[] = "'" . array_shift($pieces) . "'";
            $args[] = "document.getElementById('" . array_shift($fields) . "').value";
        }
        Horde::startBuffer();
        ?>
// Updater for <?php 
        echo $this->getTarget();
        ?>
.
function updateField<?php 
        echo $this->id();
        ?>
()
{
    var target = document.getElementById('<?php 
        echo $this->getTarget();
        ?>
');
    if (target) {
        target.value = (<?php 
        echo implode(' + ', str_replace("\n", "\\n", $args));
        ?>
).replace(/(^ +| +$)/, '').replace(/ +/g, ' ');
    }
}<?php 
        $GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(Horde::endBuffer());
    }
Example #18
0
 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();
 }
Example #19
0
    /**
     */
    protected function _content()
    {
        Horde::startBuffer();
        ?>
<link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>
<div id="googlesearch">...</div>
<script type="text/javascript" src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=<?php 
        echo htmlspecialchars($GLOBALS['conf']['api']['googlesearch']);
        ?>
"></script>
<script type="text/javascript">
//<![CDATA[
function GoogleSearchSetup()
{
    // Create a search control
    var searchControl = new GSearchControl();

    // Add in a full set of searchers
    searchControl.addSearcher(new GwebSearch());
    searchControl.addSearcher(new GvideoSearch());
    searchControl.addSearcher(new GblogSearch());
    searchControl.addSearcher(new GnewsSearch());
    searchControl.addSearcher(new GbookSearch());

    // create a drawOptions object
    var drawOptions = new GdrawOptions();

    // tell the searcher to draw itself in tabbed mode
    drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
    searchControl.draw(document.getElementById('googlesearch'), drawOptions);
}
GSearch.setOnLoadCallback(GoogleSearchSetup);
//]]>
</script>
<?php 
        return Horde::endBuffer();
    }
Example #20
0
 /**
  * $registry
  * $notification
  * $conf
  * $criteria
  *
  */
 public function run()
 {
     extract($this->_params, EXTR_REFS);
     $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah');
     /* Get requested channel. */
     try {
         $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($criteria['feed']);
     } catch (Exception $e) {
         Horde::log($e, 'ERR');
         $notification->push(_("Invalid channel."), 'horde.error');
         Horde::url('delivery/index.php', true)->redirect();
         exit;
     }
     $title = sprintf(_("HTML Delivery for \"%s\""), $channel['channel_name']);
     $options = array();
     foreach ($templates as $key => $info) {
         $options[] = '<option value="' . $key . '"' . ($key == $criteria['format'] ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>';
     }
     $template = new Horde_Template();
     $template->setOption('gettext', 'true');
     $template->set('url', Horde::selfUrl());
     $template->set('session', Horde_Util::formInput());
     $template->set('channel_id', $criteria['feed']);
     $template->set('channel_name', $channel['channel_name']);
     $template->set('format', $criteria['format']);
     $template->set('options', $options);
     // @TODO: This is ugly. storage driver shouldn't be rendering any display
     // refactor this to use individual views possibly with a choice of different templates
     $template->set('stories', $GLOBALS['injector']->getInstance('Jonah_Driver')->renderChannel($criteria['feed'], $criteria['format']));
     // Buffer the notifications and send to the template
     Horde::startBuffer();
     $GLOBALS['notification']->notify(array('listeners' => 'status'));
     $template->set('notify', Horde::endBuffer());
     $GLOBALS['page_output']->header(array('title' => $title));
     echo $template->fetch(JONAH_TEMPLATES . '/delivery/html.html');
     $GLOBALS['page_output']->footer();
 }
Example #21
0
    if ($config->writePHPConfig($vars, $php)) {
        Horde::url('admin/config/index.php', true)->redirect();
    } else {
        $notification->push(sprintf(_("Could not save the configuration file %s. You can either use one of the options to save the code back on %s or copy manually the code below to %s."), Horde_Util::realPath($configFile), Horde::link(Horde::url('admin/config/index.php') . '#update', _("Configuration")) . _("Configuration") . '</a>', Horde_Util::realPath($configFile)), 'horde.warning', array('content.raw', 'sticky'));
    }
} elseif ($form->isSubmitted()) {
    $notification->push(_("There was an error in the configuration form. Perhaps you left out a required field."), 'horde.error');
}
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin/config'));
$view->addHelper('Text');
$view->php = $php;
/* Create the link for the diff popup only if stored in session. */
if ($session->exists('horde', 'config/' . $app)) {
    $url = Horde::url('admin/config/diff.php', true)->add('app', $app);
    $view->diff_popup = Horde::link('#', '', '', '', Horde::popupJs($url, array('height' => 480, 'width' => 640, 'urlencode' => true)) . 'return false;') . _("show differences") . '</a>';
}
Horde::startBuffer();
require HORDE_TEMPLATES . '/admin/menu.inc';
$menu_output = Horde::endBuffer();
/* Render the configuration form. */
$renderer = $form->getRenderer();
$renderer->setAttrColumnWidth('50%');
/* Buffer the form template */
Horde::startBuffer();
$form->renderActive($renderer, $vars, Horde::url('admin/config/config.php'), 'post');
$view->form = Horde::endBuffer();
/* Send headers */
$page_output->header(array('title' => $title));
/* Output page */
echo $menu_output . $view->render('config');
$page_output->footer();
Example #22
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification;
     $this->_assertCategory(Ingo_Storage::ACTION_SPAM, _("Spam filtering"));
     /* Get the spam object and rule. */
     $ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
     $spam = $ingo_storage->retrieve(Ingo_Storage::ACTION_SPAM);
     $filters = $ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
     $spam_id = $filters->findRuleId(Ingo_Storage::ACTION_SPAM);
     $spam_rule = $filters->getRule($spam_id);
     if ($this->vars->submitbutton == _("Return to Rules List")) {
         Ingo_Basic_Filters::url()->redirect();
     }
     /* Build form. */
     $form = new Ingo_Form_Spam($this->vars);
     $renderer = new Horde_Form_Renderer(array('encode_title' => false, 'varrenderer_driver' => array('ingo', 'ingo')));
     /* Perform requested actions. Ingo_Form_Spam does token checking for
      * us .*/
     if ($form->validate($this->vars)) {
         $success = false;
         try {
             $spam->setSpamFolder($this->validateMbox('folder'));
             $success = true;
         } catch (Horde_Exception $e) {
             $notification->push($e);
         }
         $spam->setSpamLevel($this->vars->level);
         try {
             $ingo_storage->store($spam);
             $notification->push(_("Changes saved."), 'horde.success');
             if ($this->vars->submitbutton == _("Save and Enable")) {
                 $filters->ruleEnable($spam_id);
                 $ingo_storage->store($filters);
                 $notification->push(_("Rule Enabled"), 'horde.success');
                 $spam_rule['disable'] = false;
             } elseif ($this->vars->submitbutton == _("Save and Disable")) {
                 $filters->ruleDisable($spam_id);
                 $ingo_storage->store($filters);
                 $notification->push(_("Rule Disabled"), 'horde.success');
                 $spam_rule['disable'] = true;
             }
             Ingo_Script_Util::update();
         } catch (Ingo_Exception $e) {
             $notification->push($e);
         }
     }
     /* Add buttons depending on the above actions. */
     $form->setCustomButtons($spam_rule['disable']);
     /* Set default values. */
     $form->folder_var->type->setFolder($spam->getSpamFolder());
     if (!$form->isSubmitted()) {
         $this->vars->level = $spam->getSpamLevel();
         $this->vars->folder = $spam->getSpamFolder();
         $this->vars->actionID = '';
     }
     /* Set form title. */
     $form_title = _("Spam Filtering");
     if (!empty($spam_rule['disable'])) {
         $form_title .= ' [<span class="horde-form-error">' . _("Disabled") . '</span>]';
     }
     $form_title .= ' ' . Horde_Help::link('ingo', 'spam');
     $form->setTitle($form_title);
     $this->header = _("Spam Filtering");
     Horde::startBuffer();
     $form->renderActive($renderer, $this->vars, self::url(), 'post');
     $this->output = Horde::endBuffer();
 }
Example #23
0
/* Which forums page are we on?  Default to page 0. */
$forum_page = Horde_Util::getFormData('forum_page', 0);
$forums_per_page = $prefs->getValue('forums_per_page');
$forum_start = $forum_page * $forums_per_page;
/* Get the list of forums. */
try {
    $forums_list = $forums->getForums(0, true, $sort_by, $sort_dir, true, $forum_start, $forums_per_page);
    $forums_count = $forums->countForums();
} catch (Horde_Exception_NotFound $e) {
    $forums_count = 0;
}
/* Set up the column headers. */
$col_headers = array('forum_name' => _("Forum"), 'forum_description' => _("Description"), 'message_count' => _("Posts"), 'thread_count' => _("Threads"), 'message_timestamp' => _("Last Post"), 'message_author' => _("Posted by"), 'message_date' => _("Date"));
$col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'forums');
/* Set up the template tags. */
$view = new Agora_View();
$view->col_headers = $col_headers;
$view->forums_list = $forums_list;
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$view->notify = Horde::endBuffer();
$view->actions = empty($actions) ? null : $actions;
/* Set up pager. */
$vars = Horde_Variables::getDefaultVariables();
$pager_ob = new Horde_Core_Ui_Pager('forum_page', $vars, array('num' => $forums_count, 'url' => 'forums.php', 'perpage' => $forums_per_page));
$pager_ob->preserve('scope', $scope);
$view->pager_link = $pager_ob->render();
$page_output->addLinkTag(array('href' => Horde::url('rss/index.php', true, -1)->add('scope', $scope), 'title' => _("Forums")));
$page_output->header(array('title' => _("All Forums")));
echo $view->render('forums');
$page_output->footer();
Example #24
0
    /**
     * Handle output of the embedded widget: allows embedding calendar widgets
     * in external websites.
     *
     * The following arguments are required:
     *   - calendar: The share_name for the requested calendar.
     *   - container: The DOM node to populate with the widget.
     *   - view: The view (block) we want.
     *
     * The following are optional (and are not used for all views)
     *   - css
     *   - days
     *   - maxevents: The maximum number of events to show.
     *   - months: The number of months to include.
     */
    public function embed()
    {
        global $page_output, $registry;
        /* First, determine the type of view we are asking for */
        $view = $this->vars->view;
        /* The DOM container to put the HTML in on the remote site */
        $container = $this->vars->container;
        /* The share_name of the calendar to display */
        $calendar = $this->vars->calendar;
        /* Deault to showing only 1 month when we have a choice */
        $count_month = $this->vars->get('months', 1);
        /* Default to no limit for the number of events */
        $max_events = $this->vars->get('maxevents', 0);
        /* Default to one week */
        $count_days = $this->vars->get('days', 7);
        if ($this->vars->css == 'none') {
            $nocss = true;
        }
        /* Build the block parameters */
        $params = array('calendar' => $calendar, 'maxevents' => $max_events, 'months' => $count_month, 'days' => $count_days);
        /* Call the Horde_Block api to get the calendar HTML */
        $title = $registry->call('horde/blockTitle', array('kronolith', $view, $params));
        $results = $registry->call('horde/blockContent', array('kronolith', $view, $params));
        /* Some needed paths */
        $js_path = $registry->get('jsuri', 'kronolith');
        /* Local js */
        $jsurl = Horde::url($js_path . '/embed.js', true);
        /* Horde's js */
        $hjs_path = $registry->get('jsuri', 'horde');
        $hjsurl = Horde::url($hjs_path . '/tooltips.js', true);
        $pturl = Horde::url($hjs_path . '/prototype.js', true);
        /* CSS */
        if (empty($nocss)) {
            $page_output->addThemeStylesheet('embed.css');
            Horde::startBuffer();
            $page_output->includeStylesheetFiles(array('nobase' => true), true);
            $css = Horde::endBuffer();
        } else {
            $css = '';
        }
        /* Escape the text and put together the javascript to send back */
        $container = Horde_Serialize::serialize($container, Horde_Serialize::JSON);
        $results = Horde_Serialize::serialize('<div class="kronolith_embedded"><div class="title">' . $title . '</div>' . $results . '</div>', Horde_Serialize::JSON);
        $js = <<<EOT
if (typeof kronolith == 'undefined') {
    if (typeof Prototype == 'undefined') {
        document.write('<script type="text/javascript" src="{$pturl}"></script>');
    }
    if (typeof Horde_ToolTips == 'undefined') {
        Horde_ToolTips_Autoload = false;
        document.write('<script type="text/javascript" src="{$hjsurl}"></script>');
    }
    kronolith = new Object();
    kronolithNodes = new Array();
    document.write('<script type="text/javascript" src="{$jsurl}"></script>');
    document.write('{$css}');
}
kronolithNodes[kronolithNodes.length] = {$container};
kronolith[{$container}] = {$results};
EOT;
        return new Horde_Core_Ajax_Response_Raw($js, 'text/javascript');
    }
Example #25
0
 /**
  * @throws IMP_Exception
  */
 protected function _init()
 {
     global $conf, $injector, $notification, $page_output;
     if (!$this->indices) {
         throw new IMP_Exception(_("No message index given."));
     }
     $page_output->addScriptFile('message-dimp.js');
     $page_output->addScriptFile('textarearesize.js', 'horde');
     $page_output->addScriptFile('toggle_quotes.js', 'horde');
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     $js_vars = array();
     switch ($this->vars->actionID) {
         case 'strip_attachment':
             try {
                 $this->indices = new IMP_Indices_Mailbox($this->indices->mailbox, $injector->getInstance('IMP_Message')->stripPart($this->indices, $this->vars->id));
                 $js_vars['-DimpMessage.strip'] = 1;
                 $notification->push(_("Attachment successfully stripped."), 'horde.success');
             } catch (IMP_Exception $e) {
                 $notification->push($e);
             }
             break;
     }
     try {
         $show_msg = new IMP_Ajax_Application_ShowMessage($this->indices);
         $msg_res = $show_msg->showMessage(array('headers' => array_diff(array_keys($injector->getInstance('IMP_Message_Ui')->basicHeaders()), array('subject')), 'preview' => false));
     } catch (IMP_Exception $e) {
         $notification->notify(array('listeners' => array('status', 'audio')));
         echo Horde::wrapInlineScript(array('parent.close()'));
         exit;
     }
     $ajax_queue = $injector->getInstance('IMP_Ajax_Queue');
     $ajax_queue->poll($this->indices->mailbox);
     list(, $buid) = $this->indices->buids->getSingle();
     foreach (array('from', 'to', 'cc', 'bcc', 'replyTo', 'log') as $val) {
         if (!empty($msg_res[$val])) {
             $js_vars['DimpMessage.' . $val] = $msg_res[$val];
         }
     }
     if (!empty($msg_res['list_info']['exists'])) {
         $js_vars['DimpMessage.reply_list'] = true;
         $this->view->listinfo = Horde::popupJs(IMP_Basic_Listinfo::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox)), array('urlencode' => true));
     }
     $js_vars['DimpMessage.buid'] = $buid;
     $js_vars['DimpMessage.mbox'] = $this->indices->mailbox->form_to;
     $js_vars['DimpMessage.tasks'] = $injector->getInstance('Horde_Core_Factory_Ajax')->create('imp', $this->vars)->getTasks();
     $page_output->addInlineJsVars($js_vars);
     if (isset($msg_res['js'])) {
         $page_output->addInlineScript(array_filter($msg_res['js']), true);
     }
     $this->_pages[] = 'message';
     /* Determine if compose mode is disabled. */
     if (IMP_Compose::canCompose()) {
         $this->view->qreply = $injector->getInstance('IMP_Dynamic_Compose_Common')->compose($this, array('title' => _("Message") . ': ' . $msg_res['subject']));
         $this->_pages[] = 'qreply';
         $this->js_conf['qreply'] = 1;
     }
     $page_output->noDnsPrefetch();
     $this->view->show_delete = $this->indices->mailbox->access_deletemsgs;
     list($real_mbox, ) = $this->indices->getSingle();
     $this->view->show_innocent = $real_mbox->innocent_show;
     $this->view->show_spam = $real_mbox->spam_show;
     $this->view->show_view_all = empty($msg_res['onepart']);
     $this->view->show_view_source = !empty($conf['user']['allow_view_source']);
     $this->view->save_as = $msg_res['save_as'];
     $this->view->subject = isset($msg_res['subjectlink']) ? $msg_res['subjectlink'] : $msg_res['subject'];
     $hdrs = array();
     foreach ($msg_res['headers'] as $val) {
         $hdrs[] = array_filter(array('id' => isset($val['id']) ? 'msgHeader' . $val['id'] : null, 'label' => $val['name'], 'val' => $val['value']));
     }
     $this->view->hdrs = $hdrs;
     if (isset($msg_res['atc_label'])) {
         $this->view->atc_label = $msg_res['atc_label'];
         if (isset($msg_res['atc_list'])) {
             $this->view->atc_list = $msg_res['atc_list'];
         } else {
             $this->view->atc_list = array();
         }
         if (isset($msg_res['atc_download'])) {
             $this->view->atc_download = $msg_res['atc_download'];
         }
     } else {
         $this->view->atc_list = array();
     }
     $this->view->msgtext = $msg_res['msgtext'];
     Horde::startBuffer();
     $notification->notify(array('listeners' => array('status', 'audio')));
     $this->view->status = Horde::endBuffer();
     $this->title = $msg_res['title'];
     $this->view->title = $this->title;
 }
Example #26
0
 /**
  */
 public function status()
 {
     Horde::startBuffer();
     $GLOBALS['notification']->notify(array('listeners' => array('status', 'audio')));
     return Horde::endBuffer();
 }
Example #27
0
 /**
  * Build the HTML for the other galleries widget content.
  *
  * @param Horde_View $view  The view object.
  */
 protected function _getOtherGalleries(&$view)
 {
     $owner = $this->_view->gallery->get('owner');
     // Set up the tree
     $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('otherAnselGalleries_' . md5($owner), 'Javascript', array('class' => 'anselWidgets'));
     try {
         $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $owner));
     } catch (Ansel_Exception $e) {
         Horde::log($e, 'ERR');
         return;
     }
     foreach ($galleries as $gallery) {
         $parents = $gallery->get('parents');
         if (empty($parents)) {
             $parent = null;
         } else {
             $parents = explode(':', $parents);
             $parent = array_pop($parents);
         }
         $img = (string) Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'mini', true);
         $link = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery'), true);
         $tree->addNode(array('id' => $gallery->id, 'parent' => $parent, 'label' => $gallery->get('name'), 'expanded' => $gallery->id == $this->_view->gallery->id, 'params' => array('icon' => $img, 'url' => $link)));
     }
     Horde::startBuffer();
     $tree->sort('label');
     $tree->renderTree();
     $view->tree = Horde::endBuffer();
     $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_ToggleOtherGalleries', array('id' => 'othergalleries-toggle'));
 }
Example #28
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification;
     $this->_assertCategory(Ingo_Storage::ACTION_VACATION, _("Vacation"));
     /* Get vacation object and rules. */
     $ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
     $vacation = $ingo_storage->retrieve(Ingo_Storage::ACTION_VACATION);
     $filters = $ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
     $vac_id = $filters->findRuleId(Ingo_Storage::ACTION_VACATION);
     $vac_rule = $filters->getRule($vac_id);
     /* Load libraries. */
     if ($this->vars->submitbutton == _("Return to Rules List")) {
         Ingo_Basic_Filters::url()->redirect();
     }
     /* Build form. */
     $form = new Ingo_Form_Vacation($this->vars, '', null, $injector->getInstance('Ingo_Factory_Script')->create(Ingo::RULE_VACATION)->availableCategoryFeatures(Ingo_Storage::ACTION_VACATION));
     /* Perform requested actions. Ingo_Form_Vacation does token checking
      * for us. */
     if ($form->validate($this->vars)) {
         $form->getInfo($this->vars, $info);
         $vacation->setVacationAddresses(isset($info['addresses']) ? $info['addresses'] : '');
         $vacation->setVacationDays($info['days']);
         $vacation->setVacationExcludes($info['excludes']);
         $vacation->setVacationIgnorelist($info['ignorelist'] == 'on');
         $vacation->setVacationReason($info['reason']);
         $vacation->setVacationSubject($info['subject']);
         $vacation->setVacationStart($info['start']);
         $vacation->setVacationEnd($info['end']);
         try {
             $ingo_storage->store($vacation);
             $notification->push(_("Changes saved."), 'horde.success');
             if ($this->vars->submitbutton == _("Save and Enable")) {
                 $filters->ruleEnable($vac_id);
                 $ingo_storage->store($filters);
                 $notification->push(_("Rule Enabled"), 'horde.success');
                 $vac_rule['disable'] = false;
             } elseif ($this->vars->get('submitbutton') == _("Save and Disable")) {
                 $filters->ruleDisable($vac_id);
                 $ingo_storage->store($filters);
                 $notification->push(_("Rule Disabled"), 'horde.success');
                 $vac_rule['disable'] = true;
             }
             Ingo_Script_Util::update();
         } catch (Ingo_Exception $e) {
             $notification->push($e);
         }
     }
     /* Add buttons depending on the above actions. */
     $form->setCustomButtons($vac_rule['disable']);
     /* Make sure we have at least one address. */
     if (!$vacation->getVacationAddresses()) {
         $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create();
         $addresses = implode("\n", $identity->getAll('from_addr'));
         /* Remove empty lines. */
         $addresses = trim(preg_replace('/\\n+/', "\n", $addresses));
         if (empty($addresses)) {
             $addresses = $GLOBALS['registry']->getAuth();
         }
         $vacation->setVacationAddresses($addresses);
     }
     /* Set default values. */
     if (!$form->isSubmitted()) {
         $this->vars->set('addresses', implode("\n", $vacation->getVacationAddresses()));
         $this->vars->set('excludes', implode("\n", $vacation->getVacationExcludes()));
         $this->vars->set('ignorelist', $vacation->getVacationIgnorelist());
         $this->vars->set('days', $vacation->getVacationDays());
         $this->vars->set('subject', $vacation->getVacationSubject());
         $this->vars->set('reason', $vacation->getVacationReason());
         $this->vars->set('start', $vacation->getVacationStart());
         $this->vars->set('end', $vacation->getVacationEnd());
         $this->vars->set('start_year', $vacation->getVacationStartYear());
         $this->vars->set('start_month', $vacation->getVacationStartMonth() - 1);
         $this->vars->set('start_day', $vacation->getVacationStartDay() - 1);
         $this->vars->set('end_year', $vacation->getVacationEndYear());
         $this->vars->set('end_month', $vacation->getVacationEndMonth() - 1);
         $this->vars->set('end_day', $vacation->getVacationEndDay() - 1);
     }
     /* Set form title. */
     $form_title = _("Vacation");
     if (!empty($vac_rule['disable'])) {
         $form_title .= ' [<span class="horde-form-error">' . _("Disabled") . '</span>]';
     }
     $form_title .= ' ' . Horde_Help::link('ingo', 'vacation');
     $form->setTitle($form_title);
     $this->header = _("Vacation Edit");
     Horde::startBuffer();
     $form->renderActive(new Horde_Form_Renderer(array('encode_title' => false, 'varrenderer_driver' => array('ingo', 'ingo'))), $this->vars, self::url(), 'post');
     $this->output = Horde::endBuffer();
 }
Example #29
0
Horde::startBuffer();
// Token checking occurs in constructor.
$vars = $injector->getInstance('Horde_Variables');
try {
    $ajax = $injector->getInstance('Horde_Core_Factory_Ajax')->create($app, $vars, $action, $vars->token);
} catch (Horde_Exception $e) {
    /* Treat a token error as a session timeout. */
    $response = new Horde_Core_Ajax_Response_HordeCore_SessionTimeout($app);
    $response->jsonhtml = $vars->jsonhtml;
    $response->sendAndExit();
}
try {
    $ajax->doAction();
    // Clear the output buffer that we started above, and log any unexpected
    // output at a DEBUG level.
    if ($out = Horde::endBuffer()) {
        Horde::log('Unexpected output when creating AJAX reponse: ' . $out, 'DEBUG');
    }
    // Send the final result.
    $ajax->send();
} catch (Horde_Exception_AuthenticationFailure $e) {
    // If we reach this, authentication to Horde was successful, but
    // authentication to some underlying backend failed. Best to logout
    // immediately, since no way of knowing if error is transient.
    $response = new Horde_Core_Ajax_Response_HordeCore_NoAuth($app, $e->getCode());
    $response->jsonhtml = $vars->jsonhtml;
    $response->sendAndExit();
} catch (Exception $e) {
    $notification->push($e->getMessage(), 'horde.error');
    $response = new Horde_Core_Ajax_Response_HordeCore();
    $response->jsonhtml = $vars->jsonhtml;
Example #30
0
 /**
  * Image view specific HTML - done so we can extend View_Image for things
  * like the slideshow view etc...
  */
 protected function _html()
 {
     global $conf, $registry, $prefs, $page_output;
     // Build initial view properties
     $view = $this->_getView();
     $view->hide_slideshow = !empty($this->_params['hide_slideshow']);
     // Starting image
     $imageIndex = $this->_revList[$this->resource->id];
     // Get the next and previous image ids
     if (isset($this->_imageList[$imageIndex + 1])) {
         $next = $this->_imageList[$imageIndex + 1];
     } else {
         $next = $this->_imageList[0];
     }
     if (isset($this->_imageList[$imageIndex - 1])) {
         $prev = $this->_imageList[$imageIndex - 1];
     } else {
         $prev = $this->_imageList[count($this->_imageList) - 1];
     }
     // Calculate the page number of the next/prev images
     $perpage = $prefs->getValue('tilesperpage');
     $pagestart = $this->_page * $perpage;
     $pageend = min(count($this->_imageList), $pagestart + $perpage - 1);
     $page_next = $this->_page;
     if ($this->_revList[$this->resource->id] + 1 > $pageend) {
         ++$page_next;
     }
     $page_prev = $this->_page;
     if ($this->_revList[$this->resource->id] - 1 < $pagestart) {
         --$page_prev;
     }
     // Previous image link
     if (!empty($this->_params['image_view_url'])) {
         $view->prev_url = str_replace(array('%i', '%g', '%s'), array($prev, $this->gallery->id, $this->_slug), urldecode($this->_params['image_view_url']));
     } else {
         $view->prev_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $prev, 'view' => 'Image', 'page' => $page_prev), $this->_date));
     }
     $prevImgSrc = Ansel::getImageUrl($prev, 'screen', true, $this->_style);
     // Next image link
     if (!empty($this->_params['image_view_url'])) {
         $view->next_url = str_replace(array('%i', '%g', '%s'), array($prev, $this->gallery->id, $this->_slug), urldecode($this->_params['image_view_url']));
     } else {
         $view->next_url = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $next, 'view' => 'Image', 'page' => $page_next), $this->_date));
     }
     $nextImgSrc = Ansel::getImageUrl($next, 'screen', true, $this->_style);
     // Slideshow link
     if (!empty($this->_params['slideshow_link'])) {
         $this->_urls['slideshow'] = str_replace(array('%i', '%g'), array($this->resource->id, $this->gallery->id), urldecode($this->_params['slideshow_link']));
     } else {
         $this->_urls['slideshow'] = Horde::url('view.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id, 'view' => 'Slideshow'), $this->_date));
     }
     // These items don't work when viewing through the api
     if (empty($this->_params['api'])) {
         $this->addWidget(Ansel_Widget::factory('Tags', array('view' => 'image')));
         $this->addWidget(Ansel_Widget::factory('SimilarPhotos'));
         $this->addWidget(Ansel_Widget::factory('Geotag', array('images' => array($this->resource->id))));
         if ($conf['faces']['driver']) {
             $this->addWidget(Ansel_Widget::factory('ImageFaces', array('selfUrl' => $this->_urls['self'])));
         }
         $this->addWidget(Ansel_Widget::factory('Links', array()));
         // In line caption editing
         if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_EditCaption', array('width' => $this->_geometry['width'], 'id' => 'anselcaption', 'dataid' => $this->resource->id));
         }
     }
     // Output the js if we are calling via the api
     if (!empty($this->_params['api'])) {
         foreach (array('prototype.js', 'stripe.js', 'scriptaculous/effects.js') as $val) {
             $tmp = new Horde_Script_File_JsDir($val, 'horde');
             Horde::startBuffer();
             echo $tmp->tag_full;
             $html = Horde::endBuffer();
         }
     } else {
         $html = '';
     }
     $js = array();
     if (empty($this->_params['hide_slideshow'])) {
         $js[] = '$$(\'.ssPlay\').each(function(n) { n.show(); });';
     }
     $js = array_merge($js, array('AnselImageView.nextImgSrc = "' . $nextImgSrc . '"', 'AnselImageView.prevImgSrc = "' . $prevImgSrc . '"', 'AnselImageView.urls = { "imgsrc": "' . $this->_urls['imgsrc'] . '" }', 'AnselImageView.onload()'));
     $page_output->addInlineScript($js);
     // Pass the urls now that we have them all.
     $view->urls = $this->_urls;
     // Get the exif data if needed.
     if ($prefs->getValue('showexif')) {
         $view->exif = array_chunk($this->resource->getAttributes(), 3, true);
     }
     // Comments
     if ($comments = $this->_getCommentData()) {
         if (!empty($comments['threads'])) {
             $this->view->commentHtml = '<br>' . $comments['threads'];
         }
         if (!empty($comments['comments'])) {
             $this->view->commentHtml .= '<br>' . $comments['comments'];
         }
     }
     return $html . $view->render('image');
 }