Reads data for an event.
@param [String => Mixed] $opts
@return [String => Mixed]
@override CourseViewed
544643
public function read(array $opts) {
        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'scorm_event',
            'scorm_url' => $opts['module']->url,
            'scorm_name' => $opts['module']->name,
            'scorm_scoes_id' => $opts['scorm_scoes']->id,
            'scorm_scoes_type' => 'http://adlnet.gov/expapi/activities/lesson',
            'scorm_scoes_url' => $opts['module']->url,
            'scorm_scoes_name' => $opts['scorm_scoes']->title,
            'scorm_scoes_description' => $opts['scorm_scoes']->title,
            'scorm_attempt' => $opts['cmi_data']['attemptid'],
            'scorm_status' => $opts['scorm_scoes_track']['status'],
        ])];
    }
889449
public static function table(array $data, string $title = 'Data Table', array $opts = []): int
    {
        return Table::show($data, $title, $opts);
    }
19365
public function read(array $opts) {
        return array_merge(parent::read($opts), [
            'verb' => [
                'id' => 'http://adlnet.gov/expapi/verbs/registered',
                'display' => $this->readVerbDisplay($opts),
            ],
            'object' => $this->readApp($opts),
        ]);
    }
1058020
public function retrieveData($path, array $params = array(), array $opts = array())
    {
        return empty($params)
            ? $this->_processResponse($this->http->get($this->_getApiPath($opts) . $path))
            : $this->_processResponse(
                $this->http->get($this->_getApiPath($opts) . $path . "?" . http_build_query($params, '', '&'))
            );
    }
1038086
public function getEvents(array $options = null)
    {
        $url = ThisData::ENDPOINT_EVENTS;
        if (!is_null($options)) {
            $url .= '?' . http_build_query($options);
        }
        $response = $this->synchronousExecute('GET', $url);
        return json_decode($response->getBody(), TRUE);
    }
797259
public function fromArray(array $opts) 
    {
        $this->_opts = \Coast\array_merge_smart(
            $this->_opts,
            $opts
        );
        return $this;
    }
845691
public function toString(array $opts = array())
    {
        $eol = empty($opts['canonical'])
            ? $this->_eol
            : "\r\n";
        $text = '';

        foreach ($this->toArray($opts) as $key => $val) {
            foreach ((is_array($val) ? $val : array($val)) as $entry) {
                $text .= $key . ': ' . $entry . $eol;
            }
        }

        return $text . $eol;
    }
716681
protected function _processString($str, $opts)
    {
        if (!empty($opts['length'])) {
            return substr($str, empty($opts['start']) ? 0 : $opts['start'], $opts['length']);
        } elseif (!empty($opts['start'])) {
            return substr($str, $opts['start']);
        }

        return $str;
    }
1118045
public static function parse($str, $opts = array())
	{
		$params = array();
		$opts = \array_merge(
			array(
				'conv_dot'		=> false,
				'conv_space'	=> true,
			),
			$opts
		);
		if (( $opts['conv_dot'] || \strpos($str, '.') === false )
			&& ( $opts['conv_space'] || \strpos($str, ' ') === false )
		) {
			// just use parse_str
			\parse_str($str, $params);
		} else {
			$pairs = \explode('&', $str);
			foreach ($pairs as $pair) {
				$ptr = &$params;
				$pair = \array_map('urldecode', \explode('=', $pair));
				$path = $pair[0];
				$v = isset($pair[1])
					? $pair[1]
					: '';
				$i = 0;
				$re = '/^([^\[]*)/';
				while (\preg_match($re, $path, $matches)) {
					$k = $matches[1];
					$a = \preg_match('/^\s?$/', $k);		// 0 or 1 whitepace = append
					if ($i == 0) {
						// ltrim spaces as parse_str() does
						$k = \ltrim($k, ' ');
						if (\strlen($k) == 0) {
							break;
						}
						if ($opts['conv_space']) {
							$k = \str_replace(' ', '_', $k);
						}
						$re = '/^\[([^\]]*?)\](\s*)/';	// change regex
					} elseif (!empty($matches[2])) {
						$path = '';	// space on the end... this is the end of the path
					}
					$path = \substr($path, \strlen($matches[0]));	// remaining path
					if ($path !== false) {
						if ($a) {
							$ptr[] = array();
							\end($ptr);
							$k = \key($ptr);
						} elseif (!isset($ptr[ $k ]) || \is_string($ptr[ $k ])) {
							$ptr[ $k ] = array();
						}
						$ptr = &$ptr[$k];
					} else {
						if ($a) {
							$ptr[] = $v;
						} else {
							$ptr[ $k ] = $v;
						}
						break;
					}
					$i++;
				}
				if (!empty($path)) {
					// still have remaining path... there were unmatched brackets
					$ptr = $v;
				}
			}
		}
		return $params;
	}
645242
protected function getOptVal(array $opts, $option)
    {
        $ploded = explode('.', $option);
        $arr = $opts;
        $val = null;
        while ($curr = array_shift($ploded)) {
            if (isset($arr[$curr])) {
                if (is_array($arr[$curr])) {
                    $arr = $arr[$curr];
                } else {
                    return $arr[$curr];
                }
            } else {
                return null;
            }
        }
    }
764187
public function curlGet($url, array $params = [], array $opts = [])
    {
        $params = $this->params($params);
        $queryStr = http_build_query($params);
        $opts[CURLOPT_POST] = false;
        $opts[CURLOPT_URL] = $queryStr ? "$url?$queryStr" : $url;

        return self::curl($opts);
    }
978083
public function get($userid = null, $opts = array())
	{
		$this->debug->groupCollapsed(__METHOD__, $userid);
		$opts = array_merge(array(
			'localtime' => true,	// true: return formatted date/time string for user's timezone
		), $opts);
		$vals_datetime = array('createdon','lastactivity','previousactivity');
		if (is_null($userid) || $userid == $this->userid) {
			$this->debug->log('use current user');
			$user = $this->user;
		} else {
			$ignore = array( 'password' );
			$joins = array();
			foreach ($this->cfg['userForeignKeys'] as $fka) {
				if (!empty($fka['getJoin'])) {
					$joins[] = $fka['getJoin'];
				}
				if (!empty($fka['ignoreKey'])) {
					$ignore[] = $fka['userCol'];
				}
			}
			$joins = !empty($joins)
				? ' '.implode(' ', $joins)
				: '';
			$query = 'SELECT * FROM `user`'
				.' LEFT JOIN `user_auth` USING (`userid`)'
				.$joins
				.' WHERE `user`.`userid` = '.$this->db->quoteValue($userid);
			$users = $this->db->query($query)[0];
			$this->debug->table($users, 'users');
			$user = $users[0];
			foreach ($vals_datetime as $k) {
				if (isset($user[$k])) {
					$user[$k] = strtotime($user[$k]);
				}
			}
			$query = 'SELECT `right` FROM `user_rights` WHERE `userid` = '.$this->db->quoteValue($userid);
			$rights = $this->db->query($query)[0];
			foreach ($rights as $k => $a) {
				$rights[$k] = $a['right'];
			}
			$user['previousactivity'] = $user['lastactivity'];
			$user['rights'] = $rights;
			foreach ($ignore as $k) {
				unset($user[$k]);
			}
		}
		if ($opts['localtime']) {
			foreach ($vals_datetime as $k) {
				$user[$k] = $this->datetimeLocal($user[$k]);
			}
		}
		$this->debug->log('user', $user);
		$this->debug->groupEnd();
		return $user;
	}
1102213
public function select($opts)
    {
        $objs = array();
        
        if (is_array($opts)) {
            foreach ($this as $obj) {
                foreach ($opts as $prop => $cond) {
                    if (!$obj->$prop || $obj->$prop != $cond)
                        continue;
                    $objs[] = $obj;
                }
            }
        } elseif ($opts instanceof Closure) {
            foreach ($this->members() as $obj) {
                $opts($obj) && $objs[] = $obj;
            }
        }
        
        return new self($objs);
    }
113489
public static function retrieve($id = null, $opts = null)
    {
        if (!$opts && is_string($id) && substr($id, 0, 3) === 'sk_') {
            $opts = $id;
            $id = null;
        }
        return self::_retrieve($id, $opts);
    }
568924
public function mount(array $opts) {
		if (!isset($opts['path']) || $opts['path'] === '') {
			return $this->setError('Path undefined.');;
		}
		
		$this->options = array_merge($this->options, $opts);
		$this->id = $this->driverId.(!empty($this->options['id']) ? $this->options['id'] : elFinder::$volumesCnt++).'_';
		$this->root = $this->normpathCE($this->options['path']);
		$this->separator = isset($this->options['separator']) ? $this->options['separator'] : DIRECTORY_SEPARATOR;
		
		// set server encoding
		if (!empty($this->options['encoding']) && strtoupper($this->options['encoding']) !== 'UTF-8') {
			$this->encoding = $this->options['encoding'];
		} else {
			$this->encoding = null;
		}
		
		$argInit = ($_SERVER['REQUEST_METHOD'] === 'POST')? !empty($_POST['init']) : !empty($_GET['init']);
		
		// session cache
		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
		}
		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
		
		// default file attribute
		$this->defaults = array(
			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
		);

		// root attributes
		$this->attributes[] = array(
			'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR).'$~',
			'locked'  => true,
			'hidden'  => false
		);
		// set files attributes
		if (!empty($this->options['attributes']) && is_array($this->options['attributes'])) {
			
			foreach ($this->options['attributes'] as $a) {
				// attributes must contain pattern and at least one rule
				if (!empty($a['pattern']) || count($a) > 1) {
					$this->attributes[] = $a;
				}
			}
		}

		if (!empty($this->options['accessControl']) && is_callable($this->options['accessControl'])) {
			$this->access = $this->options['accessControl'];
		}
		
		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
		$this->yesterday = $this->today-86400;
		
		// debug($this->attributes);
		if (!$this->init()) {
			return false;
		}
		
		// check some options is arrays
		$this->uploadAllow = isset($this->options['uploadAllow']) && is_array($this->options['uploadAllow'])
			? $this->options['uploadAllow']
			: array();
			
		$this->uploadDeny = isset($this->options['uploadDeny']) && is_array($this->options['uploadDeny'])
			? $this->options['uploadDeny']
			: array();

		if (is_string($this->options['uploadOrder'])) { // telephat_mode on, compatibility with 1.x
			$parts = explode(',', isset($this->options['uploadOrder']) ? $this->options['uploadOrder'] : 'deny,allow');
			$this->uploadOrder = array(trim($parts[0]), trim($parts[1]));
		} else { // telephat_mode off
			$this->uploadOrder = $this->options['uploadOrder'];
		}
			
		if (!empty($this->options['uploadMaxSize'])) {
			$size = ''.$this->options['uploadMaxSize'];
			$unit = strtolower(substr($size, strlen($size) - 1));
			$n = 1;
			switch ($unit) {
				case 'k':
					$n = 1024;
					break;
				case 'm':
					$n = 1048576;
					break;
				case 'g':
					$n = 1073741824;
			}
			$this->uploadMaxSize = intval($size)*$n;
		}
			
		$this->disabled = isset($this->options['disabled']) && is_array($this->options['disabled'])
			? $this->options['disabled']
			: array();
		
		$this->cryptLib   = $this->options['cryptLib'];
		$this->mimeDetect = $this->options['mimeDetect'];

		// find available mimetype detect method
		$type = strtolower($this->options['mimeDetect']);
		$type = preg_match('/^(finfo|mime_content_type|internal|auto)$/i', $type) ? $type : 'auto';
		$regexp = '/text\/x\-(php|c\+\+)/';
	
		if (($type == 'finfo' || $type == 'auto') 
		&& class_exists('finfo')) {
			$tmpFileInfo = @explode(';', @finfo_file(finfo_open(FILEINFO_MIME), __FILE__));
		} else {
			$tmpFileInfo = false;
		}
	
		if ($tmpFileInfo && preg_match($regexp, array_shift($tmpFileInfo))) {
			$type = 'finfo';
			$this->finfo = finfo_open(FILEINFO_MIME);
		} elseif (($type == 'mime_content_type' || $type == 'auto') 
		&& function_exists('mime_content_type')
		&& preg_match($regexp, array_shift(explode(';', mime_content_type(__FILE__))))) {
			$type = 'mime_content_type';
		} else {
			$type = 'internal';
		}
		$this->mimeDetect = $type;

		// load mimes from external file for mimeDetect == 'internal'
		// based on Alexey Sukhotin idea and patch: http://elrte.org/redmine/issues/163
		// file must be in file directory or in parent one 
		if ($this->mimeDetect == 'internal' && !self::$mimetypesLoaded) {
			self::$mimetypesLoaded = true;
			$this->mimeDetect = 'internal';
			$file = false;
			if (!empty($this->options['mimefile']) && file_exists($this->options['mimefile'])) {
				$file = $this->options['mimefile'];
			} elseif (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'mime.types')) {
				$file = dirname(__FILE__).DIRECTORY_SEPARATOR.'mime.types';
			} elseif (file_exists(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'mime.types')) {
				$file = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'mime.types';
			}

			if ($file && file_exists($file)) {
				$mimecf = file($file);

				foreach ($mimecf as $line_num => $line) {
					if (!preg_match('/^\s*#/', $line)) {
						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
							if (!isset(self::$mimetypes[$mime[$i]])) {
								self::$mimetypes[$mime[$i]] = $mime[0];
							}
						}
					}
				}
			}
		}

		$this->rootName = empty($this->options['alias']) ? $this->basenameCE($this->root) : $this->options['alias'];

		// This get's triggered if $this->root == '/' and alias is empty.
		// Maybe modify _basename instead?
		if ($this->rootName === '') $this->rootName = $this->separator;

		$root = $this->stat($this->root);
		
		if (!$root) {
			return $this->setError('Root folder does not exists.');
		}
		if (!$root['read'] && !$root['write']) {
			return $this->setError('Root folder has not read and write permissions.');
		}
		
		// debug($root);
		
		if ($root['read']) {
			// check startPath - path to open by default instead of root
			if ($this->options['startPath']) {
				$start = $this->stat($this->options['startPath']);
				if (!empty($start)
				&& $start['mime'] == 'directory'
				&& $start['read']
				&& empty($start['hidden'])
				&& $this->inpathCE($this->options['startPath'], $this->root)) {
					$this->startPath = $this->options['startPath'];
					if (substr($this->startPath, -1, 1) == $this->options['separator']) {
						$this->startPath = substr($this->startPath, 0, -1);
					}
				}
			}
		} else {
			$this->options['URL']     = '';
			$this->options['tmbURL']  = '';
			$this->options['tmbPath'] = '';
			// read only volume
			array_unshift($this->attributes, array(
				'pattern' => '/.*/',
				'read'    => false
			));
		}
		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
		$this->URL      = $this->options['URL'];
		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
			$this->URL .= '/';
		}

		$this->tmbURL   = !empty($this->options['tmbURL']) ? $this->options['tmbURL'] : '';
		if ($this->tmbURL && preg_match("|[^/?&=]$|", $this->tmbURL)) {
			$this->tmbURL .= '/';
		}
		
		$this->nameValidator = !empty($this->options['acceptedName']) && (is_string($this->options['acceptedName']) || is_callable($this->options['acceptedName']))
			? $this->options['acceptedName']
			: '';

		$this->_checkArchivers();
		// manual control archive types to create
		if (!empty($this->options['archiveMimes']) && is_array($this->options['archiveMimes'])) {
			foreach ($this->archivers['create'] as $mime => $v) {
				if (!in_array($mime, $this->options['archiveMimes'])) {
					unset($this->archivers['create'][$mime]);
				}
			}
		}
		
		// manualy add archivers
		if (!empty($this->options['archivers']['create']) && is_array($this->options['archivers']['create'])) {
			foreach ($this->options['archivers']['create'] as $mime => $conf) {
				if (strpos($mime, 'application/') === 0 
				&& !empty($conf['cmd']) 
				&& isset($conf['argc']) 
				&& !empty($conf['ext'])
				&& !isset($this->archivers['create'][$mime])) {
					$this->archivers['create'][$mime] = $conf;
				}
			}
		}
		
		if (!empty($this->options['archivers']['extract']) && is_array($this->options['archivers']['extract'])) {
			foreach ($this->options['archivers']['extract'] as $mime => $conf) {
				if (strpos($mime, 'application/') === 0
				&& !empty($conf['cmd']) 
				&& isset($conf['argc']) 
				&& !empty($conf['ext'])
				&& !isset($this->archivers['extract'][$mime])) {
					$this->archivers['extract'][$mime] = $conf;
				}
			}
		}

		$this->configure();
		// echo $this->uploadMaxSize;
		// echo $this->options['uploadMaxSize'];
		return $this->mounted = true;
	}
605667
function readStream(opts) {
    return db.createReadStream(ns.encodeRange(opts)).pipe(decodeStream(opts))
  }
403937
public function merge($opts)
    {
        $primary_opts = self::parse($opts);
        if ($primary_opts->apiKey === null) {
            $primary_opts->apiKey = $this->apiKey;
        }
        $primary_opts->headers = array_merge($this->headers, $primary_opts->headers);
        return $primary_opts;
    }