PageRenderTime 53ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/snippets/snippets.rb

https://github.com/alafos/joomla-ruble
Ruby | 1712 lines | 1663 code | 49 blank | 0 comment | 0 complexity | 629df40ac12e49055bca1b520ef9ccd3 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. require 'ruble'
  2. snippet t(:jiniheader) do |s|
  3. s.trigger = 'jiniheader'
  4. s.expansion = '; ${1:Hello}
  5. ; Copyright (C) ${2:2012 AtomTech, Inc}. All rights reserved.
  6. ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
  7. ; Note : All ini files need to be saved as UTF-8 - No BOM
  8. '
  9. end
  10. with_defaults :scope => 'text.xml' do
  11. snippet t(:jcomponentmanifest) do |s|
  12. s.trigger = 'jcomponentmanifest'
  13. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  14. <extension type="component" version="2.5" method="upgrade">
  15. <name>${1:com_hello}</name>
  16. <author>${2:Bruno Batista}</author>
  17. <creationDate>$3</creationDate>
  18. <copyright>(C) ${4:2012 AtomTech, Inc}. All rights reserved.</copyright>
  19. <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
  20. <authorEmail>${5:bruno@atomtech.com.br}</authorEmail>
  21. <authorUrl>http://www.${6:atomtech.com.br}</authorUrl>
  22. <version>2.5.0</version>
  23. <description>COM_${8:HELLO}_XML_DESCRIPTION</description>
  24. <install>
  25. <sql>
  26. <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
  27. </sql>
  28. </install>
  29. <uninstall>
  30. <sql>
  31. <file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
  32. </sql>
  33. </uninstall>
  34. <files folder="site">
  35. <folder>controllers</folder>
  36. <folder>helpers</folder>
  37. <folder>models</folder>
  38. <folder>views</folder>
  39. <filename>${9:hello}.php</filename>
  40. <filename>controller.php</filename>
  41. <filename>index.html</filename>
  42. <filename>router.php</filename>
  43. </files>
  44. <languages folder="site">
  45. <language tag="${11:pt-BR}">language/${11:pt-BR}.${1:com_hello}.ini</language>
  46. </languages>
  47. <administration>
  48. <menu img="class:${9:hello}">${1:com_hello}</menu>
  49. <submenu>
  50. <menu link="option=${1:com_hello}" view="${9:hello}" img="class:${9:hello}" alt="${10:Hello}/${10:Hello}">${1:com_hello}</menu>
  51. <menu link="option=com_categories&amp;extension=${1:com_hello}" view="categories" img="class:${9:hello}-cat" alt="${10:Hello}/Categories">${1:com_hello}_categories</menu>
  52. </submenu>
  53. <files folder="admin">
  54. <folder>controllers</folder>
  55. <folder>helpers</folder>
  56. <folder>models</folder>
  57. <folder>language</folder>
  58. <folder>sql</folder>
  59. <folder>tables</folder>
  60. <folder>views</folder>
  61. <filename>${9:hello}.php</filename>
  62. <filename>access.xml</filename>
  63. <filename>config.xml</filename>
  64. <filename>controller.php</filename>
  65. <filename>index.html</filename>
  66. </files>
  67. <languages folder="admin">
  68. <language tag="${11:pt-BR}">language/${11:pt-BR}.${1:com_hello}.ini</language>
  69. <language tag="${11:pt-BR}">language/${11:pt-BR}.${1:com_hello}.sys.ini</language>
  70. </languages>
  71. </administration>
  72. </extension>
  73. '
  74. end
  75. snippet t(:jmodulemanifest) do |s|
  76. s.trigger = 'jmodulemanifest'
  77. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  78. <extension type="module" version="2.5" client="site" method="upgrade">
  79. <name>${1:mod_hello}</name>
  80. <author>${2:Bruno Batista}</author>
  81. <creationDate>$3</creationDate>
  82. <copyright>Copyright (C) ${4:2012 AtomTech, Inc}. All rights reserved.</copyright>
  83. <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
  84. <authorEmail>${5:bruno@atomtech.com.br}</authorEmail>
  85. <authorUrl>http://www.${6:atomtech.com.br}</authorUrl>
  86. <version>2.5.0</version>
  87. <description>MOD_${7:HELLO}_XML_DESCRIPTION</description>
  88. <files>
  89. <filename module="${1:mod_hello}">${1:mod_hello}.php</filename>
  90. <folder>tmpl</folder>
  91. <filename>${1:mod_hello}.xml</filename>
  92. <filename>helper.php</filename>
  93. <filename>index.html</filename>
  94. </files>
  95. <languages>
  96. <language tag="${8:pt-BR}">${8:pt-BR}.${1:mod_hello}.ini</language>
  97. <language tag="${8:pt-BR}">${8:pt-BR}.${1:mod_hello}.sys.ini</language>
  98. </languages>
  99. <config>
  100. <fields name="params">
  101. <fieldset name="advanced">
  102. <field name="layout" type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
  103. <field name="moduleclass_sfx" type="text" label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL" description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
  104. <field name="cache" type="list" default="1" label="COM_MODULES_FIELD_CACHING_LABEL" description="COM_MODULES_FIELD_CACHING_DESC">
  105. <option value="1">JGLOBAL_USE_GLOBAL</option>
  106. <option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
  107. </field>
  108. <field name="cache_time" type="text" default="900" label="COM_MODULES_FIELD_CACHE_TIME_LABEL" description="COM_MODULES_FIELD_CACHE_TIME_DESC" />
  109. <field name="cachemode" type="hidden" default="static">
  110. <option value="static"></option>
  111. </field>
  112. </fieldset>
  113. </fields>
  114. </config>
  115. </extension>
  116. '
  117. end
  118. snippet t(:jpluginmanifest) do |s|
  119. s.trigger = 'jpluginmanifest'
  120. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  121. <extension version="2.5" type="plugin" group="user">
  122. <name>${1:plg_hello}</name>
  123. <author>${2:Bruno Batista}</author>
  124. <creationDate>$3</creationDate>
  125. <copyright>(C) ${4:2012 AtomTech, Inc}. All rights reserved.</copyright>
  126. <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
  127. <authorEmail>${5:bruno@atomtech.com.br}</authorEmail>
  128. <authorUrl>http://www.${6:atomtech.com.br}</authorUrl>
  129. <version>2.5.0</version>
  130. <description>PLG_${7:HELLO}_XML_DESCRIPTION</description>
  131. <files>
  132. <filename plugin="${8:hello}">${8:hello}.php</filename>
  133. <filename>index.html</filename>
  134. </files>
  135. <languages>
  136. <language tag="${9:pt-BR}">${9:pt-BR}.${1:plg_hello}.ini</language>
  137. <language tag="${9:pt-BR}">${9:pt-BR}.${1:plg_hello}.sys.ini</language>
  138. </languages>
  139. <config>
  140. <fields name="params">
  141. </fields>
  142. </config>
  143. </extension>
  144. '
  145. end
  146. snippet t(:jtemplatemanifest) do |s|
  147. s.trigger = 'jtemplatemanifest'
  148. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  149. <!DOCTYPE install PUBLIC "-//Joomla! 1.6//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd">
  150. <extension version="2.5" type="template" client="site">
  151. <name>${1:hello}</name>
  152. <creationDate>$2</creationDate>
  153. <author>${3:Bruno Batista}</author>
  154. <authorEmail>${4:bruno@atomtech.com.br}</authorEmail>
  155. <authorUrl>http://www.${5:atomtech.com.br}</authorUrl>
  156. <copyright>Copyright (C) ${6:2012 AtomTech, Inc}. All rights reserved.</copyright>
  157. <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
  158. <version>2.5.0</version>
  159. <description>TPL_${7:HELLO}_XML_DESCRIPTION</description>
  160. <files>
  161. <folder>css</folder>
  162. <folder>html</folder>
  163. <folder>images</folder>
  164. <folder>js</folder>
  165. <folder>language</folder>
  166. <filename>component.php</filename>
  167. <filename>error.php</filename>
  168. <filename>favicon.ico</filename>
  169. <filename>index.html</filename>
  170. <filename>index.php</filename>
  171. <filename>template_preview.png</filename>
  172. <filename>template_thumbnail.png</filename>
  173. <filename>templateDetails.xml</filename>
  174. </files>
  175. <positions>
  176. <position>${1:hello}-mainmenu</position>
  177. <position>${1:hello}-search</position>
  178. <position>${1:hello}-sidebar</position>
  179. <position>${1:hello}-footer</position>
  180. <position>${1:hello}-footermenu</position>
  181. </positions>
  182. <languages folder="language">
  183. <language tag="${8:pt-BR}">${8:pt-BR}/${8:pt-BR}.tpl_${1:hello}.ini</language>
  184. <language tag="${8:pt-BR}">${8:pt-BR}/${8:pt-BR}.tpl_${1:hello}.sys.ini</language>
  185. </languages>
  186. </extension>
  187. '
  188. end
  189. snippet t(:jaccess) do |s|
  190. s.trigger = 'jaccess'
  191. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  192. <access component="${1:com_hello}">
  193. <section name="component">
  194. <action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
  195. <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
  196. <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
  197. <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
  198. <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
  199. <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
  200. </section>
  201. <section name="category">
  202. <action name="core.create" title="JACTION_CREATE" description="COM_CATEGORIES_ACCESS_CREATE_DESC" />
  203. <action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />
  204. <action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />
  205. <action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
  206. </section>
  207. </access>
  208. '
  209. end
  210. snippet t(:jconfig) do |s|
  211. s.trigger = 'jconfig'
  212. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  213. <config>
  214. <fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC">
  215. <field name="rules" type="rules" label="JCONFIG_PERMISSIONS_LABEL" class="inputbox" filter="rules" validate="rules" component="${1:com_hello}" section="component" />
  216. </fieldset>
  217. </config>
  218. '
  219. end
  220. snippet t(:jform) do |s|
  221. s.trigger = 'jform'
  222. s.expansion = '<?xml version="1.0" encoding="utf-8"?>
  223. <form>
  224. <fieldset name="details" addfieldpath="/administrator/components/${1:com_hello}/models/fields">
  225. <field name="id" type="text" default="0" readonly="true" class="readonly" label="JGLOBAL_FIELD_ID_LABEL" description="JGLOBAL_FIELD_ID_DESC" />
  226. <field name="title" type="text" class="inputbox" size="40" label="JGLOBAL_TITLE" description="JFIELD_TITLE_DESC" required="true" />
  227. <field name="alias" type="text" class="inputbox" size="40" label="JFIELD_ALIAS_LABEL" description="JFIELD_ALIAS_DESC" />
  228. <field name="catid" type="categoryedit" extension="${1:com_hello}" label="JCATEGORY" description="COM_${2:HELLO}_FIELD_CATEGORY_DESC" class="inputbox" required="true" addfieldpath="/administrator/components/com_categories/models/fields"> >
  229. </field>
  230. <field name="published" type="list" label="JSTATUS" description="COM_${2:HELLO}_FIELD_STATE_DESC" class="inputbox" size="1" default="1">
  231. <option value="1">JPUBLISHED</option>
  232. <option value="0">JUNPUBLISHED</option>
  233. <option value="2">JARCHIVED</option>
  234. <option value="-2">JTRASHED</option>
  235. </field>
  236. <field name="ordering" type="ordering" class="inputbox" label="JFIELD_ORDERING_LABEL" description="JFIELD_ORDERING_DESC" />
  237. <field name="description" type="editor" label="JGLOBAL_DESCRIPTION" description="COM_${2:HELLO}_FIELD_DESCRIPTION_DESC" class="inputbox" filter="JComponentHelper::filterText" buttons="true" hide="readmore,pagebreak" />
  238. </fieldset>
  239. <fieldset name="publish">
  240. <field name="created" type="calendar" label="JGLOBAL_FIELD_CREATED_LABEL" description="JGLOBAL_FIELD_CREATED_DESC" class="inputbox" size="22" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
  241. <field name="created_by" type="user" label="JGLOBAL_FIELD_CREATED_BY_LABEL" description="JGLOBAL_FIELD_CREATED_BY_Desc" />
  242. <field name="modified" type="calendar" class="readonly" label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_WEBLINKS_FIELD_MODIFIED_DESC" size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
  243. <field name="modified_by" type="user" label="JGLOBAL_FIELD_MODIFIED_BY_LABEL" class="readonly" readonly="true" filter="unset" />
  244. <field name="checked_out" type="hidden" filter="unset" />
  245. <field name="checked_out_time" type="hidden" filter="unset" />
  246. <field name="publish_up" type="calendar" label="JGLOBAL_FIELD_PUBLISH_UP_LABEL" description="JGLOBAL_FIELD_PUBLISH_UP_DESC" class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22" filter="user_utc" />
  247. <field name="publish_down" type="calendar" label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL" description="JGLOBAL_FIELD_PUBLISH_DOWN_DESC" class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22" filter="user_utc" />
  248. </fieldset>
  249. </form>
  250. '
  251. end
  252. end
  253. with_defaults :scope => 'text.html - source' do
  254. snippet t(:jheader) do |s|
  255. s.trigger = 'jheader'
  256. s.expansion = '<?php
  257. /**
  258. * @package ${1:Hello}
  259. * @subpackage ${2:com_hello}
  260. * @copyright Copyright (C) ${3:AtomTech}, Inc. All rights reserved.
  261. * @license GNU General Public License version 2 or later; see LICENSE.txt
  262. */
  263. // no direct access
  264. defined(\'_JEXEC\') or die;
  265. '
  266. end
  267. end
  268. with_defaults :scope => 'source.php' do
  269. snippet t(:jaddstyle) do |s|
  270. s.trigger = 'jaddstyle'
  271. s.expansion = '// Add style
  272. \$doc = JFactory::getDocument();
  273. \$doc->setTitle(JText::_(\'COM_${1:HELLO}_${2:HELLO}_TITLE\'));
  274. \$doc->addStyleSheet(JURI::root() . \'media/${3:com_hello}/css/backend.css\');
  275. '
  276. end
  277. snippet t(:jchecktoken) do |s|
  278. s.trigger = 'jchecktoken'
  279. s.expansion = '// Check for request forgeries.
  280. JSession::checkToken() or jexit(JText::_(\'JINVALID_TOKEN\'));'
  281. end
  282. snippet t(:jcontrolleredit) do |s|
  283. s.trigger = 'jcontrolleredit'
  284. s.expansion = 'jimport(\'joomla.application.component.controllerform\');
  285. /**
  286. * ${4:Hello} controller class.
  287. *
  288. * @package ${1:Hello}
  289. * @subpackage ${2:com_hello}
  290. * @since 2.5
  291. */
  292. class ${3:Hello}Controller${4:Hello} extends JControllerForm
  293. {
  294. /**
  295. * @var string The prefix to use with controller messages.
  296. * @since 2.5
  297. */
  298. protected \$text_prefix = \'COM_${5:HELLO}_${6:HELLO}\';
  299. }
  300. '
  301. end
  302. snippet t(:jcontrollerlist) do |s|
  303. s.trigger = 'jcontrollerlist'
  304. s.expansion = 'jimport(\'joomla.application.component.controlleradmin\');
  305. /**
  306. * ${4:Hello} list controller class.
  307. *
  308. * @package ${1:Hello}
  309. * @subpackage ${2:com_hello}
  310. * @since 2.5
  311. */
  312. class ${3:Hello}Controller${4:Hello} extends JControllerAdmin
  313. {
  314. /**
  315. * @var string The prefix to use with controller messages.
  316. * @since 2.5
  317. */
  318. protected \$text_prefix = \'COM_${5:HELLO}_${5:HELLO}\';
  319. /**
  320. * Constructor.
  321. *
  322. * @param array An optional associative array of configuration settings.
  323. * @see JController
  324. * @since 2.5
  325. */
  326. public function __construct(\$config = array())
  327. {
  328. parent::__construct(\$config);
  329. }
  330. /**
  331. * Proxy for getModel.
  332. * @since 2.5
  333. */
  334. public function getModel(\$name = \'${6:Hello}\', \$prefix = \'${3:Hello}Model\', \$config = array(\'ignore_request\' => true))
  335. {
  336. \$model = parent::getModel(\$name, \$prefix, \$config);
  337. return \$model;
  338. }
  339. }
  340. '
  341. end
  342. snippet t(:jdbo) do |s|
  343. s.trigger = 'jdbo'
  344. s.expansion = '// Initialiase variables.
  345. \$db = JFactory::getDbo();
  346. // Use following line in a model.
  347. //\$db = \$this->getDbo();
  348. \$query = \$db->getQuery(true);
  349. // Prepare query.
  350. \$query->select(\'\');
  351. \$query->from(\'#__\');
  352. \$query->where(\'\');
  353. // Inject the query and load the result.
  354. \$db->setQuery(\$query);
  355. \$result = \$db->loadObjectList();
  356. // Check for errors.
  357. if (\$error = \$db->getErrorMsg()) {
  358. \$this->setError(\$error);
  359. \$result = false;
  360. return \$result;
  361. }
  362. '
  363. end
  364. snippet t(:jdefaultview) do |s|
  365. s.trigger = 'jdefaultview'
  366. s.expansion = '/**
  367. * @var string The default view.
  368. * @since 2.5
  369. */
  370. protected $default_view = \'$1\';
  371. '
  372. end
  373. snippet t(:jdoc) do |s|
  374. s.trigger = 'jdoc'
  375. s.expansion = '<jdoc:include type="${1:component}" />'
  376. end
  377. snippet t(:jdocmessage) do |s|
  378. s.trigger = 'jdocmessage'
  379. s.expansion = '<?php
  380. \$messages = \$app->getMessageQueue();
  381. if (count(\$messages)) {
  382. foreach (\$messages as \$message) {
  383. \$html = \'<div class="alert alert-\' . strtolower(\$message[\'type\']) . \'">\';
  384. \$html .= \'<button data-dismiss="alert" class="close">×</button>\';
  385. \$html .= \'<strong>\' . JText::_(\'TPL_BOOTSTRAP_MESSAGE_\' . strtoupper(\$message[\'type\'])) . \'!</strong> \' . \$message[\'message\'];
  386. \$html .= \'</div>\';
  387. echo \$html;
  388. }
  389. }
  390. ?>'
  391. end
  392. snippet t(:jdocmodules) do |s|
  393. s.trigger = 'jdocmodules'
  394. s.expansion = '<jdoc:include type="modules" name="${1:hello-mainmenu}" style="${2:none}" />'
  395. end
  396. snippet t(:jfield) do |s|
  397. s.trigger = 'jfield'
  398. s.expansion = '/**
  399. * Form Field ${3:Name} class.
  400. *
  401. * @package ${1:Hello}
  402. * @subpackage ${2:com_hello}
  403. * @since 2.5
  404. */
  405. class JFormField${3:Name} extends JFormField
  406. {
  407. /**
  408. * The field type.
  409. *
  410. * @var string
  411. */
  412. protected \$type = \'${3:Name}\';
  413. /**
  414. * Method to get the field input.
  415. *
  416. * @return string The field input.
  417. * @since 2.5
  418. */
  419. protected function getInput()
  420. {
  421. \$return = \'\';
  422. return \$return;
  423. }
  424. }
  425. '
  426. end
  427. snippet t(:jfieldordering) do |s|
  428. s.trigger = 'jfieldordering'
  429. s.expansion = '/**
  430. * Supports an HTML select list of ${3:hellos}
  431. *
  432. * @package ${1:Hello}
  433. * @subpackage ${2:com_hello}
  434. * @since 2.5
  435. */
  436. class JFormFieldOrdering extends JFormField
  437. {
  438. /**
  439. * The form field type.
  440. *
  441. * @var string
  442. * @since 1.6
  443. */
  444. protected \$type = \'Ordering\';
  445. /**
  446. * Method to get the field input markup.
  447. *
  448. * @return string The field input markup.
  449. * @since 1.6
  450. */
  451. protected function getInput()
  452. {
  453. // Initialize variables.
  454. \$html = array();
  455. \$attr = \'\';
  456. // Initialize some field attributes.
  457. \$attr .= \$this->element[\'class\'] ? \' class="\'.(string) \$this->element[\'class\'].\'"\' : \'\';
  458. \$attr .= ((string) \$this->element[\'disabled\'] == \'true\') ? \' disabled="disabled"\' : \'\';
  459. \$attr .= \$this->element[\'size\'] ? \' size="\'.(int) \$this->element[\'size\'].\'"\' : \'\';
  460. // Initialize JavaScript field attributes.
  461. \$attr .= \$this->element[\'onchange\'] ? \' onchange="\'.(string) \$this->element[\'onchange\'].\'"\' : \'\';
  462. // Get some field values from the form.
  463. \$${4:hello}Id = (int) \$this->form->getValue(\'id\');
  464. \$categoryId = (int) \$this->form->getValue(\'catid\');
  465. // Build the query for the ordering list.
  466. \$query = \'SELECT ordering AS value, ${6:title} AS text\' .
  467. \' FROM #__${5:hellos}\' .
  468. \' WHERE catid = \' . (int) \$categoryId .
  469. \' ORDER BY ordering\';
  470. // Create a read-only list (no ${6:title}) with a hidden input to store the value.
  471. if ((string) \$this->element[\'readonly\'] == \'true\') {
  472. \$html[] = JHtml::_(\'list.ordering\', \'\', \$query, trim(\$attr), \$this->value, \$${4:hello}Id ? 0 : 1);
  473. \$html[] = \'<input type="hidden" name="\'.\$this->${6:title}.\'" value="\'.\$this->value.\'"/>\';
  474. }
  475. // Create a regular list.
  476. else {
  477. \$html[] = JHtml::_(\'list.ordering\', \$this->${6:title}, \$query, trim(\$attr), \$this->value, \$${4:hello}Id ? 0 : 1);
  478. }
  479. return implode(\$html);
  480. }
  481. }
  482. '
  483. end
  484. snippet t(:jgetlayout) do |s|
  485. s.trigger = 'jgetlayout'
  486. s.expansion = 'require JModuleHelper::getLayoutPath(\'${1:mod_hello}\', $params->get(\'layout\', \'default\'));
  487. '
  488. end
  489. snippet t(:jgetlist) do |s|
  490. s.trigger = 'jgetlist'
  491. s.expansion = '\$list = mod${1:Hello}Helper::getList(\$params);'
  492. end
  493. snippet t(:jgridsort) do |s|
  494. s.trigger = 'jgridsort'
  495. s.expansion = '<?php echo JHtml::_(\'grid.sort\', \'COM_${1:HELLO}_HEADING_${2:TITLE}\', \'a.${3:title}\', \$listDirn, \$listOrder); ?>'
  496. end
  497. snippet t(:jhelper) do |s|
  498. s.trigger = 'jhelper'
  499. s.expansion = '/**
  500. * ${3:Hello} component helper.
  501. *
  502. * @package ${1:Hello}
  503. * @subpackage ${2:com_hello}
  504. * @since 2.5
  505. */
  506. class ${3:Hello}Helper
  507. {
  508. public static \$extension = \'${2:com_hello}\';
  509. /**
  510. * Configure the Linkbar.
  511. *
  512. * @param string \$vName The name of the active view.
  513. *
  514. * @return void
  515. * @since 2.5
  516. */
  517. public static function addSubmenu(\$vName)
  518. {
  519. JSubMenuHelper::addEntry(
  520. JText::_(\'COM_${5:HELLO}_SUBMENU_${5:HELLO}\'),
  521. \'index.php?option=${2:com_hello}&view=${4:hello}\',
  522. \$vName == \'${4:hello}\'
  523. );
  524. JSubMenuHelper::addEntry(
  525. JText::_(\'COM_${5:HELLO}_SUBMENU_CATEGORIES\'),
  526. \'index.php?option=com_categories&extension=${2:com_hello}\',
  527. \$vName == \'categories\'
  528. );
  529. }
  530. /**
  531. * Gets a list of the actions that can be performed.
  532. *
  533. * @return JObject
  534. */
  535. public static function getActions()
  536. {
  537. \$user = JFactory::getUser();
  538. \$result = new JObject;
  539. \$assetName = \'${2:com_hello}\';
  540. \$actions = array(
  541. \'core.admin\', \'core.manage\', \'core.create\', \'core.edit\', \'core.edit.state\', \'core.delete\'
  542. );
  543. foreach (\$actions as \$action) {
  544. \$result->set(\$action, \$user->authorise(\$action, \$assetName));
  545. }
  546. return \$result;
  547. }
  548. }
  549. '
  550. end
  551. snippet t(:jhtmldate) do |s|
  552. s.trigger = 'jhtmldate'
  553. s.expansion = '<?php echo JHtml::_(\'date\', \$item->${1:created}, JText::_(\'${2:DATE_FORMAT_LC4}\')); ?>'
  554. end
  555. snippet t(:jitem) do |s|
  556. s.trigger = 'jitem'
  557. s.expansion = '<?php echo $item->${1:title}; ?>'
  558. end
  559. snippet t(:jlanguagelist) do |s|
  560. s.trigger = 'jlanguagelist'
  561. s.expansion = 'COM_${1:HELLO}${2:_VIEW}_N_ITEMS_ARCHIVED="%d ${3:Hellos} arquivados com sucesso."
  562. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_ARCHIVED_0="Nenhum ${4:Hello} arquivado."
  563. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_ARCHIVED_1="1 ${4:Hello} arquivado com sucesso."
  564. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_DELETED="%d ${3:Hellos} deletados com sucesso."
  565. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_DELETED_0="Nenhum ${4:Hello} deletado."
  566. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_DELETED_1="1 ${4:Hello} deletado com sucesso."
  567. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_PUBLISHED="%d ${3:Hellos} publicados com sucesso."
  568. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_PUBLISHED_0="Nenhum ${4:Hello} publicado."
  569. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_PUBLISHED_1="1 ${4:Hello} publicado com sucesso."
  570. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_TRASHED="%d ${3:Hellos} lixeira com sucesso."
  571. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_TRASHED_0="Nenhum ${4:Hello} lixeira."
  572. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_TRASHED_1="1 ${4:Hello} lixeira com sucesso."
  573. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_UNPUBLISHED="%d ${3:Hellos} despublicados com sucesso."
  574. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_UNPUBLISHED_0="Nenhum ${4:Hello} despublicado."
  575. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_UNPUBLISHED_1="1 ${4:Hello} despublicado com sucesso."
  576. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_CHECKED_IN="%d ${3:Hellos} desbloqueados com sucesso."
  577. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_CHECKED_IN_0="Nenhum ${4:Hello} desbloqueado."
  578. COM_${1:HELLO}${2:_VIEW}_N_ITEMS_CHECKED_IN_1="1 ${4:Hello} desbloqueado com sucesso."'
  579. end
  580. snippet t(:jlayoutedit) do |s|
  581. s.trigger = 'jlayoutedit'
  582. s.expansion = 'JHtml::addIncludePath(JPATH_COMPONENT . \'/helpers/html\');
  583. JHtml::_(\'behavior.tooltip\');
  584. JHtml::_(\'behavior.formvalidation\');
  585. \$canDo = ${1:Hello}Helper::getActions();
  586. ?>
  587. <form action="<?php echo JRoute::_(\'index.php?option=${2:com_hello}&layout=edit&id=\'.(int) \$this->item->id); ?>" method="post" name="adminForm" id="${3:hello}-form" class="form-validate">
  588. <div class="width-60 fltlft">
  589. <fieldset class="adminform">
  590. <legend><?php echo empty(\$this->item->id) ? JText::_(\'COM_${4:HELLO}_${5:HELLO}_ADD\') : JText::sprintf(\'COM_${4:HELLO}_${5:HELLO}_EDIT\', \$this->item->id); ?></legend>
  591. <ul class="adminformlist">
  592. <?php if (\$this->item->id): ?>
  593. <li><?php echo \$this->form->getLabel(\'id\'); ?>
  594. <?php echo \$this->form->getInput(\'id\'); ?></li>
  595. <?php endif ?>
  596. <li><?php echo \$this->form->getLabel(\'title\'); ?>
  597. <?php echo \$this->form->getInput(\'title\'); ?></li>
  598. <li><?php echo \$this->form->getLabel(\'alias\'); ?>
  599. <?php echo \$this->form->getInput(\'alias\'); ?></li>
  600. <li><?php echo \$this->form->getLabel(\'catid\'); ?>
  601. <?php echo \$this->form->getInput(\'catid\'); ?></li>
  602. <?php if (\$canDo->get(\'core.edit.state\')) : ?>
  603. <li><?php echo \$this->form->getLabel(\'published\'); ?>
  604. <?php echo \$this->form->getInput(\'published\'); ?></li>
  605. <?php endif; ?>
  606. <li><?php echo \$this->form->getLabel(\'ordering\'); ?>
  607. <?php echo \$this->form->getInput(\'ordering\'); ?></li>
  608. </ul>
  609. <div class="clr"></div>
  610. <?php echo \$this->form->getLabel(\'description\'); ?>
  611. <div class="clr"></div>
  612. <?php echo \$this->form->getInput(\'description\'); ?>
  613. </fieldset>
  614. </div>
  615. <div class="width-40 fltrt">
  616. <?php echo \$this->loadTemplate(\'${6:publish}\'); ?>
  617. </div>
  618. <div>
  619. <input type="hidden" name="task" value="" />
  620. <?php echo JHtml::_(\'form.token\'); ?>
  621. </div>
  622. <div class="clr"></div>
  623. </form>
  624. '
  625. end
  626. snippet t(:jlayoutfieldset) do |s|
  627. s.trigger = 'jlayoutfieldset'
  628. s.expansion = '<fieldset class="panelform">
  629. <ul class="adminformlist">
  630. <?php foreach(\$this->form->getFieldset(\'${1:publish}\') as \$field): ?>
  631. <li><?php echo \$field->label; ?>
  632. <?php echo \$field->input; ?></li>
  633. <?php endforeach; ?>
  634. </ul>
  635. </fieldset>'
  636. end
  637. snippet t(:jlayoutlist) do |s|
  638. s.trigger = 'jlayoutlist'
  639. s.expansion = 'JHtml::addIncludePath(JPATH_COMPONENT.\'/helpers/html\');
  640. JHtml::_(\'behavior.tooltip\');
  641. JHtml::_(\'behavior.multiselect\');
  642. \$user = JFactory::getUser();
  643. \$userId = \$user->get(\'id\');
  644. \$listOrder = \$this->escape(\$this->state->get(\'list.ordering\'));
  645. \$listDirn = \$this->escape(\$this->state->get(\'list.direction\'));
  646. \$canOrder = \$user->authorise(\'core.edit.state\', \'${1:com_hello}.category\');
  647. \$saveOrder = \$listOrder == \'a.ordering\';
  648. \$params = (isset(\$this->state->params)) ? \$this->state->params : new JObject();
  649. ?>
  650. <form action="<?php echo JRoute::_(\'index.php?option=${1:com_hello}&view=${2:hellos}\'); ?>" method="post" name="adminForm" id="adminForm">
  651. <fieldset id="filter-bar">
  652. <div class="filter-search fltlft">
  653. <label class="filter-search-lbl" for="filter_search"><?php echo JText::_(\'JSEARCH_FILTER_LABEL\'); ?></label>
  654. <input type="text" name="filter_search" id="filter_search" value="<?php echo \$this->escape(\$this->state->get(\'filter.search\')); ?>" title="<?php echo JText::_(\'COM_${3:HELLO}_SEARCH_IN_TITLE\'); ?>" />
  655. <button type="submit"><?php echo JText::_(\'JSEARCH_FILTER_SUBMIT\'); ?></button>
  656. <button type="button" onclick="document.id(\'filter_search\').value=\'\';this.form.submit();"><?php echo JText::_(\'JSEARCH_FILTER_CLEAR\'); ?></button>
  657. </div>
  658. <div class="filter-select fltrt">
  659. <select name="filter_published" class="inputbox" onchange="this.form.submit()">
  660. <option value=""><?php echo JText::_(\'JOPTION_SELECT_PUBLISHED\');?></option>
  661. <?php echo JHtml::_(\'select.options\', JHtml::_(\'jgrid.publishedOptions\'), \'value\', \'text\', \$this->state->get(\'filter.published\'), true);?>
  662. </select>
  663. <select name="filter_category_id" class="inputbox" onchange="this.form.submit()">
  664. <option value=""><?php echo JText::_(\'JOPTION_SELECT_CATEGORY\');?></option>
  665. <?php echo JHtml::_(\'select.options\', JHtml::_(\'category.options\', \'${1:com_hello}\'), \'value\', \'text\', \$this->state->get(\'filter.category_id\'));?>
  666. </select>
  667. </div>
  668. </fieldset>
  669. <div class="clr"></div>
  670. <table class="adminlist">
  671. <thead>
  672. <tr>
  673. <th width="1%">
  674. <input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_(\'JGLOBAL_CHECK_ALL\'); ?>" onclick="Joomla.checkAll(this)" />
  675. </th>
  676. <th>
  677. <?php echo JHtml::_(\'grid.sort\', \'JGLOBAL_TITLE\', \'a.title\', \$listDirn, \$listOrder); ?>
  678. </th>
  679. <th width="5%">
  680. <?php echo JHtml::_(\'grid.sort\', \'JSTATUS\', \'a.published\', \$listDirn, \$listOrder); ?>
  681. </th>
  682. <th width="10%">
  683. <?php echo JHtml::_(\'grid.sort\', \'JCATEGORY\', \'category_title\', \$listDirn, \$listOrder); ?>
  684. </th>
  685. <th width="10%">
  686. <?php echo JHtml::_(\'grid.sort\', \'JGRID_HEADING_ORDERING\', \'a.ordering\', \$listDirn, \$listOrder); ?>
  687. <?php if (\$canOrder && \$saveOrder): ?>
  688. <?php echo JHtml::_(\'grid.order\', \$this->items, \'filesave.png\', \'${2:hellos}.saveorder\'); ?>
  689. <?php endif;?>
  690. </th>
  691. <th width="1%" class="nowrap">
  692. <?php echo JHtml::_(\'grid.sort\', \'JGRID_HEADING_ID\', \'a.id\', \$listDirn, \$listOrder); ?>
  693. </th>
  694. </tr>
  695. </thead>
  696. <tfoot>
  697. <tr>
  698. <td colspan="13">
  699. <?php echo \$this->pagination->getListFooter(); ?>
  700. </td>
  701. </tr>
  702. </tfoot>
  703. <tbody>
  704. <?php foreach (\$this->items as \$i => \$item) :
  705. \$ordering = \$listOrder == \'a.ordering\';
  706. \$item->cat_link = JRoute::_(\'index.php?option=com_categories&extension=${1:com_hello}&task=edit&type=other&cid[]=\'. \$item->catid);
  707. \$canCreate = \$user->authorise(\'core.create\', \'${1:com_hello}.category.\'.\$item->catid);
  708. \$canEdit = \$user->authorise(\'core.edit\', \'${1:com_hello}.category.\'.\$item->catid);
  709. \$canCheckin = \$user->authorise(\'core.manage\', \'com_checkin\') || \$item->checked_out == \$userId || \$item->checked_out == 0;
  710. \$canChange = \$user->authorise(\'core.edit.state\', \'${1:com_hello}.category.\'.\$item->catid) && \$canCheckin;
  711. ?>
  712. <tr class="row<?php echo \$i % 2; ?>">
  713. <td class="center">
  714. <?php echo JHtml::_(\'grid.id\', \$i, \$item->id); ?>
  715. </td>
  716. <td>
  717. <?php if (\$item->checked_out) : ?>
  718. <?php echo JHtml::_(\'jgrid.checkedout\', \$i, \$item->editor, \$item->checked_out_time, \'${2:hellos}.\', \$canCheckin); ?>
  719. <?php endif; ?>
  720. <?php if (\$canEdit) : ?>
  721. <a href="<?php echo JRoute::_(\'index.php?option=${1:com_hello}&task=${4:hello}.edit&id=\'.(int) \$item->id); ?>">
  722. <?php echo \$this->escape(\$item->title); ?></a>
  723. <?php else : ?>
  724. <?php echo \$this->escape(\$item->title); ?>
  725. <?php endif; ?>
  726. <p class="smallsub">
  727. <?php echo JText::sprintf(\'JGLOBAL_LIST_ALIAS\', \$this->escape(\$item->alias));?></p>
  728. </td>
  729. <td class="center">
  730. <?php echo JHtml::_(\'jgrid.published\', \$item->published, \$i, \'${2:hellos}.\', \$canChange, \'cb\', \$item->publish_up, \$item->publish_down); ?>
  731. </td>
  732. <td class="center">
  733. <?php echo \$this->escape(\$item->category_title); ?>
  734. </td>
  735. <td class="order">
  736. <?php if (\$canChange) : ?>
  737. <?php if (\$saveOrder) : ?>
  738. <?php if (\$listDirn == \'asc\') : ?>
  739. <span><?php echo \$this->pagination->orderUpIcon(\$i, (@\$this->items[\$i-1]->catid == \$item->catid), \'${2:hellos}.orderup\', \'JLIB_HTML_MOVE_UP\', \$ordering); ?></span>
  740. <span><?php echo \$this->pagination->orderDownIcon(\$i, \$this->pagination->total, (@\$this->items[\$i+1]->catid == \$item->catid), \'${2:hellos}.orderdown\', \'JLIB_HTML_MOVE_DOWN\', \$ordering); ?></span>
  741. <?php elseif (\$listDirn == \'desc\') : ?>
  742. <span><?php echo \$this->pagination->orderUpIcon(\$i, (@\$this->items[\$i-1]->catid == \$item->catid), \'${2:hellos}.orderdown\', \'JLIB_HTML_MOVE_UP\', \$ordering); ?></span>
  743. <span><?php echo \$this->pagination->orderDownIcon(\$i, \$this->pagination->total, (@\$this->items[\$i+1]->catid == \$item->catid), \'${2:hellos}.orderup\', \'JLIB_HTML_MOVE_DOWN\', \$ordering); ?></span>
  744. <?php endif; ?>
  745. <?php endif; ?>
  746. <?php \$disabled = \$saveOrder ? \'\' : \'disabled="disabled"\'; ?>
  747. <input type="text" name="order[]" size="5" value="<?php echo \$item->ordering;?>" <?php echo \$disabled; ?> class="text-area-order" />
  748. <?php else : ?>
  749. <?php echo \$item->ordering; ?>
  750. <?php endif; ?>
  751. </td>
  752. <td class="center">
  753. <?php echo \$item->id; ?>
  754. </td>
  755. </tr>
  756. <?php endforeach; ?>
  757. </tbody>
  758. </table>
  759. <div>
  760. <input type="hidden" name="task" value="" />
  761. <input type="hidden" name="boxchecked" value="0" />
  762. <input type="hidden" name="filter_order" value="<?php echo \$listOrder; ?>" />
  763. <input type="hidden" name="filter_order_Dir" value="<?php echo \$listDirn; ?>" />
  764. <?php echo JHtml::_(\'form.token\'); ?>
  765. </div>
  766. </form>
  767. '
  768. end
  769. snippet t(:jloadtemplate) do |s|
  770. s.trigger = 'jloadtemplate'
  771. s.expansion = '<?php echo \$this->loadTemplate(\'$1\'); ?>'
  772. end
  773. snippet t(:jmastercomponent) do |s|
  774. s.trigger = 'jmastercomponent'
  775. s.expansion = '// Access check.
  776. if (!JFactory::getUser()->authorise(\'core.manage\', \'${1:com_hello}\')) {
  777. return JError::raiseWarning(404, JText::_(\'JERROR_ALERTNOAUTHOR\'));
  778. }
  779. // Include dependancies
  780. jimport(\'joomla.application.component.controller\');
  781. // Execute the task.
  782. \$controller = JController::getInstance(\'${2:Hello}\');
  783. \$controller->execute(JRequest::getCmd(\'task\'));
  784. \$controller->redirect();
  785. '
  786. end
  787. snippet t(:jmastercontroller) do |s|
  788. s.trigger = 'jmastercontroller'
  789. s.expansion = 'jimport(\'joomla.application.component.controller\');
  790. /**
  791. * ${3:Hello} Component Controller
  792. *
  793. * @package ${1:Hello}
  794. * @subpackage ${2:com_hello}
  795. */
  796. class ${3:Hello}Controller extends JController
  797. {
  798. /**
  799. * @var string The default view.
  800. * @since 2.5
  801. */
  802. protected \$default_view = \'${4:cpanel}\';
  803. /**
  804. * Method to display a view.
  805. *
  806. * @param boolean If true, the view output will be cached
  807. * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  808. *
  809. * @return JController This object to support chaining.
  810. * @since 2.5
  811. */
  812. public function display(\$cachable = false, \$urlparams = false)
  813. {
  814. require_once JPATH_COMPONENT.\'/helpers/${5:hello}.php\';
  815. // Load the submenu.
  816. ${3:Hello}Helper::addSubmenu(JRequest::getCmd(\'view\', \'${4:cpanel}\'));
  817. \$view = JRequest::getCmd(\'view\', \'${4:cpanel}\');
  818. \$layout = JRequest::getCmd(\'layout\', \'default\');
  819. \$id = JRequest::getInt(\'id\');
  820. parent::display();
  821. return \$this;
  822. }
  823. }
  824. '
  825. end
  826. snippet t(:jmastercontrollerdisplay) do |s|
  827. s.trigger = 'jmastercontrollerdisplay'
  828. s.expansion = '/**
  829. * Method to display a view.
  830. *
  831. * @param boolean If true, the view output will be cached
  832. * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  833. *
  834. * @return JController This object to support chaining.
  835. * @since 2.5
  836. */
  837. public function display(\$cachable = false, \$urlparams = false)
  838. {
  839. require_once JPATH_COMPONENT.\'/helpers/${1:hello}.php\';
  840. // Load the submenu.
  841. ContactHelper::addSubmenu(JRequest::getCmd(\'view\', \'${2:cpanel}\'));
  842. \$view = JRequest::getCmd(\'view\', \'${2:cpanel}\');
  843. \$layout = JRequest::getCmd(\'layout\', \'default\');
  844. \$id = JRequest::getInt(\'id\');
  845. parent::display();
  846. return \$this;
  847. }
  848. '
  849. end
  850. snippet t(:jmodeledit) do |s|
  851. s.trigger = 'jmodeledit'
  852. s.expansion = 'jimport(\'joomla.application.component.modeladmin\');
  853. /**
  854. * ${4:Hello} model.
  855. *
  856. * @package ${1:Hello}
  857. * @subpackage ${2:com_hello}
  858. * @since 2.5
  859. */
  860. class ${3:Hello}Model${4:Hello} extends JModelAdmin
  861. {
  862. /**
  863. * Returns a reference to the a Table object, always creating it.
  864. *
  865. * @param type The table type to instantiate
  866. * @param string A prefix for the table class name. Optional.
  867. * @param array Configuration array for model. Optional.
  868. * @return JTable A database object
  869. * @since 2.5
  870. */
  871. public function getTable(\$type = \'${4:Hello}\', \$prefix = \'${3:Hello}Table\', \$config = array())
  872. {
  873. return JTable::getInstance(\$type, \$prefix, \$config);
  874. }
  875. /**
  876. * Method to get the record form.
  877. *
  878. * @param array \$data Data for the form.
  879. * @param boolean \$loadData True if the form is to load its own data (default case), false if not.
  880. * @return mixed A JForm object on success, false on failure
  881. * @since 2.5
  882. */
  883. public function getForm(\$data = array(), \$loadData = true)
  884. {
  885. // Get the form.
  886. \$form = \$this->loadForm(\'${2:com_hello}.${5:hello}\', \'${5:hello}\', array(\'control\' => \'jform\', \'load_data\' => \$loadData));
  887. if (empty(\$form)) {
  888. return false;
  889. }
  890. return \$form;
  891. }
  892. /**
  893. * Method to get the data that should be injected in the form.
  894. *
  895. * @return mixed The data for the form.
  896. * @since 2.5
  897. */
  898. protected function loadFormData()
  899. {
  900. // Check the session for previously entered form data.
  901. \$data = JFactory::getApplication()->getUserState(\'${2:com_hello}.edit.${5:hello}.data\', array());
  902. if (empty(\$data)) {
  903. \$data = \$this->getItem();
  904. }
  905. return \$data;
  906. }
  907. }
  908. '
  909. end
  910. snippet t(:jmodellist) do |s|
  911. s.trigger = 'jmodellist'
  912. s.expansion = 'jimport(\'joomla.application.component.modellist\');
  913. /**
  914. * Methods supporting a list of contact records.
  915. *
  916. * @package ${1:Hello}
  917. * @subpackage ${2:com_hello}
  918. * @since 2.5
  919. */
  920. class ${3:Hello}Model${4:Hellos} extends JModelList
  921. {
  922. /**
  923. * Constructor.
  924. *
  925. * @param array An optional associative array of configuration settings.
  926. * @see JController
  927. * @since 2.5
  928. */
  929. public function __construct(\$config = array())
  930. {
  931. if (empty(\$config[\'filter_fields\'])) {
  932. \$config[\'filter_fields\'] = array(
  933. \'id\', \'a.id\',
  934. \'title\', \'a.title\',
  935. \'alias\', \'a.alias\',
  936. \'catid\', \'a.catid\', \'category_title\',
  937. \'published\', \'a.published\',
  938. \'created\', \'a.created\',
  939. \'created_by\', \'a.created_by\',
  940. \'ordering\', \'a.ordering\'
  941. );
  942. }
  943. parent::__construct(\$config);
  944. }
  945. /**
  946. * Method to auto-populate the model state.
  947. *
  948. * Note. Calling getState in this method will result in recursion.
  949. *
  950. * @return void
  951. * @since 2.5
  952. */
  953. protected function populateState(\$ordering = null, \$direction = null)
  954. {
  955. // Initialise variables.
  956. \$app = JFactory::getApplication();
  957. // Adjust the context to support modal layouts.
  958. if (\$layout = JRequest::getVar(\'layout\')) {
  959. \$this->context .= \'.\'.\$layout;
  960. }
  961. \$search = \$this->getUserStateFromRequest(\$this->context.\'.filter.search\', \'filter_search\');
  962. \$this->setState(\'filter.search\', \$search);
  963. \$published = \$this->getUserStateFromRequest(\$this->context.\'.filter.published\', \'filter_published\', \'\');
  964. \$this->setState(\'filter.published\', \$published);
  965. \$categoryId = \$this->getUserStateFromRequest(\$this->context.\'.filter.category_id\', \'filter_category_id\');
  966. \$this->setState(\'filter.category_id\', \$categoryId);
  967. // List state information.
  968. parent::populateState(\'a.title\', \'asc\');
  969. }
  970. /**
  971. * Method to get a store id based on model configuration state.\$
  972. *
  973. * This is necessary because the model is used by the component and
  974. * different modules that might need different sets of data or different
  975. * ordering requirements.
  976. *
  977. * @param string \$id A prefix for the store id.
  978. *
  979. * @return string A store id.
  980. * @since 2.5
  981. */
  982. protected function getStoreId(\$id = \'\')
  983. {
  984. // Compile the store id.
  985. \$id .= \':\'.\$this->getState(\'filter.search\');
  986. \$id .= \':\'.\$this->getState(\'filter.published\');
  987. \$id .= \':\'.\$this->getState(\'filter.category_id\');
  988. return parent::getStoreId(\$id);
  989. }
  990. /**
  991. * Build an SQL query to load the list data.
  992. *
  993. * @return JDatabaseQuery
  994. * @since 2.5
  995. */
  996. protected function getListQuery()
  997. {
  998. // Create a new query object.
  999. \$db = \$this->getDbo();
  1000. \$query = \$db->getQuery(true);
  1001. \$user = JFactory::getUser();
  1002. // Select the required fields from the table.
  1003. \$query->select(
  1004. \$this->getState(
  1005. \'list.select\',
  1006. \'a.id, a.catid, a.title, a.alias, a.description, a.checked_out, a.checked_out_time\' .
  1007. \', a.published, a.created, a.created_by, a.ordering\'.
  1008. \', a.publish_up, a.publish_down\'
  1009. )
  1010. );
  1011. \$query->from(\'#__${5:table_name} AS a\');
  1012. // Join over the users for the checked out user.
  1013. \$query->select(\'uc.name AS editor\');
  1014. \$query->join(\'LEFT\', \'#__users AS uc ON uc.id = a.checked_out\');
  1015. // Join over the categories.
  1016. \$query->select(\'c.title AS category_title\');
  1017. \$query->join(\'LEFT\', \'#__categories AS c ON c.id = a.catid\');
  1018. // Filter by published state
  1019. \$published = \$this->getState(\'filter.published\');
  1020. if (is_numeric(\$published)) {
  1021. \$query->where(\'a.published = \' . (int) \$published);
  1022. }
  1023. elseif (\$published === \'\') {
  1024. \$query->where(\'(a.published = 0 OR a.published = 1)\');
  1025. }
  1026. // Filter by a single or group of categories.
  1027. \$categoryId = \$this->getState(\'filter.category_id\');
  1028. if (is_numeric(\$categoryId)) {
  1029. \$query->where(\'a.catid = \'.(int) \$categoryId);
  1030. }
  1031. elseif (is_array(\$categoryId)) {
  1032. JArrayHelper::toInteger(\$categoryId);
  1033. \$categoryId = implode(\',\', \$categoryId);
  1034. \$query->where(\'a.catid IN (\'.\$categoryId.\')\');
  1035. }
  1036. // Filter by search in title.
  1037. \$search = \$this->getState(\'filter.search\');
  1038. if (!empty(\$search)) {
  1039. if (stripos(\$search, \'id:\') === 0) {
  1040. \$query->where(\'a.id = \'.(int) substr(\$search, 3));
  1041. }
  1042. else {
  1043. \$search = \$db->Quote(\'%\'.\$db->escape(\$search, true).\'%\');
  1044. \$query->where(\'(a.title LIKE \'.\$search.\' OR a.alias LIKE \'.\$search.\')\');
  1045. }
  1046. }
  1047. // Add the list ordering clause.
  1048. \$orderCol = \$this->state->get(\'list.ordering\', \'a.title\');
  1049. \$orderDirn = \$this->state->get(\'list.direction\', \'asc\');
  1050. if (\$orderCol == \'a.ordering\' || \$orderCol == \'category_title\') {
  1051. \$orderCol = \'c.title \'.\$orderDirn.\', a.ordering\';
  1052. }
  1053. \$query->order(\$db->escape(\$orderCol.\' \'.\$orderDirn));
  1054. //echo nl2br(str_replace(\'#__\',\'jos_\',\$query));
  1055. return \$query;
  1056. }
  1057. }
  1058. '
  1059. end
  1060. snippet t(:jmodule) do |s|
  1061. s.trigger = 'jmodule'
  1062. s.expansion = '// Include the syndicate functions only once
  1063. require_once dirname(__FILE__) . \'/helper.php\';
  1064. //\$list = mod${1:Hello}Helper::getList(\$params);
  1065. \$moduleclass_sfx = htmlspecialchars(\$params->get(\'moduleclass_sfx\'));
  1066. require JModuleHelper::getLayoutPath(\'${2:mod_hello}\', \$params->get(\'layout\', \'default\'));
  1067. '
  1068. end
  1069. snippet t(:jmodulehelper) do |s|
  1070. s.trigger = 'jmodulehelper'
  1071. s.expansion = '/**
  1072. * ${1:Hello} module helper.
  1073. *
  1074. * @package ${1:Hello}
  1075. * @subpackage ${2:mod_hello}
  1076. * @since 2.5
  1077. */
  1078. class Mod${1:Hello}Helper
  1079. {
  1080. /**
  1081. * Get a list of the ${3:hello} items.
  1082. *
  1083. * @param JRegistry \$params The module options.
  1084. *
  1085. * @return array
  1086. * @since 2.5
  1087. */
  1088. static function getList(&\$params)
  1089. {
  1090. // Initialiase variables.
  1091. \$db = JFactory::getDbo();
  1092. \$query = \$db->getQuery(true);
  1093. // Prepare query.
  1094. \$query->select(\'\');
  1095. \$query->from(\'#__\');
  1096. \$query->where(\'\');
  1097. // Inject the query and load the items.
  1098. \$db->setQuery(\$query);
  1099. \$items = \$db->loadObjectList();
  1100. // Check for errors.
  1101. if (\$error = \$db->getErrorMsg()) {
  1102. \$this->setError(\$error);
  1103. \$items = false;
  1104. return \$items;
  1105. }
  1106. return \$items;
  1107. }
  1108. }
  1109. '
  1110. end
  1111. snippet t(:jpreparedocument) do |s|
  1112. s.trigger = 'jpreparedocument'
  1113. s.expansion = '/**
  1114. * Prepares the document
  1115. */
  1116. protected function _prepareDocument()
  1117. {
  1118. \$app = JFactory::getApplication();
  1119. \$menus = \$app->getMenu();
  1120. \$pathway = \$app->getPathway();
  1121. \$title = null;
  1122. // Because the application sets a default page title,
  1123. // we need to get it from the menu item itself
  1124. \$menu = \$menus->getActive();
  1125. if (\$menu) {
  1126. \$this->params->def(\'page_heading\', \$this->params->get(\'page_title\', \$menu->title));
  1127. }
  1128. else {
  1129. \$this->params->def(\'page_heading\', JText::_(\'COM_${1:HELLO}_DEFAULT_PAGE_TITLE\'));
  1130. }
  1131. \$title = \$this->params->get(\'page_title\', \'\');
  1132. if (empty(\$title)) {
  1133. \$title = \$app->getCfg(\'sitename\');
  1134. }
  1135. elseif (\$app->getCfg(\'sitename_pagetitles\', 0) == 1) {
  1136. \$title = JText::sprintf(\'JPAGETITLE\', \$app->getCfg(\'sitename\'), \$title);
  1137. }
  1138. elseif (\$app->getCfg(\'sitename_pagetitles\', 0) == 2) {
  1139. \$title = JText::sprintf(\'JPAGETITLE\', \$title, \$app->getCfg(\'sitename\'));
  1140. }
  1141. if (empty(\$title)) {
  1142. \$title = \$this->item->name;
  1143. }
  1144. \$this->document->setTitle(\$title);
  1145. if (\$this->item->metadesc)
  1146. {
  1147. \$this->document->setDescription(\$this->item->metadesc);
  1148. }
  1149. elseif (!\$this->item->metadesc && \$this->params->get(\'menu-meta_description\'))
  1150. {
  1151. \$this->document->setDescription(\$this->params->get(\'menu-meta_description\'));
  1152. }
  1153. if (\$this->item->metakey)
  1154. {
  1155. \$this->document->setMetadata(\'keywords\', \$this->item->metakey);
  1156. }
  1157. elseif (!\$this->item->metakey && \$this->params->get(\'menu-meta_keywords\'))
  1158. {
  1159. \$this->document->setMetadata(\'keywords\', \$this->params->get(\'menu-meta_keywords\'));
  1160. }
  1161. if (\$this->params->get(\'robots\'))
  1162. {
  1163. \$this->document->setMetadata(\'robots\', \$this->params->get(\'robots\'));
  1164. }
  1165. }'
  1166. end
  1167. snippet t(:jsliders) do |s|
  1168. s.trigger = 'jsliders'
  1169. s.expansion = '<?php echo JHtml::_(\'sliders.start\', \'${1:hello}-sliders-\'.$this->item->id, array(\'useCookie\'=>1)); ?>
  1170. <?php echo JHtml::_(\'sliders.panel\', JText::_(\'${2:COM_HELLO_TITLE}\'), \'${3:class_name}\'); ?>
  1171. <?php echo JHtml::_(\'sliders.end\'); ?>'
  1172. end
  1173. snippet t(:jtable) do |s|
  1174. s.trigger = 'jtable'
  1175. s.expansion = 'jimport(\'joomla.application.component.model\');
  1176. /**
  1177. * ${4:Hello} table class.
  1178. *
  1179. * @package ${1:Hello}
  1180. * @subpackage ${2:com_hello}
  1181. * @since 2.5
  1182. */
  1183. class ${3:Hello}Table${4:Hello} extends JTable
  1184. {
  1185. /**
  1186. * Constructor
  1187. *
  1188. * @param object &\$db JDatabase connector object.
  1189. *
  1190. * @since 2.5
  1191. */
  1192. public function __construct(&\$db)
  1193. {
  1194. parent::__construct(\'#__${5:hellos}\', \'id\', \$db);
  1195. }
  1196. /**
  1197. * Method to bind an associative array or object to the JTable instance. This
  1198. * method only binds properties that are publicly accessible and optionally
  1199. * takes an array of properties to ignore when binding.
  1200. *
  1201. * @param array \$array Named array
  1202. * @param mixed \$ignore An optional array or space separated list of properties
  1203. * to ignore while binding. [optional]
  1204. *
  1205. * @return mixed Null if operation was satisfactory, otherwise returns an error string
  1206. *
  1207. * @since 2.5
  1208. */
  1209. public function bind(\$array, \$ignore = \'\')
  1210. {
  1211. if (isset(\$array[\'params\']) && is_array(\$array[\'params\']))
  1212. {
  1213. \$registry = new JRegistry;
  1214. \$registry->loadArray(\$array[\'params\']);
  1215. \$array[\'params\'] = (string) \$registry;
  1216. }
  1217. return parent::bind(\$array, \$ignore);
  1218. }
  1219. /**
  1220. * Method to perform sanity checks on the JTable instance properties to ensure
  1221. * they are safe to store in the database. Child classes should override this
  1222. * method to make sure the data they are storing in the database is safe and
  1223. * as expected before storage.
  1224. *
  1225. * @return boolean True if the instance is sane and able to be stored in the database.
  1226. *
  1227. * @since 2.5
  1228. */
  1229. public function check()
  1230. {
  1231. if (trim(\$this->alias) == \'\')
  1232. {
  1233. \$this->alias = \$this->title;
  1234. }
  1235. \$this->alias = JApplication::stringURLSafe(\$this->alias);
  1236. if (trim(str_replace(\'-\', \'\', \$this->alias)) == \'\')
  1237. {
  1238. \$this->alias = JFactory::getDate()->format(\'Y-m-d-H-i-s\');
  1239. }
  1240. return true;
  1241. }
  1242. /**
  1243. * Method to store a row in the database from the JTable instance properties.
  1244. * If a primary key value is set the row with that primary key value will be
  1245. * updated with the instance property values. If no primary key value is set
  1246. * a new row will be inserted into the database with the properties from the
  1247. * JTable instance.
  1248. *
  1249. * @param boolean \$updateNulls True to update fields even if they are null. [optional]
  1250. *
  1251. * @return boolean True on success.
  1252. *
  1253. * @since 2.5
  1254. */
  1255. public function store(\$updateNulls = false)
  1256. {
  1257. \$date = JFactory::getDate();
  1258. \$user = JFactory::getUser();
  1259. if (\$this->id)
  1260. {
  1261. // Existing item
  1262. \$this->modified = \$date->toMySQL();
  1263. \$this->modified_by = \$user->get(\'id\');
  1264. }
  1265. else
  1266. {
  1267. // New item. A filter\'s created field can be set by the user,
  1268. // so we don\'t touch it if it is set.
  1269. if (!intval(\$this->created))
  1270. {
  1271. \$this->created = \$date->toMySQL();
  1272. }
  1273. if (empty(\$this->created_by))
  1274. {
  1275. \$this->created_by = \$user->get(\'id\');
  1276. }
  1277. }
  1278. // Verify that the alias is unique
  1279. \$table = JTable::getInstance(\'${4:Hello}\', \'${3:Hello}Table\');
  1280. if (\$table->load(array(\'alias\' => \$this->alias)) && (\$table->id != \$this->id || \$this->id == 0))
  1281. {
  1282. \$this->setError(JText::_(\'JLIB_DATABASE_ERROR_ARTICLE_UNIQUE_ALIAS\'));
  1283. return false;
  1284. }
  1285. return parent::store(\$updateNulls);
  1286. }
  1287. }
  1288. '
  1289. end
  1290. snippet t(:jtext) do |s|
  1291. s.trigger = 'jtext'
  1292. s.expansion = '<?php echo JText::_(\'$1\'); ?>'
  1293. end
  1294. snippet t(:jtoken) do |s|
  1295. s.trigger = 'jtoken'
  1296. s.expansion = '<?php echo JHtml::_(\'form.token\'); ?>'
  1297. end
  1298. snippet t(:jview) do |s|
  1299. s.trigger = 'jview'
  1300. s.expansion = 'jimport(\'joomla.application.component.view\');
  1301. /**
  1302. * View class for a list of ${8:cpanel}.
  1303. *
  1304. * @package ${1:Hello}
  1305. * @subpackage ${2:com_hello}
  1306. * @since 2.5
  1307. */
  1308. class ${3:Hello}View${4:Cpanel} extends JView
  1309. {
  1310. /**
  1311. * Method to display the view.
  1312. *
  1313. * @param string \$tpl A template file to load. [optional]
  1314. *
  1315. * @return mixed A string if successful, otherwise a JError object.
  1316. *
  1317. * @since 1.6
  1318. */
  1319. public function display(\$tpl = null)
  1320. {
  1321. // Check for errors.
  1322. if (count(\$errors = \$this->get(\'Errors\')))
  1323. {
  1324. JError::raiseError(500, implode("\n", \$errors));
  1325. return false;
  1326. }
  1327. \$this->addToolbar();
  1328. // Include the component HTML helpers.
  1329. JHtml::addIncludePath(JPATH_COMPONENT . \'/helpers/html\');
  1330. parent::display(\$tpl);
  1331. }
  1332. /**
  1333. * Add the page title and toolbar.
  1334. *
  1335. * @return void
  1336. *
  1337. * @since 1.6
  1338. */
  1339. protected function addToolbar()
  1340. {
  1341. require_once JPATH_COMPONENT . \'/helpers/${5:hellos}.php\';
  1342. \$canDo = ${3:Hello}Helper::getActions();
  1343. JToolBarHelper::title(JText::_(\'COM_${6:HELLO}_${7:CPANEL}\'), \'${8:cpanel}.png\');
  1344. if (\$canDo->get(\'core.admin\'))
  1345. {
  1346. JToolBarHelper::preferences(\'${2:com_hello}\');
  1347. JToolBarHelper::divider();
  1348. }
  1349. JToolBarHelper::help(\'${8:cpanel}\', \$com = true);
  1350. }
  1351. }
  1352. '
  1353. end
  1354. snippet t(:jviewedit) do |s|
  1355. s.trigger = 'jviewedit'
  1356. s.expansion = 'jimport(\'joomla.application.component.view\');
  1357. /**
  1358. * View to edit a ${7:hellos}.
  1359. *
  1360. * @package ${1:Hello}
  1361. * @subpackage ${2:com_hello}
  1362. * @since 2.5
  1363. */
  1364. class ${3:Hello}View${4:Hello} extends JView
  1365. {
  1366. protected \$form;
  1367. protected \$item;
  1368. protected \$state;
  1369. /**
  1370. * Display the view
  1371. */
  1372. public function display(\$tpl = null)
  1373. {
  1374. // Initialiase variables.
  1375. \$this->form = \$this->get(\'Form\');
  1376. \$this->item = \$this->get(\'Item\');
  1377. \$this->state = \$this->get(\'State\');
  1378. // Check for errors.
  1379. if (count(\$errors = \$this->get(\'Errors\'))) {
  1380. JError::raiseError(500, implode("\n", \$errors));
  1381. return false;
  1382. }
  1383. \$this->addToolbar();
  1384. parent::display(\$tpl);
  1385. }
  1386. /**
  1387. * Add the page title and toolbar.
  1388. *
  1389. * @since 2.5
  1390. */
  1391. protected function addToolbar()
  1392. {
  1393. JRequest::setVar(\'hidemainmenu\', true);
  1394. \$user = JFactory::getUser();
  1395. \$userId = \$user->get(\'id\');
  1396. \$isNew = (\$this->item->id == 0);
  1397. \$checkedOut= !(\$this->item->checked_out == 0 || \$this->item->checked_out == \$userId);
  1398. // Since we don\'t track these assets a…

Large files files are truncated, but you can click here to view the full file