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


PHP Preference类代码示例

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


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

示例1: preference

 function preference($args)
 {
     // Preference methods automatically refer only to preferences
     // belonging to the current user.
     $method = $_SERVER['REQUEST_METHOD'];
     switch ($method) {
         case 'GET':
             $name = getUserGetVar('name');
             if ($name) {
                 $preferenceDao = new PreferenceDAO();
                 $preference =& $preferenceDao->getPreference($name);
                 if (null == $preference) {
                     header('HTTP/1.1 404 Not Found');
                     echo '<h1>404 Not Found</h1><p>No such preference</p>';
                 } else {
                     header('Content-type: text/plain');
                     echo $preference->getPreferenceName() . ':' . $preference->getPreferenceValue();
                 }
             } else {
                 $preferenceDao = new PreferenceDAO();
                 $preferences =& $preferenceDao->getPreferences();
                 header('Content-type: text/plain');
                 $first = true;
                 foreach ($preferences as $pref) {
                     if (!$first) {
                         echo "\n";
                     } else {
                         $first = false;
                     }
                     echo $pref->getPreferenceName() . ':' . $pref->getPreferenceValue();
                 }
             }
             break;
         case 'POST':
             $name = getUserGetVar('name');
             $value = getUserPostVar('value');
             if (null == $name || null == $value) {
                 header('HTTP/1.1 400 Bad Request');
                 echo "<h1>400 Bad Request</h1><p>Must specify name and vaule parameters</p>";
             } else {
                 if ('annotations.show' == $name || 'annotations.show-user' == $name || 'annotations.note-edit-mode' == $name) {
                     $preference = new Preference();
                     $preference->setPreferenceName($name);
                     $preference->setPreferenceValue($value);
                     $preferenceDao = new PreferenceDAO();
                     if (null == $preferenceDao->getPreference($name)) {
                         $preferenceDao->insertPreference($preference);
                     } else {
                         $preferenceDao->updatePreference($preference);
                     }
                     header('HTTP/1.1 204 Preference Set');
                 } else {
                     header('HTTP/1.1 404 Invalid Preference');
                     echo "<h1>404 Invalid Preference</h1><p>The preference name you specificed is not valid.</p>";
                 }
             }
             break;
     }
 }
开发者ID:njorth,项目名称:marginalia,代码行数:59,代码来源:MarginaliaHandler.inc.php

示例2: read_prefs

 function read_prefs()
 {
     if (!isset($this->preference)) {
         $preference_factory = new Preference();
         $preferences = $preference_factory->find_all();
         $this->preference = $preferences[0];
     }
 }
开发者ID:emeraldion,项目名称:creso,代码行数:8,代码来源:creso_controller.php

示例3: index

 function index()
 {
     if ($this->request->is_post()) {
         $preference = new Preference($_POST);
         $preference->save();
     }
     $preference_factory = new Preference();
     $preferences = $preference_factory->find_all();
     $this->preference = $preferences[0];
 }
开发者ID:emeraldion,项目名称:creso,代码行数:10,代码来源:preferences_controller.php

示例4: __construct

 function __construct()
 {
     parent::__construct();
     osc_run_hook('init_admin');
     // check if exist a new version each day
     if (time() - osc_last_version_check() > 24 * 3600) {
         $data = osc_file_get_contents('http://osclass.org/latest_version.php?callback=?');
         $data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
         $json = json_decode($data);
         if ($json->version > osc_version()) {
             osc_set_preference('update_core_json', $data);
         } else {
             osc_set_preference('update_core_json', '');
         }
         osc_set_preference('last_version_check', time());
         osc_reset_preferences();
     }
     $config_version = str_replace('.', '', OSCLASS_VERSION);
     $config_version = preg_replace('|-.*|', '', $config_version);
     if ($config_version > Preference::newInstance()->get('version')) {
         if (get_class($this) == 'CAdminTools') {
         } else {
             if (get_class($this) != 'CAdminUpgrade') {
                 $this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
             }
         }
     }
 }
开发者ID:randomecho,项目名称:OSClass,代码行数:28,代码来源:AdminSecBaseModel.php

示例5: getInstance

 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Preference();
     }
     return self::$instance;
 }
开发者ID:aslikeyou,项目名称:php_design_patterns,代码行数:7,代码来源:example2.php

示例6: upgrade

 /**
  * upgrade
  * This is a recommended plugin function
  */
 public function upgrade()
 {
     $from_version = Plugin::get_plugin_version($this->name);
     if ($from_version < 2) {
         Preference::insert('catalogfav_columns', 'Catalog favorites columns', '1', '25', 'integer', 'plugins');
     }
     return true;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:12,代码来源:CatalogFavorites.plugin.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $actif = "preference";
     $mode = 'preference';
     $profil = Preference::first();
     return view('admin.param-config', compact('actif', 'mode', 'profil'));
 }
开发者ID:blackdavinci,项目名称:crm-ftz,代码行数:13,代码来源:PreferenceController.php

示例8: uninstall

 /**
  * uninstall
  * This is a required plugin function
  */
 public function uninstall()
 {
     Preference::delete('amazon_base_url');
     Preference::delete('amazon_max_results_pages');
     Preference::delete('amazon_developer_public_key');
     Preference::delete('amazon_developer_private_api_key');
     Preference::delete('amazon_developer_associate_tag');
     return true;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:13,代码来源:Amazon.plugin.php

示例9: basic_info

function basic_info()
{
    require_once ABS_PATH . 'oc-includes/osclass/model/Admin.php';
    require_once ABS_PATH . 'oc-includes/osclass/model/Preference.php';
    Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => 'admin', 's_password' => sha1('admin'), 's_email' => $_POST['email']));
    $mPreference = Preference::newInstance();
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => $_POST['webtitle'], 'e_type' => 'STRING'));
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => $_POST['email'], 'e_type' => 'STRING'));
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:9,代码来源:install-location.php

示例10: __construct

 function __construct()
 {
     parent::__construct();
     // check if is moderator and can enter to this page
     if ($this->isModerator()) {
         if (!in_array($this->page, array('items', 'comments', 'media', 'login', 'admins', 'ajax', 'stats', ''))) {
             osc_add_flash_error_message(_m("You don't have enough permissions"), 'admin');
             $this->redirectTo(osc_admin_base_url());
         }
     }
     osc_run_hook('init_admin');
     // check if exist a new version each day
     if (time() - osc_last_version_check() > 24 * 3600) {
         $data = osc_file_get_contents('http://osclass.org/latest_version.php?callback=?');
         $data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
         $json = json_decode($data);
         if ($json->version > osc_version()) {
             osc_set_preference('update_core_json', $data);
         } else {
             osc_set_preference('update_core_json', '');
         }
         osc_set_preference('last_version_check', time());
         osc_reset_preferences();
     }
     $config_version = str_replace('.', '', OSCLASS_VERSION);
     $config_version = preg_replace('|-.*|', '', $config_version);
     if ($config_version > Preference::newInstance()->get('version')) {
         if (get_class($this) == 'CAdminTools') {
         } else {
             if (get_class($this) != 'CAdminUpgrade') {
                 $this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
             }
         }
     }
     // show messages subscribed
     $status_subscribe = Params::getParam('subscribe_osclass');
     if ($status_subscribe != '') {
         switch ($status_subscribe) {
             case -1:
                 osc_add_flash_error_message(_m('Entered an invalid email'), 'admin');
                 break;
             case 0:
                 osc_add_flash_warning_message(_m("You're already subscribed"), 'admin');
                 break;
             case 1:
                 osc_add_flash_ok_message(_m('Subscribed correctly'), 'admin');
                 break;
             default:
                 osc_add_flash_warning_message(_m("Error subscribing"), 'admin');
                 break;
         }
     }
     // show donation successful
     if (Params::getParam('donation') == 'successful') {
         osc_add_flash_ok_message(_m('Thank you very much for your donation'), 'admin');
     }
 }
开发者ID:semul,项目名称:Osclass,代码行数:57,代码来源:AdminSecBaseModel.php

示例11: customHead

function customHead()
{
    $all = Preference::newInstance()->findValueByName('location_todo');
    if ($all == '') {
        $all = 0;
    }
    $worktodo = LocationsTmp::newInstance()->count();
    ?>
        <script type="text/javascript">
            function reload() {
                window.location = '<?php 
    echo osc_admin_base_url(true) . '?page=tools&action=locations';
    ?>
';
            }

            function ajax_() {
                $.ajax({
                    type: "POST",
                    url: '<?php 
    echo osc_admin_base_url(true);
    ?>
?page=ajax&action=location_stats&<?php 
    echo osc_csrf_token_url();
    ?>
',
                    dataType: 'json',
                    success: function(data) {
                        if(data.status=='done') {
                        }else{
                            var pending = data.pending;
                            var all = <?php 
    echo osc_esc_js($all);
    ?>
;
                            var percent = parseInt( ((all-pending)*100) / all );
                            $('span#percent').html(percent);
                            ajax_();
                        }
                    }
                });
            }

            $(document).ready(function(){
                if(<?php 
    echo $worktodo;
    ?>
> 0) {
                    ajax_();
                }
            });
        </script>
        <?php 
}
开发者ID:jmcclenon,项目名称:Osclass,代码行数:54,代码来源:locations.php

示例12: getHideArchive

 public function getHideArchive()
 {
     $userId = Yii::app()->user->id;
     if ($userId) {
         $preference = Preference::model()->find("userId = {$userId} AND hideProject = 'archive'");
         if ($preference) {
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:13,代码来源:Preference.php

示例13: setCategoryInBdd

function setCategoryInBdd($categories_id)
{
    global $bdd;
    global $_TABLES;
    if (!is_null($bdd) && !is_null($_TABLES)) {
        if (isset($_SESSION['user_id'])) {
            $user_id = $_SESSION['user_id'];
            $objPreference = new Preference($bdd, $_TABLES);
            $objPreference->removeAllPreferenceByUser($user_id);
            if (count($categories_id) > 0) {
                foreach ($categories_id as $key => $category_id) {
                    $objPreference->addPreferenceByUser($user_id, $category_id);
                }
            }
            return true;
        } else {
            return false;
        }
    } else {
        error_log("BDD ERROR : " . json_encode($bdd));
        error_log("TABLES ERROR : " . json_encode($_TABLES));
    }
}
开发者ID:xXNoceboXx,项目名称:WUS,代码行数:23,代码来源:controller.category.php

示例14: google_analytics_actions

function google_analytics_actions()
{
    $dao_preference = new Preference();
    $option = Params::getParam('option');
    if (Params::getParam('file') != 'google_analytics/admin.php') {
        return '';
    }
    if ($option == 'stepone') {
        $webid = Params::getParam('webid');
        Preference::newInstance()->update(array("s_value" => $webid), array("s_section" => "plugin-google_analytics", "s_name" => "google_analytics_id"));
        osc_add_flash_ok_message(__('The tracking ID has been updated', 'google_analytics'), 'admin');
        osc_redirect_to(osc_admin_render_plugin_url('google_analytics/admin.php'));
    }
}
开发者ID:mylastof,项目名称:os-class,代码行数:14,代码来源:index.php

示例15: basic_info

function basic_info()
{
    require_once LIB_PATH . 'osclass/model/Admin.php';
    require_once LIB_PATH . 'osclass/model/Preference.php';
    require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
    if ($_POST['s_name'] == '') {
        $admin = 'admin';
    } else {
        $admin = $_POST['s_name'];
    }
    if ($_POST['s_passwd'] == '') {
        $password = osc_genRandomPassword();
    } else {
        $password = $_POST['s_passwd'];
    }
    Admin::newInstance()->insert(array('s_name' => 'Administrator', 's_username' => $admin, 's_password' => sha1($password), 's_email' => $_POST['email']));
    $mPreference = Preference::newInstance();
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'pageTitle', 's_value' => $_POST['webtitle'], 'e_type' => 'STRING'));
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'contactEmail', 's_value' => $_POST['email'], 'e_type' => 'STRING'));
    $body = 'Welcome ' . $_POST['webtitle'] . ',<br/><br/>';
    $body .= 'Your OSClass installation at ' . WEB_PATH . ' is up and running. You can access to the administration panel with this data access:<br/>';
    $body .= '<ul>';
    $body .= '<li>username: ' . $admin . '</li>';
    $body .= '<li>password: ' . $password . '</li>';
    $body .= '</ul>';
    $body .= 'Regards,<br/>';
    $body .= 'The <a href=\'http://osclass.org/\'>OSClass</a> team';
    $sitename = strtolower($_SERVER['SERVER_NAME']);
    if (substr($sitename, 0, 4) == 'www.') {
        $sitename = substr($sitename, 4);
    }
    try {
        require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
        $mail = new PHPMailer(true);
        $mail->CharSet = "utf-8";
        $mail->Host = "localhost";
        $mail->From = 'osclass@' . $sitename;
        $mail->FromName = 'OSClass';
        $mail->Subject = 'OSClass successfully installed!';
        $mail->AddAddress($_POST['email'], 'OSClass administrator');
        $mail->Body = $body;
        $mail->AltBody = $body;
        if (!$mail->Send()) {
            return array('email_status' => $_POST['email'] . "<br>" . $mail->ErrorInfo, 's_password' => $password);
        } else {
            return array('email_status' => '', 's_password' => $password);
        }
    } catch (phpmailerException $exception) {
    }
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:50,代码来源:install-location.php


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