idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
7,900
public function html2text ( $ html , $ advanced = false ) { if ( $ advanced ) { require_once 'extras/class.html2text.php' ; $ htmlconverter = new html2text ( $ html ) ; return $ htmlconverter -> get_text ( ) ; } return html_entity_decode ( trim ( strip_tags ( preg_replace ( '/<(head|title|style|script)[^>]*>.*?<\/\\1>/si' , '' , $ html ) ) ) , ENT_QUOTES , $ this -> CharSet ) ; }
Convert an HTML string into plain text .
7,901
public static function _mime_types ( $ ext = '' ) { $ mimes = array ( 'xl' => 'application/excel' , 'hqx' => 'application/mac-binhex40' , 'cpt' => 'application/mac-compactpro' , 'bin' => 'application/macbinary' , 'doc' => 'application/msword' , 'word' => 'application/msword' , 'class' => 'application/octet-stream' , 'dll' => 'application/octet-stream' , 'dms' => 'application/octet-stream' , 'exe' => 'application/octet-stream' , 'lha' => 'application/octet-stream' , 'lzh' => 'application/octet-stream' , 'psd' => 'application/octet-stream' , 'sea' => 'application/octet-stream' , 'so' => 'application/octet-stream' , 'oda' => 'application/oda' , 'pdf' => 'application/pdf' , 'ai' => 'application/postscript' , 'eps' => 'application/postscript' , 'ps' => 'application/postscript' , 'smi' => 'application/smil' , 'smil' => 'application/smil' , 'mif' => 'application/vnd.mif' , 'xls' => 'application/vnd.ms-excel' , 'ppt' => 'application/vnd.ms-powerpoint' , 'wbxml' => 'application/vnd.wap.wbxml' , 'wmlc' => 'application/vnd.wap.wmlc' , 'dcr' => 'application/x-director' , 'dir' => 'application/x-director' , 'dxr' => 'application/x-director' , 'dvi' => 'application/x-dvi' , 'gtar' => 'application/x-gtar' , 'php3' => 'application/x-httpd-php' , 'php4' => 'application/x-httpd-php' , 'php' => 'application/x-httpd-php' , 'phtml' => 'application/x-httpd-php' , 'phps' => 'application/x-httpd-php-source' , 'js' => 'application/x-javascript' , 'swf' => 'application/x-shockwave-flash' , 'sit' => 'application/x-stuffit' , 'tar' => 'application/x-tar' , 'tgz' => 'application/x-tar' , 'xht' => 'application/xhtml+xml' , 'xhtml' => 'application/xhtml+xml' , 'zip' => 'application/zip' , 'mid' => 'audio/midi' , 'midi' => 'audio/midi' , 'mp2' => 'audio/mpeg' , 'mp3' => 'audio/mpeg' , 'mpga' => 'audio/mpeg' , 'aif' => 'audio/x-aiff' , 'aifc' => 'audio/x-aiff' , 'aiff' => 'audio/x-aiff' , 'ram' => 'audio/x-pn-realaudio' , 'rm' => 'audio/x-pn-realaudio' , 'rpm' => 'audio/x-pn-realaudio-plugin' , 'ra' => 'audio/x-realaudio' , 'wav' => 'audio/x-wav' , 'bmp' => 'image/bmp' , 'gif' => 'image/gif' , 'jpeg' => 'image/jpeg' , 'jpe' => 'image/jpeg' , 'jpg' => 'image/jpeg' , 'png' => 'image/png' , 'tiff' => 'image/tiff' , 'tif' => 'image/tiff' , 'eml' => 'message/rfc822' , 'css' => 'text/css' , 'html' => 'text/html' , 'htm' => 'text/html' , 'shtml' => 'text/html' , 'log' => 'text/plain' , 'text' => 'text/plain' , 'txt' => 'text/plain' , 'rtx' => 'text/richtext' , 'rtf' => 'text/rtf' , 'vcf' => 'text/vcard' , 'vcard' => 'text/vcard' , 'xml' => 'text/xml' , 'xsl' => 'text/xml' , 'mpeg' => 'video/mpeg' , 'mpe' => 'video/mpeg' , 'mpg' => 'video/mpeg' , 'mov' => 'video/quicktime' , 'qt' => 'video/quicktime' , 'rv' => 'video/vnd.rn-realvideo' , 'avi' => 'video/x-msvideo' , 'movie' => 'video/x-sgi-movie' ) ; return ( array_key_exists ( strtolower ( $ ext ) , $ mimes ) ? $ mimes [ strtolower ( $ ext ) ] : 'application/octet-stream' ) ; }
Get the MIME type for a file extension .
7,902
public function set ( $ name , $ value = '' ) { try { if ( isset ( $ this -> $ name ) ) { $ this -> $ name = $ value ; } else { throw new phpmailerException ( $ this -> lang ( 'variable_set' ) . $ name , self :: STOP_CRITICAL ) ; } } catch ( Exception $ exc ) { $ this -> setError ( $ exc -> getMessage ( ) ) ; if ( $ exc -> getCode ( ) == self :: STOP_CRITICAL ) { return false ; } } return true ; }
Set or reset instance properties .
7,903
public static function runtime ( $ fnc = null , $ params = array ( ) ) { if ( is_null ( $ fnc ) ) { return static :: $ runtime_class ; } return call_user_func_array ( array ( static :: $ runtime_class , $ fnc ) , $ params ) ; }
get the current runtime class name or execute an function on the runtime class
7,904
public static function paths ( $ paths = null , $ define = true ) { if ( is_null ( $ paths ) ) { return static :: $ paths ; } foreach ( $ paths as $ key => $ path ) { static :: $ paths [ $ key ] = $ path ; if ( $ define === true ) { define ( strtoupper ( $ key ) . 'PATH' , $ path ) ; } } }
paths getter and setter
7,905
public static function directories ( $ dirs = null , $ define = true ) { if ( is_null ( $ dirs ) ) { return static :: $ directories ; } foreach ( $ dirs as $ key => $ dir ) { static :: $ directories [ $ key ] = $ dir ; if ( $ define === true ) { define ( 'CCDIR_' . strtoupper ( $ key ) , $ dir ) ; } } }
directories getter and setter
7,906
public static function wake ( $ environment ) { if ( ! is_null ( static :: $ environment ) ) { throw new CCException ( "ClanCats::wake - you cannot wake the application twice." ) ; } static :: $ environment = $ environment ; static :: $ config = CCConfig :: create ( 'main' ) ; CCError_Inspector :: info_callback ( 'ClanCatsFramework' , function ( ) { return array ( 'Runtime Class' => \ ClanCats :: runtime ( ) , 'CCF Version' => \ ClanCats :: version ( ) , 'CCF Environment' => \ ClanCats :: environment ( ) , 'Development env' => var_export ( \ ClanCats :: in_development ( ) , true ) , 'File extention' => EXT , 'Core namespace' => CCCORE_NAMESPACE , ) ; } ) ; CCError_Inspector :: info_callback ( 'CCF Paths' , array ( 'ClanCats' , 'paths' ) ) ; CCError_Inspector :: info_callback ( 'CCF Directories' , array ( 'ClanCats' , 'directories' ) ) ; CCError_Inspector :: info_callback ( 'Namespaces' , function ( ) { return \ CCFinder :: $ namespaces ; } ) ; }
start the ccf lifecycle
7,907
public static function wake_app ( $ app ) { static :: $ runtime_class = $ app ; \ CCFinder :: bind ( $ app , static :: $ paths [ 'app' ] . $ app . EXT ) ; $ response = $ app :: wake ( ) ; if ( $ response instanceof CCResponse ) { if ( static :: $ config -> send_app_wake_response ) { $ response -> send ( true ) ; die ; } } $ response = null ; if ( method_exists ( $ app , 'wake_' . static :: $ environment ) ) { $ response = call_user_func ( $ app . '::wake_' . static :: $ environment ) ; if ( $ response instanceof CCResponse ) { if ( static :: $ config -> send_app_wake_response ) { $ response -> send ( true ) ; die ; } } } CCRouter :: on ( $ app :: routes ( ) ) ; }
start the ccf app lifecycle
7,908
public function join ( Builder $ objBuilder , $ blnExpandSelection = false , iCondition $ objJoinCondition = null , Clause \ Select $ objSelect = null ) { $ objParentNode = $ this -> objParentNode ; if ( ! $ objParentNode ) { throw new Caller ( 'A column node must have a parent node.' ) ; } else { $ objParentNode -> join ( $ objBuilder , $ blnExpandSelection , $ objJoinCondition , $ objSelect ) ; } }
Join the node to the given query . Since this is a leaf node we pass on the join to the parent .
7,909
public function getAsManualSqlColumn ( ) { if ( $ this -> strTableName ) { return $ this -> strTableName . '.' . $ this -> strName ; } else { if ( ( $ this -> objParentNode ) && ( $ this -> objParentNode -> strTableName ) ) { return $ this -> objParentNode -> strTableName . '.' . $ this -> strName ; } else { return $ this -> strName ; } } }
Get the unaliased column name . For special situations like order by since you can t order by aliases .
7,910
public function getUserRolePermissions ( ) { $ roles = Role :: select ( 'id' , 'name' , 'label' ) -> get ( ) ; $ permissions = Permission :: select ( 'id' , 'name' , 'label' ) -> get ( ) ; return \ View :: make ( 'admin.permissions.role-assign-permissions' , [ 'roles' => $ roles , 'permissions' => $ permissions , 'title' => 'assign' , ] ) ; }
Display given permissions to role .
7,911
public function postUserRolePermissions ( Request $ request ) { $ this -> validate ( $ request , [ 'role' => 'required' , 'permissions' => 'required' ] ) ; $ role = Role :: with ( 'permissions' ) -> whereName ( $ request -> role ) -> first ( ) ; $ role -> permissions ( ) -> detach ( ) ; foreach ( $ request -> permissions as $ permission_name ) { $ permission = Permission :: whereName ( $ permission_name ) -> first ( ) ; $ role -> assign ( $ permission ) ; } \ Session :: flash ( 'flash_message' , 'Permission granted!' ) ; return \ Redirect :: route ( 'admin.assign-role-permissions' , [ ] ) ; }
Store given permissions to role .
7,912
public static function create ( $ paths , $ cache = null , $ debug = false ) { $ wise = new self ( $ debug ) ; if ( $ cache ) { $ wise -> setCacheDir ( $ cache ) ; } $ locator = new FileLocator ( $ paths ) ; $ resolver = new LoaderResolver ( array ( new Loader \ IniFileLoader ( $ locator ) , new Loader \ JsonFileLoader ( $ locator ) , new Loader \ PhpFileLoader ( $ locator ) , new Loader \ XmlFileLoader ( $ locator ) , new Loader \ YamlFileLoader ( $ locator ) , ) ) ; $ wise -> setCollector ( new Resource \ ResourceCollector ( ) ) ; $ wise -> setLoader ( new DelegatingLoader ( $ resolver ) ) ; $ resolver -> setResourceCollector ( $ wise -> getCollector ( ) ) ; $ resolver -> setWise ( $ wise ) ; return $ wise ; }
Creates a pre - configured instance of Wise .
7,913
public function load ( $ resource , $ type = null , $ require = false ) { if ( null === $ this -> loader ) { throw new LogicException ( 'No loader has been configured.' ) ; } if ( false === $ this -> loader -> supports ( $ resource , $ type ) ) { throw LoaderException :: format ( 'The resource "%s"%s is not supported by the loader.' , is_scalar ( $ resource ) ? $ resource : gettype ( $ resource ) , $ type ? " ($type)" : '' ) ; } if ( $ this -> cacheDir && $ this -> collector && is_string ( $ resource ) && ( false === strpos ( "\n" , $ resource ) ) && ( false === strpos ( "\r" , $ resource ) ) ) { $ cache = new ConfigCache ( $ this -> cacheDir . DIRECTORY_SEPARATOR . basename ( $ resource ) . '.cache' , $ this -> debug ) ; if ( $ cache -> isFresh ( ) ) { return require $ cache ; } } if ( $ this -> collector ) { $ this -> collector -> clearResources ( ) ; } $ data = $ this -> process ( $ this -> loader -> load ( $ resource , $ type ) , $ resource , $ type , $ require ) ; if ( isset ( $ cache ) ) { $ cache -> write ( '<?php return ' . var_export ( $ data , true ) . ';' , $ this -> collector -> getResources ( ) ) ; } return $ data ; }
Loads the configuration data from a resource .
7,914
public function loadFlat ( $ resource , $ type = null , $ require = false ) { return ArrayUtil :: flatten ( $ this -> load ( $ resource , $ type , $ require ) ) ; }
Loads the configuration data from a resource and returns it flattened .
7,915
public function setCollector ( ResourceCollectorInterface $ collector ) { $ this -> collector = $ collector ; if ( $ this -> loader ) { if ( $ this -> loader instanceof ResourceAwareInterface ) { $ this -> loader -> setResourceCollector ( $ collector ) ; } if ( $ this -> loader instanceof DelegatingLoader ) { $ resolver = $ this -> loader -> getResolver ( ) ; if ( $ resolver instanceof ResourceAwareInterface ) { $ resolver -> setResourceCollector ( $ collector ) ; } } } }
Sets the resource collector .
7,916
public function setGlobalParameters ( $ parameters ) { if ( ! is_array ( $ parameters ) && ! ( $ parameters instanceof ArrayAccess ) ) { throw new InvalidArgumentException ( 'The $parameters argument must be an array or array accessible object.' ) ; } $ this -> parameters = $ parameters ; }
Sets a list of global parameters .
7,917
public function setLoader ( LoaderInterface $ loader ) { $ this -> loader = $ loader ; if ( $ this -> collector && ( $ loader instanceof ResourceAwareInterface ) ) { $ loader -> setResourceCollector ( $ this -> collector ) ; } if ( $ loader instanceof WiseAwareInterface ) { $ loader -> setWise ( $ this ) ; } if ( $ loader instanceof DelegatingLoader ) { $ resolver = $ loader -> getResolver ( ) ; if ( $ this -> collector && ( $ resolver instanceof ResourceAwareInterface ) ) { $ resolver -> setResourceCollector ( $ this -> collector ) ; } if ( $ resolver instanceof WiseAwareInterface ) { $ resolver -> setWise ( $ this ) ; } } }
Sets a configuration loader .
7,918
private function process ( array $ data , $ resource , $ type , $ require ) { if ( $ this -> processor ) { if ( $ this -> processor instanceof ProcessorInterface ) { if ( $ this -> processor -> supports ( $ resource , $ type ) ) { $ data = $ this -> processor -> process ( $ data ) ; } elseif ( $ require ) { throw ProcessorException :: format ( 'The resource "%s"%s is not supported by the processor.' , is_string ( $ resource ) ? $ resource : gettype ( $ resource ) , $ type ? " ($type)" : '' ) ; } } else { $ processor = new Processor ( ) ; $ data = $ processor -> processConfiguration ( $ this -> processor , $ data ) ; } } elseif ( $ require ) { throw ProcessorException :: format ( 'No processor registered to handle any resource.' ) ; } return $ data ; }
Processes the configuration definition .
7,919
public static function create ( $ path ) { if ( is_null ( $ path ) ) { return new static ( ) ; } if ( substr ( $ path , 0 , 1 ) != '/' ) { $ path = ORBITPATH . $ path ; } if ( substr ( $ path , - 1 ) != '/' ) { $ path .= '/' ; } $ blueprint = $ path . 'blueprint.json' ; if ( ! file_exists ( $ blueprint ) ) { throw new CCException ( "CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}." ) ; } if ( ! $ blueprint_data = CCJson :: read ( $ blueprint ) ) { throw new CCException ( "CCOrbit_Ship::create - invalid blueprint at {$blueprint}." ) ; } return static :: blueprint ( $ blueprint_data , $ path ) ; }
create an new ship object from path
7,920
public static function blueprint ( $ data , $ path ) { if ( ! is_array ( $ data ) ) { throw new \ InvalidArgumentException ( "CCOrbit_Ship::blueprint - first argument has to be an array." ) ; } $ ship = new static ( ) ; $ name = $ data [ 'name' ] ; $ namespace = $ data [ 'namespace' ] ; if ( is_null ( $ name ) ) { $ name = basename ( $ path ) ; } if ( $ namespace === true ) { $ namespace = $ name ; } if ( is_string ( $ namespace ) ) { \ CCFinder :: bundle ( $ namespace , $ path ) ; $ class = $ namespace . '\\Ship' ; if ( class_exists ( $ class ) ) { $ ship = new $ class ( ) ; } } $ ship -> name = $ name ; $ ship -> path = $ path ; $ ship -> namespace = $ namespace ; foreach ( $ data as $ key => $ item ) { if ( property_exists ( $ ship , $ key ) ) { $ ship -> $ key = $ item ; } } if ( $ ship -> namespace === false ) { if ( is_null ( $ ship -> wake ) ) { $ ship -> wake = 'shipyard/wake' . EXT ; } if ( is_null ( $ ship -> install ) ) { $ ship -> install = 'shipyard/install' . EXT ; } if ( is_null ( $ ship -> uninstall ) ) { $ ship -> uninstall = 'shipyard/uninstall' . EXT ; } } elseif ( is_string ( $ ship -> namespace ) ) { if ( is_null ( $ ship -> wake ) ) { $ ship -> wake = 'Ship::wake' ; } if ( is_null ( $ ship -> install ) ) { $ ship -> install = 'Ship::install' ; } if ( is_null ( $ ship -> uninstall ) ) { $ ship -> uninstall = 'Ship::uninstall' ; } } return $ ship ; }
create new ship with given data
7,921
public function event ( $ event ) { if ( is_string ( $ this -> namespace ) ) { if ( strpos ( $ event , '::' ) !== false ) { $ callback = explode ( '::' , $ event ) ; $ class = $ this -> namespace . "\\" . $ callback [ 0 ] ; if ( class_exists ( $ class ) ) { call_user_func ( array ( $ this , $ callback [ 1 ] ) ) ; } } else { if ( is_file ( $ this -> path . $ event ) ) { require $ this -> path . $ event ; } } } else { if ( is_file ( $ this -> path . $ event ) ) { require $ this -> path . $ event ; } } }
run an event on this object
7,922
public function align ( $ direction = 'horizontal' , $ collapse = 'sm' , $ indent = 2 ) { if ( $ direction == 'collapse' ) { $ this -> align = '' ; } elseif ( $ direction == 'inline' ) { $ this -> align = 'form-inline' ; } else { $ this -> align = 'form-horizontal' ; $ this -> collapse = ( in_array ( $ collapse , array ( 'xs' , 'sm' , 'md' , 'lg' ) ) ) ? $ collapse : 'sm' ; $ this -> indent = ( is_numeric ( $ indent ) && $ indent > 0 && $ indent < 12 ) ? $ indent : 2 ; } }
Utilize any Bootstrap form style .
7,923
public function prompt ( $ place , $ html , $ required = false ) { switch ( $ place ) { case 'info' : case 'append' : $ this -> prompt [ $ place ] = $ html ; break ; case 'prepend' : $ this -> prompt [ 'prepend' ] = array ( 'html' => $ html , 'required' => ( bool ) $ required ) ; break ; } }
This is to add html tags or semicolons or asterisks or whatever you would like to all of the form s prompts .
7,924
public function submit ( $ submit = 'Submit' , $ reset = '' ) { $ buttons = func_get_args ( ) ; if ( substr ( $ submit , 0 , 1 ) != '<' ) { $ buttons [ 0 ] = $ this -> page -> tag ( 'button' , array ( 'type' => 'submit' , 'class' => array ( 'btn' , 'btn-primary' , str_replace ( 'input' , 'btn' , $ this -> input ) ) , 'data-loading-text' => 'Submitting...' , ) , $ submit ) ; } if ( isset ( $ buttons [ 1 ] ) && substr ( $ reset , 0 , 1 ) != '<' ) { $ buttons [ 1 ] = $ this -> page -> tag ( 'button' , array ( 'type' => 'reset' , 'class' => array ( 'btn' , 'btn-default' , str_replace ( 'input' , 'btn' , $ this -> input ) ) , ) , $ reset ) ; } return $ this -> field ( '' , implode ( ' ' , $ buttons ) ) ; }
Quickly adds a submit button to your form .
7,925
public function assignCryptographyEngine ( CryptographyEngine $ cryptographyEngine , $ email ) { $ this -> cryptographyEngine = $ cryptographyEngine ; $ this -> email = $ email ; }
assigns the cryptography engine
7,926
protected function resolveActionFromStdClass ( stdClass $ stdClass ) { if ( isset ( $ stdClass -> data ) ) $ stdClass -> data = $ this -> cryptographyEngine -> decrypt ( $ stdClass -> data , $ this -> email ) ; return Action :: createFromStdClass ( $ stdClass ) ; }
resolves an action from a stdClass
7,927
public function merge ( GDBackend $ image ) { imagealphablending ( $ this -> owner -> getImageResource ( ) , false ) ; imagesavealpha ( $ this -> owner -> getImageResource ( ) , true ) ; imagealphablending ( $ image -> getImageResource ( ) , false ) ; imagesavealpha ( $ image -> getImageResource ( ) , true ) ; $ srcX = 0 ; $ srcY = 0 ; $ srcW = $ image -> getWidth ( ) ; $ srcH = $ image -> getHeight ( ) ; $ dstX = round ( ( $ this -> owner -> getWidth ( ) - $ srcW ) / 2 ) ; $ dstY = round ( ( $ this -> owner -> getHeight ( ) - $ srcH ) / 2 ) ; $ dstW = $ image -> getWidth ( ) ; $ dstH = $ image -> getHeight ( ) ; imagecopyresampled ( $ this -> owner -> getImageResource ( ) , $ image -> getImageResource ( ) , $ dstX , $ dstY , $ srcX , $ srcY , $ dstW , $ dstH , $ srcW , $ srcH ) ; $ output = clone $ this -> owner ; $ output -> setImageResource ( $ this -> owner -> getImageResource ( ) ) ; return $ output ; }
Merge two Images together
7,928
public function blur ( $ intensity ) { $ image = $ this -> owner -> getImageResource ( ) ; switch ( $ intensity ) { case 'light' : for ( $ x = 1 ; $ x <= 10 ; $ x ++ ) imagefilter ( $ image , IMG_FILTER_GAUSSIAN_BLUR ) ; break ; case 'strong' : for ( $ x = 1 ; $ x <= 40 ; $ x ++ ) imagefilter ( $ image , IMG_FILTER_GAUSSIAN_BLUR ) ; break ; case 'normal' : default : for ( $ x = 1 ; $ x <= 25 ; $ x ++ ) imagefilter ( $ image , IMG_FILTER_GAUSSIAN_BLUR ) ; break ; } $ output = clone $ this -> owner ; $ output -> setImageResource ( $ image ) ; return $ output ; }
blur the image
7,929
public function toJpeg ( $ backgroundColor , $ type ) { $ image = $ this -> owner -> getImageResource ( ) ; switch ( $ type ) { case IMAGETYPE_GIF : case IMAGETYPE_PNG : $ newGD = imagecreatetruecolor ( $ this -> owner -> getWidth ( ) , $ this -> owner -> getHeight ( ) ) ; $ bg = GDBackend :: color_web2gd ( $ newGD , $ backgroundColor ) ; imagefill ( $ newGD , 0 , 0 , $ bg ) ; imagealphablending ( $ newGD , TRUE ) ; imagecopy ( $ newGD , $ image , 0 , 0 , 0 , 0 , $ this -> owner -> getWidth ( ) , $ this -> owner -> getHeight ( ) ) ; break ; case IMAGETYPE_JPEG : $ newGD = $ image ; break ; } $ output = clone $ this -> owner ; $ output -> setImageResource ( $ newGD ) ; return $ output ; }
convert to jpeg
7,930
public function createAdapter ( $ collection ) { if ( \ is_array ( $ collection ) ) { $ className = 'Array' ; } else { try { $ r = new \ ReflectionClass ( $ collection ) ; $ className = $ r -> getName ( ) ; } catch ( \ ReflectionException $ exc ) { throw new AdapterNotSupportedException ( $ collection ) ; } } $ adapterName = __NAMESPACE__ . "\\" . $ className . 'Adapter' ; return new $ adapterName ( $ collection ) ; }
This method recieve a data collection and returns the corresponding adapter .
7,931
public function appendConfiguration ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> children ( ) -> arrayNode ( 'vcs' ) -> children ( ) -> scalarNode ( 'url' ) -> end ( ) -> arrayNode ( 'export' ) -> children ( ) -> scalarNode ( 'revfile' ) -> isRequired ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; }
Appends Git configuration options
7,932
protected function setRegistryWritableFalse ( ) { foreach ( $ this -> lookup_pool as $ reg ) { if ( $ reg instanceof WritableInterface && ! $ reg -> setWritable ( false ) ) { return false ; } } return true ; }
Set writable to FALSE in all registries
7,933
public function setQuad ( Quad $ quad ) { $ quad -> checkId ( ) ; $ quad -> setScriptEvents ( true ) ; $ this -> quad = $ quad ; return $ this ; }
Set the CheckBox Quad
7,934
public static function write ( $ path , $ content ) { static :: mkdir ( $ path ) ; if ( file_put_contents ( $ path , $ content , LOCK_EX ) === false ) { if ( static :: _can_print ( ) ) { CCCli :: line ( CCCli :: color ( 'failure' , 'red' ) . ' creating ' . $ path ) ; } return false ; } if ( static :: _can_print ( ) ) { CCCli :: line ( CCCli :: color ( 'created' , 'green' ) . ' ' . $ path ) ; } return true ; }
save a file
7,935
public static function append ( $ path , $ content ) { if ( ! is_dir ( dirname ( $ path ) ) ) { if ( ! mkdir ( dirname ( $ path ) , 0755 , true ) ) { throw new CCException ( "CCFile - could not create directory: " . dirname ( $ path ) ) ; } } return file_put_contents ( $ path , $ content , LOCK_EX | FILE_APPEND ) ; }
append to a file
7,936
public static function delete ( $ path ) { $ success = false ; if ( file_exists ( $ path ) ) { $ success = unlink ( $ path ) ; } if ( static :: _can_print ( ) ) { if ( $ success ) { CCCli :: line ( CCCli :: color ( 'removed' , 'green' ) . ' ' . $ path ) ; } else { CCCli :: line ( CCCli :: color ( 'removing failure' , 'red' ) . ' ' . $ path ) ; } } return $ success ; }
Delete a file This function is going to remove a file from your filesystem
7,937
public static function upload ( $ key , $ path ) { if ( $ file = static :: upload_path ( $ key ) ) { return move_uploaded_file ( $ file , $ path ) ; } return false ; }
Move user uploads to another dir
7,938
public static function _init ( ) { if ( ClanCats :: in_development ( ) ) { CCEvent :: mind ( 'response.output' , function ( $ output ) { if ( strpos ( $ output , '</body>' ) === false ) { return $ output ; } $ table = \ UI \ Table :: create ( array ( 'style' => array ( 'width' => '100%' , ) , 'cellpadding' => '5' , 'class' => 'table debug-table debug-table-errors' , ) ) ; $ table -> header ( array ( '#' , 'message' , 'file' ) ) ; foreach ( \ CCError :: $ non_fatals as $ key => $ item ) { $ table -> row ( array ( $ key + 1 , $ item -> getMessage ( ) , CCStr :: strip ( $ item -> getFile ( ) , CCROOT ) . ':' . $ item -> getLine ( ) , ) ) ; } return str_replace ( '</body>' , $ table . "\n</body>" , $ output ) ; } ) ; } }
error class init
7,939
private static function is_fatal_level ( $ level ) { $ fatals = array ( E_ERROR , E_PARSE , E_CORE_ERROR , E_CORE_WARNING , E_COMPILE_ERROR , E_COMPILE_WARNING , E_DEPRECATED , ) ; if ( is_object ( ClanCats :: $ config ) && ClanCats :: $ config instanceof CCConfig ) { if ( in_array ( $ level , ClanCats :: $ config -> get ( 'error.fatal_levels' , $ fatals ) ) ) { return true ; } } return false ; }
check if a level is fatal
7,940
public static function error ( $ num , $ message , $ file , $ line ) { $ exception = new CCException ( static :: $ error_types [ $ num ] . " - " . $ message , 0 , $ num , $ file , $ line ) ; if ( static :: is_fatal_level ( $ num ) ) { if ( static :: $ in_shutdown_process ) { static :: exception ( $ exception ) ; } else { throw $ exception ; } } else { static :: $ non_fatals [ ] = $ exception ; } }
The error handler converts PHP errors to CCExceptions . These get handled by the CCError exception handler .
7,941
public function init ( ) { parent :: init ( ) ; if ( ! empty ( $ this -> theme ) && ! in_array ( $ this -> theme , $ this -> _supportedThemes ) ) { throw new InvalidConfigException ( 'Unsupported built-in theme : ' . $ this -> theme ) ; } if ( isset ( $ this -> pluginOptions [ 'animation' ] ) && ! in_array ( $ this -> pluginOptions [ 'animation' ] , $ this -> _supportedAnimation ) ) { throw new InvalidConfigException ( 'Unsupported animation mode : ' . $ this -> pluginOptions [ 'animation' ] ) ; } }
Chekcs validity of theme and animation options
7,942
public function registerClientScript ( ) { $ view = $ this -> getView ( ) ; if ( isset ( $ this -> theme ) ) { $ path = $ view -> getAssetManager ( ) -> publish ( __DIR__ . '/assets/css/themes' ) ; $ view -> registerCSSFile ( $ path [ 1 ] . '/' . $ this -> theme . '.css' ) ; if ( $ this -> theme == 'image' && isset ( $ this -> pluginOptions [ 'scrollText' ] ) ) { $ this -> pluginOptions [ 'scrollText' ] = '' ; } } ScrollupAsset :: register ( $ view ) ; $ options = empty ( $ this -> pluginOptions ) ? '{}' : Json :: encode ( $ this -> pluginOptions ) ; $ js = "$.scrollUp($options);" ; $ view -> registerJs ( $ js ) ; }
Registers the needed JavaScript and inject the JS initialization code .
7,943
public function getLocation ( $ position ) { $ pattern = '/\r\n|[\n\r\u2028\u2029]/g' ; $ subject = mb_substr ( $ this -> body , 0 , $ position , 'UTF-8' ) ; preg_match_all ( $ pattern , $ subject , $ matches , PREG_OFFSET_CAPTURE ) ; $ location = array_reduce ( $ matches [ 0 ] , function ( $ carry , $ match ) use ( $ position ) { return [ $ carry [ 0 ] + 1 , $ position + 1 - ( $ match [ 1 ] + mb_strlen ( $ match [ 0 ] , 'UTF-8' ) ) ] ; } , [ 1 , $ position + 1 ] ) ; return new SourceLocation ( $ location [ 0 ] , $ location [ 1 ] ) ; }
Takes a Source and a UTF - 8 character offset and returns the corresponding line and column as a SourceLocation .
7,944
public function addChild ( & $ child ) { JLog :: add ( 'JNode::addChild() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; if ( $ child instanceof Jnode ) { $ child -> setParent ( $ this ) ; } }
Add child to this node
7,945
public function setParent ( & $ parent ) { JLog :: add ( 'JNode::setParent() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; if ( $ parent instanceof JNode || is_null ( $ parent ) ) { $ hash = spl_object_hash ( $ this ) ; if ( ! is_null ( $ this -> _parent ) ) { unset ( $ this -> _parent -> children [ $ hash ] ) ; } if ( ! is_null ( $ parent ) ) { $ parent -> _children [ $ hash ] = & $ this ; } $ this -> _parent = & $ parent ; } }
Set the parent of a this node
7,946
private function registerFactories ( ContainerBuilder $ container , Definition $ clientService , $ clientName ) { $ container -> setDefinition ( sprintf ( 'kch_sms_api.sms_factory.%s' , $ clientName ) , new Definition ( '%kch_sms_api.sms_factory.class%' ) ) -> addMethodCall ( 'setClient' , array ( $ clientService ) ) -> addTag ( 'kch_sms_api.factory' , array ( 'alias' => 'kch_sms_api_factory' ) ) ; $ container -> setDefinition ( sprintf ( 'kch_sms_api.mms_factory.%s' , $ clientName ) , new Definition ( '%kch_sms_api.mms_factory.class%' ) ) -> addMethodCall ( 'setClient' , array ( $ clientService ) ) -> addTag ( 'kch_sms_api.factory' , array ( 'alias' => 'kch_sms_api_factory' ) ) ; $ container -> setDefinition ( sprintf ( 'kch_sms_api.vms_factory.%s' , $ clientName ) , new Definition ( '%kch_sms_api.vms_factory.class%' ) ) -> addMethodCall ( 'setClient' , array ( $ clientService ) ) -> addTag ( 'kch_sms_api.factory' , array ( 'alias' => 'kch_sms_api_factory' ) ) ; $ container -> setDefinition ( sprintf ( 'kch_sms_api.sender_factory.%s' , $ clientName ) , new Definition ( '%kch_sms_api.sender_factory.class%' ) ) -> addMethodCall ( 'setClient' , array ( $ clientService ) ) -> addTag ( 'kch_sms_api.factory' , array ( 'alias' => 'kch_sms_api_factory' ) ) ; $ container -> setDefinition ( sprintf ( 'kch_sms_api.contacts_factory.%s' , $ clientName ) , new Definition ( '%kch_sms_api.contacts_factory.class%' ) ) -> addMethodCall ( 'setClient' , array ( $ clientService ) ) -> addTag ( 'kch_sms_api.factory' , array ( 'alias' => 'kch_sms_api_factory' ) ) ; }
Method register all library factories for Client .
7,947
public function isMetaProperty ( $ property ) { if ( array_key_exists ( $ property -> getName ( ) , $ this -> forcedMetaProperties ) ) return $ this -> forcedMetaProperties [ $ property -> getName ( ) ] ; return TRUE ; }
Soll dsa Property z . b . im SetMetaGetter genannt werden?
7,948
public function get ( $ key , $ default = null ) { if ( ! isset ( $ this -> GET [ $ key ] ) ) { return $ default ; } return $ this -> GET [ $ key ] ; }
get a GET param
7,949
public function post ( $ key , $ default = null ) { if ( ! isset ( $ this -> POST [ $ key ] ) ) { return $ default ; } return $ this -> POST [ $ key ] ; }
get a POST param
7,950
public function server ( $ key , $ default = null ) { if ( ! isset ( $ this -> SERVER [ strtoupper ( $ key ) ] ) ) { return $ default ; } return $ this -> SERVER [ strtoupper ( $ key ) ] ; }
get a SERVER param
7,951
public function file ( $ key , $ default = null ) { if ( ! isset ( $ this -> FILES [ $ key ] ) ) { return $ default ; } return $ this -> FILES [ $ key ] ; }
get a FILE param
7,952
public function client ( $ key = null ) { if ( is_null ( $ this -> client ) ) { $ this -> client = new \ stdClass ; if ( $ this -> has_server ( 'HTTP_CF_CONNECTING_IP' ) ) { $ this -> client -> ip = $ this -> server ( 'HTTP_CF_CONNECTING_IP' ) ; } elseif ( $ this -> has_server ( 'HTTP_X_FORWARDED_FOR' ) ) { $ this -> client -> ip = $ this -> server ( 'HTTP_X_FORWARDED_FOR' ) ; } elseif ( $ this -> has_server ( 'HTTP_CLIENT_IP' ) ) { $ this -> client -> ip = $ this -> server ( 'HTTP_CLIENT_IP' ) ; } else { $ this -> client -> ip = $ this -> server ( 'REMOTE_ADDR' , '127.0.0.1' ) ; } $ this -> client -> agent = $ this -> server ( 'HTTP_USER_AGENT' , '' ) ; $ this -> client -> port = $ this -> server ( 'REMOTE_PORT' , '' ) ; $ this -> client -> fingerprint = CCStr :: hash ( $ this -> client ( 'agent' ) . $ this -> client ( 'ip' ) ) ; $ this -> client -> language = CCLang :: set_current ( $ this -> server ( 'HTTP_ACCEPT_LANGUAGE' ) ) ; } if ( is_null ( $ key ) ) { return $ this -> client ; } return $ this -> client -> { $ key } ; }
get the client data
7,953
public function method ( $ is = null ) { if ( ! is_null ( $ is ) ) { return strtoupper ( $ is ) === $ this -> method ( ) ; } return strtoupper ( $ this -> server ( 'HTTP_X_HTTP_METHOD_OVERRIDE' , $ this -> server ( 'REQUEST_METHOD' , 'GET' ) ) ) ; }
get the current requesting method GET POST PUT DELETE
7,954
public function uri ( $ full = false ) { if ( is_null ( $ this -> uri ) ) { $ this -> uri = $ this -> server ( 'REQUEST_URI' , '/' ) ; $ this -> uri = preg_replace ( '/(\/+)/' , '/' , $ this -> uri ) ; if ( ! $ full ) { $ this -> uri = CCStr :: cut ( $ this -> uri , '?' ) ; } $ this -> uri = substr ( $ this -> uri , strlen ( ClanCats :: $ config -> get ( 'url.path' ) ) ) ; if ( ! $ this -> uri ) { $ this -> uri = '' ; } } return $ this -> uri ; }
get the requestet uri
7,955
public function connect ( $ conf ) { $ connection_params = array ( ) ; foreach ( $ conf as $ key => $ value ) { if ( is_string ( $ value ) ) { $ connection_params [ '{' . $ key . '}' ] = $ value ; } } $ connection_string = \ CCStr :: replace ( $ this -> connection_string , $ connection_params ) ; $ this -> connection = new \ PDO ( $ connection_string , $ conf [ 'user' ] , $ conf [ 'pass' ] , $ this -> connection_attributes ( $ conf ) ) ; $ this -> connection -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; return true ; }
connect to database
7,956
public static function __callHandler ( $ index , $ value , array $ handler ) { $ promise = $ handler [ 0 ] ; if ( $ promise -> getState ( ) !== self :: PENDING ) { return ; } try { if ( isset ( $ handler [ $ index ] ) ) { $ promise -> resolve ( call_user_func ( $ handler [ $ index ] , $ value ) ) ; } elseif ( $ index === 1 ) { $ promise -> resolve ( $ value ) ; } else { $ promise -> reject ( $ value ) ; } } catch ( \ Throwable $ reason ) { $ promise -> reject ( $ reason ) ; } catch ( \ Exception $ reason ) { $ promise -> reject ( $ reason ) ; } }
Call a stack of handlers using a specific callback index and value .
7,957
public function _add_localize_script ( ) { $ handle = get_template ( ) ; if ( ! wp_script_is ( get_template ( ) ) && wp_script_is ( get_stylesheet ( ) ) ) { $ handle = get_stylesheet ( ) ; } $ handle = apply_filters ( 'inc2734_wp_share_buttons_localize_script_handle' , $ handle ) ; wp_localize_script ( $ handle , 'inc2734_wp_share_buttons_' . $ this -> service_name , [ 'endpoint' => admin_url ( 'admin-ajax.php' ) , 'action' => 'inc2734_wp_share_buttons_' . $ this -> service_name , '_ajax_nonce' => wp_create_nonce ( $ this -> _get_nonce_key ( ) ) , ] ) ; }
Setup localize script
7,958
public function get ( $ key = null ) { if ( Arr :: key ( $ key , $ this -> _data ) ) { return $ this -> _data [ $ key ] ; } return $ this -> _data ; }
Get replacement val or all list .
7,959
public function set ( $ key , $ val ) { $ this -> _data = Hash :: merge ( [ $ key => $ val ] , $ this -> _data ) ; return $ this ; }
Add new value in list .
7,960
public function text ( $ text ) { foreach ( $ this -> _data as $ macros => $ value ) { $ macros = '{' . $ macros . '}' ; $ text = preg_replace ( '#' . $ macros . '#ius' , $ value , $ text ) ; } return $ text ; }
Get replacement text .
7,961
public function exception ( $ exception , $ user_message = null ) { if ( $ exception instanceof \ Exception == false ) { return $ this -> error ( 'unknown exception format' , response :: STATUS_INTERNAL_SERVER_ERROR ) ; } $ exception_class = bootstrap :: get_library ( 'exception' ) ; $ this -> data [ 'exception' ] [ 'current' ] = $ exception ; $ this -> data [ 'exception' ] [ 'current_trace_string' ] = $ exception_class :: clean_paths ( nl2br ( $ exception -> getTraceAsString ( ) ) ) ; $ previous = $ exception -> getPrevious ( ) ; if ( $ previous ) { $ this -> data [ 'exception' ] [ 'previous' ] = $ previous ; $ this -> data [ 'exception' ] [ 'previous_trace_string' ] = $ exception_class :: clean_paths ( nl2br ( $ previous -> getTraceAsString ( ) ) ) ; } $ reason = $ exception -> getMessage ( ) ; $ code = $ exception -> getCode ( ) ; $ this -> error ( $ reason , $ code , $ user_message ) ; }
show an error page using an exception
7,962
public function error ( $ reason = null , $ code = response :: STATUS_INTERNAL_SERVER_ERROR , $ user_message = null ) { $ response = bootstrap :: get_library ( 'response' ) ; $ error_data = [ 'status_code' => $ code , 'status_message' => $ response :: get_status_message ( $ code ) , ] ; $ error_data [ 'status_code_is_' . $ code ] = true ; if ( $ user_message ) { $ error_data [ 'user_message' ] = $ user_message ; } if ( ENVIRONMENT == 'development' ) { $ error_data [ 'development' ] = true ; if ( $ reason ) { $ error_data [ 'reason' ] = $ reason ; } } if ( ! empty ( $ this -> data [ 'exception' ] [ 'current' ] ) ) { if ( $ this -> data [ 'exception' ] [ 'current' ] instanceof \ alsvanzelf \ fem \ exception ) { if ( empty ( $ error_data [ 'user_message' ] ) ) { $ error_data [ 'user_message' ] = $ this -> data [ 'exception' ] [ 'current' ] -> getUserMessage ( ) ; } $ error_data [ 'user_action' ] = $ this -> data [ 'exception' ] [ 'current' ] -> getUserAction ( ) ; } if ( ENVIRONMENT != 'development' ) { unset ( $ this -> data [ 'exception' ] ) ; } } $ response :: send_status ( $ code ) ; if ( empty ( static :: $ default_error_template ) ) { $ page_data = [ 'error' => $ error_data , ] ; if ( ! empty ( $ this -> data [ 'exception' ] ) ) { $ page_data [ 'exception' ] = $ this -> data [ 'exception' ] ; } static :: show_default_error ( $ page_data ) ; } else { $ this -> data [ 'title' ] = $ error_data [ 'status_message' ] ; $ this -> data [ 'error' ] = $ error_data ; $ this -> show ( static :: $ default_error_template ) ; } die ; }
show an error page
7,963
private static function show_default_error ( $ error_data ) { $ template_path = \ alsvanzelf \ fem \ ROOT_DIR . 'vendor/alsvanzelf/fem/src/templates/default_error.html' ; $ template_content = file_get_contents ( $ template_path ) ; $ renderer = new \ Mustache_Engine ( ) ; echo $ renderer -> render ( $ template_content , $ error_data ) ; }
shows a default error template in case no specific one is set
7,964
protected static function __orCombinator ( array $ fs , $ a ) { return self :: any ( Arrays :: map ( function ( $ c ) use ( $ a ) { return $ c ( $ a ) ; } , $ fs ) ) ; }
Logical Or Combinator
7,965
protected static function __andCombinator ( array $ fs , $ a ) { return self :: all ( Arrays :: map ( function ( $ c ) use ( $ a ) { return $ c ( $ a ) ; } , $ fs ) ) ; }
Logical And Combinator
7,966
public function loadAllowance ( $ request , $ action ) { $ allowance = Yii :: $ app -> cache -> get ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id . '_allowance' ) ; $ allowanceUpdatedAt = Yii :: $ app -> cache -> get ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id . '_allowance_update_at' ) ; if ( $ allowance && $ allowanceUpdatedAt ) { return [ $ allowance , $ allowanceUpdatedAt ] ; } else { return [ Yii :: $ app -> settings -> get ( 'requestRateLimit' , 'user' , 60 ) , time ( ) ] ; } }
Loads the number of allowed requests and the corresponding timestamp from a persistent storage .
7,967
public function saveAllowance ( $ request , $ action , $ allowance , $ timestamp ) { Yii :: $ app -> cache -> set ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id . '_allowance' , $ allowance , 60 ) ; Yii :: $ app -> cache -> set ( $ action -> controller -> id . ':' . $ action -> id . ':' . $ this -> id . '_allowance_update_at' , $ timestamp , 60 ) ; }
Saves the number of allowed requests and the corresponding timestamp to a persistent storage .
7,968
public function rgbXY ( $ x , $ y ) { $ color = $ this -> colorXY ( $ x , $ y ) ; return array ( ( $ color >> 16 ) & 0xFF , ( $ color >> 8 ) & 0xFF , $ color & 0xFF ) ; }
Returns RGB array of pixel s color
7,969
public function create ( ) { switch ( $ this -> info [ 2 ] ) { case IMAGETYPE_JPEG : $ this -> resource = imagecreatefromjpeg ( $ this -> file ) ; break ; case IMAGETYPE_GIF : $ this -> resource = imagecreatefromgif ( $ this -> file ) ; break ; case IMAGETYPE_PNG : $ this -> resource = imagecreatefrompng ( $ this -> file ) ; break ; default : throw new Exception ( 'Image type is not supported' ) ; break ; } }
Create an image resource
7,970
public function save ( $ file , $ type = IMAGETYPE_JPEG , $ quality = 75 , $ permissions = false ) { $ dir = dirname ( $ file ) ; if ( ! file_exists ( $ dir ) ) { $ mask = umask ( ) ; mkdir ( $ dir , 0777 , true ) ; umask ( $ mask ) ; } switch ( $ type ) { case IMAGETYPE_JPEG : imagejpeg ( $ this -> resource , $ file , $ quality ) ; break ; case IMAGETYPE_GIF : imagegif ( $ this -> resource , $ file ) ; break ; case IMAGETYPE_PNG : imagepng ( $ this -> resource , $ file ) ; break ; default : throw new Exception ( 'Image type is not supported' ) ; break ; } if ( $ permissions !== false ) chmod ( $ file , $ permissions ) ; return $ this ; }
Save image to file
7,971
public function fitResize ( $ max_width = 150 , $ max_height = 150 , $ min_width = 20 , $ min_height = 20 ) { $ kw = $ max_width / $ this -> width ( ) ; $ kh = $ max_height / $ this -> height ( ) ; if ( $ kw > $ kh ) { $ new_h = $ max_height ; $ new_w = round ( $ kh * $ this -> width ( ) ) ; } else { $ new_w = $ max_width ; $ new_h = round ( $ kw * $ this -> height ( ) ) ; } $ this -> resize ( $ new_w , $ new_h ) ; return $ this ; }
Fit the image with the same proportion into an area
7,972
public function scaleResize ( $ width , $ height ) { $ kw = $ this -> width ( ) / $ width ; $ kh = $ this -> height ( ) / $ height ; if ( $ kh < $ kw ) { $ src_h = $ this -> height ( ) ; $ src_y = 0 ; $ src_w = round ( $ kh * $ width ) ; $ src_x = round ( ( $ this -> width ( ) - $ src_w ) / 2 ) ; } else { $ src_h = round ( $ kh * $ height ) ; $ src_y = round ( ( $ this -> height ( ) - $ src_h ) / 2 ) ; $ src_w = $ this -> width ( ) ; $ src_x = 0 ; } $ new = imagecreatetruecolor ( $ width , $ height ) ; imagecopyresampled ( $ new , $ this -> resource , 0 , 0 , $ src_x , $ src_y , $ width , $ height , $ src_w , $ src_h ) ; $ this -> resource = $ new ; return $ this ; }
Resize image correctly scaled and than crop the necessary area
7,973
public function getAttribute ( $ attributes , $ name ) { foreach ( $ attributes as $ a ) { if ( $ a -> key == $ name ) { return $ a -> value ; } } return null ; }
Returns the value of attribute with name
7,974
public function getAuthToken ( ) { try { $ response = $ this -> client -> request ( 'GET' , "authenticate/accessToken" , [ 'headers' => [ 'x-api-client-id' => $ this -> clientId , 'x-api-key' => $ this -> apiKey ] ] ) ; $ this -> authToken = json_decode ( $ response -> getBody ( ) ) -> token ; return $ this -> authToken ; } catch ( GuzzleHttp \ Exception \ RequestException $ e ) { $ this -> handleExceptionResult ( $ e ) ; } }
Gets an authorization token using the clients API key . Most requests to the SafeStream API require an authorization token .
7,975
protected function getReadableTime ( $ time , $ percision = 3 ) { $ unit = 's' ; if ( $ time < 1 ) { $ time *= 1000 ; $ percision = 0 ; $ unit = 'ms' ; } elseif ( $ time > 60 ) { $ time /= 60 ; $ unit = 'm' ; } $ time = number_format ( $ time , $ percision ) ; return "{$time} {$unit}" ; }
Formatter for human - readable time Only handles time up to 60 minutes gracefully
7,976
protected function getReadableMemory ( $ size , $ percision = 2 ) { $ unitOptions = array ( 'b' , 'k' , 'M' , 'G' ) ; $ base = log ( $ size , 1024 ) ; $ memory = round ( pow ( 1024 , $ base - floor ( $ base ) ) , $ percision ) ; $ unit = $ unitOptions [ floor ( $ base ) ] ; return "{$memory} {$unit}" ; }
Formatter for human - readable memory Only handles time up to a few gigs gracefully
7,977
public function addContentElement ( ApiElement $ element ) { $ newContent = [ ] ; $ rawElements = [ ] ; $ content = $ this -> getContent ( ) ; if ( $ this -> hasCopy ( ) ) { $ newContent [ ] = array_shift ( $ content ) ; } foreach ( $ content as $ resourceGroup ) { if ( ! is_array ( $ resourceGroup ) ) { $ newContent [ ] = array_shift ( $ content ) ; } else { $ rawElements [ ] = $ resourceGroup ; } } array_shift ( $ rawElements ) ; $ newContent [ ] = $ element ; $ this -> content = array_merge ( $ newContent , $ rawElements ) ; }
Add content element to the current content
7,978
public function getCopyText ( ) { $ content = $ this -> getContent ( ) ; $ copy = array_shift ( $ content ) ; if ( ! is_array ( $ copy ) ) { return null ; } if ( $ copy [ 'element' ] !== 'copy' ) { return null ; } return $ copy [ 'content' ] ; }
Get the copy text of the current element ; raw markdown likely
7,979
public function hasClass ( $ className ) { foreach ( $ this -> meta [ 'classes' ] as $ classInMeta ) { if ( $ classInMeta === $ className ) { return true ; } } return false ; }
Check whether or not this element has a given class
7,980
public function addTOC ( $ styleFont = null , $ styleTOC = null ) { $ toc = new PHPWord_TOC ( $ styleFont , $ styleTOC ) ; $ this -> _elementCollection [ ] = $ toc ; return $ toc ; }
Add a Table - of - Contents Element
7,981
public function addTitle ( $ text , $ depth = 1 ) { $ styles = PHPWord_Style :: getStyles ( ) ; if ( array_key_exists ( 'Heading_' . $ depth , $ styles ) ) { $ style = 'Heading' . $ depth ; } else { $ style = null ; } $ title = new PHPWord_Section_Title ( $ text , $ depth , $ style ) ; $ data = PHPWord_TOC :: addTitle ( $ text , $ depth ) ; $ anchor = $ data [ 0 ] ; $ bookmarkId = $ data [ 1 ] ; $ title -> setAnchor ( $ anchor ) ; $ title -> setBookmarkId ( $ bookmarkId ) ; $ this -> _elementCollection [ ] = $ title ; return $ title ; }
Add a Title Element
7,982
public function deleteContainers ( $ containers , $ force = false ) { if ( ! empty ( $ containers ) ) { if ( ! isset ( $ containers [ 0 ] ) ) { $ containers = [ $ containers ] ; } foreach ( $ containers as $ key => $ folder ) { try { $ name = array_get ( $ folder , 'name' , trim ( array_get ( $ folder , 'path' ) , '/' ) ) ; if ( ! empty ( $ name ) ) { $ this -> deleteContainer ( $ name , $ force ) ; } else { throw new DfException ( 'No name found for container in delete request.' ) ; } } catch ( \ Exception $ ex ) { $ containers [ $ key ] [ 'error' ] = [ 'message' => $ ex -> getMessage ( ) , 'code' => $ ex -> getCode ( ) ] ; } } } return $ containers ; }
Delete multiple containers and all of their content
7,983
public function msginitFile ( string $ filename ) : PoFile { if ( ! is_readable ( $ filename ) ) { $ source = false ; } else { $ source = file_get_contents ( $ filename ) ; } if ( false === $ source ) { throw new FileNotReadableException ( $ filename ) ; } return $ this -> msginitString ( $ source , $ filename ) ; }
Inspect the supplied source file capture gettext references as a PoFile object
7,984
public function escapeForPo ( string $ string ) : string { if ( $ string [ 0 ] == '"' || $ string [ 0 ] == "'" ) { $ string = substr ( $ string , 1 , - 1 ) ; } $ string = str_replace ( "\r\n" , "\n" , $ string ) ; $ string = stripcslashes ( $ string ) ; return addcslashes ( $ string , "\0..\37\"" ) ; }
Prepare a string from tokenized output for use in a po file . Remove any surrounding quotes escape control characters and double quotes .
7,985
public function checkPhpFormatFlag ( PoEntry $ entry ) : void { if ( preg_match ( '#(?<!%)%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]#' , $ entry -> get ( PoTokens :: MESSAGE ) . $ entry -> get ( PoTokens :: PLURAL ) ) ) { $ entry -> addFlag ( 'php-format' ) ; } }
Check the supplied entry for sprintf directives and set php - format flag if found
7,986
public function perform ( ) { $ declaration = $ this -> createDeclaration ( compact ( 'alias' ) ) ; $ declaration -> setAlias ( $ this -> argument ( 'alias' ) ?? $ this -> argument ( 'name' ) ) ; $ declaration -> setDescription ( ( string ) $ this -> option ( 'description' ) ) ; $ this -> writeDeclaration ( $ declaration ) ; }
Create command declaration .
7,987
public function isGroupCenterPresentOnce ( ExecutionContextInterface $ context ) { $ groupCentersIds = array ( ) ; foreach ( $ this -> getGroupCenters ( ) as $ groupCenter ) { if ( in_array ( $ groupCenter -> getId ( ) , $ groupCentersIds ) ) { $ context -> buildViolation ( "The user has already those permissions" ) -> addViolation ( ) ; } else { $ groupCentersIds [ ] = $ groupCenter -> getId ( ) ; } } }
This function check that groupCenter are present only once . The validator use this function to avoid a user to be associated to the same groupCenter more than once .
7,988
public static function stringStartsWith ( $ str , $ prefix ) { if ( is_array ( $ prefix ) ) { foreach ( $ prefix as $ p ) { if ( $ p === "" || strpos ( $ str , $ p ) === 0 ) { return true ; } ; } return false ; } return $ prefix === "" || strpos ( $ str , $ prefix ) === 0 ; }
Does a string start with another string?
7,989
public static function stringEndsWith ( $ str , $ postfix ) { if ( is_array ( $ postfix ) ) { foreach ( $ postfix as $ p ) { if ( $ p === "" || substr ( $ str , - strlen ( $ p ) ) === $ p ) { return true ; } } return false ; } return $ postfix === "" || substr ( $ str , - strlen ( $ postfix ) ) === $ postfix ; }
Does a string end with another string?
7,990
public function toArray ( ) { $ data = array ( 'name' => $ this -> name , 'hash' => $ this -> hash , 'phash' => $ this -> phash , 'mime' => $ this -> mime , 'ts' => $ this -> ts , 'size' => $ this -> size , 'dirs' => $ this -> dirs , 'read' => $ this -> read , 'write' => $ this -> write , 'locked' => $ this -> locked , 'tmb' => $ this -> tmb , 'alias' => $ this -> alias , 'thash' => $ this -> thash , 'dim' => $ this -> dim , 'volumeid' => $ this -> volumeid , 'path' => $ this -> path , 'url' => $ this -> url , ) ; return array_filter ( $ data , function ( $ var ) { return ! is_null ( $ var ) ; } ) ; }
FileInfo return as array .
7,991
public static function create ( $ quantity , $ productCode , $ description , $ amount , $ vat , $ currency = "EUR" ) { $ item = new LineItem ; $ item -> quantity = $ quantity ; $ item -> productCode = $ productCode ; $ item -> description = $ description ; $ item -> amount = $ amount ; $ item -> vat = $ vat ; $ item -> currency = $ currency ; return $ item ; }
LineItem creator .
7,992
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof CountryQuery ) { return $ criteria ; } $ query = new CountryQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
Returns a new CountryQuery object .
7,993
public function filterByEn ( $ en = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ en ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ en ) ) { $ en = str_replace ( '*' , '%' , $ en ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CountryPeer :: EN , $ en , $ comparison ) ; }
Filter the query on the en column
7,994
public function filterByDe ( $ de = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ de ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ de ) ) { $ de = str_replace ( '*' , '%' , $ de ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( CountryPeer :: DE , $ de , $ comparison ) ; }
Filter the query on the de column
7,995
public function addStyle ( Style $ style ) { if ( ! in_array ( $ style , $ this -> styles , true ) ) { array_push ( $ this -> styles , $ style ) ; } return $ this ; }
Add a new Style
7,996
public function addStyle3d ( Style3d $ style3d ) { if ( ! in_array ( $ style3d , $ this -> styles3d , true ) ) { array_push ( $ this -> styles3d , $ style3d ) ; } return $ this ; }
Add a new Style3d
7,997
public function getMood ( $ createIfEmpty = true ) { if ( ! $ this -> mood && $ createIfEmpty ) { $ this -> createMood ( ) ; } return $ this -> mood ; }
Get the Mood
7,998
public function createMood ( ) { if ( $ this -> mood ) { return $ this -> mood ; } $ mood = new Mood ( ) ; $ this -> setMood ( $ mood ) ; return $ this -> mood ; }
Create a new Mood if necessary
7,999
public function render ( \ DOMDocument $ domDocument ) { $ stylesheetXml = $ domDocument -> createElement ( "stylesheet" ) ; if ( $ this -> styles3d ) { $ stylesXml = $ domDocument -> createElement ( "frame3dstyles" ) ; $ stylesheetXml -> appendChild ( $ stylesXml ) ; foreach ( $ this -> styles3d as $ style3d ) { $ style3dXml = $ style3d -> render ( $ domDocument ) ; $ stylesXml -> appendChild ( $ style3dXml ) ; } } if ( $ this -> mood ) { $ moodXml = $ this -> mood -> render ( $ domDocument ) ; $ stylesheetXml -> appendChild ( $ moodXml ) ; } return $ stylesheetXml ; }
Render the Stylesheet