view) { case 0: if ($teaser && !$page) { return TRUE; } break; case 1: if (!$teaser && $page) { return TRUE; } break; case 2: if ($teaser || $page) { return TRUE; } break; } return FALSE; } function defaults() { $this->module = 'share'; $this->label = t('Share popup'); $this->name = t('Share'); $this->effects = 1; $this->load_tabs(); } function load($share_id) { $data = db_fetch_object(db_query("SELECT s.`share_id`, s.`module`, s.`label`, s.`node_types`, s.`category_terms`, s.`where`, s.`view`, s.`status`, s.`weight`, s_share.`name`, s_share.`effects` FROM {share} AS s LEFT JOIN {share_share} AS s_share ON s.share_id = s_share.share_id WHERE s.share_id = %d", $share_id)); foreach ($data as $key => $value) { switch ($key) { case 'node_types': case 'category_terms': $this->$key = unserialize($value); break; default: $this->$key = $value; break; } } $this->load_tabs(); } function load_tabs() { $weights = array(); $tabs = array(); foreach (module_implements('share_info') as $module) { $tab = module_invoke($module, 'share_info'); $tabs[$module] = (object)$tab; $tabs[$module]->module = $module; if ($this->share_id) { $tabs[$module]->enabled = 0; } $weights[$module] = $tab['weight']; } $result = db_query("SELECT * FROM {share_tabs} WHERE share_id = %d AND enabled = %d ORDER BY weight, title", $this->share_id, 1); while ($data = db_fetch_object($result)) { $tab = drupal_clone($data); $tab = (array)$tab; $args = drupal_clone($this); $tab_data = (object)module_invoke($data->module, 'share_tab', 'load', $args); if (!empty($tab_data)) { $tab = $tab + (array)$tab_data; } $tabs[$tab['module']] = (object)$tab; $weights[$tab['module']] = $tab['weight']; } array_multisort($weights, $tabs); $this->tabs = $tabs; } function render($node, $op = FALSE) { $output = ''; switch ($op) { case 'link': $output .= l($this->name, 'share/'. $this->share_id .'/'. $node->nid, array('id' => 'share-'. $this->share_id .'-'. $node->nid, 'class' => 'share-link')); break; case 'popup': $output .= $this->render_popup($node); break; default: $output .= '
'; break; } return $output; } function render_popup($node) { $tabs = array(); $content = array(); foreach ($this->tabs as $tab) { if (!$tab->enabled) { continue; } if ($result = $this->render_tab($tab, $node)) { $tabs[] = array( 'id' => str_replace('_', '-', check_plain($tab->id)), 'name' => $tab->title ); $content[] = array( 'id' => str_replace('_', '-', check_plain($tab->id)), 'content' => $result ); } } $data['tabs'] = theme('share_popup_tabs', $tabs, $node->nid); $data['content'] = theme('share_popup_content', $content, $node->nid); return theme('share_popup', $data); } function render_tab($tab, $node) { return module_invoke($tab->module, 'share_tab', 'process', $tab, $node); } }