当前位置: 首页>>代码示例>>PHP>>正文


PHP FOFInflector::pluralize方法代码示例

本文整理汇总了PHP中FOFInflector::pluralize方法的典型用法代码示例。如果您正苦于以下问题:PHP FOFInflector::pluralize方法的具体用法?PHP FOFInflector::pluralize怎么用?PHP FOFInflector::pluralize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FOFInflector的用法示例。


在下文中一共展示了FOFInflector::pluralize方法的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'];
     }
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:33,代码来源:csv.php

示例2: 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;
 }
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:33,代码来源:platform.php

示例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 ? FOFInflector::pluralize($name) : FOFInflector::singularize($name);
         $itemNameParts[] = $name;
         $itemName = FOFInflector::implode($itemNameParts);
     } else {
         $name = array_pop($itemNameParts);
         $itemName = $pluralise ? FOFInflector::pluralize($name) : FOFInflector::singularize($name);
     }
     if (!empty($prefix)) {
         $itemName = $prefix . '_' . $itemName;
     }
     return $itemName;
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:34,代码来源:relations.php

示例4: getOptions

 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     $this->value = array();
     $value_field = $this->element['value_field'] ? (string) $this->element['value_field'] : 'title';
     $input = new FOFInput();
     $component = ucfirst(str_replace('com_', '', $input->getString('option')));
     $view = ucfirst($input->getString('view'));
     $relation = FOFInflector::pluralize((string) $this->element['name']);
     $model = FOFModel::getTmpInstance(ucfirst($relation), $component . 'Model');
     $table = $model->getTable();
     $key = $table->getKeyName();
     $value = $table->getColumnAlias($value_field);
     foreach ($model->getItemList(true) as $option) {
         $options[] = JHtml::_('select.option', $option->{$key}, $option->{$value});
     }
     if ($id = FOFModel::getAnInstance($view)->getId()) {
         $table = FOFTable::getInstance($view, $component . 'Table');
         $table->load($id);
         $relations = $table->getRelations()->getMultiple($relation);
         foreach ($relations as $item) {
             $this->value[] = $item->getId();
         }
     }
     return $options;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:31,代码来源:relation.php

示例5: loadTemplate

 /**
  * Overrides the built-in loadTemplate function with an FOF-specific one.
  * Our overriden function uses loadAnyTemplate to provide smarter view
  * template loading.
  *
  * @param   string   $tpl     The name of the template file to parse
  * @param   boolean  $strict  Should we use strict naming, i.e. force a non-empty $tpl?
  *
  * @return  mixed  A string if successful, otherwise a JError object
  */
 public function loadTemplate($tpl = null, $strict = false)
 {
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $basePath = $isAdmin ? 'admin:' : 'site:';
     $basePath .= $this->config['option'] . '/';
     $altBasePath = $basePath;
     $basePath .= $this->config['view'] . '/';
     $altBasePath .= (FOFInflector::isSingular($this->config['view']) ? FOFInflector::pluralize($this->config['view']) : FOFInflector::singularize($this->config['view'])) . '/';
     if ($strict) {
         $paths = array($basePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''), $altBasePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''));
     } else {
         $paths = array($basePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''), $basePath . $this->getLayout(), $basePath . 'default' . ($tpl ? "_{$tpl}" : ''), $basePath . 'default', $altBasePath . $this->getLayout() . ($tpl ? "_{$tpl}" : ''), $altBasePath . $this->getLayout(), $altBasePath . 'default' . ($tpl ? "_{$tpl}" : ''), $altBasePath . 'default');
     }
     foreach ($paths as $path) {
         $result = $this->loadAnyTemplate($path);
         if (!$result instanceof Exception) {
             break;
         }
     }
     if (version_compare(JVERSION, '3.0', 'lt') && $result instanceof Exception) {
         JError::raiseError($result->getCode(), $result->getMessage());
     }
     return $result;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:34,代码来源:view.php

示例6: __construct

 /**
  * Public constructor. Instantiates a FOFView 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();
     }
     // Get the input
     if (array_key_exists('input', $config)) {
         if ($config['input'] instanceof FOFInput) {
             $this->input = $config['input'];
         } else {
             $this->input = new FOFInput($config['input']);
         }
     } else {
         $this->input = new FOFInput();
     }
     parent::__construct($config);
     $component = 'com_foobar';
     // Get the component name
     if (array_key_exists('input', $config)) {
         if ($config['input'] instanceof FOFInput) {
             $tmpInput = $config['input'];
         } else {
             $tmpInput = new FOFInput($config['input']);
         }
         $component = $tmpInput->getCmd('option', '');
     } else {
         $tmpInput = $this->input;
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     // Get the view name
     $view = null;
     if (array_key_exists('input', $config)) {
         $view = $tmpInput->getCmd('view', '');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     // Set the component and the view to the input array
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
     }
     // Set the view name
     if (array_key_exists('name', $config)) {
         $this->_name = $config['name'];
     } else {
         $this->_name = $config['view'];
     }
     $tmpInput->set('view', $this->_name);
     $config['input'] = $tmpInput;
     $config['name'] = $this->_name;
     $config['view'] = $this->_name;
     // Get the component directories
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
     // Set the charset (used by the variable escaping functions)
     if (array_key_exists('charset', $config)) {
         FOFPlatform::getInstance()->logDeprecated('Setting a custom charset for escaping in FOFView\'s constructor is deprecated. Override FOFView::escape() instead.');
         $this->_charset = $config['charset'];
     }
     // User-defined escaping callback
     if (array_key_exists('escape', $config)) {
         $this->setEscape($config['escape']);
     }
     // Set a base path for use by the view
     if (array_key_exists('base_path', $config)) {
         $this->_basePath = $config['base_path'];
     } else {
         $this->_basePath = $componentPaths['main'];
     }
     // Set the default template search path
     if (array_key_exists('template_path', $config)) {
         // User-defined dirs
         $this->_setPath('template', $config['template_path']);
     } else {
         $altView = FOFInflector::isSingular($this->getName()) ? FOFInflector::pluralize($this->getName()) : FOFInflector::singularize($this->getName());
         $this->_setPath('template', $this->_basePath . '/views/' . $altView . '/tmpl');
         $this->_addPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl');
     }
     // Set the default helper search path
     if (array_key_exists('helper_path', $config)) {
         // User-defined dirs
         $this->_setPath('helper', $config['helper_path']);
     } else {
         $this->_setPath('helper', $this->_basePath . '/helpers');
//.........这里部分代码省略.........
开发者ID:naka211,项目名称:studiekorrektur,代码行数:101,代码来源:view.php

示例7: getMyViews

 /**
  * Automatically detects all views of the component
  *
  * @return  array  A list of all views, in the order to be displayed in the toolbar submenu
  */
 protected function getMyViews()
 {
     $views = array();
     $t_views = array();
     $using_meta = false;
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($this->component);
     $searchPath = $componentPaths['main'] . '/views';
     JLoader::import('joomla.filesystem.folder');
     JLoader::import('joomla.utilities.arrayhelper');
     $allFolders = JFolder::folders($searchPath);
     if (!empty($allFolders)) {
         foreach ($allFolders as $folder) {
             $view = $folder;
             // View already added
             if (in_array(FOFInflector::pluralize($view), $t_views)) {
                 continue;
             }
             // Do we have a 'skip.xml' file in there?
             $files = JFolder::files($searchPath . '/' . $view, '^skip\\.xml$');
             if (!empty($files)) {
                 continue;
             }
             // Do we have extra information about this view? (ie. ordering)
             $meta = JFolder::files($searchPath . '/' . $view, '^metadata\\.xml$');
             // Not found, do we have it inside the plural one?
             if (!$meta) {
                 $plural = FOFInflector::pluralize($view);
                 if (in_array($plural, $allFolders)) {
                     $view = $plural;
                     $meta = JFolder::files($searchPath . '/' . $view, '^metadata\\.xml$');
                 }
             }
             if (!empty($meta)) {
                 $using_meta = true;
                 $xml = simplexml_load_file($searchPath . '/' . $view . '/' . $meta[0]);
                 $order = (int) $xml->foflib->ordering;
             } else {
                 // Next place. It's ok since the index are 0-based and count is 1-based
                 if (!isset($to_order)) {
                     $to_order = array();
                 }
                 $order = count($to_order);
             }
             $view = FOFInflector::pluralize($view);
             $t_view = new stdClass();
             $t_view->ordering = $order;
             $t_view->view = $view;
             $to_order[] = $t_view;
             $t_views[] = $view;
         }
     }
     JArrayHelper::sortObjects($to_order, 'ordering');
     $views = JArrayHelper::getColumn($to_order, 'view');
     // If not using the metadata file, let's put the cpanel view on top
     if (!$using_meta) {
         $cpanel = array_search('cpanels', $views);
         if ($cpanel !== false) {
             unset($views[$cpanel]);
             array_unshift($views, 'cpanels');
         }
     }
     return $views;
 }
开发者ID:Tommar,项目名称:vino2,代码行数:68,代码来源:toolbar.php

示例8: 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');
//.........这里部分代码省略.........
开发者ID:01J,项目名称:skazkipronebo,代码行数:101,代码来源:joomla.php

示例9: createView

 /**
  * Creates a View object instance and returns it
  *
  * @param   string  $name    The name of the view, e.g. Items
  * @param   string  $prefix  The prefix of the view, e.g. FoobarView
  * @param   string  $type    The type of the view, usually one of Html, Raw, Json or Csv
  * @param   array   $config  The configuration variables to use for creating the view
  *
  * @return  FOFView
  */
 protected function createView($name, $prefix = '', $type = '', $config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $result = null;
     // Clean the view name
     $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
     $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
     $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
     if (!isset($config['input'])) {
         $config['input'] = $this->input;
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     // Guess the component name and view
     if (!empty($prefix)) {
         preg_match('/(.*)View$/', $prefix, $m);
         $component = 'com_' . strtolower($m[1]);
     } else {
         $component = '';
     }
     if (empty($component) && array_key_exists('input', $config)) {
         $component = $tmpInput->get('option', $component, 'cmd');
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     $view = strtolower($viewName);
     if (empty($view) && array_key_exists('input', $config)) {
         $view = $tmpInput->get('view', $view, 'cmd');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
         $config['input'] = $tmpInput;
     }
     // Get the component directories
     $componentPaths = FOFPlatform::getInstance()->getComponentBaseDirs($config['option']);
     // Get the base paths where the view class files are expected to live
     $basePaths = array($componentPaths['main'], $componentPaths['alt']);
     $basePaths = array_merge($this->paths['view']);
     // Get the alternate (singular/plural) view name
     $altViewName = FOFInflector::isPlural($viewName) ? FOFInflector::singularize($viewName) : FOFInflector::pluralize($viewName);
     $suffixes = array($viewName, $altViewName, 'default');
     $filesystem = FOFPlatform::getInstance()->getIntegrationObject('filesystem');
     foreach ($suffixes as $suffix) {
         // Build the view class name
         $viewClass = $classPrefix . ucfirst($suffix);
         if (class_exists($viewClass)) {
             // The class is already loaded
             break;
         }
         // The class is not loaded. Let's load it!
         $viewPath = $this->createFileName('view', array('name' => $suffix, 'type' => $viewType));
         $path = $filesystem->pathFind($basePaths, $viewPath);
         if ($path) {
             require_once $path;
         }
         if (class_exists($viewClass)) {
             // The class was loaded successfully
             break;
         }
     }
     if (!class_exists($viewClass)) {
         $viewClass = 'FOFView' . ucfirst($type);
     }
     $templateOverridePath = FOFPlatform::getInstance()->getTemplateOverridePath($config['option']);
     // Setup View configuration options
     if (!array_key_exists('template_path', $config)) {
         $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::pluralize($config['view']) . '/tmpl';
         if ($templateOverridePath) {
             $config['template_path'][] = $templateOverridePath . '/' . FOFInflector::pluralize($config['view']);
         }
         $config['template_path'][] = $componentPaths['main'] . '/views/' . FOFInflector::singularize($config['view']) . '/tmpl';
//.........这里部分代码省略.........
开发者ID:educakanchay,项目名称:kanchay,代码行数:101,代码来源:controller.php

示例10: 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;
 }
开发者ID:jputz12,项目名称:OneNow-Vshop,代码行数:101,代码来源:base.php

示例11: 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
  *
  * @return  string  The path and filename of the form to load
  *
  * @since   2.0
  */
 public function findFormFilename($source)
 {
     // Get some useful variables
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', 'cpanels');
     if (!$isCli) {
         $template = JFactory::getApplication()->getTemplate();
     } else {
         $template = 'cli';
     }
     $file_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $file_root .= '/components/' . $option;
     $alt_file_root = $isAdmin ? JPATH_SITE : JPATH_ADMINISTRATOR;
     $alt_file_root .= '/components/' . $option;
     $template_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $template_root .= '/templates/' . $template . '/html/' . $option;
     // 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
     $jversion = new JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()) . '.xml', '.j' . $majorVersion . '.xml', '.xml');
     unset($jversion, $versionParts, $majorVersion);
     // 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;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:51,代码来源:model.php

示例12: 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;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:14,代码来源:table.php

示例13: getPluralization

 public static function getPluralization($name, $form = 'singular')
 {
     static $cache = array();
     if (!empty($cache[$name . '.' . $form])) {
         return $cache[$name . '.' . $form];
     }
     //Pluralization
     if (JFile::exists(JPATH_LIBRARIES . '/fof/include.php')) {
         if (!defined('FOF_INCLUDED')) {
             require_once JPATH_LIBRARIES . '/fof/include.php';
         }
     } else {
         if (JFile::exists(JPATH_LIBRARIES . '/fof/inflector/inflector.php')) {
             require_once JPATH_LIBRARIES . '/fof/inflector/inflector.php';
         } else {
             require_once JPATH_COMPONENT . '/helpers/fofinflector.php';
         }
     }
     $plural = null;
     //$inflector = new FOFInflector();
     //see if name is singular, if so get a plural
     if (FOFInflector::isSingular($name)) {
         $plural = FOFInflector::pluralize($name);
     }
     //if still no plural check if name is plural
     if (empty($plural)) {
         if (FOFInflector::isPlural($name)) {
             //if its a plural switch them
             $plural = $name;
             //and get a singular
             $name = FOFInflector::singularize($name);
         }
     }
     //if still no plural just make one anyway
     if (empty($plural)) {
         $plural = $name . 's';
     }
     $cache[$name . '.plural'] = $plural;
     $cache[$name . '.singular'] = $name;
     return $cache[$name . '.' . $form];
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:41,代码来源:jacc.php

示例14: createView

 /**
  * Creates a View object instance and returns it
  *
  * @param   string  $name    The name of the view, e.g. Items
  * @param   string  $prefix  The prefix of the view, e.g. FoobarView
  * @param   string  $type    The type of the view, usually one of Html, Raw, Json or Csv
  * @param   array   $config  The configuration variables to use for creating the view
  *
  * @return  FOFView
  */
 protected function createView($name, $prefix = '', $type = '', $config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $result = null;
     // Clean the view name
     $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
     $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
     $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
     if (!isset($config['input'])) {
         $config['input'] = $this->input;
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     // Guess the component name and view
     if (!empty($prefix)) {
         preg_match('/(.*)View$/', $prefix, $m);
         $component = 'com_' . strtolower($m[1]);
     } else {
         $component = '';
     }
     if (empty($component) && array_key_exists('input', $config)) {
         $component = $tmpInput->get('option', $component, 'cmd');
     }
     if (array_key_exists('option', $config)) {
         if ($config['option']) {
             $component = $config['option'];
         }
     }
     $config['option'] = $component;
     $view = strtolower($viewName);
     if (empty($view) && array_key_exists('input', $config)) {
         $view = $tmpInput->get('view', $view, 'cmd');
     }
     if (array_key_exists('view', $config)) {
         if ($config['view']) {
             $view = $config['view'];
         }
     }
     $config['view'] = $view;
     if (array_key_exists('input', $config)) {
         $tmpInput->set('option', $config['option']);
         $tmpInput->set('view', $config['view']);
         $config['input'] = $tmpInput;
     }
     // Get the base paths where the view class files are expected to live
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $basePaths = array(JPATH_SITE . '/components/' . $config['option'] . '/views', JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/views');
     if ($isAdmin || $isCli) {
         $basePaths = array_reverse($basePaths);
         $basePaths = array_merge($basePaths, $this->paths['view'], $basePaths);
     } else {
         $basePaths = array_merge($this->paths['view']);
     }
     // Get the alternate (singular/plural) view name
     $altViewName = FOFInflector::isPlural($viewName) ? FOFInflector::singularize($viewName) : FOFInflector::pluralize($viewName);
     $suffixes = array($viewName, $altViewName, 'default');
     JLoader::import('joomla.filesystem.path');
     foreach ($suffixes as $suffix) {
         // Build the view class name
         $viewClass = $classPrefix . ucfirst($suffix);
         if (class_exists($viewClass)) {
             // The class is already loaded
             break;
         }
         // The class is not loaded. Let's load it!
         $viewPath = $this->createFileName('view', array('name' => $suffix, 'type' => $viewType));
         $path = JPath::find($basePaths, $viewPath);
         if ($path) {
             require_once $path;
         }
         if (class_exists($viewClass)) {
             // The class was loaded successfully
             break;
         }
     }
     if (!class_exists($viewClass)) {
         $viewClass = 'FOFView' . ucfirst($type);
     }
     // Setup View configuration options
     if ($isAdmin) {
         $basePath = JPATH_ADMINISTRATOR;
     } elseif ($isCli) {
//.........这里部分代码省略.........
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:101,代码来源:controller.php

示例15: dispatch

 /**
  * The main code of the Dispatcher. It spawns the necessary controller and
  * runs it.
  *
  * @throws Exception
  *
  * @return  null
  */
 public function dispatch()
 {
     $platform = FOFPlatform::getInstance();
     if (!$platform->authorizeAdmin($this->input->getCmd('option', 'com_foobar'))) {
         return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     $this->transparentAuthentication();
     // Merge English and local translations
     $platform->loadTranslations($this->component);
     $canDispatch = true;
     if ($platform->isCli()) {
         $canDispatch = $canDispatch && $this->onBeforeDispatchCLI();
     }
     $canDispatch = $canDispatch && $this->onBeforeDispatch();
     if (!$canDispatch) {
         $platform->setHeader('Status', '403 Forbidden', true);
         return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     // Get and execute the controller
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', $this->defaultView);
     $task = $this->input->getCmd('task', null);
     if (empty($task)) {
         $task = $this->getTask($view);
     }
     // Pluralise/sungularise the view name for typical tasks
     if (in_array($task, array('edit', 'add', 'read'))) {
         $view = FOFInflector::singularize($view);
     } elseif (in_array($task, array('browse'))) {
         $view = FOFInflector::pluralize($view);
     }
     $this->input->set('view', $view);
     $this->input->set('task', $task);
     $config = $this->config;
     $config['input'] = $this->input;
     $controller = FOFController::getTmpInstance($option, $view, $config);
     $status = $controller->execute($task);
     if (!$this->onAfterDispatch()) {
         $platform->setHeader('Status', '403 Forbidden', true);
         return $platform->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
     }
     $format = $this->input->get('format', 'html', 'cmd');
     $format = empty($format) ? 'html' : $format;
     if ($format == 'html') {
         // In HTML views perform a redirection
         if ($controller->redirect()) {
             return;
         }
     } else {
         // In non-HTML views just exit the application with the proper HTTP headers
         if ($controller->hasRedirect()) {
             $headers = $platform->sendHeaders();
             jexit();
         }
     }
 }
开发者ID:01J,项目名称:skazkipronebo,代码行数:64,代码来源:dispatcher.php


注:本文中的FOFInflector::pluralize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。