本文整理汇总了PHP中F0FInflector::implode方法的典型用法代码示例。如果您正苦于以下问题:PHP F0FInflector::implode方法的具体用法?PHP F0FInflector::implode怎么用?PHP F0FInflector::implode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F0FInflector
的用法示例。
在下文中一共展示了F0FInflector::implode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*/
protected function getOptions()
{
$options = array();
// Initialize some field attributes.
$key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
$value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
$applyAccess = $this->element['apply_access'] ? (string) $this->element['apply_access'] : 'false';
$modelName = (string) $this->element['model'];
$nonePlaceholder = (string) $this->element['none'];
$translate = empty($this->element['translate']) ? 'true' : (string) $this->element['translate'];
$translate = in_array(strtolower($translate), array('true', 'yes', '1', 'on')) ? true : false;
if (!empty($nonePlaceholder)) {
$options[] = JHtml::_('select.option', null, JText::_($nonePlaceholder));
}
// Process field atrtibutes
$applyAccess = strtolower($applyAccess);
$applyAccess = in_array($applyAccess, array('yes', 'on', 'true', '1'));
// Explode model name into model name and prefix
$parts = F0FInflector::explode($modelName);
$mName = ucfirst(array_pop($parts));
$mPrefix = F0FInflector::implode($parts);
// Get the model object
$config = array('savestate' => 0);
$model = F0FModel::getTmpInstance($mName, $mPrefix, $config);
if ($applyAccess) {
$model->applyAccessFiltering();
}
// Process state variables
foreach ($this->element->children() as $stateoption) {
// Only add <option /> elements.
if ($stateoption->getName() != 'state') {
continue;
}
$stateKey = (string) $stateoption['key'];
$stateValue = (string) $stateoption;
$model->setState($stateKey, $stateValue);
}
// Set the query and get the result list.
$items = $model->getItemList(true);
// Build the field options.
if (!empty($items)) {
foreach ($items as $item) {
if ($translate == true) {
$options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
} else {
$options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例2: getThisView
/**
* Returns current view object
*
* @param array $config Configuration variables for the model
*
* @return F0FView The global instance of the view object (singleton)
*/
public final function getThisView($config = array())
{
if (!is_object($this->_viewObject)) {
// Make sure $config is an array
if (is_object($config)) {
$config = (array) $config;
} elseif (!is_array($config) || empty($config)) {
// array_merge is required to create a copy instead of assigning by reference
$config = array_merge($this->config);
}
$prefix = null;
$viewName = null;
$viewType = null;
if (!empty($this->viewName)) {
$parts = F0FInflector::explode($this->viewName);
$viewName = ucfirst(array_pop($parts));
$prefix = F0FInflector::implode($parts);
} else {
$prefix = ucfirst($this->bareComponent) . 'View';
$viewName = ucfirst($this->view);
}
$document = F0FPlatform::getInstance()->getDocument();
if ($document instanceof JDocument) {
$viewType = $document->getType();
} else {
$viewType = $this->input->getCmd('format', 'html');
}
if ($viewType == 'html' && $this->hasForm) {
$viewType = 'form';
}
if (!array_key_exists('input', $config) || !$config['input'] instanceof F0FInput) {
$config['input'] = $this->input;
}
$config['input']->set('base_path', $this->basePath);
$this->_viewObject = $this->getView($viewName, $viewType, $prefix, $config);
}
return $this->_viewObject;
}
示例3: normaliseItemName
/**
* Normalises the format of a relation name
*
* @param string $itemName The raw relation name
* @param boolean $pluralise Should I pluralise the name? If not, I will singularise it
*
* @return string The normalised relation key name
*/
protected function normaliseItemName($itemName, $pluralise = false)
{
// Explode the item name
$itemNameParts = explode('_', $itemName);
// If we have multiple parts the first part is considered to be the component name
if (count($itemNameParts) > 1) {
$prefix = array_shift($itemNameParts);
} else {
$prefix = null;
}
// If we still have multiple parts we need to pluralise/singularise the last part and join everything in
// CamelCase format
if (count($itemNameParts) > 1) {
$name = array_pop($itemNameParts);
$name = $pluralise ? F0FInflector::pluralize($name) : F0FInflector::singularize($name);
$itemNameParts[] = $name;
$itemName = F0FInflector::implode($itemNameParts);
} else {
$name = array_pop($itemNameParts);
$itemName = $pluralise ? F0FInflector::pluralize($name) : F0FInflector::singularize($name);
}
if (!empty($prefix)) {
$itemName = $prefix . '_' . $itemName;
}
return $itemName;
}