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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
crisu83/yiistrap | widgets/TbTypeAhead.php | TbTypeAhead.registerClientScript | public function registerClientScript()
{
/** @var TbApi $api */
$selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId());
$this->registerPlugin(TbApi::PLUGIN_TYPEAHEAD, $selector, $this->pluginOptions);
} | php | public function registerClientScript()
{
/** @var TbApi $api */
$selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId());
$this->registerPlugin(TbApi::PLUGIN_TYPEAHEAD, $selector, $this->pluginOptions);
} | [
"public",
"function",
"registerClientScript",
"(",
")",
"{",
"/** @var TbApi $api */",
"$",
"selector",
"=",
"'#'",
".",
"TbArray",
"::",
"getValue",
"(",
"'id'",
",",
"$",
"this",
"->",
"htmlOptions",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
... | Register required scripts. | [
"Register",
"required",
"scripts",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbTypeAhead.php#L128-L133 | train |
contentful/rich-text.php | src/Renderer.php | Renderer.createNodeRenderers | private function createNodeRenderers(): array
{
return [
new NodeRenderer\AssetHyperlink(),
new NodeRenderer\Blockquote(),
new NodeRenderer\Document(),
new NodeRenderer\EmbeddedAssetBlock(),
new NodeRenderer\EmbeddedAssetInline(),
new NodeRenderer\EmbeddedEntryBlock(),
new NodeRenderer\EmbeddedEntryInline(),
new NodeRenderer\EntryHyperlink(),
new NodeRenderer\Heading1(),
new NodeRenderer\Heading2(),
new NodeRenderer\Heading3(),
new NodeRenderer\Heading4(),
new NodeRenderer\Heading5(),
new NodeRenderer\Heading6(),
new NodeRenderer\Hr(),
new NodeRenderer\Hyperlink(),
new NodeRenderer\ListItem(),
new NodeRenderer\Nothing(),
new NodeRenderer\OrderedList(),
new NodeRenderer\Paragraph(),
new NodeRenderer\Text(),
new NodeRenderer\UnorderedList(),
];
} | php | private function createNodeRenderers(): array
{
return [
new NodeRenderer\AssetHyperlink(),
new NodeRenderer\Blockquote(),
new NodeRenderer\Document(),
new NodeRenderer\EmbeddedAssetBlock(),
new NodeRenderer\EmbeddedAssetInline(),
new NodeRenderer\EmbeddedEntryBlock(),
new NodeRenderer\EmbeddedEntryInline(),
new NodeRenderer\EntryHyperlink(),
new NodeRenderer\Heading1(),
new NodeRenderer\Heading2(),
new NodeRenderer\Heading3(),
new NodeRenderer\Heading4(),
new NodeRenderer\Heading5(),
new NodeRenderer\Heading6(),
new NodeRenderer\Hr(),
new NodeRenderer\Hyperlink(),
new NodeRenderer\ListItem(),
new NodeRenderer\Nothing(),
new NodeRenderer\OrderedList(),
new NodeRenderer\Paragraph(),
new NodeRenderer\Text(),
new NodeRenderer\UnorderedList(),
];
} | [
"private",
"function",
"createNodeRenderers",
"(",
")",
":",
"array",
"{",
"return",
"[",
"new",
"NodeRenderer",
"\\",
"AssetHyperlink",
"(",
")",
",",
"new",
"NodeRenderer",
"\\",
"Blockquote",
"(",
")",
",",
"new",
"NodeRenderer",
"\\",
"Document",
"(",
")... | Creates a list of default node renderers.
@return NodeRendererInterface[] | [
"Creates",
"a",
"list",
"of",
"default",
"node",
"renderers",
"."
] | 3711660bb65635572c126f6a64b6faea249babc6 | https://github.com/contentful/rich-text.php/blob/3711660bb65635572c126f6a64b6faea249babc6/src/Renderer.php#L109-L135 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.init | public function init()
{
parent::init();
if ($this->bootstrapPath === null) {
$this->bootstrapPath = Yii::getPathOfAlias('vendor.twbs.bootstrap.dist');
}
} | php | public function init()
{
parent::init();
if ($this->bootstrapPath === null) {
$this->bootstrapPath = Yii::getPathOfAlias('vendor.twbs.bootstrap.dist');
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"bootstrapPath",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"bootstrapPath",
"=",
"Yii",
"::",
"getPathOfAlias",
"(",
"'vendor.twbs.bootstr... | Initializes this component. | [
"Initializes",
"this",
"component",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L58-L64 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.registerCoreCss | public function registerCoreCss($url = null, $media = 'screen')
{
if ($url === null) {
$fileName = YII_DEBUG ? 'bootstrap.css' : 'bootstrap.min.css';
$url = $this->getBootstrapUrl() . '/css/' . $fileName;
}
Yii::app()->getClientScript()->registerCssFile($url, $media);
} | php | public function registerCoreCss($url = null, $media = 'screen')
{
if ($url === null) {
$fileName = YII_DEBUG ? 'bootstrap.css' : 'bootstrap.min.css';
$url = $this->getBootstrapUrl() . '/css/' . $fileName;
}
Yii::app()->getClientScript()->registerCssFile($url, $media);
} | [
"public",
"function",
"registerCoreCss",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"media",
"=",
"'screen'",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"null",
")",
"{",
"$",
"fileName",
"=",
"YII_DEBUG",
"?",
"'bootstrap.css'",
":",
"'bootstrap.min.css'",
";... | Registers the Bootstrap CSS.
@param string $url the URL to the CSS file to register.
@param string $media the media type (defaults to 'screen'). | [
"Registers",
"the",
"Bootstrap",
"CSS",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L71-L78 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.registerYiistrapCss | public function registerYiistrapCss($url = null, $media = 'screen')
{
if ($url === null) {
$fileName = YII_DEBUG ? 'yiistrap.css' : 'yiistrap.min.css';
$url = $this->getAssetsUrl() . '/css/' . $fileName;
}
Yii::app()->getClientScript()->registerCssFile($url, $media);
} | php | public function registerYiistrapCss($url = null, $media = 'screen')
{
if ($url === null) {
$fileName = YII_DEBUG ? 'yiistrap.css' : 'yiistrap.min.css';
$url = $this->getAssetsUrl() . '/css/' . $fileName;
}
Yii::app()->getClientScript()->registerCssFile($url, $media);
} | [
"public",
"function",
"registerYiistrapCss",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"media",
"=",
"'screen'",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"null",
")",
"{",
"$",
"fileName",
"=",
"YII_DEBUG",
"?",
"'yiistrap.css'",
":",
"'yiistrap.min.css'",
... | Registers the Yiistrap CSS.
@param string $url the URL to the CSS file to register.
@param string $media the media type (default to 'screen'). | [
"Registers",
"the",
"Yiistrap",
"CSS",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L99-L106 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.registerCoreScripts | public function registerCoreScripts($url = null, $position = CClientScript::POS_END)
{
if ($url === null) {
$fileName = YII_DEBUG ? 'bootstrap.js' : 'bootstrap.min.js';
$url = $this->getBootstrapUrl() . '/js/' . $fileName;
}
/** @var CClientScript $cs */
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($url, $position);
} | php | public function registerCoreScripts($url = null, $position = CClientScript::POS_END)
{
if ($url === null) {
$fileName = YII_DEBUG ? 'bootstrap.js' : 'bootstrap.min.js';
$url = $this->getBootstrapUrl() . '/js/' . $fileName;
}
/** @var CClientScript $cs */
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($url, $position);
} | [
"public",
"function",
"registerCoreScripts",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"position",
"=",
"CClientScript",
"::",
"POS_END",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"null",
")",
"{",
"$",
"fileName",
"=",
"YII_DEBUG",
"?",
"'bootstrap.js'",
":... | Registers jQuery and Bootstrap JavaScript.
@param string $url the URL to the JavaScript file to register.
@param int $position the position of the JavaScript code. | [
"Registers",
"jQuery",
"and",
"Bootstrap",
"JavaScript",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L132-L142 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.registerPopover | public function registerPopover($selector = 'body', $options = array())
{
TbArray::defaultValue('selector', 'a[rel=popover]', $options);
$this->registerPlugin(self::PLUGIN_POPOVER, $selector, $options);
} | php | public function registerPopover($selector = 'body', $options = array())
{
TbArray::defaultValue('selector', 'a[rel=popover]', $options);
$this->registerPlugin(self::PLUGIN_POPOVER, $selector, $options);
} | [
"public",
"function",
"registerPopover",
"(",
"$",
"selector",
"=",
"'body'",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"TbArray",
"::",
"defaultValue",
"(",
"'selector'",
",",
"'a[rel=popover]'",
",",
"$",
"options",
")",
";",
"$",
"this",
... | Registers the Bootstrap Popover plugin.
@param string $selector the CSS selector.
@param array $options the JavaScript options for the plugin.
@see http://twitter.github.com/bootstrap/javascript.html#popover | [
"Registers",
"the",
"Bootstrap",
"Popover",
"plugin",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L177-L181 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.registerTooltip | public function registerTooltip($selector = 'body', $options = array())
{
TbArray::defaultValue('selector', 'a[rel=tooltip]', $options);
$this->registerPlugin(self::PLUGIN_TOOLTIP, $selector, $options);
} | php | public function registerTooltip($selector = 'body', $options = array())
{
TbArray::defaultValue('selector', 'a[rel=tooltip]', $options);
$this->registerPlugin(self::PLUGIN_TOOLTIP, $selector, $options);
} | [
"public",
"function",
"registerTooltip",
"(",
"$",
"selector",
"=",
"'body'",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"TbArray",
"::",
"defaultValue",
"(",
"'selector'",
",",
"'a[rel=tooltip]'",
",",
"$",
"options",
")",
";",
"$",
"this",
... | Registers the Bootstrap Tooltip plugin.
@param string $selector the CSS selector.
@param array $options the JavaScript options for the plugin.
@see http://twitter.github.com/bootstrap/javascript.html#tooltip | [
"Registers",
"the",
"Bootstrap",
"Tooltip",
"plugin",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L189-L193 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.registerPlugin | public function registerPlugin($name, $selector, $options = array(), $position = CClientScript::POS_END)
{
$options = !empty($options) ? CJavaScript::encode($options) : '';
$script = "jQuery('{$selector}').{$name}({$options});";
$id = __CLASS__ . '#Plugin' . self::$counter++;
Yii::app()->clientScript->registerScript($id, $script, $position);
} | php | public function registerPlugin($name, $selector, $options = array(), $position = CClientScript::POS_END)
{
$options = !empty($options) ? CJavaScript::encode($options) : '';
$script = "jQuery('{$selector}').{$name}({$options});";
$id = __CLASS__ . '#Plugin' . self::$counter++;
Yii::app()->clientScript->registerScript($id, $script, $position);
} | [
"public",
"function",
"registerPlugin",
"(",
"$",
"name",
",",
"$",
"selector",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"position",
"=",
"CClientScript",
"::",
"POS_END",
")",
"{",
"$",
"options",
"=",
"!",
"empty",
"(",
"$",
"options",
... | Registers a specific Bootstrap plugin using the given selector and options.
@param string $name the plugin name.
@param string $selector the CSS selector.
@param array $options the JavaScript options for the plugin.
@param int $position the position of the JavaScript code. | [
"Registers",
"a",
"specific",
"Bootstrap",
"plugin",
"using",
"the",
"given",
"selector",
"and",
"options",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L202-L208 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.getBootstrapUrl | protected function getBootstrapUrl()
{
if (!isset($this->_bootstrapUrl)) {
if (isset($this->cdnUrl)) {
$this->_bootstrapUrl = $this->cdnUrl;
} else {
if (($path = Yii::getPathOfAlias($this->bootstrapPath)) !== false) {
$this->bootstrapPath = $path;
} else if ($this->bootstrapPath === false) {
throw new Exception("Invalid Bootstrap path and CDN URL not set. Set vendor.twbs.bootstrap.dist alias or cdnUrl parameter in the configuration file.");
}
$this->_bootstrapUrl = Yii::app()->assetManager->publish($this->bootstrapPath, false, -1, $this->forceCopyAssets);
}
}
return $this->_bootstrapUrl;
} | php | protected function getBootstrapUrl()
{
if (!isset($this->_bootstrapUrl)) {
if (isset($this->cdnUrl)) {
$this->_bootstrapUrl = $this->cdnUrl;
} else {
if (($path = Yii::getPathOfAlias($this->bootstrapPath)) !== false) {
$this->bootstrapPath = $path;
} else if ($this->bootstrapPath === false) {
throw new Exception("Invalid Bootstrap path and CDN URL not set. Set vendor.twbs.bootstrap.dist alias or cdnUrl parameter in the configuration file.");
}
$this->_bootstrapUrl = Yii::app()->assetManager->publish($this->bootstrapPath, false, -1, $this->forceCopyAssets);
}
}
return $this->_bootstrapUrl;
} | [
"protected",
"function",
"getBootstrapUrl",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_bootstrapUrl",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cdnUrl",
")",
")",
"{",
"$",
"this",
"->",
"_bootstrapUrl",
"=",
... | Returns the url to the published Bootstrap folder, or the CDN if applicable.
@return string the url.
@throws Exception | [
"Returns",
"the",
"url",
"to",
"the",
"published",
"Bootstrap",
"folder",
"or",
"the",
"CDN",
"if",
"applicable",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L236-L251 | train |
crisu83/yiistrap | components/TbApi.php | TbApi.getAssetsUrl | protected function getAssetsUrl()
{
if (!isset($this->_assetsUrl)) {
$assetPath = dirname(__DIR__) . '/assets';
$this->_assetsUrl = Yii::app()->assetManager->publish($assetPath, false, -1, $this->forceCopyAssets);
}
return $this->_assetsUrl;
} | php | protected function getAssetsUrl()
{
if (!isset($this->_assetsUrl)) {
$assetPath = dirname(__DIR__) . '/assets';
$this->_assetsUrl = Yii::app()->assetManager->publish($assetPath, false, -1, $this->forceCopyAssets);
}
return $this->_assetsUrl;
} | [
"protected",
"function",
"getAssetsUrl",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_assetsUrl",
")",
")",
"{",
"$",
"assetPath",
"=",
"dirname",
"(",
"__DIR__",
")",
".",
"'/assets'",
";",
"$",
"this",
"->",
"_assetsUrl",
"=",
... | Returns the url to the published folder that contains the assets for this extension.
@return string the url. | [
"Returns",
"the",
"url",
"to",
"the",
"published",
"folder",
"that",
"contains",
"the",
"assets",
"for",
"this",
"extension",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/components/TbApi.php#L257-L264 | train |
crisu83/yiistrap | widgets/TbPanel.php | TbPanel.run | public function run()
{
$this->renderContent();
$content = ob_get_clean();
if ($this->hideOnEmpty && trim($content) === '') {
return;
}
echo $this->_openTag;
echo $content;
if ($this->renderContentContainer) {
echo "</div>\n";
}
$this->renderFooter();
echo "</div>";
} | php | public function run()
{
$this->renderContent();
$content = ob_get_clean();
if ($this->hideOnEmpty && trim($content) === '') {
return;
}
echo $this->_openTag;
echo $content;
if ($this->renderContentContainer) {
echo "</div>\n";
}
$this->renderFooter();
echo "</div>";
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"renderContent",
"(",
")",
";",
"$",
"content",
"=",
"ob_get_clean",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hideOnEmpty",
"&&",
"trim",
"(",
"$",
"content",
")",
"===",
"''",
")"... | Renders the content of the panel. | [
"Renders",
"the",
"content",
"of",
"the",
"panel",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbPanel.php#L92-L106 | train |
crisu83/yiistrap | widgets/TbTabs.php | TbTabs.initEvents | public function initEvents()
{
foreach (array('onShow', 'onShown') as $event) {
if ($this->$event !== null) {
$modalEvent = strtolower(substr($event, 2));
if ($this->$event instanceof CJavaScriptExpression) {
$this->events[$modalEvent] = $this->$event;
} else {
$this->events[$modalEvent] = new CJavaScriptExpression($this->$event);
}
}
}
} | php | public function initEvents()
{
foreach (array('onShow', 'onShown') as $event) {
if ($this->$event !== null) {
$modalEvent = strtolower(substr($event, 2));
if ($this->$event instanceof CJavaScriptExpression) {
$this->events[$modalEvent] = $this->$event;
} else {
$this->events[$modalEvent] = new CJavaScriptExpression($this->$event);
}
}
}
} | [
"public",
"function",
"initEvents",
"(",
")",
"{",
"foreach",
"(",
"array",
"(",
"'onShow'",
",",
"'onShown'",
")",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"$",
"event",
"!==",
"null",
")",
"{",
"$",
"modalEvent",
"=",
"strtolower... | Initialize events if any | [
"Initialize",
"events",
"if",
"any"
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbTabs.php#L67-L79 | train |
crisu83/yiistrap | widgets/TbNav.php | TbNav.isItemActive | protected function isItemActive($item, $route)
{
if (isset($item['url']) && is_array($item['url']) && !strcasecmp(trim($item['url'][0], '/'), $route)) {
unset($item['url']['#']);
if (count($item['url']) > 1) {
foreach (array_splice($item['url'], 1) as $name => $value) {
if (!isset($_GET[$name]) || $_GET[$name] != $value) {
return false;
}
}
}
return true;
}
return false;
} | php | protected function isItemActive($item, $route)
{
if (isset($item['url']) && is_array($item['url']) && !strcasecmp(trim($item['url'][0], '/'), $route)) {
unset($item['url']['#']);
if (count($item['url']) > 1) {
foreach (array_splice($item['url'], 1) as $name => $value) {
if (!isset($_GET[$name]) || $_GET[$name] != $value) {
return false;
}
}
}
return true;
}
return false;
} | [
"protected",
"function",
"isItemActive",
"(",
"$",
"item",
",",
"$",
"route",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'url'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"item",
"[",
"'url'",
"]",
")",
"&&",
"!",
"strcasecmp",
"(",
"trim",
... | Checks whether a menu item is active.
@param array $item the menu item to be checked.
@param string $route the route of the current request.
@return boolean whether the menu item is active. | [
"Checks",
"whether",
"a",
"menu",
"item",
"is",
"active",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbNav.php#L156-L170 | train |
crisu83/yiistrap | widgets/TbModal.php | TbModal.renderButton | public function renderButton()
{
if (!empty($this->buttonOptions) && is_array($this->buttonOptions)) {
TbArray::defaultValue('data-toggle', 'modal', $this->buttonOptions);
if ($this->remote !== null) {
$this->buttonOptions['data-remote'] = CHtml::normalizeUrl($this->remote);
}
$selector = '#' . $this->htmlOptions['id'];
$label = TbArray::popValue('label', $this->buttonOptions, 'button');
$attr = isset($this->buttonOptions['data-remote']) ? 'data-target' : 'href';
TbArray::defaultValue($attr, $selector, $this->buttonOptions);
echo TbHtml::button($label, $this->buttonOptions);
}
} | php | public function renderButton()
{
if (!empty($this->buttonOptions) && is_array($this->buttonOptions)) {
TbArray::defaultValue('data-toggle', 'modal', $this->buttonOptions);
if ($this->remote !== null) {
$this->buttonOptions['data-remote'] = CHtml::normalizeUrl($this->remote);
}
$selector = '#' . $this->htmlOptions['id'];
$label = TbArray::popValue('label', $this->buttonOptions, 'button');
$attr = isset($this->buttonOptions['data-remote']) ? 'data-target' : 'href';
TbArray::defaultValue($attr, $selector, $this->buttonOptions);
echo TbHtml::button($label, $this->buttonOptions);
}
} | [
"public",
"function",
"renderButton",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"buttonOptions",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"buttonOptions",
")",
")",
"{",
"TbArray",
"::",
"defaultValue",
"(",
"'data-toggle'",
"... | Renders the button | [
"Renders",
"the",
"button"
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbModal.php#L203-L218 | train |
crisu83/yiistrap | widgets/TbThumbnails.php | TbThumbnails.renderItems | public function renderItems()
{
$thumbnails = array();
$data = $this->dataProvider->getData();
if (!empty($data)) {
$owner = $this->getOwner();
$render = $owner instanceof CController ? 'renderPartial' : 'render';
foreach ($data as $i => $row) {
$thumbnail = array();
$d = $this->viewData;
$d['index'] = $i;
$d['data'] = $row;
$d['widget'] = $this;
$thumbnail['caption'] = $owner->$render($this->itemView, $d, true);
if (isset($this->url)) {
$thumbnail['url'] = $this->evaluateExpression($this->url, array('data' => $row));
}
if (isset($this->span)) {
$thumbnail['span'] = $this->span;
}
$thumbnails[] = $thumbnail;
}
echo TbHtml::thumbnails($thumbnails, $this->htmlOptions);
} else {
$this->renderEmptyText();
}
} | php | public function renderItems()
{
$thumbnails = array();
$data = $this->dataProvider->getData();
if (!empty($data)) {
$owner = $this->getOwner();
$render = $owner instanceof CController ? 'renderPartial' : 'render';
foreach ($data as $i => $row) {
$thumbnail = array();
$d = $this->viewData;
$d['index'] = $i;
$d['data'] = $row;
$d['widget'] = $this;
$thumbnail['caption'] = $owner->$render($this->itemView, $d, true);
if (isset($this->url)) {
$thumbnail['url'] = $this->evaluateExpression($this->url, array('data' => $row));
}
if (isset($this->span)) {
$thumbnail['span'] = $this->span;
}
$thumbnails[] = $thumbnail;
}
echo TbHtml::thumbnails($thumbnails, $this->htmlOptions);
} else {
$this->renderEmptyText();
}
} | [
"public",
"function",
"renderItems",
"(",
")",
"{",
"$",
"thumbnails",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"dataProvider",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$"... | Renders the data items for the view.
Each item is corresponding to a single data model instance. | [
"Renders",
"the",
"data",
"items",
"for",
"the",
"view",
".",
"Each",
"item",
"is",
"corresponding",
"to",
"a",
"single",
"data",
"model",
"instance",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbThumbnails.php#L42-L69 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.tag | public static function tag($tag, $htmlOptions = array(), $content = false, $closeTag = true)
{
self::addSpanClass($htmlOptions);
self::addColClass($htmlOptions);
self::addPullClass($htmlOptions);
self::addTextAlignClass($htmlOptions);
return parent::tag($tag, $htmlOptions, $content, $closeTag);
} | php | public static function tag($tag, $htmlOptions = array(), $content = false, $closeTag = true)
{
self::addSpanClass($htmlOptions);
self::addColClass($htmlOptions);
self::addPullClass($htmlOptions);
self::addTextAlignClass($htmlOptions);
return parent::tag($tag, $htmlOptions, $content, $closeTag);
} | [
"public",
"static",
"function",
"tag",
"(",
"$",
"tag",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"content",
"=",
"false",
",",
"$",
"closeTag",
"=",
"true",
")",
"{",
"self",
"::",
"addSpanClass",
"(",
"$",
"htmlOptions",
")",
";",
... | Generates an HTML element.
@param string $tag the tag name.
@param array $htmlOptions the element attributes.
@param mixed $content the content to be enclosed between open and close element tags.
@param boolean $closeTag whether to generate the close tag.
@return string the generated HTML element tag. | [
"Generates",
"an",
"HTML",
"element",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L746-L753 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.activeCheckBox | public static function activeCheckBox($model, $attribute, $htmlOptions = array())
{
$label = TbArray::popValue('label', $htmlOptions, false);
$labelOptions = TbArray::popValue('labelOptions', $htmlOptions, array());
$input = parent::activeCheckBox($model, $attribute, $htmlOptions);
if (TbArray::popValue('useContainer', $htmlOptions, false)) {
return self::tag(
'div',
array('class' => 'checkbox'),
self::createCheckBoxAndRadioButtonLabel($label, $input, $labelOptions)
);
} else {
return self::createCheckBoxAndRadioButtonLabel($label, $input, $labelOptions);
}
} | php | public static function activeCheckBox($model, $attribute, $htmlOptions = array())
{
$label = TbArray::popValue('label', $htmlOptions, false);
$labelOptions = TbArray::popValue('labelOptions', $htmlOptions, array());
$input = parent::activeCheckBox($model, $attribute, $htmlOptions);
if (TbArray::popValue('useContainer', $htmlOptions, false)) {
return self::tag(
'div',
array('class' => 'checkbox'),
self::createCheckBoxAndRadioButtonLabel($label, $input, $labelOptions)
);
} else {
return self::createCheckBoxAndRadioButtonLabel($label, $input, $labelOptions);
}
} | [
"public",
"static",
"function",
"activeCheckBox",
"(",
"$",
"model",
",",
"$",
"attribute",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"label",
"=",
"TbArray",
"::",
"popValue",
"(",
"'label'",
",",
"$",
"htmlOptions",
",",
"false",
... | Generates a check box for a model attribute.
@param CModel $model the data model.
@param string $attribute the attribute.
@param array $htmlOptions additional HTML attributes.
@return string the generated check box. | [
"Generates",
"a",
"check",
"box",
"for",
"a",
"model",
"attribute",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L1947-L1961 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.activeRadioButtonList | public static function activeRadioButtonList($model, $attribute, $data, $htmlOptions = array())
{
parent::resolveNameID($model, $attribute, $htmlOptions);
$selection = parent::resolveValue($model, $attribute);
$name = TbArray::popValue('name', $htmlOptions);
$uncheckValue = TbArray::popValue('uncheckValue', $htmlOptions, '');
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => parent::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheckValue !== null ? parent::hiddenField($name, $uncheckValue, $hiddenOptions) : '';
return $hidden . self::radioButtonList($name, $selection, $data, $htmlOptions);
} | php | public static function activeRadioButtonList($model, $attribute, $data, $htmlOptions = array())
{
parent::resolveNameID($model, $attribute, $htmlOptions);
$selection = parent::resolveValue($model, $attribute);
$name = TbArray::popValue('name', $htmlOptions);
$uncheckValue = TbArray::popValue('uncheckValue', $htmlOptions, '');
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => parent::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheckValue !== null ? parent::hiddenField($name, $uncheckValue, $hiddenOptions) : '';
return $hidden . self::radioButtonList($name, $selection, $data, $htmlOptions);
} | [
"public",
"static",
"function",
"activeRadioButtonList",
"(",
"$",
"model",
",",
"$",
"attribute",
",",
"$",
"data",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"parent",
"::",
"resolveNameID",
"(",
"$",
"model",
",",
"$",
"attribute",
","... | Generates a radio button list for a model attribute.
@param CModel $model the data model.
@param string $attribute the attribute.
@param array $data $data value-label pairs used to generate the radio button list.
@param array $htmlOptions additional HTML attributes.
@return string the generated list. | [
"Generates",
"a",
"radio",
"button",
"list",
"for",
"a",
"model",
"attribute",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L2060-L2069 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.activeCheckBoxList | public static function activeCheckBoxList($model, $attribute, $data, $htmlOptions = array())
{
parent::resolveNameID($model, $attribute, $htmlOptions);
$selection = parent::resolveValue($model, $attribute);
if ($model->hasErrors($attribute)) {
parent::addErrorCss($htmlOptions);
}
$name = TbArray::popValue('name', $htmlOptions);
$uncheckValue = TbArray::popValue('uncheckValue', $htmlOptions, '');
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => parent::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheckValue !== null ? parent::hiddenField($name, $uncheckValue, $hiddenOptions) : '';
return $hidden . self::checkBoxList($name, $selection, $data, $htmlOptions);
} | php | public static function activeCheckBoxList($model, $attribute, $data, $htmlOptions = array())
{
parent::resolveNameID($model, $attribute, $htmlOptions);
$selection = parent::resolveValue($model, $attribute);
if ($model->hasErrors($attribute)) {
parent::addErrorCss($htmlOptions);
}
$name = TbArray::popValue('name', $htmlOptions);
$uncheckValue = TbArray::popValue('uncheckValue', $htmlOptions, '');
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => parent::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheckValue !== null ? parent::hiddenField($name, $uncheckValue, $hiddenOptions) : '';
return $hidden . self::checkBoxList($name, $selection, $data, $htmlOptions);
} | [
"public",
"static",
"function",
"activeCheckBoxList",
"(",
"$",
"model",
",",
"$",
"attribute",
",",
"$",
"data",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"parent",
"::",
"resolveNameID",
"(",
"$",
"model",
",",
"$",
"attribute",
",",
... | Generates a check box list for a model attribute.
@param CModel $model the data model.
@param string $attribute the attribute.
@param array $data $data value-label pairs used to generate the check box list.
@param array $htmlOptions additional HTML attributes.
@return string the generated list. | [
"Generates",
"a",
"check",
"box",
"list",
"for",
"a",
"model",
"attribute",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L2093-L2105 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.controls | public static function controls($controls, $htmlOptions = array())
{
if (TbArray::popValue('row', $htmlOptions, false)) {
self::addCssClass('row', $htmlOptions);
}
$before = TbArray::popValue('before', $htmlOptions, '');
$after = TbArray::popValue('after', $htmlOptions, '');
if (is_array($controls)) {
$controls = implode('', $controls);
}
$content = $before . $controls . $after;
return self::tag('div', $htmlOptions, $content);
} | php | public static function controls($controls, $htmlOptions = array())
{
if (TbArray::popValue('row', $htmlOptions, false)) {
self::addCssClass('row', $htmlOptions);
}
$before = TbArray::popValue('before', $htmlOptions, '');
$after = TbArray::popValue('after', $htmlOptions, '');
if (is_array($controls)) {
$controls = implode('', $controls);
}
$content = $before . $controls . $after;
return self::tag('div', $htmlOptions, $content);
} | [
"public",
"static",
"function",
"controls",
"(",
"$",
"controls",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"TbArray",
"::",
"popValue",
"(",
"'row'",
",",
"$",
"htmlOptions",
",",
"false",
")",
")",
"{",
"self",
"::",
"ad... | Generates form controls.
@param mixed $controls the controls.
@param array $htmlOptions additional HTML attributes.
@return string the generated controls. | [
"Generates",
"form",
"controls",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L2802-L2814 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.formActions | public static function formActions($actions, $htmlOptions = array())
{
self::addCssClass('form-actions', $htmlOptions);
if (is_array($actions)) {
$actions = implode(' ', $actions);
}
// todo: remove this
$labelWidthClass = TbArray::popValue('labelWidthClass', $htmlOptions, self::$defaultFormLabelWidthClass);
$controlWidthClass = TbArray::popValue('controlWidthClass', $htmlOptions, self::$defaultFormControlWidthClass);
// todo: remove everything that has to do with form layout
if (TbArray::popValue('formLayout', $htmlOptions, self::FORM_LAYOUT_VERTICAL) == self::FORM_LAYOUT_HORIZONTAL) {
self::addCssClass(self::switchColToOffset($labelWidthClass), $htmlOptions);
self::addCssClass(self::switchOffsetToCol($controlWidthClass), $htmlOptions);
return self::tag('div', array('class' => 'form-group'), self::tag('div', $htmlOptions, $actions));
} else {
return self::tag('div', $htmlOptions, $actions);
}
} | php | public static function formActions($actions, $htmlOptions = array())
{
self::addCssClass('form-actions', $htmlOptions);
if (is_array($actions)) {
$actions = implode(' ', $actions);
}
// todo: remove this
$labelWidthClass = TbArray::popValue('labelWidthClass', $htmlOptions, self::$defaultFormLabelWidthClass);
$controlWidthClass = TbArray::popValue('controlWidthClass', $htmlOptions, self::$defaultFormControlWidthClass);
// todo: remove everything that has to do with form layout
if (TbArray::popValue('formLayout', $htmlOptions, self::FORM_LAYOUT_VERTICAL) == self::FORM_LAYOUT_HORIZONTAL) {
self::addCssClass(self::switchColToOffset($labelWidthClass), $htmlOptions);
self::addCssClass(self::switchOffsetToCol($controlWidthClass), $htmlOptions);
return self::tag('div', array('class' => 'form-group'), self::tag('div', $htmlOptions, $actions));
} else {
return self::tag('div', $htmlOptions, $actions);
}
} | [
"public",
"static",
"function",
"formActions",
"(",
"$",
"actions",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'form-actions'",
",",
"$",
"htmlOptions",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"action... | Generates form actions div. This is no longer necessary in Bootstrap 3, but it is still useful to use for
horizontal forms. When used with a horizontal form, it will appropriately align the actions below other form
controls.
@param mixed $actions the actions.
@param array $htmlOptions additional HTML attributes.
@return string the generated actions. | [
"Generates",
"form",
"actions",
"div",
".",
"This",
"is",
"no",
"longer",
"necessary",
"in",
"Bootstrap",
"3",
"but",
"it",
"is",
"still",
"useful",
"to",
"use",
"for",
"horizontal",
"forms",
".",
"When",
"used",
"with",
"a",
"horizontal",
"form",
"it",
... | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L2837-L2856 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.imageThumbnail | public static function imageThumbnail($src, $alt = '', $htmlOptions = array())
{
$htmlOptions['type'] = self::IMAGE_TYPE_THUMBNAIL;
return self::image($src, $alt, $htmlOptions);
} | php | public static function imageThumbnail($src, $alt = '', $htmlOptions = array())
{
$htmlOptions['type'] = self::IMAGE_TYPE_THUMBNAIL;
return self::image($src, $alt, $htmlOptions);
} | [
"public",
"static",
"function",
"imageThumbnail",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"''",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"htmlOptions",
"[",
"'type'",
"]",
"=",
"self",
"::",
"IMAGE_TYPE_THUMBNAIL",
";",
"return",
... | Generates an image tag within thumbnail frame.
@param string $src the image URL.
@param string $alt the alternative text display.
@param array $htmlOptions additional HTML attributes.
@return string the generated image tag. | [
"Generates",
"an",
"image",
"tag",
"within",
"thumbnail",
"frame",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L3202-L3206 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.menu | public static function menu(array $items, $htmlOptions = array(), $depth = 0)
{
// todo: consider making this method protected.
if (!empty($items)) {
$htmlOptions['role'] = 'menu';
$output = self::openTag('ul', $htmlOptions);
foreach ($items as $itemOptions) {
if (is_string($itemOptions)) {
if ($itemOptions == '---') {
$output .= self::menuDivider();
} else {
$output .= $itemOptions;
}
} else {
if (TbArray::popValue('visible', $itemOptions, true) === false) {
continue;
}
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $itemOptions, array());
if (!empty($options)) {
$itemOptions = TbArray::merge($options, $itemOptions);
}
$label = TbArray::popValue('label', $itemOptions, '');
if (TbArray::popValue('active', $itemOptions, false)) {
self::addCssClass('active', $itemOptions);
}
if (TbArray::popValue('disabled', $itemOptions, false)) {
self::addCssClass('disabled', $itemOptions);
}
if (!isset($itemOptions['linkOptions'])) {
$itemOptions['linkOptions'] = array();
}
$icon = TbArray::popValue('icon', $itemOptions);
if (!empty($icon)) {
$label = self::icon($icon) . ' ' . $label;
}
$items = TbArray::popValue('items', $itemOptions, array());
$url = TbArray::popValue('url', $itemOptions, false);
if (empty($items)) {
if (!$url) {
$output .= self::menuHeader($label);
} else {
$itemOptions['linkOptions']['tabindex'] = -1;
$output .= self::menuLink($label, $url, $itemOptions);
}
} else {
$output .= self::menuDropdown($label, $url, $items, $itemOptions, $depth);
}
}
}
$output .= '</ul>';
return $output;
} else {
return '';
}
} | php | public static function menu(array $items, $htmlOptions = array(), $depth = 0)
{
// todo: consider making this method protected.
if (!empty($items)) {
$htmlOptions['role'] = 'menu';
$output = self::openTag('ul', $htmlOptions);
foreach ($items as $itemOptions) {
if (is_string($itemOptions)) {
if ($itemOptions == '---') {
$output .= self::menuDivider();
} else {
$output .= $itemOptions;
}
} else {
if (TbArray::popValue('visible', $itemOptions, true) === false) {
continue;
}
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $itemOptions, array());
if (!empty($options)) {
$itemOptions = TbArray::merge($options, $itemOptions);
}
$label = TbArray::popValue('label', $itemOptions, '');
if (TbArray::popValue('active', $itemOptions, false)) {
self::addCssClass('active', $itemOptions);
}
if (TbArray::popValue('disabled', $itemOptions, false)) {
self::addCssClass('disabled', $itemOptions);
}
if (!isset($itemOptions['linkOptions'])) {
$itemOptions['linkOptions'] = array();
}
$icon = TbArray::popValue('icon', $itemOptions);
if (!empty($icon)) {
$label = self::icon($icon) . ' ' . $label;
}
$items = TbArray::popValue('items', $itemOptions, array());
$url = TbArray::popValue('url', $itemOptions, false);
if (empty($items)) {
if (!$url) {
$output .= self::menuHeader($label);
} else {
$itemOptions['linkOptions']['tabindex'] = -1;
$output .= self::menuLink($label, $url, $itemOptions);
}
} else {
$output .= self::menuDropdown($label, $url, $items, $itemOptions, $depth);
}
}
}
$output .= '</ul>';
return $output;
} else {
return '';
}
} | [
"public",
"static",
"function",
"menu",
"(",
"array",
"$",
"items",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"// todo: consider making this method protected.\r",
"if",
"(",
"!",
"empty",
"(",
"$",
"items",
")"... | Generates a menu.
@param array $items the menu items.
@param array $htmlOptions additional HTML attributes.
@param integer $depth the current depth.
@return string the generated menu. | [
"Generates",
"a",
"menu",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L3612-L3667 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.menuHeader | public static function menuHeader($label, $htmlOptions = array())
{
self::addCssClass('dropdown-header', $htmlOptions);
return self::tag('li', $htmlOptions, $label);
} | php | public static function menuHeader($label, $htmlOptions = array())
{
self::addCssClass('dropdown-header', $htmlOptions);
return self::tag('li', $htmlOptions, $label);
} | [
"public",
"static",
"function",
"menuHeader",
"(",
"$",
"label",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'dropdown-header'",
",",
"$",
"htmlOptions",
")",
";",
"return",
"self",
"::",
"tag",
"(",
"'li... | Generates a menu header.
@param string $label the header text.
@param array $htmlOptions additional HTML options.
@return string the generated header. | [
"Generates",
"a",
"menu",
"header",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L3719-L3723 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.navbar | public static function navbar($content, $htmlOptions = array())
{
self::addCssClass('navbar', $htmlOptions);
$display = TbArray::popValue('display', $htmlOptions);
if (!empty($display)) {
self::addCssClass('navbar-' . $display, $htmlOptions);
}
$color = TbArray::popValue('color', $htmlOptions, 'default');
if (!empty($color)) {
self::addCssClass('navbar-' . $color, $htmlOptions);
}
$htmlOptions['role'] = 'navigation';
$output = self::openTag('nav', $htmlOptions);
$output .= $content;
$output .= '</nav>';
return $output;
} | php | public static function navbar($content, $htmlOptions = array())
{
self::addCssClass('navbar', $htmlOptions);
$display = TbArray::popValue('display', $htmlOptions);
if (!empty($display)) {
self::addCssClass('navbar-' . $display, $htmlOptions);
}
$color = TbArray::popValue('color', $htmlOptions, 'default');
if (!empty($color)) {
self::addCssClass('navbar-' . $color, $htmlOptions);
}
$htmlOptions['role'] = 'navigation';
$output = self::openTag('nav', $htmlOptions);
$output .= $content;
$output .= '</nav>';
return $output;
} | [
"public",
"static",
"function",
"navbar",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'navbar'",
",",
"$",
"htmlOptions",
")",
";",
"$",
"display",
"=",
"TbArray",
"::",
"popValue",
... | Generates a navbar.
@param string $content the navbar content.
@param array $htmlOptions additional HTML attributes.
@return string the generated navbar. | [
"Generates",
"a",
"navbar",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L3841-L3857 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.navbarBrandLink | public static function navbarBrandLink($label, $url, $htmlOptions = array())
{
self::addCssClass('navbar-brand', $htmlOptions);
return self::link($label, $url, $htmlOptions);
} | php | public static function navbarBrandLink($label, $url, $htmlOptions = array())
{
self::addCssClass('navbar-brand', $htmlOptions);
return self::link($label, $url, $htmlOptions);
} | [
"public",
"static",
"function",
"navbarBrandLink",
"(",
"$",
"label",
",",
"$",
"url",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'navbar-brand'",
",",
"$",
"htmlOptions",
")",
";",
"return",
"self",
"::... | Generates a brand link for the navbar.
@param string $label the link label text.
@param string $url the link url.
@param array $htmlOptions additional HTML attributes.
@return string the generated link. | [
"Generates",
"a",
"brand",
"link",
"for",
"the",
"navbar",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L3866-L3870 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.paginationLink | public static function paginationLink($label, $url, $htmlOptions = array())
{
$linkOptions = TbArray::popValue('linkOptions', $htmlOptions, array());
if (TbArray::popValue('active', $htmlOptions, false)) {
self::addCssClass('active', $htmlOptions);
$label .= ' ' . self::tag('span', array('class' => 'sr-only'), '(current)');
}
if (TbArray::popValue('disabled', $htmlOptions, false)) {
self::addCssClass('disabled', $htmlOptions);
}
$content = self::link($label, $url, $linkOptions);
return self::tag('li', $htmlOptions, $content);
} | php | public static function paginationLink($label, $url, $htmlOptions = array())
{
$linkOptions = TbArray::popValue('linkOptions', $htmlOptions, array());
if (TbArray::popValue('active', $htmlOptions, false)) {
self::addCssClass('active', $htmlOptions);
$label .= ' ' . self::tag('span', array('class' => 'sr-only'), '(current)');
}
if (TbArray::popValue('disabled', $htmlOptions, false)) {
self::addCssClass('disabled', $htmlOptions);
}
$content = self::link($label, $url, $linkOptions);
return self::tag('li', $htmlOptions, $content);
} | [
"public",
"static",
"function",
"paginationLink",
"(",
"$",
"label",
",",
"$",
"url",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"linkOptions",
"=",
"TbArray",
"::",
"popValue",
"(",
"'linkOptions'",
",",
"$",
"htmlOptions",
",",
"ar... | Generates a pagination link.
@param string $label the link label text.
@param mixed $url the link url.
@param array $htmlOptions additional HTML attributes.
@return string the generated link. | [
"Generates",
"a",
"pagination",
"link",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L4013-L4025 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.pager | public static function pager(array $links, $htmlOptions = array())
{
if (!empty($links)) {
self::addCssClass('pager', $htmlOptions);
$output = self::openTag('ul', $htmlOptions);
foreach ($links as $itemOptions) {
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $itemOptions, array());
if (!empty($options)) {
$itemOptions = TbArray::merge($options, $itemOptions);
}
$label = TbArray::popValue('label', $itemOptions, '');
$url = TbArray::popValue('url', $itemOptions, false);
$output .= self::pagerLink($label, $url, $itemOptions);
}
$output .= '</ul>';
return $output;
}
return '';
} | php | public static function pager(array $links, $htmlOptions = array())
{
if (!empty($links)) {
self::addCssClass('pager', $htmlOptions);
$output = self::openTag('ul', $htmlOptions);
foreach ($links as $itemOptions) {
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $itemOptions, array());
if (!empty($options)) {
$itemOptions = TbArray::merge($options, $itemOptions);
}
$label = TbArray::popValue('label', $itemOptions, '');
$url = TbArray::popValue('url', $itemOptions, false);
$output .= self::pagerLink($label, $url, $itemOptions);
}
$output .= '</ul>';
return $output;
}
return '';
} | [
"public",
"static",
"function",
"pager",
"(",
"array",
"$",
"links",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"links",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'pager'",
",",
"$",
"htmlO... | Generates a pager.
@param array $links the pager buttons.
@param array $htmlOptions additional HTML attributes.
@return string the generated pager. | [
"Generates",
"a",
"pager",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L4033-L4052 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.thumbnails | public static function thumbnails(array $thumbnails, $htmlOptions = array())
{
if (!empty($thumbnails)) {
self::addCssClass('thumbnails', $htmlOptions);
$defaultSpan = TbArray::popValue('span', $htmlOptions, 3);
$output = self::openTag('ul', $htmlOptions);
foreach ($thumbnails as $thumbnailOptions) {
if (isset($thumbnailOptions['visible']) && $thumbnailOptions['visible'] === false) {
continue;
}
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $thumbnailOptions, array());
if (!empty($options)) {
$thumbnailOptions = TbArray::merge($options, $thumbnailOptions);
}
$thumbnailOptions['itemOptions']['span'] = TbArray::popValue('span', $thumbnailOptions, $defaultSpan);
$caption = TbArray::popValue('caption', $thumbnailOptions, '');
$captionOptions = TbArray::popValue('captionOptions', $thumbnailOptions, array());
self::addCssClass('caption', $captionOptions);
$label = TbArray::popValue('label', $thumbnailOptions);
$labelOptions = TbArray::popValue('labelOptions', $thumbnailOptions, array());
if (!empty($label)) {
$caption = self::tag('h3', $labelOptions, $label) . $caption;
}
$content = !empty($caption) ? self::tag('div', $captionOptions, $caption) : '';
$image = TbArray::popValue('image', $thumbnailOptions);
$imageOptions = TbArray::popValue('imageOptions', $thumbnailOptions, array());
$imageAlt = TbArray::popValue('alt', $imageOptions, '');
if (!empty($image)) {
$content = parent::image($image, $imageAlt, $imageOptions) . $content;
}
$url = TbArray::popValue('url', $thumbnailOptions, false);
$output .= $url !== false
? self::thumbnailLink($content, $url, $thumbnailOptions)
: self::thumbnail($content, $thumbnailOptions);
}
$output .= '</ul>';
return $output;
} else {
return '';
}
} | php | public static function thumbnails(array $thumbnails, $htmlOptions = array())
{
if (!empty($thumbnails)) {
self::addCssClass('thumbnails', $htmlOptions);
$defaultSpan = TbArray::popValue('span', $htmlOptions, 3);
$output = self::openTag('ul', $htmlOptions);
foreach ($thumbnails as $thumbnailOptions) {
if (isset($thumbnailOptions['visible']) && $thumbnailOptions['visible'] === false) {
continue;
}
// todo: consider removing the support for htmlOptions.
$options = TbArray::popValue('htmlOptions', $thumbnailOptions, array());
if (!empty($options)) {
$thumbnailOptions = TbArray::merge($options, $thumbnailOptions);
}
$thumbnailOptions['itemOptions']['span'] = TbArray::popValue('span', $thumbnailOptions, $defaultSpan);
$caption = TbArray::popValue('caption', $thumbnailOptions, '');
$captionOptions = TbArray::popValue('captionOptions', $thumbnailOptions, array());
self::addCssClass('caption', $captionOptions);
$label = TbArray::popValue('label', $thumbnailOptions);
$labelOptions = TbArray::popValue('labelOptions', $thumbnailOptions, array());
if (!empty($label)) {
$caption = self::tag('h3', $labelOptions, $label) . $caption;
}
$content = !empty($caption) ? self::tag('div', $captionOptions, $caption) : '';
$image = TbArray::popValue('image', $thumbnailOptions);
$imageOptions = TbArray::popValue('imageOptions', $thumbnailOptions, array());
$imageAlt = TbArray::popValue('alt', $imageOptions, '');
if (!empty($image)) {
$content = parent::image($image, $imageAlt, $imageOptions) . $content;
}
$url = TbArray::popValue('url', $thumbnailOptions, false);
$output .= $url !== false
? self::thumbnailLink($content, $url, $thumbnailOptions)
: self::thumbnail($content, $thumbnailOptions);
}
$output .= '</ul>';
return $output;
} else {
return '';
}
} | [
"public",
"static",
"function",
"thumbnails",
"(",
"array",
"$",
"thumbnails",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"thumbnails",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'thumbnails'",
... | Generates a list of thumbnails.
@param array $thumbnails the list configuration.
@param array $htmlOptions additional HTML attributes.
@return string the generated thumbnails. | [
"Generates",
"a",
"list",
"of",
"thumbnails",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L4164-L4205 | train |
crisu83/yiistrap | helpers/TbHtml.php | TbHtml.modalHeader | public static function modalHeader($content, $htmlOptions = array())
{
self::addCssClass('modal-header', $htmlOptions);
$closeOptions = TbArray::popValue('closeOptions', $htmlOptions, array());
$closeOptions['dismiss'] = 'modal';
$headingOptions = TbArray::popValue('headingOptions', $htmlOptions, array());
$closeLabel = TbArray::popValue('closeLabel', $htmlOptions, self::CLOSE_TEXT);
$closeButton = self::closeButton($closeLabel, $closeOptions);
self::addCssClass('modal-title', $headingOptions);
$header = self::tag('h4', $headingOptions, $content);
return self::tag('div', $htmlOptions, $closeButton . $header);
} | php | public static function modalHeader($content, $htmlOptions = array())
{
self::addCssClass('modal-header', $htmlOptions);
$closeOptions = TbArray::popValue('closeOptions', $htmlOptions, array());
$closeOptions['dismiss'] = 'modal';
$headingOptions = TbArray::popValue('headingOptions', $htmlOptions, array());
$closeLabel = TbArray::popValue('closeLabel', $htmlOptions, self::CLOSE_TEXT);
$closeButton = self::closeButton($closeLabel, $closeOptions);
self::addCssClass('modal-title', $headingOptions);
$header = self::tag('h4', $headingOptions, $content);
return self::tag('div', $htmlOptions, $closeButton . $header);
} | [
"public",
"static",
"function",
"modalHeader",
"(",
"$",
"content",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"self",
"::",
"addCssClass",
"(",
"'modal-header'",
",",
"$",
"htmlOptions",
")",
";",
"$",
"closeOptions",
"=",
"TbArray",
"::",... | Generates a modal header.
@param string $content the header content.
@param array $htmlOptions additional HTML attributes.
@return string the generated header. | [
"Generates",
"a",
"modal",
"header",
"."
] | 0375cf186f2af76e4b26bbaa95a7be4996590b86 | https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/helpers/TbHtml.php#L4581-L4592 | train |
cpliakas/magento-client-php | src/Magento/Client/Rest/OauthException.php | OauthException.factory | public static function factory(RequestInterface $request, Response $response)
{
$message = 'Client error response' . PHP_EOL . implode(PHP_EOL, array(
'[status code] ' . $response->getStatusCode(),
'[reason phrase] ' . $response->getReasonPhrase(),
'[url] ' . $request->getUrl(),
));
$e = new static($message);
$e->setResponse($response);
$e->setRequest($request);
return $e;
} | php | public static function factory(RequestInterface $request, Response $response)
{
$message = 'Client error response' . PHP_EOL . implode(PHP_EOL, array(
'[status code] ' . $response->getStatusCode(),
'[reason phrase] ' . $response->getReasonPhrase(),
'[url] ' . $request->getUrl(),
));
$e = new static($message);
$e->setResponse($response);
$e->setRequest($request);
return $e;
} | [
"public",
"static",
"function",
"factory",
"(",
"RequestInterface",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"message",
"=",
"'Client error response'",
".",
"PHP_EOL",
".",
"implode",
"(",
"PHP_EOL",
",",
"array",
"(",
"'[status code] '",... | Factory method to create a new Oauth exception.
@param RequestInterface $request
@param Response $response
@return OauthException | [
"Factory",
"method",
"to",
"create",
"a",
"new",
"Oauth",
"exception",
"."
] | f13c45c5ca36c2260632c191225c7664c6dfd176 | https://github.com/cpliakas/magento-client-php/blob/f13c45c5ca36c2260632c191225c7664c6dfd176/src/Magento/Client/Rest/OauthException.php#L19-L32 | train |
cpliakas/magento-client-php | src/Magento/Client/Rest/OauthException.php | OauthException.getOauthProblem | public function getOauthProblem()
{
parse_str($this->getResponse()->getBody(true), $arr);
return isset($arr['oauth_problem']) ? $arr['oauth_problem'] : '';
} | php | public function getOauthProblem()
{
parse_str($this->getResponse()->getBody(true), $arr);
return isset($arr['oauth_problem']) ? $arr['oauth_problem'] : '';
} | [
"public",
"function",
"getOauthProblem",
"(",
")",
"{",
"parse_str",
"(",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
"true",
")",
",",
"$",
"arr",
")",
";",
"return",
"isset",
"(",
"$",
"arr",
"[",
"'oauth_problem'",
"]",
")",
... | Returns the Magento problem constant.
@return string | [
"Returns",
"the",
"Magento",
"problem",
"constant",
"."
] | f13c45c5ca36c2260632c191225c7664c6dfd176 | https://github.com/cpliakas/magento-client-php/blob/f13c45c5ca36c2260632c191225c7664c6dfd176/src/Magento/Client/Rest/OauthException.php#L39-L43 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.requireDefaultRecords | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Only run on ErrorPage class directly, not subclasses
if (static::class !== self::class || !SiteTree::config()->create_default_pages) {
return;
}
$defaultPages = $this->getDefaultRecords();
foreach ($defaultPages as $defaultData) {
$this->requireDefaultRecordFixture($defaultData);
}
} | php | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Only run on ErrorPage class directly, not subclasses
if (static::class !== self::class || !SiteTree::config()->create_default_pages) {
return;
}
$defaultPages = $this->getDefaultRecords();
foreach ($defaultPages as $defaultData) {
$this->requireDefaultRecordFixture($defaultData);
}
} | [
"public",
"function",
"requireDefaultRecords",
"(",
")",
"{",
"parent",
"::",
"requireDefaultRecords",
"(",
")",
";",
"// Only run on ErrorPage class directly, not subclasses",
"if",
"(",
"static",
"::",
"class",
"!==",
"self",
"::",
"class",
"||",
"!",
"SiteTree",
... | Ensures that there is always a 404 page by checking if there's an
instance of ErrorPage with a 404 and 500 error code. If there is not,
one is created when the DB is built. | [
"Ensures",
"that",
"there",
"is",
"always",
"a",
"404",
"page",
"by",
"checking",
"if",
"there",
"s",
"an",
"instance",
"of",
"ErrorPage",
"with",
"a",
"404",
"and",
"500",
"error",
"code",
".",
"If",
"there",
"is",
"not",
"one",
"is",
"created",
"when... | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L128-L142 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.requireDefaultRecordFixture | protected function requireDefaultRecordFixture($defaultData)
{
$code = $defaultData['ErrorCode'];
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
$pageExists = !empty($page);
if (!$pageExists) {
$page = new ErrorPage($defaultData);
$page->write();
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
}
// Check if static files are enabled
if (!self::config()->enable_static_file) {
return;
}
// Ensure this page has cached error content
$success = true;
if (!$page->hasStaticPage()) {
// Update static content
$success = $page->writeStaticPage();
} elseif ($pageExists) {
// If page exists and already has content, no alteration_message is displayed
return;
}
if ($success) {
DB::alteration_message(
sprintf('%s error page created', $code),
'created'
);
} else {
DB::alteration_message(
sprintf('%s error page could not be created. Please check permissions', $code),
'error'
);
}
} | php | protected function requireDefaultRecordFixture($defaultData)
{
$code = $defaultData['ErrorCode'];
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
$pageExists = !empty($page);
if (!$pageExists) {
$page = new ErrorPage($defaultData);
$page->write();
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
}
// Check if static files are enabled
if (!self::config()->enable_static_file) {
return;
}
// Ensure this page has cached error content
$success = true;
if (!$page->hasStaticPage()) {
// Update static content
$success = $page->writeStaticPage();
} elseif ($pageExists) {
// If page exists and already has content, no alteration_message is displayed
return;
}
if ($success) {
DB::alteration_message(
sprintf('%s error page created', $code),
'created'
);
} else {
DB::alteration_message(
sprintf('%s error page could not be created. Please check permissions', $code),
'error'
);
}
} | [
"protected",
"function",
"requireDefaultRecordFixture",
"(",
"$",
"defaultData",
")",
"{",
"$",
"code",
"=",
"$",
"defaultData",
"[",
"'ErrorCode'",
"]",
";",
"$",
"page",
"=",
"ErrorPage",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'ErrorCode'",
",",
"$... | Build default record from specification fixture
@param array $defaultData | [
"Build",
"default",
"record",
"from",
"specification",
"fixture"
] | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L149-L186 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.getDefaultRecords | protected function getDefaultRecords()
{
$data = array(
array(
'ErrorCode' => 404,
'Title' => _t('SilverStripe\\ErrorPage\\ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found'),
'Content' => _t(
'SilverStripe\\ErrorPage\\ErrorPage.DEFAULTERRORPAGECONTENT',
'<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p>'
. '<p>Please check the spelling of the URL you were trying to access and try again.</p>'
)
),
array(
'ErrorCode' => 500,
'Title' => _t('SilverStripe\\ErrorPage\\ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error'),
'Content' => _t(
'SilverStripe\\ErrorPage\\ErrorPage.DEFAULTSERVERERRORPAGECONTENT',
'<p>Sorry, there was a problem with handling your request.</p>'
)
)
);
$this->extend('getDefaultRecords', $data);
return $data;
} | php | protected function getDefaultRecords()
{
$data = array(
array(
'ErrorCode' => 404,
'Title' => _t('SilverStripe\\ErrorPage\\ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found'),
'Content' => _t(
'SilverStripe\\ErrorPage\\ErrorPage.DEFAULTERRORPAGECONTENT',
'<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p>'
. '<p>Please check the spelling of the URL you were trying to access and try again.</p>'
)
),
array(
'ErrorCode' => 500,
'Title' => _t('SilverStripe\\ErrorPage\\ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error'),
'Content' => _t(
'SilverStripe\\ErrorPage\\ErrorPage.DEFAULTSERVERERRORPAGECONTENT',
'<p>Sorry, there was a problem with handling your request.</p>'
)
)
);
$this->extend('getDefaultRecords', $data);
return $data;
} | [
"protected",
"function",
"getDefaultRecords",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"array",
"(",
"'ErrorCode'",
"=>",
"404",
",",
"'Title'",
"=>",
"_t",
"(",
"'SilverStripe\\\\ErrorPage\\\\ErrorPage.DEFAULTERRORPAGETITLE'",
",",
"'Page not found'",
")",
",... | Returns an array of arrays, each of which defines properties for a new
ErrorPage record.
@return array | [
"Returns",
"an",
"array",
"of",
"arrays",
"each",
"of",
"which",
"defines",
"properties",
"for",
"a",
"new",
"ErrorPage",
"record",
"."
] | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L194-L219 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.hasStaticPage | protected function hasStaticPage()
{
if (!self::config()->enable_static_file) {
return false;
}
// Attempt to retrieve content from generated file handler
$filename = $this->getErrorFilename();
$storeFilename = File::join_paths(self::config()->store_filepath, $filename);
$result = self::get_asset_handler()->getContent($storeFilename);
return !empty($result);
} | php | protected function hasStaticPage()
{
if (!self::config()->enable_static_file) {
return false;
}
// Attempt to retrieve content from generated file handler
$filename = $this->getErrorFilename();
$storeFilename = File::join_paths(self::config()->store_filepath, $filename);
$result = self::get_asset_handler()->getContent($storeFilename);
return !empty($result);
} | [
"protected",
"function",
"hasStaticPage",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"config",
"(",
")",
"->",
"enable_static_file",
")",
"{",
"return",
"false",
";",
"}",
"// Attempt to retrieve content from generated file handler",
"$",
"filename",
"=",
"$",
... | Determine if static content is cached for this page
@return bool | [
"Determine",
"if",
"static",
"content",
"is",
"cached",
"for",
"this",
"page"
] | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L261-L272 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.writeStaticPage | public function writeStaticPage()
{
if (!self::config()->enable_static_file) {
return false;
}
// Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
$originalThemes = SSViewer::get_themes();
try {
// Restore front-end themes from config
$themes = SSViewer::config()->get('themes') ?: $originalThemes;
SSViewer::set_themes($themes);
// Render page as non-member in live mode
$response = Member::actAs(null, function () {
$response = Director::test(Director::makeRelative($this->getAbsoluteLiveLink()));
return $response;
});
$errorContent = $response->getBody();
} finally {
// Restore themes
SSViewer::set_themes($originalThemes);
}
// Make sure we have content to save
if ($errorContent) {
// Store file content in the default store
$storeFilename = File::join_paths(
self::config()->store_filepath,
$this->getErrorFilename()
);
self::get_asset_handler()->setContent($storeFilename, $errorContent);
return true;
} else {
return false;
}
} | php | public function writeStaticPage()
{
if (!self::config()->enable_static_file) {
return false;
}
// Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
$originalThemes = SSViewer::get_themes();
try {
// Restore front-end themes from config
$themes = SSViewer::config()->get('themes') ?: $originalThemes;
SSViewer::set_themes($themes);
// Render page as non-member in live mode
$response = Member::actAs(null, function () {
$response = Director::test(Director::makeRelative($this->getAbsoluteLiveLink()));
return $response;
});
$errorContent = $response->getBody();
} finally {
// Restore themes
SSViewer::set_themes($originalThemes);
}
// Make sure we have content to save
if ($errorContent) {
// Store file content in the default store
$storeFilename = File::join_paths(
self::config()->store_filepath,
$this->getErrorFilename()
);
self::get_asset_handler()->setContent($storeFilename, $errorContent);
return true;
} else {
return false;
}
} | [
"public",
"function",
"writeStaticPage",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"config",
"(",
")",
"->",
"enable_static_file",
")",
"{",
"return",
"false",
";",
"}",
"// Run the page (reset the theme, it might've been disabled by LeftAndMain::init())",
"$",
"or... | Write out the published version of the page to the filesystem.
@return true if the page write was successful | [
"Write",
"out",
"the",
"published",
"version",
"of",
"the",
"page",
"to",
"the",
"filesystem",
"."
] | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L279-L317 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.get_content_for_errorcode | public static function get_content_for_errorcode($statusCode)
{
if (!self::config()->enable_static_file) {
return null;
}
// Attempt to retrieve content from generated file handler
$filename = self::get_error_filename($statusCode);
$storeFilename = File::join_paths(
self::config()->store_filepath,
$filename
);
return self::get_asset_handler()->getContent($storeFilename);
} | php | public static function get_content_for_errorcode($statusCode)
{
if (!self::config()->enable_static_file) {
return null;
}
// Attempt to retrieve content from generated file handler
$filename = self::get_error_filename($statusCode);
$storeFilename = File::join_paths(
self::config()->store_filepath,
$filename
);
return self::get_asset_handler()->getContent($storeFilename);
} | [
"public",
"static",
"function",
"get_content_for_errorcode",
"(",
"$",
"statusCode",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"config",
"(",
")",
"->",
"enable_static_file",
")",
"{",
"return",
"null",
";",
"}",
"// Attempt to retrieve content from generated file han... | Returns statically cached content for a given error code
@param int $statusCode A HTTP Statuscode, typically 404 or 500
@return string|null | [
"Returns",
"statically",
"cached",
"content",
"for",
"a",
"given",
"error",
"code"
] | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L338-L351 | train |
silverstripe/silverstripe-errorpage | src/ErrorPage.php | ErrorPage.get_error_filename | protected static function get_error_filename($statusCode, $instance = null)
{
if (!$instance) {
$instance = ErrorPage::singleton();
}
// Allow modules to extend this filename (e.g. for multi-domain, translatable)
$name = "error-{$statusCode}.html";
$instance->extend('updateErrorFilename', $name, $statusCode);
return $name;
} | php | protected static function get_error_filename($statusCode, $instance = null)
{
if (!$instance) {
$instance = ErrorPage::singleton();
}
// Allow modules to extend this filename (e.g. for multi-domain, translatable)
$name = "error-{$statusCode}.html";
$instance->extend('updateErrorFilename', $name, $statusCode);
return $name;
} | [
"protected",
"static",
"function",
"get_error_filename",
"(",
"$",
"statusCode",
",",
"$",
"instance",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"instance",
")",
"{",
"$",
"instance",
"=",
"ErrorPage",
"::",
"singleton",
"(",
")",
";",
"}",
"// Allow m... | Gets the filename identifier for the given error code.
Used when handling responses under error conditions.
@param int $statusCode A HTTP Statuscode, typically 404 or 500
@param ErrorPage $instance Optional instance to use for name generation
@return string | [
"Gets",
"the",
"filename",
"identifier",
"for",
"the",
"given",
"error",
"code",
".",
"Used",
"when",
"handling",
"responses",
"under",
"error",
"conditions",
"."
] | 1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c | https://github.com/silverstripe/silverstripe-errorpage/blob/1f25ed3ca1176c49c6113d1496a2f1d2c3d8ee9c/src/ErrorPage.php#L392-L401 | train |
pear/Console_Getopt | Console/Getopt.php | Console_Getopt._parseLongOption | protected static function _parseLongOption($arg, $long_options, &$opts, &$argIdx, $args, $skip_unknown)
{
@list($opt, $opt_arg) = explode('=', $arg, 2);
$opt_len = strlen($opt);
for ($i = 0; $i < count($long_options); $i++) {
$long_opt = $long_options[$i];
$opt_start = substr($long_opt, 0, $opt_len);
$long_opt_name = str_replace('=', '', $long_opt);
/* Option doesn't match. Go on to the next one. */
if ($long_opt_name != $opt) {
continue;
}
$opt_rest = substr($long_opt, $opt_len);
/* Check that the options uniquely matches one of the allowed
options. */
if ($i + 1 < count($long_options)) {
$next_option_rest = substr($long_options[$i + 1], $opt_len);
} else {
$next_option_rest = '';
}
if ($opt_rest != '' && $opt{0} != '=' &&
$i + 1 < count($long_options) &&
$opt == substr($long_options[$i+1], 0, $opt_len) &&
$next_option_rest != '' &&
$next_option_rest{0} != '=') {
$msg = "Console_Getopt: option --$opt is ambiguous";
return PEAR::raiseError($msg);
}
if (substr($long_opt, -1) == '=') {
if (substr($long_opt, -2) != '==') {
/* Long option requires an argument.
Take the next argument if one wasn't specified. */;
if (!strlen($opt_arg)) {
if (!isset($args[++$argIdx])) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
$opt_arg = $args[$argIdx];
}
if (Console_Getopt::_isShortOpt($opt_arg)
|| Console_Getopt::_isLongOpt($opt_arg)) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
}
} else if ($opt_arg) {
$msg = "Console_Getopt: option --$opt doesn't allow an argument";
return PEAR::raiseError($msg);
}
$opts[] = array('--' . $opt, $opt_arg);
return;
}
if ($skip_unknown === true) {
return;
}
return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
} | php | protected static function _parseLongOption($arg, $long_options, &$opts, &$argIdx, $args, $skip_unknown)
{
@list($opt, $opt_arg) = explode('=', $arg, 2);
$opt_len = strlen($opt);
for ($i = 0; $i < count($long_options); $i++) {
$long_opt = $long_options[$i];
$opt_start = substr($long_opt, 0, $opt_len);
$long_opt_name = str_replace('=', '', $long_opt);
/* Option doesn't match. Go on to the next one. */
if ($long_opt_name != $opt) {
continue;
}
$opt_rest = substr($long_opt, $opt_len);
/* Check that the options uniquely matches one of the allowed
options. */
if ($i + 1 < count($long_options)) {
$next_option_rest = substr($long_options[$i + 1], $opt_len);
} else {
$next_option_rest = '';
}
if ($opt_rest != '' && $opt{0} != '=' &&
$i + 1 < count($long_options) &&
$opt == substr($long_options[$i+1], 0, $opt_len) &&
$next_option_rest != '' &&
$next_option_rest{0} != '=') {
$msg = "Console_Getopt: option --$opt is ambiguous";
return PEAR::raiseError($msg);
}
if (substr($long_opt, -1) == '=') {
if (substr($long_opt, -2) != '==') {
/* Long option requires an argument.
Take the next argument if one wasn't specified. */;
if (!strlen($opt_arg)) {
if (!isset($args[++$argIdx])) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
$opt_arg = $args[$argIdx];
}
if (Console_Getopt::_isShortOpt($opt_arg)
|| Console_Getopt::_isLongOpt($opt_arg)) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
}
} else if ($opt_arg) {
$msg = "Console_Getopt: option --$opt doesn't allow an argument";
return PEAR::raiseError($msg);
}
$opts[] = array('--' . $opt, $opt_arg);
return;
}
if ($skip_unknown === true) {
return;
}
return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
} | [
"protected",
"static",
"function",
"_parseLongOption",
"(",
"$",
"arg",
",",
"$",
"long_options",
",",
"&",
"$",
"opts",
",",
"&",
"$",
"argIdx",
",",
"$",
"args",
",",
"$",
"skip_unknown",
")",
"{",
"@",
"list",
"(",
"$",
"opt",
",",
"$",
"opt_arg",... | Parse long option
@param string $arg Argument
@param string[] $long_options Available long options
@param string[][] &$opts
@param int &$argIdx
@param string[] $args
@return void|PEAR_Error | [
"Parse",
"long",
"option"
] | 6c77aeb625b32bd752e89ee17972d103588b90c0 | https://github.com/pear/Console_Getopt/blob/6c77aeb625b32bd752e89ee17972d103588b90c0/Console/Getopt.php#L272-L341 | train |
whitehat101/apr1-md5 | src/APR1_MD5.php | APR1_MD5.salt | public static function salt() {
$alphabet = self::APRMD5_ALPHABET;
$salt = '';
for($i=0; $i<8; $i++) {
$offset = hexdec(bin2hex(openssl_random_pseudo_bytes(1))) % 64;
$salt .= $alphabet[$offset];
}
return $salt;
} | php | public static function salt() {
$alphabet = self::APRMD5_ALPHABET;
$salt = '';
for($i=0; $i<8; $i++) {
$offset = hexdec(bin2hex(openssl_random_pseudo_bytes(1))) % 64;
$salt .= $alphabet[$offset];
}
return $salt;
} | [
"public",
"static",
"function",
"salt",
"(",
")",
"{",
"$",
"alphabet",
"=",
"self",
"::",
"APRMD5_ALPHABET",
";",
"$",
"salt",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"8",
";",
"$",
"i",
"++",
")",
"{",
"$",
"offs... | 8 character salts are the best. Don't encourage anything but the best. | [
"8",
"character",
"salts",
"are",
"the",
"best",
".",
"Don",
"t",
"encourage",
"anything",
"but",
"the",
"best",
"."
] | d555fc829099381e9708362d04e9c3cc99b2142a | https://github.com/whitehat101/apr1-md5/blob/d555fc829099381e9708362d04e9c3cc99b2142a/src/APR1_MD5.php#L53-L61 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/Conference.php | Conference.dial | public function dial($data) {
$envelope = new stdClass();
$envelope->action = "dial";
$envelope->data = $data;
return $this->executeDial($envelope);
} | php | public function dial($data) {
$envelope = new stdClass();
$envelope->action = "dial";
$envelope->data = $data;
return $this->executeDial($envelope);
} | [
"public",
"function",
"dial",
"(",
"$",
"data",
")",
"{",
"$",
"envelope",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"envelope",
"->",
"action",
"=",
"\"dial\"",
";",
"$",
"envelope",
"->",
"data",
"=",
"$",
"data",
";",
"return",
"$",
"this",
"-... | Dial out to endpoints and place answering endpoints in a conference
@param stdClass $data Endpoints' information for dialing | [
"Dial",
"out",
"to",
"endpoints",
"and",
"place",
"answering",
"endpoints",
"in",
"a",
"conference"
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/Conference.php#L14-L20 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/AbstractEntity.php | AbstractEntity.getRaw | public function getRaw($stream = false)
{
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$uri = $this->getURI('/raw');
$x = $this->getSDK()->get($uri, array(), array('accept'=>'audio/*',
'content_type'=>'audio/*', 'Range'=> 'bytes'));
header('Content-Type: '.$x->getHeader('Content-Type')[0]);
header('content-length: '.$x->getHeader('content-length')[0]);
header('Accept-Ranges: '.$x->getHeader('Accept-Ranges')[0]);
if (!$stream) {
header('Content-Disposition: '.$x->getHeader('Content-Disposition')[0]);
}
echo $x->getBody();
} | php | public function getRaw($stream = false)
{
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$uri = $this->getURI('/raw');
$x = $this->getSDK()->get($uri, array(), array('accept'=>'audio/*',
'content_type'=>'audio/*', 'Range'=> 'bytes'));
header('Content-Type: '.$x->getHeader('Content-Type')[0]);
header('content-length: '.$x->getHeader('content-length')[0]);
header('Accept-Ranges: '.$x->getHeader('Accept-Ranges')[0]);
if (!$stream) {
header('Content-Disposition: '.$x->getHeader('Content-Disposition')[0]);
}
echo $x->getBody();
} | [
"public",
"function",
"getRaw",
"(",
"$",
"stream",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
")",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"$",
"uri",
"=",
"$",
"this",
... | downloads or streams a media file
@param boolean $stream Set to true to stream the file
@return binary Media file | [
"downloads",
"or",
"streams",
"a",
"media",
"file"
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/AbstractEntity.php#L163-L178 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/AbstractEntity.php | AbstractEntity.fetch | public function fetch($append_uri = null) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$response = $this->get(array(), $append_uri);
$entity = $response->getData();
$this->setEntity($entity);
return $this;
} | php | public function fetch($append_uri = null) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$response = $this->get(array(), $append_uri);
$entity = $response->getData();
$this->setEntity($entity);
return $this;
} | [
"public",
"function",
"fetch",
"(",
"$",
"append_uri",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
")",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"... | Explicitly fetch from Kazoo, typicall it lazy-loads.
This could also be used to re-load to ensure the data
is fresh. | [
"Explicitly",
"fetch",
"from",
"Kazoo",
"typicall",
"it",
"lazy",
"-",
"loads",
".",
"This",
"could",
"also",
"be",
"used",
"to",
"re",
"-",
"load",
"to",
"ensure",
"the",
"data",
"is",
"fresh",
"."
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/AbstractEntity.php#L186-L195 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/AbstractEntity.php | AbstractEntity.mset | public static function mset($chunk, array $keys, $value) {
$head = $chunk;
$last = count($keys)-1;
foreach($keys as $id => $key) {
if ($last == $id) {
if (is_null($value)) {
unset($chunk->$key);
} else {
$chunk->$key = $value;
}
} else {
$chunk->$key = isset($chunk->$key)? $chunk->$key : new stdClass();
$chunk = $chunk->$key;
}
}
return $head;
} | php | public static function mset($chunk, array $keys, $value) {
$head = $chunk;
$last = count($keys)-1;
foreach($keys as $id => $key) {
if ($last == $id) {
if (is_null($value)) {
unset($chunk->$key);
} else {
$chunk->$key = $value;
}
} else {
$chunk->$key = isset($chunk->$key)? $chunk->$key : new stdClass();
$chunk = $chunk->$key;
}
}
return $head;
} | [
"public",
"static",
"function",
"mset",
"(",
"$",
"chunk",
",",
"array",
"$",
"keys",
",",
"$",
"value",
")",
"{",
"$",
"head",
"=",
"$",
"chunk",
";",
"$",
"last",
"=",
"count",
"(",
"$",
"keys",
")",
"-",
"1",
";",
"foreach",
"(",
"$",
"keys"... | auto-create nodes for this->k1->k2->k3 = v1 | [
"auto",
"-",
"create",
"nodes",
"for",
"this",
"-",
">",
"k1",
"-",
">",
"k2",
"-",
">",
"k3",
"=",
"v1"
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/AbstractEntity.php#L439-L455 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/HttpClient/HttpClient.php | HttpClient.resetHeaders | public function resetHeaders() {
$headers = $this->getSDK()->getOption('headers');
$this->headers = array(
'Accept' => $headers['accept'],
'Content-Type' => $headers['content_type'],
'User-Agent' => $headers['user_agent'],
);
} | php | public function resetHeaders() {
$headers = $this->getSDK()->getOption('headers');
$this->headers = array(
'Accept' => $headers['accept'],
'Content-Type' => $headers['content_type'],
'User-Agent' => $headers['user_agent'],
);
} | [
"public",
"function",
"resetHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getSDK",
"(",
")",
"->",
"getOption",
"(",
"'headers'",
")",
";",
"$",
"this",
"->",
"headers",
"=",
"array",
"(",
"'Accept'",
"=>",
"$",
"headers",
"[",
"'... | Reset headers to the SDK options | [
"Reset",
"headers",
"to",
"the",
"SDK",
"options"
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/HttpClient/HttpClient.php#L124-L131 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/Account.php | Account.createChild | public function createChild($account) {
$id = $this->getId();
$payload = $account->getPayload();
$this->setTokenValue($this->getEntityIdName(), $id);
$response = $this->put($payload);
$entity = $response->getData();
$this->setEntity($entity);
return $this;
} | php | public function createChild($account) {
$id = $this->getId();
$payload = $account->getPayload();
$this->setTokenValue($this->getEntityIdName(), $id);
$response = $this->put($payload);
$entity = $response->getData();
$this->setEntity($entity);
return $this;
} | [
"public",
"function",
"createChild",
"(",
"$",
"account",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"$",
"payload",
"=",
"$",
"account",
"->",
"getPayload",
"(",
")",
";",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"th... | Create a child account of this account. Returns the new Account entity.
@param \Kazoo\Api\Entity\Account $account The account to create below
this account
@return \Kazoo\Api\Entity\Account The new child account after saving | [
"Create",
"a",
"child",
"account",
"of",
"this",
"account",
".",
"Returns",
"the",
"new",
"Account",
"entity",
"."
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/Account.php#L62-L74 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/Device.php | Device.performAction | public function performAction($action, $data = null) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$payload = new \stdClass;
$payload->data = new \stdClass;
$payload->data->action = $action;
$payload->data->data = is_null($data) ? new \stdClass : $data;
$this->put(json_encode($payload));
} | php | public function performAction($action, $data = null) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$payload = new \stdClass;
$payload->data = new \stdClass;
$payload->data->action = $action;
$payload->data->data = is_null($data) ? new \stdClass : $data;
$this->put(json_encode($payload));
} | [
"public",
"function",
"performAction",
"(",
"$",
"action",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
")",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"$",
"... | Perform an action on this device
@param string $action The name of the action to perform
@param stdClass|null $data Optional extra data to control how the action
is performed | [
"Perform",
"an",
"action",
"on",
"this",
"device"
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/Device.php#L14-L23 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/Media.php | Media.postRaw | public function postRaw($path, $mime_type)
{
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$bin = file_get_contents($path);
$b64 = 'data:'.$mime_type.';base64,'.base64_encode($bin);
$uri = $this->getURI('/raw');
$x = $this->getSDK()->post($uri, $b64, array('Content-Type' => 'application/x-base64'));
} | php | public function postRaw($path, $mime_type)
{
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$bin = file_get_contents($path);
$b64 = 'data:'.$mime_type.';base64,'.base64_encode($bin);
$uri = $this->getURI('/raw');
$x = $this->getSDK()->post($uri, $b64, array('Content-Type' => 'application/x-base64'));
} | [
"public",
"function",
"postRaw",
"(",
"$",
"path",
",",
"$",
"mime_type",
")",
"{",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
")",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"$",
"bin",
"=",
"file... | posts media file
@param string $path Local path of media file
@param string $mime_type file mime-type | [
"posts",
"media",
"file"
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/Media.php#L12-L19 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/User.php | User.cdrs | public function cdrs(array $filter = array()) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$collection_name = '\\Kazoo\\Api\\Collection\\Cdrs';
return new $collection_name($this, array($filter));
} | php | public function cdrs(array $filter = array()) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$collection_name = '\\Kazoo\\Api\\Collection\\Cdrs';
return new $collection_name($this, array($filter));
} | [
"public",
"function",
"cdrs",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
")",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"$",
"collect... | Get a collection of CDRs owned by this user. This API comes from cb_cdrs.
@param array $filter Key-value pairs to filter for in the returned
collection.
@param \Kazoo\Api\Collection\Cdrs The filtered collection of CDRs for
this user. | [
"Get",
"a",
"collection",
"of",
"CDRs",
"owned",
"by",
"this",
"user",
".",
"This",
"API",
"comes",
"from",
"cb_cdrs",
"."
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/User.php#L18-L23 | train |
2600hz/kazoo-php-sdk | lib/hz2600/Kazoo/Api/Entity/User.php | User.channels | public function channels(array $filter = array()) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$collection_name = '\\Kazoo\\Api\\Collection\\Channels';
return new $collection_name($this, array($filter));
} | php | public function channels(array $filter = array()) {
$this->setTokenValue($this->getEntityIdName(), $this->getId());
$collection_name = '\\Kazoo\\Api\\Collection\\Channels';
return new $collection_name($this, array($filter));
} | [
"public",
"function",
"channels",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setTokenValue",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
")",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"$",
"col... | Get a collection of channels that are active for this user.
@param array $filter Key-value pairs to filter for in the returned
collection.
@return \Kazoo\Api\Collection\Channels The filtered collection of
channels for this user. | [
"Get",
"a",
"collection",
"of",
"channels",
"that",
"are",
"active",
"for",
"this",
"user",
"."
] | 945217ce4562c87d2663d2a55c8603f77ff37dec | https://github.com/2600hz/kazoo-php-sdk/blob/945217ce4562c87d2663d2a55c8603f77ff37dec/lib/hz2600/Kazoo/Api/Entity/User.php#L34-L39 | train |
ezsystems/ezfind | classes/ezfmodulefunctioncollection.php | ezfModuleFunctionCollection.getFacetParameters | public function getFacetParameters()
{
$facetArray = array();
foreach ( $_GET as $name => $value )
{
if ( strpos( $name, 'facet_' ) === 0 )
{
$facetArray[substr( $name, 6 )] = $value;
}
}
return array( 'result' => array( $facetArray ) );
} | php | public function getFacetParameters()
{
$facetArray = array();
foreach ( $_GET as $name => $value )
{
if ( strpos( $name, 'facet_' ) === 0 )
{
$facetArray[substr( $name, 6 )] = $value;
}
}
return array( 'result' => array( $facetArray ) );
} | [
"public",
"function",
"getFacetParameters",
"(",
")",
"{",
"$",
"facetArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"_GET",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'facet_'",
")",
"=... | Get HTTP get facet parameters
@return array HTTP GET facet parameters, as described in the facets
design document | [
"Get",
"HTTP",
"get",
"facet",
"parameters"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfmodulefunctioncollection.php#L27-L39 | train |
ezsystems/ezfind | classes/extendedattributefilters/ezfindgeodistextendedattributefilter.php | eZFindGeoDistExtendedAttributeFilter.filterQueryParams | public function filterQueryParams( array $queryParams, array $filterParams )
{
try
{
if( !isset( $filterParams['field'] ) )
{
throw new Exception( 'Missing filter parameter "field"' );
}
if( !isset( $filterParams['latitude'] ) )
{
throw new Exception( 'Missing filter parameter "latitude"' );
}
if( !isset( $filterParams['longitude'] ) )
{
throw new Exception( 'Missing filter parameter "longitude"' );
}
$fieldName = eZSolr::getFieldName( $filterParams['field'] );
//geodist custom parameters
$queryParams['sfield'] = $fieldName;
$queryParams['pt'] = $filterParams['latitude'] . ',' . $filterParams['longitude'];
//sort by geodist
$queryParams['sort'] = 'geodist() asc,' . $queryParams['sort'];
//exclude unlocated documents
$queryParams['fq'][] = $fieldName.':[-90,-90 TO 90,90]';
}
catch( Exception $e )
{
eZDebug::writeWarning( $e->getMessage(), __CLASS__ );
}
return $queryParams;
} | php | public function filterQueryParams( array $queryParams, array $filterParams )
{
try
{
if( !isset( $filterParams['field'] ) )
{
throw new Exception( 'Missing filter parameter "field"' );
}
if( !isset( $filterParams['latitude'] ) )
{
throw new Exception( 'Missing filter parameter "latitude"' );
}
if( !isset( $filterParams['longitude'] ) )
{
throw new Exception( 'Missing filter parameter "longitude"' );
}
$fieldName = eZSolr::getFieldName( $filterParams['field'] );
//geodist custom parameters
$queryParams['sfield'] = $fieldName;
$queryParams['pt'] = $filterParams['latitude'] . ',' . $filterParams['longitude'];
//sort by geodist
$queryParams['sort'] = 'geodist() asc,' . $queryParams['sort'];
//exclude unlocated documents
$queryParams['fq'][] = $fieldName.':[-90,-90 TO 90,90]';
}
catch( Exception $e )
{
eZDebug::writeWarning( $e->getMessage(), __CLASS__ );
}
return $queryParams;
} | [
"public",
"function",
"filterQueryParams",
"(",
"array",
"$",
"queryParams",
",",
"array",
"$",
"filterParams",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"filterParams",
"[",
"'field'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",... | Modifies SolR query params according to filter parameters
@param array $queryParams
@param array $filterParams
@return array $queryParams | [
"Modifies",
"SolR",
"query",
"params",
"according",
"to",
"filter",
"parameters"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/extendedattributefilters/ezfindgeodistextendedattributefilter.php#L37-L74 | train |
ezsystems/ezfind | classes/ezsolrbase.php | eZSolrBase.postQuery | protected function postQuery( $request, $postData, $contentType = self::DEFAULT_REQUEST_CONTENTTYPE )
{
$url = $this->SearchServerURI . $request;
return $this->sendHTTPRequestRetry( $url, $postData, $contentType );
} | php | protected function postQuery( $request, $postData, $contentType = self::DEFAULT_REQUEST_CONTENTTYPE )
{
$url = $this->SearchServerURI . $request;
return $this->sendHTTPRequestRetry( $url, $postData, $contentType );
} | [
"protected",
"function",
"postQuery",
"(",
"$",
"request",
",",
"$",
"postData",
",",
"$",
"contentType",
"=",
"self",
"::",
"DEFAULT_REQUEST_CONTENTTYPE",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"SearchServerURI",
".",
"$",
"request",
";",
"return",
... | Send HTTP Post query to the Solr engine
@param string $request request name (examples: /select, /update, ...)
@param string $postData post data
@param string $languageCodes A language code string
@param string $contentType POST content type
@return string Result of HTTP Request ( without HTTP headers ) | [
"Send",
"HTTP",
"Post",
"query",
"to",
"the",
"Solr",
"engine"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrbase.php#L125-L129 | train |
ezsystems/ezfind | classes/ezsolrbase.php | eZSolrBase.validateUpdateResult | static function validateUpdateResult ( $updateResult )
{
if ( empty( $updateResult ) )
{
eZDebug::writeError( 'Empty response received from Solr', 'eZ Find' );
return false;
}
$dom = new DOMDocument( '1.0' );
// Supresses error messages
$status = $dom->loadXML( $updateResult, LIBXML_NOWARNING | LIBXML_NOERROR );
if ( !$status )
{
eZDebug::writeError( 'Invalid XML received from Solr: '.$updateResult, 'eZ Find' );
return false;
}
$intElements = $dom->getElementsByTagName( 'int' );
if ( $intElements->length < 1 )
{
eZDebug::writeError( 'Invalid response from Solr: '.$updateResult, 'eZ Find' );
return false;
}
foreach ( $intElements as $intNode )
{
foreach ( $intNode->attributes as $attribute )
{
if ( ( $attribute->name === 'name' ) and ( $attribute->value === 'status' ) )
{
//Then we have found the correct node
return ( $intNode->nodeValue === "0" );
}
}
}
eZDebug::writeError( 'Invalid response from Solr: '.$updateResult, 'eZ Find' );
return false;
} | php | static function validateUpdateResult ( $updateResult )
{
if ( empty( $updateResult ) )
{
eZDebug::writeError( 'Empty response received from Solr', 'eZ Find' );
return false;
}
$dom = new DOMDocument( '1.0' );
// Supresses error messages
$status = $dom->loadXML( $updateResult, LIBXML_NOWARNING | LIBXML_NOERROR );
if ( !$status )
{
eZDebug::writeError( 'Invalid XML received from Solr: '.$updateResult, 'eZ Find' );
return false;
}
$intElements = $dom->getElementsByTagName( 'int' );
if ( $intElements->length < 1 )
{
eZDebug::writeError( 'Invalid response from Solr: '.$updateResult, 'eZ Find' );
return false;
}
foreach ( $intElements as $intNode )
{
foreach ( $intNode->attributes as $attribute )
{
if ( ( $attribute->name === 'name' ) and ( $attribute->value === 'status' ) )
{
//Then we have found the correct node
return ( $intNode->nodeValue === "0" );
}
}
}
eZDebug::writeError( 'Invalid response from Solr: '.$updateResult, 'eZ Find' );
return false;
} | [
"static",
"function",
"validateUpdateResult",
"(",
"$",
"updateResult",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"updateResult",
")",
")",
"{",
"eZDebug",
"::",
"writeError",
"(",
"'Empty response received from Solr'",
",",
"'eZ Find'",
")",
";",
"return",
"false... | Function to validate the update result returned by solr
A valid solr update reply contains the following document:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">3</int>
</lst>
<strname="WARNING">This response format is experimental. It is likely to change in the future.</str>
</response>
Function will check if solrResult document contains "<int name="status">0</int>" | [
"Function",
"to",
"validate",
"the",
"update",
"result",
"returned",
"by",
"solr"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrbase.php#L254-L292 | train |
ezsystems/ezfind | classes/ezsolrbase.php | eZSolrBase.deleteDocs | function deleteDocs ( $docIDs = array(), $query = false, $commit = true, $optimize = false, $commitWithin = 0 )
{
$postString = '<delete>';
if ( is_numeric( $commitWithin ) && $commitWithin > 0 )
{
$postString = '<delete commitWithin="' . $commitWithin . '">';
}
if ( empty( $query ) )
{
foreach ( $docIDs as $docID )
{
$postString .= '<id>' . $docID . '</id>';
}
}
else
{
$postString .= '<query>' . $query . '</query>';
}
$postString .= '</delete>';
$updateXML = $this->postQuery ( '/update', $postString, 'text/xml' );
if ( $optimize )
{
$this->optimize( $commit );
}
elseif ( $commit )
{
$this->commit();
}
return self::validateUpdateResult( $updateXML );
} | php | function deleteDocs ( $docIDs = array(), $query = false, $commit = true, $optimize = false, $commitWithin = 0 )
{
$postString = '<delete>';
if ( is_numeric( $commitWithin ) && $commitWithin > 0 )
{
$postString = '<delete commitWithin="' . $commitWithin . '">';
}
if ( empty( $query ) )
{
foreach ( $docIDs as $docID )
{
$postString .= '<id>' . $docID . '</id>';
}
}
else
{
$postString .= '<query>' . $query . '</query>';
}
$postString .= '</delete>';
$updateXML = $this->postQuery ( '/update', $postString, 'text/xml' );
if ( $optimize )
{
$this->optimize( $commit );
}
elseif ( $commit )
{
$this->commit();
}
return self::validateUpdateResult( $updateXML );
} | [
"function",
"deleteDocs",
"(",
"$",
"docIDs",
"=",
"array",
"(",
")",
",",
"$",
"query",
"=",
"false",
",",
"$",
"commit",
"=",
"true",
",",
"$",
"optimize",
"=",
"false",
",",
"$",
"commitWithin",
"=",
"0",
")",
"{",
"$",
"postString",
"=",
"'<del... | Removes an array of docID's from the Solr index
@param array $docsID List of document IDs to delete. If set to <empty>,
$query will be used to delete documents instead.
@param string $query Solr Query. This will be ignored if $docIDs is set.
@param bool $optimize set to true to perform a solr optimize after delete
@param integer $commitWithin specifies within how many milliseconds a commit should occur if no other commit
@return bool | [
"Removes",
"an",
"array",
"of",
"docID",
"s",
"from",
"the",
"Solr",
"index"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrbase.php#L354-L386 | train |
ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.fetchConfigurationForObject | public static function fetchConfigurationForObject( $objectID,
$groupByLanguage = true,
$languageCode = null,
$limit = null,
$countOnly = false,
$searchQuery = null )
{
if ( ! is_numeric( $objectID ) )
return null;
$fieldFilters = $custom = null;
$asObject = true;
$results = array();
$sortClause = $groupByLanguage ? array( 'language_code' => 'asc' ) : null;
$conds = array( 'contentobject_id' => $objectID );
if ( $languageCode and $languageCode !== '' )
$conds['language_code'] = array( array( $languageCode, self::WILDCARD ) );
if ( $searchQuery )
{
if ( !is_array( $searchQuery ) and $searchQuery != '' )
{
$conds['search_query'] = $searchQuery;
}
elseif ( array_key_exists( 'searchQuery', $searchQuery ) and $searchQuery['searchQuery'] != '' )
{
$conds['search_query'] = $searchQuery['fuzzy'] === true ? array( 'like', "%{$searchQuery['searchQuery']}%" ) : $searchQuery['searchQuery'];
}
}
if ( $countOnly )
{
return parent::count( self::definition(), $conds );
}
else
{
$rows = parent::fetchObjectList( self::definition(), $fieldFilters, $conds, $sortClause, $limit, $asObject, false, $custom );
foreach ( $rows as $row )
{
if ( $groupByLanguage )
{
$results[$row->attribute( 'language_code' )][] = $row;
}
else
{
$results[] = $row;
}
}
return $results;
}
} | php | public static function fetchConfigurationForObject( $objectID,
$groupByLanguage = true,
$languageCode = null,
$limit = null,
$countOnly = false,
$searchQuery = null )
{
if ( ! is_numeric( $objectID ) )
return null;
$fieldFilters = $custom = null;
$asObject = true;
$results = array();
$sortClause = $groupByLanguage ? array( 'language_code' => 'asc' ) : null;
$conds = array( 'contentobject_id' => $objectID );
if ( $languageCode and $languageCode !== '' )
$conds['language_code'] = array( array( $languageCode, self::WILDCARD ) );
if ( $searchQuery )
{
if ( !is_array( $searchQuery ) and $searchQuery != '' )
{
$conds['search_query'] = $searchQuery;
}
elseif ( array_key_exists( 'searchQuery', $searchQuery ) and $searchQuery['searchQuery'] != '' )
{
$conds['search_query'] = $searchQuery['fuzzy'] === true ? array( 'like', "%{$searchQuery['searchQuery']}%" ) : $searchQuery['searchQuery'];
}
}
if ( $countOnly )
{
return parent::count( self::definition(), $conds );
}
else
{
$rows = parent::fetchObjectList( self::definition(), $fieldFilters, $conds, $sortClause, $limit, $asObject, false, $custom );
foreach ( $rows as $row )
{
if ( $groupByLanguage )
{
$results[$row->attribute( 'language_code' )][] = $row;
}
else
{
$results[] = $row;
}
}
return $results;
}
} | [
"public",
"static",
"function",
"fetchConfigurationForObject",
"(",
"$",
"objectID",
",",
"$",
"groupByLanguage",
"=",
"true",
",",
"$",
"languageCode",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"countOnly",
"=",
"false",
",",
"$",
"searchQuery"... | Retrieves the elevate configuration for a given content object, possibly per language.
@param int $objectID ID of the content object to fetch elevate configuration for
@param boolean $groupByLanguage Group results per language. If true, the return value will look like the following :
<code>
array( 'eng-GB' => array( ( eZFindElevateConfiguration ) $conf1,
( eZFindElevateConfiguration ) $conf2 ),
'fre-FR' => array( ( eZFindElevateConfiguration ) $conf3 ),
'*' => array( ( eZFindElevateConfiguration ) $conf4 ),
( eZFindElevateConfiguration ) $conf5
)
</code>
@param string $languageCode if filtering on language-code is required
@param array $limit Associative array containing the 'offset' and 'limit' keys, with integers as values, framing the result set. Example :
<code>
array( 'offset' => 0,
'limit' => 10 )
</code>
@param boolean $countOnly If only the count of matching results is needed
@param mixed $searchQuery Can be a string containing the search_query to filter on.
Can also be an array looking like the following, supporting fuzzy search optionnally.
<code>
array( 'searchQuery' => ( string ) 'foo bar',
'fuzzy' => ( boolean ) true )
</code>
@return mixed An array containing the eZFindElevateConfiguration objects, optionnally sorted by language code, null if error. | [
"Retrieves",
"the",
"elevate",
"configuration",
"for",
"a",
"given",
"content",
"object",
"possibly",
"per",
"language",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L136-L187 | train |
ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.fetchObjectsForQueryString | public static function fetchObjectsForQueryString( $queryString, $groupByLanguage = true, $languageCode = null, $limit = null, $countOnly = false )
{
if ( ( is_string( $queryString ) and $queryString === '' ) or
( is_array( $queryString ) and array_key_exists( 'searchQuery', $queryString ) and $queryString['searchQuery'] == '' )
)
{
return null;
}
$fieldFilters = $custom = null;
$objects = array();
$conds = array();
$sortClause = $groupByLanguage ? array( 'language_code' => 'asc' ) : null;
if ( !is_array( $queryString ) )
{
$conds['search_query'] = $queryString;
}
else
{
$conds['search_query'] = @$queryString['fuzzy'] === true ? array( 'like', "%{$queryString['searchQuery']}%" ) : $queryString['searchQuery'];
}
if ( $languageCode and $languageCode !== '' )
$conds['language_code'] = array( array( $languageCode, self::WILDCARD ) );
if ( $countOnly )
{
return parent::count( self::definition(), $conds );
}
else
{
$rows = parent::fetchObjectList( self::definition(), $fieldFilters, $conds, $sortClause, $limit, false, false, $custom );
foreach ( $rows as $row )
{
if ( ( $obj = eZContentObject::fetch( $row['contentobject_id'] ) ) !== null )
{
if ( $groupByLanguage )
{
$objects[$row['language_code']][] = $obj;
}
else
{
$objects[] = $obj;
}
}
}
return $objects;
}
} | php | public static function fetchObjectsForQueryString( $queryString, $groupByLanguage = true, $languageCode = null, $limit = null, $countOnly = false )
{
if ( ( is_string( $queryString ) and $queryString === '' ) or
( is_array( $queryString ) and array_key_exists( 'searchQuery', $queryString ) and $queryString['searchQuery'] == '' )
)
{
return null;
}
$fieldFilters = $custom = null;
$objects = array();
$conds = array();
$sortClause = $groupByLanguage ? array( 'language_code' => 'asc' ) : null;
if ( !is_array( $queryString ) )
{
$conds['search_query'] = $queryString;
}
else
{
$conds['search_query'] = @$queryString['fuzzy'] === true ? array( 'like', "%{$queryString['searchQuery']}%" ) : $queryString['searchQuery'];
}
if ( $languageCode and $languageCode !== '' )
$conds['language_code'] = array( array( $languageCode, self::WILDCARD ) );
if ( $countOnly )
{
return parent::count( self::definition(), $conds );
}
else
{
$rows = parent::fetchObjectList( self::definition(), $fieldFilters, $conds, $sortClause, $limit, false, false, $custom );
foreach ( $rows as $row )
{
if ( ( $obj = eZContentObject::fetch( $row['contentobject_id'] ) ) !== null )
{
if ( $groupByLanguage )
{
$objects[$row['language_code']][] = $obj;
}
else
{
$objects[] = $obj;
}
}
}
return $objects;
}
} | [
"public",
"static",
"function",
"fetchObjectsForQueryString",
"(",
"$",
"queryString",
",",
"$",
"groupByLanguage",
"=",
"true",
",",
"$",
"languageCode",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"countOnly",
"=",
"false",
")",
"{",
"if",
"("... | Retrieves the content objects elevated by a given query string, possibly per language.
@param mixed $searchQuery Can be a string containing the search_query to filter on.
Can also be an array looking like the following, supporting fuzzy search optionnally.
<code>
array( 'searchQuery' => ( string ) 'foo bar',
'fuzzy' => ( boolean ) true )
</code>
@param string $languageCode if filtering on language-code is required
@param array $limit Associative array containing the 'offset' and 'limit' keys, with integers as values, framing the result set. Example :
<code>
array( 'offset' => 0,
'limit' => 10 )
</code>
@param boolean $countOnly If only the count of matching results is needed
@return mixed An array containing the content objects elevated by the query string, optionnally sorted by language code, null if error. If $countOnly is true,
only the result count is returned. | [
"Retrieves",
"the",
"content",
"objects",
"elevated",
"by",
"a",
"given",
"query",
"string",
"possibly",
"per",
"language",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L210-L259 | train |
ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.add | public static function add( $queryString, $objectID, $languageCode = self::WILDCARD )
{
$db = eZDB::instance();
$queryString = $db->escapeString( $queryString );
if ( $languageCode === self::WILDCARD )
{
self::purge( $queryString, $objectID );
}
else
{
// trying to insert an elevate configuration row for a specific language, while one already exists for all languages.
if ( parent::fetchObject( self::definition(), null, array( 'contentobject_id' => $objectID, 'search_query' => $queryString, 'language_code' => self::WILDCARD ) ) )
return null;
}
$row = array( 'search_query' => $queryString,
'contentobject_id' => $objectID,
'language_code' => $languageCode );
$conf = new eZFindElevateConfiguration( $row );
$conf->store();
return $conf;
} | php | public static function add( $queryString, $objectID, $languageCode = self::WILDCARD )
{
$db = eZDB::instance();
$queryString = $db->escapeString( $queryString );
if ( $languageCode === self::WILDCARD )
{
self::purge( $queryString, $objectID );
}
else
{
// trying to insert an elevate configuration row for a specific language, while one already exists for all languages.
if ( parent::fetchObject( self::definition(), null, array( 'contentobject_id' => $objectID, 'search_query' => $queryString, 'language_code' => self::WILDCARD ) ) )
return null;
}
$row = array( 'search_query' => $queryString,
'contentobject_id' => $objectID,
'language_code' => $languageCode );
$conf = new eZFindElevateConfiguration( $row );
$conf->store();
return $conf;
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"queryString",
",",
"$",
"objectID",
",",
"$",
"languageCode",
"=",
"self",
"::",
"WILDCARD",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"queryString",
"=",
"$",
"db",
"->"... | Adds an elevate configuration row, optionnally for a given language.
@param string $queryString Query string for which elevate configuration is added
@param int $objectID Content object for which the elevate configuration is added
@param string $languageCode Language code for which the elevate configuration is added. Defaults to 'all languages' | [
"Adds",
"an",
"elevate",
"configuration",
"row",
"optionnally",
"for",
"a",
"given",
"language",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L269-L292 | train |
ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.purge | public static function purge( $queryString = '' , $objectID = null, $languageCode = null )
{
// check that some conditions were passed
if ( $queryString === '' and $objectID === null and $languageCode === null )
return false;
if ( $queryString !== '' )
$conds['search_query'] = $queryString;
if ( $objectID !== null )
$conds['contentobject_id'] = $objectID;
if ( $languageCode !== null )
$conds['language_code'] = $languageCode;
return parent::removeObject( self::definition(), $conds );
} | php | public static function purge( $queryString = '' , $objectID = null, $languageCode = null )
{
// check that some conditions were passed
if ( $queryString === '' and $objectID === null and $languageCode === null )
return false;
if ( $queryString !== '' )
$conds['search_query'] = $queryString;
if ( $objectID !== null )
$conds['contentobject_id'] = $objectID;
if ( $languageCode !== null )
$conds['language_code'] = $languageCode;
return parent::removeObject( self::definition(), $conds );
} | [
"public",
"static",
"function",
"purge",
"(",
"$",
"queryString",
"=",
"''",
",",
"$",
"objectID",
"=",
"null",
",",
"$",
"languageCode",
"=",
"null",
")",
"{",
"// check that some conditions were passed",
"if",
"(",
"$",
"queryString",
"===",
"''",
"and",
"... | Purges the configuration rows for a given query string, a given object, or both.
@param string $queryString Query string for which elevate configuration is removed
@param int $objectID Content object for which the elevate configuration is removed
@param string $languageCode Language code for which the elevate configuration is removed. Defaults to 'all languages' | [
"Purges",
"the",
"configuration",
"rows",
"for",
"a",
"given",
"query",
"string",
"a",
"given",
"object",
"or",
"both",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L301-L317 | train |
ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.synchronizeWithSolr | public static function synchronizeWithSolr( $shard = null )
{
if ( self::generateConfiguration() )
{
try
{
self::pushConfigurationToSolr( $shard );
}
catch ( Exception $e )
{
self::$lastSynchronizationError = $e->getMessage();
eZDebug::writeError( self::$lastSynchronizationError, __METHOD__ );
return false;
}
}
else
{
$message = ezpI18n::tr( 'extension/ezfind/elevate', "Error while generating the configuration XML" );
self::$lastSynchronizationError = $message;
eZDebug::writeError( $message, __METHOD__ );
return false;
}
return true;
} | php | public static function synchronizeWithSolr( $shard = null )
{
if ( self::generateConfiguration() )
{
try
{
self::pushConfigurationToSolr( $shard );
}
catch ( Exception $e )
{
self::$lastSynchronizationError = $e->getMessage();
eZDebug::writeError( self::$lastSynchronizationError, __METHOD__ );
return false;
}
}
else
{
$message = ezpI18n::tr( 'extension/ezfind/elevate', "Error while generating the configuration XML" );
self::$lastSynchronizationError = $message;
eZDebug::writeError( $message, __METHOD__ );
return false;
}
return true;
} | [
"public",
"static",
"function",
"synchronizeWithSolr",
"(",
"$",
"shard",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"generateConfiguration",
"(",
")",
")",
"{",
"try",
"{",
"self",
"::",
"pushConfigurationToSolr",
"(",
"$",
"shard",
")",
";",
"}",
... | Synchronizes the elevate configuration stored in the DB
with the one actually used by Solr.
@return boolean true if the whole operation passed, false otherwise. | [
"Synchronizes",
"the",
"elevate",
"configuration",
"stored",
"in",
"the",
"DB",
"with",
"the",
"one",
"actually",
"used",
"by",
"Solr",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L325-L348 | train |
ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.getRuntimeQueryParameters | public static function getRuntimeQueryParameters( $forceElevation = false, $enableElevation = true, $searchText = '' )
{
$retArray = array( 'forceElevation' => 'false',
'enableElevation' => 'true' );
if ( $enableElevation === false or $searchText == '' )
{
$retArray['enableElevation'] = 'false';
return $retArray;
}
if ( $forceElevation === true )
{
$retArray['forceElevation'] = 'true';
}
return $retArray;
} | php | public static function getRuntimeQueryParameters( $forceElevation = false, $enableElevation = true, $searchText = '' )
{
$retArray = array( 'forceElevation' => 'false',
'enableElevation' => 'true' );
if ( $enableElevation === false or $searchText == '' )
{
$retArray['enableElevation'] = 'false';
return $retArray;
}
if ( $forceElevation === true )
{
$retArray['forceElevation'] = 'true';
}
return $retArray;
} | [
"public",
"static",
"function",
"getRuntimeQueryParameters",
"(",
"$",
"forceElevation",
"=",
"false",
",",
"$",
"enableElevation",
"=",
"true",
",",
"$",
"searchText",
"=",
"''",
")",
"{",
"$",
"retArray",
"=",
"array",
"(",
"'forceElevation'",
"=>",
"'false'... | Generates a well-formed array of elevate-related query parameters.
@param boolean $forceElevation Whether elevation should be forced or not. Parameter supported at runtime from Solr@rev:735117
Should be used when a sort array other than the default one ( 'score desc' ) is passed in the query parameters,
if one wants the elevate configuration to be actually taken into account.
@param boolean $enableElevation Whether the Elevate functionnality should be used or not. Defaults to 'true'.
@param string $searchText Workaround for an issue in Solr's QueryElevationComponent : when the search string is empty, Solr throws
an Exception and stops the request.
@return array The well-formed query parameter regarding the elevate functionnality. Example :
<code>
array( 'forceElevation' => 'true',
'enableElevation' => 'true' )
</code> | [
"Generates",
"a",
"well",
"-",
"formed",
"array",
"of",
"elevate",
"-",
"related",
"query",
"parameters",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L488-L505 | train |
ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.quoteIfNeeded | static function quoteIfNeeded( $value )
{
$quote = '';
if ( strpos( $value, ' ' ) !== false )
{
$quote = '"';
if ( strpos( trim( $value ), '(' ) === 0 )
{
$quote = '';
}
}
return $quote . $value . $quote;
} | php | static function quoteIfNeeded( $value )
{
$quote = '';
if ( strpos( $value, ' ' ) !== false )
{
$quote = '"';
if ( strpos( trim( $value ), '(' ) === 0 )
{
$quote = '';
}
}
return $quote . $value . $quote;
} | [
"static",
"function",
"quoteIfNeeded",
"(",
"$",
"value",
")",
"{",
"$",
"quote",
"=",
"''",
";",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"$",
"quote",
"=",
"'\"'",
";",
"if",
"(",
"strpos",
"(",
"trim",... | Analyze the string, and decide if quotes should be added or not.
@param string String
@return string String with quotes added if needed.
@deprecated | [
"Analyze",
"the",
"string",
"and",
"decide",
"if",
"quotes",
"should",
"be",
"added",
"or",
"not",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1084-L1096 | train |
ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.fieldTypeExludeList | protected function fieldTypeExludeList( $searchText )
{
if ( is_null( $searchText ) )
{
return array( 'date', 'boolean', 'int', 'long', 'float', 'double', 'sint', 'slong', 'sfloat', 'sdouble' );
}
$excludeFieldList = array();
// Check if search text is a date.
if ( strtotime( $searchText ) === false )
{
$excludeFieldList[] = 'date';
}
if ( strtolower( $searchText ) !== 'true' &&
strtolower( $searchText ) !== 'false' )
{
$excludeFieldList[] = 'boolean';
}
if ( !is_numeric( $searchText ) )
{
$excludeFieldList[] = 'int';
$excludeFieldList[] = 'long';
$excludeFieldList[] = 'float';
$excludeFieldList[] = 'double';
$excludeFieldList[] = 'sint';
$excludeFieldList[] = 'slong';
$excludeFieldList[] = 'sfloat';
$excludeFieldList[] = 'sdouble';
}
return $excludeFieldList;
} | php | protected function fieldTypeExludeList( $searchText )
{
if ( is_null( $searchText ) )
{
return array( 'date', 'boolean', 'int', 'long', 'float', 'double', 'sint', 'slong', 'sfloat', 'sdouble' );
}
$excludeFieldList = array();
// Check if search text is a date.
if ( strtotime( $searchText ) === false )
{
$excludeFieldList[] = 'date';
}
if ( strtolower( $searchText ) !== 'true' &&
strtolower( $searchText ) !== 'false' )
{
$excludeFieldList[] = 'boolean';
}
if ( !is_numeric( $searchText ) )
{
$excludeFieldList[] = 'int';
$excludeFieldList[] = 'long';
$excludeFieldList[] = 'float';
$excludeFieldList[] = 'double';
$excludeFieldList[] = 'sint';
$excludeFieldList[] = 'slong';
$excludeFieldList[] = 'sfloat';
$excludeFieldList[] = 'sdouble';
}
return $excludeFieldList;
} | [
"protected",
"function",
"fieldTypeExludeList",
"(",
"$",
"searchText",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"searchText",
")",
")",
"{",
"return",
"array",
"(",
"'date'",
",",
"'boolean'",
",",
"'int'",
",",
"'long'",
",",
"'float'",
",",
"'double'",... | Check if search string requires certain field types to be excluded from the search
@param string Search string
If null, exclude all non text fields
@todo make sure this function is in sync with schema.xml
@todo decide wether or not to drop this, pure numeric and date values are
most likely to go into filters, not the main query
@return array List of field types to exclude from the search | [
"Check",
"if",
"search",
"string",
"requires",
"certain",
"field",
"types",
"to",
"be",
"excluded",
"from",
"the",
"search"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1411-L1442 | train |
ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.getContentClassFilterQuery | protected function getContentClassFilterQuery( $contentClassIdent )
{
if ( empty( $contentClassIdent ) )
{
return null;
}
if ( is_array( $contentClassIdent ) )
{
$classQueryParts = array();
foreach ( $contentClassIdent as $classID )
{
$classID = trim( $classID );
if ( empty( $classID ) )
{
continue;
}
if ( (int)$classID . '' == $classID . '' )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $classID;
}
elseif ( is_string( $classID ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $classID ) )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
else
{
eZDebug::writeError( "Unknown class_id filtering parameter: $classID", __METHOD__ );
}
}
return implode( ' OR ', $classQueryParts );
}
elseif ( (int)$contentClassIdent . '' == $contentClassIdent . '' )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $contentClassIdent;
}
elseif ( is_string( $contentClassIdent ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $contentClassIdent ) )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
eZDebug::writeError( 'No valid content class', __METHOD__ );
return null;
} | php | protected function getContentClassFilterQuery( $contentClassIdent )
{
if ( empty( $contentClassIdent ) )
{
return null;
}
if ( is_array( $contentClassIdent ) )
{
$classQueryParts = array();
foreach ( $contentClassIdent as $classID )
{
$classID = trim( $classID );
if ( empty( $classID ) )
{
continue;
}
if ( (int)$classID . '' == $classID . '' )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $classID;
}
elseif ( is_string( $classID ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $classID ) )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
else
{
eZDebug::writeError( "Unknown class_id filtering parameter: $classID", __METHOD__ );
}
}
return implode( ' OR ', $classQueryParts );
}
elseif ( (int)$contentClassIdent . '' == $contentClassIdent . '' )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $contentClassIdent;
}
elseif ( is_string( $contentClassIdent ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $contentClassIdent ) )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
eZDebug::writeError( 'No valid content class', __METHOD__ );
return null;
} | [
"protected",
"function",
"getContentClassFilterQuery",
"(",
"$",
"contentClassIdent",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"contentClassIdent",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"contentClassIdent",
")",
")",
"{",... | Generate class query filter.
@param mixed $contentClassIdent eZContentClass id, identifier or list of ids.
@return string Content class query filter. Returns null if invalid
$contentClassIdent is provided. | [
"Generate",
"class",
"query",
"filter",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1480-L1531 | train |
ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.getSectionFilterQuery | protected function getSectionFilterQuery( $sectionIdent )
{
if ( empty( $sectionIdent ) )
{
return null;
}
if ( is_array( $sectionIdent ) )
{
$sectionQueryParts = array();
foreach ( $sectionIdent as $sectionID )
{
$sectionID = trim( $sectionID );
if ( ctype_digit( $sectionID ) )
{
$sectionQueryParts[] = eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionID;
}
else
{
eZDebug::writeError( "Unknown section_id filtering parameter: $sectionID", __METHOD__ );
}
}
return implode( ' OR ', $sectionQueryParts );
}
$sectionIdent = trim( $sectionIdent );
if ( ctype_digit( $sectionIdent ) )
{
return eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionIdent;
}
eZDebug::writeError( 'No valid section id', __METHOD__ );
return null;
} | php | protected function getSectionFilterQuery( $sectionIdent )
{
if ( empty( $sectionIdent ) )
{
return null;
}
if ( is_array( $sectionIdent ) )
{
$sectionQueryParts = array();
foreach ( $sectionIdent as $sectionID )
{
$sectionID = trim( $sectionID );
if ( ctype_digit( $sectionID ) )
{
$sectionQueryParts[] = eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionID;
}
else
{
eZDebug::writeError( "Unknown section_id filtering parameter: $sectionID", __METHOD__ );
}
}
return implode( ' OR ', $sectionQueryParts );
}
$sectionIdent = trim( $sectionIdent );
if ( ctype_digit( $sectionIdent ) )
{
return eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionIdent;
}
eZDebug::writeError( 'No valid section id', __METHOD__ );
return null;
} | [
"protected",
"function",
"getSectionFilterQuery",
"(",
"$",
"sectionIdent",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sectionIdent",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"sectionIdent",
")",
")",
"{",
"$",
"sectionQu... | Generate section query filter.
@param mixed $sectionIdent eZSection id or list of ids.
@return string Section query filter. Returns null if invalid
$sectionIdent is provided. | [
"Generate",
"section",
"query",
"filter",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1541-L1576 | train |
ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.getClassAttributes | protected function getClassAttributes( $classIDArray = false,
$classAttributeIDArray = false,
$fieldTypeExcludeList = null )
{
eZDebug::createAccumulator( 'Class attribute list', 'eZ Find' );
eZDebug::accumulatorStart( 'Class attribute list' );
$fieldArray = array();
$classAttributeArray = array();
// classAttributeIDArray = simple integer (content class attribute ID)
if ( is_numeric( $classAttributeIDArray ) and $classAttributeIDArray > 0 )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeIDArray );
}
// classAttributeIDArray = array of integers (content class attribute IDs)
else if ( is_array( $classAttributeIDArray ) )
{
foreach ( $classAttributeIDArray as $classAttributeID )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeID );
}
}
// no class attribute list given, we need a class list
// this block will create the class attribute array based on $classIDArray
if ( empty( $classAttributeArray ) )
{
// Fetch class list.
$condArray = array( "is_searchable" => 1,
"version" => eZContentClass::VERSION_STATUS_DEFINED );
if ( !$classIDArray )
{
$classIDArray = array();
}
else if ( !is_array( $classIDArray ) )
{
$classIDArray = array( $classIDArray );
}
// literal class identifiers are converted to numerical ones
$tmpClassIDArray = $classIDArray;
$classIDArray = array();
foreach ( $tmpClassIDArray as $key => $classIdentifier )
{
if ( !is_numeric( $classIdentifier ) )
{
if ( !$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier, false ) )
{
eZDebug::writeWarning( "Unknown content class identifier '$classIdentifier'", __METHOD__ );
}
else
{
$classIDArray[] = $contentClass['id'];
}
}
else
{
$classIDArray[] = $classIdentifier;
}
}
if ( !empty( $classIDArray ) )
{
$condArray['contentclass_id'] = array( $classIDArray );
}
$classAttributeArray = eZContentClassAttribute::fetchFilteredList( $condArray );
}
// $classAttributeArray now contains a list of eZContentClassAttribute
// we can use to construct the list of fields solr should search in
// @TODO : retrieve sub attributes here. Mind the types !
foreach ( $classAttributeArray as $classAttribute )
{
$fieldArray = array_merge( ezfSolrDocumentFieldBase::getFieldNameList( $classAttribute, $fieldTypeExcludeList ), $fieldArray );
}
// the array is unified + sorted in order to make it consistent
$fieldArray = array_unique( $fieldArray );
sort( $fieldArray );
eZDebug::accumulatorStop( 'Class attribute list' );
return $fieldArray;
} | php | protected function getClassAttributes( $classIDArray = false,
$classAttributeIDArray = false,
$fieldTypeExcludeList = null )
{
eZDebug::createAccumulator( 'Class attribute list', 'eZ Find' );
eZDebug::accumulatorStart( 'Class attribute list' );
$fieldArray = array();
$classAttributeArray = array();
// classAttributeIDArray = simple integer (content class attribute ID)
if ( is_numeric( $classAttributeIDArray ) and $classAttributeIDArray > 0 )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeIDArray );
}
// classAttributeIDArray = array of integers (content class attribute IDs)
else if ( is_array( $classAttributeIDArray ) )
{
foreach ( $classAttributeIDArray as $classAttributeID )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeID );
}
}
// no class attribute list given, we need a class list
// this block will create the class attribute array based on $classIDArray
if ( empty( $classAttributeArray ) )
{
// Fetch class list.
$condArray = array( "is_searchable" => 1,
"version" => eZContentClass::VERSION_STATUS_DEFINED );
if ( !$classIDArray )
{
$classIDArray = array();
}
else if ( !is_array( $classIDArray ) )
{
$classIDArray = array( $classIDArray );
}
// literal class identifiers are converted to numerical ones
$tmpClassIDArray = $classIDArray;
$classIDArray = array();
foreach ( $tmpClassIDArray as $key => $classIdentifier )
{
if ( !is_numeric( $classIdentifier ) )
{
if ( !$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier, false ) )
{
eZDebug::writeWarning( "Unknown content class identifier '$classIdentifier'", __METHOD__ );
}
else
{
$classIDArray[] = $contentClass['id'];
}
}
else
{
$classIDArray[] = $classIdentifier;
}
}
if ( !empty( $classIDArray ) )
{
$condArray['contentclass_id'] = array( $classIDArray );
}
$classAttributeArray = eZContentClassAttribute::fetchFilteredList( $condArray );
}
// $classAttributeArray now contains a list of eZContentClassAttribute
// we can use to construct the list of fields solr should search in
// @TODO : retrieve sub attributes here. Mind the types !
foreach ( $classAttributeArray as $classAttribute )
{
$fieldArray = array_merge( ezfSolrDocumentFieldBase::getFieldNameList( $classAttribute, $fieldTypeExcludeList ), $fieldArray );
}
// the array is unified + sorted in order to make it consistent
$fieldArray = array_unique( $fieldArray );
sort( $fieldArray );
eZDebug::accumulatorStop( 'Class attribute list' );
return $fieldArray;
} | [
"protected",
"function",
"getClassAttributes",
"(",
"$",
"classIDArray",
"=",
"false",
",",
"$",
"classAttributeIDArray",
"=",
"false",
",",
"$",
"fieldTypeExcludeList",
"=",
"null",
")",
"{",
"eZDebug",
"::",
"createAccumulator",
"(",
"'Class attribute list'",
",",... | Get an array of class attribute identifiers based on either a class attribute
list, or a content classes list
@param array $classIDArray
Classes to search in. Either an array of class ID, class identifiers,
a class ID or a class identifier.
Using numerical attribute/class identifiers for $classIDArray is more efficient.
@param array $classAttributeID
Class attributes to search in. Either an array of class attribute id,
or a single class attribute. Literal identifiers are not allowed.
@param array $fieldTypeExcludeList
filter list. List of field types to exclude. ( set to empty array by default ).
@return array List of solr field names. | [
"Get",
"an",
"array",
"of",
"class",
"attribute",
"identifiers",
"based",
"on",
"either",
"a",
"class",
"attribute",
"list",
"or",
"a",
"content",
"classes",
"list"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1801-L1884 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getData | public function getData()
{
$contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldNameArray = array();
foreach ( array_keys( eZSolr::$fieldTypeContexts ) as $context )
{
$fieldNameArray[] = self::getFieldName( $contentClassAttribute, null, $context );
}
$fieldNameArray = array_unique( $fieldNameArray );
$metaData = $this->ContentObjectAttribute->metaData();
$processedMetaDataArray = array();
if ( is_array( $metaData ) )
{
$processedMetaDataArray = array();
foreach ( $metaData as $value )
{
$processedMetaDataArray[] = $this->preProcessValue( $value,
self::getClassAttributeType( $contentClassAttribute ) );
}
}
else
{
$processedMetaDataArray[] = $this->preProcessValue( $metaData,
self::getClassAttributeType( $contentClassAttribute ) );
}
$fields = array();
foreach ( $fieldNameArray as $fieldName )
{
$fields[$fieldName] = $processedMetaDataArray ;
}
return $fields;
} | php | public function getData()
{
$contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldNameArray = array();
foreach ( array_keys( eZSolr::$fieldTypeContexts ) as $context )
{
$fieldNameArray[] = self::getFieldName( $contentClassAttribute, null, $context );
}
$fieldNameArray = array_unique( $fieldNameArray );
$metaData = $this->ContentObjectAttribute->metaData();
$processedMetaDataArray = array();
if ( is_array( $metaData ) )
{
$processedMetaDataArray = array();
foreach ( $metaData as $value )
{
$processedMetaDataArray[] = $this->preProcessValue( $value,
self::getClassAttributeType( $contentClassAttribute ) );
}
}
else
{
$processedMetaDataArray[] = $this->preProcessValue( $metaData,
self::getClassAttributeType( $contentClassAttribute ) );
}
$fields = array();
foreach ( $fieldNameArray as $fieldName )
{
$fields[$fieldName] = $processedMetaDataArray ;
}
return $fields;
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"contentClassAttribute",
"=",
"$",
"this",
"->",
"ContentObjectAttribute",
"->",
"attribute",
"(",
"'contentclass_attribute'",
")",
";",
"$",
"fieldNameArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"a... | Get data to index, and field name to use.
@since ez find 2.2: indexed values to be context aware
different fields may be used for searching, sorting and faceting
@return array Associative array with field name and field value.
Field value can be an array.
Example 1:
<code>
array( 'field_name_i' => 123 );
</code>
Example 2:
<code>
array( 'field_name_i' => array( "1", 2, '3' ) );
</code> | [
"Get",
"data",
"to",
"index",
"and",
"field",
"name",
"to",
"use",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L54-L90 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getClassAttributeType | static function getClassAttributeType( eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search' )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
// Subattribute-related behaviour here.
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getClassAttributeType' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getClassAttributeType' ),
array( $classAttribute, $subAttribute, $context ) ) )
)
{
return $returnValue;
}
}
// Fallback #1: single-fielded datatype behaviour here.
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', eZSolr::$fieldTypeContexts[$context] );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #2: search field datatypemap (pre ezfind 2.2 behaviour)
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'DatatypeMap' );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #3: return default field.
return $eZFindIni->variable( 'SolrFieldMapSettings', 'Default' );
} | php | static function getClassAttributeType( eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search' )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
// Subattribute-related behaviour here.
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getClassAttributeType' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getClassAttributeType' ),
array( $classAttribute, $subAttribute, $context ) ) )
)
{
return $returnValue;
}
}
// Fallback #1: single-fielded datatype behaviour here.
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', eZSolr::$fieldTypeContexts[$context] );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #2: search field datatypemap (pre ezfind 2.2 behaviour)
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'DatatypeMap' );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #3: return default field.
return $eZFindIni->variable( 'SolrFieldMapSettings', 'Default' );
} | [
"static",
"function",
"getClassAttributeType",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"subAttribute",
"=",
"null",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"eZFindIni",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")... | Get Solr schema field type from eZContentClassAttribute.
Available field types are:
- string - Unprocessed text
- boolean - Boolean
- int - Integer, not sortable
- long - Long, not sortable
- float - Float, not sortable
- double - Double, not sortable
- sint - Integer, sortable
- slong - Long, sortable
- sfloat - Float, sortable
- sdouble - Double, sortable
- date - Date, see also: http://www.w3.org/TR/xmlschema-2/#dateTime
- text - Text, processed and allows fuzzy matches.
- textTight - Text, less filters are applied than for the text datatype.
@see ezfSolrDocumentFieldName::$FieldTypeMap
@param eZContentClassAttribute Instance of eZContentClassAttribute.
@param $subAttribute string In case the type of a datatype's sub-attribute is requested,
the subattribute's name is passed here.
@return string Field type. Null if no field type is defined. | [
"Get",
"Solr",
"schema",
"field",
"type",
"from",
"eZContentClassAttribute",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L172-L204 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getFieldNameList | public static function getFieldNameList( eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array() )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getFieldNameList' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getFieldNameList' ),
array( $classAttribute, $exclusiveTypeFilter ) ) )
)
{
return $returnValue;
}
}
// fallback behaviour :
if ( empty( $exclusiveTypeFilter ) or !in_array( self::getClassAttributeType( $classAttribute ), $exclusiveTypeFilter ) )
return array( self::getFieldName( $classAttribute ) );
else
return array();
} | php | public static function getFieldNameList( eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array() )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getFieldNameList' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getFieldNameList' ),
array( $classAttribute, $exclusiveTypeFilter ) ) )
)
{
return $returnValue;
}
}
// fallback behaviour :
if ( empty( $exclusiveTypeFilter ) or !in_array( self::getClassAttributeType( $classAttribute ), $exclusiveTypeFilter ) )
return array( self::getFieldName( $classAttribute ) );
else
return array();
} | [
"public",
"static",
"function",
"getFieldNameList",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"exclusiveTypeFilter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"eZFindIni",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")",
";",
"$",
... | Gets the list of solr fields for the given content class attribute. Delegates
the action to the datatype-specific handler, if any. If none, the datatype has one
field only, hence the delegation to the local getFieldName.
@param eZContentClassAttribute $classAttribute
@param array $exclusiveTypeFilter Array of types ( strings ) which should be excluded
from the result.
@return array Array of applicable solr field names
@see ezfSolrDocumentFieldBase::getFieldName() | [
"Gets",
"the",
"list",
"of",
"solr",
"fields",
"for",
"the",
"given",
"content",
"class",
"attribute",
".",
"Delegates",
"the",
"action",
"to",
"the",
"datatype",
"-",
"specific",
"handler",
"if",
"any",
".",
"If",
"none",
"the",
"datatype",
"has",
"one",
... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L218-L241 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getInstance | static function getInstance( eZContentObjectAttribute $objectAttribute )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $objectAttribute->attribute( 'data_type_string' );
// Check if using custom handler.
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( isset( $customMapList[$datatypeString] ) )
{
$fieldBaseClass = $customMapList[$datatypeString];
if ( class_exists( $fieldBaseClass ) )
{
return new $fieldBaseClass( $objectAttribute );
}
else
{
eZDebug::writeError( "Unknown document field base class '$fieldBaseClass' for datatype '$datatypeString', check your ezfind.ini configuration", __METHOD__ );
}
}
// Return standard handler.
return new ezfSolrDocumentFieldBase( $objectAttribute );
} | php | static function getInstance( eZContentObjectAttribute $objectAttribute )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $objectAttribute->attribute( 'data_type_string' );
// Check if using custom handler.
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( isset( $customMapList[$datatypeString] ) )
{
$fieldBaseClass = $customMapList[$datatypeString];
if ( class_exists( $fieldBaseClass ) )
{
return new $fieldBaseClass( $objectAttribute );
}
else
{
eZDebug::writeError( "Unknown document field base class '$fieldBaseClass' for datatype '$datatypeString', check your ezfind.ini configuration", __METHOD__ );
}
}
// Return standard handler.
return new ezfSolrDocumentFieldBase( $objectAttribute );
} | [
"static",
"function",
"getInstance",
"(",
"eZContentObjectAttribute",
"$",
"objectAttribute",
")",
"{",
"$",
"eZFindIni",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")",
";",
"$",
"datatypeString",
"=",
"$",
"objectAttribute",
"->",
"attribute",
"(",
"... | Returns instance of ezfSolrDocumentFieldBase based on the eZContentObjectAttribute
provided.
To override the standard class ezfSolrDocumentFieldBase, specify in the configuration
files which sub-class which should be used.
@param eZContentObjectAttribute Instance of eZContentObjectAttribute.
@return ezfSolrDocumentFieldBase Instance of ezfSolrDocumentFieldBase. | [
"Returns",
"instance",
"of",
"ezfSolrDocumentFieldBase",
"based",
"on",
"the",
"eZContentObjectAttribute",
"provided",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L303-L326 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.preProcessValue | static function preProcessValue( $value, $fieldType )
{
switch( $fieldType )
{
case 'date':
{
if ( is_numeric( $value ) )
{
$value = self::convertTimestampToDate( $value );
}
// Flag this as not to index
else
{
$value = null;
}
} break;
case 'boolean':
{
if ( is_numeric( $value ) )
{
$value = $value ? 'true' : 'false';
}
} break;
default:
{
// Do nothing yet.
} break;
}
return $value;
} | php | static function preProcessValue( $value, $fieldType )
{
switch( $fieldType )
{
case 'date':
{
if ( is_numeric( $value ) )
{
$value = self::convertTimestampToDate( $value );
}
// Flag this as not to index
else
{
$value = null;
}
} break;
case 'boolean':
{
if ( is_numeric( $value ) )
{
$value = $value ? 'true' : 'false';
}
} break;
default:
{
// Do nothing yet.
} break;
}
return $value;
} | [
"static",
"function",
"preProcessValue",
"(",
"$",
"value",
",",
"$",
"fieldType",
")",
"{",
"switch",
"(",
"$",
"fieldType",
")",
"{",
"case",
"'date'",
":",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"self",
... | Preprocess value to make sure it complies to the
requirements Solr has to the different field types.
@param mixed Value
@param string Fielt type
@return moxed Processed value | [
"Preprocess",
"value",
"to",
"make",
"sure",
"it",
"complies",
"to",
"the",
"requirements",
"Solr",
"has",
"to",
"the",
"different",
"field",
"types",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L337-L370 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateSubattributeFieldName | public static function generateSubattributeFieldName( eZContentClassAttribute $classAttribute, $subfieldName, $type )
{
// base name of subfields ends with self::SUBATTR_FIELD_PREFIX so
// that it's possible to differentiate those fields in schema.xml
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' )
. self::SUBATTR_FIELD_SEPARATOR . $subfieldName . self::SUBATTR_FIELD_SEPARATOR,
$type );
} | php | public static function generateSubattributeFieldName( eZContentClassAttribute $classAttribute, $subfieldName, $type )
{
// base name of subfields ends with self::SUBATTR_FIELD_PREFIX so
// that it's possible to differentiate those fields in schema.xml
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' )
. self::SUBATTR_FIELD_SEPARATOR . $subfieldName . self::SUBATTR_FIELD_SEPARATOR,
$type );
} | [
"public",
"static",
"function",
"generateSubattributeFieldName",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"subfieldName",
",",
"$",
"type",
")",
"{",
"// base name of subfields ends with self::SUBATTR_FIELD_PREFIX so",
"// that it's possible to differentiate... | Generates the full Solr field name for a datatype's subattribute.
Helper method to be used, if needed, by datatype-specific handlers.
@see ezfSolrDocumentFieldDummyExample
@param eZContentClassAttribute $classAttribute
@param string $subfieldName
@param string $type The fully qualified type. It must be picked amongst
the keys of the ezfSolrDocumentFieldName::$FieldTypeMap array.
@return string | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"a",
"datatype",
"s",
"subattribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L399-L408 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateAttributeFieldName | public static function generateAttributeFieldName( eZContentClassAttribute $classAttribute, $type )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::ATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ),
$type );
} | php | public static function generateAttributeFieldName( eZContentClassAttribute $classAttribute, $type )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::ATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ),
$type );
} | [
"public",
"static",
"function",
"generateAttributeFieldName",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"type",
")",
"{",
"$",
"documentFieldName",
"=",
"self",
"::",
"getDocumentFieldName",
"(",
")",
";",
"return",
"$",
"documentFieldName",
"... | Generates the full Solr field name for an attribute.
Helper method to be used, if needed, by datatype-specific handlers.
@see ezfSolrDocumentFieldDummyExample
@param eZContentClassAttribute $classAttribute
@param string $type The fully qualified type. It must be picked amongst
the keys of the ezfSolrDocumentFieldName::$FieldTypeMap array.
@return string | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"an",
"attribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L422-L428 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateMetaFieldName | public static function generateMetaFieldName( $baseName, $context = 'search' )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::META_FIELD_PREFIX . $baseName,
eZSolr::getMetaAttributeType( $baseName, $context ) );
} | php | public static function generateMetaFieldName( $baseName, $context = 'search' )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::META_FIELD_PREFIX . $baseName,
eZSolr::getMetaAttributeType( $baseName, $context ) );
} | [
"public",
"static",
"function",
"generateMetaFieldName",
"(",
"$",
"baseName",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"documentFieldName",
"=",
"self",
"::",
"getDocumentFieldName",
"(",
")",
";",
"return",
"$",
"documentFieldName",
"->",
"lookupSc... | Generates the full Solr field name for a metadata attribute.
Helper method to be used, if needed, by datatype-specific handlers.
It is used in the search plugin eZSolr.
@param string $baseName
@return string
@example
If $baseName equals 'main_url_alias',
the return value will be : 'meta_main_url_alias_s' | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"a",
"metadata",
"attribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
".",
"It",
"is",
"used",
"in",
"the",
"search",
"plugin",
... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L442-L448 | train |
ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateSubmetaFieldName | public static function generateSubmetaFieldName( $baseName, eZContentClassAttribute $classAttribute )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBMETA_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ) . self::SUBATTR_FIELD_SEPARATOR . $baseName . self::SUBATTR_FIELD_SEPARATOR,
eZSolr::getMetaAttributeType( $baseName ) );
} | php | public static function generateSubmetaFieldName( $baseName, eZContentClassAttribute $classAttribute )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBMETA_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ) . self::SUBATTR_FIELD_SEPARATOR . $baseName . self::SUBATTR_FIELD_SEPARATOR,
eZSolr::getMetaAttributeType( $baseName ) );
} | [
"public",
"static",
"function",
"generateSubmetaFieldName",
"(",
"$",
"baseName",
",",
"eZContentClassAttribute",
"$",
"classAttribute",
")",
"{",
"$",
"documentFieldName",
"=",
"self",
"::",
"getDocumentFieldName",
"(",
")",
";",
"return",
"$",
"documentFieldName",
... | Generates the full Solr field name for a metadata subattribute.
Helper method to be used, if needed, by datatype-specific handlers.
Used particularly when indexing metadata of a related object.
@param string $baseName
@param eZContentClassAttribute $classAttribute
@return string
@example
If $baseName equals 'main_url_alias', and $classAttribute
has as identifier 'dummy', the return value will be :
'submeta_dummy-main_url_alias_s'
@see ezfSolrDocumentFieldObjectRelation | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"a",
"metadata",
"subattribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
".",
"Used",
"particularly",
"when",
"indexing",
"metadata"... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L466-L472 | train |
ezsystems/ezfind | classes/ezsolrdoc.php | eZSolrDoc.setBoost | public function setBoost ( $boost = null )
{
if ( $boost !== null && is_numeric( $boost ))
{
$this->DocBoost = $boost;
}
} | php | public function setBoost ( $boost = null )
{
if ( $boost !== null && is_numeric( $boost ))
{
$this->DocBoost = $boost;
}
} | [
"public",
"function",
"setBoost",
"(",
"$",
"boost",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"boost",
"!==",
"null",
"&&",
"is_numeric",
"(",
"$",
"boost",
")",
")",
"{",
"$",
"this",
"->",
"DocBoost",
"=",
"$",
"boost",
";",
"}",
"}"
] | Set document boost
@param float Document boost | [
"Set",
"document",
"boost"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrdoc.php#L66-L72 | train |
ezsystems/ezfind | classes/ezsolrdoc.php | eZSolrDoc.addField | public function addField ( $name, $content, $boost = null )
{
if ( !is_array( $content ) )
{
$content = array( $content );
}
if (array_key_exists($name, $this->Doc))
{
$this->Doc[$name]['content'] = array_merge($this->Doc[$name]['content'], $content);
}
else
{
$this->Doc[$name]['content'] = $content;
}
$this->Doc[$name]['boost'] = $boost;
} | php | public function addField ( $name, $content, $boost = null )
{
if ( !is_array( $content ) )
{
$content = array( $content );
}
if (array_key_exists($name, $this->Doc))
{
$this->Doc[$name]['content'] = array_merge($this->Doc[$name]['content'], $content);
}
else
{
$this->Doc[$name]['content'] = $content;
}
$this->Doc[$name]['boost'] = $boost;
} | [
"public",
"function",
"addField",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"boost",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"$",
"content",
"=",
"array",
"(",
"$",
"content",
")",
";",
"}",
... | Add document field
@param string Field name
@param mixed Field content. $content may be a value or an array containing values.
if the the array has more than one element, the schema declaration must be multi-valued too
@param float Field boost ( optional ). | [
"Add",
"document",
"field"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrdoc.php#L82-L98 | train |
ezsystems/ezfind | classes/ezsolrdoc.php | eZSolrDoc.docToXML | function docToXML()
{
$this->DomDoc = new DOMDocument( '1.0', 'utf-8' );
$this->DomRootElement = $this->DomDoc->createElement( 'doc' );
$this->DomDoc->appendChild( $this->DomRootElement );
if ($this->DocBoost !== null && is_numeric( $this->DocBoost ) )
{
// This will force the '.' as decimal separator and not depend on the locale
$docBoost = sprintf('%F',$this->DocBoost);
$this->DomRootElement->setAttribute( 'boost', $docBoost );
}
foreach ($this->Doc as $name => $field) {
foreach( $field['content'] as $value )
{
// $value should never be array. Log the value and the stack trace.
if ( is_array( $value ) )
{
$backtrace = debug_backtrace();
$dump = array( $backtrace[0], $backtrace[1] );
eZDebug::writeError( 'Tried to index array value: ' . $name . "\nValue: " . var_export( $value, 1 ) .
"\nStack trace: " . var_export( $dump, 1 ) );
continue;
}
$fieldElement = $this->DomDoc->createElement( 'field' );
$fieldElement->appendChild( $this->DomDoc->createTextNode( $value ) );
$fieldElement->setAttribute( 'name', $name );
if ( $field['boost'] !== null && is_numeric( $field['boost'] ) )
{
$fieldElement->setAttribute( 'boost', $field['boost'] );
}
$this->DomRootElement->appendChild( $fieldElement );
}
}
$rawXML = $this->DomDoc->saveXML( $this->DomRootElement );
//make sure there are no control characters left that could currupt the XML string
return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXML);
} | php | function docToXML()
{
$this->DomDoc = new DOMDocument( '1.0', 'utf-8' );
$this->DomRootElement = $this->DomDoc->createElement( 'doc' );
$this->DomDoc->appendChild( $this->DomRootElement );
if ($this->DocBoost !== null && is_numeric( $this->DocBoost ) )
{
// This will force the '.' as decimal separator and not depend on the locale
$docBoost = sprintf('%F',$this->DocBoost);
$this->DomRootElement->setAttribute( 'boost', $docBoost );
}
foreach ($this->Doc as $name => $field) {
foreach( $field['content'] as $value )
{
// $value should never be array. Log the value and the stack trace.
if ( is_array( $value ) )
{
$backtrace = debug_backtrace();
$dump = array( $backtrace[0], $backtrace[1] );
eZDebug::writeError( 'Tried to index array value: ' . $name . "\nValue: " . var_export( $value, 1 ) .
"\nStack trace: " . var_export( $dump, 1 ) );
continue;
}
$fieldElement = $this->DomDoc->createElement( 'field' );
$fieldElement->appendChild( $this->DomDoc->createTextNode( $value ) );
$fieldElement->setAttribute( 'name', $name );
if ( $field['boost'] !== null && is_numeric( $field['boost'] ) )
{
$fieldElement->setAttribute( 'boost', $field['boost'] );
}
$this->DomRootElement->appendChild( $fieldElement );
}
}
$rawXML = $this->DomDoc->saveXML( $this->DomRootElement );
//make sure there are no control characters left that could currupt the XML string
return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXML);
} | [
"function",
"docToXML",
"(",
")",
"{",
"$",
"this",
"->",
"DomDoc",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"this",
"->",
"DomRootElement",
"=",
"$",
"this",
"->",
"DomDoc",
"->",
"createElement",
"(",
"'doc'",
")",
";",... | Convert current object to XML string
@return string XML string. | [
"Convert",
"current",
"object",
"to",
"XML",
"string"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrdoc.php#L113-L155 | train |
ezsystems/ezfind | classes/solrstorage/ezmatrixsolrstorage.php | ezmatrixSolrStorage.getAttributeContent | public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
{
$rows = $contentObjectAttribute->content()->attribute( 'rows' );
$target = array(
'has_rendered_content' => false,
'rendered' => null,
'content' => array()
);
foreach( $rows['sequential'] as $elt )
{
$target['content'][] = $elt['columns'];
}
return $target;
} | php | public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
{
$rows = $contentObjectAttribute->content()->attribute( 'rows' );
$target = array(
'has_rendered_content' => false,
'rendered' => null,
'content' => array()
);
foreach( $rows['sequential'] as $elt )
{
$target['content'][] = $elt['columns'];
}
return $target;
} | [
"public",
"static",
"function",
"getAttributeContent",
"(",
"eZContentObjectAttribute",
"$",
"contentObjectAttribute",
",",
"eZContentClassAttribute",
"$",
"contentClassAttribute",
")",
"{",
"$",
"rows",
"=",
"$",
"contentObjectAttribute",
"->",
"content",
"(",
")",
"->... | Returns the content of the matrix to be stored in Solr
@param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
@param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
@return array | [
"Returns",
"the",
"content",
"of",
"the",
"matrix",
"to",
"be",
"stored",
"in",
"Solr"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/solrstorage/ezmatrixsolrstorage.php#L22-L35 | train |
ezsystems/ezfind | classes/ezfindextendedattributefilterfactory.php | eZFindExtendedAttributeFilterFactory.getInstance | public static function getInstance( $filterID )
{
if( !isset( self::$instances[$filterID] ) )
{
try
{
if( !self::$filtersList )
{
$ini = eZINI::instance( 'ezfind.ini' );
self::$filtersList = $ini->variable( 'ExtendedAttributeFilters', 'FiltersList' );
}
if( !isset( self::$filtersList[$filterID] ) )
{
throw new Exception( $filterID . ' extended attribute filter is not defined' );
}
$className = self::$filtersList[$filterID];
if( !class_exists( $className ) )
{
throw new Exception( 'Could not find class ' . $className );
}
$instance = new $className();
if( !$instance instanceof eZFindExtendedAttributeFilterInterface )
{
throw new Exception( $className . ' is not a valid eZFindExtendedAttributeFilterInterface' );
}
self::$instances[$filterID] = $instance;
}
catch( Exception $e)
{
eZDebug::writeWarning( $e->getMessage(), __METHOD__ );
self::$instances[$filterID] = false;
}
}
return self::$instances[$filterID];
} | php | public static function getInstance( $filterID )
{
if( !isset( self::$instances[$filterID] ) )
{
try
{
if( !self::$filtersList )
{
$ini = eZINI::instance( 'ezfind.ini' );
self::$filtersList = $ini->variable( 'ExtendedAttributeFilters', 'FiltersList' );
}
if( !isset( self::$filtersList[$filterID] ) )
{
throw new Exception( $filterID . ' extended attribute filter is not defined' );
}
$className = self::$filtersList[$filterID];
if( !class_exists( $className ) )
{
throw new Exception( 'Could not find class ' . $className );
}
$instance = new $className();
if( !$instance instanceof eZFindExtendedAttributeFilterInterface )
{
throw new Exception( $className . ' is not a valid eZFindExtendedAttributeFilterInterface' );
}
self::$instances[$filterID] = $instance;
}
catch( Exception $e)
{
eZDebug::writeWarning( $e->getMessage(), __METHOD__ );
self::$instances[$filterID] = false;
}
}
return self::$instances[$filterID];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"filterID",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"filterID",
"]",
")",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"filtersList",
")"... | Get singleton instance for filter
@param string $filterID
@return eZFindExtendedAttributeFilterInterface|false | [
"Get",
"singleton",
"instance",
"for",
"filter"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindextendedattributefilterfactory.php#L32-L71 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.getMetaAttributesForObject | public static function getMetaAttributesForObject( eZContentObject $object )
{
$metaAttributeValues = array();
foreach ( self::metaAttributes() as $attributeName => $fieldType )
{
$metaAttributeValues[] = array( 'name' => $attributeName,
'value' => $object->attribute( $attributeName ),
'fieldType' => $fieldType );
}
return $metaAttributeValues;
} | php | public static function getMetaAttributesForObject( eZContentObject $object )
{
$metaAttributeValues = array();
foreach ( self::metaAttributes() as $attributeName => $fieldType )
{
$metaAttributeValues[] = array( 'name' => $attributeName,
'value' => $object->attribute( $attributeName ),
'fieldType' => $fieldType );
}
return $metaAttributeValues;
} | [
"public",
"static",
"function",
"getMetaAttributesForObject",
"(",
"eZContentObject",
"$",
"object",
")",
"{",
"$",
"metaAttributeValues",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"metaAttributes",
"(",
")",
"as",
"$",
"attributeName",
"=>",
... | Fetches the meta attributes for a given content object
and fill the structure described below.
@param eZContentObject $object
@return array
<code>
array(
array( 'name' => 'id'
'value' => 82
'fieldType' => 'sint' ),
...
)
</code>
@see eZSolr::metaAttributes() | [
"Fetches",
"the",
"meta",
"attributes",
"for",
"a",
"given",
"content",
"object",
"and",
"fill",
"the",
"structure",
"described",
"below",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L71-L81 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.getMetaAttributeType | static function getMetaAttributeType( $name, $context = 'search' )
{
$attributeList = array( 'search' => array_merge( array( 'guid' => 'mstring',
'installation_id' => 'mstring',
'installation_url' => 'mstring',
'name' => 'text',
'sort_name' => 'mstring',
'anon_access' => 'boolean',
'language_code' => 'mstring',
'available_language_codes' => 'mstring',
'main_url_alias' => 'mstring',
'main_path_string' => 'mstring',
'owner_name' => 'text',
'owner_group_id' => 'sint',
'path' => 'sint',
'object_states' => 'sint',
'visible_path' => 'sint',
'hidden_path' => 'sint',
'visible_path_string' => 'mstring',
'hidden_path_string' => 'mstring' ),
self::metaAttributes(),
self::nodeAttributes() ),
'facet' => array(
'owner_name' => 'string' ),
'filter' => array(),
'sort' => array() );
if ( ! empty( $attributeList[$context][$name] ) )
{
return $attributeList[$context][$name];
}
elseif ( ! empty( $attributeList['search'][$name] ) )
{
return $attributeList['search'][$name];
}
else
{
return null;
}
//return $attributeList[$name];
} | php | static function getMetaAttributeType( $name, $context = 'search' )
{
$attributeList = array( 'search' => array_merge( array( 'guid' => 'mstring',
'installation_id' => 'mstring',
'installation_url' => 'mstring',
'name' => 'text',
'sort_name' => 'mstring',
'anon_access' => 'boolean',
'language_code' => 'mstring',
'available_language_codes' => 'mstring',
'main_url_alias' => 'mstring',
'main_path_string' => 'mstring',
'owner_name' => 'text',
'owner_group_id' => 'sint',
'path' => 'sint',
'object_states' => 'sint',
'visible_path' => 'sint',
'hidden_path' => 'sint',
'visible_path_string' => 'mstring',
'hidden_path_string' => 'mstring' ),
self::metaAttributes(),
self::nodeAttributes() ),
'facet' => array(
'owner_name' => 'string' ),
'filter' => array(),
'sort' => array() );
if ( ! empty( $attributeList[$context][$name] ) )
{
return $attributeList[$context][$name];
}
elseif ( ! empty( $attributeList['search'][$name] ) )
{
return $attributeList['search'][$name];
}
else
{
return null;
}
//return $attributeList[$name];
} | [
"static",
"function",
"getMetaAttributeType",
"(",
"$",
"name",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"attributeList",
"=",
"array",
"(",
"'search'",
"=>",
"array_merge",
"(",
"array",
"(",
"'guid'",
"=>",
"'mstring'",
",",
"'installation_id'",
... | Get meta attribute Solr document field type
@param string name Meta attribute name
@param string context search, facet, filter, sort
@return string Solr document field type. Null if meta attribute type does not exists. | [
"Get",
"meta",
"attribute",
"Solr",
"document",
"field",
"type"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L110-L151 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.getNodeID | protected function getNodeID( $doc )
{
$docPathStrings = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'path_string' )];
$docVisibilities = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )];
if ( count( $docPathStrings ) > 1 )
{
// reordering the path strings and the associated visibilities so
// that the main node path string and the main node visibility are
// in the first position.
$mainNodeIdx = array_search(
$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_path_string' )],
$docPathStrings
);
if ( $mainNodeIdx != 0 )
{
array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] );
array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] );
// adding +1 to indexing because of array_unshift
unset( $docVisibilities[$mainNodeIdx + 1], $docPathStrings[$mainNodeIdx + 1] );
}
}
$locationFilter = isset( $this->postSearchProcessingData['subtree_array'] ) ? $this->postSearchProcessingData['subtree_array'] : array();
$subtreeLimitations = isset( $this->postSearchProcessingData['subtree_limitations'] ) ? $this->postSearchProcessingData['subtree_limitations'] : array();
$validSubtreeArray = $this->getValidPathStringsByLimitation(
$docPathStrings,
$locationFilter
);
$validSubtreeLimitations = $this->getValidPathStringsByLimitation(
$docPathStrings,
$subtreeLimitations
);
$ignoreVisibility = eZContentObjectTreeNode::showInvisibleNodes();
if ( isset( $this->postSearchProcessingData['ignore_visibility'] ) )
{
$ignoreVisibility = $this->postSearchProcessingData['ignore_visibility'];
}
// Intersect between $validSubtreeArray (search location filter) and $validSubtreeLimitations (user policy limitations)
// indicates valid locations for $doc in current search query
// If this intersect is not empty, we take the first node id that
// matches the visibility requirement
$validSubtrees = array_flip(
array_intersect( $validSubtreeArray, $validSubtreeLimitations )
);
if ( !empty( $validSubtrees ) )
{
foreach ( $docPathStrings as $k => $path )
{
if ( isset( $validSubtrees[$path] ) )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
// Could not find a visible location for content that current user has read access on.
return null;
}
else
{
$contentId = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'id' )];
$content = eZContentObject::fetch( $contentId );
if ( $content instanceof eZContentObject && !$content->canRead() )
{
eZDebug::writeError(
"Could not find valid/granted locations for content #$contentId. Broken sync between eZPublish and Solr ?\n\n" .
"Location filter : " . print_r( $locationFilter, true ) .
"Subtree limitations for user : " . print_r( $subtreeLimitations, true ),
__METHOD__
);
}
foreach ( $docPathStrings as $k => $path )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
return (int)$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_node_id' )];
} | php | protected function getNodeID( $doc )
{
$docPathStrings = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'path_string' )];
$docVisibilities = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )];
if ( count( $docPathStrings ) > 1 )
{
// reordering the path strings and the associated visibilities so
// that the main node path string and the main node visibility are
// in the first position.
$mainNodeIdx = array_search(
$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_path_string' )],
$docPathStrings
);
if ( $mainNodeIdx != 0 )
{
array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] );
array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] );
// adding +1 to indexing because of array_unshift
unset( $docVisibilities[$mainNodeIdx + 1], $docPathStrings[$mainNodeIdx + 1] );
}
}
$locationFilter = isset( $this->postSearchProcessingData['subtree_array'] ) ? $this->postSearchProcessingData['subtree_array'] : array();
$subtreeLimitations = isset( $this->postSearchProcessingData['subtree_limitations'] ) ? $this->postSearchProcessingData['subtree_limitations'] : array();
$validSubtreeArray = $this->getValidPathStringsByLimitation(
$docPathStrings,
$locationFilter
);
$validSubtreeLimitations = $this->getValidPathStringsByLimitation(
$docPathStrings,
$subtreeLimitations
);
$ignoreVisibility = eZContentObjectTreeNode::showInvisibleNodes();
if ( isset( $this->postSearchProcessingData['ignore_visibility'] ) )
{
$ignoreVisibility = $this->postSearchProcessingData['ignore_visibility'];
}
// Intersect between $validSubtreeArray (search location filter) and $validSubtreeLimitations (user policy limitations)
// indicates valid locations for $doc in current search query
// If this intersect is not empty, we take the first node id that
// matches the visibility requirement
$validSubtrees = array_flip(
array_intersect( $validSubtreeArray, $validSubtreeLimitations )
);
if ( !empty( $validSubtrees ) )
{
foreach ( $docPathStrings as $k => $path )
{
if ( isset( $validSubtrees[$path] ) )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
// Could not find a visible location for content that current user has read access on.
return null;
}
else
{
$contentId = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'id' )];
$content = eZContentObject::fetch( $contentId );
if ( $content instanceof eZContentObject && !$content->canRead() )
{
eZDebug::writeError(
"Could not find valid/granted locations for content #$contentId. Broken sync between eZPublish and Solr ?\n\n" .
"Location filter : " . print_r( $locationFilter, true ) .
"Subtree limitations for user : " . print_r( $subtreeLimitations, true ),
__METHOD__
);
}
foreach ( $docPathStrings as $k => $path )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
return (int)$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_node_id' )];
} | [
"protected",
"function",
"getNodeID",
"(",
"$",
"doc",
")",
"{",
"$",
"docPathStrings",
"=",
"$",
"doc",
"[",
"ezfSolrDocumentFieldBase",
"::",
"generateMetaFieldName",
"(",
"'path_string'",
")",
"]",
";",
"$",
"docVisibilities",
"=",
"$",
"doc",
"[",
"ezfSolr... | Returns the relative NodeID for a given search result,
depending on whether a subtree filter was applied or not and limitations by user policy limitations.
Policy limitations (subtree/node) are aggregated by a logic OR (same for subtree filters).
Subtree filters and policy limitations are aggregated together with a logic AND,
so that valid locations must comply subtree filters (if any) AND subtree/node policy limitations (if any)
@param array $doc The search result, directly received from Solr.
@return int The NodeID corresponding the search result | [
"Returns",
"the",
"relative",
"NodeID",
"for",
"a",
"given",
"search",
"result",
"depending",
"on",
"whether",
"a",
"subtree",
"filter",
"was",
"applied",
"or",
"not",
"and",
"limitations",
"by",
"user",
"policy",
"limitations",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L318-L403 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.addFieldBaseToDoc | function addFieldBaseToDoc( ezfSolrDocumentFieldBase $fieldBase, eZSolrDoc $doc, $boost = false )
{
$fieldBaseData = $fieldBase->getData();
if ( empty( $fieldBaseData ) )
{
if ( is_object( $fieldBase ) )
{
$contentClassAttribute = $fieldBase->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldName = $fieldBase->getFieldName( $contentClassAttribute );
$errorMessage = 'empty array for ' . $fieldName;
}
else
{
$errorMessage = '$fieldBase not an object';
}
eZDebug::writeNotice( $errorMessage , __METHOD__ );
return false;
}
else
{
foreach ( $fieldBaseData as $key => $value )
{
// since ezfind 2.3, a NULL value returned from $fieldBase in the $value elements is used as a flag not to index
if ( !is_null( $value ) )
{
$doc->addField( $key, $value, $boost );
}
}
return true;
}
} | php | function addFieldBaseToDoc( ezfSolrDocumentFieldBase $fieldBase, eZSolrDoc $doc, $boost = false )
{
$fieldBaseData = $fieldBase->getData();
if ( empty( $fieldBaseData ) )
{
if ( is_object( $fieldBase ) )
{
$contentClassAttribute = $fieldBase->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldName = $fieldBase->getFieldName( $contentClassAttribute );
$errorMessage = 'empty array for ' . $fieldName;
}
else
{
$errorMessage = '$fieldBase not an object';
}
eZDebug::writeNotice( $errorMessage , __METHOD__ );
return false;
}
else
{
foreach ( $fieldBaseData as $key => $value )
{
// since ezfind 2.3, a NULL value returned from $fieldBase in the $value elements is used as a flag not to index
if ( !is_null( $value ) )
{
$doc->addField( $key, $value, $boost );
}
}
return true;
}
} | [
"function",
"addFieldBaseToDoc",
"(",
"ezfSolrDocumentFieldBase",
"$",
"fieldBase",
",",
"eZSolrDoc",
"$",
"doc",
",",
"$",
"boost",
"=",
"false",
")",
"{",
"$",
"fieldBaseData",
"=",
"$",
"fieldBase",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"empty",
"(... | Add instance of ezfSolrDocumentFieldBase to Solr document.
@param ezfSolrDocumentFieldBase Instance of ezfSolrDocumentFieldBase
@param eZSolrDoc Solr document | [
"Add",
"instance",
"of",
"ezfSolrDocumentFieldBase",
"to",
"Solr",
"document",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L789-L820 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.commit | function commit( $softCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->commit( $softCommit );
}
}
else
{
$this->Solr->commit( $softCommit );
}
} | php | function commit( $softCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->commit( $softCommit );
}
}
else
{
$this->Solr->commit( $softCommit );
}
} | [
"function",
"commit",
"(",
"$",
"softCommit",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UseMultiLanguageCores",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"SolrLanguageShards",
"as",
"$",
"shard",
")",
"{",
"$",
"shard",
"... | Performs a solr COMMIT | [
"Performs",
"a",
"solr",
"COMMIT"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L825-L840 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.optimize | function optimize( $withCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->optimize( $withCommit );
}
}
else
{
$this->Solr->optimize( $withCommit );
}
} | php | function optimize( $withCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->optimize( $withCommit );
}
}
else
{
$this->Solr->optimize( $withCommit );
}
} | [
"function",
"optimize",
"(",
"$",
"withCommit",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UseMultiLanguageCores",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"SolrLanguageShards",
"as",
"$",
"shard",
")",
"{",
"$",
"shard",
... | Performs a solr OPTIMIZE call | [
"Performs",
"a",
"solr",
"OPTIMIZE",
"call"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L845-L859 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.moreLikeThis | function moreLikeThis( $queryType, $queryValue, $params = array() )
{
eZDebug::createAccumulator( 'MoreLikeThis', 'eZ Find' );
eZDebug::accumulatorStart( 'MoreLikeThis' );
$error = 'Server not running';
$asObjects = isset( $params['AsObjects'] ) ? $params['AsObjects'] : true;
//mlt does not support distributed search yet, so find out which is
//the language core to use and qyery only this one
//search across languages does not make sense here
$coreToUse = null;
if ( $this->UseMultiLanguageCores == true )
{
$languages = $this->SiteINI->variable( 'RegionalSettings', 'SiteLanguageList' );
if ( array_key_exists ( $languages[0], $this->SolrLanguageShards ) )
{
$coreToUse = $this->SolrLanguageShards[$languages[0]];
}
}
else
{
$coreToUse = $this->Solr;
}
if ( trim( $queryType ) == '' || trim( $queryValue ) == '' )
{
$error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $queryType . ', Query Value = ' . $queryValue;
eZDebug::writeNotice( $error, __METHOD__ );
$resultArray = null;
}
else
{
eZDebug::createAccumulator( 'Query build', 'eZ Find' );
eZDebug::accumulatorStart( 'Query build' );
$queryBuilder = new ezfeZPSolrQueryBuilder( $this );
$queryParams = $queryBuilder->buildMoreLikeThis( $queryType, $queryValue, $params );
eZDebug::accumulatorStop( 'Query build' );
eZDebug::createAccumulator( 'Engine time', 'eZ Find' );
eZDebug::accumulatorStart( 'Engine time' );
$resultArray = $coreToUse->rawSolrRequest( '/mlt', $queryParams );
eZDebug::accumulatorStop( 'Engine time' );
}
if ( $resultArray )
{
$searchCount = $resultArray[ 'response' ][ 'numFound' ];
$objectRes = $this->buildResultObjects(
$resultArray, $searchCount, $asObjects, $params
);
$stopWordArray = array();
eZDebugSetting::writeDebug( 'extension-ezfind-query-mlt', $resultArray['interestingTerms'], 'MoreLikeThis terms' );
return array(
'SearchResult' => $objectRes,
'SearchCount' => $searchCount,
'StopWordArray' => $stopWordArray,
'SearchExtras' => new ezfSearchResultInfo( $resultArray )
);
}
else
{
return array(
'SearchResult' => false,
'SearchCount' => 0,
'StopWordArray' => array(),
'SearchExtras' => new ezfSearchResultInfo( array( 'error' => ezpI18n::tr( 'ezfind', $error ) ) ) );
}
} | php | function moreLikeThis( $queryType, $queryValue, $params = array() )
{
eZDebug::createAccumulator( 'MoreLikeThis', 'eZ Find' );
eZDebug::accumulatorStart( 'MoreLikeThis' );
$error = 'Server not running';
$asObjects = isset( $params['AsObjects'] ) ? $params['AsObjects'] : true;
//mlt does not support distributed search yet, so find out which is
//the language core to use and qyery only this one
//search across languages does not make sense here
$coreToUse = null;
if ( $this->UseMultiLanguageCores == true )
{
$languages = $this->SiteINI->variable( 'RegionalSettings', 'SiteLanguageList' );
if ( array_key_exists ( $languages[0], $this->SolrLanguageShards ) )
{
$coreToUse = $this->SolrLanguageShards[$languages[0]];
}
}
else
{
$coreToUse = $this->Solr;
}
if ( trim( $queryType ) == '' || trim( $queryValue ) == '' )
{
$error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $queryType . ', Query Value = ' . $queryValue;
eZDebug::writeNotice( $error, __METHOD__ );
$resultArray = null;
}
else
{
eZDebug::createAccumulator( 'Query build', 'eZ Find' );
eZDebug::accumulatorStart( 'Query build' );
$queryBuilder = new ezfeZPSolrQueryBuilder( $this );
$queryParams = $queryBuilder->buildMoreLikeThis( $queryType, $queryValue, $params );
eZDebug::accumulatorStop( 'Query build' );
eZDebug::createAccumulator( 'Engine time', 'eZ Find' );
eZDebug::accumulatorStart( 'Engine time' );
$resultArray = $coreToUse->rawSolrRequest( '/mlt', $queryParams );
eZDebug::accumulatorStop( 'Engine time' );
}
if ( $resultArray )
{
$searchCount = $resultArray[ 'response' ][ 'numFound' ];
$objectRes = $this->buildResultObjects(
$resultArray, $searchCount, $asObjects, $params
);
$stopWordArray = array();
eZDebugSetting::writeDebug( 'extension-ezfind-query-mlt', $resultArray['interestingTerms'], 'MoreLikeThis terms' );
return array(
'SearchResult' => $objectRes,
'SearchCount' => $searchCount,
'StopWordArray' => $stopWordArray,
'SearchExtras' => new ezfSearchResultInfo( $resultArray )
);
}
else
{
return array(
'SearchResult' => false,
'SearchCount' => 0,
'StopWordArray' => array(),
'SearchExtras' => new ezfSearchResultInfo( array( 'error' => ezpI18n::tr( 'ezfind', $error ) ) ) );
}
} | [
"function",
"moreLikeThis",
"(",
"$",
"queryType",
",",
"$",
"queryValue",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"eZDebug",
"::",
"createAccumulator",
"(",
"'MoreLikeThis'",
",",
"'eZ Find'",
")",
";",
"eZDebug",
"::",
"accumulatorStart",
"("... | More like this is pretty similar to normal search, but usually only the object or node id are sent to Solr
However, streams or a search text body can also be passed .. Solr will extract the important terms and build a
query for us
@param string $queryType is one of 'noid', 'oid', 'url', 'text'
@param $queryValue the node id, object id, url or text body to use
@param array parameters. @see ezfeZPSolrQueryBuilder::buildMoreLikeThis()
@return array List of eZFindResultNode objects.
@todo: add functionality not to call the DB to recreate objects : $asObjects == false | [
"More",
"like",
"this",
"is",
"pretty",
"similar",
"to",
"normal",
"search",
"but",
"usually",
"only",
"the",
"object",
"or",
"node",
"id",
"are",
"sent",
"to",
"Solr",
"However",
"streams",
"or",
"a",
"search",
"text",
"body",
"can",
"also",
"be",
"pass... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1068-L1138 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.installationID | static function installationID()
{
if ( !empty( self::$InstallationID ) )
{
return self::$InstallationID;
}
$db = eZDB::instance();
$resultSet = $db->arrayQuery( 'SELECT value FROM ezsite_data WHERE name=\'ezfind_site_id\'' );
if ( count( $resultSet ) >= 1 )
{
self::$InstallationID = $resultSet[0]['value'];
}
else
{
self::$InstallationID = md5( time() . '-' . mt_rand() );
$db->query( 'INSERT INTO ezsite_data ( name, value ) values( \'ezfind_site_id\', \'' . self::$InstallationID . '\' )' );
}
return self::$InstallationID;
} | php | static function installationID()
{
if ( !empty( self::$InstallationID ) )
{
return self::$InstallationID;
}
$db = eZDB::instance();
$resultSet = $db->arrayQuery( 'SELECT value FROM ezsite_data WHERE name=\'ezfind_site_id\'' );
if ( count( $resultSet ) >= 1 )
{
self::$InstallationID = $resultSet[0]['value'];
}
else
{
self::$InstallationID = md5( time() . '-' . mt_rand() );
$db->query( 'INSERT INTO ezsite_data ( name, value ) values( \'ezfind_site_id\', \'' . self::$InstallationID . '\' )' );
}
return self::$InstallationID;
} | [
"static",
"function",
"installationID",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"InstallationID",
")",
")",
"{",
"return",
"self",
"::",
"$",
"InstallationID",
";",
"}",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",... | Returns the eZ publish installation ID, used by eZ find to identify sites
@return string installaiton ID. | [
"Returns",
"the",
"eZ",
"publish",
"installation",
"ID",
"used",
"by",
"eZ",
"find",
"to",
"identify",
"sites"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1193-L1214 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.guid | function guid( $contentObject, $languageCode = '' )
{
if ( !$contentObject instanceof eZContentObject )
return md5( self::installationID() . '-' . $contentObject . '-' . $languageCode );
return md5( self::installationID() . '-' . $contentObject->attribute( 'id' ) . '-' . $languageCode );
} | php | function guid( $contentObject, $languageCode = '' )
{
if ( !$contentObject instanceof eZContentObject )
return md5( self::installationID() . '-' . $contentObject . '-' . $languageCode );
return md5( self::installationID() . '-' . $contentObject->attribute( 'id' ) . '-' . $languageCode );
} | [
"function",
"guid",
"(",
"$",
"contentObject",
",",
"$",
"languageCode",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"contentObject",
"instanceof",
"eZContentObject",
")",
"return",
"md5",
"(",
"self",
"::",
"installationID",
"(",
")",
".",
"'-'",
".",
"$"... | Computes the unique ID of a content object language version
@param eZContentObject|int $contentObject The content object OR content object Id
@param string $languageCode
@return string guid | [
"Computes",
"the",
"unique",
"ID",
"of",
"a",
"content",
"object",
"language",
"version"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1223-L1229 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.extractLanguageCodesFromSolrResult | private function extractLanguageCodesFromSolrResult( $solrResults )
{
$languages = array();
if ( isset( $solrResults['response']['docs'] ) )
{
foreach ( $solrResults['response']['docs'] as $doc )
{
if ( isset( $doc['meta_language_code_ms'] ) )
{
$languages[] = $doc['meta_language_code_ms'];
}
}
}
return $languages;
} | php | private function extractLanguageCodesFromSolrResult( $solrResults )
{
$languages = array();
if ( isset( $solrResults['response']['docs'] ) )
{
foreach ( $solrResults['response']['docs'] as $doc )
{
if ( isset( $doc['meta_language_code_ms'] ) )
{
$languages[] = $doc['meta_language_code_ms'];
}
}
}
return $languages;
} | [
"private",
"function",
"extractLanguageCodesFromSolrResult",
"(",
"$",
"solrResults",
")",
"{",
"$",
"languages",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"solrResults",
"[",
"'response'",
"]",
"[",
"'docs'",
"]",
")",
")",
"{",
"foreach"... | Extracts the list of 'meta_language_code_ms' from a solrResult array.
@param $solrResults
@return array of languages (as strings) | [
"Extracts",
"the",
"list",
"of",
"meta_language_code_ms",
"from",
"a",
"solrResult",
"array",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1275-L1291 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.cleanup | function cleanup( $allInstallations = false, $optimize = false )
{
if ( $allInstallations === true )
{
$optimize = true;
$deleteQuery = '*:*';
}
else
{
$deleteQuery = ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_id' ) . ':' . self::installationID();
}
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->deleteDocs( array(), $deleteQuery, true, $optimize );
}
return true;
}
else
{
return $this->Solr->deleteDocs( array(), $deleteQuery, true );
}
} | php | function cleanup( $allInstallations = false, $optimize = false )
{
if ( $allInstallations === true )
{
$optimize = true;
$deleteQuery = '*:*';
}
else
{
$deleteQuery = ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_id' ) . ':' . self::installationID();
}
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->deleteDocs( array(), $deleteQuery, true, $optimize );
}
return true;
}
else
{
return $this->Solr->deleteDocs( array(), $deleteQuery, true );
}
} | [
"function",
"cleanup",
"(",
"$",
"allInstallations",
"=",
"false",
",",
"$",
"optimize",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"allInstallations",
"===",
"true",
")",
"{",
"$",
"optimize",
"=",
"true",
";",
"$",
"deleteQuery",
"=",
"'*:*'",
";",
"}",... | Clean up search index for current installation.
@return bool true if cleanup was successful
@todo: handle multicore configs (need a parameter for it) for return values | [
"Clean",
"up",
"search",
"index",
"for",
"current",
"installation",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1298-L1322 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.addNodeAssignment | public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved )
{
eZContentOperationCollection::registerSearchObject( $objectID, null, $isMoved );
} | php | public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved )
{
eZContentOperationCollection::registerSearchObject( $objectID, null, $isMoved );
} | [
"public",
"function",
"addNodeAssignment",
"(",
"$",
"mainNodeID",
",",
"$",
"objectID",
",",
"$",
"nodeAssignmentIDList",
",",
"$",
"isMoved",
")",
"{",
"eZContentOperationCollection",
"::",
"registerSearchObject",
"(",
"$",
"objectID",
",",
"null",
",",
"$",
"... | Called when a node assignement is added to an object.
Simply re-index for now.
@todo: defer to cron if there are children involved and re-index these too
@todo when Solr supports it: update fields only
@param $mainNodeID
@param $objectID
@param $nodeAssignmentIDList
@param bool $isMoved true if node is being moved
@return unknown_type
@see eZSearch::addNodeAssignment() | [
"Called",
"when",
"a",
"node",
"assignement",
"is",
"added",
"to",
"an",
"object",
".",
"Simply",
"re",
"-",
"index",
"for",
"now",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1494-L1497 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.swapNode | public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$contentObject1 = eZContentObject::fetchByNodeID( $nodeID );
$contentObject2 = eZContentObject::fetchByNodeID( $selectedNodeID );
$this->addObject( $contentObject1 );
$this->addObject( $contentObject2 );
} | php | public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$contentObject1 = eZContentObject::fetchByNodeID( $nodeID );
$contentObject2 = eZContentObject::fetchByNodeID( $selectedNodeID );
$this->addObject( $contentObject1 );
$this->addObject( $contentObject2 );
} | [
"public",
"function",
"swapNode",
"(",
"$",
"nodeID",
",",
"$",
"selectedNodeID",
",",
"$",
"nodeIdList",
"=",
"array",
"(",
")",
")",
"{",
"$",
"contentObject1",
"=",
"eZContentObject",
"::",
"fetchByNodeID",
"(",
"$",
"nodeID",
")",
";",
"$",
"contentObj... | Called when two nodes are swapped.
Simply re-index for now.
@todo when Solr supports it: update fields only
@param $nodeID
@param $selectedNodeID
@param $nodeIdList
@return void | [
"Called",
"when",
"two",
"nodes",
"are",
"swapped",
".",
"Simply",
"re",
"-",
"index",
"for",
"now",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1528-L1534 | train |
ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.pushElevateConfiguration | public function pushElevateConfiguration()
{
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
eZFindElevateConfiguration::synchronizeWithSolr( $shard );
}
return true;
}
else
{
return eZFindElevateConfiguration::synchronizeWithSolr( $this->Solr );
}
} | php | public function pushElevateConfiguration()
{
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
eZFindElevateConfiguration::synchronizeWithSolr( $shard );
}
return true;
}
else
{
return eZFindElevateConfiguration::synchronizeWithSolr( $this->Solr );
}
} | [
"public",
"function",
"pushElevateConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UseMultiLanguageCores",
"==",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"SolrLanguageShards",
"as",
"$",
"shard",
")",
"{",
"eZFindElevateConfiguration",
... | synchronises elevate configuration across language shards in case of
multiple lnguage indexes, or the default one
@TODO: handle exceptions properly | [
"synchronises",
"elevate",
"configuration",
"across",
"language",
"shards",
"in",
"case",
"of",
"multiple",
"lnguage",
"indexes",
"or",
"the",
"default",
"one"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1580-L1595 | train |
ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.run | public function run()
{
$this->Script->startup();
$this->Options = $this->Script->getOptions(
"[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql][clean][clean-all][conc:][php-exec:][commit-within:]",
"",
array(
'db-host' => "Database host",
'db-user' => "Database user",
'db-password' => "Database password",
'db-database' => "Database name",
'db-driver' => "Database driver",
'db-type' => "Database driver, alias for --db-driver",
'sql' => "Display sql queries",
'clean' => "Remove all search data of the current installation id before beginning indexing",
'clean-all' => "Remove all search data for all installations",
'conc' => 'Parallelization, number of concurent processes to use',
'php-exec' => 'Full path to PHP executable',
'commit-within' => 'Commit to Solr within this time in seconds (default '
. self::DEFAULT_COMMIT_WITHIN . ' seconds)',
)
);
$this->Script->initialize();
// check if ezfind is enabled and exit if not
if ( ! in_array( 'ezfind', eZExtension::activeExtensions() ) )
{
$this->CLI->error( 'eZ Find extension is not enabled and because of that index process will fail. Please enable it and run this script again.' );
$this->Script->shutdown( 0 );
}
// Fix siteaccess
$siteAccess = $this->Options['siteaccess'] ? $this->Options['siteaccess'] : false;
if ( $siteAccess )
{
$this->changeSiteAccessSetting( $siteAccess );
}
else
{
$this->CLI->warning( 'You did not specify a siteaccess. The admin siteaccess is a required option in most cases.' );
$input = readline( 'Are you sure the default siteaccess has all available languages defined? ([y] or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
}
// Check that Solr server is up and running
if ( !$this->checkSolrRunning() )
{
$this->Script->shutdown( 1 );
exit();
}
$this->initializeDB();
// call clean up routines which will deal with the CLI arguments themselves
$this->cleanUp();
$this->cleanUpAll();
if ( isset( $this->Options['commit-within'] )
&& is_numeric( $this->Options['commit-within'] ) )
{
$this->commitWithin = (int)$this->Options['commit-within'];
}
$this->CLI->output( 'Starting object re-indexing' );
// Get PHP executable from user.
$this->getPHPExecutable();
$this->runMain();
} | php | public function run()
{
$this->Script->startup();
$this->Options = $this->Script->getOptions(
"[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql][clean][clean-all][conc:][php-exec:][commit-within:]",
"",
array(
'db-host' => "Database host",
'db-user' => "Database user",
'db-password' => "Database password",
'db-database' => "Database name",
'db-driver' => "Database driver",
'db-type' => "Database driver, alias for --db-driver",
'sql' => "Display sql queries",
'clean' => "Remove all search data of the current installation id before beginning indexing",
'clean-all' => "Remove all search data for all installations",
'conc' => 'Parallelization, number of concurent processes to use',
'php-exec' => 'Full path to PHP executable',
'commit-within' => 'Commit to Solr within this time in seconds (default '
. self::DEFAULT_COMMIT_WITHIN . ' seconds)',
)
);
$this->Script->initialize();
// check if ezfind is enabled and exit if not
if ( ! in_array( 'ezfind', eZExtension::activeExtensions() ) )
{
$this->CLI->error( 'eZ Find extension is not enabled and because of that index process will fail. Please enable it and run this script again.' );
$this->Script->shutdown( 0 );
}
// Fix siteaccess
$siteAccess = $this->Options['siteaccess'] ? $this->Options['siteaccess'] : false;
if ( $siteAccess )
{
$this->changeSiteAccessSetting( $siteAccess );
}
else
{
$this->CLI->warning( 'You did not specify a siteaccess. The admin siteaccess is a required option in most cases.' );
$input = readline( 'Are you sure the default siteaccess has all available languages defined? ([y] or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
}
// Check that Solr server is up and running
if ( !$this->checkSolrRunning() )
{
$this->Script->shutdown( 1 );
exit();
}
$this->initializeDB();
// call clean up routines which will deal with the CLI arguments themselves
$this->cleanUp();
$this->cleanUpAll();
if ( isset( $this->Options['commit-within'] )
&& is_numeric( $this->Options['commit-within'] ) )
{
$this->commitWithin = (int)$this->Options['commit-within'];
}
$this->CLI->output( 'Starting object re-indexing' );
// Get PHP executable from user.
$this->getPHPExecutable();
$this->runMain();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"Script",
"->",
"startup",
"(",
")",
";",
"$",
"this",
"->",
"Options",
"=",
"$",
"this",
"->",
"Script",
"->",
"getOptions",
"(",
"\"[db-host:][db-user:][db-password:][db-database:][db-type:|db-driv... | Startup and run script. | [
"Startup",
"and",
"run",
"script",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L75-L149 | train |
ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.getPHPExecutable | protected function getPHPExecutable()
{
$validExecutable = false;
$output = array();
$exec = 'php';
if ( !empty( $this->Options['php-exec'] ) )
{
$exec = $this->Options['php-exec'];
}
exec( $exec . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $exec;
}
while( !$validExecutable )
{
$input = readline( 'Enter path to PHP-CLI executable ( or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
exec( $input . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $input;
}
}
} | php | protected function getPHPExecutable()
{
$validExecutable = false;
$output = array();
$exec = 'php';
if ( !empty( $this->Options['php-exec'] ) )
{
$exec = $this->Options['php-exec'];
}
exec( $exec . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $exec;
}
while( !$validExecutable )
{
$input = readline( 'Enter path to PHP-CLI executable ( or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
exec( $input . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $input;
}
}
} | [
"protected",
"function",
"getPHPExecutable",
"(",
")",
"{",
"$",
"validExecutable",
"=",
"false",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"exec",
"=",
"'php'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"Options",
"[",
"'php-... | Get PHP executable from user input. Exit if php executable cannot be
found and if no executable is entered. | [
"Get",
"PHP",
"executable",
"from",
"user",
"input",
".",
"Exit",
"if",
"php",
"executable",
"cannot",
"be",
"found",
"and",
"if",
"no",
"executable",
"is",
"entered",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L156-L189 | train |
ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.iterate | protected function iterate( $count = false )
{
if ( !$count )
{
$count = $this->Limit;
}
for ( $iterateCount = 0; $iterateCount < $count; ++$iterateCount )
{
if ( ++$this->IterateCount > $this->ObjectCount )
{
break;
}
$this->Script->iterate( $this->CLI, true );
}
} | php | protected function iterate( $count = false )
{
if ( !$count )
{
$count = $this->Limit;
}
for ( $iterateCount = 0; $iterateCount < $count; ++$iterateCount )
{
if ( ++$this->IterateCount > $this->ObjectCount )
{
break;
}
$this->Script->iterate( $this->CLI, true );
}
} | [
"protected",
"function",
"iterate",
"(",
"$",
"count",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"count",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"Limit",
";",
"}",
"for",
"(",
"$",
"iterateCount",
"=",
"0",
";",
"$",
"iterateCount",
"... | Iterate index counter
@param int $count | [
"Iterate",
"index",
"counter"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L335-L350 | train |
ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.forkAndExecute | protected function forkAndExecute( $nodeID, $offset, $limit )
{
eZDB::setInstance( null );
// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).
eZClusterFileHandler::preFork();
$pid = pcntl_fork();
// reinitialize DB after fork
$this->initializeDB();
if ( $pid == -1 )
{
die( 'could not fork' );
}
else if ( $pid )
{
// Main process
return $pid;
}
else
{
// We are the child process
if ( $this->execute( $nodeID, $offset, $limit ) > 0 )
{
$this->Script->shutdown( 0 );
}
else
{
$this->Script->shutdown( 3 );
}
}
} | php | protected function forkAndExecute( $nodeID, $offset, $limit )
{
eZDB::setInstance( null );
// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).
eZClusterFileHandler::preFork();
$pid = pcntl_fork();
// reinitialize DB after fork
$this->initializeDB();
if ( $pid == -1 )
{
die( 'could not fork' );
}
else if ( $pid )
{
// Main process
return $pid;
}
else
{
// We are the child process
if ( $this->execute( $nodeID, $offset, $limit ) > 0 )
{
$this->Script->shutdown( 0 );
}
else
{
$this->Script->shutdown( 3 );
}
}
} | [
"protected",
"function",
"forkAndExecute",
"(",
"$",
"nodeID",
",",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"eZDB",
"::",
"setInstance",
"(",
"null",
")",
";",
"// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).",
"eZClusterFileHandler... | Fork and execute
@param int $nodeid
@param int $offset
@param int $limit | [
"Fork",
"and",
"execute"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L359-L392 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.