本文整理汇总了PHP中QQN::NarroRole方法的典型用法代码示例。如果您正苦于以下问题:PHP QQN::NarroRole方法的具体用法?PHP QQN::NarroRole怎么用?PHP QQN::NarroRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQN
的用法示例。
在下文中一共展示了QQN::NarroRole方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($objParentObject, $strControlId = null)
{
// Call the Parent
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
$this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroRoleListPanel.tpl.php';
$this->pnlRolePermissions = new NarroRolePermissionPanel($this);
if (QApplication::QueryString('r')) {
$this->pnlRolePermissions->Role = NarroRole::Load(QApplication::QueryString('r'));
}
$this->pnlRoleUsers = new NarroRoleUserListPanel($this);
if ($this->pnlRolePermissions->Role instanceof NarroRole) {
$this->pnlRoleUsers->Role = $this->pnlRolePermissions->Role;
}
switch (QApplication::QueryString('view')) {
case 'permission':
$this->pnlRolePermissions->Display = QDisplayStyle::Inline;
$this->pnlRoleUsers->Display = QDisplayStyle::None;
break;
case 'user':
$this->pnlRolePermissions->Display = QDisplayStyle::None;
$this->pnlRoleUsers->Display = QDisplayStyle::Inline;
break;
default:
$this->pnlRolePermissions->Display = QDisplayStyle::None;
$this->pnlRoleUsers->Display = QDisplayStyle::None;
}
// Setup DataGrid Columns
$this->colRoleName = new QDataGridColumn(t('Role'), '<?= $_CONTROL->ParentControl->dtgRole_RoleNameColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroRole()->RoleName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroRole()->RoleName, false)));
$this->colRoleName->HtmlEntities = false;
$this->colActions = new QDataGridColumn(t('Actions'), '<?= $_CONTROL->ParentControl->dtgRole_Actions_Render($_ITEM) ?>');
$this->colActions->HtmlEntities = false;
// Setup DataGrid
$this->dtgRole = new NarroDataGrid($this);
$this->dtgRole->Title = t('Roles');
// Specify Whether or Not to Refresh using Ajax
$this->dtgRole->UseAjax = false;
// Specify the local databind method this datagrid will use
$this->dtgRole->SetDataBinder('dtgRole_Bind', $this);
$this->dtgRole->AddColumn($this->colRoleName);
$this->dtgRole->AddColumn($this->colActions);
$this->dtgRole->SortColumnIndex = 0;
}
示例2: ResolveContentItem
/**
* Used internally by the Meta-based Add Column tools.
*
* Given a QQNode or a Text String, this will return a NarroRole-based QQNode.
* It will also verify that it is a proper NarroRole-based QQNode, and will throw an exception otherwise.
*
* @param mixed $mixContent
* @return QQNode
*/
protected function ResolveContentItem($mixContent)
{
if ($mixContent instanceof QQNode) {
if (!$mixContent->_ParentNode) {
throw new QCallerException('Content QQNode cannot be a Top Level Node');
}
if ($mixContent->_RootTableName == 'narro_role') {
if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
$objCurrentNode = $mixContent;
while ($objCurrentNode = $objCurrentNode->_ParentNode) {
if (!$objCurrentNode instanceof QQNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
}
return $mixContent;
} else {
throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "narro_role".');
}
} else {
if (is_string($mixContent)) {
switch ($mixContent) {
case 'RoleId':
return QQN::NarroRole()->RoleId;
case 'RoleName':
return QQN::NarroRole()->RoleName;
default:
throw new QCallerException('Simple Property not found in NarroRoleDataGrid content: ' . $mixContent);
}
} else {
if ($mixContent instanceof QQAssociationNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
} else {
throw new QCallerException('Invalid Content type');
}
}
}
}
示例3: CreateNarroTemplate
private function CreateNarroTemplate($intProjectId)
{
$strPoFile = __DOCROOT__ . __SUBDIRECTORY__ . '/locale/' . $this->objSourceLanguage->LanguageCode . '/narro.po';
NarroLogger::LogInfo(sprintf('Building a narro gettext template in %s.', $strPoFile));
$arrPermissions = NarroPermission::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroPermission()->PermissionName)));
NarroLogger::LogInfo(sprintf('Found %d permission names to localize.', count($arrPermissions)));
$arrRoles = NarroRole::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::NarroRole()->RoleName)));
NarroLogger::LogInfo(sprintf('Found %d role names to localize.', count($arrRoles)));
$allFiles = NarroUtils::ListDirectory(realpath(dirname(__FILE__) . '/../../..'), null, '/.*\\/drafts\\/.*|.*\\/data\\/.*|.*\\/examples\\/.*|.*\\/qcubed_generated\\/.*/');
NarroLogger::LogInfo(sprintf('Found %d php files to search for localizable messages.', count($allFiles)));
foreach ($allFiles as $strFileName) {
if (pathinfo($strFileName, PATHINFO_EXTENSION) != 'php') {
continue;
}
$strFile = file_get_contents($strFileName);
$strShortPath = str_ireplace(realpath(__DOCROOT__ . __SUBDIRECTORY__) . '/', '', $strFileName);
if (strpos($strShortPath, 'data') === 0) {
continue;
}
if (strpos($strShortPath, 'includes/qcubed_generated') === 0) {
continue;
}
$strFile = str_replace("\\'", "&&&escapedsimplequote&&&", $strFile);
$strFile = str_replace('\\"', "&&&escapeddoublequote&&&", $strFile);
if ($strFile) {
preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\']([^\']{2,})[\']\\s*\\)/', $strFile, $arrMatches);
if (isset($arrMatches[2])) {
foreach ($arrMatches[2] as $intMatchNo => $strText) {
if (trim($strText) != '') {
$strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
$arrMessages[md5($strText)]['text'] = $strText;
$arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
$strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
$arrMessages[md5($strText)]['context'] = '#. ';
foreach ($arrFullMatches[0] as $strFullMatch) {
if (trim($strFullMatch)) {
$arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
}
}
}
}
}
preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\\"]([^\\"]{2,})[\\"]\\s*\\)/', $strFile, $arrMatches);
if (isset($arrMatches[2])) {
foreach ($arrMatches[2] as $intMatchNo => $strText) {
if (trim($strText) != '') {
$strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
$arrMessages[md5($strText)]['text'] = $strText;
$arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
$strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
$arrMessages[md5($strText)]['context'] = '#. ';
foreach ($arrFullMatches[0] as $strFullMatch) {
if (trim($strFullMatch)) {
$arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
}
}
}
}
}
preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\']([^\']{2,})[\']\\s*,\\s*[\']([^\']{2,})[\']\\s*,\\s*([^\\)]+)\\s*\\)/', $strFile, $arrMatches);
if (isset($arrMatches[2])) {
foreach ($arrMatches[2] as $intMatchNo => $strText) {
if (trim($strText) != '') {
$strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
$arrMessages[md5($strText)]['text'] = $strText;
$arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
$arrMessages[md5($strText)]['plural'] = $arrMatches[3][$intMatchNo];
$strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
$arrMessages[md5($strText)]['context'] = '#. ';
foreach ($arrFullMatches[0] as $strFullMatch) {
if (trim($strFullMatch)) {
$arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
}
}
}
}
}
preg_match_all('/([^a-zA-Z]t|NarroApp::Translate|QApplication::Translate|__t)\\s*\\(\\s*[\\"]([^\\"]{2,})[\\"]\\s*,\\s*[\\"]([^\\"]{2,})[\\"]\\s*,\\s*([^\\)]+)\\s*\\)/', $strFile, $arrMatches);
if (isset($arrMatches[2])) {
foreach ($arrMatches[2] as $intMatchNo => $strText) {
if (trim($strText) != '') {
$strText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $strText);
$arrMessages[md5($strText)]['text'] = $strText;
$arrMessages[md5($strText)]['files'][$strShortPath] = $strShortPath;
$arrMessages[md5($strText)]['plural'] = $arrMatches[3][$intMatchNo];
$strSearchText = str_replace(array("&&&escapedsimplequote&&&", "&&&escapeddoublequote&&&"), array("'", '\\"'), $arrMatches[0][$intMatchNo]);
preg_match_all('/^.*' . preg_quote($strSearchText, '/') . '.*$/m', $strFile, $arrFullMatches);
$arrMessages[md5($strText)]['context'] = '#. ';
foreach ($arrFullMatches[0] as $strFullMatch) {
if (trim($strFullMatch)) {
$arrMessages[md5($strText)]['context'] .= trim($strFullMatch) . "\n";
}
}
}
}
}
preg_match_all('/NarroApp::RegisterPreference\\(\\s*\'([^\']+)\'\\s*,\\s*\'[^\']+\'\\s*,\\s*\'([^\']+)\'\\s*,\\s*/', $strFile, $arrMatches);
//.........这里部分代码省略.........
示例4: __construct
public function __construct($objUser, $objParentObject, $strControlId = null)
{
// Call the Parent
try {
parent::__construct($objParentObject, $strControlId);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
$this->strTemplate = __NARRO_INCLUDES__ . '/narro/panel/NarroUserRolePanel.tpl.php';
$this->objUser = $objUser;
// Setup DataGrid Columns
$this->colLanguage = new QDataGridColumn(t('Language'), '<?= $_CONTROL->ParentControl->dtgUserRole_LanguageColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Language->LanguageName, false)));
$this->colLanguage->HtmlEntities = false;
$this->colProject = new QDataGridColumn(t('Project'), '<?= $_CONTROL->ParentControl->dtgUserRole_ProjectColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Project->ProjectName, false)));
$this->colProject->HtmlEntities = false;
$this->colRole = new QDataGridColumn(t('Roles'), '<?= $_CONTROL->ParentControl->dtgUserRole_RoleColumn_Render($_ITEM) ?>', array('OrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName), 'ReverseOrderByClause' => QQ::OrderBy(QQN::NarroUserRole()->Role->RoleName, false)));
$this->colRole->HtmlEntities = false;
$this->colActions = new QDataGridColumn(t('Actions'), '<?= $_CONTROL->ParentControl->dtgUserRole_ActionsColumn_Render($_ITEM) ?>');
$this->colActions->HtmlEntities = false;
// Setup DataGrid
$this->dtgUserRole = new NarroDataGrid($this);
$this->dtgUserRole->Title = sprintf(t('<b>%s</b>\'s roles'), NarroLink::UserProfile($this->objUser->UserId, $this->objUser->RealName));
$this->dtgUserRole->ShowHeader = true;
$this->dtgUserRole->Paginator = new QPaginator($this->dtgUserRole);
$this->dtgUserRole->PaginatorAlternate = new QPaginator($this->dtgUserRole);
$this->dtgUserRole->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page');
// Specify Whether or Not to Refresh using Ajax
$this->dtgUserRole->UseAjax = QApplication::$UseAjax;
// Specify the local databind method this datagrid will use
$this->dtgUserRole->SetDataBinder('dtgUserRole_Bind', $this);
$this->dtgUserRole->AddColumn($this->colLanguage);
$this->dtgUserRole->AddColumn($this->colProject);
$this->dtgUserRole->AddColumn($this->colRole);
$this->lstLanguage = new QListBox($this);
$this->lstLanguage->AddItem('Any');
foreach (NarroLanguage::LoadAllActive(array(QQ::OrderBy(QQN::NarroLanguage()->LanguageName))) as $objNarroLanguage) {
if (QApplication::HasPermission('Can manage user roles', null, $objNarroLanguage->LanguageId)) {
$this->blnCanManageSomeRoles = true;
}
$this->lstLanguage->AddItem($objNarroLanguage->LanguageName, $objNarroLanguage->LanguageId);
}
$this->lstLanguage->SelectedValue = QApplication::GetLanguageId();
$this->lstProject = new QListBox($this);
$this->lstProject->AddItem('Any');
foreach (NarroProject::QueryArray(QQ::Equal(QQN::NarroProject()->Active, 1), array(QQ::OrderBy(QQN::NarroProject()->ProjectName))) as $objNarroProject) {
if (QApplication::HasPermission('Can manage user roles', $objNarroProject->ProjectId)) {
$this->blnCanManageSomeRoles = true;
}
$this->lstProject->AddItem($objNarroProject->ProjectName, $objNarroProject->ProjectId);
}
if (!$this->blnCanManageSomeRoles && QApplication::HasPermission('Can manage user roles')) {
$this->blnCanManageSomeRoles = true;
}
if ($this->blnCanManageSomeRoles) {
$this->dtgUserRole->AddColumn($this->colActions);
}
$this->lstRole = new QListBox($this);
foreach (NarroRole::LoadAll(array(QQ::OrderBy(QQN::NarroRole()->RoleName))) as $objNarroRole) {
if ($objNarroRole->RoleName == 'Administrator' && !QApplication::HasPermission('Administrator')) {
continue;
}
$this->lstRole->AddItem($objNarroRole->RoleName, $objNarroRole->RoleId);
}
$this->btnAddRole = new QButton($this);
$this->btnAddRole->Text = t('Add');
$this->btnAddRole->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnAddRole_Click'));
}
示例5: LoadByRoleName
/**
* Load a single NarroRole object,
* by RoleName Index(es)
* @param string $strRoleName
* @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
* @return NarroRole
*/
public static function LoadByRoleName($strRoleName, $objOptionalClauses = null)
{
return NarroRole::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroRole()->RoleName, $strRoleName)), $objOptionalClauses);
}