/** * Get storage information * @access public * @return array */ public function getStorageStatus() { $result = null; if ($this->_cache === true) { $dbCache = $this->getDI()->get('dbCache'); $key = md5(__METHOD__); $result = $dbCache->get($key); } if ($result === null) { $phql = "SHOW VARIABLES"; $query = new Resultset(null, null, $this->_connection->query($phql), $this->_cache); $result = $query->toArray(); $result = \Helpers\Node::arrayToPair($result); if ($this->_cache === true) { $dbCache->save($key, $result); } } return $result; }
/** * Creating a Zend\Paginator\Paginator from Elastica\ResultSet. * This paginator can be passed directly zf-hal or whereever you want. * This method use ElasticsearchAdapter as ArrayAdapter * * @param ResultSet $resultSet Elastica result data * @return Paginator Created paginator from resultset with ElasticsearchAdapter. */ public function buildPaginator(Resultset $resultSet) { $itemsPerPage = empty($resultSet->getQuery()->getParam('size')) ? $this->getDefaultPageSize() : $resultSet->getQuery()->getParam('size'); $currentPage = (int) ceil($resultSet->getQuery()->getParam('size') / $itemsPerPage) + 1; $results = []; foreach ($resultSet->getResults() as $result) { $data = $result->getData(); $data['_score'] = $result->getScore(); $results[] = $data; } $adapter = new ElasticsearchAdapter($results, $resultSet->getTotalHits()); $adapter->setMeta('aggs', $resultSet->getAggregations()); $paginator = new Paginator($adapter); $paginator->setCurrentPageNumber($currentPage); $paginator->setItemCountPerPage($itemsPerPage); return $paginator; }
/** * * @param Resultset $rs */ private static function _getObject(Resultset $rs) { $ret = new self(); while ($rs->NextRow()) { $ret->setSetting($rs->getKey(), $rs->getValue()); } $ret->resetSignature(); return $ret; }
private static function _getObject(Resultset $rs, Project $project) { $ret = new Project_Log($project); $ret->setId($rs->getId()); $ret->setDate($rs->getDate()); $ret->setType($rs->getType()); $ret->setMessage($rs->getMessage()); $ret->setUsername($rs->getUsername()); $ret->resetSignature(); return $ret; }
public function search($query, $fields = array()) { if (!count($fields)) { $searchable_fields = array(); foreach (FW4_Structure::get_searchable_fields() as $field) { if ($field->getName() == 'bool') { continue; } $fields[strval($field['searchable'])] = strval($field['searchable']); } } if (!count($this->order_by)) { $this->order_by[] = 'MATCH(`' . implode('`,`', $fields) . '`) AGAINST ("' . $this->escape($query) . '") DESC'; } $this->where[] = '_language = "' . language() . '"'; $this->where[] = 'MATCH(`' . implode('`,`', $fields) . '`) AGAINST ("' . $this->escape($query) . '") > 0'; $sql = 'SELECT *, MATCH(`' . implode('`,`', $fields) . '`) AGAINST ("' . $this->escape($query) . '") as score FROM `_search_index` WHERE ' . implode(' AND ', $this->where); if (count($this->group_by)) { $sql .= ' GROUP BY ' . implode(',', $this->group_by); } if (count($this->order_by)) { $sql .= ' ORDER BY ' . implode(',', $this->order_by); } if ($this->limit) { $sql .= ' LIMIT ' . intval($this->limit * ($this->page - 1)) . ',' . $this->limit; } $result = new Resultset($this->db->query($sql, PDO::FETCH_CLASS, 'Model', array('translate' => array())), '_search_index', '_search_index'); $result->_children($this->children); $result->_relations($this->relations); $result->_fetchable_fields($this->fetchable_fields); return $result; }
private static function _getObject(Resultset $rs, Project_Build $build) { $ret = new self($build); $ret->setDate($rs->getDate()); $ret->setVersion($rs->getVersion()); $ret->resetSignature(); return $ret; }
private static function _getObject(Resultset $rs, Project_Build $build) { $ret = new self($build); $ret->setDate($rs->getDate()); $ret->setVersion($rs->getVersion()); $ret->setAhh($rs->getAhh()); $ret->setAndc($rs->getAndc()); $ret->setCalls($rs->getCalls()); $ret->setCcn($rs->getCcn()); $ret->setCcn2($rs->getCcn2()); $ret->setCloc($rs->getCloc()); $ret->setClsa($rs->getClsa()); $ret->setClsc($rs->getClsc()); $ret->setEloc($rs->getEloc()); $ret->setFanout($rs->getFanout()); $ret->setLeafs($rs->getLeafs()); $ret->setLloc($rs->getLloc()); $ret->setLoc($rs->getLoc()); $ret->setMaxDit($rs->getMaxDit()); $ret->setNcloc($rs->getNcloc()); $ret->setNoc($rs->getNoc()); $ret->setNof($rs->getNof()); $ret->setNoi($rs->getNoi()); $ret->setNom($rs->getNom()); $ret->setNop($rs->getNop()); $ret->setRoots($rs->getRoots()); $ret->resetSignature(); return $ret; }
/** * * @param unknown_type $rs */ private static function &_getObject(Resultset $rs, array $options = array()) { isset($options['loadUsers']) ?: ($options['loadUsers'] = true); $ret = new Project(); $ret->setAvatar($rs->getAvatar()); $ret->setScmConnectorType($rs->getScmConnectorType()); $ret->setScmRemoteRepository($rs->getScmRemoteRepository()); $ret->setScmUsername($rs->getScmUsername()); $ret->setScmPassword($rs->getScmPassword()); $ret->setScmCheckChangesTimeout($rs->getScmCheckChangesTimeout()); $ret->setWorkDir($rs->getWorkDir()); $ret->setReleaseLabel($rs->getReleaseLabel()); $ret->setDateCreation($rs->getDateCreation()); $ret->setDateCheckedForChanges($rs->getDateCheckedForChanges()); $ret->setDescription($rs->getDescription()); $ret->setId($rs->getId()); $specialTasks = @unserialize($rs->getSpecialTasks()); if ($specialTasks === false) { $specialTasks = array(); } $ret->setSpecialTasks($specialTasks); $ret->setStatsNumBuilds($rs->getStatsNumBuilds()); $ret->setStatus($rs->getStatus()); $ret->setTitle($rs->getTitle()); $ret->setVisits($rs->getVisits()); $ret->setOptionReleasePackage($rs->getOptionReleasePackage()); $ret->setScmEnvVars($rs->getScmEnvVars()); // // Builders // // // The following is a workaround on the fact that the translation of this // serialized object to the database gets all broken, due to the fact of PHP // introducing NULL bytes around the '*' that is prepended before protected // variable members, in the serialized mode. This method replaces those // problematic NULL bytes with an identifier string '~~NULL_BYTE~~', // rendering serialization and unserialization of these specific kinds of // object safe. Credits to travis@travishegner.com on: // http://pt.php.net/manual/en/function.serialize.php#96504 // $unsafeSerializedIntegrationBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getIntegrationBuilder()); if (($integrationBuilder = unserialize($unsafeSerializedIntegrationBuilder)) === false) { SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize integration builder for this project [PID={$ret->getId()}]"); $integrationBuilder = new Build_BuilderElement_Project(); } $ret->setIntegrationBuilder($integrationBuilder); $unsafeSerializedDeploymentBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getDeploymentBuilder()); if (($deploymentBuilder = unserialize($unsafeSerializedDeploymentBuilder)) === false) { SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize deployment builder for this project [PID={$ret->getId()}]"); $deploymentBuilder = new Build_BuilderElement_Project(); } $ret->setDeploymentBuilder($deploymentBuilder); if ($options['loadUsers']) { $ret->loadUsers(); } $ret->resetSignature(); return $ret; }
private static function _getObject(Resultset $rs, Project $project) { $ret = new Project_Build($project); $ret->setId($rs->getId()); $ret->setDate($rs->getDate()); $ret->setDuration($rs->getDuration()); $ret->setLabel($rs->getLabel()); $ret->setDescription($rs->getDescription()); $ret->setOutput($rs->getOutput()); $ret->setReleaseFile($rs->getReleaseFile()); $specialTasks = @unserialize($rs->getSpecialTasks()); if ($specialTasks === false) { $specialTasks = array(); } $ret->setSpecialTasks($specialTasks); $ret->setStatus($rs->getStatus()); $ret->setScmRevision($rs->getScmRevision()); // // Get all extras related to this build // //$ret->setPtrPhpDepend(PhpDepend::getById($ret, $GLOBALS['user'], Access::READ)); $ret->resetSignature(); return $ret; }
public function getCouche($profil_id = null, $utilisateur_id = null) { if ((is_null($profil_id) || trim($profil_id) == "") && (is_null($utilisateur_id) || trim($utilisateur_id) == "")) { $sql = " SELECT c.*, true as est_visible, false as est_active, true as est_lecture, true as est_ecriture, true as est_analyse, true as est_export" . " FROM igo_couche c where c.id={$this->id}; "; } else { if (!is_null($profil_id) && trim($profil_id) != "") { $sql = "SELECT c.*, true as est_visible, false as est_active,est_lecture or est_publique as est_lecture, est_ecriture, est_analyse, est_export" . " FROM igo_couche c LEFT JOIN igo_permission p ON c.id=p.couche_id and p.profil_id=" . $profil_id . " where c.id={$this->id} "; } else { $sql = " SELECT c.*, est_visible, est_active, est_lecture or est_publique as est_lecture, est_ecriture, est_analyse, est_export" . " FROM igo_couche c LEFT JOIN igo_permission p, igo_utilisateur_profil up ON c.id=p.couche_id and and p.profil_id=up.profil_id and up.utilisateur_id=" . $utilisateur_id . "" . " where c.id={$this->id}"; } } $igo_couche = new IgoCouche(); $igo_couche = new Resultset(null, $igo_couche, $igo_couche->getReadConnection()->query($sql)); return $igo_couche; }
private static function _getObject(Resultset $rs, Project $project, User $user) { if (empty($user) || !$user instanceof User || empty($project) || !$project instanceof Project) { return false; } $ret = new self($project, $user, $rs->getAccess()); // // The following is a workaround on the fact that the translation of this // serialized object to the database gets all broken, due to the fact of PHP // introducing NULL bytes around the '*' that is prepended before protected // variable members, in the serialized mode. This method replaces those // problematic NULL bytes with an identifier string '~~NULL_BYTE~~', // rendering serialization and unserialization of these specific kinds of // object safe. Credits to travis@travishegner.com on: // http://pt.php.net/manual/en/function.serialize.php#96504 // $unsafeSerializedNotifications = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getNotifications()); if (($notifications = unserialize($unsafeSerializedNotifications)) === false || !$notifications instanceof NotificationSettings) { $notifications = new NotificationSettings($project, $user); } $ret->setNotifications($notifications); $ret->resetSignature(); // Update user and project for these notification settings $notifications->setPtrProject($project); $notifications->setPtrUser($user); return $ret; }