*/
public $attributessecondary = array();
+ /**
+ * The string to use next to the icon for the action icon relating to the secondary (dropdown) menu.
+ * @var array
+ */
+ public $actiontext = null;
+
+ /**
+ * An icon to use for the toggling the secondary menu (dropdown).
+ * @var pix_icon
+ */
+ public $actionicon;
+
/**
* Constructs the action menu with the given items.
*
'aria-labelledby' => 'action-menu-toggle-'.$this->instance,
'role' => 'menu'
);
+ $this->actionicon = new pix_icon(
+ 't/contextmenu',
+ new lang_string('actions', 'moodle'),
+ 'moodle',
+ array('class' => 'iconsmall', 'title' => '')
+ );
$this->set_alignment(self::TR, self::BR);
foreach ($actions as $action) {
$this->add($action);
if ($output === null) {
$output = $OUTPUT;
}
- $title = get_string('actions', 'moodle');
- $pixicon = $output->pix_icon(
- 't/contextmenu',
- $title,
- 'moodle',
- array('class' => 'iconsmall', 'title' => '')
- );
-
+ $pixicon = $this->actionicon;
+ $title = new lang_string('actions', 'moodle');
+ if ($pixicon instanceof renderable) {
+ $pixicon = $output->render($pixicon);
+ if ($pixicon instanceof pix_icon && isset($pixicon->attributes['alt'])) {
+ $title = $pixicon->attributes['alt'];
+ }
+ }
+ $string = '';
+ if ($this->actiontext) {
+ $string = $this->actiontext;
+ }
$actions = $this->primaryactions;
$attributes = array(
'class' => 'toggle-display',
'id' => 'action-menu-toggle-'.$this->instance,
'role' => 'menuitem'
);
- $actions[] = html_writer::link('#', $pixicon, $attributes);
+ $actions[] = html_writer::link('#', $string.$pixicon, $attributes);
return $actions;
}
* @param bool $primary Whether this is a primary action or not.
* @param array $attributes Any attribtues associated with the action.
*/
- public function __construct(moodle_url $url, pix_icon $icon, $text, $primary = true, array $attributes = array()) {
+ public function __construct(moodle_url $url, pix_icon $icon = null, $text, $primary = true, array $attributes = array()) {
parent::__construct($url, $text, null, $attributes, $icon);
$this->primary = (bool)$primary;
$this->add_class('menu-action');
* @param string $text
* @param array $attributes
*/
- public function __construct(moodle_url $url, pix_icon $icon, $text, array $attributes = array()) {
+ public function __construct(moodle_url $url, pix_icon $icon = null, $text, array $attributes = array()) {
parent::__construct($url, $icon, $text, true, $attributes);
}
}
* @param string $text
* @param array $attributes
*/
- public function __construct(moodle_url $url, pix_icon $icon, $text, array $attributes = array()) {
+ public function __construct(moodle_url $url, pix_icon $icon = null, $text, array $attributes = array()) {
parent::__construct($url, $icon, $text, false, $attributes);
}
}