idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
59,600
public function inCollection ( $ varValue , $ blnReturnKey = false ) { $ varReturn = false ; foreach ( $ this -> collection as $ object ) { if ( $ object == $ varValue || $ varValue === get_class ( $ object ) ) { $ varReturn = ( $ blnReturnKey ) ? $ this -> key ( ) : true ; break ; } } self :: rewind ( ) ; return $ varReturn ; }
Check if an object is in the collection
59,601
public function remove ( $ objElement ) { $ varKey = $ this -> inCollection ( $ objElement , true ) ; if ( $ varKey !== false ) { unset ( $ this -> collection [ $ varKey ] ) ; } $ this -> rebuild ( ) ; return true ; }
Remove an element from the collection
59,602
public function toHtmlInternal ( $ value = null ) { $ strSelected = "" ; if ( $ this -> __selected && is_null ( $ value ) ) { $ strSelected = " selected=\"selected\"" ; } if ( $ value == $ this -> __value ) { $ strSelected = " selected=\"selected\"" ; } $ strOutput = "<option value=\"{$this->__value}\"{$strSelected} {$this->__getMetaString()}>{$this->__label}</option>\n" ; return $ strOutput ; }
Generate HTMl output
59,603
public function __toHtml ( ) { return $ this -> toHtml ( $ submitted = false , $ blnSimpleLayout = false , $ blnLabel = true , $ blnDisplayError = true ) ; }
Render paragraph s HTML
59,604
public function toHtml ( $ submitted = false , $ blnSimpleLayout = false , $ blnLabel = true , $ blnDisplayError = true ) { $ this -> setConditionalMeta ( ) ; $ this -> setMeta ( "class" , "vf__paragraph" ) ; $ strOutput = "<div{$this->__getMetaString()}>\n" ; if ( ! empty ( $ this -> __header ) ) { $ strOutput .= "<h3{$this->__getLabelMetaString()}>{$this->__header}</h3>\n" ; } if ( ! empty ( $ this -> __body ) ) { if ( preg_match ( "/<p.*?>/" , $ this -> __body ) > 0 ) { $ strOutput .= "{$this->__body}\n" ; } else { $ strOutput .= "<p{$this->__getFieldMetaString()}>{$this->__body}</p>\n" ; } } $ strOutput .= "</div>\n" ; return $ strOutput ; }
Render paragraph HTML
59,605
public function getValidValue ( $ intDynamicPosition = 0 ) { $ varReturn = null ; if ( isset ( $ this -> __validvalues [ $ intDynamicPosition ] ) ) { $ varReturn = $ this -> __validvalues [ $ intDynamicPosition ] ; } return $ varReturn ; }
Get the validated value
59,606
private function __hasError ( $ intDynamicPosition = 0 ) { return ( isset ( $ this -> __errors [ $ intDynamicPosition ] ) && ! empty ( $ this -> __errors [ $ intDynamicPosition ] ) ) ; }
Check if an error has occured
59,607
public static function checkCORS ( ) { Logger :: log ( 'Checking CORS' ) ; $ corsEnabled = Config :: getParam ( 'cors.enabled' ) ; $ request = Request :: getInstance ( ) ; if ( NULL !== $ corsEnabled ) { if ( $ corsEnabled === '*' || preg_match ( $ corsEnabled , $ request -> getServer ( 'HTTP_REFERER' ) ) ) { if ( ! headers_sent ( ) ) { header ( 'Access-Control-Allow-Credentials: true' ) ; header ( 'Access-Control-Allow-Origin: ' . Request :: getInstance ( ) -> getServer ( 'HTTP_ORIGIN' , '*' ) ) ; header ( 'Vary: Origin' ) ; header ( 'Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS' ) ; header ( 'Access-Control-Allow-Headers: ' . implode ( ', ' , self :: getCorsHeaders ( ) ) ) ; } if ( Request :: getInstance ( ) -> getMethod ( ) === Request :: VERB_OPTIONS ) { Logger :: log ( 'Returning OPTIONS header confirmation for CORS pre flight requests' , LOG_DEBUG ) ; header ( 'HTTP/1.1 200 OK' ) ; exit ( ) ; } } } }
Check CROS requests
59,608
protected function dumpException ( \ Exception $ e ) { Logger :: log ( 'Starting dump exception' ) ; $ ex = ( NULL !== $ e -> getPrevious ( ) ) ? $ e -> getPrevious ( ) : $ e ; $ error = array ( "error" => $ ex -> getMessage ( ) , "file" => $ ex -> getFile ( ) , "line" => $ ex -> getLine ( ) , ) ; Logger :: log ( 'Throwing exception' , LOG_ERR , $ error ) ; unset ( $ error ) ; return $ this -> router -> httpNotFound ( $ ex ) ; }
Method that convert an exception to html
59,609
public function contains ( Address $ address ) { $ addressValue = $ address -> get ( ) ; return $ addressValue >= $ this -> firstAddress -> get ( ) && $ addressValue <= $ this -> lastAddress -> get ( ) ; }
Determine if a given address is contained within the range .
59,610
public function logs ( ) { $ log = t ( "Selecciona un fichero de log" ) ; $ logs = $ this -> srv -> getLogFiles ( ) ; asort ( $ logs ) ; return $ this -> render ( "logs.html.twig" , array ( "logs" => $ logs , "log" => $ log , ) ) ; }
Servicio que muestra los logs del sistema
59,611
public function setDefaults ( $ arrDefaults = array ( ) ) { if ( is_array ( $ arrDefaults ) ) { $ this -> __defaults = $ arrDefaults ; } else { throw new \ InvalidArgumentException ( "Invalid argument passed in to ValidForm->setDefaults(). Expected array got " . gettype ( $ arrDefaults ) , E_ERROR ) ; } }
Use an array to set default values on all the forms children . The array s keys should be the form name to set the default value of the value is the actual value or values to set .
59,612
public function addHtml ( $ html , $ meta = array ( ) ) { $ objString = new StaticText ( $ html , $ meta ) ; $ this -> __elements -> addObject ( $ objString ) ; return $ objString ; }
Injects a string in the form .
59,613
public function addFieldset ( $ header = null , $ noteHeader = null , $ noteBody = null , $ meta = array ( ) ) { $ objFieldSet = new Fieldset ( $ header , $ noteHeader , $ noteBody , $ meta ) ; $ this -> __elements -> addObject ( $ objFieldSet ) ; return $ objFieldSet ; }
Add a fieldset to the form field collection
59,614
public function addHiddenField ( $ name , $ type , $ meta = array ( ) , $ blnJustRender = false ) { $ objField = new Hidden ( $ name , $ type , $ meta ) ; if ( ! $ blnJustRender ) { $ objFieldset = $ this -> __elements -> getLast ( "ValidFormBuilder\\Fieldset" ) ; if ( $ this -> __elements -> count ( ) == 0 || ! is_object ( $ objFieldset ) ) { $ objFieldset = $ this -> addFieldset ( ) ; } $ objField -> setMeta ( "parent" , $ objFieldset , true ) ; $ objFieldset -> addField ( $ objField ) ; } return $ objField ; }
Add a hidden input field to the form collection .
59,615
public static function renderField ( $ name , $ label , $ type , $ validationRules , $ errorHandlers , $ meta ) { $ objField = null ; switch ( $ type ) { case static :: VFORM_STRING : case static :: VFORM_WORD : case static :: VFORM_EMAIL : case static :: VFORM_URL : case static :: VFORM_SIMPLEURL : case static :: VFORM_CUSTOM : case static :: VFORM_CURRENCY : case static :: VFORM_DATE : case static :: VFORM_NUMERIC : case static :: VFORM_INTEGER : $ objField = new Text ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_PASSWORD : $ objField = new Password ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_HTML : case static :: VFORM_CUSTOM_TEXT : case static :: VFORM_TEXT : $ objField = new Textarea ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_FILE : $ objField = new File ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_BOOLEAN : $ objField = new Checkbox ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_RADIO_LIST : case static :: VFORM_CHECK_LIST : $ objField = new Group ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_SELECT_LIST : $ objField = new Select ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; case static :: VFORM_HIDDEN : $ objField = new Hidden ( $ name , $ type , $ meta ) ; break ; default : $ objField = new Element ( $ name , $ type , $ label , $ validationRules , $ errorHandlers , $ meta ) ; break ; } return $ objField ; }
Use this utility method to only render \ ValidFormBuilder \ Element instances of the defined types .
59,616
public function addField ( $ name , $ label , $ type , $ validationRules = array ( ) , $ errorHandlers = array ( ) , $ meta = array ( ) , $ blnJustRender = false ) { $ objField = static :: renderField ( $ name , $ label , $ type , $ validationRules , $ errorHandlers , $ meta ) ; $ objField -> setRequiredStyle ( $ this -> __requiredstyle ) ; if ( ! $ blnJustRender ) { $ objFieldset = $ this -> __elements -> getLast ( "ValidFormBuilder\\Fieldset" ) ; if ( $ this -> __elements -> count ( ) == 0 || ! is_object ( $ objFieldset ) ) { $ objFieldset = $ this -> addFieldset ( ) ; } $ objField -> setMeta ( "parent" , $ objFieldset , true ) ; $ objFieldset -> addField ( $ objField ) ; } return $ objField ; }
Add a new element to the internal elements collection
59,617
public function addParagraph ( $ strBody , $ strHeader = "" , $ meta = array ( ) ) { $ objParagraph = new Paragraph ( $ strHeader , $ strBody , $ meta ) ; $ objFieldset = $ this -> __elements -> getLast ( "ValidFormBuilder\\Fieldset" ) ; if ( $ this -> __elements -> count ( ) == 0 || ! is_object ( $ objFieldset ) ) { $ objFieldset = $ this -> addFieldset ( ) ; } $ objParagraph -> setMeta ( "parent" , $ objFieldset , true ) ; $ objFieldset -> addField ( $ objParagraph ) ; return $ objParagraph ; }
Adds a \ ValidFormBuilder \ Paragraph object to the internal elements collection .
59,618
public function addArea ( $ label = null , $ active = false , $ name = null , $ checked = false , $ meta = array ( ) ) { $ objArea = new Area ( $ label , $ active , $ name , $ checked , $ meta ) ; $ objArea -> setRequiredStyle ( $ this -> __requiredstyle ) ; $ objFieldset = $ this -> __elements -> getLast ( "ValidFormBuilder\\Fieldset" ) ; if ( $ this -> __elements -> count ( ) == 0 || ! is_object ( $ objFieldset ) ) { $ objFieldset = $ this -> addFieldset ( ) ; } $ objArea -> setMeta ( "parent" , $ objFieldset , true ) ; $ objFieldset -> addField ( $ objArea ) ; return $ objArea ; }
Add an area to the internal elements collection .
59,619
public function addMultiField ( $ label = null , $ meta = array ( ) ) { $ strName = ( isset ( $ meta [ "name" ] ) ) ? $ meta [ "name" ] : null ; $ objField = new MultiField ( $ label , $ meta , $ strName ) ; $ objField -> setRequiredStyle ( $ this -> __requiredstyle ) ; $ objFieldset = $ this -> __elements -> getLast ( "ValidFormBuilder\\Fieldset" ) ; if ( $ this -> __elements -> count ( ) == 0 || ! is_object ( $ objFieldset ) ) { $ objFieldset = $ this -> addFieldset ( ) ; } $ objField -> setMeta ( "parent" , $ objFieldset , true ) ; $ objFieldset -> addField ( $ objField ) ; return $ objField ; }
Create a Multifield element
59,620
public function toHtml ( $ blnClientSide = true , $ blnForceSubmitted = null , $ strCustomJs = "" ) { $ strOutput = "" ; if ( $ blnClientSide ) { $ strOutput .= $ this -> __toJS ( $ strCustomJs ) ; } $ strClass = "validform" ; if ( is_array ( $ this -> __meta ) ) { if ( isset ( $ this -> __meta [ "class" ] ) ) { $ strClass .= " " . $ this -> __meta [ "class" ] ; } } $ blnForceSubmitted = ( is_null ( $ blnForceSubmitted ) ) ? $ this -> isSubmitted ( ) : $ blnForceSubmitted ; $ strAutoComplete = ( ! $ this -> autocomplete ) ? "autocomplete=\"off\" " : "" ; $ strOutput .= "<form " . "id=\"{$this->__name}\" " . "method=\"post\" " . "enctype=\"multipart/form-data\" " . "action=\"{$this->__action}\" {$strAutoComplete}" . "class=\"{$strClass}\"{$this->__metaToData()}>\n" ; if ( $ blnForceSubmitted && ! empty ( $ this -> __mainalert ) ) { $ strOutput .= "<div class=\"vf__main_error\"><p>{$this->__mainalert}</p></div>\n" ; } if ( ! empty ( $ this -> __description ) ) { $ strOutput .= "<div class=\"vf__description\"><p>{$this->__description}</p></div>\n" ; } $ blnNavigation = false ; $ strOutput .= $ this -> fieldsToHtml ( $ blnForceSubmitted , $ blnNavigation ) ; if ( ! $ blnNavigation ) { $ strOutput .= "<div class=\"vf__navigation\">\n" ; $ strOutput .= "<input type=\"submit\" value=\"{$this->__submitlabel}\" class=\"vf__button\" />\n" ; $ strOutput .= "</div>\n" ; } $ strOutput .= "<input type=\"hidden\" name=\"vf__dispatch\" value=\"{$this->__name}\" />\n" ; if ( $ this -> __usecsrfprotection ) { $ strOutput .= "<input type=\"hidden\" name=\"" . CSRF :: TOKEN_NAME . "\" value=\"" . CSRF :: getToken ( ) . "\" />\n" ; } $ strOutput .= "</form>" ; return $ strOutput ; }
Generate HTML output - build form
59,621
public function fieldsToHtml ( $ blnForceSubmitted = false , & $ blnNavigation = false ) { $ strReturn = "" ; if ( is_array ( $ this -> __defaults ) && count ( $ this -> __defaults ) > 0 ) { $ objFields = $ this -> getCachedFields ( ) ; foreach ( $ objFields as $ objField ) { $ strName = $ objField -> getName ( true ) ; if ( array_key_exists ( $ strName , $ this -> __defaults ) ) { $ varValue = $ this -> __defaults [ $ strName ] ; $ blnDynamic = $ objField -> isDynamic ( ) ; if ( ! $ blnDynamic ) { $ objParent = $ objField -> getMeta ( "parent" , null ) ; if ( is_object ( $ objParent ) ) { $ blnDynamic = $ objParent -> isDynamic ( ) ; } } if ( is_array ( $ varValue ) && ! array_key_exists ( $ strName . "_dynamic" , $ this -> __defaults ) && $ blnDynamic ) { $ intDynamicCount = 0 ; if ( count ( $ varValue ) > 0 ) { $ intDynamicCount = count ( $ varValue ) - 1 ; } $ this -> __defaults [ $ strName . "_dynamic" ] = $ intDynamicCount ; } $ objField -> setDefault ( $ varValue ) ; } } } $ blnDisplayErrors = ( $ this -> isSubmitted ( ) ) ? true : $ this -> getDisplayErrors ( ) ; foreach ( $ this -> __elements as $ element ) { $ strReturn .= $ element -> toHtml ( $ this -> isSubmitted ( $ blnForceSubmitted ) , false , true , $ blnDisplayErrors ) ; if ( get_class ( $ element ) == "ValidFormBuilder\\Navigation" ) { $ blnNavigation = true ; } } return $ strReturn ; }
This method generates HTML output for the current internal elements collection .
59,622
public function elementsToJs ( $ blnRawJs = false ) { $ strReturn = "" ; $ strJs = "" ; foreach ( $ this -> __elements as $ element ) { $ strJs .= $ element -> toJS ( ) ; } $ strJs = str_replace ( "\n" , "\n\t" , $ strJs ) ; if ( ! $ blnRawJs ) { $ strReturn .= "<script type=\"text/javascript\">\n" ; $ strReturn .= "// <![CDATA[\n" ; } $ strReturn .= "\tvar objForm = $(\"#{$this->__name}\").data(\"vf__formElement\");\n\t" ; $ strReturn .= $ strJs ; $ strReturn .= "objForm.initialize();\n" ; if ( ! $ blnRawJs ) { $ strReturn .= "// ]]>\n" ; $ strReturn .= "</script>\n" ; } return $ strReturn ; }
Generate the Javascript output only for the fields and conditions .
59,623
public function serialize ( $ blnSubmittedValues = true ) { $ this -> valuesAsHtml ( $ blnSubmittedValues ) ; return base64_encode ( gzcompress ( serialize ( $ this ) ) ) ; }
Serialize compress and encode the entire form including it s values
59,624
public function getFields ( ) { $ objFields = new Collection ( ) ; foreach ( $ this -> __elements as $ objFieldset ) { if ( $ objFieldset -> hasFields ( ) ) { foreach ( $ objFieldset -> getFields ( ) as $ objField ) { if ( is_object ( $ objField ) ) { if ( $ objField -> hasFields ( ) ) { if ( get_class ( $ objField ) == "ValidFormBuilder\\Area" && $ objField -> isActive ( ) ) { $ objFields -> addObject ( $ objField ) ; } foreach ( $ objField -> getFields ( ) as $ objSubField ) { if ( is_object ( $ objSubField ) ) { if ( $ objSubField -> hasFields ( ) ) { if ( get_class ( $ objSubField ) == "ValidFormBuilder\\Area" && $ objSubField -> isActive ( ) ) { $ objFields -> addObject ( $ objSubField ) ; } foreach ( $ objSubField -> getFields ( ) as $ objSubSubField ) { if ( is_object ( $ objSubSubField ) ) { $ objFields -> addObject ( $ objSubSubField ) ; } } } else { $ objFields -> addObject ( $ objSubField ) ; } } } } else { $ objFields -> addObject ( $ objField ) ; } } } } else { $ objFields -> addObject ( $ objFieldset ) ; } } $ this -> __cachedfields = $ objFields ; return $ objFields ; }
Get a flat Collection of all internal elements .
59,625
public function getValidField ( $ id ) { $ objReturn = null ; $ objFields = $ this -> getFields ( ) ; foreach ( $ objFields as $ objField ) { if ( $ objField -> getId ( ) == $ id ) { $ objReturn = $ objField ; break ; } } if ( is_null ( $ objReturn ) ) { foreach ( $ objFields as $ objField ) { if ( $ objField -> getName ( ) == $ id ) { $ objReturn = $ objField ; break ; } } } return $ objReturn ; }
Get a valid field object .
59,626
public function valuesAsHtml ( $ hideEmpty = false , $ collection = null ) { $ strTable = "\t<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"validform\">\n" ; $ strTableOutput = "" ; $ collection = ( ! is_null ( $ collection ) ) ? $ collection : $ this -> __elements ; foreach ( $ collection as $ objFieldset ) { $ strSet = "" ; $ strTableOutput .= $ this -> fieldsetAsHtml ( $ objFieldset , $ strSet , $ hideEmpty ) ; } if ( ! empty ( $ strTableOutput ) ) { return $ strTable . $ strTableOutput . "</table>" ; } else { if ( ! empty ( $ this -> __novaluesmessage ) ) { return $ strTable . "<tr><td colspan=\"3\">{$this->__novaluesmessage}</td></tr></table>" ; } else { return "" ; } } }
A utility method to parse an overview of the submitted values .
59,627
public function fieldsetAsHtml ( $ objFieldset , & $ strSet , $ hideEmpty = false ) { $ strTableOutput = "" ; if ( ! $ this -> elementShouldDisplay ( $ objFieldset ) ) { return $ strTableOutput ; } foreach ( $ objFieldset -> getFields ( ) as $ objField ) { if ( is_object ( $ objField ) && get_class ( $ objField ) !== "ValidFormBuilder\\Hidden" ) { $ strValue = $ objField -> getValue ( ) ; if ( is_array ( $ strValue ) ) { $ strValue = implode ( ", " , $ strValue ) ; } if ( ( ! empty ( $ strValue ) && $ hideEmpty ) || ( ! $ hideEmpty && ! is_null ( $ strValue ) ) ) { if ( $ objField -> hasFields ( ) ) { switch ( get_class ( $ objField ) ) { case "ValidFormBuilder\\MultiField" : $ strSet .= $ this -> multiFieldAsHtml ( $ objField , $ hideEmpty ) ; break ; default : $ strSet .= $ this -> areaAsHtml ( $ objField , $ hideEmpty ) ; } } else { $ strSet .= $ this -> fieldAsHtml ( $ objField , $ hideEmpty ) ; } } if ( $ objField -> isDynamic ( ) ) { $ intDynamicCount = $ objField -> getDynamicCount ( ) ; if ( $ intDynamicCount > 0 ) { for ( $ intCount = 1 ; $ intCount <= $ intDynamicCount ; $ intCount ++ ) { switch ( get_class ( $ objField ) ) { case "ValidFormBuilder\\MultiField" : $ strSet .= $ this -> multiFieldAsHtml ( $ objField , $ hideEmpty , $ intCount ) ; break ; case "ValidFormBuilder\\Area" : $ strSet .= $ this -> areaAsHtml ( $ objField , $ hideEmpty , $ intCount ) ; break ; default : $ strSet .= $ this -> fieldAsHtml ( $ objField , $ hideEmpty , $ intCount ) ; } } } } } } $ strHeader = $ objFieldset -> getHeader ( ) ; if ( ! empty ( $ strHeader ) && ! empty ( $ strSet ) ) { $ strTableOutput .= "<tr>" ; $ strTableOutput .= "<td colspan=\"3\">&nbsp;</td>\n" ; $ strTableOutput .= "</tr>" ; $ strTableOutput .= "<tr>" ; $ strTableOutput .= "<td colspan=\"3\"><b>{$strHeader}</b></td>\n" ; $ strTableOutput .= "</tr>" ; } if ( ! empty ( $ strSet ) ) { $ strTableOutput .= $ strSet ; } return $ strTableOutput ; }
Generates HTML output for all fieldsets and their children elements .
59,628
protected function areaAsHtml ( $ objField , $ hideEmpty = false , $ intDynamicCount = 0 ) { $ strReturn = "" ; $ strSet = "" ; $ blnShouldDisplay = $ this -> elementShouldDisplay ( $ objField ) ; if ( $ objField -> hasContent ( $ intDynamicCount ) && $ blnShouldDisplay ) { foreach ( $ objField -> getFields ( ) as $ objSubField ) { if ( get_class ( $ objSubField ) !== "ValidFormBuilder\\Paragraph" ) { switch ( get_class ( $ objSubField ) ) { case "ValidFormBuilder\\MultiField" : $ strSet .= $ this -> multiFieldAsHtml ( $ objSubField , $ hideEmpty , $ intDynamicCount ) ; break ; default : $ strSet .= $ this -> fieldAsHtml ( $ objSubField , $ hideEmpty , $ intDynamicCount ) ; if ( $ objSubField -> isDynamic ( ) ) { $ intDynamicCount = $ objSubField -> getDynamicCount ( ) ; for ( $ intCount = 1 ; $ intCount <= $ intDynamicCount ; $ intCount ++ ) { $ strSet .= $ this -> fieldAsHtml ( $ objSubField , $ hideEmpty , $ intCount ) ; } } } } } } $ strLabel = $ objField -> getShortLabel ( ) ; if ( ! empty ( $ strSet ) ) { if ( ! empty ( $ strLabel ) ) { $ strReturn = "<tr>" ; $ strReturn .= "<td colspan=\"3\" style=\"white-space:nowrap\" class=\"vf__area_header\">" ; $ strReturn .= "<h3>{$strLabel}</h3>" ; $ strReturn .= "</td>\n" ; $ strReturn .= "</tr>" ; } $ strReturn .= $ strSet ; } else { if ( ! empty ( $ this -> __novaluesmessage ) && $ objField -> isActive ( ) ) { $ strReturn = "<tr>" ; $ strReturn .= "<td colspan=\"3\" style=\"white-space:nowrap\" class=\"vf__area_header\">" ; $ strReturn .= "<h3>{$strLabel}</h3>" ; $ strReturn .= "</td>\n" ; $ strReturn .= "</tr>" ; return $ strReturn . "<tr><td colspan=\"3\">{$this->__novaluesmessage}</td></tr>" ; } else { return "" ; } } return $ strReturn ; }
Generates HTML output for the given area object and its child elements
59,629
protected function multiFieldAsHtml ( $ objField , $ hideEmpty = false , $ intDynamicCount = 0 ) { $ strReturn = "" ; if ( ! $ this -> elementShouldDisplay ( $ objField ) ) { return $ strReturn ; } if ( $ objField -> hasContent ( $ intDynamicCount ) ) { if ( $ objField -> hasFields ( ) ) { $ strValue = "" ; $ objSubFields = $ objField -> getFields ( ) ; $ intCount = 0 ; foreach ( $ objSubFields as $ objSubField ) { $ intCount ++ ; if ( get_class ( $ objSubField ) == "ValidFormBuilder\\Hidden" && $ objSubField -> isDynamicCounter ( ) ) { continue ; } $ varValue = $ objSubField -> getValue ( $ intDynamicCount ) ; $ strValue .= ( is_array ( $ varValue ) ) ? implode ( ", " , $ varValue ) : $ varValue ; $ strValue .= ( $ objSubFields -> count ( ) > $ intCount ) ? " " : "" ; } $ strValue = trim ( $ strValue ) ; $ strLabel = $ objField -> getShortLabel ( ) ; if ( ( ! empty ( $ strValue ) && $ hideEmpty ) || ( ! $ hideEmpty && ! empty ( $ strValue ) ) ) { $ strValue = htmlspecialchars ( $ strValue , ENT_QUOTES ) ; $ strValue = nl2br ( $ strValue ) ; $ strReturn .= "<tr class=\"vf__field_value\">" ; $ strReturn .= "<td valign=\"top\"" ; $ strReturn .= " style=\"white-space:nowrap; padding-right: 20px\"" ; $ strReturn .= " class=\"vf__field\">" ; $ strReturn .= $ strLabel ; $ strReturn .= "</td>" ; $ strReturn .= "<td valign=\"top\" class=\"vf__value\">" ; $ strReturn .= "<strong>" . $ strValue . "</strong>" ; $ strReturn .= "</td>\n" ; $ strReturn .= "</tr>" ; } } } return $ strReturn ; }
Generates HTML output for the given MultiField object and its child elements
59,630
protected function fieldAsHtml ( $ objField , $ hideEmpty = false , $ intDynamicCount = 0 ) { $ strReturn = "" ; $ strLabel = $ objField -> getShortLabel ( ) ; $ varValue = ( $ intDynamicCount > 0 ) ? $ objField -> getValue ( $ intDynamicCount ) : $ objField -> getValue ( ) ; $ strValue = ( is_array ( $ varValue ) ) ? implode ( ", " , $ varValue ) : $ varValue ; if ( ! $ this -> elementShouldDisplay ( $ objField ) ) { return $ strReturn ; } if ( ( ! empty ( $ strValue ) && $ hideEmpty ) || ( ! $ hideEmpty && ! is_null ( $ strValue ) ) ) { if ( ( get_class ( $ objField ) == "ValidFormBuilder\\Hidden" ) && $ objField -> isDynamicCounter ( ) ) { return $ strReturn ; } else { switch ( $ objField -> getType ( ) ) { case static :: VFORM_BOOLEAN : $ strValue = ( $ strValue == 1 ) ? "yes" : "no" ; break ; } if ( empty ( $ strLabel ) && empty ( $ strValue ) ) { } else { $ strValue = htmlspecialchars ( $ strValue , ENT_QUOTES ) ; $ strValue = nl2br ( $ strValue ) ; $ strReturn .= "<tr class=\"vf__field_value\">" ; $ strReturn .= "<td valign=\"top\" style=\"padding-right: 20px\" class=\"vf__field\">" ; $ strReturn .= $ strLabel ; $ strReturn .= "</td>" ; $ strReturn .= "<td valign=\"top\" class=\"vf__value\">" ; $ strReturn .= "<strong>" . $ strValue . "</strong>" ; $ strReturn .= "</td>\n" ; $ strReturn .= "</tr>" ; } } } return $ strReturn ; }
Generates HTML output for the given field object and its child elements
59,631
public function generateId ( $ intLength = 8 ) { $ strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ; $ strReturn = '' ; srand ( ( double ) microtime ( ) * 1000000 ) ; for ( $ i = 1 ; $ i <= $ intLength ; $ i ++ ) { $ intNum = rand ( ) % ( strlen ( $ strChars ) - 1 ) ; $ strTmp = substr ( $ strChars , $ intNum , 1 ) ; $ strReturn .= $ strTmp ; } return $ strReturn ; }
Generate a unique ID
59,632
public static function getHttpBodyValue ( $ param , $ varReplaceNotSet = null ) { parse_str ( file_get_contents ( 'php://input' ) , $ arrPostVars ) ; $ strReturn = ( isset ( $ arrPostVars [ $ param ] ) ) ? $ arrPostVars [ $ param ] : $ varReplaceNotSet ; return $ strReturn ; }
Get the value of a form field from the raw HTTP body . This is used for PUT and DELETE HTTP methods .
59,633
protected function __toJS ( $ strCustomJs = "" , $ arrInitArguments = array ( ) , $ blnRawJs = false ) { $ strReturn = "" ; $ strJs = "" ; foreach ( $ this -> __elements as $ element ) { $ strJs .= $ element -> toJS ( ) ; } foreach ( $ this -> __jsevents as $ event => $ method ) { $ strJs .= "\tobjForm.addEvent(\"{$event}\", {$method});\n" ; } $ strJs = str_replace ( "\n" , "\n\t" , $ strJs ) ; if ( ! $ blnRawJs ) { $ strReturn .= "<script type=\"text/javascript\">\n" ; $ strReturn .= "// <![CDATA[\n" ; } $ strName = str_replace ( "-" , "_" , $ this -> __name ) ; $ strReturn .= "function {$strName}_init() {\n" ; $ strCalledClass = static :: getStrippedClassName ( get_called_class ( ) ) ; $ strArguments = "\"{$this->__name}\", \"{$this->__mainalert}\"" ; if ( count ( $ arrInitArguments ) > 0 ) { $ strArguments = "\"{$this->__name}\", \"{$this->__mainalert}\", " . json_encode ( $ arrInitArguments ) ; } if ( $ strCalledClass !== "ValidForm" ) { $ strReturn .= "\tvar objForm = (typeof {$strCalledClass} !== \"undefined\") ? " ; $ strReturn .= "new {$strCalledClass}({$strArguments}) : " ; $ strReturn .= "new ValidForm(\"{$this->__name}\", \"{$this->__mainalert}\");\n" ; } else { $ strReturn .= "\tvar objForm = new ValidForm(\"{$this->__name}\", \"{$this->__mainalert}\");\n" ; } $ strReturn .= $ strJs ; if ( ! empty ( $ strCustomJs ) ) { $ strReturn .= $ strCustomJs ; } $ strReturn .= "\tobjForm.initialize();\n" ; $ strReturn .= "\t$(\"#{$this->__name}\").data(\"vf__formElement\", objForm);" ; $ strReturn .= "};\n" ; $ strReturn .= "\n" ; $ strReturn .= "try {\n" ; $ strReturn .= "\tjQuery(function(){\n" ; $ strReturn .= "\t\t{$this->__name}_init();\n" ; $ strReturn .= "\t});\n" ; $ strReturn .= "} catch (e) {\n" ; $ strReturn .= "\talert('Exception caught while initiating ValidForm:\\n\\n' + e.message);\n" ; $ strReturn .= "}\n" ; if ( ! $ blnRawJs ) { $ strReturn .= "// ]]>\n" ; $ strReturn .= "</script>\n" ; } return $ strReturn ; }
Generate javascript initialization code .
59,634
protected function elementShouldDisplay ( Base $ objElement ) { $ blnReturn = true ; $ objCondition = $ objElement -> getConditionRecursive ( "visible" ) ; if ( is_object ( $ objCondition ) ) { if ( $ objCondition -> isMet ( 0 ) ) { $ blnReturn = $ objCondition -> getValue ( ) ; } else { $ blnReturn = ! $ objCondition -> getValue ( ) ; } } return $ blnReturn ; }
Check if an element should be visible according to an optionally attached visible condition .
59,635
private function __validate ( ) { $ blnReturn = true ; foreach ( $ this -> __elements as $ element ) { if ( ! $ element -> isValid ( ) ) { $ blnReturn = false ; break ; } } return $ blnReturn ; }
Loops trough all internal elements in the collection and validates each element .
59,636
public static function getStrippedClassName ( $ classname ) { $ pos = strrpos ( $ classname , '\\' ) ; if ( $ pos ) { return substr ( $ classname , $ pos + 1 ) ; } return $ classname ; }
Returns the class name and strips off the namespace .
59,637
private static function splitFriendlyEmail ( $ email ) { if ( false !== strpos ( $ email , '<' ) ) { return array_map ( 'trim' , explode ( ' <' , str_replace ( '>' , '' , $ email ) ) ) ; } elseif ( false !== strpos ( $ email , '[' ) ) { return array_map ( 'trim' , explode ( ' [' , str_replace ( ']' , '' , $ email ) ) ) ; } else { return [ '' , $ email ] ; } }
Split a friendly - name e - address and return name and e - mail as array
59,638
public function regenerateUrls ( ) { $ router = Router :: getInstance ( ) ; try { $ router -> hydrateRouting ( ) ; $ router -> simpatize ( ) ; Security :: getInstance ( ) -> setFlash ( "callback_message" , t ( "Rutas generadas correctamente" ) ) ; Security :: getInstance ( ) -> setFlash ( "callback_route" , $ this -> getRoute ( "admin-routes" , true ) ) ; } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_ERR ) ; Security :: getInstance ( ) -> setFlash ( "callback_message" , t ( "Algo no ha salido bien, revisa los logs" ) ) ; Security :: getInstance ( ) -> setFlash ( "callback_route" , $ this -> getRoute ( "admin-routes" , true ) ) ; } return $ this -> redirect ( 'admin-routes' ) ; }
Service to regenerate routes
59,639
private function updateData ( $ callback = null ) : void { $ queryBuilder = $ this -> dbUtils -> getConn ( ) -> createQueryBuilder ( ) ; if ( $ this -> limit === 0 ) { $ this -> setLimit ( $ this -> dbUtils -> countResults ( $ this -> entity ) ) ; } $ this -> expression -> evaluateExpressions ( $ this -> configEntities [ $ this -> entity ] [ 'pre_actions' ] ) ; $ startAt = 0 ; $ num = 0 ; while ( $ num < $ this -> limit ) { $ rows = $ queryBuilder -> select ( '*' ) -> from ( $ this -> entity ) -> setFirstResult ( $ startAt ) -> setMaxResults ( $ this -> batchSize ) -> orderBy ( $ this -> priKey ) -> execute ( ) ; foreach ( $ rows as $ row ) { $ this -> { $ this -> updateMode [ $ this -> mode ] } ( $ row ) ; if ( $ callback !== null ) { $ callback ( ++ $ num ) ; } if ( $ num >= $ this -> limit ) { break 2 ; } } $ num = $ startAt += $ this -> batchSize ; } if ( $ this -> mode === 'batch' ) { $ this -> loadDataInBatch ( 'update' ) ; } $ this -> expression -> evaluateExpressions ( $ this -> configEntities [ $ this -> entity ] [ 'post_actions' ] ) ; }
Update data of db table .
59,640
private function insertData ( $ callback = null ) : void { $ this -> expression -> evaluateExpressions ( $ this -> configEntities [ $ this -> entity ] [ 'pre_actions' ] ) ; for ( $ rowNum = 1 ; $ rowNum <= $ this -> limit ; $ rowNum ++ ) { $ this -> { $ this -> insertMode [ $ this -> mode ] } ( $ rowNum ) ; if ( ! is_null ( $ callback ) ) { $ callback ( $ rowNum ) ; } } if ( $ this -> mode === 'batch' ) { $ this -> loadDataInBatch ( 'insert' ) ; } $ this -> expression -> evaluateExpressions ( $ this -> configEntities [ $ this -> entity ] [ 'post_actions' ] ) ; }
Insert data into table
59,641
private function doInsertByQueries ( ) : void { $ data = $ this -> generateFakeData ( ) ; $ queryBuilder = $ this -> dbUtils -> getConn ( ) -> createQueryBuilder ( ) ; $ queryBuilder = $ queryBuilder -> insert ( $ this -> entity ) ; foreach ( $ data as $ field => $ value ) { $ queryBuilder = $ queryBuilder -> setValue ( $ field , ":$field" ) ; $ queryBuilder = $ queryBuilder -> setParameter ( ":$field" , $ value ) ; } $ this -> returnRes === true ? array_push ( $ this -> queries , $ this -> dbUtils -> getRawSQL ( $ queryBuilder ) ) : null ; if ( $ this -> pretend === false ) { $ queryBuilder -> execute ( ) ; } }
Execute an INSERT with Doctrine QueryBuilder
59,642
public function toHtml ( $ submitted = false , $ blnSimpleLayout = false , $ blnLabel = true , $ blnDisplayErrors = true ) { if ( ! empty ( $ this -> __disabled ) ) { $ this -> setFieldMeta ( "disabled" , "disabled" ) ; } $ strReturn = "<input type=\"{$this->__type}\" value=\"{$this->__label}\"{$this->__getFieldMetaString()} />\n" ; return $ strReturn ; }
Generate the HTML output for this button
59,643
public function check ( $ intDynamicPosition = 0 ) { $ blnReturn = false ; if ( $ this -> __subject instanceof Element ) { $ strValue = $ this -> __subject -> __getValue ( true , $ intDynamicPosition ) ; $ strValue = ( is_null ( $ strValue ) ) ? $ strValue = $ this -> __subject -> getValue ( $ intDynamicPosition ) : $ strValue ; if ( ! is_null ( $ strValue ) ) { if ( is_array ( $ strValue ) && isset ( $ strValue [ $ intDynamicPosition ] ) ) { $ strValue = $ strValue [ $ intDynamicPosition ] ; } $ blnReturn = $ this -> __verify ( $ strValue ) ; } } else { throw new \ Exception ( "Invalid subject supplied in Comparison. Class " . get_class ( $ this -> __subject ) . " given. Expecting instance of Element." , 1 ) ; } return $ blnReturn ; }
Check this comparison
59,644
public function jsonSerialize ( $ intDynamicPosition = null ) { if ( get_class ( $ this -> __subject ) == "ValidFormBuilder\\GroupField" ) { $ identifier = $ this -> __subject -> getId ( ) ; } else { $ identifier = $ this -> __subject -> getName ( ) ; if ( $ intDynamicPosition > 0 ) { $ identifier = $ identifier . "_" . $ intDynamicPosition ; } } $ arrReturn = array ( "subject" => $ identifier , "comparison" => $ this -> __comparison , "value" => $ this -> __value ) ; return $ arrReturn ; }
Convert the Comparion s contents to a json string in order to validate this comparison client - side
59,645
private function __verify ( $ strValue ) { $ blnReturn = false ; $ strLowerValue = strtolower ( $ strValue ) ; $ strCompareAgainst = ( is_string ( $ this -> __value ) ) ? strtolower ( $ this -> __value ) : null ; switch ( $ this -> __comparison ) { case ValidForm :: VFORM_COMPARISON_EQUAL : $ blnReturn = ( $ strLowerValue == $ strCompareAgainst ) ; break ; case ValidForm :: VFORM_COMPARISON_NOT_EQUAL : $ blnReturn = ( $ strLowerValue != $ strCompareAgainst ) ; break ; case ValidForm :: VFORM_COMPARISON_LESS_THAN : $ blnReturn = ( $ strValue < $ this -> __value ) ; break ; case ValidForm :: VFORM_COMPARISON_GREATER_THAN : $ blnReturn = ( $ strValue > $ this -> __value ) ; break ; case ValidForm :: VFORM_COMPARISON_LESS_THAN_OR_EQUAL : $ blnReturn = ( $ strValue <= $ this -> __value ) ; break ; case ValidForm :: VFORM_COMPARISON_GREATER_THAN_OR_EQUAL : $ blnReturn = ( $ strValue >= $ this -> __value ) ; break ; case ValidForm :: VFORM_COMPARISON_EMPTY : $ blnReturn = empty ( $ strValue ) ; break ; case ValidForm :: VFORM_COMPARISON_NOT_EMPTY : $ blnReturn = ! empty ( $ strValue ) ; break ; case ValidForm :: VFORM_COMPARISON_STARTS_WITH : $ blnReturn = ( strpos ( $ strLowerValue , $ strCompareAgainst ) === 0 ) ; break ; case ValidForm :: VFORM_COMPARISON_ENDS_WITH : $ blnReturn = ( substr ( $ strLowerValue , - strlen ( $ strCompareAgainst ) ) === $ strCompareAgainst ) ; break ; case ValidForm :: VFORM_COMPARISON_CONTAINS : $ blnReturn = ( strpos ( $ strLowerValue , $ strCompareAgainst ) !== false ) ; break ; case ValidForm :: VFORM_COMPARISON_REGEX : $ blnReturn = preg_match ( $ this -> __value , $ strValue ) ; break ; case ValidForm :: VFORM_COMPARISON_IN_ARRAY : $ blnReturn = in_array ( $ strValue , $ this -> __value ) ; break ; case ValidForm :: VFORM_COMPARISON_NOT_IN_ARRAY : $ blnReturn = ! in_array ( $ strValue , $ this -> __value ) ; break ; } return $ blnReturn ; }
Verify this comparison against the actual value
59,646
public static function clearDocumentRoot ( ) { $ rootDirs = array ( "css" , "js" , "media" , "font" ) ; foreach ( $ rootDirs as $ dir ) { if ( file_exists ( WEB_DIR . DIRECTORY_SEPARATOR . $ dir ) ) { try { self :: deleteDir ( WEB_DIR . DIRECTORY_SEPARATOR . $ dir ) ; } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) ) ; } } } }
Method that remove all data in the document root path
59,647
public static function createDir ( $ dir ) { try { if ( ! is_dir ( $ dir ) && @ mkdir ( $ dir , 0775 , true ) === false ) { throw new \ Exception ( t ( 'Can\'t create directory ' ) . $ dir ) ; } } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_WARNING ) ; if ( ! file_exists ( dirname ( $ dir ) ) ) { throw new GeneratorException ( $ e -> getMessage ( ) . $ dir ) ; } } }
Method that creates any parametrized path
59,648
public static function getTemplatePath ( ) { $ path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR ; return realpath ( $ path ) ; }
Method that returns the templates path
59,649
private function convertToBytes ( $ strSize ) { switch ( strtolower ( substr ( $ strSize , - 1 ) ) ) { case 'm' : return ( int ) $ strSize * 1048576 ; case 'k' : return ( int ) $ strSize * 1024 ; case 'g' : return ( int ) $ strSize * 1073741824 ; default : return $ strSize ; } }
Convert file size to bytes
59,650
public function registerCustomTypes ( ) : void { if ( \ Doctrine \ DBAL \ Types \ Type :: hasType ( 'neuralyzer_enum' ) ) { return ; } \ Doctrine \ DBAL \ Types \ Type :: addType ( 'neuralyzer_enum' , 'Edyan\Neuralyzer\Doctrine\Type\Enum' ) ; $ platform = $ this -> conn -> getDatabasePlatform ( ) ; $ platform -> registerDoctrineTypeMapping ( 'enum' , 'neuralyzer_enum' ) ; $ platform -> registerDoctrineTypeMapping ( 'bit' , 'boolean' ) ; }
Add a custom enum type
59,651
public function isSubmitted ( $ blnForce = false ) { $ blnReturn = false ; if ( ValidForm :: get ( "vf__dispatch" ) == $ this -> __name ) { $ strUniqueId = ValidWizard :: get ( "vf__uniqueid" ) ; if ( ! empty ( $ strUniqueId ) ) { $ this -> __setUniqueId ( $ strUniqueId ) ; } $ blnReturn = true ; } elseif ( $ blnForce ) { $ blnReturn = true ; } return $ blnReturn ; }
Check if the wizard is submitted
59,652
public function getPage ( $ intPage = 1 ) { $ intPage -- ; if ( $ intPage < 0 ) { $ intPage = 0 ; } $ this -> __elements -> seek ( $ intPage ) ; $ objReturn = $ this -> __elements -> current ( ) ; if ( $ objReturn === false || get_class ( $ objReturn ) !== "ValidFormBuilder\\Page" ) { $ objReturn = null ; } return $ objReturn ; }
Get a page from the collection based on it s zero - based position in the elements collection
59,653
public function addPage ( $ id = "" , $ header = "" , $ meta = array ( ) ) { $ objPage = new Page ( $ id , $ header , $ meta ) ; $ this -> __elements -> addObject ( $ objPage ) ; if ( $ this -> __elements -> count ( ) == 1 ) { $ this -> addHiddenField ( "vf__uniqueid" , ValidForm :: VFORM_STRING , array ( "default" => $ this -> getUniqueId ( ) ) ) ; } $ this -> __pagecount ++ ; return $ objPage ; }
Add a page to the wizard
59,654
public function addFieldset ( $ header = null , $ noteHeader = null , $ noteBody = null , $ meta = array ( ) ) { $ objFieldSet = new Fieldset ( $ header , $ noteHeader , $ noteBody , $ meta ) ; $ objPage = $ this -> __elements -> getLast ( "ValidFormBuilder\\Page" ) ; if ( ! is_object ( $ objPage ) ) { $ objPage = $ this -> addPage ( ) ; } $ objPage -> addField ( $ objFieldSet ) ; return $ objFieldSet ; }
Add a fieldset
59,655
public function valuesAsHtml ( $ hideEmpty = false , $ collection = null ) { $ strTable = "\t<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"validform\">\n" ; $ strTableOutput = "" ; $ collection = ( ! is_null ( $ collection ) ) ? $ collection : $ this -> __elements ; foreach ( $ collection as $ objPage ) { if ( get_class ( $ objPage ) === "ValidFormBuilder\\Page" ) { if ( ! $ this -> elementShouldDisplay ( $ objPage ) ) { continue ; } $ strHeader = $ objPage -> getShortHeader ( ) ; $ strTableOutput .= "<tr><td colspan=\"3\" class=\"vf__page-header\">{$strHeader}</td></tr>" ; foreach ( $ objPage -> getFields ( ) as $ objFieldset ) { $ strSet = "" ; $ strTableOutput .= parent :: fieldsetAsHtml ( $ objFieldset , $ strSet , $ hideEmpty ) ; } } } if ( ! empty ( $ strTableOutput ) ) { return $ strTable . $ strTableOutput . "</table>" ; } else { if ( ! empty ( $ this -> __novaluesmessage ) ) { return $ strTable . "<tr><td colspan=\"3\">{$this->__novaluesmessage}</td></tr></table>" ; } else { return "" ; } } }
Generate valuesAsHtml overview
59,656
public static function unserialize ( $ strSerialized , $ strUniqueId = "" ) { $ objReturn = parent :: unserialize ( $ strSerialized ) ; if ( get_class ( $ objReturn ) == "ValidFormBuilder\\ValidWizard" && ! empty ( $ strUniqueId ) ) { $ objReturn -> __setUniqueId ( $ strUniqueId ) ; } return $ objReturn ; }
Unserialize a previously serialized ValidWizard object
59,657
protected function __toJs ( $ strCustomJs = "" , $ arrInitArguments = array ( ) , $ blnRawJs = false ) { if ( $ this -> __currentpage > 1 ) { $ arrInitArguments [ "initialPage" ] = $ this -> __currentpage ; } $ arrInitArguments [ "confirmPage" ] = $ this -> __hasconfirmpage ; $ strJs = "" ; $ strJs .= "objForm.setLabel('next', '" . $ this -> __nextlabel . "');\n\t" ; $ strJs .= "objForm.setLabel('previous', '" . $ this -> __previouslabel . "');\n\t" ; if ( ! empty ( $ this -> __nextclass ) ) { $ strJs .= "objForm.setClass('next', '" . $ this -> __nextclass . "');\n\t" ; } if ( ! empty ( $ this -> __previousclass ) ) { $ strJs .= "objForm.setClass('previous', '" . $ this -> __previousclass . "');\n\t" ; } if ( strlen ( $ strCustomJs ) > 0 ) { $ strJs .= $ strCustomJs ; } return parent :: __toJs ( $ strJs , $ arrInitArguments , $ blnRawJs ) ; }
Generate Javascript code
59,658
public function getFields ( $ blnIncludeMultiFields = false ) { $ objFields = new Collection ( ) ; foreach ( $ this -> __elements as $ objPage ) { if ( $ objPage -> hasFields ( ) ) { foreach ( $ objPage -> getFields ( ) as $ objFieldset ) { if ( $ objFieldset -> hasFields ( ) ) { foreach ( $ objFieldset -> getFields ( ) as $ objField ) { if ( is_object ( $ objField ) ) { if ( $ objField -> hasFields ( ) ) { if ( get_class ( $ objField ) == "ValidFormBuilder\\MultiField" && $ blnIncludeMultiFields ) { $ objFields -> addObject ( $ objField ) ; } foreach ( $ objField -> getFields ( ) as $ objSubField ) { if ( is_object ( $ objSubField ) ) { if ( $ objSubField -> hasFields ( ) ) { if ( get_class ( $ objField ) == "ValidFormBuilder\\MultiField" && $ blnIncludeMultiFields ) { $ objFields -> addObject ( $ objField ) ; } foreach ( $ objSubField -> getFields ( ) as $ objSubSubField ) { if ( is_object ( $ objSubSubField ) ) { $ objFields -> addObject ( $ objSubSubField ) ; } } } else { $ objFields -> addObject ( $ objSubField ) ; } } } } else { $ objFields -> addObject ( $ objField ) ; } } } } else { $ objFields -> addObject ( $ objFieldset ) ; } } } else { $ objFields -> addObject ( $ objPage ) ; } } return $ objFields ; }
getFields creates a flat collection of all form fields .
59,659
protected function hasQueryBuilderMethod ( string $ name ) : bool { if ( method_exists ( $ this -> queryBuilder , $ name ) ) { return true ; } if ( method_exists ( $ this -> queryBuilder , 'hasMacro' ) && $ this -> queryBuilder -> hasMacro ( $ name ) ) { return true ; } return false ; }
Does the QueryBuilder we re using have a method with the provided name? This will also check any functionality added via a macro .
59,660
public static function register ( ) { $ postType = static :: getPostType ( ) ; $ config = static :: getPostTypeConfig ( ) ; if ( empty ( $ postType ) || $ postType === 'post' ) { throw new PostTypeRegistrationException ( 'Post type not set' ) ; } if ( empty ( $ config ) ) { throw new PostTypeRegistrationException ( 'Config not set' ) ; } register_post_type ( $ postType , $ config ) ; }
Register this PostType with WordPress
59,661
public static function all ( $ perPage = - 1 , $ orderby = 'menu_order' , $ order = 'ASC' ) { $ order = strtoupper ( $ order ) ; $ args = [ 'posts_per_page' => $ perPage , 'orderby' => $ orderby , 'order' => $ order , ] ; return static :: query ( $ args ) ; }
Get all posts of this type
59,662
public static function query ( $ args = null ) { $ args = is_array ( $ args ) ? $ args : [ ] ; $ args = array_merge ( $ args , [ 'post_type' => static :: getPostType ( ) ] ) ; if ( ! isset ( $ args [ 'post_status' ] ) ) { $ args [ 'post_status' ] = 'publish' ; } return static :: posts ( $ args ) ; }
Convenience function that takes a standard set of WP_Query arguments but mixes it with arguments that mean we re selecting the right post type
59,663
private function run ( TaskExecutionInterface $ execution ) { $ start = microtime ( true ) ; $ execution -> setStartTime ( new \ DateTime ( ) ) ; $ execution -> setStatus ( TaskStatus :: RUNNING ) ; $ this -> taskExecutionRepository -> save ( $ execution ) ; try { $ execution = $ this -> hasPassed ( $ execution , $ this -> handle ( $ execution ) ) ; } catch ( ExitException $ exception ) { throw $ exception ; } catch ( \ Exception $ exception ) { $ execution = $ this -> hasFailed ( $ execution , $ exception ) ; } finally { $ this -> finalize ( $ execution , $ start ) ; } }
Run execution with given handler .
59,664
private function handle ( TaskExecutionInterface $ execution ) { $ this -> eventDispatcher -> dispatch ( Events :: TASK_BEFORE , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; try { return $ this -> executor -> execute ( $ execution ) ; } catch ( RetryException $ exception ) { $ execution = $ this -> taskExecutionRepository -> findByUuid ( $ execution -> getUuid ( ) ) ; if ( $ execution -> getAttempts ( ) === $ exception -> getMaximumAttempts ( ) ) { throw $ exception -> getPrevious ( ) ; } $ execution -> reset ( ) ; $ execution -> incrementAttempts ( ) ; $ this -> eventDispatcher -> dispatch ( Events :: TASK_RETRIED , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; $ this -> taskExecutionRepository -> save ( $ execution ) ; throw new ExitException ( ) ; } finally { $ this -> eventDispatcher -> dispatch ( Events :: TASK_AFTER , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; } }
Handle given execution and fire before and after events .
59,665
private function hasPassed ( TaskExecutionInterface $ execution , $ result ) { $ execution = $ this -> taskExecutionRepository -> findByUuid ( $ execution -> getUuid ( ) ) ; $ execution -> setStatus ( TaskStatus :: COMPLETED ) ; $ execution -> setResult ( $ result ) ; $ this -> eventDispatcher -> dispatch ( Events :: TASK_PASSED , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; return $ execution ; }
The given task passed the run .
59,666
private function hasFailed ( TaskExecutionInterface $ execution , \ Exception $ exception ) { $ execution = $ this -> taskExecutionRepository -> findByUuid ( $ execution -> getUuid ( ) ) ; $ execution -> setException ( $ exception -> __toString ( ) ) ; $ execution -> setStatus ( TaskStatus :: FAILED ) ; $ this -> eventDispatcher -> dispatch ( Events :: TASK_FAILED , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; return $ execution ; }
The given task failed the run .
59,667
private function finalize ( TaskExecutionInterface $ execution , $ start ) { $ execution = $ this -> taskExecutionRepository -> findByUuid ( $ execution -> getUuid ( ) ) ; if ( $ execution -> getStatus ( ) !== TaskStatus :: PLANNED ) { $ execution -> setEndTime ( new \ DateTime ( ) ) ; $ execution -> setDuration ( microtime ( true ) - $ start ) ; } $ this -> eventDispatcher -> dispatch ( Events :: TASK_FINISHED , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; $ this -> taskExecutionRepository -> save ( $ execution ) ; }
Finalizes given execution .
59,668
public function cacheMetrics ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cached != null ) { return $ this -> cached ; } $ this -> cached = $ this -> client -> call ( 'GET' , 'metrics' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; return $ this -> cached ; }
Cache Metrics for performance improvement .
59,669
public function indexMetrics ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cache != false ) { return $ this -> cacheMetrics ( $ num , $ page ) ; } return $ this -> client -> call ( 'GET' , 'metrics' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; }
Get a defined number of Metrics .
59,670
public function searchMetrics ( $ search , $ by , $ limit = 1 , $ num = 1000 , $ page = 1 ) { $ metrics = $ this -> indexMetrics ( $ num , $ page ) [ 'data' ] ; $ filtered = array_filter ( $ metrics , function ( $ metric ) use ( $ search , $ by ) { if ( array_key_exists ( $ by , $ metric ) ) { if ( strpos ( $ metric [ $ by ] , $ search ) !== false ) { return $ metric ; } if ( $ metric [ $ by ] === $ search ) { return $ metric ; } } return false ; } ) ; if ( $ limit == 1 ) { return array_shift ( $ filtered ) ; } return array_slice ( $ filtered , 0 , $ limit ) ; }
Search if a defined number of Metrics exists .
59,671
private function loadFullDictionary ( ) : void { $ file = __DIR__ . '/../Dictionary/' . $ this -> language ; if ( ! file_exists ( $ file ) ) { $ file = __DIR__ . '/../Dictionary/en_US' ; } self :: $ dictionary = array_filter ( explode ( PHP_EOL , file_get_contents ( $ file ) ) ) ; }
Load the current language dictionary with a lot of words to always be able to get a unique value .
59,672
public function __toArray ( ) { $ dto = array ( ) ; try { $ reflectionClass = new \ ReflectionClass ( $ this ) ; $ properties = $ reflectionClass -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) ; if ( count ( $ properties ) > 0 ) { foreach ( $ properties as $ property ) { $ value = $ property -> getValue ( $ this ) ; if ( is_object ( $ value ) && method_exists ( $ value , 'toArray' ) ) { $ dto [ $ property -> getName ( ) ] = $ value -> toArray ( ) ; } elseif ( is_array ( $ value ) ) { foreach ( $ value as & $ arrValue ) { if ( $ arrValue instanceof Dto ) { $ arrValue = $ arrValue -> toArray ( ) ; } } $ dto [ $ property -> getName ( ) ] = $ value ; } else { $ dto [ $ property -> getName ( ) ] = $ property -> getValue ( $ this ) ; } } } } catch ( \ Exception $ e ) { Logger :: log ( get_class ( $ this ) . ': ' . $ e -> getMessage ( ) , LOG_ERR ) ; } return $ dto ; }
Convert dto to array representation
59,673
public function fromArray ( array $ object = array ( ) ) { if ( count ( $ object ) > 0 ) { $ reflector = new \ ReflectionClass ( $ this ) ; $ properties = InjectorHelper :: extractProperties ( $ reflector , \ ReflectionProperty :: IS_PUBLIC , InjectorHelper :: VAR_PATTERN ) ; unset ( $ reflector ) ; foreach ( $ object as $ key => $ value ) { if ( property_exists ( $ this , $ key ) && null !== $ value ) { $ this -> parseDtoField ( $ properties , $ key , $ value ) ; } } } }
Hydrate object from array
59,674
public static function addModelField ( TableMap $ tableMap , ModelCriteria & $ query , $ field , $ value = null ) { if ( $ column = self :: checkFieldExists ( $ tableMap , $ field ) ) { self :: addQueryFilter ( $ column , $ query , $ value ) ; } }
Method that adds the fields for the model into the API Query
59,675
public function createInstance ( $ sid , $ token , $ version = null , $ retryAttempts = 1 ) { return new \ Services_Twilio ( $ sid , $ token , $ version , null , $ retryAttempts ) ; }
Returns a new \ Services_Twilio instance from the given parameters
59,676
public static function checkFieldExists ( TableMap $ tableMap , $ field ) { $ column = null ; try { foreach ( $ tableMap -> getColumns ( ) as $ tableMapColumn ) { $ columnName = $ tableMapColumn -> getPhpName ( ) ; if ( preg_match ( '/^' . $ field . '$/i' , $ columnName ) ) { $ column = $ tableMapColumn ; break ; } } } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_DEBUG ) ; } return $ column ; }
Check if parametrized field exists in api model
59,677
public function postLogin ( $ route = null ) { $ form = new LoginForm ( ) ; $ form -> setData ( array ( "route" => $ route ) ) ; $ form -> build ( ) ; $ tpl = Template :: getInstance ( ) ; $ tpl -> setPublicZone ( true ) ; $ template = "login.html.twig" ; $ params = array ( 'form' => $ form , ) ; $ cookies = array ( ) ; $ form -> hydrate ( ) ; if ( $ form -> isValid ( ) ) { if ( Security :: getInstance ( ) -> checkAdmin ( $ form -> getFieldValue ( "user" ) , $ form -> getFieldValue ( "pass" ) ) ) { $ cookies = array ( array ( "name" => Security :: getInstance ( ) -> getHash ( ) , "value" => base64_encode ( $ form -> getFieldValue ( "user" ) . ":" . $ form -> getFieldValue ( "pass" ) ) , "expire" => time ( ) + 3600 , "http" => true , ) ) ; $ template = "redirect.html.twig" ; $ params = array ( 'route' => $ form -> getFieldValue ( "route" ) , 'status_message' => t ( "Acceso permitido... redirigiendo!!" ) , 'delay' => 1 , ) ; } else { $ form -> setError ( "user" , t ( "El usuario no tiene acceso a la web" ) ) ; } } return $ tpl -> render ( $ template , $ params , $ cookies ) ; }
Servicio que valida el login
59,678
public function addField ( $ objField ) { if ( get_class ( $ objField ) == "ValidFormBuilder\\Fieldset" ) { $ objField -> setMeta ( "parent" , $ this , true ) ; $ this -> __elements -> addObject ( $ objField ) ; } else { if ( $ this -> __elements -> count ( ) == 0 ) { $ objFieldset = new Fieldset ( ) ; $ this -> __elements -> addObject ( $ objFieldset ) ; } $ objFieldset = $ this -> __elements -> getLast ( ) ; $ objField -> setMeta ( "parent" , $ objFieldset , true ) ; $ objFieldset -> getFields ( ) -> addObject ( $ objField ) ; if ( $ objField -> isDynamic ( ) && get_class ( $ objField ) !== "ValidFormBuilder\\MultiField" && get_class ( $ objField ) !== "ValidFormBuilder\\Area" ) { $ objHidden = new Hidden ( $ objField -> getId ( ) . "_dynamic" , ValidForm :: VFORM_INTEGER , array ( "default" => 0 , "dynamicCounter" => true ) ) ; $ objFieldset -> addField ( $ objHidden ) ; $ objField -> setDynamicCounter ( $ objHidden ) ; } } }
Add a field object
59,679
public function getValue ( $ intDynamicPosition = 0 ) { $ varValue = parent :: getValue ( $ intDynamicPosition ) ; return ( strlen ( $ varValue ) > 0 && $ varValue !== 0 ) ? true : false ; }
Get checkbox value
59,680
public static function checkRestrictedAccess ( $ route ) { Logger :: log ( 'Checking admin zone' ) ; if ( ! Config :: getInstance ( ) -> checkTryToSaveConfig ( ) && ( preg_match ( '/^\/(admin|setup\-admin)/i' , $ route ) || Config :: getParam ( 'restricted' , false ) ) ) { if ( ! self :: isTest ( ) && null === Cache :: getInstance ( ) -> getDataFromFile ( CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json' , Cache :: JSONGZ , true ) ) { throw new AdminCredentialsException ( ) ; } if ( ! Security :: getInstance ( ) -> checkAdmin ( ) ) { throw new AccessDeniedException ( ) ; } Logger :: log ( 'Admin access granted' ) ; } }
Method that checks the access to the restricted zone
59,681
public static function calculateNetworkAddress ( Address $ address , SubnetMask $ subnetMask ) { return new Address ( $ address -> get ( ) & $ subnetMask -> get ( ) ) ; }
Calculate the network address of a Block given an IPV4 network address and SubnetMask .
59,682
public static function calculateBroadcastAddress ( Address $ address , SubnetMask $ subnetMask ) { return new Address ( $ address -> get ( ) | ~ $ subnetMask -> get ( ) ) ; }
Calculate the broadcast address of a Block given an IPV4 network address and SubnetMask .
59,683
public function addField ( $ field ) { if ( ! $ field instanceof Base ) { throw new \ InvalidArgumentException ( "No valid object passed to Fieldset::addField(). " . "Object should be an instance of \\ValidFormBuilder\\Base." , E_ERROR ) ; } $ this -> __fields -> addObject ( $ field ) ; $ field -> setMeta ( "parent" , $ this , true ) ; if ( $ field -> isDynamic ( ) && get_class ( $ field ) !== "ValidFormBuilder\\MultiField" && get_class ( $ field ) !== "ValidFormBuilder\\Area" ) { $ objHidden = new Hidden ( $ field -> getId ( ) . "_dynamic" , ValidForm :: VFORM_INTEGER , array ( "default" => 0 , "dynamicCounter" => true ) ) ; $ this -> __fields -> addObject ( $ objHidden ) ; $ field -> setDynamicCounter ( $ objHidden ) ; } }
Add an object to the fiedset s elements collection
59,684
public function toHtml ( $ submitted = false , $ blnSimpleLayout = false , $ blnLabel = true , $ blnDisplayErrors = true ) { $ this -> setConditionalMeta ( ) ; $ this -> __setMeta ( "id" , $ this -> getName ( ) , false ) ; $ strOutput = "<fieldset{$this->__getMetaString()}>\n" ; if ( ! empty ( $ this -> __header ) ) { $ strOutput .= "<legend><span>{$this->__header}</span></legend>\n" ; } if ( is_object ( $ this -> __note ) ) { $ strOutput .= $ this -> __note -> toHtml ( ) ; } foreach ( $ this -> __fields as $ field ) { $ strOutput .= $ field -> toHtml ( $ submitted , $ blnSimpleLayout , $ blnLabel , $ blnDisplayErrors ) ; } $ strOutput .= "</fieldset>\n" ; return $ strOutput ; }
Generate HTML output for this fieldset and all it s children
59,685
public function getAdmins ( ) { $ admins = $ this -> security -> getAdmins ( ) ; if ( ! empty ( $ admins ) ) { if ( ! $ this -> security -> checkAdmin ( ) ) { $ this -> setAdminHeaders ( ) ; } } $ this -> parseAdmins ( $ admins ) ; return $ admins ; }
Servicio que devuelve los administradores de la plataforma
59,686
public function getLogFiles ( ) { $ files = new Finder ( ) ; $ files -> files ( ) -> in ( LOG_DIR ) -> name ( '*.log' ) -> sortByModifiedTime ( ) ; $ logs = array ( ) ; foreach ( $ files as $ file ) { $ size = $ file -> getSize ( ) / 8 / 1024 ; $ time = date ( 'c' , $ file -> getMTime ( ) ) ; $ dateTime = new \ DateTime ( $ time ) ; if ( ! isset ( $ logs [ $ dateTime -> format ( 'Y' ) ] ) ) { $ logs [ $ dateTime -> format ( 'Y' ) ] = [ ] ; } $ logs [ $ dateTime -> format ( 'Y' ) ] [ $ dateTime -> format ( 'm' ) ] [ $ time ] = [ 'filename' => $ file -> getFilename ( ) , 'size' => round ( $ size , 3 ) , ] ; krsort ( $ logs [ $ dateTime -> format ( 'Y' ) ] [ $ dateTime -> format ( 'm' ) ] ) ; krsort ( $ logs [ $ dateTime -> format ( 'Y' ) ] ) ; } return $ logs ; }
Servicio que lee los logs y los formatea para listarlos
59,687
public function cacheComponents ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cached != null ) { return $ this -> cached ; } $ this -> cached = $ this -> client -> call ( 'GET' , 'components' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; return $ this -> cached ; }
Cache Components for performance improvement .
59,688
public function indexComponents ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cache === true ) { return $ this -> cacheComponents ( $ num , $ page ) ; } return $ this -> client -> call ( 'GET' , 'components' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; }
Get a defined number of Components .
59,689
public function searchComponents ( $ search , $ by , $ limit = 1 , $ num = 1000 , $ page = 1 ) { $ components = $ this -> indexComponents ( $ num , $ page ) [ 'data' ] ; $ filtered = array_filter ( $ components , function ( $ component ) use ( $ search , $ by ) { if ( array_key_exists ( $ by , $ component ) ) { if ( strpos ( $ component [ $ by ] , $ search ) !== false ) { return $ component ; } if ( $ component [ $ by ] === $ search ) { return $ component ; } } return false ; } ) ; if ( $ limit == 1 ) { return array_shift ( $ filtered ) ; } return array_slice ( $ filtered , 0 , $ limit ) ; }
Search if a defined number of Components exists .
59,690
public static function validate ( $ checkType , $ value ) { if ( array_key_exists ( $ checkType , self :: $ checks ) ) { if ( empty ( self :: $ checks [ $ checkType ] ) ) { $ blnReturn = true ; } else { if ( is_array ( $ value ) ) { $ arrValues = $ value ; $ blnSub = true ; foreach ( $ arrValues as $ value ) { $ blnSub = preg_match ( self :: $ checks [ $ checkType ] , $ value ) ; if ( ! $ blnSub ) { exit ( ) ; } } $ blnReturn = $ blnSub ; } else { $ blnReturn = preg_match ( self :: $ checks [ $ checkType ] , $ value ) ; } } } else { if ( empty ( $ checkType ) ) { $ blnReturn = true ; } else { $ blnReturn = @ preg_match ( $ checkType , $ value ) ; } } return $ blnReturn ; }
Validate input against regular expression
59,691
public static function getCheck ( $ checkType ) { $ strReturn = "" ; if ( array_key_exists ( $ checkType , self :: $ checks ) ) { $ strReturn = self :: $ checks [ $ checkType ] ; } return $ strReturn ; }
Get the regular expression that is used by the given field type
59,692
private function setReponseHeaders ( $ contentType = 'text/html' , array $ cookies = array ( ) ) { $ powered = Config :: getParam ( 'poweredBy' , 'PSFS' ) ; header ( 'X-Powered-By: ' . $ powered ) ; ResponseHelper :: setStatusHeader ( $ this -> getStatusCode ( ) ) ; ResponseHelper :: setAuthHeaders ( $ this -> isPublicZone ( ) ) ; ResponseHelper :: setCookieHeaders ( $ cookies ) ; header ( 'Content-type: ' . $ contentType ) ; }
Servicio que establece las cabeceras de la respuesta
59,693
public function output ( $ output = '' , $ contentType = 'text/html' , array $ cookies = array ( ) ) { if ( ! self :: isTest ( ) ) { Logger :: log ( 'Start output response' ) ; ob_start ( ) ; $ this -> setReponseHeaders ( $ contentType , $ cookies ) ; header ( 'Content-length: ' . strlen ( $ output ) ) ; header ( 'CRC: ' . crc32 ( $ output ) ) ; $ needCache = Cache :: needCache ( ) ; $ cache = Cache :: getInstance ( ) ; list ( $ path , $ cacheDataName ) = $ cache -> getRequestCacheHash ( ) ; if ( null !== $ cacheDataName && false !== $ needCache && $ this -> getStatusCode ( ) === Template :: STATUS_OK ) { Logger :: log ( 'Saving output response into cache' ) ; $ cache -> storeData ( 'json' . DIRECTORY_SEPARATOR . $ path . $ cacheDataName , $ output ) ; $ cache -> storeData ( 'json' . DIRECTORY_SEPARATOR . $ path . $ cacheDataName . '.headers' , headers_list ( ) , Cache :: JSON ) ; } elseif ( Request :: getInstance ( ) -> getMethod ( ) !== 'GET' ) { $ cache -> flushCache ( ) ; } echo $ output ; ob_flush ( ) ; ob_end_clean ( ) ; Logger :: log ( 'End output response' ) ; $ this -> closeRender ( ) ; } else { return $ output ; } }
Servicio que devuelve el output
59,694
public function cacheIncidents ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cached != null ) { return $ this -> cached ; } $ this -> cached = $ this -> client -> call ( 'GET' , 'incidents' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; return $ this -> cached ; }
Cache Incidents for performance improvement .
59,695
public function indexIncidents ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cache != false ) { return $ this -> cacheIncidents ( $ num , $ page ) ; } return $ this -> client -> call ( 'GET' , 'incidents' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; }
Get a defined number of Incidents .
59,696
public function searchIncidents ( $ search , $ by , $ limit = 1 , $ num = 1000 , $ page = 1 ) { $ incidents = $ this -> indexIncidents ( $ num , $ page ) [ 'data' ] ; $ filtered = array_filter ( $ incidents , function ( $ incident ) use ( $ search , $ by ) { if ( array_key_exists ( $ by , $ incident ) ) { if ( strpos ( $ incident [ $ by ] , $ search ) !== false ) { return $ incident ; } if ( $ incident [ $ by ] === $ search ) { return $ incident ; } } return false ; } ) ; if ( $ limit == 1 ) { return array_shift ( $ filtered ) ; } return array_slice ( $ filtered , 0 , $ limit ) ; }
Search if a defined number of Incidents exists .
59,697
protected function scheduleTask ( TaskInterface $ task ) { if ( null !== ( $ execution = $ this -> taskExecutionRepository -> findPending ( $ task ) ) ) { return ; } if ( $ task -> getInterval ( ) === null && 0 < count ( $ this -> taskExecutionRepository -> findByTask ( $ task ) ) ) { return ; } $ scheduleTime = $ task -> getInterval ( ) ? $ task -> getInterval ( ) -> getNextRunDate ( ) : $ task -> getFirstExecution ( ) ; $ execution = $ this -> taskExecutionRepository -> create ( $ task , $ scheduleTime ) ; $ execution -> setStatus ( TaskStatus :: PLANNED ) ; $ this -> eventDispatcher -> dispatch ( Events :: TASK_EXECUTION_CREATE , new TaskExecutionEvent ( $ task , $ execution ) ) ; $ this -> taskExecutionRepository -> save ( $ execution ) ; }
Schedule execution for given task .
59,698
public function getModules ( $ requestModule ) { $ modules = [ ] ; $ domains = $ this -> route -> getDomains ( ) ; if ( count ( $ domains ) ) { foreach ( $ domains as $ module => $ info ) { try { $ module = preg_replace ( '/(@|\/)/' , '' , $ module ) ; if ( $ module === $ requestModule && ! preg_match ( '/^ROOT/i' , $ module ) ) { $ modules = [ 'name' => $ module , 'path' => dirname ( $ info [ 'base' ] . DIRECTORY_SEPARATOR . '..' ) , ] ; } } catch ( \ Exception $ e ) { $ modules [ ] = $ e -> getMessage ( ) ; } } } return $ modules ; }
Method that extract all modules
59,699
public function extractApiEndpoints ( array $ module ) { $ modulePath = $ module [ 'path' ] . DIRECTORY_SEPARATOR . 'Api' ; $ moduleName = $ module [ 'name' ] ; $ endpoints = [ ] ; if ( file_exists ( $ modulePath ) ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ modulePath ) -> depth ( 0 ) -> name ( '*.php' ) ; if ( count ( $ finder ) ) { foreach ( $ finder as $ file ) { $ namespace = "\\{$moduleName}\\Api\\" . str_replace ( '.php' , '' , $ file -> getFilename ( ) ) ; $ info = $ this -> extractApiInfo ( $ namespace , $ moduleName ) ; if ( ! empty ( $ info ) ) { $ endpoints [ $ namespace ] = $ info ; } } } } return $ endpoints ; }
Method that extract all endpoints for each module