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

Move shared module directory code to a shared file and support autoloading module interfaces #299

Merged
merged 26 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2819a91
Additional Search Fields
jeffnm Feb 27, 2017
132eb12
Fix PHP Notices on organizations landing page.
t4k Jun 14, 2017
d381b5e
Add a check in case user does not have first or last names.
t4k Jun 20, 2017
1c27089
Issue 281: Fix button when adding a step in admin workflow edit
veggiematts Sep 6, 2017
397709f
fixing type in update script.
Sep 12, 2017
734ecd5
Delete info.php
jeffnm Sep 15, 2017
38854da
refactor directory.php module files to share common code
jsavell Sep 20, 2017
ddcf978
move some language management to common_directory file
jsavell Sep 20, 2017
3e3c814
include common_directory from licensing module, include global LangCo…
jsavell Sep 20, 2017
0c076ed
update autoloader to find module defined interfaces
jsavell Sep 20, 2017
10a6d00
fix license headers
jsavell Sep 20, 2017
a79493e
move format_date function to common directory
jsavell Sep 21, 2017
384122b
fix usage directory and move more shared functions to common directory
jsavell Sep 21, 2017
3992765
Merge pull request #295 from coral-erm/jeffnm-patch-5
veggiematts Sep 25, 2017
69245b5
Merge pull request #238 from caltechlibrary/issue77-php-notices-organ…
veggiematts Oct 10, 2017
a5b0afc
Issue #77: Undefined index: auth/…/Utility.php Line 71
t4k Oct 13, 2017
df6bd68
Merge pull request #309 from caltechlibrary/77-notice-auth-utility-71
veggiematts Oct 18, 2017
1990daa
Merge pull request #290 from jcraitz/jcraitz-fix-SQL_typo-update_2.0.0
veggiematts Oct 18, 2017
4c5eef8
Add checks to avoid PHP Notices in Resources code. (#233)
t4k Oct 19, 2017
112a659
Merge pull request #286 from biblibre/Issue_281_Wrong_Button_In_Worfk…
t4k Oct 27, 2017
b74d408
Add checks for indexes and update HTML structure.
t4k Oct 31, 2017
75db7fc
Merge branch 'development' into jeffnm-resources-search
t4k Oct 31, 2017
78ea34a
Re-add <b> element; required for CSS.
t4k Oct 31, 2017
e65b038
Merge pull request #183 from coral-erm/jeffnm-resources-search
t4k Oct 31, 2017
5dc838b
Merge remote-tracking branch 'origin/pull/299' into PR299
veggiematts Dec 18, 2017
143d1aa
PR299: Fix API
veggiematts Dec 18, 2017
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
28 changes: 0 additions & 28 deletions auth/LangCodes.php

This file was deleted.

4 changes: 3 additions & 1 deletion auth/admin/classes/common/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public function getCORALPath(){
//returns page URL up to /coral/
public function getCORALURL(){
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
Expand Down
60 changes: 2 additions & 58 deletions auth/directory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
**************************************************************************************************************************
** CORAL Usage Statistics Reporting Module v. 1.0
Expand All @@ -17,64 +16,9 @@
**************************************************************************************************************************
*/


// Useful directory constants, ending with |/|.
define('ADMIN_DIR', dirname(__FILE__) . '/admin/');
// Define the MODULE base directory, ending with |/|.
define('BASE_DIR', dirname(__FILE__) . '/');
define('CLASSES_DIR', ADMIN_DIR . 'classes/');

// Automatically load undefined classes from subdirectories of |CLASSES_DIR|.
function __autoload( $className ) {
if (file_exists(CLASSES_DIR) && is_readable(CLASSES_DIR) && is_dir(CLASSES_DIR)) {
$directory = dir(CLASSES_DIR);

// Iterate over the files and directories in |CLASSES_DIR|.
while (false !== ($entry = $directory->read())) {
$path = CLASSES_DIR . $entry;

// Look only at subdirectories
if (is_dir($path)) {
$filename = $path . '/' . $className . '.php';
if (file_exists($filename) && is_readable($filename) && is_file($filename)) {
// Could probably safely use |require()| here, since |__autoload()| is only called when a class isn't loaded.
require_once($filename);
}
}
}
$directory->close();
}
}

// Add lcfirst() for PHP < 5.3.0
if (false === function_exists('lcfirst')) {
function lcfirst($string) {
return strtolower(substr($string, 0, 1)) . substr($string, 1);
}
}



//fix default timezone for PHP > 5.3
if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")){
@date_default_timezone_set(@date_default_timezone_get());
}

// Include file of language codes
include_once 'LangCodes.php';
$lang_name = new LangCodes();
require_once "../common/common_directory.php";

// Verify the language of the browser
global $http_lang;
if(isset($_COOKIE["lang"])){
$http_lang = $_COOKIE["lang"];
}else{
$codeL = str_replace("-","_",substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,5));
$http_lang = $lang_name->getLanguage($codeL);
if($http_lang == "")
$http_lang = "en_US";
}
putenv("LC_ALL=$http_lang");
setlocale(LC_ALL, $http_lang.".utf8");
bindtextdomain("messages", dirname(__FILE__) . "/locale");
textdomain("messages");
?>
111 changes: 111 additions & 0 deletions common/common_directory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

/*
**************************************************************************************************************************
** CORAL Common Directory
**
** Copyright (c) 2010 University of Notre Dame
**
** This file is part of CORAL.
**
** CORAL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
**
** CORAL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along with CORAL. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************************************************************
*/

// Increase memory due to large sized reports
ini_set('max_execution_time', 1000);
ini_set("default_socket_timeout", 1000);
ini_set('memory_limit', '256M');

define('ADMIN_DIR', BASE_DIR . 'admin/');
define('CLASSES_DIR', ADMIN_DIR . 'classes/');
define('INTERFACES_DIR', ADMIN_DIR . 'interfaces/');

// Automatically load undefined classes from subdirectories of |CLASSES_DIR|.
spl_autoload_register( function ($className) {
$directories = array(CLASSES_DIR,INTERFACES_DIR);
foreach ($directories as $currentDirectory) {
if (file_exists($currentDirectory) && is_readable($currentDirectory) && is_dir($currentDirectory)) {
$directory = dir($currentDirectory);
// Iterate over the files and directories in |CLASSES_DIR|.
while (false !== ($entry = $directory->read())) {
$path = $currentDirectory . $entry;
// Look only at subdirectories
if (is_dir($path)) {
$filename = $path . '/' . $className . '.php';
if (file_exists($filename) && is_readable($filename) && is_file($filename)) {
// Could probably safely use |require()| here, since |__autoload()| is only called when a class isn't loaded.
require_once($filename);
break;
}
}
}
$directory->close();
}
}
});


// Add lcfirst() for PHP < 5.3.0
if (false === function_exists('lcfirst')) {
function lcfirst($string) {
return strtolower(substr($string, 0, 1)) . substr($string, 1);
}
}

//fix default timezone for PHP > 5.3
if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")){
@date_default_timezone_set(@date_default_timezone_get());
}


function format_date($mysqlDate) {

//see http://php.net/manual/en/function.date.php for options

//there is a dependence on strtotime recognizing date format for date inputs
//thus, european format (d-m-Y) must use dashes rather than slashes

//upper case Y = four digit year
//lower case y = two digit year
//make sure digit years matches for both directory.php and common.js

//SUGGESTED: "m/d/Y" or "d-m-Y"

return date("m/d/Y", strtotime($mysqlDate));

}

function debug($value) {
echo '<pre>'.print_r($value, true).'</pre>';
}

// Include file of language codes
include_once BASE_DIR . '/../LangCodes.php';
$lang_name = new LangCodes();

// Verify the language of the browser
$GLOBALS['http_lang'];

if(isset($_COOKIE["lang"])) {
$GLOBALS['http_lang'] = $_COOKIE["lang"];
} else {
$codeL = str_replace("-","_",substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,5));
$GLOBALS['http_lang'] = $lang_name->getLanguage($codeL);

if($GLOBALS['http_lang'] == "") {
$GLOBALS['http_lang'] = "en_US";
}
}

putenv("LC_ALL={$GLOBALS['http_lang']}");
setlocale(LC_ALL, "{$GLOBALS['http_lang']}.utf8");
bindtextdomain("messages", BASE_DIR."locale");
textdomain("messages");

?>
29 changes: 0 additions & 29 deletions licensing/LangCodes.php

This file was deleted.

75 changes: 2 additions & 73 deletions licensing/directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,80 +16,9 @@
**************************************************************************************************************************
*/

// Useful directory constants, ending with |/|.
define('ADMIN_DIR', dirname(__FILE__) . '/admin/');
// Define the MODULE base directory, ending with |/|.
define('BASE_DIR', dirname(__FILE__) . '/');
define('CLASSES_DIR', ADMIN_DIR . 'classes/');

// Automatically load undefined classes from subdirectories of |CLASSES_DIR|.
function __autoload( $className ) {
if (file_exists(CLASSES_DIR) && is_readable(CLASSES_DIR) && is_dir(CLASSES_DIR)) {
$directory = dir(CLASSES_DIR);
require_once "../common/common_directory.php";

// Iterate over the files and directories in |CLASSES_DIR|.
while (false !== ($entry = $directory->read())) {
$path = CLASSES_DIR . $entry;

// Look only at subdirectories
if (is_dir($path)) {
$filename = $path . '/' . $className . '.php';
if (file_exists($filename) && is_readable($filename) && is_file($filename)) {
// Could probably safely use |require()| here, since |__autoload()| is only called when a class isn't loaded.
require_once($filename);
}
}
}
$directory->close();
}
}

// Add lcfirst() for PHP < 5.3.0
if (false === function_exists('lcfirst')) {
function lcfirst($string) {
return strtolower(substr($string, 0, 1)) . substr($string, 1);
}
}


//fix default timezone for PHP > 5.3
if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")){
@date_default_timezone_set(@date_default_timezone_get());
}


function format_date($mysqlDate) {

//see http://php.net/manual/en/function.date.php for options

//there is a dependence on strtotime recognizing date format for date inputs
//thus, european format (d-m-Y) must use dashes rather than slashes

//upper case Y = four digit year
//lower case y = two digit year
//make sure digit years matches for both directory.php and common.js

//SUGGESTED: "m/d/Y" or "d-m-Y"

return date("m/d/Y", strtotime($mysqlDate));

}

// Include file of language codes
include_once 'LangCodes.php';
$lang_name = new LangCodes();

// Verify the language of the browser
global $http_lang;
if(isset($_COOKIE["lang"])){
$http_lang = $_COOKIE["lang"];
}else{
$codeL = str_replace("-","_",substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,5));
$http_lang = $lang_name->getLanguage($codeL);
if($http_lang == "")
$http_lang = "en_US";
}
putenv("LC_ALL=$http_lang");
setlocale(LC_ALL, $http_lang.".utf8");
bindtextdomain("messages", dirname(__FILE__) . "/locale");
textdomain("messages");
?>
29 changes: 0 additions & 29 deletions management/LangCodes.php

This file was deleted.

Loading