public function initialize() { $this->_controller = 'Index'; $this->_action = 'index'; $this->_params = array(); $config = Model3_Registry::get('config'); $configData = $config->getArray(); $this->_multilang = $configData['m3_internationalization']['inter_multilang']; $this->_lang = $configData['m3_internationalization']['inter_default_lang']; }
/** * Autentifica al usuario en el sistema por medio de su username y password * @param string $user El username del usuario * @param string $pass El password del usuario * @return bool|Regresa true si los datos del usuario son validos en la BD, en caso de fallar regresa false */ public function authenticate($user, $pass) { $dbs = Model3_Registry::getInstance()->get('databases'); $em = $dbs[$this->_config['cnx']]; /* @var $em Doctrine\ORM\EntityManager */ $user = $em->getRepository($this->_config['table'])->findOneBy(array($this->_config['user'] => $user)); if ($user) { $method = 'get' . ucwords($this->_config['pass']); if ($user->{$method}() == $pass) { $_SESSION['__M3']['Credentials'] = $user->getData(); return true; } return false; } }
public function selectCatalogTypes($entity, $options = array(), $selected = '') { $dbs = Model3_Registry::getInstance()->get('databases'); $em = $dbs['DefaultDb']; $list = $em->getRepository('DefaultDb_Entity_' . $entity)->findAll(); $strOptions = ''; foreach ($options as $key => $option) { $strOptions .= $key . '="' . $option . '" '; } $html = '<select ' . $strOptions . '>'; $html .= '<option value="">Seleccione</option>'; $param = ''; foreach ($list as $row) { if ($selected == $row->getId()) { $param = 'selected="selected"'; } $html .= '<option value="' . $row->getId() . '" ' . $param . '>' . $row->getName() . '</option>'; $param = ''; } $html .= '</select>'; return $html; }
public function url($options = null, $propague = false) { $reset = false; $strlenController = 0; $strlenAction = 0; if ($options == null) { $options = array(); } $url = $this->_baseUrl . '/'; $config = Model3_Registry::get('config'); $configData = $config->getArray(); if ($configData['m3_internationalization']['inter_multilang'] == true) { if (array_key_exists('lang', $options)) { $url .= $options['lang']; $url .= '/'; } else { $url .= $this->_request->getLang(); $url .= '/'; } } if (array_key_exists('component', $options)) { if ($options['component'] != null) { $url .= $options['component']; $url .= '/'; $reset = true; } unset($options['component']); } else { if ($this->_request->isComponent()) { $url .= $this->_request->geComponent(); $url .= '/'; } } if (array_key_exists('module', $options)) { if ($options['module'] != null) { $url .= $options['module']; $url .= '/'; $reset = true; } unset($options['module']); } else { if ($this->_request->isModule()) { $url .= $this->_request->getModule(); $url .= '/'; } } if (array_key_exists('controller', $options)) { if ($options['controller'] != null) { $url .= $options['controller']; if ($options['controller'] == 'Index') { $strlenController = strlen($url); } $reset = true; } unset($options['controller']); } else { if (!$reset) { $url .= $this->_request->getController(); } else { $url .= 'Index'; $strlenController = strlen($url); } } $url .= '/'; if (array_key_exists('action', $options)) { if ($options['action'] != null) { $url .= $options['action']; if ($options['action'] == 'index') { $strlenController = strlen($url); } } unset($options['action']); } else { if (!$reset) { $url .= $this->_request->getAction(); } else { $url .= 'index'; $strlenAction = strlen($url); } } $url .= '/'; if ($propague == true) { $params = $this->_request->getParams(); foreach ($params as $key => $param) { if (array_key_exists($key, $options)) { if ($options[$key] != null) { $url .= $key . '/'; $url .= $options[$key]; $url .= '/'; } unset($options[$key]); } else { $url .= $key . '/'; $url .= $param; $url .= '/'; } } } foreach ($options as $key => $option) { $url .= $key . '/' . $option . '/'; } /** * Limpiaremos la url en caso de que termine en index/ o en Index/index/ */ if ($strlenAction != 0 && $strlenAction + 1 == strlen($url)) { if ($strlenController != 0 && $strlenController + 1 == strlen($url)) { $url = substr($url, 0, $strlenController - 5); } else { $url = substr($url, 0, $strlenAction - 5); } } return $url; }
/** * Libera la instancia */ public static function _unsetInstance() { self::$_registry = null; }
/** * * @param string $dbName * @return Doctrine\ORM\EntityManager */ public function getEntityManager($dbName) { $em = false; $dbs = Model3_Registry::getInstance()->get('databases'); if (array_key_exists($dbName, $dbs) == true) { $em = $dbs[$dbName]; } return $em; }
public static function baseUrl() { $registry = Model3_Registry::getInstance(); $config = $registry->get('config'); $carray = $config->getArray(); return $carray['general']['url']; }