本文整理汇总了PHP中FOFInflector::explode方法的典型用法代码示例。如果您正苦于以下问题:PHP FOFInflector::explode方法的具体用法?PHP FOFInflector::explode怎么用?PHP FOFInflector::explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOFInflector
的用法示例。
在下文中一共展示了FOFInflector::explode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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', JText::_($nonePlaceholder), null);
}
// Process field atrtibutes
$applyAccess = strtolower($applyAccess);
$applyAccess = in_array($applyAccess, array('yes', 'on', 'true', '1'));
// Explode model name into model name and prefix
$parts = FOFInflector::explode($modelName);
$mName = ucfirst(array_pop($parts));
$mPrefix = FOFInflector::implode($parts);
// Get the model object
$config = array('savestate' => 0);
$model = FOFModel::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: __construct
/**
* Database iterator constructor.
*
* @param mixed $cursor The database cursor.
* @param string $column An option column to use as the iterator key.
* @param string $class The table class of the returned objects.
* @param array $config Configuration parameters to push to the table class
*
* @throws InvalidArgumentException
*/
public function __construct($cursor, $column = null, $class, $config = array())
{
// Figure out the type and prefix of the class by the class name
$parts = FOFInflector::explode($class);
if (count($parts) != 3) {
throw new InvalidArgumentException('Invalid table name, expected a pattern like ComponentTableFoobar got ' . $class);
}
$this->_tableObject = FOFTable::getInstance($parts[2], ucfirst($parts[0]) . ucfirst($parts[1]))->getClone();
$this->cursor = $cursor;
$this->class = 'stdClass';
$this->_column = $column;
$this->_fetched = 0;
$this->next();
}
示例3: normaliseParameters
/**
* Normalise the parameters of a relation, guessing missing values
*
* @param boolean $pivot Is this a many to many relation involving a pivot table?
* @param string $itemName is how it will be known locally to the getRelatedItems method (plural)
* @param string $tableClass if skipped it is defined automatically as ComponentnameTableItemname
* @param string $localKey is the column containing our side of the FK relation, default: componentname_itemname_id
* @param string $remoteKey is the remote table's FK column, default: componentname_itemname_id
* @param string $ourPivotKey is the column containing our side of the FK relation in the pivot table, default: $localKey
* @param string $theirPivotKey is the column containing the other table's side of the FK relation in the pivot table, default $remoteKey
* @param string $pivotTable is the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles)
*
* @return void
*/
protected function normaliseParameters($pivot = false, &$itemName, &$tableClass, &$localKey, &$remoteKey, &$ourPivotKey, &$theirPivotKey, &$pivotTable)
{
// Get a default table class if none is provided
if (empty($tableClass)) {
$tableClassParts = explode('_', $itemName, 3);
if (count($tableClassParts) == 1) {
array_unshift($tableClassParts, $this->componentName);
}
if ($tableClassParts[0] == 'joomla') {
$tableClassParts[0] = 'J';
}
$tableClass = ucfirst($tableClassParts[0]) . 'Table' . ucfirst(FOFInflector::singularize($tableClassParts[1]));
}
// Make sure we have both a local and remote key
if (empty($localKey) && empty($remoteKey)) {
// WARNING! If we have a pivot table, this behavior is wrong!
// Infact if we have `parts` and `groups` the local key should be foobar_part_id and the remote one foobar_group_id.
// However, this isn't a real issue because:
// 1. we have no way to detect the local key of a multiple relation
// 2. this scenario never happens, since, in this class, if we're adding a multiple relation we always supply the local key
$tableClassParts = FOFInflector::explode($tableClass);
$localKey = $tableClassParts[0] . '_' . $tableClassParts[2] . '_id';
$remoteKey = $localKey;
} elseif (empty($localKey) && !empty($remoteKey)) {
$localKey = $remoteKey;
} elseif (!empty($localKey) && empty($remoteKey)) {
if ($pivot) {
$tableClassParts = FOFInflector::explode($tableClass);
$remoteKey = $tableClassParts[0] . '_' . $tableClassParts[2] . '_id';
} else {
$remoteKey = $localKey;
}
}
// If we don't have a pivot table nullify the relevant variables and return
if (!$pivot) {
$ourPivotKey = null;
$theirPivotKey = null;
$pivotTable = null;
return;
}
if (empty($ourPivotKey)) {
$ourPivotKey = $localKey;
}
if (empty($theirPivotKey)) {
$theirPivotKey = $remoteKey;
}
if (empty($pivotTable)) {
$pivotTable = '#__' . strtolower($this->componentName) . '_' . strtolower(FOFInflector::pluralize($this->tableType)) . '_';
$itemNameParts = explode('_', $itemName);
$lastPart = array_pop($itemNameParts);
$pivotTable .= strtolower($lastPart);
}
}
示例4: normaliseParameters
/**
* Normalise the parameters of a relation, guessing missing values
*
* @param boolean $pivot Is this a many to many relation involving a pivot table?
* @param string $itemName is how it will be known locally to the getRelatedItems method (plural)
* @param string $tableClass if skipped it is defined automatically as ComponentnameTableItemname
* @param string $localKey is the column containing our side of the FK relation, default: componentname_itemname_id
* @param string $remoteKey is the remote table's FK column, default: componentname_itemname_id
* @param string $ourPivotKey is the column containing our side of the FK relation in the pivot table, default: $localKey
* @param string $theirPivotKey is the column containing the other table's side of the FK relation in the pivot table, default $remoteKey
* @param string $pivotTable is the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles)
*
* @return void
*/
private function normaliseParameters($pivot = false, &$itemName, &$tableClass, &$localKey, &$remoteKey, &$ourPivotKey, &$theirPivotKey, &$pivotTable)
{
// Get a default table class if none is provided
if (empty($tableClass)) {
$tableClassParts = explode('_', $itemName, 3);
if (count($tableClassParts) == 1) {
array_unshift($tableClassParts, $this->componentName);
}
if ($tableClassParts[0] == 'joomla') {
$tableClassParts[0] = 'J';
}
$tableClass = ucfirst($tableClassParts[0]) . 'Table' . ucfirst(FOFInflector::singularize($tableClassParts[1]));
}
// Make sure we have both a local and remote key
if (empty($localKey) && empty($remoteKey)) {
$tableClassParts = FOFInflector::explode($tableClass);
$localKey = $tableClassParts[0] . '_' . $tableClassParts[2] . '_id';
$remoteKey = $localKey;
} elseif (empty($localKey) && !empty($remoteKey)) {
$localKey = $remoteKey;
} elseif (!empty($localKey) && empty($remoteKey)) {
$remoteKey = $localKey;
}
// If we don't have a pivot table nullify the relevant variables and return
if (!$pivot) {
$ourPivotKey = null;
$theirPivotKey = null;
$pivotTable = null;
return;
}
if (empty($ourPivotKey)) {
$ourPivotKey = $localKey;
}
if (empty($theirPivotKey)) {
$theirPivotKey = $remoteKey;
}
if (empty($pivotTable)) {
$pivotTable = '#__' . strtolower($this->componentName) . '_' . strtolower(FOFInflector::pluralize($this->tableType)) . '_';
$itemNameParts = explode('_', $itemName);
$lastPart = array_pop($itemNameParts);
$pivotTable .= strtolower($lastPart);
}
}
示例5: __construct
/**
* Database iterator constructor.
*
* @param mixed $cursor The database cursor.
* @param string $column An option column to use as the iterator key.
* @param string $class The table class of the returned objects.
* @param array $config Configuration parameters to push to the table class
*
* @throws InvalidArgumentException
*/
public function __construct($cursor, $column = null, $class, $config = array())
{
// Figure out the type and prefix of the class by the class name
$parts = FOFInflector::explode($class);
$this->_tableObject = FOFTable::getInstance($parts[2], ucfirst($parts[0]) . ucfirst($parts[1]));
$this->cursor = $cursor;
$this->class = 'stdClass';
$this->_column = $column;
$this->_fetched = 0;
$this->next();
}
示例6: getThisView
/**
* Returns current view object
*
* @param array $config Configuration variables for the model
*
* @return FOFView 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)) {
$config = array();
}
$prefix = null;
$viewName = null;
$viewType = null;
if (!empty($this->viewName)) {
$parts = FOFInflector::explode($this->viewName);
$viewName = ucfirst(array_pop($parts));
$prefix = FOFInflector::implode($parts);
} else {
$prefix = ucfirst($this->bareComponent) . 'View';
$viewName = ucfirst($this->view);
}
$document = FOFPlatform::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 FOFInput) {
$config['input'] = $this->input;
}
$config['input']->set('base_path', $this->basePath);
$this->_viewObject = $this->getView($viewName, $viewType, $prefix, $config);
}
return $this->_viewObject;
}