From 1c019f4219dbb4352c0057e6507dda3919760343 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Tue, 6 May 2014 15:31:47 +0700 Subject: [PATCH] Fix 500 Unable to load format class Fix #297 --- source/plg_system_t3/includes/admin/theme.php | 2 + .../plg_system_t3/includes/format/less3.3.php | 137 ++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 source/plg_system_t3/includes/format/less3.3.php diff --git a/source/plg_system_t3/includes/admin/theme.php b/source/plg_system_t3/includes/admin/theme.php index fc7257bf5e..cbeb6f2159 100644 --- a/source/plg_system_t3/includes/admin/theme.php +++ b/source/plg_system_t3/includes/admin/theme.php @@ -14,6 +14,8 @@ jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); +// add new Less format class to work with joomla 3.3 +T3::import('format/less3.3'); /** * diff --git a/source/plg_system_t3/includes/format/less3.3.php b/source/plg_system_t3/includes/format/less3.3.php new file mode 100644 index 0000000000..7a24d87443 --- /dev/null +++ b/source/plg_system_t3/includes/format/less3.3.php @@ -0,0 +1,137 @@ + $value) + { + // If the value is an object then we need to put it in a local section. + $result[] = $this->getKey($key) . ': ' . $this->getValue($value); + } + + return implode("\n", $result); + } + + /** + * Converts an LESS variables string to name/value pair object + */ + public function stringToObject($data, array $options = array()) + { + // If no lines present just return the object. + if (empty($data)) + { + return new stdClass; + } + + // Initialize variables. + $obj = new stdClass; + $lines = explode("\n", $data); + + // Process the lines. + foreach ($lines as $line) + { + // Trim any unnecessary whitespace. + $line = trim($line); + + // Ignore empty lines and comments. + if (empty($line) || (substr($line, 0, 1) == '/') || (substr($line, 0, 1) == '*')) + { + continue; + } + + // Check that an equal sign exists and is not the first character of the line. + if (!strpos($line, ':')) + { + // Maybe throw exception? + continue; + } + + // Get the key and value for the line. + list ($key, $value) = explode(':', $line, 2); + + // Validate the key. + if (preg_match('/@[^A-Z0-9_]/i', $key)) + { + // Maybe throw exception? + continue; + } + + // Validate the value. + //if (preg_match('/[^\(\)A-Z0-9_-];$/i', $value)) + //{ + // Maybe throw exception? + // continue; + //} + + // If the value is quoted then we assume it is a string. + + $key = str_replace('@', '', $key); + $value = str_replace(';', '', $value); + $value = preg_replace('/\/\/(.*)/', '', $value); + $value = trim($value); + $obj->$key = $value; + } + + // Cache the string to save cpu cycles -- thus the world :) + + return $obj; + } + + /** + * Method to get a value in an INI format. + * + * @param mixed $value The value to convert to INI format. + * + * @return string The value in INI format. + * + * @since 11.1 + */ + protected function getValue($value) + { + return $value . ';'; + } + + /** + * Method to get a value in an INI format. + * + * @param mixed $key + * + * @return string The value in INI format. + * + * @since 11.1 + */ + protected function getKey($key) + { + return '@' . $key; + } +}