Ejemplo n.º 1
0
 public function testEmptyElementIfIsReference()
 {
     $m = new Mapper($this->project);
     $m->setFrom("*.java");
     try {
         $m->setRefid(new Reference("dummyref"));
         $this->fail("Can add reference to Mapper with from attribute set");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
     $m = new Mapper($this->project);
     $m->setRefid(new Reference("dummyref"));
     try {
         $m->setFrom("*.java");
         $this->fail("Can set from in Mapper that is a reference.");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
     $m = new Mapper($this->project);
     $m->setRefid(new Reference("dummyref"));
     try {
         $m->setTo("*.java");
         $this->fail("Can set to in Mapper that is a reference.");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
     try {
         $m = new Mapper($this->project);
         $m->setRefid(new Reference("dummyref"));
         $m->setType("glob");
         $this->fail("Can set type in Mapper that is a reference.");
     } catch (BuildException $be) {
         $this->assertEquals("You must not specify more than one attribute when using refid", $be->getMessage());
     }
 }
Ejemplo n.º 2
0
 public function __construct(Mapper $mapper, array $namespaces, array $paths)
 {
     $this->mapper = $mapper;
     $this->namespaces = $namespaces;
     $this->paths = $paths;
     $this->tables = $this->mapper->generate();
 }
Ejemplo n.º 3
0
 public function testMapperWithDefaultValue()
 {
     require_once __DIR__ . '/helpers/MapperTestDefaultHelper.php';
     $mapper = new Mapper();
     $class = $mapper->mapInputToCommand('MapperTestDefaultHelper', []);
     $this->assertEquals('456', $class->test);
 }
Ejemplo n.º 4
0
 function login()
 {
     if (!empty($_POST)) {
         $check = new Check();
         $user = new User();
         $pdo = new Db();
         $db = $pdo->get();
         $mapper = new Mapper($db);
         //Проверяем входные данные
         $user->login = $check->checkInput($_POST['login']);
         $password = $check->checkInput($_POST['pass']);
         $user->password = md5($password);
         //Если пользователь не найден
         $this->user = $mapper->select($user);
         if (empty($this->user)) {
             $this->error = "Пароль или логин не совпадают";
             $this->out('login.php');
         } else {
             $this->out('profile.php');
             //Если найден, выводим профиль
         }
     } else {
         $this->out('login.php');
     }
 }
Ejemplo n.º 5
0
 /**
  * Add file in given feed
  * @return bool
  */
 public static function add($feedID, $files, $ssh_connection)
 {
     // set permissions with the ssh connection
     // get feed path
     $mapper = new Mapper('Feed');
     $mapper->get($feedID);
     $resultsFeed = $mapper->get();
     $mapper = new Mapper('User');
     $mapper->get($resultsFeed['Feed'][0]->user_id);
     $resultsUser = $mapper->get();
     // target directory
     $dir = CHRIS_USERS . '/' . $resultsUser['User'][0]->username . '/file_browser/' . $resultsFeed['Feed'][0]->name . '-' . $resultsFeed['Feed'][0]->id . '/';
     $ssh_connection->exec('chmod 777 ' . $dir);
     foreach ($files as $key => $value) {
         $target_path = $dir . basename($value['name']);
         if (move_uploaded_file($value['tmp_name'], $target_path)) {
             // all good, set permissions correctly
             // not through ssh connection, do it as chris
             exec('chmod 775 ' . $target_path);
         } else {
             // oops.... something went wrong
             return $value['error'];
         }
         $ssh_connection->exec('chmod 755 ' . $dir);
     }
     // all files uploaded successfully
     return 0;
 }
Ejemplo n.º 6
0
 /**
  * Returns lazy loaded field by its name
  *
  * @param string $fieldName
  * @return mixed
  */
 public function getComputed($fieldName)
 {
     if (!isset($this->computed[$fieldName])) {
         $value = $this->mapper->lazyload($this, $fieldName);
         $this->computed[$fieldName] = $value;
     }
     return $this->computed[$fieldName];
 }
Ejemplo n.º 7
0
 /**
  * Constructor Method
  *
  * @param \Spot\Mapper $mapper
  * @throws Exception
  * @internal param $Spot_Mapper
  * @internal param string $entityName Name of the entity to query on/for
  */
 public function __construct(Mapper $mapper)
 {
     $this->_mapper = $mapper;
     $this->_entityName = $mapper->entity();
     $this->_tableName = $mapper->table();
     // Create Doctrine DBAL query builder from Doctrine\DBAL\Connection
     $this->_queryBuilder = $mapper->connection()->createQueryBuilder();
 }
Ejemplo n.º 8
0
 /**
  * Add a <code>FileNameMapper</code>.
  * @param FileNameMapper $fileNameMapper a <code>FileNameMapper</code>.
  * @throws BadMethodCallException if attempting to add this
  *         <code>ContainerMapper</code> to itself, or if the specified
  *         <code>FileNameMapper</code> is itself a <code>ContainerMapper</code>
  *         that contains this <code>ContainerMapper</code>.
  */
 public function add(Mapper $fileNameMapper)
 {
     if ($this == $fileNameMapper || $fileNameMapper instanceof ContainerMapper && $fileNameMapper->contains($this)) {
         throw new BadMethodCallException("Circular mapper containment condition detected");
     } else {
         $this->mappers[] = $fileNameMapper;
     }
 }
Ejemplo n.º 9
0
 public function registerAdapter($name, Adapter $adapter)
 {
     if (isset($this->adapters[$name])) {
         throw new Exception\InvalidArgumentException("Adapter with name " . $name . " already registered!");
     }
     $this->adapters[$name] = $adapter;
     if ($adapter->getMapping()) {
         $this->mapper->registerAdapterMapping($name, $adapter->getMapping());
     }
 }
Ejemplo n.º 10
0
 function savelike($like, $itemid)
 {
     $pdo = new Db();
     $db = $pdo->get();
     $mapper = new Mapper($db);
     $comments = new Comments();
     $comments->likes = $like;
     $comments->id = $itemid;
     $mapper->saveLike($comments);
 }
Ejemplo n.º 11
0
 /**
  * Validate a token. Returns the result and deletes the token if valid.
  *
  * @param string $token The token
  * @return boolean
  */
 public static function validate($token)
 {
     $tokenMapper = new Mapper('Token');
     $tokenMapper->filter('value=(?)', $token);
     $tokenResults = $tokenMapper->get();
     if (count($tokenResults['Token']) == 0) {
         return false;
     }
     // we found the token
     Mapper::delete($tokenResults['Token'][0], $tokenResults['Token'][0]->id);
     return true;
 }
Ejemplo n.º 12
0
 public function get(array $hashMap, $isNestedKeysName = false)
 {
     $pattern = $this->getPattern($isNestedKeysName);
     $this->mapper->match($pattern, [$hashMap]);
     $data = $this->mapper->current();
     if (empty($data)) {
         $result = $this->getEmptyArray($pattern);
     } else {
         $result = $this->arrayHelper->toTuple($data, $pattern);
     }
     return $result;
 }
Ejemplo n.º 13
0
 public function __construct()
 {
     parent::__construct();
     $this->selectStmt = self::$db_handler->prepare('SELECT * FROM role WHERE rid=?');
     $this->updateStmt = self::$db_handler->prepare('UPDATE role SET role=?, role_des=? WHERE rid=?');
     $this->insertStmt = self::$db_handler->prepare('INSERT INTO role ( role, role_des ) VALUES( ?, ? )');
 }
Ejemplo n.º 14
0
 function __construct()
 {
     parent::__construct();
     $this->selectStmt = self::$db_handler->prepare('SELECT * FROM health_goal WHERE uid=?');
     $this->updateStmt = self::$db_handler->prepare('UPDATE health_goal SET walk=?, upper_limb=?, lower_limb=? WHERE uid=?');
     $this->insertStmt = self::$db_handler->prepare('INSERT INTO health_goal ( walk, upper_limb, lower_limb ) VALUES( ?, ?, ? )');
 }
Ejemplo n.º 15
0
Archivo: Form.php Proyecto: arhe/pwak
 /**
  * FormTools::WriteOptionsFromObject()
  * Prend en paramètres un nom d'objet et retourne un tableau
  * d'options de type:
  * <code>
  *         [0=>'<option value="1">Label1</option>',
  *          1=>'<option value="2">Label2</option>']
  * </code>
  *
  * @static
  * @param string $objname le nom de l'objet
  * @param mixed $selID la ou les valeurs selectionnées par défaut
  * @param mixed array or Filter: un filtre optionnel à appliquer
  * @param array $sort un tableau optionnel pour le tri
  * @param string $labelMethod la méthode à utiliser pour le label
  * @param array $fields les attributs à récupérer.
  * @param boolean $addNullEntry true pour ajouter une option 'Sélectionnez
  * un élément'
  * @return array the options array
  */
 static function writeOptionsFromObject($objname, $selID = 0, $filter = array(), $sort = array(), $labelmethod = 'toString', $fields = array(), $addNullEntry = false)
 {
     $options = array();
     $mapper = Mapper::singleton($objname);
     if (Tools::isException($mapper)) {
         return $mapper;
     }
     if ($labelmethod == 'toString') {
         $toStringAttribute = Tools::getToStringAttribute($objname);
         $fields = is_array($toStringAttribute) ? $toStringAttribute : array($toStringAttribute);
     }
     $col = $mapper->loadCollection($filter, $sort, $fields);
     if ($col instanceof Collection) {
         $dataArray = array();
         $count = $col->getCount();
         for ($i = 0; $i < $count; $i++) {
             $item = $col->getItem($i);
             if (method_exists($item, 'getId') && method_exists($item, $labelmethod)) {
                 $dataArray[$item->getId()] = $item->{$labelmethod}();
             }
             unset($item);
         }
         $options = FormTools::writeOptionsFromArray($dataArray, $selID, $addNullEntry);
     }
     return $options;
 }
Ejemplo n.º 16
0
 public function __construct()
 {
     parent::__construct();
     $this->selectStmt = self::$db_handler->prepare('SELECT * FROM setting WHERE uid=?');
     $this->updateStmt = self::$db_handler->prepare('UPDATE setting SET weight=?, heart_rate=?, slumber=?, walk=?, upper_limb=?, lower_limb=?, send_campaign=?, sync_time=? WHERE uid=?');
     $this->insertStmt = self::$db_handler->prepare('INSERT INTO setting ( uid ) VALUES( ? )');
 }
Ejemplo n.º 17
0
 public static function write($name, $value, $expires = null)
 {
     $self = self::getInstance();
     $expires = $self->expire($expires);
     $path = Mapper::normalize(Mapper::base() . $self->path);
     return setcookie($self->name . '[' . $name . ']', self::encrypt($value), $expires, $path, $self->domain, $self->secure);
 }
Ejemplo n.º 18
0
 function __construct()
 {
     parent::__construct();
     $this->selectStmt = self::$PDO->prepare("SELECT * FROM venue WHERE id=?");
     $this->updateStmt = self::$PDO->prepare("update venue set name=?, id=? where id=?");
     $this->insertStmt = self::$PDO->prepare("insert into venue ( name ) \n                             values( ? )");
 }
Ejemplo n.º 19
0
 function __construct($table)
 {
     if (!self::$DB) {
         self::$DB = new PDO('mysql:dbname=mapper;host=localhost', 'mapper', 'mapper');
         self::$DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         self::$DB->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
         $this->table = $table;
         switch (self::$DB->getAttribute(PDO::ATTR_DRIVER_NAME)) {
             case 'mysql':
                 $nameOpening = $nameClosing = '`';
                 break;
             case 'mssql':
                 $nameOpening = '[';
                 $nameClosing = ']';
                 break;
             default:
                 $nameOpening = $nameClosing = '"';
                 break;
         }
         $this->selectStmt = "SELECT * FROM " . $this->tabel . " WHERE id=?";
         $this->selectAllStmt = "SELECT * FROM {$this->table}";
         $this->updateStmt = "UPDATE {$this->table} SET name=?, body=?, author_id=? WHERE id=?";
         $this->insertStmt = "INSERT INTO {$this->table}\n                                        (name, body, author_id)\n                                        VALUES (?, ?, ?)";
         $this->deleteStmt = "DELETE FROM {$this->table} WHERE id = ?";
     }
 }
Ejemplo n.º 20
0
 /**
  * Checks to make sure all settings are kosher. In this case, it
  * means that the dest attribute has been set and we have a mapper.
  */
 public function verifySettings()
 {
     if ($this->targetdir === null) {
         $this->setError("The targetdir attribute is required.");
     }
     if ($this->map === null) {
         if ($this->mapperElement === null) {
             $this->map = new IdentityMapper();
         } else {
             $this->map = $this->mapperElement->getImplementation();
             if ($this->map === null) {
                 $this->setError("Could not set <mapper> element.");
             }
         }
     }
 }
Ejemplo n.º 21
0
 function __construct($table)
 {
     $class = get_class($this);
     print_r(strToLower($class));
     echo "\n";
     parent::__construct($table);
 }
Ejemplo n.º 22
0
 /**
  * Закольцевать агрегат, начиная с определенного места.
  * Например, есть 5 элементов, надо закольцевать, начиная с 3.
  * В результате получается 3,4,5,1,2.
  * @param integer $offset
  * @return Aggregate
  */
 public function recircle($offset)
 {
     $entityIds = $this->getListEntitiesId();
     $sortedEntityIds = array_slice($entityIds, $offset - 1, count($entityIds) - ($offset - 1));
     $sortedEntityIds = array_merge($sortedEntityIds, array_slice($entityIds, 0, $offset - 1));
     return $this->mapper->createAggregate($sortedEntityIds, null, true);
 }
Ejemplo n.º 23
0
 public static function instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Ejemplo n.º 24
0
 public function link($text, $url = null, $attr = array(), $full = false)
 {
     if (is_null($url)) {
         $url = $text;
     }
     $attr['href'] = Mapper::url($url, $full);
     return $this->tag('a', $text, $attr);
 }
Ejemplo n.º 25
0
 function __construct()
 {
     parent::__construct();
     $this->selectAllStmt = self::$PDO->prepare("SELECT * FROM venue");
     $this->selectStmt = self::$PDO->prepare("SELECT * FROM venue WHERE id=?");
     $this->updateStmt = self::$PDO->prepare("UPDATE venue SET name=?, id=? WHERE id=?");
     $this->insertStmt = self::$PDO->prepare("INSERT into venue ( name ) \n                             values( ? )");
 }
Ejemplo n.º 26
0
 /**
  * ActivityMapper constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->selectAll = self::$db_handler->prepare('SELECT title, content FROM activity');
     $this->selectStmt = self::$db_handler->prepare('SELECT * FROM activity WHERE acid=?');
     $this->updateStmt = self::$db_handler->prepare('UPDATE activity SET title=?, content=?, a_img_url=?, enter_amount=?, end_time=? WHERE acid=?');
     $this->insertStmt = self::$db_handler->prepare('INSERT INTO activity ( title, content, post_time, end_time ) VALUES( ?, ?, ?, ? )');
 }
Ejemplo n.º 27
0
 /**
  * PostMapper constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->selectAll = self::$db_handler->prepare('SELECT * FROM post ORDER BY post_id');
     $this->selectStmt = self::$db_handler->prepare('SELECT * FROM post WHERE post_id=?');
     $this->updateStmt = self::$db_handler->prepare('UPDATE post SET content=? WHERE post_id=?');
     $this->insertStmt = self::$db_handler->prepare('INSERT INTO post (content, post_time) VALUES(?, ? )');
 }
Ejemplo n.º 28
0
 function save(Feed $feed)
 {
     parent::save($feed);
     foreach ($feed->items() as $item) {
         $item->feed_id($feed->id());
         $item->save();
     }
 }
Ejemplo n.º 29
0
 function __construct()
 {
     parent::__construct();
     $this->selectStmt = self::$db_handler->prepare('SELECT * FROM plan WHERE uid=?');
     $this->updateStmt = self::$db_handler->prepare('UPDATE plan SET breakfast=?, lunch=?, dinner=?, exercise=? WHERE uid=? AND pid=?');
     $this->insertStmt = self::$db_handler->prepare('INSERT INTO plan ( pid, uid ) VALUES( ?, ? )');
     $this->countStmt = self::$db_handler->prepare('SELECT count(*) ' . self::COUNT . ' FROM plan WHERE uid=?');
 }
Ejemplo n.º 30
0
 public function create($action = null, $options = array())
 {
     $options += array('method' => 'post', 'action' => Mapper::url($action));
     if ($options['method'] == 'file') {
         $options['method'] = 'post';
         $options['enctype'] = 'multipart/form-data';
     }
     return $this->html->openTag('form', $options);
 }