Example #1
0
 /**
  * Display the toolbar
  */
 protected function _setToolbar()
 {
     $state = $this->get('State');
     $canDo = ContentHelper::getActions($state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('Content_Articles_Title'), 'article.png');
     if ($canDo->get('core.create')) {
         JToolBarHelper::custom('article.add', 'new.png', 'new_f2.png', 'New', false);
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::custom('article.edit', 'edit.png', 'edit_f2.png', 'Edit', true);
     }
     JToolBarHelper::divider();
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::custom('articles.publish', 'publish.png', 'publish_f2.png', 'Publish', true);
         JToolBarHelper::custom('articles.unpublish', 'unpublish.png', 'unpublish_f2.png', 'Unpublish', true);
         if ($state->get('filter.published') != -1) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('articles.archive');
         }
     }
     if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'articles.delete');
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('articles.trash');
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_content');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('screen.content.articles');
 }
Example #2
0
 /**
  * Display the toolbar
  */
 protected function _setToolbar()
 {
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('Content_Featured_Title'), 'featured.png');
     if ($canDo->get('core.create')) {
         JToolBarHelper::custom('article.add', 'new.png', 'new_f2.png', 'New', false);
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::custom('article.edit', 'edit.png', 'edit_f2.png', 'Edit', true);
     }
     JToolBarHelper::divider();
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::custom('articles.publish', 'publish.png', 'publish_f2.png', 'Publish', true);
         JToolBarHelper::custom('articles.unpublish', 'unpublish.png', 'unpublish_f2.png', 'Unpublish', true);
         JToolBarHelper::custom('featured.delete', 'remove.png', 'remove_f2.png', 'JToolbar_Remove', true);
         if ($this->state->get('filter.published') != -1) {
             JToolBarHelper::archiveList('articles.archive');
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_content');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('screen.content.featured');
 }
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     // Include the component HTML helpers.
     JSNFactory::import('components.com_content.helpers.content');
     JSNFactory::import('components.com_content.helpers.html.contentadministrator');
     $JSNMedia = JSNFactory::getMedia();
     $JSNMedia->addStyleSheet(JSN_POWERADMIN_STYLE_URI . 'content.css');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.content.js');
     if ($this->getLayout() == 'pagebreak') {
         // TODO: This is really dogy - should change this one day.
         $eName = JRequest::getVar('e_name');
         $eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName);
         $document = JFactory::getDocument();
         $document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
         $this->assignRef('eName', $eName);
         parent::display($tpl);
         return;
     }
     // Initialiase variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $language = JFactory::getLanguage();
     $language->load('com_content');
     parent::display($tpl);
 }
Example #4
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_CONTENT_FEATURED_TITLE'), 'featured.png');
     if ($canDo->get('core.create')) {
         JToolBarHelper::custom('article.add', 'new.png', 'new_f2.png', 'JTOOLBAR_NEW', false);
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::custom('article.edit', 'edit.png', 'edit_f2.png', 'JTOOLBAR_EDIT', true);
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::custom('articles.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::custom('articles.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         JToolBarHelper::divider();
         JToolBarHelper::archiveList('articles.archive', 'JTOOLBAR_ARCHIVE');
         JToolBarHelper::custom('articles.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
         JToolBarHelper::custom('featured.delete', 'remove.png', 'remove_f2.png', 'JTOOLBAR_REMOVE', true);
     }
     if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolBarHelper::divider();
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::divider();
             JToolBarHelper::trash('articles.trash', 'JTOOLBAR_TRASH');
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_content');
         JToolBarHelper::divider();
     }
     JToolBarHelper::help('JHELP_CONTENT_FEATURED_ARTICLES');
 }
Example #5
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     ContentHelper::addSubmenu('featured');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->authors = $this->get('Authors');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Levels filter.
     $options = array();
     $options[] = JHtml::_('select.option', '1', JText::_('J1'));
     $options[] = JHtml::_('select.option', '2', JText::_('J2'));
     $options[] = JHtml::_('select.option', '3', JText::_('J3'));
     $options[] = JHtml::_('select.option', '4', JText::_('J4'));
     $options[] = JHtml::_('select.option', '5', JText::_('J5'));
     $options[] = JHtml::_('select.option', '6', JText::_('J6'));
     $options[] = JHtml::_('select.option', '7', JText::_('J7'));
     $options[] = JHtml::_('select.option', '8', JText::_('J8'));
     $options[] = JHtml::_('select.option', '9', JText::_('J9'));
     $options[] = JHtml::_('select.option', '10', JText::_('J10'));
     $this->f_levels = $options;
     $this->addToolbar();
     $this->sidebar = JHtmlSidebar::render();
     parent::display($tpl);
 }
Example #6
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     Toolbar::title(Lang::txt('COM_CONTENT_FEATURED_TITLE'), 'featured.png');
     if ($canDo->get('core.create')) {
         Toolbar::addNew('article.add');
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('article.edit');
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
         Toolbar::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         Toolbar::divider();
         Toolbar::archiveList('articles.archive');
         Toolbar::checkin('articles.checkin');
         Toolbar::custom('featured.delete', 'remove.png', 'remove_f2.png', 'JTOOLBAR_REMOVE', true);
     }
     if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::trash('articles.trash');
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_content');
         Toolbar::divider();
     }
     Toolbar::help('featured');
 }
Example #7
0
 protected function doBuild(PageContext $ctxt, PageBuilderContext $builderCtxt, RequestArrayAdapter $requestParams, ArrayAdapter $buildParams)
 {
     //1. ЗАГОЛОВОК
     $builderCtxt->setTitle($this->basicPage->getTitle());
     //2. JAVASCRIPT
     $jsParams['postId'] = $ctxt->getPostId();
     $jsParams['rubricId'] = $ctxt->getRubricId();
     $jsParams['postType'] = $ctxt->getPostType();
     $jsParams['isPostsListPage'] = $ctxt->isPostsListPage();
     $jsParams['isRubricPage'] = $ctxt->isRubricPage();
     $jsParams['isPostPage'] = $ctxt->isPostPage();
     //Разборы, пройденные пользователем
     $passed = TrainManager::inst()->getUserPassedLessons();
     $jsParams['passedLessons'] = empty($passed) ? null : $passed;
     //Структура проекта
     $jsParams['structure'] = NavigationManager::inst()->getStructure();
     $builderCtxt->setJsParams($jsParams);
     //Параметры, зависимые от страницы
     $builderCtxt->setJsParams($this->basicPage->getJsParams());
     //3. SMARTY RESOURCES
     $builderCtxt->setSmartyParams4Resources($this->basicPage->getSmartyParams4Resources());
     //4. GET SMARTY PARAMS FOR TPL
     $smartyParams['host'] = ServerArrayAdapter::HTTP_HOST();
     $smartyParams['content'] = BasicPagesManager::inst()->getResourcesLinks($this->basicPage->getIdent(), ContentHelper::getContent($this->basicPage));
     return $smartyParams;
 }
Example #8
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     JToolbarHelper::title(JText::_('COM_CONTENT_FEATURED_TITLE'), 'featured.png');
     if ($canDo->get('core.create')) {
         JToolbarHelper::addNew('article.add');
     }
     if ($canDo->get('core.edit')) {
         JToolbarHelper::editList('article.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolbarHelper::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
         JToolbarHelper::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolbarHelper::custom('featured.delete', 'remove.png', 'remove_f2.png', 'JTOOLBAR_REMOVE', true);
         JToolbarHelper::archiveList('articles.archive');
         JToolbarHelper::checkin('articles.checkin');
     }
     if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolbarHelper::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
     } elseif ($canDo->get('core.edit.state')) {
         JToolbarHelper::trash('articles.trash');
     }
     if ($canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_content');
     }
     JToolbarHelper::help('JHELP_CONTENT_FEATURED_ARTICLES');
     JHtmlSidebar::setAction('index.php?option=com_content&view=featured');
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category_id', JHtml::_('select.options', JHtml::_('category.options', 'com_content'), 'value', 'text', $this->state->get('filter.category_id')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_MAX_LEVELS'), 'filter_level', JHtml::_('select.options', $this->f_levels, 'value', 'text', $this->state->get('filter.level')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_AUTHOR'), 'filter_author_id', JHtml::_('select.options', $this->authors, 'value', 'text', $this->state->get('filter.author_id')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_LANGUAGE'), 'filter_language', JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language')));
 }
Example #9
0
 protected function doBuild(\PageContext $ctxt, \PageBuilderContext $builderCtxt, \RequestArrayAdapter $requestParams, \ArrayAdapter $buildParams)
 {
     //1. ЗАГОЛОВОК
     $builderCtxt->setTitle($this->authed ? 'Админка | ' . $this->adminPage->title() : 'xxx');
     //2. JAVASCRIPT
     $builderCtxt->setJsParams($this->authed ? $this->adminPage->getJsParams() : null);
     //3. SMARTY RESOURCES
     if ($this->authed) {
         $builderCtxt->setSmartyParams4Resources($this->adminPage->getSmartyParams4Resources());
         $builderCtxt->setSmartyParam4Resources('IDENT', $this->adminPage->getPageIdent());
         $builderCtxt->setSmartyParam4Resources('TIMELINE_ENABE', true);
     }
     $smartyParams['authed'] = $this->authed;
     if (!$this->authed) {
         return $smartyParams;
     }
     //Запустим неограниченный по времени режим - мало ли, что мы там будем делать:)
     PsUtil::startUnlimitedMode();
     //Получаем содержимое админской страницы
     $content = ContentHelper::getContent($this->adminPage);
     //Добавляем к ней ресурсы
     $content = APagesResources::inst()->getResourcesLinks($this->adminPage->getPageIdent(), $content);
     $smartyParams['page'] = $this->adminPage;
     $smartyParams['content'] = $content;
     $smartyParams['pagesLayout'] = AdminPagesManager::getInstance()->getLayout();
     return $smartyParams;
 }
Example #10
0
 /**
  * Display the toolbar
  */
 protected function _setToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
     JToolBarHelper::title(JText::_('Content_Page_' . ($checkedOut ? 'View_Article' : ($isNew ? 'Add_Article' : 'Edit_Article'))), 'article-add.png');
     // If not checked out, can save the item.
     if (!$checkedOut && $canDo->get('core.edit')) {
         JToolBarHelper::apply('article.apply', 'JToolbar_Apply');
         JToolBarHelper::save('article.save', 'JToolbar_Save');
         JToolBarHelper::custom('article.save2new', 'save-new.png', 'save-new_f2.png', 'JToolbar_Save_and_new', false);
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         JToolBarHelper::custom('article.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JToolbar_Save_as_Copy', false);
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('article.cancel', 'JToolbar_Cancel');
     } else {
         JToolBarHelper::cancel('article.cancel', 'JToolbar_Close');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('screen.content.article');
 }
 /**
  * @param	int $articleid	The article item id
  */
 public static function association($articleid)
 {
     // Get the associations
     $associations = ContentHelper::getAssociations($articleid);
     foreach ($associations as $tag => $associated) {
         $associations[$tag] = (int) $associated->id;
     }
     // Get the associated menu items
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('c.*');
     $query->from('#__content as c');
     $query->select('cat.title as category_title');
     $query->leftJoin('#__categories as cat ON cat.id=c.catid');
     $query->where('c.id IN (' . implode(',', array_values($associations)) . ')');
     $query->leftJoin('#__languages as l ON c.language=l.lang_code');
     $query->select('l.image');
     $query->select('l.title as language_title');
     $db->setQuery($query);
     $items = $db->loadObjectList('id');
     // Check for a database error.
     if ($error = $db->getErrorMsg()) {
         JError::raiseWarning(500, $error);
         return false;
     }
     // Construct html
     $text = array();
     foreach ($associations as $tag => $associated) {
         if ($associated != $articleid) {
             $text[] = JText::sprintf('COM_CONTENT_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->category_title);
         }
     }
     return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_CONTENT_TIP_ASSOCIATION'), 'admin/icon-16-links.png');
 }
 protected function preparePartnerSlides()
 {
     $slides = array();
     $data = Yii::app()->db->createCommand(sprintf('SELECT  p.title, ph.filename, ph.title photo_title, ph.description photo_description
                                                         FROM partners p 
                                                         LEFT JOIN gallery g ON g.`gallery_id` = p.gallery_id
                                                         LEFT JOIN photo ph ON ph.gallery_id = g.gallery_id
                                                         WHERE p.is_active = 1 AND p.partner_id <> %d AND (ph.is_top <> 1 OR ph.is_top IS NULL)
                                                         ORDER BY ph.sort_order DESC', Yii::app()->params['partner_id']))->queryAll();
     foreach ($data as $slide) {
         $slides[] = array('url' => ImageHelper::imageUrl('', $slide['filename']), 'content' => sprintf('<img src=\'%s\' alt\'%s\' title=\'%s\'></img>', ImageHelper::imageUrl('partner_footer_frontend', $slide['filename']), ContentHelper::prepareStr($slide['title']), ContentHelper::prepareStr($slide['title'])));
     }
     return $slides;
 }
Example #13
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() !== 'modal') {
         ContentHelper::addSubmenu('articles');
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->authors = $this->get('Authors');
     $this->filterForm = $this->get('FilterForm');
     $this->activeFilters = $this->get('ActiveFilters');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Levels filter.
     $options = array();
     $options[] = JHtml::_('select.option', '1', JText::_('J1'));
     $options[] = JHtml::_('select.option', '2', JText::_('J2'));
     $options[] = JHtml::_('select.option', '3', JText::_('J3'));
     $options[] = JHtml::_('select.option', '4', JText::_('J4'));
     $options[] = JHtml::_('select.option', '5', JText::_('J5'));
     $options[] = JHtml::_('select.option', '6', JText::_('J6'));
     $options[] = JHtml::_('select.option', '7', JText::_('J7'));
     $options[] = JHtml::_('select.option', '8', JText::_('J8'));
     $options[] = JHtml::_('select.option', '9', JText::_('J9'));
     $options[] = JHtml::_('select.option', '10', JText::_('J10'));
     $this->f_levels = $options;
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
         $this->sidebar = JHtmlSidebar::render();
     } else {
         // In article associations modal we need to remove language filter if forcing a language.
         // We also need to change the category filter to show show categories with All or the forced language.
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD')) {
             // If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
             $languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
             $this->filterForm->setField($languageXml, 'filter', true);
             // Also, unset the active language filter so the search tools is not open by default with this filter.
             unset($this->activeFilters['language']);
             // One last changes needed is to change the category filter to just show categories with All language or with the forced language.
             $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
         }
     }
     parent::display($tpl);
 }
 protected function prepareSlides()
 {
     $slides = array();
     $data = Yii::app()->db->createCommand('SELECT gp.*, p.title post_title, ph.filename, ph.title photo_title, ph.description photo_description, u.firstname, u.lastname
                                                         FROM galleryposts gp
                                                         LEFT JOIN users u ON u.user_id = gp.user_id                                                            
                                                         LEFT JOIN posting p ON p.post_id = gp.post_id
                                                         LEFT JOIN gallery g ON g.`gallery_id` = p.gallery_id
                                                         LEFT JOIN photo ph ON ph.gallery_id = g.gallery_id
                                                         WHERE gp.is_top = 1 AND gp.publication_date <= NOW()
                                                         ORDER BY ph.sort_order DESC')->queryAll();
     foreach ($data as $slide) {
         $slides[] = array('url' => ImageHelper::imageUrl('main_page_slider', $slide['filename']), 'content' => sprintf('<a href=\'%s\'><img src=\'%s\' alt=\'%s\' title=\'%s\'></img></a>', Yii::app()->createAbsoluteUrl('portfolio/default/view', array('id' => $slide['post_id'])), ImageHelper::imageUrl('main_page_slider', $slide['filename']), ContentHelper::prepareStr($slide['photo_description']), ContentHelper::prepareStr($slide['photo_description'])));
     }
     return $slides;
 }
Example #15
0
 /**
  * Add the page title and toolbar.
  *
  * @since   1.6
  */
 protected function addToolbar()
 {
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     $user = JFactory::getUser();
     // Get the toolbar object instance
     $bar = JToolBar::getInstance('toolbar');
     JToolbarHelper::title(JText::_('COM_CONTENT_ARTICLES_TITLE'), 'article.png');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_content', 'core.create')) > 0) {
         JToolbarHelper::addNew('article.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolbarHelper::editList('article.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolbarHelper::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
         JToolbarHelper::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolbarHelper::custom('articles.featured', 'featured.png', 'featured_f2.png', 'JFEATURED', true);
         JToolbarHelper::archiveList('articles.archive');
         JToolbarHelper::checkin('articles.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolbarHelper::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
     } elseif ($canDo->get('core.edit.state')) {
         JToolbarHelper::trash('articles.trash');
     }
     // Add a batch button
     if ($user->authorise('core.create', 'com_content') && $user->authorise('core.edit', 'com_content') && $user->authorise('core.edit.state', 'com_content')) {
         JHtml::_('bootstrap.modal', 'collapseModal');
         $title = JText::_('JTOOLBAR_BATCH');
         // Instantiate a new JLayoutFile instance and render the batch button
         $layout = new JLayoutFile('joomla.toolbar.batch');
         $dhtml = $layout->render(array('title' => $title));
         $bar->appendButton('Custom', $dhtml, 'batch');
     }
     if ($canDo->get('core.admin')) {
         JToolbarHelper::preferences('com_content');
     }
     JToolbarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER');
     JHtmlSidebar::setAction('index.php?option=com_content&view=articles');
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category_id', JHtml::_('select.options', JHtml::_('category.options', 'com_content'), 'value', 'text', $this->state->get('filter.category_id')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_MAX_LEVELS'), 'filter_level', JHtml::_('select.options', $this->f_levels, 'value', 'text', $this->state->get('filter.level')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_AUTHOR'), 'filter_author_id', JHtml::_('select.options', $this->authors, 'value', 'text', $this->state->get('filter.author_id')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_LANGUAGE'), 'filter_language', JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_TAG'), 'filter_tag', JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag')));
 }
Example #16
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Load the submenu.
     ContentHelper::addSubmenu(JRequest::getCmd('view', 'articles'));
     $view = JRequest::getCmd('view', 'articles');
     $layout = JRequest::getCmd('layout', 'articles');
     $id = JRequest::getInt('id');
     // Check for edit form.
     if ($view == 'article' && $layout == 'edit' && !$this->checkEditId('com_content.edit.article', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_content&view=articles', false));
         return false;
     }
     parent::display();
     return $this;
 }
 /**
  * Method to get the associations for a given item
  *
  * @param   integer  $id    Id of the item
  * @param   string   $view  Name of the view
  *
  * @return  array   Array of associations for the item
  *
  * @since  3.0
  */
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = is_null($view) ? $jinput->get('view') : $view;
     $id = empty($id) ? $jinput->getInt('id') : $id;
     if ($view == 'article') {
         if ($id) {
             $associations = ContentHelper::getAssociations($id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     }
     if ($view == 'category' || $view == 'categories') {
         return self::getCategoryAssociations($id, 'com_content');
     }
     return array();
 }
Example #18
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
     JToolBarHelper::title(JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE'))), 'article-add.png');
     // Built the actions for new and existing records.
     // For new records, check the create permission.
     if ($isNew && count($user->getAuthorisedCategories('com_content', 'core.create')) > 0) {
         JToolBarHelper::apply('article.apply');
         JToolBarHelper::save('article.save');
         JToolBarHelper::save2new('article.save2new');
         JToolBarHelper::cancel('article.cancel');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolBarHelper::apply('article.apply');
                 JToolBarHelper::save('article.save');
                 // We can save this record, but check the create permission to see if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::save2new('article.save2new');
                 }
             }
         }
         // If checked out, we can still save
         if ($canDo->get('core.create')) {
             JToolBarHelper::save2copy('article.save2copy');
         }
         JToolBarHelper::cancel('article.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER_EDIT');
 }
Example #19
0
 /**
  * Display the view
  */
 function display()
 {
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'content.php';
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = JRequest::getWord('view', 'articles');
     $vFormat = $document->getType();
     $lName = JRequest::getWord('layout', 'default');
     // Get and render the view.
     if ($view =& $this->getView($vName, $vFormat)) {
         // Get the model for the view.
         $model =& $this->getModel($vName);
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         $view->display();
         // Load the submenu.
         ContentHelper::addSubmenu($vName);
     }
 }
Example #20
0
<ul class="album-list article-album">
<?php 
foreach ($data as $blogs) {
    ?>
    <?php 
    $arr = explode(' ', $blogs['publication_date']);
    $timestamp = CDateTimeParser::parse($blogs['publication_date'], 'yyyy-MM-dd hh:mm:ss');
    $date = Yii::app()->dateFormatter->format('d MMMM y', $timestamp);
    $title = ContentHelper::cutStringEx($blogs['p_title'], 100);
    $imgUrl = ImageHelper::imageUrl('blogs_slider', $blogs['filename']);
    ?>
    <li title="<?php 
    echo $title;
    ?>
">
        <a href="<?php 
    echo Yii::app()->createAbsoluteUrl('blogs/default/view', array('id' => $blogs['id']));
    ?>
">
            <img style="width: 335px; height: 228px;" src="<?php 
    echo $imgUrl;
    ?>
" alt="<?php 
    echo $title;
    ?>
" title="<?php 
    echo $title;
    ?>
">
            <span>
                <span class="album-title"><?php 
Example #21
0
            <div class="rubric">
                 <?php 
    echo $data['content'];
    ?>
            </div>
            
            <?php 
    if ($data['is_active']) {
        ?>
            
                <ul class="photo-list">
                <?php 
        foreach ($photos as $photo) {
            ?>
                    <?php 
            $description = ContentHelper::cutStringEx($photo['description'], 100);
            $imgThumbUrl = ImageHelper::imageUrl('portfolio_index_frontend', $photo['filename']);
            $imgRawUrl = ImageHelper::imageUrl('raw', $photo['filename']);
            ?>
                    <li>
                        <a class="fancybox-button" rel="fancybox-button" href="<?php 
            echo $imgRawUrl;
            ?>
" title="<?php 
            echo $description;
            ?>
">
                            <img src="<?php 
            echo $imgThumbUrl;
            ?>
" alt="<?php 
Example #22
0
 /**
  * Apply Joomla text filters based on the user's groups
  *
  * @param  string $string The string to clean
  *
  * @return string         The cleaned string
  */
 public function applyTextFilters($string)
 {
     // Apply the textfilters (let's reuse Joomla's ContentHelper class)
     if (!class_exists('ContentHelper')) {
         require_once JPATH_SITE . '/administrator/components/com_content/helpers/content.php';
     }
     return ContentHelper::filterText((string) $string);
 }
Example #23
0
 function _getLists()
 {
     global $mainframe;
     // Initialize variables
     $db =& JFactory::getDBO();
     // Get some variables from the request
     $sectionid = JRequest::getVar('sectionid', -1, '', 'int');
     $redirect = $sectionid;
     $option = JRequest::getCmd('option');
     $filter_order = $mainframe->getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $filter_state = $mainframe->getUserStateFromRequest('articleelement.filter_state', 'filter_state', '', 'word');
     $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int');
     $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int');
     $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int');
     $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
     $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int');
     $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string');
     $search = JString::strtolower($search);
     // get list of categories for dropdown filter
     $filter = $filter_sectionid >= 0 ? ' WHERE cc.section = ' . $db->Quote($filter_sectionid) : '';
     // get list of categories for dropdown filter
     $query = 'SELECT cc.id AS value, cc.title AS text, section' . ' FROM #__categories AS cc' . ' INNER JOIN #__sections AS s ON s.id = cc.section' . $filter . ' ORDER BY s.ordering, cc.ordering';
     $lists['catid'] = ContentHelper::filterCategory($query, $catid);
     // get list of sections for dropdown filter
     $javascript = 'onchange="document.adminForm.submit();"';
     $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript);
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // search filter
     $lists['search'] = $search;
     return $lists;
 }
Example #24
0
<?php

/**
 * The main logic of the module.
 *
 * @version	   $Id:  $
 * @copyright  Copyright (C) 2011 Migur Ltd. All rights reserved.
 * @license	   GNU General Public License version 2 or later; see LICENSE.txt
 */
JLoader::import('helpers.content', JPATH_COMPONENT_ADMINISTRATOR, '');
// Each link in content at the end should has ABSOLUTE url
// If link or src has relative path (not started with 'http')
// then we complement it with current base url
echo ContentHelper::pathsToAbsolute($params->get('text'));
Example #25
0
 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->attribs);
         $item->attribs = $registry->toArray();
         // Convert the metadata field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->images);
         $item->images = $registry->toArray();
         // Convert the urls field to an array.
         $registry = new JRegistry();
         $registry->loadString($item->urls);
         $item->urls = $registry->toArray();
         $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
     }
     // Load associated content items
     $app = JFactory::getApplication();
     $assoc = isset($app->item_associations) ? $app->item_associations : 0;
     if ($assoc) {
         $item->associations = array();
         if ($item->id != null) {
             $associations = ContentHelper::getAssociations($item->id);
             foreach ($associations as $tag => $association) {
                 $item->associations[$tag] = $association->id;
             }
         }
     }
     return $item;
 }
 /**
  * Saves the article an edit form submit
  * @param database A database connector object
  */
 function saveContent()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Initialize variables
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $option = JRequest::getCmd('option');
     $task = JRequest::getCmd('task');
     $sectionid = JRequest::getVar('sectionid', 0, '', 'int');
     $redirect = JRequest::getVar('redirect', $sectionid, 'post', 'int');
     $menu = JRequest::getVar('menu', 'mainmenu', 'post', 'menutype');
     $menuid = JRequest::getVar('menuid', 0, 'post', 'int');
     $nullDate = $db->getNullDate();
     $row =& JTable::getInstance('content');
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     $row->bind($details);
     // sanitise id field
     $row->id = (int) $row->id;
     $isNew = true;
     // Are we saving from an item edit?
     if ($row->id) {
         $isNew = false;
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     // Append time if not added to publish date
     if (strlen(trim($row->publish_up)) <= 10) {
         $row->publish_up .= ' 00:00:00';
     }
     $date =& JFactory::getDate($row->publish_up, $tzoffset);
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Get a state and parameter variables from the request
     $row->state = JRequest::getVar('state', 0, '', 'int');
     $params = JRequest::getVar('params', null, 'post', 'array');
     // Build parameter INI string
     if (is_array($params)) {
         $txt = array();
         foreach ($params as $k => $v) {
             $txt[] = "{$k}={$v}";
         }
         $row->attribs = implode("\n", $txt);
     }
     // Get metadata string
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
                 $txt[] = "{$k}={$v}";
             }
         }
         $row->metadata = implode("\n", $txt);
     }
     // Prepare the content for saving to the database
     ContentHelper::saveContentPrep($row);
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     // Increment the content version number
     $row->version++;
     $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew));
     if (in_array(false, $result, true)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     // Store the content to the database
     if (!$row->store()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     // Check the article and update item order
     $row->checkin();
     $row->reorder('catid = ' . (int) $row->catid . ' AND state >= 0');
     /*
      * We need to update frontpage status for the article.
      *
      * First we include the frontpage table and instantiate an instance of it.
      */
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS . 'tables' . DS . 'frontpage.php';
     $fp = new TableFrontPage($db);
     // Is the article viewable on the frontpage?
     if (JRequest::getVar('frontpage', 0, '', 'int')) {
         // Is the item already viewable on the frontpage?
         if (!$fp->load($row->id)) {
             // Insert the new entry
             $query = 'INSERT INTO #__content_frontpage' . ' VALUES ( ' . (int) $row->id . ', 1 )';
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseError(500, $db->stderr());
                 return false;
             }
             $fp->ordering = 1;
         }
     } else {
         // Delete the item from frontpage if it exists
         if (!$fp->delete($row->id)) {
             $msg .= $fp->stderr();
         }
         $fp->ordering = 0;
     }
     $fp->reorder();
     $cache =& JFactory::getCache('com_content');
     $cache->clean();
     $dispatcher->trigger('onAfterContentSave', array(&$row, $isNew));
     switch ($task) {
         case 'go2menu':
             $mainframe->redirect('index.php?option=com_menus&menutype=' . $menu);
             break;
         case 'go2menuitem':
             $mainframe->redirect('index.php?option=com_menus&menutype=' . $menu . '&task=edit&id=' . $menuid);
             break;
         case 'menulink':
             ContentHelper::menuLink($redirect, $row->id);
             break;
         case 'resethits':
             ContentHelper::resetHits($redirect, $row->id);
             break;
         case 'apply':
             $msg = JText::sprintf('SUCCESSFULLY SAVED CHANGES TO ARTICLE', $row->title);
             $mainframe->redirect('index.php?option=com_content&sectionid=' . $redirect . '&task=edit&cid[]=' . $row->id, $msg);
             break;
         case 'save':
         default:
             $msg = JText::sprintf('Successfully Saved Article', $row->title);
             $mainframe->redirect('index.php?option=com_content&sectionid=' . $redirect, $msg);
             break;
     }
 }
Example #27
0
 /**
  * Almacena la noticia enviada por el usuario a traves de una instancia
  * del módulo mod_soycorresponsal.
  */
 function saveCorresponsalContent()
 {
     $mainframe = JFactory::getApplication();
     jimport('json.json');
     $helper = new comZonalesHelper();
     $response = array();
     // chequea irregularidades en el request
     JRequest::checkToken() or jexit('Invalid Token');
     // titulo del modulo que envio el request
     $moduleTitle = JRequest::getVar('module', NULL, 'post', 'string');
     // chequea que el modulo especificado en el request sea valido
     if (!$moduleTitle) {
         jexit($helper->getJsonResponse('failure', 'Error interno', 'No module name'));
     } else {
         jimport('joomla.application.module.helper');
         $module = JModuleHelper::getModule('soycorresponsal', $moduleTitle);
         if ($module->id == 0) {
             jexit($helper->getJsonResponse('failure', 'Error interno', 'Invalid module'));
         }
     }
     // recupera parametros del módulo
     $modparams = new JParameter($module->params);
     // librería recaptcha
     jimport('recaptcha.recaptchalib');
     // parametros del componente
     $zonalesParams =& JComponentHelper::getParams('com_zonales');
     $privatekey = $zonalesParams->get('recaptcha_privatekey', null);
     if (!$privatekey) {
         jexit($helper->getJsonResponse('failure', $modparams->get('error'), 'No recaptcha private key'));
     } else {
         // validamos la respuesta del usuario
         $challenge = JRequest::getVar('recaptcha_challenge_field', NULL, 'post', 'string');
         $response = JRequest::getVar('recaptcha_response_field', NULL, 'post', 'string');
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $challenge, $response);
         if (!$resp->is_valid) {
             jexit($helper->getJsonResponse('captcha-failure', $modparams->get('error'), 'Invalid response'));
         } else {
             // inicializa variables a utilizar
             $db =& JFactory::getDBO();
             $user =& JFactory::getUser();
             if ($user->guest) {
                 $user =& JFactory::getUser($modparams->get('user'));
             }
             //$catid = $modparams->get('category', 0);
             $nullDate = $db->getNullDate();
             // tabla de contenidos joomla
             $row =& JTable::getInstance('content');
             /* if ($catid > 0) {
                $category =& JTable::getInstance('category');
                $category->load($catid);
                $sectionid = $category->section;
                } */
             $nullDate = $db->getNullDate();
             $row->title = JRequest::getVar('title', NULL, 'post', 'string');
             $row->sectionid = 0;
             $row->catid = 0;
             $row->version = 0;
             $row->state = 1;
             $row->ordering = 0;
             $row->images = array();
             $row->publish_down = $nullDate;
             $row->created_by = $user->get('id');
             $row->modified = gmdate('Y-m-d H:i:s');
             // corrección de la fecha
             $config =& JFactory::getConfig();
             $row->created = gmdate('Y-m-d H:i:s');
             $row->publish_up = gmdate('Y-m-d 00:00:00');
             // se redondea timestamp de creación
             if ($row->created && strlen(trim($row->created)) <= 10) {
                 $row->created .= ' 00:00:00';
             }
             // Prepare the content for saving to the database
             require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'helper.php';
             ContentHelper::saveContentPrep($row);
             // Se agregan nombre de usuario, correo y telefono
             $enviaNombre = JRequest::getVar('nombre', NULL, 'post', 'string');
             $enviaEmail = JRequest::getVar('email', NULL, 'post', 'string');
             $enviaTel = JRequest::getVar('telefono', NULL, 'post', 'string');
             $row->introtext = $row->introtext . "<p>Envio esta noticia:</p><p>Nombre: {$enviaNombre}<br/>Email: {$enviaEmail}<br/>";
             /**
              * Para videos de YouTube, arreglo la url para que se pueda ver
              */
             $searchString = "watch?v=";
             $imgPos = 0;
             while ($imgPos = strpos($row->introtext, $searchString, $imgPos)) {
                 $strPre = substr($row->introtext, 0, $imgPos);
                 $strPos = substr($row->introtext, $imgPos + strlen($searchString));
                 $row->introtext = $strPre . 'v/' . $strPos;
             }
             // Make sure the data is valid
             if (!$row->check()) {
                 JError::raiseError(500, $db->stderr());
             }
             // Store the content to the database
             if (!$row->store()) {
                 JError::raiseError(500, $db->stderr());
             }
             // Check the article and update item order
             $row->checkin();
             $row->reorder('catid = ' . (int) $row->catid . ' AND state >= 0');
             // Asignamos los tags de Custom Properties según los valores de zonal y localidad
             $partidoId = JRequest::getVar('provincias_sc', NULL, 'post', 'int');
             $zonaId = JRequest::getVar('localidad', NULL, 'post', 'int');
             $query = "REPLACE INTO #__custom_properties (ref_table, content_id,field_id,value_id)\n\t\t\t\t\tSELECT 'content','{$row->id}',v.field_id AS field, v.id AS value\n\t\t\t\t\tFROM #__custom_properties_values v\n                                        WHERE v.parent_id = {$partidoId}\n\t\t\t\t\tAND v.id = {$zonaId}\n                                        OR v.name = 'la_voz_del_vecino'";
             $database = JFactory::getDBO();
             $database->setQuery($query);
             $database->query();
             // Process the content preparation plugins
             JPluginHelper::importPlugin('content');
             $dispatcher =& JDispatcher::getInstance();
             $dispatcher->trigger('onAfterContentSave', array(&$row, $row->id < 1));
             // Todo ok, enviamos confirmación
             echo $helper->getJsonResponse('success', $modparams->get('confirmacion'));
             return;
         }
     }
 }
Example #28
0
 function saveArticle()
 {
     // Initialize variables
     $db =& FabrikWorker::getDbo();
     $user =& JFactory::getUser();
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $this->_postFabrikDataAsArticleData();
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $option = JRequest::getCmd('option');
     $sectionid = JRequest::getVar('sectionid', 0, '', 'int');
     $nullDate = $db->getNullDate();
     $row =& FabTable::getInstance('content');
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     $row->bind($details);
     // sanitise id field
     $row->id = (int) $row->id;
     $this->_isNew = true;
     // Are we saving from an item edit?
     if ($row->id) {
         $this->_isNew = false;
         $datenow = JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     // Append time if not added to publish date
     if (strlen(trim($row->publish_up)) <= 10) {
         $row->publish_up .= ' 00:00:00';
     }
     $date =& JFactory::getDate($row->publish_up, $tzoffset);
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Get a state and parameter variables from the request
     // should probably punt this logic into the controller, but for now ...
     $articlePublishElementName = $this->_elementBaseName($this->_articlePublishElement);
     $row->state = $this->_formModel->_formData[$articlePublishElementName];
     // probably an array, i.e. coming from a yes/no radio or dropdown
     if (is_array($row->state)) {
         $row->state = $row->state[0];
     }
     $params = JRequest::getVar('params', null, 'post', 'array');
     $row->params = json_encode($params);
     // Get metadata string
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
                 $txt[] = "{$k}={$v}";
             }
         }
         $row->metadata = implode("\n", $txt);
     }
     // Prepare the content for saving to the database
     ContentHelper::saveContentPrep($row);
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     // Increment the content version number
     $row->version++;
     $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $this->_isNew));
     if (in_array(false, $result, true)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     // Store the content to the database
     if (!$row->store()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     $this->_articleId = $row->id;
     // Check the article and update item order
     $row->checkin();
     $row->reorder('catid = ' . (int) $row->catid . ' AND state >= 0');
     //		*
     //		 * We need to update frontpage status for the article.
     //		 *
     //		 * First we include the frontpage table and instantiate an instance of it.
     //		 *
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS . 'tables' . DS . 'frontpage.php';
     $fp = new TableFrontPage($db);
     // Is the article viewable on the frontpage?
     if (JRequest::getVar('frontpage', 0, '', 'int')) {
         // Is the item already viewable on the frontpage?
         if (!$fp->load($row->id)) {
             // Insert the new entry
             $query = 'INSERT INTO #__content_frontpage' . ' VALUES ( ' . (int) $row->id . ', 1 )';
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseError(500, $db->stderr());
                 return false;
             }
             $fp->ordering = 1;
         }
     } else {
         // Delete the item from frontpage if it exists
         if (!$fp->delete($row->id)) {
             $msg .= $fp->stderr();
         }
         $fp->ordering = 0;
     }
     $fp->reorder();
     $cache =& JFactory::getCache('com_content');
     $cache->clean();
     $dispatcher->trigger('onAfterContentSave', array(&$row, $this->_isNew));
 }
Example #29
0
 function cleanText($text)
 {
     if (version_compare(JVERSION, '2.5.0', 'ge')) {
         $text = JComponentHelper::filterText($text);
     } else {
         if (version_compare(JVERSION, '2.5.0', 'lt') && version_compare(JVERSION, '1.6.0', 'ge')) {
             JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'content.php');
             $text = ContentHelper::filterText($text);
         } else {
             $config = JComponentHelper::getParams('com_content');
             $user = JFactory::getUser();
             $gid = $user->get('gid');
             $filterGroups = $config->get('filter_groups');
             // convert to array if one group selected
             if (!is_array($filterGroups) && (int) $filterGroups > 0) {
                 $filterGroups = array($filterGroups);
             }
             if (is_array($filterGroups) && in_array($gid, $filterGroups)) {
                 $filterType = $config->get('filter_type');
                 $filterTags = preg_split('#[,\\s]+#', trim($config->get('filter_tags')));
                 $filterAttrs = preg_split('#[,\\s]+#', trim($config->get('filter_attritbutes')));
                 switch ($filterType) {
                     case 'NH':
                         $filter = new JFilterInput();
                         break;
                     case 'WL':
                         $filter = new JFilterInput($filterTags, $filterAttrs, 0, 0, 0);
                         break;
                     case 'BL':
                     default:
                         $filter = new JFilterInput($filterTags, $filterAttrs, 1, 1);
                         break;
                 }
                 $text = $filter->clean($text);
             } elseif (empty($filterGroups) && $gid != '25') {
                 // no default filtering for super admin (gid=25)
                 $filter = new JFilterInput(array(), array(), 1, 1);
                 $text = $filter->clean($text);
             }
         }
     }
     return $text;
 }
Example #30
-3
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     $user = JFactory::getUser();
     JToolBarHelper::title(JText::_('COM_CONTENT_ARTICLES_TITLE'), 'article.png');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_content', 'core.create')) > 0) {
         JToolBarHelper::addNew('article.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('article.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolBarHelper::custom('articles.featured', 'featured.png', 'featured_f2.png', 'JFEATURED', true);
         JToolBarHelper::divider();
         JToolBarHelper::archiveList('articles.archive');
         JToolBarHelper::checkin('articles.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolBarHelper::divider();
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('articles.trash');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_content');
         JToolBarHelper::divider();
     }
     JToolBarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER');
 }