first commit
This commit is contained in:
20
administrator/components/com_newsfeeds/access.xml
Normal file
20
administrator/components/com_newsfeeds/access.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<access component="com_newsfeeds">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" />
|
||||
<action name="core.options" title="JACTION_OPTIONS" />
|
||||
<action name="core.manage" title="JACTION_MANAGE" />
|
||||
<action name="core.create" title="JACTION_CREATE" />
|
||||
<action name="core.delete" title="JACTION_DELETE" />
|
||||
<action name="core.edit" title="JACTION_EDIT" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||
<action name="core.edit.own" title="JACTION_EDITOWN" />
|
||||
</section>
|
||||
<section name="category">
|
||||
<action name="core.create" title="JACTION_CREATE" />
|
||||
<action name="core.delete" title="JACTION_DELETE" />
|
||||
<action name="core.edit" title="JACTION_EDIT" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||
<action name="core.edit.own" title="JACTION_EDITOWN" />
|
||||
</section>
|
||||
</access>
|
||||
430
administrator/components/com_newsfeeds/config.xml
Normal file
430
administrator/components/com_newsfeeds/config.xml
Normal file
@ -0,0 +1,430 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<help key="News_Feed:_Options"/>
|
||||
<inlinehelp button="show"/>
|
||||
<fieldset
|
||||
name="newsfeed"
|
||||
label="COM_NEWSFEEDS_FIELD_CONFIG_NEWSFEED_SETTINGS_LABEL"
|
||||
description="COM_NEWSFEEDS_FIELD_CONFIG_NEWSFEED_SETTINGS_DESC"
|
||||
>
|
||||
|
||||
<field
|
||||
name="newsfeed_layout"
|
||||
type="componentlayout"
|
||||
label="JGLOBAL_FIELD_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
menuitems="true"
|
||||
extension="com_newsfeeds"
|
||||
view="newsfeed"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="save_history"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="history_limit"
|
||||
type="number"
|
||||
label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"
|
||||
default="5"
|
||||
filter="integer"
|
||||
showon="save_history:1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="show_feed_image"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_feed_description"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_item_description"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="feed_character_count"
|
||||
type="number"
|
||||
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
|
||||
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
|
||||
filter="integer"
|
||||
default="0"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="feed_display_order"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="des">JGLOBAL_MOST_RECENT_FIRST</option>
|
||||
<option value="asc">JGLOBAL_OLDEST_FIRST</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="float_first"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FLOAT_FIRST_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="right">COM_NEWSFEEDS_RIGHT</option>
|
||||
<option value="left">COM_NEWSFEEDS_LEFT</option>
|
||||
<option value="none">COM_NEWSFEEDS_NONE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="float_second"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FLOAT_SECOND_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="right">COM_NEWSFEEDS_RIGHT</option>
|
||||
<option value="left">COM_NEWSFEEDS_LEFT</option>
|
||||
<option value="none">COM_NEWSFEEDS_NONE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_tags"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_TAGS_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="category"
|
||||
label="JCATEGORY"
|
||||
description="COM_NEWSFEEDS_FIELD_CONFIG_CATEGORY_SETTINGS_DESC"
|
||||
>
|
||||
|
||||
<field
|
||||
name="category_layout"
|
||||
type="componentlayout"
|
||||
label="JGLOBAL_FIELD_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
menuitems="true"
|
||||
extension="com_newsfeeds"
|
||||
view="category"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="show_category_title"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_CATEGORY_TITLE"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_description"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_description_image"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="maxLevel"
|
||||
type="list"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
default="-1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNONE</option>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_empty_categories"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
default="0"
|
||||
showon="maxLevel:-1,1,2,3,4,5"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_subcat_desc"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
default="1"
|
||||
showon="maxLevel:-1,1,2,3,4,5"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_cat_items"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_cat_tags"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_TAGS_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="categories"
|
||||
label="JCATEGORIES"
|
||||
description="COM_NEWSFEEDS_CATEGORIES_DESC"
|
||||
>
|
||||
|
||||
<field
|
||||
name="show_base_description"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="maxLevelcat"
|
||||
type="list"
|
||||
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
|
||||
default="-1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
<option value="0">JNONE</option>
|
||||
<option value="1">J1</option>
|
||||
<option value="2">J2</option>
|
||||
<option value="3">J3</option>
|
||||
<option value="4">J4</option>
|
||||
<option value="5">J5</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_empty_categories_cat"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
|
||||
default="0"
|
||||
showon="maxLevelcat:-1,1,2,3,4,5"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_subcat_desc_cat"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
|
||||
default="1"
|
||||
showon="maxLevelcat:-1,1,2,3,4,5"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_cat_items_cat"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="listlayout"
|
||||
label="JGLOBAL_LIST_LAYOUT_OPTIONS"
|
||||
description="COM_NEWSFEEDS_FIELD_CONFIG_LIST_SETTINGS_DESC"
|
||||
>
|
||||
|
||||
<field
|
||||
name="filter_field"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_FILTER_FIELD_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_limit"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_headings"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_SHOW_HEADINGS_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_articles"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_link"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_LINKS_LABEL"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination"
|
||||
type="list"
|
||||
label="JGLOBAL_PAGINATION_LABEL"
|
||||
default="2"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_pagination_results"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
default="1"
|
||||
showon="show_pagination:1,2"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="integration"
|
||||
label="JGLOBAL_INTEGRATION_LABEL"
|
||||
description="COM_NEWSFEEDS_CONFIG_INTEGRATION_SETTINGS_DESC"
|
||||
>
|
||||
<fieldset
|
||||
name="integration_sef"
|
||||
label="JGLOBAL_SEF_TITLE"
|
||||
>
|
||||
<field
|
||||
name="sef_ids"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
label="JGLOBAL_SEF_NOIDS_LABEL"
|
||||
filter="integer">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="permissions"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
component="com_newsfeeds"
|
||||
section="component"
|
||||
/>
|
||||
</fieldset>
|
||||
</config>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<help key="News_Feeds:_Edit_Category" />
|
||||
<listhelp key="News_Feeds:_Categories" />
|
||||
</form>
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Newsfeeds\Administrator\Field">
|
||||
|
||||
<fields name="filter">
|
||||
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_NEWSFEEDS_FILTER_SEARCH_LABEL"
|
||||
description="COM_NEWSFEEDS_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="status"
|
||||
label="JSTATUS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="category_id"
|
||||
type="category"
|
||||
label="JCATEGORY"
|
||||
extension="com_newsfeeds"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_CATEGORY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JGRID_HEADING_ACCESS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_ACCESS</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JGRID_HEADING_LANGUAGE"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_LANGUAGE</option>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tag"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
hint="JOPTION_SELECT_TAG"
|
||||
multiple="true"
|
||||
mode="nested"
|
||||
custom="false"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="level"
|
||||
type="integer"
|
||||
label="JGLOBAL_MAXLEVEL_LABEL"
|
||||
first="1"
|
||||
last="10"
|
||||
step="1"
|
||||
languages="*"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_MAX_LEVELS</option>
|
||||
</field>
|
||||
</fields>
|
||||
|
||||
<fields name="list">
|
||||
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
class="js-select-submit-on-change"
|
||||
default="a.name ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
|
||||
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
|
||||
<option value="a.published ASC">JSTATUS_ASC</option>
|
||||
<option value="a.published DESC">JSTATUS_DESC</option>
|
||||
<option value="a.name ASC">JGLOBAL_TITLE_ASC</option>
|
||||
<option value="a.name DESC">JGLOBAL_TITLE_DESC</option>
|
||||
<option value="category_title ASC">JCATEGORY_ASC</option>
|
||||
<option value="category_title DESC">JCATEGORY_DESC</option>
|
||||
<option value="access_level ASC">JGRID_HEADING_ACCESS_ASC</option>
|
||||
<option value="access_level DESC">JGRID_HEADING_ACCESS_DESC</option>
|
||||
<option value="numarticles ASC">COM_NEWSFEEDS_NUM_ARTICLES_HEADING_ASC</option>
|
||||
<option value="numarticles DESC">COM_NEWSFEEDS_NUM_ARTICLES_HEADING_DESC</option>
|
||||
<option value="a.cache_time ASC">COM_NEWSFEEDS_CACHE_TIME_HEADING_ASC</option>
|
||||
<option value="a.cache_time DESC">COM_NEWSFEEDS_CACHE_TIME_HEADING_DESC</option>
|
||||
<option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option>
|
||||
<option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option>
|
||||
<option value="language_title ASC" requires="multilanguage">JGRID_HEADING_LANGUAGE_ASC</option>
|
||||
<option value="language_title DESC" requires="multilanguage">JGRID_HEADING_LANGUAGE_DESC</option>
|
||||
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="25"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
449
administrator/components/com_newsfeeds/forms/newsfeed.xml
Normal file
449
administrator/components/com_newsfeeds/forms/newsfeed.xml
Normal file
@ -0,0 +1,449 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Newsfeeds\Administrator\Field">
|
||||
|
||||
<fieldset>
|
||||
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="JGLOBAL_TITLE"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="alias"
|
||||
type="text"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
hint="JFIELD_ALIAS_PLACEHOLDER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
default="1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="2">JARCHIVED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="catid"
|
||||
type="categoryedit"
|
||||
label="JCATEGORY"
|
||||
extension="com_newsfeeds"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
required="true"
|
||||
default=""
|
||||
/>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tags"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
multiple="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="version_note"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
|
||||
maxlength="255"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="description"
|
||||
type="editor"
|
||||
label="JGLOBAL_DESCRIPTION"
|
||||
buttons="true"
|
||||
hide="pagebreak,readmore"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="link"
|
||||
type="url"
|
||||
label="COM_NEWSFEEDS_FIELD_LINK_LABEL"
|
||||
required="true"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="numarticles"
|
||||
type="number"
|
||||
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_LABEL"
|
||||
filter="integer"
|
||||
default="5"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cache_time"
|
||||
type="number"
|
||||
label="COM_NEWSFEEDS_FIELD_CACHETIME_LABEL"
|
||||
filter="integer"
|
||||
default="3600"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="ordering"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
content_type="com_newsfeeds.newsfeed"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_CREATED_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by_alias"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_CREATED_BY_ALIAS_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="modified"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL"
|
||||
class="readonly"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
readonly="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="modified_by"
|
||||
type="user"
|
||||
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
label="COM_NEWSFEEDS_FIELD_VERSION_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="checked_out"
|
||||
type="Text"
|
||||
label="JGLOBAL_FIELD_CHECKEDOUT_LABEL"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="checked_out_time"
|
||||
type="Text"
|
||||
label="JGLOBAL_FIELD_CHECKEDOUT_TIME_LABEL"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_up"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_down"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="hits"
|
||||
type="text"
|
||||
label="JGLOBAL_HITS"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
filter="UINT"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metakey"
|
||||
type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metadesc"
|
||||
type="textarea"
|
||||
label="JFIELD_META_DESCRIPTION_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
maxlength="300"
|
||||
charcounter="true"
|
||||
/>
|
||||
|
||||
<fields name="images">
|
||||
|
||||
<fieldset name="images" label="JGLOBAL_FIELDSET_IMAGE_OPTIONS">
|
||||
|
||||
<field
|
||||
name="image_first"
|
||||
type="media"
|
||||
label="COM_NEWSFEEDS_FIELD_FIRST_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="float_first"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FLOAT_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="right">COM_NEWSFEEDS_RIGHT</option>
|
||||
<option value="left">COM_NEWSFEEDS_LEFT</option>
|
||||
<option value="none">COM_NEWSFEEDS_NONE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_first_alt"
|
||||
type="text"
|
||||
label="COM_NEWSFEEDS_FIELD_IMAGE_ALT_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_first_alt_empty"
|
||||
type="checkbox"
|
||||
label="COM_NEWSFEEDS_FIELD_IMAGE_ALT_EMPTY_LABEL"
|
||||
description="COM_NEWSFEEDS_FIELD_IMAGE_ALT_EMPTY_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_first_caption"
|
||||
type="text"
|
||||
label="COM_NEWSFEEDS_FIELD_IMAGE_CAPTION_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="spacer1"
|
||||
type="spacer"
|
||||
hr="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_second"
|
||||
type="media"
|
||||
label="COM_NEWSFEEDS_FIELD_SECOND_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="float_second"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FLOAT_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="right">COM_NEWSFEEDS_RIGHT</option>
|
||||
<option value="left">COM_NEWSFEEDS_LEFT</option>
|
||||
<option value="none">COM_NEWSFEEDS_NONE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_second_alt"
|
||||
type="text"
|
||||
label="COM_NEWSFEEDS_FIELD_IMAGE_ALT_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_second_alt_empty"
|
||||
type="checkbox"
|
||||
label="COM_NEWSFEEDS_FIELD_IMAGE_ALT_EMPTY_LABEL"
|
||||
description="COM_NEWSFEEDS_FIELD_IMAGE_ALT_EMPTY_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="image_second_caption"
|
||||
type="text"
|
||||
label="COM_NEWSFEEDS_FIELD_IMAGE_CAPTION_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="jbasic" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
|
||||
|
||||
<field
|
||||
name="numarticles"
|
||||
type="number"
|
||||
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_LABEL"
|
||||
filter="integer"
|
||||
default="5"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cache_time"
|
||||
type="number"
|
||||
label="COM_NEWSFEEDS_FIELD_CACHETIME_LABEL"
|
||||
filter="integer"
|
||||
default="3600"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="rtl"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FIELD_RTL_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">COM_NEWSFEEDS_FIELD_VALUE_SITE</option>
|
||||
<option value="1">COM_NEWSFEEDS_FIELD_VALUE_LTR</option>
|
||||
<option value="2">COM_NEWSFEEDS_FIELD_VALUE_RTL</option>
|
||||
</field>
|
||||
|
||||
<fields name="params" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
|
||||
|
||||
<field
|
||||
name="show_feed_image"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_feed_description"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_item_description"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="feed_character_count"
|
||||
type="number"
|
||||
label="COM_NEWSFEEDS_FIELD_CHARACTERS_COUNT_LABEL"
|
||||
description="COM_NEWSFEEDS_FIELD_CHARACTERS_COUNT_DESC"
|
||||
filter="integer"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="newsfeed_layout"
|
||||
type="componentlayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
extension="com_newsfeeds"
|
||||
view="newsfeed"
|
||||
useglobal="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="feed_display_order"
|
||||
type="list"
|
||||
label="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="des">JGLOBAL_MOST_RECENT_FIRST</option>
|
||||
<option value="asc">JGLOBAL_OLDEST_FIRST</option>
|
||||
</field>
|
||||
</fields>
|
||||
</fieldset>
|
||||
|
||||
<fields name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
|
||||
<fieldset name="jmetadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
|
||||
<field
|
||||
name="robots"
|
||||
type="list"
|
||||
label="JFIELD_METADATA_ROBOTS_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="index, follow"></option>
|
||||
<option value="noindex, follow"></option>
|
||||
<option value="index, nofollow"></option>
|
||||
<option value="noindex, nofollow"></option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rights"
|
||||
type="text"
|
||||
label="JFIELD_META_RIGHTS_LABEL"
|
||||
rows="2"
|
||||
cols="30"
|
||||
filter="string"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
27
administrator/components/com_newsfeeds/helpers/newsfeeds.php
Normal file
27
administrator/components/com_newsfeeds/helpers/newsfeeds.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
*/
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeeds component helper.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Newsfeeds\Administrator\Helper\NewsfeedsHelper instead
|
||||
*/
|
||||
class NewsfeedsHelper extends \Joomla\Component\Newsfeeds\Administrator\Helper\NewsfeedsHelper
|
||||
{
|
||||
}
|
||||
62
administrator/components/com_newsfeeds/newsfeeds.xml
Normal file
62
administrator/components/com_newsfeeds/newsfeeds.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>com_newsfeeds</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2006-04</creationDate>
|
||||
<copyright>(C) 2006 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>4.0.0</version>
|
||||
<description>COM_NEWSFEEDS_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Component\Newsfeeds</namespace>
|
||||
<install> <!-- Runs on install -->
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</install>
|
||||
<uninstall> <!-- Runs on uninstall -->
|
||||
<sql>
|
||||
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
|
||||
</sql>
|
||||
</uninstall>
|
||||
<files folder="site">
|
||||
<folder>helpers</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB/com_newsfeeds.ini</language>
|
||||
</languages>
|
||||
<media destination="com_newsfeeds" folder="media">
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
<administration>
|
||||
<menu img="class:newsfeeds">com_newsfeeds</menu>
|
||||
<submenu>
|
||||
<!--
|
||||
Note that all & must be escaped to & for the file to be valid
|
||||
XML and be parsed by the installer
|
||||
-->
|
||||
<menu link="option=com_newsfeeds" view="feeds" img="class:rss"
|
||||
alt="Newsfeeds/Feeds">com_newsfeeds_feeds</menu>
|
||||
<menu link="option=com_categories&extension=com_newsfeeds"
|
||||
view="categories" img="class:newsfeeds-cat" alt="Newsfeeds/Categories">com_newsfeeds_categories</menu>
|
||||
</submenu>
|
||||
<files folder="admin">
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
<filename>newsfeeds.xml</filename>
|
||||
<folder>forms</folder>
|
||||
<folder>helpers</folder>
|
||||
<folder>services</folder>
|
||||
<folder>sql</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<language tag="en-GB">language/en-GB/com_newsfeeds.ini</language>
|
||||
<language tag="en-GB">language/en-GB/com_newsfeeds.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
||||
68
administrator/components/com_newsfeeds/services/provider.php
Normal file
68
administrator/components/com_newsfeeds/services/provider.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Association\AssociationExtensionInterface;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
use Joomla\CMS\Component\Router\RouterFactoryInterface;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
||||
use Joomla\CMS\Extension\ComponentInterface;
|
||||
use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
|
||||
use Joomla\CMS\HTML\Registry;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\Component\Newsfeeds\Administrator\Extension\NewsfeedsComponent;
|
||||
use Joomla\Component\Newsfeeds\Administrator\Helper\AssociationsHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* The newsfeed service provider.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(AssociationExtensionInterface::class, new AssociationsHelper());
|
||||
|
||||
$container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Newsfeeds'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Newsfeeds'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Newsfeeds'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\Joomla\\Component\\Newsfeeds'));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$component = new NewsfeedsComponent($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setRegistry($container->get(Registry::class));
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
|
||||
$component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,42 @@
|
||||
--
|
||||
-- Table structure for table `#__newsfeeds`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__newsfeeds` (
|
||||
`catid` int NOT NULL DEFAULT 0,
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL DEFAULT '',
|
||||
`alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
|
||||
`link` varchar(2048) NOT NULL DEFAULT '',
|
||||
`published` tinyint NOT NULL DEFAULT 0,
|
||||
`numarticles` int unsigned NOT NULL DEFAULT 1,
|
||||
`cache_time` int unsigned NOT NULL DEFAULT 3600,
|
||||
`checked_out` int unsigned NOT NULL DEFAULT 0,
|
||||
`checked_out_time` datetime,
|
||||
`ordering` int NOT NULL DEFAULT 0,
|
||||
`rtl` tinyint NOT NULL DEFAULT 0,
|
||||
`access` int unsigned NOT NULL DEFAULT 0,
|
||||
`language` char(7) NOT NULL DEFAULT '',
|
||||
`params` text NOT NULL,
|
||||
`created` datetime NOT NULL,
|
||||
`created_by` int unsigned NOT NULL DEFAULT 0,
|
||||
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
|
||||
`modified` datetime NOT NULL,
|
||||
`modified_by` int unsigned NOT NULL DEFAULT 0,
|
||||
`metakey` text NOT NULL,
|
||||
`metadesc` text NOT NULL,
|
||||
`metadata` text NOT NULL,
|
||||
`publish_up` datetime,
|
||||
`publish_down` datetime,
|
||||
`description` text NOT NULL,
|
||||
`version` int unsigned NOT NULL DEFAULT 1,
|
||||
`hits` int unsigned NOT NULL DEFAULT 0,
|
||||
`images` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_state` (`published`),
|
||||
KEY `idx_catid` (`catid`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
KEY `idx_language` (`language`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||
@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS `#__newsfeeds`;
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* The newsfeed controller for ajax requests
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
class AjaxController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Method to fetch associations of a newsfeed
|
||||
*
|
||||
* The method assumes that the following http parameters are passed in an Ajax Get request:
|
||||
* token: the form token
|
||||
* assocId: the id of the newsfeed whose associations are to be returned
|
||||
* excludeLang: the association for this language is to be excluded
|
||||
*
|
||||
* @return null
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public function fetchAssociations()
|
||||
{
|
||||
if (!Session::checkToken('get')) {
|
||||
echo new JsonResponse(null, Text::_('JINVALID_TOKEN'), true);
|
||||
} else {
|
||||
$assocId = $this->input->getInt('assocId', 0);
|
||||
|
||||
if ($assocId == 0) {
|
||||
echo new JsonResponse(null, Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'assocId'), true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$excludeLang = $this->input->get('excludeLang', '', 'STRING');
|
||||
|
||||
$associations = Associations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', (int) $assocId);
|
||||
|
||||
unset($associations[$excludeLang]);
|
||||
|
||||
// Add the title to each of the associated records
|
||||
$newsfeedsTable = $this->factory->createTable('Newsfeed', 'Administrator');
|
||||
|
||||
foreach ($associations as $lang => $association) {
|
||||
$newsfeedsTable->load($association->id);
|
||||
$associations[$lang]->title = $newsfeedsTable->name;
|
||||
}
|
||||
|
||||
$countContentLanguages = \count(LanguageHelper::getContentLanguages([0, 1], false));
|
||||
|
||||
if (\count($associations) == 0) {
|
||||
$message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE');
|
||||
} elseif ($countContentLanguages > \count($associations) + 2) {
|
||||
$tags = implode(', ', array_keys($associations));
|
||||
$message = Text::sprintf('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME', $tags);
|
||||
} else {
|
||||
$message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL');
|
||||
}
|
||||
|
||||
echo new JsonResponse($associations, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeeds display controller.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The default view.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'newsfeeds';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe URL parameters and their variable types.
|
||||
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
|
||||
*
|
||||
* @return static|boolean This object to support chaining.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = [])
|
||||
{
|
||||
$view = $this->input->get('view', 'newsfeeds');
|
||||
$layout = $this->input->get('layout', 'default');
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Check for edit form.
|
||||
if ($view == 'newsfeed' && $layout == 'edit' && !$this->checkEditId('com_newsfeeds.edit.newsfeed', $id)) {
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
if (!\count($this->app->getMessageQueue())) {
|
||||
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
|
||||
}
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_newsfeeds&view=newsfeeds', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::display();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Versioning\VersionableControllerTrait;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeed controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedController extends FormController
|
||||
{
|
||||
use VersionableControllerTrait;
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = [])
|
||||
{
|
||||
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
|
||||
$allow = null;
|
||||
|
||||
if ($categoryId) {
|
||||
// If the category has been passed in the URL check it.
|
||||
$allow = $this->app->getIdentity()->authorise('core.create', $this->option . '.category.' . $categoryId);
|
||||
}
|
||||
|
||||
if ($allow === null) {
|
||||
// In the absence of better information, revert to the component permissions.
|
||||
return parent::allowAdd($data);
|
||||
}
|
||||
|
||||
return $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if you can edit a record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = [], $key = 'id')
|
||||
{
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
|
||||
// Since there is no asset tracking, fallback to the component permissions.
|
||||
if (!$recordId) {
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
|
||||
// Get the item.
|
||||
$item = $this->getModel()->getItem($recordId);
|
||||
|
||||
// Since there is no item, return false.
|
||||
if (empty($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// Check if can edit own core.edit.own.
|
||||
$canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id;
|
||||
|
||||
// Check the category core.edit permissions.
|
||||
return $canEditOwn || $user->authorise('core.edit', $this->option . '.category.' . (int) $item->catid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param object $model The model.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function batch($model = null)
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Newsfeed', '', []);
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(Route::_('index.php?option=com_newsfeeds&view=newsfeeds' . $this->getRedirectToListAppend(), false));
|
||||
|
||||
return parent::batch($model);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeeds list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedsController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Method to get a model object, loading it if required.
|
||||
*
|
||||
* @param string $name The model name. Optional.
|
||||
* @param string $prefix The class prefix. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return object The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Newsfeed', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the number of published newsfeeds for quickicons
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function getQuickiconContent()
|
||||
{
|
||||
$model = $this->getModel('newsfeeds');
|
||||
|
||||
$model->setState('filter.published', 1);
|
||||
|
||||
$amount = (int) $model->getTotal();
|
||||
|
||||
$result = [];
|
||||
|
||||
$result['amount'] = $amount;
|
||||
$result['sronly'] = Text::plural('COM_NEWSFEEDS_N_QUICKICON_SRONLY', $amount);
|
||||
$result['name'] = Text::plural('COM_NEWSFEEDS_N_QUICKICON', $amount);
|
||||
|
||||
echo new JsonResponse($result);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Extension;
|
||||
|
||||
use Joomla\CMS\Association\AssociationServiceInterface;
|
||||
use Joomla\CMS\Association\AssociationServiceTrait;
|
||||
use Joomla\CMS\Categories\CategoryServiceInterface;
|
||||
use Joomla\CMS\Categories\CategoryServiceTrait;
|
||||
use Joomla\CMS\Component\Router\RouterServiceInterface;
|
||||
use Joomla\CMS\Component\Router\RouterServiceTrait;
|
||||
use Joomla\CMS\Extension\BootableExtensionInterface;
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
|
||||
use Joomla\CMS\Tag\TagServiceInterface;
|
||||
use Joomla\CMS\Tag\TagServiceTrait;
|
||||
use Joomla\Component\Newsfeeds\Administrator\Service\HTML\AdministratorService;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component class for com_newsfeeds
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class NewsfeedsComponent extends MVCComponent implements
|
||||
BootableExtensionInterface,
|
||||
CategoryServiceInterface,
|
||||
AssociationServiceInterface,
|
||||
RouterServiceInterface,
|
||||
TagServiceInterface
|
||||
{
|
||||
use AssociationServiceTrait;
|
||||
use HTMLRegistryAwareTrait;
|
||||
use RouterServiceTrait;
|
||||
use CategoryServiceTrait, TagServiceTrait {
|
||||
CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait;
|
||||
CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* Booting the extension. This is the function to set up the environment of the extension like
|
||||
* registering new class loaders, etc.
|
||||
*
|
||||
* If required, some initial set up can be done from services of the container, eg.
|
||||
* registering HTML services.
|
||||
*
|
||||
* @param ContainerInterface $container The container
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function boot(ContainerInterface $container)
|
||||
{
|
||||
$this->getRegistry()->register('newsfeedsadministrator', new AdministratorService());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the table for the count items functions for the given section.
|
||||
*
|
||||
* @param string $section The section
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getTableNameForSection(string $section = null)
|
||||
{
|
||||
return $section === 'category' ? 'categories' : 'newsfeeds';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state column for the count items functions for the given section.
|
||||
*
|
||||
* @param string $section The section
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getStateColumnForSection(string $section = null)
|
||||
{
|
||||
return 'published';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Field\Modal;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\FormField;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Supports a modal newsfeeds picker.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedField extends FormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'Modal_Newsfeed';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$allowNew = ((string) $this->element['new'] == 'true');
|
||||
$allowEdit = ((string) $this->element['edit'] == 'true');
|
||||
$allowClear = ((string) $this->element['clear'] != 'false');
|
||||
$allowSelect = ((string) $this->element['select'] != 'false');
|
||||
$allowPropagate = ((string) $this->element['propagate'] == 'true');
|
||||
|
||||
$languages = LanguageHelper::getContentLanguages([0, 1], false);
|
||||
|
||||
// Load language
|
||||
Factory::getLanguage()->load('com_newsfeeds', JPATH_ADMINISTRATOR);
|
||||
|
||||
// The active newsfeed id field.
|
||||
$value = (int) $this->value ?: '';
|
||||
|
||||
// Create the modal id.
|
||||
$modalId = 'Newsfeed_' . $this->id;
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
|
||||
// Add the modal field script to the document head.
|
||||
$wa->useScript('field.modal-fields');
|
||||
|
||||
// Script to proxy the select modal function to the modal-fields.js file.
|
||||
if ($allowSelect) {
|
||||
static $scriptSelect = null;
|
||||
|
||||
if (\is_null($scriptSelect)) {
|
||||
$scriptSelect = [];
|
||||
}
|
||||
|
||||
if (!isset($scriptSelect[$this->id])) {
|
||||
$wa->addInlineScript(
|
||||
"
|
||||
window.jSelectNewsfeed_" . $this->id . " = function (id, title, object) {
|
||||
window.processModalSelect('Newsfeed', '" . $this->id . "', id, title, '', object);
|
||||
}",
|
||||
[],
|
||||
['type' => 'module']
|
||||
);
|
||||
|
||||
Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
|
||||
|
||||
$scriptSelect[$this->id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup variables for display.
|
||||
$linkNewsfeeds = 'index.php?option=com_newsfeeds&view=newsfeeds&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
$linkNewsfeed = 'index.php?option=com_newsfeeds&view=newsfeed&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
$modalTitle = Text::_('COM_NEWSFEEDS_SELECT_A_FEED');
|
||||
|
||||
if (isset($this->element['language'])) {
|
||||
$linkNewsfeeds .= '&forcedLanguage=' . $this->element['language'];
|
||||
$linkNewsfeed .= '&forcedLanguage=' . $this->element['language'];
|
||||
$modalTitle .= ' — ' . $this->element['label'];
|
||||
}
|
||||
|
||||
$urlSelect = $linkNewsfeeds . '&function=jSelectNewsfeed_' . $this->id;
|
||||
$urlEdit = $linkNewsfeed . '&task=newsfeed.edit&id=\' + document.getElementById("' . $this->id . '_id").value + \'';
|
||||
$urlNew = $linkNewsfeed . '&task=newsfeed.add';
|
||||
|
||||
if ($value) {
|
||||
$id = (int) $value;
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('name'))
|
||||
->from($db->quoteName('#__newsfeeds'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$title = $db->loadResult();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
$title = empty($title) ? Text::_('COM_NEWSFEEDS_SELECT_A_FEED') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// The current newsfeed display field.
|
||||
$html = '';
|
||||
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
|
||||
$html .= '<span class="input-group">';
|
||||
}
|
||||
|
||||
$html .= '<input class="form-control" id="' . $this->id . '_name" type="text" value="' . $title . '" readonly size="35">';
|
||||
|
||||
// Select newsfeed button
|
||||
if ($allowSelect) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? ' hidden' : '') . '"'
|
||||
. ' id="' . $this->id . '_select"'
|
||||
. ' data-bs-toggle="modal"'
|
||||
. ' type="button"'
|
||||
. ' data-bs-target="#ModalSelect' . $modalId . '">'
|
||||
. '<span class="icon-file" aria-hidden="true"></span> ' . Text::_('JSELECT')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// New newsfeed button
|
||||
if ($allowNew) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-secondary' . ($value ? ' hidden' : '') . '"'
|
||||
. ' id="' . $this->id . '_new"'
|
||||
. ' data-bs-toggle="modal"'
|
||||
. ' type="button"'
|
||||
. ' data-bs-target="#ModalNew' . $modalId . '">'
|
||||
. '<span class="icon-plus" aria-hidden="true"></span> ' . Text::_('JACTION_CREATE')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// Edit newsfeed button
|
||||
if ($allowEdit) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' id="' . $this->id . '_edit"'
|
||||
. ' data-bs-toggle="modal"'
|
||||
. ' type="button"'
|
||||
. ' data-bs-target="#ModalEdit' . $modalId . '">'
|
||||
. '<span class="icon-pen-square" aria-hidden="true"></span> ' . Text::_('JACTION_EDIT')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// Clear newsfeed button
|
||||
if ($allowClear) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' id="' . $this->id . '_clear"'
|
||||
. ' type="button"'
|
||||
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
|
||||
. '<span class="icon-times" aria-hidden="true"></span> ' . Text::_('JCLEAR')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// Propagate newsfeed button
|
||||
if ($allowPropagate && \count($languages) > 2) {
|
||||
// Strip off language tag at the end
|
||||
$tagLength = (int) \strlen($this->element['language']);
|
||||
$callbackFunctionStem = substr("jSelectNewsfeed_" . $this->id, 0, -$tagLength);
|
||||
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' type="button"'
|
||||
. ' id="' . $this->id . '_propagate"'
|
||||
. ' title="' . Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') . '"'
|
||||
. ' onclick="Joomla.propagateAssociation(\'' . $this->id . '\', \'' . $callbackFunctionStem . '\');">'
|
||||
. '<span class="icon-sync" aria-hidden="true"></span> ' . Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
|
||||
$html .= '</span>';
|
||||
}
|
||||
|
||||
// Select newsfeed modal
|
||||
if ($allowSelect) {
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalSelect' . $modalId,
|
||||
[
|
||||
'title' => $modalTitle,
|
||||
'url' => $urlSelect,
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => 70,
|
||||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// New newsfeed modal
|
||||
if ($allowNew) {
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalNew' . $modalId,
|
||||
[
|
||||
'title' => Text::_('COM_NEWSFEEDS_NEW_NEWSFEED'),
|
||||
'backdrop' => 'static',
|
||||
'keyboard' => false,
|
||||
'closeButton' => false,
|
||||
'url' => $urlNew,
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => 70,
|
||||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'add\', \'newsfeed\', \'cancel\', \'newsfeed-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
|
||||
. '<button type="button" class="btn btn-primary"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'add\', \'newsfeed\', \'save\', \'newsfeed-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JSAVE') . '</button>'
|
||||
. '<button type="button" class="btn btn-success"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'add\', \'newsfeed\', \'apply\', \'newsfeed-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JAPPLY') . '</button>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Edit newsfeed modal.
|
||||
if ($allowEdit) {
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalEdit' . $modalId,
|
||||
[
|
||||
'title' => Text::_('COM_NEWSFEEDS_EDIT_NEWSFEED'),
|
||||
'backdrop' => 'static',
|
||||
'keyboard' => false,
|
||||
'closeButton' => false,
|
||||
'url' => $urlEdit,
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => 70,
|
||||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary"'
|
||||
. ' onclick="window.processModalEdit(this, \'' . $this->id
|
||||
. '\', \'edit\', \'newsfeed\', \'cancel\', \'newsfeed-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
|
||||
. '<button type="button" class="btn btn-primary"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'edit\', \'newsfeed\', \'save\', \'newsfeed-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JSAVE') . '</button>'
|
||||
. '<button type="button" class="btn btn-success"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'edit\', \'newsfeed\', \'apply\', \'newsfeed-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JAPPLY') . '</button>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Add class='required' for client side validation
|
||||
$class = $this->required ? ' class="required modal-value"' : '';
|
||||
|
||||
$html .= '<input type="hidden" id="' . $this->id . '_id"' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
|
||||
. '" data-text="' . htmlspecialchars(Text::_('COM_NEWSFEEDS_SELECT_A_FEED', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '">';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field label markup.
|
||||
*
|
||||
* @return string The field label markup.
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
return str_replace($this->id, $this->id . '_name', parent::getLabel());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Field;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Field\ListField;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* News Feed List field.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedsField extends ListField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'Newsfeeds';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = [];
|
||||
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('id', 'value'),
|
||||
$db->quoteName('name', 'text'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__newsfeeds', 'a'))
|
||||
->order($db->quoteName('a.name'));
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$options = $db->loadObjectList();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Association\AssociationExtensionHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Component\Newsfeeds\Site\Helper\AssociationHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content associations helper.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
class AssociationsHelper extends AssociationExtensionHelper
|
||||
{
|
||||
/**
|
||||
* The extension name
|
||||
*
|
||||
* @var array $extension
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $extension = 'com_newsfeeds';
|
||||
|
||||
/**
|
||||
* Array of item types
|
||||
*
|
||||
* @var array $itemTypes
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $itemTypes = ['newsfeed', 'category'];
|
||||
|
||||
/**
|
||||
* Has the extension association support
|
||||
*
|
||||
* @var boolean $associationsSupport
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $associationsSupport = true;
|
||||
|
||||
/**
|
||||
* 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 4.0.0
|
||||
*/
|
||||
public function getAssociationsForItem($id = 0, $view = null)
|
||||
{
|
||||
return AssociationHelper::getAssociations($id, $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated items for an item
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
* @param int $id The id of item for which we need the associated items
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function getAssociations($typeName, $id)
|
||||
{
|
||||
$type = $this->getType($typeName);
|
||||
|
||||
$context = $this->extension . '.item';
|
||||
$catidField = 'catid';
|
||||
|
||||
if ($typeName === 'category') {
|
||||
$context = 'com_categories.item';
|
||||
$catidField = '';
|
||||
}
|
||||
|
||||
// Get the associations.
|
||||
$associations = Associations::getAssociations(
|
||||
$this->extension,
|
||||
$type['tables']['a'],
|
||||
$context,
|
||||
$id,
|
||||
'id',
|
||||
'alias',
|
||||
$catidField
|
||||
);
|
||||
|
||||
return $associations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item information
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
* @param int $id The id of item for which we need the associated items
|
||||
*
|
||||
* @return Table|null
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function getItem($typeName, $id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$table = null;
|
||||
|
||||
switch ($typeName) {
|
||||
case 'newsfeed':
|
||||
$table = Table::getInstance('NewsfeedTable', 'Joomla\\Component\\Newsfeeds\\Administrator\\Table\\');
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$table = Table::getInstance('Category');
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($table)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$table->load($id);
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the type
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
*
|
||||
* @return array Array of item types
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function getType($typeName = '')
|
||||
{
|
||||
$fields = $this->getFieldsTemplate();
|
||||
$tables = [];
|
||||
$joins = [];
|
||||
$support = $this->getSupportTemplate();
|
||||
$title = '';
|
||||
|
||||
if (\in_array($typeName, $this->itemTypes)) {
|
||||
switch ($typeName) {
|
||||
case 'newsfeed':
|
||||
$fields['title'] = 'a.name';
|
||||
$fields['state'] = 'a.published';
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['category'] = true;
|
||||
$support['save2copy'] = true;
|
||||
|
||||
$tables = [
|
||||
'a' => '#__newsfeeds',
|
||||
];
|
||||
$title = 'newsfeed';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$fields['created_user_id'] = 'a.created_user_id';
|
||||
$fields['ordering'] = 'a.lft';
|
||||
$fields['level'] = 'a.level';
|
||||
$fields['catid'] = '';
|
||||
$fields['state'] = 'a.published';
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['level'] = true;
|
||||
|
||||
$tables = [
|
||||
'a' => '#__categories',
|
||||
];
|
||||
|
||||
$title = 'category';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'fields' => $fields,
|
||||
'support' => $support,
|
||||
'tables' => $tables,
|
||||
'joins' => $joins,
|
||||
'title' => $title,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeeds component helper.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedsHelper extends ContentHelper
|
||||
{
|
||||
/**
|
||||
* Name of the extension
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $extension = 'com_newsfeeds';
|
||||
|
||||
/**
|
||||
* Adds Count Items for Category Manager.
|
||||
*
|
||||
* @param \stdClass[] &$items The banner category objects
|
||||
*
|
||||
* @return \stdClass[]
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
public static function countItems(&$items)
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select(
|
||||
[
|
||||
$db->quoteName('published', 'state'),
|
||||
'COUNT(*) AS ' . $db->quoteName('count'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__newsfeeds'))
|
||||
->where($db->quoteName('catid') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->group($db->quoteName('state'));
|
||||
$db->setQuery($query);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$item->count_trashed = 0;
|
||||
$item->count_archived = 0;
|
||||
$item->count_unpublished = 0;
|
||||
$item->count_published = 0;
|
||||
|
||||
$id = (int) $item->id;
|
||||
$newfeeds = $db->loadObjectList();
|
||||
|
||||
foreach ($newfeeds as $newsfeed) {
|
||||
if ($newsfeed->state == 1) {
|
||||
$item->count_published = $newsfeed->count;
|
||||
}
|
||||
|
||||
if ($newsfeed->state == 0) {
|
||||
$item->count_unpublished = $newsfeed->count;
|
||||
}
|
||||
|
||||
if ($newsfeed->state == 2) {
|
||||
$item->count_archived = $newsfeed->count;
|
||||
}
|
||||
|
||||
if ($newsfeed->state == -2) {
|
||||
$item->count_trashed = $newsfeed->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Count Items for Tag Manager.
|
||||
*
|
||||
* @param \stdClass[] &$items The newsfeed tag objects
|
||||
* @param string $extension The name of the active view.
|
||||
*
|
||||
* @return \stdClass[]
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public static function countTagItems(&$items, $extension)
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$parts = explode('.', $extension);
|
||||
$section = null;
|
||||
|
||||
if (\count($parts) > 1) {
|
||||
$section = $parts[1];
|
||||
}
|
||||
|
||||
$query->select(
|
||||
[
|
||||
$db->quoteName('published', 'state'),
|
||||
'COUNT(*) AS ' . $db->quoteName('count'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__contentitem_tag_map', 'ct'));
|
||||
|
||||
if ($section === 'category') {
|
||||
$query->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('ct.content_item_id') . ' = ' . $db->quoteName('c.id'));
|
||||
} else {
|
||||
$query->join('LEFT', $db->quoteName('#__newsfeeds', 'c'), $db->quoteName('ct.content_item_id') . ' = ' . $db->quoteName('c.id'));
|
||||
}
|
||||
|
||||
$query->where(
|
||||
[
|
||||
$db->quoteName('ct.tag_id') . ' = :id',
|
||||
$db->quoteName('ct.type_alias') . ' = :extension',
|
||||
]
|
||||
)
|
||||
->bind(':id', $id, ParameterType::INTEGER)
|
||||
->bind(':extension', $extension)
|
||||
->group($db->quoteName('state'));
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$item->count_trashed = 0;
|
||||
$item->count_archived = 0;
|
||||
$item->count_unpublished = 0;
|
||||
$item->count_published = 0;
|
||||
|
||||
// Update ID used in database query.
|
||||
$id = (int) $item->id;
|
||||
$newsfeeds = $db->loadObjectList();
|
||||
|
||||
foreach ($newsfeeds as $newsfeed) {
|
||||
if ($newsfeed->state == 1) {
|
||||
$item->count_published = $newsfeed->count;
|
||||
}
|
||||
|
||||
if ($newsfeed->state == 0) {
|
||||
$item->count_unpublished = $newsfeed->count;
|
||||
}
|
||||
|
||||
if ($newsfeed->state == 2) {
|
||||
$item->count_archived = $newsfeed->count;
|
||||
}
|
||||
|
||||
if ($newsfeed->state == -2) {
|
||||
$item->count_trashed = $newsfeed->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,429 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
use Joomla\CMS\Versioning\VersionableModelTrait;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeed model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedModel extends AdminModel
|
||||
{
|
||||
use VersionableModelTrait;
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_newsfeeds.newsfeed';
|
||||
|
||||
/**
|
||||
* The context used for the associations table
|
||||
*
|
||||
* @var string
|
||||
* @since 3.4.4
|
||||
*/
|
||||
protected $associationsContext = 'com_newsfeeds.item';
|
||||
|
||||
/**
|
||||
* @var string The prefix to use with controller messages.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_NEWSFEEDS';
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
if (empty($record->id) || $record->published != -2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.delete', 'com_newsfeed.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
return parent::canDelete($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can have its state changed.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.edit.state', 'com_newsfeeds.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
return parent::canEditState($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form|bool A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_newsfeeds.newsfeed', 'newsfeed', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Modify the form based on access controls.
|
||||
if (!$this->canEditState((object) $data)) {
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
$form->setFieldAttribute('published', 'disabled', 'true');
|
||||
$form->setFieldAttribute('publish_up', 'disabled', 'true');
|
||||
$form->setFieldAttribute('publish_down', 'disabled', 'true');
|
||||
|
||||
// Disable fields while saving.
|
||||
// The controller has already verified this is a record you can edit.
|
||||
$form->setFieldAttribute('ordering', 'filter', 'unset');
|
||||
$form->setFieldAttribute('published', 'filter', 'unset');
|
||||
$form->setFieldAttribute('publish_up', 'filter', 'unset');
|
||||
$form->setFieldAttribute('publish_down', 'filter', 'unset');
|
||||
}
|
||||
|
||||
// Don't allow to change the created_by user if not allowed to access com_users.
|
||||
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users')) {
|
||||
$form->setFieldAttribute('created_by', 'filter', 'unset');
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return mixed The data for the form.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$data = Factory::getApplication()->getUserState('com_newsfeeds.edit.newsfeed.data', []);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
|
||||
// Prime some default values.
|
||||
if ($this->getState('newsfeed.id') == 0) {
|
||||
$app = Factory::getApplication();
|
||||
$data->set('catid', $app->getInput()->get('catid', $app->getUserState('com_newsfeeds.newsfeeds.filter.category_id'), 'int'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->preprocessData('com_newsfeeds.newsfeed', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
|
||||
// Create new category, if needed.
|
||||
$createCategory = true;
|
||||
|
||||
// If category ID is provided, check if it's valid.
|
||||
if (is_numeric($data['catid']) && $data['catid']) {
|
||||
$createCategory = !CategoriesHelper::validateCategoryId($data['catid'], 'com_newsfeeds');
|
||||
}
|
||||
|
||||
// Save New Category
|
||||
if ($createCategory && $this->canCreateCategory()) {
|
||||
$category = [
|
||||
// Remove #new# prefix, if exists.
|
||||
'title' => strpos($data['catid'], '#new#') === 0 ? substr($data['catid'], 5) : $data['catid'],
|
||||
'parent_id' => 1,
|
||||
'extension' => 'com_newsfeeds',
|
||||
'language' => $data['language'],
|
||||
'published' => 1,
|
||||
];
|
||||
|
||||
/** @var \Joomla\Component\Categories\Administrator\Model\CategoryModel $categoryModel */
|
||||
$categoryModel = Factory::getApplication()->bootComponent('com_categories')
|
||||
->getMVCFactory()->createModel('Category', 'Administrator', ['ignore_request' => true]);
|
||||
|
||||
// Create new category.
|
||||
if (!$categoryModel->save($category)) {
|
||||
$this->setError($categoryModel->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the Category ID.
|
||||
$data['catid'] = $categoryModel->getState('category.id');
|
||||
}
|
||||
|
||||
// Alter the name for save as copy
|
||||
if ($input->get('task') == 'save2copy') {
|
||||
$origTable = clone $this->getTable();
|
||||
$origTable->load($input->getInt('id'));
|
||||
|
||||
if ($data['name'] == $origTable->name) {
|
||||
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
|
||||
$data['name'] = $name;
|
||||
$data['alias'] = $alias;
|
||||
} else {
|
||||
if ($data['alias'] == $origTable->alias) {
|
||||
$data['alias'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$data['published'] = 0;
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a single record.
|
||||
*
|
||||
* @param integer $pk The id of the primary key.
|
||||
*
|
||||
* @return mixed Object on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
if ($item = parent::getItem($pk)) {
|
||||
// Convert the params field to an array.
|
||||
$registry = new Registry($item->metadata);
|
||||
$item->metadata = $registry->toArray();
|
||||
|
||||
// Convert the images field to an array.
|
||||
$registry = new Registry($item->images);
|
||||
$item->images = $registry->toArray();
|
||||
}
|
||||
|
||||
// Load associated newsfeeds items
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($assoc) {
|
||||
$item->associations = [];
|
||||
|
||||
if ($item->id != null) {
|
||||
$associations = Associations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $item->id);
|
||||
|
||||
foreach ($associations as $tag => $association) {
|
||||
$item->associations[$tag] = $association->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item->id)) {
|
||||
$item->tags = new TagsHelper();
|
||||
$item->tags->getTagIds($item->id, 'com_newsfeeds.newsfeed');
|
||||
|
||||
// @todo: We probably don't need this in any client - but needs careful validation
|
||||
if (!Factory::getApplication()->isClient('api')) {
|
||||
$item->metadata['tags'] = $item->tags;
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table prior to saving.
|
||||
*
|
||||
* @param \Joomla\CMS\Table\Table $table The table object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$date = Factory::getDate();
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
|
||||
$table->alias = ApplicationHelper::stringURLSafe($table->alias, $table->language);
|
||||
|
||||
if (empty($table->alias)) {
|
||||
$table->alias = ApplicationHelper::stringURLSafe($table->name, $table->language);
|
||||
}
|
||||
|
||||
if (empty($table->id)) {
|
||||
// Set the values
|
||||
$table->created = $date->toSql();
|
||||
|
||||
// Set ordering to the last item if not set
|
||||
if (empty($table->ordering)) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select('MAX(' . $db->quoteName('ordering') . ')')
|
||||
->from($db->quoteName('#__newsfeeds'));
|
||||
$db->setQuery($query);
|
||||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
} else {
|
||||
// Set the values
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->get('id');
|
||||
}
|
||||
|
||||
// Increment the content version number.
|
||||
$table->version++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the published state of one or more records.
|
||||
*
|
||||
* @param array &$pks A list of the primary keys to change.
|
||||
* @param integer $value The value of the published state.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function publish(&$pks, $value = 1)
|
||||
{
|
||||
$result = parent::publish($pks, $value);
|
||||
|
||||
// Clean extra cache for newsfeeds
|
||||
$this->cleanCache('feed_parser');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A protected method to get a set of ordering conditions.
|
||||
*
|
||||
* @param object $table A record object.
|
||||
*
|
||||
* @return array An array of conditions to add to ordering queries.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getReorderConditions($table)
|
||||
{
|
||||
return [
|
||||
$this->getDatabase()->quoteName('catid') . ' = ' . (int) $table->catid,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* A protected method to get a set of ordering conditions.
|
||||
*
|
||||
* @param Form $form The form object.
|
||||
* @param array $data The data to be injected into the form
|
||||
* @param string $group The plugin group to process
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
if ($this->canCreateCategory()) {
|
||||
$form->setFieldAttribute('catid', 'allowAdd', 'true');
|
||||
|
||||
// Add a prefix for categories created on the fly.
|
||||
$form->setFieldAttribute('catid', 'customPrefix', '#new#');
|
||||
}
|
||||
|
||||
// Association newsfeeds items
|
||||
if (Associations::isEnabled()) {
|
||||
$languages = LanguageHelper::getContentLanguages(false, false, null, 'ordering', 'asc');
|
||||
|
||||
if (\count($languages) > 1) {
|
||||
$addform = new \SimpleXMLElement('<form />');
|
||||
$fields = $addform->addChild('fields');
|
||||
$fields->addAttribute('name', 'associations');
|
||||
$fieldset = $fields->addChild('fieldset');
|
||||
$fieldset->addAttribute('name', 'item_associations');
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$field = $fieldset->addChild('field');
|
||||
$field->addAttribute('name', $language->lang_code);
|
||||
$field->addAttribute('type', 'modal_newsfeed');
|
||||
$field->addAttribute('language', $language->lang_code);
|
||||
$field->addAttribute('label', $language->title);
|
||||
$field->addAttribute('translate_label', 'false');
|
||||
$field->addAttribute('select', 'true');
|
||||
$field->addAttribute('new', 'true');
|
||||
$field->addAttribute('edit', 'true');
|
||||
$field->addAttribute('clear', 'true');
|
||||
$field->addAttribute('propagate', 'true');
|
||||
}
|
||||
|
||||
$form->load($addform, false);
|
||||
}
|
||||
}
|
||||
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the user allowed to create an on the fly category?
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 3.6.1
|
||||
*/
|
||||
private function canCreateCategory()
|
||||
{
|
||||
return $this->getCurrentUser()->authorise('core.create', 'com_newsfeeds');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Methods supporting a list of newsfeed records.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedsModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* @param MVCFactoryInterface $factory The factory.
|
||||
*
|
||||
* @see \Joomla\CMS\MVC\Model\BaseDatabaseModel
|
||||
* @since 3.2
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null)
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'name', 'a.name',
|
||||
'alias', 'a.alias',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'catid', 'a.catid', 'category_id', 'category_title',
|
||||
'published', 'a.published',
|
||||
'access', 'a.access', 'access_level',
|
||||
'created', 'a.created',
|
||||
'created_by', 'a.created_by',
|
||||
'ordering', 'a.ordering',
|
||||
'language', 'a.language', 'language_title',
|
||||
'publish_up', 'a.publish_up',
|
||||
'publish_down', 'a.publish_down',
|
||||
'cache_time', 'a.cache_time',
|
||||
'numarticles',
|
||||
'tag',
|
||||
'level', 'c.level',
|
||||
'tag',
|
||||
];
|
||||
|
||||
if (Associations::isEnabled()) {
|
||||
$config['filter_fields'][] = 'association';
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($config, $factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = 'a.name', $direction = 'asc')
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$forcedLanguage = $app->getInput()->get('forcedLanguage', '', 'cmd');
|
||||
|
||||
// Adjust the context to support modal layouts.
|
||||
if ($layout = $app->getInput()->get('layout')) {
|
||||
$this->context .= '.' . $layout;
|
||||
}
|
||||
|
||||
// Adjust the context to support forced languages.
|
||||
if ($forcedLanguage) {
|
||||
$this->context .= '.' . $forcedLanguage;
|
||||
}
|
||||
|
||||
// Load the parameters.
|
||||
$params = ComponentHelper::getParams('com_newsfeeds');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
|
||||
// Force a language.
|
||||
if (!empty($forcedLanguage)) {
|
||||
$this->setState('filter.language', $forcedLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.published');
|
||||
$id .= ':' . $this->getState('filter.category_id');
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.language');
|
||||
$id .= ':' . $this->getState('filter.level');
|
||||
$id .= ':' . serialize($this->getState('filter.tag'));
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.name'),
|
||||
$db->quoteName('a.alias'),
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('a.catid'),
|
||||
$db->quoteName('a.numarticles'),
|
||||
$db->quoteName('a.cache_time'),
|
||||
$db->quoteName('a.created_by'),
|
||||
$db->quoteName('a.published'),
|
||||
$db->quoteName('a.access'),
|
||||
$db->quoteName('a.ordering'),
|
||||
$db->quoteName('a.language'),
|
||||
$db->quoteName('a.publish_up'),
|
||||
$db->quoteName('a.publish_down'),
|
||||
]
|
||||
)
|
||||
)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('l.title', 'language_title'),
|
||||
$db->quoteName('l.image', 'language_image'),
|
||||
$db->quoteName('uc.name', 'editor'),
|
||||
$db->quoteName('ag.title', 'access_level'),
|
||||
$db->quoteName('c.title', 'category_title'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__newsfeeds', 'a'))
|
||||
->join('LEFT', $db->quoteName('#__languages', 'l'), $db->quoteName('l.lang_code') . ' = ' . $db->quoteName('a.language'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'uc'), $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out'))
|
||||
->join('LEFT', $db->quoteName('#__viewlevels', 'ag'), $db->quoteName('ag.id') . ' = ' . $db->quoteName('a.access'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'));
|
||||
|
||||
// Join over the associations.
|
||||
if (Associations::isEnabled()) {
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
|
||||
->from($db->quoteName('#__associations', 'asso1'))
|
||||
->join('INNER', $db->quoteName('#__associations', 'asso2'), $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
|
||||
$db->quoteName('asso1.context') . ' = ' . $db->quote('com_newsfeeds.item'),
|
||||
]
|
||||
);
|
||||
|
||||
$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
|
||||
}
|
||||
|
||||
// Filter by access level.
|
||||
if ($access = (int) $this->getState('filter.access')) {
|
||||
$query->where($db->quoteName('a.access') . ' = :access')
|
||||
->bind(':access', $access, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->whereIn($db->quoteName('a.access'), $user->getAuthorisedViewLevels());
|
||||
}
|
||||
|
||||
// Filter by published state.
|
||||
$published = (string) $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$published = (int) $published;
|
||||
$query->where($db->quoteName('a.published') . ' = :published')
|
||||
->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where($db->quoteName('a.published') . ' IN (0, 1)');
|
||||
}
|
||||
|
||||
// Filter by category.
|
||||
$categoryId = $this->getState('filter.category_id');
|
||||
|
||||
if (is_numeric($categoryId)) {
|
||||
$categoryId = (int) $categoryId;
|
||||
$query->where($db->quoteName('a.catid') . ' = :categoryId')
|
||||
->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter on the level.
|
||||
if ($level = (int) $this->getState('filter.level')) {
|
||||
$query->where($db->quoteName('c.level') . ' <= :level')
|
||||
->bind(':level', $level, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
if ($search = $this->getState('filter.search')) {
|
||||
if (stripos($search, 'id:') === 0) {
|
||||
$search = (int) substr($search, 3);
|
||||
$query->where($db->quoteName('a.id') . ' = :search')
|
||||
->bind(':search', $search, ParameterType::INTEGER);
|
||||
} else {
|
||||
$search = '%' . str_replace(' ', '%', trim($search)) . '%';
|
||||
$query->where('(' . $db->quoteName('a.name') . ' LIKE :search1 OR ' . $db->quoteName('a.alias') . ' LIKE :search2)')
|
||||
->bind([':search1', ':search2'], $search);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on the language.
|
||||
if ($language = $this->getState('filter.language')) {
|
||||
$query->where($db->quoteName('a.language') . ' = :language')
|
||||
->bind(':language', $language);
|
||||
}
|
||||
|
||||
// Filter by a single or group of tags.
|
||||
$tag = $this->getState('filter.tag');
|
||||
|
||||
// Run simplified query when filtering by one tag.
|
||||
if (\is_array($tag) && \count($tag) === 1) {
|
||||
$tag = $tag[0];
|
||||
}
|
||||
|
||||
if ($tag && \is_array($tag)) {
|
||||
$tag = ArrayHelper::toInteger($tag);
|
||||
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select('DISTINCT ' . $db->quoteName('content_item_id'))
|
||||
->from($db->quoteName('#__contentitem_tag_map'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('tag_id') . ' IN (' . implode(',', $query->bindArray($tag)) . ')',
|
||||
$db->quoteName('type_alias') . ' = ' . $db->quote('com_newsfeeds.newsfeed'),
|
||||
]
|
||||
);
|
||||
|
||||
$query->join(
|
||||
'INNER',
|
||||
'(' . $subQuery . ') AS ' . $db->quoteName('tagmap'),
|
||||
$db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
);
|
||||
} elseif ($tag = (int) $tag) {
|
||||
$query->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__contentitem_tag_map', 'tagmap'),
|
||||
$db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
)
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('tagmap.tag_id') . ' = :tag',
|
||||
$db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_newsfeeds.newsfeed'),
|
||||
]
|
||||
)
|
||||
->bind(':tag', $tag, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$orderCol = $this->state->get('list.ordering', 'a.name');
|
||||
$orderDirn = $this->state->get('list.direction', 'ASC');
|
||||
|
||||
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
|
||||
$ordering = [
|
||||
$db->quoteName('c.title') . ' ' . $db->escape($orderDirn),
|
||||
$db->quoteName('a.ordering') . ' ' . $db->escape($orderDirn),
|
||||
];
|
||||
} else {
|
||||
$ordering = $db->escape($orderCol) . ' ' . $db->escape($orderDirn);
|
||||
}
|
||||
|
||||
$query->order($ordering);
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Service\HTML;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Utility class for creating HTML Grids.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class AdministratorService
|
||||
{
|
||||
/**
|
||||
* Get the associated language flags
|
||||
*
|
||||
* @param int $newsfeedid The item id to search associations
|
||||
*
|
||||
* @return string The language HTML
|
||||
*
|
||||
* @throws \Exception Throws a 500 Exception on Database failure
|
||||
*/
|
||||
public function association($newsfeedid)
|
||||
{
|
||||
// Defaults
|
||||
$html = '';
|
||||
|
||||
// Get the associations
|
||||
if ($associations = Associations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $newsfeedid)) {
|
||||
foreach ($associations as $tag => $associated) {
|
||||
$associations[$tag] = (int) $associated->id;
|
||||
}
|
||||
|
||||
// Get the associated newsfeed items
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('c.id'),
|
||||
$db->quoteName('c.name', 'title'),
|
||||
$db->quoteName('cat.title', 'category_title'),
|
||||
$db->quoteName('l.sef', 'lang_sef'),
|
||||
$db->quoteName('l.lang_code'),
|
||||
$db->quoteName('l.image'),
|
||||
$db->quoteName('l.title', 'language_title'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__newsfeeds', 'c'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'cat'), $db->quoteName('cat.id') . ' = ' . $db->quoteName('c.catid'))
|
||||
->join('LEFT', $db->quoteName('#__languages', 'l'), $db->quoteName('c.language') . ' = ' . $db->quoteName('l.lang_code'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('c.id') . ' IN (' . implode(',', $query->bindArray(array_values($associations))) . ')',
|
||||
$db->quoteName('c.id') . ' != :id',
|
||||
]
|
||||
)
|
||||
->bind(':id', $newsfeedid, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$items = $db->loadObjectList('id');
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \Exception($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
if ($items) {
|
||||
$languages = LanguageHelper::getContentLanguages([0, 1]);
|
||||
$content_languages = array_column($languages, 'lang_code');
|
||||
|
||||
foreach ($items as &$item) {
|
||||
if (\in_array($item->lang_code, $content_languages)) {
|
||||
$text = $item->lang_code;
|
||||
$url = Route::_('index.php?option=com_newsfeeds&task=newsfeed.edit&id=' . (int) $item->id);
|
||||
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
|
||||
. htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br>' . Text::sprintf('JCATEGORY_SPRINTF', $item->category_title);
|
||||
$classes = 'badge bg-secondary';
|
||||
|
||||
$item->link = '<a href="' . $url . '" class="' . $classes . '">' . $text . '</a>'
|
||||
. '<div role="tooltip" id="tip-' . (int) $newsfeedid . '-' . (int) $item->id . '">' . $tooltip . '</div>';
|
||||
} else {
|
||||
// Display warning if Content Language is trashed or deleted
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_ASSOCIATIONS_CONTENTLANGUAGE_WARNING', $item->lang_code), 'warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$html = LayoutHelper::render('joomla.content.associations', $items);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Tag\TaggableTableInterface;
|
||||
use Joomla\CMS\Tag\TaggableTableTrait;
|
||||
use Joomla\CMS\User\CurrentUserInterface;
|
||||
use Joomla\CMS\User\CurrentUserTrait;
|
||||
use Joomla\CMS\Versioning\VersionableTableInterface;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Newsfeed Table class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class NewsfeedTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface
|
||||
{
|
||||
use TaggableTableTrait;
|
||||
use CurrentUserTrait;
|
||||
|
||||
/**
|
||||
* Indicates that columns fully support the NULL value in the database
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
/**
|
||||
* Ensure the params, metadata and images are json encoded in the bind method
|
||||
*
|
||||
* @var array
|
||||
* @since 3.3
|
||||
*/
|
||||
protected $_jsonEncode = ['params', 'metadata', 'images'];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
* @param ?DispatcherInterface $dispatcher Event dispatcher for this table
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->typeAlias = 'com_newsfeeds.newsfeed';
|
||||
parent::__construct('#__newsfeeds', 'id', $db, $dispatcher);
|
||||
$this->setColumnAlias('title', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check method to ensure data integrity.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
try {
|
||||
parent::check();
|
||||
} catch (\Exception $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for valid name.
|
||||
if (trim($this->name) == '') {
|
||||
$this->setError(Text::_('COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = $this->name;
|
||||
}
|
||||
|
||||
$this->alias = ApplicationHelper::stringURLSafe($this->alias, $this->language);
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '') {
|
||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
// Check for a valid category.
|
||||
if (!$this->catid = (int) $this->catid) {
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_CATEGORY_REQUIRED'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
|
||||
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clean up description -- eliminate quotes and <> brackets
|
||||
if (!empty($this->metadesc)) {
|
||||
// Only process if not empty
|
||||
$bad_characters = ["\"", '<', '>'];
|
||||
$this->metadesc = StringHelper::str_ireplace($bad_characters, '', $this->metadesc);
|
||||
}
|
||||
|
||||
if (!$this->hits) {
|
||||
$this->hits = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden \Joomla\CMS\Table\Table::store to set modified data.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function store($updateNulls = true)
|
||||
{
|
||||
$date = Factory::getDate();
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Set created date if not set.
|
||||
if (!(int) $this->created) {
|
||||
$this->created = $date->toSql();
|
||||
}
|
||||
|
||||
if ($this->id) {
|
||||
// Existing item
|
||||
$this->modified_by = $user->get('id');
|
||||
$this->modified = $date->toSql();
|
||||
} else {
|
||||
// Field created_by can be set by the user, so we don't touch it if it's set.
|
||||
if (empty($this->created_by)) {
|
||||
$this->created_by = $user->get('id');
|
||||
}
|
||||
|
||||
if (!(int) $this->modified) {
|
||||
$this->modified = $this->created;
|
||||
}
|
||||
|
||||
if (empty($this->modified_by)) {
|
||||
$this->modified_by = $this->created_by;
|
||||
}
|
||||
}
|
||||
|
||||
// Set publish_up, publish_down to null if not set
|
||||
if (!$this->publish_up) {
|
||||
$this->publish_up = null;
|
||||
}
|
||||
|
||||
if (!$this->publish_down) {
|
||||
$this->publish_down = null;
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = Table::getInstance('NewsfeedTable', __NAMESPACE__ . '\\', ['dbo' => $this->_db]);
|
||||
|
||||
if ($table->load(['alias' => $this->alias, 'catid' => $this->catid]) && ($table->id != $this->id || $this->id == 0)) {
|
||||
// Is the existing newsfeed trashed?
|
||||
$this->setError(Text::_('COM_NEWSFEEDS_ERROR_UNIQUE_ALIAS'));
|
||||
|
||||
if ($table->published === -2) {
|
||||
$this->setError(Text::_('COM_NEWSFEEDS_ERROR_UNIQUE_ALIAS_TRASHED'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save links as punycode.
|
||||
$this->link = PunycodeHelper::urlToPunycode($this->link);
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type alias for the history table
|
||||
*
|
||||
* @return string The alias as described above
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getTypeAlias()
|
||||
{
|
||||
return $this->typeAlias;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\View\Newsfeed;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to edit a newsfeed.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The item object for the newsfeed
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* The form object for the newsfeed
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* The model state of the newsfeed
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->item = $this->get('Item');
|
||||
$this->form = $this->get('Form');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// If we are forcing a language in modal (used for associations).
|
||||
if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->getInput()->get('forcedLanguage', '', 'cmd')) {
|
||||
// Set the language field to the forcedLanguage and disable changing it.
|
||||
$this->form->setValue('language', null, $forcedLanguage);
|
||||
$this->form->setFieldAttribute('language', 'readonly', 'true');
|
||||
|
||||
// Only allow to select categories with All language or with the forced language.
|
||||
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
|
||||
|
||||
// Only allow to select tags with All language or with the forced language.
|
||||
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$isNew = ($this->item->id == 0);
|
||||
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id'));
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
// Since we don't track these assets at the item level, use the category id.
|
||||
$canDo = ContentHelper::getActions('com_newsfeeds', 'category', $this->item->catid);
|
||||
|
||||
$title = $isNew ? Text::_('COM_NEWSFEEDS_MANAGER_NEWSFEED_NEW') : Text::_('COM_NEWSFEEDS_MANAGER_NEWSFEED_EDIT');
|
||||
ToolbarHelper::title($title, 'rss newsfeeds');
|
||||
|
||||
// If not checked out, can save the item.
|
||||
if (!$checkedOut && ($canDo->get('core.edit') || \count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0)) {
|
||||
$toolbar->apply('newsfeed.apply');
|
||||
}
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($checkedOut, $canDo, $user, $isNew) {
|
||||
// If not checked out, can save the item.
|
||||
if (!$checkedOut && ($canDo->get('core.edit') || \count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0)) {
|
||||
$childBar->save('newsfeed.save');
|
||||
}
|
||||
|
||||
if (!$checkedOut && \count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0) {
|
||||
$childBar->save2new('newsfeed.save2new');
|
||||
}
|
||||
|
||||
// If an existing item, can save to a copy.
|
||||
if (!$isNew && $canDo->get('core.create')) {
|
||||
$childBar->save2copy('newsfeed.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (empty($this->item->id)) {
|
||||
$toolbar->cancel('newsfeed.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
$toolbar->cancel('newsfeed.cancel');
|
||||
|
||||
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) {
|
||||
$toolbar->versions('com_newsfeeds.newsfeed', $this->item->id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isNew && Associations::isEnabled() && ComponentHelper::isEnabled('com_associations')) {
|
||||
$toolbar->standardButton('associations', 'JTOOLBAR_ASSOCIATIONS', 'newsfeed.editAssociations')
|
||||
->icon('icon-contract')
|
||||
->listCheck(false);
|
||||
}
|
||||
|
||||
$toolbar->divider();
|
||||
$toolbar->help('News_Feeds:_Edit');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Newsfeeds\Administrator\View\Newsfeeds;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Toolbar\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of newsfeeds.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The list of newsfeeds
|
||||
*
|
||||
* @var CMSObject
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var \Joomla\CMS\Pagination\Pagination
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Is this view an Empty State
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $isEmptyState = false;
|
||||
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $activeFilters;
|
||||
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
|
||||
$this->setLayout('emptystate');
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// We don't need toolbar in the modal layout.
|
||||
if ($this->getLayout() !== 'modal') {
|
||||
$this->addToolbar();
|
||||
|
||||
// We do not need to filter by language when multilingual is disabled
|
||||
if (!Multilanguage::isEnabled()) {
|
||||
unset($this->activeFilters['language']);
|
||||
$this->filterForm->removeField('language', 'filter');
|
||||
}
|
||||
} 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 = Factory::getApplication()->getInput()->get('forcedLanguage', '', 'CMD')) {
|
||||
// If the language is forced we can't allow to select the language, so transform the language selector filter into a 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
$state = $this->get('State');
|
||||
$canDo = ContentHelper::getActions('com_newsfeeds', 'category', $state->get('filter.category_id'));
|
||||
$user = $this->getCurrentUser();
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_NEWSFEEDS_MANAGER_NEWSFEEDS'), 'rss newsfeeds');
|
||||
|
||||
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0) {
|
||||
$toolbar->addNew('newsfeed.add');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $user->authorise('core.admin'))) {
|
||||
/** @var DropdownButton $dropdown */
|
||||
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
|
||||
->toggleSplit(false)
|
||||
->icon('icon-ellipsis-h')
|
||||
->buttonClass('btn btn-action')
|
||||
->listCheck(true);
|
||||
|
||||
$childBar = $dropdown->getChildToolbar();
|
||||
|
||||
$childBar->publish('newsfeeds.publish')->listCheck(true);
|
||||
$childBar->unpublish('newsfeeds.unpublish')->listCheck(true);
|
||||
$childBar->archive('newsfeeds.archive')->listCheck(true);
|
||||
|
||||
if ($user->authorise('core.admin')) {
|
||||
$childBar->checkin('newsfeeds.checkin')->listCheck(true);
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') != -2) {
|
||||
$childBar->trash('newsfeeds.trash')->listCheck(true);
|
||||
}
|
||||
|
||||
// Add a batch button
|
||||
if (
|
||||
$user->authorise('core.create', 'com_newsfeeds')
|
||||
&& $user->authorise('core.edit', 'com_newsfeeds')
|
||||
&& $user->authorise('core.edit.state', 'com_newsfeeds')
|
||||
) {
|
||||
$childBar->popupButton('batch', 'JTOOLBAR_BATCH')
|
||||
->selector('collapseModal')
|
||||
->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $state->get('filter.published') == -2 && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('newsfeeds.delete', 'JTOOLBAR_EMPTY_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
if ($user->authorise('core.admin', 'com_newsfeeds') || $user->authorise('core.options', 'com_newsfeeds')) {
|
||||
$toolbar->preferences('com_newsfeeds');
|
||||
}
|
||||
|
||||
$toolbar->help('News_Feeds');
|
||||
}
|
||||
}
|
||||
120
administrator/components/com_newsfeeds/tmpl/newsfeed/edit.php
Normal file
120
administrator/components/com_newsfeeds/tmpl/newsfeed/edit.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate');
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
|
||||
$this->ignore_fieldsets = ['images', 'jbasic', 'jmetadata', 'item_associations'];
|
||||
$this->useCoreUI = true;
|
||||
|
||||
// In case of modal
|
||||
$isModal = $input->get('layout') === 'modal';
|
||||
$layout = $isModal ? 'modal' : 'edit';
|
||||
$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
|
||||
?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_newsfeeds&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="newsfeed-form" aria-label="<?php echo Text::_('COM_NEWSFEEDS_FORM_TITLE_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>" class="form-validate">
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>
|
||||
|
||||
<div class="main-card">
|
||||
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', empty($this->item->id) ? Text::_('COM_NEWSFEEDS_NEW_NEWSFEED') : Text::_('COM_NEWSFEEDS_EDIT_NEWSFEED')); ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
<div class="form-vertical">
|
||||
<?php echo $this->form->renderField('link'); ?>
|
||||
<?php echo $this->form->renderField('description'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'images', Text::_('JGLOBAL_FIELDSET_OPTIONS')); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<fieldset id="fieldset-image" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS'); ?></legend>
|
||||
<div>
|
||||
<?php foreach ($this->form->getGroup('images') as $field) : ?>
|
||||
<?php echo $field->renderField(); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<?php echo $this->loadTemplate('display'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('JGLOBAL_FIELDSET_PUBLISHING')); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<fieldset id="fieldset-publishingdata" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_PUBLISHING'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.publishingdata', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<fieldset id="fieldset-metadata" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_METADATA_OPTIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.metadata', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php if (!$isModal && $assoc) : ?>
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'associations', Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
|
||||
<fieldset id="fieldset-associations" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.associations', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
<?php elseif ($isModal && $assoc) : ?>
|
||||
<div class="hidden"><?php echo LayoutHelper::render('joomla.edit.associations', $this); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$this->fieldset = 'jbasic';
|
||||
?>
|
||||
|
||||
<fieldset id="fieldset-display" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_DISPLAY_OPTIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.fieldset', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
?>
|
||||
<div class="container-popup">
|
||||
<?php $this->setLayout('edit'); ?>
|
||||
<?php echo $this->loadTemplate(); ?>
|
||||
</div>
|
||||
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('table.columns')
|
||||
->useScript('multiselect');
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$saveOrder = $listOrder == 'a.ordering';
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($saveOrder && !empty($this->items)) {
|
||||
$saveOrderingUrl = 'index.php?option=com_newsfeeds&task=newsfeeds.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
HTMLHelper::_('draggablelist.draggable');
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_newsfeeds&view=newsfeeds'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table" id="newsfeedList">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_NEWSFEEDS_TABLE_CAPTION'); ?>,
|
||||
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
|
||||
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('grid.checkall'); ?>
|
||||
</td>
|
||||
<th scope="col" class="w-1 text-center d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-5 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="title">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_NEWSFEEDS_NUM_ARTICLES_HEADING', 'numarticles', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_NEWSFEEDS_CACHE_TIME_HEADING', 'a.cache_time', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if ($assoc) : ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_NEWSFEEDS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th scope="col" class="w-5 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody <?php if ($saveOrder) :
|
||||
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true"<?php
|
||||
endif; ?>>
|
||||
<?php foreach ($this->items as $i => $item) :
|
||||
$ordering = ($listOrder == 'a.ordering');
|
||||
$canCreate = $user->authorise('core.create', 'com_newsfeeds.category.' . $item->catid);
|
||||
$canEdit = $user->authorise('core.edit', 'com_newsfeeds.category.' . $item->catid);
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out);
|
||||
$canEditOwn = $user->authorise('core.edit.own', 'com_newsfeeds.category.' . $item->catid) && $item->created_by == $user->id;
|
||||
$canChange = $user->authorise('core.edit.state', 'com_newsfeeds.category.' . $item->catid) && $canCheckin;
|
||||
?>
|
||||
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
|
||||
</td>
|
||||
<td class="text-center d-none d-md-table-cell">
|
||||
<?php
|
||||
$iconClass = '';
|
||||
if (!$canChange) {
|
||||
$iconClass = ' inactive';
|
||||
} elseif (!$saveOrder) {
|
||||
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
|
||||
}
|
||||
?>
|
||||
<span class="sortable-handler<?php echo $iconClass ?>">
|
||||
<span class="icon-ellipsis-v" aria-hidden="true"></span>
|
||||
</span>
|
||||
<?php if ($canChange && $saveOrder) : ?>
|
||||
<input type="text" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order hidden">
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'newsfeeds.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
|
||||
</td>
|
||||
<th scope="row" class="has-context">
|
||||
<div>
|
||||
<?php if ($item->checked_out) : ?>
|
||||
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'newsfeeds.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit || $canEditOwn) : ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_newsfeeds&task=newsfeed.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->name); ?>">
|
||||
<?php echo $this->escape($item->name); ?></a>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($item->name); ?>
|
||||
<?php endif; ?>
|
||||
<div class="small">
|
||||
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
|
||||
</div>
|
||||
<div class="small">
|
||||
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $this->escape($item->access_level); ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo (int) $item->numarticles; ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo (int) $item->cache_time; ?>
|
||||
</td>
|
||||
<?php if ($assoc) : ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php if ($item->association) : ?>
|
||||
<?php echo HTMLHelper::_('newsfeedsadministrator.association', $item->id); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo (int) $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php // load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php // Load the batch processing form if user is allowed ?>
|
||||
<?php
|
||||
if (
|
||||
$user->authorise('core.create', 'com_newsfeeds')
|
||||
&& $user->authorise('core.edit', 'com_newsfeeds')
|
||||
&& $user->authorise('core.edit.state', 'com_newsfeeds')
|
||||
) : ?>
|
||||
<?php echo HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'collapseModal',
|
||||
[
|
||||
'title' => Text::_('COM_NEWSFEEDS_BATCH_OPTIONS'),
|
||||
'footer' => $this->loadTemplate('batch_footer'),
|
||||
],
|
||||
$this->loadTemplate('batch_body')
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="boxchecked" value="0">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$published = (int) $this->state->get('filter.published');
|
||||
?>
|
||||
|
||||
<div class="p-3">
|
||||
<div class="row">
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.language', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.access', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php if ($published >= 0) : ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.item', ['extension' => 'com_newsfeeds']); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.tag', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-tag-id').value=''" data-bs-dismiss="modal">
|
||||
<?php echo Text::_('JCANCEL'); ?>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('newsfeed.batch');return false;">
|
||||
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
|
||||
</button>
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$displayData = [
|
||||
'textPrefix' => 'COM_NEWSFEEDS',
|
||||
'formURL' => 'index.php?option=com_newsfeeds&view=newsfeeds',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:News_Feeds',
|
||||
'icon' => 'icon-rss newsfeeds',
|
||||
];
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ($user->authorise('core.create', 'com_newsfeeds') || count($user->getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0) {
|
||||
$displayData['createURL'] = 'index.php?option=com_newsfeeds&task=newsfeed.add';
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
||||
134
administrator/components/com_newsfeeds/tmpl/newsfeeds/modal.php
Normal file
134
administrator/components/com_newsfeeds/tmpl/newsfeeds/modal.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_newsfeeds
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('core');
|
||||
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$function = $app->getInput()->getCmd('function', 'jSelectNewsfeed');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$multilang = Multilanguage::isEnabled();
|
||||
?>
|
||||
<div class="container-popup">
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_newsfeeds&view=newsfeeds&layout=modal&tmpl=component&function=' . $function); ?>" method="post" name="adminForm" id="adminForm">
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table table-sm">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_NEWSFEEDS_TABLE_CAPTION'); ?>,
|
||||
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
|
||||
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="title">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-15 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if ($multilang) : ?>
|
||||
<th scope="col" class="w-15 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th scope="col" class="w-1 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$iconStates = [
|
||||
-2 => 'icon-trash',
|
||||
0 => 'icon-times',
|
||||
1 => 'icon-check',
|
||||
2 => 'icon-folder',
|
||||
];
|
||||
?>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php if ($item->language && $multilang) {
|
||||
$tag = strlen($item->language);
|
||||
if ($tag == 5) {
|
||||
$lang = substr($item->language, 0, 2);
|
||||
} elseif ($tag == 6) {
|
||||
$lang = substr($item->language, 0, 3);
|
||||
} else {
|
||||
$lang = '';
|
||||
}
|
||||
} elseif (!$multilang) {
|
||||
$lang = '';
|
||||
}
|
||||
?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td class="text-center">
|
||||
<span class="tbody-icon">
|
||||
<span class="<?php echo $iconStates[$this->escape($item->published)]; ?>" aria-hidden="true"></span>
|
||||
</span>
|
||||
</td>
|
||||
<th scope="row">
|
||||
<a href="javascript:void(0)" onclick="if (window.parent) window.parent.<?php echo $this->escape($function); ?>('<?php echo $item->id; ?>', '<?php echo $this->escape(addslashes($item->name)); ?>', '<?php echo $this->escape($item->catid); ?>', null, '<?php echo $this->escape(RouteHelper::getNewsfeedRoute($item->id, $item->catid, $item->language)); ?>', '<?php echo $this->escape($lang); ?>', null);">
|
||||
<?php echo $this->escape($item->name); ?></a>
|
||||
<div class="small">
|
||||
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
|
||||
</div>
|
||||
</th>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $this->escape($item->access_level); ?>
|
||||
</td>
|
||||
<?php if ($multilang) : ?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo (int) $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php // load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="boxchecked" value="0">
|
||||
<input type="hidden" name="forcedLanguage" value="<?php echo $app->getInput()->get('forcedLanguage', '', 'CMD'); ?>">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user