Пример #1
0
/**
 * Gets pointer number of active row in the resultset
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset, key) {

	zval *_0, *_1;


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_count"), PH_NOISY_CC);
	if (ZEPHIR_GE(_0, _1)) {
		RETURN_NULL();
	}
	RETURN_MEMBER(this_ptr, "_pointer");

}
Пример #2
0
/**
 * 判断字母是否在某个区域内。用于判断某个字符只能介于[a-h](包含)之间的类似情况。
 * @param string alpha 原值。
 * @param string start_alpha 起始值。
 * @param string end_alpha 截止值。
 * @return boolean
 */
PHP_METHOD(Winer_Validator, alpha_between) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *alpha_param = NULL, *start_alpha_param = NULL, *end_alpha_param = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL;
	zval *alpha = NULL, *start_alpha = NULL, *end_alpha = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &alpha_param, &start_alpha_param, &end_alpha_param);

	zephir_get_strval(alpha, alpha_param);
	zephir_get_strval(start_alpha, start_alpha_param);
	zephir_get_strval(end_alpha, end_alpha_param);


	ZEPHIR_CALL_SELF(&_0, "is_alpha", NULL, alpha);
	zephir_check_call_status();
	if (ZEPHIR_IS_FALSE(_0)) {
		RETURN_MM_BOOL(0);
	}
	ZEPHIR_CALL_SELF(&_1, "is_alpha", NULL, start_alpha);
	zephir_check_call_status();
	if (ZEPHIR_IS_FALSE(_1)) {
		RETURN_MM_BOOL(0);
	}
	ZEPHIR_CALL_SELF(&_2, "is_alpha", NULL, end_alpha);
	zephir_check_call_status();
	if (ZEPHIR_IS_FALSE(_2)) {
		RETURN_MM_BOOL(0);
	}
	if (ZEPHIR_GE(start_alpha, end_alpha)) {
		RETURN_MM_BOOL(0);
	}
	if (ZEPHIR_LT(alpha, start_alpha)) {
		RETURN_MM_BOOL(0);
	}
	if (ZEPHIR_GT(alpha, end_alpha)) {
		RETURN_MM_BOOL(0);
	}
	RETURN_MM_BOOL(1);

}
Пример #3
0
/**
 * Ascending listener sort callback.
 *
 * @param \Xpl\Event\Listener a
 * @param \Xpl\Event\Listener b
 * @return int Sort result
 */
PHP_METHOD(Xpl_Event_Manager, sortListenersAsc) {

	zval *a, *b, *_0, *_1, *_2;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &a, &b);



	ZEPHIR_INIT_VAR(_0);
	ZEPHIR_OBS_VAR(_1);
	zephir_read_property(&_1, a, SL("priority"), PH_NOISY_CC);
	ZEPHIR_OBS_VAR(_2);
	zephir_read_property(&_2, b, SL("priority"), PH_NOISY_CC);
	if (ZEPHIR_GE(_1, _2)) {
		ZVAL_LONG(_0, 1);
	} else {
		ZVAL_LONG(_0, -1);
	}
	RETURN_CCTOR(_0);

}
Пример #4
0
/**
 * Logs messages to the internal logger. Appends logs to the logger	 
 */
PHP_METHOD(Phalcon_Logger_Adapter, log) {

	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool _0, _1;
	zval *context = NULL;
	zval *type, *message = NULL, *context_param = NULL, *timestamp, *toggledMessage = NULL, *toggledType = NULL, *_2, *_3, *_4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 2, &type, &message, &context_param);

	if (!message) {
		message = ZEPHIR_GLOBAL(global_null);
	}
	if (!context_param) {
	ZEPHIR_INIT_VAR(context);
	array_init(context);
	} else {
	context = context_param;

	}


	_0 = Z_TYPE_P(type) == IS_STRING;
	if (_0) {
		_0 = Z_TYPE_P(message) == IS_LONG;
	}
	if (_0) {
		ZEPHIR_CPY_WRT(toggledMessage, type);
		ZEPHIR_CPY_WRT(toggledType, message);
	} else {
		_1 = Z_TYPE_P(type) == IS_STRING;
		if (_1) {
			_1 = Z_TYPE_P(message) == IS_NULL;
		}
		if (_1) {
			ZEPHIR_CPY_WRT(toggledMessage, type);
			ZEPHIR_CPY_WRT(toggledType, message);
		} else {
			ZEPHIR_CPY_WRT(toggledMessage, message);
			ZEPHIR_CPY_WRT(toggledType, type);
		}
	}
	if (Z_TYPE_P(toggledType) == IS_NULL) {
		ZEPHIR_INIT_NVAR(toggledType);
		ZVAL_LONG(toggledType, 7);
	}
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("_logLevel"), PH_NOISY_CC);
	if (ZEPHIR_GE(_2, toggledType)) {
		ZEPHIR_INIT_VAR(timestamp);
		zephir_time(timestamp);
		_3 = zephir_fetch_nproperty_this(this_ptr, SL("_transaction"), PH_NOISY_CC);
		if (zephir_is_true(_3)) {
			ZEPHIR_INIT_VAR(_4);
			object_init_ex(_4, phalcon_logger_item_ce);
			ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 52, toggledMessage, toggledType, timestamp, context);
			zephir_check_call_status();
			zephir_update_property_array_append(this_ptr, SL("_queue"), _4 TSRMLS_CC);
		} else {
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "loginternal", NULL, 0, toggledMessage, toggledType, timestamp, context);
			zephir_check_call_status();
		}
	}
	RETURN_THIS();

}
Пример #5
0
PHP_METHOD(PhalconPlus_Base_Exception, __construct) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *info = NULL, info_sub, *logger = NULL, logger_sub, __$null, message, args, _0, _12, cnt, argsCnt, _13, _14, _1$$4, _2$$4, _3$$4, _4$$5, _5$$5, _6$$5, _7$$6, _8$$7, _9$$7, _10$$7, _11$$7, _15$$9, _16$$9;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&info_sub);
	ZVAL_UNDEF(&logger_sub);
	ZVAL_NULL(&__$null);
	ZVAL_UNDEF(&message);
	ZVAL_UNDEF(&args);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_12);
	ZVAL_UNDEF(&cnt);
	ZVAL_UNDEF(&argsCnt);
	ZVAL_UNDEF(&_13);
	ZVAL_UNDEF(&_14);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_3$$4);
	ZVAL_UNDEF(&_4$$5);
	ZVAL_UNDEF(&_5$$5);
	ZVAL_UNDEF(&_6$$5);
	ZVAL_UNDEF(&_7$$6);
	ZVAL_UNDEF(&_8$$7);
	ZVAL_UNDEF(&_9$$7);
	ZVAL_UNDEF(&_10$$7);
	ZVAL_UNDEF(&_11$$7);
	ZVAL_UNDEF(&_15$$9);
	ZVAL_UNDEF(&_16$$9);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 2, &info, &logger);

	if (!info) {
		info = &info_sub;
		ZEPHIR_INIT_VAR(info);
		ZVAL_STRING(info, "");
	}
	if (!logger) {
		logger = &logger_sub;
		logger = &__$null;
	}


	ZEPHIR_INIT_VAR(&message);
	ZVAL_STRING(&message, "");
	ZEPHIR_INIT_VAR(&args);
	array_init(&args);
	ZEPHIR_INIT_VAR(&_0);
	zephir_get_called_class(&_0 TSRMLS_CC);
	ZEPHIR_INIT_NVAR(&message);
	ZEPHIR_CONCAT_SV(&message, "An exception created: ", &_0);
	if (ZEPHIR_IS_EMPTY(info)) {
	} else {
		if (Z_TYPE_P(info) == IS_ARRAY) {
			zephir_array_fetch_long(&_1$$4, info, 0, PH_NOISY | PH_READONLY, "phalconplus/Base/Exception.zep", 22 TSRMLS_CC);
			ZEPHIR_CALL_FUNCTION(&_2$$4, "strval", NULL, 27, &_1$$4);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(&_3$$4);
			ZEPHIR_CONCAT_VSV(&_3$$4, &message, ", message: ", &_2$$4);
			ZEPHIR_CPY_WRT(&message, &_3$$4);
			ZEPHIR_OBS_NVAR(&args);
			if (zephir_array_isset_long_fetch(&args, info, 1, 0 TSRMLS_CC)) {
				zephir_array_fetch_long(&_4$$5, info, 1, PH_NOISY | PH_READONLY, "phalconplus/Base/Exception.zep", 24 TSRMLS_CC);
				if (Z_TYPE_P(&_4$$5) == IS_ARRAY) {
					ZEPHIR_OBS_NVAR(&args);
					zephir_array_fetch_long(&args, info, 1, PH_NOISY, "phalconplus/Base/Exception.zep", 24 TSRMLS_CC);
				} else {
					ZEPHIR_INIT_NVAR(&args);
					zephir_create_array(&args, 1, 0 TSRMLS_CC);
					zephir_array_fetch_long(&_5$$5, info, 1, PH_NOISY | PH_READONLY, "phalconplus/Base/Exception.zep", 24 TSRMLS_CC);
					ZEPHIR_CALL_FUNCTION(&_6$$5, "strval", NULL, 27, &_5$$5);
					zephir_check_call_status();
					zephir_array_fast_append(&args, &_6$$5);
				}
			}
		} else if (Z_TYPE_P(info) == IS_STRING) {
			ZEPHIR_INIT_VAR(&_7$$6);
			ZEPHIR_CONCAT_VSV(&_7$$6, &message, ", message: ", info);
			ZEPHIR_CPY_WRT(&message, &_7$$6);
		}
	}
	if (!(Z_TYPE_P(logger) == IS_NULL)) {
		ZEPHIR_INIT_VAR(&_8$$7);
		ZVAL_LONG(&_9$$7, 256);
		zephir_json_encode(&_8$$7, &args, zephir_get_intval(&_9$$7) );
		ZEPHIR_INIT_VAR(&_10$$7);
		ZEPHIR_CONCAT_VSV(&_10$$7, &message, ", args: ", &_8$$7);
		ZEPHIR_CALL_METHOD(&_11$$7, this_ptr, "getlevel", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, logger, "log", NULL, 0, &_10$$7, &_11$$7);
		zephir_check_call_status();
	}
	zephir_read_property(&_12, this_ptr, SL("message"), PH_NOISY_CC | PH_READONLY);
	if (ZEPHIR_IS_EMPTY(&_12)) {
		zephir_update_property_zval(this_ptr, SL("message"), &message);
	}
	zephir_read_property(&_13, this_ptr, SL("message"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_INIT_VAR(&_14);
	ZVAL_STRING(&_14, "%s");
	ZEPHIR_CALL_FUNCTION(&cnt, "substr_count", NULL, 28, &_13, &_14);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(&argsCnt);
	ZVAL_LONG(&argsCnt, zephir_fast_count_int(&args TSRMLS_CC));
	if (ZEPHIR_GE(&argsCnt, &cnt)) {
		zephir_read_property(&_15$$9, this_ptr, SL("message"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_CALL_FUNCTION(&_16$$9, "vsprintf", NULL, 29, &_15$$9, &args);
		zephir_check_call_status();
		zephir_update_property_zval(this_ptr, SL("message"), &_16$$9);
	}
	ZEPHIR_MM_RESTORE();

}