예제 #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
 /**
  * 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);
 }
예제 #3
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;
 }
 /**
  * This method will create a ProfileTemplateField based on the content type filter specified
  *
  * @param string $user_prefix                A identifier provided by the programmer to
  *                                           recognise it's generated form
  * @param string $profile_template              Must be present
  *
  * @return object The ProfileTemplateField object, or null if the user didn't create one
  * @static
  */
 public static function processCreateFieldUI($user_prefix, ProfileTemplate $profile_template)
 {
     $db = AbstractDb::getObject();
     // Init values
     $profile_template_field_object = null;
     $max_display_order_row = null;
     $name = "get_new_profile_template_field_{$user_prefix}_add";
     if (!empty($_REQUEST[$name])) {
         /* Get the display order to add the ProfileTemplateField at the end */
         $sql = "SELECT MAX(display_order) as max_display_order FROM profile_template_fields WHERE profile_template_id = '" . $profile_template->getId() . "'";
         $db->execSqlUniqueRes($sql, $max_display_order_row, false);
         $display_order = $max_display_order_row['max_display_order'] + 1;
         $profile_template_field_id = get_guid();
         $sql = "INSERT INTO profile_template_fields (profile_template_field_id, profile_template_id, display_order) VALUES ('{$profile_template_field_id}', '{$profile_template->getId()}', {$display_order});";
         if (!$db->execSqlUpdate($sql, false)) {
             throw new Exception(_('Unable to insert new content into database!'));
         }
         $profile_template_field_object = self::getObject($profile_template_field_id);
         $name = "get_new_profile_template_field_{$user_prefix}_content_type_filter";
         $content_type_filter_ui_result = FormSelectGenerator::getResult($name, null);
         if (empty($content_type_filter_ui_result)) {
             throw new exception("Unable to retrieve the content type filter to associate with the new field");
         }
         $content_type_filter = ContentTypeFilter::getObject($content_type_filter_ui_result);
         $profile_template_field_object->replaceContentTypeFilter($content_type_filter);
     }
     return $profile_template_field_object;
 }
예제 #5
0
 /** 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;
 }
예제 #6
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;
 }
예제 #7
0
 function processAdminUI()
 {
     // Init values
     $errmsg = null;
     if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         parent::processAdminUI();
         /* content_ordering_mode */
         $name = "content_group_" . $this->id . "_content_ordering_mode";
         $this->setContentOrderingMode(FormSelectGenerator::getResult($name, null));
         /*content_changes_on_mode */
         $name = "content_group_" . $this->id . "_content_changes_on_mode";
         $this->setContentChangesOnMode(FormSelectGenerator::getResult($name, null));
         /* allow_repeat*/
         $name = "content_group_" . $this->id . "_allow_repeat";
         $this->setAllowRepeat(FormSelectGenerator::getResult($name, null));
         /*display_num_elements*/
         $name = "content_group_" . $this->id . "_display_num_elements";
         $this->setDisplayNumElements($_REQUEST[$name]);
         /* content_group_element */
         $name = "content_group_" . $this->id . "_expired_elements_shown";
         if (empty($_REQUEST[$name])) {
             $additionalWhere = "AND (valid_until_timestamp IS NULL OR valid_until_timestamp >= CURRENT_TIMESTAMP) \n";
         } else {
             $additionalWhere = null;
         }
         foreach ($this->getElements($additionalWhere) as $element) {
             $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase";
             if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
                 $element->delete($errmsg);
             } else {
                 $element->processAdminUI();
             }
         }
         // The two following calls will either add a new element or add an existing one ( depending on what button the user clicked
         /* We explicitely call the ContentGroupElement version of processNewContentUI */
         ContentGroupElement::processNewContentUI("content_group_{$this->id}_new_element", $this);
         // Last parameters allows for existing content ( if any was selected )
         ContentGroupElement::processNewContentUI("content_group_{$this->id}_existing_element", $this, true);
     }
 }
예제 #8
0
 /**
  * Processes the input of the administration interface for Langstring
  *
  * @return void
  */
 public function processAdminUI()
 {
     // Init values.
     $result = null;
     if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         parent::processAdminUI();
         $generateur_form_select = new FormSelectGenerator();
         $sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '{$this->id}'";
         $this->mBd->execSql($sql, $result, false);
         if ($result != null) {
             while (list($key, $value) = each($result)) {
                 $language = $generateur_form_select->getResult("langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_language", null);
                 if (empty($language)) {
                     $language = '';
                     $languageSQL = 'NULL';
                 } else {
                     $languageSQL = "'" . $language . "'";
                 }
                 if (!empty($_REQUEST["langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_erase"]) && $_REQUEST["langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_erase"] == true) {
                     $this->mBd->execSqlUpdate("DELETE FROM content_langstring_entries WHERE langstrings_id = '{$this->id}' AND langstring_entries_id='{$value['langstring_entries_id']}'", FALSE);
                     // Create new cache object.
                     $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $language . '_string', $this->id);
                     // Check if caching has been enabled.
                     if ($_cache->isCachingEnabled) {
                         // Remove old cached data.
                         $_cache->eraseCachedData();
                     }
                 } else {
                     // Strip HTML tags !
                     $string = $_REQUEST["langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_string"];
                     $string = $this->mBd->escapeString(strip_tags($string, $this->allowed_html_tags));
                     // If PEAR::HTML_Safe is available strips down all potentially dangerous content
                     $_HtmlSafe = new HtmlSafe();
                     if ($_HtmlSafe->isHtmlSafeEnabled) {
                         // Add "embed" and "object" to the default set of dangerous tags
                         $_HtmlSafe->setDeleteTags(array("embed", "object"), true);
                         // Strip HTML
                         $string = $_HtmlSafe->parseHtml($string);
                     }
                     if ($value['value'] != $string || $language != $value['locales_id']) {
                         $this->mBd->execSqlUpdate("UPDATE content_langstring_entries SET locales_id = {$languageSQL} , value = '{$string}' WHERE langstrings_id = '{$this->id}' AND langstring_entries_id='{$value['langstring_entries_id']}'", FALSE);
                         $this->touch();
                         // Create new cache object.
                         $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $language . '_string', $this->id);
                         // Check if caching has been enabled.
                         if ($_cache->isCachingEnabled) {
                             // Remove old cached data.
                             $_cache->eraseCachedData();
                             // Save data into cache.
                             $_cache->saveCachedData($string);
                         }
                     }
                 }
             }
         }
         //Nouvelles chaîne(s)
         self::processNewUI($this->id, false);
     }
 }
예제 #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
 /**
  * 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
 function processAdminUI()
 {
     if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         parent::processAdminUI();
         $generator = new FormSelectGenerator();
         $name = "flickr_photostream_" . $this->id . "_api_key";
         !empty($_REQUEST[$name]) ? $this->setApiKey($_REQUEST[$name]) : $this->setApiKey(null);
         $name = "flickr_photostream_" . $this->id . "_api_shared_secret";
         !empty($_REQUEST[$name]) ? $this->setApiSharedSecret($_REQUEST[$name]) : $this->setApiSharedSecret(null);
         $name = "flickr_photostream_" . $this->id . "_photo_batch_size";
         !empty($_REQUEST[$name]) ? $this->setPhotoBatchSize($_REQUEST[$name]) : $this->setPhotoBatchSize(null);
         if ($generator->isPresent("DisplayMode" . $this->getID(), "FlickrPhotostream")) {
             $this->setDisplayMode($generator->getResult("DisplayMode" . $this->getID(), "FlickrPhotostream"));
         }
         if ($generator->isPresent("SelectionMode" . $this->getID(), "FlickrPhotostream")) {
             $this->setSelectionMode($generator->getResult("SelectionMode" . $this->getID(), "FlickrPhotostream"));
         }
         // Check for existing API key
         if ($this->getAPIKey() && $this->getSelectionMode()) {
             try {
                 switch ($this->getSelectionMode()) {
                     // Process common data for groups and users
                     case self::SELECT_BY_GROUP:
                         if ($generator->isPresent("GroupPhotoPool" . $this->getID(), "FlickrPhotostream")) {
                             $this->setGroupId($generator->getResult("GroupPhotoPool" . $this->getID(), "FlickrPhotostream"));
                         }
                     case self::SELECT_BY_USER:
                         $name = "flickr_photostream_" . $this->id . "_reset_user_id";
                         if (!empty($_REQUEST[$name]) || !$this->getFlickrUserId()) {
                             $this->setUserId(null);
                             $name = "flickr_photostream_" . $this->id . "_email";
                             if (!empty($_REQUEST[$name]) && ($flickr_user = $this->getUserByEmail($_REQUEST[$name])) != null) {
                                 $this->setUserId($flickr_user->getId());
                                 $this->setUserName($flickr_user->getName());
                             } else {
                                 echo _("Could not find a Flickr user with this e-mail.");
                             }
                         }
                         break;
                     case self::SELECT_BY_TAGS:
                         $name = "flickr_photostream_" . $this->id . "_tags";
                         if (!empty($_REQUEST[$name])) {
                             $this->setTags($_REQUEST[$name]);
                         } else {
                             $this->setTags(null);
                         }
                         if ($generator->isPresent("TagMode" . $this->getID(), "FlickrPhotostream")) {
                             $this->setTagMode($generator->getResult("TagMode" . $this->getID(), "FlickrPhotostream"));
                         }
                         break;
                 }
             } catch (Exception $e) {
                 echo _("Could not complete successfully the saving procedure.");
             }
             $name = "flickr_photostream_" . $this->id . "_display_title";
             !empty($_REQUEST[$name]) ? $this->setDisplayTitle(true) : $this->setDisplayTitle(false);
             $name = "flickr_photostream_" . $this->id . "_display_tags";
             !empty($_REQUEST[$name]) ? $this->setDisplayTags(true) : $this->setDisplayTags(false);
             $name = "flickr_photostream_" . $this->id . "_display_description";
             !empty($_REQUEST[$name]) ? $this->setDisplayDescription(true) : $this->setDisplayDescription(false);
             if ($generator->isPresent("PreferredSize" . $this->getID(), "FlickrPhotostream")) {
                 $this->setPreferredSize($generator->getResult("PreferredSize" . $this->getID(), "FlickrPhotostream"));
             }
         }
     }
 }
예제 #12
0
 /**
  * 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
 /**
  * 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;
 }
예제 #15
0
 public function processAdminUI()
 {
     $db = AbstractDb::getObject();
     $currentUser = self::getCurrentUser();
     if (Security::hasPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
         /* Account status */
         $name = "user_" . $this->getId() . "_accountstatus";
         $status = FormSelectGenerator::getResult($name, null);
         $this->setAccountStatus($status);
     }
     if ($this == $currentUser || Security::requirePermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
         /* Username */
         $name = "user_" . $this->getId() . "_username";
         $this->setUsername($_REQUEST[$name]);
         /* Change password */
         $nameOldpassword = "******" . $this->getId() . "_oldpassword";
         $nameNewpassword = "******" . $this->getId() . "_newpassword";
         $nameNewpasswordAgain = "user_" . $this->getId() . "_newpassword_again";
         if ($_REQUEST[$nameNewpassword] != null) {
             if ($this == $currentUser && $this->getPasswordHash() != User::passwordHash($_REQUEST[$nameOldpassword])) {
                 throw new Exception(_("Wrong password."));
             }
             if ($_REQUEST[$nameNewpassword] != $_REQUEST[$nameNewpasswordAgain]) {
                 throw new Exception(_("Passwords do not match."));
             }
             $this->setPassword($_REQUEST[$nameNewpassword]);
         }
         // Pretend there is only one
         $profiles = $this->getAllProfiles();
         if (!empty($profiles)) {
             $current_profile = $profiles[0];
             if ($current_profile != null) {
                 $current_profile->processAdminUI();
                 $name = "user_" . $this->getId() . "_delete_profile_" . $current_profile->getId();
                 if (!empty($_REQUEST[$name])) {
                     $errmsg = null;
                     $current_profile->delete($errmsg);
                 }
             }
         } else {
             $name = "user_" . $this->getId() . "_add_profile";
             if (!empty($_REQUEST[$name])) {
                 // Get the list of profile templates for the users' network
                 $profile_templates = ProfileTemplate::getAllProfileTemplates($this->getNetwork());
                 if (!empty($profile_templates)) {
                     // Create a blank profile and link it to the user
                     $current_profile = Profile::createNewObject(null, $profile_templates[0]);
                     $this->addProfile($current_profile);
                 }
             }
         }
     }
 }
예제 #16
0
 /**
  * Processes the input of the administration interface for Picture
  *
  * @return void
  */
 public function processAdminUI()
 {
     if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         parent::processAdminUI();
         /* width and height */
         $name = "banner_add_group_{this->getId()}_widthxheight";
         $widthxheight = FormSelectGenerator::getResult($name, null);
         //pretty_print_r($widthxheight);
         $name = "banner_add_group_{this->getId()}_max_width";
         $max_width = $_REQUEST[$name];
         /*max_height*/
         $name = "banner_add_group_{this->getId()}_max_height";
         $max_height = $_REQUEST[$name];
         if (!empty($widthxheight)) {
             $widthxheightArray = explode('/', $widthxheight);
             $max_width_select = $widthxheightArray[0];
             $max_height_select = $widthxheightArray[1];
             if (($max_width_select != $max_width || $max_height_select != $max_height) && ($max_width == $this->getKVP(get_class($this) . '_max_width') && $max_height == $this->getKVP(get_class($this) . '_max_height'))) {
                 /* Width and height weren't manually changed, or were empty */
                 $max_width = $max_width_select;
                 $max_height = $max_height_select;
             }
         }
         $this->setKVP(get_class($this) . '_max_width', $max_width);
         $this->setKVP(get_class($this) . '_max_height', $max_height);
     }
 }
예제 #17
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['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;
 }
예제 #18
0
 /** Process admin interface of this object.  When an object overrides this method, they should call the parent processAdminUI at the BEGINING of processing.
  */
 public function processAdminUI()
 {
     if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         $db = AbstractDb::getObject();
         if ($this->getObjectType() == 'Content') {
             $content_type = FormSelectGenerator::getResult("content_" . $this->id . "_content_type", "Content");
             $this->setContentType($content_type);
         } else {
             //Content medatada
             if ($this->isSimpleContent() == false || $this->isPersistent()) {
                 /* title_is_displayed */
                 if (!empty($this->content_row['title'])) {
                     $name = "content_" . $this->id . "_title_is_displayed";
                     !empty($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false);
                 }
                 /* title */
                 if (empty($this->content_row['title'])) {
                     $title = self::processNewContentUI("title_{$this->id}_new");
                     if ($title != null) {
                         $title_id = $title->GetId();
                         $db->execSqlUpdate("UPDATE content SET title = '{$title_id}' WHERE content_id = '{$this->id}'", FALSE);
                     }
                 } else {
                     $title = self::getObject($this->content_row['title']);
                     $name = "content_" . $this->id . "_title_erase";
                     if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
                         $db->execSqlUpdate("UPDATE content SET title = NULL WHERE content_id = '{$this->id}'", FALSE);
                         $title->delete($errmsg);
                     } else {
                         $title->processAdminUI();
                     }
                 }
             }
             if ($this->isSimpleContent() == false) {
                 /* description */
                 if (empty($this->content_row['description'])) {
                     $description = self::processNewContentUI("description_{$this->id}_new");
                     if ($description != null) {
                         $description_id = $description->GetId();
                         $db->execSqlUpdate("UPDATE content SET description = '{$description_id}' WHERE content_id = '{$this->id}'", FALSE);
                     }
                 } else {
                     $description = self::getObject($this->content_row['description']);
                     $name = "content_" . $this->id . "_description_erase";
                     if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
                         $db->execSqlUpdate("UPDATE content SET description = NULL WHERE content_id = '{$this->id}'", FALSE);
                         $description->delete($errmsg);
                     } else {
                         $description->processAdminUI();
                     }
                 }
                 /* long description */
                 if (empty($this->content_row['long_description'])) {
                     $long_description = self::processNewContentUI("long_description_{$this->id}_new");
                     if ($long_description != null) {
                         $long_description_id = $long_description->GetId();
                         $db->execSqlUpdate("UPDATE content SET long_description = '{$long_description_id}' WHERE content_id = '{$this->id}'", FALSE);
                     }
                 } else {
                     $long_description = self::getObject($this->content_row['long_description']);
                     $name = "content_" . $this->id . "_long_description_erase";
                     if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
                         $db->execSqlUpdate("UPDATE content SET long_description = NULL WHERE content_id = '{$this->id}'", FALSE);
                         $long_description->delete($errmsg);
                     } else {
                         $long_description->processAdminUI();
                     }
                 }
                 /* project_info */
                 if (empty($this->content_row['project_info'])) {
                     $project_info = self::processNewContentUI("project_info_{$this->id}_new");
                     if ($project_info != null) {
                         $project_info_id = $project_info->GetId();
                         $db->execSqlUpdate("UPDATE content SET project_info = '{$project_info_id}' WHERE content_id = '{$this->id}'", FALSE);
                     }
                 } else {
                     $project_info = self::getObject($this->content_row['project_info']);
                     $name = "content_" . $this->id . "_project_info_erase";
                     if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
                         $db->execSqlUpdate("UPDATE content SET project_info = NULL WHERE content_id = '{$this->id}'", FALSE);
                         $project_info->delete($errmsg);
                     } else {
                         $project_info->processAdminUI();
                     }
                 }
             }
             //End content metadata
             if ($this->isSimpleContent() == false || $this->isPersistent()) {
                 /* is_persistent */
                 $name = "content_" . $this->id . "_is_persistent";
                 !empty($_REQUEST[$name]) ? $this->setIsPersistent(true) : $this->setIsPersistent(false);
                 /* content_has_owners */
                 $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) {
                         $user = User::getObject($content_owner_row['user_id']);
                         $user_id = $user->getId();
                         $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove";
                         if (!empty($_REQUEST[$name])) {
                             $this->deleteOwner($user);
                         } else {
                             $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author";
                             $content_owner_row['is_author'] == 't' ? $is_author = true : ($is_author = false);
                             !empty($_REQUEST[$name]) ? $should_be_author = true : ($should_be_author = false);
                             if ($is_author != $should_be_author) {
                                 $should_be_author ? $is_author_sql = 'TRUE' : ($is_author_sql = 'FALSE');
                                 $sql = "UPDATE content_has_owners SET is_author={$is_author_sql} WHERE content_id='{$this->id}' AND user_id='{$user_id}'";
                                 if (!$db->execSqlUpdate($sql, false)) {
                                     throw new Exception(_('Unable to set as author in the database.'));
                                 }
                             }
                         }
                     }
                 }
                 $errMsg = null;
                 $user = User::processSelectUserUI("content_{$this->id}_new_owner", $errMsg);
                 $name = "content_{$this->id}_add_owner_submit";
                 if (!empty($_REQUEST[$name]) && $user != null) {
                     $this->addOwner($user);
                 }
             }
         }
         $this->refresh();
     }
 }
예제 #19
0
 /**
  * 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;
 }