sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function getUnreviewedSelectQuery(LocaleEntity $locale)
{
$cn = $this->app->make(EntityManager::class)->getConnection();
$queryLocaleID = $cn->quote($locale->getID());
return $cn->executeQuery(
$this->getBaseSelectString($locale, false, false) .
" inner join
... | Get the recordset of all the translations of a locale that needs to be reviewed.
@param LocaleEntity $locale
@return PDOStatement | entailment |
public function getPackageSelectQuery(PackageVersionEntity $packageVersion, LocaleEntity $locale, $excludeUntranslatedStrings = false)
{
$cn = $this->app->make(EntityManager::class)->getConnection();
$queryPackageVersionID = (int) $packageVersion->getID();
return $cn->executeQuery(
... | Get recordset of the translations for a specific package, version and locale.
@param PackageVersionEntity $packageVersion
@param LocaleEntity $locale
@param bool $excludeUntranslatedStrings
@return PDOStatement | entailment |
public function forPackage($packageOrHandleVersion, LocaleEntity $locale, $excludeUntranslatedStrings = false)
{
if ($packageOrHandleVersion instanceof PackageVersionEntity) {
$packageVersion = $packageOrHandleVersion;
} elseif (is_array($packageOrHandleVersion) && isset($packageOrHandle... | Get the translations for a specific package, version and locale.
@param PackageVersionEntity|array $packageOrHandleVersion The package version for which you want the translations (a Package\Version entity instance of an array with handle and version)
@param LocaleEntity $locale the locale that you want
@param bool $ex... | entailment |
public function unreviewed(LocaleEntity $locale)
{
$rs = $this->getUnreviewedSelectQuery($locale);
$result = $this->buildTranslations($locale, $rs);
$result->setHeader('Project-Id-Version', 'unreviewed');
return $result;
} | Get the unreviewed translations for a locale.
@param LocaleEntity $locale the locale that you want
@param bool $excludeUntranslatedStrings set to true to filter out untranslated strings
@return Translations | entailment |
protected function buildTranslations(LocaleEntity $locale, PDOStatement $rs)
{
$translations = new Translations();
$translations->setLanguage($locale->getID());
$numPlurals = $locale->getPluralCount();
while (($row = $rs->fetch()) !== false) {
$translation = new \Gettext\... | @param LocaleEntity $locale
@param PDOStatement $rs
@return Translations | entailment |
public function localeHasPendingApprovals(LocaleEntity $locale)
{
$cn = $this->app->make(EntityManager::class)->getConnection();
$rs = $cn->executeQuery(
'
select
CommunityTranslationTranslations.id
from
CommunityTra... | Does a locale have translation strings that needs review?
@param LocaleEntity $locale
@return bool | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('ez_share_buttons');
$systemNode = $this->generateScopeBaseNode($rootNode);
$this->addCommonSettings($systemNode);
$this->addFacebookLikeSettings($systemNode);
$... | {@inheritdoc} | entailment |
protected function parseSize($size)
{
$result = null;
$size = (string) $size;
$matches = null;
if (preg_match('/^\s*(\d+(?:\.\d*)?)\s*(?:([bkmgtpezy])b?)?\s*/i', $size, $matches)) {
$value = (float) $matches[1];
$unit = empty($matches[2]) ? 'b' : strtolower($m... | @param string|int $size
@return int|null | entailment |
protected function normalizeArgs(array $args)
{
$args += [
'statsFromPackage' => '',
];
$error = $this->app->make('helper/validation/error');
$normalized = [];
try {
/* @var \CommunityTranslation\Service\RateLimit $rateLimitHelper */
list(... | {@inheritdoc}
@see BlockController::normalizeArgs() | entailment |
private function getPostedFile()
{
$file = $this->request->files->get('file');
if ($file === null) {
throw new UserMessageException(t('Please specify the file to be analyzed'));
}
if (!$file->isValid()) {
throw new UserMessageException($file->getErrorMessage()... | @throws UserMessageException
$return \Symfony\Component\HttpFoundation\File\UploadedFile | entailment |
private function getPostedLocales()
{
$localeIDs = [];
$list = $this->post('translatedLocales');
if (is_array($list)) {
$localeIDs = array_merge($localeIDs, $list);
}
$list = $this->post('untranslatedLocales');
if (is_array($list)) {
$localeIDs... | @throws UserMessageException
$return \CommunityTranslation\Entity\Locale[] | entailment |
public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
$eventName = $this->getStopwatchEventName($request);
$this->stopwatch->start($eventName, self::CATEGORY);
return $next($request)->then(function (ResponseInterface $response) use ($eventName) {
... | {@inheritdoc} | entailment |
public function getColumnContent($gridField, $record, $columnName) {
if(!$record->canView()) return;
$field = GridField_FormAction::create($gridField, 'ExportSingle'.$record->ID, false,
"exportsingle", array('RecordID' => $record->ID))
->addExtraClass('gridfield-button-expor... | Return the button to show at the end of the row
@param GridField $gridField
@param DataObject $record
@param string $columnName
@return string - the HTML for the column | entailment |
public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
if($actionName == 'exportsingle') {
// Get the item
$item = $gridField->getList()->byID($arguments['RecordID']);
if(!$item) {
return;
}
// Make sure t... | Handle the actions and apply any changes to the GridField
@param GridField $gridField
@param string $actionName
@param mixed $arguments
@param array $data - form data
@return void | entailment |
public function setUseLabelsAsHeaders($value)
{
if ($value === null) {
$this->useLabelsAsHeaders = null;
} else {
$this->useLabelsAsHeaders = (bool)$value;
}
return $this;
} | Set the DataFormatter's UseFieldLabelsAsHeaders property
@param bool $value
@return GridFieldExcelExportButton | entailment |
public function createAttributeValueFromRequest()
{
$data = $this->post();
if (!is_array($data)) {
$data = [];
}
$data += [
'operation' => null,
'current-token' => '',
'current-token-hash' => '',
];
switch ($data['operat... | {@inheritdoc}
@see \Concrete\Core\Attribute\Controller::createAttributeValueFromRequest() | entailment |
public function search()
{
$this->set('form', $this->app->make('helper/form'));
$this->set('fieldName', $this->field('value'));
$this->set('fieldValue', $this->request('value'));
} | {@inheritdoc}
@see \Concrete\Core\Attribute\DefaultController::search() | entailment |
protected function normalizeArgs(array $args)
{
$error = $this->app->make('helper/validation/error');
$normalized = [
'askNewTeamCID' => null,
'askNewTeamLink' => '',
];
switch (isset($args['askNewTeamLinkType']) ? $args['askNewTeamLinkType'] : '') {
... | {@inheritdoc}
@see BlockController::normalizeArgs() | entailment |
protected function getPackageVersions($obj)
{
$result = [];
if ($obj instanceof PackageVersionEntity) {
$result[] = $obj;
} elseif (is_array($obj)) {
$app = Application::getFacadeApplication();
if (isset($obj['handle']) && isset($obj['version'])) {
... | @param mixed $obj
@return PackageVersionEntity[] | entailment |
protected function getLocales($obj)
{
$result = [];
if ($obj instanceof LocaleEntity) {
$result[] = $obj;
} elseif (is_string($obj)) {
$app = Application::getFacadeApplication();
$l = $app->make(LocaleRepository::class)->findApproved($obj);
if ... | @param mixed $obj
@return LocaleEntity[] | entailment |
public function getOne(PackageVersionEntity $packageVersion, LocaleEntity $locale)
{
$array = $this->get($packageVersion, $locale);
return array_shift($array);
} | Get some stats about a package version and a locale.
@param PackageVersionEntity $packageVersion
@param LocaleEntity $locale
@return Stats | entailment |
public function get($wantedPackageVersions, $wantedLocales)
{
$packageVersions = array_values(array_unique($this->getPackageVersions($wantedPackageVersions)));
$locales = array_values(array_unique($this->getLocales($wantedLocales)));
$qb = $this->createQueryBuilder('s');
if (count($p... | Get some stats about one or more package versions and one or more locales.
@param PackageVersionEntity|PackageVersionEntity[]|array|array[array] $wantedPackageVersions
@param LocaleEntity|LocaleEntity[]|string|string[] $wantedLocales
@return StatsEntity[] | entailment |
public function resetForLocaleTranslatables(LocaleEntity $locale, $translatables)
{
$this->resetForLocale($locale);
$translatableIDs = [];
if ($translatables) {
if ($translatables instanceof TranslatableEntity) {
$translatableIDs[] = $translatables->getID();
... | @param LocaleEntity $locale
@param TranslatableEntity|int|TranslatableEntity[]|int[] $translatables
@throws UserMessageException | entailment |
protected function build(PackageVersionEntity $packageVersion, array $locales)
{
$result = [];
$app = Application::getFacadeApplication();
try {
$total = (int) $app->make(TranslatablePlaceRepository::class)
->createQueryBuilder('p')
->select('c... | @param PackageVersionEntity $packageVersion
@param LocaleEntity[] $locales
@return Stats | entailment |
public function getUser($user)
{
$result = null;
if ($user === 'current') {
$u = new \User();
if ($u->isRegistered()) {
$result = $u;
}
} elseif (is_int($user) || (is_string($user) && is_numeric($user))) {
$result = \User::getBy... | Parse the $user parameter of the functions.
@param int|UserService|UserEntity|'current' $user
@return \User|null | entailment |
public function getUserEntity($user)
{
$result = null;
if ($user instanceof UserEntity) {
$result = $user;
} else {
$u = $this->getUser($user);
if ($u !== null) {
$result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u-... | Parse the $user parameter of the functions.
@param int|UserService|UserEntity|'current' $user
@return UserEntity|null | entailment |
protected function getLocale($locale)
{
$result = null;
if ($locale instanceof LocaleEntity) {
$result = $locale;
} elseif (is_string($locale) && $locale !== '') {
$result = $this->app->make(LocaleRepository::class)->findApproved($locale);
}
return $r... | Parse the $locale parameter of the functions.
@param mixed $locale
@return LocaleEntity|null | entailment |
public function getLocaleAccess($locale, $user = 'current')
{
$result = self::NONE;
$user = $this->getUser($user);
if ($user === null) {
$result = self::NOT_LOGGED_IN;
} else {
$result = self::NONE;
if ($user->getUserID() == USER_SUPER_ID) {
... | Get the access level to a specific locale.
@param LocaleEntity|string $locale
@param UserService|int|'current' $user
@return int One of the Access constants | entailment |
public function setLocaleAccess($wantedLocale, $access, $wantedUser = 'current')
{
$user = $this->getUser($wantedUser);
if ($user === null) {
throw new UserMessageException(t('Invalid user'));
}
$locale = $this->getLocale($wantedLocale);
if ($locale === null) {
... | Get the access level to a specific locale.
@param LocaleEntity|string $wantedLocale
@param int $access One of the Access constants
@param UserService|int|'current' $wantedUser
@return int One of the Access constants | entailment |
public function setGlobalAccess($enable, $user = 'current')
{
$user = $this->getUser($user);
if ($user === null) {
throw new UserMessageException(t('Invalid user'));
}
if ($user->getUserID() === USER_SUPER_ID) {
return;
}
$group = $this->groups... | Set or unset global administration access.
@param bool $enable
@param UserService|int|'current' $user | entailment |
private function decodeOnEncodingHeader($headerName, ResponseInterface $response)
{
if ($response->hasHeader($headerName)) {
$encodings = $response->getHeader($headerName);
$newEncodings = [];
while ($encoding = array_pop($encodings)) {
$stream = $this->d... | Decode a response on a specific header (content encoding or transfer encoding mainly).
@param string $headerName Name of the header
@param ResponseInterface $response Response
@return ResponseInterface A new instance of the response decoded | entailment |
private function decorateStream($encoding, StreamInterface $stream)
{
if ('chunked' == strtolower($encoding)) {
return new DechunkStream($stream);
}
if ('compress' == strtolower($encoding)) {
return new DecompressStream($stream);
}
if ('deflate' == s... | Decorate a stream given an encoding.
@param string $encoding
@param StreamInterface $stream
@return StreamInterface|false A new stream interface or false if encoding is not supported | entailment |
public function getSerializedTranslationsFile(PackageVersionEntity $packageVersion, LocaleEntity $locale, TranslationsConverter $format)
{
$fileMTime = null;
$file = $this->getCacheDirectory($packageVersion, $locale, true) . '/data.' . $format->getHandle();
if ($this->fs->isFile($file)) {
... | @param PackageVersionEntity $packageVersion
@param LocaleEntity $locale
@param TranslationsConverter $format
@throws UserMessageException
@return string | entailment |
public function getSerializedTranslations(PackageVersionEntity $packageVersion, LocaleEntity $locale, TranslationsConverter $format)
{
$file = $this->getSerializedTranslationsFile($packageVersion, $locale, $format);
$result = $this->fs->get($file);
if ($result === false) {
throw... | @param PackageVersionEntity $packageVersion
@param LocaleEntity $locale
@param TranslationsConverter $format
@throws UserMessageException
@return string | entailment |
protected function getWorktreeDirectory()
{
if ($this->worktreeDirectory === null) {
$config = $this->app->make('community_translation/config');
$dir = $config->get('options.tempDir');
$dir = is_string($dir) ? rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $dir), '/') : '';
... | Get the working tree directory.
@throws UserMessageException
@return string | entailment |
protected function getGitDirectory()
{
if ($this->gitDirectory === null) {
$this->gitDirectory = $this->getWorktreeDirectory() . '/.git';
}
return $this->gitDirectory;
} | Get the git directory.
@throws UserMessageException
@return string | entailment |
public function getRootDirectory()
{
$dir = $this->getWorktreeDirectory();
$relativeRoot = trim(str_replace(DIRECTORY_SEPARATOR, '/', $this->gitRepository->getDirectoryToParse()), '/');
if ($relativeRoot !== '') {
$dir .= '/' . $relativeRoot;
}
return $dir;
} | Return the directory containing the files to be parsed.
@throws UserMessageException
@return string | entailment |
public function initialize()
{
$directory = $this->getWorktreeDirectory();
$fs = $this->getFilesystem();
if (@$fs->isDirectory($directory)) {
@$fs->cleanDirectory($directory);
if (count($fs->files($directory)) > 0 || count($fs->directories($directory)) > 0) {
... | Initializes the git repository (if the local directory exists it will be erased).
@throws UserMessageException | entailment |
public function update()
{
$fs = $this->getFilesystem();
if ($fs->isDirectory($this->getGitDirectory())) {
$this->runGit('fetch origin --tags');
} else {
$this->initialize();
}
} | Initializes or update the git repository.
@throws UserMessageException | entailment |
public function getTaggedVersions()
{
$tagFilters = $this->gitRepository->getTagFiltersExpanded();
$taggedVersions = [];
if ($tagFilters !== null) {
$matches = null;
foreach ($this->runGit('tag --list') as $tag) {
$matchResult = @preg_match($this->git... | Returns the list of tags and their associated versions (keys are the tags, values are the versions).
@throws UserMessageException
@return array Keys: tag, values: version | entailment |
private function runGit($cmd, $setDirectories = true)
{
static $execAvailable;
if (!isset($execAvailable)) {
$safeMode = @ini_get('safe_mode');
if (!empty($safeMode)) {
throw new UserMessageException(t("Safe-mode can't be on"));
}
if (!... | Execute a git command.
@param string $cmd
@param bool $setDirectories
@throws UserMessageException
@return string[] | entailment |
protected function normalizeArgs(array $args)
{
$args += [
'numTranslators' => '',
'limitToLocale' => '',
];
$valn = $this->app->make(Numbers::class);
$normalized = [
'numTranslators' => $valn->integer($args['numTranslators'], 1) ? (int) $args['num... | {@inheritdoc}
@see BlockController::normalizeArgs() | entailment |
public function search($params)
{
$searchResult = $this->getRequest()->request(
'POST',
$this->getRequestUrl('searches'),
$this->getSearchQuery($params)
);
return $this->getInputsFromSearchResult($searchResult);
} | Searches Inputs
@param array $params
@return Input[] array | entailment |
public function getSearchQuery($params)
{
$data['query'] = [];
$data['query']['ands'] = [];
if (isset($params[self::INPUT_CONCEPTS])) {
$data['query']['ands'] = $this->getInputConceptsQuery(
$data['query']['ands'],
$params[self::INPUT_CONCEPTS]
... | @param array $params
@return array | entailment |
public function getInputConceptsQuery($data, $concepts)
{
foreach ($concepts as $concept) {
$data[] = $this->setData(
[
'concepts' => [
[
'name' => $concept->getName(),
'value' => ... | Generates Input Concept search query and adds it to existing data
@param $data
@param Concept[] $concepts
@return array $data | entailment |
public function getMetadataQuery($data, $metadata)
{
foreach ($metadata as $searchMetadata) {
$data[] = $this->setData(['metadata' => $searchMetadata], 'input');
}
return $data;
} | Generates Metadata search query and adds it to existing data
@param $data
@param array $metadata
@return array $data | entailment |
public function getImagesQuery($data, $inputs)
{
foreach ($inputs as $input) {
$data[] = $this->setData(['image' => ['url' => $input->getImage()]], 'input');
}
return $data;
} | Generates Image search query and adds it to existing data
@param $data
@param Input[] $inputs
@return array $data | entailment |
public function getReverseImagesQuery($data, $inputs)
{
foreach ($inputs as $input) {
$data[] = ['output' => $this->setData(['image' => ['url' => $input->getImage()]], 'input')];
}
return $data;
} | Generates Reverse Image search query and adds it to existing data
@param $data
@param Input[] $inputs
@return array $data | entailment |
public function searchByPredictedConcepts($concepts)
{
$searchResult = $this->getRequest()->request(
'POST',
$this->getRequestUrl('searches'),
$this->getSearchQuery([self::OUTPUT_CONCEPTS => $concepts])
);
return $this->getInputsFromSearchResult($searchRe... | Searches Inputs by predicted Concepts
@param Concept[] $concepts
@return Input[] array | entailment |
public function searchByUserSuppliedConcepts($concepts)
{
$searchResult = $this->getRequest()->request(
'POST',
$this->getRequestUrl('searches'),
$this->getSearchQuery([self::INPUT_CONCEPTS => $concepts])
);
return $this->getInputsFromSearchResult($search... | Searches Inputs by predicted Concepts
@param Concept[] $concepts
@return Input[] array | entailment |
public function searchByCustomMetadata($metadata)
{
$searchResult = $this->getRequest()->request(
'POST',
$this->getRequestUrl('searches'),
$this->getSearchQuery([self::METADATA => $metadata])
);
return $this->getInputsFromSearchResult($searchResult);
... | Searches Inputs custom Metadata
@param array $metadata
@return Input[] array | entailment |
public function searchByReverseImage($inputs)
{
$searchResult = $this->getRequest()->request(
'POST',
$this->getRequestUrl('searches'),
$this->getSearchQuery([self::REVERSED_IMAGES => $inputs])
);
return $this->getInputsFromSearchResult($searchResult);
... | Searches Inputs custom Metadata
@param Input[] $inputs
@return Input[] array | entailment |
public function searchByMatchUrl($inputs)
{
$searchResult = $this->getRequest()->request(
'POST',
$this->getRequestUrl('searches'),
$this->getSearchQuery([self::IMAGES => $inputs])
);
return $this->getInputsFromSearchResult($searchResult);
} | Searches Inputs custom Metadata
@param Input[] $inputs
@return Input[] array | entailment |
public function getInputsFromSearchResult($searchResult)
{
$input_array = [];
if (!isset($searchResult['hits'])) {
throw new \Exception('Hits Not Found');
}
foreach ($searchResult['hits'] as $hit) {
if (!isset($hit['input'])) {
throw new \Exc... | Parses Search Request Result and gets Inputs
@param $searchResult
@return array
@throws \Exception | entailment |
public static function create(Package $package, $version)
{
$result = new static();
$result->package = $package;
$result->version = (string) $version;
$result->createdOn = new DateTime();
$result->updatedOn = new DateTime();
return $result;
} | @param Package $package
@param string $version
@return static | entailment |
public function getDisplayVersion()
{
if ($this->isDevVersion()) {
return t(/*i18n: %s is a version*/'%s development series', substr($this->version, strlen(static::DEV_PREFIX)));
} else {
return $this->version;
}
} | Get the package version display name.
@return string | entailment |
private function getCommentPeopleIDs(TranslatableCommentEntity $comment)
{
$result = [];
$author = $comment->getPostedBy();
if ($author !== null) {
$result[] = $author->getUserID();
}
foreach ($comment->getChildComments() as $childComment) {
$result = ... | @param TranslatableCommentEntity $comment
@return int[] | entailment |
protected function getRecipientIDs(NotificationEntity $notification)
{
$result = [];
$locale = null;
$notificationData = $notification->getNotificationData();
$commentsRepository = $this->app->make(TranslatableCommentRepository::class);
$someComment = false;
// Let's ... | {@inheritdoc}
@see Category::getRecipientIDs() | entailment |
private function markdownToHtml($md)
{
return nl2br(
$this->app->make('helper/text')->autolink(
htmlspecialchars(
$md,
ENT_QUOTES,
APP_CHARSET,
true
)
)
);
} | @param string $md
@return string | entailment |
public function getMailParameters(NotificationEntity $notification, UserInfo $recipient)
{
$notificationData = $notification->getNotificationData();
$localeRepository = $this->app->make(LocaleRepository::class);
if ($notificationData['localeID'] === null) {
$locale = null;
... | {@inheritdoc}
@see Category::getMailParameters() | entailment |
public function getHTMLFragments($gridField)
{
// Set up the split button
$splitButton = new SplitButton('Export', 'Export');
$splitButton->setAttribute('data-icon', 'download-csv');
// XLSX option
$button = new GridField_FormAction(
$gridField,
'xlsx... | @inheritdoc
Create the split button with all the export options.
@param GridField $gridField
@return array | entailment |
protected function genericHandle($dataFormatterClass, $ext, GridField $gridField, $request = null)
{
$items = $this->getItems($gridField);
$this->setHeader($gridField, $ext);
$formater = new $dataFormatterClass();
$formater->setUseLabelsAsHeaders($this->useLabelsAsHeaders);
... | Generic Handle request that will return a Spread Sheet in the requested format
@param string $dataFormatterClass
@param string $ext
@param GridField $gridField
@param SS_HTTPRequest $request
@return string | entailment |
protected function setHeader($gridField, $ext)
{
$do = singleton($gridField->getModelClass());
Controller::curr()->getResponse()
->addHeader(
"Content-Disposition",
'attachment; filename="' .
$do->i18n_plural_name() .
'.' .... | Set the HTTP header to force a download and set the filename.
@param GridField $gridField
@param string $ext Extension to use in the filename. | entailment |
protected function getItems(GridField $gridField)
{
$gridField->getConfig()->removeComponentsByType('GridFieldPaginator');
$items = $gridField->getManipulatedList();
foreach ($gridField->getConfig()->getComponents() as $component) {
if ($component instanceof GridFieldFilterHead... | Helper function to extract the item list out of the GridField.
@param GridField $gridField
@return SS_list | entailment |
public function up()
{
Schema::create(\Config::get('registry.table', 'system_registries'), function(Blueprint $table)
{
$table->string('key');
$table->text('value');
$table->primary('key');
});
} | Run the migrations.
@return void | entailment |
public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
$chainIdentifier = spl_object_hash((object) $first);
return $next($request)->then(function (ResponseInterface $response) use ($request, $chainIdentifier) {
if (array_key_exists($chainIdentifier, ... | {@inheritdoc} | entailment |
public function buildFacebookLike()
{
$facebookLikeProvider = new FacebookLikeProvider(array(
'layout' => $this->configResolver->getParameter('facebook_like.layout', 'ez_share_buttons'),
'width' => $this->configResolver->getParameter('facebook_like.width', 'ez_share_buttons'),
... | Builds Facebook like button provider.
@return \EzSystems\ShareButtonsBundle\SocialShare\ProviderInterface | entailment |
public function buildFacebookRecommend()
{
$facebookRecommendProvider = new FacebookRecommendProvider(array(
'layout' => $this->configResolver->getParameter('facebook_recommend.layout', 'ez_share_buttons'),
'width' => $this->configResolver->getParameter('facebook_recommend.width', 'e... | Builds Facebook recommend button provider.
@return \EzSystems\ShareButtonsBundle\SocialShare\ProviderInterface | entailment |
public function buildTwitter()
{
$twitterProvider = new TwitterProvider(array(
'showUsername' => $this->configResolver->getParameter('twitter.show_username', 'ez_share_buttons'),
'largeButton' => $this->configResolver->getParameter('twitter.large_button', 'ez_share_buttons'),
... | Builds Twitter button provider.
@return \EzSystems\ShareButtonsBundle\SocialShare\ProviderInterface | entailment |
public function buildLinkedin()
{
$linkedinProvider = new LinkedinProvider(array(
'countMode' => $this->configResolver->getParameter('linkedin.count_mode', 'ez_share_buttons'),
'language' => $this->configResolver->getParameter('linkedin.language', 'ez_share_buttons'),
));
... | Builds Linkedin button provider.
@return \EzSystems\ShareButtonsBundle\SocialShare\ProviderInterface | entailment |
public function buildGooglePlus()
{
$googlePlusProvider = new GooglePlusProvider(array(
'size' => $this->configResolver->getParameter('google_plus.size', 'ez_share_buttons'),
'annotation' => $this->configResolver->getParameter('google_plus.annotation', 'ez_share_buttons'),
... | Builds Google Plus button provider.
@return \EzSystems\ShareButtonsBundle\SocialShare\ProviderInterface | entailment |
public function buildXing()
{
$xingProvider = new XingProvider(array(
'shape' => $this->configResolver->getParameter('xing.shape', 'ez_share_buttons'),
'counter' => $this->configResolver->getParameter('xing.counter', 'ez_share_buttons'),
'language' => $this->configResolve... | Builds Xing button provider.
@return \EzSystems\ShareButtonsBundle\SocialShare\ProviderInterface | entailment |
public function import(RemotePackageEntity $remotePackage)
{
$temp = $this->download($remotePackage);
$rootPath = $this->getRootPath($temp);
$this->translatableImporter->importDirectory($rootPath, $remotePackage->getHandle(), $remotePackage->getVersion(), '');
$package = $this->packa... | Import a remote package.
@param RemotePackageEntity $remotePackage
@throws UserMessageException | entailment |
private function download(RemotePackageEntity $remotePackage)
{
$temp = $this->app->make(VolatileDirectory::class);
/* @var VolatileDirectory $temp */
$zipFilename = $temp->getPath() . '/downloaded.zip';
$this->httpClient->reset();
$this->httpClient->setOptions([
... | @param RemotePackageEntity $remotePackage
@throws UserMessageException
@return VolatileDirectory | entailment |
private function decodeGzip($fromFilename, $toFilename)
{
if (!function_exists('gzopen')) {
throw new UserMessageException(t(/*i18n: %s is a compression method, like gzip*/'The PHP zlib extension is required in order to decode "%s" encodings.', 'gzip'));
}
try {
$hFro... | @param string $fromFilename
@param string $toFilename
@throws UserMessageException | entailment |
private function decodeDeflate($fromFilename, $toFilename)
{
if (!function_exists('gzuncompress')) {
throw new UserMessageException(t(/*i18n: %s is a compression method, like gzip*/'The PHP zlib extension is required in order to decode "%s" encodings.', 'deflate'));
}
$compressed... | @param string $fromFilename
@param string $toFilename
@throws UserMessageException | entailment |
private function getRootPath(VolatileDirectory $temp)
{
$fs = $temp->getFilesystem();
$result = $temp->getPath() . '/unzipped';
for (; ;) {
if (count($fs->files($result)) !== 0) {
break;
}
$dirs = $fs->directories($result);
if (... | @param VolatileDirectory $temp
@return string | entailment |
protected function normalizeArgs(array $args)
{
$args += [
'resultsPerPage' => null,
'allowedDownloadFormats' => null,
];
$normalized = [];
$error = $this->app->make('helper/validation/error');
/* @var \Concrete\Core\Error\ErrorList\ErrorList $error */... | {@inheritdoc}
@see BlockController::normalizeArgs() | entailment |
private function getAllowedDownloadFormats(LocaleEntity $locale, $user = 'current', array $approvedLocales = null)
{
$result = [];
$allowedFormats = [];
if ($this->allowedDownloadFormats) {
$tcProvider = $this->app->make(TranslationsConverterProvider::class);
foreach ... | @param LocaleEntity $locale
@param mixed $user
@param LocaleEntity[]|null $approvedLocales
@return \CommunityTranslation\TranslationsConverter\ConverterInterface[] | entailment |
public function percToProgressbarClass($perc, $translatedThreshold = null)
{
if ($translatedThreshold === null) {
$translatedThreshold = $this->getTranslatedThreshold();
}
if ($perc >= 100) {
$percClass = 'progress-bar-success';
} elseif ($perc >= $translatedT... | @param int $perc
@param int|null $translatedThreshold
@return string | entailment |
private function getSearchWords($text)
{
$result = [];
if (is_string($text)) {
$text = trim(preg_replace('/[\W_]+/u', ' ', $text));
if ($text !== '') {
$words = explode(' ', mb_strtolower($text));
$words = array_values(array_unique($words));
... | @param string $text
@return string[] | entailment |
private function buildSearchQuery(array $words)
{
$qb = $this->app->make(PackageRepository::class)->createQueryBuilder('p');
$expr = $qb->expr();
$orFields = $expr->orX();
foreach (['p.handle', 'p.name'] as $fieldName) {
$and = $expr->andX();
foreach ($words a... | @param string[] $words
@return \Doctrine\ORM\QueryBuilder | entailment |
public function saveTranslationsToFile(Translations $translations, $filename)
{
if (!$this->canSerializeTranslations()) {
throw new UserMessageException(t('The "%s" converter is not able to serialize translations', $this->getName()));
}
$serialized = $this->convertTranslationsToS... | {@inheritdoc}
@see ConverterInterface::saveTranslationsToFile() | entailment |
public function loadTranslationsFromFile($filename)
{
if (!$this->canSerializeTranslations()) {
throw new UserMessageException(t('The "%s" converter is not able to unserialize translations', $this->getName()));
}
if (!$this->fs->isFile($filename)) {
throw new UserMes... | {@inheritdoc}
@see ConverterInterface::loadTranslationsFromFile() | entailment |
public function getRequestUser()
{
if ($this->requestUser === null) {
$token = $this->getRequestApiToken();
if ($token === '') {
$this->requestUser = 'no-token';
} else {
$ip = $this->app->make('ip');
if ($ip->isBanned()) {
... | @throws AccessDeniedException
@return User | entailment |
public function checkGenericAccess($configKey)
{
$config = $this->app->make('community_translation/config');
$level = $config->get('options.api.access.' . $configKey);
switch ($level) {
case self::ACCESSOPTION_EVERYBODY:
return;
case self::ACCESSOPTION... | @param string $configKey
@throws AccessDeniedException | entailment |
public function checkLocaleAccess($configKey)
{
$config = $this->app->make('community_translation/config');
$level = $config->get('options.api.access.' . $configKey);
switch ($level) {
case self::ACCESSOPTION_EVERYBODY:
return $this->getApprovedLocales();
... | @param string $configKey
@throws AccessDeniedException
@return \CommunityTranslation\Entity\Locale[] | entailment |
public function getRateLimit()
{
$result = null;
$config = $this->app->make('community_translation/config');
$maxRequests = (int) $config->get('options.api.rateLimit.maxRequests');
if ($maxRequests > 0) {
$timeWindow = (int) $config->get('options.api.rateLimit.timeWindow'... | Returns the defined rate limit (if set).
@return int[]|null First item is the max requests, second limit is the time window. If no rate limit is defined returns null. | entailment |
public function getVisitsCountFromCurrentIP($timeWindow)
{
$timeWindow = (int) $timeWindow;
$ipControlLog = $this->app->make(IPControlLog::class);
return $ipControlLog->countVisits('api', new DateTime("-$timeWindow seconds"));
} | Get the number of visits from the current IP address since a determined number of seconds ago.
@param int $timeWindow
@return int | entailment |
public function checkRateLimit()
{
$rateLimit = $this->getRateLimit();
if ($rateLimit !== null) {
list($maxRequests, $timeWindow) = $rateLimit;
$visits = $this->getVisitsCountFromCurrentIP($timeWindow);
if ($visits >= $maxRequests) {
throw new User... | Check if the API Rate limit has been reached.
@throws UserMessageException | entailment |
public static function create()
{
$result = new static();
$result->devBranches = [];
$result->directoryToParse = '';
$result->directoryForPlaces = '';
$result->detectedVersions = [];
$result->tagToVersionRegexp = '/^(?:v(?:er(?:s(?:ion)?)?)?[.\s]*)?(\d+(?:\.\d+)*)$/';... | Create a new instance.
@return static | entailment |
public function setDirectoryToParse($value)
{
$this->directoryToParse = trim(str_replace(DIRECTORY_SEPARATOR, '/', trim((string) $value)), '/');
return $this;
} | Set the path to the directory to be parsed.
@param string $value
@return static | entailment |
public function setDirectoryForPlaces($value)
{
$this->directoryForPlaces = trim(str_replace(DIRECTORY_SEPARATOR, '/', trim((string) $value)), '/');
return $this;
} | Set the base directory for places.
@param string $value
@return static | entailment |
public function addDetectedVersion($version, $kind, $repoName)
{
$this->detectedVersions[$version] = [
'kind' => $kind,
'repoName' => $repoName,
];
return $this;
} | Add a repository detected version.
@param string $version
@param string $kind
@param string $repoName
@return static | entailment |
public function getDetectedVersion($version)
{
return isset($this->detectedVersions[$version]) ? $this->detectedVersions[$version] : null;
} | Get the repository tag filters.
@param string $version
@return array|null | entailment |
public function setTagFilters(array $value = null)
{
if ($value === null) {
$this->tagFilters = ['none'];
} elseif (empty($value)) {
$this->tagFilters = ['all'];
} else {
$this->tagFilters = $value;
}
return $this;
} | Set the repository tag filters.
@param string[]|null $value Null for no tags, an array otherwise (empty means all tags)
@return static | entailment |
public function getTagFilters()
{
if ($this->tagFilters === ['none']) {
$result = null;
} elseif ($this->tagFilters === ['all']) {
$result = [];
} else {
$result = $this->tagFilters;
}
return $result;
} | Get the repository tag filters.
@return string[]|null | entailment |
public function getTagFiltersExpanded()
{
$tagFilters = $this->getTagFilters();
if ($tagFilters === null) {
$result = null;
} else {
$result = [];
$m = null;
foreach ($tagFilters as $tagFilter) {
if (preg_match('/^\s*([<>=]+)\s*... | Extracts the info for tag filter.
@return null|array(array('operator' => string, 'version' => string)) | entailment |
public function getTagFiltersDisplayName()
{
$expanded = $this->getTagFiltersExpanded();
if ($expanded === null) {
$result = tc('Tags', 'none');
} elseif (count($expanded) === 0) {
$result = tc('Tags', 'all');
} else {
$list = [];
forea... | Get a visual representation of the tag filters.
@return string | entailment |
public static function create(UserEntity $user, Package\Version $packageVersion, $notifyUpdates)
{
$result = new static();
$result->user = $user;
$result->packageVersion = $packageVersion;
$result->notifyUpdates = $notifyUpdates ? true : false;
return $result;
} | @param UserEntity $user User associated to this subscription
@param Package $package package associated to this subscription
@param bool $notifyUpdates Send notifications about updates to this package versions?
@return static | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.