idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
11,800
public function sayHello ( ) { $ helloCommand = new Hello ( ) ; $ helloResponse = $ this -> connection -> execute ( $ helloCommand ) ; $ this -> hello = ( array ) $ helloCommand -> parse ( $ helloResponse ) ; $ this -> id = $ this -> hello [ HelloResponse :: NODE_ID ] ; $ this -> createPrefix ( $ this -> id ) ; $ this ...
Say a new HELLO to the node and parse the response
11,801
private function connectToTheNode ( ) { $ this -> connection -> connect ( $ this -> credentials -> getConnectionTimeout ( ) , $ this -> credentials -> getResponseTimeout ( ) ) ; }
Connect to the node
11,802
private function authenticateWithPassword ( ) { if ( $ this -> credentials -> havePassword ( ) ) { $ authCommand = new Auth ( ) ; $ authCommand -> setArguments ( [ $ this -> credentials -> getPassword ( ) ] ) ; $ authResponse = $ this -> connection -> execute ( $ authCommand ) ; $ response = $ authCommand -> parse ( $ ...
Authenticate with the node with a password if set
11,803
private function createPrefix ( $ id ) { $ this -> prefix = substr ( $ id , self :: PREFIX_START , self :: PREFIX_LENGTH ) ; }
Create a node prefix from the node ID
11,804
private function readPriorityFromHello ( $ hello , $ id ) { foreach ( $ hello [ HelloResponse :: NODES ] as $ node ) { if ( $ node [ HelloResponse :: NODE_ID ] === $ id ) { return $ node [ HelloResponse :: NODE_PRIORITY ] ; } } return self :: PRIORITY_FALLBACK ; }
Read out the node s own priority from a HELLO response
11,805
protected function checkFileName ( $ fileName ) { $ extension = strtolower ( pathinfo ( $ fileName , PATHINFO_EXTENSION ) ) ; $ allow = $ this -> getWhitelistedExtensions ( ) ; $ block = $ this -> getBlacklistedExtensions ( ) ; return ( ( false === $ allow || in_array ( $ extension , $ allow ) ) && ( false === $ block ...
Checks whether the file name is acceptable for upload .
11,806
protected function checkMimeType ( $ mimeType ) { $ allow = $ this -> getWhitelistedMimeTypes ( ) ; $ block = $ this -> getBlacklistedMimeTypes ( ) ; if ( false !== $ allow ) { foreach ( $ allow as $ pattern ) { if ( $ this -> wildCardMatch ( $ mimeType , $ pattern ) ) { return true ; } } return false ; } if ( false !=...
Checks whether the mimetype is acceptable for upload .
11,807
protected function getWhitelistedExtensions ( ) { $ allow = config ( 'cms-upload-module.upload.restrict.extensions.allow' , null ) ; if ( ! is_array ( $ allow ) || ! count ( $ allow ) ) { return false ; } return array_map ( 'trim' , array_map ( 'strtolower' , $ allow ) ) ; }
Returns whitelisted extensions or false if no whitelist is set .
11,808
protected function getBlacklistedExtensions ( ) { $ block = config ( 'cms-upload-module.upload.restrict.extensions.block' , null ) ; if ( ! is_array ( $ block ) || ! count ( $ block ) ) { return false ; } return array_map ( 'trim' , array_map ( 'strtolower' , $ block ) ) ; }
Returns blacklisted extensions or false if no whitelist is set .
11,809
protected function getWhitelistedMimeTypes ( ) { $ allow = config ( 'cms-upload-module.upload.restrict.mimetypes.allow' , null ) ; if ( ! is_array ( $ allow ) || ! count ( $ allow ) ) { return false ; } return array_map ( 'trim' , array_map ( 'strtolower' , $ allow ) ) ; }
Returns whitelisted mimetypes or false if no whitelist is set .
11,810
protected function getBlacklistedMimeTypes ( ) { $ block = config ( 'cms-upload-module.upload.restrict.mimetypes.block' , null ) ; if ( ! is_array ( $ block ) || ! count ( $ block ) ) { return false ; } return array_map ( 'trim' , array_map ( 'strtolower' , $ block ) ) ; }
Returns blacklisted mimetypes or false if no whitelist is set .
11,811
protected function wildCardMatch ( $ source , $ pattern ) { $ pattern = preg_quote ( $ pattern , '#' ) ; $ pattern = str_replace ( '\?' , '.?' , $ pattern ) ; $ pattern = str_replace ( '\*' , '.*?' , $ pattern ) ; return ( bool ) preg_match ( '#^' . $ pattern . '$#i' , $ source ) ; }
Returns whether a string matches against a wildcard pattern .
11,812
public function getPublicPath ( $ path = '' , $ raiseException = false ) { $ publicDir = $ this -> config -> get ( 'publicDir' , self :: PLUGIN_HANDLE ) ; $ publicPath = $ this -> ioHelper -> getRealPath ( $ publicDir . '/' . $ path ) ; if ( ! $ publicPath && $ raiseException ) { throw new Exception ( "{$publicPath} do...
Get a path relative to the site public directory
11,813
public function prefix ( string $ path , $ char = '/' ) { if ( ! $ this -> startsWith ( $ path , $ char ) ) { $ path = "{$char}{$path}" ; } return $ path ; }
Prefix character to path if not present
11,814
public static function fromPEM ( PEM $ pem ) { switch ( $ pem -> type ( ) ) { case PEM :: TYPE_RSA_PRIVATE_KEY : return RSA \ RSAPrivateKey :: fromDER ( $ pem -> data ( ) ) ; case PEM :: TYPE_EC_PRIVATE_KEY : return EC \ ECPrivateKey :: fromDER ( $ pem -> data ( ) ) ; case PEM :: TYPE_PRIVATE_KEY : return PrivateKeyInf...
Initialize private key from PEM .
11,815
public function handleException ( $ exception ) { Yii :: $ app -> bugsnag -> notifyException ( $ exception ) ; $ this -> inExceptionHandler = true ; parent :: handleException ( $ exception ) ; }
Ensures CB logs are written to the DB if an exception occurs
11,816
public function handleFatalError ( ) { if ( is_object ( Yii :: $ app ) ) { Yii :: $ app -> bugsnag -> runShutdownHandler ( ) ; } parent :: handleFatalError ( ) ; }
Handles fatal PHP errors
11,817
public function updateCMSFields ( FieldList $ fields ) { $ excluded = $ this -> owner -> getExcludedSiteTreeClassNames ( ) ; if ( ! empty ( $ excluded ) ) { $ pages = SiteTree :: get ( ) -> filter ( array ( 'ParentID' => $ this -> owner -> ID , 'ClassName' => $ excluded ) ) ; $ gridField = new GridField ( "ChildPages" ...
This is responsible for adding the child pages tab and gridfield .
11,818
public function onParseTemplate ( Template $ template ) : void { if ( ! $ this -> environment -> isEnabled ( ) ) { return ; } $ this -> initialize ( ) ; if ( $ this -> isAutoMappingDisabled ( $ template -> getName ( ) ) ) { return ; } $ templateName = $ this -> getMappedTemplateName ( $ template -> getName ( ) ) ; if (...
Handle the on parse template hook .
11,819
private function initialize ( ) : void { if ( $ this -> mapping === null ) { $ this -> mapping = $ this -> environment -> getConfig ( ) -> get ( 'templates.mapping' , [ ] ) ; } }
Initialize the mapping configuration .
11,820
private function getMappedTemplateName ( string $ templateName ) : ? string { if ( isset ( $ this -> mapping [ 'mandatory' ] [ $ templateName ] ) ) { return $ this -> mapping [ 'mandatory' ] [ $ templateName ] ; } if ( isset ( $ this -> mapping [ 'optional' ] [ $ templateName ] ) ) { return $ this -> mapping [ 'optiona...
Get the mapped template name . Returns null if not mapped .
11,821
private function isAutoMappingDisabled ( string $ templateName ) : bool { if ( isset ( $ this -> mapping [ 'mandatory' ] [ $ templateName ] ) ) { return false ; } return ! $ this -> environment -> getConfig ( ) -> get ( 'templates.auto_mapping' , true ) ; }
Check if template auto mapping is disabled .
11,822
public static function createFresh ( $ dn , $ attrs = array ( ) ) { if ( ! is_array ( $ attrs ) ) { return PEAR :: raiseError ( "Unable to create fresh entry: Parameter \$attrs needs to be an array!" ) ; } $ entry = new Net_LDAP2_Entry ( $ attrs , $ dn ) ; return $ entry ; }
Creates a fresh entry that may be added to the directory later on
11,823
public static function createConnected ( $ ldap , $ entry ) { if ( ! $ ldap instanceof Net_LDAP2 ) { return PEAR :: raiseError ( "Unable to create connected entry: Parameter \$ldap needs to be a Net_LDAP2 object!" ) ; } if ( ! is_resource ( $ entry ) ) { return PEAR :: raiseError ( "Unable to create connected entry: Pa...
Creates a Net_LDAP2_Entry object out of an ldap entry resource
11,824
public static function createExisting ( $ dn , $ attrs = array ( ) ) { if ( ! is_array ( $ attrs ) ) { return PEAR :: raiseError ( "Unable to create entry object: Parameter \$attrs needs to be an array!" ) ; } $ entry = Net_LDAP2_Entry :: createFresh ( $ dn , $ attrs ) ; if ( $ entry instanceof Net_LDAP2_Error ) { retu...
Creates an Net_LDAP2_Entry object that is considered already existing
11,825
public function dn ( $ dn = null ) { if ( false == is_null ( $ dn ) ) { if ( is_null ( $ this -> _dn ) ) { $ this -> _dn = $ dn ; } else { $ this -> _newdn = $ dn ; } return true ; } return ( isset ( $ this -> _newdn ) ? $ this -> _newdn : $ this -> currentDN ( ) ) ; }
Get or set the distinguished name of the entry
11,826
protected function setAttributes ( $ attributes = null ) { if ( is_null ( $ attributes ) && is_resource ( $ this -> _entry ) && is_resource ( $ this -> _link ) ) { if ( $ this -> _ldap instanceof Net_LDAP2 ) { $ schema = $ this -> _ldap -> schema ( ) ; } $ attributes = array ( ) ; do { if ( empty ( $ attr ) ) { $ ber =...
Sets the internal attributes array
11,827
public function getValues ( ) { $ attrs = array ( ) ; foreach ( $ this -> _attributes as $ attr => $ value ) { $ attrs [ $ attr ] = $ this -> getValue ( $ attr ) ; } return $ attrs ; }
Get the values of all attributes in a hash
11,828
public function getValue ( $ attr , $ option = null ) { $ attr = $ this -> getAttrName ( $ attr ) ; if ( ! array_key_exists ( $ attr , $ this -> _attributes ) ) { switch ( $ option ) { case 'single' : $ value = false ; break ; case 'all' : $ value = array ( ) ; break ; default : $ value = '' ; } } else { switch ( $ opt...
Get the value of a specific attribute
11,829
public function exists ( $ attr ) { $ attr = $ this -> getAttrName ( $ attr ) ; return array_key_exists ( $ attr , $ this -> _attributes ) ; }
Returns whether an attribute exists or not
11,830
public function add ( $ attr = array ( ) ) { if ( false == is_array ( $ attr ) ) { return PEAR :: raiseError ( "Parameter must be an array" ) ; } if ( $ this -> isNew ( ) ) { $ this -> setAttributes ( $ attr ) ; } foreach ( $ attr as $ k => $ v ) { $ k = $ this -> getAttrName ( $ k ) ; if ( false == is_array ( $ v ) ) ...
Adds a new attribute or a new value to an existing attribute
11,831
public function delete ( $ attr = null ) { if ( is_null ( $ attr ) ) { $ this -> _delete = true ; return true ; } if ( is_string ( $ attr ) ) { $ attr = array ( $ attr ) ; } if ( is_numeric ( key ( $ attr ) ) ) { foreach ( $ attr as $ name ) { if ( is_array ( $ name ) ) { $ del_attr_name = array_search ( $ name , $ att...
Deletes an whole attribute or a value or the whole entry
11,832
public function replace ( $ attr = array ( ) , $ force = false ) { if ( false == is_array ( $ attr ) ) { return PEAR :: raiseError ( "Parameter must be an array" ) ; } foreach ( $ attr as $ k => $ v ) { $ k = $ this -> getAttrName ( $ k ) ; if ( false == is_array ( $ v ) ) { if ( is_int ( $ v ) ) { $ v = "$v" ; } if ( ...
Replaces attributes or its values
11,833
protected function getAttrName ( $ attr ) { $ name = strtolower ( $ attr ) ; if ( array_key_exists ( $ name , $ this -> _map ) ) { $ attr = $ this -> _map [ $ name ] ; } return $ attr ; }
Returns the right attribute name
11,834
public function setLDAP ( $ ldap ) { if ( ! $ ldap instanceof Net_LDAP2 ) { return PEAR :: raiseError ( "LDAP is not a valid Net_LDAP2 object" ) ; } else { $ this -> _ldap = $ ldap ; return true ; } }
Sets a reference to the LDAP - Object of this entry
11,835
public static function closeMuxConnections ( ) { $ count = count ( self :: $ multiplexedConnections ) ; if ( $ count ) { echo "Closing $count multiplexed connections...\n" ; foreach ( self :: $ multiplexedConnections as $ key => $ connection ) { exec ( "ssh -O stop -o LogLevel=QUIET -S $connection > /dev/null 2>&1" ) ;...
Close all multiplexed connections
11,836
public function exec ( $ command , $ asUser = null ) { $ command = new Command ( $ this , $ command , $ asUser ) ; return $ command -> exec ( ) ; }
Execute command on this connection
11,837
public function uglify ( array $ files , $ outputFilename , array $ options = [ ] , $ finalJsHeaderFilename = null ) { foreach ( $ files as $ filename ) { if ( ! is_readable ( $ filename ) ) { throw new UglifyJSException ( "Filename " . $ filename . " is not readable" ) ; } } $ optionsString = $ this -> validateOptions...
Calls the uglifyjs script and minifies the Javascript
11,838
public static function createForClass ( $ class , $ name , $ title = null , \ SS_List $ items = null ) { $ folderName = self :: getFolderForClass ( $ class , $ name ) ; $ inst = new static ( $ name , $ title , $ items ) ; $ inst -> setFolderName ( $ folderName . '/' . $ name ) ; return $ inst ; }
Return an instance of UploadField with the folder name already set up
11,839
public static function getFolderForClass ( $ class ) { $ folderName = 'Uploads' ; if ( is_object ( $ class ) ) { if ( method_exists ( $ class , 'hasMethod' ) && $ class -> hasMethod ( 'BaseFolder' ) ) { $ folderName = $ class -> BaseFolder ( ) ; } elseif ( $ class instanceof Page ) { $ folderName = get_class ( $ class ...
Get folder for a given class
11,840
public function newForm ( $ name , array $ definition ) { $ container = ContainerBuilder :: buildContainer ( [ $ name => Definition :: object ( 'Slick\Form\Form' ) -> constructor ( [ $ name ] ) ] ) ; $ this -> _form = $ container -> get ( $ name ) ; foreach ( $ definition as $ name => $ element ) { $ this -> addElement...
Creates a new form object
11,841
public function addElement ( FieldsetInterface & $ form , $ name , $ data ) { if ( $ data [ 'type' ] == 'fieldset' ) { $ fieldset = new Fieldset ( [ 'name' => $ name ] ) ; foreach ( $ data [ 'elements' ] as $ key => $ def ) { $ this -> addElement ( $ fieldset , $ key , $ def ) ; } $ form -> add ( $ fieldset ) ; } else ...
Adds an element to the form
11,842
public function addValidation ( Element & $ element , array $ data ) { foreach ( $ data as $ key => $ value ) { if ( is_string ( $ key ) ) { $ element -> getInput ( ) -> getValidatorChain ( ) -> add ( StaticValidator :: create ( $ key , $ value ) ) ; $ this -> checkRequired ( $ key , $ element ) ; } else { $ element ->...
Add validator to the provided element
11,843
public function checkRequired ( $ validator , Element & $ element ) { if ( in_array ( $ validator , [ 'notEmpty' ] ) ) { $ element -> getInput ( ) -> required = true ; $ element -> getInput ( ) -> allowEmpty = false ; } }
Check required flag based on validator name
11,844
protected function set_post_type_archive ( $ post_type_object ) { $ label = $ post_type_object -> label ; $ this -> set ( $ label , $ this -> get_post_type_archive_link ( $ post_type_object -> name ) ) ; }
Sets Breadcrumbs items of post type archive
11,845
protected function set_terms ( $ post_type_object ) { $ taxonomies = get_object_taxonomies ( $ post_type_object -> name ) ; if ( ! $ taxonomies ) { return ; } $ taxonomy = apply_filters ( 'inc2734_wp_breadcrumbs_main_taxonomy' , array_shift ( $ taxonomies ) , $ taxonomies , $ post_type_object ) ; $ terms = get_the_term...
Sets Breadcrumbs items of terms
11,846
protected function set_categories ( ) { $ categories = get_the_category ( get_the_ID ( ) ) ; if ( $ categories ) { $ category = array_shift ( $ categories ) ; $ this -> set_ancestors ( $ category -> term_id , 'category' ) ; $ this -> set ( $ category -> name , get_term_link ( $ category ) ) ; } }
Sets Breadcrumbs items of categories
11,847
public function insert ( $ data , $ weight = 0 ) { if ( $ this -> isEmpty ( ) ) { $ this -> _nodes [ ] = [ 'data' => $ data , 'weight' => $ weight ] ; return $ this ; } $ inserted = false ; $ new = [ ] ; while ( count ( $ this -> _nodes ) > 0 ) { $ element = array_shift ( $ this -> _nodes ) ; if ( ! $ inserted && $ thi...
Inserts a new object in the list
11,848
public function remove ( ) { unset ( $ this -> _nodes [ $ this -> _pointer ] ) ; $ this -> _nodes = array_values ( $ this -> _nodes ) ; return $ this ; }
Removes current object from the list
11,849
public function addSets ( array $ values = array ( ) ) { foreach ( $ values as $ column => $ value ) { $ this -> addSet ( $ column , $ value ) ; } return $ this ; }
Add the values to be set
11,850
public function toSql ( ) { if ( $ this -> isEmpty ( ) ) { return '' ; } $ params = $ this -> getParams ( ) ; $ sql = array ( 'SET' ) ; $ set = array ( ) ; foreach ( $ params as $ column => $ value ) { $ set [ ] = implode ( ' = ' , array ( $ column , $ this -> getBuilder ( ) -> getHelper ( ) -> toDbValue ( $ value ) ) ...
The SET query part
11,851
public function addToCart ( $ productid , $ price , $ quantity ) { $ productAlreadyExists = 0 ; $ olderProduct = ShoppingCartItem :: where ( 'product_id' , '=' , $ productid ) -> where ( 'user_id' , '=' , Auth :: user ( ) -> id ) -> first ( ) ; if ( $ olderProduct != null ) { $ productAlreadyExists = $ olderProduct -> ...
Function to add items to a cart
11,852
public function removeFromCart ( $ productid ) { ShoppingCartItem :: where ( 'product_id' , '=' , $ productid ) -> where ( 'user_id' , '=' , Auth :: user ( ) -> id ) -> delete ( ) ; }
Function to delete an item from a cart
11,853
public function updateItemInCart ( $ productid , $ quantity ) { $ olderProduct = ShoppingCartItem :: where ( 'product_id' , '=' , $ productid ) -> where ( 'user_id' , '=' , Auth :: user ( ) -> id ) -> first ( ) ; if ( $ olderProduct != null ) { $ olderProduct -> qty = $ quantity ; $ olderProduct -> save ( ) ; } }
Function to update an item in the cart
11,854
public function totalPrice ( ) { $ total = 0 ; $ products = $ this -> content ( ) ; foreach ( $ products as $ product ) { $ total += ( $ product -> qty * $ product -> price ) ; } $ total = ( $ total + ( $ total * ( $ this -> taxRate / 100 ) ) ) ; $ total += $ this -> deliveryCharges ; return $ total ; }
Function to calculate the total price of products in the cart
11,855
public function dispatch ( RouteInfo $ routeInfo ) { $ this -> setRouteInfo ( $ routeInfo ) ; $ method = $ this -> _routeInfo -> getAction ( ) ; $ controller = $ this -> getController ( $ method ) ; $ inspector = new Inspector ( $ controller ) ; $ methodExists = $ inspector -> hasMethod ( $ method ) ; if ( ! $ methodEx...
Dispatches the routed request
11,856
public function getController ( $ method ) { if ( is_null ( $ this -> _controller ) ) { $ className = $ this -> _routeInfo -> getController ( ) ; if ( ! class_exists ( $ className ) ) { throw new Exception \ ControllerNotFoundException ( "Controller '{$className}' not found" ) ; } $ options = array ( 'request' => $ thi...
Loads the controller
11,857
protected function _render ( ) { $ response = $ this -> _application -> response ; $ body = $ response -> getBody ( ) ; $ this -> _controller -> set ( 'flashMessages' , $ this -> _controller -> flashMessages ) ; $ data = $ this -> _controller -> getViewVars ( ) ; $ doLayout = $ this -> _controller -> renderLayout && $ ...
Render the view and layout templates with controller data
11,858
public function getView ( ) { if ( is_null ( $ this -> _view ) ) { $ controller = $ this -> _routeInfo -> controllerName ; $ name = $ this -> _routeInfo -> action ; $ ext = $ this -> _routeInfo -> getExtension ( ) ; $ template = "{$controller}/{$name}.{$ext}.twig" ; if ( ! is_null ( $ this -> _controller -> view ) ) { ...
Returns the view for current request
11,859
public function getLayout ( ) { if ( is_null ( $ this -> _layout ) ) { $ default = 'layouts/default' ; $ ext = $ this -> _routeInfo -> getExtension ( ) ; $ file = "{$default}.{$ext}.twig" ; if ( ! is_null ( $ this -> _controller -> layout ) ) { $ file = "{$this->_controller->layout}.{$ext}.twig" ; } $ this -> _layout =...
Returns the layout for current request
11,860
protected function prepareTree ( array $ arr ) { $ tree = [ ] ; foreach ( $ arr as $ a ) { $ name = $ a -> getName ( ) ; $ cur = & $ tree ; foreach ( explode ( "-" , $ name ) as $ e ) { if ( empty ( $ cur [ $ e ] ) ) $ cur [ $ e ] = [ ] ; $ cur = & $ cur [ $ e ] ; } } return $ tree ; }
prepare stack list
11,861
protected function flatternTree ( array $ treeIn ) { $ treeOut = [ ] ; foreach ( $ treeIn as $ name => $ children ) { if ( count ( $ children ) === 0 ) { $ treeOut [ $ name ] = [ ] ; } elseif ( count ( $ children ) === 1 ) { $ name = sprintf ( '%s-%s' , $ name , key ( $ children ) ) ; if ( count ( $ children [ key ( $ ...
flattern tree to gain a better overview
11,862
public function setConfig ( array $ config ) { $ this -> config = $ config ; $ this -> senderID = $ this -> config [ 'default_sender' ] ; if ( ! isset ( $ this -> config [ 'auth' ] ) ) { throw new \ Exception ( $ this -> lang [ 'exceptions' ] [ '0' ] ) ; } else { if ( ! isset ( $ this -> config [ 'auth' ] [ 'username' ...
This method allows user to change configuration on - the - fly
11,863
public function sendBulk ( $ recipents , $ message = '' , $ date = '' , $ senderID = '' ) { $ this -> preChecks ( $ message , $ senderID ) ; $ dateStr = '' ; if ( strlen ( $ date ) ) { $ dateStr = ' tarih="' . $ date . '"' ; } if ( is_array ( $ recipents ) ) { $ recipents = implode ( ', ' , $ recipents ) ; } $ xml = '<...
Send same bulk message to many people
11,864
public function send ( $ receiver , $ message = '' , $ date = '' , $ senderID = '' ) { $ this -> preChecks ( $ message , $ senderID ) ; if ( $ receiver == null || ! strlen ( trim ( $ receiver ) ) ) { return 102 ; } $ dateStr = '' ; if ( strlen ( $ date ) ) { $ dateStr = ' tarih="' . $ date . '"' ; } $ xml = '<?xml vers...
Sends a single SMS to a single person
11,865
public function sendMulti ( $ reciversMessage , $ date = '' , $ senderID = '' ) { if ( $ senderID == null || ! strlen ( trim ( $ senderID ) ) ) { $ senderID = $ this -> config [ 'default_sender' ] ; } $ dateStr = '' ; if ( strlen ( $ date ) ) { $ dateStr = ' tarih="' . $ date . '"' ; } $ xml = '<?xml version="1.0" enco...
Sends multiple SMSes to various people with various content
11,866
public function checkBalance ( ) { $ xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<smskredi ka="' . $ this -> config [ 'auth' ] [ 'username' ] . '" pwd="' . $ this -> config [ 'auth' ] [ 'password' ] . '" />' ; $ response = $ this -> postXML ( $ xml , 'https://smsgw.mutlucell.com/smsgw-ws/gtcrdtex' ) ; return intv...
Balance Checker Shows how much SMS you have left
11,867
public function parseOutput ( $ output ) { if ( $ this -> isnum ( $ output ) ) { switch ( $ output ) { case 20 : return $ this -> lang [ 'reports' ] [ '20' ] ; break ; case 21 : return $ this -> lang [ 'reports' ] [ '21' ] ; break ; case 22 : return $ this -> lang [ 'reports' ] [ '22' ] ; break ; case 23 : return $ thi...
Parse the output
11,868
public function getStatus ( $ output ) { if ( $ this -> isnum ( $ output ) ) { return false ; } elseif ( preg_match ( '/(\$[0-9]+\#[0-9]+\.[0-9]+)/i' , $ output ) ) { $ output = explode ( '#' , $ output ) ; $ status = $ output [ 1 ] ; if ( $ status == '0.0' ) { return false ; } else { return true ; } } else { return fa...
Gets the SMS s status
11,869
protected function preChecks ( $ message , $ senderID ) { if ( $ senderID == null || ! strlen ( trim ( $ senderID ) ) ) { $ this -> senderID = $ this -> config [ 'default_sender' ] ; } else { $ this -> senderID = $ senderID ; } if ( $ message == null || ! strlen ( trim ( $ message ) ) ) { $ this -> message = '&' ; } el...
Prechecks to prevent multiple usage
11,870
public function addSubmitButton ( $ value = 'Save' , array $ classes = null ) { $ this -> add ( [ 'name' => 'submit' , 'type' => Submit :: class , 'attributes' => [ 'value' => $ value , 'class' => ( ! is_null ( $ classes ) ? join ( ' ' , $ classes ) : 'btn btn-primary' ) , ] , ] ) ; }
Used to add a submit button to the Form .
11,871
public function get ( $ elementOrFieldset ) { if ( $ elementOrFieldset === 'csrf' ) { foreach ( $ this -> elements as $ formElement ) { if ( $ formElement instanceof Csrf ) { return $ formElement ; } } } return parent :: get ( $ elementOrFieldset ) ; }
Retrieve a named element or fieldset
11,872
protected function _getter ( $ name ) { $ normalized = lcfirst ( $ name ) ; $ property = "_{$normalized}" ; if ( property_exists ( $ this , $ property ) ) { $ annotations = $ this -> inspector -> getPropertyAnnotations ( $ property ) ; if ( ! $ annotations -> hasAnnotation ( '@readwrite' ) && ! $ annotations -> hasAnno...
Retrieves the value a property with the given name .
11,873
protected function _is ( $ name ) { $ normalized = lcfirst ( $ name ) ; $ property = "_{$normalized}" ; if ( property_exists ( $ this , $ property ) ) { $ annotations = $ this -> inspector -> getPropertyAnnotations ( $ property ) ; if ( ! $ annotations -> hasAnnotation ( '@readwrite' ) && ! $ annotations -> hasAnnotati...
Retrieves the boolean value a property with the given name .
11,874
public function __isset ( $ name ) { $ normalized = lcfirst ( $ name ) ; $ property = "_{$normalized}" ; if ( property_exists ( $ this , $ property ) ) { return true ; } return false ; }
Checks if a given property name exists and can be accessed
11,875
public function actionIndex ( ) { $ audit = Yii :: app ( ) -> getModule ( 'audit' ) ; $ data = $ audit -> getDbConnection ( ) -> createCommand ( "SELECT id FROM " . AuditError :: model ( ) -> tableName ( ) . " WHERE status=:new_status" ) -> query ( array ( ':new_status' => 'new' , ) ) ; while ( $ data && ( $ row = $ da...
Send error emails . Requires yii - email - module
11,876
public static function classForCurrentStep ( ) { $ step = self :: getCurrentStep ( ) ; if ( ! $ step ) { $ step = 1 ; } if ( Controller :: has_curr ( ) ) { $ requestStep = Controller :: curr ( ) -> getRequest ( ) -> getVar ( 'step' ) ; if ( $ requestStep ) { $ step = $ requestStep ; } } return str_replace ( self :: cla...
Get class name for current step based on this class name
11,877
public function AllSteps ( ) { $ num = self :: classNameNumber ( ) ; if ( ! $ num ) { return ; } $ n = 1 ; $ curr = self :: getCurrentStep ( ) ; if ( ! $ curr ) { $ curr = 1 ; } if ( ! Controller :: has_curr ( ) ) { return ; } $ c = Controller :: curr ( ) ; $ class = str_replace ( $ num , $ n , get_called_class ( ) ) ;...
Get all steps as an ArrayList . To be used for your templates .
11,878
public static function setMaxStep ( $ value ) { Session :: set ( self :: classNameWithoutNumber ( ) . '.maxStep' , ( int ) $ value ) ; return Session :: save ( ) ; }
Set max step
11,879
public static function setCurrentStep ( $ value ) { $ value = ( int ) $ value ; if ( $ value > self :: getMaxStep ( ) ) { self :: setMaxStep ( $ value ) ; } Session :: set ( self :: classNameWithoutNumber ( ) . '.step' , $ value ) ; return Session :: save ( ) ; }
Set current step
11,880
public static function isLastStep ( ) { $ n = self :: classNameNumber ( ) ; $ n1 = $ n + 1 ; $ class = str_replace ( $ n , $ n1 , get_called_class ( ) ) ; return ! class_exists ( $ class ) ; }
Check if this is the last step
11,881
public function gotoStep ( ) { $ step = $ this -> Controller ( ) -> getRequest ( ) -> getVar ( 'step' ) ; if ( $ step > 0 && $ step <= self :: getMaxStep ( ) ) { self :: setCurrentStep ( $ step ) ; } return $ this -> Controller ( ) -> redirectBack ( ) ; }
Goto a step
11,882
protected function definePrevNextActions ( $ doSet = false ) { $ actions = new FieldList ( ) ; $ prevClass = 'FormAction' ; if ( class_exists ( 'FormActionNoValidation' ) ) { $ prevClass = 'FormActionNoValidation' ; } $ prev = null ; if ( self :: classNameNumber ( ) > 1 ) { $ prev = new $ prevClass ( 'doPrev' , _t ( 'F...
Call this instead of manually creating your actions
11,883
protected function definePrevNextSaveActions ( $ doSet = false ) { $ actions = $ this -> definePrevNextActions ( $ doSet ) ; $ cls = 'FormAction' ; if ( class_exists ( 'FormActionNoValidation' ) ) { $ cls = 'FormActionNoValidation' ; } $ save = new $ cls ( 'doSave' , _t ( 'FormExtra.doSave' , 'Save' ) ) ; $ save -> add...
Same as definePrevNext + a save button
11,884
public static function getAndAssertActiveBlock ( $ type ) { $ active_block = static :: getActive ( ) ; $ current = get_class ( $ active_block -> activeBlock ( ) ) ; if ( ! is_a ( $ active_block -> activeBlock ( ) , $ type ) ) { throw new Exception ( "Improperly nested block. Expected a $type, got a $current" ) ; } retu...
Obtains the current active block and asserts that it is a given type . Used to enforce block nested rules for the DSL .
11,885
public function getRootCategories ( ) { return self :: where ( 'parent' , 0 ) -> where ( 'slug' , '<>' , config ( 'Categories::category.default_category.slug' ) ) -> orderby ( 'id' , 'desc' ) -> where ( 'model_type' , $ this -> modelType ) -> get ( ) ; }
get root categories = > parent = 0
11,886
public function categoryLists ( $ categories = [ ] , $ parent = false ) { $ data = [ ] ; $ categories = ( count ( $ categories ) == 0 && ! $ parent ) ? $ this -> rootCategories ( ) : $ categories ; if ( count ( $ categories ) > 0 ) { foreach ( $ categories as $ category ) { $ data [ ] = [ 'id' => $ category -> id , 'ti...
get array list of categories with child
11,887
public function categoryOption ( $ categories , $ value = null ) { $ options = "" ; if ( $ categories ) { foreach ( $ categories as $ category ) { $ line = $ this -> makeLineForDepth ( $ this -> getDepth ( $ category -> parent ) ) ; $ selected = $ value == $ category -> id ? 'selected' : '' ; $ options .= "<option $sel...
get html option with child
11,888
public function getOptionListCategories ( $ value , $ attributes = null , $ select = true ) { $ options = $ this -> categoryOption ( $ this -> getRootCategories ( $ this -> modelType ) , $ value ) ; $ attrs = $ this -> makeAttributesForOption ( $ attributes ) ; $ newOption = "<option selected value='0'>" . trans ( 'Cat...
get html select or options
11,889
public function makeLineForDepth ( $ depth = 0 , $ symbol = ' - ' ) { $ line = '' ; if ( $ depth > 0 ) { for ( $ i = 1 ; $ i <= $ depth ; $ i ++ ) $ line .= $ symbol ; } return $ line ; }
make line style with depth for before title
11,890
public function makeAttributesForOption ( $ attributes ) { $ attrs = '' ; if ( $ attributes ) { foreach ( $ attributes as $ key => $ value ) { $ attrs .= "$key='" . $ value . "'" ; } } return $ attrs ; }
make attr for html select
11,891
public function getDepth ( $ parent = 0 ) { $ counter = 0 ; $ r = true ; while ( $ r ) { $ category = self :: where ( 'id' , $ parent ) -> first ( ) ; if ( $ category ) { $ counter ++ ; $ parent = $ category -> parent ; if ( $ category -> parent == 0 ) { break ; } } else break ; } return $ counter ; }
get category depth
11,892
public function load ( ) { $ this -> _checkAdapter ( ) ; if ( ! class_exists ( $ this -> getClass ( ) ) ) { throw new InvalidArgumentException ( "The loader class '{$this->getClass()}' is not defined." ) ; } $ reflexion = new ReflectionClass ( $ this -> getClass ( ) ) ; $ args = [ [ 'adapter' => $ this -> _adapter ] ] ...
Queries the database and retrieves the schema object that maps it
11,893
protected function _checkAdapter ( ) { $ notDefined = ! is_object ( $ this -> _adapter ) ; $ isAdapter = $ this -> _adapter instanceof AdapterInterface ; if ( $ notDefined || ! $ isAdapter ) { throw new InvalidArgumentException ( "You need to set the database adapter for this schema loader." ) ; } }
Checks if the adapter is defined
11,894
public static function getScaffoldController ( Controller $ instance , $ options = [ ] ) { $ options = array_merge ( [ 'controller' => $ instance , 'request' => $ instance -> request , 'response' => $ instance -> response , 'view' => $ instance -> view , 'layout' => $ instance -> layout , 'basePath' => $ instance -> ba...
Creates a new scaffold controller
11,895
public function getModelName ( ) { if ( is_null ( $ this -> _modelName ) ) { $ this -> setModelName ( 'Models\\' . ucfirst ( $ this -> get ( 'modelSingular' ) ) ) ; } return $ this -> _modelName ; }
Returns the model class name
11,896
public function setModelName ( $ name ) { $ this -> _modelName = $ name ; $ nameParts = explode ( "\\" , $ name ) ; $ controllerName = end ( $ nameParts ) ; $ nameParts = Text :: camelCaseToSeparator ( $ controllerName , '#' ) ; $ nameParts = explode ( '#' , $ nameParts ) ; $ final = Text :: plural ( strtolower ( array...
Sets model name
11,897
public function getDescriptor ( ) { if ( is_null ( $ this -> _descriptor ) ) { $ this -> _descriptor = new Descriptor ( [ 'descriptor' => Manager :: getInstance ( ) -> get ( $ this -> getModelName ( ) ) ] ) ; } return $ this -> _descriptor ; }
Returns model descriptor
11,898
public function index ( ) { $ pagination = new Pagination ( ) ; $ pattern = StaticFilter :: filter ( 'text' , $ this -> getController ( ) -> request -> getQuery ( 'pattern' , null ) ) ; $ this -> view = 'scaffold/index' ; $ descriptor = $ this -> getDescriptor ( ) ; $ query = call_user_func_array ( [ $ this -> getModel...
Handles the request to display index page
11,899
public function show ( $ recordId = 0 ) { $ this -> view = 'scaffold/show' ; $ recordId = StaticFilter :: filter ( 'number' , $ recordId ) ; $ record = call_user_func_array ( [ $ this -> getModelName ( ) , 'get' ] , [ $ recordId ] ) ; if ( is_null ( $ record ) ) { $ this -> addWarningMessage ( "The {$this->get('modelSi...
Handles the request to display show page