public function volume() { $id = $this->request->data['_id']; $conditions = array('_id' => $id); $fields = array('number', '_id'); $volumes = Volumes::find('first', array("fields" => $fields, "conditions" => $conditions, "order" => "number ASC")); $volume_id = $volumes['_id']; $volume_number = $volumes['number']; $url = CWMG_VOLUMES_PATH . "\\v" . str_pad($volume_number, 3, "0", STR_PAD_LEFT) . "-" . $this->roman($volume_number) . "\\TXT"; $count = Pages::count(array('volume_number' => $volume_number)); $numeric_vol = str_pad($volume_number, 3, '0', STR_PAD_LEFT); $roman_vol = $this->roman($volume_number); return compact('count', 'url', 'numeric_vol', 'roman_vol', 'volume_number'); }
public function volume() { if (!empty($this->request->params['args'][0])) { $filename = $this->request->params['args'][0]; $volume_id = strval(floatval(substr(substr($this->request->params['args'][0], 0, 4), 1, 3))); $Pagesconditions = array('volume_number' => $volume_id, 'filename' => $this->request->params['args'][0]); } else { $id = $this->request->data['_id']; $conditions = array('_id' => $id); $fields = array('number'); $volumes = Volumes::find('first', array("fields" => $fields, "conditions" => $conditions, "order" => "number ASC")); $volume_id = strval($volumes['number']); $Pagesconditions = array('volume_number' => $volume_id, 'updated' => 'Y'); } $pages = Pages::find('all', array('options' => array('fields' => array('_id', 'filename', 'description')), 'conditions' => $Pagesconditions, 'order' => array('sort_order' => 'ASC'), 'limit' => 1)); $numeric_vol = str_pad($volume_id, 3, '0', STR_PAD_LEFT); $roman_vol = $this->roman($volume_id); Pages::meta('key', '_id'); Pages::meta('title', 'filename'); $topage = Pages::find('list', array(array('fields' => array('_id', 'filename')), 'conditions' => array('volume_number' => $volume_id), 'order' => array('sort_order' => 'ASC'))); return compact("pages", "numeric_vol", "roman_vol", "topage"); }