/**
  * @param SUBSCRIBER $subscriber
  * @param NAMED_OBJECT $obj
  * @param string $page_name
  * @param bool $subscribed
  * @param bool $include_return_url
  * @param string $caption
  */
 protected function show_subscription($subscriber, $obj, $page_name, $subscribed, $include_return_url, $caption)
 {
     if (!$caption) {
         $type_info = $obj->type_info();
         $caption = strtolower($type_info->singular_title);
     }
     $url = new URL($obj->home_page());
     $url->replace_name_and_extension($page_name);
     $url->add_argument('subscribed', !$subscribed);
     $url->add_argument('email', $subscriber->email);
     if ($include_return_url) {
         $url->add_argument('return_url', urlencode($this->env->url(Url_part_no_host)));
     }
     echo '<tr>';
     echo '<th>' . $caption . '</th>';
     echo '<td>' . $obj->title_as_link() . '</td>';
     echo '<td>' . ($subscribed ? 'subscribed' : '<strong>not</strong> subscribed') . '</td>';
     echo '<td><a class="button" href="' . $url->as_html() . '">' . ($subscribed ? 'Unsubscribe' : 'Subscribe') . '</a></td>';
     echo '</tr>';
 }
 /**
  * Record difference between two objects, if any.
  * Pass in the name to use in the message and the two options. You can also specify your own text to use when
  * one of the objects is not set.
  * @param string $name
  * @param NAMED_OBJECT $orig The original object.
  * @param NAMED_OBJECT $new The new object.
  * @param string $empty_text Text to use when object is not set.
  * @param string $prefix Show this after each object's title.
  * @param string $suffix
  * @access private
  */
 protected function _record_object_difference($name, $orig, $new, $empty_text = '[not set]', $prefix = '', $suffix = '')
 {
     if (isset($orig)) {
         $t = $orig->title_formatter();
         $t->max_visible_output_chars = 0;
         $orig_title = $prefix . $orig->title_as_plain_text($t) . $suffix;
     } else {
         $orig_title = $empty_text;
     }
     if (isset($new)) {
         $t = $new->title_formatter();
         $t->max_visible_output_chars = 0;
         $new_title = $prefix . $new->title_as_plain_text($t) . $suffix;
     } else {
         $new_title = $empty_text;
     }
     $this->_record_string_difference($name, $orig_title, $new_title);
 }
 /**
  * @param DATABASE $db Database from which to load values.
  */
 public function load($db)
 {
     parent::load($db);
     $this->title = $db->f('title');
     $this->database_version = $db->f('version');
     $this->_version_not_found = empty($this->database_version);
 }
 /**
  * Return a {@link MUNGER} for the given object.
  * 
  * @param NAMED_OBJECT $obj
  * @param OBJECT_RENDERER_OPTIONS $options
  * @return MUNGER
  * @access private
  */
 protected function _make_formatter($obj, $options)
 {
     if ($this->_is_html($options)) {
         return $obj->html_formatter();
     }
     return $obj->plain_text_formatter();
 }
Esempio n. 5
0
 /**
  * @access private
  */
 protected function _create()
 {
     if ($this->kind == Privilege_kind_group) {
         $this->db->logged_query("SELECT MAX(importance) FROM {$this->app->table_names->folder_permissions}" . " WHERE folder_id = {$this->folder_id} AND kind = '" . Privilege_kind_group . "'");
         if ($this->db->next_record()) {
             $this->importance = $this->db->f(0) + 1;
         } else {
             $this->importance = 1;
         }
     }
     parent::_create();
 }
 /**
  * Emit a piece of text as plain text.
  * Used standard formatting provided by the {@link NAMED_OBJECT::plain_text_formatter()}
  * and settings from {@link _prepare_formatter()}.
  * 
  * @param NAMED_OBJECT $obj
  * @param string $text
  * @private
  */
 protected function _echo_text_as_plain_text($obj, $text)
 {
     if ($text) {
         $munger = $obj->plain_text_formatter();
         $this->_prepare_formatter($munger);
         $munger->right_margin = $this->_options->right_margin;
         echo $this->line($munger->transform($text, $obj));
     }
 }
 /**
  * Return a description for use in logging.
  * @return string
  */
 public function instance_description()
 {
     $Result = parent::instance_description();
     if ($this->exists()) {
         $Result .= ', id=' . $this->id;
     } else {
         $Result .= ', new';
     }
     return $Result;
 }
 /**
  * Add this object's (unlinked) name to the location.
  * @param NAMED_OBJECT $obj
  * @param string $icon The optional icon to include with the object's menu item.
  */
 public function add_object_text($obj, $icon = '')
 {
     $t = $obj->title_formatter();
     $t->max_visible_output_chars = 0;
     $this->append($obj->title_as_html($t), '', $icon);
 }