/** * @param string $databaseName */ public function __construct($databaseName) { $this->entries = new MapOf(function ($data) use($databaseName) { return new SmsModel($databaseName); }); parent::__construct(SmsMongoMapper::connect($databaseName), array()); }
/** * * @param ProjectModel $projectModel * @param int $newerThanTimestamp */ public function __construct($projectModel, $newerThanTimestamp = null) { if (!is_null($newerThanTimestamp)) { $startDate = new \MongoDate($newerThanTimestamp); parent::__construct(self::mapper($projectModel->databaseName()), array('dateModified' => array('$gte' => $startDate)), array(), array('name' => 1)); } else { parent::__construct(self::mapper($projectModel->databaseName()), array(), array(), array('name' => 1)); } }
/** * * @param ProjectModel $projectModel * @param int $newerThanTimestamp */ public function __construct($projectModel, $newerThanTimestamp = null) { $lexProject = new LexiconProjectModel($projectModel->id->asString()); if (!is_null($newerThanTimestamp)) { $startDate = new \MongoDate($newerThanTimestamp); parent::__construct(self::mapper($projectModel->databaseName()), array('isDeleted' => true, 'dateModified' => array('$gte' => $startDate)), array()); } else { parent::__construct(self::mapper($projectModel->databaseName()), array('isDeleted' => true), array()); } }
/** * * @param ProjectModel $projectModel * @param int $newerThanTimestamp * @param int $limit * @param int $skip */ public function __construct($projectModel, $newerThanTimestamp = null, $limit = 0, $skip = 0) { $this->entries = new ArrayOf(function ($data) use($projectModel) { return new LexCommentModel($projectModel); }); // sort ascending by creation date if (!is_null($newerThanTimestamp)) { $startDate = new \MongoDate($newerThanTimestamp); parent::__construct(self::mapper($projectModel->databaseName()), array('isDeleted' => false, 'dateModified' => array('$gte' => $startDate)), array(), array('dateCreated' => 1), $limit, $skip); } else { parent::__construct(self::mapper($projectModel->databaseName()), array('isDeleted' => false), array(), array('dateCreated' => 1), $limit, $skip); } }
public function __construct() { parent::__construct(GlobalQuestionTemplateModelMongoMapper::instance(), array(), array('title', 'description')); }
public function __construct($projectModel, $textId) { parent::__construct(QuestionModelMongoMapper::connect($projectModel->databaseName()), array('description' => array('$regex' => ''), 'textRef' => MongoMapper::mongoID($textId)), array('description')); }
public function __construct($projectModel, $textId) { parent::__construct(QuestionModelMongoMapper::connect($projectModel->databaseName()), array('description' => array('$regex' => ''), 'textRef' => MongoMapper::mongoID($textId)), array('title', 'description', 'answers', 'isArchived'), array('dateCreated' => -1)); }
public function readForDto($missingInfo = '') { // TODO This can be refactored to perform missing info based on the data type, rather than the property name. There is much repetition in the code below CP 2014-08 parent::read(); $entriesToReturn = array(); if ($missingInfo != '') { foreach ($this->entries as $entry) { $foundMissingInfo = false; if (!array_key_exists('senses', $entry) || count($entry['senses']) == 0) { $foundMissingInfo = true; } else { foreach ($entry['senses'] as $sense) { switch ($missingInfo) { case LexiconConfigObj::DEFINITION: if (!array_key_exists('definition', $sense) || count($sense['definition']) == 0) { $foundMissingInfo = true; } else { foreach ($sense['definition'] as $form) { if ($form['value'] == '') { $foundMissingInfo = true; } } } break; case LexiconConfigObj::POS: if (!array_key_exists('partOfSpeech', $sense) || !array_key_exists('value', $sense['partOfSpeech']) || $sense['partOfSpeech']['value'] == '') { $foundMissingInfo = true; } break; case LexiconConfigObj::EXAMPLE_SENTENCE: if (!array_key_exists('examples', $sense) || count($sense['examples']) == 0) { $foundMissingInfo = true; } else { foreach ($sense['examples'] as $example) { if (!array_key_exists('sentence', $example) || count($example['sentence']) == 0) { $foundMissingInfo = true; } else { foreach ($example['sentence'] as $form) { if ($form['value'] == '') { $foundMissingInfo = true; } } } } } break; case LexiconConfigObj::EXAMPLE_TRANSLATION: if (!array_key_exists('examples', $sense) || count($sense['examples']) == 0) { $foundMissingInfo = true; } else { foreach ($sense['examples'] as $example) { if (!array_key_exists('translation', $example) || count($example['translation']) == 0) { $foundMissingInfo = true; } else { foreach ($example['translation'] as $form) { if ($form['value'] == '') { $foundMissingInfo = true; } } } } } break; default: throw new \Exception("Unknown missingInfoType = " . $missingInfo); } if ($foundMissingInfo) { break; } } } if ($foundMissingInfo) { $entriesToReturn[] = $entry; } } // end of foreach $this->entries = $entriesToReturn; $this->count = count($this->entries); } }
public function __construct($projectModel) { parent::__construct(TextModelMongoMapper::connect($projectModel->databaseName()), array('title' => array('$regex' => '')), array('title')); }
public function __construct($projectModel) { $databaseName = $projectModel->databaseName(); parent::__construct(self::mapper($databaseName), array(), array('title', 'description')); }
public function __construct($projectId) { parent::__construct(UserModelMongoMapper::instance(), array('username' => array('$regex' => '\\w'), 'projects' => array('$in' => array(MongoMapper::mongoID($projectId)))), array('username', 'email', 'name')); }
/** * @param string $site */ public function __construct($site) { $this->_site = $site; parent::__construct(ProjectModelMongoMapper::instance()); }
public function __construct($projectModel) { // hardcoded to limit 100. TODO implement paging $this->entries = new MapOf(function ($data) use($projectModel) { return new ActivityModel($projectModel); }); parent::__construct(ActivityModelMongoMapper::connect($projectModel->databaseName()), array('action' => array('$regex' => '')), array(), array('dateCreated' => -1), 100); }
public function __construct() { parent::__construct(ProjectModelMongoMapper::instance(), array(), array('projectName', 'language')); }
/** * @param MongoMapper $term * @param string or array $projectIdOrIds * @param Website $website * @param bool $include */ public function __construct($term, $projectIdOrIds = '', $website, $include = false) { $query = array('$or' => array(array('name' => array('$regex' => $term, '$options' => '-i')), array('username' => array('$regex' => $term, '$options' => '-i')), array('email' => array('$regex' => $term, '$options' => '-i')))); if (!empty($projectIdOrIds)) { // Allow $projectIdOrIds to be either an array or a single ID if (is_array($projectIdOrIds)) { $idsForQuery = $projectIdOrIds; } else { $idsForQuery = array($projectIdOrIds); } // If passed string IDs, convert to MongoID objects $idsForQuery = array_map(function ($id) { if (is_string($id)) { return MongoMapper::mongoID($id); } else { return $id; } }, $idsForQuery); $inOrNotIn = $include ? '$in' : '$nin'; $query['projects'] = array($inOrNotIn => $idsForQuery); //error_log("Query: " . print_r($query, true)); } // Filter for only users on the current site $encodedDomain = $website->domain; MongoEncoder::encodeDollarDot($encodedDomain); $query['siteRole.' . $encodedDomain] = array('$exists' => true); parent::__construct(UserModelMongoMapper::instance(), $query, array('username', 'email', 'name', 'avatarRef')); // If we were called with a project filter that excluded certain users, also // return a list of specifically which users were excluded. Which happens to // be another typeahead search with the same query term, but *including* only // the ones matching this project. if ($projectIdOrIds && !$include) { $this->excludedUsers = new UserTypeaheadModel($term, $projectIdOrIds, $website, true); $this->excludedUsers->read(); } //echo("Result: " . print_r($this, true)); }
public function __construct($userId) { parent::__construct(CommunityModelMongoMapper::instance(), array('users' => array('$in' => array($userId))), array('communityname')); }
public function __construct($projectModel) { parent::__construct(TextModelMongoMapper_sf_v0_9_18::connect('sf_jamaican_psalms'), array('title' => array('$regex' => '')), array('title')); }