/** * Renders a user status area which displays logged in status and provides various user-related operations. * @param $options * An associative array of parameters, which can include: * "icon" => Optional. Icon for the login button. Defaults to Qbix icon. * "label" => Optional. Text for the login button. Defaults to 'log in'. * "logoutIcon" => Optional. Icon for 'Log out' item in the tool menu. * "menuItems" => Optional. Additional menu items beside 'Log out' which will be shown in user menu. * Should be an array of hashes like { 'contents': 'value', 'action': 'value' }. * "onCancel" => Optional. Function, string function name or Q.Event. Called when user was unable to login or cancelled login dialog. * "onLogin" => Optional. Function or Q.Event. Called when user successfully logged it. * "onLogout" => Optional. Function, string function name or Q.Event. Called when user successfully logged out. * "onMenuSelect" => Optional. Function, string function name or Q.Event. * Called when user selected some item from user selected some item from user menu except 'Log out'. * @return {string} */ function Users_status_tool($options) { $defaults = array('icon' => 'plugins/Q/img/ui/qbix_icon' . (Q_Request::isMobile() ? '_small' : '') . '.png', 'label' => 'log in', 'logoutIcon' => null, 'menuItems' => array(), 'onCancel' => null, 'onLogin' => null, 'onLogout' => null, 'onMenuSelect' => null); $options = array_merge($defaults, $options); Q_Response::addStylesheet('plugins/Q/css/Q.css'); Q_Response::addStylesheet('plugins/Users/css/Users.css'); Q_Response::setToolOptions($options); return Q::view('Users/tool/status/status.php', $options); }
/** * This tool contains functionality to show things in columns * @class Q columns * @constructor * @param {array} [options] Provide options for this tool * @param {array} [options.animation] For customizing animated transitions * @param {integer} [options.animation.duration] The duration of the transition in milliseconds, defaults to 500 * @param {array} [options.animation.hide] The css properties in "hide" state of animation * @param {array} [options.animation.show] The css properties in "show" state of animation * @param {array} [options.back] For customizing the back button on mobile * @param {string} [options.back.src] The src of the image to use for the back button * @param {boolean} [options.back.triggerFromTitle] Whether the whole title would be a trigger for the back button. Defaults to true. * @param {boolean} [options.back.hide] Whether to hide the back button. Defaults to false, but you can pass true on android, for example. * @param {array} [options.close] For customizing the back button on desktop and tablet * @param {string} [options.close.src] The src of the image to use for the close button * @param {string} [options.title] You can put a default title for all columns here (which is shown as they are loading) * @param {string} [options.column] You can put a default content for all columns here (which is shown as they are loading) * @param {array} [options.clickable] If not null, enables the Q/clickable tool with options from here. Defaults to null. * @param {array} [options.scrollbarsAutoHide] If not null, enables Q/scrollbarsAutoHide functionality with options from here. Enabled by default. * @param {boolean} [options.fullscreen] Whether to use fullscreen mode on mobile phones, using document to scroll instead of relying on possibly buggy "overflow" CSS implementation. Defaults to true on Android, false everywhere else. * @param {array} [options.columns] In PHP only, an array of $name => $column pairs, where $column is in the form array('title' => $html, 'content' => $html, 'close' => true) * @return {string} */ function Q_columns_tool($options) { $jsOptions = array('animation', 'back', 'close', 'title', 'scrollbarsAutoHide', 'fullscreen'); Q_Response::setToolOptions(Q::take($options, $jsOptions)); if (!isset($options['columns'])) { return ''; } Q_Response::addScript('plugins/Q/js/tools/columns.js'); Q_Response::addStylesheet('plugins/Q/css/columns.css'); $result = '<div class="Q_columns_container Q_clearfix">'; $columns = array(); $i = 0; $closeSrc = Q::ifset($options, 'close', 'src', 'plugins/Q/img/x.png'); $backSrc = Q::ifset($options, 'back', 'src', 'plugins/Q/img/back-v.png'); foreach ($options['columns'] as $name => $column) { $close = Q::ifset($column, 'close', $i > 0); $Q_close = Q_Request::isMobile() ? 'Q_close' : 'Q_close Q_back'; $closeHtml = !$close ? '' : (Q_Request::isMobile() ? '<div class="Q_close Q_back">' . Q_Html::img($backSrc, 'Back') . '</div>' : '<div class="Q_close">' . Q_Html::img($closeSrc, 'Close') . '</div>'); $n = Q_Html::text($name); $columnClass = 'Q_column_' . Q_Utils::normalize($name) . ' Q_column_' . $i; if (isset($column['html'])) { $html = $column['html']; $columns[] = <<<EOT \t<div class="Q_columns_column {$columnClass}" data-index="{$i}" data-name="{$n}"> \t\t{$html} \t</div> EOT; } else { $titleHtml = Q::ifset($column, 'title', '[title]'); $columnHtml = Q::ifset($column, 'column', '[column]'); $classes = $columnClass . ' ' . Q::ifset($column, 'class', ''); $attrs = ''; if (isset($column['data'])) { $json = Q::json_encode($column['data']); $attrs = 'data-more="' . Q_Html::text($json) . '"'; foreach ($column['data'] as $k => $v) { $attrs .= 'data-' . Q_Html::text($k) . '="' . Q_Html::text($v) . '" '; } } $data = Q::ifset($column, 'data', ''); $columns[] = <<<EOT \t<div class="Q_columns_column {$classes}" data-index="{$i}" data-name="{$n}" {$attrs}> \t\t<div class="Q_columns_title"> \t\t\t{$closeHtml} \t\t\t<h2 class="Q_title_slot">{$titleHtml}</h2> \t\t</div> \t\t<div class="Q_column_slot">{$columnHtml}</div> \t</div> EOT; } ++$i; } $result .= "\n" . implode("\n", $columns) . "\n</div>"; return $result; }
function Users_device_post() { $user = Users::loggedInUser(true); $token = isset($_REQUEST['token']) ? $_REQUEST['token'] : null; $platform = Q_Request::platform(); $version = Q_Request::OSVersion(); $formFactor = Q_Request::isMobile() ? 'mobile' : (Q_Request::isTablet() ? 'tablet' : null); $device = new Users_Device(); $device->userId = $user->id; $device->deviceId = $token; $device->platform = $platform; $device->version = $version; $device->formFactor = $formFactor; $device->sessionId = Q_Session::id(); $_SESSION['Users']['deviceId'] = $token; Q_Response::setSlot('data', !!$device->save(true)); Q_Utils::sendToNode(array("Q/method" => "Users/device", "userId" => $user->id, "deviceId" => $token)); }
/** * This tool renders ways to get in touch * * @param array [$options] An associative array of options, containing: * @param {string|Users_User} [$options.user] Required. The user object or id of the user exposing their primary identifiers for getting in touch. * @param {boolean|string} [$options.email] Pass true here to use the primary verified email address, if any. Or pass the string label for this button. * @param {string} [$options.emailSubject] Fill this if you want the email subject to be automatically filled in * @param {string} [$options.emailBody] Fill this if you want the email body to be automatically filled in * @param {boolean|string} [$options.sms] Pass true here to allow texting the primary verified mobile number, if any. Or pass the string label for this button. * @param {boolean|string} [$options.call] Pass true here to allow calling the primary verified mobile number, if any. Or pass the string label for this button. * @param {string} [$options.tag] The type of tag to use, defaults to "button" * @param {string} [$options.class] Any classes to add to the tags * @param {string} [$options.between] Any HTML to put between the elements */ function Users_getintouch_tool($options) { $tag = 'button'; $class = null; $between = ''; $user = null; $emailSubject = ''; $emailBody = ''; extract($options, EXTR_IF_EXISTS); if (!$user) { throw new Q_Exception_RequiredField(array('field' => 'user')); } if (is_string($user)) { $userId = $user; $user = Users_User::fetch($userId); if (!$user) { throw new Q_Exception_MissingRow(array('table' => 'user', 'criteria' => "id={$userId}")); } } $ways = array(); $email = $sms = $call = false; if (!empty($options['email']) and $user->emailAddress) { $email = is_string($options['email']) ? $options['email'] : "Email me"; $email = Q_Html::img("plugins/Users/img/email.png") . $email; $ways['email'] = Q_Html::tag($tag, array('id' => 'email', 'class' => $class), $email); Q_Response::setToolOptions(array('emailAddress' => Q_Utils::obfuscate($user->emailAddress), 'emailSubject' => Q_Utils::obfuscate($emailSubject), 'emailBody' => Q_Utils::obfuscate($emailBody))); } if (Q_Request::isMobile()) { $obfuscated_mobileNumber = Q_Utils::obfuscate($user->mobileNumber); if (!empty($options['sms']) and $user->mobileNumber) { $sms = is_string($options['sms']) ? $options['sms'] : "Text me"; $sms = Q_Html::img("plugins/Users/img/sms.png") . $sms; $ways['sms'] = Q_Html::tag($tag, array('id' => 'sms', 'class' => $class), $sms); Q_Response::setToolOptions(array('mobileNumber' => $obfuscated_mobileNumber)); } if (!empty($options['call']) and $user->mobileNumber) { $call = is_string($options['call']) ? $options['call'] : "Call me"; $call = Q_Html::img("plugins/Users/img/call.png") . $call; $ways['call'] = Q_Html::tag($tag, array('id' => 'call', 'class' => $class), $call); Q_Response::setToolOptions(array('mobileNumber' => $obfuscated_mobileNumber)); } } return implode($between, $ways); }
} ?> <div id="dashboard_user_contextual" class="Q_contextual" data-handler="MyApp.userContextual"> <ul class="Q_listing"> <?php if ($user) { ?> <?php if (!$user->mobileNumber) { ?> <li data-action="setIdentifier">set mobile number</li> <?php } elseif (!$user->emailAddress) { ?> <li data-action="setIdentifier">set email address</li> <?php } ?> <?php } ?> <li data-action="logout">log out</li> </ul> </div> </div> <?php echo Q::tool('Q/tabs', array('vertical' => !Q_Request::isMobile(), 'overflow' => array('content' => '{{html}}'), 'compact' => true, 'tabs' => array('welcome' => 'Welcome', 'about' => 'About'), 'urls' => array('welcome' => 'MyApp/welcome', 'about' => 'MyApp/about'))); ?> </div>
if ($user) { ?> <?php if (!$user->mobileNumber) { ?> <li data-action="setIdentifier">set mobile number</li> <?php } elseif (!$user->emailAddress) { ?> <li data-action="setIdentifier">set email address</li> <?php } ?> <?php } ?> <li data-action="logout">log out</li> </ul> </div> </div> <?php Q::tool('Q/tabs', array('vertical' => !Q_Request::isMobile(), 'overflow' => '{{html}}', 'compact' => true, 'tabs' => array('welcome' => 'Welcome', 'about' => 'About'), 'urls' => array('welcome' => 'First/welcome', 'about' => 'First/about'))); ?> <?php echo Q::tool(array('Q/tabs' => array('vertical' => !Q_Request::isMobile(), 'overflow' => '{{html}}', 'compact' => true, 'tabs' => array('welcome' => 'Welcome', 'about' => 'About'), 'urls' => array('welcome' => 'First/welcome', 'about' => 'First/about')), 'Streams/related' => array('publisher' => 'First', 'streamName' => 'Websites/articles', 'relationType' => 'article', 'creatable' => array('Websites/article' => array('title' => 'New Page')), 'editable' => 'title', '.Websites_article_preview_tool' => array('inplace' => array('inplace' => array('maxWidth' => '.Streams_preview_container', 'editOnClick' => false)), 'icon' => false), 'tag' => 'li')), 'dashboard'); ?> </div>
static function htmlAttributes() { $touchscreen = Q_Request::isTouchscreen() ? 'Q_touchscreen' : 'Q_notTouchscreen'; $mobile = Q_Request::isMobile() ? 'Q_mobile' : 'Q_notMobile'; $cordova = Q_Request::isCordova() ? 'Q_cordova' : 'Q_notCordova'; $platform = 'Q_' . Q_Request::platform(); $ie = Q_Request::isIE() ? 'Q_ie' : 'Q_notIE'; $ie8 = Q_Request::isIE(0, 8) ? 'Q_ie8OrBelow' : 'Q_notIE8OrBelow'; $uri = Q_Dispatcher::uri(); $classes = "{$uri->module} {$uri->module}_{$uri->action}"; $result = 'lang="en" prefix="og: http://ogp.me/ns# object: http://ogp.me/ns/object#" ' . "class='{$touchscreen} {$mobile} {$cordova} {$platform} {$ie} {$ie8} {$classes}'"; return $result; }
/** * Returns the string containing all the html attributes * @method htmlAttributes * @static * @return {string} */ static function htmlAttributes() { $touchscreen = Q_Request::isTouchscreen() ? 'Q_touchscreen' : 'Q_notTouchscreen'; $mobile = Q_Request::isMobile() ? 'Q_mobile' : 'Q_notMobile'; $cordova = Q_Request::isCordova() ? 'Q_cordova' : 'Q_notCordova'; $platform = 'Q_' . Q_Request::platform(); $ie = Q_Request::isIE() ? 'Q_ie' : 'Q_notIE'; $ie8 = Q_Request::isIE(0, 8) ? 'Q_ie8OrBelow' : 'Q_notIE8OrBelow'; $uri = Q_Dispatcher::uri(); $classes = "{$uri->module} {$uri->module}_{$uri->action}"; foreach (self::$htmlCssClasses as $k => $v) { $classes .= Q_Html::text(" {$k}"); } $language = self::language(); return 'lang="' . $language . '" ' . 'prefix="og: http://ogp.me/ns# object: http://ogp.me/ns/object#" ' . "class='{$touchscreen} {$mobile} {$cordova} {$platform} {$ie} {$ie8} {$classes}'"; }
/** * The names of slots that were requested, if any * @method slotNames * @static * @param {boolean} [$returnDefaults=false] If set to true, returns the array of slot names set in config field * named Q/response/$app/slotNames * in the event that slotNames was not specified at all in the request. * @return {array} */ static function slotNames($returnDefaults = false) { if (isset(self::$slotNames_override)) { return self::$slotNames_override; } if (null === Q_Request::special('slotNames', null)) { if ($returnDefaults !== true) { return null; } $slotNames = Q_Config::get('Q', 'response', 'slotNames', array('content', 'dashboard', 'title', 'notices')); if (Q_Request::isMobile()) { $mobile_slotNames = Q_Config::get('Q', 'response', 'mobileSlotNames', false); if ($mobile_slotNames) { $slotNames = $mobile_slotNames; } } return $slotNames; } $slotNames = Q_Request::special('slotNames', null); if (empty($slotNames)) { return array(); } if (is_string($slotNames)) { $arr = array(); foreach (explode(',', $slotNames) as $sn) { $arr[] = $sn; } $slotNames = $arr; } return $slotNames; }
static function htmlAttributes() { $touchscreen = Q_Request::isTouchscreen() ? 'Q_touchscreen' : 'Q_notTouchscreen'; $mobile = Q_Request::isMobile() ? 'Q_mobile' : 'Q_notMobile'; $ie = Q_Request::isIE() ? 'Q_ie' : 'Q_notIE'; $ie8 = Q_Request::isIE(0, 8) ? 'Q_ie8OrBelow' : 'Q_notIE8OrBelow'; $result = 'lang="en" prefix="og: http://ogp.me/ns# object: http://ogp.me/ns/object#" ' . "class='{$touchscreen} {$mobile} {$ie} {$ie8}'"; return $result; }
<div id='dashboard'> <div id="callUs"> <i class="fa fa-phone-square" style="font-size: 30px; color: #34ccff; position: relative; top: 5px;"></i> <span>CALL : (212) 434-0067</span> </div> <h1 class="Shipping_logo"> <?php echo Q_Html::img('img/logo/main-logo.png', 'Encompass Shipping'); ?> </h1> <?php echo Q::tool('Q/tabs', array('vertical' => !Q_Request::isMobile(), 'overflow' => '{{html}}', 'compact' => true, 'tabs' => $tabs, 'urls' => $urls, 'classes' => $classes)); ?> <div id="dashboard_user"> <?php if ($user) { ?> <?php echo Q::tool("Users/avatar", array('userId' => $user->id, 'icon' => 50, 'short' => true), 'dashboard'); ?> <?php } else { ?> <a href="#login" class="Shipping_login">log in</a> <?php } ?> <div id="dashboard_user_contextual" class="Q_contextual" data-handler="Shipping.userContextual"> <ul class="Q_listing">