本文整理汇总了PHP中sfToolkit::stringToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP sfToolkit::stringToArray方法的具体用法?PHP sfToolkit::stringToArray怎么用?PHP sfToolkit::stringToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfToolkit
的用法示例。
在下文中一共展示了sfToolkit::stringToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLinkToAction
public function getLinkToAction($actionName, $params, $pk_link = false)
{
$options = isset($params['params']) && !is_array($params['params']) ? sfToolkit::stringToArray($params['params']) : array();
// default values
if ($actionName[0] == '_') {
$actionName = substr($actionName, 1);
$name = $actionName;
//$icon = sfConfig::get('sf_admin_web_dir').'/images/'.$actionName.'_icon.png';
$action = $actionName;
if ($actionName == 'delete') {
$options['post'] = true;
if (!isset($options['confirm'])) {
$options['confirm'] = 'Are you sure?';
}
}
} else {
$name = isset($params['name']) ? $params['name'] : $actionName;
//$icon = isset($params['icon']) ? sfToolkit::replaceConstants($params['icon']) : sfConfig::get('sf_admin_web_dir').'/images/default_icon.png';
$action = isset($params['action']) ? $params['action'] : 'List' . sfInflector::camelize($actionName);
}
$url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\'';
$phpOptions = var_export($options, true);
// little hack
$phpOptions = preg_replace("/'confirm' => '(.+?)(?<!\\\\)'/", '\'confirm\' => __(\'$1\')', $phpOptions);
return '<li class="sf_admin_action_' . sfInflector::underscore($name) . '">[?php echo link_to(__(\'' . $params['label'] . '\'), \'' . $this->getModuleName() . '/' . $action . $url_params . ($options ? ', ' . $phpOptions : '') . ') ?]</li>' . "\n";
}
示例2: getOptionToAction
/**
* Returns HTML code for an action option in a select tag.
*
* @param string The action name
* @param array The parameters
*
* @return string HTML code
*/
public function getOptionToAction($actionName, $params)
{
$options = isset($params['params']) ? sfToolkit::stringToArray($params['params']) : array();
// default values
if ($actionName[0] == '_') {
$actionName = substr($actionName, 1);
if ($actionName == 'deleteSelected') {
$params['name'] = 'Delete Selected';
}
}
$name = isset($params['name']) ? $params['name'] : $actionName;
$options['value'] = $actionName;
$phpOptions = var_export($options, true);
return '[?php echo content_tag(\'option\', __(\'' . $name . '\')' . ($options ? ', ' . $phpOptions : '') . ') ?]';
}
示例3: getColumnEditTag
public function getColumnEditTag($column, $params = array())
{
// user defined parameters
$user_params = $this->getParameterValue('edit.fields.' . $column->getName() . '.params');
$user_params = is_array($user_params) ? $user_params : sfToolkit::stringToArray($user_params);
$params = $user_params ? array_merge($params, $user_params) : $params;
if ($column->isComponent()) {
return "get_component('" . $this->getModuleName() . "', '" . $column->getName() . "', array('type' => 'edit', '{$this->getSingularName()}' => \${$this->getSingularName()}))";
} else {
if ($column->isPartial()) {
return "get_partial('" . $column->getName() . "', array('type' => 'edit', '{$this->getSingularName()}' => \${$this->getSingularName()}))";
}
}
if ($this->getParameterValue('edit.fields.' . $column->getName() . '.type') == "plain") {
return "'<div class=\"sf_admin_plain_field\">'.\${$this->getSingularName()}->get" . sfInflector::camelize($column->getName()) . "().'</div>'";
} else {
return '$form["' . $column->getName() . '"]->render(' . $this->getObjectTagParams($params) . ')';
}
}
示例4: array
'foo=bar' => array('foo' => 'bar'),
'foo1=bar1 foo=bar ' => array('foo1' => 'bar1', 'foo' => 'bar'),
'foo1="bar1 foo1"' => array('foo1' => 'bar1 foo1'),
'foo1="bar1 foo1" foo=bar' => array('foo1' => 'bar1 foo1', 'foo' => 'bar'),
'foo1 = "bar1=foo1" foo=bar' => array('foo1' => 'bar1=foo1', 'foo' => 'bar'),
'foo1= \'bar1 foo1\' foo = bar' => array('foo1' => 'bar1 foo1', 'foo' => 'bar'),
'foo1=\'bar1=foo1\' foo = bar' => array('foo1' => 'bar1=foo1', 'foo' => 'bar'),
'foo1= bar1 foo1 foo=bar' => array('foo1' => 'bar1 foo1', 'foo' => 'bar'),
'foo1="l\'autre" foo=bar' => array('foo1' => 'l\'autre', 'foo' => 'bar'),
'foo1="l"autre" foo=bar' => array('foo1' => 'l"autre', 'foo' => 'bar'),
'foo_1=bar_1' => array('foo_1' => 'bar_1'),
);
foreach ($tests as $string => $attributes)
{
$t->is(sfToolkit::stringToArray($string), $attributes, '->stringToArray()');
}
// ::isUTF8()
$t->diag('::isUTF8()');
$t->is('été', true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');
$t->is(sfToolkit::isUTF8('AZERTYazerty1234-_'), true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');
$t->is(sfToolkit::isUTF8('AZERTYazerty1234-_'.chr(254)), false, '::isUTF8() returns false if the parameter is not an UTF-8 encoded string');
// check a very long string
$string = str_repeat('Here is an UTF8 string avec du français.', 1000);
$t->is(sfToolkit::isUTF8($string), true, '::isUTF8() can operate on very large strings');
// ::literalize()
$t->diag('::literalize()');
foreach (array('true', 'on', '+', 'yes') as $param)
{
示例5: _parse_attributes
function _parse_attributes($string)
{
return is_array($string) ? $string : sfToolkit::stringToArray($string);
}
示例6: foreach
echo $this->getSingularName();
?>
->save();
<?php
foreach ($this->getColumnCategories('edit.display') as $category) {
foreach ($this->getColumns('edit.display', $category) as $name => $column) {
$type = $column->getCreoleType();
$name = $column->getName();
if ($column->isPrimaryKey()) {
continue;
}
$credentials = $this->getParameterValue('edit.fields.' . $column->getName() . '.credentials');
$input_type = $this->getParameterValue('edit.fields.' . $column->getName() . '.type');
$user_params = $this->getParameterValue('edit.fields.' . $column->getName() . '.params');
$user_params = is_array($user_params) ? $user_params : sfToolkit::stringToArray($user_params);
$through_class = isset($user_params['through_class']) ? $user_params['through_class'] : '';
if ($through_class) {
$class = $this->getClassName();
$related_class = sfPropelManyToMany::getRelatedClass($class, $through_class);
$related_table = constant($related_class . 'Peer::TABLE_NAME');
$middle_table = constant($through_class . 'Peer::TABLE_NAME');
$this_table = constant($class . 'Peer::TABLE_NAME');
$related_column = sfPropelManyToMany::getRelatedColumn($class, $through_class);
$column = sfPropelManyToMany::getColumn($class, $through_class);
if ($input_type == 'admin_double_list' || $input_type == 'admin_check_list' || $input_type == 'admin_select_list') {
if ($credentials) {
$credentials = str_replace("\n", ' ', var_export($credentials, true));
?>
if ($this->getUser()->hasCredential(<?php
echo $credentials;
示例7: parseAttr
/**
* Parse attributes
*
* @param string $string Attributes in string
* @return array Attributes
*/
protected static function parseAttr($string)
{
return is_array($string) ? $string : sfToolkit::stringToArray($string);
}
示例8: getOptionsArray
public function getOptionsArray()
{
return sfToolkit::stringToArray($this->getWidgetOptions());
}
示例9: retrieveOptFromString
public static function retrieveOptFromString(&$string, &$opt)
{
if (empty($string)) {
return null;
}
$opt = array_merge($opt, sfToolkit::stringToArray($string));
$string = '';
}
示例10: _convertHierarchyToMenuArray
/**
* Converts the data from getMenuHierarchy into a form usable for import
* by ioMenuItem.
*
* This is roughly opposite to the transformations done when persisting
* data in persistFromMenuArray() and _convertMenuData
*
* @param array $data The tree array data from getMenuHierarchy()
* @return array
*/
protected static function _convertHierarchyToMenuArray($data)
{
unset($data['level'], $data['id']);
if (isset($data['Permissions'])) {
$credentials = array();
foreach ($data['Permissions'] as $permission) {
$credentials[] = $permission['name'];
}
$data['credentials'] = $credentials;
unset($data['Permissions']);
}
// handle i18n
if (isset($data['Translation'])) {
// we have i18n, so create an array of i18n labels
$i18nLabels = array();
foreach ($data['Translation'] as $culture => $i18nData) {
if ($i18nData['label']) {
$i18nLabels[$culture] = $i18nData['label'];
}
}
$data['i18n_labels'] = $i18nLabels;
unset($data['Translation']);
// try to set the default label from the default culture
$defaultCulture = sfConfig::get('sf_default_culture');
if (isset($i18nLabels[$defaultCulture])) {
$data['label'] = $i18nLabels[$defaultCulture];
}
}
// convert the attributes back into an array
$data['attributes'] = sfToolkit::stringToArray($data['attributes']);
// handle the children data
if (isset($data['__children'])) {
$childrenData = array();
foreach ($data['__children'] as $childData) {
// recurse the children data onto this method
$childrenData[$childData['name']] = self::_convertHierarchyToMenuArray($childData);
}
$data['children'] = $childrenData;
unset($data['__children']);
}
return $data;
}
示例11: getClasses
/**
* Returns the CSS classes to apply as a string
*
* @param string $params
* @return string
* @static
*/
public static function getClasses($params)
{
$table = sfToolkit::stringToArray($params);
return $table['class'];
}
示例12: getParamsArray
public function getParamsArray()
{
return $this->get('params') ? sfToolkit::stringToArray($this->get('params')) : array();
}
示例13: getColumnListTag
/**
* Returns HTML code for a column in list mode.
*
* @param string The column name
* @param array The parameters
*
* @return string HTML code
*/
public function getColumnListTag($column, $params = array())
{
$user_params = $this->getParameterValue('list.fields.' . $column->getName() . '.params');
$user_params = is_array($user_params) ? $user_params : sfToolkit::stringToArray($user_params);
$params = $user_params ? array_merge($params, $user_params) : $params;
$type = $column->getType();
$columnGetter = $this->getColumnGetter($column, true);
if ($column->isComponent()) {
return "get_component('" . $this->getModuleName() . "', '" . $column->getName() . "', array('type' => 'list', '{$this->getSingularName()}' => \${$this->getSingularName()}))";
} else {
if ($column->isPartial()) {
return "get_partial('" . $column->getName() . "', array('type' => 'list', '{$this->getSingularName()}' => \${$this->getSingularName()}))";
} else {
if ($type == PropelColumnTypes::DATE || $type == PropelColumnTypes::TIMESTAMP) {
$format = isset($params['date_format']) ? $params['date_format'] : ($type == PropelColumnTypes::DATE ? 'D' : 'f');
return "({$columnGetter} !== null && {$columnGetter} !== '') ? format_date({$columnGetter}, \"{$format}\") : ''";
} elseif ($type == PropelColumnTypes::BOOLEAN) {
return "{$columnGetter} ? image_tag(sfConfig::get('sf_admin_web_dir').'/images/tick.png') : ' '";
} else {
return "{$columnGetter}";
}
}
}
}
示例14: prepare
/**
* Apply common options to a value.
*
* @param mixed $value
* @param mixed $options
*
* @return bool whether to continue execution
*/
protected function prepare(&$value, &$options = array())
{
if (is_string($options)) {
$options = sfToolkit::stringToArray($options);
}
if (isset($options['use_flash']) && $options['use_flash']) {
unset($options['use_flash']);
$trace = debug_backtrace();
$caller = $trace[1];
$this->plant($caller['function'], array($value, $options));
return false;
} else {
if (is_string($value) && isset($options['is_route']) && $options['is_route']) {
$value = $this->context->getController()->genUrl($value);
unset($options['is_route']);
}
return true;
}
}
示例15: getColumnFilterTag
/**
* Returns HTML code for a column in filter mode.
*
* @param string The column name
* @param array The parameters
*
* @return string HTML code
*/
public function getColumnFilterTag($column, $params = array())
{
$user_params = $this->getParameterValue('list.fields.' . $column->getColumnName() . '.params');
$user_params = is_array($user_params) ? $user_params : sfToolkit::stringToArray($user_params);
$params = $user_params ? array_merge($params, $user_params) : $params;
# if ($column->isComponent())
# {
# return "get_component('".$this->getModuleName()."', '".$column->getName()."', array('type' => 'list'))";
# }
# else if ($column->isPartial())
# {
# return "get_partial('".$column->getName()."', array('type' => 'filter', 'filters' => \$filters))";
# }
$type = $column->getCreoleType();
$default_value = "isset(\$filters['" . $column->getColumnName() . "']) ? \$filters['" . $column->getColumnName() . "'] : null";
$unquotedName = 'filters[' . $column->getColumnName() . ']';
$name = "'{$unquotedName}'";
if ($column->isForeignKey()) {
$params = $this->getObjectTagParams($params, array('include_blank' => true, 'related_class' => $this->getRelatedClassName($column), 'text_method' => '__toString', 'control_name' => $unquotedName));
return "object_select_tag({$default_value}, null, {$params})";
} else {
if ($type == CreoleTypes::DATE) {
// rich=false not yet implemented
$params = $this->getObjectTagParams($params, array('middle' => '<br>', 'rich' => true, 'calendar_button_img' => sfConfig::get('sf_admin_web_dir') . '/images/calendar.gif'));
return "input_date_range_tag({$name}, {$default_value}, {$params})";
} else {
if ($type == CreoleTypes::TIMESTAMP) {
// rich=false not yet implemented
$params = $this->getObjectTagParams($params, array('middle' => '<br>', 'rich' => true, 'withtime' => true, 'calendar_button_img' => sfConfig::get('sf_admin_web_dir') . '/images/calendar.gif'));
return "input_date_range_tag({$name}, {$default_value}, {$params})";
} else {
if ($type == CreoleTypes::BOOLEAN) {
$defaultIncludeCustom = '__("yes or no")';
$option_params = $this->getObjectTagParams($params, array('include_custom' => $defaultIncludeCustom));
$params = $this->getObjectTagParams($params);
// little hack
$option_params = preg_replace("/'" . preg_quote($defaultIncludeCustom) . "'/", $defaultIncludeCustom, $option_params);
$options = "options_for_select(array(1 => __('yes'), 0 => __('no')), {$default_value}, {$option_params})";
return "select_tag({$name}, {$options}, {$params})";
} else {
if ($type == CreoleTypes::CHAR || $type == CreoleTypes::VARCHAR || $type == CreoleTypes::TEXT || $type == CreoleTypes::LONGVARCHAR) {
$size = $column->getSize() < 15 ? $column->getSize() : 15;
$params = $this->getObjectTagParams($params, array('size' => $size));
return "input_tag({$name}, {$default_value}, {$params})";
} else {
if ($type == CreoleTypes::INTEGER || $type == CreoleTypes::TINYINT || $type == CreoleTypes::SMALLINT || $type == CreoleTypes::BIGINT) {
$params = $this->getObjectTagParams($params, array('size' => 7));
return "input_tag({$name}, {$default_value}, {$params})";
} else {
if ($type == CreoleTypes::FLOAT || $type == CreoleTypes::DOUBLE || $type == CreoleTypes::DECIMAL || $type == CreoleTypes::NUMERIC || $type == CreoleTypes::REAL) {
$params = $this->getObjectTagParams($params, array('size' => 7));
return "input_tag({$name}, {$default_value}, {$params})";
} else {
$params = $this->getObjectTagParams($params, array('disabled' => true));
return "input_tag({$name}, {$default_value}, {$params})";
}
}
}
}
}
}
}
}