Ejemplo n.º 1
0
 /**
  * Load the template and send email, verifing if was successfull
  * @param array $params possible keys are
  * <ul>
  *  	<li><i>subject</i> email subject</li>
  *  	<li><i>message</i> email message</li>  
  *  	<li><i>info</i> additional information from message</li>
  * 		<li><i>email(optional)</i> email address to be sent</li>
  * 		<li><i>copy(optional)</i> email address for the hidden copy</li>
  *  	<li><i>tpl</i> template name to be load</li>
  *  </ul>
  * @return true false according to the sending
  */
 public function sendTemplate($params)
 {
     $infoText = '';
     $send = true;
     $tags = array('[subject]', '[message]');
     $content = array($params['subject'], nl2br($params['message']));
     $pathTpl = APPLICATION_PATH . '/utils/emails/' . $params['tpl'] . '.txt';
     $codeHTML = file_get_contents($pathTpl);
     if (isset($params['info'])) {
         foreach ($params['info'] as $title => $info) {
             $infoText .= '<div><span class="markText">' . $this->_lang->{$title} . '</span>: ' . $info . '</div>';
         }
         $tags[] = '[info]';
         $content[] = $infoText;
     }
     // Put subject and message
     $finalHTML = str_replace($tags, $content, $codeHTML);
     $header = 'MIME-Version: 1.0' . "\r\n";
     $header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
     $header .= 'From: ' . self::DEFAULT_EMAIL_FROM . "\r\n";
     if (isset($params['copy'])) {
         $header .= 'Bcc: ' . $params['copy'] . "\r\n";
     }
     $objUrls = new URLs();
     $serverName = $objUrls->getServer();
     if ($serverName != 'localhost') {
         $send = mail($params['email'], $params['subject'], $finalHTML, $header);
     }
     return $send ? true : false;
 }
Ejemplo n.º 2
0
 /**
  * returns the instance created by its first invoke.
  *
  * @return URLs
  */
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * @param string $arg current path
  * @return string whether the current li is active or not
  */
 protected function active($arg)
 {
     $active = true;
     $level = count(explode('/', URLs::getInstance()->root())) - 2;
     $regexp = '/' . str_replace('/', '\\/', URLs::getInstance()->root()) . '/';
     foreach (explode('/', preg_replace($regexp, '', $arg, 1)) as $module) {
         $active &= URLs::getInstance()->module($level) == $module;
         $level++;
     }
     return $active ? 'class="active"' : '';
 }
 protected function prefix($anchor)
 {
     $root = URLs::getInstance()->root();
     if ($anchor && URLs::getInstance()->isRoot()) {
         $prefix = '#';
     } else {
         if ($anchor || URLs::getInstance()->isRaw() && $anchor) {
             $prefix = $root . '#';
         } else {
             $prefix = $root;
         }
     }
     return $prefix;
 }
 protected function actionListener()
 {
     try {
         $module = URLs::getInstance()->module();
         $config = Config::getInstance()->hasPlugin($module) ? Config::getInstance()->getPlugin($module) : Config::getInstance()->getConfig();
         $this->model = new Container($config);
         $this->addModel($this->model, $config);
         $this->navigation = new $this->view($this->model, $config);
     } catch (ErrorException $e) {
         $this->model = new Container([]);
         // TODO
     } catch (Exception $e) {
         $this->model = new Container([]);
         // TODO
     }
 }
Ejemplo n.º 6
0
 private function __construct()
 {
     $this->config = Config::getInstance()->getGeneralArray('head');
     self::setTitle($this->config['title'] . ' - ' . URLs::getInstance()->module());
     // default meta tags
     self::addMeta('description', $this->config['description']);
     if (isset($this->config['meta'])) {
         foreach ($this->config['meta'] as $k => $v) {
             self::addMeta($k, $v);
         }
     }
     // default og tags
     $title = $this->config['title'] . ' - ' . URLs::getInstance()->module();
     self::addOg('title', $title);
     self::addOg('description', $this->config['description']);
     self::addOg('url', 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     self::addOg('image', $this->config['image']);
     self::addOg('type', 'website');
 }
 protected function actionListener()
 {
     try {
         $this->root = Config::getInstance()->getGeneral('general', 'app_root');
         $module = URLs::getInstance()->module();
         if (Config::getInstance()->hasPlugin($module)) {
             // if the module part of the URI may be a plugin
             $config = Config::getInstance()->getPlugin($module);
             $this->root .= $module . '/';
         } else {
             $config = Config::getInstance()->getConfig();
         }
         $this->model = new Container($config);
         foreach ($config as $key => $value) {
             $this->model->addModel(parent::evaluateModel($value), $key);
         }
     } catch (ErrorException $e) {
         $this->model = new Container(array());
         // TODO
     } catch (Exception $e) {
         $this->model = new Container(array());
         // TODO
     }
 }
Ejemplo n.º 8
0
 protected function resolveURL($config, $level)
 {
     if ($value = URLs::getInstance()->level($level)) {
         // if a dropdown is present
         if (array_key_exists($value, $config)) {
             $config = self::resolveURL($config[$value], $level + 1);
         } else {
             if (array_key_exists('path', $config)) {
                 // if URL points to static link
                 $config['path'] = $config['path'] . $value . $config['type']::MIME;
             } else {
                 throw new Exception('The requested URL is not available.');
             }
         }
     }
     return $config;
 }
Ejemplo n.º 9
0
 protected function pager($count, $limit)
 {
     $pager = '';
     if (!is_null($limit)) {
         $prev = isset($_GET['page']) ? $_GET['page'] - 1 : 0;
         $next = isset($_GET['page']) ? $_GET['page'] + 1 : 2;
         $self = URLs::getInstance()->getURI() . '?' . QueryString::remove('page', $_SERVER['QUERY_STRING']) . '&page=';
         $self = Config::getInstance()->app_root . $self;
         if ($prev > 0) {
             $pager = '<li class="previous"><a href="' . $self . $prev . '">&larr; Newer</a></li>';
         }
         if ($next <= ceil($count / $limit)) {
             $pager .= '<li class="next"><a href="' . $self . $next . '">Older &rarr;</a></li>';
         }
         $pager = '<ul class="pager">' . $pager . '</ul>';
         $pager = '<div class="row"><div class="col-md-12">' . $pager . '</div></div>';
     }
     return $pager;
 }
Ejemplo n.º 10
0
$config = Config::getInstance()->getGeneralArray('general');
if (isset($config['highlight']) && $config['highlight']) {
    $style = isset($config['scheme']) ? $config['scheme'] : 'default.css';
    Head::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/css/' . $style);
    Script::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/js/prism.js');
}
if (array_key_exists('img_resize', $config) && $config['img_resize']) {
    Script::getInstance()->link('image.js');
}
Head::getInstance()->link(PUBLIC_LIB_DIR . 'bootstrap/css/bootstrap.min.css');
Head::getInstance()->link(PUBLIC_LIB_DIR . 'font-awesome/css/font-awesome.min.css');
// Add jquery and bootstrap into header so included HTML pages can use the libs
Head::getInstance()->linkScript(PUBLIC_LIB_DIR . 'jquery/js/jquery.min.js');
Head::getInstance()->linkScript(PUBLIC_LIB_DIR . 'bootstrap/js/bootstrap.min.js');
// Onepager or not
if (URLs::getInstance()->isPlugin()) {
    // plugin
    $layout = Config::getInstance()->getGeneral('general', 'plugin_layout');
} else {
    $layout = Config::getInstance()->getGeneral('general', 'page_layout');
}
switch ($layout) {
    case "floating":
        $container = new FloatingController();
        $navigation = new NavigationController("FloatingNavigationView");
        break;
    case "stacked":
    default:
        $container = new StackedController();
        $navigation = new NavigationController("StackedNavigationView");
}
Ejemplo n.º 11
0
 * You should have received a copy of the GNU General Public License
 * along with the project. if not, write to the Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
include_once '../src/config.php';
include_once LIB_DIR . 'Autoload.php';
include_once LIB_DIR . 'ScanDir.php';
ini_set('display_errors', 1);
$src = Autoload::getInstance(SRC_DIR, false)->getClasses();
$lib = Autoload::getInstance(LIB_DIR, false)->getClasses();
$classes = array_merge($src, $lib);
set_error_handler("error_handler", E_ALL);
/**
 * Parse REQUEST_URI to enable pretty URLS
 */
URLs::getInstance()->parseURI();
/**
 * setup page and load provided business-casual.php
 */
$config = Config::getInstance()->getGeneralArray('general');
if (isset($config['highlight']) && $config['highlight']) {
    $style = isset($config['scheme']) ? $config['scheme'] : 'default.css';
    Head::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/css/' . $style);
    Script::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/js/prism.js');
}
if (array_key_exists('img_resize', $config) && $config['img_resize']) {
    Script::getInstance()->link('image.js');
}
Head::getInstance()->link(PUBLIC_LIB_DIR . 'bootstrap/css/bootstrap.min.css');
Head::getInstance()->link(PUBLIC_LIB_DIR . 'font-awesome/css/font-awesome.min.css');
// Add jquery and bootstrap into header so included HTML pages can use the libs
Ejemplo n.º 12
0
 protected function pager($model)
 {
     $pager = '';
     if (!array_key_exists('paging', $model->config) || $model->config['paging']) {
         if (!is_null($model->limit)) {
             $prev = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] - 1 : 0;
             $next = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] + 1 : 2;
             $self = URLs::getInstance()->getURI() . '?' . QueryString::remove('page', $_SERVER['QUERY_STRING']) . '&page=';
             $self = Config::getInstance()->app_root . $self;
             if ($prev > 0) {
                 $pager = '<li class="previous"><a href="' . $self . $prev . '"><i class="fa fa-chevron-left"></i> Newer</a></li>';
             }
             if ($next <= ceil($model->count / $model->limit)) {
                 $pager .= '<li class="next"><a href="' . $self . $next . '">Older <i class="fa fa-chevron-right"></i></a></li>';
             }
             $pager = '<ul class="pager">' . $pager . '</ul>';
             $pager = '<div class="row"><div class="col-md-12">' . $pager . '</div></div>';
         }
     }
     return $pager;
 }
Ejemplo n.º 13
0
 protected function raw($view)
 {
     $raw = URLs::getInstance()->getURI();
     if (URLs::getInstance()->isRaw() && is_file($raw)) {
         switch (pathinfo($raw, PATHINFO_EXTENSION)) {
             case 'html':
                 $config = ['key' => 'raw', 'name' => 'raw', 'path' => $raw, 'subtitle' => false];
                 $model = new HyperTextMarkup($config);
                 break;
             case 'php':
                 $config = ['key' => 'raw', 'name' => 'raw', 'path' => $raw, 'subtitle' => false];
                 $model = new HypertextPreprocessor($config);
                 break;
             default:
                 throw new Exception('The requested URL is not available.');
         }
         $this->view = new $view($model, $config);
     } else {
         throw new Exception('The requested URL is not available.');
     }
 }