public function __construct() { $this->request = Wi3::instance()->routing->url; // Url of request, as found in routing // base URL determination of the *unrewritten* site URL // First get the part of the *rewritten* url that comes after $controller/$action (e.g. "pagename/arg1/arg2" after "sitearea/view") // Rewritten URL might be: .../sitearea/view/pagename/arg1 OR .../adminarea/ // (There is NOT NECESSARILY an action after the controller: Do a check for that!) if (strpos(Wi3::inst()->routing->filename, "app/index.php/" . Wi3::inst()->routing->controller . "/" . Wi3::inst()->routing->action) !== FALSE) { // There is an action part present $pagepart = substr(Wi3::inst()->routing->filename, strpos(Wi3::inst()->routing->filename, "app/index.php/" . Wi3::inst()->routing->controller . "/" . Wi3::inst()->routing->action) + strlen("app/index.php/" . Wi3::inst()->routing->controller . "/" . Wi3::inst()->routing->action)); } else { // There is only the controller and NOT an action part $pagepart = substr(Wi3::inst()->routing->filename, strpos(Wi3::inst()->routing->filename, "app/index.php/" . Wi3::inst()->routing->controller) + strlen("app/index.php/" . Wi3::inst()->routing->controller)); } if (!empty($pagepart)) { // That pagepart is also available in the *unrewritten* URL, at the very end of the URL // The part before it is our 'base' that we want to fetch $baseurl = substr(Wi3::inst()->routing->url, 0, strlen(Wi3::inst()->routing->url) - strlen($pagepart)) . "/"; // OR alternatively: $basepart = substr(Wi3::inst()->routing->url, 0, strrpos(Wi3::inst()->routing->url, $pagepart)); } else { // There is no pagepart, so only a baseurl (should in reality not occur, but anyways) $baseurl = Wi3::inst()->routing->url; } // Ensure a slash at the end of the baseurl $baseurl = trim($baseurl, "/") . "/"; // The baseurl is now something like http://domain.com/(folder/)adminarea/ or http://domain.com/(folder/)_wi3controller/somecontroller or http://comain.com/(folder/)pagename // We however do not want parts like adminarea or _wi3controller in the base url // Mind: we do not need to check for things like _wi3files because these URLs will/should not resolve here, but get a file directly if (strpos($baseurl, "/_wi3controllers/") !== FALSE) { $this->baseurl = substr($baseurl, 0, strpos($baseurl, "/_wi3controllers/") + 1); } else { if (strpos($baseurl, "/adminarea/") !== FALSE) { $this->baseurl = substr($baseurl, 0, strpos($baseurl, "/adminarea/") + 1); } else { if (strpos($baseurl, "/superadminarea/") !== FALSE) { $this->baseurl = substr($baseurl, 0, strpos($baseurl, "/superadminarea/") + 1); } else { $this->baseurl = $baseurl; //substr($baseurl, 0, -1); } } } // Now set the different 'urlof' variables $this->appfiles = $this->wi3files = $this->baseurl . "_wi3files/"; $this->appcontrollers = $this->wi3controllers = $this->baseurl . "_wi3controllers/"; // Adminarea can shorthandedly be accessed like domain.com/something/adminarea/action // This also goes for /adminarea_menu_ajax etc // Take that into account if (strpos(Wi3::inst()->routing->controller, "adminarea") === 0 or strpos(Wi3::inst()->routing->controller, "superadminarea") === 0) { $this->controller = $this->baseurl . Wi3::inst()->routing->controller . "/"; } else { $this->controller = $this->controller(Wi3::inst()->routing->controller); } $this->action = $this->action(Wi3::inst()->routing->action); //site and pagefiller location can only be known after site and page have been loaded by Engine or View //we therefore register an hook on the wi3.siteandpageloaded event Event::instance("wi3.init.sitearea.site.loaded")->callback(array("Wi3_urlof", "fillsite")); Event::instance("wi3.init.sitearea.page.loaded")->callback(array("Wi3_urlof", "fillpageandpagefiller")); }
public function create_table_from_sprig_model($m) { // Create Model if only string is passed if (is_string($m)) { $m = Sprig::factory($m); } $sqls = $this->sql_for_creating_table_from_sprig_model($m); $sqls += $this->sql_for_creating_connection_table_from_sprig_model($m); $db = Wi3::instance()->database->instance($m->_db); //use correct global or site db-instance, depending on the setting of the model $result = array(); foreach ($sqls as $name => $sql) { $res = $db->query(NULL, $sql, TRUE); if ($res !== FALSE) { $result[$name] = $sql; } else { $result[$name] = FALSE; } } return $result; }
Kohana::modules(array('event' => MODPATH . 'event', 'sprig-auth' => MODPATH . 'sprig-auth', 'acl' => APPPATH . 'acl', 'sprig-mptt' => MODPATH . 'sprig-mptt', 'sprig' => MODPATH . 'sprig', 'auth' => MODPATH . 'auth', 'cache' => MODPATH . 'cache', 'phpquery' => MODPATH . 'phpquery', 'database' => MODPATH . 'database', 'plugin_multilanguage' => APPPATH . 'plugins/multilanguage', 'plugin_jquery' => APPPATH . 'plugins/jquery', 'plugin_clientjavascriptvars' => APPPATH . 'plugins/clientjavascriptvars', 'plugin_tikocache' => APPPATH . 'plugins/tikocache', 'plugin_betterexamples' => APPPATH . 'plugins/betterexamples', 'pagefiller_default' => APPPATH . 'pagefillers/default', 'htmlpurifier' => MODPATH . 'htmlpurifier')); // Enable the Supercache (don't for the moment, it won't help performance-wise) // $super_cache = Super_Cache::instance(); if (!defined('SUPPRESS_REQUEST')) { /** * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO']. * If no source is specified, the URI will be automatically detected. */ $request = Request::instance(); try { Event::instance('wi3.beforeinit')->execute(); // Used by i.e. caching-mechanisms /** * Now init Wi3. The main Wi3 class in turn will load its subclasses */ Wi3::instance()->init(); // Fire event that marks the begin of process execution Event::instance('wi3.beforeexecution')->execute(); // Used by i.e. caching-mechanisms // Attempt to execute the response $request->execute(); if (is_object($request->response)) { $request->response = $request->response->render(); // ->response is a View object most often. By rendering it and then storing it as a string, Request::instance()->response will contain the final string-result, so that the HTML can be changed by methods that are attached to following events. Also, the views will not get rendered over and over when casted to a string. } // Request::instance()->response will now contain the page-html // A row of Events that are now executed in order // Add content to response Event::instance('wi3.afterexecution.addcontent.css.first')->execute(); // Add css Event::instance('wi3.afterexecution.addcontent.css.second')->execute();
<?php // Dependencies Wi3::inst()->plugins->load("plugin_jquery_wi3"); $this->css("style.css"); // Publish an array as JS object on the frontend $results = array("pages" => array(), "articles" => array()); foreach ($pages as $index => $page) { $results["pages"][] = array("title" => $page->longtitle, "text" => "", "url" => Wi3::instance()->urlof->page($page)); } foreach ($articles as $index => $article) { if (isset($article->title) && isset($article->summary) && isset($article->pageurl)) { $results["articles"][] = array("title" => $article->title, "text" => $article->summary, "url" => $article->pageurl); } } $this->javascriptObject("wi3.pagefiller.default.simpleblogsearch.searchdata", $results); $this->javascript("js.js"); ?> <input class='wi3_pagefiller_default_component_simpleblogsearch' placeholder='zoeken'></input> <div style='background: #fff; max-width: 200px;'> <div class='wi3_pagefiller_default_component_simpleblogsearch_result'> ... </div> </div>