function send($assets, $inline = false) { # Load javascript libraries $findjQuery = false; $this->Html->app = $this->app; // Incorporate controller set assets before sending if (!empty($this->assets['js'])) { $assets['js'] = array_merge($assets['js'], $this->assets['js']); } if (!empty($this->assets['css'])) { $assets['css'] = array_merge($assets['css'], $this->assets['css']); } cmsFramework::isRTL() and $assets['css'][] = 'rtl'; // For CB and JomSocial prevent jQuery from loading twice // Check is done against constants defined in those applications if (isset($assets['js']) && !empty($assets['js'])) { $findjQuery = array_search('jquery', $assets['js']); $findjQueryUI = array_search('jq.ui.core', $assets['js']); $findjQueryUICss = array_search('jq.ui.core', $assets['css']); if ($findjQuery !== false) { if (defined('J_JQUERY_LOADED') || defined('C_ASSET_JQUERY')) { unset($assets['js'][$findjQuery]); // unset($assets['js'][$findjQueryUI],$assets['css'][$findjQueryUI]); } else { define('J_JQUERY_LOADED', 1); define('C_ASSET_JQUERY', 1); } } } if (isset($assets['js']) && !empty($assets['js'])) { $this->Html->js(arrayFilter($assets['js'], $this->Libraries->js()), $inline); } # Load CSS stylesheets if (isset($assets['css']) && !empty($assets['css'])) { $findjQueryUI = array_search('jq.ui.core', $assets['css']); if ($findjQueryUI !== false) { if (defined('J_JQUERYUI_LOADED')) { unset($assets['css'][array_search('jq.ui.core', $assets['css'])]); } else { define('J_JQUERYUI_LOADED', 1); } } $this->Html->css(arrayFilter($assets['css'], $this->Libraries->css()), $inline); } # Set jQuery defaults if ($findjQuery && isset($assets['js']['jreviews'])) { ?> <script type="text/javascript"> jreviews.ajax_init(); </script> <?php } if (Sanitize::getBool($this->Config, 'ie6pngfix')) { $App =& App::getInstance($this->app); $AppPaths = $App->{$this->app . 'Paths'}; $jsUrl = isset($AppPaths['Javascript']['jquery/jquery.pngfix.pack.js']) ? $AppPaths['Javascript']['jquery/jquery.pngfix.pack.js'] : false; if ($jsUrl) { cmsFramework::addScript('<!--[if lte IE 6]><script type="text/javascript" src="' . $jsUrl . '"></script><script type="text/javascript">jQuery(document).ready(function(){jQuery(document).pngFix();});</script><![endif]-->'); } unset($App, $AppPaths); } }
/** * Dynamically replace the field tags with their labels/form field equivalents */ function afterFilter() { $output =& $this->output; $names = array(); $labels = array(); $select = array(); $cat_tag = false; $date_field = false; $cat_auto = Sanitize::getInt($this->params['module'], 'cat_auto'); $dir_id = $section_id = $cat_id = $criteria_id = ''; # Initialize FormHelper $Form = new FormHelper(); $CustomFields = new CustomFieldsHelper(); $CustomFields->Config =& $this->Config; # Process custom field tag attributes foreach ($this->fieldTags as $key => $value) { $var = explode('|', $value); if (!strstr($value, '_label')) { $names[$var[0]] = $value; } elseif (strstr($value, '_label')) { $labels[] = substr($value, 0, -6); } if ($value == 'category') { $cat_tag = true; /************************/ if (isset($var[1]) && $var[1] == 'm') { $category_select_type = ' multiple="multiple"'; } if (isset($var[2]) && (int) $var[2] > 0) { $category_select_size = ' size="' . $var[2] . '"'; } /************************/ } if (isset($var[1]) && strtolower($var[1]) == 'm') { $select[$var[0]] = 'selectmultiple'; } elseif (isset($var[1]) && strtolower($var[1]) == 's') { $select[$var[0]] = 'select'; } $select_size[$var[0]] = isset($var[2]) ? $var[2] : 5; # Check for category select list if ($var[0] == 'category') { if (isset($var[1]) && strtolower($var[1]) == 's') { $category_select_type = ' multiple="multiple"'; } if (isset($var[2]) && (int) $var[2] > 0) { $category_select_size = ' size="' . $var[2] . '"'; } } } # Get selected values from url $entry = array(); foreach ($this->params as $key => $value) { if (substr($key, 0, 3) == 'jr_') { $entry['Field']['pairs'][$key]['value'] = explode('_', $value); } // Add categories/sections } if (isset($this->params['tag'])) { $entry['Field']['pairs']['jr_' . $this->params['tag']['field']]['value'] = array($this->params['tag']['value']); } # Generate category list if tag found in view if ($cat_tag) { # Get module params before auto-detect $param_cat_id = Sanitize::getString($this->params['module'], 'cat_id'); $param_dir_id = Sanitize::getString($this->params['module'], 'dir_id'); $param_type_id = Sanitize::getString($this->params['module'], 'criteria_id'); # Category auto detect $ids = CommonController::_discoverIDs($this); if ($cat_auto) { extract($ids); } elseif ($this->cmsVersion != CMS_JOOMLA15) { isset($ids['cat_id']) and $cat_id = $ids['cat_id']; } if ($this->cmsVersion == CMS_JOOMLA15 && $section_id == '' && $cat_id != '') { $sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")"; $this->_db->setQuery($sql); $section_id = $this->_db->loadResult(); } $cat_id != '' and $this->params['module']['cat_id'] = $cat_id; $cat_id == '' and $section_id != '' and $this->params['module']['section_id'] = $section_id; $cat_id == '' and $criteria_id != '' and $this->params['module']['criteria_id'] = $criteria_id; if ($this->cmsVersion == CMS_JOOMLA15) { $categorySelect = $this->Category->categoryTree($this->_user->gid, $this->params); } else { $options = array('disabled' => false, 'cat_id' => !empty($param_cat_id) && !$cat_auto ? $param_cat_id : ($cat_auto ? $cat_id : ''), 'parent_id' => !empty($param_cat_id) && !$cat_auto ? $param_cat_id : ($cat_auto ? $cat_id : ''), 'dir_id' => !empty($param_dir_id) && !$cat_auto ? $param_dir_id : ($cat_auto ? $dir_id : ''), 'type_id' => !empty($param_type_id) && !$cat_auto ? $param_type_id : ($cat_auto ? $criteria_id : '')); if ($cat_auto && empty($options['cat_id'])) { $options['level'] = 1; } $categories = $this->Category->getCategoryList($options); // Now get the parent and sibling categories if ($cat_auto && isset($categories[$cat_id]) && count($categories) == 1) { $options['cat_id'] = $options['parent_id'] = $categories[$cat_id]->parent_id; $categories = $this->Category->getCategoryList($options); } $categorySelect = $Form->select('data[categories]', array_merge(array(array('value' => null, 'text' => '- ' . __t("Select Category", true) . ' -')), $categories), $cat_id, array('class' => 'jrSelect')); } $output = str_replace('{' . $names['category'] . '}', $categorySelect, $output); } $fields = $this->Field->getFieldsArrayFromNames(array_keys($names), 'listing', $entry); # Replace label tags and change field type based on view atttributes if ($fields) { foreach ($fields as $key => $group) { foreach ($group['Fields'] as $name => $field) { if (isset($select[$name])) { $fields[$key]['Fields'][$name]['type'] = $select[$name]; $fields[$key]['Fields'][$name]['properties']['size'] = $select_size[$name]; } elseif ($fields[$key]['Fields'][$name]['type'] == 'textarea') { $fields[$key]['Fields'][$name]['type'] = 'text'; } if (in_array($name, $labels)) { $output = str_replace('{' . $name . '_label}', $field['title'], $output); } if ($field['type'] == 'date') { $date_field = true; } } } $search = true; $location = 'listing'; $CustomFields->form_id = Sanitize::getInt($this->params, 'module_id'); $formFields = $CustomFields->getFormFields($fields, $location, $search, __t("Select", true)); # Replace input tags foreach ($names as $key => $name) { if (isset($formFields["data[Field][Listing][{$key}]"])) { $output = str_replace('{' . $names[$key] . '}', $formFields["data[Field][Listing][{$key}]"], $output); } } # Load js and css if ($date_field) { $Html = ClassRegistry::getClass('HtmlHelper'); $Html->app = 'jreviews'; $Libraries = ClassRegistry::getClass('LibrariesHelper'); $Html->js(arrayFilter(array('jq.ui.core', 'jq.ui.datepicker'), $Libraries->js())); $Html->css(arrayFilter(array('jq.ui.core'), $Libraries->css()), false); ?> <script type="text/javascript">jreviews.datepicker();</script> <?php } } return $output; }
function send($assets, $inline = false) { # Load javascript libraries $findjQuery = false; $this->Html->app = $this->app; unset($this->viewVars); /** * Send cachable scripts to the head tag from controllers and components by adding it to the head array */ if (!empty($this->assets['head-top'])) { foreach ($this->assets['head-top'] as $head) { cmsFramework::addScript($head); } } // Incorporate controller set assets before sending if (!empty($this->assets['js'])) { $assets['js'] = array_merge($assets['js'], $this->assets['js']); } if (!empty($this->assets['css'])) { $assets['css'] = array_merge($assets['css'], $this->assets['css']); } $assets['css'][] = 'custom_styles'; cmsFramework::isRTL() and $assets['css'][] = 'rtl'; # Load CSS stylesheets if (isset($assets['css']) && !empty($assets['css'])) { $findjQueryUI = array_search('jq.ui.core', $assets['css']); if ($findjQueryUI !== false) { if (defined('J_JQUERYUI_LOADED')) { unset($assets['css'][array_search('jq.ui.core', $assets['css'])]); } else { define('J_JQUERYUI_LOADED', 1); } } $this->Html->css(arrayFilter($assets['css'], $this->Libraries->css()), $inline); } // For CB // Check is done against constants defined in those applications if (isset($assets['js']) && !empty($assets['js'])) { $findjQuery = array_search('jquery', $assets['js']); $findjQueryUI = array_search('jq.ui.core', $assets['js']); if ($findjQuery !== false) { if (defined('J_JQUERY_LOADED') || JFactory::getApplication()->get('jquery')) { unset($assets['js'][$findjQuery]); } else { define('J_JQUERY_LOADED', 1); // JFactory::getApplication()->set('jquery', true); This was for Warp, but it loads too late. jQuery must be manually disabled in the configuration // define( 'C_ASSET_JQUERY', 1 ); } } if ($findjQueryUI != false) { $locale = cmsFramework::locale(); $assets['js'][] = 'jquery/i18n/jquery.ui.datepicker-' . $locale; } } if (isset($assets['js']) && !empty($assets['js'])) { $this->Html->js(arrayFilter($assets['js'], $this->Libraries->js()), $inline); } # Set jQuery defaults if ($findjQuery && isset($assets['js']['jreviews'])) { ?> <script type="text/javascript"> /* <![CDATA[ */ jreviews.ajax_init(); /* ]]> */ </script> <?php } if (isset($this->Config) && Sanitize::getBool($this->Config, 'ie6pngfix')) { $App =& App::getInstance($this->app); $AppPaths = $App->{$this->app . 'Paths'}; $jsUrl = isset($AppPaths['Javascript']['jquery/jquery.pngfix.pack.js']) ? $AppPaths['Javascript']['jquery/jquery.pngfix.pack.js'] : false; if ($jsUrl) { cmsFramework::addScript('<!--[if lte IE 6]><script type="text/javascript" src="' . $jsUrl . '"></script><script type="text/javascript">jQuery(document).ready(function(){jQuery(document).pngFix();});</script><![endif]-->'); } unset($App, $AppPaths); } /** * Send cachable scripts to the head tag from controllers and components by adding it to the head array */ if (!empty($this->assets['head'])) { foreach ($this->assets['head'] as $head) { cmsFramework::addScript($head); } } }
function onProfileDisplay() { if (!file_exists($this->_path . DS . 'admin.jreviews.php')) { return JText::_('jReviews is not installed. Please contact site administrator.'); } else { $user = CFactory::getActiveProfile(); $userId = $user->id; $cacheSetting = $this->params->get('cache', 1) ? JApplication::getCfg('caching') : 0; # Load CSS stylesheets -- done here because when cache is on css is not loaded if ($cacheSetting) { # MVC initalization script if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } require 'components' . DS . 'com_jreviews' . DS . 'jreviews' . DS . 'framework.php'; //Create config file $eParams['data']['controller'] = 'common'; $eParams['data']['action'] = 'index'; $Dispatcher = new S2Dispatcher('jreviews', false, true); $Dispatcher->dispatch($eParams); unset($Dispatcher); $Access = Configure::read('JreviewsSystem.Access'); $Config = Configure::read('JreviewsSystem.Config'); App::import('Helper', 'html'); $Html = ClassRegistry::getClass('HtmlHelper'); $Html->viewTheme = $Config->template; $Html->app = 'jreviews'; App::import('Helper', 'libraries', 'jreviews'); $Libraries = ClassRegistry::getClass('LibrariesHelper'); $Libraries->Config = $Config; $assets = array('css' => array('theme', 'theme.detail', 'theme.form', 'jq.ui.core', 'paginator'), 'js' => array('jreviews', 'jquery' => 'jquery', 'jq.ui.core', 'jq.jreviews.plugins')); if ($Access->canAddReview() || $Access->isEditor()) { $assets['js'][] = 'jreviews.fields'; if ($Config->rating_selector == 'stars') { $assets['js'][] = 'jq.ui.rating'; } $assets['js'][] = 'jq.tooltip'; } $Html->css(arrayFilter($assets['css'], $Libraries->css())); $Html->js(arrayFilter($assets['js'], $Libraries->js())); ?> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function() { <?php if ($Access->canAddReview && !$Access->moderateReview() && $Config->facebook_enable && $Config->facebook_reviews) { ?> if(!jQuery('#fb-root').length) jQuery("body").append('<div id="fb-root"></div>'); jreviews.facebook.init({ 'appid':'<?php echo $Config->facebook_appid; ?> ', 'optout':<?php echo $Config->facebook_optout; ?> , 'success':function(){ jreviews.facebook.checkPermissions({ 'onPermission':function(){jreviews.facebook.setCheckbox('jr_submitButton',true);}, 'onNoSession':function(){jreviews.facebook.setCheckbox('jr_submitButton',false);} }); }, 'publish_text': '<?php __t("Publish to Facebook", false, true); ?> ' }); <?php } ?> }); /* ]]> */ </script> <?php } $cache =& JFactory::getCache('plgCommunityJreviews_reviewme'); $cache->setCaching($cacheSetting); $callback = array('plgCommunityJreviews_reviewme', '_getPage'); $contents = $cache->call($callback, $userId, $this->params, $cacheSetting); return $contents; } }