Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug fix2

  • Loading branch information...
commit 8e3a8cb210590970ba0d84fa08fa64d564f887c7 1 parent ee32a34
@ounziw authored
Showing with 105 additions and 115 deletions.
  1. +105 −115 libraries/breadcrumb.php
View
220 libraries/breadcrumb.php
@@ -29,131 +29,121 @@
*/
class Breadcrumb
{
- var $addon;
- var $site_structure;
- var $page_info;
- var $bread;
- var $breaddata;
- var $page_data = array();
- var $addon_version = '1.0';
+ var $addon;
+ var $site_structure;
+ var $page_info;
+ var $bread;
+ var $breaddata;
+ var $page_data = array();
+ var $addon_version = '1.0';
- /**
- * __construct
- *
- * @access protected
- * @return void
- */
- function __construct()
- {
- $this->addon =& get_instance();
- $this->addon->load->helper(array('page', 'array'));
- $this->addon->load->model(array('page_model'));
- $this->site_structure = $this->addon->site_model->get_setting('site_structure');
- }
+ /**
+ * __construct
+ *
+ * @access protected
+ * @return void
+ */
+ function __construct()
+ {
+ $this->addon =& get_instance();
+ $this->addon->load->helper(array('page', 'array'));
+ $this->addon->load->model(array('page_model'));
+ $this->site_structure = $this->addon->site_model->get_setting('site_structure');
+ }
- /**
- * create
- *
- * @param array $template_data
- * @access public
- * @return void
- */
- function create($template_data = array())
- {
- $this->page_info = $this->addon->page_model->get_page_by_url_title($this->addon->mojomotor_parser->url_title);
- $this->create_path_array($this->page_info->id, $this->site_structure);
+ /**
+ * create
+ *
+ * @param array $template_data
+ * @access public
+ * @return void
+ */
+ function create($template_data = array())
+ {
+ $this->page_info = $this->addon->page_model->get_page_by_url_title($this->addon->mojomotor_parser->url_title);
+ $this->create_path_array($this->page_info->id, $this->site_structure);
- // Breadcrumb Separator
- if (isset($template_data['parameters']['sep']))
- {
- $this->bread['sep'] = htmlspecialchars($template_data['parameters']['sep'],ENT_QUOTES,"UTF-8");
- }
- else {
- $this->bread['sep'] = ' » ';
- }
-
- $this->bread['currentpage'] = $this->page_info->page_title;
+ // Breadcrumb Separator
+ if (isset($template_data['parameters']['sep']))
+ {
+ $this->bread['sep'] = htmlspecialchars($template_data['parameters']['sep'],ENT_QUOTES,"UTF-8");
+ }
+ else {
+ $this->bread['sep'] = ' » ';
+ }
- // Homepage Title & Link
- $this->bread['contents'][0] = array(
- "url" => base_url(),
- "title" => $this->addon->site_model->get_setting('site_name')
- );
- foreach($this->page_data as $val)
- {
- $page = $this->addon->page_model->get_page($val);
- array_push($this->bread['contents'], array(
- "url" => site_url('page/' . $page->url_title),
- "title" => $page->page_title
- ));
- }
- $orig_view_path = $this->addon->load->_ci_view_path;
- $this->addon->load->_ci_view_path = APPPATH.'third_party/breadcrumb/views/';
- $this->breaddata = $this->addon->load->view('breadlink', $this->bread, TRUE);
- $this->addon->load->_ci_view_path = $orig_view_path;
- return $this->breaddata;
-
-/*****
- $this->breaddata = '<a href="';
- $this->breaddata .= base_url();
- $this->breaddata .= '">';
- $this->breaddata .= $this->addon->site_model->get_setting('site_name');
- $this->breaddata .= '</a>';
+ $this->bread['currentpage'] = $this->page_info->page_title;
- $this->breaddata .= $sep;
- foreach($this->page_data as $val)
- {
- $page = $this->addon->page_model->get_page($val);
- $this->breaddata .= '<a href="';
- $this->breaddata .= site_url('page/' . $page->url_title) ;
- $this->breaddata .= '">';
- $this->breaddata .= $page->page_title;
- $this->breaddata .= '</a>';
- $this->breaddata .= $sep;
- }
- $this->breaddata .= $this->page_info->page_title ;
- return $this->breaddata;
-*****/
- }
+ // Homepage Title & Link
+ $this->bread['contents'][0] = array(
+ "url" => base_url(),
+ "title" => $this->addon->site_model->get_setting('site_name')
+ );
+ foreach($this->page_data as $val)
+ {
+ $page = $this->addon->page_model->get_page($val);
+ array_push($this->bread['contents'], array(
+ "url" => site_url('page/' . $page->url_title),
+ "title" => $page->page_title
+ ));
+ }
+ $orig_view_path = $this->addon->load->_ci_view_path;
+ $this->addon->load->_ci_view_path = APPPATH.'third_party/breadcrumb/views/';
+ $this->breaddata = $this->addon->load->view('breadlink', $this->bread, TRUE);
+ $this->addon->load->_ci_view_path = $orig_view_path;
+ return $this->breaddata;
+ }
- /**
- * create_path_array
- *
- * creates an array (KEY=depth, VALUE=page id), for example,
- * ([0] => 3, [1] => 6, [2] => 20)
- * will be stored in $this->page_data
- *
- * @param mixed $needle
- * @param array $haystack
- * @param int $depth
- * @param array $patharray
- * @access public
- * @return void
- */
- function create_path_array($needle, $haystack = array(), $depth = 0, $patharray = array())
- {
- foreach ($haystack as $key => $value)
- {
- if ($key == $needle)
- {
- if ($depth > 0)
- {
- $this->page_data = $patharray;
- }
- break;
- }
- if (is_array($value))
- {
- $patharray[$depth] = $key;
- $found = $this->create_path_array($needle, $haystack[$key], $depth+1, $patharray);
- }
- }
+ /**
+ * create_path_array
+ *
+ * creates an array (KEY=depth, VALUE=page id), for example,
+ * ([0] => 3, [1] => 6, [2] => 20)
+ * will be stored in $this->page_data
+ *
+ * @param mixed $needle
+ * @param array $haystack
+ * @param int $depth
+ * @param array $patharray
+ * @access public
+ * @return void
+ */
+ function create_path_array($needle, $haystack = array(), $depth = 0, $patharray = array())
+ {
- return FALSE;
- }
+ foreach ($haystack as $key => $value)
+ {
+ if ($key == $needle)
+ {
+ if ($depth > 0)
+ {
+ for ($i=0;$i<$depth;$i++)
+ {
+ $this->page_data[$i] = $patharray[$i];
+ }
+ }
+ break;
+ }
+ if (is_array($value))
+ {
+ $patharray[$depth] = $key;
+ $found = $this->create_path_array($needle, $haystack[$key], $depth+1, $patharray);
+ }
+ }
+ return FALSE;
+ }
+
+ function test()
+ {
+ $this->addon->load->library('unit_test');
+
+ $this->addon->unit->run($this->page_data,'is_array');
+ $this->addon->unit->run($this->bread['sep'],' &raquo; ');
+ echo $this->addon->unit->report();
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.