public function perform($unconsumed_path) { //$this->setupAutoload(); $dispatcher = new Trails_Dispatcher($this->getPluginPath(), rtrim(PluginEngine::getLink($this, array(), null), '/'), 'show'); $dispatcher->plugin = $this; $dispatcher->dispatch($unconsumed_path); }
function perform($unconsumed_path) { $trails_root = $this->getPluginPath() . "/app"; $dispatcher = new Trails_Dispatcher($trails_root, rtrim(PluginEngine::getURL($this, null, ''), '/'), self::DEFAULT_CONTROLLER); $dispatcher->plugin = $this; $dispatcher->dispatch($unconsumed_path); }
/** * This method dispatches and displays all actions. It uses the template * method design pattern, so you may want to implement the methods #route * and/or #display to adapt to your needs. * * @param string the part of the dispatch path, that were not consumed yet * * @return void */ function perform($unconsumed_path) { if (!$unconsumed_path) { header("Location: " . PluginEngine::getUrl($this), 302); return false; } $trails_root = $this->getPluginPath(); $dispatcher = new Trails_Dispatcher($trails_root, null, 'show'); $dispatcher->current_plugin = $this; $dispatcher->dispatch($unconsumed_path); }
/** * Create a new Trails_Dispatcher with Stud.IP specific parameters * for: trails_root is "$STUDIP_BASE_PATH/app", trails_uri is * "dispatch.php" and default_controller is "default" (which does * not map to anything). */ public function __construct() { global $STUDIP_BASE_PATH, $ABSOLUTE_URI_STUDIP; $trails_root = $STUDIP_BASE_PATH . DIRECTORY_SEPARATOR . 'app'; $trails_uri = rtrim($ABSOLUTE_URI_STUDIP, '/') . '/dispatch.php'; $default_controller = 'default'; parent::__construct($trails_root, $trails_uri, $default_controller); }
function run($commands) { $name = array_shift($commands); $path = sprintf('%s/%s/%s_generator.php', dirname(__FILE__), $name, $name); $klass = Trails_Dispatcher::camelize($name) . 'Generator'; if (!file_exists($path)) { printf("\n" . " You must supply a valid generator as the first command.\n\n" . " Available generators are:\n\n" . " %s\n\n", join("\n ", Trails_Generator::get_generators())); return; } require_once $path; $generator =& new $klass($path, $commands); if (!sizeof($commands)) { echo $generator->usage(); return; } $generator->manifest(); printf("%s\n", join("\n", $generator->log)); }
# furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. error_reporting(E_ALL); # define root $trails_root = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'app'; $trails_uri = sprintf('http%s://%s%s%s', isset($_SERVER['HTTPS']) ? 's' : '', $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT'], $_SERVER['SCRIPT_NAME']); # load trails # require_once $trails_root . '/../vendor/trails/trails-unabridged.php'; require_once $trails_root . '/../vendor/trails/src/dispatcher.php'; require_once $trails_root . '/../vendor/trails/src/response.php'; require_once $trails_root . '/../vendor/trails/src/controller.php'; require_once $trails_root . '/../vendor/trails/src/inflector.php'; require_once $trails_root . '/../vendor/trails/src/flash.php'; require_once $trails_root . '/../vendor/trails/src/exception.php'; # load flexi require_once $trails_root . '/../vendor/flexi/lib/flexi.php'; # dispatch $request_uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '/'; $default_controller = 'example'; $dispatcher = new Trails_Dispatcher($trails_root, $trails_uri, $default_controller); $dispatcher->dispatch($request_uri);
function perform($unconsumed_path) { $dispatcher = new Trails_Dispatcher($this->getPluginPath() . '/app', rtrim(PluginEngine::getLink($this, array(), null), '/'), 'generator'); $dispatcher->plugin = $this; $dispatcher->dispatch($unconsumed_path); }
<?php echo '<?php'; ?> class <?php echo Trails_Dispatcher::camelize($controller); ?> Controller extends Trails_Controller { <?php foreach ($actions as $action) { ?> function <?php echo $action; ?> _action() { } <?php } ?> }
/** * This method dispatches all actions. * * @param string part of the dispatch path that was not consumed * * @return void */ public function perform($unconsumed_path) { $args = explode('/', $unconsumed_path); $action = $args[0] !== '' ? array_shift($args) . '_action' : 'show_action'; if (!method_exists($this, $action)) { $trails_root = $this->getPluginPath(); $trails_uri = rtrim(PluginEngine::getLink($this, array(), null, true), '/'); $dispatcher = new Trails_Dispatcher($trails_root, $trails_uri, 'index'); $dispatcher->current_plugin = $this; try { $dispatcher->dispatch($unconsumed_path); } catch (Trails_UnknownAction $exception) { if (count($args) > 0) { throw $exception; } else { throw new Exception(_('unbekannte Plugin-Aktion: ') . $unconsumed_path); } } } else { call_user_func_array(array($this, $action), $args); } }
/** * **/ public function perform($unconsumed_path) { $dispatcher = new Trails_Dispatcher($this->getPluginPath() . DIRECTORY_SEPARATOR . 'app', rtrim(PluginEngine::getLink($this, array(), null), '/'), 'admin'); $dispatcher->plugin = $this; $dispatcher->dispatch($unconsumed_path); }