idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
2,700
public function linkTopology ( $ devices = null ) { if ( $ devices == null ) $ devices = $ this -> crawl ( ) ; $ links = array ( ) ; foreach ( $ devices as $ feDevice => $ feNeighbours ) { foreach ( $ feNeighbours as $ fe2Device => $ fe2Links ) { foreach ( $ fe2Links as $ fe2Link ) { if ( isset ( $ links [ $ fe2Device ] [ $ feDevice ] [ $ fe2Link [ 'remotePort' ] ] ) ) continue ; if ( ! isset ( $ links [ $ feDevice ] ) ) $ links [ $ feDevice ] = array ( ) ; if ( ! isset ( $ links [ $ feDevice ] [ $ fe2Device ] ) ) $ links [ $ feDevice ] [ $ fe2Device ] = array ( ) ; $ links [ $ feDevice ] [ $ fe2Device ] [ $ fe2Link [ 'localPort' ] ] = array ( ) ; foreach ( $ fe2Link as $ k => $ v ) $ links [ $ feDevice ] [ $ fe2Device ] [ $ fe2Link [ 'localPort' ] ] [ $ k ] = $ v ; } } } return $ links ; }
Find the layer 2 topology as an array with no link mentioned more than once .
2,701
public static function camelToUnderscore ( $ s ) { $ s = preg_replace ( '#(.)(?=[A-Z])#' , '$1_' , $ s ) ; $ s = strtolower ( $ s ) ; $ s = rawurlencode ( $ s ) ; return $ s ; }
camelCase - > camel_case
2,702
public static function underscoreToCamel ( $ s ) { $ s = preg_replace ( '#_(?=[a-zA-Z])#' , ' ' , $ s ) ; $ s = substr ( ucwords ( 'x' . $ s ) , 1 ) ; $ s = str_replace ( ' ' , '' , $ s ) ; return $ s ; }
camel_case - > camelCase
2,703
protected function o_fontEncoding ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'fontEncoding' , 'info' => $ options ) ; break ; case 'out' : $ res = "\n$id 0 obj\n<< /Type /Encoding\n" ; if ( ! isset ( $ o [ 'info' ] [ 'encoding' ] ) ) { $ o [ 'info' ] [ 'encoding' ] = 'WinAnsiEncoding' ; } if ( $ o [ 'info' ] [ 'encoding' ] !== 'none' ) { $ res .= "/BaseEncoding /" . $ o [ 'info' ] [ 'encoding' ] . "\n" ; } $ res .= "/Differences \n[" ; $ onum = - 100 ; foreach ( $ o [ 'info' ] [ 'differences' ] as $ num => $ label ) { if ( $ num != $ onum + 1 ) { $ res .= "\n$num /$label" ; } else { $ res .= " /$label" ; } $ onum = $ num ; } $ res .= "\n]\n>>\nendobj" ; return $ res ; } }
the font encoding
2,704
protected function o_fontGIDtoCIDMap ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'fontGIDtoCIDMap' , 'info' => $ options ) ; break ; case 'out' : $ res = "\n$id 0 obj\n" ; $ fontFileName = $ o [ 'info' ] [ 'fontFileName' ] ; $ tmp = $ this -> fonts [ $ fontFileName ] [ 'CIDtoGID' ] = base64_decode ( $ this -> fonts [ $ fontFileName ] [ 'CIDtoGID' ] ) ; $ compressed = isset ( $ this -> fonts [ $ fontFileName ] [ 'CIDtoGID_Compressed' ] ) && $ this -> fonts [ $ fontFileName ] [ 'CIDtoGID_Compressed' ] ; if ( ! $ compressed && isset ( $ o [ 'raw' ] ) ) { $ res .= $ tmp ; } else { $ res .= "<<" ; if ( ! $ compressed && $ this -> compressionReady && $ this -> options [ 'compression' ] ) { $ compressed = true ; $ tmp = gzcompress ( $ tmp , 6 ) ; } if ( $ compressed ) { $ res .= "\n/Filter /FlateDecode" ; } $ res .= "\n/Length " . mb_strlen ( $ tmp , '8bit' ) . ">>\nstream\n$tmp\nendstream" ; } $ res .= "\nendobj" ; return $ res ; } }
a font glyph to character map needed for unicode fonts
2,705
protected function o_annotation ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ pageId = $ this -> currentPage ; $ this -> o_page ( $ pageId , 'annot' , $ id ) ; switch ( $ options [ 'type' ] ) { case 'link' : $ this -> objects [ $ id ] = array ( 't' => 'annotation' , 'info' => $ options ) ; $ this -> numObj ++ ; $ this -> o_action ( $ this -> numObj , 'new' , $ options [ 'url' ] ) ; $ this -> objects [ $ id ] [ 'info' ] [ 'actionId' ] = $ this -> numObj ; break ; case 'ilink' : $ label = $ options [ 'label' ] ; $ this -> objects [ $ id ] = array ( 't' => 'annotation' , 'info' => $ options ) ; $ this -> numObj ++ ; $ this -> o_action ( $ this -> numObj , 'new' , array ( 'type' => 'ilink' , 'label' => $ label ) ) ; $ this -> objects [ $ id ] [ 'info' ] [ 'actionId' ] = $ this -> numObj ; break ; } break ; case 'out' : $ res = "\n$id 0 obj\n<< /Type /Annot" ; switch ( $ o [ 'info' ] [ 'type' ] ) { case 'link' : case 'ilink' : $ res .= "\n/Subtype /Link" ; break ; } $ res .= "\n/A " . $ o [ 'info' ] [ 'actionId' ] . " 0 R" ; $ res .= "\n/Border [0 0 0]" ; $ res .= "\n/H /I" ; $ res .= "\n/Rect [ " ; foreach ( $ o [ 'info' ] [ 'rect' ] as $ v ) { $ res .= sprintf ( "%.4F " , $ v ) ; } $ res .= "]" ; $ res .= "\n>>\nendobj" ; return $ res ; } }
an annotation object this will add an annotation to the current page . initially will support just link annotations
2,706
protected function o_extGState ( $ id , $ action , $ options = "" ) { static $ valid_params = array ( "LW" , "LC" , "LC" , "LJ" , "ML" , "D" , "RI" , "OP" , "op" , "OPM" , "Font" , "BG" , "BG2" , "UCR" , "TR" , "TR2" , "HT" , "FL" , "SM" , "SA" , "BM" , "SMask" , "CA" , "ca" , "AIS" , "TK" ) ; if ( $ action !== "new" ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case "new" : $ this -> objects [ $ id ] = array ( 't' => 'extGState' , 'info' => $ options ) ; $ this -> numStates ++ ; $ this -> o_pages ( $ this -> currentNode , 'extGState' , array ( "objNum" => $ id , "stateNum" => $ this -> numStates ) ) ; break ; case "out" : $ res = "\n$id 0 obj\n<< /Type /ExtGState\n" ; foreach ( $ o [ "info" ] as $ k => $ v ) { if ( ! in_array ( $ k , $ valid_params ) ) continue ; $ res .= "/$k $v\n" ; } $ res .= ">>\nendobj" ; return $ res ; } }
graphics state object
2,707
function setCurrentFont ( ) { $ this -> currentFont = $ this -> currentBaseFont ; $ this -> currentFontNum = $ this -> fonts [ $ this -> currentFont ] [ 'fontNum' ] ; }
sets up the current font based on the font families and the current text state note that this system is quite flexible a bold - italic font can be completely different to a italic - bold font and even bold - bold will have to be defined within the family to have meaning This function is to be called whenever the currentTextState is changed it will update the currentFont setting to whatever the appropriatte family one is . If the user calls selectFont themselves then that will reset the currentBaseFont and the currentFont This function will change the currentFont to whatever it should be but will not change the currentBaseFont .
2,708
function setLineTransparency ( $ mode , $ opacity ) { static $ blend_modes = array ( "Normal" , "Multiply" , "Screen" , "Overlay" , "Darken" , "Lighten" , "ColorDogde" , "ColorBurn" , "HardLight" , "SoftLight" , "Difference" , "Exclusion" ) ; if ( ! in_array ( $ mode , $ blend_modes ) ) $ mode = "Normal" ; if ( $ mode === $ this -> currentLineTransparency [ "mode" ] && $ opacity == $ this -> currentLineTransparency [ "opacity" ] ) return ; $ this -> currentLineTransparency [ "mode" ] = $ mode ; $ this -> currentLineTransparency [ "opacity" ] = $ opacity ; $ options = array ( "BM" => "/$mode" , "CA" => ( float ) $ opacity ) ; $ this -> setGraphicsState ( $ options ) ; }
Set current blend mode & opacity for lines .
2,709
function setFillTransparency ( $ mode , $ opacity ) { static $ blend_modes = array ( "Normal" , "Multiply" , "Screen" , "Overlay" , "Darken" , "Lighten" , "ColorDogde" , "ColorBurn" , "HardLight" , "SoftLight" , "Difference" , "Exclusion" ) ; if ( ! in_array ( $ mode , $ blend_modes ) ) $ mode = "Normal" ; if ( $ mode === $ this -> currentFillTransparency [ "mode" ] && $ opacity == $ this -> currentFillTransparency [ "opacity" ] ) return ; $ this -> currentFillTransparency [ "mode" ] = $ mode ; $ this -> currentFillTransparency [ "opacity" ] = $ opacity ; $ options = array ( "BM" => "/$mode" , "ca" => ( float ) $ opacity ) ; $ this -> setGraphicsState ( $ options ) ; }
Set current blend mode & opacity for filled objects .
2,710
function filledEllipse ( $ x0 , $ y0 , $ r1 , $ r2 = 0 , $ angle = 0 , $ nSeg = 8 , $ astart = 0 , $ afinish = 360 ) { return $ this -> ellipse ( $ x0 , $ y0 , $ r1 , $ r2 = 0 , $ angle , $ nSeg , $ astart , $ afinish , true , true ) ; }
draw a filled ellipse
2,711
function filledRectangle ( $ x1 , $ y1 , $ width , $ height ) { $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= sprintf ( "\n%.3F %.3F %.3F %.3F re f" , $ x1 , $ y1 , $ width , $ height ) ; }
a filled rectangle note that it is the width and height of the rectangle which are the secondary paramaters not the coordinates of the upper - right corner
2,712
function save ( ) { $ this -> currentColour = null ; $ this -> currentStrokeColour = null ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nq" ; }
save the current graphic state
2,713
protected function parse ( $ userAgent ) { $ originalUserAgent = $ userAgent ; $ nodesUAPosition = strrpos ( $ userAgent , 'Nodes/' ) ; if ( $ nodesUAPosition !== false ) { $ nodesUserAgent = substr ( $ userAgent , $ nodesUAPosition ) ; $ this -> parseNodesUserAgent ( $ nodesUserAgent ) ; $ originalUserAgent = substr ( $ userAgent , 0 , $ nodesUAPosition - 1 ) ; } $ this -> parseOriginalUserAgent ( $ originalUserAgent ) ; }
Parse received user agent .
2,714
public function indexAction ( $ attributeId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } return array ( 'attribute' => $ attribute , ) ; }
Lists all AttributeValue entities .
2,715
public function createAction ( Request $ request , $ attributeId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = new AttributeValue ( ) ; $ form = $ this -> createForm ( new AttributeValueType ( ) , $ entity ) ; $ entity -> setAttribute ( $ attribute ) ; $ form -> bind ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'value.created' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_attributevalue_show' , array ( 'attributeId' => $ attributeId , 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'attribute' => $ attribute , 'form' => $ form -> createView ( ) , ) ; }
Creates a new AttributeValue entity .
2,716
public function newAction ( $ attributeId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = new AttributeValue ( ) ; $ form = $ this -> createForm ( new AttributeValueType ( ) , $ entity ) ; return array ( 'entity' => $ entity , 'attribute' => $ attribute , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new AttributeValue entity .
2,717
public function showAction ( $ attributeId , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = $ em -> getRepository ( 'EcommerceBundle:AttributeValue' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find AttributeValue entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ attributeId , $ id ) ; return array ( 'entity' => $ entity , 'attribute' => $ attribute , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Finds and displays a AttributeValue entity .
2,718
public function editAction ( $ attributeId , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = $ em -> getRepository ( 'EcommerceBundle:AttributeValue' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find AttributeValue entity.' ) ; } $ editForm = $ this -> createForm ( new AttributeValueType ( ) , $ entity ) ; $ deleteForm = $ this -> createDeleteForm ( $ attributeId , $ id ) ; return array ( 'entity' => $ entity , 'attribute' => $ attribute , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Displays a form to edit an existing AttributeValue entity .
2,719
private function createDeleteForm ( $ attributeId , $ id ) { return $ this -> createFormBuilder ( array ( 'attributeId' => $ attributeId , 'id' => $ id ) ) -> add ( 'attributeId' , 'hidden' ) -> add ( 'id' , 'hidden' ) -> getForm ( ) ; }
Creates a form to delete a AttributeValue entity by id .
2,720
public function isValidMethod ( $ method ) { $ reflection = $ this -> getReflection ( ) -> getMethod ( $ method ) ; return ! $ reflection -> isAbstract ( ) && $ reflection -> isPublic ( ) && preg_match ( $ this -> methodRule , $ method ) > 0 ; }
Validate if method is routable
2,721
public function getRoutableReflectionMethodList ( ) { $ reflections = [ ] ; foreach ( $ this -> getReflection ( ) -> getMethods ( ) as $ reflection ) { if ( $ this -> isValidMethod ( $ reflection -> name ) ) { $ reflections [ ] = $ reflection ; } } return $ reflections ; }
Get list of ReflectionMethod if is valid routable
2,722
public function generateRoutables ( Router $ router = null , $ prefix = null ) { $ router ? : $ router = new Router ; $ prefix ? : $ prefix = $ this -> buildUriPrefix ( $ this -> reflection -> getShortName ( ) ) ; foreach ( $ this -> getRoutableReflectionMethodList ( ) as $ reflection ) { $ this -> addRouteFromMethod ( $ router , $ reflection -> getName ( ) , $ prefix ) ; } return $ router ; }
Gets the routable list
2,723
protected function getMethodPartAndVerb ( $ method ) { preg_match ( $ this -> methodRule , $ method , $ matches ) ; return empty ( $ matches ) ? false : array_slice ( $ matches , 1 ) ; }
Gets the data of Method
2,724
protected function createCurrentSiteInfo ( ) { while ( $ this -> queryResult -> valid ( ) ) { $ data = $ this -> queryResult -> current ( ) ; $ current = $ this -> createSiteInfo ( $ data ) ; $ schema = $ current -> getSchema ( ) ; if ( ! empty ( $ this -> queriedSchemas [ $ schema ] ) ) { $ this -> queryResult -> next ( ) ; } else { $ this -> queriedSchemas [ $ schema ] = true ; return $ this -> setSiteInfo ( $ this -> currentSiteInfo = $ current ) ; } } $ this -> currentSiteInfo = null ; return null ; }
Create current SiteInfo
2,725
public function getVersions ( $ pattern = null ) { $ versions = array_keys ( $ this -> versions ) ; if ( empty ( $ pattern ) ) { return $ versions ; } $ pattern = preg_replace ( '~\.~' , '\\.' , $ pattern ) ; $ pattern = preg_replace ( '~[xyz]+~i' , '\\d+' , $ pattern ) ; $ result = [ ] ; foreach ( $ versions as $ version ) { if ( preg_match ( "~^{$pattern}~" , $ version ) ) { $ result [ ] = $ version ; } } return $ result ; }
Get all known version numbers matching a pattern .
2,726
public function getSourceInfo ( $ version = 'latest' , $ ext = null ) { $ info = $ this -> getInfo ( $ version ) ; if ( ! empty ( $ ext ) && isset ( $ info [ 'source' ] [ $ ext ] ) ) { return $ info [ 'source' ] [ $ ext ] ; } foreach ( [ 'xz' , 'bz2' , 'gz' ] as $ ext ) { if ( isset ( $ info [ 'source' ] [ $ ext ] ) ) { return $ info [ 'source' ] [ $ ext ] ; } } throw new \ Exception ( "No source information for version $version." ) ; }
Get the download information for a specific version .
2,727
public function getInfo ( $ version = 'latest' ) { $ version = $ this -> resolveVersion ( $ version ) ; if ( ! isset ( $ this -> versions [ $ version ] ) ) { throw new \ Exception ( "No information for version $version." ) ; } return $ this -> versions [ $ version ] ; }
Get information about a specific version .
2,728
public function createImportFile ( ) { @ unlink ( $ this -> localPath ) ; $ fp = fopen ( $ this -> localPath , 'w' ) ; fwrite ( $ fp , $ this -> xmlStart ) ; foreach ( $ this -> elements as $ element ) { fwrite ( $ fp , $ element -> getXml ( ) ) ; } fwrite ( $ fp , $ this -> xmlEnd ) ; fclose ( $ fp ) ; return $ this -> localPath ; }
Returns the local path of the file
2,729
protected function runSeeder ( $ database ) { $ class = $ this -> option ( 'seeder' ) ? : 'DatabaseSeeder' ; $ force = $ this -> input -> getOption ( 'force' ) ; $ this -> call ( 'db:seed' , array ( '--database' => $ database , '--class' => $ class , '--force' => $ force , ) ) ; }
Run the database seeder command .
2,730
public function writeInt8 ( int $ value ) : self { $ this -> bytes .= Writer :: bit8 ( $ value ) ; return $ this ; }
Write a signed 8 bit integer .
2,731
public function writeInt16 ( int $ value ) : self { $ this -> bytes .= Writer :: bit16 ( $ value ) ; return $ this ; }
Write a signed 16 bit integer .
2,732
public function writeInt32 ( int $ value ) : self { $ this -> bytes .= Writer :: bit32 ( $ value ) ; return $ this ; }
Write a signed 32 bit integer .
2,733
public function writeInt64 ( int $ value ) : self { $ this -> bytes .= Writer :: bit64 ( $ value ) ; return $ this ; }
Write a signed 64 bit integer .
2,734
public function addModule ( $ key , Module $ module ) { $ this -> _modules [ $ key ] = $ module ; $ module -> setApplication ( $ this ) ; $ module -> bootstrap ( $ this ) ; if ( $ module instanceof Listener ) { $ this -> on ( 'mvc' , $ module ) ; } return $ module ; }
Add a module into the application .
2,735
public function createLinks ( $ web ) { $ web = Path :: ds ( $ web , true ) ; foreach ( $ this -> getModules ( ) as $ key => $ module ) { $ moduleWeb = $ module -> getPath ( ) . 'web' . Path :: SEPARATOR ; if ( ! file_exists ( $ moduleWeb ) ) { continue ; } $ targetLink = $ web . $ key . Path :: SEPARATOR ; if ( ! file_exists ( $ targetLink ) ) { symlink ( $ moduleWeb , $ targetLink ) ; } else if ( is_file ( $ targetLink ) && ! is_link ( $ targetLink ) ) { throw new AssetSymlinkException ( sprintf ( 'Webroot folder %s must not exist so that static assets can be symlinked' , $ key ) ) ; } } }
Create symbolic links to the webroot folder within each module . This allows for direct static asset handling .
2,736
public function get ( $ key ) { if ( isset ( $ this -> _components [ $ key ] ) ) { return $ this -> _components [ $ key ] ; } throw new MissingComponentException ( sprintf ( 'Application component %s does not exist' , $ key ) ) ; }
Return a component by key .
2,737
public function getModule ( $ key ) { if ( isset ( $ this -> _modules [ $ key ] ) ) { return $ this -> _modules [ $ key ] ; } throw new MissingModuleException ( sprintf ( 'Could not locate %s module' , $ key ) ) ; }
Return a module by key .
2,738
public function handleAsset ( $ params ) { $ response = $ this -> getResponse ( ) ; $ path = null ; try { $ module = $ this -> getModule ( $ params [ 'module' ] ) ; $ path = implode ( '/' , [ $ module -> getPath ( ) , 'web' , $ params [ 'asset' ] , $ params [ 'path' ] ] ) ; $ this -> emit ( 'mvc.preAsset' , [ $ this , & $ path , $ response ] ) ; if ( file_exists ( $ path ) ) { $ response -> body ( file_get_contents ( $ path ) ) -> cache ( ) -> contentType ( pathinfo ( $ path , PATHINFO_EXTENSION ) ) -> contentLength ( filesize ( $ path ) ) -> lastModified ( filemtime ( $ path ) ) ; } else { $ response -> statusCode ( 404 ) ; } } catch ( Exception $ e ) { $ response -> statusCode ( 404 ) ; } $ this -> emit ( 'mvc.postAsset' , [ $ this , $ path , $ response ] ) ; $ response -> respond ( ) ; exit ( ) ; }
Handle a static asset by outputting the file contents and size to the browser . If the asset does not exist throw a 404 and exit .
2,739
public function handleError ( Exception $ exception ) { if ( class_exists ( 'Titon\Debug\Debugger' ) ) { Debugger :: logException ( $ exception ) ; } try { $ controller = Registry :: get ( 'titon.controller' ) ; if ( ! ( $ controller instanceof Controller ) ) { throw new MissingControllerException ( ) ; } } catch ( Exception $ e ) { $ controller = new ErrorController ( ) ; $ controller -> initialize ( ) ; } try { $ view = Registry :: get ( 'titon.view' ) ; if ( ! ( $ view instanceof ViewInterface ) ) { throw new MissingViewException ( ) ; } } catch ( Exception $ e ) { $ view = new View ( ) ; $ view -> addHelper ( 'html' , new HtmlHelper ( ) ) ; $ view -> addHelper ( 'block' , new BlockHelper ( ) ) ; $ view -> addHelper ( 'asset' , new AssetHelper ( [ 'webroot' => $ this -> getWebroot ( ) ] ) ) ; } $ controller -> setView ( $ view ) ; $ controller -> setRequest ( $ this -> getRequest ( ) ) ; $ controller -> setResponse ( $ this -> getResponse ( ) ) ; $ this -> emit ( 'mvc.preError' , [ $ this , $ controller , $ exception ] ) ; $ response = $ controller -> renderError ( $ exception ) ; $ this -> emit ( 'mvc.postError' , [ $ this , $ controller , $ exception , & $ response ] ) ; $ this -> getResponse ( ) -> body ( $ response ) -> respond ( ) ; $ this -> emit ( 'mvc.onShutdown' , [ $ this ] ) ; exit ( ) ; }
Default mechanism for handling uncaught exceptions . Will fetch the current controller instance or instantiate an ErrorController . The error view template will be rendered .
2,740
public function run ( $ webroot ) { $ this -> _webroot = $ webroot ; $ this -> getRequest ( ) -> set ( 'webroot' , $ webroot ) ; $ this -> createLinks ( $ webroot ) ; $ this -> emit ( 'mvc.preRun' , [ $ this ] ) ; $ dispatcher = $ this -> getDispatcher ( ) ; $ dispatcher -> setApplication ( $ this ) ; $ dispatcher -> setParams ( $ this -> getRouter ( ) -> current ( ) -> getParams ( ) ) ; $ dispatcher -> setRequest ( $ this -> getRequest ( ) ) ; $ dispatcher -> setResponse ( $ this -> getResponse ( ) ) ; $ response = $ dispatcher -> dispatch ( ) ; $ this -> emit ( 'mvc.postRun' , [ $ this ] ) ; $ this -> getResponse ( ) -> body ( $ response ) -> respond ( ) ; $ this -> emit ( 'mvc.onShutdown' , [ $ this ] ) ; exit ( ) ; }
Run the application by fetching the dispatcher and dispatching the request to the module and controller that matches the current URL .
2,741
public function set ( $ key , $ object ) { $ this -> _components [ $ key ] = Registry :: set ( $ object ) ; return $ this ; }
Set an object to use throughout the application .
2,742
public function setRouter ( Router $ router ) { $ this -> set ( 'router' , $ router ) ; $ this -> _router = $ this -> get ( 'router' ) ; return $ this ; }
Set the router .
2,743
public function execute ( Framework $ framework , RequestAbstract $ request , Response $ response , $ value = null ) { $ permissions = array ( ) ; foreach ( $ value as $ accessLevel ) { $ parts = explode ( '\\' , $ accessLevel ) ; if ( $ parts [ 1 ] === 'Group' && count ( $ parts ) === 3 ) { $ uuid = $ parts [ 2 ] ; $ groupPermissions = $ this -> accessControlManager -> getPermissionsForUuid ( $ uuid ) ; if ( $ groupPermissions !== false ) { foreach ( $ groupPermissions as $ groupPermission ) { $ permissions [ ] = $ groupPermission ; } } } else { $ permissions [ ] = $ accessLevel ; } } $ permissions = array_unique ( $ permissions ) ; return $ permissions ; }
Replaces all group access levels with the permissions of the group
2,744
private function renderEmbeddedFiles ( & $ content , $ boundary ) { foreach ( $ this -> cids as $ image => $ cid ) { if ( ! is_readable ( $ image ) ) { throw new MailException ( 'Image could bot be read: ' . $ image ) ; } $ type = self :: getMimeTypeOfImage ( $ image ) ; $ name = basename ( $ image ) ; $ data = chunk_split ( base64_encode ( file_get_contents ( $ image ) ) ) ; $ content .= "\r\n" ; $ content .= "--$boundary\r\n" ; $ content .= "Content-Type: $type;\r\n\tname=\"$name\"\r\n" ; $ content .= "Content-Transfer-Encoding: base64\r\n" ; $ content .= "Content-ID: <" . $ cid . ">\r\n" ; $ content .= "Content-Description: \"$name\"\r\n" ; $ content .= "Content-Location: \"$name\"\r\n" ; $ content .= "\r\n" ; $ content .= "$data" ; } }
Render embedded files into the given content .
2,745
private function renderAttachments ( & $ content , $ boundary ) { foreach ( $ this -> attachments as $ file => $ name ) { if ( ! is_readable ( $ file ) ) { throw new MailException ( 'File could not be read: ' . $ file ) ; } $ data = chunk_split ( base64_encode ( file_get_contents ( $ file ) ) ) ; $ type = mime_content_type ( $ file ) ; $ content .= "\r\n" ; $ content .= "--$boundary\r\n" ; $ content .= "Content-Type: $type;\r\n\tname=\"$name\"\r\n" ; $ content .= "Content-Transfer-Encoding: base64\r\n" ; $ content .= "Content-Description: \"$name\"\r\n" ; $ content .= "Content-Disposition: attachment;\r\n\tfilename=\"$name\"\r\n" ; $ content .= "\r\n" ; $ content .= "$data" ; } }
Render attachments into the given content .
2,746
private function renderPlainText ( & $ content , $ text , $ encoding , $ boundary ) { $ content .= "\r\n" ; $ content .= "--$boundary\r\n" ; $ content .= "Content-Type: text/plain;\r\n\tcharset=\"$encoding\"\r\n" ; $ content .= "Content-Transfer-Encoding: quoted-printable\r\n" ; $ content .= "\r\n" ; $ content .= "$text\r\n" ; }
Render plain text into the given content .
2,747
private function renderHtml ( & $ content , $ html , $ encoding , $ boundary ) { $ content .= "\r\n" ; $ content .= "--$boundary\r\n" ; $ content .= "Content-Type: text/html;\r\n\tcharset=\"$encoding\"\r\n" ; $ content .= "Content-Transfer-Encoding: quoted-printable\r\n" ; $ content .= "\r\n" ; $ content .= "$html\r\n" ; }
Render HTML into the given content .
2,748
private function renderTextAndHtml ( & $ content , $ text , $ html , $ encoding , $ boundary ) { $ uid = uniqid ( ) ; $ boundary2 = "x----_=_NextPart_003_$uid" ; $ content .= "\r\n--$boundary\r\n" ; $ content .= "Content-Type: multipart/alternative;\r\n\tboundary=\"$boundary2\"\r\n" ; $ this -> renderPlainText ( $ content , $ text , $ encoding , $ boundary2 ) ; $ this -> renderHtml ( $ content , $ html , $ encoding , $ boundary2 ) ; $ content .= "\r\n--$boundary2--\r\n" ; }
Render text and html into the given content .
2,749
private function renderTextAndHtmlWithEmbededFiles ( & $ content , $ text , $ html , $ encoding , $ boundary ) { $ uid = uniqid ( ) ; $ boundary2 = "x----_=_NextPart_002_$uid" ; $ content .= "\r\n--$boundary\r\n" ; $ content .= "Content-Type: multipart/related;\r\n\tboundary=\"$boundary2\";\r\n\ttype=\"multipart/alternative\"\r\n" ; $ this -> renderTextAndHtml ( $ content , $ text , $ html , $ encoding , $ boundary2 ) ; $ this -> renderEmbeddedFiles ( $ content , $ boundary2 ) ; $ content .= "\r\n--$boundary2--\r\n" ; }
Render text and html with embedded files into the given content .
2,750
private static function getMimeTypeOfImage ( $ image ) { static $ mimes ; if ( $ mimes === null ) { $ mimes = [ 'cod' => 'image/cis-cod' , 'ras' => 'image/cmu-raster' , 'fif' => 'image/fif' , 'gif' => 'image/gif' , 'ief' => 'image/ief' , 'jpeg' => 'image/jpeg' , 'jpg' => 'image/jpeg' , 'jpe' => 'image/jpeg' , 'png' => 'image/png' , 'tiff' => 'image/tiff' , 'tif' => 'image/tiff' , 'mcf' => 'image/vasa' , 'wbmp' => 'image/vnd.wap.wbmp' , 'fh4' => 'image/x-freehand' , 'fh5' => 'image/x-freehand' , 'fhc' => 'image/x-freehand' , 'ico' => 'image/x-icon' , 'pnm' => 'image/x-portable-anymap' , 'pbm' => 'image/x-portable-bitmap' , 'pgm' => 'image/x-portable-graymap' , 'ppm' => 'image/x-portable-pixmap' , 'rgb' => 'image/x-rgb' , 'wxd' => 'image/x-windowdump' , 'xbm' => 'image/x-xbitmap' , 'xpm' => 'image/x-xpixmap' , ] ; } $ ext = pathinfo ( $ image , PATHINFO_EXTENSION ) ; $ type = isset ( $ mimes [ $ ext ] ) ? $ mimes [ $ ext ] : 'application/octet-stream' ; return $ type ; }
Gets the MIME Type of the given image .
2,751
private function justAddress ( $ address ) { if ( ( $ pos = strpos ( $ address , '<' ) ) === false ) { return $ address ; } $ n = strlen ( $ address ) ; if ( $ address [ $ n - 1 ] == '>' ) { $ address = substr ( $ address , $ pos + 1 , - 1 ) ; } return $ address ; }
Get the address without the name .
2,752
private function findAddress ( $ needle , array $ haystack ) { $ address = $ this -> justAddress ( $ needle ) ; foreach ( $ haystack as $ i => $ item ) { if ( $ this -> justAddress ( $ item ) == $ address ) { return $ i ; } } return false ; }
Get the index of the given address .
2,753
public static function save ( $ file , $ lang , $ language = null ) { ( $ language === null ) and $ language = static :: get_lang ( ) ; if ( ! is_null ( $ language ) ) { $ file = explode ( '::' , $ file ) ; end ( $ file ) ; $ file [ key ( $ file ) ] = $ language . DS . end ( $ file ) ; $ file = implode ( '::' , $ file ) ; } if ( ! is_array ( $ lang ) ) { if ( ! isset ( static :: $ lines [ $ language ] [ $ lang ] ) ) { return false ; } $ lang = static :: $ lines [ $ language ] [ $ lang ] ; } $ type = pathinfo ( $ file , PATHINFO_EXTENSION ) ; if ( ! $ type ) { $ type = 'php' ; $ file .= '.' . $ type ; } $ class = '\\Lang_' . ucfirst ( $ type ) ; if ( ! class_exists ( $ class , true ) ) { throw new \ LangException ( 'Cannot save a language file of type: ' . $ type ) ; } $ driver = new $ class ; return $ driver -> save ( $ file , $ lang ) ; }
Save a language array to disk .
2,754
public function getFallbackThemes ( $ name ) { if ( ! isset ( $ this -> data [ $ name ] [ 'fallbacks' ] ) ) { return array ( ) ; } if ( ! is_array ( $ this -> data [ $ name ] [ 'fallbacks' ] ) && ! ( $ this -> data [ $ name ] [ 'fallbacks' ] instanceof Traversable ) ) { return array ( ( string ) $ this -> data [ $ name ] [ 'fallbacks' ] ) ; } return $ this -> data [ $ name ] [ 'fallbacks' ] ; }
Retrieve the fallback theme
2,755
function setLabel ( $ label ) { $ label = str_replace ( ' ' , '-' , ucwords ( str_replace ( [ '_' , '-' ] , ' ' , ( string ) $ label ) ) ) ; if ( ! isValidLabel ( $ label ) ) throw new \ InvalidArgumentException ( sprintf ( 'Invalid header name "%s".' , is_null ( $ label ) ? 'null' : $ label ) ) ; $ this -> label = $ label ; return $ this ; }
Set Header Label
2,756
function render ( ) { $ label = $ this -> getLabel ( ) ; if ( empty ( $ label ) ) throw new \ Exception ( 'Header label is empty.' ) ; return $ label . ': ' . $ this -> renderValueLine ( ) . self :: CRLF ; }
Represent Header As String
2,757
public function json ( $ forceJson = false , $ returnAllIfNotJson = true ) { if ( $ forceJson || $ this -> isJson ( ) ) { return json_decode ( $ this -> getContent ( ) ) ; } if ( ! $ returnAllIfNotJson ) { return null ; } return ( object ) $ this -> all ( ) ; }
Get json request .
2,758
public function accept ( $ accept , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: ACCEPT , 'value' => $ accept , 'message' => $ error ] ) ; } return $ this ; }
file types accepted
2,759
public function extension ( $ extension , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: EXTENSION , 'value' => $ extension , 'message' => $ error ] ) ; } return $ this ; }
file extensions accepted
2,760
public function setDateFormat ( Event $ e ) { $ form = $ e -> getParam ( 'form' ) ; $ hydrator = $ form -> getHydrator ( ) ; $ dateTimeStrategy = $ hydrator -> getStrategy ( 'dateTime' ) ; $ dateTimeStrategy -> setHydrateFormat ( $ this -> getOptions ( ) -> getDateFormat ( ) ) ; }
Add date format
2,761
public function validateImplementation ( ) { $ required = [ 'model' => ' does not implement a model definition.' , 'resource_path' => ' does not implement a resource path definition.' , ] ; foreach ( $ required as $ implementation => $ message ) { if ( ! isset ( $ this -> { $ implementation } ) ) { throw new \ InvalidArgumentException ( static :: class . $ message ) ; } } }
Make sure a model has been defined for this restful resource
2,762
public function model ( $ instance = false ) { if ( ! isset ( $ this -> model ) ) { throw new \ InvalidArgumentException ( static :: class . ' does not implement a model definition.' ) ; } return $ instance ? new $ this -> model : $ this -> model ; }
Get the model class
2,763
public function path ( $ id = null ) { if ( ! isset ( $ this -> resource_path ) ) { throw new \ InvalidArgumentException ( static :: class . ' does not implement a resource path definition.' ) ; } return is_null ( $ id ) ? $ this -> url ( $ this -> resource_path ) : $ this -> url ( "$this->resource_path/$id" ) ; }
Find the resource path
2,764
protected function makeGenericUpdate ( Model $ model ) { $ field = array_first ( $ model -> getFillable ( ) , function ( $ key , $ value ) use ( $ model ) { return ( $ value !== $ model -> getKeyName ( ) ) ; } ) ; switch ( gettype ( $ model -> { $ field } ) ) { case 'string' : $ model -> { $ field } = $ model -> { $ field } . ' updated' ; break ; case 'boolean' : $ model -> { $ field } = ! $ model -> { $ field } ; break ; case 'integer' : case 'NULL' : default : $ model -> { $ field } = $ model -> { $ field } + 1 ; } return $ this ; }
Makes a generic update on the first fillable attribute but avoiding the primary key .
2,765
public function getPolicyByHostname ( $ name ) { if ( ! $ this -> inventory -> hasHost ( $ name ) ) { return array ( ) ; } $ policy = array ( ) ; $ host = $ this -> inventory -> getHost ( $ name ) ; foreach ( $ this -> inventory -> getHostGroupsByHost ( $ host ) as $ group ) { $ policy = array_replace_recursive ( $ policy , $ group -> getFirewallPolicy ( ) ) ; } return array_replace_recursive ( $ policy , $ host -> getFirewallPolicy ( ) ) ; }
Get the firewall policy for the named host .
2,766
private function getInstanceHelper ( $ config ) { if ( is_callable ( $ config ) ) { return $ config ; } if ( ! isset ( $ config [ 'class_name' ] ) ) { throw new Exception \ RuntimeException ( 'Config router convert miss "class_name"' ) ; } $ className = $ config [ 'class_name' ] ; if ( ! class_exists ( $ className ) ) { throw new Exception \ RuntimeException ( sprintf ( '"%s" is not existed' , $ className ) ) ; } $ object = new $ className ; return $ object ; }
Base on config for convertion get callable
2,767
protected function setHttpMethods ( Route $ route , array $ httpMethods ) { foreach ( $ httpMethods as $ idx => $ method ) { $ httpMethods [ $ idx ] = strtoupper ( $ method ) ; } $ route -> via ( $ httpMethods ) ; }
Set Http methods constraints for router
2,768
public function addRoute ( $ name , array $ routeInfo ) { if ( ! isset ( $ routeInfo [ 'route' ] ) || ! isset ( $ routeInfo [ 'definitions' ] ) ) { $ errMsg = 'Not found required configs for router. Maybe miss "route" or "definitions"' ; throw new Exception \ InvalidArgumentException ( $ errMsg ) ; } $ route = $ this -> add ( $ routeInfo [ 'route' ] , $ routeInfo [ 'definitions' ] ) ; $ route -> setName ( $ name ) ; if ( isset ( $ routeInfo [ 'convertions' ] ) ) { $ this -> setConvertions ( $ route , $ routeInfo [ 'convertions' ] ) ; } if ( isset ( $ routeInfo [ 'before_match' ] ) ) { $ this -> setBeforeMatch ( $ route , $ routeInfo [ 'before_match' ] ) ; } if ( isset ( $ routeInfo [ 'host_name' ] ) ) { $ route -> setHostname ( $ routeInfo [ 'host_name' ] ) ; } if ( isset ( $ routeInfo [ 'methods' ] ) ) { $ this -> setHttpMethods ( $ route , $ routeInfo [ 'methods' ] ) ; } }
Add route by array config
2,769
public function setConnectionParameters ( string $ driver = 'mysql' , string $ host , string $ database , string $ user , string $ pass ) { $ this -> driver = $ driver ; $ this -> host = $ host ; $ this -> database = $ database ; $ this -> user = $ user ; $ this -> pass = $ pass ; }
Setup the connection parameters for PDO
2,770
public function generateNewPDO ( ) : \ PDO { if ( $ this -> validateConfig ( ) ) { $ dns = $ this -> driver . ':dbname=' . $ this -> database . ";host=" . $ this -> host ; return new \ PDO ( $ dns , $ this -> user , $ this -> pass ) ; } else { throw ( new \ Exception ( "Invalid or missing database connection parameters" ) ) ; } }
Generate a new PDO instance using validated parameters or throw an Exception
2,771
private function calculateLanguagesPercentage ( $ languages ) { $ total = $ languages -> sum ( 'count' ) ; return $ languages -> transform ( function ( $ item ) use ( $ total ) { return $ item + [ 'percentage' => round ( ( $ item [ 'count' ] / $ total ) * 100 , 2 ) ] ; } ) ; }
Calculate the languages percentage .
2,772
public function editPage ( $ title , $ section = null , $ sectiontitle = null , $ text = null , $ summary = null ) { $ token = $ this -> getToken ( $ title , 'edit' ) ; $ path = '?action=edit' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'section' => $ section , 'sectiontitle' => $ section , 'text' => $ text , 'summary' => $ summary , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to edit a page .
2,773
public function undeletePage ( $ title , $ reason = null , $ timestamp = null , $ watchlist = null ) { $ token = $ this -> getToken ( $ title , 'undelete' ) ; $ path = '?action=undelete' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'reason' => $ reason , 'timestamp' => $ timestamp , 'watchlist' => $ watchlist , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to restore certain revisions of a deleted page .
2,774
public function movePageByName ( $ from , $ to , $ reason = null , $ movetalk = null , $ movesubpages = null , $ noredirect = null , $ watchlist = null , $ ignorewarnings = null ) { $ token = $ this -> getToken ( $ from , 'move' ) ; $ path = '?action=move' ; $ data = array ( 'from' => $ from , 'to' => $ reason , 'token' => $ token , 'reason' => $ reason , 'movetalk' => $ movetalk , 'movesubpages' => $ movesubpages , 'noredirect' => $ noredirect , 'watchlist' => $ watchlist , 'ignorewarnings' => $ ignorewarnings , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to move a page .
2,775
public function rollback ( $ title , $ user , $ summary = null , $ markbot = null , $ watchlist = null ) { $ token = $ this -> getToken ( $ title , 'rollback' ) ; $ path = '?action=rollback' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'user' => $ user , 'expiry' => $ summary , 'markbot' => $ markbot , 'watchlist' => $ watchlist , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to undo the last edit to the page .
2,776
public function changeProtection ( $ title , $ protections , $ expiry = null , $ reason = null , $ cascade = null , $ watchlist = null ) { $ token = $ this -> getToken ( $ title , 'unblock' ) ; $ path = '?action=protect' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'protections' => $ protections , 'expiry' => $ expiry , 'reason' => $ reason , 'cascade' => $ cascade , 'watchlist' => $ watchlist , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to change the protection level of a page .
2,777
public function getPageInfo ( array $ titles , array $ inprop = null , array $ intoken = null , $ incontinue = null ) { $ path = '?action=query&prop=info' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( isset ( $ inprop ) ) { $ path .= '&inprop=' . $ this -> buildParameter ( $ inprop ) ; } if ( isset ( $ intoken ) ) { $ path .= '&intoken=' . $ this -> buildParameter ( $ intoken ) ; } if ( $ incontinue ) { $ path .= '&incontinue=' ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get basic page information .
2,778
public function getPageProperties ( array $ titles , $ ppcontinue = null , $ ppprop = null ) { $ path = '?action=query&prop=pageprops' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( $ ppcontinue ) { $ path .= '&ppcontinue=' ; } if ( isset ( $ ppprop ) ) { $ path .= '&ppprop=' . $ ppprop ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get various properties defined in the page content .
2,779
public function getRevisions ( array $ titles , array $ rvprop = null , $ rvparse = null , $ rvlimit = null ) { $ path = '?action=query&prop=revisions' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( isset ( $ rvprop ) ) { $ path .= '&rvprop=' . $ this -> buildParameter ( $ rvprop ) ; } if ( $ rvparse ) { $ path .= '&rvparse=' ; } if ( isset ( $ rvlimit ) ) { $ path .= '&rvlimit=' . $ rvlimit ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get a list of revisions .
2,780
public function getPageTemplates ( array $ titles , array $ tlnamespace = null , $ tllimit = null , $ tlcontinue = null , $ tltemplates = null , $ tldir = null ) { $ path = '?action=query&prop=templates' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( isset ( $ tlnamespace ) ) { $ path .= '&tlnamespace=' . $ this -> buildParameter ( $ tlnamespace ) ; } if ( isset ( $ tllimit ) ) { $ path .= '&tllimit=' . $ tllimit ; } if ( $ tlcontinue ) { $ path .= '&tlcontinue=' ; } if ( isset ( $ tltemplates ) ) { $ path .= '&tltemplates=' . $ tltemplates ; } if ( isset ( $ tldir ) ) { $ path .= '&tldir=' . $ tldir ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get all page templates from the given page .
2,781
public function getBackLinks ( $ bltitle , $ blpageid = null , $ blcontinue = null , array $ blnamespace = null , $ blfilterredirect = null , $ bllimit = null , $ blredirect = null ) { $ path = '?action=query&list=backlinks' ; if ( isset ( $ bltitle ) ) { $ path .= '&bltitle=' . $ bltitle ; } if ( isset ( $ blpageid ) ) { $ path .= '&blpageid=' . $ blpageid ; } if ( $ blcontinue ) { $ path .= '&blcontinue=' ; } if ( isset ( $ blnamespace ) ) { $ path .= '&blnamespace=' . $ this -> buildParameter ( $ blnamespace ) ; } if ( isset ( $ blfilterredirect ) ) { $ path .= '&blfilterredirect=' . $ blfilterredirect ; } if ( isset ( $ bllimit ) ) { $ path .= '&bllimit=' . $ bllimit ; } if ( $ blredirect ) { $ path .= '&blredirect=' ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get all pages that link to the given page .
2,782
public function getIWBackLinks ( $ iwbltitle , $ iwblprefix = null , $ iwblcontinue = null , $ iwbllimit = null , array $ iwblprop = null ) { $ path = '?action=query&list=iwbacklinks' ; if ( isset ( $ iwbltitle ) ) { $ path .= '&iwbltitle=' . $ iwbltitle ; } if ( isset ( $ iwblprefix ) ) { $ path .= '&iwblprefix=' . $ iwblprefix ; } if ( $ iwblcontinue ) { $ path .= '&iwblcontinue=' ; } if ( isset ( $ iwbllimit ) ) { $ path .= '&bllimit=' . $ iwbllimit ; } if ( isset ( $ iwblprop ) ) { $ path .= '&iwblprop=' . $ this -> buildParameter ( $ iwblprop ) ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get all pages that link to the given interwiki link .
2,783
public function getToken ( $ user , $ intoken ) { $ path = '?action=query&prop=info&intoken=' . $ intoken . '&titles=User:' . $ user ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , null ) ; return ( string ) $ this -> validateResponse ( $ response ) -> query -> pages -> page [ $ intoken . 'token' ] ; }
Method to get access token .
2,784
public function macroOnLoad ( MacroNode $ node , PhpWriter $ writer ) : string { if ( $ node -> args == '' ) { throw new CompileException ( 'Missing function name argument in {onLoad} macro.' ) ; } return $ writer -> write ( ' if($presenter->isAjax()) { echo "' . $ node -> args . '();"; }else{ echo "if (window.addEventListener) { window.addEventListener(\'load\', ' . $ node -> args . ', false); } else if (window.attachEvent) { window.attachEvent(\'onload\', ' . $ node -> args . '); } else { window.onload = ' . $ node -> args . '; }"; }' ) ; }
onLoad pro javascript
2,785
public function connect ( \ OtherCode \ FController \ Components \ Services $ services , \ OtherCode \ FController \ Components \ Registry $ storage , \ OtherCode \ FController \ Components \ Messages $ messages ) { if ( ! isset ( $ this -> services ) ) { $ this -> services = $ services ; } if ( ! isset ( $ this -> storage ) ) { $ this -> storage = $ storage ; } if ( ! isset ( $ this -> messages ) ) { $ this -> messages = $ messages ; } }
Load the services into the module if they have not loaded already
2,786
public function exists ( $ category , $ post ) { $ ds = DIRECTORY_SEPARATOR ; $ postPath = str_replace ( '/' , $ ds , $ category . $ ds . $ post ) ; $ fullPostPath = app_path ( ) . $ ds . 'lablog' . $ ds . $ postPath . '.post' ; if ( $ this -> fs -> exists ( $ fullPostPath ) ) { return true ; } return false ; }
Check that a post exists .
2,787
public function getAll ( $ category ) { $ ds = DIRECTORY_SEPARATOR ; $ category = str_replace ( '/' , $ ds , $ category ) ; $ path = app_path ( ) . $ ds . 'lablog' . $ ds . $ category ; $ posts = $ this -> fs -> files ( $ path ) ; $ allPosts = array ( ) ; foreach ( $ posts as $ post ) { if ( strpos ( $ post , '.post' ) === false ) { continue ; } $ postPath = str_replace ( '.post' , '' , $ post ) ; $ allPosts [ $ this -> modified ( $ post ) . rand ( ) ] = str_replace ( $ path , '' , $ postPath ) ; } krsort ( $ allPosts ) ; $ posts = array ( ) ; foreach ( $ allPosts as $ post ) { $ categoryExplode = explode ( $ ds , $ post ) ; $ post = array_pop ( $ categoryExplode ) ; $ posts [ ] = $ this -> getPost ( $ category , $ post ) ; } return $ posts ; }
Get all files from the blog of specified category .
2,788
public function newAction ( Request $ request ) { $ provincium = new Provincia ( ) ; $ form = $ this -> createForm ( 'Matudelatower\UbicacionBundle\Form\Type\ProvinciaType' , $ provincium ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ provincium ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'provincia_show' , array ( 'id' => $ provincium -> getId ( ) ) ) ; } return $ this -> render ( 'UbicacionBundle:provincia:new.html.twig' , array ( 'provincium' => $ provincium , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new Provincia entity .
2,789
public function showAction ( Provincia $ provincium ) { $ deleteForm = $ this -> createDeleteForm ( $ provincium ) ; return $ this -> render ( 'UbicacionBundle:provincia:show.html.twig' , array ( 'provincium' => $ provincium , 'delete_form' => $ deleteForm -> createView ( ) , ) ) ; }
Finds and displays a Provincia entity .
2,790
public function deleteAction ( Request $ request , Provincia $ provincium ) { $ form = $ this -> createDeleteForm ( $ provincium ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ provincium ) ; $ em -> flush ( ) ; } return $ this -> redirectToRoute ( 'provincia_index' ) ; }
Deletes a Provincia entity .
2,791
private function createDeleteForm ( Provincia $ provincium ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'provincia_delete' , array ( 'id' => $ provincium -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
Creates a form to delete a Provincia entity .
2,792
public function toast ( $ toast , $ displayTime = null , $ class = null ) { if ( ! $ toast instanceof Toast ) { $ toast = new Toast ( $ toast , $ displayTime , $ class ) ; } $ this -> container -> add ( $ toast ) ; return $ this ; }
Add a toast message
2,793
public static function romanToInt ( $ str = null ) { if ( is_null ( $ str ) ) { return null ; } if ( $ str == self :: $ romans_letters [ 0 ] ) { return 0 ; } if ( ! self :: isRomanNumber ( $ str ) ) { return false ; } $ result = 0 ; $ length = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ index = array_search ( $ str { $ i } , self :: $ romans_letters ) ; $ value = self :: $ romans_numbers [ $ index ] ; $ nextval = null ; if ( $ i < ( $ length - 1 ) ) { $ nextind = array_search ( $ str { $ i + 1 } , self :: $ romans_letters ) ; $ nextval = self :: $ romans_numbers [ $ nextind ] ; } $ result += ( ! is_null ( $ nextval ) && $ nextval > $ value ) ? - $ value : $ value ; } return $ result ; }
Get the integer equivalent from roman notation
2,794
public static function intToRoman ( $ a = null ) { if ( is_null ( $ a ) ) { return null ; } if ( $ a > 4999 ) { return null ; } if ( $ a == 0 ) { return self :: $ romans_letters [ 0 ] ; } $ a = ( string ) $ a ; $ ctt = '' ; $ counter = 1 ; for ( $ i = ( strlen ( $ a ) - 1 ) ; $ i >= 0 ; $ i -- ) { $ tmp_ctt = '' ; $ char = $ a { $ i } ; if ( $ char > 0 && $ char < 4 ) { $ index = array_search ( $ counter , self :: $ romans_numbers ) ; $ tmp_ctt .= str_pad ( self :: $ romans_letters [ $ index ] , $ char , self :: $ romans_letters [ $ index ] ) ; } elseif ( 3 < $ char && $ char < 9 ) { $ index = array_search ( $ counter , self :: $ romans_numbers ) ; if ( $ char == 4 ) { $ tmp_ctt .= self :: $ romans_letters [ $ index ] ; } $ tmp_ctt .= self :: $ romans_letters [ $ index + 1 ] ; if ( $ char > 5 ) { $ tmp_ctt .= str_pad ( self :: $ romans_letters [ $ index ] , ( $ char - 5 ) , self :: $ romans_letters [ $ index ] ) ; } } elseif ( $ char == 9 ) { $ index = array_search ( $ counter , self :: $ romans_numbers ) ; $ tmp_ctt .= self :: $ romans_letters [ $ index ] . self :: $ romans_letters [ $ index + 2 ] ; } $ counter = $ counter * 10 ; $ ctt = $ tmp_ctt . $ ctt ; } return $ ctt ; }
Get the roman notation of a number inferior to 5000
2,795
public static function get ( $ code = 200 ) { if ( isset ( self :: $ http_status_codes [ $ code ] ) ) { return ( self :: $ http_status_codes [ $ code ] ) ; } return ( false ) ; }
Take a http response code and return the textual representation
2,796
public function get ( $ index ) { $ index = intval ( $ index ) ; $ i = 0 ; foreach ( $ this -> getInnerIterator ( ) as $ v ) { if ( $ i == $ index ) { return $ v ; } $ i ++ ; } return null ; }
Get a value by numeric index .
2,797
public function callback ( Closure $ callback ) { foreach ( $ this -> getInnerIterator ( ) as $ key => $ value ) { yield $ callback ( $ value , $ key ) ; } }
Maps a callback over all entries .
2,798
public static function createXml ( $ nodeName , $ arr = [ ] , $ version = '1.0' , $ encoding = 'UTF-8' , $ formatOutput = true ) { $ class = new self ( $ version , $ encoding , $ formatOutput ) ; $ class -> xml -> appendChild ( $ class -> convert ( $ nodeName , $ arr ) ) ; return $ class -> xml ; }
This method converts an array to XML .
2,799
public static function getXmlString ( $ nodeName , $ arr = [ ] , $ version = '1.0' , $ encoding = 'UTF-8' , $ formatOutput = true ) { return self :: createXml ( $ nodeName , $ arr , $ version , $ encoding , $ formatOutput ) -> saveXML ( ) ; }
This method returns the string representation of DOMDocument .