repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.o_procset
function o_procset( $id, $action, $options = '' ) { if ( $action != 'new' ) { $o =& $this->objects[$id]; } switch ( $action ) { case 'new': $this->objects[$id] = array( 't' => 'procset', 'info' => array( 'PDF' => 1, 'Text' => 1 ) ); $this->o_pages( $this->currentNode, 'procset', $id ); $this->procsetObjectId = $id; break; case 'add': // this is to add new items to the procset list, despite the fact that this is considered // obselete, the items are required for printing to some postscript printers switch ( $options ) { case 'ImageB': case 'ImageC': case 'ImageI': $o['info'][$options] = 1; break; } break; case 'out': $res = "\n" . $id . " 0 obj\n["; foreach ( $o['info'] as $label => $val ) { $res .= '/'.$label.' '; } $res .= "]\nendobj"; return $res; break; } }
php
function o_procset( $id, $action, $options = '' ) { if ( $action != 'new' ) { $o =& $this->objects[$id]; } switch ( $action ) { case 'new': $this->objects[$id] = array( 't' => 'procset', 'info' => array( 'PDF' => 1, 'Text' => 1 ) ); $this->o_pages( $this->currentNode, 'procset', $id ); $this->procsetObjectId = $id; break; case 'add': // this is to add new items to the procset list, despite the fact that this is considered // obselete, the items are required for printing to some postscript printers switch ( $options ) { case 'ImageB': case 'ImageC': case 'ImageI': $o['info'][$options] = 1; break; } break; case 'out': $res = "\n" . $id . " 0 obj\n["; foreach ( $o['info'] as $label => $val ) { $res .= '/'.$label.' '; } $res .= "]\nendobj"; return $res; break; } }
[ "function", "o_procset", "(", "$", "id", ",", "$", "action", ",", "$", "options", "=", "''", ")", "{", "if", "(", "$", "action", "!=", "'new'", ")", "{", "$", "o", "=", "&", "$", "this", "->", "objects", "[", "$", "id", "]", ";", "}", "switch...
the document procset, solves some problems with printing to old PS printers
[ "the", "document", "procset", "solves", "some", "problems", "with", "printing", "to", "old", "PS", "printers" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L1056-L1092
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.o_info
function o_info( $id, $action, $options = '' ) { if ( $action != 'new' ) { $o =& $this->objects[$id]; } switch ($action) { case 'new': $this->infoObject = $id; $date = 'D:' . date( 'Ymd' ); $this->objects[$id] = array( 't' => 'info', 'info' => array( 'Creator' => 'eZ Publish CMS, http://ez.no', 'CreationDate' => $date ) ); break; case 'Title': case 'Author': case 'Subject': case 'Keywords': case 'Creator': case 'Producer': case 'CreationDate': case 'ModDate': case 'Trapped': $o['info'][$action]=$options; break; case 'out': if ( $this->encrypted ) { $this->encryptInit( $id ); } $res = "\n" . $id . " 0 obj\n<<\n"; foreach ( $o['info'] as $k => $v ) { $res .= '/' . $k . ' ('; if ( $this->encrypted ) { $res .= $this->filterText( $this->ARC4( $v ) ); } else { $res .= $this->filterText( $v ); } $res .= ")\n"; } $res .= ">>\nendobj"; return $res; break; } }
php
function o_info( $id, $action, $options = '' ) { if ( $action != 'new' ) { $o =& $this->objects[$id]; } switch ($action) { case 'new': $this->infoObject = $id; $date = 'D:' . date( 'Ymd' ); $this->objects[$id] = array( 't' => 'info', 'info' => array( 'Creator' => 'eZ Publish CMS, http://ez.no', 'CreationDate' => $date ) ); break; case 'Title': case 'Author': case 'Subject': case 'Keywords': case 'Creator': case 'Producer': case 'CreationDate': case 'ModDate': case 'Trapped': $o['info'][$action]=$options; break; case 'out': if ( $this->encrypted ) { $this->encryptInit( $id ); } $res = "\n" . $id . " 0 obj\n<<\n"; foreach ( $o['info'] as $k => $v ) { $res .= '/' . $k . ' ('; if ( $this->encrypted ) { $res .= $this->filterText( $this->ARC4( $v ) ); } else { $res .= $this->filterText( $v ); } $res .= ")\n"; } $res .= ">>\nendobj"; return $res; break; } }
[ "function", "o_info", "(", "$", "id", ",", "$", "action", ",", "$", "options", "=", "''", ")", "{", "if", "(", "$", "action", "!=", "'new'", ")", "{", "$", "o", "=", "&", "$", "this", "->", "objects", "[", "$", "id", "]", ";", "}", "switch", ...
define the document information
[ "define", "the", "document", "information" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L1097-L1146
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.o_contents
function o_contents($id,$action,$options=''){ if ($action!='new'){ $o =& $this->objects[$id]; } switch ($action){ case 'new': $this->objects[$id]=array('t'=>'contents','c'=>'','info'=>array()); if (strlen($options) && intval($options)){ // then this contents is the primary for a page $this->objects[$id]['onPage']=$options; } else if ($options=='raw'){ // then this page contains some other type of system object $this->objects[$id]['raw']=1; } break; case 'add': // add more options to the decleration foreach ($options as $k=>$v){ $o['info'][$k]=$v; } case 'out': $tmp=$o['c']; $res= "\n".$id." 0 obj\n"; if (isset($this->objects[$id]['raw'])){ $res.=$tmp; } else { $res.= "<<"; if (function_exists('gzcompress') && $this->options['compression']){ // then implement ZLIB based compression on this content stream $res.=" /Filter /FlateDecode"; $tmp = gzcompress($tmp); } if ($this->encrypted){ $this->encryptInit($id); $tmp = $this->ARC4($tmp); } foreach($o['info'] as $k=>$v){ $res .= "\n/".$k.' '.$v; } $res.="\n/Length ".strlen($tmp)." >>\nstream\n".$tmp."\nendstream"; } $res.="\nendobj\n"; return $res; break; } }
php
function o_contents($id,$action,$options=''){ if ($action!='new'){ $o =& $this->objects[$id]; } switch ($action){ case 'new': $this->objects[$id]=array('t'=>'contents','c'=>'','info'=>array()); if (strlen($options) && intval($options)){ // then this contents is the primary for a page $this->objects[$id]['onPage']=$options; } else if ($options=='raw'){ // then this page contains some other type of system object $this->objects[$id]['raw']=1; } break; case 'add': // add more options to the decleration foreach ($options as $k=>$v){ $o['info'][$k]=$v; } case 'out': $tmp=$o['c']; $res= "\n".$id." 0 obj\n"; if (isset($this->objects[$id]['raw'])){ $res.=$tmp; } else { $res.= "<<"; if (function_exists('gzcompress') && $this->options['compression']){ // then implement ZLIB based compression on this content stream $res.=" /Filter /FlateDecode"; $tmp = gzcompress($tmp); } if ($this->encrypted){ $this->encryptInit($id); $tmp = $this->ARC4($tmp); } foreach($o['info'] as $k=>$v){ $res .= "\n/".$k.' '.$v; } $res.="\n/Length ".strlen($tmp)." >>\nstream\n".$tmp."\nendstream"; } $res.="\nendobj\n"; return $res; break; } }
[ "function", "o_contents", "(", "$", "id", ",", "$", "action", ",", "$", "options", "=", "''", ")", "{", "if", "(", "$", "action", "!=", "'new'", ")", "{", "$", "o", "=", "&", "$", "this", "->", "objects", "[", "$", "id", "]", ";", "}", "switc...
the contents objects hold all of the content which appears on pages
[ "the", "contents", "objects", "hold", "all", "of", "the", "content", "which", "appears", "on", "pages" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L1339-L1384
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.newDocument
function newDocument($pageSize=array(0,0,612,792)){ $this->numObj=0; $this->objects = array(); $this->numObj++; $this->o_catalog($this->numObj,'new'); $this->numObj++; $this->o_outlines($this->numObj,'new'); $this->numObj++; $this->o_pages($this->numObj,'new'); $this->o_pages($this->numObj,'mediaBox',$pageSize); $this->currentNode = 3; $this->numObj++; $this->o_procset($this->numObj,'new'); $this->numObj++; $this->o_info($this->numObj,'new'); $this->numObj++; $this->o_page($this->numObj,'new'); // need to store the first page id as there is no way to get it to the user during // startup $this->firstPageId = $this->currentContents; }
php
function newDocument($pageSize=array(0,0,612,792)){ $this->numObj=0; $this->objects = array(); $this->numObj++; $this->o_catalog($this->numObj,'new'); $this->numObj++; $this->o_outlines($this->numObj,'new'); $this->numObj++; $this->o_pages($this->numObj,'new'); $this->o_pages($this->numObj,'mediaBox',$pageSize); $this->currentNode = 3; $this->numObj++; $this->o_procset($this->numObj,'new'); $this->numObj++; $this->o_info($this->numObj,'new'); $this->numObj++; $this->o_page($this->numObj,'new'); // need to store the first page id as there is no way to get it to the user during // startup $this->firstPageId = $this->currentContents; }
[ "function", "newDocument", "(", "$", "pageSize", "=", "array", "(", "0", ",", "0", ",", "612", ",", "792", ")", ")", "{", "$", "this", "->", "numObj", "=", "0", ";", "$", "this", "->", "objects", "=", "array", "(", ")", ";", "$", "this", "->", ...
intialize a new document if this is called on an existing document results may be unpredictable, but the existing document would be lost at minimum this function is called automatically by the constructor function @access private
[ "intialize", "a", "new", "document", "if", "this", "is", "called", "on", "an", "existing", "document", "results", "may", "be", "unpredictable", "but", "the", "existing", "document", "would", "be", "lost", "at", "minimum", "this", "function", "is", "called", ...
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L1718-L1746
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.shadedRectangle
function shadedRectangle( $x1, $y1, $width, $height, $options ) { $this->numObj++; $shadingLabel = $this->o_shading( $this->numObj, 'new', $options ); $this->saveState(); $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F',$x1).' '.sprintf('%.3F',$y1).' '.sprintf('%.3F',$width).' '.sprintf('%.3F',$height).' re'; $this->objects[$this->currentContents]['c'].="\nW n"; $this->objects[$this->currentContents]['c'].="\n/".$shadingLabel.' sh'; $this->restoreState(); }
php
function shadedRectangle( $x1, $y1, $width, $height, $options ) { $this->numObj++; $shadingLabel = $this->o_shading( $this->numObj, 'new', $options ); $this->saveState(); $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F',$x1).' '.sprintf('%.3F',$y1).' '.sprintf('%.3F',$width).' '.sprintf('%.3F',$height).' re'; $this->objects[$this->currentContents]['c'].="\nW n"; $this->objects[$this->currentContents]['c'].="\n/".$shadingLabel.' sh'; $this->restoreState(); }
[ "function", "shadedRectangle", "(", "$", "x1", ",", "$", "y1", ",", "$", "width", ",", "$", "height", ",", "$", "options", ")", "{", "$", "this", "->", "numObj", "++", ";", "$", "shadingLabel", "=", "$", "this", "->", "o_shading", "(", "$", "this",...
Create shaded rectangle area \param x1 \param x2 \param width \param height \param options array ( 'orientation' => <vertical|horizontal ( optianal )>, 'color0' => <CMYK color array>, 'color1' => <CMYK color array> )
[ "Create", "shaded", "rectangle", "area" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L2445-L2459
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.getFontDecender
function getFontDecender( $size = false ) { // note that this will most likely return a negative value if ( !$this->numFonts ) { $this->selectFont( './fonts/Helvetica' ); } $h = $this->fonts[$this->currentFont]['FontBBox'][1]; if ( $size === false ) { $size = $this->fontSize(); } return $size*$h/1000; }
php
function getFontDecender( $size = false ) { // note that this will most likely return a negative value if ( !$this->numFonts ) { $this->selectFont( './fonts/Helvetica' ); } $h = $this->fonts[$this->currentFont]['FontBBox'][1]; if ( $size === false ) { $size = $this->fontSize(); } return $size*$h/1000; }
[ "function", "getFontDecender", "(", "$", "size", "=", "false", ")", "{", "// note that this will most likely return a negative value", "if", "(", "!", "$", "this", "->", "numFonts", ")", "{", "$", "this", "->", "selectFont", "(", "'./fonts/Helvetica'", ")", ";", ...
return the font decender, this will normally return a negative number if you add this number to the baseline, you get the level of the bottom of the font it is in the pdf user units
[ "return", "the", "font", "decender", "this", "will", "normally", "return", "a", "negative", "number", "if", "you", "add", "this", "number", "to", "the", "baseline", "you", "get", "the", "level", "of", "the", "bottom", "of", "the", "font", "it", "is", "in...
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L2608-L2621
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.PRVTgetTextPosition
function PRVTgetTextPosition( $x, $y, $angle, $size, $wa, $text ) { $tmp = false; // given this information return an array containing x and y for the end position as elements 0 and 1 $w = $this->getTextWidth($size,$text); // need to adjust for the number of spaces in this text $words = explode(' ',$text); $nspaces=count($words)-1; $w += $wa*$nspaces; $a = deg2rad((float)$angle); if ( $tmp ) { return array($this->xOffset(),-sin($a)*$w+$y); } return array(cos($a)*$w+$x,-sin($a)*$w+$y); }
php
function PRVTgetTextPosition( $x, $y, $angle, $size, $wa, $text ) { $tmp = false; // given this information return an array containing x and y for the end position as elements 0 and 1 $w = $this->getTextWidth($size,$text); // need to adjust for the number of spaces in this text $words = explode(' ',$text); $nspaces=count($words)-1; $w += $wa*$nspaces; $a = deg2rad((float)$angle); if ( $tmp ) { return array($this->xOffset(),-sin($a)*$w+$y); } return array(cos($a)*$w+$x,-sin($a)*$w+$y); }
[ "function", "PRVTgetTextPosition", "(", "$", "x", ",", "$", "y", ",", "$", "angle", ",", "$", "size", ",", "$", "wa", ",", "$", "text", ")", "{", "$", "tmp", "=", "false", ";", "// given this information return an array containing x and y for the end position as...
given a start position and information about how text is to be laid out, calculate where on the page the text will end @access private
[ "given", "a", "start", "position", "and", "information", "about", "how", "text", "is", "to", "be", "laid", "out", "calculate", "where", "on", "the", "page", "the", "text", "will", "end" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L2649-L2665
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.PRVTcheckTextDirective
function PRVTcheckTextDirective( &$text, $i, &$f, $final = 0 ) { $x = 0; $y = 0; return $this->PRVTcheckTextDirective1( $text, $i, $f, $final, $x, $y ); }
php
function PRVTcheckTextDirective( &$text, $i, &$f, $final = 0 ) { $x = 0; $y = 0; return $this->PRVTcheckTextDirective1( $text, $i, $f, $final, $x, $y ); }
[ "function", "PRVTcheckTextDirective", "(", "&", "$", "text", ",", "$", "i", ",", "&", "$", "f", ",", "$", "final", "=", "0", ")", "{", "$", "x", "=", "0", ";", "$", "y", "=", "0", ";", "return", "$", "this", "->", "PRVTcheckTextDirective1", "(", ...
wrapper function for PRVTcheckTextDirective1 @access private
[ "wrapper", "function", "for", "PRVTcheckTextDirective1" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L2672-L2677
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.getTextWidth
function getTextWidth( $size, $text ) { // this function should not change any of the settings, though it will need to // track any directives which change during calculation, so copy them at the start // and put them back at the end. $this->pushTextState( $this->currentTextState ); if (!$this->numFonts) { $this->selectFont('./fonts/Helvetica'); } // converts a number or a float to a string so it can get the width $text = "$text"; // hmm, this is where it all starts to get tricky - use the font information to // calculate the width of each character, add them up and convert to user units $w = 0; $len = strlen( $text ); $cf = $this->currentFont; for ( $i = 0; $i < $len; $i++ ) { $f = 1; $directiveArray = $this->PRVTcheckTextDirective( $text, $i, $f ); $directive = $directiveArray['directive']; if ( $directive ) { if ($f) { $this->setCurrentFont(); $cf = $this->currentFont; } $i = $i + $directive-1; } else { $char = ord( $text[$i] ); if ( isset($this->fonts[$cf]['differences'][$char] ) ) { // then this character is being replaced by another $name = $this->fonts[$cf]['differences'][$char]; if ( isset($this->fonts[$cf]['C'][$name]['WX'] ) ) { $w += $this->fonts[$cf]['C'][$name]['WX']; } } else if ( isset($this->fonts[$cf]['C'][$char]['WX'] ) ) { $w += $this->fonts[$cf]['C'][$char]['WX']; } else { $w += 700; } } } $this->popTextState(); $this->setCurrentFont(); return $w*$size/1000; }
php
function getTextWidth( $size, $text ) { // this function should not change any of the settings, though it will need to // track any directives which change during calculation, so copy them at the start // and put them back at the end. $this->pushTextState( $this->currentTextState ); if (!$this->numFonts) { $this->selectFont('./fonts/Helvetica'); } // converts a number or a float to a string so it can get the width $text = "$text"; // hmm, this is where it all starts to get tricky - use the font information to // calculate the width of each character, add them up and convert to user units $w = 0; $len = strlen( $text ); $cf = $this->currentFont; for ( $i = 0; $i < $len; $i++ ) { $f = 1; $directiveArray = $this->PRVTcheckTextDirective( $text, $i, $f ); $directive = $directiveArray['directive']; if ( $directive ) { if ($f) { $this->setCurrentFont(); $cf = $this->currentFont; } $i = $i + $directive-1; } else { $char = ord( $text[$i] ); if ( isset($this->fonts[$cf]['differences'][$char] ) ) { // then this character is being replaced by another $name = $this->fonts[$cf]['differences'][$char]; if ( isset($this->fonts[$cf]['C'][$name]['WX'] ) ) { $w += $this->fonts[$cf]['C'][$name]['WX']; } } else if ( isset($this->fonts[$cf]['C'][$char]['WX'] ) ) { $w += $this->fonts[$cf]['C'][$char]['WX']; } else { $w += 700; } } } $this->popTextState(); $this->setCurrentFont(); return $w*$size/1000; }
[ "function", "getTextWidth", "(", "$", "size", ",", "$", "text", ")", "{", "// this function should not change any of the settings, though it will need to", "// track any directives which change during calculation, so copy them at the start", "// and put them back at the end.", "$", "this...
calculate how wide a given text string will be on a page, at a given size. this can be called externally, but is alse used by the other class functions
[ "calculate", "how", "wide", "a", "given", "text", "string", "will", "be", "on", "a", "page", "at", "a", "given", "size", ".", "this", "can", "be", "called", "externally", "but", "is", "alse", "used", "by", "the", "other", "class", "functions" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3041-L3101
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.PRVTadjustWrapText
function PRVTadjustWrapText( $text, $actual, $width, &$x, &$adjust, $justification ) { switch ( $justification ) { case 'left': return; break; case 'right': $x += $width - $actual; break; case 'center': case 'centre': $x += ($width - $actual) / 2; break; case 'full': // count the number of words $words = explode( ' ', $text ); $nspaces = count($words) - 1; if ( $nspaces > 0 ) { $adjust = ($width-$actual) / $nspaces; } else { $adjust = 0; } break; } }
php
function PRVTadjustWrapText( $text, $actual, $width, &$x, &$adjust, $justification ) { switch ( $justification ) { case 'left': return; break; case 'right': $x += $width - $actual; break; case 'center': case 'centre': $x += ($width - $actual) / 2; break; case 'full': // count the number of words $words = explode( ' ', $text ); $nspaces = count($words) - 1; if ( $nspaces > 0 ) { $adjust = ($width-$actual) / $nspaces; } else { $adjust = 0; } break; } }
[ "function", "PRVTadjustWrapText", "(", "$", "text", ",", "$", "actual", ",", "$", "width", ",", "&", "$", "x", ",", "&", "$", "adjust", ",", "$", "justification", ")", "{", "switch", "(", "$", "justification", ")", "{", "case", "'left'", ":", "return...
do a part of the calculation for sorting out the justification of the text @access private
[ "do", "a", "part", "of", "the", "calculation", "for", "sorting", "out", "the", "justification", "of", "the", "text" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3108-L3136
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.saveState
function saveState( $pageEnd = 0 ) { if ( $pageEnd ) { // this will be called at a new page to return the state to what it was on the // end of the previous page, before the stack was closed down // This is to get around not being able to have open 'q' across pages $opt = $this->stateStack[$pageEnd]; // ok to use this as stack starts numbering at 1 $this->setColor($opt['col'],1); $this->setStrokeColor($opt['str'],1); $this->objects[$this->currentContents]['c'].="\n".$opt['lin']; //$this->currentLineStyle = $opt['lin']; } else { $this->nStateStack++; $this->stateStack[$this->nStateStack]=array( 'col' => $this->currentColour, 'str' => $this->currentStrokeColour, 'lin' => $this->currentLineStyle ); } $this->objects[$this->currentContents]['c'] .= "\nq"; }
php
function saveState( $pageEnd = 0 ) { if ( $pageEnd ) { // this will be called at a new page to return the state to what it was on the // end of the previous page, before the stack was closed down // This is to get around not being able to have open 'q' across pages $opt = $this->stateStack[$pageEnd]; // ok to use this as stack starts numbering at 1 $this->setColor($opt['col'],1); $this->setStrokeColor($opt['str'],1); $this->objects[$this->currentContents]['c'].="\n".$opt['lin']; //$this->currentLineStyle = $opt['lin']; } else { $this->nStateStack++; $this->stateStack[$this->nStateStack]=array( 'col' => $this->currentColour, 'str' => $this->currentStrokeColour, 'lin' => $this->currentLineStyle ); } $this->objects[$this->currentContents]['c'] .= "\nq"; }
[ "function", "saveState", "(", "$", "pageEnd", "=", "0", ")", "{", "if", "(", "$", "pageEnd", ")", "{", "// this will be called at a new page to return the state to what it was on the", "// end of the previous page, before the stack was closed down", "// This is to get around not be...
this will be called at a new page to return the state to what it was on the end of the previous page, before the stack was closed down This is to get around not being able to have open 'q' across pages
[ "this", "will", "be", "called", "at", "a", "new", "page", "to", "return", "the", "state", "to", "what", "it", "was", "on", "the", "end", "of", "the", "previous", "page", "before", "the", "stack", "was", "closed", "down", "This", "is", "to", "get", "a...
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3337-L3358
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.restoreState
function restoreState( $pageEnd = 0 ) { if ( !$pageEnd ) { $n = $this->nStateStack; $this->currentColour = $this->stateStack[$n]['col']; $this->currentStrokeColour = $this->stateStack[$n]['str']; $this->objects[$this->currentContents]['c'] .= "\n".$this->stateStack[$n]['lin']; $this->currentLineStyle = $this->stateStack[$n]['lin']; unset( $this->stateStack[$n] ); $this->nStateStack--; } $this->objects[$this->currentContents]['c'] .= "\nQ"; }
php
function restoreState( $pageEnd = 0 ) { if ( !$pageEnd ) { $n = $this->nStateStack; $this->currentColour = $this->stateStack[$n]['col']; $this->currentStrokeColour = $this->stateStack[$n]['str']; $this->objects[$this->currentContents]['c'] .= "\n".$this->stateStack[$n]['lin']; $this->currentLineStyle = $this->stateStack[$n]['lin']; unset( $this->stateStack[$n] ); $this->nStateStack--; } $this->objects[$this->currentContents]['c'] .= "\nQ"; }
[ "function", "restoreState", "(", "$", "pageEnd", "=", "0", ")", "{", "if", "(", "!", "$", "pageEnd", ")", "{", "$", "n", "=", "$", "this", "->", "nStateStack", ";", "$", "this", "->", "currentColour", "=", "$", "this", "->", "stateStack", "[", "$",...
restore a previously saved state
[ "restore", "a", "previously", "saved", "state" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3363-L3376
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.openObject
function openObject() { $this->nStack++; $this->stack[$this->nStack] = array( 'c' => $this->currentContents, 'p' => $this->currentPage ); // add a new object of the content type, to hold the data flow $this->numObj++; $this->o_contents( $this->numObj, 'new' ); $this->currentContents = $this->numObj; $this->looseObjects[$this->numObj] = 1; return $this->numObj; }
php
function openObject() { $this->nStack++; $this->stack[$this->nStack] = array( 'c' => $this->currentContents, 'p' => $this->currentPage ); // add a new object of the content type, to hold the data flow $this->numObj++; $this->o_contents( $this->numObj, 'new' ); $this->currentContents = $this->numObj; $this->looseObjects[$this->numObj] = 1; return $this->numObj; }
[ "function", "openObject", "(", ")", "{", "$", "this", "->", "nStack", "++", ";", "$", "this", "->", "stack", "[", "$", "this", "->", "nStack", "]", "=", "array", "(", "'c'", "=>", "$", "this", "->", "currentContents", ",", "'p'", "=>", "$", "this",...
make a loose object, the output will go into this object, until it is closed, then will revert to the current one. this object will not appear until it is included within a page. the function will return the object number
[ "make", "a", "loose", "object", "the", "output", "will", "go", "into", "this", "object", "until", "it", "is", "closed", "then", "will", "revert", "to", "the", "current", "one", ".", "this", "object", "will", "not", "appear", "until", "it", "is", "include...
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3384-L3396
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.reopenObject
function reopenObject( $id ) { $this->nStack++; $this->stack[$this->nStack] = array( 'c' => $this->currentContents, 'p' => $this->currentPage ); $this->currentContents=$id; // also if this object is the primary contents for a page, then set the current page to its parent if ( isset( $this->objects[$id]['onPage'] ) ) { $this->currentPage = $this->objects[$id]['onPage']; } }
php
function reopenObject( $id ) { $this->nStack++; $this->stack[$this->nStack] = array( 'c' => $this->currentContents, 'p' => $this->currentPage ); $this->currentContents=$id; // also if this object is the primary contents for a page, then set the current page to its parent if ( isset( $this->objects[$id]['onPage'] ) ) { $this->currentPage = $this->objects[$id]['onPage']; } }
[ "function", "reopenObject", "(", "$", "id", ")", "{", "$", "this", "->", "nStack", "++", ";", "$", "this", "->", "stack", "[", "$", "this", "->", "nStack", "]", "=", "array", "(", "'c'", "=>", "$", "this", "->", "currentContents", ",", "'p'", "=>",...
open an existing object for editing
[ "open", "an", "existing", "object", "for", "editing" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3401-L3412
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.closeObject
function closeObject() { // close the object, as long as there was one open in the first place, which will be indicated by // an objectId on the stack. if ( $this->nStack > 0 ) { $this->currentContents=$this->stack[$this->nStack]['c']; $this->currentPage=$this->stack[$this->nStack]['p']; $this->nStack--; // easier to probably not worry about removing the old entries, they will be overwritten // if there are new ones. } }
php
function closeObject() { // close the object, as long as there was one open in the first place, which will be indicated by // an objectId on the stack. if ( $this->nStack > 0 ) { $this->currentContents=$this->stack[$this->nStack]['c']; $this->currentPage=$this->stack[$this->nStack]['p']; $this->nStack--; // easier to probably not worry about removing the old entries, they will be overwritten // if there are new ones. } }
[ "function", "closeObject", "(", ")", "{", "// close the object, as long as there was one open in the first place, which will be indicated by", "// an objectId on the stack.", "if", "(", "$", "this", "->", "nStack", ">", "0", ")", "{", "$", "this", "->", "currentContents", "...
close an object
[ "close", "an", "object" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3417-L3429
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.addObject
function addObject( $id, $options = 'add' ) { // add the specified object to the page if ( isset( $this->looseObjects[$id] ) && $this->currentContents != $id ) { // then it is a valid object, and it is not being added to itself switch ( $options ) { case 'all': // then this object is to be added to this page (done in the next block) and // all future new pages. $this->addLooseObjects[$id] = 'all'; case 'add': if ( isset( $this->objects[$this->currentContents]['onPage'] ) ) { // then the destination contents is the primary for the page // (though this object is actually added to that page) $this->o_page( $this->objects[$this->currentContents]['onPage'], 'content', $id ); } break; case 'even': $this->addLooseObjects[$id] = 'even'; $pageObjectId = $this->objects[$this->currentContents]['onPage']; if ( $this->objects[$pageObjectId]['info']['pageNum'] % 2 == 0 ) { $this->addObject( $id ); // hacky huh :) } break; case 'odd': $this->addLooseObjects[$id] = 'odd'; $pageObjectId = $this->objects[$this->currentContents]['onPage']; if ( $this->objects[$pageObjectId]['info']['pageNum'] % 2 == 1 ) { $this->addObject( $id ); // hacky huh :) } break; case 'next': $this->addLooseObjects[$id] = 'all'; break; case 'nexteven': $this->addLooseObjects[$id] = 'even'; break; case 'nextodd': $this->addLooseObjects[$id] = 'odd'; break; } } }
php
function addObject( $id, $options = 'add' ) { // add the specified object to the page if ( isset( $this->looseObjects[$id] ) && $this->currentContents != $id ) { // then it is a valid object, and it is not being added to itself switch ( $options ) { case 'all': // then this object is to be added to this page (done in the next block) and // all future new pages. $this->addLooseObjects[$id] = 'all'; case 'add': if ( isset( $this->objects[$this->currentContents]['onPage'] ) ) { // then the destination contents is the primary for the page // (though this object is actually added to that page) $this->o_page( $this->objects[$this->currentContents]['onPage'], 'content', $id ); } break; case 'even': $this->addLooseObjects[$id] = 'even'; $pageObjectId = $this->objects[$this->currentContents]['onPage']; if ( $this->objects[$pageObjectId]['info']['pageNum'] % 2 == 0 ) { $this->addObject( $id ); // hacky huh :) } break; case 'odd': $this->addLooseObjects[$id] = 'odd'; $pageObjectId = $this->objects[$this->currentContents]['onPage']; if ( $this->objects[$pageObjectId]['info']['pageNum'] % 2 == 1 ) { $this->addObject( $id ); // hacky huh :) } break; case 'next': $this->addLooseObjects[$id] = 'all'; break; case 'nexteven': $this->addLooseObjects[$id] = 'even'; break; case 'nextodd': $this->addLooseObjects[$id] = 'odd'; break; } } }
[ "function", "addObject", "(", "$", "id", ",", "$", "options", "=", "'add'", ")", "{", "// add the specified object to the page", "if", "(", "isset", "(", "$", "this", "->", "looseObjects", "[", "$", "id", "]", ")", "&&", "$", "this", "->", "currentContents...
after an object has been created, it wil only show if it has been added, using this function.
[ "after", "an", "object", "has", "been", "created", "it", "wil", "only", "show", "if", "it", "has", "been", "added", "using", "this", "function", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3447-L3494
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.addInfo
function addInfo( $label, $value = 0 ) { // this will only work if the label is one of the valid ones. // modify this so that arrays can be passed as well. // if $label is an array then assume that it is key=>value pairs // else assume that they are both scalar, anything else will probably error if ( is_array( $label ) ) { foreach ( $label as $l => $v ) { $this->o_info( $this->infoObject, $l, $v ); } } else { $this->o_info( $this->infoObject, $label, $value ); } }
php
function addInfo( $label, $value = 0 ) { // this will only work if the label is one of the valid ones. // modify this so that arrays can be passed as well. // if $label is an array then assume that it is key=>value pairs // else assume that they are both scalar, anything else will probably error if ( is_array( $label ) ) { foreach ( $label as $l => $v ) { $this->o_info( $this->infoObject, $l, $v ); } } else { $this->o_info( $this->infoObject, $label, $value ); } }
[ "function", "addInfo", "(", "$", "label", ",", "$", "value", "=", "0", ")", "{", "// this will only work if the label is one of the valid ones.", "// modify this so that arrays can be passed as well.", "// if $label is an array then assume that it is key=>value pairs", "// else assume ...
add content to the documents info object
[ "add", "content", "to", "the", "documents", "info", "object" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3499-L3516
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.setPreferences
function setPreferences( $label, $value = 0 ) { // this will only work if the label is one of the valid ones. if ( is_array( $label ) ) { foreach ( $label as $l => $v ) { $this->o_catalog( $this->catalogId, 'viewerPreferences', array( $l => $v ) ); } } else { $this->o_catalog( $this->catalogId, 'viewerPreferences', array( $label => $value ) ); } }
php
function setPreferences( $label, $value = 0 ) { // this will only work if the label is one of the valid ones. if ( is_array( $label ) ) { foreach ( $label as $l => $v ) { $this->o_catalog( $this->catalogId, 'viewerPreferences', array( $l => $v ) ); } } else { $this->o_catalog( $this->catalogId, 'viewerPreferences', array( $label => $value ) ); } }
[ "function", "setPreferences", "(", "$", "label", ",", "$", "value", "=", "0", ")", "{", "// this will only work if the label is one of the valid ones.", "if", "(", "is_array", "(", "$", "label", ")", ")", "{", "foreach", "(", "$", "label", "as", "$", "l", "=...
set the viewer preferences of the document, it is up to the browser to obey these.
[ "set", "the", "viewer", "preferences", "of", "the", "document", "it", "is", "up", "to", "the", "browser", "to", "obey", "these", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3521-L3535
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.PRVT_getBytes
function PRVT_getBytes( &$data, $pos, $num ) { // return the integer represented by $num bytes from $pos within $data $ret = 0; for ( $i = 0; $i < $num; $i++ ) { $ret = $ret * 256; $ret+= ord( $data[$pos+$i] ); } return $ret; }
php
function PRVT_getBytes( &$data, $pos, $num ) { // return the integer represented by $num bytes from $pos within $data $ret = 0; for ( $i = 0; $i < $num; $i++ ) { $ret = $ret * 256; $ret+= ord( $data[$pos+$i] ); } return $ret; }
[ "function", "PRVT_getBytes", "(", "&", "$", "data", ",", "$", "pos", ",", "$", "num", ")", "{", "// return the integer represented by $num bytes from $pos within $data", "$", "ret", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", ...
extract an integer from a position in a byte stream @access private
[ "extract", "an", "integer", "from", "a", "position", "in", "a", "byte", "stream" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3542-L3552
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.addJpegFromFile
function addJpegFromFile( $img, $x, $y, $w = 0, $h = 0 ) { // attempt to add a jpeg image straight from a file, using no GD commands // note that this function is unable to operate on a remote file. if ( !file_exists( $img ) ) { //echo "FILE NOT EXISTS: $img"; return; } $tmp = getimagesize( $img ); $imageWidth = $tmp[0]; $imageHeight = $tmp[1]; if ( isset( $tmp['channels'] ) ) { $channels = $tmp['channels']; } else { $channels = 3; } if ( $w <= 0 && $h <= 0 ) { $w = $imageWidth; } if ( $w == 0 ) { $w = $h / $imageHeight * $imageWidth; } if ( $h == 0 ) { $h = $w * $imageHeight / $imageWidth; } $fp = fopen( $img, 'rb' ); $data = fread( $fp, filesize( $img ) ); fclose( $fp ); $this->addJpegImage_common( $data, $x, $y, $w, $h, $imageWidth, $imageHeight, $channels ); }
php
function addJpegFromFile( $img, $x, $y, $w = 0, $h = 0 ) { // attempt to add a jpeg image straight from a file, using no GD commands // note that this function is unable to operate on a remote file. if ( !file_exists( $img ) ) { //echo "FILE NOT EXISTS: $img"; return; } $tmp = getimagesize( $img ); $imageWidth = $tmp[0]; $imageHeight = $tmp[1]; if ( isset( $tmp['channels'] ) ) { $channels = $tmp['channels']; } else { $channels = 3; } if ( $w <= 0 && $h <= 0 ) { $w = $imageWidth; } if ( $w == 0 ) { $w = $h / $imageHeight * $imageWidth; } if ( $h == 0 ) { $h = $w * $imageHeight / $imageWidth; } $fp = fopen( $img, 'rb' ); $data = fread( $fp, filesize( $img ) ); fclose( $fp ); $this->addJpegImage_common( $data, $x, $y, $w, $h, $imageWidth, $imageHeight, $channels ); }
[ "function", "addJpegFromFile", "(", "$", "img", ",", "$", "x", ",", "$", "y", ",", "$", "w", "=", "0", ",", "$", "h", "=", "0", ")", "{", "// attempt to add a jpeg image straight from a file, using no GD commands", "// note that this function is unable to operate on a...
add a JPEG image into the document, from a file
[ "add", "a", "JPEG", "image", "into", "the", "document", "from", "a", "file" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3790-L3834
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.addImage
function addImage( &$img, $x, $y, $w = 0, $h = 0, $quality = 75 ) { // add a new image into the current location, as an external object // add the image at $x,$y, and with width and height as defined by $w & $h // note that this will only work with full colour images and makes them jpg images for display // later versions could present lossless image formats if there is interest. // there seems to be some problem here in that images that have quality set above 75 do not appear // not too sure why this is, but in the meantime I have restricted this to 75. if ( $quality > 75 ) { $quality = 75; } // if the width or height are set to zero, then set the other one based on keeping the image // height/width ratio the same, if they are both zero, then give up :) $imageWidth = imagesx( $img ); $imageHeight = imagesy( $img ); if ( $w <= 0 && $h <= 0 ) { return; } if ( $w == 0 ) { $w = $h / $imageHeight * $imageWidth; } if ( $h == 0 ) { $h = $w * $imageHeight / $imageWidth; } // gotta get the data out of the img.. // so I write to a temp file, and then read it back.. soo ugly, my apologies. $tmpDir = '/tmp'; $tmpName = tempnam( $tmpDir, 'img' ); imagejpeg( $img, $tmpName, $quality ); $fp = fopen( $tmpName, 'rb' ); if ( $fp ) { $data = ''; while ( !feof( $fp ) ) { $data .= fread( $fp, 1024 ); } fclose( $fp ); } else { $error = 1; $errormsg = 'trouble opening file'; } unlink( $tmpName ); $this->addJpegImage_common( $data, $x, $y, $w, $h, $imageWidth, $imageHeight ); }
php
function addImage( &$img, $x, $y, $w = 0, $h = 0, $quality = 75 ) { // add a new image into the current location, as an external object // add the image at $x,$y, and with width and height as defined by $w & $h // note that this will only work with full colour images and makes them jpg images for display // later versions could present lossless image formats if there is interest. // there seems to be some problem here in that images that have quality set above 75 do not appear // not too sure why this is, but in the meantime I have restricted this to 75. if ( $quality > 75 ) { $quality = 75; } // if the width or height are set to zero, then set the other one based on keeping the image // height/width ratio the same, if they are both zero, then give up :) $imageWidth = imagesx( $img ); $imageHeight = imagesy( $img ); if ( $w <= 0 && $h <= 0 ) { return; } if ( $w == 0 ) { $w = $h / $imageHeight * $imageWidth; } if ( $h == 0 ) { $h = $w * $imageHeight / $imageWidth; } // gotta get the data out of the img.. // so I write to a temp file, and then read it back.. soo ugly, my apologies. $tmpDir = '/tmp'; $tmpName = tempnam( $tmpDir, 'img' ); imagejpeg( $img, $tmpName, $quality ); $fp = fopen( $tmpName, 'rb' ); if ( $fp ) { $data = ''; while ( !feof( $fp ) ) { $data .= fread( $fp, 1024 ); } fclose( $fp ); } else { $error = 1; $errormsg = 'trouble opening file'; } unlink( $tmpName ); $this->addJpegImage_common( $data, $x, $y, $w, $h, $imageWidth, $imageHeight ); }
[ "function", "addImage", "(", "&", "$", "img", ",", "$", "x", ",", "$", "y", ",", "$", "w", "=", "0", ",", "$", "h", "=", "0", ",", "$", "quality", "=", "75", ")", "{", "// add a new image into the current location, as an external object", "// add the image...
add an image into the document, from a GD object this function is not all that reliable, and I would probably encourage people to use the file based functions
[ "add", "an", "image", "into", "the", "document", "from", "a", "GD", "object", "this", "function", "is", "not", "all", "that", "reliable", "and", "I", "would", "probably", "encourage", "people", "to", "use", "the", "file", "based", "functions" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3841-L3898
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.addJpegImage_common
function addJpegImage_common( &$data, $x, $y, $w = 0, $h = 0, $imageWidth, $imageHeight, $channels = 3 ) { // note that this function is not to be called externally // it is just the common code between the GD and the file options $this->numImages++; $im = $this->numImages; $label = 'I'.$im; $this->numObj++; $this->o_image( $this->numObj, 'new', array( 'label' => $label, 'data' => $data, 'iw' => $imageWidth, 'ih' => $imageHeight, 'channels' => $channels ) ); $this->objects[$this->currentContents]['c'] .= "\nq"; $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F',$w)." 0 0 ".sprintf('%.3F',$h)." ".sprintf('%.3F',$x)." ".sprintf('%.3F',$y)." cm"; $this->objects[$this->currentContents]['c'] .= "\n/".$label.' Do'; $this->objects[$this->currentContents]['c'] .= "\nQ"; }
php
function addJpegImage_common( &$data, $x, $y, $w = 0, $h = 0, $imageWidth, $imageHeight, $channels = 3 ) { // note that this function is not to be called externally // it is just the common code between the GD and the file options $this->numImages++; $im = $this->numImages; $label = 'I'.$im; $this->numObj++; $this->o_image( $this->numObj, 'new', array( 'label' => $label, 'data' => $data, 'iw' => $imageWidth, 'ih' => $imageHeight, 'channels' => $channels ) ); $this->objects[$this->currentContents]['c'] .= "\nq"; $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F',$w)." 0 0 ".sprintf('%.3F',$h)." ".sprintf('%.3F',$x)." ".sprintf('%.3F',$y)." cm"; $this->objects[$this->currentContents]['c'] .= "\n/".$label.' Do'; $this->objects[$this->currentContents]['c'] .= "\nQ"; }
[ "function", "addJpegImage_common", "(", "&", "$", "data", ",", "$", "x", ",", "$", "y", ",", "$", "w", "=", "0", ",", "$", "h", "=", "0", ",", "$", "imageWidth", ",", "$", "imageHeight", ",", "$", "channels", "=", "3", ")", "{", "// note that thi...
common code used by the two JPEG adding functions @access private
[ "common", "code", "used", "by", "the", "two", "JPEG", "adding", "functions" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3905-L3923
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.openHere
function openHere( $style, $a = 0, $b = 0, $c = 0 ) { // this function will open the document at a specified page, in a specified style // the values for style, and the required paramters are: // 'XYZ' left, top, zoom // 'Fit' // 'FitH' top // 'FitV' left // 'FitR' left,bottom,right // 'FitB' // 'FitBH' top // 'FitBV' left $this->numObj++; $this->o_destination( $this->numObj, 'new', array( 'page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c ) ); $id = $this->catalogId; $this->o_catalog( $id, 'openHere', $this->numObj ); }
php
function openHere( $style, $a = 0, $b = 0, $c = 0 ) { // this function will open the document at a specified page, in a specified style // the values for style, and the required paramters are: // 'XYZ' left, top, zoom // 'Fit' // 'FitH' top // 'FitV' left // 'FitR' left,bottom,right // 'FitB' // 'FitBH' top // 'FitBV' left $this->numObj++; $this->o_destination( $this->numObj, 'new', array( 'page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c ) ); $id = $this->catalogId; $this->o_catalog( $id, 'openHere', $this->numObj ); }
[ "function", "openHere", "(", "$", "style", ",", "$", "a", "=", "0", ",", "$", "b", "=", "0", ",", "$", "c", "=", "0", ")", "{", "// this function will open the document at a specified page, in a specified style", "// the values for style, and the required paramters are:...
specify where the document should open when it first starts
[ "specify", "where", "the", "document", "should", "open", "when", "it", "first", "starts" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3928-L3946
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.addDestination
function addDestination($label,$style,$a=0,$b=0,$c=0) { // associates the given label with the destination, it is done this way so that a destination can be specified after // it has been linked to // styles are the same as the 'openHere' function $this->numObj++; $this->o_destination( $this->numObj, 'new', array( 'page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c ) ); $id = $this->numObj; // store the label->idf relationship, note that this means that labels can be used only once $this->destinations["$label"] = $id; }
php
function addDestination($label,$style,$a=0,$b=0,$c=0) { // associates the given label with the destination, it is done this way so that a destination can be specified after // it has been linked to // styles are the same as the 'openHere' function $this->numObj++; $this->o_destination( $this->numObj, 'new', array( 'page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c ) ); $id = $this->numObj; // store the label->idf relationship, note that this means that labels can be used only once $this->destinations["$label"] = $id; }
[ "function", "addDestination", "(", "$", "label", ",", "$", "style", ",", "$", "a", "=", "0", ",", "$", "b", "=", "0", ",", "$", "c", "=", "0", ")", "{", "// associates the given label with the destination, it is done this way so that a destination can be specified a...
create a labelled destination within the document
[ "create", "a", "labelled", "destination", "within", "the", "document" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3951-L3963
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.setFontFamily
function setFontFamily($family,$options='') { if (!is_array($options)) { if ($family=='init') { // set the known family groups // these font families will be used to enable bold and italic markers to be included // within text streams. html forms will be used... <b></b> <i></i> $this->fontFamilies['Helvetica'] = array( 'b'=>'Helvetica-Bold' ,'i'=>'Helvetica-Oblique' ,'bi'=>'Helvetica-BoldOblique' ,'ib'=>'Helvetica-BoldOblique' ); $this->fontFamilies['Courier'] = array( 'b'=>'Courier-Bold' ,'i'=>'Courier-Oblique' ,'bi'=>'Courier-BoldOblique' ,'ib'=>'Courier-BoldOblique' ); $this->fontFamilies['Times-Roman'] = array( 'b'=>'Times-Bold' ,'i'=>'Times-Italic' ,'bi'=>'Times-BoldItalic' ,'ib'=>'Times-BoldItalic' ); } } else { // the user is trying to set a font family // note that this can also be used to set the base ones to something else if (strlen($family)) { $this->fontFamilies[$family] = $options; } } }
php
function setFontFamily($family,$options='') { if (!is_array($options)) { if ($family=='init') { // set the known family groups // these font families will be used to enable bold and italic markers to be included // within text streams. html forms will be used... <b></b> <i></i> $this->fontFamilies['Helvetica'] = array( 'b'=>'Helvetica-Bold' ,'i'=>'Helvetica-Oblique' ,'bi'=>'Helvetica-BoldOblique' ,'ib'=>'Helvetica-BoldOblique' ); $this->fontFamilies['Courier'] = array( 'b'=>'Courier-Bold' ,'i'=>'Courier-Oblique' ,'bi'=>'Courier-BoldOblique' ,'ib'=>'Courier-BoldOblique' ); $this->fontFamilies['Times-Roman'] = array( 'b'=>'Times-Bold' ,'i'=>'Times-Italic' ,'bi'=>'Times-BoldItalic' ,'ib'=>'Times-BoldItalic' ); } } else { // the user is trying to set a font family // note that this can also be used to set the base ones to something else if (strlen($family)) { $this->fontFamilies[$family] = $options; } } }
[ "function", "setFontFamily", "(", "$", "family", ",", "$", "options", "=", "''", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", ")", "{", "if", "(", "$", "family", "==", "'init'", ")", "{", "// set the known family groups", "// these fon...
define font families, this is used to initialize the font families for the default fonts and for the user to add new ones for their fonts. The default bahavious can be overridden should that be desired.
[ "define", "font", "families", "this", "is", "used", "to", "initialize", "the", "font", "families", "for", "the", "default", "fonts", "and", "for", "the", "user", "to", "add", "new", "ones", "for", "their", "fonts", ".", "The", "default", "bahavious", "can"...
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L3970-L4008
train
ezsystems/ezpublish-legacy
lib/ezpdf/classes/class.pdf.php
Cpdf.transaction
function transaction( $action ) { switch ( $action ) { case 'start': // store all the data away into the checkpoint variable $data = get_object_vars( $this ); $this->checkpoint = $data; unset( $data ); break; case 'commit': if ( is_array( $this->checkpoint ) && isset( $this->checkpoint['checkpoint'] ) ) { $tmp = $this->checkpoint['checkpoint']; $this->checkpoint = $tmp; unset( $tmp ); } else { $this->checkpoint = ''; } break; case 'rewind': // do not destroy the current checkpoint, but move us back to the state then, so that we can try again if ( is_array( $this->checkpoint ) ) { // can only abort if were inside a checkpoint $tmp = $this->checkpoint; foreach ( $tmp as $k => $v ) { if ( $k != 'checkpoint' ) { $this->$k = $v; } } unset($tmp); } break; case 'abort': if ( is_array( $this->checkpoint ) ) { // can only abort if were inside a checkpoint $tmp = $this->checkpoint; foreach ( $tmp as $k => $v ) { $this->$k = $v; } unset($tmp); } break; } }
php
function transaction( $action ) { switch ( $action ) { case 'start': // store all the data away into the checkpoint variable $data = get_object_vars( $this ); $this->checkpoint = $data; unset( $data ); break; case 'commit': if ( is_array( $this->checkpoint ) && isset( $this->checkpoint['checkpoint'] ) ) { $tmp = $this->checkpoint['checkpoint']; $this->checkpoint = $tmp; unset( $tmp ); } else { $this->checkpoint = ''; } break; case 'rewind': // do not destroy the current checkpoint, but move us back to the state then, so that we can try again if ( is_array( $this->checkpoint ) ) { // can only abort if were inside a checkpoint $tmp = $this->checkpoint; foreach ( $tmp as $k => $v ) { if ( $k != 'checkpoint' ) { $this->$k = $v; } } unset($tmp); } break; case 'abort': if ( is_array( $this->checkpoint ) ) { // can only abort if were inside a checkpoint $tmp = $this->checkpoint; foreach ( $tmp as $k => $v ) { $this->$k = $v; } unset($tmp); } break; } }
[ "function", "transaction", "(", "$", "action", ")", "{", "switch", "(", "$", "action", ")", "{", "case", "'start'", ":", "// store all the data away into the checkpoint variable", "$", "data", "=", "get_object_vars", "(", "$", "this", ")", ";", "$", "this", "-...
a few functions which should allow the document to be treated transactionally.
[ "a", "few", "functions", "which", "should", "allow", "the", "document", "to", "be", "treated", "transactionally", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezpdf/classes/class.pdf.php#L4021-L4073
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezimage/ezimagealiashandler.php
eZImageAliasHandler.removeAllAliases
static function removeAllAliases( $contentObjectAttribute ) { /** @var eZImageAliasHandler $handler */ $handler = $contentObjectAttribute->attribute( 'content' ); if ( !$handler->isImageOwner() ) { return; } $attributeData = $handler->originalAttributeData(); $files = eZImageFile::fetchForContentObjectAttribute( $attributeData['attribute_id'], false ); $dirs = array(); foreach ( $files as $filepath ) { $file = eZClusterFileHandler::instance( $filepath ); if ( $file->exists() ) { $file->fileDelete( $filepath ); $dirs[] = eZDir::dirpath( $filepath ); } } $dirs = array_unique( $dirs ); foreach ( $dirs as $dirpath ) { eZDir::cleanupEmptyDirectories( $dirpath ); } eZImageFile::removeForContentObjectAttribute( $attributeData['attribute_id'] ); }
php
static function removeAllAliases( $contentObjectAttribute ) { /** @var eZImageAliasHandler $handler */ $handler = $contentObjectAttribute->attribute( 'content' ); if ( !$handler->isImageOwner() ) { return; } $attributeData = $handler->originalAttributeData(); $files = eZImageFile::fetchForContentObjectAttribute( $attributeData['attribute_id'], false ); $dirs = array(); foreach ( $files as $filepath ) { $file = eZClusterFileHandler::instance( $filepath ); if ( $file->exists() ) { $file->fileDelete( $filepath ); $dirs[] = eZDir::dirpath( $filepath ); } } $dirs = array_unique( $dirs ); foreach ( $dirs as $dirpath ) { eZDir::cleanupEmptyDirectories( $dirpath ); } eZImageFile::removeForContentObjectAttribute( $attributeData['attribute_id'] ); }
[ "static", "function", "removeAllAliases", "(", "$", "contentObjectAttribute", ")", "{", "/** @var eZImageAliasHandler $handler */", "$", "handler", "=", "$", "contentObjectAttribute", "->", "attribute", "(", "'content'", ")", ";", "if", "(", "!", "$", "handler", "->...
Removes all image alias files which the attribute refers to. @param eZContentObjectAttribute @note If you want to remove the alias information use removeAliases(). @deprecated use removeAliases, it does the same thing
[ "Removes", "all", "image", "alias", "files", "which", "the", "attribute", "refers", "to", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezimage/ezimagealiashandler.php#L675-L702
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezimage/ezimagealiashandler.php
eZImageAliasHandler.purgeAllAliases
public function purgeAllAliases() { $aliasList = $this->aliasList( false ); ezpEvent::getInstance()->notify( 'image/purgeAliases', array( $aliasList['original']['url'] ) ); unset( $aliasList['original'] ); // keeping original foreach ( $aliasList as $alias ) { if ( $alias['is_valid'] ) $this->removeAliasFile( $alias['url'] ); // remove entry from DOM model $doc = $this->ContentObjectAttributeData['DataTypeCustom']['dom_tree']; $domXPath = new DOMXPath( $doc ); foreach ( $domXPath->query( "//alias[@name='{$alias['name']}']") as $aliasNode ) { $aliasNode->parentNode->removeChild( $aliasNode ); } } if ( isset( $doc ) ) $this->storeDOMTree( $doc, true, false ); }
php
public function purgeAllAliases() { $aliasList = $this->aliasList( false ); ezpEvent::getInstance()->notify( 'image/purgeAliases', array( $aliasList['original']['url'] ) ); unset( $aliasList['original'] ); // keeping original foreach ( $aliasList as $alias ) { if ( $alias['is_valid'] ) $this->removeAliasFile( $alias['url'] ); // remove entry from DOM model $doc = $this->ContentObjectAttributeData['DataTypeCustom']['dom_tree']; $domXPath = new DOMXPath( $doc ); foreach ( $domXPath->query( "//alias[@name='{$alias['name']}']") as $aliasNode ) { $aliasNode->parentNode->removeChild( $aliasNode ); } } if ( isset( $doc ) ) $this->storeDOMTree( $doc, true, false ); }
[ "public", "function", "purgeAllAliases", "(", ")", "{", "$", "aliasList", "=", "$", "this", "->", "aliasList", "(", "false", ")", ";", "ezpEvent", "::", "getInstance", "(", ")", "->", "notify", "(", "'image/purgeAliases'", ",", "array", "(", "$", "aliasLis...
Removes the images alias while keeping the original image. @see eZCache::purgeAllAliases()
[ "Removes", "the", "images", "alias", "while", "keeping", "the", "original", "image", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezimage/ezimagealiashandler.php#L708-L730
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezimage/ezimagealiashandler.php
eZImageAliasHandler.removeAliases
function removeAliases() { $aliasList = $this->aliasList(); foreach ( $aliasList as $alias ) { if ( $alias['is_valid'] ) $this->removeAliasFile( $alias['url'] ); } if ( !empty( $aliasList['original']['url'] ) ) { ezpEvent::getInstance()->notify( 'image/removeAliases', array( $aliasList['original']['url'] ) ); } $this->generateXMLData(); }
php
function removeAliases() { $aliasList = $this->aliasList(); foreach ( $aliasList as $alias ) { if ( $alias['is_valid'] ) $this->removeAliasFile( $alias['url'] ); } if ( !empty( $aliasList['original']['url'] ) ) { ezpEvent::getInstance()->notify( 'image/removeAliases', array( $aliasList['original']['url'] ) ); } $this->generateXMLData(); }
[ "function", "removeAliases", "(", ")", "{", "$", "aliasList", "=", "$", "this", "->", "aliasList", "(", ")", ";", "foreach", "(", "$", "aliasList", "as", "$", "alias", ")", "{", "if", "(", "$", "alias", "[", "'is_valid'", "]", ")", "$", "this", "->...
Removes aliases from the attribute. Files, as well as their references in ezimagefile, are only removed if this attribute/version was the last one referencing it. The attribute's XML is then reset to reference no image.
[ "Removes", "aliases", "from", "the", "attribute", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezimage/ezimagealiashandler.php#L738-L753
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezimage/ezimagealiashandler.php
eZImageAliasHandler.httpFile
function httpFile( $release = false ) { if ( isset( $this->ContentObjectAttributeData['DataTypeCustom']['http_file'] ) ) { $httpFile = $this->ContentObjectAttributeData['DataTypeCustom']['http_file']; if ( $release ) { unset( $this->ContentObjectAttributeData['DataTypeCustom']['http_file'] ); } return $httpFile; } return false; }
php
function httpFile( $release = false ) { if ( isset( $this->ContentObjectAttributeData['DataTypeCustom']['http_file'] ) ) { $httpFile = $this->ContentObjectAttributeData['DataTypeCustom']['http_file']; if ( $release ) { unset( $this->ContentObjectAttributeData['DataTypeCustom']['http_file'] ); } return $httpFile; } return false; }
[ "function", "httpFile", "(", "$", "release", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "ContentObjectAttributeData", "[", "'DataTypeCustom'", "]", "[", "'http_file'", "]", ")", ")", "{", "$", "httpFile", "=", "$", "this", "->", ...
Returns the stored HTTP file object or false if no object is stored. @param bool $release Erase the content of the stored HTTP file @see setHTTPFile
[ "Returns", "the", "stored", "HTTP", "file", "object", "or", "false", "if", "no", "object", "is", "stored", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezimage/ezimagealiashandler.php#L1076-L1089
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezimage/ezimagealiashandler.php
eZImageAliasHandler.initializeFromHTTPFile
function initializeFromHTTPFile( $httpFile, $imageAltText = false ) { $this->increaseImageSerialNumber(); $mimeData = eZMimeType::findByFileContents( $httpFile->attribute( 'filename' ) ); if ( !$mimeData['is_valid'] ) { $mimeData = eZMimeType::findByName( $httpFile->attribute( 'mime_type' ) ); if ( !$mimeData['is_valid'] ) { $mimeData = eZMimeType::findByURL( $httpFile->attribute( 'original_filename' ) ); } } $this->removeAliases(); $this->setOriginalAttributeDataValues( $this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code'] ); $contentVersion = eZContentObjectVersion::fetchVersion( $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['contentobject_id'] ); $objectName = $this->imageName( $this->ContentObjectAttributeData, $contentVersion ); $objectPathString = $this->imagePath( $this->ContentObjectAttributeData, $contentVersion, true ); eZMimeType::changeBaseName( $mimeData, $objectName ); eZMimeType::changeDirectoryPath( $mimeData, $objectPathString ); $httpFile->store( false, false, $mimeData ); $originalFilename = $httpFile->attribute( 'original_filename' ); return $this->initialize( $mimeData, $originalFilename, $imageAltText ); }
php
function initializeFromHTTPFile( $httpFile, $imageAltText = false ) { $this->increaseImageSerialNumber(); $mimeData = eZMimeType::findByFileContents( $httpFile->attribute( 'filename' ) ); if ( !$mimeData['is_valid'] ) { $mimeData = eZMimeType::findByName( $httpFile->attribute( 'mime_type' ) ); if ( !$mimeData['is_valid'] ) { $mimeData = eZMimeType::findByURL( $httpFile->attribute( 'original_filename' ) ); } } $this->removeAliases(); $this->setOriginalAttributeDataValues( $this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code'] ); $contentVersion = eZContentObjectVersion::fetchVersion( $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['contentobject_id'] ); $objectName = $this->imageName( $this->ContentObjectAttributeData, $contentVersion ); $objectPathString = $this->imagePath( $this->ContentObjectAttributeData, $contentVersion, true ); eZMimeType::changeBaseName( $mimeData, $objectName ); eZMimeType::changeDirectoryPath( $mimeData, $objectPathString ); $httpFile->store( false, false, $mimeData ); $originalFilename = $httpFile->attribute( 'original_filename' ); return $this->initialize( $mimeData, $originalFilename, $imageAltText ); }
[ "function", "initializeFromHTTPFile", "(", "$", "httpFile", ",", "$", "imageAltText", "=", "false", ")", "{", "$", "this", "->", "increaseImageSerialNumber", "(", ")", ";", "$", "mimeData", "=", "eZMimeType", "::", "findByFileContents", "(", "$", "httpFile", "...
Initializes the content object attribute with the uploaded HTTP file @param eZHTTPFile $httpFile @param string $imageAltText Optional image ALT text @return TODO: FIXME
[ "Initializes", "the", "content", "object", "attribute", "with", "the", "uploaded", "HTTP", "file" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezimage/ezimagealiashandler.php#L1099-L1128
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezuser/ezuserloginhandler.php
eZUserLoginHandler.preCheck
public static function preCheck( array &$siteBasics, eZURI $uri ) { if ( !$siteBasics['user-object-required'] ) { return null; } $ini = eZINI::instance(); $requireUserLogin = ( $ini->variable( 'SiteAccessSettings', 'RequireUserLogin' ) == 'true' ); $forceLogin = false; if ( eZSession::hasStarted() ) { $http = eZHTTPTool::instance(); $forceLogin = $http->hasSessionVariable( self::FORCE_LOGIN ); } if ( !$requireUserLogin && !$forceLogin ) { return null; } return self::checkUser( $siteBasics, $uri ); }
php
public static function preCheck( array &$siteBasics, eZURI $uri ) { if ( !$siteBasics['user-object-required'] ) { return null; } $ini = eZINI::instance(); $requireUserLogin = ( $ini->variable( 'SiteAccessSettings', 'RequireUserLogin' ) == 'true' ); $forceLogin = false; if ( eZSession::hasStarted() ) { $http = eZHTTPTool::instance(); $forceLogin = $http->hasSessionVariable( self::FORCE_LOGIN ); } if ( !$requireUserLogin && !$forceLogin ) { return null; } return self::checkUser( $siteBasics, $uri ); }
[ "public", "static", "function", "preCheck", "(", "array", "&", "$", "siteBasics", ",", "eZURI", "$", "uri", ")", "{", "if", "(", "!", "$", "siteBasics", "[", "'user-object-required'", "]", ")", "{", "return", "null", ";", "}", "$", "ini", "=", "eZINI",...
Check if user login is required. If so, use login handler to redirect user. @since 4.4 @param array $siteBasics @param eZURI $uri @return array|true|false|null An associative array on redirect with 'module' and 'function' keys, true on successful and false/null on #fail.
[ "Check", "if", "user", "login", "is", "required", ".", "If", "so", "use", "login", "handler", "to", "redirect", "user", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuserloginhandler.php#L135-L155
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/models/ezprest_authcode.php
ezpRestAuthcode.getState
public function getState() { return array( 'id' => $this->id, 'expirytime' => $this->expirytime, 'client_id' => $this->client_id, 'user_id' => $this->user_id, 'scope' => $this->scope, ); }
php
public function getState() { return array( 'id' => $this->id, 'expirytime' => $this->expirytime, 'client_id' => $this->client_id, 'user_id' => $this->user_id, 'scope' => $this->scope, ); }
[ "public", "function", "getState", "(", ")", "{", "return", "array", "(", "'id'", "=>", "$", "this", "->", "id", ",", "'expirytime'", "=>", "$", "this", "->", "expirytime", ",", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'user_id'", "=>", ...
Get the PersistentObject state. @return array(string=>mixed) The state of the object.
[ "Get", "the", "PersistentObject", "state", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/models/ezprest_authcode.php#L67-L76
train
ezsystems/ezpublish-legacy
lib/ezfile/classes/ezmd5.php
eZMD5.checkMD5Sums
static function checkMD5Sums( $file, $subDirStr = '' ) { $result = array(); $lines = file( $file, FILE_IGNORE_NEW_LINES ); if ( $lines !== false && isset( $lines[0] ) ) { foreach ( $lines as $key => $line ) { if ( isset( $line[34] ) ) { $md5Key = substr( $line, 0, 32 ); $filename = $subDirStr . substr( $line, 34 ); if ( !file_exists( $filename ) || $md5Key != md5_file( $filename ) ) { $result[] = $filename; } } } } return $result; }
php
static function checkMD5Sums( $file, $subDirStr = '' ) { $result = array(); $lines = file( $file, FILE_IGNORE_NEW_LINES ); if ( $lines !== false && isset( $lines[0] ) ) { foreach ( $lines as $key => $line ) { if ( isset( $line[34] ) ) { $md5Key = substr( $line, 0, 32 ); $filename = $subDirStr . substr( $line, 34 ); if ( !file_exists( $filename ) || $md5Key != md5_file( $filename ) ) { $result[] = $filename; } } } } return $result; }
[ "static", "function", "checkMD5Sums", "(", "$", "file", ",", "$", "subDirStr", "=", "''", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "lines", "=", "file", "(", "$", "file", ",", "FILE_IGNORE_NEW_LINES", ")", ";", "if", "(", "$", "li...
Check MD5 sum file to check if files have changed. Return array of changed files. @param string $file File name of md5 check sums file @param string $subDirStr Sub dir where files in md5 check sum file resides e.g. '' (default) if root and 'extension/ezoe/' for ezoe extension. @return array List of miss-matching files.
[ "Check", "MD5", "sum", "file", "to", "check", "if", "files", "have", "changed", ".", "Return", "array", "of", "changed", "files", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezfile/classes/ezmd5.php#L28-L50
train
ezsystems/ezpublish-legacy
kernel/common/eztemplatedesignresource.php
eZTemplateDesignResource.findDesignBase
private static function findDesignBase( eZINI $ini, $siteAccess = false ) { if( $siteAccess ) { $ini = eZSiteAccess::getIni( $siteAccess, 'site.ini' ); $standardDesign = $ini->variable( 'DesignSettings', 'StandardDesign' ); $siteDesign = $ini->variable( 'DesignSettings', 'SiteDesign' ); } else { $ini = eZINI::instance(); $standardDesign = eZTemplateDesignResource::designSetting( 'standard' ); $siteDesign = eZTemplateDesignResource::designSetting( 'site' ); } $siteDesignList = $ini->variable( 'DesignSettings', 'AdditionalSiteDesignList' ); array_unshift( $siteDesignList, $siteDesign ); $siteDesignList[] = $standardDesign; $siteDesignList = array_unique( $siteDesignList ); $designBaseList = array(); $extensionDirectory = eZExtension::baseDirectory(); $designStartPath = eZTemplateDesignResource::designStartPath(); $extensions = eZTemplateDesignResource::designExtensions(); foreach ( $siteDesignList as $design ) { foreach ( $extensions as $extension ) { $path = "$extensionDirectory/$extension/$designStartPath/$design"; if ( file_exists( $path ) ) { $designBaseList[] = $path; } } $path = "$designStartPath/$design"; if ( file_exists( $path ) ) { $designBaseList[] = $path; } } return $designBaseList; }
php
private static function findDesignBase( eZINI $ini, $siteAccess = false ) { if( $siteAccess ) { $ini = eZSiteAccess::getIni( $siteAccess, 'site.ini' ); $standardDesign = $ini->variable( 'DesignSettings', 'StandardDesign' ); $siteDesign = $ini->variable( 'DesignSettings', 'SiteDesign' ); } else { $ini = eZINI::instance(); $standardDesign = eZTemplateDesignResource::designSetting( 'standard' ); $siteDesign = eZTemplateDesignResource::designSetting( 'site' ); } $siteDesignList = $ini->variable( 'DesignSettings', 'AdditionalSiteDesignList' ); array_unshift( $siteDesignList, $siteDesign ); $siteDesignList[] = $standardDesign; $siteDesignList = array_unique( $siteDesignList ); $designBaseList = array(); $extensionDirectory = eZExtension::baseDirectory(); $designStartPath = eZTemplateDesignResource::designStartPath(); $extensions = eZTemplateDesignResource::designExtensions(); foreach ( $siteDesignList as $design ) { foreach ( $extensions as $extension ) { $path = "$extensionDirectory/$extension/$designStartPath/$design"; if ( file_exists( $path ) ) { $designBaseList[] = $path; } } $path = "$designStartPath/$design"; if ( file_exists( $path ) ) { $designBaseList[] = $path; } } return $designBaseList; }
[ "private", "static", "function", "findDesignBase", "(", "eZINI", "$", "ini", ",", "$", "siteAccess", "=", "false", ")", "{", "if", "(", "$", "siteAccess", ")", "{", "$", "ini", "=", "eZSiteAccess", "::", "getIni", "(", "$", "siteAccess", ",", "'site.ini'...
Find the location on design bases on the disk @param $ini an eZINI object @param $siteAccess Wether to use siteaccesses or not @return array The list of design bases
[ "Find", "the", "location", "on", "design", "bases", "on", "the", "disk" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/common/eztemplatedesignresource.php#L723-L770
train
ezsystems/ezpublish-legacy
kernel/common/eztemplatedesignresource.php
eZTemplateDesignResource.savesMemoryCache
private static function savesMemoryCache( array $designBaseList, $siteAccess = false ) { // store design base list in memory for the current request if ( $siteAccess ) $GLOBALS['eZTemplateDesignResourceSiteAccessBases'][$siteAccess] = $designBaseList; else $GLOBALS['eZTemplateDesignResourceBases'] = $designBaseList; }
php
private static function savesMemoryCache( array $designBaseList, $siteAccess = false ) { // store design base list in memory for the current request if ( $siteAccess ) $GLOBALS['eZTemplateDesignResourceSiteAccessBases'][$siteAccess] = $designBaseList; else $GLOBALS['eZTemplateDesignResourceBases'] = $designBaseList; }
[ "private", "static", "function", "savesMemoryCache", "(", "array", "$", "designBaseList", ",", "$", "siteAccess", "=", "false", ")", "{", "// store design base list in memory for the current request", "if", "(", "$", "siteAccess", ")", "$", "GLOBALS", "[", "'eZTemplat...
Stores design base list in memory for the current request @param $designBaseList An array with the design bases @param $siteAccess Whether to use siteaccess or not @return void
[ "Stores", "design", "base", "list", "in", "memory", "for", "the", "current", "request" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/common/eztemplatedesignresource.php#L779-L786
train
ezsystems/ezpublish-legacy
kernel/common/eztemplatedesignresource.php
eZTemplateDesignResource.overrideArray
static function overrideArray( $siteAccess = false ) { if ( $siteAccess === false and self::$overrideArrayCache !== null ) { return self::$overrideArrayCache; } $bases = eZTemplateDesignResource::allDesignBases( $siteAccess ); // fetch the override array from a specific siteacces if ( $siteAccess ) { $overrideINI = eZSiteAccess::getIni( $siteAccess, 'override.ini' ); } else { $overrideINI = eZINI::instance( 'override.ini' ); } $designStartPath = eZTemplateDesignResource::designStartPath(); // Generate match cache for all templates // Build arrays of available files, start with standard design and end with most prefered design $matchFileArray = array(); $reverseBases = array_reverse( $bases ); foreach ( $reverseBases as $base ) { $templateResource = $base . '/templates'; $sourceFileArray = eZDir::recursiveFindRelative( $templateResource, "", "tpl" ); foreach ( $sourceFileArray as $source ) { $matchFileArray[$source]['base_dir'] = $templateResource; $matchFileArray[$source]['template'] = $source; } } // Load override templates $overrideSettingGroups = $overrideINI->groups(); if ( isset( $GLOBALS['eZDesignOverrides'] ) ) { $overrideSettingGroups = array_merge( $overrideSettingGroups, $GLOBALS['eZDesignOverrides'] ); } foreach ( $overrideSettingGroups as $overrideName => $overrideSetting ) { if( !isset( $overrideSetting['Source'] ) ) { continue; } $overrideSource = "/" . $overrideSetting['Source']; $overrideMatchFile = $overrideSetting['MatchFile']; // Find the matching file in the available resources $triedFiles = array(); $fileInfo = eZTemplateDesignResource::fileMatch( $bases, 'override/templates', $overrideMatchFile, $triedFiles ); $resourceInUse = is_array( $fileInfo ) ? $fileInfo['resource'] : false; $overrideMatchFilePath = is_array( $fileInfo ) ? $fileInfo['path'] : false; // if the override template is not found // then we probably shouldn't use it // there should be added a check around the following code // if ( $overrideMatchFilePath ) // { $customMatchArray = array(); $customMatchArray['conditions'] = isset( $overrideSetting['Match'] ) ? $overrideSetting['Match'] : null; $customMatchArray['match_file'] = $overrideMatchFilePath; $customMatchArray['override_name'] = $overrideName; $matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray; // } // if overriding a non-existing template // then we use the override template as main template // this code should probably be removed // because we should not allow an override if the main template is missing if ( $resourceInUse && !isset( $matchFileArray[$overrideSource]['base_dir'] ) ) { $matchFileArray[$overrideSource]['base_dir'] = $resourceInUse; $matchFileArray[$overrideSource]['template'] = $overrideSource; } if ( ! $overrideMatchFilePath ) { eZDebug::writeError( "Custom match file: path '$overrideMatchFile' not found in any resource. Check the template settings in settings/override.ini", __METHOD__ ); eZDebug::writeError( implode( ', ', $triedFiles ), __METHOD__ . ' tried files' ); } } if ( $siteAccess === false ) { self::$overrideArrayCache = $matchFileArray; } return $matchFileArray; }
php
static function overrideArray( $siteAccess = false ) { if ( $siteAccess === false and self::$overrideArrayCache !== null ) { return self::$overrideArrayCache; } $bases = eZTemplateDesignResource::allDesignBases( $siteAccess ); // fetch the override array from a specific siteacces if ( $siteAccess ) { $overrideINI = eZSiteAccess::getIni( $siteAccess, 'override.ini' ); } else { $overrideINI = eZINI::instance( 'override.ini' ); } $designStartPath = eZTemplateDesignResource::designStartPath(); // Generate match cache for all templates // Build arrays of available files, start with standard design and end with most prefered design $matchFileArray = array(); $reverseBases = array_reverse( $bases ); foreach ( $reverseBases as $base ) { $templateResource = $base . '/templates'; $sourceFileArray = eZDir::recursiveFindRelative( $templateResource, "", "tpl" ); foreach ( $sourceFileArray as $source ) { $matchFileArray[$source]['base_dir'] = $templateResource; $matchFileArray[$source]['template'] = $source; } } // Load override templates $overrideSettingGroups = $overrideINI->groups(); if ( isset( $GLOBALS['eZDesignOverrides'] ) ) { $overrideSettingGroups = array_merge( $overrideSettingGroups, $GLOBALS['eZDesignOverrides'] ); } foreach ( $overrideSettingGroups as $overrideName => $overrideSetting ) { if( !isset( $overrideSetting['Source'] ) ) { continue; } $overrideSource = "/" . $overrideSetting['Source']; $overrideMatchFile = $overrideSetting['MatchFile']; // Find the matching file in the available resources $triedFiles = array(); $fileInfo = eZTemplateDesignResource::fileMatch( $bases, 'override/templates', $overrideMatchFile, $triedFiles ); $resourceInUse = is_array( $fileInfo ) ? $fileInfo['resource'] : false; $overrideMatchFilePath = is_array( $fileInfo ) ? $fileInfo['path'] : false; // if the override template is not found // then we probably shouldn't use it // there should be added a check around the following code // if ( $overrideMatchFilePath ) // { $customMatchArray = array(); $customMatchArray['conditions'] = isset( $overrideSetting['Match'] ) ? $overrideSetting['Match'] : null; $customMatchArray['match_file'] = $overrideMatchFilePath; $customMatchArray['override_name'] = $overrideName; $matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray; // } // if overriding a non-existing template // then we use the override template as main template // this code should probably be removed // because we should not allow an override if the main template is missing if ( $resourceInUse && !isset( $matchFileArray[$overrideSource]['base_dir'] ) ) { $matchFileArray[$overrideSource]['base_dir'] = $resourceInUse; $matchFileArray[$overrideSource]['template'] = $overrideSource; } if ( ! $overrideMatchFilePath ) { eZDebug::writeError( "Custom match file: path '$overrideMatchFile' not found in any resource. Check the template settings in settings/override.ini", __METHOD__ ); eZDebug::writeError( implode( ', ', $triedFiles ), __METHOD__ . ' tried files' ); } } if ( $siteAccess === false ) { self::$overrideArrayCache = $matchFileArray; } return $matchFileArray; }
[ "static", "function", "overrideArray", "(", "$", "siteAccess", "=", "false", ")", "{", "if", "(", "$", "siteAccess", "===", "false", "and", "self", "::", "$", "overrideArrayCache", "!==", "null", ")", "{", "return", "self", "::", "$", "overrideArrayCache", ...
Get an array of all the current templates and overrides for them. The current siteaccess is used if none is specified. @static @return array
[ "Get", "an", "array", "of", "all", "the", "current", "templates", "and", "overrides", "for", "them", ".", "The", "current", "siteaccess", "is", "used", "if", "none", "is", "specified", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/common/eztemplatedesignresource.php#L823-L923
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.hasResponseGroup
protected function hasResponseGroup( $name ) { return in_array( $name, $this->defaultResponsegroups ) || ( isset( $this->request->variables['ResponseGroups'] ) && in_array( $name, $this->request->variables['ResponseGroups'] ) ); }
php
protected function hasResponseGroup( $name ) { return in_array( $name, $this->defaultResponsegroups ) || ( isset( $this->request->variables['ResponseGroups'] ) && in_array( $name, $this->request->variables['ResponseGroups'] ) ); }
[ "protected", "function", "hasResponseGroup", "(", "$", "name", ")", "{", "return", "in_array", "(", "$", "name", ",", "$", "this", "->", "defaultResponsegroups", ")", "||", "(", "isset", "(", "$", "this", "->", "request", "->", "variables", "[", "'Response...
Checks if a response group has been provided in the requested REST URI @param string $name Response group name @return bool
[ "Checks", "if", "a", "response", "group", "has", "been", "provided", "in", "the", "requested", "REST", "URI" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L61-L68
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.getResponseGroups
protected function getResponseGroups() { $resGroups = $this->request->variables['ResponseGroups']; for ( $i = 0, $iMax = count( $this->defaultResponsegroups ); $i < $iMax; ++$i ) { if ( !in_array( $this->defaultResponsegroups[$i], $resGroups ) ) $resGroups[] = $this->defaultResponsegroups[$i]; } return $resGroups; }
php
protected function getResponseGroups() { $resGroups = $this->request->variables['ResponseGroups']; for ( $i = 0, $iMax = count( $this->defaultResponsegroups ); $i < $iMax; ++$i ) { if ( !in_array( $this->defaultResponsegroups[$i], $resGroups ) ) $resGroups[] = $this->defaultResponsegroups[$i]; } return $resGroups; }
[ "protected", "function", "getResponseGroups", "(", ")", "{", "$", "resGroups", "=", "$", "this", "->", "request", "->", "variables", "[", "'ResponseGroups'", "]", ";", "for", "(", "$", "i", "=", "0", ",", "$", "iMax", "=", "count", "(", "$", "this", ...
Returns requested response groups @return array
[ "Returns", "requested", "response", "groups" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L75-L85
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.getContentVariable
protected function getContentVariable( $name ) { if ( isset( $this->request->contentVariables[$name] ) ) { return $this->request->contentVariables[$name]; } return null; }
php
protected function getContentVariable( $name ) { if ( isset( $this->request->contentVariables[$name] ) ) { return $this->request->contentVariables[$name]; } return null; }
[ "protected", "function", "getContentVariable", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "request", "->", "contentVariables", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "request", "->", "contentVariab...
Returns requested content variable, is it set @param string $name Content variable name @return string|null
[ "Returns", "requested", "content", "variable", "is", "it", "set" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L118-L126
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.createResult
public function createResult() { $debug = ezpRestDebug::getInstance(); $debug->startTimer( 'GeneratingRestResult', 'RestController' ); if ( !self::$isCacheCreated ) { ezcCacheManager::createCache( self::CACHE_ID, $this->getCacheLocation(), 'ezpRestCacheStorageClusterObject', array( 'ttl' => $this->getActionTTL() ) ); self::$isCacheCreated = true; } $cache = ezcCacheManager::getCache( self::CACHE_ID ); $controllerCacheId = $this->generateCacheId(); $isCacheEnabled = $this->isCacheEnabled(); // Try to restore application cache. // If expired or not yet available, generate it and store it $cache->isCacheEnabled = $isCacheEnabled; if ( ( $res = $cache->restore( $controllerCacheId ) ) === false ) { try { $debug->log( 'Generating cache', ezcLog::DEBUG ); $debug->switchTimer( 'GeneratingCache', 'GeneratingRestResult' ); $res = parent::createResult(); $resGroups = $this->getResponseGroups(); if ( !empty( $resGroups ) ) { $res->variables['requestedResponseGroups'] = $resGroups; } if ( $res instanceof ezpRestMvcResult ) { $res->responseGroups = $resGroups; } if ( $isCacheEnabled ) $cache->store( $controllerCacheId, $res ); $debug->stopTimer( 'GeneratingCache' ); } catch ( Exception $e ) { $debug->log( 'Exception caught, aborting cache generation', ezcLog::DEBUG ); if ( $isCacheEnabled ) $cache->abortCacheGeneration(); throw $e; } } // Add debug infos to output if debug is enabled $debug->stopTimer( 'GeneratingRestResult' ); if ( ezpRestDebug::isDebugEnabled() ) { $res->variables['debug'] = $debug->getReport(); } return $res; }
php
public function createResult() { $debug = ezpRestDebug::getInstance(); $debug->startTimer( 'GeneratingRestResult', 'RestController' ); if ( !self::$isCacheCreated ) { ezcCacheManager::createCache( self::CACHE_ID, $this->getCacheLocation(), 'ezpRestCacheStorageClusterObject', array( 'ttl' => $this->getActionTTL() ) ); self::$isCacheCreated = true; } $cache = ezcCacheManager::getCache( self::CACHE_ID ); $controllerCacheId = $this->generateCacheId(); $isCacheEnabled = $this->isCacheEnabled(); // Try to restore application cache. // If expired or not yet available, generate it and store it $cache->isCacheEnabled = $isCacheEnabled; if ( ( $res = $cache->restore( $controllerCacheId ) ) === false ) { try { $debug->log( 'Generating cache', ezcLog::DEBUG ); $debug->switchTimer( 'GeneratingCache', 'GeneratingRestResult' ); $res = parent::createResult(); $resGroups = $this->getResponseGroups(); if ( !empty( $resGroups ) ) { $res->variables['requestedResponseGroups'] = $resGroups; } if ( $res instanceof ezpRestMvcResult ) { $res->responseGroups = $resGroups; } if ( $isCacheEnabled ) $cache->store( $controllerCacheId, $res ); $debug->stopTimer( 'GeneratingCache' ); } catch ( Exception $e ) { $debug->log( 'Exception caught, aborting cache generation', ezcLog::DEBUG ); if ( $isCacheEnabled ) $cache->abortCacheGeneration(); throw $e; } } // Add debug infos to output if debug is enabled $debug->stopTimer( 'GeneratingRestResult' ); if ( ezpRestDebug::isDebugEnabled() ) { $res->variables['debug'] = $debug->getReport(); } return $res; }
[ "public", "function", "createResult", "(", ")", "{", "$", "debug", "=", "ezpRestDebug", "::", "getInstance", "(", ")", ";", "$", "debug", "->", "startTimer", "(", "'GeneratingRestResult'", ",", "'RestController'", ")", ";", "if", "(", "!", "self", "::", "$...
Override to add the "requestedResponseGroups" variable for every REST requests @see lib/ezc/MvcTools/src/interfaces/ezcMvcController::createResult()
[ "Override", "to", "add", "the", "requestedResponseGroups", "variable", "for", "every", "REST", "requests" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L143-L207
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.doHttpOptions
public function doHttpOptions() { $methods = implode( ', ', $this->supported_http_methods ); $result = new ezpRestMvcResult; $result->status = new ezpRestStatusResponse( ezpHttpResponseCodes::OK, 'Allowed methods are: ' . $methods, array( 'Allow' => $methods ) ); return $result; }
php
public function doHttpOptions() { $methods = implode( ', ', $this->supported_http_methods ); $result = new ezpRestMvcResult; $result->status = new ezpRestStatusResponse( ezpHttpResponseCodes::OK, 'Allowed methods are: ' . $methods, array( 'Allow' => $methods ) ); return $result; }
[ "public", "function", "doHttpOptions", "(", ")", "{", "$", "methods", "=", "implode", "(", "', '", ",", "$", "this", "->", "supported_http_methods", ")", ";", "$", "result", "=", "new", "ezpRestMvcResult", ";", "$", "result", "->", "status", "=", "new", ...
Default action to handle OPTIONS requests. @return ezcMvcResult
[ "Default", "action", "to", "handle", "OPTIONS", "requests", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L214-L224
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.getActionTTL
private function getActionTTL() { $routingInfos = $this->getRouter()->getRoutingInformation(); // Check if we have TTL settings for this controller/action $actionSectionName = $routingInfos->controllerClass . '_' . $routingInfos->action . '_CacheSettings'; if ( $this->restINI->hasVariable( $actionSectionName, 'CacheTTL' ) ) { return (int)$this->restINI->variable( $actionSectionName, 'CacheTTL' ); } $controllerSectionName = $routingInfos->controllerClass . '_CacheSettings'; if ( $this->restINI->hasVariable( $controllerSectionName, 'CacheTTL' ) ) // Nothing at controller/action level, check at controller level { return (int)$this->restINI->variable( $controllerSectionName, 'CacheTTL' ); } return (int)$this->restINI->variable( 'CacheSettings', 'DefaultCacheTTL' ); }
php
private function getActionTTL() { $routingInfos = $this->getRouter()->getRoutingInformation(); // Check if we have TTL settings for this controller/action $actionSectionName = $routingInfos->controllerClass . '_' . $routingInfos->action . '_CacheSettings'; if ( $this->restINI->hasVariable( $actionSectionName, 'CacheTTL' ) ) { return (int)$this->restINI->variable( $actionSectionName, 'CacheTTL' ); } $controllerSectionName = $routingInfos->controllerClass . '_CacheSettings'; if ( $this->restINI->hasVariable( $controllerSectionName, 'CacheTTL' ) ) // Nothing at controller/action level, check at controller level { return (int)$this->restINI->variable( $controllerSectionName, 'CacheTTL' ); } return (int)$this->restINI->variable( 'CacheSettings', 'DefaultCacheTTL' ); }
[ "private", "function", "getActionTTL", "(", ")", "{", "$", "routingInfos", "=", "$", "this", "->", "getRouter", "(", ")", "->", "getRoutingInformation", "(", ")", ";", "// Check if we have TTL settings for this controller/action", "$", "actionSectionName", "=", "$", ...
Returns cache TTL value for current action as set in rest.ini Default value will be [CacheSettings].DefaultCacheTTL. This can be refined by setting a [<controllerClass>_<action>_CacheSettings] section (see comments in rest.ini). @return int TTL in seconds
[ "Returns", "cache", "TTL", "value", "for", "current", "action", "as", "set", "in", "rest", ".", "ini" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L248-L266
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/controllers/rest_controller.php
ezpRestMvcController.generateCacheId
private function generateCacheId() { $routingInfos = $this->getRouter()->getRoutingInformation(); $aCacheId = array( ezpRestPrefixFilterInterface::getApiProviderName(), ezpRestPrefixFilterInterface::getApiVersion(), $routingInfos->controllerClass, $routingInfos->action ); // Add internal variables, caught in the URL. See ezpRestHttpRequestParser::fillVariables() // Also add content variables foreach ( $this->request->contentVariables + $this->request->variables as $name => $val ) { $aCacheId[] = $name . '=' . ( is_array( $val ) ? implode( ',', $val ) : $val ); } return md5( implode( '-', $aCacheId ) ); }
php
private function generateCacheId() { $routingInfos = $this->getRouter()->getRoutingInformation(); $aCacheId = array( ezpRestPrefixFilterInterface::getApiProviderName(), ezpRestPrefixFilterInterface::getApiVersion(), $routingInfos->controllerClass, $routingInfos->action ); // Add internal variables, caught in the URL. See ezpRestHttpRequestParser::fillVariables() // Also add content variables foreach ( $this->request->contentVariables + $this->request->variables as $name => $val ) { $aCacheId[] = $name . '=' . ( is_array( $val ) ? implode( ',', $val ) : $val ); } return md5( implode( '-', $aCacheId ) ); }
[ "private", "function", "generateCacheId", "(", ")", "{", "$", "routingInfos", "=", "$", "this", "->", "getRouter", "(", ")", "->", "getRoutingInformation", "(", ")", ";", "$", "aCacheId", "=", "array", "(", "ezpRestPrefixFilterInterface", "::", "getApiProviderNa...
Generates unique cache ID for current request. The cache ID is a MD5 hash and takes into account : - API Name - API Version - Controller class - Action - Internal variables (passed parameters, ResponseGroups...) - Content variables (Translation...) @return string
[ "Generates", "unique", "cache", "ID", "for", "current", "request", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/rest_controller.php#L281-L299
train
ezsystems/ezpublish-legacy
kernel/classes/binaryhandlers/ezfilepassthrough/ezfilepassthroughhandler.php
eZFilePassthroughHandler.dispositionType
protected static function dispositionType( $mimeType ) { $ini = eZINI::instance( 'file.ini' ); $mimeTypes = $ini->variable( 'PassThroughSettings', 'ContentDisposition', array() ); if ( isset( $mimeTypes[$mimeType] ) ) { return $mimeTypes[$mimeType]; } return $ini->variable( 'PassThroughSettings', 'DefaultContentDisposition' ); }
php
protected static function dispositionType( $mimeType ) { $ini = eZINI::instance( 'file.ini' ); $mimeTypes = $ini->variable( 'PassThroughSettings', 'ContentDisposition', array() ); if ( isset( $mimeTypes[$mimeType] ) ) { return $mimeTypes[$mimeType]; } return $ini->variable( 'PassThroughSettings', 'DefaultContentDisposition' ); }
[ "protected", "static", "function", "dispositionType", "(", "$", "mimeType", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", "'file.ini'", ")", ";", "$", "mimeTypes", "=", "$", "ini", "->", "variable", "(", "'PassThroughSettings'", ",", "'ContentDi...
Checks if a file should be downloaded to disk or displayed inline in the browser. Behavior by MIME type and default behavior are configured in file.ini @param string $mimetype @return string "attachment" or "inline"
[ "Checks", "if", "a", "file", "should", "be", "downloaded", "to", "disk", "or", "displayed", "inline", "in", "the", "browser", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/binaryhandlers/ezfilepassthrough/ezfilepassthroughhandler.php#L91-L102
train
ezsystems/ezpublish-legacy
kernel/classes/ezsslzone.php
eZSSLZone.enabled
static function enabled() { if ( isset( $GLOBALS['eZSSLZoneEnabled'] ) ) return $GLOBALS['eZSSLZoneEnabled']; $enabled = false; $ini = eZINI::instance(); if ( $ini->hasVariable( 'SSLZoneSettings', 'SSLZones' ) ) $enabled = ( $ini->variable( 'SSLZoneSettings', 'SSLZones' ) == 'enabled' ); return $GLOBALS['eZSSLZoneEnabled'] = $enabled; }
php
static function enabled() { if ( isset( $GLOBALS['eZSSLZoneEnabled'] ) ) return $GLOBALS['eZSSLZoneEnabled']; $enabled = false; $ini = eZINI::instance(); if ( $ini->hasVariable( 'SSLZoneSettings', 'SSLZones' ) ) $enabled = ( $ini->variable( 'SSLZoneSettings', 'SSLZones' ) == 'enabled' ); return $GLOBALS['eZSSLZoneEnabled'] = $enabled; }
[ "static", "function", "enabled", "(", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'eZSSLZoneEnabled'", "]", ")", ")", "return", "$", "GLOBALS", "[", "'eZSSLZoneEnabled'", "]", ";", "$", "enabled", "=", "false", ";", "$", "ini", "=", "eZINI...
\static Returns true if the SSL zones functionality is enabled, false otherwise. The result is cached in memory to save time on multiple invocations.
[ "\\", "static", "Returns", "true", "if", "the", "SSL", "zones", "functionality", "is", "enabled", "false", "otherwise", ".", "The", "result", "is", "cached", "in", "memory", "to", "save", "time", "on", "multiple", "invocations", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsslzone.php#L37-L48
train
ezsystems/ezpublish-legacy
kernel/classes/ezsslzone.php
eZSSLZone.isKeepModeView
static function isKeepModeView( $module, $view ) { $ini = eZINI::instance(); $viewsModes = $ini->variable( 'SSLZoneSettings', 'ModuleViewAccessMode' ); $sslViews = array_keys( $viewsModes, 'ssl' ); $keepModeViews = array_keys( $viewsModes, 'keep' ); if ( eZSSLZone::viewIsInArray( $module, $view, $keepModeViews ) < eZSSLZone::viewIsInArray( $module, $view, $sslViews ) ) { eZDebugSetting::writeDebug( 'kernel-ssl-zone', 'The view cannot choose access mode itself.' ); return false; } return true; }
php
static function isKeepModeView( $module, $view ) { $ini = eZINI::instance(); $viewsModes = $ini->variable( 'SSLZoneSettings', 'ModuleViewAccessMode' ); $sslViews = array_keys( $viewsModes, 'ssl' ); $keepModeViews = array_keys( $viewsModes, 'keep' ); if ( eZSSLZone::viewIsInArray( $module, $view, $keepModeViews ) < eZSSLZone::viewIsInArray( $module, $view, $sslViews ) ) { eZDebugSetting::writeDebug( 'kernel-ssl-zone', 'The view cannot choose access mode itself.' ); return false; } return true; }
[ "static", "function", "isKeepModeView", "(", "$", "module", ",", "$", "view", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", ")", ";", "$", "viewsModes", "=", "$", "ini", "->", "variable", "(", "'SSLZoneSettings'", ",", "'ModuleViewAccessMode'"...
\static \return true if the view is defined as 'keep'
[ "\\", "static", "\\", "return", "true", "if", "the", "view", "is", "defined", "as", "keep" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsslzone.php#L189-L204
train
ezsystems/ezpublish-legacy
kernel/classes/ezsslzone.php
eZSSLZone.checkObject
static function checkObject( $module, $view, $object ) { if ( !eZSSLZone::enabled() ) return; /* If the given module/view is not in the list of 'keep mode' views, * i.e. it cannot choose access mode itself, * then do nothing. */ if ( !eZSSLZone::isKeepModeView( $module, $view ) ) return; $pathStringList = eZPersistentObject::fetchObjectList( eZContentObjectTreeNode::definition(), // def array( 'path_string' ), // field_filters array( 'contentobject_id' => $object->attribute( 'id' ) ), // conds null, // sorts null, // limit false // asObject ); if ( is_array( $pathStringList ) && count( $pathStringList ) ) { /* The object has some assigned nodes. * If at least one of those nodes belongs to an SSL zone, * we switch to SSL. */ // "flatten" the array array_walk( $pathStringList, function( &$a ) { $a = $a['path_string']; } ); } else { /* The object has no assigned nodes. * Let's work with its parent nodes. * If at least one of the parent nodes belongs to an SSL zone, * we switch to SSL. */ $pathStringList = array(); $nodes = $object->parentNodes( $object->attribute( 'current' ) ); if ( !is_array( $nodes ) ) { eZDebug::writeError( 'Object ' . $object->attribute( 'is' ) . 'does not have neither assigned nor parent nodes.' ); } else { foreach( $nodes as $node ) { $pathStringList[] = $node->attribute( 'path_string' ); } } } $inSSL = false; // does the object belong to an SSL zone? foreach ( $pathStringList as $pathString ) { if ( eZSSLZone::checkNodePath( $module, $view, $pathString, false ) ) { $inSSL = true; break; } } eZSSLZone::switchIfNeeded( $inSSL ); }
php
static function checkObject( $module, $view, $object ) { if ( !eZSSLZone::enabled() ) return; /* If the given module/view is not in the list of 'keep mode' views, * i.e. it cannot choose access mode itself, * then do nothing. */ if ( !eZSSLZone::isKeepModeView( $module, $view ) ) return; $pathStringList = eZPersistentObject::fetchObjectList( eZContentObjectTreeNode::definition(), // def array( 'path_string' ), // field_filters array( 'contentobject_id' => $object->attribute( 'id' ) ), // conds null, // sorts null, // limit false // asObject ); if ( is_array( $pathStringList ) && count( $pathStringList ) ) { /* The object has some assigned nodes. * If at least one of those nodes belongs to an SSL zone, * we switch to SSL. */ // "flatten" the array array_walk( $pathStringList, function( &$a ) { $a = $a['path_string']; } ); } else { /* The object has no assigned nodes. * Let's work with its parent nodes. * If at least one of the parent nodes belongs to an SSL zone, * we switch to SSL. */ $pathStringList = array(); $nodes = $object->parentNodes( $object->attribute( 'current' ) ); if ( !is_array( $nodes ) ) { eZDebug::writeError( 'Object ' . $object->attribute( 'is' ) . 'does not have neither assigned nor parent nodes.' ); } else { foreach( $nodes as $node ) { $pathStringList[] = $node->attribute( 'path_string' ); } } } $inSSL = false; // does the object belong to an SSL zone? foreach ( $pathStringList as $pathString ) { if ( eZSSLZone::checkNodePath( $module, $view, $pathString, false ) ) { $inSSL = true; break; } } eZSSLZone::switchIfNeeded( $inSSL ); }
[ "static", "function", "checkObject", "(", "$", "module", ",", "$", "view", ",", "$", "object", ")", "{", "if", "(", "!", "eZSSLZone", "::", "enabled", "(", ")", ")", "return", ";", "/* If the given module/view is not in the list of 'keep mode' views,\n * i.e...
\static Check whether the given object should cause access mode change. It it should, this method does not return.
[ "\\", "static", "Check", "whether", "the", "given", "object", "should", "cause", "access", "mode", "change", ".", "It", "it", "should", "this", "method", "does", "not", "return", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsslzone.php#L379-L444
train
ezsystems/ezpublish-legacy
kernel/classes/ezsslzone.php
eZSSLZone.checkModuleView
static function checkModuleView( $module, $view ) { if ( !eZSSLZone::enabled() ) return; $ini = eZINI::instance(); $viewsModes = $ini->variable( 'SSLZoneSettings', 'ModuleViewAccessMode' ); $sslViews = array_keys( $viewsModes, 'ssl' ); $keepModeViews = array_keys( $viewsModes, 'keep' ); $sslPriority = eZSSLZone::viewIsInArray( $module, $view, $sslViews ); $keepModePriority = eZSSLZone::viewIsInArray( $module, $view, $keepModeViews ); if ( $sslPriority && $keepModePriority && $sslPriority == $keepModePriority ) { eZDebug::writeError( "Configuration error: view $module/$view is defined both as 'ssl' and 'keep'", 'eZSSLZone' ); return; } /* If the view belongs to the list of views we should not change access mode for, * then do nothing. * (however, the view may do access mode switch itself later) */ if ( $keepModePriority > $sslPriority ) { eZDebugSetting::writeDebug( 'kernel-ssl-zone', 'Keeping current access mode...' ); return; } /* Otherwise we look if the view is in the list of SSL views, * and if it is, we switch to SSL. Else, if it's not, we switch to plain HTTP. */ $inSSL = ( $sslPriority > 0 ); eZDebugSetting::writeDebug( 'kernel-ssl-zone', ( isset( $inSSL ) ? ( $inSSL?'yes':'no') : 'dunno' ), 'Should we use SSL for this view?' ); // Change access mode if we need to. eZSSLZone::switchIfNeeded( $inSSL ); }
php
static function checkModuleView( $module, $view ) { if ( !eZSSLZone::enabled() ) return; $ini = eZINI::instance(); $viewsModes = $ini->variable( 'SSLZoneSettings', 'ModuleViewAccessMode' ); $sslViews = array_keys( $viewsModes, 'ssl' ); $keepModeViews = array_keys( $viewsModes, 'keep' ); $sslPriority = eZSSLZone::viewIsInArray( $module, $view, $sslViews ); $keepModePriority = eZSSLZone::viewIsInArray( $module, $view, $keepModeViews ); if ( $sslPriority && $keepModePriority && $sslPriority == $keepModePriority ) { eZDebug::writeError( "Configuration error: view $module/$view is defined both as 'ssl' and 'keep'", 'eZSSLZone' ); return; } /* If the view belongs to the list of views we should not change access mode for, * then do nothing. * (however, the view may do access mode switch itself later) */ if ( $keepModePriority > $sslPriority ) { eZDebugSetting::writeDebug( 'kernel-ssl-zone', 'Keeping current access mode...' ); return; } /* Otherwise we look if the view is in the list of SSL views, * and if it is, we switch to SSL. Else, if it's not, we switch to plain HTTP. */ $inSSL = ( $sslPriority > 0 ); eZDebugSetting::writeDebug( 'kernel-ssl-zone', ( isset( $inSSL ) ? ( $inSSL?'yes':'no') : 'dunno' ), 'Should we use SSL for this view?' ); // Change access mode if we need to. eZSSLZone::switchIfNeeded( $inSSL ); }
[ "static", "function", "checkModuleView", "(", "$", "module", ",", "$", "view", ")", "{", "if", "(", "!", "eZSSLZone", "::", "enabled", "(", ")", ")", "return", ";", "$", "ini", "=", "eZINI", "::", "instance", "(", ")", ";", "$", "viewsModes", "=", ...
\static Decide whether we should change access mode for this module view or not. Called from index.php.
[ "\\", "static", "Decide", "whether", "we", "should", "change", "access", "mode", "for", "this", "module", "view", "or", "not", ".", "Called", "from", "index", ".", "php", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsslzone.php#L451-L493
train
ezsystems/ezpublish-legacy
update/common/scripts/5.4/fixremovedezurlobjectlinks.php
ezpUrlObjectLinkRemove.xmlClassAttributeIds
public function xmlClassAttributeIds() { if ( $this->xmlClassAttributeIdArray === null ) { // First we want to find all class attributes which are defined. We won't be touching // attributes which are in a transient state. $xmlTextAttributes = eZContentClassAttribute::fetchList( true, array( 'data_type' => 'ezxmltext', 'version' => 0 ) ); $this->xmlClassAttributeIdArray = array(); foreach ( $xmlTextAttributes as $classAttr ) { $this->xmlClassAttributeIdArray[] = $classAttr->attribute( 'id' ); } unset( $xmlTextAttributes ); } return $this->xmlClassAttributeIdArray; }
php
public function xmlClassAttributeIds() { if ( $this->xmlClassAttributeIdArray === null ) { // First we want to find all class attributes which are defined. We won't be touching // attributes which are in a transient state. $xmlTextAttributes = eZContentClassAttribute::fetchList( true, array( 'data_type' => 'ezxmltext', 'version' => 0 ) ); $this->xmlClassAttributeIdArray = array(); foreach ( $xmlTextAttributes as $classAttr ) { $this->xmlClassAttributeIdArray[] = $classAttr->attribute( 'id' ); } unset( $xmlTextAttributes ); } return $this->xmlClassAttributeIdArray; }
[ "public", "function", "xmlClassAttributeIds", "(", ")", "{", "if", "(", "$", "this", "->", "xmlClassAttributeIdArray", "===", "null", ")", "{", "// First we want to find all class attributes which are defined. We won't be touching", "// attributes which are in a transient state.", ...
Get an array of all defined class attributes with ezxmltext datatype. @return array
[ "Get", "an", "array", "of", "all", "defined", "class", "attributes", "with", "ezxmltext", "datatype", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/update/common/scripts/5.4/fixremovedezurlobjectlinks.php#L121-L138
train
ezsystems/ezpublish-legacy
update/common/scripts/5.4/fixremovedezurlobjectlinks.php
ezpUrlObjectLinkRemove.xmlTextContentObjectAttributeCount
public function xmlTextContentObjectAttributeCount() { if ( $this->xmlAttrCount === null ) { $this->xmlAttrCount = eZContentObjectAttribute::fetchListByClassID( $this->xmlClassAttributeIds(), false, null, false, true ); } return $this->xmlAttrCount; }
php
public function xmlTextContentObjectAttributeCount() { if ( $this->xmlAttrCount === null ) { $this->xmlAttrCount = eZContentObjectAttribute::fetchListByClassID( $this->xmlClassAttributeIds(), false, null, false, true ); } return $this->xmlAttrCount; }
[ "public", "function", "xmlTextContentObjectAttributeCount", "(", ")", "{", "if", "(", "$", "this", "->", "xmlAttrCount", "===", "null", ")", "{", "$", "this", "->", "xmlAttrCount", "=", "eZContentObjectAttribute", "::", "fetchListByClassID", "(", "$", "this", "-...
Retrieve the number of valid ezxmltext occurences @return int
[ "Retrieve", "the", "number", "of", "valid", "ezxmltext", "occurences" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/update/common/scripts/5.4/fixremovedezurlobjectlinks.php#L145-L152
train
ezsystems/ezpublish-legacy
update/common/scripts/5.4/fixremovedezurlobjectlinks.php
ezpUrlObjectLinkRemove.outputString
public function outputString( $message, $label = null, $groupedEntry = false ) { if ( $groupedEntry ) { $this->finalOutputMessageArray[$this->outputEntryNumber]["messages"][] = $message; } else { $this->outputEntryNumber++; $this->finalOutputMessageArray[$this->outputEntryNumber] = array( "messages" => array( $message ), "label" => $label ); } }
php
public function outputString( $message, $label = null, $groupedEntry = false ) { if ( $groupedEntry ) { $this->finalOutputMessageArray[$this->outputEntryNumber]["messages"][] = $message; } else { $this->outputEntryNumber++; $this->finalOutputMessageArray[$this->outputEntryNumber] = array( "messages" => array( $message ), "label" => $label ); } }
[ "public", "function", "outputString", "(", "$", "message", ",", "$", "label", "=", "null", ",", "$", "groupedEntry", "=", "false", ")", "{", "if", "(", "$", "groupedEntry", ")", "{", "$", "this", "->", "finalOutputMessageArray", "[", "$", "this", "->", ...
Add a message to the message buffer, to be displayed after processData has completed. @param string $message @param string $label @param bool $groupedEntry @return void
[ "Add", "a", "message", "to", "the", "message", "buffer", "to", "be", "displayed", "after", "processData", "has", "completed", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/update/common/scripts/5.4/fixremovedezurlobjectlinks.php#L162-L174
train
ezsystems/ezpublish-legacy
update/common/scripts/5.4/fixremovedezurlobjectlinks.php
ezpUrlObjectLinkRemove.processData
public function processData() { while ( $this->processedCount < $this->xmlTextContentObjectAttributeCount() ) { $limit = array( 'offset' => $this->offset, 'length' => $this->fetchLimit ); $xmlAttributeChunk = eZContentObjectAttribute::fetchListByClassID( $this->xmlClassAttributeIds(), false, $limit, true, false ); foreach ( $xmlAttributeChunk as $xmlAttr ) { $result = true; // If the current entry has been logged, we don't increment the running number // so that the entries can be displayed together on output. $currentEntryLogged = false; $currentId = $xmlAttr->attribute( 'id' ); $objectId = $xmlAttr->attribute( 'contentobject_id' ); $version = $xmlAttr->attribute( 'version' ); $languageCode = $xmlAttr->attribute( 'language_code' ); $label = "Attribute [id:{$currentId}] - [Object-id:{$objectId}] - [Version:{$version}] - [Language:{$languageCode}]"; $xmlText = eZXMLTextType::rawXMLText( $xmlAttr ); if ( empty( $xmlText ) ) { if ( $this->verboseLevel > 0 ) { $this->outputString( "Empty XML-data", $label, $currentEntryLogged ); $currentEntryLogged = true; } $result = false; continue; } $dom = new DOMDocument( '1.0', 'utf-8' ); $success = $dom->loadXML( $xmlText ); if ( !$success ) { if ( $this->verboseLevel > 0 ) { $this->outputString( "XML not loaded correctly for attribute", $label, $currentEntryLogged ); $currentEntryLogged = true; } $result = false; continue; } $linkNodes = $dom->getElementsByTagName( 'link' ); $urlIdArray = array(); foreach ( $linkNodes as $link ) { // We are looking for external 'http://'-style links, not the internal // object or node links. if ( $link->hasAttribute( 'url_id' ) ) { $urlIdArray[] = $link->getAttribute( 'url_id' ); } } $urlIdArray = array_unique( $urlIdArray ); if ( count( $urlIdArray ) > 0 ) { if ( $this->verboseLevel > 0 ) { $this->outputString( "Found http-link elements in xml-block", $label, $currentEntryLogged ); $currentEntryLogged = true; } if ( $this->doFix) { $db = eZDB::instance(); $db->begin(); eZSimplifiedXMLInput::updateUrlObjectLinks( $xmlAttr, $urlIdArray ); $db->commit(); } } $this->script->iterate( $this->cli, $result ); $label = null; } $this->processedCount += count( $xmlAttributeChunk ); $this->offset += $this->fetchLimit; unset( $xmlAttributeChunk ); } }
php
public function processData() { while ( $this->processedCount < $this->xmlTextContentObjectAttributeCount() ) { $limit = array( 'offset' => $this->offset, 'length' => $this->fetchLimit ); $xmlAttributeChunk = eZContentObjectAttribute::fetchListByClassID( $this->xmlClassAttributeIds(), false, $limit, true, false ); foreach ( $xmlAttributeChunk as $xmlAttr ) { $result = true; // If the current entry has been logged, we don't increment the running number // so that the entries can be displayed together on output. $currentEntryLogged = false; $currentId = $xmlAttr->attribute( 'id' ); $objectId = $xmlAttr->attribute( 'contentobject_id' ); $version = $xmlAttr->attribute( 'version' ); $languageCode = $xmlAttr->attribute( 'language_code' ); $label = "Attribute [id:{$currentId}] - [Object-id:{$objectId}] - [Version:{$version}] - [Language:{$languageCode}]"; $xmlText = eZXMLTextType::rawXMLText( $xmlAttr ); if ( empty( $xmlText ) ) { if ( $this->verboseLevel > 0 ) { $this->outputString( "Empty XML-data", $label, $currentEntryLogged ); $currentEntryLogged = true; } $result = false; continue; } $dom = new DOMDocument( '1.0', 'utf-8' ); $success = $dom->loadXML( $xmlText ); if ( !$success ) { if ( $this->verboseLevel > 0 ) { $this->outputString( "XML not loaded correctly for attribute", $label, $currentEntryLogged ); $currentEntryLogged = true; } $result = false; continue; } $linkNodes = $dom->getElementsByTagName( 'link' ); $urlIdArray = array(); foreach ( $linkNodes as $link ) { // We are looking for external 'http://'-style links, not the internal // object or node links. if ( $link->hasAttribute( 'url_id' ) ) { $urlIdArray[] = $link->getAttribute( 'url_id' ); } } $urlIdArray = array_unique( $urlIdArray ); if ( count( $urlIdArray ) > 0 ) { if ( $this->verboseLevel > 0 ) { $this->outputString( "Found http-link elements in xml-block", $label, $currentEntryLogged ); $currentEntryLogged = true; } if ( $this->doFix) { $db = eZDB::instance(); $db->begin(); eZSimplifiedXMLInput::updateUrlObjectLinks( $xmlAttr, $urlIdArray ); $db->commit(); } } $this->script->iterate( $this->cli, $result ); $label = null; } $this->processedCount += count( $xmlAttributeChunk ); $this->offset += $this->fetchLimit; unset( $xmlAttributeChunk ); } }
[ "public", "function", "processData", "(", ")", "{", "while", "(", "$", "this", "->", "processedCount", "<", "$", "this", "->", "xmlTextContentObjectAttributeCount", "(", ")", ")", "{", "$", "limit", "=", "array", "(", "'offset'", "=>", "$", "this", "->", ...
Search through valid ezxmltext occurrences, and fix missing url object links if specified. @return void
[ "Search", "through", "valid", "ezxmltext", "occurrences", "and", "fix", "missing", "url", "object", "links", "if", "specified", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/update/common/scripts/5.4/fixremovedezurlobjectlinks.php#L182-L269
train
ezsystems/ezpublish-legacy
update/common/scripts/5.4/fixremovedezurlobjectlinks.php
ezpUrlObjectLinkRemove.showSummary
public function showSummary() { foreach ( $this->finalOutputMessageArray as $messageEntry ) { if ( $messageEntry['label'] !== null ) { $this->cli->output( $this->cli->stylize( 'bold', $messageEntry['label'] ) ); } foreach ( $messageEntry['messages'] as $msg ) { $this->cli->output( $msg); } $this->cli->output(); } }
php
public function showSummary() { foreach ( $this->finalOutputMessageArray as $messageEntry ) { if ( $messageEntry['label'] !== null ) { $this->cli->output( $this->cli->stylize( 'bold', $messageEntry['label'] ) ); } foreach ( $messageEntry['messages'] as $msg ) { $this->cli->output( $msg); } $this->cli->output(); } }
[ "public", "function", "showSummary", "(", ")", "{", "foreach", "(", "$", "this", "->", "finalOutputMessageArray", "as", "$", "messageEntry", ")", "{", "if", "(", "$", "messageEntry", "[", "'label'", "]", "!==", "null", ")", "{", "$", "this", "->", "cli",...
Print a summary of all the messages created during processData. @return void
[ "Print", "a", "summary", "of", "all", "the", "messages", "created", "during", "processData", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/update/common/scripts/5.4/fixremovedezurlobjectlinks.php#L276-L291
train
ezsystems/ezpublish-legacy
kernel/private/api/content/criteria/limit.php
ezpContentLimitCriteria.offset
public function offset( $offset ) { $offset = (int)$offset; if( $offset >= 0 ) $this->offset = $offset; return $this; }
php
public function offset( $offset ) { $offset = (int)$offset; if( $offset >= 0 ) $this->offset = $offset; return $this; }
[ "public", "function", "offset", "(", "$", "offset", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "if", "(", "$", "offset", ">=", "0", ")", "$", "this", "->", "offset", "=", "$", "offset", ";", "return", "$", "this", ";", "...
Sets the offset criteria @param $offset @return ezpContentLimitCriteria Current limit criteria object
[ "Sets", "the", "offset", "criteria" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/criteria/limit.php#L39-L46
train
ezsystems/ezpublish-legacy
kernel/private/api/content/criteria/limit.php
ezpContentLimitCriteria.limit
public function limit( $limit ) { $limit = (int)$limit; if( $limit > 0 ) $this->limit = $limit; return $this; }
php
public function limit( $limit ) { $limit = (int)$limit; if( $limit > 0 ) $this->limit = $limit; return $this; }
[ "public", "function", "limit", "(", "$", "limit", ")", "{", "$", "limit", "=", "(", "int", ")", "$", "limit", ";", "if", "(", "$", "limit", ">", "0", ")", "$", "this", "->", "limit", "=", "$", "limit", ";", "return", "$", "this", ";", "}" ]
Sets the limit criteria @param $limit @return ezpContentLimitCriteria Current limit criteria object
[ "Sets", "the", "limit", "criteria" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/criteria/limit.php#L53-L60
train
ezsystems/ezpublish-legacy
kernel/classes/datatypes/ezxmltext/ezxmltexttype.php
eZXMLTextType.onPublish
function onPublish( $contentObjectAttribute, $object, $publishedNodes ) { $currentVersion = $object->currentVersion(); $langMask = $currentVersion->attribute( 'language_mask' ); // We find all translations present in the current version. We calculate // this from the language mask already present in the fetched version, // so no further round-trip to the DB is required. $languageList = eZContentLanguage::decodeLanguageMask( $langMask, true ); $languageList = $languageList['language_list']; // We want to have the class attribute identifier of the attribute // containing the current ezxmltext, as we then can use the more efficient // eZContentObject->fetchAttributesByIdentifier() to get the data $identifier = $contentObjectAttribute->attribute( 'contentclass_attribute_identifier' ); $attributeArray = $object->fetchAttributesByIdentifier( array( $identifier ), $currentVersion->attribute( 'version' ), $languageList ); foreach ( $attributeArray as $attribute ) { $xmlText = eZXMLTextType::rawXMLText( $attribute ); $dom = new DOMDocument( '1.0', 'utf-8' ); if ( !$dom->loadXML( $xmlText ) ) continue; // urls $urlIdArray = array(); foreach ( $dom->getElementsByTagName( 'link' ) as $link ) { // We are looking for external 'http://'-style links, not the internal // object or node links. if ( $link->hasAttribute( 'url_id' ) ) { $urlIdArray[] = $link->getAttribute( 'url_id' ); } } $urlIdArray = array_unique( $urlIdArray ); $db = eZDB::instance(); $db->begin(); eZSimplifiedXMLInput::updateUrlObjectLinks( $attribute, $urlIdArray ); $db->commit(); // linked objects $linkedObjectIdArray = $this->getRelatedObjectList( $dom->getElementsByTagName( 'link' ) ); // embedded objects $embeddedObjectIdArray = array_merge( $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed' ) ), $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed-inline' ) ) ); if ( !empty( $embeddedObjectIdArray ) ) { $object->appendInputRelationList( $embeddedObjectIdArray, eZContentObject::RELATION_EMBED ); } if ( !empty( $linkedObjectIdArray ) ) { $object->appendInputRelationList( $linkedObjectIdArray, eZContentObject::RELATION_LINK ); } if ( !empty( $linkedObjectIdArray ) || !empty( $embeddedObjectIdArray ) ) { $object->commitInputRelations( $currentVersion->attribute( 'version' ) ); } } }
php
function onPublish( $contentObjectAttribute, $object, $publishedNodes ) { $currentVersion = $object->currentVersion(); $langMask = $currentVersion->attribute( 'language_mask' ); // We find all translations present in the current version. We calculate // this from the language mask already present in the fetched version, // so no further round-trip to the DB is required. $languageList = eZContentLanguage::decodeLanguageMask( $langMask, true ); $languageList = $languageList['language_list']; // We want to have the class attribute identifier of the attribute // containing the current ezxmltext, as we then can use the more efficient // eZContentObject->fetchAttributesByIdentifier() to get the data $identifier = $contentObjectAttribute->attribute( 'contentclass_attribute_identifier' ); $attributeArray = $object->fetchAttributesByIdentifier( array( $identifier ), $currentVersion->attribute( 'version' ), $languageList ); foreach ( $attributeArray as $attribute ) { $xmlText = eZXMLTextType::rawXMLText( $attribute ); $dom = new DOMDocument( '1.0', 'utf-8' ); if ( !$dom->loadXML( $xmlText ) ) continue; // urls $urlIdArray = array(); foreach ( $dom->getElementsByTagName( 'link' ) as $link ) { // We are looking for external 'http://'-style links, not the internal // object or node links. if ( $link->hasAttribute( 'url_id' ) ) { $urlIdArray[] = $link->getAttribute( 'url_id' ); } } $urlIdArray = array_unique( $urlIdArray ); $db = eZDB::instance(); $db->begin(); eZSimplifiedXMLInput::updateUrlObjectLinks( $attribute, $urlIdArray ); $db->commit(); // linked objects $linkedObjectIdArray = $this->getRelatedObjectList( $dom->getElementsByTagName( 'link' ) ); // embedded objects $embeddedObjectIdArray = array_merge( $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed' ) ), $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed-inline' ) ) ); if ( !empty( $embeddedObjectIdArray ) ) { $object->appendInputRelationList( $embeddedObjectIdArray, eZContentObject::RELATION_EMBED ); } if ( !empty( $linkedObjectIdArray ) ) { $object->appendInputRelationList( $linkedObjectIdArray, eZContentObject::RELATION_LINK ); } if ( !empty( $linkedObjectIdArray ) || !empty( $embeddedObjectIdArray ) ) { $object->commitInputRelations( $currentVersion->attribute( 'version' ) ); } } }
[ "function", "onPublish", "(", "$", "contentObjectAttribute", ",", "$", "object", ",", "$", "publishedNodes", ")", "{", "$", "currentVersion", "=", "$", "object", "->", "currentVersion", "(", ")", ";", "$", "langMask", "=", "$", "currentVersion", "->", "attri...
Method triggered on publish for xml text datatype This method makes sure that links from all translations of an xml text are registered in the ezurl_object_link table, and thus retained, if previous versions of an object are removed. It also checks for embedded objects in other languages xml, and makes sure the matching object relations are stored for the publish version. @param eZContentObjectAttribute $contentObjectAttribute @param eZContentObject $object @param array $publishedNodes @return boolean
[ "Method", "triggered", "on", "publish", "for", "xml", "text", "datatype" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezxmltext/ezxmltexttype.php#L149-L219
train
ezsystems/ezpublish-legacy
kernel/content/ezcontentpublishingbehaviour.php
ezpContentPublishingBehaviour.getBehaviour
public static function getBehaviour() { if ( self::$behaviour === null ) { $return = new ezpContentPublishingBehaviour; } else { $return = clone self::$behaviour; if ( self::$behaviour->isTemporary ) { self::$behaviour = null; } } return $return; }
php
public static function getBehaviour() { if ( self::$behaviour === null ) { $return = new ezpContentPublishingBehaviour; } else { $return = clone self::$behaviour; if ( self::$behaviour->isTemporary ) { self::$behaviour = null; } } return $return; }
[ "public", "static", "function", "getBehaviour", "(", ")", "{", "if", "(", "self", "::", "$", "behaviour", "===", "null", ")", "{", "$", "return", "=", "new", "ezpContentPublishingBehaviour", ";", "}", "else", "{", "$", "return", "=", "clone", "self", "::...
Get the currently set behaviour. Returns the default one if one ain't set @return ezpContentPublishingBehaviour
[ "Get", "the", "currently", "set", "behaviour", ".", "Returns", "the", "default", "one", "if", "one", "ain", "t", "set" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentpublishingbehaviour.php#L58-L73
train
ezsystems/ezpublish-legacy
kernel/classes/vathandlers/ezdefaultvathandler.php
eZDefaultVATHandler.getProductCategory
function getProductCategory( $object ) { $ini = eZINI::instance( 'shop.ini' ); if ( !$ini->hasVariable( 'VATSettings', 'ProductCategoryAttribute' ) ) { eZDebug::writeError( "Cannot find product category: please specify its attribute identifier " . "in the following setting: shop.ini.[VATSettings].ProductCategoryAttribute" ); return null; } $categoryAttributeName = $ini->variable( 'VATSettings', 'ProductCategoryAttribute' ); if ( !$categoryAttributeName ) { eZDebug::writeError( "Cannot find product category: empty attribute name specified " . "in the following setting: shop.ini.[VATSettings].ProductCategoryAttribute" ); return null; } $productDataMap = $object->attribute( 'data_map' ); if ( !isset( $productDataMap[$categoryAttributeName] ) ) { eZDebug::writeError( "Cannot find product category: there is no attribute '$categoryAttributeName' in object '" . $object->attribute( 'name' ) . "' of class '" . $object->attribute( 'class_name' ) . "'." ); return null; } $categoryAttribute = $productDataMap[$categoryAttributeName]; $productCategory = $categoryAttribute->attribute( 'content' ); if ( $productCategory === null ) { eZDebug::writeNotice( "Product category is not specified in object '" . $object->attribute( 'name' ) . "' of class '" . $object->attribute( 'class_name' ) . "'." ); return null; } return $productCategory; }
php
function getProductCategory( $object ) { $ini = eZINI::instance( 'shop.ini' ); if ( !$ini->hasVariable( 'VATSettings', 'ProductCategoryAttribute' ) ) { eZDebug::writeError( "Cannot find product category: please specify its attribute identifier " . "in the following setting: shop.ini.[VATSettings].ProductCategoryAttribute" ); return null; } $categoryAttributeName = $ini->variable( 'VATSettings', 'ProductCategoryAttribute' ); if ( !$categoryAttributeName ) { eZDebug::writeError( "Cannot find product category: empty attribute name specified " . "in the following setting: shop.ini.[VATSettings].ProductCategoryAttribute" ); return null; } $productDataMap = $object->attribute( 'data_map' ); if ( !isset( $productDataMap[$categoryAttributeName] ) ) { eZDebug::writeError( "Cannot find product category: there is no attribute '$categoryAttributeName' in object '" . $object->attribute( 'name' ) . "' of class '" . $object->attribute( 'class_name' ) . "'." ); return null; } $categoryAttribute = $productDataMap[$categoryAttributeName]; $productCategory = $categoryAttribute->attribute( 'content' ); if ( $productCategory === null ) { eZDebug::writeNotice( "Product category is not specified in object '" . $object->attribute( 'name' ) . "' of class '" . $object->attribute( 'class_name' ) . "'." ); return null; } return $productCategory; }
[ "function", "getProductCategory", "(", "$", "object", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", "'shop.ini'", ")", ";", "if", "(", "!", "$", "ini", "->", "hasVariable", "(", "'VATSettings'", ",", "'ProductCategoryAttribute'", ")", ")", "{"...
Determine object's product category. \private \static
[ "Determine", "object", "s", "product", "category", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/vathandlers/ezdefaultvathandler.php#L58-L102
train
ezsystems/ezpublish-legacy
kernel/classes/vathandlers/ezdefaultvathandler.php
eZDefaultVATHandler.chooseVatType
function chooseVatType( $productCategory, $country ) { $vatRules = eZVatRule::fetchList(); $catID = $productCategory->attribute( 'id' ); $vatPriorities = array(); foreach ( $vatRules as $rule ) { $ruleCountry = $rule->attribute( 'country_code' ); $ruleCatIDs = $rule->attribute( 'product_categories_ids' ); $ruleVatID = $rule->attribute( 'vat_type' ); $categoryMatch = 0; $countryMatch = 0; if ( $ruleCountry == '*' ) $countryMatch = 1; elseif ( $ruleCountry == $country ) $countryMatch = 2; if ( !$ruleCatIDs ) $categoryMatch = 1; elseif ( in_array( $catID, $ruleCatIDs ) ) $categoryMatch = 2; if ( $countryMatch && $categoryMatch ) $vatPriority = $countryMatch * 2 + $categoryMatch - 2; else $vatPriority = 0; if ( !isset( $vatPriorities[$vatPriority] ) ) $vatPriorities[$vatPriority] = $ruleVatID; } krsort( $vatPriorities, SORT_NUMERIC ); $bestPriority = 0; if ( $vatPriorities ) { $tmpKeys = array_keys( $vatPriorities ); $bestPriority = array_shift( $tmpKeys ); } if ( $bestPriority == 0 ) { eZDebug::writeError( "Cannot find a suitable VAT type " . "for country '" . $country . "'" . " and category '" . $productCategory->attribute( 'name' ). "'." ); return new eZVatType( array( "id" => 0, "name" => ezpI18n::tr( 'kernel/shop', 'None' ), "percentage" => 0.0 ) ); } $bestVatTypeID = array_shift( $vatPriorities ); $bestVatType = eZVatType::fetch( $bestVatTypeID ); eZDebug::writeDebug( sprintf( "Best matching VAT for '%s'/'%s' is '%s' (%d%%)", $country, $productCategory->attribute( 'name' ), $bestVatType->attribute( 'name' ), $bestVatType->attribute( 'percentage' ) ) ); return $bestVatType; }
php
function chooseVatType( $productCategory, $country ) { $vatRules = eZVatRule::fetchList(); $catID = $productCategory->attribute( 'id' ); $vatPriorities = array(); foreach ( $vatRules as $rule ) { $ruleCountry = $rule->attribute( 'country_code' ); $ruleCatIDs = $rule->attribute( 'product_categories_ids' ); $ruleVatID = $rule->attribute( 'vat_type' ); $categoryMatch = 0; $countryMatch = 0; if ( $ruleCountry == '*' ) $countryMatch = 1; elseif ( $ruleCountry == $country ) $countryMatch = 2; if ( !$ruleCatIDs ) $categoryMatch = 1; elseif ( in_array( $catID, $ruleCatIDs ) ) $categoryMatch = 2; if ( $countryMatch && $categoryMatch ) $vatPriority = $countryMatch * 2 + $categoryMatch - 2; else $vatPriority = 0; if ( !isset( $vatPriorities[$vatPriority] ) ) $vatPriorities[$vatPriority] = $ruleVatID; } krsort( $vatPriorities, SORT_NUMERIC ); $bestPriority = 0; if ( $vatPriorities ) { $tmpKeys = array_keys( $vatPriorities ); $bestPriority = array_shift( $tmpKeys ); } if ( $bestPriority == 0 ) { eZDebug::writeError( "Cannot find a suitable VAT type " . "for country '" . $country . "'" . " and category '" . $productCategory->attribute( 'name' ). "'." ); return new eZVatType( array( "id" => 0, "name" => ezpI18n::tr( 'kernel/shop', 'None' ), "percentage" => 0.0 ) ); } $bestVatTypeID = array_shift( $vatPriorities ); $bestVatType = eZVatType::fetch( $bestVatTypeID ); eZDebug::writeDebug( sprintf( "Best matching VAT for '%s'/'%s' is '%s' (%d%%)", $country, $productCategory->attribute( 'name' ), $bestVatType->attribute( 'name' ), $bestVatType->attribute( 'percentage' ) ) ); return $bestVatType; }
[ "function", "chooseVatType", "(", "$", "productCategory", ",", "$", "country", ")", "{", "$", "vatRules", "=", "eZVatRule", "::", "fetchList", "(", ")", ";", "$", "catID", "=", "$", "productCategory", "->", "attribute", "(", "'id'", ")", ";", "$", "vatPr...
Choose the best matching VAT type for given product category and country. We calculate priority for each VAT type and then choose the VAT type having the highest priority (or first of those having the highest priority). VAT type priority is calculated from county match and category match as following: CountryMatch = 0 CategoryMatch = 1 if ( there is exact match on country ) CountryMatch = 2 elseif ( there is weak match on country ) CountryMatch = 1 if ( there is exact match on product category ) CategoryMatch = 2 elseif ( there is weak match on product category ) CategoryMatch = 1 if ( there is match on both country and category ) VatTypePriority = CountryMatch * 2 + CategoryMatch - 2 else VatTypePriority = 0 \private \static
[ "Choose", "the", "best", "matching", "VAT", "type", "for", "given", "product", "category", "and", "country", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/vathandlers/ezdefaultvathandler.php#L134-L201
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/interfaces/route_filter.php
ezpRestRouteFilterInterface.getRouteFilter
public static function getRouteFilter() { $opt = new ezpExtensionOptions(); $opt->iniFile = 'rest.ini'; $opt->iniSection = 'RouteSettings'; $opt->iniVariable = 'RouteSettingImpl'; $routeSecurityFilterInstance = eZExtension::getHandlerClass( $opt ); if ( ! $routeSecurityFilterInstance instanceof self ) { throw new ezpRestRouteSecurityFilterNotFoundException(); } return $routeSecurityFilterInstance; }
php
public static function getRouteFilter() { $opt = new ezpExtensionOptions(); $opt->iniFile = 'rest.ini'; $opt->iniSection = 'RouteSettings'; $opt->iniVariable = 'RouteSettingImpl'; $routeSecurityFilterInstance = eZExtension::getHandlerClass( $opt ); if ( ! $routeSecurityFilterInstance instanceof self ) { throw new ezpRestRouteSecurityFilterNotFoundException(); } return $routeSecurityFilterInstance; }
[ "public", "static", "function", "getRouteFilter", "(", ")", "{", "$", "opt", "=", "new", "ezpExtensionOptions", "(", ")", ";", "$", "opt", "->", "iniFile", "=", "'rest.ini'", ";", "$", "opt", "->", "iniSection", "=", "'RouteSettings'", ";", "$", "opt", "...
Returns the currently configured class for handling Route security. @static @throws ezpRestRouteSecurityFilterNotFoundException @return ezpRestRouteFilterInterface
[ "Returns", "the", "currently", "configured", "class", "for", "handling", "Route", "security", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/interfaces/route_filter.php#L27-L42
train
ezsystems/ezpublish-legacy
kernel/setup/steps/ezstep_site_types.php
eZStepSiteTypes.downloadFile
function downloadFile( $url, $outDir, $forcedFileName = false ) { $fileName = $outDir . "/" . ( $forcedFileName ? $forcedFileName : basename( $url ) ); eZDebug::writeNotice( "Downloading file '$fileName' from $url" ); // Create the out directory if not exists. if ( !file_exists( $outDir ) ) eZDir::mkdir( $outDir, false, true ); // First try CURL if ( extension_loaded( 'curl' ) ) { $ch = curl_init( $url ); $fp = eZStepSiteTypes::fopen( $fileName, 'wb' ); if ( $fp === false ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Cannot write to file' ) . ': ' . $this->FileOpenErrorMsg; return false; } curl_setopt( $ch, CURLOPT_FILE, $fp ); curl_setopt( $ch, CURLOPT_HEADER, 0 ); curl_setopt( $ch, CURLOPT_FAILONERROR, 1 ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); // Get proxy $ini = eZINI::instance(); $proxy = $ini->hasVariable( 'ProxySettings', 'ProxyServer' ) ? $ini->variable( 'ProxySettings', 'ProxyServer' ) : false; if ( $proxy ) { curl_setopt ( $ch, CURLOPT_PROXY , $proxy ); $userName = $ini->hasVariable( 'ProxySettings', 'User' ) ? $ini->variable( 'ProxySettings', 'User' ) : false; $password = $ini->hasVariable( 'ProxySettings', 'Password' ) ? $ini->variable( 'ProxySettings', 'Password' ) : false; if ( $userName ) { curl_setopt ( $ch, CURLOPT_PROXYUSERPWD, "$userName:$password" ); } } if ( !curl_exec( $ch ) ) { $this->ErrorMsg = curl_error( $ch ); return false; } curl_close( $ch ); fclose( $fp ); } else { $parsedUrl = parse_url( $url ); $checkIP = isset( $parsedUrl[ 'host' ] ) ? ip2long( gethostbyname( $parsedUrl[ 'host' ] ) ) : false; if ( $checkIP === false ) { return false; } // If we don't have CURL installed we used standard fopen urlwrappers // Note: Could be blocked by not allowing remote calls. if ( !copy( $url, $fileName ) ) { $buf = eZHTTPTool::sendHTTPRequest( $url, 80, false, 'eZ Publish', false ); $header = false; $body = false; if ( eZHTTPTool::parseHTTPResponse( $buf, $header, $body ) ) { eZFile::create( $fileName, false, $body ); } else { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Failed to copy %url to local file %filename', null, array( "%url" => $url, "%filename" => $fileName ) ); return false; } } } return $fileName; }
php
function downloadFile( $url, $outDir, $forcedFileName = false ) { $fileName = $outDir . "/" . ( $forcedFileName ? $forcedFileName : basename( $url ) ); eZDebug::writeNotice( "Downloading file '$fileName' from $url" ); // Create the out directory if not exists. if ( !file_exists( $outDir ) ) eZDir::mkdir( $outDir, false, true ); // First try CURL if ( extension_loaded( 'curl' ) ) { $ch = curl_init( $url ); $fp = eZStepSiteTypes::fopen( $fileName, 'wb' ); if ( $fp === false ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Cannot write to file' ) . ': ' . $this->FileOpenErrorMsg; return false; } curl_setopt( $ch, CURLOPT_FILE, $fp ); curl_setopt( $ch, CURLOPT_HEADER, 0 ); curl_setopt( $ch, CURLOPT_FAILONERROR, 1 ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); // Get proxy $ini = eZINI::instance(); $proxy = $ini->hasVariable( 'ProxySettings', 'ProxyServer' ) ? $ini->variable( 'ProxySettings', 'ProxyServer' ) : false; if ( $proxy ) { curl_setopt ( $ch, CURLOPT_PROXY , $proxy ); $userName = $ini->hasVariable( 'ProxySettings', 'User' ) ? $ini->variable( 'ProxySettings', 'User' ) : false; $password = $ini->hasVariable( 'ProxySettings', 'Password' ) ? $ini->variable( 'ProxySettings', 'Password' ) : false; if ( $userName ) { curl_setopt ( $ch, CURLOPT_PROXYUSERPWD, "$userName:$password" ); } } if ( !curl_exec( $ch ) ) { $this->ErrorMsg = curl_error( $ch ); return false; } curl_close( $ch ); fclose( $fp ); } else { $parsedUrl = parse_url( $url ); $checkIP = isset( $parsedUrl[ 'host' ] ) ? ip2long( gethostbyname( $parsedUrl[ 'host' ] ) ) : false; if ( $checkIP === false ) { return false; } // If we don't have CURL installed we used standard fopen urlwrappers // Note: Could be blocked by not allowing remote calls. if ( !copy( $url, $fileName ) ) { $buf = eZHTTPTool::sendHTTPRequest( $url, 80, false, 'eZ Publish', false ); $header = false; $body = false; if ( eZHTTPTool::parseHTTPResponse( $buf, $header, $body ) ) { eZFile::create( $fileName, false, $body ); } else { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Failed to copy %url to local file %filename', null, array( "%url" => $url, "%filename" => $fileName ) ); return false; } } } return $fileName; }
[ "function", "downloadFile", "(", "$", "url", ",", "$", "outDir", ",", "$", "forcedFileName", "=", "false", ")", "{", "$", "fileName", "=", "$", "outDir", ".", "\"/\"", ".", "(", "$", "forcedFileName", "?", "$", "forcedFileName", ":", "basename", "(", "...
Downloads file. Sets $this->ErrorMsg in case of an error. \private \param $url URL. \param $outDir Directory where to put downloaded file to. \param $forcedFileName Force saving downloaded file under this name. \return false on error, path to downloaded package otherwise.
[ "Downloads", "file", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/setup/steps/ezstep_site_types.php#L61-L143
train
ezsystems/ezpublish-legacy
kernel/setup/steps/ezstep_site_types.php
eZStepSiteTypes.downloadAndImportPackage
function downloadAndImportPackage( $packageName, $packageUrl, $forceDownload = false ) { $package = eZPackage::fetch( $packageName, false, false, false ); if ( is_object( $package ) ) { if ( $forceDownload ) { $package->remove(); } else { eZDebug::writeNotice( "Skipping download of package '$packageName': package already exists." ); return $package; } } $archiveName = $this->downloadFile( $packageUrl, /* $outDir = */ eZStepSiteTypes::tempDir() ); if ( $archiveName === false ) { eZDebug::writeWarning( "Download of package '$packageName' from '$packageUrl' failed: $this->ErrorMsg" ); $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Download of package \'%pkg\' failed. You may upload the package manually.', false, array( '%pkg' => $packageName ) ); return false; } $package = eZPackage::import( $archiveName, $packageName, false ); // Remove downloaded ezpkg file $ezFileHandler = new eZFileHandler(); $ezFileHandler->unlink( $archiveName ); if ( !$package instanceof eZPackage ) { if ( $package == eZPackage::STATUS_INVALID_NAME ) { eZDebug::writeNotice( "The package name $packageName is invalid" ); } else { eZDebug::writeNotice( "Invalid package" ); } $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Invalid package' ); return false; } return $package; }
php
function downloadAndImportPackage( $packageName, $packageUrl, $forceDownload = false ) { $package = eZPackage::fetch( $packageName, false, false, false ); if ( is_object( $package ) ) { if ( $forceDownload ) { $package->remove(); } else { eZDebug::writeNotice( "Skipping download of package '$packageName': package already exists." ); return $package; } } $archiveName = $this->downloadFile( $packageUrl, /* $outDir = */ eZStepSiteTypes::tempDir() ); if ( $archiveName === false ) { eZDebug::writeWarning( "Download of package '$packageName' from '$packageUrl' failed: $this->ErrorMsg" ); $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Download of package \'%pkg\' failed. You may upload the package manually.', false, array( '%pkg' => $packageName ) ); return false; } $package = eZPackage::import( $archiveName, $packageName, false ); // Remove downloaded ezpkg file $ezFileHandler = new eZFileHandler(); $ezFileHandler->unlink( $archiveName ); if ( !$package instanceof eZPackage ) { if ( $package == eZPackage::STATUS_INVALID_NAME ) { eZDebug::writeNotice( "The package name $packageName is invalid" ); } else { eZDebug::writeNotice( "Invalid package" ); } $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Invalid package' ); return false; } return $package; }
[ "function", "downloadAndImportPackage", "(", "$", "packageName", ",", "$", "packageUrl", ",", "$", "forceDownload", "=", "false", ")", "{", "$", "package", "=", "eZPackage", "::", "fetch", "(", "$", "packageName", ",", "false", ",", "false", ",", "false", ...
Downloads and imports package. Sets $this->ErrorMsg in case of an error. \param $forceDownload download even if this package already exists. \private \return false on error, package object otherwise.
[ "Downloads", "and", "imports", "package", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/setup/steps/ezstep_site_types.php#L154-L204
train
ezsystems/ezpublish-legacy
kernel/setup/steps/ezstep_site_types.php
eZStepSiteTypes.uploadPackage
function uploadPackage() { if ( !eZHTTPFile::canFetch( 'PackageBinaryFile' ) ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'No package selected for upload' ) . '.'; return; } $file = eZHTTPFile::fetch( 'PackageBinaryFile' ); if ( !$file ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Failed fetching upload package file' ); return; } $packageFilename = $file->attribute( 'filename' ); $packageName = $file->attribute( 'original_filename' ); if ( preg_match( "#^(.+)-[0-9](\.[0-9]+)-[0-9].ezpkg$#", $packageName, $matches ) ) $packageName = $matches[1]; $packageName = preg_replace( array( "#[^a-zA-Z0-9]+#", "#_+#", "#(^_)|(_$)#" ), array( '_', '_', '' ), $packageName ); $package = eZPackage::import( $packageFilename, $packageName, false ); if ( is_object( $package ) ) { // package successfully imported return; } elseif ( $package == eZPackage::STATUS_ALREADY_EXISTS ) { eZDebug::writeWarning( "Package '$packageName' already exists." ); } else { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Uploaded file is not an eZ Publish package' ); } }
php
function uploadPackage() { if ( !eZHTTPFile::canFetch( 'PackageBinaryFile' ) ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'No package selected for upload' ) . '.'; return; } $file = eZHTTPFile::fetch( 'PackageBinaryFile' ); if ( !$file ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Failed fetching upload package file' ); return; } $packageFilename = $file->attribute( 'filename' ); $packageName = $file->attribute( 'original_filename' ); if ( preg_match( "#^(.+)-[0-9](\.[0-9]+)-[0-9].ezpkg$#", $packageName, $matches ) ) $packageName = $matches[1]; $packageName = preg_replace( array( "#[^a-zA-Z0-9]+#", "#_+#", "#(^_)|(_$)#" ), array( '_', '_', '' ), $packageName ); $package = eZPackage::import( $packageFilename, $packageName, false ); if ( is_object( $package ) ) { // package successfully imported return; } elseif ( $package == eZPackage::STATUS_ALREADY_EXISTS ) { eZDebug::writeWarning( "Package '$packageName' already exists." ); } else { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Uploaded file is not an eZ Publish package' ); } }
[ "function", "uploadPackage", "(", ")", "{", "if", "(", "!", "eZHTTPFile", "::", "canFetch", "(", "'PackageBinaryFile'", ")", ")", "{", "$", "this", "->", "ErrorMsg", "=", "ezpI18n", "::", "tr", "(", "'design/standard/setup/init'", ",", "'No package selected for ...
Upload local package. \private
[ "Upload", "local", "package", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/setup/steps/ezstep_site_types.php#L291-L335
train
ezsystems/ezpublish-legacy
kernel/setup/steps/ezstep_site_types.php
eZStepSiteTypes.processPostData
function processPostData() { if ( $this->Http->hasPostVariable( 'UploadPackageButton' ) ) { $this->uploadPackage(); return false; // force displaying the same step. } if ( !$this->Http->hasPostVariable( 'eZSetup_site_type' ) ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'No site package chosen.' ); return false; } $sitePackageInfo = $this->Http->postVariable( 'eZSetup_site_type' ); $downloaded = false; // true - if $sitePackageName package has been downloaded. if ( preg_match( '/^(\w+)\|(.+)$/', $sitePackageInfo, $matches ) ) { // remote site package chosen: download it. $sitePackageName = $matches[1]; $sitePackageURL = $matches[2]; // we already know that we should download the package anyway as it has newer version // so use force download mode $package = $this->downloadAndImportPackage( $sitePackageName, $sitePackageURL, true ); if ( is_object( $package ) ) { $downloaded = true; $this->Message = ezpI18n::tr( 'design/standard/setup/init', 'Package \'%packageName\' and it\'s dependencies have been downloaded successfully. Press \'Next\' to continue.', false, array( '%packageName' => $sitePackageName ) ); } } else { // local (already imported) site package chosen: just fetch it. $sitePackageName = $sitePackageInfo; $package = eZPackage::fetch( $sitePackageName, false, false, false ); $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Invalid package' ) . '.'; } // Verify package. if ( !is_object( $package ) || !$this->selectSiteType( $sitePackageName ) ) return false; // Download packages that the site package requires. $downloadDependandPackagesResult = $this->downloadDependantPackages( $package ); return $downloadDependandPackagesResult == false ? false : !$downloaded; }
php
function processPostData() { if ( $this->Http->hasPostVariable( 'UploadPackageButton' ) ) { $this->uploadPackage(); return false; // force displaying the same step. } if ( !$this->Http->hasPostVariable( 'eZSetup_site_type' ) ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'No site package chosen.' ); return false; } $sitePackageInfo = $this->Http->postVariable( 'eZSetup_site_type' ); $downloaded = false; // true - if $sitePackageName package has been downloaded. if ( preg_match( '/^(\w+)\|(.+)$/', $sitePackageInfo, $matches ) ) { // remote site package chosen: download it. $sitePackageName = $matches[1]; $sitePackageURL = $matches[2]; // we already know that we should download the package anyway as it has newer version // so use force download mode $package = $this->downloadAndImportPackage( $sitePackageName, $sitePackageURL, true ); if ( is_object( $package ) ) { $downloaded = true; $this->Message = ezpI18n::tr( 'design/standard/setup/init', 'Package \'%packageName\' and it\'s dependencies have been downloaded successfully. Press \'Next\' to continue.', false, array( '%packageName' => $sitePackageName ) ); } } else { // local (already imported) site package chosen: just fetch it. $sitePackageName = $sitePackageInfo; $package = eZPackage::fetch( $sitePackageName, false, false, false ); $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Invalid package' ) . '.'; } // Verify package. if ( !is_object( $package ) || !$this->selectSiteType( $sitePackageName ) ) return false; // Download packages that the site package requires. $downloadDependandPackagesResult = $this->downloadDependantPackages( $package ); return $downloadDependandPackagesResult == false ? false : !$downloaded; }
[ "function", "processPostData", "(", ")", "{", "if", "(", "$", "this", "->", "Http", "->", "hasPostVariable", "(", "'UploadPackageButton'", ")", ")", "{", "$", "this", "->", "uploadPackage", "(", ")", ";", "return", "false", ";", "// force displaying the same s...
Process POST data. \reimp
[ "Process", "POST", "data", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/setup/steps/ezstep_site_types.php#L342-L390
train
ezsystems/ezpublish-legacy
kernel/setup/steps/ezstep_site_types.php
eZStepSiteTypes.fetchAvailablePackages
function fetchAvailablePackages( $type = false ) { $typeArray = array(); if ( $type ) $typeArray['type'] = $type; $packageList = eZPackage::fetchPackages( array( 'db_available' => false ), $typeArray ); return $packageList; }
php
function fetchAvailablePackages( $type = false ) { $typeArray = array(); if ( $type ) $typeArray['type'] = $type; $packageList = eZPackage::fetchPackages( array( 'db_available' => false ), $typeArray ); return $packageList; }
[ "function", "fetchAvailablePackages", "(", "$", "type", "=", "false", ")", "{", "$", "typeArray", "=", "array", "(", ")", ";", "if", "(", "$", "type", ")", "$", "typeArray", "[", "'type'", "]", "=", "$", "type", ";", "$", "packageList", "=", "eZPacka...
Fetches list of packages already available locally. \private
[ "Fetches", "list", "of", "packages", "already", "available", "locally", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/setup/steps/ezstep_site_types.php#L619-L628
train
ezsystems/ezpublish-legacy
kernel/setup/steps/ezstep_site_types.php
eZStepSiteTypes.retrieveRemotePackagesList
function retrieveRemotePackagesList( $onlySitePackages = false ) { // Download index file. $idxFileName = $this->downloadFile( $this->XMLIndexURL, /* $outDir = */ eZStepSiteTypes::tempDir(), 'index.xml' ); if ( $idxFileName === false ) { // Searching for a local index.xml file to use for offline installation $destIndexPath = eZStepSiteTypes::tempDir() . DIRECTORY_SEPARATOR . 'index.xml'; $repo = eZPackage::systemRepositoryInformation(); if ( $repo ) { $sourceIndexPath = $repo['path'] . DIRECTORY_SEPARATOR . 'index.xml'; if ( file_exists( $sourceIndexPath ) ) { eZFileHandler::copy( $sourceIndexPath, $destIndexPath ); $idxFileName = $destIndexPath; // Removing error message from downloadFile $this->ErrorMsg = false; } } } if ( $idxFileName === false ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.' ); eZDebug::writeNotice( "Cannot download remote packages index file from '$this->XMLIndexURL'." ); return false; } // Parse it. $dom = new DOMDocument( '1.0', 'utf-8' ); $dom->preserveWhiteSpace = false; $success = $dom->load( realpath( $idxFileName ) ); @unlink( $idxFileName ); if ( !$success ) { eZDebug::writeError( "Unable to open index file." ); return false; } $root = $dom->documentElement; if ( $root->localName != 'packages' ) { eZDebug::writeError( "Malformed index file." ); return false; } $packageList = array(); foreach ( $root->childNodes as $packageNode ) { if ( $packageNode->localName != 'package' ) // skip unwanted chilren continue; if ( $onlySitePackages && $packageNode->getAttribute( 'type' ) != 'site' ) // skip non-site packages continue; $packageAttributes = array(); foreach ( $packageNode->attributes as $attributeNode ) { $packageAttributes[$attributeNode->localName] = $attributeNode->value; } $packageList[$packageAttributes['name']] = $packageAttributes; } return $packageList; }
php
function retrieveRemotePackagesList( $onlySitePackages = false ) { // Download index file. $idxFileName = $this->downloadFile( $this->XMLIndexURL, /* $outDir = */ eZStepSiteTypes::tempDir(), 'index.xml' ); if ( $idxFileName === false ) { // Searching for a local index.xml file to use for offline installation $destIndexPath = eZStepSiteTypes::tempDir() . DIRECTORY_SEPARATOR . 'index.xml'; $repo = eZPackage::systemRepositoryInformation(); if ( $repo ) { $sourceIndexPath = $repo['path'] . DIRECTORY_SEPARATOR . 'index.xml'; if ( file_exists( $sourceIndexPath ) ) { eZFileHandler::copy( $sourceIndexPath, $destIndexPath ); $idxFileName = $destIndexPath; // Removing error message from downloadFile $this->ErrorMsg = false; } } } if ( $idxFileName === false ) { $this->ErrorMsg = ezpI18n::tr( 'design/standard/setup/init', 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.' ); eZDebug::writeNotice( "Cannot download remote packages index file from '$this->XMLIndexURL'." ); return false; } // Parse it. $dom = new DOMDocument( '1.0', 'utf-8' ); $dom->preserveWhiteSpace = false; $success = $dom->load( realpath( $idxFileName ) ); @unlink( $idxFileName ); if ( !$success ) { eZDebug::writeError( "Unable to open index file." ); return false; } $root = $dom->documentElement; if ( $root->localName != 'packages' ) { eZDebug::writeError( "Malformed index file." ); return false; } $packageList = array(); foreach ( $root->childNodes as $packageNode ) { if ( $packageNode->localName != 'package' ) // skip unwanted chilren continue; if ( $onlySitePackages && $packageNode->getAttribute( 'type' ) != 'site' ) // skip non-site packages continue; $packageAttributes = array(); foreach ( $packageNode->attributes as $attributeNode ) { $packageAttributes[$attributeNode->localName] = $attributeNode->value; } $packageList[$packageAttributes['name']] = $packageAttributes; } return $packageList; }
[ "function", "retrieveRemotePackagesList", "(", "$", "onlySitePackages", "=", "false", ")", "{", "// Download index file.", "$", "idxFileName", "=", "$", "this", "->", "downloadFile", "(", "$", "this", "->", "XMLIndexURL", ",", "/* $outDir = */", "eZStepSiteTypes", "...
Retrieve list of packages available to download. Example of return value: array( 'packages' => array( '<package_name1>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... ), '<package_name2>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... ) ) );
[ "Retrieve", "list", "of", "packages", "available", "to", "download", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/setup/steps/ezstep_site_types.php#L643-L714
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/models/ezprest_token.php
ezpRestToken.generateToken
public static function generateToken( $vary ) { mt_srand( base_convert( substr( md5( $vary ), 0, 6 ), 36, 10 ) * microtime( true ) ); $a = base_convert( mt_rand(), 10, 36 ); $b = base_convert( mt_rand(), 10, 36 ); $token = substr( $b . $a, 1, 8 ); $tokenHash = sha1( $token ); return $tokenHash; }
php
public static function generateToken( $vary ) { mt_srand( base_convert( substr( md5( $vary ), 0, 6 ), 36, 10 ) * microtime( true ) ); $a = base_convert( mt_rand(), 10, 36 ); $b = base_convert( mt_rand(), 10, 36 ); $token = substr( $b . $a, 1, 8 ); $tokenHash = sha1( $token ); return $tokenHash; }
[ "public", "static", "function", "generateToken", "(", "$", "vary", ")", "{", "mt_srand", "(", "base_convert", "(", "substr", "(", "md5", "(", "$", "vary", ")", ",", "0", ",", "6", ")", ",", "36", ",", "10", ")", "*", "microtime", "(", "true", ")", ...
Generates a random token. Code is adopted from MvcAuthenticationTiein @return string The token.
[ "Generates", "a", "random", "token", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/models/ezprest_token.php#L92-L101
train
ezsystems/ezpublish-legacy
kernel/private/rest/classes/models/ezprest_token.php
ezpRestToken.fetch
public static function fetch( $accessToken, $authCheck = true ) { $tokenInfo = null; $session = ezcPersistentSessionInstance::get(); $q = $session->createFindQuery( __CLASS__ ); $e = $q->expr; $q->innerJoin( 'ezprest_clients', 'ezprest_token.client_id', 'ezprest_clients.client_id' ); if ( $authCheck ) { $q->innerJoin( 'ezprest_authorized_clients', $e->lAnd( $e->eq( 'ezprest_authorized_clients.rest_client_id', 'ezprest_clients.id' ), $e->eq( 'ezprest_authorized_clients.user_id', 'ezprest_token.user_id' ) ) ); } $q->where( $q->expr->eq( 'ezprest_token.id', $q->bindValue( $accessToken ) ) ); $tokenInfo = $session->find( $q, 'ezpRestToken' ); if ( !empty( $tokenInfo ) ) { $tokenInfo = array_shift( $tokenInfo ); } else // Empty array. For consistency in result, cast it to null { $tokenInfo = null; } return $tokenInfo; }
php
public static function fetch( $accessToken, $authCheck = true ) { $tokenInfo = null; $session = ezcPersistentSessionInstance::get(); $q = $session->createFindQuery( __CLASS__ ); $e = $q->expr; $q->innerJoin( 'ezprest_clients', 'ezprest_token.client_id', 'ezprest_clients.client_id' ); if ( $authCheck ) { $q->innerJoin( 'ezprest_authorized_clients', $e->lAnd( $e->eq( 'ezprest_authorized_clients.rest_client_id', 'ezprest_clients.id' ), $e->eq( 'ezprest_authorized_clients.user_id', 'ezprest_token.user_id' ) ) ); } $q->where( $q->expr->eq( 'ezprest_token.id', $q->bindValue( $accessToken ) ) ); $tokenInfo = $session->find( $q, 'ezpRestToken' ); if ( !empty( $tokenInfo ) ) { $tokenInfo = array_shift( $tokenInfo ); } else // Empty array. For consistency in result, cast it to null { $tokenInfo = null; } return $tokenInfo; }
[ "public", "static", "function", "fetch", "(", "$", "accessToken", ",", "$", "authCheck", "=", "true", ")", "{", "$", "tokenInfo", "=", "null", ";", "$", "session", "=", "ezcPersistentSessionInstance", "::", "get", "(", ")", ";", "$", "q", "=", "$", "se...
Fetches an ezpRestToken persistent object from an access token @param string $accessToken Access token hash string @param bool $authCheck If true, will also check if token corresponds to a client app authorized by its user @return ezpRestToken
[ "Fetches", "an", "ezpRestToken", "persistent", "object", "from", "an", "access", "token" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/models/ezprest_token.php#L109-L135
train
ezsystems/ezpublish-legacy
kernel/classes/ezaudit.php
eZAudit.fetchAuditNameSettings
static function fetchAuditNameSettings() { $ini = eZINI::instance( 'audit.ini' ); $auditNames = $ini->hasVariable( 'AuditSettings', 'AuditFileNames' ) ? $ini->variable( 'AuditSettings', 'AuditFileNames' ) : array(); $varDir = eZINI::instance()->variable( 'FileSettings', 'VarDir' ); // concat varDir setting with LogDir setting $logDir = $varDir . '/'; $logDir .= $ini->hasVariable( 'AuditSettings', 'LogDir' ) ? $ini->variable( 'AuditSettings', 'LogDir' ): self::DEFAULT_LOG_DIR; $resultArray = array(); foreach ( array_keys( $auditNames ) as $auditNameKey ) { $auditNameValue = $auditNames[$auditNameKey]; $resultArray[$auditNameKey] = array( 'dir' => $logDir, 'file_name' => $auditNameValue ); } return $resultArray; }
php
static function fetchAuditNameSettings() { $ini = eZINI::instance( 'audit.ini' ); $auditNames = $ini->hasVariable( 'AuditSettings', 'AuditFileNames' ) ? $ini->variable( 'AuditSettings', 'AuditFileNames' ) : array(); $varDir = eZINI::instance()->variable( 'FileSettings', 'VarDir' ); // concat varDir setting with LogDir setting $logDir = $varDir . '/'; $logDir .= $ini->hasVariable( 'AuditSettings', 'LogDir' ) ? $ini->variable( 'AuditSettings', 'LogDir' ): self::DEFAULT_LOG_DIR; $resultArray = array(); foreach ( array_keys( $auditNames ) as $auditNameKey ) { $auditNameValue = $auditNames[$auditNameKey]; $resultArray[$auditNameKey] = array( 'dir' => $logDir, 'file_name' => $auditNameValue ); } return $resultArray; }
[ "static", "function", "fetchAuditNameSettings", "(", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", "'audit.ini'", ")", ";", "$", "auditNames", "=", "$", "ini", "->", "hasVariable", "(", "'AuditSettings'", ",", "'AuditFileNames'", ")", "?", "$", ...
Returns an associative array of all names of audit and the log files used by this class, Will be fetched from ini settings. @return array
[ "Returns", "an", "associative", "array", "of", "all", "names", "of", "audit", "and", "the", "log", "files", "used", "by", "this", "class", "Will", "be", "fetched", "from", "ini", "settings", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezaudit.php#L21-L41
train
ezsystems/ezpublish-legacy
kernel/classes/ezaudit.php
eZAudit.isAuditEnabled
static function isAuditEnabled() { if ( isset( $GLOBALS['eZAuditEnabled'] ) ) { return $GLOBALS['eZAuditEnabled']; } $enabled = eZAudit::fetchAuditEnabled(); $GLOBALS['eZAuditEnabled'] = $enabled; return $enabled; }
php
static function isAuditEnabled() { if ( isset( $GLOBALS['eZAuditEnabled'] ) ) { return $GLOBALS['eZAuditEnabled']; } $enabled = eZAudit::fetchAuditEnabled(); $GLOBALS['eZAuditEnabled'] = $enabled; return $enabled; }
[ "static", "function", "isAuditEnabled", "(", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'eZAuditEnabled'", "]", ")", ")", "{", "return", "$", "GLOBALS", "[", "'eZAuditEnabled'", "]", ";", "}", "$", "enabled", "=", "eZAudit", "::", "fetchAud...
Returns true if audit should be enabled. @return boolean
[ "Returns", "true", "if", "audit", "should", "be", "enabled", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezaudit.php#L90-L99
train
ezsystems/ezpublish-legacy
kernel/classes/ezaudit.php
eZAudit.fetchAuditEnabled
static function fetchAuditEnabled() { $ini = eZINI::instance( 'audit.ini' ); $auditEnabled = $ini->hasVariable( 'AuditSettings', 'Audit' ) ? $ini->variable( 'AuditSettings', 'Audit' ) : 'disabled'; $enabled = $auditEnabled == 'enabled'; return $enabled; }
php
static function fetchAuditEnabled() { $ini = eZINI::instance( 'audit.ini' ); $auditEnabled = $ini->hasVariable( 'AuditSettings', 'Audit' ) ? $ini->variable( 'AuditSettings', 'Audit' ) : 'disabled'; $enabled = $auditEnabled == 'enabled'; return $enabled; }
[ "static", "function", "fetchAuditEnabled", "(", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", "'audit.ini'", ")", ";", "$", "auditEnabled", "=", "$", "ini", "->", "hasVariable", "(", "'AuditSettings'", ",", "'Audit'", ")", "?", "$", "ini", "...
Returns true if audit should be enabled. Will fetch from ini setting. @return bool
[ "Returns", "true", "if", "audit", "should", "be", "enabled", ".", "Will", "fetch", "from", "ini", "setting", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezaudit.php#L107-L115
train
ezsystems/ezpublish-legacy
kernel/classes/ezaudit.php
eZAudit.auditNameSettings
static function auditNameSettings() { if ( isset( $GLOBALS['eZAuditNameSettings'] ) ) { return $GLOBALS['eZAuditNameSettings']; } $nameSettings = eZAudit::fetchAuditNameSettings(); $GLOBALS['eZAuditNameSettings'] = $nameSettings; return $nameSettings; }
php
static function auditNameSettings() { if ( isset( $GLOBALS['eZAuditNameSettings'] ) ) { return $GLOBALS['eZAuditNameSettings']; } $nameSettings = eZAudit::fetchAuditNameSettings(); $GLOBALS['eZAuditNameSettings'] = $nameSettings; return $nameSettings; }
[ "static", "function", "auditNameSettings", "(", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'eZAuditNameSettings'", "]", ")", ")", "{", "return", "$", "GLOBALS", "[", "'eZAuditNameSettings'", "]", ";", "}", "$", "nameSettings", "=", "eZAudit", ...
Returns an associative array of all names of audit and the log files used by this class @return array
[ "Returns", "an", "associative", "array", "of", "all", "names", "of", "audit", "and", "the", "log", "files", "used", "by", "this", "class" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezaudit.php#L122-L131
train
ezsystems/ezpublish-legacy
kernel/classes/ezsiteaccess.php
eZSiteAccess.findPathToSiteAccess
static function findPathToSiteAccess( $siteAccess ) { $ini = eZINI::instance(); $siteAccessList = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' ); if ( !in_array( $siteAccess, $siteAccessList ) ) return false; $currentPath = 'settings/siteaccess/' . $siteAccess; if ( file_exists( $currentPath ) ) return $currentPath; $activeExtensions = eZExtension::activeExtensions(); $baseDir = eZExtension::baseDirectory(); foreach ( $activeExtensions as $extension ) { $currentPath = $baseDir . '/' . $extension . '/settings/siteaccess/' . $siteAccess; if ( file_exists( $currentPath ) ) return $currentPath; } return 'settings/siteaccess/' . $siteAccess; }
php
static function findPathToSiteAccess( $siteAccess ) { $ini = eZINI::instance(); $siteAccessList = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' ); if ( !in_array( $siteAccess, $siteAccessList ) ) return false; $currentPath = 'settings/siteaccess/' . $siteAccess; if ( file_exists( $currentPath ) ) return $currentPath; $activeExtensions = eZExtension::activeExtensions(); $baseDir = eZExtension::baseDirectory(); foreach ( $activeExtensions as $extension ) { $currentPath = $baseDir . '/' . $extension . '/settings/siteaccess/' . $siteAccess; if ( file_exists( $currentPath ) ) return $currentPath; } return 'settings/siteaccess/' . $siteAccess; }
[ "static", "function", "findPathToSiteAccess", "(", "$", "siteAccess", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", ")", ";", "$", "siteAccessList", "=", "$", "ini", "->", "variable", "(", "'SiteAccessSettings'", ",", "'AvailableSiteAccessList'", ...
Returns path to site access @param string $siteAccess @return string|false Return path to siteacces or false if invalid
[ "Returns", "path", "to", "site", "access" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsiteaccess.php#L66-L87
train
ezsystems/ezpublish-legacy
kernel/classes/ezsiteaccess.php
eZSiteAccess.matchRegexp
static function matchRegexp( &$text, $reg, $num ) { $reg = str_replace( '/', "\\/", $reg ); if ( preg_match( "/$reg/", $text, $regs ) && $num < count( $regs ) ) { $text = str_replace( $regs[$num], '', $text ); return $regs[$num]; } return null; }
php
static function matchRegexp( &$text, $reg, $num ) { $reg = str_replace( '/', "\\/", $reg ); if ( preg_match( "/$reg/", $text, $regs ) && $num < count( $regs ) ) { $text = str_replace( $regs[$num], '', $text ); return $regs[$num]; } return null; }
[ "static", "function", "matchRegexp", "(", "&", "$", "text", ",", "$", "reg", ",", "$", "num", ")", "{", "$", "reg", "=", "str_replace", "(", "'/'", ",", "\"\\\\/\"", ",", "$", "reg", ")", ";", "if", "(", "preg_match", "(", "\"/$reg/\"", ",", "$", ...
Match a regex expression @since 4.4 @param string $text @param string $reg @param int $num @return string|null
[ "Match", "a", "regex", "expression" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsiteaccess.php#L428-L437
train
ezsystems/ezpublish-legacy
kernel/classes/ezsiteaccess.php
eZSiteAccess.getIni
static function getIni( $siteAccess, $settingFile = 'site.ini' ) { // return global if siteaccess is same as requested or false if ( isset( $GLOBALS['eZCurrentAccess']['name'] ) && $GLOBALS['eZCurrentAccess']['name'] === $siteAccess ) { return eZINI::instance( $settingFile ); } else if ( !$siteAccess ) { return eZINI::instance( $settingFile ); } // create a site ini instance using $useLocalOverrides = true $siteIni = new eZINI( 'site.ini', 'settings', null, null, true ); // create a dummy access definition (not used as long as $siteIni is sent to self::load() ) $access = array( 'name' => $siteAccess, 'type' => eZSiteAccess::TYPE_STATIC, 'uri_part' => array() ); // Load siteaccess but on our locale instance of site.ini only $access = self::load( $access, $siteIni ); // if site.ini, return with no further work needed if ( $settingFile === 'site.ini' ) { return $siteIni; } // load settings file with $useLocalOverrides = true $ini = new eZINI( $settingFile,'settings', null, null, true ); $ini->setOverrideDirs( $siteIni->overrideDirs( false ) ); $ini->load(); return $ini; }
php
static function getIni( $siteAccess, $settingFile = 'site.ini' ) { // return global if siteaccess is same as requested or false if ( isset( $GLOBALS['eZCurrentAccess']['name'] ) && $GLOBALS['eZCurrentAccess']['name'] === $siteAccess ) { return eZINI::instance( $settingFile ); } else if ( !$siteAccess ) { return eZINI::instance( $settingFile ); } // create a site ini instance using $useLocalOverrides = true $siteIni = new eZINI( 'site.ini', 'settings', null, null, true ); // create a dummy access definition (not used as long as $siteIni is sent to self::load() ) $access = array( 'name' => $siteAccess, 'type' => eZSiteAccess::TYPE_STATIC, 'uri_part' => array() ); // Load siteaccess but on our locale instance of site.ini only $access = self::load( $access, $siteIni ); // if site.ini, return with no further work needed if ( $settingFile === 'site.ini' ) { return $siteIni; } // load settings file with $useLocalOverrides = true $ini = new eZINI( $settingFile,'settings', null, null, true ); $ini->setOverrideDirs( $siteIni->overrideDirs( false ) ); $ini->load(); return $ini; }
[ "static", "function", "getIni", "(", "$", "siteAccess", ",", "$", "settingFile", "=", "'site.ini'", ")", "{", "// return global if siteaccess is same as requested or false", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'eZCurrentAccess'", "]", "[", "'name'", "]", ...
Loads ini environment for a specific siteaccess eg: $ini = eZSiteAccess::getIni( 'eng', 'site.ini' ); @since 4.4 @param string $siteAccess @param string $settingFile @return eZINI
[ "Loads", "ini", "environment", "for", "a", "specific", "siteaccess" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsiteaccess.php#L631-L667
train
ezsystems/ezpublish-legacy
lib/ezdb/classes/ezmysqlcharset.php
eZMySQLCharset.mapTo
public static function mapTo( $charset ) { $lowerCharset = strtolower( $charset ); return isset( self::$mapping[$lowerCharset] ) ? self::$mapping[$lowerCharset] : $charset; }
php
public static function mapTo( $charset ) { $lowerCharset = strtolower( $charset ); return isset( self::$mapping[$lowerCharset] ) ? self::$mapping[$lowerCharset] : $charset; }
[ "public", "static", "function", "mapTo", "(", "$", "charset", ")", "{", "$", "lowerCharset", "=", "strtolower", "(", "$", "charset", ")", ";", "return", "isset", "(", "self", "::", "$", "mapping", "[", "$", "lowerCharset", "]", ")", "?", "self", "::", ...
Maps an internal charset to one understood by MySQL. If the charset is unknown, it will be returned as is. @param string $charset Charset to map. @return string The converted charset. @since 4.4
[ "Maps", "an", "internal", "charset", "to", "one", "understood", "by", "MySQL", ".", "If", "the", "charset", "is", "unknown", "it", "will", "be", "returned", "as", "is", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezmysqlcharset.php#L64-L68
train
ezsystems/ezpublish-legacy
lib/ezdb/classes/ezmysqlcharset.php
eZMySQLCharset.mapFrom
public static function mapFrom( $charset ) { $lowerCharset = strtolower( $charset ); return isset( self::$reverseMapping[$lowerCharset] ) ? self::$reverseMapping[$lowerCharset] : $charset; }
php
public static function mapFrom( $charset ) { $lowerCharset = strtolower( $charset ); return isset( self::$reverseMapping[$lowerCharset] ) ? self::$reverseMapping[$lowerCharset] : $charset; }
[ "public", "static", "function", "mapFrom", "(", "$", "charset", ")", "{", "$", "lowerCharset", "=", "strtolower", "(", "$", "charset", ")", ";", "return", "isset", "(", "self", "::", "$", "reverseMapping", "[", "$", "lowerCharset", "]", ")", "?", "self",...
Maps a MySQL charset to an internal one. If the charset is unknown, it will be returned as is. @param string $charset Charset to map. @return string The converted charset. @since 4.4
[ "Maps", "a", "MySQL", "charset", "to", "an", "internal", "one", ".", "If", "the", "charset", "is", "unknown", "it", "will", "be", "returned", "as", "is", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezmysqlcharset.php#L80-L84
train
ezsystems/ezpublish-legacy
kernel/private/classes/ezpkernelweb.php
ezpKernelWeb.getPolicyCheckViewMap
protected function getPolicyCheckViewMap( array $policyCheckOmitList ) { if ( $this->policyCheckViewMap !== null ) return $this->policyCheckViewMap; $this->policyCheckViewMap = array(); foreach ( $policyCheckOmitList as $omitItem ) { $items = explode( '/', $omitItem ); if ( count( $items ) > 1 ) { $module = $items[0]; if ( !isset( $this->policyCheckViewMap[$module] ) ) $this->policyCheckViewMap[$module] = array(); $this->policyCheckViewMap[$module][$items[1]] = true; } } return $this->policyCheckViewMap; }
php
protected function getPolicyCheckViewMap( array $policyCheckOmitList ) { if ( $this->policyCheckViewMap !== null ) return $this->policyCheckViewMap; $this->policyCheckViewMap = array(); foreach ( $policyCheckOmitList as $omitItem ) { $items = explode( '/', $omitItem ); if ( count( $items ) > 1 ) { $module = $items[0]; if ( !isset( $this->policyCheckViewMap[$module] ) ) $this->policyCheckViewMap[$module] = array(); $this->policyCheckViewMap[$module][$items[1]] = true; } } return $this->policyCheckViewMap; }
[ "protected", "function", "getPolicyCheckViewMap", "(", "array", "$", "policyCheckOmitList", ")", "{", "if", "(", "$", "this", "->", "policyCheckViewMap", "!==", "null", ")", "return", "$", "this", "->", "policyCheckViewMap", ";", "$", "this", "->", "policyCheckV...
Returns the map for policy check view @param array $policyCheckOmitList @return array
[ "Returns", "the", "map", "for", "policy", "check", "view" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpkernelweb.php#L879-L898
train
ezsystems/ezpublish-legacy
kernel/private/classes/ezpkernelweb.php
ezpKernelWeb.sessionInit
protected function sessionInit() { if ( !isset( $this->settings['session'] ) || !$this->settings['session']['configured'] ) { // running without Symfony2 or session is not configured // we keep the historic behaviour $ini = eZINI::instance(); if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' ) eZSession::start(); else eZSession::lazyStart(); } else { $sfHandler = new ezpSessionHandlerSymfony( $this->settings['session']['has_previous'] || $this->settings['session']['started'] ); $sfHandler->setStorage( $this->settings['session']['storage'] ); eZSession::init( $this->settings['session']['name'], $this->settings['session']['started'], $this->settings['session']['namespace'], $sfHandler ); } // let session specify if db is required $this->siteBasics['db-required'] = eZSession::getHandlerInstance()->dbRequired(); }
php
protected function sessionInit() { if ( !isset( $this->settings['session'] ) || !$this->settings['session']['configured'] ) { // running without Symfony2 or session is not configured // we keep the historic behaviour $ini = eZINI::instance(); if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' ) eZSession::start(); else eZSession::lazyStart(); } else { $sfHandler = new ezpSessionHandlerSymfony( $this->settings['session']['has_previous'] || $this->settings['session']['started'] ); $sfHandler->setStorage( $this->settings['session']['storage'] ); eZSession::init( $this->settings['session']['name'], $this->settings['session']['started'], $this->settings['session']['namespace'], $sfHandler ); } // let session specify if db is required $this->siteBasics['db-required'] = eZSession::getHandlerInstance()->dbRequired(); }
[ "protected", "function", "sessionInit", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "settings", "[", "'session'", "]", ")", "||", "!", "$", "this", "->", "settings", "[", "'session'", "]", "[", "'configured'", "]", ")", "{", "// r...
Initializes the session. If running, through Symfony the session parameters from Symfony override the session parameter from eZ Publish.
[ "Initializes", "the", "session", ".", "If", "running", "through", "Symfony", "the", "session", "parameters", "from", "Symfony", "override", "the", "session", "parameter", "from", "eZ", "Publish", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpkernelweb.php#L1037-L1066
train
ezsystems/ezpublish-legacy
kernel/private/classes/ezpkernelweb.php
ezpKernelWeb.runCallback
public function runCallback( \Closure $callback, $postReinitialize = true ) { $this->requestInit(); try { $return = $callback(); } catch ( Exception $e ) { $this->shutdown( $postReinitialize ); throw $e; } $this->shutdown( $postReinitialize ); return $return; }
php
public function runCallback( \Closure $callback, $postReinitialize = true ) { $this->requestInit(); try { $return = $callback(); } catch ( Exception $e ) { $this->shutdown( $postReinitialize ); throw $e; } $this->shutdown( $postReinitialize ); return $return; }
[ "public", "function", "runCallback", "(", "\\", "Closure", "$", "callback", ",", "$", "postReinitialize", "=", "true", ")", "{", "$", "this", "->", "requestInit", "(", ")", ";", "try", "{", "$", "return", "=", "$", "callback", "(", ")", ";", "}", "ca...
Run a callback function in legacy environment
[ "Run", "a", "callback", "function", "in", "legacy", "environment" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpkernelweb.php#L1215-L1232
train
ezsystems/ezpublish-legacy
kernel/classes/ezpolicy.php
eZPolicy.copy
function copy( $roleID ) { $params = array(); $params['ModuleName'] = $this->attribute( 'module_name' ); $params['FunctionName'] = $this->attribute( 'function_name' ); $db = eZDB::instance(); $db->begin(); $newPolicy = eZPolicy::createNew( $roleID, $params ); foreach ( $this->attribute( 'limitations' ) as $limitation ) { $limitation->copy( $newPolicy->attribute( 'id' ) ); } $db->commit(); return $newPolicy; }
php
function copy( $roleID ) { $params = array(); $params['ModuleName'] = $this->attribute( 'module_name' ); $params['FunctionName'] = $this->attribute( 'function_name' ); $db = eZDB::instance(); $db->begin(); $newPolicy = eZPolicy::createNew( $roleID, $params ); foreach ( $this->attribute( 'limitations' ) as $limitation ) { $limitation->copy( $newPolicy->attribute( 'id' ) ); } $db->commit(); return $newPolicy; }
[ "function", "copy", "(", "$", "roleID", ")", "{", "$", "params", "=", "array", "(", ")", ";", "$", "params", "[", "'ModuleName'", "]", "=", "$", "this", "->", "attribute", "(", "'module_name'", ")", ";", "$", "params", "[", "'FunctionName'", "]", "="...
Copies the policy and its limitations to another role @param int $roleID the ID of the role to copy to @return eZPolicy the created eZPolicy copy
[ "Copies", "the", "policy", "and", "its", "limitations", "to", "another", "role" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezpolicy.php#L197-L213
train
ezsystems/ezpublish-legacy
kernel/classes/ezpolicy.php
eZPolicy.fetchTemporaryCopy
public static function fetchTemporaryCopy( $policyID ) { $policy = eZPersistentObject::fetchObject( self::definition(), null, array( 'original_id' => $policyID ), true ); if ( $policy instanceof eZPolicy ) { return $policy; } // The temporary copy does not exist yet, create it else { $policy = self::fetch( $policyID ); if ( $policy === null ) return false; else { return $policy->createTemporaryCopy(); } } }
php
public static function fetchTemporaryCopy( $policyID ) { $policy = eZPersistentObject::fetchObject( self::definition(), null, array( 'original_id' => $policyID ), true ); if ( $policy instanceof eZPolicy ) { return $policy; } // The temporary copy does not exist yet, create it else { $policy = self::fetch( $policyID ); if ( $policy === null ) return false; else { return $policy->createTemporaryCopy(); } } }
[ "public", "static", "function", "fetchTemporaryCopy", "(", "$", "policyID", ")", "{", "$", "policy", "=", "eZPersistentObject", "::", "fetchObject", "(", "self", "::", "definition", "(", ")", ",", "null", ",", "array", "(", "'original_id'", "=>", "$", "polic...
Fetches the temporary copy of a policy @param int $policyID The original policy ID @return eZPolicy
[ "Fetches", "the", "temporary", "copy", "of", "a", "policy" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezpolicy.php#L388-L408
train
ezsystems/ezpublish-legacy
kernel/classes/ezpolicy.php
eZPolicy.createTemporaryCopy
public function createTemporaryCopy() { if ( $this->attribute( 'original_id' ) === 0 ) throw new Exception( 'eZPolicy #' . $this->attribute( 'id' ) . ' is already a temporary item (original: #'. $this->attribute( 'original_id' ) . ')' ); $policyCopy = self::copy( $this->attribute( 'role_id' ) ); $policyCopy->setAttribute( 'original_id', $this->attribute( 'id' ) ); $policyCopy->store(); return $policyCopy; }
php
public function createTemporaryCopy() { if ( $this->attribute( 'original_id' ) === 0 ) throw new Exception( 'eZPolicy #' . $this->attribute( 'id' ) . ' is already a temporary item (original: #'. $this->attribute( 'original_id' ) . ')' ); $policyCopy = self::copy( $this->attribute( 'role_id' ) ); $policyCopy->setAttribute( 'original_id', $this->attribute( 'id' ) ); $policyCopy->store(); return $policyCopy; }
[ "public", "function", "createTemporaryCopy", "(", ")", "{", "if", "(", "$", "this", "->", "attribute", "(", "'original_id'", ")", "===", "0", ")", "throw", "new", "Exception", "(", "'eZPolicy #'", ".", "$", "this", "->", "attribute", "(", "'id'", ")", "....
Creates a temporary copy for this policy so that it can be edited. The policies will be linked to the copy @return eZPolicy the temporary copy @since 4.4
[ "Creates", "a", "temporary", "copy", "for", "this", "policy", "so", "that", "it", "can", "be", "edited", ".", "The", "policies", "will", "be", "linked", "to", "the", "copy" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezpolicy.php#L415-L425
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._copyInner
private function _copyInner( $srcFilePath, $dstFilePath, $fname, $metaData ) { $this->_delete( $dstFilePath, true, $fname ); $datatype = $metaData['datatype']; $filePathHash = md5( $dstFilePath ); $scope = $metaData['scope']; $contentLength = $metaData['size']; $fileMTime = $metaData['mtime']; $nameTrunk = self::nameTrunk( $dstFilePath, $scope ); // Copy file metadata. if ( $this->_insertUpdate( $this->dbTable( $dstFilePath ), array( 'datatype'=> $datatype, 'name' => $dstFilePath, 'name_trunk' => $nameTrunk, 'name_hash' => $filePathHash, 'scope' => $scope, 'size' => $contentLength, 'mtime' => $fileMTime, 'expired' => ($fileMTime < 0) ? 1 : 0 ), "datatype=VALUES(datatype), scope=VALUES(scope), size=VALUES(size), mtime=VALUES(mtime), expired=VALUES(expired)", $fname ) === false ) { return $this->_fail( $srcFilePath, "Failed to insert file metadata on copying." ); } // Copy file data. if ( !$this->dfsbackend->copyFromDFSToDFS( $srcFilePath, $dstFilePath ) ) { return $this->_fail( $srcFilePath, "Failed to copy DFS://$srcFilePath to DFS://$dstFilePath" ); } return true; }
php
private function _copyInner( $srcFilePath, $dstFilePath, $fname, $metaData ) { $this->_delete( $dstFilePath, true, $fname ); $datatype = $metaData['datatype']; $filePathHash = md5( $dstFilePath ); $scope = $metaData['scope']; $contentLength = $metaData['size']; $fileMTime = $metaData['mtime']; $nameTrunk = self::nameTrunk( $dstFilePath, $scope ); // Copy file metadata. if ( $this->_insertUpdate( $this->dbTable( $dstFilePath ), array( 'datatype'=> $datatype, 'name' => $dstFilePath, 'name_trunk' => $nameTrunk, 'name_hash' => $filePathHash, 'scope' => $scope, 'size' => $contentLength, 'mtime' => $fileMTime, 'expired' => ($fileMTime < 0) ? 1 : 0 ), "datatype=VALUES(datatype), scope=VALUES(scope), size=VALUES(size), mtime=VALUES(mtime), expired=VALUES(expired)", $fname ) === false ) { return $this->_fail( $srcFilePath, "Failed to insert file metadata on copying." ); } // Copy file data. if ( !$this->dfsbackend->copyFromDFSToDFS( $srcFilePath, $dstFilePath ) ) { return $this->_fail( $srcFilePath, "Failed to copy DFS://$srcFilePath to DFS://$dstFilePath" ); } return true; }
[ "private", "function", "_copyInner", "(", "$", "srcFilePath", ",", "$", "dstFilePath", ",", "$", "fname", ",", "$", "metaData", ")", "{", "$", "this", "->", "_delete", "(", "$", "dstFilePath", ",", "true", ",", "$", "fname", ")", ";", "$", "datatype", ...
Inner function used by _copy to perform the operation in a transaction @param string $srcFilePath @param string $dstFilePath @param bool $fname @param array $metaData Source file's metadata @return bool @see _copy
[ "Inner", "function", "used", "by", "_copy", "to", "perform", "the", "operation", "in", "a", "transaction" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L246-L279
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._purge
public function _purge( $filePath, $onlyExpired = false, $expiry = false, $fname = false ) { if ( $fname ) $fname .= "::_purge($filePath)"; else $fname = "_purge($filePath)"; $sql = "DELETE FROM " . $this->dbTable( $filePath ) . " WHERE name_hash=" . $this->_md5( $filePath ); if ( $expiry !== false ) { $sql .= " AND mtime<" . (int)$expiry; } elseif ( $onlyExpired ) { $sql .= " AND expired=1"; } if ( !$this->_query( $sql, $fname ) ) { return $this->_fail( "Purging file metadata for $filePath failed" ); } if ( mysqli_affected_rows( $this->db ) == 1 ) { $this->dfsbackend->delete( $filePath ); } $this->eventHandler->notify( 'cluster/deleteFile', array( $filePath ) ); return true; }
php
public function _purge( $filePath, $onlyExpired = false, $expiry = false, $fname = false ) { if ( $fname ) $fname .= "::_purge($filePath)"; else $fname = "_purge($filePath)"; $sql = "DELETE FROM " . $this->dbTable( $filePath ) . " WHERE name_hash=" . $this->_md5( $filePath ); if ( $expiry !== false ) { $sql .= " AND mtime<" . (int)$expiry; } elseif ( $onlyExpired ) { $sql .= " AND expired=1"; } if ( !$this->_query( $sql, $fname ) ) { return $this->_fail( "Purging file metadata for $filePath failed" ); } if ( mysqli_affected_rows( $this->db ) == 1 ) { $this->dfsbackend->delete( $filePath ); } $this->eventHandler->notify( 'cluster/deleteFile', array( $filePath ) ); return true; }
[ "public", "function", "_purge", "(", "$", "filePath", ",", "$", "onlyExpired", "=", "false", ",", "$", "expiry", "=", "false", ",", "$", "fname", "=", "false", ")", "{", "if", "(", "$", "fname", ")", "$", "fname", ".=", "\"::_purge($filePath)\"", ";", ...
Purges meta-data and file-data for a file entry Will only expire a single file. Use _purgeByLike to purge multiple files @param string $filePath Path of the file to purge @param bool $onlyExpired Only purges expired files @param bool|int $expiry @param bool $fname @see _purgeByLike @return bool|eZMySQLBackendError
[ "Purges", "meta", "-", "data", "and", "file", "-", "data", "for", "a", "file", "entry" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L295-L322
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._purgeByLike
public function _purgeByLike( $like, $onlyExpired = false, $limit = 50, $expiry = false, $fname = false ) { if ( $fname ) $fname .= "::_purgeByLike($like, $onlyExpired)"; else $fname = "_purgeByLike($like, $onlyExpired)"; // common query part used for both DELETE and SELECT $where = " WHERE name LIKE " . $this->_quote( $like, true ); if ( $expiry !== false ) $where .= " AND mtime < " . (int)$expiry; elseif ( $onlyExpired ) $where .= " AND expired = 1"; if ( $limit ) $sqlLimit = " LIMIT $limit"; else $sqlLimit = ""; $this->_begin( $fname ); // select query, in FOR UPDATE mode $selectSQL = "SELECT name FROM " . $this->dbTable( $like ) . "{$where} {$sqlLimit} FOR UPDATE"; if ( !$res = $this->_query( $selectSQL, $fname ) ) { $this->_rollback( $fname ); return $this->_fail( "Selecting file metadata by like statement $like failed" ); } $resultCount = mysqli_num_rows( $res ); // if there are no results, we can just return 0 and stop right here if ( $resultCount == 0 ) { $this->_rollback( $fname ); return 0; } // the candidate for purge are indexed in an array else { for ( $i = 0; $i < $resultCount; $i++ ) { $row = mysqli_fetch_assoc( $res ); $files[] = $row['name']; } } // delete query $deleteSQL = "DELETE FROM " . $this->dbTable( $like ) . " {$where} {$sqlLimit}"; if ( !$res = $this->_query( $deleteSQL, $fname ) ) { $this->_rollback( $fname ); return $this->_fail( "Purging file metadata by like statement $like failed" ); } $deletedDBFiles = mysqli_affected_rows( $this->db ); $commitResult = $this->_commit( $fname ); if ( $commitResult === true || $commitResult === null ) { $this->dfsbackend->delete( $files ); return $deletedDBFiles; } return false; }
php
public function _purgeByLike( $like, $onlyExpired = false, $limit = 50, $expiry = false, $fname = false ) { if ( $fname ) $fname .= "::_purgeByLike($like, $onlyExpired)"; else $fname = "_purgeByLike($like, $onlyExpired)"; // common query part used for both DELETE and SELECT $where = " WHERE name LIKE " . $this->_quote( $like, true ); if ( $expiry !== false ) $where .= " AND mtime < " . (int)$expiry; elseif ( $onlyExpired ) $where .= " AND expired = 1"; if ( $limit ) $sqlLimit = " LIMIT $limit"; else $sqlLimit = ""; $this->_begin( $fname ); // select query, in FOR UPDATE mode $selectSQL = "SELECT name FROM " . $this->dbTable( $like ) . "{$where} {$sqlLimit} FOR UPDATE"; if ( !$res = $this->_query( $selectSQL, $fname ) ) { $this->_rollback( $fname ); return $this->_fail( "Selecting file metadata by like statement $like failed" ); } $resultCount = mysqli_num_rows( $res ); // if there are no results, we can just return 0 and stop right here if ( $resultCount == 0 ) { $this->_rollback( $fname ); return 0; } // the candidate for purge are indexed in an array else { for ( $i = 0; $i < $resultCount; $i++ ) { $row = mysqli_fetch_assoc( $res ); $files[] = $row['name']; } } // delete query $deleteSQL = "DELETE FROM " . $this->dbTable( $like ) . " {$where} {$sqlLimit}"; if ( !$res = $this->_query( $deleteSQL, $fname ) ) { $this->_rollback( $fname ); return $this->_fail( "Purging file metadata by like statement $like failed" ); } $deletedDBFiles = mysqli_affected_rows( $this->db ); $commitResult = $this->_commit( $fname ); if ( $commitResult === true || $commitResult === null ) { $this->dfsbackend->delete( $files ); return $deletedDBFiles; } return false; }
[ "public", "function", "_purgeByLike", "(", "$", "like", ",", "$", "onlyExpired", "=", "false", ",", "$", "limit", "=", "50", ",", "$", "expiry", "=", "false", ",", "$", "fname", "=", "false", ")", "{", "if", "(", "$", "fname", ")", "$", "fname", ...
Purges meta-data and file-data for files matching a pattern using a SQL LIKE syntax. @param string $like SQL LIKE string applied to ezdfsfile.name to look for files to purge @param bool $onlyExpired Only purge expired files (ezdfsfile.expired = 1) @param int $limit Maximum number of items to purge in one call @param bool|int $expiry Timestamp used to limit deleted files: only files older than this date will be deleted @param string|bool $fname Optional caller name for debugging @see _purge @return bool|int false if it fails, number of affected rows otherwise
[ "Purges", "meta", "-", "data", "and", "file", "-", "data", "for", "files", "matching", "a", "pattern", "using", "a", "SQL", "LIKE", "syntax", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L338-L404
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._delete
public function _delete( $filePath, $insideOfTransaction = false, $fname = false ) { if ( $fname ) $fname .= "::_delete($filePath)"; else $fname = "_delete($filePath)"; // @todo Check if this is requried: _protec will already take care of // checking if a transaction is running. But leave it like this // for now. if ( $insideOfTransaction ) { $res = $this->_deleteInner( $filePath, $fname ); if ( !$res || $res instanceof eZMySQLBackendError ) { $this->_handleErrorType( $res ); } } else { $res = $this->_protect( array( $this, '_deleteInner' ), $fname, $filePath, $insideOfTransaction, $fname ); } $this->eventHandler->notify( 'cluster/deleteFile', array( $filePath ) ); return $res; }
php
public function _delete( $filePath, $insideOfTransaction = false, $fname = false ) { if ( $fname ) $fname .= "::_delete($filePath)"; else $fname = "_delete($filePath)"; // @todo Check if this is requried: _protec will already take care of // checking if a transaction is running. But leave it like this // for now. if ( $insideOfTransaction ) { $res = $this->_deleteInner( $filePath, $fname ); if ( !$res || $res instanceof eZMySQLBackendError ) { $this->_handleErrorType( $res ); } } else { $res = $this->_protect( array( $this, '_deleteInner' ), $fname, $filePath, $insideOfTransaction, $fname ); } $this->eventHandler->notify( 'cluster/deleteFile', array( $filePath ) ); return $res; }
[ "public", "function", "_delete", "(", "$", "filePath", ",", "$", "insideOfTransaction", "=", "false", ",", "$", "fname", "=", "false", ")", "{", "if", "(", "$", "fname", ")", "$", "fname", ".=", "\"::_delete($filePath)\"", ";", "else", "$", "fname", "=",...
Deletes a file from DB The file won't be removed from disk, _purge has to be used for this. Only single files will be deleted, to delete multiple files, _deleteByLike has to be used. @param string $filePath Path of the file to delete @param bool $insideOfTransaction Wether or not a transaction is already started @param bool|string $fname Optional caller name for debugging @see _deleteInner @see _deleteByLike @return bool
[ "Deletes", "a", "file", "from", "DB" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L421-L447
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._deleteByLike
public function _deleteByLike( $like, $fname = false ) { if ( $fname ) $fname .= "::_deleteByLike($like)"; else $fname = "_deleteByLike($like)"; $return = $this->_protect( array( $this, '_deleteByLikeInner' ), $fname, $like, $fname ); if ( $return ) $this->eventHandler->notify( 'cluster/deleteByLike', array( $like ) ); return $return; }
php
public function _deleteByLike( $like, $fname = false ) { if ( $fname ) $fname .= "::_deleteByLike($like)"; else $fname = "_deleteByLike($like)"; $return = $this->_protect( array( $this, '_deleteByLikeInner' ), $fname, $like, $fname ); if ( $return ) $this->eventHandler->notify( 'cluster/deleteByLike', array( $like ) ); return $return; }
[ "public", "function", "_deleteByLike", "(", "$", "like", ",", "$", "fname", "=", "false", ")", "{", "if", "(", "$", "fname", ")", "$", "fname", ".=", "\"::_deleteByLike($like)\"", ";", "else", "$", "fname", "=", "\"_deleteByLike($like)\"", ";", "$", "retur...
Deletes multiple files using a SQL LIKE statement Use _delete if you need to delete single files @param string $like SQL LIKE condition applied to ezdfsfile.name to look for files to delete. Will use name_trunk if the LIKE string matches a filetype that supports name_trunk. @param bool|string $fname Optional caller name for debugging @return bool @see _deleteByLikeInner @see _delete
[ "Deletes", "multiple", "files", "using", "a", "SQL", "LIKE", "statement" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L477-L490
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._deleteByWildcard
public function _deleteByWildcard( $wildcard, $fname = false ) { if ( $fname ) $fname .= "::_deleteByWildcard($wildcard)"; else $fname = "_deleteByWildcard($wildcard)"; return $this->_protect( array( $this, '_deleteByWildcardInner' ), $fname, $wildcard, $fname ); }
php
public function _deleteByWildcard( $wildcard, $fname = false ) { if ( $fname ) $fname .= "::_deleteByWildcard($wildcard)"; else $fname = "_deleteByWildcard($wildcard)"; return $this->_protect( array( $this, '_deleteByWildcardInner' ), $fname, $wildcard, $fname ); }
[ "public", "function", "_deleteByWildcard", "(", "$", "wildcard", ",", "$", "fname", "=", "false", ")", "{", "if", "(", "$", "fname", ")", "$", "fname", ".=", "\"::_deleteByWildcard($wildcard)\"", ";", "else", "$", "fname", "=", "\"_deleteByWildcard($wildcard)\""...
Deletes multiple DB files by wildcard @param string $wildcard @param mixed $fname @return bool @deprecated Has severe performance issues
[ "Deletes", "multiple", "DB", "files", "by", "wildcard" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L517-L525
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._deleteByWildcardInner
protected function _deleteByWildcardInner( $wildcard, $fname ) { // Convert wildcard to regexp. $regex = '^' . mysqli_real_escape_string( $this->db, $wildcard ) . '$'; $regex = str_replace( array( '.' ), array( '\.' ), $regex ); $regex = str_replace( array( '?', '*', '{', '}', ',' ), array( '.', '.*', '(', ')', '|' ), $regex ); $sql = "UPDATE " . $this->dbTable( $wildcard ) . " SET mtime=-ABS(mtime), expired=1\nWHERE name REGEXP '$regex'"; if ( !$res = $this->_query( $sql, $fname ) ) { return $this->_fail( "Failed to delete files by wildcard: '$wildcard'" ); } return true; }
php
protected function _deleteByWildcardInner( $wildcard, $fname ) { // Convert wildcard to regexp. $regex = '^' . mysqli_real_escape_string( $this->db, $wildcard ) . '$'; $regex = str_replace( array( '.' ), array( '\.' ), $regex ); $regex = str_replace( array( '?', '*', '{', '}', ',' ), array( '.', '.*', '(', ')', '|' ), $regex ); $sql = "UPDATE " . $this->dbTable( $wildcard ) . " SET mtime=-ABS(mtime), expired=1\nWHERE name REGEXP '$regex'"; if ( !$res = $this->_query( $sql, $fname ) ) { return $this->_fail( "Failed to delete files by wildcard: '$wildcard'" ); } return true; }
[ "protected", "function", "_deleteByWildcardInner", "(", "$", "wildcard", ",", "$", "fname", ")", "{", "// Convert wildcard to regexp.", "$", "regex", "=", "'^'", ".", "mysqli_real_escape_string", "(", "$", "this", "->", "db", ",", "$", "wildcard", ")", ".", "'...
Callback used by _deleteByWildcard to perform the deletion @param mixed $wildcard @param mixed $fname @return bool @deprecated Has severe performance issues
[ "Callback", "used", "by", "_deleteByWildcard", "to", "perform", "the", "deletion" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L535-L554
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend.mkdir_p
private function mkdir_p( $dir ) { // create parent directories $dirElements = explode( '/', $dir ); if ( count( $dirElements ) == 0 ) return true; $result = true; $currentDir = $dirElements[0]; if ( $currentDir != '' && !file_exists( $currentDir ) && !eZDir::mkdir( $currentDir, false ) ) return false; for ( $i = 1; $i < count( $dirElements ); ++$i ) { $dirElement = $dirElements[$i]; if ( strlen( $dirElement ) == 0 ) continue; $currentDir .= '/' . $dirElement; if ( !file_exists( $currentDir ) && !eZDir::mkdir( $currentDir, false ) ) return false; $result = true; } return $result; }
php
private function mkdir_p( $dir ) { // create parent directories $dirElements = explode( '/', $dir ); if ( count( $dirElements ) == 0 ) return true; $result = true; $currentDir = $dirElements[0]; if ( $currentDir != '' && !file_exists( $currentDir ) && !eZDir::mkdir( $currentDir, false ) ) return false; for ( $i = 1; $i < count( $dirElements ); ++$i ) { $dirElement = $dirElements[$i]; if ( strlen( $dirElement ) == 0 ) continue; $currentDir .= '/' . $dirElement; if ( !file_exists( $currentDir ) && !eZDir::mkdir( $currentDir, false ) ) return false; $result = true; } return $result; }
[ "private", "function", "mkdir_p", "(", "$", "dir", ")", "{", "// create parent directories", "$", "dirElements", "=", "explode", "(", "'/'", ",", "$", "dir", ")", ";", "if", "(", "count", "(", "$", "dirElements", ")", "==", "0", ")", "return", "true", ...
Creates a directory and all parent directories in its path, if necessary @param string $dir @return bool
[ "Creates", "a", "directory", "and", "all", "parent", "directories", "in", "its", "path", "if", "necessary" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L658-L686
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._getFileList
public function _getFileList( $scopes = false, $excludeScopes = false, $limit = false, $path = false ) { $filePathList = array(); $tables = array_unique( array( $this->metaDataTable, $this->metaDataTableCache ) ); foreach ( $tables as $table ) { $query = 'SELECT name FROM ' . $table; if ( is_array( $scopes ) && count( $scopes ) > 0 ) { $query .= ' WHERE scope '; if ( $excludeScopes ) $query .= 'NOT '; $query .= "IN ('" . implode( "', '", $scopes ) . "')"; } if ( $path != false && $scopes == false) { $query .= " WHERE name LIKE '" . $path . "%'"; } else if ( $path != false) { $query .= " AND name LIKE '" . $path . "%'"; } if ( $limit && array_sum($limit) ) { $query .= " LIMIT {$limit[0]}, {$limit[1]}"; } $rslt = $this->_query( $query, "_getFileList( array( " . implode( ', ', is_array( $scopes ) ? $scopes : array() ) . " ), $excludeScopes )" ); if ( !$rslt ) { eZDebug::writeError( 'Unable to get file list', __METHOD__ ); throw new Exception( "dfs/mysqli DB error: " . mysqli_error( $this->db ) . "\nSQL Query: $query", mysqli_errno( $this->db ) ); } while ( $row = mysqli_fetch_row( $rslt ) ) { $filePathList[] = $row[0]; } mysqli_free_result( $rslt ); } return $filePathList; }
php
public function _getFileList( $scopes = false, $excludeScopes = false, $limit = false, $path = false ) { $filePathList = array(); $tables = array_unique( array( $this->metaDataTable, $this->metaDataTableCache ) ); foreach ( $tables as $table ) { $query = 'SELECT name FROM ' . $table; if ( is_array( $scopes ) && count( $scopes ) > 0 ) { $query .= ' WHERE scope '; if ( $excludeScopes ) $query .= 'NOT '; $query .= "IN ('" . implode( "', '", $scopes ) . "')"; } if ( $path != false && $scopes == false) { $query .= " WHERE name LIKE '" . $path . "%'"; } else if ( $path != false) { $query .= " AND name LIKE '" . $path . "%'"; } if ( $limit && array_sum($limit) ) { $query .= " LIMIT {$limit[0]}, {$limit[1]}"; } $rslt = $this->_query( $query, "_getFileList( array( " . implode( ', ', is_array( $scopes ) ? $scopes : array() ) . " ), $excludeScopes )" ); if ( !$rslt ) { eZDebug::writeError( 'Unable to get file list', __METHOD__ ); throw new Exception( "dfs/mysqli DB error: " . mysqli_error( $this->db ) . "\nSQL Query: $query", mysqli_errno( $this->db ) ); } while ( $row = mysqli_fetch_row( $rslt ) ) { $filePathList[] = $row[0]; } mysqli_free_result( $rslt ); } return $filePathList; }
[ "public", "function", "_getFileList", "(", "$", "scopes", "=", "false", ",", "$", "excludeScopes", "=", "false", ",", "$", "limit", "=", "false", ",", "$", "path", "=", "false", ")", "{", "$", "filePathList", "=", "array", "(", ")", ";", "$", "tables...
Returns the list of cluster files, filtered by the optional params @param array|bool $scopes filter by array of scopes to include in the list @param bool $excludeScopes if true, $scopes param acts as an exclude filter @param array|bool $limit limits the search to offset limit[0], limit limit[1] @param bool|string $path filter to include entries only including $path @return array|false the db list of entries of false if none found
[ "Returns", "the", "list", "of", "cluster", "files", "filtered", "by", "the", "optional", "params" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L1108-L1155
train
ezsystems/ezpublish-legacy
kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
eZDFSFileHandlerMySQLiBackend._begin
protected function _begin( $fname = false ) { if ( $fname ) $fname .= "::_begin"; else $fname = "_begin"; $this->transactionCount++; if ( $this->transactionCount == 1 ) $this->_query( "BEGIN", $fname ); }
php
protected function _begin( $fname = false ) { if ( $fname ) $fname .= "::_begin"; else $fname = "_begin"; $this->transactionCount++; if ( $this->transactionCount == 1 ) $this->_query( "BEGIN", $fname ); }
[ "protected", "function", "_begin", "(", "$", "fname", "=", "false", ")", "{", "if", "(", "$", "fname", ")", "$", "fname", ".=", "\"::_begin\"", ";", "else", "$", "fname", "=", "\"_begin\"", ";", "$", "this", "->", "transactionCount", "++", ";", "if", ...
Starts a new transaction by executing a BEGIN call. If a transaction is already started nothing is executed.
[ "Starts", "a", "new", "transaction", "by", "executing", "a", "BEGIN", "call", ".", "If", "a", "transaction", "is", "already", "started", "nothing", "is", "executed", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php#L1354-L1363
train
ezsystems/ezpublish-legacy
kernel/classes/ezvatrule.php
eZVatRule.fetchByVatType
static function fetchByVatType( $vatID ) { return eZPersistentObject::fetchObjectList( eZVatRule::definition(), null, array( 'vat_type' => (int) $vatID ), null, null, true, false, null ); }
php
static function fetchByVatType( $vatID ) { return eZPersistentObject::fetchObjectList( eZVatRule::definition(), null, array( 'vat_type' => (int) $vatID ), null, null, true, false, null ); }
[ "static", "function", "fetchByVatType", "(", "$", "vatID", ")", "{", "return", "eZPersistentObject", "::", "fetchObjectList", "(", "eZVatRule", "::", "definition", "(", ")", ",", "null", ",", "array", "(", "'vat_type'", "=>", "(", "int", ")", "$", "vatID", ...
Fetch VAT rules referencing given VAT type. \param $vatID ID of VAT type to count VAT rules for. \public \static
[ "Fetch", "VAT", "rules", "referencing", "given", "VAT", "type", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatrule.php#L94-L99
train
ezsystems/ezpublish-legacy
kernel/classes/ezvatrule.php
eZVatRule.fetchCountByCategory
static function fetchCountByCategory( $categories ) { $db = eZDB::instance(); $query = "SELECT COUNT(*) AS count FROM ezvatrule vr, ezvatrule_product_category vrpc " . "WHERE vr.id=vrpc.vatrule_id AND "; if ( is_array( $categories ) ) { $query .= $db->generateSQLINStatement( $categories, 'vrpc.product_category_id', false, false, 'int' ); } else { $query .= "vrpc.product_category_id =" . (int) $categories; } $rows = $db->arrayQuery( $query ); return $rows[0]['count']; }
php
static function fetchCountByCategory( $categories ) { $db = eZDB::instance(); $query = "SELECT COUNT(*) AS count FROM ezvatrule vr, ezvatrule_product_category vrpc " . "WHERE vr.id=vrpc.vatrule_id AND "; if ( is_array( $categories ) ) { $query .= $db->generateSQLINStatement( $categories, 'vrpc.product_category_id', false, false, 'int' ); } else { $query .= "vrpc.product_category_id =" . (int) $categories; } $rows = $db->arrayQuery( $query ); return $rows[0]['count']; }
[ "static", "function", "fetchCountByCategory", "(", "$", "categories", ")", "{", "$", "db", "=", "eZDB", "::", "instance", "(", ")", ";", "$", "query", "=", "\"SELECT COUNT(*) AS count FROM ezvatrule vr, ezvatrule_product_category vrpc \"", ".", "\"WHERE vr.id=vrpc.vatrule...
Fetch number of VAT rules referencing given product categories @param $categories Category (single or list) to count VAT rules for. @return int
[ "Fetch", "number", "of", "VAT", "rules", "referencing", "given", "product", "categories" ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatrule.php#L108-L127
train
ezsystems/ezpublish-legacy
kernel/classes/ezvatrule.php
eZVatRule.fetchCountByVatType
static function fetchCountByVatType( $vatID ) { $rows = eZPersistentObject::fetchObjectList( eZVatRule::definition(), array(), array( 'vat_type' => (int) $vatID ), false, null, false, false, array( array( 'operation' => 'count( * )', 'name' => 'count' ) ) ); return $rows[0]['count']; }
php
static function fetchCountByVatType( $vatID ) { $rows = eZPersistentObject::fetchObjectList( eZVatRule::definition(), array(), array( 'vat_type' => (int) $vatID ), false, null, false, false, array( array( 'operation' => 'count( * )', 'name' => 'count' ) ) ); return $rows[0]['count']; }
[ "static", "function", "fetchCountByVatType", "(", "$", "vatID", ")", "{", "$", "rows", "=", "eZPersistentObject", "::", "fetchObjectList", "(", "eZVatRule", "::", "definition", "(", ")", ",", "array", "(", ")", ",", "array", "(", "'vat_type'", "=>", "(", "...
Return number of VAT rules referencing given VAT type. \param $vatID ID of VAT type to count VAT rules for. \public \static
[ "Return", "number", "of", "VAT", "rules", "referencing", "given", "VAT", "type", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatrule.php#L136-L148
train
ezsystems/ezpublish-legacy
kernel/classes/ezvatrule.php
eZVatRule.removeVatRule
static function removeVatRule( $id ) { $db = eZDB::instance(); $db->begin(); // Remove product categories associated with the rule. eZVatRule::removeProductCategories( $id ); // Remove the rule itself. eZPersistentObject::removeObject( eZVatRule::definition(), array( "id" => $id ) ); $db->commit(); }
php
static function removeVatRule( $id ) { $db = eZDB::instance(); $db->begin(); // Remove product categories associated with the rule. eZVatRule::removeProductCategories( $id ); // Remove the rule itself. eZPersistentObject::removeObject( eZVatRule::definition(), array( "id" => $id ) ); $db->commit(); }
[ "static", "function", "removeVatRule", "(", "$", "id", ")", "{", "$", "db", "=", "eZDB", "::", "instance", "(", ")", ";", "$", "db", "->", "begin", "(", ")", ";", "// Remove product categories associated with the rule.", "eZVatRule", "::", "removeProductCategori...
Remove given VAT charging rule.
[ "Remove", "given", "VAT", "charging", "rule", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatrule.php#L163-L176
train
ezsystems/ezpublish-legacy
kernel/classes/ezvatrule.php
eZVatRule.productCategoriesString
function productCategoriesString() { $categories = $this->attribute( 'product_categories' ); if ( !$categories ) { $result = ezpI18n::tr( 'kernel/shop', 'Any' ); return $result; } $categoriesNames = array(); foreach ( $categories as $cat ) $categoriesNames[] = $cat['name']; return join( ', ', $categoriesNames ); }
php
function productCategoriesString() { $categories = $this->attribute( 'product_categories' ); if ( !$categories ) { $result = ezpI18n::tr( 'kernel/shop', 'Any' ); return $result; } $categoriesNames = array(); foreach ( $categories as $cat ) $categoriesNames[] = $cat['name']; return join( ', ', $categoriesNames ); }
[ "function", "productCategoriesString", "(", ")", "{", "$", "categories", "=", "$", "this", "->", "attribute", "(", "'product_categories'", ")", ";", "if", "(", "!", "$", "categories", ")", "{", "$", "result", "=", "ezpI18n", "::", "tr", "(", "'kernel/shop'...
Return product categories as string, separated with commas. \private
[ "Return", "product", "categories", "as", "string", "separated", "with", "commas", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatrule.php#L227-L241
train
ezsystems/ezpublish-legacy
kernel/classes/ezvatrule.php
eZVatRule.productCategoriesIDs
function productCategoriesIDs() { $catIDs = array(); $categories = $this->attribute( 'product_categories' ); if ( $categories ) { foreach ( $categories as $cat ) $catIDs[] = $cat['id']; } return $catIDs; }
php
function productCategoriesIDs() { $catIDs = array(); $categories = $this->attribute( 'product_categories' ); if ( $categories ) { foreach ( $categories as $cat ) $catIDs[] = $cat['id']; } return $catIDs; }
[ "function", "productCategoriesIDs", "(", ")", "{", "$", "catIDs", "=", "array", "(", ")", ";", "$", "categories", "=", "$", "this", "->", "attribute", "(", "'product_categories'", ")", ";", "if", "(", "$", "categories", ")", "{", "foreach", "(", "$", "...
Return IDs of product categories associated with the rule. \private
[ "Return", "IDs", "of", "product", "categories", "associated", "with", "the", "rule", "." ]
2493420f527fbc829a8d5bdda402e05d64a20db7
https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatrule.php#L248-L260
train