Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

# [#30349] Cleaned up use of database & query objects. Thanks Peter van

Westen and Michael Babker
(Fix #856)
  • Loading branch information...
commit 4d50339a7344687afba38acf275cea4e967666b5 1 parent f02bfcb
@nonumber nonumber authored infograf768 committed
Showing with 5,820 additions and 5,627 deletions.
  1. +1 −1  administrator/components/com_admin/models/sysinfo.php
  2. +11 −11 administrator/components/com_admin/script.php
  3. +24 −25 administrator/components/com_banners/helpers/banners.php
  4. +4 −5 administrator/components/com_banners/helpers/html/banner.php
  5. +57 −52 administrator/components/com_banners/models/banners.php
  6. +31 −26 administrator/components/com_banners/models/clients.php
  7. +105 −87 administrator/components/com_banners/models/tracks.php
  8. +6 −6 administrator/components/com_banners/tables/banner.php
  9. +24 −24 administrator/components/com_categories/helpers/categories.php
  10. +7 −7 administrator/components/com_categories/helpers/html/categoriesadministrator.php
  11. +45 −45 administrator/components/com_categories/models/categories.php
  12. +28 −28 administrator/components/com_categories/models/category.php
  13. +56 −50 administrator/components/com_categories/models/fields/categoryedit.php
  14. +23 −23 administrator/components/com_categories/models/fields/categoryparent.php
  15. +16 −11 administrator/components/com_checkin/models/checkin.php
  16. +6 −6 administrator/components/com_config/helper/component.php
  17. +7 −7 administrator/components/com_config/models/fields/filters.php
  18. +9 −9 administrator/components/com_contact/helpers/html/contact.php
  19. +36 −37 administrator/components/com_contact/models/contact.php
  20. +55 −54 administrator/components/com_contact/models/contacts.php
  21. +1 −1  administrator/components/com_contact/models/fields/modal/contacts.php
  22. +9 −9 administrator/components/com_content/helpers/html/contentadministrator.php
  23. +59 −56 administrator/components/com_content/models/article.php
  24. +74 −69 administrator/components/com_content/models/articles.php
  25. +28 −25 administrator/components/com_content/models/featured.php
  26. +1 −1  administrator/components/com_content/models/fields/modal/article.php
  27. +12 −12 administrator/components/com_finder/helpers/html/finder.php
  28. +79 −79 administrator/components/com_finder/helpers/indexer/adapter.php
  29. +85 −90 administrator/components/com_finder/helpers/indexer/driver/mysql.php
  30. +84 −89 administrator/components/com_finder/helpers/indexer/driver/postgresql.php
  31. +63 −68 administrator/components/com_finder/helpers/indexer/driver/sqlsrv.php
  32. +12 −12 administrator/components/com_finder/helpers/indexer/helper.php
  33. +41 −41 administrator/components/com_finder/helpers/indexer/query.php
  34. +44 −45 administrator/components/com_finder/helpers/indexer/taxonomy.php
  35. +6 −7 administrator/components/com_finder/helpers/language.php
  36. +6 −6 administrator/components/com_finder/models/fields/searchfilter.php
  37. +8 −8 administrator/components/com_finder/models/filters.php
  38. +17 −20 administrator/components/com_finder/models/index.php
  39. +16 −18 administrator/components/com_finder/models/maps.php
  40. +19 −19 administrator/components/com_finder/models/statistics.php
  41. +4 −4 administrator/components/com_finder/tables/filter.php
  42. +4 −4 administrator/components/com_finder/tables/map.php
  43. +9 −8 administrator/components/com_installer/helpers/installer.php
  44. +10 −9 administrator/components/com_installer/models/database.php
  45. +15 −15 administrator/components/com_installer/models/discover.php
  46. +4 −4 administrator/components/com_installer/models/languages.php
  47. +9 −9 administrator/components/com_installer/models/manage.php
  48. +14 −10 administrator/components/com_installer/models/update.php
  49. +76 −53 administrator/components/com_joomlaupdate/models/default.php
  50. +60 −60 administrator/components/com_languages/helpers/multilangstatus.php
  51. +7 −7 administrator/components/com_languages/models/installed.php
  52. +21 −22 administrator/components/com_languages/models/languages.php
  53. +5 −5 administrator/components/com_languages/models/strings.php
  54. +26 −25 administrator/components/com_login/models/login.php
  55. +24 −16 administrator/components/com_menus/controllers/menus.php
  56. +9 −9 administrator/components/com_menus/helpers/html/menus.php
  57. +45 −41 administrator/components/com_menus/helpers/menus.php
  58. +10 −10 administrator/components/com_menus/models/fields/menuordering.php
  59. +13 −14 administrator/components/com_menus/models/fields/menuparent.php
  60. +115 −107 administrator/components/com_menus/models/item.php
  61. +74 −67 administrator/components/com_menus/models/items.php
  62. +25 −25 administrator/components/com_menus/models/menu.php
  63. +14 −15 administrator/components/com_menus/models/menus.php
  64. +7 −7 administrator/components/com_menus/models/menutypes.php
  65. +5 −5 administrator/components/com_messages/models/config.php
  66. +3 −3 administrator/components/com_messages/models/fields/usermessages.php
  67. +8 −9 administrator/components/com_messages/models/message.php
  68. +17 −17 administrator/components/com_messages/models/messages.php
  69. +6 −7 administrator/components/com_modules/helpers/html/modules.php
  70. +17 −19 administrator/components/com_modules/helpers/modules.php
  71. +38 −40 administrator/components/com_modules/models/module.php
  72. +64 −56 administrator/components/com_modules/models/modules.php
  73. +5 −5 administrator/components/com_modules/models/positions.php
  74. +23 −20 administrator/components/com_modules/models/select.php
  75. +9 −9 administrator/components/com_newsfeeds/helpers/html/newsfeed.php
  76. +1 −1  administrator/components/com_newsfeeds/models/fields/modal/newsfeeds.php
  77. +4 −5 administrator/components/com_newsfeeds/models/fields/newsfeeds.php
  78. +37 −37 administrator/components/com_newsfeeds/models/newsfeed.php
  79. +48 −48 administrator/components/com_newsfeeds/models/newsfeeds.php
  80. +17 −18 administrator/components/com_plugins/helpers/plugins.php
  81. +1 −1  administrator/components/com_plugins/models/fields/ordering.php
  82. +3 −3 administrator/components/com_plugins/models/plugin.php
  83. +35 −34 administrator/components/com_plugins/models/plugins.php
  84. +6 −6 administrator/components/com_redirect/helpers/redirect.php
  85. +30 −30 administrator/components/com_redirect/models/link.php
  86. +22 −19 administrator/components/com_redirect/models/links.php
  87. +4 −1 administrator/components/com_redirect/tables/link.php
  88. +13 −13 administrator/components/com_search/models/searches.php
  89. +6 −6 administrator/components/com_tags/helpers/tags.php
  90. +44 −43 administrator/components/com_tags/models/tags.php
  91. +14 −14 administrator/components/com_templates/helpers/templates.php
  92. +29 −26 administrator/components/com_templates/models/source.php
  93. +11 −11 administrator/components/com_templates/models/style.php
  94. +26 −24 administrator/components/com_templates/models/styles.php
  95. +10 −10 administrator/components/com_templates/models/template.php
  96. +17 −15 administrator/components/com_templates/models/templates.php
  97. +10 −10 administrator/components/com_templates/tables/style.php
  98. +27 −28 administrator/components/com_users/helpers/debug.php
  99. +10 −7 administrator/components/com_users/helpers/users.php
  100. +34 −32 administrator/components/com_users/models/debuggroup.php
  101. +35 −33 administrator/components/com_users/models/debuguser.php
  102. +10 −11 administrator/components/com_users/models/fields/groupparent.php
  103. +22 −19 administrator/components/com_users/models/groups.php
  104. +20 −18 administrator/components/com_users/models/levels.php
  105. +4 −4 administrator/components/com_users/models/mail.php
  106. +9 −9 administrator/components/com_users/models/notes.php
  107. +7 −7 administrator/components/com_users/models/user.php
  108. +41 −40 administrator/components/com_users/models/users.php
  109. +3 −3 administrator/components/com_users/tables/note.php
  110. +38 −35 administrator/components/com_weblinks/models/weblinks.php
  111. +1 −1  administrator/components/com_weblinks/tables/weblink.php
  112. +44 −40 administrator/includes/application.php
  113. +5 −6 administrator/modules/mod_logged/helper.php
  114. +16 −17 administrator/modules/mod_menu/helper.php
  115. +14 −14 administrator/modules/mod_stats_admin/helper.php
  116. +12 −12 administrator/modules/mod_status/mod_status.php
  117. +43 −40 components/com_banners/models/banner.php
  118. +76 −73 components/com_banners/models/banners.php
  119. +10 −10 components/com_contact/helpers/route.php
  120. +48 −43 components/com_contact/models/category.php
  121. +30 −31 components/com_contact/models/contact.php
  122. +28 −28 components/com_contact/models/featured.php
  123. +24 −16 components/com_contact/router.php
  124. +2 −2 components/com_content/helpers/query.php
  125. +10 −10 components/com_content/helpers/route.php
  126. +73 −64 components/com_content/models/article.php
  127. +91 −84 components/com_content/models/articles.php
  128. +8 −8 components/com_content/models/category.php
  129. +27 −24 components/com_content/router.php
  130. +1 −1  components/com_content/views/category/view.feed.php
  131. +1 −1  components/com_content/views/featured/view.feed.php
  132. +63 −63 components/com_finder/helpers/html/filter.php
  133. +41 −43 components/com_finder/models/search.php
  134. +7 −7 components/com_finder/models/suggestions.php
  135. +10 −10 components/com_newsfeeds/helpers/route.php
  136. +36 −32 components/com_newsfeeds/models/category.php
  137. +16 −17 components/com_newsfeeds/models/newsfeed.php
  138. +6 −2 components/com_newsfeeds/router.php
  139. +4 −4 components/com_tags/models/tags.php
  140. +25 −22 components/com_users/helpers/html/users.php
  141. +51 −51 components/com_users/models/registration.php
  142. +23 −23 components/com_users/models/remind.php
  143. +58 −57 components/com_users/models/reset.php
  144. +35 −19 components/com_users/router.php
  145. +10 −10 components/com_weblinks/helpers/route.php
  146. +37 −33 components/com_weblinks/models/category.php
  147. +20 −14 components/com_weblinks/router.php
  148. +77 −67 includes/application.php
  149. +3 −0  installation/CHANGELOG
  150. +4 −4 installation/application/web.php
  151. +2 −2 installation/controller/database.php
  152. +2 −2 installation/controller/install/database.php
  153. +2 −2 installation/controller/install/database_backup.php
  154. +2 −2 installation/controller/install/sample.php
  155. +32 −32 installation/model/configuration.php
  156. +45 −49 installation/model/database.php
  157. +6 −6 installation/model/languages.php
  158. +4 −5 libraries/cms/form/field/contenttype.php
  159. +7 −7 libraries/cms/form/field/editor.php
  160. +4 −4 libraries/cms/form/field/media.php
  161. +5 −5 libraries/cms/form/field/moduleorder.php
  162. +7 −8 libraries/cms/form/field/tag.php
  163. +9 −9 libraries/cms/form/field/templatestyle.php
  164. +2 −2 libraries/cms/form/field/user.php
  165. +5 −5 libraries/cms/helper/route.php
  166. +8 −10 libraries/cms/html/category.php
  167. +8 −10 libraries/cms/html/tag.php
  168. +34 −32 libraries/cms/installer/adapter/component.php
  169. +12 −13 libraries/cms/installer/adapter/file.php
  170. +7 −7 libraries/cms/installer/adapter/language.php
  171. +10 −10 libraries/cms/installer/adapter/library.php
  172. +18 −14 libraries/cms/installer/adapter/module.php
  173. +6 −6 libraries/cms/installer/adapter/package.php
  174. +8 −6 libraries/cms/installer/adapter/plugin.php
  175. +24 −23 libraries/cms/installer/adapter/template.php
  176. +3 −3 libraries/cms/installer/helper.php
  177. +29 −30 libraries/cms/installer/installer.php
  178. +13 −16 libraries/cms/language/associations.php
  179. +7 −8 libraries/cms/language/multilang.php
  180. +10 −11 libraries/cms/menu/site.php
  181. +9 −9 libraries/cms/search/helper.php
  182. +3 −3 libraries/cms/table/corecontent.php
  183. +124 −135 libraries/cms/tags/tags.php
  184. +1 −1  libraries/cms/toolbar/button/slider.php
  185. +29 −29 libraries/joomla/access/access.php
  186. +1 −1  libraries/joomla/base/adapter.php
  187. +1 −1  libraries/joomla/base/adapterinstance.php
  188. +3 −3 libraries/joomla/database/database.php
  189. +20 −20 libraries/joomla/database/driver.php
  190. +7 −7 libraries/joomla/database/driver/mysql.php
  191. +6 −6 libraries/joomla/database/driver/mysqli.php
  192. +26 −28 libraries/joomla/database/driver/oracle.php
  193. +9 −9 libraries/joomla/database/driver/pdo.php
  194. +43 −44 libraries/joomla/database/driver/postgresql.php
  195. +5 −5 libraries/joomla/database/driver/sqlite.php
  196. +32 −32 libraries/joomla/database/driver/sqlsrv.php
  197. +4 −4 libraries/joomla/database/exporter/mysqli.php
  198. +6 −6 libraries/joomla/database/exporter/postgresql.php
  199. +24 −24 libraries/joomla/database/importer/mysqli.php
  200. +31 −31 libraries/joomla/database/importer/postgresql.php
  201. +4 −4 libraries/joomla/database/query.php
  202. +1 −1  libraries/joomla/database/query/postgresql.php
  203. +1 −1  libraries/joomla/database/query/sqlite.php
  204. +1 −1  libraries/joomla/database/query/sqlsrv.php
  205. +5 −5 libraries/joomla/date/date.php
  206. +7 −7 libraries/joomla/document/html/html.php
  207. +1 −1  libraries/joomla/form/fields/checkbox.php
  208. +1 −1  libraries/joomla/form/fields/checkboxes.php
  209. +1 −1  libraries/joomla/form/fields/combo.php
  210. +1 −1  libraries/joomla/form/fields/email.php
  211. +1 −1  libraries/joomla/form/fields/file.php
  212. +1 −1  libraries/joomla/form/fields/hidden.php
  213. +6 −6 libraries/joomla/form/fields/plugins.php
  214. +1 −1  libraries/joomla/form/fields/radio.php
  215. +8 −8 libraries/joomla/form/fields/rules.php
  216. +1 −1  libraries/joomla/form/fields/sql.php
  217. +1 −1  libraries/joomla/form/fields/text.php
  218. +4 −4 libraries/joomla/form/rule/email.php
  219. +4 −4 libraries/joomla/form/rule/username.php
  220. +23 −25 libraries/joomla/html/access.php
  221. +1 −1  libraries/joomla/html/jgrid.php
  222. +12 −13 libraries/joomla/html/list.php
  223. +6 −6 libraries/joomla/html/rules.php
  224. +2 −2 libraries/joomla/html/select.php
  225. +11 −11 libraries/joomla/html/user.php
  226. +11 −11 libraries/joomla/language/helper.php
  227. +7 −7 libraries/joomla/log/logger/database.php
  228. +4 −5 libraries/joomla/plugin/helper.php
  229. +8 −8 libraries/joomla/session/storage/database.php
  230. +7 −8 libraries/joomla/table/asset.php
  231. +5 −5 libraries/joomla/table/extension.php
  232. +87 −84 libraries/joomla/table/nested.php
  233. +60 −61 libraries/joomla/table/table.php
  234. +5 −5 libraries/joomla/table/update.php
  235. +53 −58 libraries/joomla/table/user.php
  236. +18 −21 libraries/joomla/table/usergroup.php
  237. +7 −7 libraries/joomla/updater/adapters/collection.php
  238. +7 −7 libraries/joomla/updater/adapters/extension.php
  239. +9 −9 libraries/joomla/updater/updater.php
  240. +17 −17 libraries/joomla/user/helper.php
  241. +6 −2 libraries/joomla/user/user.php
  242. +17 −17 libraries/legacy/application/application.php
  243. +20 −18 libraries/legacy/categories/categories.php
  244. +5 −5 libraries/legacy/component/helper.php
  245. +2 −2 libraries/legacy/error/error.php
  246. +8 −8 libraries/legacy/form/field/componentlayout.php
  247. +8 −8 libraries/legacy/form/field/modulelayout.php
  248. +5 −5 libraries/legacy/html/contentlanguage.php
  249. +24 −24 libraries/legacy/html/menu.php
  250. +13 −13 libraries/legacy/module/helper.php
  251. +8 −8 libraries/legacy/table/category.php
  252. +7 −7 libraries/legacy/table/content.php
  253. +1 −1  libraries/legacy/table/menu.php
  254. +48 −50 libraries/legacy/table/menu/type.php
  255. +14 −17 libraries/legacy/table/session.php
  256. +21 −21 modules/mod_articles_archive/helper.php
  257. +8 −6 modules/mod_articles_latest/helper.php
  258. +5 −6 modules/mod_login/helper.php
  259. +39 −39 modules/mod_related_items/helper.php
  260. +14 −14 modules/mod_stats/helper.php
  261. +10 −13 modules/mod_tags_popular/helper.php
  262. +21 −22 modules/mod_tags_similar/helper.php
  263. +8 −8 modules/mod_users_latest/helper.php
  264. +14 −14 modules/mod_whosonline/helper.php
  265. +4 −5 plugins/authentication/joomla/joomla.php
  266. +32 −31 plugins/content/joomla/joomla.php
  267. +21 −21 plugins/content/pagenavigation/pagenavigation.php
  268. +5 −6 plugins/editors/tinymce/tinymce.php
  269. +35 −34 plugins/extension/joomla/joomla.php
  270. +23 −23 plugins/finder/categories/categories.php
  271. +25 −25 plugins/finder/contacts/contacts.php
  272. +22 −22 plugins/finder/content/content.php
  273. +20 −20 plugins/finder/newsfeeds/newsfeeds.php
  274. +17 −17 plugins/finder/tags/tags.php
  275. +23 −23 plugins/finder/weblinks/weblinks.php
  276. +35 −33 plugins/search/categories/categories.php
  277. +44 −40 plugins/search/contacts/contacts.php
  278. +71 −65 plugins/search/content/content.php
  279. +34 −34 plugins/search/newsfeeds/newsfeeds.php
  280. +41 −39 plugins/search/weblinks/weblinks.php
  281. +15 −15 plugins/system/debug/debug.php
  282. +36 −33 plugins/system/redirect/redirect.php
  283. +3 −3 plugins/user/contactcreator/contactcreator.php
  284. +46 −44 plugins/user/joomla/joomla.php
  285. +24 −22 plugins/user/profile/profile.php
  286. +45 −37 tests/plugins/search/example/example.php
View
2  administrator/components/com_admin/models/sysinfo.php
@@ -128,7 +128,7 @@ public function &getInfo()
$this->info = array();
$version = new JVersion;
$platform = new JPlatform;
- $db = JFactory::getDBO();
+ $db = JFactory::getDbo();
if (isset($_SERVER['SERVER_SOFTWARE']))
{
$sf = $_SERVER['SERVER_SOFTWARE'];
View
22 administrator/components/com_admin/script.php
@@ -21,7 +21,7 @@ class JoomlaInstallerScript
/**
* Method to update Joomla!
*
- * @param JInstallerFile $installer The class calling this method
+ * @param JInstallerFile $installer The class calling this method
*
* @return void
*/
@@ -42,7 +42,7 @@ protected function updateDatabase()
$results = $db->loadObjectList();
if ($db->getErrorNum())
{
- echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $db->getErrorNum(), $db->getErrorMsg()).'<br />';
+ echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $db->getErrorNum(), $db->getErrorMsg()) . '<br />';
return;
}
foreach ($results as $result)
@@ -54,7 +54,7 @@ protected function updateDatabase()
$db->execute();
if ($db->getErrorNum())
{
- echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $db->getErrorNum(), $db->getErrorMsg()).'<br />';
+ echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $db->getErrorNum(), $db->getErrorMsg()) . '<br />';
return;
}
break;
@@ -210,12 +210,12 @@ protected function updateManifestCaches()
// Attempt to refresh manifest caches
$db = JFactory::getDbo();
- $query = $db->getQuery(true);
- $query->select('*');
- $query->from('#__extensions');
+ $query = $db->getQuery(true)
+ ->select('*')
+ ->from('#__extensions');
foreach ($extensions as $extension)
{
- $query->where('type='.$db->quote($extension[0]).' AND element='.$db->quote($extension[1]).' AND folder='.$db->quote($extension[2]).' AND client_id='.$extension[3], 'OR');
+ $query->where('type=' . $db->quote($extension[0]) . ' AND element=' . $db->quote($extension[1]) . ' AND folder=' . $db->quote($extension[2]) . ' AND client_id=' . $extension[3], 'OR');
}
$db->setQuery($query);
$extensions = $db->loadObjectList();
@@ -223,14 +223,14 @@ protected function updateManifestCaches()
// Check for a database error.
if ($db->getErrorNum())
{
- echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $db->getErrorNum(), $db->getErrorMsg()).'<br />';
+ echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $db->getErrorNum(), $db->getErrorMsg()) . '<br />';
return;
}
foreach ($extensions as $extension)
{
if (!$installer->refreshManifestCache($extension->extension_id))
{
- echo JText::sprintf('FILES_JOOMLA_ERROR_MANIFEST', $extension->type, $extension->element, $extension->name, $extension->client_id).'<br />';
+ echo JText::sprintf('FILES_JOOMLA_ERROR_MANIFEST', $extension->type, $extension->element, $extension->name, $extension->client_id) . '<br />';
}
}
}
@@ -615,7 +615,7 @@ public function deleteUnexistingFiles()
{
if (JFile::exists(JPATH_ROOT . $file) && !JFile::delete(JPATH_ROOT . $file))
{
- echo JText::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $file).'<br />';
+ echo JText::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $file) . '<br />';
}
}
@@ -624,7 +624,7 @@ public function deleteUnexistingFiles()
{
if (JFolder::exists(JPATH_ROOT . $folder) && !JFolder::delete(JPATH_ROOT . $folder))
{
- echo JText::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $folder).'<br />';
+ echo JText::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $folder) . '<br />';
}
}
}
View
49 administrator/components/com_banners/helpers/banners.php
@@ -100,16 +100,16 @@ public static function getActions($categoryId = 0)
public static function updateReset()
{
$user = JFactory::getUser();
- $db = JFactory::getDBO();
+ $db = JFactory::getDbo();
$nullDate = $db->getNullDate();
$now = JFactory::getDate();
- $query = $db->getQuery(true);
- $query->select('*');
- $query->from('#__banners');
- $query->where("'".$now."' >= ".$db->quoteName('reset'));
- $query->where($db->quoteName('reset').' != '.$db->quote($nullDate).' AND '.$db->quoteName('reset').'!=NULL');
- $query->where('('.$db->quoteName('checked_out').' = 0 OR '.$db->quoteName('checked_out').' = '.(int) $db->Quote($user->id).')');
- $db->setQuery((string) $query);
+ $query = $db->getQuery(true)
+ ->select('*')
+ ->from('#__banners')
+ ->where($db->quote($now) . ' >= ' . $db->quote('reset'))
+ ->where($db->quoteName('reset') . ' != ' . $db->quote($nullDate) . ' AND ' . $db->quoteName('reset') . '!=NULL')
+ ->where('(' . $db->quoteName('checked_out') . ' = 0 OR ' . $db->quoteName('checked_out') . ' = ' . (int) $db->quote($user->id) . ')');
+ $db->setQuery($query);
try
{
@@ -147,30 +147,30 @@ public static function updateReset()
break;
case 2:
$date = JFactory::getDate('+1 year '.date('Y-m-d', strtotime('now')));
- $reset = $db->Quote($date->toSql());
+ $reset = $db->quote($date->toSql());
break;
case 3:
$date = JFactory::getDate('+1 month '.date('Y-m-d', strtotime('now')));
- $reset = $db->Quote($date->toSql());
+ $reset = $db->quote($date->toSql());
break;
case 4:
$date = JFactory::getDate('+7 day '.date('Y-m-d', strtotime('now')));
- $reset = $db->Quote($date->toSql());
+ $reset = $db->quote($date->toSql());
break;
case 5:
$date = JFactory::getDate('+1 day '.date('Y-m-d', strtotime('now')));
- $reset = $db->Quote($date->toSql());
+ $reset = $db->quote($date->toSql());
break;
}
// Update the row ordering field.
- $query->clear();
- $query->update($db->quoteName('#__banners'));
- $query->set($db->quoteName('reset').' = '.$db->quote($reset));
- $query->set($db->quoteName('impmade').' = '.$db->quote(0));
- $query->set($db->quoteName('clicks').' = '.$db->quote(0));
- $query->where($db->quoteName('id').' = '.$db->quote($row->id));
- $db->setQuery((string) $query);
+ $query->clear()
+ ->update($db->quoteName('#__banners'))
+ ->set($db->quoteName('reset') . ' = ' . $db->quote($reset))
+ ->set($db->quoteName('impmade') . ' = ' . $db->quote(0))
+ ->set($db->quoteName('clicks') . ' = ' . $db->quote(0))
+ ->where($db->quoteName('id') . ' = ' . $db->quote($row->id));
+ $db->setQuery($query);
try
{
@@ -190,12 +190,11 @@ public static function getClientOptions()
{
$options = array();
- $db = JFactory::getDbo();
- $query = $db->getQuery(true);
-
- $query->select('id As value, name As text');
- $query->from('#__banner_clients AS a');
- $query->order('a.name');
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
+ ->select('id As value, name As text')
+ ->from('#__banner_clients AS a')
+ ->order('a.name');
// Get the options.
$db->setQuery($query);
View
9 administrator/components/com_banners/helpers/html/banner.php
@@ -51,11 +51,10 @@ public static function clients()
public static function clientlist()
{
$db = JFactory::getDbo();
- $query = $db->getQuery(true);
-
- $query->select('id As value, name As text');
- $query->from('#__banner_clients AS a');
- $query->order('a.name');
+ $query = $db->getQuery(true)
+ ->select('id As value, name As text')
+ ->from('#__banner_clients AS a')
+ ->order('a.name');
// Get the options.
$db->setQuery($query);
View
109 administrator/components/com_banners/models/banners.php
@@ -62,12 +62,12 @@ public function &getCategoryOrders()
{
if (!isset($this->cache['categoryorders']))
{
- $db = $this->getDbo();
- $query = $db->getQuery(true);
- $query->select('MAX(ordering) as '.$db->quoteName('max').', catid');
- $query->select('catid');
- $query->from('#__banners');
- $query->group('catid');
+ $db = $this->getDbo();
+ $query = $db->getQuery(true)
+ ->select('MAX(ordering) as ' . $db->quoteName('max') . ', catid')
+ ->select('catid')
+ ->from('#__banners')
+ ->group('catid');
$db->setQuery($query);
$this->cache['categoryorders'] = $db->loadAssocList('catid', 0);
}
@@ -82,47 +82,48 @@ public function &getCategoryOrders()
*/
protected function getListQuery()
{
- $db = $this->getDbo();
- $query = $db->getQuery(true);
+ $db = $this->getDbo();
+ $query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
- 'a.id AS id, a.name AS name, a.alias AS alias,'.
- 'a.checked_out AS checked_out,'.
- 'a.checked_out_time AS checked_out_time, a.catid AS catid,' .
- 'a.clicks AS clicks, a.metakey AS metakey, a.sticky AS sticky,'.
- 'a.impmade AS impmade, a.imptotal AS imptotal,' .
- 'a.state AS state, a.ordering AS ordering,'.
- 'a.purchase_type as purchase_type,'.
- 'a.language, a.publish_up, a.publish_down'
+ 'a.id AS id, a.name AS name, a.alias AS alias,' .
+ 'a.checked_out AS checked_out,' .
+ 'a.checked_out_time AS checked_out_time, a.catid AS catid,' .
+ 'a.clicks AS clicks, a.metakey AS metakey, a.sticky AS sticky,' .
+ 'a.impmade AS impmade, a.imptotal AS imptotal,' .
+ 'a.state AS state, a.ordering AS ordering,' .
+ 'a.purchase_type as purchase_type,' .
+ 'a.language, a.publish_up, a.publish_down'
)
);
- $query->from($db->quoteName('#__banners').' AS a');
+ $query->from($db->quoteName('#__banners') . ' AS a');
// Join over the language
- $query->select('l.title AS language_title');
- $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language');
+ $query->select('l.title AS language_title')
+ ->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
- $query->select('uc.name AS editor');
- $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
+ $query->select('uc.name AS editor')
+ ->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the categories.
- $query->select('c.title AS category_title');
- $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
+ $query->select('c.title AS category_title')
+ ->join('LEFT', '#__categories AS c ON c.id = a.catid');
// Join over the clients.
- $query->select('cl.name AS client_name,cl.purchase_type as client_purchase_type');
- $query->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid');
+ $query->select('cl.name AS client_name,cl.purchase_type as client_purchase_type')
+ ->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid');
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published))
{
- $query->where('a.state = '.(int) $published);
- } elseif ($published === '')
+ $query->where('a.state = ' . (int) $published);
+ }
+ elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
@@ -131,14 +132,14 @@ protected function getListQuery()
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
- $query->where('a.catid = '.(int) $categoryId);
+ $query->where('a.catid = ' . (int) $categoryId);
}
// Filter by client.
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
- $query->where('a.cid = '.(int) $clientId);
+ $query->where('a.cid = ' . (int) $clientId);
}
// Filter by search in title
@@ -147,10 +148,12 @@ protected function getListQuery()
{
if (stripos($search, 'id:') === 0)
{
- $query->where('a.id = '.(int) substr($search, 3));
- } else {
- $search = $db->Quote('%'.$db->escape($search, true).'%');
- $query->where('(a.name LIKE '.$search.' OR a.alias LIKE '.$search.')');
+ $query->where('a.id = ' . (int) substr($search, 3));
+ }
+ else
+ {
+ $search = $db->quote('%' . $db->escape($search, true) . '%');
+ $query->where('(a.name LIKE ' . $search . ' OR a.alias LIKE ' . $search . ')');
}
}
@@ -161,15 +164,17 @@ protected function getListQuery()
}
// Add the list ordering clause.
- $orderCol = $this->state->get('list.ordering', 'ordering');
- $orderDirn = $this->state->get('list.direction', 'ASC');
+ $orderCol = $this->state->get('list.ordering', 'ordering');
+ $orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol == 'ordering' || $orderCol == 'category_title')
{
- $orderCol = 'c.title '.$orderDirn.', a.ordering';
+ $orderCol = 'c.title ' . $orderDirn . ', a.ordering';
}
if ($orderCol == 'client_name')
+ {
$orderCol = 'cl.name';
- $query->order($db->escape($orderCol.' '.$orderDirn));
+ }
+ $query->order($db->escape($orderCol . ' ' . $orderDirn));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
@@ -182,18 +187,18 @@ protected function getListQuery()
* different modules that might need different sets of data or different
* ordering requirements.
*
- * @param string $id A prefix for the store id.
+ * @param string $id A prefix for the store id.
* @return string A store id.
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
- $id .= ':'.$this->getState('filter.search');
- $id .= ':'.$this->getState('filter.access');
- $id .= ':'.$this->getState('filter.state');
- $id .= ':'.$this->getState('filter.category_id');
- $id .= ':'.$this->getState('filter.language');
+ $id .= ':' . $this->getState('filter.search');
+ $id .= ':' . $this->getState('filter.access');
+ $id .= ':' . $this->getState('filter.state');
+ $id .= ':' . $this->getState('filter.category_id');
+ $id .= ':' . $this->getState('filter.language');
return parent::getStoreId($id);
}
@@ -201,10 +206,10 @@ protected function getStoreId($id = '')
/**
* Returns a reference to the a Table object, always creating it.
*
- * @param type The table type to instantiate
- * @param string A prefix for the table class name. Optional.
- * @param array Configuration array for model. Optional.
- * @return JTable A database object
+ * @param type The table type to instantiate
+ * @param string A prefix for the table class name. Optional.
+ * @param array Configuration array for model. Optional.
+ * @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'Banner', $prefix = 'BannersTable', $config = array())
@@ -224,19 +229,19 @@ protected function populateState($ordering = null, $direction = null)
$app = JFactory::getApplication('administrator');
// Load the filter state.
- $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
+ $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
- $state = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_state', '', 'string');
+ $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);
- $categoryId = $this->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', '');
+ $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
- $clientId = $this->getUserStateFromRequest($this->context.'.filter.client_id', 'filter_client_id', '');
+ $clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
- $language = $this->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
+ $language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Load the parameters.
View
57 administrator/components/com_banners/models/clients.php
@@ -55,10 +55,10 @@ protected function populateState($ordering = null, $direction = null)
$app = JFactory::getApplication('administrator');
// Load the filter state.
- $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
+ $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
- $state = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_state', '', 'string');
+ $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);
// Load the parameters.
@@ -76,16 +76,16 @@ protected function populateState($ordering = null, $direction = null)
* different modules that might need different sets of data or different
* ordering requirements.
*
- * @param string $id A prefix for the store id.
+ * @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
- $id .= ':'.$this->getState('filter.search');
- $id .= ':'.$this->getState('filter.access');
- $id .= ':'.$this->getState('filter.state');
+ $id .= ':' . $this->getState('filter.search');
+ $id .= ':' . $this->getState('filter.access');
+ $id .= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
@@ -105,33 +105,34 @@ protected function getListQuery()
$query->select(
$this->getState(
'list.select',
- 'a.id AS id,'.
- 'a.name AS name,'.
- 'a.contact AS contact,'.
- 'a.checked_out AS checked_out,'.
- 'a.checked_out_time AS checked_out_time, ' .
- 'a.state AS state,'.
- 'a.metakey AS metakey,'.
- 'a.purchase_type as purchase_type'
+ 'a.id AS id,' .
+ 'a.name AS name,' .
+ 'a.contact AS contact,' .
+ 'a.checked_out AS checked_out,' .
+ 'a.checked_out_time AS checked_out_time, ' .
+ 'a.state AS state,' .
+ 'a.metakey AS metakey,' .
+ 'a.purchase_type as purchase_type'
)
);
- $query->from($db->quoteName('#__banner_clients').' AS a');
+ $query->from($db->quoteName('#__banner_clients') . ' AS a');
// Join over the banners for counting
- $query->select('COUNT(b.id) as nbanners');
- $query->join('LEFT', '#__banners AS b ON a.id = b.cid');
+ $query->select('COUNT(b.id) as nbanners')
+ ->join('LEFT', '#__banners AS b ON a.id = b.cid');
// Join over the users for the checked out user.
- $query->select('uc.name AS editor');
- $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
+ $query->select('uc.name AS editor')
+ ->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published))
{
- $query->where('a.state = '.(int) $published);
- } elseif ($published === '')
+ $query->where('a.state = ' . (int) $published);
+ }
+ elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
@@ -144,17 +145,21 @@ protected function getListQuery()
{
if (stripos($search, 'id:') === 0)
{
- $query->where('a.id = '.(int) substr($search, 3));
- } else {
- $search = $db->Quote('%'.$db->escape($search, true).'%');
- $query->where('a.name LIKE '.$search);
+ $query->where('a.id = ' . (int) substr($search, 3));
+ }
+ else
+ {
+ $search = $db->quote('%' . $db->escape($search, true) . '%');
+ $query->where('a.name LIKE ' . $search);
}
}
$ordering_o = $this->getState('list.ordering', 'ordering');
if ($ordering_o == 'nbanners')
+ {
$ordering_o = 'COUNT(b.id)';
+ }
// Add the list ordering clause.
- $query->order($db->escape($ordering_o).' '.$db->escape($this->getState('list.direction', 'ASC')));
+ $query->order($db->escape($ordering_o) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
View
192 administrator/components/com_banners/models/tracks.php
@@ -59,19 +59,19 @@ protected function populateState($ordering = null, $direction = null)
$app = JFactory::getApplication('administrator');
// Load the filter state.
- $type = $this->getUserStateFromRequest($this->context.'.filter.type', 'filter_type');
+ $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type');
$this->setState('filter.type', $type);
- $begin = $this->getUserStateFromRequest($this->context.'.filter.begin', 'filter_begin', '', 'string');
+ $begin = $this->getUserStateFromRequest($this->context . '.filter.begin', 'filter_begin', '', 'string');
$this->setState('filter.begin', $begin);
- $end = $this->getUserStateFromRequest($this->context.'.filter.end', 'filter_end', '', 'string');
+ $end = $this->getUserStateFromRequest($this->context . '.filter.end', 'filter_end', '', 'string');
$this->setState('filter.end', $end);
- $categoryId = $this->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', '');
+ $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
- $clientId = $this->getUserStateFromRequest($this->context.'.filter.client_id', 'filter_client_id', '');
+ $clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
// Load the parameters.
@@ -90,51 +90,51 @@ protected function populateState($ordering = null, $direction = null)
*/
protected function getListQuery()
{
- require_once JPATH_COMPONENT.'/helpers/banners.php';
+ require_once JPATH_COMPONENT . '/helpers/banners.php';
// Create a new query object.
- $db = $this->getDbo();
- $query = $db->getQuery(true);
+ $db = $this->getDbo();
+ $query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
- 'a.track_date as track_date,'.
- 'a.track_type as track_type,'.
- 'a.'.$db->quoteName('count'), ' as '.$db->quoteName('count')
+ 'a.track_date as track_date,'
+ . 'a.track_type as track_type,'
+ . $db->quoteName('a.count') . ' as ' . $db->quoteName('count')
);
- $query->from($db->quoteName('#__banner_tracks').' AS a');
+ $query->from($db->quoteName('#__banner_tracks') . ' AS a');
// Join with the banners
- $query->join('LEFT', $db->quoteName('#__banners').' as b ON b.id=a.banner_id');
- $query->select('b.name as name');
+ $query->join('LEFT', $db->quoteName('#__banners') . ' as b ON b.id=a.banner_id')
+ ->select('b.name as name');
// Join with the client
- $query->join('LEFT', $db->quoteName('#__banner_clients').' as cl ON cl.id=b.cid');
- $query->select('cl.name as client_name');
+ $query->join('LEFT', $db->quoteName('#__banner_clients') . ' as cl ON cl.id=b.cid')
+ ->select('cl.name as client_name');
// Join with the category
- $query->join('LEFT', $db->quoteName('#__categories').' as cat ON cat.id=b.catid');
- $query->select('cat.title as category_title');
+ $query->join('LEFT', $db->quoteName('#__categories') . ' as cat ON cat.id=b.catid')
+ ->select('cat.title as category_title');
// Filter by type
$type = $this->getState('filter.type');
if (!empty($type))
{
- $query->where('a.track_type = '.(int) $type);
+ $query->where('a.track_type = ' . (int) $type);
}
// Filter by client
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
- $query->where('b.cid = '.(int) $clientId);
+ $query->where('b.cid = ' . (int) $clientId);
}
// Filter by category
$catedoryId = $this->getState('filter.category_id');
if (is_numeric($catedoryId))
{
- $query->where('b.catid = '.(int) $catedoryId);
+ $query->where('b.catid = ' . (int) $catedoryId);
}
// Filter by begin date
@@ -142,19 +142,19 @@ protected function getListQuery()
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
- $query->where('a.track_date >= '.$db->Quote($begin));
+ $query->where('a.track_date >= ' . $db->quote($begin));
}
// Filter by end date
$end = $this->getState('filter.end');
if (!empty($end))
{
- $query->where('a.track_date <= '.$db->Quote($end));
+ $query->where('a.track_date <= ' . $db->quote($end));
}
// Add the list ordering clause.
$orderCol = $this->getState('list.ordering', 'name');
- $query->order($db->escape($orderCol).' '.$db->escape($this->getState('list.direction', 'ASC')));
+ $query->order($db->escape($orderCol) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
@@ -168,13 +168,13 @@ protected function getListQuery()
*/
public function delete()
{
- $user = JFactory::getUser();
- $categoryId = $this->getState('category_id');
+ $user = JFactory::getUser();
+ $categoryId = $this->getState('category_id');
// Access checks.
if ($categoryId)
{
- $allow = $user->authorise('core.delete', 'com_banners.category.'.(int) $categoryId);
+ $allow = $user->authorise('core.delete', 'com_banners.category.' . (int) $categoryId);
}
else
{
@@ -185,29 +185,28 @@ public function delete()
{
// Delete tracks from this banner
$db = $this->getDbo();
- $query = $db->getQuery(true);
- $query->delete();
- $query->from($db->quoteName('#__banner_tracks'));
+ $query = $db->getQuery(true)
+ ->delete($db->quoteName('#__banner_tracks'));
// Filter by type
$type = $this->getState('filter.type');
if (!empty($type))
{
- $query->where('track_type = '.(int) $type);
+ $query->where('track_type = ' . (int) $type);
}
// Filter by begin date
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
- $query->where('track_date >= '.$db->Quote($begin));
+ $query->where('track_date >= ' . $db->quote($begin));
}
// Filter by end date
$end = $this->getState('filter.end');
if (!empty($end))
{
- $query->where('track_date <= '.$db->Quote($end));
+ $query->where('track_date <= ' . $db->quote($end));
}
$where = '1';
@@ -215,18 +214,18 @@ public function delete()
$clientId = $this->getState('filter.client_id');
if (!empty($clientId))
{
- $where .= ' AND cid = '.(int) $clientId;
+ $where .= ' AND cid = ' . (int) $clientId;
}
// Filter by category
if (!empty($categoryId))
{
- $where .= ' AND catid = '.(int) $categoryId;
+ $where .= ' AND catid = ' . (int) $categoryId;
}
- $query->where('banner_id IN (SELECT id FROM '.$db->quoteName('#__banners').' WHERE '.$where.')');
+ $query->where('banner_id IN (SELECT id FROM ' . $db->quoteName('#__banners') . ' WHERE ' . $where . ')');
- $db->setQuery((string) $query);
+ $db->setQuery($query);
$this->setError((string) $query);
try
@@ -250,58 +249,70 @@ public function delete()
/**
* Get file name
*
- * @return string The file name
+ * @return string The file name
* @since 1.6
*/
public function getBaseName()
{
- if (!isset($this->basename)) {
+ if (!isset($this->basename))
+ {
- $app = JFactory::getApplication();
- $basename = $this->getState('basename');
- $basename = str_replace('__SITE__', $app->getCfg('sitename'), $basename);
- $categoryId = $this->getState('filter.category_id');
+ $app = JFactory::getApplication();
+ $basename = $this->getState('basename');
+ $basename = str_replace('__SITE__', $app->getCfg('sitename'), $basename);
+ $categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
if ($categoryId > 0)
{
$basename = str_replace('__CATID__', $categoryId, $basename);
- } else {
+ }
+ else
+ {
$basename = str_replace('__CATID__', '', $basename);
}
$categoryName = $this->getCategoryName();
$basename = str_replace('__CATNAME__', $categoryName, $basename);
- } else {
+ }
+ else
+ {
$basename = str_replace('__CATID__', '', $basename);
$basename = str_replace('__CATNAME__', '', $basename);
}
$clientId = $this->getState('filter.client_id');
- if (is_numeric($clientId)) {
+ if (is_numeric($clientId))
+ {
if ($clientId > 0)
{
$basename = str_replace('__CLIENTID__', $clientId, $basename);
- } else {
+ }
+ else
+ {
$basename = str_replace('__CLIENTID__', '', $basename);
}
$clientName = $this->getClientName();
$basename = str_replace('__CLIENTNAME__', $clientName, $basename);
-
- } else {
+ }
+ else
+ {
$basename = str_replace('__CLIENTID__', '', $basename);
$basename = str_replace('__CLIENTNAME__', '', $basename);
}
$type = $this->getState('filter.type');
- if ($type > 0) {
+ if ($type > 0)
+ {
$basename = str_replace('__TYPE__', $type, $basename);
- $typeName = JText::_('COM_BANNERS_TYPE'.$type);
+ $typeName = JText::_('COM_BANNERS_TYPE' . $type);
$basename = str_replace('__TYPENAME__', $typeName, $basename);
- } else {
+ }
+ else
+ {
$basename = str_replace('__TYPE__', '', $basename);
$basename = str_replace('__TYPENAME__', '', $basename);
}
@@ -310,7 +321,9 @@ public function getBaseName()
if (!empty($begin))
{
$basename = str_replace('__BEGIN__', $begin, $basename);
- } else {
+ }
+ else
+ {
$basename = str_replace('__BEGIN__', '', $basename);
}
@@ -318,7 +331,9 @@ public function getBaseName()
if (!empty($end))
{
$basename = str_replace('__END__', $end, $basename);
- } else {
+ }
+ else
+ {
$basename = str_replace('__END__', '', $basename);
}
@@ -331,7 +346,7 @@ public function getBaseName()
/**
* Get the category name.
*
- * @return string The category name
+ * @return string The category name
* @since 1.6
*/
protected function getCategoryName()
@@ -341,11 +356,11 @@ protected function getCategoryName()
if ($categoryId)
{
$db = $this->getDbo();
- $query = $db->getQuery(true);
- $query->select('title');
- $query->from($db->quoteName('#__categories'));
- $query->where($db->quoteName('id').'='.$db->quote($categoryId));
- $db->setQuery((string) $query);
+ $query = $db->getQuery(true)
+ ->select('title')
+ ->from($db->quoteName('#__categories'))
+ ->where($db->quoteName('id') . '=' . $db->quote($categoryId));
+ $db->setQuery($query);
try
{
@@ -368,7 +383,7 @@ protected function getCategoryName()
/**
* Get the category name
*
- * @return string The category name.
+ * @return string The category name.
* @since 1.6
*/
protected function getClientName()
@@ -378,11 +393,11 @@ protected function getClientName()
if ($clientId)
{
$db = $this->getDbo();
- $query = $db->getQuery(true);
- $query->select('name');
- $query->from($db->quoteName('#__banner_clients'));
- $query->where($db->quoteName('id').'='.$db->quote($clientId));
- $db->setQuery((string) $query);
+ $query = $db->getQuery(true)
+ ->select('name')
+ ->from($db->quoteName('#__banner_clients'))
+ ->where($db->quoteName('id') . '=' . $db->quote($clientId));
+ $db->setQuery($query);
try
{
@@ -405,7 +420,7 @@ protected function getClientName()
/**
* Get the file type.
*
- * @return string The file type
+ * @return string The file type
* @since 1.6
*/
public function getFileType()
@@ -416,7 +431,7 @@ public function getFileType()
/**
* Get the mime type.
*
- * @return string The mime type.
+ * @return string The mime type.
* @since 1.6
*/
public function getMimeType()
@@ -427,31 +442,33 @@ public function getMimeType()
/**
* Get the content
*
- * @return string The content.
+ * @return string The content.
* @since 1.6
*/
public function getContent()
{
- if (!isset($this->content)) {
+ if (!isset($this->content))
+ {
$this->content = '';
$this->content .=
- '"'.str_replace('"', '""', JText::_('COM_BANNERS_HEADING_NAME')).'","'.
- str_replace('"', '""', JText::_('COM_BANNERS_HEADING_CLIENT')).'","'.
- str_replace('"', '""', JText::_('JCATEGORY')).'","'.
- str_replace('"', '""', JText::_('COM_BANNERS_HEADING_TYPE')).'","'.
- str_replace('"', '""', JText::_('COM_BANNERS_HEADING_COUNT')).'","'.
- str_replace('"', '""', JText::_('JDATE')).'"'."\n";
-
- foreach ($this->getItems() as $item) {
+ '"' . str_replace('"', '""', JText::_('COM_BANNERS_HEADING_NAME')) . '","' .
+ str_replace('"', '""', JText::_('COM_BANNERS_HEADING_CLIENT')) . '","' .
+ str_replace('"', '""', JText::_('JCATEGORY')) . '","' .
+ str_replace('"', '""', JText::_('COM_BANNERS_HEADING_TYPE')) . '","' .
+ str_replace('"', '""', JText::_('COM_BANNERS_HEADING_COUNT')) . '","' .
+ str_replace('"', '""', JText::_('JDATE')) . '"' . "\n";
+
+ foreach ($this->getItems() as $item)
+ {
$this->content .=
- '"'.str_replace('"', '""', $item->name).'","'.
- str_replace('"', '""', $item->client_name).'","'.
- str_replace('"', '""', $item->category_title).'","'.
- str_replace('"', '""', ($item->track_type == 1 ? JText::_('COM_BANNERS_IMPRESSION'): JText::_('COM_BANNERS_CLICK'))) . '","' .
- str_replace('"', '""', $item->count).'","'.
- str_replace('"', '""', $item->track_date).'"'."\n";
+ '"' . str_replace('"', '""', $item->name) . '","' .
+ str_replace('"', '""', $item->client_name) . '","' .
+ str_replace('"', '""', $item->category_title) . '","' .
+ str_replace('"', '""', ($item->track_type == 1 ? JText::_('COM_BANNERS_IMPRESSION') : JText::_('COM_BANNERS_CLICK'))) . '","' .
+ str_replace('"', '""', $item->count) . '","' .
+ str_replace('"', '""', $item->track_date) . '"' . "\n";
}
if ($this->getState('compressed'))
@@ -463,12 +480,12 @@ public function getContent()
$files['track']['name'] = $this->getBasename() . '.csv';
$files['track']['data'] = $this->content;
$files['track']['time'] = time();
- $ziproot = $app->getCfg('tmp_path').'/' . uniqid('banners_tracks_') . '.zip';
+ $ziproot = $app->getCfg('tmp_path') . '/' . uniqid('banners_tracks_') . '.zip';
// run the packager
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
- $delete = JFolder::files($app->getCfg('tmp_path').'/', uniqid('banners_tracks_'), false, true);
+ $delete = JFolder::files($app->getCfg('tmp_path') . '/', uniqid('banners_tracks_'), false, true);
if (!empty($delete))
{
@@ -484,7 +501,8 @@ public function getContent()
{
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_ADAPTER_FAILURE'));
return false;
- } elseif (!$packager->create($ziproot, $files))
+ }
+ elseif (!$packager->create($ziproot, $files))
{
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_CREATE_FAILURE'));
return false;
View
12 administrator/components/com_banners/tables/banner.php
@@ -74,7 +74,7 @@ public function check()
} elseif (empty($this->ordering))
{
// Set ordering to last if ordering was 0
- $this->ordering = self::getNextOrder($this->_db->quoteName('catid').'=' . $this->_db->Quote($this->catid).' AND state>=0');
+ $this->ordering = self::getNextOrder($this->_db->quoteName('catid').'=' . $this->_db->quote($this->catid).' AND state>=0');
}
return true;
@@ -152,19 +152,19 @@ public function store($updateNulls = false)
break;
case 2:
$date = JFactory::getDate('+1 year '.date('Y-m-d', strtotime('now')));
- $reset = $this->_db->Quote($date->toSql());
+ $reset = $this->_db->quote($date->toSql());
break;
case 3:
$date = JFactory::getDate('+1 month '.date('Y-m-d', strtotime('now')));
- $reset = $this->_db->Quote($date->toSql());
+ $reset = $this->_db->quote($date->toSql());
break;
case 4:
$date = JFactory::getDate('+7 day '.date('Y-m-d', strtotime('now')));
- $reset = $this->_db->Quote($date->toSql());
+ $reset = $this->_db->quote($date->toSql());
break;
case 5:
$date = JFactory::getDate('+1 day '.date('Y-m-d', strtotime('now')));
- $reset = $this->_db->Quote($date->toSql());
+ $reset = $this->_db->quote($date->toSql());
break;
}
// Store the row
@@ -194,7 +194,7 @@ public function store($updateNulls = false)
if ($oldrow->state >= 0 && ($this->state < 0 || $oldrow->catid != $this->catid))
{
// Reorder the oldrow
- $this->reorder($this->_db->quoteName('catid').'=' . $this->_db->Quote($oldrow->catid).' AND state>=0');
+ $this->reorder($this->_db->quoteName('catid').'=' . $this->_db->quote($oldrow->catid).' AND state>=0');
}
}
return count($this->getErrors()) == 0;
View
48 administrator/components/com_categories/helpers/categories.php
@@ -22,7 +22,7 @@ class CategoriesHelper
/**
* Configure the Submenu links.
*
- * @param string The extension being used for the categories.
+ * @param string The extension being used for the categories.
*
* @return void
* @since 1.6
@@ -44,15 +44,15 @@ public static function addSubmenu($extension)
}
// Try to find the component helper.
- $eName = str_replace('com_', '', $component);
- $file = JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component.'/helpers/'.$eName.'.php');
+ $eName = str_replace('com_', '', $component);
+ $file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');
if (file_exists($file))
{
require_once $file;
- $prefix = ucfirst(str_replace('com_', '', $component));
- $cName = $prefix.'Helper';
+ $prefix = ucfirst(str_replace('com_', '', $component));
+ $cName = $prefix . 'Helper';
if (class_exists($cName))
{
@@ -62,12 +62,12 @@ public static function addSubmenu($extension)
$lang = JFactory::getLanguage();
// loading language file from the administrator/language directory then
// loading language file from the administrator/components/*extension*/language directory
- $lang->load($component, JPATH_BASE, null, false, false)
- || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component), null, false, false)
- || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false)
- || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component), $lang->getDefault(), false, false);
+ $lang->load($component, JPATH_BASE, null, false, false)
+ || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, false)
+ || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false)
+ || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), $lang->getDefault(), false, false);
- call_user_func(array($cName, 'addSubmenu'), 'categories'.(isset($section)?'.'.$section:''));
+ call_user_func(array($cName, 'addSubmenu'), 'categories' . (isset($section) ? '.' . $section : ''));
}
}
}
@@ -76,18 +76,18 @@ public static function addSubmenu($extension)
/**
* Gets a list of the actions that can be performed.
*
- * @param string $extension The extension.
- * @param integer $categoryId The category ID.
+ * @param string $extension The extension.
+ * @param integer $categoryId The category ID.
*
* @return JObject
* @since 1.6
*/
public static function getActions($extension, $categoryId = 0)
{
- $user = JFactory::getUser();
- $result = new JObject;
- $parts = explode('.', $extension);
- $component = $parts[0];
+ $user = JFactory::getUser();
+ $result = new JObject;
+ $parts = explode('.', $extension);
+ $component = $parts[0];
if (empty($categoryId))
{
@@ -96,7 +96,7 @@ public static function getActions($extension, $categoryId = 0)
}
else
{
- $assetName = $component.'.category.'.(int) $categoryId;
+ $assetName = $component . '.category.' . (int) $categoryId;
$level = 'category';
}
@@ -114,13 +114,13 @@ public static function getAssociations($pk, $extension = 'com_content')
{
$associations = array();
$db = JFactory::getDbo();
- $query = $db->getQuery(true);
- $query->from('#__categories as c');
- $query->innerJoin('#__associations as a ON a.id = c.id AND a.context='.$db->q('com_categories.item'));
- $query->innerJoin('#__associations as a2 ON a.key = a2.key');
- $query->innerJoin('#__categories as c2 ON a2.id = c2.id AND c2.extension = '.$db->q($extension));
- $query->where('c.id =' . (int) $pk);
- $query->where('c.extension = ' . $db->q($extension));
+ $query = $db->getQuery(true)
+ ->from('#__categories as c')
+ ->join('INNER', '#__associations as a ON a.id = c.id AND a.context=' . $db->quote('com_categories.item'))
+ ->join('INNER', '#__associations as a2 ON a.key = a2.key')
+ ->join('INNER', '#__categories as c2 ON a2.id = c2.id AND c2.extension = ' . $db->quote($extension))
+ ->where('c.id =' . (int) $pk)
+ ->where('c.extension = ' . $db->quote($extension));
$select = array(
'c2.language',
$query->concatenate(array('c2.id', 'c2.alias'), ':') . ' AS id'
View
14 administrator/components/com_categories/helpers/html/categoriesadministrator.php
@@ -29,13 +29,13 @@ public static function association($catid, $extension = 'com_content')
// Get the associated categories
$db = JFactory::getDbo();
- $query = $db->getQuery(true);
- $query->select('c.*');
- $query->from('#__categories as c');
- $query->where('c.id IN ('.implode(',', array_values($associations)).')');
- $query->leftJoin('#__languages as l ON c.language=l.lang_code');
- $query->select('l.image');
- $query->select('l.title as language_title');
+ $query = $db->getQuery(true)
+ ->select('c.*')
+ ->from('#__categories as c')
+ ->where('c.id IN ('.implode(',', array_values($associations)).')')
+ ->join('LEFT', '#__languages as l ON c.language=l.lang_code')
+ ->select('l.image')
+ ->select('l.title as language_title');
$db->setQuery($query);
$items = $db->loadObjectList('id');
View
90 administrator/components/com_categories/models/categories.php
@@ -55,16 +55,16 @@ public function __construct($config = array())
*
* Note. Calling getState in this method will result in recursion.
*
- * @param string An optional ordering field.
- * @param string An optional direction (asc|desc).
+ * @param string An optional ordering field.
+ * @param string An optional direction (asc|desc).
*
* @return void
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
- $app = JFactory::getApplication();
- $context = $this->context;
+ $app = JFactory::getApplication();
+ $context = $this->context;
$extension = $app->getUserStateFromRequest('com_categories.categories.filter.extension', 'extension', 'com_content', 'cmd');
@@ -77,22 +77,22 @@ protected function populateState($ordering = null, $direction = null)
// Extract the optional section name
$this->setState('filter.section', (count($parts) > 1) ? $parts[1] : null);
- $search = $this->getUserStateFromRequest($context.'.search', 'filter_search');
+ $search = $this->getUserStateFromRequest($context . '.search', 'filter_search');
$this->setState('filter.search', $search);
- $level = $this->getUserStateFromRequest($context.'.filter.level', 'filter_level', 0, 'int');
+ $level = $this->getUserStateFromRequest($context . '.filter.level', 'filter_level', 0, 'int');
$this->setState('filter.level', $level);
- $access = $this->getUserStateFromRequest($context.'.filter.access', 'filter_access', 0, 'int');
+ $access = $this->getUserStateFromRequest($context . '.filter.access', 'filter_access', 0, 'int');
$this->setState('filter.access', $access);
- $published = $this->getUserStateFromRequest($context.'.filter.published', 'filter_published', '');
+ $published = $this->getUserStateFromRequest($context . '.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
- $language = $this->getUserStateFromRequest($context.'.filter.language', 'filter_language', '');
+ $language = $this->getUserStateFromRequest($context . '.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
- $tag = $this->getUserStateFromRequest($this->context.'.filter.tag', 'filter_tag', '');
+ $tag = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', '');
$this->setState('filter.tag', $tag);
// List state information.
@@ -106,7 +106,7 @@ protected function populateState($ordering = null, $direction = null)
* different modules that might need different sets of data or different
* ordering requirements.
*
- * @param string $id A prefix for the store id.
+ * @param string $id A prefix for the store id.
*
* @return string A store id.
* @since 1.6
@@ -114,10 +114,10 @@ protected function populateState($ordering = null, $direction = null)
protected function getStoreId($id = '')
{
// Compile the store id.
- $id .= ':'.$this->getState('filter.search');
- $id .= ':'.$this->getState('filter.extension');
- $id .= ':'.$this->getState('filter.published');
- $id .= ':'.$this->getState('filter.language');
+ $id .= ':' . $this->getState('filter.search');
+ $id .= ':' . $this->getState('filter.extension');
+ $id .= ':' . $this->getState('filter.published');
+ $id .= ':' . $this->getState('filter.language');
return parent::getStoreId($id);
}
@@ -130,47 +130,47 @@ protected function getStoreId($id = '')
protected function getListQuery()
{
// Create a new query object.
- $db = $this->getDbo();
- $query = $db->getQuery(true);
- $user = JFactory::getUser();
- $app = JFactory::getApplication();
+ $db = $this->getDbo();
+ $query = $db->getQuery(true);
+ $user = JFactory::getUser();
+ $app = JFactory::getApplication();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.note, a.published, a.access' .
- ', a.checked_out, a.checked_out_time, a.created_user_id' .
- ', a.path, a.parent_id, a.level, a.lft, a.rgt' .
- ', a.language'
+ ', a.checked_out, a.checked_out_time, a.created_user_id' .
+ ', a.path, a.parent_id, a.level, a.lft, a.rgt' .
+ ', a.language'
)
);
$query->from('#__categories AS a');
// Join over the language
- $query->select('l.title AS language_title');
- $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language');
+ $query->select('l.title AS language_title')
+ ->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
- $query->select('uc.name AS editor');
- $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
+ $query->select('uc.name AS editor')
+ ->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
- $query->select('ag.title AS access_level');
- $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
+ $query->select('ag.title AS access_level')
+ ->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the users for the author.
- $query->select('ua.name AS author_name');
- $query->join('LEFT', '#__users AS ua ON ua.id = a.created_user_id');
+ $query->select('ua.name AS author_name')
+ ->join('LEFT', '#__users AS ua ON ua.id = a.created_user_id');
// Join over the associations.
$assoc = $this->getAssoc();
if ($assoc)
{
- $query->select('COUNT(asso2.id)>1 as association');
- $query->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context='.$db->quote('com_categories.item'));
- $query->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key');
- $query->group('a.id');
+ $query->select('COUNT(asso2.id)>1 as association')
+ ->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_categories.item'))
+ ->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')
+ ->group('a.id');
}
// Filter by extension
@@ -194,7 +194,7 @@ protected function getListQuery()
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
- $groups = implode(',', $user->getAuthorisedViewLevels());
+ $groups = implode(',', $user->getAuthorisedViewLevels());