Beispiel #1
0
 function click2Search($field, $criteriaid, $catid, $Itemid)
 {
     if (isset($field['properties']['click2search'])) {
         $Itemid = $Itemid ? $Itemid : '';
         if (isset($field['properties']['click2searchlink']) && $field['properties']['click2searchlink'] != '') {
             $click2searchlink = $field['properties']['click2searchlink'];
         } else {
             $click2searchlink = 'index.php?option=' . S2Paths::get('jreviews', 'S2_CMSCOMP') . '&Itemid={ITEMID}&url=tag/{FIELDNAME}/{FIELDTEXT}/criteria' . _PARAM_CHAR . '{CRITERIAID}';
         }
         foreach ($this->output as $key => $text) {
             if ($field['type'] == 'date') {
                 $field['value'][$key] = str_replace(' 00:00:00', '', $field['value'][$key]);
             }
             $url = $click2searchlink;
             if ($Itemid > 0) {
                 $url = str_replace('{ITEMID}', $Itemid, $url);
             } else {
                 $url = str_replace(array('_m{ITEMID}', '&Itemid={ITEMID}'), '', $url);
             }
             $url = str_ireplace(array('{FIELDNAME}', '{FIELDTEXT}', '{CRITERIAID}', '{CATID}'), array(substr($field['name'], 3), urlencode($field['value'][$key]), urlencode($criteriaid), urlencode($catid)), $url);
             $url = s2ampReplace($url);
             $url = cmsFramework::route($url);
             $this->output[$key] = "<a href=\"{$url}\">{$text}</a>";
         }
     }
 }
Beispiel #2
0
 function generateFormSelect($orderingList, $selected, $attributes)
 {
     # Construct new route
     $new_route = cmsFramework::constructRoute($this->passedArgs, array('order', 'page'));
     $selectList = array();
     foreach ($orderingList as $value => $text) {
         $selectList[] = array('value' => cmsFramework::route($new_route . '/order' . _PARAM_CHAR . $value), 'text' => $text);
     }
     $selected = cmsFramework::route($new_route . '/order' . _PARAM_CHAR . $selected);
     return $this->Form->select('order', $selectList, $selected, $attributes);
 }
Beispiel #3
0
    function Categories()
    {
        $assets = array('js' => array('jreviews', 'jquery', 'jreviews.compare', 'jq.ui.core', 'jq.ui.slider', 'jq.json', 'jq.jsoncookie'), 'css' => array('theme', 'theme.list', 'paginator', 'jq.ui.core'));
        $this->_user->id > 0 and array_push($assets['js'], 'jq.jreviews.plugins');
        ?>

        <script type="text/javascript">
        jQuery(document).ready(function() {                                                 
            jreviewsCompare.set({
                'numberOfListingsPerPage':<?php 
        echo Sanitize::getInt($this->Config, 'list_compare_columns', 3);
        ?>
,
                'lang': {
                    'compare_all':'<?php 
        __t("Compare All", false, true);
        ?>
',
                    'remove_all':'<?php 
        __t("Remove All", false, true);
        ?>
',
                    'select_more':'<?php 
        __t("You need to select more than one listing for comparison!", false, true);
        ?>
'
                },
                'compareURL':'<?php 
        echo cmsFramework::route('index.php?option=com_jreviews&url=categories/compare/type:type_id/');
        ?>
'
            });
            <?php 
        if ($this->action == 'compare') {
            ?>
jreviewsCompare.initComparePage();<?php 
        }
        ?>
    
            jreviewsCompare.initCompareDashboard();
            <?php 
        if ($this->action != 'compare') {
            ?>
jreviewsCompare.initListPage();<?php 
        }
        ?>
            // fix the height of divs on comparison page after everything is loaded    
            jQuery(window).load(function(){ jreviewsCompare.fixCompareImagesAlignment(); });             
        });
        </script>   
       
		<?php 
        $this->send($assets);
    }
 function _process()
 {
     $urlSeparator = "_";
     $simple_search = Sanitize::getInt($this->data, 'simple_search');
     $keywords = Sanitize::getVar($this->data, 'keywords');
     $criteria = isset($this->data['Search']) ? Sanitize::getInt($this->data['Search'], 'criteria_id') : null;
     $dir = str_replace(array(',', ' '), array($urlSeparator, ''), Sanitize::getString($this->data, 'dir'));
     $cat = str_replace(array(',', ' '), array($urlSeparator, ''), Sanitize::getString($this->data, 'cat'));
     $section = str_replace(array(',', ' '), array($urlSeparator, ''), Sanitize::getString($this->data, 'section'));
     /*J15*/
     $order = Sanitize::getVar($this->data, 'order');
     $query_type = Sanitize::getVar($this->data, 'search_query_type');
     $scope = Sanitize::getVar($this->data, 'contentoptions');
     $author = Sanitize::getString($this->data, 'author');
     $categories = Sanitize::getVar($this->data, 'categories');
     $menu_id = Sanitize::getInt($this->data, 'menu_id');
     $tmpl_suffix = Sanitize::getString($this->data, 'tmpl_suffix');
     $illegal_chars = array('#', '/', '?', ':', urldecode('%E3%80%80'));
     // Last one is japanese double space
     $sort = '';
     # Load Routes helper
     App::import('Helper', 'routes', 'jreviews');
     $Routes = new RoutesHelper();
     // Replace ampersands with temp string to be replaced back as urlencoded ampersand further below
     $keywords = str_replace(array_keys($this->KeywordReplacementMask), array_values($this->KeywordReplacementMask), $keywords);
     # Get the Itemid
     $menu_id_param = $menu_id > 0 ? $menu_id : '';
     $url_params = '';
     # SIMPLE SEARCH
     if ($simple_search) {
         # Build the query string
         if (trim($keywords) != '') {
             $url_params .= (cmsFramework::mosCmsSef() ? '' : '/') . 'keywords' . _PARAM_CHAR . str_replace(' ', '+', urlencode(str_replace($illegal_chars, ' ', $keywords)));
         }
         !empty($dir) and $url_params .= "/dir" . _PARAM_CHAR . $dir;
         !empty($section) and $url_params .= "/cat" . _PARAM_CHAR . 's' . $section;
         /*J15*/
         !empty($cat) and $url_params .= "/cat" . _PARAM_CHAR . $cat;
         !empty($tmpl_suffix) and $url_params .= '/tmpl_suffix' . _PARAM_CHAR . $tmpl_suffix;
         !empty($order) and $sort = '/order' . _PARAM_CHAR . $order;
         # Checks if need to keep the Itemid on the result page
         if ($this->Config->search_itemid && $menu_id) {
             $url = $Routes->search_results($menu_id_param, '');
         } else {
             $url = $Routes->search_results(null, '');
         }
         $url = cmsFramework::route($url . $url_params . $sort);
         $url = str_replace(array_keys($this->KeywordReplacementUrl), array_values($this->KeywordReplacementUrl), $url);
         cmsFramework::redirect($url);
         exit;
     }
     # ADVANCED SEARCH
     $url_params = array();
     $criteria_param = $criteria ? (cmsFramework::mosCmsSef() ? '' : '/') . 'criteria:' . $criteria : '';
     // Search query type
     !empty($query_type) and $url_params[] = "query" . _PARAM_CHAR . $query_type;
     !empty($dir) != '' and $url_params[] = "dir" . _PARAM_CHAR . $dir;
     // Listing and reviews
     if ($keywords) {
         if ($scope) {
             $url_params[] = "scope" . _PARAM_CHAR . urlencode(implode($urlSeparator, $scope));
         }
         $url_params[] = "keywords" . _PARAM_CHAR . urlencode(str_replace($illegal_chars, ' ', $keywords));
     }
     // Author
     !empty($author) and $url_params[] = "author" . _PARAM_CHAR . urlencode($author);
     // Categories
     if (is_array($categories)) {
         // Remove empty values from array
         foreach ($categories as $index => $value) {
             if (empty($value)) {
                 unset($categories[$index]);
             }
         }
         if (!empty($categories)) {
             $cat = urlencode(implode($urlSeparator, $categories));
             !empty($cat) and $url_params[] = "cat" . _PARAM_CHAR . $cat;
         }
     } elseif ($categories != '') {
         // Single select category list
         !empty($categories) and $url_params[] = "cat" . _PARAM_CHAR . $categories;
     }
     // First pass to process numeric values, need to merge operator and operand into one parameter
     if (isset($this->data['Field'])) {
         foreach ($this->data['Field']['Listing'] as $key => $value) {
             if (substr($key, -9, 9) == '_operator') {
                 $operand = substr($key, 0, -9);
                 if (is_array($this->data['Field']['Listing'][$operand]) && is_numeric($this->data['Field']['Listing'][$operand][0]) || is_numeric($this->data['Field']['Listing'][$operand])) {
                     $this->data['Field']['Listing'][$operand] = $value . $urlSeparator . trim(implode('_', $this->data['Field']['Listing'][$operand]));
                 } elseif (is_array($this->data['Field']['Listing'][$operand]) && trim($this->data['Field']['Listing'][$operand][0]) != '' || !is_array($this->data['Field']['Listing'][$operand]) && trim($this->data['Field']['Listing'][$operand]) != '') {
                     // Assume it's a date field
                     $this->data['Field']['Listing'][$operand] = $value . $urlSeparator . "date_" . implode('_', $this->data['Field']['Listing'][$operand]);
                 } else {
                     $this->data['Field']['Listing'][$operand] = '';
                 }
                 // Remove trailing separator char
                 $this->data['Field']['Listing'][$operand] = rtrim($this->data['Field']['Listing'][$operand], $urlSeparator);
             }
         }
         // Second pass to process everything
         foreach ($this->data['Field']['Listing'] as $key => $value) {
             $key_parts = explode("_", $key);
             $imploded_value = '';
             if (substr($key, 0, 3) == "jr_" && substr($key, -9, 9) != '_operator' && @$key_parts[2] != 'reset') {
                 // multiple option field
                 if (is_array($value)) {
                     if (is_array($value[0]) && !empty($value[0])) {
                         $imploded_value = implode($urlSeparator, $value[0]);
                     } elseif (!is_array($value[0]) && implode('', $value) != '') {
                         $imploded_value = implode($urlSeparator, $value);
                     }
                     if ($key != '' && $imploded_value != '') {
                         $url_params[] = "{$key}" . _PARAM_CHAR . urlencode(trim($imploded_value));
                     }
                     // single option field
                 } elseif (!is_array($value) && trim($value) != '') {
                     $url_params[] = "{$key}" . _PARAM_CHAR . urlencode(trim($value));
                 }
             }
         }
     }
     // End isset $this->Data['Field']
     !empty($tmpl_suffix) and $url_params[] = 'tmpl_suffix' . _PARAM_CHAR . $tmpl_suffix;
     $url_params[] = "order" . _PARAM_CHAR . ($order ? $order : $this->Config->list_order_default);
     # Remove empty values from array
     foreach ($url_params as $index => $value) {
         if (empty($value)) {
             unset($url_params[$index]);
         }
     }
     $url_params = (cmsFramework::mosCmsSef() ? '' : '/') . implode('/', $url_params);
     # Uncomment this line and comment the one below to keep the Itemid on the result page
     if ($this->Config->search_itemid && $menu_id) {
         $url = $Routes->search_results($menu_id_param, '');
     } else {
         $url = $Routes->search_results(null, '');
     }
     // Params outside route function because it messes up the urlencoding
     $url = cmsFramework::route($url . $criteria_param . $url_params);
     $url = str_replace(array_keys($this->KeywordReplacementUrl), array_values($this->KeywordReplacementUrl), $url);
     cmsFramework::redirect($url);
 }
Beispiel #5
0
 /**
  * Convert relative urls to absolute for use in feeds, emails, etc.
  */
 function makeAbsUrl($url, $options = array())
 {
     $options = array_merge(array('sef' => false, 'ampreplace' => false), $options);
     $options['sef'] and $url = cmsFramework::route($url);
     $options['ampreplace'] and $url = str_replace('&amp;', '&', $url);
     if (!strstr($url, 'http')) {
         $url_parts = parse_url(WWW_ROOT);
         $url = $url_parts['scheme'] . '://' . $url_parts['host'] . $url;
     }
     return $url;
 }
Beispiel #6
0
 function listingsFeed($title = '', $attributes = array())
 {
     $base_url = rtrim(cmsFramework::constructRoute($this->passedArgs), '/') . '/action:xml/';
     $title = sprintf(__t("%s listing feeds", true), $title);
     if (isset($attributes['return_url'])) {
         $base_url = cmsFramework::route($base_url);
         return $base_url;
     } else {
         $attributes = array_merge(array('title' => $title, 'class' => 'jr_feedListings'), $attributes);
         return $this->Html->link('', $base_url, $attributes);
     }
 }
Beispiel #7
0
    function ListingsDetail()
    {
        $assets = array('js' => array('jreviews', 'jreviews.compare', 'jquery', 'jq.ui.core', 'jreviews.fields', 'jq.ui.rating', 'jq.jreviews.plugins', 'jq.tooltip', 'jq.json', 'jq.jsoncookie'), 'css' => array('theme', 'theme.detail', 'theme.form', 'paginator', 'jq.ui.core'));
        $facebook_id = Sanitize::getString($this->Config, 'facebook_appid');
        $facebook_opengraph = Sanitize::getBool($this->Config, 'facebook_opengraph', true);
        $facebook_xfbml = $facebook_id && $facebook_opengraph;
        $facebook_post = $facebook_id && $this->Access->canAddReview() && !$this->Access->moderateReview() && $this->Config->facebook_enable && $this->Config->facebook_reviews;
        ?>
        <script type="text/javascript">    
        /* <![CDATA[ */
        jQuery(document).ready(function() 
        {         
            jreviewsCompare.set({
                'numberOfListingsPerPage':<?php 
        echo Sanitize::getInt($this->Config, 'list_compare_columns', 3);
        ?>
,
                'maxNumberOfListings' : 15,
                'compareURL':'<?php 
        echo cmsFramework::route('index.php?option=com_jreviews&url=categories/compare/type:type_id/');
        ?>
'
            });
            jreviewsCompare.initCompareDashboard();
            jreviewsCompare.initListingsSelection();            

            <?php 
        if ($facebook_xfbml || $facebook_post) {
            ?>
                               
            if(!jQuery('#fb-root').length) jQuery("body").append('<div id="fb-root"></div>');
            jreviews.facebook.init({
                'appid':'<?php 
            echo $this->Config->facebook_appid;
            ?>
'
            });
            <?php 
        }
        ?>
                   
        });       
        /* ]]> */
        </script> 
        <?php 
        $this->send($assets);
    }
 /**
  * Returns sef urls passed as posted data via curl
  * Used to get front end sef urls from admin side
  * 
  */
 function _sefUrl()
 {
     $sef_urls = array();
     $urls = Sanitize::getVar($this->data, 'url');
     if (empty($urls)) {
         return;
     }
     foreach ($urls as $key => $url) {
         $sef_urls[$key] = cmsFramework::route($url);
     }
     echo json_encode($sef_urls);
 }
 function _save()
 {
     /*******************************************************************
      * This method is processed inside an iframe
      * To access any of the DOM elements via jQuery it's necessary to prepend
      * all jQuery calls with $parentFrame (i.e. $parentFrame.jQuery)
      ********************************************************************/
     $this->autoRender = false;
     $this->autoLayout = false;
     $response = array();
     $parentFrame = 'window.parent';
     $validation = '';
     $listing_id = Sanitize::getInt($this->data['Listing'], 'id', 0);
     $isNew = $this->Listing->isNew = $listing_id == 0 ? true : false;
     $this->data['email'] = Sanitize::getString($this->data, 'email');
     $this->data['name'] = Sanitize::getString($this->data, 'name');
     $this->data['categoryid_hidden'] = Sanitize::getInt($this->data['Listing'], 'categoryid_hidden');
     $cat_id = Sanitize::getVar($this->data['Listing'], 'catid');
     $this->data['Listing']['catid'] = is_array($cat_id) ? (int) array_pop(array_filter($cat_id)) : (int) $cat_id;
     /*J16*/
     $this->data['Listing']['title'] = Sanitize::getString($this->data['Listing'], 'title', '');
     $this->data['Listing']['created_by_alias'] = Sanitize::getString($this->data, 'name', '');
     if ($this->cmsVersion == CMS_JOOMLA15) {
         $this->data['sectionid_hidden'] = Sanitize::getInt($this->data['Listing'], 'sectionid_hidden');
         $this->data['Listing']['sectionid'] = Sanitize::getInt($this->data['Listing'], 'sectionid');
     } else {
         $this->data['Listing']['language'] = '*';
         $this->data['Listing']['access'] = 1;
     }
     $category_id = $this->data['Listing']['catid'] ? $this->data['Listing']['catid'] : $this->data['categoryid_hidden'];
     # Get criteria info
     $criteria = $this->Criteria->findRow(array('conditions' => array('Criteria.id = 
             (SELECT criteriaid FROM #__jreviews_categories WHERE id = ' . (int) $category_id . ' AND `option` = "com_content")
         ')));
     if (!$criteria) {
         $validation = __t("The category selected is invalid.", true, true);
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     $this->data['Criteria']['id'] = $criteria['Criteria']['criteria_id'];
     # Override global configuration
     isset($criteria['ListingType']) and $this->Config->override($criteria['ListingType']['config']);
     # Perform access checks
     if ($isNew && !$this->Access->canAddListing()) {
         return $this->makeJS("{$parentFrame}.s2Alert('" . __t("You are not allowed to submit listings in this category.", true, true) . "')");
     } elseif (!$isNew) {
         $query = "SELECT created_by FROM #__content WHERE id = " . $listing_id;
         $this->_db->setQuery($query);
         $listing_owner = $this->_db->loadResult();
         if (!$this->Access->canEditListing($listing_owner)) {
             return $this->makeJS("{$parentFrame}.s2Alert('" . s2Messages::accessDenied() . "')");
         }
     }
     # Load the notifications observer model component and initialize it.
     # Done here so it only loads on save and not for all controlller actions.
     $this->components = array('security', 'notifications');
     $this->__initComponents();
     if ($this->invalidToken == true) {
         return $this->makeJS("{$parentFrame}.s2Alert('" . s2Messages::invalidToken() . "')");
     }
     # Override configuration
     $category = $this->Category->findRow(array('conditions' => array('Category.id = ' . $this->data['Listing']['catid'])));
     $this->Config->override($category['ListingType']['config']);
     if ($this->Access->loadWysiwygEditor()) {
         $this->data['Listing']['introtext'] = Sanitize::stripScripts(Sanitize::stripWhitespace(Sanitize::getVar($this->data['__raw']['Listing'], 'introtext')));
         $this->data['Listing']['fulltext'] = Sanitize::stripScripts(Sanitize::stripWhitespace(Sanitize::getVar($this->data['__raw']['Listing'], 'fulltext')));
         $this->data['Listing']['introtext'] = html_entity_decode($this->data['Listing']['introtext'], ENT_QUOTES, cmsFramework::getCharset());
         $this->data['Listing']['fulltext'] = html_entity_decode($this->data['Listing']['fulltext'], ENT_QUOTES, cmsFramework::getCharset());
     } else {
         $this->data['Listing']['introtext'] = Sanitize::stripAll($this->data['Listing'], 'introtext', '');
         if (isset($this->data['Listing']['fulltext'])) {
             $this->data['Listing']['fulltext'] = Sanitize::stripAll($this->data['Listing'], 'fulltext', '');
         } else {
             $this->data['Listing']['fulltext'] = '';
         }
     }
     $this->data['Listing']['introtext'] = str_replace('<br>', '<br />', $this->data['Listing']['introtext']);
     $this->data['Listing']['fulltext'] = str_replace('<br>', '<br />', $this->data['Listing']['fulltext']);
     if ($this->Access->canAddMeta()) {
         $this->data['Listing']['metadesc'] = Sanitize::getString($this->data['Listing'], 'metadesc');
         $this->data['Listing']['metakey'] = Sanitize::getString($this->data['Listing'], 'metakey');
     }
     // Title alias handling
     $slug = '';
     $alias = Sanitize::getString($this->data['Listing'], 'alias');
     if ($isNew && $alias == '') {
         $slug = S2Router::sefUrlEncode($this->data['Listing']['title']);
         if (trim(str_replace('-', '', $slug)) == '') {
             $slug = date("Y-m-d-H-i-s");
         }
     } elseif ($alias != '') {
         // Alias filled in so we convert it to a valid alias
         $slug = S2Router::sefUrlEncode($alias);
         if (trim(str_replace('-', '', $slug)) == '') {
             $slug = date("Y-m-d-H-i-s");
         }
     }
     $slug != '' and $this->data['Listing']['alias'] = $slug;
     # Check for duplicates
     switch ($this->Config->content_title_duplicates) {
         case 'category':
             // Checks for duplicates in the same category
             $query = "\r\n                        SELECT \r\n                            count(*) \r\n                        FROM \r\n                            #__content AS Listing WHERE Listing.title = " . $this->_db->Quote($this->data['Listing']['title']) . "\r\n                            AND Listing.state >= 0 \r\n                            AND Listing.catid = " . $this->data['Listing']['catid'] . (!$isNew ? " AND Listing.id <> " . $listing_id : '');
             $this->_db->setQuery($query);
             $titleExists = $this->_db->loadResult();
             break;
         case 'no':
             // Checks for duplicates all over the place
             $query = "\r\n                        SELECT \r\n                            count(*) \r\n                        FROM \r\n                            #__content AS Listing\r\n                        WHERE \r\n                            Listing.title = " . $this->_db->Quote($this->data['Listing']['title']) . "\r\n                           AND Listing.state >= 0\r\n                           " . (!$isNew ? " AND Listing.id <> " . $listing_id : '');
             $this->_db->setQuery($query);
             $titleExists = $this->_db->loadResult();
             break;
         case 'yes':
             // Duplicates are allowed, no checking necessary
             $titleExists = false;
             break;
     }
     if ($titleExists && $this->data['Listing']['title'] != '') {
         // if listing exists
         $validation = '<span>' . __t("A listing with that title already exists.", true, true) . "</span>";
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     // Review form display check logic used several times below
     $revFormSetting = $this->Config->content_show_reviewform;
     if ($revFormSetting == 'noteditors' && !$this->Config->author_review) {
         $revFormSetting = 'all';
     }
     $revFormEnabled = !isset($this->data['review_optional']) && $this->Access->canAddReview() && $isNew && ($revFormSetting == 'all' && ($this->Config->author_review || $this->Config->user_reviews) || $revFormSetting == 'authors' && $this->Access->isJreviewsEditor($this->_user->id) || $revFormSetting == 'noteditors' && !$this->Access->isJreviewsEditor($this->_user->id));
     // Validation of content default input fields
     if ($this->cmsVersion == CMS_JOOMLA15) {
         if (!$this->data['Listing']['catid'] || !$this->data['Listing']['sectionid']) {
             $this->Listing->validateSetError("sec_cat", __t("You need to select both a section and a category.", true));
         }
     } else {
         !$this->data['Listing']['catid'] and $this->Listing->validateSetError("sec_cat", __t("You need to select a category.", true));
     }
     // Validate only if it's a new listing
     if ($isNew) {
         if (!$this->_user->id) {
             $this->Listing->validateInput($this->data['name'], "name", "text", __t("You must fill in your name.", true), $this->Config->content_name == "required" ? 1 : 0);
             $this->Listing->validateInput($this->data['email'], "email", "email", __t("You must fill in a valid email address.", true), $this->Config->content_email == "required" ? 1 : 0);
             $this->data['name'] = Sanitize::getString($this->data, 'name', '');
             $this->data['email'] = Sanitize::getString($this->data, 'email', '');
         } else {
             $this->data['name'] = $this->_user->name;
             $this->data['email'] = $this->_user->email;
         }
     }
     $this->Listing->validateInput($this->data['Listing']['title'], "title", "text", __t("You must fill in a title for the new listing.", true, true), 1);
     # Validate listing custom fields
     $listing_valid_fields =& $this->Field->validate($this->data, 'listing', $this->Access);
     $this->Listing->validateErrors = array_merge($this->Listing->validateErrors, $this->Field->validateErrors);
     $this->Listing->validateInput($this->data['Listing']['introtext'], "introtext", "text", __t("You must fill in a summary for the new listing.", true, true), $this->Config->content_summary == "required" ? 1 : 0);
     $this->Listing->validateInput($this->data['Listing']['fulltext'], "fulltext", "text", __t("You must fill in a description for the new listing.", true, true), $this->Config->content_description == "required" ? 1 : 0);
     # Validate review custom fields
     if ($revFormEnabled && $criteria['Criteria']['state']) {
         // Review inputs
         $this->data['Review']['userid'] = $this->_user->id;
         $this->data['Review']['email'] = $this->data['email'];
         $this->data['Review']['name'] = $this->data['name'];
         $this->data['Review']['username'] = Sanitize::getString($this->data, 'name', '');
         $this->data['Review']['title'] = Sanitize::getString($this->data['Review'], 'title');
         $this->data['Review']['location'] = Sanitize::getString($this->data['Review'], 'location');
         // deprecated
         $this->data['Review']['comments'] = Sanitize::getString($this->data['Review'], 'comments');
         // Review standard fields
         $this->Listing->validateInput($this->data['Review']['title'], "rev_title", "text", __t("You must fill in a title for the review.", true, true), $this->Config->reviewform_title == 'required' ? true : false);
         if ($criteria['Criteria']['state'] == 1) {
             $criteria_qty = $criteria['Criteria']['quantity'];
             $ratingErr = 0;
             if (!isset($this->data['Rating'])) {
                 $ratingErr = $criteria_qty;
             } else {
                 for ($i = 0; $i < $criteria_qty; $i++) {
                     if (!isset($this->data['Rating']['ratings'][$i]) || (empty($this->data['Rating']['ratings'][$i]) || $this->data['Rating']['ratings'][$i] == 'undefined' || (double) $this->data['Rating']['ratings'][$i] > $this->Config->rating_scale)) {
                         $ratingErr++;
                     }
                 }
             }
             $this->Listing->validateInput('', "rating", "text", sprintf(__t("You are missing a rating in %s criteria.", true, true), $ratingErr), $ratingErr);
         }
         // Review custom fields
         $this->Field->validateErrors = array();
         // Clear any previous validation errors
         $review_valid_fields = $this->Field->validate($this->data, 'review', $this->Access);
         $this->Listing->validateErrors = array_merge($this->Listing->validateErrors, $this->Field->validateErrors);
         $this->Listing->validateInput($this->data['Review']['comments'], "comments", "text", __t("You must fill in your comment.", true, true), $this->Config->reviewform_comment == 'required' ? true : false);
     }
     // if ($revFormEnabled && $criteria['Criteria']['state'])
     # Validate image fields
     $this->Uploads->validateImages();
     # Validate Captcha security code
     if ($isNew && $this->Access->showCaptcha()) {
         if (!isset($this->data['Captcha']['code'])) {
             $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true, true));
         } elseif ($this->data['Captcha']['code'] == '') {
             $this->Listing->validateInput($this->data['Captcha']['code'], "code", "text", __t("You must fill in the security code.", true), 1);
         } else {
             if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) {
                 $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true, true));
             }
         }
     }
     # Get all validation messages
     $validation = $this->Listing->validateGetError() . $this->Uploads->getMsg();
     # Validation failed
     if ($validation != '') {
         $response[] = "var parentForm = {$parentFrame}.jQuery('#jr_listingForm');";
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "parentForm.find('.button').removeAttr('disabled');";
         // Transform textareas into wysiwyg editors
         if ($this->Access->loadWysiwygEditor()) {
             App::import('Helper', 'Editor', 'jreviews');
             $Editor = new EditorHelper();
             $response[] = $parentFrame . '.' . $Editor->transform(true);
         }
         // Replace captcha with new instance
         if ($this->Access->in_groups($this->Config->security_image)) {
             $captcha = $this->Captcha->displayCode();
             $response[] = "{$parentFrame}.jQuery('#captcha').attr('src','{$captcha['src']}');";
             $response[] = "{$parentFrame}.jQuery('#jr_captchaCode').val('');";
         }
         $response[] = "parentForm.find('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
         // Can't use ajaxResponse b/c we are in an iframe
     }
     # Validation passed, continue...
     if ($isNew) {
         $this->data['Listing']['created'] = _CURRENT_SERVER_TIME;
         //gmdate('Y-m-d H:i:s');
         $this->data['Listing']['publish_up'] = _CURRENT_SERVER_TIME;
         //gmdate('Y-m-d H:i:s');
         $this->data['Listing']['created_by'] = $this->_user->id;
         $this->data['Listing']['publish_down'] = NULL_DATE;
         $this->data['Field']['Listing']['email'] = $this->data['email'];
         // If visitor, assign name field to content Alias
         if (!$this->_user->id) {
             $this->data['Listing']['created_by_alias'] = $this->data['name'];
         }
         // Check moderation settings
         $this->data['Listing']['state'] = (int) (!$this->Access->moderateListing());
         // If listing moderation is enabled, then the review is also moderated
         if (!$this->data['Listing']['state']) {
             $this->Config->moderation_reviews = $this->Config->moderation_editor_reviews = $this->Config->moderation_item;
         }
     } else {
         if ($this->Config->moderation_item_edit) {
             $this->data['Listing']['state'] = (int) (!$this->Access->moderateListing());
         }
         $this->data['Listing']['modified'] = _CURRENT_SERVER_TIME;
         //gmdate('Y-m-d H:i:s');
         $this->data['Listing']['modified_by'] = $this->_user->id;
         $query = 'SELECT images FROM #__content WHERE id = ' . $this->data['Listing']['id'];
         $this->_db->setQuery($query);
         $this->data['Listing']['images'] = $this->_db->loadResult();
         // Check total number of images
         if (!$this->Uploads->checkImageCount($this->data['Listing']['images'])) {
             $validation .= '<span>' . sprintf(__t("The total number of images is limited to %s", true, true), $this->Config->content_images) . '</span><br />';
             $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
             $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
             $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
             return $this->makeJS($response);
         }
     }
     // Process images and update data array
     if ($this->Uploads->success) {
         $imageUploadPath = PATH_ROOT . _JR_PATH_IMAGES . 'jreviews' . DS;
         $this->Uploads->uploadImages($this->data['Listing']['id'], $imageUploadPath);
         if ($isNew) {
             // New item
             $currImages = $this->Uploads->images;
         } elseif ($this->data['Listing']['images'] != '') {
             // Editing and there are existing images
             $currImages = array_merge(explode("\n", $this->data['Listing']['images']), $this->Uploads->images);
         } else {
             // Editing and there are no existing images
             $currImages = $this->Uploads->images;
         }
         $this->data['Listing']['images'] = implode("\n", $currImages);
     }
     # Save listing
     $savedListing = $this->Listing->store($this->data);
     $listing_id = $this->data['Listing']['id'];
     if (!$savedListing) {
         $validation .= __t("The was a problem saving the listing", true, true);
     }
     // Error on listing save
     if ($validation != '') {
         $response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
         $response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
         $response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
         return $this->makeJS($response);
     }
     # Save listing custom fields
     $this->data['Field']['Listing']['contentid'] = $this->data['Listing']['id'];
     $this->Field->save($this->data, 'listing', $isNew, $listing_valid_fields);
     # Begin insert review in table
     if ($revFormEnabled && $criteria['Criteria']['state']) {
         // Get reviewer type, for now editor reviews don't work in Everywhere components
         $this->data['Review']['author'] = (int) $this->Access->isJreviewsEditor($this->_user->id);
         $this->data['Review']['mode'] = 'com_content';
         $this->data['Review']['pid'] = (int) $this->data['Listing']['id'];
         // Force plugin loading on Review model
         $this->_initPlugins('Review');
         $this->Review->isNew = true;
         $savedReview = $this->Review->save($this->data, $this->Access, $review_valid_fields);
     }
     # Before render callback
     if ($isNew && isset($this->Listing->plgBeforeRenderListingSaveTrigger)) {
         $plgBeforeRenderListingSave = $this->Listing->plgBeforeRenderListingSave();
         switch ($plgBeforeRenderListingSave) {
             case '0':
                 $this->data['Listing']['state'] = 1;
                 break;
             case '1':
                 $this->data['Listing']['state'] = 0;
                 break;
             case '':
                 break;
             default:
                 return $plgBeforeRenderListingSave;
                 break;
         }
     }
     # Moderation disabled
     if (!isset($this->data['Listing']['state']) || $this->data['Listing']['state']) {
         $fields = array('Criteria.criteria AS `Criteria.criteria`', 'Criteria.tooltips AS `Criteria.tooltips`');
         $listing = $this->Listing->findRow(array('fields' => $fields, 'conditions' => array('Listing.id = ' . $listing_id)), array('afterFind'));
         # Facebook wall integration
         $fb_checkbox = Sanitize::getBool($this->data, 'fb_publish');
         $facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_listings') && $fb_checkbox;
         $token = cmsFramework::getCustomToken($listing_id);
         $facebook_integration and $response[] = $parentFrame . '.jQuery.get(' . $parentFrame . '.s2AjaxUri+' . $parentFrame . '.jreviews.ajax_params()+\'&url=facebook/_postListing/id:' . $listing_id . '&' . $token . '=1\');
             ';
         $url = cmsFramework::route($listing['Listing']['url']);
         $update_text = $isNew ? __t("Thank you for your submission.", true, true) : __t("The listing was successfully saved.", true, true);
         //JOEYG CODE
         //THE FOLLOWING GETS THE LISTING TYPE FROM THE DB FOR THE NEWLY SAVED LISTING
         //IF THE TYPE IS BUSINESS PROFILE OR PROJECT LISTING THEN DISPLAY THE after_submit.thtml file
         //ELSE DISPLAY NORMAL MESSAGE
         //IF WE ONLY WANT TO ADD THE after_submit.thtml if the listing is new then add
         if ($isNew) {
             $query = "SELECT `listing_type` FROM `jos_vpbd_content_criteria` WHERE `jos_vpbd_content_criteria`.`listing_id` = " . $this->data['Listing']['id'];
             $this->_db->setQuery($query);
             $jg_listing_type = $this->_db->loadResult();
             if ($jg_listing_type == 2 || $jg_listing_type == 7) {
                 $update_html = $this->render('listings', 'after_submit');
             } else {
                 $update_html = "<a href=\"{$url}\">" . __t("Click here to view your listing", true) . "</a>";
             }
             //ends if/else
         } else {
             //not new
             $update_html = "<a href=\"{$url}\">" . __t("Click here to view your listing", true) . "</a>";
         }
         //ends if($isNew)
         //ENDS JOEYG ALTER CODE
         $jsonObject = json_encode(compact('target_id', 'update_text', 'update_html'));
         $response[] = '
                 var $parentForm = ' . $parentFrame . '.jQuery(\'#jr_listingForm\');
                 $parentForm.scrollTo({duration:400,offset:-100});
                 $parentForm.s2ShowUpdate(' . $jsonObject . ');                                                       
             ';
         return $this->makeJS($response);
     }
     # Moderation enabled
     $update_text = __t("Thank you for your submission. It will be published once it is verified.", true);
     $update_html = '<div id=\\"s2Msgjr_listingForm\\" class=\\"jr_postUpdate\\">' . $update_text . '</div>';
     $response[] = '
         var $parentForm = ' . $parentFrame . '.jQuery(\'#jr_listingForm\');
         $parentForm.scrollTo({duration:400,offset:-100},function(){
             $parentForm.fadeOut(250,function(){$parentForm.html("' . $update_html . '").show();});
         });
     ';
     return $this->makeJS($response);
 }
Beispiel #10
0
 /**
  * Generates the dropdown list for number of items per page
  * @return html select list
  */
 function display_items_per_page()
 {
     $args = func_get_args();
     if (func_num_args() == 2) {
         $this->update_id = array_shift($args);
         $items_per_page = array_shift($args);
     } else {
         $items_per_page = array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
     }
     $Form = ClassRegistry::getClass('FormHelper');
     $segments = '';
     $url_param = array();
     $passedArgs = $this->passedArgs;
     if ($this->ajaxRequest) {
         foreach ($items_per_page as $limit) {
             $selectList[] = array('value' => $limit, 'text' => $limit);
         }
         $selected = $this->limit;
         //Sanitize::getInt($this->data,'limit');
         $onchange = ($this->ajax_scroll ? "jQuery('#" . $this->scroll_id . "').scrollTo(500,100);" : '') . "        \r\n                var \$form = jQuery(this).parents('form');\r\n                \$form.find('input[name=&#34;data[page]&#34;]').val(1);\r\n                \$form.find('input[name=&#34;data[limit]&#34;]').val(this.value);\r\n                \$form.find('input[name=&#34;data[action]&#34;]').val('{$this->action}');\r\n                jQuery.post(s2AjaxUri,\$form.serialize(),function(s2Out){jQuery('#{$this->update_id}').html(s2Out);},'html');\r\n            ";
         return __t("Results per page", true) . ': ' . $Form->select('order_limit', $selectList, $selected, array('onchange' => $onchange));
     } else {
         foreach ($items_per_page as $limit) {
             if (defined('MVC_FRAMEWORK_ADMIN')) {
                 $url = $this->base_url . 'page' . _PARAM_CHAR . '1/limit' . _PARAM_CHAR . $limit;
             } else {
                 $url = cmsFramework::route($this->base_url . '/page' . _PARAM_CHAR . '1/limit' . _PARAM_CHAR . $limit . (cmsFramework::mosCmsSef() ? '' : '/'));
             }
             $selectList[] = array('value' => $url, 'text' => $limit);
         }
         if (defined('MVC_FRAMEWORK_ADMIN')) {
             $selected = $this->base_url . 'page' . _PARAM_CHAR . '1/limit' . _PARAM_CHAR . $this->limit;
         } else {
             $selected = cmsFramework::route($this->base_url . '/page' . _PARAM_CHAR . '1/limit' . _PARAM_CHAR . $this->limit . (cmsFramework::mosCmsSef() ? '' : '/'));
         }
         return __t("Results per page", true) . ': ' . $Form->select('order_limit', $selectList, $selected, array('onchange' => "window.location=this.value"));
     }
 }
Beispiel #11
0
 function generateFormSelect($orderingList, $selected, $attributes)
 {
     # Construct new route
     $new_route = cmsFramework::constructRoute($this->passedArgs, array('lang', 'order', 'page'));
     if (Sanitize::getInt($this->params, 'page', 1) == 1 && preg_match('/^(index.php\\?option=com_jreviews&amp;Itemid=[0-9]+)(&amp;url=menu\\/)$/i', $new_route, $matches)) {
         // Remove menu segment from url if page 1 and it' a menu
         $new_route_page_1 = $matches[1];
     }
     $selectList = array();
     foreach ($orderingList as $value => $text) {
         $default_order = Sanitize::getString($this->params, 'default_order');
         // Default order takes user back to the first page
         if ($value == $default_order) {
             $selectList[] = array('value' => cmsFramework::route($new_route_page_1), 'text' => $text);
         } else {
             $selectList[] = array('value' => cmsFramework::route($new_route . '/order' . _PARAM_CHAR . $value), 'text' => $text);
         }
     }
     if ($selected == $default_order) {
         $selected = cmsFramework::route($new_route_page_1);
     } else {
         $selected = cmsFramework::route($new_route . '/order' . _PARAM_CHAR . $selected);
     }
     return $this->Form->select('order', $selectList, $selected, $attributes);
 }
Beispiel #12
0
 /**
  * Dynamic Listing Model Loading for jReviewsEverywhere extensions
  * Detects which extension is being used to load the correct Listing model
  *
  * @param object $controller
  * @param string $extension
  */
 function loadListingModel(&$controller, $extension = null)
 {
     if (in_array($controller->name, array('admin/reviews', 'reviews')) && $controller->action == '_save') {
         $extension = Sanitize::getString($controller->data['Review'], 'mode');
         !$extension and isset($controller->data['Listing']) and $extension = Sanitize::getString($controller->data['Listing'], 'extension');
     } else {
         $extension = $extension ? $extension : Sanitize::getString($controller->params, 'extension', Sanitize::getString($controller->data, 'extension'));
     }
     if (!$extension && isset($controller->params['module'])) {
         // Final check for module parameter
         $extension = Sanitize::getString($controller->params['module'], 'extension');
     }
     $extension == '' and $controller->name != 'facebook' and $controller->name != 'reviews' and $controller->name != 'community_reviews' and $controller->name != 'module_reviews' and $controller->name != 'discussions' and $controller->name != 'admin/reviews' and $controller->name != 'admin/admin_owner_replies' and $controller->name != 'admin/admin_reports' and $controller->name != 'admin/admin_discussions' and $extension = 'com_content';
     // Check if in listing detail page and it's a 3rd party component to dynamically load it's Listing model
     if ($extension) {
         $name = $this->name . '_' . $extension;
         App::import('Model', $name, 'jreviews');
         $class_name = inflector::camelize($this->name . '_' . $extension) . 'Model';
         if ($extension != '' && class_exists($class_name)) {
             $controller->Listing = new $class_name($controller->params);
             if (isset($controller->Review) && $controller->action != '_save') {
                 unset($controller->Review->joins['listings'], $controller->Review->joins['jreviews_categories'], $controller->Review->joins['criteria']);
                 $controller->Review->joins = array_merge($controller->Review->joins, $controller->Listing->joinsReviews);
             }
         } else {
             // Extension used in url doesn't have a plugin so we redirect to 404 error page
             $controller->autoLayout = false;
             $controller->autoRender = true;
             cmsFramework::redirect(cmsFramework::route('index.php?option=com_jreviews&url=404'));
         }
     }
 }
Beispiel #13
0
 /**
  * Convert relative urls to absolute for use in feeds, emails, etc.
  */
 function makeAbsUrl($url, $options = array())
 {
     $options = array_merge(array('sef' => false, 'ampreplace' => false), $options);
     $options['sef'] and $url = cmsFramework::route($url);
     $options['ampreplace'] and $url = str_replace('&amp;', '&', $url);
     if (!strstr($url, 'http')) {
         $url_parts = parse_url(WWW_ROOT);
         # If the site is in a folder make sure it is included in the url just once
         if ($url_parts['path'] != '') {
             if (strcmp($url_parts['path'], substr($url, 0, strlen($url_parts['path']))) !== 0) {
                 $url = rtrim($url_parts['path'], '/') . $url;
             }
         }
         $url = $url_parts['scheme'] . '://' . $url_parts['host'] . $url;
     }
     return $url;
 }
Beispiel #14
0
 function sefLink($title, $url = null, $attributes = array())
 {
     $url = str_replace('{_PARAM_CHAR}', _PARAM_CHAR, $url);
     if (isset($attributes['return_url'])) {
         return cmsFramework::route($url);
     }
     $attributes = $this->_parseAttributes($attributes);
     return sprintf($this->tags['link'], cmsFramework::route($url), $attributes, $title);
 }