コード例 #1
0
 function get_content()
 {
     global $CFG, $USER;
     //note: do NOT include files at the top of this file
     require_once $CFG->dirroot . '/tag/lib.php';
     require_once $CFG->libdir . '/filelib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     $tagid = optional_param('id', 0, PARAM_INT);
     // tag id - for backware compatibility
     $tag = optional_param('tag', '', PARAM_TAG);
     // tag
     if ($tag) {
         $tagobject = tag_get('name', $tag);
     } else {
         if ($tagid) {
             $tagobject = tag_get('id', $tagid);
         }
     }
     if (empty($tagobject)) {
         $this->content = new stdClass();
         $this->content->text = '';
         $this->content->footer = '';
         return $this->content;
     }
     //include related tags in the photo query ?
     $tagscsv = $tagobject->name;
     if (!empty($this->config->includerelatedtags)) {
         $tagscsv .= ',' . tag_get_related_tags_csv(tag_get_related_tags($tagobject->id), TAG_RETURN_TEXT);
     }
     $tagscsv = urlencode($tagscsv);
     //number of photos to display
     $numberofphotos = DEFAULT_NUMBER_OF_PHOTOS;
     if (!empty($this->config->numberofphotos)) {
         $numberofphotos = $this->config->numberofphotos;
     }
     //sort search results by
     $sortby = 'relevance';
     if (!empty($this->config->sortby)) {
         $sortby = $this->config->sortby;
     }
     //pull photos from a specific photoset
     if (!empty($this->config->photoset)) {
         $request = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos';
         $request .= '&api_key=' . FLICKR_DEV_KEY;
         $request .= '&photoset_id=' . $this->config->photoset;
         $request .= '&per_page=' . $numberofphotos;
         $request .= '&format=php_serial';
         $response = $this->fetch_request($request);
         $search = unserialize($response);
         foreach ($search['photoset']['photo'] as $p) {
             $p['owner'] = $search['photoset']['owner'];
         }
         $photos = array_values($search['photoset']['photo']);
     } else {
         $request = 'http://api.flickr.com/services/rest/?method=flickr.photos.search';
         $request .= '&api_key=' . FLICKR_DEV_KEY;
         $request .= '&tags=' . $tagscsv;
         $request .= '&per_page=' . $numberofphotos;
         $request .= '&sort=' . $sortby;
         $request .= '&format=php_serial';
         $response = $this->fetch_request($request);
         $search = unserialize($response);
         $photos = array_values($search['photos']['photo']);
     }
     if (strcmp($search['stat'], 'ok') != 0) {
         return;
     }
     //if no results were returned, exit...
     //Accessibility: render the list of photos
     $text = '<ul class="inline-list">';
     foreach ($photos as $photo) {
         $text .= '<li><a href="http://www.flickr.com/photos/' . $photo['owner'] . '/' . $photo['id'] . '/" title="' . s($photo['title']) . '">';
         $text .= '<img alt="' . s($photo['title']) . '" class="flickr-photos" src="' . $this->build_photo_url($photo, 'square') . "\" /></a></li>\n";
     }
     $text .= "</ul>\n";
     $this->content = new stdClass();
     $this->content->text = $text;
     $this->content->footer = '';
     return $this->content;
 }
コード例 #2
0
/**
 * Prints a box with the description of a tag and its related tags
 *
 * @package core_tag
 * @access  public
 * @todo    MDL-31149 create a system setting for $max_tags_displayed, instead of using an in code literal
 * @param   stdClass    $tag_object
 * @param   bool        $return     if true the function will return the generated tag cloud instead of displaying it.
 * @return  string/null a HTML box showing a description of the tag object and it's relationsips or null if output is done directly
 *                      in the function.
 */
function tag_print_description_box($tag_object, $return = false)
{
    global $USER, $CFG, $OUTPUT;
    $max_tags_displayed = 10;
    $tagname = tag_display_name($tag_object);
    $related_tags = tag_get_related_tags($tag_object->id, TAG_RELATED_ALL, $max_tags_displayed + 1);
    // this gets one more than we want
    $content = !empty($tag_object->description) || $related_tags;
    $output = '';
    if ($content) {
        $output .= $OUTPUT->box_start('generalbox', 'tag-description');
    }
    if (!empty($tag_object->description)) {
        $options = new stdClass();
        $options->para = false;
        $options->overflowdiv = true;
        $tag_object->description = file_rewrite_pluginfile_urls($tag_object->description, 'pluginfile.php', get_context_instance(CONTEXT_SYSTEM)->id, 'tag', 'description', $tag_object->id);
        $output .= format_text($tag_object->description, $tag_object->descriptionformat, $options);
    }
    if ($related_tags) {
        $more_links = false;
        if (count($related_tags) > $max_tags_displayed) {
            array_pop($related_tags);
            $more_links = true;
        }
        $output .= '<br /><br /><strong>' . get_string('relatedtags', 'tag') . ': </strong>' . tag_get_related_tags_csv($related_tags);
        if ($more_links) {
            $output .= ' ...';
        }
    }
    if ($content) {
        $output .= $OUTPUT->box_end();
    }
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #3
0
/**
 * Prints a box with the description of a tag and its related tags
 *
 * @param unknown_type $tag_object
 * @param $return if true return html string
 */
function tag_print_description_box($tag_object, $return = false)
{
    global $USER, $CFG;
    $max_tags_displayed = 10;
    // todo: turn this into a system setting
    $tagname = tag_display_name($tag_object);
    $related_tags = tag_get_related_tags($tag_object->id, TAG_RELATED_ALL, $max_tags_displayed + 1);
    // this gets one more than we want
    $content = !empty($tag_object->description) || $related_tags;
    $output = '';
    if ($content) {
        $output .= print_box_start('generalbox', 'tag-description', true);
    }
    if (!empty($tag_object->description)) {
        $options = new object();
        $options->para = false;
        $output .= format_text($tag_object->description, $tag_object->descriptionformat, $options);
    }
    if ($related_tags) {
        $more_links = false;
        if (count($related_tags) > $max_tags_displayed) {
            array_pop($related_tags);
            $more_links = true;
        }
        $output .= '<br /><br /><strong>' . get_string('relatedtags', 'tag') . ': </strong>' . tag_get_related_tags_csv($related_tags);
        if ($more_links) {
            $output .= ' ...';
        }
    }
    if ($content) {
        $output .= print_box_end(true);
    }
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #4
0
ファイル: edit.php プロジェクト: EmmanuelYupit/educursos
} else {
    if ($tag_id) {
        $tag = tag_get('id', $tag_id, '*');
    }
}
if (empty($tag)) {
    redirect($CFG->wwwroot . '/tag/search.php');
}
$PAGE->set_url('/tag/index.php', array('id' => $tag->id));
$PAGE->set_subpage($tag->id);
$PAGE->set_context($systemcontext);
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
$PAGE->set_pagelayout('base');
$tagname = tag_display_name($tag);
// set the relatedtags field of the $tag object that will be passed to the form
$tag->relatedtags = tag_get_related_tags_csv(tag_get_related_tags($tag->id, TAG_RELATED_MANUAL), TAG_RETURN_TEXT);
$options = new stdClass();
$options->smiley = false;
$options->filter = false;
// convert and remove any XSS
$tag->description = format_text($tag->description, $tag->descriptionformat, $options);
$tag->descriptionformat = FORMAT_HTML;
$errorstring = '';
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'context' => $systemcontext, 'subdirs' => file_area_contains_subdirs($systemcontext, 'tag', 'description', $tag->id));
$tag = file_prepare_standard_editor($tag, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
$tagform = new tag_edit_form(null, compact('editoroptions'));
if ($tag->tagtype == 'official') {
    $tag->tagtype = '1';
} else {
    $tag->tagtype = '0';
}