public function load($group) { if (!count($this->_sources)) { throw new JsonApiApplication_Exception("No configuration sources attached"); } if (empty($group)) { throw new JsonApiApplication_Exception("Need to specify a config group"); } if (!is_string($group)) { throw new JsonApiApplication_Exception("Config group must be a string"); } if (strpos($group, ".") !== FALSE) { list($group, $path) = explode(".", $group, 2); } if (isset($this->_groups[$group])) { if (isset($path)) { return Arr::path($this->_groups[$group], $path, NULL, "."); } return $this->_groups[$group]; } $config = array(); $sources = array_reverse($this->_sources); foreach ($sources as $source) { if ($source instanceof JsonApiApplication_Config_Reader) { if ($source_config = $source->load($group)) { $config = Arr::merge($config, $source_config); } } } $this->_groups[$group] = new JsonApiApplication_Config_Group($this, $group, $config); if (isset($path)) { return Arr::path($config, $path, NULL, "."); } return $this->_groups[$group]; }
public static function is_multi($id) { if (!self::$enums) { self::init(); } return Arr::path(self::$enums, $id . '.allow_multi'); }
/** * Render view. * * @return string */ public function content() { ob_start(); $foursquare = $this->venue->foursquare(); if (!$foursquare) { echo new View_Alert(__('This venue has not been linked to Foursquare yet.'), null, View_Alert::INFO); } else { // Homepage echo HTML::anchor(Arr::path($foursquare, 'short_url'), HTML::image(Arr::path($foursquare, 'primarycategory.iconurl'), array('alt' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')), 'title' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')))) . ' ' . HTML::chars(Arr::path($foursquare, 'primarycategory.nodename'))), '<br />'; // Mayor if ($mayor = Arr::path($foursquare, 'stats.mayor.user')) { echo __('Mayor: :mayor, :city', array(':mayor' => HTML::anchor('http://foursquare.com/user/' . Arr::get($mayor, 'id'), HTML::chars(Arr::get($mayor, 'firstname')) . ' ' . HTML::chars(Arr::get($mayor, 'lastname'))), ':city' => HTML::chars($mayor['homecity']))), '<br />'; } // Checkins echo __('Check-ins: :checkins', array(':checkins' => '<var>' . Arr::path($foursquare, 'stats.checkins') . '</var>')), '<br />'; // Here now echo __('Here now: :herenow', array(':herenow' => '<var>' . Arr::path($foursquare, 'stats.herenow') . '</var>')), '<br />'; // Tips if ($tips = Arr::path($foursquare, 'tips')) { echo '<h5>', __('Tips (:tips)', array(':tips' => '<var>' . count($tips) . '</var>')), '</h5><dl>'; foreach (array_slice($tips, 0, 5) as $tip) { echo '<dt>', HTML::anchor('http://foursquare.com/user/' . Arr::path($tip, 'user.id'), HTML::chars(Arr::path($tip, 'user.firstname')) . ' ' . HTML::chars(Arr::path($tip, 'user.lastname'))), ', ', HTML::chars(Arr::path($tip, 'user.homecity')), ':</dt>'; echo '<dd>', Text::auto_p(HTML::chars(Arr::path($tip, 'text'))), '</dd>'; } echo '</dl>'; } } // Admin controls if (Permission::has($this->venue, Model_Venue::PERMISSION_UPDATE)) { echo HTML::anchor('#map', __('Link to Foursquare'), array('class' => 'action', 'id' => 'link-foursquare')); echo $this->form(); } return ob_get_clean(); }
public function before() { $fullBaseUrl = Url::base(true); //was user on our site? if (strpos($this->request->referrer(), $fullBaseUrl) === 0) { //now check that a controller set, it wasn't the user controller, and that the session var "noReturn" is not false $uri = parse_url($this->request->referrer(), PHP_URL_PATH); // correct the path for url_base and index_file, in part taken from Kohana_Request::detect_uri() // Get the path from the base URL, including the index file $base_url = parse_url(Kohana::$base_url, PHP_URL_PATH); if (strpos($uri, $base_url) === 0) { // Remove the base URL from the URI $uri = (string) substr($uri, strlen($base_url)); } if (Kohana::$index_file and strpos($uri, Kohana::$index_file) === 0) { // Remove the index file from the URI $uri = (string) substr($uri, strlen(Kohana::$index_file)); } $processedRef = Request::process_uri($uri); $referrerController = Arr::path($processedRef, 'params.controller', false); if ($referrerController && $referrerController != 'user' && !Session::instance()->get('noReturn', false)) { Session::instance()->set('returnUrl', $this->request->referrer()); } } parent::before(); }
/** * @param null|mixed $path * @param null|mixed $default * @param null|string $delimeter * * @return array|mixed */ public function config($path = NULL, $default = NULL, $delimeter = NULL) { if (NULL === $this->_config) { $this->_config = Kohana::$config->load('geocode')->as_array(); } return NULL === $path ? $this->_config : Arr::path($this->_config, $path, $default, $delimeter); }
/** * Load modules config * * @param $group * @param $module * @return mixed * @throws Kohana_Exception */ public function load($group, $module) { if (empty($group) || empty($module)) { throw new Twig_Exception("Need to specify a config group and module name"); } if (!is_string($group) || !is_string($module)) { throw new Twig_Exception("Config group and module name must be a string"); } if (strpos($group, '.') !== FALSE) { // Split the config group and path list($group, $path) = explode('.', $group, 2); } if (isset($this->_config_groups[$group])) { if (isset($path)) { return Arr::path($this->_config_groups[$group], $path, NULL, '.'); } return $this->_config_groups[$group]; } $config = array(); $file = $this->_get_config_file($group, $module); if (is_file($file)) { $config = Arr::merge($config, Kohana::load($file)); } $this->_config_groups[$group] = new Config_Group(Kohana::$config, $group, $config); if (isset($path)) { return Arr::path($config, $path, NULL, '.'); } return $this->_config_groups[$group]; }
/** * Verify the access token. * * @param array an associative array of auth settings * @return OAuthToken * @link http://digg.com/api/docs/1.0/detail/oauth.verify */ public function verify_access_token() { // Configure the auth settings $auth_config = array(); if ($this->is_valid_token(NULL, TRUE)) { $token = $this->_token; $auth_config = array('token_key' => $token->key, 'token_secret' => $token->secret); } $auth_config = Arr::merge($this->_auth_config, $auth_config); // Configure the HTTP method, URL, and request parameters $http_method = MMI_HTTP::METHOD_POST; $url = $this->_api_url; $parms = array('method' => 'oauth.verify'); // Verify the request token $verified = 0; $response = $this->_auth_request($auth_config, $http_method, $url, $parms); if ($response instanceof MMI_Curl_Response) { $http_status_code = $response->http_status_code(); if (intval($http_status_code) === 200) { $data = $this->_decode_xml($response->body(), TRUE); if (is_array($data)) { $verified = intval(Arr::path($data, '@attributes.verified', 0)); } } } unset($response); return $verified === 1; }
/** * Retrieves multiple paths from an array. If the path does not exist in the * array, the default value will be added instead. * * // Get the values "username", "password" from $_POST * $auth = Arr::extract($_POST, array('username', 'password')); * * // Get the value "level1.level2a" from $data * $data = array('level1' => array('level2a' => 'value 1', 'level2b' => 'value 2')); * Arr::extract($data, array('level1.level2a', 'password')); * * @param array $array array to extract paths from * @param array $paths list of path * @param mixed $default default value * @return array */ public static function extract($array, array $paths, $default = NULL) { $found = array(); foreach ($paths as $path) { Arr::set_path($found, $path, Arr::path($array, $path, $default)); } return $found; }
public function config($group, $type, $model_name = NULL) { $model_name = $model_name ? $model_name : $this->model_name; $config = self::$_config === NULL ? self::$_config = Kohana::$config->load('huia/api') : self::$_config; $custom = $config->get('custom_' . $group); $regexp = Arr::path($custom, strtolower(Inflector::singular($model_name)) . '.' . $type); return $regexp !== NULL ? $regexp : Arr::get($config->get($group), $type); }
public function as_array() { $data = parent::as_array(); $data['options'] = json_decode($data['options'], true); if (!Arr::path($data, "options.title.text", false)) { Arr::set_path($data, "options.title.text", __($data['name'])); } return $data; }
/** * Test the Mixx API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'mixx.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_MIXX); // $response = $svc->get('users/show', array('user_key' => $username)); $requests = array('profile' => array('url' => 'users/show', 'parms' => array('user_key' => $username)), 'real-life-size-bus-transformer' => array('url' => 'thingies/show', 'parms' => array('url' => 'http://www.atcrux.com/2010/03/11/real-life-size-bus-transformer/', 'comments' => 1, 'tags' => 1))); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
public function action_index() { $logs = ORM::factory('log')->filter(); Assets::css('logs', 'cms/media/css/controller/logs.css'); $per_page = (int) Arr::get($this->request->query(), 'per_page', 20); $pager = Pagination::factory(array('total_items' => $logs->reset(FALSE)->count_all(), 'items_per_page' => $per_page)); $sidebar = new Sidebar(array(new Sidebar_Fields_DateRange(array('label' => __('Date range'), 'name' => 'created_on', 'range' => array(array('name' => '', 'value' => Arr::path($this->request->query(), 'created_on.0')), array('name' => '', 'value' => Arr::path($this->request->query(), 'created_on.1'))))), new Sidebar_Fields_Select(array('name' => 'level[]', 'label' => __('Log level'), 'options' => Log::levels(), 'selected' => (array) $this->request->query('level'))), new Sidebar_Fields_Input(array('name' => 'per_page', 'label' => __('Items per page'), 'value' => $per_page, 'size' => 3)))); $this->set_title(__('Logs'), FALSE); $this->template->content = View::factory('logs/index', array('logs' => $logs->with('user')->limit($pager->items_per_page)->offset($pager->offset)->find_all(), 'pager' => $pager, 'sidebar' => $sidebar)); }
/** * Test the GitHub API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'github.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_GITHUB); // $response = $svc->get("user/show/{$username}"); $requests = array($username => array('url' => "user/show/{$username}"), 'shadowhand' => array('url' => 'user/show/shadowhand')); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
/** * Test the Gowalla API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'gowalla.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_GOWALLA); // $response = $svc->get("users/{$username}"); $requests = array('profile' => array('url' => "users/{$username}"), 'stamps' => array('url' => "users/{$username}/stamps"), 'top spots' => array('url' => "users/{$username}/top_spots")); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
/** * Test the SlideShare API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'slideshare.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_SLIDESHARE); // $response = $svc->get('get_slideshows_by_user', array('username_for' => $username, 'detailed' => '1')); $requests = array('user slideshows' => array('url' => 'get_slideshows_by_user', 'parms' => array('username_for' => $username, 'detailed' => '1')), 'user groups' => array('url' => 'get_user_groups', 'parms' => array('username_for' => $username)), 'user contacts' => array('url' => 'get_user_contacts', 'parms' => array('username_for' => $username)), 'get slideshow' => array('url' => 'get_slideshow', 'parms' => array('slideshow_url' => 'http://www.slideshare.net/vortexau/improving-php-application-performance-with-apc-presentation', 'detailed' => '1'))); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
public static function locate($address) { if (!self::$config) { self::$config = Kohana::$config->load('mapquest'); } if (!is_array($address)) { $address = array($address); } $address = array_map(function ($value) { return trim(preg_replace('/^.*unit [0-9]+,/i', '', str_replace("\n", ', ', $value))); }, $address); reset($address); $list = array(); $response = array(); while ($item = current($address)) { $list[$item] = key($address); $state = substr($item, strrpos($item, ',') + 1); $item = array('country' => 'AU', 'street' => $item); if ($state) { $item['state'] = $state; } $data[] = $item; next($address); if (!key($address) && $list || count($list) >= self::$config->get('batch_size')) { $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $url = self::$config->get('service_url') . '?key=' . self::$config->get('api_key'); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array('locations' => $data))); $result = curl_exec($curl); curl_close($curl); $result = json_decode($result, true); try { foreach ($result['results'] as $item) { $key = Arr::get($list, Arr::path($item, 'providedLocation.street')); if ($key === NULL) { continue; } $location = array_shift($item['locations']); $response[$key] = Arr::get($location, 'latLng'); } } catch (Exception $e) { } $list = array(); $data = array(); } } if (count($address) == 1 && isset($address[0])) { return $response[0]; } else { return $response; } }
public function action_forgot() { if ($this->request->method() == Request::POST) { $this->auto_render = FALSE; $widget = Widget_Manager::factory('User_Forgot'); Context::instance()->set('email', Arr::path($this->request->post(), 'forgot.email')); $widget->set_values(array('next_url' => Route::get('user')->uri(array('action' => 'login'))))->on_page_load(); } $this->set_title(__('Forgot password')); $this->template->content = View::factory('system/forgot'); }
/** * Returns the current notification array. * * @param string Notification type * @return array */ public static function as_array($type = NULL) { $session = Session::instance(); // Import the session data localy $data = $session->as_array(); if ($type === NULL) { return Arr::path($data, 'notice', array()); } else { return array($type => Arr::path($data, 'notice.' . $type)); } }
/** * Test the Reddit API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'reddit.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_REDDIT); $svc->login(); // $response = $svc->get('api/info', array('url' => 'http://www.1stwebdesigner.com/tutorials/create-stay-on-top-menu-css3-jquery/')); $requests = array('user about' => array('url' => "user/{$username}/about"), 'clear vote' => array('method' => MMI_HTTP::METHOD_POST, 'url' => 'api/vote', 'parms' => array('api_type' => 'json', 'dir' => '0', 'id' => 't3_ckvqi', 'r' => 'web_design'))); $response = $svc->mexec($requests); $this->_set_response($response, $svc->service()); }
/** * Test the Tumblr API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $email = 'XXXXXXXXXX'; $password = '******'; $username = Arr::path($config, 'tumblr.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_TUMBLR); // $response = $svc->get('http://memakeit.tumblr.com/api/read'); $requests = array('posts' => array('url' => "http://{$username}.tumblr.com/api/read"), 'pages' => array('url' => "http://{$username}.tumblr.com/api/pages"), 'posts (private)' => array('method' => MMI_HTTP::METHOD_POST, 'url' => "http://{$username}.tumblr.com/api/read", 'parms' => array('email' => $email, 'password' => $password)), 'likes' => array('method' => MMI_HTTP::METHOD_POST, 'url' => 'likes', 'parms' => array('email' => $email, 'password' => $password)), 'settings' => array('method' => MMI_HTTP::METHOD_POST, 'url' => 'authenticate', 'parms' => array('email' => $email, 'password' => $password))); $response = $svc->mexec($requests); $this->_set_response($response, $svc->service()); }
public function action_index() { $id = strval(Arr::get($_GET, 'id')); $job = Database_Mongo::collection('jobs')->findOne(array('_id' => $id), array('data' => 1)); if (!$job) { throw new HTTP_Exception_404('Not found'); } $point = strval(Arr::get($_GET, 'point')); $archive = Database_Mongo::collection('archive')->findOne(array('_id' => new MongoId($point)), array('update_time' => 1)); if (!$archive) { throw new HTTP_Exception_404('Not found'); } $result = Database_Mongo::collection('archive')->find(array('job_key' => $id, 'update_time' => array('$gt' => $archive['update_time'])))->sort(array('update_time' => -1)); $ids = array(); $values = array(); foreach ($result as $item) { $ids[] = $item['_id']; foreach (Arr::get($item, 'data', array()) as $key => $data) { $job['data'][$key] = $values[$key] = $data['old_value']; } } foreach ($values as $key => $value) { if ($value) { $new['$set']['data.' . $key] = $value; } else { $new['$unset']['data.' . $key] = 1; } } if ($new) { $new['$set']['last_update'] = $archive['update_time']; } $submissions = array(); $result = Database_Mongo::collection('submissions')->find(array('job_key' => $id, 'process_time' => array('$gt' => $archive['update_time']))); foreach ($result as $item) { if (Arr::path($job, $item['key'], '') != $item['value']) { $submissions[] = $item['_id']; } } if ($new) { Database_Mongo::collection('submissions')->update(array('_id' => array('$in' => $submissions)), array('$unset' => array('process_time' => 1), '$set' => array('active' => 1))); Database_Mongo::collection('jobs')->update(array('_id' => $id), $new); Database_Mongo::collection('archive')->remove(array('_id' => array('$in' => $ids))); } $message = ''; if (count($ids)) { $message .= count($ids) . ' changes were removed. '; } if (count($submissions)) { $message .= count($submissions) . ' submissions were unapproved. '; } Messages::save('Ticket ' . $id . ' successfully rolled back to ' . date('d-m-Y H:i', $archive['update_time']) . '. ' . $message); die(json_encode(array('success' => true))); }
/** * Test the LastFM API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'lastfm.auth.username', 'memakeit'); $parms1 = array('method' => 'user.getinfo', 'user' => $username); $parms2 = array('method' => 'artist.gettoptracks', 'artist' => 'the fall'); $svc = MMI_API::factory(MMI_API::SERVICE_LASTFM); // $response = $svc->get(NULL, $parms1); $requests = array($parms1['method'] => array('parms' => $parms1), $parms2['method'] => array('parms' => $parms2)); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
public function action_index() { $id = $this->request->param('id'); $location = Arr::get($_GET, 'location', ''); $type = Arr::get($_GET, 'type', 'other'); $title = Arr::get($_GET, 'title', 'other'); $job = Database_Mongo::collection('jobs')->findOne(array('_id' => strval($id))); if (!$job) { throw new HTTP_Exception_404('Not found'); } if (!Group::current('show_all_jobs') && !in_array((int) User::current('company_id'), Arr::get($job, 'companies', array()), true) && !in_array((int) User::current('company_id'), Arr::get($job, 'ex', array()), true)) { throw new HTTP_Exception_403('Forbidden'); } switch ($type) { case 'photo-before': $type = 'Photos'; $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.before.%NUM%'; $title = ''; break; case 'photo-after': $type = 'Photos'; $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.after.%NUM%'; $title = ''; break; case 'jsa': $type = 'JSA-forms'; $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.JSA.%NUM%'; $title = ''; break; case 'waiver': $type = 'Waiver'; $filename = $id . '.' . Arr::path($job, 'data.9') . '.' . Arr::path($job, 'data.14') . '.Waiver.%NUM%'; $title = ''; break; case 'odtr': $title = ''; $type = 'otdr-traces'; $filename = ''; break; default: $type = 'Other'; $filename = ''; break; } $number = DB::select('numbering')->from('attachments')->where('job_id', '=', $id)->and_where('folder', '=', $type)->order_by('numbering', 'desc')->limit(1)->execute()->get('numbering'); $data = array('filename' => $filename, 'mime' => '', 'uploaded' => 0, 'user_id' => User::current('id'), 'job_id' => $id, 'folder' => $type, 'fda_id' => Arr::path($job, 'data.14'), 'address' => trim(preg_replace('/-{2,}/', '-', preg_replace('/[^0-9a-z\\-]/i', '-', Arr::path($job, 'data.8'))), '-'), 'title' => $title, 'numbering' => intval($number) + 1); $result = Arr::get(DB::insert('attachments', array_keys($data))->values(array_values($data))->execute(), 0); if (file_exists(DOCROOT . 'storage/' . $result)) { unlink(DOCROOT . 'storage/' . $result); } die(json_encode(array('success' => true, 'id' => $result))); }
/** * Gets a value from an array using a dot separated path. * * // Get the value of $array['foo']['bar'] * $value = Arr::path($array, 'foo.bar'); * * Using a wildcard "*" will search intermediate arrays and return an array. * * // Get the values of "color" in theme * $colors = Arr::path($array, 'theme.*.color'); * * @param array array to search * @param string key path, dot separated * @param mixed default value if the path is not set * @return mixed */ public static function path($array, $path, $default = NULL) { if (array_key_exists($path, $array)) { // No need to do extra processing return $array[$path]; } // Remove outer dots, wildcards, or spaces $path = trim($path, '.* '); // Split the keys by slashes $keys = explode('.', $path); do { $key = array_shift($keys); if (ctype_digit($key)) { // Make the key an integer $key = (int) $key; } if (isset($array[$key])) { if ($keys) { if (is_array($array[$key])) { // Dig down into the next part of the path $array = $array[$key]; } else { // Unable to dig deeper break; } } else { // Found the path requested return $array[$key]; } } elseif ($key === '*') { // Handle wildcards $values = array(); foreach ($array as $arr) { if ($value = Arr::path($arr, implode('.', $keys))) { $values[] = $value; } } if ($values) { // Found the values requested return $values; } else { // Unable to dig deeper break; } } else { // Unable to dig deeper break; } } while ($keys); // Unable to find the value requested return $default; }
/** * Test the Brightkite API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'brightkite.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_BRIGHTKITE); if (!$svc->is_valid_token(NULL, TRUE)) { die(HTML::anchor($svc->get_auth_redirect(), $svc->service() . ' authorization required')); } // $response = $svc->get("people/{$username}"); $requests = array('profile' => array('url' => "people/{$username}"), 'config' => array('url' => "people/{$username}/config"), 'friends' => array('url' => "people/{$username}/friends"), 'placemarks' => array('url' => "people/{$username}/placemarks"), 'objects' => array('url' => "people/{$username}/objects", 'parms' => array('filters' => 'checkins,notes,photos'))); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
public function before() { $baseUrl = Url::base(true); if (substr($this->request->referrer(), 0, strlen($baseUrl)) == $baseUrl) { $urlPath = ltrim(parse_url($this->request->referrer(), PHP_URL_PATH), '/'); $processedRef = Request::process_uri($urlPath); $referrerController = Arr::path($processedRef, 'params.controller', false); if ($referrerController && $referrerController != 'user' && !Session::instance()->get('noReturn', false)) { Session::instance()->set('returnUrl', $this->request->referrer()); } } parent::before(); }
/** * Test the FriendFeed API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'friendfeed.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_FRIENDFEED); if (!$svc->is_valid_token(NULL, TRUE)) { die(HTML::anchor($svc->get_auth_redirect(), $svc->service() . ' authorization required')); } // $response = $svc->get('feed/home'); $requests = array('me feed' => array('url' => 'feed/me'), 'user feed' => array('url' => "feed/{$username}"), 'friends feed' => array('url' => "feed/{$username}/friends"), 'comments feed' => array('url' => "feed/{$username}/comments"), 'likes feed' => array('url' => "feed/{$username}/likes")); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
/** * Test the Digg API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'digg.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_DIGG); if (!$svc->is_valid_token(NULL, TRUE)) { die(HTML::anchor($svc->get_auth_redirect(), $svc->service() . ' authorization required')); } // $response = $svc->get(NULL, array('method' => 'user.getInfo', 'username' => $username)); $requests = array('user.getDiggs' => array('url' => '', 'parms' => array('method' => 'user.getDiggs', 'username' => $username)), 'user.getInfo' => array('url' => '', 'parms' => array('method' => 'user.getInfo', 'username' => $username))); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
/** * Test the Picasa API. * * @return void */ public function action_index() { $config = MMI_API::get_config(TRUE); $username = Arr::path($config, 'picasa.auth.username', 'memakeit'); $svc = MMI_API::factory(MMI_API::SERVICE_PICASA); if (!$svc->is_valid_token(NULL, TRUE)) { die(HTML::anchor($svc->get_auth_redirect(), $svc->service() . ' authorization required')); } // $response = $svc->get("user/{$username}", array('kind' => 'photo', 'access' => 'all')); $requests = array('albums' => array('url' => "user/{$username}", 'parms' => array('kind' => 'album', 'access' => 'all')), 'recent photos' => array('url' => "user/{$username}", 'parms' => array('kind' => 'photo', 'access' => 'all'))); $response = $svc->mget($requests); $this->_set_response($response, $svc->service()); }
/** * Creates a SwiftMailer instance. * * @param string DSN connection string * @return object Swift object */ public static function mailer() { if (Email::$_mailer) { return Email::$_mailer; } // Load default configuration $config = Kohana::$config->load('html-email')->as_array(); switch ($config['driver']) { case 'smtp': $transport = Swift_SmtpTransport::newInstance(Arr::path($config, 'options.hostname', 'localhost'), Arr::path($config, 'options.port', 25), Arr::path($config, 'options.encryption')); $transport->setTimeout(Arr::path($config, 'options.timeout', 5)); $user = Arr::path($config, 'options.username'); $pass = Arr::path($config, 'options.password'); if ($user and $pass) { $transport->setUsername($user); $transport->setPassword($pass); } break; case 'sendmail': $transport = Swift_SendmailTransport::newInstance(Arr::get($config, 'options', '/usr/sbin/sendmail -bs')); break; case 'postmark': $transport = Openbuildings\Postmark\Swift_PostmarkTransport::newInstance(Arr::get($config, 'options')); break; case 'null': $transport = Swift_NullTransport::newInstance(); break; default: // Use the native connection $transport = Swift_MailTransport::newInstance(); break; } // Create the SwiftMailer instance self::$_mailer = Swift_Mailer::newInstance($transport); if (Arr::get($config, 'inline_css')) { self::$_mailer->registerPLugin(new Openbuildings\Swiftmailer\CssInlinerPlugin()); } if ($filter = Arr::get($config, 'filter')) { self::$_mailer->registerPlugin(new Openbuildings\Swiftmailer\FilterPlugin(Arr::get($filter, 'whitelist', array()), Arr::get($filter, 'blacklist', array()))); } if ($google_campaign = Arr::path($config, 'google_campaign.campaigns')) { self::$_mailer->registerPlugin(new Openbuildings\Swiftmailer\GoogleCampaignPlugin(array(), array('share' => $google_campaign['share'], 'abandoned_cart' => $google_campaign['abandoned_cart']))); } if ($logger = Arr::get($config, "logger")) { if ($logger === TRUE) { self::$_mailer->registerPlugin(new Swift_Plugins_Fullloggerplugin(new Email_Logger())); } else { self::$_mailer->registerPlugin(new $logger(new Email_Logger())); } } }