Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few mods #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/DevHelper/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
41 changes: 41 additions & 0 deletions library/DevHelper/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class _DevHelper_Config extends DevHelper_Config_Base
{
protected $_dataClasses = array();
protected $_dataPatches = array();
protected $_exportPath = false;
protected $_exportIncludes = array();

/**
* Return false to trigger the upgrade!
**/
protected function _upgrade()
{
return true; // remove this line to trigger update

/*
$this->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
),
),
);
*/
}
}
6 changes: 6 additions & 0 deletions library/DevHelper/Config/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ abstract class DevHelper_Config_Base
protected $_dataPatches = array();
protected $_exportPath = false;
protected $_exportIncludes = array();
protected $_extraExtensions = array();

protected function _upgrade()
{
Expand Down Expand Up @@ -255,6 +256,11 @@ public function getPrefix()
return $prefix;
}

public function getExtraExtensions()
{
return $this->_extraExtensions;
}

public function outputSelf()
{
$className = get_class($this);
Expand Down
33 changes: 25 additions & 8 deletions library/DevHelper/Generator/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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 {
Expand Down