repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php | HostConfiguration.compileAndWrite | public function compileAndWrite()
{
$this->configuration->compileAndWrite();
$this->cache = $this->configuration->getConfig();
$this->setHost($this->host);
} | php | public function compileAndWrite()
{
$this->configuration->compileAndWrite();
$this->cache = $this->configuration->getConfig();
$this->setHost($this->host);
} | [
"public",
"function",
"compileAndWrite",
"(",
")",
"{",
"$",
"this",
"->",
"configuration",
"->",
"compileAndWrite",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"=",
"$",
"this",
"->",
"configuration",
"->",
"getConfig",
"(",
")",
";",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/HostConfiguration.php#L176-L181 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/TaskManager/LiveInformation.php | LiveInformation.getManager | public function getManager($throwException = false)
{
$data = $this->query($throwException);
return [
'configuration' => $this->status->getStatus(),
'actual' => isset($data['manager']) ? TaskManagerStatus::STATUS_STARTED : TaskManagerStatus::STATUS_STOPPED,
'process-id' => isset($data['manager']) ? $data['manager']['process-id'] : null,
];
} | php | public function getManager($throwException = false)
{
$data = $this->query($throwException);
return [
'configuration' => $this->status->getStatus(),
'actual' => isset($data['manager']) ? TaskManagerStatus::STATUS_STARTED : TaskManagerStatus::STATUS_STOPPED,
'process-id' => isset($data['manager']) ? $data['manager']['process-id'] : null,
];
} | [
"public",
"function",
"getManager",
"(",
"$",
"throwException",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"throwException",
")",
";",
"return",
"[",
"'configuration'",
"=>",
"$",
"this",
"->",
"status",
"->",
"getSta... | Returns live informations about the task manager.
@return array | [
"Returns",
"live",
"informations",
"about",
"the",
"task",
"manager",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php#L33-L42 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/TaskManager/LiveInformation.php | LiveInformation.getTask | public function getTask(liveTask $task, $throwException = false)
{
$data = $this->query($throwException);
return $this->formatTask($task, $data);
} | php | public function getTask(liveTask $task, $throwException = false)
{
$data = $this->query($throwException);
return $this->formatTask($task, $data);
} | [
"public",
"function",
"getTask",
"(",
"liveTask",
"$",
"task",
",",
"$",
"throwException",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"throwException",
")",
";",
"return",
"$",
"this",
"->",
"formatTask",
"(",
"$",
... | Returns live informations about the given task.
@param liveTask $task
@param boolean $throwException
@return array | [
"Returns",
"live",
"informations",
"about",
"the",
"given",
"task",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php#L50-L55 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/TaskManager/LiveInformation.php | LiveInformation.getTasks | public function getTasks($tasks, $throwException = false)
{
$data = $this->query($throwException);
$ret = [];
foreach ($tasks as $task) {
$ret[$task->getId()] = $this->formatTask($task, $data);
}
return $ret;
} | php | public function getTasks($tasks, $throwException = false)
{
$data = $this->query($throwException);
$ret = [];
foreach ($tasks as $task) {
$ret[$task->getId()] = $this->formatTask($task, $data);
}
return $ret;
} | [
"public",
"function",
"getTasks",
"(",
"$",
"tasks",
",",
"$",
"throwException",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"throwException",
")",
";",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tasks... | Returns live informations about some tasks.
@param liveTask[] $tasks
@param boolean $throwException
@return array | [
"Returns",
"live",
"informations",
"about",
"some",
"tasks",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php#L65-L75 |
alchemy-fr/Phraseanet | lib/classes/recordutils/image.php | recordutils_image.stamp | public static function stamp(Application $app, \media_subdef $subdef)
{
static $palette;
if (null === $palette) {
$palette = new RGB();
}
$xmlToColor = function ($attr, $ret = [255, 255, 255]) use ($palette) {
try {
$alpha = 100;
$attr = explode(',', $attr);
if(count($attr) == 4) {
// 0..127 -> 100..0
$alpha = (int)((127 - (int)array_pop($attr)) / 1.27);
}
return $palette->color($attr, $alpha);
} catch (ImagineException $e) {
return $palette->color($ret);
}
};
$base_id = $subdef->get_record()->getBaseId();
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
return $subdef->getRealPath();
}
if (!$subdef->is_physically_present()) {
return $subdef->getRealPath();
}
$rotation = null;
try {
$image = $app->getMediaFromUri($subdef->getRealPath());
if (MediaInterface::TYPE_IMAGE === $image->getType()) {
$rotation = $image->getOrientation();
}
} catch (\Exception $e) {
// getting orientation failed but we don't care the reason
}
$domprefs = new DOMDocument();
if (false === $domprefs->loadXML($subdef->get_record()->getCollection()->get_prefs())) {
return $subdef->getRealPath();
}
if (false === $sxxml = simplexml_load_string($app['serializer.caption']->serialize($subdef->get_record()->get_caption(), CaptionSerializer::SERIALIZE_XML))) {
return $subdef->getRealPath();
}
$xpprefs = new DOMXPath($domprefs);
$stampNodes = $xpprefs->query('/baseprefs/stamp');
if ($stampNodes->length == 0) {
return $subdef->getRealPath();
}
$pathIn = $subdef->getRealPath();
$pathOut = $subdef->getStampRealPath();
$vars = $xpprefs->query('/baseprefs/stamp/*/var');
// no way to cache when date changes
for ($i = 0; $i < $vars->length; $i++) {
if (strtoupper($vars->item($i)->getAttribute('name')) == 'DATE') {
@unlink($pathOut);
break;
}
}
// get from cache ?
if (is_file($pathOut)) {
return $pathOut;
}
// open the document
$image_in = $app['imagine']->open($pathIn);
$image_size = $image_in->getSize();
switch ($rotation) {
case Image::ORIENTATION_90:
$image_width = $image_size->getHeight();
$image_height = $image_size->getWidth();
$image_in->rotate(90);
$rotation = '90';
break;
case Image::ORIENTATION_270:
$image_width = $image_size->getHeight();
$image_height = $image_size->getWidth();
$image_in->rotate(270);
break;
case Image::ORIENTATION_180:
$image_width = $image_size->getWidth();
$image_height = $image_size->getHeight();
$image_in->rotate(180);
break;
default:
$image_width = $image_size->getWidth();
$image_height = $image_size->getHeight();
break;
}
// open the logo
$logo_phywidth = $logo_phyheight = 0; // physical size
$logo_file = $app['root.path'] . '/config/stamp/' . $base_id;
try {
$logo_obj = $app['imagine']->open($logo_file);
$logo_size = $logo_obj->getSize();
$logo_phywidth = $logo_size->getWidth();
$logo_phyheight = $logo_size->getHeight();
} catch (ImagineException $e) {
}
$tables = [
'TOP' => ['h' => 0, 'rows' => []],
'TOP-OVER' => ['h' => 0, 'rows' => []],
'BOTTOM' => ['h' => 0, 'rows' => []],
'BOTTOM-OVER' => ['h' => 0, 'rows' => []]
];
for ($istamp = 0; $istamp < $stampNodes->length; $istamp++) {
$stamp = $stampNodes->item($istamp);
$stamp_background = $xmlToColor($stamp->getAttribute('background'), [255, 255, 255]);
$stamp_position = strtoupper(trim($stamp->getAttribute('position')));
if (!in_array($stamp_position, ['TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'])) {
$stamp_position = 'BOTTOM';
}
// replace "var" nodes with their value
$vars = $xpprefs->query('*/var', $stamp);
for ($i = 0; $i < $vars->length; $i++) {
$varval = '';
$n = $vars->item($i);
switch (strtoupper($n->getAttribute('name'))) {
case 'DATE':
if (!($format = $n->getAttribute('format'))) {
$format = 'Y/m/d H:i:s';
}
$varval = date($format);
@unlink($pathOut); // no cache possible when date changes
break;
case 'RECORD_ID':
$varval = $subdef->get_record()->getRecordId();
break;
}
$n->parentNode->replaceChild($domprefs->createTextNode($varval), $n);
}
// replace "field" nodes with their values
$fields = $xpprefs->query('*/field', $stamp);
for ($i = 0; $i < $fields->length; $i++) {
$fldval = '';
$n = $fields->item($i);
$fieldname = $n->getAttribute('name');
$x = $sxxml->description->{$fieldname};
if (is_array($x)) {
foreach ($x as $v) {
$fldval .= ( $fldval ? '; ' : '') . (string) $v;
}
} else {
$fldval .= ( $fldval ? '; ' : '') . (string) $x;
}
$n->parentNode->replaceChild($domprefs->createTextNode($fldval), $n);
}
$domprefs->normalizeDocument();
$text_width = $image_width;
$logopos = null;
// compute logo position / size
$logo_reswidth = 0;
$logo_resheight = 0;
if ($logo_phywidth > 0 && $logo_phyheight > 0) {
$v = $xpprefs->query('logo', $stamp);
if ($v->length > 0) {
$logo_reswidth = $logo_phywidth;
$logo_resheight = $logo_phyheight;
$logopos = @strtoupper($v->item(0)->getAttribute('position'));
if (($logowidth = trim($v->item(0)->getAttribute('width'))) != '') {
if (substr($logowidth, -1) == '%') {
$logo_reswidth = (int) ($logowidth * $image_width / 100);
} else {
$logo_reswidth = (int) $logowidth;
}
$logo_resheight = (int) ($logo_phyheight * ($logo_reswidth / $logo_phywidth));
}
if ($logopos == 'LEFT' || $logopos == 'RIGHT') {
if ($logo_reswidth > $image_width / 2) {
// logo too large, resize please
$logo_reswidth = (int) ($image_width / 2);
$logo_resheight = (int) ($logo_phyheight * ($logo_reswidth / $logo_phywidth));
}
$text_width -= $logo_reswidth;
if ($logopos == 'LEFT') {
$logo_xpos = 0;
} else {
$logo_xpos = ($image_width - $logo_reswidth);
}
}
}
}
// compute text blocks
$txth = 0;
$txtblock = [];
$texts = $xpprefs->query('text', $stamp);
$fontsize = "100%";
for ($i = 0; $i < $texts->length; $i++) {
if (($tmpfontsize = trim($texts->item($i)->getAttribute('size'))) != '') {
if (substr($tmpfontsize, -1) == '%') {
$tmpfontsize = (int) ($tmpfontsize * $image_width / 4000);
} else {
$tmpfontsize = (int) $tmpfontsize;
}
$fontsize = $tmpfontsize;
}
if ($fontsize < 2) {
$fontsize = 2;
} elseif ($fontsize > 300) {
$fontsize = 300;
}
$txtline = $texts->item($i)->nodeValue;
if ($txtline != '') {
$wrap = static::wrap($app['imagine'], $fontsize, 0, __DIR__ . '/arial.ttf', $txtline, $text_width);
$txtblock[] = [
'fontsize' => $fontsize,
'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), [0, 0, 0]),
'h' => $wrap['toth'],
'lines' => $wrap['l']
];
$txth += $wrap['toth'];
}
}
$stampheight = max($logo_resheight, $txth);
if ($stamp_position == 'TOP-OVER' || $stamp_position == 'BOTTOM-OVER') {
if ($tables[$stamp_position]['h'] + $stampheight > $image_height) {
$stampheight = $image_height - $tables[$stamp_position]['h'];
}
}
if ($stampheight <= 0) {
continue;
}
// create the block
$imfg = $app['imagine']->create(new Box($image_width, $stampheight), $stamp_background);
// copy the logo
if ($logo_reswidth > 0 && $logo_resheight > 0) {
if ($logo_reswidth != $logo_phywidth) {
$imfg->paste(
$logo_obj->copy()->resize(new Box($logo_reswidth, $logo_resheight)),
new Point($logo_xpos, 0)
);
} else {
$imfg->paste($logo_obj, new Point($logo_xpos, 0));
}
}
// fill with text
$draw = $imfg->draw();
$txt_ypos = 0;
foreach ($txtblock as $block) {
$font = $app['imagine']->font(__DIR__ . '/arial.ttf', $block['fontsize'], $block['fontcolor']);
foreach ($block['lines'] as $line) {
if ($line['t'] != '') {
$draw->text($line['t'], $font, new Point($logo_reswidth, $txt_ypos), 0);
}
$txt_ypos += $line['h'];
}
}
// memo into one of the 4 buffer
$tables[$stamp_position]['rows'][] = [
'x0' => 0,
'y0' => $tables[$stamp_position]['h'],
'w' => $image_width,
'h' => $stampheight,
'img' => $imfg
];
$tables[$stamp_position]['h'] += $stampheight;
}
$newh = $tables['TOP']['h'] + $image_height + $tables['BOTTOM']['h'];
// create the output image
$image_out = $app['imagine']->create(new Box($image_width, $newh), $palette->color("FFFFFF", 64));
// paste the input image into
$image_out->paste($image_in, new Point(0, $tables['TOP']['h']));
// fix the coordinates
foreach ($tables['TOP-OVER']['rows'] as $k => $row) {
$tables['TOP-OVER']['rows'][$k]['y0'] += $tables['TOP']['h'];
}
foreach ($tables['BOTTOM-OVER']['rows'] as $k => $row) {
$tables['BOTTOM-OVER']['rows'][$k]['y0'] += $tables['TOP']['h'] + $image_height - $tables['BOTTOM-OVER']['h'];
}
foreach ($tables['BOTTOM']['rows'] as $k => $row) {
$tables['BOTTOM']['rows'][$k]['y0'] += $tables['TOP']['h'] + $image_height;
}
// paste blocks
foreach (['TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'] as $ta) {
foreach ($tables[$ta]['rows'] as $row) {
if ($row['h'] > 0) {
$image_out->paste($row['img'], new Point($row['x0'], $row['y0']));
}
}
}
// save the output
$image_out->save($pathOut);
if (is_file($pathOut)) {
$writer = $app['exiftool.writer'];
// copy metadata to the stamped file if we can
if(method_exists($writer, "copy")) {
$writer->copy($subdef->getRealPath(), $pathOut);
}
return $pathOut;
}
return $subdef->getRealPath();
} | php | public static function stamp(Application $app, \media_subdef $subdef)
{
static $palette;
if (null === $palette) {
$palette = new RGB();
}
$xmlToColor = function ($attr, $ret = [255, 255, 255]) use ($palette) {
try {
$alpha = 100;
$attr = explode(',', $attr);
if(count($attr) == 4) {
// 0..127 -> 100..0
$alpha = (int)((127 - (int)array_pop($attr)) / 1.27);
}
return $palette->color($attr, $alpha);
} catch (ImagineException $e) {
return $palette->color($ret);
}
};
$base_id = $subdef->get_record()->getBaseId();
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
return $subdef->getRealPath();
}
if (!$subdef->is_physically_present()) {
return $subdef->getRealPath();
}
$rotation = null;
try {
$image = $app->getMediaFromUri($subdef->getRealPath());
if (MediaInterface::TYPE_IMAGE === $image->getType()) {
$rotation = $image->getOrientation();
}
} catch (\Exception $e) {
// getting orientation failed but we don't care the reason
}
$domprefs = new DOMDocument();
if (false === $domprefs->loadXML($subdef->get_record()->getCollection()->get_prefs())) {
return $subdef->getRealPath();
}
if (false === $sxxml = simplexml_load_string($app['serializer.caption']->serialize($subdef->get_record()->get_caption(), CaptionSerializer::SERIALIZE_XML))) {
return $subdef->getRealPath();
}
$xpprefs = new DOMXPath($domprefs);
$stampNodes = $xpprefs->query('/baseprefs/stamp');
if ($stampNodes->length == 0) {
return $subdef->getRealPath();
}
$pathIn = $subdef->getRealPath();
$pathOut = $subdef->getStampRealPath();
$vars = $xpprefs->query('/baseprefs/stamp/*/var');
// no way to cache when date changes
for ($i = 0; $i < $vars->length; $i++) {
if (strtoupper($vars->item($i)->getAttribute('name')) == 'DATE') {
@unlink($pathOut);
break;
}
}
// get from cache ?
if (is_file($pathOut)) {
return $pathOut;
}
// open the document
$image_in = $app['imagine']->open($pathIn);
$image_size = $image_in->getSize();
switch ($rotation) {
case Image::ORIENTATION_90:
$image_width = $image_size->getHeight();
$image_height = $image_size->getWidth();
$image_in->rotate(90);
$rotation = '90';
break;
case Image::ORIENTATION_270:
$image_width = $image_size->getHeight();
$image_height = $image_size->getWidth();
$image_in->rotate(270);
break;
case Image::ORIENTATION_180:
$image_width = $image_size->getWidth();
$image_height = $image_size->getHeight();
$image_in->rotate(180);
break;
default:
$image_width = $image_size->getWidth();
$image_height = $image_size->getHeight();
break;
}
// open the logo
$logo_phywidth = $logo_phyheight = 0; // physical size
$logo_file = $app['root.path'] . '/config/stamp/' . $base_id;
try {
$logo_obj = $app['imagine']->open($logo_file);
$logo_size = $logo_obj->getSize();
$logo_phywidth = $logo_size->getWidth();
$logo_phyheight = $logo_size->getHeight();
} catch (ImagineException $e) {
}
$tables = [
'TOP' => ['h' => 0, 'rows' => []],
'TOP-OVER' => ['h' => 0, 'rows' => []],
'BOTTOM' => ['h' => 0, 'rows' => []],
'BOTTOM-OVER' => ['h' => 0, 'rows' => []]
];
for ($istamp = 0; $istamp < $stampNodes->length; $istamp++) {
$stamp = $stampNodes->item($istamp);
$stamp_background = $xmlToColor($stamp->getAttribute('background'), [255, 255, 255]);
$stamp_position = strtoupper(trim($stamp->getAttribute('position')));
if (!in_array($stamp_position, ['TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'])) {
$stamp_position = 'BOTTOM';
}
// replace "var" nodes with their value
$vars = $xpprefs->query('*/var', $stamp);
for ($i = 0; $i < $vars->length; $i++) {
$varval = '';
$n = $vars->item($i);
switch (strtoupper($n->getAttribute('name'))) {
case 'DATE':
if (!($format = $n->getAttribute('format'))) {
$format = 'Y/m/d H:i:s';
}
$varval = date($format);
@unlink($pathOut); // no cache possible when date changes
break;
case 'RECORD_ID':
$varval = $subdef->get_record()->getRecordId();
break;
}
$n->parentNode->replaceChild($domprefs->createTextNode($varval), $n);
}
// replace "field" nodes with their values
$fields = $xpprefs->query('*/field', $stamp);
for ($i = 0; $i < $fields->length; $i++) {
$fldval = '';
$n = $fields->item($i);
$fieldname = $n->getAttribute('name');
$x = $sxxml->description->{$fieldname};
if (is_array($x)) {
foreach ($x as $v) {
$fldval .= ( $fldval ? '; ' : '') . (string) $v;
}
} else {
$fldval .= ( $fldval ? '; ' : '') . (string) $x;
}
$n->parentNode->replaceChild($domprefs->createTextNode($fldval), $n);
}
$domprefs->normalizeDocument();
$text_width = $image_width;
$logopos = null;
// compute logo position / size
$logo_reswidth = 0;
$logo_resheight = 0;
if ($logo_phywidth > 0 && $logo_phyheight > 0) {
$v = $xpprefs->query('logo', $stamp);
if ($v->length > 0) {
$logo_reswidth = $logo_phywidth;
$logo_resheight = $logo_phyheight;
$logopos = @strtoupper($v->item(0)->getAttribute('position'));
if (($logowidth = trim($v->item(0)->getAttribute('width'))) != '') {
if (substr($logowidth, -1) == '%') {
$logo_reswidth = (int) ($logowidth * $image_width / 100);
} else {
$logo_reswidth = (int) $logowidth;
}
$logo_resheight = (int) ($logo_phyheight * ($logo_reswidth / $logo_phywidth));
}
if ($logopos == 'LEFT' || $logopos == 'RIGHT') {
if ($logo_reswidth > $image_width / 2) {
// logo too large, resize please
$logo_reswidth = (int) ($image_width / 2);
$logo_resheight = (int) ($logo_phyheight * ($logo_reswidth / $logo_phywidth));
}
$text_width -= $logo_reswidth;
if ($logopos == 'LEFT') {
$logo_xpos = 0;
} else {
$logo_xpos = ($image_width - $logo_reswidth);
}
}
}
}
// compute text blocks
$txth = 0;
$txtblock = [];
$texts = $xpprefs->query('text', $stamp);
$fontsize = "100%";
for ($i = 0; $i < $texts->length; $i++) {
if (($tmpfontsize = trim($texts->item($i)->getAttribute('size'))) != '') {
if (substr($tmpfontsize, -1) == '%') {
$tmpfontsize = (int) ($tmpfontsize * $image_width / 4000);
} else {
$tmpfontsize = (int) $tmpfontsize;
}
$fontsize = $tmpfontsize;
}
if ($fontsize < 2) {
$fontsize = 2;
} elseif ($fontsize > 300) {
$fontsize = 300;
}
$txtline = $texts->item($i)->nodeValue;
if ($txtline != '') {
$wrap = static::wrap($app['imagine'], $fontsize, 0, __DIR__ . '/arial.ttf', $txtline, $text_width);
$txtblock[] = [
'fontsize' => $fontsize,
'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), [0, 0, 0]),
'h' => $wrap['toth'],
'lines' => $wrap['l']
];
$txth += $wrap['toth'];
}
}
$stampheight = max($logo_resheight, $txth);
if ($stamp_position == 'TOP-OVER' || $stamp_position == 'BOTTOM-OVER') {
if ($tables[$stamp_position]['h'] + $stampheight > $image_height) {
$stampheight = $image_height - $tables[$stamp_position]['h'];
}
}
if ($stampheight <= 0) {
continue;
}
// create the block
$imfg = $app['imagine']->create(new Box($image_width, $stampheight), $stamp_background);
// copy the logo
if ($logo_reswidth > 0 && $logo_resheight > 0) {
if ($logo_reswidth != $logo_phywidth) {
$imfg->paste(
$logo_obj->copy()->resize(new Box($logo_reswidth, $logo_resheight)),
new Point($logo_xpos, 0)
);
} else {
$imfg->paste($logo_obj, new Point($logo_xpos, 0));
}
}
// fill with text
$draw = $imfg->draw();
$txt_ypos = 0;
foreach ($txtblock as $block) {
$font = $app['imagine']->font(__DIR__ . '/arial.ttf', $block['fontsize'], $block['fontcolor']);
foreach ($block['lines'] as $line) {
if ($line['t'] != '') {
$draw->text($line['t'], $font, new Point($logo_reswidth, $txt_ypos), 0);
}
$txt_ypos += $line['h'];
}
}
// memo into one of the 4 buffer
$tables[$stamp_position]['rows'][] = [
'x0' => 0,
'y0' => $tables[$stamp_position]['h'],
'w' => $image_width,
'h' => $stampheight,
'img' => $imfg
];
$tables[$stamp_position]['h'] += $stampheight;
}
$newh = $tables['TOP']['h'] + $image_height + $tables['BOTTOM']['h'];
// create the output image
$image_out = $app['imagine']->create(new Box($image_width, $newh), $palette->color("FFFFFF", 64));
// paste the input image into
$image_out->paste($image_in, new Point(0, $tables['TOP']['h']));
// fix the coordinates
foreach ($tables['TOP-OVER']['rows'] as $k => $row) {
$tables['TOP-OVER']['rows'][$k]['y0'] += $tables['TOP']['h'];
}
foreach ($tables['BOTTOM-OVER']['rows'] as $k => $row) {
$tables['BOTTOM-OVER']['rows'][$k]['y0'] += $tables['TOP']['h'] + $image_height - $tables['BOTTOM-OVER']['h'];
}
foreach ($tables['BOTTOM']['rows'] as $k => $row) {
$tables['BOTTOM']['rows'][$k]['y0'] += $tables['TOP']['h'] + $image_height;
}
// paste blocks
foreach (['TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'] as $ta) {
foreach ($tables[$ta]['rows'] as $row) {
if ($row['h'] > 0) {
$image_out->paste($row['img'], new Point($row['x0'], $row['y0']));
}
}
}
// save the output
$image_out->save($pathOut);
if (is_file($pathOut)) {
$writer = $app['exiftool.writer'];
// copy metadata to the stamped file if we can
if(method_exists($writer, "copy")) {
$writer->copy($subdef->getRealPath(), $pathOut);
}
return $pathOut;
}
return $subdef->getRealPath();
} | [
"public",
"static",
"function",
"stamp",
"(",
"Application",
"$",
"app",
",",
"\\",
"media_subdef",
"$",
"subdef",
")",
"{",
"static",
"$",
"palette",
";",
"if",
"(",
"null",
"===",
"$",
"palette",
")",
"{",
"$",
"palette",
"=",
"new",
"RGB",
"(",
")... | @param Application $app
@param \media_subdef $subdef
@return string The path to the stamped file | [
"@param",
"Application",
"$app",
"@param",
"\\",
"media_subdef",
"$subdef"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/recordutils/image.php#L30-L367 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Border/Attribute/Factory.php | Factory.getFileAttribute | public static function getFileAttribute(Application $app, $name, $serialized)
{
switch ($name)
{
case AttributeInterface::NAME_METADATA:
return Metadata::loadFromString($app, $serialized);
case AttributeInterface::NAME_STORY:
return Story::loadFromString($app, $serialized);
case AttributeInterface::NAME_METAFIELD:
return MetaField::loadFromString($app, $serialized);
case AttributeInterface::NAME_STATUS:
return Status::loadFromString($app, $serialized);
}
throw new \InvalidArgumentException(sprintf('Unknown attribute %s', $name));
} | php | public static function getFileAttribute(Application $app, $name, $serialized)
{
switch ($name)
{
case AttributeInterface::NAME_METADATA:
return Metadata::loadFromString($app, $serialized);
case AttributeInterface::NAME_STORY:
return Story::loadFromString($app, $serialized);
case AttributeInterface::NAME_METAFIELD:
return MetaField::loadFromString($app, $serialized);
case AttributeInterface::NAME_STATUS:
return Status::loadFromString($app, $serialized);
}
throw new \InvalidArgumentException(sprintf('Unknown attribute %s', $name));
} | [
"public",
"static",
"function",
"getFileAttribute",
"(",
"Application",
"$",
"app",
",",
"$",
"name",
",",
"$",
"serialized",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"AttributeInterface",
"::",
"NAME_METADATA",
":",
"return",
"Metadata",
"::"... | Build a file package Attribute
@param Application $app Application context
@param string $name The name of the attribute, one of the
AttributeInterface::NAME_* constants
@param string $serialized The serialized value of the attribute
(AttributeInterface::asString result)
@return AttributeInterface The attribute
@throws \InvalidArgumentException | [
"Build",
"a",
"file",
"package",
"Attribute"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Attribute/Factory.php#L34-L49 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Filesystem/FilesystemService.php | FilesystemService.writeMediaSourceFile | public function writeMediaSourceFile(\databox $databox, $source, $filename)
{
$realPath = $this->generateDataboxDocumentBasePath($databox) . $filename;
$this->filesystem->copy($source, $realPath, true);
$this->filesystem->chmod($realPath, 0760);
return $realPath;
} | php | public function writeMediaSourceFile(\databox $databox, $source, $filename)
{
$realPath = $this->generateDataboxDocumentBasePath($databox) . $filename;
$this->filesystem->copy($source, $realPath, true);
$this->filesystem->chmod($realPath, 0760);
return $realPath;
} | [
"public",
"function",
"writeMediaSourceFile",
"(",
"\\",
"databox",
"$",
"databox",
",",
"$",
"source",
",",
"$",
"filename",
")",
"{",
"$",
"realPath",
"=",
"$",
"this",
"->",
"generateDataboxDocumentBasePath",
"(",
"$",
"databox",
")",
".",
"$",
"filename"... | Write Media source file with given filename
@param \databox $databox
@param string $source
@param string $filename
@return string | [
"Write",
"Media",
"source",
"file",
"with",
"given",
"filename"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php#L135-L143 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Filesystem/FilesystemService.php | FilesystemService.getExtensionFromSpec | private function getExtensionFromSpec(SpecificationInterface $spec)
{
switch ($spec->getType()) {
case SpecificationInterface::TYPE_IMAGE:
return $this->getExtensionFromImageCodec($spec->getImageCodec());
case SpecificationInterface::TYPE_ANIMATION:
return 'gif';
case SpecificationInterface::TYPE_AUDIO:
return $this->getExtensionFromAudioCodec($spec->getAudioCodec());
case SpecificationInterface::TYPE_VIDEO:
return $this->getExtensionFromVideoCodec($spec->getVideoCodec());
case SpecificationInterface::TYPE_SWF:
return 'swf';
case PdfSpecification::TYPE_PDF:
return 'pdf';
}
return null;
} | php | private function getExtensionFromSpec(SpecificationInterface $spec)
{
switch ($spec->getType()) {
case SpecificationInterface::TYPE_IMAGE:
return $this->getExtensionFromImageCodec($spec->getImageCodec());
case SpecificationInterface::TYPE_ANIMATION:
return 'gif';
case SpecificationInterface::TYPE_AUDIO:
return $this->getExtensionFromAudioCodec($spec->getAudioCodec());
case SpecificationInterface::TYPE_VIDEO:
return $this->getExtensionFromVideoCodec($spec->getVideoCodec());
case SpecificationInterface::TYPE_SWF:
return 'swf';
case PdfSpecification::TYPE_PDF:
return 'pdf';
}
return null;
} | [
"private",
"function",
"getExtensionFromSpec",
"(",
"SpecificationInterface",
"$",
"spec",
")",
"{",
"switch",
"(",
"$",
"spec",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"SpecificationInterface",
"::",
"TYPE_IMAGE",
":",
"return",
"$",
"this",
"->",
"getEx... | Get the extension from MediaAlchemyst specs
@param SpecificationInterface $spec
@return string | [
"Get",
"the",
"extension",
"from",
"MediaAlchemyst",
"specs"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php#L168-L186 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php | FeedEntry.isPublisher | public function isPublisher(User $user)
{
if ($this->publisher) {
if ($this->publisher->getUser()->getId() === $user->getId()) {
return true;
}
}
return false;
} | php | public function isPublisher(User $user)
{
if ($this->publisher) {
if ($this->publisher->getUser()->getId() === $user->getId()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isPublisher",
"(",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"publisher",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"publisher",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
"===",
"$",
"user",
"->",
... | Returns a boolean indicating whether the given User is the publisher of the entry.
@param User $user
@return boolean | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"given",
"User",
"is",
"the",
"publisher",
"of",
"the",
"entry",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php#L322-L331 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php | FeedEntry.getItem | public function getItem($id)
{
foreach ($this->items as $item) {
if ($item->getId() == $id) {
return ($item);
}
}
return null;
} | php | public function getItem($id)
{
foreach ($this->items as $item) {
if ($item->getId() == $id) {
return ($item);
}
}
return null;
} | [
"public",
"function",
"getItem",
"(",
"$",
"id",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"getId",
"(",
")",
"==",
"$",
"id",
")",
"{",
"return",
"(",
"$",
"item",
")",
"... | Returns the item from a given id.
@param int $id
@return null|FeedItem | [
"Returns",
"the",
"item",
"from",
"a",
"given",
"id",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php#L340-L349 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Command/Setup/Install.php | Install.doExecute | protected function doExecute(InputInterface $input, OutputInterface $output)
{
/** @var DialogHelper $dialog */
$dialog = $this->getHelperSet()->get('dialog');
$output->writeln("<comment>
,-._.-._.-._.-._.-.
`-. ,-'
.----------------------------------------------. | |
| | | |
| Hello ! | | |
| | | |
| You are on your way to install Phraseanet, | ,';\".________.-.
| You will need access to 2 MySQL databases. | ;';_' )]
| | ; `-|
| `. `T- |
`----------------------------------------------._ \ | |
`-; | |
|..________..-|
/\/ |________..|
,'`./ >,( |
\_.-|_/,-/ ii | |
`.\"' `-/ .-\"\"\"|| |
/`^\"-; | ||____|
/ / `.__/ | ||
/ | ||
| ||
</comment>"
);
if (!$input->getOption('yes') && !$input->getOption('appbox')) {
$continue = $dialog->askConfirmation($output, 'Do you have these two DB handy ? (N/y)', false);
if (!$continue) {
$output->writeln("See you later !");
return 0;
}
}
$serverName = $this->getServerName($input, $output, $dialog);
$abConn = $this->getABConn($input, $output, $dialog, $serverName);
if(!$abConn) {
return 1; // no ab is fatal
}
list($dbConn, $templateName) = $this->getDBConn($input, $output, $abConn, $dialog);
list($email, $password) = $this->getCredentials($input, $output, $dialog);
$dataPath = $this->getDataPath($input, $output, $dialog);
if (!$input->getOption('yes')) {
$continue = $dialog->askConfirmation($output, "<question>Phraseanet is going to be installed, continue ? (N/y)</question>", false);
if (!$continue) {
$output->writeln("See you later !");
return 0;
}
}
$this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $templateName, $this->detectBinaries());
if (null !== $this->getApplication()) {
$command = $this->getApplication()->find('crossdomain:generate');
$command->run(new ArrayInput([
'command' => 'crossdomain:generate'
]), $output);
}
$output->writeln("<info>Install successful !</info>");
return 0;
} | php | protected function doExecute(InputInterface $input, OutputInterface $output)
{
/** @var DialogHelper $dialog */
$dialog = $this->getHelperSet()->get('dialog');
$output->writeln("<comment>
,-._.-._.-._.-._.-.
`-. ,-'
.----------------------------------------------. | |
| | | |
| Hello ! | | |
| | | |
| You are on your way to install Phraseanet, | ,';\".________.-.
| You will need access to 2 MySQL databases. | ;';_' )]
| | ; `-|
| `. `T- |
`----------------------------------------------._ \ | |
`-; | |
|..________..-|
/\/ |________..|
,'`./ >,( |
\_.-|_/,-/ ii | |
`.\"' `-/ .-\"\"\"|| |
/`^\"-; | ||____|
/ / `.__/ | ||
/ | ||
| ||
</comment>"
);
if (!$input->getOption('yes') && !$input->getOption('appbox')) {
$continue = $dialog->askConfirmation($output, 'Do you have these two DB handy ? (N/y)', false);
if (!$continue) {
$output->writeln("See you later !");
return 0;
}
}
$serverName = $this->getServerName($input, $output, $dialog);
$abConn = $this->getABConn($input, $output, $dialog, $serverName);
if(!$abConn) {
return 1; // no ab is fatal
}
list($dbConn, $templateName) = $this->getDBConn($input, $output, $abConn, $dialog);
list($email, $password) = $this->getCredentials($input, $output, $dialog);
$dataPath = $this->getDataPath($input, $output, $dialog);
if (!$input->getOption('yes')) {
$continue = $dialog->askConfirmation($output, "<question>Phraseanet is going to be installed, continue ? (N/y)</question>", false);
if (!$continue) {
$output->writeln("See you later !");
return 0;
}
}
$this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $templateName, $this->detectBinaries());
if (null !== $this->getApplication()) {
$command = $this->getApplication()->find('crossdomain:generate');
$command->run(new ArrayInput([
'command' => 'crossdomain:generate'
]), $output);
}
$output->writeln("<info>Install successful !</info>");
return 0;
} | [
"protected",
"function",
"doExecute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"/** @var DialogHelper $dialog */",
"$",
"dialog",
"=",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"get",
"(",
"'dialog'",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/Setup/Install.php#L73-L146 |
alchemy-fr/Phraseanet | lib/classes/unicode.php | unicode.convert | public function convert($string, $target)
{
$ok_methods = [self::CONVERT_TO_LC, self::CONVERT_TO_ND, self::CONVERT_TO_LCND];
if (!in_array($target, $ok_methods)) {
throw new Exception_InvalidArgument(
sprintf('Invalid argument 2 "%s", valid values are [%s].'
, $target
, implode('|', $ok_methods)
)
);
}
if (function_exists('phrasea_utf8_convert_to')) {
return phrasea_utf8_convert_to($string, $target);
}
$out = '';
$_map = $this->getMap($target); // faster in loop
$length = mb_strlen($string, 'UTF-8');
for ($i = 0; $i < $length; $i++) {
if (true === array_key_exists(($c = mb_substr($string, $i, 1, 'UTF-8')), $_map)) {
$out .= $_map[$c];
} else {
$out .= $c;
}
}
return $out;
} | php | public function convert($string, $target)
{
$ok_methods = [self::CONVERT_TO_LC, self::CONVERT_TO_ND, self::CONVERT_TO_LCND];
if (!in_array($target, $ok_methods)) {
throw new Exception_InvalidArgument(
sprintf('Invalid argument 2 "%s", valid values are [%s].'
, $target
, implode('|', $ok_methods)
)
);
}
if (function_exists('phrasea_utf8_convert_to')) {
return phrasea_utf8_convert_to($string, $target);
}
$out = '';
$_map = $this->getMap($target); // faster in loop
$length = mb_strlen($string, 'UTF-8');
for ($i = 0; $i < $length; $i++) {
if (true === array_key_exists(($c = mb_substr($string, $i, 1, 'UTF-8')), $_map)) {
$out .= $_map[$c];
} else {
$out .= $c;
}
}
return $out;
} | [
"public",
"function",
"convert",
"(",
"$",
"string",
",",
"$",
"target",
")",
"{",
"$",
"ok_methods",
"=",
"[",
"self",
"::",
"CONVERT_TO_LC",
",",
"self",
"::",
"CONVERT_TO_ND",
",",
"self",
"::",
"CONVERT_TO_LCND",
"]",
";",
"if",
"(",
"!",
"in_array",... | Converts a string
@param string $string
@param string $target One of the unicode::CONVERT_TO_* constants
@return string
@throws Exception_InvalidArgument | [
"Converts",
"a",
"string"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/unicode.php#L1587-L1616 |
alchemy-fr/Phraseanet | lib/classes/unicode.php | unicode.toUTF8 | public function toUTF8($string)
{
/**
* (8x except 85, 8C) + (9x except 9C) + (BC, BD, BE)
*/
static $macchars = "\x81\x82\x83\x84\x86\x87\x88\x89\x8A\x8B\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9D\x9E\x9F\xBC\xBD\xBE";
if (mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') == $string) {
$mac = mb_convert_encoding($string, 'windows-1252', 'UTF-8');
for ($i = strlen($mac); $i;) {
if (strpos($macchars, $mac[ -- $i]) !== false) {
return(iconv('MACINTOSH', 'UTF-8', $mac));
}
}
return($string);
} else {
for ($i = strlen($string); $i;) {
if (strpos($macchars, $string[ -- $i]) !== false) {
return(iconv('MACINTOSH', 'UTF-8', $string));
}
}
return(iconv('windows-1252', 'UTF-8', $string));
}
} | php | public function toUTF8($string)
{
/**
* (8x except 85, 8C) + (9x except 9C) + (BC, BD, BE)
*/
static $macchars = "\x81\x82\x83\x84\x86\x87\x88\x89\x8A\x8B\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9D\x9E\x9F\xBC\xBD\xBE";
if (mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') == $string) {
$mac = mb_convert_encoding($string, 'windows-1252', 'UTF-8');
for ($i = strlen($mac); $i;) {
if (strpos($macchars, $mac[ -- $i]) !== false) {
return(iconv('MACINTOSH', 'UTF-8', $mac));
}
}
return($string);
} else {
for ($i = strlen($string); $i;) {
if (strpos($macchars, $string[ -- $i]) !== false) {
return(iconv('MACINTOSH', 'UTF-8', $string));
}
}
return(iconv('windows-1252', 'UTF-8', $string));
}
} | [
"public",
"function",
"toUTF8",
"(",
"$",
"string",
")",
"{",
"/**\n * (8x except 85, 8C) + (9x except 9C) + (BC, BD, BE)\n */",
"static",
"$",
"macchars",
"=",
"\"\\x81\\x82\\x83\\x84\\x86\\x87\\x88\\x89\\x8A\\x8B\\x8D\\x8E\\x8F\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98... | Guess the charset of a string and returns the UTF-8 version
@param string $string
@return string | [
"Guess",
"the",
"charset",
"of",
"a",
"string",
"and",
"returns",
"the",
"UTF",
"-",
"8",
"version"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/unicode.php#L1685-L1710 |
alchemy-fr/Phraseanet | lib/classes/unicode.php | unicode.substituteCtrlCharacters | public function substituteCtrlCharacters($string, $substitution = '_')
{
static $chars_in = null;
if (is_null($chars_in)) {
$chars_in = [];
for ($cc = 0; $cc < 32; $cc ++) {
if (in_array($cc, [9, 10, 13])) {
continue;
}
$chars_in[] = chr($cc);
}
}
return str_replace($chars_in, $substitution, $string);
} | php | public function substituteCtrlCharacters($string, $substitution = '_')
{
static $chars_in = null;
if (is_null($chars_in)) {
$chars_in = [];
for ($cc = 0; $cc < 32; $cc ++) {
if (in_array($cc, [9, 10, 13])) {
continue;
}
$chars_in[] = chr($cc);
}
}
return str_replace($chars_in, $substitution, $string);
} | [
"public",
"function",
"substituteCtrlCharacters",
"(",
"$",
"string",
",",
"$",
"substitution",
"=",
"'_'",
")",
"{",
"static",
"$",
"chars_in",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"chars_in",
")",
")",
"{",
"$",
"chars_in",
"=",
"[",
"]"... | Removes ctrl chars (tous < 32 sauf 9,10,13)
@param string $string
@param string $substitution
@return string | [
"Removes",
"ctrl",
"chars",
"(",
"tous",
"<",
"32",
"sauf",
"9",
"10",
"13",
")"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/unicode.php#L1720-L1738 |
alchemy-fr/Phraseanet | lib/classes/unicode.php | unicode.parseDate | public function parseDate($date)
{
$date = str_replace(['-', ':', '/', '.'], ' ', $date);
$date_yyyy = $date_mm = $date_dd = $date_hh = $date_ii = $date_ss = 0;
switch (sscanf($date, '%d %d %d %d %d %d', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii, $date_ss)) {
case 1:
$date = sprintf('%04d/00/00 00:00:00', $date_yyyy);
break;
case 2:
$date = sprintf('%04d/%02d/00 00:00:00', $date_yyyy, $date_mm);
break;
case 3:
$date = sprintf('%04d/%02d/%02d 00:00:00', $date_yyyy, $date_mm, $date_dd);
break;
case 4:
$date = sprintf('%04d/%02d/%02d %02d:00:00', $date_yyyy, $date_mm, $date_dd, $date_hh);
break;
case 5:
$date = sprintf('%04d/%02d/%02d %02d:%02d:00', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii);
break;
case 6:
$date = sprintf('%04d/%02d/%02d %02d:%02d:%02d', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii, $date_ss);
break;
default:
$date = '0000/00/00 00:00:00';
}
return $date;
} | php | public function parseDate($date)
{
$date = str_replace(['-', ':', '/', '.'], ' ', $date);
$date_yyyy = $date_mm = $date_dd = $date_hh = $date_ii = $date_ss = 0;
switch (sscanf($date, '%d %d %d %d %d %d', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii, $date_ss)) {
case 1:
$date = sprintf('%04d/00/00 00:00:00', $date_yyyy);
break;
case 2:
$date = sprintf('%04d/%02d/00 00:00:00', $date_yyyy, $date_mm);
break;
case 3:
$date = sprintf('%04d/%02d/%02d 00:00:00', $date_yyyy, $date_mm, $date_dd);
break;
case 4:
$date = sprintf('%04d/%02d/%02d %02d:00:00', $date_yyyy, $date_mm, $date_dd, $date_hh);
break;
case 5:
$date = sprintf('%04d/%02d/%02d %02d:%02d:00', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii);
break;
case 6:
$date = sprintf('%04d/%02d/%02d %02d:%02d:%02d', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii, $date_ss);
break;
default:
$date = '0000/00/00 00:00:00';
}
return $date;
} | [
"public",
"function",
"parseDate",
"(",
"$",
"date",
")",
"{",
"$",
"date",
"=",
"str_replace",
"(",
"[",
"'-'",
",",
"':'",
",",
"'/'",
",",
"'.'",
"]",
",",
"' '",
",",
"$",
"date",
")",
";",
"$",
"date_yyyy",
"=",
"$",
"date_mm",
"=",
"$",
"... | Parse a string and try to return the date normalized
@example usage :
//returns '2012/00/00 00:00:00'
$unicode->parseDate('2012');
@todo timezonify
@param string $date
@return string | [
"Parse",
"a",
"string",
"and",
"try",
"to",
"return",
"the",
"date",
"normalized"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/unicode.php#L1753-L1782 |
alchemy-fr/Phraseanet | lib/classes/patch/390alpha8a.php | patch_390alpha8a.apply | public function apply(base $appbox, Application $app)
{
$sql = 'DELETE FROM Tasks';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'SELECT task_id, active, crashed, name, class, settings FROM task2';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
try {
$job = $this->createJob($app, $row['class']);
} catch (\RuntimeException $e) {
continue;
}
$settings = simplexml_load_string($row['settings']);
$period = $job->getEditor()->getDefaultPeriod();
if ($settings->period) {
$period = (int) $settings->period;
unset($settings->period);
$row['settings'] = $settings->asXML();
}
$task = new Task();
$task->setCrashed($row['crashed'])
->setJobId($job->getJobId())
->setName($row['name'])
->setPeriod($period)
->setSettings($row['settings'])
->setStatus($row['active'] ? Task::STATUS_STARTED : Task::STATUS_STOPPED);
$app['orm.em']->persist($task);
}
$app['orm.em']->flush();
} | php | public function apply(base $appbox, Application $app)
{
$sql = 'DELETE FROM Tasks';
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'SELECT task_id, active, crashed, name, class, settings FROM task2';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
try {
$job = $this->createJob($app, $row['class']);
} catch (\RuntimeException $e) {
continue;
}
$settings = simplexml_load_string($row['settings']);
$period = $job->getEditor()->getDefaultPeriod();
if ($settings->period) {
$period = (int) $settings->period;
unset($settings->period);
$row['settings'] = $settings->asXML();
}
$task = new Task();
$task->setCrashed($row['crashed'])
->setJobId($job->getJobId())
->setName($row['name'])
->setPeriod($period)
->setSettings($row['settings'])
->setStatus($row['active'] ? Task::STATUS_STARTED : Task::STATUS_STOPPED);
$app['orm.em']->persist($task);
}
$app['orm.em']->flush();
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"sql",
"=",
"'DELETE FROM Tasks'",
";",
"$",
"stmt",
"=",
"$",
"app",
"->",
"getApplicationBox",
"(",
")",
"->",
"get_connection",
"(",
")",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/390alpha8a.php#L58-L97 |
alchemy-fr/Phraseanet | lib/classes/patch/380alpha10a.php | patch_380alpha10a.apply | public function apply(base $appbox, Application $app)
{
$sql = 'SELECT id, `usage`
FROM `order`';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE `order` SET `usage` = :usage
WHERE id = :id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
$stmt->execute([
':usage' => strip_tags($row['usage']),
':id' => $row['id'],
]);
}
$stmt->closeCursor();
return true;
} | php | public function apply(base $appbox, Application $app)
{
$sql = 'SELECT id, `usage`
FROM `order`';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE `order` SET `usage` = :usage
WHERE id = :id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
$stmt->execute([
':usage' => strip_tags($row['usage']),
':id' => $row['id'],
]);
}
$stmt->closeCursor();
return true;
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"sql",
"=",
"'SELECT id, `usage`\n FROM `order`'",
";",
"$",
"stmt",
"=",
"$",
"appbox",
"->",
"get_connection",
"(",
")",
"->",
"prepare",... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/380alpha10a.php#L49-L72 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Controller/Prod/EditController.php | EditController.presetsLoadAction | public function presetsLoadAction($preset_id)
{
$ret = [];
$preset = $this->findPresetOr404($preset_id);
$fields = [];
foreach ($preset->getData() as $field) {
$fields[$field['name']] = $field['value'];
}
$ret['fields'] = $fields;
return $this->app->json($ret);
} | php | public function presetsLoadAction($preset_id)
{
$ret = [];
$preset = $this->findPresetOr404($preset_id);
$fields = [];
foreach ($preset->getData() as $field) {
$fields[$field['name']] = $field['value'];
}
$ret['fields'] = $fields;
return $this->app->json($ret);
} | [
"public",
"function",
"presetsLoadAction",
"(",
"$",
"preset_id",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"preset",
"=",
"$",
"this",
"->",
"findPresetOr404",
"(",
"$",
"preset_id",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
... | route GET "../prod/records/edit/presets/{preset_id}"
@param int $preset_id
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"route",
"GET",
"..",
"/",
"prod",
"/",
"records",
"/",
"edit",
"/",
"presets",
"/",
"{",
"preset_id",
"}"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/EditController.php#L416-L430 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Controller/Prod/EditController.php | EditController.presetsListAction | public function presetsListAction(Request $request)
{
$sbas_id = $request->get('sbas_id');
$user = $this->getAuthenticatedUser();
$ret = [];
$ret['html'] = $this->getPresetHTMLList($sbas_id, $user);
return $this->app->json($ret);
} | php | public function presetsListAction(Request $request)
{
$sbas_id = $request->get('sbas_id');
$user = $this->getAuthenticatedUser();
$ret = [];
$ret['html'] = $this->getPresetHTMLList($sbas_id, $user);
return $this->app->json($ret);
} | [
"public",
"function",
"presetsListAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"sbas_id",
"=",
"$",
"request",
"->",
"get",
"(",
"'sbas_id'",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getAuthenticatedUser",
"(",
")",
";",
"$",
"ret",
"... | route GET "../prod/records/edit/presets"
@param Request $request
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"route",
"GET",
"..",
"/",
"prod",
"/",
"records",
"/",
"edit",
"/",
"presets"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/EditController.php#L438-L448 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Controller/Prod/EditController.php | EditController.presetsDeleteAction | public function presetsDeleteAction($preset_id)
{
$user = $this->getAuthenticatedUser();
$ret = [];
$preset = $this->findPresetOr404($preset_id);
$sbas_id = $preset->getSbasId();
$this->getPresetManipulator()->delete($preset);
$ret['html'] = $this->getPresetHTMLList($sbas_id, $user);
return $this->app->json($ret);
} | php | public function presetsDeleteAction($preset_id)
{
$user = $this->getAuthenticatedUser();
$ret = [];
$preset = $this->findPresetOr404($preset_id);
$sbas_id = $preset->getSbasId();
$this->getPresetManipulator()->delete($preset);
$ret['html'] = $this->getPresetHTMLList($sbas_id, $user);
return $this->app->json($ret);
} | [
"public",
"function",
"presetsDeleteAction",
"(",
"$",
"preset_id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getAuthenticatedUser",
"(",
")",
";",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"preset",
"=",
"$",
"this",
"->",
"findPresetOr404",
"(",
"$"... | route DELETE "../prod/records/edit/presets/{preset_id}"
@param int $preset_id
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"route",
"DELETE",
"..",
"/",
"prod",
"/",
"records",
"/",
"edit",
"/",
"presets",
"/",
"{",
"preset_id",
"}"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/EditController.php#L456-L470 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Controller/Prod/EditController.php | EditController.presetsSaveAction | public function presetsSaveAction(Request $request)
{
$sbas_id = $request->get('sbas_id');
$user = $this->getAuthenticatedUser();
$ret = [];
$this->getPresetManipulator()->create(
$user,
$sbas_id,
$request->get('title'),
$request->get('fields')
);
$ret['html'] = $this->getPresetHTMLList($sbas_id, $user);
return $this->app->json($ret);
} | php | public function presetsSaveAction(Request $request)
{
$sbas_id = $request->get('sbas_id');
$user = $this->getAuthenticatedUser();
$ret = [];
$this->getPresetManipulator()->create(
$user,
$sbas_id,
$request->get('title'),
$request->get('fields')
);
$ret['html'] = $this->getPresetHTMLList($sbas_id, $user);
return $this->app->json($ret);
} | [
"public",
"function",
"presetsSaveAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"sbas_id",
"=",
"$",
"request",
"->",
"get",
"(",
"'sbas_id'",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getAuthenticatedUser",
"(",
")",
";",
"$",
"ret",
"... | route POST "../prod/records/edit/presets"
@param Request $request
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"route",
"POST",
"..",
"/",
"prod",
"/",
"records",
"/",
"edit",
"/",
"presets"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Prod/EditController.php#L478-L495 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Manipulator/LazaretManipulator.php | LazaretManipulator.clear | public function clear($maxTodo = -1)
{
$ret = array(
'success' => false,
'message' => '',
'result' => array(
'tobedone' => 0,
'done' => 0,
'todo' => 0,
'max' => '',
)
);
if( $maxTodo <= 0) {
$maxTodo = -1; // all
}
$ret['result']['max'] = $maxTodo;
$ret['result']['tobedone'] = (int) $this->repository->createQueryBuilder('id')
->select('COUNT(id)')
->getQuery()
->getSingleScalarResult();
if($maxTodo == -1) {
// all
$lazaretFiles = $this->repository->findAll();
} else {
// limit maxTodo
$lazaretFiles = $this->repository->findBy(array(), null, $maxTodo);
}
$this->entityManager->beginTransaction();
try {
foreach ($lazaretFiles as $lazaretFile) {
$this->denyLazaretFile($lazaretFile);
$ret['result']['done']++;
}
$this->entityManager->commit();
$ret['success'] = true;
} catch (\Exception $e) {
$this->entityManager->rollback();
$ret['message'] = $this->app->trans('An error occured');
}
$ret['result']['todo'] = $ret['result']['tobedone'] - $ret['result']['done'];
return $ret;
} | php | public function clear($maxTodo = -1)
{
$ret = array(
'success' => false,
'message' => '',
'result' => array(
'tobedone' => 0,
'done' => 0,
'todo' => 0,
'max' => '',
)
);
if( $maxTodo <= 0) {
$maxTodo = -1; // all
}
$ret['result']['max'] = $maxTodo;
$ret['result']['tobedone'] = (int) $this->repository->createQueryBuilder('id')
->select('COUNT(id)')
->getQuery()
->getSingleScalarResult();
if($maxTodo == -1) {
// all
$lazaretFiles = $this->repository->findAll();
} else {
// limit maxTodo
$lazaretFiles = $this->repository->findBy(array(), null, $maxTodo);
}
$this->entityManager->beginTransaction();
try {
foreach ($lazaretFiles as $lazaretFile) {
$this->denyLazaretFile($lazaretFile);
$ret['result']['done']++;
}
$this->entityManager->commit();
$ret['success'] = true;
} catch (\Exception $e) {
$this->entityManager->rollback();
$ret['message'] = $this->app->trans('An error occured');
}
$ret['result']['todo'] = $ret['result']['tobedone'] - $ret['result']['done'];
return $ret;
} | [
"public",
"function",
"clear",
"(",
"$",
"maxTodo",
"=",
"-",
"1",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
"'success'",
"=>",
"false",
",",
"'message'",
"=>",
"''",
",",
"'result'",
"=>",
"array",
"(",
"'tobedone'",
"=>",
"0",
",",
"'done'",
"=>",
... | Empty lazaret
@param int $maxTodo
@return Array | [
"Empty",
"lazaret"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Manipulator/LazaretManipulator.php#L76-L123 |
alchemy-fr/Phraseanet | lib/classes/patch/320alpha1b.php | patch_320alpha1b.apply | public function apply(base $appbox, Application $app)
{
$sql = 'REPLACE INTO records_rights
(
SELECT null as id, usr_id, b.sbas_id, record_id, "1" as document, null as preview,
"push" as `case`, pushFrom as pusher_usr_id
FROM sselcont c, ssel s, bas b
WHERE c.ssel_id = s.ssel_id
AND b.base_id = c.base_id
AND c.canHD = 1
)';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
return true;
} | php | public function apply(base $appbox, Application $app)
{
$sql = 'REPLACE INTO records_rights
(
SELECT null as id, usr_id, b.sbas_id, record_id, "1" as document, null as preview,
"push" as `case`, pushFrom as pusher_usr_id
FROM sselcont c, ssel s, bas b
WHERE c.ssel_id = s.ssel_id
AND b.base_id = c.base_id
AND c.canHD = 1
)';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
return true;
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"sql",
"=",
"'REPLACE INTO records_rights\n (\n SELECT null as id, usr_id, b.sbas_id, record_id, \"1\" as document, null as preview,\n ... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/320alpha1b.php#L49-L65 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/Upgrade39Sessions.php | Upgrade39Sessions.apply | public function apply(EntityManager $em, \appbox $appbox, Configuration $conf)
{
if ($this->tableExists($em, 'Sessions')) {
$this->dropTable($em, 'SessionModules');
$this->dropTable($em, 'Sessions');
}
} | php | public function apply(EntityManager $em, \appbox $appbox, Configuration $conf)
{
if ($this->tableExists($em, 'Sessions')) {
$this->dropTable($em, 'SessionModules');
$this->dropTable($em, 'Sessions');
}
} | [
"public",
"function",
"apply",
"(",
"EntityManager",
"$",
"em",
",",
"\\",
"appbox",
"$",
"appbox",
",",
"Configuration",
"$",
"conf",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tableExists",
"(",
"$",
"em",
",",
"'Sessions'",
")",
")",
"{",
"$",
"this... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/Upgrade39Sessions.php#L25-L31 |
alchemy-fr/Phraseanet | lib/classes/record/preview.php | record_preview.getStatistics | public function getStatistics($nbDays)
{
if(is_null($this->statistics)) {
if($nbDays < 1) {
throw new \Alchemy\Phrasea\Exception\InvalidArgumentException("nbDays must be > 0");
}
if(!$this->app->getAclForUser($this->app->getAuthenticatedUser())
->has_right_on_base($this->getBaseId(), \ACL::CANREPORT)) {
return( ($this->statistics = false) );
}
$this->statistics = [
'days' => $nbDays,
'from' => '',
'to' => '',
'max_views' => 0,
'max_downloads' => 0,
'by_day' => [
// '2012-01-02' => [
// 'label' => '2012-01-02',
// 'views' => 123,
// 'downloads' => 456,
// ],
],
'referrers' => [
'report::acces direct' => [
'label' => $this->app->trans('report::acces direct'),
'count' => 0
],
'admin::monitor: module production' => [
'label' => $this->app->trans('admin::monitor: module production'),
'count' => 0
],
'admin::monitor: module client' => [
'label' => $this->app->trans('admin::monitor: module client'),
'count' => 0
],
'report:: page d\'accueil' => [
'label' => $this->app->trans('report:: page d\'accueil'),
'count' => 0
],
'report:: visualiseur cooliris' => [
'label' => $this->app->trans('report:: visualiseur cooliris'),
'count' => 0
],
// ...
// some more entries can be added if the referrer does not match anything
]
];
// preset 30 dates in the past
//
$nbDays--; // because 0 is included
for ($d=$nbDays; $d>=0; $d--) {
$datetime = new DateTime('-' . $d . ' days');
$datetime->modify('+1 day');
$date = date_format($datetime, 'Y-m-d');
if($d == $nbDays) {
$this->statistics['from'] = $date;
}
elseif($d == 0) {
$this->statistics['to'] = $date;
}
$this->statistics['by_day'][$date] = [
'label' => $date,
'views' => 0,
'downloads' => 0
];
}
//------- views stats
//
$sql = "SELECT COUNT(id) AS n, DATE_FORMAT(date, '%Y-%m-%d') AS datee FROM `log_view`\n"
. " WHERE record_id = :record_id\n"
. " AND date >= :from AND date <= :to\n"
. " AND site_id = :site\n"
. " GROUP BY datee ORDER BY datee ASC";
$result = $this->getDataboxConnection()
->executeQuery($sql, [
':record_id' => $this->getRecordId(),
':site' => $this->app['conf']->get(['main', 'key']),
':from' => $this->statistics['from'],
':to' => $this->statistics['to']
])
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$date = $row['datee'];
if(array_key_exists($date, $this->statistics['by_day'])) {
$this->statistics['by_day'][$date]['views'] += (int)($row['n']);
if($this->statistics['by_day'][$date]['views'] > $this->statistics['max_views']) {
$this->statistics['max_views'] = $this->statistics['by_day'][$date]['views'];
}
}
}
//------- downloads stats
//
$sql = "SELECT COUNT(d.id) AS n, DATE_FORMAT(d.date, '%Y-%m-%d') AS datee\n"
. " FROM `log_docs` AS d, log AS l\n"
. " WHERE action='download'\n"
. " AND log_id=l.id\n"
. " AND record_id= :record_id\n"
. " AND d.date >= :from AND d.date <= :to\n"
. " AND site= :site\n"
. " GROUP BY datee ORDER BY datee ASC";
$result = $this->getDataboxConnection()
->executeQuery($sql, [
':record_id' => $this->getRecordId(),
':site' => $this->app['conf']->get(['main', 'key']),
':from' => $this->statistics['from'],
':to' => $this->statistics['to']
])
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$date = $row['datee'];
if(array_key_exists($date, $this->statistics['by_day'])) {
$this->statistics['by_day'][$date]['downloads'] += (int)($row['n']);
if($this->statistics['by_day'][$date]['downloads'] > $this->statistics['max_downloads']) {
$this->statistics['max_downloads'] = $this->statistics['by_day'][$date]['downloads'];
}
}
}
//------- referers stats
//
$sql = "SELECT count( id ) AS n, referrer FROM `log_view`\n"
. " WHERE record_id = :record_id\n"
. " AND date >= :from AND date <= :to\n"
. " GROUP BY referrer ORDER BY referrer ASC";
$result = $this->getDataboxConnection()
->executeQuery($sql, [
':record_id' => $this->getRecordId(),
':from' => $this->statistics['from'],
':to' => $this->statistics['to']
])
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$k = $row['referrer'];
if ($k == 'NO REFERRER') {
$k = $this->app->trans('report::acces direct');
}
elseif ($k == $this->app['conf']->get('servername') . 'prod/') {
$k = $this->app->trans('admin::monitor: module production');
}
elseif ($k == $this->app['conf']->get('servername') . 'client/') {
$k = $this->app->trans('admin::monitor: module client');
}
elseif (strpos($k, 'http://apps.cooliris.com/') !== false) {
$k = $this->app->trans('report:: visualiseur cooliris');
}
elseif (strpos($k, $this->app['conf']->get('servername') . 'login/') !== false) {
$k = $this->app->trans('report:: page d\'accueil');
}
elseif (strpos($k, $this->app['conf']->get('servername') . 'document/') !== false) {
$k = $this->app->trans('report::acces direct');
}
elseif (strpos($k, $this->app['conf']->get('servername') . 'permalink/') !== false) {
$k = $this->app->trans('report::acces direct');
}
if (!isset($this->statistics['referrers'][$k])) {
// the referrer does not match anything, just add it untranslated
$this->statistics['referrers'][$k] = [
'label' => $k,
'count' => 0
];
}
$this->statistics['referrers'][$k]['count'] += (int)$row['n'];
}
}
return $this->statistics;
} | php | public function getStatistics($nbDays)
{
if(is_null($this->statistics)) {
if($nbDays < 1) {
throw new \Alchemy\Phrasea\Exception\InvalidArgumentException("nbDays must be > 0");
}
if(!$this->app->getAclForUser($this->app->getAuthenticatedUser())
->has_right_on_base($this->getBaseId(), \ACL::CANREPORT)) {
return( ($this->statistics = false) );
}
$this->statistics = [
'days' => $nbDays,
'from' => '',
'to' => '',
'max_views' => 0,
'max_downloads' => 0,
'by_day' => [
// '2012-01-02' => [
// 'label' => '2012-01-02',
// 'views' => 123,
// 'downloads' => 456,
// ],
],
'referrers' => [
'report::acces direct' => [
'label' => $this->app->trans('report::acces direct'),
'count' => 0
],
'admin::monitor: module production' => [
'label' => $this->app->trans('admin::monitor: module production'),
'count' => 0
],
'admin::monitor: module client' => [
'label' => $this->app->trans('admin::monitor: module client'),
'count' => 0
],
'report:: page d\'accueil' => [
'label' => $this->app->trans('report:: page d\'accueil'),
'count' => 0
],
'report:: visualiseur cooliris' => [
'label' => $this->app->trans('report:: visualiseur cooliris'),
'count' => 0
],
// ...
// some more entries can be added if the referrer does not match anything
]
];
// preset 30 dates in the past
//
$nbDays--; // because 0 is included
for ($d=$nbDays; $d>=0; $d--) {
$datetime = new DateTime('-' . $d . ' days');
$datetime->modify('+1 day');
$date = date_format($datetime, 'Y-m-d');
if($d == $nbDays) {
$this->statistics['from'] = $date;
}
elseif($d == 0) {
$this->statistics['to'] = $date;
}
$this->statistics['by_day'][$date] = [
'label' => $date,
'views' => 0,
'downloads' => 0
];
}
//------- views stats
//
$sql = "SELECT COUNT(id) AS n, DATE_FORMAT(date, '%Y-%m-%d') AS datee FROM `log_view`\n"
. " WHERE record_id = :record_id\n"
. " AND date >= :from AND date <= :to\n"
. " AND site_id = :site\n"
. " GROUP BY datee ORDER BY datee ASC";
$result = $this->getDataboxConnection()
->executeQuery($sql, [
':record_id' => $this->getRecordId(),
':site' => $this->app['conf']->get(['main', 'key']),
':from' => $this->statistics['from'],
':to' => $this->statistics['to']
])
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$date = $row['datee'];
if(array_key_exists($date, $this->statistics['by_day'])) {
$this->statistics['by_day'][$date]['views'] += (int)($row['n']);
if($this->statistics['by_day'][$date]['views'] > $this->statistics['max_views']) {
$this->statistics['max_views'] = $this->statistics['by_day'][$date]['views'];
}
}
}
//------- downloads stats
//
$sql = "SELECT COUNT(d.id) AS n, DATE_FORMAT(d.date, '%Y-%m-%d') AS datee\n"
. " FROM `log_docs` AS d, log AS l\n"
. " WHERE action='download'\n"
. " AND log_id=l.id\n"
. " AND record_id= :record_id\n"
. " AND d.date >= :from AND d.date <= :to\n"
. " AND site= :site\n"
. " GROUP BY datee ORDER BY datee ASC";
$result = $this->getDataboxConnection()
->executeQuery($sql, [
':record_id' => $this->getRecordId(),
':site' => $this->app['conf']->get(['main', 'key']),
':from' => $this->statistics['from'],
':to' => $this->statistics['to']
])
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$date = $row['datee'];
if(array_key_exists($date, $this->statistics['by_day'])) {
$this->statistics['by_day'][$date]['downloads'] += (int)($row['n']);
if($this->statistics['by_day'][$date]['downloads'] > $this->statistics['max_downloads']) {
$this->statistics['max_downloads'] = $this->statistics['by_day'][$date]['downloads'];
}
}
}
//------- referers stats
//
$sql = "SELECT count( id ) AS n, referrer FROM `log_view`\n"
. " WHERE record_id = :record_id\n"
. " AND date >= :from AND date <= :to\n"
. " GROUP BY referrer ORDER BY referrer ASC";
$result = $this->getDataboxConnection()
->executeQuery($sql, [
':record_id' => $this->getRecordId(),
':from' => $this->statistics['from'],
':to' => $this->statistics['to']
])
->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$k = $row['referrer'];
if ($k == 'NO REFERRER') {
$k = $this->app->trans('report::acces direct');
}
elseif ($k == $this->app['conf']->get('servername') . 'prod/') {
$k = $this->app->trans('admin::monitor: module production');
}
elseif ($k == $this->app['conf']->get('servername') . 'client/') {
$k = $this->app->trans('admin::monitor: module client');
}
elseif (strpos($k, 'http://apps.cooliris.com/') !== false) {
$k = $this->app->trans('report:: visualiseur cooliris');
}
elseif (strpos($k, $this->app['conf']->get('servername') . 'login/') !== false) {
$k = $this->app->trans('report:: page d\'accueil');
}
elseif (strpos($k, $this->app['conf']->get('servername') . 'document/') !== false) {
$k = $this->app->trans('report::acces direct');
}
elseif (strpos($k, $this->app['conf']->get('servername') . 'permalink/') !== false) {
$k = $this->app->trans('report::acces direct');
}
if (!isset($this->statistics['referrers'][$k])) {
// the referrer does not match anything, just add it untranslated
$this->statistics['referrers'][$k] = [
'label' => $k,
'count' => 0
];
}
$this->statistics['referrers'][$k]['count'] += (int)$row['n'];
}
}
return $this->statistics;
} | [
"public",
"function",
"getStatistics",
"(",
"$",
"nbDays",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"statistics",
")",
")",
"{",
"if",
"(",
"$",
"nbDays",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"Alchemy",
"\\",
"Phrasea",
"\\",
"E... | get statistics about the record during the last nbDays
- nb of dowloads, nb of views, referrers.
@param int $nbDays
@return array|bool false if user is not allowed to see stats (aka report)
@throws Exception
@throws \Doctrine\DBAL\DBALException | [
"get",
"statistics",
"about",
"the",
"record",
"during",
"the",
"last",
"nbDays",
"-",
"nb",
"of",
"dowloads",
"nb",
"of",
"views",
"referrers",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/record/preview.php#L381-L546 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php | MailInfoNewPublication.getMessage | public function getMessage()
{
if (!$this->author) {
throw new LogicException('You must set an author before calling getMessage');
}
if (!$this->title) {
throw new LogicException('You must set an title before calling getMessage');
}
return $this->app->trans('%user% vient de publier %title%', ['%user%' => $this->author, '%title%' => $this->title]);
} | php | public function getMessage()
{
if (!$this->author) {
throw new LogicException('You must set an author before calling getMessage');
}
if (!$this->title) {
throw new LogicException('You must set an title before calling getMessage');
}
return $this->app->trans('%user% vient de publier %title%', ['%user%' => $this->author, '%title%' => $this->title]);
} | [
"public",
"function",
"getMessage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"author",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You must set an author before calling getMessage'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"title",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewPublication.php#L58-L68 |
alchemy-fr/Phraseanet | lib/classes/patch/390alpha9b.php | patch_390alpha9b.apply | public function apply(base $appbox, Application $app)
{
$this->upgradeConf($app);
$this->upgradeRegistry($app);
} | php | public function apply(base $appbox, Application $app)
{
$this->upgradeConf($app);
$this->upgradeRegistry($app);
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"upgradeConf",
"(",
"$",
"app",
")",
";",
"$",
"this",
"->",
"upgradeRegistry",
"(",
"$",
"app",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/390alpha9b.php#L50-L54 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Authentication/ACLProvider.php | ACLProvider.get | public function get(User $user)
{
if (null !== $acl = $this->fetchFromCache($user)) {
return $acl;
}
return $this->fetch($user);
} | php | public function get(User $user)
{
if (null !== $acl = $this->fetchFromCache($user)) {
return $acl;
}
return $this->fetch($user);
} | [
"public",
"function",
"get",
"(",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"acl",
"=",
"$",
"this",
"->",
"fetchFromCache",
"(",
"$",
"user",
")",
")",
"{",
"return",
"$",
"acl",
";",
"}",
"return",
"$",
"this",
"->",
"fetch"... | Gets ACL for user.
@param User $user
@return \ACL | [
"Gets",
"ACL",
"for",
"user",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/ACLProvider.php#L40-L47 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Authentication/ACLProvider.php | ACLProvider.fetchFromCache | private function fetchFromCache(User $user)
{
return $this->hasCache($user) ? self::$cache[$user->getId()] : null;
} | php | private function fetchFromCache(User $user)
{
return $this->hasCache($user) ? self::$cache[$user->getId()] : null;
} | [
"private",
"function",
"fetchFromCache",
"(",
"User",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"hasCache",
"(",
"$",
"user",
")",
"?",
"self",
"::",
"$",
"cache",
"[",
"$",
"user",
"->",
"getId",
"(",
")",
"]",
":",
"null",
";",
"}"
] | Fetchs ACL from cache for users.
@param User $user
@return null || \ACL | [
"Fetchs",
"ACL",
"from",
"cache",
"for",
"users",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/ACLProvider.php#L64-L67 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Authentication/ACLProvider.php | ACLProvider.fetch | private function fetch(User $user)
{
return self::$cache[$user->getId()] = new \ACL($user, $this->app);
} | php | private function fetch(User $user)
{
return self::$cache[$user->getId()] = new \ACL($user, $this->app);
} | [
"private",
"function",
"fetch",
"(",
"User",
"$",
"user",
")",
"{",
"return",
"self",
"::",
"$",
"cache",
"[",
"$",
"user",
"->",
"getId",
"(",
")",
"]",
"=",
"new",
"\\",
"ACL",
"(",
"$",
"user",
",",
"$",
"this",
"->",
"app",
")",
";",
"}"
] | Saves user's ACL in cache and returns it.
@param User $user
@return \ACL | [
"Saves",
"user",
"s",
"ACL",
"in",
"cache",
"and",
"returns",
"it",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Authentication/ACLProvider.php#L88-L91 |
alchemy-fr/Phraseanet | lib/classes/databox/subdefsStructure.php | databox_subdefsStructure.hasSubdef | public function hasSubdef($subdef_type, $subdef_name)
{
$group = $this->getSubdefGroup(strtolower($subdef_type));
if ($group) {
return $group->hasSubdef(strtolower($subdef_name));
}
return false;
} | php | public function hasSubdef($subdef_type, $subdef_name)
{
$group = $this->getSubdefGroup(strtolower($subdef_type));
if ($group) {
return $group->hasSubdef(strtolower($subdef_name));
}
return false;
} | [
"public",
"function",
"hasSubdef",
"(",
"$",
"subdef_type",
",",
"$",
"subdef_name",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"getSubdefGroup",
"(",
"strtolower",
"(",
"$",
"subdef_type",
")",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"return... | @param string $subdef_type
@param string $subdef_name
@return bool | [
"@param",
"string",
"$subdef_type",
"@param",
"string",
"$subdef_name"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/databox/subdefsStructure.php#L118-L127 |
alchemy-fr/Phraseanet | lib/classes/databox/subdefsStructure.php | databox_subdefsStructure.get_subdef | public function get_subdef($subdef_type, $subdef_name)
{
$type = strtolower($subdef_type);
$name = strtolower($subdef_name);
$group = $this->getSubdefGroup(strtolower($subdef_type));
if (!$group) {
throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $name, $type));
}
try {
return $group->getSubdef($name);
} catch (RuntimeException $exception) {
throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $name, $type), $exception);
}
} | php | public function get_subdef($subdef_type, $subdef_name)
{
$type = strtolower($subdef_type);
$name = strtolower($subdef_name);
$group = $this->getSubdefGroup(strtolower($subdef_type));
if (!$group) {
throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $name, $type));
}
try {
return $group->getSubdef($name);
} catch (RuntimeException $exception) {
throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $name, $type), $exception);
}
} | [
"public",
"function",
"get_subdef",
"(",
"$",
"subdef_type",
",",
"$",
"subdef_name",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"subdef_type",
")",
";",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"subdef_name",
")",
";",
"$",
"group",
"=",
"$"... | @param string $subdef_type
@param string $subdef_name
@return databox_subdef
@throws Exception_Databox_SubdefNotFound | [
"@param",
"string",
"$subdef_type",
"@param",
"string",
"$subdef_name"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/databox/subdefsStructure.php#L136-L152 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Border/Checker/Filename.php | Filename.check | public function check(EntityManager $em, File $file)
{
$boolean = empty(\record_adapter::get_records_by_originalname(
$file->getCollection()->get_databox(), $file->getOriginalName(), $this->sensitive, 0, 1
));
return new Response($boolean, $this);
} | php | public function check(EntityManager $em, File $file)
{
$boolean = empty(\record_adapter::get_records_by_originalname(
$file->getCollection()->get_databox(), $file->getOriginalName(), $this->sensitive, 0, 1
));
return new Response($boolean, $this);
} | [
"public",
"function",
"check",
"(",
"EntityManager",
"$",
"em",
",",
"File",
"$",
"file",
")",
"{",
"$",
"boolean",
"=",
"empty",
"(",
"\\",
"record_adapter",
"::",
"get_records_by_originalname",
"(",
"$",
"file",
"->",
"getCollection",
"(",
")",
"->",
"ge... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Border/Checker/Filename.php#L46-L53 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php | ValidationSession.getParticipant | public function getParticipant(User $user)
{
foreach ($this->getParticipants() as $participant) {
if ($participant->getUser()->getId() == $user->getId()) {
return $participant;
}
}
throw new NotFoundHttpException('Participant not found' . $user->getEmail());
} | php | public function getParticipant(User $user)
{
foreach ($this->getParticipants() as $participant) {
if ($participant->getUser()->getId() == $user->getId()) {
return $participant;
}
}
throw new NotFoundHttpException('Participant not found' . $user->getEmail());
} | [
"public",
"function",
"getParticipant",
"(",
"User",
"$",
"user",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getParticipants",
"(",
")",
"as",
"$",
"participant",
")",
"{",
"if",
"(",
"$",
"participant",
"->",
"getUser",
"(",
")",
"->",
"getId",
"("... | Get a participant
@return ValidationParticipant | [
"Get",
"a",
"participant"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php#L276-L285 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php | NginxMode.setHeaders | public function setHeaders(Request $request)
{
$xAccelMapping = [];
foreach ($this->mapping as $entry) {
$xAccelMapping[] = sprintf('%s=%s', $entry['directory'], $entry['mount-point']);
}
if (count($xAccelMapping) > 0 ) {
$request->headers->add([
'X-Sendfile-Type' => 'X-Accel-Redirect',
'X-Accel-Mapping' => implode(',', $xAccelMapping),
]);
}
} | php | public function setHeaders(Request $request)
{
$xAccelMapping = [];
foreach ($this->mapping as $entry) {
$xAccelMapping[] = sprintf('%s=%s', $entry['directory'], $entry['mount-point']);
}
if (count($xAccelMapping) > 0 ) {
$request->headers->add([
'X-Sendfile-Type' => 'X-Accel-Redirect',
'X-Accel-Mapping' => implode(',', $xAccelMapping),
]);
}
} | [
"public",
"function",
"setHeaders",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"xAccelMapping",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"mapping",
"as",
"$",
"entry",
")",
"{",
"$",
"xAccelMapping",
"[",
"]",
"=",
"sprintf",
"(",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php#L23-L37 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php | NginxMode.setMapping | public function setMapping(array $mapping)
{
$final = [];
foreach ($mapping as $entry) {
if (!is_array($entry)) {
throw new InvalidArgumentException('XSendFile mapping entry must be an array');
}
if (!isset($entry['directory'])) {
throw new InvalidArgumentException('XSendFile mapping entry must contain at least a "directory" key');
}
if (!isset($entry['mount-point'])) {
throw new InvalidArgumentException('XSendFile mapping entry must contain at least a "mount-point" key');
}
if (false === is_dir(trim($entry['directory'])) || '' === trim($entry['mount-point'])) {
continue;
}
$final[] = [
'directory' => $this->sanitizePath(realpath($entry['directory'])),
'mount-point' => $this->sanitizeMountPoint($entry['mount-point'])
];
}
$this->mapping = $final;
} | php | public function setMapping(array $mapping)
{
$final = [];
foreach ($mapping as $entry) {
if (!is_array($entry)) {
throw new InvalidArgumentException('XSendFile mapping entry must be an array');
}
if (!isset($entry['directory'])) {
throw new InvalidArgumentException('XSendFile mapping entry must contain at least a "directory" key');
}
if (!isset($entry['mount-point'])) {
throw new InvalidArgumentException('XSendFile mapping entry must contain at least a "mount-point" key');
}
if (false === is_dir(trim($entry['directory'])) || '' === trim($entry['mount-point'])) {
continue;
}
$final[] = [
'directory' => $this->sanitizePath(realpath($entry['directory'])),
'mount-point' => $this->sanitizeMountPoint($entry['mount-point'])
];
}
$this->mapping = $final;
} | [
"public",
"function",
"setMapping",
"(",
"array",
"$",
"mapping",
")",
"{",
"$",
"final",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"entry",
")",
")",
"{",
"throw",
"ne... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php#L42-L70 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Utilities/ComposerSetup.php | ComposerSetup.setup | public function setup($target)
{
$installer = tempnam(sys_get_temp_dir(), 'install');
$handle = fopen($installer, 'w+');
$request = $this->guzzle->get('https://getcomposer.org/installer', null, $handle);
try {
$response = $request->send();
fclose($handle);
} catch (GuzzleException $e) {
fclose($handle);
throw new RuntimeException('Unable to download composer install script.');
}
if (200 !== $response->getStatusCode()) {
@unlink($installer);
throw new RuntimeException('Unable to download composer install script.');
}
$dir = getcwd();
if (!@chdir(dirname($target))) {
throw new RuntimeException('Unable to move to target directory for composer install.');
}
$process = ProcessBuilder::create([$this->phpExecutable, $installer])
->setTimeout(300)
->getProcess()
;
try {
$process->run();
@unlink($installer);
} catch (ProcessException $e) {
@unlink($installer);
throw new RuntimeException('Unable run composer install script.');
}
if (!@rename(getcwd() . '/composer.phar', $target)) {
throw new RuntimeException('Composer install failed.');
}
if (!@chdir($dir)) {
throw new RuntimeException('Unable to move back to origin directory.');
}
if (!$process->isSuccessful()) {
throw new RuntimeException('Composer install failed.');
}
if (!file_exists($target)) {
throw new RuntimeException('Composer install failed.');
}
} | php | public function setup($target)
{
$installer = tempnam(sys_get_temp_dir(), 'install');
$handle = fopen($installer, 'w+');
$request = $this->guzzle->get('https://getcomposer.org/installer', null, $handle);
try {
$response = $request->send();
fclose($handle);
} catch (GuzzleException $e) {
fclose($handle);
throw new RuntimeException('Unable to download composer install script.');
}
if (200 !== $response->getStatusCode()) {
@unlink($installer);
throw new RuntimeException('Unable to download composer install script.');
}
$dir = getcwd();
if (!@chdir(dirname($target))) {
throw new RuntimeException('Unable to move to target directory for composer install.');
}
$process = ProcessBuilder::create([$this->phpExecutable, $installer])
->setTimeout(300)
->getProcess()
;
try {
$process->run();
@unlink($installer);
} catch (ProcessException $e) {
@unlink($installer);
throw new RuntimeException('Unable run composer install script.');
}
if (!@rename(getcwd() . '/composer.phar', $target)) {
throw new RuntimeException('Composer install failed.');
}
if (!@chdir($dir)) {
throw new RuntimeException('Unable to move back to origin directory.');
}
if (!$process->isSuccessful()) {
throw new RuntimeException('Composer install failed.');
}
if (!file_exists($target)) {
throw new RuntimeException('Composer install failed.');
}
} | [
"public",
"function",
"setup",
"(",
"$",
"target",
")",
"{",
"$",
"installer",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'install'",
")",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"installer",
",",
"'w+'",
")",
";",
"$",
"request",
"... | Downloads composer installer and setups it to the given target.
@param string $target
@throws RuntimeException | [
"Downloads",
"composer",
"installer",
"and",
"setups",
"it",
"to",
"the",
"given",
"target",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php#L48-L101 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php | FeedLinkGenerator.generate | public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false)
{
if (!$this->supports($feed)) {
throw new InvalidArgumentException('FeedLinkGenerator only support aggregate feeds.');
}
switch ($format) {
case self::FORMAT_ATOM:
$params = [
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
'id' => $feed->getId(),
'format' => 'atom'
];
if (null !== $page) {
$params['page'] = $page;
}
return new FeedLink(
$this->generator->generate('feed_user', $params, UrlGenerator::ABSOLUTE_URL),
sprintf('%s - %s', $feed->getTitle(), 'Atom'),
'application/atom+xml'
);
case self::FORMAT_RSS:
$params = [
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
'id' => $feed->getId(),
'format' => 'rss'
];
if (null !== $page) {
$params['page'] = $page;
}
return new FeedLink(
$this->generator->generate('feed_user', $params, UrlGenerator::ABSOLUTE_URL),
sprintf('%s - %s', $feed->getTitle(), 'RSS'),
'application/rss+xml'
);
default:
throw new InvalidArgumentException(sprintf('Format %s is not recognized.', $format));
}
} | php | public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false)
{
if (!$this->supports($feed)) {
throw new InvalidArgumentException('FeedLinkGenerator only support aggregate feeds.');
}
switch ($format) {
case self::FORMAT_ATOM:
$params = [
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
'id' => $feed->getId(),
'format' => 'atom'
];
if (null !== $page) {
$params['page'] = $page;
}
return new FeedLink(
$this->generator->generate('feed_user', $params, UrlGenerator::ABSOLUTE_URL),
sprintf('%s - %s', $feed->getTitle(), 'Atom'),
'application/atom+xml'
);
case self::FORMAT_RSS:
$params = [
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
'id' => $feed->getId(),
'format' => 'rss'
];
if (null !== $page) {
$params['page'] = $page;
}
return new FeedLink(
$this->generator->generate('feed_user', $params, UrlGenerator::ABSOLUTE_URL),
sprintf('%s - %s', $feed->getTitle(), 'RSS'),
'application/rss+xml'
);
default:
throw new InvalidArgumentException(sprintf('Format %s is not recognized.', $format));
}
} | [
"public",
"function",
"generate",
"(",
"FeedInterface",
"$",
"feed",
",",
"User",
"$",
"user",
",",
"$",
"format",
",",
"$",
"page",
"=",
"null",
",",
"$",
"renew",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php#L48-L88 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/User.php | User.setGender | public function setGender($gender)
{
if (null !== $gender) {
$gender = (string)$gender;
}
if (!in_array($gender, [
null,
(string)self::GENDER_MISS,
(string)self::GENDER_MR,
(string)self::GENDER_MRS,
], true)) {
throw new InvalidArgumentException(sprintf("Invalid gender %s.", $gender));
}
$this->gender = $gender ? (int)$gender : null;
return $this;
} | php | public function setGender($gender)
{
if (null !== $gender) {
$gender = (string)$gender;
}
if (!in_array($gender, [
null,
(string)self::GENDER_MISS,
(string)self::GENDER_MR,
(string)self::GENDER_MRS,
], true)) {
throw new InvalidArgumentException(sprintf("Invalid gender %s.", $gender));
}
$this->gender = $gender ? (int)$gender : null;
return $this;
} | [
"public",
"function",
"setGender",
"(",
"$",
"gender",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"gender",
")",
"{",
"$",
"gender",
"=",
"(",
"string",
")",
"$",
"gender",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"gender",
",",
"[",
"null",... | @param string $gender
@return $this
@throws InvalidArgumentException | [
"@param",
"string",
"$gender"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/User.php#L431-L450 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/User.php | User.setLocale | public function setLocale($locale)
{
if (null !== $locale && !array_key_exists($locale, Application::getAvailableLanguages())) {
throw new InvalidArgumentException(sprintf('Invalid locale %s.', $locale));
}
$this->locale = $locale;
return $this;
} | php | public function setLocale($locale)
{
if (null !== $locale && !array_key_exists($locale, Application::getAvailableLanguages())) {
throw new InvalidArgumentException(sprintf('Invalid locale %s.', $locale));
}
$this->locale = $locale;
return $this;
} | [
"public",
"function",
"setLocale",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"locale",
"&&",
"!",
"array_key_exists",
"(",
"$",
"locale",
",",
"Application",
"::",
"getAvailableLanguages",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Inva... | @param string $locale
@return $this
@throws InvalidArgumentException | [
"@param",
"string",
"$locale",
"@return",
"$this"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/User.php#L565-L574 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/User.php | User.addSetting | public function addSetting(UserSetting $setting)
{
$this->settings->set($setting->getName(), $setting);
return $this;
} | php | public function addSetting(UserSetting $setting)
{
$this->settings->set($setting->getName(), $setting);
return $this;
} | [
"public",
"function",
"addSetting",
"(",
"UserSetting",
"$",
"setting",
")",
"{",
"$",
"this",
"->",
"settings",
"->",
"set",
"(",
"$",
"setting",
"->",
"getName",
"(",
")",
",",
"$",
"setting",
")",
";",
"return",
"$",
"this",
";",
"}"
] | @param UserSetting $setting
@return User | [
"@param",
"UserSetting",
"$setting"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/User.php#L1029-L1034 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/User.php | User.addNotificationSettings | public function addNotificationSettings(UserNotificationSetting $notificationSetting)
{
$this->notificationSettings->set($notificationSetting->getName(), $notificationSetting);
return $this;
} | php | public function addNotificationSettings(UserNotificationSetting $notificationSetting)
{
$this->notificationSettings->set($notificationSetting->getName(), $notificationSetting);
return $this;
} | [
"public",
"function",
"addNotificationSettings",
"(",
"UserNotificationSetting",
"$",
"notificationSetting",
")",
"{",
"$",
"this",
"->",
"notificationSettings",
"->",
"set",
"(",
"$",
"notificationSetting",
"->",
"getName",
"(",
")",
",",
"$",
"notificationSetting",
... | @param UserNotificationSetting $notificationSetting
@return User | [
"@param",
"UserNotificationSetting",
"$notificationSetting"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/User.php#L1049-L1054 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php | MailInfoOrderCancelled.getMessage | public function getMessage()
{
if (!$this->deliverer instanceof User) {
throw new LogicException('You must set a deliverer before calling getMessage()');
}
if (null === $this->quantity) {
throw new LogicException('You must set a deliverer before calling getMessage()');
}
return $this->app->trans('%user% a refuse %quantity% elements de votre commande', [
'%user%' => $this->deliverer->getDisplayName(),
'%quantity%' => $this->quantity,
]);
} | php | public function getMessage()
{
if (!$this->deliverer instanceof User) {
throw new LogicException('You must set a deliverer before calling getMessage()');
}
if (null === $this->quantity) {
throw new LogicException('You must set a deliverer before calling getMessage()');
}
return $this->app->trans('%user% a refuse %quantity% elements de votre commande', [
'%user%' => $this->deliverer->getDisplayName(),
'%quantity%' => $this->quantity,
]);
} | [
"public",
"function",
"getMessage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"deliverer",
"instanceof",
"User",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You must set a deliverer before calling getMessage()'",
")",
";",
"}",
"if",
"(",
"null",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php#L55-L68 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/SearchEngine/Elastic/AST/TextNode.php | TextNode.merge | public static function merge(TextNode $a, TextNode $b)
{
return new self(sprintf('%s%s', $a->getValue(), $b->getValue()));
} | php | public static function merge(TextNode $a, TextNode $b)
{
return new self(sprintf('%s%s', $a->getValue(), $b->getValue()));
} | [
"public",
"static",
"function",
"merge",
"(",
"TextNode",
"$",
"a",
",",
"TextNode",
"$",
"b",
")",
"{",
"return",
"new",
"self",
"(",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"a",
"->",
"getValue",
"(",
")",
",",
"$",
"b",
"->",
"getValue",
"(",
")",
... | Merge two text nodes by concatenating their content.
/!\ Text contexts are lost in the process
@param TextNode $a First node
@param TextNode $b The other one
@return TextNode Merged text node | [
"Merge",
"two",
"text",
"nodes",
"by",
"concatenating",
"their",
"content",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/SearchEngine/Elastic/AST/TextNode.php#L21-L24 |
alchemy-fr/Phraseanet | lib/classes/patch/320alpha2a.php | patch_320alpha2a.apply | public function apply(base $appbox, Application $app)
{
$dql = 'SELECT u FROM Phraseanet:User u WHERE u.nonce IS NULL';
$q = $app['orm.em']->createQuery($dql);
$q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
$users = $q->getResult();
$n = 0;
foreach ($users as $user) {
$user->setNonce($app['random.medium']->generateString(64));
$app['orm.em']->persist($user);
$n++;
if ($n %100 === 0) {
$app['orm.em']->flush();
}
}
$app['orm.em']->flush();
$sql = 'SELECT task_id, `class` FROM task2';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE task2 SET `class` = :class WHERE task_id = :task_id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
if (strpos($row['class'], 'task_period_') !== false)
continue;
$params = [
':task_id' => $row['task_id']
, ':class' => str_replace('task_', 'task_period_', $row['class'])
];
$stmt->execute($params);
}
$stmt->closeCursor();
return true;
} | php | public function apply(base $appbox, Application $app)
{
$dql = 'SELECT u FROM Phraseanet:User u WHERE u.nonce IS NULL';
$q = $app['orm.em']->createQuery($dql);
$q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
$users = $q->getResult();
$n = 0;
foreach ($users as $user) {
$user->setNonce($app['random.medium']->generateString(64));
$app['orm.em']->persist($user);
$n++;
if ($n %100 === 0) {
$app['orm.em']->flush();
}
}
$app['orm.em']->flush();
$sql = 'SELECT task_id, `class` FROM task2';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE task2 SET `class` = :class WHERE task_id = :task_id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
if (strpos($row['class'], 'task_period_') !== false)
continue;
$params = [
':task_id' => $row['task_id']
, ':class' => str_replace('task_', 'task_period_', $row['class'])
];
$stmt->execute($params);
}
$stmt->closeCursor();
return true;
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"dql",
"=",
"'SELECT u FROM Phraseanet:User u WHERE u.nonce IS NULL'",
";",
"$",
"q",
"=",
"$",
"app",
"[",
"'orm.em'",
"]",
"->",
"createQuery",
"(",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/320alpha2a.php#L50-L92 |
alchemy-fr/Phraseanet | lib/classes/patch/390alpha20a.php | patch_390alpha20a.apply | public function apply(base $appbox, Application $app)
{
$perRequest = 100;
$offset = 0;
do {
$sql = sprintf('SELECT id, datas, type FROM notifications ORDER BY id ASC LIMIT %d, %d', $offset, $perRequest);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE notifications SET datas = :json WHERE id = :id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
$json = $row['datas'];
if (false !== ($sx = @simplexml_load_string($row['datas']))) {
$data = [];
foreach ($sx->children() as $name => $value) {
$data[$name] = (string) $value;
}
if ($row['type'] === 'notify_uploadquarantine') {
$data['reasons'] = [];
if (isset($sx->reasons)) {
foreach ($sx->reasons as $reason) {
$data['reasons'][] = (string) $reason->checkClassName;
}
}
}
if (in_array($row['type'], ['notify_autoregister', 'notify_register'])) {
$data['base_ids'] = [];
if (isset($sx->base_ids)) {
foreach ($sx->base_ids as $base_id) {
$data['base_ids'][] = (int) $base_id->base_id;
}
}
}
$json = json_encode($data);
}
$stmt->execute([':id' => $row['id'], ':json' => $json]);
}
$stmt->closeCursor();
$offset += $perRequest;
} while (count($rs) > 0);
return true;
} | php | public function apply(base $appbox, Application $app)
{
$perRequest = 100;
$offset = 0;
do {
$sql = sprintf('SELECT id, datas, type FROM notifications ORDER BY id ASC LIMIT %d, %d', $offset, $perRequest);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE notifications SET datas = :json WHERE id = :id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
$json = $row['datas'];
if (false !== ($sx = @simplexml_load_string($row['datas']))) {
$data = [];
foreach ($sx->children() as $name => $value) {
$data[$name] = (string) $value;
}
if ($row['type'] === 'notify_uploadquarantine') {
$data['reasons'] = [];
if (isset($sx->reasons)) {
foreach ($sx->reasons as $reason) {
$data['reasons'][] = (string) $reason->checkClassName;
}
}
}
if (in_array($row['type'], ['notify_autoregister', 'notify_register'])) {
$data['base_ids'] = [];
if (isset($sx->base_ids)) {
foreach ($sx->base_ids as $base_id) {
$data['base_ids'][] = (int) $base_id->base_id;
}
}
}
$json = json_encode($data);
}
$stmt->execute([':id' => $row['id'], ':json' => $json]);
}
$stmt->closeCursor();
$offset += $perRequest;
} while (count($rs) > 0);
return true;
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"perRequest",
"=",
"100",
";",
"$",
"offset",
"=",
"0",
";",
"do",
"{",
"$",
"sql",
"=",
"sprintf",
"(",
"'SELECT id, datas, type FROM notifications O... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/390alpha20a.php#L49-L98 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/ControllerProvider/ControllerProviderServiceProvider.php | ControllerProviderServiceProvider.register | public function register(Application $app)
{
$this->loadProviders();
foreach ($this->controllerProviders as $class => $values) {
$app->register(new $class, $values);
}
} | php | public function register(Application $app)
{
$this->loadProviders();
foreach ($this->controllerProviders as $class => $values) {
$app->register(new $class, $values);
}
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"loadProviders",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"controllerProviders",
"as",
"$",
"class",
"=>",
"$",
"values",
")",
"{",
"$",
"app",
"->"... | Registers services on the given app.
This method should only be used to configure services and parameters.
It should not get services. | [
"Registers",
"services",
"on",
"the",
"given",
"app",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/ControllerProvider/ControllerProviderServiceProvider.php#L20-L27 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php | FeedItemRepository.isRecordInPublicFeed | public function isRecordInPublicFeed($sbas_id, $record_id)
{
$dql = 'SELECT COUNT(i)
FROM Phraseanet:FeedItem i
JOIN i.entry e
JOIN e.feed f
WHERE i.sbasId = :sbas_id
AND i.recordId = :record_id
AND f.public = true';
$query = $this->_em->createQuery($dql);
$query->setParameters(['sbas_id' => $sbas_id, 'record_id' => $record_id]);
return $query->getSingleScalarResult() > 0;
} | php | public function isRecordInPublicFeed($sbas_id, $record_id)
{
$dql = 'SELECT COUNT(i)
FROM Phraseanet:FeedItem i
JOIN i.entry e
JOIN e.feed f
WHERE i.sbasId = :sbas_id
AND i.recordId = :record_id
AND f.public = true';
$query = $this->_em->createQuery($dql);
$query->setParameters(['sbas_id' => $sbas_id, 'record_id' => $record_id]);
return $query->getSingleScalarResult() > 0;
} | [
"public",
"function",
"isRecordInPublicFeed",
"(",
"$",
"sbas_id",
",",
"$",
"record_id",
")",
"{",
"$",
"dql",
"=",
"'SELECT COUNT(i)\n FROM Phraseanet:FeedItem i\n JOIN i.entry e\n JOIN e.feed f\n WHERE i.sbasId = :sbas_id\n AN... | Checks if a record is published in a public feed.
@param int $sbas_id
@param int $record_id
@return bool | [
"Checks",
"if",
"a",
"record",
"is",
"published",
"in",
"a",
"public",
"feed",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php#L35-L49 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php | MailInfoOrderDelivered.getMessage | public function getMessage()
{
if (!$this->deliverer) {
throw new LogicException('You must set a deliverer before calling getMessage');
}
return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName()]);
} | php | public function getMessage()
{
if (!$this->deliverer) {
throw new LogicException('You must set a deliverer before calling getMessage');
}
return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName()]);
} | [
"public",
"function",
"getMessage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"deliverer",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You must set a deliverer before calling getMessage'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"app",
"->",... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php#L60-L67 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Model/Entities/ApiAccount.php | ApiAccount.setApplication | public function setApplication(ApiApplication $application)
{
$application->addAccount($this);
$this->application = $application;
return $this;
} | php | public function setApplication(ApiApplication $application)
{
$application->addAccount($this);
$this->application = $application;
return $this;
} | [
"public",
"function",
"setApplication",
"(",
"ApiApplication",
"$",
"application",
")",
"{",
"$",
"application",
"->",
"addAccount",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"application",
"=",
"$",
"application",
";",
"return",
"$",
"this",
";",
"}"... | @param ApiApplication $application
@return ApiAccount | [
"@param",
"ApiApplication",
"$application"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Model/Entities/ApiAccount.php#L96-L103 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Core/Provider/SessionHandlerServiceProvider.php | SessionHandlerServiceProvider.register | public function register(Application $app)
{
$app['session.storage.handler.factory'] = $app->share(function (Application $app) {
return new SessionHandlerFactory($app['cache.connection-factory']);
});
} | php | public function register(Application $app)
{
$app['session.storage.handler.factory'] = $app->share(function (Application $app) {
return new SessionHandlerFactory($app['cache.connection-factory']);
});
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'session.storage.handler.factory'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"return",
"new",
"SessionHandler... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Provider/SessionHandlerServiceProvider.php#L26-L31 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/ControllerProvider/Prod/Record.php | Record.connect | public function connect(Application $app)
{
$controllers = $this->createAuthenticatedCollection($app);
$controllers->match('/', 'controller.prod.records:getRecord')
->bind('record_details')
->method('GET|POST');
$controllers->get('/record/{sbasId}/{recordId}/', 'controller.prod.records:getRecordById')
->bind('record_single')
->assert('sbasId', '\d+')
->assert('recordId', '\d+');
$controllers->post('/delete/', 'controller.prod.records:doDeleteRecords')
->bind('record_delete');
$controllers->post('/delete/what/', 'controller.prod.records:whatCanIDelete')
->bind('record_what_can_i_delete');
$controllers->post('/renew-url/', 'controller.prod.records:renewUrl')
->bind('record_renew_url');
return $controllers;
} | php | public function connect(Application $app)
{
$controllers = $this->createAuthenticatedCollection($app);
$controllers->match('/', 'controller.prod.records:getRecord')
->bind('record_details')
->method('GET|POST');
$controllers->get('/record/{sbasId}/{recordId}/', 'controller.prod.records:getRecordById')
->bind('record_single')
->assert('sbasId', '\d+')
->assert('recordId', '\d+');
$controllers->post('/delete/', 'controller.prod.records:doDeleteRecords')
->bind('record_delete');
$controllers->post('/delete/what/', 'controller.prod.records:whatCanIDelete')
->bind('record_what_can_i_delete');
$controllers->post('/renew-url/', 'controller.prod.records:renewUrl')
->bind('record_renew_url');
return $controllers;
} | [
"public",
"function",
"connect",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"controllers",
"=",
"$",
"this",
"->",
"createAuthenticatedCollection",
"(",
"$",
"app",
")",
";",
"$",
"controllers",
"->",
"match",
"(",
"'/'",
",",
"'controller.prod.records:get... | {@inheritDoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/ControllerProvider/Prod/Record.php#L44-L67 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.sqlBuilder | public function sqlBuilder($domain)
{
switch ($domain) {
case 'connexion' :
return new module_report_sqlconnexion($this->app, $this);
break;
case 'download' :
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
return new module_report_sqldownload($this->app, $this);
break;
case 'question' :
return new module_report_sqlquestion($this->app, $this);
break;
case 'action' :
return new module_report_sqlaction($this->app, $this);
break;
default:
return $this->req;
break;
}
} | php | public function sqlBuilder($domain)
{
switch ($domain) {
case 'connexion' :
return new module_report_sqlconnexion($this->app, $this);
break;
case 'download' :
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
return new module_report_sqldownload($this->app, $this);
break;
case 'question' :
return new module_report_sqlquestion($this->app, $this);
break;
case 'action' :
return new module_report_sqlaction($this->app, $this);
break;
default:
return $this->req;
break;
}
} | [
"public",
"function",
"sqlBuilder",
"(",
"$",
"domain",
")",
"{",
"switch",
"(",
"$",
"domain",
")",
"{",
"case",
"'connexion'",
":",
"return",
"new",
"module_report_sqlconnexion",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"this",
")",
";",
"break",
";",
... | Retourne un objet qui genere la requete selon le type de report
@param string $domain
@return module_report_sqlconnexion | [
"Retourne",
"un",
"objet",
"qui",
"genere",
"la",
"requete",
"selon",
"le",
"type",
"de",
"report"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L576-L596 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.setDisplay | protected function setDisplay($tab, $groupby = false)
{
if ($tab == false && $groupby == false)
$this->initDefaultConfigColumn($this->default_display);
elseif ($groupby != false && $tab == false)
$this->initDefaultConfigColumn($this->champ);
elseif ($tab != false)
$this->setConfigColumn($tab);
return;
} | php | protected function setDisplay($tab, $groupby = false)
{
if ($tab == false && $groupby == false)
$this->initDefaultConfigColumn($this->default_display);
elseif ($groupby != false && $tab == false)
$this->initDefaultConfigColumn($this->champ);
elseif ($tab != false)
$this->setConfigColumn($tab);
return;
} | [
"protected",
"function",
"setDisplay",
"(",
"$",
"tab",
",",
"$",
"groupby",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"tab",
"==",
"false",
"&&",
"$",
"groupby",
"==",
"false",
")",
"$",
"this",
"->",
"initDefaultConfigColumn",
"(",
"$",
"this",
"->",
... | initialise les configuration des columns ex : boundable, linkable orderable
etc .. par defaut ou celle passe en parametre par $tab
@param array $tab
@param string $groupby
@return void | [
"initialise",
"les",
"configuration",
"des",
"columns",
"ex",
":",
"boundable",
"linkable",
"orderable",
"etc",
"..",
"par",
"defaut",
"ou",
"celle",
"passe",
"en",
"parametre",
"par",
"$tab"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L615-L625 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.setCor | private function setCor()
{
return [
'user' => $this->app->trans('report:: utilisateur'),
'coll_id' => $this->app->trans('report:: collections'),
'connexion' => $this->app->trans('report:: Connexion'),
'comment' => $this->app->trans('report:: commentaire'),
'search' => $this->app->trans('report:: question'),
'date' => $this->app->trans('report:: date'),
'ddate' => $this->app->trans('report:: date'),
'fonction' => $this->app->trans('report:: fonction'),
'activite' => $this->app->trans('report:: activite'),
'pays' => $this->app->trans('report:: pays'),
'societe' => $this->app->trans('report:: societe'),
'nb' => $this->app->trans('report:: nombre'),
'pourcent' => $this->app->trans('report:: pourcentage'),
'telechargement' => $this->app->trans('report:: telechargement'),
'record_id' => $this->app->trans('report:: record id'),
'final' => $this->app->trans('report:: type d\'action'),
// 'xml' => $this->app->trans('report:: sujet'),
'file' => $this->app->trans('report:: fichier'),
'mime' => $this->app->trans('report:: type'),
'size' => $this->app->trans('report:: taille'),
'copyright' => $this->app->trans('report:: copyright'),
'final' => $this->app->trans('phraseanet:: sous definition')
];
return;
} | php | private function setCor()
{
return [
'user' => $this->app->trans('report:: utilisateur'),
'coll_id' => $this->app->trans('report:: collections'),
'connexion' => $this->app->trans('report:: Connexion'),
'comment' => $this->app->trans('report:: commentaire'),
'search' => $this->app->trans('report:: question'),
'date' => $this->app->trans('report:: date'),
'ddate' => $this->app->trans('report:: date'),
'fonction' => $this->app->trans('report:: fonction'),
'activite' => $this->app->trans('report:: activite'),
'pays' => $this->app->trans('report:: pays'),
'societe' => $this->app->trans('report:: societe'),
'nb' => $this->app->trans('report:: nombre'),
'pourcent' => $this->app->trans('report:: pourcentage'),
'telechargement' => $this->app->trans('report:: telechargement'),
'record_id' => $this->app->trans('report:: record id'),
'final' => $this->app->trans('report:: type d\'action'),
// 'xml' => $this->app->trans('report:: sujet'),
'file' => $this->app->trans('report:: fichier'),
'mime' => $this->app->trans('report:: type'),
'size' => $this->app->trans('report:: taille'),
'copyright' => $this->app->trans('report:: copyright'),
'final' => $this->app->trans('phraseanet:: sous definition')
];
return;
} | [
"private",
"function",
"setCor",
"(",
")",
"{",
"return",
"[",
"'user'",
"=>",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",
"'report:: utilisateur'",
")",
",",
"'coll_id'",
"=>",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",
"'report:: collections'",
")",... | etablis les correspondance entre gettext et le nom des columns du report
@return array | [
"etablis",
"les",
"correspondance",
"entre",
"gettext",
"et",
"le",
"nom",
"des",
"columns",
"du",
"report"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L661-L689 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.setDay | private function setDay()
{
return [
1 => $this->app->trans('phraseanet::jours:: lundi'),
2 => $this->app->trans('phraseanet::jours:: mardi'),
3 => $this->app->trans('phraseanet::jours:: mercredi'),
4 => $this->app->trans('phraseanet::jours:: jeudi'),
5 => $this->app->trans('phraseanet::jours:: vendredi'),
6 => $this->app->trans('phraseanet::jours:: samedi'),
7 => $this->app->trans('phraseanet::jours:: dimanche')];
} | php | private function setDay()
{
return [
1 => $this->app->trans('phraseanet::jours:: lundi'),
2 => $this->app->trans('phraseanet::jours:: mardi'),
3 => $this->app->trans('phraseanet::jours:: mercredi'),
4 => $this->app->trans('phraseanet::jours:: jeudi'),
5 => $this->app->trans('phraseanet::jours:: vendredi'),
6 => $this->app->trans('phraseanet::jours:: samedi'),
7 => $this->app->trans('phraseanet::jours:: dimanche')];
} | [
"private",
"function",
"setDay",
"(",
")",
"{",
"return",
"[",
"1",
"=>",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",
"'phraseanet::jours:: lundi'",
")",
",",
"2",
"=>",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",
"'phraseanet::jours:: mardi'",
")",
... | etablis les correspondance entre gettext et le nom des jours du report
@return array | [
"etablis",
"les",
"correspondance",
"entre",
"gettext",
"et",
"le",
"nom",
"des",
"jours",
"du",
"report"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L695-L705 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.setMonth | private function setMonth()
{
return [
$this->app->trans('janvier'),
$this->app->trans('fevrier'),
$this->app->trans('mars'),
$this->app->trans('avril'),
$this->app->trans('mai'),
$this->app->trans('juin'),
$this->app->trans('juillet'),
$this->app->trans('aout'),
$this->app->trans('septembre'),
$this->app->trans('octobre'),
$this->app->trans('novembre'),
$this->app->trans('decembre')
];
} | php | private function setMonth()
{
return [
$this->app->trans('janvier'),
$this->app->trans('fevrier'),
$this->app->trans('mars'),
$this->app->trans('avril'),
$this->app->trans('mai'),
$this->app->trans('juin'),
$this->app->trans('juillet'),
$this->app->trans('aout'),
$this->app->trans('septembre'),
$this->app->trans('octobre'),
$this->app->trans('novembre'),
$this->app->trans('decembre')
];
} | [
"private",
"function",
"setMonth",
"(",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",
"'janvier'",
")",
",",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",
"'fevrier'",
")",
",",
"$",
"this",
"->",
"app",
"->",
"trans",
"(",... | etablis les correspondance entre gettext et le nom des mois du report
@return array | [
"etablis",
"les",
"correspondance",
"entre",
"gettext",
"et",
"le",
"nom",
"des",
"mois",
"du",
"report"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L711-L727 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.calculatePages | protected function calculatePages()
{
if ($this->nb_record && $this->total > $this->nb_record) {
$this->previous_page = $this->nb_page - 1;
if ($this->previous_page == 0)
$this->previous_page = false;
$test = ($this->total / $this->nb_record);
if ($this->nb_page == intval(ceil($test)))
$this->next_page = false;
else
$this->next_page = $this->nb_page + 1;
}
} | php | protected function calculatePages()
{
if ($this->nb_record && $this->total > $this->nb_record) {
$this->previous_page = $this->nb_page - 1;
if ($this->previous_page == 0)
$this->previous_page = false;
$test = ($this->total / $this->nb_record);
if ($this->nb_page == intval(ceil($test)))
$this->next_page = false;
else
$this->next_page = $this->nb_page + 1;
}
} | [
"protected",
"function",
"calculatePages",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nb_record",
"&&",
"$",
"this",
"->",
"total",
">",
"$",
"this",
"->",
"nb_record",
")",
"{",
"$",
"this",
"->",
"previous_page",
"=",
"$",
"this",
"->",
"nb_page",... | effectue le mechanism de pagination
@param resultset $rs | [
"effectue",
"le",
"mechanism",
"de",
"pagination"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L733-L746 |
alchemy-fr/Phraseanet | lib/classes/module/report.php | module_report.buildReport | public function buildReport($tab = false, $groupby = false, $on = false)
{
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
if (sizeof($this->report) > 0) {
return $this->report;
}
$databox = $this->app->findDataboxById($this->sbas_id);
$conn = $databox->get_connection();
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
$this->buildReq($groupby, $on);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\nreq=%s\n\n", __FILE__, __LINE__, $this->req), FILE_APPEND);
try {
try {
$stmt = $conn->prepare($this->req);
$stmt->execute($this->params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
} catch (DBALException $e) {
return;
}
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, get_class($this)), FILE_APPEND);
//set request field
$this->setChamp($rs);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//set display
$this->setDisplay($tab, $groupby);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//construct results
$this->buildResult($this->app, $rs);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//calculate prev and next page
$this->calculatePages();
//do we display navigator ?
$this->setDisplayNav();
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//assign all variables
$this->setReport();
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
return $this->report;
} catch (\Exception $e) {
echo $e->getMessage();
}
} | php | public function buildReport($tab = false, $groupby = false, $on = false)
{
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
if (sizeof($this->report) > 0) {
return $this->report;
}
$databox = $this->app->findDataboxById($this->sbas_id);
$conn = $databox->get_connection();
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
$this->buildReq($groupby, $on);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\nreq=%s\n\n", __FILE__, __LINE__, $this->req), FILE_APPEND);
try {
try {
$stmt = $conn->prepare($this->req);
$stmt->execute($this->params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
} catch (DBALException $e) {
return;
}
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s) %s\n\n", __FILE__, __LINE__, get_class($this)), FILE_APPEND);
//set request field
$this->setChamp($rs);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//set display
$this->setDisplay($tab, $groupby);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//construct results
$this->buildResult($this->app, $rs);
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//calculate prev and next page
$this->calculatePages();
//do we display navigator ?
$this->setDisplayNav();
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
//assign all variables
$this->setReport();
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n\n", __FILE__, __LINE__), FILE_APPEND);
return $this->report;
} catch (\Exception $e) {
echo $e->getMessage();
}
} | [
"public",
"function",
"buildReport",
"(",
"$",
"tab",
"=",
"false",
",",
"$",
"groupby",
"=",
"false",
",",
"$",
"on",
"=",
"false",
")",
"{",
"// no_file_put_contents(\"/tmp/report.txt\", sprintf(\"%s (%s)\\n\\n\", __FILE__, __LINE__), FILE_APPEND);",
"if",
"(",
"sizeo... | Build the final formated array which contains all the result,
we construct the html code from this array
@param array $tab pass the configcolumn parameter to this tab
@param array $groupby
@param array $on
@return the formated array | [
"Build",
"the",
"final",
"formated",
"array",
"which",
"contains",
"all",
"the",
"result",
"we",
"construct",
"the",
"html",
"code",
"from",
"this",
"array"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/module/report.php#L831-L884 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Controller/Client/RootController.php | RootController.getClientAction | public function getClientAction(Request $request)
{
if (!$this->getAuthenticator()->isAuthenticated() && null !== $request->query->get('nolog')) {
return $this->app->redirectPath('login_authenticate_as_guest', ['redirect' => 'client']);
}
if (null !== $response = $this->getFirewall()->requireAuthentication()) {
return $response;
}
$this->getSession()->getFlashBag()->add('step_by_step', '');
return $this->app->redirect($this->app->path('prod', array('client')));
} | php | public function getClientAction(Request $request)
{
if (!$this->getAuthenticator()->isAuthenticated() && null !== $request->query->get('nolog')) {
return $this->app->redirectPath('login_authenticate_as_guest', ['redirect' => 'client']);
}
if (null !== $response = $this->getFirewall()->requireAuthentication()) {
return $response;
}
$this->getSession()->getFlashBag()->add('step_by_step', '');
return $this->app->redirect($this->app->path('prod', array('client')));
} | [
"public",
"function",
"getClientAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getAuthenticator",
"(",
")",
"->",
"isAuthenticated",
"(",
")",
"&&",
"null",
"!==",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
... | /!\/!\/!\/!\/!\/!\/!\/!\/!\
Client is no longer used
Redirect to production with a nice message
@param Request $request
@return Response | [
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\",
"/",
"!",
"\\"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Controller/Client/RootController.php#L46-L58 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Core/Configuration/RegistryFormManipulator.php | RegistryFormManipulator.createForm | public function createForm(PropertyAccess $conf = null)
{
$form = $this->factory->create(new MainConfigurationFormType($this->translator, $this->languages));
$currentConf = $conf ? ($conf->get('registry') ?: []) : [];
$data = array_replace_recursive($this->getDefaultData($currentConf), $currentConf);
$form->setData($data);
return $form;
} | php | public function createForm(PropertyAccess $conf = null)
{
$form = $this->factory->create(new MainConfigurationFormType($this->translator, $this->languages));
$currentConf = $conf ? ($conf->get('registry') ?: []) : [];
$data = array_replace_recursive($this->getDefaultData($currentConf), $currentConf);
$form->setData($data);
return $form;
} | [
"public",
"function",
"createForm",
"(",
"PropertyAccess",
"$",
"conf",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"new",
"MainConfigurationFormType",
"(",
"$",
"this",
"->",
"translator",
",",
"$",
"this",
... | Creates a setup form. Set data if a configuration is given.
@param PropertyAccess $conf
@return FormInterface | [
"Creates",
"a",
"setup",
"form",
".",
"Set",
"data",
"if",
"a",
"configuration",
"is",
"given",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/RegistryFormManipulator.php#L47-L55 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Core/Configuration/RegistryFormManipulator.php | RegistryFormManipulator.getRegistryData | public function getRegistryData(FormInterface $form = null, PropertyAccess $conf = null)
{
$data = [];
if (null !== $form) {
if (!$form->isSubmitted()) {
throw new RuntimeException('Form must have been submitted');
}
$newData = $form->getData();
$data = $this->filterNullValues($newData);
}
$currentConf = $conf ? ($conf->get('registry') ?: []) : [];
return array_replace_recursive($this->getDefaultData($currentConf), $data);
} | php | public function getRegistryData(FormInterface $form = null, PropertyAccess $conf = null)
{
$data = [];
if (null !== $form) {
if (!$form->isSubmitted()) {
throw new RuntimeException('Form must have been submitted');
}
$newData = $form->getData();
$data = $this->filterNullValues($newData);
}
$currentConf = $conf ? ($conf->get('registry') ?: []) : [];
return array_replace_recursive($this->getDefaultData($currentConf), $data);
} | [
"public",
"function",
"getRegistryData",
"(",
"FormInterface",
"$",
"form",
"=",
"null",
",",
"PropertyAccess",
"$",
"conf",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"form",
")",
"{",
"if",
"(",
"!",
"$... | Gets the registry data given a submitted form.
Default configuration is returned if no form provided.
@param FormInterface $form
@param PropertyAccess $conf
@return array | [
"Gets",
"the",
"registry",
"data",
"given",
"a",
"submitted",
"form",
".",
"Default",
"configuration",
"is",
"returned",
"if",
"no",
"form",
"provided",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Configuration/RegistryFormManipulator.php#L66-L81 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Command/SearchEngine/IndexManipulateCommand.php | IndexManipulateCommand.verbose | private function verbose($s, $verbosity = OutputInterface::VERBOSITY_VERBOSE)
{
if ($this->output->getVerbosity() >= $verbosity) {
$this->output->writeln($s);
}
} | php | private function verbose($s, $verbosity = OutputInterface::VERBOSITY_VERBOSE)
{
if ($this->output->getVerbosity() >= $verbosity) {
$this->output->writeln($s);
}
} | [
"private",
"function",
"verbose",
"(",
"$",
"s",
",",
"$",
"verbosity",
"=",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"output",
"->",
"getVerbosity",
"(",
")",
">=",
"$",
"verbosity",
")",
"{",
"$",
"this",
... | print a string if verbosity >= verbose (-v)
@param string $s
@param int $verbosity | [
"print",
"a",
"string",
"if",
"verbosity",
">",
"=",
"verbose",
"(",
"-",
"v",
")"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Command/SearchEngine/IndexManipulateCommand.php#L32-L37 |
alchemy-fr/Phraseanet | lib/classes/patch/383alpha3a.php | patch_383alpha3a.apply | public function apply(base $appbox, Application $app)
{
$sql = 'SELECT base_id, ord, sbas_id
FROM `bas`
ORDER BY sbas_id, ord';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sbasData = [];
$sbas_id = null;
$reorder = [];
foreach ($rs as $row) {
$sbasData[$row['sbas_id']][] = ['base_id' => $row['base_id']];
if ($sbas_id !== $row['sbas_id']) {
$orders = [];
}
$sbas_id = $row['sbas_id'];
if (in_array($row['ord'], $orders, true)) {
$reorder[] = $row['sbas_id'];
}
$orders[] = $row['ord'];
}
$reorder = array_unique($reorder);
if (count($reorder) > 0) {
$sql = 'UPDATE bas SET ord = :ord WHERE base_id = :base_id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($reorder as $sbas_id) {
$i = 1;
foreach ($sbasData[$sbas_id] as $data) {
$stmt->execute(['base_id' => $data['base_id'], 'ord' => $i++]);
}
}
$stmt->closeCursor();
}
return true;
} | php | public function apply(base $appbox, Application $app)
{
$sql = 'SELECT base_id, ord, sbas_id
FROM `bas`
ORDER BY sbas_id, ord';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sbasData = [];
$sbas_id = null;
$reorder = [];
foreach ($rs as $row) {
$sbasData[$row['sbas_id']][] = ['base_id' => $row['base_id']];
if ($sbas_id !== $row['sbas_id']) {
$orders = [];
}
$sbas_id = $row['sbas_id'];
if (in_array($row['ord'], $orders, true)) {
$reorder[] = $row['sbas_id'];
}
$orders[] = $row['ord'];
}
$reorder = array_unique($reorder);
if (count($reorder) > 0) {
$sql = 'UPDATE bas SET ord = :ord WHERE base_id = :base_id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($reorder as $sbas_id) {
$i = 1;
foreach ($sbasData[$sbas_id] as $data) {
$stmt->execute(['base_id' => $data['base_id'], 'ord' => $i++]);
}
}
$stmt->closeCursor();
}
return true;
} | [
"public",
"function",
"apply",
"(",
"base",
"$",
"appbox",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"sql",
"=",
"'SELECT base_id, ord, sbas_id\n FROM `bas`\n ORDER BY sbas_id, ord'",
";",
"$",
"stmt",
"=",
"$",
"appbox",
"->",
"get... | {@inheritdoc} | [
"{"
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/classes/patch/383alpha3a.php#L49-L88 |
alchemy-fr/Phraseanet | lib/Alchemy/Phrasea/Core/Provider/WebProfilerServiceProvider.php | WebProfilerServiceProvider.register | public function register(Application $app)
{
// Required because the Silex provider is not up to date with Symfony Debug Toolbar
$app['web_profiler.toolbar.listener'] = $app->share(
$app->extend('web_profiler.toolbar.listener', function () use ($app) {
return new WebDebugToolbarListener(
$app['twig'],
$app['web_profiler.debug_toolbar.intercept_redirects'],
2,
$app['web_profiler.debug_toolbar.position'],
$app['url_generator']
);
})
);
if (class_exists(AjaxDataCollector::class)) {
$app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function (array $templates) {
$templates[] = array('ajax', '@WebProfiler/Collector/ajax.html.twig');
return $templates;
}));
$app['data_collectors'] = $app->share($app->extend('data_collectors', function (array $collectors, $app) {
$collectors['ajax'] = $app->share(function () {
return new AjaxDataCollector();
});
return $collectors;
}));
}
$app['dbal.config.register.loggers'] = $app->protect(function (Configuration $config, $name) use ($app) {
$debugLogger = new DebugStack();
$loggerChain = new LoggerChain();
$loggerChain->addLogger($debugLogger);
$loggerChain->addLogger($app['data_collectors.doctrine.logger']);
$app['data_collectors.doctrine']->addLogger($name, $debugLogger);
$config->setSQLLogger($loggerChain);
});
$app['data_collectors.doctrine.logger'] = $app->share(function ($app) {
return new DbalLogger($app['logger'], $app['stopwatch']);
});
$app['data_collectors.doctrine'] = $app->share(function ($app) {
return new DoctrineDataCollector(new LazyArrayAccess(new LazyLocator($app, 'dbs')));
});
$app['cache'] = $app->share($app->extend('cache', function (Cache $cache, $app) {
$namespace = $app['conf']->get(['main', 'cache', 'options', 'namespace']);
$cache = new TraceableCache($cache);
$cache->setNamespace($namespace);
return $cache;
}));
$app['data_collector.cache_subscriber'] = $app->share(function ($app) {
return new CacheStatisticsSubscriber($app['cache']);
});
$app['data_collectors'] = $app->share($app->extend('data_collectors', function (array $collectors, $app) {
$collectors['db'] = $app->share(function ($app) {
return $app['data_collectors.doctrine'];
});
$collectors['cache'] = $app->share(function ($app) {
return new CacheDataCollector($app['data_collector.cache_subscriber']);
});
return $collectors;
}));
$app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function (array $templates) {
$templates[] = array('db', '@DoctrineBundle/Collector/db.html.twig');
$templates[] = array('cache', '@PhraseaProfiler/cache.html.twig');
return $templates;
}));
$app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
$loader->addPath(
$app['root.path'] . '/vendor/sorien/silex-dbal-profiler/src/Sorien/Resources/views',
'DoctrineBundle'
);
$loader->addPath($app['root.path'] . '/templates-profiler/', 'PhraseaProfiler');
return $loader;
}));
} | php | public function register(Application $app)
{
// Required because the Silex provider is not up to date with Symfony Debug Toolbar
$app['web_profiler.toolbar.listener'] = $app->share(
$app->extend('web_profiler.toolbar.listener', function () use ($app) {
return new WebDebugToolbarListener(
$app['twig'],
$app['web_profiler.debug_toolbar.intercept_redirects'],
2,
$app['web_profiler.debug_toolbar.position'],
$app['url_generator']
);
})
);
if (class_exists(AjaxDataCollector::class)) {
$app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function (array $templates) {
$templates[] = array('ajax', '@WebProfiler/Collector/ajax.html.twig');
return $templates;
}));
$app['data_collectors'] = $app->share($app->extend('data_collectors', function (array $collectors, $app) {
$collectors['ajax'] = $app->share(function () {
return new AjaxDataCollector();
});
return $collectors;
}));
}
$app['dbal.config.register.loggers'] = $app->protect(function (Configuration $config, $name) use ($app) {
$debugLogger = new DebugStack();
$loggerChain = new LoggerChain();
$loggerChain->addLogger($debugLogger);
$loggerChain->addLogger($app['data_collectors.doctrine.logger']);
$app['data_collectors.doctrine']->addLogger($name, $debugLogger);
$config->setSQLLogger($loggerChain);
});
$app['data_collectors.doctrine.logger'] = $app->share(function ($app) {
return new DbalLogger($app['logger'], $app['stopwatch']);
});
$app['data_collectors.doctrine'] = $app->share(function ($app) {
return new DoctrineDataCollector(new LazyArrayAccess(new LazyLocator($app, 'dbs')));
});
$app['cache'] = $app->share($app->extend('cache', function (Cache $cache, $app) {
$namespace = $app['conf']->get(['main', 'cache', 'options', 'namespace']);
$cache = new TraceableCache($cache);
$cache->setNamespace($namespace);
return $cache;
}));
$app['data_collector.cache_subscriber'] = $app->share(function ($app) {
return new CacheStatisticsSubscriber($app['cache']);
});
$app['data_collectors'] = $app->share($app->extend('data_collectors', function (array $collectors, $app) {
$collectors['db'] = $app->share(function ($app) {
return $app['data_collectors.doctrine'];
});
$collectors['cache'] = $app->share(function ($app) {
return new CacheDataCollector($app['data_collector.cache_subscriber']);
});
return $collectors;
}));
$app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function (array $templates) {
$templates[] = array('db', '@DoctrineBundle/Collector/db.html.twig');
$templates[] = array('cache', '@PhraseaProfiler/cache.html.twig');
return $templates;
}));
$app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
$loader->addPath(
$app['root.path'] . '/vendor/sorien/silex-dbal-profiler/src/Sorien/Resources/views',
'DoctrineBundle'
);
$loader->addPath($app['root.path'] . '/templates-profiler/', 'PhraseaProfiler');
return $loader;
}));
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"// Required because the Silex provider is not up to date with Symfony Debug Toolbar",
"$",
"app",
"[",
"'web_profiler.toolbar.listener'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"$",
"app",
"... | Registers services on the given app.
This method should only be used to configure services and parameters.
It should not get services. | [
"Registers",
"services",
"on",
"the",
"given",
"app",
"."
] | train | https://github.com/alchemy-fr/Phraseanet/blob/904b67192e276ab4706efb7b72df4910f9e00973/lib/Alchemy/Phrasea/Core/Provider/WebProfilerServiceProvider.php#L30-L121 |
FriendsOfCake/bootstrap-ui | src/View/Widget/ButtonWidget.php | ButtonWidget.render | public function render(array $data, ContextInterface $context)
{
$data = $this->applyButtonClasses($data);
return parent::render($data, $context);
} | php | public function render(array $data, ContextInterface $context)
{
$data = $this->applyButtonClasses($data);
return parent::render($data, $context);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"applyButtonClasses",
"(",
"$",
"data",
")",
";",
"return",
"parent",
"::",
"render",
"(",
"$",
"data",
"... | Renders a button.
@param array $data The data to build a button with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string | [
"Renders",
"a",
"button",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Widget/ButtonWidget.php#L34-L39 |
FriendsOfCake/bootstrap-ui | src/View/UIViewTrait.php | UIViewTrait.initializeUI | public function initializeUI(array $options = [])
{
if ((!isset($options['layout']) || $options['layout'] === true) &&
$this->layout === 'default'
) {
$this->layout = 'BootstrapUI.default';
} elseif (isset($options['layout']) && is_string($options['layout'])) {
$this->layout = $options['layout'];
}
$this->loadHelper('Html', ['className' => 'BootstrapUI.Html']);
$this->loadHelper('Form', ['className' => 'BootstrapUI.Form']);
$this->loadHelper('Flash', ['className' => 'BootstrapUI.Flash']);
$this->loadHelper('Paginator', ['className' => 'BootstrapUI.Paginator']);
if (class_exists('\Cake\View\Helper\BreadcrumbsHelper')) {
$this->loadHelper('Breadcrumbs', ['className' => 'BootstrapUI.Breadcrumbs']);
}
} | php | public function initializeUI(array $options = [])
{
if ((!isset($options['layout']) || $options['layout'] === true) &&
$this->layout === 'default'
) {
$this->layout = 'BootstrapUI.default';
} elseif (isset($options['layout']) && is_string($options['layout'])) {
$this->layout = $options['layout'];
}
$this->loadHelper('Html', ['className' => 'BootstrapUI.Html']);
$this->loadHelper('Form', ['className' => 'BootstrapUI.Form']);
$this->loadHelper('Flash', ['className' => 'BootstrapUI.Flash']);
$this->loadHelper('Paginator', ['className' => 'BootstrapUI.Paginator']);
if (class_exists('\Cake\View\Helper\BreadcrumbsHelper')) {
$this->loadHelper('Breadcrumbs', ['className' => 'BootstrapUI.Breadcrumbs']);
}
} | [
"public",
"function",
"initializeUI",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'layout'",
"]",
")",
"||",
"$",
"options",
"[",
"'layout'",
"]",
"===",
"true",
")",
"&&",
"$",
... | Initialization hook method.
@param array $options Associative array with valid keys:
- `layout`:
- If not set or true will use the plugin's layout
- If a layout name passed it will be used
- If false do nothing (will keep your layout)
@return void | [
"Initialization",
"hook",
"method",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/UIViewTrait.php#L22-L39 |
FriendsOfCake/bootstrap-ui | src/View/Helper/BreadcrumbsHelper.php | BreadcrumbsHelper.render | public function render(array $attributes = [], array $separator = [])
{
$attributes += $this->_defaultAttributes;
return parent::render($attributes, $separator);
} | php | public function render(array $attributes = [], array $separator = [])
{
$attributes += $this->_defaultAttributes;
return parent::render($attributes, $separator);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"array",
"$",
"separator",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"+=",
"$",
"this",
"->",
"_defaultAttributes",
";",
"return",
"parent",
"::",
"render",
"(",
"$"... | {@inheritDoc} | [
"{"
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/BreadcrumbsHelper.php#L32-L37 |
FriendsOfCake/bootstrap-ui | src/View/Widget/RadioWidget.php | RadioWidget.render | public function render(array $data, ContextInterface $context)
{
$data += [
'inline' => false,
];
$this->_inline = $data['inline'];
unset($data['inline']);
return parent::render($data, $context);
} | php | public function render(array $data, ContextInterface $context)
{
$data += [
'inline' => false,
];
$this->_inline = $data['inline'];
unset($data['inline']);
return parent::render($data, $context);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"+=",
"[",
"'inline'",
"=>",
"false",
",",
"]",
";",
"$",
"this",
"->",
"_inline",
"=",
"$",
"data",
"[",
"'inline'",
"]",
";",... | Render a set of radio buttons.
Data supports the following keys:
- `name` - Set the input name.
- `inline` - The alignement to use.
- `options` - An array of options. See below for more information.
- `disabled` - Either true or an array of inputs to disable.
When true, the select element will be disabled.
- `val` - A string of the option to mark as selected.
- `label` - Either false to disable label generation, or
an array of attributes for all labels.
- `required` - Set to true to add the required attribute
on all generated radios.
- `idPrefix` Prefix for generated ID attributes.
@param array $data The data to build radio buttons with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string | [
"Render",
"a",
"set",
"of",
"radio",
"buttons",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Widget/RadioWidget.php#L38-L47 |
FriendsOfCake/bootstrap-ui | src/View/Widget/RadioWidget.php | RadioWidget._renderLabel | protected function _renderLabel($radio, $label, $input, $context, $escape)
{
if ($this->_inline) {
$label = [
'text' => $radio['text'],
'class' => 'radio-inline'
];
}
return parent::_renderLabel($radio, $label, $input, $context, $escape);
} | php | protected function _renderLabel($radio, $label, $input, $context, $escape)
{
if ($this->_inline) {
$label = [
'text' => $radio['text'],
'class' => 'radio-inline'
];
}
return parent::_renderLabel($radio, $label, $input, $context, $escape);
} | [
"protected",
"function",
"_renderLabel",
"(",
"$",
"radio",
",",
"$",
"label",
",",
"$",
"input",
",",
"$",
"context",
",",
"$",
"escape",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_inline",
")",
"{",
"$",
"label",
"=",
"[",
"'text'",
"=>",
"$",
"... | Renders a label element for a given radio button.
In the future this might be refactored into a separate widget as other
input types (multi-checkboxes) will also need labels generated.
@param array $radio The input properties.
@param false|string|array $label The properties for a label.
@param string $input The input widget.
@param \Cake\View\Form\ContextInterface $context The form context.
@param bool $escape Whether or not to HTML escape the label.
@return string Generated label. | [
"Renders",
"a",
"label",
"element",
"for",
"a",
"given",
"radio",
"button",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Widget/RadioWidget.php#L62-L72 |
FriendsOfCake/bootstrap-ui | src/View/Helper/PaginatorHelper.php | PaginatorHelper.numbers | public function numbers(array $options = [])
{
$class = 'pagination';
$options += [
'class' => $class,
'after' => '</ul>',
'size' => null,
];
$options['class'] = implode(' ', (array)$options['class']);
if (!empty($options['size'])) {
$options['class'] .= " {$class}-{$options['size']}";
}
$options += [
'before' => '<ul class="' . $options['class'] . '">',
];
unset($options['class'], $options['size']);
if (isset($options['prev'])) {
if ($options['prev'] === true) {
$options['prev'] = $this->getConfig('labels.prev');
}
$options['before'] .= $this->prev($options['prev'], ['escape' => false]);
}
if (isset($options['next'])) {
if ($options['next'] === true) {
$options['next'] = $this->getConfig('labels.next');
}
$options['after'] = $this->next($options['next'], ['escape' => false]) . $options['after'];
}
return parent::numbers($options);
} | php | public function numbers(array $options = [])
{
$class = 'pagination';
$options += [
'class' => $class,
'after' => '</ul>',
'size' => null,
];
$options['class'] = implode(' ', (array)$options['class']);
if (!empty($options['size'])) {
$options['class'] .= " {$class}-{$options['size']}";
}
$options += [
'before' => '<ul class="' . $options['class'] . '">',
];
unset($options['class'], $options['size']);
if (isset($options['prev'])) {
if ($options['prev'] === true) {
$options['prev'] = $this->getConfig('labels.prev');
}
$options['before'] .= $this->prev($options['prev'], ['escape' => false]);
}
if (isset($options['next'])) {
if ($options['next'] === true) {
$options['next'] = $this->getConfig('labels.next');
}
$options['after'] = $this->next($options['next'], ['escape' => false]) . $options['after'];
}
return parent::numbers($options);
} | [
"public",
"function",
"numbers",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"'pagination'",
";",
"$",
"options",
"+=",
"[",
"'class'",
"=>",
"$",
"class",
",",
"'after'",
"=>",
"'</ul>'",
",",
"'size'",
"=>",
"null",
",... | Returns a set of numbers for the paged result set.
In addition to the numbers, the method can also generate previous and next
links using additional options as shown below which are not available in
CakePHP core's PaginatorHelper::numbers().
### Options
- `prev` If set generates "previous" link. Can be `true` or string.
- `next` If set generates "next" link. Can be `true` or string.
- `size` Used to control sizing class added to UL tag. For eg.
using `'size' => 'lg'` would add class `pagination-lg` to UL tag.
@param array $options Options for the numbers.
@return string Numbers string.
@link http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-page-number-links | [
"Returns",
"a",
"set",
"of",
"numbers",
"for",
"the",
"paged",
"result",
"set",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/PaginatorHelper.php#L65-L102 |
FriendsOfCake/bootstrap-ui | src/View/Helper/OptionsAwareTrait.php | OptionsAwareTrait.applyButtonClasses | public function applyButtonClasses(array $data)
{
if ($this->hasAnyClass($this->buttonClasses, $data)) {
$data = $this->injectClasses(['btn'], $data);
} else {
$data = $this->injectClasses(['btn', 'btn-default'], $data);
}
return $this->renameClasses($this->buttonClassAliases, $data);
} | php | public function applyButtonClasses(array $data)
{
if ($this->hasAnyClass($this->buttonClasses, $data)) {
$data = $this->injectClasses(['btn'], $data);
} else {
$data = $this->injectClasses(['btn', 'btn-default'], $data);
}
return $this->renameClasses($this->buttonClassAliases, $data);
} | [
"public",
"function",
"applyButtonClasses",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAnyClass",
"(",
"$",
"this",
"->",
"buttonClasses",
",",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"injectClasses"... | Contains the logic for applying style classes for buttons.
@param array $data An array of HTML attributes and options.
@return array An array of HTML attributes and options. | [
"Contains",
"the",
"logic",
"for",
"applying",
"style",
"classes",
"for",
"buttons",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/OptionsAwareTrait.php#L41-L50 |
FriendsOfCake/bootstrap-ui | src/View/Helper/OptionsAwareTrait.php | OptionsAwareTrait.renameClasses | public function renameClasses(array $classMap, array $options)
{
$options += ['class' => []];
$options['class'] = $this->_toClassArray($options['class']);
$classes = [];
foreach ($options['class'] as $name) {
$classes[] = array_key_exists($name, $classMap)
? $classMap[$name]
: $name;
}
$options['class'] = trim(implode(' ', $classes));
return $options;
} | php | public function renameClasses(array $classMap, array $options)
{
$options += ['class' => []];
$options['class'] = $this->_toClassArray($options['class']);
$classes = [];
foreach ($options['class'] as $name) {
$classes[] = array_key_exists($name, $classMap)
? $classMap[$name]
: $name;
}
$options['class'] = trim(implode(' ', $classes));
return $options;
} | [
"public",
"function",
"renameClasses",
"(",
"array",
"$",
"classMap",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'class'",
"=>",
"[",
"]",
"]",
";",
"$",
"options",
"[",
"'class'",
"]",
"=",
"$",
"this",
"->",
"_toClassArray",
... | Renames any CSS classes found in the options.
@param array $classMap Key/Value pair of class(es) to be renamed.
@param array $options An array of HTML attributes and options.
@return array An array of HTML attributes and options. | [
"Renames",
"any",
"CSS",
"classes",
"found",
"in",
"the",
"options",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/OptionsAwareTrait.php#L59-L72 |
FriendsOfCake/bootstrap-ui | src/View/Helper/OptionsAwareTrait.php | OptionsAwareTrait.hasAnyClass | public function hasAnyClass($classes, array $options)
{
$options += ['class' => []];
$options['class'] = $this->_toClassArray($options['class']);
$classes = $this->_toClassArray($classes);
foreach ($classes as $class) {
if (in_array($class, $options['class'])) {
return true;
}
}
return false;
} | php | public function hasAnyClass($classes, array $options)
{
$options += ['class' => []];
$options['class'] = $this->_toClassArray($options['class']);
$classes = $this->_toClassArray($classes);
foreach ($classes as $class) {
if (in_array($class, $options['class'])) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasAnyClass",
"(",
"$",
"classes",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'class'",
"=>",
"[",
"]",
"]",
";",
"$",
"options",
"[",
"'class'",
"]",
"=",
"$",
"this",
"->",
"_toClassArray",
"(",
"$",
... | Checks if `$options['class']` contains any one of the class names.
@param array|string $classes Name of class(es) to check.
@param array $options An array of HTML attributes and options.
@return bool True if any one of the class names was found. | [
"Checks",
"if",
"$options",
"[",
"class",
"]",
"contains",
"any",
"one",
"of",
"the",
"class",
"names",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/OptionsAwareTrait.php#L81-L95 |
FriendsOfCake/bootstrap-ui | src/View/Helper/OptionsAwareTrait.php | OptionsAwareTrait.injectClasses | public function injectClasses($classes, array $options)
{
$options += ['class' => [], 'skip' => []];
$options['class'] = $this->_toClassArray($options['class']);
$options['skip'] = $this->_toClassArray($options['skip']);
$classes = $this->_toClassArray($classes);
foreach ($classes as $class) {
if (!in_array($class, $options['class']) && !in_array($class, $options['skip'])) {
array_push($options['class'], $class);
}
}
unset($options['skip']);
$options['class'] = trim(implode(' ', $options['class']));
return $options;
} | php | public function injectClasses($classes, array $options)
{
$options += ['class' => [], 'skip' => []];
$options['class'] = $this->_toClassArray($options['class']);
$options['skip'] = $this->_toClassArray($options['skip']);
$classes = $this->_toClassArray($classes);
foreach ($classes as $class) {
if (!in_array($class, $options['class']) && !in_array($class, $options['skip'])) {
array_push($options['class'], $class);
}
}
unset($options['skip']);
$options['class'] = trim(implode(' ', $options['class']));
return $options;
} | [
"public",
"function",
"injectClasses",
"(",
"$",
"classes",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'class'",
"=>",
"[",
"]",
",",
"'skip'",
"=>",
"[",
"]",
"]",
";",
"$",
"options",
"[",
"'class'",
"]",
"=",
"$",
"this"... | Injects classes into `$options['class']` when they don't already exist. If a class is defined
in `$options['skip']` then it will not be injected. This method removes `$options['skip']` before
returning.
@param array|string $classes Name of class(es) to inject.
@param array $options An array of HTML attributes and options.
@return array An array of HTML attributes and options. | [
"Injects",
"classes",
"into",
"$options",
"[",
"class",
"]",
"when",
"they",
"don",
"t",
"already",
"exist",
".",
"If",
"a",
"class",
"is",
"defined",
"in",
"$options",
"[",
"skip",
"]",
"then",
"it",
"will",
"not",
"be",
"injected",
".",
"This",
"meth... | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/OptionsAwareTrait.php#L106-L124 |
FriendsOfCake/bootstrap-ui | src/View/Helper/OptionsAwareTrait.php | OptionsAwareTrait.checkClasses | public function checkClasses($classes, array $options)
{
if (empty($options['class'])) {
return false;
}
$options['class'] = $this->_toClassArray($options['class']);
$classes = $this->_toClassArray($classes);
foreach ($classes as $class) {
if (!in_array($class, $options['class'])) {
return false;
}
}
return true;
} | php | public function checkClasses($classes, array $options)
{
if (empty($options['class'])) {
return false;
}
$options['class'] = $this->_toClassArray($options['class']);
$classes = $this->_toClassArray($classes);
foreach ($classes as $class) {
if (!in_array($class, $options['class'])) {
return false;
}
}
return true;
} | [
"public",
"function",
"checkClasses",
"(",
"$",
"classes",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'class'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"options",
"[",
"'class'",
"]",
"=",
"... | Checks if `$classes` are part of the `$options['class']`.
@param array|string $classes Name of class(es) to check.
@param array $options An array of HTML attributes and options.
@return bool False if one or more class(es) do not exist. | [
"Checks",
"if",
"$classes",
"are",
"part",
"of",
"the",
"$options",
"[",
"class",
"]",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/OptionsAwareTrait.php#L133-L149 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper.create | public function create($model = null, array $options = [])
{
// @codeCoverageIgnoreStart
if (isset($options['horizontal'])) {
if ($options['horizontal'] === true) {
$options['horizontal'] = 'horizontal';
}
$options['align'] = $options['horizontal'];
unset($options['horizontal']);
trigger_error('The `horizontal` option is deprecated. Use `align` instead.');
}
// @codeCoverageIgnoreEnd
$options += [
'class' => null,
'role' => 'form',
'align' => null,
'templates' => [],
];
return parent::create($model, $this->_formAlignment($options));
} | php | public function create($model = null, array $options = [])
{
// @codeCoverageIgnoreStart
if (isset($options['horizontal'])) {
if ($options['horizontal'] === true) {
$options['horizontal'] = 'horizontal';
}
$options['align'] = $options['horizontal'];
unset($options['horizontal']);
trigger_error('The `horizontal` option is deprecated. Use `align` instead.');
}
// @codeCoverageIgnoreEnd
$options += [
'class' => null,
'role' => 'form',
'align' => null,
'templates' => [],
];
return parent::create($model, $this->_formAlignment($options));
} | [
"public",
"function",
"create",
"(",
"$",
"model",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// @codeCoverageIgnoreStart",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'horizontal'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"o... | Returns an HTML FORM element.
@param mixed $model The context for which the form is being defined. Can
be an ORM entity, ORM resultset, or an array of meta data. You can use false or null
to make a model-less form.
@param array $options An array of html attributes and options.
@return string An formatted opening FORM tag. | [
"Returns",
"an",
"HTML",
"FORM",
"element",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L141-L162 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper.submit | public function submit($caption = null, array $options = [])
{
$options = $this->applyButtonClasses($options);
return parent::submit($caption, $options);
} | php | public function submit($caption = null, array $options = [])
{
$options = $this->applyButtonClasses($options);
return parent::submit($caption, $options);
} | [
"public",
"function",
"submit",
"(",
"$",
"caption",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"applyButtonClasses",
"(",
"$",
"options",
")",
";",
"return",
"parent",
"::",
"submit",
... | Creates a submit button element.
Overrides parent method to add CSS class `btn`, to the element.
@param string $caption The label appearing on the button OR if string contains :// or the
extension .jpg, .jpe, .jpeg, .gif, .png use an image if the extension
exists, AND the first character is /, image is relative to webroot,
OR if the first character is not /, image is relative to webroot/img.
@param array $options Array of options. See above.
@return string A HTML submit button
@link http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-buttons-and-submit-elements | [
"Creates",
"a",
"submit",
"button",
"element",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L177-L182 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper.control | public function control($fieldName, array $options = [])
{
$options += [
'prepend' => null,
'append' => null,
'inline' => null,
'type' => null,
'label' => null,
'error' => null,
'required' => null,
'options' => null,
'help' => null,
'tooltip' => null,
'templates' => [],
'templateVars' => []
];
$options = $this->_parseOptions($fieldName, $options);
$newTemplates = $options['templates'];
if ($newTemplates) {
$this->templater()->push();
$templateMethod = is_string($options['templates']) ? 'load' : 'add';
$this->templater()->{$templateMethod}($options['templates']);
$options['templates'] = [];
}
switch ($options['type']) {
case 'checkbox':
if (!isset($options['inline'])) {
$options['inline'] = $this->checkClasses($options['type'] . '-inline', (array)$options['label']);
}
if ($options['inline']) {
$options['label'] = $this->injectClasses($options['type'] . '-inline', (array)$options['label']);
if (!isset($newTemplates['checkboxContainer'])) {
$options['templates']['checkboxContainer'] = '{{content}}';
}
}
unset($options['inline']);
break;
case 'radio':
if ($options['inline'] && $this->_align !== 'horizontal') {
$options['templates']['formGroup'] = $this->templater()->get('radioInlineFormGroup');
}
if (!$options['inline']) {
$options['templates']['nestingLabel'] = $this->templater()->get('radioNestingLabel');
}
break;
case 'select':
if (isset($options['multiple']) && $options['multiple'] === 'checkbox') {
$options['type'] = 'multicheckbox';
} else {
if ($options['label'] !== false && strpos($this->getTemplates('label'), 'class=') === false) {
$options['label'] = $this->injectClasses('control-label', (array)$options['label']);
}
}
break;
case 'multiselect':
break;
case 'textarea':
default:
if ($options['label'] !== false && strpos($this->getTemplates('label'), 'class=') === false) {
$options['label'] = $this->injectClasses('control-label', (array)$options['label']);
}
}
if ($options['help']) {
$options['help'] = $this->templater()->format(
'help',
['content' => $options['help']]
);
}
if ($options['tooltip']) {
$tooltip = $this->templater()->format(
'tooltip',
['content' => $options['tooltip']]
);
$options['label']['templateVars']['tooltip'] = ' ' . $tooltip;
unset($options['tooltip']);
}
$controlMethod = $this->_controlMethod;
$result = parent::$controlMethod($fieldName, $options);
if ($newTemplates) {
$this->templater()->pop();
}
return $result;
} | php | public function control($fieldName, array $options = [])
{
$options += [
'prepend' => null,
'append' => null,
'inline' => null,
'type' => null,
'label' => null,
'error' => null,
'required' => null,
'options' => null,
'help' => null,
'tooltip' => null,
'templates' => [],
'templateVars' => []
];
$options = $this->_parseOptions($fieldName, $options);
$newTemplates = $options['templates'];
if ($newTemplates) {
$this->templater()->push();
$templateMethod = is_string($options['templates']) ? 'load' : 'add';
$this->templater()->{$templateMethod}($options['templates']);
$options['templates'] = [];
}
switch ($options['type']) {
case 'checkbox':
if (!isset($options['inline'])) {
$options['inline'] = $this->checkClasses($options['type'] . '-inline', (array)$options['label']);
}
if ($options['inline']) {
$options['label'] = $this->injectClasses($options['type'] . '-inline', (array)$options['label']);
if (!isset($newTemplates['checkboxContainer'])) {
$options['templates']['checkboxContainer'] = '{{content}}';
}
}
unset($options['inline']);
break;
case 'radio':
if ($options['inline'] && $this->_align !== 'horizontal') {
$options['templates']['formGroup'] = $this->templater()->get('radioInlineFormGroup');
}
if (!$options['inline']) {
$options['templates']['nestingLabel'] = $this->templater()->get('radioNestingLabel');
}
break;
case 'select':
if (isset($options['multiple']) && $options['multiple'] === 'checkbox') {
$options['type'] = 'multicheckbox';
} else {
if ($options['label'] !== false && strpos($this->getTemplates('label'), 'class=') === false) {
$options['label'] = $this->injectClasses('control-label', (array)$options['label']);
}
}
break;
case 'multiselect':
break;
case 'textarea':
default:
if ($options['label'] !== false && strpos($this->getTemplates('label'), 'class=') === false) {
$options['label'] = $this->injectClasses('control-label', (array)$options['label']);
}
}
if ($options['help']) {
$options['help'] = $this->templater()->format(
'help',
['content' => $options['help']]
);
}
if ($options['tooltip']) {
$tooltip = $this->templater()->format(
'tooltip',
['content' => $options['tooltip']]
);
$options['label']['templateVars']['tooltip'] = ' ' . $tooltip;
unset($options['tooltip']);
}
$controlMethod = $this->_controlMethod;
$result = parent::$controlMethod($fieldName, $options);
if ($newTemplates) {
$this->templater()->pop();
}
return $result;
} | [
"public",
"function",
"control",
"(",
"$",
"fieldName",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'prepend'",
"=>",
"null",
",",
"'append'",
"=>",
"null",
",",
"'inline'",
"=>",
"null",
",",
"'type'",
"=>",
"n... | Generates a form input element complete with label and wrapper div.
Adds extra option besides the ones supported by parent class method:
- `append` - Append addon to input.
- `prepend` - Prepend addon to input.
- `inline` - Boolean for generating inline checkbox/radio.
- `help` - Help text of include in the input container.
@param string $fieldName This should be "Modelname.fieldname".
@param array $options Each type of input takes different options.
@return string Completed form widget. | [
"Generates",
"a",
"form",
"input",
"element",
"complete",
"with",
"label",
"and",
"wrapper",
"div",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L216-L310 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper.end | public function end(array $secureAttributes = [])
{
$this->_align = $this->_grid = null;
return parent::end($secureAttributes);
} | php | public function end(array $secureAttributes = [])
{
$this->_align = $this->_grid = null;
return parent::end($secureAttributes);
} | [
"public",
"function",
"end",
"(",
"array",
"$",
"secureAttributes",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"_align",
"=",
"$",
"this",
"->",
"_grid",
"=",
"null",
";",
"return",
"parent",
"::",
"end",
"(",
"$",
"secureAttributes",
")",
";",
"}"
... | Closes an HTML form, cleans up values set by FormHelper::create(), and writes hidden
input fields where appropriate.
Overrides parent method to reset the form alignment and grid size.
@param array $secureAttributes Secure attributes which will be passed as HTML attributes
into the hidden input elements generated for the Security Component.
@return string A closing FORM tag. | [
"Closes",
"an",
"HTML",
"form",
"cleans",
"up",
"values",
"set",
"by",
"FormHelper",
"::",
"create",
"()",
"and",
"writes",
"hidden",
"input",
"fields",
"where",
"appropriate",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L322-L327 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper.staticControl | public function staticControl($fieldName, array $options = [])
{
$options += [
'escape' => true,
'required' => false,
'secure' => true,
'hiddenField' => true
];
$secure = $options['secure'];
$hiddenField = $options['hiddenField'];
unset($options['secure'], $options['hiddenField']);
$options = $this->_initInputField(
$fieldName,
['secure' => static::SECURE_SKIP] + $options
);
$content = $options['escape'] ? h($options['val']) : $options['val'];
$static = $this->formatTemplate('staticControl', [
'content' => $content
]);
if (!$hiddenField) {
return $static;
}
if ($secure === true) {
$this->_secure(true, $this->_secureFieldName($options['name']), (string)$options['val']);
}
$options['type'] = 'hidden';
return $static . $this->widget('hidden', $options);
} | php | public function staticControl($fieldName, array $options = [])
{
$options += [
'escape' => true,
'required' => false,
'secure' => true,
'hiddenField' => true
];
$secure = $options['secure'];
$hiddenField = $options['hiddenField'];
unset($options['secure'], $options['hiddenField']);
$options = $this->_initInputField(
$fieldName,
['secure' => static::SECURE_SKIP] + $options
);
$content = $options['escape'] ? h($options['val']) : $options['val'];
$static = $this->formatTemplate('staticControl', [
'content' => $content
]);
if (!$hiddenField) {
return $static;
}
if ($secure === true) {
$this->_secure(true, $this->_secureFieldName($options['name']), (string)$options['val']);
}
$options['type'] = 'hidden';
return $static . $this->widget('hidden', $options);
} | [
"public",
"function",
"staticControl",
"(",
"$",
"fieldName",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'escape'",
"=>",
"true",
",",
"'required'",
"=>",
"false",
",",
"'secure'",
"=>",
"true",
",",
"'hiddenField'... | Used to place plain text next to label within a form.
### Options:
- `hiddenField` - boolean to indicate if you want value for field included
in a hidden input. Defaults to true.
@param string $fieldName Name of a field, like this "modelname.fieldname"
@param array $options Array of HTML attributes.
@return string An HTML text input element. | [
"Used",
"to",
"place",
"plain",
"text",
"next",
"to",
"label",
"within",
"a",
"form",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L341-L375 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper._groupTemplate | protected function _groupTemplate($options)
{
$groupTemplate = $options['options']['type'] . 'FormGroup';
if (!$this->templater()->get($groupTemplate)) {
$groupTemplate = 'formGroup';
}
return $this->templater()->format($groupTemplate, [
'input' => isset($options['input']) ? $options['input'] : [],
'label' => $options['label'],
'error' => $options['error'],
'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : [],
'help' => $options['options']['help'],
]);
} | php | protected function _groupTemplate($options)
{
$groupTemplate = $options['options']['type'] . 'FormGroup';
if (!$this->templater()->get($groupTemplate)) {
$groupTemplate = 'formGroup';
}
return $this->templater()->format($groupTemplate, [
'input' => isset($options['input']) ? $options['input'] : [],
'label' => $options['label'],
'error' => $options['error'],
'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : [],
'help' => $options['options']['help'],
]);
} | [
"protected",
"function",
"_groupTemplate",
"(",
"$",
"options",
")",
"{",
"$",
"groupTemplate",
"=",
"$",
"options",
"[",
"'options'",
"]",
"[",
"'type'",
"]",
".",
"'FormGroup'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"templater",
"(",
")",
"->",
"ge... | Generates an group template element
@param array $options The options for group template
@return string The generated group template | [
"Generates",
"an",
"group",
"template",
"element"
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L399-L413 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper._inputContainerTemplate | protected function _inputContainerTemplate($options)
{
$inputContainerTemplate = $options['options']['type'] . 'Container' . $options['errorSuffix'];
if (!$this->templater()->get($inputContainerTemplate)) {
$inputContainerTemplate = 'inputContainer' . $options['errorSuffix'];
}
return $this->templater()->format($inputContainerTemplate, [
'content' => $options['content'],
'error' => $options['error'],
'required' => $options['options']['required'] ? ' required' : '',
'type' => $options['options']['type'],
'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : [],
'help' => $options['options']['help'],
]);
} | php | protected function _inputContainerTemplate($options)
{
$inputContainerTemplate = $options['options']['type'] . 'Container' . $options['errorSuffix'];
if (!$this->templater()->get($inputContainerTemplate)) {
$inputContainerTemplate = 'inputContainer' . $options['errorSuffix'];
}
return $this->templater()->format($inputContainerTemplate, [
'content' => $options['content'],
'error' => $options['error'],
'required' => $options['options']['required'] ? ' required' : '',
'type' => $options['options']['type'],
'templateVars' => isset($options['options']['templateVars']) ? $options['options']['templateVars'] : [],
'help' => $options['options']['help'],
]);
} | [
"protected",
"function",
"_inputContainerTemplate",
"(",
"$",
"options",
")",
"{",
"$",
"inputContainerTemplate",
"=",
"$",
"options",
"[",
"'options'",
"]",
"[",
"'type'",
"]",
".",
"'Container'",
".",
"$",
"options",
"[",
"'errorSuffix'",
"]",
";",
"if",
"... | Generates an input container template
@param array $options The options for input container template.
@return string The generated input container template. | [
"Generates",
"an",
"input",
"container",
"template"
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L421-L436 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper._parseOptions | protected function _parseOptions($fieldName, $options)
{
$options = parent::_parseOptions($fieldName, $options);
$options += ['id' => $this->_domId($fieldName)];
if (is_string($options['label'])) {
$options['label'] = ['text' => $options['label']];
}
return $options;
} | php | protected function _parseOptions($fieldName, $options)
{
$options = parent::_parseOptions($fieldName, $options);
$options += ['id' => $this->_domId($fieldName)];
if (is_string($options['label'])) {
$options['label'] = ['text' => $options['label']];
}
return $options;
} | [
"protected",
"function",
"_parseOptions",
"(",
"$",
"fieldName",
",",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"parent",
"::",
"_parseOptions",
"(",
"$",
"fieldName",
",",
"$",
"options",
")",
";",
"$",
"options",
"+=",
"[",
"'id'",
"=>",
"$",
"t... | Generates input options array
@param string $fieldName The name of the field to parse options for.
@param array $options Options list.
@return array Options | [
"Generates",
"input",
"options",
"array"
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L445-L454 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper._formAlignment | protected function _formAlignment($options)
{
if (!$options['align']) {
$options['align'] = $this->_detectFormAlignment($options);
}
if (is_array($options['align'])) {
$this->_grid = $options['align'];
$options['align'] = 'horizontal';
} elseif ($options['align'] === 'horizontal') {
$this->_grid = $this->getConfig('grid');
}
if (!in_array($options['align'], ['default', 'horizontal', 'inline'])) {
throw new InvalidArgumentException('Invalid `align` option value.');
}
$this->_align = $options['align'];
unset($options['align']);
$templates = $this->_config['templateSet'][$this->_align];
if (is_string($options['templates'])) {
$options['templates'] = (new PhpConfig())->read($options['templates']);
}
if ($this->_align === 'default') {
$options['templates'] += $templates;
return $options;
}
$options = $this->injectClasses('form-' . $this->_align, $options);
if ($this->_align === 'inline') {
$options['templates'] += $templates;
return $options;
}
$offsetedGridClass = implode(' ', [$this->_gridClass('left', true), $this->_gridClass('middle')]);
$templates['label'] = sprintf($templates['label'], $this->_gridClass('left'));
$templates['formGroup'] = sprintf($templates['formGroup'], $this->_gridClass('middle'));
foreach (['checkboxFormGroup', 'submitContainer'] as $value) {
$templates[$value] = sprintf($templates[$value], $offsetedGridClass);
}
$options['templates'] += $templates;
return $options;
} | php | protected function _formAlignment($options)
{
if (!$options['align']) {
$options['align'] = $this->_detectFormAlignment($options);
}
if (is_array($options['align'])) {
$this->_grid = $options['align'];
$options['align'] = 'horizontal';
} elseif ($options['align'] === 'horizontal') {
$this->_grid = $this->getConfig('grid');
}
if (!in_array($options['align'], ['default', 'horizontal', 'inline'])) {
throw new InvalidArgumentException('Invalid `align` option value.');
}
$this->_align = $options['align'];
unset($options['align']);
$templates = $this->_config['templateSet'][$this->_align];
if (is_string($options['templates'])) {
$options['templates'] = (new PhpConfig())->read($options['templates']);
}
if ($this->_align === 'default') {
$options['templates'] += $templates;
return $options;
}
$options = $this->injectClasses('form-' . $this->_align, $options);
if ($this->_align === 'inline') {
$options['templates'] += $templates;
return $options;
}
$offsetedGridClass = implode(' ', [$this->_gridClass('left', true), $this->_gridClass('middle')]);
$templates['label'] = sprintf($templates['label'], $this->_gridClass('left'));
$templates['formGroup'] = sprintf($templates['formGroup'], $this->_gridClass('middle'));
foreach (['checkboxFormGroup', 'submitContainer'] as $value) {
$templates[$value] = sprintf($templates[$value], $offsetedGridClass);
}
$options['templates'] += $templates;
return $options;
} | [
"protected",
"function",
"_formAlignment",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"options",
"[",
"'align'",
"]",
")",
"{",
"$",
"options",
"[",
"'align'",
"]",
"=",
"$",
"this",
"->",
"_detectFormAlignment",
"(",
"$",
"options",
")",
";",... | Form alignment detector/switcher.
@param array $options Options.
@return array Modified options. | [
"Form",
"alignment",
"detector",
"/",
"switcher",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L462-L513 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper._gridClass | protected function _gridClass($position, $offset = false)
{
$class = 'col-%s-';
if ($offset) {
$class .= 'offset-';
}
if (isset($this->_grid[$position])) {
return sprintf($class, 'md') . $this->_grid[$position];
}
$classes = [];
foreach ($this->_grid as $screen => $positions) {
if (isset($positions[$position])) {
array_push($classes, sprintf($class, $screen) . $positions[$position]);
}
}
return implode(' ', $classes);
} | php | protected function _gridClass($position, $offset = false)
{
$class = 'col-%s-';
if ($offset) {
$class .= 'offset-';
}
if (isset($this->_grid[$position])) {
return sprintf($class, 'md') . $this->_grid[$position];
}
$classes = [];
foreach ($this->_grid as $screen => $positions) {
if (isset($positions[$position])) {
array_push($classes, sprintf($class, $screen) . $positions[$position]);
}
}
return implode(' ', $classes);
} | [
"protected",
"function",
"_gridClass",
"(",
"$",
"position",
",",
"$",
"offset",
"=",
"false",
")",
"{",
"$",
"class",
"=",
"'col-%s-'",
";",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"class",
".=",
"'offset-'",
";",
"}",
"if",
"(",
"isset",
"(",
"$... | Returns a Bootstrap grid class (i.e. `col-md-2`).
@param string $position One of `left`, `middle` or `right`.
@param bool $offset If true, will append `offset-` to the class.
@return string Classes. | [
"Returns",
"a",
"Bootstrap",
"grid",
"class",
"(",
"i",
".",
"e",
".",
"col",
"-",
"md",
"-",
"2",
")",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L522-L541 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FormHelper.php | FormHelper._detectFormAlignment | protected function _detectFormAlignment($options)
{
foreach (['horizontal', 'inline'] as $align) {
if ($this->checkClasses('form-' . $align, $options)) {
return $align;
}
}
return $this->getConfig('align');
} | php | protected function _detectFormAlignment($options)
{
foreach (['horizontal', 'inline'] as $align) {
if ($this->checkClasses('form-' . $align, $options)) {
return $align;
}
}
return $this->getConfig('align');
} | [
"protected",
"function",
"_detectFormAlignment",
"(",
"$",
"options",
")",
"{",
"foreach",
"(",
"[",
"'horizontal'",
",",
"'inline'",
"]",
"as",
"$",
"align",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkClasses",
"(",
"'form-'",
".",
"$",
"align",
",",... | Detects the form alignment when possible.
@param array $options Options.
@return string Form alignment type. One of `default`, `horizontal` or `inline`. | [
"Detects",
"the",
"form",
"alignment",
"when",
"possible",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FormHelper.php#L549-L558 |
FriendsOfCake/bootstrap-ui | src/View/Widget/CheckboxWidget.php | CheckboxWidget.render | public function render(array $data, ContextInterface $context)
{
$data += [
'inline' => false,
];
if ($data['inline']) {
$this->_templates->add(['checkboxContainer' => '{{content}}']);
}
unset($data['inline']);
return parent::render($data, $context);
} | php | public function render(array $data, ContextInterface $context)
{
$data += [
'inline' => false,
];
if ($data['inline']) {
$this->_templates->add(['checkboxContainer' => '{{content}}']);
}
unset($data['inline']);
return parent::render($data, $context);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"+=",
"[",
"'inline'",
"=>",
"false",
",",
"]",
";",
"if",
"(",
"$",
"data",
"[",
"'inline'",
"]",
")",
"{",
"$",
"this",
"->... | Render a checkbox element.
Data supports the following keys:
- `name` - The name of the input.
- `inline` - The alignement to use.
- `value` - The value attribute. Defaults to '1'.
- `val` - The current value. If it matches `value` the checkbox will be checked.
You can also use the 'checked' attribute to make the checkbox checked.
- `disabled` - Whether or not the checkbox should be disabled.
Any other attributes passed in will be treated as HTML attributes.
@deprecated 0.4 This widget is no longer used.
@param array $data The data to create a checkbox with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string Generated HTML string. | [
"Render",
"a",
"checkbox",
"element",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Widget/CheckboxWidget.php#L27-L40 |
FriendsOfCake/bootstrap-ui | src/View/Helper/HtmlHelper.php | HtmlHelper.badge | public function badge($text, array $options = [])
{
$options += ['tag' => 'span'];
$tag = $options['tag'];
unset($options['tag']);
return $this->tag($tag, $text, $this->injectClasses('badge', $options));
} | php | public function badge($text, array $options = [])
{
$options += ['tag' => 'span'];
$tag = $options['tag'];
unset($options['tag']);
return $this->tag($tag, $text, $this->injectClasses('badge', $options));
} | [
"public",
"function",
"badge",
"(",
"$",
"text",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'tag'",
"=>",
"'span'",
"]",
";",
"$",
"tag",
"=",
"$",
"options",
"[",
"'tag'",
"]",
";",
"unset",
"(",
"$",
"o... | Returns Bootstrap badge markup. By default, uses `<SPAN>`.
@param string $text Text to show in badge.
@param array $options Additional HTML attributes.
@return string HTML badge markup. | [
"Returns",
"Bootstrap",
"badge",
"markup",
".",
"By",
"default",
"uses",
"<SPAN",
">",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/HtmlHelper.php#L15-L22 |
FriendsOfCake/bootstrap-ui | src/View/Helper/HtmlHelper.php | HtmlHelper.getCrumbList | public function getCrumbList(array $options = [], $startText = false)
{
$options += [
'separator' => '',
];
return parent::getCrumbList($this->injectClasses('breadcrumb', $options), $startText);
} | php | public function getCrumbList(array $options = [], $startText = false)
{
$options += [
'separator' => '',
];
return parent::getCrumbList($this->injectClasses('breadcrumb', $options), $startText);
} | [
"public",
"function",
"getCrumbList",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"startText",
"=",
"false",
")",
"{",
"$",
"options",
"+=",
"[",
"'separator'",
"=>",
"''",
",",
"]",
";",
"return",
"parent",
"::",
"getCrumbList",
"(",
"$",
... | Returns breadcrumbs as a (x)html list
This method uses HtmlHelper::tag() to generate list and its elements. Works
similar to HtmlHelper::getCrumbs(), so it uses options which every
crumb was added with.
### Options
- `separator` Separator content to insert in between breadcrumbs, defaults to ''
- `firstClass` Class for wrapper tag on the first breadcrumb, defaults to 'first'
- `lastClass` Class for wrapper tag on current active page, defaults to 'last'
@param array $options Array of HTML attributes to apply to the generated list elements.
@param string|array|bool $startText This will be the first crumb, if false it defaults to first crumb in
array. Can also be an array, see `HtmlHelper::getCrumbs` for details.
@return string|null Breadcrumbs HTML list.
@link http://book.cakephp.org/3.0/en/views/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper | [
"Returns",
"breadcrumbs",
"as",
"a",
"(",
"x",
")",
"html",
"list"
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/HtmlHelper.php#L43-L50 |
FriendsOfCake/bootstrap-ui | src/View/Helper/HtmlHelper.php | HtmlHelper.icon | public function icon($name, array $options = [])
{
$options += [
'tag' => 'i',
'iconSet' => 'glyphicon',
'class' => null,
];
$classes = [$options['iconSet'], $options['iconSet'] . '-' . $name];
$options = $this->injectClasses($classes, $options);
return $this->formatTemplate('tag', [
'tag' => $options['tag'],
'attrs' => $this->templater()->formatAttributes($options, ['tag', 'iconSet']),
]);
} | php | public function icon($name, array $options = [])
{
$options += [
'tag' => 'i',
'iconSet' => 'glyphicon',
'class' => null,
];
$classes = [$options['iconSet'], $options['iconSet'] . '-' . $name];
$options = $this->injectClasses($classes, $options);
return $this->formatTemplate('tag', [
'tag' => $options['tag'],
'attrs' => $this->templater()->formatAttributes($options, ['tag', 'iconSet']),
]);
} | [
"public",
"function",
"icon",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"+=",
"[",
"'tag'",
"=>",
"'i'",
",",
"'iconSet'",
"=>",
"'glyphicon'",
",",
"'class'",
"=>",
"null",
",",
"]",
";",
"$",
"classe... | Returns Bootstrap icon markup. By default, uses `<I>` and `glypicon`.
@param string $name Name of icon (i.e. search, leaf, etc.).
@param array $options Additional HTML attributes.
@return string HTML icon markup. | [
"Returns",
"Bootstrap",
"icon",
"markup",
".",
"By",
"default",
"uses",
"<I",
">",
"and",
"glypicon",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/HtmlHelper.php#L59-L74 |
FriendsOfCake/bootstrap-ui | src/View/Helper/HtmlHelper.php | HtmlHelper.label | public function label($text, $options = [])
{
if (is_string($options)) {
$options = ['type' => $options];
}
$options += [
'tag' => 'span',
'type' => 'default',
];
$classes = ['label', 'label-' . $options['type']];
$tag = $options['tag'];
unset($options['tag'], $options['type']);
return $this->tag($tag, $text, $this->injectClasses($classes, $options));
} | php | public function label($text, $options = [])
{
if (is_string($options)) {
$options = ['type' => $options];
}
$options += [
'tag' => 'span',
'type' => 'default',
];
$classes = ['label', 'label-' . $options['type']];
$tag = $options['tag'];
unset($options['tag'], $options['type']);
return $this->tag($tag, $text, $this->injectClasses($classes, $options));
} | [
"public",
"function",
"label",
"(",
"$",
"text",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"[",
"'type'",
"=>",
"$",
"options",
"]",
";",
"}",
"$",
"options",
... | Returns Bootstrap label markup. By default, uses `<SPAN>`.
@param string $text Text to show in label.
@param array|string $options Additional HTML attributes.
@return string HTML icon markup. | [
"Returns",
"Bootstrap",
"label",
"markup",
".",
"By",
"default",
"uses",
"<SPAN",
">",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/HtmlHelper.php#L83-L99 |
FriendsOfCake/bootstrap-ui | src/View/Widget/InputgroupTrait.php | InputgroupTrait._withInputGroup | protected function _withInputGroup(array $data, ContextInterface $context)
{
$data += [
'prepend' => null,
'append' => null,
];
if (!isset($data['type']) || $data['type'] !== 'hidden') {
$data = $this->injectClasses('form-control', $data);
}
$prepend = $data['prepend'];
$append = $data['append'];
unset($data['append'], $data['prepend']);
$input = parent::render($data, $context);
if ($prepend) {
$prepend = $this->_addon($prepend, $data);
}
if ($append) {
$append = $this->_addon($append, $data);
}
if ($prepend || $append) {
$input = $this->_templates->format('inputGroupContainer', [
'append' => $append,
'prepend' => $prepend,
'content' => $input,
'templateVars' => $data['templateVars'],
]);
}
return $input;
} | php | protected function _withInputGroup(array $data, ContextInterface $context)
{
$data += [
'prepend' => null,
'append' => null,
];
if (!isset($data['type']) || $data['type'] !== 'hidden') {
$data = $this->injectClasses('form-control', $data);
}
$prepend = $data['prepend'];
$append = $data['append'];
unset($data['append'], $data['prepend']);
$input = parent::render($data, $context);
if ($prepend) {
$prepend = $this->_addon($prepend, $data);
}
if ($append) {
$append = $this->_addon($append, $data);
}
if ($prepend || $append) {
$input = $this->_templates->format('inputGroupContainer', [
'append' => $append,
'prepend' => $prepend,
'content' => $input,
'templateVars' => $data['templateVars'],
]);
}
return $input;
} | [
"protected",
"function",
"_withInputGroup",
"(",
"array",
"$",
"data",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"+=",
"[",
"'prepend'",
"=>",
"null",
",",
"'append'",
"=>",
"null",
",",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$"... | Render a widget with input group wrapper if requried.
Apart from the standard data keys used by a widget you can use following
extra keys:
- `append` Append addon to input.
- `prepend` Prepend addon to input.
@param array $data The data to build an input with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string | [
"Render",
"a",
"widget",
"with",
"input",
"group",
"wrapper",
"if",
"requried",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Widget/InputgroupTrait.php#L24-L58 |
FriendsOfCake/bootstrap-ui | src/View/Widget/InputgroupTrait.php | InputgroupTrait._addon | protected function _addon($addon, $data)
{
if (is_string($addon)) {
$class = 'input-group-' . ($this->_isButton($addon) ? 'btn' : 'addon');
$addon = $this->_templates->format('inputGroupAddon', [
'class' => $class,
'content' => $addon,
'templateVars' => $data['templateVars'],
]);
} else {
$class = 'input-group-btn';
$addon = $this->_templates->format('inputGroupAddon', [
'class' => $class,
'content' => implode('', $addon),
'templateVars' => $data['templateVars'],
]);
}
return $addon;
} | php | protected function _addon($addon, $data)
{
if (is_string($addon)) {
$class = 'input-group-' . ($this->_isButton($addon) ? 'btn' : 'addon');
$addon = $this->_templates->format('inputGroupAddon', [
'class' => $class,
'content' => $addon,
'templateVars' => $data['templateVars'],
]);
} else {
$class = 'input-group-btn';
$addon = $this->_templates->format('inputGroupAddon', [
'class' => $class,
'content' => implode('', $addon),
'templateVars' => $data['templateVars'],
]);
}
return $addon;
} | [
"protected",
"function",
"_addon",
"(",
"$",
"addon",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"addon",
")",
")",
"{",
"$",
"class",
"=",
"'input-group-'",
".",
"(",
"$",
"this",
"->",
"_isButton",
"(",
"$",
"addon",
")",
"?",
... | Get addon HTML.
@param string|array $addon Addon content.
@param array $data Widget data.
@return string | [
"Get",
"addon",
"HTML",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Widget/InputgroupTrait.php#L67-L86 |
FriendsOfCake/bootstrap-ui | src/View/Helper/FlashHelper.php | FlashHelper.render | public function render($key = 'flash', array $options = [])
{
if (!$this->request->getSession()->check("Flash.$key")) {
return null;
}
$stack = $this->request->getSession()->read("Flash.$key");
if (!is_array($stack)) {
throw new \UnexpectedValueException(sprintf(
'Value for flash setting key "%s" must be an array.',
$key
));
}
if (isset($stack['element'])) {
$stack = [$stack];
}
$out = '';
foreach ($stack as $message) {
$message = $options + $message;
$message['params'] += $this->_config;
$this->request->getSession()->delete("Flash.$key");
$element = $message['element'];
if (strpos($element, '.') === false &&
preg_match('#Flash/(default|success|error|info|warning)$#', $element, $matches)
) {
$class = $matches[1];
$class = str_replace(['default', 'error'], ['info', 'danger'], $class);
if (is_array($message['params']['class'])) {
$message['params']['class'][] = 'alert-' . $class;
}
$element = $this->_config['element'];
}
$out .= $this->_View->element($element, $message);
}
return $out;
} | php | public function render($key = 'flash', array $options = [])
{
if (!$this->request->getSession()->check("Flash.$key")) {
return null;
}
$stack = $this->request->getSession()->read("Flash.$key");
if (!is_array($stack)) {
throw new \UnexpectedValueException(sprintf(
'Value for flash setting key "%s" must be an array.',
$key
));
}
if (isset($stack['element'])) {
$stack = [$stack];
}
$out = '';
foreach ($stack as $message) {
$message = $options + $message;
$message['params'] += $this->_config;
$this->request->getSession()->delete("Flash.$key");
$element = $message['element'];
if (strpos($element, '.') === false &&
preg_match('#Flash/(default|success|error|info|warning)$#', $element, $matches)
) {
$class = $matches[1];
$class = str_replace(['default', 'error'], ['info', 'danger'], $class);
if (is_array($message['params']['class'])) {
$message['params']['class'][] = 'alert-' . $class;
}
$element = $this->_config['element'];
}
$out .= $this->_View->element($element, $message);
}
return $out;
} | [
"public",
"function",
"render",
"(",
"$",
"key",
"=",
"'flash'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"check",
"(",
"\"Flash.$key\"",
")",
")",
"{",... | Similar to the core's FlashHelper used to render the message set in FlashComponent::set().
If the flash element configured is one of "default", "error", "info", "success" or "warning"
"BootstrapUI." is prepended to the name so that the element is used from this plugin.
@param string $key The [Flash.]key you are rendering in the view.
@param array $options Additional options to use for the creation of this flash message.
Supports the 'params', and 'element' keys that are used in the helper.
@return string|null Rendered flash message or null if flash key does not exist
in session.
@throws \UnexpectedValueException If value for flash settings key is not an array. | [
"Similar",
"to",
"the",
"core",
"s",
"FlashHelper",
"used",
"to",
"render",
"the",
"message",
"set",
"in",
"FlashComponent",
"::",
"set",
"()",
"."
] | train | https://github.com/FriendsOfCake/bootstrap-ui/blob/6a01b0c3ebe0ac7f19af35b4b6dc8e4b4834f3f9/src/View/Helper/FlashHelper.php#L66-L107 |
pear/Mail | Mail.php | Mail.factory | public static function factory($driver, $params = array())
{
$driver = strtolower($driver);
@include_once 'Mail/' . $driver . '.php';
$class = 'Mail_' . $driver;
if (class_exists($class)) {
$mailer = new $class($params);
return $mailer;
} else {
return PEAR::raiseError('Unable to find class for driver ' . $driver);
}
} | php | public static function factory($driver, $params = array())
{
$driver = strtolower($driver);
@include_once 'Mail/' . $driver . '.php';
$class = 'Mail_' . $driver;
if (class_exists($class)) {
$mailer = new $class($params);
return $mailer;
} else {
return PEAR::raiseError('Unable to find class for driver ' . $driver);
}
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"driver",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"driver",
"=",
"strtolower",
"(",
"$",
"driver",
")",
";",
"@",
"include_once",
"'Mail/'",
".",
"$",
"driver",
".",
"'.php'",
";... | Provides an interface for generating Mail:: objects of various
types
@param string $driver The kind of Mail:: object to instantiate.
@param array $params The parameters to pass to the Mail:: object.
@return object Mail a instance of the driver class or if fails a PEAR Error | [
"Provides",
"an",
"interface",
"for",
"generating",
"Mail",
"::",
"objects",
"of",
"various",
"types"
] | train | https://github.com/pear/Mail/blob/c79a855bf8720d4643ef61500b766381c27cc741/Mail.php#L75-L86 |
pear/Mail | Mail.php | Mail.send | public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
}
$result = $this->_sanitizeHeaders($headers);
if (is_a($result, 'PEAR_Error')) {
return $result;
}
// if we're passed an array of recipients, implode it.
if (is_array($recipients)) {
$recipients = implode(', ', $recipients);
}
// get the Subject out of the headers array so that we can
// pass it as a seperate argument to mail().
$subject = '';
if (isset($headers['Subject'])) {
$subject = $headers['Subject'];
unset($headers['Subject']);
}
// flatten the headers out.
list(, $text_headers) = Mail::prepareHeaders($headers);
return mail($recipients, $subject, $body, $text_headers);
} | php | public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
}
$result = $this->_sanitizeHeaders($headers);
if (is_a($result, 'PEAR_Error')) {
return $result;
}
// if we're passed an array of recipients, implode it.
if (is_array($recipients)) {
$recipients = implode(', ', $recipients);
}
// get the Subject out of the headers array so that we can
// pass it as a seperate argument to mail().
$subject = '';
if (isset($headers['Subject'])) {
$subject = $headers['Subject'];
unset($headers['Subject']);
}
// flatten the headers out.
list(, $text_headers) = Mail::prepareHeaders($headers);
return mail($recipients, $subject, $body, $text_headers);
} | [
"public",
"function",
"send",
"(",
"$",
"recipients",
",",
"$",
"headers",
",",
"$",
"body",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"headers",
")",
")",
"{",
"return",
"PEAR",
"::",
"raiseError",
"(",
"'$headers must be an array'",
")",
";",
"... | Implements Mail::send() function using php's built-in mail()
command.
@param mixed $recipients Either a comma-seperated list of recipients
(RFC822 compliant), or an array of recipients,
each RFC822 valid. This may contain recipients not
specified in the headers, for Bcc:, resending
messages, etc.
@param array $headers The array of headers to send with the mail, in an
associative array, where the array key is the
header name (ie, 'Subject'), and the array value
is the header value (ie, 'test'). The header
produced from those values would be 'Subject:
test'.
@param string $body The full text of the message body, including any
Mime parts, etc.
@return mixed Returns true on success, or a PEAR_Error
containing a descriptive error message on
failure.
@deprecated use Mail_mail::send instead | [
"Implements",
"Mail",
"::",
"send",
"()",
"function",
"using",
"php",
"s",
"built",
"-",
"in",
"mail",
"()",
"command",
"."
] | train | https://github.com/pear/Mail/blob/c79a855bf8720d4643ef61500b766381c27cc741/Mail.php#L114-L142 |
pear/Mail | Mail.php | Mail._sanitizeHeaders | protected function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] =
preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
null, $value);
}
} | php | protected function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] =
preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
null, $value);
}
} | [
"protected",
"function",
"_sanitizeHeaders",
"(",
"&",
"$",
"headers",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"headers",
"[",
"$",
"key",
"]",
"=",
"preg_replace",
"(",
"'=((<CR>|<LF>|0x0A/%0A|0x0D/%0... | Sanitize an array of mail headers by removing any additional header
strings present in a legitimate header's value. The goal of this
filter is to prevent mail injection attacks.
@param array $headers The associative array of headers to sanitize. | [
"Sanitize",
"an",
"array",
"of",
"mail",
"headers",
"by",
"removing",
"any",
"additional",
"header",
"strings",
"present",
"in",
"a",
"legitimate",
"header",
"s",
"value",
".",
"The",
"goal",
"of",
"this",
"filter",
"is",
"to",
"prevent",
"mail",
"injection"... | train | https://github.com/pear/Mail/blob/c79a855bf8720d4643ef61500b766381c27cc741/Mail.php#L151-L158 |
pear/Mail | Mail.php | Mail.prepareHeaders | protected function prepareHeaders($headers)
{
$lines = array();
$from = null;
foreach ($headers as $key => $value) {
if (strcasecmp($key, 'From') === 0) {
include_once 'Mail/RFC822.php';
$parser = new Mail_RFC822();
$addresses = $parser->parseAddressList($value, 'localhost', false);
if (is_a($addresses, 'PEAR_Error')) {
return $addresses;
}
$from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
// Reject envelope From: addresses with spaces.
if (strstr($from, ' ')) {
return false;
}
$lines[] = $key . ': ' . $value;
} elseif (strcasecmp($key, 'Received') === 0) {
$received = array();
if (is_array($value)) {
foreach ($value as $line) {
$received[] = $key . ': ' . $line;
}
}
else {
$received[] = $key . ': ' . $value;
}
// Put Received: headers at the top. Spam detectors often
// flag messages with Received: headers after the Subject:
// as spam.
$lines = array_merge($received, $lines);
} else {
// If $value is an array (i.e., a list of addresses), convert
// it to a comma-delimited string of its elements (addresses).
if (is_array($value)) {
$value = implode(', ', $value);
}
$lines[] = $key . ': ' . $value;
}
}
return array($from, join($this->sep, $lines));
} | php | protected function prepareHeaders($headers)
{
$lines = array();
$from = null;
foreach ($headers as $key => $value) {
if (strcasecmp($key, 'From') === 0) {
include_once 'Mail/RFC822.php';
$parser = new Mail_RFC822();
$addresses = $parser->parseAddressList($value, 'localhost', false);
if (is_a($addresses, 'PEAR_Error')) {
return $addresses;
}
$from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
// Reject envelope From: addresses with spaces.
if (strstr($from, ' ')) {
return false;
}
$lines[] = $key . ': ' . $value;
} elseif (strcasecmp($key, 'Received') === 0) {
$received = array();
if (is_array($value)) {
foreach ($value as $line) {
$received[] = $key . ': ' . $line;
}
}
else {
$received[] = $key . ': ' . $value;
}
// Put Received: headers at the top. Spam detectors often
// flag messages with Received: headers after the Subject:
// as spam.
$lines = array_merge($received, $lines);
} else {
// If $value is an array (i.e., a list of addresses), convert
// it to a comma-delimited string of its elements (addresses).
if (is_array($value)) {
$value = implode(', ', $value);
}
$lines[] = $key . ': ' . $value;
}
}
return array($from, join($this->sep, $lines));
} | [
"protected",
"function",
"prepareHeaders",
"(",
"$",
"headers",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"$",
"from",
"=",
"null",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strcasec... | Take an array of mail headers and return a string containing
text usable in sending a message.
@param array $headers The array of headers to prepare, in an associative
array, where the array key is the header name (ie,
'Subject'), and the array value is the header
value (ie, 'test'). The header produced from those
values would be 'Subject: test'.
@return mixed Returns false if it encounters a bad address,
otherwise returns an array containing two
elements: Any From: address found in the headers,
and the plain text version of the headers. | [
"Take",
"an",
"array",
"of",
"mail",
"headers",
"and",
"return",
"a",
"string",
"containing",
"text",
"usable",
"in",
"sending",
"a",
"message",
"."
] | train | https://github.com/pear/Mail/blob/c79a855bf8720d4643ef61500b766381c27cc741/Mail.php#L175-L222 |
pear/Mail | Mail.php | Mail.parseRecipients | protected function parseRecipients($recipients)
{
include_once 'Mail/RFC822.php';
// if we're passed an array, assume addresses are valid and
// implode them before parsing.
if (is_array($recipients)) {
$recipients = implode(', ', $recipients);
}
// Parse recipients, leaving out all personal info. This is
// for smtp recipients, etc. All relevant personal information
// should already be in the headers.
$Mail_RFC822 = new Mail_RFC822();
$addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);
// If parseAddressList() returned a PEAR_Error object, just return it.
if (is_a($addresses, 'PEAR_Error')) {
return $addresses;
}
$recipients = array();
if (is_array($addresses)) {
foreach ($addresses as $ob) {
$recipients[] = $ob->mailbox . '@' . $ob->host;
}
}
return $recipients;
} | php | protected function parseRecipients($recipients)
{
include_once 'Mail/RFC822.php';
// if we're passed an array, assume addresses are valid and
// implode them before parsing.
if (is_array($recipients)) {
$recipients = implode(', ', $recipients);
}
// Parse recipients, leaving out all personal info. This is
// for smtp recipients, etc. All relevant personal information
// should already be in the headers.
$Mail_RFC822 = new Mail_RFC822();
$addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);
// If parseAddressList() returned a PEAR_Error object, just return it.
if (is_a($addresses, 'PEAR_Error')) {
return $addresses;
}
$recipients = array();
if (is_array($addresses)) {
foreach ($addresses as $ob) {
$recipients[] = $ob->mailbox . '@' . $ob->host;
}
}
return $recipients;
} | [
"protected",
"function",
"parseRecipients",
"(",
"$",
"recipients",
")",
"{",
"include_once",
"'Mail/RFC822.php'",
";",
"// if we're passed an array, assume addresses are valid and",
"// implode them before parsing.",
"if",
"(",
"is_array",
"(",
"$",
"recipients",
")",
")",
... | Take a set of recipients and parse them, returning an array of
bare addresses (forward paths) that can be passed to sendmail
or an smtp server with the rcpt to: command.
@param mixed Either a comma-seperated list of recipients
(RFC822 compliant), or an array of recipients,
each RFC822 valid.
@return mixed An array of forward paths (bare addresses) or a PEAR_Error
object if the address list could not be parsed. | [
"Take",
"a",
"set",
"of",
"recipients",
"and",
"parse",
"them",
"returning",
"an",
"array",
"of",
"bare",
"addresses",
"(",
"forward",
"paths",
")",
"that",
"can",
"be",
"passed",
"to",
"sendmail",
"or",
"an",
"smtp",
"server",
"with",
"the",
"rcpt",
"to... | train | https://github.com/pear/Mail/blob/c79a855bf8720d4643ef61500b766381c27cc741/Mail.php#L236-L265 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.