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
 /**
  *
  */
 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;
 }