本文整理匯總了PHP中Inflector::variablize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::variablize方法的具體用法?PHP Inflector::variablize怎麽用?PHP Inflector::variablize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::variablize方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: googleMap
public function googleMap($divId = 'map', $options = array(), $attrs = array(), $center = array())
{
if (!$center) {
$center = array('latitude' => (double) get_option('geolocation_default_latitude'), 'longitude' => (double) get_option('geolocation_default_longitude'), 'zoomLevel' => (double) get_option('geolocation_default_zoom_level'));
}
if (!array_key_exists('params', $options)) {
$options['params'] = array();
}
if (!array_key_exists('uri', $options)) {
// This should not be a link to the public side b/c then all the URLs that
// are generated inside the KML will also link to the public side.
$options['uri'] = url('geolocation/map.kml');
}
if (!array_key_exists('mapType', $options)) {
$options['mapType'] = get_option('geolocation_map_type');
}
if (!array_key_exists('fitMarkers', $options)) {
$options['fitMarkers'] = (bool) get_option('geolocation_auto_fit_browse');
}
$class = 'map geolocation-map';
if (isset($attrs['class'])) {
$class .= ' ' . $attrs['class'];
}
$options = js_escape($options);
$center = js_escape($center);
$varDivId = Inflector::variablize($divId);
$divAttrs = array_merge($attrs, array('id' => $divId, 'class' => $class));
$html = '<div ' . tag_attributes($divAttrs) . '></div>';
$js = "var {$varDivId}" . "OmekaMapBrowse = new OmekaMapBrowse(" . js_escape($divId) . ", {$center}, {$options}); ";
$html .= "<script type='text/javascript'>{$js}</script>";
return $html;
}
示例2: itemGoogleMap
public function itemGoogleMap($item = null, $width = '200px', $height = '200px', $hasBalloonForMarker = false, $markerHtmlClassName = 'geolocation_balloon')
{
$divId = "item-map-{$item->id}";
$location = get_db()->getTable('Location')->findLocationByItem($item, true);
// Only set the center of the map if this item actually has a location
// associated with it
if ($location) {
$center['latitude'] = $location->latitude;
$center['longitude'] = $location->longitude;
$center['zoomLevel'] = $location->zoom_level;
$center['show'] = true;
if ($hasBalloonForMarker) {
$titleLink = link_to_item(metadata($item, array('Dublin Core', 'Title'), array(), $item), array(), 'show', $item);
$thumbnailLink = !item_image('thumbnail') ? '' : link_to_item(item_image('thumbnail', array(), 0, $item), array(), 'show', $item);
$description = metadata($item, array('Dublin Core', 'Description'), array('snippet' => 150), $item);
$center['markerHtml'] = '<div class="' . $markerHtmlClassName . '">' . '<div class="geolocation_balloon_title">' . $titleLink . '</div>' . '<div class="geolocation_balloon_thumbnail">' . $thumbnailLink . '</div>' . '<p class="geolocation_balloon_description">' . $description . '</p></div>';
}
$options = array();
$options['mapType'] = get_option('geolocation_map_type');
$center = js_escape($center);
$options = js_escape($options);
$style = "width: {$width}; height: {$height}";
$html = '<div id="' . $divId . '" class="map geolocation-map" style="' . $style . '"></div>';
$js = "var " . Inflector::variablize($divId) . ";";
$js .= "OmekaMapSingle = new OmekaMapSingle(" . js_escape($divId) . ", {$center}, {$options}); ";
$html .= "<script type='text/javascript'>{$js}</script>";
} else {
$html = '<p class="map-notification">' . __('This item has no location info associated with it.') . '</p>';
}
return $html;
}
示例3: addHooksAndFilters
/**
* Iterate over hooks and filters, define callbacks.
*
* @return void
*/
public function addHooksAndFilters()
{
foreach (self::$_hooks as $hookName) {
$functionName = Inflector::variablize($hookName);
add_plugin_hook($hookName, array($this, $functionName));
}
foreach (self::$_filters as $filterName) {
$functionName = Inflector::variablize($filterName);
add_filter($filterName, array($this, $functionName));
}
}
示例4: __construct
public function __construct(Bbx_Model $parentModel, $childName, array $attributes)
{
$this->_childName = $childName;
extract($attributes);
$this->_parentTableName = $parentModel->getTable()->info('name');
$this->_parentModelName = get_class($parentModel);
$this->_type = Inflector::variablize(substr(get_class($this), 22));
if (isset($select)) {
$this->_originalSelect = $select;
$this->_select = $select;
}
if (isset($polymorphic)) {
// belongsTo only
$this->_polymorphic = true;
$this->_polymorphicKey = Inflector::singularize($childName) . '_id';
$this->_polymorphicType = Inflector::singularize($childName) . '_type';
$this->_childModelName = Inflector::classify($parentModel->{$this->_polymorphicType});
} else {
// could do this out of registry
$this->_childName = isset($source) ? $source : $childName;
$this->_childModelName = Inflector::classify($this->_childName);
}
$this->_childTableName = Bbx_Model::load($this->_childModelName)->getTableName();
if (isset($through)) {
$this->_throughName = $through;
$this->_throughModelName = Inflector::classify($through);
$this->_throughModel = Bbx_Model::load($this->_throughModelName, true);
$this->_throughTableName = $this->_throughModel->getTableName();
}
if (isset($as)) {
// hasMany(Through) only
$this->_polymorphic = true;
$this->_polymorphicKey = $as . '_id';
$this->_polymorphicType = $as . '_type';
$polymorphicTable = isset($this->_throughTableName) ? $this->_throughTableName : $this->_childTableName;
$this->_parentRefColumn = $as . '_id';
$type = Inflector::singularize(Inflector::underscore($this->_parentTableName));
$typeSelect = array('where' => array("`" . $polymorphicTable . "`.`" . $as . "_type` = '" . $type . "'"));
$this->_originalSelect = array_merge_recursive((array) $this->_originalSelect, $typeSelect);
} else {
$this->_parentRefColumn = Inflector::singularize($this->_parentTableName) . '_id';
}
$this->_models[$this->_childModelName] = Bbx_Model::load($this->_childModelName);
$this->_originalSelect = $this->_mergeSelects($this->_convertForSelect($this->_models[$this->_childModelName]->getDefaultParams()), $this->_originalSelect);
$this->_select = $this->_originalSelect;
}
示例5: url
if ($harvest) {
?>
<div class="harvest-status">
<?php
if (empty($asText)) {
?>
<a href="<?php
echo url("oaipmh-harvester/index/status?harvest_id={$harvest->id}");
?>
"><?php
echo html_escape(ucwords($harvest->status));
?>
</a>
<?php
} else {
?>
<span class="status <?php
echo $harvest->status == OaipmhHarvester_Harvest::STATUS_IN_PROGRESS ? 'progress' : Inflector::variablize($harvest->status);
?>
">
<?php
echo html_escape(__(ucwords($harvest->status)));
?>
</span>
<?php
}
?>
</div>
<?php
}
示例6: dispatchRequest
/**
* Parses the HTTP query and dispatches to the correct verb handler.
*
* Checks arguments for each verb type, and sets XML request tag.
*
* @uses checkArguments()
*/
private function dispatchRequest()
{
$request = $this->document->createElement('request', OAI_PMH_BASE_URL);
$this->document->documentElement->appendChild($request);
$requiredArgs = array();
$optionalArgs = array();
if (!($verb = $this->_getParam('verb'))) {
$this->throwError(self::OAI_ERR_BAD_VERB, 'No verb specified.');
return;
}
$resumptionToken = $this->_getParam('resumptionToken');
if ($resumptionToken) {
$requiredArgs = array('resumptionToken');
} else {
switch ($this->query['verb']) {
case 'Identify':
break;
case 'GetRecord':
$requiredArgs = array('identifier', 'metadataPrefix');
break;
case 'ListRecords':
$requiredArgs = array('metadataPrefix');
$optionalArgs = array('from', 'until', 'set');
break;
case 'ListIdentifiers':
$requiredArgs = array('metadataPrefix');
$optionalArgs = array('from', 'until', 'set');
break;
case 'ListSets':
break;
case 'ListMetadataFormats':
$optionalArgs = array('identifier');
break;
default:
$this->throwError(self::OAI_ERR_BAD_VERB);
}
}
$this->checkArguments($requiredArgs, $optionalArgs);
if (!$this->error) {
foreach ($this->query as $key => $value) {
$request->setAttribute($key, $value);
}
if ($resumptionToken) {
$this->resumeListResponse($resumptionToken);
} else {
if ($verb == 'ListRecords' || $verb == 'ListIdentifiers') {
$this->initListResponse();
} else {
/* This Inflector use means verb-implementing functions must be
the lowerCamelCased version of the verb name. */
$functionName = Inflector::variablize($verb);
$this->{$functionName}();
}
}
}
}
示例7: switch
<?php
if ($folder) {
?>
<div class="folder-status">
<span class="status <?php
echo Inflector::variablize($folder->status);
?>
">
<?php
switch ($folder->status) {
case OaiPmhStaticRepository::STATUS_ADDED:
$status = __('Folder added');
break;
case OaiPmhStaticRepository::STATUS_RESET:
$status = __('Status reset');
break;
case OaiPmhStaticRepository::STATUS_QUEUED:
$status = __('Process queued');
break;
case OaiPmhStaticRepository::STATUS_PROGRESS:
$status = __('Process in progress');
break;
case OaiPmhStaticRepository::STATUS_PAUSED:
$status = __('Process paused');
break;
case OaiPmhStaticRepository::STATUS_STOPPED:
$status = __('Process stopped');
break;
case OaiPmhStaticRepository::STATUS_KILLED:
$status = __('Process killed');
示例8: geolocation_google_map_for_item
/**
* Returns the google map code for an item
* @param Item $item
* @param int $width
* @param int $height
* @param boolean $hasBalloonForMarker
* @return string
**/
function geolocation_google_map_for_item($item = null, $width = '200px', $height = '200px', $hasBalloonForMarker = true, $markerHtmlClassName = 'geolocation_balloon')
{
if (!$item) {
$item = get_current_item();
}
$ht = '';
$divId = "item-map-{$item->id}";
ob_start();
if ($hasBalloonForMarker) {
echo geolocation_marker_style();
}
?>
<style type="text/css" media="screen">
/* The map for the items page needs a bit of styling on it */
#address_balloon dt {
font-weight: bold;
}
#address_balloon {
width: 100px;
}
</style>
<?php
$location = geolocation_get_location_for_item($item, true);
// Only set the center of the map if this item actually has a location
// associated with it
if ($location) {
$center['latitude'] = $location->latitude;
$center['longitude'] = $location->longitude;
$center['zoomLevel'] = $location->zoom_level;
$center['show'] = true;
if ($hasBalloonForMarker) {
$center['markerHtml'] = geolocation_get_marker_html_for_item($item, $markerHtmlClassName);
}
$center = js_escape($center);
$options = js_escape($options);
?>
<div id="<?php
echo $divId;
?>
" style="width:<?php
echo $width;
?>
; height:<?php
echo $height;
?>
;" class="map"></div>
<script type="text/javascript">
//<![CDATA[
var <?php
echo Inflector::variablize($divId);
?>
OmekaMapSingle = new OmekaMapSingle(<?php
echo js_escape($divId);
?>
, <?php
echo $center;
?>
, <?php
echo $options;
?>
);
//]]>
</script>
<?php
} else {
?>
<p class="map-notification">This item has no location info associated with it.</p>
<?php
}
$ht .= ob_get_contents();
ob_end_clean();
return $ht;
}
示例9: _writeProcessAndSpecific
protected function _writeProcessAndSpecific($record)
{
$writer = $this->_writer;
// Process data are not written, except the name, the record type and
// the action.
$attributes = array();
foreach ($record['process'] as $key => $value) {
if (in_array($key, array('name', 'record type', 'action'))) {
$attributes[$key] = $value;
}
}
// The union keeps the former values.
$attributes += $record['specific'];
if (empty($attributes)) {
return;
}
foreach ($attributes as $key => $value) {
// Manage exceptions.
// TODO Avoid these exceptions.
// Exception for the file path.
if ($key == 'path' && $record['process']['record type'] == 'File') {
$key = 'file';
// The full path is checked, fully formatted and encoded.
$value = $record['process']['fullpath'];
} elseif ($key == 'item_type_name' && $record['process']['record type'] == 'Item') {
$key = 'itemType';
} else {
$key = Inflector::variablize($key);
}
// Normally, only for tags, but they are now moved into extra.
if (is_array($value)) {
$value = implode(',', $value);
}
$writer->writeAttribute($key, $value);
}
}