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


PHP Setting::exists方法代码示例

本文整理汇总了PHP中Setting::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::exists方法的具体用法?PHP Setting::exists怎么用?PHP Setting::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Setting的用法示例。


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

示例1: Setting

 function after_content_create($content)
 {
     $s = new Setting();
     $s->where('name', 'uploading_publish_on_captured_date')->get();
     if ($s->exists() && $s->value === 'true') {
         $fresh = new Content();
         $fresh->get_by_id($content['id']);
         $fresh->published_on = $content['captured_on']['utc'] ? $content['captured_on']['timestamp'] : 'captured_on';
         $fresh->save();
     }
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:11,代码来源:plugin.php

示例2: index

 function index()
 {
     list($params, $id, $slug) = $this->parse_params(func_get_args());
     // Create or update
     if ($this->method != 'get') {
         $c = new Content();
         switch ($this->method) {
             case 'post':
             case 'put':
                 if ($this->method == 'put') {
                     // Update
                     $c->get_by_id($id);
                     if (!$c->exists()) {
                         $this->error('404', "Content with ID: {$id} not found.");
                         return;
                     }
                     $c->old_published_on = $c->published_on;
                     $c->old_captured_on = $c->captured_on;
                     $c->old_uploaded_on = $c->uploaded_on;
                     if (isset($_POST['slug'])) {
                         $c->current_slug = $c->slug;
                     }
                 }
                 if (isset($_REQUEST['name'])) {
                     if (isset($_REQUEST['upload_session_start'])) {
                         $s = new Setting();
                         $s->where('name', 'last_upload')->get();
                         if ($s->exists() && $s->value != $_REQUEST['upload_session_start']) {
                             $s->value = $_REQUEST['upload_session_start'];
                             $s->save();
                         }
                     }
                     $file_name = $c->clean_filename($_REQUEST['name']);
                     $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
                     $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
                     $tmp_dir = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
                     $tmp_path = $tmp_dir . DIRECTORY_SEPARATOR . $file_name;
                     make_child_dir($tmp_dir);
                     if ($chunks == 0 || $chunk == $chunks - 1) {
                         if (isset($_REQUEST['text'])) {
                             $path = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR;
                             $internal_id = false;
                         } else {
                             if (isset($_REQUEST['plugin'])) {
                                 $info = pathinfo($_REQUEST['name']);
                                 $path = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $_REQUEST['plugin'] . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR;
                                 $file_name = $_REQUEST['basename'] . '.' . $info['extension'];
                                 $internal_id = false;
                             } else {
                                 list($internal_id, $path) = $c->generate_internal_id();
                             }
                         }
                         if ($path) {
                             $path .= $file_name;
                             if ($chunks == 0) {
                                 $tmp_path = $path;
                             }
                         } else {
                             $this->error('500', 'Unable to create directory for upload.');
                             return;
                         }
                     }
                     // Look for the content type header
                     if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
                         $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
                     } else {
                         if (isset($_SERVER["CONTENT_TYPE"])) {
                             $contentType = $_SERVER["CONTENT_TYPE"];
                         } else {
                             $contentType = '';
                         }
                     }
                     if (strpos($contentType, "multipart") !== false) {
                         if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
                             $out = fopen($tmp_path, $chunk == 0 ? "wb" : "ab");
                             if ($out) {
                                 // Read binary input stream and append it to temp file
                                 $in = fopen($_FILES['file']['tmp_name'], "rb");
                                 if ($in) {
                                     while ($buff = fread($in, 4096)) {
                                         fwrite($out, $buff);
                                     }
                                 } else {
                                     $this->error('500', 'Unable to read input stream.');
                                     return;
                                 }
                                 fclose($out);
                                 unlink($_FILES['file']['tmp_name']);
                             } else {
                                 $this->error('500', 'Unable to write to output file.');
                                 return;
                             }
                         } else {
                             $this->error('500', 'Unable to move uploaded file.');
                             return;
                         }
                     } else {
                         $out = fopen($tmp_path, $chunk == 0 ? "wb" : "ab");
                         if ($out) {
                             // Read binary input stream and append it to temp file
//.........这里部分代码省略.........
开发者ID:Caldis,项目名称:htdocs,代码行数:101,代码来源:contents.php

示例3: Setting

<?php

$s = new Setting();
$s->where('name', 'retain_image_metadata')->get();
if (!$s->exists()) {
    $n = new Setting();
    $n->name = 'retain_image_metadata';
    $n->value = 'false';
    $n->save();
}
$done = true;
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:11,代码来源:0009.php

示例4: index

    function index()
    {
        if (!$this->auth) {
            $this->error('403', 'Forbidden');
            return;
        }
        $image_processing = new Setting();
        $image_processing->where('name', 'image_processing_library')->get();
        include FCPATH . 'app' . DIRECTORY_SEPARATOR . 'koken' . DIRECTORY_SEPARATOR . 'DarkroomUtils.php';
        $libs = DarkroomUtils::libraries();
        if ($image_processing->exists()) {
            if (!isset($libs[$image_processing->value])) {
                $top = array_shift(array_keys($libs));
                $lib = $libs[$top];
                $image_processing->value = $lib['key'];
                $image_processing->save();
            }
        } else {
            if (!defined('MAGICK_PATH_FINAL') || (MAGICK_PATH_FINAL === 'convert' || !isset($libs[MAGICK_PATH_FINAL]))) {
                $top = array_shift(array_keys($libs));
                $lib = $libs[$top];
            } else {
                $lib = $libs[MAGICK_PATH_FINAL];
            }
            $image_processing->name = 'image_processing_library';
            $image_processing->value = $lib['key'];
            $image_processing->save();
        }
        $last_check = new Setting();
        $last_check->where('name', 'last_migration');
        $last_check_count = $last_check->count();
        if ($last_check_count > 1) {
            $last_check->where('name', 'last_migration')->order_by('value ASC')->limit($last_check_count - 1)->get();
            $last_check->delete_all();
        }
        $s = new Setting();
        $settings = $s->get_iterated();
        $data = array('image_processing_libraries' => array_values($libs));
        $bools = array('has_toured', 'site_hidpi', 'retain_image_metadata', 'image_use_defaults', 'use_default_labels_links', 'uploading_publish_on_captured_date');
        foreach ($settings as $setting) {
            // Don't allow dupes to screw things up
            if (isset($data[$setting->name])) {
                continue;
            }
            $value = $setting->value;
            if (in_array($setting->name, $bools)) {
                $value = $value == 'true';
            }
            if ($setting->name === 'last_upload') {
                $value = $value === 'false' ? false : (int) $value;
            }
            $data[$setting->name] = $value;
        }
        if (!isset($data['uploading_publish_on_captured_date'])) {
            $data['uploading_publish_on_captured_date'] = false;
        }
        if (!isset($data['uploading_default_album_visibility'])) {
            $data['uploading_default_album_visibility'] = 'public';
        }
        if (!isset($data['email_handler'])) {
            $data['email_handler'] = 'DDI_Email';
        }
        $data['email_handlers'] = Shutter::get_email_handlers();
        $disable_cache_file = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'no-site-cache';
        $data['enable_site_cache'] = !file_exists($disable_cache_file);
        if ($this->method != 'get') {
            if ($this->auth_role !== 'god') {
                $this->error('403', 'Forbidden');
                return;
            }
            if (isset($_POST['signin_bg'])) {
                $c = new Content();
                $c->get_by_id($_POST['signin_bg']);
                if ($c->exists()) {
                    $_c = $c->to_array();
                    $large = array_pop($_c['presets']);
                    // TODO: Error checking for permissions reject
                    $f = $large['url'];
                    $to = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'wallpaper' . DIRECTORY_SEPARATOR . 'signin.jpg';
                    if (extension_loaded('curl')) {
                        $cp = curl_init($f);
                        $fp = fopen($to, "w+");
                        if (!$fp) {
                            curl_close($cp);
                        } else {
                            curl_setopt($cp, CURLOPT_FILE, $fp);
                            curl_exec($cp);
                            curl_close($cp);
                            fclose($fp);
                        }
                    } elseif (ini_get('allow_url_fopen')) {
                        copy($f, $to);
                    }
                }
            } else {
                if (isset($_POST['enable_site_cache'])) {
                    if ($_POST['enable_site_cache'] === 'true') {
                        @unlink($disable_cache_file);
                    } else {
                        touch($disable_cache_file);
//.........这里部分代码省略.........
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:101,代码来源:settings.php

示例5: migrate

 function migrate($n = false)
 {
     if ($this->method !== 'post') {
         $this->error('403', 'Forbidden');
         return;
     }
     $CI =& get_instance();
     $this->db =& $CI->db;
     $db_config = Shutter::get_db_configuration();
     $this->load->dbforge();
     if ($n === 'schema') {
         require FCPATH . 'app' . DIRECTORY_SEPARATOR . 'koken' . DIRECTORY_SEPARATOR . 'schema.php';
         foreach ($koken_tables as $table_name => $info) {
             $table = $db_config['prefix'] . "{$table_name}";
             if ($this->db->table_exists($table)) {
                 $existing_fields = array();
                 foreach ($this->db->field_data($table) as $field) {
                     $existing_fields[$field->name] = $field;
                 }
                 foreach ($info['fields'] as $field_name => $field_info) {
                     if (array_key_exists($field_name, $existing_fields)) {
                         $field_info['type'] = strtolower($field_info['type']);
                         $compare = (array) $existing_fields[$field_name];
                         unset($compare['name']);
                         unset($compare['primary_key']);
                         if (isset($compare['max_length'])) {
                             $compare['constraint'] = (int) $compare['max_length'];
                             unset($compare['max_length']);
                         }
                         if (in_array(strtolower($field_info['type']), array('text', 'varchar', 'longtext'))) {
                             $field_info['null'] = true;
                         }
                         $diff = array_diff_assoc($field_info, $compare);
                         if (isset($diff['null']) && $diff['null'] === true && is_null($compare['default']) && $field_info['type'] !== 'text' && $field_info['type'] !== 'varchar') {
                             unset($diff['null']);
                         }
                         if (!empty($diff)) {
                             $this->dbforge->modify_column($table, array($field_name => $field_info));
                         }
                     } else {
                         if (in_array(strtolower($field_info['type']), array('text', 'varchar', 'longtext'))) {
                             $field_info['null'] = true;
                         }
                         $this->dbforge->add_column($table, array($field_name => $field_info));
                     }
                 }
                 if (isset($info['keys'])) {
                     foreach ($info['keys'] as $key) {
                         if (is_array($key)) {
                             $key_name = $this->db->_protect_identifiers(implode('_', $key));
                             $key = $this->db->_protect_identifiers($key);
                         } else {
                             $key_name = $this->db->_protect_identifiers($key);
                             $key = array($key_name);
                         }
                         $sql = "ALTER TABLE {$table} ADD KEY {$key_name} (" . implode(', ', $key) . ")";
                         $this->db->query($sql);
                     }
                 }
                 if (isset($info['uniques'])) {
                     foreach ($info['uniques'] as $key) {
                         $this->db->query("CREATE UNIQUE INDEX {$key} ON {$table} ({$key})");
                     }
                 }
             } else {
                 if (!isset($info['no_id'])) {
                     $this->dbforge->add_field('id');
                 }
                 $this->dbforge->add_field($info['fields']);
                 if (isset($info['keys'])) {
                     foreach ($info['keys'] as $key) {
                         $primary = false;
                         if ($key == 'id') {
                             $primary = true;
                         }
                         $this->dbforge->add_key($key, $primary);
                     }
                 }
                 $this->dbforge->create_table($db_config['prefix'] . "{$table_name}");
                 if (isset($info['uniques'])) {
                     $table = $db_config['prefix'] . "{$table_name}";
                     foreach ($info['uniques'] as $key) {
                         $this->db->query("CREATE UNIQUE INDEX {$key} ON {$table} ({$key})");
                     }
                 }
             }
         }
         $this->_clear_system_caches();
         $s = new Setting();
         $s->where('name', 'uuid')->get();
         if (!$s->exists()) {
             $s = new Setting();
             $s->name = 'uuid';
             $s->value = md5($_SERVER['HTTP_HOST'] . uniqid('', true));
             $s->save();
         }
         $uuid = $s->value;
         $base_folder = trim(preg_replace('/\\/api\\.php(.*)?$/', '', $_SERVER['SCRIPT_NAME']), '/');
         include FCPATH . 'app' . DIRECTORY_SEPARATOR . 'koken' . DIRECTORY_SEPARATOR . 'DarkroomUtils.php';
         $s->where('name', 'image_processing_library')->get();
//.........这里部分代码省略.........
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:101,代码来源:update.php

示例6: array

 function _compile_plugins()
 {
     $storage = FCPATH . 'storage/plugins/';
     $plugins = $this->parse_plugins();
     $to_compile = array('info' => array('email_handler' => 'DDI_Email'), 'plugins' => array());
     foreach ($plugins as $plugin) {
         if (!$plugin['internal'] && $plugin['activated'] && $plugin['setup']) {
             $_arr = array('path' => $plugin['path']);
             if (isset($plugin['data'])) {
                 $data = array();
                 foreach ($plugin['data'] as $key => $arr) {
                     if (isset($arr['value'])) {
                         $data[$key] = $arr['value'];
                     }
                 }
                 $_arr['data'] = $data;
             }
             $to_compile['plugins'][] = $_arr;
         }
     }
     $s = new Setting();
     $s->where('name', 'email_handler')->get();
     if ($s->exists()) {
         $to_compile['info']['email_handler'] = $s->value;
     }
     $s = new Setting();
     $s->where('name', 'email_delivery_address')->get();
     if ($s->exists()) {
         $to_compile['info']['email_delivery_address'] = $s->value;
     }
     Shutter::write_cache('plugins/compiled.cache', serialize($to_compile));
 }
开发者ID:Caldis,项目名称:htdocs,代码行数:32,代码来源:Koken_Controller.php

示例7: value

 public static function value($name, $default = false, $return = true)
 {
     $setting = new Setting();
     $setting->where('name', $name)->limit(1)->get();
     if (!$setting->exists()) {
         return $default;
     } else {
         $val = $setting->get_value();
         if (empty($val)) {
             return $default;
         } else {
             if ($return) {
                 return $setting->get_value();
             } else {
                 echo $setting->get_value();
             }
         }
     }
 }
开发者ID:jotavejv,项目名称:CMS,代码行数:19,代码来源:setting.php


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