/** * River Navs * * @param obj $river - the loaded river object * @param string $active - the active menu * @return array $nav */ public static function river($river = NULL, $active = NULL) { $nav = array(); if ($river) { // List $nav[] = array('id' => 'list-navigation-link', 'active' => 'list', 'url' => '/list', 'label' => __('List')); // Drops $nav[] = array('id' => 'drops-navigation-link', 'active' => 'drops', 'url' => '/drops', 'label' => __('Drops')); // Photos $nav[] = array('id' => 'photos-navigation-link', 'active' => 'photos', 'url' => '/photos', 'label' => __('Photos')); // Photos $nav[] = array('id' => 'trends-navigation-link', 'active' => 'trends', 'url' => '/trends', 'label' => __('Trends')); } // SwiftRiver Plugin Hook -- Add Nav Items Swiftriver_Event::run('swiftriver.river.nav', $nav); return $nav; }
/** * Create a single new drop and publish new ones for meta extraction. * * @return array */ public static function create_drop($drop) { list($drops, $new_drops) = Model_Droplet::create_from_array(array($drop)); if (!empty($new_drops)) { Swiftriver_Event::run('swiftriver.droplet.extract_metadata', $new_drops[0]); Model_Droplet::create_from_array(array($new_drops[0])); } return $drops[0]; }
<?php if (isset($form_list)) { ?> // Bootstrap the global form list Assets.formList.reset(<?php echo $form_list; ?> ); <?php } ?> }); </script> <?php Swiftriver_Event::run('swiftriver.template.head'); ?> </head> <body> <?php if ($show_nav) { ?> <header class="toolbar"> <div class="center"> <div class="col_6"> <h1 class="logo"> <a href="<?php echo $dashboard_url; ?> ">
/** * Toggles the status of the channel options for the current river * * @param bool $activate When TRUE, activates the channel options for * the river. When FALSE, removes the channel options from the crawling * schedule */ private function _toggle_channel_option_status($activate) { // Get all the channel filter options $channel_options = ORM::factory('channel_filter_option')->where('channel_filter_id', 'IN', DB::select('id')->from('channel_filters')->where('river_id', '=', $this->id))->find_all(); // Status - determines the action to be taken on the channel options $new_status = $activate ? "activate" : "deactivate"; foreach ($channel_options as $option) { // Run deactivation events for each option Swiftriver_Event::run('swiftriver.channel.option.' . $new_status, $option); } // Garbage collection unset($channel_options); }
</li> <li <?php if ($active == 'quotas') { echo 'class="active"'; } ?> > <a href="<?php echo URL::site('settings/quotas'); ?> "><?php echo __('Channel Quotas'); ?> </a> </li> <?php // Swiftriver Plugin Hook -- add settings nav item Swiftriver_Event::run('swiftriver.settings.nav', $active); ?> </ul> </nav> <div id="content" class="settings cf"> <div class="center"> <div class="col_12"> <?php echo $settings_content; ?> </div> </div> </div>
<section class="panel"> <nav class="cf"> <ul class="views"> <li class="droplets <?php $active == 'droplets' ? 'active' : ''; ?> "><a href="<?php echo $drops_url; ?> "><?php echo __('Drops'); ?> </a></li> <?php // SwiftRiver Plugin Hook -- Add River Nav Item Swiftriver_Event::run('swiftriver.bucket.nav', $bucket); ?> <li class="view-panel"><a href="<?php echo $more_url; ?> "><span class="arrow"></span><?php echo __('Trends'); ?> </a></li> </ul> </nav> <div class="drawer"></div> </section> <div class="trend_container cf"> <?php
/** * Overrides the default behaviour to perform * extra tasks before removing the channel filter * entry */ public function delete() { Swiftriver_Event::run('swiftriver.channel.option.pre_delete', $this); // Default parent::delete(); }
<div id="modal-container"> <div class="modal-window"> <div id="modal-viewport"> </div> </div> <div class="modal-window-secondary"></div> </div> <div id="confirmation-container"> <div class="modal-window"></div> </div> <article class="system-message" id="system-message-template"> <div class="center"> <a href="#" class="system-message-close"><span class="icon-cancel"></span></a> <p><strong></strong> </p> </div> </article> <footer class="center"></footer> <?php // SwiftRiver Plugin Hook Swiftriver_Event::run('swiftriver.footer'); ?> </body> </html> <?php // Uncomment to profile // echo View::factory('profiler/stats');
/** * Update channel filter option and creates it if it doesn't exist * * @param int id * @param mixed value * @return Model_Channel_Filter_option */ public function update_option($value, $id = 0) { $filter_option = ORM::factory('channel_filter_option', $id); if ($filter_option->loaded()) { Swiftriver_Event::run('swiftriver.channel.option.pre_delete', $filter_option); } $filter_option->channel_filter_id = $this->id; $filter_option->key = $value['key']; unset($value['key']); $filter_option->value = json_encode($value); $filter_option->save(); return $filter_option; }
/** * File upload end point. */ public function action_file() { $this->template = ""; $this->auto_render = FALSE; $channel_id = intval($this->request->param('id', 0)); $channel = $this->river->get_channel_by_id($channel_id); if (!$channel) { throw new HTTP_Exception_404(); } $file = $_FILES['file']; if (!Upload::not_empty($file)) { $this->response->status(400); $this->response->headers('Content-Type', 'application/json'); echo json_encode(array('error' => __("Invalid file"))); return; } // Pass on the files to plugings try { $file['key'] = $this->request->post('key'); Swiftriver_Event::run('swiftriver.channel.option.file', $file); } catch (SwiftRiver_Exception_ChannelOption $e) { $this->response->status(400); $this->response->headers('Content-Type', 'application/json'); echo json_encode(array('error' => $e->getMessage())); return; } // Create the filter options $options_array = array(); foreach ($file['option_data'] as $option_data) { // Validate option data first, skip failures try { $channel_option_array['channel'] = $channel->channel; Swiftriver_Event::run('swiftriver.channel.option.pre_save', $option_data); // Validation passed, save the option $channel_option = $channel->update_option($option_data); // Return the new id + updated values $option_array = $this->river->get_channel_options($channel, $channel_option->id); $options_array[] = $option_array[0]; } catch (SwiftRiver_Exception_ChannelOption $e) { // Do nothing } } echo json_encode($options_array); }
/** * Dashboard Navigation Links * * @param string $user - logged in user * @return array $nav */ protected static function get_nav($user) { $nav = array(); // Activity Stream $nav[] = array('id' => 'activities-navigation-link', 'url' => '', 'label' => __('Activity')); // Content $nav[] = array('id' => 'content-navigation-link', 'url' => '/content', 'label' => __('Content')); // Invite if (Swiftriver::get_setting('general_invites_enabled') and $user->invites > 0) { $nav[] = array('id' => 'invite-navigation-link', 'url' => '/invite', 'label' => __('Invites')); } // SwiftRiver Plugin Hook -- Add Nav Items Swiftriver_Event::run('swiftriver.dashboard.nav', $nav); return $nav; }
/** * Dashboard Navigation Links * * @param string $active - the active menu * @return array $nav */ protected static function get_nav() { $nav = array(); // List $nav[] = array('id' => 'dashboard-navigation-link', 'url' => '', 'label' => __('Dashboard')); // Drops $nav[] = array('id' => 'settings-navigation-link', 'url' => '/settings', 'label' => __('Settings')); // SwiftRiver Plugin Hook -- Add Nav Items Swiftriver_Event::run('swiftriver.dashboard.nav', $nav); return $nav; }
/** * Header CSS + Hook * * @return void */ public function action_css() { // SwiftRiver Plugin Hook -- Add Custom JS Swiftriver_Event::run('swiftriver.header.css'); }
/** * Modify the given channel in the river * * @return Array */ public function update_channel_from_array($river_id, $channel_id, $channel_array) { Swiftriver_Event::run('swiftriver.channel.validate', $channel_array); $channel_array = $this->api->get_rivers_api()->update_channel($river_id, $channel_id, $channel_array["channel"], json_encode($channel_array["parameters"])); $channel_array['parameters'] = json_decode($channel_array['parameters'], TRUE); $channel_array['display_name'] = ''; Swiftriver_Event::run('swiftriver.channel.format', $channel_array); return $channel_array; }