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


PHP Q类代码示例

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


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

示例1: actionModify

 function actionModify()
 {
     $id = (int) $this->_context->get('id');
     $rs = Account::find('user_id = ?', $id)->getOne();
     if (!$rs->id()) {
         return $this->msg($tip = '参数错误', url('manage::account'));
     }
     $form = Form_Common::createForm('', 'manage/profile');
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         $post = $form->values();
         $user_mail = $post['user_mail'];
         $user_pass = $post['user_pass'];
         $is_locked = $post['is_locked'] ? '1' : '0';
         #dump($post);
         if ($user_pass) {
             $user_pass = sha1(md5('sike' . $post['user_pass'] . Q::ini('appini/secret_key')));
             $rs->user_pass;
         }
         $rs->user_mail = $user_mail;
         $rs->is_locked = $is_locked;
         $rs->save();
         return $this->msg($tip = '修改成功', url('manage::account/modify', array('id' => $id)));
     }
     $form->import($rs->toArray());
     $form->element('user_pass')->value = '';
     $form->element('is_locked')->checked = $rs->is_locked;
     #dump($form->element('is_locked'));
     $this->_view['form'] = $form;
     $this->_view['rs'] = $rs;
     $order = Order::find('user_id = ?', $id)->order('created DESC')->getAll();
     $this->_view['order'] = $order;
     $this->_view['_UDI'] = 'manage::account/index';
 }
开发者ID:xyz12810,项目名称:xiao3vpn,代码行数:33,代码来源:account_controller.php

示例2: loadCached

 /**
  * 载入缓存的 YAML 解析结果,如果缓存失效,则重新解析并生成缓存
  *
  * @param string $filename
  *   要解析的 yaml 文件名
  * @param array $replace
  *   对于 YAML 内容要进行自动替换的字符串对
  * @param string $cache_backend
  *   要使用的缓存后端
  *
  * @return array
  *   解析结果
  */
 static function loadCached($filename, array $replace = null, $cache_backend = null)
 {
     static $cache_obj = null;
     if (!is_file($filename)) {
         throw new QException_FileNotFound($filename);
     }
     $policy = array('lifetime' => 86400, 'serialize' => true);
     $mtime = filemtime($filename);
     $id = 'yaml_cache_' . md5($filename);
     if (is_null($cache_backend)) {
         if (is_null($cache_obj)) {
             $cache_obj = Q::getSingleton(Q::getIni('runtime_cache_backend'));
         }
         $cache = $cache_obj;
     } else {
         $cache = self::getSingleton($cache_backend);
     }
     /* @var $cache QCache_File */
     $data = $cache->get($id, $policy);
     if (!isset($data['yaml']) || empty($data['mtime']) || $data['mtime'] < $mtime) {
         // 缓存失效
         $data = array('mtime' => $mtime, 'yaml' => self::load($filename, $replace));
         $cache->set($id, $data, $policy);
     }
     return $data['yaml'];
 }
开发者ID:fchaose,项目名称:qeephp,代码行数:39,代码来源:yaml.php

示例3: log_shard_query

function log_shard_query($params)
{
    foreach ($params['queries'] as $shard => $query) {
        if ($query->className === 'Users_Session') {
            continue;
        }
        $connection = $query->db->connectionName();
        if ($begin = $query->getClause('BEGIN') and $query->nestedTransactionCount == 1) {
            Q::log($begin);
        }
        $duration = ceil($query->endedTime - $query->startedTime);
        Q::log("Query {$connection} on shard \"{$shard}\":\n{$params['sql']}\n(duration: {$duration} ms)\n\n");
        if ($commit = $query->getClause('COMMIT') and $query->nestedTransactionCount == 0) {
            Q::log($commit);
        }
        if (!empty($params['exception'])) {
            Q::log("ROLLBACK (due to exception)");
            Q::log("query was: " . $params['sql']);
            Q::log($params['exception']);
        } else {
            if ($rollback = $query->getClause('ROLLBACK')) {
                Q::log($rollback);
            }
        }
    }
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:26,代码来源:init.php

示例4: Q_response_dashboard

function Q_response_dashboard()
{
    $app = Q_Config::expect('Q', 'app');
    $slogan = "Powered by Q.";
    $user = Users::loggedInUser();
    return Q::view("{$app}/dashboard.php", compact('slogan', 'user'));
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:7,代码来源:dashboard.php

示例5: render

 /**
  * 实现接口
  *
  */
 function render()
 {
     //得到子菜单的标题
     $menu_title = $this->_extract('menu');
     //的到子菜单的属性
     $sub_menu = Q::ini('appini/admin_sub_menus/' . $menu_title);
     //是否存在
     if (!is_array($sub_menu)) {
         $sub_menu = array();
     }
     //得到当前的属性
     $currentmenu = $this->_extract('current');
     //输出子菜单 如果是当前的加上css
     $out = "<ul>\n";
     foreach ($sub_menu as $menu) {
         //是否是当前菜单
         if ($menu['title'] == $currentmenu) {
             $out .= "<li class=\"current\">";
         } else {
             $out .= "<li>";
         }
         $out .= '<a href="' . url($menu['udi']) . '"> <span>';
         $out .= h($menu['title']) . '</span>';
         $out .= "</a></li>\n";
     }
     $out .= "</ul>\n";
     return $out;
 }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:32,代码来源:smalltabs.php

示例6: Streams_stream_response_Q_inplace

function Streams_stream_response_Q_inplace()
{
    $stream = isset(Streams::$cache['stream']) ? Streams::$cache['stream'] : null;
    if (!$stream) {
        throw new Exception("No stream");
    }
    if (isset($_REQUEST['title'])) {
        $result = $stream->title;
    } else {
        if (isset($_REQUEST['attributes'])) {
            if (is_array($_REQUEST['attributes'])) {
                reset($_REQUEST['attributes']);
                $result = $stream->getAttribute(key($_REQUEST['attributes']));
            } else {
                $result = $stream->attributes;
            }
        } else {
            $fieldNames = array_diff(Streams::getExtendFieldNames($stream->type), array('insertedTime', 'updatedTime'));
            $field = 'content';
            foreach ($fieldNames as $f) {
                if (isset($_REQUEST[$f])) {
                    $field = $f;
                    break;
                }
            }
            $result = $stream->{$field};
        }
    }
    $convert = Q::ifset($_REQUEST, 'convert', '["\\n"]');
    return Q_Html::text($result, json_decode($convert, true));
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:31,代码来源:Q_inplace.php

示例7: Streams_invite_response_data

function Streams_invite_response_data()
{
    if (isset(Streams::$cache['invited'])) {
        return Streams::$cache['invited'];
    }
    $user = Users::loggedInUser(true);
    $publisherId = Streams::requestedPublisherId();
    $streamType = Streams::requestedType();
    $invitingUserId = Streams::requestedField('invitingUserId');
    $limit = Q::ifset($_REQUEST, 'limit', Q_Config::get('Streams', 'invites', 'limit', 100));
    $invited = Streams_Invited::select('*')->where(array('userId' => $user->id, 'state' => 'pending', 'expireTime <' => new Db_Expression('CURRENT_TIMESTAMP')))->limit($limit)->fetchDbRows(null, null, 'token');
    $query = Streams_Invite::select('*')->where(array('token' => array_keys($invited)));
    if (isset($publisherId)) {
        $query = $query->where(array('publisherId' => $publisherId));
    }
    if (isset($streamType)) {
        $query = $query->where(array('streamName' => new Db_Range($streamType . '/', true, false, true)));
    }
    if (isset($invitingUserId)) {
        $query = $query->where(array('invitingUserId' => $invitingUserId));
    }
    $invites = $query->fetchDbRows();
    $streams = array();
    foreach ($invites as $invite) {
        $stream = new Streams_Stream();
        $stream->publisherId = $invite->publisherId;
        $stream->name = $invite->streamName;
        if ($stream->retrieve()) {
            $streams[$invite->token] = $stream->exportArray();
            $streams[$invite->token]['displayName'] = $invite->displayName;
        }
    }
    return compact('streams', 'invites');
}
开发者ID:dmitriz,项目名称:Platform,代码行数:34,代码来源:data.php

示例8: addContact

 /**
  * Add contact with one or more labels
  * @method addContact
  * @static
  * @param {string} $userId
  *  The id of the user whose contact will be added
  * @param {string} $contactUserId
  *  The id of the user who is the contact
  * @param {string|array} $label
  *  The label of the contact. This can be a string or an array of strings, in which case
  *  multiple contact rows are saved.
  * @param {string} [$nickname='']
  *  Optional nickname to assign to the contact
  *  @optional
  * @throws {Q_Exception_RequiredField}
  *	if $label is missing
  * @return {array} Array of contacts that are saved
  */
 static function addContact($userId, $label, $contactUserId, $nickname = '')
 {
     foreach (array('userId', 'label', 'contactUserId') as $field) {
         if (empty(${$field})) {
             throw new Q_Exception_RequiredField(compact('field'));
         }
     }
     $labels = is_array($label) ? $label : array($label);
     $contacts = array();
     foreach ($labels as $l) {
         // Insert the contacts one by one
         $contact = new Users_Contact();
         $contact->userId = $userId;
         $contact->contactUserId = $contactUserId;
         $contact->label = $l;
         if ($nickname) {
             $contact->nickname = $nickname;
         }
         $contact->save(true);
         $contacts[] = $contact;
     }
     /**
      * @event Users/Contact/addContact {after}
      * @param {string} contactUserId
      * @param {string} label
      * @param {array} contacts
      */
     Q::event('Users/Contact/addContact', compact('contactUserId', 'label', 'contacts'), 'after');
     return $contacts;
 }
开发者ID:atirjavid,项目名称:Platform,代码行数:48,代码来源:Contact.php

示例9: UserAclRoles

 function UserAclRoles($user_id = '')
 {
     $show_box['title'] = '获取用户全部角色';
     $return_value = '';
     $roles_idname = array();
     $roles_id = array();
     $sp_roles = Q::ini('appini/sp_role');
     // 第一步:直接从中间表获得用户的全部角色ID
     $user_roles = UsersHaveRoles::find('user_id = ?', intval($user_id))->asArray()->getAll();
     //dump($user_roles);
     // 取出有用的ID,去除deny的ID
     foreach ($user_roles as $value) {
         if ($value['is_include']) {
             $roles_id[] = $value['role_id'];
         }
     }
     //dump ( $roles_id);
     $roles_arr = Roles::find('role_id in (?)', Q::normalize($roles_id, ","))->asArray()->getAll();
     foreach ($roles_arr as $value) {
         $roles_idname[$value['role_id']] = $value['rolename'];
     }
     //dump($roles_idname);
     if (in_array($sp_roles['REPEAL'], $roles_idname)) {
         $return_value = array($value['role_id'] => $sp_roles['REPEAL']);
         return $return_value;
     } elseif (in_array($sp_roles['FREEZE'], $roles_idname)) {
         $return_value = array($value['role_id'] => $sp_roles['FREEZE']);
         return $return_value;
     } elseif (in_array($sp_roles['UNCHECKED'], $roles_idname)) {
         $return_value = array($value['role_id'] => $sp_roles['UNCHECKED']);
         return $return_value;
     } else {
         return $roles_idname;
     }
 }
开发者ID:Debenson,项目名称:openwan,代码行数:35,代码来源:acl.php

示例10: Assets_payment_tool

/**
 * Standard tool for making payments.
 * @class Assets payment
 * @constructor
 * @param {array} $options Override various options for this tool
 *  @param {string} $options.payments can be "authnet" or "stripe"
 *  @param {string} $options.amount the amount to pay.
 *  @param {double} [$options.currency="usd"] the currency to pay in. (authnet supports only "usd")
 *  @param {string} [$options.payButton] Can override the title of the pay button
 *  @param {String} [$options.publisherId=Users::communityId()] The publisherId of the Assets/product or Assets/service stream
 *  @param {String} [$options.streamName] The name of the Assets/product or Assets/service stream
 *  @param {string} [$options.name=Users::communityName()] The name of the organization the user will be paying
 *  @param {string} [$options.image] The url pointing to a square image of your brand or product. The recommended minimum size is 128x128px.
 *  @param {string} [$options.description=null] A short name or description of the product or service being purchased.
 *  @param {string} [$options.panelLabel] The label of the payment button in the Stripe Checkout form (e.g. "Pay {{amount}}", etc.). If you include {{amount}}, it will be replaced by the provided amount. Otherwise, the amount will be appended to the end of your label.
 *  @param {string} [$options.zipCode] Specify whether Stripe Checkout should validate the billing ZIP code (true or false). The default is false.
 *  @param {boolean} [$options.billingAddress] Specify whether Stripe Checkout should collect the user's billing address (true or false). The default is false.
 *  @param {boolean} [$options.shippingAddress] Specify whether Checkout should collect the user's shipping address (true or false). The default is false.
 *  @param {string} [$options.email=Users::loggedInUser(true)->emailAddress] You can use this to override the email address, if any, provided to Stripe Checkout to be pre-filled.
 *  @param {boolean} [$options.allowRememberMe=true] Specify whether to include the option to "Remember Me" for future purchases (true or false).
 *  @param {boolean} [$options.bitcoin=false] Specify whether to accept Bitcoin (true or false). 
 *  @param {boolean} [$options.alipay=false] Specify whether to accept Alipay ('auto', true, or false). 
 *  @param {boolean} [$options.alipayReusable=false] Specify if you need reusable access to the customer's Alipay account (true or false).
 */
function Assets_payment_tool($options)
{
    Q_Valid::requireFields(array('payments', 'amount'), $options, true);
    if (empty($options['name'])) {
        $options['name'] = Users::communityName();
    }
    if (!empty($options['image'])) {
        $options['image'] = Q_Html::themedUrl($options['image']);
    }
    $options['payments'] = strtolower($options['payments']);
    if (empty($options['email'])) {
        $options['email'] = Users::loggedInUser(true)->emailAddress;
    }
    $payments = ucfirst($options['payments']);
    $currency = strtolower(Q::ifset($options, 'currency', 'usd'));
    if ($payments === 'Authnet' and $currency !== 'usd') {
        throw new Q_Exception("Authnet doesn't support currencies other than USD", 'currency');
    }
    $className = "Assets_Payments_{$payments}";
    switch ($payments) {
        case 'Authnet':
            $adapter = new $className($options);
            $token = $options['token'] = $adapter->authToken();
            $testing = $options['testing'] = Q_Config::expect('Assets', 'payments', $lcpayments, 'testing');
            $action = $options['action'] = $testing ? "https://test.authorize.net/profile/manage" : "https://secure.authorize.net/profile/manage";
            break;
        case 'Stripe':
            $publishableKey = Q_Config::expect('Assets', 'payments', 'stripe', 'publishableKey');
            break;
    }
    $titles = array('Authnet' => 'Authorize.net', 'Stripe' => 'Stripe');
    Q_Response::setToolOptions($options);
    $payButton = Q::ifset($options, 'payButton', "Pay with " . $titles[$payments]);
    return Q::view("Assets/tool/payment/{$payments}.php", compact('token', 'publishableKey', 'action', 'payButton'));
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:59,代码来源:tool.php

示例11: getConn

 /**
  * 获得一个数据库连接对象
  *
  * $dsn_name 参数指定要使用应用程序设置中的哪一个项目作为创建数据库连接的 DSN 信息。
  * 对于同样的 DSN 信息,只会返回一个数据库连接对象。
  *
  * @param string $dsn_name
  *
  * @return QDB_Adapter_Abstract
  */
 static function getConn($dsn_name = null)
 {
     $default = empty($dsn_name);
     if ($default && Q::isRegistered('dbo_default')) {
         return Q::registry('dbo_default');
     }
     if (empty($dsn_name)) {
         $dsn = Q::getIni('db_dsn_pool/default');
     } else {
         $dsn = Q::getIni('db_dsn_pool/' . $dsn_name);
     }
     if (empty($dsn)) {
         // LC_MSG: Invalid DSN.
         trigger_error('invalid dsn');
         throw new QException(__('Invalid DSN.'));
     }
     $dbtype = $dsn['driver'];
     $objid = "dbo_{$dbtype}_" . md5(serialize($dsn));
     if (Q::isRegistered($objid)) {
         return Q::registry($objid);
     }
     $class_name = 'QDB_Adapter_' . ucfirst($dbtype);
     $dbo = new $class_name($dsn, $objid);
     Q::register($dbo, $objid);
     if ($default) {
         Q::register($dbo, 'dbo_default');
     }
     return $dbo;
 }
开发者ID:fchaose,项目名称:qeephp,代码行数:39,代码来源:qdb.php

示例12: Websites_seo_post

function Websites_seo_post()
{
    if (empty($_REQUEST['streamName'])) {
        throw new Q_Exception_RequiredField(array('field' => 'streamName'));
    }
    $prefix = "Websites/seo/";
    if (substr($_REQUEST['streamName'], 0, strlen($prefix)) !== $prefix) {
        throw new Q_Exception_WrongValue(array('field' => 'streamName', 'range' => "string beginning with {$prefix}"));
    }
    $user = Users::loggedInUser(true);
    $publisherId = Users::communityId();
    $type = "Websites/seo";
    if (!Streams::isAuthorizedToCreate($user->id, $publisherId, $type)) {
        throw new Users_Exception_NotAuthorized();
    }
    $stream = new Streams_Stream($publisherId);
    $stream->publisherId = $publisherId;
    $stream->name = $_REQUEST['streamName'];
    $stream->type = $type;
    if (isset($_REQUEST['uri'])) {
        $stream->setAttribute('uri', $_REQUEST['uri']);
    }
    $stream->save();
    $stream->post($user->id, array('type' => 'Streams/created', 'content' => '', 'instructions' => Q::json_encode($stream->toArray())), true);
    $stream->subscribe();
    // autosubscribe to streams you yourself create, using templates
    Q_Response::setSlot('stream', $stream->exportArray());
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:28,代码来源:post.php

示例13: testRegisterAutoLoad

 /**
  * 测试注册自动载入方法
  */
 function testRegisterAutoLoad()
 {
     Q::registerAutoload(__CLASS__);
     $obj = new Class3();
     Q::registerAutoLoad(__CLASS__, false);
     $this->assertFalse(class_exists('Class4'));
 }
开发者ID:BGCX262,项目名称:zys-blog-svn-to-git,代码行数:10,代码来源:loadclass.php

示例14: Q_file_post

/**
 * Used by HTTP clients to upload a new file to the server
 * @class Q/file
 * @method post
 * @param {array} [$params] Parameters that can come from the request
 *   @param {string} [$params.data]  Required if $_FILES is empty. Base64-encoded image data URI - see RFC 2397
 *   @param {string} [$params.path="uploads"] parent path under web dir (see subpath)
 *   @param {string} [$params.subpath=""] subpath that should follow the path, to save the image under
 *   @param {string} [$params.name] override the name of the file, after the subpath
 */
function Q_file_post($params = null)
{
    $p = $params ? $params : Q::take($_REQUEST, array('data', 'path', 'subpath'));
    if (!empty($_FILES)) {
        $file = reset($_FILES);
        if ($tmp = $file['tmp_name']) {
            if (empty($p['data'])) {
                $p['data'] = file_get_contents($tmp);
                $p['name'] = $file['name'];
            }
            unlink($tmp);
        }
    } else {
        if (empty($p['data'])) {
            throw new Q_Exception_RequiredField(array('field' => 'data'), 'data');
        }
        $p['data'] = base64_decode(chunk_split(substr($p['data'], strpos($p['data'], ',') + 1)));
    }
    $timeLimit = Q_Config::get('Q', 'uploads', 'limits', 'file', 'time', 5 * 60 * 60);
    set_time_limit($timeLimit);
    // default is 5 min
    $data = Q_File::save($p);
    if (empty($params)) {
        Q_Response::setSlot('data', $data);
    }
    return $data;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:37,代码来源:post.php

示例15: Q_expandable_tool

/**
 * This tool implements expandable containers that work on most modern browsers,
 * including ones on touchscreens.
 * @class Q expandable
 * @constructor
 * @param {array} $options Options for the tool
 * @param {string} $options.title Required. The title for the expandable.
 * @param {string} $options.content The content. Required unless you pass "items" instead.
 * @param {array} [$options.items] An array of strings to wrap in <span> elements and render in the content
 * @param {string} [$options.class] If you use "items", optionally specify the class of the container elements for each item
 * @param {integer} [$options.title] A number, if any, to display when collapsed
 * @param {boolean} [$options.autoCollapseSiblings]  Whether, when expanding an expandable, its siblings should be automatically collapsed.
 */
function Q_expandable_tool($options)
{
    if (isset($options['items'])) {
        $classString = isset($options['class']) ? "class='{$options['class']}'" : '';
        $lines = array();
        foreach ($options['items'] as $key => $value) {
            $lines[] = "<span {$classString}>{$key}</span>";
        }
        $between = Q::ifset($options, 'between', '');
        $options['content'] = implode($between, $lines);
    }
    foreach (array('title', 'content') as $field) {
        if (!isset($options[$field])) {
            throw new Q_Exception_RequiredField(compact('field'));
        }
    }
    Q_Response::addScript('plugins/Q/js/tools/expandable.js');
    Q_Response::addStylesheet('plugins/Q/css/expandable.css');
    $count = Q::ifset($options, 'count', '');
    $style = empty($options['expanded']) ? '' : 'style="display:block"';
    $h2 = "<h2>\n\t<span class='Q_expandable_count'>{$count}</span>\n\t{$options['title']}\n</h2>";
    $div = "<div class='Q_expandable_container' {$style}><div class='Q_expandable_content'>\n\t{$options['content']}\n</div></div>";
    Q_Response::setToolOptions($options);
    return $h2 . $div;
}
开发者ID:AndreyTepaykin,项目名称:Platform,代码行数:38,代码来源:tool.php


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