Пример #1
0
    public function mostrar_redes()
    {
        $social = new Social();
        // id="social" al div principal
        ?>
		<div>
			<div class="social">
				<?php 
        $social->button_gplus('standard');
        ?>
			</div>
			<div class="social">
				<?php 
        $social->button_twitter_share('large');
        ?>
			</div>
			<div class="social">
				<?php 
        $social->button_twitter_follow('codeando_org');
        ?>
			</div>
			<div class="social">
				<?php 
        $social->button_fb_share();
        ?>
			</div>
		</div>
		<?php 
    }
Пример #2
0
 public function workOnUser($provider, $provideruser)
 {
     $userClass = Yii::app()->controller->module->userClass;
     $social = Social::model()->find("provider='" . $provider . "' AND provideruser='******'");
     if ($social) {
         $user = $userClass::model()->find("id=" . $social->yiiuser);
         return $user;
     } else {
         // no user is connected to that provideruser,
         $social = new Social();
         // a new relation will be needed
         $social->provider = $provider;
         // what provider
         $social->provideruser = $provideruser;
         // the unique user
         // if a yii-user is already logged in add the provideruser to that account
         if (!Yii::app()->user->isGuest) {
             $social->yiiuser = Yii::app()->user->id;
             $user = $userClass::model()->findByPk(Yii::app()->user->id);
         } else {
             // we want to create a new $userClass
             $user = new $userClass();
             $user->username = $provideruser;
             if ($user->save()) {
                 //we get an user id
                 $social->yiiuser = $user->id;
             }
         }
         if ($social->save()) {
             return $user;
         }
     }
 }
 /**
  * Converts the response in JSON format to the value object i.e Social
  *
  * @param json
  *            - response in JSON format
  *
  * @return Social object filled with json data
  *
  */
 public function buildResponse($json)
 {
     $slJSONObject = $this->getServiceJSONObject("social", $json);
     $sl = new Social();
     $sl->setStrResponse($json);
     $sl->setResponseSuccess($this->isRespponseSuccess($json));
     $this->buildObjectFromJSONTree($sl, $slJSONObject);
     if ($slJSONObject->has("friends")) {
         if ($slJSONObject->__get("friends") instanceof JSONObject) {
             $friendJSONObj = $slJSONObject->__get("friends");
             $friends = new Friends($sl);
             $this->buildJsonFriends($friends, $friendJSONObj);
         } else {
             // There is an Array of attribute
             $friendsJSONArray = $slJSONObject->getJSONArray("friends");
             for ($i = 0; $i < count($friendsJSONArray); $i++) {
                 $friendJSONObj = $friendsJSONArray[$i];
                 $friends = new Friends($sl);
                 $this->buildJsonFriends($friends, $friendJSONObj);
             }
         }
     }
     if ($slJSONObject->has("profile")) {
         if ($slJSONObject->__get("profile") instanceof JSONObject) {
             $publicJSONObject = $slJSONObject->__get("profile");
             $publicfriend = new PublicProfile($sl);
             $this->buildJsonPublicProfile($publicfriend, $publicJSONObject);
         } else {
             // There is an Array of attribute
             $profileJSONArray = $slJSONObject->getJSONArray("profile");
             for ($i = 0; $i < count($profileJSONArray); $i++) {
                 $profileJSONObj = $profileJSONArray[$i];
                 $publicfriends = new PublicProfile($sl);
                 $this->buildJsonPublicProfile($publicfriends, $profileJSONObj);
             }
         }
     }
     if ($slJSONObject->has("me")) {
         if ($slJSONObject->__get("me") instanceof JSONObject) {
             $meJSONObj = $slJSONObject->__get("me");
             $me = new SocialFacebookProfile($sl);
             $this->buildJsonFacebookProfile($me, $meJSONObj);
         }
     }
     if ($slJSONObject->has("facebookProfile")) {
         if ($slJSONObject->__get("facebookProfile") instanceof JSONObject) {
             $meJSONObj = $slJSONObject->__get("facebookProfile");
             $me = new SocialFacebookProfile($sl);
             $this->buildJsonFacebookProfileLink($me, $meJSONObj);
         }
     }
     return $sl;
 }
Пример #4
0
    public function actionNewMessage() {
        $time=time();
        if (isset($_POST['message']) && $_POST['message'] != '') {
            $user = Yii::app()->user->getName();
            $chat = new Social;
            $chat->data = $_POST['message'];
            $chat->timestamp = $time;
            $chat->user = $user;
            $chat->type = 'chat';

            if ($chat->save()) {
                echo '1';
            }
        }
    }
Пример #5
0
 public static function getObject()
 {
     $class = get_called_class();
     $class = substr($class, strrpos($class, '\\') + 1);
     $object = Social::get($class, 'object_name');
     return $object;
 }
Пример #6
0
 /**
  * Add a message to the log.
  *
  * @static
  * @param  string  $message    message to add to the log
  * @param  array   $args       arguments to pass to the writer
  * @param  string  $context    context of the log message
  * @param  bool    $backtrace  show the backtrace
  * @return void
  */
 public function write($message, array $args = null, $context = null, $backtrace = false)
 {
     if (!Social::option('debug') and !in_array($context, apply_filters('social_log_contexts', array()))) {
         return;
     }
     if ($args !== null) {
         foreach ($args as $key => $value) {
             $message = str_replace(':' . $key, $value, $message);
         }
     }
     if ($context !== null) {
         $context = '[' . strtoupper(str_replace('-', ' ', $context)) . '] ';
     }
     $error_str = $context . '[SOCIAL - ' . current_time('mysql', 1) . ' - ' . $_SERVER['REMOTE_ADDR'] . '] ' . $message;
     if ($backtrace) {
         ob_start();
         debug_print_backtrace();
         $trace = ob_get_contents();
         ob_end_clean();
         $error_str .= "\n\n" . $trace . "\n\n";
     }
     if (is_writable($this->_file)) {
         error_log($error_str . "\n", 3, $this->_file);
     } else {
         error_log($error_str);
     }
 }
 public function adminAuthenticate()
 {
     $connections = array_filter(Social::getConnections(), function ($connection) {
         return $connection['identifier'] and $connection['secret'];
     });
     return View::make('sentinel.admin-login.index', compact('connections'));
 }
Пример #8
0
 public function show()
 {
     // sitemap
     $this->controller->setView('SitemapView');
     $sitemap = $this->controller->display();
     // legal notice
     $left = array_key_exists('legal_notice', $this->config) ? $this->config['legal_notice'] : '';
     $left = '<div class="col-md-6 col-md-offset-2"><p>' . $left . '</p></div>';
     $right = '<div class="col-md-2"><p class="pull-right"><a href="#">Back to top</a></p></div>';
     // social
     $social = '';
     $general = Config::getInstance()->getGeneralArray('general');
     if (array_key_exists('social', $general) && $general['social']) {
         $buttons = Social::getInstance()->socialButtons('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], Head::getInstance()->getTitle());
         $span = floor(6 / count($buttons));
         foreach ($buttons as $b) {
             $social .= '<div class="col-xs-2 col-md-' . $span . ' text-center">' . $b . '</div>';
         }
         $x = floor((8 - count($buttons)) / 2);
         $social = '<div class="row"><div class="col-md-offset-2 col-md-' . $x . '"></div>' . $social . '</div>';
     }
     // powered by
     $poweredby = '';
     if (isset($this->config['poweredby'])) {
         $poweredby = '<p class="poweredby text-center">' . $this->config['poweredby'] . '</p>';
         $poweredby = '<div class="row"><div class="col-md-8 col-md-offset-2">' . $poweredby . '</div></div>';
     }
     // put it together
     return $sitemap . '<div class="footer-inner row">' . $left . $right . '</div>' . $social . $poweredby;
 }
 /**
  * Handles authentication
  *
  * @param  string  $slug
  * @return mixed
  */
 public function getCallback($slug)
 {
     try {
         $user = Social::authenticate($slug, URL::current(), function ($link, $provider, $token, $slug) {
             if ($slug == 'facebook') {
                 // Retrieve the user in question for modificiation
                 $user = $link->getUser();
                 // Get user details
                 $data = $provider->getUserDetails($token)->getArrayCopy();
                 // Update user details
                 $user->facebook_uid = $data['uid'];
                 $user->save();
             } else {
                 if ($slug == 'twitter') {
                     // Retrieve the user in question for modificiation
                     $user = $link->getUser();
                     // Get user details
                     $data = $provider->getUserDetails($token);
                     // Update user details
                     $user->twitter_nickname = $data->nickname;
                     $user->twitter_image_url = $data->imageUrl;
                     $user->save();
                 }
             }
         });
         return Redirect::to('oauth/authenticated');
     } catch (Exception $e) {
         return Redirect::to('oauth')->withErrors($e->getMessage());
     }
 }
Пример #10
0
 /**
  * returns the instance created by its first invoke.
  *
  * @return Social
  */
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #11
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  */
 public function actionEdit()
 {
     $model = $this->loadUser();
     $social = Social::model()->find("provider='facebook' AND yiiuser=" . Yii::app()->user->id);
     $profile = $model->profile;
     UWprofilepic::handleProfilePic($model, $profile);
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'profile-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (isset($_POST['Profile'])) {
         $model->attributes = $_POST['User'];
         $profile->attributes = $_POST['Profile'];
         if ($model->validate() && $profile->validate()) {
             $model->save();
             $profile->save();
             Yii::app()->user->setFlash('success', 'Your changes have been saved successfully.');
             $this->redirect('/user/profile/edit/');
         } else {
             $profile->validate();
         }
     }
     $this->render('edit', array('model' => $model, 'social' => $social, 'profile' => $profile));
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Social::create([]);
     }
 }
Пример #13
0
 public function testAfterDelete()
 {
     $user = User::model()->findByPk('2');
     if (X2_TEST_DEBUG_LEVEL > 1) {
         /**/
         print 'id of user to delete: ';
         /**/
         print $user->id;
     }
     // test calendar permissions deletion
     $this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
     $this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
     // assert that group to user records exist for this user
     $this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) > 0);
     $this->assertTrue($user->delete());
     X2_TEST_DEBUG_LEVEL > 1 && (print 'looking for groupToUser records with userId = ' . $user->id);
     GroupToUser::model()->refresh();
     // assert that group to user records were deleted
     $this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) === 0);
     // test profile deletion
     $this->assertTrue(sizeof(Profile::model()->findAllByAttributes(array('username' => $user->username))) === 0);
     // test social deletion
     $this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('user' => $user->username))) === 0);
     $this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('associationId' => $user->id))) === 0);
     // test event deletion
     $this->assertTrue(sizeof(Events::model()->findAll("user=:username OR (type='feed' AND associationId=" . $user->id . ")", array(':username' => $user->username))) === 0);
     // test calendar permissions deletion
     $this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
     $this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
 }
Пример #14
0
 public function action_login()
 {
     //if user loged in redirect home
     if (Auth::instance()->logged_in()) {
         Auth::instance()->login_redirect();
     }
     Social::include_vendor();
     $user = FALSE;
     $config = Social::get();
     if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) {
         try {
             Hybrid_Endpoint::process($this->request->query());
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
             $this->redirect(Route::url('default'));
         }
     } else {
         $provider_name = $this->request->param('id');
         try {
             // initialize Hybrid_Auth with a given file
             $hybridauth = new Hybrid_Auth($config);
             // try to authenticate with the selected provider
             if ($provider_name == 'openid') {
                 $params = array('openid_identifier' => 'https://openid.stackexchange.com/');
             } else {
                 $params = NULL;
             }
             $adapter = $hybridauth->authenticate($provider_name, $params);
             if ($hybridauth->isConnectedWith($provider_name)) {
                 //var_dump($adapter->getUserProfile());
                 $user_profile = $adapter->getUserProfile();
             }
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage());
             $this->redirect(Route::url('default'));
         }
         //try to login the user with same provider and identifier
         $user = Auth::instance()->social_login($provider_name, $user_profile->identifier);
         //we couldnt login create account
         if ($user == FALSE) {
             $email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email;
             $name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName;
             //if not email provided
             if (!Valid::email($email, TRUE)) {
                 Alert::set(Alert::INFO, __('We need your email address to complete'));
                 //redirect him to select the email to register
                 $this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name);
             } else {
                 //register the user in DB
                 Model_User::create_social($email, $name, $provider_name, $user_profile->identifier);
                 //log him in
                 Auth::instance()->social_login($provider_name, $user_profile->identifier);
             }
         } else {
             Alert::set(Alert::SUCCESS, __('Welcome!'));
         }
         $this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default')));
     }
 }
Пример #15
0
 protected function verify_nonce()
 {
     $nonce = $this->request->query('_wpnonce');
     if (!Social::wp39_verify_nonce($nonce, $this->request->action())) {
         Social::log('NONCE Failure', array(), null, true);
         wp_die('Oops, please try again.');
     }
 }
Пример #16
0
function reg_with_fb()
{
    $_SESSION['fb_from'] = "register";
    $social = new Social();
    $social->includeFacebookLib();
    $client_id = Get::sett('social_fb_api');
    $client_secret = Get::sett('social_fb_secret');
    $redirect_uri = Get::sett('url') . 'index.php?modname=login&op=facebook_login';
    $serviceFactory = new \OAuth\ServiceFactory();
    $storage = new Session();
    $credentials = new Credentials($client_id, $client_secret, $redirect_uri);
    $facebookService = $serviceFactory->createService('facebook', $credentials, $storage, array());
    //, 'userinfo_profile'
    $authUrl = $facebookService->getAuthorizationUri();
    header('Location: ' . $authUrl);
    die;
}
Пример #17
0
 public function loadModel($id)
 {
     $model = Social::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #18
0
 function __construct($acct = null)
 {
     // Set our ID
     $this->id = $acct->id();
     // Set the account (Social_Service_Twitter_Account)
     $this->social_acct = $acct;
     // For convenience, set a reference to the service which has all the account methods
     $this->service =& Social::instance()->service('twitter');
 }
Пример #19
0
 public function run()
 {
     $content = Social::model()->findByAttributes(array('type' => 'motd'));
     if (isset($content)) {
         $content = CHtml::encode($content->data);
     } else {
         $content = Yii::t('app', 'Please enter a message of the day!');
     }
     $this->render('messageBox', array('content' => $content));
 }
Пример #20
0
 /**
  * Display the specified resource.
  * GET /posts/{id}
  *
  * @param  string  $slug
  * @return Response
  */
 public function show($slug)
 {
     $post = Post::where('slug', $slug)->firstOrFail();
     $author = $post->user;
     //recuperer les socials link
     $socials = Social::all();
     /*$cat = $post->category();*/
     $comments = $post->comments;
     return View::make('posts.show', compact('post', 'author', 'comments', 'tags', 'socials'));
 }
 public static function add_links_from_social()
 {
     $Social = new Social();
     $ids = get_post_meta(get_the_ID(), '_social_broadcasted_ids', true);
     $services = $Social->instance()->services();
     $broadcasts = array();
     $see_on_social = '';
     if (is_array($ids) and count($ids)) {
         foreach ($services as $key => $service) {
             if (isset($ids[$key]) and count($ids[$key])) {
                 $broadcasted = true;
                 foreach ($ids[$key] as $user_id => $broadcasted) {
                     $account = $service->account($user_id);
                     foreach ($broadcasted as $broadcasted_id => $data) {
                         if (false === $account) {
                             $class = 'Social_Service_' . $key . '_Account';
                             $account = new $class($data['account']);
                             if (!$account->has_user() and 'twitter' == $key) {
                                 $recovered = $service->recover_broadcasted_tweet_data($broadcasted_id, $post->ID);
                                 if (isset($recovered->user)) {
                                     $data['account']->user = $recovered->user;
                                     $account = new $class($data['account']);
                                 }
                             }
                         }
                         $broadcasted = esc_html($service->title());
                         if (isset($broadcasted_id)) {
                             if ($account->has_user() or 'twitter' !== $service->key()) {
                                 $url = $service->status_url($account->username(), $broadcasted_id);
                                 if (!empty($url)) {
                                     $broadcasts[] = esc_url($url);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $broadcasts;
 }
Пример #22
0
 public function run()
 {
     $content = Social::model()->findAllByAttributes(array('type' => 'note', 'associationId' => Yii::app()->user->getId()), array('order' => 'timestamp DESC'));
     if (count($content) > 0) {
         $data = $content;
     } else {
         $soc = new Social();
         $soc->data = Yii::t('app', "Feel free to enter some notes!");
         $data = array($soc);
     }
     $this->render('noteBox', array('data' => $data));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('socials', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->text('link');
         $table->string('css');
         $table->boolean('online')->default(0);
         $table->timestamps();
     });
     Social::create(['name' => 'facebook', 'link' => 'http://www.facebook.com', 'css' => 'fa fa-facebook', 'online' => 1]);
     Social::create(['name' => 'twitter', 'link' => 'http://www.twitter.com', 'css' => 'fa fa-twitter', 'online' => 1]);
 }
Пример #24
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id = null, $userid = null)
 {
     if ($id) {
         $model = Social::model()->findByPk($id);
     }
     if ($userid) {
         $model = Social::model()->find("yiiuser = '******'");
     }
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #25
0
 public function __construct()
 {
     $this->data['messages'] = View::make('block.messages')->with('messages', $this->getMessage())->render();
     $this->data['setting'] = Setting::first();
     $this->data['sliderList'] = Slider::orderBy('sort')->get();
     $this->data['socialList'] = Social::orderBy('sort')->get();
     $this->data['categoryList'] = Category::where('main', 0)->orderBy('sort')->get();
     $this->data['groupList'] = Group::orderBy('sort')->get();
     $this->data['buildOwn'] = Product::where('is_build', 1)->first();
     $placeList = Place::all();
     foreach ($placeList as $place) {
         $this->data['place'][$place->name] = $place->pageList()->orderBy('sort')->get();
     }
     $this->data['seo'] = array('keywords' => 'Pepperino', 'title' => 'Pepperino', 'description' => 'Pepperino');
 }
Пример #26
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Social Authentication for login')));
     $this->template->title = __('Social Auth');
     $this->template->styles = array('css/sortable.css' => 'screen');
     $this->template->scripts['footer'][] = 'js/jquery-sortable-min.js';
     //retrieve social_auth values
     $config = Social::get();
     if ($p = $this->request->post()) {
         $confit_old = $config;
         $config_new = array();
         foreach ($p as $key => $value) {
             if ($key != 'submit') {
                 // check if its id, secret .. and build multy d. array, same as they have
                 if (strpos($key, '_id')) {
                     $config_new['providers'][str_replace('_id', '', $key)]['keys']['id'] = $value;
                 } elseif (strpos($key, '_secret')) {
                     $config_new['providers'][str_replace('_secret', '', $key)]['keys']['secret'] = $value;
                 } elseif (strpos($key, '_key')) {
                     $config_new['providers'][str_replace('_key', '', $key)]['keys']['key'] = $value;
                 } elseif ($key == 'debug_mode') {
                     $config_new[$key] = $value;
                 } else {
                     $config_new['providers'][$key]['enabled'] = $value;
                 }
             }
         }
         // two fields not included
         $config_new['base_url'] = Route::url('default', array('controller' => 'social', 'action' => 'login', 'id' => 1));
         $config_new['debug_file'] = DOCROOT . 'oc/vendor/hybridauth/logs.txt';
         $obj_social_config = new Model_Config();
         $conf = $obj_social_config->where('group_name', '=', 'social')->where('config_key', '=', 'config')->limit(1)->find();
         if ($conf->loaded()) {
             $conf->config_value = json_encode($config_new);
             try {
                 $conf->save();
                 $config = $config_new;
                 //we update the form values if we changed them
                 Alert::set(Alert::SUCCESS, __('Social Auth updated'));
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
     }
     $this->template->content = View::factory('oc-panel/pages/social_auth/index', array('config' => $config));
 }
Пример #27
0
 /**
  * Imports a tweet by URL.
  *
  * @return void
  */
 public function action_from_url()
 {
     $this->verify_nonce();
     Social::log('Import tweet by URL started.');
     $service = $this->social->service('twitter');
     if ($service !== false) {
         $response = $service->import_tweet_by_url($this->request->query('post_id'), $this->request->query('url'));
         if ($response !== true) {
             echo $response;
             exit;
         }
         Social::log('Import tweet by URL finished.');
     } else {
         Social::log('Import tweet by URL failed, Twitter class not found.');
     }
     echo Social_Aggregation_Log::instance($this->request->query('post_id'));
     exit;
 }
Пример #28
0
 public function getLogin($social)
 {
     try {
         switch ($social) {
             case 'facebook':
                 $su = \Social::facebook('user');
                 break;
             case 'google':
                 $su = \Social::google('user');
                 break;
             default:
                 $su = null;
         }
         if ($su === null) {
             return \Redirect::route('frontend.index');
         }
         $m = \Member::where('uid', '=', $su->id)->where('social', '=', $social)->first();
         if ($m == null) {
             $m = new \Member();
             $m->uid = $su->id;
             $m->social = $social;
             $m->name = $su->name;
             $m->email = $su->email;
             if ($social == 'facebook') {
                 if (isset($su->birthday)) {
                     $m->birthday = date('Y-m-d', strtotime($su->birthday));
                 }
                 if (isset($su->gender)) {
                     $m->gender = substr($su->gender, 0, 1);
                 }
             }
             $m->save();
         }
         // register user into Auth that is a global variable
         \Auth::login($m);
         return \Redirect::route('frontend.index');
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
 }
Пример #29
0
 public function markup(Markup $model, $arg)
 {
     $body = '<div class="preview"><div class="text">' . $model->parse($arg) . '</div></div>';
     $body = '<div class="row content-item"><div class="col-md-12">' . $body . '</div></div>';
     if (array_key_exists('static', $model->config) && $model->config['static']) {
         $href = Config::getInstance()->app_root . $model->config['static'] . '/' . preg_replace('/\\.[^.\\s]{2,4}$/', '', basename($model->config['path']));
         // social
         $social = '';
         $general = Config::getInstance()->getGeneralArray('general');
         // TODO description
         if (array_key_exists('social', $general) && $general['social']) {
             $buttons = Social::getInstance()->socialButtons('https://' . $_SERVER['HTTP_HOST'] . $href, Head::getInstance()->getTitle());
             $span = floor(6 / count($buttons));
             foreach ($buttons as $b) {
                 $social .= '<div class="col-xs-2 col-md-' . $span . ' text-center">' . $b . '</div>';
             }
         }
         $static = '<a class="btn" href="' . $href . '">More <i class="fa fa-angle-double-right"></i></a>';
         $body .= '<div class="row socials"><div class="col-md-5"><div class="row">' . $social . '</div></div><div class="col-md-7 text-right">' . $static . '</div></div>';
     }
     return self::head($model->parseTags($model->config['path'])) . $body;
 }
Пример #30
0
 /**
  * Makes sure Social CRONs are not scheduled more than once.
  *
  * @return void
  */
 public function action_check_crons()
 {
     // this is an internal only call, so manually calling URL decode
     if (urldecode($this->request->query('social_api_key')) != Social::option('system_cron_api_key')) {
         Social::log('API key failed');
         wp_die('Oops, invalid API key.');
     }
     $crons = _get_cron_array();
     $social_crons = array('15' => false);
     foreach ($crons as $timestamp => $_crons) {
         foreach ($_crons as $key => $cron) {
             foreach ($social_crons as $cron_key => $status) {
                 $event_key = 'social_cron_' . $cron_key . '_core';
                 if ($key == $event_key and $social_crons[$cron_key]) {
                     wp_unschedule_event($timestamp, $event_key);
                     Social::log('Unscheduled extra event: ' . $event_key);
                 } else {
                     $social_crons[$cron_key] = true;
                 }
             }
         }
     }
 }