/** * Gets the currencies * @return array List of currencies */ function getData() { // Lets load the data if it doesn't already exist if (empty($this->_data)) { $query = $this->_buildQuery(); $this->_data = $this->_getList($query, 0, 1); if (!count($this->_data)) { JError::raiseError(404, JText::_('COM_CONTENTBUILDER_FORM_NOT_FOUND')); } foreach ($this->_data as $data) { if (!$this->frontend && $data->display_in == 0) { JError::raiseError(404, JText::_('COM_CONTENTBUILDER_RECORD_NOT_FOUND')); } else { if ($this->frontend && $data->display_in == 1) { JError::raiseError(404, JText::_('COM_CONTENTBUILDER_RECORD_NOT_FOUND')); } } $data->show_page_heading = $this->_show_page_heading; $data->limited_options = $this->frontend ? $data->limited_article_options_fe : $data->limited_article_options; $data->form_id = $this->_id; $data->record_id = $this->_record_id; if ($data->type && $data->reference_id) { // article options $this->_db->setQuery("Select content.id, content.modified_by, content.version, content.hits, content.catid From #__contentbuilder_articles As articles, #__content As content Where (content.state = 1 Or content.state = 0) And content.id = articles.article_id And articles.form_id = " . $this->_id . " And articles.record_id = " . $this->_db->Quote($this->_record_id)); $article = $this->_db->loadAssoc(); if ($data->create_articles) { if (!$this->is15) { // JOOMLA 1.6 params retrieval jimport('joomla.form.form'); JForm::addFormPath(JPATH_SITE . '/administrator/components/com_contentbuilder/models/forms'); JForm::addFieldPath(JPATH_SITE . '/administrator/components/com_content/models/fields'); $form = JForm::getInstance('com_content.article', 'article', array('control' => 'jform', 'load_data' => true)); if (is_array($article)) { $table = JTable::getInstance('content'); $loaded = $table->load($article['id']); if ($loaded) { // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $item = JArrayHelper::toObject($properties, 'JObject'); if (property_exists($item, 'params')) { $registry = new JRegistry(); if (!$this->is30) { $registry->loadJSON($item->params); } else { $registry->loadString($item->params); } $item->params = $registry->toArray(); } // Convert the params field to an array. $registry = new JRegistry(); if (!$this->is30) { $registry->loadJSON($item->attribs); } else { $registry->loadString($item->attribs); } $item->attribs = $registry->toArray(); // Convert the params field to an array. $registry = new JRegistry(); if (!$this->is30) { $registry->loadJSON($item->metadata); } else { $registry->loadString($item->metadata); } $item->metadata = $registry->toArray(); $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext; // Import the approriate plugin group. JPluginHelper::importPlugin('content'); // Get the dispatcher. $dispatcher = JDispatcher::getInstance(); // Trigger the form preparation event. $results = $dispatcher->trigger('onContentPrepareForm', array($form, $item)); // Check for errors encountered while preparing the form. if (count($results) && in_array(false, $results, true)) { // Get the last error. $error = $dispatcher->getError(); // Convert to a JException if necessary. if (!JError::isError($error)) { throw new Exception($error); } } $form->bind($item); $data->sectioncategories = array(); $data->row = $item; $data->lists = array(); } else { $data->sectioncategories = array(); $data->row = new stdClass(); $data->row->title = ''; $data->row->alias = ''; // special for 1.5 $data->lists = array('state' => '', 'frontpage' => '', 'sectionid' => '', 'catid' => ''); // special for 1.5 } $data->article_settings = new stdClass(); $data->article_settings->modified_by = $article['modified_by']; $data->article_settings->version = $article['version']; $data->article_settings->hits = $article['hits']; $data->article_settings->catid = $article['catid']; } else { $data->article_settings = new stdClass(); $data->article_settings->modified_by = 0; $data->article_settings->version = 0; $data->article_settings->hits = 0; $data->article_settings->catid = 0; } $data->article_options = $form; // article options end // Joomla 1.6 params retrieval end } else { // Joomla 1.5 params retrieval if (!$data->limited_options) { $form = new JParameter('', JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_content' . DS . 'models' . DS . 'article.xml'); } else { $form = new JParameter('', JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_contentbuilder' . DS . 'assets' . DS . 'article.xml'); } $table = JTable::getInstance('content'); // sections $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\""; $query = 'SELECT s.id, s.title' . ' FROM #__sections AS s' . ' ORDER BY s.ordering'; $this->_db->setQuery($query); $seections = array(); $sections[] = JHTML::_('select.option', '-1', '- ' . JText::_('Select Section') . ' -', 'id', 'title'); $sections[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'id', 'title'); $sections = array_merge($sections, $this->_db->loadObjectList()); // categories foreach ($sections as $section) { $section_list[] = (int) $section->id; } $sectioncategories = array(); $sectioncategories[-1] = array(); $sectioncategories[-1][] = JHTML::_('select.option', '-1', JText::_('Select Category'), 'id', 'title'); $section_list = implode('\', \'', $section_list); $query = 'SELECT id, title, section' . ' FROM #__categories' . ' WHERE section IN ( \'' . $section_list . '\' )' . ' ORDER BY ordering'; $this->_db->setQuery($query); $cat_list = $this->_db->loadObjectList(); // Uncategorized category mapped to uncategorized section $uncat = new stdClass(); $uncat->id = 0; $uncat->title = JText::_('Uncategorized'); $uncat->section = 0; $cat_list[] = $uncat; foreach ($sections as $section) { $sectioncategories[$section->id] = array(); $rows2 = array(); foreach ($cat_list as $cat) { if ($cat->section == $section->id) { $rows2[] = $cat; } } foreach ($rows2 as $row2) { $sectioncategories[$section->id][] = JHTML::_('select.option', $row2->id, $row2->title, 'id', 'title'); } } $sectioncategories['-1'][] = JHTML::_('select.option', '-1', JText::_('Select Category'), 'id', 'title'); $categories = array(); foreach ($cat_list as $cat) { $categories[] = $cat; } $categories[] = JHTML::_('select.option', '-1', JText::_('Select Category'), 'id', 'title'); if (is_array($article)) { $loaded = $table->load($article['id']); if ($loaded) { // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $item = JArrayHelper::toObject($properties, 'JObject'); $form->set('created_by', $item->created_by); $form->set('access', $item->access); $form->set('created_by_alias', $item->created_by_alias); $form->set('created', JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S')); $form->set('publish_up', JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S')); if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $this->_db->getNullDate()) { $form->set('publish_down', JText::_('Never')); } else { $form->set('publish_down', JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S')); } // Advanced Group $form->loadINI($item->attribs); // Metadata Group $form->set('description', $item->metadesc); $form->set('keywords', $item->metakey); $form->loadINI($item->metadata); $lists['state'] = JHTML::_('select.booleanlist', 'state', '', $item->state); $query = 'SELECT COUNT(content_id)' . ' FROM #__content_frontpage' . ' WHERE content_id = ' . (int) $item->id; $this->_db->setQuery($query); $item->frontpage = $this->_db->loadResult(); if (!$item->frontpage) { $item->frontpage = 0; } $lists['frontpage'] = JHTML::_('select.booleanlist', 'frontpage', '', $item->frontpage); $lists['sectionid'] = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'id', 'title', intval($item->sectionid)); $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval($item->catid)); $query = 'SELECT ordering AS value, title AS text FROM #__content WHERE catid = ' . (int) $data->default_category . ' AND state > ' . (int) "-1" . ' ORDER BY ordering'; $lists['ordering'] = JHTML::_('list.specificordering', $table, $article['id'], $query, 1); $data->sectioncategories = $sectioncategories; $data->row = $item; // special for 1.5 $data->lists = $lists; } else { $data->sectioncategories = $sectioncategories; $data->row = $table; // special for 1.5 $fplist = JHTML::_('select.booleanlist', 'frontpage', '', 0); $sectionid = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'id', 'title', intval($item->sectionid)); $catid = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', 0); // Select List: Category Ordering $query = 'SELECT ordering AS value, title AS text FROM #__content WHERE catid = ' . (int) $data->default_category . ' AND state > ' . (int) "-1" . ' ORDER BY ordering'; $olist = JHTML::_('list.specificordering', $table, 0, $query, 1); $data->lists = array('ordering' => $olist, 'state' => '', 'frontpage' => $fplist, 'sectionid' => $sectionid, 'catid' => $catid); // special for 1.5 } $data->article_settings = new stdClass(); $data->article_settings->modified_by = $article['modified_by']; $data->article_settings->version = $article['version']; $data->article_settings->hits = $article['hits']; $data->article_settings->catid = $article['catid']; } else { $data->sectioncategories = $sectioncategories; $data->row = $table; // special for 1.5 $fplist = JHTML::_('select.booleanlist', 'frontpage', '', 0); $sectionid = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" ' . $javascript, 'id', 'title', 0); $catid = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', 0); // Select List: Category Ordering $query = 'SELECT ordering AS value, title AS text FROM #__content WHERE catid = ' . (int) $data->default_category . ' AND state > ' . (int) "-1" . ' ORDER BY ordering'; $olist = JHTML::_('list.specificordering', $table, 0, $query, 1); $data->lists = array('ordering' => $olist, 'state' => '', 'frontpage' => $fplist, 'sectionid' => $sectionid, 'catid' => $catid); // special for 1.5 $data->article_settings = new stdClass(); $data->article_settings->modified_by = 0; $data->article_settings->version = 0; $data->article_settings->hits = 0; $data->article_settings->catid = 0; } $data->article_options = $form; // Joomla 1.5 params retrieval end } } $data->back_button = JRequest::getBool('latest', 0) && !JRequest::getCmd('record_id', '') ? false : $this->_show_back_button; $data->latest = $this->_latest; $data->is15 = $this->is15; $data->frontend = $this->frontend; $data->form = contentbuilder::getForm($data->type, $data->reference_id); if (!$data->form->exists) { JError::raiseError(404, JText::_('COM_CONTENTBUILDER_FORM_NOT_FOUND')); } $data->page_title = ''; if (JRequest::getInt('cb_prefix_in_title', 1)) { if (!$this->_menu_item) { $data->page_title = $data->use_view_name_as_title ? $data->name : $data->form->getPageTitle(); } else { $data->page_title = $data->use_view_name_as_title ? $data->name : JFactory::getDocument()->getTitle(); } } $data->labels = $data->form->getElementLabels(); $ids = array(); foreach ($data->labels as $reference_id => $label) { $ids[] = $this->_db->Quote($reference_id); } if (count($ids)) { $this->_db->setQuery("Select Distinct `label`, reference_id From #__contentbuilder_elements Where form_id = " . intval($this->_id) . " And reference_id In (" . implode(',', $ids) . ") And published = 1 Order By ordering"); $rows = $this->_db->loadAssocList(); $ids = array(); foreach ($rows as $row) { $ids[] = $row['reference_id']; } } $data->items = $data->form->getRecord($this->_record_id, $data->published_only, $this->frontend ? $data->own_only_fe ? JFactory::getUser()->get('id', 0) : -1 : ($data->own_only ? JFactory::getUser()->get('id', 0) : -1), $this->frontend ? $data->show_all_languages_fe : true); if (count($data->items)) { $user = null; if ($data->act_as_registration) { $meta = $data->form->getRecordMetadata($this->_record_id); $this->_db->setQuery("Select * From #__users Where id = " . $meta->created_id); $user = $this->_db->loadObject(); } $label = ''; foreach ($data->items as $rec) { if ($rec->recElementId == $data->title_field) { if ($data->act_as_registration && $user !== null) { if ($data->registration_name_field == $rec->recElementId) { $rec->recValue = $user->name; } else { if ($data->registration_username_field == $rec->recElementId) { $item->recValue = $user->username; } else { if ($data->registration_email_field == $item->recElementId) { $rec->recValue = $user->email; } else { if ($data->registration_email_repeat_field == $rec->recElementId) { $rec->recValue = $user->email; } } } } } $label = cbinternal($rec->recValue); break; } } // trying first element if no title field given if (!$label) { $label = cbinternal($data->items[0]->recValue); } // "buddy quaid hack", should be an option in future versions jimport('joomla.version'); $version = new JVersion(); if (version_compare($version->getShortVersion(), '1.6', '>=')) { if ($this->_show_page_heading && $this->_page_title != '' && $this->_page_heading != '' && $this->_page_title == $this->_page_heading) { $data->page_title = $this->_page_title; } else { $data->page_title .= $label ? (!$data->page_title ? '' : ': ') . $label : ''; } } else { if ($this->_show_page_heading && $this->_page_title != '' && !JRequest::getInt('cb_prefix_in_title', 1)) { $data->page_title = $this->_page_title; } else { $data->page_title .= $label ? (!$data->page_title ? '' : ': ') . $label : ''; } } if ($this->frontend) { $document = JFactory::getDocument(); $document->setTitle(html_entity_decode($data->page_title, ENT_QUOTES, 'UTF-8')); } } //if(!$data->edit_by_type){ $i = 0; $api_items = ''; $api_names = $data->form->getElementNames(); $cntItems = count($api_names); foreach ($api_names as $reference_id => $api_name) { $api_items .= '"' . addslashes($api_name) . '": "' . addslashes($reference_id) . '"' . ($i + 1 < $cntItems ? ',' : ''); $i++; } $items = $api_items; JFactory::getDocument()->addScriptDeclaration(' <!-- var contentbuilder = new function(){ this.items = {' . $items . '}; var items = this.items; this._ = function(name){ var els = document.getElementsByName("cb_"+items[name]); if(els.length == 0){ els = document.getElementsByName("cb_"+items[name]+"[]"); } return els.length == 1 ? els[0] : els; }; var _ = this._; this.urldecode = function (str) { return decodeURIComponent((str+\'\').replace(/\\+/g, \'%20\')); }; this.getQuery = function ( name ){ name = name.replace(/[\\[]/,"\\\\[").replace(/[\\]]/,"\\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ){ return null; } else { return this.urldecode(results[1]); } }; this.onClick = function(name, func){ if(typeof func != "function") return; var els = document.getElementsByName("cb_"+items[name]); if(els.length == 0){ els = document.getElementsByName("cb_"+items[name]+"[]"); } for(var i = 0; i < els.length; i++){ els[i].onclick = func; } }; this.onFocus = function(name, func){ if(typeof func != "function") return; var els = document.getElementsByName("cb_"+items[name]); if(els.length == 0){ els = document.getElementsByName("cb_"+items[name]+"[]"); } for(var i = 0; i < els.length; i++){ els[i].onfocus = func; } }; this.onBlur = function(name, func){ if(typeof func != "function") return; var els = document.getElementsByName("cb_"+items[name]); if(els.length == 0){ els = document.getElementsByName("cb_"+items[name]+"[]"); } for(var i = 0; i < els.length; i++){ els[i].onblur = func; } }; this.onChange = function(name, func){ if(typeof func != "function") return; var els = document.getElementsByName("cb_"+items[name]); if(els.length == 0){ els = document.getElementsByName("cb_"+items[name]+"[]"); } for(var i = 0; i < els.length; i++){ els[i].onchange = func; } }; this.onSelect = function(name, func){ if(typeof func != "function") return; var els = document.getElementsByName("cb_"+items[name]); if(els.length == 0){ els = document.getElementsByName("cb_"+items[name]+"[]"); } for(var i = 0; i < els.length; i++){ els[i].onselect = func; } }; this.submitReady = function(){ return true; }; var _submitReady = this.submitReady; this.onSubmit = function(){ if(arguments.length > 0 && typeof arguments[0] == "function") { _submitReady = arguments[0]; return; } if(typeof _submitReady == "function" && _submitReady()) { document.adminForm.submit(); } }; } //--> '); //} $data->template = contentbuilder::getEditableTemplate($this->_id, $this->_record_id, $data->items, $ids, !$data->edit_by_type); $metadata = $data->form->getRecordMetadata($this->_record_id); if ($metadata instanceof stdClass && $data->metadata) { $data->created = $metadata->created ? $metadata->created : ''; $data->created_by = $metadata->created_by ? $metadata->created_by : ''; $data->modified = $metadata->modified ? $metadata->modified : ''; $data->modified_by = $metadata->modified_by ? $metadata->modified_by : ''; } else { $data->created = ''; $data->created_by = ''; $data->modified = ''; $data->modified_by = ''; } } return $data; } } return null; }