first commit
This commit is contained in:
61
administrator/components/com_banners/access.xml
Normal file
61
administrator/components/com_banners/access.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<access component="com_banners">
|
||||
<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"
|
||||
/>
|
||||
|
||||
</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"
|
||||
/>
|
||||
</section>
|
||||
</access>
|
||||
89
administrator/components/com_banners/banners.xml
Normal file
89
administrator/components/com_banners/banners.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>com_banners</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_BANNERS_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Component\Banners</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>src</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB/com_banners.ini</language>
|
||||
</languages>
|
||||
<media destination="com_banners" folder="media">
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
|
||||
<administration>
|
||||
<menu img="class:bookmark">com_banners</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_banners"
|
||||
view="banners"
|
||||
img="class:banners"
|
||||
alt="Banners/Banners"
|
||||
>
|
||||
com_banners_banners
|
||||
</menu>
|
||||
<menu
|
||||
link="option=com_categories&extension=com_banners"
|
||||
view="categories"
|
||||
img="class:banners-cat"
|
||||
alt="Banners/Categories"
|
||||
>
|
||||
com_banners_categories
|
||||
</menu>
|
||||
<menu
|
||||
link="option=com_banners&view=clients"
|
||||
view="clients"
|
||||
img="class:banners-clients"
|
||||
alt="Banners/Clients"
|
||||
>
|
||||
com_banners_clients
|
||||
</menu>
|
||||
<menu
|
||||
link="option=com_banners&view=tracks"
|
||||
view="tracks"
|
||||
img="class:banners-tracks"
|
||||
alt="Banners/Tracks"
|
||||
>
|
||||
com_banners_tracks
|
||||
</menu>
|
||||
</submenu>
|
||||
<files folder="admin">
|
||||
<filename>access.xml</filename>
|
||||
<filename>banners.xml</filename>
|
||||
<filename>config.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_banners.ini</language>
|
||||
<language tag="en-GB">language/en-GB/com_banners.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
||||
112
administrator/components/com_banners/config.xml
Normal file
112
administrator/components/com_banners/config.xml
Normal file
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<help key="Banners:_Options"/>
|
||||
<inlinehelp button="show"/>
|
||||
<fieldset
|
||||
name="component"
|
||||
label="COM_BANNERS_FIELDSET_CONFIG_CLIENT_OPTIONS_LABEL"
|
||||
description="COM_BANNERS_FIELDSET_CONFIG_CLIENT_OPTIONS_DESC"
|
||||
>
|
||||
|
||||
<field
|
||||
name="purchase_type"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL"
|
||||
default="1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
|
||||
<option value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
|
||||
<option value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
|
||||
<option value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
|
||||
<option value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_impressions"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_robots_impressions"
|
||||
type="radio"
|
||||
label="COM_BANNERS_FIELD_TRACKROBOTSIMPRESSION_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_clicks"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="metakey_prefix"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_METAKEYWORDPREFIX_LABEL"
|
||||
description="COM_BANNERS_FIELD_METAKEYWORDPREFIX_DESC"
|
||||
default=""
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="banners"
|
||||
label="COM_BANNERS_FIELDSET_CONFIG_BANNER_OPTIONS_LABEL"
|
||||
description="COM_BANNERS_FIELDSET_CONFIG_BANNER_OPTIONS_DESC"
|
||||
>
|
||||
|
||||
<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"
|
||||
filter="integer"
|
||||
default="10"
|
||||
showon="save_history:1"
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="permissions"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
>
|
||||
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
component="com_banners"
|
||||
section="component"
|
||||
/>
|
||||
|
||||
</fieldset>
|
||||
</config>
|
||||
342
administrator/components/com_banners/forms/banner.xml
Normal file
342
administrator/components/com_banners/forms/banner.xml
Normal file
@ -0,0 +1,342 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Banners\Administrator\Field">
|
||||
<fieldset name="details">
|
||||
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
readonly="true"
|
||||
class="readonly"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_NAME_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="alias"
|
||||
type="text"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
hint="JFIELD_ALIAS_PLACEHOLDER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="catid"
|
||||
type="categoryedit"
|
||||
label="JCATEGORY"
|
||||
extension="com_banners"
|
||||
required="true"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
default=""
|
||||
class="advancedSelect"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
class="form-select-color-state"
|
||||
default="1"
|
||||
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="ordering"
|
||||
type="ordering"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
table="#__banners"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="version_note"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
|
||||
maxlength="255"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="description"
|
||||
type="editor"
|
||||
label="JGLOBAL_DESCRIPTION"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
buttons="true"
|
||||
hide="readmore,pagebreak,module,article,contact,menu"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="type"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_TYPE_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">COM_BANNERS_FIELD_VALUE_IMAGE</option>
|
||||
<option value="1">COM_BANNERS_FIELD_VALUE_CUSTOM</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="custombannercode"
|
||||
type="textarea"
|
||||
label="COM_BANNERS_FIELD_CUSTOMCODE_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
filter="raw"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="clickurl"
|
||||
type="url"
|
||||
label="COM_BANNERS_FIELD_CLICKURL_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="publish" label="COM_BANNERS_GROUP_LABEL_PUBLISHING_DETAILS">
|
||||
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_BANNERS_FIELD_CREATED_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="COM_BANNERS_FIELD_CREATED_BY_LABEL"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by_alias"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_CREATED_BY_ALIAS_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="modified"
|
||||
type="calendar"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
translateformat="true"
|
||||
showtime="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_BANNERS_FIELD_VERSION_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_up"
|
||||
type="calendar"
|
||||
label="COM_BANNERS_FIELD_PUBLISH_UP_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_down"
|
||||
type="calendar"
|
||||
label="COM_BANNERS_FIELD_PUBLISH_DOWN_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="bannerdetails" label="COM_BANNERS_GROUP_LABEL_BANNER_DETAILS">
|
||||
|
||||
<field
|
||||
name="sticky"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_BANNERS_FIELD_STICKY_LABEL"
|
||||
description="COM_BANNERS_FIELD_STICKY_DESC"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="otherparams">
|
||||
<field
|
||||
name="imptotal"
|
||||
type="imptotal"
|
||||
label="COM_BANNERS_FIELD_IMPTOTAL_LABEL"
|
||||
default="0"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="impmade"
|
||||
type="impmade"
|
||||
label="COM_BANNERS_FIELD_IMPMADE_LABEL"
|
||||
default="0"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="clicks"
|
||||
type="clicks"
|
||||
label="COM_BANNERS_FIELD_CLICKS_LABEL"
|
||||
default="0"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cid"
|
||||
type="bannerclient"
|
||||
label="COM_BANNERS_FIELD_CLIENT_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="purchase_type"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT</option>
|
||||
<option value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
|
||||
<option value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
|
||||
<option value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
|
||||
<option value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
|
||||
<option value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_impressions"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_clicks"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
|
||||
<field
|
||||
name="metakey"
|
||||
type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="own_prefix"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_BANNERS_FIELD_BANNEROWNPREFIX_LABEL"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="metakey_prefix"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_METAKEYWORDPREFIX_LABEL"
|
||||
description="COM_BANNERS_FIELD_METAKEYWORDPREFIX_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fields name="params" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
|
||||
<fieldset name="image">
|
||||
<field
|
||||
name="imageurl"
|
||||
type="media"
|
||||
label="COM_BANNERS_FIELD_IMAGE_LABEL"
|
||||
directory="banners"
|
||||
hide_none="1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="width"
|
||||
type="number"
|
||||
label="COM_BANNERS_FIELD_WIDTH_LABEL"
|
||||
class="validate-numeric"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="height"
|
||||
type="number"
|
||||
label="COM_BANNERS_FIELD_HEIGHT_LABEL"
|
||||
class="validate-numeric"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="alt"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_ALT_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<fieldset name="custom">
|
||||
<field
|
||||
name="bannercode"
|
||||
type="textarea"
|
||||
label="COM_BANNERS_FIELD_CUSTOMCODE_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
filter="raw"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
5
administrator/components/com_banners/forms/category.xml
Normal file
5
administrator/components/com_banners/forms/category.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<help key="Banners:_New_or_Edit_Category" />
|
||||
<listhelp key="Banners:_Categories" />
|
||||
</form>
|
||||
133
administrator/components/com_banners/forms/client.xml
Normal file
133
administrator/components/com_banners/forms/client.xml
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Banners\Administrator\Field">
|
||||
<fieldset name="details">
|
||||
<field
|
||||
name="id"
|
||||
type="number"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
readonly="true"
|
||||
class="readonly"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_NAME_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="contact"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_CONTACT_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="email"
|
||||
type="email"
|
||||
label="COM_BANNERS_FIELD_EMAIL_LABEL"
|
||||
validate="email"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
class="form-select-color-state"
|
||||
default="1"
|
||||
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="version_note"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
|
||||
maxlength="255"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="purchase_type"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
|
||||
<option value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
|
||||
<option value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
|
||||
<option value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
|
||||
<option value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_impressions"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="track_clicks"
|
||||
type="list"
|
||||
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="-1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
<field
|
||||
name="metakey"
|
||||
type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="own_prefix"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_BANNERS_FIELD_CLIENTOWNPREFIX_LABEL"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="metakey_prefix"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_CLIENT_METAKEYWORDPREFIX_LABEL"
|
||||
description="COM_BANNERS_FIELD_CLIENT_METAKEYWORDPREFIX_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="extra" label="COM_BANNERS_EXTRA">
|
||||
<field
|
||||
name="extrainfo"
|
||||
type="textarea"
|
||||
label="COM_BANNERS_FIELD_EXTRAINFO_LABEL"
|
||||
rows="5"
|
||||
cols="80"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
||||
24
administrator/components/com_banners/forms/download.xml
Normal file
24
administrator/components/com_banners/forms/download.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
|
||||
<fieldset name="details">
|
||||
|
||||
<field
|
||||
name="compressed"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_BANNERS_FIELD_COMPRESSED_LABEL"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="basename"
|
||||
type="text"
|
||||
label="COM_BANNERS_FIELD_BASENAME_LABEL"
|
||||
description="COM_BANNERS_FIELD_BASENAME_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
||||
107
administrator/components/com_banners/forms/filter_banners.xml
Normal file
107
administrator/components/com_banners/forms/filter_banners.xml
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Banners\Administrator\Field">
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_BANNERS_BANNERS_FILTER_SEARCH_LABEL"
|
||||
description="COM_BANNERS_BANNERS_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_banners"
|
||||
class="js-select-submit-on-change"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_CATEGORY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="client_id"
|
||||
type="bannerclient"
|
||||
label="COM_BANNERS_HEADING_CLIENT"
|
||||
extension="com_content"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">COM_BANNERS_SELECT_CLIENT</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="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"
|
||||
statuses="*,0,1,2,-2"
|
||||
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.state ASC">JSTATUS_ASC</option>
|
||||
<option value="a.state DESC">JSTATUS_DESC</option>
|
||||
<option value="a.name ASC">JGLOBAL_NAME_ASC</option>
|
||||
<option value="a.name DESC">JGLOBAL_NAME_DESC</option>
|
||||
<option value="category_title ASC">JCATEGORY_ASC</option>
|
||||
<option value="category_title DESC">JCATEGORY_DESC</option>
|
||||
<option value="a.sticky ASC">COM_BANNERS_HEADING_STICKY_ASC</option>
|
||||
<option value="a.sticky DESC">COM_BANNERS_HEADING_STICKY_DESC</option>
|
||||
<option value="client_name ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
|
||||
<option value="client_name DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
|
||||
<option value="impmade ASC">COM_BANNERS_HEADING_IMPRESSIONS_ASC</option>
|
||||
<option value="impmade DESC">COM_BANNERS_HEADING_IMPRESSIONS_DESC</option>
|
||||
<option value="clicks ASC">COM_BANNERS_HEADING_CLICKS_ASC</option>
|
||||
<option value="clicks DESC">COM_BANNERS_HEADING_CLICKS_DESC</option>
|
||||
<option value="a.language ASC" requires="multilanguage">JGRID_HEADING_LANGUAGE_ASC</option>
|
||||
<option value="a.language 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>
|
||||
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_BANNERS_CLIENTS_FILTER_SEARCH_LABEL"
|
||||
description="COM_BANNERS_CLIENTS_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="status"
|
||||
label="JSTATUS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="purchase_type"
|
||||
type="list"
|
||||
label="COM_BANNERS_HEADING_TYPE"
|
||||
default="0"
|
||||
class="js-select-submit-on-change"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_BANNERS_SELECT_TYPE</option>
|
||||
<option value="1">COM_BANNERS_FIELD_VALUE_UNLIMITED</option>
|
||||
<option value="2">COM_BANNERS_FIELD_VALUE_YEARLY</option>
|
||||
<option value="3">COM_BANNERS_FIELD_VALUE_MONTHLY</option>
|
||||
<option value="4">COM_BANNERS_FIELD_VALUE_WEEKLY</option>
|
||||
<option value="5">COM_BANNERS_FIELD_VALUE_DAILY</option>
|
||||
</field>
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
statuses="*,0,1,2,-2"
|
||||
class="js-select-submit-on-change"
|
||||
default="a.name ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="a.state ASC">JSTATUS_ASC</option>
|
||||
<option value="a.state DESC">JSTATUS_DESC</option>
|
||||
<option value="a.name ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
|
||||
<option value="a.name DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
|
||||
<option value="a.contact ASC">COM_BANNERS_HEADING_CONTACT_ASC</option>
|
||||
<option value="a.contact DESC">COM_BANNERS_HEADING_CONTACT_DESC</option>
|
||||
<option value="a.purchase_type ASC">COM_BANNERS_HEADING_PURCHASETYPE_ASC</option>
|
||||
<option value="a.purchase_type DESC">COM_BANNERS_HEADING_PURCHASETYPE_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>
|
||||
109
administrator/components/com_banners/forms/filter_tracks.xml
Normal file
109
administrator/components/com_banners/forms/filter_tracks.xml
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Banners\Administrator\Field">
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_BANNERS_TRACKS_FILTER_SEARCH_LABEL"
|
||||
description="COM_BANNERS_TRACKS_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="category_id"
|
||||
type="category"
|
||||
label="JCATEGORY"
|
||||
extension="com_banners"
|
||||
class="js-select-submit-on-change"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_CATEGORY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="client_id"
|
||||
type="bannerclient"
|
||||
label="COM_BANNERS_HEADING_CLIENT"
|
||||
extension="com_content"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">COM_BANNERS_SELECT_CLIENT</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="type"
|
||||
type="list"
|
||||
label="COM_BANNERS_HEADING_TYPE"
|
||||
class="js-select-submit-on-change"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_BANNERS_SELECT_TYPE</option>
|
||||
<option value="1">COM_BANNERS_TYPE1</option>
|
||||
<option value="2">COM_BANNERS_TYPE2</option>
|
||||
</field>
|
||||
|
||||
<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>
|
||||
|
||||
<field
|
||||
name="begin"
|
||||
type="calendar"
|
||||
label="COM_BANNERS_BEGIN_LABEL"
|
||||
hint="COM_BANNERS_BEGIN_HINT"
|
||||
format="%Y-%m-%d"
|
||||
filter="user_utc"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="end"
|
||||
type="calendar"
|
||||
label="COM_BANNERS_END_LABEL"
|
||||
hint="COM_BANNERS_END_HINT"
|
||||
format="%Y-%m-%d"
|
||||
filter="user_utc"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
class="js-select-submit-on-change"
|
||||
default="b.name ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="b.name ASC">JGLOBAL_NAME_ASC</option>
|
||||
<option value="b.name DESC">JGLOBAL_NAME_DESC</option>
|
||||
<option value="cl.name ASC">COM_BANNERS_HEADING_CLIENT_ASC</option>
|
||||
<option value="cl.name DESC">COM_BANNERS_HEADING_CLIENT_DESC</option>
|
||||
<option value="a.track_type ASC">COM_BANNERS_HEADING_TYPE_ASC</option>
|
||||
<option value="a.track_type DESC">COM_BANNERS_HEADING_TYPE_DESC</option>
|
||||
<option value="a.count ASC">COM_BANNERS_HEADING_COUNT_ASC</option>
|
||||
<option value="a.count DESC">COM_BANNERS_HEADING_COUNT_DESC</option>
|
||||
<option value="a.track_date ASC">JDATE_ASC</option>
|
||||
<option value="a.track_date DESC">JDATE_DESC</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="5"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
27
administrator/components/com_banners/helpers/banners.php
Normal file
27
administrator/components/com_banners/helpers/banners.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 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
|
||||
|
||||
/**
|
||||
* Banners component helper.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Banners\Administrator\Helper\BannersHelper instead
|
||||
*/
|
||||
class BannersHelper extends \Joomla\Component\Banners\Administrator\Helper\BannersHelper
|
||||
{
|
||||
}
|
||||
63
administrator/components/com_banners/services/provider.php
Normal file
63
administrator/components/com_banners/services/provider.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\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\Banners\Administrator\Extension\BannersComponent;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* The banners 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->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Banners'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Banners'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Banners'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\Joomla\\Component\\Banners'));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$component = new BannersComponent($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setRegistry($container->get(Registry::class));
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,85 @@
|
||||
--
|
||||
-- Table structure for table `#__banners`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__banners` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`cid` int NOT NULL DEFAULT 0,
|
||||
`type` int NOT NULL DEFAULT 0,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
|
||||
`imptotal` int NOT NULL DEFAULT 0,
|
||||
`impmade` int NOT NULL DEFAULT 0,
|
||||
`clicks` int NOT NULL DEFAULT 0,
|
||||
`clickurl` varchar(200) NOT NULL DEFAULT '',
|
||||
`state` tinyint NOT NULL DEFAULT 0,
|
||||
`catid` int unsigned NOT NULL DEFAULT 0,
|
||||
`description` text NOT NULL,
|
||||
`custombannercode` varchar(2048) NOT NULL,
|
||||
`sticky` tinyint unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` int NOT NULL DEFAULT 0,
|
||||
`metakey` text NOT NULL,
|
||||
`params` text NOT NULL,
|
||||
`own_prefix` tinyint NOT NULL DEFAULT 0,
|
||||
`metakey_prefix` varchar(400) NOT NULL DEFAULT '',
|
||||
`purchase_type` tinyint NOT NULL DEFAULT -1,
|
||||
`track_clicks` tinyint NOT NULL DEFAULT -1,
|
||||
`track_impressions` tinyint NOT NULL DEFAULT -1,
|
||||
`checked_out` int unsigned NOT NULL DEFAULT 0,
|
||||
`checked_out_time` datetime,
|
||||
`publish_up` datetime,
|
||||
`publish_down` datetime,
|
||||
`reset` datetime,
|
||||
`created` datetime NOT NULL,
|
||||
`language` char(7) NOT NULL DEFAULT '',
|
||||
`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,
|
||||
`version` int unsigned NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_state` (`state`),
|
||||
KEY `idx_own_prefix` (`own_prefix`),
|
||||
KEY `idx_metakey_prefix` (`metakey_prefix`(100)),
|
||||
KEY `idx_banner_catid` (`catid`),
|
||||
KEY `idx_language` (`language`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Table structure for table `#__banner_clients`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__banner_clients` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`contact` varchar(255) NOT NULL DEFAULT '',
|
||||
`email` varchar(255) NOT NULL DEFAULT '',
|
||||
`extrainfo` text NOT NULL,
|
||||
`state` tinyint NOT NULL DEFAULT 0,
|
||||
`checked_out` int unsigned NOT NULL DEFAULT 0,
|
||||
`checked_out_time` datetime,
|
||||
`metakey` text NOT NULL,
|
||||
`own_prefix` tinyint NOT NULL DEFAULT 0,
|
||||
`metakey_prefix` varchar(400) NOT NULL DEFAULT '',
|
||||
`purchase_type` tinyint NOT NULL DEFAULT -1,
|
||||
`track_clicks` tinyint NOT NULL DEFAULT -1,
|
||||
`track_impressions` tinyint NOT NULL DEFAULT -1,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_own_prefix` (`own_prefix`),
|
||||
KEY `idx_metakey_prefix` (`metakey_prefix`(100))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Table structure for table `#__banner_tracks`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__banner_tracks` (
|
||||
`track_date` datetime NOT NULL,
|
||||
`track_type` int unsigned NOT NULL,
|
||||
`banner_id` int unsigned NOT NULL,
|
||||
`count` int unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`track_date`,`track_type`,`banner_id`),
|
||||
KEY `idx_track_date` (`track_date`),
|
||||
KEY `idx_track_type` (`track_type`),
|
||||
KEY `idx_banner_id` (`banner_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||
@ -0,0 +1,6 @@
|
||||
DROP TABLE IF EXISTS `#__banners`;
|
||||
|
||||
DROP TABLE IF EXISTS `#__banner_clients`;
|
||||
|
||||
DROP TABLE IF EXISTS `#__banner_tracks`;
|
||||
|
||||
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\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
|
||||
|
||||
/**
|
||||
* Banner controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannerController extends FormController
|
||||
{
|
||||
use VersionableControllerTrait;
|
||||
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_BANNER';
|
||||
|
||||
/**
|
||||
* 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 = [])
|
||||
{
|
||||
$filter = $this->input->getInt('filter_category_id');
|
||||
$categoryId = ArrayHelper::getValue($data, 'catid', $filter, 'int');
|
||||
|
||||
if ($categoryId) {
|
||||
// If the category has been passed in the URL check it.
|
||||
return $this->app->getIdentity()->authorise('core.create', $this->option . '.category.' . $categoryId);
|
||||
}
|
||||
|
||||
// In the absence of better information, revert to the component permissions.
|
||||
return parent::allowAdd($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing 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;
|
||||
$categoryId = 0;
|
||||
|
||||
if ($recordId) {
|
||||
$categoryId = (int) $this->getModel()->getItem($recordId)->catid;
|
||||
}
|
||||
|
||||
if ($categoryId) {
|
||||
// The category has been set. Check the category permissions.
|
||||
return $this->app->getIdentity()->authorise('core.edit', $this->option . '.category.' . $categoryId);
|
||||
}
|
||||
|
||||
// Since there is no asset tracking, revert to the component permissions.
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param string $model The model
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function batch($model = null)
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Banner', '', []);
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(Route::_('index.php?option=com_banners&view=banners' . $this->getRedirectToListAppend(), false));
|
||||
|
||||
return parent::batch($model);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banners list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannersController extends AdminController
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_BANNERS';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* @param ?MVCFactoryInterface $factory The factory.
|
||||
* @param ?CMSApplication $app The Application for the dispatcher
|
||||
* @param ?Input $input Input
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
|
||||
$this->registerTask('sticky_unpublish', 'sticky_publish');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Banner', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stick items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function sticky_publish()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
$ids = (array) $this->input->get('cid', [], 'int');
|
||||
$values = ['sticky_publish' => 1, 'sticky_unpublish' => 0];
|
||||
$task = $this->getTask();
|
||||
$value = ArrayHelper::getValue($values, $task, 0, 'int');
|
||||
|
||||
// Remove zero values resulting from input filter
|
||||
$ids = array_filter($ids);
|
||||
|
||||
if (empty($ids)) {
|
||||
$this->app->enqueueMessage(Text::_('COM_BANNERS_NO_BANNERS_SELECTED'), 'warning');
|
||||
} else {
|
||||
// Get the model.
|
||||
/** @var \Joomla\Component\Banners\Administrator\Model\BannerModel $model */
|
||||
$model = $this->getModel();
|
||||
|
||||
// Change the state of the records.
|
||||
if (!$model->stick($ids, $value)) {
|
||||
$this->app->enqueueMessage($model->getError(), 'warning');
|
||||
} else {
|
||||
if ($value == 1) {
|
||||
$ntext = 'COM_BANNERS_N_BANNERS_STUCK';
|
||||
} else {
|
||||
$ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK';
|
||||
}
|
||||
|
||||
$this->setMessage(Text::plural($ntext, \count($ids)));
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_banners&view=banners');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the number of published banners for quickicons
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function getQuickiconContent()
|
||||
{
|
||||
$model = $this->getModel('banners');
|
||||
|
||||
$model->setState('filter.published', 1);
|
||||
|
||||
$amount = (int) $model->getTotal();
|
||||
|
||||
$result = [];
|
||||
|
||||
$result['amount'] = $amount;
|
||||
$result['sronly'] = Text::plural('COM_BANNERS_N_QUICKICON_SRONLY', $amount);
|
||||
$result['name'] = Text::plural('COM_BANNERS_N_QUICKICON', $amount);
|
||||
|
||||
echo new JsonResponse($result);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\Versioning\VersionableControllerTrait;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Client controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ClientController extends FormController
|
||||
{
|
||||
use VersionableControllerTrait;
|
||||
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_CLIENT';
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Clients list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ClientsController extends AdminController
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_CLIENTS';
|
||||
|
||||
/**
|
||||
* 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 \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Client', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Banners\Administrator\Helper\BannersHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banners display controller.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The default view.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'banners';
|
||||
|
||||
/**
|
||||
* 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 BaseController|boolean This object to support chaining.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = [])
|
||||
{
|
||||
BannersHelper::updateReset();
|
||||
|
||||
$view = $this->input->get('view', 'banners');
|
||||
$layout = $this->input->get('layout', 'default');
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Check for edit form.
|
||||
if ($view === 'banner' && $layout === 'edit' && !$this->checkEditId('com_banners.edit.banner', $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_banners&view=banners', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($view === 'client' && $layout === 'edit' && !$this->checkEditId('com_banners.edit.client', $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_banners&view=clients', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::display();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Tracks list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class TracksController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $context = 'com_banners.tracks';
|
||||
|
||||
/**
|
||||
* 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 \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Tracks', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to remove a record.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
$this->checkToken();
|
||||
|
||||
// Get the model.
|
||||
/** @var \Joomla\Component\Banners\Administrator\Model\TracksModel $model */
|
||||
$model = $this->getModel();
|
||||
|
||||
// Load the filter state.
|
||||
$model->setState('filter.type', $this->app->getUserState($this->context . '.filter.type'));
|
||||
$model->setState('filter.begin', $this->app->getUserState($this->context . '.filter.begin'));
|
||||
$model->setState('filter.end', $this->app->getUserState($this->context . '.filter.end'));
|
||||
$model->setState('filter.category_id', $this->app->getUserState($this->context . '.filter.category_id'));
|
||||
$model->setState('filter.client_id', $this->app->getUserState($this->context . '.filter.client_id'));
|
||||
$model->setState('list.limit', 0);
|
||||
$model->setState('list.start', 0);
|
||||
|
||||
$count = $model->getTotal();
|
||||
|
||||
// Remove the items.
|
||||
if (!$model->delete()) {
|
||||
$this->app->enqueueMessage($model->getError(), 'warning');
|
||||
} elseif ($count > 0) {
|
||||
$this->setMessage(Text::plural('COM_BANNERS_TRACKS_N_ITEMS_DELETED', $count));
|
||||
} else {
|
||||
$this->setMessage(Text::_('COM_BANNERS_TRACKS_NO_ITEMS_DELETED'));
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_banners&view=tracks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display method for the raw track data.
|
||||
*
|
||||
* @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 This object to support chaining.
|
||||
*
|
||||
* @since 1.5
|
||||
* @todo This should be done as a view, not here!
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = [])
|
||||
{
|
||||
// Get the document object.
|
||||
$vName = 'tracks';
|
||||
|
||||
// Get and render the view.
|
||||
if ($view = $this->getView($vName, 'raw')) {
|
||||
// Check for request forgeries.
|
||||
$this->checkToken('GET');
|
||||
|
||||
// Get the model for the view.
|
||||
/** @var \Joomla\Component\Banners\Administrator\Model\TracksModel $model */
|
||||
$model = $this->getModel($vName);
|
||||
|
||||
// Load the filter state.
|
||||
$app = $this->app;
|
||||
|
||||
$model->setState('filter.type', $app->getUserState($this->context . '.filter.type'));
|
||||
$model->setState('filter.begin', $app->getUserState($this->context . '.filter.begin'));
|
||||
$model->setState('filter.end', $app->getUserState($this->context . '.filter.end'));
|
||||
$model->setState('filter.category_id', $app->getUserState($this->context . '.filter.category_id'));
|
||||
$model->setState('filter.client_id', $app->getUserState($this->context . '.filter.client_id'));
|
||||
$model->setState('list.limit', 0);
|
||||
$model->setState('list.start', 0);
|
||||
|
||||
$form = $this->input->get('jform', [], 'array');
|
||||
|
||||
$model->setState('basename', $form['basename']);
|
||||
$model->setState('compressed', $form['compressed']);
|
||||
|
||||
// Create one year cookies.
|
||||
$cookieLifeTime = time() + 365 * 86400;
|
||||
$cookieDomain = $app->get('cookie_domain', '');
|
||||
$cookiePath = $app->get('cookie_path', '/');
|
||||
$isHttpsForced = $app->isHttpsForced();
|
||||
|
||||
$this->input->cookie->set(
|
||||
ApplicationHelper::getHash($this->context . '.basename'),
|
||||
$form['basename'],
|
||||
[
|
||||
'expires' => $cookieLifeTime,
|
||||
'path' => $cookiePath,
|
||||
'domain' => $cookieDomain,
|
||||
'secure' => $isHttpsForced,
|
||||
'httponly' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->input->cookie->set(
|
||||
ApplicationHelper::getHash($this->context . '.compressed'),
|
||||
$form['compressed'],
|
||||
[
|
||||
'expires' => $cookieLifeTime,
|
||||
'path' => $cookiePath,
|
||||
'domain' => $cookieDomain,
|
||||
'secure' => $isHttpsForced,
|
||||
'httponly' => true,
|
||||
]
|
||||
);
|
||||
|
||||
// Push the model into the view (as default).
|
||||
$view->setModel($model, true);
|
||||
|
||||
// Push document object into the view.
|
||||
$view->document = $this->app->getDocument();
|
||||
|
||||
$view->display();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Extension;
|
||||
|
||||
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\Banners\Administrator\Service\Html\Banner;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component class for com_banners
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class BannersComponent extends MVCComponent implements
|
||||
BootableExtensionInterface,
|
||||
CategoryServiceInterface,
|
||||
RouterServiceInterface,
|
||||
TagServiceInterface
|
||||
{
|
||||
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)
|
||||
{
|
||||
$banner = new Banner();
|
||||
$banner->setDatabase($container->get(DatabaseInterface::class));
|
||||
|
||||
$this->getRegistry()->register('banner', $banner);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 'banners';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Field;
|
||||
|
||||
use Joomla\CMS\Form\Field\ListField;
|
||||
use Joomla\Component\Banners\Administrator\Helper\BannersHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Bannerclient field.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannerclientField extends ListField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'BannerClient';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return array_merge(parent::getOptions(), BannersHelper::getClientOptions());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Field;
|
||||
|
||||
use Joomla\CMS\Form\FormField;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Clicks field.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ClicksField extends FormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'Clicks';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$onclick = ' onclick="document.getElementById(\'' . $this->id . '\').value=\'0\';"';
|
||||
|
||||
return '<div class="input-group"><input class="form-control" type="text" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" readonly="readonly">'
|
||||
. '<button type="button" class="btn btn-secondary" ' . $onclick . '>'
|
||||
. '<span class="icon-sync" aria-hidden="true"></span> ' . Text::_('JRESET') . '</button></div>';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Field;
|
||||
|
||||
use Joomla\CMS\Form\FormField;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Impressions field.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ImpmadeField extends FormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'ImpMade';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$onclick = ' onclick="document.getElementById(\'' . $this->id . '\').value=\'0\';"';
|
||||
|
||||
return '<div class="input-group"><input class="form-control" type="text" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" readonly="readonly">'
|
||||
. '<button type="button" class="btn btn-secondary" ' . $onclick . '>'
|
||||
. '<span class="icon-sync" aria-hidden="true"></span> ' . Text::_('JRESET') . '</button></div>';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Field;
|
||||
|
||||
use Joomla\CMS\Form\FormField;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Total Impressions field.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ImptotalField extends FormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'ImpTotal';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$class = ' class="form-control validate-numeric text_area"';
|
||||
$onchange = ' onchange="document.getElementById(\'' . $this->id . '_unlimited\').checked=document.getElementById(\'' . $this->id
|
||||
. '\').value==\'\';"';
|
||||
$onclick = ' onclick="if (document.getElementById(\'' . $this->id . '_unlimited\').checked) document.getElementById(\'' . $this->id
|
||||
. '\').value=\'\';"';
|
||||
$value = empty($this->value) ? '' : $this->value;
|
||||
$checked = empty($this->value) ? ' checked="checked"' : '';
|
||||
|
||||
return '<input type="text" name="' . $this->name . '" id="' . $this->id . '" size="9" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8')
|
||||
. '" ' . $class . $onchange . '>'
|
||||
. '<fieldset class="form-check impunlimited"><input class="form-check-input" id="' . $this->id . '_unlimited" type="checkbox"' . $checked . $onclick . '>'
|
||||
. '<label for="' . $this->id . '_unlimited" id="jform-imp" class="form-check-label">' . Text::_('COM_BANNERS_UNLIMITED') . '</label></fieldset>';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banners component helper.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannersHelper extends ContentHelper
|
||||
{
|
||||
/**
|
||||
* Update / reset the banners
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function updateReset()
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$date = Factory::getDate();
|
||||
$app = Factory::getApplication();
|
||||
$user = $app->getIdentity();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__banners'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('reset') . ' <= :date',
|
||||
$db->quoteName('reset') . ' IS NOT NULL',
|
||||
]
|
||||
)
|
||||
->bind(':date', $date)
|
||||
->extendWhere(
|
||||
'AND',
|
||||
[
|
||||
$db->quoteName('checked_out') . ' IS NULL',
|
||||
$db->quoteName('checked_out') . ' = :userId',
|
||||
],
|
||||
'OR'
|
||||
)
|
||||
->bind(':userId', $user->id, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$rows = $db->loadObjectList();
|
||||
} catch (\RuntimeException $e) {
|
||||
$app->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$purchaseType = $row->purchase_type;
|
||||
|
||||
if ($purchaseType < 0 && $row->cid) {
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\ClientTable $client */
|
||||
$client = Table::getInstance('ClientTable', '\\Joomla\\Component\\Banners\\Administrator\\Table\\');
|
||||
$client->load($row->cid);
|
||||
$purchaseType = $client->purchase_type;
|
||||
}
|
||||
|
||||
if ($purchaseType < 0) {
|
||||
$params = ComponentHelper::getParams('com_banners');
|
||||
$purchaseType = $params->get('purchase_type');
|
||||
}
|
||||
|
||||
switch ($purchaseType) {
|
||||
case 1:
|
||||
$reset = null;
|
||||
break;
|
||||
case 2:
|
||||
$date = Factory::getDate('+1 year ' . date('Y-m-d'));
|
||||
$reset = $date->toSql();
|
||||
break;
|
||||
case 3:
|
||||
$date = Factory::getDate('+1 month ' . date('Y-m-d'));
|
||||
$reset = $date->toSql();
|
||||
break;
|
||||
case 4:
|
||||
$date = Factory::getDate('+7 day ' . date('Y-m-d'));
|
||||
$reset = $date->toSql();
|
||||
break;
|
||||
case 5:
|
||||
$date = Factory::getDate('+1 day ' . date('Y-m-d'));
|
||||
$reset = $date->toSql();
|
||||
break;
|
||||
}
|
||||
|
||||
// Update the row ordering field.
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__banners'))
|
||||
->set(
|
||||
[
|
||||
$db->quoteName('reset') . ' = :reset',
|
||||
$db->quoteName('impmade') . ' = 0',
|
||||
$db->quoteName('clicks') . ' = 0',
|
||||
]
|
||||
)
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':reset', $reset, $reset === null ? ParameterType::NULL : ParameterType::STRING)
|
||||
->bind(':id', $row->id, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
$app->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get client list in text/value format for a select field
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getClientOptions()
|
||||
{
|
||||
$options = [];
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('id', 'value'),
|
||||
$db->quoteName('name', 'text'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banner_clients', 'a'))
|
||||
->where($db->quoteName('a.state') . ' = 1')
|
||||
->order($db->quoteName('a.name'));
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$options = $db->loadObjectList();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
array_unshift($options, HTMLHelper::_('select.option', '0', Text::_('COM_BANNERS_NO_CLIENT')));
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
481
administrator/components/com_banners/src/Model/BannerModel.php
Normal file
481
administrator/components/com_banners/src/Model/BannerModel.php
Normal file
@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Table\TableInterface;
|
||||
use Joomla\CMS\Versioning\VersionableModelTrait;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannerModel extends AdminModel
|
||||
{
|
||||
use VersionableModelTrait;
|
||||
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_BANNERS_BANNER';
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_banners.banner';
|
||||
|
||||
/**
|
||||
* Batch copy/move command. If set to false, the batch copy/move command is not supported
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $batch_copymove = 'category_id';
|
||||
|
||||
/**
|
||||
* Allowed batch commands
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $batch_commands = [
|
||||
'client_id' => 'batchClient',
|
||||
'language_id' => 'batchLanguage',
|
||||
];
|
||||
|
||||
/**
|
||||
* Data cleanup after batch copying data
|
||||
*
|
||||
* @param TableInterface $table The table object containing the newly created item
|
||||
* @param integer $newId The id of the new item
|
||||
* @param integer $oldId The original item id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.2
|
||||
*/
|
||||
protected function cleanupPostBatchCopy(TableInterface $table, $newId, $oldId)
|
||||
{
|
||||
// Initialise clicks and impmade
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__banners'))
|
||||
->set($db->quoteName('clicks') . ' = 0')
|
||||
->set($db->quoteName('impmade') . ' = 0')
|
||||
->where($db->quoteName('id') . ' = :newId')
|
||||
->bind(':newId', $newId, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Batch client changes for a group of banners.
|
||||
*
|
||||
* @param string $value The new value matching a client.
|
||||
* @param array $pks An array of row IDs.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function batchClient($value, $pks, $contexts)
|
||||
{
|
||||
// Set the variables
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\BannerTable $table */
|
||||
$table = $this->getTable();
|
||||
|
||||
foreach ($pks as $pk) {
|
||||
if (!$user->authorise('core.edit', $contexts[$pk])) {
|
||||
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$table->reset();
|
||||
$table->load($pk);
|
||||
$table->cid = (int) $value;
|
||||
|
||||
if (!$table->store()) {
|
||||
$this->setError($table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->state != -2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
return parent::canDelete($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to preprocess generating a new title in order to allow tables with alternative names
|
||||
* for alias and title to use the batch move and copy methods
|
||||
*
|
||||
* @param integer $categoryId The target category id
|
||||
* @param Table $table The \Joomla\CMS\Table\Table within which move or copy is taking place
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.8.12
|
||||
*/
|
||||
public function generateTitle($categoryId, $table)
|
||||
{
|
||||
// Alter the title & alias
|
||||
$data = $this->generateNewTitle($categoryId, $table->alias, $table->name);
|
||||
$table->name = $data['0'];
|
||||
$table->alias = $data['1'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// Check against the category.
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.edit.state', 'com_banners.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
// Default to component settings if category not known.
|
||||
return parent::canEditState($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form. [optional]
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not. [optional]
|
||||
*
|
||||
* @return Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_banners.banner', 'banner', ['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('publish_up', 'disabled', 'true');
|
||||
$form->setFieldAttribute('publish_down', 'disabled', 'true');
|
||||
$form->setFieldAttribute('state', 'disabled', 'true');
|
||||
$form->setFieldAttribute('sticky', '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('publish_up', 'filter', 'unset');
|
||||
$form->setFieldAttribute('publish_down', 'filter', 'unset');
|
||||
$form->setFieldAttribute('state', 'filter', 'unset');
|
||||
$form->setFieldAttribute('sticky', '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.
|
||||
$app = Factory::getApplication();
|
||||
$data = $app->getUserState('com_banners.edit.banner.data', []);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
|
||||
// Prime some default values.
|
||||
if ($this->getState('banner.id') == 0) {
|
||||
$filters = (array) $app->getUserState('com_banners.banners.filter');
|
||||
$filterCatId = $filters['category_id'] ?? null;
|
||||
|
||||
$data->set('catid', $app->getInput()->getInt('catid', $filterCatId));
|
||||
}
|
||||
}
|
||||
|
||||
$this->preprocessData('com_banners.banner', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to stick records.
|
||||
*
|
||||
* @param array $pks The ids of the items to publish.
|
||||
* @param integer $value The value of the published state
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function stick(&$pks, $value = 1)
|
||||
{
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\BannerTable $table */
|
||||
$table = $this->getTable();
|
||||
$pks = (array) $pks;
|
||||
|
||||
// Access checks.
|
||||
foreach ($pks as $i => $pk) {
|
||||
if ($table->load($pk)) {
|
||||
if (!$this->canEditState($table)) {
|
||||
// Prune items that you can't change.
|
||||
unset($pks[$i]);
|
||||
Factory::getApplication()->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to change the state of the records.
|
||||
if (!$table->stick($pks, $value, $this->getCurrentUser()->id)) {
|
||||
$this->setError($table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A protected method to get a set of ordering conditions.
|
||||
*
|
||||
* @param Table $table A record object.
|
||||
*
|
||||
* @return array An array of conditions to add to ordering queries.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getReorderConditions($table)
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
return [
|
||||
$db->quoteName('catid') . ' = ' . (int) $table->catid,
|
||||
$db->quoteName('state') . ' >= 0',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table prior to saving.
|
||||
*
|
||||
* @param Table $table A Table object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$date = Factory::getDate();
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if (empty($table->id)) {
|
||||
// Set the values
|
||||
$table->created = $date->toSql();
|
||||
$table->created_by = $user->id;
|
||||
|
||||
// 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('#__banners'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
} else {
|
||||
// Set the values
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->id;
|
||||
}
|
||||
|
||||
// Increment the content version number.
|
||||
$table->version++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows preprocessing of the Form object.
|
||||
*
|
||||
* @param Form $form The form object
|
||||
* @param array $data The data to be merged into the form object
|
||||
* @param string $group The plugin group to be executed
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.6.1
|
||||
*/
|
||||
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#');
|
||||
}
|
||||
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
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_banners');
|
||||
}
|
||||
|
||||
// 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_banners',
|
||||
'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 new category ID.
|
||||
$data['catid'] = $categoryModel->getState('category.id');
|
||||
}
|
||||
|
||||
// Alter the name for save as copy
|
||||
if ($input->get('task') == 'save2copy') {
|
||||
/** @var \Joomla\Component\Banners\Administrator\Table\BannerTable $origTable */
|
||||
$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['state'] = 0;
|
||||
}
|
||||
|
||||
if ($input->get('task') == 'save2copy' || $input->get('task') == 'copy') {
|
||||
$data['clicks'] = 0;
|
||||
$data['impmade'] = 0;
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_banners');
|
||||
}
|
||||
}
|
||||
285
administrator/components/com_banners/src/Model/BannersModel.php
Normal file
285
administrator/components/com_banners/src/Model/BannersModel.php
Normal file
@ -0,0 +1,285 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Methods supporting a list of banner records.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannersModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'cid', 'a.cid', 'client_name',
|
||||
'name', 'a.name',
|
||||
'alias', 'a.alias',
|
||||
'state', 'a.state',
|
||||
'ordering', 'a.ordering',
|
||||
'language', 'a.language',
|
||||
'catid', 'a.catid', 'category_title',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'created', 'a.created',
|
||||
'impmade', 'a.impmade',
|
||||
'imptotal', 'a.imptotal',
|
||||
'clicks', 'a.clicks',
|
||||
'publish_up', 'a.publish_up',
|
||||
'publish_down', 'a.publish_down',
|
||||
'sticky', 'a.sticky',
|
||||
'client_id',
|
||||
'category_id',
|
||||
'published',
|
||||
'level', 'c.level',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the maximum ordering value for each category.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function &getCategoryOrders()
|
||||
{
|
||||
if (!isset($this->cache['categoryorders'])) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
'MAX(' . $db->quoteName('ordering') . ') AS ' . $db->quoteName('max'),
|
||||
$db->quoteName('catid'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banners'))
|
||||
->group($db->quoteName('catid'));
|
||||
$db->setQuery($query);
|
||||
$this->cache['categoryorders'] = $db->loadAssocList('catid', 0);
|
||||
}
|
||||
|
||||
return $this->cache['categoryorders'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// 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.clicks'),
|
||||
$db->quoteName('a.metakey'),
|
||||
$db->quoteName('a.sticky'),
|
||||
$db->quoteName('a.impmade'),
|
||||
$db->quoteName('a.imptotal'),
|
||||
$db->quoteName('a.state'),
|
||||
$db->quoteName('a.ordering'),
|
||||
$db->quoteName('a.purchase_type'),
|
||||
$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('c.title', 'category_title'),
|
||||
$db->quoteName('cl.name', 'client_name'),
|
||||
$db->quoteName('cl.purchase_type', 'client_purchase_type'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banners', '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('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'))
|
||||
->join('LEFT', $db->quoteName('#__banner_clients', 'cl'), $db->quoteName('cl.id') . ' = ' . $db->quoteName('a.cid'));
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$published = (int) $published;
|
||||
$query->where($db->quoteName('a.state') . ' = :published')
|
||||
->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where($db->quoteName('a.state') . ' 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 by client.
|
||||
$clientId = $this->getState('filter.client_id');
|
||||
|
||||
if (is_numeric($clientId)) {
|
||||
$clientId = (int) $clientId;
|
||||
$query->where($db->quoteName('a.cid') . ' = :clientId')
|
||||
->bind(':clientId', $clientId, 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 on the level.
|
||||
if ($level = (int) $this->getState('filter.level')) {
|
||||
$query->where($db->quoteName('c.level') . ' <= :level')
|
||||
->bind(':level', $level, 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 {
|
||||
if ($orderCol === 'client_name') {
|
||||
$orderCol = 'cl.name';
|
||||
}
|
||||
|
||||
$ordering = $db->escape($orderCol) . ' ' . $db->escape($orderDirn);
|
||||
}
|
||||
|
||||
$query->order($ordering);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
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.client_id');
|
||||
$id .= ':' . $this->getState('filter.language');
|
||||
$id .= ':' . $this->getState('filter.level');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the a Table object, always creating it.
|
||||
*
|
||||
* @param string $type The table type to instantiate
|
||||
* @param string $prefix A prefix for the table class name. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return Table A Table object
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTable($type = 'Banner', $prefix = 'Administrator', $config = [])
|
||||
{
|
||||
return parent::getTable($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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')
|
||||
{
|
||||
// Load the parameters.
|
||||
$this->setState('params', ComponentHelper::getParams('com_banners'));
|
||||
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
}
|
||||
138
administrator/components/com_banners/src/Model/ClientModel.php
Normal file
138
administrator/components/com_banners/src/Model/ClientModel.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Versioning\VersionableModelTrait;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Client model.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ClientModel extends AdminModel
|
||||
{
|
||||
use VersionableModelTrait;
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_banners.client';
|
||||
|
||||
/**
|
||||
* 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->state != -2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($record->catid)) {
|
||||
return $this->getCurrentUser()->authorise('core.delete', 'com_banners.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)
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if (!empty($record->catid)) {
|
||||
return $user->authorise('core.edit.state', 'com_banners.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
return $user->authorise('core.edit.state', 'com_banners');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 \Joomla\CMS\Form\Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_banners.client', 'client', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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_banners.edit.client.data', []);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
$this->preprocessData('com_banners.client', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table prior to saving.
|
||||
*
|
||||
* @param Table $table A Table object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
|
||||
}
|
||||
}
|
||||
295
administrator/components/com_banners/src/Model/ClientsModel.php
Normal file
295
administrator/components/com_banners/src/Model/ClientsModel.php
Normal file
@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Methods supporting a list of banner records.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ClientsModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'id', 'a.id',
|
||||
'name', 'a.name',
|
||||
'contact', 'a.contact',
|
||||
'state', 'a.state',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'purchase_type', 'a.purchase_type',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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')
|
||||
{
|
||||
// Load the parameters.
|
||||
$this->setState('params', ComponentHelper::getParams('com_banners'));
|
||||
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.state');
|
||||
$id .= ':' . $this->getState('filter.purchase_type');
|
||||
|
||||
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);
|
||||
|
||||
$defaultPurchase = (int) ComponentHelper::getParams('com_banners')->get('purchase_type', 3);
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.name'),
|
||||
$db->quoteName('a.contact'),
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('a.state'),
|
||||
$db->quoteName('a.metakey'),
|
||||
$db->quoteName('a.purchase_type'),
|
||||
]
|
||||
)
|
||||
)
|
||||
->select(
|
||||
[
|
||||
'COUNT(' . $db->quoteName('b.id') . ') AS ' . $db->quoteName('nbanners'),
|
||||
$db->quoteName('uc.name', 'editor'),
|
||||
]
|
||||
);
|
||||
|
||||
$query->from($db->quoteName('#__banner_clients', 'a'));
|
||||
|
||||
// Join over the banners for counting
|
||||
$query->join('LEFT', $db->quoteName('#__banners', 'b'), $db->quoteName('a.id') . ' = ' . $db->quoteName('b.cid'));
|
||||
|
||||
// Join over the users for the checked out user.
|
||||
$query->join('LEFT', $db->quoteName('#__users', 'uc'), $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out'));
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.state');
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$published = (int) $published;
|
||||
$query->where($db->quoteName('a.state') . ' = :published')
|
||||
->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where($db->quoteName('a.state') . ' IN (0, 1)');
|
||||
}
|
||||
|
||||
$query->group(
|
||||
[
|
||||
$db->quoteName('a.id'),
|
||||
$db->quoteName('a.name'),
|
||||
$db->quoteName('a.contact'),
|
||||
$db->quoteName('a.checked_out'),
|
||||
$db->quoteName('a.checked_out_time'),
|
||||
$db->quoteName('a.state'),
|
||||
$db->quoteName('a.metakey'),
|
||||
$db->quoteName('a.purchase_type'),
|
||||
$db->quoteName('uc.name'),
|
||||
]
|
||||
);
|
||||
|
||||
// Filter by search in title
|
||||
if ($search = trim($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(' ', '%', $search) . '%';
|
||||
$query->where($db->quoteName('a.name') . ' LIKE :search')
|
||||
->bind(':search', $search);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by purchase type
|
||||
if ($purchaseType = (int) $this->getState('filter.purchase_type')) {
|
||||
if ($defaultPurchase === $purchaseType) {
|
||||
$query->where('(' . $db->quoteName('a.purchase_type') . ' = :type OR ' . $db->quoteName('a.purchase_type') . ' = -1)');
|
||||
} else {
|
||||
$query->where($db->quoteName('a.purchase_type') . ' = :type');
|
||||
}
|
||||
|
||||
$query->bind(':type', $purchaseType, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order(
|
||||
$db->quoteName($db->escape($this->getState('list.ordering', 'a.name'))) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))
|
||||
);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the getItems method to attach additional metrics to the list.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
// Get a storage key.
|
||||
$store = $this->getStoreId('getItems');
|
||||
|
||||
// Try to load the data from internal storage.
|
||||
if (!empty($this->cache[$store])) {
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
// Load the list items.
|
||||
$items = parent::getItems();
|
||||
|
||||
// If empty or an error, just return.
|
||||
if (empty($items)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Getting the following metric by joins is WAY TOO SLOW.
|
||||
// Faster to do three queries for very large banner trees.
|
||||
|
||||
// Get the clients in the list.
|
||||
$db = $this->getDatabase();
|
||||
$clientIds = array_column($items, 'id');
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('cid'),
|
||||
'COUNT(' . $db->quoteName('cid') . ') AS ' . $db->quoteName('count_published'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banners'))
|
||||
->where($db->quoteName('state') . ' = :state')
|
||||
->whereIn($db->quoteName('cid'), $clientIds)
|
||||
->group($db->quoteName('cid'))
|
||||
->bind(':state', $state, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
// Get the published banners count.
|
||||
try {
|
||||
$state = 1;
|
||||
$countPublished = $db->loadAssocList('cid', 'count_published');
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the unpublished banners count.
|
||||
try {
|
||||
$state = 0;
|
||||
$countUnpublished = $db->loadAssocList('cid', 'count_published');
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the trashed banners count.
|
||||
try {
|
||||
$state = -2;
|
||||
$countTrashed = $db->loadAssocList('cid', 'count_published');
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the archived banners count.
|
||||
try {
|
||||
$state = 2;
|
||||
$countArchived = $db->loadAssocList('cid', 'count_published');
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inject the values back into the array.
|
||||
foreach ($items as $item) {
|
||||
$item->count_published = $countPublished[$item->id] ?? 0;
|
||||
$item->count_unpublished = $countUnpublished[$item->id] ?? 0;
|
||||
$item->count_trashed = $countTrashed[$item->id] ?? 0;
|
||||
$item->count_archived = $countArchived[$item->id] ?? 0;
|
||||
}
|
||||
|
||||
// Add the items to the internal cache.
|
||||
$this->cache[$store] = $items;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\FormModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Download model.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class DownloadModel extends FormModel
|
||||
{
|
||||
/**
|
||||
* The model context
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_banners.tracks';
|
||||
|
||||
/**
|
||||
* Auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
|
||||
$this->setState('basename', $input->cookie->getString(ApplicationHelper::getHash($this->_context . '.basename'), '__SITE__'));
|
||||
$this->setState('compressed', $input->cookie->getInt(ApplicationHelper::getHash($this->_context . '.compressed'), 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 \Joomla\CMS\Form\Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_banners.download', 'download', ['control' => 'jform', 'load_data' => $loadData]);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
$data = (object) [
|
||||
'basename' => $this->getState('basename'),
|
||||
'compressed' => $this->getState('compressed'),
|
||||
];
|
||||
|
||||
$this->preprocessData('com_banners.download', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
496
administrator/components/com_banners/src/Model/TracksModel.php
Normal file
496
administrator/components/com_banners/src/Model/TracksModel.php
Normal file
@ -0,0 +1,496 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Model;
|
||||
|
||||
use Joomla\Archive\Archive;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Filesystem\File;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Methods supporting a list of tracks.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class TracksModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* The base name
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $basename;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'b.name', 'banner_name',
|
||||
'cl.name', 'client_name', 'client_id',
|
||||
'c.title', 'category_title', 'category_id',
|
||||
'track_type', 'a.track_type', 'type',
|
||||
'count', 'a.count',
|
||||
'track_date', 'a.track_date', 'end', 'begin',
|
||||
'level', 'c.level',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = 'b.name', $direction = 'asc')
|
||||
{
|
||||
// Load the parameters.
|
||||
$this->setState('params', ComponentHelper::getParams('com_banners'));
|
||||
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
[
|
||||
$db->quoteName('a.track_date'),
|
||||
$db->quoteName('a.track_type'),
|
||||
$db->quoteName('a.count'),
|
||||
$db->quoteName('b.name', 'banner_name'),
|
||||
$db->quoteName('cl.name', 'client_name'),
|
||||
$db->quoteName('c.title', 'category_title'),
|
||||
]
|
||||
);
|
||||
|
||||
// From tracks table.
|
||||
$query->from($db->quoteName('#__banner_tracks', 'a'));
|
||||
|
||||
// Join with the banners.
|
||||
$query->join('LEFT', $db->quoteName('#__banners', 'b'), $db->quoteName('b.id') . ' = ' . $db->quoteName('a.banner_id'));
|
||||
|
||||
// Join with the client.
|
||||
$query->join('LEFT', $db->quoteName('#__banner_clients', 'cl'), $db->quoteName('cl.id') . ' = ' . $db->quoteName('b.cid'));
|
||||
|
||||
// Join with the category.
|
||||
$query->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('b.catid'));
|
||||
|
||||
// Filter by type.
|
||||
|
||||
if ($type = (int) $this->getState('filter.type')) {
|
||||
$query->where($db->quoteName('a.track_type') . ' = :type')
|
||||
->bind(':type', $type, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by client.
|
||||
$clientId = $this->getState('filter.client_id');
|
||||
|
||||
if (is_numeric($clientId)) {
|
||||
$clientId = (int) $clientId;
|
||||
$query->where($db->quoteName('b.cid') . ' = :clientId')
|
||||
->bind(':clientId', $clientId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by category.
|
||||
$categoryId = $this->getState('filter.category_id');
|
||||
|
||||
if (is_numeric($categoryId)) {
|
||||
$categoryId = (int) $categoryId;
|
||||
$query->where($db->quoteName('b.catid') . ' = :categoryId')
|
||||
->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by begin date.
|
||||
if ($begin = $this->getState('filter.begin')) {
|
||||
$query->where($db->quoteName('a.track_date') . ' >= :begin')
|
||||
->bind(':begin', $begin);
|
||||
}
|
||||
|
||||
// Filter by end date.
|
||||
if ($end = $this->getState('filter.end')) {
|
||||
$query->where($db->quoteName('a.track_date') . ' <= :end')
|
||||
->bind(':end', $end);
|
||||
}
|
||||
|
||||
// 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 banner name or client name.
|
||||
if ($search = $this->getState('filter.search')) {
|
||||
$search = '%' . StringHelper::strtolower($search) . '%';
|
||||
$query->where('(LOWER(' . $db->quoteName('b.name') . ') LIKE :search1 OR LOWER(' . $db->quoteName('cl.name') . ') LIKE :search2)')
|
||||
->bind([':search1', ':search2'], $search);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order(
|
||||
$db->quoteName($db->escape($this->getState('list.ordering', 'b.name'))) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))
|
||||
);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete rows.
|
||||
*
|
||||
* @return boolean Returns true on success, false on failure.
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$user = $this->getCurrentUser();
|
||||
$categoryId = (int) $this->getState('category_id');
|
||||
|
||||
// Access checks.
|
||||
if ($categoryId) {
|
||||
$allow = $user->authorise('core.delete', 'com_banners.category.' . $categoryId);
|
||||
} else {
|
||||
$allow = $user->authorise('core.delete', 'com_banners');
|
||||
}
|
||||
|
||||
if ($allow) {
|
||||
// Delete tracks from this banner
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__banner_tracks'));
|
||||
|
||||
// Filter by type
|
||||
if ($type = (int) $this->getState('filter.type')) {
|
||||
$query->where($db->quoteName('track_type') . ' = :type')
|
||||
->bind(':type', $type, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by begin date
|
||||
if ($begin = $this->getState('filter.begin')) {
|
||||
$query->where($db->quoteName('track_date') . ' >= :begin')
|
||||
->bind(':begin', $begin);
|
||||
}
|
||||
|
||||
// Filter by end date
|
||||
if ($end = $this->getState('filter.end')) {
|
||||
$query->where($db->quoteName('track_date') . ' <= :end')
|
||||
->bind(':end', $end);
|
||||
}
|
||||
|
||||
$subQuery = $db->getQuery(true);
|
||||
$subQuery->select($db->quoteName('id'))
|
||||
->from($db->quoteName('#__banners'));
|
||||
|
||||
// Filter by client
|
||||
if ($clientId = (int) $this->getState('filter.client_id')) {
|
||||
$subQuery->where($db->quoteName('cid') . ' = :clientId');
|
||||
$query->bind(':clientId', $clientId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by category
|
||||
if ($categoryId) {
|
||||
$subQuery->where($db->quoteName('catid') . ' = :categoryId');
|
||||
$query->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
$query->where($db->quoteName('banner_id') . ' IN (' . $subQuery . ')');
|
||||
|
||||
$db->setQuery($query);
|
||||
$this->setError((string) $query);
|
||||
|
||||
try {
|
||||
$db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Factory::getApplication()->enqueueMessage(Text::_('JERROR_CORE_DELETE_NOT_PERMITTED'), 'error');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file name
|
||||
*
|
||||
* @return string The file name
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getBaseName()
|
||||
{
|
||||
if (!isset($this->basename)) {
|
||||
$basename = str_replace('__SITE__', Factory::getApplication()->get('sitename'), $this->getState('basename'));
|
||||
$categoryId = $this->getState('filter.category_id');
|
||||
|
||||
if (is_numeric($categoryId)) {
|
||||
if ($categoryId > 0) {
|
||||
$basename = str_replace('__CATID__', $categoryId, $basename);
|
||||
} else {
|
||||
$basename = str_replace('__CATID__', '', $basename);
|
||||
}
|
||||
|
||||
$categoryName = $this->getCategoryName();
|
||||
$basename = str_replace('__CATNAME__', $categoryName, $basename);
|
||||
} else {
|
||||
$basename = str_replace(['__CATID__', '__CATNAME__'], '', $basename);
|
||||
}
|
||||
|
||||
$clientId = $this->getState('filter.client_id');
|
||||
|
||||
if (is_numeric($clientId)) {
|
||||
if ($clientId > 0) {
|
||||
$basename = str_replace('__CLIENTID__', $clientId, $basename);
|
||||
} else {
|
||||
$basename = str_replace('__CLIENTID__', '', $basename);
|
||||
}
|
||||
|
||||
$clientName = $this->getClientName();
|
||||
$basename = str_replace('__CLIENTNAME__', $clientName, $basename);
|
||||
} else {
|
||||
$basename = str_replace(['__CLIENTID__', '__CLIENTNAME__'], '', $basename);
|
||||
}
|
||||
|
||||
$type = $this->getState('filter.type');
|
||||
|
||||
if ($type > 0) {
|
||||
$basename = str_replace('__TYPE__', $type, $basename);
|
||||
$typeName = Text::_('COM_BANNERS_TYPE' . $type);
|
||||
$basename = str_replace('__TYPENAME__', $typeName, $basename);
|
||||
} else {
|
||||
$basename = str_replace(['__TYPE__', '__TYPENAME__'], '', $basename);
|
||||
}
|
||||
|
||||
$begin = $this->getState('filter.begin');
|
||||
|
||||
if (!empty($begin)) {
|
||||
$basename = str_replace('__BEGIN__', $begin, $basename);
|
||||
} else {
|
||||
$basename = str_replace('__BEGIN__', '', $basename);
|
||||
}
|
||||
|
||||
$end = $this->getState('filter.end');
|
||||
|
||||
if (!empty($end)) {
|
||||
$basename = str_replace('__END__', $end, $basename);
|
||||
} else {
|
||||
$basename = str_replace('__END__', '', $basename);
|
||||
}
|
||||
|
||||
$this->basename = $basename;
|
||||
}
|
||||
|
||||
return $this->basename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category name.
|
||||
*
|
||||
* @return string The category name
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getCategoryName()
|
||||
{
|
||||
$categoryId = (int) $this->getState('filter.category_id');
|
||||
|
||||
if ($categoryId) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('title'))
|
||||
->from($db->quoteName('#__categories'))
|
||||
->where($db->quoteName('id') . ' = :categoryId')
|
||||
->bind(':categoryId', $categoryId, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$name = $db->loadResult();
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
return Text::_('COM_BANNERS_NOCATEGORYNAME');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the client name
|
||||
*
|
||||
* @return string The client name.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getClientName()
|
||||
{
|
||||
$clientId = (int) $this->getState('filter.client_id');
|
||||
|
||||
if ($clientId) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('name'))
|
||||
->from($db->quoteName('#__banner_clients'))
|
||||
->where($db->quoteName('id') . ' = :clientId')
|
||||
->bind(':clientId', $clientId, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$name = $db->loadResult();
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
return Text::_('COM_BANNERS_NOCLIENTNAME');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file type.
|
||||
*
|
||||
* @return string The file type
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getFileType()
|
||||
{
|
||||
return $this->getState('compressed') ? 'zip' : 'csv';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mime type.
|
||||
*
|
||||
* @return string The mime type.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
return $this->getState('compressed') ? 'application/zip' : 'text/csv';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content
|
||||
*
|
||||
* @return string The content.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (!isset($this->content)) {
|
||||
$this->content = '"' . str_replace('"', '""', Text::_('COM_BANNERS_HEADING_NAME')) . '","'
|
||||
. str_replace('"', '""', Text::_('COM_BANNERS_HEADING_CLIENT')) . '","'
|
||||
. str_replace('"', '""', Text::_('JCATEGORY')) . '","'
|
||||
. str_replace('"', '""', Text::_('COM_BANNERS_HEADING_TYPE')) . '","'
|
||||
. str_replace('"', '""', Text::_('COM_BANNERS_HEADING_COUNT')) . '","'
|
||||
. str_replace('"', '""', Text::_('JDATE')) . '"' . "\n";
|
||||
|
||||
foreach ($this->getItems() as $item) {
|
||||
$this->content .= '"' . str_replace('"', '""', $item->banner_name) . '","'
|
||||
. str_replace('"', '""', $item->client_name) . '","'
|
||||
. str_replace('"', '""', $item->category_title) . '","'
|
||||
. str_replace('"', '""', ($item->track_type == 1 ? Text::_('COM_BANNERS_IMPRESSION') : Text::_('COM_BANNERS_CLICK'))) . '","'
|
||||
. str_replace('"', '""', $item->count) . '","'
|
||||
. str_replace('"', '""', $item->track_date) . '"' . "\n";
|
||||
}
|
||||
|
||||
if ($this->getState('compressed')) {
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$files = [
|
||||
'track' => [
|
||||
'name' => $this->getBaseName() . '.csv',
|
||||
'data' => $this->content,
|
||||
'time' => time(),
|
||||
],
|
||||
];
|
||||
$ziproot = $app->get('tmp_path') . '/' . uniqid('banners_tracks_') . '.zip';
|
||||
|
||||
// Run the packager
|
||||
$delete = Folder::files($app->get('tmp_path') . '/', uniqid('banners_tracks_'), false, true);
|
||||
|
||||
if (!empty($delete)) {
|
||||
if (!File::delete($delete)) {
|
||||
// File::delete throws an error
|
||||
$this->setError(Text::_('COM_BANNERS_ERR_ZIP_DELETE_FAILURE'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$archive = new Archive();
|
||||
|
||||
if (!$packager = $archive->getAdapter('zip')) {
|
||||
$this->setError(Text::_('COM_BANNERS_ERR_ZIP_ADAPTER_FAILURE'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$packager->create($ziproot, $files)) {
|
||||
$this->setError(Text::_('COM_BANNERS_ERR_ZIP_CREATE_FAILURE'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->content = file_get_contents($ziproot);
|
||||
|
||||
// Remove tmp zip file, it's no longer needed.
|
||||
File::delete($ziproot);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
126
administrator/components/com_banners/src/Service/Html/Banner.php
Normal file
126
administrator/components/com_banners/src/Service/Html/Banner.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Administrator\Service\Html;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Database\DatabaseAwareTrait;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner HTML class.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class Banner
|
||||
{
|
||||
use DatabaseAwareTrait;
|
||||
|
||||
/**
|
||||
* Display a batch widget for the client selector.
|
||||
*
|
||||
* @return string The necessary HTML for the widget.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function clients()
|
||||
{
|
||||
// Create the batch selector to change the client on a selection list.
|
||||
return implode(
|
||||
"\n",
|
||||
[
|
||||
'<label id="batch-client-lbl" for="batch-client-id">',
|
||||
Text::_('COM_BANNERS_BATCH_CLIENT_LABEL'),
|
||||
'</label>',
|
||||
'<select class="form-select" name="batch[client_id]" id="batch-client-id">',
|
||||
'<option value="">' . Text::_('COM_BANNERS_BATCH_CLIENT_NOCHANGE') . '</option>',
|
||||
'<option value="0">' . Text::_('COM_BANNERS_NO_CLIENT') . '</option>',
|
||||
HTMLHelper::_('select.options', static::clientlist(), 'value', 'text'),
|
||||
'</select>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function clientlist()
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('id', 'value'),
|
||||
$db->quoteName('name', 'text'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__banner_clients'))
|
||||
->order($db->quoteName('name'));
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$options = $db->loadObjectList();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pinned state on a grid
|
||||
*
|
||||
* @param integer $value The state value.
|
||||
* @param integer $i The row index
|
||||
* @param boolean $enabled An optional setting for access control on the action.
|
||||
* @param string $checkbox An optional prefix for checkboxes.
|
||||
*
|
||||
* @return string The Html code
|
||||
*
|
||||
* @see HTMLHelperJGrid::state
|
||||
* @since 2.5.5
|
||||
*/
|
||||
public function pinned($value, $i, $enabled = true, $checkbox = 'cb')
|
||||
{
|
||||
$states = [
|
||||
1 => [
|
||||
'sticky_unpublish',
|
||||
'COM_BANNERS_BANNERS_PINNED',
|
||||
'COM_BANNERS_BANNERS_HTML_UNPIN_BANNER',
|
||||
'COM_BANNERS_BANNERS_PINNED',
|
||||
true,
|
||||
'publish',
|
||||
'publish',
|
||||
],
|
||||
0 => [
|
||||
'sticky_publish',
|
||||
'COM_BANNERS_BANNERS_UNPINNED',
|
||||
'COM_BANNERS_BANNERS_HTML_PIN_BANNER',
|
||||
'COM_BANNERS_BANNERS_UNPINNED',
|
||||
true,
|
||||
'unpublish',
|
||||
'unpublish',
|
||||
],
|
||||
];
|
||||
|
||||
return HTMLHelper::_('jgrid.state', $states, $value, $i, 'banners.', $enabled, true, $checkbox);
|
||||
}
|
||||
}
|
||||
360
administrator/components/com_banners/src/Table/BannerTable.php
Normal file
360
administrator/components/com_banners/src/Table/BannerTable.php
Normal file
@ -0,0 +1,360 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Versioning\VersionableTableInterface;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Banner table
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class BannerTable extends Table implements VersionableTableInterface
|
||||
{
|
||||
/**
|
||||
* Indicates that columns fully support the NULL value in the database
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
* @param ?DispatcherInterface $dispatcher Event dispatcher for this table
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->typeAlias = 'com_banners.banner';
|
||||
|
||||
parent::__construct('#__banners', 'id', $db, $dispatcher);
|
||||
|
||||
$this->created = Factory::getDate()->toSql();
|
||||
$this->setColumnAlias('published', 'state');
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase click count
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clicks()
|
||||
{
|
||||
$id = (int) $this->id;
|
||||
$query = $this->_db->getQuery(true)
|
||||
->update($this->_db->quoteName('#__banners'))
|
||||
->set($this->_db->quoteName('clicks') . ' = ' . $this->_db->quoteName('clicks') . ' + 1')
|
||||
->where($this->_db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $id, ParameterType::INTEGER);
|
||||
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @see Table::check
|
||||
* @since 1.5
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
try {
|
||||
parent::check();
|
||||
} catch (\Exception $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set name
|
||||
$this->name = htmlspecialchars_decode($this->name, ENT_QUOTES);
|
||||
|
||||
// Set alias
|
||||
if (trim($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;
|
||||
}
|
||||
|
||||
// Set created date if not set.
|
||||
if (!(int) $this->created) {
|
||||
$this->created = Factory::getDate()->toSql();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if (!\is_null($this->publish_down) && !\is_null($this->publish_up) && $this->publish_down < $this->publish_up) {
|
||||
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set ordering
|
||||
if ($this->state < 0) {
|
||||
// Set ordering to 0 if state is archived or trashed
|
||||
$this->ordering = 0;
|
||||
} elseif (empty($this->ordering)) {
|
||||
// Set ordering to last if ordering was 0
|
||||
$this->ordering = self::getNextOrder($this->_db->quoteName('catid') . ' = ' . ((int) $this->catid) . ' AND ' . $this->_db->quoteName('state') . ' >= 0');
|
||||
}
|
||||
|
||||
// Set modified to created if not set
|
||||
if (!$this->modified) {
|
||||
$this->modified = $this->created;
|
||||
}
|
||||
|
||||
// Set modified_by to created_by if not set
|
||||
if (empty($this->modified_by)) {
|
||||
$this->modified_by = $this->created_by;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded bind function
|
||||
*
|
||||
* @param mixed $array An associative array or object to bind to the \Joomla\CMS\Table\Table instance.
|
||||
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function bind($array, $ignore = [])
|
||||
{
|
||||
if (isset($array['params']) && \is_array($array['params'])) {
|
||||
$registry = new Registry($array['params']);
|
||||
|
||||
if ((int) $registry->get('width', 0) < 0) {
|
||||
$this->setError(Text::sprintf('JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED', Text::_('COM_BANNERS_FIELD_WIDTH_LABEL')));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((int) $registry->get('height', 0) < 0) {
|
||||
$this->setError(Text::sprintf('JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED', Text::_('COM_BANNERS_FIELD_HEIGHT_LABEL')));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Converts the width and height to an absolute numeric value:
|
||||
$width = abs((int) $registry->get('width', 0));
|
||||
$height = abs((int) $registry->get('height', 0));
|
||||
|
||||
// Sets the width and height to an empty string if = 0
|
||||
$registry->set('width', $width ?: '');
|
||||
$registry->set('height', $height ?: '');
|
||||
|
||||
$array['params'] = (string) $registry;
|
||||
}
|
||||
|
||||
if (isset($array['imptotal'])) {
|
||||
$array['imptotal'] = abs((int) $array['imptotal']);
|
||||
}
|
||||
|
||||
return parent::bind($array, $ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to store a row
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success, false on failure.
|
||||
*/
|
||||
public function store($updateNulls = true)
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
|
||||
if (empty($this->id)) {
|
||||
$purchaseType = $this->purchase_type;
|
||||
|
||||
if ($purchaseType < 0 && $this->cid) {
|
||||
$client = new ClientTable($db);
|
||||
$client->load($this->cid);
|
||||
$purchaseType = $client->purchase_type;
|
||||
}
|
||||
|
||||
if ($purchaseType < 0) {
|
||||
$purchaseType = ComponentHelper::getParams('com_banners')->get('purchase_type');
|
||||
}
|
||||
|
||||
switch ($purchaseType) {
|
||||
case 1:
|
||||
$this->reset = null;
|
||||
break;
|
||||
case 2:
|
||||
$date = Factory::getDate('+1 year ' . date('Y-m-d'));
|
||||
$this->reset = $date->toSql();
|
||||
break;
|
||||
case 3:
|
||||
$date = Factory::getDate('+1 month ' . date('Y-m-d'));
|
||||
$this->reset = $date->toSql();
|
||||
break;
|
||||
case 4:
|
||||
$date = Factory::getDate('+7 day ' . date('Y-m-d'));
|
||||
$this->reset = $date->toSql();
|
||||
break;
|
||||
case 5:
|
||||
$date = Factory::getDate('+1 day ' . date('Y-m-d'));
|
||||
$this->reset = $date->toSql();
|
||||
break;
|
||||
}
|
||||
|
||||
// Store the row
|
||||
parent::store($updateNulls);
|
||||
} else {
|
||||
// Get the old row
|
||||
$oldrow = new self($db, $this->getDispatcher());
|
||||
|
||||
if (!$oldrow->load($this->id) && $oldrow->getError()) {
|
||||
$this->setError($oldrow->getError());
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = new self($db, $this->getDispatcher());
|
||||
|
||||
if ($table->load(['alias' => $this->alias, 'catid' => $this->catid]) && ($table->id != $this->id || $this->id == 0)) {
|
||||
$this->setError(Text::_('COM_BANNERS_ERROR_UNIQUE_ALIAS'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the new row
|
||||
parent::store($updateNulls);
|
||||
|
||||
// Need to reorder ?
|
||||
if ($oldrow->state >= 0 && ($this->state < 0 || $oldrow->catid != $this->catid)) {
|
||||
// Reorder the oldrow
|
||||
$this->reorder($this->_db->quoteName('catid') . ' = ' . ((int) $oldrow->catid) . ' AND ' . $this->_db->quoteName('state') . ' >= 0');
|
||||
}
|
||||
}
|
||||
|
||||
return \count($this->getErrors()) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the sticky state for a row or list of rows in the database
|
||||
* table. The method respects checked out rows by other users and will attempt
|
||||
* to checkin rows that it can after adjustments are made.
|
||||
*
|
||||
* @param mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
|
||||
* @param integer $state The sticky state. eg. [0 = unsticked, 1 = sticked]
|
||||
* @param integer $userId The user id of the user performing the operation.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function stick($pks = null, $state = 1, $userId = 0)
|
||||
{
|
||||
$k = $this->_tbl_key;
|
||||
|
||||
// Sanitize input.
|
||||
$pks = ArrayHelper::toInteger($pks);
|
||||
$userId = (int) $userId;
|
||||
$state = (int) $state;
|
||||
|
||||
// If there are no primary keys set check to see if the instance key is set.
|
||||
if (empty($pks)) {
|
||||
if ($this->$k) {
|
||||
$pks = [$this->$k];
|
||||
} else {
|
||||
// Nothing to set publishing state on, return false.
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Get an instance of the table
|
||||
$table = new self($this->getDbo(), $this->getDispatcher());
|
||||
|
||||
// For all keys
|
||||
foreach ($pks as $pk) {
|
||||
// Load the banner
|
||||
if (!$table->load($pk)) {
|
||||
$this->setError($table->getError());
|
||||
}
|
||||
|
||||
// Verify checkout
|
||||
if (\is_null($table->checked_out) || $table->checked_out == $userId) {
|
||||
// Change the state
|
||||
$table->sticky = $state;
|
||||
$table->checked_out = null;
|
||||
$table->checked_out_time = null;
|
||||
|
||||
// Check the row
|
||||
$table->check();
|
||||
|
||||
// Store the row
|
||||
if (!$table->store()) {
|
||||
$this->setError($table->getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return \count($this->getErrors()) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
101
administrator/components/com_banners/src/Table/ClientTable.php
Normal file
101
administrator/components/com_banners/src/Table/ClientTable.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Banners\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Versioning\VersionableTableInterface;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Client table
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ClientTable extends Table implements VersionableTableInterface
|
||||
{
|
||||
/**
|
||||
* Indicates that columns fully support the NULL value in the database
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
* @param ?DispatcherInterface $dispatcher Event dispatcher for this table
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->typeAlias = 'com_banners.client';
|
||||
|
||||
$this->setColumnAlias('published', 'state');
|
||||
|
||||
parent::__construct('#__banner_clients', 'id', $db, $dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean True if the object is ok
|
||||
*
|
||||
* @see Table::check()
|
||||
* @since 4.0.0
|
||||
*/
|
||||
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_BANNERS_WARNING_PROVIDE_VALID_NAME'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for valid contact
|
||||
if (trim($this->contact) === '') {
|
||||
$this->setError(Text::_('COM_BANNERS_PROVIDE_VALID_CONTACT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Banner;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
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;
|
||||
use Joomla\Component\Banners\Administrator\Model\BannerModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to edit a banner.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The Form object
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* The active item
|
||||
*
|
||||
* @var object
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var object
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var BannerModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->form = $model->getForm();
|
||||
$this->item = $model->getItem();
|
||||
$this->state = $model->getState();
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->id;
|
||||
$isNew = ($this->item->id == 0);
|
||||
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
// Since we don't track these assets at the item level, use the category id.
|
||||
$canDo = ContentHelper::getActions('com_banners', 'category', $this->item->catid);
|
||||
|
||||
ToolbarHelper::title($isNew ? Text::_('COM_BANNERS_MANAGER_BANNER_NEW') : Text::_('COM_BANNERS_MANAGER_BANNER_EDIT'), 'bookmark banners');
|
||||
|
||||
// If not checked out, can save the item.
|
||||
if (!$checkedOut && ($canDo->get('core.edit') || \count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0)) {
|
||||
$toolbar->apply('banner.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_banners', 'core.create')) > 0)) {
|
||||
$childBar->save('banner.save');
|
||||
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save2new('banner.save2new');
|
||||
}
|
||||
}
|
||||
|
||||
// If an existing item, can save to a copy.
|
||||
if (!$isNew && $canDo->get('core.create')) {
|
||||
$childBar->save2copy('banner.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (empty($this->item->id)) {
|
||||
$toolbar->cancel('banner.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
$toolbar->cancel('banner.cancel');
|
||||
|
||||
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) {
|
||||
$toolbar->versions('com_banners.banner', $this->item->id);
|
||||
}
|
||||
}
|
||||
|
||||
$toolbar->divider();
|
||||
$toolbar->help('Banners:_Edit');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Banners;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
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\Pagination\Pagination;
|
||||
use Joomla\CMS\Toolbar\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Banners\Administrator\Model\BannersModel;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of banners.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The search tools form
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.6
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
public $activeFilters = [];
|
||||
|
||||
/**
|
||||
* Category data
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $categories = [];
|
||||
|
||||
/**
|
||||
* An array of items
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var Pagination
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var Registry
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Is this view an Empty State
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private $isEmptyState = false;
|
||||
|
||||
/**
|
||||
* Method to display the view.
|
||||
*
|
||||
* @param string $tpl A template file to load. [optional]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var BannersModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->categories = $model->getCategoryOrders();
|
||||
$this->items = $model->getItems();
|
||||
$this->pagination = $model->getPagination();
|
||||
$this->state = $model->getState();
|
||||
$this->filterForm = $model->getFilterForm();
|
||||
$this->activeFilters = $model->getActiveFilters();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
$canDo = ContentHelper::getActions('com_banners', 'category', $this->state->get('filter.category_id'));
|
||||
$user = $this->getCurrentUser();
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_BANNERS'), 'bookmark banners');
|
||||
|
||||
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0) {
|
||||
$toolbar->addNew('banner.add');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')))) {
|
||||
/** @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();
|
||||
|
||||
if ($canDo->get('core.edit.state')) {
|
||||
if ($this->state->get('filter.published') != 2) {
|
||||
$childBar->publish('banners.publish')->listCheck(true);
|
||||
|
||||
$childBar->unpublish('banners.unpublish')->listCheck(true);
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') != -1) {
|
||||
if ($this->state->get('filter.published') != 2) {
|
||||
$childBar->archive('banners.archive')->listCheck(true);
|
||||
} elseif ($this->state->get('filter.published') == 2) {
|
||||
$childBar->publish('publish')->task('banners.publish')->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
$childBar->checkin('banners.checkin');
|
||||
|
||||
if ($this->state->get('filter.published') != -2) {
|
||||
$childBar->trash('banners.trash')->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('banners.delete', 'JTOOLBAR_EMPTY_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
// Add a batch button
|
||||
if (
|
||||
$user->authorise('core.create', 'com_banners')
|
||||
&& $user->authorise('core.edit', 'com_banners')
|
||||
&& $user->authorise('core.edit.state', 'com_banners')
|
||||
) {
|
||||
$childBar->popupButton('batch', 'JTOOLBAR_BATCH')
|
||||
->selector('collapseModal')
|
||||
->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->authorise('core.admin', 'com_banners') || $user->authorise('core.options', 'com_banners')) {
|
||||
$toolbar->preferences('com_banners');
|
||||
}
|
||||
|
||||
$toolbar->help('Banners');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Client;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
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\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Banners\Administrator\Model\ClientModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to edit a client.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The Form object
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* The active item
|
||||
*
|
||||
* @var CMSObject
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Object containing permissions for the item
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
* @since 1.5
|
||||
*/
|
||||
protected $canDo;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var ClientModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->form = $model->getForm();
|
||||
$this->item = $model->getItem();
|
||||
$this->state = $model->getState();
|
||||
$this->canDo = ContentHelper::getActions('com_banners');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
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->id);
|
||||
$canDo = $this->canDo;
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(
|
||||
$isNew ? Text::_('COM_BANNERS_MANAGER_CLIENT_NEW') : Text::_('COM_BANNERS_MANAGER_CLIENT_EDIT'),
|
||||
'bookmark banners-clients'
|
||||
);
|
||||
|
||||
// If not checked out, can save the item.
|
||||
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
|
||||
$toolbar->apply('client.apply');
|
||||
}
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($checkedOut, $canDo, $isNew) {
|
||||
// If not checked out, can save the item.
|
||||
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
|
||||
$childBar->save('client.save');
|
||||
}
|
||||
|
||||
if (!$checkedOut && $canDo->get('core.create')) {
|
||||
$childBar->save2new('client.save2new');
|
||||
}
|
||||
|
||||
// If an existing item, can save to a copy.
|
||||
if (!$isNew && $canDo->get('core.create')) {
|
||||
$childBar->save2copy('client.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (empty($this->item->id)) {
|
||||
$toolbar->cancel('client.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
$toolbar->cancel('client.cancel');
|
||||
|
||||
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) {
|
||||
$toolbar->versions('com_banners.client', $this->item->id);
|
||||
}
|
||||
}
|
||||
|
||||
$toolbar->divider();
|
||||
$toolbar->help('Banners:_New_or_Edit_Client');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Clients;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Pagination\Pagination;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Banners\Administrator\Model\ClientsModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of clients.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The search tools form
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.6
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
public $activeFilters = [];
|
||||
|
||||
/**
|
||||
* An array of items
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var 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;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var ClientsModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->items = $model->getItems();
|
||||
$this->pagination = $model->getPagination();
|
||||
$this->state = $model->getState();
|
||||
$this->filterForm = $model->getFilterForm();
|
||||
$this->activeFilters = $model->getActiveFilters();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
$canDo = ContentHelper::getActions('com_banners');
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_CLIENTS'), 'bookmark banners-clients');
|
||||
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbar->addNew('client.add');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $canDo->get('core.admin'))) {
|
||||
$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('clients.publish')->listCheck(true);
|
||||
$childBar->unpublish('clients.unpublish')->listCheck(true);
|
||||
$childBar->archive('clients.archive')->listCheck(true);
|
||||
|
||||
if ($canDo->get('core.admin')) {
|
||||
$childBar->checkin('clients.checkin')->listCheck(true);
|
||||
}
|
||||
|
||||
if (!$this->state->get('filter.state') == -2) {
|
||||
$childBar->trash('clients.trash')->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $this->state->get('filter.state') == -2 && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('clients.delete', 'JTOOLBAR_EMPTY_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
|
||||
$toolbar->preferences('com_banners');
|
||||
}
|
||||
|
||||
$toolbar->help('Banners:_Clients');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Download;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\Component\Banners\Administrator\Model\DownloadModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for download a list of tracks.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The Form object
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var DownloadModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->form = $model->getForm();
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Tracks;
|
||||
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Pagination\Pagination;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Banners\Administrator\Model\TracksModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of tracks.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The search tools form
|
||||
*
|
||||
* @var Form
|
||||
* @since 1.6
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
public $activeFilters = [];
|
||||
|
||||
/**
|
||||
* An array of items
|
||||
*
|
||||
* @var array
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var 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;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var TracksModel $model */
|
||||
$model = $this->getModel();
|
||||
$this->items = $model->getItems();
|
||||
$this->pagination = $model->getPagination();
|
||||
$this->state = $model->getState();
|
||||
$this->filterForm = $model->getFilterForm();
|
||||
$this->activeFilters = $model->getActiveFilters();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
$canDo = ContentHelper::getActions('com_banners', 'category', $this->state->get('filter.category_id'));
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_TRACKS'), 'bookmark banners-tracks');
|
||||
|
||||
if (!$this->isEmptyState) {
|
||||
$toolbar->popupButton()
|
||||
->url(Route::_('index.php?option=com_banners&view=download&tmpl=component'))
|
||||
->text('JTOOLBAR_EXPORT')
|
||||
->selector('downloadModal')
|
||||
->icon('icon-download')
|
||||
->footer('<button class="btn btn-secondary" data-bs-dismiss="modal" type="button"'
|
||||
. ' onclick="window.parent.Joomla.Modal.getCurrent().close();">'
|
||||
. Text::_('COM_BANNERS_CANCEL') . '</button>'
|
||||
. '<button class="btn btn-success" type="button"'
|
||||
. ' onclick="Joomla.iframeButtonClick({iframeSelector: \'#downloadModal\', buttonSelector: \'#exportBtn\'})">'
|
||||
. Text::_('COM_BANNERS_TRACKS_EXPORT') . '</button>');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('tracks.delete', 'COM_BANNERS_TRACKS_DELETE')
|
||||
->message('COM_BANNERS_DELETE_MSG')
|
||||
->listCheck(false);
|
||||
}
|
||||
|
||||
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
|
||||
$toolbar->preferences('com_banners');
|
||||
}
|
||||
|
||||
$toolbar->help('Banners:_Tracks');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Banners\Administrator\View\Tracks;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\Component\Banners\Administrator\Model\TracksModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of tracks.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class RawView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* Display the view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var TracksModel $model */
|
||||
$model = $this->getModel();
|
||||
$basename = $model->getBaseName();
|
||||
$fileType = $model->getFileType();
|
||||
$mimeType = $model->getMimeType();
|
||||
$content = $model->getContent();
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$this->getDocument()->setMimeEncoding($mimeType);
|
||||
|
||||
/** @var CMSApplication $app */
|
||||
$app = Factory::getApplication();
|
||||
$app->setHeader(
|
||||
'Content-disposition',
|
||||
'attachment; filename="' . $basename . '.' . $fileType . '"; creation-date="' . Factory::getDate()->toRFC822() . '"',
|
||||
true
|
||||
);
|
||||
echo $content;
|
||||
}
|
||||
}
|
||||
91
administrator/components/com_banners/tmpl/banner/edit.php
Normal file
91
administrator/components/com_banners/tmpl/banner/edit.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Banner\HtmlView $this */
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate')
|
||||
->useScript('com_banners.admin-banner-edit');
|
||||
|
||||
?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_banners&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="banner-form" aria-label="<?php echo Text::_('COM_BANNERS_BANNER_' . ((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', Text::_('COM_BANNERS_BANNER_DETAILS')); ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
<?php echo $this->form->renderField('type'); ?>
|
||||
<div id="image">
|
||||
<?php echo $this->form->renderFieldset('image'); ?>
|
||||
</div>
|
||||
<div id="custom">
|
||||
<?php echo $this->form->renderField('custombannercode'); ?>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->form->renderField('clickurl');
|
||||
echo $this->form->renderField('description');
|
||||
?>
|
||||
</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', 'otherparams', Text::_('COM_BANNERS_GROUP_LABEL_BANNER_DETAILS')); ?>
|
||||
<fieldset id="fieldset-otherparams" class="options-form">
|
||||
<legend><?php echo Text::_('COM_BANNERS_GROUP_LABEL_BANNER_DETAILS'); ?></legend>
|
||||
<div>
|
||||
<?php echo $this->form->renderFieldset('otherparams'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?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 $this->form->renderFieldset('metadata'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
203
administrator/components/com_banners/tmpl/banners/default.php
Normal file
203
administrator/components/com_banners/tmpl/banners/default.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Banners\HtmlView $this */
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('table.columns')
|
||||
->useScript('multiselect');
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->get('id');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$saveOrder = $listOrder == 'a.ordering';
|
||||
|
||||
if ($saveOrder && !empty($this->items)) {
|
||||
$saveOrderingUrl = 'index.php?option=com_banners&task=banners.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
HTMLHelper::_('draggablelist.draggable');
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_banners&view=banners'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php
|
||||
// Search tools bar
|
||||
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="bannerList">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_BANNERS_BANNERS_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-1 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_NAME', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 text-center d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_STICKY', 'a.sticky', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CLIENT', 'client_name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_IMPRESSIONS', 'impmade', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CLICKS', 'clicks', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'a.language', $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 == 'ordering');
|
||||
$item->cat_link = Route::_('index.php?option=com_categories&extension=com_banners&task=edit&type=other&cid[]=' . $item->catid);
|
||||
$canCreate = $user->authorise('core.create', 'com_banners.category.' . $item->catid);
|
||||
$canEdit = $user->authorise('core.edit', 'com_banners.category.' . $item->catid);
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out);
|
||||
$canChange = $user->authorise('core.edit.state', 'com_banners.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->state, $i, 'banners.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
|
||||
</td>
|
||||
<th scope="row">
|
||||
<div class="break-word">
|
||||
<?php if ($item->checked_out) : ?>
|
||||
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'banners.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit) : ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_banners&task=banner.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 break-word">
|
||||
<?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="text-center d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('banner.pinned', $item->sticky, $i, $canChange); ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->client_name; ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo Text::sprintf('COM_BANNERS_IMPRESSIONS', $item->impmade, $item->imptotal ?: Text::_('COM_BANNERS_UNLIMITED')); ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->clicks; ?> -
|
||||
<?php echo sprintf('%.2f%%', $item->impmade ? 100 * $item->clicks / $item->impmade : 0); ?>
|
||||
</td>
|
||||
<?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 $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php // Load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php // Load the batch processing form. ?>
|
||||
<?php
|
||||
if (
|
||||
$user->authorise('core.create', 'com_banners')
|
||||
&& $user->authorise('core.edit', 'com_banners')
|
||||
&& $user->authorise('core.edit.state', 'com_banners')
|
||||
) : ?>
|
||||
<?php echo HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'collapseModal',
|
||||
[
|
||||
'title' => Text::_('COM_BANNERS_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,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Banners\HtmlView $this */
|
||||
|
||||
$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 HTMLHelper::_('banner.clients'); ?>
|
||||
</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_banners']); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Banners\HtmlView $this */
|
||||
|
||||
?>
|
||||
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-client-id').value='';document.getElementById('batch-language-id').value=''" data-bs-dismiss="modal">
|
||||
<?php echo Text::_('JCANCEL'); ?>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('banner.batch');return false;">
|
||||
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
|
||||
</button>
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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_BANNERS',
|
||||
'formURL' => 'index.php?option=com_banners&view=banners',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help40:Banners',
|
||||
'icon' => 'icon-bookmark banners',
|
||||
];
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ($user->authorise('core.create', 'com_banners') || count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0) {
|
||||
$displayData['createURL'] = 'index.php?option=com_banners&task=banner.add';
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
||||
70
administrator/components/com_banners/tmpl/client/edit.php
Normal file
70
administrator/components/com_banners/tmpl/client/edit.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Client\HtmlView $this */
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate');
|
||||
|
||||
?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_banners&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="client-form" aria-label="<?php echo Text::_('COM_BANNERS_CLIENT_' . ((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' => 'general', 'recall' => true, 'breakpoint' => 768]); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'general', empty($this->item->id) ? Text::_('COM_BANNERS_NEW_CLIENT') : Text::_('COM_BANNERS_EDIT_CLIENT')); ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
<?php
|
||||
echo $this->form->renderField('contact');
|
||||
echo $this->form->renderField('email');
|
||||
echo $this->form->renderField('purchase_type');
|
||||
echo $this->form->renderField('track_impressions');
|
||||
echo $this->form->renderField('track_clicks');
|
||||
echo $this->form->renderFieldset('extra');
|
||||
?>
|
||||
</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', 'metadata', Text::_('JGLOBAL_FIELDSET_METADATA_OPTIONS')); ?>
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-6">
|
||||
<fieldset id="fieldset-metadata" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_METADATA_OPTIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo $this->form->renderFieldset('metadata'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
190
administrator/components/com_banners/tmpl/clients/default.php
Normal file
190
administrator/components/com_banners/tmpl/clients/default.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Clients\HtmlView $this */
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->getDocument()->getWebAssetManager();
|
||||
$wa->useScript('table.columns')
|
||||
->useScript('multiselect');
|
||||
|
||||
$purchaseTypes = [
|
||||
'1' => 'UNLIMITED',
|
||||
'2' => 'YEARLY',
|
||||
'3' => 'MONTHLY',
|
||||
'4' => 'WEEKLY',
|
||||
'5' => 'DAILY',
|
||||
];
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->get('id');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$params = $this->state->get('params') ?? new Registry();
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_banners&view=clients'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php
|
||||
// Search tools bar
|
||||
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">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_BANNERS_CLIENTS_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">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CLIENT', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-15 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CONTACT', 'a.contact', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-3 text-center d-none d-md-table-cell">
|
||||
<span class="icon-check" aria-hidden="true" title="<?php echo Text::_('COM_BANNERS_COUNT_PUBLISHED_ITEMS'); ?>"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('COM_BANNERS_COUNT_PUBLISHED_ITEMS'); ?></span>
|
||||
</th>
|
||||
<th scope="col" class="w-3 text-center d-none d-md-table-cell">
|
||||
<span class="icon-times" aria-hidden="true" title="<?php echo Text::_('COM_BANNERS_COUNT_UNPUBLISHED_ITEMS'); ?>"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('COM_BANNERS_COUNT_UNPUBLISHED_ITEMS'); ?></span>
|
||||
</th>
|
||||
<th scope="col" class="w-3 text-center d-none d-md-table-cell">
|
||||
<span class="icon-folder icon-fw" aria-hidden="true" title="<?php echo Text::_('COM_BANNERS_COUNT_ARCHIVED_ITEMS'); ?>"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('COM_BANNERS_COUNT_ARCHIVED_ITEMS'); ?></span>
|
||||
</th>
|
||||
<th scope="col" class="w-3 text-center d-none d-md-table-cell">
|
||||
<span class="icon-trash" aria-hidden="true" title="<?php echo Text::_('COM_BANNERS_COUNT_TRASHED_ITEMS'); ?>"></span>
|
||||
<span class="visually-hidden"><?php echo Text::_('COM_BANNERS_COUNT_TRASHED_ITEMS'); ?></span>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_PURCHASETYPE', 'a.purchase_type', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-3 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) :
|
||||
$canCreate = $user->authorise('core.create', 'com_banners');
|
||||
$canEdit = $user->authorise('core.edit', 'com_banners');
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || is_null($item->checked_out);
|
||||
$canChange = $user->authorise('core.edit.state', 'com_banners') && $canCheckin;
|
||||
?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'clients.', $canChange); ?>
|
||||
</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, 'clients.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit) : ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_banners&task=client.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>
|
||||
</th>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->contact; ?>
|
||||
</td>
|
||||
<td class="text-center btns d-none d-md-table-cell itemnumber">
|
||||
<a class="btn <?php echo ($item->count_published > 0) ? 'btn-success' : 'btn-secondary'; ?>" href="<?php echo Route::_('index.php?option=com_banners&view=banners&filter[client_id]=' . (int) $item->id . '&filter[published]=1'); ?>"
|
||||
aria-describedby="tip-publish<?php echo $i; ?>">
|
||||
<?php echo $item->count_published; ?>
|
||||
</a>
|
||||
<div role="tooltip" id="tip-publish<?php echo $i; ?>">
|
||||
<?php echo Text::_('COM_BANNERS_COUNT_PUBLISHED_ITEMS'); ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center btns d-none d-md-table-cell itemnumber">
|
||||
<a class="btn <?php echo ($item->count_unpublished > 0) ? 'btn-danger' : 'btn-secondary'; ?>" href="<?php echo Route::_('index.php?option=com_banners&view=banners&filter[client_id]=' . (int) $item->id . '&filter[published]=0'); ?>"
|
||||
aria-describedby="tip-unpublish<?php echo $i; ?>">
|
||||
<?php echo $item->count_unpublished; ?>
|
||||
</a>
|
||||
<div role="tooltip" id="tip-unpublish<?php echo $i; ?>">
|
||||
<?php echo Text::_('COM_BANNERS_COUNT_UNPUBLISHED_ITEMS'); ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center btns d-none d-md-table-cell itemnumber">
|
||||
<a class="btn <?php echo ($item->count_archived > 0) ? 'btn-info' : 'btn-secondary'; ?>" href="<?php echo Route::_('index.php?option=com_banners&view=banners&filter[client_id]=' . (int) $item->id . '&filter[published]=2'); ?>"
|
||||
aria-describedby="tip-archived<?php echo $i; ?>">
|
||||
<?php echo $item->count_archived; ?>
|
||||
</a>
|
||||
<div role="tooltip" id="tip-archived<?php echo $i; ?>">
|
||||
<?php echo Text::_('COM_BANNERS_COUNT_ARCHIVED_ITEMS'); ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center btns d-none d-md-table-cell itemnumber">
|
||||
<a class="btn <?php echo ($item->count_trashed > 0) ? 'btn-dark' : 'btn-secondary'; ?>" href="<?php echo Route::_('index.php?option=com_banners&view=banners&filter[client_id]=' . (int) $item->id . '&filter[published]=-2'); ?>"
|
||||
aria-describedby="tip-trashed<?php echo $i; ?>">
|
||||
<?php echo $item->count_trashed; ?>
|
||||
</a>
|
||||
<div role="tooltip" id="tip-trashed<?php echo $i; ?>">
|
||||
<?php echo Text::_('COM_BANNERS_COUNT_TRASHED_ITEMS'); ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php if ($item->purchase_type < 0) : ?>
|
||||
<?php echo Text::sprintf('COM_BANNERS_DEFAULT', Text::_('COM_BANNERS_FIELD_VALUE_' . $purchaseTypes[$params->get('purchase_type')])); ?>
|
||||
<?php else : ?>
|
||||
<?php echo Text::_('COM_BANNERS_FIELD_VALUE_' . $purchaseTypes[$item->purchase_type]); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo $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">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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_BANNERS_CLIENT',
|
||||
'formURL' => 'index.php?option=com_banners&view=clients',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help40:Banners:_Clients',
|
||||
'icon' => 'icon-bookmark banners',
|
||||
];
|
||||
|
||||
if (count($this->getCurrentUser()->getAuthorisedCategories('com_banners', 'core.create')) > 0) {
|
||||
$displayData['createURL'] = 'index.php?option=com_banners&task=client.add';
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
||||
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Download\HtmlView $this */
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('form.validate');
|
||||
|
||||
?>
|
||||
<div class="container-popup">
|
||||
<form
|
||||
class="form-horizontal form-validate"
|
||||
id="download-form"
|
||||
name="adminForm"
|
||||
action="<?php echo Route::_('index.php?option=com_banners&task=tracks.display&format=raw&' . Session::getFormToken() . '=1'); ?>"
|
||||
method="post">
|
||||
|
||||
<?php foreach ($this->form->getFieldset() as $field) : ?>
|
||||
<?php echo $this->form->renderField($field->fieldname); ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<button class="visually-hidden"
|
||||
id="exportBtn"
|
||||
type="button"
|
||||
onclick="this.form.submit();window.top.setTimeout('window.parent.Joomla.Modal.getCurrent().close()', 700);">
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
99
administrator/components/com_banners/tmpl/tracks/default.php
Normal file
99
administrator/components/com_banners/tmpl/tracks/default.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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\HTML\HTMLHelper;
|
||||
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('table.columns');
|
||||
|
||||
/** @var \Joomla\Component\Banners\Administrator\View\Tracks\HtmlView $this */
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_banners&view=tracks'); ?>" 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">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_BANNERS_TRACKS_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="title">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_NAME', 'b.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-20">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_CLIENT', 'cl.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_TYPE', 'a.track_type', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_BANNERS_HEADING_COUNT', 'a.count', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JDATE', 'a.track_date', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<th scope="row">
|
||||
<?php echo $item->banner_name; ?>
|
||||
<div class="small">
|
||||
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
|
||||
</div>
|
||||
</th>
|
||||
<td>
|
||||
<?php echo $item->client_name; ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->track_type == 1 ? Text::_('COM_BANNERS_IMPRESSION') : Text::_('COM_BANNERS_CLICK'); ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo $item->count; ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('date', $item->track_date, Text::_('DATE_FORMAT_LC5')); ?>
|
||||
</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">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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_BANNERS_TRACKS',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help40:Banners:_Tracks',
|
||||
'icon' => 'icon-bookmark banners',
|
||||
];
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
||||
Reference in New Issue
Block a user