Esempio n. 1
0
 /**
  * @param string $key
  * @throws Exception
  */
 static function save_md_data($key)
 {
     if (!isset(self::$_action_list[$key])) {
         self::_error_and_redirect('不存在此页', '/');
     }
     $actions = self::$_action_list[$key];
     $content = Lib_Request::post_var('content');
     if (trim($content) == '') {
         Lib_Request::flash('error', '提交内容为空');
         Module_HttpRequest_Router::redirect_to($actions[self::URL]);
     }
     $keyword = $actions[self::KEYWORD];
     $model_option = new Model_Option();
     $content = str_replace("\r", '', $content);
     $content = str_replace("\n", '\\n', $content);
     //$content = htmlentities($content);
     $result = $model_option->update_option_by_keyword($keyword, $content);
     if ($result['errno'] != Const_Err_Base::ERR_OK) {
         self::_error_and_redirect(Lib_Helper::format_err_struct($result), $actions[self::URL]);
     } else {
         $help2opcode = ['help_index' => Module_OperationRecord_Main::OPCODE_HELP_INFO, 'help_dev' => Module_OperationRecord_Main::OPCODE_HELP_DEVELOP, 'help_todo' => Module_OperationRecord_Main::OPCODE_HELP_TODO, 'internal_api' => Module_OperationRecord_Main::OPCODE_HELP_INTERNAL, 'open_api' => Module_OperationRecord_Main::OPCODE_HELP_OPEN];
         $opcode = isset($help2opcode[$keyword]) ? $help2opcode[$keyword] : Module_OperationRecord_Main::OPCODE_HELP_INFO;
         Module_OperationRecord_Main::add_record($opcode);
         Lib_Request::flash('保存成功');
         Module_HttpRequest_Router::redirect_to($actions[self::URL]);
     }
 }
Esempio n. 2
0
 /**
  * @return array
  * @throws Exception
  */
 function get_nav()
 {
     if ($this->_nav === null) {
         $mo = new Model_Option();
         $nav = $mo->get_one_by_keyword(Module_Page_Manager::SAVE_KEY_NAV);
         if ($nav[Const_DataAccess::MREK_ERRNO] != Const_Err_Base::ERR_OK) {
             throw new Exception(Lib_Helper::format_err_struct($nav), $nav[Const_DataAccess::MREK_ERRNO]);
         }
         $this->_nav = $nav[Const_DataAccess::MREK_DATA]['value'];
     }
     return $this->_nav;
 }
 public function Option($table, $field, $filter = array(), $key = "")
 {
     $this->logger->debug(__FILE__ . " : Option function execute in Management.");
     $optmodel = new Model_Option($this->dbtype, $this->logger);
     if (strlen($table) > 0) {
         $optmodel->table = $table;
     } else {
         $this->logger->error(__FILE__ . " : Option function table is not defined in Management.");
     }
     if (strlen($field) > 0) {
         $optmodel->_field = $field;
     } else {
         $this->logger->error(__FILE__ . " : Option function field is not defined in Management.");
     }
     if (is_array($filter)) {
         $optmodel->filter = $filter;
     } else {
         $optmodel->filter = array();
     }
     if (strlen($key) > 0) {
         $optmodel->_key = $key;
     } else {
         $optmodel->_key = "";
     }
     if ($optmodel->prepare()) {
         return $optmodel->execute();
     } else {
         return array();
     }
 }
Esempio n. 4
0
 public function action_edit()
 {
     $id = $this->request->param('id', null);
     if (is_numeric($id)) {
         $option = Model_Option::find_by_id($id);
         if (!$option) {
             throw new Exception_Page('common.option_not_found');
         }
         $this->template_data['title'] = __('admin.settings.edit.modify_option');
     } else {
         $option = new Model_Option();
         $this->template_data['title'] = __('admin.settings.edit.new_option');
     }
     if ($this->request->is_post()) {
         $post = $this->cleaned_post();
         $option->update($post);
         $option->save();
         $this->redirect('/admin/setting');
     }
     $this->template_data['option'] = $option;
 }
Esempio n. 5
0
 public function action_option()
 {
     $this->template->title = 'WSJ | RN Options Market';
     /*  Find options the user has bought and now can sell or execute  */
     $options_sell = Model_Option::find('all', array('where' => array(array('user_id', '=', $this->user->id), array('expiration_date', '>', DB::expr(time())), array('status', '=', 'Sold'), 'or' => array(array('user_id', '=', $this->_userId), array('expiration_date', '>', DB::expr(time())), array('status', '=', 'New')))));
     /*  Find options that do not belong to user and is allowed to buy  */
     $options_buy = Model_Option::find('all', array('where' => array(array('user_id', '!=', $this->_userId), array('expiration_date', '>', DB::expr(time())), array('status', '=', 'Sell'))));
     $data['optionsSell'] = $options_sell;
     $data['optionsBuy'] = $options_buy;
     /* set data info views and set views in template */
     $this->template->sell_option = View::forge('backend/index/option/sell', $data);
     $this->template->buy_option = View::forge('backend/index/option/buy', $data);
     $this->template->modal = View::forge('backend/index/option/modal');
 }
Esempio n. 6
0
 /**
  * Set option(s)
  *
  * @param   mixed   Name of option or array in array('option' => 'value') style
  * @param   string  Value of the option
  * @param   bool    If true, not existing options will be created.
  * @return  void
  */
 public static function set($options, $value = null, $create = false)
 {
     is_array($options) or $options = array($options => $value);
     $fetched = Model_Option::find()->where('option', 'in', array_keys($options))->get();
     foreach ($fetched as $option) {
         static::$_cached[$option->option] = $option->value = $options[$option->option];
         $option->save();
         unset($options[$option->option]);
     }
     if ($create and count($options) > 0) {
         foreach ($options as $option => $value) {
             static::$_cached[$option] = $value;
             $opt = Model_Option::forge();
             $opt->option = $option;
             $opt->value = $value;
             $opt->save();
         }
     }
 }
Esempio n. 7
0
    ?>
<script type="text/javascript">
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();
        var scripts = s.getElementsByTagName(o);
        var already_have = false;
        for (var index = 0; index < scripts.length; index++)
        {
            try {
                if ( scripts[index].src.indexOf(g) >= 0 ) {
                    already_have = true;
                }
            } catch (e){}
        }
        if ( ! already_have )
        {
            a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        }
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', '<?php 
    echo $gacode;
    ?>
', '<?php 
    echo Model_Option::get_option('domain');
    ?>
');
    ga('send', 'pageview');
</script>
<?php 
}
Esempio n. 8
0
<table class="table table-responsive">
    <thead>
    <tr>
        <th style="width: 200px"><?php 
echo __('admin.settings.index.name');
?>
</th>
        <th><?php 
echo __('admin.settings.index.description');
?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach (Model_Option::all_options() as $option) {
    ?>
        <tr>
            <td><a href="<?php 
    e::url("/admin/setting/edit/{$option['option_id']}");
    ?>
"><?php 
    echo $option['name'];
    ?>
</a></td>
            <td><?php 
    echo $option['desc'];
    ?>
</td>
        </tr>
    <?php 
Esempio n. 9
0
<?php

$public_key = Model_Option::get_option('captcha_public_key', false);
$path = Kohana::find_file('vendor', 'recaptcha-php-1.11/recaptchalib');
require_once $path;
echo recaptcha_get_html($public_key);
Esempio n. 10
0
<table class="table table-responsive">
    <thead>
    <tr>
        <th style="width: 200px"><?php 
echo __('admin.settings.index.name');
?>
</th>
        <th><?php 
echo __('admin.settings.index.value');
?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach (Model_Option::defaults() as $key => $value) {
    ?>
        <tr class="config-default">
            <td><?php 
    echo $key;
    ?>
</td>
            <td><?php 
    echo $value;
    ?>
</td>
        </tr>
    <?php 
}
?>
    </tbody>
Esempio n. 11
0
<?php

echo __('common.user_forget_password');
?>
 <?php 
echo Model_Option::get_option('admin.email');
Esempio n. 12
0
 public function save()
 {
     parent::save();
     self::$local_cache = null;
 }
Esempio n. 13
0
 public static function delete($name = '')
 {
     if (false === static::is_enabled()) {
         return false;
     }
     if (!isset(static::$_data[$name])) {
         return false;
     }
     $single = \Model_Option::delete(static::$_data[$name]['id']);
     unset(static::$_data[$name]);
     return true;
 }
Esempio n. 14
0
 public function data_dir()
 {
     $data_dir = Model_Option::get_option('data_dir');
     return $data_dir . '/' . $this->problem_id;
 }