sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
private function revokeMembership($user)
{
try {
foreach($user->membershipList as $group) {
if ($group->resync_on_login) {
$user->membershipList()->detach($group);
}
}
} catch (\Exception $ex) {
Log::error('Exc... | Revoke membership to all local group that are marked with
'resync_on_login' as 1 or true.
@param $user The user to revoke group membership from. | entailment |
private function replicateMembershipFromLDAP($user)
{
$adldap = false;
try {
$username = $user->username;
$groupModel = $this->createGroupModel();
$ldapConOp = $this->GetLDAPConnectionOptions();
$ldapRecursive = Settings::get('eloquent-ldap.recursive_... | Grants membership to local groups for each LDAP/AD group that the user
is a member of. See the option "LDAP_RECURSIVE_GROUPS" to enable
deep LDAP/AD group probe.
NOTE: This will not maintain the hierarchical structure of the groups,
instead the structure will be 'flattened'. If you want to maintain
the hierarchical str... | entailment |
private function validateLDAPCredentials(array $credentials)
{
$credentialsValidated = false;
$adldap = false;
try {
$userPassword = $credentials['password'];
$userName = $credentials['username'];
$ldapConOp = $this->GetLDAPConnectionOptions();
... | Validates the credentials against the configured LDAP/AD server.
The credentials are passed in an array with the keys 'username'
and 'password'.
@param array $credentials The credentials to validate.
@return boolean | entailment |
private function handleLDAPError(\Adldap\Adldap $adldap)
{
if (false != $adldap) {
// May be helpful for finding out what and why went wrong.
$adLDAPError = $adldap->getConnection()->getLastError();
if ("Success" != $adLDAPError) {
Log::error('Problem with... | Logs the last LDAP error if it is not "Success".
@param array $adldap The instance of the adLDAP object to check for
error. | entailment |
public function fire()
{
$url = $this->argument('url');
// Remote request.
$invoke = (preg_match('/^http(s)?:/', $url)) ? 'invokeRemote' : 'invoke';
// Method to call.
$method = $this->option('request');
$method = strtolower($method);
$method = (in_array($method, array('get', 'post', 'put', 'delete', '... | Execute the console command.
@return mixed | entailment |
public function instantiate($className)
{
if ($cloneable = self::$cachedCloneables->$className) {
return clone $cloneable;
}
$factory = self::$cachedInstantiators->$className;
/* @var $factory Closure */
return $factory();
} | {@inheritDoc} | entailment |
public function buildFactory($className)
{
$reflectionClass = $this->getReflectionClass($className);
if ($this->isInstantiableViaReflection($reflectionClass)) {
return function () use ($reflectionClass) {
return $reflectionClass->newInstanceWithoutConstructor();
... | @internal
@private
Builds a {@see \Closure} capable of instantiating the given $className without
invoking its constructor.
This method is only exposed as public because of PHP 5.3 compatibility. Do not
use this method in your own code
@param string $className
@return Closure | entailment |
private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, $serializedString)
{
set_error_handler(function ($code, $message, $file, $line) use ($reflectionClass, & $error) {
$error = UnexpectedValueException::fromUncleanUnSerialization(
$reflectionC... | @param ReflectionClass $reflectionClass
@param string $serializedString
@throws UnexpectedValueException
@return void | entailment |
private function isInstantiableViaReflection(ReflectionClass $reflectionClass)
{
if (\PHP_VERSION_ID >= 50600) {
return ! ($reflectionClass->isInternal() && $reflectionClass->isFinal());
}
return \PHP_VERSION_ID >= 50400 && ! $this->hasInternalAncestors($reflectionClass);
} | @param ReflectionClass $reflectionClass
@return bool | entailment |
private function getSerializationFormat(ReflectionClass $reflectionClass)
{
if ($this->isPhpVersionWithBrokenSerializationFormat()
&& $reflectionClass->implementsInterface('Serializable')
) {
return self::SERIALIZATION_FORMAT_USE_UNSERIALIZER;
}
return self::... | Verifies if the given PHP version implements the `Serializable` interface serialization
with an incompatible serialization format. If that's the case, use serialization marker
"C" instead of "O".
@link http://news.php.net/php.internals/74654
@param ReflectionClass $reflectionClass
@return string the serialization fo... | entailment |
private function getInstantiatorsMap()
{
$that = $this; // PHP 5.3 compatibility
return self::$cachedInstantiators = self::$cachedInstantiators
?: new CallbackLazyMap(function ($className) use ($that) {
return $that->buildFactory($className);
});
} | Builds or fetches the instantiators map
@return CallbackLazyMap | entailment |
private function getCloneablesMap()
{
$cachedInstantiators = $this->getInstantiatorsMap();
$that = $this;
return self::$cachedCloneables = self::$cachedCloneables
?: new CallbackLazyMap(function ($className) use ($cachedInstantiators, $that) {
/* @... | Builds or fetches the cloneables map
@return CallbackLazyMap | entailment |
public function up()
{
//======
// USERS
//======
// Either uncomment the section below to create the users table if it
// was not already done before, or use it as an example for your own
// migration.
// // Create users table
// Schema::create('users',... | Run the migrations.
@return void | entailment |
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('auth_type');
});
// Uncomment the section below if the users table was created above.
// // Drop the users table.
// Schema::drop('users');
Schema::table('gro... | Reverse the migrations.
@return void | entailment |
protected function settingForm()
{
return Administrator::form(function (Form $form) {
$form->display('username', trans('admin.username'));
$form->text('name', trans('admin.name'))->rules('required');
$form->email('email', trans('Email'));
$form->mobile('mobile... | Model-form for user setting.
@return Form | entailment |
public function handle()
{
if (empty($this->option('name'))) {
$this->importAll();
} else {
$name = $this->option('name');
$name = str_replace('-', '', $name);
if (method_exists($this, $name)) {
call_user_func([$this, $name]);
... | Execute the console command. | entailment |
public function registerApi()
{
$this->app['api.request'] = $this->app->share(function($app)
{
$remoteClient = new Client();
return new Api($app['config'], $app['router'], $app['request'], $remoteClient);
});
} | Register Api.
@return void | entailment |
public function registerApiCallCommand()
{
$this->app['api.call'] = $this->app->share(function($app)
{
return new Commands\ApiCallCommand($app['api.request']);
});
} | Register Api Call command.
@return void | entailment |
public function run()
{
// add default menus.
Menu::truncate();
Menu::insert([
[
'parent_id' => 0,
'order' => 1,
'title' => '系统管理',
'icon' => 'fa-tasks',
'uri' => '/',
],
[
... | Run the database seeds. | entailment |
public function make($data, $code, $overwrite = false)
{
// Status returned.
$status = (preg_match('/^(1|2|3)/', $code)) ? 'success' : 'error';
// Change object to array.
if (is_object($data))
{
$data = $data->toArray();
}
// Data as a string.
... | Make json data format.
@param mixed $data
@param integer $code
@param boolean $overwrite
@return string | entailment |
public function configureRemoteClient($configurations)
{
foreach ($configurations as $option => $value)
{
call_user_func_array(array($this->remoteClient, 'setDefaultOption'), array($option, $value));
}
} | Configure remote client for http request.
@param array $configuration
array
(
'verify' => false, //allows self signed certificates
'verify', '/path/to/cacert.pem', //custom certificate
'headers/X-Foo', 'Bar', //custom header
'auth', array('usernam... | entailment |
public function invoke($uri, $method, $parameters = array())
{
// Request URI.
if ( ! preg_match('/^http(s)?:/', $uri))
{
$uri = '/'.ltrim($uri, '/');
}
try
{
// Store the original request data and route.
$originalInput = $this->re... | Call internal URI with parameters.
@param string $uri
@param string $method
@param array $parameters
@return mixed | entailment |
public function invokeRemote($uri, $method, $parameters = array())
{
$remoteClient = $this->getRemoteClient();
// Make request.
$request = call_user_func_array(array($remoteClient, $method), array($uri, null, $parameters));
// Send request.
$response = $request->send();
... | Invoke with remote uri.
@param string $uri
@param string $method
@param array $parameters
@return mixed | entailment |
public function index()
{
return Admin::content(function (Content $content) {
$content->header(trans('admin.menu'));
$content->description(trans('admin.list'));
$content->row(function (Row $row) {
$row->column(6, $this->treeView()->render());
... | Index interface.
@return Content | entailment |
public function form()
{
return Menu::form(function (Form $form) {
$form->display('id', 'ID');
$form->select('parent_id', trans('admin.parent_id'))->options(Menu::selectOptions());
$form->text('title', trans('admin.title'))->rules('required');
$form->icon('ic... | Make a form builder.
@return Form | entailment |
public static function debug($msg)
{
if ($msg === 'open' || $msg === 'close') {
self::$_debugOpen = $msg === 'open';
} elseif (self::$_debugOpen === true) {
$key = self::$_processKey === null ? '' : '[' . self::$_processKey . '] ';
echo '[DEBUG] ', date('H:i:s '),... | Open/close debug mode
@param string $msg | entailment |
public function setParser($p)
{
if ($p === null || $p instanceof ParseInterface || is_callable($p)) {
$this->_parser = $p;
}
} | Set response parse handler
@param callable $p parse handler | entailment |
public function runParser($res, $req, $key = null)
{
if ($this->_parser !== null) {
self::debug('run parser: ', $req->getRawUrl());
if ($this->_parser instanceof ParseInterface) {
$this->_parser->parse($res, $req, $key);
} else {
call_user_... | Run parse handler
@param Response $res response object
@param Request $req request object
@param mixed $key the key string of multi request | entailment |
public function head($url, $params = [])
{
if (is_array($url)) {
return $this->mhead($url, $params);
}
return $this->exec($this->buildRequest('HEAD', $url, $params));
} | Shortcut of HEAD request
@param string $url request URL string.
@param array $params query params appended to URL.
@return Response result response object. | entailment |
public function get($url, $params = [])
{
if (is_array($url)) {
return $this->mget($url, $params);
}
return $this->exec($this->buildRequest('GET', $url, $params));
} | Shortcut of GET request
@param string $url request URL string.
@param array $params extra query params, appended to URL.
@return Response result response object. | entailment |
public function delete($url, $params = [])
{
if (is_array($url)) {
return $this->mdelete($url, $params);
}
return $this->exec($this->buildRequest('DELETE', $url, $params));
} | Shortcut of DELETE request
@param string $url request URL string.
@param array $params extra query params, appended to URL.
@return Response result response object. | entailment |
public function post($url, $params = [])
{
$req = $url instanceof Request ? $url : $this->buildRequest('POST', $url);
foreach ($params as $key => $value) {
$req->addPostField($key, $value);
}
return $this->exec($req);
} | Shortcut of POST request
@param string|Request $url request URL string, or request object.
@param array $params post fields.
@return Response result response object. | entailment |
public function put($url, $content = '')
{
$req = $url instanceof Request ? $url : $this->buildRequest('PUT', $url);
$req->setBody($content);
return $this->exec($req);
} | Shortcut of PUT request
@param string|Request $url request URL string, or request object.
@param string $content content to be put.
@return Response result response object. | entailment |
public function getJson($url, $params = [])
{
$req = $this->buildRequest('GET', $url, $params);
$req->setHeader('accept', 'application/json');
$res = $this->exec($req);
return $res === false ? false : $res->getJson();
} | Shortcut of GET restful request as json format
@param string $url request URL string.
@param array $params extra query params, appended to URL.
@return array result json data, or false on failure. | entailment |
public function exec($req)
{
// build recs
$recs = [];
if ($req instanceof Request) {
$recs[] = new Processor($this, $req);
} elseif (is_array($req)) {
foreach ($req as $key => $value) {
if ($value instanceof Request) {
$rec... | Execute http requests
@param Request|Request[] $req the request object, or array of multiple requests
@return Response|Response[] result response object, or response array for multiple requests | entailment |
protected function buildRequest($method, $url, $params = [])
{
if (count($params) > 0) {
$url .= strpos($url, '?') === false ? '?' : '&';
$url .= http_build_query($params);
}
return new Request($url, $method);
} | Build a http request
@param string $method
@param string $url
@param array $params
@return Request | entailment |
protected function buildRequests($method, $urls, $params = [])
{
$reqs = [];
foreach ($urls as $key => $url) {
$reqs[$key] = $this->buildRequest($method, $url, $params);
}
return $reqs;
} | Build multiple http requests
@param string $method
@param array $urls
@param array $params
@return Request[] | entailment |
public function generate(array $ast) : string
{
$this->traverser->traverse($ast);
$generatedCode = parent::generate($ast);
$className = trim($this->visitor->getNamespace() . '\\' . $this->visitor->getName(), '\\');
$fileName = $this->fileLocator->getGeneratedClassFileName($... | Write generated code to disk and return the class code
{@inheritDoc}
@throws \CodeGenerationUtils\Visitor\Exception\UnexpectedValueException | entailment |
public function contentcontrollerInit()
{
// only call custom script if page has Slides and DataExtension
if (DataObject::has_extension($this->owner->Classname, FlexSlider::class)) {
if ($this->owner->getSlideShow()->exists()) {
$this->getCustomScript();
}
... | add requirements to PageController init() | entailment |
public function call(string $method, array $parameters)
{
if ($this->isSingleRequest) {
$this->units = [];
}
$this->units[] = new Invoke($this->generatorId->get(), $method, $parameters);
if ($this->isSingleRequest) {
$resultSpecifier = $this->execute(new Inv... | Make request
@param string $method
@param array $parameters
@return $this|mixed
@throws JsonRpcException | entailment |
public function notification(string $method, array $parameters)
{
if ($this->isSingleRequest) {
$this->units = [];
}
$this->units[] = new Notification($method, $parameters);
if ($this->isSingleRequest) {
$this->execute(new InvokeSpec($this->units, true));
... | Make notification request
@param string $method
@param array $parameters
@return $this|null | entailment |
public function batchExecute()
{
$results = $this->execute(new InvokeSpec($this->units, false))->getResults();
// Make right order in sequence of results. It's required operation, because JSON-RPC2
// specification define: "The Response objects being returned from a batch call MAY be return... | Execute batch request
@return array | entailment |
private function execute(InvokeSpec $call): ResultSpec
{
$request = $this->requestBuilder->build($call);
$response = $this->transport->request($request);
return $this->responseParser->parse($response);
} | @param InvokeSpec $call
@return ResultSpec | entailment |
protected function compile()
{
$intCatIdAllowed = false;
/*
if ($this->intKatID == 0) //direkter Aufruf ohne ID
{
$objVisitorsKatID = \Database::getInstance()
->prepare("SELECT
MIN(pid) AS ANZ
FROM
... | Generate module | entailment |
protected function getFourteenDays($KatID, $VisitorsXid)
{
$visitors_today_visit = 0;
$visitors_today_hit = 0;
$visitors_yesterday_visit = 0;
$visitors_yesterday_hit = 0;
$visitors_visit_start = 0;
$visitors_hit_start = 0;
$visitors_day_of_week_prefix = '';
//Anzahl Tage zu erst a... | 14 Tagesstat und Vorgabewerte | entailment |
protected function getMonth($VisitorsID)
{
$LastMonthVisits = 0;
$LastMonthHits = 0;
$CurrentMonthVisits = 0;
$CurrentMonthHits = 0;
$YearCurrentMonth = date('Y-m-d');
$YearLastMonth = date('Y-m-d' ,mktime(0, 0, 0, date("m")-1, 1, date("Y")));
$CurrentMonth = (int... | Monatswerte (Aktueller und Letzer) | entailment |
protected function getOtherMonth($VisitorsID)
{
$StartMonth = date('Y-m-d',mktime(0, 0, 0, date("m")-11, 1, date("Y"))); // aktueller Monat -11
$EndMonth = date('Y-m-d',mktime(0, 0, 0, date("m")-1 , 0, date("Y"))); // letzter Tag des vorletzten Monats
if ($VisitorsID)
{
//Total je Monat (aktueller ... | Monatswerte (Vorletzter und älter, max 10) | entailment |
protected function getOtherYears($VisitorsID)
{
$StartYear = date('Y-m-d',mktime(0, 0, 0, 1, 1, date("Y")-11)); // aktuelles Jahr -11
$EndYear = date('Y-m-d'); // Aktuelles Datum
if ($VisitorsID)
{
//Total je Monat (aktueller und letzter)
$objVisitorsToYear = \Database::getInsta... | Jahreswerte (Aktuelles und älter (10) = max 11) | entailment |
protected function getAverage($VisitorsID)
{
$VisitorsAverageVisits = 0;
$VisitorsAverageHits = 0;
$VisitorsAverageVisits30 = 0;
$VisitorsAverageHits30 = 0;
$VisitorsAverageVisits60 = 0;
$VisitorsAverageHits60 = 0;
$tmpTotalDays = 0;
if ($VisitorsID)
{... | Average Stat | entailment |
protected function getWeeks($VisitorsID)
{
/*
* YEARWEEK('2013-12-31', 3) ergibt 201401 (iso Jahr der iso Woche)!
* muss so sein, da sonst between nicht funktioniert
* (Current muss größer sein als Last)
* daher muss PHP auch das ISO Jahr zurückgeben!
*/
$LastWeekVisits ... | Wochenwerte | entailment |
protected function getTotal($VisitorsID)
{
$VisitorsTotalVisitCount = 0;
$VisitorsTotalHitCount = 0;
if ($VisitorsID)
{
//Total seit Zählung
$objVisitorsTotalCount = \Database::getInstance()
->prepare("SELECT
SUM(visitors_visit) AS SUMV... | Total Hits und Visits | entailment |
protected function setZero()
{
if (false === $this->boolAllowReset)
{
return ;
}
$intCID = preg_replace('@\D@', '', \Input::get('zid')); // only digits
if ($intCID>0)
{
// mal sehen ob ein Startdatum gesetzt war
$objVisitorsDate = \Database::getInstance()
... | Statistic, set on zero | entailment |
protected function setZeroBrowser()
{
if (false === $this->boolAllowReset)
{
return ;
}
$intCID = preg_replace('@\D@', '', \Input::get('zid')); // only digits
if ($intCID>0)
{
// Browser
\Database::getInstance()
->prepare("DELETE FROM ... | Statistic, set on zero | entailment |
protected function getBrowserTop($VisitorsID)
{
$topNo = 20;
$VisitorsBrowserVersion = array();
$VisitorsBrowserLang = array();
$VisitorsBrowserOS = array();
if ($VisitorsID)
{
//Version
$objVisitorsBrowserVersion = \Database::getInstance()
->prepare("SELECT
... | TOP Browser | entailment |
protected function getSearchEngine($VisitorsKatID)
{
$VisitorsSearchEngines = array(); // only searchengines
$VisitorsSearchEngineKeywords = array(); //searchengine - keywords, order by keywords
$day60 = mktime(0, 0, 0, date("m")-2 , date("d") ,date("Y"));
$objVisitors = \Database::getInstance()
... | TOP 20 SearchEngine
@param integer $VisitorsID Category-ID des Zählers
@return array | entailment |
protected function getReferrerTop($VisitorsID)
{
$topNo = 30;
$VisitorsReferrerTop = array();
if ($VisitorsID)
{
//Version
$objVisitorsReferrerTop = \Database::getInstance()
->prepare("SELECT
`visitors_referrer_dns`,
... | TOP 30 Referrer
@param integer $VisitorsID ID des Zählers
@return array | entailment |
protected function parseDateVisitors($language='en', $intTstamp=null, $prefix='')
{
switch ($language)
{
case 'de':
$strModified = $prefix . 'd.m.Y';
break;
case 'en':
$strModified = $prefix . 'Y-m-d';
break;
default :
... | Timestamp nach Datum in deutscher oder internationaler Schreibweise
@param string $language
@param insteger $intTstamp
@return string | entailment |
protected function getVisitorsOnline($VisitorsID)
{
$objVisitorsOnlineCount = \Database::getInstance()
->prepare("SELECT
COUNT(id) AS VOC
FROM
tl_visitors_blocker
WHERE
... | Get VisitorsOnline
@param integer $VisitorsID ID des Zählers
@return integer | entailment |
protected function getBestDay($VisitorsID)
{
$objVisitorsBestday = \Database::getInstance()
->prepare("SELECT
visitors_date,
visitors_visit,
visitors_hit
FROM
... | Get Best Day Data (most Visitors on this day)
@param integer $VisitorsID ID des Zählers
@return array Date,Visits,Hits | entailment |
protected function getBadDay($VisitorsID)
{
$objVisitorsBadday = \Database::getInstance()
->prepare("SELECT
visitors_date,
visitors_visit,
visitors_hit
FROM
... | Get Bad Day Data (fewest Visitors on this day)
@param integer $VisitorsID ID des Zählers
@return array Date,Visits,Hits | entailment |
protected function getVisitorCategoriesByUsergroups()
{
$arrVisitorCats = array();
$objVisitorCat = \Database::getInstance()
->prepare("SELECT
`id`
, `title`
... | Get visitor categories by usergroups
@param array $Usergroups
@return array | entailment |
protected function isUserInVisitorStatGroups($visitors_stat_groups, $visitors_stat_protected)
{
if ( true === $this->User->isAdmin )
{
//Debug log_message('Ich bin Admin', 'visitors_debug.log');
return true; // Admin darf immer
}
//wenn Schutz nicht aktiviert ist, darf jeder
... | Check if User member of group in visitor statistik groups
@param string DB Field "visitors_stat_groups", serialized array
@return bool true / false | entailment |
public static function getIdentifier(string $name) : string
{
return str_replace(
'.',
'',
uniqid(
preg_match(static::VALID_IDENTIFIER_FORMAT, $name)
? $name
: static::DEFAULT_IDENTIFIER,
true
)
... | Generates a valid unique identifier from the given name
@param string $name
@return string | entailment |
public function parse(string $payload): ResultSpec
{
$data = @json_decode($payload, true);
if (!is_array($data)) {
throw new BaseClientException('Parse error', JsonRpcException::PARSE_ERROR);
}
$units = [];
if ($this->isSingleResponse($data)) {
$uni... | @param string $payload
@return ResultSpec | entailment |
private function decodeResult(array $record): AbstractResult
{
$record = $this->preParse($record);
if ($this->isValidResult($record)) {
$unit = new Result($record['id'], $record['result']);
} elseif ($this->isValidError($record)) {
$exceptionClass = $this->exceptionM... | @param array $record
@return AbstractResult | entailment |
private function isValidResult($payload): bool
{
if (!is_array($payload)) {
return false;
}
$headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0';
$resultValid = array_key_exists('result', $payload);
$idValid = array_key_exists... | @param array $payload
@return bool | entailment |
private function isValidError($payload): bool
{
if (!is_array($payload)) {
return false;
}
$headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0';
$errorValid = array_key_exists('error', $payload) && is_array($payload['error'])
... | @param array $payload
@return bool | entailment |
private function preParse(array $data): array
{
$result = $this->preParse->handle(new ParserContainer($this, $data));
if ($result instanceof ParserContainer) {
return $result->getValue();
}
throw new \RuntimeException();
} | @param array $data
@return array | entailment |
public function decode(EntityInterface $entity) {
$idField = $this->_primaryKey;
$hashid = $entity->get($idField);
if (!$hashid) {
return false;
}
$field = $this->_config['field'];
if (!$field) {
return false;
}
$id = $this->decodeHashid($hashid);
$entity->set($field, $id);
$entity->setDirt... | Sets up hashid for model.
@param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved
@return bool True if save should proceed, false otherwise | entailment |
public function encode(EntityInterface $entity) {
$idField = $this->_primaryKey;
$id = $entity->get($idField);
if (!$id) {
return false;
}
$field = $this->_config['field'];
if (!$field) {
return false;
}
$hashid = $this->encodeId($id);
$entity->set($field, $hashid);
$entity->setDirty($field... | Sets up hashid for model.
@param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved
@return bool True if save should proceed, false otherwise | entailment |
public function findHashed(Query $query, array $options) {
$field = $this->_config['field'];
if (!$field) {
return $query;
}
$idField = $this->_primaryKey;
$query->formatResults(function ($results) use ($field, $idField) {
$newResult = [];
$results->each(function ($row, $key) use ($field, $idField... | Custom finder for hashids field.
Options:
- hid (required), best to use HashidBehavior::HID constant
- noFirst (optional, to leave the query open for adjustments, no first() called)
@param \Cake\ORM\Query $query Query.
@param array $options Array of options as described above
@return \Cake\ORM\Query|\Cake\Datasource\... | entailment |
public function spacy_entities( $text, $lang = 'en' )
{
$data = $this->post_call('/spacy/entities', ['text' => $text, 'lang' => $lang ] );
return ( !empty($data['entities']) ) ? $data['entities'] : null;
} | Spacy.io Entity Extraction | entailment |
public function afinn_sentiment( $text, $lang = 'en' )
{
$data = $this->post_call('/afinn', ['text' => $text, 'lang' => $lang ] );
return ( isset($data['afinn']) ) ? $data['afinn'] : null;
} | AFINN Sentiment Analysis | entailment |
public function summarize( $text, $word_count = null )
{
$data = $this->post_call('/gensim/summarize', ['text' => $text, 'word_count' => $word_count ] );
return ( !empty($data['summarize']) ) ? $data['summarize'] : null;
} | Summarize long text | entailment |
public function newspaper_html( $html )
{
$data = $this->post_call('/newspaper', ['html' => $html ] );
return ( !empty($data['newspaper']) ) ? $data['newspaper'] : null;
} | Article Extraction from HTML | entailment |
public function newspaper( $url )
{
$data = $this->get_call('/newspaper', ['url' => $url ] );
return ( !empty($data['newspaper']) ) ? $data['newspaper'] : null;
} | Article Extraction from URL | entailment |
public function readability( $url )
{
$data = $this->get_call('/readability', ['url' => $url ] );
return ( !empty($data['readability']) ) ? $data['readability'] : null;
} | Readability Article Extraction from URL | entailment |
public function readability_html( $html )
{
$data = $this->post_call('/readability', ['html' => $html ] );
return ( !empty($data['readability']) ) ? $data['readability'] : null;
} | Readability Article Extraction from HTML | entailment |
public function sentiment( $text, $language = null )
{
$data = $this->post_call('/polyglot/sentiment', ['text' => $text, 'lang' => $language ] );
return ( isset($data['sentiment']) ) ? $data['sentiment'] : null;
} | Sentiment Analysis by Polyglot | entailment |
public function neighbours( $word, $lang = 'en')
{
$data = $this->get_call('/polyglot/neighbours', ['word' => $word, 'lang' => $lang ] );
return ( !empty($data['neighbours']) ) ? $data['neighbours'] : null;
} | Get neighbouring words | entailment |
public function polyglot_entities( $text, $language = null )
{
$data = $this->post_call('/polyglot/entities', ['text' => $text, 'lang' => $language] );
$this->msg( $data );
return new \Web64\Nlp\Classes\PolyglotResponse( $data['polyglot'] );
} | Get entities and sentiment analysis of text | entailment |
public function language( $text )
{
$data = $this->post_call('/langid', ['text' => $text] );
if ( isset($data['langid']) && isset($data['langid']['language']))
{
// return 'no' for Norwegian Bokmaal and Nynorsk
if ( $data['langid']['language'] == 'nn' || $data['langid']['language'] == 'nb' )
return 'n... | Get language code for text | entailment |
public function addHost( $host )
{
$host = rtrim( $host , '/');
if ( array_search($host, $this->api_hosts) === false)
$this->api_hosts[] = $host;
} | Internals | entailment |
private function msg( $value )
{
if ( $this->debug )
{
if ( is_array($value) )
{
fwrite(STDOUT, print_r( $value, true ) . PHP_EOL );
}
else
fwrite(STDOUT, $value . PHP_EOL );
}
} | debug message | entailment |
private function chooseHost()
{
$random_a = $this->api_hosts;
shuffle($random_a); // pick random host
foreach( $random_a as $api_url )
{
$this->msg( "chooseHost() - Testing: $api_url ");
$content = @file_get_contents( $api_url );
if ( empty( $content ) )
{
... | find working host | entailment |
public function generatePageVisitHitTop($VisitorsID, $limit = 20, $parse = true)
{
$arrPageStatCount = false;
$objPageStatCount = \Database::getInstance()
->prepare("SELECT
visitors_page_id,
visi... | //////////////////////////////////////////////////////////// | entailment |
public function generatePageVisitHitTopDays($VisitorsID, $days = 365, $parse = false)
{
$STARTDATE = date("Y-m-d", mktime(0, 0, 0, date("m") , date("d")-$days, date("Y")) );
$arrPageStatCount = false;
$objPageStatCount = \Database::getInstance()
->prepare("SELEC... | generatePageVisitHitTopDays speziell für den Export
Filterung nach Anzahl Tagen
@param integer $VisitorsID
@param number $days
@param string $parse
@return string|multitype:string NULL | entailment |
public function updateCMSFields(FieldList $fields)
{
// Remove all Meta fields
$fields->removeByName('Metadata');
// Add summary fields
$fields->addFieldToTab('Root.Main', TextAreaField::create('MetaDescription', _t('JonoM\ShareCare\ShareCareSummary.SummaryTitle','Content summary'))
... | Add and re-arrange CMS fields for streamlined summary editing. | entailment |
public function getOGDescription()
{
// Use MetaDescription if set
if ($this->owner->MetaDescription) {
$description = trim($this->owner->MetaDescription);
if (!empty($description)) {
return $description;
}
}
return $this->owner->g... | The description that will be used in the 'og:description' open graph tag.
Use a custom value if set, or fallback to a default value.
@return string | entailment |
public function getDefaultOGDescription()
{
// Fall back to Content
if ($this->owner->Content) {
$description = trim($this->owner->obj('Content')->Summary(20, 5));
if (!empty($description)) {
return $description;
}
}
return false;
... | The default/fallback value to be used in the 'og:description' open graph tag.
@return string | entailment |
public function leaveNode(Node $node)
{
$filter = $this->filter;
if (! $node instanceof ClassMethod || null === ($filterResult = $filter($node))) {
return null;
}
if (false === $filterResult) {
return false;
}
$node->stmts = array(
... | Replaces the given node if it is a class method and matches according to the given callback
@param \PhpParser\Node $node
@return bool|null|\PhpParser\Node\Stmt\ClassMethod | entailment |
public function checkBot()
{
$bundles = array_keys(\System::getContainer()->getParameter('kernel.bundles')); // old \ModuleLoader::getActive()
if ( !in_array( 'BugBusterBotdetectionBundle', $bundles ) )
{
//BugBusterBotdetectionBundle Modul fehlt, Abbruch
\System::getContainer()
->get('mo... | Spider Bot Check
@return bool | entailment |
public function checkUserAgent($visitors_category_id)
{
if (\Environment::get('httpUserAgent'))
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
else
{
return false; // Ohne Absender keine Suche
}
$arrUserAgents = array();
$objUserAgents =... | HTTP_USER_AGENT Special Check
@return bool | entailment |
public function checkBE()
{
if ($this->isContao45())
{
if ($this->_BackendUser)
{
ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': True' );
return true;
}
ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': False' );
retur... | BE Login Check
basiert auf Frontend.getLoginStatus
@return bool | entailment |
public function isDomain($host)
{
$dnsResult = false;
//$this->_vhost : Host.TLD
//idn_to_ascii
$dnsResult = @dns_get_record( \Idna::encode( $host ), DNS_ANY );
if ( $dnsResult )
{
ModuleVisitorLog::writeLog( __METHOD__ , __LINE__ , ': True' );
return true;
}
... | Check if Domain valid
@param string Host / domain.tld
@return boolean | entailment |
public function isContao45()
{
//Thanks fritzmg for this hint
// get the Contao version
$version = PrettyVersions::getVersion('contao/core-bundle');
// check for Contao >=4.5
if (\Composer\Semver\Semver::satisfies($version->getShortVersion(), '>=4.5'))
{
ModuleVisitorLog::writeLo... | Check if contao/cor-bundle >= 4.5.0
@return boolean | entailment |
public function visitorGetUserIP()
{
$UserIP = \Environment::get('ip');
if (strpos($UserIP, ',') !== false) //first IP
{
$UserIP = trim( substr($UserIP, 0, strpos($UserIP, ',') ) );
}
if ( true === $this->visitorIsPrivateIP($UserIP) &&
false === empty($_SERVER['HTTP_X_FORWARD... | Get User IP
@return string | entailment |
public function log($level, $message, array $context = array())
{
fwrite($this->stream, $this->formatMessage($this->interpolate($message, $context)));
} | Logs with an arbitrary level.
@param mixed $level
@param string $message
@param array $context
@return null | entailment |
public function updateCMSFields(FieldList $fields)
{
$msg = _t('JonoM\ShareCare\ShareCare.CMSMessage', 'When this page is shared by people on social media it will look something like this:');
$tab = 'Root.' . _t('JonoM\ShareCare\ShareCare.TabName', 'Share');
if ($msg) {
$fields->... | Add a Social Media tab with a preview of share appearance to the CMS. | entailment |
public function clearFacebookCache()
{
if ($this->owner->hasMethod('AbsoluteLink')) {
$anonymousUser = new Member();
if ($this->owner->can('View', $anonymousUser)) {
$client = new Client();
try {
$client->request('GET', 'https://gra... | Tell Facebook to re-scrape this URL, if it is accessible to the public. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.