Initial decoupling of Weblinks

July made me do it!
This commit is contained in:
Andrew Eddie 2014-04-08 22:32:59 +10:00
parent d83e00fc65
commit a7b3eb7c5c
78 changed files with 7561 additions and 3 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.idea
build
releases

48
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,48 @@
# Joomla! Weblinks Contribution Guide
Thanks for your interest in this extension for Joomla. Please review the following notes about contributing and maintaining this package.
## Version Strategy
* When in doubt, refer to the new Joomla development strategy modelled on Semver (link).
* The major version of this package is synchronised with the major version of Joomla it is designed to run under.
For example, Weblinks 3.x is designed to run under Joomla 3.x; Weblinks 4.x under Joomla 4.x; and so on.
* A new minor version will be released each time there is a new feature or a significant change made to the package.
* A new patch version will be released each time there is a bug or cosmetic fix made to the package.
## Pull Requests
First fork this repository under your own account and make the changes to the code that you want to make.
Then make a Pull Request against the `master` branch of this repository.
### @since tags
If adding new PHP class methods or properties, the `@since` tags should be given the value of `__DEPLOY_VERSION__`.
This special tag will be replaced when the new version is built.
## Bugs and Issues
You can browse existing issues [here](https://github.com/joomla-extensions/weblinks/issues).
If you find any new bugs, or want to raise any type of support issue, please use raise a
[new issue](https://github.com/joomla-extensions/weblinks/issues/new).
## Release Procedure
This is the procedure and checklist for creating a new package.
* Update the version number in `build.ini`.
* Run `phing set-version`.
* Pun `phing` to make the new package for the version.
* Run `phing tag`.
* Push the commits and tags up to Github.
* Go to the releases page on Github.
* Click on the new tag.
- Click the `Edit Tag` button.
- Fill in the title and description for the release.
- Attach the zip-file for the package to the release. Wait for the file to complete uploading!
- Click the `Publish Release` button.
* Create a new `<update>` tag in the `manifest.xml` file.
- Change the `<version>` tag to the new version.
- Change the `<downloadurl>` tag to match the URL of the new release.
- Commit the change.

340
LICENSE Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -1,4 +1,3 @@
weblinks
========
# Weblinks for Joomla!
This is a prototype for isolating the Joomla CMS Weblinks suite of extensions and managing it as a standalone extension.
This is a prototype for isolating the Joomla's Weblinks suite of extensions and managing it as a standalone extension.

5
build.ini Normal file
View File

@ -0,0 +1,5 @@
# The release version for the extension package.
version=3.0.0
# The name of the package.
package=weblinks

115
build.xml Normal file
View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Weblinks" default="make" basedir=".">
<tstamp>
<format property="build.date" pattern="%Y-%m-%d" />
</tstamp>
<property file="build.ini" />
<target name="help">
<echo>Use `$ phing -l` to list the available targets.</echo>
</target>
<target name="make-dev" description="Builds the extension release package for development testing." depends="rebuild-extension-archives">
<echo msg="Deleting old development build." />
<delete quiet="yes" includeemptydirs="true">
<fileset dir="releases">
<include name="pkg_${package}_dev.zip" />
</fileset>
</delete>
<echo msg="Making the development ${package} package ." />
<zip destfile="releases/pkg_${package}_dev.zip">
<fileset dir="build">
<include name="**" />
</fileset>
</zip>
</target>
<target name="make" description="Builds the extension release package for a version." depends="rebuild-extension-archives">
<echo msg="Making the ${package} package for version ${version}." />
<zip destfile="releases/pkg_${package}_${version}.zip">
<fileset dir="build">
<include name="**" />
</fileset>
</zip>
</target>
<target name="rebuild-extension-archives" description="Rebuilds the archive (zip) files for each extension.">
<mkdir dir="build" />
<mkdir dir="releases" />
<echo msg="Cleaning build directory." />
<delete quiet="yes" includeemptydirs="true">
<fileset dir="*">
<include name="build" />
</fileset>
</delete>
<echo msg="Creating extension archives (zip files)." />
<foreach param="extension" target="build-archive">
<fileset dir="src">
<include name="com_*" />
<include name="mod_*" />
<include name="plg_*" />
<include name="tpl_*" />
</fileset>
</foreach>
<copy todir="build" >
<fileset dir="src">
<include name="language/**" />
<include name="pkg_${package}.xml" />
</fileset>
</copy>
</target>
<target name="build-archive" description="Builds an archive for a single extension.">
<zip destfile="build/${extension}.zip" basedir="src/${extension}" />
</target>
<target name="replace-deploy-version" description="Replaces the `__DEPLOY_VERSION__` markers with a designated tag and commits the changes.">
<echo>Replacing "__DEPLOY_VERSION__" with "${version}".</echo>
<reflexive>
<fileset dir=".">
<include pattern="*.md" />
<include pattern="src/**/*.php" />
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="__DEPLOY_VERSION__" replace="${version}"/>
</replaceregexp>
</filterchain>
</reflexive>
</target>
<target name="tag" description="Tags the repository using git.">
<gitcommit repository="." message="Tagging release `${version}`." allFiles="true" />
<gittag repository="." name="${version}" annotate="true" message="${version}" />
<!--<gitpush repository="." all="true" />-->
<echo>Push tags manually with `$ git push --tags origin`.</echo>
</target>
<target name="set-version" description="Sets the &lt;version&gt; tag in all XML files with the version from the build.ini file.">
<phingcall target="replace-xml">
<property name="tag" value="version" />
<property name="tagValue" value="${version}" />
</phingcall>
</target>
<target name="replace-xml" description="[PRIVATE] Sets an XML tag with a new value.">
<echo message="Replacing '${tag}' tag with '${tagValue}'."/>
<reflexive>
<fileset dir=".">
<include pattern="src/**/*.xml" />
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="&lt;${tag}&gt;(.*?)&lt;/${tag}&gt;"
replace="&lt;${tag}&gt;${tagValue}&lt;/${tag}&gt;"/>
</replaceregexp>
</filterchain>
</reflexive>
</target>
</project>

18
manifest.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<updates>
<update>
<name>Weblinks Extension Package</name>
<description>Joomla! CMS Weblinks Package</description>
<element>pkg_weblinks</element>
<type>package</type>
<version>3.0.0</version>
<infourl title="Artof Comments 1.1">
https://github.com/joomla-extensions/weblinks
</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/joomla-extensions/weblinks/releases/download/3.0.0/pkg_weblinks_3.0.0.zip</downloadurl>
</downloads>
<targetplatform name="joomla" version="3.0" />
<client>site</client>
</update>
</updates>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<access component="com_weblinks">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
</section>
<section name="category">
<action name="core.create" title="JACTION_CREATE" description="COM_CATEGORIES_ACCESS_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />
</section>
</access>

View File

@ -0,0 +1,367 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset name="component"
label="COM_WEBLINKS_COMPONENT_LABEL"
description="COM_WEBLINKS_COMPONENT_DESC"
>
<field name="target" type="list"
default="0"
description="COM_WEBLINKS_FIELD_TARGET_DESC"
label="COM_WEBLINKS_FIELD_TARGET_LABEL"
>
<option value="0">JBROWSERTARGET_PARENT</option>
<option value="1">JBROWSERTARGET_NEW</option>
<option value="2">JBROWSERTARGET_POPUP</option>
<option value="3">JBROWSERTARGET_MODAL</option>
</field>
<field
name="save_history"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"
description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="history_limit"
type="text"
filter="integer"
label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"
description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"
default="5"
/>
<field name="count_clicks" type="radio"
class="btn-group btn-group-yesno"
default="1"
label="COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
description="COM_WEBLINKS_FIELD_COUNTCLICKS_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="icons" type="list"
default="1"
label="COM_WEBLINKS_FIELD_ICON_LABEL"
description="COM_WEBLINKS_FIELD_ICON_DESC"
filter="integer">
<option value="0">COM_WEBLINKS_FIELD_ICON_OPTION_TEXT</option>
<option value="1">COM_WEBLINKS_FIELD_ICON_OPTION_ICON</option>
<option value="2">COM_WEBLINKS_FIELD_ICON_OPTION_WEBLINK</option>
</field>
<field name="link_icons" type="media"
description="COM_WEBLINKS_FIELD_CONFIG_ICON_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_ICON_LABEL"
/>
<field
name="float_first"
type="list"
label="COM_WEBLINKS_FLOAT_LABEL"
description="COM_WEBLINKS_FLOAT_DESC">
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
</field>
<field
name="float_second"
type="list"
label="COM_WEBLINKS_FLOAT_LABEL"
description="COM_WEBLINKS_FLOAT_DESC">
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
</field>
<field
id="show_tags"
name="show_tags"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="COM_WEBLINKS_FIELD_SHOW_TAGS_LABEL"
description="COM_WEBLINKS_FIELD_SHOW_TAGS_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
<fieldset name="category"
label="JCATEGORY"
description="COM_WEBLINKS_CATEGORY_DESC"
>
<field
name="category_layout" type="componentlayout"
label="JGLOBAL_FIELD_LAYOUT_LABEL"
description="JGLOBAL_FIELD_LAYOUT_DESC"
menuitems="true"
extension="com_weblinks"
view="category"
/>
<field name="show_category_title" type="radio"
class="btn-group btn-group-yesno"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_description"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_description_image"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="maxLevel" type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
default="-1"
>
<option value="0">JNONE</option>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field name="show_empty_categories" type="radio"
class="btn-group btn-group-yesno"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
default="0"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_subcat_desc" type="radio"
class="btn-group btn-group-yesno"
default="1"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_cat_num_links" type="radio"
class="btn-group btn-group-yesno"
default="1"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_cat_tags" type="radio"
label="COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_LABEL"
description="COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
<fieldset name="categories"
label="JCATEGORIES"
description="COM_WEBLINKS_CATEGORIES_DESC"
>
<field name="show_base_description" type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
description="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="maxLevelcat" type="list"
default="-1"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field name="show_empty_categories_cat" type="radio"
class="btn-group btn-group-yesno"
default="0"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_subcat_desc_cat" type="radio"
class="btn-group btn-group-yesno"
default="1"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_cat_num_links_cat" type="radio"
class="btn-group btn-group-yesno"
default="1"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
<fieldset name="list_layout"
label="JGLOBAL_LIST_LAYOUT_OPTIONS"
description="COM_WEBLINKS_LIST_LAYOUT_DESC"
>
<field
name="filter_field"
type="list"
default="1"
description="JGLOBAL_FILTER_FIELD_DESC"
label="JGLOBAL_FILTER_FIELD_LABEL"
>
<option value="1">JSHOW</option>
<option value="hide">JHIDE</option>
</field>
<field
name="show_pagination_limit"
type="radio" default="1"
class="btn-group btn-group-yesno"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
description="JGLOBAL_DISPLAY_SELECT_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_headings" type="radio"
default="1"
class="btn-group btn-group-yesno"
description="JGLOBAL_SHOW_HEADINGS_DESC"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_link_description" type="radio"
default="1"
class="btn-group btn-group-yesno"
description="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_link_hits" type="radio"
class="btn-group btn-group-yesno"
default="1"
description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
label="JGLOBAL_HITS"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field name="show_pagination"
type="list"
default="2"
label="JGLOBAL_PAGINATION_LABEL"
description="JGLOBAL_PAGINATION_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
<option value="2">JGLOBAL_AUTO</option>
</field>
<field name="show_pagination_results"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
description="JGLOBAL_PAGINATION_RESULTS_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
<fieldset
name="integration"
label="JGLOBAL_INTEGRATION_LABEL"
description="COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC"
>
<field
name="show_feed_link"
type="radio"
class="btn-group btn-group-yesno"
default="1"
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
description="JGLOBAL_SHOW_FEED_LINK_DESC">
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
<fieldset name="permissions"
description="JCONFIG_PERMISSIONS_DESC"
label="JCONFIG_PERMISSIONS_LABEL"
>
<field name="rules" type="rules"
component="com_weblinks"
filter="rules"
validate="rules"
label="JCONFIG_PERMISSIONS_LABEL"
section="component" />
</fieldset>
</config>

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Weblink Controller
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksController extends JControllerLegacy
{
/**
* 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, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/weblinks.php';
$view = $this->input->get('view', 'weblinks');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($view == 'weblink' && $layout == 'edit' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false));
return false;
}
parent::display();
return $this;
}
}

View File

@ -0,0 +1,126 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblink controller class.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksControllerWeblink extends JControllerForm
{
/**
* 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 = array())
{
$user = JFactory::getUser();
$categoryId = JArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the URL check it.
$allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId);
}
if ($allow === null)
{
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
}
else
{
return $allow;
}
}
/**
* Method to check if you can add a new 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 = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$categoryId = 0;
if ($recordId)
{
$categoryId = (int) $this->getModel()->getItem($recordId)->catid;
}
if ($categoryId)
{
// The category has been set. Check the category permissions.
return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId);
}
else
{
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 1.7
*/
public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Weblink', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$task = $this->getTask();
if ($task == 'save')
{
$this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false));
}
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks list controller class.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksControllerWeblinks extends JControllerAdmin
{
/**
* Proxy for getModel
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config The array of possible config values. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Weblink', $prefix = 'WeblinksModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Method to provide child classes the opportunity to process after the delete task.
*
* @param JModelLegacy $model The model for the component
* @param mixed $ids array of ids deleted.
*
* @return void
*
* @since 3.1
*/
protected function postDeleteHook(JModelLegacy $model, $ids = null)
{
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks helper.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksHelper extends JHelperContent
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName = 'weblinks')
{
JHtmlSidebar::addEntry(
JText::_('COM_WEBLINKS_SUBMENU_WEBLINKS'),
'index.php?option=com_weblinks&view=weblinks',
$vName == 'weblinks'
);
JHtmlSidebar::addEntry(
JText::_('COM_WEBLINKS_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_weblinks',
$vName == 'categories'
);
}
}

View File

@ -0,0 +1,121 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_WEBLINKS="Weblinks"
COM_WEBLINKS_ACCESS_HEADING="Access"
COM_WEBLINKS_BATCH_OPTIONS="Batch process the selected links"
COM_WEBLINKS_BATCH_TIP="If choosing to copy a link, any other actions selected will be applied to the copied link. Otherwise, all actions are applied to the selected link."
COM_WEBLINKS_CATEGORIES_DESC="These settings apply for Web Links Categories Options unless they are changed for a specific menu item."
COM_WEBLINKS_CATEGORY_DESC="These settings apply for Web Links Category Options unless they are changed for a specific menu item."
COM_WEBLINKS_COMPONENT_DESC="These settings apply for Web Links unless they are changed for a specific menu item or web link."
COM_WEBLINKS_COMPONENT_LABEL="Weblink"
COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Weblinks Component will integrate with other extensions."
COM_WEBLINKS_CONFIGURATION="Web Links Manager Options"
COM_WEBLINKS_EDIT_WEBLINK="Edit Web Link"
COM_WEBLINKS_ERR_TABLES_NAME="There is already a Web Link with that name in this category. Please try again."
COM_WEBLINKS_ERR_TABLES_PROVIDE_URL="Please provide a valid URL"
COM_WEBLINKS_ERR_TABLES_TITLE="Your web link must contain a title."
COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another web link from this category has the same alias"
COM_WEBLINKS_FIELD_ALIAS_DESC="The alias is for internal use only. Leave this blank and Joomla will fill in a default value from the title. It has to be unique for each web link in the same category."
COM_WEBLINKS_FIELD_CATEGORY_DESC="Choose a category for this Web link"
COM_WEBLINKS_FIELD_CATEGORYCHOOSE_DESC="Please choose a Web Links category to display"
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC="Show/Hide the number of Web Links in each Category"
COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL="# Web Links"
COM_WEBLINKS_FIELD_CONFIG_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded"
COM_WEBLINKS_FIELD_CONFIG_COUNTCLICKS_LABEL="Count Clicks"
COM_WEBLINKS_FIELD_CONFIG_DESCRIPTION_DESC="Show/Hide the description below"
COM_WEBLINKS_FIELD_CONFIG_HITS_DESC="Show/Hide hits"
COM_WEBLINKS_FIELD_CONFIG_ICON_DESC="If Icon is chosen above, select an icon to display with the Web Links. If none is selected, the default icon will be used."
COM_WEBLINKS_FIELD_CONFIG_ICON_LABEL="Select Icon"
COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC="Show/Hide the links description"
COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL="Links description"
COM_WEBLINKS_FIELD_CONFIG_OTHERCATS_DESC="Show/hide other categories"
COM_WEBLINKS_FIELD_CONFIG_OTHERCATS_LABEL="Other categories"
COM_WEBLINKS_FIELD_CONFIG_SHOWREPORT_DESC="Show/Hide the Report Bad Link option"
COM_WEBLINKS_FIELD_CONFIG_SHOWREPORT_LABEL="Reports"
COM_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded"
COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL="Count Clicks"
COM_WEBLINKS_FIELD_DESCRIPTION_DESC="Enter a description for the web link."
COM_WEBLINKS_FIELD_DISPLAY_NUM_DESC="Default number of Web links to list on a page."
COM_WEBLINKS_FIELD_DISPLAY_NUM_LABEL="# of Web links to List"
COM_WEBLINKS_FIELD_FIRST_DESC="The image to be displayed"
COM_WEBLINKS_FIELD_FIRST_LABEL="First image"
COM_WEBLINKS_FIELD_HEIGHT_DESC="Height of the target popup or modal window. Defaults to 600x500 if one field is left empty."
COM_WEBLINKS_FIELD_HEIGHT_LABEL="Height"
COM_WEBLINKS_FIELD_ICON_DESC="Displays a text, an icon or nothing with the Web links. Default is 'Icon'."
COM_WEBLINKS_FIELD_ICON_LABEL="Text/Icon/Web Link Only"
COM_WEBLINKS_FIELD_ICON_OPTION_ICON="Icon"
COM_WEBLINKS_FIELD_ICON_OPTION_TEXT="Text"
COM_WEBLINKS_FIELD_ICON_OPTION_WEBLINK="Web Link Only"
COM_WEBLINKS_FIELD_IMAGE_ALT_DESC="Alternative text used for visitors without access to images. Replaced with caption text if it is present."
COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL="Alt text"
COM_WEBLINKS_FIELD_IMAGE_CAPTION_DESC="Caption attached to the image"
COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL="Caption"
COM_WEBLINKS_FIELD_LANGUAGE_DESC="Assign a language to this weblink"
COM_WEBLINKS_FIELD_MODIFIED_DESC="The date and time the link was last modified"
COM_WEBLINKS_FIELD_SECOND_DESC="The second image to be displayed"
COM_WEBLINKS_FIELD_SECOND_LABEL="Second image"
COM_WEBLINKS_FIELD_SELECT_CATEGORY_DESC="Select a weblinks category to display"
COM_WEBLINKS_FIELD_SELECT_CATEGORY_LABEL="Select a category"
COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_DESC="Show the tags for a category"
COM_WEBLINKS_FIELD_SHOW_CAT_TAGS_LABEL="Show Tags"
COM_WEBLINKS_FIELD_SHOW_TAGS_DESC="Show the tags for a weblink"
COM_WEBLINKS_FIELD_SHOW_TAGS_LABEL="Show Tags "
COM_WEBLINKS_FIELD_STATE_DESC="Set publication status."
COM_WEBLINKS_FIELD_TARGET_DESC="Target browser window when the link is clicked"
COM_WEBLINKS_FIELD_TARGET_LABEL="Target"
COM_WEBLINKS_FIELD_TITLE_DESC="Web Link must have a title"
COM_WEBLINKS_FIELD_URL_DESC="You must enter a URL. IDN (International) Links are converted to punycode when they are saved."
COM_WEBLINKS_FIELD_URL_LABEL="URL"
COM_WEBLINKS_FIELD_VALUE_REPORTED="Reported"
COM_WEBLINKS_FIELD_VERSION_DESC="A count of the number of times this weblink has been revised."
COM_WEBLINKS_FIELD_VERSION_LABEL="Revision"
COM_WEBLINKS_FIELD_WIDTH_DESC="Width of the target popup or modal window. Defaults to 600x500 if one field is left empty."
COM_WEBLINKS_FIELD_WIDTH_LABEL="Width"
COM_WEBLINKS_FIELDSET_IMAGES="Images"
COM_WEBLINKS_FIELDSET_OPTIONS="Options"
COM_WEBLINKS_FILTER_CATEGORY="Filter Category"
COM_WEBLINKS_FILTER_STATE="Filter State"
COM_WEBLINKS_FLOAT_DESC="Controls placement of the image"
COM_WEBLINKS_FLOAT_LABEL="Image Float"
COM_WEBLINKS_HITS_DESC="Number of hits for this weblink"
COM_WEBLINKS_LEFT="Left"
COM_WEBLINKS_LIST_LAYOUT_DESC="These settings apply for Weblinks List Layout Options unless they are changed for a specific menu item."
COM_WEBLINKS_MANAGER_WEBLINK="Web Links Manager: Web Link"
COM_WEBLINKS_MANAGER_WEBLINKS="Web Links Manager: Web Links"
COM_WEBLINKS_N_ITEMS_ARCHIVED="%d weblinks successfully archived"
COM_WEBLINKS_N_ITEMS_ARCHIVED_1="%d weblink successfully archived"
COM_WEBLINKS_N_ITEMS_CHECKED_IN_0="No weblink successfully checked in"
COM_WEBLINKS_N_ITEMS_CHECKED_IN_1="%d weblink successfully checked in"
COM_WEBLINKS_N_ITEMS_CHECKED_IN_MORE="%d weblinks successfully checked in"
COM_WEBLINKS_N_ITEMS_DELETED="%d weblinks successfully deleted"
COM_WEBLINKS_N_ITEMS_DELETED_1="%d weblink successfully deleted"
COM_WEBLINKS_N_ITEMS_PUBLISHED="%d weblinks successfully published"
COM_WEBLINKS_N_ITEMS_PUBLISHED_1="%d weblink successfully published"
COM_WEBLINKS_N_ITEMS_TRASHED="%d weblinks successfully trashed"
COM_WEBLINKS_N_ITEMS_TRASHED_1="%d weblink successfully trashed"
COM_WEBLINKS_N_ITEMS_UNPUBLISHED="%d weblinks successfully unpublished"
COM_WEBLINKS_N_ITEMS_UNPUBLISHED_1="%d weblink successfully unpublished"
COM_WEBLINKS_NEW_WEBLINK="New Web link"
COM_WEBLINKS_NONE="None"
COM_WEBLINKS_OPTION_FILTER_ACCESS="- Filter Access -"
COM_WEBLINKS_OPTION_FILTER_CATEGORY="- Filter Category -"
COM_WEBLINKS_OPTION_FILTER_PUBLISHED="- Filter State -"
COM_WEBLINKS_OPTIONS="Options"
COM_WEBLINKS_ORDER_HEADING="Order"
COM_WEBLINKS_RIGHT="Right"
COM_WEBLINKS_SAVE_SUCCESS="Weblink successfully saved"
COM_WEBLINKS_SEARCH_IN_TITLE="Search in title"
COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC="If Show, empty categories will display. A category is only empty - if it has no Weblinks or subcategories."
COM_WEBLINKS_SUBMENU_CATEGORIES="Categories"
COM_WEBLINKS_SUBMENU_WEBLINKS="Web Links"
COM_WEBLINKS_XML_DESCRIPTION="Component for web links management"
JGLOBAL_NO_ITEM_SELECTED="No weblinks selected"
JGLOBAL_NEWITEMSLAST_DESC="New Weblinks default to the last position. Ordering can be changed after this Weblink is saved."
JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE="You are not allowed to create new weblinks in this category."
JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT="You are not allowed to edit one or more of these weblinks."
JLIB_RULES_SETTING_NOTES="1. If you change the setting, it will apply to this component. Note that:<br /><em>Inherited</em> means that the permissions from global configuration and parent group will be used.<br /><em>Denied</em> means that no matter what the global configuration or parent group settings are, the group being edited cannot take this action on this component.<br /><em>Allowed</em> means that the group being edited will be able to take this action for this component (but if this is in conflict with the global configuration or parent group it will have no impact; a conflict will be indicated by <em>Not Allowed (Locked)</em> under Calculated Settings).<br />2. If you select a new setting, click <em>Save</em> to refresh the calculated settings."

View File

@ -0,0 +1,21 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_WEBLINKS="Weblinks"
COM_WEBLINKS_XML_DESCRIPTION="Component for web links management"
COM_WEBLINKS_LINKS="Links"
COM_WEBLINKS_CATEGORIES="Categories"
COM_WEBLINKS_CATEGORY_ADD_TITLE="Category Manager: Add A New Weblinks Category"
COM_WEBLINKS_CATEGORY_EDIT_TITLE="Category Manager: Edit A Weblinks Category"
COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_DESC="Displays a list of Web Links for a category"
COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_TITLE="List Web Links in a Category"
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_DESC="Show all the web link categories within a category."
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_TITLE="List All Web Link Categories"
COM_WEBLINKS_FORM_VIEW_DEFAULT_DESC="Display a form to submit a web link in the frontend."
COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link"

View File

@ -0,0 +1,272 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields"
>
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL"
readonly="true" class="readonly"
description="JGLOBAL_FIELD_ID_DESC"/>
<field name="title" type="text"
class="inputbox input-xxlarge input-large-text"
size="40" label="JGLOBAL_TITLE"
description="COM_WEBLINKS_FIELD_TITLE_DESC" required="true" />
<field name="alias" type="text" class="inputbox"
size="40" label="JFIELD_ALIAS_LABEL"
description="COM_WEBLINKS_FIELD_ALIAS_DESC"
hint="JFIELD_ALIAS_PLACEHOLDER" />
<field name="catid" type="categoryedit" extension="com_weblinks"
label="JCATEGORY" description="COM_WEBLINKS_FIELD_CATEGORY_DESC"
class="inputbox"
>
</field>
<field name="url" type="url"
class="inputbox span12"
filter="url"
size="40" label="COM_WEBLINKS_FIELD_URL_LABEL"
description="COM_WEBLINKS_FIELD_URL_DESC" required="true" />
<field name="description" type="editor" buttons="true" hide="pagebreak,readmore"
class="inputbox"
filter="JComponentHelper::filterText"
label="JGLOBAL_DESCRIPTION" description="COM_WEBLINKS_FIELD_DESCRIPTION_DESC" />
<field name="hits"
type="text"
class="readonly"
size="6" label="JGLOBAL_HITS"
description="COM_WEBLINKS_HITS_DESC"
readonly="true"
filter="unset" />
<field
name="state"
type="list"
label="JSTATUS"
description="COM_WEBLINKS_FIELD_STATE_DESC"
class="chzn-color-state"
size="1"
default="1">
<option
value="1">JPUBLISHED</option>
<option
value="0">JUNPUBLISHED</option>
<option
value="2">JARCHIVED</option>
<option
value="-3">COM_WEBLINKS_FIELD_VALUE_REPORTED</option>
<option
value="-2">JTRASHED</option>
</field>
<field name="ordering" type="ordering" class="inputbox"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
content_type="com_weblinks.weblink"
/>
<field name="access" type="accesslevel" label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC" class="inputbox" size="1" />
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_WEBLINKS_FIELD_LANGUAGE_DESC"
class="inputbox">
<option value="*">JALL</option>
</field>
<field name="tags"
type="tag"
label="JTAG"
description="JTAG_DESC"
class="inputbox"
multiple="true"
>
</field>
<field name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
class="inputbox" size="45"
labelclass="control-label"
/>
<field name="created" type="calendar"
label="JGLOBAL_FIELD_CREATED_LABEL" description="JGLOBAL_FIELD_CREATED_DESC"
class="inputbox" size="22" format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<field name="created_by" type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL" description="JGLOBAL_FIELD_CREATED_BY_Desc" />
<field name="created_by_alias" type="text"
label="JGLOBAL_FIELD_CREATED_BY_ALIAS_LABEL" description="JGLOBAL_FIELD_CREATED_BY_ALIAS_DESC"
class="inputbox" size="20" />
<field name="modified" type="calendar" class="readonly"
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_WEBLINKS_FIELD_MODIFIED_DESC"
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<field name="modified_by" type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset" />
<field name="checked_out" type="hidden" filter="unset" />
<field name="checked_out_time" type="hidden" filter="unset" />
<field name="publish_up" type="calendar"
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL" description="JGLOBAL_FIELD_PUBLISH_UP_DESC"
class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22"
filter="user_utc" />
<field name="publish_down" type="calendar"
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL" description="JGLOBAL_FIELD_PUBLISH_DOWN_DESC"
class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22"
filter="user_utc" />
<field name="version" type="text" class="readonly"
label="COM_WEBLINKS_FIELD_VERSION_LABEL" size="6" description="COM_WEBLINKS_FIELD_VERSION_DESC"
readonly="true" filter="unset" />
<field name="metakey" type="textarea"
label="JFIELD_META_KEYWORDS_LABEL" description="JFIELD_META_KEYWORDS_DESC"
class="inputbox" rows="3" cols="30" />
<field name="metadesc" type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL" description="JFIELD_META_DESCRIPTION_DESC"
class="inputbox" rows="3" cols="30" />
<field name="xreference" type="text"
label="JFIELD_XREFERENCE_LABEL" description="JFIELD_XREFERENCE_DESC"
class="inputbox" size="20" />
</fieldset>
<fields name="params" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
<fieldset name="jbasic" label="COM_WEBLINKS_FIELDSET_OPTIONS">
<field name="target" type="list" default=""
label="COM_WEBLINKS_FIELD_TARGET_LABEL" description="COM_WEBLINKS_FIELD_TARGET_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JBROWSERTARGET_PARENT</option>
<option value="1">JBROWSERTARGET_NEW</option>
<option value="2">JBROWSERTARGET_POPUP</option>
<option value="3">JBROWSERTARGET_MODAL</option>
</field>
<field name="width" type="text"
class="inputbox validate-numeric" label="COM_WEBLINKS_FIELD_WIDTH_LABEL"
description="COM_WEBLINKS_FIELD_WIDTH_DESC" />
<field name="height" type="text"
class="inputbox validate-numeric" label="COM_WEBLINKS_FIELD_HEIGHT_LABEL"
description="COM_WEBLINKS_FIELD_HEIGHT_DESC" />
<field name="count_clicks" type="list"
class="chzn-color"
label="COM_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
description="COM_WEBLINKS_FIELD_COUNTCLICKS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fields>
<fields name="images">
<fieldset name="images" label="JGLOBAL_FIELDSET_IMAGE_OPTIONS">
<field
name="image_first"
type="media"
label="COM_WEBLINKS_FIELD_FIRST_LABEL"
description="COM_WEBLINKS_FIELD_FIRST_DESC" />
<field
name="float_first"
type="list"
label="COM_WEBLINKS_FLOAT_LABEL"
description="COM_WEBLINKS_FLOAT_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
</field>
<field name="image_first_alt"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_DESC"
class="inputbox"
size="20" />
<field name="image_first_caption"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_CAPTION_DESC"
class="inputbox"
size="20" />
<field name="spacer1"
type="spacer"
hr="true" />
<field
name="image_second"
type="media"
label="COM_WEBLINKS_FIELD_SECOND_LABEL"
description="COM_WEBLINKS_FIELD_SECOND_DESC" />
<field
name="float_second"
type="list"
label="COM_WEBLINKS_FLOAT_LABEL"
description="COM_WEBLINKS_FLOAT_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="right">COM_WEBLINKS_RIGHT</option>
<option value="left">COM_WEBLINKS_LEFT</option>
<option value="none">COM_WEBLINKS_NONE</option>
</field>
<field name="image_second_alt"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_ALT_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_ALT_DESC"
class="inputbox"
size="20" />
<field name="image_second_caption"
type="text"
label="COM_WEBLINKS_FIELD_IMAGE_CAPTION_LABEL"
description="COM_WEBLINKS_FIELD_IMAGE_CAPTION_DESC"
class="inputbox"
size="20" />
</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"
description="JFIELD_METADATA_ROBOTS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
</field>
<field name="rights" type="text"
label="JFIELD_META_RIGHTS_LABEL" description="JFIELD_META_RIGHTS_DESC"
required="false" filter="string" cols="30" rows="2" />
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,343 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks model.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksModelWeblink extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_weblinks.weblink';
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_WEBLINKS';
/**
* 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 for the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->state != -2)
{
return;
}
$user = JFactory::getUser();
if ($record->catid)
{
return $user->authorise('core.delete', 'com_weblinks.category.'.(int) $record->catid);
}
else
{
return parent::canDelete($record);
}
}
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
if (!empty($record->catid))
{
return $user->authorise('core.edit.state', 'com_weblinks.category.'.(int) $record->catid);
}
else
{
return parent::canEditState($record);
}
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $type The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A JTable object
*
* @since 1.6
*/
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Abstract method for getting the form from the model.
*
* @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 mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_weblinks.weblink', 'weblink', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Determine correct permissions to check.
if ($this->getState('weblink.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('state', 'disabled', 'true');
$form->setFieldAttribute('publish_up', 'disabled', 'true');
$form->setFieldAttribute('publish_down', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('state', 'filter', 'unset');
$form->setFieldAttribute('publish_up', 'filter', 'unset');
$form->setFieldAttribute('publish_down', 'filter', 'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return array The default data is an empty array.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('weblink.id') == 0)
{
$app = JFactory::getApplication();
$data->set('catid', $app->input->get('catid', $app->getUserState('com_weblinks.weblinks.filter.category_id'), 'int'));
}
}
$this->preprocessData('com_weblinks.weblink', $data);
return $data;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Convert the metadata field to an array.
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
// Convert the images field to an array.
$registry = new JRegistry;
$registry->loadString($item->images);
$item->images = $registry->toArray();
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_weblinks.weblink');
$item->metadata['tags'] = $item->tags;
}
}
return $item;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A reference to a JTable object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplication::stringURLSafe($table->alias);
if (empty($table->alias))
{
$table->alias = JApplication::stringURLSafe($table->title);
}
if (empty($table->id))
{
// Set the values
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__weblinks'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
else
{
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->get('id');
}
}
// Increment the weblink version number.
$table->version++;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A JTable object.
*
* @return array An array of conditions to add to ordering queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
$condition = array();
$condition[] = 'catid = ' . (int) $table->catid;
return $condition;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 3.1
*/
public function save($data)
{
$app = JFactory::getApplication();
// Alter the title for save as copy
if ($app->input->get('task') == 'save2copy')
{
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
$data['title'] = $name;
$data['alias'] = $alias;
$data['state'] = 0;
}
return parent::save($data);
}
/**
* Method to change the title & alias.
*
* @param integer $category_id The id of the parent.
* @param string $alias The alias.
* @param string $name The title.
*
* @return array Contains the modified title and alias.
*
* @since 3.1
*/
protected function generateNewTitle($category_id, $alias, $name)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
{
if ($name == $table->title)
{
$name = JString::increment($name);
}
$alias = JString::increment($alias, 'dash');
}
return array($name, $alias);
}
}

View File

@ -0,0 +1,232 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of weblink records.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksModelWeblinks extends JModelList
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_title',
'state', 'a.state',
'access', 'a.access', 'access_level',
'created', 'a.created',
'created_by', 'a.created_by',
'ordering', 'a.ordering',
'featured', 'a.featured',
'language', 'a.language',
'hits', 'a.hits',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'url', 'a.url',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$accessId = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
$published = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $published);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
$tag = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', '');
$this->setState('filter.tag', $tag);
// Load the parameters.
$params = JComponentHelper::getParams('com_weblinks');
$this->setState('params', $params);
// List state information.
parent::populateState('a.title', 'asc');
}
/**
* 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.access');
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.language');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid,' .
'a.hits,' .
'a.state, a.access, a.ordering,' .
'a.language, a.publish_up, a.publish_down'
)
);
$query->from($db->quoteName('#__weblinks') . ' AS a');
// Join over the language
$query->select('l.title AS language_title')
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the categories.
$query->select('c.title AS category_title')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$query->where('a.access = ' . (int) $access);
}
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$query->where('a.catid = ' . (int) $categoryId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search . ')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where('a.language = ' . $db->quote($language));
}
$tagId = $this->getState('filter.tag');
// Filter by a single tag.
if (is_numeric($tagId))
{
$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId)
->join(
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_weblinks.weblink')
);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
{
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
}

View File

@ -0,0 +1,42 @@
CREATE TABLE IF NOT EXISTS `#__weblinks` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`catid` int(11) NOT NULL DEFAULT '0',
`sid` int(11) NOT NULL DEFAULT '0',
`title` varchar(250) NOT NULL DEFAULT '',
`alias` varchar(255) NOT NULL DEFAULT '',
`url` varchar(250) NOT NULL DEFAULT '',
`description` text NOT NULL,
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`hits` int(11) NOT NULL DEFAULT '0',
`state` tinyint(1) NOT NULL DEFAULT '0',
`checked_out` int(11) NOT NULL DEFAULT '0',
`checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ordering` int(11) NOT NULL DEFAULT '0',
`archived` tinyint(1) NOT NULL DEFAULT '0',
`approved` tinyint(1) NOT NULL DEFAULT '1',
`access` int(11) NOT NULL DEFAULT '1',
`params` text NOT NULL,
`language` char(7) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(10) unsigned NOT NULL DEFAULT '0',
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(10) unsigned NOT NULL DEFAULT '0',
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`metadata` text NOT NULL,
`featured` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'Set if link is featured.',
`xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_state` (`state`),
KEY `idx_catid` (`catid`),
KEY `idx_createdby` (`created_by`),
KEY `idx_featured_catid` (`featured`,`catid`),
KEY `idx_language` (`language`),
KEY `idx_xreference` (`xreference`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS `#__weblinks`;

View File

@ -0,0 +1,286 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblink Table class
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksTableWeblink extends JTable
{
/**
* Constructor
*
* @param JDatabaseDriver &$db A database connector object
*/
public function __construct(&$db)
{
parent::__construct('#__weblinks', 'id', $db);
}
/**
* Overloaded bind function to pre-process the params.
*
* @param mixed $array An associative array or object to bind to the JTable instance.
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return boolean True on success.
*
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new JRegistry;
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata']))
{
$registry = new JRegistry;
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (isset($array['images']) && is_array($array['images']))
{
$registry = new JRegistry;
$registry->loadArray($array['images']);
$array['images'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
/**
* Overload the store method for the Weblinks table.
*
* @param boolean Toggle whether null values should be updated.
* @return boolean True on success, false on failure.
* @since 1.6
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id)
{
// Existing item
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
}
else
{
// New weblink. A weblink created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created)
{
$this->created = $date->toSql();
}
if (empty($this->created_by))
{
$this->created_by = $user->get('id');
}
}
// Set publish_up to null date if not set
if (!$this->publish_up)
{
$this->publish_up = $this->_db->getNullDate();
}
// Set publish_down to null date if not set
if (!$this->publish_down)
{
$this->publish_down = $this->_db->getNullDate();
}
// Verify that the alias is unique
$table = JTable::getInstance('Weblink', 'WeblinksTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
return false;
}
// Convert IDN urls to punycode
$this->url = JStringPunycode::urlToPunycode($this->url);
return parent::store($updateNulls);
}
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*/
public function check()
{
if (JFilterInput::checkAttribute(array ('href', $this->url)))
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
return false;
}
// check for valid name
if (trim($this->title) == '')
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
return false;
}
// Check for existing name
$query = $this->_db->getQuery(true)
->select($this->_db->quoteName('id'))
->from($this->_db->quoteName('#__weblinks'))
->where($this->_db->quoteName('title') . ' = ' . $this->_db->quote($this->title))
->where($this->_db->quoteName('catid') . ' = ' . (int) $this->catid);
$this->_db->setQuery($query);
$xid = (int) $this->_db->loadResult();
if ($xid && $xid != (int) $this->id)
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME'));
return false;
}
if (empty($this->alias))
{
$this->alias = $this->title;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
// Check the publish down date is not earlier than publish up.
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up)
{
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
// clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->metakey))
{
// only process if not empty
$bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters
$keys = explode(',', $after_clean); // create array using commas as delimiter
$clean_keys = array();
foreach ($keys as $key)
{
if (trim($key)) { // ignore blank keywords
$clean_keys[] = trim($key);
}
}
$this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", "
}
return true;
}
/**
* Method to set the publishing state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed An optional array of primary key values to update. If not
* set the instance property value is used.
* @param integer The publishing state. eg. [0 = unpublished, 1 = published]
* @param integer The user id of the user performing the operation.
* @return boolean True on success.
* @since 1.0.4
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else {
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Build the WHERE clause for the primary keys.
$where = $k.'='.implode(' OR '.$k.'=', $pks);
// Determine if there is checkin support for the table.
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time'))
{
$checkin = '';
}
else
{
$checkin = ' AND (checked_out = 0 OR checked_out = '.(int) $userId.')';
}
// Update the publishing state for rows with the given primary keys.
$this->_db->setQuery(
'UPDATE '.$this->_db->quoteName($this->_tbl) .
' SET '.$this->_db->quoteName('state').' = '.(int) $state .
' WHERE ('.$where.')' .
$checkin
);
try
{
$this->_db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
{
// Checkin the rows.
foreach ($pks as $pk)
{
$this->checkin($pk);
}
}
// If the JTable instance value is in the list of primary keys that were set, set the instance.
if (in_array($this->$k, $pks))
{
$this->state = $state;
}
$this->setError('');
return true;
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'weblink.cancel' || document.formvalidator.isValid(document.id('weblink-form'))) {
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task, document.getElementById('weblink-form'));
}
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="weblink-form" class="form-validate">
<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
<div class="form-horizontal">
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', empty($this->item->id) ? JText::_('COM_WEBLINKS_NEW_WEBLINK', true) : JText::_('COM_WEBLINKS_EDIT_WEBLINK', true)); ?>
<div class="row-fluid">
<div class="span9">
<div class="form-vertical">
<?php echo $this->form->getControlGroup('url'); ?>
<?php echo $this->form->getControlGroup('description'); ?>
</div>
</div>
<div class="span3">
<?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'images', JText::_('JGLOBAL_FIELDSET_IMAGE_OPTIONS', true)); ?>
<div class="row-fluid">
<div class="span6">
<?php echo $this->form->getControlGroup('images'); ?>
<?php foreach ($this->form->getGroup('images') as $field) : ?>
<?php echo $field->getControlGroup(); ?>
<?php endforeach; ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
<div class="row-fluid form-horizontal-desktop">
<div class="span6">
<?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
</div>
<div class="span6">
<?php echo JLayoutHelper::render('joomla.edit.metadata', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
</div>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1,12 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.metadata', $this);

View File

@ -0,0 +1,28 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$fieldSets = $this->form->getFieldsets('params');
foreach ($fieldSets as $name => $fieldSet) :
?>
<div class="tab-pane" id="params-<?php echo $name;?>">
<?php
if (isset($fieldSet->description) && trim($fieldSet->description)) :
echo '<p class="alert alert-info">'.$this->escape(JText::_($fieldSet->description)).'</p>';
endif;
?>
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>

View File

@ -0,0 +1,97 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View to edit a weblink.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksViewWeblink extends JViewLegacy
{
protected $state;
protected $item;
protected $form;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
// Since we don't track these assets at the item level, use the category id.
$canDo = JHelperContent::getActions('com_weblinks', 'category', $this->item->catid);
JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINK'), 'link weblinks');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('com_weblinks', 'core.create')))))
{
JToolbarHelper::apply('weblink.apply');
JToolbarHelper::save('weblink.save');
}
if (!$checkedOut && (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))))
{
JToolbarHelper::save2new('weblink.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0))
{
JToolbarHelper::save2copy('weblink.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('weblink.cancel');
}
else
{
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
{
JToolbarHelper::versions('com_weblinks.weblink', $this->item->id);
}
JToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS_EDIT');
}
}

View File

@ -0,0 +1,211 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
$saveOrder = $listOrder == 'a.ordering';
if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'weblinkList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo JText::_('COM_WEBLINKS_SEARCH_IN_TITLE');?></label>
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_WEBLINKS_SEARCH_IN_TITLE'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC');?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING');?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING');?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY');?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder);?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped" id="weblinkList">
<thead>
<tr>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?>
</th>
<th width="1%" class="hidden-phone">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="1%" style="min-width:55px" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_LANGUAGE', 'a.language', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="10">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$ordering = ($listOrder == 'a.ordering');
$item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]='. $item->catid);
$canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid);
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid);
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin;
?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid?>">
<td class="order nowrap center hidden-phone">
<?php
$iconClass = '';
if (!$canChange)
{
$iconClass = ' inactive';
}
elseif (!$saveOrder)
{
$iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass ?>">
<i class="icon-menu"></i>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering;?>" class="width-20 text-area-order " />
<?php endif; ?>
</td>
<td class="center hidden-phone">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td class="center">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
</td>
<td class="nowrap has-context">
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id='.(int) $item->id); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<span class="small">
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias));?>
</span>
<div class="small">
<?php echo $this->escape($item->category_title); ?>
</div>
</td>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?>
</td>
<td class="center hidden-phone">
<?php echo $item->hits; ?>
</td>
<td class="small nowrap hidden-phone">
<?php if ($item->language == '*'):?>
<?php echo JText::alt('JALL', 'language'); ?>
<?php else:?>
<?php echo $item->language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?>
<?php endif;?>
</td>
<td class="center hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php //Load the batch processing form. ?>
<?php echo $this->loadTemplate('batch'); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$published = $this->state->get('filter.state');
?>
<div class="modal hide fade" id="collapseModal">
<div class="modal-header">
<button type="button" role="presentation" class="close" data-dismiss="modal">&#215;</button>
<h3><?php echo JText::_('COM_WEBLINKS_BATCH_OPTIONS'); ?></h3>
</div>
<div class="modal-body modal-batch">
<p><?php echo JText::_('COM_WEBLINKS_BATCH_TIP'); ?></p>
<div class="row-fluid">
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.tag'); ?>
</div>
</div>
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.language'); ?>
</div>
</div>
</div>
<div class="row-fluid">
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.access'); ?>
</div>
</div>
<?php if ($published >= 0) : ?>
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.item', 'com_weblinks'); ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<div class="modal-footer">
<button class="btn" type="button" onclick="document.id('batch-category-id').value='';document.id('batch-access').value='';document.id('batch-language-id').value='';document.id('batch-tag-id)').value=''" data-dismiss="modal">
<?php echo JText::_('JCANCEL'); ?>
</button>
<button class="btn btn-primary" type="submit" onclick="Joomla.submitbutton('weblink.batch');">
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</div>
</div>

View File

@ -0,0 +1,164 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of weblinks.
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksViewWeblinks extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*
* @return void
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
WeblinksHelper::addSubmenu('weblinks');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/weblinks.php';
$state = $this->get('State');
$canDo = JHelperContent::getActions('com_weblinks', 'category', $state->get('filter.category_id'));
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolBar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks');
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
{
JToolbarHelper::addNew('weblink.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('weblink.edit');
}
if ($canDo->get('core.edit.state')) {
JToolbarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::archiveList('weblinks.archive');
JToolbarHelper::checkin('weblinks.checkin');
}
if ($state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH');
} elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('weblinks.trash');
}
// Add a batch button
if ($user->authorise('core.create', 'com_weblinks') && $user->authorise('core.edit', 'com_weblinks') && $user->authorise('core.edit.state', 'com_weblinks'))
{
JHtml::_('bootstrap.modal', 'collapseModal');
$title = JText::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button
$layout = new JLayoutFile('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($user->authorise('core.admin', 'com_weblinks'))
{
JToolbarHelper::preferences('com_weblinks');
}
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS');
JHtmlSidebar::setAction('index.php?option=com_weblinks&view=weblinks');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_state',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true)
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_weblinks'), 'value', 'text', $this->state->get('filter.category_id'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_ACCESS'),
'filter_access',
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_LANGUAGE'),
'filter_language',
JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_TAG'),
'filter_tag',
JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag'))
);
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'a.ordering' => JText::_('JGRID_HEADING_ORDERING'),
'a.state' => JText::_('JSTATUS'),
'a.title' => JText::_('JGLOBAL_TITLE'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'a.hits' => JText::_('JGLOBAL_HITS'),
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}

View File

@ -0,0 +1,20 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_weblinks'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$controller = JControllerLegacy::getInstance('Weblinks');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade">
<name>com_weblinks</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<copyright>(C) 2005 - 2014 Open Source Matters. All rights reserved.
</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>3.0.0</version>
<description>COM_WEBLINKS_XML_DESCRIPTION</description>
<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">
<filename>index.html</filename>
<filename>weblinks.php</filename>
<filename>controller.php</filename>
<filename>router.php</filename>
<filename>metadata.xml</filename>
<folder>views</folder>
<folder>models</folder>
<folder>controllers</folder>
<folder>helpers</folder>
</files>
<languages folder="site">
<language tag="en-GB">language/en-GB.com_weblinks.ini</language>
</languages>
<administration>
<menu img="class:weblinks">com_weblinks</menu>
<submenu>
<!--
Note that all & must be escaped to &amp; for the file to be valid
XML and be parsed by the installer
-->
<menu link="option=com_weblinks" view="links" img="class:weblinks"
alt="Weblinks/Links">com_weblinks_links</menu>
<menu link="option=com_categories&amp;extension=com_weblinks"
view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu>
</submenu>
<files folder="admin">
<filename>access.xml</filename>
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>index.html</filename>
<filename>weblinks.php</filename>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>models</folder>
<folder>sql</folder>
<folder>tables</folder>
<folder>views</folder>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB.com_weblinks.ini</language>
<language tag="en-GB">language/en-GB.com_weblinks.sys.ini</language>
</languages>
</administration>
</extension>

View File

@ -0,0 +1,65 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Component Controller
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
$cachable = true; // Huh? Why not just put that in the constructor?
$user = JFactory::getUser();
// Set the default view name and format from the Request.
// Note we are using w_id to avoid collisions with the router and the return page.
// Frontend is a bit messier than the backend.
$id = $this->input->getInt('w_id');
$vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName);
if ($user->get('id') ||($this->input->getMethod() == 'POST' && $vName = 'categories'))
{
$cachable = false;
}
$safeurlparams = array(
'id' => 'INT',
'limit' => 'UINT',
'limitstart' => 'UINT',
'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD',
'lang' => 'CMD'
);
// Check for edit form.
if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id))
{
// Somehow the person just went to the form - we don't allow that.
return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
}
return parent::display($cachable, $safeurlparams);
}
}

View File

@ -0,0 +1,313 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksControllerWeblink extends JControllerForm
{
/**
* @since 1.6
*/
protected $view_item = 'form';
/**
* @since 1.6
*/
protected $view_list = 'categories';
/**
* The URL edit variable.
*
* @var string
* @since 3.2
*/
protected $urlVar = 'a.id';
/**
* Method to add a new record.
*
* @return boolean True if the article can be added, false if not.
* @since 1.6
*/
public function add()
{
if (!parent::add())
{
// Redirect to the return page.
$this->setRedirect($this->getReturnPage());
}
}
/**
* 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 = array())
{
$user = JFactory::getUser();
$categoryId = JArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the URL check it.
$allow = $user->authorise('core.create', $this->option.'.category.'.$categoryId);
}
if ($allow === null)
{
// In the absense of better information, revert to the component permissions.
return parent::allowAdd($data);
}
else
{
return $allow;
}
}
/**
* Method to check if you can add a new 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 = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$categoryId = 0;
if ($recordId)
{
$categoryId = (int) $this->getModel()->getItem($recordId)->catid;
}
if ($categoryId)
{
// The category has been set. Check the category permissions.
return JFactory::getUser()->authorise('core.edit', $this->option.'.category.'.$categoryId);
}
else
{
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
}
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return Boolean True if access level checks pass, false otherwise.
* @since 1.6
*/
public function cancel($key = 'w_id')
{
parent::cancel($key);
// Redirect to the return page.
$this->setRedirect($this->getReturnPage());
}
/**
* Method to edit an existing record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return Boolean True if access level check and checkout passes, false otherwise.
* @since 1.6
*/
public function edit($key = null, $urlVar = 'w_id')
{
$result = parent::edit($key, $urlVar);
return $result;
}
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
* @since 1.5
*/
public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Gets the URL arguments to append to an item redirect.
*
* @param integer $recordId The primary key id for the item.
* @param string $urlVar The name of the URL variable for the id.
*
* @return string The arguments to append to the redirect URL.
* @since 1.6
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = null)
{
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
$itemId = $this->input->getInt('Itemid');
$return = $this->getReturnPage();
if ($itemId)
{
$append .= '&Itemid='.$itemId;
}
if ($return)
{
$append .= '&return='.base64_encode($return);
}
return $append;
}
/**
* Get the return URL.
*
* If a "return" variable has been passed in the request
*
* @return string The return URL.
* @since 1.6
*/
protected function getReturnPage()
{
$return = $this->input->get('return', null, 'base64');
if (empty($return) || !JUri::isInternal(base64_decode($return)))
{
return JUri::base();
}
else
{
return base64_decode($return);
}
}
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
return;
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return Boolean True if successful, false otherwise.
* @since 1.6
*/
public function save($key = null, $urlVar = 'w_id')
{
$result = parent::save($key, $urlVar);
// If ok, redirect to the return page.
if ($result)
{
$this->setRedirect($this->getReturnPage());
}
return $result;
}
/**
* Go to a weblink
*
* @return void
* @since 1.6
*/
public function go()
{
// Get the ID from the request
$id = $this->input->getInt('id');
// Get the model, requiring published items
$modelLink = $this->getModel('Weblink', '', array('ignore_request' => true));
$modelLink->setState('filter.published', 1);
// Get the item
$link = $modelLink->getItem($id);
// Make sure the item was found.
if (empty($link))
{
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
}
// Check whether item access level allows access.
$user = JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();
if (!in_array($link->access, $groups))
{
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Check whether category access level allows access.
$modelCat = $this->getModel('Category', 'WeblinksModel', array('ignore_request' => true));
$modelCat->setState('filter.published', 1);
// Get the category
$category = $modelCat->getCategory($link->catid);
// Make sure the category was found.
if (empty($category))
{
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
}
// Check whether item access level allows access.
if (!in_array($category->access, $groups))
{
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Redirect to the URL
// TODO: Probably should check for a valid http link
if ($link->url)
{
$modelLink->hit($id);
JFactory::getApplication()->redirect($link->url);
}
else
{
return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID'));
}
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');
/**
* Weblinks Component Association Helper
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 3.0
*/
abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
{
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
jimport('helper.route', JPATH_COMPONENT_SITE);
$app = JFactory::getApplication();
$jinput = $app->input;
$view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view == 'category' || $view == 'categories')
{
return self::getCategoryAssociations($id, 'com_weblinks');
}
return array();
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Component Category Tree
*
* @static
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksCategories extends JCategories
{
public function __construct($options = array())
{
$options['table'] = '#__weblinks';
$options['extension'] = 'com_weblinks';
parent::__construct($options);
}
}

View File

@ -0,0 +1,77 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblink Component HTML Helper
*
* @static
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class JHtmlIcon
{
public static function create($weblink, $params)
{
JHtml::_('bootstrap.tooltip');
$uri = JUri::getInstance();
$url = JRoute::_(WeblinksHelperRoute::getFormRoute(0, base64_encode($uri)));
$text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true);
$button = JHtml::_('link', $url, $text);
$output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_FORM_CREATE_WEBLINK') . '">' . $button . '</span>';
return $output;
}
public static function edit($weblink, $params, $attribs = array())
{
$uri = JUri::getInstance();
if ($params && $params->get('popup'))
{
return;
}
if ($weblink->state < 0)
{
return;
}
JHtml::_('bootstrap.tooltip');
$url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri));
$icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png';
$text = JHtml::_('image', 'system/'.$icon, JText::_('JGLOBAL_EDIT'), null, true);
if ($weblink->state == 0)
{
$overlib = JText::_('JUNPUBLISHED');
}
else
{
$overlib = JText::_('JPUBLISHED');
}
$date = JHtml::_('date', $weblink->created);
$author = $weblink->created_by_alias ? $weblink->created_by_alias : $weblink->author;
$overlib .= '&lt;br /&gt;';
$overlib .= $date;
$overlib .= '&lt;br /&gt;';
$overlib .= htmlspecialchars($author, ENT_COMPAT, 'UTF-8');
$button = JHtml::_('link', JRoute::_($url), $text);
$output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>';
return $output;
}
}

View File

@ -0,0 +1,241 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Component Route Helper
*
* @static
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
abstract class WeblinksHelperRoute
{
protected static $lookup;
protected static $lang_lookup = array();
/**
* @param integer The route of the weblink
*/
public static function getWeblinkRoute($id, $catid, $language = 0)
{
$needles = array(
'weblink' => array((int) $id)
);
//Create the link
$link = 'index.php?option=com_weblinks&view=weblink&id='. $id;
if ($catid > 1)
{
$categories = JCategories::getInstance('Weblinks');
$category = $categories->get($catid);
if ($category)
{
$needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category'];
$link .= '&catid='.$catid;
}
}
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
self::buildLanguageLookup();
if (isset(self::$lang_lookup[$language]))
{
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
return $link;
}
/**
* @param integer $id The id of the weblink.
* @param string $return The return page variable.
*/
public static function getFormRoute($id, $return = null)
{
// Create the link.
if ($id)
{
$link = 'index.php?option=com_weblinks&task=weblink.edit&w_id='. $id;
}
else
{
$link = 'index.php?option=com_weblinks&task=weblink.add&w_id=0';
}
if ($return)
{
$link .= '&return='.$return;
}
return $link;
}
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof JCategoryNode)
{
$id = $catid->id;
$category = $catid;
}
else
{
$id = (int) $catid;
$category = JCategories::getInstance('Weblinks')->get($id);
}
if ($id < 1 || !($category instanceof JCategoryNode))
{
$link = '';
}
else
{
$needles = array();
// Create the link
$link = 'index.php?option=com_weblinks&view=category&id='.$id;
$catids = array_reverse($category->getPath());
$needles['category'] = $catids;
$needles['categories'] = $catids;
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
self::buildLanguageLookup();
if (isset(self::$lang_lookup[$language]))
{
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
}
return $link;
}
protected static function buildLanguageLookup()
{
if (count(self::$lang_lookup) == 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
self::$lang_lookup[$lang->lang_code] = $lang->sef;
}
}
}
protected static function _findItem($needles = null)
{
$app = JFactory::getApplication();
$menus = $app->getMenu('site');
$language = isset($needles['language']) ? $needles['language'] : '*';
// Prepare the reverse lookup array.
if (!isset(self::$lookup[$language]))
{
self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_weblinks');
$attributes = array('component_id');
$values = array($component->id);
if ($language != '*')
{
$attributes[] = 'language';
$values[] = array($needles['language'], '*');
}
$items = $menus->getItems($attributes, $values);
if ($items)
{
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view']))
{
$view = $item->query['view'];
if (!isset(self::$lookup[$language][$view]))
{
self::$lookup[$language][$view] = array();
}
if (isset($item->query['id']))
{
// here it will become a bit tricky
// language != * can override existing entries
// language == * cannot override existing entries
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{
self::$lookup[$language][$view][$item->query['id']] = $item->id;
}
}
}
}
}
}
if ($needles)
{
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$language][$view]))
{
foreach ($ids as $id)
{
if (isset(self::$lookup[$language][$view][(int) $id]))
{
return self::$lookup[$language][$view][(int) $id];
}
}
}
}
}
// Check if the active menuitem matches the requested language
$active = $menus->getActive();
if ($active && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled()))
{
return $active->id;
}
// If not found, return language specific home link
$default = $menus->getDefault($language);
return !empty($default->id) ? $default->id : null;
}
}

View File

@ -0,0 +1,34 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
COM_WEBLINKS_DEFAULT_PAGE_TITLE="Web Links"
COM_WEBLINKS_EDIT="Edit Web link"
COM_WEBLINKS_ERR_TABLES_NAME="There is already a Web Link with that name in this category. Please try again."
COM_WEBLINKS_ERR_TABLES_PROVIDE_URL="Please provide a valid URL"
COM_WEBLINKS_ERR_TABLES_TITLE="Your Web Link must contain a title."
COM_WEBLINKS_ERROR_CATEGORY_NOT_FOUND="Web link category not found"
COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another Web Link from this category has the same alias"
COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND="Web Link not found"
COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID="Invalid Web link URL"
COM_WEBLINKS_FIELD_ALIAS_DESC="The alias is for internal use only. Leave this blank and Joomla will fill in a default value from the title. It has to be unique for each web link in the same category."
COM_WEBLINKS_FIELD_CATEGORY_DESC="You must select a Category."
COM_WEBLINKS_FIELD_DESCRIPTION_DESC="Enter a description for your Web link"
COM_WEBLINKS_FILTER_LABEL="Filter field"
COM_WEBLINKS_FILTER_SEARCH_DESC="Web Links Filter Search"
COM_WEBLINKS_FIELD_TITLE_DESC="Your Web Link must have a Title."
COM_WEBLINKS_FIELD_URL_DESC="You must enter a URL."
COM_WEBLINKS_FIELD_URL_LABEL="URL"
COM_WEBLINKS_FORM_CREATE_WEBLINK="Submit a Web Link"
COM_WEBLINKS_GRID_TITLE="Title"
COM_WEBLINKS_LINK="Web Link"
COM_WEBLINKS_NAME="Name"
COM_WEBLINKS_NO_WEBLINKS="There are no Web Links in this category"
COM_WEBLINKS_NUM="# of links:"
COM_WEBLINKS_FORM_EDIT_WEBLINK="Edit a Web Link"
COM_WEBLINKS_FORM_SUBMIT_WEBLINK="Submit a Web Link"
COM_WEBLINKS_SAVE_SUCCESS="Web link successfully saved"
COM_WEBLINKS_SUBMIT_SAVE_SUCCESS="Web Link successfully submitted"
COM_WEBLINKS_WEB_LINKS="Web links"
JGLOBAL_NEWITEMSLAST_DESC="New Web Links default to the last position. Ordering can be changed after this Web Link has been saved."

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
</metadata>

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* This models supports retrieving lists of article categories.
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksModelCategories extends JModelList
{
/**
* Model context string.
*
* @var string
*/
public $_context = 'com_weblinks.categories';
/**
* The category context (allows other extensions to derived from this model).
*
* @var string
*/
protected $_extension = 'com_weblinks';
private $_parent = null;
private $_items = null;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parentId = $app->input->getInt('id');
$this->setState('filter.parentId', $parentId);
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.extension');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.parentId');
return parent::getStoreId($id);
}
/**
* redefine the function an add some properties to make the styling more easy
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
if (!count($this->_items))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_num_links', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = JCategories::getInstance('Weblinks', $options);
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
if (is_object($this->_parent))
{
$this->_items = $this->_parent->getChildren();
} else {
$this->_items = false;
}
}
return $this->_items;
}
public function getParent()
{
if (!is_object($this->_parent))
{
$this->getItems();
}
return $this->_parent;
}
}

View File

@ -0,0 +1,365 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Weblinks Component Weblink Model
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksModelCategory extends JModelList
{
/**
* Category items data
*
* @var array
*/
protected $_item = null;
protected $_articles = null;
protected $_siblings = null;
protected $_children = null;
protected $_parent = null;
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'hits', 'a.hits',
'ordering', 'a.ordering',
);
}
parent::__construct($config);
}
/**
* The category that applies.
*
* @access protected
* @var object
*/
protected $_category = null;
/**
* The list of other weblink categories.
*
* @access protected
* @var array
*/
protected $_categories = null;
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Invoke the parent getItems method to get the main list
$items = parent::getItems();
// Convert the params field into an object, saving original in _params
foreach ($items as $item)
{
if (!isset($this->_params))
{
$params = new JRegistry;
$params->loadString($item->params);
$item->params = $params;
}
// Get the tags
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_weblinks.weblink', $item->id);
}
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @since 1.6
*/
protected function getListQuery()
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select required fields from the categories.
$query->select($this->getState('list.select', 'a.*'))
->from($db->quoteName('#__weblinks') . ' AS a')
->where('a.access IN (' . $groups . ')');
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
$query->where('a.catid = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')');
//Filter by published category
$cpublished = $this->getState('filter.c.published');
if (is_numeric($cpublished))
{
$query->where('c.published = ' . (int) $cpublished);
}
}
// Join over the users for the author and modified_by names.
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
->select("ua.email AS author_email")
->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Filter by state
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.state = ' . (int) $state);
}
// do not show trashed links on the front-end
$query->where('a.state != -2');
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$date = JFactory::getDate();
$nowDate = $db->quote($date->toSql());
if ($this->getState('filter.publish_date'))
{
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// Filter by search in title
$search = $this->getState('list.filter');
if (!empty($search))
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_weblinks');
// List state information
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
$this->setState('list.limit', $limit);
$limitstart = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
$orderCol = $app->input->get('filter_order', 'ordering');
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$id = $app->input->get('id', 0, 'int');
$this->setState('category.id', $id);
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks')))
{
// limit to published for people who can't edit or edit.state.
$this->setState('filter.state', 1);
// Filter by start and end dates.
$this->setState('filter.publish_date', true);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Load the parameters.
$this->setState('params', $params);
}
/**
* Method to get category data for the current category
*
* @param integer An optional ID
*
* @return object
* @since 1.5
*/
public function getCategory()
{
if (!is_object($this->_item))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_num_links_cat', 1) || $params->get('show_empty_categories', 0);
$categories = JCategories::getInstance('Weblinks', $options);
$this->_item = $categories->get($this->getState('category.id', 'root'));
if (is_object($this->_item))
{
$this->_children = $this->_item->getChildren();
$this->_parent = false;
if ($this->_item->getParent())
{
$this->_parent = $this->_item->getParent();
}
$this->_rightsibling = $this->_item->getSibling();
$this->_leftsibling = $this->_item->getSibling(false);
}
else
{
$this->_children = false;
$this->_parent = false;
}
}
return $this->_item;
}
/**
* Get the parent category
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function getParent()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_parent;
}
/**
* Get the sibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getLeftSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_leftsibling;
}
function &getRightSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getChildren()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_children;
}
/**
* Increment the hit counter for the category.
*
* @param int $pk Optional primary key of the category to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*
* @since 3.2
*/
public function hit($pk = 0)
{
$input = JFactory::getApplication()->input;
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
$table = JTable::getInstance('Category', 'JTable');
$table->load($pk);
$table->hit($pk);
}
return true;
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT_ADMINISTRATOR.'/models/weblink.php';
/**
* Weblinks model.
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.6
*/
class WeblinksModelForm extends WeblinksModelWeblink
{
/**
* Model typeAlias string. Used for version history.
*
* @var string
*/
public $typeAlias = 'com_weblinks.weblink';
/**
* Get the return URL.
*
* @return string The return URL.
* @since 1.6
*/
public function getReturnPage()
{
return base64_encode($this->getState('return_page'));
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication();
// Load state from the request.
$pk = $app->input->getInt('w_id');
$this->setState('weblink.id', $pk);
// Add compatibility variable for default naming conventions.
$this->setState('form.id', $pk);
$categoryId = $app->input->getInt('catid');
$this->setState('weblink.catid', $categoryId);
$return = $app->input->get('return', null, 'base64');
if (!JUri::isInternal(base64_decode($return)))
{
$return = null;
}
$this->setState('return_page', base64_decode($return));
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('layout', $app->input->getString('layout'));
}
}

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_categories/models/fields">
<field name="id" type="hidden"
label="WEBLINK_ID_LABEL"
readonly="true"
required="true"
size="10"
default="0"
/>
<field
id="contenthistory"
name="contenthistory"
type="contenthistory"
data-typeAlias="com_weblinks.weblink"
label="JTOOLBAR_VERSIONS" />
<field name="title" type="text"
description="COM_WEBLINKS_FIELD_TITLE_DESC"
label="JGLOBAL_TITLE"
required="true"
size="30"
/>
<field name="alias" type="text"
description="COM_WEBLINKS_FIELD_ALIAS_DESC"
label="JFIELD_ALIAS_LABEL"
hint="JFIELD_ALIAS_PLACEHOLDER"
size="45"
/>
<field name="description" type="editor"
buttons="true"
hide="pagebreak,readmore"
description="COM_WEBLINKS_FIELD_DESCRIPTION_DESC"
filter="safehtml"
label="JGLOBAL_DESCRIPTION"
asset_id="com_weblinks"
/>
<field name="state" type="list"
default="1"
description="JFIELD_PUBLISHED_DESC"
label="JSTATUS"
size="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="catid" type="categoryedit"
description="COM_WEBLINKS_FIELD_CATEGORY_DESC"
extension="com_weblinks"
label="JCATEGORY"
required="true"
/>
<field name="url" type="url"
filter="url"
description="COM_WEBLINKS_FIELD_URL_DESC"
label="COM_WEBLINKS_FIELD_URL_LABEL"
required="true"
size="45"
/>
<field
name="language"
type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="JFIELD_LANGUAGE_DESC"
class="inputbox">
<option value="*">JALL</option>
</field>
<field name="tags"
type="tag"
label="JTAG"
description="JTAG_DESC"
class="inputbox"
multiple="true" />
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
class="inputbox"
size="45"
labelclass="control-label" />
</fieldset>
<fields name="metadata">
<fieldset name="jmetadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field name="robots"
type="hidden"
filter="unset"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
labelclass="control-label"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
</field>
<field name="author"
type="hidden"
filter="unset"
label="JAUTHOR"
description="JFIELD_METADATA_AUTHOR_DESC"
size="20"
labelclass="control-label"
/>
<field name="rights"
type="hidden"
label="JFIELD_META_RIGHTS_LABEL"
filter="unset"
description="JFIELD_META_RIGHTS_DESC"
required="false"
labelclass="control-label"
/>
<field name="xreference"
type="hidden"
filter="unset"
label="COM_CONTENT_FIELD_XREFERENCE_LABEL"
description="COM_CONTENT_FIELD_XREFERENCE_DESC"
class="inputbox"
size="20"
labelclass="control-label" />
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,128 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
/**
* Weblinks Component Model for a Weblink record
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksModelWeblink extends JModelItem
{
/**
* Model context string.
*
* @access protected
* @var string
*/
protected $_context = 'com_weblinks.weblink';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication();
$params = $app->getParams();
// Load the object state.
$id = $app->input->getInt('id');
$this->setState('weblink.id', $id);
// Load the parameters.
$this->setState('params', $params);
}
/**
* Method to get an object.
*
* @param integer The id of the object to get.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($id = null)
{
if ($this->_item === null)
{
$this->_item = false;
if (empty($id))
{
$id = $this->getState('weblink.id');
}
// Get a level row instance.
$table = JTable::getInstance('Weblink', 'WeblinksTable');
// Attempt to load the row.
if ($table->load($id))
{
// Check published state.
if ($published = $this->getState('filter.published'))
{
if ($table->state != $published)
{
return $this->_item;
}
}
// Convert the JTable to a clean JObject.
$properties = $table->getProperties(1);
$this->_item = JArrayHelper::toObject($properties, 'JObject');
}
elseif ($error = $table->getError())
{
$this->setError($error);
}
}
return $this->_item;
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'Weblink', $prefix = 'WeblinksTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to increment the hit counter for the weblink
*
* @param integer $id Optional ID of the weblink.
*
* @return boolean True on success
*/
public function hit($id = null)
{
if (empty($id))
{
$id = $this->getState('weblink.id');
}
$weblink = $this->getTable('Weblink', 'WeblinksTable');
return $weblink->hit($id);
}
}

View File

@ -0,0 +1,229 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Build the route for the com_weblinks component
*
* @return array An array of URL arguments
*
* @return array The URL arguments to use to assemble the subsequent URL.
*/
function WeblinksBuildRoute(&$query)
{
$segments = array();
// get a menu item based on Itemid or currently active
$app = JFactory::getApplication();
$menu = $app->getMenu();
$params = JComponentHelper::getParams('com_weblinks');
$advanced = $params->get('sef_advanced_link', 0);
// we need a menu item. Either the one specified in the query, or the current active one if none specified
if (empty($query['Itemid']))
{
$menuItem = $menu->getActive();
}
else
{
$menuItem = $menu->getItem($query['Itemid']);
}
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
if (isset($query['view']))
{
$view = $query['view'];
if (empty($query['Itemid']) || empty($menuItem) || $menuItem->component != 'com_weblinks')
{
$segments[] = $query['view'];
}
// We need to keep the view for forms since they never have their own menu item
if ($view != 'form')
{
unset($query['view']);
}
}
// are we dealing with an weblink that is attached to a menu item?
if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id']))
{
unset($query['view']);
unset($query['catid']);
unset($query['id']);
return $segments;
}
if (isset($view) and ($view == 'category' or $view == 'weblink'))
{
if ($mId != (int) $query['id'] || $mView != $view)
{
if ($view == 'weblink' && isset($query['catid']))
{
$catid = $query['catid'];
}
elseif (isset($query['id']))
{
$catid = $query['id'];
}
$menuCatid = $mId;
$categories = JCategories::getInstance('Weblinks');
$category = $categories->get($catid);
if ($category)
{
//TODO Throw error that the category either not exists or is unpublished
$path = $category->getPath();
$path = array_reverse($path);
$array = array();
foreach ($path as $id)
{
if ((int) $id == (int) $menuCatid)
{
break;
}
if ($advanced)
{
list($tmp, $id) = explode(':', $id, 2);
}
$array[] = $id;
}
$segments = array_merge($segments, array_reverse($array));
}
if ($view == 'weblink')
{
if ($advanced)
{
list($tmp, $id) = explode(':', $query['id'], 2);
}
else
{
$id = $query['id'];
}
$segments[] = $id;
}
}
unset($query['id']);
unset($query['catid']);
}
if (isset($query['layout']))
{
if (!empty($query['Itemid']) && isset($menuItem->query['layout']))
{
if ($query['layout'] == $menuItem->query['layout'])
{
unset($query['layout']);
}
}
else
{
if ($query['layout'] == 'default')
{
unset($query['layout']);
}
}
}
return $segments;
}
/**
* Parse the segments of a URL.
*
* @return array The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*/
function WeblinksParseRoute($segments)
{
$vars = array();
//Get the active menu item.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
$params = JComponentHelper::getParams('com_weblinks');
$advanced = $params->get('sef_advanced_link', 0);
// Count route segments
$count = count($segments);
// Standard routing for weblinks.
if (!isset($item))
{
$vars['view'] = $segments[0];
$vars['id'] = $segments[$count - 1];
return $vars;
}
// From the categories view, we can only jump to a category.
$id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root';
$category = JCategories::getInstance('Weblinks')->get($id);
$categories = $category->getChildren();
$found = 0;
foreach ($segments as $segment)
{
foreach ($categories as $category)
{
if (($category->slug == $segment) || ($advanced && $category->alias == str_replace(':', '-', $segment)))
{
$vars['id'] = $category->id;
$vars['view'] = 'category';
$categories = $category->getChildren();
$found = 1;
break;
}
}
if ($found == 0)
{
if ($advanced)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__weblinks')
->where($db->quoteName('catid') . ' = ' . (int) $vars['catid'])
->where($db->quoteName('alias') . ' = ' . $db->quote($db->quote(str_replace(':', '-', $segment))));
$db->setQuery($query);
$id = $db->loadResult();
}
else
{
$id = $segment;
}
$vars['id'] = $id;
$vars['view'] = 'weblink';
break;
}
$found = 0;
}
return $vars;
}

View File

@ -0,0 +1,17 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
JHtml::_('behavior.caption');
echo JLayoutHelper::render('joomla.content.categories_default', $this);
echo $this->loadTemplate('items');
?>
</div>

View File

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="com_weblinks_categories_view_default_title" option="com_weblinks_categories_view_default_option">
<help
key="JHELP_MENUS_MENU_ITEM_WEBLINK_CATEGORIES"
/>
<message>
<![CDATA[com_weblinks_categories_view_default_desc]]>
</message>
</layout>
<!-- Add fields to the request variables for the layout. -->
<fields name="request">
<fieldset name="request"
>
<field name="id" type="category"
description="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_DESC"
extension="com_weblinks"
label="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_LABEL"
show_root="true"
required="true"
/>
</fieldset>
</fields>
<!-- Add fields to the parameters object for the layout. -->
<fields name="params">
<fieldset name="basic" label="JGLOBAL_CATEGORIES_OPTIONS">
<field name="show_base_description" type="list"
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
description="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="categories_description" type="textarea"
description="JGLOBAL_FIELD_CATEGORIES_DESC_DESC"
label="JGLOBAL_FIELD_CATEGORIES_DESC_LABEL"
cols="25"
rows="5"
/>
<field name="maxLevelcat" type="list"
default="-1"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field name="show_empty_categories_cat" type="list"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_subcat_desc_cat" type="list"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_cat_num_links_cat" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="category" label="JGLOBAL_CATEGORY_OPTIONS">
<field name="spacer1" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field name="show_category_title" type="list"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description" type="list"
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description_image" type="list"
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="maxLevel" type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNONE</option>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field name="show_empty_categories" type="list"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_subcat_desc" type="list"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_cat_num_links" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS">
<field name="spacer2" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field
name="filter_field"
type="list"
default=""
description="JGLOBAL_FILTER_FIELD_DESC"
label="JGLOBAL_FILTER_FIELD_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="hide">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination_limit" type="list"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
description="JGLOBAL_DISPLAY_SELECT_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_headings" type="list"
description="JGLOBAL_SHOW_HEADINGS_DESC"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_link_description" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_link_hits" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
label="JGLOBAL_HITS"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination" type="list"
description="JGLOBAL_PAGINATION_DESC"
label="JGLOBAL_PAGINATION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="2">JGLOBAL_AUTO</option>
</field>
<field name="show_pagination_results" type="list"
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
description="JGLOBAL_PAGINATION_RESULTS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
$class = ' class="first"';
if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) :
?>
<?php foreach($this->items[$this->parent->id] as $id => $item) : ?>
<?php
if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) :
if (!isset($this->items[$this->parent->id][$id + 1]))
{
$class = ' class="last"';
}
?>
<div <?php echo $class; ?> >
<?php $class = ''; ?>
<h3 class="page-header item-title">
<a href="<?php echo JRoute::_(WeblinksHelperRoute::getCategoryRoute($item->id));?>">
<?php echo $this->escape($item->title); ?></a>
<?php if ($this->params->get('show_cat_num_articles_cat') == 1) :?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::tooltipText('COM_WEBLINKS_NUM_ITEMS'); ?>">
<?php echo $item->numitems; ?>
</span>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0) : ?>
<a href="#category-<?php echo $item->id;?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<?php endif;?>
</h3>
<?php if ($this->params->get('show_subcat_desc_cat') == 1) :?>
<?php if ($item->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $item->description, '', 'com_weblinks.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0) :?>
<div class="collapse fade" id="category-<?php echo $item->id;?>">
<?php
$this->items[$item->id] = $item->getChildren();
$this->parent = $item;
$this->maxLevelcat--;
echo $this->loadTemplate('items');
$this->parent = $item->getParent();
$this->maxLevelcat++;
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -0,0 +1,85 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content categories view.
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksViewCategories extends JViewCategories
{
protected $item = null;
/**
* @var string Default title to use for page title
* @since 3.2
*/
protected $defaultPageTitle = 'COM_WEBLINKS_DEFAULT_PAGE_TITLE';
/**
* @var string The name of the extension for the category
* @since 3.2
*/
protected $extension = 'com_weblinks';
/**
* @var string The name of the view to link individual items to
* @since 3.2
*/
protected $viewName = 'weblink';
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a Error object.
*/
public function display($tpl = null)
{
$state = $this->get('State');
$items = $this->get('Items');
$parent = $this->get('Parent');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
if ($items === false)
{
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
}
if ($parent == false)
{
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
}
$params = &$state->params;
$items = array($parent->id => $items);
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->maxLevelcat = $params->get('maxLevelcat', -1);
$this->params = &$params;
$this->parent = &$parent;
$this->items = &$items;
return parent::display($tpl);
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<view title="Category">
<message><![CDATA[TYPECATEGORYDESC]]></message>
</view>
</metadata>

View File

@ -0,0 +1,14 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
$this->subtemplatename = 'items';
echo JLayoutHelper::render('joomla.content.category_default', $this);

View File

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="com_weblinks_category_view_default_title" option="com_weblinks_category_view_default_option">
<help
key="JHELP_MENUS_MENU_ITEM_WEBLINK_CATEGORY"
/>
<message>
<![CDATA[com_weblinks_category_view_default_desc]]>
</message>
</layout>
<!-- Add fields to the request variables for the layout. -->
<fields name="request">
<fieldset name="request">
<field name="id" type="category"
default="0"
description="COM_WEBLINKS_FIELD_SELECT_CATEGORY_DESC"
extension="com_weblinks"
label="COM_WEBLINKS_FIELD_SELECT_CATEGORY_LABEL"
required="true"
/>
</fieldset>
</fields>
<!-- Add fields to the parameters object for the layout. -->
<fields name="params">
<fieldset name="basic" label="JGLOBAL_CATEGORY_OPTIONS">
<field name="spacer1" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field name="show_category_title" type="list"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description" type="list"
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description_image" type="list"
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="maxLevel" type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNONE</option>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field name="show_empty_categories" type="list"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
description="COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_subcat_desc" type="list"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_cat_num_links" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_CAT_SHOWNUMBERS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS">
<field name="spacer2" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field
name="filter_field"
type="list"
default=""
description="JGLOBAL_FILTER_FIELD_DESC"
label="JGLOBAL_FILTER_FIELD_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="hide">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination_limit" type="list"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
description="JGLOBAL_DISPLAY_SELECT_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_headings" type="list"
description="JGLOBAL_SHOW_HEADINGS_DESC"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_link_description" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_DESC"
label="COM_WEBLINKS_FIELD_CONFIG_LINKDESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_link_hits" type="list"
description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
label="JGLOBAL_HITS"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination" type="list"
description="JGLOBAL_PAGINATION_DESC"
label="JGLOBAL_PAGINATION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="2">JGLOBAL_AUTO</option>
</field>
<field name="show_pagination_results" type="list"
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
description="JGLOBAL_PAGINATION_RESULTS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="integration"
>
<field name="show_feed_link" type="list"
description="JGLOBAL_SHOW_FEED_LINK_DESC"
label="JGLOBAL_SHOW_FEED_LINK_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,57 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$class = ' class="first"';
if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) :
?>
<ul>
<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
<?php
if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :
if (!isset($this->children[$this->category->id][$id + 1]))
{
$class = ' class="last"';
}
?>
<li<?php echo $class; ?>>
<?php $class = ''; ?>
<span class="item-title"><a href="<?php echo JRoute::_(WeblinksHelperRoute::getCategoryRoute($child->id));?>">
<?php echo $this->escape($child->title); ?></a>
</span>
<?php if ($this->params->get('show_subcat_desc') == 1) :?>
<?php if ($child->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $child->description, '', 'com_weblinks.category'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->params->get('show_cat_num_links') == 1) :?>
<dl class="weblink-count"><dt>
<?php echo JText::_('COM_WEBLINKS_NUM'); ?></dt>
<dd><?php echo $child->numitems; ?></dd>
</dl>
<?php endif; ?>
<?php if (count($child->getChildren()) > 0 ) :
$this->children[$child->id] = $child->getChildren();
$this->category = $child;
$this->maxLevel--;
echo $this->loadTemplate('children');
$this->category = $child->getParent();
$this->maxLevel++;
endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif;

View File

@ -0,0 +1,177 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.framework');
// Create a shortcut for params.
$params = &$this->item->params;
// Get the user object.
$user = JFactory::getUser();
// Check if user is allowed to add/edit based on weblinks permissinos.
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.'.$this->category->id);
$canCreate = $user->authorise('core.create', 'com_weblinks');
$canEditState = $user->authorise('core.edit.state', 'com_weblinks');
$n = count($this->items);
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<?php if (empty($this->items)) : ?>
<p> <?php echo JText::_('COM_WEBLINKS_NO_WEBLINKS'); ?></p>
<?php else : ?>
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
<?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?>
<fieldset class="filters btn-toolbar">
<?php if ($this->params->get('filter_field') != 'hide') :?>
<div class="btn-group">
<label class="filter-search-lbl element-invisible" for="filter-search"><span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span><?php echo JText::_('COM_WEBLINKS_FILTER_LABEL').'&#160;'; ?></label>
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>" />
</div>
<?php endif; ?>
<?php if ($this->params->get('show_pagination_limit')) : ?>
<div class="btn-group pull-right">
<label for="limit" class="element-invisible">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
</label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<ul class="category list-striped list-condensed">
<?php foreach ($this->items as $i => $item) : ?>
<?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?>
<?php if ($this->items[$i]->state == 0) : ?>
<li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
<?php else: ?>
<li class="cat-list-row<?php echo $i % 2; ?>" >
<?php endif; ?>
<?php if ($this->params->get('show_link_hits', 1)) : ?>
<span class="list-hits badge badge-info pull-right">
<?php echo JText::sprintf('JGLOBAL_HITS_COUNT', $item->hits); ?>
</span>
<?php endif; ?>
<?php if ($canEdit) : ?>
<span class="list-edit pull-left width-50">
<?php echo JHtml::_('icon.edit', $item, $params); ?>
</span>
<?php endif; ?>
<div class="list-title">
<?php if ($this->params->get('icons', 1) == 0) : ?>
<?php echo JText::_('COM_WEBLINKS_LINK'); ?>
<?php elseif ($this->params->get('icons', 1) == 1) : ?>
<?php if (!$this->params->get('link_icons')) : ?>
<?php echo JHtml::_('image', 'system/weblink.png', JText::_('COM_WEBLINKS_LINK'), null, true); ?>
<?php else: ?>
<?php echo '<img src="'.$this->params->get('link_icons').'" alt="'.JText::_('COM_WEBLINKS_LINK').'" />'; ?>
<?php endif; ?>
<?php endif; ?>
<?php
// Compute the correct link
$menuclass = 'category'.$this->pageclass_sfx;
$link = $item->link;
$width = $item->params->get('width');
$height = $item->params->get('height');
if ($width == null || $height == null)
{
$width = 600;
$height = 500;
}
if ($this->items[$i]->state == 0) : ?>
<span class="label label-warning">Unpublished</span>
<?php endif; ?>
<?php switch ($item->params->get('target', $this->params->get('target')))
{
case 1:
// open in a new window
echo '<a href="'. $link .'" target="_blank" class="'. $menuclass .'" rel="nofollow">'.
$this->escape($item->title) .'</a>';
break;
case 2:
// open in a popup window
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='.$this->escape($width).',height='.$this->escape($height).'';
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '".$attribs."'); return false;\">".
$this->escape($item->title).'</a>';
break;
case 3:
// open in a modal window
JHtml::_('behavior.modal', 'a.modal');
echo '<a class="modal" href="'.$link.'" rel="{handler: \'iframe\', size: {x:'.$this->escape($width).', y:'.$this->escape($height).'}}">'.
$this->escape($item->title). ' </a>';
break;
default:
// open in parent window
echo '<a href="'. $link . '" class="'. $menuclass .'" rel="nofollow">'.
$this->escape($item->title) . ' </a>';
break;
}
?>
</div>
<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($tagsData); ?>
<?php endif; ?>
<?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?>
<?php $images = json_decode($item->images); ?>
<?php if (isset($images->image_first) and !empty($images->image_first)) : ?>
<?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img
<?php if ($images->image_first_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_first_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div>
<?php endif; ?>
<?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
<?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_second_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_second_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div>
<?php endif; ?>
<?php echo $item->description; ?>
<?php endif; ?>
</li>
<?php endif;?>
<?php endforeach; ?>
</ul>
<?php // Code to add a link to submit a weblink. ?>
<?php /* if ($canCreate) : // TODO This is not working due to some problem in the router, I think. Ref issue #23685 ?>
<?php echo JHtml::_('icon.create', $item, $item->params); ?>
<?php endif; */ ?>
<?php if ($this->params->get('show_pagination')) : ?>
<div class="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>
</form>
<?php endif; ?>

View File

@ -0,0 +1,26 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the WebLinks component
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.0
*/
class WeblinksViewCategory extends JViewCategoryfeed
{
/**
* @var string The name of the view to link individual items to
* @since 3.2
*/
protected $viewName = 'weblink';
}

View File

@ -0,0 +1,105 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the WebLinks component
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksViewCategory extends JViewCategory
{
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a Error object.
*/
public function display($tpl = null)
{
parent::commonCategoryDisplay();
// Prepare the data.
// Compute the weblink slug & link url.
foreach ($this->items as $item)
{
$item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id;
if ($item->params->get('count_clicks', $this->params->get('count_clicks')) == 1)
{
$item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&id='. $item->id);
}
else
{
$item->link = $item->url;
}
$temp = new JRegistry;
$temp->loadString($item->params);
$item->params = clone($this->params);
$item->params->merge($temp);
}
return parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
*/
protected function prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('COM_WEBLINKS_DEFAULT_PAGE_TITLE'));
}
$id = (int) @$menu->query['id'];
if ($menu && ($menu->query['option'] != 'com_weblinks' || $id != $this->category->id))
{
$this->params->set('page_subheading', $this->category->title);
$path = array(array('title' => $this->category->title, 'link' => ''));
$category = $this->category->getParent();
while (($menu->query['option'] != 'com_weblinks' || $id != $category->id) && $category->id > 1)
{
$path[] = array('title' => $category->title, 'link' => WeblinksHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
}
parent::addFeed();
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<view
title="Form">
<message><![CDATA[TYPEARTICLAYDESC]]></message>
</view>
</metadata>

View File

@ -0,0 +1,77 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.modal', 'a.modal_jform_contenthistory');
// Create shortcut to parameters.
$params = $this->state->get('params');
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'weblink.cancel' || document.formvalidator.isValid(document.getElementById('adminForm')))
{
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task);
}
}
</script>
<div class="edit<?php echo $this->pageclass_sfx; ?>">
<?php if ($this->params->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=form&w_id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate form-vertical">
<div class="btn-toolbar">
<div class="btn-group">
<button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('weblink.save')">
<span class="icon-ok"></span> <?php echo JText::_('JSAVE') ?>
</button>
</div>
<div class="btn-group">
<button type="button" class="btn" onclick="Joomla.submitbutton('weblink.cancel')">
<span class="icon-cancel"></span> <?php echo JText::_('JCANCEL') ?>
</button>
</div>
<?php if ($params->get('save_history', 0)) : ?>
<div class="btn-group">
<?php echo $this->form->getInput('contenthistory'); ?>
</div>
<?php endif; ?>
</div>
<hr class="hr-condensed" />
<?php echo $this->form->renderField('title'); ?>
<?php echo $this->form->renderField('alias'); ?>
<?php echo $this->form->renderField('catid'); ?>
<?php echo $this->form->renderField('url'); ?>
<?php echo $this->form->renderField('tags'); ?>
<?php if ($params->get('save_history', 0)) : ?>
<?php echo $this->form->renderField('version_note'); ?>
<?php endif; ?>
<?php if ($this->user->authorise('core.edit.state', 'com_weblinks.weblink')) : ?>
<?php echo $this->form->renderField('state'); ?>
<?php endif; ?>
<?php echo $this->form->renderField('language'); ?>
<?php echo $this->form->renderField('description'); ?>
<input type="hidden" name="return" value="<?php echo $this->return_page;?>" />
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout
title="com_weblinks_form_view_default_title" option="com_weblinks_form_view_default_option">
<help
key="JHELP_MENUS_MENU_ITEM_WEBLINK_SUBMIT"
/>
<message>
<![CDATA[com_weblinks_form_view_default_desc]]>
</message>
</layout>
</metadata>

View File

@ -0,0 +1,137 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML Article View class for the Weblinks component
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksViewForm extends JViewLegacy
{
protected $form;
protected $item;
protected $return_page;
protected $state;
public function display($tpl = null)
{
$user = JFactory::getUser();
// Get model data.
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
$this->return_page = $this->get('ReturnPage');
if (empty($this->item->id))
{
$authorised = ($user->authorise('core.create', 'com_weblinks') || (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))));
}
else
{
$authorised = $user->authorise('core.edit', 'com_weblinks.category.'.$this->item->catid);
}
if ($authorised !== true)
{
JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
if (!empty($this->item))
{
$this->form->bind($this->item);
}
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Create a shortcut to the parameters.
$params = &$this->state->params;
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->params = $params;
$this->user = $user;
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if (empty($this->item->id))
{
$head = JText::_('COM_WEBLINKS_FORM_SUBMIT_WEBLINK');
}
else
{
$head = JText::_('COM_WEBLINKS_FORM_EDIT_WEBLINK');
}
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', $head);
}
$title = $this->params->def('page_title', $head);
if ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
$this->document->setTitle($title);
if ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the WebLinks component
*
* @package Joomla.Site
* @subpackage com_weblinks
* @since 1.5
*/
class WeblinksViewWeblink extends JViewLegacy
{
protected $state;
protected $item;
public function display($tpl = null)
{
// Get some data from the models
$item = $this->get('Item');
if ($this->getLayout() == 'edit')
{
$this->_displayEdit($tpl);
return;
}
if ($item->url)
{
// redirects to url if matching id found
JFactory::getApplication()->redirect($item->url);
}
else
{
//TODO create proper error handling
JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
}
}
}

View File

@ -0,0 +1,16 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT.'/helpers/route.php';
$controller = JControllerLegacy::getInstance('Weblinks');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PKG_WEBLINKS="Weblinks Extension Package"
PKG_WEBLINKS_XML_DESCRIPTION="The Weblinks package includes the weblinks component, module, and search plugins for both of Joomla's search platforms."

116
src/mod_weblinks/helper.php Normal file
View File

@ -0,0 +1,116 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
require_once JPATH_SITE . '/components/com_weblinks/helpers/category.php';
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_weblinks/models', 'WeblinksModel');
/**
* Helper for mod_weblinks
*
* @package Joomla.Site
* @subpackage mod_weblinks
* @since 1.5.0
*/
class ModWeblinksHelper
{
/**
* Show online member names
*
* @param mixed &$params The parameters set in the administrator backend
*
* @return mixed Null if no weblinks based on input parameters else an array containing all the weblinks.
*
* @since 1.5.0
**/
public static function getList(&$params)
{
// Get an instance of the generic articles model
$model = JModelLegacy::getInstance('Category', 'WeblinksModel', array('ignore_request' => true));
// Set application parameters in model
$app = JFactory::getApplication();
$appParams = $app->getParams();
$model->setState('params', $appParams);
// Set the filters based on the module params
$model->setState('list.start', 0);
$model->setState('list.limit', (int) $params->get('count', 5));
$model->setState('filter.state', 1);
$model->setState('filter.publish_date', true);
// Access filter
$access = !JComponentHelper::getParams('com_weblinks')->get('show_noauth');
$model->setState('filter.access', $access);
$ordering = $params->get('ordering', 'ordering');
$model->setState('list.ordering', $ordering == 'order' ? 'ordering' : $ordering);
$model->setState('list.direction', $params->get('direction', 'asc'));
$catid = (int) $params->get('catid', 0);
$model->setState('category.id', $catid);
// Create query object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('a.alias', '!=', '0');
$case_when1 .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $a_id . ' END as slug';
$case_when2 = ' CASE WHEN ';
$case_when2 .= $query->charLength('c.alias', '!=', '0');
$case_when2 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when2 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when2 .= ' ELSE ';
$case_when2 .= $c_id . ' END as catslug';
$model->setState(
'list.select',
'a.*, c.published AS c_published,' . $case_when1 . ',' . $case_when2 . ',' . 'DATE_FORMAT(a.created, "%Y-%m-%d") AS created'
);
$model->setState('filter.c.published', 1);
// Filter by language
$model->setState('filter.language', $app->getLanguageFilter());
$items = $model->getItems();
if ($items)
{
foreach ($items as $item)
{
if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1)
{
$item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&catid=' . $item->catslug . '&id=' . $item->slug);
}
else
{
$item->link = $item->url;
}
}
return $items;
}
else
{
return;
}
}
}

View File

@ -0,0 +1,31 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
MOD_WEBLINKS="Weblinks"
MOD_WEBLINKS_FIELD_CATEGORY_DESC="Choose the Weblinks category to display"
MOD_WEBLINKS_FIELD_COUNT_DESC="Number of Web Links to display"
MOD_WEBLINKS_FIELD_COUNT_LABEL="Count"
MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded"
MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL="Count Clicks"
MOD_WEBLINKS_FIELD_DESCRIPTION_DESC="Display Web Link description"
MOD_WEBLINKS_FIELD_DESCRIPTION_LABEL="Description"
MOD_WEBLINKS_FIELD_FOLLOW_DESC="Robots index - allow to follow or not"
MOD_WEBLINKS_FIELD_FOLLOW_LABEL="Follow/No Follow"
MOD_WEBLINKS_FIELD_HITS_DESC="Show Hits"
MOD_WEBLINKS_FIELD_HITS_LABEL="Hits"
MOD_WEBLINKS_FIELD_ORDERDIRECTION_DESC="Set the ordering direction"
MOD_WEBLINKS_FIELD_ORDERDIRECTION_LABEL="Direction"
MOD_WEBLINKS_FIELD_ORDERING_DESC="Ordering for the Web Links"
MOD_WEBLINKS_FIELD_ORDERING_LABEL="Ordering"
MOD_WEBLINKS_FIELD_TARGET_DESC="Target browser window when the link is clicked"
MOD_WEBLINKS_FIELD_TARGET_LABEL="Target Window"
MOD_WEBLINKS_FIELD_VALUE_ASCENDING="Ascending"
MOD_WEBLINKS_FIELD_VALUE_DESCENDING="Descending"
MOD_WEBLINKS_FIELD_VALUE_FOLLOW="Follow"
MOD_WEBLINKS_FIELD_VALUE_HITS="Hits"
MOD_WEBLINKS_FIELD_VALUE_NOFOLLOW="No follow"
MOD_WEBLINKS_FIELD_VALUE_ORDER="Order"
MOD_WEBLINKS_HITS="Hits"
MOD_WEBLINKS_XML_DESCRIPTION="This modules displays weblinks from a category defined in the Weblinks component."

View File

@ -0,0 +1,9 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
MOD_WEBLINKS="Weblinks"
MOD_WEBLINKS_XML_DESCRIPTION="This modules displays Web Links from a category defined in the Weblinks component."
MOD_WEBLINKS_LAYOUT_DEFAULT="Default"

View File

@ -0,0 +1,24 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the weblinks functions only once
require_once __DIR__ . '/helper.php';
$list = ModWeblinksHelper::getList($params);
if (!count($list))
{
return;
}
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
require JModuleHelper::getLayoutPath('mod_weblinks', $params->get('layout', 'default'));

View File

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<extension
type="module"
version="3.1"
client="site"
method="upgrade">
<name>mod_weblinks</name>
<author>Joomla! Project</author>
<creationDate>July 2009</creationDate>
<copyright>Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.</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>3.0.0</version>
<description>MOD_WEBLINKS_XML_DESCRIPTION</description>
<files>
<filename module="mod_weblinks">mod_weblinks.php</filename>
<folder>tmpl</folder>
<filename>helper.php</filename>
<filename>index.html</filename>
<filename>mod_weblinks.xml</filename>
</files>
<languages>
<language tag="en-GB">en-GB.mod_weblinks.ini</language>
<language tag="en-GB">en-GB.mod_weblinks.sys.ini</language>
</languages>
<help key="JHELP_EXTENSIONS_MODULE_MANAGER_WEBLINKS" />
<config>
<fields name="params">
<fieldset name="basic">
<field
name="catid"
type="category"
extension="com_weblinks"
required="true"
label="JCATEGORY"
description="MOD_WEBLINKS_FIELD_CATEGORY_DESC" />
<field
name="count"
type="text"
default="5"
label="MOD_WEBLINKS_FIELD_COUNT_LABEL"
description="MOD_WEBLINKS_FIELD_COUNT_DESC" />
<field
name="ordering"
type="list"
default="title"
label="MOD_WEBLINKS_FIELD_ORDERING_LABEL"
description="MOD_WEBLINKS_FIELD_ORDERING_DESC">
<option
value="title">JGLOBAL_TITLE</option>
<option
value="order">MOD_WEBLINKS_FIELD_VALUE_ORDER</option>
<option
value="hits">MOD_WEBLINKS_FIELD_VALUE_HITS</option>
</field>
<field
name="direction"
type="list"
default="asc"
label="MOD_WEBLINKS_FIELD_ORDERDIRECTION_LABEL"
description="MOD_WEBLINKS_FIELD_ORDERDIRECTION_DESC">
<option
value="asc">MOD_WEBLINKS_FIELD_VALUE_ASCENDING</option>
<option
value="desc">MOD_WEBLINKS_FIELD_VALUE_DESCENDING</option>
</field>
<field
name="target"
type="list"
default="3"
label="MOD_WEBLINKS_FIELD_TARGET_LABEL"
description="MOD_WEBLINKS_FIELD_TARGET_DESC">
<option
value="1">JBROWSERTARGET_NEW</option>
<option
value="2">JBROWSERTARGET_POPUP</option>
<option
value="3">JBROWSERTARGET_PARENT</option>
</field>
<field
name="follow"
type="list"
default="0"
label="MOD_WEBLINKS_FIELD_FOLLOW_LABEL"
description="MOD_WEBLINKS_FIELD_FOLLOW_DESC">
<option
value="follow">MOD_WEBLINKS_FIELD_VALUE_FOLLOW</option>
<option
value="nofollow">MOD_WEBLINKS_FIELD_VALUE_NOFOLLOW</option>
</field>
<field
name="description"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="MOD_WEBLINKS_FIELD_DESCRIPTION_LABEL"
description="MOD_WEBLINKS_FIELD_DESCRIPTION_DESC">
<option
value="1">JSHOW</option>
<option
value="0">JHIDE</option>
</field>
<field
name="hits"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="MOD_WEBLINKS_FIELD_HITS_LABEL"
description="MOD_WEBLINKS_FIELD_HITS_DESC">
<option
value="1">JSHOW</option>
<option
value="0">JHIDE</option>
</field>
<field
name="count_clicks"
type="list"
class="chzn-color"
default="0"
label="MOD_WEBLINKS_FIELD_COUNTCLICKS_LABEL"
description="MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC">
<option
value="">JGLOBAL_USE_GLOBAL</option>
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
</fieldset>
<fieldset
name="advanced">
<field
name="layout"
type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
<field
name="moduleclass_sfx"
type="textarea" rows="3"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
<field
name="cache"
type="list"
default="1"
label="COM_MODULES_FIELD_CACHING_LABEL"
description="COM_MODULES_FIELD_CACHING_DESC">
<option
value="1">JGLOBAL_USE_GLOBAL</option>
<option
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field
name="cache_time"
type="text"
default="900"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
description="COM_MODULES_FIELD_CACHE_TIME_DESC" />
<field
name="cachemode"
type="hidden"
default="static">
<option
value="static"></option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php
foreach ($list as $item) :
?>
<li>
<?php
$link = $item->link;
switch ($params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
if ($params->get('description', 0))
{
echo nl2br($item->description);
}
if ($params->get('hits', 0))
{
echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')';
}
?>
</li>
<?php
endforeach;
?>
</ul>

30
src/pkg_weblinks.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="3.0" method="upgrade">
<name>pkg_weblinks</name>
<packagename>weblinks</packagename>
<creationDate>December 2012</creationDate>
<packager>Joomla! Project</packager>
<copyright>(C) 2005 - 2012 Open Source Matters. All rights reserved.</copyright>
<packageremail>admin@joomla.org</packageremail>
<packagerurl>www.joomla.org</packagerurl>
<author>Joomla! Project</author>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<description>PKG_WEBLINKS_XML_DESCRIPTION</description>
<files folder="packages">
<!-- The id for each extension is the element stored in the DB -->
<file type="component" id="com_weblinks">com_weblinks.zip</file>
<file type="module" id="mod_weblinks" client="site">mod_weblinks.zip</file>
<file type="plugin" id="weblinks" group="finder">plg_finder_weblinks.zip</file>
<file type="plugin" id="weblinks" group="search">plg_search_weblinks.zip</file>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.pkg_weblinks.sys.ini</language>
</languages>
<updateservers>
<!-- Note: No spaces or linebreaks allowed between the server tags -->
<server type="extension" name="Weblinks Update Site">https://github.com/joomla-extensions/weblinks/master/manifest.xml</server>
</updateservers>
</extension>

View File

@ -0,0 +1,10 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PLG_FINDER_WEBLINKS="Smart Search - Weblinks"
PLG_FINDER_WEBLINKS_XML_DESCRIPTION="This plugin indexes Joomla! Weblinks."
PLG_FINDER_QUERY_FILTER_BRANCH_S_WEB_LINK="Web link"
PLG_FINDER_QUERY_FILTER_BRANCH_P_WEB_LINK="Web links"

View File

@ -0,0 +1,8 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PLG_FINDER_WEBLINKS="Smart Search - Weblinks"
PLG_FINDER_WEBLINKS_ERROR_ACTIVATING_PLUGIN="Could not automatically activate the "_QQ_"Smart Search - Weblinks"_QQ_" plugin"
PLG_FINDER_WEBLINKS_XML_DESCRIPTION="This plugin indexes Joomla! Weblinks."

View File

@ -0,0 +1,379 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
// Load the base adapter.
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Smart Search adapter for Joomla Web Links.
*
* @package Joomla.Plugin
* @subpackage Finder.Weblinks
* @since 2.5
*/
class PlgFinderWeblinks extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Weblinks';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_weblinks';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'weblink';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Web Link';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__weblinks';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to update the item link information when the item category is
* changed. This is fired when the item category is published or unpublished
* from the list view.
*
* @param string $extension The extension whose category has been updated.
* @param array $pks An array of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderCategoryChangeState($extension, $pks, $value)
{
// Make sure we're handling com_weblinks categories.
if ($extension == 'com_weblinks')
{
$this->categoryStateChange($pks, $value);
}
}
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_weblinks.weblink')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the item from the index.
return $this->remove($id);
}
/**
* Smart Search after content save method.
* Reindexes the link information for a weblink that has been saved.
* It also makes adjustments if the access level of a weblink item or
* the category to which it belongs has been changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object.
* @param boolean $isNew True if the content has just been created.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle web links here. We need to handle front end and back end editing.
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form' )
{
// Check if the access levels are different.
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item.
$this->reindex($row->id);
}
// Check for access changes in the category.
if ($context == 'com_categories.category')
{
// Check if the access levels are different.
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Smart Search before content save method.
* This event is fired before the data is actually saved.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object.
* @param boolean $isNew True if the content is just about to be created.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle web links here.
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
{
// Query the database for the old access level if the item isn't new.
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category.
if ($context == 'com_categories.category')
{
// Query the database for the old access level if the item isn't new.
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks An array of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle web links here.
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled.
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format. Not used.
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
$item->setLanguage();
// Initialise the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = $registry;
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug, $item->language);
$item->path = FinderIndexerHelper::getContentPath($item->route);
/*
* Add the meta-data processing instructions based on the newsfeeds
* configuration parameters.
*/
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Web Link');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.catid, a.title, a.alias, a.url AS link, a.description AS summary')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.ordering')
->select('a.created_by_alias, a.modified, a.modified_by')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('a.state AS state, a.created AS start_date, a.params')
->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query.
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id . ' END as catslug';
$query->select($case_when_category_alias)
->from('#__weblinks AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
return $query;
}
/**
* Method to get the query clause for getting items to update by time.
*
* @param string $time The modified timestamp.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getUpdateQueryByTime($time)
{
// Build an SQL query based on the modified time.
$query = $this->db->getQuery(true)
->where('a.date >= ' . $this->db->quote($time));
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_weblinks</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2014 Open Source Matters. All rights reserved.</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>3.0.0</version>
<description>PLG_FINDER_WEBLINKS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="weblinks">weblinks.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_weblinks.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_weblinks.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,10 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PLG_SEARCH_WEBLINKS="Search - Weblinks"
PLG_SEARCH_WEBLINKS_FIELD_SEARCHLIMIT_DESC="Number of search items to return"
PLG_SEARCH_WEBLINKS_FIELD_SEARCHLIMIT_LABEL="Search Limit"
PLG_SEARCH_WEBLINKS_WEBLINKS="Weblinks"
PLG_SEARCH_WEBLINKS_XML_DESCRIPTION="Enables searching of Weblinks Component"

View File

@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
PLG_SEARCH_WEBLINKS="Search - Weblinks"
PLG_SEARCH_WEBLINKS_XML_DESCRIPTION="Enables searching of Weblinks Component"

View File

@ -0,0 +1,220 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Search.weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
/**
* Weblinks search plugin.
*
* @package Joomla.Plugin
* @subpackage Search.weblinks
* @since 1.6
*/
class PlgSearchWeblinks extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Determine areas searchable by this plugin.
*
* @return array An array of search areas.
*
* @since 1.6
*/
public function onContentSearchAreas()
{
static $areas = array(
'weblinks' => 'PLG_SEARCH_WEBLINKS_WEBLINKS'
);
return $areas;
}
/**
* Search content (weblinks).
*
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text;
if (is_array($areas))
{
if (!array_intersect($areas, array_keys($this->onContentSearchAreas())))
{
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent)
{
$state[] = 1;
}
if ($sArchived)
{
$state[] = 2;
}
if (empty($state))
{
return array();
}
$text = trim($text);
if ($text == '')
{
return array();
}
$searchWeblinks = JText::_('PLG_SEARCH_WEBLINKS');
switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.url LIKE ' . $text;
$wheres2[] = 'a.description LIKE ' . $text;
$wheres2[] = 'a.title LIKE ' . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.url LIKE ' . $word;
$wheres2[] = 'a.description LIKE ' . $word;
$wheres2[] = 'a.title LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering)
{
case 'oldest':
$order = 'a.created ASC';
break;
case 'popular':
$order = 'a.hits DESC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.title ASC, a.title ASC';
break;
case 'newest':
default:
$order = 'a.created DESC';
}
$query = $db->getQuery(true);
// SQLSRV changes.
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.title AS title, \'\' AS created, a.url, a.description AS text, ' . $case_when . "," . $case_when1)
->select($query->concatenate(array($db->quote($searchWeblinks), 'c.title'), " / ") . ' AS section')
->select('\'1\' AS browsernav')
->from('#__weblinks AS a')
->join('INNER', '#__categories as c ON c.id = a.catid')
->where('(' . $where . ') AND a.state IN (' . implode(',', $state) . ') AND c.published = 1 AND c.access IN (' . $groups . ')')
->order($order);
// Filter by language.
if ($app->isSite() && JLanguageMultilang::isEnabled())
{
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')')
->where('c.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
$return = array();
if ($rows)
{
foreach ($rows as $key => $row)
{
$rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug);
}
foreach ($rows as $weblink)
{
if (searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title')))
{
$return[] = $weblink;
}
}
}
return $return;
}
}

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="search">
<name>plg_search_weblinks</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.</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>3.0.0</version>
<description>PLG_SEARCH_WEBLINKS_XML_DESCRIPTION</description>
<files>
<filename plugin="weblinks">weblinks.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_search_weblinks.ini</language>
<language tag="en-GB">en-GB.plg_search_weblinks.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="search_limit" type="text"
default="50"
description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC"
label="JFIELD_PLG_SEARCH_SEARCHLIMIT_LABEL"
size="5"
/>
<field name="search_content" type="radio"
class="btn-group btn-group-yesno"
default="0"
description="JFIELD_PLG_SEARCH_ALL_DESC"
label="JFIELD_PLG_SEARCH_ALL_LABEL"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
<field name="search_archived" type="radio"
class="btn-group btn-group-yesno"
default="0"
description="JFIELD_PLG_SEARCH_ARCHIVED_DESC"
label="JFIELD_PLG_SEARCH_ARCHIVED_LABEL"
>
<option value="1">JON</option>
<option value="0">JOFF</option>
</field>
</fieldset>
</fields>
</config>
</extension>