Skip to content

Commit

Permalink
MDL-19690 - eliminate the $OUTPUT->initialise_deprecated_cfg_pixpath …
Browse files Browse the repository at this point in the history
…horrible hack.

Replace $CFG->pixpath with $OUPTUT->old_icon_url(...) instead.
  • Loading branch information
tjhunt committed Jul 2, 2009
1 parent f2a1963 commit c8873c4
Show file tree
Hide file tree
Showing 16 changed files with 10 additions and 45 deletions.
1 change: 0 additions & 1 deletion lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,6 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
*/
function MoodleQuickForm($formName, $method, $action, $target='', $attributes=null){
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();

static $formcounter = 1;

Expand Down
15 changes: 0 additions & 15 deletions lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1932,21 +1932,6 @@ public function container_start($classes = '', $id = '') {
public function container_end() {
return $this->opencontainers->pop('container');
}

/**
* At the moment we frequently have a problem with $CFG->pixpath not being
* initialised when it is needed. Unfortunately, there is no nice way to handle
* this. I think we need to replace $CFG->pixpath with something like $OUTPUT->icon(...).
* However, until then, we need a way to force $CFG->pixpath to be initialised,
* to fix the error messages, and that is what this function if for.
*/
public function initialise_deprecated_cfg_pixpath() {
// Actually, we don't have to do anything here. Just calling any method
// of $OBJECT is enough. However, if the only reason you are calling
// an $OUTPUT method is to get $CFG->pixpath initialised, please use this
// method, so we can find them and clean them up later once we have
// found a better replacement for $CFG->pixpath.
}
}


Expand Down
3 changes: 1 addition & 2 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4652,7 +4652,6 @@ function editorhelpbutton(){
function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false,
$imagetext='') {
global $CFG, $COURSE, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();

//warning if ever $text parameter is used
//$text option won't work properly because the text needs to be always cleaned and,
Expand Down Expand Up @@ -4694,7 +4693,7 @@ function helpbutton($page, $title, $module='moodle', $image=true, $linktext=fals
$linkobject .= $imagetext;
} else {
$linkobject .= '<img class="iconhelp" alt="'.s(strip_tags($tooltip)).'" src="'.
$CFG->pixpath .'/help.gif" />';
$OUTPUT->old_icon_url('help') . '" />';
}
} else {
$linkobject .= $tooltip;
Expand Down
2 changes: 0 additions & 2 deletions mod/chat/gui_ajax/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
// setup $PAGE so that format_text will work properly
$PAGE->set_cm($cm, $course, $chat);

$OUTPUT->initialise_deprecated_cfg_pixpath();

if($CFG->chat_use_cache){
$cache = new file_cache();
$users = $cache->get('user');
Expand Down
1 change: 0 additions & 1 deletion question/category_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public function question_category_object($page, $pageurl, $contexts, $currentcat
$this->str->cancel = get_string('cancel');
$this->str->editcategories = get_string('editcategories', 'quiz');
$this->str->page = get_string('page');
$OUTPUT->initialise_deprecated_cfg_pixpath();
$this->pixpath = $CFG->pixpath;

$this->pageurl = $pageurl;
Expand Down
3 changes: 1 addition & 2 deletions repository/alfresco/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ private function get_url($node) {

public function get_listing($uuid = '', $path = '') {
global $CFG, $SESSION, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$ret = array();
$ret['dynload'] = true;
$ret['list'] = array();
Expand Down Expand Up @@ -129,7 +128,7 @@ public function get_listing($uuid = '', $path = '') {
'children'=>array());
} elseif ($child->child->type == $file_filter) {
$ret['list'][] = array('title'=>$child->child->cm_name,
'thumbnail' => $CFG->pixpath .'/f/'. mimeinfo('icon32', $child->child->cm_name),
'thumbnail' => $OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $child->child->cm_name))),
'source'=>$child->child->id);
}
}
Expand Down
3 changes: 1 addition & 2 deletions repository/boxnet/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public function get_login() {
*/
public function search($search_text) {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$list = array();
$ret = array();
$tree = $this->box->getAccountTree();
Expand All @@ -155,7 +154,7 @@ public function search($search_text) {
'date'=>$filedates[$n],
'source'=>'http://box.net/api/1.0/download/'
.$this->auth_token.'/'.$fileids[$n],
'thumbnail'=>$CFG->pixpath.'/f/'.mimeinfo('icon32', $v));
'thumbnail'=>$OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $v))));
}
}
}
Expand Down
1 change: 0 additions & 1 deletion repository/draft/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function print_login() {
*/
public function get_listing($path = '', $page = '') {
global $CFG, $USER, $itemid, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$ret = array();
$ret['dynload'] = true;
$ret['nosearch'] = true;
Expand Down
1 change: 0 additions & 1 deletion repository/filepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
set_time_limit(0);

require_login();
$OUTPUT->initialise_deprecated_cfg_pixpath();

$page = optional_param('page', '', PARAM_RAW); // page
$client_id = optional_param('client_id', SITEID, PARAM_RAW); // client ID
Expand Down
4 changes: 1 addition & 3 deletions repository/filesystem/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function __construct($repositoryid, $context = SITEID, $options = array()
}
public function get_listing($path = '', $page = '') {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();

$list = array();
$list['list'] = array();
// process breacrumb trail
Expand Down Expand Up @@ -66,7 +64,7 @@ public function get_listing($path = '', $page = '') {
'source' => $path.'/'.$file,
'size' => filesize($this->root_path.$file),
'date' => time(),
'thumbnail' => $CFG->pixpath .'/f/'. mimeinfo('icon32', $this->root_path.$file)
'thumbnail' => $OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $this->root_path.$file)))
);
} else {
if (!empty($path)) {
Expand Down
4 changes: 1 addition & 3 deletions repository/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ public static function static_function($plugin, $function) {
*/
public static function move_to_filepool($path, $name, $itemid, $filearea = 'user_draft') {
global $DB, $CFG, $USER, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$context = get_context_instance(CONTEXT_USER, $USER->id);
$now = time();
$entry = new object();
Expand Down Expand Up @@ -770,7 +769,7 @@ public static function move_to_filepool($path, $name, $itemid, $filearea = 'user
return array('url'=>$ret->get_url(),
'id'=>$file->get_itemid(),
'file'=>$file->get_filename(),
'icon'=>$CFG->pixpath.'/f/'.mimeinfo('icon32', $path)
'icon'=>$OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $path)))
);
} else {
return null;
Expand Down Expand Up @@ -897,7 +896,6 @@ public static function encode_path($filearea, $path, $visiblename) {
*/
public static function build_tree($fileinfo, $search, $dynamicmode, &$list) {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();

$filecount = 0;
$children = $fileinfo->get_children();
Expand Down
1 change: 0 additions & 1 deletion repository/local/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function search($search_text) {
*/
public function get_listing($encodedpath = '', $page = '', $search = '') {
global $CFG, $USER, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$ret = array();
$ret['dynload'] = true;
$ret['nosearch'] = true;
Expand Down
3 changes: 1 addition & 2 deletions repository/mahara/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ private function ensure_environment() {
*/
public function get_listing($path = null, $page = 1, $search = '') {
global $CFG, $DB, $USER, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();

///check that Mahara has a good version
///We also check that the "get file list" method has been activated (if it is not
Expand Down Expand Up @@ -215,7 +214,7 @@ public function get_listing($path = null, $page = 1, $search = '') {
if ($file['artefacttype'] == 'image') {
$thumbnail = $host->wwwroot."/artefact/file/download.php?file=".$file['id']."&size=70x55";
} else {
$thumbnail = $CFG->pixpath .'/f/'. mimeinfo('icon32', $file['title']);
$thumbnail = $OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $file['title'])));
}
$list[] = array( 'title'=>$file['title'], 'date'=>$file['mtime'], 'source'=>$file['id'], 'thumbnail' => $thumbnail);
}
Expand Down
3 changes: 1 addition & 2 deletions repository/s3/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public function __construct($repositoryid, $context = SITEID, $options = array()
}
public function get_listing($path = '', $page = '') {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$list = array();
$list['list'] = array();
// the management interface url
Expand Down Expand Up @@ -46,7 +45,7 @@ public function get_listing($path = '', $page = '') {
'size'=>$file['size'],
'date'=>userdate($file['time']),
'source'=>$path.'/'.$file['name'],
'thumbnail'=>$CFG->pixpath.'/f/'.mimeinfo('icon32', $file['name'])
'thumbnail'=>$OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $file['name'])))
);
}
}
Expand Down
7 changes: 2 additions & 5 deletions repository/url/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function print_login() {
*/
public function get_listing($path='', $page='') {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$ret = array();
$curl = new curl;
$msg = $curl->head($this->file_url);
Expand All @@ -102,15 +101,14 @@ public function get_listing($path='', $page='') {
$ret['list'][] = array(
'title'=>$filename,
'source'=>$this->file_url,
'thumbnail' => $CFG->pixpath .'/f/'. mimeinfo('icon32', $filename)
'thumbnail' => $OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $filename)))
);
}
}
return $ret;
}
public function analyse_page($baseurl, $content, &$list) {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$urls = extract_html_urls($content);
$images = $urls['img']['src'];
$pattern = '#img(.+)src="?\'?([[:alnum:]:?=&@/._+-]+)"?\'?#i';
Expand All @@ -122,8 +120,7 @@ public function analyse_page($baseurl, $content, &$list) {
'thumbnail'=>url_to_absolute($baseurl, $url),
'thumbnail_height'=>84,
'thumbnail_width'=>84
//'thumbnail' => $CFG->pixpath .'/f/'. mimeinfo('icon32', $url)
);
);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions repository/webdav/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function global_search() {
}
public function get_listing($path='', $page = '') {
global $CFG, $OUTPUT;
$OUTPUT->initialise_deprecated_cfg_pixpath();
$list = array();
$ret = array();
$ret['dynload'] = true;
Expand Down Expand Up @@ -122,7 +121,7 @@ public function get_listing($path='', $page = '') {
$size = !empty($v['getcontentlength'])? $v['getcontentlength']:'';
$ret['list'][] = array(
'title'=>$title,
'thumbnail' => $CFG->pixpath .'/f/'. mimeinfo('icon32', $title),
'thumbnail' => $OUTPUT->old_icon_url('f/'. str_replace(array('.png', '.gif'), '', mimeinfo('icon32', $title))),
'size'=>$size,
'date'=>$filedate,
'source'=>$v['href']
Expand Down

0 comments on commit c8873c4

Please sign in to comment.