本文整理汇总了PHP中Horde_Util类的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Util类的具体用法?PHP Horde_Util怎么用?PHP Horde_Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Horde_Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: minify
/**
*/
public function minify()
{
if (!is_executable($this->_opts['java']) || !is_readable($this->_opts['closure'])) {
$this->_opts['logger']->log('The java path or Closure location can not be accessed.', Horde_Log::ERR);
return parent::minify();
}
$cmd = trim(escapeshellcmd($this->_opts['java']) . ' -jar ' . escapeshellarg($this->_opts['closure']));
if (isset($this->_opts['sourcemap']) && is_array($this->_data)) {
$this->_sourcemap = Horde_Util::getTempFile();
$cmd .= ' --create_source_map ' . escapeshellarg($this->_sourcemap) . ' --source_map_format=V3';
$suffix = "\n//# sourceMappingURL=" . $this->_opts['sourcemap'];
} else {
$suffix = '';
}
if (isset($this->_opts['cmdline'])) {
$cmd .= ' ' . trim($this->_opts['cmdline']);
}
if (is_array($this->_data)) {
$js = '';
foreach ($this->_data as $val) {
$cmd .= ' ' . $val;
}
} else {
$js = $this->_data;
}
$cmdline = new Horde_JavascriptMinify_Util_Cmdline();
return $cmdline->runCmd($js, $cmd, $this->_opts['logger']) . $suffix . $this->_sourceUrls();
}
示例2: token
/**
* Renders a token into text matching the requested format.
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
if (!isset($options['attr']['alt'])) {
$options['attr']['alt'] = $options['src'];
}
if (strpos($options['src'], '://') === false) {
if ($options['src'][0] != '/') {
if (strpos($options['src'], ':')) {
list($page, $options['src']) = explode(':', $options['src'], 2);
} else {
$page = Horde_Util::getFormData('page');
if ($page == 'EditPage') {
$page = Horde_Util::getFormData('referrer');
}
if (empty($page)) {
$page = 'Wiki/Home';
}
}
$params = array('page' => $page, 'mime' => '1', 'file' => $options['src']);
$options['src'] = $GLOBALS['registry']->downloadUrl($options['src'], $params)->setRaw(true);
}
} else {
$options['src'] = new Horde_Url(Horde::externalUrl($options['src']));
$options['src']->setRaw(true);
}
// Send external links through Horde::externalUrl().
if (isset($options['attr']['link']) && strpos($options['attr']['link'], '://')) {
$href = htmlspecialchars($options['attr']['link']);
unset($options['attr']['link']);
return Horde::link(Horde::externalUrl($href), $href) . $this->_token($options) . '</a>';
} else {
return $this->_token($options);
}
}
示例3: _delete
/**
* Copyright 2001-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 Jon Parise <jon@horde.org>
* @author Jan Schneider <jan@horde.org>
*/
function _delete($task_id, $tasklist_id)
{
global $injector, $nag_shares, $notification, $registry;
if (!empty($task_id)) {
try {
$task = Nag::getTask($tasklist_id, $task_id);
$task->loadChildren();
try {
$share = $nag_shares->getShare($tasklist_id);
} catch (Horde_Share_Exception $e) {
throw new Nag_Exception($e);
}
if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
$notification->push(_("Access denied deleting task."), 'horde.error');
} else {
$storage = $injector->getInstance('Nag_Factory_Driver')->create($tasklist_id);
try {
$storage->delete($task_id);
} catch (Nag_Exception $e) {
$notification->push(sprintf(_("There was a problem deleting %s: %s"), $task->name, $e->getMessage()), 'horde.error');
}
$notification->push(sprintf(_("Deleted %s."), $task->name), 'horde.success');
}
} catch (Nag_Exception $e) {
$notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
}
}
/* Return to the last page or to the task list. */
if ($url = Horde_Util::getFormData('url')) {
header('Location: ' . $url);
exit;
}
Horde::url('list.php', true)->redirect();
}
示例4: _uploadFTP
/**
* Does an FTP upload to save the configuration.
*/
function _uploadFTP($params)
{
global $registry, $notification;
$params['hostspec'] = 'localhost';
try {
$vfs = Horde_Vfs::factory('ftp', $params);
} catch (Horde_Vfs_Exception $e) {
$notification->push(sprintf(_("Could not connect to server \"%s\" using FTP: %s"), $params['hostspec'], $e->getMessage()), 'horde.error');
return false;
}
/* Loop through the config and write to FTP. */
$no_errors = true;
foreach ($GLOBALS['session']->get('horde', 'config/') as $app => $config) {
$path = $registry->get('fileroot', $app) . '/config';
/* Try to back up the current conf.php. */
if ($vfs->exists($path, 'conf.php')) {
try {
$vfs->rename($path, 'conf.php', $path, '/conf.bak.php');
$notification->push(_("Successfully saved backup configuration."), 'horde.success');
} catch (Horde_Vfs_Exception $e) {
$notification->push(sprintf(_("Could not save a backup configuation: %s"), $e->getMessage()), 'horde.error');
}
}
try {
$vfs->writeData($path, 'conf.php', $config);
$notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success');
$GLOBALS['session']->remove('horde', 'config/' . $app);
} catch (Horde_Vfs_Exception $e) {
$no_errors = false;
$notification->push(sprintf(_("Could not write configuration for \"%s\": %s"), $app, $e->getMessage()), 'horde.error');
}
}
$registry->rebuild();
return $no_errors;
}
示例5: content
/**
* Renders this page in content mode.
*
* @return string The page content.
* @throws Wicked_Exception
*/
public function content()
{
global $wicked;
$days = (int) Horde_Util::getGet('days', 3);
$summaries = $wicked->getRecentChanges($days);
if (count($summaries) < 10) {
$summaries = $wicked->mostRecent(10);
}
$bydate = array();
$changes = array();
foreach ($summaries as $page) {
$page = new Wicked_Page_StandardPage($page);
$createDate = $page->versionCreated();
$tm = localtime($createDate, true);
$createDate = mktime(0, 0, 0, $tm['tm_mon'], $tm['tm_mday'], $tm['tm_year'], $tm['tm_isdst']);
$version_url = $page->pageUrl()->add('version', $page->version());
$diff_url = Horde::url('diff.php')->add(array('page' => $page->pageName(), 'v1' => '?', 'v2' => $page->version()));
$diff_alt = sprintf(_("Show changes for %s"), $page->version());
$diff_img = Horde::img('diff.png', $diff_alt);
$pageInfo = array('author' => $page->author(), 'name' => $page->pageName(), 'url' => $page->pageUrl(), 'version' => $page->version(), 'version_url' => $version_url, 'version_alt' => sprintf(_("Show version %s"), $page->version()), 'diff_url' => $diff_url, 'diff_alt' => $diff_alt, 'diff_img' => $diff_img, 'created' => $page->formatVersionCreated(), 'change_log' => $page->changeLog());
$bydate[$createDate][$page->versionCreated()][$page->version()] = $pageInfo;
}
krsort($bydate);
foreach ($bydate as $bysecond) {
$day = array();
krsort($bysecond);
foreach ($bysecond as $pageList) {
krsort($pageList);
$day = array_merge($day, array_values($pageList));
}
$changes[] = array('date' => $day[0]['created'], 'pages' => $day);
}
return $changes;
}
示例6: processRequest
public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
{
$id = Horde_Util::getFormData('bookmark');
$gateway = $this->getInjector()->getInstance('Trean_Bookmarks');
$notification = $this->getInjector()->getInstance('Horde_Notification');
try {
$bookmark = $gateway->getBookmark($id);
$old_url = $bookmark->url;
$bookmark->url = Horde_Util::getFormData('bookmark_url');
$bookmark->title = Horde_Util::getFormData('bookmark_title');
$bookmark->description = Horde_Util::getFormData('bookmark_description');
$bookmark->tags = Horde_Util::getFormData('treanBookmarkTags');
if ($old_url != $bookmark->url) {
$bookmark->http_status = '';
}
$bookmark->save();
$result = array('data' => 'saved');
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("There was an error saving the bookmark: %s"), $e->getMessage()), 'horde.error');
$result = array('error' => $e->getMessage());
}
if (Horde_Util::getFormData('format') == 'json') {
$response->setContentType('application/json');
$response->setBody(json_encode($result));
} else {
$response->setRedirectUrl(Horde_Util::getFormData('url', Horde::url('browse.php', true)));
}
}
示例7: close
function close($focus = false)
{
echo '</form>' . "\n";
if (Horde_Util::getGet('reply_focus')) {
echo '<script type="text/javascript">document.getElementById("message_body").focus()</script>';
}
}
示例8: menu
/**
*/
public function menu($menu)
{
$scope = Horde_Util::getGet('scope', 'agora');
/* Agora Home. */
$url = Horde::url('forums.php')->add('scope', $scope);
$menu->add($url, _("_Forums"), 'forums.png', null, null, null, dirname($_SERVER['PHP_SELF']) == $GLOBALS['registry']->get('webroot') && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
/* Thread list, if applicable. */
if (isset($GLOBALS['forum_id'])) {
$menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('threads.php')), _("_Threads"), 'threads.png');
if ($scope == 'agora' && $GLOBALS['registry']->getAuth()) {
$menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('messages/edit.php')), _("New Thread"), 'newmessage.png');
}
}
if ($scope == 'agora' && Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
$menu->add(Horde::url('editforum.php'), _("_New Forum"), 'newforum.png', null, null, null, Horde_Util::getFormData('agora') ? '__noselection' : null);
}
if (Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
$url = Horde::url('moderate.php')->add('scope', $scope);
$menu->add($url, _("_Moderate"), 'moderate.png');
}
if ($GLOBALS['registry']->isAdmin()) {
$menu->add(Horde::url('moderators.php'), _("_Moderators"), 'hot.png');
}
$url = Horde::url('search.php')->add('scope', $scope);
$menu->add($url, _("_Search"), 'search.png');
}
示例9: _renderInfo
/**
* Return the rendered information about the Horde_Mime_Part object.
*
* URL parameters used by this function:
* - zip_contents: (integer) If set, show contents of ZIP file.
*
* @return array See Horde_Mime_Viewer_Driver::render().
*/
protected function _renderInfo()
{
global $injector;
$vars = $injector->getInstance('Horde_Variables');
if (!$this->getConfigParam('show_contents') && !$vars->zip_contents) {
$status = new IMP_Mime_Status($this->_mimepart, _("This is a compressed file."));
$status->addMimeAction('zipViewContents', _("Click to display the file contents."));
$status->icon('mime/compressed.png');
return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
}
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mime'));
$view->addHelper('Text');
$view->downloadclass = 'zipdownload';
$view->files = array();
$view->tableclass = 'zipcontents';
$zlib = Horde_Util::extensionExists('zlib');
foreach ($this->_getZipInfo() as $key => $val) {
$file = new stdClass();
$file->name = $val['name'];
$file->size = IMP::sizeFormat($val['size']);
/* TODO: Add ability to render in-browser for filetypes we can
* handle. */
if (!empty($val['size']) && strstr($val['attr'], 'D') === false && ($zlib && $val['method'] == 0x8 || $val['method'] == 0x0)) {
$file->download = $this->getConfigParam('imp_contents')->linkView($this->_mimepart, 'download_render', '', array('class' => 'iconImg downloadAtc', 'jstext' => _("Download"), 'params' => array('zip_attachment' => $key)));
} else {
$file->download = '';
}
$view->files[] = $file;
}
return array($this->_mimepart->getMimeId() => array('data' => $view->render('compressed'), 'type' => 'text/html; charset=UTF-8'));
}
示例10: __construct
/**
* Const'r
*
* @see Horde_Image_Base::_construct
*/
public function __construct($params, $context = array())
{
if (!Horde_Util::loadExtension('imagick')) {
throw new Horde_Image_Exception('Required PECL Imagick extension not found.');
}
parent::__construct($params, $context);
ini_set('imagick.locale_fix', 1);
$this->_imagick = new Imagick();
if (!empty($params['filename'])) {
$this->loadFile($params['filename']);
} elseif (!empty($params['data'])) {
$this->loadString($params['data']);
} else {
$this->_width = max(array($this->_width, 1));
$this->_height = max(array($this->_height, 1));
try {
$this->_imagick->newImage($this->_width, $this->_height, $this->_background);
} catch (ImagickException $e) {
throw new Horde_Image_Exception($e);
}
}
try {
$this->_imagick->setImageFormat($this->_type);
} catch (ImagickException $e) {
throw new Horde_Image_Exception($e);
}
}
示例11: _getFaces
/**
* Get faces
*
* @param string $file Picture filename
* @throws Horde_Exception
*/
protected function _getFaces($file)
{
if (!Horde_Util::loadExtension('facedetect')) {
throw new Ansel_Exception('You do not have the facedetect extension enabled in PHP');
}
return face_detect($file, $this->_defs);
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$storage1 = new Horde_SessionHandler_Storage_File(array('path' => self::$dir));
$storage2 = new Horde_SessionHandler_Storage_File(array('path' => Horde_Util::createTempDir()));
self::$handler = new Horde_SessionHandler_Storage_Stack(array('stack' => array($storage1, $storage2)));
}
示例13: html
public function html($active = true)
{
if (!$this->contact) {
echo '<h3>' . _("The requested contact was not found.") . '</h3>';
return;
}
if (!$this->contact->hasPermission(Horde_Perms::DELETE)) {
if (!$this->contact->hasPermission(Horde_Perms::READ)) {
echo '<h3>' . _("You do not have permission to view this contact.") . '</h3>';
return;
} else {
echo '<h3>' . _("You only have permission to view this contact.") . '</h3>';
return;
}
}
echo '<div id="DeleteContact"' . ($active ? '' : ' style="display:none"') . '>';
?>
<form action="<?php
echo Horde::url('delete.php');
?>
" method="post">
<?php
echo Horde_Util::formInput();
?>
<input type="hidden" name="url" value="<?php
echo htmlspecialchars(Horde_Util::getFormData('url'));
?>
" />
<input type="hidden" name="source" value="<?php
echo htmlspecialchars($this->contact->driver->getName());
?>
" />
<input type="hidden" name="key" value="<?php
echo htmlspecialchars($this->contact->getValue('__key'));
?>
" />
<div class="headerbox" style="padding: 8px">
<p><?php
echo _("Permanently delete this contact?");
?>
</p>
<input type="submit" class="horde-delete" name="delete" value="<?php
echo _("Delete");
?>
" />
</div>
</form>
</div>
<?php
if ($active && $GLOBALS['browser']->hasFeature('dom')) {
if ($this->contact->hasPermission(Horde_Perms::READ)) {
$view = new Turba_View_Contact($this->contact);
$view->html(false);
}
if ($this->contact->hasPermission(Horde_Perms::EDIT)) {
$delete = new Turba_View_EditContact($this->contact);
$delete->html(false);
}
}
}
示例14: minify
/**
*/
public function minify()
{
if (!is_executable($this->_opts['java']) || !is_readable($this->_opts['closure'])) {
$this->_opts['logger']->log('The java path or Closure location can not be accessed.', Horde_Log::ERR);
return parent::minify();
}
/* --warning_level QUIET - closure default is "DEFAULT" which will
* cause code with compiler warnings to output bad js (see Bug
* #13789) */
$cmd = trim(escapeshellcmd($this->_opts['java']) . ' -jar ' . escapeshellarg($this->_opts['closure']) . ' --warning_level QUIET');
if (isset($this->_opts['sourcemap']) && is_array($this->_data)) {
$this->_sourcemap = Horde_Util::getTempFile();
$cmd .= ' --create_source_map ' . escapeshellarg($this->_sourcemap) . ' --source_map_format=V3';
$suffix = "\n//# sourceMappingURL=" . $this->_opts['sourcemap'];
} else {
$suffix = '';
}
if (isset($this->_opts['cmdline'])) {
$cmd .= ' ' . trim($this->_opts['cmdline']);
}
if (is_array($this->_data)) {
$js = '';
foreach ($this->_data as $val) {
$cmd .= ' ' . $val;
}
} else {
$js = $this->_data;
}
$cmdline = new Horde_JavascriptMinify_Util_Cmdline();
return $cmdline->runCmd($js, $cmd, $this->_opts['logger']) . $suffix . $this->_sourceUrls();
}
示例15: __construct
/**
* Const'r
*
*/
public function __construct($bookmarks = null, $browser = null)
{
$this->_bookmarks = $bookmarks;
if ($browser) {
$this->_browser = $browser;
} else {
$this->_browser = $GLOBALS['injector']->getInstance('Trean_TagBrowser');
}
$action = Horde_Util::getFormData('actionID', '');
switch ($action) {
case 'remove':
$tag = Horde_Util::getFormData('tag');
if (isset($tag)) {
$this->_browser->removeTag($tag);
$this->_browser->save();
}
break;
case 'add':
default:
// Add new tag to the stack, save to session.
$tag = Horde_Util::getFormData('tag');
if (isset($tag)) {
$this->_browser->addTag($tag);
$this->_browser->save();
}
}
// Check for empty tag search.. then do what?
$this->_noSearch = $this->_browser->tagCount() < 1;
}