本文整理汇总了PHP中Horde_Themes_Image::tag方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Themes_Image::tag方法的具体用法?PHP Horde_Themes_Image::tag怎么用?PHP Horde_Themes_Image::tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Themes_Image
的用法示例。
在下文中一共展示了Horde_Themes_Image::tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _content
/**
*/
protected function _content()
{
$phases = $this->_calculateMoonPhases(date('Y'));
$now = time();
$lastNew = 0;
$lastNewStamp = 0;
$offset = 0;
foreach ($phases as $key => $val) {
if ($key < $now && $key > $lastNewStamp && $val == _("New Moon")) {
$lastNew = $offset;
$lastNewStamp = $key;
}
$offset++;
}
$dates = isset($this->_params['phase']) && $this->_params['phase'] == 'next' ? array_slice(array_keys($phases), $lastNew + 4, 4) : array_slice(array_keys($phases), $lastNew, 4);
$location = isset($this->_params['hemisphere']) && $this->_params['hemisphere'] == 'northern' ? _("Northern Hemisphere") : _("Southern Hemisphere");
$html = '<table width="100%" height="100%" cellspacing="0">' . '<tr><td colspan="4" class="control"><strong>' . $location . '</strong></td></tr>' . '<tr height="100%"><td width="25%" align="center">' . Horde_Themes_Image::tag('block/moon/newmoon.png', array('alt' => _("New Moon"))) . '<br />' . strftime($GLOBALS['prefs']->getValue('date_format_mini'), $dates[0]) . '</td>';
$html .= '<td width="25%" align="center">';
if (isset($this->_params['hemisphere']) && $this->_params['hemisphere'] == 'northern') {
$html .= Horde_Themes_Image::tag('block/moon/lastquarter.png', array('alt' => _("First Quarter")));
} else {
$html .= Horde_Themes_Image::tag('block/moon/firstquarter.png', array('alt' => _("First Quarter")));
}
$html .= '<br />' . strftime($GLOBALS['prefs']->getValue('date_format_mini'), $dates[1]) . '</td>';
$html .= '<td width="25%" align="center">' . Horde_Themes_Image::tag('block/moon/fullmoon.png', array('alt' => _("Full Moon"))) . '<br />' . strftime($GLOBALS['prefs']->getValue('date_format_mini'), $dates[2]) . '</td>';
$html .= '<td width="25%" align="center">';
if (isset($this->_params['hemisphere']) && $this->_params['hemisphere'] == 'northern') {
$html .= Horde_Themes_Image::tag('block/moon/firstquarter.png', array('alt' => _("Last Quarter")));
} else {
$html .= Horde_Themes_Image::tag('block/moon/lastquarter.png', array('alt' => _("Last Quarter")));
}
$html .= '<br />' . strftime($GLOBALS['prefs']->getValue('date_format_mini'), $dates[3]) . '</td></tr></table>';
return $html;
}
示例2: _content
/**
*/
protected function _content()
{
global $page_output;
$name = strval(new Horde_Support_Randomid());
$page_output->addScriptFile('vatid.js', 'horde');
$page_output->addInlineScript(array('$("' . $name . '").observe("submit", HordeBlockVatid.onSubmit.bindAsEventListener(HordeBlockVatid))'), true);
return '<form style="padding:2px" action="' . $this->_ajaxUpdateUrl() . '" id="' . $name . '">' . Horde_Util::formInput() . Horde::label('vatid', _("VAT identification number:")) . '<br /><input type="text" length="14" name="vatid" />' . '<br /><input type="submit" id="vatbutton" value="' . _("Check") . '" class="horde-default" /> ' . Horde_Themes_Image::tag('loading.gif', array('alt' => _("Checking"), 'attr' => array('style' => 'display:none'))) . '<div class="vatidResults"></div>' . '</form>';
}
示例3: generateFlagImageByHost
/**
* Generate a flag image tag.
*
* @param string $host The hostname.
*
* @return string An HTML IMG tag (or empty if host is not found).
*/
public static function generateFlagImageByHost($host)
{
if (($data = self::getFlagImageObByHost($host)) === false) {
return '';
}
$img = Horde_Themes_Image::tag($data['ob'], array('alt' => $data['name'], 'attr' => array('title' => $data['name'])));
return $img ? $img : '[' . $data['name'] . ']';
}
示例4: _renderVarInput_TurbaTags
/**
* Render tag field.
*/
protected function _renderVarInput_TurbaTags($form, $var, $vars)
{
$varname = htmlspecialchars($var->getVarName());
$value = $var->getValue($vars);
$html = sprintf('<input id="%s" type="text" name="%s" value="%s" />', $varname, $varname, $value);
$html .= sprintf('<span id="%s_loading_img" style="display:none;">%s</span>', $varname, Horde_Themes_Image::tag('loading.gif', array('alt' => _("Loading..."))));
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Turba_Ajax_Imple_TagAutoCompleter', array('id' => $varname));
return $html;
}
示例5: _content
/**
*/
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> ' . Horde_Themes_Image::tag('loading.gif', array('attr' => array('id' => 'cloudloadingimg', 'style' => 'display:none;'))) . '</div>' . $cloud->buildHTML() . '<div id="cloudsearch"></div>';
}
示例6: _init
/**
*/
protected function _init()
{
global $browser, $injector, $page_output, $registry;
$page_output->addScriptFile('base.js');
$page_output->addScriptFile('passphrase.js');
$page_output->addScriptFile('viewport.js');
$page_output->addScriptFile('external/CustomElements.js');
$page_output->addScriptFile('external/time-elements.js');
$page_output->addScriptFile('external/tinycon.js');
$page_output->addScriptFile('dragdrop2.js', 'horde');
$page_output->addScriptFile('form_ghost.js', 'horde');
$page_output->addScriptFile('jstorage.js', 'horde');
$page_output->addScriptFile('slider2.js', 'horde');
$page_output->addScriptFile('toggle_quotes.js', 'horde');
$page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
$page_output->addScriptPackage('IMP_Script_Package_Imp');
$page_output->addThemeStylesheet('mailbox.css');
$page_output->addThemeStylesheet('message_view.css');
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if ($imp_imap->access(IMP_Imap::ACCESS_FLAGS)) {
$page_output->addScriptFile('colorpicker.js', 'horde');
$this->view->picker_img = Horde_Themes_Image::tag('colorpicker.png', array('alt' => _("Color Picker")));
}
if ($imp_imap->access(IMP_Imap::ACCESS_REMOTE)) {
$page_output->addScriptFile('external/base64.js');
}
$this->_addMailboxVars();
$this->view->show_innocent = !empty($imp_imap->config->innocent_params);
$this->view->show_search = $imp_imap->access(IMP_Imap::ACCESS_SEARCH);
$this->view->show_spam = !empty($imp_imap->config->spam_params);
$impSubinfo = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/dynamic'));
$impSubinfo->addHelper('Text');
$impSubinfo->quota = (bool) $imp_imap->config->quota;
$topbar = $injector->getInstance('Horde_View_Topbar');
$topbar->search = $this->view->show_search;
$topbar->searchMenu = true;
$topbar->subinfo = $impSubinfo->render('mailbox_subinfo');
$page_output->topbar = true;
$blank = new Horde_Url();
$impSidebar = new Horde_View(array('templatePath' => array($registry->get('templates', 'horde') . '/sidebar', IMP_TEMPLATES . '/dynamic')));
$impSidebar->addHelper('Text');
$impSidebar->containers = array(array('id' => 'imp-specialmboxes'));
if ($imp_imap->isImap()) {
$impSidebar->containers[] = array('rows' => array(array('id' => 'folderopts_link', 'cssClass' => 'folderoptsImg', 'link' => $blank->link() . _("Folder Actions") . '</a>'), array('id' => 'dropbase', 'style' => 'display:none', 'cssClass' => 'folderImg', 'link' => $blank->link() . _("Move to Base Level") . '</a>')));
$impSidebar->containers[] = array('id' => 'imp-normalmboxes');
}
$sidebar = $injector->getInstance('Horde_View_Sidebar');
$sidebar->newLink = $blank->link(array('id' => 'composelink', 'class' => 'icon'));
$sidebar->newText = _("New Message");
$sidebar->content = $impSidebar->render('sidebar');
$this->view->sidebar = $sidebar->render();
$this->view->max_fsize = intval($browser->allowFileUploads());
$page_output->noDnsPrefetch();
$this->_pages[] = 'mailbox';
}
示例7: AddIcons
public static function AddIcons(&$p_recordSet, $p_iconFile, $p_altText, $p_fieldName, $p_conditionFilter)
{
/* Please note that inclusion occurs if EVERY field of the record included in
p_conditionFilter match the provided value */
$v_icon = Horde_Themes_Image::tag($p_iconFile, array('alt' => $p_altText));
foreach ($p_recordSet as &$v_record) {
$v_isIncluded = true;
foreach ($p_conditionFilter as $v_fieldName => $v_fieldValue) {
if ($v_record[$v_fieldName] !== $v_fieldValue) {
$v_isIncluded = false;
}
}
$v_record[$p_fieldName] = $v_isIncluded ? $v_icon : NULL;
}
}
示例8: minisearch
/**
* AJAX action: Return Turba minisearch information.
*
* Variables used:
* - abooks: (array) UIDs of source addressbook.
* - search: (string) Search string.
*
* @return object HTML search output in the 'html' parameter.
*/
public function minisearch()
{
global $attributes, $injector, $registry;
$ob = new stdClass();
$results = array();
$search = trim($this->vars->search);
if (!is_null($search)) {
foreach (Horde_Serialize::unserialize($this->vars->abooks, Horde_Serialize::JSON) as $val) {
try {
$res = $injector->getInstance('Turba_Factory_Driver')->create($val)->search(array('name' => $search));
while ($ob = $res->next()) {
if ($ob->isGroup()) {
continue;
}
foreach ($ob->getAttributes() as $k => $v) {
if (!empty($attributes[$k]['type']) && $attributes[$k]['type'] == 'email') {
if (!empty($v)) {
try {
$mail_link = $registry->call('mail/compose', array(array('to' => $v)));
} catch (Horde_Exception $e) {
$mail_link = 'mailto:' . urlencode($v);
}
}
$link = empty($v) ? htmlspecialchars($ob->getValue('name')) : htmlspecialchars($ob->getValue('name') . ' <' . $v . '>');
$results[] = '<li class="linedRow">' . Horde::link(Horde::url($ob->url()), _("View Contact"), '', '_parent') . Horde_Themes_Image::tag('contact.png', array('alt' => _("View Contact"))) . '</a> ' . (!empty($v) ? '<a href="' . $mail_link . '">' : '') . $link . (!empty($v) ? '</a>' : '') . '</li>';
break;
}
}
}
} catch (Turba_Exception $e) {
}
}
}
if (count($results)) {
$ob->html = '<ul>' . implode('', $results) . '</ul>';
} elseif (!is_null($search)) {
$ob->html = _("No contacts found");
}
return $ob;
}
示例9: source
/**
* Create code needed for source selection.
*
* @param array $data Data items:
* <pre>
* 'mainlabel' - (string) Main label.
* 'no_up' - (boolean) [OPTIONAL] Disable movement of selected items
* up/down.
* 'selectlabel' - (array) Selected label.
* 'sourcelabel' - (string) [OPTIONAL] Source selection label.
* 'sources' - (array) List of sources - keys are source names. Each
* source is an array with the entries: 'label', 'selected' and
* 'unselected'.
* 'unselectlabel' - (array) Unselected label.
* </pre>
*
* @return string HTML UI code.
*/
public static function source($data)
{
$t = $GLOBALS['injector']->createInstance('Horde_Template');
$t->set('mainlabel', $data['mainlabel']);
$t->set('selectlabel', $data['selectlabel']);
$t->set('unselectlabel', $data['unselectlabel']);
$sources = $labels = array();
foreach ($data['sources'] as $key => $val) {
$selected = $unselected = array();
foreach ($val['selected'] as $key2 => $val2) {
$selected[] = array('l' => $val2, 'v' => $key2);
}
foreach ($val['unselected'] as $key2 => $val2) {
$unselected[] = array('l' => $val2, 'v' => $key2);
}
$sources[$key] = array($selected, $unselected);
$labels[] = array('key' => $key, 'label' => $val['label']);
}
if (count($sources) == 1) {
$val = reset($sources);
$t->set('selected', $val[0]);
$t->set('unselected', $val[1]);
} else {
$t->set('source_select', true);
$t->set('sources', $labels);
$t->set('sourcelabel', $data['sourcelabel']);
$js = array();
foreach ($sources as $key => $val) {
$js[] = array('selected' => $val[0], 'source' => $key, 'unselected' => $val[1]);
}
$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineJsVars(array('HordeSourceSelectPrefs.source_list' => $js));
}
$t->set('addimg', Horde_Themes_Image::tag($GLOBALS['registry']->nlsconfig->curr_rtl ? 'lhand.png' : 'rhand.png', array('alt' => Horde_Core_Translation::t("Add source"))));
$t->set('removeimg', Horde_Themes_Image::tag($GLOBALS['registry']->nlsconfig->curr_rtl ? 'rhand.png' : 'lhand.png', array('alt' => Horde_Core_Translation::t("Remove source"))));
if (empty($data['no_up'])) {
$t->set('upimg', Horde_Themes_Image::tag('nav/up.png', array('alt' => Horde_Core_Translation::t("Move up"))));
$t->set('downimg', Horde_Themes_Image::tag('nav/down.png', array('alt' => Horde_Core_Translation::t("Move down"))));
}
return $t->fetch($GLOBALS['registry']->get('templates', 'horde') . '/prefs/source.html');
}
示例10: __toString
/**
* String representation of this object.
*
* @return string String representation.
*/
public function __toString()
{
switch ($this->type) {
case 'imp.forward':
$img = 'forwarded.png';
$label = _("Forward");
break;
case 'imp.redirect':
$img = 'forwarded.png';
$label = _("Redirect");
break;
case 'imp.reply':
case 'imp.reply_all':
case 'imp.reply_list':
$img = 'answered.png';
$label = _("Reply");
break;
default:
return parent::__toString();
}
return Horde_Themes_Image::tag(Horde_Themes::img($img, 'imp'), array('alt' => $label)) . '<div class="noticetext">' . parent::__toString() . '</div>';
}
示例11: display
/**
*/
public function display(Horde_Core_Prefs_Ui $ui)
{
global $injector, $page_output, $prefs;
if (!$ui->nobuttons) {
$page_output->addScriptFile('hordecore.js', 'horde');
$page_output->addScriptFile('colorpicker.js', 'horde');
$page_output->addScriptFile('prefs/flag.js');
}
$p_css = new Horde_Themes_Element('prefs.css');
$page_output->addStylesheet($p_css->fs, $p_css->uri);
$page_output->addInlineJsVars(array('ImpFlagPrefs.new_prompt' => _("Please enter the label for the new flag:"), 'ImpFlagPrefs.confirm_delete' => _("Are you sure you want to delete this flag?")));
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
$view->addHelper('FormTag');
$view->addHelper('Tag');
$view->locked = $prefs->isLocked('msgflags');
$view->picker_img = Horde_Themes_Image::tag('colorpicker.png', array('alt' => _("Color Picker")));
$out = array();
$flaglist = $injector->getInstance('IMP_Flags')->getList();
foreach ($flaglist as $val) {
$hash = $val->hash;
$bgid = 'bg_' . $hash;
$color = $val->bgdefault ? '' : $val->bgcolor;
$tmp = array();
if ($val instanceof IMP_Flag_User) {
$tmp['label'] = htmlspecialchars($val->label);
$tmp['label_name'] = 'label_' . $hash;
$tmp['user'] = true;
} else {
$tmp['icon'] = $val->span;
$tmp['label'] = Horde::label($bgid, $val->label);
}
$tmp['color'] = $color;
$tmp['colorid'] = $bgid;
$tmp['colorstyle'] = 'color:' . $val->fgcolor . ';' . (strlen($color) ? 'background-color:' . $color . ';' : '');
$out[] = $tmp;
}
$view->flags = $out;
return $view->render('flags');
}
示例12: _content
/**
*/
protected function _content()
{
if (empty($this->_params['location'])) {
throw new Horde_Exception(_("No location is set."));
}
// Set the timezone variable, if available.
$GLOBALS['registry']->setTimeZone();
list($lat, $long) = explode(':', $this->_params['location']);
$rise = $this->_calculateSunset(time(), $lat, $long, false, floor(date('Z') / 3600));
$set = $this->_calculateSunset(time(), $lat, $long, true, floor(date('Z') / 3600));
$location = '';
global $coordinates;
if (!is_array($coordinates)) {
require 'Horde/Nls/Coordinates.php';
}
foreach ($coordinates as $country) {
if (array_key_exists($this->_params['location'], $country)) {
$location = $country[$this->_params['location']];
break;
}
}
return '<table width="100%" height="100%" cellspacing="0"><tr>' . '<td colspan="2" class="control"><strong>' . $location . '</strong></td></tr><tr height="100%">' . '<td width="50%" align="center">' . Horde_Themes_Image::tag('block/sunrise/sunrise.png', array('alt' => _("Sun Rise"))) . '<br />' . $rise . '</td>' . '<td width="50%" align="center">' . Horde_Themes_Image::tag('block/sunrise/sunset.png', array('alt' => _("Sun Set"))) . '<br />' . $set . '</td>' . '</tr></table>';
}
示例13: _
<?php
}
?>
</tr>
<?php
$futureDays++;
?>
<?php
}
?>
</table>
<!-- Logo -->
<?php
if ($this->logo) {
?>
<div class="rightAlign"><?php
echo _("Weather data provided by") . ' ' . Horde::link(Horde::externalUrl($this->link), $this->title, '', '_blank', '', $this->title) . Horde_Themes_Image::tag($this->logo);
?>
</a></div>
<?php
} else {
?>
<div class="rightAlign"><?php
echo _("Weather data provided by") . ' ' . Horde::link(Horde::externalUrl($this->link), $this->title, '', '_blank', '', $this->title) . '<em>' . $this->title;
?>
</em></a></div>
<?php
}
?>
<?php
}
示例14: getSummary
/**
* Get summary info for a MIME ID.
*
* @param string $id The MIME ID.
* @param integer $mask A bitmask indicating what information to return:
* <pre>
* Always output:
* 'type' = MIME type
*
* IMP_Contents::SUMMARY_BYTES
* Output: parts = 'bytes'
*
* IMP_Contents::SUMMARY_SIZE
* Output: parts = 'size'
*
* IMP_Contents::SUMMARY_ICON
* IMP_Contents::SUMMARY_ICON_RAW
* Output: parts = 'icon'
*
* IMP_Contents::SUMMARY_DESCRIP
* Output: parts = 'description_raw'
*
* IMP_Contents::SUMMARY_DESCRIP_LINK
* Output: parts = 'description'
*
* IMP_Contents::SUMMARY_DOWNLOAD
* Output: parts = 'download', 'download_url'
*
* IMP_Contents::SUMMARY_IMAGE_SAVE
* Output: parts = 'img_save'
*
* IMP_Contents::SUMMARY_PRINT
* IMP_Contents::SUMMARY_PRINT_STUB
* Output: parts = 'print'
*
* IMP_Contents::SUMMARY_STRIP
* Output: parts = 'strip'
* </pre>
*
* @return array An array with the requested information.
*/
public function getSummary($id, $mask = 0)
{
$autodetect_link = false;
$param_array = array();
$this->_buildMessage();
$part = array('bytes' => null, 'download' => null, 'download_url' => null, 'id' => $id, 'img_save' => null, 'size' => null, 'strip' => null);
$mime_part = $this->getMimePart($id, array('nocontents' => true));
if (!$mime_part) {
return $part;
}
$mime_type = $mime_part->getType();
/* If this is an attachment that has no specific MIME type info, see
* if we can guess a rendering type. */
if (in_array($mime_type, array('application/octet-stream', 'application/base64'))) {
$mime_type = Horde_Mime_Magic::filenameToMIME($mime_part->getName());
if ($mime_type == $mime_part->getType()) {
$autodetect_link = true;
} else {
$mime_part = clone $mime_part;
$mime_part->setType($mime_type);
$param_array['ctype'] = $mime_type;
}
}
$part['type'] = $mime_type;
/* Is this part an attachment? */
$is_atc = $mime_part->isAttachment();
/* Get bytes/size information. */
if ($mask & self::SUMMARY_BYTES || $mask & self::SUMMARY_SIZE) {
$part['bytes'] = $size = $mime_part->getBytes();
$part['size'] = $size > 1048576 ? sprintf(_("%s MB"), IMP::numberFormat($size / 1048576, 1)) : sprintf(_("%s KB"), max(round($size / 1024), 1));
}
/* Get part's icon. */
if ($mask & self::SUMMARY_ICON || $mask & self::SUMMARY_ICON_RAW) {
$part['icon'] = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->getIcon($mime_type);
if ($mask & self::SUMMARY_ICON) {
$part['icon'] = Horde_Themes_Image::tag($part['icon'], array('attr' => array('title' => $mime_type)));
}
} else {
$part['icon'] = null;
}
/* Get part's description. */
$description = $this->getPartName($mime_part, true);
if ($mask & self::SUMMARY_DESCRIP_LINK) {
if (($can_d = $this->canDisplay($mime_part, self::RENDER_FULL)) || $autodetect_link) {
$part['description'] = $this->linkViewJS($mime_part, 'view_attach', htmlspecialchars($description), array('jstext' => sprintf(_("View %s"), $description), 'params' => array_filter(array_merge($param_array, array('autodetect' => !$can_d)))));
} else {
$part['description'] = htmlspecialchars($description);
}
}
if ($mask & self::SUMMARY_DESCRIP) {
$part['description_raw'] = $description;
}
/* Download column. */
if ($is_atc && $mask & self::SUMMARY_DOWNLOAD) {
$part['download'] = $this->linkView($mime_part, 'download_attach', '', array('attr' => array('download' => $mime_part->getName(true) ?: $mime_part->getPrimaryType()), 'class' => 'iconImg downloadAtc', 'jstext' => _("Download")));
$part['download_url'] = $this->urlView($mime_part, 'download_attach');
}
/* Display the image save link if the required registry calls are
* present. */
//.........这里部分代码省略.........
示例15: setupEditForm
/**
* Create a permission editing form.
*
* @param Horde_Perms_Permission $permission TODO
*/
public function setupEditForm($permission)
{
/* Initialise form if required. */
$this->_formInit();
$this->_form->setButtons(Horde_Core_Translation::t("Update"), true);
$this->_vars->set('perm_id', $this->_perms->getPermissionId($permission));
$this->_form->addHidden('', 'perm_id', 'text', false);
/* Get permission configuration. */
$this->_type = $permission->get('type');
$params = $this->_corePerms->getParams($permission->getName());
/* Default permissions. */
$perm_val = $permission->getDefaultPermissions();
$this->_form->setSection('default', Horde_Core_Translation::t("All Authenticated Users"), Horde_Themes_Image::tag('perms.png'), false);
/* We MUST use 'deflt' for the variable name because 'default' is a
* reserved word in JavaScript. */
if ($this->_type == 'matrix') {
/* Set up the columns for the permissions matrix. */
$cols = Horde_Perms::getPermsArray();
/* Define a single matrix row for default perms. */
$matrix = array(Horde_Perms::integerToArray($perm_val));
$this->_form->addVariable('', 'deflt', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
} else {
$var = $this->_form->addVariable('', 'deflt', $this->_type, false, false, null, $params);
$var->setDefault($perm_val);
}
/* Guest permissions. */
$perm_val = $permission->getGuestPermissions();
$this->_form->setSection('guest', Horde_Core_Translation::t("Guest Permissions"), '', false);
if ($this->_type == 'matrix') {
/* Define a single matrix row for guest perms. */
$matrix = array(Horde_Perms::integerToArray($perm_val));
$this->_form->addVariable('', 'guest', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
} else {
$var = $this->_form->addVariable('', 'guest', $this->_type, false, false, null, $params);
$var->setDefault($perm_val);
}
/* Object creator permissions. */
$perm_val = $permission->getCreatorPermissions();
$this->_form->setSection('creator', Horde_Core_Translation::t("Creator Permissions"), Horde_Themes_Image::tag('user.png'), false);
if ($this->_type == 'matrix') {
/* Define a single matrix row for creator perms. */
$matrix = array(Horde_Perms::integerToArray($perm_val));
$this->_form->addVariable('', 'creator', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
} else {
$var = $this->_form->addVariable('', 'creator', $this->_type, false, false, null, $params);
$var->setDefault($perm_val);
}
/* Users permissions. */
$perm_val = $permission->getUserPermissions();
$this->_form->setSection('users', Horde_Core_Translation::t("Individual Users"), Horde_Themes_Image::tag('user.png'), false);
$auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
$user_list = array();
if ($auth->hasCapability('list')) {
/* The auth driver has list capabilities so set up an array which
* the matrix field type will recognise to set up an enum box for
* adding new users to the permissions matrix. */
$new_users = array();
try {
$user_list = $auth->listNames();
foreach ($user_list as $user => $name) {
if (!isset($perm_val[$user])) {
$new_users[$user] = $name;
}
}
} catch (Horde_Auth_Exception $e) {
$new_users = true;
}
} else {
/* No list capabilities, setting to true so that the matrix field
* type will offer a text input box for adding new users. */
$new_users = true;
}
if ($this->_type == 'matrix') {
/* Set up the matrix array, breaking up each permission integer
* into an array. The keys of this array will be the row
* headers. */
$rows = array();
$matrix = array();
foreach ($perm_val as $u_id => $u_perms) {
$rows[$u_id] = isset($user_list[$u_id]) ? $user_list[$u_id] : $u_id;
$matrix[$u_id] = Horde_Perms::integerToArray($u_perms);
}
$this->_form->addVariable('', 'u', 'matrix', false, false, null, array($cols, $rows, $matrix, $new_users));
} else {
if ($new_users) {
if (is_array($new_users)) {
$u_n = Horde_Util::getFormData('u_n');
$u_n = empty($u_n['u']) ? null : $u_n['u'];
$user_html = '<select name="u_n[u]"><option value="">' . Horde_Core_Translation::t("-- select --") . '</option>';
foreach ($new_users as $new_user => $name) {
$user_html .= '<option value="' . $new_user . '"';
$user_html .= $u_n == $new_user ? ' selected="selected"' : '';
$user_html .= '>' . htmlspecialchars($name) . '</option>';
}
$user_html .= '</select>';
//.........这里部分代码省略.........