Exemple #1
0
/**
 * Executes the validation
 */
PHP_METHOD(Phalcon_Validation_Validator_File, validate) {

	zend_bool _4, _5, _6, _8, _9, _18, _19, _21, _29, _30, _65, _72$$29, _81$$36;
	zephir_fcall_cache_entry *_15 = NULL, *_17 = NULL, *_44 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *field = NULL;
	zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *fieldTypes = NULL, *code = NULL, *minResolutionArray = NULL, *maxResolutionArray = NULL, *_0 = NULL, *_3, *_7, *_10, *_20, *_22, *_23 = NULL, *_36 = NULL, *_55 = NULL, *_64 = NULL, *_66 = NULL, *_1$$3, *_2$$5, *_11$$6 = NULL, *_14$$6 = NULL, *_16$$6, *_12$$7, *_13$$8, *_24$$9 = NULL, *_27$$9 = NULL, *_28$$9, *_25$$10, *_26$$11, *_31$$12 = NULL, *_34$$12 = NULL, *_35$$12, *_32$$13, *_33$$14, *_37$$15 = NULL, *_39$$15, *_40$$15, *_41$$15, *_42$$15, *_43$$15 = NULL, *_45$$15, *_46$$15, _47$$15, *_48$$15, *_49$$15 = NULL, *_38$$16, *_50$$18 = NULL, *_53$$18 = NULL, *_54$$18, *_51$$19, *_52$$20, *_56$$21, _57$$24, *_58$$24, *_59$$26 = NULL, *_62$$26 = NULL, *_63$$26, *_60$$27, *_61$$28, *_67$$29, *_68$$29 = NULL, *_69$$29 = NULL, *_78$$29 = NULL, *_70$$30, *_71$$31, *_73$$33 = NULL, *_76$$33 = NULL, *_77$$33, *_74$$34, *_75$$35, *_79$$36, *_80$$37, *_82$$38 = NULL, *_85$$38 = NULL, *_86$$38, *_83$$39, *_84$$40;

	ZEPHIR_MM_GROW();
	zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC);
	zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
	zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
	zephir_fetch_params(1, 2, 0, &validation, &field_param);

	if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
		zephir_get_strval(field, field_param);
	} else {
		ZEPHIR_INIT_VAR(field);
		ZVAL_EMPTY_STRING(field);
	}


	ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (Z_TYPE_P(label) == IS_ARRAY) {
		zephir_array_fetch(&_1$$3, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 108 TSRMLS_CC);
		ZEPHIR_CPY_WRT(label, _1$$3);
	}
	if (ZEPHIR_IS_EMPTY(label)) {
		ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "code", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (Z_TYPE_P(code) == IS_ARRAY) {
		zephir_array_fetch(&_2$$5, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 117 TSRMLS_CC);
		ZEPHIR_CPY_WRT(code, _2$$5);
	}
	zephir_array_fetch_string(&_3, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC);
	_4 = ZEPHIR_IS_STRING(_3, "POST");
	if (_4) {
		_4 = ZEPHIR_IS_EMPTY(_POST);
	}
	_5 = _4;
	if (_5) {
		_5 = ZEPHIR_IS_EMPTY(_FILES);
	}
	_6 = _5;
	if (_6) {
		zephir_array_fetch_string(&_7, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC);
		_6 = ZEPHIR_GT_LONG(_7, 0);
	}
	_8 = _6;
	if (!(_8)) {
		_9 = zephir_array_isset_string(value, SS("error"));
		if (_9) {
			zephir_array_fetch_string(&_10, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 121 TSRMLS_CC);
			_9 = ZEPHIR_IS_LONG_IDENTICAL(_10, 1);
		}
		_8 = _9;
	}
	if (_8) {
		ZEPHIR_INIT_VAR(_11$$6);
		ZVAL_STRING(_11$$6, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11$$6);
		zephir_check_temp_parameter(_11$$6);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (Z_TYPE_P(message) == IS_ARRAY) {
			zephir_array_fetch(&_12$$7, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 127 TSRMLS_CC);
			ZEPHIR_CPY_WRT(message, _12$$7);
		}
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_13$$8);
			ZVAL_STRING(_13$$8, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _13$$8);
			zephir_check_temp_parameter(_13$$8);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_11$$6);
		object_init_ex(_11$$6, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_14$$6, "strtr", &_15, 26, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_16$$6);
		ZVAL_STRING(_16$$6, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _11$$6, "__construct", &_17, 466, _14$$6, field, _16$$6, code);
		zephir_check_temp_parameter(_16$$6);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11$$6);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	_18 = !(zephir_array_isset_string(value, SS("error")));
	if (!(_18)) {
		_18 = !(zephir_array_isset_string(value, SS("tmp_name")));
	}
	_19 = _18;
	if (!(_19)) {
		zephir_array_fetch_string(&_20, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 138 TSRMLS_CC);
		_19 = !ZEPHIR_IS_LONG_IDENTICAL(_20, 0);
	}
	_21 = _19;
	if (!(_21)) {
		zephir_array_fetch_string(&_22, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 138 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&_23, "is_uploaded_file", NULL, 246, _22);
		zephir_check_call_status();
		_21 = !zephir_is_true(_23);
	}
	if (_21) {
		ZEPHIR_INIT_VAR(_24$$9);
		ZVAL_STRING(_24$$9, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _24$$9);
		zephir_check_temp_parameter(_24$$9);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (Z_TYPE_P(message) == IS_ARRAY) {
			zephir_array_fetch(&_25$$10, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 144 TSRMLS_CC);
			ZEPHIR_CPY_WRT(message, _25$$10);
		}
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_26$$11);
			ZVAL_STRING(_26$$11, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _26$$11);
			zephir_check_temp_parameter(_26$$11);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_24$$9);
		object_init_ex(_24$$9, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_27$$9, "strtr", &_15, 26, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_28$$9);
		ZVAL_STRING(_28$$9, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _24$$9, "__construct", &_17, 466, _27$$9, field, _28$$9, code);
		zephir_check_temp_parameter(_28$$9);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _24$$9);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	_29 = !(zephir_array_isset_string(value, SS("name")));
	if (!(_29)) {
		_29 = !(zephir_array_isset_string(value, SS("type")));
	}
	_30 = _29;
	if (!(_30)) {
		_30 = !(zephir_array_isset_string(value, SS("size")));
	}
	if (_30) {
		ZEPHIR_INIT_VAR(_31$$12);
		ZVAL_STRING(_31$$12, "messageValid", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _31$$12);
		zephir_check_temp_parameter(_31$$12);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (Z_TYPE_P(message) == IS_ARRAY) {
			zephir_array_fetch(&_32$$13, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 161 TSRMLS_CC);
			ZEPHIR_CPY_WRT(message, _32$$13);
		}
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_33$$14);
			ZVAL_STRING(_33$$14, "FileValid", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _33$$14);
			zephir_check_temp_parameter(_33$$14);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_31$$12);
		object_init_ex(_31$$12, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_34$$12, "strtr", &_15, 26, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_35$$12);
		ZVAL_STRING(_35$$12, "FileValid", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _31$$12, "__construct", &_17, 466, _34$$12, field, _35$$12, code);
		zephir_check_temp_parameter(_35$$12);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _31$$12);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_36, this_ptr, "hasoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_36)) {
		ZEPHIR_INIT_VAR(byteUnits);
		zephir_create_array(byteUnits, 9, 0 TSRMLS_CC);
		add_assoc_long_ex(byteUnits, SS("B"), 0);
		add_assoc_long_ex(byteUnits, SS("K"), 10);
		add_assoc_long_ex(byteUnits, SS("M"), 20);
		add_assoc_long_ex(byteUnits, SS("G"), 30);
		add_assoc_long_ex(byteUnits, SS("T"), 40);
		add_assoc_long_ex(byteUnits, SS("KB"), 10);
		add_assoc_long_ex(byteUnits, SS("MB"), 20);
		add_assoc_long_ex(byteUnits, SS("GB"), 30);
		add_assoc_long_ex(byteUnits, SS("TB"), 40);
		ZEPHIR_INIT_VAR(_37$$15);
		ZVAL_STRING(_37$$15, "maxSize", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _37$$15);
		zephir_check_temp_parameter(_37$$15);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(matches);
		ZVAL_NULL(matches);
		ZEPHIR_INIT_VAR(unit);
		ZVAL_STRING(unit, "B", 1);
		if (Z_TYPE_P(maxSize) == IS_ARRAY) {
			zephir_array_fetch(&_38$$16, maxSize, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 180 TSRMLS_CC);
			ZEPHIR_CPY_WRT(maxSize, _38$$16);
		}
		ZEPHIR_INIT_NVAR(_37$$15);
		ZEPHIR_INIT_VAR(_39$$15);
		ZEPHIR_INIT_VAR(_40$$15);
		zephir_array_keys(_40$$15, byteUnits TSRMLS_CC);
		zephir_fast_join_str(_39$$15, SL("|"), _40$$15 TSRMLS_CC);
		ZEPHIR_INIT_VAR(_41$$15);
		ZEPHIR_CONCAT_SVS(_41$$15, "/^([0-9]+(?:\\.[0-9]+)?)(", _39$$15, ")?$/Di");
		zephir_preg_match(_37$$15, _41$$15, maxSize, matches, 0, 0 , 0  TSRMLS_CC);
		if (zephir_array_isset_long(matches, 2)) {
			ZEPHIR_OBS_NVAR(unit);
			zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 186 TSRMLS_CC);
		}
		zephir_array_fetch_long(&_42$$15, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&_43$$15, "floatval", &_44, 322, _42$$15);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_45$$15);
		zephir_array_fetch(&_46$$15, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC);
		ZEPHIR_SINIT_VAR(_47$$15);
		ZVAL_LONG(&_47$$15, 2);
		zephir_pow_function(_45$$15, &_47$$15, _46$$15);
		ZEPHIR_INIT_VAR(bytes);
		mul_function(bytes, _43$$15, _45$$15 TSRMLS_CC);
		zephir_array_fetch_string(&_48$$15, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 191 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&_43$$15, "floatval", &_44, 322, _48$$15);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_49$$15, "floatval", &_44, 322, bytes);
		zephir_check_call_status();
		if (ZEPHIR_GT(_43$$15, _49$$15)) {
			ZEPHIR_INIT_VAR(_50$$18);
			ZVAL_STRING(_50$$18, "messageSize", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _50$$18);
			zephir_check_temp_parameter(_50$$18);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE);
			if (Z_TYPE_P(message) == IS_ARRAY) {
				zephir_array_fetch(&_51$$19, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 196 TSRMLS_CC);
				ZEPHIR_CPY_WRT(message, _51$$19);
			}
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_52$$20);
				ZVAL_STRING(_52$$20, "FileSize", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _52$$20);
				zephir_check_temp_parameter(_52$$20);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_50$$18);
			object_init_ex(_50$$18, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_53$$18, "strtr", &_15, 26, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_54$$18);
			ZVAL_STRING(_54$$18, "FileSize", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _50$$18, "__construct", &_17, 466, _53$$18, field, _54$$18, code);
			zephir_check_temp_parameter(_54$$18);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _50$$18);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_55, this_ptr, "hasoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_55)) {
		ZEPHIR_INIT_VAR(_56$$21);
		ZVAL_STRING(_56$$21, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _56$$21);
		zephir_check_temp_parameter(_56$$21);
		zephir_check_call_status();
		ZEPHIR_OBS_VAR(fieldTypes);
		if (zephir_array_isset_fetch(&fieldTypes, types, field, 0 TSRMLS_CC)) {
			ZEPHIR_CPY_WRT(types, fieldTypes);
		}
		if (Z_TYPE_P(types) != IS_ARRAY) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 217);
			return;
		}
		if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_SINIT_VAR(_57$$24);
			ZVAL_LONG(&_57$$24, 16);
			ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 243, &_57$$24);
			zephir_check_call_status();
			zephir_array_fetch_string(&_58$$24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 222 TSRMLS_CC);
			ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 244, tmp, _58$$24);
			zephir_check_call_status();
			ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 245, tmp);
			zephir_check_call_status();
		} else {
			ZEPHIR_OBS_NVAR(mime);
			zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 226 TSRMLS_CC);
		}
		if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) {
			ZEPHIR_INIT_VAR(_59$$26);
			ZVAL_STRING(_59$$26, "messageType", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _59$$26);
			zephir_check_temp_parameter(_59$$26);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			ZEPHIR_INIT_NVAR(_59$$26);
			zephir_fast_join_str(_59$$26, SL(", "), types TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":types"), &_59$$26, PH_COPY | PH_SEPARATE);
			if (Z_TYPE_P(message) == IS_ARRAY) {
				zephir_array_fetch(&_60$$27, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 234 TSRMLS_CC);
				ZEPHIR_CPY_WRT(message, _60$$27);
			}
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_61$$28);
				ZVAL_STRING(_61$$28, "FileType", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _61$$28);
				zephir_check_temp_parameter(_61$$28);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_59$$26);
			object_init_ex(_59$$26, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_62$$26, "strtr", &_15, 26, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_63$$26);
			ZVAL_STRING(_63$$26, "FileType", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _59$$26, "__construct", &_17, 466, _62$$26, field, _63$$26, code);
			zephir_check_temp_parameter(_63$$26);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _59$$26);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_64, this_ptr, "hasoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	_65 = zephir_is_true(_64);
	if (!(_65)) {
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_STRING(_0, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_66, this_ptr, "hasoption", NULL, 0, _0);
		zephir_check_temp_parameter(_0);
		zephir_check_call_status();
		_65 = zephir_is_true(_66);
	}
	if (_65) {
		zephir_array_fetch_string(&_67$$29, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 247 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 254, _67$$29);
		zephir_check_call_status();
		ZEPHIR_OBS_VAR(width);
		zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 248 TSRMLS_CC);
		ZEPHIR_OBS_VAR(height);
		zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 249 TSRMLS_CC);
		ZEPHIR_INIT_VAR(_69$$29);
		ZVAL_STRING(_69$$29, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_68$$29, this_ptr, "hasoption", NULL, 0, _69$$29);
		zephir_check_temp_parameter(_69$$29);
		zephir_check_call_status();
		if (zephir_is_true(_68$$29)) {
			ZEPHIR_INIT_VAR(_70$$30);
			ZVAL_STRING(_70$$30, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&minResolution, this_ptr, "getoption", NULL, 0, _70$$30);
			zephir_check_temp_parameter(_70$$30);
			zephir_check_call_status();
			if (Z_TYPE_P(minResolution) == IS_ARRAY) {
				zephir_array_fetch(&_71$$31, minResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 254 TSRMLS_CC);
				ZEPHIR_CPY_WRT(minResolution, _71$$31);
			}
			ZEPHIR_INIT_VAR(minResolutionArray);
			zephir_fast_explode_str(minResolutionArray, SL("x"), minResolution, LONG_MAX TSRMLS_CC);
			ZEPHIR_OBS_VAR(minWidth);
			zephir_array_fetch_long(&minWidth, minResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 257 TSRMLS_CC);
			ZEPHIR_OBS_VAR(minHeight);
			zephir_array_fetch_long(&minHeight, minResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 258 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_NVAR(minWidth);
			ZVAL_LONG(minWidth, 1);
			ZEPHIR_INIT_NVAR(minHeight);
			ZVAL_LONG(minHeight, 1);
		}
		_72$$29 = ZEPHIR_LT(width, minWidth);
		if (!(_72$$29)) {
			_72$$29 = ZEPHIR_LT(height, minHeight);
		}
		if (_72$$29) {
			ZEPHIR_INIT_VAR(_73$$33);
			ZVAL_STRING(_73$$33, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _73$$33);
			zephir_check_temp_parameter(_73$$33);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			zephir_array_update_string(&replacePairs, SL(":min"), &minResolution, PH_COPY | PH_SEPARATE);
			if (Z_TYPE_P(message) == IS_ARRAY) {
				zephir_array_fetch(&_74$$34, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 269 TSRMLS_CC);
				ZEPHIR_CPY_WRT(message, _74$$34);
			}
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_75$$35);
				ZVAL_STRING(_75$$35, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _75$$35);
				zephir_check_temp_parameter(_75$$35);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_73$$33);
			object_init_ex(_73$$33, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_76$$33, "strtr", &_15, 26, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_77$$33);
			ZVAL_STRING(_77$$33, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _73$$33, "__construct", &_17, 466, _76$$33, field, _77$$33, code);
			zephir_check_temp_parameter(_77$$33);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _73$$33);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
		ZEPHIR_INIT_NVAR(_69$$29);
		ZVAL_STRING(_69$$29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_78$$29, this_ptr, "hasoption", NULL, 0, _69$$29);
		zephir_check_temp_parameter(_69$$29);
		zephir_check_call_status();
		if (zephir_is_true(_78$$29)) {
			ZEPHIR_INIT_VAR(_79$$36);
			ZVAL_STRING(_79$$36, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&maxResolution, this_ptr, "getoption", NULL, 0, _79$$36);
			zephir_check_temp_parameter(_79$$36);
			zephir_check_call_status();
			if (Z_TYPE_P(maxResolution) == IS_ARRAY) {
				zephir_array_fetch(&_80$$37, maxResolution, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 284 TSRMLS_CC);
				ZEPHIR_CPY_WRT(maxResolution, _80$$37);
			}
			ZEPHIR_INIT_VAR(maxResolutionArray);
			zephir_fast_explode_str(maxResolutionArray, SL("x"), maxResolution, LONG_MAX TSRMLS_CC);
			ZEPHIR_OBS_VAR(maxWidth);
			zephir_array_fetch_long(&maxWidth, maxResolutionArray, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 287 TSRMLS_CC);
			ZEPHIR_OBS_VAR(maxHeight);
			zephir_array_fetch_long(&maxHeight, maxResolutionArray, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 288 TSRMLS_CC);
			_81$$36 = ZEPHIR_GT(width, maxWidth);
			if (!(_81$$36)) {
				_81$$36 = ZEPHIR_GT(height, maxHeight);
			}
			if (_81$$36) {
				ZEPHIR_INIT_VAR(_82$$38);
				ZVAL_STRING(_82$$38, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _82$$38);
				zephir_check_temp_parameter(_82$$38);
				zephir_check_call_status();
				ZEPHIR_INIT_NVAR(replacePairs);
				zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
				zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
				zephir_array_update_string(&replacePairs, SL(":max"), &maxResolution, PH_COPY | PH_SEPARATE);
				if (Z_TYPE_P(message) == IS_ARRAY) {
					zephir_array_fetch(&_83$$39, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 295 TSRMLS_CC);
					ZEPHIR_CPY_WRT(message, _83$$39);
				}
				if (ZEPHIR_IS_EMPTY(message)) {
					ZEPHIR_INIT_VAR(_84$$40);
					ZVAL_STRING(_84$$40, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
					ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _84$$40);
					zephir_check_temp_parameter(_84$$40);
					zephir_check_call_status();
				}
				ZEPHIR_INIT_NVAR(_82$$38);
				object_init_ex(_82$$38, phalcon_validation_message_ce);
				ZEPHIR_CALL_FUNCTION(&_85$$38, "strtr", &_15, 26, message, replacePairs);
				zephir_check_call_status();
				ZEPHIR_INIT_VAR(_86$$38);
				ZVAL_STRING(_86$$38, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(NULL, _82$$38, "__construct", &_17, 466, _85$$38, field, _86$$38, code);
				zephir_check_temp_parameter(_86$$38);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _82$$38);
				zephir_check_call_status();
				RETURN_MM_BOOL(0);
			}
		}
	}
	RETURN_MM_BOOL(1);

}
Exemple #2
0
/**
 * Lists table indexes
 *
 * <code>
 *   print_r($connection->describeIndexes('robots_parts'));
 * </code>
 *
 * @param  string table
 * @param  string schema
 * @return \Phalcon\Db\IndexInterface[]
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeIndexes) {

	HashTable *_5, *_16;
	HashPosition _4, _15;
	zephir_fcall_cache_entry *_21 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *table_param = NULL, *schema = NULL, *indexes = NULL, *index = NULL, *keyName = NULL, *indexType = NULL, *indexObjects = NULL, *columns = NULL, *name = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, **_17, *_7$$4 = NULL, *_8$$3, *_10$$3, *_11$$3, *_9$$6, *_12$$7 = NULL, *_13$$8 = NULL, *_14$$9 = NULL, *_18$$11 = NULL, *_19$$11, *_20$$11;
	zval *table = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &table_param, &schema);

	if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(table_param) == IS_STRING)) {
		zephir_get_strval(table, table_param);
	} else {
		ZEPHIR_INIT_VAR(table);
		ZVAL_EMPTY_STRING(table);
	}
	if (!schema) {
		schema = ZEPHIR_GLOBAL(global_null);
	}


	ZEPHIR_INIT_VAR(indexes);
	array_init(indexes);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_2, _1, "describeindexes", NULL, 0, table, schema);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 2);
	ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3);
	zephir_check_call_status();
	zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/mysql.zep", 392);
	for (
	  ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
	  ; zephir_hash_move_forward_ex(_5, &_4)
	) {
		ZEPHIR_GET_HVALUE(index, _6);
		zephir_array_fetch_string(&keyName, index, SL("Key_name"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 365 TSRMLS_CC);
		zephir_array_fetch_string(&indexType, index, SL("Index_type"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 366 TSRMLS_CC);
		if (!(zephir_array_isset(indexes, keyName))) {
			ZEPHIR_INIT_NVAR(_7$$4);
			array_init(_7$$4);
			zephir_array_update_zval(&indexes, keyName, &_7$$4, PH_COPY | PH_SEPARATE);
		}
		zephir_array_fetch(&_8$$3, indexes, keyName, PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 372 TSRMLS_CC);
		if (!(zephir_array_isset_string(_8$$3, SS("columns")))) {
			ZEPHIR_INIT_NVAR(columns);
			array_init(columns);
		} else {
			zephir_array_fetch(&_9$$6, indexes, keyName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 375 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(columns);
			zephir_array_fetch_string(&columns, _9$$6, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 375 TSRMLS_CC);
		}
		zephir_array_fetch_string(&_10$$3, index, SL("Column_name"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 378 TSRMLS_CC);
		zephir_array_append(&columns, _10$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/mysql.zep", 378);
		zephir_array_update_multi(&indexes, &columns TSRMLS_CC, SL("zs"), 3, keyName, SL("columns"));
		zephir_array_fetch_string(&_11$$3, index, SL("Non_unique"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 385 TSRMLS_CC);
		if (ZEPHIR_IS_STRING(keyName, "PRIMARY")) {
			ZEPHIR_INIT_NVAR(_12$$7);
			ZVAL_STRING(_12$$7, "PRIMARY", 1);
			zephir_array_update_multi(&indexes, &_12$$7 TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
		} else if (ZEPHIR_IS_STRING(indexType, "FULLTEXT")) {
			ZEPHIR_INIT_NVAR(_13$$8);
			ZVAL_STRING(_13$$8, "FULLTEXT", 1);
			zephir_array_update_multi(&indexes, &_13$$8 TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
		} else if (ZEPHIR_IS_LONG(_11$$3, 0)) {
			ZEPHIR_INIT_NVAR(_14$$9);
			ZVAL_STRING(_14$$9, "UNIQUE", 1);
			zephir_array_update_multi(&indexes, &_14$$9 TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
		} else {
			zephir_array_update_multi(&indexes, &ZEPHIR_GLOBAL(global_null) TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
		}
	}
	ZEPHIR_INIT_VAR(indexObjects);
	array_init(indexObjects);
	zephir_is_iterable(indexes, &_16, &_15, 0, 0, "phalcon/db/adapter/pdo/mysql.zep", 397);
	for (
	  ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS
	  ; zephir_hash_move_forward_ex(_16, &_15)
	) {
		ZEPHIR_GET_HMKEY(name, _16, _15);
		ZEPHIR_GET_HVALUE(index, _17);
		ZEPHIR_INIT_NVAR(_18$$11);
		object_init_ex(_18$$11, phalcon_db_index_ce);
		zephir_array_fetch_string(&_19$$11, index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 394 TSRMLS_CC);
		zephir_array_fetch_string(&_20$$11, index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 394 TSRMLS_CC);
		ZEPHIR_CALL_METHOD(NULL, _18$$11, "__construct", &_21, 22, name, _19$$11, _20$$11);
		zephir_check_call_status();
		zephir_array_update_zval(&indexObjects, name, &_18$$11, PH_COPY | PH_SEPARATE);
	}
	RETURN_CCTOR(indexObjects);

}
Exemple #3
0
/**
 * Lists table references
 *
 *<code>
 * print_r($connection->describeReferences('robots_parts'));
 *</code>
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeReferences) {

	zval *_15$$3 = NULL, *_20$$6 = NULL;
	HashTable *_5, *_17;
	HashPosition _4, _16;
	zephir_fcall_cache_entry *_22 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *table_param = NULL, *schema_param = NULL, *references = NULL, *reference = NULL, *arrayReference = NULL, *constraintName = NULL, *referenceObjects = NULL, *name = NULL, *referencedSchema = NULL, *referencedTable = NULL, *columns = NULL, *referencedColumns = NULL, *referenceUpdate = NULL, *referenceDelete = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, **_18, *_7$$5, *_8$$5, *_9$$5, *_10$$5, *_11$$5, *_12$$5, *_13$$3, *_14$$3, *_19$$6 = NULL, *_21$$6 = NULL;
	zval *table = NULL, *schema = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &table_param, &schema_param);

	if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(table_param) == IS_STRING)) {
		zephir_get_strval(table, table_param);
	} else {
		ZEPHIR_INIT_VAR(table);
		ZVAL_EMPTY_STRING(table);
	}
	if (!schema_param) {
		ZEPHIR_INIT_VAR(schema);
		ZVAL_EMPTY_STRING(schema);
	} else {
	if (unlikely(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(schema_param) == IS_STRING)) {
		zephir_get_strval(schema, schema_param);
	} else {
		ZEPHIR_INIT_VAR(schema);
		ZVAL_EMPTY_STRING(schema);
	}
	}


	ZEPHIR_INIT_VAR(references);
	array_init(references);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_2, _1, "describereferences", NULL, 0, table, schema);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 3);
	ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3);
	zephir_check_call_status();
	zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/mysql.zep", 449);
	for (
	  ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
	  ; zephir_hash_move_forward_ex(_5, &_4)
	) {
		ZEPHIR_GET_HVALUE(reference, _6);
		zephir_array_fetch_long(&constraintName, reference, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 418 TSRMLS_CC);
		if (!(zephir_array_isset(references, constraintName))) {
			ZEPHIR_OBS_NVAR(referencedSchema);
			zephir_array_fetch_long(&referencedSchema, reference, 3, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 420 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedTable);
			zephir_array_fetch_long(&referencedTable, reference, 4, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 421 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referenceUpdate);
			zephir_array_fetch_long(&referenceUpdate, reference, 6, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 422 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referenceDelete);
			zephir_array_fetch_long(&referenceDelete, reference, 7, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 423 TSRMLS_CC);
			ZEPHIR_INIT_NVAR(columns);
			array_init(columns);
			ZEPHIR_INIT_NVAR(referencedColumns);
			array_init(referencedColumns);
		} else {
			zephir_array_fetch(&_7$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 428 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedSchema);
			zephir_array_fetch_string(&referencedSchema, _7$$5, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 428 TSRMLS_CC);
			zephir_array_fetch(&_8$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 429 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedTable);
			zephir_array_fetch_string(&referencedTable, _8$$5, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 429 TSRMLS_CC);
			zephir_array_fetch(&_9$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 430 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(columns);
			zephir_array_fetch_string(&columns, _9$$5, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 430 TSRMLS_CC);
			zephir_array_fetch(&_10$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 431 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedColumns);
			zephir_array_fetch_string(&referencedColumns, _10$$5, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 431 TSRMLS_CC);
			zephir_array_fetch(&_11$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 432 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referenceUpdate);
			zephir_array_fetch_string(&referenceUpdate, _11$$5, SL("onUpdate"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 432 TSRMLS_CC);
			zephir_array_fetch(&_12$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 433 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referenceDelete);
			zephir_array_fetch_string(&referenceDelete, _12$$5, SL("onDelete"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 433 TSRMLS_CC);
		}
		zephir_array_fetch_long(&_13$$3, reference, 1, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 436 TSRMLS_CC);
		zephir_array_append(&columns, _13$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/mysql.zep", 436);
		zephir_array_fetch_long(&_14$$3, reference, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 437 TSRMLS_CC);
		zephir_array_append(&referencedColumns, _14$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/mysql.zep", 437);
		ZEPHIR_INIT_NVAR(_15$$3);
		zephir_create_array(_15$$3, 6, 0 TSRMLS_CC);
		zephir_array_update_string(&_15$$3, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_15$$3, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_15$$3, SL("columns"), &columns, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_15$$3, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_15$$3, SL("onUpdate"), &referenceUpdate, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_15$$3, SL("onDelete"), &referenceDelete, PH_COPY | PH_SEPARATE);
		zephir_array_update_zval(&references, constraintName, &_15$$3, PH_COPY | PH_SEPARATE);
	}
	ZEPHIR_INIT_VAR(referenceObjects);
	array_init(referenceObjects);
	zephir_is_iterable(references, &_17, &_16, 0, 0, "phalcon/db/adapter/pdo/mysql.zep", 461);
	for (
	  ; zephir_hash_get_current_data_ex(_17, (void**) &_18, &_16) == SUCCESS
	  ; zephir_hash_move_forward_ex(_17, &_16)
	) {
		ZEPHIR_GET_HMKEY(name, _17, _16);
		ZEPHIR_GET_HVALUE(arrayReference, _18);
		ZEPHIR_INIT_NVAR(_19$$6);
		object_init_ex(_19$$6, phalcon_db_reference_ce);
		ZEPHIR_INIT_NVAR(_20$$6);
		zephir_create_array(_20$$6, 6, 0 TSRMLS_CC);
		ZEPHIR_OBS_NVAR(_21$$6);
		zephir_array_fetch_string(&_21$$6, arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 452 TSRMLS_CC);
		zephir_array_update_string(&_20$$6, SL("referencedSchema"), &_21$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_21$$6);
		zephir_array_fetch_string(&_21$$6, arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 453 TSRMLS_CC);
		zephir_array_update_string(&_20$$6, SL("referencedTable"), &_21$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_21$$6);
		zephir_array_fetch_string(&_21$$6, arrayReference, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 454 TSRMLS_CC);
		zephir_array_update_string(&_20$$6, SL("columns"), &_21$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_21$$6);
		zephir_array_fetch_string(&_21$$6, arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 455 TSRMLS_CC);
		zephir_array_update_string(&_20$$6, SL("referencedColumns"), &_21$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_21$$6);
		zephir_array_fetch_string(&_21$$6, arrayReference, SL("onUpdate"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 456 TSRMLS_CC);
		zephir_array_update_string(&_20$$6, SL("onUpdate"), &_21$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_21$$6);
		zephir_array_fetch_string(&_21$$6, arrayReference, SL("onDelete"), PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 458 TSRMLS_CC);
		zephir_array_update_string(&_20$$6, SL("onDelete"), &_21$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_CALL_METHOD(NULL, _19$$6, "__construct", &_22, 23, name, _20$$6);
		zephir_check_call_status();
		zephir_array_update_zval(&referenceObjects, name, &_19$$6, PH_COPY | PH_SEPARATE);
	}
	RETURN_CCTOR(referenceObjects);

}
Exemple #4
0
/**
 * Executes the validation
 */
PHP_METHOD(Phalcon_Validation_Validator_File, validate) {

	zend_bool _2, _3, _4, _6, _7, _16, _17, _18, _20, _21, _23, _30, _31, _62, _69$$21, _77$$26;
	zephir_fcall_cache_entry *_12 = NULL, *_14 = NULL, *_43 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *field = NULL;
	zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *_0 = NULL, *_1, *_5, *_8, *_15 = NULL, *_19, *_22, *_24, *_25 = NULL, *_36 = NULL, *_53 = NULL, *_61 = NULL, *_63 = NULL, *_9$$4 = NULL, *_11$$4 = NULL, *_13$$4, *_10$$5, *_26$$7 = NULL, *_28$$7 = NULL, *_29$$7, *_27$$8, *_32$$9 = NULL, *_34$$9 = NULL, *_35$$9, *_33$$10, *_37$$11 = NULL, *_38$$11, *_39$$11, *_40$$11, *_41$$11, *_42$$11 = NULL, *_44$$11, *_45$$11, _46$$11, *_47$$11, *_48$$11 = NULL, *_49$$13 = NULL, *_51$$13 = NULL, *_52$$13, *_50$$14, *_54$$15, _55$$17, *_56$$17, *_57$$19 = NULL, *_59$$19 = NULL, *_60$$19, *_58$$20, *_64$$21, *_65$$21 = NULL, *_66$$21 = NULL, *_74$$21 = NULL, *_67$$22 = NULL, *_68$$22, *_70$$24 = NULL, *_71$$24 = NULL, *_73$$24, *_72$$25, *_75$$26 = NULL, *_76$$26, *_78$$27 = NULL, *_79$$27 = NULL, *_81$$27, *_80$$28;

	ZEPHIR_MM_GROW();
	zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC);
	zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
	zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
	zephir_fetch_params(1, 2, 0, &validation, &field_param);

	if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
		zephir_get_strval(field, field_param);
	} else {
		ZEPHIR_INIT_VAR(field);
		ZVAL_EMPTY_STRING(field);
	}


	ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (ZEPHIR_IS_EMPTY(label)) {
		ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
		zephir_check_call_status();
	}
	zephir_array_fetch_string(&_1, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC);
	_2 = ZEPHIR_IS_STRING(_1, "POST");
	if (_2) {
		_2 = ZEPHIR_IS_EMPTY(_POST);
	}
	_3 = _2;
	if (_3) {
		_3 = ZEPHIR_IS_EMPTY(_FILES);
	}
	_4 = _3;
	if (_4) {
		zephir_array_fetch_string(&_5, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC);
		_4 = ZEPHIR_GT_LONG(_5, 0);
	}
	_6 = _4;
	if (!(_6)) {
		_7 = zephir_array_isset_string(value, SS("error"));
		if (_7) {
			zephir_array_fetch_string(&_8, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC);
			_7 = ZEPHIR_IS_LONG_IDENTICAL(_8, 1);
		}
		_6 = _7;
	}
	if (_6) {
		ZEPHIR_INIT_VAR(_9$$4);
		ZVAL_STRING(_9$$4, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _9$$4);
		zephir_check_temp_parameter(_9$$4);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_10$$5);
			ZVAL_STRING(_10$$5, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _10$$5);
			zephir_check_temp_parameter(_10$$5);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_9$$4);
		object_init_ex(_9$$4, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_11$$4, "strtr", &_12, 55, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_13$$4);
		ZVAL_STRING(_13$$4, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _9$$4, "__construct", &_14, 434, _11$$4, field, _13$$4);
		zephir_check_temp_parameter(_13$$4);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _9$$4);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_15, this_ptr, "issetoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	_16 = zephir_is_true(_15);
	if (_16) {
		_17 = ZEPHIR_IS_EMPTY(value);
		if (!(_17)) {
			_18 = zephir_array_isset_string(value, SS("error"));
			if (_18) {
				zephir_array_fetch_string(&_19, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC);
				_18 = ZEPHIR_IS_LONG_IDENTICAL(_19, 4);
			}
			_17 = _18;
		}
		_16 = _17;
	}
	if (_16) {
		RETURN_MM_BOOL(1);
	}
	_20 = !(zephir_array_isset_string(value, SS("error")));
	if (!(_20)) {
		_20 = !(zephir_array_isset_string(value, SS("tmp_name")));
	}
	_21 = _20;
	if (!(_21)) {
		zephir_array_fetch_string(&_22, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC);
		_21 = !ZEPHIR_IS_LONG_IDENTICAL(_22, 0);
	}
	_23 = _21;
	if (!(_23)) {
		zephir_array_fetch_string(&_24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&_25, "is_uploaded_file", NULL, 229, _24);
		zephir_check_call_status();
		_23 = !zephir_is_true(_25);
	}
	if (_23) {
		ZEPHIR_INIT_VAR(_26$$7);
		ZVAL_STRING(_26$$7, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _26$$7);
		zephir_check_temp_parameter(_26$$7);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_27$$8);
			ZVAL_STRING(_27$$8, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _27$$8);
			zephir_check_temp_parameter(_27$$8);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_26$$7);
		object_init_ex(_26$$7, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_28$$7, "strtr", &_12, 55, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_29$$7);
		ZVAL_STRING(_29$$7, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _26$$7, "__construct", &_14, 434, _28$$7, field, _29$$7);
		zephir_check_temp_parameter(_29$$7);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _26$$7);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	_30 = !(zephir_array_isset_string(value, SS("name")));
	if (!(_30)) {
		_30 = !(zephir_array_isset_string(value, SS("type")));
	}
	_31 = _30;
	if (!(_31)) {
		_31 = !(zephir_array_isset_string(value, SS("size")));
	}
	if (_31) {
		ZEPHIR_INIT_VAR(_32$$9);
		ZVAL_STRING(_32$$9, "messageValid", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _32$$9);
		zephir_check_temp_parameter(_32$$9);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_33$$10);
			ZVAL_STRING(_33$$10, "FileValid", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _33$$10);
			zephir_check_temp_parameter(_33$$10);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_32$$9);
		object_init_ex(_32$$9, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_34$$9, "strtr", &_12, 55, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_35$$9);
		ZVAL_STRING(_35$$9, "FileValid", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _32$$9, "__construct", &_14, 434, _34$$9, field, _35$$9);
		zephir_check_temp_parameter(_35$$9);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _32$$9);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_36, this_ptr, "issetoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_36)) {
		ZEPHIR_INIT_VAR(byteUnits);
		zephir_create_array(byteUnits, 9, 0 TSRMLS_CC);
		add_assoc_long_ex(byteUnits, SS("B"), 0);
		add_assoc_long_ex(byteUnits, SS("K"), 10);
		add_assoc_long_ex(byteUnits, SS("M"), 20);
		add_assoc_long_ex(byteUnits, SS("G"), 30);
		add_assoc_long_ex(byteUnits, SS("T"), 40);
		add_assoc_long_ex(byteUnits, SS("KB"), 10);
		add_assoc_long_ex(byteUnits, SS("MB"), 20);
		add_assoc_long_ex(byteUnits, SS("GB"), 30);
		add_assoc_long_ex(byteUnits, SS("TB"), 40);
		ZEPHIR_INIT_VAR(_37$$11);
		ZVAL_STRING(_37$$11, "maxSize", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _37$$11);
		zephir_check_temp_parameter(_37$$11);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(matches);
		ZVAL_NULL(matches);
		ZEPHIR_INIT_VAR(unit);
		ZVAL_STRING(unit, "B", 1);
		ZEPHIR_INIT_NVAR(_37$$11);
		ZEPHIR_INIT_VAR(_38$$11);
		ZEPHIR_INIT_VAR(_39$$11);
		zephir_array_keys(_39$$11, byteUnits TSRMLS_CC);
		zephir_fast_join_str(_38$$11, SL("|"), _39$$11 TSRMLS_CC);
		ZEPHIR_INIT_VAR(_40$$11);
		ZEPHIR_CONCAT_SVS(_40$$11, "/^([0-9]+(?:\\.[0-9]+)?)(", _38$$11, ")?$/Di");
		zephir_preg_match(_37$$11, _40$$11, maxSize, matches, 0, 0 , 0  TSRMLS_CC);
		if (zephir_array_isset_long(matches, 2)) {
			ZEPHIR_OBS_NVAR(unit);
			zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 115 TSRMLS_CC);
		}
		zephir_array_fetch_long(&_41$$11, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&_42$$11, "floatval", &_43, 301, _41$$11);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_44$$11);
		zephir_array_fetch(&_45$$11, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC);
		ZEPHIR_SINIT_VAR(_46$$11);
		ZVAL_LONG(&_46$$11, 2);
		zephir_pow_function(_44$$11, &_46$$11, _45$$11);
		ZEPHIR_INIT_VAR(bytes);
		mul_function(bytes, _42$$11, _44$$11 TSRMLS_CC);
		zephir_array_fetch_string(&_47$$11, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 120 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&_42$$11, "floatval", &_43, 301, _47$$11);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_48$$11, "floatval", &_43, 301, bytes);
		zephir_check_call_status();
		if (ZEPHIR_GT(_42$$11, _48$$11)) {
			ZEPHIR_INIT_VAR(_49$$13);
			ZVAL_STRING(_49$$13, "messageSize", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _49$$13);
			zephir_check_temp_parameter(_49$$13);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE);
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_50$$14);
				ZVAL_STRING(_50$$14, "FileSize", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _50$$14);
				zephir_check_temp_parameter(_50$$14);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_49$$13);
			object_init_ex(_49$$13, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_51$$13, "strtr", &_12, 55, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_52$$13);
			ZVAL_STRING(_52$$13, "FileSize", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _49$$13, "__construct", &_14, 434, _51$$13, field, _52$$13);
			zephir_check_temp_parameter(_52$$13);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _49$$13);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_53, this_ptr, "issetoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_53)) {
		ZEPHIR_INIT_VAR(_54$$15);
		ZVAL_STRING(_54$$15, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _54$$15);
		zephir_check_temp_parameter(_54$$15);
		zephir_check_call_status();
		if (Z_TYPE_P(types) != IS_ARRAY) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 138);
			return;
		}
		if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_SINIT_VAR(_55$$17);
			ZVAL_LONG(&_55$$17, 16);
			ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 226, &_55$$17);
			zephir_check_call_status();
			zephir_array_fetch_string(&_56$$17, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 143 TSRMLS_CC);
			ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 227, tmp, _56$$17);
			zephir_check_call_status();
			ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 228, tmp);
			zephir_check_call_status();
		} else {
			ZEPHIR_OBS_NVAR(mime);
			zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 147 TSRMLS_CC);
		}
		if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) {
			ZEPHIR_INIT_VAR(_57$$19);
			ZVAL_STRING(_57$$19, "messageType", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _57$$19);
			zephir_check_temp_parameter(_57$$19);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			ZEPHIR_INIT_NVAR(_57$$19);
			zephir_fast_join_str(_57$$19, SL(", "), types TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":types"), &_57$$19, PH_COPY | PH_SEPARATE);
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_58$$20);
				ZVAL_STRING(_58$$20, "FileType", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _58$$20);
				zephir_check_temp_parameter(_58$$20);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_57$$19);
			object_init_ex(_57$$19, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_59$$19, "strtr", &_12, 55, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_60$$19);
			ZVAL_STRING(_60$$19, "FileType", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _57$$19, "__construct", &_14, 434, _59$$19, field, _60$$19);
			zephir_check_temp_parameter(_60$$19);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _57$$19);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_61, this_ptr, "issetoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	_62 = zephir_is_true(_61);
	if (!(_62)) {
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_STRING(_0, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_63, this_ptr, "issetoption", NULL, 0, _0);
		zephir_check_temp_parameter(_0);
		zephir_check_call_status();
		_62 = zephir_is_true(_63);
	}
	if (_62) {
		zephir_array_fetch_string(&_64$$21, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 164 TSRMLS_CC);
		ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 237, _64$$21);
		zephir_check_call_status();
		ZEPHIR_OBS_VAR(width);
		zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 165 TSRMLS_CC);
		ZEPHIR_OBS_VAR(height);
		zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC);
		ZEPHIR_INIT_VAR(_66$$21);
		ZVAL_STRING(_66$$21, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_65$$21, this_ptr, "issetoption", NULL, 0, _66$$21);
		zephir_check_temp_parameter(_66$$21);
		zephir_check_call_status();
		if (zephir_is_true(_65$$21)) {
			ZEPHIR_INIT_VAR(_68$$22);
			ZVAL_STRING(_68$$22, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_67$$22, this_ptr, "getoption", NULL, 0, _68$$22);
			zephir_check_temp_parameter(_68$$22);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(minResolution);
			zephir_fast_explode_str(minResolution, SL("x"), _67$$22, LONG_MAX TSRMLS_CC);
			ZEPHIR_OBS_VAR(minWidth);
			zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 170 TSRMLS_CC);
			ZEPHIR_OBS_VAR(minHeight);
			zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_NVAR(minWidth);
			ZVAL_LONG(minWidth, 1);
			ZEPHIR_INIT_NVAR(minHeight);
			ZVAL_LONG(minHeight, 1);
		}
		_69$$21 = ZEPHIR_LT(width, minWidth);
		if (!(_69$$21)) {
			_69$$21 = ZEPHIR_LT(height, minHeight);
		}
		if (_69$$21) {
			ZEPHIR_INIT_VAR(_70$$24);
			ZVAL_STRING(_70$$24, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _70$$24);
			zephir_check_temp_parameter(_70$$24);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			ZEPHIR_INIT_NVAR(_70$$24);
			ZVAL_STRING(_70$$24, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_71$$24, this_ptr, "getoption", NULL, 0, _70$$24);
			zephir_check_temp_parameter(_70$$24);
			zephir_check_call_status();
			zephir_array_update_string(&replacePairs, SL(":min"), &_71$$24, PH_COPY | PH_SEPARATE);
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_72$$25);
				ZVAL_STRING(_72$$25, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _72$$25);
				zephir_check_temp_parameter(_72$$25);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_70$$24);
			object_init_ex(_70$$24, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_71$$24, "strtr", &_12, 55, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_73$$24);
			ZVAL_STRING(_73$$24, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _70$$24, "__construct", &_14, 434, _71$$24, field, _73$$24);
			zephir_check_temp_parameter(_73$$24);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _70$$24);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
		ZEPHIR_INIT_NVAR(_66$$21);
		ZVAL_STRING(_66$$21, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_74$$21, this_ptr, "issetoption", NULL, 0, _66$$21);
		zephir_check_temp_parameter(_66$$21);
		zephir_check_call_status();
		if (zephir_is_true(_74$$21)) {
			ZEPHIR_INIT_VAR(_76$$26);
			ZVAL_STRING(_76$$26, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_75$$26, this_ptr, "getoption", NULL, 0, _76$$26);
			zephir_check_temp_parameter(_76$$26);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(maxResolution);
			zephir_fast_explode_str(maxResolution, SL("x"), _75$$26, LONG_MAX TSRMLS_CC);
			ZEPHIR_OBS_VAR(maxWidth);
			zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 192 TSRMLS_CC);
			ZEPHIR_OBS_VAR(maxHeight);
			zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 193 TSRMLS_CC);
			_77$$26 = ZEPHIR_GT(width, maxWidth);
			if (!(_77$$26)) {
				_77$$26 = ZEPHIR_GT(height, maxHeight);
			}
			if (_77$$26) {
				ZEPHIR_INIT_VAR(_78$$27);
				ZVAL_STRING(_78$$27, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _78$$27);
				zephir_check_temp_parameter(_78$$27);
				zephir_check_call_status();
				ZEPHIR_INIT_NVAR(replacePairs);
				zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
				zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
				ZEPHIR_INIT_NVAR(_78$$27);
				ZVAL_STRING(_78$$27, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_79$$27, this_ptr, "getoption", NULL, 0, _78$$27);
				zephir_check_temp_parameter(_78$$27);
				zephir_check_call_status();
				zephir_array_update_string(&replacePairs, SL(":max"), &_79$$27, PH_COPY | PH_SEPARATE);
				if (ZEPHIR_IS_EMPTY(message)) {
					ZEPHIR_INIT_VAR(_80$$28);
					ZVAL_STRING(_80$$28, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
					ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _80$$28);
					zephir_check_temp_parameter(_80$$28);
					zephir_check_call_status();
				}
				ZEPHIR_INIT_NVAR(_78$$27);
				object_init_ex(_78$$27, phalcon_validation_message_ce);
				ZEPHIR_CALL_FUNCTION(&_79$$27, "strtr", &_12, 55, message, replacePairs);
				zephir_check_call_status();
				ZEPHIR_INIT_VAR(_81$$27);
				ZVAL_STRING(_81$$27, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(NULL, _78$$27, "__construct", &_14, 434, _79$$27, field, _81$$27);
				zephir_check_temp_parameter(_81$$27);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _78$$27);
				zephir_check_call_status();
				RETURN_MM_BOOL(0);
			}
		}
	}
	RETURN_MM_BOOL(1);

}
Exemple #5
0
/**
 * Generates random text in accordance with the template
 *
 * <code>
 * // Hi my name is a Bob
 * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!");
 *
 * // Hi my name is a Jon
 * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!");
 *
 * // Hello my name is a Bob
 * echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!");
 *
 * // Hello my name is a Zyxep
 * echo Phalcon\Text::dynamic("[Hi/Hello], my name is a [Zyxep/Mark]!", "[", "]", "/");
 * </code>
 */
PHP_METHOD(Phalcon_Text, dynamic) {

	zend_bool _11$$6;
	HashTable *_9$$5;
	HashPosition _8$$5;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL, *_14 = NULL, *_19 = NULL;
	zval *text_param = NULL, *leftDelimiter_param = NULL, *rightDelimiter_param = NULL, *separator_param = NULL, *ldS = NULL, *rdS = NULL, *pattern = NULL, *matches = NULL, *match = NULL, *words = NULL, *word = NULL, *sub = NULL, *_0 = NULL, *_2 = NULL, *_6, *_7 = NULL, *_3$$3, **_10$$5, *_12$$6, *_13$$6 = NULL, *_15$$6, *_16$$6 = NULL, *_17$$6 = NULL, *_18$$6 = NULL;
	zval *text = NULL, *leftDelimiter = NULL, *rightDelimiter = NULL, *separator = NULL, *_4$$3;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 3, &text_param, &leftDelimiter_param, &rightDelimiter_param, &separator_param);

	if (UNEXPECTED(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(text_param) == IS_STRING)) {
		zephir_get_strval(text, text_param);
	} else {
		ZEPHIR_INIT_VAR(text);
		ZVAL_EMPTY_STRING(text);
	}
	if (!leftDelimiter_param) {
		ZEPHIR_INIT_VAR(leftDelimiter);
		ZVAL_STRING(leftDelimiter, "{", 1);
	} else {
	if (UNEXPECTED(Z_TYPE_P(leftDelimiter_param) != IS_STRING && Z_TYPE_P(leftDelimiter_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'leftDelimiter' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(leftDelimiter_param) == IS_STRING)) {
		zephir_get_strval(leftDelimiter, leftDelimiter_param);
	} else {
		ZEPHIR_INIT_VAR(leftDelimiter);
		ZVAL_EMPTY_STRING(leftDelimiter);
	}
	}
	if (!rightDelimiter_param) {
		ZEPHIR_INIT_VAR(rightDelimiter);
		ZVAL_STRING(rightDelimiter, "}", 1);
	} else {
	if (UNEXPECTED(Z_TYPE_P(rightDelimiter_param) != IS_STRING && Z_TYPE_P(rightDelimiter_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'rightDelimiter' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(rightDelimiter_param) == IS_STRING)) {
		zephir_get_strval(rightDelimiter, rightDelimiter_param);
	} else {
		ZEPHIR_INIT_VAR(rightDelimiter);
		ZVAL_EMPTY_STRING(rightDelimiter);
	}
	}
	if (!separator_param) {
		ZEPHIR_INIT_VAR(separator);
		ZVAL_STRING(separator, "|", 1);
	} else {
	if (UNEXPECTED(Z_TYPE_P(separator_param) != IS_STRING && Z_TYPE_P(separator_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'separator' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(separator_param) == IS_STRING)) {
		zephir_get_strval(separator, separator_param);
	} else {
		ZEPHIR_INIT_VAR(separator);
		ZVAL_EMPTY_STRING(separator);
	}
	}


	ZEPHIR_CALL_FUNCTION(&_0, "substr_count", &_1, 459, text, leftDelimiter);
	zephir_check_call_status();
	ZEPHIR_CALL_FUNCTION(&_2, "substr_count", &_1, 459, text, rightDelimiter);
	zephir_check_call_status();
	if (!ZEPHIR_IS_IDENTICAL(_0, _2)) {
		ZEPHIR_INIT_VAR(_3$$3);
		object_init_ex(_3$$3, spl_ce_RuntimeException);
		ZEPHIR_INIT_VAR(_4$$3);
		ZEPHIR_CONCAT_SVS(_4$$3, "Syntax error in string \"", text, "\"");
		ZEPHIR_CALL_METHOD(NULL, _3$$3, "__construct", NULL, 460, _4$$3);
		zephir_check_call_status();
		zephir_throw_exception_debug(_3$$3, "phalcon/text.zep", 289 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_CALL_FUNCTION(&ldS, "preg_quote", &_5, 461, leftDelimiter);
	zephir_check_call_status();
	ZEPHIR_CALL_FUNCTION(&rdS, "preg_quote", &_5, 461, rightDelimiter);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(pattern);
	ZEPHIR_CONCAT_SVSVVSVS(pattern, "/", ldS, "([^", ldS, rdS, "]+)", rdS, "/");
	ZEPHIR_INIT_VAR(matches);
	array_init(matches);
	ZEPHIR_INIT_VAR(_6);
	ZVAL_LONG(_6, 2);
	ZEPHIR_MAKE_REF(matches);
	ZEPHIR_CALL_FUNCTION(&_7, "preg_match_all", NULL, 39, pattern, text, matches, _6);
	ZEPHIR_UNREF(matches);
	zephir_check_call_status();
	if (!(zephir_is_true(_7))) {
		RETURN_CTOR(text);
	}
	if (Z_TYPE_P(matches) == IS_ARRAY) {
		zephir_is_iterable(matches, &_9$$5, &_8$$5, 0, 0, "phalcon/text.zep", 312);
		for (
		  ; zend_hash_get_current_data_ex(_9$$5, (void**) &_10$$5, &_8$$5) == SUCCESS
		  ; zend_hash_move_forward_ex(_9$$5, &_8$$5)
		) {
			ZEPHIR_GET_HVALUE(match, _10$$5);
			_11$$6 = !(zephir_array_isset_long(match, 0));
			if (!(_11$$6)) {
				_11$$6 = !(zephir_array_isset_long(match, 1));
			}
			if (_11$$6) {
				continue;
			}
			zephir_array_fetch_long(&_12$$6, match, 1, PH_NOISY | PH_READONLY, "phalcon/text.zep", 307 TSRMLS_CC);
			ZEPHIR_INIT_NVAR(words);
			zephir_fast_explode(words, separator, _12$$6, LONG_MAX TSRMLS_CC);
			ZEPHIR_OBS_NVAR(word);
			ZEPHIR_CALL_FUNCTION(&_13$$6, "array_rand", &_14, 462, words);
			zephir_check_call_status();
			zephir_array_fetch(&word, words, _13$$6, PH_NOISY, "phalcon/text.zep", 308 TSRMLS_CC);
			zephir_array_fetch_long(&_15$$6, match, 0, PH_NOISY | PH_READONLY, "phalcon/text.zep", 309 TSRMLS_CC);
			ZEPHIR_CALL_FUNCTION(&sub, "preg_quote", &_5, 461, _15$$6, separator);
			zephir_check_call_status();
			ZEPHIR_INIT_LNVAR(_16$$6);
			ZEPHIR_CONCAT_SVS(_16$$6, "/", sub, "/");
			ZEPHIR_INIT_NVAR(_17$$6);
			ZVAL_LONG(_17$$6, 1);
			ZEPHIR_CALL_FUNCTION(&_18$$6, "preg_replace", &_19, 40, _16$$6, word, text, _17$$6);
			zephir_check_call_status();
			zephir_get_strval(text, _18$$6);
		}
	}
	RETURN_CTOR(text);

}
Exemple #6
0
/**
 * Lists table references
 *
 * @param	string table
 * @param	string schema
 * @return	Phalcon\Db\ReferenceInterface[]
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeReferences) {

	zval *_13$$3 = NULL, *_18$$6 = NULL;
	HashTable *_5, *_15;
	HashPosition _4, _14;
	zephir_fcall_cache_entry *_20 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *table, *schema = NULL, *references = NULL, *reference = NULL, *arrayReference = NULL, *constraintName = NULL, *referenceObjects = NULL, *name = NULL, *referencedSchema = NULL, *referencedTable = NULL, *columns = NULL, *referencedColumns = NULL, *number = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, **_16, *_7$$5, *_8$$5, *_9$$5, *_10$$5, *_11$$3, *_12$$3, *_17$$6 = NULL, *_19$$6 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &table, &schema);

	if (!schema) {
		schema = ZEPHIR_GLOBAL(global_null);
	}


	ZEPHIR_INIT_VAR(references);
	array_init(references);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_2, _1, "describereferences", NULL, 0, table, schema);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 3);
	ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3);
	zephir_check_call_status();
	zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 391);
	for (
	  ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
	  ; zephir_hash_move_forward_ex(_5, &_4)
	) {
		ZEPHIR_GET_HMKEY(number, _5, _4);
		ZEPHIR_GET_HVALUE(reference, _6);
		ZEPHIR_INIT_NVAR(constraintName);
		ZEPHIR_CONCAT_SV(constraintName, "foreign_key_", number);
		if (!(zephir_array_isset(references, constraintName))) {
			ZEPHIR_INIT_NVAR(referencedSchema);
			ZVAL_NULL(referencedSchema);
			ZEPHIR_OBS_NVAR(referencedTable);
			zephir_array_fetch_long(&referencedTable, reference, 2, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 370 TSRMLS_CC);
			ZEPHIR_INIT_NVAR(columns);
			array_init(columns);
			ZEPHIR_INIT_NVAR(referencedColumns);
			array_init(referencedColumns);
		} else {
			zephir_array_fetch(&_7$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 374 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedSchema);
			zephir_array_fetch_string(&referencedSchema, _7$$5, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 374 TSRMLS_CC);
			zephir_array_fetch(&_8$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 375 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedTable);
			zephir_array_fetch_string(&referencedTable, _8$$5, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 375 TSRMLS_CC);
			zephir_array_fetch(&_9$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 376 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(columns);
			zephir_array_fetch_string(&columns, _9$$5, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 376 TSRMLS_CC);
			zephir_array_fetch(&_10$$5, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 377 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(referencedColumns);
			zephir_array_fetch_string(&referencedColumns, _10$$5, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 377 TSRMLS_CC);
		}
		zephir_array_fetch_long(&_11$$3, reference, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 380 TSRMLS_CC);
		zephir_array_append(&columns, _11$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 380);
		zephir_array_fetch_long(&_12$$3, reference, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 381 TSRMLS_CC);
		zephir_array_append(&referencedColumns, _12$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 381);
		ZEPHIR_INIT_NVAR(_13$$3);
		zephir_create_array(_13$$3, 4, 0 TSRMLS_CC);
		zephir_array_update_string(&_13$$3, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_13$$3, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_13$$3, SL("columns"), &columns, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&_13$$3, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE);
		zephir_array_update_zval(&references, constraintName, &_13$$3, PH_COPY | PH_SEPARATE);
	}
	ZEPHIR_INIT_VAR(referenceObjects);
	array_init(referenceObjects);
	zephir_is_iterable(references, &_15, &_14, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 401);
	for (
	  ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS
	  ; zephir_hash_move_forward_ex(_15, &_14)
	) {
		ZEPHIR_GET_HMKEY(name, _15, _14);
		ZEPHIR_GET_HVALUE(arrayReference, _16);
		ZEPHIR_INIT_NVAR(_17$$6);
		object_init_ex(_17$$6, phalcon_db_reference_ce);
		ZEPHIR_INIT_NVAR(_18$$6);
		zephir_create_array(_18$$6, 4, 0 TSRMLS_CC);
		ZEPHIR_OBS_NVAR(_19$$6);
		zephir_array_fetch_string(&_19$$6, arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 394 TSRMLS_CC);
		zephir_array_update_string(&_18$$6, SL("referencedSchema"), &_19$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_19$$6);
		zephir_array_fetch_string(&_19$$6, arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 395 TSRMLS_CC);
		zephir_array_update_string(&_18$$6, SL("referencedTable"), &_19$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_19$$6);
		zephir_array_fetch_string(&_19$$6, arrayReference, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 396 TSRMLS_CC);
		zephir_array_update_string(&_18$$6, SL("columns"), &_19$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_OBS_NVAR(_19$$6);
		zephir_array_fetch_string(&_19$$6, arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 398 TSRMLS_CC);
		zephir_array_update_string(&_18$$6, SL("referencedColumns"), &_19$$6, PH_COPY | PH_SEPARATE);
		ZEPHIR_CALL_METHOD(NULL, _17$$6, "__construct", &_20, 16, name, _18$$6);
		zephir_check_call_status();
		zephir_array_update_zval(&referenceObjects, name, &_17$$6, PH_COPY | PH_SEPARATE);
	}
	RETURN_CCTOR(referenceObjects);

}
Exemple #7
0
/**
 * Handle the whole command-line tasks
 */
PHP_METHOD(Phalcon_Cli_Console, handle) {

	zend_bool _5;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *arguments_param = NULL, __$false, dependencyInjector, router, eventsManager, moduleName, modules, module, path, className, moduleObject, dispatcher, task, _0, _3, _4, _15, _16, _17, _18, _1$$4, _2$$4, _6$$6, _7$$10, _8$$10, _9$$12, _10$$12, _11$$17, _12$$17, _13$$18, _14$$18, _19$$20, _20$$20, _21$$22;
	zval arguments;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&arguments);
	ZVAL_BOOL(&__$false, 0);
	ZVAL_UNDEF(&dependencyInjector);
	ZVAL_UNDEF(&router);
	ZVAL_UNDEF(&eventsManager);
	ZVAL_UNDEF(&moduleName);
	ZVAL_UNDEF(&modules);
	ZVAL_UNDEF(&module);
	ZVAL_UNDEF(&path);
	ZVAL_UNDEF(&className);
	ZVAL_UNDEF(&moduleObject);
	ZVAL_UNDEF(&dispatcher);
	ZVAL_UNDEF(&task);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_15);
	ZVAL_UNDEF(&_16);
	ZVAL_UNDEF(&_17);
	ZVAL_UNDEF(&_18);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_6$$6);
	ZVAL_UNDEF(&_7$$10);
	ZVAL_UNDEF(&_8$$10);
	ZVAL_UNDEF(&_9$$12);
	ZVAL_UNDEF(&_10$$12);
	ZVAL_UNDEF(&_11$$17);
	ZVAL_UNDEF(&_12$$17);
	ZVAL_UNDEF(&_13$$18);
	ZVAL_UNDEF(&_14$$18);
	ZVAL_UNDEF(&_19$$20);
	ZVAL_UNDEF(&_20$$20);
	ZVAL_UNDEF(&_21$$22);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &arguments_param);

	if (!arguments_param) {
		ZEPHIR_INIT_VAR(&arguments);
		array_init(&arguments);
	} else {
		zephir_get_arrval(&arguments, arguments_param);
	}


	ZEPHIR_OBS_VAR(&dependencyInjector);
	zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	if (Z_TYPE_P(&dependencyInjector) != IS_OBJECT) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "A dependency injection object is required to access internal services", "phalcon/cli/console.zep", 42);
		return;
	}
	zephir_read_property(&_0, this_ptr, SL("_eventsManager"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CPY_WRT(&eventsManager, &_0);
	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(&_2$$4);
		ZVAL_STRING(&_2$$4, "console:boot");
		ZEPHIR_CALL_METHOD(&_1$$4, &eventsManager, "fire", NULL, 0, &_2$$4, this_ptr);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$4)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_VAR(&_4);
	ZVAL_STRING(&_4, "router");
	ZEPHIR_CALL_METHOD(&_3, &dependencyInjector, "getshared", NULL, 0, &_4);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(&router, &_3);
	_5 = !(zephir_fast_count_int(&arguments TSRMLS_CC));
	if (_5) {
		zephir_read_property(&_0, this_ptr, SL("_arguments"), PH_NOISY_CC | PH_READONLY);
		_5 = zephir_is_true(&_0);
	}
	if (_5) {
		zephir_read_property(&_6$$6, this_ptr, SL("_arguments"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &_6$$6);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &arguments);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&moduleName, &router, "getmodulename", NULL, 0);
	zephir_check_call_status();
	if (!(zephir_is_true(&moduleName))) {
		ZEPHIR_OBS_NVAR(&moduleName);
		zephir_read_property(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC);
	}
	if (zephir_is_true(&moduleName)) {
		if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_VAR(&_8$$10);
			ZVAL_STRING(&_8$$10, "console:beforeStartModule");
			ZEPHIR_CALL_METHOD(&_7$$10, &eventsManager, "fire", NULL, 0, &_8$$10, this_ptr, &moduleName);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(&_7$$10)) {
				RETURN_MM_BOOL(0);
			}
		}
		ZEPHIR_OBS_VAR(&modules);
		zephir_read_property(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);
		if (!(zephir_array_isset(&modules, &moduleName))) {
			ZEPHIR_INIT_VAR(&_9$$12);
			object_init_ex(&_9$$12, phalcon_cli_console_exception_ce);
			ZEPHIR_INIT_VAR(&_10$$12);
			ZEPHIR_CONCAT_SVS(&_10$$12, "Module '", &moduleName, "' isn't registered in the console container");
			ZEPHIR_CALL_METHOD(NULL, &_9$$12, "__construct", NULL, 4, &_10$$12);
			zephir_check_call_status();
			zephir_throw_exception_debug(&_9$$12, "phalcon/cli/console.zep", 82 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
		ZEPHIR_OBS_VAR(&module);
		zephir_array_fetch(&module, &modules, &moduleName, PH_NOISY, "phalcon/cli/console.zep", 85 TSRMLS_CC);
		if (Z_TYPE_P(&module) != IS_ARRAY) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/cli/console.zep", 87);
			return;
		}
		ZEPHIR_OBS_VAR(&className);
		if (!(zephir_array_isset_string_fetch(&className, &module, SL("className"), 0))) {
			ZEPHIR_INIT_NVAR(&className);
			ZVAL_STRING(&className, "Module");
		}
		ZEPHIR_OBS_VAR(&path);
		if (zephir_array_isset_string_fetch(&path, &module, SL("path"), 0)) {
			if (!(zephir_class_exists(&className, zephir_is_true(&__$false)  TSRMLS_CC))) {
				if (!((zephir_file_exists(&path TSRMLS_CC) == SUCCESS))) {
					ZEPHIR_INIT_VAR(&_11$$17);
					object_init_ex(&_11$$17, phalcon_cli_console_exception_ce);
					ZEPHIR_INIT_VAR(&_12$$17);
					ZEPHIR_CONCAT_SVS(&_12$$17, "Module definition path '", &path, "' doesn't exist");
					ZEPHIR_CALL_METHOD(NULL, &_11$$17, "__construct", NULL, 4, &_12$$17);
					zephir_check_call_status();
					zephir_throw_exception_debug(&_11$$17, "phalcon/cli/console.zep", 97 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
				if (zephir_require_zval(&path TSRMLS_CC) == FAILURE) {
					RETURN_MM_NULL();
				}
			}
		}
		ZEPHIR_CALL_METHOD(&moduleObject, &dependencyInjector, "get", NULL, 0, &className);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerautoloaders", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerservices", NULL, 0, &dependencyInjector);
		zephir_check_call_status();
		if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_VAR(&_14$$18);
			ZVAL_STRING(&_14$$18, "console:afterStartModule");
			ZEPHIR_CALL_METHOD(&_13$$18, &eventsManager, "fire", NULL, 0, &_14$$18, this_ptr, &moduleObject);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(&_13$$18)) {
				RETURN_MM_BOOL(0);
			}
		}
	}
	ZEPHIR_INIT_NVAR(&_4);
	ZVAL_STRING(&_4, "dispatcher");
	ZEPHIR_CALL_METHOD(&_3, &dependencyInjector, "getshared", NULL, 0, &_4);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(&dispatcher, &_3);
	ZEPHIR_CALL_METHOD(&_3, &router, "getmodulename", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setmodulename", NULL, 0, &_3);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_15, &router, "gettaskname", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "settaskname", NULL, 0, &_15);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_16, &router, "getactionname", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setactionname", NULL, 0, &_16);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_17, &router, "getparams", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setparams", NULL, 0, &_17);
	zephir_check_call_status();
	zephir_read_property(&_18, this_ptr, SL("_options"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setoptions", NULL, 0, &_18);
	zephir_check_call_status();
	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(&_20$$20);
		ZVAL_STRING(&_20$$20, "console:beforeHandleTask");
		ZEPHIR_CALL_METHOD(&_19$$20, &eventsManager, "fire", NULL, 0, &_20$$20, this_ptr, &dispatcher);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(&_19$$20)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_CALL_METHOD(&task, &dispatcher, "dispatch", NULL, 0);
	zephir_check_call_status();
	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(&_21$$22);
		ZVAL_STRING(&_21$$22, "console:afterHandleTask");
		ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_21$$22, this_ptr, &task);
		zephir_check_call_status();
	}
	RETURN_CCTOR(&task);

}
Exemple #8
0
/**
 * Lists table indexes
 *
 * <code>
 *   print_r($connection->describeIndexes('robots_parts'));
 * </code>
 *
 * @param  string table
 * @param  string schema
 * @return \Phalcon\Db\IndexInterface[]
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeIndexes) {

	HashTable *_5, *_28, *_15$$3;
	HashPosition _4, _27, _14$$3;
	zephir_fcall_cache_entry *_20 = NULL, *_33 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *table, *schema = NULL, *indexes = NULL, *index = NULL, *keyName = NULL, *indexObjects = NULL, *name = NULL, *columns = NULL, *describeIndex = NULL, *indexSql = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, **_29, *_7$$4 = NULL, *_8$$3, *_10$$3 = NULL, *_11$$3, *_12$$3 = NULL, *_13$$3 = NULL, **_16$$3, *_18$$3, *_19$$3 = NULL, *_21$$3, *_9$$6, *_17$$7, *_22$$8 = NULL, *_23$$8 = NULL, _24$$8 = zval_used_for_init, *_25$$9 = NULL, *_26$$10 = NULL, *_30$$12 = NULL, *_31$$12, *_32$$12;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &table, &schema);

	if (!schema) {
		schema = ZEPHIR_GLOBAL(global_null);
	}


	ZEPHIR_INIT_VAR(indexes);
	array_init(indexes);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_2, _1, "describeindexes", NULL, 0, table, schema);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 2);
	ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3);
	zephir_check_call_status();
	zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 341);
	for (
	  ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
	  ; zephir_hash_move_forward_ex(_5, &_4)
	) {
		ZEPHIR_GET_HVALUE(index, _6);
		ZEPHIR_OBS_NVAR(keyName);
		zephir_array_fetch_string(&keyName, index, SL("name"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 311 TSRMLS_CC);
		if (!(zephir_array_isset(indexes, keyName))) {
			ZEPHIR_INIT_NVAR(_7$$4);
			array_init(_7$$4);
			zephir_array_update_zval(&indexes, keyName, &_7$$4, PH_COPY | PH_SEPARATE);
		}
		zephir_array_fetch(&_8$$3, indexes, keyName, PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 317 TSRMLS_CC);
		if (!(zephir_array_isset_string(_8$$3, SS("columns")))) {
			ZEPHIR_INIT_NVAR(columns);
			array_init(columns);
		} else {
			zephir_array_fetch(&_9$$6, indexes, keyName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 320 TSRMLS_CC);
			ZEPHIR_OBS_NVAR(columns);
			zephir_array_fetch_string(&columns, _9$$6, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 320 TSRMLS_CC);
		}
		_11$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&_12$$3, _11$$3, "describeindex", NULL, 0, keyName);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(_13$$3);
		ZVAL_LONG(_13$$3, 2);
		ZEPHIR_CALL_METHOD(&_10$$3, this_ptr, "fetchall", NULL, 0, _12$$3, _13$$3);
		zephir_check_call_status();
		zephir_is_iterable(_10$$3, &_15$$3, &_14$$3, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 327);
		for (
		  ; zephir_hash_get_current_data_ex(_15$$3, (void**) &_16$$3, &_14$$3) == SUCCESS
		  ; zephir_hash_move_forward_ex(_15$$3, &_14$$3)
		) {
			ZEPHIR_GET_HVALUE(describeIndex, _16$$3);
			zephir_array_fetch_string(&_17$$7, describeIndex, SL("name"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 324 TSRMLS_CC);
			zephir_array_append(&columns, _17$$7, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 324);
		}
		zephir_array_update_multi(&indexes, &columns TSRMLS_CC, SL("zs"), 3, keyName, SL("columns"));
		_18$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&_19$$3, _18$$3, "listindexessql", NULL, 0, table, schema, keyName);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&indexSql, this_ptr, "fetchcolumn", &_20, 0, _19$$3);
		zephir_check_call_status();
		zephir_array_fetch_string(&_21$$3, index, SL("unique"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 330 TSRMLS_CC);
		if (zephir_is_true(_21$$3)) {
			ZEPHIR_INIT_NVAR(_22$$8);
			ZEPHIR_INIT_NVAR(_23$$8);
			ZEPHIR_SINIT_NVAR(_24$$8);
			ZVAL_STRING(&_24$$8, "# UNIQUE #i", 0);
			zephir_preg_match(_23$$8, &_24$$8, indexSql, _22$$8, 0, 0 , 0  TSRMLS_CC);
			if (zephir_is_true(_23$$8)) {
				ZEPHIR_INIT_NVAR(_25$$9);
				ZVAL_STRING(_25$$9, "UNIQUE", 1);
				zephir_array_update_multi(&indexes, &_25$$9 TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
			} else {
				ZEPHIR_INIT_NVAR(_26$$10);
				ZVAL_STRING(_26$$10, "PRIMARY", 1);
				zephir_array_update_multi(&indexes, &_26$$10 TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
			}
		} else {
			zephir_array_update_multi(&indexes, &ZEPHIR_GLOBAL(global_null) TSRMLS_CC, SL("zs"), 3, keyName, SL("type"));
		}
	}
	ZEPHIR_INIT_VAR(indexObjects);
	array_init(indexObjects);
	zephir_is_iterable(indexes, &_28, &_27, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 346);
	for (
	  ; zephir_hash_get_current_data_ex(_28, (void**) &_29, &_27) == SUCCESS
	  ; zephir_hash_move_forward_ex(_28, &_27)
	) {
		ZEPHIR_GET_HMKEY(name, _28, _27);
		ZEPHIR_GET_HVALUE(index, _29);
		ZEPHIR_INIT_NVAR(_30$$12);
		object_init_ex(_30$$12, phalcon_db_index_ce);
		zephir_array_fetch_string(&_31$$12, index, SL("columns"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 343 TSRMLS_CC);
		zephir_array_fetch_string(&_32$$12, index, SL("type"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 343 TSRMLS_CC);
		ZEPHIR_CALL_METHOD(NULL, _30$$12, "__construct", &_33, 15, name, _31$$12, _32$$12);
		zephir_check_call_status();
		zephir_array_update_zval(&indexObjects, name, &_30$$12, PH_COPY | PH_SEPARATE);
	}
	RETURN_CCTOR(indexObjects);

}
Exemple #9
0
/**
 * Builds a Phalcon\Mvc\Model\Criteria based on an input array like _POST
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, fromInput) {

    zend_bool _6$$4, _7$$7;
    HashTable *_4$$3;
    HashPosition _3$$3;
    zend_class_entry *_2$$3;
    int ZEPHIR_LAST_CALL_STATUS;
    zval *data = NULL;
    zval *modelName = NULL, *operator = NULL, *_12$$10;
    zval *dependencyInjector, *modelName_param = NULL, *data_param = NULL, *operator_param = NULL, *attribute = NULL, *conditions = NULL, *field = NULL, *value = NULL, *type = NULL, *metaData = NULL, *model = NULL, *dataTypes = NULL, *bind = NULL, *criteria = NULL, *columnMap = NULL, *_0$$3 = NULL, *_1$$3 = NULL, **_5$$3, *_8$$9 = NULL, *_9$$9 = NULL, *_10$$8 = NULL, *_11$$10;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 3, 1, &dependencyInjector, &modelName_param, &data_param, &operator_param);

    if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) {
        zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC);
        RETURN_MM_NULL();
    }
    if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) {
        zephir_get_strval(modelName, modelName_param);
    } else {
        ZEPHIR_INIT_VAR(modelName);
        ZVAL_EMPTY_STRING(modelName);
    }
    data = data_param;
    if (!operator_param) {
        ZEPHIR_INIT_VAR(operator);
        ZVAL_STRING(operator, "AND", 1);
    } else {
        if (unlikely(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) {
            zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be a string") TSRMLS_CC);
            RETURN_MM_NULL();
        }
        if (likely(Z_TYPE_P(operator_param) == IS_STRING)) {
            zephir_get_strval(operator, operator_param);
        } else {
            ZEPHIR_INIT_VAR(operator);
            ZVAL_EMPTY_STRING(operator);
        }
    }


    ZEPHIR_INIT_VAR(conditions);
    array_init(conditions);
    if (zephir_fast_count_int(data TSRMLS_CC)) {
        ZEPHIR_INIT_VAR(_0$$3);
        ZVAL_STRING(_0$$3, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY);
        ZEPHIR_CALL_METHOD(&metaData, dependencyInjector, "getshared", NULL, 0, _0$$3);
        zephir_check_temp_parameter(_0$$3);
        zephir_check_call_status();
        ZEPHIR_INIT_VAR(model);
        zephir_fetch_safe_class(_1$$3, modelName);
        _2$$3 = zend_fetch_class(Z_STRVAL_P(_1$$3), Z_STRLEN_P(_1$$3), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
        object_init_ex(model, _2$$3);
        if (zephir_has_constructor(model TSRMLS_CC)) {
            ZEPHIR_INIT_NVAR(_0$$3);
            ZVAL_NULL(_0$$3);
            ZEPHIR_CALL_METHOD(NULL, model, "__construct", NULL, 0, _0$$3, dependencyInjector);
            zephir_check_call_status();
        }
        ZEPHIR_CALL_METHOD(&dataTypes, metaData, "getdatatypes", NULL, 0, model);
        zephir_check_call_status();
        ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, model);
        zephir_check_call_status();
        ZEPHIR_INIT_VAR(bind);
        array_init(bind);
        zephir_is_iterable(data, &_4$$3, &_3$$3, 0, 0, "phalcon/mvc/model/criteria.zep", 711);
        for (
            ; zephir_hash_get_current_data_ex(_4$$3, (void**) &_5$$3, &_3$$3) == SUCCESS
            ; zephir_hash_move_forward_ex(_4$$3, &_3$$3)
        ) {
            ZEPHIR_GET_HMKEY(field, _4$$3, _3$$3);
            ZEPHIR_GET_HVALUE(value, _5$$3);
            _6$$4 = Z_TYPE_P(columnMap) == IS_ARRAY;
            if (_6$$4) {
                _6$$4 = ((zephir_fast_count_int(columnMap TSRMLS_CC)) ? 1 : 0);
            }
            if (_6$$4) {
                ZEPHIR_OBS_NVAR(attribute);
                zephir_array_fetch(&attribute, columnMap, field, PH_NOISY, "phalcon/mvc/model/criteria.zep", 688 TSRMLS_CC);
            } else {
                ZEPHIR_CPY_WRT(attribute, field);
            }
            ZEPHIR_OBS_NVAR(type);
            if (zephir_array_isset_fetch(&type, dataTypes, attribute, 0 TSRMLS_CC)) {
                _7$$7 = Z_TYPE_P(value) != IS_NULL;
                if (_7$$7) {
                    _7$$7 = !ZEPHIR_IS_STRING_IDENTICAL(value, "");
                }
                if (_7$$7) {
                    if (ZEPHIR_IS_LONG(type, 2)) {
                        ZEPHIR_INIT_LNVAR(_8$$9);
                        ZEPHIR_CONCAT_SVSVS(_8$$9, "[", field, "] LIKE :", field, ":");
                        zephir_array_append(&conditions, _8$$9, PH_SEPARATE, "phalcon/mvc/model/criteria.zep", 700);
                        ZEPHIR_INIT_LNVAR(_9$$9);
                        ZEPHIR_CONCAT_SVS(_9$$9, "%", value, "%");
                        zephir_array_update_zval(&bind, field, &_9$$9, PH_COPY | PH_SEPARATE);
                        continue;
                    }
                    ZEPHIR_INIT_LNVAR(_10$$8);
                    ZEPHIR_CONCAT_SVSVS(_10$$8, "[", field, "] = :", field, ":");
                    zephir_array_append(&conditions, _10$$8, PH_SEPARATE, "phalcon/mvc/model/criteria.zep", 707);
                    zephir_array_update_zval(&bind, field, &value, PH_COPY | PH_SEPARATE);
                }
            }
        }
    }
    ZEPHIR_INIT_VAR(criteria);
    object_init_ex(criteria, phalcon_mvc_model_criteria_ce);
    if (zephir_has_constructor(criteria TSRMLS_CC)) {
        ZEPHIR_CALL_METHOD(NULL, criteria, "__construct", NULL, 0);
        zephir_check_call_status();
    }
    if (zephir_fast_count_int(conditions TSRMLS_CC)) {
        ZEPHIR_INIT_VAR(_11$$10);
        ZEPHIR_INIT_VAR(_12$$10);
        ZEPHIR_CONCAT_SVS(_12$$10, " ", operator, " ");
        zephir_fast_join(_11$$10, _12$$10, conditions TSRMLS_CC);
        ZEPHIR_CALL_METHOD(NULL, criteria, "where", NULL, 328, _11$$10);
        zephir_check_call_status();
        ZEPHIR_CALL_METHOD(NULL, criteria, "bind", NULL, 329, bind);
        zephir_check_call_status();
    }
    ZEPHIR_CALL_METHOD(NULL, criteria, "setmodelname", NULL, 320, modelName);
    zephir_check_call_status();
    RETURN_CCTOR(criteria);

}
Exemple #10
0
/**
 * Executes the validation
 */
PHP_METHOD(Phalcon_Validation_Validator_Numericality, validate) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *field = NULL;
	zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0, *_1, _2, *_3$$3 = NULL, *_8$$3 = NULL, *_9$$3, *_4$$4, *_5$$6, *_6$$7, *_7$$8;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &validation, &field_param);

	if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
		zephir_get_strval(field, field_param);
	} else {
		ZEPHIR_INIT_VAR(field);
		ZVAL_EMPTY_STRING(field);
	}


	ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_0);
	ZEPHIR_INIT_VAR(_1);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_STRING(&_2, "/^-?\\d+\\.?\\d*$/", 0);
	zephir_preg_match(_1, &_2, value, _0, 0, 0 , 0  TSRMLS_CC);
	if (!(zephir_is_true(_1))) {
		ZEPHIR_INIT_VAR(_3$$3);
		ZVAL_STRING(_3$$3, "label", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _3$$3);
		zephir_check_temp_parameter(_3$$3);
		zephir_check_call_status();
		if (Z_TYPE_P(label) == IS_ARRAY) {
			zephir_array_fetch(&_4$$4, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/numericality.zep", 75 TSRMLS_CC);
			ZEPHIR_CPY_WRT(label, _4$$4);
		}
		if (ZEPHIR_IS_EMPTY(label)) {
			ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_3$$3);
		ZVAL_STRING(_3$$3, "message", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _3$$3);
		zephir_check_temp_parameter(_3$$3);
		zephir_check_call_status();
		if (Z_TYPE_P(message) == IS_ARRAY) {
			zephir_array_fetch(&_5$$6, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/numericality.zep", 83 TSRMLS_CC);
			ZEPHIR_CPY_WRT(message, _5$$6);
		}
		ZEPHIR_INIT_VAR(replacePairs);
		zephir_create_array(replacePairs, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		if (ZEPHIR_IS_EMPTY(message)) {
			ZEPHIR_INIT_VAR(_6$$7);
			ZVAL_STRING(_6$$7, "Numericality", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _6$$7);
			zephir_check_temp_parameter(_6$$7);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_NVAR(_3$$3);
		ZVAL_STRING(_3$$3, "code", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _3$$3);
		zephir_check_temp_parameter(_3$$3);
		zephir_check_call_status();
		if (Z_TYPE_P(code) == IS_ARRAY) {
			zephir_array_fetch(&_7$$8, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/numericality.zep", 92 TSRMLS_CC);
			ZEPHIR_CPY_WRT(code, _7$$8);
		}
		ZEPHIR_INIT_NVAR(_3$$3);
		object_init_ex(_3$$3, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_8$$3, "strtr", NULL, 26, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_9$$3);
		ZVAL_STRING(_9$$3, "Numericality", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _3$$3, "__construct", NULL, 464, _8$$3, field, _9$$3, code);
		zephir_check_temp_parameter(_9$$3);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _3$$3);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	RETURN_MM_BOOL(1);

}
/**
 * Executes the validation
 */
PHP_METHOD(Phalcon_Validation_Validator_StringLength, validate) {

	zend_bool _1;
	zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *field = NULL;
	zval *validation, *field_param = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *message = NULL, *minimum = NULL, *maximum = NULL, *label = NULL, *replacePairs = NULL, *code = NULL, *_0 = NULL, *_2$$4, *_3$$6, *_4$$9, *_5$$10, *_6$$11 = NULL, *_9$$11 = NULL, *_11$$11, *_7$$12, *_8$$13, *_13$$14, *_14$$15, *_15$$16 = NULL, *_18$$16 = NULL, *_19$$16, *_16$$17, *_17$$18;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &validation, &field_param);

	if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
		zephir_get_strval(field, field_param);
	} else {
		ZEPHIR_INIT_VAR(field);
		ZVAL_EMPTY_STRING(field);
	}


	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "hasoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "hasoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	_1 = !zephir_is_true(isSetMin);
	if (_1) {
		_1 = !zephir_is_true(isSetMax);
	}
	if (_1) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set", "phalcon/validation/validator/stringlength.zep", 92);
		return;
	}
	ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
	zephir_check_call_status();
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (Z_TYPE_P(label) == IS_ARRAY) {
		zephir_array_fetch(&_2$$4, label, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 98 TSRMLS_CC);
		ZEPHIR_CPY_WRT(label, _2$$4);
	}
	if (ZEPHIR_IS_EMPTY(label)) {
		ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "code", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (Z_TYPE_P(code) == IS_ARRAY) {
		zephir_array_fetch(&_3$$6, code, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 106 TSRMLS_CC);
		ZEPHIR_CPY_WRT(code, _3$$6);
	}
	if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 382, value);
		zephir_check_call_status();
	} else {
		ZEPHIR_INIT_NVAR(length);
		ZVAL_LONG(length, zephir_fast_strlen_ev(value));
	}
	if (zephir_is_true(isSetMax)) {
		ZEPHIR_INIT_VAR(_4$$9);
		ZVAL_STRING(_4$$9, "max", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _4$$9);
		zephir_check_temp_parameter(_4$$9);
		zephir_check_call_status();
		if (Z_TYPE_P(maximum) == IS_ARRAY) {
			zephir_array_fetch(&_5$$10, maximum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 123 TSRMLS_CC);
			ZEPHIR_CPY_WRT(maximum, _5$$10);
		}
		if (ZEPHIR_GT(length, maximum)) {
			ZEPHIR_INIT_VAR(_6$$11);
			ZVAL_STRING(_6$$11, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _6$$11);
			zephir_check_temp_parameter(_6$$11);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE);
			if (Z_TYPE_P(message) == IS_ARRAY) {
				zephir_array_fetch(&_7$$12, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 132 TSRMLS_CC);
				ZEPHIR_CPY_WRT(message, _7$$12);
			}
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_8$$13);
				ZVAL_STRING(_8$$13, "TooLong", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _8$$13);
				zephir_check_temp_parameter(_8$$13);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_6$$11);
			object_init_ex(_6$$11, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_9$$11, "strtr", &_10, 26, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_11$$11);
			ZVAL_STRING(_11$$11, "TooLong", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _6$$11, "__construct", &_12, 466, _9$$11, field, _11$$11, code);
			zephir_check_temp_parameter(_11$$11);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _6$$11);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
	}
	if (zephir_is_true(isSetMin)) {
		ZEPHIR_INIT_VAR(_13$$14);
		ZVAL_STRING(_13$$14, "min", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _13$$14);
		zephir_check_temp_parameter(_13$$14);
		zephir_check_call_status();
		if (Z_TYPE_P(minimum) == IS_ARRAY) {
			zephir_array_fetch(&_14$$15, minimum, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 159 TSRMLS_CC);
			ZEPHIR_CPY_WRT(minimum, _14$$15);
		}
		if (ZEPHIR_LT(length, minimum)) {
			ZEPHIR_INIT_VAR(_15$$16);
			ZVAL_STRING(_15$$16, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _15$$16);
			zephir_check_temp_parameter(_15$$16);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(replacePairs);
			zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
			zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
			zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE);
			if (Z_TYPE_P(message) == IS_ARRAY) {
				zephir_array_fetch(&_16$$17, message, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/stringlength.zep", 168 TSRMLS_CC);
				ZEPHIR_CPY_WRT(message, _16$$17);
			}
			if (ZEPHIR_IS_EMPTY(message)) {
				ZEPHIR_INIT_VAR(_17$$18);
				ZVAL_STRING(_17$$18, "TooShort", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _17$$18);
				zephir_check_temp_parameter(_17$$18);
				zephir_check_call_status();
			}
			ZEPHIR_INIT_NVAR(_15$$16);
			object_init_ex(_15$$16, phalcon_validation_message_ce);
			ZEPHIR_CALL_FUNCTION(&_18$$16, "strtr", &_10, 26, message, replacePairs);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(_19$$16);
			ZVAL_STRING(_19$$16, "TooShort", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(NULL, _15$$16, "__construct", &_12, 466, _18$$16, field, _19$$16, code);
			zephir_check_temp_parameter(_19$$16);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _15$$16);
			zephir_check_call_status();
			RETURN_MM_BOOL(0);
		}
	}
	RETURN_MM_BOOL(1);

}
Exemple #12
0
/**
 * Executes the validation
 */
PHP_METHOD(Phalcon_Validation_Validator_Confirmation, validate) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *field = NULL;
	zval *validation, *field_param = NULL, *fieldWith = NULL, *value = NULL, *valueWith = NULL, *message = NULL, *label = NULL, *labelWith = NULL, *replacePairs = NULL, *code = NULL, *_0, *_2 = NULL, *_1$$3, *_3$$4 = NULL, *_5$$4 = NULL, *_6$$4, *_4$$5;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &validation, &field_param);

	if (UNEXPECTED(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(field_param) == IS_STRING)) {
		zephir_get_strval(field, field_param);
	} else {
		ZEPHIR_INIT_VAR(field);
		ZVAL_EMPTY_STRING(field);
	}


	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "with", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&fieldWith, this_ptr, "getoption", NULL, 0, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (Z_TYPE_P(fieldWith) == IS_ARRAY) {
		zephir_array_fetch(&_1$$3, fieldWith, field, PH_NOISY | PH_READONLY, "phalcon/validation/validator/confirmation.zep", 78 TSRMLS_CC);
		ZEPHIR_CPY_WRT(fieldWith, _1$$3);
	}
	ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&valueWith, validation, "getvalue", NULL, 0, fieldWith);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_2, this_ptr, "compare", NULL, 482, value, valueWith);
	zephir_check_call_status();
	if (!(zephir_is_true(_2))) {
		ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, field);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_3$$4);
		ZVAL_STRING(_3$$4, "Confirmation", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&message, this_ptr, "preparemessage", NULL, 0, validation, field, _3$$4);
		zephir_check_temp_parameter(_3$$4);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&code, this_ptr, "preparecode", NULL, 0, field);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(_3$$4);
		ZVAL_STRING(_3$$4, "labelWith", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&labelWith, this_ptr, "getoption", NULL, 0, _3$$4);
		zephir_check_temp_parameter(_3$$4);
		zephir_check_call_status();
		if (Z_TYPE_P(labelWith) == IS_ARRAY) {
			zephir_array_fetch(&_4$$5, labelWith, fieldWith, PH_NOISY | PH_READONLY, "phalcon/validation/validator/confirmation.zep", 91 TSRMLS_CC);
			ZEPHIR_CPY_WRT(labelWith, _4$$5);
		}
		if (ZEPHIR_IS_EMPTY(labelWith)) {
			ZEPHIR_CALL_METHOD(&labelWith, validation, "getlabel", NULL, 0, fieldWith);
			zephir_check_call_status();
		}
		ZEPHIR_INIT_VAR(replacePairs);
		zephir_create_array(replacePairs, 2, 0 TSRMLS_CC);
		zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE);
		zephir_array_update_string(&replacePairs, SL(":with"), &labelWith, PH_COPY | PH_SEPARATE);
		ZEPHIR_INIT_NVAR(_3$$4);
		object_init_ex(_3$$4, phalcon_validation_message_ce);
		ZEPHIR_CALL_FUNCTION(&_5$$4, "strtr", NULL, 27, message, replacePairs);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_6$$4);
		ZVAL_STRING(_6$$4, "Confirmation", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _3$$4, "__construct", NULL, 479, _5$$4, field, _6$$4, code);
		zephir_check_temp_parameter(_6$$4);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _3$$4);
		zephir_check_call_status();
		RETURN_MM_BOOL(0);
	}
	RETURN_MM_BOOL(1);

}