getSetting() public method

get the setting
Since: 3.0.0
public getSetting ( string $key = null ) : mixed
$key string key of the item
return mixed
Exemplo n.º 1
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('loginFormStart');
     $outputLegend = null;
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('login'));
     if (Db::getSetting('recovery')) {
         $linkElement = new Html\Element();
         $linkElement->init('a', ['href' => $this->_registry->get('parameterRoute') . 'login/recover']);
         $outputLegend = $linkElement->text($this->_language->get('recovery_question') . $this->_language->get('question_mark'));
     }
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-login'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]);
     /* create the form */
     $formElement->append('<fieldset>')->legend($outputLegend)->append('<ul><li>')->label('* ' . $this->_language->get('user'), ['for' => 'user'])->text(['autofocus' => 'autofocus', 'id' => 'user', 'name' => 'user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required'])->append('</li><li>')->label('* ' . $this->_language->get('password'), ['for' => 'password'])->password(['id' => 'password', 'name' => 'password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required'])->append('</li>');
     if (Db::getSetting('captcha') > 0) {
         $formElement->append('<li>')->captcha('task')->append('</li>');
     }
     $formElement->append('</ul></fieldset>');
     if (Db::getSetting('captcha') > 0) {
         $formElement->captcha('solution');
     }
     $formElement->token()->submit();
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('loginFormEnd');
     return $output;
 }
Exemplo n.º 2
0
 /**
  * @param object $categories
  * @param object $articles
  *
  * @return string
  */
 protected static function _writeXML($categories = null, $articles = null)
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     $writer->setIndent(true);
     $writer->setIndentString('	');
     $writer->startDocument('1.0', Db::getSetting('charset'));
     $writer->startElement('urlset');
     $writer->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     $writer->startElement('url');
     $writer->writeElement('loc', Registry::get('root'));
     $writer->endElement();
     /* process categories */
     foreach ($categories as $value) {
         $writer->startElement('url');
         $writer->writeElement('loc', Registry::get('root') . Registry::get('parameterRoute') . build_route('categories', $value->id));
         $writer->writeElement('lastmod', date('c', strtotime($value->date)));
         $writer->endElement();
     }
     /* process articles */
     foreach ($articles as $value) {
         $writer->startElement('url');
         $writer->writeElement('loc', Registry::get('root') . Registry::get('parameterRoute') . build_route('articles', $value->id));
         $writer->writeElement('lastmod', date('c', strtotime($value->date)));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     return $writer->outputMemory(true);
 }
Exemplo n.º 3
0
 /**
  * render the title
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $title = $this->_registry->get('metaTitle') ? $this->_registry->get('metaTitle') : Db::getSetting('title');
     $description = $this->_registry->get('metaDescription') ? $this->_registry->get('metaDescription') : Db::getSetting('description');
     $titleElement = new Html\Element();
     return $titleElement->init('title')->text($title . Db::getSetting('divider') . $description)->render();
 }
Exemplo n.º 4
0
 /**
  * automate run
  *
  * @since 2.1.0
  */
 protected function _autorun()
 {
     $dbStatus = $this->_registry->get('dbStatus');
     $lastTable = $this->_registry->get('lastTable');
     $lastId = $this->_registry->get('lastId');
     /* detect language */
     $this->_detect(['query' => $this->_request->getQuery('l'), 'session' => $this->_request->getSession('language'), 'contents' => $lastTable ? Db::forTablePrefix($lastTable)->where('id', $lastId)->findOne()->language : null, 'settings' => $dbStatus === 2 ? Db::getSetting('language') : null, 'browser' => substr($this->_request->getServer('HTTP_ACCEPT_LANGUAGE'), 0, 2), 'fallback' => 'en'], 'language', 'languages/' . $this->_filePlaceholder . '.json');
 }
Exemplo n.º 5
0
 /**
  * automate run
  *
  * @since 2.1.0
  */
 protected function _autorun()
 {
     $dbStatus = $this->_registry->get('dbStatus');
     $lastTable = $this->_registry->get('lastTable');
     $lastId = $this->_registry->get('lastId');
     $fileInstall = $this->_registry->get('file') === 'install.php';
     $partial = $fileInstall ? 'install.phtml' : 'index.phtml';
     /* detect template */
     $this->_detect(['query' => $this->_request->getQuery('t'), 'session' => $this->_request->getSession('template'), 'contents' => $lastTable ? Db::forTablePrefix($lastTable)->where('id', $lastId)->findOne()->template : null, 'settings' => $dbStatus === 2 ? Db::getSetting('template') : null, 'install' => $fileInstall ? 'install' : null, 'fallback' => 'default'], 'template', 'templates/' . $this->_filePlaceholder . '/' . $partial);
 }
Exemplo n.º 6
0
 /**
  * init the class
  *
  * @since 2.6.0
  *
  * @param array $optionArray options of the breadcrumb
  */
 public function init($optionArray = [])
 {
     if (is_array($optionArray)) {
         $this->_optionArray = array_merge($this->_optionArray, $optionArray);
     }
     if (!$this->_optionArray['divider']) {
         $this->_optionArray['divider'] = Db::getSetting('divider');
     }
     $this->_create();
 }
Exemplo n.º 7
0
 /**
  * list the settings
  *
  * @since 3.0.0
  *
  * @return string
  */
 protected function _list()
 {
     $output = null;
     $settings = Db::getSetting();
     /* process settings */
     foreach ($settings as $setting) {
         $output .= str_pad($setting->name, 30) . $setting->value . PHP_EOL;
     }
     return $output;
 }
Exemplo n.º 8
0
 /**
  * sanitize the html
  *
  * @since 2.4.0
  *
  * @param string $html target html
  * @param boolean $filter optional filter nodes
  *
  * @return string
  */
 public function sanitize($html = null, $filter = true)
 {
     $charset = Db::getSetting('charset');
     $html = mb_convert_encoding($html, 'html-entities', $charset);
     $doc = $this->_createDocument($html);
     $doc = $this->_cleanDocument($doc);
     /* filter nodes */
     if ($filter === true) {
         $doc = $this->_stripTags($doc);
         $doc = $this->_stripAttributes($doc);
         $doc = $this->_stripValues($doc);
     }
     /* collect output */
     $output = trim($doc->saveHTML());
     return $output;
 }
Exemplo n.º 9
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('adminSettingFormStart');
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-admin-title-content']);
     $titleElement->text($this->_language->get('settings'));
     $formElement = new AdminForm($this->_registry, $this->_language);
     $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . 'admin/update/settings', 'class' => 'rs-admin-js-accordion rs-admin-js-validate-form rs-admin-component-accordion rs-admin-form-default rs-admin-fn-clearfix'], 'button' => ['save' => ['name' => 'update']], 'link' => ['cancel' => ['href' => $this->_registry->get('parameterRoute') . 'admin']]]);
     /* create the form */
     $formElement->append('<fieldset class="rs-admin-js-set-accordion rs-admin-js-set-active rs-admin-set-accordion rs-admin-set-active">')->append('<legend class="rs-admin-js-title-accordion rs-admin-js-title-active rs-admin-title-accordion rs-admin-title-active">' . $this->_language->get('general') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-js-box-active rs-admin-box-accordion rs-admin-box-accordion rs-admin-box-active"><li>')->label($this->_language->get('language'), ['for' => 'language'])->select(Helper\Option::getLanguageArray(), ['id' => 'language', 'name' => 'language', 'value' => Db::getSetting('language')])->append('</li><li>')->label($this->_language->get('template'), ['for' => 'template'])->select(Helper\Option::getTemplateArray(), ['id' => 'template', 'name' => 'template', 'value' => Db::getSetting('template')])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('metadata') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('title'), ['for' => 'title'])->text(['id' => 'title', 'name' => 'title', 'value' => Db::getSetting('title')])->append('</li><li>')->label($this->_language->get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'value' => Db::getSetting('author')])->append('</li><li>')->label($this->_language->get('copyright'), ['for' => 'copyright'])->text(['id' => 'copyright', 'name' => 'copyright', 'value' => Db::getSetting('copyright')])->append('</li><li>')->label($this->_language->get('description'), ['for' => 'description'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'description', 'name' => 'description', 'rows' => 1, 'value' => Db::getSetting('description')])->append('</li><li>')->label($this->_language->get('keywords'), ['for' => 'keywords'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'keywords', 'name' => 'keywords', 'rows' => 1, 'value' => Db::getSetting('keywords')])->append('</li><li>')->label($this->_language->get('robots'), ['for' => 'robots'])->select(Helper\Option::getRobotArray(), ['id' => 'robots', 'name' => 'robots', 'value' => filter_var(Db::getSetting('robots'), FILTER_VALIDATE_INT)])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('contact') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'value' => Db::getSetting('email')])->append('</li><li>')->label($this->_language->get('subject'), ['for' => 'subject'])->text(['id' => 'subject', 'name' => 'subject', 'value' => Db::getSetting('subject')])->append('</li><li>')->label($this->_language->get('notification'), ['for' => 'notification'])->select(Helper\Option::getToggleArray(), ['id' => 'notification', 'name' => 'notification', 'value' => intval(Db::getSetting('notification'))])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('formatting') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('charset'), ['for' => 'charset'])->text(['id' => 'charset', 'name' => 'charset', 'value' => Db::getSetting('charset')])->append('</li><li>')->label($this->_language->get('divider'), ['for' => 'divider'])->text(['id' => 'divider', 'name' => 'divider', 'value' => Db::getSetting('divider')])->append('</li><li>')->label($this->_language->get('time'), ['for' => 'time'])->select(Helper\Option::getTimeArray(), ['id' => 'time', 'name' => 'time', 'value' => Db::getSetting('time')])->append('</li><li>')->label($this->_language->get('date'), ['for' => 'date'])->select(Helper\Option::getDateArray(), ['id' => 'date', 'name' => 'date', 'value' => Db::getSetting('date')])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('contents') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('homepage'), ['for' => 'homepage'])->select(Helper\Option::getContentArray('articles'), ['id' => 'homepage', 'name' => 'homepage', 'value' => Db::getSetting('homepage')])->append('</li><li>')->label($this->_language->get('limit'), ['for' => 'limit'])->number(['id' => 'limit', 'name' => 'limit', 'value' => Db::getSetting('limit')])->append('</li><li>')->label($this->_language->get('order'), ['for' => 'order'])->select(Helper\Option::getOrderArray(), ['id' => 'order', 'name' => 'order', 'value' => Db::getSetting('order')])->append('</li><li>')->label($this->_language->get('pagination'), ['for' => 'pagination'])->select(Helper\Option::getToggleArray(), ['id' => 'pagination', 'name' => 'pagination', 'value' => intval(Db::getSetting('pagination'))])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('users') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('registration'), ['for' => 'registration'])->select(Helper\Option::getToggleArray(), ['id' => 'registration', 'name' => 'registration', 'value' => intval(Db::getSetting('registration'))])->append('</li><li>')->label($this->_language->get('verification'), ['for' => 'verification'])->select(Helper\Option::getToggleArray(), ['id' => 'verification', 'name' => 'verification', 'value' => intval(Db::getSetting('verification'))])->append('</li><li>')->label($this->_language->get('recovery'), ['for' => 'recovery'])->select(Helper\Option::getToggleArray(), ['id' => 'recovery', 'name' => 'recovery', 'value' => intval(Db::getSetting('recovery'))])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('security') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('moderation'), ['for' => 'moderation'])->select(Helper\Option::getToggleArray(), ['id' => 'moderation', 'name' => 'moderation', 'value' => intval(Db::getSetting('moderation'))])->append('</li><li>')->label($this->_language->get('captcha'), ['for' => 'captcha'])->select(Helper\Option::getCaptchaArray(), ['id' => 'captcha', 'name' => 'captcha', 'value' => intval(Db::getSetting('captcha'))])->append('</li></ul></fieldset>')->token()->cancel()->save();
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('adminSettingFormEnd');
     return $output;
 }
Exemplo n.º 10
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @param array $resultArray array for the result
  *
  * @return string
  */
 public function render($resultArray = [])
 {
     $output = Hook::trigger('resultListStart');
     $accessValidator = new Validator\Access();
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-title-result']);
     $listElement = new Html\Element();
     $listElement->init('ol', ['class' => 'rs-list-result']);
     $itemElement = new Html\Element();
     $itemElement->init('li');
     $linkElement = new Html\Element();
     $linkElement->init('a', ['class' => 'rs-link-result']);
     $textElement = new Html\Element();
     $textElement->init('span', ['class' => 'rs-text-result-date']);
     /* process result */
     foreach ($resultArray as $table => $result) {
         $outputItem = null;
         if ($result) {
             /* collect item output */
             foreach ($result as $value) {
                 if ($accessValidator->validate($result->access, $this->_registry->get('myGroups')) === Validator\ValidatorInterface::PASSED) {
                     $textDate = date(Db::getSetting('date'), strtotime($value->date));
                     $linkElement->attr('href', $this->_registry->get('parameterRoute') . build_route($table, $value->id))->text($value->title ? $value->title : $value->author);
                     $textElement->text($textDate);
                     $outputItem .= $itemElement->html($linkElement . $textElement);
                 }
             }
             /* collect output */
             if ($outputItem) {
                 $titleElement->text($this->_language->get($table));
                 $listElement->html($outputItem);
                 $output .= $titleElement . $listElement;
             }
         }
     }
     $output .= Hook::trigger('resultListEnd');
     return $output;
 }
Exemplo n.º 11
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @param integer $articleId identifier of the article
  *
  * @return string
  */
 public function render($articleId = null)
 {
     $output = Hook::trigger('commentFormStart');
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('comment_new'));
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]);
     /* create the form */
     $formElement->append('<fieldset>')->legend()->append('<ul><li>')->label('* ' . $this->_language->get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'readonly' => $this->_registry->get('myName') ? 'readonly' : null, 'required' => 'required', 'value' => $this->_registry->get('myName')])->append('</li><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'readonly' => $this->_registry->get('myEmail') ? 'readonly' : null, 'required' => 'required', 'value' => $this->_registry->get('myEmail')])->append('</li><li>')->label($this->_language->get('url'), ['for' => 'url'])->url(['id' => 'url', 'name' => 'url'])->append('</li><li>')->label('* ' . $this->_language->get('text'), ['for' => 'text'])->textarea(['class' => 'rs-js-auto-resize rs-js-editor-textarea rs-field-textarea', 'id' => 'text', 'name' => 'text', 'required' => 'required'])->append('</li>');
     if (Db::getSetting('captcha') > 0) {
         $formElement->append('<li>')->captcha('task')->append('</li>');
     }
     $formElement->append('</ul></fieldset>');
     if (Db::getSetting('captcha') > 0) {
         $formElement->captcha('solution');
     }
     $formElement->hidden(['name' => 'article', 'value' => $articleId])->token()->submit()->reset();
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('commentFormEnd');
     return $output;
 }
Exemplo n.º 12
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('recoverFormStart');
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('recovery'));
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-recover'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]);
     /* create the form */
     $formElement->append('<fieldset>')->legend($this->_language->get('recovery_request') . $this->_language->get('point'))->append('<ul><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['autofocus' => 'autofocus', 'id' => 'email', 'name' => 'email', 'required' => 'required'])->append('</li>');
     if (Db::getSetting('captcha') > 0) {
         $formElement->append('<li>')->captcha('task')->append('</li>');
     }
     $formElement->append('</ul></fieldset>');
     if (Db::getSetting('captcha') > 0) {
         $formElement->captcha('solution');
     }
     $formElement->token()->submit();
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('recoverFormEnd');
     return $output;
 }
Exemplo n.º 13
0
 /**
  * send the mail
  *
  * @since 3.0.0
  *
  * @param array $mailArray
  *
  * @return boolean
  */
 protected function _mail($mailArray = [])
 {
     /* html elements */
     $linkElement = new Html\Element();
     $linkElement->init('a', ['href' => $this->_registry->get('root')])->text($this->_registry->get('root'));
     /* prepare mail */
     $toArray = [$mailArray['adminName'] => $mailArray['adminEmail']];
     $fromArray = [Db::getSetting('author') => Db::getSetting('email')];
     $subject = $this->_language->get('installation');
     $bodyArray = ['<strong>' . $this->_language->get('user') . $this->_language->get('colon') . '</strong> ' . $mailArray['adminUser'], '<br />', '<strong>' . $this->_language->get('password') . $this->_language->get('colon') . '</strong> ' . $mailArray['adminPassword'], '<br />', '<strong>' . $this->_language->get('url') . $this->_language->get('colon') . '</strong> ' . $linkElement];
     /* send mail */
     $mailer = new Mailer();
     $mailer->init($toArray, $fromArray, $subject, $bodyArray);
     return $mailer->send();
 }
Exemplo n.º 14
0
 /**
  * mail
  *
  * @since 3.0.0
  *
  * @param array $mailArray
  *
  * @return boolean
  */
 protected static function _mail($mailArray = [])
 {
     $toArray = [Db::getSetting('author') => Db::getSetting('email')];
     $fromArray = [$mailArray['author'] => $mailArray['email']];
     $subject = Language::get('contact');
     $bodyArray = [Language::get('author') . Language::get('colon') . ' ' . $mailArray['author'], '<br />', Language::get('email') . Language::get('colon') . ' <a href="mailto:' . $mailArray['email'] . '">' . $mailArray['email'] . '</a>', '<br />', Language::get('url') . Language::get('colon') . ' <a href="' . $mailArray['url'] . '">' . $mailArray['url'] . '</a>', '<br />', Language::get('message') . Language::get('colon') . ' ' . $mailArray['text']];
     /* send mail */
     $mailer = new Mailer();
     $mailer->init($toArray, $fromArray, $subject, $bodyArray);
     return $mailer->send();
 }
Exemplo n.º 15
0
 /**
  * send the mail
  *
  * @since 3.0.0
  *
  * @param array $mailArray
  *
  * @return boolean
  */
 protected function _mail($mailArray = [])
 {
     $urlLogin = $this->_registry->get('root') . '/' . $this->_registry->get('parameterRoute') . 'login';
     /* html elements */
     $linkElement = new Html\Element();
     $linkElement->init('a', ['href' => $urlLogin])->text($urlLogin);
     /* prepare mail */
     $toArray = [$mailArray['name'] => $mailArray['email'], Db::getSetting('author') => Db::getSetting('notification') ? Db::getSetting('email') : null];
     $fromArray = [$mailArray['name'] => $mailArray['email']];
     $subject = $this->_language->get('registration');
     $bodyArray = ['<strong>' . $this->_language->get('name') . $this->_language->get('colon') . '</strong> ' . $mailArray['name'], '<br />', '<strong>' . $this->_language->get('user') . $this->_language->get('colon') . '</strong> ' . $mailArray['user'], '<br />', '<strong>' . $this->_language->get('password') . $this->_language->get('colon') . '</strong> ' . $mailArray['password'], '<br />', '<strong>' . $this->_language->get('login') . $this->_language->get('colon') . '<strong> ' . $linkElement];
     /* send mail */
     $mailer = new Mailer();
     $mailer->init($toArray, $fromArray, $subject, $bodyArray);
     return $mailer->send();
 }
Exemplo n.º 16
0
 /**
  * testGetSettingInvalid
  *
  * @since 2.2.0
  */
 public function testGetSettingInvalid()
 {
     /* actual */
     $actual = Db::getSetting('invalidKey');
     /* compare */
     $this->assertFalse($actual);
 }
Exemplo n.º 17
0
 /**
  * validate
  *
  * @since 3.0.0
  *
  * @param array $postArray array of the post
  * @param object $user object of the user
  *
  * @return array
  */
 protected function _validate($postArray = [], $user = null)
 {
     $passwordValidator = new Validator\Password();
     $captchaValidator = new Validator\Captcha();
     /* validate post */
     $messageArray = [];
     if (!$postArray['user']) {
         $messageArray[] = $this->_language->get('user_empty');
     } else {
         if (!$user->id) {
             $messageArray[] = $this->_language->get('user_incorrect');
         }
     }
     if (!$postArray['password']) {
         $messageArray[] = $this->_language->get('password_empty');
     } else {
         if ($user->password && $passwordValidator->validate($postArray['password'], $user->password) === Validator\ValidatorInterface::FAILED) {
             $messageArray[] = $this->_language->get('password_incorrect');
         }
     }
     if (Db::getSetting('captcha') > 0 && $captchaValidator->validate($postArray['task'], $postArray['solution']) === Validator\ValidatorInterface::FAILED) {
         $messageArray[] = $this->_language->get('captcha_incorrect');
     }
     return $messageArray;
 }
Exemplo n.º 18
0
 /**
  * send the mail
  *
  * @since 3.0.0
  *
  * @param array $mailArray array of the mail
  *
  * @return boolean
  */
 protected function _mail($mailArray = [])
 {
     $urlArticle = $this->_registry->get('root') . '/' . $this->_registry->get('parameterRoute') . $mailArray['route'];
     /* html elements */
     $linkElement = new Html\Element();
     $linkElement->init('a');
     $linkEmail = $linkElement->copy();
     $linkEmail->attr(['href' => 'mailto:' . $mailArray['email']])->text($mailArray['email']);
     $linkUrl = $linkElement->copy();
     $linkUrl->attr(['href' => $mailArray['url']])->text($mailArray['url'] ? $mailArray['url'] : $this->_language->get('none'));
     $linkArticle = $linkElement->copy();
     $linkArticle->attr(['href' => $urlArticle])->text($urlArticle);
     /* prepare mail */
     $toArray = [$this->_language->get('author') => Db::getSetting('email')];
     $fromArray = [$mailArray['author'] => $mailArray['email']];
     $subject = $this->_language->get('comment_new');
     $bodyArray = ['<strong>' . $this->_language->get('author') . $this->_language->get('colon') . '</strong> ' . $mailArray['author'], '<br />', '<strong>' . $this->_language->get('email') . $this->_language->get('colon') . '</strong> ' . $linkEmail, '<br />', '<strong>' . $this->_language->get('url') . $this->_language->get('colon') . '</strong> ' . $linkUrl . '<br />', '<br />', '<strong>' . $this->_language->get('article') . $this->_language->get('colon') . '</strong> ' . $linkArticle, '<br />', '<strong>' . $this->_language->get('comment') . $this->_language->get('colon') . '</strong> ' . $mailArray['text']];
     /* send mail */
     $mailer = new Mailer();
     $mailer->init($toArray, $fromArray, $subject, $bodyArray);
     return $mailer->send();
 }
Exemplo n.º 19
0
 /**
  * getExifData
  *
  * @since 3.0.0
  *
  * @param string $file
  *
  * @return array
  */
 protected static function _getExifData($file = null)
 {
     $dataArray = [];
     $exifArray = function_exists('exif_read_data') ? exif_read_data($file) : [];
     /* handle data */
     if ($exifArray) {
         $dataArray['artist'] = $exifArray['Artist'];
         $dataArray['date'] = $exifArray['DateTime'] ? date(Db::getSetting('date'), strtotime($exifArray['DateTime'])) : null;
         $dataArray['description'] = $exifArray['ImageDescription'];
     }
     $dataArray = array_filter($dataArray);
     return $dataArray;
 }
Exemplo n.º 20
0
 /**
  * send the mail
  *
  * @since 3.0.0
  *
  * @param array $mailArray array of the mail
  *
  * @return boolean
  */
 protected function _mail($mailArray = [])
 {
     $urlReset = $this->_registry->get('root') . '/' . $this->_registry->get('parameterRoute') . 'login';
     /* html elements */
     $linkElement = new Element();
     $linkElement->init('a', ['href' => $urlReset, 'class' => 'link-result'])->text($urlReset);
     /* prepare mail */
     $toArray = [$mailArray['name'] => $mailArray['email']];
     $fromArray = [Db::getSetting('author') => Db::getSetting('email')];
     $subject = $this->_language->get('password_new');
     $bodyArray = ['<strong>' . $this->_language->get('password_new') . $this->_language->get('colon') . '</strong> ' . $mailArray['password'], '<br />', '<strong>' . $this->_language->get('login') . $this->_language->get('colon') . '</strong> ' . $linkElement];
     /* send mail */
     $mailer = new Mailer();
     $mailer->init($toArray, $fromArray, $subject, $bodyArray);
     return $mailer->send();
 }
Exemplo n.º 21
0
 /**
  * renderItem
  *
  * @param string $directory
  * @param array $optionArray
  *
  * @return string
  */
 protected static function _renderItem($directory = null, $optionArray = [])
 {
     $outputItem = null;
     /* html elements */
     $linkElement = new Html\Element();
     $linkElement->init('a', ['class' => self::$_configArray['className']['link']]);
     $textSizeElement = new Html\Element();
     $textSizeElement->init('span', ['class' => self::$_configArray['className']['textSize']]);
     $textDateElement = new Html\Element();
     $textDateElement->init('span', ['class' => self::$_configArray['className']['textDate']]);
     /* lister directory */
     $listerDirectory = new Directory();
     $listerDirectory->init($directory);
     $listerDirectoryArray = $listerDirectory->getArray();
     /* process directory */
     foreach ($listerDirectoryArray as $value) {
         $path = $directory . '/' . $value;
         $fileExtension = pathinfo($path, PATHINFO_EXTENSION);
         $text = self::_replace($value, $fileExtension, $optionArray['replace']);
         $textDate = date(Db::getSetting('date'), filectime($path));
         $isDir = is_dir($path);
         $isFile = is_file($path) && array_key_exists($fileExtension, self::$_configArray['extension']);
         /* handle directory */
         if ($isDir || $isFile) {
             $outputItem .= '<li>';
         }
         if ($isDir) {
             $outputItem .= $linkElement->copy()->attr(['href' => Registry::get('parameterRoute') . Registry::get('fullRoute') . '&directory=' . $path . $optionArray['hash'], 'title' => Language::get('directory', '_directory_lister')])->addClass(self::$_configArray['className']['types']['directory'])->text($text);
             $outputItem .= $textSizeElement->copy();
         } else {
             if ($isFile) {
                 $fileType = self::$_configArray['extension'][$fileExtension];
                 $textSize = ceil(filesize($path) / self::$_configArray['size']['divider']);
                 $outputItem .= $linkElement->copy()->attr(['href' => Registry::get('root') . '/' . $path, 'target' => '_blank', 'title' => Language::get('file', '_directory_lister')])->addClass(self::$_configArray['className']['types'][$fileType])->text($text);
                 $outputItem .= $textSizeElement->copy()->attr('data-unit', self::$_configArray['size']['unit'])->text($textSize);
             }
         }
         if ($isDir || $isFile) {
             $outputItem .= $textDateElement->copy()->text($textDate);
             $outputItem .= '</li>';
         }
     }
     return $outputItem;
 }
Exemplo n.º 22
0
 /**
  * setting
  *
  * @since 2.6.0
  *
  * @param string $key
  *
  * @return string
  */
 public static function setting($key = null)
 {
     return Db::getSetting($key);
 }
Exemplo n.º 23
0
 /**
  * get the keywords
  *
  * @since 3.0.0
  *
  * @return string
  */
 public static function getKeywords()
 {
     $lastTable = Registry::get('lastTable');
     $lastId = Registry::get('lastId');
     $metaKeywords = Registry::get('metaKeywords');
     /* find keywords */
     if ($metaKeywords) {
         $keywords = $metaKeywords;
     } else {
         if ($lastTable && $lastId) {
             $lastContent = Db::forTablePrefix($lastTable)->whereIdIs($lastId)->findOne();
             $keywords = $lastContent->keywords;
         }
     }
     /* handle keywords */
     if ($keywords) {
         return $keywords;
     }
     return Db::getSetting('keywords');
 }