diff --git a/classes/actions/ActionAdmin.class.php b/classes/actions/ActionAdmin.class.php index 85506d5c..1c49fa38 100644 --- a/classes/actions/ActionAdmin.class.php +++ b/classes/actions/ActionAdmin.class.php @@ -42,6 +42,7 @@ class ActionAdmin extends Action { $this->AddEvent('plugins','EventPlugins'); $this->AddEvent('restorecomment','EventRestoreComment'); $this->AddEvent('userfields','EventUserfields'); + $this->AddEvent('recalcfavourite','EventRecalculateFavourite'); } @@ -67,6 +68,20 @@ class ActionAdmin extends Action { $this->SetTemplateAction('index'); } + /** + * Перестроение дерева комментариев, актуально при $config['module']['comment']['use_nested'] = true; + * + */ + protected function EventRecalculateFavourite() { + set_time_limit(0); + $this->Comment_RecalculateFavourite(); + $this->Topic_RecalculateFavourite(); + $this->Cache_Clean(); + + $this->Message_AddNotice($this->Lang_Get('admin_favourites_recalculated'),$this->Lang_Get('attention')); + $this->SetTemplateAction('index'); + } + /** * Страница со списком плагинов * diff --git a/classes/actions/ActionAjax.class.php b/classes/actions/ActionAjax.class.php index 11b23d84..f6fcb748 100644 --- a/classes/actions/ActionAjax.class.php +++ b/classes/actions/ActionAjax.class.php @@ -428,9 +428,11 @@ class ActionAjax extends Action { 'target_publish' => $oTopic->getPublish() ) ); - if ($this->Topic_AddFavouriteTopic($oFavouriteTopicNew)) { + $oTopic->setCountFavourite($oTopic->getCountFavourite()+1); + if ($this->Topic_AddFavouriteTopic($oFavouriteTopicNew) and $this->Topic_UpdateTopic($oTopic)) { $this->Message_AddNoticeSingle($this->Lang_Get('topic_favourite_add_ok'),$this->Lang_Get('attention')); $this->Viewer_AssignAjax('bState',true); + $this->Viewer_AssignAjax('iCount', $oTopic->getCountFavourite()); } else { $this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error')); return; @@ -445,9 +447,11 @@ class ActionAjax extends Action { return; } if ($oFavouriteTopic and !$iType) { - if ($this->Topic_DeleteFavouriteTopic($oFavouriteTopic)) { + $oTopic->setCountFavourite($oTopic->getCountFavourite()-1); + if ($this->Topic_DeleteFavouriteTopic($oFavouriteTopic) and $this->Topic_UpdateTopic($oTopic)) { $this->Message_AddNoticeSingle($this->Lang_Get('topic_favourite_del_ok'),$this->Lang_Get('attention')); $this->Viewer_AssignAjax('bState',false); + $this->Viewer_AssignAjax('iCount', $oTopic->getCountFavourite()); } else { $this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error')); return; @@ -488,9 +492,11 @@ class ActionAjax extends Action { 'target_publish' => $oComment->getPublish() ) ); - if ($this->Comment_AddFavouriteComment($oFavouriteCommentNew)) { + $oComment->setCountFavourite($oComment->getCountFavourite()+1); + if ($this->Comment_AddFavouriteComment($oFavouriteCommentNew) and $this->Comment_UpdateComment($oComment)) { $this->Message_AddNoticeSingle($this->Lang_Get('comment_favourite_add_ok'),$this->Lang_Get('attention')); $this->Viewer_AssignAjax('bState',true); + $this->Viewer_AssignAjax('iCount', $oComment->getCountFavourite()); } else { $this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error')); return; @@ -505,9 +511,11 @@ class ActionAjax extends Action { return; } if ($oFavouriteComment and !$iType) { - if ($this->Comment_DeleteFavouriteComment($oFavouriteComment)) { + $oComment->setCountFavourite($oComment->getCountFavourite()-1); + if ($this->Comment_DeleteFavouriteComment($oFavouriteComment) and $this->Comment_UpdateComment($oComment)) { $this->Message_AddNoticeSingle($this->Lang_Get('comment_favourite_del_ok'),$this->Lang_Get('attention')); $this->Viewer_AssignAjax('bState',false); + $this->Viewer_AssignAjax('iCount', $oComment->getCountFavourite()); } else { $this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error')); return; diff --git a/classes/modules/comment/Comment.class.php b/classes/modules/comment/Comment.class.php index 9b962976..4a3c25be 100644 --- a/classes/modules/comment/Comment.class.php +++ b/classes/modules/comment/Comment.class.php @@ -886,5 +886,15 @@ class ModuleComment extends Module { } } } + + /** + * Пересчитывает счетчик избранных комментариев + * + * @return type + */ + public function RecalculateFavourite(){ + return $this->oMapper->RecalculateFavourite(); + } + } ?> \ No newline at end of file diff --git a/classes/modules/comment/entity/Comment.entity.class.php b/classes/modules/comment/entity/Comment.entity.class.php index 783a3c5c..e91769c4 100644 --- a/classes/modules/comment/entity/Comment.entity.class.php +++ b/classes/modules/comment/entity/Comment.entity.class.php @@ -87,7 +87,11 @@ class ModuleComment_EntityComment extends Entity } public function getIsFavourite() { return $this->_aData['comment_is_favourite']; - } + } + + public function getCountFavourite() { + return $this->_aData['comment_count_favourite']; + } @@ -155,6 +159,9 @@ class ModuleComment_EntityComment extends Entity } public function setIsFavourite($data) { $this->_aData['comment_is_favourite']=$data; - } + } + public function setCountFavourite($data) { + $this->_aData['comment_count_favourite']=$data; + } } ?> \ No newline at end of file diff --git a/classes/modules/comment/mapper/Comment.mapper.class.php b/classes/modules/comment/mapper/Comment.mapper.class.php index 8c72124c..e9c619a9 100644 --- a/classes/modules/comment/mapper/Comment.mapper.class.php +++ b/classes/modules/comment/mapper/Comment.mapper.class.php @@ -489,13 +489,14 @@ class ModuleComment_MapperComment extends Mapper { comment_text= ?, comment_rating= ?f, comment_count_vote= ?d, + comment_count_favourite= ?d, comment_delete = ?d , comment_publish = ?d , comment_text_hash = ? WHERE comment_id = ?d "; - if ($this->oDb->query($sql,$oComment->getText(),$oComment->getRating(),$oComment->getCountVote(),$oComment->getDelete(),$oComment->getPublish(),$oComment->getTextHash(),$oComment->getId())) { + if ($this->oDb->query($sql,$oComment->getText(),$oComment->getRating(),$oComment->getCountVote(),$oComment->getCountFavourite(),$oComment->getDelete(),$oComment->getPublish(),$oComment->getTextHash(),$oComment->getId())) { return true; } return false; @@ -649,5 +650,25 @@ class ModuleComment_MapperComment extends Mapper { } return array(); } + + public function RecalculateFavourite() { + $sql = " + UPDATE ".Config::Get('db.table.comment')." c + SET c.comment_count_favourite = ( + SELECT count(f.user_id) + FROM ".Config::Get('db.table.favourite')." f + WHERE + f.target_id = c.comment_id + AND + f.target_publish = 1 + AND + f.target_type = 'comment' + ) + "; + if ($this->oDb->query($sql)) { + return true; + } + return false; + } } ?> \ No newline at end of file diff --git a/classes/modules/topic/Topic.class.php b/classes/modules/topic/Topic.class.php index b1348125..0381f22f 100644 --- a/classes/modules/topic/Topic.class.php +++ b/classes/modules/topic/Topic.class.php @@ -1635,6 +1635,15 @@ class ModuleTopic extends Module { return $this->Image_GetWebPath($sFile); } + + /** + * Пересчитывает счетчик избранных топиков + * + * @return type + */ + public function RecalculateFavourite(){ + return $this->oMapperTopic->RecalculateFavourite(); + } } ?> \ No newline at end of file diff --git a/classes/modules/topic/entity/Topic.entity.class.php b/classes/modules/topic/entity/Topic.entity.class.php index 102457b4..57ffe8d5 100644 --- a/classes/modules/topic/entity/Topic.entity.class.php +++ b/classes/modules/topic/entity/Topic.entity.class.php @@ -130,6 +130,9 @@ class ModuleTopic_EntityTopic extends Entity public function getIsFavourite() { return $this->_aData['topic_is_favourite']; } + public function getCountFavourite() { + return $this->_aData['topic_count_favourite']; + } /*************************************************************************************************************************************************** * методы расширения типов топика @@ -394,6 +397,8 @@ class ModuleTopic_EntityTopic extends Entity public function setIsFavourite($data) { $this->_aData['topic_is_favourite']=$data; } - + public function setCountFavourite($data) { + $this->_aData['topic_count_favourite']=$data; + } } ?> \ No newline at end of file diff --git a/classes/modules/topic/mapper/Topic.mapper.class.php b/classes/modules/topic/mapper/Topic.mapper.class.php index f39203ea..540ae4ff 100644 --- a/classes/modules/topic/mapper/Topic.mapper.class.php +++ b/classes/modules/topic/mapper/Topic.mapper.class.php @@ -383,13 +383,14 @@ class ModuleTopic_MapperTopic extends Mapper { topic_count_vote= ?d, topic_count_read= ?d, topic_count_comment= ?d, + topic_count_favourite= ?d, topic_cut_text = ? , topic_forbid_comment = ? , topic_text_hash = ? WHERE topic_id = ?d "; - if ($this->oDb->query($sql,$oTopic->getBlogId(),$oTopic->getTitle(),$oTopic->getTags(),$oTopic->getDateAdd(),$oTopic->getDateEdit(),$oTopic->getUserIp(),$oTopic->getPublish(),$oTopic->getPublishDraft(),$oTopic->getPublishIndex(),$oTopic->getRating(),$oTopic->getCountVote(),$oTopic->getCountRead(),$oTopic->getCountComment(),$oTopic->getCutText(),$oTopic->getForbidComment(),$oTopic->getTextHash(),$oTopic->getId())) { + if ($this->oDb->query($sql,$oTopic->getBlogId(),$oTopic->getTitle(),$oTopic->getTags(),$oTopic->getDateAdd(),$oTopic->getDateEdit(),$oTopic->getUserIp(),$oTopic->getPublish(),$oTopic->getPublishDraft(),$oTopic->getPublishIndex(),$oTopic->getRating(),$oTopic->getCountVote(),$oTopic->getCountRead(),$oTopic->getCountComment(),$oTopic->getCountFavourite(),$oTopic->getCutText(),$oTopic->getForbidComment(),$oTopic->getTextHash(),$oTopic->getId())) { $this->UpdateTopicContent($oTopic); return true; } @@ -798,5 +799,25 @@ class ModuleTopic_MapperTopic extends Mapper { id= ?d'; $this->oDb->query($sql, $iPhotoId); } + + public function RecalculateFavourite() { + $sql = " + UPDATE ".Config::Get('db.table.topic')." t + SET t.topic_count_favourite = ( + SELECT count(f.user_id) + FROM ".Config::Get('db.table.favourite')." f + WHERE + f.target_id = t.topic_id + AND + f.target_publish = 1 + AND + f.target_type = 'topic' + ) + "; + if ($this->oDb->query($sql)) { + return true; + } + return false; + } } ?> \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/COPYING b/engine/lib/external/CSSTidy-1.3/COPYING index 3912109b..623b9576 100644 --- a/engine/lib/external/CSSTidy-1.3/COPYING +++ b/engine/lib/external/CSSTidy-1.3/COPYING @@ -1,340 +1,177 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 +GNU LESSER GENERAL PUBLIC LICENSE - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Version 2.1, February 1999 - Preamble +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +Preamble - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. + * a) The modified work must itself be a software library. + * b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + * c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + * d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - NO WARRANTY +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - 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. +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - - Copyright (C) +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - 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. +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + * a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + * b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + * c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + * d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + * e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + * b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + +one line to give the library's name and an idea of what it does. +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice diff --git a/engine/lib/external/CSSTidy-1.3/NEWS b/engine/lib/external/CSSTidy-1.3/NEWS new file mode 100644 index 00000000..4862c658 --- /dev/null +++ b/engine/lib/external/CSSTidy-1.3/NEWS @@ -0,0 +1,28 @@ +Changelog + +Key: # = backwards incompatible change, ! = new feature, - = bugfix. + +1.4, unknown release date +# CSSTidy is now licensed under LGPL! +! csstidy->set_cfg now accept a single parameter, an associative array, to + set all configuration options +! Templates can now be loaded via set_cfg using the 'template' config + parameter +! csstidy_print->formatted_page added, returns a full XHTML page based + off of csstidy_print->formatted +! cssparsed.css created, contains just the CSS for formatted CSS output +! New CSS 3 units "ch" and "turn" added +! Unit tests added, requires Text_Diff (PEAR) and SimpleTest +! Some invalid selectors are now removed during optimization, this can + be turned off by setting 'discard_invalid_selectors' to false +- Added localizations for css_optimiser.php +- Fixed bug with cookie setting for custom templates +- Minor security problem in css_optimiser.php fixed +- Fixed bug with float handling in exotic locales +- Fixed bug with non-functioning getenv in ASAPI +- Fixed bug with bad hexadecimal syntax recovery +- At-selectors optimized by removing unnecessary url() +- Fixed optimisation: 1.0 was not optimised to 1 +- Fixed incorrect parsing of !imporant close to numbers +- Allowed Copy to Clipboard for Firefox if preference set (if not, gives + instructions on how to add and warning re: security) \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/README b/engine/lib/external/CSSTidy-1.3/README index d2e8096f..7d82dbbe 100644 --- a/engine/lib/external/CSSTidy-1.3/README +++ b/engine/lib/external/CSSTidy-1.3/README @@ -1,28 +1,43 @@ -CSSTidy - -Changelog: http://cdburnerxp.se/cssparse/csstidy/changelog.php - -css_optimiser.php is the web-interface, css_parser.php contains the PHP class (CSSTidy). - -This class represents a CSS parser which reads CSS code and saves it in an array. -In opposite to most other CSS parsers, it does not use regular expressions and -thus has full CSS2 support and a higher reliability. The downside of not using regular expressions -is a lower speed though. -Additional to that it applies some optimisations and fixes to the CSS code. -An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php - - - -CSSTidy is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -CSSTidy 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 CSSTidy; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +CSSTidy +--- + +CSSTidy is a CSS minifier +Since the original project (http://csstidy.sourceforge.net/index.php) has been suspended +here is the import of https://csstidy.svn.sourceforge.net/svnroot/csstidy on 2010-11-14 + +master branch corresponds to the trunk of svn repository and shoul be stabilized +v1.3 branch corresponds to the last stable relase published by the author. +It integrates some bugfixes and a 1.3.1 version has been taged +Only PHP version is here maintained + +--- + +CSSTidy + +Original Tracker : +http://sourceforge.net/tracker/?group_id=148404&atid=771415 + +css_optimiser.php is the web-interface, css_parser.php contains the PHP class (CSSTidy). + +This class represents a CSS parser which reads CSS code and saves it in an array. +In opposite to most other CSS parsers, it does not use regular expressions and +thus has full CSS2 support and a higher reliability. The downside of not using regular expressions +is a lower speed though. +Additional to that it applies some optimisations and fixes to the CSS code. +An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php + + + Copyright 2005, 2006, 2007 Florian Schmitz + + CSSTidy is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + CSSTidy 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . diff --git a/engine/lib/external/CSSTidy-1.3/class.csstidy.php b/engine/lib/external/CSSTidy-1.3/class.csstidy.php index 5ab4cf90..1084627e 100644 --- a/engine/lib/external/CSSTidy-1.3/class.csstidy.php +++ b/engine/lib/external/CSSTidy-1.3/class.csstidy.php @@ -1,29 +1,40 @@ . * - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License * @package csstidy - * @author Florian Schmitz (floele at gmail dot com) 2005-2006 + * @author Florian Schmitz (floele at gmail dot com) 2005-2007 + * @author Brett Zamir (brettz9 at yahoo dot com) 2007 + * @author Nikolay Matsievsky (speed at webo dot name) 2009-2010 + * @author Cedric Morin (cedric at yterium dot com) 2010 */ +/** + * Defines ctype functions if required + * + * @version 1.0 + */ +require_once('class.csstidy_ctype.php'); /** * Various CSS data needed for correct optimisations etc. @@ -49,6 +60,7 @@ require('class.csstidy_optimise.php'); /** * CSS Parser class * + * This class represents a CSS parser which reads CSS code and saves it in an array. * In opposite to most other CSS parsers, it does not use regular expressions and * thus has full CSS2 support and a higher reliability. @@ -56,949 +68,1052 @@ require('class.csstidy_optimise.php'); * An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php * @package csstidy * @author Florian Schmitz (floele at gmail dot com) 2005-2006 - * @version 1.3 + * @version 1.3.1 */ class csstidy { -/** - * Saves the parsed CSS - * @var array - * @access public - */ -var $css = array(); + /** + * Saves the parsed CSS. This array is empty if preserve_css is on. + * @var array + * @access public + */ + var $css = array(); + /** + * Saves the parsed CSS (raw) + * @var array + * @access private + */ + var $tokens = array(); + /** + * Printer class + * @see csstidy_print + * @var object + * @access public + */ + var $print; + /** + * Optimiser class + * @see csstidy_optimise + * @var object + * @access private + */ + var $optimise; + /** + * Saves the CSS charset (@charset) + * @var string + * @access private + */ + var $charset = ''; + /** + * Saves all @import URLs + * @var array + * @access private + */ + var $import = array(); + /** + * Saves the namespace + * @var string + * @access private + */ + var $namespace = ''; + /** + * Contains the version of csstidy + * @var string + * @access private + */ + var $version = '1.3'; + /** + * Stores the settings + * @var array + * @access private + */ + var $settings = array(); + /** + * Saves the parser-status. + * + * Possible values: + * - is = in selector + * - ip = in property + * - iv = in value + * - instr = in string (started at " or ' or ( ) + * - ic = in comment (ignore everything) + * - at = in @-block + * + * @var string + * @access private + */ + var $status = 'is'; + /** + * Saves the current at rule (@media) + * @var string + * @access private + */ + var $at = ''; + /** + * Saves the current selector + * @var string + * @access private + */ + var $selector = ''; + /** + * Saves the current property + * @var string + * @access private + */ + var $property = ''; + /** + * Saves the position of , in selectors + * @var array + * @access private + */ + var $sel_separate = array(); + /** + * Saves the current value + * @var string + * @access private + */ + var $value = ''; + /** + * Saves the current sub-value + * + * Example for a subvalue: + * background:url(foo.png) red no-repeat; + * "url(foo.png)", "red", and "no-repeat" are subvalues, + * seperated by whitespace + * @var string + * @access private + */ + var $sub_value = ''; + /** + * Array which saves all subvalues for a property. + * @var array + * @see sub_value + * @access private + */ + var $sub_value_arr = array(); + /** + * Saves the char which opened the last string + * @var string + * @access private + */ + var $str_char = ''; + var $cur_string = ''; + /** + * Status from which the parser switched to ic or instr + * @var string + * @access private + */ + var $from = ''; + /** + * Variable needed to manage string-in-strings, for example url("foo.png") + * @var string + * @access private + */ + var $str_in_str = false; + /** + * =true if in invalid at-rule + * @var bool + * @access private + */ + var $invalid_at = false; + /** + * =true if something has been added to the current selector + * @var bool + * @access private + */ + var $added = false; + /** + * Array which saves the message log + * @var array + * @access private + */ + var $log = array(); + /** + * Saves the line number + * @var integer + * @access private + */ + var $line = 1; + /** + * Marks if we need to leave quotes for a string + * @var string + * @access private + */ + var $quoted_string = false; -/** - * Saves the parsed CSS (raw) - * @var array - * @access private - */ -var $tokens = array(); + /** + * List of tokens + * @var string + */ + var $tokens_list = ""; + /** + * Loads standard template and sets default settings + * @access private + * @version 1.3 + */ + function csstidy() { + $this->settings['remove_bslash'] = true; + $this->settings['compress_colors'] = true; + $this->settings['compress_font-weight'] = true; + $this->settings['lowercase_s'] = false; + /* + 1 common shorthands optimization + 2 + font property optimization + 3 + background property optimization + */ + $this->settings['optimise_shorthands'] = 1; + $this->settings['remove_last_;'] = true; + /* rewrite all properties with low case, better for later gzip OK, safe*/ + $this->settings['case_properties'] = 1; + /* sort properties in alpabetic order, better for later gzip + * but can cause trouble in case of overiding same propertie or using hack + */ + $this->settings['sort_properties'] = false; + /* + 1, 3, 5, etc -- enable sorting selectors inside @media: a{}b{}c{} + 2, 5, 8, etc -- enable sorting selectors inside one CSS declaration: a,b,c{} + preserve order by default cause it can break functionnality + */ + $this->settings['sort_selectors'] = 0; + /* is dangeroues to be used: CSS is broken sometimes */ + $this->settings['merge_selectors'] = 0; + /* preserve or not browser hacks */ + $this->settings['discard_invalid_selectors'] = false; + $this->settings['discard_invalid_properties'] = false; + $this->settings['css_level'] = 'CSS2.1'; + $this->settings['preserve_css'] = false; + $this->settings['timestamp'] = false; + $this->settings['template'] = ''; // say that propertie exist + $this->set_cfg('template','default'); // call load_template + $this->optimise = new csstidy_optimise($this); -/** - * Printer class - * @see csstidy_print - * @var object - * @access public - */ -var $print; - -/** - * Optimiser class - * @see csstidy_optimise - * @var object - * @access private - */ -var $optimise; - -/** - * Saves the CSS charset (@charset) - * @var string - * @access private - */ -var $charset = ''; - -/** - * Saves all @import URLs - * @var array - * @access private - */ -var $import = array(); - -/** - * Saves the namespace - * @var string - * @access private - */ -var $namespace = ''; - -/** - * Contains the version of csstidy - * @var string - * @access private - */ -var $version = '1.3'; - -/** - * Stores the settings - * @var array - * @access private - */ -var $settings = array(); - -/** - * Saves the parser-status. - * - * Possible values: - * - is = in selector - * - ip = in property - * - iv = in value - * - instr = in string (started at " or ' or ( ) - * - ic = in comment (ignore everything) - * - at = in @-block - * - * @var string - * @access private - */ -var $status = 'is'; - - -/** - * Saves the current at rule (@media) - * @var string - * @access private - */ -var $at = ''; - -/** - * Saves the current selector - * @var string - * @access private - */ -var $selector = ''; - -/** - * Saves the current property - * @var string - * @access private - */ -var $property = ''; - -/** - * Saves the position of , in selectors - * @var array - * @access private - */ -var $sel_separate = array(); - -/** - * Saves the current value - * @var string - * @access private - */ -var $value = ''; - -/** - * Saves the current sub-value - * - * Example for a subvalue: - * background:url(foo.png) red no-repeat; - * "url(foo.png)", "red", and "no-repeat" are subvalues, - * seperated by whitespace - * @var string - * @access private - */ -var $sub_value = ''; - -/** - * Array which saves all subvalues for a property. - * @var array - * @see sub_value - * @access private - */ -var $sub_value_arr = array(); - -/** - * Saves the char which opened the last string - * @var string - * @access private - */ -var $str_char = ''; -var $cur_string = ''; - -/** - * Status from which the parser switched to ic or instr - * @var string - * @access private - */ -var $from = ''; - -/** - * Variable needed to manage string-in-strings, for example url("foo.png") - * @var string - * @access private - */ -var $str_in_str = false; - -/** - * =true if in invalid at-rule - * @var bool - * @access private - */ -var $invalid_at = false; - -/** - * =true if something has been added to the current selector - * @var bool - * @access private - */ -var $added = false; - -/** - * Array which saves the message log - * @var array - * @access private - */ -var $log = array(); - -/** - * Saves the line number - * @var integer - * @access private - */ -var $line = 1; - -/** - * Loads standard template and sets default settings - * @access private - * @version 1.3 - */ -function csstidy() -{ - $this->settings['remove_bslash'] = true; - $this->settings['compress_colors'] = true; - $this->settings['compress_font-weight'] = true; - $this->settings['lowercase_s'] = false; - $this->settings['optimise_shorthands'] = 1; - $this->settings['remove_last_;'] = false; - $this->settings['case_properties'] = 1; - $this->settings['sort_properties'] = false; - $this->settings['sort_selectors'] = false; - $this->settings['merge_selectors'] = 2; - $this->settings['discard_invalid_properties'] = false; - $this->settings['css_level'] = 'CSS2.1'; - $this->settings['preserve_css'] = false; - $this->settings['timestamp'] = false; - - $this->load_template('default'); - $this->print = new csstidy_print($this); - $this->optimise = new csstidy_optimise($this); -} - -/** - * Get the value of a setting. - * @param string $setting - * @access public - * @return mixed - * @version 1.0 - */ -function get_cfg($setting) -{ - if(isset($this->settings[$setting])) - { - return $this->settings[$setting]; + $this->tokens_list = & $GLOBALS['csstidy']['tokens']; } - return false; -} -/** - * Set the value of a setting. - * @param string $setting - * @param mixed $value - * @access public - * @return bool - * @version 1.0 - */ -function set_cfg($setting,$value) -{ - if(isset($this->settings[$setting]) && $value !== '') - { - $this->settings[$setting] = $value; - return true; - } - return false; -} - -/** - * Adds a token to $this->tokens - * @param mixed $type - * @param string $data - * @param bool $do add a token even if preserve_css is off - * @access private - * @version 1.0 - */ -function _add_token($type, $data, $do = false) { - if($this->get_cfg('preserve_css') || $do) { - $this->tokens[] = array($type, ($type == COMMENT) ? $data : trim($data)); - } -} - -/** - * Add a message to the message log - * @param string $message - * @param string $type - * @param integer $line - * @access private - * @version 1.0 - */ -function log($message,$type,$line = -1) -{ - if($line === -1) - { - $line = $this->line; - } - $line = intval($line); - $add = array('m' => $message, 't' => $type); - if(!isset($this->log[$line]) || !in_array($add,$this->log[$line])) - { - $this->log[$line][] = $add; - } -} - -/** - * Parse unicode notations and find a replacement character - * @param string $string - * @param integer $i - * @access private - * @return string - * @version 1.2 - */ -function _unicode(&$string, &$i) -{ - ++$i; - $add = ''; - $tokens =& $GLOBALS['csstidy']['tokens']; - $replaced = false; - - while($i < strlen($string) && (ctype_xdigit($string{$i}) || ctype_space($string{$i})) && strlen($add) < 6) - { - $add .= $string{$i}; - - if(ctype_space($string{$i})) { - break; + /** + * Get the value of a setting. + * @param string $setting + * @access public + * @return mixed + * @version 1.0 + */ + function get_cfg($setting) { + if (isset($this->settings[$setting])) { + return $this->settings[$setting]; } - $i++; - } - - if(hexdec($add) > 47 && hexdec($add) < 58 || hexdec($add) > 64 && hexdec($add) < 91 || hexdec($add) > 96 && hexdec($add) < 123) - { - $this->log('Replaced unicode notation: Changed \\'. $add .' to ' . chr(hexdec($add)),'Information'); - $add = chr(hexdec($add)); - $replaced = true; - } - else { - $add = trim('\\'.$add); - } - - if(@ctype_xdigit($string{$i+1}) && ctype_space($string{$i}) - && !$replaced || !ctype_space($string{$i})) { - $i--; - } - - if($add != '\\' || !$this->get_cfg('remove_bslash') || strpos($tokens, $string{$i+1}) !== false) { - return $add; - } - - if($add == '\\') { - $this->log('Removed unnecessary backslash','Information'); - } - return ''; -} - -/** - * Loads a new template - * @param string $content either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default" - * @param bool $from_file uses $content as filename if true - * @access public - * @version 1.1 - * @see http://csstidy.sourceforge.net/templates.php - */ -function load_template($content, $from_file=true) -{ - $predefined_templates =& $GLOBALS['csstidy']['predefined_templates']; - if($content == 'high_compression' || $content == 'default' || $content == 'highest_compression' || $content == 'low_compression') - { - $this->template = $predefined_templates[$content]; - return; - } - - if($from_file) - { - $content = strip_tags(file_get_contents($content),''); - } - $content = str_replace("\r\n","\n",$content); // Unify newlines (because the output also only uses \n) - $template = explode('|',$content); - - for ($i = 0; $i < count($template); $i++ ) - { - $this->template[$i] = $template[$i]; - } -} - -/** - * Starts parsing from URL - * @param string $url - * @access public - * @version 1.0 - */ -function parse_from_url($url) -{ - return $this->parse(@file_get_contents($url)); -} - -/** - * Checks if there is a token at the current position - * @param string $string - * @param integer $i - * @access public - * @version 1.11 - */ -function is_token(&$string, $i) -{ - $tokens =& $GLOBALS['csstidy']['tokens']; - return (strpos($tokens, $string{$i}) !== false && !csstidy::escaped($string,$i)); -} - - -/** - * Parses CSS in $string. The code is saved as array in $this->css - * @param string $string the CSS code - * @access public - * @return bool - * @version 1.1 - */ -function parse($string) { - // PHP bug? Settings need to be refreshed in PHP4 - $this->print = new csstidy_print($this); - $this->optimise = new csstidy_optimise($this); - - $all_properties =& $GLOBALS['csstidy']['all_properties']; - $at_rules =& $GLOBALS['csstidy']['at_rules']; - - $this->css = array(); - $this->print->input_css = $string; - $string = str_replace("\r\n","\n",$string) . ' '; - $cur_comment = ''; - - for ($i = 0, $size = strlen($string); $i < $size; $i++ ) - { - if($string{$i} == "\n" || $string{$i} == "\r") - { - ++$this->line; - } - - switch($this->status) - { - /* Case in at-block */ - case 'at': - if(csstidy::is_token($string,$i)) - { - if($string{$i} == '/' && @$string{$i+1} == '*') - { - $this->status = 'ic'; ++$i; - $this->from = 'at'; - } - elseif($string{$i} == '{') - { - $this->status = 'is'; - $this->_add_token(AT_START, $this->at); - } - elseif($string{$i} == ',') - { - $this->at = trim($this->at).','; - } - elseif($string{$i} == '\\') - { - $this->at .= $this->_unicode($string,$i); - } - } - else - { - $lastpos = strlen($this->at)-1; - if(!( (ctype_space($this->at{$lastpos}) || csstidy::is_token($this->at,$lastpos) && $this->at{$lastpos} == ',') && ctype_space($string{$i}))) - { - $this->at .= $string{$i}; - } - } - break; - - /* Case in-selector */ - case 'is': - if(csstidy::is_token($string,$i)) - { - if($string{$i} == '/' && @$string{$i+1} == '*' && trim($this->selector) == '') - { - $this->status = 'ic'; ++$i; - $this->from = 'is'; - } - elseif($string{$i} == '@' && trim($this->selector) == '') - { - // Check for at-rule - $this->invalid_at = true; - foreach($at_rules as $name => $type) - { - if(!strcasecmp(substr($string,$i+1,strlen($name)),$name)) - { - ($type == 'at') ? $this->at = '@'.$name : $this->selector = '@'.$name; - $this->status = $type; - $i += strlen($name); - $this->invalid_at = false; - } - } - - if($this->invalid_at) - { - $this->selector = '@'; - $invalid_at_name = ''; - for($j = $i+1; $j < $size; ++$j) - { - if(!ctype_alpha($string{$j})) - { - break; - } - $invalid_at_name .= $string{$j}; - } - $this->log('Invalid @-rule: '.$invalid_at_name.' (removed)','Warning'); - } - } - elseif(($string{$i} == '"' || $string{$i} == "'")) - { - $this->cur_string = $string{$i}; - $this->status = 'instr'; - $this->str_char = $string{$i}; - $this->from = 'is'; - } - elseif($this->invalid_at && $string{$i} == ';') - { - $this->invalid_at = false; - $this->status = 'is'; - } - elseif($string{$i} == '{') - { - $this->status = 'ip'; - $this->_add_token(SEL_START, $this->selector); - $this->added = false; - } - elseif($string{$i} == '}') - { - $this->_add_token(AT_END, $this->at); - $this->at = ''; - $this->selector = ''; - $this->sel_separate = array(); - } - elseif($string{$i} == ',') - { - $this->selector = trim($this->selector).','; - $this->sel_separate[] = strlen($this->selector); - } - elseif($string{$i} == '\\') - { - $this->selector .= $this->_unicode($string,$i); - } - // remove unnecessary universal selector, FS#147 - else if(!($string{$i} == '*' && @in_array($string{$i+1}, array('.', '#', '[', ':')))) { - $this->selector .= $string{$i}; - } - } - else - { - $lastpos = strlen($this->selector)-1; - if($lastpos == -1 || !( (ctype_space($this->selector{$lastpos}) || csstidy::is_token($this->selector,$lastpos) && $this->selector{$lastpos} == ',') && ctype_space($string{$i}))) - { - $this->selector .= $string{$i}; - } - } - break; - - /* Case in-property */ - case 'ip': - if(csstidy::is_token($string,$i)) - { - if(($string{$i} == ':' || $string{$i} == '=') && $this->property != '') - { - $this->status = 'iv'; - if(!$this->get_cfg('discard_invalid_properties') || csstidy::property_is_valid($this->property)) { - $this->_add_token(PROPERTY, $this->property); - } - } - elseif($string{$i} == '/' && @$string{$i+1} == '*' && $this->property == '') - { - $this->status = 'ic'; ++$i; - $this->from = 'ip'; - } - elseif($string{$i} == '}') - { - $this->explode_selectors(); - $this->status = 'is'; - $this->invalid_at = false; - $this->_add_token(SEL_END, $this->selector); - $this->selector = ''; - $this->property = ''; - } - elseif($string{$i} == ';') - { - $this->property = ''; - } - elseif($string{$i} == '\\') - { - $this->property .= $this->_unicode($string,$i); - } - } - elseif(!ctype_space($string{$i})) - { - $this->property .= $string{$i}; - } - break; - - /* Case in-value */ - case 'iv': - $pn = (($string{$i} == "\n" || $string{$i} == "\r") && $this->property_is_next($string,$i+1) || $i == strlen($string)-1); - if(csstidy::is_token($string,$i) || $pn) - { - if($string{$i} == '/' && @$string{$i+1} == '*') - { - $this->status = 'ic'; ++$i; - $this->from = 'iv'; - } - elseif(($string{$i} == '"' || $string{$i} == "'" || $string{$i} == '(')) - { - $this->cur_string = $string{$i}; - $this->str_char = ($string{$i} == '(') ? ')' : $string{$i}; - $this->status = 'instr'; - $this->from = 'iv'; - } - elseif($string{$i} == ',') - { - $this->sub_value = trim($this->sub_value).','; - } - elseif($string{$i} == '\\') - { - $this->sub_value .= $this->_unicode($string,$i); - } - elseif($string{$i} == ';' || $pn) - { - if($this->selector{0} == '@' && isset($at_rules[substr($this->selector,1)]) && $at_rules[substr($this->selector,1)] == 'iv') - { - $this->sub_value_arr[] = trim($this->sub_value); - - $this->status = 'is'; - - switch($this->selector) - { - case '@charset': $this->charset = $this->sub_value_arr[0]; break; - case '@namespace': $this->namespace = implode(' ',$this->sub_value_arr); break; - case '@import': $this->import[] = implode(' ',$this->sub_value_arr); break; - } - - $this->sub_value_arr = array(); - $this->sub_value = ''; - $this->selector = ''; - $this->sel_separate = array(); - } - else - { - $this->status = 'ip'; - } - } - elseif($string{$i} != '}') - { - $this->sub_value .= $string{$i}; - } - if(($string{$i} == '}' || $string{$i} == ';' || $pn) && !empty($this->selector)) - { - if($this->at == '') - { - $this->at = DEFAULT_AT; - } - - // case settings - if($this->get_cfg('lowercase_s')) - { - $this->selector = strtolower($this->selector); - } - $this->property = strtolower($this->property); - - $this->optimise->subvalue(); - if($this->sub_value != '') { - $this->sub_value_arr[] = $this->sub_value; - $this->sub_value = ''; - } - - $this->value = implode(' ',$this->sub_value_arr); - - $this->selector = trim($this->selector); - - $this->optimise->value(); - - $valid = csstidy::property_is_valid($this->property); - if((!$this->invalid_at || $this->get_cfg('preserve_css')) && (!$this->get_cfg('discard_invalid_properties') || $valid)) - { - $this->css_add_property($this->at,$this->selector,$this->property,$this->value); - $this->_add_token(VALUE, $this->value); - $this->optimise->shorthands(); - } - if(!$valid) - { - if($this->get_cfg('discard_invalid_properties')) - { - $this->log('Removed invalid property: '.$this->property,'Warning'); - } - else - { - $this->log('Invalid property in '.strtoupper($this->get_cfg('css_level')).': '.$this->property,'Warning'); - } - } - - $this->property = ''; - $this->sub_value_arr = array(); - $this->value = ''; - } - if($string{$i} == '}') - { - $this->explode_selectors(); - $this->_add_token(SEL_END, $this->selector); - $this->status = 'is'; - $this->invalid_at = false; - $this->selector = ''; - } - } - elseif(!$pn) - { - $this->sub_value .= $string{$i}; - - if(ctype_space($string{$i})) - { - $this->optimise->subvalue(); - if($this->sub_value != '') { - $this->sub_value_arr[] = $this->sub_value; - $this->sub_value = ''; - } - } - } - break; - - /* Case in string */ - case 'instr': - if($this->str_char == ')' && ($string{$i} == '"' || $string{$i} == '\'') && !$this->str_in_str && !csstidy::escaped($string,$i)) - { - $this->str_in_str = true; - } - elseif($this->str_char == ')' && ($string{$i} == '"' || $string{$i} == '\'') && $this->str_in_str && !csstidy::escaped($string,$i)) - { - $this->str_in_str = false; - } - $temp_add = $string{$i}; // ...and no not-escaped backslash at the previous position - if( ($string{$i} == "\n" || $string{$i} == "\r") && !($string{$i-1} == '\\' && !csstidy::escaped($string,$i-1)) ) - { - $temp_add = "\\A "; - $this->log('Fixed incorrect newline in string','Warning'); - } - if (!($this->str_char == ')' && in_array($string{$i}, $GLOBALS['csstidy']['whitespace']) && !$this->str_in_str)) { - $this->cur_string .= $temp_add; - } else { - // path http://www.pixelastic.com/blog/188:css3-gradients-with-csstidy - if ($this->sub_value=="-webkit-gradient" || $this->sub_value=="-moz-linear-gradient") { - $this->cur_string.=' '; - } - } - if($string{$i} == $this->str_char && !csstidy::escaped($string,$i) && !$this->str_in_str) - { - $this->status = $this->from; - if (!preg_match('|[' . implode('', $GLOBALS['csstidy']['whitespace']) . ']|uis', $this->cur_string) && $this->property != 'content') { - if ($this->str_char == '"' || $this->str_char == '\'') { - $this->cur_string = substr($this->cur_string, 1, -1); - } else if (strlen($this->cur_string) > 3 && ($this->cur_string[1] == '"' || $this->cur_string[1] == '\'')) /* () */ { - $this->cur_string = $this->cur_string[0] . substr($this->cur_string, 2, -2) . substr($this->cur_string, -1); - } - } - if($this->from == 'iv') - { - $this->sub_value .= $this->cur_string; - } - elseif($this->from == 'is') - { - $this->selector .= $this->cur_string; - } - } - break; - - /* Case in-comment */ - case 'ic': - if($string{$i} == '*' && $string{$i+1} == '/') - { - $this->status = $this->from; - $i++; - $this->_add_token(COMMENT, $cur_comment); - $cur_comment = ''; - } - else - { - $cur_comment .= $string{$i}; - } - break; - } - } - - $this->optimise->postparse(); - - $this->print->_reset(); - - return !(empty($this->css) && empty($this->import) && empty($this->charset) && empty($this->tokens) && empty($this->namespace)); -} - -/** - * Explodes selectors - * @access private - * @version 1.0 - */ -function explode_selectors() -{ - // Explode multiple selectors - if($this->get_cfg('merge_selectors') == 1) - { - $new_sels = array(); - $lastpos = 0; - $this->sel_separate[] = strlen($this->selector); - foreach($this->sel_separate as $num => $pos) - { - if($num == count($this->sel_separate)-1) { - $pos += 1; - } - - $new_sels[] = substr($this->selector,$lastpos,$pos-$lastpos-1); - $lastpos = $pos; - } - - if(count($new_sels) > 1) - { - foreach($new_sels as $selector) - { - $this->merge_css_blocks($this->at,$selector,$this->css[$this->at][$this->selector]); - } - unset($this->css[$this->at][$this->selector]); - } - } - $this->sel_separate = array(); -} - -/** - * Checks if a character is escaped (and returns true if it is) - * @param string $string - * @param integer $pos - * @access public - * @return bool - * @version 1.02 - */ -function escaped(&$string,$pos) -{ - return !(@($string{$pos-1} != '\\') || csstidy::escaped($string,$pos-1)); -} - -/** - * Adds a property with value to the existing CSS code - * @param string $media - * @param string $selector - * @param string $property - * @param string $new_val - * @access private - * @version 1.2 - */ -function css_add_property($media,$selector,$property,$new_val) -{ - if($this->get_cfg('preserve_css') || trim($new_val) == '') { - return; - } - - $this->added = true; - if(isset($this->css[$media][$selector][$property])) - { - if((csstidy::is_important($this->css[$media][$selector][$property]) && csstidy::is_important($new_val)) || !csstidy::is_important($this->css[$media][$selector][$property])) - { - unset($this->css[$media][$selector][$property]); - $this->css[$media][$selector][$property] = trim($new_val); - } - } - else - { - $this->css[$media][$selector][$property] = trim($new_val); - } -} - -/** - * Adds CSS to an existing media/selector - * @param string $media - * @param string $selector - * @param array $css_add - * @access private - * @version 1.1 - */ -function merge_css_blocks($media,$selector,$css_add) -{ - foreach($css_add as $property => $value) - { - $this->css_add_property($media,$selector,$property,$value,false); - } -} - -/** - * Checks if $value is !important. - * @param string $value - * @return bool - * @access public - * @version 1.0 - */ -function is_important(&$value) -{ - return (!strcasecmp(substr(str_replace($GLOBALS['csstidy']['whitespace'],'',$value),-10,10),'!important')); -} - -/** - * Returns a value without !important - * @param string $value - * @return string - * @access public - * @version 1.0 - */ -function gvw_important($value) -{ - if(csstidy::is_important($value)) - { - $value = trim($value); - $value = substr($value,0,-9); - $value = trim($value); - $value = substr($value,0,-1); - $value = trim($value); - return $value; - } - return $value; -} - -/** - * Checks if the next word in a string from pos is a CSS property - * @param string $istring - * @param integer $pos - * @return bool - * @access private - * @version 1.2 - */ -function property_is_next($istring, $pos) -{ - $all_properties =& $GLOBALS['csstidy']['all_properties']; - $istring = substr($istring,$pos,strlen($istring)-$pos); - $pos = strpos($istring,':'); - if($pos === false) - { return false; } - $istring = strtolower(trim(substr($istring,0,$pos))); - if(isset($all_properties[$istring])) - { - $this->log('Added semicolon to the end of declaration','Warning'); - return true; + + /** + * Load a template + * @param string $template used by set_cfg to load a template via a configuration setting + * @access private + * @version 1.4 + */ + function _load_template($template) { + switch ($template) { + case 'default': + $this->load_template('default'); + break; + + case 'highest': + $this->load_template('highest_compression'); + break; + + case 'high': + $this->load_template('high_compression'); + break; + + case 'low': + $this->load_template('low_compression'); + break; + + default: + $this->load_template($template); + break; + } } - return false; -} -/** - * Checks if a property is valid - * @param string $property - * @return bool; - * @access public - * @version 1.0 - */ -function property_is_valid($property) { - $all_properties =& $GLOBALS['csstidy']['all_properties']; - return (isset($all_properties[$property]) && strpos($all_properties[$property],strtoupper($this->get_cfg('css_level'))) !== false ); -} + /** + * Set the value of a setting. + * @param string $setting + * @param mixed $value + * @access public + * @return bool + * @version 1.0 + */ + function set_cfg($setting, $value=null) { + if (is_array($setting) && $value === null) { + foreach ($setting as $setprop => $setval) { + $this->settings[$setprop] = $setval; + } + if (array_key_exists('template', $setting)) { + $this->_load_template($this->settings['template']); + } + return true; + } else if (isset($this->settings[$setting]) && $value !== '') { + $this->settings[$setting] = $value; + if ($setting === 'template') { + $this->_load_template($this->settings['template']); + } + return true; + } + return false; + } + + /** + * Adds a token to $this->tokens + * @param mixed $type + * @param string $data + * @param bool $do add a token even if preserve_css is off + * @access private + * @version 1.0 + */ + function _add_token($type, $data, $do = false) { + if ($this->get_cfg('preserve_css') || $do) { + $this->tokens[] = array($type, ($type == COMMENT) ? $data : trim($data)); + } + } + + /** + * Add a message to the message log + * @param string $message + * @param string $type + * @param integer $line + * @access private + * @version 1.0 + */ + function log($message, $type, $line = -1) { + if ($line === -1) { + $line = $this->line; + } + $line = intval($line); + $add = array('m' => $message, 't' => $type); + if (!isset($this->log[$line]) || !in_array($add, $this->log[$line])) { + $this->log[$line][] = $add; + } + } + + /** + * Parse unicode notations and find a replacement character + * @param string $string + * @param integer $i + * @access private + * @return string + * @version 1.2 + */ + function _unicode(&$string, &$i) { + ++$i; + $add = ''; + $replaced = false; + + while ($i < strlen($string) && (ctype_xdigit($string{$i}) || ctype_space($string{$i})) && strlen($add) < 6) { + $add .= $string{$i}; + + if (ctype_space($string{$i})) { + break; + } + $i++; + } + + if (hexdec($add) > 47 && hexdec($add) < 58 || hexdec($add) > 64 && hexdec($add) < 91 || hexdec($add) > 96 && hexdec($add) < 123) { + $this->log('Replaced unicode notation: Changed \\' . $add . ' to ' . chr(hexdec($add)), 'Information'); + $add = chr(hexdec($add)); + $replaced = true; + } else { + $add = trim('\\' . $add); + } + + if (@ctype_xdigit($string{$i + 1}) && ctype_space($string{$i}) + && !$replaced || !ctype_space($string{$i})) { + $i--; + } + + if ($add !== '\\' || !$this->get_cfg('remove_bslash') || strpos($this->tokens_list, $string{$i + 1}) !== false) { + return $add; + } + + if ($add === '\\') { + $this->log('Removed unnecessary backslash', 'Information'); + } + return ''; + } + + /** + * Write formatted output to a file + * @param string $filename + * @param string $doctype when printing formatted, is a shorthand for the document type + * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet + * @param string $title when printing formatted, is the title to be added in the head of the document + * @param string $lang when printing formatted, gives a two-letter language code to be added to the output + * @access public + * @version 1.4 + */ + function write_page($filename, $doctype='xhtml1.1', $externalcss=true, $title='', $lang='en') { + $this->write($filename, true); + } + + /** + * Write plain output to a file + * @param string $filename + * @param bool $formatted whether to print formatted or not + * @param string $doctype when printing formatted, is a shorthand for the document type + * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet + * @param string $title when printing formatted, is the title to be added in the head of the document + * @param string $lang when printing formatted, gives a two-letter language code to be added to the output + * @param bool $pre_code whether to add pre and code tags around the code (for light HTML formatted templates) + * @access public + * @version 1.4 + */ + function write($filename, $formatted=false, $doctype='xhtml1.1', $externalcss=true, $title='', $lang='en', $pre_code=true) { + $filename .= ( $formatted) ? '.xhtml' : '.css'; + + if (!is_dir('temp')) { + $madedir = mkdir('temp'); + if (!$madedir) { + print 'Could not make directory "temp" in ' . dirname(__FILE__); + exit; + } + } + $handle = fopen('temp/' . $filename, 'w'); + if ($handle) { + if (!$formatted) { + fwrite($handle, $this->print->plain()); + } else { + fwrite($handle, $this->print->formatted_page($doctype, $externalcss, $title, $lang, $pre_code)); + } + } + fclose($handle); + } + + /** + * Loads a new template + * @param string $content either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default" + * @param bool $from_file uses $content as filename if true + * @access public + * @version 1.1 + * @see http://csstidy.sourceforge.net/templates.php + */ + function load_template($content, $from_file=true) { + $predefined_templates = & $GLOBALS['csstidy']['predefined_templates']; + if ($content === 'high_compression' || $content === 'default' || $content === 'highest_compression' || $content === 'low_compression') { + $this->template = $predefined_templates[$content]; + return; + } + + + if ($from_file) { + $content = strip_tags(file_get_contents($content), ''); + } + $content = str_replace("\r\n", "\n", $content); // Unify newlines (because the output also only uses \n) + $template = explode('|', $content); + + for ($i = 0; $i < count($template); $i++) { + $this->template[$i] = $template[$i]; + } + } + + /** + * Starts parsing from URL + * @param string $url + * @access public + * @version 1.0 + */ + function parse_from_url($url) { + return $this->parse(@file_get_contents($url)); + } + + /** + * Checks if there is a token at the current position + * @param string $string + * @param integer $i + * @access public + * @version 1.11 + */ + function is_token(&$string, $i) { + return (strpos($this->tokens_list, $string{$i}) !== false && !csstidy::escaped($string, $i)); + } + + /** + * Parses CSS in $string. The code is saved as array in $this->css + * @param string $string the CSS code + * @access public + * @return bool + * @version 1.1 + */ + function parse($string) { + // Temporarily set locale to en_US in order to handle floats properly + $old = @setlocale(LC_ALL, 0); + @setlocale(LC_ALL, 'C'); + + // PHP bug? Settings need to be refreshed in PHP4 + $this->print = new csstidy_print($this); + $this->optimise = new csstidy_optimise($this); + + $all_properties = & $GLOBALS['csstidy']['all_properties']; + $at_rules = & $GLOBALS['csstidy']['at_rules']; + + $this->css = array(); + $this->print->input_css = $string; + $string = str_replace("\r\n", "\n", $string) . ' '; + $cur_comment = ''; + + for ($i = 0, $size = strlen($string); $i < $size; $i++) { + if ($string{$i} === "\n" || $string{$i} === "\r") { + ++$this->line; + } + + switch ($this->status) { + /* Case in at-block */ + case 'at': + if (csstidy::is_token($string, $i)) { + if ($string{$i} === '/' && @$string{$i + 1} === '*') { + $this->status = 'ic'; + ++$i; + $this->from = 'at'; + } elseif ($string{$i} === '{') { + $this->status = 'is'; + $this->at = $this->css_new_media_section($this->at); + $this->_add_token(AT_START, $this->at); + } elseif ($string{$i} === ',') { + $this->at = trim($this->at) . ','; + } elseif ($string{$i} === '\\') { + $this->at .= $this->_unicode($string, $i); + } + // fix for complicated media, i.e @media screen and (-webkit-min-device-pixel-ratio:0) + elseif (in_array($string{$i}, array('(', ')', ':'))) { + $this->at .= $string{$i}; + } + } else { + $lastpos = strlen($this->at) - 1; + if (!( (ctype_space($this->at{$lastpos}) || csstidy::is_token($this->at, $lastpos) && $this->at{$lastpos} === ',') && ctype_space($string{$i}))) { + $this->at .= $string{$i}; + } + } + break; + + /* Case in-selector */ + case 'is': + if (csstidy::is_token($string, $i)) { + if ($string{$i} === '/' && @$string{$i + 1} === '*' && trim($this->selector) == '') { + $this->status = 'ic'; + ++$i; + $this->from = 'is'; + } elseif ($string{$i} === '@' && trim($this->selector) == '') { + // Check for at-rule + $this->invalid_at = true; + foreach ($at_rules as $name => $type) { + if (!strcasecmp(substr($string, $i + 1, strlen($name)), $name)) { + ($type === 'at') ? $this->at = '@' . $name : $this->selector = '@' . $name; + $this->status = $type; + $i += strlen($name); + $this->invalid_at = false; + } + } + + if ($this->invalid_at) { + $this->selector = '@'; + $invalid_at_name = ''; + for ($j = $i + 1; $j < $size; ++$j) { + if (!ctype_alpha($string{$j})) { + break; + } + $invalid_at_name .= $string{$j}; + } + $this->log('Invalid @-rule: ' . $invalid_at_name . ' (removed)', 'Warning'); + } + } elseif (($string{$i} === '"' || $string{$i} === "'")) { + $this->cur_string = $string{$i}; + $this->status = 'instr'; + $this->str_char = $string{$i}; + $this->from = 'is'; + /* fixing CSS3 attribute selectors, i.e. a[href$=".mp3" */ + $this->quoted_string = ($string{$i - 1} == '=' ); + } elseif ($this->invalid_at && $string{$i} === ';') { + $this->invalid_at = false; + $this->status = 'is'; + } elseif ($string{$i} === '{') { + $this->status = 'ip'; + if($this->at == '') { + $this->at = $this->css_new_media_section(DEFAULT_AT); + } + $this->selector = $this->css_new_selector($this->at,$this->selector); + $this->_add_token(SEL_START, $this->selector); + $this->added = false; + } elseif ($string{$i} === '}') { + $this->_add_token(AT_END, $this->at); + $this->at = ''; + $this->selector = ''; + $this->sel_separate = array(); + } elseif ($string{$i} === ',') { + $this->selector = trim($this->selector) . ','; + $this->sel_separate[] = strlen($this->selector); + } elseif ($string{$i} === '\\') { + $this->selector .= $this->_unicode($string, $i); + } elseif ($string{$i} === '*' && @in_array($string{$i + 1}, array('.', '#', '[', ':'))) { + // remove unnecessary universal selector, FS#147 + } else { + $this->selector .= $string{$i}; + } + } else { + $lastpos = strlen($this->selector) - 1; + if ($lastpos == -1 || !( (ctype_space($this->selector{$lastpos}) || csstidy::is_token($this->selector, $lastpos) && $this->selector{$lastpos} === ',') && ctype_space($string{$i}))) { + $this->selector .= $string{$i}; + } + } + break; + + /* Case in-property */ + case 'ip': + if (csstidy::is_token($string, $i)) { + if (($string{$i} === ':' || $string{$i} === '=') && $this->property != '') { + $this->status = 'iv'; + if (!$this->get_cfg('discard_invalid_properties') || csstidy::property_is_valid($this->property)) { + $this->property = $this->css_new_property($this->at,$this->selector,$this->property); + $this->_add_token(PROPERTY, $this->property); + } + } elseif ($string{$i} === '/' && @$string{$i + 1} === '*' && $this->property == '') { + $this->status = 'ic'; + ++$i; + $this->from = 'ip'; + } elseif ($string{$i} === '}') { + $this->explode_selectors(); + $this->status = 'is'; + $this->invalid_at = false; + $this->_add_token(SEL_END, $this->selector); + $this->selector = ''; + $this->property = ''; + } elseif ($string{$i} === ';') { + $this->property = ''; + } elseif ($string{$i} === '\\') { + $this->property .= $this->_unicode($string, $i); + } + // else this is dumb IE a hack, keep it + elseif ($this->property=='' AND !ctype_space($string{$i})) { + $this->property .= $string{$i}; + } + } + elseif (!ctype_space($string{$i})) { + $this->property .= $string{$i}; + } + break; + + /* Case in-value */ + case 'iv': + $pn = (($string{$i} === "\n" || $string{$i} === "\r") && $this->property_is_next($string, $i + 1) || $i == strlen($string) - 1); + if (csstidy::is_token($string, $i) || $pn) { + if ($string{$i} === '/' && @$string{$i + 1} === '*') { + $this->status = 'ic'; + ++$i; + $this->from = 'iv'; + } elseif (($string{$i} === '"' || $string{$i} === "'" || $string{$i} === '(')) { + $this->cur_string = $string{$i}; + $this->str_char = ($string{$i} === '(') ? ')' : $string{$i}; + $this->status = 'instr'; + $this->from = 'iv'; + } elseif ($string{$i} === ',') { + $this->sub_value = trim($this->sub_value) . ','; + } elseif ($string{$i} === '\\') { + $this->sub_value .= $this->_unicode($string, $i); + } elseif ($string{$i} === ';' || $pn) { + if ($this->selector{0} === '@' && isset($at_rules[substr($this->selector, 1)]) && $at_rules[substr($this->selector, 1)] === 'iv') { + /* Add quotes to charset, import, namespace */ + $this->sub_value_arr[] = '"' . trim($this->sub_value) . '"'; + + $this->status = 'is'; + + switch ($this->selector) { + case '@charset': $this->charset = $this->sub_value_arr[0]; + break; + case '@namespace': $this->namespace = implode(' ', $this->sub_value_arr); + break; + case '@import': $this->import[] = implode(' ', $this->sub_value_arr); + break; + } + + $this->sub_value_arr = array(); + $this->sub_value = ''; + $this->selector = ''; + $this->sel_separate = array(); + } else { + $this->status = 'ip'; + } + } elseif ($string{$i} !== '}') { + $this->sub_value .= $string{$i}; + } + if (($string{$i} === '}' || $string{$i} === ';' || $pn) && !empty($this->selector)) { + if ($this->at == '') { + $this->at = $this->css_new_media_section(DEFAULT_AT); + } + + // case settings + if ($this->get_cfg('lowercase_s')) { + $this->selector = strtolower($this->selector); + } + $this->property = strtolower($this->property); + + $this->optimise->subvalue(); + if ($this->sub_value != '') { + if (substr($this->sub_value, 0, 6) == 'format') { + $this->sub_value = str_replace(array('format(', ')'), array('format("', '")'), $this->sub_value); + } + $this->sub_value_arr[] = $this->sub_value; + $this->sub_value = ''; + } + + $this->value = array_shift($this->sub_value_arr); + while(count($this->sub_value_arr)){ + $this->value .= (substr($this->value,-1,1)==','?'':' ').array_shift($this->sub_value_arr); + } + + $this->optimise->value(); + + $valid = csstidy::property_is_valid($this->property); + if ((!$this->invalid_at || $this->get_cfg('preserve_css')) && (!$this->get_cfg('discard_invalid_properties') || $valid)) { + $this->css_add_property($this->at, $this->selector, $this->property, $this->value); + $this->_add_token(VALUE, $this->value); + $this->optimise->shorthands(); + } + if (!$valid) { + if ($this->get_cfg('discard_invalid_properties')) { + $this->log('Removed invalid property: ' . $this->property, 'Warning'); + } else { + $this->log('Invalid property in ' . strtoupper($this->get_cfg('css_level')) . ': ' . $this->property, 'Warning'); + } + } + + $this->property = ''; + $this->sub_value_arr = array(); + $this->value = ''; + } + if ($string{$i} === '}') { + $this->explode_selectors(); + $this->_add_token(SEL_END, $this->selector); + $this->status = 'is'; + $this->invalid_at = false; + $this->selector = ''; + } + } elseif (!$pn) { + $this->sub_value .= $string{$i}; + + if (ctype_space($string{$i})) { + $this->optimise->subvalue(); + if ($this->sub_value != '') { + $this->sub_value_arr[] = $this->sub_value; + $this->sub_value = ''; + } + } + } + break; + + /* Case in string */ + case 'instr': + if ($this->str_char === ')' && ($string{$i} === '"' || $string{$i} === '\'') && !$this->str_in_str && !csstidy::escaped($string, $i)) { + $this->str_in_str = true; + } elseif ($this->str_char === ')' && ($string{$i} === '"' || $string{$i} === '\'') && $this->str_in_str && !csstidy::escaped($string, $i)) { + $this->str_in_str = false; + } + $temp_add = $string{$i}; // ...and no not-escaped backslash at the previous position + if (($string{$i} === "\n" || $string{$i} === "\r") && !($string{$i - 1} === '\\' && !csstidy::escaped($string, $i - 1))) { + $temp_add = "\\A "; + $this->log('Fixed incorrect newline in string', 'Warning'); + } + // this optimisation remove space in css3 properties (see vendor-prefixed/webkit-gradient.csst) + #if (!($this->str_char === ')' && in_array($string{$i}, $GLOBALS['csstidy']['whitespace']) && !$this->str_in_str)) { + $this->cur_string .= $temp_add; + #} + if ($string{$i} == $this->str_char && !csstidy::escaped($string, $i) && !$this->str_in_str) { + $this->status = $this->from; + if (!preg_match('|[' . implode('', $GLOBALS['csstidy']['whitespace']) . ']|uis', $this->cur_string) && $this->property !== 'content') { + if (!$this->quoted_string) { + if ($this->str_char === '"' || $this->str_char === '\'') { + // Temporarily disable this optimization to avoid problems with @charset rule, quote properties, and some attribute selectors... + // Attribute selectors fixed, added quotes to @chartset, no problems with properties detected. Enabled + $this->cur_string = substr($this->cur_string, 1, -1); + } else if (strlen($this->cur_string) > 3 && ($this->cur_string[1] === '"' || $this->cur_string[1] === '\'')) /* () */ { + $this->cur_string = $this->cur_string[0] . substr($this->cur_string, 2, -2) . substr($this->cur_string, -1); + } + } else { + $this->quoted_string = false; + } + } + if ($this->from === 'iv') { + if (!$this->quoted_string){ + if (strpos($this->cur_string,',')!==false) + // we can on only remove space next to ',' + $this->cur_string = implode(',',array_map('trim',explode(',',$this->cur_string))); + // and multiple spaces (too expensive) + if (strpos($this->cur_string,' ')!==false) + $this->cur_string = preg_replace(",\s+,"," ",$this->cur_string); + } + $this->sub_value .= $this->cur_string; + } elseif ($this->from === 'is') { + $this->selector .= $this->cur_string; + } + } + break; + + /* Case in-comment */ + case 'ic': + if ($string{$i} === '*' && $string{$i + 1} === '/') { + $this->status = $this->from; + $i++; + $this->_add_token(COMMENT, $cur_comment); + $cur_comment = ''; + } else { + $cur_comment .= $string{$i}; + } + break; + } + } + + $this->optimise->postparse(); + + $this->print->_reset(); + + @setlocale(LC_ALL, $old); // Set locale back to original setting + + return!(empty($this->css) && empty($this->import) && empty($this->charset) && empty($this->tokens) && empty($this->namespace)); + } + + /** + * Explodes selectors + * @access private + * @version 1.0 + */ + function explode_selectors() { + // Explode multiple selectors + if ($this->get_cfg('merge_selectors') === 1) { + $new_sels = array(); + $lastpos = 0; + $this->sel_separate[] = strlen($this->selector); + foreach ($this->sel_separate as $num => $pos) { + if ($num == count($this->sel_separate) - 1) { + $pos += 1; + } + + $new_sels[] = substr($this->selector, $lastpos, $pos - $lastpos - 1); + $lastpos = $pos; + } + + if (count($new_sels) > 1) { + foreach ($new_sels as $selector) { + if (isset($this->css[$this->at][$this->selector])) { + $this->merge_css_blocks($this->at, $selector, $this->css[$this->at][$this->selector]); + } + } + unset($this->css[$this->at][$this->selector]); + } + } + $this->sel_separate = array(); + } + + /** + * Checks if a character is escaped (and returns true if it is) + * @param string $string + * @param integer $pos + * @access public + * @return bool + * @version 1.02 + */ + static function escaped(&$string, $pos) { + return!(@($string{$pos - 1} !== '\\') || csstidy::escaped($string, $pos - 1)); + } + + /** + * Adds a property with value to the existing CSS code + * @param string $media + * @param string $selector + * @param string $property + * @param string $new_val + * @access private + * @version 1.2 + */ + function css_add_property($media, $selector, $property, $new_val) { + if ($this->get_cfg('preserve_css') || trim($new_val) == '') { + return; + } + + $this->added = true; + if (isset($this->css[$media][$selector][$property])) { + if ((csstidy::is_important($this->css[$media][$selector][$property]) && csstidy::is_important($new_val)) || !csstidy::is_important($this->css[$media][$selector][$property])) { + $this->css[$media][$selector][$property] = trim($new_val); + } + } else { + $this->css[$media][$selector][$property] = trim($new_val); + } + } + + /** + * Start a new media section. + * Check if the media is not already known, + * else rename it with extra spaces + * to avoid merging + * + * @param string $media + * @return string + */ + function css_new_media_section($media){ + if($this->get_cfg('preserve_css')) { + return $media; + } + + // if the last @media is the same as this + // keep it + if (!$this->css OR !is_array($this->css) OR empty($this->css)){ + return $media; + } + end($this->css); + list($at,) = each($this->css); + if ($at == $media){ + return $media; + } + while (isset($this->css[$media])) + if (is_numeric($media)) + $media++; + else + $media .= " "; + return $media; + } + + /** + * Start a new selector. + * If already referenced in this media section, + * rename it with extra space to avoid merging + * except if merging is required, + * or last selector is the same (merge siblings) + * + * never merge @font-face + * + * @param string $media + * @param string $selector + * @return string + */ + function css_new_selector($media,$selector){ + if($this->get_cfg('preserve_css')) { + return $selector; + } + $selector = trim($selector); + if (strncmp($selector,"@font-face",10)!=0){ + if ($this->settings['merge_selectors'] != false) + return $selector; + + if (!$this->css OR !isset($this->css[$media]) OR !$this->css[$media]) + return $selector; + + // if last is the same, keep it + end($this->css[$media]); + list($sel,) = each($this->css[$media]); + if ($sel == $selector){ + return $selector; + } + } + + while (isset($this->css[$media][$selector])) + $selector .= " "; + return $selector; + } + + /** + * Start a new propertie. + * If already references in this selector, + * rename it with extra space to avoid override + * + * @param string $media + * @param string $selector + * @param string $property + * @return string + */ + function css_new_property($media, $selector, $property){ + if($this->get_cfg('preserve_css')) { + return $property; + } + if (!$this->css OR !isset($this->css[$media][$selector]) OR !$this->css[$media][$selector]) + return $property; + + while (isset($this->css[$media][$selector][$property])) + $property .= " "; + + return $property; + } + + /** + * Adds CSS to an existing media/selector + * @param string $media + * @param string $selector + * @param array $css_add + * @access private + * @version 1.1 + */ + function merge_css_blocks($media, $selector, $css_add) { + foreach ($css_add as $property => $value) { + $this->css_add_property($media, $selector, $property, $value, false); + } + } + + /** + * Checks if $value is !important. + * @param string $value + * @return bool + * @access public + * @version 1.0 + */ + static function is_important(&$value) { + return (!strcasecmp(substr(str_replace($GLOBALS['csstidy']['whitespace'], '', $value), -10, 10), '!important')); + } + + /** + * Returns a value without !important + * @param string $value + * @return string + * @access public + * @version 1.0 + */ + static function gvw_important($value) { + if (csstidy::is_important($value)) { + $value = trim($value); + $value = substr($value, 0, -9); + $value = trim($value); + $value = substr($value, 0, -1); + $value = trim($value); + return $value; + } + return $value; + } + + /** + * Checks if the next word in a string from pos is a CSS property + * @param string $istring + * @param integer $pos + * @return bool + * @access private + * @version 1.2 + */ + function property_is_next($istring, $pos) { + $all_properties = & $GLOBALS['csstidy']['all_properties']; + $istring = substr($istring, $pos, strlen($istring) - $pos); + $pos = strpos($istring, ':'); + if ($pos === false) { + return false; + } + $istring = strtolower(trim(substr($istring, 0, $pos))); + if (isset($all_properties[$istring])) { + $this->log('Added semicolon to the end of declaration', 'Warning'); + return true; + } + return false; + } + + /** + * Checks if a property is valid + * @param string $property + * @return bool; + * @access public + * @version 1.0 + */ + function property_is_valid($property) { + $all_properties = & $GLOBALS['csstidy']['all_properties']; + return (isset($all_properties[$property]) && strpos($all_properties[$property], strtoupper($this->get_cfg('css_level'))) !== false ); + } } -?> diff --git a/engine/lib/external/CSSTidy-1.3/class.csstidy_ctype.php b/engine/lib/external/CSSTidy-1.3/class.csstidy_ctype.php new file mode 100644 index 00000000..bc5accc5 --- /dev/null +++ b/engine/lib/external/CSSTidy-1.3/class.csstidy_ctype.php @@ -0,0 +1,46 @@ + \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/class.csstidy_optimise.php b/engine/lib/external/CSSTidy-1.3/class.csstidy_optimise.php index 9a4ceb62..78968909 100644 --- a/engine/lib/external/CSSTidy-1.3/class.csstidy_optimise.php +++ b/engine/lib/external/CSSTidy-1.3/class.csstidy_optimise.php @@ -1,29 +1,33 @@ . * - * You should have received a copy of the GNU General Public License - * along with CSSTidy; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License * @package csstidy - * @author Florian Schmitz (floele at gmail dot com) 2005-2006 + * @author Florian Schmitz (floele at gmail dot com) 2005-2007 + * @author Brett Zamir (brettz9 at yahoo dot com) 2007 + * @author Nikolay Matsievsky (speed at webo dot name) 2009-2010 */ /** @@ -35,775 +39,893 @@ * @author Florian Schmitz (floele at gmail dot com) 2005-2006 * @version 1.0 */ +class csstidy_optimise { + + /** + * Constructor + * @param array $css contains the class csstidy + * @access private + * @version 1.0 + */ + function csstidy_optimise(&$css) { + $this->parser = & $css; + $this->css = & $css->css; + $this->sub_value = & $css->sub_value; + $this->at = & $css->at; + $this->selector = & $css->selector; + $this->property = & $css->property; + $this->value = & $css->value; + } + + /** + * Optimises $css after parsing + * @access public + * @version 1.0 + */ + function postparse() { + if ($this->parser->get_cfg('preserve_css')) { + return; + } + + if ($this->parser->get_cfg('merge_selectors') === 2) { + foreach ($this->css as $medium => $value) { + $this->merge_selectors($this->css[$medium]); + } + } + + if ($this->parser->get_cfg('discard_invalid_selectors')) { + foreach ($this->css as $medium => $value) { + $this->discard_invalid_selectors($this->css[$medium]); + } + } + + if ($this->parser->get_cfg('optimise_shorthands') > 0) { + foreach ($this->css as $medium => $value) { + foreach ($value as $selector => $value1) { + $this->css[$medium][$selector] = csstidy_optimise::merge_4value_shorthands($this->css[$medium][$selector]); + + if ($this->parser->get_cfg('optimise_shorthands') < 2) { + continue; + } + + $this->css[$medium][$selector] = csstidy_optimise::merge_font($this->css[$medium][$selector]); + + if ($this->parser->get_cfg('optimise_shorthands') < 3) { + continue; + } + + $this->css[$medium][$selector] = csstidy_optimise::merge_bg($this->css[$medium][$selector]); + if (empty($this->css[$medium][$selector])) { + unset($this->css[$medium][$selector]); + } + } + } + } + } + + /** + * Optimises values + * @access public + * @version 1.0 + */ + function value() { + $shorthands = & $GLOBALS['csstidy']['shorthands']; + + // optimise shorthand properties + if (isset($shorthands[$this->property])) { + $temp = csstidy_optimise::shorthand($this->value); // FIXME - move + if ($temp != $this->value) { + $this->parser->log('Optimised shorthand notation (' . $this->property . '): Changed "' . $this->value . '" to "' . $temp . '"', 'Information'); + } + $this->value = $temp; + } + + // Remove whitespace at ! important + if ($this->value != $this->compress_important($this->value)) { + $this->parser->log('Optimised !important', 'Information'); + } + } + + /** + * Optimises shorthands + * @access public + * @version 1.0 + */ + function shorthands() { + $shorthands = & $GLOBALS['csstidy']['shorthands']; + + if (!$this->parser->get_cfg('optimise_shorthands') || $this->parser->get_cfg('preserve_css')) { + return; + } + + if ($this->property === 'font' && $this->parser->get_cfg('optimise_shorthands') > 1) { + $this->css[$this->at][$this->selector]['font']=''; + $this->parser->merge_css_blocks($this->at, $this->selector, csstidy_optimise::dissolve_short_font($this->value)); + } + if ($this->property === 'background' && $this->parser->get_cfg('optimise_shorthands') > 2) { + $this->css[$this->at][$this->selector]['background']=''; + $this->parser->merge_css_blocks($this->at, $this->selector, csstidy_optimise::dissolve_short_bg($this->value)); + } + if (isset($shorthands[$this->property])) { + $this->parser->merge_css_blocks($this->at, $this->selector, csstidy_optimise::dissolve_4value_shorthands($this->property, $this->value)); + if (is_array($shorthands[$this->property])) { + $this->css[$this->at][$this->selector][$this->property] = ''; + } + } + } + + /** + * Optimises a sub-value + * @access public + * @version 1.0 + */ + function subvalue() { + $replace_colors = & $GLOBALS['csstidy']['replace_colors']; + + $this->sub_value = trim($this->sub_value); + if ($this->sub_value == '') { // caution : '0' + return; + } + + $important = ''; + if (csstidy::is_important($this->sub_value)) { + $important = '!important'; + } + $this->sub_value = csstidy::gvw_important($this->sub_value); + + // Compress font-weight + if ($this->property === 'font-weight' && $this->parser->get_cfg('compress_font-weight')) { + if ($this->sub_value === 'bold') { + $this->sub_value = '700'; + $this->parser->log('Optimised font-weight: Changed "bold" to "700"', 'Information'); + } else if ($this->sub_value === 'normal') { + $this->sub_value = '400'; + $this->parser->log('Optimised font-weight: Changed "normal" to "400"', 'Information'); + } + } + + $temp = $this->compress_numbers($this->sub_value); + if (strcasecmp($temp, $this->sub_value) !== 0) { + if (strlen($temp) > strlen($this->sub_value)) { + $this->parser->log('Fixed invalid number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning'); + } else { + $this->parser->log('Optimised number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information'); + } + $this->sub_value = $temp; + } + if ($this->parser->get_cfg('compress_colors')) { + $temp = $this->cut_color($this->sub_value); + if ($temp !== $this->sub_value) { + if (isset($replace_colors[$this->sub_value])) { + $this->parser->log('Fixed invalid color name: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning'); + } else { + $this->parser->log('Optimised color: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information'); + } + $this->sub_value = $temp; + } + } + $this->sub_value .= $important; + } + + /** + * Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px + * @param string $value + * @access public + * @return string + * @version 1.0 + */ + function shorthand($value) { + $important = ''; + if (csstidy::is_important($value)) { + $values = csstidy::gvw_important($value); + $important = '!important'; + } + else + $values = $value; + + $values = explode(' ', $values); + switch (count($values)) { + case 4: + if ($values[0] == $values[1] && $values[0] == $values[2] && $values[0] == $values[3]) { + return $values[0] . $important; + } elseif ($values[1] == $values[3] && $values[0] == $values[2]) { + return $values[0] . ' ' . $values[1] . $important; + } elseif ($values[1] == $values[3]) { + return $values[0] . ' ' . $values[1] . ' ' . $values[2] . $important; + } + break; + + case 3: + if ($values[0] == $values[1] && $values[0] == $values[2]) { + return $values[0] . $important; + } elseif ($values[0] == $values[2]) { + return $values[0] . ' ' . $values[1] . $important; + } + break; + + case 2: + if ($values[0] == $values[1]) { + return $values[0] . $important; + } + break; + } + + return $value; + } + + /** + * Removes unnecessary whitespace in ! important + * @param string $string + * @return string + * @access public + * @version 1.1 + */ + function compress_important(&$string) { + if (csstidy::is_important($string)) { + $string = csstidy::gvw_important($string) . '!important'; + } + return $string; + } + + /** + * Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values. + * @param string $color + * @return string + * @version 1.1 + */ + function cut_color($color) { + $replace_colors = & $GLOBALS['csstidy']['replace_colors']; + + // rgb(0,0,0) -> #000000 (or #000 in this case later) + if (strtolower(substr($color, 0, 4)) === 'rgb(') { + $color_tmp = substr($color, 4, strlen($color) - 5); + $color_tmp = explode(',', $color_tmp); + for ($i = 0; $i < count($color_tmp); $i++) { + $color_tmp[$i] = trim($color_tmp[$i]); + if (substr($color_tmp[$i], -1) === '%') { + $color_tmp[$i] = round((255 * $color_tmp[$i]) / 100); + } + if ($color_tmp[$i] > 255) + $color_tmp[$i] = 255; + } + $color = '#'; + for ($i = 0; $i < 3; $i++) { + if ($color_tmp[$i] < 16) { + $color .= '0' . dechex($color_tmp[$i]); + } else { + $color .= dechex($color_tmp[$i]); + } + } + } + + // Fix bad color names + if (isset($replace_colors[strtolower($color)])) { + $color = $replace_colors[strtolower($color)]; + } + + // #aabbcc -> #abc + if (strlen($color) == 7) { + $color_temp = strtolower($color); + if ($color_temp{0} === '#' && $color_temp{1} == $color_temp{2} && $color_temp{3} == $color_temp{4} && $color_temp{5} == $color_temp{6}) { + $color = '#' . $color{1} . $color{3} . $color{5}; + } + } + + switch (strtolower($color)) { + /* color name -> hex code */ + case 'black': return '#000'; + case 'fuchsia': return '#f0f'; + case 'white': return '#fff'; + case 'yellow': return '#ff0'; + + /* hex code -> color name */ + case '#800000': return 'maroon'; + case '#ffa500': return 'orange'; + case '#808000': return 'olive'; + case '#800080': return 'purple'; + case '#008000': return 'green'; + case '#000080': return 'navy'; + case '#008080': return 'teal'; + case '#c0c0c0': return 'silver'; + case '#808080': return 'gray'; + case '#f00': return 'red'; + } + + return $color; + } + + /** + * Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 ) + * @param string $subvalue + * @return string + * @version 1.2 + */ + function compress_numbers($subvalue) { + $unit_values = & $GLOBALS['csstidy']['unit_values']; + $color_values = & $GLOBALS['csstidy']['color_values']; + + // for font:1em/1em sans-serif...; + if ($this->property === 'font') { + $temp = explode('/', $subvalue); + } else { + $temp = array($subvalue); + } + for ($l = 0; $l < count($temp); $l++) { + // if we are not dealing with a number at this point, do not optimise anything + $number = $this->AnalyseCssNumber($temp[$l]); + if ($number === false) { + return $subvalue; + } + + // Fix bad colors + if (in_array($this->property, $color_values)) { + $temp[$l] = '#' . $temp[$l]; + continue; + } + + if (abs($number[0]) > 0) { + if ($number[1] == '' && in_array($this->property, $unit_values, true)) { + $number[1] = 'px'; + } + } else { + $number[1] = ''; + } + + $temp[$l] = $number[0] . $number[1]; + } + + return ((count($temp) > 1) ? $temp[0] . '/' . $temp[1] : $temp[0]); + } + + /** + * Checks if a given string is a CSS valid number. If it is, + * an array containing the value and unit is returned + * @param string $string + * @return array ('unit' if unit is found or '' if no unit exists, number value) or false if no number + */ + function AnalyseCssNumber($string) { + // most simple checks first + if (strlen($string) == 0 || ctype_alpha($string{0})) { + return false; + } + + $units = & $GLOBALS['csstidy']['units']; + $return = array(0, ''); + + $return[0] = floatval($string); + if (abs($return[0]) > 0 && abs($return[0]) < 1) { + if ($return[0] < 0) { + $return[0] = '-' . ltrim(substr($return[0], 1), '0'); + } else { + $return[0] = ltrim($return[0], '0'); + } + } + + // Look for unit and split from value if exists + foreach ($units as $unit) { + $expectUnitAt = strlen($string) - strlen($unit); + if (!($unitInString = stristr($string, $unit))) { // mb_strpos() fails with "false" + continue; + } + $actualPosition = strpos($string, $unitInString); + if ($expectUnitAt === $actualPosition) { + $return[1] = $unit; + $string = substr($string, 0, - strlen($unit)); + break; + } + } + if (!is_numeric($string)) { + return false; + } + return $return; + } + + /** + * Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red} + * Very basic and has at least one bug. Hopefully there is a replacement soon. + * @param array $array + * @return array + * @access public + * @version 1.2 + */ + function merge_selectors(&$array) { + $css = $array; + foreach ($css as $key => $value) { + if (!isset($css[$key])) { + continue; + } + $newsel = ''; + + // Check if properties also exist in another selector + $keys = array(); + // PHP bug (?) without $css = $array; here + foreach ($css as $selector => $vali) { + if ($selector == $key) { + continue; + } + + if ($css[$key] === $vali) { + $keys[] = $selector; + } + } + + if (!empty($keys)) { + $newsel = $key; + unset($css[$key]); + foreach ($keys as $selector) { + unset($css[$selector]); + $newsel .= ',' . $selector; + } + $css[$newsel] = $value; + } + } + $array = $css; + } + + /** + * Removes invalid selectors and their corresponding rule-sets as + * defined by 4.1.7 in REC-CSS2. This is a very rudimentary check + * and should be replaced by a full-blown parsing algorithm or + * regular expression + * @version 1.4 + */ + function discard_invalid_selectors(&$array) { + $invalid = array('+' => true, '~' => true, ',' => true, '>' => true); + foreach ($array as $selector => $decls) { + $ok = true; + $selectors = array_map('trim', explode(',', $selector)); + foreach ($selectors as $s) { + $simple_selectors = preg_split('/\s*[+>~\s]\s*/', $s); + foreach ($simple_selectors as $ss) { + if ($ss === '') + $ok = false; + // could also check $ss for internal structure, + // but that probably would be too slow + } + } + if (!$ok) + unset($array[$selector]); + } + } + + /** + * Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;... + * @param string $property + * @param string $value + * @return array + * @version 1.0 + * @see merge_4value_shorthands() + */ + function dissolve_4value_shorthands($property, $value) { + $shorthands = & $GLOBALS['csstidy']['shorthands']; + if (!is_array($shorthands[$property])) { + $return[$property] = $value; + return $return; + } + + $important = ''; + if (csstidy::is_important($value)) { + $value = csstidy::gvw_important($value); + $important = '!important'; + } + $values = explode(' ', $value); + + + $return = array(); + if (count($values) == 4) { + for ($i = 0; $i < 4; $i++) { + $return[$shorthands[$property][$i]] = $values[$i] . $important; + } + } elseif (count($values) == 3) { + $return[$shorthands[$property][0]] = $values[0] . $important; + $return[$shorthands[$property][1]] = $values[1] . $important; + $return[$shorthands[$property][3]] = $values[1] . $important; + $return[$shorthands[$property][2]] = $values[2] . $important; + } elseif (count($values) == 2) { + for ($i = 0; $i < 4; $i++) { + $return[$shorthands[$property][$i]] = (($i % 2 != 0)) ? $values[1] . $important : $values[0] . $important; + } + } else { + for ($i = 0; $i < 4; $i++) { + $return[$shorthands[$property][$i]] = $values[0] . $important; + } + } + + return $return; + } + + /** + * Explodes a string as explode() does, however, not if $sep is escaped or within a string. + * @param string $sep seperator + * @param string $string + * @return array + * @version 1.0 + */ + function explode_ws($sep, $string) { + $status = 'st'; + $to = ''; + + $output = array(); + $num = 0; + for ($i = 0, $len = strlen($string); $i < $len; $i++) { + switch ($status) { + case 'st': + if ($string{$i} == $sep && !csstidy::escaped($string, $i)) { + ++$num; + } elseif ($string{$i} === '"' || $string{$i} === '\'' || $string{$i} === '(' && !csstidy::escaped($string, $i)) { + $status = 'str'; + $to = ($string{$i} === '(') ? ')' : $string{$i}; + (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i}; + } else { + (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i}; + } + break; + + case 'str': + if ($string{$i} == $to && !csstidy::escaped($string, $i)) { + $status = 'st'; + } + (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i}; + break; + } + } + + if (isset($output[0])) { + return $output; + } else { + return array($output); + } + } + + /** + * Merges Shorthand properties again, the opposite of dissolve_4value_shorthands() + * @param array $array + * @return array + * @version 1.2 + * @see dissolve_4value_shorthands() + */ + function merge_4value_shorthands($array) { + $return = $array; + $shorthands = & $GLOBALS['csstidy']['shorthands']; + + foreach ($shorthands as $key => $value) { + if (isset($array[$value[0]]) && isset($array[$value[1]]) + && isset($array[$value[2]]) && isset($array[$value[3]]) && $value !== 0) { + $return[$key] = ''; + + $important = ''; + for ($i = 0; $i < 4; $i++) { + $val = $array[$value[$i]]; + if (csstidy::is_important($val)) { + $important = '!important'; + $return[$key] .= csstidy::gvw_important($val) . ' '; + } else { + $return[$key] .= $val . ' '; + } + unset($return[$value[$i]]); + } + $return[$key] = csstidy_optimise::shorthand(trim($return[$key] . $important)); + } + } + return $return; + } + + /** + * Dissolve background property + * @param string $str_value + * @return array + * @version 1.0 + * @see merge_bg() + * @todo full CSS 3 compliance + */ + function dissolve_short_bg($str_value) { + // don't try to explose background gradient ! + if (stripos($str_value, "gradient(")!==FALSE) + return array('background'=>$str_value); + + $background_prop_default = & $GLOBALS['csstidy']['background_prop_default']; + $repeat = array('repeat', 'repeat-x', 'repeat-y', 'no-repeat', 'space'); + $attachment = array('scroll', 'fixed', 'local'); + $clip = array('border', 'padding'); + $origin = array('border', 'padding', 'content'); + $pos = array('top', 'center', 'bottom', 'left', 'right'); + $important = ''; + $return = array('background-image' => null, 'background-size' => null, 'background-repeat' => null, 'background-position' => null, 'background-attachment' => null, 'background-clip' => null, 'background-origin' => null, 'background-color' => null); + + if (csstidy::is_important($str_value)) { + $important = ' !important'; + $str_value = csstidy::gvw_important($str_value); + } + + $str_value = csstidy_optimise::explode_ws(',', $str_value); + for ($i = 0; $i < count($str_value); $i++) { + $have['clip'] = false; + $have['pos'] = false; + $have['color'] = false; + $have['bg'] = false; + + if (is_array($str_value[$i])) { + $str_value[$i] = $str_value[$i][0]; + } + $str_value[$i] = csstidy_optimise::explode_ws(' ', trim($str_value[$i])); + + for ($j = 0; $j < count($str_value[$i]); $j++) { + if ($have['bg'] === false && (substr($str_value[$i][$j], 0, 4) === 'url(' || $str_value[$i][$j] === 'none')) { + $return['background-image'] .= $str_value[$i][$j] . ','; + $have['bg'] = true; + } elseif (in_array($str_value[$i][$j], $repeat, true)) { + $return['background-repeat'] .= $str_value[$i][$j] . ','; + } elseif (in_array($str_value[$i][$j], $attachment, true)) { + $return['background-attachment'] .= $str_value[$i][$j] . ','; + } elseif (in_array($str_value[$i][$j], $clip, true) && !$have['clip']) { + $return['background-clip'] .= $str_value[$i][$j] . ','; + $have['clip'] = true; + } elseif (in_array($str_value[$i][$j], $origin, true)) { + $return['background-origin'] .= $str_value[$i][$j] . ','; + } elseif ($str_value[$i][$j]{0} === '(') { + $return['background-size'] .= substr($str_value[$i][$j], 1, -1) . ','; + } elseif (in_array($str_value[$i][$j], $pos, true) || is_numeric($str_value[$i][$j]{0}) || $str_value[$i][$j]{0} === null || $str_value[$i][$j]{0} === '-' || $str_value[$i][$j]{0} === '.') { + $return['background-position'] .= $str_value[$i][$j]; + if (!$have['pos']) + $return['background-position'] .= ' '; else + $return['background-position'].= ','; + $have['pos'] = true; + } + elseif (!$have['color']) { + $return['background-color'] .= $str_value[$i][$j] . ','; + $have['color'] = true; + } + } + } + + foreach ($background_prop_default as $bg_prop => $default_value) { + if ($return[$bg_prop] !== null) { + $return[$bg_prop] = substr($return[$bg_prop], 0, -1) . $important; + } + else + $return[$bg_prop] = $default_value . $important; + } + return $return; + } + + /** + * Merges all background properties + * @param array $input_css + * @return array + * @version 1.0 + * @see dissolve_short_bg() + * @todo full CSS 3 compliance + */ + function merge_bg($input_css) { + $background_prop_default = & $GLOBALS['csstidy']['background_prop_default']; + // Max number of background images. CSS3 not yet fully implemented + $number_of_values = @max(count(csstidy_optimise::explode_ws(',', $input_css['background-image'])), count(csstidy_optimise::explode_ws(',', $input_css['background-color'])), 1); + // Array with background images to check if BG image exists + $bg_img_array = @csstidy_optimise::explode_ws(',', csstidy::gvw_important($input_css['background-image'])); + $new_bg_value = ''; + $important = ''; + + // if background properties is here and not empty, don't try anything + if (isset($input_css['background']) AND $input_css['background']) + return $input_css; + + for ($i = 0; $i < $number_of_values; $i++) { + foreach ($background_prop_default as $bg_property => $default_value) { + // Skip if property does not exist + if (!isset($input_css[$bg_property])) { + continue; + } + + $cur_value = $input_css[$bg_property]; + // skip all optimisation if gradient() somewhere + if (stripos($cur_value, "gradient(")!==FALSE) + return $input_css; + + // Skip some properties if there is no background image + if ((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none') + && ($bg_property === 'background-size' || $bg_property === 'background-position' + || $bg_property === 'background-attachment' || $bg_property === 'background-repeat')) { + continue; + } + + // Remove !important + if (csstidy::is_important($cur_value)) { + $important = ' !important'; + $cur_value = csstidy::gvw_important($cur_value); + } + + // Do not add default values + if ($cur_value === $default_value) { + continue; + } + + $temp = csstidy_optimise::explode_ws(',', $cur_value); + + if (isset($temp[$i])) { + if ($bg_property === 'background-size') { + $new_bg_value .= '(' . $temp[$i] . ') '; + } else { + $new_bg_value .= $temp[$i] . ' '; + } + } + } + + $new_bg_value = trim($new_bg_value); + if ($i != $number_of_values - 1) + $new_bg_value .= ','; + } + + // Delete all background-properties + foreach ($background_prop_default as $bg_property => $default_value) { + unset($input_css[$bg_property]); + } + + // Add new background property + if ($new_bg_value !== '') + $input_css['background'] = $new_bg_value . $important; + elseif(isset ($input_css['background'])) + $input_css['background'] = 'none'; + + return $input_css; + } + + /** + * Dissolve font property + * @param string $str_value + * @return array + * @version 1.3 + * @see merge_font() + */ + function dissolve_short_font($str_value) { + $font_prop_default = & $GLOBALS['csstidy']['font_prop_default']; + $font_weight = array('normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900); + $font_variant = array('normal', 'small-caps'); + $font_style = array('normal', 'italic', 'oblique'); + $important = ''; + $return = array('font-style' => null, 'font-variant' => null, 'font-weight' => null, 'font-size' => null, 'line-height' => null, 'font-family' => null); + + if (csstidy::is_important($str_value)) { + $important = '!important'; + $str_value = csstidy::gvw_important($str_value); + } + + $have['style'] = false; + $have['variant'] = false; + $have['weight'] = false; + $have['size'] = false; + // Detects if font-family consists of several words w/o quotes + $multiwords = false; + + // Workaround with multiple font-family + $str_value = csstidy_optimise::explode_ws(',', trim($str_value)); + + $str_value[0] = csstidy_optimise::explode_ws(' ', trim($str_value[0])); + + for ($j = 0; $j < count($str_value[0]); $j++) { + if ($have['weight'] === false && in_array($str_value[0][$j], $font_weight)) { + $return['font-weight'] = $str_value[0][$j]; + $have['weight'] = true; + } elseif ($have['variant'] === false && in_array($str_value[0][$j], $font_variant)) { + $return['font-variant'] = $str_value[0][$j]; + $have['variant'] = true; + } elseif ($have['style'] === false && in_array($str_value[0][$j], $font_style)) { + $return['font-style'] = $str_value[0][$j]; + $have['style'] = true; + } elseif ($have['size'] === false && (is_numeric($str_value[0][$j]{0}) || $str_value[0][$j]{0} === null || $str_value[0][$j]{0} === '.')) { + $size = csstidy_optimise::explode_ws('/', trim($str_value[0][$j])); + $return['font-size'] = $size[0]; + if (isset($size[1])) { + $return['line-height'] = $size[1]; + } else { + $return['line-height'] = ''; // don't add 'normal' ! + } + $have['size'] = true; + } else { + if (isset($return['font-family'])) { + $return['font-family'] .= ' ' . $str_value[0][$j]; + $multiwords = true; + } else { + $return['font-family'] = $str_value[0][$j]; + } + } + } + // add quotes if we have several qords in font-family + if ($multiwords !== false) { + $return['font-family'] = '"' . $return['font-family'] . '"'; + } + $i = 1; + while (isset($str_value[$i])) { + $return['font-family'] .= ',' . trim($str_value[$i]); + $i++; + } + + // Fix for 100 and more font-size + if ($have['size'] === false && isset($return['font-weight']) && + is_numeric($return['font-weight']{0})) { + $return['font-size'] = $return['font-weight']; + unset($return['font-weight']); + } + + foreach ($font_prop_default as $font_prop => $default_value) { + if ($return[$font_prop] !== null) { + $return[$font_prop] = $return[$font_prop] . $important; + } + else + $return[$font_prop] = $default_value . $important; + } + return $return; + } + + /** + * Merges all fonts properties + * @param array $input_css + * @return array + * @version 1.3 + * @see dissolve_short_font() + */ + function merge_font($input_css) { + $font_prop_default = & $GLOBALS['csstidy']['font_prop_default']; + $new_font_value = ''; + $important = ''; + // Skip if not font-family and font-size set + if (isset($input_css['font-family']) && isset($input_css['font-size'])) { + // fix several words in font-family - add quotes + if (isset($input_css['font-family'])) { + $families = explode(",", $input_css['font-family']); + $result_families = array(); + foreach ($families as $family) { + $family = trim($family); + $len = strlen($family); + if (strpos($family, " ") && + !(($family{0} == '"' && $family{$len - 1} == '"') || + ($family{0} == "'" && $family{$len - 1} == "'"))) { + $family = '"' . $family . '"'; + } + $result_families[] = $family; + } + $input_css['font-family'] = implode(",", $result_families); + } + foreach ($font_prop_default as $font_property => $default_value) { + + // Skip if property does not exist + if (!isset($input_css[$font_property])) { + continue; + } + + $cur_value = $input_css[$font_property]; + + // Skip if default value is used + if ($cur_value === $default_value) { + continue; + } + + // Remove !important + if (csstidy::is_important($cur_value)) { + $important = '!important'; + $cur_value = csstidy::gvw_important($cur_value); + } + + $new_font_value .= $cur_value; + // Add delimiter + $new_font_value .= ( $font_property === 'font-size' && + isset($input_css['line-height'])) ? '/' : ' '; + } + + $new_font_value = trim($new_font_value); + + // Delete all font-properties + foreach ($font_prop_default as $font_property => $default_value) { + if ($font_property!=='font' OR !$new_font_value) + unset($input_css[$font_property]); + } + + // Add new font property + if ($new_font_value !== '') { + $input_css['font'] = $new_font_value . $important; + } + } + + return $input_css; + } -class csstidy_optimise -{ - /** - * Constructor - * @param array $css contains the class csstidy - * @access private - * @version 1.0 - */ - function csstidy_optimise(&$css) - { - $this->parser =& $css; - $this->css =& $css->css; - $this->sub_value =& $css->sub_value; - $this->at =& $css->at; - $this->selector =& $css->selector; - $this->property =& $css->property; - $this->value =& $css->value; - } - - /** - * Optimises $css after parsing - * @access public - * @version 1.0 - */ - function postparse() - { - if ($this->parser->get_cfg('preserve_css')) { - return; - } - - if ($this->parser->get_cfg('merge_selectors') == 2) - { - foreach ($this->css as $medium => $value) - { - $this->merge_selectors($this->css[$medium]); - } - } - - if ($this->parser->get_cfg('optimise_shorthands') > 0) - { - foreach ($this->css as $medium => $value) - { - foreach ($value as $selector => $value1) - { - $this->css[$medium][$selector] = csstidy_optimise::merge_4value_shorthands($this->css[$medium][$selector]); - - if ($this->parser->get_cfg('optimise_shorthands') < 2) { - continue; - } - - $this->css[$medium][$selector] = csstidy_optimise::merge_bg($this->css[$medium][$selector]); - if (empty($this->css[$medium][$selector])) { - unset($this->css[$medium][$selector]); - } - } - } - } - } - - /** - * Optimises values - * @access public - * @version 1.0 - */ - function value() - { - $shorthands =& $GLOBALS['csstidy']['shorthands']; - - // optimise shorthand properties - if(isset($shorthands[$this->property])) - { - $temp = csstidy_optimise::shorthand($this->value); // FIXME - move - if($temp != $this->value) - { - $this->parser->log('Optimised shorthand notation ('.$this->property.'): Changed "'.$this->value.'" to "'.$temp.'"','Information'); - } - $this->value = $temp; - } - - // Remove whitespace at ! important - if($this->value != $this->compress_important($this->value)) - { - $this->parser->log('Optimised !important','Information'); - } - } - - /** - * Optimises shorthands - * @access public - * @version 1.0 - */ - function shorthands() - { - $shorthands =& $GLOBALS['csstidy']['shorthands']; - - if(!$this->parser->get_cfg('optimise_shorthands') || $this->parser->get_cfg('preserve_css')) { - return; - } - - if($this->property == 'background' && $this->parser->get_cfg('optimise_shorthands') > 1) - { - unset($this->css[$this->at][$this->selector]['background']); - $this->parser->merge_css_blocks($this->at,$this->selector,csstidy_optimise::dissolve_short_bg($this->value)); - } - if(isset($shorthands[$this->property])) - { - $this->parser->merge_css_blocks($this->at,$this->selector,csstidy_optimise::dissolve_4value_shorthands($this->property,$this->value)); - if(is_array($shorthands[$this->property])) - { - unset($this->css[$this->at][$this->selector][$this->property]); - } - } - } - - /** - * Optimises a sub-value - * @access public - * @version 1.0 - */ - function subvalue() - { - $replace_colors =& $GLOBALS['csstidy']['replace_colors']; - - $this->sub_value = trim($this->sub_value); - if($this->sub_value == '') // caution : '0' - { - return; - } - - $important = ''; - if(csstidy::is_important($this->sub_value)) - { - $important = '!important'; - } - $this->sub_value = csstidy::gvw_important($this->sub_value); - - // Compress font-weight - if($this->property == 'font-weight' && $this->parser->get_cfg('compress_font-weight')) - { - if($this->sub_value == 'bold') - { - $this->sub_value = '700'; - $this->parser->log('Optimised font-weight: Changed "bold" to "700"','Information'); - } - else if($this->sub_value == 'normal') - { - $this->sub_value = '400'; - $this->parser->log('Optimised font-weight: Changed "normal" to "400"','Information'); - } - } - - $temp = $this->compress_numbers($this->sub_value); - if($temp != $this->sub_value) - { - if(strlen($temp) > strlen($this->sub_value)) { - $this->parser->log('Fixed invalid number: Changed "'.$this->sub_value.'" to "'.$temp.'"','Warning'); - } else { - $this->parser->log('Optimised number: Changed "'.$this->sub_value.'" to "'.$temp.'"','Information'); - } - $this->sub_value = $temp; - } - if($this->parser->get_cfg('compress_colors')) - { - $temp = $this->cut_color($this->sub_value); - if($temp !== $this->sub_value) - { - if(isset($replace_colors[$this->sub_value])) { - $this->parser->log('Fixed invalid color name: Changed "'.$this->sub_value.'" to "'.$temp.'"','Warning'); - } else { - $this->parser->log('Optimised color: Changed "'.$this->sub_value.'" to "'.$temp.'"','Information'); - } - $this->sub_value = $temp; - } - } - $this->sub_value .= $important; - } - - /** - * Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px - * @param string $value - * @access public - * @return string - * @version 1.0 - */ - function shorthand($value) - { - $important = ''; - if(csstidy::is_important($value)) - { - $values = csstidy::gvw_important($value); - $important = '!important'; - } - else $values = $value; - - $values = explode(' ',$values); - switch(count($values)) - { - case 4: - if($values[0] == $values[1] && $values[0] == $values[2] && $values[0] == $values[3]) - { - return $values[0].$important; - } - elseif($values[1] == $values[3] && $values[0] == $values[2]) - { - return $values[0].' '.$values[1].$important; - } - elseif($values[1] == $values[3]) - { - return $values[0].' '.$values[1].' '.$values[2].$important; - } - break; - - case 3: - if($values[0] == $values[1] && $values[0] == $values[2]) - { - return $values[0].$important; - } - elseif($values[0] == $values[2]) - { - return $values[0].' '.$values[1].$important; - } - break; - - case 2: - if($values[0] == $values[1]) - { - return $values[0].$important; - } - break; - } - - return $value; - } - - /** - * Removes unnecessary whitespace in ! important - * @param string $string - * @return string - * @access public - * @version 1.1 - */ - function compress_important(&$string) - { - if(csstidy::is_important($string)) - { - $string = csstidy::gvw_important($string) . '!important'; - } - return $string; - } - - /** - * Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values. - * @param string $color - * @return string - * @version 1.1 - */ - function cut_color($color) - { - $replace_colors =& $GLOBALS['csstidy']['replace_colors']; - - // rgb(0,0,0) -> #000000 (or #000 in this case later) - if(strtolower(substr($color,0,4)) == 'rgb(') - { - $color_tmp = substr($color,4,strlen($color)-5); - $color_tmp = explode(',',$color_tmp); - for ( $i = 0; $i < count($color_tmp); $i++ ) - { - $color_tmp[$i] = trim ($color_tmp[$i]); - if(substr($color_tmp[$i],-1) == '%') - { - $color_tmp[$i] = round((255*$color_tmp[$i])/100); - } - if($color_tmp[$i]>255) $color_tmp[$i] = 255; - } - $color = '#'; - for ($i = 0; $i < 3; $i++ ) - { - if($color_tmp[$i]<16) { - $color .= '0' . dechex($color_tmp[$i]); - } else { - $color .= dechex($color_tmp[$i]); - } - } - } - - // Fix bad color names - if(isset($replace_colors[strtolower($color)])) - { - $color = $replace_colors[strtolower($color)]; - } - - // #aabbcc -> #abc - if(strlen($color) == 7) - { - $color_temp = strtolower($color); - if($color_temp{0} == '#' && $color_temp{1} == $color_temp{2} && $color_temp{3} == $color_temp{4} && $color_temp{5} == $color_temp{6}) - { - $color = '#'.$color{1}.$color{3}.$color{5}; - } - } - - switch(strtolower($color)) - { - /* color name -> hex code */ - case 'black': return '#000'; - case 'fuchsia': return '#F0F'; - case 'white': return '#FFF'; - case 'yellow': return '#FF0'; - - /* hex code -> color name */ - case '#800000': return 'maroon'; - case '#ffa500': return 'orange'; - case '#808000': return 'olive'; - case '#800080': return 'purple'; - case '#008000': return 'green'; - case '#000080': return 'navy'; - case '#008080': return 'teal'; - case '#c0c0c0': return 'silver'; - case '#808080': return 'gray'; - case '#f00': return 'red'; - } - - return $color; - } - - /** - * Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 ) - * @param string $subvalue - * @return string - * @version 1.2 - */ - function compress_numbers($subvalue) - { - $units =& $GLOBALS['csstidy']['units']; - $unit_values =& $GLOBALS['csstidy']['unit_values']; - $color_values =& $GLOBALS['csstidy']['color_values']; - - // for font:1em/1em sans-serif...; - if($this->property == 'font') - { - $temp = explode('/',$subvalue); - } - else - { - $temp = array($subvalue); - } - for ($l = 0; $l < count($temp); $l++) - { - // continue if no numeric value - if (!(strlen($temp[$l]) > 0 && ( is_numeric($temp[$l]{0}) || $temp[$l]{0} == '+' || $temp[$l]{0} == '-' ) )) - { - continue; - } - - // Fix bad colors - if (in_array($this->property, $color_values)) - { - $temp[$l] = '#'.$temp[$l]; - } - - if (floatval($temp[$l]) == 0) - { - $temp[$l] = '0'; - } - else - { - $unit_found = FALSE; - for ($m = 0, $size_4 = count($units); $m < $size_4; $m++) - { - if (strpos(strtolower($temp[$l]),$units[$m]) !== FALSE) - { - $temp[$l] = floatval($temp[$l]).$units[$m]; - $unit_found = TRUE; - break; - } - } - if (!$unit_found && in_array($this->property,$unit_values,TRUE)) - { - $temp[$l] = floatval($temp[$l]).'px'; - } - else if (!$unit_found) - { - $temp[$l] = floatval($temp[$l]); - } - // Remove leading zero - if (abs(floatval($temp[$l])) < 1) { - if (floatval($temp[$l]) < 0) { - $temp[$l] = '-' . substr($temp[$l], 2); - } else { - $temp[$l] = substr($temp[$l], 1); - } - } - } - } - - return ((count($temp) > 1) ? $temp[0].'/'.$temp[1] : $temp[0]); - } - - /** - * Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red} - * Very basic and has at least one bug. Hopefully there is a replacement soon. - * @param array $array - * @return array - * @access public - * @version 1.2 - */ - function merge_selectors(&$array) - { - $css = $array; - foreach($css as $key => $value) - { - if(!isset($css[$key])) - { - continue; - } - $newsel = ''; - - // Check if properties also exist in another selector - $keys = array(); - // PHP bug (?) without $css = $array; here - foreach($css as $selector => $vali) - { - if($selector == $key) - { - continue; - } - - if($css[$key] === $vali) - { - $keys[] = $selector; - } - } - - if(!empty($keys)) - { - $newsel = $key; - unset($css[$key]); - foreach($keys as $selector) - { - unset($css[$selector]); - $newsel .= ','.$selector; - } - $css[$newsel] = $value; - } - } - $array = $css; - } - - /** - * Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;... - * @param string $property - * @param string $value - * @return array - * @version 1.0 - * @see merge_4value_shorthands() - */ - function dissolve_4value_shorthands($property,$value) - { - $shorthands =& $GLOBALS['csstidy']['shorthands']; - if(!is_array($shorthands[$property])) - { - $return[$property] = $value; - return $return; - } - - $important = ''; - if(csstidy::is_important($value)) - { - $value = csstidy::gvw_important($value); - $important = '!important'; - } - $values = explode(' ',$value); - - - $return = array(); - if(count($values) == 4) - { - for($i=0;$i<4;$i++) - { - $return[$shorthands[$property][$i]] = $values[$i].$important; - } - } - elseif(count($values) == 3) - { - $return[$shorthands[$property][0]] = $values[0].$important; - $return[$shorthands[$property][1]] = $values[1].$important; - $return[$shorthands[$property][3]] = $values[1].$important; - $return[$shorthands[$property][2]] = $values[2].$important; - } - elseif(count($values) == 2) - { - for($i=0;$i<4;$i++) - { - $return[$shorthands[$property][$i]] = (($i % 2 != 0)) ? $values[1].$important : $values[0].$important; - } - } - else - { - for($i=0;$i<4;$i++) - { - $return[$shorthands[$property][$i]] = $values[0].$important; - } - } - - return $return; - } - - /** - * Explodes a string as explode() does, however, not if $sep is escaped or within a string. - * @param string $sep seperator - * @param string $string - * @return array - * @version 1.0 - */ - function explode_ws($sep,$string) - { - $status = 'st'; - $to = ''; - - $output = array(); - $num = 0; - for($i = 0, $len = strlen($string);$i < $len; $i++) - { - switch($status) - { - case 'st': - if($string{$i} == $sep && !csstidy::escaped($string,$i)) - { - ++$num; - } - elseif($string{$i} == '"' || $string{$i} == '\'' || $string{$i} == '(' && !csstidy::escaped($string,$i)) - { - $status = 'str'; - $to = ($string{$i} == '(') ? ')' : $string{$i}; - (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i}; - } - else - { - (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i}; - } - break; - - case 'str': - if($string{$i} == $to && !csstidy::escaped($string,$i)) - { - $status = 'st'; - } - (isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i}; - break; - } - } - - if(isset($output[0])) - { - return $output; - } - else - { - return array($output); - } - } - - /** - * Merges Shorthand properties again, the opposite of dissolve_4value_shorthands() - * @param array $array - * @return array - * @version 1.2 - * @see dissolve_4value_shorthands() - */ - function merge_4value_shorthands($array) - { - $return = $array; - $shorthands =& $GLOBALS['csstidy']['shorthands']; - - foreach($shorthands as $key => $value) - { - if(isset($array[$value[0]]) && isset($array[$value[1]]) - && isset($array[$value[2]]) && isset($array[$value[3]]) && $value !== 0) - { - $return[$key] = ''; - - $important = ''; - for($i = 0; $i < 4; $i++) - { - $val = $array[$value[$i]]; - if(csstidy::is_important($val)) - { - $important = '!important'; - $return[$key] .= csstidy::gvw_important($val).' '; - } - else - { - $return[$key] .= $val.' '; - } - unset($return[$value[$i]]); - } - $return[$key] = csstidy_optimise::shorthand(trim($return[$key].$important)); - } - } - return $return; - } - - /** - * Dissolve background property - * @param string $str_value - * @return array - * @version 1.0 - * @see merge_bg() - * @todo full CSS 3 compliance - */ - function dissolve_short_bg($str_value) - { - $background_prop_default =& $GLOBALS['csstidy']['background_prop_default']; - $repeat = array('repeat','repeat-x','repeat-y','no-repeat','space'); - $attachment = array('scroll','fixed','local'); - $clip = array('border','padding'); - $origin = array('border','padding','content'); - $pos = array('top','center','bottom','left','right'); - $important = ''; - $return = array('background-image' => NULL,'background-size' => NULL,'background-repeat' => NULL,'background-position' => NULL,'background-attachment'=>NULL,'background-clip' => NULL,'background-origin' => NULL,'background-color' => NULL); - - if(csstidy::is_important($str_value)) - { - $important = ' !important'; - $str_value = csstidy::gvw_important($str_value); - } - - $str_value = csstidy_optimise::explode_ws(',',$str_value); - for($i = 0; $i < count($str_value); $i++) - { - $have['clip'] = FALSE; $have['pos'] = FALSE; - $have['color'] = FALSE; $have['bg'] = FALSE; - - $str_value[$i] = csstidy_optimise::explode_ws(' ',trim($str_value[$i])); - - for($j = 0; $j < count($str_value[$i]); $j++) - { - if($have['bg'] === FALSE && (substr($str_value[$i][$j],0,4) == 'url(' || $str_value[$i][$j] === 'none')) - { - $return['background-image'] .= $str_value[$i][$j].','; - $have['bg'] = TRUE; - } - elseif(in_array($str_value[$i][$j],$repeat,TRUE)) - { - $return['background-repeat'] .= $str_value[$i][$j].','; - } - elseif(in_array($str_value[$i][$j],$attachment,TRUE)) - { - $return['background-attachment'] .= $str_value[$i][$j].','; - } - elseif(in_array($str_value[$i][$j],$clip,TRUE) && !$have['clip']) - { - $return['background-clip'] .= $str_value[$i][$j].','; - $have['clip'] = TRUE; - } - elseif(in_array($str_value[$i][$j],$origin,TRUE)) - { - $return['background-origin'] .= $str_value[$i][$j].','; - } - elseif($str_value[$i][$j]{0} == '(') - { - $return['background-size'] .= substr($str_value[$i][$j],1,-1).','; - } - elseif(in_array($str_value[$i][$j],$pos,TRUE) || is_numeric($str_value[$i][$j]{0}) || $str_value[$i][$j]{0} === NULL) - { - $return['background-position'] .= $str_value[$i][$j]; - if(!$have['pos']) $return['background-position'] .= ' '; else $return['background-position'].= ','; - $have['pos'] = TRUE; - } - elseif(!$have['color']) - { - $return['background-color'] .= $str_value[$i][$j].','; - $have['color'] = TRUE; - } - } - } - - foreach($background_prop_default as $bg_prop => $default_value) - { - if($return[$bg_prop] !== NULL) - { - $return[$bg_prop] = substr($return[$bg_prop],0,-1).$important; - } - else $return[$bg_prop] = $default_value.$important; - } - return $return; - } - - /** - * Merges all background properties - * @param array $input_css - * @return array - * @version 1.0 - * @see dissolve_short_bg() - * @todo full CSS 3 compliance - */ - function merge_bg($input_css) - { - $background_prop_default =& $GLOBALS['csstidy']['background_prop_default']; - // Max number of background images. CSS3 not yet fully implemented - $number_of_values = @max(count(csstidy_optimise::explode_ws(',',$input_css['background-image'])),count(csstidy_optimise::explode_ws(',',$input_css['background-color'])),1); - // Array with background images to check if BG image exists - $bg_img_array = @csstidy_optimise::explode_ws(',',csstidy::gvw_important($input_css['background-image'])); - $new_bg_value = ''; - $important = ''; - - for($i = 0; $i < $number_of_values; $i++) - { - foreach($background_prop_default as $bg_property => $default_value) - { - // Skip if property does not exist - if(!isset($input_css[$bg_property])) - { - continue; - } - - $cur_value = $input_css[$bg_property]; - - // Skip some properties if there is no background image - if((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none') - && ($bg_property === 'background-size' || $bg_property === 'background-position' - || $bg_property === 'background-attachment' || $bg_property === 'background-repeat')) - { - continue; - } - - // Remove !important - if(csstidy::is_important($cur_value)) - { - $important = ' !important'; - $cur_value = csstidy::gvw_important($cur_value); - } - - // Do not add default values - if($cur_value === $default_value) - { - continue; - } - - $temp = csstidy_optimise::explode_ws(',',$cur_value); - - if(isset($temp[$i])) - { - if($bg_property == 'background-size') - { - $new_bg_value .= '('.$temp[$i].') '; - } - else - { - $new_bg_value .= $temp[$i].' '; - } - } - } - - $new_bg_value = trim($new_bg_value); - if($i != $number_of_values-1) $new_bg_value .= ','; - } - - // Delete all background-properties - foreach($background_prop_default as $bg_property => $default_value) - { - unset($input_css[$bg_property]); - } - - // Add new background property - if($new_bg_value !== '') $input_css['background'] = $new_bg_value.$important; - - return $input_css; - } } -?> \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/class.csstidy_print.php b/engine/lib/external/CSSTidy-1.3/class.csstidy_print.php index ec962031..96b76a09 100644 --- a/engine/lib/external/CSSTidy-1.3/class.csstidy_print.php +++ b/engine/lib/external/CSSTidy-1.3/class.csstidy_print.php @@ -1,29 +1,33 @@ . * - * You should have received a copy of the GNU General Public License - * along with CSSTidy; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License * @package csstidy - * @author Florian Schmitz (floele at gmail dot com) 2005-2006 + * @author Florian Schmitz (floele at gmail dot com) 2005-2007 + * @author Brett Zamir (brettz9 at yahoo dot com) 2007 + * @author Cedric Morin (cedric at yterium dot com) 2010 */ /** @@ -33,317 +37,370 @@ * * @package csstidy * @author Florian Schmitz (floele at gmail dot com) 2005-2006 - * @version 1.0 + * @version 1.0.1 */ +class csstidy_print { -class csstidy_print -{ - /** - * Saves the input CSS string - * @var string - * @access private - */ - var $input_css = ''; + /** + * Saves the input CSS string + * @var string + * @access private + */ + var $input_css = ''; + /** + * Saves the formatted CSS string + * @var string + * @access public + */ + var $output_css = ''; + /** + * Saves the formatted CSS string (plain text) + * @var string + * @access public + */ + var $output_css_plain = ''; - /** - * Saves the formatted CSS string - * @var string - * @access public - */ - var $output_css = ''; + /** + * Constructor + * @param array $css contains the class csstidy + * @access private + * @version 1.0 + */ + function csstidy_print(&$css) { + $this->parser = & $css; + $this->css = & $css->css; + $this->template = & $css->template; + $this->tokens = & $css->tokens; + $this->charset = & $css->charset; + $this->import = & $css->import; + $this->namespace = & $css->namespace; + } - /** - * Saves the formatted CSS string (plain text) - * @var string - * @access public - */ - var $output_css_plain = ''; + /** + * Resets output_css and output_css_plain (new css code) + * @access private + * @version 1.0 + */ + function _reset() { + $this->output_css = ''; + $this->output_css_plain = ''; + } - /** - * Constructor - * @param array $css contains the class csstidy - * @access private - * @version 1.0 - */ - function csstidy_print(&$css) - { - $this->parser =& $css; - $this->css =& $css->css; - $this->template =& $css->template; - $this->tokens =& $css->tokens; - $this->charset =& $css->charset; - $this->import =& $css->import; - $this->namespace =& $css->namespace; - } + /** + * Returns the CSS code as plain text + * @param string $default_media default @media to add to selectors without any @media + * @return string + * @access public + * @version 1.0 + */ + function plain($default_media='') { + $this->_print(true, $default_media); + return $this->output_css_plain; + } - /** - * Resets output_css and output_css_plain (new css code) - * @access private - * @version 1.0 - */ - function _reset() - { - $this->output_css = ''; - $this->output_css_plain = ''; - } + /** + * Returns the formatted CSS code + * @param string $default_media default @media to add to selectors without any @media + * @return string + * @access public + * @version 1.0 + */ + function formatted($default_media='') { + $this->_print(false, $default_media); + return $this->output_css; + } - /** - * Returns the CSS code as plain text - * @return string - * @access public - * @version 1.0 - */ - function plain() - { - $this->_print(true); - return $this->output_css_plain; - } + /** + * Returns the formatted CSS code to make a complete webpage + * @param string $doctype shorthand for the document type + * @param bool $externalcss indicates whether styles to be attached internally or as an external stylesheet + * @param string $title title to be added in the head of the document + * @param string $lang two-letter language code to be added to the output + * @return string + * @access public + * @version 1.4 + */ + function formatted_page($doctype='xhtml1.1', $externalcss=true, $title='', $lang='en') { + switch ($doctype) { + case 'xhtml1.0strict': + $doctype_output = ''; + break; + case 'xhtml1.1': + default: + $doctype_output = ''; + break; + } - /** - * Returns the formatted CSS code - * @return string - * @access public - * @version 1.0 - */ - function formatted() - { - $this->_print(false); - return $this->output_css; - } + $output = $cssparsed = ''; + $this->output_css_plain = & $output; - /** - * Returns the formatted CSS Code and saves it into $this->output_css and $this->output_css_plain - * @param bool $plain plain text or not - * @access private - * @version 2.0 - */ - function _print($plain = false) - { - if ($this->output_css && $this->output_css_plain) { - return; - } + $output .= $doctype_output . "\n" . '' : ' lang="' . $lang . '">'; + $output .= "\n\n $title"; - $output = ''; - if (!$this->parser->get_cfg('preserve_css')) { - $this->_convert_raw_css(); - } + if ($externalcss) { + $output .= "\n "; + } else { + $output .= "\n" . ' '; +// } + } + $output .= "\n\n"; + $output .= $this->formatted(); + $output .= '' . "\n" . ''; + return $this->output_css_plain; + } - $template =& $this->template; + /** + * Returns the formatted CSS Code and saves it into $this->output_css and $this->output_css_plain + * @param bool $plain plain text or not + * @param string $default_media default @media to add to selectors without any @media + * @access private + * @version 2.0 + */ + function _print($plain = false, $default_media='') { + if ($this->output_css && $this->output_css_plain) { + return; + } - if ($plain) { - $template = array_map('strip_tags', $template); - } + $output = ''; + if (!$this->parser->get_cfg('preserve_css')) { + $this->_convert_raw_css($default_media); + } - if ($this->parser->get_cfg('timestamp')) { - array_unshift($this->tokens, array(COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . date('r') . ' ')); - } + $template = & $this->template; - if (!empty($this->charset)) { - $output .= $template[0].'@charset '.$template[5].$this->charset.$template[6]; - } + if ($plain) { + $template = array_map('strip_tags', $template); + } - if (!empty($this->import)) { - for ($i = 0, $size = count($this->import); $i < $size; $i ++) { - $output .= $template[0].'@import '.$template[5].$this->import[$i].$template[6]; - } - } + if ($this->parser->get_cfg('timestamp')) { + array_unshift($this->tokens, array(COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . date('r') . ' ')); + } - if (!empty($this->namespace)) { - $output .= $template[0].'@namespace '.$template[5].$this->namespace.$template[6]; - } + if (!empty($this->charset)) { + $output .= $template[0] . '@charset ' . $template[5] . $this->charset . $template[6]; + } - $output .= $template[13]; - $in_at_out = ''; - $out =& $output; + if (!empty($this->import)) { + for ($i = 0, $size = count($this->import); $i < $size; $i++) { + if (substr($this->import[$i], 0, 4) === 'url(' && substr($this->import[$i], -1, 1) === ')') { + $this->import[$i] = '\'' . substr($this->import[$i], 4, -1) . '\''; + $this->parser->log('Optimised @import : Removed "url("', 'Information'); + } + $output .= $template[0] . '@import ' . $template[5] . $this->import[$i] . $template[6]; + } + } - foreach ($this->tokens as $key => $token) - { - switch ($token[0]) - { - case AT_START: - $out .= $template[0].$this->_htmlsp($token[1], $plain).$template[1]; - $out =& $in_at_out; - break; + if (!empty($this->namespace)) { + if (substr($this->namespace, 0, 4) === 'url(' && substr($this->namespace, -1, 1) === ')') { + $this->namespace = '\'' . substr($this->namespace, 4, -1) . '\''; + $this->parser->log('Optimised @namespace : Removed "url("', 'Information'); + } + $output .= $template[0] . '@namespace ' . $template[5] . $this->namespace . $template[6]; + } - case SEL_START: - if($this->parser->get_cfg('lowercase_s')) $token[1] = strtolower($token[1]); - $out .= ($token[1]{0} !== '@') ? $template[2].$this->_htmlsp($token[1], $plain) : $template[0].$this->_htmlsp($token[1], $plain); - $out .= $template[3]; - break; + $output .= $template[13]; + $in_at_out = ''; + $out = & $output; - case PROPERTY: - if($this->parser->get_cfg('case_properties') == 2) $token[1] = strtoupper($token[1]); - if($this->parser->get_cfg('case_properties') == 1) $token[1] = strtolower($token[1]); - $out .= $template[4] . $this->_htmlsp($token[1], $plain) . ':' . $template[5]; - break; + foreach ($this->tokens as $key => $token) { + switch ($token[0]) { + case AT_START: + $out .= $template[0] . $this->_htmlsp($token[1], $plain) . $template[1]; + $out = & $in_at_out; + break; - case VALUE: - $out .= $this->_htmlsp($token[1], $plain); - if($this->_seeknocomment($key, 1) == SEL_END && $this->parser->get_cfg('remove_last_;')) { - $out .= str_replace(';', '', $template[6]); - } else { - $out .= $template[6]; - } - break; + case SEL_START: + if ($this->parser->get_cfg('lowercase_s')) + $token[1] = strtolower($token[1]); + $out .= ( $token[1]{0} !== '@') ? $template[2] . $this->_htmlsp($token[1], $plain) : $template[0] . $this->_htmlsp($token[1], $plain); + $out .= $template[3]; + break; - case SEL_END: - $out .= $template[7]; - if($this->_seeknocomment($key, 1) != AT_END) $out .= $template[8]; - break; + case PROPERTY: + if ($this->parser->get_cfg('case_properties') === 2) { + $token[1] = strtoupper($token[1]); + } elseif ($this->parser->get_cfg('case_properties') === 1) { + $token[1] = strtolower($token[1]); + } + $out .= $template[4] . $this->_htmlsp($token[1], $plain) . ':' . $template[5]; + break; - case AT_END: - $out =& $output; - $out .= $template[10] . str_replace("\n", "\n" . $template[10], $in_at_out); - $in_at_out = ''; - $out .= $template[9]; - break; + case VALUE: + $out .= $this->_htmlsp($token[1], $plain); + if ($this->_seeknocomment($key, 1) == SEL_END && $this->parser->get_cfg('remove_last_;')) { + $out .= str_replace(';', '', $template[6]); + } else { + $out .= $template[6]; + } + break; - case COMMENT: - $out .= $template[11] . '/*' . $this->_htmlsp($token[1], $plain) . '*/' . $template[12]; - break; - } - } + case SEL_END: + $out .= $template[7]; + if ($this->_seeknocomment($key, 1) != AT_END) + $out .= $template[8]; + break; - $output = trim($output); + case AT_END: + $out = & $output; + $out .= $template[10] . str_replace("\n", "\n" . $template[10], $in_at_out); + $in_at_out = ''; + $out .= $template[9]; + break; - if (!$plain) { - $this->output_css = $output; - $this->_print(true); - } else { - $this->output_css_plain = $output; - } - } + case COMMENT: + $out .= $template[11] . '/*' . $this->_htmlsp($token[1], $plain) . '*/' . $template[12]; + break; + } + } - /** - * Gets the next token type which is $move away from $key, excluding comments - * @param integer $key current position - * @param integer $move move this far - * @return mixed a token type - * @access private - * @version 1.0 - */ - function _seeknocomment($key, $move) { - $go = ($move > 0) ? 1 : -1; - for ($i = $key + 1; abs($key-$i)-1 < abs($move); $i += $go) { - if (!isset($this->tokens[$i])) { - return; - } - if ($this->tokens[$i][0] == COMMENT) { - $move += 1; - continue; - } - return $this->tokens[$i][0]; - } - } + $output = trim($output); - /** - * Converts $this->css array to a raw array ($this->tokens) - * @access private - * @version 1.0 - */ - function _convert_raw_css() - { - $this->tokens = array(); + if (!$plain) { + $this->output_css = $output; + $this->_print(true); + } else { + // If using spaces in the template, don't want these to appear in the plain output + $this->output_css_plain = str_replace(' ', '', $output); + } + } - foreach ($this->css as $medium => $val) - { - if ($this->parser->get_cfg('sort_selectors')) ksort($val); - if ($medium != DEFAULT_AT) { - $this->parser->_add_token(AT_START, $medium, true); - } + /** + * Gets the next token type which is $move away from $key, excluding comments + * @param integer $key current position + * @param integer $move move this far + * @return mixed a token type + * @access private + * @version 1.0 + */ + function _seeknocomment($key, $move) { + $go = ($move > 0) ? 1 : -1; + for ($i = $key + 1; abs($key - $i) - 1 < abs($move); $i += $go) { + if (!isset($this->tokens[$i])) { + return; + } + if ($this->tokens[$i][0] == COMMENT) { + $move += 1; + continue; + } + return $this->tokens[$i][0]; + } + } - foreach ($val as $selector => $vali) - { - if ($this->parser->get_cfg('sort_properties')) ksort($vali); - $this->parser->_add_token(SEL_START, $selector, true); + /** + * Converts $this->css array to a raw array ($this->tokens) + * @param string $default_media default @media to add to selectors without any @media + * @access private + * @version 1.0 + */ + function _convert_raw_css($default_media='') { + $this->tokens = array(); - foreach ($vali as $property => $valj) - { - $this->parser->_add_token(PROPERTY, $property, true); - $this->parser->_add_token(VALUE, $valj, true); - } + foreach ($this->css as $medium => $val) { + if ($this->parser->get_cfg('sort_selectors')) + ksort($val); + if (intval($medium) < DEFAULT_AT) { + $this->parser->_add_token(AT_START, $medium, true); + } + elseif ($default_media) { + $this->parser->_add_token(AT_START, $default_media, true); + } + + foreach ($val as $selector => $vali) { + if ($this->parser->get_cfg('sort_properties')) + ksort($vali); + $this->parser->_add_token(SEL_START, $selector, true); - $this->parser->_add_token(SEL_END, $selector, true); - } + foreach ($vali as $property => $valj) { + $this->parser->_add_token(PROPERTY, $property, true); + $this->parser->_add_token(VALUE, $valj, true); + } - if ($medium != DEFAULT_AT) { - $this->parser->_add_token(AT_END, $medium, true); - } - } - } + $this->parser->_add_token(SEL_END, $selector, true); + } - /** - * Same as htmlspecialchars, only that chars are not replaced if $plain !== true. This makes print_code() cleaner. - * @param string $string - * @param bool $plain - * @return string - * @see csstidy_print::_print() - * @access private - * @version 1.0 - */ - function _htmlsp($string, $plain) - { - if (!$plain) { - return htmlspecialchars($string); - } - return $string; - } + if (intval($medium) < DEFAULT_AT) { + $this->parser->_add_token(AT_END, $medium, true); + } + elseif ($default_media) { + $this->parser->_add_token(AT_END, $default_media, true); + } + } + } - /** - * Get compression ratio - * @access public - * @return float - * @version 1.2 - */ - function get_ratio() - { - if (!$this->output_css_plain) { - $this->formatted(); - } - return round((strlen($this->input_css) - strlen($this->output_css_plain)) / strlen($this->input_css), 3) * 100; - } + /** + * Same as htmlspecialchars, only that chars are not replaced if $plain !== true. This makes print_code() cleaner. + * @param string $string + * @param bool $plain + * @return string + * @see csstidy_print::_print() + * @access private + * @version 1.0 + */ + function _htmlsp($string, $plain) { + if (!$plain) { + return htmlspecialchars($string, ENT_QUOTES, 'utf-8'); + } + return $string; + } - /** - * Get difference between the old and new code in bytes and prints the code if necessary. - * @access public - * @return string - * @version 1.1 - */ - function get_diff() - { - if (!$this->output_css_plain) { - $this->formatted(); - } + /** + * Get compression ratio + * @access public + * @return float + * @version 1.2 + */ + function get_ratio() { + if (!$this->output_css_plain) { + $this->formatted(); + } + return round((strlen($this->input_css) - strlen($this->output_css_plain)) / strlen($this->input_css), 3) * 100; + } - $diff = strlen($this->output_css_plain) - strlen($this->input_css); + /** + * Get difference between the old and new code in bytes and prints the code if necessary. + * @access public + * @return string + * @version 1.1 + */ + function get_diff() { + if (!$this->output_css_plain) { + $this->formatted(); + } - if ($diff > 0) { - return '+' . $diff; - } elseif ($diff == 0) { - return '+-' . $diff; - } + $diff = strlen($this->output_css_plain) - strlen($this->input_css); - return $diff; - } + if ($diff > 0) { + return '+' . $diff; + } elseif ($diff == 0) { + return '+-' . $diff; + } - /** - * Get the size of either input or output CSS in KB - * @param string $loc default is "output" - * @access public - * @return integer - * @version 1.0 - */ - function size($loc = 'output') - { - if ($loc == 'output' && !$this->output_css) { - $this->formatted(); - } + return $diff; + } + + /** + * Get the size of either input or output CSS in KB + * @param string $loc default is "output" + * @access public + * @return integer + * @version 1.0 + */ + function size($loc = 'output') { + if ($loc === 'output' && !$this->output_css) { + $this->formatted(); + } + + if ($loc === 'input') { + return (strlen($this->input_css) / 1000); + } else { + return (strlen($this->output_css_plain) / 1000); + } + } - if ($loc == 'input') { - return (strlen($this->input_css) / 1000); - } else { - return (strlen($this->output_css_plain) / 1000); - } - } } -?> \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/css_optimiser.php b/engine/lib/external/CSSTidy-1.3/css_optimiser.php new file mode 100644 index 00000000..24f021cd --- /dev/null +++ b/engine/lib/external/CSSTidy-1.3/css_optimiser.php @@ -0,0 +1,478 @@ +. + * + * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License + * @package csstidy + * @author Florian Schmitz (floele at gmail dot com) 2005-2007 + * @author Brett Zamir (brettz9 at yahoo dot com) 2007 + */ + +require('class.csstidy.php'); +require('lang.inc.php'); + + +if (get_magic_quotes_gpc()) { + if (isset($_REQUEST['css_text'])) { + $_REQUEST['css_text'] = stripslashes($_REQUEST['css_text']); + } + if (isset($_REQUEST['custom'])) { + $_REQUEST['custom'] = stripslashes($_REQUEST['custom']); + } + if (isset($_COOKIE['custom_template'])) { + $_COOKIE['custom_template'] = stripslashes($_COOKIE['custom_template']); + } +} + +function rmdirr($dirname,$oc=0) +{ + // Sanity check + if (!file_exists($dirname)) { + return false; + } + // Simple delete for a file + if (is_file($dirname) && (time()-fileatime($dirname))>3600) { + return unlink($dirname); + } + // Loop through the folder + if(is_dir($dirname)) + { + $dir = dir($dirname); + while (false !== $entry = $dir->read()) { + // Skip pointers + if ($entry === '.' || $entry === '..') { + continue; + } + // Recurse + rmdirr($dirname.'/'.$entry,$oc); + } + $dir->close(); + } + // Clean up + if ($oc==1) + { + return rmdir($dirname); + } +} + +function options($options, $selected = null, $labelIsValue = false) +{ + $html = ''; + + settype($selected, 'array'); + settype($options, 'array'); + + foreach ($options as $value=>$label) + { + if (is_array($label)) { + $value = $label[0]; + $label = $label[1]; + } + $label = htmlspecialchars($label, ENT_QUOTES, 'utf-8'); + $value = $labelIsValue ? $label + : htmlspecialchars($value, ENT_QUOTES, 'utf-8'); + + $html .= ''; + } + + return $html; +} + +$css = new csstidy(); +$is_custom = isset($_REQUEST['custom']) && !empty($_REQUEST['custom']) && isset($_REQUEST['template']) && ($_REQUEST['template'] === '4'); +if($is_custom) +{ + setcookie ('custom_template', $_REQUEST['custom'], time()+360000); +} + +rmdirr('temp'); + +if(isset($_REQUEST['case_properties'])) $css->set_cfg('case_properties',$_REQUEST['case_properties']); +if(isset($_REQUEST['lowercase'])) $css->set_cfg('lowercase_s',true); +if(!isset($_REQUEST['compress_c']) && isset($_REQUEST['post'])) $css->set_cfg('compress_colors',false); +if(!isset($_REQUEST['compress_fw']) && isset($_REQUEST['post'])) $css->set_cfg('compress_font-weight',false); +if(isset($_REQUEST['merge_selectors'])) $css->set_cfg('merge_selectors', $_REQUEST['merge_selectors']); +if(isset($_REQUEST['optimise_shorthands'])) $css->set_cfg('optimise_shorthands',$_REQUEST['optimise_shorthands']); +if(!isset($_REQUEST['rbs']) && isset($_REQUEST['post'])) $css->set_cfg('remove_bslash',false); +if(isset($_REQUEST['preserve_css'])) $css->set_cfg('preserve_css',true); +if(isset($_REQUEST['sort_sel'])) $css->set_cfg('sort_selectors',true); +if(isset($_REQUEST['sort_de'])) $css->set_cfg('sort_properties',true); +if(isset($_REQUEST['remove_last_sem'])) $css->set_cfg('remove_last_;',true); +if(isset($_REQUEST['discard'])) $css->set_cfg('discard_invalid_properties',true); +if(isset($_REQUEST['css_level'])) $css->set_cfg('css_level',$_REQUEST['css_level']); +if(isset($_REQUEST['timestamp'])) $css->set_cfg('timestamp',true); + + +// This by itself is enough since our scripts don't use DOM to create elements (in which case the namespace aware ones +// should be used when serving as application/xhtml+xml but not when served as text/html ; +// also, case will be different when retrieving element names, as HTML DOM returns in upper case, +// genuine XHTML DOM (when XHTML served as such) as lower +if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml')) { + $http_accept = 'application/xhtml+xml'; +} +elseif (stristr($_SERVER['HTTP_ACCEPT'], 'application/xml')) { + $http_accept = 'application/xml'; +} +elseif (stristr($_SERVER['HTTP_ACCEPT'], 'text/xml')) { + $http_accept = 'text/xml'; +} +elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'Opera ') || stristr($_SERVER['HTTP_USER_AGENT'], 'Opera/')) { + preg_match('@Opera/(\d)@', $_SERVER['HTTP_USER_AGENT'], $matches); + if (isset($matches[1]) && $matches[1] >= 7) { + $http_accept = 'application/xhtml+xml'; + } + else { + $http_accept = 'text/html'; + } +} +else { + $http_accept = 'text/html'; +} + +header('Content-Type: '.$http_accept.'; charset=utf-8'); + +if ($http_accept === 'text/html') { +?> + + + + + + + + + <?php echo $lang[$l][0]; echo $css->version; ?>) + + + + + +

+ +

+ csstidy version; ?>) +

+ : English Deutsch French Chinese

+

+ +

+ +
+
+
+ + + size="35" />
+ +
+
+
+
+ +
+
+ + + get_cfg('preserve_css')) echo 'checked="checked"'; ?> /> +
+ + + get_cfg('sort_selectors')) echo 'checked="checked"'; ?> /> +
+ + + get_cfg('sort_properties')) echo 'checked="checked"'; ?> /> +
+ + + +
+ + +
+ + + get_cfg('compress_colors')) echo 'checked="checked"';?> /> +
+ + + get_cfg('compress_font-weight')) echo 'checked="checked"';?> /> +
+ + + get_cfg('lowercase_s')) echo 'checked="checked"'; ?> /> +
+ + +
+ get_cfg('case_properties') === 0) echo 'checked="checked"'; ?> /> + + get_cfg('case_properties') === 1) echo 'checked="checked"'; ?> /> + + get_cfg('case_properties') === 2) echo 'checked="checked"'; ?> /> +
+ + get_cfg('remove_bslash')) echo 'checked="checked"'; ?> /> +
+ + + get_cfg('remove_last_;')) echo 'checked="checked"'; ?> /> +
+ + + get_cfg('discard_invalid_properties')) echo 'checked="checked"'; ?> /> + +
+ + + get_cfg('timestamp')) echo 'checked="checked"'; ?> /> +
+ + /> +
+ + + /> +
+ +
+ +
+
+
+ load_template($_REQUEST['custom'],false); + } + break; + + case 3: + $css->load_template('highest_compression'); + break; + + case 2: + $css->load_template('high_compression'); + break; + + case 0: + $css->load_template('low_compression'); + break; + } + } + + if($url) + { + if(substr($_REQUEST['url'],0,7) !== 'http://') + { + $_REQUEST['url'] = 'http://'.$_REQUEST['url']; + } + $result = $css->parse_from_url($_REQUEST['url'],0); + } + elseif(isset($_REQUEST['css_text']) && strlen($_REQUEST['css_text'])>5) + { + $result = $css->parse($_REQUEST['css_text']); + } + + if($result) + { + $ratio = $css->print->get_ratio(); + $diff = $css->print->get_diff(); + if(isset($_REQUEST['file_output'])) + { + $filename = md5(mt_rand().time().mt_rand()); + if (!is_dir('temp')) { + $madedir = mkdir('temp'); + if (!$madedir) { + print 'Could not make directory "temp" in '.dirname(__FILE__); + exit; + } + } + $handle = fopen('temp/'.$filename.'.css','w'); + if($handle) { + if(fwrite($handle,$css->print->plain())) + { + $file_ok = true; + } + } + fclose($handle); + } + if($ratio>0) $ratio = ''.$ratio.'% + ('.$diff.' Bytes)'; else $ratio = ''.$ratio.'% ('.$diff.' Bytes)'; + if(count($css->log) > 0): ?> +
Messages +
log as $line => $array) + { + echo '
',$line,'
'; + $array_size = count($array); + for($i = 0; $i < $array_size; ++$i) + { + echo '
',$array[$i]['m'],'
'; + } + } + ?>
+
+ ',$lang[$l][37],': ',$css->print->size('input'),'KB, ',$lang[$l][38],':',$css->print->size('output'),'KB, ',$lang[$l][36],': ',$ratio; + if($file_ok) + { + echo ' - Download'; + } + echo ' - ',$lang[$l][58],''; + echo ''; + echo ''; + echo $css->print->formatted(); + echo '

'; + + echo '
',$lang[$l][64],''; + echo '
'; + echo '
',$lang[$l][65],''; + echo ''; + + echo '

↑ ',$lang[$l][59],'

'; + + } + elseif(isset($_REQUEST['css_text']) || isset($_REQUEST['url'])) { + echo '

',$lang[$l][28],'

'; + } + ?> +

+ . +

+ + \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/cssparse.css b/engine/lib/external/CSSTidy-1.3/cssparse.css index bd8cc13e..38fc40b4 100644 --- a/engine/lib/external/CSSTidy-1.3/cssparse.css +++ b/engine/lib/external/CSSTidy-1.3/cssparse.css @@ -1,4 +1,6 @@ -body { +@import url("cssparsed.css"); + +html, body { font:0.8em Verdana,Helvetica,sans-serif; background:#F8F8F6; } @@ -17,6 +19,9 @@ margin:0.5em 0; padding:1em; border:solid #7284AB 2px; } +fieldset.code_output { +display:inline; +} h1 { font-size:2em; @@ -55,30 +60,6 @@ padding:2px 4px; border:dashed 1px; } -span.at { -color:darkblue; -} - -span.format { -color:gray; -} - -span.property { -color:green; -} - -span.selector { -color:blue; -} - -span.value { -color:red; -} - -span.comment { -color:orange; -} - textarea#css_text { width:27em; height:370px; diff --git a/engine/lib/external/CSSTidy-1.3/cssparsed.css b/engine/lib/external/CSSTidy-1.3/cssparsed.css new file mode 100644 index 00000000..5aaf2bb1 --- /dev/null +++ b/engine/lib/external/CSSTidy-1.3/cssparsed.css @@ -0,0 +1,29 @@ +code#copytext { + white-space: pre; + font-family: Verdana; +} + +.at { +color:darkblue; +} + +.format { +color:gray; +} + +.property { +color:green; +} + +.selector { +color:blue; +} + +.value { +color:red; +left: 500px; +} + +.comment { +color:orange; +} \ No newline at end of file diff --git a/engine/lib/external/CSSTidy-1.3/data.inc.php b/engine/lib/external/CSSTidy-1.3/data.inc.php index 8c7b2720..b926a4b8 100644 --- a/engine/lib/external/CSSTidy-1.3/data.inc.php +++ b/engine/lib/external/CSSTidy-1.3/data.inc.php @@ -21,6 +21,7 @@ * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @package csstidy * @author Florian Schmitz (floele at gmail dot com) 2005 + * @author Nikolay Matsievsky (speed at webo dot name) 2010 */ define('AT_START', 1); @@ -74,10 +75,10 @@ $GLOBALS['csstidy']['at_rules'] = array('page' => 'is','font-face' => 'is','char * @version 1.2 */ $GLOBALS['csstidy']['unit_values'] = array ('background', 'background-position', 'border', 'border-top', 'border-right', 'border-bottom', 'border-left', 'border-width', - 'border-top-width', 'border-right-width', 'border-left-width', 'border-bottom-width', 'bottom', 'border-spacing', 'font-size', - 'height', 'left', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'max-height', 'max-width', - 'min-height', 'min-width', 'outline-width', 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left', - 'position', 'right', 'top', 'text-indent', 'letter-spacing', 'word-spacing', 'width'); + 'border-top-width', 'border-right-width', 'border-left-width', 'border-bottom-width', 'bottom', 'border-spacing', + 'font-size', 'height', 'left', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'max-height', + 'max-width', 'min-height', 'min-width', 'outline', 'outline-width', 'padding', 'padding-top', 'padding-right', + 'padding-bottom', 'padding-left', 'right', 'top', 'text-indent', 'letter-spacing', 'word-spacing', 'width'); /** * Properties that allow as value @@ -97,7 +98,6 @@ $GLOBALS['csstidy']['color_values'][] = 'border-left-color'; $GLOBALS['csstidy']['color_values'][] = 'color'; $GLOBALS['csstidy']['color_values'][] = 'outline-color'; - /** * Default values for the background properties * @@ -117,6 +117,21 @@ $GLOBALS['csstidy']['background_prop_default']['background-clip'] = 'border'; $GLOBALS['csstidy']['background_prop_default']['background-origin'] = 'padding'; $GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparent'; +/** + * Default values for the font properties + * + * @global array $GLOBALS['csstidy']['font_prop_default'] + * @see merge_fonts() + * @version 1.3 + */ +$GLOBALS['csstidy']['font_prop_default'] = array(); +$GLOBALS['csstidy']['font_prop_default']['font-style'] = 'normal'; +$GLOBALS['csstidy']['font_prop_default']['font-variant'] = 'normal'; +$GLOBALS['csstidy']['font_prop_default']['font-weight'] = 'normal'; +$GLOBALS['csstidy']['font_prop_default']['font-size'] = ''; +$GLOBALS['csstidy']['font_prop_default']['line-height'] = ''; +$GLOBALS['csstidy']['font_prop_default']['font-family'] = ''; + /** * A list of non-W3C color names which get replaced by their hex-codes * @@ -125,133 +140,132 @@ $GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparen * @version 1.0 */ $GLOBALS['csstidy']['replace_colors'] = array(); -$GLOBALS['csstidy']['replace_colors']['aliceblue'] = '#F0F8FF'; -$GLOBALS['csstidy']['replace_colors']['antiquewhite'] = '#FAEBD7'; -$GLOBALS['csstidy']['replace_colors']['aquamarine'] = '#7FFFD4'; -$GLOBALS['csstidy']['replace_colors']['azure'] = '#F0FFFF'; -$GLOBALS['csstidy']['replace_colors']['beige'] = '#F5F5DC'; -$GLOBALS['csstidy']['replace_colors']['bisque'] = '#FFE4C4'; -$GLOBALS['csstidy']['replace_colors']['blanchedalmond'] = '#FFEBCD'; -$GLOBALS['csstidy']['replace_colors']['blueviolet'] = '#8A2BE2'; -$GLOBALS['csstidy']['replace_colors']['brown'] = '#A52A2A'; -$GLOBALS['csstidy']['replace_colors']['burlywood'] = '#DEB887'; -$GLOBALS['csstidy']['replace_colors']['cadetblue'] = '#5F9EA0'; -$GLOBALS['csstidy']['replace_colors']['chartreuse'] = '#7FFF00'; -$GLOBALS['csstidy']['replace_colors']['chocolate'] = '#D2691E'; -$GLOBALS['csstidy']['replace_colors']['coral'] = '#FF7F50'; -$GLOBALS['csstidy']['replace_colors']['cornflowerblue'] = '#6495ED'; -$GLOBALS['csstidy']['replace_colors']['cornsilk'] = '#FFF8DC'; -$GLOBALS['csstidy']['replace_colors']['crimson'] = '#DC143C'; -$GLOBALS['csstidy']['replace_colors']['cyan'] = '#00FFFF'; -$GLOBALS['csstidy']['replace_colors']['darkblue'] = '#00008B'; -$GLOBALS['csstidy']['replace_colors']['darkcyan'] = '#008B8B'; -$GLOBALS['csstidy']['replace_colors']['darkgoldenrod'] = '#B8860B'; -$GLOBALS['csstidy']['replace_colors']['darkgray'] = '#A9A9A9'; +$GLOBALS['csstidy']['replace_colors']['aliceblue'] = '#f0f8ff'; +$GLOBALS['csstidy']['replace_colors']['antiquewhite'] = '#faebd7'; +$GLOBALS['csstidy']['replace_colors']['aquamarine'] = '#7fffd4'; +$GLOBALS['csstidy']['replace_colors']['azure'] = '#f0ffff'; +$GLOBALS['csstidy']['replace_colors']['beige'] = '#f5f5dc'; +$GLOBALS['csstidy']['replace_colors']['bisque'] = '#ffe4c4'; +$GLOBALS['csstidy']['replace_colors']['blanchedalmond'] = '#ffebcd'; +$GLOBALS['csstidy']['replace_colors']['blueviolet'] = '#8a2be2'; +$GLOBALS['csstidy']['replace_colors']['brown'] = '#a52a2a'; +$GLOBALS['csstidy']['replace_colors']['burlywood'] = '#deb887'; +$GLOBALS['csstidy']['replace_colors']['cadetblue'] = '#5f9ea0'; +$GLOBALS['csstidy']['replace_colors']['chartreuse'] = '#7fff00'; +$GLOBALS['csstidy']['replace_colors']['chocolate'] = '#d2691e'; +$GLOBALS['csstidy']['replace_colors']['coral'] = '#ff7f50'; +$GLOBALS['csstidy']['replace_colors']['cornflowerblue'] = '#6495ed'; +$GLOBALS['csstidy']['replace_colors']['cornsilk'] = '#fff8dc'; +$GLOBALS['csstidy']['replace_colors']['crimson'] = '#dc143c'; +$GLOBALS['csstidy']['replace_colors']['cyan'] = '#00ffff'; +$GLOBALS['csstidy']['replace_colors']['darkblue'] = '#00008b'; +$GLOBALS['csstidy']['replace_colors']['darkcyan'] = '#008b8b'; +$GLOBALS['csstidy']['replace_colors']['darkgoldenrod'] = '#b8860b'; +$GLOBALS['csstidy']['replace_colors']['darkgray'] = '#a9a9a9'; $GLOBALS['csstidy']['replace_colors']['darkgreen'] = '#006400'; -$GLOBALS['csstidy']['replace_colors']['darkkhaki'] = '#BDB76B'; -$GLOBALS['csstidy']['replace_colors']['darkmagenta'] = '#8B008B'; -$GLOBALS['csstidy']['replace_colors']['darkolivegreen'] = '#556B2F'; -$GLOBALS['csstidy']['replace_colors']['darkorange'] = '#FF8C00'; -$GLOBALS['csstidy']['replace_colors']['darkorchid'] = '#9932CC'; -$GLOBALS['csstidy']['replace_colors']['darkred'] = '#8B0000'; -$GLOBALS['csstidy']['replace_colors']['darksalmon'] = '#E9967A'; -$GLOBALS['csstidy']['replace_colors']['darkseagreen'] = '#8FBC8F'; -$GLOBALS['csstidy']['replace_colors']['darkslateblue'] = '#483D8B'; -$GLOBALS['csstidy']['replace_colors']['darkslategray'] = '#2F4F4F'; -$GLOBALS['csstidy']['replace_colors']['darkturquoise'] = '#00CED1'; -$GLOBALS['csstidy']['replace_colors']['darkviolet'] = '#9400D3'; -$GLOBALS['csstidy']['replace_colors']['deeppink'] = '#FF1493'; -$GLOBALS['csstidy']['replace_colors']['deepskyblue'] = '#00BFFF'; +$GLOBALS['csstidy']['replace_colors']['darkkhaki'] = '#bdb76b'; +$GLOBALS['csstidy']['replace_colors']['darkmagenta'] = '#8b008b'; +$GLOBALS['csstidy']['replace_colors']['darkolivegreen'] = '#556b2f'; +$GLOBALS['csstidy']['replace_colors']['darkorange'] = '#ff8c00'; +$GLOBALS['csstidy']['replace_colors']['darkorchid'] = '#9932cc'; +$GLOBALS['csstidy']['replace_colors']['darkred'] = '#8b0000'; +$GLOBALS['csstidy']['replace_colors']['darksalmon'] = '#e9967a'; +$GLOBALS['csstidy']['replace_colors']['darkseagreen'] = '#8fbc8f'; +$GLOBALS['csstidy']['replace_colors']['darkslateblue'] = '#483d8b'; +$GLOBALS['csstidy']['replace_colors']['darkslategray'] = '#2f4f4f'; +$GLOBALS['csstidy']['replace_colors']['darkturquoise'] = '#00ced1'; +$GLOBALS['csstidy']['replace_colors']['darkviolet'] = '#9400d3'; +$GLOBALS['csstidy']['replace_colors']['deeppink'] = '#ff1493'; +$GLOBALS['csstidy']['replace_colors']['deepskyblue'] = '#00bfff'; $GLOBALS['csstidy']['replace_colors']['dimgray'] = '#696969'; -$GLOBALS['csstidy']['replace_colors']['dodgerblue'] = '#1E90FF'; -$GLOBALS['csstidy']['replace_colors']['feldspar'] = '#D19275'; -$GLOBALS['csstidy']['replace_colors']['firebrick'] = '#B22222'; -$GLOBALS['csstidy']['replace_colors']['floralwhite'] = '#FFFAF0'; -$GLOBALS['csstidy']['replace_colors']['forestgreen'] = '#228B22'; -$GLOBALS['csstidy']['replace_colors']['gainsboro'] = '#DCDCDC'; -$GLOBALS['csstidy']['replace_colors']['ghostwhite'] = '#F8F8FF'; -$GLOBALS['csstidy']['replace_colors']['gold'] = '#FFD700'; -$GLOBALS['csstidy']['replace_colors']['goldenrod'] = '#DAA520'; -$GLOBALS['csstidy']['replace_colors']['greenyellow'] = '#ADFF2F'; -$GLOBALS['csstidy']['replace_colors']['honeydew'] = '#F0FFF0'; -$GLOBALS['csstidy']['replace_colors']['hotpink'] = '#FF69B4'; -$GLOBALS['csstidy']['replace_colors']['indianred'] = '#CD5C5C'; -$GLOBALS['csstidy']['replace_colors']['indigo'] = '#4B0082'; -$GLOBALS['csstidy']['replace_colors']['ivory'] = '#FFFFF0'; -$GLOBALS['csstidy']['replace_colors']['khaki'] = '#F0E68C'; -$GLOBALS['csstidy']['replace_colors']['lavender'] = '#E6E6FA'; -$GLOBALS['csstidy']['replace_colors']['lavenderblush'] = '#FFF0F5'; -$GLOBALS['csstidy']['replace_colors']['lawngreen'] = '#7CFC00'; -$GLOBALS['csstidy']['replace_colors']['lemonchiffon'] = '#FFFACD'; -$GLOBALS['csstidy']['replace_colors']['lightblue'] = '#ADD8E6'; -$GLOBALS['csstidy']['replace_colors']['lightcoral'] = '#F08080'; -$GLOBALS['csstidy']['replace_colors']['lightcyan'] = '#E0FFFF'; -$GLOBALS['csstidy']['replace_colors']['lightgoldenrodyellow'] = '#FAFAD2'; -$GLOBALS['csstidy']['replace_colors']['lightgrey'] = '#D3D3D3'; -$GLOBALS['csstidy']['replace_colors']['lightgreen'] = '#90EE90'; -$GLOBALS['csstidy']['replace_colors']['lightpink'] = '#FFB6C1'; -$GLOBALS['csstidy']['replace_colors']['lightsalmon'] = '#FFA07A'; -$GLOBALS['csstidy']['replace_colors']['lightseagreen'] = '#20B2AA'; -$GLOBALS['csstidy']['replace_colors']['lightskyblue'] = '#87CEFA'; -$GLOBALS['csstidy']['replace_colors']['lightslateblue'] = '#8470FF'; +$GLOBALS['csstidy']['replace_colors']['dodgerblue'] = '#1e90ff'; +$GLOBALS['csstidy']['replace_colors']['feldspar'] = '#d19275'; +$GLOBALS['csstidy']['replace_colors']['firebrick'] = '#b22222'; +$GLOBALS['csstidy']['replace_colors']['floralwhite'] = '#fffaf0'; +$GLOBALS['csstidy']['replace_colors']['forestgreen'] = '#228b22'; +$GLOBALS['csstidy']['replace_colors']['gainsboro'] = '#dcdcdc'; +$GLOBALS['csstidy']['replace_colors']['ghostwhite'] = '#f8f8ff'; +$GLOBALS['csstidy']['replace_colors']['gold'] = '#ffd700'; +$GLOBALS['csstidy']['replace_colors']['goldenrod'] = '#daa520'; +$GLOBALS['csstidy']['replace_colors']['greenyellow'] = '#adff2f'; +$GLOBALS['csstidy']['replace_colors']['honeydew'] = '#f0fff0'; +$GLOBALS['csstidy']['replace_colors']['hotpink'] = '#ff69b4'; +$GLOBALS['csstidy']['replace_colors']['indianred'] = '#cd5c5c'; +$GLOBALS['csstidy']['replace_colors']['indigo'] = '#4b0082'; +$GLOBALS['csstidy']['replace_colors']['ivory'] = '#fffff0'; +$GLOBALS['csstidy']['replace_colors']['khaki'] = '#f0e68c'; +$GLOBALS['csstidy']['replace_colors']['lavender'] = '#e6e6fa'; +$GLOBALS['csstidy']['replace_colors']['lavenderblush'] = '#fff0f5'; +$GLOBALS['csstidy']['replace_colors']['lawngreen'] = '#7cfc00'; +$GLOBALS['csstidy']['replace_colors']['lemonchiffon'] = '#fffacd'; +$GLOBALS['csstidy']['replace_colors']['lightblue'] = '#add8e6'; +$GLOBALS['csstidy']['replace_colors']['lightcoral'] = '#f08080'; +$GLOBALS['csstidy']['replace_colors']['lightcyan'] = '#e0ffff'; +$GLOBALS['csstidy']['replace_colors']['lightgoldenrodyellow'] = '#fafad2'; +$GLOBALS['csstidy']['replace_colors']['lightgrey'] = '#d3d3d3'; +$GLOBALS['csstidy']['replace_colors']['lightgreen'] = '#90ee90'; +$GLOBALS['csstidy']['replace_colors']['lightpink'] = '#ffb6c1'; +$GLOBALS['csstidy']['replace_colors']['lightsalmon'] = '#ffa07a'; +$GLOBALS['csstidy']['replace_colors']['lightseagreen'] = '#20b2aa'; +$GLOBALS['csstidy']['replace_colors']['lightskyblue'] = '#87cefa'; +$GLOBALS['csstidy']['replace_colors']['lightslateblue'] = '#8470ff'; $GLOBALS['csstidy']['replace_colors']['lightslategray'] = '#778899'; -$GLOBALS['csstidy']['replace_colors']['lightsteelblue'] = '#B0C4DE'; -$GLOBALS['csstidy']['replace_colors']['lightyellow'] = '#FFFFE0'; -$GLOBALS['csstidy']['replace_colors']['limegreen'] = '#32CD32'; -$GLOBALS['csstidy']['replace_colors']['linen'] = '#FAF0E6'; -$GLOBALS['csstidy']['replace_colors']['magenta'] = '#FF00FF'; -$GLOBALS['csstidy']['replace_colors']['mediumaquamarine'] = '#66CDAA'; -$GLOBALS['csstidy']['replace_colors']['mediumblue'] = '#0000CD'; -$GLOBALS['csstidy']['replace_colors']['mediumorchid'] = '#BA55D3'; -$GLOBALS['csstidy']['replace_colors']['mediumpurple'] = '#9370D8'; -$GLOBALS['csstidy']['replace_colors']['mediumseagreen'] = '#3CB371'; -$GLOBALS['csstidy']['replace_colors']['mediumslateblue'] = '#7B68EE'; -$GLOBALS['csstidy']['replace_colors']['mediumspringgreen'] = '#00FA9A'; -$GLOBALS['csstidy']['replace_colors']['mediumturquoise'] = '#48D1CC'; -$GLOBALS['csstidy']['replace_colors']['mediumvioletred'] = '#C71585'; +$GLOBALS['csstidy']['replace_colors']['lightsteelblue'] = '#b0c4de'; +$GLOBALS['csstidy']['replace_colors']['lightyellow'] = '#ffffe0'; +$GLOBALS['csstidy']['replace_colors']['limegreen'] = '#32cd32'; +$GLOBALS['csstidy']['replace_colors']['linen'] = '#faf0e6'; +$GLOBALS['csstidy']['replace_colors']['magenta'] = '#ff00ff'; +$GLOBALS['csstidy']['replace_colors']['mediumaquamarine'] = '#66cdaa'; +$GLOBALS['csstidy']['replace_colors']['mediumblue'] = '#0000cd'; +$GLOBALS['csstidy']['replace_colors']['mediumorchid'] = '#ba55d3'; +$GLOBALS['csstidy']['replace_colors']['mediumpurple'] = '#9370d8'; +$GLOBALS['csstidy']['replace_colors']['mediumseagreen'] = '#3cb371'; +$GLOBALS['csstidy']['replace_colors']['mediumslateblue'] = '#7b68ee'; +$GLOBALS['csstidy']['replace_colors']['mediumspringgreen'] = '#00fa9a'; +$GLOBALS['csstidy']['replace_colors']['mediumturquoise'] = '#48d1cc'; +$GLOBALS['csstidy']['replace_colors']['mediumvioletred'] = '#c71585'; $GLOBALS['csstidy']['replace_colors']['midnightblue'] = '#191970'; -$GLOBALS['csstidy']['replace_colors']['mintcream'] = '#F5FFFA'; -$GLOBALS['csstidy']['replace_colors']['mistyrose'] = '#FFE4E1'; -$GLOBALS['csstidy']['replace_colors']['moccasin'] = '#FFE4B5'; -$GLOBALS['csstidy']['replace_colors']['navajowhite'] = '#FFDEAD'; -$GLOBALS['csstidy']['replace_colors']['oldlace'] = '#FDF5E6'; -$GLOBALS['csstidy']['replace_colors']['olivedrab'] = '#6B8E23'; -$GLOBALS['csstidy']['replace_colors']['orangered'] = '#FF4500'; -$GLOBALS['csstidy']['replace_colors']['orchid'] = '#DA70D6'; -$GLOBALS['csstidy']['replace_colors']['palegoldenrod'] = '#EEE8AA'; -$GLOBALS['csstidy']['replace_colors']['palegreen'] = '#98FB98'; -$GLOBALS['csstidy']['replace_colors']['paleturquoise'] = '#AFEEEE'; -$GLOBALS['csstidy']['replace_colors']['palevioletred'] = '#D87093'; -$GLOBALS['csstidy']['replace_colors']['papayawhip'] = '#FFEFD5'; -$GLOBALS['csstidy']['replace_colors']['peachpuff'] = '#FFDAB9'; -$GLOBALS['csstidy']['replace_colors']['peru'] = '#CD853F'; -$GLOBALS['csstidy']['replace_colors']['pink'] = '#FFC0CB'; -$GLOBALS['csstidy']['replace_colors']['plum'] = '#DDA0DD'; -$GLOBALS['csstidy']['replace_colors']['powderblue'] = '#B0E0E6'; -$GLOBALS['csstidy']['replace_colors']['rosybrown'] = '#BC8F8F'; -$GLOBALS['csstidy']['replace_colors']['royalblue'] = '#4169E1'; -$GLOBALS['csstidy']['replace_colors']['saddlebrown'] = '#8B4513'; -$GLOBALS['csstidy']['replace_colors']['salmon'] = '#FA8072'; -$GLOBALS['csstidy']['replace_colors']['sandybrown'] = '#F4A460'; -$GLOBALS['csstidy']['replace_colors']['seagreen'] = '#2E8B57'; -$GLOBALS['csstidy']['replace_colors']['seashell'] = '#FFF5EE'; -$GLOBALS['csstidy']['replace_colors']['sienna'] = '#A0522D'; -$GLOBALS['csstidy']['replace_colors']['skyblue'] = '#87CEEB'; -$GLOBALS['csstidy']['replace_colors']['slateblue'] = '#6A5ACD'; +$GLOBALS['csstidy']['replace_colors']['mintcream'] = '#f5fffa'; +$GLOBALS['csstidy']['replace_colors']['mistyrose'] = '#ffe4e1'; +$GLOBALS['csstidy']['replace_colors']['moccasin'] = '#ffe4b5'; +$GLOBALS['csstidy']['replace_colors']['navajowhite'] = '#ffdead'; +$GLOBALS['csstidy']['replace_colors']['oldlace'] = '#fdf5e6'; +$GLOBALS['csstidy']['replace_colors']['olivedrab'] = '#6b8e23'; +$GLOBALS['csstidy']['replace_colors']['orangered'] = '#ff4500'; +$GLOBALS['csstidy']['replace_colors']['orchid'] = '#da70d6'; +$GLOBALS['csstidy']['replace_colors']['palegoldenrod'] = '#eee8aa'; +$GLOBALS['csstidy']['replace_colors']['palegreen'] = '#98fb98'; +$GLOBALS['csstidy']['replace_colors']['paleturquoise'] = '#afeeee'; +$GLOBALS['csstidy']['replace_colors']['palevioletred'] = '#d87093'; +$GLOBALS['csstidy']['replace_colors']['papayawhip'] = '#ffefd5'; +$GLOBALS['csstidy']['replace_colors']['peachpuff'] = '#ffdab9'; +$GLOBALS['csstidy']['replace_colors']['peru'] = '#cd853f'; +$GLOBALS['csstidy']['replace_colors']['pink'] = '#ffc0cb'; +$GLOBALS['csstidy']['replace_colors']['plum'] = '#dda0dd'; +$GLOBALS['csstidy']['replace_colors']['powderblue'] = '#b0e0e6'; +$GLOBALS['csstidy']['replace_colors']['rosybrown'] = '#bc8f8f'; +$GLOBALS['csstidy']['replace_colors']['royalblue'] = '#4169e1'; +$GLOBALS['csstidy']['replace_colors']['saddlebrown'] = '#8b4513'; +$GLOBALS['csstidy']['replace_colors']['salmon'] = '#fa8072'; +$GLOBALS['csstidy']['replace_colors']['sandybrown'] = '#f4a460'; +$GLOBALS['csstidy']['replace_colors']['seagreen'] = '#2e8b57'; +$GLOBALS['csstidy']['replace_colors']['seashell'] = '#fff5ee'; +$GLOBALS['csstidy']['replace_colors']['sienna'] = '#a0522d'; +$GLOBALS['csstidy']['replace_colors']['skyblue'] = '#87ceeb'; +$GLOBALS['csstidy']['replace_colors']['slateblue'] = '#6a5acd'; $GLOBALS['csstidy']['replace_colors']['slategray'] = '#708090'; -$GLOBALS['csstidy']['replace_colors']['snow'] = '#FFFAFA'; -$GLOBALS['csstidy']['replace_colors']['springgreen'] = '#00FF7F'; -$GLOBALS['csstidy']['replace_colors']['steelblue'] = '#4682B4'; -$GLOBALS['csstidy']['replace_colors']['tan'] = '#D2B48C'; -$GLOBALS['csstidy']['replace_colors']['thistle'] = '#D8BFD8'; -$GLOBALS['csstidy']['replace_colors']['tomato'] = '#FF6347'; -$GLOBALS['csstidy']['replace_colors']['turquoise'] = '#40E0D0'; -$GLOBALS['csstidy']['replace_colors']['violet'] = '#EE82EE'; -$GLOBALS['csstidy']['replace_colors']['violetred'] = '#D02090'; -$GLOBALS['csstidy']['replace_colors']['wheat'] = '#F5DEB3'; -$GLOBALS['csstidy']['replace_colors']['whitesmoke'] = '#F5F5F5'; -$GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9ACD32'; - +$GLOBALS['csstidy']['replace_colors']['snow'] = '#fffafa'; +$GLOBALS['csstidy']['replace_colors']['springgreen'] = '#00ff7f'; +$GLOBALS['csstidy']['replace_colors']['steelblue'] = '#4682b4'; +$GLOBALS['csstidy']['replace_colors']['tan'] = '#d2b48c'; +$GLOBALS['csstidy']['replace_colors']['thistle'] = '#d8bfd8'; +$GLOBALS['csstidy']['replace_colors']['tomato'] = '#ff6347'; +$GLOBALS['csstidy']['replace_colors']['turquoise'] = '#40e0d0'; +$GLOBALS['csstidy']['replace_colors']['violet'] = '#ee82ee'; +$GLOBALS['csstidy']['replace_colors']['violetred'] = '#d02090'; +$GLOBALS['csstidy']['replace_colors']['wheat'] = '#f5deb3'; +$GLOBALS['csstidy']['replace_colors']['whitesmoke'] = '#f5f5f5'; +$GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9acd32'; /** * A list of all shorthand properties that are devided into four properties and/or have four subvalues diff --git a/engine/lib/external/CSSTidy-1.3/lang.inc.php b/engine/lib/external/CSSTidy-1.3/lang.inc.php index 522447f1..9e6b24b0 100644 --- a/engine/lib/external/CSSTidy-1.3/lang.inc.php +++ b/engine/lib/external/CSSTidy-1.3/lang.inc.php @@ -1,183 +1,248 @@ . + * + * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License + * @package csstidy + * @author Florian Schmitz (floele at gmail dot com) 2005-2007 + * @author Brett Zamir (brettz9 at yahoo dot com) 2007 + */ + + if(isset($_GET['lang'])) { - $l = $_GET['lang']; -} else { - $l = getenv('HTTP_ACCEPT_LANGUAGE'); - $l = strtolower(substr($l,0,2)); + $l = $_GET['lang']; } -$l = ($l == 'de' || $l == 'fr' || $l == 'zh') ? $l : 'en'; +else if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $l = $_SERVER['HTTP_ACCEPT_LANGUAGE']; + $l = strtolower(substr($l, 0, 2)); +} +else { + $l = ''; +} + +$l = (in_array($l, array('de', 'fr', 'zh'))) ? $l : 'en'; + +// note 5 in all but French, and 40 in all are orphaned $lang = array(); $lang['en'][0] = 'CSS Formatter and Optimiser/Optimizer (based on CSSTidy '; -$lang['de'][0] = 'CSS Formatierer und Optimierer (basierend auf CSSTidy '; $lang['en'][1] = 'CSS Formatter and Optimiser'; -$lang['de'][1] = 'CSS Formatierer und Optimierer'; $lang['en'][2] = '(based on'; -$lang['de'][2] = '(basierend auf'; $lang['en'][3] = '(plaintext)'; -$lang['de'][3] = '(Textversion)'; $lang['en'][4] = 'Important Note:'; -$lang['de'][4] = 'Wichtiger Hinweis:'; -$lang['en'][6] = 'Your code should be well-formed. This is no validator which points out errors in your CSS code. To make sure that your code is valid, use the W3C Validator.'; -$lang['de'][6] = 'Der CSS Code sollte wohlgeformt sein. Der CSS Code wird nicht auf Gültigkeit überprüft. Um sicherzugehen dass dein Code valide ist, benutze den W3C Validierungsservice.'; +$lang['en'][6] = 'Your code should be well-formed. This is not a validator which points out errors in your CSS code. To make sure that your code is valid, use the W3C Validator.'; $lang['en'][7] = 'all comments are removed'; -$lang['de'][7] = 'alle Kommentare werden entfernt'; $lang['en'][8] = 'CSS Input:'; -$lang['de'][8] = 'CSS Eingabe:'; $lang['en'][9] = 'CSS-Code:'; -$lang['de'][9] = 'CSS-Code:'; $lang['en'][10] = 'CSS from URL:'; -$lang['de'][10] = 'CSS von URL:'; $lang['en'][11] = 'Code Layout:'; -$lang['de'][11] = 'Code Layout:'; -$lang['en'][12] = 'Compression (code layout):'; -$lang['de'][12] = 'Komprimierung (Code Layout):'; +$lang['en'][12] = 'Compression (code layout):'; $lang['en'][13] = 'Highest (no readability, smallest size)'; -$lang['de'][13] = 'Höchste (keine Lesbarkeit, niedrigste Größe)'; $lang['en'][14] = 'High (moderate readability, smaller size)'; -$lang['de'][14] = 'Hoch (mittelmäßige Lesbarkeit, geringe Größe)'; $lang['en'][15] = 'Standard (balance between readability and size)'; -$lang['de'][15] = 'Standard (Kompromiss zwischen Lesbarkeit und Größe)'; $lang['en'][16] = 'Low (higher readability)'; -$lang['de'][16] = 'Niedrig (höhere Lesbarkeit)'; $lang['en'][17] = 'Custom (enter below)'; -$lang['de'][17] = 'Benutzerdefiniert (unten eingeben)'; $lang['en'][18] = 'Custom template'; -$lang['de'][18] = 'Benutzerdefinierte Vorlage'; $lang['en'][19] = 'Options'; -$lang['de'][19] = 'Optionen'; $lang['en'][20] = 'Sort Selectors (caution)'; -$lang['de'][20] = 'Selektoren sortieren (Vorsicht)'; $lang['en'][21] = 'Sort Properties'; -$lang['de'][21] = 'Eigenschaften sortieren'; $lang['en'][22] = 'Regroup selectors'; -$lang['de'][22] = 'Selektoren umgruppieren'; $lang['en'][23] = 'Optimise shorthands'; -$lang['de'][23] = 'Shorthands optimieren'; $lang['en'][24] = 'Compress colors'; -$lang['de'][24] = 'Farben komprimieren'; $lang['en'][25] = 'Lowercase selectors'; -$lang['de'][25] = 'Selektoren in Kleinbuchstaben'; $lang['en'][26] = 'Case for properties:'; -$lang['de'][26] = 'Groß-/Kleinschreibung für Eigenschaften'; $lang['en'][27] = 'Lowercase'; -$lang['de'][27] = 'Kleinbuchstaben'; -$lang['en'][28] = 'No or invalid CSS input or wrong URL!'; -$lang['de'][28] = 'Keine oder ungültige CSS Eingabe oder falsche URL!'; +$lang['en'][28] = 'No or invalid CSS input or wrong URL!'; $lang['en'][29] = 'Uppercase'; -$lang['de'][29] = 'Großbuchstaben'; $lang['en'][30] = 'lowercase elementnames needed for XHTML'; -$lang['de'][30] = 'kleingeschriebene Elementnamen benötigt für XHTML'; $lang['en'][31] = 'Remove unnecessary backslashes'; -$lang['de'][31] = 'Unnötige Backslashes entfernen'; $lang['en'][32] = 'convert !important-hack'; -$lang['de'][32] = '!important-Hack konvertieren'; $lang['en'][33] = 'Output as file'; -$lang['de'][33] = 'Als Datei ausgeben'; -$lang['en'][34] = 'Bigger compression because of smaller newlines (copy & paste doesn\'t work)'; -$lang['de'][34] = 'Größere Komprimierung augrund von kleineren Neuezeile-Zeichen'; +$lang['en'][34] = 'Bigger compression because of smaller newlines (copy & paste doesn\'t work)'; $lang['en'][35] = 'Process CSS'; -$lang['de'][35] = 'CSS verarbeiten'; $lang['en'][36] = 'Compression Ratio'; -$lang['de'][36] = 'Komprimierungsrate'; $lang['en'][37] = 'Input'; -$lang['de'][37] = 'Eingabe'; $lang['en'][38] = 'Output'; -$lang['de'][38] = 'Ausgabe'; $lang['en'][39] = 'Language'; -$lang['de'][39] = 'Sprache'; $lang['en'][41] = 'Attention: This may change the behaviour of your CSS Code!'; -$lang['de'][41] = 'Achtung: Dies könnte das Verhalten ihres CSS-Codes verändern!'; $lang['en'][42] = 'Remove last ;'; -$lang['de'][42] = 'Letztes ; entfernen'; $lang['en'][43] = 'Discard invalid properties'; -$lang['de'][43] = 'Ungültige Eigenschaften entfernen'; $lang['en'][44] = 'Only safe optimisations'; -$lang['de'][44] = 'Nur sichere Optimierungen'; $lang['en'][45] = 'Compress font-weight'; -$lang['de'][45] = 'font-weight komprimieren'; $lang['en'][46] = 'Save comments'; -$lang['de'][46] = 'Kommentare beibehalten'; $lang['en'][47] = 'Do not change anything'; $lang['en'][48] = 'Only seperate selectors (split at ,)'; $lang['en'][49] = 'Merge selectors with the same properties (fast)'; $lang['en'][50] = 'Merge selectors intelligently (slow)'; +$lang['en'][51] = 'Preserve CSS'; +$lang['en'][52] = 'Save comments, hacks, etc. Most optimisations can *not* be applied if this is enabled.'; +$lang['en'][53] = 'None'; +$lang['en'][54] = 'Don\'t optimise'; +$lang['en'][55] = 'Safe optimisations'; +$lang['en'][56] = 'All optimisations'; +$lang['en'][57] = 'Add timestamp'; +$lang['en'][58] = 'Copy to clipboard'; +$lang['en'][59] = 'Back to top'; +$lang['en'][60] = 'Your browser doesn\'t support copy to clipboard.'; +$lang['en'][61] = 'For bugs and suggestions feel free to'; +$lang['en'][62] = 'contact me'; +$lang['en'][63] = 'Output CSS code as complete HTML document'; +$lang['en'][64] = 'Code'; +$lang['en'][65] = 'CSS to style CSS output'; +$lang['en'][66] = 'You need to go to about:config in your URL bar, select \'signed.applets.codebase_principal_support\' in the filter field, and set its value to true in order to use this feature; however, be aware that doing so increases security risks.'; + + +$lang['de'][0] = 'CSS Formatierer und Optimierer (basierend auf CSSTidy '; +$lang['de'][1] = 'CSS Formatierer und Optimierer'; +$lang['de'][2] = '(basierend auf'; +$lang['de'][3] = '(Textversion)'; +$lang['de'][4] = 'Wichtiger Hinweis:'; +$lang['de'][6] = 'Der CSS Code sollte wohlgeformt sein. Der CSS Code wird nicht auf Gültigkeit überprüft. Um sicherzugehen dass dein Code valide ist, benutze den W3C Validierungsservice.'; +$lang['de'][7] = 'alle Kommentare werden entfernt'; +$lang['de'][8] = 'CSS Eingabe:'; +$lang['de'][9] = 'CSS-Code:'; +$lang['de'][10] = 'CSS von URL:'; +$lang['de'][11] = 'Code Layout:'; +$lang['de'][12] = 'Komprimierung (Code Layout):'; +$lang['de'][13] = 'Höchste (keine Lesbarkeit, niedrigste Größe)'; +$lang['de'][14] = 'Hoch (mittelmäßige Lesbarkeit, geringe Größe)'; +$lang['de'][15] = 'Standard (Kompromiss zwischen Lesbarkeit und Größe)'; +$lang['de'][16] = 'Niedrig (höhere Lesbarkeit)'; +$lang['de'][17] = 'Benutzerdefiniert (unten eingeben)'; +$lang['de'][18] = 'Benutzerdefinierte Vorlage'; +$lang['de'][19] = 'Optionen'; +$lang['de'][20] = 'Selektoren sortieren (Vorsicht)'; +$lang['de'][21] = 'Eigenschaften sortieren'; +$lang['de'][22] = 'Selektoren umgruppieren'; +$lang['de'][23] = 'Shorthands optimieren'; +$lang['de'][24] = 'Farben komprimieren'; +$lang['de'][25] = 'Selektoren in Kleinbuchstaben'; +$lang['de'][26] = 'Groß-/Kleinschreibung für Eigenschaften'; +$lang['de'][27] = 'Kleinbuchstaben'; +$lang['de'][28] = 'Keine oder ungültige CSS Eingabe oder falsche URL!'; +$lang['de'][29] = 'Großbuchstaben'; +$lang['de'][30] = 'kleingeschriebene Elementnamen benötigt für XHTML'; +$lang['de'][31] = 'Unnötige Backslashes entfernen'; +$lang['de'][32] = '!important-Hack konvertieren'; +$lang['de'][33] = 'Als Datei ausgeben'; +$lang['de'][34] = 'Größere Komprimierung augrund von kleineren Neuezeile-Zeichen'; +$lang['de'][35] = 'CSS verarbeiten'; +$lang['de'][36] = 'Komprimierungsrate'; +$lang['de'][37] = 'Eingabe'; +$lang['de'][38] = 'Ausgabe'; +$lang['de'][39] = 'Sprache'; +$lang['de'][41] = 'Achtung: Dies könnte das Verhalten ihres CSS-Codes verändern!'; +$lang['de'][42] = 'Letztes ; entfernen'; +$lang['de'][43] = 'Ungültige Eigenschaften entfernen'; +$lang['de'][44] = 'Nur sichere Optimierungen'; +$lang['de'][45] = 'font-weight komprimieren'; +$lang['de'][46] = 'Kommentare beibehalten'; $lang['de'][47] = 'Nichts ändern'; $lang['de'][48] = 'Selektoren nur trennen (am Komma)'; $lang['de'][49] = 'Selektoren mit gleichen Eigenschaften zusammenfassen (schnell)'; $lang['de'][50] = 'Selektoren intelligent zusammenfassen (langsam!)'; -$lang['en'][51] = 'Preserve CSS'; $lang['de'][51] = 'CSS erhalten'; -$lang['en'][52] = 'Save comments, hacks, etc. Most optimisations can *not* be applied if this is enabled.'; $lang['de'][52] = 'Kommentare, Hacks, etc. speichern. Viele Optimierungen sind dann aber nicht mehr möglich.'; -$lang['en'][53] = 'None'; $lang['de'][53] = 'Keine'; -$lang['en'][54] = 'Don\'t optimise'; $lang['de'][54] = 'Nicht optimieren'; -$lang['en'][55] = 'Safe optimisations'; $lang['de'][55] = 'Sichere Optimierungen'; -$lang['en'][56] = 'All optimisations'; $lang['de'][56] = 'Alle Optimierungen'; -$lang['en'][57] = 'Add timestamp'; $lang['de'][57] = 'Zeitstempel hinzufügen'; +$lang['de'][58] = 'Copy to clipboard'; +$lang['de'][59] = 'Back to top'; +$lang['de'][60] = 'Your browser doesn\'t support copy to clipboard.'; +$lang['de'][61] = 'For bugs and suggestions feel free to'; +$lang['de'][62] = 'contact me'; +$lang['de'][63] = 'Output CSS code as complete HTML document'; +$lang['de'][64] = 'Code'; +$lang['de'][65] = 'CSS to style CSS output'; +$lang['de'][66] = 'You need to go to about:config in your URL bar, select \'signed.applets.codebase_principal_support\' in the filter field, and set its value to true in order to use this feature; however, be aware that doing so increases security risks.'; -$lang['fr'][0] = 'CSS Formatteur et Optimiseur (basé sur CSSTidy '; + +$lang['fr'][0] = 'CSS Formatteur et Optimiseur (basé sur CSSTidy '; $lang['fr'][1] = 'CSS Formatteur et Optimiseur'; $lang['fr'][2] = '(basé sur '; -$lang['fr'][3] = '(Version Text)'; -$lang['fr'][4] = 'notes Importantes:'; -$lang['fr'][5] = 'les mêmes sélecteurs et les propriétés sont automatiquement fusionnés'; -$lang['fr'][6] = 'votre code doit être Valide. Ce n\'est pas un validateur qui signale des erreurs dans votre code de CSS. Assurez-vous que votre code est correct en utilisant le le validateur : W3C Validator'; +$lang['fr'][3] = '(Version texte)'; +$lang['fr'][4] = 'Note Importante :'; +$lang['fr'][6] = 'Votre code doit être valide. Ce n’est pas un validateur qui signale les erreurs dans votre code CSS. Pour être sûr que votre code est correct, utilisez le validateur : W3C Validator.'; $lang['fr'][7] = 'tous les commentaires sont enlevés'; -$lang['fr'][8] = 'Champ CSS:'; -$lang['fr'][9] = 'CSS-Code:'; -$lang['fr'][10] = 'CSS en provenance d\'une URL:
'; -$lang['fr'][11] = 'Mise en page du code:'; -$lang['fr'][12] = 'Compression (Mise en page du code):'; -$lang['fr'][13] = 'Le plus compact (aucune lisibilité, plus petite taille)'; -$lang['fr'][14] = 'Trés compact (lisibilité modérée, plus petite taille)'; -$lang['fr'][15] = 'Normale (équilibre entre la lisibilité et la taille)'; -$lang['fr'][16] = 'Peu compact (une lisibilité plus élevée)'; +$lang['fr'][8] = 'Champ CSS :'; +$lang['fr'][9] = 'Code CSS :'; +$lang['fr'][10] = 'CSS en provenance d’une URL :
'; +$lang['fr'][11] = 'Mise en page du code :'; +$lang['fr'][12] = 'Compression (mise en page du code) :'; +$lang['fr'][13] = 'La plus élevée (aucune lisibilité, taille minimale)'; +$lang['fr'][14] = 'Élevée (lisibilité modérée, petite taille)'; +$lang['fr'][15] = 'Normale (équilibre entre lisibilité et taille)'; +$lang['fr'][16] = 'Faible (lisibilité élevée)'; $lang['fr'][17] = 'Sur mesure (entrer ci-dessous)'; -$lang['fr'][18] = 'Sur mesure Gabarit'; +$lang['fr'][18] = 'Gabarit sur mesure'; $lang['fr'][19] = 'Options'; $lang['fr'][20] = 'Trier les sélecteurs (attention)'; $lang['fr'][21] = 'Trier les propriétés'; -$lang['fr'][22] = 'Fusionner les sélecteurs'; -$lang['fr'][23] = 'Optimise shorthands'; +$lang['fr'][22] = 'Regrouper les sélecteurs'; +$lang['fr'][23] = 'Propriétés raccourcies'; $lang['fr'][24] = 'Compresser les couleurs'; $lang['fr'][25] = 'Sélecteurs en minuscules'; -$lang['fr'][26] = 'Cases (Minuscules & Majuscule) pour les propriétés:'; -$lang['fr'][27] = 'Minuscules'; -$lang['fr'][28] = 'CSS non valide ou URL incorrecte!'; +$lang['fr'][26] = 'Case pour les propriétés :'; +$lang['fr'][27] = 'Minuscule'; +$lang['fr'][28] = 'CSS non valide ou URL incorrecte !'; $lang['fr'][29] = 'Majuscule'; $lang['fr'][30] = 'les noms des éléments en minuscules (indispensables pour XHTML)'; $lang['fr'][31] = 'enlever les antislashs inutiles'; $lang['fr'][32] = 'convertir !important-hack'; $lang['fr'][33] = 'Sauver en tant que fichier'; -$lang['fr'][34] = 'Une plus grande compression en raison de plus petits caractères'; -$lang['fr'][35] = 'Compresser le CSS'; +$lang['fr'][34] = 'Meilleure compression grâce aux caractères de saut de ligne plus petits (copier & coller ne marche pas)'; +$lang['fr'][35] = 'Compresser la CSS'; $lang['fr'][36] = 'Facteur de Compression'; $lang['fr'][37] = 'Entrée'; $lang['fr'][38] = 'Sortie'; -$lang['fr'][39] = 'Language'; -$lang['fr'][41] = 'Attention : ceci peut changer le comportement de votre code de CSS !'; +$lang['fr'][39] = 'Langue'; +$lang['fr'][41] = 'Attention : ceci peut changer le comportement de votre code CSS !'; $lang['fr'][42] = 'Enlever le dernier ;'; $lang['fr'][43] = 'Supprimer les propriétés non valide'; $lang['fr'][44] = 'Seulement les optimisations sûres'; $lang['fr'][45] = 'Compresser font-weight'; $lang['fr'][46] = 'Sauvegarder les commentaires '; -$lang['fr'][47] = 'Ne changer rien'; +$lang['fr'][47] = 'Ne rien changer'; $lang['fr'][48] = 'Sépare les sélecteurs (sépare au niveau de ,)'; -$lang['fr'][49] = 'Fusionne les sélecteurs avec les mêmes propriétés (rapides)'; +$lang['fr'][49] = 'Fusionne les sélecteurs avec les mêmes propriétés (rapide)'; $lang['fr'][50] = 'Fusionne les sélecteurs intelligemment (lent)'; -$lang['fr'][51] = 'Preserve CSS'; -$lang['fr'][52] = 'Save comments, hacks, etc. Most optimisations can *not* be applied if this is enabled.'; -$lang['fr'][53] = 'None'; -$lang['fr'][54] = 'Don\'t optimise'; -$lang['fr'][55] = 'Safe optimisations'; -$lang['fr'][56] = 'All optimisations'; -$lang['fr'][57] = 'Add timestamp'; +$lang['fr'][51] = 'Préserver la CSS'; +$lang['fr'][52] = 'Sauvegarder les commentaires, hacks, etc. La plupart des optimisations ne peuvent *pas* être appliquées si cela est activé.'; +$lang['fr'][53] = 'Aucun'; +$lang['fr'][54] = 'Ne pas optimiser'; +$lang['fr'][55] = 'Optimisations sûres'; +$lang['fr'][56] = 'Toutes les optimisations'; +$lang['fr'][57] = 'Ajouter un timestamp'; +$lang['fr'][58] = 'Copier dans le presse-papiers'; +$lang['fr'][59] = 'Retour en haut'; +$lang['fr'][60] = 'Votre navigateur ne suporte pas la copie vers le presse-papiers.'; +$lang['fr'][61] = 'Pour signaler des bugs ou pour des suggestions,'; +$lang['fr'][62] = 'contactez-moi'; +$lang['fr'][63] = 'Sauver le code CSS comme document complet HTML'; +$lang['fr'][64] = 'Code'; +$lang['fr'][65] = 'CSS pour colorier la sortie CSS'; +$lang['fr'][66] = 'Vous devez aller dans about:config dans votre barre d’adresse, selectionner \'signed.applets.codebase_principal_support\' dans le champ Filtre et attribuez-lui la valeur \'true\' pour utiliser cette fonctionnalité; toutefois, soyez conscient que cela augmente les risques de sécurité.'; + $lang['zh'][0] = 'CSS整形與最佳化工具(使用 CSSTidy '; $lang['zh'][1] = 'CSS整形與最佳化工具'; @@ -212,7 +277,7 @@ $lang['zh'][30] = 'XHTML必須使用小寫的元素名稱'; $lang['zh'][31] = '移除不必要的反斜線'; $lang['zh'][32] = '轉換 !important-hack'; $lang['zh'][33] = '輸出成檔案形式'; -$lang['zh'][34] = '由於比較少換行字元, 會有更大的壓縮比率(複製&貼上沒有用)'; +$lang['zh'][34] = '由於比較少換行字元, 會有更大的壓縮比率(複製&貼上沒有用)'; $lang['zh'][35] = '執行'; $lang['zh'][36] = '壓縮比率'; $lang['zh'][37] = '輸入'; @@ -235,4 +300,12 @@ $lang['zh'][54] = '不做最佳化'; $lang['zh'][55] = '安全地最佳化'; $lang['zh'][56] = '全部最佳化'; $lang['zh'][57] = '加上時間戳記'; -?> +$lang['zh'][58] = '复制到剪贴板'; +$lang['zh'][59] = '回到页面上方'; +$lang['zh'][60] = '你的浏览器不支持复制到剪贴板。'; +$lang['zh'][61] = '如果程序有错误或你有建议,欢迎'; +$lang['zh'][62] = '和我联系'; +$lang['zh'][63] = 'Output CSS code as complete HTML document'; +$lang['zh'][64] = '代码'; +$lang['zh'][65] = 'CSS to style CSS output'; +$lang['zh'][66] = 'You need to go to about:config in your URL bar, select \'signed.applets.codebase_principal_support\' in the filter field, and set its value to true in order to use this feature; however, be aware that doing so increases security risks.'; diff --git a/install/convert_0.5.1_to_0.5.2.sql b/install/convert_0.5.1_to_0.5.2.sql new file mode 100644 index 00000000..14667967 --- /dev/null +++ b/install/convert_0.5.1_to_0.5.2.sql @@ -0,0 +1,2 @@ +ALTER TABLE `prefix_topic` ADD `topic_count_favourite` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `topic_count_comment`; +ALTER TABLE `prefix_comment` ADD `comment_count_favourite` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `comment_count_vote`; diff --git a/templates/language/english.php b/templates/language/english.php index 11ea40dd..f41bfccd 100644 --- a/templates/language/english.php +++ b/templates/language/english.php @@ -835,6 +835,7 @@ return array( 'admin_list_plugins' => 'Manage plugins', 'admin_list_userfields' => 'Configuring custom fields', 'admin_list_restorecomment' => 'Rebuilding a tree comments', + 'admin_list_recalcfavourite' => 'Recalculate counters of favorites', /** @@ -900,6 +901,7 @@ return array( */ 'admin_title' => 'Admin', 'admin_comment_restore_tree' => 'Tree comments restore successful', + 'admin_favourites_recalculated' => 'Favourites counters has been recalculated', /** * Plugin administration page diff --git a/templates/language/russian.php b/templates/language/russian.php index 14620910..bb2eee64 100644 --- a/templates/language/russian.php +++ b/templates/language/russian.php @@ -834,6 +834,7 @@ return array( 'admin_list_plugins' => 'Управление плагинами', 'admin_list_userfields' => 'Настройка пользовательских полей', 'admin_list_restorecomment' => 'Перестроение дерева комментариев', + 'admin_list_recalcfavourite' => 'Пересчитать счетчики избранных', /** * Рейтинг TOP @@ -898,6 +899,7 @@ return array( */ 'admin_title' => 'Админка', 'admin_comment_restore_tree' => 'Дерево комментариев перестроенно', + 'admin_favourites_recalculated' => 'Счетчики избранных пересчитаны', /** * Страница администрирования плагинов diff --git a/templates/skin/developer-jquery/actions/ActionAdmin/index.tpl b/templates/skin/developer-jquery/actions/ActionAdmin/index.tpl index 2553e51f..46b3714e 100644 --- a/templates/skin/developer-jquery/actions/ActionAdmin/index.tpl +++ b/templates/skin/developer-jquery/actions/ActionAdmin/index.tpl @@ -4,6 +4,7 @@
  • {$aLang.admin_list_plugins}
  • {$aLang.admin_list_userfields}
  • {$aLang.admin_list_restorecomment}
  • +
  • {$aLang.admin_list_recalcfavourite}
  • {hook run='admin_action_item'} diff --git a/templates/skin/developer-jquery/comment.tpl b/templates/skin/developer-jquery/comment.tpl index d1fc15c6..1b103a4a 100644 --- a/templates/skin/developer-jquery/comment.tpl +++ b/templates/skin/developer-jquery/comment.tpl @@ -16,7 +16,7 @@ {/if}
  • {if $oUserCurrent and !$bNoCommentFavourites} -
  • +
  • {if $oComment->getCountFavourite()>0}{$oComment->getCountFavourite()}{else} {/if}
  • {/if} {if !$oComment->getDelete() and $oUserCurrent and $oUserCurrent->isAdministrator()}
  • {$aLang.comment_delete}
  • diff --git a/templates/skin/developer-jquery/css/common.css b/templates/skin/developer-jquery/css/common.css index c2c265a9..90a5e744 100644 --- a/templates/skin/developer-jquery/css/common.css +++ b/templates/skin/developer-jquery/css/common.css @@ -1,76 +1,77 @@ -/* Voting */ -.voting { overflow: hidden; zoom: 1; } - -.voting .total { float: left; padding: 0 7px; font-weight: bold; color: #aaa; } -.voting .total a { text-decoration: none; color: #999; outline: none; } - -.voting.positive .total { color: #390; } -.voting.negative .total { color: #f00; } - -.voting .plus, -.voting .minus { width: 10px; height: 10px; float: left; display: block; background: url(../images/voting.png) no-repeat; position: relative; top: 4px; outline: none; } -.voting .plus { background-position: 0 0; } -.voting .minus { background-position: -20px 0; } -.voting .plus:hover { background-position: -10px 0; } -.voting .minus:hover { background-position: -30px 0; } - -.voting.voted.plus .plus { background-position: -10px 0; } -.voting.voted.minus .minus { background-position: -30px 0; } -.voting.voted.plus .minus:hover { background-position: -20px 0; } -.voting.voted.minus .plus:hover { background-position: 0 0; } - -.voting.guest .plus:hover { background-position: 0 0; } -.voting.guest .minus:hover { background-position: -20px 0; } - - -/* Favorite */ -.favourite { background: url(../images/favorite.png) no-repeat; display: block; height: 16px; width: 16px; position: relative; top: 1px; } -.favourite:hover { background-position: 0 -16px !important; } -.favourite.active { background-position: 0 -16px; } - - -/* Pagination */ -.pagination ul li { display: inline; margin-right: 5px; } -.pagination ul li.active { color: #aaa; } -.pagination.pagination-comments { margin-bottom: 15px; } - - -/* Switcher */ -.switcher { overflow: hidden; zoom: 1; margin-bottom: 10px; } -.switcher li { float: left; margin-right: 3px; } -.switcher li a { float: left; padding: 1px 10px 2px; text-decoration: none; color: #777; background: #eee; } -.switcher li.active a { border: 0; color: #eee; background: #555; } - -.switcher-block { overflow: hidden; zoom: 1; margin-bottom: 10px; } -.switcher-block li { float: left; padding: 1px 10px 2px; margin-right: 3px; color: #777; background: #eee; cursor: pointer; } -.switcher-block li:hover { background: #ddd; } -.switcher-block li.active { color: #eee; background: #555; } - - -/* System messages */ -.system-message-error { background: #f0c8c8; color: #b22626; padding: 10px 15px; margin-bottom: 15px; } -.system-message-notice { background: #dafad8; color: #4bb23b; padding: 10px 15px; margin-bottom: 15px; } - - -/* Actions */ -.actions { overflow: hidden; zoom: 1; margin-bottom: 10px; } -.actions li a { overflow: hidden; zoom: 1; margin-bottom: 10px; color: #333; text-decoration: none; } -.actions li { float: left; margin-right: 10px; } -.actions li .edit { padding-left: 15px; background: url(../images/edit.png) no-repeat 0 1px; } -.actions li .delete { padding-left: 14px; background: url(../images/delete.png) no-repeat 0 2px; } -.actions li .rss { padding-left: 15px; background: url(../images/rss.png) no-repeat 0 1px; } -.actions li a:hover { text-decoration: underline; } - - -/* Misc */ -.user, .ls-user { padding-left: 12px; background: url(../images/user.png) no-repeat 0 2px; color: #555; } -.user.inactive { color: #888; } - -.center { width: 300px; margin: 0 auto; } - -.table { width: 100%; margin-bottom: 15px; } -.table thead td { background: #fafafa; } -.table td { border: 1px solid #eee; padding: 5px; } -.table tr.active td { background: #F1FCEF; } - +/* Voting */ +.voting { overflow: hidden; zoom: 1; } + +.voting .total { float: left; padding: 0 7px; font-weight: bold; color: #aaa; } +.voting .total a { text-decoration: none; color: #999; outline: none; } + +.voting.positive .total { color: #390; } +.voting.negative .total { color: #f00; } + +.voting .plus, +.voting .minus { width: 10px; height: 10px; float: left; display: block; background: url(../images/voting.png) no-repeat; position: relative; top: 4px; outline: none; } +.voting .plus { background-position: 0 0; } +.voting .minus { background-position: -20px 0; } +.voting .plus:hover { background-position: -10px 0; } +.voting .minus:hover { background-position: -30px 0; } + +.voting.voted.plus .plus { background-position: -10px 0; } +.voting.voted.minus .minus { background-position: -30px 0; } +.voting.voted.plus .minus:hover { background-position: -20px 0; } +.voting.voted.minus .plus:hover { background-position: 0 0; } + +.voting.guest .plus:hover { background-position: 0 0; } +.voting.guest .minus:hover { background-position: -20px 0; } + + +/* Favorite */ +.favourite { background: url(../images/favorite.png) no-repeat; display: block; height: 16px; width: 16px; position: relative; top: 1px; float: left;} +.favourite:hover { background-position: 0 -16px !important; } +.favourite.active { background-position: 0 -16px; } +.favourite-count { color: #333; font-weight: bold; float: left; margin-left: 2px; } + + +/* Pagination */ +.pagination ul li { display: inline; margin-right: 5px; } +.pagination ul li.active { color: #aaa; } +.pagination.pagination-comments { margin-bottom: 15px; } + + +/* Switcher */ +.switcher { overflow: hidden; zoom: 1; margin-bottom: 10px; } +.switcher li { float: left; margin-right: 3px; } +.switcher li a { float: left; padding: 1px 10px 2px; text-decoration: none; color: #777; background: #eee; } +.switcher li.active a { border: 0; color: #eee; background: #555; } + +.switcher-block { overflow: hidden; zoom: 1; margin-bottom: 10px; } +.switcher-block li { float: left; padding: 1px 10px 2px; margin-right: 3px; color: #777; background: #eee; cursor: pointer; } +.switcher-block li:hover { background: #ddd; } +.switcher-block li.active { color: #eee; background: #555; } + + +/* System messages */ +.system-message-error { background: #f0c8c8; color: #b22626; padding: 10px 15px; margin-bottom: 15px; } +.system-message-notice { background: #dafad8; color: #4bb23b; padding: 10px 15px; margin-bottom: 15px; } + + +/* Actions */ +.actions { overflow: hidden; zoom: 1; margin-bottom: 10px; } +.actions li a { overflow: hidden; zoom: 1; margin-bottom: 10px; color: #333; text-decoration: none; } +.actions li { float: left; margin-right: 10px; } +.actions li .edit { padding-left: 15px; background: url(../images/edit.png) no-repeat 0 1px; } +.actions li .delete { padding-left: 14px; background: url(../images/delete.png) no-repeat 0 2px; } +.actions li .rss { padding-left: 15px; background: url(../images/rss.png) no-repeat 0 1px; } +.actions li a:hover { text-decoration: underline; } + + +/* Misc */ +.user, .ls-user { padding-left: 12px; background: url(../images/user.png) no-repeat 0 2px; color: #555; } +.user.inactive { color: #888; } + +.center { width: 300px; margin: 0 auto; } + +.table { width: 100%; margin-bottom: 15px; } +.table thead td { background: #fafafa; } +.table td { border: 1px solid #eee; padding: 5px; } +.table tr.active td { background: #F1FCEF; } + .right { float: right; } \ No newline at end of file diff --git a/templates/skin/developer-jquery/js/favourite.js b/templates/skin/developer-jquery/js/favourite.js index e5853587..a4eb914b 100644 --- a/templates/skin/developer-jquery/js/favourite.js +++ b/templates/skin/developer-jquery/js/favourite.js @@ -47,6 +47,8 @@ ls.favourite = (function ($) { if (result.bState) { this.objFavourite.addClass(this.options.active); } + + $('#fav_count_'+type+'_'+idTarget).text((result.iCount>0) ? result.iCount : ''); } }.bind(this)); return false; diff --git a/templates/skin/developer-jquery/topic_link.tpl b/templates/skin/developer-jquery/topic_link.tpl index 7311539b..a1ad5ac4 100644 --- a/templates/skin/developer-jquery/topic_link.tpl +++ b/templates/skin/developer-jquery/topic_link.tpl @@ -60,7 +60,7 @@
  • {$oUser->getLogin()}
  • {date_format date=$oTopic->getDateAdd()}
  • -
  • +
  • {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if}
  • {$oTopic->getLinkUrl(true)}
  • {if $bTopicList}
  • {$oUser->getLogin()}
  • {date_format date=$oTopic->getDateAdd()}
  • -
  • +
  • {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if}
  • {if $bTopicList}
  • {$oUser->getLogin()}
  • {date_format date=$oTopic->getDateAdd()}
  • -
  • +
  • {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if}
  • {if $bTopicList}
  • {$oUser->getLogin()}
  • {date_format date=$oTopic->getDateAdd()}
  • -
  • +
  • {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if}
  • {if $bTopicList}
  • {$aLang.admin_list_plugins}
  • {$aLang.admin_list_userfields}
  • {$aLang.admin_list_restorecomment}
  • +
  • {$aLang.admin_list_recalcfavourite}
  • {hook run='admin_action_item'} -{include file='footer.tpl'} \ No newline at end of file +{include file='footer.tpl'} diff --git a/templates/skin/new-jquery/comment.tpl b/templates/skin/new-jquery/comment.tpl index 045fb24e..1b8869c3 100644 --- a/templates/skin/new-jquery/comment.tpl +++ b/templates/skin/new-jquery/comment.tpl @@ -43,7 +43,7 @@ {/if}
  • {if $oUserCurrent and !$bNoCommentFavourites} -
  • +
  • {if $oComment->getCountFavourite()>0}{$oComment->getCountFavourite()}{else} {/if}
  • {/if} {if !$oComment->getDelete() and $oUserCurrent and $oUserCurrent->isAdministrator()}
  • {$aLang.comment_delete}
  • diff --git a/templates/skin/new-jquery/css/comments.css b/templates/skin/new-jquery/css/comments.css index f29efbd5..4b255051 100644 --- a/templates/skin/new-jquery/css/comments.css +++ b/templates/skin/new-jquery/css/comments.css @@ -62,7 +62,8 @@ .comment .info li a.favourite { float: left; width: 10px; height: 8px; background: url(../images/icons.gif) -40px -40px no-repeat; position: relative; top: 4px; } .comment .info li a.favourite.active { background-position: -50px -40px; } .comment .info li a.favourite:hover { background-position: -50px -40px; } -.comment .info li a { } +.comment .info li span.favourite-count { color: #390; margin-left: 2px; position: relative; top: 1px; } +.comment .info li a { } /* Content */ .comment .content { color: #000; margin: 0 30px 10px 0; border: 1px solid #DDDEDE; background: #f7f7f7; border-radius: 7px; padding: 8px 30px 9px 10px; position: relative; overflow: hidden; zoom: 1; } diff --git a/templates/skin/new-jquery/css/topic.css b/templates/skin/new-jquery/css/topic.css index c90dc9dc..7da450f6 100644 --- a/templates/skin/new-jquery/css/topic.css +++ b/templates/skin/new-jquery/css/topic.css @@ -2,7 +2,7 @@ /* Title */ .topic .title { margin-bottom: 3px; font-size: 22px; font-family: Verdana, sans-serif; } -.topic .title a { } +.topic .title a { } /* Content */ .topic .content { overflow: hidden; zoom: 1; margin-bottom: 15px; font-size: 14px; font-family: Verdana, sans-serif; line-height: 20px; } @@ -42,9 +42,10 @@ .topic .info li.comments-link a:hover span { background: #390; color: #fff; } .topic .info li.url a { padding-left: 16px; background: url(../images/topic_link.gif) 0 1px no-repeat; font-size: 11px; } -.topic .favourite { position: absolute; top: 8px; left: -8px; height: 16px; width: 20px; background: url(../images/icons.gif) no-repeat 0 -40px; } -.topic .favourite:hover { background: url(../images/icons.gif) no-repeat -20px -40px; } -.topic .favourite.active { background: url(../images/icons.gif) no-repeat -20px -40px; } +.topic .favourite { position: absolute; top: 8px; left: -8px; height: 16px; width: 20px; background: url(../images/icons.gif) no-repeat 0 -40px; text-align: center; font-weight: bold; text-decoration: none; } +.topic .favourite:hover { background: url(../images/icons.gif) no-repeat -20px -40px; color: #fff; } +.topic .favourite.active { background: url(../images/icons.gif) no-repeat -20px -40px; color: #fff; } +.topic .favourite-count { color: #390; position: absolute;top: 15px; left: -7px; width: 32px; } /* Poll */ .topic .poll { margin-bottom: 15px; font-size: 14px; } @@ -65,7 +66,7 @@ .topic .poll .poll-total { color: #aaa; } /* Topic Photo */ -.topic.photo { } +.topic.photo { } .topic.photo .topic-photo-preview { position: relative; margin-bottom: 15px; cursor: pointer; } .topic.photo .topic-photo-preview img { vertical-align: top; } .topic.photo .topic-photo-preview .topic-photo-count { display: none; cursor: pointer; position: absolute; top: 5px; right: 5px; background: #000; color: #6bd24b; padding: 4px 7px; background: rgba(0,0,0,.6); } diff --git a/templates/skin/new-jquery/js/favourite.js b/templates/skin/new-jquery/js/favourite.js index 662df908..9c4cf086 100644 --- a/templates/skin/new-jquery/js/favourite.js +++ b/templates/skin/new-jquery/js/favourite.js @@ -47,6 +47,8 @@ ls.favourite = (function ($) { if (result.bState) { this.objFavourite.addClass(this.options.active); } + + $('#fav_count_'+type+'_'+idTarget).text((result.iCount>0) ? result.iCount : ''); } }.bind(this)); return false; diff --git a/templates/skin/new-jquery/topic_link.tpl b/templates/skin/new-jquery/topic_link.tpl index 8404aa64..ef80b96c 100644 --- a/templates/skin/new-jquery/topic_link.tpl +++ b/templates/skin/new-jquery/topic_link.tpl @@ -11,7 +11,9 @@ {$aLang.topic_link} - + + {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if} +
    @@ -75,4 +77,4 @@ {if !$bTopicList} {hook run='topic_show_end' topic=$oTopic} {/if} -
    \ No newline at end of file + diff --git a/templates/skin/new-jquery/topic_photoset.tpl b/templates/skin/new-jquery/topic_photoset.tpl index 7b2c6c5a..1f29fdae 100644 --- a/templates/skin/new-jquery/topic_photoset.tpl +++ b/templates/skin/new-jquery/topic_photoset.tpl @@ -20,7 +20,9 @@ {/if} - + + {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if} + @@ -133,4 +135,4 @@ {if !$bTopicList} {hook run='topic_show_end' topic=$oTopic} {/if} - \ No newline at end of file + diff --git a/templates/skin/new-jquery/topic_question.tpl b/templates/skin/new-jquery/topic_question.tpl index b65c1dad..34301516 100644 --- a/templates/skin/new-jquery/topic_question.tpl +++ b/templates/skin/new-jquery/topic_question.tpl @@ -15,7 +15,9 @@ {/if} - + + {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if} + @@ -117,4 +119,4 @@ {if !$bTopicList} {hook run='topic_show_end' topic=$oTopic} {/if} - \ No newline at end of file + diff --git a/templates/skin/new-jquery/topic_topic.tpl b/templates/skin/new-jquery/topic_topic.tpl index baf1eef0..3e329823 100644 --- a/templates/skin/new-jquery/topic_topic.tpl +++ b/templates/skin/new-jquery/topic_topic.tpl @@ -14,7 +14,9 @@ {/if} - + + {if $oTopic->getCountFavourite()>0}{$oTopic->getCountFavourite()}{else} {/if} + @@ -81,4 +83,4 @@ {if !$bTopicList} {hook run='topic_show_end' topic=$oTopic} {/if} - \ No newline at end of file +