Beispiel #1
0
 /**
  * Sets WPL view to wplview variable. This function sets other parameters as well in $_REQUEST
  * @author Howard R <*****@*****.**>
  * @static
  * @return void
  */
 public static function set_view()
 {
     /** set view **/
     $wplview = wpl_request::getVar('wplview', '');
     if (trim($wplview) != '') {
         return;
     }
     /** checking wordpress post type (post, page, any kind of posts and ...) **/
     if (!is_page() and !is_single()) {
         return;
     }
     /** getting the post id and post content **/
     $post_id = wpl_global::get_the_ID();
     $post_content = wpl_db::get('post_content', 'posts', 'id', $post_id);
     $wplview = '';
     if (strpos($post_content, '[wpl_property_listings') !== false or strpos($post_content, '[WPL') !== false) {
         $wplview = 'property_listing';
     } elseif (strpos($post_content, '[wpl_property_show') !== false) {
         $wplview = 'property_show';
     } elseif (strpos($post_content, '[wpl_profile_listing') !== false) {
         $wplview = 'profile_listing';
     } elseif (strpos($post_content, '[wpl_profile_show') !== false) {
         $wplview = 'profile_show';
     } elseif (strpos($post_content, '[wpl_my_profile') !== false) {
         $wplview = 'profile_wizard';
     } elseif (strpos($post_content, '[wpl_add_edit_listing') !== false) {
         $wplview = 'property_wizard';
     } elseif (strpos($post_content, '[wpl_listing_manager') !== false) {
         $wplview = 'property_manager';
     } elseif (strpos($post_content, '[wpl_payments') !== false) {
         $wplview = 'payments';
     } elseif (strpos($post_content, '[wpl_addon_') !== false) {
         $pos1 = strpos($post_content, '[wpl_addon_');
         $pos2 = strpos($post_content, ' ', $pos1);
         if ($pos2 === false) {
             $pos2 = strpos($post_content, ']', $pos1);
         }
         $shortcode = trim(substr($post_content, $pos1, $pos2 - $pos1), '[_ ]');
         $shortcode = str_replace('wpl_', '', $shortcode);
         $wplview = $shortcode;
     } elseif (strpos($post_content, '[wpl_custom_') !== false) {
         $wplview = 'wpl_custom_view';
     }
     /** set view **/
     if (trim($wplview) != '') {
         wpl_request::setVar('wplview', $wplview);
     }
     $pattern = get_shortcode_regex();
     preg_match('/' . $pattern . '/s', $post_content, $matches);
     $wpl_shortcodes = array('WPL', 'wpl_property_listings', 'wpl_property_show', 'wpl_profile_listing', 'wpl_profile_show', 'wpl_my_profile', 'wpl_add_edit_listing', 'wpl_listing_manager');
     if (is_array($matches) and isset($matches[2]) and in_array($matches[2], $wpl_shortcodes)) {
         $shortcode = $matches[0];
         $params_str = trim($matches[3], ', ');
         if (trim($params_str) != '') {
             $attributes = shortcode_parse_atts($params_str);
             foreach ($attributes as $key => $value) {
                 if (trim($key) == '') {
                     continue;
                 }
                 wpl_request::setVar($key, $value, 'method', false);
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Returns some activity with specified criteria
  * @author Howard <*****@*****.**>
  * @static
  * @param string $position
  * @param int $enabled
  * @param string $condition
  * @param string $result
  * @return objects
  */
 public static function get_activities($position, $enabled = 1, $condition = '', $result = 'loadObjectList')
 {
     if (trim($condition) == '') {
         $client = wpl_global::get_client();
         $condition = " AND `client` IN ({$client}, 2)";
         if (trim($position) != '') {
             $condition .= " AND `position`='{$position}'";
         }
         if (trim($enabled) != '') {
             $condition .= " AND `enabled`>='{$enabled}'";
         }
         /** page associations **/
         if (is_page()) {
             $post_id = wpl_global::get_the_ID();
             if ($post_id) {
                 $condition .= " AND (`association_type`='1' OR (`association_type`='2' AND `associations` LIKE '%[" . $post_id . "]%') OR (`association_type`='3' AND `associations` NOT LIKE '%[" . $post_id . "]%'))";
             }
         }
         $condition .= " ORDER BY `index` ASC, `ID` DESC";
     }
     $query = "SELECT * FROM `#__wpl_activities` WHERE 1 " . $condition;
     return wpl_db::select($query, $result);
 }