本文整理汇总了PHP中ZLanguage::getLanguageCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ZLanguage::getLanguageCode方法的具体用法?PHP ZLanguage::getLanguageCode怎么用?PHP ZLanguage::getLanguageCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZLanguage
的用法示例。
在下文中一共展示了ZLanguage::getLanguageCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display block
*/
public function display($blockinfo)
{
if (!SecurityUtil::checkPermission('Zgoodies:marqueeblock:', "{$blockinfo['bid']}::", ACCESS_OVERVIEW)) {
return;
}
if (!ModUtil::available('Zgoodies')) {
return;
}
$vars = BlockUtil::varsFromContent($blockinfo['content']);
$lang = ZLanguage::getLanguageCode();
// block title
if (isset($vars['block_title'][$lang]) && !empty($vars['block_title'][$lang])) {
$blockinfo['title'] = $vars['block_title'][$lang];
}
// marquee content
if (isset($vars['marquee_content'][$lang]) && !empty($vars['marquee_content'][$lang])) {
$vars['marquee_content_lang'] = $vars['marquee_content'][$lang];
}
if (!isset($vars['marquee_content'])) {
$vars['marquee_content_lang'] = '';
}
$this->view->assign('vars', $vars);
$this->view->assign('bid', $blockinfo['bid']);
$blockinfo['content'] = $this->view->fetch('blocks/' . $vars['block_template']);
if (isset($vars['block_wrap']) && !$vars['block_wrap']) {
if (empty($blockinfo['title'])) {
return $blockinfo['content'];
} else {
return '<h4>' . DataUtil::formatForDisplayHTML($blockinfo['title']) . '</h4>' . "\n" . $blockinfo['content'];
}
}
return BlockUtil::themeBlock($blockinfo);
}
示例2: handleCommand
public function handleCommand(Zikula_Form_View $view, &$args)
{
if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_ADD)) {
throw new Zikula_Exception_Forbidden($this->__('Error! You have not been granted access to create pages.'));
}
if ($args['commandName'] == 'create') {
$pageData = $this->view->getValues();
$validators = $this->notifyHooks(new Zikula_ValidationHook('content.ui_hooks.pages.validate_edit', new Zikula_Hook_ValidationProviders()))->getValidators();
if (!$validators->hasErrors() && $this->view->isValid()) {
$id = ModUtil::apiFunc('Content', 'Page', 'newPage', array('page' => $pageData, 'pageId' => $this->pageId, 'location' => $this->location));
if ($id === false) {
return false;
}
// notify any hooks they may now commit the as the original form has been committed.
$objectUrl = new Zikula_ModUrl('Content', 'user', 'view', ZLanguage::getLanguageCode(), array('pid' => $this->pageId));
$this->notifyHooks(new Zikula_ProcessHook('content.ui_hooks.pages.process_edit', $this->pageId, $objectUrl));
} else {
return false;
}
$url = ModUtil::url('Content', 'admin', 'editPage', array('pid' => $id));
} else {
if ($args['commandName'] == 'cancel') {
$id = null;
$url = ModUtil::url('Content', 'admin', 'main');
}
}
return $this->view->redirect($url);
}
示例3: smarty_function_selector_user_category
/**
* User category selector.
*
* Available parameters:
* - btnText: If set, the results are assigned to the corresponding variable instead of printed out
* - cid: category ID
*
* Example
* {selector_user_category cid="1" assign="category"}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string HTML code of the selector.
*/
function smarty_function_selector_user_category($params, Zikula_View $view)
{
$field = isset($params['field']) ? $params['field'] : 'id';
$selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0;
$defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0;
$defaultText = isset($params['defaultText']) ? $params['defaultText'] : '';
$lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode();
$name = isset($params['name']) ? $params['name'] : 'defautlselectorname';
$recurse = isset($params['recurse']) ? $params['recurse'] : true;
$relative = isset($params['relative']) ? $params['relative'] : true;
$includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false;
$includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true;
$all = isset($params['all']) ? $params['all'] : false;
$displayPath = isset($params['displayPath']) ? $params['displayPath'] : false;
$attributes = isset($params['attributes']) ? $params['attributes'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
$editLink = isset($params['editLink']) ? $params['editLink'] : true;
$submit = isset($params['submit']) ? $params['submit'] : false;
$multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1;
$doReplaceRootCat = false;
$userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative));
$html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize);
if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) {
$url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser');
$html .= " <a href=\"{$url}\">" . __('Edit sub-categories') . '</a>';
}
if ($assign) {
$view->assign($assign, $html);
} else {
return $html;
}
}
示例4: smarty_function_manuallink
/**
* Zikula_View function to create manual link.
*
* This function creates a manual link from some parameters.
*
* Available parameters:
* - manual: name of manual file, manual.html if not set
* - chapter: an anchor in the manual file to jump to
* - newwindow: opens the manual in a new window using javascript
* - width: width of the window if newwindow is set, default 600
* - height: height of the window if newwindow is set, default 400
* - title: name of the new window if newwindow is set, default is modulename
* - class: class for use in the <a> tag
* - assign: if set, the results ( array('url', 'link') are assigned to the corresponding variable instead of printed out
*
* Example
* {manuallink newwindow=1 width=400 height=300 title=rtfm }
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string|void
*/
function smarty_function_manuallink($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('manuallink')), E_USER_DEPRECATED);
$userlang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
$stdlang = System::getVar('language_i18n');
$title = isset($params['title']) ? $params['title'] : 'Manual';
$manual = isset($params['manual']) ? $params['manual'] : 'manual.html';
$chapter = isset($params['chapter']) ? '#' . $params['chapter'] : '';
$class = isset($params['class']) ? 'class="' . $params['class'] . '"' : '';
$width = isset($params['width']) ? $params['width'] : 600;
$height = isset($params['height']) ? $params['height'] : 400;
$modname = ModUtil::getName();
$possibleplaces = array("modules/{$modname}/docs/{$userlang}/manual/{$manual}", "modules/{$modname}/docs/{$stdlang}/manual/{$manual}", "modules/{$modname}/docs/en/manual/{$manual}", "modules/{$modname}/docs/{$userlang}/{$manual}", "modules/{$modname}/docs/{$stdlang}/{$manual}", "modules/{$modname}/docs/lang/en/{$manual}");
foreach ($possibleplaces as $possibleplace) {
if (file_exists($possibleplace)) {
$url = $possibleplace . $chapter;
break;
}
}
if (isset($params['newwindow'])) {
$link = "<a {$class} href='#' onclick=\"window.open( '" . DataUtil::formatForDisplay($url) . "' , '" . DataUtil::formatForDisplay($modname) . "', 'status=yes,scrollbars=yes,resizable=yes,width={$width},height={$height}'); picwin.focus();\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
} else {
$link = "<a {$class} href=\"" . DataUtil::formatForDisplay($url) . "\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
}
if (isset($params['assign'])) {
$ret = array('url' => $url, 'link' => $link);
$view->assign($params['assign'], $ret);
return;
} else {
return $link;
}
}
示例5: renderDocument
/**
* Render and display the specified legal document, or redirect to the specified custom URL if it exists.
*
* If a custom URL for the legal document exists, as specified by the module variable identified by $customUrlKey, then
* this function will redirect the user to that URL.
*
* If no custom URL exists, then this function will render and return the appropriate template for the legal document, as
* specified by $documentName. If the legal document
*
* @param string $documentName The "name" of the document, as specified by the names of the user and text template
* files in the format 'legal_user_documentname.tpl' and 'legal_text_documentname.tpl'.
* @param string $accessInstanceKey The string used in the instance_right part of the permission access key for this document.
* @param string $activeFlagKey The string used to name the module variable that indicates whether this legal document is
* active or not; typically this is a constant from {@link Legal_Constant}, such as
* {@link Legal_Constant::MODVAR_LEGALNOTICE_ACTIVE}.
* @param string $customUrlKey The string used to name the module variable that contains a custom static URL for the
* legal document; typically this is a constant from {@link Legal_Constant}, such as
* {@link Legal_Constant::MODVAR_TERMS_URL}.
*
* @return string HTML output string
*
* @throws Zikula_Exception_Forbidden Thrown if the user does not have the appropriate access level for the function.
*/
private function renderDocument($documentName, $accessInstanceKey, $activeFlagKey, $customUrlKey)
{
// Security check
if (!SecurityUtil::checkPermission($this->name . '::' . $accessInstanceKey, '::', ACCESS_OVERVIEW)) {
throw new Zikula_Exception_Forbidden();
}
if (!$this->getVar($activeFlagKey)) {
return $this->view->fetch('legal_user_policynotactive.tpl');
} else {
$customUrl = $this->getVar($customUrlKey, '');
if (empty($customUrl)) {
// work out the template path
$template = "legal_user_{$documentName}.tpl";
// get the current users language
$languageCode = ZLanguage::transformFS(ZLanguage::getLanguageCode());
if (!$this->view->template_exists("{$languageCode}/legal_text_{$documentName}.tpl")) {
$languageCode = 'en';
}
return $this->view->assign('languageCode', $languageCode)
->fetch($template);
} else {
$this->redirect($customUrl);
}
}
}
示例6: search
/**
* Performs the actual search processing.
*/
public function search($args)
{
ModUtil::dbInfoLoad('Search');
$dbtables = DBUtil::getTables();
$pageTable = $dbtables['content_page'];
$pageColumn = $dbtables['content_page_column'];
$contentTable = $dbtables['content_content'];
$contentColumn = $dbtables['content_content_column'];
$contentSearchTable = $dbtables['content_searchable'];
$contentSearchColumn = $dbtables['content_searchable_column'];
$translatedPageTable = $dbtables['content_translatedpage'];
$translatedPageColumn = $dbtables['content_translatedpage_column'];
$sessionId = session_id();
// check whether we need to search also in translated content
$multilingual = System::getVar('multilingual');
$currentLanguage = ZLanguage::getLanguageCode();
$searchWhereClauses = array();
$searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')';
if ($multilingual) {
$searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')';
}
$searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')';
// add default filters
$whereClauses = array();
$whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')';
$whereClauses[] = $pageColumn['active'] . ' = 1';
$whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())";
$whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())";
$whereClauses[] = $contentColumn['active'] . ' = 1';
$whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1');
$titleFields = $pageColumn['title'];
$additionalJoins = '';
if ($multilingual) {
// if searching in non-default languages, we need the translated title
$titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle';
// join also the translation table if required
$additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'";
// prevent content snippets in other languages
$whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\'';
}
$where = implode(' AND ', $whereClauses);
$sql = "\n SELECT DISTINCT {$titleFields},\n {$contentSearchColumn['text']} AS description,\n {$pageColumn['id']} AS pageId,\n {$pageColumn['cr_date']} AS createdDate\n FROM {$pageTable}\n JOIN {$contentTable}\n ON {$contentColumn['pageId']} = {$pageColumn['id']}\n JOIN {$contentSearchTable}\n ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n {$additionalJoins}\n WHERE {$where}\n ";
$result = DBUtil::executeSQL($sql);
if (!$result) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
$objectArray = DBUtil::marshallObjects($result);
foreach ($objectArray as $object) {
$pageTitle = $object['page_title'];
if ($object['translatedTitle'] != '') {
$pageTitle = $object['translatedTitle'];
}
$searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId);
if (!\DBUtil::insertObject($searchItemData, 'search_result')) {
return \LogUtil::registerError($this->__('Error! Could not save the search results.'));
}
}
return true;
}
示例7: __construct
/**
* Constructor.
*
* @param KernelInterface $kernel
* @param RouterInterface $router The route generator
* @param EngineInterface $templatingService
* @param MarkdownExtra $parser
*/
public function __construct(KernelInterface $kernel, RouterInterface $router, EngineInterface $templatingService, MarkdownExtra $parser)
{
$this->kernel = $kernel;
$this->router = $router;
$this->templatingService = $templatingService;
$this->parser = $parser;
$this->locale = \ZLanguage::getLanguageCode();
}
示例8: smarty_function_assignedcategorieslist
/**
* Retrieve an HTML unordered list of the categories assigned to a specified item.
*
* The assigned categories are retrieved from $item['__CATEGORIES__'] (DBUtil) or $item['Categories'] (Doctrine).
* However, if we are using Doctrine 2, the categories are passed as param.
*
* Available attributes:
* - item (array) The item from which to retrieve the assigned categories.
* or
* - categories (object) The item's categories.
* - doctrine2 (boolean) true or false if using doctrine2 or not.
*
* Example:
*
* <samp>{assignedcategorieslist item=$myVar}</samp>
* <samp>{assignedcategorieslist categories=$myCategories doctrine2=true}</samp>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return string The HTML code for an unordered list containing the item's
* assigned categories. If no categories are assigned to the
* item, then the list will contain a single list-item (<li>)
* with a message to that effect.
*/
function smarty_function_assignedcategorieslist($params, Zikula_View $view)
{
if (isset($params['doctrine2']) && (bool) $params['doctrine2'] == true) {
if (!isset($params['categories'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assignedcategorieslist', 'categories')));
return false;
}
} elseif (!isset($params['item'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assignedcategorieslist', 'item')));
return false;
}
$lang = ZLanguage::getLanguageCode();
$result = "<ul>\n";
if (isset($params['doctrine2']) && (bool) $params['doctrine2'] == true) {
if (count($params['categories']) > 0) {
foreach ($params['categories'] as $category) {
$name = $category->getCategory()->getName();
$display_name = $category->getCategory()->getDisplayName();
$result .= "<li>\n";
if (isset($display_name[$lang]) && !empty($display_name[$lang])) {
$result .= $display_name[$lang];
} elseif (isset($name) && !empty($name)) {
$result .= $name;
}
$result .= "</li>\n";
}
} else {
$result .= '<li>' . DataUtil::formatForDisplay(__('No assigned categories.')) . '</li>';
}
} else {
if (isset($params['item']['Categories']) && !empty($params['item']['Categories'])) {
$categories = $params['item']['Categories'];
} elseif (isset($params['item']['__CATEGORIES__']) && !empty($params['item']['__CATEGORIES__'])) {
$categories = $params['item']['__CATEGORIES__'];
} else {
$categories = array();
}
if (!empty($categories)) {
foreach ($categories as $property => $category) {
if (isset($category['Category'])) {
$category = $category['Category'];
}
$result .= "<li>\n";
if (isset($category['display_name'][$lang])) {
$result .= $category['display_name'][$lang];
} elseif (isset($category['name'])) {
$result .= $category['name'];
}
$result .= "</li>\n";
}
} else {
$result .= '<li>' . DataUtil::formatForDisplay(__('No assigned categories.')) . '</li>';
}
}
$result .= "</ul>\n";
return $result;
}
示例9: initialize
public function initialize(Zikula_Form_View $view)
{
$this->contentId = (int) FormUtil::getPassedValue('cid', isset($this->args['cid']) ? $this->args['cid'] : -1);
$this->language = ZLanguage::getLanguageCode();
$content = ModUtil::apiFunc('Content', 'Content', 'getContent', array('id' => $this->contentId, 'language' => $this->language, 'translate' => false));
if ($content === false) {
return $this->view->registerError(null);
}
$this->contentType = ModUtil::apiFunc('Content', 'Content', 'getContentType', $content);
if ($this->contentType === false) {
return $this->view->registerError(null);
}
$this->pageId = $content['pageId'];
if ((bool) $this->getVar('inheritPermissions', false) === true) {
if (!ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $this->pageId, 'level' => ACCESS_EDIT))) {
throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
}
} else {
if (!SecurityUtil::checkPermission('Content:page:', $this->pageId . '::', ACCESS_EDIT)) {
throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
}
}
$page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId, 'includeContent' => false, 'filter' => array('checkActive' => false)));
if ($page === false) {
return $this->view->registerError(null);
}
if ($this->language == $page['language']) {
return $this->view->registerError(LogUtil::registerError($this->__f('Sorry, you cannot translate an item to the same language as it\'s default language ("%1$s"). Change the current site language ("%2$s") to some other language on the <a href="%3$s">localisation settings</a> page.<br /> Another way is to add, for instance, <strong>&lang=de</strong> to the url for changing the current site language to German and after that the item can be translated to German.', array($page['language'], $this->language, ModUtil::url('Settings', 'admin', 'multilingual')))));
}
$translationInfo = ModUtil::apiFunc('Content', 'Content', 'getTranslationInfo', array('contentId' => $this->contentId));
if ($translationInfo === false) {
return $this->view->registerError(null);
}
PageUtil::setVar('title', $this->__("Translate content item") . ' : ' . $page['title']);
$templates = $this->contentType['plugin']->getTranslationTemplates();
$this->view->assign('translationtemplates', $templates);
$this->view->assign('page', $page);
$this->view->assign('data', $content['data']);
$this->view->assign('isTranslatable', $content['isTranslatable']);
$this->view->assign('translated', isset($content['translated']) ? $content['translated'] : array());
$this->view->assign('translationInfo', $translationInfo);
$this->view->assign('translationStep', $this->contentId);
$this->view->assign('language', $this->language);
$this->view->assign('contentType', $this->contentType);
Content_Util::contentAddAccess($this->view, $this->pageId);
if (!$this->view->isPostBack() && FormUtil::getPassedValue('back', 0)) {
$this->backref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
}
if ($this->backref != null) {
$returnUrl = $this->backref;
} else {
$returnUrl = ModUtil::url('Content', 'admin', 'editpage', array('pid' => $this->pageId));
}
ModUtil::apiFunc('PageLock', 'user', 'pageLock', array('lockName' => "contentTranslateContent{$this->contentId}", 'returnUrl' => $returnUrl));
return true;
}
示例10: getInstance
/**
* Get Singleton instance.
*
* @param string $locale Locale.
*
* @return ZI18n object instance.
*/
public static function getInstance($locale = null)
{
if (!isset($locale)) {
$locale = ZLanguage::getLanguageCode();
}
if (!isset(self::$instance[$locale])) {
self::$instance[$locale] = new self(new ZLocale($locale));
}
return self::$instance[$locale];
}
示例11: getall
/**
* Gets all the notes created in the noteboard
* @author: Albert Pérez Monfort (aperezm@xtec.cat)
* @param: args $tema: it is used for filter the notes of a topyc
* $nid: if only a note is showed
* @return: And array with the items information
*/
public function getall($args) {
$tema = FormUtil::getPassedValue('tema', isset($args['tema']) ? $args['tema'] : null, 'POST');
$nid = FormUtil::getPassedValue('nid', isset($args['nid']) ? $args['nid'] : null, 'POST');
$marked = FormUtil::getPassedValue('marked', isset($args['marked']) ? $args['marked'] : null, 'POST');
$public = FormUtil::getPassedValue('public', isset($args['public']) ? $args['public'] : null, 'POST');
$sv = FormUtil::getPassedValue('sv', isset($args['sv']) ? $args['sv'] : null, 'POST');
$numitems = (isset($args['numitems'])) ? $args['numitems'] : '-1';
if (!ModUtil::func('IWmain', 'user', 'checkSecurityValue', array('sv' => $sv))) {
// Security check
if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
}
$pntable = DBUtil::getTables();
$c = $pntable['IWnoteboard_column'];
if (!isset($nid)) {
$time = time();
if ($tema > 0) {
$where = "$c[caduca] > $time AND $c[tid]=$tema";
} elseif ($tema == '-1') {
$where = "$c[caduca] > $time AND $c[tid]=0";
} else {
$where = "$c[caduca] > $time";
}
$orderby = "$c[edited] desc, $c[data] desc, $c[nid] desc";
} else {
$registre = ModUtil::apiFunc('IWnoteboard', 'user', 'get', array('nid' => $nid));
if ($registre == false) {
LogUtil::registerError($this->__('The note has not been found'));
return System::redirect(ModUtil::url('IWnoteboard', 'user', 'main'));
}
$where = "$c[nid]=$nid";
$orderby = '';
}
if (isset($marked) && $marked == 1) {
$where .= " AND $c[marca] like '%$" . UserUtil::getVar('uid') . "$%'";
}
if (isset($public) && $public == 1) {
$where .= " AND $c[public] = 1";
}
if (ModUtil::getVar('IWnoteboard', 'multiLanguage') == 1) {
$where .= " AND ($c[lang]='" . ZLanguage::getLanguageCode() . "' OR $c[lang] = '')";
}
// get the objects from the db
$items = DBUtil::selectObjectArray('IWnoteboard', $where, $orderby, '-1', $numitems, 'nid');
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($items === false) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
// Return the items
return $items;
}
示例12: display
/**
* This method provides a item detail view.
*
* @param string $tpl Name of alternative template (to be used instead of the default template).
* @param boolean $raw Optional way to display a template instead of fetching it (required for standalone output).
*
* @return mixed Output.
*/
public function display()
{
$legacyControllerType = $this->request->query->filter('lct', 'user', FILTER_SANITIZE_STRING);
System::queryStringSetVar('type', $legacyControllerType);
$this->request->query->set('type', $legacyControllerType);
$controllerHelper = new MUVideo_Util_Controller($this->serviceManager);
// parameter specifying which type of objects we are treating
$objectType = 'movie';
$utilArgs = array('controller' => 'movie', 'action' => 'display');
$permLevel = $legacyControllerType == 'admin' ? ACCESS_ADMIN : ACCESS_READ;
$this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', '::', $permLevel), LogUtil::getErrorMsgPermission());
$entityClass = $this->name . '_Entity_' . ucwords($objectType);
$repository = $this->entityManager->getRepository($entityClass);
$repository->setControllerArguments(array());
$idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType));
// retrieve identifier of the object we wish to view
$idValues = $controllerHelper->retrieveIdentifier($this->request, array(), $objectType, $idFields);
$hasIdentifier = $controllerHelper->isValidIdentifier($idValues);
$this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.'));
$selectionArgs = array('ot' => $objectType, 'id' => $idValues);
$entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', $selectionArgs);
$this->throwNotFoundUnless($entity != null, $this->__('No such item.'));
unset($idValues);
$entity->initWorkflow();
// build ModUrl instance for display hooks; also create identifier for permission check
$currentUrlArgs = $entity->createUrlArgs();
$instanceId = $entity->createCompositeIdentifier();
$currentUrlArgs['id'] = $instanceId;
// TODO remove this
$currentUrlObject = new Zikula_ModUrl($this->name, 'movie', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs);
$this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', $instanceId . '::', $permLevel), LogUtil::getErrorMsgPermission());
$viewHelper = new MUVideo_Util_View($this->serviceManager);
$templateFile = $viewHelper->getViewTemplate($this->view, $objectType, 'display', array());
// set cache id
$component = $this->name . ':' . ucwords($objectType) . ':';
$instance = $instanceId . '::';
$accessLevel = ACCESS_READ;
if (SecurityUtil::checkPermission($component, $instance, ACCESS_COMMENT)) {
$accessLevel = ACCESS_COMMENT;
}
if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) {
$accessLevel = ACCESS_EDIT;
}
$this->view->setCacheId($objectType . '|' . $instanceId . '|a' . $accessLevel);
// assign output data to view object.
$this->view->assign($objectType, $entity)->assign('currentUrlObject', $currentUrlObject)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs));
// initialize
$youtubeId = '';
// we get the id from the url
$youtubeId = explode('=', $entity['urlOfYoutube']);
// assign to template
$this->view->assign('youtubeId', $youtubeId[1]);
// fetch and return the appropriate template
return $viewHelper->processTemplate($this->view, $objectType, 'display', array(), $templateFile);
}
示例13: smarty_function_lang
/**
* Zikula_View function to get the site's language.
*
* Available parameters:
* - assign if set, the language will be assigned to this variable
*
* Example
* <html lang="{lang}">
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string|void The language, null if params['assign'] is true.
*/
function smarty_function_lang($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$fs = isset($params['fs']) ? $params['fs'] : false;
$result = $fs ? ZLanguage::transformFS(ZLanguage::getLanguageCode()) : ZLanguage::getLanguageCode();
if ($assign) {
$view->assign($assign, $result);
return;
}
return $result;
}
示例14: __construct
function __construct($registryId = null, $parentId = null)
{
if (!empty($parentId)) {
$this->parentId = $parentId;
} else {
$parentIdCategory = \CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Global');
$this->parentId = $parentIdCategory['id'];
}
$this->registryId = $registryId;
$this->lang = \ZLanguage::getLanguageCode();
}
示例15: Admin_Messages_admin_new
/**
* add a new admin message
* This is a standard function that is called whenever an administrator
* wishes to create a new module item
* @author Mark West
* @return string HTML output string
*/
function Admin_Messages_admin_new()
{
// Security check
if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
// Create output object
$view = Zikula_View::getInstance('Admin_Messages', false);
// Assign the default language
$view->assign('language', ZLanguage::getLanguageCode());
// Return the output that has been generated by this function
return $view->fetch('admin_messages_admin_new.htm');
}