first commit
This commit is contained in:
35
administrator/components/com_contact/access.xml
Normal file
35
administrator/components/com_contact/access.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<access component="com_contact">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" />
|
||||
<action name="core.options" title="JACTION_OPTIONS" />
|
||||
<action name="core.manage" title="JACTION_MANAGE" />
|
||||
<action name="core.create" title="JACTION_CREATE" />
|
||||
<action name="core.delete" title="JACTION_DELETE" />
|
||||
<action name="core.edit" title="JACTION_EDIT" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||
<action name="core.edit.own" title="JACTION_EDITOWN" />
|
||||
<action name="core.edit.value" title="JACTION_EDITVALUE" />
|
||||
</section>
|
||||
<section name="category">
|
||||
<action name="core.create" title="JACTION_CREATE" />
|
||||
<action name="core.delete" title="JACTION_DELETE" />
|
||||
<action name="core.edit" title="JACTION_EDIT" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||
<action name="core.edit.own" title="JACTION_EDITOWN" />
|
||||
</section>
|
||||
<section name="fieldgroup">
|
||||
<action name="core.create" title="JACTION_CREATE" />
|
||||
<action name="core.delete" title="JACTION_DELETE" />
|
||||
<action name="core.edit" title="JACTION_EDIT" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||
<action name="core.edit.own" title="JACTION_EDITOWN" />
|
||||
<action name="core.edit.value" title="JACTION_EDITVALUE" />
|
||||
</section>
|
||||
<section name="field">
|
||||
<action name="core.delete" title="JACTION_DELETE" />
|
||||
<action name="core.edit" title="JACTION_EDIT" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" />
|
||||
<action name="core.edit.value" title="JACTION_EDITVALUE" />
|
||||
</section>
|
||||
</access>
|
||||
1041
administrator/components/com_contact/config.xml
Normal file
1041
administrator/components/com_contact/config.xml
Normal file
File diff suppressed because it is too large
Load Diff
65
administrator/components/com_contact/contact.xml
Normal file
65
administrator/components/com_contact/contact.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="component" method="upgrade">
|
||||
<name>com_contact</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_CONTACT_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Component\Contact</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>forms</folder>
|
||||
<folder>helpers</folder>
|
||||
<folder>layouts</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB/com_contact.ini</language>
|
||||
</languages>
|
||||
<media destination="com_contact" folder="media">
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
<administration>
|
||||
<menu img="class:address-book">COM_CONTACT</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_contact" img="class:contact"
|
||||
alt="Contact/Contacts">COM_CONTACT_CONTACTS</menu>
|
||||
<menu link="option=com_categories&extension=com_contact"
|
||||
view="categories" img="class:contact-cat" alt="Contacts/Categories">COM_CONTACT_CATEGORIES</menu>
|
||||
</submenu>
|
||||
<files folder="admin">
|
||||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
<filename>contact.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_contact.ini</language>
|
||||
<language tag="en-GB">language/en-GB/com_contact.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
||||
|
||||
5
administrator/components/com_contact/forms/category.xml
Normal file
5
administrator/components/com_contact/forms/category.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<help key="Contacts:_Edit_Category" />
|
||||
<listhelp key="Contacts:_Categories" />
|
||||
</form>
|
||||
798
administrator/components/com_contact/forms/contact.xml
Normal file
798
administrator/components/com_contact/forms/contact.xml
Normal file
@ -0,0 +1,798 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset addfieldprefix="Joomla\Component\Contact\Administrator\Field">
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
default="0"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_NAME_LABEL"
|
||||
required="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="alias"
|
||||
type="text"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
hint="JFIELD_ALIAS_PLACEHOLDER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="version_note"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
|
||||
maxlength="255"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="user_id"
|
||||
type="user"
|
||||
label="COM_CONTACT_FIELD_LINKED_USER_LABEL"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
default="1"
|
||||
class="form-select-color-state"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="2">JARCHIVED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="catid"
|
||||
type="categoryedit"
|
||||
label="JCATEGORY"
|
||||
extension="com_contact"
|
||||
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
|
||||
required="true"
|
||||
default=""
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
filter="UINT"
|
||||
validate="options"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="misc"
|
||||
type="editor"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_MISC_LABEL"
|
||||
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
|
||||
buttons="true"
|
||||
hide="readmore,pagebreak"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
|
||||
validate="UserId"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created_by_alias"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CREATED_BY_ALIAS_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_CONTACT_FIELD_CREATED_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<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="checked_out"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="checked_out_time"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="ordering"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
content_type="com_contact.contact"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_up"
|
||||
type="calendar"
|
||||
label="COM_CONTACT_FIELD_PUBLISH_UP_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="publish_down"
|
||||
type="calendar"
|
||||
label="COM_CONTACT_FIELD_PUBLISH_DOWN_LABEL"
|
||||
translateformat="true"
|
||||
showtime="true"
|
||||
filter="user_utc"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metakey"
|
||||
type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="metadesc"
|
||||
type="textarea"
|
||||
label="JFIELD_META_DESCRIPTION_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
maxlength="300"
|
||||
charcounter="true"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="featured"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="JFEATURED"
|
||||
default="0"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tags"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
class="advancedSelect"
|
||||
multiple="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="details" label="COM_CONTACT_CONTACT_DETAILS">
|
||||
<field
|
||||
name="image"
|
||||
type="media"
|
||||
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
|
||||
hide_none="1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="con_position"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_POSITION_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="email_to"
|
||||
type="email"
|
||||
label="JGLOBAL_EMAIL"
|
||||
validate="email"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="address"
|
||||
type="textarea"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_ADDRESS_LABEL"
|
||||
rows="3"
|
||||
cols="30"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="suburb"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_SUBURB_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="state"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_STATE_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="postcode"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_POSTCODE_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="country"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_COUNTRY_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="telephone"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_TELEPHONE_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="mobile"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_MOBILE_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="fax"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_FAX_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="webpage"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_INFORMATION_WEBPAGE_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="sortname1"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_SORTNAME1_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="sortname2"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_SORTNAME2_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="sortname3"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_SORTNAME3_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fields name="params">
|
||||
<fieldset name="display" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
|
||||
<fieldset name="basic" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
|
||||
<field
|
||||
name="show_contact_category"
|
||||
type="list"
|
||||
label="JGLOBAL_SHOW_CATEGORY_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="hide">JHIDE</option>
|
||||
<option value="show_no_link">COM_CONTACT_FIELD_VALUE_NO_LINK</option>
|
||||
<option value="show_with_link">COM_CONTACT_FIELD_VALUE_WITH_LINK</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_contact_list"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONTACT_SHOW_LIST_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_tags"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_TAGS_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_info"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_INFO_LABEL"
|
||||
class="form-select-color"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_name"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_NAME_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_position"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_CONTACT_POSITION_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email"
|
||||
type="list"
|
||||
label="JGLOBAL_EMAIL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="add_mailto_link"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_ADD_MAILTO_LINK_LABEL"
|
||||
class="form-select-color"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_street_address"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STREET_ADDRESS_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_suburb"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TOWN-SUBURB_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_state"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_STATE-COUNTY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_postcode"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_POST-ZIP_CODE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_country"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_COUNTRY_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_telephone"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_TELEPHONE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_mobile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MOBILE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_fax"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_FAX_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_webpage"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_WEBPAGE_LABEL"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_image"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_SHOW_IMAGE_LABEL"
|
||||
class="form-select-color"
|
||||
useglobal="true"
|
||||
showon="show_info:1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_misc"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_MISC_INFO_LABEL"
|
||||
class="form-select-color"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="allow_vcard"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PARAMS_VCARD_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_articles"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="articles_display_num"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_ARTICLES_DISPLAY_NUM_LABEL"
|
||||
default=""
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="5">J5</option>
|
||||
<option value="10">J10</option>
|
||||
<option value="15">J15</option>
|
||||
<option value="20">J20</option>
|
||||
<option value="25">J25</option>
|
||||
<option value="30">J30</option>
|
||||
<option value="50">J50</option>
|
||||
<option value="75">J75</option>
|
||||
<option value="100">J100</option>
|
||||
<option value="150">J150</option>
|
||||
<option value="200">J200</option>
|
||||
<option value="250">J250</option>
|
||||
<option value="300">J300</option>
|
||||
<option value="0">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_profile"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_PROFILE_SHOW_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_user_custom_fields"
|
||||
type="fieldgroups"
|
||||
label="COM_CONTACT_FIELD_USER_CUSTOM_FIELDS_SHOW_LABEL"
|
||||
multiple="true"
|
||||
context="com_users.user"
|
||||
addfieldprefix="Joomla\Component\Fields\Administrator\Field"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
>
|
||||
<option value="-1">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="contact_layout"
|
||||
type="componentlayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
extension="com_contact"
|
||||
view="contact"
|
||||
useglobal="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="link" label="JGLOBAL_FIELDSET_DISPLAY_LINK_OPTIONS">
|
||||
<field
|
||||
name="show_links"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_SHOW_LINKS_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="linka_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKA_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linka"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_LINKA_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkb_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKB_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkb"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_LINKB_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkc_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKC_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkc"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_LINKC_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkd_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKD_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linkd"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_LINKD_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linke_name"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_LINKE_NAME_LABEL"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="linke"
|
||||
type="url"
|
||||
label="COM_CONTACT_FIELD_LINKE_LABEL"
|
||||
filter="url"
|
||||
validate="url"
|
||||
/>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="email" label="COM_CONTACT_FIELDSET_CONTACT_LABEL">
|
||||
<fieldset name="form" label="COM_CONTACT_FIELDSET_FORM_LABEL">
|
||||
<field
|
||||
name="show_email_form"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_SHOW_FORM_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_email_copy"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_EMAIL_EMAIL_COPY_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="validate_session"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_SESSION_CHECK_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="custom_reply"
|
||||
type="list"
|
||||
label="COM_CONTACT_FIELD_CONFIG_CUSTOM_REPLY_LABEL"
|
||||
useglobal="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="redirect"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_CONFIG_REDIRECT_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<fields name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
<fieldset name="jmetadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
|
||||
<field
|
||||
name="robots"
|
||||
type="list"
|
||||
label="JFIELD_METADATA_ROBOTS_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="index, follow" />
|
||||
<option value="noindex, follow" />
|
||||
<option value="index, nofollow" />
|
||||
<option value="noindex, nofollow" />
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="rights"
|
||||
type="text"
|
||||
label="JFIELD_METADATA_RIGHTS_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
||||
<field
|
||||
name="hits"
|
||||
type="text"
|
||||
label="JGLOBAL_HITS"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
label="COM_CONTACT_FIELD_VERSION_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
</form>
|
||||
12
administrator/components/com_contact/forms/fields/mail.xml
Normal file
12
administrator/components/com_contact/forms/fields/mail.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="params" label="COM_FIELDS_FIELD_BASIC_LABEL">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="display"
|
||||
type="hidden"
|
||||
default="2"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
134
administrator/components/com_contact/forms/filter_contacts.xml
Normal file
134
administrator/components/com_contact/forms/filter_contacts.xml
Normal file
@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
|
||||
<fields name="filter">
|
||||
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_CONTACT_FILTER_SEARCH_LABEL"
|
||||
description="COM_CONTACT_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="featured"
|
||||
type="list"
|
||||
label="JFEATURED"
|
||||
class="js-select-submit-on-change"
|
||||
default=""
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_FEATURED</option>
|
||||
<option value="0">JUNFEATURED</option>
|
||||
<option value="1">JFEATURED</option>
|
||||
</field>
|
||||
|
||||
<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"
|
||||
multiple="true"
|
||||
extension="com_contact"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
hint="JOPTION_SELECT_CATEGORY"
|
||||
class="js-select-submit-on-change"
|
||||
published="0,1,2"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JGRID_HEADING_ACCESS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_ACCESS</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JGRID_HEADING_LANGUAGE"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_LANGUAGE</option>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="tag"
|
||||
type="tag"
|
||||
label="JTAG"
|
||||
multiple="true"
|
||||
mode="nested"
|
||||
custom="false"
|
||||
hint="JOPTION_SELECT_TAG"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="level"
|
||||
type="integer"
|
||||
label="JGLOBAL_MAXLEVEL_LABEL"
|
||||
first="1"
|
||||
last="10"
|
||||
step="1"
|
||||
languages="*"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_MAX_LEVELS</option>
|
||||
</field>
|
||||
</fields>
|
||||
|
||||
<fields name="list">
|
||||
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
default="a.name ASC"
|
||||
class="js-select-submit-on-change"
|
||||
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.featured ASC">JFEATURED_ASC</option>
|
||||
<option value="a.featured DESC">JFEATURED_DESC</option>
|
||||
<option value="a.published ASC">JSTATUS_ASC</option>
|
||||
<option value="a.published 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="ul.name ASC">COM_CONTACT_FIELD_LINKED_USER_LABEL_ASC</option>
|
||||
<option value="ul.name DESC">COM_CONTACT_FIELD_LINKED_USER_LABEL_DESC</option>
|
||||
<option value="access_level ASC">JGRID_HEADING_ACCESS_ASC</option>
|
||||
<option value="access_level DESC">JGRID_HEADING_ACCESS_DESC</option>
|
||||
<option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option>
|
||||
<option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option>
|
||||
<option value="language_title ASC" requires="multilanguage">JGRID_HEADING_LANGUAGE_ASC</option>
|
||||
<option value="language_title DESC" requires="multilanguage">JGRID_HEADING_LANGUAGE_DESC</option>
|
||||
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="25"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
||||
27
administrator/components/com_contact/helpers/contact.php
Normal file
27
administrator/components/com_contact/helpers/contact.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
*/
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact component helper.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @deprecated 4.3 will be removed in 6.0
|
||||
* Use \Joomla\Component\Contact\Administrator\Helper\ContactHelper instead
|
||||
*/
|
||||
class ContactHelper extends \Joomla\Component\Contact\Administrator\Helper\ContactHelper
|
||||
{
|
||||
}
|
||||
68
administrator/components/com_contact/services/provider.php
Normal file
68
administrator/components/com_contact/services/provider.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Association\AssociationExtensionInterface;
|
||||
use Joomla\CMS\Categories\CategoryFactoryInterface;
|
||||
use Joomla\CMS\Component\Router\RouterFactoryInterface;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
||||
use Joomla\CMS\Extension\ComponentInterface;
|
||||
use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
||||
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
|
||||
use Joomla\CMS\HTML\Registry;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
use Joomla\Component\Contact\Administrator\Extension\ContactComponent;
|
||||
use Joomla\Component\Contact\Administrator\Helper\AssociationsHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* The contact service provider.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(AssociationExtensionInterface::class, new AssociationsHelper());
|
||||
|
||||
$container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Contact'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Contact'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Contact'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\Joomla\\Component\\Contact'));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$component = new ContactComponent($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setRegistry($container->get(Registry::class));
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
|
||||
$component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,56 @@
|
||||
--
|
||||
-- Table structure for table `#__contact_details`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__contact_details` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||
`con_position` varchar(255),
|
||||
`address` text,
|
||||
`suburb` varchar(100),
|
||||
`state` varchar(100),
|
||||
`country` varchar(100),
|
||||
`postcode` varchar(100),
|
||||
`telephone` varchar(255),
|
||||
`fax` varchar(255),
|
||||
`misc` mediumtext,
|
||||
`image` varchar(255),
|
||||
`email_to` varchar(255),
|
||||
`default_con` tinyint unsigned NOT NULL DEFAULT 0,
|
||||
`published` tinyint NOT NULL DEFAULT 0,
|
||||
`checked_out` int unsigned NOT NULL DEFAULT 0,
|
||||
`checked_out_time` datetime,
|
||||
`ordering` int NOT NULL DEFAULT 0,
|
||||
`params` text NOT NULL,
|
||||
`user_id` int NOT NULL DEFAULT 0,
|
||||
`catid` int NOT NULL DEFAULT 0,
|
||||
`access` int unsigned NOT NULL DEFAULT 0,
|
||||
`mobile` varchar(255) NOT NULL DEFAULT '',
|
||||
`webpage` varchar(255) NOT NULL DEFAULT '',
|
||||
`sortname1` varchar(255) NOT NULL DEFAULT '',
|
||||
`sortname2` varchar(255) NOT NULL DEFAULT '',
|
||||
`sortname3` varchar(255) NOT NULL DEFAULT '',
|
||||
`language` varchar(7) NOT NULL,
|
||||
`created` datetime NOT NULL,
|
||||
`created_by` int unsigned NOT NULL DEFAULT 0,
|
||||
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
|
||||
`modified` datetime NOT NULL,
|
||||
`modified_by` int unsigned NOT NULL DEFAULT 0,
|
||||
`metakey` text NOT NULL,
|
||||
`metadesc` text NOT NULL,
|
||||
`metadata` text NOT NULL,
|
||||
`featured` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Set if contact is featured.',
|
||||
`publish_up` datetime,
|
||||
`publish_down` datetime,
|
||||
`version` int unsigned NOT NULL DEFAULT 1,
|
||||
`hits` int unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_state` (`published`),
|
||||
KEY `idx_catid` (`catid`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
KEY `idx_featured_catid` (`featured`,`catid`),
|
||||
KEY `idx_language` (`language`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
|
||||
@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS `#__contact_details`;
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* The contact controller for ajax requests
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
class AjaxController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Method to fetch associations of a contact
|
||||
*
|
||||
* The method assumes that the following http parameters are passed in an Ajax Get request:
|
||||
* token: the form token
|
||||
* assocId: the id of the contact whose associations are to be returned
|
||||
* excludeLang: the association for this language is to be excluded
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public function fetchAssociations()
|
||||
{
|
||||
if (!Session::checkToken('get')) {
|
||||
echo new JsonResponse(null, Text::_('JINVALID_TOKEN'), true);
|
||||
} else {
|
||||
$assocId = $this->input->getInt('assocId', 0);
|
||||
|
||||
if ($assocId == 0) {
|
||||
echo new JsonResponse(null, Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'assocId'), true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$excludeLang = $this->input->get('excludeLang', '', 'STRING');
|
||||
|
||||
$associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', (int) $assocId);
|
||||
|
||||
unset($associations[$excludeLang]);
|
||||
|
||||
// Add the title to each of the associated records
|
||||
$contactTable = $this->factory->createTable('Contact', 'Administrator');
|
||||
|
||||
foreach ($associations as $lang => $association) {
|
||||
$contactTable->load($association->id);
|
||||
$associations[$lang]->title = $contactTable->name;
|
||||
}
|
||||
|
||||
$countContentLanguages = \count(LanguageHelper::getContentLanguages([0, 1], false));
|
||||
|
||||
if (\count($associations) == 0) {
|
||||
$message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE');
|
||||
} elseif ($countContentLanguages > \count($associations) + 2) {
|
||||
$tags = implode(', ', array_keys($associations));
|
||||
$message = Text::sprintf('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME', $tags);
|
||||
} else {
|
||||
$message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL');
|
||||
}
|
||||
|
||||
echo new JsonResponse($associations, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
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
|
||||
|
||||
/**
|
||||
* Controller for a single contact
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactController extends FormController
|
||||
{
|
||||
use VersionableControllerTrait;
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = [])
|
||||
{
|
||||
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
|
||||
|
||||
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;
|
||||
|
||||
// Since there is no asset tracking, fallback to the component permissions.
|
||||
if (!$recordId) {
|
||||
return parent::allowEdit($data, $key);
|
||||
}
|
||||
|
||||
// Get the item.
|
||||
$item = $this->getModel()->getItem($recordId);
|
||||
|
||||
// Since there is no item, return false.
|
||||
if (empty($item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// Check if can edit own core.edit.own.
|
||||
$canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id;
|
||||
|
||||
// Check the category core.edit permissions.
|
||||
return $canEditOwn || $user->authorise('core.edit', $this->option . '.category.' . (int) $item->catid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param object $model The model.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function batch($model = null)
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
// Set the model
|
||||
/** @var \Joomla\Component\Contact\Administrator\Model\ContactModel $model */
|
||||
$model = $this->getModel('Contact', 'Administrator', []);
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(Route::_('index.php?option=com_contact&view=contacts' . $this->getRedirectToListAppend(), false));
|
||||
|
||||
return parent::batch($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data
|
||||
* after the data has been saved.
|
||||
*
|
||||
* @param BaseDatabaseModel $model The data model object.
|
||||
* @param array $validData The validated data.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
protected function postSaveHook(BaseDatabaseModel $model, $validData = [])
|
||||
{
|
||||
if ($this->getTask() === 'save2menu') {
|
||||
$editState = [];
|
||||
|
||||
$id = $model->getState('contact.id');
|
||||
|
||||
$link = 'index.php?option=com_contact&view=contact';
|
||||
$type = 'component';
|
||||
|
||||
$editState['id'] = $id;
|
||||
$editState['link'] = $link;
|
||||
$editState['title'] = $model->getItem($id)->name;
|
||||
$editState['type'] = $type;
|
||||
$editState['request']['id'] = $id;
|
||||
|
||||
$this->app->setUserState(
|
||||
'com_menus.edit.item',
|
||||
[
|
||||
'data' => $editState,
|
||||
'type' => $type,
|
||||
'link' => $link,
|
||||
]
|
||||
);
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_menus&view=item&client_id=0&menutype=mainmenu&layout=edit', false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\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
|
||||
|
||||
/**
|
||||
* Contacts list controller class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactsController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @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('unfeatured', 'featured');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to toggle the featured setting of a list of contacts.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function featured()
|
||||
{
|
||||
// Check for request forgeries
|
||||
$this->checkToken();
|
||||
|
||||
$ids = (array) $this->input->get('cid', [], 'int');
|
||||
$values = ['featured' => 1, 'unfeatured' => 0];
|
||||
$task = $this->getTask();
|
||||
$value = ArrayHelper::getValue($values, $task, 0, 'int');
|
||||
|
||||
// Get the model.
|
||||
/** @var \Joomla\Component\Contact\Administrator\Model\ContactModel $model */
|
||||
$model = $this->getModel();
|
||||
|
||||
// Access checks.
|
||||
foreach ($ids as $i => $id) {
|
||||
// Remove zero value resulting from input filter
|
||||
if ($id === 0) {
|
||||
unset($ids[$i]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = $model->getItem($id);
|
||||
|
||||
if (!$this->app->getIdentity()->authorise('core.edit.state', 'com_contact.category.' . (int) $item->catid)) {
|
||||
// Prune items that you can't change.
|
||||
unset($ids[$i]);
|
||||
$this->app->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($ids)) {
|
||||
$message = null;
|
||||
|
||||
$this->app->enqueueMessage(Text::_('COM_CONTACT_NO_ITEM_SELECTED'), 'warning');
|
||||
} else {
|
||||
// Publish the items.
|
||||
if (!$model->featured($ids, $value)) {
|
||||
$this->app->enqueueMessage($model->getError(), 'warning');
|
||||
}
|
||||
|
||||
if ($value == 1) {
|
||||
$message = Text::plural('COM_CONTACT_N_ITEMS_FEATURED', \count($ids));
|
||||
} else {
|
||||
$message = Text::plural('COM_CONTACT_N_ITEMS_UNFEATURED', \count($ids));
|
||||
}
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_contact&view=contacts', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy for getModel.
|
||||
*
|
||||
* @param string $name The name of the model.
|
||||
* @param string $prefix The prefix for the PHP class name.
|
||||
* @param array $config Array of configuration parameters.
|
||||
*
|
||||
* @return \Joomla\CMS\MVC\Model\BaseDatabaseModel
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getModel($name = 'Contact', $prefix = 'Administrator', $config = ['ignore_request' => true])
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the number of published contacts for quickicons
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function getQuickiconContent()
|
||||
{
|
||||
$model = $this->getModel('contacts');
|
||||
|
||||
$model->setState('filter.published', 1);
|
||||
|
||||
$amount = (int) $model->getTotal();
|
||||
|
||||
$result = [];
|
||||
|
||||
$result['amount'] = $amount;
|
||||
$result['sronly'] = Text::plural('COM_CONTACT_N_QUICKICON_SRONLY', $amount);
|
||||
$result['name'] = Text::plural('COM_CONTACT_N_QUICKICON', $amount);
|
||||
|
||||
echo new JsonResponse($result);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component Controller
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The default view.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'contacts';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe URL parameters and their variable types.
|
||||
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
|
||||
*
|
||||
* @return static |boolean This object to support chaining. False on failure.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = [])
|
||||
{
|
||||
$view = $this->input->get('view', $this->default_view);
|
||||
$layout = $this->input->get('layout', 'default');
|
||||
$id = $this->input->getInt('id');
|
||||
|
||||
// Check for edit form.
|
||||
if ($view == 'contact' && $layout == 'edit' && !$this->checkEditId('com_contact.edit.contact', $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_contact&view=contacts', false));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::display();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Extension;
|
||||
|
||||
use Joomla\CMS\Association\AssociationServiceInterface;
|
||||
use Joomla\CMS\Association\AssociationServiceTrait;
|
||||
use Joomla\CMS\Categories\CategoryServiceInterface;
|
||||
use Joomla\CMS\Categories\CategoryServiceTrait;
|
||||
use Joomla\CMS\Component\Router\RouterServiceInterface;
|
||||
use Joomla\CMS\Component\Router\RouterServiceTrait;
|
||||
use Joomla\CMS\Extension\BootableExtensionInterface;
|
||||
use Joomla\CMS\Extension\MVCComponent;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Fields\FieldsServiceInterface;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Schemaorg\SchemaorgServiceInterface;
|
||||
use Joomla\CMS\Schemaorg\SchemaorgServiceTrait;
|
||||
use Joomla\CMS\Tag\TagServiceInterface;
|
||||
use Joomla\CMS\Tag\TagServiceTrait;
|
||||
use Joomla\CMS\User\UserFactoryInterface;
|
||||
use Joomla\Component\Contact\Administrator\Service\HTML\AdministratorService;
|
||||
use Joomla\Component\Contact\Administrator\Service\HTML\Icon;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Component class for com_contact
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class ContactComponent extends MVCComponent implements
|
||||
BootableExtensionInterface,
|
||||
CategoryServiceInterface,
|
||||
FieldsServiceInterface,
|
||||
SchemaorgServiceInterface,
|
||||
AssociationServiceInterface,
|
||||
RouterServiceInterface,
|
||||
TagServiceInterface
|
||||
{
|
||||
use AssociationServiceTrait;
|
||||
use HTMLRegistryAwareTrait;
|
||||
use RouterServiceTrait;
|
||||
use SchemaorgServiceTrait;
|
||||
use CategoryServiceTrait, TagServiceTrait {
|
||||
CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait;
|
||||
CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* Booting the extension. This is the function to set up the environment of the extension like
|
||||
* registering new class loaders, etc.
|
||||
*
|
||||
* If required, some initial set up can be done from services of the container, eg.
|
||||
* registering HTML services.
|
||||
*
|
||||
* @param ContainerInterface $container The container
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function boot(ContainerInterface $container)
|
||||
{
|
||||
$this->getRegistry()->register('contactadministrator', new AdministratorService());
|
||||
$this->getRegistry()->register('contacticon', new Icon($container->get(UserFactoryInterface::class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid section for the given section. If it is not valid then null
|
||||
* is returned.
|
||||
*
|
||||
* @param string $section The section to get the mapping for
|
||||
* @param object $item The item
|
||||
*
|
||||
* @return string|null The new section
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function validateSection($section, $item = null)
|
||||
{
|
||||
if (Factory::getApplication()->isClient('site') && $section == 'contact' && $item instanceof Form) {
|
||||
// The contact form needs to be the mail section
|
||||
$section = 'mail';
|
||||
}
|
||||
|
||||
if (Factory::getApplication()->isClient('site') && ($section === 'category' || $section === 'form')) {
|
||||
// The contact form needs to be the mail section
|
||||
$section = 'contact';
|
||||
}
|
||||
|
||||
if ($section !== 'mail' && $section !== 'contact') {
|
||||
// We don't know other sections
|
||||
return null;
|
||||
}
|
||||
|
||||
return $section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns valid contexts
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getContexts(): array
|
||||
{
|
||||
Factory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
|
||||
|
||||
$contexts = [
|
||||
'com_contact.contact' => Text::_('COM_CONTACT_FIELDS_CONTEXT_CONTACT'),
|
||||
'com_contact.mail' => Text::_('COM_CONTACT_FIELDS_CONTEXT_MAIL'),
|
||||
'com_contact.categories' => Text::_('JCATEGORY'),
|
||||
];
|
||||
|
||||
return $contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the table for the count items functions for the given section.
|
||||
*
|
||||
* @param string $section The section
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getTableNameForSection(string $section = null)
|
||||
{
|
||||
return ($section === 'category' ? 'categories' : 'contact_details');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state column for the count items functions for the given section.
|
||||
*
|
||||
* @param string $section The section
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function getStateColumnForSection(string $section = null)
|
||||
{
|
||||
return 'published';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns valid contexts for schemaorg
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public function getSchemaorgContexts(): array
|
||||
{
|
||||
Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
|
||||
|
||||
$contexts = [
|
||||
'com_contact.contact' => Text::_('COM_CONTACT'),
|
||||
];
|
||||
|
||||
return $contexts;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Administrator\Field\Modal;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\FormField;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Supports a modal contact picker.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactField extends FormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'Modal_Contact';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$allowNew = ((string) $this->element['new'] == 'true');
|
||||
$allowEdit = ((string) $this->element['edit'] == 'true');
|
||||
$allowClear = ((string) $this->element['clear'] != 'false');
|
||||
$allowSelect = ((string) $this->element['select'] != 'false');
|
||||
$allowPropagate = ((string) $this->element['propagate'] == 'true');
|
||||
|
||||
$languages = LanguageHelper::getContentLanguages([0, 1], false);
|
||||
|
||||
// Load language
|
||||
Factory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
|
||||
|
||||
// The active contact id field.
|
||||
$value = (int) $this->value ?: '';
|
||||
|
||||
// Create the modal id.
|
||||
$modalId = 'Contact_' . $this->id;
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
|
||||
// Add the modal field script to the document head.
|
||||
$wa->useScript('field.modal-fields');
|
||||
|
||||
// Script to proxy the select modal function to the modal-fields.js file.
|
||||
if ($allowSelect) {
|
||||
static $scriptSelect = null;
|
||||
|
||||
if (\is_null($scriptSelect)) {
|
||||
$scriptSelect = [];
|
||||
}
|
||||
|
||||
if (!isset($scriptSelect[$this->id])) {
|
||||
$wa->addInlineScript(
|
||||
"
|
||||
window.jSelectContact_" . $this->id . " = function (id, title, object) {
|
||||
window.processModalSelect('Contact', '" . $this->id . "', id, title, '', object);
|
||||
}",
|
||||
[],
|
||||
['type' => 'module']
|
||||
);
|
||||
|
||||
Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
|
||||
|
||||
$scriptSelect[$this->id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup variables for display.
|
||||
$linkContacts = 'index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
$linkContact = 'index.php?option=com_contact&view=contact&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
$modalTitle = Text::_('COM_CONTACT_SELECT_A_CONTACT');
|
||||
|
||||
if (isset($this->element['language'])) {
|
||||
$linkContacts .= '&forcedLanguage=' . $this->element['language'];
|
||||
$linkContact .= '&forcedLanguage=' . $this->element['language'];
|
||||
$modalTitle .= ' — ' . $this->element['label'];
|
||||
}
|
||||
|
||||
$urlSelect = $linkContacts . '&function=jSelectContact_' . $this->id;
|
||||
$urlEdit = $linkContact . '&task=contact.edit&id=\' + document.getElementById("' . $this->id . '_id").value + \'';
|
||||
$urlNew = $linkContact . '&task=contact.add';
|
||||
|
||||
if ($value) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('name'))
|
||||
->from($db->quoteName('#__contact_details'))
|
||||
->where($db->quoteName('id') . ' = :id')
|
||||
->bind(':id', $value, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$title = $db->loadResult();
|
||||
} catch (\RuntimeException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
$title = empty($title) ? Text::_('COM_CONTACT_SELECT_A_CONTACT') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// The current contact display field.
|
||||
$html = '';
|
||||
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
|
||||
$html .= '<span class="input-group">';
|
||||
}
|
||||
|
||||
$html .= '<input class="form-control" id="' . $this->id . '_name" type="text" value="' . $title . '" readonly size="35">';
|
||||
|
||||
// Select contact button
|
||||
if ($allowSelect) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? ' hidden' : '') . '"'
|
||||
. ' id="' . $this->id . '_select"'
|
||||
. ' data-bs-toggle="modal"'
|
||||
. ' type="button"'
|
||||
. ' data-bs-target="#ModalSelect' . $modalId . '">'
|
||||
. '<span class="icon-file" aria-hidden="true"></span> ' . Text::_('JSELECT')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// New contact button
|
||||
if ($allowNew) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-secondary' . ($value ? ' hidden' : '') . '"'
|
||||
. ' id="' . $this->id . '_new"'
|
||||
. ' data-bs-toggle="modal"'
|
||||
. ' type="button"'
|
||||
. ' data-bs-target="#ModalNew' . $modalId . '">'
|
||||
. '<span class="icon-plus" aria-hidden="true"></span> ' . Text::_('JACTION_CREATE')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// Edit contact button
|
||||
if ($allowEdit) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' id="' . $this->id . '_edit"'
|
||||
. ' data-bs-toggle="modal"'
|
||||
. ' type="button"'
|
||||
. ' data-bs-target="#ModalEdit' . $modalId . '">'
|
||||
. '<span class="icon-pen-square" aria-hidden="true"></span> ' . Text::_('JACTION_EDIT')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// Clear contact button
|
||||
if ($allowClear) {
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' id="' . $this->id . '_clear"'
|
||||
. ' type="button"'
|
||||
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
|
||||
. '<span class="icon-times" aria-hidden="true"></span> ' . Text::_('JCLEAR')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
// Propagate contact button
|
||||
if ($allowPropagate && \count($languages) > 2) {
|
||||
// Strip off language tag at the end
|
||||
$tagLength = (int) \strlen($this->element['language']);
|
||||
$callbackFunctionStem = substr("jSelectContact_" . $this->id, 0, -$tagLength);
|
||||
|
||||
$html .= '<button'
|
||||
. ' class="btn btn-primary' . ($value ? '' : ' hidden') . '"'
|
||||
. ' type="button"'
|
||||
. ' id="' . $this->id . '_propagate"'
|
||||
. ' title="' . Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') . '"'
|
||||
. ' onclick="Joomla.propagateAssociation(\'' . $this->id . '\', \'' . $callbackFunctionStem . '\');">'
|
||||
. '<span class="icon-sync" aria-hidden="true"></span> ' . Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
if ($allowSelect || $allowNew || $allowEdit || $allowClear) {
|
||||
$html .= '</span>';
|
||||
}
|
||||
|
||||
// Select contact modal
|
||||
if ($allowSelect) {
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalSelect' . $modalId,
|
||||
[
|
||||
'title' => $modalTitle,
|
||||
'url' => $urlSelect,
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => 70,
|
||||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// New contact modal
|
||||
if ($allowNew) {
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalNew' . $modalId,
|
||||
[
|
||||
'title' => Text::_('COM_CONTACT_NEW_CONTACT'),
|
||||
'backdrop' => 'static',
|
||||
'keyboard' => false,
|
||||
'closeButton' => false,
|
||||
'url' => $urlNew,
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => 70,
|
||||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'add\', \'contact\', \'cancel\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
|
||||
. '<button type="button" class="btn btn-primary"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'add\', \'contact\', \'save\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JSAVE') . '</button>'
|
||||
. '<button type="button" class="btn btn-success"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'add\', \'contact\', \'apply\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JAPPLY') . '</button>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Edit contact modal.
|
||||
if ($allowEdit) {
|
||||
$html .= HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'ModalEdit' . $modalId,
|
||||
[
|
||||
'title' => Text::_('COM_CONTACT_EDIT_CONTACT'),
|
||||
'backdrop' => 'static',
|
||||
'keyboard' => false,
|
||||
'closeButton' => false,
|
||||
'url' => $urlEdit,
|
||||
'height' => '400px',
|
||||
'width' => '800px',
|
||||
'bodyHeight' => 70,
|
||||
'modalWidth' => 80,
|
||||
'footer' => '<button type="button" class="btn btn-secondary"'
|
||||
. ' onclick="window.processModalEdit(this, \'' . $this->id
|
||||
. '\', \'edit\', \'contact\', \'cancel\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
|
||||
. '<button type="button" class="btn btn-primary"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'edit\', \'contact\', \'save\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JSAVE') . '</button>'
|
||||
. '<button type="button" class="btn btn-success"'
|
||||
. ' onclick="window.processModalEdit(this, \''
|
||||
. $this->id . '\', \'edit\', \'contact\', \'apply\', \'contact-form\', \'jform_id\', \'jform_name\'); return false;">'
|
||||
. Text::_('JAPPLY') . '</button>',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Note: class='required' for client side validation.
|
||||
$class = $this->required ? ' class="required modal-value"' : '';
|
||||
|
||||
$html .= '<input type="hidden" id="' . $this->id . '_id"' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
|
||||
. '" data-text="' . htmlspecialchars(Text::_('COM_CONTACT_SELECT_A_CONTACT', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '">';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field label markup.
|
||||
*
|
||||
* @return string The field label markup.
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
return str_replace($this->id, $this->id . '_name', parent::getLabel());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Association\AssociationExtensionHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Component\Contact\Site\Helper\AssociationHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content associations helper.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
class AssociationsHelper extends AssociationExtensionHelper
|
||||
{
|
||||
/**
|
||||
* The extension name
|
||||
*
|
||||
* @var array $extension
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $extension = 'com_contact';
|
||||
|
||||
/**
|
||||
* Array of item types
|
||||
*
|
||||
* @var array $itemTypes
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $itemTypes = ['contact', 'category'];
|
||||
|
||||
/**
|
||||
* Has the extension association support
|
||||
*
|
||||
* @var boolean $associationsSupport
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected $associationsSupport = true;
|
||||
|
||||
/**
|
||||
* Method to get the associations for a given item.
|
||||
*
|
||||
* @param integer $id Id of the item
|
||||
* @param string $view Name of the view
|
||||
*
|
||||
* @return array Array of associations for the item
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getAssociationsForItem($id = 0, $view = null)
|
||||
{
|
||||
return AssociationHelper::getAssociations($id, $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated items for an item
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
* @param int $id The id of item for which we need the associated items
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function getAssociations($typeName, $id)
|
||||
{
|
||||
$type = $this->getType($typeName);
|
||||
|
||||
$context = $this->extension . '.item';
|
||||
$catidField = 'catid';
|
||||
|
||||
if ($typeName === 'category') {
|
||||
$context = 'com_categories.item';
|
||||
$catidField = '';
|
||||
}
|
||||
|
||||
// Get the associations.
|
||||
$associations = Associations::getAssociations(
|
||||
$this->extension,
|
||||
$type['tables']['a'],
|
||||
$context,
|
||||
$id,
|
||||
'id',
|
||||
'alias',
|
||||
$catidField
|
||||
);
|
||||
|
||||
return $associations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item information
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
* @param int $id The id of item for which we need the associated items
|
||||
*
|
||||
* @return Table|null
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function getItem($typeName, $id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$table = null;
|
||||
|
||||
switch ($typeName) {
|
||||
case 'contact':
|
||||
$table = Table::getInstance('ContactTable', 'Joomla\\Component\\Contact\\Administrator\\Table\\');
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$table = Table::getInstance('Category');
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($table)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$table->load($id);
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the type
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
*
|
||||
* @return array Array of item types
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function getType($typeName = '')
|
||||
{
|
||||
$fields = $this->getFieldsTemplate();
|
||||
$tables = [];
|
||||
$joins = [];
|
||||
$support = $this->getSupportTemplate();
|
||||
$title = '';
|
||||
|
||||
if (\in_array($typeName, $this->itemTypes)) {
|
||||
switch ($typeName) {
|
||||
case 'contact':
|
||||
$fields['title'] = 'a.name';
|
||||
$fields['state'] = 'a.published';
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['category'] = true;
|
||||
$support['save2copy'] = true;
|
||||
|
||||
$tables = [
|
||||
'a' => '#__contact_details',
|
||||
];
|
||||
|
||||
$title = 'contact';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$fields['created_user_id'] = 'a.created_user_id';
|
||||
$fields['ordering'] = 'a.lft';
|
||||
$fields['level'] = 'a.level';
|
||||
$fields['catid'] = '';
|
||||
$fields['state'] = 'a.published';
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['level'] = true;
|
||||
|
||||
$tables = [
|
||||
'a' => '#__categories',
|
||||
];
|
||||
|
||||
$title = 'category';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'fields' => $fields,
|
||||
'support' => $support,
|
||||
'tables' => $tables,
|
||||
'joins' => $joins,
|
||||
'title' => $title,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact component helper.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactHelper extends ContentHelper
|
||||
{
|
||||
}
|
||||
516
administrator/components/com_contact/src/Model/ContactModel.php
Normal file
516
administrator/components/com_contact/src/Model/ContactModel.php
Normal file
@ -0,0 +1,516 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
use Joomla\CMS\Versioning\VersionableModelTrait;
|
||||
use Joomla\Component\Categories\Administrator\Helper\CategoriesHelper;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Item Model for a Contact.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactModel extends AdminModel
|
||||
{
|
||||
use VersionableModelTrait;
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_contact.contact';
|
||||
|
||||
/**
|
||||
* The context used for the associations table
|
||||
*
|
||||
* @var string
|
||||
* @since 3.4.4
|
||||
*/
|
||||
protected $associationsContext = 'com_contact.item';
|
||||
|
||||
/**
|
||||
* 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 = [
|
||||
'assetgroup_id' => 'batchAccess',
|
||||
'language_id' => 'batchLanguage',
|
||||
'tag' => 'batchTag',
|
||||
'user_id' => 'batchUser',
|
||||
];
|
||||
|
||||
/**
|
||||
* Name of the form
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $formName = 'contact';
|
||||
|
||||
/**
|
||||
* Batch change a linked user.
|
||||
*
|
||||
* @param integer $value The new value matching a User ID.
|
||||
* @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 batchUser($value, $pks, $contexts)
|
||||
{
|
||||
foreach ($pks as $pk) {
|
||||
if ($this->user->authorise('core.edit', $contexts[$pk])) {
|
||||
$this->table->reset();
|
||||
$this->table->load($pk);
|
||||
$this->table->user_id = (int) $value;
|
||||
|
||||
if (!$this->table->store()) {
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
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->published != -2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getCurrentUser()->authorise('core.delete', 'com_contact.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can have its state edited.
|
||||
*
|
||||
* @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_contact.category.' . (int) $record->catid);
|
||||
}
|
||||
|
||||
// Default to component settings if category not known.
|
||||
return parent::canEditState($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the row form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return Form|boolean A Form object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
Form::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_users/models/fields');
|
||||
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_contact.' . $this->formName, $this->formName, ['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('featured', 'disabled', 'true');
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
$form->setFieldAttribute('published', 'disabled', 'true');
|
||||
|
||||
// Disable fields while saving.
|
||||
// The controller has already verified this is a record you can edit.
|
||||
$form->setFieldAttribute('featured', 'filter', 'unset');
|
||||
$form->setFieldAttribute('ordering', 'filter', 'unset');
|
||||
$form->setFieldAttribute('published', '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 a single record.
|
||||
*
|
||||
* @param integer $pk The id of the primary key.
|
||||
*
|
||||
* @return mixed Object on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
if ($item = parent::getItem($pk)) {
|
||||
// Convert the metadata field to an array.
|
||||
$registry = new Registry($item->metadata);
|
||||
$item->metadata = $registry->toArray();
|
||||
}
|
||||
|
||||
// Load associated contact items
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($assoc) {
|
||||
$item->associations = [];
|
||||
|
||||
if ($item->id != null) {
|
||||
$associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $item->id);
|
||||
|
||||
foreach ($associations as $tag => $association) {
|
||||
$item->associations[$tag] = $association->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load item tags
|
||||
if (!empty($item->id)) {
|
||||
$item->tags = new TagsHelper();
|
||||
$item->tags->getTagIds($item->id, 'com_contact.contact');
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Check the session for previously entered form data.
|
||||
$data = $app->getUserState('com_contact.edit.contact.data', []);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
|
||||
// Prime some default values.
|
||||
if ($this->getState('contact.id') == 0) {
|
||||
$data->set('catid', $app->getInput()->get('catid', $app->getUserState('com_contact.contacts.filter.category_id'), 'int'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->preprocessData('com_contact.contact', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
|
||||
// Create new category, if needed.
|
||||
$createCategory = true;
|
||||
|
||||
// If category ID is provided, check if it's valid.
|
||||
if (is_numeric($data['catid']) && $data['catid']) {
|
||||
$createCategory = !CategoriesHelper::validateCategoryId($data['catid'], 'com_contact');
|
||||
}
|
||||
|
||||
// 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_contact',
|
||||
'language' => $data['language'],
|
||||
'published' => 1,
|
||||
];
|
||||
|
||||
/** @var \Joomla\Component\Categories\Administrator\Model\CategoryModel $categoryModel */
|
||||
$categoryModel = Factory::getApplication()->bootComponent('com_categories')
|
||||
->getMVCFactory()->createModel('Category', 'Administrator', ['ignore_request' => true]);
|
||||
|
||||
// Create new category.
|
||||
if (!$categoryModel->save($category)) {
|
||||
$this->setError($categoryModel->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the Category ID.
|
||||
$data['catid'] = $categoryModel->getState('category.id');
|
||||
}
|
||||
|
||||
// Alter the name for save as copy
|
||||
if ($input->get('task') == 'save2copy') {
|
||||
$origTable = clone $this->getTable();
|
||||
$origTable->load($input->getInt('id'));
|
||||
|
||||
if ($data['name'] == $origTable->name) {
|
||||
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
|
||||
$data['name'] = $name;
|
||||
$data['alias'] = $alias;
|
||||
} else {
|
||||
if ($data['alias'] == $origTable->alias) {
|
||||
$data['alias'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$data['published'] = 0;
|
||||
}
|
||||
|
||||
$links = ['linka', 'linkb', 'linkc', 'linkd', 'linke'];
|
||||
|
||||
foreach ($links as $link) {
|
||||
if (!empty($data['params'][$link])) {
|
||||
$data['params'][$link] = PunycodeHelper::urlToPunycode($data['params'][$link]);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table prior to saving.
|
||||
*
|
||||
* @param \Joomla\CMS\Table\Table $table The Table object
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$date = Factory::getDate()->toSql();
|
||||
|
||||
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
|
||||
|
||||
$table->generateAlias();
|
||||
|
||||
if (empty($table->id)) {
|
||||
// Set the values
|
||||
$table->created = $date;
|
||||
|
||||
// Set ordering to the last item if not set
|
||||
if (empty($table->ordering)) {
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select('MAX(ordering)')
|
||||
->from($db->quoteName('#__contact_details'));
|
||||
$db->setQuery($query);
|
||||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
} else {
|
||||
// Set the values
|
||||
$table->modified = $date;
|
||||
$table->modified_by = $this->getCurrentUser()->id;
|
||||
}
|
||||
|
||||
// Increment the content version number.
|
||||
$table->version++;
|
||||
}
|
||||
|
||||
/**
|
||||
* A protected method to get a set of ordering conditions.
|
||||
*
|
||||
* @param \Joomla\CMS\Table\Table $table A record object.
|
||||
*
|
||||
* @return array An array of conditions to add to ordering queries.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getReorderConditions($table)
|
||||
{
|
||||
return [
|
||||
$this->getDatabase()->quoteName('catid') . ' = ' . (int) $table->catid,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess the form.
|
||||
*
|
||||
* @param Form $form Form object.
|
||||
* @param object $data Data object.
|
||||
* @param string $group Group name.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0.3
|
||||
*/
|
||||
protected function preprocessForm(Form $form, $data, $group = 'content')
|
||||
{
|
||||
if ($this->canCreateCategory()) {
|
||||
$form->setFieldAttribute('catid', 'allowAdd', 'true');
|
||||
|
||||
// Add a prefix for categories created on the fly.
|
||||
$form->setFieldAttribute('catid', 'customPrefix', '#new#');
|
||||
}
|
||||
|
||||
// Association contact items
|
||||
if (Associations::isEnabled()) {
|
||||
$languages = LanguageHelper::getContentLanguages(false, false, null, 'ordering', 'asc');
|
||||
|
||||
if (\count($languages) > 1) {
|
||||
$addform = new \SimpleXMLElement('<form />');
|
||||
$fields = $addform->addChild('fields');
|
||||
$fields->addAttribute('name', 'associations');
|
||||
$fieldset = $fields->addChild('fieldset');
|
||||
$fieldset->addAttribute('name', 'item_associations');
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$field = $fieldset->addChild('field');
|
||||
$field->addAttribute('name', $language->lang_code);
|
||||
$field->addAttribute('type', 'modal_contact');
|
||||
$field->addAttribute('language', $language->lang_code);
|
||||
$field->addAttribute('label', $language->title);
|
||||
$field->addAttribute('translate_label', 'false');
|
||||
$field->addAttribute('select', 'true');
|
||||
$field->addAttribute('new', 'true');
|
||||
$field->addAttribute('edit', 'true');
|
||||
$field->addAttribute('clear', 'true');
|
||||
$field->addAttribute('propagate', 'true');
|
||||
}
|
||||
|
||||
$form->load($addform, false);
|
||||
}
|
||||
}
|
||||
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to toggle the featured setting of contacts.
|
||||
*
|
||||
* @param array $pks The ids of the items to toggle.
|
||||
* @param integer $value The value to toggle to.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function featured($pks, $value = 0)
|
||||
{
|
||||
// Sanitize the ids.
|
||||
$pks = ArrayHelper::toInteger((array) $pks);
|
||||
|
||||
if (empty($pks)) {
|
||||
$this->setError(Text::_('COM_CONTACT_NO_ITEM_SELECTED'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$table = $this->getTable();
|
||||
|
||||
try {
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->update($db->quoteName('#__contact_details'));
|
||||
$query->set($db->quoteName('featured') . ' = :featured');
|
||||
$query->whereIn($db->quoteName('id'), $pks);
|
||||
$query->bind(':featured', $value, ParameterType::INTEGER);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$db->execute();
|
||||
} catch (\Exception $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$table->reorder();
|
||||
|
||||
// Clean component's cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_contact');
|
||||
}
|
||||
}
|
||||
357
administrator/components/com_contact/src/Model/ContactsModel.php
Normal file
357
administrator/components/com_contact/src/Model/ContactsModel.php
Normal file
@ -0,0 +1,357 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Methods supporting a list of contact records.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class ContactsModel 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',
|
||||
'alias', 'a.alias',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'catid', 'a.catid', 'category_id', 'category_title',
|
||||
'user_id', 'a.user_id',
|
||||
'published', 'a.published',
|
||||
'access', 'a.access', 'access_level',
|
||||
'created', 'a.created',
|
||||
'created_by', 'a.created_by',
|
||||
'ordering', 'a.ordering',
|
||||
'featured', 'a.featured',
|
||||
'language', 'a.language', 'language_title',
|
||||
'publish_up', 'a.publish_up',
|
||||
'publish_down', 'a.publish_down',
|
||||
'ul.name', 'linked_user',
|
||||
'tag',
|
||||
'level', 'c.level',
|
||||
];
|
||||
|
||||
if (Associations::isEnabled()) {
|
||||
$config['filter_fields'][] = 'association';
|
||||
}
|
||||
}
|
||||
|
||||
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')
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
$forcedLanguage = $app->getInput()->get('forcedLanguage', '', 'cmd');
|
||||
|
||||
// Adjust the context to support modal layouts.
|
||||
if ($layout = $app->getInput()->get('layout')) {
|
||||
$this->context .= '.' . $layout;
|
||||
}
|
||||
|
||||
// Adjust the context to support forced languages.
|
||||
if ($forcedLanguage) {
|
||||
$this->context .= '.' . $forcedLanguage;
|
||||
}
|
||||
|
||||
// List state information.
|
||||
parent::populateState($ordering, $direction);
|
||||
|
||||
// Force a language.
|
||||
if (!empty($forcedLanguage)) {
|
||||
$this->setState('filter.language', $forcedLanguage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.published');
|
||||
$id .= ':' . serialize($this->getState('filter.category_id'));
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.language');
|
||||
$id .= ':' . serialize($this->getState('filter.tag'));
|
||||
$id .= ':' . $this->getState('filter.level');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Select the required fields from the table.
|
||||
$query->select(
|
||||
$db->quoteName(
|
||||
explode(
|
||||
', ',
|
||||
$this->getState(
|
||||
'list.select',
|
||||
'a.id, a.name, a.alias, a.checked_out, a.checked_out_time, a.catid, a.user_id' .
|
||||
', a.published, a.access, a.created, a.created_by, a.ordering, a.featured, a.language' .
|
||||
', a.publish_up, a.publish_down'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$query->from($db->quoteName('#__contact_details', 'a'));
|
||||
|
||||
// Join over the users for the linked user.
|
||||
$query->select(
|
||||
[
|
||||
$db->quoteName('ul.name', 'linked_user'),
|
||||
$db->quoteName('ul.email'),
|
||||
]
|
||||
)
|
||||
->join(
|
||||
'LEFT',
|
||||
$db->quoteName('#__users', 'ul') . ' ON ' . $db->quoteName('ul.id') . ' = ' . $db->quoteName('a.user_id')
|
||||
);
|
||||
|
||||
// Join over the language
|
||||
$query->select($db->quoteName('l.title', 'language_title'))
|
||||
->select($db->quoteName('l.image', 'language_image'))
|
||||
->join(
|
||||
'LEFT',
|
||||
$db->quoteName('#__languages', 'l') . ' ON ' . $db->quoteName('l.lang_code') . ' = ' . $db->quoteName('a.language')
|
||||
);
|
||||
|
||||
// Join over the users for the checked out user.
|
||||
$query->select($db->quoteName('uc.name', 'editor'))
|
||||
->join(
|
||||
'LEFT',
|
||||
$db->quoteName('#__users', 'uc') . ' ON ' . $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out')
|
||||
);
|
||||
|
||||
// Join over the asset groups.
|
||||
$query->select($db->quoteName('ag.title', 'access_level'))
|
||||
->join(
|
||||
'LEFT',
|
||||
$db->quoteName('#__viewlevels', 'ag') . ' ON ' . $db->quoteName('ag.id') . ' = ' . $db->quoteName('a.access')
|
||||
);
|
||||
|
||||
// Join over the categories.
|
||||
$query->select($db->quoteName('c.title', 'category_title'))
|
||||
->join(
|
||||
'LEFT',
|
||||
$db->quoteName('#__categories', 'c') . ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid')
|
||||
);
|
||||
|
||||
// Join over the associations.
|
||||
if (Associations::isEnabled()) {
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
|
||||
->from($db->quoteName('#__associations', 'asso1'))
|
||||
->join('INNER', $db->quoteName('#__associations', 'asso2'), $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
|
||||
$db->quoteName('asso1.context') . ' = ' . $db->quote('com_contact.item'),
|
||||
]
|
||||
);
|
||||
|
||||
$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
|
||||
}
|
||||
|
||||
// Filter by featured.
|
||||
$featured = (string) $this->getState('filter.featured');
|
||||
|
||||
if (\in_array($featured, ['0','1'])) {
|
||||
$query->where($db->quoteName('a.featured') . ' = ' . (int) $featured);
|
||||
}
|
||||
|
||||
// Filter by access level.
|
||||
if ($access = $this->getState('filter.access')) {
|
||||
$query->where($db->quoteName('a.access') . ' = :access');
|
||||
$query->bind(':access', $access, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->whereIn($db->quoteName('a.access'), $user->getAuthorisedViewLevels());
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
|
||||
if (is_numeric($published)) {
|
||||
$query->where($db->quoteName('a.published') . ' = :published');
|
||||
$query->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where('(' . $db->quoteName('a.published') . ' = 0 OR ' . $db->quoteName('a.published') . ' = 1)');
|
||||
}
|
||||
|
||||
// Filter by search in name.
|
||||
$search = $this->getState('filter.search');
|
||||
|
||||
if (!empty($search)) {
|
||||
if (stripos($search, 'id:') === 0) {
|
||||
$search = substr($search, 3);
|
||||
$query->where($db->quoteName('a.id') . ' = :id');
|
||||
$query->bind(':id', $search, ParameterType::INTEGER);
|
||||
} else {
|
||||
$search = '%' . trim($search) . '%';
|
||||
$query->where(
|
||||
'(' . $db->quoteName('a.name') . ' LIKE :name OR ' . $db->quoteName('a.alias') . ' LIKE :alias)'
|
||||
);
|
||||
$query->bind(':name', $search);
|
||||
$query->bind(':alias', $search);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on the language.
|
||||
if ($language = $this->getState('filter.language')) {
|
||||
$query->where($db->quoteName('a.language') . ' = :language');
|
||||
$query->bind(':language', $language);
|
||||
}
|
||||
|
||||
// Filter by a single or group of tags.
|
||||
$tag = $this->getState('filter.tag');
|
||||
|
||||
// Run simplified query when filtering by one tag.
|
||||
if (\is_array($tag) && \count($tag) === 1) {
|
||||
$tag = $tag[0];
|
||||
}
|
||||
|
||||
if ($tag && \is_array($tag)) {
|
||||
$tag = ArrayHelper::toInteger($tag);
|
||||
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select('DISTINCT ' . $db->quoteName('content_item_id'))
|
||||
->from($db->quoteName('#__contentitem_tag_map'))
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('tag_id') . ' IN (' . implode(',', $query->bindArray($tag)) . ')',
|
||||
$db->quoteName('type_alias') . ' = ' . $db->quote('com_contact.contact'),
|
||||
]
|
||||
);
|
||||
|
||||
$query->join(
|
||||
'INNER',
|
||||
'(' . $subQuery . ') AS ' . $db->quoteName('tagmap'),
|
||||
$db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
);
|
||||
} elseif ($tag = (int) $tag) {
|
||||
$query->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__contentitem_tag_map', 'tagmap'),
|
||||
$db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
|
||||
)
|
||||
->where(
|
||||
[
|
||||
$db->quoteName('tagmap.tag_id') . ' = :tag',
|
||||
$db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_contact.contact'),
|
||||
]
|
||||
)
|
||||
->bind(':tag', $tag, ParameterType::INTEGER);
|
||||
}
|
||||
|
||||
// Filter by categories and by level
|
||||
$categoryId = $this->getState('filter.category_id', []);
|
||||
$level = $this->getState('filter.level');
|
||||
|
||||
if (!\is_array($categoryId)) {
|
||||
$categoryId = $categoryId ? [$categoryId] : [];
|
||||
}
|
||||
|
||||
// Case: Using both categories filter and by level filter
|
||||
if (\count($categoryId)) {
|
||||
$categoryId = ArrayHelper::toInteger($categoryId);
|
||||
$categoryTable = Table::getInstance('Category', '\\Joomla\\CMS\\Table\\');
|
||||
$subCatItemsWhere = [];
|
||||
|
||||
// @todo: Convert to prepared statement
|
||||
foreach ($categoryId as $filter_catid) {
|
||||
$categoryTable->load($filter_catid);
|
||||
$subCatItemsWhere[] = '(' .
|
||||
($level ? 'c.level <= ' . ((int) $level + (int) $categoryTable->level - 1) . ' AND ' : '') .
|
||||
'c.lft >= ' . (int) $categoryTable->lft . ' AND ' .
|
||||
'c.rgt <= ' . (int) $categoryTable->rgt . ')';
|
||||
}
|
||||
|
||||
$query->where('(' . implode(' OR ', $subCatItemsWhere) . ')');
|
||||
} elseif ($level) {
|
||||
// Case: Using only the by level filter
|
||||
$query->where($db->quoteName('c.level') . ' <= :level');
|
||||
$query->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') {
|
||||
$orderCol = $db->quoteName('c.title') . ' ' . $orderDirn . ', ' . $db->quoteName('a.ordering');
|
||||
}
|
||||
|
||||
$query->order($db->escape($orderCol . ' ' . $orderDirn));
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Service\HTML;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\LanguageHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Database\ParameterType;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact HTML helper class.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class AdministratorService
|
||||
{
|
||||
/**
|
||||
* Get the associated language flags
|
||||
*
|
||||
* @param integer $contactid The item id to search associations
|
||||
*
|
||||
* @return string The language HTML
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function association($contactid)
|
||||
{
|
||||
// Defaults
|
||||
$html = '';
|
||||
|
||||
// Get the associations
|
||||
if ($associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $contactid)) {
|
||||
foreach ($associations as $tag => $associated) {
|
||||
$associations[$tag] = (int) $associated->id;
|
||||
}
|
||||
|
||||
// Get the associated contact items
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('c.id'),
|
||||
$db->quoteName('c.name', 'title'),
|
||||
$db->quoteName('l.sef', 'lang_sef'),
|
||||
$db->quoteName('lang_code'),
|
||||
$db->quoteName('cat.title', 'category_title'),
|
||||
$db->quoteName('l.image'),
|
||||
$db->quoteName('l.title', 'language_title'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__contact_details', 'c'))
|
||||
->join('LEFT', $db->quoteName('#__categories', 'cat'), $db->quoteName('cat.id') . ' = ' . $db->quoteName('c.catid'))
|
||||
->join('LEFT', $db->quoteName('#__languages', 'l'), $db->quoteName('c.language') . ' = ' . $db->quoteName('l.lang_code'))
|
||||
->whereIn($db->quoteName('c.id'), array_values($associations))
|
||||
->where($db->quoteName('c.id') . ' != :id')
|
||||
->bind(':id', $contactid, ParameterType::INTEGER);
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$items = $db->loadObjectList('id');
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \Exception($e->getMessage(), 500, $e);
|
||||
}
|
||||
|
||||
if ($items) {
|
||||
$languages = LanguageHelper::getContentLanguages([0, 1]);
|
||||
$content_languages = array_column($languages, 'lang_code');
|
||||
|
||||
foreach ($items as &$item) {
|
||||
if (\in_array($item->lang_code, $content_languages)) {
|
||||
$text = $item->lang_code;
|
||||
$url = Route::_('index.php?option=com_contact&task=contact.edit&id=' . (int) $item->id);
|
||||
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
|
||||
. htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br>' . Text::sprintf('JCATEGORY_SPRINTF', $item->category_title);
|
||||
$classes = 'badge bg-secondary';
|
||||
|
||||
$item->link = '<a href="' . $url . '" class="' . $classes . '">' . $text . '</a>'
|
||||
. '<div role="tooltip" id="tip-' . (int) $contactid . '-' . (int) $item->id . '">' . $tooltip . '</div>';
|
||||
} else {
|
||||
// Display warning if Content Language is trashed or deleted
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_ASSOCIATIONS_CONTENTLANGUAGE_WARNING', $item->lang_code), 'warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$html = LayoutHelper::render('joomla.content.associations', $items);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the featured/not-featured icon.
|
||||
*
|
||||
* @param integer $value The featured value.
|
||||
* @param integer $i Id of the item.
|
||||
* @param boolean $canChange Whether the value can be changed or not.
|
||||
*
|
||||
* @return string The anchor tag to toggle featured/unfeatured contacts.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function featured($value, $i, $canChange = true)
|
||||
{
|
||||
Factory::getDocument()->getWebAssetManager()->useScript('list-view');
|
||||
|
||||
// Array of image, task, title, action
|
||||
$states = [
|
||||
0 => ['unfeatured', 'contacts.featured', 'COM_CONTACT_UNFEATURED', 'JGLOBAL_ITEM_FEATURE'],
|
||||
1 => ['featured', 'contacts.unfeatured', 'JFEATURED', 'JGLOBAL_ITEM_UNFEATURE'],
|
||||
];
|
||||
$state = ArrayHelper::getValue($states, (int) $value, $states[1]);
|
||||
$icon = $state[0] === 'featured' ? 'star featured' : 'circle';
|
||||
$tooltipText = Text::_($state[3]);
|
||||
|
||||
if (!$canChange) {
|
||||
$tooltipText = Text::_($state[2]);
|
||||
}
|
||||
|
||||
$html = '<button type="button" class="js-grid-item-action tbody-icon' . ($value == 1 ? ' active' : '') . '"'
|
||||
. ' aria-labelledby="cb' . $i . '-desc" data-item-id="cb' . $i . '" data-item-task="' . $state[1] . '">'
|
||||
. '<span class="icon-' . $icon . '" aria-hidden="true"></span>'
|
||||
. '</button>'
|
||||
. '<div role="tooltip" id="cb' . $i . '-desc">' . $tooltipText . '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
166
administrator/components/com_contact/src/Service/HTML/Icon.php
Normal file
166
administrator/components/com_contact/src/Service/HTML/Icon.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\Contact\Administrator\Service\HTML;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\User\UserFactoryAwareTrait;
|
||||
use Joomla\CMS\User\UserFactoryInterface;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Content Component HTML Helper
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Icon
|
||||
{
|
||||
use UserFactoryAwareTrait;
|
||||
|
||||
/**
|
||||
* Service constructor
|
||||
*
|
||||
* @param UserFactoryInterface $userFactory The userFactory
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct(UserFactoryInterface $userFactory)
|
||||
{
|
||||
$this->setUserFactory($userFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a link to the create item page for the given category
|
||||
*
|
||||
* @param object $category The category information
|
||||
* @param Registry $params The item parameters
|
||||
* @param array $attribs Optional attributes for the link
|
||||
*
|
||||
* @return string The HTML markup for the create item link
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function create($category, $params, $attribs = [])
|
||||
{
|
||||
$uri = Uri::getInstance();
|
||||
|
||||
$url = 'index.php?option=com_contact&task=contact.add&return=' . base64_encode($uri) . '&id=0&catid=' . $category->id;
|
||||
|
||||
$text = '';
|
||||
|
||||
if ($params->get('show_icons')) {
|
||||
$text .= '<span class="icon-plus icon-fw" aria-hidden="true"></span>';
|
||||
}
|
||||
|
||||
$text .= Text::_('COM_CONTACT_NEW_CONTACT');
|
||||
|
||||
// Add the button classes to the attribs array
|
||||
if (isset($attribs['class'])) {
|
||||
$attribs['class'] .= ' btn btn-primary';
|
||||
} else {
|
||||
$attribs['class'] = 'btn btn-primary';
|
||||
}
|
||||
|
||||
$button = HTMLHelper::_('link', Route::_($url), $text, $attribs);
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an edit icon for the contact.
|
||||
*
|
||||
* This icon will not display in a popup window, nor if the contact is trashed.
|
||||
* Edit access checks must be performed in the calling code.
|
||||
*
|
||||
* @param object $contact The contact information
|
||||
* @param Registry $params The item parameters
|
||||
* @param array $attribs Optional attributes for the link
|
||||
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
|
||||
*
|
||||
* @return string The HTML for the contact edit icon.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function edit($contact, $params, $attribs = [], $legacy = false)
|
||||
{
|
||||
$user = Factory::getUser();
|
||||
$uri = Uri::getInstance();
|
||||
|
||||
// Ignore if in a popup window.
|
||||
if ($params && $params->get('popup')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Ignore if the state is negative (trashed).
|
||||
if ($contact->published < 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Show checked_out icon if the contact is checked out by a different user
|
||||
if (
|
||||
property_exists($contact, 'checked_out')
|
||||
&& property_exists($contact, 'checked_out_time')
|
||||
&& !\is_null($contact->checked_out)
|
||||
&& $contact->checked_out !== $user->get('id')
|
||||
) {
|
||||
$checkoutUser = $this->getUserFactory()->loadUserById($contact->checked_out);
|
||||
$date = HTMLHelper::_('date', $contact->checked_out_time);
|
||||
$tooltip = Text::sprintf('COM_CONTACT_CHECKED_OUT_BY', $checkoutUser->name)
|
||||
. ' <br> ' . $date;
|
||||
|
||||
$text = LayoutHelper::render('joomla.content.icons.edit_lock', ['contact' => $contact, 'tooltip' => $tooltip, 'legacy' => $legacy]);
|
||||
|
||||
$attribs['aria-describedby'] = 'editcontact-' . (int) $contact->id;
|
||||
$output = HTMLHelper::_('link', '#', $text, $attribs);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
$contactUrl = RouteHelper::getContactRoute($contact->slug, $contact->catid, $contact->language);
|
||||
$url = $contactUrl . '&task=contact.edit&id=' . $contact->id . '&return=' . base64_encode($uri);
|
||||
|
||||
if ((int) $contact->published === 0) {
|
||||
$tooltip = Text::_('COM_CONTACT_EDIT_UNPUBLISHED_CONTACT');
|
||||
} else {
|
||||
$tooltip = Text::_('COM_CONTACT_EDIT_PUBLISHED_CONTACT');
|
||||
}
|
||||
|
||||
$nowDate = strtotime(Factory::getDate());
|
||||
$icon = $contact->published ? 'edit' : 'eye-slash';
|
||||
|
||||
if (
|
||||
($contact->publish_up !== null && strtotime($contact->publish_up) > $nowDate)
|
||||
|| ($contact->publish_down !== null && strtotime($contact->publish_down) < $nowDate)
|
||||
) {
|
||||
$icon = 'eye-slash';
|
||||
}
|
||||
|
||||
$aria_described = 'editcontact-' . (int) $contact->id;
|
||||
|
||||
$text = '<span class="icon-' . $icon . '" aria-hidden="true"></span>';
|
||||
$text .= Text::_('JGLOBAL_EDIT');
|
||||
$text .= '<div role="tooltip" id="' . $aria_described . '">' . $tooltip . '</div>';
|
||||
|
||||
$attribs['aria-describedby'] = $aria_described;
|
||||
$output = HTMLHelper::_('link', Route::_($url), $text, $attribs);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
270
administrator/components/com_contact/src/Table/ContactTable.php
Normal file
270
administrator/components/com_contact/src/Table/ContactTable.php
Normal file
@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filter\InputFilter;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\String\PunycodeHelper;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\CMS\Tag\TaggableTableInterface;
|
||||
use Joomla\CMS\Tag\TaggableTableTrait;
|
||||
use Joomla\CMS\User\CurrentUserInterface;
|
||||
use Joomla\CMS\User\CurrentUserTrait;
|
||||
use Joomla\CMS\Versioning\VersionableTableInterface;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\String\StringHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Contact Table class.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class ContactTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface
|
||||
{
|
||||
use TaggableTableTrait;
|
||||
use CurrentUserTrait;
|
||||
|
||||
/**
|
||||
* Indicates that columns fully support the NULL value in the database
|
||||
*
|
||||
* @var boolean
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $_supportNullValue = true;
|
||||
|
||||
/**
|
||||
* Ensure the params and metadata in json encoded in the bind method
|
||||
*
|
||||
* @var array
|
||||
* @since 3.3
|
||||
*/
|
||||
protected $_jsonEncode = ['params', 'metadata'];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
* @param ?DispatcherInterface $dispatcher Event dispatcher for this table
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->typeAlias = 'com_contact.contact';
|
||||
|
||||
parent::__construct('#__contact_details', 'id', $db, $dispatcher);
|
||||
|
||||
$this->setColumnAlias('title', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a contact.
|
||||
*
|
||||
* @param boolean $updateNulls True to update fields even if they are null.
|
||||
*
|
||||
* @return boolean True on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function store($updateNulls = true)
|
||||
{
|
||||
$date = Factory::getDate()->toSql();
|
||||
$userId = $this->getCurrentUser()->id;
|
||||
|
||||
// Set created date if not set.
|
||||
if (!(int) $this->created) {
|
||||
$this->created = $date;
|
||||
}
|
||||
|
||||
if ($this->id) {
|
||||
// Existing item
|
||||
$this->modified_by = $userId;
|
||||
$this->modified = $date;
|
||||
} else {
|
||||
// Field created_by field can be set by the user, so we don't touch it if it's set.
|
||||
if (empty($this->created_by)) {
|
||||
$this->created_by = $userId;
|
||||
}
|
||||
|
||||
if (!(int) $this->modified) {
|
||||
$this->modified = $date;
|
||||
}
|
||||
|
||||
if (empty($this->modified_by)) {
|
||||
$this->modified_by = $userId;
|
||||
}
|
||||
}
|
||||
|
||||
// Store utf8 email as punycode
|
||||
if ($this->email_to !== null) {
|
||||
$this->email_to = PunycodeHelper::emailToPunycode($this->email_to);
|
||||
}
|
||||
|
||||
// Convert IDN urls to punycode
|
||||
if ($this->webpage !== null) {
|
||||
$this->webpage = PunycodeHelper::urlToPunycode($this->webpage);
|
||||
}
|
||||
|
||||
// Verify that the alias is unique
|
||||
$table = new self($this->getDbo(), $this->getDispatcher());
|
||||
|
||||
if ($table->load(['alias' => $this->alias, 'catid' => $this->catid]) && ($table->id != $this->id || $this->id == 0)) {
|
||||
// Is the existing contact trashed?
|
||||
$this->setError(Text::_('COM_CONTACT_ERROR_UNIQUE_ALIAS'));
|
||||
|
||||
if ($table->published === -2) {
|
||||
$this->setError(Text::_('COM_CONTACT_ERROR_UNIQUE_ALIAS_TRASHED'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::store($updateNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded check function
|
||||
*
|
||||
* @return boolean True on success, false on failure
|
||||
*
|
||||
* @see \Joomla\CMS\Table\Table::check
|
||||
* @since 1.5
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
try {
|
||||
parent::check();
|
||||
} catch (\Exception $e) {
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->default_con = (int) $this->default_con;
|
||||
|
||||
if ($this->webpage !== null && InputFilter::checkAttribute(['href', $this->webpage])) {
|
||||
$this->setError(Text::_('COM_CONTACT_WARNING_PROVIDE_VALID_URL'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for valid name
|
||||
if (trim($this->name) == '') {
|
||||
$this->setError(Text::_('COM_CONTACT_WARNING_PROVIDE_VALID_NAME'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate a valid alias
|
||||
$this->generateAlias();
|
||||
|
||||
// Check for a valid category.
|
||||
if (!$this->catid = (int) $this->catid) {
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_CATEGORY_REQUIRED'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sanity check for user_id
|
||||
if (!$this->user_id) {
|
||||
$this->user_id = 0;
|
||||
}
|
||||
|
||||
// Check the publish down date is not earlier than publish up.
|
||||
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
|
||||
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->id) {
|
||||
// Hits must be zero on a new item
|
||||
$this->hits = 0;
|
||||
}
|
||||
|
||||
// Clean up description -- eliminate quotes and <> brackets
|
||||
if (!empty($this->metadesc)) {
|
||||
// Only process if not empty
|
||||
$badCharacters = ["\"", '<', '>'];
|
||||
$this->metadesc = StringHelper::str_ireplace($badCharacters, '', $this->metadesc);
|
||||
} else {
|
||||
$this->metadesc = '';
|
||||
}
|
||||
|
||||
if (empty($this->params)) {
|
||||
$this->params = '{}';
|
||||
}
|
||||
|
||||
if (empty($this->metadata)) {
|
||||
$this->metadata = '{}';
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (!$this->modified) {
|
||||
$this->modified = $this->created;
|
||||
}
|
||||
|
||||
if (empty($this->modified_by)) {
|
||||
$this->modified_by = $this->created_by;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid alias from title / date.
|
||||
* Remains public to be able to check for duplicated alias before saving
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateAlias()
|
||||
{
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = $this->name;
|
||||
}
|
||||
|
||||
$this->alias = ApplicationHelper::stringURLSafe($this->alias, $this->language);
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '') {
|
||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
return $this->alias;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the type alias for the history and tags mapping table
|
||||
*
|
||||
* @return string The alias as described above
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getTypeAlias()
|
||||
{
|
||||
return $this->typeAlias;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\View\Contact;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View to edit a contact.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The Form object
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* The active item
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Initialise variables.
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
$this->state = $this->get('State');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// If we are forcing a language in modal (used for associations).
|
||||
if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->getInput()->get('forcedLanguage', '', 'cmd')) {
|
||||
// Set the language field to the forcedLanguage and disable changing it.
|
||||
$this->form->setValue('language', null, $forcedLanguage);
|
||||
$this->form->setFieldAttribute('language', 'readonly', 'true');
|
||||
|
||||
// Only allow to select categories with All language or with the forced language.
|
||||
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
|
||||
|
||||
// Only allow to select tags with All language or with the forced language.
|
||||
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
|
||||
}
|
||||
|
||||
if ($this->getLayout() !== 'modal') {
|
||||
$this->addToolbar();
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$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_contact', 'category', $this->item->catid);
|
||||
|
||||
ToolbarHelper::title($isNew ? Text::_('COM_CONTACT_MANAGER_CONTACT_NEW') : Text::_('COM_CONTACT_MANAGER_CONTACT_EDIT'), 'address-book contact');
|
||||
|
||||
// Build the actions for new and existing records.
|
||||
if ($isNew) {
|
||||
// For new records, check the create permission.
|
||||
if (\count($user->getAuthorisedCategories('com_contact', 'core.create')) > 0) {
|
||||
$toolbar->apply('contact.apply');
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($user) {
|
||||
$childBar->save('contact.save');
|
||||
|
||||
if ($user->authorise('core.create', 'com_menus.menu')) {
|
||||
$childBar->save('contact.save2menu', 'JTOOLBAR_SAVE_TO_MENU');
|
||||
}
|
||||
|
||||
$childBar->save2new('contact.save2new');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar->cancel('contact.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
|
||||
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId);
|
||||
|
||||
// Can't save the record if it's checked out and editable
|
||||
if (!$checkedOut && $itemEditable) {
|
||||
$toolbar->apply('contact.apply');
|
||||
}
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($checkedOut, $itemEditable, $canDo, $user) {
|
||||
// Can't save the record if it's checked out and editable
|
||||
if (!$checkedOut && $itemEditable) {
|
||||
$childBar->save('contact.save');
|
||||
|
||||
// We can save this record, but check the create permission to see if we can return to make a new one.
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save2new('contact.save2new');
|
||||
}
|
||||
}
|
||||
|
||||
// If checked out, we can still save2menu
|
||||
if ($user->authorise('core.create', 'com_menus.menu')) {
|
||||
$childBar->save('contact.save2menu', 'JTOOLBAR_SAVE_TO_MENU');
|
||||
}
|
||||
|
||||
// If checked out, we can still save
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save2copy('contact.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$toolbar->cancel('contact.cancel');
|
||||
|
||||
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $itemEditable) {
|
||||
$toolbar->versions('com_contact.contact', $this->item->id);
|
||||
}
|
||||
|
||||
if (Associations::isEnabled() && ComponentHelper::isEnabled('com_associations')) {
|
||||
$toolbar->standardButton('contract', 'JTOOLBAR_ASSOCIATIONS', 'contact.editAssociations')
|
||||
->icon('icon-contract')
|
||||
->listCheck(false);
|
||||
}
|
||||
}
|
||||
|
||||
$toolbar->divider();
|
||||
$toolbar->help('Contacts:_Edit');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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\Contact\Administrator\View\Contacts;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ContentHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of contacts.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* An array of items
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var \Joomla\CMS\Pagination\Pagination
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $activeFilters;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
|
||||
$this->setLayout('emptystate');
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
// Preprocess the list of items to find ordering divisions.
|
||||
// @todo: Complete the ordering stuff with nested sets
|
||||
foreach ($this->items as &$item) {
|
||||
$item->order_up = true;
|
||||
$item->order_dn = true;
|
||||
}
|
||||
|
||||
// We don't need toolbar in the modal window.
|
||||
if ($this->getLayout() !== 'modal') {
|
||||
$this->addToolbar();
|
||||
|
||||
// We do not need to filter by language when multilingual is disabled
|
||||
if (!Multilanguage::isEnabled()) {
|
||||
unset($this->activeFilters['language']);
|
||||
$this->filterForm->removeField('language', 'filter');
|
||||
}
|
||||
} else {
|
||||
// In article associations modal we need to remove language filter if forcing a language.
|
||||
// We also need to change the category filter to show show categories with All or the forced language.
|
||||
if ($forcedLanguage = Factory::getApplication()->getInput()->get('forcedLanguage', '', 'CMD')) {
|
||||
// If the language is forced we can't allow to select the language, so transform the language selector filter into a hidden field.
|
||||
$languageXml = new \SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
|
||||
$this->filterForm->setField($languageXml, 'filter', true);
|
||||
|
||||
// Also, unset the active language filter so the search tools is not open by default with this filter.
|
||||
unset($this->activeFilters['language']);
|
||||
|
||||
// One last changes needed is to change the category filter to just show categories with All language or with the forced language.
|
||||
$this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
|
||||
}
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
$canDo = ContentHelper::getActions('com_contact', 'category', $this->state->get('filter.category_id'));
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
// Get the toolbar object instance
|
||||
$toolbar = Toolbar::getInstance();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_CONTACT_MANAGER_CONTACTS'), 'address-book contact');
|
||||
|
||||
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_contact', 'core.create')) > 0) {
|
||||
$toolbar->addNew('contact.add');
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $canDo->get('core.edit.state')) {
|
||||
/** @var DropdownButton $dropdown */
|
||||
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
|
||||
->toggleSplit(false)
|
||||
->icon('icon-ellipsis-h')
|
||||
->buttonClass('btn btn-action')
|
||||
->listCheck(true);
|
||||
|
||||
$childBar = $dropdown->getChildToolbar();
|
||||
|
||||
$childBar->publish('contacts.publish')->listCheck(true);
|
||||
$childBar->unpublish('contacts.unpublish')->listCheck(true);
|
||||
$childBar->standardButton('featured', 'JFEATURE', 'contacts.featured')
|
||||
->listCheck(true);
|
||||
$childBar->standardButton('unfeatured', 'JUNFEATURE', 'contacts.unfeatured')
|
||||
->listCheck(true);
|
||||
$childBar->archive('contacts.archive')->listCheck(true);
|
||||
|
||||
if ($user->authorise('core.admin')) {
|
||||
$childBar->checkin('contacts.checkin');
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') != -2) {
|
||||
$childBar->trash('contacts.trash')->listCheck(true);
|
||||
}
|
||||
|
||||
// Add a batch button
|
||||
if (
|
||||
$user->authorise('core.create', 'com_contact')
|
||||
&& $user->authorise('core.edit', 'com_contact')
|
||||
&& $user->authorise('core.edit.state', 'com_contact')
|
||||
) {
|
||||
$childBar->popupButton('batch', 'JTOOLBAR_BATCH')
|
||||
->selector('collapseModal')
|
||||
->listCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('contacts.delete', 'JTOOLBAR_EMPTY_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
if ($user->authorise('core.admin', 'com_contact') || $user->authorise('core.options', 'com_contact')) {
|
||||
$toolbar->preferences('com_contact');
|
||||
}
|
||||
|
||||
$toolbar->help('Contacts');
|
||||
}
|
||||
}
|
||||
134
administrator/components/com_contact/tmpl/contact/edit.php
Normal file
134
administrator/components/com_contact/tmpl/contact/edit.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('keepalive')
|
||||
->useScript('form.validate');
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->getInput();
|
||||
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
|
||||
$this->ignore_fieldsets = ['details', 'item_associations', 'jmetadata'];
|
||||
$this->useCoreUI = true;
|
||||
|
||||
// In case of modal
|
||||
$isModal = $input->get('layout') === 'modal';
|
||||
$layout = $isModal ? 'modal' : 'edit';
|
||||
$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
|
||||
?>
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_contact&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="contact-form" aria-label="<?php echo Text::_('COM_CONTACT_FORM_TITLE_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>" class="form-validate">
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>
|
||||
|
||||
<div class="main-card">
|
||||
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', empty($this->item->id) ? Text::_('COM_CONTACT_NEW_CONTACT') : Text::_('COM_CONTACT_EDIT_CONTACT')); ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<?php echo $this->form->renderField('user_id'); ?>
|
||||
<?php echo $this->form->renderField('image'); ?>
|
||||
<?php echo $this->form->renderField('con_position'); ?>
|
||||
<?php echo $this->form->renderField('email_to'); ?>
|
||||
<?php echo $this->form->renderField('address'); ?>
|
||||
<?php echo $this->form->renderField('suburb'); ?>
|
||||
<?php echo $this->form->renderField('state'); ?>
|
||||
<?php echo $this->form->renderField('postcode'); ?>
|
||||
<?php echo $this->form->renderField('country'); ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<?php echo $this->form->renderField('telephone'); ?>
|
||||
<?php echo $this->form->renderField('mobile'); ?>
|
||||
<?php echo $this->form->renderField('fax'); ?>
|
||||
<?php echo $this->form->renderField('webpage'); ?>
|
||||
<?php echo $this->form->renderField('sortname1'); ?>
|
||||
<?php echo $this->form->renderField('sortname2'); ?>
|
||||
<?php echo $this->form->renderField('sortname3'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'misc', Text::_('JGLOBAL_FIELDSET_MISCELLANEOUS')); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<fieldset id="fieldset-misc" class="options-form">
|
||||
<legend><?php echo $this->form->getField('misc')->title; ?></legend>
|
||||
<div>
|
||||
<?php echo $this->form->getLabel('misc'); ?>
|
||||
<?php echo $this->form->getInput('misc'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('JGLOBAL_FIELDSET_PUBLISHING')); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<fieldset id="fieldset-publishingdata" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_PUBLISHING'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.publishingdata', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<fieldset id="fieldset-metadata" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_METADATA_OPTIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.metadata', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
|
||||
<?php if (!$isModal && $assoc) : ?>
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'associations', Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
|
||||
<fieldset id="fieldset-associations" class="options-form">
|
||||
<legend><?php echo Text::_('JGLOBAL_FIELDSET_ASSOCIATIONS'); ?></legend>
|
||||
<div>
|
||||
<?php echo LayoutHelper::render('joomla.edit.associations', $this); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php echo HTMLHelper::_('uitab.endTab'); ?>
|
||||
<?php elseif ($isModal && $assoc) : ?>
|
||||
<div class="hidden"><?php echo LayoutHelper::render('joomla.edit.associations', $this); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
16
administrator/components/com_contact/tmpl/contact/modal.php
Normal file
16
administrator/components/com_contact/tmpl/contact/modal.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
?>
|
||||
<div class="container-popup">
|
||||
<?php $this->setLayout('edit'); ?>
|
||||
<?php echo $this->loadTemplate(); ?>
|
||||
</div>
|
||||
210
administrator/components/com_contact/tmpl/contacts/default.php
Normal file
210
administrator/components/com_contact/tmpl/contacts/default.php
Normal file
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Associations;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('table.columns')
|
||||
->useScript('multiselect');
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->get('id');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$saveOrder = $listOrder == 'a.ordering';
|
||||
$assoc = Associations::isEnabled();
|
||||
|
||||
if ($saveOrder && !empty($this->items)) {
|
||||
$saveOrderingUrl = 'index.php?option=com_contact&task=contacts.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1';
|
||||
HTMLHelper::_('draggablelist.draggable');
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_contact'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table" id="contactList">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_CONTACT_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', 'JFEATURED', 'a.featured', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CONTACT_FIELD_NAME_LABEL', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CONTACT_FIELD_LINKED_USER_LABEL', 'ul.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if ($assoc) : ?>
|
||||
<th scope="col" class="w-10">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CONTACT_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th scope="col" class="w-5 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody <?php if ($saveOrder) :
|
||||
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true"<?php
|
||||
endif; ?>>
|
||||
<?php
|
||||
$n = count($this->items);
|
||||
foreach ($this->items as $i => $item) :
|
||||
$canCreate = $user->authorise('core.create', 'com_contact.category.' . $item->catid);
|
||||
$canEdit = $user->authorise('core.edit', 'com_contact.category.' . $item->catid);
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out);
|
||||
$canEditOwn = $user->authorise('core.edit.own', 'com_contact.category.' . $item->catid) && $item->created_by == $userId;
|
||||
$canChange = $user->authorise('core.edit.state', 'com_contact.category.' . $item->catid) && $canCheckin;
|
||||
|
||||
$item->cat_link = Route::_('index.php?option=com_categories&extension=com_contact&task=edit&type=other&id=' . $item->catid);
|
||||
?>
|
||||
<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::_('contactadministrator.featured', $item->featured, $i, $canChange); ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'contacts.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
|
||||
</td>
|
||||
|
||||
<th scope="row" class="has-context">
|
||||
<div>
|
||||
<?php if ($item->checked_out) : ?>
|
||||
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'contacts.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canEdit || $canEditOwn) : ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_contact&task=contact.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->name); ?>">
|
||||
<?php echo $this->escape($item->name); ?></a>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($item->name); ?>
|
||||
<?php endif; ?>
|
||||
<div class="small">
|
||||
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
|
||||
</div>
|
||||
<div class="small">
|
||||
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
<td class="small d-none">
|
||||
<?php if (!empty($item->linked_user)) : ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_users&task=user.edit&id=' . $item->user_id); ?>"><?php echo $item->linked_user; ?></a>
|
||||
<div class="small"><?php echo $item->email; ?></div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $item->access_level; ?>
|
||||
</td>
|
||||
<?php if ($assoc) : ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php if ($item->association) : ?>
|
||||
<?php echo HTMLHelper::_('contactadministrator.association', $item->id); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="d-none d-md-table-cell">
|
||||
<?php echo $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_contact')
|
||||
&& $user->authorise('core.edit', 'com_contact')
|
||||
&& $user->authorise('core.edit.state', 'com_contact')
|
||||
) : ?>
|
||||
<?php echo HTMLHelper::_(
|
||||
'bootstrap.renderModal',
|
||||
'collapseModal',
|
||||
[
|
||||
'title' => Text::_('COM_CONTACT_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,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
$published = (int) $this->state->get('filter.published');
|
||||
$noUser = true;
|
||||
?>
|
||||
|
||||
<div class="p-3">
|
||||
<div class="row">
|
||||
<?php if (Multilanguage::isEnabled()) : ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.language', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.access', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php if ($published >= 0) : ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.item', ['extension' => 'com_contact']); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.tag', []); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="controls">
|
||||
<?php echo LayoutHelper::render('joomla.html.batch.user', ['noUser' => $noUser]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-user-id').value='';document.getElementById('batch-tag-id').value=''" data-bs-dismiss="modal">
|
||||
<?php echo Text::_('JCANCEL'); ?>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('contact.batch');return false;">
|
||||
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
|
||||
</button>
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @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_CONTACT',
|
||||
'formURL' => 'index.php?option=com_contact',
|
||||
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Contacts',
|
||||
'icon' => 'icon-address-book contact',
|
||||
];
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
|
||||
if ($user->authorise('core.create', 'com_contact') || count($user->getAuthorisedCategories('com_contact', 'core.create')) > 0) {
|
||||
$displayData['createURL'] = 'index.php?option=com_contact&task=contact.add';
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate', $displayData);
|
||||
155
administrator/components/com_contact/tmpl/contacts/modal.php
Normal file
155
administrator/components/com_contact/tmpl/contacts/modal.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_contact
|
||||
*
|
||||
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Component\Contact\Site\Helper\RouteHelper;
|
||||
|
||||
$app = Factory::getApplication();
|
||||
|
||||
if ($app->isClient('site')) {
|
||||
Session::checkToken('get') or die(Text::_('JINVALID_TOKEN'));
|
||||
}
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = $this->document->getWebAssetManager();
|
||||
$wa->useScript('com_contact.admin-contacts-modal');
|
||||
|
||||
$function = $app->getInput()->getCmd('function', 'jSelectContact');
|
||||
$editor = $app->getInput()->getCmd('editor', '');
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$onclick = $this->escape($function);
|
||||
$multilang = Multilanguage::isEnabled();
|
||||
|
||||
if (!empty($editor)) {
|
||||
// This view is used also in com_menus. Load the xtd script only if the editor is set!
|
||||
$this->document->addScriptOptions('xtd-contacts', ['editor' => $editor]);
|
||||
$onclick = "jSelectContact";
|
||||
}
|
||||
?>
|
||||
<div class="container-popup">
|
||||
|
||||
<form action="<?php echo Route::_('index.php?option=com_contact&view=contacts&layout=modal&tmpl=component&editor=' . $editor . '&function=' . $function . '&' . Session::getFormToken() . '=1'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table table-sm">
|
||||
<caption class="visually-hidden">
|
||||
<?php echo Text::_('COM_CONTACT_TABLE_CAPTION'); ?>,
|
||||
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
|
||||
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="w-1 text-center">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="title">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-10">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CONTACT_FIELD_LINKED_USER_LABEL', 'ul.name', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th scope="col" class="w-15 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'access_level', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php if ($multilang) : ?>
|
||||
<th scope="col" class="w-10 d-none d-md-table-cell">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th scope="col" class="w-1">
|
||||
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$iconStates = [
|
||||
-2 => 'icon-trash',
|
||||
0 => 'icon-times',
|
||||
1 => 'icon-check',
|
||||
2 => 'icon-folder',
|
||||
];
|
||||
?>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php if ($item->language && $multilang) {
|
||||
$tag = strlen($item->language);
|
||||
if ($tag == 5) {
|
||||
$lang = substr($item->language, 0, 2);
|
||||
} elseif ($tag == 6) {
|
||||
$lang = substr($item->language, 0, 3);
|
||||
} else {
|
||||
$lang = '';
|
||||
}
|
||||
} elseif (!$multilang) {
|
||||
$lang = '';
|
||||
}
|
||||
?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td class="text-center">
|
||||
<span class="tbody-icon">
|
||||
<span class="<?php echo $iconStates[$this->escape($item->published)]; ?>" aria-hidden="true"></span>
|
||||
</span>
|
||||
</td>
|
||||
<th scope="row">
|
||||
<a class="select-link" href="javascript:void(0)" data-function="<?php echo $this->escape($onclick); ?>" data-id="<?php echo $item->id; ?>" data-title="<?php echo $this->escape($item->name); ?>" data-uri="<?php echo $this->escape(RouteHelper::getContactRoute($item->id, $item->catid, $item->language)); ?>" data-language="<?php echo $this->escape($lang); ?>">
|
||||
<?php echo $this->escape($item->name); ?>
|
||||
</a>
|
||||
<div class="small">
|
||||
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
|
||||
</div>
|
||||
</th>
|
||||
<td>
|
||||
<?php if (!empty($item->linked_user)) : ?>
|
||||
<?php echo $item->linked_user; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo $this->escape($item->access_level); ?>
|
||||
</td>
|
||||
<?php if ($multilang) : ?>
|
||||
<td class="small d-none d-md-table-cell">
|
||||
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<?php echo (int) $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php // load the pagination. ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<input type="hidden" name="forcedLanguage" value="<?php echo $app->getInput()->get('forcedLanguage', '', 'CMD'); ?>">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user