Esempio n. 1
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $cache = JFactory::getCache();
     $user = JFactory::getUser();
     $model = $this->getModel();
     $articles_model = $this->getModel('articles');
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $id = $app->input->getInt('id', 0);
     if (!$id) {
         if (!$user->guest) {
             $id = $user->id;
         } else {
             if ($this->params->get('blogUserId', 0) > 0) {
                 $id = $this->params->get('blogUserId');
             } else {
                 CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403);
                 return;
             }
         }
     }
     $limitstart = $app->input->getInt('start', 0);
     $limitstart = floor($limitstart / 5) * 5;
     $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id);
     $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => 5, 'order' => 'a.created', 'order_dir' => 'desc', 'user_id' => $id));
     $this->assignRef('user', $profile);
     $this->assignRef('articles', $articles->articles);
     $this->assignRef('pagination', $articles->pagination);
     $document = JFactory::getDocument();
     $title = JText::sprintf('TXT_USERS_BLOG', addslashes($profile['name']));
     $title = CjBlogHelper::get_page_title($title);
     $document->setTitle($title);
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Esempio n. 2
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $cache = JFactory::getCache();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $articles_model = $this->getModel('articles');
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $document->addScript(CJBLOG_MEDIA_URI . 'js/jquery.form.js');
     $document->addScript(CJBLOG_MEDIA_URI . 'js/jquery.Jcrop.min.js');
     $id = $app->input->getInt('id', 0);
     if (!$id) {
         if (!$user->guest) {
             $id = $user->id;
         } else {
             CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403);
             return;
         }
     }
     if ($user->id != $id) {
         $model->hit($id);
     }
     $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id);
     // 		$badges = $cache->call(array('CjBlogApi', 'get_user_badges'), $id);
     // 		$articles = $cache->call(array($articles_model, 'get_articles'), array('published'=>1, 'pagination'=>false, 'limitstart'=>0, 'limit'=>5, 'user_id'=>$id));
     if (!$profile) {
         CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403);
     }
     $this->assignRef('profile', $profile);
     $document->setTitle(CjBlogHelper::get_page_title($profile['name']));
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Esempio n. 3
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $active = $app->getMenu()->getActive();
     $model = $this->getModel();
     $articles_model = $this->getModel('badges');
     $page_heading = '';
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     switch ($this->action) {
         case 'badges_home':
             $badges = $model->get_badges();
             $this->assignRef('badgegroups', $badges);
             $page_heading = JText::_('LBL_BADGES');
             break;
         case 'user_badges':
             $id = $app->input->getInt('id', null);
             $my = JFactory::getUser($id);
             $badges = $model->get_user_badges($my->id);
             $this->assignRef('badgegroups', $badges);
             $page_heading = JText::sprintf('TXT_BADGES_OWNED_BY', $my->name, array('jsSafe' => true));
             $document->setMetaData('robots', 'noindex,follow');
             break;
     }
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = $page_heading;
     }
     $document->setTitle(CjBlogHelper::get_page_title($title));
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Esempio n. 4
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $active = $app->getMenu()->getActive();
     $parent_id = $app->input->getInt('id', 0);
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     $page_heading = JText::_('LBL_CATEGORIES');
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $parent_id = $parent_id == 0 ? 'root' : $parent_id;
     $categories = $model->get_categories($parent_id, false);
     // 		$categories = $cache->call(array($model, 'get_categories'), $parent_id == 0 ? 'root' : $parent_id, false);
     $this->assignRef('categories', $categories);
     $this->assign('brand', $app->getCfg('sitename'));
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = $page_heading;
     }
     $document->setTitle(CjBlogHelper::get_page_title($title));
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Esempio n. 5
0
				<li class="list-group-item<?php 
        echo $item->featured ? ' list-group-item-warning' : '';
        ?>
 pad-bottom-5">
					<div class="article-block media">
					
						<?php 
        if ($params->get('show_thumbnails')) {
            ?>
						<div class="pull-left hidden-phone hidden-xs">
							<a href="<?php 
            echo $articleUrl;
            ?>
" class="thumbnail no-margin-bottom">
								<img src="<?php 
            echo CjBlogHelper::get_article_thumbnail($item, $thumbSize);
            ?>
" style="width: auto; max-width: <?php 
            echo $thumbSize;
            ?>
px;" class="media-object"/>
							</a>
						</div>
						<?php 
        }
        ?>
						
						<?php 
        if ($params->get('list_show_avatar')) {
            ?>
				    		<?php 
Esempio n. 6
0
 public function onContentAfterSave($context, $article, $isNew)
 {
     if ($context != 'com_content.form' && $context != 'com_content.article' || !$article->id) {
         return true;
     }
     // delete thumbnail image to avoid wrong thumbnail in listings if article image has changed
     CjBlogHelper::delete_article_thumbnail($article);
     $api = JPATH_ROOT . '/components/com_cjblog/api.php';
     if (file_exists($api)) {
         require_once $api;
         $db = JFactory::getDbo();
         // insert or update tags
         $app = JFactory::getApplication();
         $tags = $app->input->get('tags', array(), 'array');
         $this->insert_tags($article->id, $tags);
         $query = 'select count(*) from #__content where created_by = ' . $article->created_by . ' and state = 1';
         $db->setQuery($query);
         $count = (int) $db->loadResult();
         CjBlogApi::trigger_badge_rule('com_content.num_articles', array('num_articles' => $count, 'ref_id' => $article->created_by), $article->created_by);
         if ($isNew) {
             CjBlogApi::award_points('com_content.newarticle', $article->created_by, 0, $article->id, $article->title);
             $query = 'update #__cjblog_users set num_articles = ' . $count . ' where id = ' . $article->created_by;
             $db->setQuery($query);
             $db->query();
         }
     } else {
         die('CjBlog component is not installed.');
     }
 }
Esempio n. 7
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $model = $this->getModel();
     $cache = JFactory::getCache();
     $document = JFactory::getDocument();
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $id = $app->input->getInt('id', 0);
     $result = new stdClass();
     $page_heading = '';
     $page_url = 'index.php?option=' . CJBLOG . '&view=users';
     switch ($this->action) {
         case 'top_bloggers':
             $result = $model->get_users(2);
             $page_heading = JText::_('LBL_TOP_BLOGGERS');
             $page_url = $page_url . '&task=top';
             break;
         case 'search':
             $query = $app->input->getString('search', '');
             $result = $model->get_users(4, array('query' => $query));
             $page_heading = JText::_('LBL_SEARCH');
             break;
         case 'badge_owners':
             $result = $model->get_users(3, array('badge_id' => $id));
             $badge = CjBlogApi::get_badge_details($id);
             $page_heading = JText::sprintf('TXT_USERS_WHO_WON_BADGE', $badge['title'], array('jsSafe' => true));
             $page_url = $page_url . '&task=badge&id=' . $id . ':' . $badge['alias'];
             break;
         case 'new_bloggers':
         default:
             $result = $model->get_users(1);
             $page_heading = JText::_('LBL_NEW_BLOGGERS');
             break;
     }
     if (!empty($result->users)) {
         $userIds = array_keys($result->users);
         if (!empty($userIds)) {
             $api = new CjLibApi();
             $avatarApp = $this->params->get('avatar_component', 'cjforum');
             $profileApp = $this->params->get('profile_component', 'cjforum');
             $api->prefetchUserProfiles($avatarApp, $userIds);
             if ($avatarApp != $profileApp) {
                 $api->prefetchUserProfiles($profileApp, $userIds);
             }
         }
     }
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = $page_heading;
     }
     $document->setTitle(CjBlogHelper::get_page_title($title));
     $this->assign('brand', $app->getCfg('sitename'));
     if (!empty($result)) {
         $this->assignRef('users', $result->users);
         $this->assignRef('pagination', $result->pagination);
         $this->assignRef('state', $result->state);
     }
     $this->assignRef('page_url', $page_url);
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Esempio n. 8
0
<div id="cj-wrapper">

	<?php 
include_once JPATH_COMPONENT . '/helpers/header.php';
?>
	<?php 
echo JLayoutHelper::render($layout . '.toolbar', array('params' => $this->params));
?>
	
	<div class="container-fluid category-table">
	  <div class="row-fluid">
	    <div class="span12">
	    
	    	<?php 
if (!empty($page_heading)) {
    ?>
	    	<h1 class="nopad-top padbottom-5 page-header"><?php 
    echo $this->escape($page_heading);
    ?>
</h1>
	    	<?php 
}
?>
	    	
	    	<?php 
echo CjBlogHelper::get_category_table($this->categories, $this->params, array('base_url' => 'index.php?option=' . CJBLOG . '&view=categories&task=latest', 'itemid' => $articles_itemid));
?>
	    </div>
	  </div>
	</div>
</div>
Esempio n. 9
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $cache = JFactory::getCache();
     $active = $app->getMenu()->getActive();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     $pathway = $app->getPathway();
     $model = $this->getModel();
     $category_model = $this->getModel('categories');
     $limit = $app->getCfg('list_limit', 20);
     $limitstart = $app->input->getInt('limitstart', 0);
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $this->print = $app->input->getBool('print');
     $catid = $app->input->getInt('id', 0);
     $this->category = $category = null;
     $max_cat_levels = 0;
     $page_heading = '';
     $page_url = 'index.php?option=' . CJBLOG . '&view=articles';
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
         $active_menu_catid = (int) $menuParams->get('catid', 0);
         if ($catid == 0 && $active_menu_catid > 0) {
             $catid = $active_menu_catid;
         }
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     if ($this->action != 'tagged_articles' && $catid > 0) {
         $max_cat_levels = intval($this->params->get('max_category_levels', -1));
         $category = $category_model->get_category($catid);
         $groups = $user->getAuthorisedViewLevels();
         if (!$category || !in_array($category->access, $groups)) {
             CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 403);
         }
         $this->assignRef('category', $category);
         $app->input->set('cjblogcatid', $catid);
     }
     switch ($this->action) {
         case 'latest_articles':
             $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.created', 'order_dir' => 'desc'));
             $this->assignRef('articles', $articles->articles);
             $this->assignRef('pagination', $articles->pagination);
             $this->assign('active_id', 3);
             $page_heading = JText::_('LBL_LATEST_ARTICLES');
             $page_url = $page_url . '&task=latest';
             break;
         case 'trending_articles':
             $trending_days = 30;
             $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'day_limit' => $trending_days, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.hits', 'order_dir' => 'desc'));
             $this->assignRef('articles', $articles->articles);
             $this->assignRef('pagination', $articles->pagination);
             $this->assign('active_id', 3);
             $page_heading = JText::_('LBL_TRENDING_ARTICLES') . ' ( ' . JText::sprintf('TXT_IN_LAST_X_DAYS', $trending_days) . ' )';
             $page_url = $page_url . '&task=trending';
             break;
         case 'popular_articles':
             $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.hits', 'order_dir' => 'desc'));
             $this->assignRef('articles', $articles->articles);
             $this->assignRef('pagination', $articles->pagination);
             $this->assign('active_id', 3);
             $page_heading = JText::_('LBL_MOST_POPULAR_ARTICLES');
             $page_url = $page_url . '&task=popular';
             break;
         case 'favorite_articles':
             $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'favorites' => true, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.hits', 'order_dir' => 'desc'));
             $this->assignRef('articles', $articles->articles);
             $this->assignRef('pagination', $articles->pagination);
             $this->assign('active_id', 6);
             $page_heading = JText::_('LBL_MY_FAVORITE_ARTICLES');
             $page_url = $page_url . '&task=favorites';
             break;
         case 'tagged_articles':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 return CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 403);
             }
             $articles = $model->get_articles(array('tag_id' => $id, 'published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.created', 'order_dir' => 'desc'));
             $tag = $model->get_tag_details($id);
             $this->assignRef('articles', $articles->articles);
             $this->assignRef('pagination', $articles->pagination);
             $this->assign('page_description', $tag->description);
             $this->assign('active_id', 3);
             $page_heading = JText::sprintf('TXT_TAGGED_ARTICLES', $this->escape($tag->tag_text));
             $page_url = $page_url . '&task=tag&id=' . $tag->id . ':' . $tag->alias;
             break;
     }
     // set breadcrumbs
     $path = array(array('title' => $this->params->get('page_heading'), 'link' => ''));
     if ($category) {
         $temp = $category;
         $page_heading = $page_heading . ': ' . $category->title;
         $page_url = $page_url . '&id=' . $category->id . (!empty($category->alias) ? ':' . $category->alias : '');
         while ($temp && ($active->query['option'] != CJBLOG || $active->query['view'] == 'articles') && $temp->id > 1) {
             $path[] = array('title' => $category->title, 'link' => ContentHelperRoute::getCategoryRoute($temp->id));
             $temp = $temp->getParent();
         }
     }
     $path = array_reverse($path);
     foreach ($path as $item) {
         $pathway->addItem($item['title'], $item['link']);
     }
     // set browser title
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = $page_heading;
     }
     $document->setTitle(CjBlogHelper::get_page_title($title));
     // set meta description
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     // set meta keywords
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     // set robots
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     // set nofollow if it is print
     if ($this->print) {
         $document->setMetaData('robots', 'noindex, nofollow');
     }
     $this->assignRef('page_url', $page_url);
     // display
     parent::display($tpl);
 }
Esempio n. 10
0
 /**
  * Fetch JPEG or PNG or GIF Image
  *
  * A custom function in PHP which lets you fetch jpeg or png images from remote server to your local server
  * Can also prevent duplicate by appending an increasing _xxxx to the filename. You can also overwrite it.
  *
  * Also gives a debug mode to check where the problem is, if this is not working for you.
  *
  * @author Swashata <swashata ~[at]~ intechgrity ~[dot]~ com>
  * @copyright Do what ever you wish - I like GPL <img src="http://www.intechgrity.com/wp-includes/images/smilies/icon_smile.gif?84cd58" alt=":)" class="wp-smiley">  (& love tux <img src="http://www.intechgrity.com/wp-includes/images/smilies/icon_wink.gif?84cd58" alt=";)" class="wp-smiley"> )
  * @link http://www.intechgrity.com/?p=808
  *
  * @param string $img_url The URL of the image. Should start with http or https followed by :// and end with .png or .jpeg or .jpg or .gif. Else it will not pass the validation
  * @param string $store_dir The directory where you would like to store the images.
  * @param string $store_dir_type The path type of the directory. 'relative' for the location in relation with the executing script location or 'absolute'
  * @param bool $overwrite Set to true to overwrite, false to create a new image with different name
  * @param bool|int $pref internally used to prefix the extension in case of duplicate file name. Used by the trailing recursion call
  * @param bool $debug Set to true for enable debugging and print some useful messages.
  * @return string the location of the image (either relative with the current script or abosule depending on $store_dir_type)
  */
 public static function fetch_image($img_url, $store_dir = 'image', $store_dir_type = 'relative', $overwrite = false, $pref = false, $debug = false)
 {
     //first get the base name of the image
     $i_name = explode('.', basename($img_url));
     $i_name = $i_name[0];
     //now try to guess the image type from the given url
     //it should end with a valid extension...
     //good for security too
     if (preg_match('/(http|https)?:\\/\\/.*\\.png$/i', strtolower($img_url))) {
         $img_type = 'png';
     } else {
         if (preg_match('/(http|https)?:\\/\\/.*\\.(jpg|jpeg)$/i', strtolower($img_url))) {
             $img_type = 'jpg';
         } else {
             if (preg_match('/(http|https)?:\\/\\/.*\\.gif$/i', strtolower($img_url))) {
                 $img_type = 'gif';
             } else {
                 if (true == $debug) {
                     echo 'Invalid image URL';
                 }
                 return '';
                 //possible error on the image URL
             }
         }
     }
     $dir_name = ($store_dir_type == 'relative' ? './' : '') . rtrim($store_dir, '/') . '/';
     //create the directory if not present
     if (!file_exists($dir_name)) {
         mkdir($dir_name, 0777, true);
     }
     //calculate the destination image path
     $i_dest = $dir_name . $i_name . ($pref === false ? '' : '_' . $pref) . '.' . $img_type;
     //lets see if the path exists already
     if (file_exists($i_dest)) {
         $pref = (int) $pref;
         //modify the file name, do not overwrite
         if (false == $overwrite) {
             return CjBlogHelper::fetch_image($img_url, $store_dir, $store_dir_type, $overwrite, ++$pref, $debug);
         } else {
             unlink($i_dest);
         }
     }
     //first check if the image is fetchable
     $img_info = @getimagesize($img_url);
     //is it a valid image?
     if (false == $img_info || !isset($img_info[2]) || !($img_info[2] == IMAGETYPE_JPEG || $img_info[2] == IMAGETYPE_PNG || $img_info[2] == IMAGETYPE_JPEG2000 || $img_info[2] == IMAGETYPE_GIF)) {
         if (true == $debug) {
             echo 'The image doesn\'t seem to exist in the remote server. Image: ' . $img_url . '| Image info: ' . print_r($img_info, true);
         }
         // 			jexit();
         return '';
         //return empty string
     }
     //now try to create the image
     if ($img_type == 'jpg') {
         $m_img = @imagecreatefromjpeg($img_url);
     } else {
         if ($img_type == 'png') {
             $m_img = @imagecreatefrompng($img_url);
             @imagealphablending($m_img, false);
             @imagesavealpha($m_img, true);
         } else {
             if ($img_type == 'gif') {
                 $m_img = @imagecreatefromgif($img_url);
             } else {
                 $m_img = FALSE;
             }
         }
     }
     //was the attempt successful?
     if (FALSE === $m_img) {
         if (true == $debug) {
             echo 'Can not create image from the URL';
         }
         return '';
     }
     //now attempt to save the file on local server
     if ($img_type == 'jpg') {
         if (imagejpeg($m_img, $i_dest, 100)) {
             return $i_dest;
         } else {
             return '';
         }
     } else {
         if ($img_type == 'png') {
             if (imagepng($m_img, $i_dest, 0)) {
                 return $i_dest;
             } else {
                 return '';
             }
         } else {
             if ($img_type == 'gif') {
                 if (imagegif($m_img, $i_dest)) {
                     return $i_dest;
                 } else {
                     return '';
                 }
             }
         }
     }
     return '';
 }
Esempio n. 11
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $model = $this->getModel();
     $cache = JFactory::getCache();
     $user = JFactory::getUser();
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     $page_heading = '';
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $result = new stdClass();
     switch ($this->action) {
         case 'user_points':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 $id = $user->id;
             }
             $order = $app->getUserStateFromRequest("cjbloguserpoints.order", 'order', 'a.created', 'cmd');
             $order_Dir = $app->getUserStateFromRequest("cjbloguserpoints.order_Dir", 'order_Dir', 'DESC', 'word');
             $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id);
             $result = $model->get_user_point_details($id, array('order' => $order, 'order_dir' => $order_Dir));
             $points = !empty($result->points) ? $result->points : array();
             $this->assignRef('profile', $profile);
             $this->assignRef('points', $points);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('state', $result->state);
             $page_heading = JText::sprintf('COM_CJBLOG_MY_POINTS_DETAILS', $profile['points']);
             break;
         case 'user_articles':
             $id = $app->input->getInt('id', 0);
             $my = null;
             if (!$id) {
                 $id = $user->id;
                 $my = $user;
             } else {
                 $my = JFactory::getUser($id);
             }
             $limit = $app->getCfg('list_limit', 20);
             $limitstart = $app->input->getInt('start', 0);
             $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
             $username = $this->params->get('user_display_name', 'name');
             $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'user_id' => $my->id, 'limitstart' => $limitstart, 'limit' => $limit, 'order' => 'a.created', 'order_dir' => 'desc'));
             $page_heading = JText::sprintf('TXT_USER_ARTICLES', $my->{$username}, array('jsSafe' => true));
             $page_url = 'index.php?option=' . CJBLOG . '&view=user&task=articles&id=' . $my->id . ':' . $my->username;
             $this->assignRef('articles', $articles->articles);
             $this->assignRef('pagination', $articles->pagination);
             $this->assignRef('page_url', $page_url);
             $tpl = 'articles';
             break;
         default:
             break;
     }
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = $page_heading;
     }
     JFactory::getDocument()->setTitle(CjBlogHelper::get_page_title($title));
     parent::display($tpl);
 }