PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/fuel/modules/fuel/models/Base_model_helpers.php

http://github.com/daylightstudio/FUEL-CMS
PHP | 1080 lines | 495 code | 145 blank | 440 comment | 33 complexity | d8d78dd827201e5d0588606212847a62 MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception
  1. <?php
  2. // ------------------------------------------------------------------------
  3. /**
  4. * Abstract base model helper class
  5. *
  6. * @package FUEL CMS
  7. * @subpackage Models
  8. * @category Models
  9. * @author David McReynolds @ Daylight Studio
  10. */
  11. abstract class Abstract_base_model_helper {
  12. protected $values = array();
  13. protected $parent_model = NULL;
  14. protected $record = NULL;
  15. protected $CI = NULL;
  16. protected $fuel = NULL;
  17. public function __construct($record = array(), $parent_model = NULL)
  18. {
  19. $this->CI =& get_instance();
  20. $this->fuel =& $this->CI->fuel;
  21. }
  22. // --------------------------------------------------------------------
  23. /**
  24. * Sets the parent model.
  25. *
  26. * @access public
  27. * @param object A reference to the parent model
  28. * @return object
  29. */
  30. public function set_parent_model($model)
  31. {
  32. $this->parent_model = $model;
  33. return $this;
  34. }
  35. // --------------------------------------------------------------------
  36. /**
  37. * Returns the parent model.
  38. *
  39. * @access public
  40. * @return object A reference to the parent models
  41. */
  42. public function get_parent_model()
  43. {
  44. return $this->parent_model;
  45. }
  46. // --------------------------------------------------------------------
  47. /**
  48. * Sets the values initially.
  49. *
  50. * @access public
  51. * @param array The values to set
  52. * @return object
  53. */
  54. public function set_values($values)
  55. {
  56. $this->values = $this->get_parent_model()->normalize_data($values);
  57. return $this;
  58. }
  59. /**
  60. * Appends to the values instead of overwrites all the values.
  61. *
  62. * @access public
  63. * @param array The values to set
  64. * @return object
  65. */
  66. public function append_values($values)
  67. {
  68. $values = array_merge($this->get_values(), $values);
  69. $this->set_values($values);
  70. return $this;
  71. }
  72. // --------------------------------------------------------------------
  73. /**
  74. * Returns the values.
  75. *
  76. * @access public
  77. * @return array
  78. */
  79. public function get_values()
  80. {
  81. return $this->values;
  82. }
  83. // --------------------------------------------------------------------
  84. /**
  85. * Returns the values.
  86. *
  87. * @access public
  88. * @param string A field name
  89. * @return mixed The value
  90. */
  91. public function get_value($key)
  92. {
  93. if (array_key_exists($key, $this->values))
  94. {
  95. return $this->values[$key];
  96. }
  97. return NULL;
  98. }
  99. // --------------------------------------------------------------------
  100. /**
  101. * Returns the record object.
  102. *
  103. * @access public
  104. * @return object
  105. */
  106. public function record()
  107. {
  108. if (!isset($this->record))
  109. {
  110. $key_field = $this->get_parent_model()->key_field();
  111. $id = $this->get_value($key_field);
  112. $this->record = (!empty($id)) ? $this->get_parent_model()->find_by_key($id) : FALSE;
  113. }
  114. return $this->record;
  115. }
  116. }
  117. // ------------------------------------------------------------------------
  118. /**
  119. * Base model fields class
  120. *
  121. * @package FUEL CMS
  122. * @subpackage Models
  123. * @category Models
  124. * @author David McReynolds @ Daylight Studio
  125. */
  126. class Base_model_fields extends Abstract_base_model_helper implements ArrayAccess, Countable, IteratorAggregate {
  127. protected $fields = array();
  128. public function __construct($fields = array(), $values = array(), $parent_model = NULL)
  129. {
  130. parent::__construct();
  131. $this->set_parent_model($parent_model);
  132. $this->set_fields($fields);
  133. $this->set_values($values);
  134. $this->initialize($this->get_fields(), $this->get_values(), $this->get_parent_model());
  135. }
  136. // --------------------------------------------------------------------
  137. /**
  138. * A placeholder for initialization of field data. This method will most likely be overwritten
  139. *
  140. * @access public
  141. * @return void
  142. */
  143. public function initialize($fields, $values, $parent_model)
  144. {
  145. // put in your own fields initialization code
  146. }
  147. // --------------------------------------------------------------------
  148. /**
  149. * Sets the fields initially.
  150. *
  151. * @access public
  152. * @param array The fields to set
  153. * @param boolean Determines whether or not to remove the order values set for the fields
  154. * @return object Instance of Base_model_fields
  155. */
  156. public function set_fields($fields, $remove_order = TRUE)
  157. {
  158. if ($fields instanceof Base_model_fields)
  159. {
  160. $fields = $fields->get_fields();
  161. }
  162. $this->fields = $fields;
  163. if ($remove_order)
  164. {
  165. foreach($this->fields as $key => $field)
  166. {
  167. if (array_key_exists('order', $this->fields[$key]))
  168. {
  169. unset($this->fields[$key]['order']);
  170. }
  171. }
  172. }
  173. return $this;
  174. }
  175. // --------------------------------------------------------------------
  176. /**
  177. * Returns the fields.
  178. *
  179. * @access public
  180. * @return array
  181. */
  182. public function get_fields()
  183. {
  184. return $this->fields;
  185. }
  186. /**
  187. * Returns the field parameters.
  188. *
  189. * @access public
  190. * @param string A field name
  191. * @return mixed The field
  192. */
  193. public function get_field($key)
  194. {
  195. if (array_key_exists($key, $this->fields))
  196. {
  197. return $this->fields[$key];
  198. }
  199. return NULL;
  200. }
  201. // --------------------------------------------------------------------
  202. /**
  203. * Sets a field's parameter value.
  204. *
  205. * @access public
  206. * @param string A field name
  207. * @param string The parameter of the field to set
  208. * @param mixed The value of the parameter to set
  209. * @return object Instance of Base_model_fields
  210. */
  211. public function set($field, $param, $value = NULL)
  212. {
  213. if (is_string($field) AND is_string($param))
  214. {
  215. $this->fields[$field][$param] = $value;
  216. }
  217. elseif(is_array($field))
  218. {
  219. foreach($field as $key => $val)
  220. {
  221. if (isset($value) AND is_int($key))
  222. {
  223. $this->set($val, $param, $value);
  224. }
  225. else
  226. {
  227. $this->set($key, $param, $val);
  228. }
  229. }
  230. }
  231. else
  232. {
  233. if ($value === TRUE AND isset($this->fields[$field]))
  234. {
  235. $this->fields[$field] = array_merge($this->fields[$field], $param);
  236. }
  237. else
  238. {
  239. $this->fields[$field] = $param;
  240. }
  241. }
  242. return $this;
  243. }
  244. // --------------------------------------------------------------------
  245. /**
  246. * Gets a field's parameter value.
  247. *
  248. * @access public
  249. * @param string A field name
  250. * @param string The parameter of the field to set
  251. * @return object Instance of Base_model_fields
  252. */
  253. public function get($field, $param = NULL)
  254. {
  255. if (array_key_exists($field, $this->fields))
  256. {
  257. if (!empty($param))
  258. {
  259. if (array_key_exists($param, $this->fields[$field]))
  260. {
  261. return $this->fields[$field][$param];
  262. }
  263. else
  264. {
  265. return NULL;
  266. }
  267. }
  268. else
  269. {
  270. return $this->fields[$field];
  271. }
  272. }
  273. else
  274. {
  275. return NULL;
  276. }
  277. }
  278. // --------------------------------------------------------------------
  279. /**
  280. * Removes fields
  281. *
  282. * @access public
  283. * @param array An array of fields to remove
  284. * @return object Instance of Base_model_fields
  285. */
  286. public function remove($fields)
  287. {
  288. if (is_string($fields))
  289. {
  290. $fields = preg_split('#\s*,\s*#', $fields);
  291. }
  292. $fields = (array) $fields;
  293. foreach($fields as $field)
  294. {
  295. if (isset($this->fields[$field]))
  296. {
  297. unset($this->fields[$field]);
  298. }
  299. }
  300. return $this;
  301. }
  302. // --------------------------------------------------------------------
  303. /**
  304. * Clears the fields and values.
  305. *
  306. * @access public
  307. * @return object Instance of Base_model_fields
  308. */
  309. public function clear()
  310. {
  311. $this->fields = array();
  312. $this->values = array();
  313. return $this;
  314. }
  315. // --------------------------------------------------------------------
  316. /**
  317. * Groups fields together to create a tab
  318. *
  319. * @access public
  320. * @param string The label of the tab
  321. * @param array The fields to put under the tab (optional)
  322. * @param array The order of the fields (optional)
  323. * @param string The name of additional class to append to the fieldset (tab container) (optional)
  324. * @return object Instance of Base_model_fields
  325. */
  326. public function tab($label, $fields = array(), $order_start = NULL, $other_class = '')
  327. {
  328. $other_class = (!empty($other_class)) ? ' '.$other_class : '';
  329. $this->fields[$label] = array('type' => 'fieldset', 'class' => 'tab'.$other_class);
  330. $i = 1;
  331. foreach($fields as $key => $field)
  332. {
  333. // if a string is passed in the array, then we'll assume it's the key to the field
  334. if (is_int($key))
  335. {
  336. $key = $field;
  337. $field = (isset($this->fields[$field])) ? $this->fields[$field] : NULL;
  338. }
  339. if (!empty($field))
  340. {
  341. // if the field already exists, then we unset it to give it a natural order
  342. if (isset($this->fields[$key]))
  343. {
  344. unset($this->fields[$key]);
  345. }
  346. if (!is_null($order_start))
  347. {
  348. $field['order'] = $order_start + $i;
  349. }
  350. $this->fields[$key] = $field;
  351. $i++;
  352. }
  353. }
  354. return $this;
  355. }
  356. // --------------------------------------------------------------------
  357. /**
  358. * Reorder the fields
  359. *
  360. * @access public
  361. * @param array The order of the fields
  362. * @return object Instance of Base_model_fields
  363. */
  364. public function reorder($order)
  365. {
  366. foreach($order as $key => $val)
  367. {
  368. $this->fields[$val]['order'] = $key + 1;
  369. }
  370. return $this;
  371. }
  372. // --------------------------------------------------------------------
  373. /**
  374. * Get an iterator for the items.
  375. *
  376. * @access public
  377. * @return ArrayIterator
  378. */
  379. public function getIterator()
  380. {
  381. return new ArrayIterator($this->fields);
  382. }
  383. // --------------------------------------------------------------------
  384. /**
  385. * Count the number of items in the collection.
  386. *
  387. * @access public
  388. * @return int
  389. */
  390. public function count()
  391. {
  392. return count($this->fields);
  393. }
  394. // --------------------------------------------------------------------
  395. /**
  396. * Determine if an item exists at an offset.
  397. *
  398. * @access public
  399. * @param mixed $key
  400. * @return bool
  401. */
  402. public function offsetExists($key)
  403. {
  404. return array_key_exists($key, $this->fields);
  405. }
  406. // --------------------------------------------------------------------
  407. /**
  408. * Get an item at a given offset.
  409. *
  410. * @access public
  411. * @param mixed $key
  412. * @return mixed
  413. */
  414. public function offsetGet($key)
  415. {
  416. $ref =& $this->fields[$key];
  417. return $ref;
  418. }
  419. // --------------------------------------------------------------------
  420. /**
  421. * Set the item at a given offset.
  422. *
  423. * @access public
  424. * @param mixed $key
  425. * @param mixed $value
  426. * @return void
  427. */
  428. public function offsetSet($key, $value)
  429. {
  430. if (is_null($key))
  431. {
  432. $this->fields[] = $value;
  433. }
  434. else
  435. {
  436. $this->fields[$key] = $value;
  437. }
  438. }
  439. // --------------------------------------------------------------------
  440. /**
  441. * Unset the item at a given offset.
  442. *
  443. * @access public
  444. * @param string $key
  445. * @return void
  446. */
  447. public function offsetUnset($key)
  448. {
  449. unset($this->fields[$key]);
  450. }
  451. // --------------------------------------------------------------------
  452. /**
  453. * Magic method that will allow for mass assignment of a parameter across multiple fields.
  454. *
  455. * @access public
  456. * @param string Method name
  457. * @param array The arguments to pass to the method
  458. * @return mixed
  459. */
  460. public function __call($method, $args)
  461. {
  462. if (preg_match( "/^set_(.*)/", $method, $found))
  463. {
  464. $arg1 = $args[0];
  465. $arg2 = $found[1];
  466. $arg3 = (isset($args[1])) ? $args[1] : NULL;
  467. $this->set($arg1, $arg2, $arg3);
  468. return $this;
  469. }
  470. else
  471. {
  472. throw new Exception("Invalid method call '$method' on Base_model_fields");
  473. }
  474. }
  475. }
  476. // ------------------------------------------------------------------------
  477. /**
  478. * Base model validation class
  479. *
  480. * @package FUEL CMS
  481. * @subpackage Models
  482. * @category Models
  483. * @author David McReynolds @ Daylight Studio
  484. */
  485. class Base_model_validation extends Abstract_base_model_helper {
  486. protected $validator = NULL;
  487. public function __construct($record = array(), $parent_model = NULL)
  488. {
  489. parent::__construct();
  490. $this->set_parent_model($parent_model);
  491. $this->set_values($record);
  492. $this->validator =& $parent_model->get_validation();
  493. $this->initialize($this->get_values(), $this->get_parent_model());
  494. }
  495. // --------------------------------------------------------------------
  496. /**
  497. * A placeholder for initialization of validation. This method will most likely be overwritten
  498. *
  499. * @access public
  500. * @return void
  501. */
  502. public function initialize($values, $parent_model)
  503. {
  504. }
  505. // --------------------------------------------------------------------
  506. /**
  507. * Sets the validator object initially.
  508. *
  509. * @access public
  510. * @param array The validator to set
  511. * @return object Instance of Base_model_validation
  512. */
  513. public function set_validator($validator)
  514. {
  515. $this->validator = $validator;
  516. return $this;
  517. }
  518. // --------------------------------------------------------------------
  519. /**
  520. * Returns the validator object.
  521. *
  522. * @access public
  523. * @return object
  524. */
  525. public function get_validator()
  526. {
  527. return $this->validator;
  528. }
  529. // --------------------------------------------------------------------
  530. /**
  531. * Adds an error to the parent models validator object
  532. *
  533. * @access public
  534. * @return object
  535. */
  536. public function add_error($msg, $key = NULL)
  537. {
  538. return $this->parent_model->add_error($msg, $key);
  539. }
  540. // --------------------------------------------------------------------
  541. /**
  542. * Add a validation rule
  543. *
  544. * @access public
  545. * @param string field name
  546. * @param mixed function name OR array($object_instance, $method)
  547. * @param string error message to display
  548. * @return object Instance of Base_model_validation
  549. */
  550. public function add($field, $rule, $msg = '', $params = array())
  551. {
  552. $value = $this->get_value($field);
  553. if (is_array($rule) AND empty($msg))
  554. {
  555. foreach($rule as $r => $msg)
  556. {
  557. $args = $this->extract_args($field, $r, $params);
  558. $this->get_validator()->add_rule($field, $this->normalize_rule_func($r), $msg, $args);
  559. }
  560. }
  561. else
  562. {
  563. $args = $this->extract_args($field, $rule, $params);
  564. $this->get_validator()->add_rule($field, $this->normalize_rule_func($rule), $msg, $args);
  565. }
  566. return $this;
  567. }
  568. // --------------------------------------------------------------------
  569. /**
  570. * Normalizes the the validation callback function
  571. *
  572. * @access public
  573. * @param string function name
  574. * @return mixed
  575. */
  576. protected function normalize_rule_func($rule)
  577. {
  578. if (method_exists($this, $rule))
  579. {
  580. return array($this, $rule);
  581. }
  582. if (is_array($rule))
  583. {
  584. $rule_parts = explode(':', $rule[1]);
  585. $rule[1] = current($rule_parts);
  586. }
  587. else
  588. {
  589. $rule_parts = explode(':', $rule);
  590. $rule = current($rule_parts);
  591. }
  592. return $rule;
  593. }
  594. // --------------------------------------------------------------------
  595. /**
  596. * Remove a validation rule from the validator object
  597. *
  598. * @access public
  599. * @param string function name
  600. * @return array
  601. */
  602. protected function extract_args($field, $rule, $params = array())
  603. {
  604. if (is_string($params))
  605. {
  606. $params = array($params);
  607. }
  608. if (is_array($rule) AND !empty($rule[1]))
  609. {
  610. $args = explode(':', $rule[1]);
  611. }
  612. else
  613. {
  614. $args = explode(':', $rule);
  615. }
  616. array_shift($args);
  617. $value = $this->get_value($field);
  618. $args = array_merge(array($value), $args, $params);
  619. return $args;
  620. }
  621. // --------------------------------------------------------------------
  622. /**
  623. * Remove a validation rule from the validator object
  624. *
  625. * @access public
  626. * @param string field name
  627. * @param string function name (optional)
  628. * @return array
  629. */
  630. public function remove($field, $rule = NULL)
  631. {
  632. $this->validator->remove_rule($field, $rule);
  633. return $this;
  634. }
  635. // --------------------------------------------------------------------
  636. /**
  637. * Run validation
  638. *
  639. * @access public
  640. * @return boolean
  641. */
  642. public function validate()
  643. {
  644. $values = $this->get_values();
  645. return $this->validator->validate(array_keys($values));
  646. }
  647. // --------------------------------------------------------------------
  648. /**
  649. * Magic method that will allow for mass assignment of a parameter across multiple fields.
  650. *
  651. * @access public
  652. * @param string Method name
  653. * @param array The arguments to pass to the method
  654. * @return mixed
  655. */
  656. public function __call($method, $args)
  657. {
  658. if (preg_match( "/^add_(.*)/", $method, $found))
  659. {
  660. $arg1 = $args[0];
  661. $arg2 = $found[1];
  662. $arg3 = (isset($args[1])) ? $args[1] : NULL;
  663. $this->add($arg1, $arg2, $arg3);
  664. return $this;
  665. }
  666. else
  667. {
  668. throw new Exception("Invalid method call '$method' on Base_model_validation");
  669. }
  670. }
  671. }
  672. // ------------------------------------------------------------------------
  673. /**
  674. * Base related items class
  675. *
  676. * @package FUEL CMS
  677. * @subpackage Models
  678. * @category Models
  679. * @author David McReynolds @ Daylight Studio
  680. */
  681. class Base_model_related_items extends Abstract_base_model_helper {
  682. protected $record = NULL;
  683. protected $vars = array();
  684. protected $output = '';
  685. protected $display_if_new = TRUE;
  686. public function __construct($record = array(), $parent_model = NULL)
  687. {
  688. parent::__construct();
  689. $this->set_parent_model($parent_model);
  690. $this->set_values($record);
  691. $this->output = '';
  692. $this->initialize($this->get_values(), $this->get_parent_model());
  693. }
  694. // --------------------------------------------------------------------
  695. /**
  696. * A placeholder for initialization of validation. This method will most likely be overwritten
  697. *
  698. * @access public
  699. * @return void
  700. */
  701. public function initialize($values, $parent_model)
  702. {
  703. }
  704. // --------------------------------------------------------------------
  705. /**
  706. * Returns the variables for the view.
  707. *
  708. * @access public
  709. * @param array An array of variables to pass to a view (optional)
  710. * @return array
  711. */
  712. public function vars($vars = array())
  713. {
  714. $vars['values'] = $this->get_values();
  715. $vars['rec'] = $this->record();
  716. $vars['model'] = $this->get_parent_model();
  717. $vars['CI'] =& $this->CI;
  718. $vars['fuel'] =& $this->fuel;
  719. $vars['class'] = get_class($this->get_parent_model());
  720. $vars['ref'] =& $this;
  721. return $vars;
  722. }
  723. // --------------------------------------------------------------------
  724. /**
  725. * Returns the view.
  726. *
  727. * @access public
  728. * @param string A view file. If inside an advanced module, use an array with the key being the module and the value being the view.
  729. * @param array An array of variables to pass to a view (optional)
  730. * @return string
  731. */
  732. public function view($view, $vars = array())
  733. {
  734. $module = 'app';
  735. if (is_array($view))
  736. {
  737. $module = key($view);
  738. $view = current($view);
  739. }
  740. $vars = $this->vars($vars);
  741. $this->output = $this->CI->load->module_view($module, $view, $vars, TRUE);
  742. return $this->output;
  743. }
  744. // --------------------------------------------------------------------
  745. /**
  746. * Returns the view.
  747. *
  748. * @access public
  749. * @return object Instance of Base_model_validation
  750. */
  751. public function set_output($output)
  752. {
  753. $this->output .= $output;
  754. return $this;
  755. }
  756. // --------------------------------------------------------------------
  757. /**
  758. * Returns the view.
  759. *
  760. * @access public
  761. * @return string
  762. */
  763. public function get_output()
  764. {
  765. return $this->output;
  766. }
  767. // --------------------------------------------------------------------
  768. /**
  769. * Renders the output
  770. *
  771. * @access public
  772. * @param string A view file. If inside an advanced module, use an array with the key being the module and the value being the view.
  773. * @param array An array of variables to pass to a view
  774. * @return string
  775. */
  776. public function render($view = '', $vars = array())
  777. {
  778. if (empty($this->display_if_new) AND !isset($vars['rec']->id))
  779. {
  780. return FALSE;
  781. }
  782. if (!empty($view))
  783. {
  784. $this->view($view, $vars);
  785. }
  786. return $this->output;
  787. }
  788. }
  789. // ------------------------------------------------------------------------
  790. /**
  791. * Base related items class
  792. *
  793. * @package FUEL CMS
  794. * @subpackage Models
  795. * @category Models
  796. * @author David McReynolds @ Daylight Studio
  797. */
  798. class Base_model_list_items extends Abstract_base_model_helper {
  799. public $limit = NULL;
  800. public $offset = 0;
  801. public $col = 'id';
  802. public $order = 'asc';
  803. protected $display_type = '';
  804. protected $filters = NULL;
  805. protected $select = NULL;
  806. protected $joins = NULL;
  807. protected $search_field = NULL;
  808. protected $filter_join = NULL;
  809. protected $fields = NULL;
  810. protected $db;
  811. public function __construct($parent_model = NULL)
  812. {
  813. parent::__construct();
  814. $this->set_parent_model($parent_model);
  815. $this->fields = new Base_model_fields(array(), $this->get_values(), $this->get_parent_model());
  816. $this->db =& $this->get_parent_model()->db();
  817. if (!empty($this->filters)) $this->get_parent_model()->filters = $this->filters;
  818. if (!empty($this->display_type)) $this->CI->advanced_search = $this->display_type;
  819. if (!empty($this->search_field)) $this->CI->search_field = $this->search_field;
  820. if (!empty($this->filter_join)) $this->get_parent_model()->filter_join = $this->filter_join;
  821. $this->initialize($this->get_parent_model());
  822. }
  823. // --------------------------------------------------------------------
  824. /**
  825. * A placeholder for initialization of validation. This method will most likely be overwritten
  826. *
  827. * @access public
  828. * @return void
  829. */
  830. public function initialize($parent_model)
  831. {
  832. }
  833. public function fields($values = array())
  834. {
  835. return array();
  836. }
  837. // --------------------------------------------------------------------
  838. /**
  839. * Adds a filter for searching
  840. *
  841. * @access public
  842. * @param string The name of the field to filter on
  843. * @param string A key to associate with the filter(optional)
  844. * @return void
  845. */
  846. public function add_filter($filter, $key = NULL)
  847. {
  848. $this->get_parent_model()->add_filter($filter, $key);
  849. }
  850. // --------------------------------------------------------------------
  851. /**
  852. * Adds multiple filters for searching
  853. *
  854. * @access public
  855. * @param array An array of fields to filter on
  856. * @return void
  857. */
  858. public function add_filters($filters)
  859. {
  860. $this->get_parent_model()->add_filter($filters);
  861. }
  862. // --------------------------------------------------------------------
  863. /**
  864. * Adds a filter join such as "and" or "or" to a particular field
  865. *
  866. * @access public
  867. * @param string The name of the field to filter on
  868. * @param string "and" or "or" (optional)
  869. * @return void
  870. */
  871. public function add_filter_join($field, $join_type = 'or')
  872. {
  873. $this->get_parent_model()->add_filter_join($field, $join_type);
  874. }
  875. // --------------------------------------------------------------------
  876. /**
  877. * Adds select values to the active record used for the list view
  878. *
  879. * @access public
  880. * @return void
  881. */
  882. public function select()
  883. {
  884. }
  885. // --------------------------------------------------------------------
  886. /**
  887. * Adds join values to the active record used for the list view
  888. *
  889. * @access public
  890. * @return void
  891. */
  892. public function join()
  893. {
  894. }
  895. // --------------------------------------------------------------------
  896. /**
  897. * Displays friendly text for what is being filtered on the list view
  898. *
  899. * @access public
  900. * @param array The values applied to the filters
  901. * @return string The friendly text string
  902. */
  903. public function friendly_info($values)
  904. {
  905. $this->set_values($values);
  906. }
  907. // --------------------------------------------------------------------
  908. /**
  909. * A method that can be used to do further manipulation on the data
  910. *
  911. * @access public
  912. * @param array The array of data
  913. * @param int The limit value for the list data (optional)
  914. * @param int The offset value for the list data (optional)
  915. * @param string The field name to order by (optional)
  916. * @param string The sorting order (optional)
  917. * @return array The data to return
  918. */
  919. public function process($data)
  920. {
  921. return $data;
  922. }
  923. // --------------------------------------------------------------------
  924. /**
  925. * Runs the select and join methods
  926. *
  927. * @access public
  928. * @return string
  929. */
  930. public function run()
  931. {
  932. $this->select();
  933. $this->join();
  934. }
  935. }