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