Example #1
0
function contenttoolbar_widget_display($widget)
{
    global $CFG;
    $video_url = widget_get_data("video_url", $widget->ident);
    $video_width = widget_get_data("video_width", $widget->ident);
    $video_height = widget_get_data("video_height", $widget->ident);
    $embedpattern = "/<embed[\\w\\s\"=;:.&\\?\\/-]*>\\s*<\\/embed>/";
    $urlpattern = "/(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?\"/";
    preg_match($embedpattern, $video_url, $embed);
    if (empty($embed)) {
        $body = __gettext("Invalid video param edit an check that if is a valid &lt;embed> object.");
    } else {
        preg_match($urlpattern, $video_url, $url);
        $video_url = substr($url[0], 0, -1);
        $body = run("video:text:process", "{{video:{$video_url}}}");
    }
    return array('title' => "", 'content' => $body);
}
Example #2
0
function file_widget_edit($widget)
{
    $latest_files = clean_param(widget_get_data("latest_files", $widget->ident), PARAM_INT);
    $body = "";
    $body = "<h2>" . __gettext("Files widget") . "</h2>";
    $body .= "<p>" . __gettext("This widget displays the last couple of files from this account. Simply select the number of latest files below:") . "</p>";
    $body .= "<p><input type=\"text\" name=\"widget_data[latest_files]\" value=\"" . $latest_files . "\" /></p>";
    return $body;
}
Example #3
0
function profile_widget_edit($widget)
{
    global $CFG, $profile_id, $data, $page_owner;
    static $profile;
    if ($widget->type == 'profile::profile') {
        $profile_id = $page_owner;
        require_once $CFG->dirroot . 'profile/profile.class.php';
        $profile_field = widget_get_data("profile_widget_field", $widget->ident);
        if (!isset($profile)) {
            $profile = new ElggProfile($profile_id);
        }
        $body = "<h2>" . __gettext("Profile widget") . "</h2>";
        $body .= "<p>" . __gettext("Select a profile field below; the widget will then display the profile content from this field.") . "</p>";
        $body .= "<select name=\"widget_data[profile_widget_field]\">";
        $user_type = user_info("user_type", $widget->owner);
        foreach ($data['profile:details'] as $field_row) {
            if (empty($field_row->user_type) || $field_row->user_type == $user_type) {
                if ($field_row->internal_name == $profile_field) {
                    $selected = "selected=\"selected\"";
                } else {
                    $selected = "";
                }
                $body .= "<option value=\"" . $field_row->internal_name . $selected . "\">" . $field_row->name . "</option>\n";
            }
        }
        $body .= "</select>";
    } elseif ($widget->type == 'profile::friends') {
        // can't edit this widget for now
        $body = '';
    } elseif ($widget->type == 'profile::files') {
        // can't edit this widget for now
        $body = '';
    }
    return $body;
}
Example #4
0
function newsclient_widget_edit($widget)
{
    global $CFG, $page_owner;
    $feed_id = widget_get_data("feed_id", $widget->ident);
    $feed_posts = widget_get_data("feed_posts", $widget->ident);
    if (empty($feed_posts)) {
        $feed_posts = 1;
    }
    $body = "<h2>" . __gettext("Feeds widget") . "</h2>";
    $body .= "<p>" . __gettext("This widget displays the last couple of entries from an external feed you have subscribed to. To begin, select the feed from your subscriptions below:") . "</p>";
    $feed_subscriptions = newsclient_get_subscriptions_user($page_owner, true);
    if (is_array($feed_subscriptions) && !empty($feed_subscriptions)) {
        $body .= "<p><select name=\"widget_data[feed_id]\">\n";
        foreach ($feed_subscriptions as $subscription) {
            if ($subscription->ident == $feed_id) {
                $selected = "selected=\"selected\"";
            } else {
                $selected = "";
            }
            $body .= "<option value=\"" . $subscription->ident . "\" {$selected}>" . $subscription->name . "</option>\n";
        }
        $body .= "</select></p>\n";
        $body .= "<p>" . __gettext("Then enter the number of feed entries you'd like to display:") . "</p>";
        $body .= "<p><input type=\"text\" name=\"widget_data[feed_posts]\" value=\"" . $feed_posts . "\" /></p>";
    } else {
        $body .= "<p>" . sprintf(__gettext("You can't select a feed for this widget because you don't have any feed subscriptions. Click on <a href=\"%s\">Your</a> Resources to subscribe to a feed."), $CFG->wwwroot . $_SESSION['username'] . "/feeds/") . "</p>";
    }
    return $body;
}
Example #5
0
function blog_widget_edit($widget)
{
    global $CFG, $page_owner;
    $blog_id = widget_get_data("blog_id", $widget->ident);
    $blog_posts = widget_get_data("blog_posts", $widget->ident);
    if (empty($blog_posts)) {
        $blog_posts = 1;
    }
    if (empty($blog_id)) {
        $blog_id = $page_owner;
    }
    $connections = get_records_sql("select u.ident, u.name from " . $CFG->prefix . "friends f join " . $CFG->prefix . "users u on u.ident = f.friend where f.owner = " . $_SESSION['userid'] . " order by u.name asc");
    $data = new stdClass();
    $data->ident = $page_owner;
    $data->name = run("profile:display:name", $page_owner);
    $connections[] = $data;
    if ($page_owner != $_SESSION['userid']) {
        $data = new stdClass();
        $data->ident = $_SESSION['userid'];
        $data->name = run("profile:display:name", $_SESSION['userid']);
        $connections[] = $data;
    }
    $body = "<h2>" . __gettext("Blog widget") . "</h2>";
    $body .= "<p>" . __gettext("This widget displays the last couple of blog posts from an individual user. To begin, select the user from your connections below:") . "</p>";
    $body .= "<p><select name=\"widget_data[blog_id]\">\n";
    if (is_array($connections) && !empty($connections)) {
        foreach ($connections as $connection) {
            if ($connection->ident == $blog_id) {
                $selected = "selected=\"selected\"";
            } else {
                $selected = "";
            }
            $body .= "<option value=\"" . $connection->ident . "\" {$selected}>" . $connection->name . "</option>\n";
        }
    }
    $body .= "</select></p>\n";
    $body .= "<p>" . __gettext("Then enter the number of blog posts you'd like to display:") . "</p>";
    $body .= "<p><input type=\"text\" name=\"widget_data[blog_posts]\" value=\"" . $blog_posts . "\" /></p>";
    return $body;
}
Example #6
0
function widget_text_widget_edit($widget)
{
    global $CFG, $page_owner;
    $widget_text_title = widget_get_data("widget_text_title", $widget->ident);
    $widget_text_body = widget_get_data("widget_text_body", $widget->ident);
    $body = "<h2>" . gettext("Text box") . "</h2>";
    $body .= "<p>" . gettext("This widget displays the text content of your choice. All you need to do is enter the title and body below:") . "</p>";
    $body .= "<p>" . display_input_field(array("widget_data[widget_text_title]", $widget_text_title, "text")) . "</p>";
    $body .= "<p>" . display_input_field(array("widget_data[widget_text_body]", $widget_text_body, "longtext")) . "</p>";
    return $body;
}