本文整理汇总了PHP中FOFInflector类的典型用法代码示例。如果您正苦于以下问题:PHP FOFInflector类的具体用法?PHP FOFInflector怎么用?PHP FOFInflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FOFInflector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Public constructor. Instantiates a FOFViewCsv object.
*
* @param array $config The configuration data array
*/
public function __construct($config = array())
{
// Make sure $config is an array
if (is_object($config)) {
$config = (array) $config;
} elseif (!is_array($config)) {
$config = array();
}
parent::__construct($config);
if (array_key_exists('csv_header', $config)) {
$this->csvHeader = $config['csv_header'];
} else {
$this->csvHeader = $this->input->getBool('csv_header', true);
}
if (array_key_exists('csv_filename', $config)) {
$this->csvFilename = $config['csv_filename'];
} else {
$this->csvFilename = $this->input->getString('csv_filename', '');
}
if (empty($this->csvFilename)) {
$view = $this->input->getCmd('view', 'cpanel');
$view = FOFInflector::pluralize($view);
$this->csvFilename = strtolower($view);
}
if (array_key_exists('csv_fields', $config)) {
$this->csvFields = $config['csv_fields'];
}
}
示例2: 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;
}
示例3: dispatch
public function dispatch()
{
// Look for controllers in the plugins folder
$option = $this->input->get('option', 'com_foobar', 'cmd');
$view = $this->input->get('view', $this->defaultView, 'cmd');
$c = FOFInflector::singularize($view);
$alt_path = JPATH_SITE . '/components/' . $option . '/plugins/controllers/' . $c . '.php';
JLoader::import('joomla.filesystem.file');
if (JFile::exists($alt_path)) {
// The requested controller exists and there you load it...
require_once $alt_path;
}
$this->input->set('view', $this->view);
parent::dispatch();
}
示例4: renderFormBrowse
/**
* Renders a FOFForm for a Browse view and returns the corresponding HTML
*
* @param FOFForm &$form The form to render
* @param FOFModel $model The model providing our data
* @param FOFInput $input The input object
*
* @return string The HTML rendering of the form
*/
protected function renderFormBrowse(FOFForm &$form, FOFModel $model, FOFInput $input)
{
JHtml::_('behavior.multiselect');
// Getting all header row elements
$headerFields = $form->getHeaderset();
// Start the form
$html = '';
$filter_order = $form->getView()->getLists()->order;
$filter_order_Dir = $form->getView()->getLists()->order_Dir;
$html .= '<form action="index.php" method="post" name="adminForm" id="adminForm">' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="view" value="' . FOFInflector::pluralize($input->getCmd('view')) . '" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="task" value="" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="boxchecked" value="" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="hidemainmenu" value="" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="filter_order" value="' . $filter_order . '" />' . PHP_EOL;
$html .= "\t" . '<input type="hidden" name="filter_order_Dir" value="' . $filter_order_Dir . '" />' . PHP_EOL;
if (FOFPlatform::getInstance()->isFrontend() && $input->getCmd('Itemid', 0) != 0) {
$html .= "\t" . '<input type="hidden" name="Itemid" value="' . $input->getCmd('Itemid', 0) . '" />' . PHP_EOL;
}
$html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL;
// Start the table output
$html .= "\t\t" . '<table class="adminlist" id="adminList">' . PHP_EOL;
// Get form parameters
$show_header = $form->getAttribute('show_header', 1);
$show_filters = $form->getAttribute('show_filters', 1);
$show_pagination = $form->getAttribute('show_pagination', 1);
$norows_placeholder = $form->getAttribute('norows_placeholder', '');
// Open the table header region if required
if ($show_header || $show_filters) {
$html .= "\t\t\t<thead>" . PHP_EOL;
}
// Pre-render the header and filter rows
if ($show_header || $show_filters) {
$header_html = '';
$filter_html = '';
foreach ($headerFields as $header) {
// Make sure we have a header field. Under Joomla! 2.5 we cannot
// render filter-only fields.
$tmpHeader = $header->header;
if (empty($tmpHeader)) {
continue;
}
$tdwidth = $header->tdwidth;
if (!empty($tdwidth)) {
$tdwidth = 'width="' . $tdwidth . '"';
} else {
$tdwidth = '';
}
$header_html .= "\t\t\t\t\t<th {$tdwidth}>" . PHP_EOL;
$header_html .= "\t\t\t\t\t\t" . $tmpHeader;
$header_html .= "\t\t\t\t\t</th>" . PHP_EOL;
$filter = $header->filter;
$buttons = $header->buttons;
$options = $header->options;
$filter_html .= "\t\t\t\t\t<td>" . PHP_EOL;
if (!empty($filter)) {
$filter_html .= "\t\t\t\t\t\t{$filter}" . PHP_EOL;
if (!empty($buttons)) {
$filter_html .= "\t\t\t\t\t\t<nobr>{$buttons}</nobr>" . PHP_EOL;
}
} elseif (!empty($options)) {
$label = $header->label;
$emptyOption = JHtml::_('select.option', '', '- ' . JText::_($label) . ' -');
array_unshift($options, $emptyOption);
$attribs = array('onchange' => 'document.adminForm.submit();');
$filter = JHtml::_('select.genericlist', $options, $header->name, $attribs, 'value', 'text', $header->value, false, true);
$filter_html .= "\t\t\t\t\t\t{$filter}" . PHP_EOL;
}
$filter_html .= "\t\t\t\t\t</td>" . PHP_EOL;
}
}
// Render header if enabled
if ($show_header) {
$html .= "\t\t\t\t<tr>" . PHP_EOL;
$html .= $header_html;
$html .= "\t\t\t\t</tr>" . PHP_EOL;
}
// Render filter row if enabled
if ($show_filters) {
$html .= "\t\t\t\t<tr>";
$html .= $filter_html;
$html .= "\t\t\t\t</tr>";
}
// Close the table header region if required
if ($show_header || $show_filters) {
$html .= "\t\t\t</thead>" . PHP_EOL;
}
// Loop through rows and fields, or show placeholder for no rows
$html .= "\t\t\t<tbody>" . PHP_EOL;
$fields = $form->getFieldset('items');
//.........这里部分代码省略.........
示例5: getTask
/**
* Tries to guess the controller task to execute based on the view name and
* the HTTP request method.
*
* @param string $view The name of the view
*
* @return string The best guess of the task to execute
*/
protected function getTask($view)
{
// Get a default task based on plural/singular view
$request_task = $this->input->getCmd('task', null);
$task = FOFInflector::isPlural($view) ? 'browse' : 'edit';
// Get a potential ID, we might need it later
$id = $this->input->get('id', null, 'int');
if ($id == 0) {
$ids = $this->input->get('ids', array(), 'array');
if (!empty($ids)) {
$id = array_shift($ids);
}
}
// Check the request method
if (!isset($_SERVER['REQUEST_METHOD'])) {
$_SERVER['REQUEST_METHOD'] = 'GET';
}
$requestMethod = strtoupper($_SERVER['REQUEST_METHOD']);
switch ($requestMethod) {
case 'POST':
case 'PUT':
if (!is_null($id)) {
$task = 'save';
}
break;
case 'DELETE':
if ($id != 0) {
$task = 'delete';
}
break;
case 'GET':
default:
// If it's an edit without an ID or ID=0, it's really an add
if ($task == 'edit' && $id == 0) {
$task = 'add';
} elseif ($task == 'edit' && FOFPlatform::getInstance()->isFrontend()) {
$task = 'read';
}
break;
}
return $task;
}
示例6: getLabel
/**
* Method to get the field label.
*
* @return string The field label.
*
* @since 2.0
*/
protected function getLabel()
{
// Get the label text from the XML element, defaulting to the element name.
$title = $this->element['label'] ? (string) $this->element['label'] : '';
if (empty($title)) {
$view = $this->form->getView();
$params = $view->getViewOptionAndName();
$title = $params['option'] . '_' . FOFInflector::pluralize($params['view']) . '_FIELD_' . (string) $this->element['name'];
$title = strtoupper($title);
$result = JText::_($title);
if ($result === $title) {
$title = ucfirst((string) $this->element['name']);
}
}
return $title;
}
示例7: getViewTemplatePaths
/**
* Return a list of the view template paths for this component.
*
* @param string $component The name of the component. For Joomla! this
* is something like "com_example"
* @param string $view The name of the view you're looking a
* template for
* @param string $layout The layout name to load, e.g. 'default'
* @param string $tpl The sub-template name to load (null by default)
* @param boolean $strict If true, only the specified layout will be searched for.
* Otherwise we'll fall back to the 'default' layout if the
* specified layout is not found.
*
* @see FOFPlatformInterface::getViewTemplateDirs()
*
* @return array
*/
public function getViewTemplatePaths($component, $view, $layout = 'default', $tpl = null, $strict = false)
{
$isAdmin = $this->isBackend();
$basePath = $isAdmin ? 'admin:' : 'site:';
$basePath .= $component . '/';
$altBasePath = $basePath;
$basePath .= $view . '/';
$altBasePath .= (FOFInflector::isSingular($view) ? FOFInflector::pluralize($view) : FOFInflector::singularize($view)) . '/';
if ($strict) {
$paths = array($basePath . $layout . ($tpl ? "_{$tpl}" : ''), $altBasePath . $layout . ($tpl ? "_{$tpl}" : ''));
} else {
$paths = array($basePath . $layout . ($tpl ? "_{$tpl}" : ''), $basePath . $layout, $basePath . 'default' . ($tpl ? "_{$tpl}" : ''), $basePath . 'default', $altBasePath . $layout . ($tpl ? "_{$tpl}" : ''), $altBasePath . $layout, $altBasePath . 'default' . ($tpl ? "_{$tpl}" : ''), $altBasePath . 'default');
$paths = array_unique($paths);
}
return $paths;
}
示例8: dispatch
public function dispatch()
{
if (!class_exists('AkeebaControllerDefault')) {
require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/controllers/default.php';
}
// Merge the language overrides
$paths = array(JPATH_ROOT, JPATH_ADMINISTRATOR);
$jlang = JFactory::getLanguage();
$jlang->load($this->component, $paths[0], 'en-GB', true);
$jlang->load($this->component, $paths[0], null, true);
$jlang->load($this->component, $paths[1], 'en-GB', true);
$jlang->load($this->component, $paths[1], null, true);
$jlang->load($this->component . '.override', $paths[0], 'en-GB', true);
$jlang->load($this->component . '.override', $paths[0], null, true);
$jlang->load($this->component . '.override', $paths[1], 'en-GB', true);
$jlang->load($this->component . '.override', $paths[1], null, true);
FOFInflector::addWord('alice', 'alices');
// Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!)
if (function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) {
if (function_exists('error_reporting')) {
$oldLevel = error_reporting(0);
}
$serverTimezone = @date_default_timezone_get();
if (empty($serverTimezone) || !is_string($serverTimezone)) {
$serverTimezone = 'UTC';
}
if (function_exists('error_reporting')) {
error_reporting($oldLevel);
}
@date_default_timezone_set($serverTimezone);
}
// Necessary defines for Akeeba Engine
if (!defined('AKEEBAENGINE')) {
define('AKEEBAENGINE', 1);
// Required for accessing Akeeba Engine's factory class
define('AKEEBAROOT', dirname(__FILE__) . '/akeeba');
define('ALICEROOT', dirname(__FILE__) . '/alice');
}
// Setup Akeeba's ACLs, honoring laxed permissions in component's parameters, if set
// Access check, Joomla! 1.6 style.
$user = JFactory::getUser();
if (!$user->authorise('core.manage', 'com_akeeba')) {
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Make sure we have a profile set throughout the component's lifetime
$session = JFactory::getSession();
$profile_id = $session->get('profile', null, 'akeeba');
if (is_null($profile_id)) {
// No profile is set in the session; use default profile
$session->set('profile', 1, 'akeeba');
}
// Load the factory
require_once JPATH_COMPONENT_ADMINISTRATOR . '/akeeba/factory.php';
@(include_once JPATH_COMPONENT_ADMINISTRATOR . '/alice/factory.php');
// Load the Akeeba Backup configuration and check user access permission
$aeconfig = AEFactory::getConfiguration();
AEPlatform::getInstance()->load_configuration();
unset($aeconfig);
// Preload helpers
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/includes.php';
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/escape.php';
// Load the utils helper library
AEPlatform::getInstance()->load_version_defines();
// Create a versioning tag for our static files
$staticFilesVersioningTag = md5(AKEEBA_VERSION . AKEEBA_DATE);
define('AKEEBAMEDIATAG', $staticFilesVersioningTag);
// If JSON functions don't exist, load our compatibility layer
if (!function_exists('json_encode') || !function_exists('json_decode')) {
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/jsonlib.php';
}
// Look for controllers in the plugins folder
$option = $this->input->get('option', 'com_foobar', 'cmd');
$view = $this->input->get('view', $this->defaultView, 'cmd');
$c = FOFInflector::singularize($view);
$alt_path = JPATH_ADMINISTRATOR . '/components/' . $option . '/plugins/controllers/' . $c . '.php';
JLoader::import('joomla.filesystem.file');
if (JFile::exists($alt_path)) {
// The requested controller exists and there you load it...
require_once $alt_path;
}
$this->input->set('view', $this->view);
parent::dispatch();
}
示例9: save
//.........这里部分代码省略.........
$fields = array(&$field);
if (isset($field->field_namekey)) {
$namekey = $field->field_namekey;
}
$field->field_namekey = 'field_default';
if ($this->_checkOneInput($fields, $formData['field'], $data, '', $oldData)) {
if (isset($formData['field']['field_default']) && is_array($formData['field']['field_default'])) {
$defaultValue = '';
foreach ($formData['field']['field_default'] as $value) {
if (empty($defaultValue)) {
$defaultValue .= $value;
} else {
$defaultValue .= "," . $value;
}
}
$field->field_default = strip_tags($defaultValue);
} else {
$field->field_default = @strip_tags($formData['field']['field_default']);
}
}
unset($field->field_namekey);
if (isset($namekey)) {
$field->field_namekey = $namekey;
}
$fieldOptions = $app->input->get('field_options', array(), 'array');
foreach ($fieldOptions as $column => $value) {
if (is_array($value)) {
foreach ($value as $id => $val) {
j2storeSelectableHelper::secureField($val);
$fieldOptions[$column][$id] = strip_tags($val);
}
} else {
$fieldOptions[$column] = strip_tags($value);
}
}
if ($field->field_type == "customtext") {
$fieldOptions['customtext'] = $app->input->getHtml('fieldcustomtext', '');
if (empty($field->field_id)) {
$field->field_namekey = 'customtext_' . date('z_G_i_s');
} else {
$oldField = $this->get($field->field_id);
if ($oldField->field_core) {
$field->field_type = $oldField->field_type;
}
}
}
$field->field_options = serialize($fieldOptions);
$fieldValues = $app->input->get('field_values', array(), 'array');
if (!empty($fieldValues)) {
$field->field_value = array();
foreach ($fieldValues['title'] as $i => $title) {
if (strlen($title) < 1 and strlen($fieldValues['value'][$i]) < 1) {
continue;
}
$value = strlen($fieldValues['value'][$i]) < 1 ? $title : $fieldValues['value'][$i];
$disabled = strlen($fieldValues['disabled'][$i]) < 1 ? '0' : $fieldValues['disabled'][$i];
$field->field_value[] = strip_tags($title) . '::' . strip_tags($value) . '::' . strip_tags($disabled);
}
$field->field_value = implode("\n", $field->field_value);
}
if (empty($field->field_id) && $field->field_type != 'customtext') {
if (empty($field->field_namekey)) {
$field->field_namekey = $field->field_name;
}
$field->field_namekey = preg_replace('#[^a-z0-9_]#i', '', strtolower($field->field_namekey));
if (empty($field->field_namekey)) {
$this->errors[] = 'Please specify a namekey';
return false;
}
if ($field->field_namekey > 50) {
$this->errors[] = 'Please specify a shorter column name';
return false;
}
if (in_array(strtoupper($field->field_namekey), array('ACCESSIBLE', 'ADD', 'ALL', 'ALTER', 'ANALYZE', 'AND', 'AS', 'ASC', 'ASENSITIVE', 'BEFORE', 'BETWEEN', 'BIGINT', 'BINARY', 'BLOB', 'BOTH', 'BY', 'CALL', 'CASCADE', 'CASE', 'CHANGE', 'CHAR', 'CHARACTER', 'CHECK', 'COLLATE', 'COLUMN', 'CONDITION', 'CONSTRAINT', 'CONTINUE', 'CONVERT', 'CREATE', 'CROSS', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURSOR', 'DATABASE', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELAYED', 'DELETE', 'DESC', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCT', 'DISTINCTROW', 'DIV', 'DOUBLE', 'DROP', 'DUAL', 'EACH', 'ELSE', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXISTS', 'EXIT', 'EXPLAIN', 'FALSE', 'FETCH', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FOR', 'FORCE', 'FOREIGN', 'FROM', 'FULLTEXT', 'GRANT', 'GROUP', 'HAVING', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IF', 'IGNORE', 'IN', 'INDEX', 'INFILE', 'INNER', 'INOUT', 'INSENSITIVE', 'INSERT', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'INTERVAL', 'INTO', 'IS', 'ITERATE', 'JOIN', 'KEY', 'KEYS', 'KILL', 'LEADING', 'LEAVE', 'LEFT', 'LIKE', 'LIMIT', 'LINEAR', 'LINES', 'LOAD', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONG', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MASTER_SSL_VERIFY_SERVER_CERT', 'MATCH', 'MAXVALUE', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NOT', 'NO_WRITE_TO_BINLOG', 'NULL', 'NUMERIC', 'ON', 'OPTIMIZE', 'OPTION', 'OPTIONALLY', 'OR', 'ORDER', 'OUT', 'OUTER', 'OUTFILE', 'PRECISION', 'PRIMARY', 'PROCEDURE', 'PURGE', 'RANGE', 'READ', 'READS', 'READ_WRITE', 'REAL', 'REFERENCES', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RESIGNAL', 'RESTRICT', 'RETURN', 'REVOKE', 'RIGHT', 'RLIKE', 'SCHEMA', 'SCHEMAS', 'SECOND_MICROSECOND', 'SELECT', 'SENSITIVE', 'SEPARATOR', 'SET', 'SHOW', 'SIGNAL', 'SMALLINT', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TABLE', 'TERMINATED', 'THEN', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TO', 'TRAILING', 'TRIGGER', 'TRUE', 'UNDO', 'UNION', 'UNIQUE', 'UNLOCK', 'UNSIGNED', 'UPDATE', 'USAGE', 'USE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', 'VARCHAR', 'VARCHARACTER', 'VARYING', 'WHEN', 'WHERE', 'WHILE', 'WITH', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'GENERAL', 'IGNORE_SERVER_IDS', 'MASTER_HEARTBEAT_PERIOD', 'MAXVALUE', 'RESIGNAL', 'SIGNAL', 'SLOW', 'ALIAS', 'OPTIONS', 'RELATED', 'IMAGES', 'FILES', 'CATEGORIES', 'PRICES', 'VARIANTS', 'CHARACTERISTICS'))) {
$this->errors[] = 'The column name "' . $field->field_namekey . '" is reserved. Please use another one.';
return false;
}
$tables = array($field->field_table);
foreach ($tables as $table_name) {
if ($table_name == 'address') {
$table_name = FOFInflector::pluralize($table_name);
}
$columns = $this->database->getTableColumns($this->fieldTable($table_name));
if (isset($columns[$field->field_namekey])) {
$this->errors[] = 'The field "' . $field->field_namekey . '" already exists in the table "' . $table_name . '"';
return false;
}
}
foreach ($tables as $table_name) {
if ($table_name == 'address') {
$table_name = FOFInflector::pluralize($table_name);
}
$query = 'ALTER TABLE ' . $this->fieldTable($table_name) . ' ADD `' . $field->field_namekey . '` TEXT NULL';
$this->database->setQuery($query);
$this->database->query();
}
}
$this->fielddata = $field;
return true;
}
示例10: onBeforeReset
protected function onBeforeReset()
{
if ($this->_trigger_events) {
$name = FOFInflector::pluralize($this->getKeyName());
$dispatcher = JDispatcher::getInstance();
$result = $dispatcher->trigger('onBeforeReset' . ucfirst($name), array(&$this));
if (in_array(false, $result, true)) {
return false;
} else {
return true;
}
}
return true;
}
示例11: renderFormBrowse
/**
* Renders a FOFForm for a Browse view and returns the corresponding HTML
*
* @param FOFForm &$form The form to render
* @param FOFModel $model The model providing our data
* @param FOFInput $input The input object
*
* @return string The HTML rendering of the form
*/
protected function renderFormBrowse(FOFForm &$form, FOFModel $model, FOFInput $input)
{
$html = '';
JHtml::_('behavior.multiselect');
// Joomla! 3.0+ support
if (FOFPlatform::getInstance()->checkVersion(JVERSION, '3.0', 'ge')) {
JHtml::_('bootstrap.tooltip');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$view = $form->getView();
$order = $view->escape($view->getLists()->order);
$html .= <<<ENDJS
<script type="text/javascript">
\tJoomla.orderTable = function() {
\t\ttable = document.getElementById("sortTable");
\t\tdirection = document.getElementById("directionTable");
\t\torder = table.options[table.selectedIndex].value;
\t\tif (order != '{$order}')
\t\t{
\t\t\tdirn = 'asc';
\t\t}
\t\telse {
\t\t\tdirn = direction.options[direction.selectedIndex].value;
\t\t}
\t\tJoomla.tableOrdering(order, dirn);
\t}
</script>
ENDJS;
}
// Getting all header row elements
$headerFields = $form->getHeaderset();
// Get form parameters
$show_header = $form->getAttribute('show_header', 1);
$show_filters = $form->getAttribute('show_filters', 1);
$show_pagination = $form->getAttribute('show_pagination', 1);
$norows_placeholder = $form->getAttribute('norows_placeholder', '');
// Joomla! 3.0 sidebar support
if (FOFPlatform::getInstance()->checkVersion(JVERSION, '3.0', 'gt')) {
if ($show_filters) {
JHtmlSidebar::setAction("index.php?option=" . $input->getCmd('option') . "&view=" . FOFInflector::pluralize($input->getCmd('view')));
}
// Reorder the fields with ordering first
$tmpFields = array();
$i = 1;
foreach ($headerFields as $tmpField) {
if ($tmpField instanceof FOFFormHeaderOrdering) {
$tmpFields[0] = $tmpField;
} else {
$tmpFields[$i] = $tmpField;
}
$i++;
}
$headerFields = $tmpFields;
ksort($headerFields, SORT_NUMERIC);
}
// Pre-render the header and filter rows
$header_html = '';
$filter_html = '';
$sortFields = array();
if ($show_header || $show_filters) {
foreach ($headerFields as $headerField) {
$header = $headerField->header;
$filter = $headerField->filter;
$buttons = $headerField->buttons;
$options = $headerField->options;
$sortable = $headerField->sortable;
$tdwidth = $headerField->tdwidth;
// Under Joomla! < 3.0 we can't have filter-only fields
if (FOFPlatform::getInstance()->checkVersion(JVERSION, '3.0', 'lt') && empty($header)) {
continue;
}
// If it's a sortable field, add to the list of sortable fields
if ($sortable) {
$sortFields[$headerField->name] = JText::_($headerField->label);
}
// Get the table data width, if set
if (!empty($tdwidth)) {
$tdwidth = 'width="' . $tdwidth . '"';
} else {
$tdwidth = '';
}
if (!empty($header)) {
$header_html .= "\t\t\t\t\t<th {$tdwidth}>" . PHP_EOL;
$header_html .= "\t\t\t\t\t\t" . $header;
$header_html .= "\t\t\t\t\t</th>" . PHP_EOL;
}
if (FOFPlatform::getInstance()->checkVersion(JVERSION, '3.0', 'ge')) {
// Joomla! 3.0 or later
if (!empty($filter)) {
$filter_html .= '<div class="filter-search btn-group pull-left">' . "\n";
//.........这里部分代码省略.........
示例12: findRenderer
/**
* Finds a suitable renderer
*
* @return FOFRenderAbstract
*/
protected function findRenderer()
{
$filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
// Try loading the stock renderers shipped with FOF
if (empty(self::$renderers) || !class_exists('FOFRenderJoomla', false)) {
$path = dirname(__FILE__) . '/../render/';
$renderFiles = $filesystem->folderFiles($path, '.php');
if (!empty($renderFiles)) {
foreach ($renderFiles as $filename) {
if ($filename == 'abstract.php') {
continue;
}
@(include_once $path . '/' . $filename);
$camel = FOFInflector::camelize($filename);
$className = 'FOFRender' . ucfirst(FOFInflector::getPart($camel, 0));
$o = new $className();
self::registerRenderer($o);
}
}
}
// Try to detect the most suitable renderer
$o = null;
$priority = 0;
if (!empty(self::$renderers)) {
foreach (self::$renderers as $r) {
$info = $r->getInformation();
if (!$info->enabled) {
continue;
}
if ($info->priority > $priority) {
$priority = $info->priority;
$o = $r;
}
}
}
// Return the current renderer
return $o;
}
示例13: __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();
}
示例14: findFormFilename
/**
* Guesses the best candidate for the path to use for a particular form.
*
* @param string $source The name of the form file to load, without the .xml extension.
* @param array $paths The paths to look into. You can declare this to override the default FOF paths.
*
* @return mixed A string if the path and filename of the form to load is found, false otherwise.
*
* @since 2.0
*/
public function findFormFilename($source, $paths = array())
{
// TODO Should we read from internal variables instead of the input? With a temp instance we have no input
$option = $this->input->getCmd('option', 'com_foobar');
$view = $this->name;
$componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($option);
$file_root = $componentPaths['main'];
$alt_file_root = $componentPaths['alt'];
$template_root = FOFPlatform::getInstance()->getTemplateOverridePath($option);
if (empty($paths)) {
// Set up the paths to look into
// PLEASE NOTE: If you ever change this, please update Model Unit tests, too, since we have to
// copy these default folders (we have to add the protocol for the virtual filesystem)
$paths = array($template_root . '/' . $view, $template_root . '/' . FOFInflector::singularize($view), $template_root . '/' . FOFInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
}
$paths = array_unique($paths);
// Set up the suffixes to look into
$suffixes = array();
$temp_suffixes = FOFPlatform::getInstance()->getTemplateSuffixes();
if (!empty($temp_suffixes)) {
foreach ($temp_suffixes as $suffix) {
$suffixes[] = $suffix . '.xml';
}
}
$suffixes[] = '.xml';
// Look for all suffixes in all paths
$result = false;
$filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
foreach ($paths as $path) {
foreach ($suffixes as $suffix) {
$filename = $path . '/' . $source . $suffix;
if ($filesystem->fileExists($filename)) {
$result = $filename;
break;
}
}
if ($result) {
break;
}
}
return $result;
}
示例15: findFormFilename
/**
* Guesses the best candidate for the path to use for a particular form.
*
* @param string $source The name of the form file to load, without the .xml extension.
* @param array $paths The paths to look into. You can declare this to override the default FOF paths.
*
* @return mixed A string if the path and filename of the form to load is found, false otherwise.
*
* @since 2.0
*/
public function findFormFilename($source, $paths = array())
{
$option = $this->input->getCmd('option', 'com_foobar');
$view = $this->input->getCmd('view', 'cpanels');
$componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($option);
$file_root = $componentPaths['main'];
$alt_file_root = $componentPaths['alt'];
$template_root = FOFPlatform::getInstance()->getTemplateOverridePath($option);
if (empty($paths)) {
// Set up the paths to look into
$paths = array($template_root . '/' . $view, $template_root . '/' . FOFInflector::singularize($view), $template_root . '/' . FOFInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
}
// Set up the suffixes to look into
$suffixes = array();
$temp_suffixes = FOFPlatform::getInstance()->getTemplateSuffixes();
if (!empty($temp_suffixes)) {
foreach ($temp_suffixes as $suffix) {
$suffixes[] = $suffix . '.xml';
}
}
$suffixes[] = '.xml';
// Look for all suffixes in all paths
JLoader::import('joomla.filesystem.file');
$result = false;
foreach ($paths as $path) {
foreach ($suffixes as $suffix) {
$filename = $path . '/' . $source . $suffix;
if (JFile::exists($filename)) {
$result = $filename;
break;
}
}
if ($result) {
break;
}
}
return $result;
}