/**
  * Tests Manager->remove()
  */
 public function testRemove()
 {
     $this->Manager->set(__NAMESPACE__ . __CLASS__ . __FUNCTION__ . 'MyVar', true);
     $this->assertTrue($this->Manager->has(__NAMESPACE__ . __CLASS__ . __FUNCTION__ . 'MyVar'));
     $this->Manager->remove(__NAMESPACE__ . __CLASS__ . __FUNCTION__ . 'MyVar');
     $this->assertFalse($this->Manager->has(__NAMESPACE__ . __CLASS__ . __FUNCTION__ . 'MyVar'));
 }
Example #2
0
File: Cache.php Project: cti/di
 /**
  * get unique key for given parameters
  * @param string $method
  * @param array $arguments
  * @return string
  */
 protected function getKey($method, $arguments)
 {
     if (is_null($this->useHash)) {
         $this->useHash = $this->manager->getConfiguration()->get(__CLASS__, 'useHash', false);
     }
     $key = $method . '(' . implode(', ', $arguments) . ')';
     return $this->useHash ? md5($key) : $key;
 }
Example #3
0
File: Callback.php Project: cti/di
 /**
  * @param string $class
  * @param string $method
  */
 function __construct(Manager $manager, $class, $method)
 {
     $this->class = $class;
     $this->method = $method;
     $inspector = $manager->get('Cti\\Di\\Inspector');
     $this->arguments = $inspector->getMethodArguments($class, $method);
     $this->requiredCount = $inspector->getMethodRequiredCount($class, $method);
 }
 public function testGeneral()
 {
     $sass = new Manager();
     $sass->compile('body{background-color: $red}', ['red' => '#ff0000'], [], []);
     $tempFile = KENDO_TEMP_DIR . '/test/unitest.css';
     $sass->compileToFile($tempFile, 'default', 'default', ['red' => '#ff0000'], 'body{background: $red;}');
     $this->assertNotEmpty(file_get_contents($tempFile));
 }
Example #5
0
 public function testInitInvalidHandler()
 {
     $handlerConfig = ['class' => 'Migration\\Migration', 'params' => ['value' => '12']];
     $invalidHandler = $this->getMock('Migration\\Migration', [], [], '', false);
     $this->objectManager->expects($this->once())->method('create')->will($this->returnValue($invalidHandler));
     $this->setExpectedException('\\Exception', "'Migration\\Migration' is not correct handler.");
     $this->manager->initHandler('somefield', $handlerConfig);
 }
Example #6
0
 /**
  * @param $signal
  */
 public function catchSignal($signal)
 {
     switch ($signal) {
         case SIGINT:
         case SIGTERM:
             $this->manager->getOutput()->write('[-] Exiting.');
     }
 }
Example #7
0
 function setPassword()
 {
     $bef = new Manager();
     $ant = $bef->Find($this->id);
     if ($bef->password != $this->password) {
         $this->password = md5($this->password);
     }
 }
 public function postRenderTemplate(Twig_Template $template, $result)
 {
     $this->templateRenderingDepth--;
     if ($this->templateRenderingDepth == 0) {
         $result = str_replace((string) $this->assetBag, implode("\n", $this->assetManager->getHtmTags($this->assetBag->clear())), $result);
     }
     return $result;
 }
Example #9
0
 public function testSetLanguage()
 {
     $variable = 'en';
     $manager = new Manager();
     $manager->setLanguage($variable);
     $result = $manager->getLanguage();
     $this->assertEquals($variable, $result);
 }
Example #10
0
 public function testGenerateResponse()
 {
     $context = $this->getMock('GFG\\DTOContext\\Context\\ContextInterface');
     $factory = $this->getMock('GFG\\DTOError\\FactoryInterface');
     $factory->expects($this->once())->method('generateCode')->with($context)->willReturn([['name' => 'test', 'code' => 'my code']]);
     $manager = new Manager();
     $manager->setFactory($factory);
     $this->assertSame('my code', (string) $manager->generateCode($context));
 }
Example #11
0
 /**
  * Request a crop
  *
  * @param $input
  * @return mixed
  */
 public function requestCrop($input)
 {
     if ($newImage = $this->ImageManager->cropAndSaveFile($input)) {
         $keepers = array_except($input, array('_token', 'cropper'));
         $keepers['images'][] = $newImage;
         return $this->Redirect->to($this->URL->route('dvs-media-manager') . '?' . http_build_query($keepers));
     }
     return $this->Redirect->back();
 }
Example #12
0
 public function testProductPlane()
 {
     $builder = new Builder\Plane();
     $manager = new Manager($builder);
     $manager->buildProduct();
     $product = $manager->getProduct();
     $this->assertEquals("plane", $product->getName());
     $this->assertEquals(100500, $product->getPrice());
 }
Example #13
0
 /**
  * 
  */
 public function migrate()
 {
     InputOutput::display(_("Executes all migrations"));
     $migrationManager = new Manager($module, 'production');
     $cmd = $this->getPhinxCallLine() . 'migrate ';
     $cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile();
     $cmd .= '-e ' . $this->module;
     shell_exec($cmd);
 }
Example #14
0
 public function testShouldDispatchEventWithArgumentUsingMagicMethods()
 {
     $callback = function (array $params) {
         echo json_encode($params);
     };
     $this->expectOutputString('[1,2]');
     $manager = new Manager();
     $manager->foo = $callback;
     $manager->foo(array(1, 2));
 }
 public function constructReturnOne($res)
 {
     if ($row = mysql_fetch_assoc($res)) {
         $user = new Manager();
         $user->setName($row['name']);
         $user->setPassword($row['password']);
     }
     $this->getConnection()->releaseRes($res);
     return $user;
 }
Example #16
0
 /**
  * @return Asset
  */
 public function fromWebPath($path)
 {
     $split = explode('/', $path);
     $file_name = preg_replace('/^[0-9]*-(.*)/', '$1', array_pop($split));
     $split[] = $file_name;
     $asset = $this->manager->computeAsset(implode('/', $split));
     if ($asset) {
         return $asset;
     }
     throw new Exceptions\FileNotFoundException("File {$path} not found");
 }
Example #17
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $themes = $this->manager->findAndInstallThemes();
     foreach ($themes as $theme) {
         $directories = [$theme->getViewDirectory() . DIRECTORY_SEPARATOR . 'auth' => base_path('resources/views/auth'), $theme->getPublicDirectory() => public_path('vendor/boomcms/themes/' . $theme->getName()), $theme->getDirectory() . '/migrations/' => base_path('/migrations/boomcms')];
         foreach ($directories as $from => $to) {
             if ($this->files->exists($from)) {
                 $this->publishDirectory($from, $to);
             }
         }
     }
 }
Example #18
0
 public function addschool($filename)
 {
     PHPExcel_Settings::setCacheStorageMethod(PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip);
     $files = scandir("./upload");
     array_shift($files);
     array_shift($files);
     $errors = array();
     $j = 0;
     $this->db->begin();
     foreach ($files as $file) {
         if (strstr($file, $filename)) {
             $objexcel = PHPExcel_IOFactory::load("./upload/" . $file);
             $sheet = $objexcel->getSheet(0);
             try {
                 $higestrow = $sheet->getHighestRow();
                 $i = 2;
                 while ($i <= $higestrow) {
                     $k = $sheet->getCell("A" . $i)->getValue();
                     if (is_null($k) || $k == "") {
                         break;
                     }
                     $username = (string) $sheet->getCell($this->excel_col[0] . $i)->getValue();
                     $password = (string) $sheet->getCell($this->excel_col[1] . $i)->getValue();
                     $district = (string) $sheet->getCell($this->excel_col[2] . $i)->getValue();
                     $schoolname = (string) $sheet->getCell($this->excel_col[3] . $i)->getValue();
                     $realname = (string) $sheet->getCell($this->excel_col[4] . $i)->getValue();
                     $phone = (string) $sheet->getCell($this->excel_col[5] . $i)->getValue();
                     $email = (string) $sheet->getCell($this->excel_col[6] . $i)->getValue();
                     $ID_number = (string) $sheet->getCell($this->excel_col[7] . $i)->getValue();
                     $manager = new Manager();
                     if ($manager->signup($username, $password, $phone, $email, $realname, $ID_number)) {
                         $this->newschool($schoolname, $district, $manager);
                     } else {
                         throw new PDOException();
                     }
                     $i++;
                 }
             } catch (PDOException $ex) {
                 $errors['PDOException'] = $ex->getMessage();
                 $this->db->rollback();
                 $objexcel->disconnectWorksheets();
                 unlink("./upload/" . $file);
                 // throw $ex;
                 return $errors;
             }
         }
     }
     $objexcel->disconnectWorksheets();
     unlink("./upload/" . $file);
     $this->db->commit();
     return $errors;
 }
Example #19
0
 /**
  * Get manager instance
  * 
  * @return Manager
  */
 public static function getInstance()
 {
     // Check whether manager has been set
     if (!isset(self::$instance)) {
         // Manager not set
         // Create new manager and load it's configuration
         $manager = new Manager();
         $manager->loadConfiguration();
         // Set manager
         self::$instance = $manager;
     }
     // Return manager instance
     return self::$instance;
 }
Example #20
0
 /**
  * @method POST
  */
 public function postAction()
 {
     /** @var Entity $entity */
     $entity = new $this->entityName();
     $this->entityMapper->mapper($entity, $_POST);
     if ($this->entityMapper->hasErrors()) {
         return $this->jsonResponse($this->entityMapper->getErrors(), 400);
     }
     $persisted = $this->manager->save($entity);
     if (!$persisted) {
         return $this->jsonResponse(array('error' => self::PERSISTED_ERROR), 400);
     }
     return $this->jsonResponse(array('success' => 'Alles Gut!'));
 }
Example #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ["txtName" => "required|unique:teams,name", 'staff' => 'required'], ["txtName.required" => "Please enter cate's name.", 'txt.unique' => 'This name has already been taken', 'staff.required' => 'Please select staff']);
     $team = new Manager();
     $team->name = $request->txtName;
     $team->created_user_id = Auth::user()->id;
     $team->save();
     foreach ($request->input('staff') as $key => $value) {
         $detail = new TeamDetail();
         $detail->team_id = $team->id;
         $detail->staff_id = $value;
         $detail->save();
     }
     return redirect()->route('admin.team.manager.index')->with('success', 'Posted completely!');
 }
Example #22
0
 public function onCreate()
 {
     parent::onCreate();
     $this->setId('templateMainMenu');
     $actions = Manager::getActions('template');
     foreach ($actions as $i => $group) {
         $baseGroup = new MBaseGroup("menu{$i}", $group[0]);
         $baseGroup->setFieldSet(false);
         $tree = new MTree("tree{$i}");
         $groupActions = $group[ACTION_ACTIONS];
         $array = array();
         $j = 0;
         foreach ($groupActions as $action) {
             $array[$j] = array($j, $action[ACTION_CAPTION], $action[ACTION_PATH], 'root');
             if (is_array($action[ACTION_ACTIONS])) {
                 $k = $j;
                 foreach ($action[ACTION_ACTIONS] as $internalAction) {
                     $j++;
                     $array[$j] = array($j, $internalAction[ACTION_CAPTION], $internalAction[ACTION_PATH], $k);
                 }
             }
             $j++;
         }
         $tree->setItemsFromArray($array);
         $baseGroup->addControl($tree);
         $this->addControl($baseGroup);
     }
 }
Example #23
0
 public function __construct($module, $item, $value, $defaults = null)
 {
     $this->value = $value;
     $this->module = $module;
     $this->item = $item;
     $this->defaults = $defaults;
     parent::__construct($module);
     if (file_exists(Manager::getModulePath($module, 'db/lookup.class')) && Manager::uses('/db/lookup.class', $module) || Manager::uses('/classes/lookup.class', $module)) {
         eval("\$object = new Business{$module}Lookup();");
         eval("\$info   = \$object->autoComplete{$item}(\$this,\$defaults);");
         parent::__construct($this->module);
         if ($info) {
             $this->result = $info;
         } else {
             //faz consulta
             $sql = new Msql('');
             $sql->createFrom($this->sql);
             $sql->prepare($value);
             $db = Manager::getDatabase($this->module);
             //$this->sql = MSql::prepare($this->sql,$value);
             //$result = $this->_db->query($value ? $sql->command : str_replace('?','NULL',$this->sql));
             $result = $db->query($value ? $sql->command : str_replace('?', 'NULL', $this->sql));
             $this->result = $result[0];
         }
     }
 }
Example #24
0
 /**
  * Provides the object of the question this response is for.
  * 
  * @return \Wannabe\Question
  */
 public function getQuestion()
 {
     if ($this->getQuestionID() < 1) {
         return null;
     }
     return Manager::getInstance()->getQuestionByID($this->getQuestionID());
 }
 public function renderFile()
 {
     $bCleanup = Manager::usePath() === self::DO_CLEANUP;
     $aReferences = ReferenceQuery::create()->find();
     self::checkReferences($aReferences, $bCleanup);
     if (count(self::$REFERENCES_WITHOUT_FROM) === 0 && count(self::$REFERENCES_WITHOUT_TO) === 0) {
         if (!$bCleanup) {
             print TranslationPeer::getString('test_references.references_are_ok', null, null, array('count' => count($aReferences)));
         } else {
             print TranslationPeer::getString('test_references.wrong_references_removed');
             print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references'), 'FileManager')), TranslationPeer::getString('test_references.test_again')));
         }
     } else {
         if (count(self::$REFERENCES_WITHOUT_FROM) > 0) {
             print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_FROM) . TranslationPeer::getString('test_references.loose_from_references_found'));
             foreach (self::$REFERENCES_WITHOUT_FROM as $oReference) {
                 print TagWriter::quickTag('p', array(), $oReference->getFromModelName() . '/' . $oReference->getFromId());
             }
         }
         if (count(self::$REFERENCES_WITHOUT_TO) > 0) {
             print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_TO) . TranslationPeer::getString('test_references.loose_to_references_found'));
             foreach (self::$REFERENCES_WITHOUT_TO as $oReference) {
                 print TagWriter::quickTag('p', array(), $oReference->getToModelName() . '/' . $oReference->getToId());
             }
         }
         print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references', self::DO_CLEANUP), 'FileManager')), TranslationPeer::getString('test_references.remove_loose_ends')));
     }
 }
 public function renderFile()
 {
     //Send Content-Type
     $sCharset = Settings::getSetting('encoding', 'browser', 'utf-8');
     if ($this->sType === ResourceIncluder::RESOURCE_TYPE_CSS) {
         header("Content-Type: text/css;charset={$sCharset}");
     } else {
         if ($this->sType === ResourceIncluder::RESOURCE_TYPE_JS) {
             header("Content-Type: text/javascript;charset={$sCharset}");
         }
     }
     //Find consolidated resources
     $aKeys = array();
     while (Manager::hasNextPathItem()) {
         $aKeys[] = Manager::usePath();
     }
     $sKey = 'consolidated-output-' . $this->sType . '-' . implode('|', $aKeys);
     $oCachingStrategy = clone CachingStrategy::fromConfig('file');
     $oCache = new Cache($sKey, 'resource', $oCachingStrategy);
     $oItemCachingStrategy = clone $oCachingStrategy;
     $oItemCachingStrategy->init(array('key_encode' => null));
     $oCache->sendCacheControlHeaders();
     if (!$oCache->entryExists(false)) {
         foreach ($aKeys as $sItemKey) {
             $oItemCache = new Cache($sItemKey, DIRNAME_PRELOAD, $oItemCachingStrategy);
             if (!$oItemCache->entryExists(false)) {
                 throw new Exception("Consolidated resource {$sItemKey} does not exist.");
             }
             $oCache->setContents($oItemCache->getContentsAsString() . "\n", false, true);
         }
     }
     $oCache->sendCacheControlHeaders();
     $oCache->passContents(true);
 }
Example #27
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     //在这个地方来校验用户名和密码的真实性
     //首先来看看是否有此用户名存在
     //find() 如果没有查询出来数据,则会返回null
     //findAll()  空数据会返回空数组
     //根据用户名查询是否有一个用户信息
     $user_model = Manager::model()->find('username=:name', array(':name' => $this->username));
     //如果用户名不存在
     if ($user_model === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     } else {
         if ($user_model->password !== $this->password) {
             //密码判断
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
             return false;
         } else {
             $this->errorCode = self::ERROR_NONE;
             return true;
         }
     }
     //		if(!isset($users[$this->username]))
     //			$this->errorCode=self::ERROR_USERNAME_INVALID;
     //		elseif($users[$this->username]!==$this->password)
     //			$this->errorCode=self::ERROR_PASSWORD_INVALID;
     //		else
     //			$this->errorCode=self::ERROR_NONE;
     //		return !$this->errorCode;
 }
Example #28
0
 /**
  * Provides the object of the crew.
  *
  * @return \Wannabe\Crew
  */
 public function getCrew()
 {
     if ($this->getCrewID() < 1) {
         return null;
     }
     return Manager::getInstance()->getCrewByID($this->getCrewID());
 }
Example #29
0
 public function __construct()
 {
     try {
         $this->oRootPage = PagePeer::getRootPage();
     } catch (Exception $e) {
         $this->oRootPage = self::initializeRootPage();
     }
     $this->oTreeWidget = new TreeWidgetModule();
     $this->oTreeWidget->setDelegate($this);
     $this->oTreeWidget->setSetting('init_dnd', true);
     $oInitialPage = null;
     if (Manager::hasNextPathItem()) {
         $oInitialPage = PageQuery::create()->findPk(Manager::usePath());
         if ($oInitialPage !== null) {
             Session::getSession()->setAttribute('persistent_page_id', $oInitialPage->getId());
         }
     } else {
         if (Session::getSession()->hasAttribute('persistent_page_id')) {
             $oInitialPage = PageQuery::create()->findPk(Session::getSession()->getAttribute('persistent_page_id'));
         }
     }
     if ($oInitialPage === null) {
         $oInitialPage = $this->oRootPage;
     }
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'tree_session', $this->oTreeWidget->getSessionKey());
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_id', $oInitialPage->getId());
     $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_tree_left', $oInitialPage->getTreeLeft());
     $oResourceIncluder = ResourceIncluder::defaultIncluder();
     $oResourceIncluder->addResource('admin/template.css', null, null, array(), ResourceIncluder::PRIORITY_NORMAL, null, true);
 }
Example #30
0
 public function apply($request, $response)
 {
     $response->status = MStatusCode::INTERNAL_ERROR;
     $format = $request->format;
     $response->setContentType($response->getMimeType("xx." + format));
     $this->tracestack = str_replace('#', '<br>#', $this->exception->trace);
     $errorHtml = "Not found";
     try {
         $template = new MTemplate();
         $template->context('result', $this->exception);
         $language = Manager::getOptions('language');
         $errorHtml = $template->fetch("errors/{$language}/" . $response->status . "." . ($format == null ? "html" : $format));
         if ($request->isAjax() && $format == "html") {
             if ($this->ajax->isEmpty()) {
                 $this->ajax->setId('error');
                 $this->ajax->setType('page');
                 $this->ajax->setData($errorHtml);
             }
             $response->out = $this->ajax->returnData();
         } else {
             $response->out = $errorHtml;
         }
     } catch (Exception $e) {
         throw new EMException($e);
     }
 }