Пример #1
0
/**
 * Phalcon\Flash constructor
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash, __construct){

	zval *css_classes = NULL;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 0, 1, &css_classes);
	
	if (!css_classes) {
		PHALCON_INIT_VAR(css_classes);
	} else {
		PHALCON_SEPARATE_PARAM(css_classes);
	}
	
	if (Z_TYPE_P(css_classes) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(css_classes);
		array_init_size(css_classes, 4);
		add_assoc_stringl_ex(css_classes, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("warning"), SL("warningMessage"), 1);
	}
	phalcon_update_property_this(this_ptr, SL("_cssClasses"), css_classes TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
Пример #2
0
/**
 * Phalcon\Flash constructor
 *
 * @param array $cssClasses
 */
PHP_METHOD(Phalcon_Flash, __construct){

	zval *css_classes = NULL;

	PHALCON_MM_GROW();

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &css_classes) == FAILURE) {
		RETURN_MM_NULL();
	}

	if (!css_classes) {
		PHALCON_INIT_VAR(css_classes);
	} else {
		PHALCON_SEPARATE_PARAM(css_classes);
	}
	
	if (Z_TYPE_P(css_classes) != IS_ARRAY) { 
		PHALCON_INIT_NVAR(css_classes);
		array_init_size(css_classes, 4);
		add_assoc_stringl_ex(css_classes, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(css_classes, SS("warning"), SL("warningMessage"), 1);
	}
	phalcon_update_property_zval(this_ptr, SL("_cssClasses"), css_classes TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
Пример #3
0
/**
 * Phalcon\Flash constructor
 */
PHP_METHOD(Phalcon_Flash, __construct) {

	zval *cssClasses = NULL;

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

	if (!cssClasses) {
		ZEPHIR_CPY_WRT(cssClasses, ZEPHIR_GLOBAL(global_null));
	} else {
		ZEPHIR_SEPARATE_PARAM(cssClasses);
	}


	if (Z_TYPE_P(cssClasses) != IS_ARRAY) {
		ZEPHIR_INIT_NVAR(cssClasses);
		zephir_create_array(cssClasses, 4, 0 TSRMLS_CC);
		add_assoc_stringl_ex(cssClasses, SS("error"), SL("errorMessage"), 1);
		add_assoc_stringl_ex(cssClasses, SS("notice"), SL("noticeMessage"), 1);
		add_assoc_stringl_ex(cssClasses, SS("success"), SL("successMessage"), 1);
		add_assoc_stringl_ex(cssClasses, SS("warning"), SL("warningMessage"), 1);
	}
	zephir_update_property_this(this_ptr, SL("_cssClasses"), cssClasses TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Пример #4
0
PHP_METHOD(Phalcon_Mvc_Router, __construct){

	zval *a0 = NULL, *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL;

	PHALCON_MM_GROW();
	
	PHALCON_ALLOC_ZVAL_MM(a0);
	array_init(a0);
	zend_update_property(phalcon_mvc_router_ce, this_ptr, SL("_params"), a0 TSRMLS_CC);
	PHALCON_ALLOC_ZVAL_MM(a1);
	array_init(a1);
	PHALCON_ALLOC_ZVAL_MM(a2);
	array_init(a2);
	add_assoc_stringl_ex(a2, SL("pattern")+1, SL("#^/([a-zA-Z0-9\\_]+)[/]{0,1}$#"), 1);
	PHALCON_ALLOC_ZVAL_MM(a3);
	array_init(a3);
	add_assoc_long_ex(a3, SL("controller")+1, 1);
	phalcon_array_update_string(&a2, SL("paths"), &a3, PH_COPY | PH_SEPARATE TSRMLS_CC);
	phalcon_array_append(&a1, a2, PH_SEPARATE TSRMLS_CC);
	PHALCON_ALLOC_ZVAL_MM(a4);
	array_init(a4);
	add_assoc_stringl_ex(a4, SL("pattern")+1, SL("#^/([a-zA-Z0-9\\_]+)/([a-zA-Z0-9\\_]+)(/.*)*$#"), 1);
	PHALCON_ALLOC_ZVAL_MM(a5);
	array_init(a5);
	add_assoc_long_ex(a5, SL("controller")+1, 1);
	add_assoc_long_ex(a5, SL("action")+1, 2);
	add_assoc_long_ex(a5, SL("params")+1, 3);
	phalcon_array_update_string(&a4, SL("paths"), &a5, PH_COPY | PH_SEPARATE TSRMLS_CC);
	phalcon_array_append(&a1, a4, PH_SEPARATE TSRMLS_CC);
	phalcon_update_property_zval(this_ptr, SL("_routes"), a1 TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
Пример #5
0
/**
 * Uncamelize strings which are camelized
 *
 *<code>
 *	echo Phalcon\Text::camelize('CocoBongo'); //coco_bongo
 *</code>
 *
 * @param string $str
 * @return string
 */
PHP_METHOD(Phalcon_Text, uncamelize){

	zval *str = NULL, *patterns = NULL, *replacement = NULL, *pattern = NULL, *match_pattern = NULL;
	zval *pattern_replace = NULL, *lower_pattern = NULL, *lower_str = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;
	char *hash_index;
	uint hash_index_len;
	ulong hash_num;
	int hash_type;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &str) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	PHALCON_INIT_VAR(patterns);
	array_init(patterns);
	add_assoc_stringl_ex(patterns, SL("/(?<=(?:[A-Z]))([A-Z]+)([A-Z][A-z])/")+1, SL("\\1_\\2"), 1);
	add_assoc_stringl_ex(patterns, SL("/(?<=(?:[a-z]))([A-Z])/")+1, SL("_\\1"), 1);
	if (!phalcon_valid_foreach(patterns TSRMLS_CC)) {
		return;
	}
	
	ah0 = Z_ARRVAL_P(patterns);
	zend_hash_internal_pointer_reset_ex(ah0, &hp0);
	fes_f8ee_0:
		if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
			goto fee_f8ee_0;
		}
		
		PHALCON_INIT_VAR(pattern);
		PHALCON_GET_FOREACH_KEY(pattern, ah0, hp0);
		PHALCON_INIT_VAR(replacement);
		ZVAL_ZVAL(replacement, *hd, 1, 0);
		PHALCON_INIT_VAR(match_pattern);
		PHALCON_CALL_FUNC_PARAMS_2(match_pattern, "preg_match", pattern, str);
		if (zend_is_true(match_pattern)) {
			PHALCON_INIT_VAR(pattern_replace);
			PHALCON_CALL_FUNC_PARAMS_3(pattern_replace, "preg_replace", pattern, replacement, str);
			
			PHALCON_INIT_VAR(lower_pattern);
			PHALCON_CALL_FUNC_PARAMS_1(lower_pattern, "strtolower", pattern_replace);
			
			RETURN_CTOR(lower_pattern);
		}
		zend_hash_move_forward_ex(ah0, &hp0);
		goto fes_f8ee_0;
	fee_f8ee_0:
	
	PHALCON_INIT_VAR(lower_str);
	PHALCON_CALL_FUNC_PARAMS_1(lower_str, "strtolower", str);
	
	RETURN_CTOR(lower_str);
}
Пример #6
0
PHP_METHOD(Test_NativeArray, testArray18) {

	zval *a;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	add_assoc_stringl_ex(a, SS("hello1"), SL("a"), 1);
	add_assoc_stringl_ex(a, SS("hello2"), SL("b"), 1);
	add_assoc_stringl_ex(a, SS("hello3"), SL("c"), 1);
	RETURN_CCTOR(a);

}
Пример #7
0
PHP_METHOD(Test_Json, testEncodeObject) {

	zval *obj;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(obj);
	array_init_size(obj, 5);
	add_assoc_stringl_ex(obj, SS("a"), SL("hello"), 1);
	add_assoc_stringl_ex(obj, SS("b"), SL("world"), 1);
	add_assoc_long_ex(obj, SS("c"), 128);
	zephir_json_encode(return_value, &(return_value), obj, 0  TSRMLS_CC);
	RETURN_MM();

}
Пример #8
0
zval* air_arr_del_index_el(zval *arr) {
	HashTable *ht = Z_ARRVAL_P(arr);
	zval *tmp;
	MAKE_STD_ZVAL(tmp);
	array_init(tmp);
	for(
		zend_hash_internal_pointer_reset(ht);
		zend_hash_has_more_elements(ht) == SUCCESS;
		zend_hash_move_forward(ht)
	){
		int type;
		ulong idx;
		char *key;
		uint key_len;
		zval **tmp_data;

		type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL);
		if(type == HASH_KEY_IS_STRING){
			if(zend_hash_get_current_data(ht, (void**)&tmp_data) != FAILURE) {
				add_assoc_stringl_ex(tmp, key, key_len, Z_STRVAL_PP(tmp_data), Z_STRLEN_PP(tmp_data), 1);
			}
		}
	}
	return tmp;
}
Пример #9
0
/**
 * Generates a link to the current version documentation
 */
PHP_METHOD(Phalcon_Debug, getVersion) {

	zval *link = NULL, *_0 = NULL, *_2, *_3, *_4 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL, *_6 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(link);
	zephir_create_array(link, 4, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	ZVAL_LONG(_2, 0);
	ZEPHIR_CALL_CE_STATIC(&_0, phalcon_version_ce, "getpart", &_1, 161, _2);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_3);
	ZEPHIR_CONCAT_SVS(_3, "https://docs.phalconphp.com/en/", _0, ".0.0/");
	zephir_array_update_string(&link, SL("action"), &_3, PH_COPY | PH_SEPARATE);
	ZEPHIR_CALL_CE_STATIC(&_4, phalcon_version_ce, "get", &_5, 160);
	zephir_check_call_status();
	zephir_array_update_string(&link, SL("text"), &_4, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&link, SL("local"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE);
	add_assoc_stringl_ex(link, SS("target"), SL("_new"), 1);
	ZEPHIR_CALL_CE_STATIC(&_4, phalcon_tag_ce, "linkto", &_6, 162, link);
	zephir_check_call_status();
	ZEPHIR_CONCAT_SVS(return_value, "<div class='version'>Phalcon Framework ", _4, "</div>");
	RETURN_MM();

}
Пример #10
0
/* {{{ php_foreach_cat
 */
static int php_foreach_cat (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata)
{
	int err;

	err = ypprot_err (instatus);

	if (!err)
	{
		if (inkeylen) {
			char *key = emalloc(inkeylen+1);
			strlcpy(key, inkey, inkeylen+1);
			add_assoc_stringl_ex((zval *) indata, key, inkeylen+1, inval, invallen, 1);
			efree(key);
		}

		return 0;
	}

	if (err != YPERR_NOMORE)
	{
		TSRMLS_FETCH();

		YP(error) = err;
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (err));
	}

	return 0;
}
Пример #11
0
static int httpparser_assign(char *type, int type_len, http_parser *p, const char *buf, size_t len)
{
    httpParserObj * Parser;
    Parser = (httpParserObj *)p->data;
    add_assoc_stringl_ex(Parser->variable, type, type_len, buf, len, 1);
    return 0;
}
Пример #12
0
/** {{{ int yaf_response_alter_header(yaf_response_t *response, char *name, uint name_len, char *value, long value_len, int flag TSRMLS_DC)
*/
int yaf_response_alter_header(yaf_response_t *response, char *name, uint name_len, char *value, long value_len, uint rep TSRMLS_DC) {
	zval *z_headers, **ppzval;
	char *oheader;

	if (!name_len) {
		return 1;
	}

	z_headers = zend_read_property(yaf_response_ce, response, ZEND_STRL(YAF_RESPONSE_PROPERTY_NAME_HEADER), 1 TSRMLS_CC);

	if (zend_hash_find(Z_ARRVAL_P(z_headers), name, name_len + 1, (void **)&ppzval) == FAILURE) {
		add_assoc_stringl_ex(z_headers, name, name_len + 1, value, value_len, 1);

		return 1;
	}

	oheader = Z_STRVAL_PP(ppzval);

	if (rep) {
		ZVAL_STRINGL(*ppzval, value, value_len, 1);
	} else {
		Z_STRLEN_PP(ppzval) = spprintf(&Z_STRVAL_PP(ppzval), 0, "%s, %s", oheader, value);
	}

	efree(oheader);

	return 1;
}
Пример #13
0
PHP_METHOD(Test_NativeArray, testArray18) {

	zval a;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&a);

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(&a);
	zephir_create_array(&a, 3, 0 TSRMLS_CC);
	add_assoc_stringl_ex(&a, SL("hello1"), SL("a"));
	add_assoc_stringl_ex(&a, SL("hello2"), SL("b"));
	add_assoc_stringl_ex(&a, SL("hello3"), SL("c"));
	RETURN_CCTOR(&a);

}
Пример #14
0
PHP_METHOD(Test_Issue1521, test) {

	zval _0;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&_0);

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(&_0);
	zephir_create_array(&_0, 2, 0 TSRMLS_CC);
	add_assoc_stringl_ex(&_0, SL("merchantNumber"), SL("0818217122"));
	add_assoc_stringl_ex(&_0, SL("zero"), SL("0"));
	zephir_update_property_zval(this_ptr, SL("params"), &_0);
	RETURN_MM_MEMBER(getThis(), "params");

}
Пример #15
0
/**
 * Gets default options
 */
PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getOptionsDefault) {


	zephir_create_array(return_value, 2, 0 TSRMLS_CC);
	add_assoc_long_ex(return_value, SS("category"), 0);
	add_assoc_stringl_ex(return_value, SS("defaultDomain"), SL("message"), 1);
	return;

}
Пример #16
0
ZEND_RESULT_CODE air_router_route_apply_subpats(zval *r, zval *subpats, char *key, int key_len, char *ro, int ro_len) {
	zval *tmp_val = air_arr_find(r, key, key_len);
	if(tmp_val){
		char *tmp = Z_STRVAL_P(tmp_val);
		if(tmp[0] == '$'){
			tmp_val = air_arr_find(subpats, tmp+1, strlen(tmp));
			if(tmp_val){
				add_assoc_stringl_ex(subpats, key, key_len, Z_STRVAL_P(tmp_val), Z_STRLEN_P(tmp_val), 1);
			}else{
				php_error(E_NOTICE, "ref name '%s' not found in route rule '%s', and 'index' will be set instead,", tmp,  ro TSRMLS_CC);
				add_assoc_stringl_ex(subpats, key, key_len, ZEND_STRL("index"), 1);
			}
		}else{
			add_assoc_stringl_ex(subpats, key, key_len, Z_STRVAL_P(tmp_val), Z_STRLEN_P(tmp_val), 1);
		}
		return SUCCESS;
	}
	return FAILURE;
}
Пример #17
0
PHP_METHOD(Test_Properties_PublicProperties, __construct) {

	zval *_1, *_2 = NULL, *_3;
	zval *_0, *_4 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	array_init(_0);
	zephir_update_property_this(this_ptr, SL("someGetterSetterArray"), _0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_1);
	zephir_create_array(_1, 4, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	zephir_create_array(_2, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-success"), 1);
	zephir_array_update_string(&_1, SL("success"), &_2, PH_COPY | PH_SEPARATE);
	ZEPHIR_INIT_NVAR(_2);
	zephir_create_array(_2, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-info"), 1);
	zephir_array_update_string(&_1, SL("info"), &_2, PH_COPY | PH_SEPARATE);
	ZEPHIR_INIT_NVAR(_2);
	zephir_create_array(_2, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-warning"), 1);
	zephir_array_update_string(&_1, SL("warning"), &_2, PH_COPY | PH_SEPARATE);
	ZEPHIR_INIT_NVAR(_2);
	zephir_create_array(_2, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-danger"), 1);
	zephir_array_update_string(&_1, SL("danger"), &_2, PH_COPY | PH_SEPARATE);
	zephir_update_property_this(this_ptr, SL("someArrayWithSubArray"), _1 TSRMLS_CC);
	ZEPHIR_INIT_NVAR(_2);
	zephir_create_array(_2, 3, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_2, SS("a"), SL("A"), 1);
	add_assoc_stringl_ex(_2, SS("b"), SL("B"), 1);
	add_assoc_stringl_ex(_2, SS("c"), SL("C"), 1);
	zephir_update_property_this(this_ptr, SL("someArrayWithSpecifyKeys"), _2 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_3);
	zephir_create_array(_3, 4, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_4);
	ZVAL_LONG(_4, 1);
	zephir_array_fast_append(_3, _4);
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_LONG(_4, 2);
	zephir_array_fast_append(_3, _4);
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_LONG(_4, 3);
	zephir_array_fast_append(_3, _4);
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_LONG(_4, 4);
	zephir_array_fast_append(_3, _4);
	zephir_update_property_this(this_ptr, SL("someArray"), _3 TSRMLS_CC);
	ZEPHIR_INIT_NVAR(_4);
	array_init(_4);
	zephir_update_property_this(this_ptr, SL("someEmptyArray"), _4 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Пример #18
0
void air_config_init_default(TSRMLS_D){
	zval *_data = NULL;
	MAKE_STD_ZVAL(_data);
	array_init(_data);

	zval *app = NULL;
	MAKE_STD_ZVAL(app);
	array_init(app);
	add_assoc_stringl_ex(app, ZEND_STRS("path"), ZEND_STRL("app"), 1);

	zval *exec;
	MAKE_STD_ZVAL(exec);
	array_init(exec);
	add_assoc_stringl_ex(exec, ZEND_STRS("path"), ZEND_STRL("exec"), 1);
	add_assoc_zval_ex(app, ZEND_STRS("exec"), exec);


	zval *site;
	MAKE_STD_ZVAL(site);
	array_init(site);
	add_assoc_stringl_ex(site, ZEND_STRS("path"), ZEND_STRL("site"), 1);
	add_assoc_zval_ex(app, ZEND_STRS("site"), site);

	zval *view;
	MAKE_STD_ZVAL(view);
	array_init(view);
	add_assoc_stringl_ex(view, ZEND_STRS("engine"), ZEND_STRL("air\\view"), 1);
	add_assoc_stringl_ex(view, ZEND_STRS("path"), ZEND_STRL("view"), 1);
	add_assoc_stringl_ex(view, ZEND_STRS("type"), ZEND_STRL(".php"), 1);
	add_assoc_zval_ex(app, ZEND_STRS("view"), view);

	add_assoc_zval_ex(_data, ZEND_STRS("app"), app);
	zend_update_static_property(air_config_ce, ZEND_STRL("_data"), _data TSRMLS_CC);
	zval_ptr_dtor(&_data);
}
Пример #19
0
PHP_METHOD(Test_IssetTest, __construct) {

	zval *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	zephir_create_array(_0, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_0, SS("a"), SL("true"), 1);
	zephir_update_property_this(this_ptr, SL("s"), _0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Пример #20
0
PHP_METHOD(phady_8__closure, __invoke) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0;
	zval *flash;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(flash);
	object_init_ex(flash, phalcon_flash_session_ce);
	if (zephir_has_constructor(flash TSRMLS_CC)) {
		ZEPHIR_INIT_VAR(_0);
		zephir_create_array(_0, 3, 0 TSRMLS_CC);
		add_assoc_stringl_ex(_0, SS("error"), SL("alert alert-danger"), 1);
		add_assoc_stringl_ex(_0, SS("success"), SL("alert alert-success"), 1);
		add_assoc_stringl_ex(_0, SS("notice"), SL("alert alert-info"), 1);
		ZEPHIR_CALL_METHOD(NULL, flash, "__construct", NULL, 0, _0);
		zephir_check_call_status();
	}
	RETURN_CCTOR(flash);

}
Пример #21
0
/**
 * Phalcon\Cache\Backend\Memcache constructor
 *
 * @param	array options
 */
PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, __construct) {

	zval _0$$4;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_2 = NULL;
	zval *frontend, frontend_sub, *options = NULL, options_sub, __$null, servers, _1$$5;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&frontend_sub);
	ZVAL_UNDEF(&options_sub);
	ZVAL_NULL(&__$null);
	ZVAL_UNDEF(&servers);
	ZVAL_UNDEF(&_1$$5);
	ZVAL_UNDEF(&_0$$4);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &frontend, &options);

	if (!options) {
		options = &options_sub;
		ZEPHIR_CPY_WRT(options, &__$null);
	} else {
		ZEPHIR_SEPARATE_PARAM(options);
	}


	if (Z_TYPE_P(options) != IS_ARRAY) {
		ZEPHIR_INIT_NVAR(options);
		array_init(options);
	}
	if (!(zephir_array_isset_string(options, SL("servers")))) {
		ZEPHIR_INIT_VAR(&servers);
		zephir_create_array(&servers, 1, 0 TSRMLS_CC);
		ZEPHIR_INIT_VAR(&_0$$4);
		zephir_create_array(&_0$$4, 3, 0 TSRMLS_CC);
		add_assoc_stringl_ex(&_0$$4, SL("host"), SL("127.0.0.1"));
		add_assoc_long_ex(&_0$$4, SL("port"), 11211);
		add_assoc_long_ex(&_0$$4, SL("weight"), 1);
		zephir_array_update_long(&servers, 0, &_0$$4, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY);
		zephir_array_update_string(options, SL("servers"), &servers, PH_COPY | PH_SEPARATE);
	}
	if (!(zephir_array_isset_string(options, SL("statsKey")))) {
		ZEPHIR_INIT_VAR(&_1$$5);
		ZVAL_STRING(&_1$$5, "");
		zephir_array_update_string(options, SL("statsKey"), &_1$$5, PH_COPY | PH_SEPARATE);
	}
	ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_libmemcached_ce, getThis(), "__construct", &_2, 0, frontend, options);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

}
Пример #22
0
PHP_METHOD(Test_NativeArray, testArray30) {

	zval *b;
	zval *a;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(b);
	ZVAL_STRING(b, "hello", 1);
	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 2);
	add_assoc_stringl_ex(a, Z_STRVAL_P(b), Z_STRLEN_P(b) + 1, SL("hello"), 1);
	RETURN_CCTOR(a);

}
Пример #23
0
PHP_COUCHBASE_LOCAL
void pcbc_ht_hkstores(zval *assoc, pcbc_ht_key *hk,
                      const char *value, int nvalue)
{
	const char *zh_key;
	int zh_nkey;

	ISARRAY_SANITY(assoc);

	if (nvalue == -1) {
		nvalue = strlen(value);
	}

	HK_STRING(hk, zh_key, zh_nkey);

	/* value is duplicated, so it's sane to cast to char */
	add_assoc_stringl_ex(assoc, zh_key, zh_nkey, (char *)value, nvalue, 1);
}
Пример #24
0
/**
 * Phalcon\Assets\Inline\Css
 *
 * @param string content
 * @param boolean filter
 * @param array attributes
 */
PHP_METHOD(Phalcon_Assets_Inline_Css, __construct) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_0 = NULL;
	zend_bool filter;
	zval *content_param = NULL, *filter_param = NULL, *attributes = NULL, *_1, *_2;
	zval *content = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes);

	zephir_get_strval(content, content_param);
	if (!filter_param) {
		filter = 1;
	} else {
		filter = zephir_get_boolval(filter_param);
	}
	if (!attributes) {
		ZEPHIR_CPY_WRT(attributes, ZEPHIR_GLOBAL(global_null));
	} else {
		ZEPHIR_SEPARATE_PARAM(attributes);
	}


	if (Z_TYPE_P(attributes) == IS_NULL) {
		ZEPHIR_INIT_NVAR(attributes);
		zephir_create_array(attributes, 1, 0 TSRMLS_CC);
		add_assoc_stringl_ex(attributes, SS("type"), SL("text/css"), 1);
	}
	ZEPHIR_INIT_VAR(_1);
	ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_INIT_VAR(_2);
	if (filter) {
		ZVAL_BOOL(_2, 1);
	} else {
		ZVAL_BOOL(_2, 0);
	}
	ZEPHIR_CALL_PARENT(NULL, phalcon_assets_inline_css_ce, this_ptr, "__construct", &_0, 104, _1, content, _2, attributes);
	zephir_check_temp_parameter(_1);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

}
Пример #25
0
PHP_METHOD(Test_NativeArray, testArray30) {

	zval b;
	zval a;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&a);
	ZVAL_UNDEF(&b);

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(&b);
	ZVAL_STRING(&b, "hello");
	ZEPHIR_INIT_VAR(&a);
	zephir_create_array(&a, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(&a, Z_STRVAL_P(&b), Z_STRLEN_P(&b), SL("hello"));
	RETURN_CCTOR(&a);

}
Пример #26
0
PHP_METHOD(PhalconPlus_Db_UnitOfWork, update) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zend_bool assign, _0;
	zval *initial_data = NULL, *_1;
	zval *name, *model, *initial_data_param = NULL, *assign_param = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 2, &name, &model, &initial_data_param, &assign_param);

	if (!initial_data_param) {
		ZEPHIR_INIT_VAR(initial_data);
		array_init(initial_data);
	} else {
		zephir_get_arrval(initial_data, initial_data_param);
	}
	if (!assign_param) {
		assign = 1;
	} else {
		assign = zephir_get_boolval(assign_param);
	}


	_0 = !(ZEPHIR_IS_EMPTY(initial_data));
	if (_0) {
		_0 = assign == 1;
	}
	if (_0) {
		ZEPHIR_CALL_METHOD(NULL, model, "assign", NULL, 0, initial_data);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "detach", NULL, 0, model);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_1);
	zephir_create_array(_1, 3, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_1, SS("method"), SL("update"), 1);
	zephir_array_update_string(&_1, SL("name"), &name, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_1, SL("initial_data"), &initial_data, PH_COPY | PH_SEPARATE);
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "attach", NULL, 0, model, _1);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

}
Пример #27
0
PHP_METHOD(Owl_Http_Response_Json, __construct) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_1;
	zval *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	object_init_ex(_0, owl_std_arraybag_ce);
	ZEPHIR_INIT_VAR(_1);
	zephir_create_array(_1, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_1, SS("Content-Type"), SL("application/json"), 1);
	ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 3, _1);
	zephir_check_call_status();
	zephir_update_property_this(this_ptr, SL("headers"), _0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Пример #28
0
    FOREACH_KEYVAL(pos, param, key, entry) {
        if (key.type == HASH_KEY_IS_STRING) {
            if (PHP_ICONV_ERR_SUCCESS != php_iconv_string(key.str, key.len-1, &xkey, &xlen, oe, ie)) {
                http_error_ex(HE_WARNING, HTTP_E_QUERYSTRING, "Failed to convert '%.*s' from '%s' to '%s'", key.len-1, key.str, ie, oe);
                return FAILURE;
            }
        }

        if (Z_TYPE_PP(entry) == IS_STRING) {
            if (PHP_ICONV_ERR_SUCCESS != php_iconv_string(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), &xlate_str, &xlate_len, oe, ie)) {
                if (key.type == HASH_KEY_IS_STRING) {
                    efree(xkey);
                }
                http_error_ex(HE_WARNING, HTTP_E_QUERYSTRING, "Failed to convert '%.*s' from '%s' to '%s'", Z_STRLEN_PP(entry), Z_STRVAL_PP(entry), ie, oe);
                return FAILURE;
            }
            if (key.type == HASH_KEY_IS_STRING) {
                add_assoc_stringl_ex(array, xkey, xlen+1, xlate_str, xlate_len, 0);
            } else {
                add_index_stringl(array, key.num, xlate_str, xlate_len, 0);
            }
        } else if (Z_TYPE_PP(entry) == IS_ARRAY) {
            zval *subarray;

            MAKE_STD_ZVAL(subarray);
            array_init(subarray);
            if (key.type == HASH_KEY_IS_STRING) {
                add_assoc_zval_ex(array, xkey, xlen+1, subarray);
            } else {
                add_index_zval(array, key.num, subarray);
            }
            if (SUCCESS != http_querystring_xlate(subarray, *entry, ie, oe)) {
                if (key.type == HASH_KEY_IS_STRING) {
                    efree(xkey);
                }
                return FAILURE;
            }
        }

        if (key.type == HASH_KEY_IS_STRING) {
            efree(xkey);
        }
    }
Пример #29
0
PHP_METHOD(phady_6__closure, __invoke) {

	zval *_0;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *view;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(view);
	object_init_ex(view, phalcon_mvc_view_ce);
	ZEPHIR_CALL_METHOD(NULL, view, "__construct", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_0);
	zephir_create_array(_0, 1, 0 TSRMLS_CC);
	add_assoc_stringl_ex(_0, SS(".volt"), SL("volt"), 1);
	ZEPHIR_CALL_METHOD(NULL, view, "registerengines", NULL, 0, _0);
	zephir_check_call_status();
	RETURN_CCTOR(view);

}
Пример #30
0
static int httpparser_append(char *type, int type_len, http_parser *p, const char *buf, size_t len)
{
    zval * dest, **fnd;
    httpParserObj * Parser;
    Parser = (httpParserObj *)p->data;
    if (zend_hash_find(Z_ARRVAL_P(Parser->variable), type, type_len, (void**)&fnd) == FAILURE) {
        ALLOC_INIT_ZVAL(dest);
        array_init(dest);
        add_assoc_stringl_ex(Parser->variable, type, type_len, buf, len, 1);
    } else {
        dest = *fnd;
        convert_to_string(dest);

        /* Enlarge a's buffer to hold the additional data */
        Z_STRVAL_P(dest) = erealloc(Z_STRVAL_P(dest), Z_STRLEN_P(dest) + len + 1);
        memcpy(Z_STRVAL_P(dest) + Z_STRLEN_P(dest),  buf, len);
        Z_STRLEN_P(dest) += len;
    }

    return 0;
}