repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
sulu/SuluArticleBundle
Controller/TemplateController.php
TemplateController.getAction
public function getAction(Request $request) { $structureProvider = $this->get('sulu.content.structure_manager'); $type = $request->get('type', 'default'); $templates = []; foreach ($structureProvider->getStructures('article') as $structure) { if ($this->getType($structure->getStructure()) !== $type) { continue; } $templates[] = [ 'internal' => $structure->getInternal(), 'template' => $structure->getKey(), 'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()), ]; } return new JsonResponse( [ '_embedded' => $templates, 'total' => count($templates), ] ); }
php
public function getAction(Request $request) { $structureProvider = $this->get('sulu.content.structure_manager'); $type = $request->get('type', 'default'); $templates = []; foreach ($structureProvider->getStructures('article') as $structure) { if ($this->getType($structure->getStructure()) !== $type) { continue; } $templates[] = [ 'internal' => $structure->getInternal(), 'template' => $structure->getKey(), 'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()), ]; } return new JsonResponse( [ '_embedded' => $templates, 'total' => count($templates), ] ); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ")", "{", "$", "structureProvider", "=", "$", "this", "->", "get", "(", "'sulu.content.structure_manager'", ")", ";", "$", "type", "=", "$", "request", "->", "get", "(", "'type'", ",", "'de...
Returns template for given article type. @param Request $request @return JsonResponse
[ "Returns", "template", "for", "given", "article", "type", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/TemplateController.php#L34-L58
train
sulu/SuluArticleBundle
Document/Serializer/ArticleWebsiteSubscriber.php
ArticleWebsiteSubscriber.appendPageData
public function appendPageData(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if ($article instanceof ArticlePageDocument) { $article = $article->getParent(); } if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website')) { return; } $pageNumber = 1; if ($context->attributes->containsKey('pageNumber')) { $pageNumber = $context->attributes->get('pageNumber')->get(); } $visitor->addData('page', $pageNumber); $visitor->addData('pages', $context->accept($article->getPages())); }
php
public function appendPageData(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if ($article instanceof ArticlePageDocument) { $article = $article->getParent(); } if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website')) { return; } $pageNumber = 1; if ($context->attributes->containsKey('pageNumber')) { $pageNumber = $context->attributes->get('pageNumber')->get(); } $visitor->addData('page', $pageNumber); $visitor->addData('pages', $context->accept($article->getPages())); }
[ "public", "function", "appendPageData", "(", "ObjectEvent", "$", "event", ")", "{", "$", "article", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "context", "=", "$", "...
Append page data. @param ObjectEvent $event
[ "Append", "page", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleWebsiteSubscriber.php#L115-L136
train
sulu/SuluArticleBundle
Document/Serializer/ArticleWebsiteSubscriber.php
ArticleWebsiteSubscriber.getArticleForPage
private function getArticleForPage(ArticleDocument $article, $pageNumber) { $children = $article->getChildren(); if (null === $children || 1 === $pageNumber) { return $article; } foreach ($children as $child) { if ($child instanceof ArticlePageDocument && $child->getPageNumber() === $pageNumber) { return $child; } } return $article; }
php
private function getArticleForPage(ArticleDocument $article, $pageNumber) { $children = $article->getChildren(); if (null === $children || 1 === $pageNumber) { return $article; } foreach ($children as $child) { if ($child instanceof ArticlePageDocument && $child->getPageNumber() === $pageNumber) { return $child; } } return $article; }
[ "private", "function", "getArticleForPage", "(", "ArticleDocument", "$", "article", ",", "$", "pageNumber", ")", "{", "$", "children", "=", "$", "article", "->", "getChildren", "(", ")", ";", "if", "(", "null", "===", "$", "children", "||", "1", "===", "...
Returns article page by page-number. @param ArticleDocument $article @param int $pageNumber @return ArticleDocument
[ "Returns", "article", "page", "by", "page", "-", "number", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleWebsiteSubscriber.php#L171-L185
train
sulu/SuluArticleBundle
Document/Serializer/ArticleWebsiteSubscriber.php
ArticleWebsiteSubscriber.resolve
private function resolve(ArticleInterface $article) { $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $structure->setDocument($article); $data = $article->getStructure()->toArray(); return [ 'content' => $this->contentProxyFactory->createContentProxy($structure, $data), 'view' => $this->contentProxyFactory->createViewProxy($structure, $data), ]; }
php
private function resolve(ArticleInterface $article) { $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $structure->setDocument($article); $data = $article->getStructure()->toArray(); return [ 'content' => $this->contentProxyFactory->createContentProxy($structure, $data), 'view' => $this->contentProxyFactory->createViewProxy($structure, $data), ]; }
[ "private", "function", "resolve", "(", "ArticleInterface", "$", "article", ")", "{", "$", "structure", "=", "$", "this", "->", "structureManager", "->", "getStructure", "(", "$", "article", "->", "getStructureType", "(", ")", ",", "'article'", ")", ";", "$",...
Returns content and view of article. @param ArticleInterface $article @return array
[ "Returns", "content", "and", "view", "of", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleWebsiteSubscriber.php#L215-L226
train
sulu/SuluArticleBundle
Document/Index/Factory/TagCollectionFactory.php
TagCollectionFactory.create
public function create($tagNames) { $collection = new Collection(); foreach ($tagNames as $tagName) { $tagEntity = $this->tagManager->findByName($tagName); if (!$tagEntity) { return; } $tag = new TagViewObject(); $tag->name = $tagName; $tag->id = $tagEntity->getId(); $collection[] = $tag; } return $collection; }
php
public function create($tagNames) { $collection = new Collection(); foreach ($tagNames as $tagName) { $tagEntity = $this->tagManager->findByName($tagName); if (!$tagEntity) { return; } $tag = new TagViewObject(); $tag->name = $tagName; $tag->id = $tagEntity->getId(); $collection[] = $tag; } return $collection; }
[ "public", "function", "create", "(", "$", "tagNames", ")", "{", "$", "collection", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "tagNames", "as", "$", "tagName", ")", "{", "$", "tagEntity", "=", "$", "this", "->", "tagManager", "->", ...
Create tag collection. @param string[] $tagNames @return Collection
[ "Create", "tag", "collection", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/Factory/TagCollectionFactory.php#L45-L64
train
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.dropIndex
protected function dropIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('drop')) { return true; } if (!$input->getOption('no-interaction')) { $output->writeln( '<comment>ATTENTION</comment>: This operation drops and recreates the whole index and deletes the complete data.' ); $output->writeln(''); $question = new ConfirmationQuestion('Are you sure you want to drop the index? [Y/n] '); /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); if (!$questionHelper->ask($input, $output, $question)) { return false; } $output->writeln(''); } $indexer->dropIndex(); $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln( sprintf('Dropped and recreated index for the <comment>`%s`</comment> context' . PHP_EOL, $context) ); return true; }
php
protected function dropIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('drop')) { return true; } if (!$input->getOption('no-interaction')) { $output->writeln( '<comment>ATTENTION</comment>: This operation drops and recreates the whole index and deletes the complete data.' ); $output->writeln(''); $question = new ConfirmationQuestion('Are you sure you want to drop the index? [Y/n] '); /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); if (!$questionHelper->ask($input, $output, $question)) { return false; } $output->writeln(''); } $indexer->dropIndex(); $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln( sprintf('Dropped and recreated index for the <comment>`%s`</comment> context' . PHP_EOL, $context) ); return true; }
[ "protected", "function", "dropIndex", "(", "IndexerInterface", "$", "indexer", ",", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "!", "$", "input", "->", "getOption", "(", "'drop'", ")", ")", "{", "return", "t...
Drop index if requested. @param IndexerInterface $indexer @param InputInterface $input @param OutputInterface $output @return bool
[ "Drop", "index", "if", "requested", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L98-L129
train
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.clearIndex
protected function clearIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('clear')) { return; } $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln(sprintf('Cleared index for the <comment>`%s`</comment> context', $context)); $indexer->clear(); }
php
protected function clearIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('clear')) { return; } $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln(sprintf('Cleared index for the <comment>`%s`</comment> context', $context)); $indexer->clear(); }
[ "protected", "function", "clearIndex", "(", "IndexerInterface", "$", "indexer", ",", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "!", "$", "input", "->", "getOption", "(", "'clear'", ")", ")", "{", "return", ...
Clear article-content of index. @param IndexerInterface $indexer @param InputInterface $input @param OutputInterface $output
[ "Clear", "article", "-", "content", "of", "index", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L138-L147
train
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.indexDocuments
protected function indexDocuments($locale, IndexerInterface $indexer, OutputInterface $output) { $documents = $this->getDocuments($locale); $count = count($documents); if (0 === $count) { $output->writeln(' No documents found'); return; } $progessBar = new ProgressBar($output, $count); $progessBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'); $progessBar->start(); foreach ($documents as $document) { $indexer->index($document); $progessBar->advance(); } $indexer->flush(); $progessBar->finish(); }
php
protected function indexDocuments($locale, IndexerInterface $indexer, OutputInterface $output) { $documents = $this->getDocuments($locale); $count = count($documents); if (0 === $count) { $output->writeln(' No documents found'); return; } $progessBar = new ProgressBar($output, $count); $progessBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'); $progessBar->start(); foreach ($documents as $document) { $indexer->index($document); $progessBar->advance(); } $indexer->flush(); $progessBar->finish(); }
[ "protected", "function", "indexDocuments", "(", "$", "locale", ",", "IndexerInterface", "$", "indexer", ",", "OutputInterface", "$", "output", ")", "{", "$", "documents", "=", "$", "this", "->", "getDocuments", "(", "$", "locale", ")", ";", "$", "count", "...
Index documents for given locale. @param string $locale @param IndexerInterface $indexer @param OutputInterface $output
[ "Index", "documents", "for", "given", "locale", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L156-L177
train
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.getDocuments
protected function getDocuments($locale) { $propertyEncoder = $this->getContainer()->get('sulu_document_manager.property_encoder'); $documentManager = $this->getContainer()->get('sulu_document_manager.document_manager'); $sql2 = sprintf( 'SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "sulu:article" AND [%s] IS NOT NULL', $propertyEncoder->localizedSystemName('template', $locale) ); return $documentManager->createQuery($sql2, $locale, ['load_ghost_content' => false])->execute(); }
php
protected function getDocuments($locale) { $propertyEncoder = $this->getContainer()->get('sulu_document_manager.property_encoder'); $documentManager = $this->getContainer()->get('sulu_document_manager.document_manager'); $sql2 = sprintf( 'SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "sulu:article" AND [%s] IS NOT NULL', $propertyEncoder->localizedSystemName('template', $locale) ); return $documentManager->createQuery($sql2, $locale, ['load_ghost_content' => false])->execute(); }
[ "protected", "function", "getDocuments", "(", "$", "locale", ")", "{", "$", "propertyEncoder", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'sulu_document_manager.property_encoder'", ")", ";", "$", "documentManager", "=", "$", "this", "...
Query for documents with given locale. @param string $locale @return QueryResultInterface
[ "Query", "for", "documents", "with", "given", "locale", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L186-L197
train
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.humanBytes
protected function humanBytes($bytes, $dec = 2) { $size = ['b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = (int) floor((strlen($bytes) - 1) / 3); return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . $size[$factor]; }
php
protected function humanBytes($bytes, $dec = 2) { $size = ['b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = (int) floor((strlen($bytes) - 1) / 3); return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . $size[$factor]; }
[ "protected", "function", "humanBytes", "(", "$", "bytes", ",", "$", "dec", "=", "2", ")", "{", "$", "size", "=", "[", "'b'", ",", "'kB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ",", "'PB'", ",", "'EB'", ",", "'ZB'", ",", "'YB'", "]", ";", "$", ...
Converts bytes into human readable. Inspired by http://jeffreysambells.com/2012/10/25/human-readable-filesize-php @param int $bytes @param int $dec @return string
[ "Converts", "bytes", "into", "human", "readable", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L209-L215
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.getFieldDescriptors
protected function getFieldDescriptors() { return [ 'uuid' => ElasticSearchFieldDescriptor::create('id', 'public.id') ->setDisabled(true) ->build(), 'typeTranslation' => ElasticSearchFieldDescriptor::create('typeTranslation', 'sulu_article.list.type') ->setSortField('typeTranslation.raw') ->setDisabled(!$this->getParameter('sulu_article.display_tab_all')) ->build(), 'title' => ElasticSearchFieldDescriptor::create('title', 'public.title') ->setSortField('title.raw') ->build(), 'creatorFullName' => ElasticSearchFieldDescriptor::create('creatorFullName', 'sulu_article.list.creator') ->setSortField('creatorFullName.raw') ->build(), 'changerFullName' => ElasticSearchFieldDescriptor::create('changerFullName', 'sulu_article.list.changer') ->setSortField('changerFullName.raw') ->build(), 'authorFullName' => ElasticSearchFieldDescriptor::create('authorFullName', 'sulu_article.author') ->setSortField('authorFullName.raw') ->build(), 'created' => ElasticSearchFieldDescriptor::create('created', 'public.created') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'changed' => ElasticSearchFieldDescriptor::create('changed', 'public.changed') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'authored' => ElasticSearchFieldDescriptor::create('authored', 'sulu_article.authored') ->setSortField('authored') ->setType('datetime') ->build(), 'localizationState' => ElasticSearchFieldDescriptor::create('localizationState') ->setDisabled(true) ->build(), 'published' => ElasticSearchFieldDescriptor::create('published') ->setDisabled(true) ->build(), 'publishedState' => ElasticSearchFieldDescriptor::create('publishedState') ->setDisabled(true) ->build(), 'routePath' => ElasticSearchFieldDescriptor::create('routePath') ->setDisabled(true) ->build(), ]; }
php
protected function getFieldDescriptors() { return [ 'uuid' => ElasticSearchFieldDescriptor::create('id', 'public.id') ->setDisabled(true) ->build(), 'typeTranslation' => ElasticSearchFieldDescriptor::create('typeTranslation', 'sulu_article.list.type') ->setSortField('typeTranslation.raw') ->setDisabled(!$this->getParameter('sulu_article.display_tab_all')) ->build(), 'title' => ElasticSearchFieldDescriptor::create('title', 'public.title') ->setSortField('title.raw') ->build(), 'creatorFullName' => ElasticSearchFieldDescriptor::create('creatorFullName', 'sulu_article.list.creator') ->setSortField('creatorFullName.raw') ->build(), 'changerFullName' => ElasticSearchFieldDescriptor::create('changerFullName', 'sulu_article.list.changer') ->setSortField('changerFullName.raw') ->build(), 'authorFullName' => ElasticSearchFieldDescriptor::create('authorFullName', 'sulu_article.author') ->setSortField('authorFullName.raw') ->build(), 'created' => ElasticSearchFieldDescriptor::create('created', 'public.created') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'changed' => ElasticSearchFieldDescriptor::create('changed', 'public.changed') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'authored' => ElasticSearchFieldDescriptor::create('authored', 'sulu_article.authored') ->setSortField('authored') ->setType('datetime') ->build(), 'localizationState' => ElasticSearchFieldDescriptor::create('localizationState') ->setDisabled(true) ->build(), 'published' => ElasticSearchFieldDescriptor::create('published') ->setDisabled(true) ->build(), 'publishedState' => ElasticSearchFieldDescriptor::create('publishedState') ->setDisabled(true) ->build(), 'routePath' => ElasticSearchFieldDescriptor::create('routePath') ->setDisabled(true) ->build(), ]; }
[ "protected", "function", "getFieldDescriptors", "(", ")", "{", "return", "[", "'uuid'", "=>", "ElasticSearchFieldDescriptor", "::", "create", "(", "'id'", ",", "'public.id'", ")", "->", "setDisabled", "(", "true", ")", "->", "build", "(", ")", ",", "'typeTrans...
Create field-descriptor array. @return ElasticSearchFieldDescriptor[]
[ "Create", "field", "-", "descriptor", "array", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L62-L111
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.cgetFieldsAction
public function cgetFieldsAction() { $fieldDescriptors = $this->getFieldDescriptors(); return $this->handleView($this->view(array_values($fieldDescriptors))); }
php
public function cgetFieldsAction() { $fieldDescriptors = $this->getFieldDescriptors(); return $this->handleView($this->view(array_values($fieldDescriptors))); }
[ "public", "function", "cgetFieldsAction", "(", ")", "{", "$", "fieldDescriptors", "=", "$", "this", "->", "getFieldDescriptors", "(", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "array_values", "(", "$", "field...
Returns fields. @return Response
[ "Returns", "fields", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L118-L123
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.getAction
public function getAction($uuid, Request $request) { $locale = $this->getRequestParameter($request, 'locale', true); $document = $this->getDocumentManager()->find( $uuid, $locale ); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
php
public function getAction($uuid, Request $request) { $locale = $this->getRequestParameter($request, 'locale', true); $document = $this->getDocumentManager()->find( $uuid, $locale ); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
[ "public", "function", "getAction", "(", "$", "uuid", ",", "Request", "$", "request", ")", "{", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "true", ")", ";", "$", "document", "=", "$", "this",...
Returns single article. @param string $uuid @param Request $request @return Response
[ "Returns", "single", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L313-L328
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.postAction
public function postAction(Request $request) { $action = $request->get('action'); $document = $this->getDocumentManager()->create(self::DOCUMENT_TYPE); $locale = $this->getRequestParameter($request, 'locale', true); $data = $request->request->all(); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
php
public function postAction(Request $request) { $action = $request->get('action'); $document = $this->getDocumentManager()->create(self::DOCUMENT_TYPE); $locale = $this->getRequestParameter($request, 'locale', true); $data = $request->request->all(); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ")", "{", "$", "action", "=", "$", "request", "->", "get", "(", "'action'", ")", ";", "$", "document", "=", "$", "this", "->", "getDocumentManager", "(", ")", "->", "create", "(", "sel...
Create article. @param Request $request @return Response
[ "Create", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L337-L355
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.putAction
public function putAction(Request $request, $uuid) { $locale = $this->getRequestParameter($request, 'locale', true); $action = $request->get('action'); $data = $request->request->all(); $document = $this->getDocumentManager()->find( $uuid, $locale, [ 'load_ghost_content' => false, 'load_shadow_content' => false, ] ); $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid()); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
php
public function putAction(Request $request, $uuid) { $locale = $this->getRequestParameter($request, 'locale', true); $action = $request->get('action'); $data = $request->request->all(); $document = $this->getDocumentManager()->find( $uuid, $locale, [ 'load_ghost_content' => false, 'load_shadow_content' => false, ] ); $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid()); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
[ "public", "function", "putAction", "(", "Request", "$", "request", ",", "$", "uuid", ")", "{", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "true", ")", ";", "$", "action", "=", "$", "request"...
Update articles. @param Request $request @param string $uuid @return Response
[ "Update", "articles", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L365-L393
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.orderPages
private function orderPages(array $pages, $locale) { $documentManager = $this->getDocumentManager(); for ($i = 0; $i < count($pages); ++$i) { $document = $documentManager->find($pages[$i], $locale); $documentManager->reorder($document, null); } }
php
private function orderPages(array $pages, $locale) { $documentManager = $this->getDocumentManager(); for ($i = 0; $i < count($pages); ++$i) { $document = $documentManager->find($pages[$i], $locale); $documentManager->reorder($document, null); } }
[ "private", "function", "orderPages", "(", "array", "$", "pages", ",", "$", "locale", ")", "{", "$", "documentManager", "=", "$", "this", "->", "getDocumentManager", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$...
Ordering given pages. @param array $pages @param string $locale
[ "Ordering", "given", "pages", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L528-L536
train
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.persistDocument
private function persistDocument($data, $document, $locale) { $formType = $this->getMetadataFactory()->getMetadataForAlias('article')->getFormType(); $form = $this->createForm( $formType, $document, [ // disable csrf protection, since we can't produce a token, because the form is cached on the client 'csrf_protection' => false, ] ); $form->submit($data, false); if (!$form->isValid()) { throw new InvalidFormException($form); } if (array_key_exists('author', $data) && null === $data['author']) { $document->setAuthor(null); } if (array_key_exists('additionalWebspaces', $data) && null === $data['additionalWebspaces']) { $document->setAdditionalWebspaces(null); } $this->getDocumentManager()->persist( $document, $locale, [ 'user' => $this->getUser()->getId(), 'clear_missing_content' => false, ] ); }
php
private function persistDocument($data, $document, $locale) { $formType = $this->getMetadataFactory()->getMetadataForAlias('article')->getFormType(); $form = $this->createForm( $formType, $document, [ // disable csrf protection, since we can't produce a token, because the form is cached on the client 'csrf_protection' => false, ] ); $form->submit($data, false); if (!$form->isValid()) { throw new InvalidFormException($form); } if (array_key_exists('author', $data) && null === $data['author']) { $document->setAuthor(null); } if (array_key_exists('additionalWebspaces', $data) && null === $data['additionalWebspaces']) { $document->setAdditionalWebspaces(null); } $this->getDocumentManager()->persist( $document, $locale, [ 'user' => $this->getUser()->getId(), 'clear_missing_content' => false, ] ); }
[ "private", "function", "persistDocument", "(", "$", "data", ",", "$", "document", ",", "$", "locale", ")", "{", "$", "formType", "=", "$", "this", "->", "getMetadataFactory", "(", ")", "->", "getMetadataForAlias", "(", "'article'", ")", "->", "getFormType", ...
Persists the document using the given Formation. @param array $data @param object $document @param string $locale @throws InvalidFormException @throws MissingParameterException
[ "Persists", "the", "document", "using", "the", "given", "Formation", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L556-L589
train
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleHydrate
public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior || !$node->hasProperty($propertyName)) { return; } $node = $event->getNode(); $document->setPageNumber($node->getPropertyValue($this->propertyEncoder->systemName(static::FIELD))); }
php
public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior || !$node->hasProperty($propertyName)) { return; } $node = $event->getNode(); $document->setPageNumber($node->getPropertyValue($this->propertyEncoder->systemName(static::FIELD))); }
[ "public", "function", "handleHydrate", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "propertyName", "=", "$", ...
Set the page-number to existing pages. @param HydrateEvent $event
[ "Set", "the", "page", "-", "number", "to", "existing", "pages", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L85-L96
train
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handlePersist
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $parentDocument = $document->getParent(); $page = 1; foreach ($parentDocument->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } ++$page; if ($child === $document) { break; } } $node->setProperty($propertyName, $page); $document->setPageNumber($page); }
php
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $parentDocument = $document->getParent(); $page = 1; foreach ($parentDocument->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } ++$page; if ($child === $document) { break; } } $node->setProperty($propertyName, $page); $document->setPageNumber($page); }
[ "public", "function", "handlePersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "propertyName", "=", "$", ...
Set the page-number to new pages. @param PersistEvent $event
[ "Set", "the", "page", "-", "number", "to", "new", "pages", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L103-L129
train
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleReorder
public function handleReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $propertyName = $this->propertyEncoder->systemName(static::FIELD); $parentNode = $this->documentInspector->getNode($document->getParent()); $page = 1; foreach ($parentNode->getNodes() as $childNode) { $child = $this->documentManager->find($childNode->getIdentifier(), $event->getLocale()); if (!$child instanceof PageBehavior) { continue; } $childNode->setProperty($propertyName, ++$page); $child->setPageNumber($page); } }
php
public function handleReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $propertyName = $this->propertyEncoder->systemName(static::FIELD); $parentNode = $this->documentInspector->getNode($document->getParent()); $page = 1; foreach ($parentNode->getNodes() as $childNode) { $child = $this->documentManager->find($childNode->getIdentifier(), $event->getLocale()); if (!$child instanceof PageBehavior) { continue; } $childNode->setProperty($propertyName, ++$page); $child->setPageNumber($page); } }
[ "public", "function", "handleReorder", "(", "ReorderEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "PageBehavior", ")", "{", "return", ";", "}", "$", ...
Adjust the page-numbers of siblings when reordering a page. @param ReorderEvent $event
[ "Adjust", "the", "page", "-", "numbers", "of", "siblings", "when", "reordering", "a", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L136-L156
train
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handlePublishPageNumber
public function handlePublishPageNumber(PublishEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $node->setProperty($propertyName, $document->getPageNumber()); }
php
public function handlePublishPageNumber(PublishEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $node->setProperty($propertyName, $document->getPageNumber()); }
[ "public", "function", "handlePublishPageNumber", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "propertyName", "="...
Copy page-number to live workspace. @param PublishEvent $event
[ "Copy", "page", "-", "number", "to", "live", "workspace", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L163-L173
train
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleRemove
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $page = 1; foreach ($document->getParent()->getChildren() as $child) { if (!$child instanceof PageBehavior || $child->getUuid() === $document->getUuid()) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
php
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $page = 1; foreach ($document->getParent()->getChildren() as $child) { if (!$child instanceof PageBehavior || $child->getUuid() === $document->getUuid()) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
[ "public", "function", "handleRemove", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "PageBehavior", ")", "{", "return", ";", "}", "$", ...
Adjust the page-numbers of siblings when removing a page. @param RemoveEvent $event
[ "Adjust", "the", "page", "-", "numbers", "of", "siblings", "when", "removing", "a", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L180-L196
train
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleRestore
public function handleRestore(RestoreEvent $event) { $document = $event->getDocument(); if (!$document instanceof ChildrenBehavior) { return; } $page = 1; foreach ($document->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
php
public function handleRestore(RestoreEvent $event) { $document = $event->getDocument(); if (!$document instanceof ChildrenBehavior) { return; } $page = 1; foreach ($document->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
[ "public", "function", "handleRestore", "(", "RestoreEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ChildrenBehavior", ")", "{", "return", ";", "}", "...
Adjust the page-numbers of siblings when restoring a page. @param RestoreEvent $event
[ "Adjust", "the", "page", "-", "numbers", "of", "siblings", "when", "restoring", "a", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L203-L219
train
sulu/SuluArticleBundle
Admin/ArticleJsConfig.php
ArticleJsConfig.getTitle
private function getTitle($type) { if (!array_key_exists($type, $this->typeConfiguration)) { return ucfirst($type); } return $this->typeConfiguration[$type]['translation_key']; }
php
private function getTitle($type) { if (!array_key_exists($type, $this->typeConfiguration)) { return ucfirst($type); } return $this->typeConfiguration[$type]['translation_key']; }
[ "private", "function", "getTitle", "(", "$", "type", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "typeConfiguration", ")", ")", "{", "return", "ucfirst", "(", "$", "type", ")", ";", "}", "return", "$", "thi...
Returns title for given type. @param string $type @return string
[ "Returns", "title", "for", "given", "type", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Admin/ArticleJsConfig.php#L121-L128
train
sulu/SuluArticleBundle
Document/Serializer/ArticlePageSubscriber.php
ArticlePageSubscriber.addTitleOnPostSerialize
public function addTitleOnPostSerialize(ObjectEvent $event) { $articlePage = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!$articlePage instanceof ArticlePageDocument) { return; } $visitor->addData('title', $context->accept($articlePage->getParent()->getTitle())); }
php
public function addTitleOnPostSerialize(ObjectEvent $event) { $articlePage = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!$articlePage instanceof ArticlePageDocument) { return; } $visitor->addData('title', $context->accept($articlePage->getParent()->getTitle())); }
[ "public", "function", "addTitleOnPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "articlePage", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "context", "=...
Append title to result. @param ObjectEvent $event
[ "Append", "title", "to", "result", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticlePageSubscriber.php#L43-L54
train
sulu/SuluArticleBundle
Routing/ArticleRouteDefaultProvider.php
ArticleRouteDefaultProvider.isPublished
public function isPublished($entityClass, $id, $locale) { $object = $this->documentManager->find($id, $locale); if (!$object instanceof ArticleInterface || WorkflowStage::PUBLISHED !== $object->getWorkflowStage()) { return false; } if (!$object instanceof WebspaceBehavior) { return true; } $webspace = $this->requestAnalyzer->getWebspace(); if (!$webspace || ( $this->webspaceResolver->resolveMainWebspace($object) !== $webspace->getKey() && !in_array($webspace->getKey(), $this->webspaceResolver->resolveAdditionalWebspaces($object)) ) ) { return false; } return true; }
php
public function isPublished($entityClass, $id, $locale) { $object = $this->documentManager->find($id, $locale); if (!$object instanceof ArticleInterface || WorkflowStage::PUBLISHED !== $object->getWorkflowStage()) { return false; } if (!$object instanceof WebspaceBehavior) { return true; } $webspace = $this->requestAnalyzer->getWebspace(); if (!$webspace || ( $this->webspaceResolver->resolveMainWebspace($object) !== $webspace->getKey() && !in_array($webspace->getKey(), $this->webspaceResolver->resolveAdditionalWebspaces($object)) ) ) { return false; } return true; }
[ "public", "function", "isPublished", "(", "$", "entityClass", ",", "$", "id", ",", "$", "locale", ")", "{", "$", "object", "=", "$", "this", "->", "documentManager", "->", "find", "(", "$", "id", ",", "$", "locale", ")", ";", "if", "(", "!", "$", ...
If article is not published the document will be of typ unknown-document. Also check the workflow stage if it`s a ArticleDocument. {@inheritdoc}
[ "If", "article", "is", "not", "published", "the", "document", "will", "be", "of", "typ", "unknown", "-", "document", ".", "Also", "check", "the", "workflow", "stage", "if", "it", "s", "a", "ArticleDocument", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Routing/ArticleRouteDefaultProvider.php#L127-L150
train
sulu/SuluArticleBundle
Routing/ArticleRouteDefaultProvider.php
ArticleRouteDefaultProvider.getCacheLifetime
private function getCacheLifetime($metadata) { $cacheLifetime = $metadata->cacheLifetime; if (!$cacheLifetime) { return null; } if (!is_array($cacheLifetime) || !isset($cacheLifetime['type']) || !isset($cacheLifetime['value']) || !$this->cacheLifetimeResolver->supports($cacheLifetime['type'], $cacheLifetime['value']) ) { throw new \InvalidArgumentException( sprintf('Invalid cachelifetime in article route default provider: %s', var_export($cacheLifetime, true)) ); } return $this->cacheLifetimeResolver->resolve($cacheLifetime['type'], $cacheLifetime['value']); }
php
private function getCacheLifetime($metadata) { $cacheLifetime = $metadata->cacheLifetime; if (!$cacheLifetime) { return null; } if (!is_array($cacheLifetime) || !isset($cacheLifetime['type']) || !isset($cacheLifetime['value']) || !$this->cacheLifetimeResolver->supports($cacheLifetime['type'], $cacheLifetime['value']) ) { throw new \InvalidArgumentException( sprintf('Invalid cachelifetime in article route default provider: %s', var_export($cacheLifetime, true)) ); } return $this->cacheLifetimeResolver->resolve($cacheLifetime['type'], $cacheLifetime['value']); }
[ "private", "function", "getCacheLifetime", "(", "$", "metadata", ")", "{", "$", "cacheLifetime", "=", "$", "metadata", "->", "cacheLifetime", ";", "if", "(", "!", "$", "cacheLifetime", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_array", "("...
Get cache life time. @param StructureMetadata $metadata @return int|null
[ "Get", "cache", "life", "time", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Routing/ArticleRouteDefaultProvider.php#L170-L189
train
sulu/SuluArticleBundle
Controller/WebsiteArticleController.php
WebsiteArticleController.indexAction
public function indexAction(Request $request, ArticleInterface $object, $view, $pageNumber = 1) { return $this->renderArticle($request, $object, $view, $pageNumber); }
php
public function indexAction(Request $request, ArticleInterface $object, $view, $pageNumber = 1) { return $this->renderArticle($request, $object, $view, $pageNumber); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ",", "ArticleInterface", "$", "object", ",", "$", "view", ",", "$", "pageNumber", "=", "1", ")", "{", "return", "$", "this", "->", "renderArticle", "(", "$", "request", ",", "$", "objec...
Article index action. @param Request $request @param ArticleInterface $object @param string $view @param int $pageNumber @return Response
[ "Article", "index", "action", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/WebsiteArticleController.php#L39-L42
train
sulu/SuluArticleBundle
Controller/WebsiteArticleController.php
WebsiteArticleController.renderArticle
protected function renderArticle(Request $request, ArticleInterface $object, $view, $pageNumber, $attributes = []) { $object = $this->normalizeArticle($object); $requestFormat = $request->getRequestFormat(); $viewTemplate = $view . '.' . $requestFormat . '.twig'; $content = $this->serializeArticle($object, $pageNumber); try { return $this->render( $viewTemplate, $this->get('sulu_website.resolver.template_attribute')->resolve(array_merge($content, $attributes)), $this->createResponse($request) ); } catch (\InvalidArgumentException $exception) { // template not found throw new HttpException(406, 'Error encountered when rendering content', $exception); } }
php
protected function renderArticle(Request $request, ArticleInterface $object, $view, $pageNumber, $attributes = []) { $object = $this->normalizeArticle($object); $requestFormat = $request->getRequestFormat(); $viewTemplate = $view . '.' . $requestFormat . '.twig'; $content = $this->serializeArticle($object, $pageNumber); try { return $this->render( $viewTemplate, $this->get('sulu_website.resolver.template_attribute')->resolve(array_merge($content, $attributes)), $this->createResponse($request) ); } catch (\InvalidArgumentException $exception) { // template not found throw new HttpException(406, 'Error encountered when rendering content', $exception); } }
[ "protected", "function", "renderArticle", "(", "Request", "$", "request", ",", "ArticleInterface", "$", "object", ",", "$", "view", ",", "$", "pageNumber", ",", "$", "attributes", "=", "[", "]", ")", "{", "$", "object", "=", "$", "this", "->", "normalize...
Render article with given view. @param Request $request @param ArticleInterface $object @param string $view @param int $pageNumber @param array $attributes @return Response
[ "Render", "article", "with", "given", "view", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/WebsiteArticleController.php#L55-L74
train
sulu/SuluArticleBundle
Controller/WebsiteArticleController.php
WebsiteArticleController.serializeArticle
protected function serializeArticle(ArticleInterface $object, $pageNumber) { return $this->get('jms_serializer')->serialize( $object, 'array', SerializationContext::create() ->setSerializeNull(true) ->setGroups(['website', 'content']) ->setAttribute('website', true) ->setAttribute('pageNumber', $pageNumber) ); }
php
protected function serializeArticle(ArticleInterface $object, $pageNumber) { return $this->get('jms_serializer')->serialize( $object, 'array', SerializationContext::create() ->setSerializeNull(true) ->setGroups(['website', 'content']) ->setAttribute('website', true) ->setAttribute('pageNumber', $pageNumber) ); }
[ "protected", "function", "serializeArticle", "(", "ArticleInterface", "$", "object", ",", "$", "pageNumber", ")", "{", "return", "$", "this", "->", "get", "(", "'jms_serializer'", ")", "->", "serialize", "(", "$", "object", ",", "'array'", ",", "SerializationC...
Serialize given article with page-number. @param ArticleInterface $object @param int $pageNumber @return array
[ "Serialize", "given", "article", "with", "page", "-", "number", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/WebsiteArticleController.php#L101-L112
train
sulu/SuluArticleBundle
Content/PageTreeRouteContentType.php
PageTreeRouteContentType.readPage
private function readPage($propertyName, NodeInterface $node) { $pagePropertyName = $propertyName . '-page'; if (!$node->hasProperty($pagePropertyName)) { return; } try { $pageUuid = $node->getPropertyValue($pagePropertyName, PropertyType::STRING); } catch (ItemNotFoundException $exception) { return; } return [ 'uuid' => $pageUuid, 'path' => $node->getPropertyValueWithDefault($pagePropertyName . '-path', ''), 'webspace' => $node->getPropertyValueWithDefault($pagePropertyName . '-webspace', null), ]; }
php
private function readPage($propertyName, NodeInterface $node) { $pagePropertyName = $propertyName . '-page'; if (!$node->hasProperty($pagePropertyName)) { return; } try { $pageUuid = $node->getPropertyValue($pagePropertyName, PropertyType::STRING); } catch (ItemNotFoundException $exception) { return; } return [ 'uuid' => $pageUuid, 'path' => $node->getPropertyValueWithDefault($pagePropertyName . '-path', ''), 'webspace' => $node->getPropertyValueWithDefault($pagePropertyName . '-webspace', null), ]; }
[ "private", "function", "readPage", "(", "$", "propertyName", ",", "NodeInterface", "$", "node", ")", "{", "$", "pagePropertyName", "=", "$", "propertyName", ".", "'-page'", ";", "if", "(", "!", "$", "node", "->", "hasProperty", "(", "$", "pagePropertyName", ...
Read page-information from given node. @param string $propertyName @param NodeInterface $node @return array
[ "Read", "page", "-", "information", "from", "given", "node", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/PageTreeRouteContentType.php#L194-L212
train
sulu/SuluArticleBundle
Content/PageTreeRouteContentType.php
PageTreeRouteContentType.generateSuffix
private function generateSuffix(NodeInterface $node, $locale, $pagePath) { $document = $this->documentRegistry->getDocumentForNode($node, $locale); $route = $this->chainRouteGenerator->generate($document); $route->setPath(rtrim($pagePath, '/') . '/' . ltrim($route->getPath(), '/')); $route = $this->conflictResolver->resolve($route); return substr($route->getPath(), strlen(rtrim($pagePath, '/')) + 1); }
php
private function generateSuffix(NodeInterface $node, $locale, $pagePath) { $document = $this->documentRegistry->getDocumentForNode($node, $locale); $route = $this->chainRouteGenerator->generate($document); $route->setPath(rtrim($pagePath, '/') . '/' . ltrim($route->getPath(), '/')); $route = $this->conflictResolver->resolve($route); return substr($route->getPath(), strlen(rtrim($pagePath, '/')) + 1); }
[ "private", "function", "generateSuffix", "(", "NodeInterface", "$", "node", ",", "$", "locale", ",", "$", "pagePath", ")", "{", "$", "document", "=", "$", "this", "->", "documentRegistry", "->", "getDocumentForNode", "(", "$", "node", ",", "$", "locale", "...
Generate a new suffix for document. @param NodeInterface $node @param string $locale @param string $pagePath @return string
[ "Generate", "a", "new", "suffix", "for", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/PageTreeRouteContentType.php#L241-L250
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.startGroup
public function startGroup($options = []) { $options += [ 'id' => 'panelGroup-'.(++$this->_groupCount), 'collapsible' => true, 'open' => 0, 'templateVars' => [] ]; $this->_states->push('group', [ 'groupPanelOpen' => $options['open'], 'groupPanelCount' => -1, 'groupId' => $options['id'], 'groupCollapsible' => $options['collapsible'] ]); return $this->formatTemplate('panelGroupStart', [ 'attrs' => $this->templater()->formatAttributes($options, ['open', 'collapsible']), 'templateVars' => $options['templateVars'] ]); }
php
public function startGroup($options = []) { $options += [ 'id' => 'panelGroup-'.(++$this->_groupCount), 'collapsible' => true, 'open' => 0, 'templateVars' => [] ]; $this->_states->push('group', [ 'groupPanelOpen' => $options['open'], 'groupPanelCount' => -1, 'groupId' => $options['id'], 'groupCollapsible' => $options['collapsible'] ]); return $this->formatTemplate('panelGroupStart', [ 'attrs' => $this->templater()->formatAttributes($options, ['open', 'collapsible']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "startGroup", "(", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'id'", "=>", "'panelGroup-'", ".", "(", "++", "$", "this", "->", "_groupCount", ")", ",", "'collapsible'", "=>", "true", ",", "'open'", "=>", ...
Open a panel group. ### Options - `collapsible` Set to `false` if panels should not be collapsible. Default is `true`. - `id` Identifier for the group. Default is automatically generated. - `open` If `collapsible` is `true`, indicate the panel that should be open by default. Set to `false` to have no panels open. You can also indicate if a panel should be open in the `create()` method. Default is `0`. - Other attributes will be passed to the `Html::div()` method. @param array $options Array of options. See above. @return string A formated opening HTML tag for panel groups. @link http://getbootstrap.com/javascript/#collapse-example-accordion
[ "Open", "a", "panel", "group", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L134-L151
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.endGroup
public function endGroup() { $out = ''; while ($this->_states->is('panel')) { // panels were not closed $out .= $this->end(); } $out .= $this->formatTemplate('panelGroupEnd', []); $this->_states->pop(); return $out; }
php
public function endGroup() { $out = ''; while ($this->_states->is('panel')) { // panels were not closed $out .= $this->end(); } $out .= $this->formatTemplate('panelGroupEnd', []); $this->_states->pop(); return $out; }
[ "public", "function", "endGroup", "(", ")", "{", "$", "out", "=", "''", ";", "while", "(", "$", "this", "->", "_states", "->", "is", "(", "'panel'", ")", ")", "{", "// panels were not closed", "$", "out", ".=", "$", "this", "->", "end", "(", ")", "...
Closes a panel group, closes the last panel if it has not already been closed. @return string An HTML string containing closing tags.
[ "Closes", "a", "panel", "group", "closes", "the", "last", "panel", "if", "it", "has", "not", "already", "been", "closed", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L158-L166
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.create
public function create($title = null, $options = []) { if (is_array($title)) { $options = $title; $title = null; } $out = ''; // close previous panel if in group if ($this->_states->is('panel') && $this->_states->getValue('inGroup')) { $out .= $this->end(); } $options += [ 'body' => true, 'type' => 'default', 'collapsible' => $this->_states->is('group') ? $this->_states->getValue('groupCollapsible') : $this->getConfig('collapsible'), 'open' => !$this->_states->is('group'), 'panel-count' => $this->_panelCount, 'title' => [], 'templateVars' => [] ]; $this->_panelCount = intval($options['panel-count']) + 1; // check open $open = $options['open']; if ($this->_states->is('group')) { // increment count inside $this->_states->setValue('groupPanelCount', $this->_states->getValue('groupPanelCount') + 1); $open = $open || $this->_states->getValue('groupPanelOpen') == $this->_states->getValue('groupPanelCount'); } $out .= $this->formatTemplate('panelStart', [ 'type' => $options['type'], 'attrs' => $this->templater()->formatAttributes( $options, ['body', 'type', 'collapsible', 'open', 'panel-count', 'title']), 'templateVars' => $options['templateVars'] ]); $this->_states->push('panel', [ 'part' => null, 'bodyId' => 'collapse-'.$options['panel-count'], 'headId' => 'heading-'.$options['panel-count'], 'collapsible' => $options['collapsible'], 'open' => $open, 'inGroup' => $this->_states->is('group'), 'groupId' => $this->_states->is('group') ? $this->_states->getValue('groupId') : 0 ]); if (is_string($title) && $title) { $out .= $this->_createHeader($title, [ 'title' => $options['title'] ]); if ($options['body']) { $out .= $this->_createBody(); } } return $out; }
php
public function create($title = null, $options = []) { if (is_array($title)) { $options = $title; $title = null; } $out = ''; // close previous panel if in group if ($this->_states->is('panel') && $this->_states->getValue('inGroup')) { $out .= $this->end(); } $options += [ 'body' => true, 'type' => 'default', 'collapsible' => $this->_states->is('group') ? $this->_states->getValue('groupCollapsible') : $this->getConfig('collapsible'), 'open' => !$this->_states->is('group'), 'panel-count' => $this->_panelCount, 'title' => [], 'templateVars' => [] ]; $this->_panelCount = intval($options['panel-count']) + 1; // check open $open = $options['open']; if ($this->_states->is('group')) { // increment count inside $this->_states->setValue('groupPanelCount', $this->_states->getValue('groupPanelCount') + 1); $open = $open || $this->_states->getValue('groupPanelOpen') == $this->_states->getValue('groupPanelCount'); } $out .= $this->formatTemplate('panelStart', [ 'type' => $options['type'], 'attrs' => $this->templater()->formatAttributes( $options, ['body', 'type', 'collapsible', 'open', 'panel-count', 'title']), 'templateVars' => $options['templateVars'] ]); $this->_states->push('panel', [ 'part' => null, 'bodyId' => 'collapse-'.$options['panel-count'], 'headId' => 'heading-'.$options['panel-count'], 'collapsible' => $options['collapsible'], 'open' => $open, 'inGroup' => $this->_states->is('group'), 'groupId' => $this->_states->is('group') ? $this->_states->getValue('groupId') : 0 ]); if (is_string($title) && $title) { $out .= $this->_createHeader($title, [ 'title' => $options['title'] ]); if ($options['body']) { $out .= $this->_createBody(); } } return $out; }
[ "public", "function", "create", "(", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "$", "options", "=", "$", "title", ";", "$", "title", "=", "null", ";", "}", ...
Open a panel. If `$title` is a string, the panel header is created using `$title` as its content and default options (except for the `title` options that can be specified inside `$options`). ```php echo $this->Panel->create('My Panel Title', ['title' => ['tag' => 'h2']]); ``` If the panel header is created, the panel body is automatically opened after it, except if the `no-body` options is specified (see below). If `$title` is an array, it is used as `$options`. ```php echo $this->Panel->create(['class' => 'my-panel-class']); ``` If the `create()` method is used inside a panel group, the previous panel is automatically closed. ### Options - `collapsible` Set to `true` if the panel should be collapsible. Default is fetch from configuration/ - `body` If `$title` is a string, set to `false` to not open the body after the panel header. Default is `true`. - `open` Indicate if the panel should be open. If the panel is not inside a group, the default is `true`, otherwize the default is `false` and the panel is open if its count matches the specified value in `startGroup()` (set to `true` inside a group to force the panel to be open). - `panel-count` Panel counter, can be used to override the default counter when inside a group. This value is used to generate the panel, header and body ID attribute. - `title` Array of options for the title. Default is []. - `type` Type of the panel (`'default'`, `'primary'`, ...). Default is `'default'`. - Other options will be passed to the `Html::div` method for creating the panel `<div>`. @param array|string $title The panel title or an array of options. @param array $options Array of options. See above. @return string An HTML string containing opening elements for a panel.
[ "Open", "a", "panel", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L213-L279
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.end
public function end($content = null, $options = []) { $this->_lastPanelClosed = true; $res = ''; $res .= $this->_cleanCurrent(); if ($content !== null) { $res .= $this->footer($content, $options); } $res .= $this->formatTemplate('panelEnd', []); $this->_states->pop(); return $res; }
php
public function end($content = null, $options = []) { $this->_lastPanelClosed = true; $res = ''; $res .= $this->_cleanCurrent(); if ($content !== null) { $res .= $this->footer($content, $options); } $res .= $this->formatTemplate('panelEnd', []); $this->_states->pop(); return $res; }
[ "public", "function", "end", "(", "$", "content", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "_lastPanelClosed", "=", "true", ";", "$", "res", "=", "''", ";", "$", "res", ".=", "$", "this", "->", "_cleanCurrent", ...
Closes a panel, cleans part that have not been closed correctly and optionaly adds a footer to the panel. If `$content` is not null, the `footer()` methods will be used to create the panel footer using `$content` and `$options`. ```php echo $this->Panel->end('Footer Content', ['my-class' => 'my-footer-class']); ``` @param string|null $content Footer content, or `null`. @param array $options Array of options for the footer. @return string An HTML string containing closing tags.
[ "Closes", "a", "panel", "cleans", "part", "that", "have", "not", "been", "closed", "correctly", "and", "optionaly", "adds", "a", "footer", "to", "the", "panel", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L297-L307
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper._cleanCurrent
protected function _cleanCurrent() { if (!$this->_states->is('panel')) { return ''; } $current = $this->_states->getValue('part'); if ($current === null) { return ''; } $out = $this->formatTemplate($current.'End', []); if ($this->_states->getValue('collapsible')) { $ctplt = $current.'CollapsibleEnd'; if ($this->getTemplates($ctplt)) { $out = $this->formatTemplate($ctplt, [ $current.'End' => $out ]); } } $this->_states->setValue('part', null); return $out; }
php
protected function _cleanCurrent() { if (!$this->_states->is('panel')) { return ''; } $current = $this->_states->getValue('part'); if ($current === null) { return ''; } $out = $this->formatTemplate($current.'End', []); if ($this->_states->getValue('collapsible')) { $ctplt = $current.'CollapsibleEnd'; if ($this->getTemplates($ctplt)) { $out = $this->formatTemplate($ctplt, [ $current.'End' => $out ]); } } $this->_states->setValue('part', null); return $out; }
[ "protected", "function", "_cleanCurrent", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_states", "->", "is", "(", "'panel'", ")", ")", "{", "return", "''", ";", "}", "$", "current", "=", "$", "this", "->", "_states", "->", "getValue", "(", "'...
Cleans the current panel part and return necessary HTML closing elements. @return string An HTML string containing closing elements.
[ "Cleans", "the", "current", "panel", "part", "and", "return", "necessary", "HTML", "closing", "elements", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L314-L333
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ClassTrait.php
ClassTrait.addClass
public function addClass(array $options = [], $class = null, $key = 'class') { if (!is_array($class)) { $class = explode(' ', trim($class)); } $optClass = []; if (isset($options[$key])) { $optClass = $options[$key]; if (!is_array($optClass)) { $optClass = explode(' ', trim($optClass)); } } $class = array_merge($optClass, $class); $class = array_map('trim', $class); $class = array_unique($class); $class = array_filter($class); $options[$key] = implode(' ', $class); return $options; }
php
public function addClass(array $options = [], $class = null, $key = 'class') { if (!is_array($class)) { $class = explode(' ', trim($class)); } $optClass = []; if (isset($options[$key])) { $optClass = $options[$key]; if (!is_array($optClass)) { $optClass = explode(' ', trim($optClass)); } } $class = array_merge($optClass, $class); $class = array_map('trim', $class); $class = array_unique($class); $class = array_filter($class); $options[$key] = implode(' ', $class); return $options; }
[ "public", "function", "addClass", "(", "array", "$", "options", "=", "[", "]", ",", "$", "class", "=", "null", ",", "$", "key", "=", "'class'", ")", "{", "if", "(", "!", "is_array", "(", "$", "class", ")", ")", "{", "$", "class", "=", "explode", ...
Adds the given class to the element options. @param array $options Array of options/attributes to add a class to. @param string|array $class The class names to be added. @param string $key The key to use for class (default to `'class'`). @return array Array of options with `$key` set or updated.
[ "Adds", "the", "given", "class", "to", "the", "element", "options", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ClassTrait.php#L33-L50
train
Holt59/cakephp3-bootstrap-helpers
src/Utility/StackedStates.php
StackedStates.push
public function push($type, $state = []) { if (isset($this->_defaults[$type])) { $state = array_merge($this->_defaults[$type], $state); } array_push($this->_states, [$type, $state]); }
php
public function push($type, $state = []) { if (isset($this->_defaults[$type])) { $state = array_merge($this->_defaults[$type], $state); } array_push($this->_states, [$type, $state]); }
[ "public", "function", "push", "(", "$", "type", ",", "$", "state", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_defaults", "[", "$", "type", "]", ")", ")", "{", "$", "state", "=", "array_merge", "(", "$", "this", "->",...
Push a new state, merging given values with the default ones. @param string $type Type of the new state. @param mixed $sate New state.
[ "Push", "a", "new", "state", "merging", "given", "values", "with", "the", "default", "ones", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/StackedStates.php#L73-L78
train
Holt59/cakephp3-bootstrap-helpers
src/Utility/StackedStates.php
StackedStates.setValue
public function setValue($name, $value) { $this->_states[count($this->_states) - 1][1][$name] = $value; }
php
public function setValue($name, $value) { $this->_states[count($this->_states) - 1][1][$name] = $value; }
[ "public", "function", "setValue", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "_states", "[", "count", "(", "$", "this", "->", "_states", ")", "-", "1", "]", "[", "1", "]", "[", "$", "name", "]", "=", "$", "value", ";", ...
Set a value of the current state. @param mixed $name Name of the attribute to set. @param mixed $value New value for the attribute.
[ "Set", "a", "value", "of", "the", "current", "state", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/StackedStates.php#L105-L107
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait._matchHost
protected function _matchHost($url) { $components = parse_url($url); return !(isset($components['host']) && $components['host'] != $this->_hostname()); }
php
protected function _matchHost($url) { $components = parse_url($url); return !(isset($components['host']) && $components['host'] != $this->_hostname()); }
[ "protected", "function", "_matchHost", "(", "$", "url", ")", "{", "$", "components", "=", "parse_url", "(", "$", "url", ")", ";", "return", "!", "(", "isset", "(", "$", "components", "[", "'host'", "]", ")", "&&", "$", "components", "[", "'host'", "]...
Checks if the given URL components match the current host. @param string $url URL to check. @return bool `true` if the URL matches, `false` otherwise.
[ "Checks", "if", "the", "given", "URL", "components", "match", "the", "current", "host", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L62-L65
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait._matchRelative
protected function _matchRelative($url) { $relative = $this->_relative(); if (!$relative) { return true; } $components = parse_url($url); if (!isset($components['host'])) { return true; } $path = trim($components['path'], '/'); return strpos($path, $relative) === 0; }
php
protected function _matchRelative($url) { $relative = $this->_relative(); if (!$relative) { return true; } $components = parse_url($url); if (!isset($components['host'])) { return true; } $path = trim($components['path'], '/'); return strpos($path, $relative) === 0; }
[ "protected", "function", "_matchRelative", "(", "$", "url", ")", "{", "$", "relative", "=", "$", "this", "->", "_relative", "(", ")", ";", "if", "(", "!", "$", "relative", ")", "{", "return", "true", ";", "}", "$", "components", "=", "parse_url", "("...
Checks if the given URL components match the current relative URL. This methods only works with full URL, and do not check the host. @param string $url URL to check. @return bool `true` if the URL matches, `false` otherwise.
[ "Checks", "if", "the", "given", "URL", "components", "match", "the", "current", "relative", "URL", ".", "This", "methods", "only", "works", "with", "full", "URL", "and", "do", "not", "check", "the", "host", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L75-L86
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait._normalize
protected function _normalize($url, array $parts = []) { if (!is_string($url)) { $url = Router::url($url); } if (!$this->_matchHost($url)) { return null; } if (!$this->_matchRelative($url)) { return null; } $url = Router::parseRequest(new ServerRequest($this->_removeRelative($url))); $arr = []; foreach ($this->_parts as $part) { if (!isset($url[$part]) || (isset($parts[$part]) && !$parts[$part])) { continue; } if (is_array($url[$part])) { $url[$part] = implode('/', $url[$part]); } if ($part != 'pass') { $url[$part] = strtolower($url[$part]); } $arr[] = $url[$part]; } return $this->_removeRelative(Router::normalize('/'.implode('/', $arr))); }
php
protected function _normalize($url, array $parts = []) { if (!is_string($url)) { $url = Router::url($url); } if (!$this->_matchHost($url)) { return null; } if (!$this->_matchRelative($url)) { return null; } $url = Router::parseRequest(new ServerRequest($this->_removeRelative($url))); $arr = []; foreach ($this->_parts as $part) { if (!isset($url[$part]) || (isset($parts[$part]) && !$parts[$part])) { continue; } if (is_array($url[$part])) { $url[$part] = implode('/', $url[$part]); } if ($part != 'pass') { $url[$part] = strtolower($url[$part]); } $arr[] = $url[$part]; } return $this->_removeRelative(Router::normalize('/'.implode('/', $arr))); }
[ "protected", "function", "_normalize", "(", "$", "url", ",", "array", "$", "parts", "=", "[", "]", ")", "{", "if", "(", "!", "is_string", "(", "$", "url", ")", ")", "{", "$", "url", "=", "Router", "::", "url", "(", "$", "url", ")", ";", "}", ...
Normalize an URL. @param string $url URL to normalize. @param array $pass Include pass parameters. @return string Normalized URL.
[ "Normalize", "an", "URL", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L113-L138
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait.compareUrls
public function compareUrls($lhs, $rhs = null, $parts = []) { if ($rhs == null) { $rhs = Router::url(); } $lhs = $this->_normalize($lhs, $parts); $rhs = $this->_normalize($rhs); return $lhs !== null && $rhs !== null && strpos($rhs, $lhs) === 0; }
php
public function compareUrls($lhs, $rhs = null, $parts = []) { if ($rhs == null) { $rhs = Router::url(); } $lhs = $this->_normalize($lhs, $parts); $rhs = $this->_normalize($rhs); return $lhs !== null && $rhs !== null && strpos($rhs, $lhs) === 0; }
[ "public", "function", "compareUrls", "(", "$", "lhs", ",", "$", "rhs", "=", "null", ",", "$", "parts", "=", "[", "]", ")", "{", "if", "(", "$", "rhs", "==", "null", ")", "{", "$", "rhs", "=", "Router", "::", "url", "(", ")", ";", "}", "$", ...
Check if first URL is a parent of the right URL, without regards to query parameters or hash. @param string|array $lhs First URL to compare. @param string|array $rhs Second URL to compare. Default is current URL (`Router::url()`). @return bool `true` if both URL match, `false` otherwise.
[ "Check", "if", "first", "URL", "is", "a", "parent", "of", "the", "right", "URL", "without", "regards", "to", "query", "parameters", "or", "hash", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L149-L156
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PaginatorHelper.php
PaginatorHelper.prev
public function prev($title = '<< Previous', array $options = []) { list($options, $easyIcon) = $this->_easyIconOption($options); return $this->_injectIcon(parent::prev($title, $options), $easyIcon); }
php
public function prev($title = '<< Previous', array $options = []) { list($options, $easyIcon) = $this->_easyIconOption($options); return $this->_injectIcon(parent::prev($title, $options), $easyIcon); }
[ "public", "function", "prev", "(", "$", "title", "=", "'<< Previous'", ",", "array", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "options", ",", "$", "easyIcon", ")", "=", "$", "this", "->", "_easyIconOption", "(", "$", "options", ")",...
Generates a "previous" link for a set of paged records. ### Options: - `disabledTitle` The text to used when the link is disabled. This defaults to the same text at the active link. Setting to false will cause this method to return ''. - `escape` Whether you want the contents html entity encoded, defaults to true. - `model` The model to use, defaults to `PaginatorHelper::defaultModel()`. - `url` An array of additional URL options to use for link generation. - `templates` An array of templates, or template file name containing the templates you'd like to use when generating the link for previous page. The helper's original templates will be restored once prev() is done. @param string $title Title for the link. Defaults to '<< Previous'. @param array $options Options for pagination link. See above for list of keys. @return string A "previous" link or a disabled link. @link http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-jump-links
[ "Generates", "a", "previous", "link", "for", "a", "set", "of", "paged", "records", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PaginatorHelper.php#L277-L280
train
Holt59/cakephp3-bootstrap-helpers
src/View/Widget/FancyFileWidget.php
FancyFileWidget.render
public function render(array $data, \Cake\View\Form\ContextInterface $context) { $data += [ '_input' => [], '_button' => [], 'id' => $data['name'], 'count-label' => __('files selected'), 'button-label' => (isset($data['multiple']) && $data['multiple']) ? __('Choose Files') : __('Choose File'), 'templateVars' => [] ]; $fakeInputCustomOptions = $data['_input']; $fakeButtonCustomOptions = $data['_button']; $countLabel = $data['count-label']; $buttonLabel = $data['button-label']; unset($data['_input'], $data['_button'], $data['type'], $data['count-label'], $data['button-label']); // avoid javascript errors due to invisible control unset($data['required']); $fileInput = $this->_file->render($data + [ 'style' => 'display: none;', 'onchange' => "document.getElementById('".$data['id']."-input').value = " . "(this.files.length <= 1) ? " . "(this.files.length ? this.files[0].name : '') " . ": this.files.length + ' ' + '" . $countLabel . "';", 'escape' => false ], $context); if (!empty($data['val']) && is_array($data['val'])) { if (isset($data['val']['name']) || count($data['val']) == 1) { $fakeInputCustomOptions += [ 'value' => (isset($data['val']['name'])) ? $data['val']['name'] : $data['val'][0]['name'] ]; } else { $fakeInputCustomOptions += [ 'value' => count($data['val']) . ' ' . $countLabel ]; } } $fakeInput = $this->_input->render($fakeInputCustomOptions + [ 'name' => $this->_fakeFieldName($data['name']), 'readonly' => 'readonly', 'id' => $data['id'].'-input', 'onclick' => "document.getElementById('".$data['id']."').click();", 'escape' => false ], $context); $fakeButton = $this->_button->render($fakeButtonCustomOptions + [ 'type' => 'button', 'text' => $buttonLabel, 'onclick' => "document.getElementById('".$data['id']."').click();" ], $context); return $this->_templates->format('fancyFileInput', [ 'fileInput' => $fileInput, 'button' => $fakeButton, 'input' => $fakeInput, 'attrs' => $this->_templates->formatAttributes($data), 'templateVars' => $data['templateVars'] ]); }
php
public function render(array $data, \Cake\View\Form\ContextInterface $context) { $data += [ '_input' => [], '_button' => [], 'id' => $data['name'], 'count-label' => __('files selected'), 'button-label' => (isset($data['multiple']) && $data['multiple']) ? __('Choose Files') : __('Choose File'), 'templateVars' => [] ]; $fakeInputCustomOptions = $data['_input']; $fakeButtonCustomOptions = $data['_button']; $countLabel = $data['count-label']; $buttonLabel = $data['button-label']; unset($data['_input'], $data['_button'], $data['type'], $data['count-label'], $data['button-label']); // avoid javascript errors due to invisible control unset($data['required']); $fileInput = $this->_file->render($data + [ 'style' => 'display: none;', 'onchange' => "document.getElementById('".$data['id']."-input').value = " . "(this.files.length <= 1) ? " . "(this.files.length ? this.files[0].name : '') " . ": this.files.length + ' ' + '" . $countLabel . "';", 'escape' => false ], $context); if (!empty($data['val']) && is_array($data['val'])) { if (isset($data['val']['name']) || count($data['val']) == 1) { $fakeInputCustomOptions += [ 'value' => (isset($data['val']['name'])) ? $data['val']['name'] : $data['val'][0]['name'] ]; } else { $fakeInputCustomOptions += [ 'value' => count($data['val']) . ' ' . $countLabel ]; } } $fakeInput = $this->_input->render($fakeInputCustomOptions + [ 'name' => $this->_fakeFieldName($data['name']), 'readonly' => 'readonly', 'id' => $data['id'].'-input', 'onclick' => "document.getElementById('".$data['id']."').click();", 'escape' => false ], $context); $fakeButton = $this->_button->render($fakeButtonCustomOptions + [ 'type' => 'button', 'text' => $buttonLabel, 'onclick' => "document.getElementById('".$data['id']."').click();" ], $context); return $this->_templates->format('fancyFileInput', [ 'fileInput' => $fileInput, 'button' => $fakeButton, 'input' => $fakeInput, 'attrs' => $this->_templates->formatAttributes($data), 'templateVars' => $data['templateVars'] ]); }
[ "public", "function", "render", "(", "array", "$", "data", ",", "\\", "Cake", "\\", "View", "\\", "Form", "\\", "ContextInterface", "$", "context", ")", "{", "$", "data", "+=", "[", "'_input'", "=>", "[", "]", ",", "'_button'", "=>", "[", "]", ",", ...
Render a custom file upload form widget. Data supports the following keys: - `_input` - Options for the input element. - `_button` - Options for the button element. - `name` - Set the input name. - `count-label` - Label for multiple files. Default is `__('files selected')`. - `button-label` - Button text. Default is `__('Choose File')`. - `escape` - Set to false to disable HTML escaping. All other keys will be converted into HTML attributes. Unlike other input objects the `val` property will be specifically ignored. @param array $data The data to build a file input with. @param \Cake\View\Form\ContextInterface $context The current form context. @return string HTML elements.
[ "Render", "a", "custom", "file", "upload", "form", "widget", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Widget/FancyFileWidget.php#L93-L157
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/EasyIconTrait.php
EasyIconTrait._easyIconOption
protected function _easyIconOption(array $options) { $options += [ 'easyIcon' => $this->easyIcon ]; $easyIcon = $options['easyIcon']; unset($options['easyIcon']); return [$options, $easyIcon]; }
php
protected function _easyIconOption(array $options) { $options += [ 'easyIcon' => $this->easyIcon ]; $easyIcon = $options['easyIcon']; unset($options['easyIcon']); return [$options, $easyIcon]; }
[ "protected", "function", "_easyIconOption", "(", "array", "$", "options", ")", "{", "$", "options", "+=", "[", "'easyIcon'", "=>", "$", "this", "->", "easyIcon", "]", ";", "$", "easyIcon", "=", "$", "options", "[", "'easyIcon'", "]", ";", "unset", "(", ...
Remove the `easyIcon` option from the given array and return it together with the array. @param array $options Array of options from which the easy-icon option should be extracted. @return array An array containing the options and the easy-icon option.
[ "Remove", "the", "easyIcon", "option", "from", "the", "given", "array", "and", "return", "it", "together", "with", "the", "array", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/EasyIconTrait.php#L39-L46
train
Holt59/cakephp3-bootstrap-helpers
src/View/FlexibleStringTemplate.php
FlexibleStringTemplate._getTemplateName
protected function _getTemplateName($name, array &$data = []) { if (isset($this->_callbacks[$name])) { $data = call_user_func($this->_callbacks[$name], $data); } if ($this->_callback) { $data = call_user_func($this->_callback, $name, $data); } if (isset($data['templateName'])) { $name = $data['templateName']; unset($data['templateName']); } return $name; }
php
protected function _getTemplateName($name, array &$data = []) { if (isset($this->_callbacks[$name])) { $data = call_user_func($this->_callbacks[$name], $data); } if ($this->_callback) { $data = call_user_func($this->_callback, $name, $data); } if (isset($data['templateName'])) { $name = $data['templateName']; unset($data['templateName']); } return $name; }
[ "protected", "function", "_getTemplateName", "(", "$", "name", ",", "array", "&", "$", "data", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_callbacks", "[", "$", "name", "]", ")", ")", "{", "$", "data", "=", "call_user_fun...
Retrieve a template name after checking the various callbacks. @param string $name The original name of the template. @param array $data The data to update. @return string The new name of the template.
[ "Retrieve", "a", "template", "name", "after", "checking", "the", "various", "callbacks", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/FlexibleStringTemplate.php#L70-L82
train
Holt59/cakephp3-bootstrap-helpers
src/Utility/Matching.php
Matching.matchTag
public static function matchTag($tag, $subject, &$content = null, &$attrs = null) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } // wrong tag => false if ($xml->name !== $tag) { return false; } $attrs = []; while ($xml->moveToNextAttribute()) { $attrs[$xml->name] = $xml->value; } $content = $xml->readInnerXML(); return true; }
php
public static function matchTag($tag, $subject, &$content = null, &$attrs = null) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } // wrong tag => false if ($xml->name !== $tag) { return false; } $attrs = []; while ($xml->moveToNextAttribute()) { $attrs[$xml->name] = $xml->value; } $content = $xml->readInnerXML(); return true; }
[ "public", "static", "function", "matchTag", "(", "$", "tag", ",", "$", "subject", ",", "&", "$", "content", "=", "null", ",", "&", "$", "attrs", "=", "null", ")", "{", "$", "xml", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "xml", "->", ...
Check if the given input string match the given tag, and returns an array of attributes if attrs is not null. This function does not work for "singleton" tags. @param string $tag Tag to match (e.g. 'a', 'div', 'span'). @param string $subject String within which to match the tag. @param string $content Content within the tag, if one was found. @param array $attrs Attributes of the tag, if one was found. @return bool True if the given tag was found, false otherwize.
[ "Check", "if", "the", "given", "input", "string", "match", "the", "given", "tag", "and", "returns", "an", "array", "of", "attributes", "if", "attrs", "is", "not", "null", ".", "This", "function", "does", "not", "work", "for", "singleton", "tags", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/Matching.php#L35-L57
train
Holt59/cakephp3-bootstrap-helpers
src/Utility/Matching.php
Matching.matchAttribute
public static function matchAttribute($attr, $value, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } return $xml->getAttribute($attr) === $value; }
php
public static function matchAttribute($attr, $value, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } return $xml->getAttribute($attr) === $value; }
[ "public", "static", "function", "matchAttribute", "(", "$", "attr", ",", "$", "value", ",", "$", "subject", ")", "{", "$", "xml", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "xml", "->", "xml", "(", "$", "subject", ",", "'UTF-8'", ",", "LIBX...
Check if the first tag found in the given input string contains an attribute with the given name and value. @param string $attr Name of the attribute. @param string $value Value of the attribute. @param string $subject String to search. @return bool True if an attribute with the given name/value was found, false otherwize.
[ "Check", "if", "the", "first", "tag", "found", "in", "the", "given", "input", "string", "contains", "an", "attribute", "with", "the", "given", "name", "and", "value", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/Matching.php#L70-L80
train
Holt59/cakephp3-bootstrap-helpers
src/Utility/Matching.php
Matching.findTagOrAttribute
public static function findTagOrAttribute($tag, $attrs, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } if (!is_null($attrs) && !is_array($attrs)) { $attrs = [$attrs => null]; } while ($xml->read()) { if (!is_null($tag) && $xml->name == $tag) { return true; // tag found } if (!is_null($attrs)) { foreach ($attrs as $attr => $attrValue) { $value = $xml->getAttribute($attr); if (!is_null($value) && (is_null($attrValue) || $value == $attrValue)) { return true; } } } } return false; }
php
public static function findTagOrAttribute($tag, $attrs, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } if (!is_null($attrs) && !is_array($attrs)) { $attrs = [$attrs => null]; } while ($xml->read()) { if (!is_null($tag) && $xml->name == $tag) { return true; // tag found } if (!is_null($attrs)) { foreach ($attrs as $attr => $attrValue) { $value = $xml->getAttribute($attr); if (!is_null($value) && (is_null($attrValue) || $value == $attrValue)) { return true; } } } } return false; }
[ "public", "static", "function", "findTagOrAttribute", "(", "$", "tag", ",", "$", "attrs", ",", "$", "subject", ")", "{", "$", "xml", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "xml", "->", "xml", "(", "$", "subject", ",", "'UTF-8'", ",", "L...
Check if the given input string contains an element with the given type name or attribute. @param string $tag Tag name to search for, or null if not relevant. @param string $attrs Array [name => value] for the attributes to search for, or null if not relevant. `value` can be null if only the name should be looked. @param string $subject String to search. @return bool True if the given tag or given attribute is found.
[ "Check", "if", "the", "given", "input", "string", "contains", "an", "element", "with", "the", "given", "type", "name", "or", "attribute", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/Matching.php#L93-L121
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper.create
public function create($title = null, $options = []) { if(is_array($title)) { $options = $title; } $this->_currentId = null; $this->_current = null; $options += [ 'id' => null, 'close' => true, 'body' => true, 'size' => false, 'templateVars' => [] ]; $dialogOptions = []; if($options['id']) { $this->_currentId = $options['id']; $options['aria-labelledby'] = $this->_currentId.'Label'; } switch($options['size']) { case 'lg': case 'large': case 'modal-lg': $size = ' modal-lg'; break; case 'sm': case 'small': case 'modal-sm': $size = ' modal-sm'; break; case false: $size = ''; break; default: $size = ' '.$options['size']; break; } $dialogOptions = $this->addClass($dialogOptions, $size); $dialogStart = $this->formatTemplate('modalDialogStart', [ 'attrs' => $this->templater()->formatAttributes($dialogOptions) ]); $contentStart = $this->formatTemplate('modalContentStart', []); $res = $this->formatTemplate('modalStart', [ 'dialogStart' => $dialogStart, 'contentStart' => $contentStart, 'attrs' => $this->templater()->formatAttributes($options, ['body', 'close', 'size']), 'templateVars' => $options['templateVars'] ]); if(is_string($title) && $title) { $res .= $this->_createHeader($title, ['close' => $options['close']]); if($options['body']) { $res .= $this->_createBody(); } } return $res; }
php
public function create($title = null, $options = []) { if(is_array($title)) { $options = $title; } $this->_currentId = null; $this->_current = null; $options += [ 'id' => null, 'close' => true, 'body' => true, 'size' => false, 'templateVars' => [] ]; $dialogOptions = []; if($options['id']) { $this->_currentId = $options['id']; $options['aria-labelledby'] = $this->_currentId.'Label'; } switch($options['size']) { case 'lg': case 'large': case 'modal-lg': $size = ' modal-lg'; break; case 'sm': case 'small': case 'modal-sm': $size = ' modal-sm'; break; case false: $size = ''; break; default: $size = ' '.$options['size']; break; } $dialogOptions = $this->addClass($dialogOptions, $size); $dialogStart = $this->formatTemplate('modalDialogStart', [ 'attrs' => $this->templater()->formatAttributes($dialogOptions) ]); $contentStart = $this->formatTemplate('modalContentStart', []); $res = $this->formatTemplate('modalStart', [ 'dialogStart' => $dialogStart, 'contentStart' => $contentStart, 'attrs' => $this->templater()->formatAttributes($options, ['body', 'close', 'size']), 'templateVars' => $options['templateVars'] ]); if(is_string($title) && $title) { $res .= $this->_createHeader($title, ['close' => $options['close']]); if($options['body']) { $res .= $this->_createBody(); } } return $res; }
[ "public", "function", "create", "(", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "$", "options", "=", "$", "title", ";", "}", "$", "this", "->", "_currentId", ...
Open a modal If `$title` is a string, the modal header is created using `$title` as its content and default options. ```php echo $this->Modal->create('My Modal Title'); ``` If the modal header is created, the modal body is automatically opened after it, except if the `body` options is specified(see below). If `$title` is an array, it is used as `$options`. ```php echo $this->Modal->create(['class' => 'my-modal-class']); ``` ### Options - `body` If `$title` is a string, set to `false` to not open the body after the panel header. Default is `true`. - `close` Set to `false` to not add a close button to the modal. Default is `true`. - `id` Identifier of the modal. If specified, a `aria-labelledby` HTML attribute will be added to the modal and the header will be set accordingly. - `size` Size of the modal. Either a shortcut(`'lg'`/`'large'`/`'modal-lg'` or (`'sm'`/`'small'`/`'modal-sm'`) or `false`(no size specified) or a custom class. Other options will be passed to the `Html::div` method for creating the outer modal `<div>`. @param array|string $title The modal title or an array of options. @param array $options Array of options. See above. @return string An HTML string containing opening elements for a modal.
[ "Open", "a", "modal" ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L120-L181
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper.end
public function end($buttons = NULL, $options = []) { $res = $this->_cleanCurrent(); if($buttons !== null) { $res .= $this->footer($buttons, $options); } $res .= $this->formatTemplate('modalEnd', [ 'contentEnd' => $this->formatTemplate('modalContentEnd', []), 'dialogEnd' => $this->formatTemplate('modalDialogEnd', []) ]); return $res; }
php
public function end($buttons = NULL, $options = []) { $res = $this->_cleanCurrent(); if($buttons !== null) { $res .= $this->footer($buttons, $options); } $res .= $this->formatTemplate('modalEnd', [ 'contentEnd' => $this->formatTemplate('modalContentEnd', []), 'dialogEnd' => $this->formatTemplate('modalDialogEnd', []) ]); return $res; }
[ "public", "function", "end", "(", "$", "buttons", "=", "NULL", ",", "$", "options", "=", "[", "]", ")", "{", "$", "res", "=", "$", "this", "->", "_cleanCurrent", "(", ")", ";", "if", "(", "$", "buttons", "!==", "null", ")", "{", "$", "res", ".=...
Closes a modal, cleans part that have not been closed correctly and optionaly adds a footer with buttons to the modal. If `$buttons` is not null, the `footer()` method will be used to create the modal footer using `$buttons` and `$options`: ```php echo $this->Modal->end([$this->Form->button('Save'), $this->Form->button('Close')]); ``` @param array $buttons Array of buttons for the `footer()` method or `null`. @param array $options Array of options for the `footer()` method. @return string An HTML string containing closing tags for the modal.
[ "Closes", "a", "modal", "cleans", "part", "that", "have", "not", "been", "closed", "correctly", "and", "optionaly", "adds", "a", "footer", "with", "buttons", "to", "the", "modal", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L199-L209
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper._cleanCurrent
protected function _cleanCurrent() { if($this->_current) { $current = $this->_current; $this->_current = null; return $this->formatTemplate($current.'End', []); } return ''; }
php
protected function _cleanCurrent() { if($this->_current) { $current = $this->_current; $this->_current = null; return $this->formatTemplate($current.'End', []); } return ''; }
[ "protected", "function", "_cleanCurrent", "(", ")", "{", "if", "(", "$", "this", "->", "_current", ")", "{", "$", "current", "=", "$", "this", "->", "_current", ";", "$", "this", "->", "_current", "=", "null", ";", "return", "$", "this", "->", "forma...
Cleans the current modal part and return necessary HTML closing elements. @return string An HTML string containing closing elements.
[ "Cleans", "the", "current", "modal", "part", "and", "return", "necessary", "HTML", "closing", "elements", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L216-L223
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper._part
protected function _part($part, $content = null, $options = []) { $options += [ 'templateVars' => [] ]; $out = $this->_cleanCurrent(); $out .= $this->formatTemplate($part.'Start', [ 'attrs' => $this->templater()->formatAttributes($options, ['close']), 'templateVars' => $options ]); $this->_current = $part; if ($content) { $out .= $content; $out .= $this->_cleanCurrent(); } return $out; }
php
protected function _part($part, $content = null, $options = []) { $options += [ 'templateVars' => [] ]; $out = $this->_cleanCurrent(); $out .= $this->formatTemplate($part.'Start', [ 'attrs' => $this->templater()->formatAttributes($options, ['close']), 'templateVars' => $options ]); $this->_current = $part; if ($content) { $out .= $content; $out .= $this->_cleanCurrent(); } return $out; }
[ "protected", "function", "_part", "(", "$", "part", ",", "$", "content", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "$", "out", "=", "$", "this", "->", "_clean...
Cleans the current modal part, create a new ones with the given content, and update the internal `_current` variable if necessary. @param string $part The name of the part(`'header'`, `'body'`, `'footer'`). @param string $content The content of the part or `null`. @param array $options Array of options for the `Html::tag` method. @return string
[ "Cleans", "the", "current", "modal", "part", "create", "a", "new", "ones", "with", "the", "given", "content", "and", "update", "the", "internal", "_current", "variable", "if", "necessary", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L235-L250
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper._createHeader
protected function _createHeader($title = null, $options = []) { $options += [ 'close' => true ]; $out = null; if($title) { $out = ''; if($options['close']) { $out .= $this->formatTemplate('modalHeaderCloseButton', [ 'content' => $this->formatTemplate('modalHeaderCloseContent', []), 'label' => __('Close') ]); } $out .= $this->formatTemplate('modalTitle', [ 'content' => $title, 'attrs' => $this->templater()->formatAttributes([ 'id' => $this->_currentId ? $this->_currentId.'Label' : false ]) ]); } return $this->_part('header', $out, $options); }
php
protected function _createHeader($title = null, $options = []) { $options += [ 'close' => true ]; $out = null; if($title) { $out = ''; if($options['close']) { $out .= $this->formatTemplate('modalHeaderCloseButton', [ 'content' => $this->formatTemplate('modalHeaderCloseContent', []), 'label' => __('Close') ]); } $out .= $this->formatTemplate('modalTitle', [ 'content' => $title, 'attrs' => $this->templater()->formatAttributes([ 'id' => $this->_currentId ? $this->_currentId.'Label' : false ]) ]); } return $this->_part('header', $out, $options); }
[ "protected", "function", "_createHeader", "(", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'close'", "=>", "true", "]", ";", "$", "out", "=", "null", ";", "if", "(", "$", "title", ")", "{",...
Create or open a modal header. ### Options - `close` Set to `false` to not add a close button to the modal. Default is `true`. - `templateVars` Provide template variables for the `headerStart` template. - Other attributes will be assigned to the modal header element. @param string $text The modal header content, or null to only open the header. @param array $options Array of options. See above. @return string A formated opening tag for the modal header or the complete modal header. @see `BootstrapModalHelper::header`
[ "Create", "or", "open", "a", "modal", "header", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L269-L290
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper.body
public function body($info = null, $options = []) { if(is_array($info)) { $options = $info; $info = null; } return $this->_createBody($info, $options); }
php
public function body($info = null, $options = []) { if(is_array($info)) { $options = $info; $info = null; } return $this->_createBody($info, $options); }
[ "public", "function", "body", "(", "$", "info", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "info", ")", ")", "{", "$", "options", "=", "$", "info", ";", "$", "info", "=", "null", ";", "}", "ret...
Create or open a modal body. If `$content` is a string, create a modal body using the specified content and `$options`. ```php echo $this->Modal->body('Modal Content', ['class' => 'my-class']); ``` If `$content` is `null`, create a formated opening tag for a modal body using the specified `$options`. ```php echo $this->Modal->body(null, ['class' => 'my-class']); ``` If `$content` is an array, used it as `$options` and create a formated opening tag for a modal body. ```php echo $this->Modal->body(['class' => 'my-class']); ``` ### Options - `templateVars` Provide template variables for the `bodyStart` template. - Other attributes will be assigned to the modal body element. @param array|string $info The body content, or `null`, or an array of options. `$options`. @param array $options Array of options. See above. @return string A formated opening tag for the modal body or the complete modal body.
[ "Create", "or", "open", "a", "modal", "body", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L421-L427
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.link
public function link($name, $url = '', array $options = [], array $linkOptions = []) { $url = $this->Url->build($url); $options += [ 'active' => [], 'templateVars' => [] ]; $linkOptions += [ 'templateVars' => [] ]; if (is_string($options['active'])) { $options['active'] = []; } if ($this->getConfig('autoActiveLink') && is_array($options['active'])) { $options['active'] = $this->compareUrls($url, null, $options['active']); } $active = $options['active'] ? 'Active' : ''; $level = $this->_level > 1 ? 'inner' : 'outer'; $template = $level.'MenuItem'.$active; $linkTemplate = $level.'MenuItemLink'.$active; $link = $this->formatTemplate($linkTemplate, [ 'content' => $name, 'url' => $url, 'attrs' => $this->templater()->formatAttributes($linkOptions), 'templateVars' => $linkOptions['templateVars'] ]); return $this->formatTemplate($template, [ 'link' => $link, 'attrs' => $this->templater()->formatAttributes($options, ['active']), 'templateVars' => $options['templateVars'] ]); }
php
public function link($name, $url = '', array $options = [], array $linkOptions = []) { $url = $this->Url->build($url); $options += [ 'active' => [], 'templateVars' => [] ]; $linkOptions += [ 'templateVars' => [] ]; if (is_string($options['active'])) { $options['active'] = []; } if ($this->getConfig('autoActiveLink') && is_array($options['active'])) { $options['active'] = $this->compareUrls($url, null, $options['active']); } $active = $options['active'] ? 'Active' : ''; $level = $this->_level > 1 ? 'inner' : 'outer'; $template = $level.'MenuItem'.$active; $linkTemplate = $level.'MenuItemLink'.$active; $link = $this->formatTemplate($linkTemplate, [ 'content' => $name, 'url' => $url, 'attrs' => $this->templater()->formatAttributes($linkOptions), 'templateVars' => $linkOptions['templateVars'] ]); return $this->formatTemplate($template, [ 'link' => $link, 'attrs' => $this->templater()->formatAttributes($options, ['active']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "link", "(", "$", "name", ",", "$", "url", "=", "''", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "linkOptions", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "Url", "->", "build", "(", ...
Add a link to the navbar or to a menu. Encapsulate links with `beginMenu()`, `endMenu()` to create a horizontal hover menu in the navbar or a dropdown menu. ### Options - `active` Indicates if the link is the current one. Default is automatically deduced if `autoActiveLink` is on, otherwize default is `false`. - `templateVars` Provide template variables for the templates. - Other attributes will be assigned to the navbar link element. @param string $name The link text. @param string|array $url The link URL (CakePHP way). @param array $options Array of attributes for the wrapper tag. @param array $linkOptions Array of attributes for the link. @return string A HTML tag wrapping the link.
[ "Add", "a", "link", "to", "the", "navbar", "or", "to", "a", "menu", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L233-L263
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.divider
public function divider(array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemDivider', [ 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function divider(array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemDivider', [ 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "divider", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate", "(", "'innerMenuItemDivider'", ",", "[", "'attrs...
Add a divider to an inner menu of the navbar. ### Options - `templateVars` Provide template variables for the divider template. - Other attributes will be assigned to the divider element. @param array $options Array of options. See above. @return A HTML dropdown divider tag.
[ "Add", "a", "divider", "to", "an", "inner", "menu", "of", "the", "navbar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L293-L299
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.header
public function header($name, array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemHeader', [ 'content' => $name, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function header($name, array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemHeader', [ 'content' => $name, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "header", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate", "(", "'innerMenuItemHeader'", ...
Add a header to an inner menu of the navbar. ### Options - `templateVars` Provide template variables for the header template. - Other attributes will be assigned to the header element. * @param string $name Title of the header. @param array $options Array of options for the wrapper tag. @return A HTML header tag.
[ "Add", "a", "header", "to", "an", "inner", "menu", "of", "the", "navbar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L314-L321
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.text
public function text($text, $options = []) { $options += [ 'templateVars' => [] ]; $text = preg_replace_callback('/<a([^>]*)?>([^<]*)?<\/a>/i', function($matches) { $attrs = preg_replace_callback ('/class="(.*)?"/', function ($m) { $cl = $this->addClass (['class' => $m[1]], 'navbar-link'); return 'class="'.$cl['class'].'"'; }, $matches[1], -1, $count); if ($count == 0) { $attrs .= ' class="navbar-link"'; } return '<a'.$attrs.'>'.$matches[2].'</a>'; }, $text); return $this->formatTemplate('navbarText', [ 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function text($text, $options = []) { $options += [ 'templateVars' => [] ]; $text = preg_replace_callback('/<a([^>]*)?>([^<]*)?<\/a>/i', function($matches) { $attrs = preg_replace_callback ('/class="(.*)?"/', function ($m) { $cl = $this->addClass (['class' => $m[1]], 'navbar-link'); return 'class="'.$cl['class'].'"'; }, $matches[1], -1, $count); if ($count == 0) { $attrs .= ' class="navbar-link"'; } return '<a'.$attrs.'>'.$matches[2].'</a>'; }, $text); return $this->formatTemplate('navbarText', [ 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "text", "(", "$", "text", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "$", "text", "=", "preg_replace_callback", "(", "'/<a([^>]*)?>([^<]*)?<\\/a>/i'", ",", "f...
Add a text to the navbar. ### Options - `templateVars` Provide template variables for the text template. - Other attributes will be assigned to the text element. @param string $text The text message. @param array $options Array attributes for the wrapper element. @return string A HTML element wrapping the text for the navbar.
[ "Add", "a", "text", "to", "the", "navbar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L336-L355
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.beginMenu
public function beginMenu($name = null, $url = null, $options = [], $linkOptions = [], $listOptions = []) { $template = 'outerMenuStart'; $templateOptions = []; if (is_array($name)) { $options = $name; } $options += [ 'templateVars' => [] ]; if ($this->_level == 1) { $linkOptions += [ 'caret' => '<span class="caret"></span>' ]; $template = 'innerMenuStart'; $templateOptions['dropdownLink'] = $this->formatTemplate('dropdownLink', [ 'content' => $name, 'caret' => $linkOptions['caret'], 'url' => $url ? $this->Url->build($url) : '#', 'attrs' => $this->templater()->formatAttributes($linkOptions, ['caret']) ]); $templateOptions['dropdownMenuStart'] = $this->formatTemplate('dropdownMenuStart', [ 'attrs' => $this->templater()->formatAttributes($listOptions) ]); } $this->_level += 1; return $this->formatTemplate($template, $templateOptions + [ 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function beginMenu($name = null, $url = null, $options = [], $linkOptions = [], $listOptions = []) { $template = 'outerMenuStart'; $templateOptions = []; if (is_array($name)) { $options = $name; } $options += [ 'templateVars' => [] ]; if ($this->_level == 1) { $linkOptions += [ 'caret' => '<span class="caret"></span>' ]; $template = 'innerMenuStart'; $templateOptions['dropdownLink'] = $this->formatTemplate('dropdownLink', [ 'content' => $name, 'caret' => $linkOptions['caret'], 'url' => $url ? $this->Url->build($url) : '#', 'attrs' => $this->templater()->formatAttributes($linkOptions, ['caret']) ]); $templateOptions['dropdownMenuStart'] = $this->formatTemplate('dropdownMenuStart', [ 'attrs' => $this->templater()->formatAttributes($listOptions) ]); } $this->_level += 1; return $this->formatTemplate($template, $templateOptions + [ 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "beginMenu", "(", "$", "name", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ",", "$", "linkOptions", "=", "[", "]", ",", "$", "listOptions", "=", "[", "]", ")", "{", "$", "template", "=", ...
Start a new menu. Two types of menus exist: - Horizontal hover menu in the navbar (level 0). - Vertical dropdown menu (level 1). The menu level is determined automatically: A dropdown menu needs to be part of a hover menu. In the hover menu case, pass the options array as the first argument. You can populate the menu with `link()`, `divider()`, and sub menus. Use `'class' => 'navbar-right'` option for flush right. **Note:** The `$linkOptions` and `$listOptions` parameters are not used for menu at level 0 (horizontal menu). ### Options - `templateVars` Provide template variables for the menu template. - Other attributes will be assigned to the menu element. ### Link Options - `caret` HTML caret element. Default is `'<span class="caret"></span>'`. - Other attributes will be assigned to the link element. ### List Options - Other attributes will be assigned to the list element. @param string $name Name of the menu. @param string|array $url URL for the menu. @param array $options Array of options for the wrapping element. @param array $linkOptions Array of options for the link. See above. @param array $listOptions Array of options for the openning `ul` elements. @return string HTML elements to start a menu.
[ "Start", "a", "new", "menu", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L394-L424
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.endMenu
public function endMenu() { $template = 'outerMenuEnd'; $options = []; if ($this->_level == 2) { $template = 'innerMenuEnd'; $options['dropdownMenuEnd'] = $this->formatTemplate('dropdownMenuEnd', []); } $this->_level -= 1; return $this->formatTemplate($template, $options); }
php
public function endMenu() { $template = 'outerMenuEnd'; $options = []; if ($this->_level == 2) { $template = 'innerMenuEnd'; $options['dropdownMenuEnd'] = $this->formatTemplate('dropdownMenuEnd', []); } $this->_level -= 1; return $this->formatTemplate($template, $options); }
[ "public", "function", "endMenu", "(", ")", "{", "$", "template", "=", "'outerMenuEnd'", ";", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", "_level", "==", "2", ")", "{", "$", "template", "=", "'innerMenuEnd'", ";", "$", "options",...
End a menu. @return string HTML elements to close a menu.
[ "End", "a", "menu", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L431-L440
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.end
public function end() { $containerEnd = $this->formatTemplate('containerEnd', []); $responsiveEnd = ''; if ($this->_responsive) { $responsiveEnd = $this->formatTemplate('responsiveEnd', []); } return $this->formatTemplate('navbarEnd', [ 'containerEnd' => $containerEnd, 'responsiveEnd' => $responsiveEnd ]); }
php
public function end() { $containerEnd = $this->formatTemplate('containerEnd', []); $responsiveEnd = ''; if ($this->_responsive) { $responsiveEnd = $this->formatTemplate('responsiveEnd', []); } return $this->formatTemplate('navbarEnd', [ 'containerEnd' => $containerEnd, 'responsiveEnd' => $responsiveEnd ]); }
[ "public", "function", "end", "(", ")", "{", "$", "containerEnd", "=", "$", "this", "->", "formatTemplate", "(", "'containerEnd'", ",", "[", "]", ")", ";", "$", "responsiveEnd", "=", "''", ";", "if", "(", "$", "this", "->", "_responsive", ")", "{", "$...
Close a navbar. @return string HTML elements to close the navbar.
[ "Close", "a", "navbar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L447-L457
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.icon
public function icon($icon, array $options = []) { $options += [ 'templateVars' => [] ]; return $this->formatTemplate('icon', [ 'type' => $icon, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function icon($icon, array $options = []) { $options += [ 'templateVars' => [] ]; return $this->formatTemplate('icon', [ 'type' => $icon, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "icon", "(", "$", "icon", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate", "(", "'icon'", ",", "[", "'...
Create an icon using the template `icon`. ### Options - `templateVars` Provide template variables for the `icon` template. - Other attributes will be assigned to the wrapper element. @param string $icon Name of the icon. @param array $options Array of options. See above. @return string The HTML icon.
[ "Create", "an", "icon", "using", "the", "template", "icon", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L127-L136
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.label
public function label($text, $type = null, $options = []) { if (is_string($type)) { $options['type'] = $type; } else if (is_array($type)) { $options = $type; } $options += $this->getConfig('label') + [ 'templateVars' => [] ]; $type = $options['type']; return $this->formatTemplate('label', [ 'type' => $options['type'], 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options, ['type']), 'templateVars' => $options['templateVars'] ]); }
php
public function label($text, $type = null, $options = []) { if (is_string($type)) { $options['type'] = $type; } else if (is_array($type)) { $options = $type; } $options += $this->getConfig('label') + [ 'templateVars' => [] ]; $type = $options['type']; return $this->formatTemplate('label', [ 'type' => $options['type'], 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options, ['type']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "label", "(", "$", "text", ",", "$", "type", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "type", ")", ")", "{", "$", "options", "[", "'type'", "]", "=", "$", "type", ";", ...
Create a Twitter Bootstrap span label. The second parameter may either be `$type` or `$options` (in which case the third parameter is not used, and the label type can be specified in the `$options` array). ### Options - `tag` The HTML tag to use. - `type` The type of the label. - `templateVars` Provide template variables for the `label` template. - Other attributes will be assigned to the wrapper element. @param string $text The label text @param string|array $type The label type (default, primary, success, warning, info, danger) or the array of options (see `$options`). @param array $options Array of options. See above. Default values are retrieved from the configuration. @return string The HTML label element.
[ "Create", "a", "Twitter", "Bootstrap", "span", "label", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L168-L185
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.badge
public function badge($text, $options = []) { $options += [ 'templateVars' => [] ]; return $this->formatTemplate('badge', [ 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function badge($text, $options = []) { $options += [ 'templateVars' => [] ]; return $this->formatTemplate('badge', [ 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "badge", "(", "$", "text", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate", "(", "'badge'", ",", "[", "'content'"...
Create a Twitter Bootstrap badge. ### Options - `templateVars` Provide template variables for the `badge` template. - Other attributes will be assigned to the wrapper element. @param string $text The badge text. @param array $options Array of attributes for the span element.
[ "Create", "a", "Twitter", "Bootstrap", "badge", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L199-L208
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.alert
public function alert($text, $type = null, $options = []) { if (is_string($type)) { $options['type'] = $type; } else if (is_array($type)) { $options = $type; } $options += $this->getConfig('alert') + [ 'templateVars' => [] ]; $close = null; if ($options['close']) { $closeContent = $this->formatTemplate('alertCloseContent', [ 'templateVars' => $options['templateVars'] ]); $close = $this->formatTemplate('alertCloseButton', [ 'label' => __('Close'), 'content' => $closeContent, 'attrs' => $this->templater()->formatAttributes([]), 'templateVars' => $options['templateVars'] ]); $options = $this->addClass($options, 'alert-dismissible'); } return $this->formatTemplate('alert', [ 'type' => $options['type'], 'close' => $close, 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options, ['close', 'type']), 'templateVars' => $options['templateVars'] ]); }
php
public function alert($text, $type = null, $options = []) { if (is_string($type)) { $options['type'] = $type; } else if (is_array($type)) { $options = $type; } $options += $this->getConfig('alert') + [ 'templateVars' => [] ]; $close = null; if ($options['close']) { $closeContent = $this->formatTemplate('alertCloseContent', [ 'templateVars' => $options['templateVars'] ]); $close = $this->formatTemplate('alertCloseButton', [ 'label' => __('Close'), 'content' => $closeContent, 'attrs' => $this->templater()->formatAttributes([]), 'templateVars' => $options['templateVars'] ]); $options = $this->addClass($options, 'alert-dismissible'); } return $this->formatTemplate('alert', [ 'type' => $options['type'], 'close' => $close, 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options, ['close', 'type']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "alert", "(", "$", "text", ",", "$", "type", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "type", ")", ")", "{", "$", "options", "[", "'type'", "]", "=", "$", "type", ";", ...
Create a Twitter Bootstrap style alert block, containing text. The second parameter may either be `$type` or `$options` (in this case, the third parameter is not used, and the alert type can be specified in the `$options` array). ### Options - `close` Dismissible alert. See configuration for default. - `type` The type of the alert. See configuration for default. - `templateVars` Provide template variables for the `alert` template. - Other attributes will be assigned to the wrapper element. @param string $text The alert text. @param string|array $type The type of the alert. @param array $options Array of options. See above. @return string A HTML bootstrap alert element.
[ "Create", "a", "Twitter", "Bootstrap", "style", "alert", "block", "containing", "text", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L240-L270
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.tooltip
public function tooltip($text, $tooltip, $options = []) { $options += $this->getConfig('tooltip') + [ 'tooltip' => $tooltip, 'templateVars' => [] ]; return $this->formatTemplate('tooltip', [ 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options, ['tag', 'toggle', 'placement', 'tooltip']), 'templateVars' => array_merge($options, $options['templateVars']) ]); }
php
public function tooltip($text, $tooltip, $options = []) { $options += $this->getConfig('tooltip') + [ 'tooltip' => $tooltip, 'templateVars' => [] ]; return $this->formatTemplate('tooltip', [ 'content' => $text, 'attrs' => $this->templater()->formatAttributes($options, ['tag', 'toggle', 'placement', 'tooltip']), 'templateVars' => array_merge($options, $options['templateVars']) ]); }
[ "public", "function", "tooltip", "(", "$", "text", ",", "$", "tooltip", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "$", "this", "->", "getConfig", "(", "'tooltip'", ")", "+", "[", "'tooltip'", "=>", "$", "tooltip", ",", "'t...
Create a Twitter Bootstrap style tooltip. ### Options - `toggle` The 'data-toggle' HTML attribute. - `placement` The `data-placement` HTML attribute. - `tag` The tag to use. - `templateVars` Provide template variables for the `tooltip` template. - Other attributes will be assigned to the wrapper element. @param string $text The HTML tag inner text. @param string $tooltip The tooltip text. @param array $options An array of options. See above. Default values are retrieved from the configuration. @return string The text wrapped in the specified HTML tag with a tooltip.
[ "Create", "a", "Twitter", "Bootstrap", "style", "tooltip", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L290-L300
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.progress
public function progress($widths, array $options = []) { $options += $this->getConfig('progress') + [ 'striped' => false, 'active' => false, 'min' => 0, 'max' => 100, 'templateVars' => [] ]; if (!is_array($widths)) { $widths = [ ['width' => $widths] ]; } $bars = ''; foreach ($widths as $width) { $width += $options; if ($width['striped']) { $width = $this->addClass($width, 'progress-bar-striped'); } if ($width['active']) { $width = $this->addClass($width, 'active'); } $inner = $this->formatTemplate('progressBarInner', [ 'width' => $width['width'] ]); $bars .= $this->formatTemplate('progressBar', [ 'inner' => $inner, 'type' => $width['type'], 'min' => $width['min'], 'max' => $width['max'], 'width' => $width['width'], 'attrs' => $this->templater()->formatAttributes($width, ['striped', 'active', 'min', 'max', 'type', 'width']), 'templateVars' => $width['templateVars'] ]); } return $this->formatTemplate('progressBarContainer', [ 'content' => $bars, 'attrs' => $this->templater()->formatAttributes([]), 'templateVars' => $options['templateVars'] ]); }
php
public function progress($widths, array $options = []) { $options += $this->getConfig('progress') + [ 'striped' => false, 'active' => false, 'min' => 0, 'max' => 100, 'templateVars' => [] ]; if (!is_array($widths)) { $widths = [ ['width' => $widths] ]; } $bars = ''; foreach ($widths as $width) { $width += $options; if ($width['striped']) { $width = $this->addClass($width, 'progress-bar-striped'); } if ($width['active']) { $width = $this->addClass($width, 'active'); } $inner = $this->formatTemplate('progressBarInner', [ 'width' => $width['width'] ]); $bars .= $this->formatTemplate('progressBar', [ 'inner' => $inner, 'type' => $width['type'], 'min' => $width['min'], 'max' => $width['max'], 'width' => $width['width'], 'attrs' => $this->templater()->formatAttributes($width, ['striped', 'active', 'min', 'max', 'type', 'width']), 'templateVars' => $width['templateVars'] ]); } return $this->formatTemplate('progressBarContainer', [ 'content' => $bars, 'attrs' => $this->templater()->formatAttributes([]), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "progress", "(", "$", "widths", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "$", "this", "->", "getConfig", "(", "'progress'", ")", "+", "[", "'striped'", "=>", "false", ",", "'active'", "=>", "f...
Create a Twitter Bootstrap style progress bar. ### Bar options: - `active` If `true` the progress bar will be active. Default is `false`. - `max` Maximum value for the progress bar. Default is `100`. - `min` Minimum value for the progress bar. Default is `0`. - `striped` If `true` the progress bar will be striped. Default is `false`. - `type` A string containing the `type` of the progress bar (primary, info, danger, success, warning). Default to `'primary'`. - `templateVars` Provide template variables for the `progressBar` template. - Other attributes will be assigned to the progress bar element. @param int|array $widths - `int` The width (in %) of the bar. - `array` An array of bars, with, for each bar, the following fields: - `width` **required** The width of the bar. - Other options possible (see above). @param array $options Array of options. See above. @return string The HTML bootstrap progress bar.
[ "Create", "a", "Twitter", "Bootstrap", "style", "progress", "bar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L325-L366
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/HtmlHelper.php
HtmlHelper.splicedRows
public function splicedRows($breakIndex, array $data, callable $determineContent) { $rowsHtml = '<div class="row">'; $count = 1; foreach ($data as $index => $colData) { $rowsHtml .= $determineContent($colData); if ($count % $breakIndex === 0) { $rowsHtml .= '<div class="clearfix hidden-xs hidden-sm"></div>'; } $count++; } $rowsHtml .= '</div>'; return $rowsHtml; }
php
public function splicedRows($breakIndex, array $data, callable $determineContent) { $rowsHtml = '<div class="row">'; $count = 1; foreach ($data as $index => $colData) { $rowsHtml .= $determineContent($colData); if ($count % $breakIndex === 0) { $rowsHtml .= '<div class="clearfix hidden-xs hidden-sm"></div>'; } $count++; } $rowsHtml .= '</div>'; return $rowsHtml; }
[ "public", "function", "splicedRows", "(", "$", "breakIndex", ",", "array", "$", "data", ",", "callable", "$", "determineContent", ")", "{", "$", "rowsHtml", "=", "'<div class=\"row\">'", ";", "$", "count", "=", "1", ";", "foreach", "(", "$", "data", "as", ...
Create a formatted collection of elements while maintaining proper bootstrappy markup. Useful when displaying, for example, a list of products that would require more than the maximum number of columns per row. @deprecated 3.1.0 @param int|string $breakIndex Divisible index that will trigger a new row @param array $data Collection of data used to render each column @param callable $determineContent A callback that will be called with the data required to render an individual column @return string
[ "Create", "a", "formatted", "collection", "of", "elements", "while", "maintaining", "proper", "bootstrappy", "markup", ".", "Useful", "when", "displaying", "for", "example", "a", "list", "of", "products", "that", "would", "require", "more", "than", "the", "maxim...
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/HtmlHelper.php#L496-L513
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/FormHelper.php
FormHelper._wrapInputGroup
protected function _wrapInputGroup($addonOrButtons) { if ($addonOrButtons) { $template = 'inputGroupButtons'; if (is_string($addonOrButtons)) { $addonOrButtons = $this->_makeIcon($addonOrButtons); if (!Matching::findTagOrAttribute( 'button', ['type' => 'submit'], $addonOrButtons)) { $template = 'inputGroupAddons'; } } else { $addonOrButtons = implode('', $addonOrButtons); } $addonOrButtons = $this->formatTemplate($template, [ 'content' => $addonOrButtons ]); } return $addonOrButtons; }
php
protected function _wrapInputGroup($addonOrButtons) { if ($addonOrButtons) { $template = 'inputGroupButtons'; if (is_string($addonOrButtons)) { $addonOrButtons = $this->_makeIcon($addonOrButtons); if (!Matching::findTagOrAttribute( 'button', ['type' => 'submit'], $addonOrButtons)) { $template = 'inputGroupAddons'; } } else { $addonOrButtons = implode('', $addonOrButtons); } $addonOrButtons = $this->formatTemplate($template, [ 'content' => $addonOrButtons ]); } return $addonOrButtons; }
[ "protected", "function", "_wrapInputGroup", "(", "$", "addonOrButtons", ")", "{", "if", "(", "$", "addonOrButtons", ")", "{", "$", "template", "=", "'inputGroupButtons'", ";", "if", "(", "is_string", "(", "$", "addonOrButtons", ")", ")", "{", "$", "addonOrBu...
Wraps the given string corresponding to add-ons or buttons inside a HTML wrapper element. If `$addonOrButtons` is an array, it should contains buttons and will be wrapped accordingly. If `$addonOrButtons` is a string, the wrapper will be chosen depending on the content (see `_matchButton()`). @param string|array $addonOrButtons Content to be wrapped or array of buttons to be wrapped. @return string The elements wrapped in a suitable HTML element.
[ "Wraps", "the", "given", "string", "corresponding", "to", "add", "-", "ons", "or", "buttons", "inside", "a", "HTML", "wrapper", "element", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L317-L335
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/FormHelper.php
FormHelper.prepend
public function prepend($input, $prepend) { $prepend = $this->_wrapInputGroup($prepend); if ($input === null) { return $this->formatTemplate('inputGroupStart', ['prepend' => $prepend]); } return $this->_wrap($input, $prepend, null); }
php
public function prepend($input, $prepend) { $prepend = $this->_wrapInputGroup($prepend); if ($input === null) { return $this->formatTemplate('inputGroupStart', ['prepend' => $prepend]); } return $this->_wrap($input, $prepend, null); }
[ "public", "function", "prepend", "(", "$", "input", ",", "$", "prepend", ")", "{", "$", "prepend", "=", "$", "this", "->", "_wrapInputGroup", "(", "$", "prepend", ")", ";", "if", "(", "$", "input", "===", "null", ")", "{", "return", "$", "this", "-...
Prepend the given content to the given input or create an opening input group. @param string|null $input Input to which `$prepend` will be prepend, or null to create an opening input group. @param string|array $prepend The content to prepend., @return string The input with the content of `$prepend` prepended or an opening `<div>` for an input group.
[ "Prepend", "the", "given", "content", "to", "the", "given", "input", "or", "create", "an", "opening", "input", "group", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L369-L375
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/FormHelper.php
FormHelper.append
public function append($input, $append) { $append = $this->_wrapInputGroup($append); if ($input === null) { return $this->formatTemplate('inputGroupEnd', ['append' => $append]); } return $this->_wrap($input, null, $append); }
php
public function append($input, $append) { $append = $this->_wrapInputGroup($append); if ($input === null) { return $this->formatTemplate('inputGroupEnd', ['append' => $append]); } return $this->_wrap($input, null, $append); }
[ "public", "function", "append", "(", "$", "input", ",", "$", "append", ")", "{", "$", "append", "=", "$", "this", "->", "_wrapInputGroup", "(", "$", "append", ")", ";", "if", "(", "$", "input", "===", "null", ")", "{", "return", "$", "this", "->", ...
Append the given content to the given input or close an input group. @param string|null $input Input to which `$append` will be append, or null to create a closing element for an input group. @param string|array $append The content to append., @return string The input with the content of `$append` appended or a closing `</div>` for an input group.
[ "Append", "the", "given", "content", "to", "the", "given", "input", "or", "close", "an", "input", "group", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L387-L393
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/FormHelper.php
FormHelper.buttonGroup
public function buttonGroup($buttons, array $options = []) { $options += [ 'vertical' => false, 'templateVars' => [] ]; if ($options['vertical']) { $options = $this->addClass($options, 'btn-group-vertical'); } return $this->formatTemplate('buttonGroup', [ 'content' => implode('', $buttons), 'attrs' => $this->templater()->formatAttributes($options, ['vertical']), 'templateVars' => $options['templateVars'] ]); }
php
public function buttonGroup($buttons, array $options = []) { $options += [ 'vertical' => false, 'templateVars' => [] ]; if ($options['vertical']) { $options = $this->addClass($options, 'btn-group-vertical'); } return $this->formatTemplate('buttonGroup', [ 'content' => implode('', $buttons), 'attrs' => $this->templater()->formatAttributes($options, ['vertical']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "buttonGroup", "(", "$", "buttons", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'vertical'", "=>", "false", ",", "'templateVars'", "=>", "[", "]", "]", ";", "if", "(", "$", "options", "[", ...
Creates a button group using the given buttons. ### Options - `vertical` Specifies if the group should be vertical. Default to `false`. Other options are passed to the `Html::tag` method. @param array $buttons Array of buttons for the group. @param array $options Array of options. See above. @return string A HTML string containing the button group.
[ "Creates", "a", "button", "group", "using", "the", "given", "buttons", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L605-L618
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/FormHelper.php
FormHelper.buttonToolbar
public function buttonToolbar(array $buttonGroups, array $options = array()) { $options += [ 'templateVars' => [] ]; return $this->formatTemplate('buttonToolbar', [ 'content' => implode('', $buttonGroups), 'attrs' => $this->templater()->formatAttributes($options, ['vertical']), 'templateVars' => $options['templateVars'] ]); }
php
public function buttonToolbar(array $buttonGroups, array $options = array()) { $options += [ 'templateVars' => [] ]; return $this->formatTemplate('buttonToolbar', [ 'content' => implode('', $buttonGroups), 'attrs' => $this->templater()->formatAttributes($options, ['vertical']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "buttonToolbar", "(", "array", "$", "buttonGroups", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate"...
Creates a button toolbar using the given button groups. @param array $buttonGroups Array of groups for the toolbar @param array $options Array of options for the `Html::div` method. @return string A HTML string containing the button toolbar.
[ "Creates", "a", "button", "toolbar", "using", "the", "given", "button", "groups", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L628-L637
train
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/FormHelper.php
FormHelper.dropdownButton
public function dropdownButton($title, array $menu = [], array $options = []) { // List of options to send to the dropdown() method $optsForHtml = ['align']; $ulOptions = []; foreach ($optsForHtml as $opt) { if (isset($options[$opt])) { $ulOptions[$opt] = $options[$opt]; unset($options[$opt]); } } $options += [ 'type' => false, 'dropup' => false, 'data-toggle' => 'dropdown' ]; $dropup = $options['dropup']; unset($options['dropup']); $bGroupOptions = []; if ($dropup) { $bGroupOptions = $this->addClass($bGroupOptions, 'dropup'); } $options = $this->addClass($options, 'dropdown-toggle'); return $this->buttonGroup([ $this->button($title.' <span class="caret"></span>', $options), $this->Html->dropdown($menu, $ulOptions) ], $bGroupOptions); }
php
public function dropdownButton($title, array $menu = [], array $options = []) { // List of options to send to the dropdown() method $optsForHtml = ['align']; $ulOptions = []; foreach ($optsForHtml as $opt) { if (isset($options[$opt])) { $ulOptions[$opt] = $options[$opt]; unset($options[$opt]); } } $options += [ 'type' => false, 'dropup' => false, 'data-toggle' => 'dropdown' ]; $dropup = $options['dropup']; unset($options['dropup']); $bGroupOptions = []; if ($dropup) { $bGroupOptions = $this->addClass($bGroupOptions, 'dropup'); } $options = $this->addClass($options, 'dropdown-toggle'); return $this->buttonGroup([ $this->button($title.' <span class="caret"></span>', $options), $this->Html->dropdown($menu, $ulOptions) ], $bGroupOptions); }
[ "public", "function", "dropdownButton", "(", "$", "title", ",", "array", "$", "menu", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// List of options to send to the dropdown() method", "$", "optsForHtml", "=", "[", "'align'", "]", "...
Creates a dropdown button. This function is a shortcut for: ```php $this->Form->$buttonGroup([ $this->Form->button($title, $options), $this->Html->dropdown($menu, []) ]); ``` @param string $title The text for the button. @param array $menu HTML elements corresponding to menu options (which will be wrapped into `<li>` tag). To add separator, pass 'divider'. See `BootstrapHtml::dropdown()`. @param array $options Array of options for the button. See `button()`. @return string A HTML string containing the button dropdown.
[ "Creates", "a", "dropdown", "button", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/FormHelper.php#L658-L687
train
Holt59/cakephp3-bootstrap-helpers
src/View/Widget/ColumnSelectBoxWidget.php
ColumnSelectBoxWidget.render
public function render(array $data, \Cake\View\Form\ContextInterface $context) { $data += [ 'name' => '', 'empty' => false, 'escape' => true, 'options' => [], 'disabled' => null, 'val' => null, 'templateVars' => [] ]; $options = $this->_renderContent($data); $name = $data['name']; unset($data['name'], $data['options'], $data['empty'], $data['val'], $data['escape']); if (isset($data['disabled']) && is_array($data['disabled'])) { unset($data['disabled']); } return $this->_templates->format('selectColumn', [ 'name' => $name, 'templateVars' => $data['templateVars'], 'attrs' => $this->_templates->formatAttributes($data), 'content' => implode('', $options), ]); }
php
public function render(array $data, \Cake\View\Form\ContextInterface $context) { $data += [ 'name' => '', 'empty' => false, 'escape' => true, 'options' => [], 'disabled' => null, 'val' => null, 'templateVars' => [] ]; $options = $this->_renderContent($data); $name = $data['name']; unset($data['name'], $data['options'], $data['empty'], $data['val'], $data['escape']); if (isset($data['disabled']) && is_array($data['disabled'])) { unset($data['disabled']); } return $this->_templates->format('selectColumn', [ 'name' => $name, 'templateVars' => $data['templateVars'], 'attrs' => $this->_templates->formatAttributes($data), 'content' => implode('', $options), ]); }
[ "public", "function", "render", "(", "array", "$", "data", ",", "\\", "Cake", "\\", "View", "\\", "Form", "\\", "ContextInterface", "$", "context", ")", "{", "$", "data", "+=", "[", "'name'", "=>", "''", ",", "'empty'", "=>", "false", ",", "'escape'", ...
Render a select box form input inside a column. Render a select box input given a set of data. Supported keys are: - `name` - Set the input name. - `options` - An array of options. - `disabled` - Either true or an array of options to disable. When true, the select element will be disabled. - `val` - Either a string or an array of options to mark as selected. - `empty` - Set to true to add an empty option at the top of the option elements. Set to a string to define the display text of the empty option. If an array is used the key will set the value of the empty option while, the value will set the display text. - `escape` - Set to false to disable HTML escaping. ### Options format See `Cake\View\Widget\SelectBoxWidget::render()` methods. @param array $data Data to render with. @param \Cake\View\Form\ContextInterface $context The current form context. @return string A generated select box. @throws \RuntimeException when the name attribute is empty.
[ "Render", "a", "select", "box", "form", "input", "inside", "a", "column", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Widget/ColumnSelectBoxWidget.php#L53-L76
train
Ingenico-ePayments/connect-sdk-php
lib/Ingenico/Connect/Sdk/Webhooks/InMemorySecretKeyStore.php
InMemorySecretKeyStore.storeSecretKey
public function storeSecretKey($keyId, $secretKey) { if (is_null($keyId) || strlen(trim($keyId)) == 0) { throw new UnexpectedValueException("keyId is required"); } if (is_null($secretKey) || strlen(trim($secretKey)) == 0) { throw new UnexpectedValueException("secretKey is required"); } $this->secretKeys[$keyId] = $secretKey; }
php
public function storeSecretKey($keyId, $secretKey) { if (is_null($keyId) || strlen(trim($keyId)) == 0) { throw new UnexpectedValueException("keyId is required"); } if (is_null($secretKey) || strlen(trim($secretKey)) == 0) { throw new UnexpectedValueException("secretKey is required"); } $this->secretKeys[$keyId] = $secretKey; }
[ "public", "function", "storeSecretKey", "(", "$", "keyId", ",", "$", "secretKey", ")", "{", "if", "(", "is_null", "(", "$", "keyId", ")", "||", "strlen", "(", "trim", "(", "$", "keyId", ")", ")", "==", "0", ")", "{", "throw", "new", "UnexpectedValueE...
Stores the given secret key for the given key id. @param string $keyId @param string $secretKey
[ "Stores", "the", "given", "secret", "key", "for", "the", "given", "key", "id", "." ]
97154626b4b6116a176c356e4676f1794e396586
https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/InMemorySecretKeyStore.php#L42-L51
train
Ingenico-ePayments/connect-sdk-php
lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php
WebhooksHelper.unmarshal
public function unmarshal($body, $requestHeaders) { $this->validate($body, $requestHeaders); $response = new DefaultConnectionResponse(200, array('Content-Type' => 'application/json'), $body); $responseClassMap = new ResponseClassMap(); $responseClassMap->addResponseClassName(200, '\Ingenico\Connect\Sdk\Domain\Webhooks\WebhooksEvent'); $event = $this->getResponseFactory()->createResponse($response, $responseClassMap); $this->validateApiVersion($event); return $event; }
php
public function unmarshal($body, $requestHeaders) { $this->validate($body, $requestHeaders); $response = new DefaultConnectionResponse(200, array('Content-Type' => 'application/json'), $body); $responseClassMap = new ResponseClassMap(); $responseClassMap->addResponseClassName(200, '\Ingenico\Connect\Sdk\Domain\Webhooks\WebhooksEvent'); $event = $this->getResponseFactory()->createResponse($response, $responseClassMap); $this->validateApiVersion($event); return $event; }
[ "public", "function", "unmarshal", "(", "$", "body", ",", "$", "requestHeaders", ")", "{", "$", "this", "->", "validate", "(", "$", "body", ",", "$", "requestHeaders", ")", ";", "$", "response", "=", "new", "DefaultConnectionResponse", "(", "200", ",", "...
Unmarshals the given input stream that contains the body, while also validating its contents using the given request headers. @param string $body @param array $requestHeaders @return WebhooksEvent @throws SignatureValidationException @throws ApiVersionMismatchException
[ "Unmarshals", "the", "given", "input", "stream", "that", "contains", "the", "body", "while", "also", "validating", "its", "contents", "using", "the", "given", "request", "headers", "." ]
97154626b4b6116a176c356e4676f1794e396586
https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php#L49-L60
train
Ingenico-ePayments/connect-sdk-php
lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php
WebhooksHelper.validateBody
private function validateBody($body, $requestHeaders) { $signature = $this->getHeaderValue($requestHeaders, 'X-GCS-Signature'); $keyId = $this->getHeaderValue($requestHeaders, 'X-GCS-KeyId'); $secretKey = $this->secretKeyStore->getSecretKey($keyId); $expectedSignature = base64_encode(hash_hmac("sha256", $body, $secretKey, true)); $isValid = $this->areEqualSignatures($signature, $expectedSignature); if (!$isValid) { throw new SignatureValidationException("failed to validate signature '$signature'"); } }
php
private function validateBody($body, $requestHeaders) { $signature = $this->getHeaderValue($requestHeaders, 'X-GCS-Signature'); $keyId = $this->getHeaderValue($requestHeaders, 'X-GCS-KeyId'); $secretKey = $this->secretKeyStore->getSecretKey($keyId); $expectedSignature = base64_encode(hash_hmac("sha256", $body, $secretKey, true)); $isValid = $this->areEqualSignatures($signature, $expectedSignature); if (!$isValid) { throw new SignatureValidationException("failed to validate signature '$signature'"); } }
[ "private", "function", "validateBody", "(", "$", "body", ",", "$", "requestHeaders", ")", "{", "$", "signature", "=", "$", "this", "->", "getHeaderValue", "(", "$", "requestHeaders", ",", "'X-GCS-Signature'", ")", ";", "$", "keyId", "=", "$", "this", "->",...
validation utility methods
[ "validation", "utility", "methods" ]
97154626b4b6116a176c356e4676f1794e396586
https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php#L75-L87
train
Ingenico-ePayments/connect-sdk-php
lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php
WebhooksHelper.validateApiVersion
private function validateApiVersion($event) { if (Client::API_VERSION !== $event->apiVersion) { throw new ApiVersionMismatchException($event->apiVersion, Client::API_VERSION); } }
php
private function validateApiVersion($event) { if (Client::API_VERSION !== $event->apiVersion) { throw new ApiVersionMismatchException($event->apiVersion, Client::API_VERSION); } }
[ "private", "function", "validateApiVersion", "(", "$", "event", ")", "{", "if", "(", "Client", "::", "API_VERSION", "!==", "$", "event", "->", "apiVersion", ")", "{", "throw", "new", "ApiVersionMismatchException", "(", "$", "event", "->", "apiVersion", ",", ...
general utility methods
[ "general", "utility", "methods" ]
97154626b4b6116a176c356e4676f1794e396586
https://github.com/Ingenico-ePayments/connect-sdk-php/blob/97154626b4b6116a176c356e4676f1794e396586/lib/Ingenico/Connect/Sdk/Webhooks/WebhooksHelper.php#L107-L112
train
activecollab/activecollab-feather-sdk
src/Client.php
Client.prepareUrl
private function prepareUrl($path) { $bits = parse_url($path); $path = isset($bits['path']) && $bits['path'] ? $bits['path'] : '/'; if (substr($path, 0, 1) !== '/') { $path = '/' . $path; } $query = isset($bits['query']) && $bits['query'] ? '?' . $bits['query'] : ''; return $this->getUrl() . '/api/v' . $this->getApiVersion() . $path . $query; }
php
private function prepareUrl($path) { $bits = parse_url($path); $path = isset($bits['path']) && $bits['path'] ? $bits['path'] : '/'; if (substr($path, 0, 1) !== '/') { $path = '/' . $path; } $query = isset($bits['query']) && $bits['query'] ? '?' . $bits['query'] : ''; return $this->getUrl() . '/api/v' . $this->getApiVersion() . $path . $query; }
[ "private", "function", "prepareUrl", "(", "$", "path", ")", "{", "$", "bits", "=", "parse_url", "(", "$", "path", ")", ";", "$", "path", "=", "isset", "(", "$", "bits", "[", "'path'", "]", ")", "&&", "$", "bits", "[", "'path'", "]", "?", "$", "...
Prepare URL from the given path. @param string $path @return string
[ "Prepare", "URL", "from", "the", "given", "path", "." ]
061e952f30e20df33a160b13adb4dd70d324ba70
https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Client.php#L173-L186
train
activecollab/activecollab-feather-sdk
src/Client.php
Client.prepareAttachments
private function prepareAttachments($attachments = null) { $file_params = []; if ($attachments) { $counter = 1; foreach ($attachments as $attachment) { $path = is_array($attachment) ? $attachment[0] : $attachment; if (is_readable($path)) { $file_params['attachment_'.$counter++] = $attachment; } else { throw new FileNotReadable($attachment); } } } return $file_params; }
php
private function prepareAttachments($attachments = null) { $file_params = []; if ($attachments) { $counter = 1; foreach ($attachments as $attachment) { $path = is_array($attachment) ? $attachment[0] : $attachment; if (is_readable($path)) { $file_params['attachment_'.$counter++] = $attachment; } else { throw new FileNotReadable($attachment); } } } return $file_params; }
[ "private", "function", "prepareAttachments", "(", "$", "attachments", "=", "null", ")", "{", "$", "file_params", "=", "[", "]", ";", "if", "(", "$", "attachments", ")", "{", "$", "counter", "=", "1", ";", "foreach", "(", "$", "attachments", "as", "$", ...
Prepare attachments for request. @param array|null $attachments @return array|null @throws Exceptions\FileNotReadable
[ "Prepare", "attachments", "for", "request", "." ]
061e952f30e20df33a160b13adb4dd70d324ba70
https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Client.php#L209-L228
train
activecollab/activecollab-feather-sdk
src/Response.php
Response.isJson
public function isJson() { if ($this->is_json === null) { $this->is_json = strpos($this->getContentType(), 'application/json') !== false; } return $this->is_json; }
php
public function isJson() { if ($this->is_json === null) { $this->is_json = strpos($this->getContentType(), 'application/json') !== false; } return $this->is_json; }
[ "public", "function", "isJson", "(", ")", "{", "if", "(", "$", "this", "->", "is_json", "===", "null", ")", "{", "$", "this", "->", "is_json", "=", "strpos", "(", "$", "this", "->", "getContentType", "(", ")", ",", "'application/json'", ")", "!==", "...
Return true if response is JSON. @return bool
[ "Return", "true", "if", "response", "is", "JSON", "." ]
061e952f30e20df33a160b13adb4dd70d324ba70
https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Response.php#L122-L129
train
activecollab/activecollab-feather-sdk
src/Connector.php
Connector.&
private function &getHandle($url, $headers) { $http = curl_init(); curl_setopt($http, CURLOPT_USERAGENT, $this->getUserAgent()); curl_setopt($http, CURLOPT_RETURNTRANSFER, true); curl_setopt($http, CURLINFO_HEADER_OUT, true); curl_setopt($http, CURLOPT_URL, $url); if (!$this->getSslVerifyPeer()) { curl_setopt($http, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($http, CURLOPT_SSL_VERIFYHOST, false); } if (is_array($headers) && count($headers)) { curl_setopt($http, CURLOPT_HTTPHEADER, $headers); } $this->response_headers = []; curl_setopt( $http, CURLOPT_HEADERFUNCTION, function($curl, $header) { $len = strlen($header); $header = explode(':', $header, 2); if (count($header) < 2) { return $len; } $name = strtolower(trim($header[0])); if (!array_key_exists($name, $this->response_headers)) { $this->response_headers[$name] = [trim($header[1])]; } else { $this->response_headers[$name][] = trim($header[1]); } return $len; } ); return $http; }
php
private function &getHandle($url, $headers) { $http = curl_init(); curl_setopt($http, CURLOPT_USERAGENT, $this->getUserAgent()); curl_setopt($http, CURLOPT_RETURNTRANSFER, true); curl_setopt($http, CURLINFO_HEADER_OUT, true); curl_setopt($http, CURLOPT_URL, $url); if (!$this->getSslVerifyPeer()) { curl_setopt($http, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($http, CURLOPT_SSL_VERIFYHOST, false); } if (is_array($headers) && count($headers)) { curl_setopt($http, CURLOPT_HTTPHEADER, $headers); } $this->response_headers = []; curl_setopt( $http, CURLOPT_HEADERFUNCTION, function($curl, $header) { $len = strlen($header); $header = explode(':', $header, 2); if (count($header) < 2) { return $len; } $name = strtolower(trim($header[0])); if (!array_key_exists($name, $this->response_headers)) { $this->response_headers[$name] = [trim($header[1])]; } else { $this->response_headers[$name][] = trim($header[1]); } return $len; } ); return $http; }
[ "private", "function", "&", "getHandle", "(", "$", "url", ",", "$", "headers", ")", "{", "$", "http", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "http", ",", "CURLOPT_USERAGENT", ",", "$", "this", "->", "getUserAgent", "(", ")", ")", "...
Return curl resource. @param string $url @param array|null $headers @return resource
[ "Return", "curl", "resource", "." ]
061e952f30e20df33a160b13adb4dd70d324ba70
https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Connector.php#L182-L226
train
activecollab/activecollab-feather-sdk
src/Connector.php
Connector.execute
private function execute(&$http) { $raw_response = curl_exec($http); if ($raw_response === false) { $error_code = curl_errno($http); $error_message = curl_error($http); curl_close($http); throw new CallFailed($error_code, $raw_response, null, $error_message); } else { $response = new Response($http, $raw_response, $this->response_headers); curl_close($http); return $response; } }
php
private function execute(&$http) { $raw_response = curl_exec($http); if ($raw_response === false) { $error_code = curl_errno($http); $error_message = curl_error($http); curl_close($http); throw new CallFailed($error_code, $raw_response, null, $error_message); } else { $response = new Response($http, $raw_response, $this->response_headers); curl_close($http); return $response; } }
[ "private", "function", "execute", "(", "&", "$", "http", ")", "{", "$", "raw_response", "=", "curl_exec", "(", "$", "http", ")", ";", "if", "(", "$", "raw_response", "===", "false", ")", "{", "$", "error_code", "=", "curl_errno", "(", "$", "http", ")...
Do the call. @param resource $http @return string @throws CallFailed
[ "Do", "the", "call", "." ]
061e952f30e20df33a160b13adb4dd70d324ba70
https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Connector.php#L235-L252
train
activecollab/activecollab-feather-sdk
src/Authenticator/Cloud.php
Cloud.loadAccountsAndUser
private function loadAccountsAndUser() { if (!$this->accounts_and_user_loaded) { $email_address = $this->getEmailAddress(); $password = $this->getPassword(); if (empty($email_address) || empty($password)) { throw new Authentication('Email address and password are required'); } $response = $this->getConnector()->post('https://my.activecollab.com/api/v1/external/login', null, [ 'email' => $this->getEmailAddress(), 'password' => $this->getPassword(), ]); if ($response instanceof ResponseInterface) { if ($response->isJson()) { $result = $response->getJson(); if (empty($result['is_ok'])) { if (empty($result['message'])) { throw new ListAccounts(); } else { throw new ListAccounts($result['message']); } } elseif (empty($result['user']) || empty($result['user']['intent'])) { throw new ListAccounts('Invalid response'); } else { $this->accounts = $this->all_accounts = []; if (!empty($result['accounts']) && is_array($result['accounts'])) { foreach ($result['accounts'] as $account) { $this->all_accounts[] = $account; if ($account['class'] == 'FeatherApplicationInstance' || $account['class'] == 'ActiveCollab\Shepherd\Model\Account\ActiveCollab\FeatherAccount') { $account_id = (integer) $account['name']; $this->accounts[$account_id] = [ 'id' => (integer) $account['name'], 'name' => $account['display_name'], 'url' => $account['url'], ]; } } } $this->intent = $result['user']['intent']; unset($result['user']['intent']); $this->user = $result['user']; } } else { throw new Authentication( sprintf( 'Invalid response. JSON expected, got "%s", status code "%s"', $response->getContentType(), $response->getHttpCode() ) ); } } else { throw new Authentication('Invalid response'); } } }
php
private function loadAccountsAndUser() { if (!$this->accounts_and_user_loaded) { $email_address = $this->getEmailAddress(); $password = $this->getPassword(); if (empty($email_address) || empty($password)) { throw new Authentication('Email address and password are required'); } $response = $this->getConnector()->post('https://my.activecollab.com/api/v1/external/login', null, [ 'email' => $this->getEmailAddress(), 'password' => $this->getPassword(), ]); if ($response instanceof ResponseInterface) { if ($response->isJson()) { $result = $response->getJson(); if (empty($result['is_ok'])) { if (empty($result['message'])) { throw new ListAccounts(); } else { throw new ListAccounts($result['message']); } } elseif (empty($result['user']) || empty($result['user']['intent'])) { throw new ListAccounts('Invalid response'); } else { $this->accounts = $this->all_accounts = []; if (!empty($result['accounts']) && is_array($result['accounts'])) { foreach ($result['accounts'] as $account) { $this->all_accounts[] = $account; if ($account['class'] == 'FeatherApplicationInstance' || $account['class'] == 'ActiveCollab\Shepherd\Model\Account\ActiveCollab\FeatherAccount') { $account_id = (integer) $account['name']; $this->accounts[$account_id] = [ 'id' => (integer) $account['name'], 'name' => $account['display_name'], 'url' => $account['url'], ]; } } } $this->intent = $result['user']['intent']; unset($result['user']['intent']); $this->user = $result['user']; } } else { throw new Authentication( sprintf( 'Invalid response. JSON expected, got "%s", status code "%s"', $response->getContentType(), $response->getHttpCode() ) ); } } else { throw new Authentication('Invalid response'); } } }
[ "private", "function", "loadAccountsAndUser", "(", ")", "{", "if", "(", "!", "$", "this", "->", "accounts_and_user_loaded", ")", "{", "$", "email_address", "=", "$", "this", "->", "getEmailAddress", "(", ")", ";", "$", "password", "=", "$", "this", "->", ...
Load account and user details from Active Collab ID.
[ "Load", "account", "and", "user", "details", "from", "Active", "Collab", "ID", "." ]
061e952f30e20df33a160b13adb4dd70d324ba70
https://github.com/activecollab/activecollab-feather-sdk/blob/061e952f30e20df33a160b13adb4dd70d324ba70/src/Authenticator/Cloud.php#L134-L197
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.toArray
public function toArray() { return array( 'scheme' => $this->scheme->get(), 'user' => $this->user->get(), 'pass' => $this->pass->get(), 'host' => $this->host->get(), 'port' => $this->port->get(), 'path' => $this->path->get(), 'query' => $this->query->get(), 'fragment' => $this->fragment->get(), ); }
php
public function toArray() { return array( 'scheme' => $this->scheme->get(), 'user' => $this->user->get(), 'pass' => $this->pass->get(), 'host' => $this->host->get(), 'port' => $this->port->get(), 'path' => $this->path->get(), 'query' => $this->query->get(), 'fragment' => $this->fragment->get(), ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'scheme'", "=>", "$", "this", "->", "scheme", "->", "get", "(", ")", ",", "'user'", "=>", "$", "this", "->", "user", "->", "get", "(", ")", ",", "'pass'", "=>", "$", "this", ...
Retuns a array representation like parse_url But includes all components @return array
[ "Retuns", "a", "array", "representation", "like", "parse_url", "But", "includes", "all", "components" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L174-L186
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.createFromUrl
public static function createFromUrl($url) { $url = (string) $url; $url = trim($url); $original_url = $url; $url = self::sanitizeUrl($url); //if no valid scheme is found we add one if (is_null($url)) { throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $original_url)); } $components = array_merge(array( 'scheme' => null, 'user' => null, 'pass' => null, 'host' => null, 'port' => null, 'path' => null, 'query' => null, 'fragment' => null, ), self::parseUrl($url)); $components = self::formatAuthComponent($components); $components = self::formatPathComponent($components, $original_url); return new static( new Components\Scheme($components['scheme']), new Components\User($components['user']), new Components\Pass($components['pass']), new Components\Host($components['host']), new Components\Port($components['port']), new Components\Path($components['path']), new Components\Query($components['query']), new Components\Fragment($components['fragment']) ); }
php
public static function createFromUrl($url) { $url = (string) $url; $url = trim($url); $original_url = $url; $url = self::sanitizeUrl($url); //if no valid scheme is found we add one if (is_null($url)) { throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $original_url)); } $components = array_merge(array( 'scheme' => null, 'user' => null, 'pass' => null, 'host' => null, 'port' => null, 'path' => null, 'query' => null, 'fragment' => null, ), self::parseUrl($url)); $components = self::formatAuthComponent($components); $components = self::formatPathComponent($components, $original_url); return new static( new Components\Scheme($components['scheme']), new Components\User($components['user']), new Components\Pass($components['pass']), new Components\Host($components['host']), new Components\Port($components['port']), new Components\Path($components['path']), new Components\Query($components['query']), new Components\Fragment($components['fragment']) ); }
[ "public", "static", "function", "createFromUrl", "(", "$", "url", ")", "{", "$", "url", "=", "(", "string", ")", "$", "url", ";", "$", "url", "=", "trim", "(", "$", "url", ")", ";", "$", "original_url", "=", "$", "url", ";", "$", "url", "=", "s...
Return a instance of Url from a string @param string $url a string or an object that implement the __toString method @return static @throws RuntimeException If the URL can not be parse
[ "Return", "a", "instance", "of", "Url", "from", "a", "string" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L197-L232
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.parseUrl
protected static function parseUrl($url) { $components = @parse_url($url); if (! empty($components)) { return $components; } if (is_null(static::$is_parse_url_bugged)) { static::$is_parse_url_bugged = ! is_array(@parse_url("//example.org:80")); } //bugfix for https://bugs.php.net/bug.php?id=68917 if (static::$is_parse_url_bugged && strpos($url, '/') === 0 && is_array($components = @parse_url('http:'.$url)) ) { unset($components['scheme']); return $components; } throw new RuntimeException(sprintf("The given URL: `%s` could not be parse", $url)); }
php
protected static function parseUrl($url) { $components = @parse_url($url); if (! empty($components)) { return $components; } if (is_null(static::$is_parse_url_bugged)) { static::$is_parse_url_bugged = ! is_array(@parse_url("//example.org:80")); } //bugfix for https://bugs.php.net/bug.php?id=68917 if (static::$is_parse_url_bugged && strpos($url, '/') === 0 && is_array($components = @parse_url('http:'.$url)) ) { unset($components['scheme']); return $components; } throw new RuntimeException(sprintf("The given URL: `%s` could not be parse", $url)); }
[ "protected", "static", "function", "parseUrl", "(", "$", "url", ")", "{", "$", "components", "=", "@", "parse_url", "(", "$", "url", ")", ";", "if", "(", "!", "empty", "(", "$", "components", ")", ")", "{", "return", "$", "components", ";", "}", "i...
Parse a string as an URL @param string $url The URL to parse @throws InvalidArgumentException if the URL can not be parsed @return array
[ "Parse", "a", "string", "as", "an", "URL" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L243-L263
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.createFromServer
public static function createFromServer(array $server) { $scheme = self::fetchServerScheme($server); $host = self::fetchServerHost($server); $port = self::fetchServerPort($server); $request = self::fetchServerRequestUri($server); return self::createFromUrl($scheme.$host.$port.$request); }
php
public static function createFromServer(array $server) { $scheme = self::fetchServerScheme($server); $host = self::fetchServerHost($server); $port = self::fetchServerPort($server); $request = self::fetchServerRequestUri($server); return self::createFromUrl($scheme.$host.$port.$request); }
[ "public", "static", "function", "createFromServer", "(", "array", "$", "server", ")", "{", "$", "scheme", "=", "self", "::", "fetchServerScheme", "(", "$", "server", ")", ";", "$", "host", "=", "self", "::", "fetchServerHost", "(", "$", "server", ")", ";...
Return a instance of Url from a server array @param array $server the server array @return static @throws RuntimeException If the URL can not be parse
[ "Return", "a", "instance", "of", "Url", "from", "a", "server", "array" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L292-L300
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.fetchServerScheme
protected static function fetchServerScheme(array $server) { $scheme = ''; if (isset($server['SERVER_PROTOCOL'])) { $scheme = explode('/', $server['SERVER_PROTOCOL']); $scheme = strtolower($scheme[0]); if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) { $scheme .= 's'; } $scheme .= ':'; } return $scheme.'//'; }
php
protected static function fetchServerScheme(array $server) { $scheme = ''; if (isset($server['SERVER_PROTOCOL'])) { $scheme = explode('/', $server['SERVER_PROTOCOL']); $scheme = strtolower($scheme[0]); if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) { $scheme .= 's'; } $scheme .= ':'; } return $scheme.'//'; }
[ "protected", "static", "function", "fetchServerScheme", "(", "array", "$", "server", ")", "{", "$", "scheme", "=", "''", ";", "if", "(", "isset", "(", "$", "server", "[", "'SERVER_PROTOCOL'", "]", ")", ")", "{", "$", "scheme", "=", "explode", "(", "'/'...
Return the Server URL scheme component @param array $server the server array @return string
[ "Return", "the", "Server", "URL", "scheme", "component" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L309-L322
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.fetchServerHost
protected static function fetchServerHost(array $server) { if (isset($server['HTTP_HOST'])) { $header = $server['HTTP_HOST']; if (! preg_match('/(:\d+)$/', $header, $matches)) { return $header; } return substr($header, 0, -strlen($matches[1])); } if (isset($server['SERVER_ADDR'])) { return $server['SERVER_ADDR']; } throw new RuntimeException('Host could not be detected'); }
php
protected static function fetchServerHost(array $server) { if (isset($server['HTTP_HOST'])) { $header = $server['HTTP_HOST']; if (! preg_match('/(:\d+)$/', $header, $matches)) { return $header; } return substr($header, 0, -strlen($matches[1])); } if (isset($server['SERVER_ADDR'])) { return $server['SERVER_ADDR']; } throw new RuntimeException('Host could not be detected'); }
[ "protected", "static", "function", "fetchServerHost", "(", "array", "$", "server", ")", "{", "if", "(", "isset", "(", "$", "server", "[", "'HTTP_HOST'", "]", ")", ")", "{", "$", "header", "=", "$", "server", "[", "'HTTP_HOST'", "]", ";", "if", "(", "...
Return the Server URL host component @param array $server the server array @return string @throws \RuntimeException If no host is detected
[ "Return", "the", "Server", "URL", "host", "component" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L333-L349
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.fetchServerPort
protected static function fetchServerPort(array $server) { $port = ''; if (isset($server['SERVER_PORT']) && '80' != $server['SERVER_PORT']) { $port = ':'. (int) $server['SERVER_PORT']; } return $port; }
php
protected static function fetchServerPort(array $server) { $port = ''; if (isset($server['SERVER_PORT']) && '80' != $server['SERVER_PORT']) { $port = ':'. (int) $server['SERVER_PORT']; } return $port; }
[ "protected", "static", "function", "fetchServerPort", "(", "array", "$", "server", ")", "{", "$", "port", "=", "''", ";", "if", "(", "isset", "(", "$", "server", "[", "'SERVER_PORT'", "]", ")", "&&", "'80'", "!=", "$", "server", "[", "'SERVER_PORT'", "...
Return the Server URL port component @param array $server the server array @return string
[ "Return", "the", "Server", "URL", "port", "component" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L358-L366
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.formatAuthComponent
protected static function formatAuthComponent(array $components) { if (!is_null($components['scheme']) && is_null($components['host']) && !empty($components['path']) && strpos($components['path'], '@') !== false ) { $tmp = explode('@', $components['path'], 2); $components['user'] = $components['scheme']; $components['pass'] = $tmp[0]; $components['path'] = $tmp[1]; $components['scheme'] = null; } return $components; }
php
protected static function formatAuthComponent(array $components) { if (!is_null($components['scheme']) && is_null($components['host']) && !empty($components['path']) && strpos($components['path'], '@') !== false ) { $tmp = explode('@', $components['path'], 2); $components['user'] = $components['scheme']; $components['pass'] = $tmp[0]; $components['path'] = $tmp[1]; $components['scheme'] = null; } return $components; }
[ "protected", "static", "function", "formatAuthComponent", "(", "array", "$", "components", ")", "{", "if", "(", "!", "is_null", "(", "$", "components", "[", "'scheme'", "]", ")", "&&", "is_null", "(", "$", "components", "[", "'host'", "]", ")", "&&", "!"...
Reformat the component according to the auth content @param array $components the result from parse_url @return array
[ "Reformat", "the", "component", "according", "to", "the", "auth", "content" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L395-L410
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.formatHostComponent
protected static function formatHostComponent(array $components) { if (strpos($components['host'], '@')) { list($auth, $components['host']) = explode('@', $components['host']); $components['user'] = $auth; $components['pass'] = null; if (false !== strpos($auth, ':')) { list($components['user'], $components['pass']) = explode(':', $auth); } } return $components; }
php
protected static function formatHostComponent(array $components) { if (strpos($components['host'], '@')) { list($auth, $components['host']) = explode('@', $components['host']); $components['user'] = $auth; $components['pass'] = null; if (false !== strpos($auth, ':')) { list($components['user'], $components['pass']) = explode(':', $auth); } } return $components; }
[ "protected", "static", "function", "formatHostComponent", "(", "array", "$", "components", ")", "{", "if", "(", "strpos", "(", "$", "components", "[", "'host'", "]", ",", "'@'", ")", ")", "{", "list", "(", "$", "auth", ",", "$", "components", "[", "'ho...
Reformat the component according to the host content @param array $components the result from parse_url @return array
[ "Reformat", "the", "component", "according", "to", "the", "host", "content" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L419-L431
train
thephpleague/url
src/AbstractUrl.php
AbstractUrl.formatPathComponent
protected static function formatPathComponent(array $components, $url) { if (is_null($components['scheme']) && is_null($components['host']) && !empty($components['path']) ) { if (0 === strpos($components['path'], '///')) { //even with the added scheme the URL is still broken throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $url)); } if (0 === strpos($components['path'], '//')) { $tmp = substr($components['path'], 2); $components['path'] = null; $res = explode('/', $tmp, 2); $components['host'] = $res[0]; if (isset($res[1])) { $components['path'] = $res[1]; } $components = self::formatHostComponent($components); } } return $components; }
php
protected static function formatPathComponent(array $components, $url) { if (is_null($components['scheme']) && is_null($components['host']) && !empty($components['path']) ) { if (0 === strpos($components['path'], '///')) { //even with the added scheme the URL is still broken throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $url)); } if (0 === strpos($components['path'], '//')) { $tmp = substr($components['path'], 2); $components['path'] = null; $res = explode('/', $tmp, 2); $components['host'] = $res[0]; if (isset($res[1])) { $components['path'] = $res[1]; } $components = self::formatHostComponent($components); } } return $components; }
[ "protected", "static", "function", "formatPathComponent", "(", "array", "$", "components", ",", "$", "url", ")", "{", "if", "(", "is_null", "(", "$", "components", "[", "'scheme'", "]", ")", "&&", "is_null", "(", "$", "components", "[", "'host'", "]", ")...
Reformat the component according to the path content @param array $components the result from parse_url @param string $url the original URL to be parse @return array
[ "Reformat", "the", "component", "according", "to", "the", "path", "content" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/AbstractUrl.php#L441-L465
train
thephpleague/url
src/Components/AbstractArray.php
AbstractArray.convertToArray
protected function convertToArray($data, Closure $callback) { if (is_null($data)) { return array(); } if ($data instanceof Traversable) { return iterator_to_array($data); } if (self::isStringable($data)) { $data = (string) $data; $data = trim($data); $data = $callback($data); } if (! is_array($data)) { throw new RuntimeException('Your submitted data could not be converted into a proper array'); } return $data; }
php
protected function convertToArray($data, Closure $callback) { if (is_null($data)) { return array(); } if ($data instanceof Traversable) { return iterator_to_array($data); } if (self::isStringable($data)) { $data = (string) $data; $data = trim($data); $data = $callback($data); } if (! is_array($data)) { throw new RuntimeException('Your submitted data could not be converted into a proper array'); } return $data; }
[ "protected", "function", "convertToArray", "(", "$", "data", ",", "Closure", "$", "callback", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "data", "instanceof", "Traversable", ...
convert a given data into an array @param mixed $data the data to insert @param \Closure $callback a callable function to be called to parse a given string into the corresponding component @return array @throws \RuntimeException if the data is not valid
[ "convert", "a", "given", "data", "into", "an", "array" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/AbstractArray.php#L134-L155
train
thephpleague/url
src/Components/Host.php
Host.validate
protected function validate($data) { $data = $this->validateSegment($data); if (! $data) { return $data; } $this->saveInternalEncoding(); if (! $this->isValidHostLength($data)) { $this->restoreInternalEncoding(); throw new RuntimeException('Invalid hostname, check its length'); } if (! $this->isValidHostPattern($data)) { $this->restoreInternalEncoding(); throw new RuntimeException('Invalid host label, check its content'); } if (! $this->isValidHostLabels($data)) { $this->restoreInternalEncoding(); throw new RuntimeException('Invalid host label counts, check its count'); } $data = $this->sanitizeValue($data); $data = explode( $this->delimiter, $this->punycode->decode(implode($this->delimiter, $data)) ); $this->restoreInternalEncoding(); return $data; }
php
protected function validate($data) { $data = $this->validateSegment($data); if (! $data) { return $data; } $this->saveInternalEncoding(); if (! $this->isValidHostLength($data)) { $this->restoreInternalEncoding(); throw new RuntimeException('Invalid hostname, check its length'); } if (! $this->isValidHostPattern($data)) { $this->restoreInternalEncoding(); throw new RuntimeException('Invalid host label, check its content'); } if (! $this->isValidHostLabels($data)) { $this->restoreInternalEncoding(); throw new RuntimeException('Invalid host label counts, check its count'); } $data = $this->sanitizeValue($data); $data = explode( $this->delimiter, $this->punycode->decode(implode($this->delimiter, $data)) ); $this->restoreInternalEncoding(); return $data; }
[ "protected", "function", "validate", "(", "$", "data", ")", "{", "$", "data", "=", "$", "this", "->", "validateSegment", "(", "$", "data", ")", ";", "if", "(", "!", "$", "data", ")", "{", "return", "$", "data", ";", "}", "$", "this", "->", "saveI...
Validate Host data before insertion into a URL host component @param mixed $data the data to insert @return array @throws RuntimeException If the added is invalid
[ "Validate", "Host", "data", "before", "insertion", "into", "a", "URL", "host", "component" ]
45f5529ea879ffc166cc4e4ffa478a212c183628
https://github.com/thephpleague/url/blob/45f5529ea879ffc166cc4e4ffa478a212c183628/src/Components/Host.php#L149-L180
train