示例#1
0
 /**
  * Display the template
  *
  * @param   sting  $tpl  template
  *
  * @return void
  */
 public function display($tpl = null)
 {
     if (parent::display($tpl) !== false) {
         if (!$this->app->isAdmin()) {
             $state = $this->get('State');
             $this->params = $state->get('params');
             if ($this->params->get('menu-meta_description')) {
                 $this->doc->setDescription($this->params->get('menu-meta_description'));
             }
             if ($this->params->get('menu-meta_keywords')) {
                 $this->doc->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
             }
             if ($this->params->get('robots')) {
                 $this->doc->setMetadata('robots', $this->params->get('robots'));
             }
         }
         // Set the response to indicate a file download
         $this->app->setHeader('Content-Type', 'application/vnd.ms-word');
         $name = $this->getModel()->getTable()->label;
         $name = JStringNormalise::toDashSeparated($name);
         $this->app->setHeader('Content-Disposition', "attachment;filename=\"" . $name . ".doc\"");
         $this->doc->setMimeEncoding('text/html; charset=Windows-1252', false);
         $this->output();
     }
 }
示例#2
0
 /**
  * Main setup routine for displaying the form/detail view
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     if (parent::display($tpl) !== false) {
         $this->output();
         $app = JFactory::getApplication();
         if (!$app->isAdmin()) {
             $this->state = $this->get('State');
             $this->document = JFactory::getDocument();
             $model = $this->getModel();
             $this->params = $this->state->get('params');
             $row = $model->getData();
             $w = new FabrikWorker();
             if ($this->params->get('menu-meta_description')) {
                 $desc = $w->parseMessageForPlaceHolder($this->params->get('menu-meta_description'), $row);
                 $this->document->setDescription($desc);
             }
             if ($this->params->get('menu-meta_keywords')) {
                 $keywords = $w->parseMessageForPlaceHolder($this->params->get('menu-meta_keywords'), $row);
                 $this->document->setMetadata('keywords', $keywords);
             }
             if ($this->params->get('robots')) {
                 $this->document->setMetadata('robots', $this->params->get('robots'));
             }
             // Set the response to indicate a file download
             JResponse::setHeader('Content-Type', 'application/vnd.ms-word');
             $name = $this->getModel()->getTable()->label;
             $name = JStringNormalise::toDashSeparated($name);
             JResponse::setHeader('Content-Disposition', "attachment;filename=\"" . $name . ".doc\"");
             $this->document->setMimeEncoding('text/html; charset=Windows-1252', false);
         }
     }
 }
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     JToolbarHelper::title(JString::ucwords(implode(' ', JStringNormalise::fromCamelCase($this->view, true))));
     if ($user->authorise('core.admin', 'com_fileuploadform')) {
         JToolbarHelper::preferences('com_fileuploadform');
     }
     parent::display($tpl);
 }
示例#4
0
 public function __construct(&$subject, $config = array())
 {
     parent::__construct($subject, $config);
     $this->set('highlighting', array("title", "title_*", "body_*", "metadescription_*", "category_*"));
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select(array('name', 'title'))->from('#__jreviews_fields')->where("location='content'");
     $db->setQuery($query);
     $array = array();
     foreach ($db->loadObjectList() as $item) {
         $key = JString::strtolower(JStringNormalise::toVariable($item->name)) . '_fc';
         $array[$key] = $item->title;
     }
     $this->set('operators', $array);
 }
示例#5
0
 /**
  * Prepares a listing for indexing.
  */
 protected function getDocument(&$record)
 {
     $doc = new JSolrApacheSolrDocument();
     $created = JFactory::getDate($record->created);
     $modified = JFactory::getDate($record->modified);
     $lang = $this->getLanguage($record, false);
     $created = JFactory::getDate($record->created);
     $modified = JFactory::getDate($record->modified);
     $publishUp = JFactory::getDate($record->publish_up);
     $publishDown = JFactory::getDate($record->publish_down);
     if ($created > $modified) {
         $modified = $created;
     }
     $lang = $this->getLanguage($record, false);
     $doc->addField('created', $created->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('modified', $modified->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('publish_up_dt', $publishUp->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('publish_down_dt', $publishDown->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField("title", $record->title);
     $doc->addField("title_{$lang}", $record->title);
     $doc->addField("access", $record->access);
     $doc->addField("title_ac", $record->title);
     // for auto complete
     $doc->addField("title_sort", $record->title);
     $record->summary = JSolrHelper::prepareContent($record->summary, $record->params);
     $record->body = JSolrHelper::prepareContent($record->body, $record->params);
     $doc->addField("body_{$lang}", strip_tags($record->summary));
     $doc->addField("body_{$lang}", strip_tags($record->body));
     foreach (explode(',', $record->metakey) as $metakey) {
         $doc->addField("metakeywords_{$lang}", trim($metakey));
     }
     $doc->addField("metadescription_{$lang}", $record->metadesc);
     $doc->addField("author", $record->author);
     $doc->addField("author_fc", $record->author);
     // for faceting
     $doc->addField("author_ac", $record->author);
     // for auto complete
     foreach (JSolrHelper::getTags($record, array("<h1>")) as $item) {
         $doc->addField("tags_h1_{$lang}", $item);
     }
     foreach (JSolrHelper::getTags($record, array("<h2>", "<h3>")) as $item) {
         $doc->addField("tags_h2_h3_{$lang}", $item);
     }
     foreach (JSolrHelper::getTags($record, array("<h4>", "<h5>", "<h6>")) as $item) {
         $doc->addField("tags_h4_h5_h6_{$lang}", $item);
     }
     $doc->addField("hits_i", (int) $record->hits);
     if ($record->catid) {
         $doc->addField("parent_id", $record->catid);
         $doc->addField("category_{$lang}", $record->category);
         $doc->addField("category_fc", $record->category);
         // for faceting
     }
     // index image data (if available)
     if ($record->media_type == 'photo' && $record->main_media == 1) {
         $doc->addField("media_id_i", (int) $record->media_id);
         $doc->addField("media_relative_path_s", $record->rel_path);
         $doc->addField("media_filename_s", $record->filename);
         $doc->addField("media_fileextension_s", $record->file_extension);
         $doc->addField("media_filesize_i", (int) $record->filesize);
         $doc->addField("media_info_s", $record->media_info);
         $doc->addField("media_metadata_s", $record->media_metadata);
         $doc->addField("media_published_i", (int) $record->media_published);
         $doc->addField("media_extension_s", $record->media_extension);
     }
     $doc->addField("video_count_i", (int) $record->video_count);
     $doc->addField("photo_count_i", (int) $record->photo_count);
     $doc->addField("audio_count_i", (int) $record->audio_count);
     $doc->addField("attachment_count_i", (int) $record->attachment_count);
     if (isset($record->user_rating)) {
         $doc->addField("user_rating_tf", $record->user_rating);
     }
     if (isset($record->user_rating_count)) {
         $doc->addField("user_rating_count_i", (int) $record->user_rating_count);
     }
     if (isset($record->user_criteria_rating)) {
         $doc->addField("user_criteria_rating_tf", $record->user_criteria_rating);
     }
     if (isset($record->user_criteria_rating_count)) {
         $doc->addField("user_criteria_rating_count_i", (int) $record->user_criteria_rating_count);
     }
     if (isset($record->review_count)) {
         $doc->addField("review_count_i", (int) $record->review_count);
     }
     if (isset($record->editor_rating)) {
         $doc->addField("editor_rating_tf", $record->editor_rating);
     }
     if (isset($record->editor_rating_count)) {
         $doc->addField("editor_rating_count_i", (int) $record->editor_rating_count);
     }
     if (isset($record->editor_criteria_rating)) {
         $doc->addField("editor_criteria_rating_tf", $record->editor_criteria_rating);
     }
     if (isset($record->editor_criteria_rating_count)) {
         $doc->addField("editor_criteria_rating_count_s", $record->editor_criteria_rating_count);
     }
     if (isset($record->editor_review_count)) {
         $doc->addField("editor_review_count_s", $record->editor_review_count);
     }
     if (isset($record->favorites)) {
         $doc->addField("favorites_i", (int) $record->favorites);
     }
     // Obtain the configured fields to index.
     if (array_search('jsolr_all', $this->params->def('index_fields')) === false) {
         $indexes = $this->params->def('index_fields');
     } else {
         $indexes = $this->_getJRFields();
     }
     foreach ($indexes as $index) {
         $key = JString::strtolower(JStringNormalise::toVariable($index));
         $doc->addField($key . '_txt', $record->{$index});
         // for searching.
         switch ($this->_getJRField($index)->type) {
             case 'checkboxes':
             case 'selectmultiple':
             case 'radiobuttons':
                 foreach (explode('*', $record->{$index}) as $value) {
                     if (!empty($value)) {
                         $doc->addField($key . '_sm', $value);
                     }
                 }
                 break;
             case 'integer':
                 $doc->addField($key . '_i', (int) $record->{$index});
                 break;
             default:
                 $doc->addField($key . '_s', $record->{$index});
                 // for faceting
                 break;
         }
     }
     // Obtain the configured fields to index.
     if (array_search('jsolr_all', $this->params->def('facet_fields')) === false) {
         $facets = $this->params->def('facet_fields');
     } else {
         $facets = $this->_getJRFields();
     }
     // Obtain the configured fields to facet.
     foreach ($facets as $facet) {
         $key = JString::strtolower(JStringNormalise::toVariable($facet));
         switch ($this->_getJRField($facet)->type) {
             case 'checkboxes':
             case 'selectmultiple':
             case 'radiobuttons':
                 foreach (explode('*', rtrim(ltrim($record->{$facet}, '*'), '*')) as $value) {
                     if (!empty($value)) {
                         $doc->addField($key . '_fc', $value);
                     }
                 }
                 break;
             default:
                 if (!empty($record->{$facet})) {
                     $doc->addField($key . '_fc', $record->{$facet});
                     // for faceting
                 }
                 break;
         }
     }
     return $doc;
 }
示例#6
0
 protected function buildViewFromDb($pk)
 {
     $output = new stdClass();
     $query = $this->db->getQuery(true);
     $query->select('*')->from('#__fabrik_lists')->where('id = ' . (int) $pk);
     $row = $this->db->setQuery($query)->loadObject();
     $params = new JRegistry($row->params);
     echo "<pre>";
     print_r($row);
     print_r($params);
     $output->title = $output->name = JStringNormalise::toUnderscoreSeparated($row->label);
     $output->ucm = false;
     $output->history = false;
     $output->database = new stdClass();
     $this->joins($output, $params);
     $output->created = $row->created;
     $output->created_by = $row->created_by_alias;
     $this->access($output, $params, $row);
     $output->list = new stdClass();
     $output->list->intro = $row->introduction;
     $output->list->heading = $row->label;
     $output->list->publishing = new stdClass();
     $output->list->publishing->published = $row->published;
     $output->list->publishing->up = $row->publish_up;
     $output->list->publishing->down = $row->publish_down;
     $output->list->nav = new stdClass();
     $output->list->nav->limit = (int) $row->rows_per_page;
     $output->list->nav->show = (bool) $params->get('show-table-nav', true);
     $output->list->nav->show_displaynum = (bool) $params->get('show_displaynum', true);
     $output->list->nav->show_total = (bool) $params->get('show-total', true);
     $output->list->nav->show_all_option = (bool) $params->get('showall-records', false);
     $output->list->template = $row->template;
     $output->list->order = [];
     $by = json_decode($row->order_by);
     if (!empty($by)) {
         $orderElements = $this->fieldFromElementId($by);
         $dirs = json_decode($row->order_dir);
         for ($i = 0; $i < count($by); $i++) {
             $order = new stdClass();
             $order->by = $orderElements[$i];
             $order->dir = $dirs[$i];
             $output->list->order[] = $order;
         }
     }
     $this->filters($output, $row, $params);
     $this->prefilters($output, $params);
     $output->list->toggle_cols = (bool) $params->get('toggle_cols');
     $output->list->list_filter_cols = (int) $params->get('list_filter_cols', 1);
     $output->list->empty_data_msg = $params->get('empty_data_msg');
     $output->list->outro = $params->get('outro');
     $output->list->show_add = $params->get('show-table-add');
     $output->list->sef_slug = $this->fieldFromElementId($params->get('sef-slug'));
     $output->list->admin_template = $params->get('admin_template');
     $output->list->show_title = $params->get('show-title');
     $this->pdf($output, $params);
     $this->bootstrap($output, $params);
     $this->tabs($output, $params);
     $output->list->action_method = $params->get('actionMethod', 'default');
     $output->list->checkbox_locaiton = $params->get('checkboxLocation', 'end');
     $output->list->note = $params->get('note');
     $output->list->alter_existing_db_cols = (bool) $params->get('alter_existing_db_cols');
     $output->list->process_jplugins = (bool) $params->get('process_jplugins');
     $output->list->enable_single_sorting = (bool) $params->get('enable_single_sorting');
     $output->list->collation = $params->get('collation');
     $output->list->disable_caching = (bool) $params->get('disable_caching', false);
     $output->list->distinct = (bool) $params->get('distinct', true);
     $output->list->join_display = $params->get('join-display');
     $output->list->delete_joined_rows = $params->get('delete-joined-rows');
     $output->list->show_related_add = $params->get('show_related_add');
     $output->list->show_related_info = $params->get('show_related_info');
     $output->list->isview = (bool) $params->get('isview', false);
     $this->groupby($output, $params, $row);
     $this->urls($output, $params);
     $this->feeds($output, $params);
     $this->csv($output, $params);
     $this->jSearch($output, $params);
     // Load in form - $row->form_id;
     // Build database structur - $row->db_table_name
     // Assign conncetion $row->connection_id
     return $output;
 }
 /**
  * Method to test JStringNormalise::toKey().
  *
  * @param   string  $expected  The expected value from the method.
  * @param   string  $input     The input value for the method.
  *
  * @return  void
  *
  * @dataProvider  seedToKey
  * @since   11.3
  */
 public function testToKey($expected, $input)
 {
     $this->assertEquals($expected, JStringNormalise::toKey($input));
 }
示例#8
0
 /**
  * This is always going to get the first instance of the module type unless
  * there is a title.
  *
  * @param   string  $module  The module name
  * @param   string  $title   Module title
  * @param   string  $style   Display style
  * @return  string
  */
 protected function byName($module, $title, $style = 'none')
 {
     $moduleinstance = $module . JStringNormalise::toCamelCase($title);
     if (!isset(self::$mods[$moduleinstance])) {
         self::$mods[$moduleinstance] = '';
         $document = \Document::instance();
         $renderer = $document->loadRenderer('module');
         $params = array('style' => $style);
         $mod = \Module::byName($module, $title);
         // If the module without the mod_ isn't found, try it with mod_.
         // This allows people to enter it either way in the content
         if (!isset($mod)) {
             $name = 'mod_' . $module;
             $mod = \Module::byName($name, $title);
         }
         ob_start();
         echo $renderer->render($mod, $params);
         self::$mods[$moduleinstance] = ob_get_clean();
     }
     return self::$mods[$moduleinstance];
 }
示例#9
0
 /**
  * Convert string into css class name
  *
  * @param   string  $input  string
  *
  * @return  string
  */
 protected function toVariable($input)
 {
     // Should simply be (except there's a bug in J)
     // JStringNormalise::toVariable($event->className);
     $input = trim($input);
     // Remove dashes and underscores, then convert to camel case.
     $input = JStringNormalise::toSpaceSeparated($input);
     $input = JStringNormalise::toCamelCase($input);
     // Remove leading digits.
     $input = preg_replace('#^[\\d\\.]*#', '', $input);
     // Lowercase the first character.
     $first = JString::substr($input, 0, 1);
     $first = JString::strtolower($first);
     // Replace the first character with the lowercase character.
     $input = JString::substr_replace($input, $first, 0, 1);
     return $input;
 }
示例#10
0
 /**
  * Helper wrapper method for toKey
  *
  * @param   string  $input  The string input (ASCII only).
  *
  * @return string  The key string.
  *
  * @see     JUserHelper::toKey()
  * @since   3.4
  */
 public function toKey($input)
 {
     return JStringNormalise::toKey($input);
 }
示例#11
0
 /**
  * Attach the details view as a PDF to the email
  *
  * @param   array  &$thisAttachments  Attachments
  *
  * @throws  RuntimeException
  *
  * @return  void
  */
 protected function pdfAttachement(&$thisAttachments)
 {
     $params = $this->getParams();
     if ($params->get('attach_pdf', 0) == 0) {
         return;
     }
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $config = JFactory::getConfig();
     $docType = $document->getType();
     $document->setType('pdf');
     $app = JFactory::getApplication();
     $input = $app->input;
     $orig['details'] = $input->get('view');
     $orig['format'] = $input->get('format');
     $input->set('view', 'details');
     $input->set('format', 'pdf');
     // Ensure the package is set to fabrik
     $prevUserState = $app->getUserState('com_fabrik.package');
     $app->setUserState('com_fabrik.package', 'fabrik');
     try {
         // Require files and set up DOM pdf
         require_once JPATH_SITE . '/components/com_fabrik/helpers/pdf.php';
         require_once JPATH_SITE . '/components/com_fabrik/controllers/details.php';
         FabrikPDFHelper::iniDomPdf();
         $dompdf = new DOMPDF();
         $size = strtoupper($params->get('pdf_size', 'A4'));
         $orientation = $params->get('pdf_orientation', 'portrait');
         $dompdf->set_paper($size, $orientation);
         // Store in output buffer
         ob_start();
         $controller = new FabrikControllerDetails();
         $controller->display();
         $html = ob_get_contents();
         ob_end_clean();
         // Load the HTML into DOMPdf and render it.
         $dompdf->load_html($html);
         $dompdf->render();
         // Store the file in the tmp folder so it can be attached
         $file = $config->get('tmp_path') . '/' . JStringNormalise::toDashSeparated($model->getForm()->label . '-' . $input->getString('rowid')) . '.pdf';
         $pdf = $dompdf->output();
         if (JFile::write($file, $pdf)) {
             $thisAttachments[] = $file;
         } else {
             throw new RuntimeException('Could not write PDF file to tmp folder');
         }
     } catch (Exception $e) {
         $app->enqueueMessage($e->getMessage(), 'error');
     }
     // Set the package back to what it was before rendering the module
     $app->setUserState('com_fabrik.package', $prevUserState);
     // Reset input
     foreach ($orig as $key => $val) {
         $input->set($key, $val);
     }
     // Reset document type
     $document->setType($docType);
 }
示例#12
0
文件: email.php 项目: glauberm/cinevi
 /**
  * Attach the details view as a PDF to the email
  *
  * @param   array  &$thisAttachments  Attachments
  *
  * @throws  RuntimeException
  *
  * @return  void
  */
 protected function pdfAttachment(&$thisAttachments)
 {
     $params = $this->getParams();
     if ($params->get('attach_pdf', 0) == 0) {
         return;
     }
     /** @var FabrikFEModelForm $model */
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $docType = $document->getType();
     $document->setType('pdf');
     $input = $this->app->input;
     $orig['details'] = $input->get('view');
     $orig['format'] = $input->get('format');
     $input->set('view', 'details');
     $input->set('format', 'pdf');
     // set editable false so things like getFormCss() pick up the detail, not form, CSS
     $model->setEditable(false);
     // Ensure the package is set to fabrik
     $prevUserState = $this->app->getUserState('com_fabrik.package');
     $this->app->setUserState('com_fabrik.package', 'fabrik');
     try {
         $model->getFormCss();
         foreach ($document->_styleSheets as $url => $ss) {
             $url = htmlspecialchars_decode($url);
             $formCss[] = file_get_contents($url);
         }
         // Require files and set up DOM pdf
         require_once JPATH_SITE . '/components/com_fabrik/helpers/pdf.php';
         require_once JPATH_SITE . '/components/com_fabrik/controllers/details.php';
         FabrikPDFHelper::iniDomPdf();
         $domPdf = new DOMPDF();
         $size = strtoupper($params->get('pdf_size', 'A4'));
         $orientation = $params->get('pdf_orientation', 'portrait');
         $domPdf->set_paper($size, $orientation);
         $controller = new FabrikControllerDetails();
         /**
          * $$$ hugh - stuff our model in there, with already formatted data, so it doesn't get rendered
          * all over again by the view, with unformatted data.  Should probably use a setModel() method
          * here instead of poking in to the _model, but I don't think there is a setModel for controllers?
          */
         $controller->_model = $model;
         $controller->_model->data = $this->getProcessData();
         // Store in output buffer
         ob_start();
         $controller->display();
         $html = ob_get_contents();
         ob_end_clean();
         if (!empty($formCss)) {
             $html = "<style>\n" . implode("\n", $formCss) . "</style>\n" . $html;
         }
         // Load the HTML into DOMPdf and render it.
         $domPdf->load_html(utf8_decode($html));
         $domPdf->render();
         // Store the file in the tmp folder so it can be attached
         $layout = FabrikHelperHTML::getLayout('form.fabrik-pdf-title');
         $displayData = new stdClass();
         $displayData->doc = $document;
         $displayData->model = $model;
         $fileName = $layout->render($displayData);
         $file = $this->config->get('tmp_path') . '/' . JStringNormalise::toDashSeparated($fileName) . '.pdf';
         $pdf = $domPdf->output();
         if (JFile::write($file, $pdf)) {
             $thisAttachments[] = $file;
         } else {
             throw new RuntimeException('Could not write PDF file to tmp folder');
         }
     } catch (Exception $e) {
         $this->app->enqueueMessage($e->getMessage(), 'error');
     }
     // set back to editable
     $model->setEditable(true);
     // Set the package back to what it was before rendering the module
     $this->app->setUserState('com_fabrik.package', $prevUserState);
     // Reset input
     foreach ($orig as $key => $val) {
         $input->set($key, $val);
     }
     // Reset document type
     $document->setType($docType);
 }
示例#13
0
 /**
  * Method to set an object property.
  *
  * When using getters/setters, it is worth noting that this method will
  * automatically call the getter after a property has been set to prime
  * and/or update the object cache.
  *
  * @param   string   $property   The property name.
  * @param   mixed    $value      The property value.
  * @param   boolean  $useMethod  True to use an available getter method, false otherwise.
  * @param   boolean  $useCache   True to try to load the data from cache, false otherwise.
  *
  * @return  void
  *
  * @since   12.1
  */
 protected function setProperty($property, $value, $useMethod = true, $useCache = true)
 {
     // Check if we should use the setter method.
     if ($useMethod) {
         // Get the property setter.
         $method = 'set' . JStringNormalise::toCamelCase($property);
         // Check for a setter method for the property.
         // Check that the property is not named "property" which would be recursive.
         if (in_array($method, $this->methods) && $method !== 'setProperty') {
             // Set the value using the setter.
             $this->{$method}($value);
             // Check if we should use cache.
             if ($useCache) {
                 // Load the property, not from cache.
                 $value = $this->getProperty($property, true, false);
                 // Store the value in cache.
                 $this->store($this->getStoreId($property), $value, false);
             }
             return;
         }
     }
     // Set the value.
     $this->properties[$property] = $value;
 }
示例#14
0
文件: field.php 项目: adjaika/J3Base
 /**
  * Method to instantiate the form field object.
  *
  * @param   JForm  $form  The form to attach to the form field object.
  *
  * @since   11.1
  */
 public function __construct($form = null)
 {
     // If there is a form passed into the constructor set the form and form control properties.
     if ($form instanceof JForm) {
         $this->form = $form;
         $this->formControl = $form->getFormControl();
     }
     // Detect the field type if not set
     if (!isset($this->type)) {
         $parts = JStringNormalise::fromCamelCase(get_called_class(), true);
         if ($parts[0] == 'J') {
             $this->type = JString::ucfirst($parts[count($parts) - 1], '_');
         } else {
             $this->type = JString::ucfirst($parts[0], '_') . JString::ucfirst($parts[count($parts) - 1], '_');
         }
     }
 }
示例#15
0
文件: html.php 项目: adjaika/J3Base
 /**
  * Method to get the view name
  *
  * The model name by default parsed using the classname, or it can be set
  * by passing a $config['name'] in the class constructor
  *
  * @return  string  The name of the model
  *
  * @since   3.2
  * @throws  Exception
  */
 public function getName()
 {
     if (empty($this->_name)) {
         $classname = get_class($this);
         $viewpos = strpos($classname, 'View');
         if ($viewpos === false) {
             throw new Exception(JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME'), 500);
         }
         $lastPart = substr($classname, $viewpos + 4);
         $pathParts = explode(' ', JStringNormalise::fromCamelCase($lastPart));
         if (!empty($pathParts[1])) {
             $this->_name = strtolower($pathParts[0]);
         } else {
             $this->_name = strtolower($lastPart);
         }
     }
     return $this->_name;
 }
示例#16
0
 /**
  * Split a string in camel case format
  *
  * "FooBarABCDef"            becomes  array("Foo", "Bar", "ABC", "Def");
  * "JFooBar"                 becomes  array("J", "Foo", "Bar");
  * "J001FooBar002"           becomes  array("J001", "Foo", "Bar002");
  * "abcDef"                  becomes  array("abc", "Def");
  * "abc_defGhi_Jkl"          becomes  array("abc_def", "Ghi_Jkl");
  * "ThisIsA_NASAAstronaut"   becomes  array("This", "Is", "A_NASA", "Astronaut")),
  * "JohnFitzgerald_Kennedy"  becomes  array("John", "Fitzgerald_Kennedy")),
  *
  * @param   string  $string  The source string.
  *
  * @return  array   The splitted string.
  *
  * @deprecated  12.3
  * @since   11.3
  */
 public static function splitCamelCase($string)
 {
     JLog::add('JString::splitCamelCase has been deprecated. Use JStringNormalise::fromCamelCase.', JLog::WARNING, 'deprecated');
     return JStringNormalise::fromCamelCase($string, true);
 }
示例#17
0
 /**
  * Method to change the title & alias.
  *
  * @param   integer $id    Article id
  * @param   integer $catId The id of the category.
  * @param   array   &$data The row data.
  *
  * @return    null
  */
 protected function generateNewTitle($id, $catId, &$data)
 {
     $table = JTable::getInstance('Content');
     $alias = JApplication::stringURLSafe(JStringNormalise::toDashSeparated($data['title']));
     $data['alias'] = $alias;
     $title = $data['title'];
     $titles = array();
     $aliases = array();
     // Test even if an existing article, we then remove that article title from the $titles array.
     // Means that changing an existing Fabrik title to an existing article title
     // should increment the Joomla article title.
     while ($table->load(array('alias' => $alias, 'catid' => $catId))) {
         $title = JString::increment($title);
         $titles[$table->get('id')] = $title;
         $alias = JString::increment($alias, 'dash');
         $aliases[$table->get('id')] = $alias;
     }
     unset($titles[$id]);
     unset($aliases[$id]);
     $title = empty($titles) ? $data['title'] : array_pop($titles);
     $alias = empty($aliases) ? $data['alias'] : array_pop($aliases);
     // Update the Fabrik record's title if the article alias changes..
     if ($title != $data['title']) {
         /** @var FabrikFEModelForm $formModel */
         $formModel = $this->getModel();
         $listModel = $formModel->getListModel();
         $pkName = $listModel->getPrimaryKey(true);
         $pk = ArrayHelper::getValue($this->data, $pkName);
         $titleField = $formModel->getElement($this->getParams()->get('title'), true);
         $titleField = $titleField->getFullName(false, false);
         $listModel->updateRows(array($pk), $titleField, $title);
     }
     $data['title'] = $title;
     $data['alias'] = $alias;
 }