Update of /var/cvs/Geeklog-2.x/MVCnPHP
In directory iowaoutdoors:/tmp/cvs-serv31127
Modified Files:
Controller.php
Log Message:
changed use of fileatime to filemtime as atime wasn't what I
really needed.
Index: Controller.php
============================================================
=======
RCS file: /var/cvs/Geeklog-2.x/MVCnPHP/Controller.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Controller.php 20 Nov 2006 14:53:33 -0000 1.14
--- Controller.php 20 Nov 2006 15:03:48 -0000 1.15
***************
*** 40,48 ****
* Sample usage:
* <code>
! * $configData = '/var/www/htdocs/mvcconfig.xml';
! * $controller = new
Geeklog_MVCnPHP_Controller($configData);
! * $controller->setBaseURL('http://www.example.com');
! * $controller->setViewDir('/var/www/views/');
! * $controller->setCommandDir('/var/www/commands/');
* $controller->processRequest();
* </code>
--- 40,50 ----
* Sample usage:
* <code>
! * $configOptions = array('doCompileChecks'=1,
! *
'apc_options'=>array('apc_index'=>'foo'),
! * 'viewDir=>'/var/www/views',
! *
'commandDir=>'/var/www/commands',
! * 'baseUrl'=>'http://www.example.com');
! *
! * $controller = new
Geeklog_MVCnPHP_Controller($configOptions);
* $controller->processRequest();
* </code>
***************
*** 144,147 ****
--- 146,152 ----
*
* Basic setup for the controller. Here are the config
options with their defaults:
+ * 'viewDir' => '',
+ * 'commandDir' => '',
+ * 'baseUrl' => '',
* 'allowedFormMethod' => MVC_BOTH,
* 'doCompileChecks' => true,
***************
*** 166,169 ****
--- 171,186 ----
$this->clearMessages();
+ if (!empty($options['commandDir'])) {
+
$this->setCommandDir($options['commandDir']);
+ }
+
+ if (!empty($options['viewDir'])) {
+ $this->setViewDir($options['viewDir']);
+ }
+
+ if (!empty($options['baseUrl'])) {
+ $this->setBaseURL($options['baseUrl']);
+ }
+
if (empty($options['allowedFormMethod'])) {
$this->allowedFormMethod = MVC_BOTH;
***************
*** 508,511 ****
--- 525,530 ----
* so it starts the build process.
*
+ * NOTE: this will not work if noatime is used on the
filesystem!!!!!
+ *
* author Tony Bibbs <tony geeklog.net>
* access protected
***************
*** 530,540 ****
$fd = opendir($curDir);
while (($curFile = readdir($fd))) {
! $filename = $curDir . $curFile;
// We should not have a handle to a
directory here
! if (is_dir($filename)) continue;
clearstatcache();
! if (filemtime($filename) >
$lastBuildTime) {
// Only clear the internal
configuration once, please
! echo "<pre>The file,
$filename, is either new or has changed. Must rebuild the
entire MVCnPHP Configuration<pre>";
$this->internalConfiguration =
array();
$forceBuild = true;
--- 549,560 ----
$fd = opendir($curDir);
while (($curFile = readdir($fd))) {
! $fileToCheck = $curDir . $curFile;
// We should not have a handle to a
directory here
! if (is_dir($fileToCheck)) continue;
clearstatcache();
! if (filemtime($fileToCheck) >
$lastBuildTime) {
// Only clear the internal
configuration once, please
! echo "<pre>The file,
$fileToCheck, is either new or has changed. Must rebuild
the entire MVCnPHP Configuration<pre>";
! echo "<pre> filemtime:
" . filemtime($fileToCheck) . " last build: "
. $lastBuildTime . '</pre>';
$this->internalConfiguration =
array();
$forceBuild = true;
***************
*** 542,545 ****
--- 562,567 ----
}
}
+ // If we caught the 'break' from above then
skip the next loop
+ if ($forceBuild) break;
}
}
***************
*** 554,559 ****
if (is_dir($filename)) continue;
clearstatcache();
! echo "<pre>Adding
configuration for file, $filename<pre>";
! $this->configure($filename);
}
}
--- 576,586 ----
if (is_dir($filename)) continue;
clearstatcache();
! echo "<pre>Adding
configuration for file, $filename</pre>";
! try {
! $this->configure($filename);
! } catch (Exception $e) {
! echo '<h2><font
color="red">ERROR: ' . $e->getMessage() .
'</font></h2>';
! throw $e;
! }
}
}
***************
*** 562,572 ****
// Now that we are done, set the last build time.
if ($forceBuild) {
! echo "<pre>Setting LASTBUILD time for
this MVC build</pre>";
! $this->internalConfiguration['LASTBUILD'] =
time();
// See if we should load this stuff into
shared memory. Note we assume if they gave us
// APC options that they have APC actually
installed and configured. Also if they are
// using APC we ignore their request to write
to disk as there is no point.
if ($this->apcOptions) {
! echo "<pre>Storing configuration
in memory</pre>";
if
(is_numeric($this->apcOptions['apc_ttl'])) {
apc_store($this->apcOptions['apc_index'],
$this->internalConfiguration,
--- 589,600 ----
// Now that we are done, set the last build time.
if ($forceBuild) {
! $newBuildTime = time();
! echo '<pre>Setting LASTBUILD time for this
MVC build to </pre>' . $newBuildTime;
! $this->internalConfiguration['LASTBUILD'] =
$newBuildTime;
// See if we should load this stuff into
shared memory. Note we assume if they gave us
// APC options that they have APC actually
installed and configured. Also if they are
// using APC we ignore their request to write
to disk as there is no point.
if ($this->apcOptions) {
! echo '<pre>Storing configuration in
memory</pre>';
if
(is_numeric($this->apcOptions['apc_ttl'])) {
apc_store($this->apcOptions['apc_index'],
$this->internalConfiguration,
***************
*** 598,602 ****
* APC which handles only include/require, not their
_once counterparts. Therefore you'll
* notice that this code will ignore any require's and
include's and ignore the extends clause
! * which we really don't need. In the end as long as
we can call getNames(), getForwards()
* and get
*
--- 626,630 ----
* APC which handles only include/require, not their
_once counterparts. Therefore you'll
* notice that this code will ignore any require's and
include's and ignore the extends clause
! * which we really don't need. In the end as long as
we can call getActions(), getForwards()
* and get
*
***************
*** 636,639 ****
--- 664,674 ----
$objClassNameAndParent =
$this->getClassNameAndParent($fileToConfigure);
+
+ // If we get false back then class must've been
abstract
+ if (!$objClassNameAndParent) {
+ echo "<pre> Skipping file, class
is abstract</pre>";
+ return;
+ }
+
$objectClassName = $objClassNameAndParent[0];
$codeToEval = str_ireplace('require ', '//require
', file_get_contents($fileToConfigure));
***************
*** 645,673 ****
// OK, if they tried extending anything just stub
it out for now
! if (!class_exists($objClassNameAndParent[1])) {
$parentClass = 'class ' .
$objClassNameAndParent[1] . ' {}';
}
//print_R($parentClass . "nn" .
$codeToEval);
! eval($parentClass . "nn" .
$codeToEval);
!
! $tmpObject = new $objectClassName;
echo "<pre> Found class
$objectClassName in $fileToConfigure</pre>";
! $objectLogicalNames = $tmpObject->getNames();
// If this view requested to be the default
action, set it.
! if
(in_array('getIsDefaultAction',get_class_methods($tmpObject)
)) {
! if ($tmpObject->getIsDefaultAction())
$objectLogicalNames[] = 'default';
}
// NOTE: there must be at least one value in the
array.
if (!is_array($objectLogicalNames)) {
! throw new Exception('getNames() must return an
array.');
}
// There can't be two objects sharing the same
name
foreach ($objectLogicalNames as $curName) {
! if (in_array($curName,
array_keys($this->internalConfiguration))) {
throw new Exception("The name
$curName is already used but another view or command.
Names must be unique.");
--- 680,724 ----
// OK, if they tried extending anything just stub
it out for now
! $parentClass = '';
! if (!class_exists($objClassNameAndParent[1])) {
$parentClass = 'class ' .
$objClassNameAndParent[1] . ' {}';
}
//print_R($parentClass . "nn" .
$codeToEval);
! if (eval($parentClass . "nn" .
$codeToEval) === false) {
! echo '<h2><font
color="red">Parse error found during code
evaluation</font></h2>';
! echo 'Code evaluated: <pre>' . $parentClass
. "nn" . $codeToEval . '</pre>';
! exit;
! }
!
echo "<pre> Found class
$objectClassName in $fileToConfigure</pre>";
! // Get action names
! $objectLogicalNames =
call_user_func(array($objectClassName,'getActions'));
!
! // Get any associated forwards
! if (in_array('getForwards',
get_class_methods($objectClassName))) {
! $objectForwards =
call_user_func(array($objectClassName,'getForwards'));
! if (count($objectForwards) == 0) {
! echo "<pre> class
$objectClassName has no forwards</pre>";
! }
! } else {
! echo "<pre> class
$objectClassName has no forwards</pre>";
! $objectForwards = array();
! }
// If this view requested to be the default
action, set it.
! if
(in_array('getIsDefaultAction',get_class_methods($objectClas
sName))) {
! if
(call_user_func(array($objectClassName,'getIsDefaultAction')
)) $objectLogicalNames[] = 'default';
}
// NOTE: there must be at least one value in the
array.
if (!is_array($objectLogicalNames)) {
! throw new Exception('getActions() must return
an array.');
}
// There can't be two objects sharing the same
name
foreach ($objectLogicalNames as $curName) {
! if (in_array($curName,
array_keys($this->internalConfiguration))) {
throw new Exception("The name
$curName is already used but another view or command.
Names must be unique.");
***************
*** 675,681 ****
}
- // Get any associated forwards
- $objectForwards = $tmpObject->getForwards();
if (!empty($objectForwards)) {
if (!is_array($objectForwards)) {
--- 726,731 ----
}
+ // Process the forwards
if (!empty($objectForwards)) {
if (!is_array($objectForwards)) {
***************
*** 732,735 ****
--- 782,789 ----
if (token_name($tokenArray[$i][0]) ==
'T_EXTENDS') {
$extendFound = $tokenArray[$i+2][1];
+ } else {
+ if (token_name($tokenArray[$i][0]) ==
'T_ABSTRACT') {
+ return false;
+ }
}
}
_______________________________________________
geeklog2-cvs mailing list
geeklog2-cvs lists.geeklog.net
http://lists.geeklog.net/mailman/listinfo/geeklog2-cvs
|