_open($file, $line); $this->render('close'); } function _open($file, $line=null, $options=array()) { if (!empty($line)) { $linekey=sprintf(Configure::read('Editor.linekey'),$line); } else { $linekey=''; } $command=sprintf('%s "%s" %s',Configure::read('Editor.path'),$file,$linekey); $this->log($command); $result=system($command); } function open_controller ($name, $action=null) { $name=Inflector::camelize($name); if (loadController($name)) { $cname=$name.'Controller'; $filepath=APP.'controllers'.DS.Inflector::underscore($cname).'.php'; $line=null; if (!empty($action)) { $file=& new File($filepath); if ($file->exists()) { $text=$file->read(); $textarr=split("\n",$text); foreach($textarr as $key => $str) { if (preg_match("/function\s+$action/i",$str)) { $line=$key+1; break; } } } } $this->_open($filepath,$line); } $this->render('close'); } function open_model ($name) { $name=Inflector::singularize(Inflector::camelize($name)); if (loadModel($name)) { $cname=$name; $filepath=APP.'models'.DS.Inflector::underscore($cname).'.php'; $file=& new File($filepath); if ($file->exists()) { $this->_open($filepath); } } $this->render('close'); } function open_view ($controller,$name) { $cname=Inflector::camelize($controller); if (loadController($cname)) { $filepath=APP.'views'.DS.$controller.DS.$name; $file=& new File($filepath.'.ctp'); if ($file->exists()) { $this->_open($filepath.'.ctp'); } else { $file=& new File($filepath.'.thtml'); if ($file->exists()) { $this->_open($filepath.'.thtml'); } } } $this->render('close'); } } ?>