Logika wg PKP

Tym razem w nie­co mniej tech­nicz­nym tonie, choć nie będzie bez matematyki 😉

Co powin­no być szyb­sze — bez­po­śred­nia podróż z punk­tu A do punk­tu B, czy może podróż z punk­tu A do punk­tu C, pół­go­dzin­na prze­siad­ka i dal­sza podróż z punk­tu C do punk­tu B?

Na PKP szyb­ciej jest jechać A‑C-B niż A‑B. Spójrz­cie na pod­lin­ko­wa­ny obra­zek, jadąc ze Szcze­ci­na pocią­giem o 16:27, lepiej jest wysiąść w Pozna­niu i wsiąść w inny — tej samej kate­go­rii, bo też pospiesz­ny — pociąg, niż jechać bez­po­śred­nio do Wro­cła­wia. Mimo że dodat­ko­wa prze­siad­ka w Pozna­niu trwa 25 minut, a bez­po­śred­ni pociąg odjeż­dża wcze­śniej niż ten inny, na miej­scu we Wro­cła­wiu to ten inny pociąg będzie wcze­śniej i to aż o 13 minut 😀

pkprules

Zaszufladkowano do kategorii Humor

[en] Running CodeIgniter controller methods from external application

Gosh, this blog gets too tech­ni­cal 🙁 I guess I need to start wri­ting some kind of non-IT jour­nal here. You know, the teena­ge-pink-blog style 😉

Any­way, more for my own reference.

Code­Igni­ter is a nice and nonin­tru­si­ve PHP appli­ca­tion fra­me­work that I’ve grown to like and use it (also com­mer­cial­ly). The pro­blem is inte­gra­ting its MVC with exter­nal appli­ca­tions such as CMSes.

Here­’s a quick hack I’ve done to make this possible:

1. Cre­ate „exter­nal” sub­di­rec­to­ry under „sys­tem” direc­to­ry of Code­Igni­ter installation.
2. Pla­ce atta­ched files there.
3. Open „system/libraries/Loader.php” file and patch it like this: find line 681 and change

global $OUT;
$OUT->set_output(ob_get_contents());

to

global $OUT;
if (!isset($OUT)) $OUT = $GLOBALS['ci_external_out'];
$OUT->set_output(ob_get_contents());

4. For exam­ple of use, see atta­ched index.php file, basi­cal­ly to call a con­trol­ler method, just do this:

require_once 'ciexternal.php';
echo ci_external('controller', 'method');