コード例 #1
0
 /** Return a string containing HTML definition of a forms select box containing countries
  * @return string
  */
 public static function getAvailableCountriesFormSelect()
 {
     $array_tmp = array();
     foreach (self::$implementations_map as $key => $value) {
         $array_tmp[] = array($key, $key);
     }
     return FormSelectGenerator::generateFromArray($array_tmp, null, "country", null, false);
 }
コード例 #2
0
ファイル: Content.php プロジェクト: soitun/wifidog-auth
 /**
  * Retreives the admin interface of this object. Anything that overrides
  * this method should call the parent method with it's output at the END of
  * processing.
  * @param string $subclass_admin_interface HTML content of the interface
  * element of a children.
  * @return string The HTML fragment for this interface.
  */
 public function getAdminUI($subclass_admin_interface = null, $title = null)
 {
     $db = AbstractDb::getObject();
     $html = '';
     if (!(User::getCurrentUser()->DEPRECATEDisSuperAdmin() || $this->DEPRECATEDisOwner(User::getCurrentUser()))) {
         $html .= $this->getListUI();
         $html .= ' ' . _("(You do not have access to edit this piece of content)");
     } else {
         $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
         if (!empty($title)) {
             $html .= "<legend>{$title}</legend>\n";
         }
         $html .= "<ul class='admin_element_list'>\n";
         if ($this->getObjectType() == 'Content') {
             // The object hasn't yet been typed.
             $html .= _("You must select a content type: ");
             $i = 0;
             foreach (self::getAvailableContentTypes() as $classname) {
                 $tab[$i][0] = $classname;
                 $tab[$i][1] = $classname;
                 $i++;
             }
             $html .= FormSelectGenerator::generateFromArray($tab, null, "content_" . $this->id . "_content_type", "Content", false);
         } else {
             $criteria_array = array(array('isSimpleContent'));
             $metadada_allowed_content_types = ContentTypeFilter::getObject($criteria_array);
             // Content metadata
             if ($this->isSimpleContent() == false || $this->isPersistent()) {
                 $html .= "<fieldset class='admin_element_group'>\n";
                 $html .= "<legend>" . sprintf(_("%s MetaData"), get_class($this)) . "</legend>\n";
                 /* title_is_displayed */
                 $html_title_is_displayed = _("Display the title?") . ": \n";
                 $name = "content_" . $this->id . "_title_is_displayed";
                 $this->titleShouldDisplay() ? $checked = 'CHECKED' : ($checked = '');
                 $html_title_is_displayed .= "<input type='checkbox' name='{$name}' {$checked}>\n";
                 /* title */
                 $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 if (empty($this->content_row['title'])) {
                     $html .= self::getNewContentUI("title_{$this->id}_new", $metadada_allowed_content_types, _("Title:"));
                     $html .= "</div>\n";
                 } else {
                     $html .= $html_title_is_displayed;
                     $title = self::getObject($this->content_row['title']);
                     $html .= $title->getAdminUI(null, _("Title:"));
                     $html .= "</div>\n";
                     $html .= "<div class='admin_element_tools admin_section_delete_title'>\n";
                     $name = "content_" . $this->id . "_title_erase";
                     $html .= "<input type='submit' class='submit' name='{$name}' value='" . sprintf(_("Delete %s (%s)"), _("title"), get_class($title)) . "'>";
                     $html .= "</div>\n";
                 }
                 $html .= "</li>\n";
             }
             if ($this->isSimpleContent() == false) {
                 /* description */
                 $html .= "<li class='admin_element_item_container admin_section_edit_description'>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 if (empty($this->content_row['description'])) {
                     $html .= self::getNewContentUI("description_{$this->id}_new", $metadada_allowed_content_types, _("Description:"));
                     $html .= "</div>\n";
                 } else {
                     $description = self::getObject($this->content_row['description']);
                     $html .= $description->getAdminUI(null, _("Description:"));
                     $html .= "</div>\n";
                     $html .= "<div class='admin_element_tools'>\n";
                     $name = "content_" . $this->id . "_description_erase";
                     $html .= "<input type='submit' class='submit' name='{$name}' value='" . sprintf(_("Delete %s (%s)"), _("description"), get_class($description)) . "'>";
                     $html .= "</div>\n";
                 }
                 $html .= "</li>\n";
                 /* long description */
                 $html .= "<li class='admin_element_item_container admin_section_edit_long_description'>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 if (empty($this->content_row['long_description'])) {
                     $html .= self::getNewContentUI("long_description_{$this->id}_new", $metadada_allowed_content_types, _("Long description:"));
                     $html .= "</div>\n";
                 } else {
                     $description = self::getObject($this->content_row['long_description']);
                     $html .= $description->getAdminUI(null, _("Long description:"));
                     $html .= "</div>\n";
                     $html .= "<div class='admin_element_tools'>\n";
                     $name = "content_" . $this->id . "_long_description_erase";
                     $html .= "<input type='submit' class='submit' name='{$name}' value='" . sprintf(_("Delete %s (%s)"), _("long description"), get_class($description)) . "'>";
                     $html .= "</div>\n";
                 }
                 $html .= "</li>\n";
                 /* project_info */
                 $html .= "<li class='admin_element_item_container admin_section_edit_project'>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 if (empty($this->content_row['project_info'])) {
                     $html .= self::getNewContentUI("project_info_{$this->id}_new", $metadada_allowed_content_types, _("Information on this project:"));
                     $html .= "</div>\n";
                 } else {
                     $project_info = self::getObject($this->content_row['project_info']);
                     $html .= $project_info->getAdminUI(null, _("Information on this project:"));
                     $html .= "</div>\n";
                     $html .= "<div class='admin_element_tools'>\n";
                     $name = "content_" . $this->id . "_project_info_erase";
                     $html .= "<input type='submit' class='submit' name='{$name}' value='" . sprintf(_("Delete %s (%s)"), _("project information"), get_class($project_info)) . "'>";
                     $html .= "</div>\n";
                 }
                 $html .= "</li>\n";
             }
             //End content medatada
             if ($this->isSimpleContent() == false || $this->isPersistent()) {
                 $html .= "</fieldset>\n";
             }
             if ($this->isSimpleContent() == false || $this->isPersistent()) {
                 $html .= "<fieldset class='admin_element_group'>\n";
                 $html .= "<legend>" . sprintf(_("%s access control"), get_class($this)) . "</legend>\n";
                 /* is_persistent */
                 $html .= "<li class='admin_element_item_container admin_section_edit_persistant'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Is part of reusable content library (protected from deletion)?") . ": </div>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $name = "content_" . $this->id . "_is_persistent";
                 $this->isPersistent() ? $checked = 'CHECKED' : ($checked = '');
                 $html .= "<input type='checkbox' name='{$name}' {$checked} onChange='submit();'>\n";
                 $html .= "</div>\n";
                 $html .= "</li>\n";
                 /* content_has_owners */
                 $html .= "<li class='admin_element_item_container content_has_owners'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Content owner list") . "</div>\n";
                 $html .= "<ul class='admin_element_list'>\n";
                 $db = AbstractDb::getObject();
                 $sql = "SELECT * FROM content_has_owners WHERE content_id='{$this->id}'";
                 $db->execSql($sql, $content_owner_rows, false);
                 if ($content_owner_rows != null) {
                     foreach ($content_owner_rows as $content_owner_row) {
                         $html .= "<li class='admin_element_item_container'>\n";
                         $html .= "<div class='admin_element_data'>\n";
                         $user = User::getObject($content_owner_row['user_id']);
                         $html .= $user->getListUI();
                         $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author";
                         $html .= " Is content author? ";
                         $content_owner_row['is_author'] == 't' ? $checked = 'CHECKED' : ($checked = '');
                         $html .= "<input type='checkbox' name='{$name}' {$checked}>\n";
                         $html .= "</div>\n";
                         $html .= "<div class='admin_element_tools'>\n";
                         $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove";
                         $html .= "<input type='submit' class='submit' name='{$name}' value='" . _("Remove owner") . "'>";
                         $html .= "</div>\n";
                         $html .= "</li>\n";
                     }
                 }
                 $html .= "<li class='admin_element_item_container'>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $add_button_name = "content_{$this->id}_add_owner_submit";
                 $add_button_value = _("Add owner");
                 $html .= User::getSelectUserUI("content_{$this->id}_new_owner", $add_button_name, $add_button_value);
                 $html .= "</div>\n";
                 $html .= "</li>\n";
                 $html .= "</ul>\n";
                 $html .= "</li>\n";
                 $html .= "</fieldset>\n";
             }
         }
         $html .= $subclass_admin_interface;
         $html .= "</ul>\n";
         $html .= "</fieldset>\n";
     }
     return $html;
 }
コード例 #3
0
ファイル: Network.php プロジェクト: cnlangzi/wifidog-auth
 /**
  * Get an interface to pick a Google maps type
  *
  * @param string $user_prefix           A identifier provided by the
  *                                      programmer to recognise it's
  *                                      generated html form
  * @param string $pre_selected_map_type The Google map type to be
  *                                      pre-selected in the form object
  *
  * @return string HTML markup
  */
 public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP")
 {
     $db = AbstractDb::getObject();
     // Init values
     $map_types = array(array("G_NORMAL_MAP", _("Map")), array("G_SATELLITE_MAP", _("Satellite")), array("G_HYBRID_MAP", _("Hybrid")));
     $name = $user_prefix;
     if ($pre_selected_map_type) {
         $selectedID = $pre_selected_map_type;
     } else {
         $selectedID = null;
     }
     $html = FormSelectGenerator::generateFromArray($map_types, $selectedID, $name, null, false);
     return $html;
 }
コード例 #4
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);
 }
コード例 #5
0
 /**
  * Get an interface to select a graph element
  *
  * @param string $user_prefix      A identifier provided by the programmer
  *                                 to recognise it's generated HTML form
  * @param string $user_data
  * This method understands:
  *  $userData['preSelectedObject'] An optional object to pre-select.
  *	$userData['additionalWhere'] Additional SQL conditions for the
  *                                    objects to select
  *	$userData['allowEmpty'] boolean Allow not selecting any object
  *
  * @return string HTML markup
  */
 public static function getSelectGraphElementUI($user_prefix, $userData = null)
 {
     $userData = $userData === null ? array() : $userData;
     $html = '';
     $name = $user_prefix;
     //pretty_print_r($userData);
     array_key_exists('preSelectedObject', $userData) ? empty($userData['preSelectedObject']) ? $selected_id = null : ($selected_id = $userData['preSelectedObject']->getId()) : ($selected_id = 0);
     !empty($userData['additionalWhere']) ? $additional_where = $userData['additionalWhere'] : ($additional_where = null);
     !empty($userData['allowEmpty']) ? $allow_empty = $userData['allowEmpty'] : ($allow_empty = false);
     !empty($userData['nullCaptionString']) ? $nullCaptionString = $userData['nullCaptionString'] : ($nullCaptionString = null);
     !empty($userData['onChange']) ? $onChangeString = $userData['onChange'] : ($onChangeString = "");
     $db = AbstractDb::getObject();
     $sql = "SELECT hge.element_id, hge.element_type, coalesce(n.name, ng.name, no.name) as name FROM hotspot_graph_elements hge\n                left join networks n on hge.element_id = n.network_id AND hge.element_type='Network' \n                left join node_groups ng on hge.element_id = ng.node_group_id AND hge.element_type = 'NodeGroup'\n                left join nodes no on hge.element_id = no.node_id AND hge.element_type = 'Node'\n                WHERE 1=1 {$additional_where}";
     $element_rows = null;
     $db->execSql($sql, $element_rows, false);
     $number_of_networks = count($element_rows);
     if ($number_of_networks > 1) {
         $i = 0;
         foreach ($element_rows as $element_row) {
             $tab[$i][0] = "{$element_row['element_id']},{$element_row['element_type']}";
             $tab[$i][1] = $element_row['name'] . " ({$element_row['element_type']})";
             $i++;
         }
         $html .= _("Element:") . " \n";
         $html .= FormSelectGenerator::generateFromArray($tab, $selected_id, $name, null, $allow_empty, $nullCaptionString, "onchange='{$onChangeString}'");
     } else {
         foreach ($element_rows as $element_row) {
             $html .= _("Element:") . " \n";
             $html .= " {$element_row['name']} ({$element_row['element_type']})";
             $html .= "<input type='hidden' name='{$name}' value='" . htmlspecialchars($element_row['element_id'], ENT_QUOTES, 'UTF-8') . "'>";
         }
     }
     return $html;
 }
コード例 #6
0
 /**
  * Get a flexible interface to generate new ProfileTemplateField
  *
  * @param string $user_prefix      A identifier provided by the programmer
  *                                 to recognise it's generated HTML form
  * @return string HTML markup
  */
 public static function getCreateFieldUI($user_prefix, $title = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $html .= "<fieldset class='admin_container Content'>\n";
     if (!empty($title)) {
         $html .= "<legend>{$title}</legend>\n";
     }
     $availableContentTypeFilters = ContentTypeFilter::getAllContentTypeFilters();
     $name = "get_new_profile_template_field_{$user_prefix}_content_type_filter";
     $i = 0;
     $tab = array();
     foreach ($availableContentTypeFilters as $filter) {
         $tab[$i][0] = $filter->getId();
         $tab[$i][1] = $filter->getLabel() == null ? "[" . _("No label") . "] - " . $filter->getId() : $filter->getLabel();
         $i++;
     }
     if (count($tab) > 1) {
         $label = _("Add new profile template field filtered by") . ": ";
         $html .= "<div class='admin_element_data content_add'>";
         $html .= $label;
         $html .= FormSelectGenerator::generateFromArray($tab, null, $name, null, false);
         $html .= "</div>";
     } else {
         if (count($tab) == 1) {
             $html .= '<input type="hidden" name="' . $name . '" value="' . $tab[0][0] . '">';
         } else {
             $html .= "<div class='errormsg'>" . _("Sorry, no content type filter exists.") . "</div>\n";
         }
     }
     $name = "get_new_profile_template_field_{$user_prefix}_add";
     if (count($tab) >= 1) {
         $value = _("Add");
         $html .= "<div class='admin_element_tools'>";
         $html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
         $html .= "</div>";
     }
     $html .= "</fieldset>\n";
     return $html;
 }
コード例 #7
0
ファイル: Role.php プロジェクト: cnlangzi/wifidog-auth
 /**
  * Get an interface to pick an object of this class
  *
  * If there is only one server available, no interface is actually shown
  *
  * @param string $user_prefix         A identifier provided by the
  *                                    programmer to recognise it's generated
  *                                    html form
  *  @param string $userData=null Array of contextual data optionally sent to the method.
  *  The function must still function if none of it is present.
  *
  * This method understands:
  *  $userData['preSelectedId'] An optional ProfileTemplate object id.
  *	$userData['stakeholderTypeId'] Limit to roles applicable to this stakeholder type
  * @return string HTML markup
  */
 public static function getSelectUI($user_prefix, $userData = null)
 {
     $html = '';
     $db = AbstractDb::getObject();
     $html .= "<div class='role_select_role_ui_container'>\n";
     $name = $user_prefix;
     !empty($userData['preSelectedId']) ? $selected_id = $userData['preSelectedId'] : ($selected_id = null);
     !empty($userData['stakeholderTypeId']) ? $targetObjectClassSql = " AND stakeholder_type_id = '" . $db->escapeString($userData['stakeholderTypeId']) . "' " : ($targetObjectClassSql = null);
     $sql = "SELECT role_id, role_description_content_id, stakeholder_type_id FROM roles WHERE 1=1 {$targetObjectClassSql} ORDER BY stakeholder_type_id, role_id";
     $role_rows = null;
     $db->execSql($sql, $role_rows, false);
     if ($role_rows == null) {
         $html .= sprintf(_("Sorry: No available roles in the database for stakeholder type: %s!"), $userData['stakeholderTypeId']);
     } else {
         if (count($role_rows) > 1) {
             $i = 0;
             foreach ($role_rows as $role_row) {
                 $role = self::getObject($role_row['role_id']);
                 $tab[$i][0] = $role_row['role_id'];
                 empty($userData['stakeholderTypeId']) ? $tab[$i][1] = $role_row['stakeholder_type_id'] . '; ' : ($tab[$i][1] = null);
                 $tab[$i][1] .= $role->getLabelStr();
                 $i++;
             }
             $html .= _("Role:") . " \n";
             $html .= FormSelectGenerator::generateFromArray($tab, $selected_id, $name, null, false);
         } else {
             foreach ($role_rows as $role_row) {
                 $html .= _("Role:") . " \n";
                 $html .= " {$role_row['role_id']} ";
                 $html .= "<input type='hidden' name='{$name}' value='" . htmlspecialchars($role_row['role_id'], ENT_QUOTES, 'UTF-8') . "'>";
             }
         }
     }
     $html .= "</div'>\n";
     return $html;
 }
コード例 #8
0
 /**
  * Get an interface to pick a ContentTypeFilter
  *
  * @param string $user_prefix         A identifier provided by the
  *                                    programmer to recognise it's generated
  *                                    html form
  *  @param string $userData=null Array of contextual data optionally sent to the method.
  *  The function must still function if none of it is present.
  *
  * This method understands:
  *  $userData['preSelectedObject'] An optional ProfileTemplate object id.
  *
  * @return string HTML markup
  */
 public static function getSelectUI($user_prefix, $userData = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $_content_type_filter_rows = null;
     !empty($userData['preSelectedObject']) ? $selectedId = $userData['preSelectedObject']->getId() : ($selectedId = null);
     $sql = "SELECT * FROM stakeholder_types ORDER BY stakeholder_type_id ASC";
     $db->execSql($sql, $rows, false);
     $name = $user_prefix;
     $i = 0;
     foreach ($rows as $row) {
         $tab[$i][0] = $row['stakeholder_type_id'];
         $tab[$i][1] = $row['stakeholder_type_id'];
         $i++;
     }
     $html .= FormSelectGenerator::generateFromArray($tab, $selectedId, $name, null, false);
     return $html;
 }
コード例 #9
0
 /**
  * Get an interface to pick an object of this class
  *
  * If there is only one server available, no interface is actually shown
  *
  * @param string $user_prefix         A identifier provided by the
  *                                    programmer to recognise it's generated
  *                                    html form
  *  @param string $userData=null Array of contextual data optionally sent to the method.
  *  The function must still function if none of it is present.
  *
  * This method understands:
  *  $userData['preSelectedId'] An optional ProfileTemplate object id.
  *	$userData['additionalWhere'] Additional SQL conditions for the
  *                                    objects to select
  *	$userData['typeInterface'] 'select' or 'add'.  'select' is the default
  * @return string HTML markup
  */
 public static function getSelectUI($user_prefix, $userData = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $_html = "";
     $_profile_template_rows = null;
     !empty($userData['preSelectedId']) ? $selectedId = $userData['preSelectedId'] : ($selectedId = null);
     !empty($userData['additionalWhere']) ? $additional_where = $userData['additionalWhere'] : ($additional_where = null);
     !empty($userData['typeInterface']) ? $type_interface = $userData['typeInterface'] : ($type_interface = null);
     $sql = "SELECT * FROM profile_templates WHERE 1=1 {$additional_where} ORDER BY profile_template_label ASC";
     $db->execSql($sql, $_profile_template_rows, false);
     if ($_profile_template_rows != null) {
         $_name = $user_prefix;
         $_html .= _("Profile template") . ": \n";
         $_i = 0;
         foreach ($_profile_template_rows as $_profile_template_row) {
             $_tab[$_i][0] = $_profile_template_row['profile_template_id'];
             $_tab[$_i][1] = empty($_profile_template_row['profile_template_label']) ? "[" . _("No label") . "] - " . $_profile_template_row['profile_template_id'] : $_profile_template_row['profile_template_label'];
             $_i++;
         }
         $_html .= FormSelectGenerator::generateFromArray($_tab, $selectedId, $_name, null, false);
         if ($type_interface == "add") {
             if (isset($_tab)) {
                 $name = "{$user_prefix}_add";
                 $value = _("Add");
                 $_html .= "<div class='admin_element_tools'>";
                 $_html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
                 $_html .= "</div>";
             }
         }
     }
     return $_html;
 }
コード例 #10
0
ファイル: ThemePack.php プロジェクト: cnlangzi/wifidog-auth
 /**
  * Get an interface to pick a theme pack
  *
  * If there is only one network available, no interface is actually shown
  *
  * @param string $userPrefix           An identifier provided by the
  *                                     programmer to recognise it's
  *                                     generated html form
  * @param object $preSelectedThemePack Theme object: The theme to be pre-
  *                                     selected in the form object
  *
  * @return string HTML markup
  */
 public static function getSelectUI($userPrefix, $preSelectedThemePack = null)
 {
     $html = '';
     $name = $userPrefix;
     $html .= _("Theme pack:") . " \n";
     if ($preSelectedThemePack) {
         $selected_id = $preSelectedThemePack->getId();
     } else {
         $selected_id = null;
     }
     if ($handle = @opendir(WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR)) {
         $tab = array();
         $i = 0;
         while (false !== ($directory = readdir($handle))) {
             if ($directory != '.' && $directory != '..' && $directory != '.svn' && is_dir(WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR . $directory . '/')) {
                 $theme_pack = self::getObject($directory);
                 $tab[$i][0] = $theme_pack->getId();
                 $tab[$i][1] = $theme_pack->getName();
                 $tab[$i][2] = $theme_pack->getDescription();
                 $i++;
             }
         }
         closedir($handle);
     } else {
         throw new exception(_("Unable to open the network theme packs directory"));
     }
     //pretty_print_r($tab);
     if (count($tab) > 0) {
         $html .= FormSelectGenerator::generateFromArray($tab, $selected_id, $name, null, true);
     } else {
         $html .= sprintf(_("No network theme packs available in %s"), WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR);
         $html .= "<input type='hidden' name='{$name}' value=''>";
     }
     return $html;
 }
コード例 #11
0
 public function getAdminUI($subclass_admin_interface = null, $title = null)
 {
     // Init values
     $html = '';
     $html .= "<fieldset class='admin_element_group'>\n";
     $html .= "<legend>" . sprintf(_("%s: Options"), get_class($this)) . "</legend>\n";
     $html .= "<ul class='admin_element_list'>\n";
     if ($this->_PhlickrAvailable) {
         $generator = new FormSelectGenerator();
         $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n";
         $html .= "<div class='admin_element_label'>" . _("Flickr API key") . " <a href='http://www.flickr.com/services/api/misc.api_keys.html'>(?)</a> : </div>\n";
         $html .= "<div class='admin_element_data'>\n";
         $name = "flickr_photostream_" . $this->id . "_api_key";
         $html .= "<input type='text' name='{$name}' size=40 value='" . $this->getApiKey() . "'\n";
         $html .= "</div>\n";
         $html .= "</li>\n";
         $html .= "<li class='admin_element_item_container'>\n";
         $html .= "<div class='admin_element_label'>" . _("Shared secret") . " : </div>\n";
         $html .= "<div class='admin_element_data'>\n";
         $name = "flickr_photostream_" . $this->id . "_api_shared_secret";
         $html .= "<input type='text' name='{$name}' value='" . $this->getApiSharedSecret() . "'\n";
         $html .= "</div>\n";
         $html .= "</li>\n";
         $html .= "<li class='admin_element_item_container'>\n";
         $html .= "<div class='admin_element_label'>" . _("Photos display mode") . " : </div>\n";
         $html .= "<div class='admin_element_data'>\n";
         $display_modes = array(array(0 => self::DISPLAY_GRID, 1 => _("Grid display")), array(0 => self::DISPLAY_FEATURE, 1 => _("Feature photo (last one)")), array(0 => self::DISPLAY_FEATURE_WITH_RANDOM, 1 => _("Feature photo + one at random")));
         $html .= $generator->generateFromArray($display_modes, $this->getDisplayMode(), "DisplayMode" . $this->getID(), "FlickrPhotostream", false, null);
         $html .= "</div>\n";
         $html .= "</li>\n";
         $html .= "<li class='admin_element_item_container'>\n";
         $html .= "<div class='admin_element_label'>" . _("Flick photo selection mode :") . "</div>\n";
         $html .= "<div class='admin_element_data'>\n";
         $selection_modes = array(array(0 => self::SELECT_BY_GROUP, 1 => _("Select by group")), array(0 => self::SELECT_BY_TAGS, 1 => _("Select by tags")), array(0 => self::SELECT_BY_USER, 1 => _("Select by user")));
         $html .= $generator->generateFromArray($selection_modes, $this->getSelectionMode(), "SelectionMode" . $this->getID(), "FlickrPhotostream", false, null, "onChange='submit()'");
         // Check for existing API key
         if ($this->getAPIKey()) {
             try {
                 switch ($this->getSelectionMode()) {
                     // Process common data ( User ID + User name )
                     case self::SELECT_BY_GROUP:
                     case self::SELECT_BY_USER:
                         if ($this->getFlickrUserId()) {
                             $html .= "<li class='admin_element_item_container'>\n";
                             $html .= "<div class='admin_element_label'>" . _("Flickr User ID + Username") . " : </div>\n";
                             $html .= "<div class='admin_element_data'>\n";
                             $html .= $this->getUserName() . " [" . $this->getFlickrUserId() . "]";
                             $name = "flickr_photostream_" . $this->id . "_reset_user_id";
                             $html .= " <b>( <input type='checkbox' name='{$name}' value='true'>" . _("Reset Flickr User ID") . " )</b>";
                             $html .= "</div>\n";
                             $html .= "</li>\n";
                         } else {
                             $html .= "<li class='admin_element_item_container'>\n";
                             $html .= "<div class='admin_element_label'>" . _("Flickr User E-mail") . " : </div>\n";
                             $html .= "<div class='admin_element_data'>\n";
                             $name = "flickr_photostream_" . $this->id . "_email";
                             $html .= "<input type='text' name='{$name}' value=''>";
                             $html .= "</div>\n";
                             $html .= "</li>\n";
                         }
                         break;
                 }
                 switch ($this->getSelectionMode()) {
                     case self::SELECT_BY_GROUP:
                         if ($this->getFlickrUserId()) {
                             $html .= "<li class='admin_element_item_container'>\n";
                             $html .= "<div class='admin_element_label'>" . _("Group Photo Pool") . " : </div>\n";
                             $html .= "<div class='admin_element_data'>\n";
                             $group_photo_pools = array();
                             $flickr_user = new Phlickr_User($this->getFlickrApi(), $this->getFlickrUserId());
                             $groups = array();
                             $group_photo_pools = $flickr_user->getGroupList()->getGroups();
                             foreach ($group_photo_pools as $group_photo_pool) {
                                 $groups[] = array(0 => $group_photo_pool->getId(), 1 => $group_photo_pool->getName());
                             }
                             if (count($groups) > 0) {
                                 $html .= $generator->generateFromArray($groups, $this->getGroupId(), "GroupPhotoPool" . $this->getID(), "FlickrPhotostream", false, null, "onChange='submit()'");
                             } else {
                                 $html .= _("Could not find any group photo pool.");
                             }
                             $html .= "</div>\n";
                             $html .= "</li>\n";
                         }
                         break;
                     case self::SELECT_BY_TAGS:
                         $html .= "<li class='admin_element_item_container'>\n";
                         $html .= "<div class='admin_element_label'>" . _("Tags (comma-separated)") . " : </div>\n";
                         $html .= "<div class='admin_element_data'>\n";
                         $name = "flickr_photostream_" . $this->id . "_tags";
                         $html .= "<input type='text' name='{$name}' value='" . $this->getTags() . "'>";
                         $tag_modes = array(array(0 => self::TAG_MODE_ANY, 1 => _("Match any tag")), array(0 => self::TAG_MODE_ALL, 1 => _("Match all tags")));
                         $html .= $generator->generateFromArray($tag_modes, $this->getTagMode(), "TagMode" . $this->getID(), "FlickrPhotostream", false, null, "onChange='submit()'");
                         $html .= "</div>\n";
                         $html .= "</li>\n";
                         break;
                 }
                 $html .= "<li class='admin_element_item_container'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Flickr photo display options") . " : </div>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $html .= "<li class='admin_element_item_container'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Show Flickr photo title ?") . " : </div>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $name = "flickr_photostream_" . $this->id . "_display_title";
                 $this->shouldDisplayTitle() ? $checked = 'CHECKED' : ($checked = '');
                 $html .= "<input type='checkbox' name='{$name}' {$checked}>\n";
                 $html .= "</div>\n";
                 $html .= "</li>\n";
                 $html .= "<li class='admin_element_item_container'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Show Flickr tags ?") . " : </div>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $name = "flickr_photostream_" . $this->id . "_display_tags";
                 $this->shouldDisplayTags() ? $checked = 'CHECKED' : ($checked = '');
                 $html .= "<input type='checkbox' name='{$name}' {$checked}>\n";
                 $html .= "</div>\n";
                 $html .= "</li>\n";
                 $html .= "<li class='admin_element_item_container'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Show Flickr photo description ?") . " : </div>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $name = "flickr_photostream_" . $this->id . "_display_description";
                 $this->shouldDisplayDescription() ? $checked = 'CHECKED' : ($checked = '');
                 $html .= "<input type='checkbox' name='{$name}' {$checked}>\n";
                 $html .= "</div>\n";
                 $html .= "</li>\n";
                 $html .= "<li class='admin_element_item_container'>\n";
                 $html .= "<div class='admin_element_label'>" . _("Preferred size") . " : </div>\n";
                 $html .= "<div class='admin_element_data'>\n";
                 $preferred_sizes = array(array(0 => self::SIZE_SQUARED_75x75, 1 => _("Squared 75x75")), array(0 => self::SIZE_THUMB_100x75, 1 => _("Thumbnail 100x75")), array(0 => self::SIZE_SMALL_240x180, 1 => _("Small 240x180")), array(0 => self::SIZE_MEDIUM_500x375, 1 => _("Medium 500x375")), array(0 => self::SIZE_LARGE_1024, 1 => _("Large 1024x*")), array(0 => self::SIZE_ORIGINAL, 1 => _("Original size")));
                 $html .= $generator->generateFromArray($preferred_sizes, $this->getPreferredSize(), "PreferredSize" . $this->getID(), "FlickrPhotostream", false, null, "onChange='submit()'");
                 $html .= "</div>\n";
                 $html .= "</li>\n";
                 //TODO: Add photo batch size UI support here
                 $html .= "</li>\n";
                 $html .= "</li>\n";
             } catch (Phlickr_ConnectionException $e) {
                 $html .= sprintf(_("Unable to connect to Flickr API: %s"), "<pre>{$e}</pre>");
             } catch (Phlickr_MethodFailureException $e) {
                 $html .= _("Some of the request parameters provided to Flickr API are invalid.");
             } catch (Phlickr_XmlParseException $e) {
                 $html .= _("Unable to parse Flickr's response.");
             } catch (Phlickr_Exception $e) {
                 $html .= _("Could not get content from Flickr : ") . $e;
             }
         } else {
             $html .= "<li class='admin_element_item_container'>\n";
             $html .= "<div class='admin_element_label'>" . _("YOU MUST SPECIFY AN API KEY BEFORE YOU CAN GO ON.") . "</div>\n";
             $html .= "</li>\n";
         }
         $html .= $subclass_admin_interface;
     } else {
         $html .= _("PEAR::Phlickr or PHP mudule CURL is not installed");
     }
     $html .= "</fieldset>\n";
     return parent::getAdminUI($html, $title);
 }
コード例 #12
0
ファイル: Node.php プロジェクト: cnlangzi/wifidog-auth
 /**
  * Get an interface to select the deployment status
  *
  * @param string $user_prefix A identifier provided by the programmer to
  *                            recognise it's generated html form
  *
  * @return string HTML markup
  */
 public function getSelectDeploymentStatus($user_prefix)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $status_list = null;
     $tab = array();
     $name = "{$user_prefix}";
     $db->execSql("SELECT node_deployment_status FROM node_deployment_status", $status_list, false);
     if ($status_list == null) {
         throw new Exception(_("No deployment statuses could be found in the database"));
     }
     foreach ($status_list as $status) {
         $_statusvalue = $status['node_deployment_status'];
         $tab[] = array($_statusvalue, $this->_deploymentStatuses["{$_statusvalue}"]);
     }
     $html .= FormSelectGenerator::generateFromArray($tab, $this->getDeploymentStatus(), $name, null, false);
     return $html;
 }
コード例 #13
0
 /**
  * Get an interface to pick a ContentTypeFilter 
  *
  * @param string $user_prefix         A identifier provided by the
  *                                    programmer to recognise it's generated
  *                                    html form
  *  @param string $userData=null Array of contextual data optionally sent to the method.
  *  The function must still function if none of it is present.
  *
  * This method understands:
  *  $userData['preSelectedId'] An optional ProfileTemplate object id.
  *	$userData['additionalWhere'] Additional SQL conditions for the
  *                                    objects to select
  *
  * @return string HTML markup
  */
 public static function getSelectUI($user_prefix, $userData = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $_content_type_filter_rows = null;
     !empty($userData['preSelectedId']) ? $selectedId = $userData['preSelectedId'] : ($selectedId = null);
     !empty($userData['additionalWhere']) ? $additional_where = $userData['additionalWhere'] : ($additional_where = null);
     $additional_where = $db->escapeString($additional_where);
     $sql = "SELECT * FROM content_type_filters WHERE 1=1 {$additional_where} ORDER BY content_type_filter_label ASC";
     $db->execSql($sql, $_content_type_filter_rows, false);
     if ($_content_type_filter_rows == null) {
         return $html;
     }
     $name = $user_prefix;
     $html .= _("Content type filter") . ": \n";
     $_numberOfContentTypeFilters = count($_content_type_filter_rows);
     if ($_numberOfContentTypeFilters > 1) {
         $_i = 0;
         foreach ($_content_type_filter_rows as $_content_type_filter_row) {
             $_tab[$_i][0] = $_content_type_filter_row['content_type_filter_id'];
             $_tab[$_i][1] = empty($_content_type_filter_row['content_type_filter_label']) ? "[" . _("No label") . "] - " . $_content_type_filter_row['content_type_filter_id'] : $_content_type_filter_row['content_type_filter_label'];
             $_i++;
         }
         $html .= FormSelectGenerator::generateFromArray($_tab, $selectedId, $name, null, false);
     } else {
         foreach ($_content_type_filter_rows as $_content_type_filter_row) {
             $html .= " {$_content_type_filter_row['content_type_filter_label']} ";
             $html .= "<input type='hidden' name='{$name}' value='{$_content_type_filter_row['content_type_filter_id']}'>";
         }
     }
     return $html;
 }
コード例 #14
0
ファイル: NodeGroup.php プロジェクト: cnlangzi/wifidog-auth
 /** Get an interface to pick a node group.
  * @param $user_prefix A identifier provided by the programmer to recognise it's generated html form
  *
  * @param string $userData=null Array of contextual data optionally sent to the method.
  *  The function must still function if none of it is present.
  * This method understands:
  *  $userData['preSelectedObject'] An optional object to pre-select.
  *	$userData['additionalWhere'] Additional SQL conditions for the
  *                                    objects to select
  *  $userData['additionalJoin'] Additional SQL JOIN conditions for the
  *                                    objects to select
  *	$userData['preSelectedObjects'] An optional object or array of objects to pre-select. (not
  * supported by type_interface=table)
  *  $userData['typeInterface'] select, select_multiple or table.  Default is "select"
  *
  * * @return html markup
  */
 public static function getSelectUI($user_prefix, $userData = null)
 {
     $userData = $userData === null ? array() : $userData;
     $html = '';
     $name = $user_prefix;
     //pretty_print_r($userData);
     !empty($userData['additionalWhere']) ? $additional_where = $userData['additionalWhere'] : ($additional_where = null);
     !empty($userData['allowEmpty']) ? $allow_empty = $userData['allowEmpty'] : ($allow_empty = false);
     !empty($userData['nullCaptionString']) ? $nullCaptionString = $userData['nullCaptionString'] : ($nullCaptionString = null);
     !empty($userData['onChange']) ? $onChangeString = $userData['onChange'] : ($onChangeString = "");
     !empty($userData['onlyNetwoksAllowingSignup']) ? $onlyNetwoksAllowingSignup = $userData['onlyNetwoksAllowingSignup'] : ($onlyNetwoksAllowingSignup = false);
     $db = AbstractDb::getObject();
     $sql = "SELECT node_group_id, name FROM node_groups WHERE 1=1 {$additional_where}";
     $ng_rows = array();
     $db->execSql($sql, $ng_rows, false);
     if ($ng_rows == null) {
         $ng_rows = array();
     }
     $number_of_nodegroups = count($ng_rows);
     $i = 0;
     $tab = array();
     foreach ($ng_rows as $ng_row) {
         $tab[$i][0] = $ng_row['node_group_id'];
         $tab[$i][1] = $ng_row['name'];
         $i++;
     }
     $html .= _("Node Group:") . " \n";
     $html .= FormSelectGenerator::generateFromArray($tab, null, $name, null, $allow_empty, $nullCaptionString, "onchange='{$onChangeString}'");
     return $html;
 }
コード例 #15
0
ファイル: VirtualHost.php プロジェクト: cnlangzi/wifidog-auth
 /**
  * Get an interface to pick a server
  *
  * If there is only one server available, no interface is actually shown
  *
  * @param string $user_prefix         A identifier provided by the
  *                                    programmer to recognise it's generated
  *                                    html form
  * @param object $pre_selected_server An optional server object. The server
  *                                    to be pre-selected in the form object
  * @param string $additional_where    Additional SQL conditions for the
  *                                    servers to select
  *
  * @return string HTML markup
  */
 public static function getSelectUI($user_prefix, $pre_selected_server = null, $additional_where = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $_serverRows = null;
     $name = $user_prefix;
     $html .= _("Virtual host:") . " \n";
     if ($pre_selected_server) {
         $selectedId = $pre_selected_server->getId();
     } else {
         $selectedId = null;
     }
     $additional_where = $db->escapeString($additional_where);
     $sql = "SELECT virtual_host_id, hostname FROM virtual_hosts WHERE 1=1 {$additional_where} ORDER BY hostname";
     $db->execSql($sql, $_serverRows, false);
     if ($_serverRows == null) {
         throw new Exception("Server::getSelectServerUI: Fatal error: No virtual hosts in the database!");
     }
     $_numberOfServers = count($_serverRows);
     if ($_numberOfServers > 1) {
         $_i = 0;
         foreach ($_serverRows as $_serverRow) {
             $_tab[$_i][0] = $_serverRow['virtual_host_id'];
             $_tab[$_i][1] = $_serverRow['hostname'];
             $_i++;
         }
         $html .= FormSelectGenerator::generateFromArray($_tab, $selectedId, $name, null, false);
     } else {
         foreach ($_serverRows as $_serverRow) {
             $html .= " {$_serverRow['hostname']} ";
             $html .= "<input type='hidden' name='{$name}' value='{$_serverRow['virtual_host_id']}'>";
         }
     }
     return $html;
 }