当前位置: 首页>>代码示例>>PHP>>正文


PHP Redaxscript\Db类代码示例

本文整理汇总了PHP中Redaxscript\Db的典型用法代码示例。如果您正苦于以下问题:PHP Db类的具体用法?PHP Db怎么用?PHP Db使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Db类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * 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;
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:36,代码来源:LoginForm.php

示例2: _writeXML

 /**
  * @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);
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:36,代码来源:SitemapXml.php

示例3: render

 /**
  * 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();
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:14,代码来源:Title.php

示例4: _autorun

 /**
  * 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');
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:13,代码来源:Language.php

示例5: _database

 /**
  * database status
  *
  * @since 3.0.0
  *
  * @return string
  */
 protected function _database()
 {
     $status = Db::getStatus();
     $wordingArray = $this->_commandArray['status']['argumentArray']['database']['wordingArray'];
     if (array_key_exists($status, $wordingArray)) {
         return $wordingArray[$status] . PHP_EOL;
     }
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:15,代码来源:Status.php

示例6: render

 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @param integer $moduleId identifier of the module
  *
  * @return string
  */
 public function render($moduleId = null)
 {
     $output = Hook::trigger('adminModuleFormStart');
     $module = Db::forTablePrefix('modules')->whereIdIs($moduleId)->findOne();
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-admin-title-content']);
     $titleElement->text($module->name);
     $linkElement = new Html\Element();
     $linkElement->init('a');
     $itemElement = new Html\Element();
     $itemElement->init('li');
     $listElement = new Html\Element();
     $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']);
     $formElement = new AdminForm($this->_registry, $this->_language);
     $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($module->id ? 'admin/process/modules/' . $module->id : 'admin/process/modules'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('modulesEdit') && $this->_registry->get('modulesUninstall') ? $this->_registry->get('parameterRoute') . 'admin/view/modules' : $this->_registry->get('parameterRoute') . 'admin'], 'uninstall' => ['href' => $module->alias ? $this->_registry->get('parameterRoute') . 'admin/uninstall/modules/' . $module->alias . '/' . $this->_registry->get('token') : null]]]);
     /* docs directory */
     $docsDirectory = new Directory();
     $docsDirectory->init('modules/' . $module->alias . '/docs');
     $docsDirectoryArray = $docsDirectory->getArray();
     /* collect item output */
     $tabCounter = 1;
     $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute');
     $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-' . $tabCounter++)->text($this->_language->get('module')));
     /* process directory */
     foreach ($docsDirectoryArray as $value) {
         $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-' . $tabCounter++)->text(pathinfo($value, PATHINFO_FILENAME)));
     }
     /* collect item output */
     $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-' . $tabCounter++)->text($this->_language->get('customize')));
     $listElement->append($outputItem);
     /* create the form */
     $tabCounter = 1;
     $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-' . $tabCounter++ . '" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['autofocus' => 'autofocus', 'id' => 'name', 'name' => 'name', 'required' => 'required', 'value' => $module->name])->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' => $module->description])->append('</li></ul></fieldset>');
     /* second tab */
     if ($docsDirectoryArray) {
         /* process directory */
         foreach ($docsDirectoryArray as $value) {
             $formElement->append('<fieldset id="tab-' . $tabCounter++ . '" class="rs-admin-js-set-tab rs-admin-set-tab">')->append(Template\Tag::partial('modules/' . $module->alias . '/docs/' . $value))->append('</fieldset>');
         }
     }
     /* last tab */
     $formElement->append('<fieldset id="tab-' . $tabCounter++ . '" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getToggleArray(), ['id' => 'status', 'name' => 'status', 'value' => intval($module->status)])->append('</li>');
     if ($this->_registry->get('groupsEdit')) {
         $formElement->append('<li>')->label($this->_language->get('access'), ['for' => 'access'])->select(Helper\Option::getAccessArray('groups'), ['id' => 'access', 'name' => 'access[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getAccessArray('groups')), 'value' => $module->access])->append('</li>');
     }
     $formElement->append('</ul></fieldset></div>')->token()->cancel();
     if ($this->_registry->get('modulesUninstall')) {
         $formElement->uninstall();
     }
     if ($this->_registry->get('modulesEdit')) {
         $formElement->save();
     }
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('adminModuleFormEnd');
     return $output;
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:67,代码来源:ModuleForm.php

示例7: validate

 /**
  * validate the captcha
  *
  * @since 2.2.0
  *
  * @param string $raw plain answer
  * @param string $hash hashed solution
  *
  * @return integer
  */
 public function validate($raw = null, $hash = null)
 {
     $output = Validator::FAILED;
     /* validate raw again hash */
     if (sha1($raw) === $hash || Db::getSettings('captcha') == 0) {
         $output = Validator::PASSED;
     }
     return $output;
 }
开发者ID:ITw3,项目名称:redaxscript,代码行数:19,代码来源:Captcha.php

示例8: _set

 /**
  * set the setting
  *
  * @since 3.0.0
  *
  * @param array $optionArray
  *
  * @return boolean
  */
 protected function _set($optionArray = [])
 {
     $key = $this->prompt('key', $optionArray);
     $value = $this->prompt('value', $optionArray);
     if ($key && $value) {
         return Db::setSetting($key, $value);
     }
     return false;
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:18,代码来源:Setting.php

示例9: testInit

 /**
  * testInit
  *
  * @since 2.2.0
  */
 public function testInit()
 {
     /* setup */
     Db::init($this->_config);
     /* result */
     $result = Db::getDb();
     /* compare */
     $this->assertInstanceOf('PDO', $result);
 }
开发者ID:ITw3,项目名称:redaxscript,代码行数:14,代码来源:DbTest.php

示例10: render

 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @param integer $userId identifier of the user
  *
  * @return string
  */
 public function render($userId = null)
 {
     $output = Hook::trigger('adminUserFormStart');
     $user = Db::forTablePrefix('users')->whereIdIs($userId)->findOne();
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-admin-title-content']);
     $titleElement->text($user->name ? $user->name : $this->_language->get('user_new'));
     $linkElement = new Html\Element();
     $linkElement->init('a');
     $itemElement = new Html\Element();
     $itemElement->init('li');
     $listElement = new Html\Element();
     $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']);
     $formElement = new AdminForm($this->_registry, $this->_language);
     $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($user->id ? 'admin/process/users/' . $user->id : 'admin/process/users'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('usersEdit') && $this->_registry->get('usersDelete') ? $this->_registry->get('parameterRoute') . 'admin/view/users' : $this->_registry->get('parameterRoute') . 'admin'], 'delete' => ['href' => $user->id ? $this->_registry->get('parameterRoute') . 'admin/delete/users/' . $user->id . '/' . $this->_registry->get('token') : null]]]);
     /* collect item output */
     $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute');
     $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-1')->text($this->_language->get('user')));
     $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-2')->text($this->_language->get('general')));
     if (!$user->id || $user->id > 1) {
         $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-3')->text($this->_language->get('customize')));
     }
     $listElement->append($outputItem);
     /* create the form */
     $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-1" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['autofocus' => 'autofocus', 'id' => 'name', 'name' => 'name', 'required' => 'required', 'value' => $user->name])->append('</li>');
     if (!$user->id) {
         $formElement->append('<li>')->label($this->_language->get('user'), ['for' => 'user'])->text(['id' => 'user', 'name' => 'user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required', 'value' => $user->user])->append('</li>');
     }
     $formElement->append('<li>')->label($this->_language->get('password'), ['for' => 'password'])->password(['id' => 'password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'name' => 'password'])->append('</li><li>')->label($this->_language->get('password_confirm'), ['for' => 'password_confirm'])->password(['id' => 'password_confirm', 'pattern' => '[a-zA-Z0-9]{1,30}', 'name' => 'password_confirm'])->append('</li><li>')->label($this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'required' => 'required', 'value' => $user->email])->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' => $user->description])->append('</li></ul></fieldset>')->append('<fieldset id="tab-2" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('language'), ['for' => 'language'])->select(Helper\Option::getLanguageArray(), ['id' => 'language', 'name' => 'language', 'value' => $user->language])->append('</li></ul></fieldset>');
     /* last tab */
     if (!$user->id || $user->id > 1) {
         $formElement->append('<fieldset id="tab-3" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getToggleArray(), ['id' => 'status', 'name' => 'status', 'value' => $user->id ? intval($user->status) : 1])->append('</li>');
         if ($this->_registry->get('groupsEdit')) {
             $formElement->append('<li>')->label($this->_language->get('groups'), ['for' => 'groups'])->select(Helper\Option::getAccessArray('groups'), ['id' => 'groups', 'name' => 'groups[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getAccessArray('groups')), 'value' => $user->groups])->append('</li>');
         }
         $formElement->append('</ul></fieldset>');
     }
     $formElement->append('</div>')->token()->cancel();
     if ($user->id) {
         if (($this->_registry->get('usersDelete') || $this->_registry->get('myId') === $user->id) && $user->id > 1) {
             $formElement->delete();
         }
         if ($this->_registry->get('usersEdit') || $this->_registry->get('myId') === $user->id) {
             $formElement->save();
         }
     } else {
         if ($this->_registry->get('usersNew')) {
             $formElement->create();
         }
     }
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('adminUserFormEnd');
     return $output;
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:65,代码来源:UserForm.php

示例11: render

 /**
  * render
  *
  * @since 2.2.0
  *
  * @return string
  */
 public static function render()
 {
     $output = null;
     $outputItem = null;
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h3', array('class' => self::$_config['className']['title']));
     $linkElement = new Html\Element();
     $linkElement->init('a');
     $listElement = new Html\Element();
     $listElement->init('ul', array('class' => self::$_config['className']['list']));
     /* fetch articles */
     $articles = Db::forTablePrefix('articles')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('category')->findArray();
     /* process articles */
     if (!$articles) {
         $error = Language::get('article_no') . Language::get('point');
     } else {
         $accessValidator = new Validator\Access();
         $accessDeny = 0;
         $lastCategory = 0;
         foreach ($articles as $value) {
             if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) {
                 $currentCategory = $value['category'];
                 /* collect output */
                 if ($lastCategory != $currentCategory) {
                     if ($lastCategory > 0) {
                         $output .= $listElement->html($outputItem);
                         $outputItem = null;
                     }
                     $output .= $titleElement->text($currentCategory < 1 ? Language::get('uncategorized') : Db::forTablePrefix('categories')->whereIdIs($currentCategory)->findOne()->title);
                 }
                 /* collect item output */
                 $outputItem .= '<li>';
                 $outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']);
                 $outputItem .= '</li>';
                 /* collect list output */
                 if (end($articles) === $value) {
                     $output .= $listElement->html($outputItem);
                     $outputItem = null;
                 }
                 $lastCategory = $currentCategory;
             } else {
                 $accessDeny++;
             }
         }
         /* handle access */
         if (count($articles) === $accessDeny) {
             $error = Language::get('access_no') . Language::get('point');
         }
     }
     /* handle error */
     if ($error) {
         $output = $listElement->html('<li>' . $error . '</li>');
     }
     return $output;
 }
开发者ID:joergsteinhauer,项目名称:redaxscript,代码行数:63,代码来源:Sitemap.php

示例12: _autorun

 /**
  * 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);
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:15,代码来源:Template.php

示例13: validate

 /**
  * validate the captcha
  *
  * @since 2.2.0
  *
  * @param string $task plain task
  * @param string $hash hashed solution
  *
  * @return integer
  */
 public function validate($task = null, $hash = null)
 {
     $output = ValidatorInterface::FAILED;
     $captchaHash = new Hash(Config::getInstance());
     /* validate captcha */
     if ($task && $captchaHash->validate($task, $hash) || Db::getSettings('captcha') < 1) {
         $output = ValidatorInterface::PASSED;
     }
     return $output;
 }
开发者ID:amanpreetsinghmalhotra,项目名称:redaxscript,代码行数:20,代码来源:Captcha.php

示例14: _module

 /**
  * uninstall the module
  *
  * @since 3.0.0
  *
  * @param array $optionArray
  *
  * @return boolean
  */
 protected function _module($optionArray = [])
 {
     $alias = $this->prompt('alias', $optionArray);
     $moduleClass = 'Redaxscript\\Modules\\' . $alias . '\\' . $alias;
     if (class_exists($moduleClass)) {
         $module = new $moduleClass();
         $module->uninstall();
         return !Db::forTablePrefix('modules')->where('alias', $alias)->count();
     }
     return false;
 }
开发者ID:redaxmedia,项目名称:redaxscript,代码行数:20,代码来源:Uninstall.php

示例15: testUninstall

 /**
  * testUninstall
  *
  * @since 2.2.0
  */
 public function testUninstall()
 {
     /* setup */
     $module = new Module(array('alias' => 'test'));
     $module->uninstall();
     /* result */
     Db::clearCache();
     $result = Db::forPrefixTable('modules')->where('alias', 'test')->findOne();
     /* compare */
     $this->assertFalse(is_object($result));
 }
开发者ID:ITw3,项目名称:redaxscript,代码行数:16,代码来源:ModuleTest.php


注:本文中的Redaxscript\Db类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。