Rev 15378 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppModel', 'Model');/*** Store Model** @property Order $Order* @property StoreProduct $StoreProduct*/class Store extends AppModel {/*** Display field** @var string*/public $displayField = 'name';/*** Validation rules** @var array*/public $validate = array('name' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',//'allowEmpty' => false,//'required' => false,//'last' => false, // Stop validation after this rule//'on' => 'create', // Limit validation to 'create' or 'update' operations),),'domain' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',//'allowEmpty' => false,//'required' => false,//'last' => false, // Stop validation after this rule//'on' => 'create', // Limit validation to 'create' or 'update' operations),),'affiliate_id' => array('notEmpty' => array('rule' => array('notEmpty'),//'message' => 'Your custom message here',//'allowEmpty' => false,//'required' => false,//'last' => false, // Stop validation after this rule//'on' => 'create', // Limit validation to 'create' or 'update' operations),),);//The Associations below have been created with all possible keys, those that are not needed can be removed/*** hasMany associations** @var array*//*public $hasMany = array('Order' => array('className' => 'Order','foreignKey' => 'store_id','dependent' => false,'conditions' => '','fields' => '','order' => '','limit' => '','offset' => '','exclusive' => '','finderQuery' => '','counterQuery' => ''),'StoreProduct' => array('className' => 'StoreProduct','foreignKey' => 'store_id','dependent' => false,'conditions' => '','fields' => '','order' => '','limit' => '','offset' => '','exclusive' => '','finderQuery' => '','counterQuery' => ''));*/public function getByUrl($url) {$domain = $this->get_domain($url);$this->recursive = -1;return $this->findByDomain($domain);}private function get_domain($url) {$pieces = parse_url($url);$domain = isset($pieces['host']) ? $pieces['host'] : '';if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {return $regs['domain'];}return false;}}