public function testGetClassname() { $mock = m::mock('Project'); $this->assertNotEquals('Project', get_class($mock)); $this->assertEquals('Project', get_classname($mock)); $mockNamespace = m::mock('Sub\\Task'); $this->assertNotEquals('Sub\\Task', get_class($mockNamespace)); $this->assertEquals('Sub\\Task', get_classname($mockNamespace)); }
function parse_class_string($class_string) { $c = explode(",", $class_string); sort($c); $translated_classes = array(); // make classes into nice words foreach ($c as $class) { array_push($translated_classes, get_classname($class)); } return $translated_classes; }
public function __construct($args = null) { $args = is_array($args) ? $args : func_get_args(); if (count($args) < 2) { $args = array_merge($args, [null]); } list($this->dir, $this->path) = $args; $this->dir = $this->normalizePath($this->dir); $this->path = $this->normalizePath($this->path); $basePath = $this->normalizePath(base_path()); // Windows support: Convert backslash to slash // Expand paths if ($this->dir) { $this->dir = $this->normalizePath(realpath($this->dir)); } if ($this->path) { $this->path = $this->normalizePath(realpath($this->path)); } // If path is given as the second arg if ($this->dir && File::extension($this->dir) != "") { list($this->dir, $this->path) = [null, $this->dir]; } // Default dir to the directory of the path if ($this->path) { $this->dir = $this->dir ?: dirname($this->path); } // If directory is given w/o path, pick a random manifest.json location if ($this->dir && !$this->path) { // Find the first manifest.json in the directory $paths = find_paths($this->dir . "/manifest*.json"); if (!empty($paths)) { $this->path = head($paths); } else { $this->path = $this->dir . "/manifest-" . md5(uniqid(mt_rand(), true)) . ".json"; } } if (!$this->dir && !$this->path) { throw new Exception("manifest requires output path", 1); } $data = []; try { if (File::exists($this->path)) { // \Log::info("Load manifest !");//debug $data = json_decode(File::get($this->path), true); } } catch (Exception $e) { \Log::error($this->path . " is invalid: " . get_classname($e) . " " . $e->getMessage()); } $this->data = $data; }
protected function getNamespacedName() { $namespaceName = null; $namespace = $this->getNamespace(); if (!empty($namespace)) { $namespaceName = studly_case(str_singular(implode("\\", array_flatten([$namespace, studly_case($this->getName())])))); } if (class_exists($namespaceName)) { return $namespaceName; } $className = studly_case($this->getName()); if (class_exists($className)) { // Support Laravel Alias $aliasLoader = \Illuminate\Foundation\AliasLoader::getInstance(); $aliasName = array_get($aliasLoader->getAliases(), $className); return class_exists($aliasName) ? $aliasName : $className; } $controllerNamespaces = $this->getNamespace(get_classname($this->controller)); // Detect the Root Namespace, based on the current controller namespace // And test if the resource class exists with it // Borrowed from: https://github.com/laravel/framework/blob/v5.0.13/src/Illuminate/Routing/UrlGenerator.php#L526 if (!empty($controllerNamespaces) && !(strpos($className, '\\') === 0)) { $rootNamespace = head($controllerNamespaces); $guessName = $rootNamespace . '\\' . $className; if (class_exists($guessName)) { return $guessName; } } return $this->getName(); }
/** * Fill the $params property of the given Controller * * @param \Illuminate\Routing\Controller $controller */ public function fillController($controller) { $router = app('router'); $controllerClass = get_classname($controller); $paramsFilterPrefix = "router.filter: "; $paramsFilterName = "controller.parameters." . $controllerClass; if (!Event::hasListeners($paramsFilterPrefix . $paramsFilterName)) { Event::listen($paramsFilterPrefix . $paramsFilterName, function () use($controller, $router) { $currentRoute = $router->current(); $resourceParams = []; list($resourceParams['controller'], $resourceParams['action']) = explode('@', $router->currentRouteAction()); $resourceParams['controller'] = $this->normalizeControllerName($resourceParams['controller']); $resourceId = str_singular($resourceParams['controller']); if (request()->has($resourceId)) { $params = request()->all(); } else { $specialInputKeys = $this->specialInputKeys(); $params = [$resourceId => request()->except($specialInputKeys)] + request()->only($specialInputKeys); } $routeParams = $currentRoute->parametersWithoutNulls(); // In Laravel, unlike Rails, by default 'id' parameter of a 'Product' resource is 'products' // And 'shop_id' parameter of a 'Shop' parent resource is 'shops' // So we need to reaffect correct parameter name before any controller's actions or filters. $routeParamsParsed = []; $keysToRemove = []; $lastRouteParamKey = last(array_keys($routeParams)); if ($lastRouteParamKey === 'id' || $resourceId === str_singular($lastRouteParamKey)) { $id = last($routeParams); if (is_a($id, 'Illuminate\\Database\\Eloquent\\Model')) { $id = $id->getKey(); } if (is_string($id) || is_numeric($id)) { array_pop($routeParams); $routeParamsParsed['id'] = $id; } } foreach ($routeParams as $parentIdKey => $parentIdValue) { if (is_a($parentIdValue, 'Illuminate\\Database\\Eloquent\\Model')) { $parentIdValue = $parentIdValue->getKey(); } if (is_string($parentIdValue) || is_numeric($parentIdValue)) { if (!ends_with($parentIdKey, '_id')) { $parentIdKey = str_singular($parentIdKey) . '_id'; } $routeParamsParsed[$parentIdKey] = $parentIdValue; $keysToRemove[] = $parentIdKey; } } $routeParams = array_except($routeParams, $keysToRemove); /** * You can escape or purify these parameters. For example: * * class ProductsController extends Controller * { * public function __construct() * { * $self = $this; * $this->beforeFilter(function () use($self) { * if (array_get($self->params, 'product')) { * $productParams = $this->yourPurifyOrEscapeMethod('product'); * $self->params['product'] = $productParams; * } * }); * } * } * */ $this->params = array_filter(array_merge($params, $routeParams, $routeParamsParsed, $resourceParams)); if (property_exists($controller, 'params')) { set_property($controller, 'params', $this->params); } else { $controller->params = $this->params; } }); $controller->paramsBeforeFilter($paramsFilterName); } }
//print_r($all_classes); $not_in = array(); foreach ($all_classes as $c) { if (!in_array($c, $classes)) { array_push($not_in, $c); } } //print_r($not_in); $select = "<select name='notin[]' id='notin' multiple='multiple'>"; foreach ($not_in as $c) { $c2 = get_classname($c); $select .= "<option value='{$c}'>{$c2}</option>"; } $select .= "</select>"; foreach ($classes as $class) { $c2 = get_classname($class); $table .= "<tr><td align='center'><input type='checkbox' name='check[]' value='{$class}'></td><td>{$c2}</td></tr>"; } $table .= "</table>"; $maintable = "<table border='0'><th>Currently Enrolled Classes</th><th>Add Classes</th><tr><td>{$table}</td>"; $maintable .= "<td>{$select}</td></tr></table>"; $form_head = "<form action='editdb.php' method='POST'>"; $button = "<p><input type='submit' name='submit2' value='Submit'>"; $hidden = "<input type='text' name='qstring' value='{$class_string}' hidden='hidden'>"; $hidden2 = "<input type='text' name='registerid' value='{$registerid}' hidden='hidden'>"; echo generatePage($header . $form_head . $hidden . $hidden2 . $maintable . $button . "</form>", "Edit Page"); } else { // Draw table $body = ""; $query = "SELECT r.registerid, r.fname, r.lname, r.partnerfname, r.email, c.classes\n FROM records r, classes c, confirmation f\n WHERE r.registerid = c.registerid and r.registerid = f.registerid and\n f.payment_status = 'Completed'"; try {
public function authorize($action, $resource, $args = null) { $args = is_array($args) ? $args : array_slice(func_get_args(), 2); $message = null; $options = array_extract_options($args); if (is_array($options) && array_key_exists('message', $options)) { $message = $options['message']; } elseif (is_array($args) && array_key_exists(0, $args)) { list($message) = $args; unset($args[0]); } if ($this->cannot($action, $resource, $args)) { $resourceClass = $resource; if (is_object($resourceClass)) { $resourceClass = get_classname($resourceClass); } elseif (is_array($resourceClass)) { $resourceClass = head(array_values($resourceClass)); if (is_object($resourceClass)) { $resourceClass = get_classname($resourceClass); } } $message = $message ?: $this->getUnauthorizedMessage($action, $resourceClass); throw new Exceptions\AccessDenied($message, $action, $resourceClass); } return $resource; }
/** * @return mixed */ protected function getName() { return preg_replace("/^DetectCurrent/u", "", get_classname($this->detector)); }
protected function mockController($controllerName = null) { $controllerName = $controllerName ?: $this->controllerName; $this->router = $this->app['router']; $events = $this->getProperty($this->router, 'events'); $this->setProperty($this->router, 'events', $events); $this->app['router'] = $this->router; $this->mock($controllerName); $controllerInstance = $this->app->make($controllerName); $controllerInstance->shouldReceive('paramsBeforeFilter')->with(m::type('string'))->once(); $controllerInstance->shouldReceive('getBeforeFilters')->once()->andReturn([['original' => null, 'filter' => null, 'parameters' => [], 'options' => []]]); $controllerInstance->shouldReceive('getAfterFilters')->once()->andReturn([['original' => null, 'filter' => null, 'parameters' => [], 'options' => []]]); $controllerInstance->shouldReceive('getMiddleware')->once()->andReturn([]); $controllerInstance->shouldReceive('callAction')->with(m::type('string'), m::type('array'))->andReturnUsing(function ($method, $parameters) use($controllerInstance) { $this->app->make('Params')->fillController($controllerInstance); $filterName = "router.filter: controller.parameters." . get_classname($controllerInstance); $this->assertTrue(Event::hasListeners($filterName)); Event::fire($filterName); return new \Symfony\Component\HttpFoundation\Response(); }); $this->mock('\\Efficiently\\AuthorityController\\ControllerResource'); $this->controllerResource = $this->app->make('\\Efficiently\\AuthorityController\\ControllerResource'); $this->controllerResource->shouldReceive('getNameByController')->with('ProjectsController')->andReturn('project'); return $controllerInstance; }
<?php require_once "support.php"; require_once "dbLogin.php"; require_once "sqlconnector.php"; require_once "fileEditor.php"; require_once "closed.php"; require_once "classMapping.php"; echo "<h1>Class Balance Info</h1>"; //echo drawTable($result); $new_list = array(); for ($i = 0; $i < 34; $i++) { if (in_array($i, array_keys($master_class_list))) { $lf = $master_class_list[$i]; //echo get_classname($i).": [L ".$lf["LEADER"].", F: ".$lf["FOLLOWER"]."]<br>"; $new_list[get_classname($i)] = array("LEADER" => $lf["LEADER"], "FOLLOWER" => $lf["FOLLOWER"]); } } $table = "<table border=\"1\">"; $table .= "<th>Class</th><th>Leaders</th><th>Followers</th><th>Total</th><th>Balance (L - F)</th>"; foreach ($new_list as $class => $status) { $table .= "<tr><td><strong>{$class}</strong></td>"; $table .= "<td>" . $status['LEADER'] . "</td><td>" . $status['FOLLOWER'] . "</td>"; $table .= "<td>" . ($status['LEADER'] + $status["FOLLOWER"]) . "</td>"; $table .= "<td>" . ($status['LEADER'] - $status["FOLLOWER"]) . "</td></tr>"; } echo $table;
include "../app/class/classmanager.php"; include "../app/student/studentmanager.php"; include "../app/report/reportmanager.php"; $class_id = 0; if (isset($_GET['id'])) { $class_id = $_GET['id']; } else { if (isset($_POST['id'])) { $class_id = $_POST['id']; } } $game_type = "memory"; $game_difficulty = "easy"; //$memory_easy_class = get_class_average($class_id,"memory","easy"); //$memory_easy_students = get_all_students_averages($class_id,"memory","easy"); $classname = get_classname($class_id); function printTable($class_id, $game_type, $game_difficulty) { $classAverage = get_class_average($class_id, $game_type, $game_difficulty); $studentAverage = get_all_students_averages($class_id, $game_type, $game_difficulty); $i = 1; foreach ($studentAverage as $student) { //echo "test"; echo '<tr> <td>' . $i . '</td> <td>' . $student["first_name"] . ' ' . $student["last_name"] . '</td> <td><span '; if ($student["AVG(score)"] <= $classAverage) { echo 'class="badge bg-red"'; } else { echo 'class="badge bg-green"';