Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, March 9, 2010

An overall sketch of Drupal 7

-get drupal root
-drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL)
 define constants
 define('REQUEST_TIME', $_SERVER['REQUEST_TIME']);
 _drupal_bootstrap_configuration()
  error reporting set
  drupal_environment_initialize()
   server vars read
   ini settings set
   error reporting set
  timer_start('page')
   start timers
  drupal_settings_initialize()
   load settings
   set up path
   session cookies
 _drupal_bootstrap_page_cache();
  init user
  load cache
  check if no-db opt else - get db and variables
  block_denied
  cookie init
  _drupal_bootstrap_page_header()
   bootstrap_invoke_all
   drupal_page_get_cache
   check cachable - get cache
    -maybe still run boot hooks
    serve page from cache
    -maybe still run exit hooks
    _drupal_bootstrap_database();
  -set up db
  -register autoload
    _drupal_bootstrap_variables();
  -init variables (either via cache or db)
  -load modules
    require_once DRUPAL_ROOT . '/' . variable_get('session_inc', 'includes/session.inc');
    drupal_session_initialize();
  -conditionally start session
    _drupal_bootstrap_page_header();
  -boot all
  check cache
  get lock and init
  if !cli - ob start and page_header
   -init static + send headers   
    drupal_language_initialize();
  -get languages
  -invoke modules
    require_once DRUPAL_ROOT . '/includes/common.inc';
  define more constants
    _drupal_bootstrap_full();
  -load files
  -set up settings
  -varify
  -init path
  -init custom theme
  -run init hooks
-menu_execute_active_handler()

Sunday, November 22, 2009

Tech Note: Calender fix got to get fixed

So I'm no something of a calender fix, don't ask me why that's just how I role. And thus here's some code for an xhtml calendar, php-gened + with a custom start and a custom end:


$start=array(4,19,1986);
$day = 24*60*60;
$ts = mktime(0,0,0,$start[0],$start[1],$start[2]);
$ts -= date('w',$ts)*$day;
$doctype = DOMImplementation::createDocumentType("html",
"-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
$doc = DOMImplementation::createDocument(null, 'html', $doctype);
$html=$doc->documentElement;
$head=$doc->createElement('head');
$head->appendChild($doc->createElement('title','Timeline'));
$style = $doc->createElement('style');
$style->setAttribute('type','text/css');
$styledata = '
table {
width: 100%;
}
table td {
width: 12%;
}
';
$style->appendChild($doc->createCDATASection($styledata));
$head->appendChild($style);
$html->appendChild($head);
$body=$doc->createElement('body');
$html->appendChild($body);

$table=$doc->createElement('table');
$body->appendChild($table);
$thead=$doc->createElement('thead');
$table->appendChild($thead);
$trow=$doc->createElement('tr');
$thead->appendChild($trow);
$trow->appendChild($doc->createElement('th','Sunday'));
$trow->appendChild($doc->createElement('th','Monday'));
$trow->appendChild($doc->createElement('th','Tuesday'));
$trow->appendChild($doc->createElement('th','Wednesday'));
$trow->appendChild($doc->createElement('th','Thursday'));
$trow->appendChild($doc->createElement('th','Friday'));
$trow->appendChild($doc->createElement('th','Saturday'));
$endtime=mktime();
$tbody = $doc->createElement('tbody');
$table->appendChild($tbody);
$trow=$doc->createElement('tr');
$td=$doc->createElement('td');
$h2=$doc->createElement('h2',date('F Y',$ts));
$td->appendChild($h2);
$td->setAttribute('colspan','7');
$trow->appendChild($td);
$tbody->appendChild($trow);
while($ts < $endtime) {
$trow=$doc->createElement('tr');
for($i=0; $i < 7; $i++) {
$td=$doc->createElement('td');
$td->appendChild($doc->createElement('h3',date('d',$ts)));
$trow->appendChild($td);
$pastday=$ts;
$ts+=$day;
if(date('d',$ts) $tbody->appendChild($trow);
$trow=$doc->createElement('tr');
$td=$doc->createElement('td');
$h2=$doc->createElement('h2',date('F Y',$ts));
$td->appendChild($h2);
$td->setAttribute('colspan','7');
$trow->appendChild($td);
$tbody->appendChild($trow);
$trow=$doc->createElement('tr');
for($j=0; $j < date('w',$ts);$j++) {
$td=$doc->createElement('td');
$trow->appendChild($td);
}
}
}
$tbody->appendChild($trow);
}
header('Content-Type: text/xml');
echo $doc->saveXML();
exit();


Is that the only way to do things?

No.

Is that the best way to do things?

Honestly probably not.

What would probably be the best is if I could bust out some awesome XPath and XSL 2.0 functions/elements - with the date-time/duration functions this would be trivial, so much so it would not make it to any trivia gameshow of any repute.

However, as your next trivia question - who's fighting this lameness - XQilla! Qilla on, dude, Qilla on.

So take it to your head, take it to your heart and remember Rand rocks. Goodnight Folks!

And God Bless.