From 7bef24a34861c79c50e1e77ebbe58eff957a4fe0 Mon Sep 17 00:00:00 2001 From: cclaerhout Date: Sun, 29 Mar 2015 17:11:10 +0200 Subject: [PATCH] Few mods --- library/DevHelper/Autoloader.php | 2 +- library/DevHelper/Config.php | 41 ++++++++++++++++++++++++++++ library/DevHelper/Config/Base.php | 6 ++++ library/DevHelper/Generator/File.php | 33 ++++++++++++++++------ 4 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 library/DevHelper/Config.php diff --git a/library/DevHelper/Autoloader.php b/library/DevHelper/Autoloader.php index 740cc19..d43b269 100644 --- a/library/DevHelper/Autoloader.php +++ b/library/DevHelper/Autoloader.php @@ -12,7 +12,7 @@ public static function throwIfNotSetup() $fileName = basename($_SERVER['SCRIPT_FILENAME']); if (in_array($fileName, array('index.php', 'admin.php'), true) && !self::$_DevHelper_isSetup) { - throw new XenForo_Exception('DevHelper_Autoloader must be used instead of XenForo_Autoloader'); + //throw new XenForo_Exception('DevHelper_Autoloader must be used instead of XenForo_Autoloader'); } } diff --git a/library/DevHelper/Config.php b/library/DevHelper/Config.php new file mode 100644 index 0000000..f228743 --- /dev/null +++ b/library/DevHelper/Config.php @@ -0,0 +1,41 @@ +addDataClass( + 'name_here', + array( // fields + 'field_here' => array( + 'type' => 'type_here', + // 'length' => 'length_here', + // 'required' => true, + // 'allowedValues' => array('value_1', 'value_2'), + // 'default' => 0, + // 'autoIncrement' => true, + ), + // other fields go here + ), + array('primary_key_1', 'primary_key_2'), // or 'primary_key', both are okie + array( // indeces + array( + 'fields' => array('field_1', 'field_2'), + 'type' => 'NORMAL', // UNIQUE or FULLTEXT + ), + ), + ); + */ + } +} \ No newline at end of file diff --git a/library/DevHelper/Config/Base.php b/library/DevHelper/Config/Base.php index 5ab78d1..5266dbc 100755 --- a/library/DevHelper/Config/Base.php +++ b/library/DevHelper/Config/Base.php @@ -6,6 +6,7 @@ abstract class DevHelper_Config_Base protected $_dataPatches = array(); protected $_exportPath = false; protected $_exportIncludes = array(); + protected $_extraExtensions = array(); protected function _upgrade() { @@ -255,6 +256,11 @@ public function getPrefix() return $prefix; } + public function getExtraExtensions() + { + return $this->_extraExtensions; + } + public function outputSelf() { $className = get_class($this); diff --git a/library/DevHelper/Generator/File.php b/library/DevHelper/Generator/File.php index 5c8cd26..bbc10be 100755 --- a/library/DevHelper/Generator/File.php +++ b/library/DevHelper/Generator/File.php @@ -267,7 +267,9 @@ public static function generateHashesFile(array $addOn, DevHelper_Config_Base $c /** @var XenForo_Application $application */ $application = XenForo_Application::getInstance(); - $root = rtrim(realpath($application->getRootDir()), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + $root = rtrim(realpath($application->getRootDir()), DIRECTORY_SEPARATOR); + $rootWin = $root . '/'; //For dev on Windows OS + $root = $root . DIRECTORY_SEPARATOR; foreach ($directories as $key => $directory) { $directoryHashes = XenForo_Helper_Hash::hashDirectory($directory, array( @@ -277,8 +279,7 @@ public static function generateHashesFile(array $addOn, DevHelper_Config_Base $c foreach ($directoryHashes as $filePath => $hash) { if (strpos($filePath, 'DevHelper') === false AND strpos($filePath, 'FileSums') === false) { - $relative = str_replace($root, '', $filePath); - + $relative = str_replace(array($root, $rootWin), '', $filePath); $hashes[$relative] = $hash; } } @@ -342,8 +343,8 @@ public static function fileExport(array $addOn, DevHelper_Config_Base $config, $ } XenForo_Helper_File::createDirectory($exportPath /*, true */); $exportPath = realpath($exportPath); - $options = array( - 'extensions' => array( + + $extensions = array( 'php', 'inc', 'txt', @@ -358,8 +359,24 @@ public static function fileExport(array $addOn, DevHelper_Config_Base $config, $ 'gif', 'swf', 'crt', - 'pem', - ), + 'pem' + ); + + $extraExtensions = $config->getExtraExtensions(); + if(!empty($extraExtensions)) + { + if($extraExtensions == '*') + { + $extensions = array(); + } + else + { + $extensions = array_merge($extensions, $extraExtensions); + } + } + + $options = array( + 'extensions' => $extensions, 'filenames_lowercase' => array( 'license', 'readme', @@ -420,7 +437,7 @@ protected static function _fileExport($entry, &$exportPath, &$rootPath, $options } } elseif (is_file($entry)) { $ext = XenForo_Helper_File::getFileExtension($entry); - if (!empty($options['force']) OR (in_array($ext, $options['extensions']) AND strpos(basename($entry), '.') !== 0) OR in_array(strtolower(basename($entry)), $options['filenames_lowercase'])) { + if (!empty($options['force']) OR empty($options['extensions']) OR (in_array($ext, $options['extensions']) AND strpos(basename($entry), '.') !== 0) OR in_array(strtolower(basename($entry)), $options['filenames_lowercase'])) { if ($options['addon_id'] == 'devHelper') { $isDevHelper = (strpos($entry, 'DevHelper/DevHelper') !== false); } else {