本文整理汇总了PHP中Zikula_View::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::getInstance方法的具体用法?PHP Zikula_View::getInstance怎么用?PHP Zikula_View::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zikula_View
的用法示例。
在下文中一共展示了Zikula_View::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent($args)
{
switch ($args['pluginid']) {
case 1:
//$uid = $args['uid'];
// Get matching news stories published since last newsletter
// No selection on categories made !!
$items = ModUtil::apiFunc('News', 'user', 'getall',
array('numitems' => $this->getVar('itemsperpage'),
'status' => 0,
'from' => DateUtil::getDatetime($args['last']),
'filterbydate' => true));
if ($items != false) {
if ($args['contenttype'] == 't') {
$counter = 0;
$output.="\n";
foreach ($items as $item) {
$counter++;
$output .= $counter . '. ' . $item['title'] . " (" . $this->__f('by %1$s on %2$s', array($item['contributor'], DateUtil::formatDatetime($item['from'], 'datebrief'))) . ")\n";
}
} else {
$render = Zikula_View::getInstance('News');
$render->assign('readperm', SecurityUtil::checkPermission('News::', "::", ACCESS_READ));
$render->assign('articles', $items);
$output = $render->fetch('mailz/listarticles.tpl');
}
} else {
$output = $this->__f('No News publisher articles since last newsletter on %s.', DateUtil::formatDatetime($args['last'], 'datebrief')) . "\n";
}
return $output;
}
return '';
}
示例2: validateCategoryData
/**
* Validate the data for a category
*
* @param array $data The data for the category.
*
* @return boolean true/false Whether the provided data is valid.
*/
public static function validateCategoryData($data)
{
$view = \Zikula_View::getInstance();
if (empty($data['name'])) {
$msg = $view->__('Error! You did not enter a name for the category.');
\LogUtil::registerError($msg);
return false;
}
if (empty($data['parent_id'])) {
$msg = $view->__('Error! You did not provide a parent for the category.');
\LogUtil::registerError($msg);
return false;
}
// get entity manager
$em = \ServiceUtil::get('doctrine')->getManager();
// process name
$data['name'] = self::processCategoryName($data['name']);
// check that we don't have another category with the same name
// on the same level
$dql = "\n SELECT count(c.id)\n FROM Zikula\\Core\\Doctrine\\Entity\\Category c\n WHERE c.name = '" . $data['name'] . "'\n AND c.parent = " . $data['parent_id'];
if (isset($data['id']) && is_numeric($data['id'])) {
$dql .= " AND c.id <> " . $data['id'];
}
$query = $em->createQuery($dql);
$exists = (int) $query->getSingleScalarResult();
if ($exists > 0) {
$msg = $view->__f('Category %s must be unique under parent', $data['name']);
\LogUtil::registerError($msg);
return false;
}
return true;
}
示例3: setup
/**
* Post constructor hook.
*
* @return void
*/
public function setup()
{
$this->view = \Zikula_View::getInstance(self::MODULENAME, false);
// set caching off
$this->_em = \ServiceUtil::get('doctrine.entitymanager');
$this->domain = \ZLanguage::getModuleDomain(self::MODULENAME);
}
示例4: esborra
/**
* Delete a topic from the database
* @author: Albert Pï¿œrez Monfort (aperezm@xtec.cat)
* @param: args The id of the topic
* @return: true if success and false if fails
*/
public function esborra($args) {
$tid = FormUtil::getPassedValue('tid', isset($args['tid']) ? $args['tid'] : null, 'POST');
// Security check
if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Argument check
if (!isset($tid) || !is_numeric($tid)) {
return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
}
// Get the item
$item = ModUtil::apiFunc('IWnoteboard', 'user', 'gettema', array('tid' => $tid));
if (!$item) {
return LogUtil::registerError($this->__('No such item found.'));
}
if (!DBUtil::deleteObjectByID('IWnoteboard_topics', $tid, 'tid')) {
return LogUtil::registerError($this->__('Error! Sorry! Deletion attempt failed.'));
}
// The item has been deleted, so we clear all cached pages of this item.
$view = Zikula_View::getInstance('IWnoteboard');
$view->clear_cache(null, $tid);
return true;
}
示例5: validateCategoryData
/**
* Validate the data for a category
*
* @param array $data The data for the category.
*
* @return boolean true/false Whether the provided data is valid.
*
* @throws \InvalidArgumentException Thrown if no category name is provided or
* if no parent is defined for the category
* @throws \RuntimeException Thrown if a category of the same anme already exists under the parent
*/
public static function validateCategoryData($data)
{
$view = \Zikula_View::getInstance();
if (empty($data['name'])) {
throw new \InvalidArgumentException(__('Error! You did not enter a name for the category.'));
}
if (empty($data['parent_id'])) {
throw new \InvalidArgumentException('Error! You did not provide a parent for the category.');
}
// get entity manager
$em = \ServiceUtil::get('doctrine.entitymanager');
// process name
$data['name'] = self::processCategoryName($data['name']);
// check that we don't have another category with the same name
// on the same level
$qb = $em->createQueryBuilder();
$qb->select('count(c.id)')->from('ZikulaCategoriesModule:CategoryEntity', 'c')->where('c.name = :name')->andWhere('c.parent = :parentid')->setParameter('name', $data['name'])->setParameter('parentid', $data['parent_id']);
if (isset($data['id']) && is_numeric($data['id'])) {
$qb->andWhere('c.id <> :id')->setParameter('id', $data['id']);
}
$query = $qb->getQuery();
$exists = (int) $query->getSingleScalarResult();
if ($exists > 0) {
throw new \RuntimeException($view->__f('Category %s must be unique under parent', $data['name']));
}
return true;
}
示例6: display
public function display($blockinfo) {
// Security check (1)
if (!SecurityUtil::checkPermission('IWmenu:topblock:', "$blockinfo[title]::", ACCESS_READ)) {
return false;
}
// Check if the module is available. (2)
if (!ModUtil::available('IWmenu')) {
return false;
}
// Get variables from content block (3)
//Get cached user menu
$uid = is_null(UserUtil::getVar('uid')) ? '-1' : UserUtil::getVar('uid');
//Generate menu
$menu_estructure = ModUtil::apiFunc('IWmenu', 'user', 'getMenuStructure');
// Defaults (4)
if (empty($menu_estructure)) {
return false;
}
// Create output object (6)
$view = Zikula_View::getInstance('IWmenu');
// assign your data to to the template (7)
$view->assign('menu', $menu_estructure);
// Populate block info and pass to theme (8)
$menu = $view->fetch('IWmenu_block_top.htm');
//$blockinfo['content'] = $menu;
//return BlockUtil::themesideblock($blockinfo);
return $menu;
}
示例7: search
public function search(){
// Check permission
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_READ));
//path to zk jquery lib
$js = new JCSSUtil;
$scripts = $js->scriptsMap();
$jquery = $scripts['jquery']['path'];
// Omplim les llistes desplegables del fromulari
$cursos = ModUtil::apiFunc('Llicencies', 'user', 'getYears');
$temes = ModUtil::apiFunc('Llicencies', 'user', 'getTopicList');
$subtemes = ModUtil::apiFunc('Llicencies', 'user', 'getSubtopicList');
$tipus = ModUtil::apiFunc('Llicencies', 'user', 'getTypeList');
$view = Zikula_View::getInstance($this->name);
$view->assign('jquery' , $jquery);
$view->assign('cursos' , $cursos);
$view->assign('temes' , $temes);
$view->assign('subtemes', $subtemes);
$view->assign('tipus' , $tipus);
$view->assign('admin' , false);
// Carreagr el formulari per a fer la cerca de llicències d'estudi
return $this->view->display('Llicencies_main.tpl');
}
示例8: smarty_modifier_yesno
/**
* Zikula_View modifier to turn a boolean value into a suitable language string
*
* Example
*
* {$myvar|yesno|safetext} returns Yes if $myvar = 1 and No if $myvar = 0
*
* @param string $string The contents to transform.
* @param boolean $images Display the yes/no response as tick/cross.
*
* @return string Rhe modified output.
*/
function smarty_modifier_yesno($string, $images = false)
{
if ($string != '0' && $string != '1') {
return $string;
}
if ($images) {
$view = Zikula_View::getInstance();
require_once $view->_get_plugin_filepath('function', 'img');
$params = array('modname' => 'core', 'set' => 'icons/extrasmall');
}
if ((bool) $string) {
if ($images) {
$params['src'] = 'button_ok.png';
$params['alt'] = $params['title'] = __('Yes');
return smarty_function_img($params, $view);
} else {
return __('Yes');
}
} else {
if ($images) {
$params['src'] = 'button_cancel.png';
$params['alt'] = $params['title'] = __('No');
return smarty_function_img($params, $view);
} else {
return __('No');
}
}
}
示例9: pageLock
public function pageLock($args)
{
$lockName = $args['lockName'];
$returnUrl = (array_key_exists('returnUrl', $args) ? $args['returnUrl'] : null);
$ignoreEmptyLock = (array_key_exists('ignoreEmptyLock', $args) ? $args['ignoreEmptyLock'] : false);
$uname = UserUtil::getVar('uname');
$lockedHtml = '';
if (!empty($lockName) || !$ignoreEmptyLock) {
PageUtil::AddVar('javascript', 'zikula.ui');
PageUtil::AddVar('javascript', 'system/PageLock/javascript/pagelock.js');
PageUtil::AddVar('stylesheet', ThemeUtil::getModuleStylesheet('pagelock'));
$lockInfo = ModUtil::apiFunc('pagelock', 'user', 'requireLock',
array('lockName' => $lockName,
'lockedByTitle' => $uname,
'lockedByIPNo' => $_SERVER['REMOTE_ADDR']));
$hasLock = $lockInfo['hasLock'];
if (!$hasLock) {
$view = Zikula_View::getInstance('pagelock');
$view->assign('lockedBy', $lockInfo['lockedBy']);
$lockedHtml = $view->fetch('PageLock_lockedwindow.tpl');
}
} else {
$hasLock = true;
}
$html = "<script type=\"text/javascript\">/* <![CDATA[ */ \n";
if (!empty($lockName)) {
if ($hasLock) {
$html .= "document.observe('dom:loaded', PageLock.UnlockedPage);\n";
} else {
$html .= "document.observe('dom:loaded', PageLock.LockedPage);\n";
}
}
$lockedHtml = str_replace("\n", "", $lockedHtml);
$lockedHtml = str_replace("\r", "", $lockedHtml);
// Use "PageLockLifetime*2/3" to add a good margin to lock timeout when pinging
// disabled due to #2556 and #2745
// $returnUrl = DataUtil::formatForDisplayHTML($returnUrl);
$html .= "
PageLock.LockName = '$lockName';
PageLock.ReturnUrl = '$returnUrl';
PageLock.PingTime = " . (PageLockLifetime*2/3) . ";
PageLock.LockedHTML = '" . $lockedHtml . "';
/* ]]> */</script>";
PageUtil::addVar('header', $html);
return true;
}
示例10: getView
public function getView()
{
if (!$this->view) {
$this->view = Zikula_View::getInstance($this->name);
}
return $this->view;
}
示例11: setView
/**
* Set view property.
*
* @param Zikula_View $view Default null means new Render instance for this module name.
*
* @return Zikula_AbstractController
*/
protected function setView(Zikula_View $view = null)
{
if (is_null($view)) {
$view = Zikula_View::getInstance($this->getName());
}
$this->view = $view;
return $this;
}
示例12: IWqv_qvsummaryblock_display
/**
* Gets qv summary information
*
* @author: Sara Arjona Téllez (sarjona@xtec.cat)
*/
function IWqv_qvsummaryblock_display($row) {
// Security check
if (!SecurityUtil::checkPermission('IWqv:summaryBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
return false;
}
$uid = UserUtil::getVar('uid');
if (!isset($uid))
$uid = '-1';
// Get the qvsummary saved in the user vars. It is renovate every 10 minutes
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'qvsummary',
'module' => 'IWqv',
'uid' => $uid,
'sv' => $sv));
if ($exists) {
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
'name' => 'qvsummary',
'module' => 'IWqv',
'sv' => $sv,
'nult' => true));
} else {
$teacherassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("teacher" => $uid));
$studentassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("student" => $uid));
if (empty($teacherassignments) && empty($studentassignments)) {
}
$view = Zikula_View::getInstance('IWqv', false);
$view->assign('teacherassignments', $teacherassignments);
$view->assign('studentassignments', $studentassignments);
$view->assign('isblock', true);
$s = $view->fetch('IWqv_block_summary.htm');
if (empty($teacherassignments) && empty($studentassignments)) {
$s = '';
}
//Copy the block information into user vars
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid,
'name' => 'qvsummary',
'module' => 'IWqv',
'sv' => $sv,
'value' => $s,
'lifetime' => '2000'));
}
if ($s == '') {
return false;
}
$row['content'] = $s;
return BlockUtil::themesideblock($row);
}
示例13: display
/**
* Gets topics information
*
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @author Josep Ferràndiz Farré (jferran6@xtec.cat)
*/
public function display($row) {
// Security check
if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) {
return false;
}
$uid = UserUtil::getVar('uid');
//Check if user belongs to change group. If not the block is not showed
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$isMember = ModUtil::func('IWmain', 'user', 'isMember',
array('sv' => $sv,
'gid' => ModUtil::getVar('IWmyrole', 'rolegroup'),
'uid' => $uid));
if (!$isMember) {
return false;
}
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$uidGroups = ModUtil::func('IWmain', 'user', 'getAllUserGroups',
array('sv' => $sv,
'uid' => $uid));
foreach ($uidGroups as $g) {
$originalGroups[$g['id']] = 1;
}
$view = Zikula_View::getInstance('IWmyrole', false);
// Gets the groups
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$allGroups = ModUtil::func('IWmain', 'user', 'getAllGroups',
array('sv' => $sv,
'less' => ModUtil::getVar('IWmyrole', 'rolegroup')));
$groupsNotChangeable = ModUtil::getVar('IWmyrole', 'groupsNotChangeable');
foreach ($allGroups as $group) {
if (strpos($groupsNotChangeable, '$' . $group['id'] . '$') == false) $groupsArray[] = $group;
}
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$invalidChange = ModUtil::func('IWmain', 'user', 'userGetVar',
array('uid' => $uid,
'name' => 'invalidChange',
'module' => 'IWmyrole',
'nult' => true,
'sv' => $sv));
$view->assign('groups', $groupsArray);
$view->assign('invalidChange', $invalidChange);
$view->assign('roleGroups', $originalGroups);
$s = $view->fetch('IWmyrole_block_change.htm');
$row['content'] = $s;
return BlockUtil::themesideblock($row);
}
示例14: options
/**
* Display the search form.
*
* @param array $args List of arguments.
*
* @return string Template output
*/
public function options(array $args = array())
{
if (!SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) {
return '';
}
$view = Zikula_View::getInstance($this->name);
$view->assign('active_review', !isset($args['active_review']) || isset($args['active']['active_review']));
return $view->fetch('search/options.tpl');
}
示例15: uiResponse
public function uiResponse(DisplayHook $hook, $content)
{
// Arrrr, we are forced to use Smarty -.-
// We need to clone the instance, because it causes errors otherwise when multiple hooks areas are hooked.
$view = clone \Zikula_View::getInstance('CmfcmfMediaModule');
$view->setCaching(\Zikula_View::CACHE_DISABLED);
$view->assign('content', $content);
$hook->setResponse(new \Zikula_Response_DisplayHook($this->getProvider(), $view, 'dummy.tpl'));
}