Ejemplo n.º 1
0
 /**
 		@brief		Return the link.
 		@since		2015-12-27 13:13:20
 	**/
 public function display_link()
 {
     $r = new \plainview\sdk_broadcast\html\div();
     $r->tag = 'a';
     if ($this->current) {
         $r->css_class('current');
     }
     $r->set_attribute('href', $this->url);
     $text = $this->display_name();
     if ($this->count > 0) {
         $text .= sprintf(' <span class="count">%s</span>', $this->count);
     }
     $r->title($this->title);
     $r->content($text);
     return $r . '';
 }
Ejemplo n.º 2
0
 public function __toString()
 {
     $div = new \plainview\sdk_broadcast\html\div();
     $div->css_class('tablenav');
     $div->css_class('top');
     $size = 0;
     foreach ($this->left as $left) {
         $l = new \plainview\sdk_broadcast\html\div();
         $l->css_class('alignleft');
         $string = $left->__toString();
         $l->content = $string . '&nbsp;';
         $size += strlen($string);
         $div->content .= $l;
     }
     // No real string to display? Don't display anything.
     if ($size < 1) {
         return '';
     }
     return $div . '';
 }
Ejemplo n.º 3
0
 /**
 		@brief		Return the plugins table.
 		@since		2014-05-08 15:48:39
 	**/
 public function get_plugins_table()
 {
     $form = $this->form2();
     $r = '';
     $table = $this->table();
     $plugins = new plugins($this);
     // Fill the plugins with all of the available classes
     $action = new actions\get_plugin_classes();
     // The prefix is the basename of the plugin pack class, with an underscore.
     // Not \threewp_broadcast\premium_pack\ThreeWP_Broadcast_Premium_Pack but ThreeWP_Broadcast_Premium_Pack_
     $action->__prefix = preg_replace('/.*\\\\/', '', get_called_class()) . '_';
     $action->add(static::get_plugin_classes());
     $action->execute();
     $plugins->populate($action->classes);
     // Plugins class for the coloring.
     $table = $this->table()->css_class('plugin_pack plugins with_groups');
     $row = $table->head()->row();
     $table->bulk_actions()->form($form)->add($this->_('Activate plugin'), 'activate_plugin')->add($this->_('Deactivate plugin'), 'deactivate_plugin')->add($this->_('Uninstall plugin'), 'uninstall_plugin')->cb($row);
     $row->th()->text(__('Plugin'));
     $row->th()->text(__('Description'));
     if ($form->is_posting()) {
         if ($table->bulk_actions()->pressed()) {
             $ids = $table->bulk_actions()->get_rows();
             $action = $table->bulk_actions()->get_action();
             $message = $this->_('No action selected.');
             foreach ($plugins->from_ids($ids) as $plugin) {
                 $classname = $plugin->get_classname();
                 $this->plugins()->populate($classname);
                 $new_plugin = $this->plugins()->get($classname)->plugin();
                 switch ($action) {
                     case 'activate_plugin':
                         $new_plugin->activate_internal();
                         $message = $this->_('The selected plugin(s) have been activated.');
                         break;
                     case 'deactivate_plugin':
                         $new_plugin->deactivate_internal();
                         $this->plugins()->forget($classname);
                         $message = $this->_('The selected plugin(s) have been deactivated.');
                         break;
                     case 'uninstall_plugin':
                         $new_plugin->deactivate_internal();
                         $new_plugin->uninstall_internal();
                         $this->plugins()->forget($classname);
                         $message = $this->_('The selected plugin(s) have been uninstalled.');
                         break;
                     default:
                         $this->plugins()->forget($classname);
                 }
                 $this->plugins()->save();
             }
             $this->message($message);
         }
     }
     $old_group = '';
     foreach ($plugins->by_groups() as $group => $plugins) {
         foreach ($plugins as $plugin) {
             $group = $plugin->get_comment('plugin_group');
             if ($old_group != $group) {
                 $old_group = $group;
                 // The group slug helps the javascript to group the rows together.
                 $group_slug = sanitize_title($group);
                 $row = $table->body()->row()->css_class('inactive group')->data('group', $group_slug);
                 $row->th()->css_class('plugin_group name')->colspan(3)->text($group);
             }
             $row = $table->body()->row()->css_class('plugin')->data('group', $group_slug);
             $cb = $table->bulk_actions()->cb($row, $plugin->get_id());
             $td = $row->td();
             // Assemble a label.
             $label = new \plainview\sdk_broadcast\html\div();
             $label->tag = 'label';
             $label->set_attribute('for', $cb->get_id());
             $label->content = $plugin->get_name();
             $td->text($label);
             $td->css_class('plugin-title');
             if ($this->plugins()->has($plugin->get_classname())) {
                 $row->css_class('active');
             } else {
                 $row->css_class('inactive');
             }
             $text = $plugin->get_brief_description();
             $row->td()->text($text);
         }
     }
     $r .= $form->open_tag();
     $r .= $table;
     $r .= $form->close_tag();
     return $r;
 }
Ejemplo n.º 4
0
 /**
 		@brief		Return an input container div.
 		@return		string		A div HTML element with lots of helpful classes set.
 		@since		20130815
 	**/
 public function get_display_div()
 {
     $r = new \plainview\sdk_broadcast\html\div();
     $r->css_class('form_item')->css_class('form_item_' . $this->make_id());
     if (isset($this->type)) {
         $r->css_class('form_item_' . $this->type);
     }
     if (isset($this->tag)) {
         $r->css_class('form_item_' . $this->tag);
     }
     // Get all the css classes for this input and add them to the div
     $r->css_class($this->get_attribute('class'));
     // It would be a good idea if the container could include information about the status of the input.
     if ($this->has_validation_errors()) {
         $r->css_class('does_not_validate');
     }
     if ($this->is_required()) {
         $r->css_class('required');
     }
     // Hidden?
     if ($this->is_hidden()) {
         $r->hidden();
     }
     return $r;
 }