Actualización de plugin TubePress
git-svn-id: https://192.168.0.254/svn/Proyectos.OriginalHouse_Web/trunk@67 54e8636e-a86c-764f-903d-b964358a1ae2
This commit is contained in:
parent
5bbc78c77c
commit
a6fb15531e
674
src/wp-content/plugins/tubepress/COPYING
Normal file
674
src/wp-content/plugins/tubepress/COPYING
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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
|
||||
them 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 prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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 Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
3
src/wp-content/plugins/tubepress/index.php
Normal file
3
src/wp-content/plugins/tubepress/index.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
//This file is here to stop cluttering search engine results for your site with TubePress's internals. Move along, nothing to see here!
|
||||
?>
|
||||
431
src/wp-content/plugins/tubepress/readme.txt
Normal file
431
src/wp-content/plugins/tubepress/readme.txt
Normal file
@ -0,0 +1,431 @@
|
||||
=== TubePress ===
|
||||
Contributors: k2eric
|
||||
Donate link: http://tubepress.org
|
||||
Tags: video, youtube, gallery, videos, vimeo
|
||||
Requires at least: 2.2
|
||||
Stable tag: trunk
|
||||
|
||||
Displays gorgeous YouTube and Vimeo galleries in your posts, pages, and/or sidebar. Please visit http://tubepress.org for more info!
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Unzip into your plugins directory at `(wp-content/plugins)`
|
||||
1. Activate TubePress from Site Admin > Plugins
|
||||
1. Configure from Site Admin > Settings > TubePress
|
||||
1. Type `[tubepress]` in a post or a page where you'd like to insert your first gallery
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 2.2.9 =
|
||||
* Allow for loading of user themes (regression fix)
|
||||
* Multiple shortcodes on a single page WordPress page work again (regression fix)
|
||||
* Graceful handling of "No videos found" error when using TubePress Pro in a standalone environment
|
||||
|
||||
= 2.2.8 =
|
||||
* Auto-upgrade in WordPress no longer wipes out custom themes (closes issue 349)
|
||||
* Vimeo galleries are no longer affected by value of arg_separator.input INI setting (closes issue 307)
|
||||
* JS and CSS now load correctly under HTTPS (closes issue 371)
|
||||
* Options page in WordPress now loads correctly on web servers with mod_security and ASL ruleset loaded (closes issue 184)
|
||||
* Improved reliability of YouTube feed result count (closes issue 379)
|
||||
* Fatal error in PHP 5.3.7 or higher (closes issue 386)
|
||||
* Improved reliability of shortcode parsing in WordPress widget
|
||||
* IE9 support (closes issue 263)
|
||||
* Ajax pagination now works correctly when using multiple video sources in a single gallery (TubePress Pro only)
|
||||
* Improved reliability of Ajax search input (TubePress Pro only)
|
||||
|
||||
= 2.2.7 =
|
||||
* Fixed bug that prevented Shadowbox from working in certain situations
|
||||
|
||||
= 2.2.6 =
|
||||
* Fixed deprecated warnings in PHP 5.3.0+ (closes issue 337)
|
||||
* WordPress widget now saves correctly (closes issue 348)
|
||||
* Fixed missing text for "lazy play" option in WordPress options page
|
||||
* Various code cleanup and minor fixes
|
||||
|
||||
= 2.2.5 =
|
||||
* Lightweight plugin support! Now you can customize TubePress's behavior without touching the core.
|
||||
* "Lazy" play option. Auto-starts video playback after thumbnail click (closes issue 166 )
|
||||
* Improved video meta support for embedded player in thumbnail galleries (closes issue 169 )
|
||||
* EmbedPlus support
|
||||
* TubePress Pro: Ability to combine YouTube and Vimeo in a single gallery (closes issue 228 )
|
||||
* TubePress Pro: Ability to load embedded player in a "detached" location (closes issue 244 )
|
||||
* Fixed broken i18n functionality in WordPress
|
||||
* Custom theme CSS now loads correctly for single video embeds
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
* Fixed jQuery UI conflict in admin section of WordPress (closes issue 296 )
|
||||
* User themes now appear in dropdown menu in WordPress settings page
|
||||
* Private Vimeo videos no longer appear in galleries (closes issue 276 )
|
||||
* YouTube embedded player now uses wmode=transparent (closes issue 298 )
|
||||
* Fixed deprecated warnings in PHP 5.3.0+ (closes issue 337 )
|
||||
* Made "fluid thumbnails" a first-class option, is now easy to disable when desired.
|
||||
* Modernized pagination style
|
||||
* Version bump to TinyBox2
|
||||
* Version bump to jQuery 1.6.1
|
||||
* Version bump to Fancybox 1.3.4 (closes issue 332 )
|
||||
|
||||
= 2.2.0 =
|
||||
* Interactive searching! (closes issue 138 )
|
||||
* YouTube iframe embedded player (closes issue 265 and issue 259 )
|
||||
* Improved inclusion of JS/CSS resources in WordPress environments (closes issue 191 )
|
||||
* Ability to restrict search-based galleries to videos from a specific YouTube/Vimeo user
|
||||
* New HTTP subsystem provides faster and more robust feed retrieval
|
||||
* Added advanced caching options
|
||||
* Improved visual feedback during Ajax operations (closes issue 142 )
|
||||
* Better upgrade notice for TubePress Pro users in a WordPress environment (closes issue 252 )
|
||||
* Graceful handling of single video embedding when video isn't found (closes issue 267 )
|
||||
* Broken gallery when trying to display Vimeo videos with JW FLV Media Player (closes issue 242 )
|
||||
* Incorrect detection of multi-gallery mode in some circumstances (closes issue 238 )
|
||||
* Duplicate videos no longer appear in galleries (closes issue 248 )
|
||||
* Private Vimeo videos no longer appear in galleries
|
||||
* Non-functional message service when using TubePress Pro in a PHP environment without built-in gettext support
|
||||
* Fixed bug that could affect TubePress Pro users in a WordPress environment hosted on Windows-based PHP installations
|
||||
* Removed option for "mobile" YouTube videos feed as it appears to be completely abandoned
|
||||
* YouTube now uses the iframe embedded player by default
|
||||
* Removed "enhanced genie menu" and "border" options from YouTube embedded player
|
||||
* Version bump for php-gettext to 1.0.11
|
||||
* Version bump for jQuery to 1.5.1
|
||||
|
||||
= 2.1.2 =
|
||||
* Fixed JavaScript error in Internet Explorer when determining height/width of embedded video player
|
||||
* Fixed ajax pagination appearance when non-default thumbnail sizes are in use
|
||||
* Fixed non-functional WordPress widget control
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
|
||||
= 2.1.1 =
|
||||
* Fixed major JavaScript bug in determining embedded player height/width on jQuery 1.4.2
|
||||
* Fixed bug with ajax pagination on some PHP installations
|
||||
|
||||
= 2.1.0 =
|
||||
* Ability to create galleries from multiple sources (TubePress Pro only) (closes issue 135)
|
||||
* Lightweight theming support
|
||||
* Support for "fluid" thumbnails
|
||||
* Vimeo universal player (closes issue 215)
|
||||
* Improved video search capability (closes issue 81)
|
||||
* Improved mobile user experience
|
||||
* Single video mode now works in WordPress widget
|
||||
* Fixed aliased text with Ajax pagination in Internet Explorer 7
|
||||
* Search engines no longer index TubePress's internal directories (closes issue 221)
|
||||
* Static player now works with Vimeo (closes issue 217)
|
||||
* Fixed color support for JW FLV Player
|
||||
* YouTube "most linked" gallery replaced with YouTube "top favorites" gallery due to change in API
|
||||
* Version bump for Shadowbox.js to 3.0.3
|
||||
* Version bump for JW FLV Media Player to 5.2
|
||||
* Version bump for jQuery to 1.4.2
|
||||
* Version bump for php-gettext to 1.0.10
|
||||
* Added Arabic translation thanks to Abdullah Hamed
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
* Updated Spanish translation thanks to Luis Fok
|
||||
|
||||
= 2.0.0 =
|
||||
* Vimeo support! Choose from 8 different types of Vimeo galleries. (closes issue 108)
|
||||
* Brought back ability to play each video from a gallery in a new window by itself (closes issue 94)
|
||||
* Now detects and parses HTML links found in video descriptions
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
* Added Spanish translation thanks to Luis Fok
|
||||
* Added Hebrew translation thanks to Yaron Ofer
|
||||
* Ability to blacklist individual videos (closes issue 162)
|
||||
* Option to use high-quality thumbnails (closes issue 96) (TubePress Pro only)
|
||||
* HTML popups are now centered on screen (closes issue 160)
|
||||
* Fixed regression bug for description limit (closes issue 153)
|
||||
* Incorrect video could load into embedded player after thumbnail click in certain configurations (closes issue 175)
|
||||
* resultCountCap now works on a single gallery page
|
||||
* Fixes single video mode in TubePress Pro
|
||||
* Static player now works with Ajax pagination (closes issue 177)
|
||||
* Version bump for FancyBox (to 1.3.1)
|
||||
* FancyBox now operates correctly in all browsers (closes issue 172)
|
||||
|
||||
= 1.9.0 =
|
||||
* Fixed a bug that breaks the WordPress widget administration page in some PHP installations
|
||||
* Added Portugese translation thanks to Miriam de Pauala
|
||||
|
||||
= 1.8.9 =
|
||||
|
||||
* Now includes ability to embed individual videos along with all of their meta info (title, author, description, etc)!
|
||||
* Request cache is now disabled by default
|
||||
* Updated sorting functionality. Fixes possible "bad request" response from YouTube. Fixes sorting of playlist galleries.
|
||||
* Fixed blank item on video sort order dropdown of WordPress options page (closes issue 155)
|
||||
* descLimit shortcode can now be set to zero (closes issue 153)
|
||||
* Improved compatibility with older versions of PHP (closes issue 163)
|
||||
* Added Russian translation (thanks to an anonymous supporter)
|
||||
* ShadowBox version bump to 3.0rc1
|
||||
* Improved documentation
|
||||
* (TubePress Pro) Improved i18n support
|
||||
* (TubePress Pro) FancyBox version bump to 1.2.6
|
||||
* (TubePress Pro) Fixed bug that prevented FancyBox from operating correctly in IE (closes issue 165)
|
||||
|
||||
= 1.8.8 =
|
||||
* JavaScript initialization is much more robust. Reduces chances of un-clickable video thumbnails.
|
||||
* Fixed potentially fatal error in cache mechanism
|
||||
* Improved sidebar's CSS
|
||||
* Fixed bug in video sort order (closes issue 146)
|
||||
* Fixed bug that could cause fatal error in templates
|
||||
* Version bump for JW FLV Media Player (to 5.0)
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
|
||||
= 1.8.7 =
|
||||
* Improved compatibility with PEAR (closes issue 140)
|
||||
* Fixed bug that affected determining video ID in some YouTube feeds
|
||||
* New static player option. Produces page refresh on each thumbnail click.
|
||||
* Gallery HTML is now semantically correct and more structured (closes issue 125 and issue 117)
|
||||
* TubePress Pro: New player: TinyBox (closes issue 110)
|
||||
* TubePress Pro: New player: FancyBox (closes issue 118)
|
||||
* TubePress Pro: Greatly improved WordPress integration
|
||||
* TubePress Pro: Fixed bug that produced open_basedir warning message in some installations
|
||||
* Fixed bug that prevented use of custom templates
|
||||
* Overhaul and simplification of templating system
|
||||
* Improved performance of logging system
|
||||
* Improved iPhone/iPod playback (keeps user on site instead of redirecting to YouTube player) (closes issue 143)
|
||||
|
||||
= 1.8.6 =
|
||||
* WordPress options page now uses jQuery tabs
|
||||
* Fixed bug that could prevent request cache from working in some PHP installations
|
||||
* (TubePress Pro only) Ajax pagination (closes issue 45 and issue 111)
|
||||
* (TubePress Pro only) Version bump for jQuery (1.2.6 -> 1.3.2)
|
||||
* (TubePress Pro only) Removed potential "Invalid locale category name" warning that shows up on some PHP installations
|
||||
* Version bump for JW FLV Media Player (to 4.6)
|
||||
* Fixed bug that prevented display of videos with "limited syndication" restriction
|
||||
* Shortcode and input validation is much more comprehensive (closes issue 129)
|
||||
* Fixed bug that prevented videos from playing in high definition upon request (closes issue 137)
|
||||
* Additional gallery pages are no longer indexed by search engines (closes issue 133)
|
||||
* Minor refactoring of tubepress.js functions
|
||||
* Updated WordPress plugins page blurb
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
* Various trivial improvements to HTML templates
|
||||
|
||||
= 1.8.5 =
|
||||
* Videos now play correctly on iPhone and iPod Touch (closes issue 101)
|
||||
* Flexible shortcodes! No need to include commas between attribute/value pairs. Can use single, double, or no quotes around attribute values.
|
||||
* Greatly improved debugging mode
|
||||
* Fixed bug that prevents all videos in gallery from playing if first video in gallery is unavailable (closes issue 115)
|
||||
* Fixed bug that could prevent video playback, and JavaScript error, on Firefox with AdBlock Plus enabled (closes issue 124)
|
||||
* Added ability to cap the total number of videos in a gallery (closes issue 65)
|
||||
* Updated Italian translation thanks to Gianni Diurno
|
||||
* Shadowbox CSS no longer tries to load non-existent images. (closes issue 112)
|
||||
* WordPress galleries are no longer wrapped with HTML paragraph tags (closes issue 79)
|
||||
* WordPress.org compliant readme.txt changelog (closes issue 123)
|
||||
|
||||
= 1.8.0 =
|
||||
* Includes all the changes listed in 1.8.0.RC1
|
||||
* Fixed typo on options page regarding embedded player width/height
|
||||
* Unavailable videos will now not appear in galleries at all
|
||||
|
||||
= 1.8.0 =
|
||||
* New embedded player option: JW Flv Media Player
|
||||
* New player location: jqModal
|
||||
* All classes use dependency injection via Crafty
|
||||
* jQuery 1.2.6 or higher is now required (built-in for WordPress users)
|
||||
* Multiple galleries on a single page now behave correctly with "normal" player
|
||||
* Dynamically load JavaScript libraries as needed (Prototype, Shadowbox, etc) (closes issue 56)
|
||||
* All JavaScript is now unobtrusive
|
||||
* Can now use modal players (e.g. Shadowbox) in a TubePress shortcode
|
||||
* Removed extra HTML comments and whitespace. Galleries now use about 16% less bandwidth.
|
||||
* CSS will stay valid for multiple galleries on a single page
|
||||
* CSS classes now have sensible names (renamed some classes)
|
||||
* Updated Italian translation thanks to Gianni Diurno (closes issue 83)
|
||||
* Fixed bug that affected some PHP installations with PEAR installed (closes issue 84)
|
||||
* Fixed bug that blocked WordPress plugin's "database nuke" functionality
|
||||
* Removed GreyBox as a player location due to its inability to display inline content
|
||||
* Version bump for ShadowBox (closes issue 77)
|
||||
* popup.php has been removed and replaced with JavaScript functionality (closes issue 76)
|
||||
* Better control over pagination visibility for multi-page galleries (closes issue 93)
|
||||
* Removed GreyBox and LightWindow as players
|
||||
* Graceful failure for videos that are unavailable
|
||||
|
||||
= 1.7.2 =
|
||||
|
||||
* Fullscreen playback now available in embedded player (closes issue 64)
|
||||
* Created "YouTube Feed" options category. Moved some of the advanced options into this category.
|
||||
* Added ability to exclude non-embeddable videos (closes issue 69)
|
||||
* Added jscolor HTML color picker for embedded player colors
|
||||
* Fixed bug where debugging mode threw a fatal error (closes issue 80)
|
||||
* Fixed bug where random video sort order would throw a fatal error
|
||||
* Added ability to toggle display of title/rating before video starts playing
|
||||
* Now using version 2.0 of YouTube gdata API (closes issue 68)
|
||||
|
||||
= 1.7.1 =
|
||||
|
||||
* Drastically improved class loading mechanism (uses several thousand less system calls)
|
||||
* Added Italian translation thanks to Gianni Diurno (closes issue 75)
|
||||
* Minified Shadowbox JS source using YUI Compressor
|
||||
* Fixed critical bug that broke embedded YouTube player on IE7 (closes issue 73)
|
||||
* Fixed minor bug in normal player where embedded player would shift by a few pixels after user clicked a thumbnail
|
||||
|
||||
= 1.7.0 =
|
||||
* Option to initialize TubePress options in WordPress (closes issue 52)
|
||||
* Now works with PHP <= 5.1.0 again (closes issue 59 and issue 67)
|
||||
* Links to popup.php are drastically shorter, which avoids a 404 on some webservers (closes issue 55)
|
||||
* Added German translation thanks to Pascal Berger (closes issue 58)
|
||||
* Option to play videos in HD (closes issue 33)
|
||||
* Option to show custom video in embedded player on page load while using "normal" player (closes issue 26)
|
||||
|
||||
= 1.6.9 =
|
||||
* TubePress Pro is now available! Use TubePress anywhere that runs PHP
|
||||
* Default thumbmail URL now uses "default.jpg" (closes issue 47)
|
||||
* Fixed bug that resulted in inability to paginate past the first page of a multi-page gallery.
|
||||
* Version bump for Net_URL to Net_URL2
|
||||
* Version bump for HTTP_Request to HTTP_Request2
|
||||
* Version bump for Cache_Lite
|
||||
* Huge amounts of unit/integration tests
|
||||
* Major refactoring of classes (now using dependency injection)
|
||||
|
||||
= 1.6.8 =
|
||||
* Fixed overly large gap between thumbnail rows
|
||||
|
||||
= 1.6.7 =
|
||||
* Added YouTube connection test to debug output
|
||||
* Added YouTube API client ID and developer key to aide in debugging
|
||||
* Fixed bug where TubePress would remove all post/page content if no videos were found for your request
|
||||
* Toggle request cache on/off (closes issue 43)
|
||||
* Ampersands in query strings are now properly escaped (closes issue 38)
|
||||
* Galleries can now sort videos randomly (closes issue 23)
|
||||
* Toggle "nofollow" attributes to YouTube links (closes issue 35)
|
||||
|
||||
= 1.6.6 =
|
||||
* Widget-enabled! Put TubePress in your sidebar. (closes issue 12)
|
||||
* Removed pass-by-reference warnings (closes issue 34)
|
||||
* Ability to limit length of video descriptions
|
||||
* Option to toggle relative dates/times for video upload timestamps
|
||||
* Swedish translation. Thanks to Mikael Jorhult
|
||||
* Improved error handling for PHP installations with suppressed error output
|
||||
* Removed several small bugs that affected users of PHP < 5.2.1
|
||||
|
||||
= 1.6.5 =
|
||||
* Full internationalization capability (closes issue 21)
|
||||
* Upgrades, from this version on, will no longer destroy your old TubePress default settings (closes issue 28)
|
||||
* Multiple galleries on a single post/page now possible (closes issue 20)
|
||||
* Fixes broken YouTube link (closes issue 30)
|
||||
* Video playback now functions correctly in IE7
|
||||
* Cross site scripting vulnerability fixed (thanks Numline1 for reporting)
|
||||
* Fixed debug output
|
||||
* Options page now looks good in WordPress 2.5.1
|
||||
* Various pass-by-reference warnings eliminated
|
||||
|
||||
= 1.6.0 =
|
||||
* PHP5 only. This includes an overall rewrite of the code base to take advantage of PHP5-only stuff
|
||||
* Responses from YouTube are now cached
|
||||
* New galleries: Top favorites, Most recently added, Most discussed, Most linked, Most responded, Responses to a video
|
||||
* New way to watch: Shadowbox.js
|
||||
* Removed "New Window" player
|
||||
* Customize textual formatting of dates
|
||||
* Much more control over embedded player: Toggle "related videos" feature after a video finishes, Choose from several colors, Toggle auto-play, Toggle "enhanced genie menu" when mouse enters video area (instead of user clicking the "menu" button), Toggle video loop
|
||||
* Interface improvements: Removed border and scroll bars from gallery, Removed time of day from date uploaded, Changed upload label from "Uploaded date" to "Uploaded", Pagination now supports HTTP/HTTPS and non-standard ports, Simplified templating (easier to customize the look of your galleries)
|
||||
* Issues/enhancements closed: #20, #25, #7
|
||||
* Upgrade source to GPLv3
|
||||
|
||||
= 1.5.7 =
|
||||
* Fixed yet another title problem due to YouTube changing their feed
|
||||
* Fixes issue #16
|
||||
|
||||
= 1.5.6 =
|
||||
* Fixes a major problem displaying video titles due to change in YouTube feed format
|
||||
|
||||
= 1.5.5 RC3 =
|
||||
* Fixes issue #13
|
||||
|
||||
= 1.5.5 RC2 =
|
||||
* Fixes issue #5
|
||||
* Changes default thumb width from 33% to 32% (helps with IE)
|
||||
|
||||
= 1.5.5 RC1 =
|
||||
* "Favorites" mode now displays up to 500 videos
|
||||
* "Search" mode now can return up to 1,000 videos
|
||||
* New mode: most-viewed videos from today, this week, this month, or all time
|
||||
* Customize the order of galleries by view-count, rating, relevance, or date-updated
|
||||
* Randomize thumbnails (most videos come with 4 thumbnails, this option will mix it up for each pageload)
|
||||
* Filter "racy" videos from galleries
|
||||
* Option to show a video’s category in its metadata
|
||||
* All access to TubePressVideo member variables is now done through getters
|
||||
* All HTML is generated via PEAR's HTML_Template_IT package
|
||||
|
||||
= 1.5.2 =
|
||||
* Fixes a fatal error upon plugin activation in some PHP installations
|
||||
|
||||
= 1.5.1 =
|
||||
* Fixes a minor bug with "search" mode due to YouTube changing the format of the XML results
|
||||
|
||||
= 1.5.0 =
|
||||
* "All tags" and "Any tags" modes now merged into "YouTube search" mode
|
||||
* Play videos with GreyBox (this replaces ThickBox)
|
||||
* Play videos with lightWindow
|
||||
* Pagination now uses modified Digg Style pagination
|
||||
* Max player size is now 424px x 336px (removes thin white border from player)
|
||||
* Input validation on options page
|
||||
* All error messages are extremely detailed
|
||||
* Debug mode is more comprehensive
|
||||
* Option to disable debugging mode completely
|
||||
* Embedded video is XHTML compliant
|
||||
* "Playlist" mode pages correctly (thanks, YouTube!)
|
||||
* "Normal" mode displays title and runtime correctly after user click
|
||||
* Much better code documentation
|
||||
* Code style is PEAR compliant
|
||||
* XML parsing uses PEAR's XML_Unserializer instead of XMLIster
|
||||
* Almost all functions moved to classes (helps namespace management)
|
||||
* WordPress-specific code is cleanly isolated
|
||||
* Improved message-resources handling
|
||||
* Revamped directory structure
|
||||
* Improved naming conventions all around
|
||||
* Quasi-private methods (PHP4 OOP isn't too sophisticated)
|
||||
* Most HTML printing methods use sprintf (or variant) - improves readability
|
||||
|
||||
= 1.2.0 =
|
||||
* Fixed a bug that caused an incorrect count of YouTube video results
|
||||
* Added debugging mode! See the documentation for how to use it.
|
||||
|
||||
= 1.1.5 =
|
||||
* Fixed major XML bugs that caused a fatal error when parsing YouTube's XML
|
||||
* CSS bug fixes with the pagination links
|
||||
* Fixed a bug in the options page related to the "popular" mode drop down menu
|
||||
|
||||
= 1.1 =
|
||||
* CSS bug fixes. Thanks to Scott for reporting it
|
||||
|
||||
= 1.05 =
|
||||
* Fixed huge IE display bug (thanks to Keane and Jojo for reporting it)
|
||||
* Disabled Thickbox by default due to incompatibilities with themes and other jquery-enabled features
|
||||
|
||||
= 1.0 =
|
||||
* Now with seven modes of operation: videos by playlists (with paging), featured (the latest 25 featured videos from YouTube's homepage), popular (the most-viewed videos from the past day, week, or month), related (videos that match any tag that you specify), tag (videos that match all the tags you specify), favorite videos of any user, videos uploaded by any user
|
||||
* You no longer need to supply your own developer ID and YouTube username! This means that anyone can use TubePress, even if you don't have a YouTube account!
|
||||
* Pagination. You control how many videos per page show up (supported modes only)
|
||||
* Leaner and meaner. The speedups in this version are ridiculous. Makes literally dozens less of the expensive database calls per page that existed in previous versions. Reduces database space in your wordpress options table from about 40 rows to only one.
|
||||
* Options page is more concise and XHTML compliant
|
||||
* Improved documentation
|
||||
* Bug fixes. Too many to list!
|
||||
|
||||
= 0.9 =
|
||||
* Now with five options on where to play the main video: Normally (at the top of your gallery), In a popup window, In a new window all by itself, In its original YouTube page, Using Thickbox (experimental, but very cool!)
|
||||
* Bug fix regarding HTML special characters in video titles
|
||||
|
||||
= 0.8 =
|
||||
* Major bug fix with PHP4. Thanks to Fabien and Paige for reporting it.
|
||||
|
||||
= 0.7 =
|
||||
* Override global settings on a per-page basis! This will allow you to have one page with your videos (that you've uploaded), another page with your YouTube favorites, etc.
|
||||
* Choose which meta information (author, rating, description, etc) you want to display
|
||||
* Lots of optimizations and bug fixes
|
||||
|
||||
= 0.6 =
|
||||
* Now works with PHP4
|
||||
* CSS revisions
|
||||
* Uses snoopy class instead of cURL libraries
|
||||
* Added configurable timeout parameter for contacting YouTube
|
||||
|
||||
= 0.5 =
|
||||
* Fixed small bug in time display
|
||||
|
||||
= 0.4 =
|
||||
* Takes full advantage of the YouTube API: List videos from "your favorites", List your videos (that you've uploaded), List videos that match some tag, List videos of another user
|
||||
* XHTML compliant
|
||||
|
||||
= 0.3 =
|
||||
* OK, now the bug is really fixed. Sorry about that!
|
||||
|
||||
= 0.2 =
|
||||
* Fixed major bug with CSS file path
|
||||
|
||||
= 0.1 =
|
||||
* Initial release
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Sample TubePress gallery
|
||||
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file demonstrates a trivial TubePress plugin. Uncomment the last line in the file to actually
|
||||
* activate the plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Any PHP object can be registered as a TubePress plugin. The object defines its interaction with the core by
|
||||
*
|
||||
* 1. Registering itself via TubePress::registerFilter()
|
||||
* 2. Implementing specially named methods on the object.
|
||||
*
|
||||
*/
|
||||
class SampleTubePressPlugin
|
||||
{
|
||||
/**
|
||||
* Since we're registering this object with the 'galleryHtml' filter point,
|
||||
* it needs to implement the function alter_galleryHtml($html, $galleryId);
|
||||
|
||||
* @param string $rawHtml The gallery HTML to filter.
|
||||
* @param int $galleryId The unique gallery ID.
|
||||
*
|
||||
* @return string The (possibly modified) HTML.
|
||||
*/
|
||||
public function alter_galleryHtml($rawHtml, $galleryId)
|
||||
{
|
||||
return "Hello, TubePress! $rawHtml";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finally, we register an instance of this class as a filter for the 'galleryHtml' filter point,
|
||||
* which allows us to modify TubePress's HTML for a thumbnail galery.
|
||||
*/
|
||||
//TubePress::registerFilter('galleryHtml', new SampleTubePressPlugin());
|
||||
BIN
src/wp-content/plugins/tubepress/screenshot-1.jpg
Normal file
BIN
src/wp-content/plugins/tubepress/screenshot-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/org/tubepress/impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_plugin_PluginManager',
|
||||
'org_tubepress_impl_ioc_IocContainer'
|
||||
));
|
||||
|
||||
/**
|
||||
* Convenience methods for the API user.
|
||||
*/
|
||||
class TubePress {
|
||||
|
||||
public static function registerFilter($filterPointName, $pluginInstance)
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$pluginManager = $ioc->get('org_tubepress_api_plugin_PluginManager');
|
||||
|
||||
$pluginManager->registerFilter($filterPointName, $pluginInstance);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performs TubePress-wide preflight checks and initialization.
|
||||
*/
|
||||
interface org_tubepress_api_bootstrap_Bootstrapper
|
||||
{
|
||||
|
||||
/**
|
||||
* Performs TubePress-wide initialization.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function boot();
|
||||
}
|
||||
45
src/wp-content/plugins/tubepress/sys/classes/org/tubepress/api/cache/Cache.class.php
vendored
Normal file
45
src/wp-content/plugins/tubepress/sys/classes/org/tubepress/api/cache/Cache.class.php
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* String cache for TubePress
|
||||
*/
|
||||
interface org_tubepress_api_cache_Cache
|
||||
{
|
||||
/**
|
||||
* Get a value from the cache
|
||||
*
|
||||
* @param string $key The key of the data to retrieve
|
||||
*
|
||||
* @return string The data at the given key, or false if not there
|
||||
*/
|
||||
function get($key);
|
||||
|
||||
/**
|
||||
* Save the given data with the given key
|
||||
*
|
||||
* @param string $key The key at which to save the data
|
||||
* @param string $data The data to save at the key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function save($key, $data);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The valid options categories and their names
|
||||
*
|
||||
*/
|
||||
class org_tubepress_api_const_options_CategoryName
|
||||
{
|
||||
const ADVANCED = 'advanced';
|
||||
const DISPLAY = 'display';
|
||||
const EMBEDDED = 'embedded';
|
||||
const FEED = 'feed';
|
||||
const META = 'meta';
|
||||
const WIDGET = 'widget';
|
||||
const OUTPUT = 'output';
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The types of options TubePress can handle
|
||||
*
|
||||
*/
|
||||
class org_tubepress_api_const_options_Type
|
||||
{
|
||||
const BOOL = 'boolean'; // Yes/No options
|
||||
const COLOR = 'color'; // An HTML color (6 hex digits)
|
||||
const INTEGRAL = 'integral'; // A number
|
||||
const MODE = 'mode'; // A gallery mode
|
||||
const ORDER = 'order'; // Video sort order
|
||||
const OUTPUT = 'output'; // Output mode
|
||||
const PLAYER = 'player'; // Shadowbox, popup, etc
|
||||
const PLAYER_IMPL = 'playerImplementation'; // YouTube, Longtail, etc
|
||||
const PLAYLIST = 'playlist'; // A YouTube playlist ID
|
||||
const SAFE_SEARCH = 'safeSearch'; // a SafeSearch level
|
||||
const TEXT = 'text'; // Free form text
|
||||
const THEME = 'theme'; // TubePress theme to use
|
||||
const TIME_FRAME = 'timeFrame'; // Today, last week, etc
|
||||
const YT_USER = 'youtubeUser'; // A YouTube username
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Advanced option names for the plugin.
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Advanced
|
||||
{
|
||||
const CACHE_CLEAN_FACTOR = 'cacheCleaningFactor';
|
||||
const CACHE_DIR = 'cacheDirectory';
|
||||
const CACHE_LIFETIME_SECONDS = 'cacheLifetimeSeconds';
|
||||
const DATEFORMAT = 'dateFormat';
|
||||
const DEBUG_ON = 'debugging_enabled';
|
||||
const DISABLE_HTTP_CURL = 'disableHttpTransportCurl';
|
||||
const DISABLE_HTTP_EXTHTTP = 'disableHttpTransportExtHttp';
|
||||
const DISABLE_HTTP_FOPEN = 'disableHttpTransportFopen';
|
||||
const DISABLE_HTTP_FSOCKOPEN = 'disableHttpTransportFsockOpen';
|
||||
const DISABLE_HTTP_STREAMS = 'disableHttpTransportStreams';
|
||||
const GALLERY_ID = 'galleryId';
|
||||
const KEYWORD = 'keyword';
|
||||
const VIDEO_BLACKLIST = 'videoBlacklist';
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display option names for the plugin
|
||||
*
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Display
|
||||
{
|
||||
//The order in which these constants are declared dictates the
|
||||
//order in which they'll be presented on the options page
|
||||
const THEME = 'theme';
|
||||
const AJAX_PAGINATION = 'ajaxPagination';
|
||||
const CURRENT_PLAYER_NAME = 'playerLocation';
|
||||
const RESULTS_PER_PAGE = 'resultsPerPage';
|
||||
const HQ_THUMBS = 'hqThumbs';
|
||||
const THUMB_HEIGHT = 'thumbHeight';
|
||||
const THUMB_WIDTH = 'thumbWidth';
|
||||
const FLUID_THUMBS = 'fluidThumbs';
|
||||
const ORDER_BY = 'orderBy';
|
||||
const PAGINATE_ABOVE = 'paginationAbove';
|
||||
const PAGINATE_BELOW = 'paginationBelow';
|
||||
const RANDOM_THUMBS = 'randomize_thumbnails';
|
||||
const RELATIVE_DATES = 'relativeDates';
|
||||
const DESC_LIMIT = 'descriptionLimit';
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Option names for the embedded player
|
||||
*
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Embedded
|
||||
{
|
||||
//The order in which these constants are declared dictates the
|
||||
//order in which they'll be presented on the options page */
|
||||
const PLAYER_IMPL = 'playerImplementation';
|
||||
const EMBEDDED_HEIGHT = 'embeddedHeight';
|
||||
const EMBEDDED_WIDTH = 'embeddedWidth';
|
||||
const LAZYPLAY = 'lazyPlay';
|
||||
const AUTOPLAY = 'autoplay';
|
||||
const FULLSCREEN = 'fullscreen';
|
||||
const HIGH_QUALITY = 'hd';
|
||||
const LOOP = 'loop';
|
||||
const PLAYER_COLOR = 'playerColor';
|
||||
const PLAYER_HIGHLIGHT = 'playerHighlight';
|
||||
const SHOW_INFO = 'showInfo';
|
||||
const SHOW_RELATED = 'showRelated';
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* YouTube feed options
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Feed
|
||||
{
|
||||
/* The order in which these constants are declared dictates the
|
||||
order in which they'll be presented on the options page */
|
||||
const CACHE_ENABLED = 'cacheEnabled';
|
||||
const EMBEDDABLE_ONLY = 'embeddableOnly';
|
||||
const FILTER = 'filter_racy';
|
||||
const DEV_KEY = 'developerKey';
|
||||
const RESULT_COUNT_CAP = 'resultCountCap';
|
||||
const SEARCH_ONLY_USER = 'searchResultsRestrictedToUser';
|
||||
const VIMEO_KEY = 'vimeoKey';
|
||||
const VIMEO_SECRET = 'vimeoSecret';
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Option names that control which meta info is displayed below video
|
||||
* thumbnails
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Meta
|
||||
{
|
||||
const AUTHOR = 'author';
|
||||
const CATEGORY = 'category';
|
||||
const DESCRIPTION = 'description';
|
||||
const ID = 'id';
|
||||
const LENGTH = 'length';
|
||||
const LIKES = 'likes';
|
||||
const RATING = 'rating';
|
||||
const RATINGS = 'ratings';
|
||||
const TAGS = 'tags';
|
||||
const TITLE = 'title';
|
||||
const UPLOADED = 'uploaded';
|
||||
const URL = 'url';
|
||||
const VIEWS = 'views';
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Option names defining what output to display
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Output
|
||||
{
|
||||
const MODE = 'mode';
|
||||
const VIDEO = 'video';
|
||||
const OUTPUT = 'output';
|
||||
|
||||
const SEARCH_RESULTS_URL = 'searchResultsUrl';
|
||||
const SEARCH_RESULTS_ONLY = 'searchResultsOnly';
|
||||
const SEARCH_PROVIDER = 'searchProvider';
|
||||
const SEARCH_RESULTS_DOM_ID = 'searchResultsDomId';
|
||||
|
||||
const FAVORITES_VALUE = 'favoritesValue';
|
||||
const MOST_VIEWED_VALUE = 'most_viewedValue';
|
||||
const PLAYLIST_VALUE = 'playlistValue';
|
||||
const TAG_VALUE = 'tagValue';
|
||||
const TOP_FAVORITES_VALUE = 'youtubeTopFavoritesValue';
|
||||
const TOP_RATED_VALUE = 'top_ratedValue';
|
||||
const USER_VALUE = 'userValue';
|
||||
const VIMEO_UPLOADEDBY_VALUE = 'vimeoUploadedByValue';
|
||||
const VIMEO_LIKES_VALUE = 'vimeoLikesValue';
|
||||
const VIMEO_APPEARS_IN_VALUE = 'vimeoAppearsInValue';
|
||||
const VIMEO_SEARCH_VALUE = 'vimeoSearchValue';
|
||||
const VIMEO_CREDITED_VALUE = 'vimeoCreditedToValue';
|
||||
const VIMEO_CHANNEL_VALUE = 'vimeoChannelValue';
|
||||
const VIMEO_ALBUM_VALUE = 'vimeoAlbumValue';
|
||||
const VIMEO_GROUP_VALUE = 'vimeoGroupValue';
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget option names for the plugin
|
||||
*/
|
||||
class org_tubepress_api_const_options_names_Widget
|
||||
{
|
||||
const TAGSTRING = 'widget-tagstring';
|
||||
const TITLE = 'widget-title';
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress gallery content modes.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_ModeValue
|
||||
{
|
||||
const FAVORITES = 'favorites';
|
||||
const FEATURED = 'recently_featured';
|
||||
const MOST_DISCUSSED = 'most_discussed';
|
||||
const MOST_RECENT = 'most_recent';
|
||||
const MOST_RESPONDED = 'most_responded';
|
||||
const PLAYLIST = 'playlist';
|
||||
const POPULAR = 'most_viewed';
|
||||
const TAG = 'tag';
|
||||
const TOP_FAVORITES = 'youtubeTopFavorites';
|
||||
const TOP_RATED = 'top_rated';
|
||||
const USER = 'user';
|
||||
const VIMEO_UPLOADEDBY = 'vimeoUploadedBy';
|
||||
const VIMEO_LIKES = 'vimeoLikes';
|
||||
const VIMEO_APPEARS_IN = 'vimeoAppearsIn';
|
||||
const VIMEO_SEARCH = 'vimeoSearch';
|
||||
const VIMEO_CREDITED = 'vimeoCreditedTo';
|
||||
const VIMEO_CHANNEL = 'vimeoChannel';
|
||||
const VIMEO_ALBUM = 'vimeoAlbum';
|
||||
const VIMEO_GROUP = 'vimeoGroup';
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress gallery content modes.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_OrderValue
|
||||
{
|
||||
const COMMENT_COUNT = 'commentCount';
|
||||
const DATE_PUBLISHED = 'published';
|
||||
const DURATION = 'duration';
|
||||
const NEWEST = 'newest';
|
||||
const OLDEST = 'oldest';
|
||||
const POSITION = 'position';
|
||||
const RANDOM = 'random';
|
||||
const RATING = 'rating';
|
||||
const RELEVANCE = 'relevance';
|
||||
const TITLE = 'title';
|
||||
const VIEW_COUNT = 'viewCount';
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Output options.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_OutputValue
|
||||
{
|
||||
const AJAX_SEARCH_INPUT = 'ajaxSearchInput';
|
||||
const SEARCH_INPUT = 'searchInput';
|
||||
const SEARCH_RESULTS = 'searchResults';
|
||||
const PLAYER = 'player';
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress gallery content modes.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_PlayerImplementationValue
|
||||
{
|
||||
const PROVIDER_BASED = 'provider_based';
|
||||
const LONGTAIL = 'longtail';
|
||||
const EMBEDPLUS = 'embedplus';
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress gallery content modes.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_PlayerValue
|
||||
{
|
||||
const NORMAL = 'normal';
|
||||
const POPUP = 'popup';
|
||||
const SHADOWBOX = 'shadowbox';
|
||||
const JQMODAL = 'jqmodal';
|
||||
const VIMEO = 'vimeo';
|
||||
const YOUTUBE = 'youtube';
|
||||
const STATICC = 'static';
|
||||
const SOLO = 'solo';
|
||||
const FANCYBOX = 'fancybox';
|
||||
const TINYBOX = 'tinybox';
|
||||
const DETACHED = 'detached';
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress gallery content modes.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_SafeSearchValue
|
||||
{
|
||||
const NONE = 'none';
|
||||
const MODERATE = 'moderate';
|
||||
const STRICT = 'strict';
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress gallery content modes.
|
||||
*/
|
||||
class org_tubepress_api_const_options_values_TimeFrameValue
|
||||
{
|
||||
const TODAY = 'today';
|
||||
const THIS_WEEK = 'this_week';
|
||||
const THIS_MONTH = 'this_month';
|
||||
const ALL_TIME = 'all_time';
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Official event names around the TubePress core.
|
||||
*/
|
||||
interface org_tubepress_api_const_plugin_EventName
|
||||
{
|
||||
/**
|
||||
* function on_boot();
|
||||
*/
|
||||
const BOOT = 'boot';
|
||||
}
|
||||
|
||||
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Official filter points around the TubePress core.
|
||||
*/
|
||||
interface org_tubepress_api_const_plugin_FilterPoint
|
||||
{
|
||||
/**
|
||||
* Modify any HTML that TubePress generates.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('html', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param string $html The raw HTML to modify.
|
||||
*
|
||||
* @return string The (possibly modified) HTML. Never null.
|
||||
*
|
||||
* function alter_html($html);
|
||||
*/
|
||||
const HTML_ANY = 'html';
|
||||
|
||||
/**
|
||||
* Modify the HTML for the embedded video player.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('embeddedHtml', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param string $template The raw embedded player HTML to modify.
|
||||
* @param string $videoId The video ID currently being loaded into the embedded player.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
* @param string $embeddedImplName The name of the embedded implementation ("youtube", "longtail", or "vimeo")
|
||||
*
|
||||
* @return string The (possibly modified) HTML for the embedded player. Never null.
|
||||
*
|
||||
* function alter_embeddedHtml($html, $videoId, $videoProviderName, $embeddedImplName);
|
||||
*/
|
||||
const HTML_EMBEDDED = 'embeddedHtml';
|
||||
|
||||
/**
|
||||
* Modify the HTML for a thumbnail gallery.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('galleryHtml', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param string $html The HTML to modify.
|
||||
* @param org_tubepress_api_provider_ProviderResult $providerResult The provider result for this gallery.
|
||||
* @param int $page The current page number.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
*
|
||||
* @return string The (possibly modified) html. Never null.
|
||||
*
|
||||
* function alter_galleryHtml($html, org_tubepress_api_provider_ProviderResult $providerResult, $page, $providerName);
|
||||
*/
|
||||
const HTML_GALLERY = 'galleryHtml';
|
||||
|
||||
/**
|
||||
* function alter_paginationHtml($paginationHtml, $providerName);
|
||||
*/
|
||||
const HTML_PAGINATION = 'paginationHtml';
|
||||
|
||||
/**
|
||||
* Modify the HTML for the TubePress "player"
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('playerHtml', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param string $html The HTML to modify.
|
||||
* @param org_tubepress_api_video_Video $video The video to modify.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
* @param string $playerName The TubePress "player" name (e.g. "shadowbox", "normal", "youtube", etc)
|
||||
*
|
||||
* @return string The (possibly modified) player HTML. Never null.
|
||||
*
|
||||
* function alter_playerHtml($html, org_tubepress_api_video_Video $video, $providerName, $playerName);
|
||||
*/
|
||||
const HTML_PLAYER = 'playerHtml';
|
||||
|
||||
/**
|
||||
* function alter_searchInputHtml($rawHtml);
|
||||
*/
|
||||
const HTML_SEARCHINPUT = 'searchInputHtml';
|
||||
|
||||
/**
|
||||
* Modify the HTML for a single video embed.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('singleVideoHtml', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param string $html The HTML to modify.
|
||||
* @param org_tubepress_api_video_Video $video The video to modify.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The (possibly modified) html. Never null.
|
||||
*
|
||||
*
|
||||
* function alter_singleVideoHtml($rawHtml, org_tubepress_api_video_Video $video, $providerName);
|
||||
*/
|
||||
const HTML_SINGLEVIDEO = 'singleVideoHtml';
|
||||
|
||||
/**
|
||||
* Filters the TubePress provider result.
|
||||
*
|
||||
* function alter_providerResult(org_tubepress_api_provider_ProviderResult $providerResult, $providerName);
|
||||
*/
|
||||
const PROVIDER_RESULT = 'providerResult';
|
||||
|
||||
/**
|
||||
* Modify the embedded player template.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('embeddedTemplate', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param org_tubepress_api_template_Template $template The template to modify.
|
||||
* @param string $videoId The video ID currently being loaded into the embedded player.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
* @param org_tubepress_api_url_Url $dataUrl The embedded data URL.
|
||||
* @param string $embeddedImplName The name of the embedded implementation ("youtube", "longtail", or "vimeo")
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The (possibly modified) template. Never null.
|
||||
*
|
||||
* function alter_embeddedTemplate(org_tubepress_api_template_Template $template, $videoId, $videoProviderName,
|
||||
* org_tubepress_api_url_Url $dataUrl, $embeddedImplName)
|
||||
*/
|
||||
const TEMPLATE_EMBEDDED = 'embeddedTemplate';
|
||||
|
||||
/**
|
||||
* Modify the template for a thumbnail gallery.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('galleryTemplate', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param org_tubepress_api_template_Template $template The template to modify.
|
||||
* @param org_tubepress_api_provider_ProviderResult $providerResult The provider result for this gallery.
|
||||
* @param int $page The current page number.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The (possibly modified) template. Never null.
|
||||
*
|
||||
*
|
||||
* function alter_galleryTemplate(org_tubepress_api_template_Template $template, org_tubepress_api_provider_ProviderResult $providerResult, $page, $providerName);
|
||||
*/
|
||||
const TEMPLATE_GALLERY = 'galleryTemplate';
|
||||
|
||||
/**
|
||||
* Modify the template for the TubePress "player"
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('playerTemplate', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param org_tubepress_api_template_Template $template The template to modify.
|
||||
* @param org_tubepress_api_video_Video $video The video to modify.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
* @param string $playerName The TubePress "player" name (e.g. "shadowbox", "normal", "youtube", etc)
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The (possibly modified) template. Never null.
|
||||
*
|
||||
* function alter_playerTemplate(org_tubepress_api_template_Template $template, org_tubepress_api_video_Video $video, $videoProviderName, $playerName);
|
||||
*/
|
||||
const TEMPLATE_PLAYER = 'playerTemplate';
|
||||
|
||||
/**
|
||||
* Modify the template for a single video embed.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('singleVideoTemplate', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param org_tubepress_api_template_Template $template The template to modify.
|
||||
* @param org_tubepress_api_video_Video $video The video to modify.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The (possibly modified) template. Never null.
|
||||
*
|
||||
*
|
||||
* function alter_singleVideoTemplate(org_tubepress_api_template_Template $template, org_tubepress_api_video_Video $video, $providerName);
|
||||
*/
|
||||
const TEMPLATE_SINGLEVIDEO = 'singleVideoTemplate';
|
||||
|
||||
/**
|
||||
* Modify the template for the interactive search input.
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('searchInputTemplate', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param org_tubepress_api_template_Template $template The template to modify.
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The (possibly modified) template. Never null.
|
||||
*
|
||||
*
|
||||
* function alter_searchInputTemplate(org_tubepress_api_template_Template $template);
|
||||
*/
|
||||
const TEMPLATE_SEARCHINPUT = 'searchInputTemplate';
|
||||
|
||||
/**
|
||||
* Modify an invididual TubePress video (YouTube or Vimeo).
|
||||
*
|
||||
* To use this filter point, create a class that includes a function with the method signature defined below.
|
||||
* Then in your plugin file (tubepress/content/plugins/yourplugin/yourplugin.php), register the class with:
|
||||
*
|
||||
* TubePress::registerFilter('video', $yourClassInstance);
|
||||
*
|
||||
*
|
||||
* @param org_tubepress_api_video_Video $video The video to modify.
|
||||
* @param string $videoProviderName The name of the video provider ("vimeo" or "youtube")
|
||||
*
|
||||
* @return org_tubepress_api_video_Video The (possibly modified) video. Never null.
|
||||
*
|
||||
* function alter_video(org_tubepress_api_video_Video $video, $videoProviderName);
|
||||
*/
|
||||
const VIDEO = 'video';
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Query string parameter names.
|
||||
*/
|
||||
class org_tubepress_api_const_querystring_QueryParamName
|
||||
{
|
||||
const DEBUG = 'tubepress_debug';
|
||||
const PAGE = 'tubepress_page';
|
||||
const SEARCH_TERMS = 'tubepress_search';
|
||||
const SHORTCODE = 'tubepress_shortcode';
|
||||
const VIDEO = 'tubepress_video';
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress template variables
|
||||
*/
|
||||
class org_tubepress_api_const_template_Variable
|
||||
{
|
||||
const AUTHOR_URL_PREFIX = 'authorUrlPrefix';
|
||||
const EMBEDDED_AUTOSTART = 'autostart';
|
||||
const EMBEDDED_COLOR_HIGHLIGHT = 'embeddedColorHightlight';
|
||||
const EMBEDDED_COLOR_PRIMARY = 'embeddedColorPrimary';
|
||||
const EMBEDDED_DATA_URL = 'homeURL';
|
||||
const EMBEDDED_FULLSCREEN = 'embeddedFullscreen';
|
||||
const EMBEDDED_HEIGHT = 'embeddedHeight';
|
||||
const EMBEDDED_IMPL_NAME = 'embeddedImplementationName';
|
||||
const EMBEDDED_SOURCE = 'embeddedSource';
|
||||
const EMBEDDED_WIDTH = 'embeddedWidth';
|
||||
const GALLERY_ID = 'galleryId';
|
||||
const META_LABELS = 'metaLabels';
|
||||
const META_SHOULD_SHOW = 'shouldShow';
|
||||
const OPTIONS_PAGE_CATEGORIES = 'optionsPageCategories';
|
||||
const OPTIONS_PAGE_CATEGORY_OPTIONS = 'optionsPageCategoryOptions';
|
||||
const OPTIONS_PAGE_CATEGORY_TITLE = 'optionsPageCategoryTitle';
|
||||
const OPTIONS_PAGE_INTRO = 'optionsPageIntro';
|
||||
const OPTIONS_PAGE_OPTIONS_DESC = 'optionsPageOptionsDesc';
|
||||
const OPTIONS_PAGE_OPTIONS_FILTER = 'optionsPageOptionsFilter';
|
||||
const OPTIONS_PAGE_OPTIONS_PRO_ONLY = 'optionsPageProOnly';
|
||||
const OPTIONS_PAGE_OPTIONS_TITLE = 'optionsPageOptionTitle';
|
||||
const OPTIONS_PAGE_OPTIONS_WIDGET = 'optionsPageOptionsWidget';
|
||||
const OPTIONS_PAGE_SAVE = 'optionsPageSave';
|
||||
const OPTIONS_PAGE_TITLE = 'optionsPageTitle';
|
||||
const OPTIONS_PAGE_VIMEO_OPTION = 'optionsPageVimeoOption';
|
||||
const OPTIONS_PAGE_YOUTUBE_OPTION = 'optionsPageYouTubeOption';
|
||||
const PAGINATION_BOTTOM = 'bottomPagination';
|
||||
const PAGINATION_TOP = 'topPagination';
|
||||
const PLAYER_HTML = 'preGallery';
|
||||
const PLAYER_NAME = 'playerName';
|
||||
const PRE_GALLERY = 'preGallery';
|
||||
const SEARCH_HANDLER_URL = 'searchHandlerUrl';
|
||||
const SEARCH_HIDDEN_INPUTS = 'searchHiddenInputs';
|
||||
const SEARCH_BUTTON = 'searchButton';
|
||||
const SEARCH_TARGET_DOM_ID = 'searchTargetDomId';
|
||||
const SEARCH_TERMS = 'searchTerms';
|
||||
const SHORTCODE = 'shortcode';
|
||||
const THEME_CSS = 'themeCssUrl';
|
||||
const THUMBNAIL_HEIGHT = 'thumbHeight';
|
||||
const THUMBNAIL_WIDTH = 'thumbWidth';
|
||||
const TUBEPRESS_BASE_URL = 'tubepressBaseUrl';
|
||||
const VIDEO_ARRAY = 'videoArray';
|
||||
const VIDEO_SEARCH_PREFIX = 'videoSearchPrefix';
|
||||
const VIDEO = 'video';
|
||||
const VIDEO_ID = 'videoId';
|
||||
const WIDGET_CONTROL_SHORTCODE = 'widgetControlShortcode';
|
||||
const WIDGET_CONTROL_TITLE = 'widgetControlTitle';
|
||||
const WIDGET_SHORTCODE = 'widgetShortcode';
|
||||
const WIDGET_TITLE = 'widgetTitle';
|
||||
}
|
||||
|
||||
class org_tubepress_template_Template extends org_tubepress_api_const_template_Variable {
|
||||
//the only purpose of this class is for backwards compatibility with user HTML templates :(
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates the HTML for an embeddable Flash/HTML5 video player
|
||||
*
|
||||
*/
|
||||
interface org_tubepress_api_embedded_EmbeddedHtmlGenerator
|
||||
{
|
||||
/**
|
||||
* Spits back the text for this embedded player
|
||||
*
|
||||
* @param string $videoId The video ID to display
|
||||
*
|
||||
* @throws Exception If something goes wrong.
|
||||
*
|
||||
* @return string The text for this embedded player
|
||||
*/
|
||||
function getHtml($videoId);
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Detects TubePress's environment
|
||||
*/
|
||||
interface org_tubepress_api_environment_Detector
|
||||
{
|
||||
/**
|
||||
* Detects if the user is running TubePress Pro.
|
||||
*
|
||||
* @return boolean True is the user is running TubePress Pro. False otherwise (or if there is a problem detecting the environment).
|
||||
*/
|
||||
function isPro();
|
||||
|
||||
/**
|
||||
* Detects if the user is running within WordPress
|
||||
*
|
||||
* @return boolean True is the user is running within WordPress (or if there is a problem detecting the environment). False otherwise.
|
||||
*/
|
||||
function isWordPress();
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Holds the current execution context for TubePress. This is the default options,
|
||||
* usually in persistent storage somewhere, and custom options parsed
|
||||
* from a shortcode.
|
||||
*/
|
||||
interface org_tubepress_api_exec_ExecutionContext
|
||||
{
|
||||
/**
|
||||
* Gets the value of an option
|
||||
*
|
||||
* @param string $optionName The name of the option
|
||||
*
|
||||
* @return unknown The option value
|
||||
*/
|
||||
function get($optionName);
|
||||
|
||||
/**
|
||||
* Sets the value of an option
|
||||
*
|
||||
* @param string $optionName The name of the option
|
||||
* @param unknown $optionValue The option value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set($optionName, $optionValue);
|
||||
|
||||
/**
|
||||
* Sets the options that differ from the default options.
|
||||
*
|
||||
* @param array $customOpts The custom options.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setCustomOptions($customOpts);
|
||||
|
||||
/**
|
||||
* Gets the options that differ from the default options.
|
||||
*
|
||||
* @return array The options that differ from the default options.
|
||||
*/
|
||||
function getCustomOptions();
|
||||
|
||||
/**
|
||||
* Set the current shortcode.
|
||||
*
|
||||
* @param string $newTagString The current shortcode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setActualShortcodeUsed($newTagString);
|
||||
|
||||
/**
|
||||
* Get the current shortcode
|
||||
*
|
||||
* @return string The current shortcode
|
||||
*/
|
||||
function getActualShortcodeUsed();
|
||||
|
||||
function toShortcode();
|
||||
|
||||
/**
|
||||
* Resets the context for fresh execution.
|
||||
*/
|
||||
function reset();
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Converts raw video feeds to TubePress videos
|
||||
*/
|
||||
interface org_tubepress_api_factory_VideoFactory
|
||||
{
|
||||
/**
|
||||
* Converts raw video feeds to TubePress videos
|
||||
*
|
||||
* @param unknown $feed The raw feed result from the video provider
|
||||
*
|
||||
* @return array an array of TubePress videos generated from the feed (may be empty).
|
||||
*/
|
||||
function feedToVideoArray($feed);
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress's feed retrieval mechanism
|
||||
*
|
||||
*/
|
||||
interface org_tubepress_api_feed_FeedFetcher
|
||||
{
|
||||
/**
|
||||
* Fetches the feed from the remote provider
|
||||
*
|
||||
* @param string $url The URL to fetch.
|
||||
* @param boolean $useCache Whether or not to use the network cache.
|
||||
*
|
||||
* @return unknown The raw feed from the provider
|
||||
*/
|
||||
function fetch($url, $useCache);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Examines the feed results.
|
||||
*/
|
||||
interface org_tubepress_api_feed_FeedInspector
|
||||
{
|
||||
/**
|
||||
* Count the total videos in this feed result.
|
||||
*
|
||||
* @param unknown $rawFeed The raw video feed (varies depending on provider)
|
||||
*
|
||||
* @return int The total result count of this query, or 0 if there was a problem.
|
||||
*/
|
||||
function getTotalResultCount($rawFeed);
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filesystem utilities.
|
||||
*/
|
||||
interface org_tubepress_api_filesystem_Explorer
|
||||
{
|
||||
/**
|
||||
* Finds the absolute path of the TubePress installation on the filesystem.
|
||||
*
|
||||
* @return string The absolute filesystem path of this TubePress installation.
|
||||
*/
|
||||
function getTubePressBaseInstallationPath();
|
||||
|
||||
/**
|
||||
* Find the directory name of the TubePress base installation.
|
||||
*
|
||||
* @return string The base name of the TubePress installation directory.
|
||||
*/
|
||||
function getTubePressInstallationDirectoryBaseName();
|
||||
|
||||
/**
|
||||
* Find the directories contained in the given directory (non-recursive).
|
||||
*
|
||||
* @param string $dir The absolute filesystem path of the directory to examine.
|
||||
* @param string $prefix The logging prefix.
|
||||
*
|
||||
* @return array The names of the directories in the given directory (non-recursive).
|
||||
*/
|
||||
function getDirectoriesInDirectory($dir, $prefix);
|
||||
|
||||
/**
|
||||
* Find the files contained in the given directory (non-recursive).
|
||||
*
|
||||
* @param string $dir The absolute filesystem path of the directory to examine.
|
||||
* @param string $prefix The logging prefix.
|
||||
*
|
||||
* @return array The names of the files in the given directory (non-recursive).
|
||||
*/
|
||||
function getFilenamesInDirectory($dir, $prefix);
|
||||
|
||||
/**
|
||||
* Attempt to get temporary directory.
|
||||
*
|
||||
* @return string The absolute path of a temporary directory, preferably the system directory.
|
||||
*/
|
||||
function getSystemTempDirectory();
|
||||
|
||||
function copyDirectory($source, $dest);
|
||||
|
||||
function ensureDirectoryExists($directory);
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates HTML for use in the <head>.
|
||||
*/
|
||||
interface org_tubepress_api_html_HeadHtmlGenerator
|
||||
{
|
||||
function getHeadJqueryInclusion();
|
||||
|
||||
function getHeadInlineJs();
|
||||
|
||||
function getHeadJsIncludeString();
|
||||
|
||||
function getHeadCssIncludeString();
|
||||
|
||||
function getHeadHtmlMeta();
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles HTTP client functionality.
|
||||
*/
|
||||
interface org_tubepress_api_http_HttpClient
|
||||
{
|
||||
const HTTP_METHOD_GET = 'GET';
|
||||
const HTTP_METHOD_POST = 'POST';
|
||||
const HTTP_METHOD_PUT = 'PUT';
|
||||
|
||||
const HTTP_HEADER_ACCEPT_ENCODING = 'Accept-Encoding';
|
||||
const HTTP_HEADER_CONTENT_LENGTH = 'Content-Length';
|
||||
const HTTP_HEADER_CONTENT_TYPE = 'Content-Type';
|
||||
const HTTP_HEADER_USER_AGENT = 'User-Agent';
|
||||
|
||||
/**
|
||||
* Get.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
*
|
||||
* @throws Exception If something goes wrong.
|
||||
*
|
||||
* @return string Resulting body as a string (could be null)
|
||||
*/
|
||||
function get($url);
|
||||
|
||||
/**
|
||||
* Post.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
* @param unknown $body The HTTP body.
|
||||
*
|
||||
* @return string Resulting body as a string (could be null)
|
||||
*/
|
||||
function post($url, $body);
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dependency injector for TubePress
|
||||
*/
|
||||
interface org_tubepress_api_ioc_IocService
|
||||
{
|
||||
/**
|
||||
* Get an object from the container by name.
|
||||
*
|
||||
* @param string $className The name of the object to retrieve.
|
||||
*
|
||||
* @return object The object with the given name.
|
||||
*/
|
||||
function get($className);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* General purpose message abstraction for TubePress
|
||||
*/
|
||||
interface org_tubepress_api_message_MessageService
|
||||
{
|
||||
/**
|
||||
* Get the message corresponding to the given key.
|
||||
*
|
||||
* @param string $messageKey The message key.
|
||||
*
|
||||
* @return string The corresponding message.
|
||||
*/
|
||||
function _($messageKey);
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performs validation on option values
|
||||
*/
|
||||
interface org_tubepress_api_options_OptionValidator
|
||||
{
|
||||
/**
|
||||
* Validates an option value. Will throw an Exception if validation
|
||||
* fails.
|
||||
*
|
||||
* @param string $optionName The option name
|
||||
* @param unknown_type $candidate The candidate option value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function validate($optionName, $candidate);
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles persistent storage of TubePress options
|
||||
*
|
||||
*/
|
||||
interface org_tubepress_api_options_StorageManager
|
||||
{
|
||||
/**
|
||||
* Determines if an option exists
|
||||
*
|
||||
* @param string $optionName The name of the option in question
|
||||
*
|
||||
* @return boolean True if the option exists, false otherwise
|
||||
*/
|
||||
function exists($optionName);
|
||||
|
||||
/**
|
||||
* Initializes the storage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init();
|
||||
|
||||
/**
|
||||
* Retrieve the current value of an option
|
||||
*
|
||||
* @param string $optionName The name of the option
|
||||
*
|
||||
* @return unknown_type The option's value
|
||||
*/
|
||||
function get($optionName);
|
||||
|
||||
/**
|
||||
* Sets an option value
|
||||
*
|
||||
* @param string $optionName The option name
|
||||
* @param unknown_type $optionValue The option value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set($optionName, $optionValue);
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Chain in the chain-of-responsibility pattern.
|
||||
*/
|
||||
interface org_tubepress_api_patterns_cor_Chain
|
||||
{
|
||||
/**
|
||||
* Executes the given commands with the given context.
|
||||
*
|
||||
* @param array $context An array of context elements (may be empty).
|
||||
* @param array $commandInstances An array of org_tubepress_api_patterns_cor_Command class names to execute.
|
||||
*
|
||||
* @throws Exception If none of the commands can handle execution.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function execute($context, $commandInstances);
|
||||
|
||||
/**
|
||||
* Create a context object for the chain to work with.
|
||||
*
|
||||
* @return object An instance of stdClass for the commands to work with.
|
||||
*/
|
||||
function createContextInstance();
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A generic chain link.
|
||||
*/
|
||||
interface org_tubepress_api_patterns_cor_Command
|
||||
{
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @param array $context An array of context elements (may be empty).
|
||||
*
|
||||
* @return boolean True if this command was able to handle the execution. False otherwise.
|
||||
*/
|
||||
function execute($context);
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_video_Video'
|
||||
));
|
||||
|
||||
/**
|
||||
* A TubePress "player", such as lightWindow, GreyBox, popup window, etc
|
||||
*/
|
||||
interface org_tubepress_api_player_PlayerHtmlGenerator
|
||||
{
|
||||
/**
|
||||
* Get's the HTML for the TubePress "player"
|
||||
*
|
||||
* @param org_tubepress_api_video_Video $vid The video to display in the player.
|
||||
*
|
||||
* @throws Exception If something goes wrong.
|
||||
*
|
||||
* @return string The HTML for this player with the given video.
|
||||
*/
|
||||
function getHtml(org_tubepress_api_video_Video $vid);
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Manages the registration and execution of plugins.
|
||||
*/
|
||||
interface org_tubepress_api_plugin_PluginManager
|
||||
{
|
||||
/**
|
||||
* Determines if there are any filters registered for the given point.
|
||||
*
|
||||
* @param string $filterPoint The filter point to check.
|
||||
*
|
||||
* @return boolean True if there are filters registered for the given point. False otherwise.
|
||||
*/
|
||||
public function hasFilters($filterPoint);
|
||||
|
||||
/**
|
||||
* Run all filters for the given filter point.
|
||||
*
|
||||
* @param string $filterPoint The name of the filter point.
|
||||
* @param unknown $value The value to send to the plugins.
|
||||
*
|
||||
* @return unknown_type The modified value, or void.
|
||||
*/
|
||||
public function runFilters($filterPoint, $value);
|
||||
|
||||
/**
|
||||
* Registers a filter.
|
||||
*
|
||||
* @param string $filterPoint The name of the filter point.
|
||||
* @param object $plugin The plugin instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function registerFilter($filterPoint, $plugin);
|
||||
|
||||
/**
|
||||
* Determines if there are any listeners registered for the given event.
|
||||
*
|
||||
* @param string $eventName The event name to check.
|
||||
*
|
||||
* @return boolean True if there are listeners registered for the given event. False otherwise.
|
||||
*/
|
||||
public function hasListeners($eventName);
|
||||
|
||||
/**
|
||||
* Run all listeners for the given event.
|
||||
*
|
||||
* @param string $eventName The name of the event.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function notifyListeners($eventName);
|
||||
|
||||
/**
|
||||
* Registers a listener.
|
||||
*
|
||||
* @param string $eventName The name of the event.
|
||||
* @param object $plugin The plugin instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function registerListener($eventName, $plugin);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_exec_ExecutionContext'
|
||||
));
|
||||
|
||||
/**
|
||||
* Interface to a remove video provider
|
||||
*/
|
||||
interface org_tubepress_api_provider_Provider
|
||||
{
|
||||
const DIRECTORY = 'directory';
|
||||
const YOUTUBE = 'youtube';
|
||||
const VIMEO = 'vimeo';
|
||||
|
||||
/**
|
||||
* Get the video feed result.
|
||||
*
|
||||
* @return org_tubepress_api_provider_ProviderResult The feed result, never null.
|
||||
*/
|
||||
function getMultipleVideos();
|
||||
|
||||
/**
|
||||
* Fetch a single video.
|
||||
*
|
||||
* @param string $customVideoId The video ID to fetch.
|
||||
*
|
||||
* @return org_tubepress_api_video_Video The video, or null if there's a problem.
|
||||
*/
|
||||
function getSingleVideo($customVideoId);
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Calculates video provider in use.
|
||||
*/
|
||||
interface org_tubepress_api_provider_ProviderCalculator
|
||||
{
|
||||
/**
|
||||
* Determine the current video provider.
|
||||
*
|
||||
* @return string 'youtube', 'vimeo', or 'directory'
|
||||
*/
|
||||
function calculateCurrentVideoProvider();
|
||||
|
||||
/**
|
||||
* Determine the provider of the given video ID.
|
||||
*
|
||||
* @param string $videoId The ID of the video to examine.
|
||||
*
|
||||
* @return string 'youtube', 'vimeo', or 'directory'
|
||||
*/
|
||||
function calculateProviderOfVideoId($videoId);
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple class to abstract the response from a video provider
|
||||
*/
|
||||
class org_tubepress_api_provider_ProviderResult
|
||||
{
|
||||
private $_effectiveDisplayCount;
|
||||
private $_effectiveTotalResultCount;
|
||||
private $_videoArray;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_effectiveDisplayCount = 0;
|
||||
$this->_effectiveTotalResultCount = 0;
|
||||
$this->_videoArray = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the video array
|
||||
*
|
||||
* @param array $videos The video array.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setVideoArray($videos)
|
||||
{
|
||||
if (!is_array($videos)) {
|
||||
throw new Exception('setVideoArray can only take on an array. You supplied ' . var_export($videos, true));
|
||||
}
|
||||
$this->_videoArray = $videos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the effective total result count
|
||||
*
|
||||
* @param integer $count The effective total result count.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setEffectiveTotalResultCount($count)
|
||||
{
|
||||
if (!is_numeric($count) || intval($count) < 0) {
|
||||
throw new Exception('setEffectiveTotalResultCount must take on a positive integer. You supplied ' . $count);
|
||||
}
|
||||
|
||||
$this->_effectiveTotalResultCount = intval($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the video array
|
||||
*
|
||||
* @return array The video array.
|
||||
*/
|
||||
public function getVideoArray()
|
||||
{
|
||||
return $this->_videoArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective total result count
|
||||
*
|
||||
* @return integer The effective total result count.
|
||||
*/
|
||||
public function getEffectiveTotalResultCount()
|
||||
{
|
||||
return $this->_effectiveTotalResultCount;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles some tasks related to the query string
|
||||
*/
|
||||
interface org_tubepress_api_querystring_QueryStringService
|
||||
{
|
||||
/**
|
||||
* Try to get the custom video ID from the query string
|
||||
*
|
||||
* @param array $getVars The PHP $_GET array
|
||||
*
|
||||
* @return string The custom video ID, or '' if not set or if there was a problem.
|
||||
*/
|
||||
function getCustomVideo($getVars);
|
||||
|
||||
/**
|
||||
* Returns what's in the address bar
|
||||
*
|
||||
* @param array $serverVars The PHP $_SERVER array
|
||||
*
|
||||
* @return string What's in the address bar
|
||||
*/
|
||||
function getFullUrl($serverVars);
|
||||
|
||||
/**
|
||||
* Try to figure out what page we're on by looking at the query string
|
||||
* Defaults to '1' if there's any doubt
|
||||
*
|
||||
* @param array $getVars The PHP $_GET array
|
||||
*
|
||||
* @return int The page number, or 1 if there was a problem.
|
||||
*/
|
||||
function getPageNum($getVars);
|
||||
|
||||
/**
|
||||
* Try to get the shortcode from the query string
|
||||
*
|
||||
* @param array $getVars The PHP $_GET array
|
||||
*
|
||||
* @return string The shortcode, or '' if not set or if there was a problem.
|
||||
*/
|
||||
function getShortcode($getVars);
|
||||
|
||||
function getSearchTerms($getVars);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles shortcode HTML generation.
|
||||
*/
|
||||
interface org_tubepress_api_shortcode_ShortcodeHtmlGenerator
|
||||
{
|
||||
/**
|
||||
* Generates the HTML for the given shortcode.
|
||||
*
|
||||
* @param string $shortCodeContent The shortcode content.
|
||||
*
|
||||
* @return The HTML for the given shortcode, or the error message if there was a problem.
|
||||
*/
|
||||
function getHtmlForShortcode($shortCodeContent);
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parses shortcodes.
|
||||
*/
|
||||
interface org_tubepress_api_shortcode_ShortcodeParser
|
||||
{
|
||||
/**
|
||||
* This function is used to parse a shortcode into options that TubePress can use.
|
||||
*
|
||||
* @param string $content The haystack in which to search
|
||||
*
|
||||
* @return array The associative array of parsed options.
|
||||
*/
|
||||
function parse($content);
|
||||
|
||||
/**
|
||||
* Determines if the given content contains a shortcode.
|
||||
*
|
||||
* @param string $content The content to search through
|
||||
* @param string $trigger The shortcode trigger word
|
||||
*
|
||||
* @return boolean True if there's a shortcode in the content, false otherwise.
|
||||
*/
|
||||
function somethingToParse($content, $trigger = "tubepress");
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress template
|
||||
*/
|
||||
interface org_tubepress_api_template_Template
|
||||
{
|
||||
/**
|
||||
* Converts this template to a string
|
||||
*
|
||||
*@throws Exception If there was a problem.
|
||||
*
|
||||
* @return string The string representation of this template.
|
||||
*/
|
||||
function toString();
|
||||
|
||||
/**
|
||||
* Set a template variable.
|
||||
*
|
||||
* @param string $name The name of the template variable to set.
|
||||
* @param unknown $value The value of the template variable.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setVariable($name, $value);
|
||||
|
||||
/**
|
||||
* Resets this template for use. Clears out any set variables.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function reset();
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress template builder.
|
||||
*/
|
||||
interface org_tubepress_api_template_TemplateBuilder
|
||||
{
|
||||
/**
|
||||
* Get a new template instance.
|
||||
*
|
||||
* @param string $path The absolute path of the template.
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The template instance.
|
||||
*
|
||||
* @throws Exception If the template cannot be built.
|
||||
*/
|
||||
function getNewTemplateInstance($path);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TubePress theme handler.
|
||||
*/
|
||||
interface org_tubepress_api_theme_ThemeHandler
|
||||
{
|
||||
/**
|
||||
* Gets an instance of a template appropriate for the current theme.
|
||||
*
|
||||
* @param string $pathToTemplate The relative path (from the root of the theme directory) to the template.
|
||||
*
|
||||
* @throws Exception If there was a problem.
|
||||
*
|
||||
* @return org_tubepress_api_template_Template The template instance.
|
||||
*/
|
||||
function getTemplateInstance($pathToTemplate);
|
||||
|
||||
/**
|
||||
* Returns the URL of the CSS stylesheet for the given theme.
|
||||
*
|
||||
* @param string $currentTheme The name of the theme.
|
||||
*
|
||||
* @return string The URl of the CSS stylesheet.
|
||||
*/
|
||||
function getCssPath($currentTheme);
|
||||
|
||||
/**
|
||||
* Returns the name of the current TubePress theme in use.
|
||||
*
|
||||
* @return string The current theme name, or 'default' if the default theme is in use or if there was a problem.
|
||||
*/
|
||||
function calculateCurrentThemeName();
|
||||
|
||||
/**
|
||||
* Find the absolute path of the user's content directory. In WordPress, this will be
|
||||
* wp-content/tubepress-content. In standalone PHP, this will be tubepress/tubepress-content. Confusing, I know.
|
||||
*
|
||||
* @return string The absolute path of the user's content directory.
|
||||
*/
|
||||
function getUserContentDirectory();
|
||||
}
|
||||
@ -0,0 +1,294 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* URL class. Lifted mostly from PEAR's Net_URL2 class.
|
||||
*/
|
||||
class org_tubepress_api_url_Url
|
||||
{
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_scheme = false;
|
||||
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_userinfo = false;
|
||||
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_host = false;
|
||||
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_port = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_path = '';
|
||||
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_query = false;
|
||||
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
private $_fragment = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $url an absolute or relative URL
|
||||
*/
|
||||
public function __construct($url)
|
||||
{
|
||||
// The regular expression is copied verbatim from RFC 3986, appendix B.
|
||||
// The expression does not validate the URL but matches any string.
|
||||
preg_match('!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!', $url, $matches);
|
||||
|
||||
// "path" is always present (possibly as an empty string); the rest
|
||||
// are optional.
|
||||
$this->_scheme = !empty($matches[1]) ? $matches[2] : false;
|
||||
$this->setAuthority(!empty($matches[3]) ? $matches[4] : false);
|
||||
$this->_path = $matches[5];
|
||||
$this->_query = !empty($matches[6]) ? $matches[7] : false;
|
||||
$this->_fragment = !empty($matches[8]) ? $matches[9] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query string to the specified variable in the query string.
|
||||
*
|
||||
* @param array $array (name => value) array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setQueryVariables(array $array)
|
||||
{
|
||||
if (!$array) {
|
||||
$this->_query = false;
|
||||
} else {
|
||||
foreach ($array as $name => $value) {
|
||||
$name = self::urlencode($name);
|
||||
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
$parts[] = sprintf('%s[%s]=%s', $name, $k, $v);
|
||||
}
|
||||
} elseif (!is_null($value)) {
|
||||
$parts[] = $name . '=' . self::urlencode($value);
|
||||
} else {
|
||||
$parts[] = $name;
|
||||
}
|
||||
}
|
||||
$this->_query = implode('&', $parts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the specified variable in the query string.
|
||||
*
|
||||
* @param string $name variable name
|
||||
* @param mixed $value variable value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setQueryVariable($name, $value)
|
||||
{
|
||||
$array = $this->getQueryVariables();
|
||||
$array[$name] = $value;
|
||||
$this->setQueryVariables($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specifed variable from the query string.
|
||||
*
|
||||
* @param string $name a query string variable, e.g. "foo" in "?foo=1"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetQueryVariable($name)
|
||||
{
|
||||
$array = $this->getQueryVariables();
|
||||
unset($array[$name]);
|
||||
$this->setQueryVariables($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString($encodeAmpersands = false)
|
||||
{
|
||||
// See RFC 3986, section 5.3
|
||||
$url = "";
|
||||
|
||||
if ($this->_scheme !== false) {
|
||||
$url .= $this->_scheme . ':';
|
||||
}
|
||||
|
||||
$authority = $this->getAuthority();
|
||||
if ($authority !== false) {
|
||||
$url .= '//' . $authority;
|
||||
}
|
||||
$url .= $this->_path;
|
||||
|
||||
if ($this->_query !== false) {
|
||||
$url .= '?' . $this->_query;
|
||||
}
|
||||
|
||||
if ($this->_fragment !== false) {
|
||||
$url .= '#' . $this->_fragment;
|
||||
}
|
||||
|
||||
if ($encodeAmpersands) {
|
||||
return str_replace("&", "&", $url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent-encodes all non-alphanumeric characters except these: _ . - ~
|
||||
* Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP
|
||||
* 5.2.x and earlier.
|
||||
*
|
||||
* @param $raw the string to encode
|
||||
* @return string
|
||||
*/
|
||||
public static function urlencode($string)
|
||||
{
|
||||
$encoded = rawurlencode($string);
|
||||
|
||||
// This is only necessary in PHP < 5.3.
|
||||
$encoded = str_replace('%7E', '~', $encoded);
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify
|
||||
* false if there is no authority.
|
||||
*
|
||||
* @param string|false $authority a hostname or an IP addresse, possibly
|
||||
* with userinfo prefixed and port number
|
||||
* appended, e.g. "foo:bar@example.org:81".
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAuthority($authority)
|
||||
{
|
||||
$this->_userinfo = false;
|
||||
$this->_host = false;
|
||||
$this->_port = false;
|
||||
if (preg_match('@^(([^\@]*)\@)?([^:]+)(:(\d*))?$@', $authority, $reg)) {
|
||||
if ($reg[1]) {
|
||||
$this->_userinfo = $reg[2];
|
||||
}
|
||||
|
||||
$this->_host = $reg[3];
|
||||
if (isset($reg[5])) {
|
||||
$this->_port = $reg[5];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or
|
||||
* false if there is no authority.
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public function getAuthority()
|
||||
{
|
||||
if (!$this->_host) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$authority = '';
|
||||
|
||||
if ($this->_userinfo !== false) {
|
||||
$authority .= $this->_userinfo . '@';
|
||||
}
|
||||
|
||||
$authority .= $this->_host;
|
||||
|
||||
if ($this->_port !== false) {
|
||||
$authority .= ':' . $this->_port;
|
||||
}
|
||||
|
||||
return $authority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the query string like an array as the variables would appear in
|
||||
* $_GET in a PHP script. If the URL does not contain a "?", an empty array
|
||||
* is returned.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getQueryVariables()
|
||||
{
|
||||
$pattern = '/[' . preg_quote('&', '/') . ']/';
|
||||
$parts = preg_split($pattern, $this->_query, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$return = array();
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (strpos($part, '=') !== false) {
|
||||
list($key, $value) = explode('=', $part, 2);
|
||||
} else {
|
||||
$key = $part;
|
||||
$value = null;
|
||||
}
|
||||
|
||||
$key = rawurldecode($key);
|
||||
$value = rawurldecode($value);
|
||||
|
||||
if (preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
|
||||
|
||||
$key = $matches[1];
|
||||
$idx = $matches[2];
|
||||
|
||||
// Ensure is an array
|
||||
if (empty($return[$key]) || !is_array($return[$key])) {
|
||||
$return[$key] = array();
|
||||
}
|
||||
|
||||
// Add data
|
||||
if ($idx === '') {
|
||||
$return[$key][] = $value;
|
||||
} else {
|
||||
$return[$key][$idx] = $value;
|
||||
}
|
||||
} else {
|
||||
$return[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds URLs to send out to a remote provider
|
||||
*
|
||||
*/
|
||||
interface org_tubepress_api_url_UrlBuilder
|
||||
{
|
||||
/**
|
||||
* Builds a URL for a list of videos
|
||||
*
|
||||
* @param int $currentPage The current page number of the gallery.
|
||||
*
|
||||
* @throws Exception If there was a problem.
|
||||
*
|
||||
* @return string The request URL for this gallery
|
||||
*/
|
||||
function buildGalleryUrl($currentPage);
|
||||
|
||||
/**
|
||||
* Builds a request url for a single video
|
||||
*
|
||||
* @param string $id The video ID to search for
|
||||
*
|
||||
* @throws Exception If there was a problem.
|
||||
*
|
||||
* @return string The URL for the single video given.
|
||||
*/
|
||||
function buildSingleVideoUrl($id);
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A video object that TubePress processes
|
||||
*/
|
||||
class org_tubepress_api_video_Video
|
||||
{
|
||||
private $_authorDisplayName;
|
||||
private $_authorUid;
|
||||
private $_category;
|
||||
private $_commentCount;
|
||||
private $_description;
|
||||
private $_duration;
|
||||
private $_homeUrl;
|
||||
private $_id;
|
||||
private $_keywords;
|
||||
private $_likesCount;
|
||||
private $_ratingAverage;
|
||||
private $_ratingCount;
|
||||
private $_thumbnailUrl;
|
||||
private $_timeLastUpdated;
|
||||
private $_timePublished;
|
||||
private $_title;
|
||||
private $_viewCount;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_keywords = array();
|
||||
}
|
||||
|
||||
public function getAuthorDisplayName() { return $this->_authorDisplayName; }
|
||||
public function setAuthorDisplayName($author) { $this->_authorDisplayName = $author; }
|
||||
|
||||
public function getAuthorUid() { return $this->_authorUid; }
|
||||
public function setAuthorUid($author) { $this->_authorUid = $author; }
|
||||
|
||||
public function getCategory() { return $this->_category; }
|
||||
public function setCategory($category) { $this->_category = $category; }
|
||||
|
||||
public function getCommentCount() { return $this->_commentCount; }
|
||||
public function setCommentCount($count) { $this->_commentCount = $count; }
|
||||
|
||||
public function getDescription() { return $this->_description; }
|
||||
public function setDescription($description) { $this->_description = $description; }
|
||||
|
||||
public function getDuration() { return $this->_duration; }
|
||||
public function setDuration($duration) { $this->_duration = $duration; }
|
||||
|
||||
public function getHomeUrl() { return $this->_homeUrl; }
|
||||
public function setHomeUrl($url) { $this->_homeUrl = $url; }
|
||||
|
||||
public function getId() { return $this->_id; }
|
||||
public function setId($id) { $this->_id = $id; }
|
||||
|
||||
public function getKeywords() { return $this->_keywords; }
|
||||
public function setKeywords($keywords) { $this->_keywords = $keywords; }
|
||||
|
||||
public function getLikesCount() { return $this->_likesCount; }
|
||||
public function setLikesCount($c) { $this->_likesCount = $c; }
|
||||
|
||||
public function getRatingAverage() { return $this->_ratingAverage; }
|
||||
public function setRatingAverage($average) { $this->_ratingAverage = $average; }
|
||||
|
||||
public function getRatingCount() { return $this->_ratingCount; }
|
||||
public function setRatingCount($count) { $this->_ratingCount = $count; }
|
||||
|
||||
public function getThumbnailUrl() { return $this->_thumbnailUrl; }
|
||||
public function setThumbnailUrl($url) { $this->_thumbnailUrl = $url; }
|
||||
|
||||
public function getTimeLastUpdated() { return $this->_timeLastUpdated; }
|
||||
public function setTimeLastUpdated($time) { $this->_timeLastUpdated = $time; }
|
||||
|
||||
public function getTimePublished() { return $this->_timePublished; }
|
||||
public function setTimePublished($time) { $this->_timePublished = $time; }
|
||||
|
||||
public function getTitle() { return $this->_title; }
|
||||
public function setTitle($title) { $this->_title = $title; }
|
||||
|
||||
public function getViewCount() { return $this->_viewCount; }
|
||||
public function setViewCount($count) { $this->_viewCount = $count; }
|
||||
}
|
||||
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_bootstrap_Bootstrapper',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_const_options_names_Advanced',
|
||||
'org_tubepress_api_const_plugin_EventName',
|
||||
'org_tubepress_api_const_plugin_FilterPoint',
|
||||
'org_tubepress_api_environment_Detector',
|
||||
'org_tubepress_api_filesystem_Explorer',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_plugin_PluginManager',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
'org_tubepress_impl_log_Log',
|
||||
'TubePress'
|
||||
));
|
||||
|
||||
/**
|
||||
* Performs TubePress-wide initialization.
|
||||
*/
|
||||
class org_tubepress_impl_bootstrap_TubePressBootstrapper implements org_tubepress_api_bootstrap_Bootstrapper
|
||||
{
|
||||
const LOG_PREFIX = 'TubePress Bootstrapper';
|
||||
|
||||
private static $_alreadyBooted = false;
|
||||
|
||||
/**
|
||||
* Performs TubePress-wide initialization.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
/* don't boot twice! */
|
||||
if (self::$_alreadyBooted) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->_doBoot();
|
||||
} catch (Exception $e) {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Caught exception while booting: '. $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function _doBoot()
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
$envDetector = $ioc->get('org_tubepress_api_environment_Detector');
|
||||
$pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
|
||||
|
||||
/* WordPress likes to keep control of the output */
|
||||
if ($envDetector->isWordPress()) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
/* Turn on logging if we need to */
|
||||
org_tubepress_impl_log_Log::setEnabled($context->get(org_tubepress_api_const_options_names_Advanced::DEBUG_ON), $_GET);
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Booting!');
|
||||
|
||||
/* load plugins */
|
||||
$this->loadSystemPlugins($ioc);
|
||||
$this->_loadUserPlugins($ioc);
|
||||
|
||||
/* tell everyone we're booting */
|
||||
$pm->notifyListeners(org_tubepress_api_const_plugin_EventName::BOOT);
|
||||
|
||||
/* remember that we booted. */
|
||||
self::$_alreadyBooted = true;
|
||||
}
|
||||
|
||||
private function _loadUserPlugins(org_tubepress_api_ioc_IocService $ioc)
|
||||
{
|
||||
$pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
|
||||
$fe = $ioc->get('org_tubepress_api_filesystem_Explorer');
|
||||
$th = $ioc->get('org_tubepress_api_theme_ThemeHandler');
|
||||
$pluginPath = $th->getUserContentDirectory() . '/plugins';
|
||||
$pluginDirs = $fe->getDirectoriesInDirectory($pluginPath, self::LOG_PREFIX);
|
||||
|
||||
foreach ($pluginDirs as $pluginDir) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Examining potential plugin directory at %s', $pluginDir);
|
||||
|
||||
$files = $fe->getFilenamesInDirectory($pluginDir, self::LOG_PREFIX);
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
if ('.php' == substr($file, -4) && is_readable($file)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Loading PHP file at <tt>%s</tt>', $file);
|
||||
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load system-defined plugins.
|
||||
*
|
||||
* @param org_tubepress_api_ioc_IocService $ioc The IOC container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function loadSystemPlugins(org_tubepress_api_ioc_IocService $ioc)
|
||||
{
|
||||
$pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
|
||||
|
||||
/* embedded template filters */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED, $ioc->get('org_tubepress_impl_plugin_filters_embeddedtemplate_CoreVariables'));
|
||||
|
||||
/* gallery HTML filters */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::HTML_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_galleryhtml_GalleryJs'));
|
||||
|
||||
/* gallery template filters */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_CoreVariables'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_EmbeddedPlayerName'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_Pagination'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_Player'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_VideoMeta'));
|
||||
|
||||
/* player template filters */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_PLAYER, $ioc->get('org_tubepress_impl_plugin_filters_playertemplate_CoreVariables'));
|
||||
|
||||
/* provider result filters */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_ResultCountCapper'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_VideoBlacklist'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_Shuffler'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_VideoPrepender'));
|
||||
|
||||
/* search input template filter */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SEARCHINPUT, $ioc->get('org_tubepress_impl_plugin_filters_searchinputtemplate_CoreVariables'));
|
||||
|
||||
/* single video template filters */
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, $ioc->get('org_tubepress_impl_plugin_filters_singlevideotemplate_CoreVariables'));
|
||||
$pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, $ioc->get('org_tubepress_impl_plugin_filters_singlevideotemplate_VideoMeta'));
|
||||
|
||||
$pm->registerListener(org_tubepress_api_const_plugin_EventName::BOOT, $ioc->get('org_tubepress_impl_plugin_listeners_WordPressBoot'));
|
||||
$pm->registerListener(org_tubepress_api_const_plugin_EventName::BOOT, $ioc->get('org_tubepress_impl_plugin_listeners_SkeletonExistsListener'));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,362 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Fast, light and safe Cache Class lifted almost entirely from PEAR's Cache_Lite class.
|
||||
*
|
||||
* Cache_Lite is a fast, light and safe cache system. It's optimized
|
||||
* for file containers. It is fast and safe (because it uses file
|
||||
* locking and/or anti-corruption tests).
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_cache_Cache',
|
||||
'org_tubepress_api_const_options_names_Advanced',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_impl_filesystem_FsExplorer',
|
||||
'org_tubepress_impl_log_Log',
|
||||
));
|
||||
|
||||
class org_tubepress_impl_cache_PearCacheLiteCacheService implements org_tubepress_api_cache_Cache
|
||||
{
|
||||
const HASH_DIR_LEVEL = 1;
|
||||
const HASH_DIR_UMASK = 0700;
|
||||
|
||||
const LOG_PREFIX = 'Cache_Lite Cache';
|
||||
|
||||
/**
|
||||
* Test if a cache is available and (if yes) return it
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return string data of the cache (else : false)
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
try {
|
||||
return $this->_wrappedGet($id);
|
||||
} catch (Exception $e) {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Caught exception when running "get": ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function _wrappedGet($id)
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
$life = $context->get(org_tubepress_api_const_options_names_Advanced::CACHE_LIFETIME_SECONDS);
|
||||
$data = false;
|
||||
$refreshTime = $this->_getRefreshTime($life);
|
||||
$file = $this->_getFileWithPath($id, $ioc);
|
||||
|
||||
clearstatcache();
|
||||
|
||||
if (is_null($refreshTime)) {
|
||||
if (file_exists($file)) {
|
||||
$data = $this->_read($file, $life);
|
||||
}
|
||||
} else {
|
||||
if ((file_exists($file)) && (@filemtime($file) > $refreshTime)) {
|
||||
$data = $this->_read($file, $life);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save some data in a cache file
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @param string $data data to put in cache
|
||||
*
|
||||
* @return boolean true if no problem (else : false)
|
||||
*/
|
||||
public function save($id, $data)
|
||||
{
|
||||
try {
|
||||
return $this->_wrappedSave($id, $data);
|
||||
} catch (Exception $e) {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Caught exception when saving: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function _wrappedSave($id, $data)
|
||||
{
|
||||
if (!is_string($data)) {
|
||||
throw new Exception("Cache can only save string data");
|
||||
}
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
$life = $context->get(org_tubepress_api_const_options_names_Advanced::CACHE_LIFETIME_SECONDS);
|
||||
$cleaningFactor = $context->get(org_tubepress_api_const_options_names_Advanced::CACHE_CLEAN_FACTOR);
|
||||
$file = $this->_getFileWithPath($id, $ioc);
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Saving data to key at %s and file %s. Cleaning factor is %d', $id, $file, $cleaningFactor);
|
||||
|
||||
if ($cleaningFactor > 0) {
|
||||
$rand = rand(1, $cleaningFactor);
|
||||
if ($rand == 1) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Cleaning out old cache entries');
|
||||
$this->_cleanDir($this->_getCacheDir($ioc));
|
||||
}
|
||||
}
|
||||
|
||||
$res = $this->_writeAndControl($id, $data, $life, $file, $ioc);
|
||||
|
||||
if (is_bool($res)) {
|
||||
if ($res) {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Saved data to key at %s', $id);
|
||||
return true;
|
||||
}
|
||||
// if $res if false, we need to invalidate the cache
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Invalidating cache under key at %s', $id);
|
||||
@touch($file, time() - 2 * abs($life));
|
||||
return false;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should only be called during testing!
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clean()
|
||||
{
|
||||
$this->_cleanDir($this->_getCacheDir(org_tubepress_impl_ioc_IocContainer::getInstance()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute & set the refresh time
|
||||
*
|
||||
* @param int $life The current cache lifetime.
|
||||
*
|
||||
* @return int The Unix time when a cache item must be refreshed.
|
||||
*/
|
||||
private function _getRefreshTime($life)
|
||||
{
|
||||
if ($life === 0) {
|
||||
return null;
|
||||
} else {
|
||||
return time() - $life;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a file
|
||||
*
|
||||
* @param string $file complete file path and name
|
||||
*
|
||||
* @return boolean true if no problem
|
||||
*/
|
||||
private function _unlink($file)
|
||||
{
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Removing file at %s', $file);
|
||||
if (!@unlink($file)) {
|
||||
throw new Exception('Cache_Lite : Unable to remove cache file at ' . $file);
|
||||
}
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Removed file at %s', $file);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function for cleaning cache file in the given directory
|
||||
*
|
||||
* @param string $dir directory complete path (with a trailing slash)
|
||||
*
|
||||
* @return boolean true if no problem
|
||||
*/
|
||||
private function _cleanDir($dir)
|
||||
{
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Removing cache files under directory at %s', $dir);
|
||||
$motif = 'cache_';
|
||||
|
||||
if (!($dh = @opendir($dir))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = true;
|
||||
|
||||
while ($file = readdir($dh)) {
|
||||
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
|
||||
if (substr($file, 0, 6) == 'cache_') {
|
||||
|
||||
$fileTwo = $dir . $file;
|
||||
|
||||
if (is_file($fileTwo)) {
|
||||
|
||||
if (strpos($fileTwo, $motif) !== false) {
|
||||
$result = ($result and ($this->_unlink($fileTwo)));
|
||||
}
|
||||
}
|
||||
|
||||
if ((is_dir($fileTwo)) and (self::HASH_DIR_LEVEL > 0)) {
|
||||
$result = ($result and ($this->_cleanDir($fileTwo . '/')));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function _getFileWithoutPath($id)
|
||||
{
|
||||
return 'cache_' . md5($id);
|
||||
}
|
||||
|
||||
private function _getFileWithPath($id, $ioc)
|
||||
{
|
||||
$suffix = $this->_getFileWithoutPath($id);
|
||||
$root = $this->_getCacheDir($ioc);
|
||||
|
||||
if (self::HASH_DIR_LEVEL > 0) {
|
||||
|
||||
$hash = md5($suffix);
|
||||
|
||||
for ($i=0 ; $i < self::HASH_DIR_LEVEL ; $i++) {
|
||||
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
|
||||
}
|
||||
}
|
||||
|
||||
return $root . $suffix;
|
||||
}
|
||||
|
||||
private function _read($file, $life)
|
||||
{
|
||||
$fp = @fopen($file, "rb");
|
||||
@flock($fp, LOCK_SH);
|
||||
if (!$fp) {
|
||||
throw new Exception('Unable to read cache file at ' . $file);
|
||||
}
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$length = @filesize($file);
|
||||
$hashControl = @fread($fp, 32);
|
||||
$length = $length - 32;
|
||||
|
||||
if ($length) {
|
||||
$data = @fread($fp, $length);
|
||||
} else {
|
||||
$data = '';
|
||||
}
|
||||
|
||||
@flock($fp, LOCK_UN);
|
||||
@fclose($fp);
|
||||
|
||||
$hashData = $this->_hash($data);
|
||||
|
||||
if ($hashData != $hashControl) {
|
||||
|
||||
if (!(is_null($life))) {
|
||||
@touch($file, time() - 2*abs($life));
|
||||
} else {
|
||||
@unlink($file);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function _write($id, $data, $ioc)
|
||||
{
|
||||
$file = $this->_getFileWithPath($id, $ioc);
|
||||
$cacheDir = $this->_getCacheDir($ioc);
|
||||
|
||||
if (self::HASH_DIR_LEVEL > 0) {
|
||||
|
||||
$hash = md5($file);
|
||||
$root = $cacheDir;
|
||||
|
||||
for ($i=0 ; $i < self::HASH_DIR_LEVEL ; $i++) {
|
||||
|
||||
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
|
||||
|
||||
if (!(@is_dir($root))) {
|
||||
@mkdir($root, self::HASH_DIR_UMASK, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dir = dirname($file);
|
||||
if (!@is_dir($dir)) {
|
||||
@mkdir($dir, self::HASH_DIR_UMASK, true);
|
||||
}
|
||||
|
||||
$fp = @fopen($file, "wb");
|
||||
|
||||
if (!$fp) {
|
||||
throw new Exception('Unable to write cache file : ' . $file);
|
||||
}
|
||||
|
||||
@flock($fp, LOCK_EX);
|
||||
@fwrite($fp, $this->_hash($data), 32);
|
||||
@fwrite($fp, $data);
|
||||
@flock($fp, LOCK_UN);
|
||||
@fclose($fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _writeAndControl($id, $data, $life, $file, $ioc)
|
||||
{
|
||||
$result = $this->_write($id, $data, $ioc);
|
||||
$dataRead = $this->_read($file, $life);
|
||||
|
||||
if ((is_bool($dataRead)) && (!$dataRead)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $dataRead == $data;
|
||||
}
|
||||
|
||||
private function _hash($data)
|
||||
{
|
||||
return sprintf('% 32d', crc32($data));
|
||||
}
|
||||
|
||||
private function _getCacheDir($ioc)
|
||||
{
|
||||
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
$cacheDir = $context->get(org_tubepress_api_const_options_names_Advanced::CACHE_DIR);
|
||||
|
||||
if ($cacheDir != '') {
|
||||
return $cacheDir;
|
||||
}
|
||||
|
||||
$fs = $ioc->get('org_tubepress_api_filesystem_Explorer');
|
||||
$tempDir = $fs->getSystemTempDirectory();
|
||||
|
||||
if (!is_dir($tempDir)) {
|
||||
throw new Exception('Could not determine location of system temp directory');
|
||||
}
|
||||
return $tempDir . '/tubepress_cache/';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class org_tubepress_impl_classloader_ClassLoader
|
||||
{
|
||||
/**
|
||||
* Loads an array of classes for TubePress.
|
||||
*
|
||||
* @param array $classesToLoad An array of class names to load.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function loadClasses($classesToLoad)
|
||||
{
|
||||
if (!is_array($classesToLoad)) {
|
||||
self::loadClass($classesToLoad);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($classesToLoad as $class) {
|
||||
self::loadClass($class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to load a class file based on the class name
|
||||
*
|
||||
* @param string $className The name of the class to load
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function loadClass($className)
|
||||
{
|
||||
if (!is_string($className)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* already have the class or interface? bail */
|
||||
if (class_exists($className, false) || interface_exists($className, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* see if the class is in the loading queue */
|
||||
global $tubepressClassLoadingQueue;
|
||||
|
||||
if (!isset($tubepressClassLoadingQueue)) {
|
||||
$tubepressClassLoadingQueue = array();
|
||||
}
|
||||
|
||||
if (array_key_exists($className, $tubepressClassLoadingQueue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tubepressClassLoadingQueue[$className] = '1';
|
||||
|
||||
/*
|
||||
* replace all underscores with the directory separator and add ".class.php"
|
||||
* e.g. "org_tubepress_package_MyClass" becomes "org/tubepress/package/MyClass.class.php"
|
||||
*/
|
||||
$fileName = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.class.php';
|
||||
|
||||
/* piece together the absolute file name */
|
||||
$currentDir = dirname(__FILE__) . "/../../../../";
|
||||
$absPath = $currentDir . $fileName;
|
||||
|
||||
/* include the file if it exists */
|
||||
if (file_exists($absPath)) {
|
||||
include $absPath;
|
||||
} else {
|
||||
/* stupid hack to be able to insert a debugging breakpoint */
|
||||
$x = 1;
|
||||
}
|
||||
|
||||
/* class is done loading, remove it from the queue */
|
||||
unset($tubepressClassLoadingQueue[$className]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_plugin_FilterPoint',
|
||||
'org_tubepress_api_embedded_EmbeddedHtmlGenerator',
|
||||
'org_tubepress_api_patterns_cor_Chain',
|
||||
'org_tubepress_api_plugin_PluginManager',
|
||||
'org_tubepress_api_provider_ProviderCalculator',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
));
|
||||
|
||||
/**
|
||||
* An HTML-embeddable video player.
|
||||
*/
|
||||
class org_tubepress_impl_embedded_EmbeddedPlayerChain implements org_tubepress_api_embedded_EmbeddedHtmlGenerator
|
||||
{
|
||||
/**
|
||||
* Spits back the HTML for this embedded player
|
||||
*
|
||||
* @param string $videoId The video ID to display
|
||||
*
|
||||
* @return string The HTML for this embedded player
|
||||
*/
|
||||
public function getHtml($videoId)
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$pc = $ioc->get('org_tubepress_api_provider_ProviderCalculator');
|
||||
$chain = $ioc->get('org_tubepress_api_patterns_cor_Chain');
|
||||
$pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
|
||||
$providerName = $pc->calculateProviderOfVideoId($videoId);
|
||||
$context = $chain->createContextInstance();
|
||||
|
||||
$context->providerName = $providerName;
|
||||
$context->videoId = $videoId;
|
||||
|
||||
/* let the commands do the heavy lifting */
|
||||
$status = $chain->execute($context, array(
|
||||
'org_tubepress_impl_embedded_commands_JwFlvCommand',
|
||||
'org_tubepress_impl_embedded_commands_EmbedPlusCommand',
|
||||
'org_tubepress_impl_embedded_commands_YouTubeIframeCommand',
|
||||
'org_tubepress_impl_embedded_commands_VimeoCommand',
|
||||
));
|
||||
|
||||
/* if nobody can handle it, there's really nothing else to do but bail */
|
||||
if ($status === false) {
|
||||
throw new Exception('No commands could produce the embedded HTML');
|
||||
}
|
||||
|
||||
/* pull out the relevant stuff from the context */
|
||||
$template = $context->template;
|
||||
$dataUrl = $context->dataUrl;
|
||||
$implName = $context->embeddedImplementationName;
|
||||
|
||||
$template = $pm->runFilters(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED,
|
||||
$template, $videoId, $providerName, $dataUrl, $implName);
|
||||
|
||||
return $pm->runFilters(org_tubepress_api_const_plugin_FilterPoint::HTML_EMBEDDED,
|
||||
$template->toString(), $videoId, $providerName, $implName);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_plugin_FilterPoint',
|
||||
'org_tubepress_api_plugin_PluginManager',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
));
|
||||
|
||||
/**
|
||||
* Embedded player utilities
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_embedded_EmbeddedPlayerUtils
|
||||
{
|
||||
/**
|
||||
* Returns a valid HTML color.
|
||||
*
|
||||
* @param string $candidate The first-choice HTML color. May be invalid.
|
||||
* @param string $default The fallback HTML color. Must be be invalid.
|
||||
*
|
||||
* @return string $candidate if it's a valid HTML color. $default otherwise.
|
||||
*/
|
||||
public static function getSafeColorValue($candidate, $default)
|
||||
{
|
||||
$pattern = '/^[0-9a-fA-F]{6}$/';
|
||||
if (preg_match($pattern, $candidate) === 1) {
|
||||
return $candidate;
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a boolean value to a string 1 or 0.
|
||||
*
|
||||
* @param boolean $bool The boolean value to convert.
|
||||
*
|
||||
* @return string '1' or '0'
|
||||
*/
|
||||
public static function booleanToOneOrZero($bool)
|
||||
{
|
||||
if ($bool === '1' || $bool === '0') {
|
||||
return $bool;
|
||||
}
|
||||
return $bool ? '1' : '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a boolean value to string.
|
||||
*
|
||||
* @param boolean $bool The boolean value to convert.
|
||||
*
|
||||
* @return string 'true' or 'false'
|
||||
*/
|
||||
public static function booleanToString($bool)
|
||||
{
|
||||
return $bool ? 'true' : 'false';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_template_Variable',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_patterns_cor_Command',
|
||||
'org_tubepress_api_theme_ThemeHandler',
|
||||
'org_tubepress_impl_embedded_EmbeddedPlayerUtils',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
));
|
||||
|
||||
/**
|
||||
* Base class for embedded commands.
|
||||
*/
|
||||
abstract class org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand implements org_tubepress_api_patterns_cor_Command
|
||||
{
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @param array $context An array of context elements (may be empty).
|
||||
*
|
||||
* @return boolean True if this command was able to handle the execution. False otherwise.
|
||||
*/
|
||||
public function execute($context)
|
||||
{
|
||||
global $tubepress_base_url;
|
||||
|
||||
$providerName = $context->providerName;
|
||||
$videoId = $context->videoId;
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$execContext = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
|
||||
if (!$this->_canHandle($providerName, $videoId, $ioc, $execContext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$theme = $ioc->get('org_tubepress_api_theme_ThemeHandler');
|
||||
$template = $theme->getTemplateInstance($this->_getTemplatePath($providerName, $videoId, $ioc, $execContext));
|
||||
|
||||
$context->template = $template;
|
||||
$context->dataUrl = $this->_getEmbeddedDataUrl($providerName, $videoId, $ioc, $execContext);
|
||||
$context->embeddedImplementationName = $this->_getEmbeddedImplName();
|
||||
|
||||
/* signal that we've handled execution */
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract function _getEmbeddedImplName();
|
||||
|
||||
protected abstract function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $execContext);
|
||||
|
||||
protected abstract function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $execContext);
|
||||
|
||||
protected abstract function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $execContext);
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Embedded',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_url_Url',
|
||||
'org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand',
|
||||
));
|
||||
|
||||
/**
|
||||
* Embedded player command for EmbedPlus
|
||||
*/
|
||||
class org_tubepress_impl_embedded_commands_EmbedPlusCommand extends org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand
|
||||
{
|
||||
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return $providerName === org_tubepress_api_provider_Provider::YOUTUBE
|
||||
&& $context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_IMPL) === org_tubepress_api_const_options_values_PlayerImplementationValue::EMBEDPLUS;
|
||||
}
|
||||
|
||||
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return 'embedded_flash/embedplus.tpl.php';
|
||||
}
|
||||
|
||||
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return new org_tubepress_api_url_Url(sprintf('http://www.youtube.com/embed/%s', $videoId));
|
||||
}
|
||||
|
||||
protected function _getEmbeddedImplName()
|
||||
{
|
||||
return org_tubepress_api_const_options_values_PlayerImplementationValue::EMBEDPLUS;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Embedded',
|
||||
'org_tubepress_api_const_options_values_PlayerImplementationValue',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_provider_Provider',
|
||||
'org_tubepress_api_url_Url',
|
||||
'org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand',
|
||||
));
|
||||
|
||||
/**
|
||||
* Embedded player command for the JW FLV player
|
||||
*/
|
||||
class org_tubepress_impl_embedded_commands_JwFlvCommand extends org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand
|
||||
{
|
||||
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return $providerName === org_tubepress_api_provider_Provider::YOUTUBE
|
||||
&& $context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_IMPL) === org_tubepress_api_const_options_values_PlayerImplementationValue::LONGTAIL;
|
||||
}
|
||||
|
||||
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return 'embedded_flash/longtail.tpl.php';
|
||||
}
|
||||
|
||||
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return new org_tubepress_api_url_Url(sprintf('http://www.youtube.com/watch?v=%s', $videoId));
|
||||
}
|
||||
|
||||
protected function _getEmbeddedImplName()
|
||||
{
|
||||
return 'longtail';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Embedded',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_provider_Provider',
|
||||
'org_tubepress_api_url_Url',
|
||||
'org_tubepress_impl_embedded_EmbeddedPlayerUtils',
|
||||
'org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand',
|
||||
));
|
||||
|
||||
/**
|
||||
* Embedded player command for native Vimeo
|
||||
*/
|
||||
class org_tubepress_impl_embedded_commands_VimeoCommand extends org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand
|
||||
{
|
||||
const VIMEO_EMBEDDED_PLAYER_URL = 'http://player.vimeo.com/';
|
||||
const VIMEO_QUERYPARAM_AUTOPLAY = 'autoplay';
|
||||
const VIMEO_QUERYPARAM_TITLE = 'title';
|
||||
const VIMEO_QUERYPARAM_BYLINE = 'byline';
|
||||
const VIMEO_QUERYPARAM_COLOR = 'color';
|
||||
const VIMEO_QUERYPARAM_LOOP = 'loop';
|
||||
const VIMEO_QUERYPARAM_PORTRAIT = 'portrait';
|
||||
|
||||
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return $providerName === org_tubepress_api_provider_Provider::VIMEO;
|
||||
}
|
||||
|
||||
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return 'embedded_flash/vimeo.tpl.php';
|
||||
}
|
||||
|
||||
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
$autoPlay = $context->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY);
|
||||
$color = $context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR);
|
||||
$showInfo = $context->get(org_tubepress_api_const_options_names_Embedded::SHOW_INFO);
|
||||
$loop = $context->get(org_tubepress_api_const_options_names_Embedded::LOOP);
|
||||
|
||||
/* build the data URL based on these options */
|
||||
$link = new org_tubepress_api_url_Url(self::VIMEO_EMBEDDED_PLAYER_URL . "video/$videoId");
|
||||
$link->setQueryVariable(self::VIMEO_QUERYPARAM_AUTOPLAY, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoPlay));
|
||||
$link->setQueryVariable(self::VIMEO_QUERYPARAM_COLOR, $color);
|
||||
$link->setQueryVariable(self::VIMEO_QUERYPARAM_LOOP, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($loop));
|
||||
$link->setQueryVariable(self::VIMEO_QUERYPARAM_TITLE, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
|
||||
$link->setQueryVariable(self::VIMEO_QUERYPARAM_BYLINE, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
|
||||
$link->setQueryVariable(self::VIMEO_QUERYPARAM_PORTRAIT, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected function _getEmbeddedImplName()
|
||||
{
|
||||
return 'vimeo';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Embedded',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_provider_Provider'
|
||||
));
|
||||
|
||||
/**
|
||||
* Embedded player command for YouTube iframe embeds
|
||||
*/
|
||||
class org_tubepress_impl_embedded_commands_YouTubeIframeCommand extends org_tubepress_impl_embedded_commands_AbstractEmbeddedCommand
|
||||
{
|
||||
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return $providerName === org_tubepress_api_provider_Provider::YOUTUBE;
|
||||
}
|
||||
|
||||
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
return "embedded_flash/youtube.tpl.php";
|
||||
}
|
||||
|
||||
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context)
|
||||
{
|
||||
$link = new org_tubepress_api_url_Url('http://www.youtube.com/embed/' . $videoId);
|
||||
|
||||
$showRelated = $context->get(org_tubepress_api_const_options_names_Embedded::SHOW_RELATED);
|
||||
$autoPlay = $context->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY);
|
||||
$loop = $context->get(org_tubepress_api_const_options_names_Embedded::LOOP);
|
||||
$fullscreen = $context->get(org_tubepress_api_const_options_names_Embedded::FULLSCREEN);
|
||||
$playerColor = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR), '999999');
|
||||
$playerHighlight = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_HIGHLIGHT), 'FFFFFF');
|
||||
$showInfo = $context->get(org_tubepress_api_const_options_names_Embedded::SHOW_INFO);
|
||||
|
||||
if (!($playerColor == '999999' && $playerHighlight == 'FFFFFF')) {
|
||||
$link->setQueryVariable('color2', '0x' . $playerColor);
|
||||
$link->setQueryVariable('color1', '0x' . $playerHighlight);
|
||||
}
|
||||
|
||||
$link->setQueryVariable('rel', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showRelated));
|
||||
$link->setQueryVariable('autoplay', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoPlay));
|
||||
$link->setQueryVariable('loop', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($loop));
|
||||
$link->setQueryVariable('fs', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($fullscreen));
|
||||
$link->setQueryVariable('showinfo', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
|
||||
$link->setQueryVariable('wmode', 'transparent');
|
||||
|
||||
if ($context->get(org_tubepress_api_const_options_names_Embedded::HIGH_QUALITY)) {
|
||||
$link->setQueryVariable('hd', '1');
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected function _getEmbeddedImplName()
|
||||
{
|
||||
return 'youtube';
|
||||
}
|
||||
}
|
||||
151
src/wp-content/plugins/tubepress/sys/classes/org/tubepress/impl/env/wordpress/Main.class.php
vendored
Normal file
151
src/wp-content/plugins/tubepress/sys/classes/org/tubepress/impl/env/wordpress/Main.class.php
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Advanced',
|
||||
'org_tubepress_api_const_options_values_ModeValue',
|
||||
'org_tubepress_api_html_HeadHtmlGenerator',
|
||||
'org_tubepress_api_shortcode_ShortcodeHtmlGenerator',
|
||||
'org_tubepress_api_shortcode_ShortcodeParser',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
'org_tubepress_impl_options_WordPressStorageManager',
|
||||
'org_tubepress_impl_util_StringUtils',
|
||||
));
|
||||
|
||||
class org_tubepress_impl_env_wordpress_Main
|
||||
{
|
||||
/**
|
||||
* Filters the WordPress content, looking for TubePress shortcodes and replacing them with galleries/videos.
|
||||
*
|
||||
* @param string $content The WordPress content.
|
||||
*
|
||||
* @return string The modified content.
|
||||
*/
|
||||
public static function contentFilter($content = '')
|
||||
{
|
||||
/* Whip up the IOC service */
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
|
||||
/* do as little work as possible here 'cause we might not even run */
|
||||
$wpsm = $ioc->get('org_tubepress_api_options_StorageManager');
|
||||
$trigger = $wpsm->get(org_tubepress_api_const_options_names_Advanced::KEYWORD);
|
||||
$parser = $ioc->get('org_tubepress_api_shortcode_ShortcodeParser');
|
||||
|
||||
/* no shortcode? get out */
|
||||
if (!$parser->somethingToParse($content, $trigger)) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
return self::_getHtml($content, $trigger, $parser, $ioc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the heavy lifting of generating videos/galleries from content.
|
||||
*
|
||||
* @param string $content The WordPress content.
|
||||
* @param string $trigger The shortcode keyword
|
||||
*
|
||||
* @return string The modified content.
|
||||
*/
|
||||
private static function _getHtml($content, $trigger, $parser, $ioc)
|
||||
{
|
||||
$ms = $ioc->get('org_tubepress_api_message_MessageService');
|
||||
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
$gallery = $ioc->get('org_tubepress_api_shortcode_ShortcodeHtmlGenerator');
|
||||
|
||||
/* Parse each shortcode one at a time */
|
||||
while ($parser->somethingToParse($content, $trigger)) {
|
||||
|
||||
/* Get the HTML for this particular shortcode. Could be a single video or a gallery. */
|
||||
try {
|
||||
$generatedHtml = $gallery->getHtmlForShortcode($content);
|
||||
} catch (Exception $e) {
|
||||
$generatedHtml = $ms->_('no-videos-found');
|
||||
}
|
||||
|
||||
/* remove any leading/trailing <p> tags from the content */
|
||||
$pattern = '/(<[P|p]>\s*)(' . preg_quote($context->getActualShortcodeUsed(), '/') . ')(\s*<\/[P|p]>)/';
|
||||
$content = preg_replace($pattern, '${2}', $content);
|
||||
|
||||
/* replace the shortcode with our new content */
|
||||
$currentShortcode = $context->getActualShortcodeUsed();
|
||||
$content = org_tubepress_impl_util_StringUtils::replaceFirst($currentShortcode, $generatedHtml, $content);
|
||||
|
||||
/* reset the context for the next shortcode */
|
||||
$context->reset();
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress head action hook.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function headAction()
|
||||
{
|
||||
/* no need to print anything in the head of the admin section */
|
||||
if (is_admin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$hh = $ioc->get('org_tubepress_api_html_HeadHtmlGenerator');
|
||||
|
||||
/* this inline JS helps initialize TubePress */
|
||||
$inlineJs = $hh->getHeadInlineJs();
|
||||
|
||||
/* this meta stuff prevents search engines from indexing gallery pages > 1 */
|
||||
$meta = $hh->getHeadHtmlMeta();
|
||||
|
||||
print <<<EOT
|
||||
$inlineJs
|
||||
$meta
|
||||
EOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress init action hook.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function initAction()
|
||||
{
|
||||
/* no need to queue any of this stuff up in the admin section or login page */
|
||||
if (is_admin() || __FILE__ === 'wp-login.php') {
|
||||
return;
|
||||
}
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$fse = $ioc->get('org_tubepress_api_filesystem_Explorer');
|
||||
$baseName = $fse->getTubePressInstallationDirectoryBaseName();
|
||||
|
||||
wp_register_script('tubepress', plugins_url("$baseName/sys/ui/static/js/tubepress.js", $baseName));
|
||||
wp_register_style('tubepress', plugins_url("$baseName/sys/ui/themes/default/style.css", $baseName));
|
||||
|
||||
wp_enqueue_script('jquery');
|
||||
wp_enqueue_script('tubepress');
|
||||
|
||||
wp_enqueue_style('tubepress');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_filesystem_Explorer',
|
||||
'org_tubepress_impl_ioc_FreeWordPressPluginIocService',
|
||||
'org_tubepress_impl_options_FormHandler',
|
||||
));
|
||||
|
||||
class org_tubepress_impl_env_wordpress_OptionsPage
|
||||
{
|
||||
/**
|
||||
* Hook for WordPress init.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function initAction($hook)
|
||||
{
|
||||
/* only run on TubePress settings page */
|
||||
if ($hook !== 'settings_page_tubepress') {
|
||||
return;
|
||||
}
|
||||
|
||||
global $tubepress_base_url;
|
||||
|
||||
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$fs = $iocContainer->get('org_tubepress_api_filesystem_Explorer');
|
||||
$baseName = $fs->getTubePressInstallationDirectoryBaseName();
|
||||
|
||||
wp_register_style('jquery-ui-flick', plugins_url("$baseName/sys/ui/static/css/jquery-ui-flick/jquery-ui-1.7.2.custom.css", $baseName));
|
||||
wp_register_script('jscolor-tubepress', plugins_url("$baseName/sys/ui/static/js/jscolor/jscolor.js", $baseName));
|
||||
wp_enqueue_style('jquery-ui-flick');
|
||||
wp_enqueue_script('jquery-ui-tabs');
|
||||
wp_enqueue_script('jscolor-tubepress');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for WordPress admin menu.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function menuAction()
|
||||
{
|
||||
add_options_page('TubePress Options', 'TubePress', 'manage_options', 'tubepress', array('org_tubepress_impl_env_wordpress_OptionsPage', 'executeOptionsPage'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the TubePress options page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function executeOptionsPage()
|
||||
{
|
||||
/* grab the storage manager */
|
||||
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$wpsm = $iocContainer->get('org_tubepress_api_options_StorageManager');
|
||||
|
||||
/* initialize our options in case we need to */
|
||||
$wpsm->init();
|
||||
|
||||
/* get the form handler */
|
||||
$optionsForm = $iocContainer->get('org_tubepress_impl_options_FormHandler');
|
||||
|
||||
/* are we updating? */
|
||||
if (isset($_POST['tubepress_save'])) {
|
||||
try {
|
||||
$optionsForm->collect($_POST);
|
||||
echo '<div id="message" class="updated fade"><p><strong>Options updated</strong></p></div>';
|
||||
} catch (Exception $error) {
|
||||
echo '<div id="message" class="error fade"><p><strong>' . $error->getMessage() . '</strong></p></div>';
|
||||
}
|
||||
}
|
||||
print $optionsForm->getHtml();
|
||||
}
|
||||
}
|
||||
|
||||
148
src/wp-content/plugins/tubepress/sys/classes/org/tubepress/impl/env/wordpress/Widget.class.php
vendored
Normal file
148
src/wp-content/plugins/tubepress/sys/classes/org/tubepress/impl/env/wordpress/Widget.class.php
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
|
||||
This file is part of TubePress (http://tubepress.org)
|
||||
|
||||
TubePress 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Advanced',
|
||||
'org_tubepress_api_const_options_names_Display',
|
||||
'org_tubepress_api_const_options_names_Meta',
|
||||
'org_tubepress_api_const_options_names_Widget',
|
||||
'org_tubepress_api_const_options_values_PlayerValue',
|
||||
'org_tubepress_api_const_template_Variable',
|
||||
'org_tubepress_api_filesystem_Explorer',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_impl_ioc_FreeWordPressPluginIocService',
|
||||
'org_tubepress_impl_message_WordPressMessageService',
|
||||
));
|
||||
|
||||
class org_tubepress_impl_env_wordpress_Widget
|
||||
{
|
||||
/**
|
||||
* Registers the TubePress widget with WordPress.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function initAction()
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$msg = $ioc->get('org_tubepress_api_message_MessageService');
|
||||
$widgetOps = array('classname' => 'widget_tubepress', 'description' => $msg->_('widget-description'));
|
||||
|
||||
wp_register_sidebar_widget('tubepress', 'TubePress', array('org_tubepress_impl_env_wordpress_Widget', 'printWidget'), $widgetOps);
|
||||
wp_register_widget_control('tubepress', 'TubePress', array('org_tubepress_impl_env_wordpress_Widget', 'printControlPanel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the output of the TubePress widget.
|
||||
*
|
||||
* @param array $opts The array of widget options.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function printWidget($opts)
|
||||
{
|
||||
extract($opts);
|
||||
|
||||
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$context = $iocContainer->get('org_tubepress_api_exec_ExecutionContext');
|
||||
$parser = $iocContainer->get('org_tubepress_api_shortcode_ShortcodeParser');
|
||||
$gallery = $iocContainer->get('org_tubepress_api_shortcode_ShortcodeHtmlGenerator');
|
||||
$ms = $iocContainer->get('org_tubepress_api_message_MessageService');
|
||||
|
||||
/* Turn on logging if we need to */
|
||||
org_tubepress_impl_log_Log::setEnabled($context->get(org_tubepress_api_const_options_names_Advanced::DEBUG_ON), $_GET);
|
||||
|
||||
/* default widget options */
|
||||
$defaultWidgetOptions = array(
|
||||
org_tubepress_api_const_options_names_Display::RESULTS_PER_PAGE => 3,
|
||||
org_tubepress_api_const_options_names_Meta::VIEWS => false,
|
||||
org_tubepress_api_const_options_names_Meta::DESCRIPTION => true,
|
||||
org_tubepress_api_const_options_names_Display::DESC_LIMIT => 50,
|
||||
org_tubepress_api_const_options_names_Display::CURRENT_PLAYER_NAME => org_tubepress_api_const_options_values_PlayerValue::POPUP,
|
||||
org_tubepress_api_const_options_names_Display::THUMB_HEIGHT => 105,
|
||||
org_tubepress_api_const_options_names_Display::THUMB_WIDTH => 135,
|
||||
org_tubepress_api_const_options_names_Display::PAGINATE_ABOVE => false,
|
||||
org_tubepress_api_const_options_names_Display::PAGINATE_BELOW => false,
|
||||
org_tubepress_api_const_options_names_Display::THEME => 'sidebar',
|
||||
org_tubepress_api_const_options_names_Display::FLUID_THUMBS => false
|
||||
);
|
||||
|
||||
/* now apply the user's options */
|
||||
$rawTag = $context->get(org_tubepress_api_const_options_names_Widget::TAGSTRING);
|
||||
$widgetTag = org_tubepress_impl_util_StringUtils::removeNewLines($rawTag);
|
||||
$parser->parse($widgetTag);
|
||||
|
||||
/* calculate the final options */
|
||||
$finalOptions = array_merge($defaultWidgetOptions, $context->getCustomOptions());
|
||||
$context->setCustomOptions($finalOptions);
|
||||
|
||||
if ($context->get(org_tubepress_api_const_options_names_Display::THEME) === '') {
|
||||
$context->set(org_tubepress_api_const_options_names_Display::THEME, 'sidebar');
|
||||
}
|
||||
|
||||
try {
|
||||
$out = $gallery->getHtmlForShortcode('');
|
||||
} catch (Exception $e) {
|
||||
$out = $ms->_('no-videos-found');
|
||||
}
|
||||
|
||||
/* do the standard WordPress widget dance */
|
||||
echo $before_widget . $before_title .
|
||||
$context->get(org_tubepress_api_const_options_names_Widget::TITLE) .
|
||||
$after_title . $out . $after_widget;
|
||||
|
||||
/* reset the context for the next shortcode */
|
||||
$context->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the TubePress widget control panel.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function printControlPanel()
|
||||
{
|
||||
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$wpsm = $iocContainer->get('org_tubepress_api_options_StorageManager');
|
||||
$msg = $iocContainer->get('org_tubepress_api_message_MessageService');
|
||||
$explorer = $iocContainer->get('org_tubepress_api_filesystem_Explorer');
|
||||
$tplBuilder = $iocContainer->get('org_tubepress_api_template_TemplateBuilder');
|
||||
|
||||
/* are we saving? */
|
||||
if (isset($_POST['tubepress-widget-submit'])) {
|
||||
$wpsm->set(org_tubepress_api_const_options_names_Widget::TAGSTRING, strip_tags(stripslashes($_POST['tubepress-widget-tagstring'])));
|
||||
$wpsm->set(org_tubepress_api_const_options_names_Widget::TITLE, strip_tags(stripslashes($_POST['tubepress-widget-title'])));
|
||||
}
|
||||
|
||||
/* load up the gallery template */
|
||||
$templatePath = $explorer->getTubePressBaseInstallationPath() . '/sys/ui/templates/wordpress/widget_controls.tpl.php';
|
||||
$tpl = $tplBuilder->getNewTemplateInstance($templatePath);
|
||||
|
||||
/* set up the template */
|
||||
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_CONTROL_TITLE, $msg->_('options-meta-title-title'));
|
||||
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_TITLE, $wpsm->get(org_tubepress_api_const_options_names_Widget::TITLE));
|
||||
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_CONTROL_SHORTCODE, $msg->_('widget-tagstring-description'));
|
||||
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_SHORTCODE, $wpsm->get(org_tubepress_api_const_options_names_Widget::TAGSTRING));
|
||||
|
||||
/* get the template's output */
|
||||
echo $tpl->toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_environment_Detector'
|
||||
));
|
||||
|
||||
/**
|
||||
* Detects TubePress's environment
|
||||
*/
|
||||
class org_tubepress_impl_environment_SimpleEnvironmentDetector implements org_tubepress_api_environment_Detector
|
||||
{
|
||||
/**
|
||||
* Detects if the user is running TubePress Pro.
|
||||
*
|
||||
* @return boolean True is the user is running TubePress Pro. False otherwise.
|
||||
*/
|
||||
public function isPro()
|
||||
{
|
||||
return is_readable(dirname(__FILE__) . '/../ioc/ProIocService.class.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects if the user is running within WordPress
|
||||
*
|
||||
* @return boolean True is the user is running within WordPress. False otherwise.
|
||||
*/
|
||||
public function isWordPress()
|
||||
{
|
||||
return strpos(realpath(__FILE__), 'wp-content' . DIRECTORY_SEPARATOR . 'plugins') !== false
|
||||
|| function_exists('wp_cron');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_options_OptionValidator',
|
||||
'org_tubepress_api_options_StorageManager',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
'org_tubepress_impl_options_OptionsReference',
|
||||
));
|
||||
|
||||
/**
|
||||
* Holds the current options for TubePress. This is the default options,
|
||||
* usually in persistent storage somewhere, and custom options parsed
|
||||
* from a shortcode
|
||||
*/
|
||||
class org_tubepress_impl_exec_MemoryExecutionContext implements org_tubepress_api_exec_ExecutionContext
|
||||
{
|
||||
private $_customOptions = array();
|
||||
private $_shortcode;
|
||||
private $_tpsm;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$this->_tpsm = $ioc->get('org_tubepress_api_options_StorageManager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the context.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->_customOptions = array();
|
||||
$this->_shortcode = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of an option
|
||||
*
|
||||
* @param string $optionName The name of the option
|
||||
*
|
||||
* @return unknown The option value
|
||||
*/
|
||||
public function get($optionName)
|
||||
{
|
||||
/* get the value, either from the shortcode or the db */
|
||||
if (array_key_exists($optionName, $this->_customOptions)) {
|
||||
return $this->_customOptions[$optionName];
|
||||
}
|
||||
return $this->_tpsm->get($optionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of an option
|
||||
*
|
||||
* @param string $optionName The name of the option
|
||||
* @param unknown $optionValue The option value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($optionName, $optionValue)
|
||||
{
|
||||
$this->_customOptions[$optionName] = $optionValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the options that differ from the default options.
|
||||
*
|
||||
* @param array $customOpts The custom options.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomOptions($customOpts)
|
||||
{
|
||||
$this->_customOptions = $customOpts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the options that differ from the default options.
|
||||
*
|
||||
* @return array The options that differ from the default options.
|
||||
*/
|
||||
public function getCustomOptions()
|
||||
{
|
||||
return $this->_customOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current shortcode.
|
||||
*
|
||||
* @param string $newTagString The current shortcode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setActualShortcodeUsed($newTagString)
|
||||
{
|
||||
$this->_shortcode = $newTagString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current shortcode
|
||||
*
|
||||
* @return string The current shortcode
|
||||
*/
|
||||
public function getActualShortcodeUsed()
|
||||
{
|
||||
return $this->_shortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconstruct the current state of this execution context as a shortcode string.
|
||||
*
|
||||
* @return string This context as a shortcode string.
|
||||
*/
|
||||
public function toShortcode()
|
||||
{
|
||||
$trigger = $this->get(org_tubepress_api_const_options_names_Advanced::KEYWORD);
|
||||
$optPairs = array();
|
||||
|
||||
foreach ($this->_customOptions as $name => $value) {
|
||||
$optPairs[] = $name . '="' . $value . '"';
|
||||
}
|
||||
|
||||
$optString = implode($optPairs, ', ');
|
||||
|
||||
return "[$trigger $optString]";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_plugin_FilterPoint',
|
||||
'org_tubepress_api_factory_VideoFactory',
|
||||
'org_tubepress_api_patterns_cor_Chain',
|
||||
'org_tubepress_api_plugin_PluginManager',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
));
|
||||
|
||||
/**
|
||||
* Video factory that sends the feed to the right video factory based on the provider
|
||||
*/
|
||||
class org_tubepress_impl_factory_VideoFactoryChain implements org_tubepress_api_factory_VideoFactory
|
||||
{
|
||||
/**
|
||||
* Converts raw video feeds to TubePress videos
|
||||
*
|
||||
* @param unknown $feed The raw feed result from the video provider
|
||||
*
|
||||
* @return array an array of TubePress videos generated from the feed
|
||||
*/
|
||||
public function feedToVideoArray($feed)
|
||||
{
|
||||
try {
|
||||
|
||||
return $this->_wrappedFeedToVideoArray($feed);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
org_tubepress_impl_log_Log::log('Delegating video factory', 'Caught exception building videos: ' . $e->getMessage());
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the video factory command class names.
|
||||
*
|
||||
* @return array The video factory command class names.
|
||||
*/
|
||||
protected function getArrayOfCommandNames()
|
||||
{
|
||||
return array(
|
||||
'org_tubepress_impl_factory_commands_YouTubeFactoryCommand',
|
||||
'org_tubepress_impl_factory_commands_VimeoFactoryCommand'
|
||||
);
|
||||
}
|
||||
|
||||
private function _wrappedFeedToVideoArray($feed)
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$chain = $ioc->get('org_tubepress_api_patterns_cor_Chain');
|
||||
$pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
|
||||
$pc = $ioc->get('org_tubepress_api_provider_ProviderCalculator');
|
||||
$providerName = $pc->calculateCurrentVideoProvider();
|
||||
$context = $chain->createContextInstance();
|
||||
|
||||
$context->feed = $feed;
|
||||
|
||||
/* let the commands do the heavy lifting */
|
||||
$status = $chain->execute($context, $this->getArrayOfCommandNames());
|
||||
|
||||
if ($status === false) {
|
||||
throw new Exception('No command could build the videos');
|
||||
}
|
||||
|
||||
$videos = $context->returnValue;
|
||||
|
||||
if ($pm->hasFilters(org_tubepress_api_const_plugin_FilterPoint::VIDEO)) {
|
||||
|
||||
for ($x = 0; $x < count($videos); $x++) {
|
||||
|
||||
$videos[$x] = $pm->runFilters(org_tubepress_api_const_plugin_FilterPoint::VIDEO, $videos[$x], $providerName);
|
||||
}
|
||||
}
|
||||
|
||||
return $videos;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Advanced',
|
||||
'org_tubepress_api_const_options_names_Display',
|
||||
'org_tubepress_api_patterns_cor_Command',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_video_Video',
|
||||
'org_tubepress_impl_log_Log',
|
||||
'org_tubepress_impl_util_TimeUtils'
|
||||
));
|
||||
|
||||
/**
|
||||
* Base class for factory commands.
|
||||
*/
|
||||
abstract class org_tubepress_impl_factory_commands_AbstractFactoryCommand implements org_tubepress_api_patterns_cor_Command
|
||||
{
|
||||
const LOG_PREFIX = 'Abstract Factory Command';
|
||||
|
||||
private $_context;
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @param array $context An array of context elements (may be empty).
|
||||
*
|
||||
* @return boolean True if this command was able to handle the execution. False otherwise.
|
||||
*/
|
||||
function execute($context)
|
||||
{
|
||||
/* grab the arguments */
|
||||
$feed = $context->feed;
|
||||
|
||||
if (!$this->_canHandleFeed($feed)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* give the command a chance to do some initial processing */
|
||||
$this->_preExecute($feed);
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$this->_context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
|
||||
$results = array();
|
||||
$index = 0;
|
||||
$total = $this->_countVideosInFeed($feed);
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Now building %d video(s) from raw feed', $total);
|
||||
|
||||
for ($index = 0; $index < $total; $index++) {
|
||||
|
||||
if (!$this->_canHandleVideo($index)) {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Skipping video at index %d', $index);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* build the video */
|
||||
$results[] = $this->_buildVideo($index);
|
||||
}
|
||||
|
||||
/* give the command a chance to do some post processing */
|
||||
$this->_postExecute($feed);
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Built %d video(s) from raw feed', sizeof($results));
|
||||
|
||||
$context->returnValue = $results;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely attempts to unserialize serialized PHP.
|
||||
*
|
||||
* @param unknown_type $raw The item to attempt to unserialize.
|
||||
* @throws Exception If the item cannot be unserialized.
|
||||
*
|
||||
* @return unknown_type The unserialized PHP.
|
||||
*/
|
||||
protected static function _unserializePhpFeed($raw)
|
||||
{
|
||||
$result = false;
|
||||
|
||||
if (is_string($raw) && trim($raw) != '' && preg_match("/^(i|s|a|o|d):(.*);/si",$raw) > 0) {
|
||||
$result = unserialize($raw);
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
throw new Exception(sprintf('Unable to unserialize PHP from feed'));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected abstract function _preExecute($feed);
|
||||
protected abstract function _postExecute($feed);
|
||||
protected abstract function _countVideosInFeed($feed);
|
||||
protected abstract function _canHandleVideo($index);
|
||||
protected abstract function _getAuthorDisplayName($index);
|
||||
protected abstract function _getAuthorUid($index);
|
||||
protected abstract function _getCategory($index);
|
||||
protected abstract function _getRawCommentCount($index);
|
||||
protected abstract function _getDescription($index);
|
||||
protected abstract function _getDurationInSeconds($index);
|
||||
protected abstract function _getHomeUrl($index);
|
||||
protected abstract function _getId($index);
|
||||
protected abstract function _getKeywordsArray($index);
|
||||
protected abstract function _getRawLikeCount($index);
|
||||
protected abstract function _getRatingAverage($index);
|
||||
protected abstract function _getRawRatingCount($index);
|
||||
protected abstract function _getThumbnailUrlsArray($index);
|
||||
protected abstract function _getTimeLastUpdatedInUnixTime($index);
|
||||
protected abstract function _getTimePublishedInUnixTime($index);
|
||||
protected abstract function _getTitle($index);
|
||||
protected abstract function _getRawViewCount($index);
|
||||
|
||||
protected function _pickThumbnailUrl($urls)
|
||||
{
|
||||
if (!is_array($urls) || sizeof($urls) == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$random = $this->_context->get(org_tubepress_api_const_options_names_Display::RANDOM_THUMBS);
|
||||
if ($random) {
|
||||
return $urls[array_rand($urls)];
|
||||
} else {
|
||||
return $urls[1]; // Rodax
|
||||
}
|
||||
}
|
||||
|
||||
private function _buildVideo($index)
|
||||
{
|
||||
/* collect the pieces of the video */
|
||||
$authorDisplayName = $this->_getAuthorDisplayName($index);
|
||||
$authorUid = $this->_getAuthorUid($index);
|
||||
$category = $this->_getCategory($index);
|
||||
$commentCount = self::_fancyNumber($this->_getRawCommentCount($index));
|
||||
$description = $this->_trimDescription($this->_getDescription($index));
|
||||
$duration = org_tubepress_impl_util_TimeUtils::secondsToHumanTime($this->_getDurationInSeconds($index));
|
||||
$homeUrl = $this->_getHomeUrl($index);
|
||||
$id = $this->_getId($index);
|
||||
$keywordsArray = $this->_getKeywordsArray($index);
|
||||
$likesCount = self::_fancyNumber($this->_getRawLikeCount($index));
|
||||
$ratingAverage = $this->_getRatingAverage($index);
|
||||
$ratingCount = self::_fancyNumber($this->_getRawRatingCount($index));
|
||||
$thumbUrl = $this->_pickThumbnailUrl($this->_getThumbnailUrlsArray($index));
|
||||
$timeLastUpdated = $this->_fancyTime($this->_getTimeLastUpdatedInUnixTime($index));
|
||||
$timePublished = $this->_fancyTime($this->_getTimePublishedInUnixTime($index));
|
||||
$title = $this->_getTitle($index);
|
||||
$viewCount = self::_fancyNumber($this->_getRawViewCount($index));
|
||||
|
||||
/* now build a video out of them */
|
||||
$vid = new org_tubepress_api_video_Video();
|
||||
|
||||
$vid->setAuthorDisplayName($authorDisplayName);
|
||||
$vid->setAuthorUid($authorUid);
|
||||
$vid->setCategory($category);
|
||||
$vid->setCommentCount($commentCount);
|
||||
$vid->setDescription($description);
|
||||
$vid->setDuration($duration);
|
||||
$vid->setHomeUrl($homeUrl);
|
||||
$vid->setId($id);
|
||||
$vid->setKeywords($keywordsArray);
|
||||
$vid->setLikesCount($likesCount);
|
||||
$vid->setRatingAverage($ratingAverage);
|
||||
$vid->setRatingCount($ratingCount);
|
||||
$vid->setThumbnailUrl($thumbUrl);
|
||||
$vid->setTimeLastUpdated($timeLastUpdated);
|
||||
$vid->setTimePublished($timePublished);
|
||||
$vid->setTitle($title);
|
||||
$vid->setViewCount($viewCount);
|
||||
|
||||
return $vid;
|
||||
}
|
||||
|
||||
private static function _fancyNumber($num)
|
||||
{
|
||||
if (!is_numeric($num)) {
|
||||
return 'N/A';
|
||||
}
|
||||
return number_format($num);
|
||||
}
|
||||
|
||||
private function _fancyTime($unixTime)
|
||||
{
|
||||
if ($unixTime == '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->_context->get(org_tubepress_api_const_options_names_Display::RELATIVE_DATES)) {
|
||||
return org_tubepress_impl_util_TimeUtils::getRelativeTime($unixTime);
|
||||
}
|
||||
return date($this->_context->get(org_tubepress_api_const_options_names_Advanced::DATEFORMAT), $unixTime);
|
||||
}
|
||||
|
||||
private function _trimDescription($description)
|
||||
{
|
||||
$limit = $this->_context->get(org_tubepress_api_const_options_names_Display::DESC_LIMIT);
|
||||
|
||||
if ($limit > 0 && strlen($description) > $limit) {
|
||||
$description = substr($description, 0, $limit) . '...';
|
||||
}
|
||||
return $description;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_plugin_FilterPoint',
|
||||
'org_tubepress_impl_factory_commands_AbstractFactoryCommand'
|
||||
));
|
||||
|
||||
/**
|
||||
* Video factory for Vimeo
|
||||
*/
|
||||
class org_tubepress_impl_factory_commands_VimeoFactoryCommand extends org_tubepress_impl_factory_commands_AbstractFactoryCommand
|
||||
{
|
||||
const LOG_PREFIX = 'Vimeo Factory Command';
|
||||
|
||||
protected $_videoArray;
|
||||
|
||||
protected function _canHandleFeed($feed)
|
||||
{
|
||||
try {
|
||||
|
||||
$unserialized = org_tubepress_impl_factory_commands_AbstractFactoryCommand::_unserializePhpFeed($feed);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $unserialized->stat === 'ok';
|
||||
}
|
||||
|
||||
protected function _preExecute($feed)
|
||||
{
|
||||
$unserialized = org_tubepress_impl_factory_commands_AbstractFactoryCommand::_unserializePhpFeed($feed);
|
||||
|
||||
if (isset($unserialized->video)) {
|
||||
$this->_videoArray = $unserialized->video;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($unserialized->videos) && isset($unserialized->videos->video)) {
|
||||
$this->_videoArray = $unserialized->videos->video;
|
||||
return;
|
||||
}
|
||||
$this->_videoArray = array();
|
||||
}
|
||||
|
||||
protected function _postExecute($feed)
|
||||
{
|
||||
unset($this->_videoArray);
|
||||
}
|
||||
|
||||
protected function _countVideosInFeed($feed)
|
||||
{
|
||||
return sizeof($this->_videoArray);
|
||||
}
|
||||
|
||||
protected function _getAuthorDisplayName($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->owner->display_name;
|
||||
}
|
||||
|
||||
protected function _getAuthorUid($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->owner->username;
|
||||
}
|
||||
|
||||
protected function _getCategory($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getRawCommentCount($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getDescription($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->description;
|
||||
}
|
||||
|
||||
protected function _getDurationInSeconds($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->duration;
|
||||
}
|
||||
|
||||
protected function _getHomeUrl($index)
|
||||
{
|
||||
return 'http://vimeo.com/' . $this->_videoArray[$index]->id;
|
||||
}
|
||||
|
||||
protected function _getId($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->id;
|
||||
}
|
||||
|
||||
protected function _getKeywordsArray($index)
|
||||
{
|
||||
return self::_gatherArrayOfContent($this->_videoArray[$index], 'tags', 'tag');
|
||||
}
|
||||
|
||||
protected function _getRawLikeCount($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->number_of_likes;
|
||||
}
|
||||
|
||||
protected function _getRatingAverage($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getRawRatingCount($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getThumbnailUrlsArray($index)
|
||||
{
|
||||
$raw = self::_gatherArrayOfContent($this->_videoArray[$index], 'thumbnails', 'thumbnail');
|
||||
return array($raw[0]);
|
||||
}
|
||||
|
||||
protected function _getTimeLastUpdatedInUnixTime($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getTimePublishedInUnixTime($index)
|
||||
{
|
||||
return strtotime($this->_videoArray[$index]->upload_date);
|
||||
}
|
||||
|
||||
protected function _getTitle($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->title;
|
||||
}
|
||||
|
||||
protected function _getRawViewCount($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->number_of_plays;
|
||||
}
|
||||
|
||||
protected function _canHandleVideo($index)
|
||||
{
|
||||
return $this->_videoArray[$index]->embed_privacy !== 'nowhere';
|
||||
}
|
||||
|
||||
protected static function _gatherArrayOfContent($node, $firstDimension, $secondDimension)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (isset($node->$firstDimension) && is_array($node->$firstDimension->$secondDimension)) {
|
||||
foreach ($node->$firstDimension->$secondDimension as $item) {
|
||||
$results[] = $item->_content;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_patterns_cor_Command',
|
||||
'org_tubepress_api_const_plugin_FilterPoint',
|
||||
'org_tubepress_api_url_Url',
|
||||
'org_tubepress_api_video_Video',
|
||||
'org_tubepress_impl_factory_commands_AbstractFactoryCommand',
|
||||
));
|
||||
|
||||
/**
|
||||
* Video factory for YouTube
|
||||
*/
|
||||
class org_tubepress_impl_factory_commands_YouTubeFactoryCommand extends org_tubepress_impl_factory_commands_AbstractFactoryCommand
|
||||
{
|
||||
/* shorthands for the namespaces */
|
||||
const NS_APP = 'http://www.w3.org/2007/app';
|
||||
const NS_ATOM = 'http://www.w3.org/2005/Atom';
|
||||
const NS_MEDIA = 'http://search.yahoo.com/mrss/';
|
||||
const NS_YT = 'http://gdata.youtube.com/schemas/2007';
|
||||
const NS_GD = 'http://schemas.google.com/g/2005';
|
||||
|
||||
const LOG_PREFIX = 'YouTube Video Factory';
|
||||
|
||||
private $_xpath;
|
||||
|
||||
protected function _canHandleFeed($feed)
|
||||
{
|
||||
return is_string($feed) && strpos($feed, "http://gdata.youtube.com/schemas/2007") !== false;
|
||||
}
|
||||
|
||||
protected function getXpath()
|
||||
{
|
||||
return $this->_xpath;
|
||||
}
|
||||
|
||||
protected function _preExecute($feed)
|
||||
{
|
||||
$this->_xpath = $this->_createXPath($this->_createDomDocument($feed));
|
||||
}
|
||||
|
||||
protected function _postExecute($feed)
|
||||
{
|
||||
unset($this->_xpath);
|
||||
}
|
||||
|
||||
protected function _countVideosInFeed($feed)
|
||||
{
|
||||
return $this->_xpath->query('//atom:entry')->length;
|
||||
}
|
||||
|
||||
protected function _canHandleVideo($index)
|
||||
{
|
||||
$states = $this->_relativeQuery($index, 'app:control/yt:state');
|
||||
|
||||
/* no state applied? we're good to go */
|
||||
if ($states->length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* if state is other than limitedSyndication, it's not available */
|
||||
return $this->_relativeQuery($index, "app:control/yt:state[@reasonCode='limitedSyndication']")->length !== 0;
|
||||
}
|
||||
|
||||
protected function _getAuthorDisplayName($index)
|
||||
{
|
||||
return $this->_getAuthorUid($index);
|
||||
}
|
||||
|
||||
protected function _getAuthorUid($index)
|
||||
{
|
||||
return $this->_relativeQuery($index, 'atom:author/atom:name')->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
protected function _getCategory($index)
|
||||
{
|
||||
return trim($this->_relativeQuery($index, 'media:group/media:category')->item(0)->getAttribute('label'));
|
||||
}
|
||||
|
||||
protected function _getRawCommentCount($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getDescription($index)
|
||||
{
|
||||
return $this->_relativeQuery($index, 'media:group/media:description')->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
protected function _getDurationInSeconds($index)
|
||||
{
|
||||
return $this->_relativeQuery($index, 'media:group/yt:duration')->item(0)->getAttribute('seconds');
|
||||
}
|
||||
|
||||
protected function _getHomeUrl($index)
|
||||
{
|
||||
$rawUrl = $this->_relativeQuery($index, "atom:link[@rel='alternate']")->item(0)->getAttribute('href');
|
||||
$url = new org_tubepress_api_url_Url($rawUrl);
|
||||
|
||||
return $url->toString(true);
|
||||
}
|
||||
|
||||
protected function _getId($index)
|
||||
{
|
||||
$link = $this->_relativeQuery($index, "atom:link[@type='text/html']")->item(0);
|
||||
$matches = array();
|
||||
preg_match('/.*v=(.{11}).*/', $link->getAttribute('href'), $matches);
|
||||
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
protected function _getKeywordsArray($index)
|
||||
{
|
||||
$rawKeywords = $this->_relativeQuery($index, 'media:group/media:keywords')->item(0);
|
||||
$raw = trim($rawKeywords->nodeValue);
|
||||
|
||||
return explode(", ", $raw);
|
||||
}
|
||||
|
||||
protected function _getRawLikeCount($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getRatingAverage($index)
|
||||
{
|
||||
$count = $this->_relativeQuery($index, 'gd:rating')->item(0);
|
||||
if ($count != null) {
|
||||
return number_format($count->getAttribute('average'), 2);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getRawRatingCount($index)
|
||||
{
|
||||
$count = $this->_relativeQuery($index, 'gd:rating')->item(0);
|
||||
if ($count != null) {
|
||||
return $count->getAttribute('numRaters');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getThumbnailUrlsArray($index)
|
||||
{
|
||||
$thumbs = $this->_relativeQuery($index, 'media:group/media:thumbnail');
|
||||
$result = array();
|
||||
|
||||
foreach ($thumbs as $thumb) {
|
||||
//if (strpos($thumb->getAttribute('url'), 'hqdefault') === false) { // Rodax
|
||||
$result[] = $thumb->getAttribute('url');
|
||||
//} // Rodax
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function _getTimeLastUpdatedInUnixTime($index)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _getTimePublishedInUnixTime($index)
|
||||
{
|
||||
$publishedNode = $this->_relativeQuery($index, 'atom:published');
|
||||
if ($publishedNode->length == 0) {
|
||||
return '';
|
||||
}
|
||||
$rawTime = $publishedNode->item(0)->nodeValue;
|
||||
return org_tubepress_impl_util_TimeUtils::rfc3339toUnixTime($rawTime);
|
||||
}
|
||||
|
||||
protected function _getTitle($index)
|
||||
{
|
||||
return $this->_relativeQuery($index, 'atom:title')->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
protected function _getRawViewCount($index)
|
||||
{
|
||||
$stats = $this->_relativeQuery($index, 'yt:statistics')->item(0);
|
||||
if ($stats != null) {
|
||||
return $stats->getAttribute('viewCount');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _relativeQuery($index, $query)
|
||||
{
|
||||
return $this->_xpath->query('//atom:entry[' . ($index + 1) . "]/$query");
|
||||
}
|
||||
|
||||
private function _createXPath(DOMDocument $doc)
|
||||
{
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Building xpath to parse XML');
|
||||
|
||||
if (!class_exists('DOMXPath')) {
|
||||
throw new Exception('Class DOMXPath not found');
|
||||
}
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath->registerNamespace('atom', self::NS_ATOM);
|
||||
$xpath->registerNamespace('yt', self::NS_YT);
|
||||
$xpath->registerNamespace('gd', self::NS_GD);
|
||||
$xpath->registerNamespace('media', self::NS_MEDIA);
|
||||
$xpath->registerNamespace('app', self::NS_APP);
|
||||
return $xpath;
|
||||
}
|
||||
|
||||
private function _createDomDocument($feed)
|
||||
{
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Attempting to load XML from YouTube');
|
||||
|
||||
if (!class_exists('DOMDocument')) {
|
||||
throw new Exception('DOMDocument class not found');
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
if ($doc->loadXML($feed) === false) {
|
||||
throw new Exception('Could not parse XML from YouTube');
|
||||
}
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Successfully loaded XML from YouTube');
|
||||
return $doc;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_cache_Cache',
|
||||
'org_tubepress_api_feed_FeedFetcher',
|
||||
'org_tubepress_api_http_HttpClient',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
'org_tubepress_impl_log_Log',
|
||||
));
|
||||
|
||||
/**
|
||||
* Base functionality for feed retrieval services.
|
||||
*/
|
||||
class org_tubepress_impl_feed_CacheAwareFeedFetcher implements org_tubepress_api_feed_FeedFetcher
|
||||
{
|
||||
const LOG_PREFIX = 'Cache Aware Feed Fetcher';
|
||||
|
||||
/**
|
||||
* Fetches the feed from a remote provider
|
||||
*
|
||||
* @param string $url The URL to fetch.
|
||||
* @param boolean $useCache Whether or not to use the network cache.
|
||||
*
|
||||
* @return unknown The raw feed from the provider
|
||||
*/
|
||||
public function fetch($url, $useCache)
|
||||
{
|
||||
global $tubepress_base_url;
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$cache = $ioc->get('org_tubepress_api_cache_Cache');
|
||||
|
||||
$result = '';
|
||||
if ($useCache) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'First asking cache for <a href="%s">%s</a>', $url, $url);
|
||||
|
||||
$result = $cache->get($url);
|
||||
if ($result !== false) {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Cache has <a href="%s">%s</a>. Sweet.', $url, $url);
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Cache does not have <a href="%s">%s</a>. We\'ll have to get it from the network.', $url, $url);
|
||||
$result = $this->_getFromNetwork($url, $ioc);
|
||||
$cache->save($url, $result);
|
||||
}
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Skip cache check for <a href="%s">%s</a>', $url, $url);
|
||||
$result = $this->_getFromNetwork($url, $ioc);
|
||||
}
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Raw result for <a href="%s">%s</a> is in the HTML source for this page. <span style="display:none">%s</span>', $url, $url, htmlspecialchars($result));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function _getFromNetwork($url, $ioc)
|
||||
{
|
||||
$client = $ioc->get('org_tubepress_api_http_HttpClient');
|
||||
return $client->get($url);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_feed_FeedInspector',
|
||||
'org_tubepress_api_patterns_cor_Chain',
|
||||
'org_tubepress_api_provider_ProviderCalculator',
|
||||
'org_tubepress_api_provider_ProviderResult',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
'org_tubepress_impl_feed_FeedInspectorChainContext',
|
||||
));
|
||||
|
||||
/**
|
||||
* Sends the feed to the right inspection service based on the provider.
|
||||
*/
|
||||
class org_tubepress_impl_feed_FeedInspectorChain implements org_tubepress_api_feed_FeedInspector
|
||||
{
|
||||
/**
|
||||
* Count the total videos in this feed result.
|
||||
*
|
||||
* @param unknown $rawFeed The raw video feed (varies depending on provider)
|
||||
*
|
||||
* @return int The total result count of this query, or 0 if there was a problem.
|
||||
*/
|
||||
public function getTotalResultCount($rawFeed)
|
||||
{
|
||||
try {
|
||||
|
||||
return $this->_wrappedCount($rawFeed);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
org_tubepress_impl_log_Log::log('Delegating Feed Inspector', 'Caught exception while counting: ' . $e->getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private function _wrappedCount($rawFeed)
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$pc = $ioc->get('org_tubepress_api_provider_ProviderCalculator');
|
||||
$chain = $ioc->get('org_tubepress_api_patterns_cor_Chain');
|
||||
$providerName = $pc->calculateCurrentVideoProvider();
|
||||
$context = $chain->createContextInstance();
|
||||
|
||||
$context->providerName = $providerName;
|
||||
$context->rawFeed = $rawFeed;
|
||||
|
||||
/* let the commands do the heavy lifting */
|
||||
$status = $chain->execute($context, array(
|
||||
'org_tubepress_impl_feed_commands_YouTubeFeedInspectionCommand',
|
||||
'org_tubepress_impl_feed_commands_VimeoFeedInspectionCommand'
|
||||
));
|
||||
|
||||
if ($status === false) {
|
||||
throw new Exception('No commands could inspect the feed');
|
||||
}
|
||||
|
||||
return $context->returnValue;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_patterns_cor_Command'
|
||||
));
|
||||
|
||||
/**
|
||||
* Base functionality for feed inspection.
|
||||
*/
|
||||
abstract class org_tubepress_impl_feed_commands_AbstractFeedInspectionCommand implements org_tubepress_api_patterns_cor_Command
|
||||
{
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @param array $context An array of context elements (may be empty).
|
||||
*
|
||||
* @return boolean True if this command was able to handle the execution. False otherwise.
|
||||
*/
|
||||
public function execute($context)
|
||||
{
|
||||
if ($context->providerName !== $this->_getNameOfHandledProvider()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$context->returnValue = $this->_count($context->rawFeed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract function _getNameOfHandledProvider();
|
||||
|
||||
protected abstract function _count($rawFeed);
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_feed_commands_AbstractFeedInspectionCommand'
|
||||
));
|
||||
|
||||
/**
|
||||
* Examines the feed from Vimeo
|
||||
*/
|
||||
class org_tubepress_impl_feed_commands_VimeoFeedInspectionCommand extends org_tubepress_impl_feed_commands_AbstractFeedInspectionCommand
|
||||
{
|
||||
protected function _getNameOfHandledProvider()
|
||||
{
|
||||
return org_tubepress_api_provider_Provider::VIMEO;
|
||||
}
|
||||
|
||||
protected function _count($rawFeed)
|
||||
{
|
||||
$feed = @unserialize($rawFeed);
|
||||
|
||||
return isset($feed->videos->total) ? $feed->videos->total : 0;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_feed_commands_AbstractFeedInspectionCommand'
|
||||
));
|
||||
|
||||
/**
|
||||
* Examines the feed from YouTube
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_feed_commands_YouTubeFeedInspectionCommand extends org_tubepress_impl_feed_commands_AbstractFeedInspectionCommand
|
||||
{
|
||||
const NS_OPENSEARCH = 'http://a9.com/-/spec/opensearch/1.1/';
|
||||
|
||||
protected function _count($rawFeed)
|
||||
{
|
||||
$dom = $this->_getDom($rawFeed);
|
||||
$totalResults = $dom->getElementsByTagNameNS(self::NS_OPENSEARCH, 'totalResults')->item(0)->nodeValue;
|
||||
|
||||
self::_makeSureNumeric($totalResults);
|
||||
|
||||
return $totalResults;
|
||||
}
|
||||
|
||||
protected function _getNameOfHandledProvider()
|
||||
{
|
||||
return org_tubepress_api_provider_Provider::YOUTUBE;
|
||||
}
|
||||
|
||||
private function _getDom($rawFeed)
|
||||
{
|
||||
if (!class_exists('DOMDocument')) {
|
||||
throw new Exception('DOMDocument class not found');
|
||||
}
|
||||
$dom = new DOMDocument();
|
||||
if ($dom->loadXML($rawFeed) === false) {
|
||||
throw new Exception('Problem parsing XML from YouTube');
|
||||
}
|
||||
return $dom;
|
||||
}
|
||||
|
||||
private static function _makeSureNumeric($result)
|
||||
{
|
||||
if (is_numeric($result) === false) {
|
||||
throw new Exception("YouTube returned a non-numeric result count: $result");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,297 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_filesystem_Explorer',
|
||||
'org_tubepress_impl_log_Log',
|
||||
));
|
||||
|
||||
/**
|
||||
* Some filesystem utilities
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_filesystem_FsExplorer implements org_tubepress_api_filesystem_Explorer
|
||||
{
|
||||
const LOG_PREFIX = 'FS Explorer';
|
||||
|
||||
/**
|
||||
* Finds the absolute path of the TubePress installation on the filesystem.
|
||||
*
|
||||
* @return string The absolute filesystem path of this TubePress installation.
|
||||
*/
|
||||
public function getTubePressBaseInstallationPath()
|
||||
{
|
||||
return realpath(dirname(__FILE__) . '/../../../../../../');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the directory name of the TubePress base installation.
|
||||
*
|
||||
* @return string The base name of the TubePress installation directory.
|
||||
*/
|
||||
function getTubePressInstallationDirectoryBaseName()
|
||||
{
|
||||
return basename($this->getTubePressBaseInstallationPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the directories contained in the given directory (non-recursive).
|
||||
*
|
||||
* @param string $dir The absolute filesystem path of the directory to examine.
|
||||
* @param string $prefix The logging prefix.
|
||||
*
|
||||
* @return array The names of the directories in the given directory (non-recursive).
|
||||
*/
|
||||
public function getDirectoriesInDirectory($dir, $prefix)
|
||||
{
|
||||
$realDir = $dir;
|
||||
|
||||
if (!is_dir($dir)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log($prefix, '<tt>%s</tt> is not a directory', $realDir);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
$toReturn = array();
|
||||
if ($handle = opendir($dir)) {
|
||||
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
|
||||
if ($file === '.' || $file === '..' || strpos($file, ".") === 0) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
array_push($toReturn, realpath($dir . DIRECTORY_SEPARATOR . $file));
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
|
||||
} else {
|
||||
|
||||
org_tubepress_impl_log_Log::log($prefix, 'Could not open <tt>%s</tt>', $realDir);
|
||||
}
|
||||
|
||||
return $toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the files contained in the given directory (non-recursive).
|
||||
*
|
||||
* @param string $dir The absolute filesystem path of the directory to examine.
|
||||
* @param string $prefix The logging prefix.
|
||||
*
|
||||
* @return array The names of the files in the given directory (non-recursive).
|
||||
*/
|
||||
public function getFilenamesInDirectory($dir, $prefix)
|
||||
{
|
||||
$realDir = $dir;
|
||||
|
||||
if (!is_dir($dir)) {
|
||||
org_tubepress_impl_log_Log::log($prefix, '<tt>%s</tt> is not a directory', $realDir);
|
||||
return array();
|
||||
}
|
||||
|
||||
$toReturn = array();
|
||||
if ($handle = opendir($dir)) {
|
||||
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
|
||||
if ($file === '.' || $file === '..') {
|
||||
continue;
|
||||
}
|
||||
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
array_push($toReturn, realpath($dir . DIRECTORY_SEPARATOR . $file));
|
||||
}
|
||||
closedir($handle);
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log($prefix, 'Could not open <tt>%s</tt>', $realDir);
|
||||
}
|
||||
return $toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get temporary directory.
|
||||
*
|
||||
* @return string The absolute path of a temporary directory, preferably the system directory.
|
||||
*/
|
||||
public function getSystemTempDirectory()
|
||||
{
|
||||
if (function_exists('sys_get_temp_dir')) {
|
||||
return sys_get_temp_dir();
|
||||
}
|
||||
|
||||
// Try to get from environment variable
|
||||
if (!empty($_ENV['TMP'])) {
|
||||
return realpath($_ENV['TMP']);
|
||||
} else if (!empty($_ENV['TMPDIR'])) {
|
||||
return realpath($_ENV['TMPDIR']);
|
||||
} else if (!empty($_ENV['TEMP'])) {
|
||||
return realpath($_ENV['TEMP']);
|
||||
} else {
|
||||
// Detect by creating a temporary file
|
||||
// Try to use system's temporary directory
|
||||
// as random name shouldn't exist
|
||||
$tempfile = @tempnam(md5(uniqid(rand(), true)), '');
|
||||
if ( $tempfile ) {
|
||||
$tempdir = realpath(dirname($tempfile));
|
||||
@unlink($tempfile);
|
||||
return $tempdir;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function copyDirectory($source, $dest, $level = 0)
|
||||
{
|
||||
$source = self::_cleanPath($source);
|
||||
$dest = self::_cleanPath($dest);
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sAsked to copy %s to %s', self::_spaces($level), $source, $dest);
|
||||
|
||||
if (!is_dir($source)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%s%s is not a directory', self::_spaces($level), $source);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_readable($source)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sCannot read source directory at ', self::_spaces($level), $source);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_dir($dest)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%s%s is not a directory', self::_spaces($level), $dest);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_readable($dest)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sCannot write to destination directory at ', self::_spaces($level), $dest);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sCopying %s to %s', self::_spaces($level), $source, $dest);
|
||||
|
||||
return $this->_doCopyDirectory($source, $dest, $level);
|
||||
}
|
||||
|
||||
private function _doCopyDirectory($source, $dest, $level)
|
||||
{
|
||||
$files = $this->getFilenamesInDirectory($source, self::LOG_PREFIX);
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sWill try to copy %d file(s) from %s to %s', self::_spaces($level), count($files), $source, $dest);
|
||||
|
||||
$dirs = $this->getDirectoriesInDirectory($source, self::LOG_PREFIX);
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sWill try to copy %d directories from %s to %s', self::_spaces($level), count($dirs), $source, $dest);
|
||||
|
||||
$finalDest = $dest . DIRECTORY_SEPARATOR . basename($source);
|
||||
|
||||
if ($this->ensureDirectoryExists($finalDest, $level) === false) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$finalFileDest = $finalDest . DIRECTORY_SEPARATOR . basename($file);
|
||||
$result = @copy($file, $finalFileDest);
|
||||
|
||||
if ($result === false) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sCould not copy %s to %s', self::_spaces($level), $file, $finalFileDest);
|
||||
return false;
|
||||
}
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sSuccessfully copied %s to %s', self::_spaces($level), $file, $finalFileDest);
|
||||
}
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
|
||||
$finalDirDest = self::_cleanPath($finalDest . DIRECTORY_SEPARATOR . basename($dir));
|
||||
|
||||
if ($this->ensureDirectoryExists($finalDest, $level) === false) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->copyDirectory($dir, $finalDest, $level + 1);
|
||||
|
||||
if ($result === false) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sCould not copy %s to %s', self::_spaces($level), $dir, $finalDirDest);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sDone copying %s to %s', self::_spaces($level), $source, $dest);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ensureDirectoryExists($path, $level = 0)
|
||||
{
|
||||
$path = self::_cleanPath($path);
|
||||
|
||||
if (!is_dir($path)) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sAttempting to create %s', self::_spaces($level), $path);
|
||||
|
||||
$result = @mkdir($path);
|
||||
|
||||
if ($result === false) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sCould not create directory at %s', self::_spaces($level), $path);
|
||||
return false;
|
||||
}
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, '%sSuccessfully created directory at %s', self::_spaces($level), $path);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function _cleanPath($path)
|
||||
{
|
||||
return str_replace('//', '/', str_replace('\\', '/', $path));
|
||||
}
|
||||
|
||||
private static function _spaces($level)
|
||||
{
|
||||
return substr(' ', 0, 3 * $level);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_html_HeadHtmlGenerator',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
));
|
||||
|
||||
/**
|
||||
* Generates HTML for use in the <head>.
|
||||
*/
|
||||
class org_tubepress_impl_html_DefaultHeadHtmlGenerator implements org_tubepress_api_html_HeadHtmlGenerator
|
||||
{
|
||||
private $_tubepressBaseUrl;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $tubepress_base_url;
|
||||
$this->_tubepressBaseUrl = $tubepress_base_url;
|
||||
}
|
||||
|
||||
public function getHeadJqueryInclusion()
|
||||
{
|
||||
$url = $this->_tubepressBaseUrl;
|
||||
return "<script type=\"text/javascript\" src=\"$url/sys/ui/static/js/jquery-1.6.1.min.js\"></script>";
|
||||
}
|
||||
|
||||
public function getHeadInlineJs()
|
||||
{
|
||||
$url = $this->_tubepressBaseUrl;
|
||||
return "<script type=\"text/javascript\">function getTubePressBaseUrl(){return \"$url\";}</script>";
|
||||
}
|
||||
|
||||
public function getHeadJsIncludeString()
|
||||
{
|
||||
$url = $this->_tubepressBaseUrl;
|
||||
return "<script type=\"text/javascript\" src=\"$url/sys/ui/static/js/tubepress.js\"></script>";
|
||||
}
|
||||
|
||||
public function getHeadCssIncludeString()
|
||||
{
|
||||
$url = $this->_tubepressBaseUrl;
|
||||
return "<link rel=\"stylesheet\" href=\"$url/sys/ui/themes/default/style.css\" type=\"text/css\" />";
|
||||
}
|
||||
|
||||
public function getHeadHtmlMeta()
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$qss = $ioc->get('org_tubepress_api_querystring_QueryStringService');
|
||||
$page = $qss->getPageNum($_GET);
|
||||
|
||||
return $page > 1 ? "<meta name=\"robots\" content=\"noindex, nofollow\" />" : '';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_names_Advanced',
|
||||
'org_tubepress_api_http_HttpClient',
|
||||
'org_tubepress_api_exec_ExecutionContext',
|
||||
'org_tubepress_api_patterns_cor_Chain',
|
||||
'org_tubepress_impl_http_clientimpl_Encoding',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* HTTP Class for managing HTTP Transports and making HTTP requests.
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_http_HttpClientChain implements org_tubepress_api_http_HttpClient
|
||||
{
|
||||
const LOG_PREFIX = 'HTTP Client';
|
||||
|
||||
const ARGS_BODY = 'body';
|
||||
const ARGS_COOKIES = 'cookies';
|
||||
const ARGS_COMPRESS = 'compress';
|
||||
const ARGS_DECOMPRESS = 'decompress';
|
||||
const ARGS_HEADERS = 'headers';
|
||||
const ARGS_HTTP_VERSION = 'httpversion';
|
||||
const ARGS_IS_SSL = 'ssl';
|
||||
const ARGS_METHOD = 'method';
|
||||
const ARGS_SSL_VERIFY = 'sslverify';
|
||||
const ARGS_TIMEOUT = 'timeout';
|
||||
const ARGS_USER_AGENT = 'user-agent';
|
||||
|
||||
/**
|
||||
* Post.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
* @param unknown $body The body of the POST
|
||||
*
|
||||
* @return string Resulting body as a string (could be null)
|
||||
*/
|
||||
public function post($url, $body)
|
||||
{
|
||||
return $this->_request($url, array(
|
||||
self::ARGS_METHOD => org_tubepress_api_http_HttpClient::HTTP_METHOD_POST,
|
||||
self::ARGS_BODY => $body
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
*
|
||||
* @return string Resulting body as a string (could be null)
|
||||
*/
|
||||
public function get($url)
|
||||
{
|
||||
return $this->_request($url, array(self::ARGS_METHOD => org_tubepress_api_http_HttpClient::HTTP_METHOD_GET));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a HTTP request to a URI.
|
||||
*
|
||||
* The body and headers are part of the arguments. The 'body' argument is for the body and will
|
||||
* accept either a string or an array. The 'headers' argument should be an array, but a string
|
||||
* is acceptable.
|
||||
*
|
||||
* The only URI that are supported in the HTTP Transport implementation are the HTTP and HTTPS
|
||||
* protocols. HTTP and HTTPS are assumed so the server might not know how to handle the send
|
||||
* headers. Other protocols are unsupported and most likely will fail.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
* @param array $args Generic HTTP options.
|
||||
*
|
||||
* @return array containing 'headers', 'body', 'response', 'cookies'
|
||||
*/
|
||||
private function _request($url, $args)
|
||||
{
|
||||
$defaults = array(
|
||||
self::ARGS_METHOD => org_tubepress_api_http_HttpClient::HTTP_METHOD_GET,
|
||||
self::ARGS_TIMEOUT => 5,
|
||||
self::ARGS_HTTP_VERSION => '1.0',
|
||||
self::ARGS_USER_AGENT => 'TubePress; http://tubepress.org',
|
||||
self::ARGS_HEADERS => array(),
|
||||
self::ARGS_COOKIES => array(),
|
||||
self::ARGS_BODY => null,
|
||||
self::ARGS_COMPRESS => false,
|
||||
self::ARGS_DECOMPRESS => true,
|
||||
self::ARGS_SSL_VERIFY => true
|
||||
);
|
||||
|
||||
$r = array_merge($defaults, $args);
|
||||
$arrURL = parse_url($url);
|
||||
|
||||
if (empty($url) || empty($arrURL['scheme'])) {
|
||||
throw new Exception('A valid URL was not provided.');
|
||||
}
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Will perform %s to <a href="%s">%s</a>', $r[self::ARGS_METHOD], $url, $url);
|
||||
|
||||
// Determine if this is a https call and pass that on to the transport functions
|
||||
// so that we can blacklist the transports that do not support ssl verification
|
||||
$r[self::ARGS_IS_SSL] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
|
||||
|
||||
// Determine if this request is local
|
||||
$r['local'] = 'localhost' == $arrURL['host'];
|
||||
|
||||
if (org_tubepress_impl_http_clientimpl_Encoding::isCompressionAvailable()) {
|
||||
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'HTTP compression is available. Yay!');
|
||||
$r[self::ARGS_HEADERS][org_tubepress_api_http_HttpClient::HTTP_HEADER_ACCEPT_ENCODING] = org_tubepress_impl_http_clientimpl_Encoding::getAcceptEncodingString();
|
||||
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'HTTP compression is NOT available. Boo.');
|
||||
}
|
||||
|
||||
if (empty($r[self::ARGS_BODY])) {
|
||||
|
||||
$r[self::ARGS_BODY] = null;
|
||||
|
||||
// Some servers fail when sending content without the content-length header being set.
|
||||
// Also, to fix another bug, we only send when doing POST and PUT and the content-length
|
||||
// header isn't already set.
|
||||
if (($r[self::ARGS_METHOD] == org_tubepress_api_http_HttpClient::HTTP_METHOD_POST || $r[self::ARGS_METHOD] == org_tubepress_api_http_HttpClient::HTTP_METHOD_PUT)) {
|
||||
$r[self::ARGS_HEADERS][org_tubepress_api_http_HttpClient::HTTP_HEADER_CONTENT_LENGTH] = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$r[self::ARGS_HEADERS][org_tubepress_api_http_HttpClient::HTTP_HEADER_CONTENT_LENGTH] = strlen($r[self::ARGS_BODY]);
|
||||
}
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$commands = self::_getTransportCommands($ioc);
|
||||
$sm = $ioc->get('org_tubepress_api_patterns_cor_Chain');
|
||||
$context = $sm->createContextInstance();
|
||||
|
||||
$context->url = $url;
|
||||
$context->args = $r;
|
||||
|
||||
$status = $sm->execute($context, $commands);
|
||||
|
||||
if ($status === false) {
|
||||
throw new Exception("Could not retrieve $url");
|
||||
}
|
||||
|
||||
return $context->returnValue;
|
||||
}
|
||||
|
||||
private static function _getTransportCommands(org_tubepress_api_ioc_IocService $ioc)
|
||||
{
|
||||
$result = array();
|
||||
$context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
|
||||
|
||||
if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_EXTHTTP)) {
|
||||
$result[] = 'org_tubepress_impl_http_clientimpl_commands_ExtHttpCommand';
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'ExtHttp transport disabled by request');
|
||||
}
|
||||
|
||||
if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_CURL)) {
|
||||
$result[] = 'org_tubepress_impl_http_clientimpl_commands_CurlCommand';
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Curl transport disabled by request');
|
||||
}
|
||||
|
||||
if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_STREAMS)) {
|
||||
$result[] = 'org_tubepress_impl_http_clientimpl_commands_StreamsCommand';
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Streams transport disabled by request');
|
||||
}
|
||||
|
||||
if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_FOPEN)) {
|
||||
$result[] = 'org_tubepress_impl_http_clientimpl_commands_FopenCommand';
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'fopen transport disabled by request');
|
||||
}
|
||||
|
||||
if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_FSOCKOPEN)) {
|
||||
$result[] = 'org_tubepress_impl_http_clientimpl_commands_FsockOpenCommand';
|
||||
} else {
|
||||
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'fsockopen transport disabled by request');
|
||||
}
|
||||
|
||||
if (sizeof($result) === 0) {
|
||||
throw new Exception("Must enable at least one HTTP transport");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* Internal representation of a single cookie.
|
||||
*
|
||||
* Returned cookies are represented using this class, and when cookies are set, if they are not
|
||||
* already a org_tubepress_impl_http_clientimpl_Cookie() object, then they are turned into one.
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_Cookie
|
||||
{
|
||||
/** Cookie name. */
|
||||
var $name;
|
||||
|
||||
/** Cookie value. */
|
||||
var $value;
|
||||
|
||||
/** When the cookie expires. */
|
||||
var $expires;
|
||||
|
||||
/** Cookie URL path. */
|
||||
var $path;
|
||||
|
||||
/** Cookie Domain. */
|
||||
var $domain;
|
||||
|
||||
/**
|
||||
* Sets up this cookie object.
|
||||
*
|
||||
* The parameter $data should be either an associative array containing the indices names below
|
||||
* or a header string detailing it.
|
||||
*
|
||||
* If it's an array, it should include the following elements:
|
||||
* <ol>
|
||||
* <li>Name</li>
|
||||
* <li>Value - should NOT be urlencoded already.</li>
|
||||
* <li>Expires - (optional) String or int (UNIX timestamp).</li>
|
||||
* <li>Path (optional)</li>
|
||||
* <li>Domain (optional)</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param string|array $data Raw cookie data.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
if (is_string($data)) {
|
||||
|
||||
// Assume it's a header string direct from a previous request
|
||||
$pairs = explode(';', $data);
|
||||
|
||||
// Special handling for first pair; name=value. Also be careful of "=" in value
|
||||
$name = trim(substr($pairs[0], 0, strpos($pairs[0], '=')));
|
||||
$value = substr($pairs[0], strpos($pairs[0], '=') + 1);
|
||||
$this->name = $name;
|
||||
$this->value = urldecode($value);
|
||||
|
||||
array_shift($pairs); //Removes name=value from items.
|
||||
|
||||
// Set everything else as a property
|
||||
foreach ($pairs as $pair) {
|
||||
$pair = rtrim($pair);
|
||||
|
||||
if (empty($pair)) { //Handles the cookie ending in ; which results in a empty final pair
|
||||
continue;
|
||||
}
|
||||
|
||||
list($key, $val) = strpos($pair, '=') ? explode('=', $pair) : array($pair, '');
|
||||
$key = strtolower(trim($key));
|
||||
|
||||
if ('expires' == $key) {
|
||||
$val = strtotime($val);
|
||||
}
|
||||
$this->$key = $val;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!isset($data['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set properties based directly on parameters
|
||||
$this->name = $data['name'];
|
||||
$this->value = isset($data['value']) ? $data['value'] : '';
|
||||
$this->path = isset($data['path']) ? $data['path'] : '';
|
||||
$this->domain = isset($data['domain']) ? $data['domain'] : '';
|
||||
|
||||
if (isset($data['expires'])) {
|
||||
$this->expires = is_int($data['expires']) ? $data['expires'] : strtotime($data['expires']);
|
||||
} else {
|
||||
$this->expires = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms that it's OK to send this cookie to the URL checked against.
|
||||
*
|
||||
* Decision is based on RFC 2109/2965, so look there for details on validity.
|
||||
*
|
||||
* @param string $url URL you intend to send this cookie to
|
||||
*
|
||||
* @return boolean TRUE if allowed, FALSE otherwise.
|
||||
*/
|
||||
public function test($url)
|
||||
{
|
||||
// Expires - if expired then nothing else matters
|
||||
if (time() > $this->expires) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get details on the URL we're thinking about sending to
|
||||
$url = parse_url($url);
|
||||
$url['port'] = isset($url['port']) ? $url['port'] : 80;
|
||||
$url['path'] = isset($url['path']) ? $url['path'] : '/';
|
||||
|
||||
// Values to use for comparison against the URL
|
||||
$path = isset($this->path) ? $this->path : '/';
|
||||
$port = isset($this->port) ? $this->port : 80;
|
||||
$domain = isset($this->domain) ? strtolower($this->domain) : strtolower($url['host']);
|
||||
if (false === stripos($domain, '.')) {
|
||||
$domain .= '.local';
|
||||
}
|
||||
|
||||
// Host - very basic check that the request URL ends with the domain restriction (minus leading dot)
|
||||
$domain = substr($domain, 0, 1) == '.' ? substr($domain, 1) : $domain;
|
||||
if (substr($url['host'], -strlen($domain)) != $domain) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Port - supports "port-lists" in the format: "80,8000,8080"
|
||||
if (!in_array($url['port'], explode(',', $port))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Path - request path must start with path restriction
|
||||
if (substr($url['path'], 0, strlen($path)) != $path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert cookie name and value back to header string.
|
||||
*
|
||||
* @return string Header encoded cookie name and value.
|
||||
*/
|
||||
public function getHeaderValue()
|
||||
{
|
||||
if (empty($this->name) || empty($this->value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->name . '=' . urlencode($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve cookie header for usage in the rest of the WordPress HTTP API.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFullHeader()
|
||||
{
|
||||
return 'Cookie: ' . $this->getHeaderValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,235 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* Implementation for deflate and gzip transfer encodings.
|
||||
*
|
||||
* Includes RFC 1950, RFC 1951, and RFC 1952.
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_Encoding
|
||||
{
|
||||
/**
|
||||
* Compress raw string using the deflate format.
|
||||
*
|
||||
* Supports the RFC 1951 standard.
|
||||
*
|
||||
* @param string $raw String to compress.
|
||||
* @param int $level Optional, default is 9. Compression level, 9 is highest.
|
||||
* @param string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports.
|
||||
*
|
||||
* @return string|bool False on failure.
|
||||
*/
|
||||
public static function compress($raw, $level = 9, $supports = null)
|
||||
{
|
||||
return gzdeflate($raw, $level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decompression of deflated string.
|
||||
*
|
||||
* Will attempt to decompress using the RFC 1950 standard, and if that fails
|
||||
* then the RFC 1951 standard deflate will be attempted. Finally, the RFC
|
||||
* 1952 standard gzip decode will be attempted. If all fail, then the
|
||||
* original compressed string will be returned.
|
||||
*
|
||||
* @param string $compressed String to decompress.
|
||||
* @param int $length The optional length of the compressed data.
|
||||
*
|
||||
* @return string|bool False on failure.
|
||||
*/
|
||||
public static function decompress($compressed, $length = null)
|
||||
{
|
||||
if (empty($compressed)) {
|
||||
return $compressed;
|
||||
}
|
||||
|
||||
if (false !== ($decompressed = @gzinflate($compressed))) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
if (false !== ($decompressed = self::simulatedGzInflate($compressed))) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
if (false !== ($decompressed = @gzuncompress($compressed))) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
if (function_exists('gzdecode')) {
|
||||
$decompressed = @gzdecode($compressed);
|
||||
|
||||
if (false !== $decompressed) {
|
||||
return $decompressed;
|
||||
}
|
||||
}
|
||||
|
||||
return $compressed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decompression of deflated string while staying compatible with the majority of servers.
|
||||
*
|
||||
* Certain Servers will return deflated data with headers which PHP's gziniflate()
|
||||
* function cannot handle out of the box. The following function lifted from
|
||||
* http://au2.php.net/manual/en/function.gzinflate.php#77336 will attempt to deflate
|
||||
* the various return forms used.
|
||||
*
|
||||
* See http://au2.php.net/manual/en/function.gzinflate.php#77336
|
||||
*
|
||||
* @param string $gzData String to decompress.
|
||||
*
|
||||
* @return string|bool False on failure.
|
||||
*/
|
||||
public static function simulatedGzInflate($gzData)
|
||||
{
|
||||
if (substr($gzData, 0, 3) == "\x1f\x8b\x08") {
|
||||
$i = 10;
|
||||
$flg = ord(substr($gzData, 3, 1));
|
||||
if ($flg > 0) {
|
||||
if ($flg & 4) {
|
||||
list($xlen) = unpack('v', substr($gzData, $i, 2));
|
||||
$i = $i + 2 + $xlen;
|
||||
}
|
||||
if ($flg & 8) {
|
||||
$i = strpos($gzData, "\0", $i) + 1;
|
||||
}
|
||||
if ($flg & 16) {
|
||||
$i = strpos($gzData, "\0", $i) + 1;
|
||||
}
|
||||
if ($flg & 2) {
|
||||
$i = $i + 2;
|
||||
}
|
||||
}
|
||||
return gzinflate(substr($gzData, $i, -8));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What encoding types to accept and their priority values.
|
||||
*
|
||||
* @return string Types of encoding to accept.
|
||||
*/
|
||||
public static function getAcceptEncodingString()
|
||||
{
|
||||
$type = array();
|
||||
if (function_exists('gzinflate')) {
|
||||
$type[] = 'deflate;q=1.0';
|
||||
}
|
||||
|
||||
if (function_exists('gzuncompress')) {
|
||||
$type[] = 'compress;q=0.5';
|
||||
}
|
||||
|
||||
if (function_exists('gzdecode')) {
|
||||
$type[] = 'gzip;q=0.5';
|
||||
}
|
||||
|
||||
return implode(', ', $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* What enconding the content used when it was compressed to send in the headers.
|
||||
*
|
||||
* @return string Content-Encoding string to send in the header.
|
||||
*/
|
||||
public static function getContentEncodingString()
|
||||
{
|
||||
return 'deflate';
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the content be decoded based on the headers.
|
||||
*
|
||||
* @param array|string $headers All of the available headers.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldDecode($headers)
|
||||
{
|
||||
if (is_array($headers)) {
|
||||
if (array_key_exists('content-encoding', $headers) && ! empty($headers['content-encoding'])) {
|
||||
return true;
|
||||
}
|
||||
} else if (is_string($headers)) {
|
||||
return (stripos($headers, 'content-encoding:') !== false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether decompression and compression are supported by the PHP version.
|
||||
*
|
||||
* Each function is tested instead of checking for the zlib extension, to
|
||||
* ensure that the functions all exist in the PHP version and aren't
|
||||
* disabled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCompressionAvailable()
|
||||
{
|
||||
return (function_exists('gzuncompress') || function_exists('gzdeflate') || function_exists('gzinflate'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.
|
||||
*
|
||||
* Based off the HTTP http_encoding_dechunk function. Does not support UTF-8. Does not support
|
||||
* returning footer headers. Shouldn't be too difficult to support it though.
|
||||
*
|
||||
* @param string $body Body content
|
||||
*
|
||||
* @return string Chunked decoded body on success or raw body on failure.
|
||||
*/
|
||||
public static function chunkTransferDecode($body)
|
||||
{
|
||||
$body = str_replace(array("\r\n", "\r"), "\n", $body);
|
||||
|
||||
// The body is not chunked encoding or is malformed.
|
||||
if (! preg_match('/^[0-9a-f]+(\s|\n)+/mi', trim($body))) {
|
||||
return $body;
|
||||
}
|
||||
|
||||
$parsedBody = '';
|
||||
|
||||
while (true) {
|
||||
$hasChunk = (bool) preg_match('/^([0-9a-f]+)(\s|\n)+/mi', $body, $match);
|
||||
|
||||
if (!$hasChunk || empty($match[1])) {
|
||||
return $body;
|
||||
}
|
||||
|
||||
$length = hexdec($match[1]);
|
||||
$chunkLength = strlen($match[0]);
|
||||
$strBody = substr($body, $chunkLength, $length);
|
||||
$parsedBody .= $strBody;
|
||||
$body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
|
||||
|
||||
if ("0" == trim($body)) {
|
||||
return $parsedBody; // Ignore footer headers.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_patterns_cor_Command',
|
||||
'org_tubepress_impl_http_clientimpl_Cookie',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* Base HTTP command.
|
||||
*/
|
||||
abstract class org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand implements org_tubepress_api_patterns_cor_Command
|
||||
{
|
||||
private $_redirectCount;
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @param array $context An array of context elements (may be empty).
|
||||
*
|
||||
* @return boolean True if this command was able to handle the execution. False otherwise.
|
||||
*/
|
||||
public function execute($context)
|
||||
{
|
||||
if ($this->_canHandle($context->url, $context->args) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->_doExecute($context->url, $context->args);
|
||||
|
||||
/* check response code */
|
||||
$code = $result['response']['code'];
|
||||
if ($code != 200) {
|
||||
throw new Exception("Request for " . $context->url . " returned a $code HTTP response: " . $result['response']['message']);
|
||||
}
|
||||
|
||||
$context->returnValue = $result['body'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract function _doExecute($url, $args);
|
||||
|
||||
protected abstract function _canHandle($url, $args);
|
||||
|
||||
protected function _canRedirect()
|
||||
{
|
||||
return ++$this->_redirectCount < 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform header string into an array.
|
||||
*
|
||||
* If an array is given then it is assumed to be raw header data with numeric keys with the
|
||||
* headers as the values. No headers must be passed that were already processed.
|
||||
*
|
||||
* @param string|array $headers The headers.
|
||||
*
|
||||
* @return array Processed string headers. If duplicate headers are encountered,
|
||||
* Then a numbered array is returned as the value of that header-key.
|
||||
*/
|
||||
protected static function _getProcessedHeaders($headers)
|
||||
{
|
||||
// split headers, one per array element
|
||||
if (is_string($headers)) {
|
||||
|
||||
// tolerate line terminator: CRLF = LF (RFC 2616 19.3)
|
||||
$headers = str_replace("\r\n", "\n", $headers);
|
||||
|
||||
// unfold folded header fields. LWS = [CRLF] 1*(SP | HT) <US-ASCII SP, space (32)>, <US-ASCII HT, horizontal-tab (9)> (RFC 2616 2.2)
|
||||
$headers = preg_replace('/\n[ \t]/', ' ', $headers);
|
||||
|
||||
// create the headers array
|
||||
$headers = explode("\n", $headers);
|
||||
}
|
||||
|
||||
$response = array('code' => 0, 'message' => '');
|
||||
|
||||
// If a redirection has taken place, The headers for each page request may have been passed.
|
||||
// In this case, determine the final HTTP header and parse from there.
|
||||
for ($i = count($headers)-1; $i >= 0; $i--) {
|
||||
if (!empty($headers[$i]) && false === strpos($headers[$i], ':')) {
|
||||
$headers = array_splice($headers, $i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$cookies = array();
|
||||
$newheaders = array();
|
||||
|
||||
foreach ($headers as $tempheader) {
|
||||
if (empty($tempheader)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false === strpos($tempheader, ':')) {
|
||||
list(, $response['code'], $response['message']) = explode(' ', $tempheader, 3);
|
||||
continue;
|
||||
}
|
||||
|
||||
list($key, $value) = explode(':', $tempheader, 2);
|
||||
|
||||
if (!empty($value)) {
|
||||
|
||||
$key = strtolower($key);
|
||||
|
||||
if (isset($newheaders[$key])) {
|
||||
|
||||
if (!is_array($newheaders[$key])) {
|
||||
$newheaders[$key] = array($newheaders[$key]);
|
||||
}
|
||||
|
||||
$newheaders[$key][] = trim($value);
|
||||
} else {
|
||||
$newheaders[$key] = trim($value);
|
||||
}
|
||||
if ('set-cookie' == $key) {
|
||||
$cookies[] = new org_tubepress_impl_http_clientimpl_Cookie($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array('response' => $response, 'headers' => $newheaders, 'cookies' => $cookies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the responses and splits the parts into headers and body.
|
||||
*
|
||||
* @param string $strResponse The full response string
|
||||
*
|
||||
* @return array Array with 'headers' and 'body' keys.
|
||||
*/
|
||||
protected static function _breakRawStringResponseIntoHeaderAndBody($strResponse)
|
||||
{
|
||||
$res = explode("\r\n\r\n", $strResponse, 2);
|
||||
|
||||
return array('headers' => isset($res[0]) ? $res[0] : array(), 'body' => isset($res[1]) ? $res[1] : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the arguments for a ::request() and checks for the cookie array.
|
||||
*
|
||||
* If it's found, then it's assumed to contain org_tubepress_http_HttpClientChain_Cookie objects, which are each parsed
|
||||
* into strings and added to the Cookie: header (within the arguments array). Edits the array by
|
||||
* reference.
|
||||
*
|
||||
* @param array &$r Full array of args passed into ::request()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function _buildCookieHeader(&$r)
|
||||
{
|
||||
if (! empty($r[self::ARGS_COOKIES])) {
|
||||
$cookies_header = '';
|
||||
foreach ((array) $r[self::ARGS_COOKIES] as $cookie) {
|
||||
$cookies_header .= $cookie->getHeaderValue() . '; ';
|
||||
}
|
||||
$cookies_header = substr($cookies_header, 0, -2);
|
||||
$r[self::ARGS_HEADERS]['cookie'] = $cookies_header;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand',
|
||||
'org_tubepress_impl_http_HttpClientChain',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* HTTP request method uses Curl extension to retrieve the url.
|
||||
*
|
||||
* Requires the Curl extension to be installed.
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_commands_CurlCommand extends org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand
|
||||
{
|
||||
/**
|
||||
* Send a HTTP request to a URI using cURL extension.
|
||||
*
|
||||
* @param string $url The URL to handle.
|
||||
* @param str|array $r Optional. Override the defaults.
|
||||
*
|
||||
* @return array 'headers', 'body', 'cookies' and 'response' keys.
|
||||
*/
|
||||
protected function _doExecute($url, $r)
|
||||
{
|
||||
$handle = curl_init();
|
||||
$sslVerify = isset($r[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY]) && $r[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY];
|
||||
|
||||
// CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since
|
||||
// a value of 0 will allow an ulimited timeout.
|
||||
$timeout = (int) ceil($r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT]);
|
||||
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
curl_setopt($handle, CURLOPT_TIMEOUT, $timeout);
|
||||
|
||||
curl_setopt($handle, CURLOPT_URL, $url);
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, $sslVerify);
|
||||
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, $sslVerify);
|
||||
curl_setopt($handle, CURLOPT_USERAGENT, $r[org_tubepress_impl_http_HttpClientChain::ARGS_USER_AGENT]);
|
||||
curl_setopt($handle, CURLOPT_MAXREDIRS, 5);
|
||||
|
||||
switch ($r[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD]) {
|
||||
case 'POST':
|
||||
curl_setopt($handle, CURLOPT_POST, true);
|
||||
curl_setopt($handle, CURLOPT_POSTFIELDS, $r['body']);
|
||||
break;
|
||||
case 'PUT':
|
||||
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
curl_setopt($handle, CURLOPT_POSTFIELDS, $r['body']);
|
||||
break;
|
||||
}
|
||||
|
||||
curl_setopt($handle, CURLOPT_HEADER, true);
|
||||
|
||||
// The option doesn't work with safe mode or when open_basedir is set.
|
||||
// Disable HEAD when making HEAD requests.
|
||||
if (!ini_get('safe_mode') && !ini_get('open_basedir')) {
|
||||
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
|
||||
}
|
||||
|
||||
if (!empty($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS])) {
|
||||
// cURL expects full header strings in each element
|
||||
$headers = array();
|
||||
foreach ($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS] as $name => $value) {
|
||||
$headers[] = "{$name}: $value";
|
||||
}
|
||||
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
|
||||
if ($r[org_tubepress_impl_http_HttpClientChain::ARGS_HTTP_VERSION] == '1.0') {
|
||||
curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
||||
} else {
|
||||
curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||
}
|
||||
|
||||
$theResponse = curl_exec($handle);
|
||||
|
||||
if (!empty($theResponse)) {
|
||||
|
||||
$headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
|
||||
$theHeaders = trim(substr($theResponse, 0, $headerLength));
|
||||
|
||||
if (strlen($theResponse) > $headerLength) {
|
||||
$theBody = substr($theResponse, $headerLength);
|
||||
} else {
|
||||
$theBody = '';
|
||||
}
|
||||
|
||||
if (false !== strrpos($theHeaders, "\r\n\r\n")) {
|
||||
$headerParts = explode("\r\n\r\n", $theHeaders);
|
||||
$theHeaders = $headerParts[ count($headerParts) -1 ];
|
||||
}
|
||||
$theHeaders = self::_getProcessedHeaders($theHeaders);
|
||||
|
||||
} else {
|
||||
if ($curlError = curl_error($handle)) {
|
||||
throw new Exception($curlError);
|
||||
}
|
||||
if (in_array(curl_getinfo($handle, CURLINFO_HTTP_CODE), array(301, 302))) {
|
||||
throw new Exception('Too many redirects.');
|
||||
}
|
||||
|
||||
$theHeaders = array('headers' => array(), 'cookies' => array());
|
||||
$theBody = '';
|
||||
}
|
||||
|
||||
$response = array();
|
||||
$response['code'] = curl_getinfo($handle, CURLINFO_HTTP_CODE);
|
||||
$response['message'] = $response['code'];
|
||||
|
||||
curl_close($handle);
|
||||
|
||||
if (true === $r[org_tubepress_impl_http_HttpClientChain::ARGS_DECOMPRESS] && true === org_tubepress_impl_http_clientimpl_Encoding::shouldDecode($theHeaders['headers'])) {
|
||||
$theBody = org_tubepress_impl_http_clientimpl_Encoding::decompress($theBody);
|
||||
}
|
||||
|
||||
return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $response, 'cookies' => $theHeaders['cookies']);
|
||||
}
|
||||
|
||||
protected function _canHandle($url, $args)
|
||||
{
|
||||
return function_exists('curl_init') && function_exists('curl_exec');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand',
|
||||
'org_tubepress_impl_http_HttpClientChain',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* HTTP request method uses HTTP extension to retrieve the url.
|
||||
*
|
||||
* Requires the HTTP extension to be installed. This would be the preferred transport since it can
|
||||
* handle a lot of the problems that forces the others to use the HTTP version 1.0. Even if PHP 5.2+
|
||||
* is being used, it doesn't mean that the HTTP extension will be enabled.
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_commands_ExtHttpCommand extends org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand
|
||||
{
|
||||
/**
|
||||
* Send a HTTP request to a URI using HTTP extension.
|
||||
*
|
||||
* Does not support non-blocking.
|
||||
*
|
||||
* @param string $url The URL to handle.
|
||||
* @param str|array $args Optional. Override the defaults.
|
||||
*
|
||||
* @return array 'headers', 'body', 'cookies' and 'response' keys.
|
||||
*/
|
||||
protected function _doExecute($url, $args)
|
||||
{
|
||||
switch ($args[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD]) {
|
||||
case org_tubepress_api_http_HttpClient::HTTP_METHOD_POST:
|
||||
$args[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD] = HTTP_METH_POST;
|
||||
break;
|
||||
case org_tubepress_api_http_HttpClient::HTTP_METHOD_PUT:
|
||||
$args[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD] = HTTP_METH_PUT;
|
||||
break;
|
||||
case org_tubepress_api_http_HttpClient::HTTP_METHOD_GET:
|
||||
default:
|
||||
$args[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD] = HTTP_METH_GET;
|
||||
}
|
||||
|
||||
$urlAsArray = parse_url($url);
|
||||
|
||||
if ('http' != $urlAsArray['scheme'] && 'https' != $urlAsArray['scheme']) {
|
||||
$url = preg_replace('|^' . preg_quote($urlAsArray['scheme'], '|') . '|', 'http', $url);
|
||||
}
|
||||
|
||||
$sslVerify = isset($args[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY]) && $args[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY];
|
||||
|
||||
$args[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT] = (int) ceil($args[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT]);
|
||||
|
||||
$options = array(
|
||||
'timeout' => $args[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT],
|
||||
'connecttimeout' => $args[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT],
|
||||
'redirect' => 5,
|
||||
'useragent' => $args[org_tubepress_impl_http_HttpClientChain::ARGS_USER_AGENT],
|
||||
'headers' => $args[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS],
|
||||
'ssl' => array(
|
||||
'verifypeer' => $sslVerify,
|
||||
'verifyhost' => $sslVerify
|
||||
)
|
||||
);
|
||||
|
||||
$strResponse = @http_request($args[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD], $url, $args[org_tubepress_impl_http_HttpClientChain::ARGS_BODY], $options, $info);
|
||||
|
||||
// Error may still be set, Response may return headers or partial document, and error
|
||||
// contains a reason the request was aborted, eg, timeout expired or max-redirects reached.
|
||||
if (false === $strResponse || ! empty($info['error'])) {
|
||||
throw new Exception($info['response_code'] . ': ' . $info['error']);
|
||||
}
|
||||
|
||||
$headersBody = self::_breakRawStringResponseIntoHeaderAndBody($strResponse);
|
||||
$theHeaders = $headersBody[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS];
|
||||
$theBody = $headersBody[org_tubepress_impl_http_HttpClientChain::ARGS_BODY];
|
||||
|
||||
unset($headersBody);
|
||||
|
||||
$theHeaders = self::_getProcessedHeaders($theHeaders);
|
||||
|
||||
if (! empty($theBody) && isset($theHeaders['headers']['transfer-encoding']) && 'chunked' == $theHeaders['headers']['transfer-encoding']) {
|
||||
$theBody = @http_chunked_decode($theBody);
|
||||
}
|
||||
|
||||
if (true === $args['decompress'] && true === org_tubepress_impl_http_clientimpl_Encoding::shouldDecode($theHeaders['headers'])) {
|
||||
$theBody = http_inflate($theBody);
|
||||
}
|
||||
|
||||
return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theHeaders['response'], 'cookies' => $theHeaders['cookies']);
|
||||
}
|
||||
|
||||
protected function _canHandle($url, $args)
|
||||
{
|
||||
return function_exists('http_request');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand',
|
||||
'org_tubepress_impl_http_HttpClientChain',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* HTTP request method uses fopen function to retrieve the url.
|
||||
*
|
||||
* Does not allow for $context support,
|
||||
* but should still be okay, to write the headers, before getting the response. Also requires that
|
||||
* 'allow_url_fopen' to be enabled.
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_commands_FopenCommand extends org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand
|
||||
{
|
||||
const INI_USER_AGENT = 'user_agent';
|
||||
|
||||
/**
|
||||
* Send a HTTP request to a URI using fopen().
|
||||
*
|
||||
* This transport does not support sending of headers and body, therefore should not be used in
|
||||
* the instances, where there is a body and headers.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
* @param array $args Optional. Override the defaults.
|
||||
*
|
||||
* @return array 'headers', 'body', 'cookies' and 'response' keys.
|
||||
*/
|
||||
protected function _doExecute($url, $r)
|
||||
{
|
||||
$arrURL = parse_url($url);
|
||||
|
||||
if ('http' != $arrURL['scheme'] && 'https' != $arrURL['scheme']) {
|
||||
$url = str_replace($arrURL['scheme'], 'http', $url);
|
||||
}
|
||||
|
||||
$initialUserAgent = ini_get(self::INI_USER_AGENT);
|
||||
|
||||
if (!empty($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS]) && is_array($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS])) {
|
||||
$user_agent_extra_headers = '';
|
||||
foreach ($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS] as $header => $value) {
|
||||
$user_agent_extra_headers .= "\r\n$header: $value";
|
||||
}
|
||||
@ini_set(self::INI_USER_AGENT, $r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS] . $user_agent_extra_headers);
|
||||
} else {
|
||||
@ini_set(self::INI_USER_AGENT, $r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS]);
|
||||
}
|
||||
|
||||
$handle = @fopen($url, 'r');
|
||||
|
||||
if (! $handle) {
|
||||
throw new Exception(sprintf('Could not open handle for fopen() to %s'), $url);
|
||||
}
|
||||
|
||||
$timeout = (int) floor($r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT]);
|
||||
$utimeout = $timeout == $r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT] ? 0 : 1000000 * $r['timeout'] % 1000000;
|
||||
stream_set_timeout($handle, $timeout, $utimeout);
|
||||
|
||||
$strResponse = '';
|
||||
while (! feof($handle)) {
|
||||
$strResponse .= fread($handle, 4096);
|
||||
}
|
||||
|
||||
if (function_exists('stream_get_meta_data')) {
|
||||
$meta = stream_get_meta_data($handle);
|
||||
|
||||
$theHeaders = $meta['wrapper_data'];
|
||||
if (isset($meta['wrapper_data']['headers'])) {
|
||||
$theHeaders = $meta['wrapper_data']['headers'];
|
||||
}
|
||||
} else {
|
||||
//$http_response_header is a PHP reserved variable which is set in the current-scope when using the HTTP Wrapper
|
||||
//see http://php.oregonstate.edu/manual/en/reserved.variables.httpresponseheader.php
|
||||
$theHeaders = $http_response_header;
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
|
||||
@ini_set(self::INI_USER_AGENT, $initialUserAgent); //Clean up any extra headers added
|
||||
|
||||
$processedHeaders = self::_getProcessedHeaders($theHeaders);
|
||||
|
||||
if (! empty($strResponse) && isset($processedHeaders['headers']['transfer-encoding']) && 'chunked' == $processedHeaders['headers']['transfer-encoding']) {
|
||||
$strResponse = org_tubepress_impl_http_clientimpl_Encoding::chunkTransferDecode($strResponse);
|
||||
}
|
||||
|
||||
if (true === $r['decompress'] && true === org_tubepress_impl_http_clientimpl_Encoding::shouldDecode($processedHeaders['headers'])) {
|
||||
$strResponse = org_tubepress_impl_http_clientimpl_Encoding::decompress($strResponse);
|
||||
}
|
||||
|
||||
return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response'], 'cookies' => $processedHeaders['cookies']);
|
||||
}
|
||||
|
||||
protected function _canHandle($url, $args)
|
||||
{
|
||||
if (! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$use = true;
|
||||
|
||||
//PHP does not verify SSL certs, We can only make a request via this transports if SSL Verification is turned off.
|
||||
$isSsl = isset($args[org_tubepress_impl_http_HttpClientChain::ARGS_IS_SSL]) && $args[org_tubepress_impl_http_HttpClientChain::ARGS_IS_SSL];
|
||||
|
||||
if ($isSsl) {
|
||||
$isLocal = isset($args['local']) && $args['local'];
|
||||
$sslVerify = isset($args[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY]) && $args[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY];
|
||||
if ($isLocal && true != true) {
|
||||
$use = true;
|
||||
} elseif (!$isLocal && true != true) {
|
||||
$use = true;
|
||||
} elseif (!$sslVerify) {
|
||||
$use = true;
|
||||
} else {
|
||||
$use = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $use;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand',
|
||||
'org_tubepress_impl_http_HttpClientChain',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* HTTP request method uses fsockopen function to retrieve the url.
|
||||
*
|
||||
* This would be the preferred method, but the fsockopen implementation has the most overhead of all
|
||||
* the HTTP transport implementations.
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_commands_FsockOpenCommand extends org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand
|
||||
{
|
||||
/**
|
||||
* Send a HTTP request to a URI using fsockopen().
|
||||
*
|
||||
* Does not support non-blocking mode.
|
||||
*
|
||||
* @param string $url URI resource.
|
||||
* @param array $r Optional. Override the defaults.
|
||||
*
|
||||
* @return array 'headers', 'body', 'cookies' and 'response' keys.
|
||||
*/
|
||||
protected function _doExecute($url, $r)
|
||||
{
|
||||
$iError = null; // Store error number
|
||||
$strError = null; // Store error string
|
||||
$arrURL = parse_url($url);
|
||||
$fsockopen_host = $arrURL['host'];
|
||||
$secure_transport = false;
|
||||
|
||||
if (! isset($arrURL['port'])) {
|
||||
if (($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') && extension_loaded('openssl')) {
|
||||
$fsockopen_host = "ssl://$fsockopen_host";
|
||||
$arrURL['port'] = 443;
|
||||
$secure_transport = true;
|
||||
} else {
|
||||
$arrURL['port'] = 80;
|
||||
}
|
||||
}
|
||||
|
||||
//fsockopen has issues with 'localhost' with IPv6 with certain versions of PHP, It attempts to connect to ::1,
|
||||
// which fails when the server is not set up for it. For compatibility, always connect to the IPv4 address.
|
||||
if ('localhost' == strtolower($fsockopen_host)) {
|
||||
$fsockopen_host = '127.0.0.1';
|
||||
}
|
||||
|
||||
// There are issues with the HTTPS and SSL protocols that cause errors that can be safely
|
||||
// ignored and should be ignored.
|
||||
if (true === $secure_transport) {
|
||||
$error_reporting = error_reporting(0);
|
||||
}
|
||||
|
||||
$handle = @fsockopen($fsockopen_host, $arrURL['port'], $iError, $strError, $r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT]);
|
||||
|
||||
if (false === $handle) {
|
||||
throw new Exception($iError . ': ' . $strError);
|
||||
}
|
||||
|
||||
$timeout = (int) floor($r['timeout']);
|
||||
$utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000;
|
||||
stream_set_timeout($handle, $timeout, $utimeout);
|
||||
|
||||
$requestPath = $arrURL['path'] . (isset($arrURL['query']) ? '?' . $arrURL['query'] : '');
|
||||
|
||||
if (empty($requestPath)) {
|
||||
$requestPath .= '/';
|
||||
}
|
||||
|
||||
$strHeaders = strtoupper($r[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD]) . ' ' . $requestPath . ' HTTP/' . $r[org_tubepress_impl_http_HttpClientChain::ARGS_HTTP_VERSION] . "\r\n";
|
||||
$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
|
||||
|
||||
if (isset($r[org_tubepress_impl_http_HttpClientChain::ARGS_USER_AGENT])) {
|
||||
$strHeaders .= org_tubepress_api_http_HttpClient::HTTP_HEADER_USER_AGENT . ': ' . $r[org_tubepress_impl_http_HttpClientChain::ARGS_USER_AGENT] . "\r\n";
|
||||
}
|
||||
|
||||
if (is_array($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS])) {
|
||||
foreach ((array) $r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS] as $header => $headerValue) {
|
||||
$strHeaders .= $header . ': ' . $headerValue . "\r\n";
|
||||
}
|
||||
} else {
|
||||
$strHeaders .= $r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS];
|
||||
}
|
||||
|
||||
$strHeaders .= "\r\n";
|
||||
|
||||
if (! is_null($r[org_tubepress_impl_http_HttpClientChain::ARGS_BODY])) {
|
||||
$strHeaders .= $r[org_tubepress_impl_http_HttpClientChain::ARGS_BODY];
|
||||
}
|
||||
|
||||
fwrite($handle, $strHeaders);
|
||||
|
||||
$strResponse = '';
|
||||
while (! feof($handle)) {
|
||||
$strResponse .= fread($handle, 4096);
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
|
||||
if (true === $secure_transport) {
|
||||
error_reporting($error_reporting);
|
||||
}
|
||||
|
||||
$process = self::_breakRawStringResponseIntoHeaderAndBody($strResponse);
|
||||
$arrHeaders = self::_getProcessedHeaders($process['headers']);
|
||||
|
||||
// If location is found, then assume redirect and redirect to location.
|
||||
if (isset($arrHeaders['headers']['location'])) {
|
||||
if ($this->_canRedirect()) {
|
||||
return $this->_doExecute($arrHeaders['headers']['location'], $r);
|
||||
} else {
|
||||
throw new Exception('Too many redirects.');
|
||||
}
|
||||
}
|
||||
|
||||
// If the body was chunk encoded, then decode it.
|
||||
if (! empty($process['body']) && isset($arrHeaders['headers']['transfer-encoding']) && 'chunked' == $arrHeaders['headers']['transfer-encoding']) {
|
||||
$process['body'] = org_tubepress_impl_http_clientimpl_Encoding::chunkTransferDecode($process['body']);
|
||||
}
|
||||
|
||||
if (true === $r[org_tubepress_impl_http_HttpClientChain::ARGS_DECOMPRESS] && true === org_tubepress_impl_http_clientimpl_Encoding::shouldDecode($arrHeaders['headers'])) {
|
||||
$process['body'] = org_tubepress_impl_http_clientimpl_Encoding::decompress($process['body']);
|
||||
}
|
||||
|
||||
return array('headers' => $arrHeaders['headers'], 'body' => $process['body'], 'response' => $arrHeaders['response'], 'cookies' => $arrHeaders['cookies']);
|
||||
}
|
||||
|
||||
protected function _canHandle($url, $args)
|
||||
{
|
||||
$isSsl = isset($args[org_tubepress_impl_http_HttpClientChain::ARGS_IS_SSL]) && $args[org_tubepress_impl_http_HttpClientChain::ARGS_IS_SSL];
|
||||
|
||||
if (! $isSsl && function_exists('fsockopen')) {
|
||||
$use = true;
|
||||
} elseif ($isSsl && extension_loaded('openssl') && function_exists('fsockopen')) {
|
||||
$use = true;
|
||||
} else {
|
||||
$use = false;
|
||||
}
|
||||
|
||||
return $use;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../../../impl/classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand',
|
||||
'org_tubepress_impl_http_HttpClientChain',
|
||||
));
|
||||
|
||||
/**
|
||||
* Lifted from http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/class-http.php
|
||||
*
|
||||
* HTTP request method uses Streams to retrieve the url.
|
||||
*
|
||||
* Requires PHP 5.0+ and uses fopen with stream context. Requires that 'allow_url_fopen' PHP setting
|
||||
* to be enabled.
|
||||
*
|
||||
* Second preferred method for getting the URL, for PHP 5.
|
||||
*/
|
||||
class org_tubepress_impl_http_clientimpl_commands_StreamsCommand extends org_tubepress_impl_http_clientimpl_commands_AbstractHttpCommand
|
||||
{
|
||||
/**
|
||||
* Send a HTTP request to a URI using streams with fopen().
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $args Optional. Override the defaults.
|
||||
*
|
||||
* @return array 'headers', 'body', 'cookies' and 'response' keys.
|
||||
*/
|
||||
public function _doExecute($url, $r)
|
||||
{
|
||||
$arrURL = parse_url($url);
|
||||
if ('http' != $arrURL['scheme'] && 'https' != $arrURL['scheme']) {
|
||||
$url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url);
|
||||
}
|
||||
|
||||
// Convert Header array to string.
|
||||
$strHeaders = '';
|
||||
if (is_array($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS])) {
|
||||
foreach ($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS] as $name => $value) {
|
||||
$strHeaders .= "{$name}: $value\r\n";
|
||||
}
|
||||
} else if (is_string($r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS])) {
|
||||
$strHeaders = $r[org_tubepress_impl_http_HttpClientChain::ARGS_HEADERS];
|
||||
}
|
||||
|
||||
$is_local = isset($args['local']) && $args['local'];
|
||||
$ssl_verify = isset($args[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY]) && $args[org_tubepress_impl_http_HttpClientChain::ARGS_SSL_VERIFY];
|
||||
|
||||
if ($is_local) {
|
||||
$ssl_verify = $ssl_verify;
|
||||
} elseif (! $is_local) {
|
||||
$ssl_verify = $ssl_verify;
|
||||
}
|
||||
|
||||
$arrContext = array('http' =>
|
||||
array(
|
||||
'method' => strtoupper($r[org_tubepress_impl_http_HttpClientChain::ARGS_METHOD]),
|
||||
'user_agent' => $r[org_tubepress_impl_http_HttpClientChain::ARGS_USER_AGENT],
|
||||
'max_redirects' => 6, // See #11557
|
||||
'protocol_version' => (float) $r[org_tubepress_impl_http_HttpClientChain::ARGS_HTTP_VERSION],
|
||||
'header' => $strHeaders,
|
||||
'ignore_errors' => true, // Return non-200 requests.
|
||||
'timeout' => $r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT],
|
||||
'ssl' => array(
|
||||
'verify_peer' => $ssl_verify,
|
||||
'verify_host' => $ssl_verify
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (! empty($r[org_tubepress_impl_http_HttpClientChain::ARGS_BODY])) {
|
||||
$arrContext['http']['content'] = $r[org_tubepress_impl_http_HttpClientChain::ARGS_BODY];
|
||||
}
|
||||
|
||||
$context = stream_context_create($arrContext);
|
||||
|
||||
$handle = @fopen($url, 'r', false, $context);
|
||||
|
||||
if (! $handle) {
|
||||
throw new Exception(sprintf('Could not open handle for fopen() to %s'), $url);
|
||||
}
|
||||
|
||||
$timeout = (int) floor($r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT]);
|
||||
$utimeout = $timeout == $r[org_tubepress_impl_http_HttpClientChain::ARGS_TIMEOUT] ? 0 : 1000000 * $r['timeout'] % 1000000;
|
||||
stream_set_timeout($handle, $timeout, $utimeout);
|
||||
|
||||
$strResponse = stream_get_contents($handle);
|
||||
$meta = stream_get_meta_data($handle);
|
||||
|
||||
fclose($handle);
|
||||
|
||||
$processedHeaders = array();
|
||||
if (isset($meta['wrapper_data']['headers'])) {
|
||||
$processedHeaders = self::_getProcessedHeaders($meta['wrapper_data']['headers']);
|
||||
} else {
|
||||
$processedHeaders = self::_getProcessedHeaders($meta['wrapper_data']);
|
||||
}
|
||||
|
||||
if (! empty($strResponse) && isset($processedHeaders['headers']['transfer-encoding']) && 'chunked' == $processedHeaders['headers']['transfer-encoding']) {
|
||||
$strResponse = org_tubepress_impl_http_clientimpl_Encoding::chunkTransferDecode($strResponse);
|
||||
}
|
||||
|
||||
if (true === $r[org_tubepress_impl_http_HttpClientChain::ARGS_DECOMPRESS] && true === org_tubepress_impl_http_clientimpl_Encoding::shoulddecode($processedHeaders['headers'])) {
|
||||
$strResponse = org_tubepress_impl_http_clientimpl_Encoding::decompress($strResponse);
|
||||
}
|
||||
|
||||
return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response'], 'cookies' => $processedHeaders['cookies']);
|
||||
}
|
||||
|
||||
protected function _canHandle($url, $args)
|
||||
{
|
||||
if (! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_provider_Provider',
|
||||
'org_tubepress_impl_ioc_TubePressIocService',
|
||||
));
|
||||
|
||||
/**
|
||||
* Dependency injector for TubePress in a WordPress environment
|
||||
*/
|
||||
class org_tubepress_impl_ioc_FreeWordPressPluginIocService extends org_tubepress_impl_ioc_TubePressIocService
|
||||
{
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->bind('org_tubepress_api_bootstrap_Bootstrapper') ->to('org_tubepress_impl_bootstrap_TubePressBootstrapper');
|
||||
$this->bind('org_tubepress_api_cache_Cache') ->to('org_tubepress_impl_cache_PearCacheLiteCacheService');
|
||||
$this->bind('org_tubepress_api_embedded_EmbeddedHtmlGenerator') ->to('org_tubepress_impl_embedded_EmbeddedPlayerChain');
|
||||
$this->bind('org_tubepress_api_environment_Detector') ->to('org_tubepress_impl_environment_SimpleEnvironmentDetector');
|
||||
$this->bind('org_tubepress_api_exec_ExecutionContext') ->to('org_tubepress_impl_exec_MemoryExecutionContext');
|
||||
$this->bind('org_tubepress_api_factory_VideoFactory') ->to('org_tubepress_impl_factory_VideoFactoryChain');
|
||||
$this->bind('org_tubepress_api_feed_FeedFetcher') ->to('org_tubepress_impl_feed_CacheAwareFeedFetcher');
|
||||
$this->bind('org_tubepress_api_feed_FeedInspector') ->to('org_tubepress_impl_feed_FeedInspectorChain');
|
||||
$this->bind('org_tubepress_api_filesystem_Explorer') ->to('org_tubepress_impl_filesystem_FsExplorer');
|
||||
$this->bind('org_tubepress_api_html_HeadHtmlGenerator') ->to('org_tubepress_impl_html_DefaultHeadHtmlGenerator');
|
||||
$this->bind('org_tubepress_api_http_HttpClient') ->to('org_tubepress_impl_http_HttpClientChain');
|
||||
$this->bind('org_tubepress_api_message_MessageService') ->to('org_tubepress_impl_message_WordPressMessageService');
|
||||
$this->bind('org_tubepress_api_options_OptionValidator') ->to('org_tubepress_impl_options_SimpleOptionValidator');
|
||||
$this->bind('org_tubepress_api_options_StorageManager') ->to('org_tubepress_impl_options_WordPressStorageManager');
|
||||
$this->bind('org_tubepress_api_plugin_PluginManager') ->to('org_tubepress_impl_plugin_PluginManagerImpl');
|
||||
$this->bind('org_tubepress_api_patterns_cor_Chain') ->to('org_tubepress_impl_patterns_cor_ChainGang');
|
||||
$this->bind('org_tubepress_api_player_PlayerHtmlGenerator') ->to('org_tubepress_impl_player_DefaultPlayerHtmlGenerator');
|
||||
$this->bind('org_tubepress_api_provider_Provider') ->to('org_tubepress_impl_provider_SimpleProvider');
|
||||
$this->bind('org_tubepress_api_provider_ProviderCalculator') ->to('org_tubepress_impl_provider_SimpleProviderCalculator');
|
||||
$this->bind('org_tubepress_api_querystring_QueryStringService') ->to('org_tubepress_impl_querystring_SimpleQueryStringService');
|
||||
$this->bind('org_tubepress_api_shortcode_ShortcodeHtmlGenerator')->to('org_tubepress_impl_shortcode_ShortcodeHtmlGeneratorChain');
|
||||
$this->bind('org_tubepress_api_shortcode_ShortcodeParser') ->to('org_tubepress_impl_shortcode_SimpleShortcodeParser');
|
||||
$this->bind('org_tubepress_api_template_TemplateBuilder') ->to('org_tubepress_impl_template_SimpleTemplateBuilder');
|
||||
$this->bind('org_tubepress_api_theme_ThemeHandler') ->to('org_tubepress_impl_theme_SimpleThemeHandler');
|
||||
$this->bind('org_tubepress_api_url_UrlBuilder') ->to('org_tubepress_impl_url_UrlBuilderChain');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_impl_environment_SimpleEnvironmentDetector',
|
||||
'org_tubepress_impl_log_Log',
|
||||
));
|
||||
|
||||
/**
|
||||
* Class that holds a reference to an IOC container.
|
||||
*/
|
||||
class org_tubepress_impl_ioc_IocContainer
|
||||
{
|
||||
private static $_instance = null;
|
||||
|
||||
/**
|
||||
* Get the singleton inversion of control container.
|
||||
*
|
||||
* @return org_tubepress_api_ioc_IocService The singleton IOC container.
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
/* see if we already built one */
|
||||
if (isset(self::$_instance)) {
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
$detector = new org_tubepress_impl_environment_SimpleEnvironmentDetector();
|
||||
|
||||
if ($detector->isPro()) {
|
||||
if ($detector->isWordPress()) {
|
||||
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClass('org_tubepress_impl_ioc_ProInWordPressIocService');
|
||||
self::$_instance = new org_tubepress_impl_ioc_ProInWordPressIocService();
|
||||
|
||||
} else {
|
||||
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClass('org_tubepress_impl_ioc_ProIocService');
|
||||
self::$_instance = new org_tubepress_impl_ioc_ProIocService();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClass('org_tubepress_impl_ioc_FreeWordPressPluginIocService');
|
||||
self::$_instance = new org_tubepress_impl_ioc_FreeWordPressPluginIocService();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IOC container. This should only be used during testing!
|
||||
*
|
||||
* @param org_tubepress_api_ioc_IocService $instance The IOC container
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setInstance(org_tubepress_api_ioc_IocService $instance)
|
||||
{
|
||||
self::$_instance = $instance;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClass('org_tubepress_api_ioc_IocService');
|
||||
|
||||
/**
|
||||
* Simple dependency injector for TubePress.
|
||||
*/
|
||||
class org_tubepress_impl_ioc_TubePressIocService implements org_tubepress_api_ioc_IocService
|
||||
{
|
||||
private $_interface;
|
||||
|
||||
/* map of interface/class names to implementations */
|
||||
private $_map;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_map = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the interface to which we are about to bind.
|
||||
*
|
||||
* @param string $interface The name of the interface.
|
||||
*
|
||||
* @return org_tubepress_impl_ioc_TubePressIocService For chaining.
|
||||
*/
|
||||
public function bind($interface)
|
||||
{
|
||||
$this->_interface = $interface;
|
||||
|
||||
/* chainable.. */
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the implementation of the interface used in bind().
|
||||
*
|
||||
* @param string $className The name of the implementation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function to($className)
|
||||
{
|
||||
/* prevent people from doing something like $ioc->to('foo') */
|
||||
if (!isset($this->_interface)) {
|
||||
throw new Exception('Call to "to" without calling "bind" first');
|
||||
}
|
||||
|
||||
$this->_map[$this->_interface] = $className;
|
||||
|
||||
/* clear this out for the next round */
|
||||
unset($this->_interface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference to the object implemented by the given class or interface name.
|
||||
*
|
||||
* @param string $classOrInterfaceName The name of the class or interface to retrieve.
|
||||
*
|
||||
* @return object The object instance.
|
||||
*/
|
||||
public function get($classOrInterfaceName)
|
||||
{
|
||||
/* haven't built this class/interface before? */
|
||||
if (!isset($this->_map[$classOrInterfaceName])) {
|
||||
|
||||
/* maybe we can instantiate a singleton? */
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClass($classOrInterfaceName);
|
||||
if (class_exists($classOrInterfaceName)) {
|
||||
return $this->_buildAndRemember($classOrInterfaceName, $classOrInterfaceName);
|
||||
}
|
||||
|
||||
/* give up */
|
||||
throw new Exception("$classOrInterfaceName was never bound to an implementation");
|
||||
}
|
||||
|
||||
/* we've already built it. this should be the normal case. */
|
||||
if ($this->_map[$classOrInterfaceName] instanceof $classOrInterfaceName) {
|
||||
return $this->_map[$classOrInterfaceName];
|
||||
}
|
||||
|
||||
/* build and return the mapped implementation */
|
||||
return $this->_buildInterface($classOrInterfaceName, $this->_map[$classOrInterfaceName]);
|
||||
}
|
||||
|
||||
private function _buildInterface($interfaceName, $implementationName)
|
||||
{
|
||||
class_exists($interfaceName) || org_tubepress_impl_classloader_ClassLoader::loadClass($interfaceName);
|
||||
class_exists($implementationName) || org_tubepress_impl_classloader_ClassLoader::loadClass($implementationName);
|
||||
|
||||
/* build the implementation */
|
||||
$instance = $this->_buildAndRemember($interfaceName, $implementationName);
|
||||
|
||||
/* make sure the class looks OK */
|
||||
if (!($instance instanceof $interfaceName)) {
|
||||
throw new Exception("$implementationName does not implement $interfaceName, but they were bound together");
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
private function _buildAndRemember($interfaceName, $className)
|
||||
{
|
||||
/* build it */
|
||||
$ref = new ReflectionClass($className);
|
||||
$instance = $ref->newInstance();
|
||||
|
||||
/* save it for later */
|
||||
$this->_map[$interfaceName] = $instance;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
class org_tubepress_impl_log_Log
|
||||
{
|
||||
private static $_birthDate;
|
||||
private static $_enabled = false;
|
||||
|
||||
/**
|
||||
* Print a logging statement.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function log()
|
||||
{
|
||||
if (self::$_enabled) {
|
||||
|
||||
$numArgs = func_num_args();
|
||||
$prefix = func_get_arg(0);
|
||||
$message = func_get_arg(1);
|
||||
|
||||
/* how many milliseconds have elapsed? */
|
||||
$time = number_format((microtime(true) - self::$_birthDate) * 1000, 2);
|
||||
|
||||
if ($numArgs > 2) {
|
||||
$args = func_get_args();
|
||||
$message = vsprintf($message, array_slice($args, 2, count($args)));
|
||||
}
|
||||
|
||||
/* print it! */
|
||||
printf("<div><tt style=\"font-size: small\">%s ms (%s) %s (memory: %s KB)</tt></div>\n", $time, $prefix, $message, number_format(memory_get_usage() / 1024));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally enables the log.
|
||||
*
|
||||
* @param boolean $enabled Whether or not to enable the log.
|
||||
* @param array $getVars The PHP $_GET array.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setEnabled($enabled, $getVars)
|
||||
{
|
||||
self::$_enabled = $enabled && isset($getVars['tubepress_debug']) && $getVars['tubepress_debug'] == 'true';
|
||||
|
||||
if (self::$_enabled) {
|
||||
self::$_birthDate = microtime(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,264 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php' ;
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_message_MessageService'
|
||||
));
|
||||
|
||||
/**
|
||||
* Shared message functionality for org_tubepress_api_message_MessageService implementations.
|
||||
* This class basically provides one additional layer of abstraction between
|
||||
* the code and the actual message in the .pot files.
|
||||
*/
|
||||
abstract class org_tubepress_impl_message_AbstractMessageService implements org_tubepress_api_message_MessageService
|
||||
{
|
||||
private $_msgs = array(
|
||||
'options-page-title' => 'TubePress Options',
|
||||
'options-page-save-button' => 'Save',
|
||||
'options-page-intro-text' => 'Set default options for the plugin. Each option here can be overridden on a per page/post basis with TubePress shortcodes. See the <a href="http://tubepress.org/documentation">documentation</a> for more info. An asterisk (*) next to an option indicates it\'s only available with <a href="http://tubepress.org/features">TubePress Pro</a>.',
|
||||
'options-page-options-filter' => 'Only show options applicable to...',
|
||||
|
||||
'options-category-title-output' => 'Which videos?',
|
||||
'options-category-title-display' => 'Appearance',
|
||||
'options-category-title-embedded' => 'Embedded Player',
|
||||
'options-category-title-meta' => 'Meta Display',
|
||||
'options-category-title-feed' => 'Provider Feed',
|
||||
'options-category-title-advanced' => 'Advanced',
|
||||
|
||||
'options-title-top_rated' => 'Top rated videos from...',
|
||||
'options-title-favorites' => 'This YouTube user\'s "favorites"',
|
||||
'options-title-recently_featured' => 'The latest "featured" videos on YouTube\'s homepage',
|
||||
'options-title-mobile' => 'Videos for mobile phones',
|
||||
'options-title-playlist' => 'This playlist',
|
||||
'options-desc-playlist' => 'Limited to 200 videos per playlist. Will usually look something like this: D2B04665B213AE35. Copy the playlist id from the end of the URL in your browser\'s address bar (while looking at a YouTube playlist). It comes right after the "p=". For instance: http://youtube.com/my_playlists?p=D2B04665B213AE35',
|
||||
'options-title-most_viewed' => 'Most-viewed videos from',
|
||||
'options-title-youtubeTopFavorites' => 'Videos most frequently flagged as favorites from...',
|
||||
'options-title-most_recent' => 'Most-recently added videos',
|
||||
'options-title-most_discussed' => 'Most-discussed videos',
|
||||
'options-title-most_responded' => 'Most-responded to videos',
|
||||
'options-title-views' => 'Views',
|
||||
'options-title-tag' => 'YouTube search for...',
|
||||
'options-title-user' => 'Videos from this YouTube user',
|
||||
'options-desc-tag' => 'YouTube limits this mode to 1,000 results',
|
||||
'options-title-vimeoUploadedBy' => 'Videos uploaded by this Vimeo user',
|
||||
'options-title-vimeoLikes' => 'Videos this Vimeo user likes',
|
||||
'options-title-vimeoAppearsIn' => 'Videos this Vimeo user appears in',
|
||||
'options-title-vimeoSearch' => 'Vimeo search for...',
|
||||
'options-title-vimeoCreditedTo' => 'Videos credited to this Vimeo user (either appears in or uploaded by)',
|
||||
'options-title-vimeoChannel' => 'Videos in this Vimeo channel',
|
||||
'options-title-vimeoAlbum' => 'Videos from this Vimeo album',
|
||||
'options-title-vimeoGroup' => 'Videos from this Vimeo group',
|
||||
|
||||
'options-title-playerLocation' => 'Play each video',
|
||||
'options-title-descriptionLimit' => 'Maximum description length',
|
||||
'options-desc-descriptionLimit' => 'Maximum number of characters to display in video descriptions. Set to 0 for no limit.',
|
||||
'options-title-thumbHeight' => 'Height (px) of thumbs',
|
||||
'options-desc-thumbHeight' => 'Default is 90',
|
||||
'options-title-thumbWidth' => 'Width (px) of thumbs',
|
||||
'options-desc-thumbWidth' => 'Default is 120',
|
||||
'options-title-relativeDates' => 'Use relative dates',
|
||||
'options-desc-relativeDates' => 'e.g. "yesterday" instead of "November 3, 1980"',
|
||||
'options-title-resultsPerPage' => 'Videos per Page',
|
||||
'options-desc-resultsPerPage' => 'Default is 20. Maximum is 50',
|
||||
'options-title-orderBy' => 'Order videos by',
|
||||
'options-desc-orderBy' => 'Not all sort orders can be applied to all gallery types. See the <a href="http://tubepress.org/documentation">documentation</a> for more info.',
|
||||
'options-title-paginationAbove' => 'Show pagination above thumbnails',
|
||||
'options-title-paginationBelow' => 'Show pagination below thumbnails',
|
||||
'options-desc-paginationAbove' => 'Only applies to galleries that span multiple pages',
|
||||
'options-desc-paginationBelow' => 'Only applies to galleries that span multiple pages',
|
||||
'options-title-ajaxPagination' => '<a href="http://wikipedia.org/wiki/Ajax_(programming)">Ajax</a>-enabled pagination',
|
||||
'options-title-hqThumbs' => 'Use high-quality thumbnails',
|
||||
'options-desc-hqThumbs' => 'Note: this option cannot be used with the "randomize thumbnails" feature',
|
||||
'options-title-fluidThumbs' => 'Use "fluid" thumbnails',
|
||||
'options-desc-fluidThumbs' => 'Dynamically set thumbnail spacing based on the width of their container.',
|
||||
|
||||
'options-title-autoplay' => 'Auto-play all videos',
|
||||
'options-title-embeddedHeight' => 'Max height (px)',
|
||||
'options-desc-embeddedHeight' => 'Default is 350',
|
||||
'options-title-embeddedWidth' => 'Max width (px)',
|
||||
'options-desc-embeddedWidth' => 'Default is 425',
|
||||
'options-title-fullscreen' => 'Allow fullscreen playback',
|
||||
'options-title-loop' => 'Loop',
|
||||
'options-desc-loop' => 'Continue playing the video until the user stops it',
|
||||
'options-title-playerColor' => 'Main color',
|
||||
'options-desc-playerColor' => 'Default is 999999',
|
||||
'options-title-playerHighlight' => 'Highlight color',
|
||||
'options-desc-playerHighlight' => 'Default is FFFFFF',
|
||||
'options-title-showRelated' => 'Show related videos',
|
||||
'options-desc-showRelated' => 'Toggles the display of related videos after a video finishes',
|
||||
'options-title-showInfo' => 'Show title and rating before video starts',
|
||||
'options-title-hd' => 'Show videos in high definition when available',
|
||||
'options-title-playerImplementation' => 'Implementation',
|
||||
'options-desc-playerImplementation' => 'The brand of the embedded player. Default is the provider\'s player (YouTube, Vimeo, etc)',
|
||||
'options-title-theme' => 'Theme',
|
||||
'options-desc-theme' => 'The TubePress theme to use for this gallery. Your themes can be found at <tt>%s</tt>, and default themes can be found at <tt>%s</tt>.',
|
||||
'options-title-lazyPlay' => '"Lazy" play videos',
|
||||
'options-desc-lazyPlay' => 'Auto-play each video after thumbnail click',
|
||||
|
||||
'options-title-author' => 'Author',
|
||||
'options-title-category' => 'Category',
|
||||
'options-title-description' => 'Description',
|
||||
'options-title-id' => 'ID',
|
||||
'options-title-length' => 'Length',
|
||||
'options-title-rating' => 'Rating',
|
||||
'options-title-ratings' => 'Ratings',
|
||||
'options-title-tags' => 'Keywords',
|
||||
'options-title-title' => 'Title',
|
||||
'options-title-uploaded' => 'Posted',
|
||||
'options-title-url' => 'URL',
|
||||
'options-title-views' => 'Views',
|
||||
'options-title-likes' => 'Likes',
|
||||
|
||||
'options-title-dateFormat' => 'Date format',
|
||||
'options-desc-dateFormat' => 'Set the textual formatting of date information for videos. See <a href="http://us.php.net/date">date</a> for examples.',
|
||||
'options-title-debugging_enabled' => 'Enable debugging',
|
||||
'options-desc-debugging_enabled' => 'If checked, anyone will be able to view your debugging information. This is a rather small privacy risk. If you\'re not having problems with TubePress, or you\'re worried about revealing any details of your TubePress pages, feel free to disable the feature.',
|
||||
'options-title-keyword' => 'Shortcode keyword',
|
||||
'options-desc-keyword' => 'The word you insert (in plaintext, between square brackets) into your posts/pages to display a gallery.',
|
||||
'options-title-randomize_thumbnails' => 'Randomize thumbnails',
|
||||
'options-desc-randomize_thumbnails' => 'Most videos come with several thumbnails. By selecting this option, each time someone views your gallery they will see the same videos with each video\'s thumbnail randomized. Note: this option cannot be used with the "high quality thumbnails" feature',
|
||||
'options-title-disableHttpTransportCurl' => 'Disable <a href="http://php.net/manual/en/function.curl-exec.php">cURL</a> HTTP transport',
|
||||
'options-desc-disableHttpTransportCurl' => 'Do not attempt to use cURL to fetch remote feeds. Leave enabled unless you know what you are doing.',
|
||||
'options-title-disableHttpTransportExtHttp' => 'Disable <a href="http://php.net/http_request">HTTP extension</a> transport',
|
||||
'options-desc-disableHttpTransportExtHttp' => 'Do not attempt to use the PHP HTTP extension to fetch remote feeds. Leave enabled unless you know what you are doing.',
|
||||
'options-title-disableHttpTransportFopen' => 'Disable <a href="http://php.net/manual/en/function.fopen.php">fopen</a> HTTP transport',
|
||||
'options-desc-disableHttpTransportFopen' => 'Do not attempt to use fopen to fetch remote feeds. Leave enabled unless you know what you are doing.',
|
||||
'options-title-disableHttpTransportFsockOpen' => 'Disable <a href="http://php.net/fsockopen">fsockopen</a> HTTP transport',
|
||||
'options-desc-disableHttpTransportFsockOpen' => 'Do not attempt to use fsockopen to fetch remote feeds. Leave enabled unless you know what you are doing.',
|
||||
'options-title-disableHttpTransportStreams' => 'Disable <a href="http://php.net/manual/en/intro.stream.php">PHP streams</a> HTTP transport',
|
||||
'options-desc-disableHttpTransportStreams' => 'Do not attempt to use PHP streams to fetch remote feeds. Leave enabled unless you know what you are doing.',
|
||||
'options-title-cacheDirectory' => 'Cache directory',
|
||||
'options-desc-cacheDirectory' => 'Leave blank to attempt to use system temp directory. Otherwise enter the absolute path of a writeable directory.',
|
||||
'options-title-cacheLifetimeSeconds' => 'Cache expiration time (seconds)',
|
||||
'options-desc-cacheLifetimeSeconds' => 'Cache entries will be considered stale after the specified number of seconds. Default is 3600 (one hour).',
|
||||
'options-title-cacheCleaningFactor' => 'Cache cleaning factor',
|
||||
'options-desc-cacheCleaningFactor' => 'If you enter X, the entire cache will be cleaned every 1/X cache writes. Enter 0 to disable cache cleaning.',
|
||||
|
||||
'options-title-thumbsPerVideo' => 'Thumbs per video',
|
||||
'options-desc-thumbsPerVideo' => 'How many thumbnails to generate for each video. TubePress can randomly display the thumbs each time someone visits the gallery. See the "Randomize thumbnails" option under the "Appearance" tab.',
|
||||
|
||||
'options-title-filter_racy' => 'Filter "racy" content',
|
||||
'options-desc-filter_racy' => 'Don\'t show videos that may not be suitable for minors.',
|
||||
'options-title-videoBlacklist' => 'Videos blacklist',
|
||||
'options-desc-videoBlacklist' => 'List of video IDs that should never be displayed',
|
||||
'options-title-developerKey' => 'YouTube API Developer Key',
|
||||
'options-desc-developerKey' => 'YouTube will use this developer key for logging and debugging purposes if you experience a service problem on their end. You can register a new client ID and developer key <a href="http://code.google.com/apis/youtube/dashboard/">here</a>. Don\'t change this unless you know what you\'re doing.',
|
||||
'options-title-cacheEnabled' => 'Enable request cache',
|
||||
'options-desc-cacheEnabled' => 'Store network responses locally for 1 hour. Each response is on the order of a few hundred KB, so leaving the cache enabled will significantly reduce load times for your galleries at the slight expense of freshness.',
|
||||
'options-title-embeddableOnly' => 'Only retrieve embeddable videos',
|
||||
'options-desc-embeddableOnly' => 'Some videos have embedding disabled. Checking this option will exclude these videos from your galleries.',
|
||||
'options-title-resultCountCap' => 'Maximum total videos to retrieve',
|
||||
'options-desc-resultCountCap' => 'This can help to reduce the number of pages in your gallery. Set to "0" to remove any limit.',
|
||||
'options-title-vimeoKey' => 'Vimeo API "Consumer Key"',
|
||||
'options-desc-vimeoKey' => '<a href="http://vimeo.com/api/applications/new">Click here</a> to register for a consumer key and secret.',
|
||||
'options-title-vimeoSecret' => 'Vimeo API "Consumer Secret"',
|
||||
'options-desc-vimeoSecret' => '<a href="http://vimeo.com/api/applications/new">Click here</a> to register for a consumer key and secret.',
|
||||
'options-title-searchResultsRestrictedToUser' => 'Restrict search results to videos from this user',
|
||||
'options-desc-searchResultsRestrictedToUser' => 'Only applies to search-based galleries',
|
||||
|
||||
'player-normal' => 'normally (at the top of your gallery)',
|
||||
'player-popup' => 'in a popup window',
|
||||
'player-youtube' => 'from the video\'s original YouTube page',
|
||||
'player-shadowbox' => 'with Shadowbox',
|
||||
'player-jqmodal' => 'with jqModal',
|
||||
'player-tinybox' => 'with TinyBox',
|
||||
'player-fancybox' => 'with FancyBox',
|
||||
'player-static' => 'statically (page refreshes on each thumbnail click)',
|
||||
'player-solo' => 'in a new window on its own',
|
||||
'player-vimeo' => 'from the video\'s original Vimeo page',
|
||||
'player-detached' => 'in a "detached" location (see the documentation)',
|
||||
|
||||
'order-relevance' => 'relevance',
|
||||
'order-viewCount' => 'view count',
|
||||
'order-rating' => 'rating',
|
||||
'order-published' => 'date published',
|
||||
'order-random' => 'randomly',
|
||||
'order-position' => 'position in a playlist',
|
||||
'order-commentCount' => 'comment count',
|
||||
'order-duration' => 'length',
|
||||
'order-title' => 'title',
|
||||
'order-newest' => 'newest',
|
||||
'order-oldest' => 'oldest',
|
||||
|
||||
'timeFrame-today' => 'today',
|
||||
'timeFrame-this_week' => 'this week',
|
||||
'timeFrame-this_month' => 'this month',
|
||||
'timeFrame-all_time' => 'all time',
|
||||
|
||||
'video-author' => 'Author',
|
||||
'video-category' => 'Category',
|
||||
'video-description' => 'Description',
|
||||
'video-id' => 'ID',
|
||||
'video-length' => 'Runtime',
|
||||
'video-rating' => 'Rating',
|
||||
'video-ratings' => 'Ratings',
|
||||
'video-tags' => 'Keywords',
|
||||
'video-title' => 'Title',
|
||||
'video-uploaded' => 'Posted',
|
||||
'video-url' => 'URL',
|
||||
'video-views' => 'Views',
|
||||
'video-likes' => 'Likes',
|
||||
|
||||
'validation-int-type' => '%s can only take on integer values. You supplied %s.',
|
||||
'validation-int-range' => '"%s" must be between "%d" and "%d". You supplied "%d".',
|
||||
'validation-text' => '%s must be a string. You supplied %s.',
|
||||
'validation-no-such-option' => '"%s" is not a valid option name.',
|
||||
'validation-bool' => '"%s" must be either true or false. You supplied "%s".',
|
||||
'validation-enum' => '"%s" must be one of "%s". You supplied "%s".',
|
||||
'validation-no-dots-in-path ' => 'This option cannot contain two consecutive periods',
|
||||
'validation-ffmpeg-not-executable' => '%s is not executable or does not exist.',
|
||||
'validation-directory-not-directory' => '%s is not a directory',
|
||||
'validation-directory-not-readable' => '%s is not readable',
|
||||
|
||||
'next' => 'next',
|
||||
'prev' => 'prev',
|
||||
|
||||
'widget-description' => 'Displays YouTube videos in your sidebar using TubePress',
|
||||
'widget-tagstring-description' => 'TubePress shortcode for the widget. See the <a href="http://tubepress.org/documentation"> documentation</a>.',
|
||||
|
||||
'safeSearch-none' => 'none',
|
||||
'safeSearch-moderate' => 'moderate',
|
||||
'safeSearch-strict' => 'strict',
|
||||
|
||||
'playerImplementation-provider_based' => 'Provider default',
|
||||
'playerImplementation-longtail' => 'JW FLV Media Player (by Longtail Video)',
|
||||
'playerImplementation-embedplus' => 'EmbedPlus',
|
||||
|
||||
'no-videos-found' => 'No matching videos',
|
||||
'search-input-button' => 'Search'
|
||||
);
|
||||
|
||||
/**
|
||||
* Takes a message key and provides the actual message to translate
|
||||
*
|
||||
* @param string $msgId The message id
|
||||
*
|
||||
* @return string The message translation key for gettext
|
||||
*/
|
||||
protected function _keyToMessage($msgId)
|
||||
{
|
||||
if (array_key_exists($msgId, $this->_msgs)) {
|
||||
return $this->_msgs[$msgId];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_impl_message_AbstractMessageService'
|
||||
));
|
||||
|
||||
/**
|
||||
* Message service that uses gettext (via WordPress)
|
||||
*/
|
||||
class org_tubepress_impl_message_WordPressMessageService extends org_tubepress_impl_message_AbstractMessageService
|
||||
{
|
||||
/**
|
||||
* Retrieves a message for TubePress
|
||||
*
|
||||
* @param string $msgId The message ID
|
||||
*
|
||||
* @return string The corresponding message, or "" if not found
|
||||
*/
|
||||
public function _($msgId)
|
||||
{
|
||||
$message = $this->_keyToMessage($msgId);
|
||||
return $message == '' ? '' :
|
||||
__($message, 'tubepress');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require dirname(__FILE__) . '/../classloader/ClassLoader.class.php';
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_Type',
|
||||
'org_tubepress_api_options_OptionValidator',
|
||||
'org_tubepress_api_options_StorageManager',
|
||||
'org_tubepress_impl_ioc_IocContainer',
|
||||
'org_tubepress_impl_options_OptionsReference',
|
||||
));
|
||||
|
||||
/**
|
||||
* Handles persistent storage of TubePress options
|
||||
*/
|
||||
abstract class org_tubepress_impl_options_AbstractStorageManager implements org_tubepress_api_options_StorageManager
|
||||
{
|
||||
/**
|
||||
* Creates an option in storage
|
||||
*
|
||||
* @param unknown_type $optionName The name of the option to create
|
||||
* @param unknown_type $optionValue The default value of the new option
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function create($optionName, $optionValue);
|
||||
|
||||
/**
|
||||
* Deletes an option from storage
|
||||
*
|
||||
* @param unknown_type $optionName The name of the option to delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function delete($optionName);
|
||||
|
||||
/**
|
||||
* Initialize the persistent storage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$allOptionNames = org_tubepress_impl_options_OptionsReference::getAllOptionNames();
|
||||
$vals = array();
|
||||
foreach ($allOptionNames as $optionName) {
|
||||
$vals[$optionName] = org_tubepress_impl_options_OptionsReference::getDefaultValue($optionName);
|
||||
}
|
||||
|
||||
foreach ($vals as $val => $key) {
|
||||
$this->_init($val, $key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a single option.
|
||||
*
|
||||
* @param string $name The option name.
|
||||
* @param string $value The option value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _init($name, $value)
|
||||
{
|
||||
if (!org_tubepress_impl_options_OptionsReference::shouldBePersisted($name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->exists($name)) {
|
||||
$this->delete($name);
|
||||
$this->create($name, $value);
|
||||
}
|
||||
if (org_tubepress_impl_options_OptionsReference::getType($name) != org_tubepress_api_const_options_Type::BOOL
|
||||
&& $this->get($name) == "") {
|
||||
$this->setOption($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an option value
|
||||
*
|
||||
* @param string $optionName The option name
|
||||
* @param unknown_type $optionValue The option value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($optionName, $optionValue)
|
||||
{
|
||||
if (!org_tubepress_impl_options_OptionsReference::shouldBePersisted($optionName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$validationService = $ioc->get('org_tubepress_api_options_OptionValidator');
|
||||
|
||||
$validationService->validate($optionName, $optionValue);
|
||||
$this->setOption($optionName, $optionValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an option to a new value, without validation
|
||||
*
|
||||
* @param string $optionName The name of the option to update
|
||||
* @param unknown_type $optionValue The new option value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function setOption($optionName, $optionValue);
|
||||
}
|
||||
@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
|
||||
*
|
||||
* This file is part of TubePress (http://tubepress.org)
|
||||
*
|
||||
* TubePress 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TubePress 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 TubePress. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class_exists('org_tubepress_impl_classloader_ClassLoader') || require(dirname(__FILE__) . '/../classloader/ClassLoader.class.php');
|
||||
org_tubepress_impl_classloader_ClassLoader::loadClasses(array(
|
||||
'org_tubepress_api_const_options_CategoryName',
|
||||
'org_tubepress_api_const_options_Type',
|
||||
'org_tubepress_api_const_template_Variable',
|
||||
'org_tubepress_api_filesystem_Explorer',
|
||||
'org_tubepress_api_ioc_IocService',
|
||||
'org_tubepress_api_filesystem_Explorer',
|
||||
'org_tubepress_api_options_StorageManager',
|
||||
'org_tubepress_api_message_MessageService',
|
||||
'org_tubepress_impl_options_OptionsReference',
|
||||
));
|
||||
|
||||
/**
|
||||
* Displays a generic options form for TubePress
|
||||
*
|
||||
*/
|
||||
class org_tubepress_impl_options_FormHandler
|
||||
{
|
||||
/**
|
||||
* Displays all the TubePress options in HTML
|
||||
*
|
||||
* @param org_tubepress_api_options_StorageManager $tpsm The TubePress storage manager
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getHtml()
|
||||
{
|
||||
global $tubepress_base_url;
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$messageService = $ioc->get('org_tubepress_api_message_MessageService');
|
||||
$templateBldr = $ioc->get('org_tubepress_api_template_TemplateBuilder');
|
||||
$storageManager = $ioc->get('org_tubepress_api_options_StorageManager');
|
||||
$fse = $ioc->get('org_tubepress_api_filesystem_Explorer');
|
||||
$basePath = $fse->getTubePressBaseInstallationPath();
|
||||
$template = $templateBldr->getNewTemplateInstance("$basePath/sys/ui/templates/wordpress/options_page.tpl.php");
|
||||
|
||||
/* set the surrounding text */
|
||||
$template->setVariable(org_tubepress_api_const_template_Variable::OPTIONS_PAGE_TITLE, $messageService->_('options-page-title'));
|
||||
$template->setVariable(org_tubepress_api_const_template_Variable::OPTIONS_PAGE_INTRO, $messageService->_('options-page-intro-text'));
|
||||
$template->setVariable(org_tubepress_api_const_template_Variable::OPTIONS_PAGE_SAVE, $messageService->_('options-page-save-button'));
|
||||
$template->setVariable(org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_FILTER, $messageService->_('options-page-options-filter'));
|
||||
$template->setVariable(org_tubepress_api_const_template_Variable::TUBEPRESS_BASE_URL, $tubepress_base_url);
|
||||
|
||||
$categories = array();
|
||||
|
||||
/* now parse each option category */
|
||||
$optionCategoryNames = org_tubepress_impl_options_OptionsReference::getOptionCategoryNames();
|
||||
foreach ($optionCategoryNames as $optionCategoryName) {
|
||||
|
||||
/* don't display the widget options on this page */
|
||||
if (!org_tubepress_impl_options_OptionsReference::isOptionCategoryApplicableToOptionsForm($optionCategoryName)) {
|
||||
continue;
|
||||
}
|
||||
$categories[$optionCategoryName] = $this->_createCategoryMetaArray($optionCategoryName, $messageService, $storageManager);
|
||||
}
|
||||
$template->setVariable(org_tubepress_api_const_template_Variable::OPTIONS_PAGE_CATEGORIES, $categories);
|
||||
return $template->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates options from a keyed array
|
||||
*
|
||||
* @param org_tubepress_api_options_StorageManager $tpsm The TubePress storage manager
|
||||
* @param array $postVars The POST variables
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function collect($postVars)
|
||||
{
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$storageManager = $ioc->get('org_tubepress_api_options_StorageManager');
|
||||
|
||||
/* this loop will collect everything except checkboxes */
|
||||
foreach ($postVars as $name => $value) {
|
||||
if (org_tubepress_impl_options_OptionsReference::getType($name) === org_tubepress_api_const_options_Type::BOOL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($storageManager->exists($name)) {
|
||||
$storageManager->set($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/* this loop will handle the checkboxes */
|
||||
$names = org_tubepress_impl_options_OptionsReference::getAllOptionNames();
|
||||
foreach ($names as $name) {
|
||||
|
||||
/* ignore non-bools */
|
||||
if (org_tubepress_impl_options_OptionsReference::getType($name) != org_tubepress_api_const_options_Type::BOOL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if the user checked the box, the option name will appear in the POST vars */
|
||||
$storageManager->set($name, array_key_exists($name, $postVars));
|
||||
}
|
||||
}
|
||||
|
||||
private function _createCategoryMetaArray($optionCategoryName, org_tubepress_api_message_MessageService $messageService, org_tubepress_api_options_StorageManager $storageManager)
|
||||
{
|
||||
$results = array();
|
||||
$results[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_CATEGORY_TITLE] = $messageService->_("options-category-title-$optionCategoryName");
|
||||
$results[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_CATEGORY_OPTIONS] = $optionCategoryName == org_tubepress_api_const_options_CategoryName::OUTPUT ?
|
||||
$this->_createCategoryMetaArrayForGalleryOptions($storageManager, $messageService) : $this->_createCategoryOptionsMetaArray($optionCategoryName, $messageService, $storageManager);
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function _createCategoryOptionsMetaArray($optionCategoryName, org_tubepress_api_message_MessageService $messageService,
|
||||
org_tubepress_api_options_StorageManager $storageManager)
|
||||
{
|
||||
$optionNames = org_tubepress_impl_options_OptionsReference::getOptionNamesForCategory($optionCategoryName);
|
||||
$optionsMetaArray = array();
|
||||
global $tubepress_base_url;
|
||||
|
||||
foreach ($optionNames as $optionName) {
|
||||
|
||||
if (!org_tubepress_impl_options_OptionsReference::isOptionApplicableToOptionsForm($optionName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$metaArray = array();
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_TITLE] = $messageService->_("options-title-$optionName");
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_PRO_ONLY] = org_tubepress_impl_options_OptionsReference::isOptionProOnly($optionName) ? '*' : '';
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_WIDGET] = $this->_getWidgetHtml($optionName, $storageManager, $messageService);
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_YOUTUBE_OPTION] = org_tubepress_impl_options_OptionsReference::appliesToYouTube($optionName);
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_VIMEO_OPTION] = org_tubepress_impl_options_OptionsReference::appliesToVimeo($optionName);
|
||||
|
||||
if ($optionName == org_tubepress_api_const_options_names_Display::THEME) {
|
||||
|
||||
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
|
||||
$themeHandler = $ioc->get('org_tubepress_api_theme_ThemeHandler');
|
||||
$fs = $ioc->get('org_tubepress_api_filesystem_Explorer');
|
||||
$userContentDir = $themeHandler->getUserContentDirectory();
|
||||
$baseInstallationPath = $fs->getTubePressBaseInstallationPath();
|
||||
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_DESC] = sprintf($messageService->_("options-desc-$optionName"),
|
||||
"$userContentDir/themes", "$baseInstallationPath/sys/ui/themes");
|
||||
} else {
|
||||
$metaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_DESC] = $messageService->_("options-desc-$optionName");
|
||||
}
|
||||
|
||||
$optionsMetaArray[] = $metaArray;
|
||||
}
|
||||
return $optionsMetaArray;
|
||||
}
|
||||
|
||||
private function _createCategoryMetaArrayForGalleryOptions(org_tubepress_api_options_StorageManager $storageManager, org_tubepress_api_message_MessageService $messageService)
|
||||
{
|
||||
$modeNames = org_tubepress_impl_options_OptionsReference::getValidEnumValues(org_tubepress_api_const_options_names_Output::MODE);
|
||||
$modesMetaArray = array();
|
||||
foreach ($modeNames as $modeName) {
|
||||
$modeMetaArray = array();
|
||||
$modeMetaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_TITLE] = $messageService->_("options-title-$modeName");
|
||||
$modeMetaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_PRO_ONLY] = "";
|
||||
$html = $this->_getHtmlForRadio($modeName, $storageManager);
|
||||
if (org_tubepress_impl_options_OptionsReference::isOptionName($modeName . 'Value')) {
|
||||
$newName = $modeName . 'Value';
|
||||
$html .= $this->_getWidgetHtml($newName, $storageManager, $messageService);
|
||||
}
|
||||
$modeMetaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_WIDGET] = $html;
|
||||
$modeMetaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_YOUTUBE_OPTION] = org_tubepress_impl_options_OptionsReference::appliesToYouTube($modeName);
|
||||
$modeMetaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_VIMEO_OPTION] = org_tubepress_impl_options_OptionsReference::appliesToVimeo($modeName);
|
||||
$modeMetaArray[org_tubepress_api_const_template_Variable::OPTIONS_PAGE_OPTIONS_DESC] = $messageService->_("options-desc-$modeName");
|
||||
|
||||
$modesMetaArray[] = $modeMetaArray;
|
||||
}
|
||||
return $modesMetaArray;
|
||||
}
|
||||
|
||||
private function _getWidgetHtml($optionName, org_tubepress_api_options_StorageManager $storageManager,
|
||||
org_tubepress_api_message_MessageService $messageService)
|
||||
{
|
||||
$type = org_tubepress_impl_options_OptionsReference::getType($optionName);
|
||||
$value = $storageManager->get($optionName);
|
||||
|
||||
switch ($type) {
|
||||
case org_tubepress_api_const_options_Type::BOOL:
|
||||
$checked = $value ? 'CHECKED' : '';
|
||||
return "<input type=\"checkbox\" name=\"$optionName\" value=\"$optionName\" $checked />";
|
||||
case org_tubepress_api_const_options_Type::TEXT:
|
||||
case org_tubepress_api_const_options_Type::INTEGRAL:
|
||||
return "<input type=\"text\" name=\"$optionName\" size=\"20\" value=\"$value\" />";
|
||||
case org_tubepress_api_const_options_Type::COLOR:
|
||||
return "<input type=\"text\" name=\"$optionName\" size=\"6\" class=\"color\" value=\"$value\" />";
|
||||
case org_tubepress_api_const_options_Type::ORDER:
|
||||
case org_tubepress_api_const_options_Type::PLAYER:
|
||||
case org_tubepress_api_const_options_Type::TIME_FRAME:
|
||||
case org_tubepress_api_const_options_Type::SAFE_SEARCH:
|
||||
case org_tubepress_api_const_options_Type::PLAYER_IMPL:
|
||||
$validValues = org_tubepress_impl_options_OptionsReference::getValidEnumValues($type);
|
||||
$result = "<select name=\"$optionName\">";
|
||||
|
||||
foreach ($validValues as $validValue) {
|
||||
$validValueTitle = $messageService->_("$type-$validValue");
|
||||
$selected = $validValue === $value ? 'SELECTED' : '';
|
||||
$result .= "<option value=\"$validValue\" $selected>$validValueTitle</option>";
|
||||
}
|
||||
$result .= '</select>';
|
||||
return $result;
|
||||
case org_tubepress_api_const_options_Type::THEME:
|
||||
$validValues = org_tubepress_impl_options_OptionsReference::getValidEnumValues($type);
|
||||
$result = "<select name=\"$optionName\">";
|
||||
|
||||
foreach ($validValues as $validValue) {
|
||||
$default = $validValue == 'default' && $value == '';
|
||||
$selected = $validValue === $value || $default ? 'SELECTED' : '';
|
||||
$result .= "<option value=\"$validValue\" $selected>$validValue</option>";
|
||||
}
|
||||
$result .= '</select>';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
private function _getHtmlForRadio($optionName, org_tubepress_api_options_StorageManager $storageManager)
|
||||
{
|
||||
$value = $storageManager->get(org_tubepress_api_const_options_names_Output::MODE);
|
||||
$checked = $optionName === $value ? 'CHECKED' : '';
|
||||
return "<input type=\"radio\" name=\"mode\" id=\"$optionName\" value=\"$optionName\" $checked />";
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user