_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30100 | Type.parse | train | public static function parse(string $type): self
{
static $parser = null;
if (null === $parser) {
$parser = new Parser();
}
return $parser->parse($type);
} | php | {
"resource": ""
} |
q30101 | Type.from | train | public static function from($object): self
{
if ($object instanceof self) {
return $object;
}
if (\is_object($object)) {
$object = \get_class($object);
}
if (! \is_string($object)) {
throw new InvalidArgumentException('Cannot create a typ... | php | {
"resource": ""
} |
q30102 | PostVote.getCommentsForPostvote | train | public function getCommentsForPostvote($postvote)
{
$postvoteCommentMapper = $this->getPostVoteCommentMapper();
$comments = $postvoteCommentMapper->findBy(array('postvote' => $postvote), array('createdAt' => 'DESC'));
return $comments ;
} | php | {
"resource": ""
} |
q30103 | GeotFunctions.initUserData | train | private function initUserData() {
$this->user_data[ $this->cache_key ] = (object) [
'continent' => new \StdClass(),
'country' => new \StdClass(),
'state' => new \StdClass(),
'city' => new \StdClass(),
'geolocation' => new \StdClass(),
];
} | php | {
"resource": ""
} |
q30104 | GeotFunctions.debugData | train | private function debugData() {
$state = new \stdClass;
$state->names = isset( $_REQUEST['geot_state'] ) ? [ filter_var( $_REQUEST['geot_state'], FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ] : '';
$state->iso_code = isset( $_REQUEST['geot_state_code'] ) ? filter_var( $_REQUEST['geot_state_code'], FILTER_SA... | php | {
"resource": ""
} |
q30105 | GeotFunctions.setData | train | public function setData( $key, $property, $value ) {
$this->user_data[ $this->cache_key ]->$key->$property = $value;
$this->user_data[ $this->cache_key ] = new GeotRecord( $this->user_data[ $this->cache_key ] );
return $this->user_data[ $this->cache_key ];
} | php | {
"resource": ""
} |
q30106 | GeotFunctions.get | train | public function get( $key ) {
if ( ! in_array( $key, GeotRecord::getValidRecords() ) ) {
return 'Invalid GeotRecord classname provided. Valids ones are: ' . implode( ',', GeotRecord::getValidRecords() );
}
if ( $this->user_data[ $this->cache_key ] === null ) {
$this->getUserData();
}
if ( isset( $this... | php | {
"resource": ""
} |
q30107 | GeotFunctions.getCountryByIsoCode | train | private function getCountryByIsoCode( $iso_code ) {
global $wpdb;
$query = "SELECT * FROM {$wpdb->base_prefix}geot_countries WHERE iso_code = %s";
$result = $wpdb->get_row( $wpdb->prepare( $query, array( $iso_code ) ), ARRAY_A );
$country = new \StdClass();
$country->names = new \StdCl... | php | {
"resource": ""
} |
q30108 | GeotFunctions.getFallbackCountry | train | private function getFallbackCountry() {
if ( empty( $this->opts['fallback_country'] ) ) {
$this->opts['fallback_country'] = 'US';
}
$record = (object) [
'continent' => new \StdClass(),
'country' => new \StdClass(),
'state' => new \StdClass(),
'city' => new \StdClass(),
'geolo... | php | {
"resource": ""
} |
q30109 | GeotFunctions.createRocketCookies | train | public function createRocketCookies() {
if ( apply_filters( 'geot/disable_cookies', false ) ) {
return;
}
if ( ! $this->user_data[ $this->cache_key ] instanceof GeotRecord ) {
return;
}
$country = isset($this->user_data[ $this->cache_key ]->country->iso_code) ? $this->user_data[ $this->cache_key ]->co... | php | {
"resource": ""
} |
q30110 | GeotFunctions.set_defaults | train | private function set_defaults() {
$args = geot_settings();
$this->opts = wp_parse_args( $args, [
'license' => '',
'debug_mode' => false,
// similar to disable sessions but also invalidates cookies
'cache_mode' => false,
// php sessions
'bots_country' => '',
//... | php | {
"resource": ""
} |
q30111 | GeotFunctions.check_active_user | train | private function check_active_user() {
if (
( ! isset( $this->opts['wpengine'] ) || $this->opts['wpengine'] != '1' || getenv( 'HTTP_GEOIP_COUNTRY_CODE' ) === false )
&& ( ! isset( $this->opts['maxmind'] ) || $this->opts['maxmind'] != '1' || ! file_exists( maxmind_db() ) )
&& ( ! isset( $this->opts['ip2locat... | php | {
"resource": ""
} |
q30112 | GeotFunctions.targetZip | train | private function targetZip( $places, $exclude_places ) {
$target = false;
$user_place = $this->get( 'city' );
if ( ! $user_place ) {
return apply_filters( 'geot/target_zip/return_on_user_null', false );
}
if ( count( $places ) > 0 ) {
foreach ( $places as $zip ) {
if ( strtolower( $user_place->... | php | {
"resource": ""
} |
q30113 | GeotFunctions.cleanResponse | train | private function cleanResponse( $response ) {
if ( $this->opts['cache_mode'] ) {
$this->session->set( 'geot_data', $response );
}
$this->user_data[ $this->cache_key ] = new GeotRecord( $response );
return $this->user_data[ $this->cache_key ];
} | php | {
"resource": ""
} |
q30114 | GeotFunctions.maxmind | train | private function maxmind() {
$reader = new Reader( $this->opts['maxmind_db'] );
try {
$record = $reader->get( $this->ip );
if ( empty( $record ) ) {
throw new AddressNotFoundException( 'Ip Address not found' );
}
$reader->close();
return $this->cleanResponse( RecordConverter::maxmindRecord( $re... | php | {
"resource": ""
} |
q30115 | GeotFunctions.ip2location | train | private function ip2location() {
$db = new Database( $this->opts['ip2location_db'], $this->opts['ip2location_method'] );
try {
$record = $db->lookup( $this->ip, Database::ALL );
return $this->cleanResponse( RecordConverter::ip2locationRecord( $record ) );
} catch ( \Exception $e ) {
throw new GeotExcept... | php | {
"resource": ""
} |
q30116 | GeotFunctions.checkLocale | train | private function checkLocale( $force_locale = null ) {
if ( ! $this->user_data[ $this->cache_key ] instanceof GeotRecord || apply_filters( 'geot/cancel_locale_check', false ) ) {
return;
}
$locale = get_locale();
// get language part of locale
$wp_locale = strstr( $locale, '_' ) === false ? $locale : strs... | php | {
"resource": ""
} |
q30117 | GeotFunctions.treatAsBot | train | private function treatAsBot() {
$ret = false;
// exclude login page and some others
$script = isset( $_SERVER['PHP_SELF'] ) ? basename( $_SERVER['PHP_SELF'] ) : '';
if ( in_array( $script, array( 'wp-login.php', 'xmlrpc.php', 'wp-cron.php' ) ) ) {
$ret = true;
}
// Some more checks in case above fa... | php | {
"resource": ""
} |
q30118 | GeotFunctions.user_whitelisted | train | private function user_whitelisted() {
$ret = false;
// Ips check
$settings = geot_settings();
if( isset( $settings['fallback_country_ips'] ) && in_array( $this->ip, textarea_to_array( $settings['fallback_country_ips'] ) ) ) {
$ret = true;
}
return apply_filters( 'geot/treat_request_as_whitelisted', $re... | php | {
"resource": ""
} |
q30119 | Http.routes | train | public static function routes(Router $router, array $files = null)
{
$files = $files ? $files : Kernel::config('route.files');
foreach ($files as $file) {
$router->load(path(true, $file));
}
return $router;
} | php | {
"resource": ""
} |
q30120 | PbjxToken.verify | train | public function verify(string $secret): bool
{
try {
$withoutSig = substr($this->token, 0, strrpos($this->token, '.'));
$expected = hash_hmac(self::HASH_HMAC_ALGO, $withoutSig, $secret, true);
return hash_equals($expected, $this->signature);
} catch (\Throwable $e... | php | {
"resource": ""
} |
q30121 | GeotSettings.enqueue_styles | train | public function enqueue_styles() {
global $pagenow;
if ( 'post.php' == $pagenow ) {
wp_enqueue_style( 'wp-jquery-ui-dialog' );
}
$version = \GeotFunctions\get_version();
wp_enqueue_style( 'geot', $this->plugin_url . 'css/geotarget.css', array(), $version, 'all' );
} | php | {
"resource": ""
} |
q30122 | GeotSettings.enqueue_scripts | train | public function enqueue_scripts() {
$version = \GeotFunctions\get_version();
wp_enqueue_script( 'geot-selectize', $this->plugin_url . 'js/selectize.min.js', array( 'jquery' ), $version, false );
wp_enqueue_script( 'geot-chosen', $this->plugin_url . 'js/chosen.jquery.min.js', array( 'jquery' ), $version, false );
... | php | {
"resource": ""
} |
q30123 | GeotSettings.ajax_check_license | train | public function ajax_check_license() {
if ( empty( $_POST['license'] ) ) {
echo json_encode( [ 'error' => 'Please enter the license' ] );
die();
}
$license = esc_attr( $_POST['license'] );
$response = $this->is_valid_license( $license );
$opts = geot_settings();
$opts['license'] = $licens... | php | {
"resource": ""
} |
q30124 | GeotSettings.is_valid_license | train | function is_valid_license( $license ) {
try {
$response = GeotargetingWP::checkLicense( $license );
$result = json_decode( $response );
// update license
if ( isset( $result->success ) ) {
update_option( 'geot_license_active', 'valid' );
} else {
delete_option( 'geot_license_active' );
}
... | php | {
"resource": ""
} |
q30125 | GeotSettings.tabs | train | public function tabs() {
$tabs = $this->get_tabs();
echo '<ul class="geot-admin-tabs">';
foreach ( $tabs as $id => $tab ) {
$active = $id === $this->view ? 'active' : '';
$name = $tab['name'];
$link = add_query_arg( 'view', $id, admin_url( 'admin.php?page=geot-settings' ) );
echo '<li><a href="... | php | {
"resource": ""
} |
q30126 | GeotSettings.save_settings | train | public function save_settings() {
if ( isset( $_POST['geot_nonce'] ) && wp_verify_nonce( $_POST['geot_nonce'], 'geot_save_settings' ) ) {
$settings = $_POST['geot_settings'] ;
if ( isset( $_FILES['geot_settings_json'] ) && 'application/json' == $_FILES['geot_settings_json']['type'] ) {
$file = file_ge... | php | {
"resource": ""
} |
q30127 | Handler.apply | train | public function apply(Request $request, Match $match, array $middlewares = [])
{
// get the pipe of route selected by router
$pipe = $match->getOption('pipe');
// check if pipe is valid
if (!is_array($pipe)) {
// early return
return $this->resolve($request, $... | php | {
"resource": ""
} |
q30128 | ViewRenderer.render | train | public function render(array $views)
{
if (!array_key_exists('views', $views)) {
$views['views'] = array($views);
}
$content = '';
foreach ($views['views'] as $view) {
$content .= $this->renderView($view);
}
return $content;
} | php | {
"resource": ""
} |
q30129 | ImageOptions.copyTransparency | train | public static function copyTransparency($dstImg, $srcImg)
{
$tIndex = imagecolortransparent($srcImg);
$tColor = array('red' => 255, 'green' => 255, 'blue' => 255);
if ($tIndex >= 0) {
$tColor = imagecolorsforindex($srcImg, $tIndex);
}
$tIndex = imagecolorallocate(... | php | {
"resource": ""
} |
q30130 | Kernel.handleRequest | train | public function handleRequest()
{
list($route, $target) = $this->bootForRequest();
$response = $this->runRequest($route, $target);
$this->sendResponse($response);
$this->terminateRequest();
} | php | {
"resource": ""
} |
q30131 | Kernel.bootForRequest | train | private function bootForRequest()
{
$request = Request::getInstance();
//Set error configuration and logging options
$this->setErrorConfigurations($request);
//Match routes
$route = Router::getInstance()->matchRequest($request);
abort_unless($route instanceof Route,... | php | {
"resource": ""
} |
q30132 | Kernel.getControllerLogic | train | private function getControllerLogic($action)
{
list($class, $method) = getClassAndMethodFromString($action);
$controllerClass = fixClassname(Router::$namespace, $class);
//Todo: Dependency Injection
/* @var $controller Controller */
$controller = new $controllerClass();
... | php | {
"resource": ""
} |
q30133 | Kernel.bootForJob | train | private function bootForJob()
{
if (!isCLI()) {
abort(500, "Somehow, you are not running this from a command line interface.");
}
$this->setErrorConfigurations();
//Match routes
$args = Args::parse();
$target = CLIRouter::getInstance()->matchCommand($arg... | php | {
"resource": ""
} |
q30134 | Index.client | train | public function client($client, $secret, $redirect, $requestUrl, $accessUrl)
{
//argument test
Argument::i()
//argument 1 must be a string
->test(1, 'string')
//argument 2 must be a url
->test(2, 'string')
//argument 3 must be a url
... | php | {
"resource": ""
} |
q30135 | Index.desktop | train | public function desktop($client, $secret, $redirect, $requestUrl, $accessUrl)
{
//argument test
Argument::i()
//argument 1 must be a string
->test(1, 'string')
//argument 2 must be a url
->test(2, 'string')
//argument 3 must be a url
... | php | {
"resource": ""
} |
q30136 | SetFormatByAcceptHeaderAspect.setRequestFormatByAcceptHeader | train | public function setRequestFormatByAcceptHeader(JoinPointInterface $joinPoint)
{
/** @var \Neos\Flow\Mvc\ActionRequest $actionRequest */
$actionRequest = $joinPoint->getProxy();
/**
* The Accept header should be the only one to determine which resulting
* data format the c... | php | {
"resource": ""
} |
q30137 | Ivona.read | train | public function read($text)
{
$payload = $this->getPayload($text);
$handle = $this->getHandle();
$handle->setUrl($payload->getServiceUrl());
$handle->setOption(CURLOPT_RETURNTRANSFER, 1);
$handle->setOption(CURLOPT_POST, true);
$handle->setOption(CURLOPT_POSTFIELDS,... | php | {
"resource": ""
} |
q30138 | Entity.save | train | public function save()
{
$data = [];
$values = [];
foreach ($this->getAlias() as $field => $alias) {
$method = 'get' . ucfirst($alias);
$value = $this->$method();
if (null === $value) {
continue;
}
$data[$field] = '... | php | {
"resource": ""
} |
q30139 | RemoteCompiler.setRequestHandler | train | public function setRequestHandler($handler)
{
$this->requestHandler = $handler;
$this->requestHandler->setUri($this->url)
->setMethod($this->method);
$this->requestHandler->getUri()->setPort($this->port);
return $this;
} | php | {
"resource": ""
} |
q30140 | RemoteCompiler.getRequestHandler | train | public function getRequestHandler()
{
if (!isset($this->requestHandler)) {
$requestHandler = new \Zend\Http\Client();
$requestHandler->setOptions(array(
'timeout'=> 60
));
$this->setRequestHandler($requestHandler);
}
... | php | {
"resource": ""
} |
q30141 | RemoteCompiler.parseXml | train | protected function parseXml($xml)
{
$data = array();
foreach ($xml->children() as $name => $child) {
if (count($child->children()) > 0) {
$value = $this->parseXml($child);
} else {
$value = (string) $child;
}
... | php | {
"resource": ""
} |
q30142 | RemoteCompiler.buildResponse | train | protected function buildResponse($data)
{
$response = $this->getCompilerResponse();
foreach ($data as $item) {
if (!isset($item['tag']) && !isset($item['value'])) {
continue;
}
if (isset($item['tag']) && ($item['tag'] == 'errors' || $ite... | php | {
"resource": ""
} |
q30143 | RemoteCompiler.encodeData | train | protected function encodeData($params)
{
$data = array();
foreach ($params as $key => $value) {
$key = preg_replace('/_[0-9]$/', '', $key);
$data[] = $key . '=' . urlencode($value);
}
return implode('&', $data);
} | php | {
"resource": ""
} |
q30144 | RemoteCompiler.compile | train | public function compile()
{
$requestHandler = $this->getRequestHandler();
$encodedData = $this->encodeData($this->getParams());
$requestHandler->setRawBody($encodedData);
$response = $requestHandler->send();
$xml = new \SimpleXMLElement($response->getBody());
... | php | {
"resource": ""
} |
q30145 | DoctrineObjectConstructor.getObjectManager | train | protected function getObjectManager(ClassMetadata $metadata): ?ObjectManager
{
foreach ($this->managerRegistryCollection as $managerRegistry) {
if ($objectManager = $managerRegistry->getManagerForClass($metadata->getName())) {
return $objectManager;
}
}
... | php | {
"resource": ""
} |
q30146 | DoctrineObjectConstructor.loadFromObjectManager | train | protected function loadFromObjectManager(ClassMetadata $metadata, $data)
{
// Locate possible ObjectManager
if (null === $objectManager = $this->getObjectManager($metadata)) {
return null;
}
// Locate possible ClassMetadata
$classMetadataFactory = $objectManager-... | php | {
"resource": ""
} |
q30147 | ImageConverter.convert | train | public function convert($img, $outputFormat, $targetPath, $quality = null)
{
ImageFile::save(
$targetPath,
ImageFile::get($img),
ImageFile::getType($img, $outputFormat),
$quality
);
} | php | {
"resource": ""
} |
q30148 | ActiveDataProvider.setPageFrom | train | protected function setPageFrom( QueryInterface $query )
{
if ( $this->pageFromPk )
{
$class = $this->query->modelClass;
$pks = $class::primaryKey();
if ( count($pks) > 1) {
throw new NotSupportedException('The "page-from-pk" filter can not be apply... | php | {
"resource": ""
} |
q30149 | Response.content | train | public function content($content = null)
{
if ($content !== null) {
if (!is_scalar($content) && !is_callable([$content, '__toString'])) {
throw new ResponseException('Response content must be a scalar or object with __toString() method "' . $this->getType($content) . '" given.');... | php | {
"resource": ""
} |
q30150 | Response.status | train | public function status($status = null)
{
if ($status !== null) {
if (!isset($this->statusTexts[$status])) {
throw new ResponseException('Unsupported status code "' . $status . '"');
}
$this->status = (int) $status;
if ($this->content === null... | php | {
"resource": ""
} |
q30151 | Response.protocol | train | public function protocol($protocol = null)
{
if ($protocol !== null) {
$this->protocol = $protocol;
}
return $this->protocol;
} | php | {
"resource": ""
} |
q30152 | RequestRecordStorage.createRequest | train | protected function createRequest($pid, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0)
{
if ($timeout > 0.0)
{
$timeout = $timeout * 1000 + TimeSupport::now();
}
return new RequestRecord($pid, $success, $failure, $cancel, $tim... | php | {
"resource": ""
} |
q30153 | RequestRecordStorage.expireRequests | train | protected function expireRequests()
{
$now = TimeSupport::now();
$expiredReqs = [];
foreach ($this->reqs as $pid=>$request)
{
if ($now >= $request->getTimeout())
{
$expiredReqs[] = $request;
}
}
foreach ($expiredRe... | php | {
"resource": ""
} |
q30154 | AclLibrary.getProfileAcl | train | public static function getProfileAcl($profile)
{
$acl = new AclLibrary();
// get all resources in application
$resources = Resource::all();
// get all permissions fron this profile
$permissions = Permission::getRecord($profile);
// set profile id
... | php | {
"resource": ""
} |
q30155 | AclLibrary.getJsActionsAllowed | train | public function getJsActionsAllowed($profile, $resource, $actions)
{
$actionsAllowed = '[';
$flag = false;
foreach ($actions as $action)
{
if(parent::isAllowed($profile, $resource, $action->id_008))
{
if($flag) $actionsAllowed .= ',';
... | php | {
"resource": ""
} |
q30156 | AclLibrary.allows | train | public function allows($resource = null, $privilege = null, $profile = null)
{
if($profile === null)
$profile = auth()->guard('pulsar')->user()->profile_id_010;
try
{
return parent::isAllowed($profile, $resource, $privilege);
}
catch(Exception\Invalid... | php | {
"resource": ""
} |
q30157 | Token.authenticate | train | public function authenticate($auth = null)
{
if ($auth !== null) {
$this->auth = $auth;
}
return $this->auth;
} | php | {
"resource": ""
} |
q30158 | Token.user | train | public function user($user = null)
{
if ($user !== null) {
$this->user = $user;
}
return $this->user;
} | php | {
"resource": ""
} |
q30159 | RutHelper.cleanRut | train | public static function cleanRut(string $rut, bool $forceUppercase = true)
{
// Filter the RUT string and return only numbers and verification digit.
$filtered = preg_filter('/(?!\d|k)./i', '', $rut) ?? $rut;
// If the filtered RUT is not empty and over the 6 characters, we're good.
... | php | {
"resource": ""
} |
q30160 | RutHelper.separateRut | train | public static function separateRut(string $rut, bool $uppercase = true)
{
// Throw an exception if after cleaning the RUT we receive null, since
// we cannot separate an empty string, thus making the resulting
// array impossible to return. Also, it makes it catchable.
if (empty($cle... | php | {
"resource": ""
} |
q30161 | RutHelper.validate | train | public static function validate(...$ruts)
{
if (is_array($ruts[0]) && func_num_args() === 1) {
$ruts = $ruts[0];
}
return self::performValidate($ruts);
} | php | {
"resource": ""
} |
q30162 | RutHelper.validateStrict | train | public static function validateStrict(...$ruts)
{
if (is_array($ruts[0]) && func_num_args() === 1) {
$ruts = $ruts[0];
}
return self::performValidateStrict($ruts);
} | php | {
"resource": ""
} |
q30163 | RutHelper.performValidate | train | protected static function performValidate(array $ruts)
{
foreach ($ruts as $rut) {
if (!self::validateRut($rut)) {
return false;
};
}
return true;
} | php | {
"resource": ""
} |
q30164 | RutHelper.performValidateStrict | train | protected static function performValidateStrict(array $ruts)
{
foreach ($ruts as $rut) {
if (!preg_match('/(\d){1,2}.\d{3}.\d{3}\-[\dkK]/', $rut)) {
return false;
}
if (!self::validateRut($rut)) {
return false;
};
}
... | php | {
"resource": ""
} |
q30165 | RutHelper.validateRut | train | protected static function validateRut(string $rut)
{
try {
[$num, $vd] = self::separateRut($rut);
} catch (InvalidRutException $exception) {
return false;
}
if ($vd != self::getVd($num)) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q30166 | RutHelper.isEqual | train | public static function isEqual(...$ruts)
{
// If the user passed down one single argument as an array, we will use
// that and unwrap it.
if (is_array($ruts[0]) && func_num_args() === 1) {
$ruts = $ruts[0];
}
// First, restore the keys of the array.
$ruts... | php | {
"resource": ""
} |
q30167 | RutHelper.filter | train | public static function filter(...$ruts)
{
if (is_array($ruts[0]) && func_num_args() === 1) {
$ruts = $ruts[0];
}
return array_filter($ruts, function ($rut) {
return self::validate($rut);
});
} | php | {
"resource": ""
} |
q30168 | RutHelper.isPerson | train | public static function isPerson(string $rut)
{
list($num) = self::separateRut($rut);
return $num < self::COMPANY_RUT_BASE && $num > 1000000;
} | php | {
"resource": ""
} |
q30169 | RutHelper.getVd | train | public static function getVd(int $num)
{
$i = 2;
$sum = 0;
foreach (array_reverse(str_split($num)) as $v) {
if ($i === 8) $i = 2;
$sum += $v * $i;
++$i;
}
$dig = 11 - ($sum % 11);
if ($dig === 11) $dig = 0;
if ($dig === 1... | php | {
"resource": ""
} |
q30170 | Quiz.sortQuestion | train | public function sortQuestion($data)
{
$arr = explode(",", $data);
foreach ($arr as $k => $v) {
$question = $this->getQuizQuestionMapper()->findById($v);
$question->setPosition($k);
$this->getQuizQuestionMapper()->update($question);
}
return true;... | php | {
"resource": ""
} |
q30171 | WidgetDataObject.onBeforeWrite | train | public function onBeforeWrite() {
parent::onBeforeWrite();
$has_one = $this->owner->has_one();
// Loop over each WidgetArea
foreach ($has_one as $name => $class) {
if ($class == 'WidgetArea') {
// Create the WidgetArea if it not exist
$dbName = $name . 'ID';
$wa = $this->owner->$name();
if (... | php | {
"resource": ""
} |
q30172 | Payload.getHeaders | train | public function getHeaders()
{
$this->getOptions()->getAuthenticate()->setPostData($this->getPayload());
$headers = [
'Content-Type: application/json',
'Host: tts.eu-west-1.ivonacloud.com',
'User-Agent: ' . $this->getOptions()->getUserAgent()
];
... | php | {
"resource": ""
} |
q30173 | Payload.createPayload | train | public function createPayload()
{
$payloadArray = (object)array();
$payloadArray->Input['Data'] = $this->getQueryText();
$payloadArray->Input['Type'] = 'text/plain';
$payloadArray->OutputFormat['Codec'] = $this->getOptions()->getOutputFormatCodec();
$payloadArray->OutputForm... | php | {
"resource": ""
} |
q30174 | Payload.checkServiceType | train | protected function checkServiceType($serviceType)
{
$reflection = new \ReflectionObject($this);
$constants = $reflection->getConstants();
if (!in_array($serviceType, $constants)) {
throw new RuntimeException('The type of service does not support: ' . $serviceType);
}
... | php | {
"resource": ""
} |
q30175 | UploaderComponent.findTargetFilename | train | protected function findTargetFilename($target)
{
//If the file already exists, adds a numeric suffix
if (file_exists($target)) {
$dirname = dirname($target) . DS;
$filename = pathinfo($target, PATHINFO_FILENAME);
$extension = pathinfo($target, PATHINFO_EXTENSION);... | php | {
"resource": ""
} |
q30176 | UploaderComponent.mimetype | train | public function mimetype($acceptedMimetype)
{
is_true_or_fail($this->file, __d('me_tools', 'There are no uploaded file information'), RuntimeException::class);
//Changes magic words
switch ($acceptedMimetype) {
case 'image':
$acceptedMimetype = ['image/gif', 'ima... | php | {
"resource": ""
} |
q30177 | Tag.all | train | public function all($tag) {
$i = $this->image = new Image;
$images = $this->get($tag, 'basename');
$results = array();
foreach($images as $image) {
try {
$results[] = $i->get($image['uid']);
}
catch(\Exception $e) {
if ($e->getCode() != 403) {
throw new \Exception($e);
}
}
}
ret... | php | {
"resource": ""
} |
q30178 | Tag.removeAll | train | public function removeAll($id, $sid = NULL) {
$user = new User;
$current = $user->current($sid);
if ($current['type'] < 2) throw new \JohnVanOrange\Core\Exception\NotAllowed('Must be an admin to access method', 401);
$query = new \Peyote\Delete('resources');
$query->where('value', '=', $id)
->where('... | php | {
"resource": ""
} |
q30179 | BuildContainer.build | train | function build(Container $container)
{
if (! $container instanceof Container )
throw new \Exception(sprintf(
'Container must instanceof "ContainerManager", you given "%s".'
, (is_object($container)) ? get_class($container) : gettype($container)
));
... | php | {
"resource": ""
} |
q30180 | BuildContainer.setExtends | train | function setExtends($options)
{
foreach ($options as $key => $v) {
if (!is_int($key))
$v = array($key => $v);
$this->addExtend($v);
}
return $this;
} | php | {
"resource": ""
} |
q30181 | BlockManagerJsonBase.decodeJsonContent | train | public static function decodeJsonContent($block, $assoc = true)
{
$content = $block;
$blockType = null;
if (is_object($block)) {
$content = $block->getContent();
$blockType = $block->getType();
}
$content = json_decode($content, $assoc);
if (n... | php | {
"resource": ""
} |
q30182 | StructureManager.buildStructure | train | public static function buildStructure($array, Structure $structure)
{
switch ($structure->getType()) {
case Structure::TYPE_LIST:
$result = self::buildList($array, $structure);
break;
case Structure::TYPE_ARRAY:
$result = self::buildArr... | php | {
"resource": ""
} |
q30183 | StructureManager.__s_list2 | train | private static function __s_list2($list)
{
$structure = new Structure(Structure::TYPE_LIST, '-', Structure::FOUR_SPACE_TAB);
return static::buildStructure($list, $structure);
} | php | {
"resource": ""
} |
q30184 | StructureManager.__s_array | train | private static function __s_array($array)
{
$border = new Border(Border::TYPE_FRAME);
$structure = new Structure(Structure::TYPE_ARRAY, '', null, '|', $border);
return static::buildStructure($array, $structure);
} | php | {
"resource": ""
} |
q30185 | StructureManager.buildList | train | private static function buildList(array $list, Structure $structure)
{
$insertTab = ($structure->getTab()) ? true : false;
$result = '';
foreach ($list as $value) {
$result .= ($insertTab ? $structure->getTab() : '') . $structure->getIteratorCharacter() . ' ' . $value . PHP_EOL;... | php | {
"resource": ""
} |
q30186 | StructureManager.buildArray | train | private static function buildArray(array $array, Structure $structure)
{
$maxKeyLength = Util::getMaxKeyLength($array);
$maxValueLength = Util::getMaxValueLength($array);
$drawBorders = ($structure->getBorder()) ? true : false;
$insertTab = ($structure->getTab()) ? true : f... | php | {
"resource": ""
} |
q30187 | CssParser.registerPseudoFilter | train | public function registerPseudoFilter($name, $object, $entity = "value")
{
if (is_callable($object)) {
// user defined pseudo-filter
$this->_pseudoFilters[$name] = array(
"classname" => "CssParserFilterPseudoUserDefined",
"user_def_function" => $object,... | php | {
"resource": ""
} |
q30188 | CssParser.registerCombinator | train | public function registerCombinator($name, $object)
{
if (is_callable($object)) {
$this->_combinators[$name] = array(
"classname" => "CssParserCombinatorUserDefined",
"user_def_function" => $object
);
} else {
$this->_combinators[$na... | php | {
"resource": ""
} |
q30189 | CssParser.combinator | train | protected function combinator()
{
$ret = false;
$combinatorNames = array_keys($this->_combinators);
if (list($name) = $this->in($combinatorNames)) {
$combinator = $this->_combinators[$name];
$ret = CssParserCombinatorFactory::getInstance(
$combinator[... | php | {
"resource": ""
} |
q30190 | CssParser.value | train | protected function value()
{
if ( !(list($value) = $this->str())
&& !(list($value) = $this->number())
&& !(list($value) = $this->match(CssParser::IDENTIFIER))
) {
return false;
}
return array($value);
} | php | {
"resource": ""
} |
q30191 | CssParser.pseudoFilter | train | protected function pseudoFilter()
{
if (!$this->match("/^\:/")) {
return false;
}
if (!list($name) = $this->is("identifier")) {
throw new TextParserException("Invalid identifier", $this);
}
$filter = Arr::get($this->_pseudoFilters, $name, null);
... | php | {
"resource": ""
} |
q30192 | CssParser.attrFilter | train | protected function attrFilter()
{
$attrName = "";
$op = "";
$value = "";
if (!$this->match("/^\[/")) {
return false;
}
if (!list($attrName) = $this->is("identifier")) {
throw new TextParserException("Invalid identifier", $this);
}
... | php | {
"resource": ""
} |
q30193 | CssParser.idFilter | train | protected function idFilter()
{
$id = "";
if (!$this->match("/^\#/")) {
return false;
}
if (!list($id) = $this->is("identifier")) {
throw new TextParserException("Invalid identifier", $this);
}
return new CssParserFilterId($id);
} | php | {
"resource": ""
} |
q30194 | CssParser.classFilter | train | protected function classFilter()
{
$className = "";
if (!$this->match("/^\./")) {
return false;
}
if (!list($className) = $this->is("identifier")) {
throw new TextParserException("Invalid identifier", $this);
}
return new CssParserFilterClass(... | php | {
"resource": ""
} |
q30195 | CssParser.filter | train | protected function filter()
{
$filter = null;
if ( (!$filter = $this->is("classFilter"))
&& (!$filter = $this->is("idFilter"))
&& (!$filter = $this->is("attrFilter"))
&& (!$filter = $this->is("pseudoFilter"))
) {
return false;
}
... | php | {
"resource": ""
} |
q30196 | CssParser.element | train | protected function element()
{
$element = null;
$filter = null;
$tagName = "*";
// ignores left spaces
$this->match("\s+");
if ( (list($name) = $this->eq("*"))
|| (list($name) = $this->is("identifier"))
) {
$tagName = $name? $name :... | php | {
"resource": ""
} |
q30197 | CssParser.factor | train | protected function factor()
{
$combinator = null;
if ($combinator = $this->is("combinator")) {
if (!$element = $this->is("element")) {
throw new TextParserException("Invalid expression", $this);
}
} elseif ($element = $this->is("element")) {
... | php | {
"resource": ""
} |
q30198 | CssParser.selector | train | protected function selector()
{
$factor = null;
// first factor
if (!$factor = $this->is("factor")) {
return false;
}
$selector = new CssParserModelSelector();
$selector->addFactor($factor);
// additional factors
while ($factor = $this->i... | php | {
"resource": ""
} |
q30199 | CssParser.selectorList | train | protected function selectorList()
{
$nodes = array();
do {
if (!$selector = $this->is("selector")) {
// throw new TextParserException("Invalid expression", $this);
break;
}
$nodes = Dom::mergeNodes(
$nodes,
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.