Example #1
0
 public function oauthReturn(GithubService $api, VariableMap $variableMap, Session $session, SessionBasedOauth $sessionBasedOauth)
 {
     $code = $variableMap->getVariable('code', false);
     $state = $variableMap->getVariable('state', false);
     $oauthUnguessable = $session->getSessionVariable('oauthUnguessable', null);
     if (!$code || !$state || !$oauthUnguessable) {
         $errorContext = OauthErrorContext::create("Missing data: '{$code}' '{$state}' '{$oauthUnguessable}'");
         return JigExecutable::createWithSharedObjects("pages/oauth/error", [$errorContext]);
     }
     if ($state !== $oauthUnguessable) {
         //Miss-match on what we're tring to validated.
         $errorContext = OauthErrorContext::create("Mismatch on secret'");
         return JigExecutable::createWithSharedObjects("pages/oauth/error", [$errorContext]);
     }
     try {
         $oauthOperation = $api->getOauthAuthorization(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, $code, $oauthUnguessable);
         $oauthOperation->setRedirect_uri("http://" . SERVER_HOSTNAME . "/oauthReturn");
         $accessResponse = $oauthOperation->execute();
         $session->setSessionVariable(GITHUB_ACCESS_RESPONSE_KEY, $accessResponse);
         $authToken = new Oauth2Token($accessResponse->accessToken);
         $sessionBasedOauth->save($authToken);
         $oauthSuccessContext = OauthSuccessContext::create($accessResponse);
         return JigExecutable::createWithSharedObjects("pages/oauth/success", [$oauthSuccessContext]);
     } catch (GithubArtaxServiceException $fae) {
         $errorContext = OauthErrorContext::create($fae->getMessage());
         return JigExecutable::createWithSharedObjects("pages/oauth/error", [$errorContext]);
     }
 }
Example #2
0
 public function __construct(\ImagickDemo\ImagickKernel\Control\usage $usageControl, VariableMap $variableMap)
 {
     $this->usageControl = $usageControl;
     $this->morphologyType = $variableMap->getVariable('morphologyType', \Imagick::MORPHOLOGY_EDGE_IN);
     parent::__construct($usageControl);
     $this->functionTable = [\Imagick::MORPHOLOGY_CONVOLVE => "renderConvolve", \Imagick::MORPHOLOGY_CORRELATE => "renderCorrelate", \Imagick::MORPHOLOGY_ERODE => "renderErode", \Imagick::MORPHOLOGY_DILATE => "renderDilate", \Imagick::MORPHOLOGY_ERODE_INTENSITY => "renderErodeIntensity", \Imagick::MORPHOLOGY_DILATE_INTENSITY => "renderDilateIntensity", \Imagick::MORPHOLOGY_DISTANCE => "renderDistance", \Imagick::MORPHOLOGY_DISTANCE . "Chebyshev" => "renderDistanceChebyshev", \Imagick::MORPHOLOGY_DISTANCE . "Manhattan" => "renderDistanceManhattan", \Imagick::MORPHOLOGY_DISTANCE . "Octagonal" => "renderDistanceOctagonal", \Imagick::MORPHOLOGY_DISTANCE . "Euclidian" => "renderDistanceEuclidian", \Imagick::MORPHOLOGY_ITERATIVE => "renderDistanceIterative", \Imagick::MORPHOLOGY_OPEN => "renderOpen", \Imagick::MORPHOLOGY_CLOSE => "renderClose", \Imagick::MORPHOLOGY_OPEN_INTENSITY => "renderOpenIntensity", \Imagick::MORPHOLOGY_CLOSE_INTENSITY => "renderCloseIntensity", \Imagick::MORPHOLOGY_SMOOTH => "renderSmooth", \Imagick::MORPHOLOGY_EDGE_IN => "renderEdgeIn", \Imagick::MORPHOLOGY_EDGE_OUT => "renderEdgeOut", \Imagick::MORPHOLOGY_EDGE => "renderEdge", \Imagick::MORPHOLOGY_TOP_HAT => "renderTopHat", \Imagick::MORPHOLOGY_BOTTOM_HAT => "renderBottomHat", \Imagick::MORPHOLOGY_HIT_AND_MISS => "renderHitAndMiss", \Imagick::MORPHOLOGY_THINNING => "renderThinning", \Imagick::MORPHOLOGY_THICKEN . "Standard" => "renderThicken", \Imagick::MORPHOLOGY_THICKEN . "Convex" => "renderThickenConvexHull"];
 }
 public function __construct(VariableMap $variableMap)
 {
     $elements = $this->kernelMatrixSize;
     for ($i = 0; $i < $elements; $i++) {
         $name = 'kernelMatrix_' . $i;
         $newValue = $variableMap->getVariable($name, $this->kernelMatrix[$i]);
         $newValue = floatval($newValue);
         $this->kernelMatrix[$i] = $newValue;
     }
 }
Example #4
0
 public function __construct(VariableMap $variableMap)
 {
     $this->h20 = $variableMap->getVariable(self::H20_NAME, $this->h20);
     $this->h20 = intval($this->h20);
     if ($this->h20 < 0) {
         $this->h20 = 0;
     }
     if ($this->h20 > 20) {
         $this->h20 = 20;
     }
 }
 public function __construct(VariableMap $variableMap)
 {
     $this->key = $this->getDefault();
     $newKey = $variableMap->getVariable($this->getVariableName(), $this->key);
     foreach ($this->getOptions() as $key => $value) {
         if (strcmp($newKey, $key) === 0) {
             $this->key = $key;
             $this->value = $value;
             break;
         }
     }
 }
Example #6
0
 public function notepad(TierJig $tierJig, VariableMap $variableMap, Session $session)
 {
     $data = $session->getData();
     $value = $variableMap->getVariable('data', false);
     if ($value !== false && strlen(trim($value)) != 0) {
         $data[] = $value;
         $session->setData($data);
     }
     $value = $variableMap->getVariable('submit', false);
     if ($value !== false && strcmp($value, "Clear") === 0) {
         $session->setData([]);
     }
     $session->save();
     return $tierJig->createJigExecutable('pages/notepad');
 }
 public function __construct(VariableMap $variableMap)
 {
     $value = $this->getDefault();
     $nextColor = $variableMap->getVariable($this->getVariableName(), $value);
     try {
         new \ImagickPixel($nextColor);
         //This code is only reached if ImagePixel parses the color
         //and thinks it is valid
         $value = $nextColor;
     } catch (\Exception $e) {
         //$this->errors[] = "Color '$nextColor' for $colorType was not valid.";
         //TODO Add error message
     }
     $this->value = $value;
     //zendcode eats braces
 }
 public function __construct(VariableMap $variableMap)
 {
     $value = $this->getDefault();
     $newValue = $variableMap->getVariable($this->getVariableName(), $value);
     $options = $this->getOptions();
     foreach ($options as $optionKey => $optionValue) {
         if ($value === $optionValue) {
             $this->key = $optionKey;
             $this->value = $value;
         }
     }
     $needle = array_search($newValue, $options);
     if ($needle !== false) {
         $this->key = $needle;
         $this->value = $newValue;
     }
     if (array_key_exists($newValue, $options)) {
         $this->key = $newValue;
         $this->value = $options[$newValue];
     }
 }
 public function __construct(VariableMap $variableMap)
 {
     $value = $this->getDefault();
     if ($value !== false) {
         if ($this->getDefault() > $this->getMax()) {
             trigger_error("Default is bigger than max in " . get_class($this) . ", someone has dun goofed", E_USER_NOTICE);
         }
         if ($this->getDefault() < $this->getMin()) {
             trigger_error("Default is smaller than min in " . get_class($this) . ", someone has dun goofed", E_USER_NOTICE);
         }
     }
     $value = $variableMap->getVariable($this->getVariableName(), $value);
     $value = $this->filterValue($value);
     if ($value !== false && strlen(trim($value)) != 0) {
         if ($value < $this->getMin()) {
             $value = $this->getMin();
         }
         if ($value > $this->getMax()) {
             $value = $this->getMax();
         }
     }
     $this->value = $this->filterValue($value);
 }
Example #10
0
 public static function createImageTask(VariableMap $variableMap, ImagickTaskQueue $taskQueue, PageInfo $pageInfo, Request $request, HeadersSet $headersSet, $customImage, $params)
 {
     $job = $variableMap->getVariable('job', false);
     $text = "Image is still generating.";
     if ($job === false) {
         if ($taskQueue->isActive() == false) {
             //Queue isn't active - don't bother queueing a task
             return false;
         }
         $task = new \ImagickDemo\Queue\ImagickTask($pageInfo, $params, $customImage, $request->getUri()->getPath());
         $added = $taskQueue->addTask($task);
         if ($added === true) {
             $text = "Image added to task list";
         } else {
             $text = "Image task {$added} already present.";
         }
     }
     $caching = new \Room11\Caching\LastModified\Disabled();
     foreach ($caching->getHeaders(time()) as $key => $value) {
         $headersSet->addHeader($key, $value);
     }
     return new TextBody($text, 420);
 }
Example #11
0
 public function __construct(CompositeExampleControl $compositeExampleControl, VariableMap $variableMap)
 {
     $this->compositeExampleControl = $compositeExampleControl;
     $this->type = $variableMap->getVariable('type', self::SOURCE_1);
 }
 public function __construct(\ImagickDemo\Control $control, VariableMap $variableMap)
 {
     $this->control = $control;
     $this->deconstruct = $variableMap->getVariable('deconstruct', false);
 }
 public function __construct(VariableMap $variableMap)
 {
     $this->loadedFiles = $variableMap->getVariable('filesOnly', false);
 }
 public function __construct(\ImagickDemo\Control $control, VariableMap $variableMap)
 {
     $this->control = $control;
     $this->firstLayer = $variableMap->getVariable('firstLayer', 0);
 }