Esempio n. 1
0
 public function setParams($id, $template, $layout)
 {
     require_once JPATH_SITE . '/components/com_content/models/article.php';
     $model = new ContentModelArticle();
     $this->item = $model->getItem($id);
     $this->state = $model->getState();
     $this->setLayout($template . ':' . $layout);
     $this->item->article_layout = $template . ':' . $layout;
     $this->_addPath('template', JPATH_SITE . '/templates/' . $template . '/html/com_content/article');
     $this->_addPath('template', JPATH_SITE . '/components/com_content/views/article/tmpl');
 }
Esempio n. 2
0
function addArticle($catid, $title, $introtext, $fulltext = '', $state = 1, $extra = array())
{
    // catid - id категории, title-заголовок, introtext-вводный текст, fulltext-текст подробнее, state - состояние, extra-ассоциативный массив с доп. аттрибутами
    require_once "administrator/components/com_content/models/article.php";
    $article = new ContentModelArticle();
    $data = array('catid' => $catid, 'title' => $title, 'introtext' => $introtext, 'fulltext' => $fulltext, 'state' => $state);
    foreach ($extra as $key => $item) {
        $data[$key] = $item;
    }
    $article->save($data);
}
Esempio n. 3
0
 /**
  *
  * Get item
  *
  * @param Array $pk
  */
 public function &getItem($pk = array())
 {
     $item = parent::getItem($pk['id']);
     // Add router helpers.
     $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
     $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
     $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
     // Merge article params. If this is single-article view, menu params override article params
     // Otherwise, article params override menu item params
     $this->params = $this->state->get('params');
     $temp = clone $this->params;
     // Merge so that article params take priority
     $temp->merge($item->params);
     $item->params = $temp;
     //Megre params
     $JSNConfig = JSNFactory::getConfig();
     $JSNConfig->megreMenuParams($pk['Itemid'], $item->params);
     $JSNConfig->megreGlobalParams('com_content', $item->params, true);
     $offset = $this->state->get('list.offset');
     $item->pageclass_sfx = htmlspecialchars($item->params->get('pageclass_sfx'));
     return $item;
 }
Esempio n. 4
0
	public function getItem($pk = null)
	{
		$getTemplate = false;
		if(in_array(JRequest::getCmd('task'), array('weblayout', 'webpreview'))){
			$params = JComponentHelper::getParams('com_joooid');
			$pk = intval($params->get('template_content_id', 8));
			JRequest::setVar('id', $pk);
			$getTemplate = true;

			$params->set('access-view', true);
			$this->setState('params', $params);
		}

		$item = parent::getItem($pk);
		if ($item) {
			if($getTemplate){
				$item->introtext = '{post-body}';
				$item->fulltext = '';
				$item->title = '{post-title}';
			}
		}

		return $item;
	}
Esempio n. 5
0
	static function getSlideDescription($slide, $limit) {
		$sparams = new JRegistry($slide->params);
		if($sparams->get('link_type','')=='article' && empty($slide->description)){ // if article and no description then get introtext as description
			$artid = $sparams->get('id',$sparams->get('link_article',0));
			require_once(JPATH_BASE.DS.'components'.DS.'com_content'.DS.'models'.DS.'article.php');
			$model = new ContentModelArticle();
			$article = $model->getItem($artid);
			if($article) {
				$slide->description = $article->introtext;
			}
		}
		
		$desc = strip_tags($slide->description);
		if($limit && $limit < strlen($desc)) {
			$limit = strpos($desc, ' ', $limit);
			$desc = substr($desc, 0, $limit);
			if(preg_match('/[A-Za-z0-9]$/', $desc)) $desc.=' ...';
			$desc = nl2br($desc);
		} else { // no limit or limit greater than description
			$desc = $slide->description;
		}

		return $desc;
	}
Esempio n. 6
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function save($data)
 {
     // Prevent deleting multilang associations
     $app = JFactory::getApplication();
     $assoc = isset($app->item_associations) ? $app->item_associations : 0;
     $app->item_associations = 0;
     $result = parent::save($data);
     $app->item_associations = $assoc;
     return $result;
 }
Esempio n. 7
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function save($data)
 {
     // Associations are not edited in frontend ATM so we have to inherit them
     if (JLanguageAssociations::isEnabled() && !empty($data['id'])) {
         if ($associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $data['id'])) {
             foreach ($associations as $tag => $associated) {
                 $associations[$tag] = (int) $associated->id;
             }
             $data['associations'] = $associations;
         }
     }
     return parent::save($data);
 }
 public function getItem($translation = null)
 {
     $item = parent::getItem();
     return $item;
     $table = clone parent::getItem();
     // I could pick up the URL here or treat as a special content element field type?
     if ($table->type == 'component') {
         // Note that to populate the initial value of the urlparams
         $conf = JFactory::getConfig();
         $elementTable = $conf->getValue('joomfish.elementTable', false);
         foreach ($elementTable->Fields as $efield) {
             if ($efield->Name == "link" && isset($efield->translationContent->value) && $efield->translationContent->value !== "") {
                 $uri = new JURI($efield->translationContent->value);
                 if ($uri->getVar("option", false)) {
                     $table->link = $efield->translationContent->value;
                 }
             }
         }
         $url = str_replace('index.php?', '', $table->link);
         $url = str_replace('&amp;', '&', $url);
         $table->linkparts = null;
         if (strpos($url, '&amp;') !== false) {
             $url = str_replace('&amp;', '&', $url);
         }
         parse_str($url, $table->linkparts);
         $db = $this->getDBO();
         if ($component = @$table->linkparts['option']) {
             $query = 'SELECT `extension_id`' . ' FROM `#__extensions`' . ' WHERE `element` = "' . $db->getEscaped($component) . '"';
             $db->setQuery($query);
             $table->componentid = $db->loadResult();
         }
     }
     $item = $table;
     return $item;
 }
Esempio n. 9
0
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Ilya Shunko <*****@*****.**>
 * @copyright Copyright 2005-2011 Purdue University. All rights reserved.
 * @license   http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
$this->css();
$customLandingPage = $this->config->get('landingPage', 0);
$return = base64_encode(Route::url('index.php?option=storefront'));
$loginUrl = Route::url('index.php?option=com_users&view=login&return=' . $return);
if ($customLandingPage && is_numeric($customLandingPage)) {
    include_once PATH_CORE . DS . 'components' . DS . 'com_content' . DS . 'site' . DS . 'models' . DS . 'article.php';
    $content = new ContentModelArticle();
    $article = $content->getItem($customLandingPage);
    if ($article->params->get('show_intro', '1') == '1') {
        $article->text = $article->introtext . ' ' . $article->fulltext;
    } elseif ($item->fulltext) {
        $article->text = $article->fulltext;
    } else {
        $article->text = $article->introtext;
    }
    // Prepare content to add CSS and other xhub stuff
    Event::trigger('content.onContentPrepare', array('com_content.article', &$article, array()));
    ?>

	<header id="content-header">
		<h2><?php 
    echo $article->title;
Esempio n. 10
0
 /**
  * a $item -ben adott temakor rekordhoz kapcsolodó cikk
  * létrehozása vagy modositása
  * @param integer az új rekord id -je
  * @param mysql record object  $item 
  * @return boolean     
  */
 protected function storeArtycle($newId, $item)
 {
     $result = true;
     $link = '<p><a href="' . JURI::base() . 'index.php?option=com_szavazasok&view=szavazasoklist&temakor=' . $newId . '">Ugrás a témakör oldalára</a></p>';
     $db = JFactory::getDBO();
     $db->setQuery('SELECT id FROM #__content WHERE alias="t' . $item->id . '"');
     $res = $db->loadObject();
     if ($res) {
         // kapcsolodó cikk rekord update
         $db->setQuery('update #__content
        set title=' . $db->quote($item->megnevezes . ' (kommentek)') . ',
            introtext = ' . $db->quote($item->leiras . $link) . '
        where alias="t' . $item->id . '"    
        ');
         $result = $db->query();
         if ($db->getErrorNum() > 0) {
             $db->stderr();
         }
     } else {
         $artycleData = array('catid' => 10, 'title' => $item->megnevezes . ' (kommentek)', 'introtext' => $item->leiras . $link, 'fulltext' => '', 'alias' => 't' . $newId, 'metadata' => '', 'state' => 1);
         $new_article = new ContentModelArticle();
         $result = $new_article->save($artycleData);
     }
     return $result;
 }
Esempio n. 11
0
        $state->set('params', $temp);
        $view->set('State', $state);
        // Send the display
        print $view->display();
        JRequest::setVar("id", $original_id);
        $pathway->setPathway($oldPath);
    }
} else {
    JHTML::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_content' . DS . 'helpers');
    require_once JPATH_BASE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'query.php';
    require_once JPATH_BASE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
    require_once JPATH_BASE . DS . 'components' . DS . 'com_content' . DS . 'models' . DS . 'article.php';
    jimport('joomla.application.component.helper');
    require_once 'view.html.php';
    $id = (int) $params->get('id', 0);
    $articleModel = new ContentModelArticle();
    $articleModel->setId($id);
    $articleView = new ContentViewArticle2();
    $mainframe =& JFactory::getApplication();
    jimport('joomla.filesystem.file');
    // Chose the template to use. Thanks to Jasper Jaklofsky of djeedjee.net for the code!
    if (JFile::exists(JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'mod_article' . DS . 'article' . DS . 'default.php')) {
        $articleView->addTemplatePath(JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'mod_article' . DS . 'article');
    } else {
        if ($params->get('allowTemplateOveride', false) && JFile::exists(JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_content' . DS . 'article' . DS . 'default.php')) {
            $articleView->addTemplatePath(JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_content' . DS . 'article');
        } else {
            $articleView->addTemplatePath(JPATH_BASE . DS . 'components' . DS . 'com_content' . DS . 'views' . DS . 'article' . DS . 'tmpl');
        }
    }
    // End template choice
Esempio n. 12
0
		/**
	 * Creates a faux article inside the specified category
	 * 
	 * @param type $cat_id
	 * @param type $levelpath
	 * @param type $currentArticle 
	 */
	private function createArticle_usingModel($cat_id = '1', $levelpath = '1', $currentArticle = 1)
	{
		$data = $this->getArticleData($cat_id, $levelpath, $currentArticle);
		
		require_once JPATH_ADMINISTRATOR.'/components/com_content/models/article.php';
		$model = new ContentModelArticle();
		$result = $model->save($data);
	}
Esempio n. 13
0
 /**
  *
  * Get article data
  * @param int $id
  * @return object
  */
 function getList($id = 0)
 {
     // Get the dbo
     $db = JFactory::getDbo();
     require_once JPATH_BASE . '/components/com_content/models/article.php';
     $model = new ContentModelArticle();
     $row = $model->getItem($id);
     return $row;
 }
Esempio n. 14
0
	/**
	 * Method to test whether a record can be deleted.
	 *
	 * @param	object	$record	A record object.
	 *
	 * @return	boolean	True if allowed to change the state of the record. Defaults to the permission set in the component.
	 * @since	1.6
	 */
	public function canEditState($record)
	{
		return parent::canEditState($record);
	}
Esempio n. 15
0
 public function post()
 {
     //init variable
     $app = JFactory::getApplication();
     $result = new stdClass();
     $article_id = $app->input->get('id', 0, 'INT');
     if (!$article_id) {
         $result->success = 0;
         $result->message = 'Please select article';
         $this->plugin->setResponse($result);
         return;
     }
     $art_obj = new ContentModelArticle();
     $art_obj->setId($article_id);
     $a_data = $art_obj->getArticle();
     //format data
     $obj = new BlogappSimpleSchema();
     //$item = $obj->mapPost($a_data,'', 100, array('text'));
     $item = $obj->mapPost($a_data, '', 100, array());
     $this->plugin->setResponse($item);
 }
Esempio n. 16
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $data['zip'] = JRequest::getVar('zip', null, 'files', 'array');
     var_dump($data);
     echo '<pre>';
     debug_print_backtrace();
     die;
     throw new \Exception('test');
     parent::save($data);
 }
Esempio n. 17
0
 function getList($ids = '', $catid = '', $limit = 0)
 {
     global $mainframe;
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $aid = $user->get('aid', 0);
     $contentConfig = JComponentHelper::getParams('com_content');
     $noauth = !$contentConfig->get('shownoauth');
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     $nullDate = $db->getNullDate();
     // query to determine article count
     $query = 'SELECT a.id' . ' FROM #__content AS a';
     $query .= ' WHERE a.state = 1 ';
     $query .= ' AND (a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' ) ' . ' AND (a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
     if ($ids != '') {
         $query .= "\n AND a.id in ({$ids})";
     }
     if ($catid != '') {
         $query .= " AND a.catid in ({$catid})";
     }
     $query .= ' ORDER BY a.ordering ';
     if ($catid != '' && $limit > 0) {
         $query .= "LIMIT 0, {$limit}";
     }
     $db->setQuery($query);
     $ids = $db->loadResultArray();
     jimport('joomla.plugin.helper');
     JPluginHelper::importPlugin('content');
     $app = JFactory::getApplication();
     $params = new JParameter('');
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'query.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'models' . DS . 'article.php';
     $model = new ContentModelArticle();
     $rows = array();
     foreach ($ids as $id) {
         $model->setId($id);
         $row = $model->getArticle();
         if ($row->id) {
             $app->triggerEvent('onPrepareContent', array(&$row, &$params, $limitstart));
             $row->introtext = $row->text;
             $rows[] = $row;
         }
     }
     return $rows;
 }
Esempio n. 18
0
 public function doReward($from_address, $to_address, $amounts)
 {
     $address_amounts = DogecoinTippingHelper::getBalance(array('addresses' => $from_address));
     $inline_amounts = $this->getInlineAmounts($from_address);
     $withdraw_address_amount = 0;
     $withdraw_inline_amount = 0;
     $article_id = $_POST['article_id'];
     require_once JPATH_SITE . '/components/com_content/models/article.php';
     $articleModel = new ContentModelArticle();
     $article = $articleModel->getItem($article_id);
     $params = JComponentHelper::getParams('com_dogecointipping');
     $email_title = $params->get('email_title');
     $email_template = $params->get('email_template');
     $returnInfo = new stdClass();
     if ($address_amounts - 1 >= $amounts) {
         //withdraw from dogecoin address
         try {
             $withdrawInfo = $this->block_io->withdraw(array('from_addresses' => $from_address, 'to_addresses' => $this->withdraw_address, 'amounts' => $amounts));
         } catch (Exception $e) {
             throw $e;
         }
         $this->add_inline($to_address, $amounts);
         $returnInfo->status = sprintf(JText::_('COM_DOGECOINTIPPING_WITHDRAW_BLOCKIO_SUCCESS'), $from_address, $amounts);
         $withdraw_address_amount = $amounts;
     } elseif ($address_amounts > 2 && $address_amounts - 1 + $inline_amounts - 1 >= $amounts) {
         //withdraw from dogecoin address and site inline amount
         try {
             $withdrawInfo = $this->block_io->withdraw(array('from_addresses' => $from_address, 'to_addresses' => $this->withdraw_address, 'amounts' => $address_amounts - 1));
         } catch (Exception $e) {
             throw $e;
         }
         $this->add_inline($to_address, $address_amounts - 1);
         try {
             $this->rewardInline($from_address, $to_address, $amounts - $address_amounts + 1);
         } catch (Exception $e) {
             throw $e;
         }
         $returnInfo->status = sprintf(JText::_('COM_DOGECOINTIPPING_WITHDRAW_BLOCKIO_SUCCESS'), $from_address, $address_amounts - 1) . "<br>";
         $returnInfo->status .= sprintf(JText::_('COM_DOGECOINTIPPING_WITHDRAW_INLINE_SUCCESS'), $amounts - $address_amounts + 1);
         $withdraw_address_amount = $address_amounts - 1;
         $withdraw_inline_amount = $amounts - $address_amounts + 1;
     } elseif ($inline_amounts - 1 >= $amounts) {
         //withdraw from site inline amount
         try {
             $withdrawInfo = $this->rewardInline($from_address, $to_address, $amounts);
         } catch (Exception $e) {
             throw $e;
         }
         $returnInfo->status = sprintf(JText::_('COM_DOGECOINTIPPING_WITHDRAW_INLINE_SUCCESS'), $amounts);
         $withdraw_inline_amount = $amounts;
     } else {
         // no money
         throw new Exception(JText::_('COM_DOGECOINTIPPING_WITHDRAW_NO_ENOUGH_MONEY'));
     }
     $desc = $_POST['reward_desc'];
     $to_userid = $_POST['to_userid'];
     $query_string = $_POST['query_string'];
     $data = new stdClass();
     $data->from_user_id = JFactory::getUser()->id;
     $data->to_user_id = $to_userid;
     $data->amount = $amounts;
     $data->desc = $desc;
     $data->payment_result = $returnInfo->status;
     $data->query_string = $query_string;
     $data->address_amount = $withdraw_address_amount;
     $data->inline_amount = $withdraw_inline_amount;
     $data->created = JFactory::getDate()->toSql();
     $data->article_id = $article_id;
     JFactory::getDBO()->insertObject('#__dogecointipping_reward', $data);
     $user = JFactory::getUser();
     $email_body = JString::str_ireplace('{from_user}', $user->name, $email_template);
     $email_body = JString::str_ireplace('{amount}', $amounts, $email_body);
     $article_url = JURI::root() . 'index.php?' . $query_string;
     $email_body = JString::str_ireplace('{article}', '<a href="' . $article_url . '" target="_blank">' . $article->title . '</a>', $email_body);
     $this->sendMail($to_userid, $email_title, $email_body);
     return $returnInfo;
 }
Esempio n. 19
0
 /**
  * a $item -ben adott temakor rekordhoz kapcsolodó cikk
  * létrehozása vagy modositása
  * @param mysql record object  $item 
  * @return boolean     
  */
 protected function storeArtycle($newId, $item)
 {
     $result = true;
     $db = JFactory::getDBO();
     $user = JFactory::getUser($item->user_id);
     $db->setQuery('SELECT id FROM #__content WHERE alias="k' . $item->id . '"');
     $res = $db->loadObject();
     if ($res) {
         // kapcsolodó cikk rekord update
         $db->setQuery('update #__content
        set title="' . $db->quote($user->name . ' (kommentek)') . '",
            introtext = ""
        where alias="k' . $item->id . '"    
        ');
         $result = $db->query();
         if ($db->getErrorNum() > 0) {
             $db->stderr();
         }
     } else {
         $artycleData = array('catid' => 10, 'title' => $item->name . ' (kommentek)', 'introtext' => '', 'fulltext' => '', 'alias' => 'k' . $newId, 'metadata' => '', 'state' => 1);
         $new_article = new ContentModelArticle();
         $result = $new_article->save($artycleData);
     }
     return $result;
 }
Esempio n. 20
0
 /**
  *
  */
 public static function getAjax()
 {
     //echo 'I am here';
     //die();
     $language = JFactory::getLanguage();
     $language->load('mod_quickpublish', JPATH_ADMINISTRATOR, 'en-GB', true);
     $language->load('mod_quickpublish', JPATH_ADMINISTRATOR, null, true);
     jimport('joomla.session.session');
     jimport('joomla.application.module.helper');
     require_once JPATH_ADMINISTRATOR . '/components/com_content/models/article.php';
     $app = JFactory::getApplication();
     $tk = $app->input->getCmd('tk');
     $modid = intval($app->input->getCmd('modid'));
     $title = $app->input->getString('title');
     $articletext = $app->input->getHtml('articletext');
     $state = $app->input->getInt('state');
     $catid = $app->input->getInt('catid');
     $tags = json_decode($app->input->getString('tags'));
     $metakey = $app->input->getString('metakey');
     $metadesc = $app->input->getString('metadesc');
     //var_dump($tags);
     if (!($modid > 1)) {
         $res['error'] = JText::_('MOD_QUICKPUBLISH_MOD_ID_MISSING');
         echo json_encode($res);
         die;
     }
     if (empty($title) || empty($articletext)) {
         $res['error'] = JText::_('MOD_QUICKPUBLISH_TITLE_DESC_MISSING');
         echo json_encode($res);
         die;
     }
     $session = JFactory::getSession();
     if ($session->hasToken($tk)) {
         //$module = &JModuleHelper::getModule( 'univcurconverter');
         //$params = new JRegistry($module->params);
         /*
         $module     = JTable::getInstance('module', 'JTable', array());
         $module->id = $modid;
         $module->load();
         $params  = new JObject();
         if(is_object($module)){
             $params              = new JRegistry( $module->params );
         }
         */
         $data = array('id' => 0, 'title' => $title, 'alias' => '', 'articletext' => $articletext, 'state' => $state, 'catid' => $catid, 'access' => '1', 'language' => '*', 'rules' => array('core.delete' => array('6' => 1), 'core.edit' => array('6' => 1, '4' => 1), 'core.edit.state' => array('6' => 1, '5' => 1)), 'tags' => $tags, 'metakey' => $metakey, 'metadesc' => $metadesc);
         $contentmodel = new ContentModelArticle();
         $return = $contentmodel->save($data);
         //print_r($contentmodel->getState('article.id'));
         if ($return === TRUE) {
             $res['data'] = $contentmodel->getState('article.id');
             echo json_encode($res);
         } else {
             $res['error'] = JText::_('MOD_QUICKPUBLISH_FAILETOCREATE');
             echo json_encode($res);
         }
         die;
     } else {
         $res['error'] = JText::_('MOD_QUICKPUBLISH_AJAX_TOKEN');
         echo json_encode($res);
         die;
     }
     die;
 }