예제 #1
0
	/**
	 * Retrieves EasySocial's toolbar
	 *
	 * @since	1.0
	 * @access	public
	 * @param	string
	 * @return
	 */
	public function getToolbar()
	{
		$toolbar 	= Foundry::get( 'Toolbar' );
		$output 	= $toolbar->render();

		return $output;
	}
예제 #2
0
 public static function location($location, $options = '')
 {
     $uid = uniqid();
     $classname = 'es-location-' . $uid;
     $selector = '.' . $classname;
     if (empty($location)) {
         $location = Foundry::table('Location');
     }
     $theme = Foundry::get('Themes');
     $theme->set('uid', $uid);
     $theme->set('classname', $classname);
     $theme->set('selector', $selector);
     $theme->set('location', $location);
     return $theme->output('admin/html/grid.location');
 }
예제 #3
0
 /**
  * Creates a new stream for new comments in EasyBlog
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function addIndexerNewBlog($blog)
 {
     if (!class_exists('Foundry')) {
         return;
     }
     $config = EasyBlogHelper::getConfig();
     $indexer = Foundry::get('Indexer', 'com_easyblog');
     $template = $indexer->getTemplate();
     // getting the blog content
     $content = $blog->intro . $blog->content;
     $image = '';
     // @rule: Try to get the blog image.
     if ($blog->getImage()) {
         $image = $blog->getImage()->getSource('small');
     }
     if (empty($image)) {
         // @rule: Match images from blog post
         $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i';
         preg_match($pattern, $content, $matches);
         $image = '';
         if ($matches) {
             $image = isset($matches[1]) ? $matches[1] : '';
             if (JString::stristr($matches[1], 'https://') === false && JString::stristr($matches[1], 'http://') === false && !empty($image)) {
                 $image = rtrim(JURI::root(), '/') . '/' . ltrim($image, '/');
             }
         }
     }
     if (!$image) {
         $image = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/default_facebook.png';
     }
     // @task: Strip out video tags
     $content = EasyBlogHelper::getHelper('Videos')->strip($content);
     // @task: Strip out audio tags
     $content = EasyBlogHelper::getHelper('Audio')->strip($content);
     // @task: Strip out gallery tags
     $content = EasyBlogHelper::getHelper('Gallery')->strip($content);
     // @task: Strip out album tags
     $content = EasyBlogHelper::getHelper('Album')->strip($content);
     // @rule: Once the gallery is already processed above, we will need to strip out the gallery contents since it may contain some unwanted codes
     // @2.0: <input class="easyblog-gallery"
     // @3.5: {ebgallery:'name'}
     $content = EasyBlogHelper::removeGallery($content);
     $content = strip_tags($content);
     if (JString::strlen($content) > $config->get('integrations_easysocial_indexer_newpost_length', 250)) {
         $content = JString::substr($content, 0, $config->get('integrations_easysocial_indexer_newpost_length', 250));
     }
     // lets include the title as the search snapshot.
     $content = $blog->title . ' ' . $content;
     $template->setContent($blog->title, $content);
     $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
     // Remove /administrator/ from the url.
     $url = JString::str_ireplace('administrator/', '', $url);
     $template->setSource($blog->id, 'blog', $blog->created_by, $url);
     $template->setThumbnail($image);
     $template->setLastUpdate($blog->modified);
     $state = $indexer->index($template);
     return $state;
 }
예제 #4
0
 public function getPagination()
 {
     $htmlContent = '';
     if ($this->pagination) {
         $page = $this->pagination;
         $previousLink = '';
         $nextLink = '';
         //build the extra params into the url
         $params = $this->buildPaginationParams();
         if (!is_null($page['previous'])) {
             $previousLink = JRoute::_($params . '&limitstart=' . $page['previous']);
         }
         if (!is_null($page['next'])) {
             $nextLink = JRoute::_($params . '&limitstart=' . $page['next']);
         }
         $theme = Foundry::get('Themes');
         $theme->set('next', $nextLink);
         $theme->set('previous', $previousLink);
         $htmlContent = $theme->output('site/stream/pagination');
     }
     return $htmlContent;
 }
 /**
  * Installs subextensions (modules, plugins) bundled with the main extension
  *
  * @param JInstaller $parent
  * @return JObject The subextension installation status
  */
 private function _installSubextensions($parent)
 {
     $src = $parent->getParent()->getPath('source');
     $db = JFactory::getDbo();
     $status = new JObject();
     $status->modules = array();
     $status->plugins = array();
     // Modules installation
     if (count($this->installation_queue['modules'])) {
         foreach ($this->installation_queue['modules'] as $folder => $modules) {
             if (count($modules)) {
                 foreach ($modules as $module => $modulePreferences) {
                     // Install the module
                     if (empty($folder)) {
                         $folder = 'site';
                     }
                     $path = "{$src}/modules/{$folder}/{$module}";
                     if (!is_dir($path)) {
                         $path = "{$src}/modules/{$folder}/mod_{$module}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/modules/{$module}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/modules/mod_{$module}";
                     }
                     if (!is_dir($path)) {
                         $fortest = '';
                         //continue;
                     }
                     // Was the module already installed?
                     $sql = $db->getQuery(true)->select('COUNT(*)')->from('#__modules')->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                     $db->setQuery($sql);
                     $count = $db->loadResult();
                     $installer = new JInstaller();
                     $result = $installer->install($path);
                     $status->modules[] = array('name' => $module, 'client' => $folder, 'result' => $result, 'status' => $modulePreferences[1]);
                     // Modify where it's published and its published state
                     if (!$count) {
                         // A. Position and state
                         list($modulePosition, $modulePublished) = $modulePreferences;
                         if ($modulePosition == 'cpanel') {
                             $modulePosition = 'icon';
                         }
                         $sql = $db->getQuery(true)->update($db->qn('#__modules'))->set($db->qn('position') . ' = ' . $db->q($modulePosition))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                         if ($modulePublished) {
                             $sql->set($db->qn('published') . ' = ' . $db->q('1'));
                         }
                         $db->setQuery($sql);
                         $db->execute();
                         // B. Change the ordering of back-end modules to 1 + max ordering
                         if ($folder == 'admin') {
                             $query = $db->getQuery(true);
                             $query->select('MAX(' . $db->qn('ordering') . ')')->from($db->qn('#__modules'))->where($db->qn('position') . '=' . $db->q($modulePosition));
                             $db->setQuery($query);
                             $position = $db->loadResult();
                             $position++;
                             $query = $db->getQuery(true);
                             $query->update($db->qn('#__modules'))->set($db->qn('ordering') . ' = ' . $db->q($position))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                             $db->setQuery($query);
                             $db->execute();
                         }
                         // C. Link to all pages
                         $query = $db->getQuery(true);
                         $query->select('id')->from($db->qn('#__modules'))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                         $db->setQuery($query);
                         $moduleid = $db->loadResult();
                         $query = $db->getQuery(true);
                         $query->select('*')->from($db->qn('#__modules_menu'))->where($db->qn('moduleid') . ' = ' . $db->q($moduleid));
                         $db->setQuery($query);
                         $assignments = $db->loadObjectList();
                         $isAssigned = !empty($assignments);
                         if (!$isAssigned) {
                             $o = (object) array('moduleid' => $moduleid, 'menuid' => 0);
                             $db->insertObject('#__modules_menu', $o);
                         }
                     }
                 }
             }
         }
     }
     // Plugins installation
     if (count($this->installation_queue['plugins'])) {
         foreach ($this->installation_queue['plugins'] as $folder => $plugins) {
             if (count($plugins)) {
                 foreach ($plugins as $plugin => $published) {
                     $path = "{$src}/plugins/{$folder}/{$plugin}";
                     if (!is_dir($path)) {
                         $path = "{$src}/plugins/{$folder}/plg_{$plugin}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/plugins/{$plugin}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/plugins/plg_{$plugin}";
                     }
                     if (!is_dir($path)) {
                         continue;
                     }
                     // Was the plugin already installed?
                     $query = $db->getQuery(true)->select('COUNT(*)')->from($db->qn('#__extensions'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($plugin)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($plugin)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
                     $db->setQuery($query);
                     $count = $db->loadResult();
                     $installer = new JInstaller();
                     $result = $installer->install($path);
                     $status->plugins[] = array('name' => $plugin, 'group' => $folder, 'result' => $result, 'status' => $published);
                     if ($published && !$count) {
                         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($plugin)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($plugin)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
                         $db->setQuery($query);
                         $db->execute();
                     }
                 }
             }
         }
     }
     // library installation
     if (count($this->installation_queue['libraries'])) {
         foreach ($this->installation_queue['libraries'] as $folder => $status1) {
             $path = "{$src}/libraries/{$folder}";
             $query = $db->getQuery(true)->select('COUNT(*)')->from($db->qn('#__extensions'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($folder)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($folder)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
             $db->setQuery($query);
             $count = $db->loadResult();
             $installer = new JInstaller();
             $result = $installer->install($path);
             $status->libraries[] = array('name' => $folder, 'group' => $folder, 'result' => $result, 'status' => $status1);
             //print"<pre>"; print_r($status->plugins); die;
             if ($published && !$count) {
                 $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($folder)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($folder)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
                 $db->setQuery($query);
                 $db->execute();
             }
         }
     }
     /*
     		 * 'applications'=>array(
     			'easysocial'array(
     					'quick2cartproducts'=>0,
     					'quick2cartstores'=>0
     
     			),
     		 * */
     //Application Installations
     if (count($this->installation_queue['applications'])) {
         foreach ($this->installation_queue['applications'] as $folder => $applications) {
             if (count($applications)) {
                 foreach ($applications as $app => $published) {
                     $path = "{$src}/applications/{$folder}/{$app}";
                     if (!is_dir($path)) {
                         $path = "{$src}/applications/{$folder}/plg_{$app}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/applications/{$app}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/applications/plg_{$app}";
                     }
                     if (!is_dir($path)) {
                         continue;
                     }
                     if (file_exists(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php')) {
                         require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php';
                         // Was the app already installed?
                         /*$query = $db->getQuery(true)
                         			->select('COUNT(*)')
                         			->from($db->qn('#__extensions'))
                         			->where('( '.($db->qn('name').' = '.$db->q($app)) .' OR '. ($db->qn('element').' = '.$db->q($app)) .' )')
                         			->where($db->qn('folder').' = '.$db->q($folder));
                         		$db->setQuery($query);
                         		$count = $db->loadResult();*/
                         $installer = Foundry::get('Installer');
                         // The $path here refers to your application path
                         $installer->load($path);
                         $plg_install = $installer->install();
                         //$status->app_install[] = array('name'=>'easysocial_camp_plg','group'=>'easysocial_camp_plg', 'result'=>$plg_install,'status'=>'1');
                         $status->applications[] = array('name' => $app, 'group' => $folder, 'result' => $result, 'status' => $published);
                     }
                 }
             }
         }
     }
     return $status;
 }
예제 #6
0
 public function onPrepareStoryPanel($story)
 {
     $config = Foundry::config();
     if (!$config->get('photos.enabled')) {
         return;
     }
     // Get current logged in user.
     $my = Foundry::user();
     // Get user access
     $access = Foundry::access($my->id, SOCIAL_TYPE_USER);
     $plugin = $story->createPlugin("photos", "panel");
     $theme = Foundry::get('Themes');
     // check max photos upload here.
     if ($access->exceeded('photos.uploader.max', $my->getTotalPhotos())) {
         $theme->set('exceeded', JText::sprintf('COM_EASYSOCIAL_PHOTOS_EXCEEDED_MAX_UPLOAD', $access->get('photos.uploader.max')));
     }
     // check max photos upload daily here.
     if ($access->exceeded('photos.uploader.maxdaily', $my->getTotalPhotos(true))) {
         $theme->set('exceeded', JText::sprintf('COM_EASYSOCIAL_PHOTOS_EXCEEDED_DAILY_MAX_UPLOAD', $access->get('photos.uploader.maxdaily')));
     }
     $plugin->button->html = $theme->output('themes:/apps/user/photos/story/panel.button');
     $plugin->content->html = $theme->output('themes:/apps/user/photos/story/panel.content');
     $script = Foundry::get('Script');
     $script->set('maxFileSize', $access->get('photos.uploader.maxsize') . 'M');
     $plugin->script = $script->output('apps:/user/photos/story');
     return $plugin;
 }
예제 #7
0
 /**
  * Creates a new stream for new comments in EasyBlog
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function addIndexerNewBlog($blog)
 {
     if (!class_exists('Foundry')) {
         return;
     }
     $config = EasyBlogHelper::getConfig();
     $indexer = Foundry::get('Indexer', 'com_easyblog');
     $template = $indexer->getTemplate();
     // getting the blog content
     $content = $blog->intro . $blog->content;
     $image = '';
     // @rule: Try to get the blog image.
     if ($blog->getImage()) {
         $image = $blog->getImage()->getSource('small');
     }
     if (empty($image)) {
         // @rule: Match images from blog post
         $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i';
         preg_match($pattern, $content, $matches);
         $image = '';
         if ($matches) {
             $image = isset($matches[1]) ? $matches[1] : '';
             if (JString::stristr($matches[1], 'https://') === false && JString::stristr($matches[1], 'http://') === false && !empty($image)) {
                 $image = rtrim(JURI::root(), '/') . '/' . ltrim($image, '/');
             }
         }
     }
     if (!$image) {
         $image = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/default_facebook.png';
     }
     $content = strip_tags($content);
     if (JString::strlen($content) > $config->get('integrations_easysocial_indexer_newpost_length', 250)) {
         $content = JString::substr($content, 0, $config->get('integrations_easysocial_indexer_newpost_length', 250));
     }
     $template->setContent($blog->title, $content);
     $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
     $template->setSource($blog->id, 'blog', $blog->created_by, $url);
     $template->setThumbnail($image);
     $template->setLastUpdate($blog->modified);
     $state = $indexer->index($template);
     return $state;
 }