예제 #1
0
 /** @before */
 public function PrepareSurfaceEnv()
 {
     /*//
     	dump some settings into the option manager to temper the surface
     	instances we create for testing. forcing a few defaults that i
     	want to test against just incase the defaults change a little
     	in the future.
     	//*/
     Nether\Option::Set(['nether-web-root' => dirname(dirname(__FILE__)), 'nether-web-path' => '/', 'surface-theme' => 'testing', 'surface-theme-stack' => ['common'], 'surface-auto-capture' => false, 'surface-auto-render' => false]);
     return;
 }
예제 #2
0
파일: Client.php 프로젝트: dmanetwork/slack
 public function GetChannelFromList($key)
 {
     /*//
     	@argv string ChannelKey
     	@return string
     	fetch a channel by action key from the configuration. if the channel was
     	not found then the default channel is returned.
     	//*/
     $channels = Nether\Option::Get('slack-channels');
     if (array_key_exists($key, $channels)) {
         return $channels[$key];
     } else {
         return $this->DefaultChannel;
     }
 }
예제 #3
0
 public function __construct()
 {
     $this->Driver = new \Memcached();
     $pool = Nether\Option::Get('cache-memcache-pool');
     /*//todo/
     		log instead of throw exception.
     		//*/
     if (!is_array($pool)) {
         throw new \Exception('cache-memcache-pool is not an array');
     }
     foreach ($pool as $server) {
         $this->AddServer($server);
     }
     return;
 }
예제 #4
0
파일: Ki.php 프로젝트: netherphp/ki
 static function Log($key, $ki, $argv)
 {
     if (!Nether\Option::Get('nether-ki-log')) {
         return;
     }
     if ($ki) {
         $types = [];
         foreach ($argv as $arg) {
             $type[] = gettype($arg);
         }
         self::$Log[] = sprintf('%s %s(%s)', $key, $ki->Alias, count($types) ? join(',', $types) : 'void');
     } else {
         self::$Log[] = "{$key}";
     }
 }
예제 #5
0
 public function __Construct($DB = null)
 {
     if ($DB) {
         $this->Database = $DB;
     }
     $this->Compiler = Nether\Option::Get('nether-database-verse-compiler');
     $this->ResetQueryProperties();
     return;
 }
예제 #6
0
 public function Query($Format, $Argv = false)
 {
     /*//
     	@return Nether\Database\Result
     	//*/
     if ($Argv && !is_array($Argv) && !is_object($Argv)) {
         throw new Nether\Database\Error\InvalidQueryInput();
     }
     // convert to an object if not an object. this would theoretically
     // allow you to supply objects with magic methods.
     if (!is_object($Argv)) {
         $Argv = (object) $Argv;
     }
     ////////
     // build a dataset that directly maps to the bound parameters in the
     // query with no unused values.
     $SQL = is_object($Format) ? "{$Format}" : $Format;
     $Dataset = [];
     $this->Query_BuildDataset($SQL, $Argv, $Dataset);
     $this->Query_ExpandDataset($SQL, $Argv, $Dataset);
     ////////
     // and then perform the query.
     $QueryTime = microtime(true);
     if (!($Statement = $this->Driver->Prepare($SQL))) {
         throw new Nether\Database\Error\QueryPrepareFailure();
     }
     $Result = new Database\Result($this, $Statement, $Dataset);
     if (Nether\Option::Get('nether-database-query-log')) {
         static::$QueryLog[] = (object) ['Time' => round($Result->GetTime(), 4), 'Query' => $Result->GetQuery(), 'Input' => $Result->GetArgs(), 'Count' => $Result->GetCount(), 'Trace' => static::GetDebugTrace()];
     }
     static::$QueryTime += microtime(true) - $QueryTime;
     static::$QueryCount++;
     return $Result;
 }
예제 #7
0
 public function __Construct(string $ConfigName = null)
 {
     /*//
     	given a configuration name will attempt to load it from disk. else it will
     	generate a fresh config object with default settings.
     	//*/
     $Dataset = null;
     $Options = ['ForceDefaultValues' => true];
     if ($ConfigName) {
         try {
             $Dataset = $this->Read($ConfigName);
         } catch (Exception $Error) {
             throw $Error;
         }
     }
     if ($Dataset) {
         $Options['ForceDefaultValues'] = false;
     }
     ////////
     parent::__Construct($Dataset, ['Delay' => Nether\Option::Get('Delay'), 'LastIter' => 1, 'LastURL' => '', 'QueryDownload' => '', 'QueryDownloadAttr' => '', 'QueryNext' => '', 'QueryNextAttr' => '', 'SaveDir' => Nether\Option::Get('SaveDir'), 'SaveFile' => '', 'StartURL' => '', 'PadFileNums' => 0, 'TransformDownload' => [], 'TransformNext' => [], 'UserAgent' => Nether\Option::Get('UserAgent'), 'Verbose' => true], $Options);
     ////////
     if (is_string($this->TransformDownload)) {
         $this->TransformDownload = [$this->TransformDownload];
     }
     if (is_string($this->TransformNext)) {
         $this->TransformNext = [$this->TransformNext];
     }
     return;
 }
예제 #8
0
 public function GetThemeURI($input)
 {
     /*//
     	@argv string Input
     	@return string
     	prints or returns the string at the end of the surface uri. useful for
     	linking to theme resources. accepts theme stacking to the point where
     	you can overload the theme, but we will not test that the file exists
     	in this case, so it will just be from the top of the stack.
     	//*/
     $stack = explode(':', $input);
     $file = array_pop($stack);
     $stack = $this->GetThemeStack($stack);
     return sprintf('/%s/%s/%s', trim(Option::Get('surface-theme-path'), '/'), $stack[0], $file);
 }
예제 #9
0
 public function Render($return = false)
 {
     /*//
     	@return boolean
     	begin the rendering operation using the full page template.
     	//*/
     // flag this as called.
     $this->Rendered = true;
     // fetch whatever is still hanging on in the buffer.
     $this->Stop(true);
     // check if we had decided on a theme yet.
     if (!$this->Theme) {
         $this->Theme = Nether\Option::Get('surface-theme');
     }
     // determine the template file to use.
     if (!($template = $this->GetThemeFile('design.phtml'))) {
         throw new Exception("error opening {$template} for {$this->Theme}");
     }
     // run through the framework settings to generate some common meta data
     // like page title if the data hasn't already been defined.
     $this->PrepareTitle();
     $this->PrepareKeywords();
     $this->PrepareDescription();
     ////////
     ////////
     ob_start();
     call_user_func(function ($__filename, $__scope) {
         extract($__scope);
         unset($__scope);
         require $__filename;
     }, $template, $this->GetRenderScope());
     if (!$return) {
         // print it out if we didn't want it back.
         echo ob_get_clean();
         return;
     } else {
         // hand it back if we wanted it.
         return ob_get_clean();
     }
 }
예제 #10
0
파일: Router.php 프로젝트: netherphp/avenue
 public function TranslateRouteCondition($cond)
 {
     /*//
     	return(string)
     	//*/
     foreach (Nether\Option::Get('nether-avenue-condition-shortcuts') as $old => $new) {
         $cond = str_replace($old, $new, $cond);
     }
     return $cond;
 }
예제 #11
0
파일: Cache.php 프로젝트: netherphp/cache
 protected function GetFullKey($key)
 {
     /*//
     	@argv string Key
     	prepend the defined cache-key-prefix to the requested key so that the data
     	stores can prevent collisions if a single memcache is running multiple
     	applications, or something like that.
     	//*/
     return sprintf('%s-%s', Nether\Option::Get('cache-key-prefix'), $key);
 }
예제 #12
0
파일: Cache.php 프로젝트: netherphp/cache
 public function GetStats($use = null)
 {
     /*//
     	@return array
     	returns an object with the hit/miss statistics of the cache.
     	//*/
     if (!$use) {
         $use = Option::Get('cache-drivers-use');
     }
     $hit = 0;
     $miss = 0;
     foreach ($use as $dkey) {
         if (!array_key_exists($dkey, $this->Drivers)) {
             continue;
         }
         $hit += $this->Drivers[$dkey]->GetHitCount();
         $miss += $this->Drivers[$dkey]->GetMissCount();
     }
     return (object) ['HitCount' => $this->HitCount, 'MissCount' => $this->MissCount, 'QueryCount' => $this->HitCount + $this->MissCount, 'ConnectTime' => 0, 'QueryTime' => 0];
 }
예제 #13
0
 public function __construct()
 {
     $this->SetPath(Nether\Option::Get('cache-diskcache-path'));
     return;
 }
예제 #14
0
 public function testRouteConditionTranslation()
 {
     /*//
     	test that the shortcuts translate as expected.
     	//*/
     $router = new Nether\Avenue\Router(static::$RequestData['Test']);
     foreach (Nether\Option::Get('nether-avenue-condition-shortcuts') as $old => $new) {
         (new Verify("pattern {$old} translates as expected.", $router->TranslateRouteCondition($old)))->equals($new);
     }
     return;
 }