当前位置: 首页>>代码示例>>PHP>>正文


PHP sfToolkit::stringToArray方法代码示例

本文整理汇总了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";
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:26,代码来源:sfPropelRevisitedGenerator.class.php

示例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 : '') . ') ?]';
 }
开发者ID:robinkanters,项目名称:dnsleergemeenschap,代码行数:23,代码来源:DbFinderAdminGenerator.class.php

示例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) . ')';
     }
 }
开发者ID:psskhal,项目名称:symfony-sample,代码行数:19,代码来源:sfAdvancedAdminGenerator.class.php

示例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)
{
开发者ID:nationalfield,项目名称:symfony,代码行数:31,代码来源:sfToolkitTest.php

示例5: _parse_attributes

function _parse_attributes($string)
{
    return is_array($string) ? $string : sfToolkit::stringToArray($string);
}
开发者ID:Phennim,项目名称:symfony1,代码行数:4,代码来源:TagHelper.php

示例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;
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:31,代码来源:actions.class.php

示例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);
 }
开发者ID:relo-san,项目名称:dinSymfonyExtraPlugin,代码行数:10,代码来源:DinTagHelper.php

示例8: getOptionsArray

 public function getOptionsArray()
 {
     return sfToolkit::stringToArray($this->getWidgetOptions());
 }
开发者ID:googlecode-mirror,项目名称:copisim,代码行数:4,代码来源:PlugincsSetting.class.php

示例9: retrieveOptFromString

 public static function retrieveOptFromString(&$string, &$opt)
 {
     if (empty($string)) {
         return null;
     }
     $opt = array_merge($opt, sfToolkit::stringToArray($string));
     $string = '';
 }
开发者ID:eXtreme,项目名称:diem,代码行数:8,代码来源:dmString.php

示例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;
 }
开发者ID:rafaelgou,项目名称:ioDoctrineMenuPlugin,代码行数:52,代码来源:PluginioDoctrineMenuItem.class.php

示例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'];
 }
开发者ID:omarcl,项目名称:training-spot,代码行数:12,代码来源:UIHelper.class.php

示例12: getParamsArray

 public function getParamsArray()
 {
     return $this->get('params') ? sfToolkit::stringToArray($this->get('params')) : array();
 }
开发者ID:theolymp,项目名称:diem,代码行数:4,代码来源:PluginDmSetting.class.php

示例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') : '&nbsp;'";
             } else {
                 return "{$columnGetter}";
             }
         }
     }
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:32,代码来源:sfPropelCrudGenerator.class.php

示例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;
     }
 }
开发者ID:robinkanters,项目名称:dnsleergemeenschap,代码行数:27,代码来源:sfGoogleAnalyticsTracker.class.php

示例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})";
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:taryono,项目名称:school,代码行数:71,代码来源:sfAdminGenerator.class.php


注:本文中的sfToolkit::stringToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。