« home   paste   Anonymous | Login | Signup for a new account 09-17-2019 12:14 CEST
* X »
GeSHi - Generic Syntax Highlighter Syntax Coloriser for PHP

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000043 [GeSHi] core feature N/A 12-21-05 23:26 02-18-06 11:46
Reporter BenBE View Status public  
Assigned To nigel
Priority normal Resolution fixed  
Status closed   Product Version 1.1.1alpha3
Summary 0000043: additional functions for theme enumeration
Description Sometimes it would be nice to allow the user to generate a language- or theme-dependent list of which languages a theme or which themes are supported by a particular language.

$geshi->supportedLanguageThemes //All themes the given language could be highlighted with
$geshi->supportedThemeLanguages //all languages the given Theme supports

Given those two functions you could easily generate a dropdown list for the website in which the user could choose the theme for a source.

I would include such functions for security reasons thus an user of the script doesn't have to care about directory structure, but can gather that information too. Thus you know that theming won't create any security risks and at the same time also is easy-to-use ...
Additional Information
Attached Files

- Relationships

SYSTEM WARNING: Creating default object from empty value

related to 0000055closed nigel Theme loading performed at earliest in $G->ParseCode 
child of 0000007closed nigel Theming support 

- Notes
12-22-05 09:49

I can see there use I guess, with perhaps slight naming changes.

Which reminds me that if the user selects a theme then a language that the theme doesn't support, it should default to the default theme. Perhaps they could specify a "theme preference order".
12-22-05 11:09

Or vice versa thus you can create a combobox for your website where user selects the desired languages and gets a second box containing only supported themes for that language.

IDK if your suggestion is to be included as part of the language file as a "preferred themes" setting?

$this->setPreferredThemes(array("boride", "geshi"));
12-23-05 10:00

That's an interesting idea, actually. Languages could say that they want to be highlighted by this them (if it is installed).

If the user calls setTheme though, it has to be overridden.

If the user calls setTheme (or the language file tries to set to a theme that doesn't exist), then the default theme should be used (or the next alternative tried etc).

Default theme is called 'default' and not 'geshi', btw.
12-23-05 10:13

Oh yeah, the user should be able to specify a theme preference order as well, using setTheme.
12-23-05 10:41

Another thing related to this issue is, like for the languages, giving themes a "nice name". a one-line php file in the themes base dir called "themeinfo.php" could do this job. This file is only included when "nice theme names" are requested (i.e. in the theme enumeration process).

@default vs. geshi ;-) I know :P

@Override on User request: Sure, The language only tells its oreferences and any additional call to setTheme would add the theme in front of the others thus

[boride], default //boride selected

with another call to setTheme would result in

[default], boride, (default) //default selected, second default occurance might be removed
12-23-05 13:27

So we could return "Default", "Borland IDE" etc. Good idea.

Your implementation of overriding is a good one too.
01-02-06 13:19

I've added useThemes() method to GeSHiStyler, that's what the language files should use to specify what themes they should use by default. It takes either an array or string as expected. Dupes are removed and each is tried in turn. Calls to setTheme, of course, get tried first.

$geshi->setTheme() takes an array or string as well (this is just a wrapper for calling the styler's useThemes method).

I'll add the methods this bug is about shortly.
01-02-06 15:46

I've added the methods (they are all _static_):

  * GeSHi::themesSupportedBy($language) - returns all of the themes that this language has language files in (preforms a realtime directory lookup).
  * GeSHi::languagesSupportedBy($theme) - returns all of the languages that this theme claims it supports, including dialects. This is done by looking in the new themeinfo.php file and getting an array out of it (of the form 'language' => array('dialect', ...)). So this is _not_ done by the filesystem, and to add a new language to a theme for use by this method you should also add it to the themeinfo.php file (though it doesn't stop you using the language/theme if you try to set them).
  * GeSHi::getHumanThemeName($theme) - looks in themeinfo.php to find a human name (e.g. "Borland IDE").

So if you were making your drop downs, you'd use GeSHi::themesSupportedBy() to find out what themes were available for the language chosen, then use GeSHi::getHumanThemeName() on each one to get a nice name.

Awaiting your thoughts on this. Please test for attempting to insert naughty paths because some of those methods include files, and suggest any other methods you think may be useful.
01-03-06 01:28

Other Routines may include

- isLangSupportedByTheme($themename, $langname);
Returns if the given language is supported by the theme specified

- isThemeSupporting Language($themename, $langname);
Returns if the given theme includes support for the language specified

- themesSupportedBy($language) and languagesSupportedBy($theme)
May include a second param that tells if the friendly names are to be returned
(or maybe return an associative array containing internal name as index and friendly name as value)
01-28-06 19:45

I added the static method themeSupportsLanguage($theme, $language). Note that isLanguageSupportedByTheme and isThemeSupportingLanguage are the same thing, are they not? If a language is supported by a theme then the theme surely supports that language ;)

I didn't do the optional parameter for the other methods to return human names yet. Are you sure this is needed? There's nothing to stop the user using getHumanThemeName() to get the names as they require (because getting the name means doing an include() which is slow, so we'd rather it was only done when needed).
01-29-06 01:07

Oh, yeah, error of mine ...

I meant isThemeSupportedByLang instead of isThemeSupportingLanguage.

For the getHumanName feature by a param: Would be an ease only. Default would have been "Internal Name" anyway performing the include only if requested. It's up to you if you include it ;-)
01-29-06 12:57

I've added it in CVS, it wasn't a big change.

If you confirm, I don't think that there's anything else that needs to be done for this bug.
01-30-06 01:45

IMHO there's nothing else to add. I'm closing this bug.
02-18-06 11:46

Issue closed.

- Issue History
Date Modified Username Field Change
12-21-05 23:26 BenBE New Issue
12-21-05 23:26 BenBE Status new => assigned
12-21-05 23:26 BenBE Assigned To  => nigel
12-21-05 23:36 BenBE Relationship added child of 0000007
12-22-05 09:49 nigel Note Added: 0000163
12-22-05 11:09 BenBE Note Added: 0000170
12-23-05 10:00 nigel Note Added: 0000174
12-23-05 10:13 nigel Note Added: 0000177
12-23-05 10:41 BenBE Note Added: 0000180
12-23-05 13:27 nigel Note Added: 0000183
12-24-05 13:43 BenBE Relationship added related to 0000055
01-02-06 13:19 nigel Note Added: 0000212
01-02-06 15:46 nigel Note Added: 0000219
01-02-06 15:46 nigel Status assigned => feedback
01-02-06 15:46 nigel Resolution open => fixed
01-03-06 01:28 BenBE Note Added: 0000226
01-28-06 19:45 nigel Note Added: 0000270
01-29-06 01:07 BenBE Note Added: 0000275
01-29-06 12:57 nigel Note Added: 0000279
01-30-06 01:45 BenBE Status feedback => resolved
01-30-06 01:45 BenBE Fixed in Version  => 1.1.1alpha4
01-30-06 01:45 BenBE Note Added: 0000287
02-18-06 11:46 nigel Status resolved => closed
02-18-06 11:46 nigel Note Added: 0000329


Mantis 1.0.0rc2[^]
Copyright © 2000 - 2005 Mantis Group
64 total queries executed.
44 unique queries executed.
Powered by Mantis Bugtracker