Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

theme-support for plugin-files #899

Closed
wants to merge 1 commit into from

2 participants

@inkscapeforum

most plugins call AddCssFile by direct-path, and so this css-files are not themeable. There is no bug-report, but Issue #385 is related.

This fix allows the modification of files called by direct-path in a template.

changes:

  • add template-paths to direct-path (no slash at beginning) in $_CssFiles Iteration
  • copy existing template-code to new method getCssThemePath() to avoid duplicate code

as a result the following css-path is added to glob-arr: templates/$tmpl_name/design/plugins/FileUpload/css/fileupload.css

parent is vanilla master

@inkscapeforum inkscapeforum fix to allow the modification of plugin-files in template
 - add template-paths to direct-path (no slash at beginning) in CssFile Iteration
 - copy existing template-code to new method getCssThemePath() to avoid duplicate code

e.g: templates/$tmpl_name/design/plugins/FileUpload/css/fileupload.css
e085afd
@linc
Collaborator

Hey inkscape, thanks for taking a look at this. It turns out it's already possible to override plugin CSS with your theme if the plugin is created correctly. If they call AddCssFile('PluginName', '', 'plugins/PluginName') and keep their CSS file in a design folder in the plugin, then you can override it just like anything else.

If you see plugins in one of Vanilla's repositories that don't conform to that, let me know and I'll fix them. If they are a third-party contribution, try contacting the plugin author and asking them to fix it.

@linc linc closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 14, 2011
  1. @inkscapeforum

    fix to allow the modification of plugin-files in template

    inkscapeforum authored
     - add template-paths to direct-path (no slash at beginning) in CssFile Iteration
     - copy existing template-code to new method getCssThemePath() to avoid duplicate code
    
    e.g: templates/$tmpl_name/design/plugins/FileUpload/css/fileupload.css
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 17 deletions.
  1. +29 −17 library/core/class.controller.php
View
46 library/core/class.controller.php
@@ -1245,29 +1245,23 @@ public function RenderMaster() {
foreach ($this->_CssFiles as $CssInfo) {
$CssFile = $CssInfo['FileName'];
+ $CssPaths = array();
if(strpos($CssFile, '/') !== FALSE) {
- // A direct path to the file was given.
- $CssPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile))));
+ if( $this->Theme) {
+ $CssPaths = $this->getCssThemePath( $CssFile);
+ }
+ // A direct path to the file was given.
+ $CssPaths[] = CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile)));
} else {
- $CssGlob = preg_replace('/(.*)(\.css)/', '\1*\2', $CssFile);
- $AppFolder = $CssInfo['AppFolder'];
- if ($AppFolder == '')
+ $CssGlob = preg_replace('/(.*)(\.css)/', '\1*\2', $CssFile);
+ $AppFolder = $CssInfo['AppFolder'];
+ if ($AppFolder == '')
$AppFolder = $this->ApplicationFolder;
// CSS comes from one of four places:
$CssPaths = array();
if ($this->Theme) {
- // 1. Application-specific css. eg. root/themes/theme_name/app_name/design/
- // $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob;
- // 2. Theme-wide theme view. eg. root/themes/theme_name/design/
- // a) Check to see if a customized version of the css is there.
- if ($this->ThemeOptions) {
- $Filenames = GetValueR('Styles.Value', $this->ThemeOptions);
- if (is_string($Filenames) && $Filenames != '%s')
- $CssPaths[] = PATH_THEMES.DS.$this->Theme.DS.'design'.DS.ChangeBasename($CssFile, $Filenames);
- }
- // b) Use the default filename.
- $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . $CssFile;
+ $CssPaths = $this->getCssThemePath( $CssFile);
}
@@ -1538,5 +1532,23 @@ public function SetJson($Key, $Value = '') {
public function Title($Title) {
$this->SetData('Title', $Title);
}
+
+ /**
+ * 1. Application-specific css. eg. root/themes/theme_name/app_name/design/
+ * $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob;
+ * 2. Theme-wide theme view. eg. root/themes/theme_name/design/
+ * a) Check to see if a customized version of the css is there.
+ */
+ public function getCssThemePath($CssFile) {
+ $CssPath = array();
+ if ($this->ThemeOptions) {
+ $Filenames = GetValueR('Styles.Value', $this->ThemeOptions);
+ if (is_string($Filenames) && $Filenames != '%s')
+ $CssPaths[] = PATH_THEMES.DS.$this->Theme.DS.'design'.DS.ChangeBasename($CssFile, $Filenames);
+ }
+ // b) Use the default filename.
+ $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . $CssFile;
+ return $CssPaths;
+ }
-}
+}
Something went wrong with that request. Please try again.