コード例 #1
0
 public function getAdminUI($subclass_admin_interface = null, $title = null)
 {
     $html = null;
     /* width and height */
     $max_width = $this->getKVP(get_class($this) . '_max_width');
     $max_height = $this->getKVP(get_class($this) . '_max_height');
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Maximum display size") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "banner_add_group_{this->getId()}_widthxheight";
     $html .= FormSelectGenerator::generateFromKeyLabelArray($this->predefinedSizes, $max_width . '/' . $max_height, $name, null, true, _('Use the values below for width and height'));
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*max_width*/
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Width") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "banner_add_group_{this->getId()}_max_width";
     $html .= "<input type='text' size='6' value='{$max_width}' name='{$name}'>\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*max_height*/
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Height") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "banner_add_group_{this->getId()}_max_height";
     $html .= "<input type='text' size='6' value='{$max_height}' name='{$name}'>\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     return parent::getAdminUI($html, $title);
 }
コード例 #2
0
ファイル: User.php プロジェクト: soitun/wifidog-auth
 public function getAdminUI()
 {
     $db = AbstractDb::getObject();
     $currentUser = self::getCurrentUser();
     $userPreferencesItems = array();
     $finalHtml = '';
     if (Security::hasPermission(Permission::P('NETWORK_PERM_VIEW_STATISTICS'), $this->getNetwork())) {
         /* Statistics */
         $content = "<a href='" . BASE_SSL_PATH . "admin/stats.php?Statistics=" . $this->getNetwork()->getId() . "&distinguish_users_by=user_id&stats_selected_users=" . $this->getUsername() . "&UserReport=on&user_id=" . $this->getId() . "&action=generate'>" . _("Get user statistics") . "</a>\n";
         $administrationItems[] = InterfaceElements::genSectionItem($content);
         /* Account status */
         $title = _("Account Status");
         $help = _("Note that Error is for internal use only");
         $name = "user_" . $this->getId() . "_accountstatus";
         global $account_status_to_text;
         $content = FormSelectGenerator::generateFromKeyLabelArray($account_status_to_text, $this->getAccountStatus(), $name, null, false);
         $administrationItems[] = InterfaceElements::genSectionItem($content, $title, $help);
         $finalHtml .= InterfaceElements::genSection($administrationItems, _("Administrative options"));
     }
     if ($this == $currentUser && !$this->isSplashOnlyUser() || Security::hasPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
         /* Username */
         $title = _("Username");
         $name = "user_" . $this->getId() . "_username";
         $content = "<input type='text' name='{$name}' value='" . htmlentities($this->getUsername()) . "' size=30><br/>\n";
         $content .= _("Be careful when changing this: it's the username you use to log in!");
         $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title);
         /* Email */
         $title = _("Email");
         $name = "email_" . $this->getId() . "_email";
         $content = "<input type='text' name='{$name}' disabled='disabled' value='" . htmlentities($this->getEmail()) . "' size=30><br/>\n";
         $content .= _("If you wish to change this address, please Email Support!");
         $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title);
         /* Change password */
         $changePasswordItems = array();
         if ($this == $currentUser) {
             //Don't enter the old password if changing password for another user
             $title = _("Your current password");
             $name = "user_" . $this->getId() . "_oldpassword";
             $content = "<input type='password' name='{$name}' size='20'>\n";
             $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         }
         $title = _("Your new password");
         $name = "user_" . $this->getId() . "_newpassword";
         $content = "<input type='password' name='{$name}' size='20'>\n";
         $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         $title = _("Your new password (again)");
         $name = "user_" . $this->getId() . "_newpassword_again";
         $content = "<input type='password' name='{$name}' size='20'>\n";
         $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         $userPreferencesItems[] = InterfaceElements::genSection($changePasswordItems, _("Change my password"));
         $finalHtml .= InterfaceElements::genSection($userPreferencesItems, _("User preferences"), false, false, get_class($this));
         //N.B: For now, let pretend we have only one profile per use...
         $profiles = $this->getAllProfiles();
         $current_profile = null;
         if (!empty($profiles)) {
             $current_profile = $profiles[0];
         }
         if ($current_profile != null) {
             $finalHtml .= $current_profile->getAdminUI();
             $name = "user_" . $this->getId() . "_delete_profile_" . $current_profile->getId();
             $value = _("Completely delete my public profile");
             $finalHtml .= "<div class='admin_element_tools'>";
             $finalHtml .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
             $finalHtml .= "</div>";
         } else {
             // Get the list of profile templates for the users' network
             $profile_templates = ProfileTemplate::getAllProfileTemplates($this->getNetwork());
             if (!empty($profile_templates)) {
                 $name = "user_" . $this->getId() . "_add_profile";
                 $value = _("Create my public profile");
                 $finalHtml .= "<div class='admin_element_tools'>";
                 $finalHtml .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
                 $finalHtml .= "</div>";
             }
         }
     }
     return $finalHtml;
 }
コード例 #3
0
ファイル: RssAggregator.php プロジェクト: soitun/wifidog-auth
 /**
  * Shows the administration interface for RssAggregator
  *
  * @param string $subclass_admin_interface HTML code to be added after the
  *                                         administration interface
  *
  * @return string HTML code for the administration interface
  */
 public function getAdminUI($subclass_admin_interface = null, $title = null)
 {
     $this->initFeedPressReview();
     $db = AbstractDb::getObject();
     // Init values
     $html = '';
     $feed_urls = null;
     $tab = array();
     $i = 0;
     $html .= "<ul class='admin_element_list'>\n";
     /*
      * number_of_display_items
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Total number of items to display (from all feeds)") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "rss_aggregator_" . $this->id . "_display_num_items";
     $value = $this->getDisplayNumItems();
     $html .= "<input type='text' size='2' value='{$value}' name='{$name}'>\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * algorithm_strength
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>\n";
     $title = _("How much bonus feeds that do not publish as often get over feed that publish more often.\n                                            The default is 0.75, with a typical range between 0 and 1.\n                                            At 0, you have a classic RSS aggregator, meaning the n most recent entries picked from all feeds\n                                            will be displayed. 1 is usually as high as you'll want to go:  Assuming that all feeds have \n                                            an homogenous internal distribution (ex:  one feed publishes exactly one entry a day, the\n                                            second once every two days, and the third once every three days), and you ask for 15 entries,\n                                            there will be 5 of each.  While that may not sound usefull, it still is, as the feed's distribution is\n                                            usually not homogenous.");
     $html .= "<a href=\"#\" title=\"{$title}\">" . _("Algorithm Strength") . "</a>\n";
     $html .= ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "rss_aggregator_" . $this->id . "_algorithm_strength";
     $value = $this->getAlgorithmStrength();
     $html .= "<input type='text' size='2' value='{$value}' name='{$name}'>\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * feed_expansion
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>\n";
     $title = _("Set the criteria that determines which feed items will be shown expanded by default.");
     $html .= "<a href=\"#\" title=\"{$title}\">" . _("Feed item expansion criteria") . "</a>\n";
     $html .= ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $array = FeedPressReview::getFeedExpansionAllowedOptions();
     $value = $this->getFeedExpansionMode();
     $name = "rss_aggregator_" . $this->id . "_feed_expansion";
     $html .= FormSelectGenerator::generateFromKeyLabelArray($array, $value, $name, null, false);
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * feed_ordering
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>\n";
     $title = _("Set in which order the feeds are displayed, and if items from all source should be merged together");
     $html .= "<a href=\"#\" title=\"{$title}\">" . _("Item ordering") . "</a>\n";
     $html .= ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $array = FeedPressReview::getFeedOrderingAllowedOptions();
     $value = $this->getFeedOrdering();
     $name = "rss_aggregator_" . $this->id . "_feed_ordering";
     $html .= FormSelectGenerator::generateFromKeyLabelArray($array, $value, $name, null, false);
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * display_empty_feeds
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Display empty feeds?") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "rss_aggregator_" . $this->id . "_display_empty_feeds";
     $this->getDisplayEmptyFeed() ? $checked = 'CHECKED' : ($checked = '');
     $html .= "<input type='checkbox' name='{$name}' {$checked}>\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * max_item_age
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>\n";
     $title = _("Set the oldest entries (in seconds) you are willing to see.  Any entries older than this will not\n                                            be considered at all for display, even if it means that the configured number of items to be displayed isn't reached.\n                                            It's only usefull if all your feed publish very rarely, and you don't want very old entries to show up.");
     $html .= "<a href=\"#\" title=\"{$title}\">" . _("Maximum age (seconds)") . "</a>\n";
     $html .= ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "rss_aggregator_" . $this->id . "_max_item_age";
     $value = $this->getMaxItemAge();
     $html .= "<input type='text' size='10' value='{$value}' name='{$name}'>\n";
     $html .= _("seconds");
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * rss_aggregator_element (table)
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Feeds:") . "</div>\n";
     $html .= "<ul class='admin_element_list'>\n";
     foreach ($this->content_rss_aggregator_feeds_rows as $feed_row) {
         $html .= "<li class='admin_element_item_container'>\n";
         $html .= "<div class='admin_element_data'>\n";
         $html .= $this->getFeedAdminUI($feed_row);
         $html .= "</div'>\n";
         $html .= "<div class='admin_element_tools'>\n";
         /*
          * Delete feeds
          */
         $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_delete";
         $html .= "<input type='submit' name='{$name}' value='" . _("Delete") . "'>";
         $html .= "</div>\n";
         $html .= "</li>\n";
     }
     /*
      * Add new feed
      */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<b>" . _("Add a new feed or pick one from the other feeds in the system (most_popular_first)") . "</b><br>";
     $sql = "SELECT DISTINCT ON (count, content_rss_aggregator_feeds.url) count, content_rss_aggregator_feeds.url, title FROM content_rss_aggregator_feeds\n                                        JOIN (SELECT url, count(content_rss_aggregator_feeds.url) as count\n                                        FROM content_rss_aggregator_feeds\n                                        WHERE content_rss_aggregator_feeds.url NOT IN (SELECT url FROM content_rss_aggregator_feeds WHERE content_id='{$this->id}')\n                                        GROUP BY content_rss_aggregator_feeds.url, content_rss_aggregator_feeds.url)\n                                        AS available_feeds\n                                        ON (available_feeds.url=content_rss_aggregator_feeds.url)\n                                        ORDER by count desc, content_rss_aggregator_feeds.url DESC";
     $db->execSql($sql, $feed_urls, false);
     if ($feed_urls) {
         foreach ($feed_urls as $feed_row) {
             $tab[$i][0] = $feed_row['url'];
             empty($feed_row['title']) ? $title = $feed_row['url'] : ($title = $feed_row['title']);
             $tab[$i][1] = sprintf(_("%s, used %d times"), $title, $feed_row['count']);
             $i++;
         }
     }
     $name = "rss_aggregator_{$this->id}_feed_add";
     $html .= "<input type='text' size='60' value='' name='{$name}' id='{$name}'>\n";
     $html .= FormSelectGenerator::generateFromArray($tab, null, 'existing_feeds', 'RssAggregator', true, _('Type URL manually'), "onchange='this.form.{$name}.value=this.value;'");
     $name = "rss_aggregator_{$this->id}_feed_add_button";
     $html .= "<input type='submit' name='{$name}' value='" . _("Add") . "'>";
     $html .= "</li>\n";
     $html .= "</ul>\n";
     $html .= "</li>\n";
     $html .= "</ul>\n";
     $html .= $subclass_admin_interface;
     return parent::getAdminUI($html, $title);
 }
コード例 #4
0
 public function getAdminUI($subclass_admin_interface = null, $title = null)
 {
     $html = '';
     $html .= "<fieldset class='admin_element_group'>\n";
     $html .= "<legend>" . sprintf(_("%s configuration"), get_class($this)) . "</legend>\n";
     /* content_ordering_mode */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("In what order should the content displayed?") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_" . $this->id . "_content_ordering_mode";
     $html .= FormSelectGenerator::generateFromKeyLabelArray($this->CONTENT_ORDERING_MODES, $this->getContentOrderingMode(), $name, null, false);
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*content_changes_on_mode */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("When does the content rotate?") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_" . $this->id . "_content_changes_on_mode";
     $html .= FormSelectGenerator::generateFromKeyLabelArray($this->CONTENT_CHANGES_ON_MODES, $this->getContentChangesOnMode(), $name, null, false);
     $html .= "</div>\n";
     $html .= "</li>\n";
     /* allow_repeat*/
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Can content be shown more than once to the same user?") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_" . $this->id . "_allow_repeat";
     $html .= FormSelectGenerator::generateFromKeyLabelArray($this->ALLOW_REPEAT_MODES, $this->getAllowRepeat(), $name, null, false);
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*display_num_elements*/
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Pick how many elements for each display?") . ": </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_" . $this->id . "_display_num_elements";
     $value = $this->getDisplayNumElements();
     $html .= "<input type='text' size='2' value='{$value}' name='{$name}'>\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     /* Subclass UI */
     $html .= $subclass_admin_interface;
     $html .= "</fieldset>\n";
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<fieldset class='admin_element_group'>\n";
     $html .= "<legend>" . sprintf(_("%s display element list"), get_class($this)) . "</legend>\n";
     /* content_group_element*/
     $name = "content_group_" . $this->id . "_show_expired_elements_request";
     if (empty($_REQUEST[$name])) {
         $showExpired = false;
         $additionalWhere = "AND (valid_until_timestamp IS NULL OR valid_until_timestamp >= CURRENT_TIMESTAMP) \n";
         $title_str = _("Show expired group elements");
         $html .= "<a name='group_select' onclick=\"document.getElementById('{$name}').value='" . !$showExpired . "';document.generic_object_form.submit();\">{$title_str}</a>\n";
     } else {
         $showExpired = true;
         $additionalWhere = null;
         $title_str = _("Hide expired group elements");
         $html .= "<a name='group_select' onclick=\"document.getElementById('{$name}').value='" . !$showExpired . "';document.generic_object_form.submit();\">{$title_str}</a>\n";
     }
     $html .= "<input type='hidden' name='{$name}' id='{$name}' value='{$showExpired}'>\n";
     $name = "content_group_" . $this->id . "_expired_elements_shown";
     $html .= "<input type='hidden' name='{$name}' id='{$name}' value='{$showExpired}'>\n";
     $html .= "<ul class='admin_element_list'>\n";
     foreach ($this->getElements($additionalWhere) as $element) {
         $html .= "<li class='admin_element_item_container'>\n";
         $html .= $element->getAdminUI(null, sprintf(_("%s %d"), get_class($element), $element->getDisplayOrder()));
         $html .= "<div class='admin_element_tools'>\n";
         $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase";
         $html .= "<input type='submit' class='submit' name='{$name}' value='" . sprintf(_("Delete %s %d"), get_class($element), $element->getDisplayOrder()) . "'>";
         $html .= "</div>\n";
         $html .= "</li>\n";
     }
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= self::getNewContentUI("content_group_{$this->id}_new_element", $this->allowed_content_types);
     $html .= "</li>\n";
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= self::getSelectExistingContentUI("content_group_{$this->id}_existing_element", "AND content_id != '{$this->id}' AND is_persistent=TRUE", $this->allowed_content_types);
     $html .= "</li>\n";
     $html .= "</ul>\n";
     $html .= "</fieldset>\n";
     $html .= "</li>\n";
     return parent::getAdminUI($html, $title);
 }