本文整理汇总了PHP中_parse_attributes函数的典型用法代码示例。如果您正苦于以下问题:PHP _parse_attributes函数的具体用法?PHP _parse_attributes怎么用?PHP _parse_attributes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_parse_attributes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: depp_omnibus_selector
/**
* Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
* If the user has already voted, then a message appears
*
* @param BaseObject $object Propel object instance to vote
* @param string $message a message string to be displayed in the voting-message block
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_omnibus_selector($object, $message = '', $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus');
return '';
}
$user_id = sfContext::getInstance()->getUser()->getId();
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'omnibus-flag'));
}
$object_is_omnibus = $object->getIsOmnibus();
$object_will_be_omnibus = !$object_is_omnibus;
$selector = '';
if ($object_is_omnibus) {
$status = "Questo atto è Omnibus";
$label = "Marcalo come non-Omnibus";
} else {
$status = "Questo atto non è Omnibus";
$label = "Marcalo come Omnibus";
}
$selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true));
return content_tag('div', $status) . content_tag('div', $selector, $options);
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage());
}
}
示例2: lang_anchor
function lang_anchor($controller = '', $method = FALSE, $params = FALSE, $title = FALSE, $attributes = FALSE)
{
$title = (string) $title;
$CI =& get_instance();
$lng = $CI->config->item('language');
$base_url = $CI->config->item('base_url') . "/";
$site_url = $base_url;
if ($controller) {
$trans_controller = get_class_name_controller_from_translation($controller, $lng);
$site_url .= $trans_controller . "/";
}
if ($method) {
$trans_method = get_method_name_from_translation($trans_controller, $method, $lng);
$site_url .= $trans_method . "/";
}
if ($params) {
$site_url .= $params . "/";
}
if ($title == '') {
$title = $site_url;
}
if ($attributes != '') {
$attributes = _parse_attributes($attributes);
}
return '<a href="' . $site_url . '"' . $attributes . '>' . $title . '</a>';
}
示例3: link_to
/**
* Creates a <a> link tag of the given name using a routed URL
* based on the module/action passed as argument and the routing configuration.
*
* If null is passed as a name, the link itself will become the name.
*
* Examples:
* echo link_to('Homepage', 'default/index')
* => <a href="/">Homepage</a>
*
* echo link_to('News 2008/11', 'news/index?year=2008&month=11')
* => <a href="/news/2008/11">News 2008/11</a>
*
* echo link_to('News 2008/11 [absolute url]', 'news/index?year=2008&month=11', array('absolute'=>true))
* => <a href="http://myapp.example.com/news/2008/11">News 2008/11 [absolute url]</a>
*
* echo link_to('Absolute url', 'http://www.google.com')
* => <a href="http://www.google.com">Absolute url</a>
*
* echo link_to('Link with attributes', 'default/index', array('id'=>'my_link', 'class'=>'green-arrow'))
* => <a id="my_link" class="green-arrow" href="/">Link with attributes</a>
*
* echo link_to('<img src="x.gif" width="150" height="100" alt="[link with image]" />', 'default/index' )
* => <a href="/"><img src="x.gif" width="150" height="100" alt="[link with image]" /></a>
*
*
* Options:
* 'absolute' - if set to true, the helper outputs an absolute URL
* 'query_string' - to append a query string (starting by ?) to the routed url
* 'anchor' - to append an anchor (starting by #) to the routed url
*
* @param string text appearing between the <a> tags
* @param string 'module/action' or '@rule' of the action, or an absolute url
* @param array additional HTML compliant <a> tag parameters
* @return string XHTML compliant <a href> tag
* @see url_for
*/
function link_to($name = '', $internal_uri = '', $options = array())
{
$html_options = _parse_attributes($options);
$absolute = false;
if (isset($html_options['absolute'])) {
$absolute = (bool) $html_options['absolute'];
unset($html_options['absolute']);
}
// Fabrice: FIXME (genUrl() doesnt like '#anchor' ?) => ignore empty string
$html_options['href'] = $internal_uri !== '' ? url_for($internal_uri, $absolute) : '';
// anchor
if (isset($html_options['anchor'])) {
$html_options['href'] .= '#' . $html_options['anchor'];
unset($html_options['anchor']);
}
if (isset($html_options['query_string'])) {
$html_options['href'] .= '?' . $html_options['query_string'];
unset($html_options['query_string']);
}
if (is_object($name)) {
if (method_exists($name, '__toString')) {
$name = $name->__toString();
} else {
DBG::error(sprintf('Object of class "%s" cannot be converted to string (Please create a __toString() method).', get_class($name)));
}
}
if (!strlen($name)) {
$name = $html_options['href'];
}
return content_tag('a', $name, $html_options);
}
示例4: form_error
function form_error($param, $options = array(), $catalogue = 'messages')
{
$param_for_sf = str_replace(array('[', ']'), array('{', '}'), $param);
$param = str_replace(array('{', '}'), array('[', ']'), $param);
$options = _parse_attributes($options);
$request = sfContext::getInstance()->getRequest();
$style = $request->hasError($param_for_sf) ? '' : 'display:none;';
$options['style'] = $style . (isset($options['style']) ? $options['style'] : '');
if (!isset($options['class'])) {
$options['class'] = sfConfig::get('sf_validation_error_class', 'form_error');
}
if (!isset($options['id'])) {
$options['id'] = sfConfig::get('sf_validation_error_id_prefix', 'error_for_') . get_id_from_name($param);
}
$prefix = sfConfig::get('sf_validation_error_prefix', '');
if (isset($options['prefix'])) {
$prefix = $options['prefix'];
unset($options['prefix']);
}
$suffix = sfConfig::get('sf_validation_error_suffix', '');
if (isset($options['suffix'])) {
$suffix = $options['suffix'];
unset($options['suffix']);
}
$error = $request->getError($param_for_sf, $catalogue);
return content_tag('div', $prefix . $error . $suffix, $options) . "\n";
}
示例5: image_tag
function image_tag($source, $options = array())
{
if (!$source) {
return '';
}
$options = _parse_attributes($options);
$absolute = false;
if (isset($options['absolute'])) {
unset($options['absolute']);
$absolute = true;
}
$options['src'] = system_url($source);
if (!isset($options['alt'])) {
$path_pos = strrpos($source, '/');
$dot_pos = strrpos($source, '.');
$begin = $path_pos ? $path_pos + 1 : 0;
$nb_str = ($dot_pos ? $dot_pos : strlen($source)) - $begin;
$options['alt'] = ucfirst(substr($source, $begin, $nb_str));
}
if (isset($options['size'])) {
list($options['width'], $options['height']) = split('x', $options['size'], 2);
unset($options['size']);
}
return tag('img', $options);
}
示例6: depp_prioritiser
/**
* Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
* If the user has already voted, then a message appears
*
* @param BaseObject $object Propel object instance to vote
* @param string $message a message string to be displayed in the voting-message block
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_prioritiser($object, $message = '', $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be prioritised');
return '';
}
$user_id = sfContext::getInstance()->getUser()->getId();
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'prioritising-items'));
}
$object_id = $object->getPrioritisableReferenceKey();
$list_content = '';
$object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue();
for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) {
if ($object_priority == $i) {
if ($object->getPriorityLastUser() != 0) {
$label = sprintf('Priorità impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i'));
} else {
$label = 'Priorità di default';
}
$list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current'));
} else {
$label = sprintf(__('Set priority to %d'), $i);
$list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true)));
}
}
return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message'));
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage());
}
}
示例7: gbox
/**
* Returns a link with a gBox widget attached
*
* @param string $content content to show inside the a tag
* @param string $href url (inline/ajax) to show in the gbox
* @param array $options Options of the link
*
* @author Gerald Estadieu <gestadieu@gmail.com>
* @since 15 Apr 2007
*
*/
function gbox($content, $href = '', $options = array())
{
_loadRessources();
$html_options = _parse_attributes($options);
$html_options['class'] = isset($options['class']) ? $options['class'] . ' gbox' : 'gbox';
return link_to($content, $href, $html_options);
}
示例8: adv_options_for_select
/**
* Override of the standard options_for_select, that allows the usage of the 'include_zero_custom' option
* to insert a custom field returning the 0 value on top of the options
*
* @return String
* @author Guglielmo Celata
**/
function adv_options_for_select($options = array(), $selected = '', $html_options = array())
{
$html_options = _parse_attributes($html_options);
if (is_array($selected)) {
$selected = array_map('strval', array_values($selected));
}
$html = '';
if ($value = _get_option($html_options, 'include_zero_custom')) {
$html .= content_tag('option', $value, array('value' => '0')) . "\n";
} else {
if ($value = _get_option($html_options, 'include_custom')) {
$html .= content_tag('option', $value, array('value' => '')) . "\n";
} else {
if (_get_option($html_options, 'include_blank')) {
$html .= content_tag('option', '', array('value' => '')) . "\n";
}
}
}
foreach ($options as $key => $value) {
if (is_array($value)) {
$html .= content_tag('optgroup', options_for_select($value, $selected, $html_options), array('label' => $key)) . "\n";
} else {
$option_options = array('value' => $key);
if (is_array($selected) && in_array(strval($key), $selected, true) || strval($key) == strval($selected)) {
$option_options['selected'] = 'selected';
}
$html .= content_tag('option', $value, $option_options) . "\n";
}
}
return $html;
}
示例9: double_list
/**
* two multiline select tags with associated and unassociated items
*
* @return string
* @param object object
* @param string method of object
* @param array options
* @param array html options of select tags
**/
function double_list($object, $method, $options = array(), $html_options = array())
{
$options = _parse_attributes($options);
// get the lists of objects
list($all_objects, $objects_associated, $associated_ids) = _get_object_list($object, $method, _get_option($options, 'through_class'), _get_option($options, 'peer_method'));
// options
$html_options['multiple'] = _get_option($html_options, 'multiple', true);
$html_options['size'] = _get_option($html_options, 'size', 5);
$html_options['class'] = 'double_list';
$label_assoc = _get_option($options, 'associated_label', 'Zugeh�rige Gruppen');
$label_all = _get_option($options, 'unassociated_label', 'Gruppenliste');
$name1 = _get_option($options, 'associated', 'isSelected');
$name2 = _get_option($options, 'unassociated', 'unSelected');
$form = _get_option($options, 'form_id', 'editForm');
// unassociated objects
$objects_unassociated = array();
foreach ($all_objects as $object) {
if (!in_array($object->getPrimaryKey(), $associated_ids)) {
$objects_unassociated[] = $object;
}
}
// select tags
$select1 = select_tag($name1, options_for_select(_get_options_from_objects($objects_associated), '', $options), $html_options);
unset($html_options['class']);
$select2 = select_tag($name2, options_for_select(_get_options_from_objects($objects_unassociated), '', $options), $html_options);
// output skeloton
$html = "\n<table><tr>\n\t<td class='first'><div class='first' style='padding-bottom:0px;padding-left:15px;'>{$label_assoc}</div>%s</td>\n\t<td class='first'><div class='first' style='padding-bottom:0px;padding-left:15px;'> </div>%s<br/>%s</td>\n\t<td class='first'><div class='first' style='padding-bottom:0px;padding-left:15px;'>{$label_all}</div>%s</td>\n</tr></table>\n";
// include js library
$response = sfContext::getInstance()->getResponse();
$response->addJavascript('/js/double_list.js', 'last');
return sprintf($html, $select1, link_to_function(image_tag('resultset_previous'), "double_list_move(\$('{$name2}'), \$('{$name1}'))"), link_to_function(image_tag('resultset_next'), "double_list_move(\$('{$name1}'), \$('{$name2}'))", 'style=display:block'), $select2, $form);
}
示例10: anchor
function anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
$id = '';
if (strpos($uri, '#')) {
$uri_part = explode('#', $uri);
$uri = $uri_part[0];
$id = '#' . $uri_part[1];
}
if ($uri == '/') {
$site_url = base_url();
} elseif (!is_array($uri)) {
$site_url = !preg_match('!^\\w+://! i', $uri) ? site_url($uri) : $uri;
} else {
$site_url = site_url($uri);
}
if (!isset($attributes['title'])) {
$attributes['title'] = strip_tags($title);
}
if ($title == '') {
$title = $site_url;
}
if ($attributes != '') {
$attributes = _parse_attributes($attributes);
}
return '<a href="' . $site_url . $id . '"' . $attributes . '>' . $title . '</a>';
}
示例11: anchor
function anchor($uri = '', $title = '', $attributes = '', $ssl = FALSE)
{
$title = (string) $title;
if (!is_array($uri)) {
if ($ssl) {
$site_url = !preg_match('!^\\w+://!i', $uri) ? site_url($uri, TRUE) : $uri;
} else {
$site_url = !preg_match('!^\\w+://!i', $uri) ? site_url($uri) : $uri;
}
} else {
if ($ssl) {
$site_url = site_url($uri, TRUE);
} else {
$site_url = site_url($uri);
}
}
if ($title == '') {
$title = $site_url;
}
if ($attributes == '') {
$attributes = ' title="' . $title . '"';
} else {
$attributes = _parse_attributes($attributes);
}
return '<a href="' . $site_url . '"' . $attributes . '>' . $title . '</a>';
}
示例12: _parseSyntaxes
/**
* Searches through the content and extracts out any matches. The return
* value is a formatted array of what needs to be replaced
*
* Returned syntax will look like this:
* array(
* 'link' => array(
* 3 => array('options' => array(), 'replace' => '[link:3]'),
* 5 => array('options' => array('option' => 'value'), 'replace' => '[link:5 option=value]'),
* ), asset => array(
* 10 => array('options' => array(), 'replace' => '[asset:10]'),
* ),
* )
*
* @return array
*/
private function _parseSyntaxes($content)
{
// create the replacement string (e.g. link|asset|myObject)
$replacementString = implode('|', array_keys(sfSympalConfig::get('content_syntax_types')));
preg_match_all("/\\[({$replacementString}):(.*?)\\]/", $content, $matches);
if (isset($matches[0]) && $matches[0]) {
$replacements = array();
$types = $matches[1];
$bodies = $matches[2];
foreach ($types as $type) {
$replacements[$type] = array();
}
/*
* body matches (e.g. "3" or "5 option=value")
*/
foreach ($bodies as $key => $body) {
// use the key to find the corresponding type
$typeKey = $types[$key];
$e = explode(' ', $body);
$slug = $e[0];
$replacements[$typeKey][$slug] = array('options' => _parse_attributes(substr($body, strlen($e[0]))), 'replace' => $matches[0][$key]);
}
return $replacements;
} else {
return false;
}
}
示例13: link_to_star
function link_to_star($object, $options = array())
{
$user = sfContext::getInstance()->getUser();
if ($user->isAuthenticated()) {
$response = sfContext::getInstance()->getResponse();
$has_jquery = sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_has_jquery');
if (!$has_jquery) {
$response->addJavascript('/sfPropelActAsStarredBehaviorPlugin/js/jquery-1.2.2.pack');
}
$response->addJavascript('/sfPropelActAsStarredBehaviorPlugin/js/sf_star');
$is_starred = $object->isStarred() ? 'sf_star_on' : 'sf_star_off';
$options = _parse_attributes($options);
if (isset($options['class'])) {
$options['class'] .= ' sf_star ' . $is_starred;
} else {
$options['class'] = 'sf_star ' . $is_starred;
}
$type = sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_type', null);
if (!$type || $type == 'image') {
$content = $object->isStarred() ? image_tag(sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_image_on', '/sfPropelActAsStarredBehaviorPlugin/images/star_on.gif')) : image_tag(sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_image_off', '/sfPropelActAsStarredBehaviorPlugin/images/star_off.gif'));
} elseif (isset($options['txt_on']) && isset($options['txt_off'])) {
$content = $object->isStarred() ? $options['txt_off'] : $options['txt_on'];
} else {
$content = $object->isStarred() ? sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_on') : sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_off');
}
$model = get_class($object);
$id = $object->getPrimaryKey();
return link_to($content, 'sfStar/starit?model=' . $model . '&id=' . $id, $options);
// return content_tag('span',link_to($image,'sfStar/starit?model='.$model.'&id='.$id,'class=sf_star'));
} else {
return content_tag('span', '');
}
}
示例14: object_input_sf_asset_tag
function object_input_sf_asset_tag($object, $method, $options = array())
{
$options = _parse_attributes($options);
$name = _convert_method_to_name($method, $options);
$value = _get_object_value($object, $method);
return input_sf_asset_tag($name, $value, $options);
}
示例15: depp_launcher
/**
* Return the HTML code for the launch/remove link
* plus the list of launched object for the namespace
*
* @param BaseObject $object Propel object instance to launch
* @param string $namespace The namespace where the object is *launched*
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_launcher($object, $namespace, $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be launched');
return '';
}
if (is_null($namespace)) {
sfLogger::getInstance()->debug('A namespace must be given');
return '';
}
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'launching-items'));
}
if (!isset($options['class'])) {
$options = array_merge($options, array('class' => 'vote-administration'));
}
$object_model = get_class($object);
$object_id = $object->getPrimaryKey();
// build launch/remove link
if (in_array($namespace, $object->hasBeenLaunched())) {
$action_link = link_to(__('Take the launch back'), sprintf('deppLaunching/remove?item_model=%s&item_pk=%s&namespace=%s', $object_model, $object_id, $namespace));
} else {
$action_link = link_to(__('Launch the object'), sprintf('deppLaunching/launch?item_model=%s&item_pk=%s&namespace=%s', $object_model, $object_id, $namespace));
}
$action = content_tag('div', $action_link);
$list_content = '';
$launches = sfLaunchingPeer::getAllByNamespace($namespace);
foreach ($launches as $i => $l) {
$l_obj_model = $l->getObjectModel();
$l_obj_id = $l->getObjectId();
$l_obj = deppPropelActAsLaunchableToolkit::retrieveLaunchableObject($l_obj_model, $l_obj_id);
$l_obj_short_string = $l_obj->getShortTitle();
$l_obj_remove_action = sprintf('deppLaunching/remove?item_model=%s&item_pk=%s&namespace=%s', $l_obj_model, $l_obj_id, $namespace);
$l_obj_priority_up_action = sprintf('deppLaunching/priorityUp?item_model=%s&item_pk=%s&namespace=%s', $l_obj_model, $l_obj_id, $namespace);
$l_obj_priority_dn_action = sprintf('deppLaunching/priorityDn?item_model=%s&item_pk=%s&namespace=%s', $l_obj_model, $l_obj_id, $namespace);
$l_obj_remove_link = link_to('<img src="/images/ico-remove_alert.png" alt="X" title="Rimuovi" />', $l_obj_remove_action, array('title' => __('Take the launch back'), 'class' => 'remove-vote'));
$l_obj_priority_up_link = link_to('<img src="/images/ico-thumb-up.png" alt="+" title="Aumenta priorità" />', $l_obj_priority_up_action, array('title' => __('Increase the priority'), 'class' => 'moveup-vote'));
$l_obj_priority_dn_link = link_to('<img src="/images/ico-thumb-down.png" alt="-" title="Diminuisci priorità" />', $l_obj_priority_dn_action, array('title' => __('Decrease the priority'), 'class' => 'movedown-vote'));
$l_obj_actions = "";
/*if ($i > 0)*/
$l_obj_actions .= " {$l_obj_priority_up_link} ";
/*if ($i < count($launches) - 1 )*/
$l_obj_actions .= " {$l_obj_priority_dn_link} ";
$l_obj_actions .= " {$l_obj_remove_link} ";
/*$list_content .= content_tag('tr',
content_tag('td', '<input type="text" value="'. $l->getPriority().'" name="priority['. $l_obj_id.']" size="3">'. $l_obj_short_string) .
content_tag('td', $l_obj_actions, array('style' => 'text-align:right; width:36px;display:inline-block;')));*/
$list_content .= content_tag('li', content_tag('span', $l_obj_actions, array('style' => 'text-align:right; width:36px;display:inline-block;float:right;')) . $l_obj_short_string, array('style' => 'cursor:move; border-bottom: 1px dotted #CCC;'));
}
$list = content_tag('ul', $list_content, $options);
// adding javascript for drag and drop
//use_javascript('/js/jquery-ui-1.8.16.sortable.min.js');
return $action . $list;
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppLaunching helper: ' . $e->getMessage());
}
}