Пример #1
0
 /**
  * Create and configure a {@link COMMAND}.
  * @param string $caption Text of the command.
  * @param string $url Link for the command action.
  * @param string $icon Path to the icon for the command.
  * @param bool $selected Renders as selected without the link if
  * <code>True</code>.
  * @param $link_title string The title to use for the url if the command is not selected.
  * @return COMMAND
  * @access private
  */
 protected function _make_command($caption, $url, $icon, $selected, $link_title)
 {
     $Result = $this->commands->make_command();
     $Result->id = 'item_' . mt_rand();
     if ($selected) {
         $Result->caption = "<span class=\"selected\">{$caption}</span>";
     } else {
         $Result->caption = $caption;
         $Result->link = $url;
         $Result->link_title = $link_title;
     }
     $Result->icon = $icon;
     return $Result;
 }
 /**
  * Returns a list of commands for this renderer.
  * @return \COMMANDS
  */
 public function make_commands()
 {
     $Result = new COMMANDS($this->context);
     if ($this->_comment_query->size() > 1) {
         $command = $Result->make_command();
         $Result->append($command);
         switch ($this->comment_mode) {
             case Comment_render_flat:
                 $command->caption = 'Show Threaded';
                 $command->link = $this->_obj->home_page() . "&comment_mode=threaded#comments";
                 break;
             case Comment_render_threaded:
                 $command->caption = 'Show Flat';
                 $command->link = $this->_obj->home_page() . "&comment_mode=flat#comments";
                 break;
         }
     }
     return $Result;
 }
Пример #3
0
 public function make_commands($context)
 {
     $Result = new COMMANDS($context);
     if ($this->enabled && $this->file_name) {
         $url = new URL($this->page->resolve_file($this->file_name, Force_root_on));
         foreach ($this->formats as $format => $format_title) {
             foreach ($this->content_formats as $content => $content_texts) {
                 $content_title = $content_texts[0];
                 $content_description = $content_texts[1];
                 $url->replace_argument('format', $format);
                 $url->replace_argument('content', $content);
                 $cmd = $Result->make_command();
                 $cmd->id = $format . '_' . $content;
                 $cmd->caption = '<b>' . $content_title . '</b> (' . $format_title . ')';
                 if ($format == 'rss') {
                     $cmd->icon = '{icons}indicators/newsfeed_rss';
                 } else {
                     $cmd->icon = '{icons}indicators/newsfeed_atom';
                     $cmd->description = $content_description;
                 }
                 $cmd->link = $url->as_text();
                 $Result->append($cmd);
             }
         }
     }
     return $Result;
 }
Пример #4
0
 /**
  * Draw a single-line text control with a 'browse' button onto a separate row in the form.
  *
  * @param string $id The id of the field to render.
  * @param FORM_LIST_ITEM[] $items The items to include as options in the chooser.
  * @param FORM_TEXT_CONTROL_OPTIONS $options Override the default text control rendering; can be null.
  * @param string $css_class The class to apply to the overall container.
  * @return string
  */
 public function text_line_with_chooser_as_html($id, $items, $options = null, $css_class = 'browse')
 {
     $result = '<span class="' . $css_class . '">';
     $result .= $this->text_line_as_html($id, $options);
     $commands = new COMMANDS($this->context);
     foreach ($items as $item) {
         $cmd = $commands->make_command();
         $cmd->id = $item->text;
         $cmd->caption = $item->title;
         $cmd->on_click = 'set_control_value(event, \'' . $id . '\', \'' . $item->value . '\')';
         $cmd->link = '#';
         $commands->append($cmd);
     }
     $menu_renderer = $this->context->make_menu_renderer();
     $menu_renderer->set_size(Menu_size_minimal);
     $menu_renderer->menu_class .= ' chooser';
     ob_start();
     $menu_renderer->display($commands);
     $result .= ob_get_contents();
     ob_end_clean();
     $result .= '</span>';
     return $result;
 }