var $disable_jstemplate = false; /// disable inclusion of jstemplate code..
var $company = false;
+ var $css_path = ''; // can inject a specific path into the base HTML page.
+
+
+ var $transObj = false; // used to rollback or commit in JOK/JERR
/**
* ------------- Standard getAuth/get/post methods of framework.
*
$this->loadOwnerCompany();
return true;
-
}
- function init()
+ function init($base = false)
{
+
if (isset($this->_hasInit)) {
return;
}
// move away from doing this ... you can access bootLoader.XXXXXX in the master template..
$boot = HTML_FlexyFramework::get();
// echo'<PRE>';print_R($boot);exit;
- $this->appName= $boot->appName;
- $this->appNameShort= $boot->appNameShort;
+ $this->appName = $boot->appName;
+ $this->appNameShort = $boot->appNameShort;
- $this->appModules= $boot->enable;
+ $this->appModules = $boot->enable;
// echo $this->arrayToJsInclude($files);
$this->isDev = empty($boot->Pman['isDev']) ? false : $boot->Pman['isDev'];
+ $this->css_path = empty($boot->Pman['css_path']) ? '' : $boot->Pman['css_path'];
+
$this->appDisable = $boot->disable;
$this->appDisabled = explode(',', $boot->disable);
$this->version = $boot->version;
$this->uiConfig = empty($boot->Pman['uiConfig']) ? false : $boot->Pman['uiConfig'];
- if (!empty($ff->Pman['local_autoauth']) &&
+ if (!empty($boot->Pman['local_autoauth']) &&
($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
) {
$this->isDev = true;
}
+ if (
+ !empty($_REQUEST['isDev'])
+ &&
+ (
+ (($_SERVER['SERVER_ADDR'] == '127.0.0.1') && ($_SERVER['REMOTE_ADDR'] == '127.0.0.1'))
+ ||
+ (($_SERVER['SERVER_ADDR'] == '::1') && ($_SERVER['REMOTE_ADDR'] == '::1'))
+ )
+
+ ) {
+ $boot->Pman['isDev'] = true;
+ $this->isDev = true;
+ }
+
// if a file Pman_{module}_Pman exists.. and it has an init function... - call that..
//var_dump($this->appModules);
}
/*
- * module init is only loaded on main page call, and includes checks for configuration settings.
+ * call a method on {module}/Pman.php
+ * * initially used on the main page load to call init();
+ * * also used for ccsIncludes??
+ *
+ * // usage: $this->callModules('init', $base)
+ *
*/
- function initModules()
+
+ function callModules($fn)
{
+ $args = func_get_args();
+ array_shift($args);
foreach(explode(',',$this->appModules) as $m) {
$cls = 'Pman_'. $m . '_Pman';
- //echo $cls;
- //echo $this->rootDir . '/'.str_replace('_','/', $cls). '.php';
-
if (!file_exists($this->rootDir . '/'.str_replace('_','/', $cls). '.php')) {
continue;
}
require_once str_replace('_','/', $cls). '.php';
$c = new $cls();
- if (method_exists($c,'init')) {
- $c->init($this);
+ if (method_exists($c, $fn)) {
+ call_user_func_array(array($c,$fn),$args);
}
- }
- }
-
-
+ }
+ }
function get($base, $opts=array())
{
$this->init();
if (empty($base)) {
- $this->initModules();
+ $this->callModules('init', $this, $base);
}
//$this->allowSignup= empty($opts['allowSignup']) ? 0 : 1;
//var_dump($this->isDev);
// force regeneration on load for development enviroments..
- HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev);
+ HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev && !empty($_REQUEST['isDev']));
//header('Content-type: application/xhtml+xml; charset=utf-8');
if ($this->company && $this->company->logo_id) {
$im = DB_DataObject::Factory('Images');
$im->get($this->company->logo_id);
- $this->appLogo = $this->baseURL . '/Images/Thumb/300x100/'. $this->company->logo_id .'/' . $im->filename;
+ $this->appLogo = $this->baseURL . '/Images/Thumb/x100/'. $this->company->logo_id .'/' . $im->filename;
}
header('Content-type: text/html; charset=utf-8');
/**
* loadOwnerCompany:
* finds the compay with comptype=='OWNER'
+ * ?? what about comptype_id-name ?????
*
* @return {Pman_Core_DataObjects_Companies} the owner company
*/
if (!empty($this->authUser)) {
return $this->authUser;
}
- $ff = HTML_FlexyFramework::get();
+ $ff = HTML_FlexyFramework::get();
$tbl = empty($ff->Pman['authTable']) ? 'core_person' : $ff->Pman['authTable'];
$u = DB_DataObject::factory( $tbl );
- if (!$u->isAuth()) {
+
+ if (is_a($u,'PEAR_Error') || !$u->isAuth()) {
return false;
}
$this->authUser =$u->getAuthUser();
function jerror($type, $str, $errors=array(), $content_type = false) // standard error reporting..
{
+ if ($this->transObj) {
+ $this->transObj->query('ROLLBACK');
+ }
+
+ $cli = HTML_FlexyFramework::get()->cli;
+ if ($cli) {
+ echo "ERROR: " .$str . "\n"; // print the error first, as DB might fail..
+ }
+
if ($type !== false) {
+
+ if(!empty($errors)){
+ DB_DataObject::factory('Events')->writeEventLogExtra($errors);
+ }
+
$this->addEvent($type, false, $str);
+
}
$cli = HTML_FlexyFramework::get()->cli;
if ($cli) {
- echo "ERROR: " .$str . "\n";
exit(1); // cli --- exit code to stop shell execution if necessary.
}
}
function jok($str)
{
+ if ($this->transObj ) {
+ $this->transObj->query( connection_aborted() ? 'ROLLBACK' : 'COMMIT');
+ }
+
$cli = HTML_FlexyFramework::get()->cli;
if ($cli) {
echo "OK: " .$str . "\n";
$mods = $this->modulesList();
+ $is_bootstrap = in_array('BAdmin', $mods);
+
foreach($mods as $mod) {
// add the css file..
+
+ if ($is_bootstrap) {
+ if (!file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
+ echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
+ continue;
+ }
+
+ }
$this->outputJavascriptDir("Pman/$mod/widgets", "*.js");
$this->outputJavascriptDir("Pman/$mod", "*.js");
// and finally the JsTemplate...
echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
}
+
+ $this->callModules('outputJavascriptIncludes', $this);
}
*/
function outputCSSIncludes() // includes on CSS links.
{
+
$mods = $this->modulesList();
+ $this->callModules('outputCSSIncludes', $this);
foreach($mods as $mod) {
// add the css file..
$this->outputCSSDir("Pman/$mod","*.css");
-
-
}
-
+
+
}
$basedir = $compile ? $ff->Pman['public_cache_dir'] : false;
$baseurl = $compile ? $ff->Pman['public_cache_url'] : false;
+
+
+
$lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
usort($files, $lsort);
function onException($ex)
{
-
- static $reported = false;
+ static $reported = false;
if ($reported) {
return;
}
$reported = true;
- $out = is_a($ex,'Exception') ? $ex->getMessage() : $ex->toString();
+
+ $out = is_a($ex,'Exception') || is_a($ex, 'Error') ? $ex->getMessage() : $ex->toString();
//print_R($bt); exit;
$ret = array();
$n = 0;
- $bt = is_a($ex,'Exception') ? $ex->getTrace() : $ex->backtrace;
+ $bt = is_a($ex,'Exception')|| is_a($ex, 'Error') ? $ex->getTrace() : $ex->backtrace;
+ if (is_a($ex,'Exception')|| is_a($ex, 'Error') ) {
+ $ret[] = $ex->getFile() . '('. $ex->getLine() . ')';
+ }
foreach( $bt as $b) {
$ret[] = @$b['file'] . '(' . @$b['line'] . ')@' . @$b['class'] . '::' . @$b['function'];
if ($n > 20) {
$e = DB_DataObject::factory('Events');
$e->init($act,$obj,$remarks);
- $e->event_when = date('Y-m-d H:i:s');
+ $e->event_when = $e->sqlValue('NOW()');
$eid = $e->insert();
$e = DB_DataObject::factory('Events');
$e->init($act,$obj,$remarks);
- $e->event_when = date('Y-m-d H:i:s');
+ $e->event_when = $e->sqlValue('NOW()');
$wa = DB_DataObject::factory('core_watch');
if (method_exists($wa,'notifyEvent')) {
$wa->notifyEvent($e); // trigger any actions..