public function entries()
 {
     $tag = $this->EE->TMPL->fetch_param('tag');
     // fix spacing
     $tag = str_replace('+', ' ', $tag);
     // Grab all entries with this tag
     $this->EE->db->select('tl.tag_id, tl.entry_id');
     $this->EE->db->from('exp_tagger_links tl');
     $this->EE->db->join('exp_tagger t', 't.tag_id = tl.tag_id', 'left');
     $this->EE->db->where('t.tag_name', $tag);
     $this->EE->db->where_in('tl.site_id', $this->EE->TMPL->site_ids);
     $this->EE->db->where('tl.type', 1);
     $query = $this->EE->db->get();
     // Did we find anything
     if ($query->num_rows() == 0) {
         return "No Results Found.";
     }
     // Loop through the results
     $entry_ids = array();
     foreach ($query->result() as $row) {
         $entry_ids[] = $row->entry_id;
     }
     $this->EE->TMPL->tagparams['entry_id'] = implode('|', $entry_ids);
     return parent::entries();
 }
Esempio n. 2
0
 function entries()
 {
     # Hijack the Functions class.
     $functions = $this->EE->functions;
     $this->EE->functions = new Dandy_cat_EE_Functions();
     # Create a new instance of the EE Channel class so that it can do all of our heavy lifting.
     $channel = new Channel();
     # EE's Channel class completely refactors any category string with an '&' in it. Let's use commas to sneak past that bit of code.
     if (isset($this->EE->TMPL->tagparams['category'])) {
         $this->EE->TMPL->tagparams['category'] = str_replace('&', ',', $this->EE->TMPL->tagparams['category']);
     }
     # We use the the Channel Entries workhorse for most of this.
     $entries = $channel->entries();
     # Restore the Functions class and return.
     $this->EE->functions =& $functions;
     return $entries;
 }
Esempio n. 3
0
	/**
	 * Parse Relationships
	 *
	 * Fools EE into thinking that this was an {exp:channel:entries} tag
	 */
	private function _parse_relationships($tagdata, $entry_ids, $fixed_order)
	{
		if (! $tagdata) return;

		// -------------------------------------------
		//  Parse the relationships
		// -------------------------------------------

		// make sure $entry_ids is a pipe delimited string
		if (is_array($entry_ids)) $entry_ids = implode('|', $entry_ids);

		// entry_id= or fixed_order=
		$entry_id_param = ($fixed_order && ! $this->EE->TMPL->fetch_param('order_by')) ? 'fixed_order' : 'entry_id';
		$this->EE->TMPL->tagparams[$entry_id_param] = '0|'.$entry_ids;

		// dynamic="nuts"
		$this->EE->TMPL->tagparams['dynamic'] = 'no';

		if (! isset($this->EE->TMPL->tagparams['disable']))
		{
			// disable everything but custom_fields by default
			$this->EE->TMPL->tagparams['disable'] = 'categories|category_fields|member_data|pagination';
		}

		// prep TMPL with the cached tagdata
		$this->EE->TMPL->tagdata = $tagdata;

		$vars = $this->EE->functions->assign_variables($tagdata);
		$this->EE->TMPL->var_single = $vars['var_single'];
		$this->EE->TMPL->var_pair   = $vars['var_pair'];

		if (! class_exists('Channel'))
		{
			require PATH_MOD.'channel/mod.channel.php';
		}

		// create a new Channel object and run entries()
		$Channel = new Channel();
		return $Channel->entries();
	}
Esempio n. 4
0
 /**
  * Parse Relationships
  *
  * Fools EE into thinking that this was an {exp:channel:entries} tag
  */
 private function _parse_relationships($tagdata, $entry_ids, $fixed_order)
 {
     if (!$tagdata) {
         return;
     }
     // -------------------------------------------
     //  Parse the relationships
     // -------------------------------------------
     // make sure $entry_ids is a pipe delimited string
     if (is_array($entry_ids)) {
         $entry_ids = implode('|', $entry_ids);
     }
     // entry_id= or fixed_order=
     $entry_id_param = $fixed_order && !$this->EE->TMPL->fetch_param('orderby') ? 'fixed_order' : 'entry_id';
     $this->EE->TMPL->tagparams[$entry_id_param] = '0|' . $entry_ids;
     // dynamic="nuts"
     $this->EE->TMPL->tagparams['dynamic'] = 'no';
     if (!isset($this->EE->TMPL->tagparams['disable'])) {
         // disable everything but custom_fields by default
         $this->EE->TMPL->tagparams['disable'] = 'categories|category_fields|member_data|pagination';
     }
     // prep TMPL with the cached tagdata
     $this->EE->TMPL->tagdata = $tagdata;
     $vars = $this->EE->functions->assign_variables($tagdata);
     $this->EE->TMPL->var_single = $vars['var_single'];
     $this->EE->TMPL->var_pair = $vars['var_pair'];
     // _fetch_site_ids is meant to be a private method,
     // so make sure it's still around before calling it
     if (method_exists($this->EE->TMPL, '_fetch_site_ids')) {
         $this->EE->TMPL->_fetch_site_ids();
     }
     // -------------------------------------------
     //  'playa_parse_relationships' hook
     //   - Make any last-minute changes ta $tagparams, etc., before we call $Channel->entries()
     //
     if ($this->EE->extensions->active_hook('playa_parse_relationships')) {
         $this->EE->extensions->call('playa_parse_relationships');
     }
     //
     // -------------------------------------------
     if (!class_exists('Channel')) {
         require PATH_MOD . 'channel/mod.channel.php';
     }
     // create a new Channel object and run entries()
     $Channel = new Channel();
     return $Channel->entries();
 }
 function details()
 {
     $TMPL_cache = $this->EE->TMPL;
     $tagdata = $this->EE->TMPL->tagdata;
     if (!$tagdata) {
         return;
     }
     $member_id = $this->EE->TMPL->fetch_param('member_id', 'current');
     $member_entry_id = $this->EE->TMPL->fetch_param('member_entry_id', '');
     $username = $this->EE->TMPL->fetch_param('username', '');
     $url_title = $this->EE->TMPL->fetch_param('url_title', '');
     if (!$member_id && !$member_entry_id) {
         return;
     }
     if ($member_entry_id == '') {
         if ($username != '') {
             $entry_id = $this->EE->zoo_visitor_lib->get_visitor_id_by_username($username);
         } else {
             $entry_id = $this->EE->zoo_visitor_lib->get_visitor_id($member_id);
         }
     } else {
         $entry_id = $member_entry_id;
     }
     $entry_id = !$entry_id ? "-1" : $entry_id;
     $tagdata = str_replace("{visitor:", "{", $tagdata);
     $tagdata = str_replace("{/visitor:", "{/", $tagdata);
     $tagdata = str_replace("{if visitor:", "{if ", $tagdata);
     $tagdata = str_replace("member:", "", $tagdata);
     $tagdata = str_replace("/member:", "/", $tagdata);
     $this->EE->TMPL->tagdata = $tagdata;
     if (version_compare(APP_VER, '2.1.3', '<')) {
         preg_match("/\\{if no_results\\}(.*?)\\{\\/if\\}/s", $tagdata, $m);
         if (count($m) > 0) {
             $this->EE->TMPL->no_results_block = $m[0];
             $this->EE->TMPL->no_results = $m[1];
         } else {
             $this->EE->TMPL->no_results_block = '';
             $this->EE->TMPL->no_results = '';
         }
     }
     if ($url_title == '') {
         $this->EE->TMPL->tagparams['entry_id'] = $entry_id;
     }
     if ($url_title != '') {
         $this->EE->TMPL->tagparams['url_title'] = $url_title;
     }
     $this->EE->TMPL->tagparams['channel'] = $this->settings['member_channel_name'];
     $this->EE->TMPL->tagparams['dynamic'] = 'no';
     $this->EE->TMPL->tagparams['status'] = 'not closed';
     $this->EE->TMPL->tagparams['show_expired'] = 'yes';
     $this->EE->TMPL->tagparams['require_entry'] = $entry_id == '' || $entry_id == FALSE ? 'yes' : 'no';
     if (!isset($this->EE->TMPL->tagparams['disable'])) {
         $this->EE->TMPL->tagparams['disable'] = '';
         //categories|category_fields|member_data|pagination';
     }
     $vars = $this->EE->functions->assign_variables($tagdata);
     $this->EE->TMPL->var_single = $vars['var_single'];
     $this->EE->TMPL->var_pair = $vars['var_pair'];
     if (!class_exists('Channel')) {
         require PATH_MOD . 'channel/mod.channel.php';
     }
     // create a new Channel object and run entries()
     $Channel = new Channel();
     return $Channel->entries();
 }
 function product_custom()
 {
     // We should have access to the TMPL class
     // but if we run the product_custom parser
     // from an ACT we need to load it.
     if (!isset($this->EE->TMPL)) {
         $tmp = new EE_Template();
         $this->EE->TMPL = $tmp->EE->template;
     }
     // If they passed in the entry then we are set
     $entry_id = $this->EE->TMPL->fetch_param('entry_id');
     $product_id = $this->EE->TMPL->fetch_param('product_id');
     // Ut oh. We need something to hold on too.
     if ($entry_id == '' && $product_id == '') {
         $this->EE->TMPL->log_item('BrilliantRetail: product_custom is a no go. We need an entry_id or product_id');
         return '';
     }
     if ($entry_id == '') {
         $this->EE->TMPL->log_item('BrilliantRetail: product_custom has no entry_id. Trying to retrieve from product_id');
         $entry_id = $this->EE->product_model->get_product_entry($product_id);
     }
     if ($entry_id == '') {
         $this->EE->TMPL->log_item('BrilliantRetail: product_custom is a no go. We have no entry_id to pair it too');
         return '';
     }
     $this->EE->TMPL->log_item('BrilliantRetail: product_custom processing entry_id ' . $entry_id);
     include_once APPPATH . 'modules/channel/mod.channel.php';
     $this->EE->TMPL->tagparams['entry_id'] = $entry_id;
     $this->EE->TMPL->tagparams['limit'] = '1';
     $this->EE->TMPL->tagparams['dynamic'] = 'no';
     $this->EE->TMPL->tagparams['show_future_entries'] = 'yes';
     // We may need to name space the field if they are in a custom field
     if (strpos($this->EE->TMPL->tagdata, '{br:') !== FALSE) {
         $this->EE->TMPL->log_item('BrilliantRetail: found br: namespace in the product_custom tag for entry_id ' . $entry_id);
         $original = array(LD . "br:", LD . "/br:");
         // we need to do some magic on the tmpl data
         $this->EE->TMPL->tagdata = str_replace($original, LD, $this->EE->TMPL->tagdata);
         $this->EE->TMPL->tagchunk = str_replace($original, LD, $this->EE->TMPL->tagdata);
         foreach ($this->EE->TMPL->tag_data as $key => $val) {
             $this->EE->TMPL->tag_data[$key]["block"] = str_replace($original, LD, $this->EE->TMPL->tag_data[$key]["block"]);
             $this->EE->TMPL->tag_data[$key]["chunk"] = str_replace($original, LD, $this->EE->TMPL->tag_data[$key]["chunk"]);
         }
         // Strip any name spaced single vars
         foreach ($this->EE->TMPL->var_single as $key => $val) {
             $tmp[str_replace('br:', '', $key)] = str_replace('br:', '', $val);
         }
         if (isset($tmp)) {
             $this->EE->TMPL->var_single = $tmp;
             unset($tmp);
         }
         // Strip any name spaced pair vars
         foreach ($this->EE->TMPL->var_pair as $key => $val) {
             $tmp[str_replace('br:', '', $key)] = str_replace('br:', '', $val);
         }
         if (isset($tmp)) {
             $this->EE->TMPL->var_pair = $tmp;
             unset($tmp);
         }
     }
     $custom = new Channel();
     $tagdata = $custom->entries();
     return $tagdata;
 }
Esempio n. 7
0
 /**
  * Call the native channel:entries method
  *
  * @access      private
  * @return      string
  */
 private function _channel_entries()
 {
     $this->_log('Calling the channel module');
     // --------------------------------------
     // Set dynamic="no" as default
     // --------------------------------------
     if (ee()->TMPL->fetch_param('dynamic') != 'yes') {
         ee()->TMPL->tagparams['dynamic'] = 'no';
     }
     // --------------------------------------
     // Take care of related entries
     // --------------------------------------
     if (version_compare(APP_VER, '2.6.0', '<')) {
         // We must do this, 'cause the template engine only does it for
         // channel:entries or search:search_results. The bastard.
         ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data(ee()->TMPL->tagdata);
         // Add related markers to single vars to trigger replacement
         foreach (ee()->TMPL->related_markers as $var) {
             ee()->TMPL->var_single[$var] = $var;
         }
     }
     // --------------------------------------
     // Include channel module
     // --------------------------------------
     if (!class_exists('channel')) {
         require_once PATH_MOD . 'channel/mod.channel' . EXT;
     }
     // --------------------------------------
     // Create new Channel instance
     // --------------------------------------
     $channel = new Channel();
     // --------------------------------------
     // Let the Channel module do all the heavy lifting
     // --------------------------------------
     return $channel->entries();
 }
 /**
  * Replace Entries
  * 
  * run a channel:entries loop from the fieldtype
  * 
  * {your_field_name:entries disable="pagination"} {/your_field_name}
  *
  * @param $data
  * @param array $params
  * @param bool $tagdata
  * @return string
  */
 public function replace_entries($data, $params = array(), $tagdata = FALSE)
 {
     if (!$data || !$tagdata) {
         return '';
     }
     require_once APPPATH . 'modules/channel/mod.channel.php';
     $original_tagdata = $this->EE->TMPL->tagdata;
     $original_tagparams = $this->EE->TMPL->tagparams;
     $channels = $this->EE->channel_select_model->get_channels($data);
     $channel_names = array();
     foreach ($channels as $channel) {
         $channel_names[] = $channel['channel_name'];
     }
     $this->EE->TMPL->tagdata = $tagdata;
     $this->EE->TMPL->tagparams = $params;
     $this->EE->TMPL->tagparams['channel'] = implode('|', $channel_names);
     $this->EE->TMPL->tagparams['dynamic'] = 'no';
     $channel = new Channel();
     $output = $channel->entries();
     $this->EE->TMPL->tagdata = $original_tagdata;
     $this->EE->TMPL->tagparams = $original_tagparams;
     return $output;
 }
Esempio n. 9
0
 function entries()
 {
     $parent_id = $this->EE->TMPL->fetch_param('parent_id', false);
     $include_hidden = $this->EE->TMPL->fetch_param('include_hidden', 'n');
     $cat = "";
     $uricount = $this->EE->uri->total_segments();
     //Lets iterate through all the segment uris for the trigger word
     for ($x = 1; $x <= $uricount; $x++) {
         if ($this->EE->uri->segment($x) == $this->cat_trigger) {
             $cat = $this->EE->uri->segment($x + 1);
             break;
         }
     }
     if (is_numeric($parent_id)) {
         $child_ids = $this->sql->get_child_entries($parent_id, $cat, $include_hidden);
         $fixed_order = $child_ids !== FALSE && count($child_ids > 0) ? implode('|', $child_ids) : false;
         if ($fixed_order) {
             $this->EE->TMPL->tagparams['fixed_order'] = $fixed_order;
         } else {
             $this->EE->TMPL->tagparams['entry_id'] = '-1';
             // No results
         }
     }
     return parent::entries();
 }
Esempio n. 10
0
 /**
  * Loads the Channel module and runs its entries() method
  *
  * @access      private
  * @return      void
  */
 private function _channel_entries()
 {
     // --------------------------------------
     // Make sure the following params are set
     // --------------------------------------
     $set_params = array('dynamic' => 'no', 'paginate' => 'bottom');
     foreach ($set_params as $key => $val) {
         if (!ee()->TMPL->fetch_param($key)) {
             $this->params->apply($key, $val);
         }
     }
     // --------------------------------------
     // Take care of related entries
     // --------------------------------------
     if (version_compare(APP_VER, '2.6.0', '<')) {
         // We must do this, 'cause the template engine only does it for
         // channel:entries or search:search_results. The bastard.
         ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data(ee()->TMPL->tagdata);
         // Add related markers to single vars to trigger replacement
         foreach (ee()->TMPL->related_markers as $var) {
             ee()->TMPL->var_single[$var] = $var;
         }
     }
     // --------------------------------------
     // Get channel module
     // --------------------------------------
     $this->_log('Calling the channel module');
     if (!class_exists('channel')) {
         require_once PATH_MOD . 'channel/mod.channel' . EXT;
     }
     // --------------------------------------
     // Create new Channel instance
     // --------------------------------------
     $channel = new Channel();
     // --------------------------------------
     // Let the Channel module do all the heavy lifting
     // --------------------------------------
     return $channel->entries();
 }
 public function Category_entry_loop()
 {
     parent::Channel();
     $output = '';
     $cat_url = $this->EE->TMPL->fetch_param('cat_url', '');
     if (!empty($cat_url)) {
         $sql = $this->EE->db->query("\n                SELECT \n                    *\n                FROM " . $this->EE->db->dbprefix('categories') . "\n                WHERE \n                    cat_url_title = '" . $this->EE->db->escape_str($cat_url) . "'\n            ");
         $re = $sql->result_array();
         $re = current($re);
         if (isset($re['cat_id'])) {
             $cat_id = $re['cat_id'];
             $this->EE->TMPL->tagparams['category'] = $cat_id;
             $this->EE->TMPL->tagparams['channel'] = $this->EE->TMPL->fetch_param('channel', '');
             $this->EE->TMPL->tagparams['limit'] = $this->EE->TMPL->fetch_param('limit', '');
             $this->EE->TMPL->tagparams['orderby'] = $this->EE->TMPL->fetch_param('orderby', '');
             $this->EE->TMPL->tagparams['sort'] = $this->EE->TMPL->fetch_param('sort', '');
             $this->EE->TMPL->tagparams['dynamic'] = $this->EE->TMPL->fetch_param('dynamic', '');
             $this->EE->TMPL->tagparams['disable'] = $this->EE->TMPL->fetch_param('disable', '');
             $this->EE->TMPL->tagparams['cache'] = $this->EE->TMPL->fetch_param('cache', '');
             $this->EE->TMPL->tagparams['refresh'] = $this->EE->TMPL->fetch_param('refresh', '');
             $this->EE->TMPL->tagparams['paginate'] = $this->EE->TMPL->fetch_param('paginate', '');
             $this->return_data = parent::entries();
         }
     }
     return $this->return_data;
 }
    public function favorites()
    {
        parent::Channel();
        
        // fetch current logged in user
        $current_user = $this->EE->session->userdata('member_id');
        if (empty($current_user)) return $this->EE->TMPL->no_results();

        // fetch all favorites by the user
        $re = $this->EE->taechogroup_model->get_entry_ids_by_member_id($current_user);
        if (empty($re)) return $this->EE->TMPL->no_results();

        $entry_ids = array();
        foreach ($re as $r)
        {
            $entry_ids[] = $r['entry_id'];
        }
        
        $this->EE->TMPL->tagparams['entry_id'] = implode('|', $entry_ids);
       
        $this->return_data = parent::entries();

        return $this->return_data;
    }
 /**
  * Return Channel Entries that a user has been selected in
  */
 public function assoc_entries()
 {
     // Assist parsing of global variables as parameters
     foreach (ee()->TMPL->tagparams as $key => $val) {
         ee()->TMPL->tagparams[$key] = ee()->TMPL->parse_globals($val);
     }
     $prefix = ee()->TMPL->fetch_param('prefix', 'cm_');
     $field = ee()->TMPL->fetch_param('field');
     $col = ee()->TMPL->fetch_param('col');
     $member_id = ee()->TMPL->fetch_param('member_id', '');
     $display_entries = ee()->TMPL->fetch_param('display_entries', 'yes');
     $field_data = $this->chosen_helper->convertFieldName($field, $col);
     $entries = $this->chosen_helper->associatedChannelEntries($field_data['field_id'], $field_data['col_id'], explode('|', $member_id));
     if (empty($entries)) {
         return ee()->TMPL->no_results();
     }
     // Trick EE in to thinking this is a Channel Entries Loop
     if ($display_entries == 'yes') {
         $entry_id_param = !ee()->TMPL->fetch_param('orderby') ? 'fixed_order' : 'entry_id';
         ee()->TMPL->tagparams[$entry_id_param] = '0|' . implode('|', $entries);
         ee()->TMPL->tagparams['dynamic'] = 'no';
         if (!isset(ee()->TMPL->tagparams['disable'])) {
             ee()->TMPL->tagparams['disable'] = 'categories|category_fields|member_data|pagination';
         }
         $vars = ee()->functions->assign_variables(ee()->TMPL->tagdata);
         ee()->TMPL->var_single = $vars['var_single'];
         ee()->TMPL->var_pair = $vars['var_pair'];
         if (method_exists(ee()->TMPL, '_fetch_site_ids')) {
             ee()->TMPL->_fetch_site_ids();
         }
         if (!class_exists('Channel')) {
             require PATH_MOD . 'channel/mod.channel.php';
         }
         $channel = new Channel();
         return $channel->entries();
     }
     $results = array($prefix . 'entry_ids' => implode('|', array_unique($entries)));
     if (empty(ee()->TMPL->tagdata)) {
         return $results[$prefix . 'entry_ids'];
     }
     return ee()->TMPL->parse_variables_row(ee()->TMPL->tagdata, $results);
 }